@mux/mux-audio 0.9.5 → 0.9.6
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.cjs.js.map +4 -4
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +4 -4
- package/dist/mux-audio.js +46 -33
- package/dist/mux-audio.js.map +4 -4
- package/dist/mux-audio.mjs +46 -33
- package/dist/mux-audio.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/CustomAudioElement.d.ts +1 -4
- package/dist/types/polyfills/index.d.ts +4 -0
- package/dist/types-ts3.4/CustomAudioElement.d.ts +1 -3
- package/dist/types-ts3.4/polyfills/index.d.ts +4 -0
- package/package.json +6 -6
package/dist/mux-audio.js
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
|
-
"use strict";(()=>{var vs=Object.create;var Ta=Object.defineProperty;var gs=Object.getOwnPropertyDescriptor;var ps=Object.getOwnPropertyNames;var ms=Object.getPrototypeOf,ys=Object.prototype.hasOwnProperty;var ba=(N,W)=>()=>(W||N((W={exports:{}}).exports,W),W.exports);var Es=(N,W,x,fe)=>{if(W&&typeof W=="object"||typeof W=="function")for(let se of ps(W))!ys.call(N,se)&&se!==x&&Ta(N,se,{get:()=>W[se],enumerable:!(fe=gs(W,se))||fe.enumerable});return N};var _a=(N,W,x)=>(x=N!=null?vs(ms(N)):{},Es(W||!N||!N.__esModule?Ta(x,"default",{value:N,enumerable:!0}):x,N));var Kn=(N,W,x)=>{if(!W.has(N))throw TypeError("Cannot "+x)};var pr=(N,W,x)=>(Kn(N,W,"read from private field"),x?x.call(N):W.get(N)),Lr=(N,W,x)=>{if(W.has(N))throw TypeError("Cannot add the same private member more than once");W instanceof WeakSet?W.add(N):W.set(N,x)},Rr=(N,W,x,fe)=>(Kn(N,W,"write to private field"),fe?fe.call(N,x):W.set(N,x),x);var ii=(N,W,x)=>(Kn(N,W,"access private method"),x);var ka=ba((cn,Yn)=>{(function(){var N,W;N=this,W=function(){return function(){var x={80:function(X,M,j){X.exports=j(728).default},728:function(X,M,j){"use strict";j.d(M,{default:function(){return Ln}});var te=j(48),R=j.n(te),p=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(g){var h=16*Math.random()|0;return(g==="x"?h:3&h|8).toString(16)})},w=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},k=function(g){return g&&g.nodeName!==void 0?(g.muxId||(g.muxId=g.id||w()),g.muxId):g},me=function(g){var h;g&&g.nodeName!==void 0?g=k(h=g):h=document.querySelector(g);var f=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,g,f]},re=j(640),de=j.n(re),_e=de().methodFactory;de().methodFactory=function(g,h,f){var y=_e(g,h,f);return function(){for(var b=["[mux]"],O=0;O<arguments.length;O++)b.push(arguments[O]);y.apply(void 0,b)}},de().setLevel(de().getLevel());var K=de();function ve(){return(R().doNotTrack||R().navigator&&R().navigator.doNotTrack)==="1"}var $={now:function(){var g=R().performance,h=g&&g.timing,f=h&&h.navigationStart,y=typeof f=="number"&&typeof g.now=="function"?f+g.now():Date.now();return Math.round(y)}},ae=j(678),G=j.n(ae),Se=function(g){return ke(g)[0]},ke=function(g){if(typeof g!="string"||g==="")return["localhost"];var h,f=(g.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return f&&(h=(f.match(/[^\.]+\.[^\.]+$/)||[])[0]),[f,h]},je={exists:function(){var g=R().performance;return(g&&g.timing)!==void 0},domContentLoadedEventEnd:function(){var g=R().performance,h=g&&g.timing;return h&&h.domContentLoadedEventEnd},navigationStart:function(){var g=R().performance,h=g&&g.timing;return h&&h.navigationStart}};function V(g,h,f){f=f===void 0?1:f,g[h]=g[h]||0,g[h]+=f}var E=["x-cdn","content-type","x-request-id"];function U(g){var h={};return(g=g||"").trim().split(/[\r\n]+/).forEach(function(f){if(f){var y=f.split(": "),b=y.shift();b&&(E.indexOf(b.toLowerCase())>=0||b.toLowerCase().indexOf("x-litix-")===0)&&(h[b]=y.join(": "))}}),h}var A=function(g){var h={};for(var f in g){var y=g[f];y["DATA-ID"].search("io.litix.data.")!==-1&&(h[y["DATA-ID"].replace("io.litix.data.","")]=y.VALUE)}return h};function ue(g,h){var f=Object.keys(g);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(g);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(g,b).enumerable})),f.push.apply(f,y)}return f}function Te(g){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?ue(Object(f),!0).forEach(function(y){J(g,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(f)):ue(Object(f)).forEach(function(y){Object.defineProperty(g,y,Object.getOwnPropertyDescriptor(f,y))})}return g}function J(g,h,f){return h in g?Object.defineProperty(g,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):g[h]=f,g}var z=function(g){if(!g)return{};var h=je.navigationStart(),f=g.loading,y=f?f.start:g.trequest,b=f?f.first:g.tfirst,O=f?f.end:g.tload;return{bytesLoaded:g.total,requestStart:Math.round(h+y),responseStart:Math.round(h+b),responseEnd:Math.round(h+O)}},De=function(g){if(g&&typeof g.getAllResponseHeaders=="function")return U(g.getAllResponseHeaders())};function Re(g,h){var f=Object.keys(g);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(g);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(g,b).enumerable})),f.push.apply(f,y)}return f}function Oe(g){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?Re(Object(f),!0).forEach(function(y){ye(g,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(f)):Re(Object(f)).forEach(function(y){Object.defineProperty(g,y,Object.getOwnPropertyDescriptor(f,y))})}return g}function ye(g,h,f){return h in g?Object.defineProperty(g,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):g[h]=f,g}var qe=function(g,h){if(!g||typeof g.getRequests!="function")return{};var f=g.getRequests({state:"executed"});if(f.length===0)return{};var y,b=f[f.length-1],O=Se(b.url),D=b.url,H=b.bytesLoaded,le=new Date(b.requestStartDate).getTime(),Z=new Date(b.firstByteDate).getTime(),Ce=new Date(b.requestEndDate).getTime(),at=isNaN(b.duration)?0:b.duration,Je=typeof h.getMetricsFor=="function"?h.getMetricsFor(b.mediaType).HttpList:h.getDashMetrics().getHttpRequests(b.mediaType);return Je.length>0&&(y=U(Je[Je.length-1]._responseHeaders||"")),{requestStart:le,requestResponseStart:Z,requestResponseEnd:Ce,requestBytesLoaded:H,requestResponseHeaders:y,requestMediaDuration:at,requestHostname:O,requestUrl:D}},tt=function(g,h){var f=h.getQualityFor(g),y=h.getCurrentTrackFor(g).bitrateList;return y?{currentLevel:f,renditionWidth:y[f].width||null,renditionHeight:y[f].height||null,renditionBitrate:y[f].bandwidth}:{}},ie=function(g){var h;return(h=g.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function ce(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var ne=0,xe=function(){function g(){(function(b,O){if(!(b instanceof O))throw new TypeError("Cannot call a class as a function")})(this,g)}var h,f,y;return h=g,f=[{key:"on",value:function(b,O,D){return O._eventEmitterGuid=O._eventEmitterGuid||++ne,this._listeners=this._listeners||{},this._listeners[b]=this._listeners[b]||[],D&&(O=O.bind(D)),this._listeners[b].push(O),O}},{key:"off",value:function(b,O){var D=this._listeners&&this._listeners[b];D&&D.forEach(function(H,le){H._eventEmitterGuid===O._eventEmitterGuid&&D.splice(le,1)})}},{key:"one",value:function(b,O,D){var H=this;O._eventEmitterGuid=O._eventEmitterGuid||++ne;var le=function Z(){H.off(b,Z),O.apply(D||this,arguments)};le._eventEmitterGuid=O._eventEmitterGuid,this.on(b,le)}},{key:"emit",value:function(b,O){var D=this;if(this._listeners){O=O||{};var H=this._listeners["before*"]||[],le=this._listeners[b]||[],Z=this._listeners["after"+b]||[],Ce=function(at,Je){(at=at.slice()).forEach(function(it){it.call(D,{type:b},Je)})};Ce(H,O),Ce(le,O),Ce(Z,O)}}}],f&&ce(h.prototype,f),y&&ce(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}(),Pe=xe;function Ne(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Be=function(){function g(b){var O=this;(function(D,H){if(!(D instanceof H))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,b.on("playing",function(){O._playheadShouldBeProgressing=!0}),b.on("play",this._startPlaybackHeartbeatInterval.bind(this)),b.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),b.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),b.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),b.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("seeked",function(){b.data.player_is_paused?O._stopPlaybackHeartbeatInterval():O._startPlaybackHeartbeatInterval()}),b.on("timeupdate",function(){O._playbackHeartbeatInterval!==null&&b.emit("playbackheartbeat")}),b.on("devicesleep",function(D,H){O._playbackHeartbeatInterval!==null&&(R().clearInterval(O._playbackHeartbeatInterval),b.emit("playbackheartbeatend",{viewer_time:H.viewer_time}),O._playbackHeartbeatInterval=null)})}var h,f,y;return h=g,(f=[{key:"_startPlaybackHeartbeatInterval",value:function(){var b=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=R().setInterval(function(){b.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(R().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Ne(h.prototype,f),y&&Ne(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function Ke(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function pe(g,h,f){return h&&Ke(g.prototype,h),f&&Ke(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var Ie=pe(function g(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,g),h.on("viewinit",function(){f.viewErrored=!1}),h.on("error",function(y,b){try{var O=h.errorTranslator({player_error_code:b.player_error_code,player_error_message:b.player_error_message,player_error_context:b.player_error_context});O?(h.data.player_error_code=O.player_error_code||b.player_error_code,h.data.player_error_message=O.player_error_message||b.player_error_message,h.data.player_error_context=O.player_error_context||b.player_error_context,f.viewErrored=!0):(delete h.data.player_error_code,delete h.data.player_error_message,delete h.data.player_error_context)}catch(D){h.mux.log.warn("Exception in error translator callback.",D),f.viewErrored=!0}})});function Ye(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var rt=function(){function g(b){(function(O,D){if(!(O instanceof D))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,this._watchTimeTrackerLastCheckedTime=null,b.on("playbackheartbeat",this._updateWatchTime.bind(this)),b.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var h,f,y;return h=g,(f=[{key:"_updateWatchTime",value:function(b,O){var D=O.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=D),V(this.pm.data,"view_watch_time",D-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=D}},{key:"_clearWatchTimeState",value:function(b,O){this._updateWatchTime(b,O),this._watchTimeTrackerLastCheckedTime=null}}])&&Ye(h.prototype,f),y&&Ye(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function yt(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var ht=function(){function g(b){(function(O,D){if(!(O instanceof D))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,this._playbackTimeTrackerLastPlayheadPosition=-1,b.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),b.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),b.on("seeking",this._clearPlaybackTimeState.bind(this))}var h,f,y;return h=g,(f=[{key:"_updatePlaybackTime",value:function(){var b=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&b>this._playbackTimeTrackerLastPlayheadPosition){var O=b-this._playbackTimeTrackerLastPlayheadPosition;O<=1e3&&V(this.pm.data,"view_content_playback_time",O)}this._playbackTimeTrackerLastPlayheadPosition=b}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&yt(h.prototype,f),y&&yt(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function It(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Lt=function(){function g(b){(function(D,H){if(!(D instanceof H))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b;var O=this._updatePlayheadTime.bind(this);b.on("playbackheartbeat",O),b.on("playbackheartbeatend",O),b.on("timeupdate",O),b.on("destroy",function(){b.off("timeupdate",O)})}var h,f,y;return h=g,(f=[{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(b,O){var D=this,H=function(){D.pm.currentFragmentPDT&&D.pm.currentFragmentStart&&(D.pm.data.player_program_time=D.pm.currentFragmentPDT+D.pm.data.player_playhead_time-D.pm.currentFragmentStart)};if(O&&O.player_playhead_time)this.pm.data.player_playhead_time=O.player_playhead_time,H(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var le=this.pm.getPlayheadTime();le!==void 0&&(this.pm.data.player_playhead_time=le,H(),this._updateMaxPlayheadPosition())}}}])&&It(h.prototype,f),y&&It(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function St(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function At(g,h,f){return h&&St(g.prototype,h),f&&St(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var pt=At(function g(h){if(function(O,D){if(!(O instanceof D))throw new TypeError("Cannot call a class as a function")}(this,g),!h.disableRebufferTracking){var f,y=function(O,D){b(D),f=void 0},b=function(O){if(f){var D=O.viewer_time-f;V(h.data,"view_rebuffer_duration",D),f=O.viewer_time}h.data.view_watch_time>=0&&h.data.view_rebuffer_count>0&&(h.data.view_rebuffer_frequency=h.data.view_rebuffer_count/h.data.view_watch_time,h.data.view_rebuffer_percentage=h.data.view_rebuffer_duration/h.data.view_watch_time)};h.on("playbackheartbeat",function(O,D){return b(D)}),h.on("rebufferstart",function(O,D){f||(V(h.data,"view_rebuffer_count",1),f=D.viewer_time,h.one("rebufferend",y))}),h.on("viewinit",function(){f=void 0,h.off("rebufferend",y)})}});function ut(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Rt=function(){function g(b){var O=this;(function(D,H){if(!(D instanceof H))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,b.disableRebufferTracking||b.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,b.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),b.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),b.on("seeking",function(){O._cleanupRebufferTracker(null,{viewer_time:$.now()})}))}var h,f,y;return h=g,f=[{key:"_checkIfRebuffering",value:function(b,O){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(b,O);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var D=O.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&D>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=O.viewer_time}else this._cleanupRebufferTracker(b,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(b){this._lastCheckedTime=b,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=b}},{key:"_cleanupRebufferTracker",value:function(b,O){var D=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 H=this.pm.data.player_playhead_time-this._lastPlayheadTime,le=O.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&H>0&&le-H>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+le-H}))}D?this._prepareRebufferTrackerState(O.viewer_time):this._clearRebufferTrackerState()}}],f&&ut(h.prototype,f),y&&ut(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}(),Ct=Rt;function Ht(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Qt=function(){function g(b){var O=this;(function(D,H){if(!(D instanceof H))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,b.on("viewinit",function(){var D=b.data,H=D.view_id;if(!D.view_program_changed){var le=function(Z,Ce){var at=Ce.viewer_time;Z.type==="playing"&&b.data.view_time_to_first_frame===void 0?O.calculateTimeToFirstFrame(at||$.now(),H):Z.type!=="adplaying"||b.data.view_time_to_first_frame!==void 0&&!O._inPrerollPosition()||O.calculateTimeToFirstFrame(at||$.now(),H)};b.one("playing",le),b.one("adplaying",le),b.one("viewend",function(){b.off("playing",le),b.off("adplaying",le)})}})}var h,f,y;return h=g,(f=[{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(b,O){O===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:b}),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))}}])&&Ht(h.prototype,f),y&&Ht(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function Ut(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function ur(g,h,f){return h&&Ut(g.prototype,h),f&&Ut(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var ee=ur(function g(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,g),h.on("viewinit",function(){f._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(y){h.on(y,function(){if(f._lastPlayheadPosition>=0&&h.data.player_playhead_time>=0&&f._lastPlayerWidth>=0&&f._lastSourceWidth>0&&f._lastPlayerHeight>=0&&f._lastSourceHeight>0){var b=h.data.player_playhead_time-f._lastPlayheadPosition;if(b<0)return void(f._lastPlayheadPosition=-1);var O=Math.min(f._lastPlayerWidth/f._lastSourceWidth,f._lastPlayerHeight/f._lastSourceHeight),D=Math.max(0,O-1),H=Math.max(0,1-O);h.data.view_max_upscale_percentage=Math.max(h.data.view_max_upscale_percentage||0,D),h.data.view_max_downscale_percentage=Math.max(h.data.view_max_downscale_percentage||0,H),V(h.data,"view_total_content_playback_time",b),V(h.data,"view_total_upscaling",D*b),V(h.data,"view_total_downscaling",H*b)}f._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(y){h.on(y,function(){f._lastPlayheadPosition=h.data.player_playhead_time,f._lastPlayerWidth=h.data.player_width,f._lastPlayerHeight=h.data.player_height,f._lastSourceWidth=h.data.video_source_width,f._lastSourceHeight=h.data.video_source_height})})});function F(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function T(g,h,f){return h&&F(g.prototype,h),f&&F(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var C=T(function g(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,g),this.isSeeking=!1,h.on("seeking",function(y,b){G()(h.data,b),f._lastSeekingTime=$.now(),f.isSeeking===!1&&(f.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){f.isSeeking=!1;var y=f._lastSeekingTime||$.now(),b=$.now()-y;V(h.data,"view_seek_count",1),V(h.data,"view_seek_duration",b);var O=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(O,b)}),h.on("viewend",function(){f.isSeeking=!1})});function L(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var O,D,H=[],le=!0,Z=!1;try{for(b=b.call(f);!(le=(O=b.next()).done)&&(H.push(O.value),!y||H.length!==y);le=!0);}catch(Ce){Z=!0,D=Ce}finally{try{le||b.return==null||b.return()}finally{if(Z)throw D}}return H}}(g,h)||function(f,y){if(f){if(typeof f=="string")return B(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?B(f,y):void 0}}(g,h)||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 B(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}function Y(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Q=function(g,h){g.push(h),g.sort(function(f,y){return f.viewer_time-y.viewer_time})},ge=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],we=function(){function g(b){var O=this;(function(H,le){if(!(H instanceof le))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,b.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}),ge.forEach(function(H){return b.on(H,O._updateAdData.bind(O))});var D=function(){O.isAdBreak=!1};b.on("adbreakstart",function(){O.isAdBreak=!0}),b.on("play",D),b.on("playing",D),b.on("viewend",D),b.on("adrequest",function(H,le){le=G()({ad_request_id:"generatedAdRequestId"+O._currentAdRequestNumber++},le),Q(O._adRequests,le),V(b.data,"view_ad_request_count"),O.inPrerollPosition()&&(b.data.view_preroll_requested=!0,O._adHasPlayed||V(b.data,"view_preroll_request_count"))}),b.on("adresponse",function(H,le){le=G()({ad_request_id:"generatedAdRequestId"+O._currentAdResponseNumber++},le),Q(O._adResponses,le);var Z=O.findAdRequest(le.ad_request_id);Z&&V(b.data,"view_ad_request_time",Math.max(0,le.viewer_time-Z.viewer_time))}),b.on("adplay",function(H,le){O._adHasPlayed=!0,O._wouldBeNewAdPlay&&(O._wouldBeNewAdPlay=!1,V(b.data,"view_ad_played_count")),O.inPrerollPosition()&&!b.data.view_preroll_played&&(b.data.view_preroll_played=!0,O._adRequests.length>0&&(b.data.view_preroll_request_time=Math.max(0,le.viewer_time-O._adRequests[0].viewer_time)),b.data.view_start&&(b.data.view_startup_preroll_request_time=Math.max(0,le.viewer_time-b.data.view_start)),O._prerollPlayTime=le.viewer_time)}),b.on("adplaying",function(H,le){O.inPrerollPosition()&&b.data.view_preroll_load_time===void 0&&O._prerollPlayTime!==void 0&&(b.data.view_preroll_load_time=le.viewer_time-O._prerollPlayTime,b.data.view_startup_preroll_load_time=le.viewer_time-O._prerollPlayTime)}),b.on("adended",function(){O._wouldBeNewAdPlay=!0}),b.on("aderror",function(){O._wouldBeNewAdPlay=!0})}var h,f,y;return h=g,(f=[{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(b){for(var O=0;O<this._adRequests.length;O++)if(this._adRequests[O].ad_request_id===b)return this._adRequests[O]}},{key:"_updateAdData",value:function(b,O){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&O.ad_tag_url){var D=L(ke(O.ad_tag_url),2),H=D[0],le=D[1];this.pm.data.view_preroll_ad_tag_domain=le,this.pm.data.view_preroll_ad_tag_hostname=H}if(!this.pm.data.view_preroll_ad_asset_hostname&&O.ad_asset_url){var Z=L(ke(O.ad_asset_url),2),Ce=Z[0],at=Z[1];this.pm.data.view_preroll_ad_asset_domain=at,this.pm.data.view_preroll_ad_asset_hostname=Ce}}}}])&&Y(h.prototype,f),y&&Y(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function Le(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function Fe(g,h,f){return h&&Le(g.prototype,h),f&&Le(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var Ve=Fe(function g(h){var f,y;(function(H,le){if(!(H instanceof le))throw new TypeError("Cannot call a class as a function")})(this,g);var b=function(){h.disableRebufferTracking||f&&(V(h.data,"view_waiting_rebuffer_duration",$.now()-f),f=!1,R().clearInterval(y))},O=!1,D=function(){O=!1,b()};h.on("waiting",function(){O&&(h.disableRebufferTracking||(V(h.data,"view_waiting_rebuffer_count",1),f=$.now(),y=R().setInterval(function(){if(f){var H=$.now();V(h.data,"view_waiting_rebuffer_duration",H-f),f=H}},250)))}),h.on("playing",function(){b(),O=!0}),h.on("pause",D),h.on("seeking",D)});function Ue(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function Qe(g,h,f){return h&&Ue(g.prototype,h),f&&Ue(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var ot=Qe(function g(h){var f=this;(function(O,D){if(!(O instanceof D))throw new TypeError("Cannot call a class as a function")})(this,g);var y=function(){f.lastWallClockTime=$.now(),h.on("before*",b)},b=function(O){var D=$.now(),H=f.lastWallClockTime;f.lastWallClockTime=D,D-H>3e4&&(h.emit("devicesleep",{viewer_time:H}),G()(h.data,{viewer_time:H}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:D}),G()(h.data,{viewer_time:D}),h.send("devicewake"))};h.one("playbackheartbeat",y),h.on("playbackheartbeatend",function(){h.off("before*",b),h.one("playbackheartbeat",y)})}),bt=j(375),We=j(655),kt=j.n(We),Jt="muxData",Ft=function(){var g;try{g=bt.parse(kt().get(Jt)||"")}catch{g={}}return g},Pt=function(g){try{kt().set(Jt,bt.stringify(g),{expires:7300})}catch{}},Bt=function(){var g=Ft();return g.mux_viewer_id=g.mux_viewer_id||p(),g.msn=g.msn||Math.random(),Pt(g),{mux_viewer_id:g.mux_viewer_id,mux_sample_number:g.msn}};function Ze(g,h){var f=h.beaconCollectionDomain,y=h.beaconDomain;if(f)return"https://"+f;var b=y||"litix.io";return(g=g||"inferred").match(/^[a-z0-9]+$/)?"https://"+g+"."+b:"https://img.litix.io/a.gif"}var ir=function(){var g;switch(br()){case"cellular":g="cellular";break;case"ethernet":g="wired";break;case"wifi":g="wifi";break;case void 0:break;default:g="other"}return g},br=function(){var g=R().navigator,h=g&&(g.connection||g.mozConnection||g.webkitConnection);return h&&h.type};ir.getConnectionFromAPI=br;var Nt=ir,Yt=Ir({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"}),cr=Ir({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function Ir(g){var h={};for(var f in g)g.hasOwnProperty(f)&&(h[g[f]]=f);return h}function dr(g){var h={},f={};return Object.keys(g).forEach(function(y){var b=!1;if(g.hasOwnProperty(y)&&g[y]!==void 0){var O=y.split("_"),D=O[0],H=Yt[D];H||(K.info("Data key word `"+O[0]+"` not expected in "+y),H=D+"_"),O.splice(1).forEach(function(le){le==="url"&&(b=!0),cr[le]?H+=cr[le]:Number(le)&&Math.floor(Number(le))===Number(le)?H+=le:(K.info("Data key word `"+le+"` not expected in "+y),H+="_"+le+"_")}),b?f[H]=g[y]:h[H]=g[y]}}),G()(h,f)}var Mt={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},ki=["hb","requestcompleted","requestfailed","requestcanceled"],zi="https://img.litix.io",_r=function(g){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=g||zi,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=G()({},Mt,h)};_r.prototype.queueEvent=function(g,h){var f=G()({},h);return(this._eventQueue.length<=this._options.maxQueueLength||g==="eventrateexceeded")&&(this._eventQueue.push(f),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},_r.prototype.flushEvents=function(){var g=arguments.length>0&&arguments[0]!==void 0&&arguments[0];g&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},_r.prototype.destroy=function(){var g=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,g?this._clearBeaconQueue():this.flushEvents(),R().clearTimeout(this._sendTimeout)},_r.prototype._clearBeaconQueue=function(){var g=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,h=this._eventQueue.slice(g);g>0&&G()(h[h.length-1],dr({mux_view_message:"event queue truncated"}));var f=this._createPayload(h);oi(this._beaconUrl,f,!0,function(){})},_r.prototype._sendBeaconQueue=function(){var g=this;if(!this._postInFlight){var h=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var f=this._createPayload(h),y=$.now();oi(this._beaconUrl,f,!1,function(b,O){O?(g._eventQueue=h.concat(g._eventQueue),g._failureCount+=1,K.info("Error sending beacon: "+O)):g._failureCount=0,g._roundTripTime=$.now()-y,g._postInFlight=!1})}},_r.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var g=Math.pow(2,this._failureCount-1);return(1+(g*=Math.random()))*this._options.baseTimeBetweenBeacons},_r.prototype._startBeaconSending=function(){var g=this;R().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=R().setTimeout(function(){g._eventQueue.length&&g._sendBeaconQueue(),g._startBeaconSending()},this._getNextBeaconTime()))},_r.prototype._createPayload=function(g){var h,f,y,b=this,O={transmission_timestamp:Math.round($.now())};this._roundTripTime&&(O.rtt_ms=Math.round(this._roundTripTime));var D=function(){h=JSON.stringify({metadata:O,events:f||g}),y=h.length/1024},H=function(){return y<=b._options.maxPayloadKBSize};return D(),H()||(K.info("Payload size is too big ("+y+" kb). Removing unnecessary events."),f=g.filter(function(le){return ki.indexOf(le.e)===-1}),D()),H()||(K.info("Payload size still too big ("+y+" kb). Cropping fields.."),f.forEach(function(le){for(var Z in le){var Ce=le[Z];typeof Ce=="string"&&Ce.length>51200&&(le[Z]=Ce.substring(0,51200))}}),D()),h};var oi=function(g,h,f,y){if(f&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(g,h))y();else if(R().fetch)R().fetch(g,{method:"POST",body:h,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(O){return y(null,O.ok?null:"Error")}).catch(function(O){return y(null,O)});else{if(R().XMLHttpRequest){var b=new(R()).XMLHttpRequest;return b.onreadystatechange=function(){if(b.readyState===4)return y(null,b.status!==200?"error":void 0)},b.open("POST",g),b.setRequestHeader("Content-Type","text/plain"),void b.send(h)}y()}},Qi=_r;function Ji(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var O,D,H=[],le=!0,Z=!1;try{for(b=b.call(f);!(le=(O=b.next()).done)&&(H.push(O.value),!y||H.length!==y);le=!0);}catch(Ce){Z=!0,D=Ce}finally{try{le||b.return==null||b.return()}finally{if(Z)throw D}}return H}}(g,h)||function(f,y){if(f){if(typeof f=="string")return li(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?li(f,y):void 0}}(g,h)||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 ci(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}function hi(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function fi(g,h){return fi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,y){return f.__proto__=y,f},fi(g,h)}function wi(g){var h=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 f,y=vi(g);if(h){var b=vi(this).constructor;f=Reflect.construct(y,arguments,b)}else f=y.apply(this,arguments);return en(this,f)}}function en(g,h){if(h&&(Mr(h)==="object"||typeof h=="function"))return h;if(h!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wt(g)}function Wt(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}function vi(g){return vi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},vi(g)}var mn=["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"],tn=function(g){(function(D,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function");D.prototype=Object.create(H&&H.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),H&&fi(D,H)})(O,g);var h,f,y,b=wi(O);function O(D,H,le){var Z;(function(Xe,nt){if(!(Xe instanceof nt))throw new TypeError("Cannot call a class as a function")})(this,O),(Z=b.call(this)).DOM_CONTENT_LOADED_EVENT_END=je.domContentLoadedEventEnd(),Z.NAVIGATION_START=je.navigationStart(),Z.mux=D,Z.id=H,(le=G()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(Xe){return Xe}},le)).data=le.data||{},le.data.property_key&&(le.data.env_key=le.data.property_key,delete le.data.property_key),K.setLevel(le.debug?"debug":"warn"),Z.getPlayheadTime=le.getPlayheadTime,Z.getStateData=le.getStateData||function(){return{}},Z.getAdData=le.getAdData||function(){},Z.minimumRebufferDuration=le.minimumRebufferDuration,Z.sustainedRebufferThreshold=le.sustainedRebufferThreshold,Z.playbackHeartbeatTime=le.playbackHeartbeatTime,Z.disableRebufferTracking=le.disableRebufferTracking,Z.disableRebufferTracking&&Z.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."),Z.disablePlayheadRebufferTracking=le.disablePlayheadRebufferTracking,Z.errorTranslator=le.errorTranslator,Z.playbackEventDispatcher=new Kr(D,le.data.env_key,le),Z.data={player_instance_id:p(),mux_sample_rate:le.sampleRate,beacon_domain:le.beaconCollectionDomain?le.beaconCollectionDomain:le.beaconDomain},Z.data.view_sequence_number=1,Z.data.player_sequence_number=1,Z.oldEmit=Z.emit,Z.emit=function(Xe,nt){nt=G()({viewer_time:this.mux.utils.now()},nt),this.oldEmit(Xe,nt)};var Ce=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Wt(Z));Z.on("viewinit",function(Xe,nt){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),G()(this.data,nt),this._initializeViewData(),this.one("play",Ce),this.one("adbreakstart",Ce)});var at=function(Xe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",Xe)}.bind(Wt(Z));if(Z.on("videochange",function(Xe,nt){at(nt)}),Z.on("programchange",function(Xe,nt){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."),at(G()(nt,{view_program_changed:!0})),Ce(),this.emit("play"),this.emit("playing")}),Z.on("fragmentchange",function(Xe,nt){this.currentFragmentPDT=nt.currentFragmentPDT,this.currentFragmentStart=nt.currentFragmentStart}),Z.on("destroy",Z.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var Je=function(){var Xe=Z.data.view_start!==void 0;Z.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",Xe&&Z.mux.WINDOW_HIDDEN&&(Z.data.player_is_paused||Z.emit("hb"))};window.addEventListener("visibilitychange",Je,!1);var it=function(Xe){Xe.persisted||Z.destroy()};window.addEventListener("pagehide",it,!1),Z.on("destroy",function(){window.removeEventListener("visibilitychange",Je),window.removeEventListener("pagehide",it)})}return Z.on("playerready",function(Xe,nt){G()(this.data,nt)}),mn.forEach(function(Xe){Z.on(Xe,function(nt,wt){Xe.indexOf("ad")!==0&&this._updateStateData(),G()(this.data,wt),this._sanitizeData()}),Z.on("after"+Xe,function(){(Xe!=="error"||this.errorTracker.viewErrored)&&this.send(Xe)})}),Z.on("viewend",function(Xe,nt){G()(Z.data,nt)}),Z.one("playerready",function(Xe){var nt=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=nt-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}),Z.longResumeTracker=new kr(Wt(Z)),Z.errorTracker=new Ie(Wt(Z)),new ot(Wt(Z)),Z.seekingTracker=new C(Wt(Z)),Z.playheadTime=new Lt(Wt(Z)),Z.playbackHeartbeat=new Be(Wt(Z)),new ee(Wt(Z)),Z.watchTimeTracker=new rt(Wt(Z)),new ht(Wt(Z)),Z.adTracker=new we(Wt(Z)),new Ct(Wt(Z)),new pt(Wt(Z)),new Qt(Wt(Z)),new Ve(Wt(Z)),new Sr(Wt(Z)),le.hlsjs&&Z.addHLSJS(le),le.dashjs&&Z.addDashJS(le),Z.emit("viewinit",le.data),Z}return h=O,f=[{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(D){var H=G()({},this.data);if(H.video_source_is_live===void 0&&(H.player_source_duration===1/0||H.video_source_duration===1/0?H.video_source_is_live=!0:(H.player_source_duration>0||H.video_source_duration>0)&&(H.video_source_is_live=!1)),H.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(at){H[at]=void 0}),H.video_source_url=H.video_source_url||H.player_source_url,H.video_source_url){var le=qr(ke(H.video_source_url),2),Z=le[0],Ce=le[1];H.video_source_domain=Ce,H.video_source_hostname=Z}delete H.ad_request_id,this.playbackEventDispatcher.send(D,H),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){G()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var D=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(H){var le=parseInt(D.data[H],10);D.data[H]=isNaN(le)?void 0:le}),["player_source_url","video_source_url"].forEach(function(H){if(D.data[H]){var le=D.data[H].toLowerCase();le.indexOf("data:")!==0&&le.indexOf("blob:")!==0||(D.data[H]="MSE style URL")}})}},{key:"_resetVideoData",value:function(D,H){var le=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("video_")===0&&delete le.data[Z]})}},{key:"_resetViewData",value:function(){var D=this;Object.keys(this.data).forEach(function(H){H.indexOf("view_")===0&&delete D.data[H]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(D,H){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var D=this,H=this.data.view_id=p(),le=function(){H===D.data.view_id&&V(D.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",le):le()}},{key:"_restartHeartBeat",value:function(){var D=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){D.data.player_is_paused||D.emit("hb")},1e4))}},{key:"addHLSJS",value:function(D){D.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=D.hlsjs,function(H,le,Z){var Ce=arguments.length>4?arguments[4]:void 0,at=H.log,Je=H.utils.secondsToMs,it=function(_t){var et,dt=parseInt(Ce.version);return dt===1&&_t.programDateTime!==null&&(et=_t.programDateTime),dt===0&&_t.pdt!==null&&(et=_t.pdt),et};if(je.exists()){var Xe=function(_t,et){return H.emit(le,_t,et)},nt=function(_t,et){var dt=et.levels,$e=et.audioTracks,lt=et.url,Gt=et.stats,qt=et.networkDetails,ar=et.sessionData,rr={},fr={};dt.forEach(function(gr,Wr){rr[Wr]={width:gr.width,height:gr.height,bitrate:gr.bitrate,attrs:gr.attrs}}),$e.forEach(function(gr,Wr){fr[Wr]={name:gr.name,language:gr.lang,bitrate:gr.bitrate}});var sr=z(Gt),vr=sr.bytesLoaded,Vt=sr.requestStart,or=sr.responseStart,ti=sr.responseEnd;Xe("requestcompleted",Te(Te({},A(ar)),{},{request_event_type:_t,request_bytes_loaded:vr,request_start:Vt,request_response_start:or,request_response_end:ti,request_type:"manifest",request_hostname:Se(lt),request_response_headers:De(qt),request_rendition_lists:{media:rr,audio:fr,video:{}}}))};Z.on(Ce.Events.MANIFEST_LOADED,nt);var wt=function(_t,et){var dt=et.details,$e=et.level,lt=et.networkDetails,Gt=et.stats,qt=z(Gt),ar=qt.bytesLoaded,rr=qt.requestStart,fr=qt.responseStart,sr=qt.responseEnd,vr=dt.fragments[dt.fragments.length-1],Vt=it(vr)+Je(vr.duration);Xe("requestcompleted",{request_event_type:_t,request_bytes_loaded:ar,request_start:rr,request_response_start:fr,request_response_end:sr,request_current_level:$e,request_type:"manifest",request_hostname:Se(dt.url),request_response_headers:De(lt),video_holdback:dt.holdBack&&Je(dt.holdBack),video_part_holdback:dt.partHoldBack&&Je(dt.partHoldBack),video_part_target_duration:dt.partTarget&&Je(dt.partTarget),video_target_duration:dt.targetduration&&Je(dt.targetduration),video_source_is_live:dt.live,player_manifest_newest_program_time:isNaN(Vt)?void 0:Vt})};Z.on(Ce.Events.LEVEL_LOADED,wt);var jt=function(_t,et){var dt=et.details,$e=et.networkDetails,lt=et.stats,Gt=z(lt),qt=Gt.bytesLoaded,ar=Gt.requestStart,rr=Gt.responseStart,fr=Gt.responseEnd;Xe("requestcompleted",{request_event_type:_t,request_bytes_loaded:qt,request_start:ar,request_response_start:rr,request_response_end:fr,request_type:"manifest",request_hostname:Se(dt.url),request_response_headers:De($e)})};Z.on(Ce.Events.AUDIO_TRACK_LOADED,jt);var $t=function(_t,et){var dt=et.stats,$e=et.networkDetails,lt=et.frag;dt=dt||lt.stats;var Gt=z(dt),qt=Gt.bytesLoaded,ar=Gt.requestStart,rr=Gt.responseStart,fr=Gt.responseEnd,sr=De($e),vr=sr==null?void 0:sr["x-request-id"],Vt={request_event_type:_t,request_bytes_loaded:qt,request_start:ar,request_response_start:rr,request_response_end:fr,request_hostname:$e?Se($e.responseURL):void 0,request_id:vr,request_response_headers:sr,request_media_duration:lt.duration,request_url:$e==null?void 0:$e.responseURL};lt.type==="main"?(Vt.request_type="media",Vt.request_current_level=lt.level,Vt.request_video_width=(Z.levels[lt.level]||{}).width,Vt.request_video_height=(Z.levels[lt.level]||{}).height,Vt.request_labeled_bitrate=(Z.levels[lt.level]||{}).bitrate):Vt.request_type=lt.type,Xe("requestcompleted",Vt)};Z.on(Ce.Events.FRAG_LOADED,$t);var nr=function(_t,et){var dt=et.frag,$e=dt.start,lt={currentFragmentPDT:it(dt),currentFragmentStart:Je($e)};Xe("fragmentchange",lt)};Z.on(Ce.Events.FRAG_CHANGED,nr);var mt=function(_t,et){var dt=et.type,$e=et.details,lt=et.response,Gt=et.fatal,qt=et.context,ar=et.frag;if($e===Ce.ErrorDetails.MANIFEST_LOAD_ERROR||$e===Ce.ErrorDetails.MANIFEST_LOAD_TIMEOUT||$e===Ce.ErrorDetails.FRAG_LOAD_ERROR||$e===Ce.ErrorDetails.FRAG_LOAD_TIMEOUT||$e===Ce.ErrorDetails.LEVEL_LOAD_ERROR||$e===Ce.ErrorDetails.LEVEL_LOAD_TIMEOUT){var rr=ar&&ar.url||qt&&qt.url||"";Xe("requestfailed",{request_error:$e,request_url:rr,request_hostname:Se(rr),request_type:$e===Ce.ErrorDetails.FRAG_LOAD_ERROR||$e===Ce.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:lt&<.code,request_error_text:lt&<.text})}Gt&&Xe("error",{player_error_code:dt,player_error_message:$e})};Z.on(Ce.Events.ERROR,mt);var Xt=function(_t,et){var dt=et.frag,$e=dt&&dt._url||"";Xe("requestcanceled",{request_event_type:_t,request_url:$e,request_type:"media",request_hostname:Se($e)})};Z.on(Ce.Events.FRAG_LOAD_EMERGENCY_ABORTED,Xt);var tr=function(_t,et){var dt=et.level,$e=Z.levels[dt];if($e&&$e.attrs&&$e.attrs.BANDWIDTH){var lt,Gt=$e.attrs.BANDWIDTH,qt=parseFloat($e.attrs["FRAME-RATE"]);isNaN(qt)||(lt=qt),Gt?Xe("renditionchange",{video_source_fps:lt,video_source_bitrate:Gt,video_source_width:$e.width,video_source_height:$e.height,video_source_rendition_name:$e.name,video_source_codec:$e==null?void 0:$e.videoCodec}):at.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Z.on(Ce.Events.LEVEL_SWITCHED,tr),Z._stopMuxMonitor=function(){Z.off(Ce.Events.MANIFEST_LOADED,nt),Z.off(Ce.Events.LEVEL_LOADED,wt),Z.off(Ce.Events.AUDIO_TRACK_LOADED,jt),Z.off(Ce.Events.FRAG_LOADED,$t),Z.off(Ce.Events.FRAG_CHANGED,nr),Z.off(Ce.Events.ERROR,mt),Z.off(Ce.Events.FRAG_LOAD_EMERGENCY_ABORTED,Xt),Z.off(Ce.Events.LEVEL_SWITCHED,tr),Z.off(Ce.Events.DESTROYING,Z._stopMuxMonitor),delete Z._stopMuxMonitor},Z.on(Ce.Events.DESTROYING,Z._stopMuxMonitor)}else at.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,D.hlsjs,{},D.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var D;this.hlsjs&&((D=this.hlsjs)&&typeof D._stopMuxMonitor=="function"&&D._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(D){D.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=D.dashjs,function(H,le,Z){var Ce=H.log;if(Z&&Z.on){var at=function(mt,Xt){return H.emit(le,mt,Xt)},Je=function(mt){var Xt=mt.type,tr=(mt.data||{}).url;at("requestcompleted",{request_event_type:Xt,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:Se(tr),request_url:tr})};Z.on("manifestLoaded",Je);var it={},Xe=function(mt){var Xt=mt.type,tr=mt.fragmentModel,_t=(mt.chunk||{}).mediaInfo||{},et=_t.type,dt=_t.bitrateList,$e={};(dt=dt||[]).forEach(function(Vt,or){$e[or]={},$e[or].width=Vt.width,$e[or].height=Vt.height,$e[or].bitrate=Vt.bandwidth,$e[or].attrs={}}),et==="video"?it.video=$e:et==="audio"?it.audio=$e:it.media=$e;var lt=qe(tr,Z),Gt=lt.requestStart,qt=lt.requestResponseStart,ar=lt.requestResponseEnd,rr=lt.requestResponseHeaders,fr=lt.requestMediaDuration,sr=lt.requestHostname,vr=lt.requestUrl;at("requestcompleted",{request_event_type:Xt,request_start:Gt,request_response_start:qt,request_response_end:ar,request_bytes_loaded:-1,request_type:et+"_init",request_response_headers:rr,request_hostname:sr,request_url:vr,request_media_duration:fr,request_rendition_lists:it})};Z.on("initFragmentLoaded",Xe);var nt=function(mt){var Xt=mt.type,tr=mt.fragmentModel,_t=mt.chunk||{},et=_t.mediaInfo,dt=_t.start,$e=(et||{}).type,lt=qe(tr,Z),Gt=lt.requestStart,qt=lt.requestResponseStart,ar=lt.requestResponseEnd,rr=lt.requestBytesLoaded,fr=lt.requestResponseHeaders,sr=lt.requestMediaDuration,vr=lt.requestHostname,Vt=lt.requestUrl,or=tt($e,Z),ti=or.currentLevel,gr=or.renditionWidth,Wr=or.renditionHeight,on=or.renditionBitrate;at("requestcompleted",{request_event_type:Xt,request_start:Gt,request_response_start:qt,request_response_end:ar,request_bytes_loaded:rr,request_type:$e,request_response_headers:fr,request_hostname:vr,request_url:Vt,request_media_start_time:dt,request_media_duration:sr,request_current_level:ti,request_labeled_bitrate:on,request_video_width:gr,request_video_height:Wr})};Z.on("mediaFragmentLoaded",nt);var wt={video:void 0,audio:void 0,totalBitrate:void 0},jt=function(){if(wt.video&&typeof wt.video.bitrate=="number"){if(wt.video.width&&wt.video.height){var mt=wt.video.bitrate;return wt.audio&&typeof wt.audio.bitrate=="number"&&(mt+=wt.audio.bitrate),mt!==wt.totalBitrate?(wt.totalBitrate=mt,{video_source_bitrate:mt,video_source_height:wt.video.height,video_source_width:wt.video.width,video_source_codec:ie(wt.video.codec)}):void 0}Ce.warn("have bitrate info for video but missing width/height")}},$t=function(mt,Xt,tr){if(typeof mt.newQuality=="number"){var _t=mt.mediaType;if(_t==="audio"||_t==="video"){var et=Z.getBitrateInfoListFor(_t).find(function($e){return $e.qualityIndex===mt.newQuality});if(et&&typeof et.bitrate=="number"){wt[_t]=Oe(Oe({},et),{},{codec:Z.getCurrentTrackFor(_t).codec});var dt=jt();dt&&at("renditionchange",dt)}else Ce.warn("missing bitrate info for ".concat(_t))}}else Ce.warn("missing evt.newQuality in qualityChangeRendered event",mt)};Z.on("qualityChangeRendered",$t);var nr=function(mt){var Xt=mt.error,tr=mt.event,_t=(tr=tr||{}).request||{},et=R().event&&R().event.currentTarget||{};at("requestfailed",{request_error:Xt+"_"+tr.id+"_"+_t.type,request_url:tr.url,request_hostname:Se(tr.url),request_type:_t.mediaType,request_error_code:et.status,request_error_type:et.statusText})};Z.on("error",nr),Z._stopMuxMonitor=function(){Z.off("manifestLoaded",Je),Z.off("initFragmentLoaded",Xe),Z.off("mediaFragmentLoaded",nt),Z.off("qualityChangeRendered",$t),Z.off("error",nr),delete Z._stopMuxMonitor}}else Ce.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,D.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var D;this.dashjs&&((D=this.dashjs)&&typeof D._stopMuxMonitor=="function"&&D._stopMuxMonitor(),this.dashjs=void 0)}}],f&&hi(h.prototype,f),y&&hi(h,y),Object.defineProperty(h,"prototype",{writable:!1}),O}(Pe),Nr=tn,Di=j(153),$r=j.n(Di);function Zr(g){return Zr=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},Zr(g)}function Li(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var O,D,H=[],le=!0,Z=!1;try{for(b=b.call(f);!(le=(O=b.next()).done)&&(H.push(O.value),!y||H.length!==y);le=!0);}catch(Ce){Z=!0,D=Ce}finally{try{le||b.return==null||b.return()}finally{if(Z)throw D}}return H}}(g,h)||function(f,y){if(f){if(typeof f=="string")return rn(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?rn(f,y):void 0}}(g,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
-
|
|
6
|
-
`)
|
|
7
|
-
`)
|
|
8
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function gt(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}var hr={},Yr=function g(h){var f=arguments;typeof h=="string"?g.hasOwnProperty(h)?R().setTimeout(function(){f=Array.prototype.splice.call(f,1),g[h].apply(null,f)},0):K.warn("`"+h+"` is an unknown task"):typeof h=="function"?R().setTimeout(function(){h(g)},0):K.warn("`"+h+"` is invalid.")},sn={loaded:$.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(g,h){return function(f,y,b){var O=Li(me(y),3),D=O[0],H=O[1],le=O[2],Z=f.log,Ce=f.utils.getComputedStyle,at=f.utils.secondsToMs;if(!D)return Z.error("No element was found with the `"+H+"` query selector.");if(le!=="video"&&le!=="audio")return Z.error("The element of `"+H+"` was not a media element.");D.mux&&(D.mux.destroy(),delete D.mux,Z.warn("Already monitoring this video element, replacing existing event listeners")),(b=G()({automaticErrorTracking:!0},b)).data=G()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:f.VERSION},b.data),b.getPlayheadTime=function(){return at(D.currentTime)},b.getStateData=function(){var it,Xe,nt=this.hlsjs&&this.hlsjs.url,wt=this.dashjs&&Zr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),jt={player_is_paused:D.paused,player_playhead_time:at(D.currentTime),player_width:parseInt(Ce(D,"width")),player_height:parseInt(Ce(D,"height")),player_autoplay_on:D.autoplay,player_preload_on:D.preload,player_language_code:D.lang,player_is_fullscreen:$r()&&!!($r().fullscreenElement||$r().webkitFullscreenElement||$r().mozFullScreenElement||$r().msFullscreenElement),video_poster_url:D.poster,video_source_url:nt||wt||D.currentSrc,video_source_duration:at(D.duration),video_source_height:D.videoHeight,video_source_width:D.videoWidth,view_dropped_frame_count:(it=D)===null||it===void 0||(Xe=it.getVideoPlaybackQuality)===null||Xe===void 0?void 0:Xe.call(it).droppedVideoFrames},$t=b.getPlayheadTime();if(D.getStartDate&&$t>0){var nr=D.getStartDate();if(nr&&typeof nr.getTime=="function"&&nr.getTime()){var mt=nr.getTime();if(jt.player_program_time=mt+$t,D.seekable.length>0){var Xt=mt+D.seekable.end(D.seekable.length-1);jt.player_live_edge_program_time=Xt}}}return jt},D.mux=D.mux||{},D.mux.deleted=!1,D.mux.emit=function(it,Xe){f.emit(H,it,Xe)};var Je=function(){Z.error("The monitor for this video element has already been destroyed.")};D.mux.destroy=function(){Object.keys(D.mux.listeners).forEach(function(it){D.removeEventListener(it,D.mux.listeners[it],!1)}),delete D.mux.listeners,D.mux.destroy=Je,D.mux.swapElement=Je,D.mux.emit=Je,D.mux.addHLSJS=Je,D.mux.addDashJS=Je,D.mux.removeHLSJS=Je,D.mux.removeDashJS=Je,D.mux.deleted=!0,f.emit(H,"destroy")},D.mux.swapElement=function(it){var Xe=Li(me(it),3),nt=Xe[0],wt=Xe[1],jt=Xe[2];return nt?jt!=="video"&&jt!=="audio"?f.log.error("The element of `"+wt+"` was not a media element."):(nt.muxId=D.muxId,delete D.muxId,nt.mux=nt.mux||{},nt.mux.listeners=G()({},D.mux.listeners),delete D.mux.listeners,Object.keys(nt.mux.listeners).forEach(function($t){D.removeEventListener($t,nt.mux.listeners[$t],!1),nt.addEventListener($t,nt.mux.listeners[$t],!1)}),nt.mux.swapElement=D.mux.swapElement,nt.mux.destroy=D.mux.destroy,delete D.mux,void(D=nt)):f.log.error("No element was found with the `"+wt+"` query selector.")},D.mux.addHLSJS=function(it){f.addHLSJS(H,it)},D.mux.addDashJS=function(it){f.addDashJS(H,it)},D.mux.removeHLSJS=function(){f.removeHLSJS(H)},D.mux.removeDashJS=function(){f.removeDashJS(H)},f.init(H,b),f.emit(H,"playerready"),D.paused||(f.emit(H,"play"),D.readyState>2&&f.emit(H,"playing")),D.mux.listeners={},Ri.forEach(function(it){(it!=="error"||b.automaticErrorTracking)&&(D.mux.listeners[it]=function(){var Xe={};if(it==="error"){if(!D.error||D.error.code===1)return;Xe.player_error_code=D.error.code,Xe.player_error_message=yn[D.error.code]||D.error.message}f.emit(H,it,Xe)},D.addEventListener(it,D.mux.listeners[it],!1))})}(Yr,g,h)},destroyMonitor:function(g){var h=Dn(me(g),1)[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():K.error("A video element monitor for `"+g+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(g,h){var f=k(g);hr[f]?hr[f].addHLSJS(h):K.error("A monitor for `"+f+"` has not been initialized.")},addDashJS:function(g,h){var f=k(g);hr[f]?hr[f].addDashJS(h):K.error("A monitor for `"+f+"` has not been initialized.")},removeHLSJS:function(g){var h=k(g);hr[h]?hr[h].removeHLSJS():K.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(g){var h=k(g);hr[h]?hr[h].removeDashJS():K.error("A monitor for `"+h+"` has not been initialized.")},init:function(g,h){ve()&&h&&h.respectDoNotTrack&&K.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var f=k(g);hr[f]=new Nr(Yr,f,h)},emit:function(g,h,f){var y=k(g);hr[y]?(hr[y].emit(h,f),h==="destroy"&&delete hr[y]):K.error("A monitor for `"+y+"` has not been initialized.")},checkDoNotTrack:ve,log:K,utils:Pi,events:xi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Yr,sn),R()!==void 0&&typeof R().addEventListener=="function"&&R().addEventListener("pagehide",function(g){g.persisted||(Yr.WINDOW_UNLOADING=!0)},!1);var Ln=Yr},655:function(X,M,j){var te,R;function p(w){return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},p(w);}(function(w){var k=!1;if((R=typeof(te=w)=="function"?te.call(M,j,M,X):te)===void 0||(X.exports=R),k=!0,p(M)==="object"&&(X.exports=w(),k=!0),!k){var me=window.Cookies,re=window.Cookies=w();re.noConflict=function(){return window.Cookies=me,re}}})(function(){var w=function(){for(var k=0,me={};k<arguments.length;k++){var re=arguments[k];for(var de in re)me[de]=re[de]}return me};return function k(me){function re(de,_e,K){var ve;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(K=w({path:"/"},re.defaults,K)).expires=="number"){var $=new Date;$.setMilliseconds($.getMilliseconds()+864e5*K.expires),K.expires=$}try{ve=JSON.stringify(_e),/^[\{\[]/.test(ve)&&(_e=ve)}catch{}return _e=me.write?me.write(_e,de):encodeURIComponent(String(_e)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),de=(de=(de=encodeURIComponent(String(de))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[de,"=",_e,K.expires?"; expires="+K.expires.toUTCString():"",K.path?"; path="+K.path:"",K.domain?"; domain="+K.domain:"",K.secure?"; secure":""].join("")}de||(ve={});for(var ae=document.cookie?document.cookie.split("; "):[],G=/(%[0-9A-Z]{2})+/g,Se=0;Se<ae.length;Se++){var ke=ae[Se].split("="),je=ke.slice(1).join("=");je.charAt(0)==='"'&&(je=je.slice(1,-1));try{var V=ke[0].replace(G,decodeURIComponent);if(je=me.read?me.read(je,V):me(je,V)||je.replace(G,decodeURIComponent),this.json)try{je=JSON.parse(je)}catch{}if(de===V){ve=je;break}de||(ve[V]=je)}catch{}}return ve}}return re.set=re,re.get=function(de){return re.call(re,de)},re.getJSON=function(){return re.apply({json:!0},[].slice.call(arguments))},re.defaults={},re.remove=function(de,_e){re(de,"",w(_e,{expires:-1}))},re.withConverter=k,re}(function(){})})},153:function(X,M,j){var te,R=j.g!==void 0?j.g:typeof window!="undefined"?window:{},p=j(558);typeof document!="undefined"?te=document:(te=R["__GLOBAL_DOCUMENT_CACHE@4"])||(te=R["__GLOBAL_DOCUMENT_CACHE@4"]=p),X.exports=te},48:function(X,M,j){var te;te=typeof window!="undefined"?window:j.g!==void 0?j.g:typeof self!="undefined"?self:{},X.exports=te},678:function(X){var M=9007199254740991,j="[object Arguments]",te="[object Function]",R="[object GeneratorFunction]",p=/^(?:0|[1-9]\d*)$/;function w(J,z,De){switch(De.length){case 0:return J.call(z);case 1:return J.call(z,De[0]);case 2:return J.call(z,De[0],De[1]);case 3:return J.call(z,De[0],De[1],De[2])}return J.apply(z,De)}var k,me,re=Object.prototype,de=re.hasOwnProperty,_e=re.toString,K=re.propertyIsEnumerable,ve=(k=Object.keys,me=Object,function(J){return k(me(J))}),$=Math.max,ae=!K.call({valueOf:1},"valueOf");function G(J,z){var De=E(J)||function(qe){return function(tt){return function(ie){return!!ie&&typeof ie=="object"}(tt)&&U(tt)}(qe)&&de.call(qe,"callee")&&(!K.call(qe,"callee")||_e.call(qe)==j)}(J)?function(qe,tt){for(var ie=-1,ce=Array(qe);++ie<qe;)ce[ie]=tt(ie);return ce}(J.length,String):[],Re=De.length,Oe=!!Re;for(var ye in J)!z&&!de.call(J,ye)||Oe&&(ye=="length"||ke(ye,Re))||De.push(ye);return De}function Se(J,z,De){var Re=J[z];de.call(J,z)&&V(Re,De)&&(De!==void 0||z in J)||(J[z]=De)}function ke(J,z){return!!(z=z==null?M:z)&&(typeof J=="number"||p.test(J))&&J>-1&&J%1==0&&J<z}function je(J){var z=J&&J.constructor;return J===(typeof z=="function"&&z.prototype||re)}function V(J,z){return J===z||J!=J&&z!=z}var E=Array.isArray;function U(J){return J!=null&&function(z){return typeof z=="number"&&z>-1&&z%1==0&&z<=M}(J.length)&&!function(z){var De=A(z)?_e.call(z):"";return De==te||De==R}(J)}function A(J){var z=typeof J;return!!J&&(z=="object"||z=="function")}var ue,Te=(ue=function(J,z){if(ae||je(z)||U(z))(function(Re,Oe,ye,qe){ye||(ye={});for(var tt=-1,ie=Oe.length;++tt<ie;){var ce=Oe[tt],ne=qe?qe(ye[ce],Re[ce],ce,ye,Re):void 0;Se(ye,ce,ne===void 0?Re[ce]:ne)}})(z,function(Re){return U(Re)?G(Re):function(Oe){if(!je(Oe))return ve(Oe);var ye=[];for(var qe in Object(Oe))de.call(Oe,qe)&&qe!="constructor"&&ye.push(qe);return ye}(Re)}(z),J);else for(var De in z)de.call(z,De)&&Se(J,De,z[De])},function(J,z){return z=$(z===void 0?J.length-1:z,0),function(){for(var De=arguments,Re=-1,Oe=$(De.length-z,0),ye=Array(Oe);++Re<Oe;)ye[Re]=De[z+Re];Re=-1;for(var qe=Array(z+1);++Re<z;)qe[Re]=De[Re];return qe[z]=ye,w(J,this,qe)}}(function(J,z){var De=-1,Re=z.length,Oe=Re>1?z[Re-1]:void 0,ye=Re>2?z[2]:void 0;for(Oe=ue.length>3&&typeof Oe=="function"?(Re--,Oe):void 0,ye&&function(tt,ie,ce){if(!A(ce))return!1;var ne=typeof ie;return!!(ne=="number"?U(ce)&&ke(ie,ce.length):ne=="string"&&ie in ce)&&V(ce[ie],tt)}(z[0],z[1],ye)&&(Oe=Re<3?void 0:Oe,Re=1),J=Object(J);++De<Re;){var qe=z[De];qe&&ue(J,qe,De,Oe)}return J}));X.exports=Te},640:function(X,M,j){var te,R;(function(p,w){"use strict";te=function(){var k=function(){},me="undefined",re=typeof window!==me&&typeof window.navigator!==me&&/Trident\/|MSIE /.test(window.navigator.userAgent),de=["trace","debug","info","warn","error"];function _e(E,U){var A=E[U];if(typeof A.bind=="function")return A.bind(E);try{return Function.prototype.bind.call(A,E)}catch{return function(){return Function.prototype.apply.apply(A,[E,arguments])}}}function K(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function ve(E){return E==="debug"&&(E="log"),typeof console!==me&&(E==="trace"&&re?K:console[E]!==void 0?_e(console,E):console.log!==void 0?_e(console,"log"):k)}function $(E,U){for(var A=0;A<de.length;A++){var ue=de[A];this[ue]=A<E?k:this.methodFactory(ue,E,U)}this.log=this.debug}function ae(E,U,A){return function(){typeof console!==me&&($.call(this,U,A),this[E].apply(this,arguments))}}function G(E,U,A){return ve(E)||ae.apply(this,arguments)}function Se(E,U,A){var ue,Te=this;U=U==null?"WARN":U;var J="loglevel";function z(ye){var qe=(de[ye]||"silent").toUpperCase();if(typeof window!==me&&J){try{return void(window.localStorage[J]=qe)}catch{}try{window.document.cookie=encodeURIComponent(J)+"="+qe+";"}catch{}}}function De(){var ye;if(typeof window!==me&&J){try{ye=window.localStorage[J]}catch{}if(typeof ye===me)try{var qe=window.document.cookie,tt=qe.indexOf(encodeURIComponent(J)+"=");tt!==-1&&(ye=/^([^;]+)/.exec(qe.slice(tt))[1])}catch{}return Te.levels[ye]===void 0&&(ye=void 0),ye}}function Re(){if(typeof window!==me&&J){try{return void window.localStorage.removeItem(J)}catch{}try{window.document.cookie=encodeURIComponent(J)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof E=="string"?J+=":"+E:typeof E=="symbol"&&(J=void 0),Te.name=E,Te.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Te.methodFactory=A||G,Te.getLevel=function(){return ue},Te.setLevel=function(ye,qe){if(typeof ye=="string"&&Te.levels[ye.toUpperCase()]!==void 0&&(ye=Te.levels[ye.toUpperCase()]),!(typeof ye=="number"&&ye>=0&&ye<=Te.levels.SILENT))throw"log.setLevel() called with invalid level: "+ye;if(ue=ye,qe!==!1&&z(ye),$.call(Te,ye,E),typeof console===me&&ye<Te.levels.SILENT)return"No console available for logging"},Te.setDefaultLevel=function(ye){U=ye,De()||Te.setLevel(ye,!1)},Te.resetLevel=function(){Te.setLevel(U,!1),Re()},Te.enableAll=function(ye){Te.setLevel(Te.levels.TRACE,ye)},Te.disableAll=function(ye){Te.setLevel(Te.levels.SILENT,ye)};var Oe=De();Oe==null&&(Oe=U),Te.setLevel(Oe,!1)}var ke=new Se,je={};ke.getLogger=function(E){if(typeof E!="symbol"&&typeof E!="string"||E==="")throw new TypeError("You must supply a name when creating a logger.");var U=je[E];return U||(U=je[E]=new Se(E,ke.getLevel(),ke.methodFactory)),U};var V=typeof window!==me?window.log:void 0;return ke.noConflict=function(){return typeof window!==me&&window.log===ke&&(window.log=V),ke},ke.getLoggers=function(){return je},ke.default=ke,ke},(R=typeof te=="function"?te.call(M,j,M,X):te)===void 0||(X.exports=R)})()},375:function(X,M){"use strict";var j=Object.prototype.hasOwnProperty;function te(p){try{return decodeURIComponent(p.replace(/\+/g," "))}catch{return null}}function R(p){try{return encodeURIComponent(p)}catch{return null}}M.stringify=function(p,w){w=w||"";var k,me,re=[];for(me in typeof w!="string"&&(w="?"),p)if(j.call(p,me)){if((k=p[me])||k!=null&&!isNaN(k)||(k=""),me=R(me),k=R(k),me===null||k===null)continue;re.push(me+"="+k)}return re.length?w+re.join("&"):""},M.parse=function(p){for(var w,k=/([^=?#&]+)=?([^&]*)/g,me={};w=k.exec(p);){var re=te(w[1]),de=te(w[2]);re===null||de===null||re in me||(me[re]=de)}return me}},558:function(){}},fe={};function se(X){var M=fe[X];if(M!==void 0)return M.exports;var j=fe[X]={exports:{}};return x[X].call(j.exports,j,j.exports,se),j.exports}return se.n=function(X){var M=X&&X.__esModule?function(){return X.default}:function(){return X};return se.d(M,{a:M}),M},se.d=function(X,M){for(var j in M)se.o(M,j)&&!se.o(X,j)&&Object.defineProperty(X,j,{enumerable:!0,get:M[j]})},se.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),se.o=function(X,M){return Object.prototype.hasOwnProperty.call(X,M)},se(80)}()},typeof cn=="object"&&typeof Yn=="object"?Yn.exports=W():typeof cn=="object"?cn.mux=W():N.mux=W()})()});var wa=ba((Ki,Wn)=>{typeof window!="undefined"&&function(N,W){typeof Ki=="object"&&typeof Wn=="object"?Wn.exports=W():typeof define=="function"&&define.amd?define([],W):typeof Ki=="object"?Ki.Hls=W():N.Hls=W()}(Ki,()=>(()=>{var N={21:(se,X,M)=>{"use strict";M.r(X),M.d(X,{default:()=>me});var j=function(){function re(de,_e){this.subtle=void 0,this.aesIV=void 0,this.subtle=de,this.aesIV=_e}return re.prototype.decrypt=function(de,_e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},_e,de)},re}(),te=function(){function re(de,_e){this.subtle=void 0,this.key=void 0,this.subtle=de,this.key=_e}return re.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},re}(),R=M(145),p=function(){function re(){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 de=re.prototype;return de.uint8ArrayToUint32Array_=function(_e){for(var K=new DataView(_e),ve=new Uint32Array(4),$=0;$<4;$++)ve[$]=K.getUint32(4*$);return ve},de.initTable=function(){var _e=this.sBox,K=this.invSBox,ve=this.subMix,$=ve[0],ae=ve[1],G=ve[2],Se=ve[3],ke=this.invSubMix,je=ke[0],V=ke[1],E=ke[2],U=ke[3],A=new Uint32Array(256),ue=0,Te=0,J=0;for(J=0;J<256;J++)A[J]=J<128?J<<1:J<<1^283;for(J=0;J<256;J++){var z=Te^Te<<1^Te<<2^Te<<3^Te<<4;z=z>>>8^255&z^99,_e[ue]=z,K[z]=ue;var De=A[ue],Re=A[De],Oe=A[Re],ye=257*A[z]^16843008*z;$[ue]=ye<<24|ye>>>8,ae[ue]=ye<<16|ye>>>16,G[ue]=ye<<8|ye>>>24,Se[ue]=ye,ye=16843009*Oe^65537*Re^257*De^16843008*ue,je[z]=ye<<24|ye>>>8,V[z]=ye<<16|ye>>>16,E[z]=ye<<8|ye>>>24,U[z]=ye,ue?(ue=De^A[A[A[Oe^De]]],Te^=A[A[Te]]):ue=Te=1}},de.expandKey=function(_e){for(var K=this.uint8ArrayToUint32Array_(_e),ve=!0,$=0;$<K.length&&ve;)ve=K[$]===this.key[$],$++;if(!ve){this.key=K;var ae=this.keySize=K.length;if(ae!==4&&ae!==6&&ae!==8)throw new Error("Invalid aes key size="+ae);var G,Se,ke,je,V=this.ksRows=4*(ae+6+1),E=this.keySchedule=new Uint32Array(V),U=this.invKeySchedule=new Uint32Array(V),A=this.sBox,ue=this.rcon,Te=this.invSubMix,J=Te[0],z=Te[1],De=Te[2],Re=Te[3];for(G=0;G<V;G++)G<ae?ke=E[G]=K[G]:(je=ke,G%ae==0?(je=A[(je=je<<8|je>>>24)>>>24]<<24|A[je>>>16&255]<<16|A[je>>>8&255]<<8|A[255&je],je^=ue[G/ae|0]<<24):ae>6&&G%ae==4&&(je=A[je>>>24]<<24|A[je>>>16&255]<<16|A[je>>>8&255]<<8|A[255&je]),E[G]=ke=(E[G-ae]^je)>>>0);for(Se=0;Se<V;Se++)G=V-Se,je=3&Se?E[G]:E[G-4],U[Se]=Se<4||G<=4?je:J[A[je>>>24]]^z[A[je>>>16&255]]^De[A[je>>>8&255]]^Re[A[255&je]],U[Se]=U[Se]>>>0}},de.networkToHostOrderSwap=function(_e){return _e<<24|(65280&_e)<<8|(16711680&_e)>>8|_e>>>24},de.decrypt=function(_e,K,ve){for(var $,ae,G,Se,ke,je,V,E,U,A,ue,Te,J,z,De=this.keySize+6,Re=this.invKeySchedule,Oe=this.invSBox,ye=this.invSubMix,qe=ye[0],tt=ye[1],ie=ye[2],ce=ye[3],ne=this.uint8ArrayToUint32Array_(ve),xe=ne[0],Pe=ne[1],Ne=ne[2],Be=ne[3],Ke=new Int32Array(_e),pe=new Int32Array(Ke.length),Ie=this.networkToHostOrderSwap;K<Ke.length;){for(U=Ie(Ke[K]),A=Ie(Ke[K+1]),ue=Ie(Ke[K+2]),Te=Ie(Ke[K+3]),ke=U^Re[0],je=Te^Re[1],V=ue^Re[2],E=A^Re[3],J=4,z=1;z<De;z++)$=qe[ke>>>24]^tt[je>>16&255]^ie[V>>8&255]^ce[255&E]^Re[J],ae=qe[je>>>24]^tt[V>>16&255]^ie[E>>8&255]^ce[255&ke]^Re[J+1],G=qe[V>>>24]^tt[E>>16&255]^ie[ke>>8&255]^ce[255&je]^Re[J+2],Se=qe[E>>>24]^tt[ke>>16&255]^ie[je>>8&255]^ce[255&V]^Re[J+3],ke=$,je=ae,V=G,E=Se,J+=4;$=Oe[ke>>>24]<<24^Oe[je>>16&255]<<16^Oe[V>>8&255]<<8^Oe[255&E]^Re[J],ae=Oe[je>>>24]<<24^Oe[V>>16&255]<<16^Oe[E>>8&255]<<8^Oe[255&ke]^Re[J+1],G=Oe[V>>>24]<<24^Oe[E>>16&255]<<16^Oe[ke>>8&255]<<8^Oe[255&je]^Re[J+2],Se=Oe[E>>>24]<<24^Oe[ke>>16&255]<<16^Oe[je>>8&255]<<8^Oe[255&V]^Re[J+3],pe[K]=Ie($^xe),pe[K+1]=Ie(Se^Pe),pe[K+2]=Ie(G^Ne),pe[K+3]=Ie(ae^Be),xe=U,Pe=A,Ne=ue,Be=Te,K+=4}return pe.buffer},re}(),w=M(93),k=M(63),me=function(){function re(_e,K){var ve=(K===void 0?{}:K).removePKCS7Padding,$=ve===void 0||ve;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=$,$)try{var ae=self.crypto;ae&&(this.subtle=ae.subtle||ae.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var de=re.prototype;return de.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},de.isSync=function(){return this.useSoftware},de.flush=function(){var _e=this.currentResult,K=this.remainderData;if(!_e||K)return w.logger.error("[softwareDecrypt] "+(K?"overflow bytes: "+K.byteLength:"no result")),this.reset(),null;var ve,$,ae,G=new Uint8Array(_e);return this.reset(),this.removePKCS7Padding?(ae=($=(ve=G).byteLength)&&new DataView(ve.buffer).getUint8($-1))?(0,R.sliceUint8)(ve,0,$-ae):ve:G},de.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},de.decrypt=function(_e,K,ve){var $=this;return this.useSoftware?new Promise(function(ae,G){$.softwareDecrypt(new Uint8Array(_e),K,ve);var Se=$.flush();Se?ae(Se.buffer):G(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(_e),K,ve)},de.softwareDecrypt=function(_e,K,ve){var $=this.currentIV,ae=this.currentResult,G=this.remainderData;this.logOnce("JS AES decrypt"),G&&(_e=(0,k.appendUint8Array)(G,_e),this.remainderData=null);var Se=this.getValidChunk(_e);if(!Se.length)return null;$&&(ve=$);var ke=this.softwareDecrypter;ke||(ke=this.softwareDecrypter=new p),ke.expandKey(K);var je=ae;return this.currentResult=ke.decrypt(Se.buffer,0,ve),this.currentIV=(0,R.sliceUint8)(Se,-16).buffer,je||null},de.webCryptoDecrypt=function(_e,K,ve){var $=this,ae=this.subtle;return this.key===K&&this.fastAesKey||(this.key=K,this.fastAesKey=new te(ae,K)),this.fastAesKey.expandKey().then(function(G){return ae?($.logOnce("WebCrypto AES decrypt"),new j(ae,new Uint8Array(ve)).decrypt(_e.buffer,G)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(G){return w.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+G.name+": "+G.message),$.onWebCryptoError(_e,K,ve)})},de.onWebCryptoError=function(_e,K,ve){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(_e,K,ve);var $=this.flush();if($)return $.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},de.getValidChunk=function(_e){var K=_e,ve=_e.length-_e.length%16;return ve!==_e.length&&(K=(0,R.sliceUint8)(_e,0,ve),this.remainderData=(0,R.sliceUint8)(_e,ve)),K},de.logOnce=function(_e){this.logEnabled&&(w.logger.log("[decrypter]: "+_e),this.logEnabled=!1)},re}()},181:(se,X,M)=>{"use strict";M.r(X),M.d(X,{canParse:()=>k,decodeFrame:()=>K,getID3Data:()=>p,getID3Frames:()=>_e,getTimeStamp:()=>me,isFooter:()=>R,isHeader:()=>te,isTimeStampFrame:()=>re,testables:()=>ke,utf8ArrayToStr:()=>Se});var j,te=function(V,E){return E+10<=V.length&&V[E]===73&&V[E+1]===68&&V[E+2]===51&&V[E+3]<255&&V[E+4]<255&&V[E+6]<128&&V[E+7]<128&&V[E+8]<128&&V[E+9]<128},R=function(V,E){return E+10<=V.length&&V[E]===51&&V[E+1]===68&&V[E+2]===73&&V[E+3]<255&&V[E+4]<255&&V[E+6]<128&&V[E+7]<128&&V[E+8]<128&&V[E+9]<128},p=function(V,E){for(var U=E,A=0;te(V,E);)A+=10,A+=w(V,E+6),R(V,E+10)&&(A+=10),E+=A;if(A>0)return V.subarray(U,U+A)},w=function(V,E){var U=0;return U=(127&V[E])<<21,U|=(127&V[E+1])<<14,(U|=(127&V[E+2])<<7)|127&V[E+3]},k=function(V,E){return te(V,E)&&w(V,E+6)+10<=V.length-E},me=function(V){for(var E=_e(V),U=0;U<E.length;U++){var A=E[U];if(re(A))return G(A)}},re=function(V){return V&&V.key==="PRIV"&&V.info==="com.apple.streaming.transportStreamTimestamp"},de=function(V){var E=String.fromCharCode(V[0],V[1],V[2],V[3]),U=w(V,4);return{type:E,size:U,data:V.subarray(10,10+U)}},_e=function(V){for(var E=0,U=[];te(V,E);){for(var A=w(V,E+6),ue=(E+=10)+A;E+8<ue;){var Te=de(V.subarray(E)),J=K(Te);J&&U.push(J),E+=Te.size+10}R(V,E)&&(E+=10)}return U},K=function(V){return V.type==="PRIV"?ve(V):V.type[0]==="W"?ae(V):$(V)},ve=function(V){if(!(V.size<2)){var E=Se(V.data,!0),U=new Uint8Array(V.data.subarray(E.length+1));return{key:V.type,info:E,data:U.buffer}}},$=function(V){if(!(V.size<2)){if(V.type==="TXXX"){var E=1,U=Se(V.data.subarray(E),!0);E+=U.length+1;var A=Se(V.data.subarray(E));return{key:V.type,info:U,data:A}}var ue=Se(V.data.subarray(1));return{key:V.type,data:ue}}},ae=function(V){if(V.type==="WXXX"){if(V.size<2)return;var E=1,U=Se(V.data.subarray(E),!0);E+=U.length+1;var A=Se(V.data.subarray(E));return{key:V.type,info:U,data:A}}var ue=Se(V.data);return{key:V.type,data:ue}},G=function(V){if(V.data.byteLength===8){var E=new Uint8Array(V.data),U=1&E[3],A=(E[4]<<23)+(E[5]<<15)+(E[6]<<7)+E[7];return A/=45,U&&(A+=4772185884e-2),Math.round(A)}},Se=function(V,E){E===void 0&&(E=!1);var U=je();if(U){var A=U.decode(V);if(E){var ue=A.indexOf("\0");return ue!==-1?A.substring(0,ue):A}return A.replace(/\0/g,"")}for(var Te,J,z,De=V.length,Re="",Oe=0;Oe<De;){if((Te=V[Oe++])===0&&E)return Re;if(Te!==0&&Te!==3)switch(Te>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:Re+=String.fromCharCode(Te);break;case 12:case 13:J=V[Oe++],Re+=String.fromCharCode((31&Te)<<6|63&J);break;case 14:J=V[Oe++],z=V[Oe++],Re+=String.fromCharCode((15&Te)<<12|(63&J)<<6|(63&z)<<0)}}return Re},ke={decodeTextFrame:$};function je(){return j||self.TextDecoder===void 0||(j=new self.TextDecoder("utf-8")),j}},182:(se,X,M)=>{"use strict";M.r(X),M.d(X,{default:()=>k});var j=M(544),te=M(851),R=M(93),p=M(729),w=M(973);function k(_e){var K=new p.EventEmitter,ve=function($,ae){_e.postMessage({event:$,data:ae})};K.on(te.Events.FRAG_DECRYPTED,ve),K.on(te.Events.ERROR,ve),_e.addEventListener("message",function($){var ae=$.data;switch(ae.cmd){case"init":var G=JSON.parse(ae.config);_e.transmuxer=new j.default(K,ae.typeSupported,G,ae.vendor,ae.id),(0,R.enableLogs)(G.debug,ae.id),function(){var V=function(U){R.logger[U]=function(A){ve("workerLog",{logType:U,message:A})}};for(var E in R.logger)V(E)}(),ve("init",null);break;case"configure":_e.transmuxer.configure(ae.config);break;case"demux":var Se=_e.transmuxer.push(ae.data,ae.decryptdata,ae.chunkMeta,ae.state);(0,j.isPromise)(Se)?(_e.transmuxer.async=!0,Se.then(function(V){me(_e,V)}).catch(function(V){ve(te.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:ae.chunkMeta,fatal:!1,error:V,err:V,reason:"transmuxer-worker push error"})})):(_e.transmuxer.async=!1,me(_e,Se));break;case"flush":var ke=ae.chunkMeta,je=_e.transmuxer.flush(ke);(0,j.isPromise)(je)||_e.transmuxer.async?((0,j.isPromise)(je)||(je=Promise.resolve(je)),je.then(function(V){de(_e,V,ke)}).catch(function(V){ve(te.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:ae.chunkMeta,fatal:!1,error:V,err:V,reason:"transmuxer-worker flush error"})})):de(_e,je,ke)}})}function me(_e,K){if(!((ve=K.remuxResult).audio||ve.video||ve.text||ve.id3||ve.initSegment))return!1;var ve,$=[],ae=K.remuxResult,G=ae.audio,Se=ae.video;return G&&re($,G),Se&&re($,Se),_e.postMessage({event:"transmuxComplete",data:K},$),!0}function re(_e,K){K.data1&&_e.push(K.data1.buffer),K.data2&&_e.push(K.data2.buffer)}function de(_e,K,ve){K.reduce(function($,ae){return me(_e,ae)||$},!1)||_e.postMessage({event:"transmuxComplete",data:K[0]}),_e.postMessage({event:"flush",data:ve})}},544:(se,X,M)=>{"use strict";M.r(X),M.d(X,{TransmuxConfig:()=>Ut,TransmuxState:()=>ur,default:()=>Ct,isPromise:()=>Qt});var j=M(851),te=M(973),R=M(21),p=M(965),w=M(181),k=M(856);function me(ee,F){return ee===void 0&&(ee=""),F===void 0&&(F=9e4),{type:ee,id:-1,pid:-1,inputTimeScale:F,sequenceNumber:-1,samples:[],dropped:0}}var re=M(63),de=M(145),_e=function(){function ee(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var F=ee.prototype;return F.resetInitSegment=function(T,C,L,B){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},F.resetTimeStamp=function(T){this.initPTS=T,this.resetContiguity()},F.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},F.canParse=function(T,C){return!1},F.appendFrame=function(T,C,L){},F.demux=function(T,C){this.cachedData&&(T=(0,re.appendUint8Array)(this.cachedData,T),this.cachedData=null);var L,B=w.getID3Data(T,0),Y=B?B.length:0,Q=this._audioTrack,ge=this._id3Track,we=B?w.getTimeStamp(B):void 0,Le=T.length;for((this.basePTS===null||this.frameIndex===0&&(0,p.isFiniteNumber)(we))&&(this.basePTS=K(we,C,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),B&&B.length>0&&ge.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:B,type:k.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});Y<Le;){if(this.canParse(T,Y)){var Fe=this.appendFrame(Q,T,Y);Fe?(this.frameIndex++,this.lastPTS=Fe.sample.pts,L=Y+=Fe.length):Y=Le}else w.canParse(T,Y)?(B=w.getID3Data(T,Y),ge.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:B,type:k.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),L=Y+=B.length):Y++;if(Y===Le&&L!==Le){var Ve=(0,de.sliceUint8)(T,L);this.cachedData?this.cachedData=(0,re.appendUint8Array)(this.cachedData,Ve):this.cachedData=Ve}}return{audioTrack:Q,videoTrack:me(),id3Track:ge,textTrack:me()}},F.demuxSampleAes=function(T,C,L){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},F.flush=function(T){var C=this.cachedData;return C&&(this.cachedData=null,this.demux(C,0)),{audioTrack:this._audioTrack,videoTrack:me(),id3Track:this._id3Track,textTrack:me()}},F.destroy=function(){},ee}(),K=function(ee,F,T){return(0,p.isFiniteNumber)(ee)?90*ee:9e4*F+(T||0)};let ve=_e;var $=M(93);function ae(ee,F){return ee[F]===255&&(246&ee[F+1])==240}function G(ee,F){return 1&ee[F+1]?7:9}function Se(ee,F){return(3&ee[F+3])<<11|ee[F+4]<<3|(224&ee[F+5])>>>5}function ke(ee,F){return F+1<ee.length&&ae(ee,F)}function je(ee,F){if(ke(ee,F)){var T=G(ee,F);if(F+T>=ee.length)return!1;var C=Se(ee,F);if(C<=T)return!1;var L=F+C;return L===ee.length||ke(ee,L)}return!1}function V(ee,F,T,C,L){if(!ee.samplerate){var B=function(Y,Q,ge,we){var Le,Fe,Ve,Ue,Qe=navigator.userAgent.toLowerCase(),ot=we,bt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Le=1+((192&Q[ge+2])>>>6);var We=(60&Q[ge+2])>>>2;if(!(We>bt.length-1))return Ve=(1&Q[ge+2])<<2,Ve|=(192&Q[ge+3])>>>6,$.logger.log("manifest codec:"+we+", ADTS type:"+Le+", samplingIndex:"+We),/firefox/i.test(Qe)?We>=6?(Le=5,Ue=new Array(4),Fe=We-3):(Le=2,Ue=new Array(2),Fe=We):Qe.indexOf("android")!==-1?(Le=2,Ue=new Array(2),Fe=We):(Le=5,Ue=new Array(4),we&&(we.indexOf("mp4a.40.29")!==-1||we.indexOf("mp4a.40.5")!==-1)||!we&&We>=6?Fe=We-3:((we&&we.indexOf("mp4a.40.2")!==-1&&(We>=6&&Ve===1||/vivaldi/i.test(Qe))||!we&&Ve===1)&&(Le=2,Ue=new Array(2)),Fe=We)),Ue[0]=Le<<3,Ue[0]|=(14&We)>>1,Ue[1]|=(1&We)<<7,Ue[1]|=Ve<<3,Le===5&&(Ue[1]|=(14&Fe)>>1,Ue[2]=(1&Fe)<<7,Ue[2]|=8,Ue[3]=0),{config:Ue,samplerate:bt[We],channelCount:Ve,codec:"mp4a.40."+Le,manifestCodec:ot};Y.trigger(j.Events.ERROR,{type:te.ErrorTypes.MEDIA_ERROR,details:te.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+We})}(F,T,C,L);if(!B)return;ee.config=B.config,ee.samplerate=B.samplerate,ee.channelCount=B.channelCount,ee.codec=B.codec,ee.manifestCodec=B.manifestCodec,$.logger.log("parsed codec:"+ee.codec+", rate:"+B.samplerate+", channels:"+B.channelCount)}}function E(ee){return 9216e4/ee}function U(ee,F,T,C,L){var B,Y=C+L*E(ee.samplerate),Q=function(Qe,ot){var bt=G(Qe,ot);if(ot+bt<=Qe.length){var We=Se(Qe,ot)-bt;if(We>0)return{headerLength:bt,frameLength:We}}}(F,T);if(Q){var ge=Q.frameLength,we=Q.headerLength,Le=we+ge,Fe=Math.max(0,T+Le-F.length);Fe?(B=new Uint8Array(Le-we)).set(F.subarray(T+we,F.length),0):B=F.subarray(T+we,T+Le);var Ve={unit:B,pts:Y};return Fe||ee.samples.push(Ve),{sample:Ve,length:Le,missing:Fe}}var Ue=F.length-T;return(B=new Uint8Array(Ue)).set(F.subarray(T,F.length),0),{sample:{unit:B,pts:Y},length:Ue,missing:-1}}function A(ee,F){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,C){return T.__proto__=C,T},A(ee,F)}let ue=function(ee){var F,T;function C(B,Y){var Q;return(Q=ee.call(this)||this).observer=void 0,Q.config=void 0,Q.observer=B,Q.config=Y,Q}T=ee,(F=C).prototype=Object.create(T.prototype),F.prototype.constructor=F,A(F,T);var L=C.prototype;return L.resetInitSegment=function(B,Y,Q,ge){ee.prototype.resetInitSegment.call(this,B,Y,Q,ge),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:Y,duration:ge,inputTimeScale:9e4,dropped:0}},C.probe=function(B){if(!B)return!1;for(var Y=(w.getID3Data(B,0)||[]).length,Q=B.length;Y<Q;Y++)if(je(B,Y))return $.logger.log("ADTS sync word found !"),!0;return!1},L.canParse=function(B,Y){return function(Q,ge){return function(we,Le){return Le+5<we.length}(Q,ge)&&ae(Q,ge)&&Se(Q,ge)<=Q.length-ge}(B,Y)},L.appendFrame=function(B,Y,Q){V(B,this.observer,Y,Q,B.manifestCodec);var ge=U(B,Y,Q,this.basePTS,this.frameIndex);if(ge&&ge.missing===0)return ge},C}(ve);var Te=/\/emsg[-/]ID3/i;let J=function(){function ee(T,C){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=C}var F=ee.prototype;return F.resetTimeStamp=function(){},F.resetInitSegment=function(T,C,L,B){var Y=this.videoTrack=me("video",1),Q=this.audioTrack=me("audio",1),ge=this.txtTrack=me("text",1);if(this.id3Track=me("id3",1),this.timeOffset=0,T&&T.byteLength){var we=(0,re.parseInitSegment)(T);if(we.video){var Le=we.video,Fe=Le.id,Ve=Le.timescale,Ue=Le.codec;Y.id=Fe,Y.timescale=ge.timescale=Ve,Y.codec=Ue}if(we.audio){var Qe=we.audio,ot=Qe.id,bt=Qe.timescale,We=Qe.codec;Q.id=ot,Q.timescale=bt,Q.codec=We}ge.id=re.RemuxerTrackIdConfig.text,Y.sampleDuration=0,Y.duration=Q.duration=B}},F.resetContiguity=function(){},ee.probe=function(T){return T=T.length>16384?T.subarray(0,16384):T,(0,re.findBox)(T,["moof"]).length>0},F.demux=function(T,C){this.timeOffset=C;var L=T,B=this.videoTrack,Y=this.txtTrack;if(this.config.progressive){this.remainderData&&(L=(0,re.appendUint8Array)(this.remainderData,T));var Q=(0,re.segmentValidRange)(L);this.remainderData=Q.remainder,B.samples=Q.valid||new Uint8Array}else B.samples=L;var ge=this.extractID3Track(B,C);return Y.samples=(0,re.parseSamples)(C,B),{videoTrack:B,audioTrack:this.audioTrack,id3Track:ge,textTrack:this.txtTrack}},F.flush=function(){var T=this.timeOffset,C=this.videoTrack,L=this.txtTrack;C.samples=this.remainderData||new Uint8Array,this.remainderData=null;var B=this.extractID3Track(C,this.timeOffset);return L.samples=(0,re.parseSamples)(T,C),{videoTrack:C,audioTrack:me(),id3Track:B,textTrack:me()}},F.extractID3Track=function(T,C){var L=this.id3Track;if(T.samples.length){var B=(0,re.findBox)(T.samples,["emsg"]);B&&B.forEach(function(Y){var Q=(0,re.parseEmsg)(Y);if(Te.test(Q.schemeIdUri)){var ge=(0,p.isFiniteNumber)(Q.presentationTime)?Q.presentationTime/Q.timeScale:C+Q.presentationTimeDelta/Q.timeScale,we=Q.eventDuration===4294967295?Number.POSITIVE_INFINITY:Q.eventDuration/Q.timeScale;we<=.001&&(we=Number.POSITIVE_INFINITY);var Le=Q.payload;L.samples.push({data:Le,len:Le.byteLength,dts:ge,pts:ge,type:k.MetadataSchema.emsg,duration:we})}})}return L},F.demuxSampleAes=function(T,C,L){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},F.destroy=function(){},ee}();var z=null,De=[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],Re=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Oe=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ye=[0,1,1,4];function qe(ee,F,T,C,L){if(!(T+24>F.length)){var B=tt(F,T);if(B&&T+B.frameLength<=F.length){var Y=C+L*(9e4*B.samplesPerFrame/B.sampleRate),Q={unit:F.subarray(T,T+B.frameLength),pts:Y,dts:Y};return ee.config=[],ee.channelCount=B.channelCount,ee.samplerate=B.sampleRate,ee.samples.push(Q),{sample:Q,length:B.frameLength,missing:0}}}}function tt(ee,F){var T=ee[F+1]>>3&3,C=ee[F+1]>>1&3,L=ee[F+2]>>4&15,B=ee[F+2]>>2&3;if(T!==1&&L!==0&&L!==15&&B!==3){var Y=ee[F+2]>>1&1,Q=ee[F+3]>>6,ge=1e3*De[14*(T===3?3-C:C===3?3:4)+L-1],we=Re[3*(T===3?0:T===2?1:2)+B],Le=Q===3?1:2,Fe=Oe[T][C],Ve=ye[C],Ue=8*Fe*Ve,Qe=Math.floor(Fe*ge/we+Y)*Ve;if(z===null){var ot=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);z=ot?parseInt(ot[1]):0}return!!z&&z<=87&&C===2&&ge>=224e3&&Q===0&&(ee[F+3]=128|ee[F+3]),{sampleRate:we,channelCount:Le,frameLength:Qe,samplesPerFrame:Ue}}}function ie(ee,F){return ee[F]===255&&(224&ee[F+1])==224&&(6&ee[F+1])!=0}function ce(ee,F){return F+1<ee.length&&ie(ee,F)}function ne(ee,F){if(F+1<ee.length&&ie(ee,F)){var T=tt(ee,F),C=4;T!=null&&T.frameLength&&(C=T.frameLength);var L=F+C;return L===ee.length||ce(ee,L)}return!1}let xe=function(){function ee(T){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=T,this.bytesAvailable=T.byteLength,this.word=0,this.bitsAvailable=0}var F=ee.prototype;return F.loadWord=function(){var T=this.data,C=this.bytesAvailable,L=T.byteLength-C,B=new Uint8Array(4),Y=Math.min(4,C);if(Y===0)throw new Error("no bytes available");B.set(T.subarray(L,L+Y)),this.word=new DataView(B.buffer).getUint32(0),this.bitsAvailable=8*Y,this.bytesAvailable-=Y},F.skipBits=function(T){var C;T=Math.min(T,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>T?(this.word<<=T,this.bitsAvailable-=T):(T-=this.bitsAvailable,T-=(C=T>>3)<<3,this.bytesAvailable-=C,this.loadWord(),this.word<<=T,this.bitsAvailable-=T)},F.readBits=function(T){var C=Math.min(this.bitsAvailable,T),L=this.word>>>32-C;if(T>32&&$.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=C,this.bitsAvailable>0)this.word<<=C;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(C=T-C)>0&&this.bitsAvailable?L<<C|this.readBits(C):L},F.skipLZ=function(){var T;for(T=0;T<this.bitsAvailable;++T)if((this.word&2147483648>>>T)!=0)return this.word<<=T,this.bitsAvailable-=T,T;return this.loadWord(),T+this.skipLZ()},F.skipUEG=function(){this.skipBits(1+this.skipLZ())},F.skipEG=function(){this.skipBits(1+this.skipLZ())},F.readUEG=function(){var T=this.skipLZ();return this.readBits(T+1)-1},F.readEG=function(){var T=this.readUEG();return 1&T?1+T>>>1:-1*(T>>>1)},F.readBoolean=function(){return this.readBits(1)===1},F.readUByte=function(){return this.readBits(8)},F.readUShort=function(){return this.readBits(16)},F.readUInt=function(){return this.readBits(32)},F.skipScalingList=function(T){for(var C=8,L=8,B=0;B<T;B++)L!==0&&(L=(C+this.readEG()+256)%256),C=L===0?C:L},F.readSPS=function(){var T,C,L,B=0,Y=0,Q=0,ge=0,we=this.readUByte.bind(this),Le=this.readBits.bind(this),Fe=this.readUEG.bind(this),Ve=this.readBoolean.bind(this),Ue=this.skipBits.bind(this),Qe=this.skipEG.bind(this),ot=this.skipUEG.bind(this),bt=this.skipScalingList.bind(this);we();var We=we();if(Le(5),Ue(3),we(),ot(),We===100||We===110||We===122||We===244||We===44||We===83||We===86||We===118||We===128){var kt=Fe();if(kt===3&&Ue(1),ot(),ot(),Ue(1),Ve())for(C=kt!==3?8:12,L=0;L<C;L++)Ve()&&bt(L<6?16:64)}ot();var Jt=Fe();if(Jt===0)Fe();else if(Jt===1)for(Ue(1),Qe(),Qe(),T=Fe(),L=0;L<T;L++)Qe();ot(),Ue(1);var Ft=Fe(),Pt=Fe(),Bt=Le(1);Bt===0&&Ue(1),Ue(1),Ve()&&(B=Fe(),Y=Fe(),Q=Fe(),ge=Fe());var Ze=[1,1];if(Ve()&&Ve())switch(we()){case 1:Ze=[1,1];break;case 2:Ze=[12,11];break;case 3:Ze=[10,11];break;case 4:Ze=[16,11];break;case 5:Ze=[40,33];break;case 6:Ze=[24,11];break;case 7:Ze=[20,11];break;case 8:Ze=[32,11];break;case 9:Ze=[80,33];break;case 10:Ze=[18,11];break;case 11:Ze=[15,11];break;case 12:Ze=[64,33];break;case 13:Ze=[160,99];break;case 14:Ze=[4,3];break;case 15:Ze=[3,2];break;case 16:Ze=[2,1];break;case 255:Ze=[we()<<8|we(),we()<<8|we()]}return{width:Math.ceil(16*(Ft+1)-2*B-2*Y),height:(2-Bt)*(Pt+1)*16-(Bt?2:4)*(Q+ge),pixelRatio:Ze}},F.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},ee}(),Pe=function(){function ee(T,C,L){this.keyData=void 0,this.decrypter=void 0,this.keyData=L,this.decrypter=new R.default(C,{removePKCS7Padding:!1})}var F=ee.prototype;return F.decryptBuffer=function(T){return this.decrypter.decrypt(T,this.keyData.key.buffer,this.keyData.iv.buffer)},F.decryptAacSample=function(T,C,L){var B=this,Y=T[C].unit;if(!(Y.length<=16)){var Q=Y.subarray(16,Y.length-Y.length%16),ge=Q.buffer.slice(Q.byteOffset,Q.byteOffset+Q.length);this.decryptBuffer(ge).then(function(we){var Le=new Uint8Array(we);Y.set(Le,16),B.decrypter.isSync()||B.decryptAacSamples(T,C+1,L)})}},F.decryptAacSamples=function(T,C,L){for(;;C++){if(C>=T.length)return void L();if(!(T[C].unit.length<32||(this.decryptAacSample(T,C,L),this.decrypter.isSync())))return}},F.getAvcEncryptedData=function(T){for(var C=16*Math.floor((T.length-48)/160)+16,L=new Int8Array(C),B=0,Y=32;Y<T.length-16;Y+=160,B+=16)L.set(T.subarray(Y,Y+16),B);return L},F.getAvcDecryptedUnit=function(T,C){for(var L=new Uint8Array(C),B=0,Y=32;Y<T.length-16;Y+=160,B+=16)T.set(L.subarray(B,B+16),Y);return T},F.decryptAvcSample=function(T,C,L,B,Y){var Q=this,ge=(0,re.discardEPB)(Y.data),we=this.getAvcEncryptedData(ge);this.decryptBuffer(we.buffer).then(function(Le){Y.data=Q.getAvcDecryptedUnit(ge,Le),Q.decrypter.isSync()||Q.decryptAvcSamples(T,C,L+1,B)})},F.decryptAvcSamples=function(T,C,L,B){if(T instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;C++,L=0){if(C>=T.length)return void B();for(var Y=T[C].units;!(L>=Y.length);L++){var Q=Y[L];if(!(Q.data.length<=48||Q.type!==1&&Q.type!==5||(this.decryptAvcSample(T,C,L,B,Q),this.decrypter.isSync())))return}}},ee}();function Ne(){return Ne=Object.assign?Object.assign.bind():function(ee){for(var F=1;F<arguments.length;F++){var T=arguments[F];for(var C in T)Object.prototype.hasOwnProperty.call(T,C)&&(ee[C]=T[C])}return ee},Ne.apply(this,arguments)}var Be=188;function Ke(ee,F,T,C){return{key:ee,frame:!1,pts:F,dts:T,units:[],debug:C,length:0}}function pe(ee,F){return(31&ee[F+10])<<8|ee[F+11]}function Ie(ee,F,T,C){var L={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},B=F+3+((15&ee[F+1])<<8|ee[F+2])-4;for(F+=12+((15&ee[F+10])<<8|ee[F+11]);F<B;){var Y=(31&ee[F+1])<<8|ee[F+2];switch(ee[F]){case 207:if(!C){$.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:L.audio===-1&&(L.audio=Y);break;case 21:L.id3===-1&&(L.id3=Y);break;case 219:if(!C){$.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:L.avc===-1&&(L.avc=Y);break;case 3:case 4:T.mpeg!==!0&&T.mp3!==!0?$.logger.log("MPEG audio found, not supported in this browser"):L.audio===-1&&(L.audio=Y,L.segmentCodec="mp3");break;case 36:$.logger.warn("Unsupported HEVC stream type found")}F+=5+((15&ee[F+3])<<8|ee[F+4])}return L}function Ye(ee){var F,T,C,L,B,Y=0,Q=ee.data;if(!ee||ee.size===0)return null;for(;Q[0].length<19&&Q.length>1;){var ge=new Uint8Array(Q[0].length+Q[1].length);ge.set(Q[0]),ge.set(Q[1],Q[0].length),Q[0]=ge,Q.splice(1,1)}if(((F=Q[0])[0]<<16)+(F[1]<<8)+F[2]===1){if((T=(F[4]<<8)+F[5])&&T>ee.size-6)return null;var we=F[7];192&we&&(L=536870912*(14&F[9])+4194304*(255&F[10])+16384*(254&F[11])+128*(255&F[12])+(254&F[13])/2,64&we?L-(B=536870912*(14&F[14])+4194304*(255&F[15])+16384*(254&F[16])+128*(255&F[17])+(254&F[18])/2)>54e5&&($.logger.warn(Math.round((L-B)/9e4)+"s delta between PTS and DTS, align them"),L=B):B=L);var Le=(C=F[8])+9;if(ee.size<=Le)return null;ee.size-=Le;for(var Fe=new Uint8Array(ee.size),Ve=0,Ue=Q.length;Ve<Ue;Ve++){var Qe=(F=Q[Ve]).byteLength;if(Le){if(Le>Qe){Le-=Qe;continue}F=F.subarray(Le),Qe-=Le,Le=0}Fe.set(F,Y),Y+=Qe}return T&&(T-=C+3),{data:Fe,pts:L,dts:B,len:T}}return null}function rt(ee,F){if(ee.units.length&&ee.frame){if(ee.pts===void 0){var T=F.samples,C=T.length;if(!C)return void F.dropped++;var L=T[C-1];ee.pts=L.pts,ee.dts=L.dts}F.samples.push(ee)}ee.debug.length&&$.logger.log(ee.pts+"/"+ee.dts+":"+ee.debug)}let yt=function(){function ee(T,C,L){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=T,this.config=C,this.typeSupported=L}ee.probe=function(T){var C=ee.syncOffset(T);return C>0&&$.logger.warn("MPEG2-TS detected but first sync word found @ offset "+C),C!==-1},ee.syncOffset=function(T){for(var C=Math.min(940,T.length-376)+1,L=0;L<C;){if(T[L]===71&&T[L+Be]===71)return L;L++}return-1},ee.createTrack=function(T,C){return{container:T==="video"||T==="audio"?"video/mp2t":void 0,type:T,id:re.RemuxerTrackIdConfig[T],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:T==="audio"?C:void 0}};var F=ee.prototype;return F.resetInitSegment=function(T,C,L,B){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=ee.createTrack("video"),this._audioTrack=ee.createTrack("audio",B),this._id3Track=ee.createTrack("id3"),this._txtTrack=ee.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=C,this.videoCodec=L,this._duration=B},F.resetTimeStamp=function(){},F.resetContiguity=function(){var T=this._audioTrack,C=this._avcTrack,L=this._id3Track;T&&(T.pesData=null),C&&(C.pesData=null),L&&(L.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},F.demux=function(T,C,L,B){var Y;L===void 0&&(L=!1),B===void 0&&(B=!1),L||(this.sampleAes=null);var Q=this._avcTrack,ge=this._audioTrack,we=this._id3Track,Le=this._txtTrack,Fe=Q.pid,Ve=Q.pesData,Ue=ge.pid,Qe=we.pid,ot=ge.pesData,bt=we.pesData,We=null,kt=this.pmtParsed,Jt=this._pmtId,Ft=T.length;if(this.remainderData&&(Ft=(T=(0,re.appendUint8Array)(this.remainderData,T)).length,this.remainderData=null),Ft<Be&&!B)return this.remainderData=T,{audioTrack:ge,videoTrack:Q,id3Track:we,textTrack:Le};var Pt=Math.max(0,ee.syncOffset(T));(Ft-=(Ft-Pt)%Be)<T.byteLength&&!B&&(this.remainderData=new Uint8Array(T.buffer,Ft,T.buffer.byteLength-Ft));for(var Bt=0,Ze=Pt;Ze<Ft;Ze+=Be)if(T[Ze]===71){var ir=!!(64&T[Ze+1]),br=((31&T[Ze+1])<<8)+T[Ze+2],Nt=void 0;if((48&T[Ze+3])>>4>1){if((Nt=Ze+5+T[Ze+4])===Ze+Be)continue}else Nt=Ze+4;switch(br){case Fe:ir&&(Ve&&(Y=Ye(Ve))&&this.parseAVCPES(Q,Le,Y,!1),Ve={data:[],size:0}),Ve&&(Ve.data.push(T.subarray(Nt,Ze+Be)),Ve.size+=Ze+Be-Nt);break;case Ue:if(ir){if(ot&&(Y=Ye(ot)))switch(ge.segmentCodec){case"aac":this.parseAACPES(ge,Y);break;case"mp3":this.parseMPEGPES(ge,Y)}ot={data:[],size:0}}ot&&(ot.data.push(T.subarray(Nt,Ze+Be)),ot.size+=Ze+Be-Nt);break;case Qe:ir&&(bt&&(Y=Ye(bt))&&this.parseID3PES(we,Y),bt={data:[],size:0}),bt&&(bt.data.push(T.subarray(Nt,Ze+Be)),bt.size+=Ze+Be-Nt);break;case 0:ir&&(Nt+=T[Nt]+1),Jt=this._pmtId=pe(T,Nt);break;case Jt:ir&&(Nt+=T[Nt]+1);var Yt=Ie(T,Nt,this.typeSupported,L);(Fe=Yt.avc)>0&&(Q.pid=Fe),(Ue=Yt.audio)>0&&(ge.pid=Ue,ge.segmentCodec=Yt.segmentCodec),(Qe=Yt.id3)>0&&(we.pid=Qe),We===null||kt||($.logger.log("unknown PID '"+We+"' in TS found"),We=null,Ze=Pt-188),kt=this.pmtParsed=!0;break;case 17:case 8191:break;default:We=br}}else Bt++;Bt>0&&this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:te.ErrorTypes.MEDIA_ERROR,details:te.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Bt+" TS packet/s that do not start with 0x47"}),Q.pesData=Ve,ge.pesData=ot,we.pesData=bt;var cr={audioTrack:ge,videoTrack:Q,id3Track:we,textTrack:Le};return B&&this.extractRemainingSamples(cr),cr},F.flush=function(){var T,C=this.remainderData;return this.remainderData=null,T=C?this.demux(C,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(T),this.sampleAes?this.decrypt(T,this.sampleAes):T},F.extractRemainingSamples=function(T){var C,L=T.audioTrack,B=T.videoTrack,Y=T.id3Track,Q=T.textTrack,ge=B.pesData,we=L.pesData,Le=Y.pesData;if(ge&&(C=Ye(ge))?(this.parseAVCPES(B,Q,C,!0),B.pesData=null):B.pesData=ge,we&&(C=Ye(we))){switch(L.segmentCodec){case"aac":this.parseAACPES(L,C);break;case"mp3":this.parseMPEGPES(L,C)}L.pesData=null}else we!=null&&we.size&&$.logger.log("last AAC PES packet truncated,might overlap between fragments"),L.pesData=we;Le&&(C=Ye(Le))?(this.parseID3PES(Y,C),Y.pesData=null):Y.pesData=Le},F.demuxSampleAes=function(T,C,L){var B=this.demux(T,L,!0,!this.config.progressive),Y=this.sampleAes=new Pe(this.observer,this.config,C);return this.decrypt(B,Y)},F.decrypt=function(T,C){return new Promise(function(L){var B=T.audioTrack,Y=T.videoTrack;B.samples&&B.segmentCodec==="aac"?C.decryptAacSamples(B.samples,0,function(){Y.samples?C.decryptAvcSamples(Y.samples,0,0,function(){L(T)}):L(T)}):Y.samples&&C.decryptAvcSamples(Y.samples,0,0,function(){L(T)})})},F.destroy=function(){this._duration=0},F.parseAVCPES=function(T,C,L,B){var Y,Q=this,ge=this.parseAVCNALu(T,L.data),we=this.avcSample,Le=!1;L.data=null,we&&ge.length&&!T.audFound&&(rt(we,T),we=this.avcSample=Ke(!1,L.pts,L.dts,"")),ge.forEach(function(Fe){switch(Fe.type){case 1:Y=!0,we||(we=Q.avcSample=Ke(!0,L.pts,L.dts,"")),we.frame=!0;var Ve=Fe.data;if(Le&&Ve.length>4){var Ue=new xe(Ve).readSliceType();Ue!==2&&Ue!==4&&Ue!==7&&Ue!==9||(we.key=!0)}break;case 5:Y=!0,we||(we=Q.avcSample=Ke(!0,L.pts,L.dts,"")),we.key=!0,we.frame=!0;break;case 6:Y=!0,(0,re.parseSEIMessageFromNALu)(Fe.data,1,L.pts,C.samples);break;case 7:if(Y=!0,Le=!0,!T.sps){var Qe=new xe(Fe.data).readSPS();T.width=Qe.width,T.height=Qe.height,T.pixelRatio=Qe.pixelRatio,T.sps=[Fe.data],T.duration=Q._duration;for(var ot=Fe.data.subarray(1,4),bt="avc1.",We=0;We<3;We++){var kt=ot[We].toString(16);kt.length<2&&(kt="0"+kt),bt+=kt}T.codec=bt}break;case 8:Y=!0,T.pps||(T.pps=[Fe.data]);break;case 9:Y=!1,T.audFound=!0,we&&rt(we,T),we=Q.avcSample=Ke(!1,L.pts,L.dts,"");break;case 12:Y=!0;break;default:Y=!1,we&&(we.debug+="unknown NAL "+Fe.type+" ")}we&&Y&&we.units.push(Fe)}),B&&we&&(rt(we,T),this.avcSample=null)},F.getLastNalUnit=function(T){var C,L,B=this.avcSample;if(B&&B.units.length!==0||(B=T[T.length-1]),(C=B)!==null&&C!==void 0&&C.units){var Y=B.units;L=Y[Y.length-1]}return L},F.parseAVCNALu=function(T,C){var L,B,Y=C.byteLength,Q=T.naluState||0,ge=Q,we=[],Le=0,Fe=-1,Ve=0;for(Q===-1&&(Fe=0,Ve=31&C[0],Q=0,Le=1);Le<Y;)if(L=C[Le++],Q)if(Q!==1)if(L)if(L===1){if(Fe>=0){var Ue={data:C.subarray(Fe,Le-Q-1),type:Ve};we.push(Ue)}else{var Qe=this.getLastNalUnit(T.samples);if(Qe&&(ge&&Le<=4-ge&&Qe.state&&(Qe.data=Qe.data.subarray(0,Qe.data.byteLength-ge)),(B=Le-Q-1)>0)){var ot=new Uint8Array(Qe.data.byteLength+B);ot.set(Qe.data,0),ot.set(C.subarray(0,B),Qe.data.byteLength),Qe.data=ot,Qe.state=0}}Le<Y?(Fe=Le,Ve=31&C[Le],Q=0):Q=-1}else Q=0;else Q=3;else Q=L?0:2;else Q=L?0:1;if(Fe>=0&&Q>=0){var bt={data:C.subarray(Fe,Y),type:Ve,state:Q};we.push(bt)}if(we.length===0){var We=this.getLastNalUnit(T.samples);if(We){var kt=new Uint8Array(We.data.byteLength+C.byteLength);kt.set(We.data,0),kt.set(C,We.data.byteLength),We.data=kt}}return T.naluState=Q,we},F.parseAACPES=function(T,C){var L,B,Y,Q,ge,we=0,Le=this.aacOverFlow,Fe=C.data;if(Le){this.aacOverFlow=null;var Ve=Le.missing,Ue=Le.sample.unit.byteLength;if(Ve===-1){var Qe=new Uint8Array(Ue+Fe.byteLength);Qe.set(Le.sample.unit,0),Qe.set(Fe,Ue),Fe=Qe}else{var ot=Ue-Ve;Le.sample.unit.set(Fe.subarray(0,Ve),ot),T.samples.push(Le.sample),we=Le.missing}}for(L=we,B=Fe.length;L<B-1&&!ke(Fe,L);L++);if(L===we||(L<B-1?(Y="AAC PES did not start with ADTS header,offset:"+L,Q=!1):(Y="no ADTS header found in AAC PES",Q=!0),$.logger.warn("parsing error:"+Y),this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:te.ErrorTypes.MEDIA_ERROR,details:te.ErrorDetails.FRAG_PARSING_ERROR,fatal:Q,reason:Y}),!Q)){if(V(T,this.observer,Fe,L,this.audioCodec),C.pts!==void 0)ge=C.pts;else{if(!Le)return void $.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var bt=E(T.samplerate);ge=Le.sample.pts+bt}for(var We,kt=0;L<B;){if(L+=(We=U(T,Fe,L,ge,kt)).length,We.missing){this.aacOverFlow=We;break}for(kt++;L<B-1&&!ke(Fe,L);L++);}}},F.parseMPEGPES=function(T,C){var L=C.data,B=L.length,Y=0,Q=0,ge=C.pts;if(ge!==void 0)for(;Q<B;)if(ce(L,Q)){var we=qe(T,L,Q,ge,Y);if(!we)break;Q+=we.length,Y++}else Q++;else $.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},F.parseID3PES=function(T,C){if(C.pts!==void 0){var L=Ne({},C,{type:this._avcTrack?k.MetadataSchema.emsg:k.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});T.samples.push(L)}else $.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},ee}();function ht(ee,F){return ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,C){return T.__proto__=C,T},ht(ee,F)}let It=function(ee){var F,T;function C(){return ee.apply(this,arguments)||this}T=ee,(F=C).prototype=Object.create(T.prototype),F.prototype.constructor=F,ht(F,T);var L=C.prototype;return L.resetInitSegment=function(B,Y,Q,ge){ee.prototype.resetInitSegment.call(this,B,Y,Q,ge),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:Y,duration:ge,inputTimeScale:9e4,dropped:0}},C.probe=function(B){if(!B)return!1;for(var Y=(w.getID3Data(B,0)||[]).length,Q=B.length;Y<Q;Y++)if(ne(B,Y))return $.logger.log("MPEG Audio sync word found !"),!0;return!1},L.canParse=function(B,Y){return function(Q,ge){return ie(Q,ge)&&4<=Q.length-ge}(B,Y)},L.appendFrame=function(B,Y,Q){if(this.basePTS!==null)return qe(B,Y,Q,this.basePTS,this.frameIndex)},C}(ve);var Lt=M(524),St=M(923);function At(ee,F){var T=ee==null?void 0:ee.codec;return T&&T.length>4?T:T==="hvc1"||T==="hev1"?"hvc1.1.c.L120.90":T==="av01"?"av01.0.04M.08":T==="avc1"||F===St.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let pt=function(){function ee(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var F=ee.prototype;return F.destroy=function(){},F.resetTimeStamp=function(T){this.initPTS=T,this.lastEndTime=null},F.resetNextTimestamp=function(){this.lastEndTime=null},F.resetInitSegment=function(T,C,L,B){this.audioCodec=C,this.videoCodec=L,this.generateInitSegment((0,re.patchEncyptionData)(T,B)),this.emitInitSegment=!0},F.generateInitSegment=function(T){var C=this.audioCodec,L=this.videoCodec;if(!T||!T.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var B=this.initData=(0,re.parseInitSegment)(T);C||(C=At(B.audio,St.ElementaryStreamTypes.AUDIO)),L||(L=At(B.video,St.ElementaryStreamTypes.VIDEO));var Y={};B.audio&&B.video?Y.audiovideo={container:"video/mp4",codec:C+","+L,initSegment:T,id:"main"}:B.audio?Y.audio={container:"audio/mp4",codec:C,initSegment:T,id:"audio"}:B.video?Y.video={container:"video/mp4",codec:L,initSegment:T,id:"main"}:$.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=Y},F.remux=function(T,C,L,B,Y){var Q,ge=this.initPTS,we=this.lastEndTime,Le={audio:void 0,video:void 0,text:B,id3:L,initSegment:void 0};(0,p.isFiniteNumber)(we)||(we=this.lastEndTime=Y||0);var Fe=C.samples;if(!Fe||!Fe.length)return Le;var Ve={initPTS:void 0,timescale:1},Ue=this.initData;if(Ue&&Ue.length||(this.generateInitSegment(Fe),Ue=this.initData),!Ue||!Ue.length)return $.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),Le;this.emitInitSegment&&(Ve.tracks=this.initTracks,this.emitInitSegment=!1);var Qe=(0,re.getStartDTS)(Ue,Fe);(0,p.isFiniteNumber)(ge)||(this.initPTS=Ve.initPTS=ge=Qe-Y);var ot=(0,re.getDuration)(Fe,Ue),bt=T?Qe-ge:we,We=bt+ot;(0,re.offsetStartDTS)(Ue,Fe,ge),ot>0?this.lastEndTime=We:($.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var kt=!!Ue.audio,Jt=!!Ue.video,Ft="";kt&&(Ft+="audio"),Jt&&(Ft+="video");var Pt={data1:Fe,startPTS:bt,startDTS:bt,endPTS:We,endDTS:We,type:Ft,hasAudio:kt,hasVideo:Jt,nb:1,dropped:0};Le.audio=Pt.type==="audio"?Pt:void 0,Le.video=Pt.type!=="audio"?Pt:void 0,Le.initSegment=Ve;var Bt=(Q=this.initPTS)!=null?Q:0;return Le.id3=(0,Lt.flushTextTrackMetadataCueSamples)(L,Y,Bt,Bt),B.samples.length&&(Le.text=(0,Lt.flushTextTrackUserdataCueSamples)(B,Y,Bt)),Le},ee}();var ut;try{ut=self.performance.now.bind(self.performance)}catch{$.logger.debug("Unable to use Performance API on this environment"),ut=self.Date.now}var Rt=[{demux:J,remux:pt},{demux:yt,remux:Lt.default},{demux:ue,remux:Lt.default},{demux:It,remux:Lt.default}],Ct=function(){function ee(T,C,L,B,Y){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=T,this.typeSupported=C,this.config=L,this.vendor=B,this.id=Y}var F=ee.prototype;return F.configure=function(T){this.transmuxConfig=T,this.decrypter&&this.decrypter.reset()},F.push=function(T,C,L,B){var Y=this,Q=L.transmuxing;Q.executeStart=ut();var ge=new Uint8Array(T),we=this.currentTransmuxState,Le=this.transmuxConfig;B&&(this.currentTransmuxState=B);var Fe=B||we,Ve=Fe.contiguous,Ue=Fe.discontinuity,Qe=Fe.trackSwitch,ot=Fe.accurateTimeOffset,bt=Fe.timeOffset,We=Fe.initSegmentChange,kt=Le.audioCodec,Jt=Le.videoCodec,Ft=Le.defaultInitPts,Pt=Le.duration,Bt=Le.initSegmentData,Ze=function(Ir,dr){var Mt=null;return Ir.byteLength>0&&dr!=null&&dr.key!=null&&dr.iv!==null&&dr.method!=null&&(Mt=dr),Mt}(ge,C);if(Ze&&Ze.method==="AES-128"){var ir=this.getDecrypter();if(!ir.isSync())return this.decryptionPromise=ir.webCryptoDecrypt(ge,Ze.key.buffer,Ze.iv.buffer).then(function(Ir){var dr=Y.push(Ir,null,L);return Y.decryptionPromise=null,dr}),this.decryptionPromise;var br=ir.softwareDecrypt(ge,Ze.key.buffer,Ze.iv.buffer);if(!br)return Q.executeEnd=ut(),Ht(L);ge=new Uint8Array(br)}var Nt=this.needsProbing(Ue,Qe);Nt&&this.configureTransmuxer(ge),(Ue||Qe||We||Nt)&&this.resetInitSegment(Bt,kt,Jt,Pt,C),(Ue||We||Nt)&&this.resetInitialTimestamp(Ft),Ve||this.resetContiguity();var Yt=this.transmux(ge,Ze,bt,ot,L),cr=this.currentTransmuxState;return cr.contiguous=!0,cr.discontinuity=!1,cr.trackSwitch=!1,Q.executeEnd=ut(),Yt},F.flush=function(T){var C=this,L=T.transmuxing;L.executeStart=ut();var B=this.decrypter,Y=this.currentTransmuxState,Q=this.decryptionPromise;if(Q)return Q.then(function(){return C.flush(T)});var ge=[],we=Y.timeOffset;if(B){var Le=B.flush();Le&&ge.push(this.push(Le,null,T))}var Fe=this.demuxer,Ve=this.remuxer;if(!Fe||!Ve)return this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:te.ErrorTypes.MEDIA_ERROR,details:te.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),L.executeEnd=ut(),[Ht(T)];var Ue=Fe.flush(we);return Qt(Ue)?Ue.then(function(Qe){return C.flushRemux(ge,Qe,T),ge}):(this.flushRemux(ge,Ue,T),ge)},F.flushRemux=function(T,C,L){var B=C.audioTrack,Y=C.videoTrack,Q=C.id3Track,ge=C.textTrack,we=this.currentTransmuxState,Le=we.accurateTimeOffset,Fe=we.timeOffset;$.logger.log("[transmuxer.ts]: Flushed fragment "+L.sn+(L.part>-1?" p: "+L.part:"")+" of level "+L.level);var Ve=this.remuxer.remux(B,Y,Q,ge,Fe,Le,!0,this.id);T.push({remuxResult:Ve,chunkMeta:L}),L.transmuxing.executeEnd=ut()},F.resetInitialTimestamp=function(T){var C=this.demuxer,L=this.remuxer;C&&L&&(C.resetTimeStamp(T),L.resetTimeStamp(T))},F.resetContiguity=function(){var T=this.demuxer,C=this.remuxer;T&&C&&(T.resetContiguity(),C.resetNextTimestamp())},F.resetInitSegment=function(T,C,L,B,Y){var Q=this.demuxer,ge=this.remuxer;Q&&ge&&(Q.resetInitSegment(T,C,L,B),ge.resetInitSegment(T,C,L,Y))},F.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},F.transmux=function(T,C,L,B,Y){return C&&C.method==="SAMPLE-AES"?this.transmuxSampleAes(T,C,L,B,Y):this.transmuxUnencrypted(T,L,B,Y)},F.transmuxUnencrypted=function(T,C,L,B){var Y=this.demuxer.demux(T,C,!1,!this.config.progressive),Q=Y.audioTrack,ge=Y.videoTrack,we=Y.id3Track,Le=Y.textTrack;return{remuxResult:this.remuxer.remux(Q,ge,we,Le,C,L,!1,this.id),chunkMeta:B}},F.transmuxSampleAes=function(T,C,L,B,Y){var Q=this;return this.demuxer.demuxSampleAes(T,C,L).then(function(ge){return{remuxResult:Q.remuxer.remux(ge.audioTrack,ge.videoTrack,ge.id3Track,ge.textTrack,L,B,!1,Q.id),chunkMeta:Y}})},F.configureTransmuxer=function(T){for(var C,L=this.config,B=this.observer,Y=this.typeSupported,Q=this.vendor,ge=0,we=Rt.length;ge<we;ge++)if(Rt[ge].demux.probe(T)){C=Rt[ge];break}C||($.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),C={demux:J,remux:pt});var Le=this.demuxer,Fe=this.remuxer,Ve=C.remux,Ue=C.demux;Fe&&Fe instanceof Ve||(this.remuxer=new Ve(B,L,Y,Q)),Le&&Le instanceof Ue||(this.demuxer=new Ue(B,L,Y),this.probe=Ue.probe)},F.needsProbing=function(T,C){return!this.demuxer||!this.remuxer||T||C},F.getDecrypter=function(){var T=this.decrypter;return T||(T=this.decrypter=new R.default(this.config)),T},ee}(),Ht=function(ee){return{remuxResult:{},chunkMeta:ee}};function Qt(ee){return"then"in ee&&ee.then instanceof Function}var Ut=function(ee,F,T,C,L){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=ee,this.videoCodec=F,this.initSegmentData=T,this.duration=C,this.defaultInitPts=L},ur=function(ee,F,T,C,L,B){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=ee,this.contiguous=F,this.accurateTimeOffset=T,this.trackSwitch=C,this.timeOffset=L,this.initSegmentChange=B}},973:(se,X,M)=>{"use strict";var j,te;M.r(X),M.d(X,{ErrorDetails:()=>te,ErrorTypes:()=>j}),function(R){R.NETWORK_ERROR="networkError",R.MEDIA_ERROR="mediaError",R.KEY_SYSTEM_ERROR="keySystemError",R.MUX_ERROR="muxError",R.OTHER_ERROR="otherError"}(j||(j={})),function(R){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_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.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"}(te||(te={}))},851:(se,X,M)=>{"use strict";var j;M.r(X),M.d(X,{Events:()=>j}),function(te){te.MEDIA_ATTACHING="hlsMediaAttaching",te.MEDIA_ATTACHED="hlsMediaAttached",te.MEDIA_DETACHING="hlsMediaDetaching",te.MEDIA_DETACHED="hlsMediaDetached",te.BUFFER_RESET="hlsBufferReset",te.BUFFER_CODECS="hlsBufferCodecs",te.BUFFER_CREATED="hlsBufferCreated",te.BUFFER_APPENDING="hlsBufferAppending",te.BUFFER_APPENDED="hlsBufferAppended",te.BUFFER_EOS="hlsBufferEos",te.BUFFER_FLUSHING="hlsBufferFlushing",te.BUFFER_FLUSHED="hlsBufferFlushed",te.MANIFEST_LOADING="hlsManifestLoading",te.MANIFEST_LOADED="hlsManifestLoaded",te.MANIFEST_PARSED="hlsManifestParsed",te.LEVEL_SWITCHING="hlsLevelSwitching",te.LEVEL_SWITCHED="hlsLevelSwitched",te.LEVEL_LOADING="hlsLevelLoading",te.LEVEL_LOADED="hlsLevelLoaded",te.LEVEL_UPDATED="hlsLevelUpdated",te.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",te.LEVELS_UPDATED="hlsLevelsUpdated",te.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",te.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",te.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",te.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",te.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",te.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",te.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",te.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",te.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",te.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",te.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",te.CUES_PARSED="hlsCuesParsed",te.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",te.INIT_PTS_FOUND="hlsInitPtsFound",te.FRAG_LOADING="hlsFragLoading",te.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",te.FRAG_LOADED="hlsFragLoaded",te.FRAG_DECRYPTED="hlsFragDecrypted",te.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",te.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",te.FRAG_PARSING_METADATA="hlsFragParsingMetadata",te.FRAG_PARSED="hlsFragParsed",te.FRAG_BUFFERED="hlsFragBuffered",te.FRAG_CHANGED="hlsFragChanged",te.FPS_DROP="hlsFpsDrop",te.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",te.ERROR="hlsError",te.DESTROYING="hlsDestroying",te.KEY_LOADING="hlsKeyLoading",te.KEY_LOADED="hlsKeyLoaded",te.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",te.BACK_BUFFER_REACHED="hlsBackBufferReached"}(j||(j={}))},76:(se,X,M)=>{"use strict";M.r(X),M.d(X,{default:()=>Ea});var j,te=M(945),R=M(965),p=M(851),w=M(973),k=M(93),me=/^(\d+)x(\d+)$/,re=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,de=function(){function d(e){for(var t in typeof e=="string"&&(e=d.parseAttrList(e)),e)e.hasOwnProperty(t)&&(this[t]=e[t])}var o=d.prototype;return o.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},o.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),n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(2*n,2*n+2),16);return i}return null},o.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},o.decimalFloatingPoint=function(e){return parseFloat(this[e])},o.optionalFloat=function(e,t){var i=this[e];return i?parseFloat(i):t},o.enumeratedString=function(e){return this[e]},o.bool=function(e){return this[e]==="YES"},o.decimalResolution=function(e){var t=me.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},d.parseAttrList=function(e){var t,i={};for(re.lastIndex=0;(t=re.exec(e))!==null;){var n=t[2];n.indexOf('"')===0&&n.lastIndexOf('"')===n.length-1&&(n=n.slice(1,-1)),i[t[1]]=n}return i},d}();function _e(){return _e=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},_e.apply(this,arguments)}function K(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}(function(d){d.ID="ID",d.CLASS="CLASS",d.START_DATE="START-DATE",d.DURATION="DURATION",d.END_DATE="END-DATE",d.END_ON_NEXT="END-ON-NEXT",d.PLANNED_DURATION="PLANNED-DURATION",d.SCTE35_OUT="SCTE35-OUT",d.SCTE35_IN="SCTE35-IN"})(j||(j={}));var ve=function(){function d(t,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var n=i.attr;for(var a in n)if(Object.prototype.hasOwnProperty.call(t,a)&&t[a]!==n[a]){k.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=a;break}t=_e(new de({}),n,t)}if(this.attr=t,this._startDate=new Date(t[j.START_DATE]),j.END_DATE in this.attr){var r=new Date(this.attr[j.END_DATE]);(0,R.isFiniteNumber)(r.getTime())&&(this._endDate=r)}}var o,e;return o=d,(e=[{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 t=this.duration;return t!==null?new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if(j.DURATION in this.attr){var t=this.attr.decimalFloatingPoint(j.DURATION);if((0,R.isFiniteNumber)(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return j.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(j.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(j.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,R.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}])&&K(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}(),$=M(923);function ae(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var G,Se,ke,je=function(){function d(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}var o,e;return d.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var i=this.lastPartSn-t.lastPartSn,n=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!n||!!i,this.advanced=this.endSN>t.endSN||i>0||i===0&&n>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},o=d,(e=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&(0,R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return(t=this.fragments)!==null&&t!==void 0&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&ae(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function V(d){return Uint8Array.from(atob(d),function(o){return o.charCodeAt(0)})}function E(d){return Uint8Array.from(unescape(encodeURIComponent(d)),function(o){return o.charCodeAt(0)})}function U(d){switch(d){case Se.FAIRPLAY:return G.FAIRPLAY;case Se.PLAYREADY:return G.PLAYREADY;case Se.WIDEVINE:return G.WIDEVINE;case Se.CLEARKEY:return G.CLEARKEY}}function A(d){switch(d){case G.FAIRPLAY:return Se.FAIRPLAY;case G.PLAYREADY:return Se.PLAYREADY;case G.WIDEVINE:return Se.WIDEVINE;case G.CLEARKEY:return Se.CLEARKEY}}function ue(d){var o=d.drmSystems,e=d.widevineLicenseUrl,t=o?[G.FAIRPLAY,G.WIDEVINE,G.PLAYREADY,G.CLEARKEY].filter(function(i){return!!o[i]}):[];return!t[G.WIDEVINE]&&e&&t.push(G.WIDEVINE),t}(function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.fps",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="com.widevine.alpha"})(G||(G={})),function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.streamingkeydelivery",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"}(Se||(Se={})),function(d){d.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"}(ke||(ke={}));var Te=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null,J=M(63),z={},De=function(){function d(e,t,i,n,a){n===void 0&&(n=[1]),a===void 0&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=n,this.iv=a,this.encrypted=!!e&&e!=="NONE",this.isCommonEncryption=this.encrypted&&e!=="AES-128"}d.clearKeyUriToKeyIdMap=function(){z={}};var o=d.prototype;return o.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;switch(this.keyFormat){case"identity":return this.method==="SAMPLE-AES";case Se.FAIRPLAY:case Se.WIDEVINE:case Se.PLAYREADY:case Se.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},o.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||k.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=function(P){for(var I=new Uint8Array(16),q=12;q<16;q++)I[q]=P>>8*(15-q)&255;return I}(e);return new d(this.method,this.uri,"identity",this.keyFormatVersions,t)}var i=function(P){var I,q,oe=P.split(":"),Ee=null;if(oe[0]==="data"&&oe.length===2){var he=oe[1].split(";"),Ae=he[he.length-1].split(",");if(Ae.length===2){var He=Ae[0]==="base64",ze=Ae[1];He?(he.splice(-1,1),Ee=V(ze)):(I=E(ze).subarray(0,16),(q=new Uint8Array(16)).set(I,16-I.length),Ee=q)}}return Ee}(this.uri);if(i)switch(this.keyFormat){case Se.WIDEVINE:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case Se.PLAYREADY:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,J.mp4pssh)(n,null,i);var a=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),r=String.fromCharCode.apply(null,Array.from(a)),s=r.substring(r.indexOf("<"),r.length),l=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(l){var u=l.childNodes[0]?l.childNodes[0].nodeValue:l.getAttribute("VALUE");if(u){var c=V(u).subarray(0,16);(function(P){var I=function(q,oe,Ee){var he=q[oe];q[oe]=q[Ee],q[Ee]=he};I(P,0,3),I(P,1,2),I(P,4,5),I(P,6,7)})(c),this.keyId=c}}break;default:var v=i.subarray(0,16);if(v.length!==16){var m=new Uint8Array(16);m.set(v,16-v.length),v=m}this.keyId=v}if(!this.keyId||this.keyId.byteLength!==16){var _=z[this.uri];if(!_){var S=Object.keys(z).length%Number.MAX_SAFE_INTEGER;_=new Uint8Array(16),new DataView(_.buffer,12,4).setUint32(0,S),z[this.uri]=_}this.keyId=_}return this},d}(),Re={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function Oe(d,o){return MediaSource.isTypeSupported((o||"video")+'/mp4;codecs="'+d+'"')}function ye(){return ye=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},ye.apply(this,arguments)}var qe=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,tt=/#EXT-X-MEDIA:(.*)/g,ie=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ce=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),ne=function(){function d(){}return d.findGroup=function(o,e){for(var t=0;t<o.length;t++){var i=o[t];if(i.id===e)return i}},d.convertAVC1ToAVCOTI=function(o){var e=o.split(".");if(e.length>2){var t=e.shift()+".";return(t+=parseInt(e.shift()).toString(16))+("000"+parseInt(e.shift()).toString(16)).slice(-4)}return o},d.resolve=function(o,e){return(0,te.buildAbsoluteURL)(e,o,{alwaysNormalize:!0})},d.parseMasterPlaylist=function(o,e){var t,i=[],n=[],a={},r=[],s=!1;for(qe.lastIndex=0;(t=qe.exec(o))!=null;)if(t[1]){var l,u=new de(t[1]),c={attrs:u,bitrate:u.decimalInteger("AVERAGE-BANDWIDTH")||u.decimalInteger("BANDWIDTH"),name:u.NAME,url:d.resolve(t[2],e)},v=u.decimalResolution("RESOLUTION");v&&(c.width=v.width,c.height=v.height),Pe((u.CODECS||"").split(/[ ,]+/).filter(function(P){return P}),c),c.videoCodec&&c.videoCodec.indexOf("avc1")!==-1&&(c.videoCodec=d.convertAVC1ToAVCOTI(c.videoCodec)),(l=c.unknownCodecs)!==null&&l!==void 0&&l.length||n.push(c),i.push(c)}else if(t[3]){var m=new de(t[3]);m["DATA-ID"]&&(s=!0,a[m["DATA-ID"]]=m)}else if(t[4]){var _=t[4],S=xe(_,e);S.encrypted&&S.isSupported()?r.push(S):k.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+_+'"')}return{levels:n.length>0&&n.length<i.length?n:i,sessionData:s?a:null,sessionKeys:r.length?r:null}},d.parseMasterPlaylistMedia=function(o,e,t,i){var n;i===void 0&&(i=[]);var a=[],r=0;for(tt.lastIndex=0;(n=tt.exec(o))!==null;){var s=new de(n[1]);if(s.TYPE===t){var l={attrs:s,bitrate:0,id:r++,groupId:s["GROUP-ID"],instreamId:s["INSTREAM-ID"],name:s.NAME||s.LANGUAGE||"",type:t,default:s.bool("DEFAULT"),autoselect:s.bool("AUTOSELECT"),forced:s.bool("FORCED"),lang:s.LANGUAGE,url:s.URI?d.resolve(s.URI,e):""};if(i.length){var u=d.findGroup(i,l.groupId)||i[0];Ne(l,u,"audioCodec"),Ne(l,u,"textCodec")}a.push(l)}}return a},d.parseLevelPlaylist=function(o,e,t,i,n){var a,r,s,l=new je(e),u=l.fragments,c=null,v=0,m=0,_=0,S=0,P=null,I=new $.Fragment(i,e),q=-1,oe=!1;for(ie.lastIndex=0,l.m3u8=o;(a=ie.exec(o))!==null;){oe&&(oe=!1,(I=new $.Fragment(i,e)).start=_,I.sn=v,I.cc=S,I.level=t,c&&(I.initSegment=c,I.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null));var Ee=a[1];if(Ee){I.duration=parseFloat(Ee);var he=(" "+a[2]).slice(1);I.title=he||null,I.tagList.push(he?["INF",Ee,he]:["INF",Ee])}else if(a[3]){if((0,R.isFiniteNumber)(I.duration)){if(I.start=_,s){I.levelkeys=s;var Ae=l.encryptedFragments;!I.levelkeys||!Object.keys(I.levelkeys).some(function(Dr){return I.levelkeys[Dr].isCommonEncryption})||Ae.length&&Ae[Ae.length-1].levelkeys===s||Ae.push(I)}I.sn=v,I.level=t,I.cc=S,I.urlId=n,u.push(I),I.relurl=(" "+a[3]).slice(1),Be(I,P),P=I,_+=I.duration,v++,m=0,oe=!0}}else if(a[4]){var He=(" "+a[4]).slice(1);P?I.setByteRange(He,P):I.setByteRange(He)}else if(a[5])I.rawProgramDateTime=(" "+a[5]).slice(1),I.tagList.push(["PROGRAM-DATE-TIME",I.rawProgramDateTime]),q===-1&&(q=u.length);else{if(!(a=a[0].match(ce))){k.logger.warn("No matches on slow regex match for level playlist!");continue}for(r=1;r<a.length&&a[r]===void 0;r++);var ze=(" "+a[r]).slice(1),be=(" "+a[r+1]).slice(1),Ge=a[r+2]?(" "+a[r+2]).slice(1):"";switch(ze){case"PLAYLIST-TYPE":l.type=be.toUpperCase();break;case"MEDIA-SEQUENCE":v=l.startSN=parseInt(be);break;case"SKIP":var Me=new de(be),ct=Me.decimalInteger("SKIPPED-SEGMENTS");if((0,R.isFiniteNumber)(ct)){l.skippedSegments=ct;for(var Ot=ct;Ot--;)u.unshift(null);v+=ct}var ft=Me.enumeratedString("RECENTLY-REMOVED-DATERANGES");ft&&(l.recentlyRemovedDateranges=ft.split(" "));break;case"TARGETDURATION":l.targetduration=parseFloat(be);break;case"VERSION":l.version=parseInt(be);break;case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"#":(be||Ge)&&I.tagList.push(Ge?[be,Ge]:[be]);break;case"DISCONTINUITY":S++,I.tagList.push(["DIS"]);break;case"GAP":I.tagList.push([ze]);break;case"BITRATE":I.tagList.push([ze,be]);break;case"DATERANGE":var Tt=new de(be),Dt=new ve(Tt,l.dateRanges[Tt.ID]);Dt.isValid||l.skippedSegments?l.dateRanges[Dt.id]=Dt:k.logger.warn('Ignoring invalid DATERANGE tag: "'+be+'"'),I.tagList.push(["EXT-X-DATERANGE",be]);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(be);break;case"KEY":var Zt=xe(be,e);if(Zt.isSupported()){if(Zt.method==="NONE"){s=void 0;break}s||(s={}),s[Zt.keyFormat]&&(s=ye({},s)),s[Zt.keyFormat]=Zt}else k.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+be+'"');break;case"START":var zt=new de(be).decimalFloatingPoint("TIME-OFFSET");(0,R.isFiniteNumber)(zt)&&(l.startTimeOffset=zt);break;case"MAP":var Kt=new de(be);if(I.duration){var er=new $.Fragment(i,e);Ke(er,Kt,t,s),c=er,I.initSegment=c,c.rawProgramDateTime&&!I.rawProgramDateTime&&(I.rawProgramDateTime=c.rawProgramDateTime)}else Ke(I,Kt,t,s),c=I,oe=!0;break;case"SERVER-CONTROL":var Er=new de(be);l.canBlockReload=Er.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=Er.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&Er.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=Er.optionalFloat("PART-HOLD-BACK",0),l.holdBack=Er.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Gn=new de(be);l.partTarget=Gn.decimalFloatingPoint("PART-TARGET");break;case"PART":var Cr=l.partList;Cr||(Cr=l.partList=[]);var Ni=m>0?Cr[Cr.length-1]:void 0,Ui=m++,Bi=new $.Part(new de(be),I,e,Ui,Ni);Cr.push(Bi),I.duration+=Bi.duration;break;case"PRELOAD-HINT":var st=new de(be);l.preloadHint=st;break;case"RENDITION-REPORT":var vt=new de(be);l.renditionReports=l.renditionReports||[],l.renditionReports.push(vt);break;default:k.logger.warn("line parsed but not handled: "+a)}}}P&&!P.relurl?(u.pop(),_-=P.duration,l.partList&&(l.fragmentHint=P)):l.partList&&(Be(I,P),I.cc=S,l.fragmentHint=I);var yi=u.length,Ur=u[0],Or=u[yi-1];if((_+=l.skippedSegments*l.targetduration)>0&&yi&&Or){l.averagetargetduration=_/yi;var Ei=Or.sn;l.endSN=Ei!=="initSegment"?Ei:0,l.live||(Or.endList=!0),Ur&&(l.startCC=Ur.cc)}else l.endSN=0,l.startCC=0;return l.fragmentHint&&(_+=l.fragmentHint.duration),l.totalduration=_,l.endCC=S,q>0&&function(Dr,Br){for(var Xr=Dr[Br],Ar=Br;Ar--;){var zr=Dr[Ar];if(!zr)return;zr.programDateTime=Xr.programDateTime-1e3*zr.duration,Xr=zr}}(u,q),l},d}();function xe(d,o){var e,t,i=new de(d),n=(e=i.enumeratedString("METHOD"))!=null?e:"",a=i.URI,r=i.hexadecimalInteger("IV"),s=i.enumeratedString("KEYFORMATVERSIONS"),l=(t=i.enumeratedString("KEYFORMAT"))!=null?t:"identity";a&&i.IV&&!r&&k.logger.error("Invalid IV: "+i.IV);var u=a?ne.resolve(a,o):"",c=(s||"1").split("/").map(Number).filter(Number.isFinite);return new De(n,u,l,c,r)}function Pe(d,o){["video","audio","text"].forEach(function(e){var t=d.filter(function(n){return function(a,r){var s=Re[r];return!!s&&s[a.slice(0,4)]===!0}(n,e)});if(t.length){var i=t.filter(function(n){return n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0});o[e+"Codec"]=i.length>0?i[0]:t[0],d=d.filter(function(n){return t.indexOf(n)===-1})}}),o.unknownCodecs=d}function Ne(d,o,e){var t=o[e];t&&(d[e]=t)}function Be(d,o){d.rawProgramDateTime?d.programDateTime=Date.parse(d.rawProgramDateTime):o!=null&&o.programDateTime&&(d.programDateTime=o.endProgramDateTime),(0,R.isFiniteNumber)(d.programDateTime)||(d.programDateTime=null,d.rawProgramDateTime=null)}function Ke(d,o,e,t){d.relurl=o.URI,o.BYTERANGE&&d.setByteRange(o.BYTERANGE),d.level=e,d.sn="initSegment",t&&(d.levelkeys=t),d.initSegment=null}var pe=M(308);function Ie(d,o){var e=d.url;return e!==void 0&&e.indexOf("data:")!==0||(e=o.url),e}let Ye=function(){function d(e){this.hls=void 0,this.loaders=Object.create(null),this.hls=e,this.registerListeners()}var o=d.prototype;return o.startLoad=function(e){},o.stopLoad=function(){this.destroyInternalLoaders()},o.registerListeners=function(){var e=this.hls;e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},o.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},o.createInternalLoader=function(e){var t=this.hls.config,i=t.pLoader,n=t.loader,a=new(i||n)(t);return e.loader=a,this.loaders[e.type]=a,a},o.getInternalLoader=function(e){return this.loaders[e.type]},o.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},o.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},o.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},o.onManifestLoading=function(e,t){var i=t.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:pe.PlaylistContextType.MANIFEST,url:i,deliveryDirectives:null})},o.onLevelLoading=function(e,t){var i=t.id,n=t.level,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:null,level:n,responseType:"text",type:pe.PlaylistContextType.LEVEL,url:a,deliveryDirectives:r})},o.onAudioTrackLoading=function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:n,level:null,responseType:"text",type:pe.PlaylistContextType.AUDIO_TRACK,url:a,deliveryDirectives:r})},o.onSubtitleTrackLoading=function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:n,level:null,responseType:"text",type:pe.PlaylistContextType.SUBTITLE_TRACK,url:a,deliveryDirectives:r})},o.load=function(e){var t,i,n,a,r,s,l=this.hls.config,u=this.getInternalLoader(e);if(u){var c=u.context;if(c&&c.url===e.url)return void k.logger.trace("[playlist-loader]: playlist request ongoing");k.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),u.abort()}switch(e.type){case pe.PlaylistContextType.MANIFEST:i=l.manifestLoadingMaxRetry,n=l.manifestLoadingTimeOut,a=l.manifestLoadingRetryDelay,r=l.manifestLoadingMaxRetryTimeout;break;case pe.PlaylistContextType.LEVEL:case pe.PlaylistContextType.AUDIO_TRACK:case pe.PlaylistContextType.SUBTITLE_TRACK:i=0,n=l.levelLoadingTimeOut;break;default:i=l.levelLoadingMaxRetry,n=l.levelLoadingTimeOut,a=l.levelLoadingRetryDelay,r=l.levelLoadingMaxRetryTimeout}if(u=this.createInternalLoader(e),(t=e.deliveryDirectives)!==null&&t!==void 0&&t.part&&(e.type===pe.PlaylistContextType.LEVEL&&e.level!==null?s=this.hls.levels[e.level].details:e.type===pe.PlaylistContextType.AUDIO_TRACK&&e.id!==null?s=this.hls.audioTracks[e.id].details:e.type===pe.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(s=this.hls.subtitleTracks[e.id].details),s)){var v=s.partTarget,m=s.targetduration;v&&m&&(n=Math.min(1e3*Math.max(3*v,.8*m),n))}var _={timeout:n,maxRetry:i,retryDelay:a,maxRetryDelay:r,highWaterMark:0},S={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(e,_,S)},o.loadsuccess=function(e,t,i,n){n===void 0&&(n=null),this.resetInternalLoader(i.type);var a=e.data;a.indexOf("#EXTM3U")===0?(t.parsing.start=performance.now(),a.indexOf("#EXTINF:")>0||a.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,t,i,n):this.handleMasterPlaylist(e,t,i,n)):this.handleManifestParsingError(e,i,"no EXTM3U delimiter",n)},o.loaderror=function(e,t,i){i===void 0&&(i=null),this.handleNetworkError(t,i,!1,e)},o.loadtimeout=function(e,t,i){i===void 0&&(i=null),this.handleNetworkError(t,i,!0)},o.handleMasterPlaylist=function(e,t,i,n){var a=this.hls,r=e.data,s=Ie(e,i),l=ne.parseMasterPlaylist(r,s),u=l.levels,c=l.sessionData,v=l.sessionKeys;if(u.length){var m=u.map(function(q){return{id:q.attrs.AUDIO,audioCodec:q.audioCodec}}),_=u.map(function(q){return{id:q.attrs.SUBTITLES,textCodec:q.textCodec}}),S=ne.parseMasterPlaylistMedia(r,s,"AUDIO",m),P=ne.parseMasterPlaylistMedia(r,s,"SUBTITLES",_),I=ne.parseMasterPlaylistMedia(r,s,"CLOSED-CAPTIONS");S.length&&(S.some(function(q){return!q.url})||!u[0].audioCodec||u[0].attrs.AUDIO||(k.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),S.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new de({}),bitrate:0,url:""}))),a.trigger(p.Events.MANIFEST_LOADED,{levels:u,audioTracks:S,subtitles:P,captions:I,url:s,stats:t,networkDetails:n,sessionData:c,sessionKeys:v})}else this.handleManifestParsingError(e,i,"no level found in manifest",n)},o.handleTrackOrLevelPlaylist=function(e,t,i,n){var a=this.hls,r=i.id,s=i.level,l=i.type,u=Ie(e,i),c=(0,R.isFiniteNumber)(r)?r:0,v=(0,R.isFiniteNumber)(s)?s:c,m=function(P){switch(P.type){case pe.PlaylistContextType.AUDIO_TRACK:return pe.PlaylistLevelType.AUDIO;case pe.PlaylistContextType.SUBTITLE_TRACK:return pe.PlaylistLevelType.SUBTITLE;default:return pe.PlaylistLevelType.MAIN}}(i),_=ne.parseLevelPlaylist(e.data,u,v,m,c);if(_.fragments.length){if(l===pe.PlaylistContextType.MANIFEST){var S={attrs:new de({}),bitrate:0,details:_,name:"",url:u};a.trigger(p.Events.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:u,stats:t,networkDetails:n,sessionData:null,sessionKeys:null})}t.parsing.end=performance.now(),i.levelDetails=_,this.handlePlaylistLoaded(e,t,i,n)}else a.trigger(p.Events.ERROR,{type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:u,reason:"no fragments found in level",level:typeof i.level=="number"?i.level:void 0})},o.handleManifestParsingError=function(e,t,i,n){this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===pe.PlaylistContextType.MANIFEST,url:e.url,reason:i,response:e,context:t,networkDetails:n})},o.handleNetworkError=function(e,t,i,n){i===void 0&&(i=!1),k.logger.warn("[playlist-loader]: A network "+(i?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var a=w.ErrorDetails.UNKNOWN,r=!1,s=this.getInternalLoader(e);switch(e.type){case pe.PlaylistContextType.MANIFEST:a=i?w.ErrorDetails.MANIFEST_LOAD_TIMEOUT:w.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case pe.PlaylistContextType.LEVEL:a=i?w.ErrorDetails.LEVEL_LOAD_TIMEOUT:w.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case pe.PlaylistContextType.AUDIO_TRACK:a=i?w.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:w.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case pe.PlaylistContextType.SUBTITLE_TRACK:a=i?w.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:w.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1}s&&this.resetInternalLoader(e.type);var l={type:w.ErrorTypes.NETWORK_ERROR,details:a,fatal:r,url:e.url,loader:s,context:e,networkDetails:t};n&&(l.response=n),this.hls.trigger(p.Events.ERROR,l)},o.handlePlaylistLoaded=function(e,t,i,n){var a=i.type,r=i.level,s=i.id,l=i.groupId,u=i.loader,c=i.levelDetails,v=i.deliveryDirectives;if(c!=null&&c.targetduration){if(u)switch(c.live&&(u.getCacheAge&&(c.ageHeader=u.getCacheAge()||0),u.getCacheAge&&!isNaN(c.ageHeader)||(c.ageHeader=0)),a){case pe.PlaylistContextType.MANIFEST:case pe.PlaylistContextType.LEVEL:this.hls.trigger(p.Events.LEVEL_LOADED,{details:c,level:r||0,id:s||0,stats:t,networkDetails:n,deliveryDirectives:v});break;case pe.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,{details:c,id:s||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:v});break;case pe.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADED,{details:c,id:s||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:v})}}else this.handleManifestParsingError(e,i,"invalid target duration",n)},d}();function rt(d,o){var e;try{e=new Event("addtrack")}catch{(e=document.createEvent("Event")).initEvent("addtrack",!1,!1)}e.track=d,o.dispatchEvent(e)}function yt(d,o){var e=d.mode;if(e==="disabled"&&(d.mode="hidden"),d.cues&&!d.cues.getCueById(o.id))try{if(d.addCue(o),!d.cues.getCueById(o.id))throw new Error("addCue is failed for: "+o)}catch(i){k.logger.debug("[texttrack-utils]: "+i);var t=new self.TextTrackCue(o.startTime,o.endTime,o.text);t.id=o.id,d.addCue(t)}e==="disabled"&&(d.mode=e)}function ht(d){var o=d.mode;if(o==="disabled"&&(d.mode="hidden"),d.cues)for(var e=d.cues.length;e--;)d.removeCue(d.cues[e]);o==="disabled"&&(d.mode=o)}function It(d,o,e,t){var i=d.mode;if(i==="disabled"&&(d.mode="hidden"),d.cues&&d.cues.length>0)for(var n=function(r,s,l){var u=[],c=function(S,P){if(P<S[0].startTime)return 0;var I=S.length-1;if(P>S[I].endTime)return-1;for(var q=0,oe=I;q<=oe;){var Ee=Math.floor((oe+q)/2);if(P<S[Ee].startTime)oe=Ee-1;else{if(!(P>S[Ee].startTime&&q<I))return Ee;q=Ee+1}}return S[q].startTime-P<P-S[oe].startTime?q:oe}(r,s);if(c>-1)for(var v=c,m=r.length;v<m;v++){var _=r[v];if(_.startTime>=s&&_.endTime<=l)u.push(_);else if(_.startTime>l)return u}return u}(d.cues,o,e),a=0;a<n.length;a++)t&&!t(n[a])||d.removeCue(n[a]);i==="disabled"&&(d.mode=i)}var Lt=M(181),St=M(856);function At(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var pt=function(){var d=At();try{new d(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function ut(d,o){return d.getTime()/1e3-o}let Rt=function(){function d(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var o=d.prototype;return o.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},o._registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},o._unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},o.onMediaAttached=function(e,t){this.media=t.media},o.onMediaDetaching=function(){this.id3Track&&(ht(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},o.onManifestLoading=function(){this.dateRangeCuesAppended={}},o.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},o.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 rt(i,this.media),i}return this.media.addTextTrack("metadata","id3")}},o.onFragParsingMetadata=function(e,t){if(this.media){var i=this.hls.config,n=i.enableEmsgMetadataCues,a=i.enableID3MetadataCues;if(n||a){var r=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var s=At(),l=0;l<r.length;l++){var u=r[l].type;if((u!==St.MetadataSchema.emsg||n)&&a){var c=Lt.getID3Frames(r[l].data);if(c){var v=r[l].pts,m=v+r[l].duration;m>pt&&(m=pt),m-v<=0&&(m=v+.25);for(var _=0;_<c.length;_++){var S=c[_];if(!Lt.isTimeStampFrame(S)){this.updateId3CueEnds(v);var P=new s(v,m,"");P.value=S,u&&(P.type=u),this.id3Track.addCue(P)}}}}}}}},o.updateId3CueEnds=function(e){var t,i=(t=this.id3Track)===null||t===void 0?void 0:t.cues;if(i)for(var n=i.length;n--;){var a=i[n];a.startTime<e&&a.endTime===pt&&(a.endTime=e)}},o.onBufferFlushing=function(e,t){var i=t.startOffset,n=t.endOffset,a=t.type,r=this.id3Track,s=this.hls;if(s){var l=s.config,u=l.enableEmsgMetadataCues,c=l.enableID3MetadataCues;r&&(u||c)&&It(r,i,n,a==="audio"?function(v){return v.type===St.MetadataSchema.audioId3&&c}:a==="video"?function(v){return v.type===St.MetadataSchema.emsg&&u}:function(v){return v.type===St.MetadataSchema.audioId3&&c||v.type===St.MetadataSchema.emsg&&u})}},o.onLevelUpdated=function(e,t){var i=this,n=t.details;if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,r=this.id3Track,s=n.dateRanges,l=Object.keys(s);if(r)for(var u=Object.keys(a).filter(function(q){return!l.includes(q)}),c=function(q){var oe=u[q];Object.keys(a[oe].cues).forEach(function(Ee){r.removeCue(a[oe].cues[Ee])}),delete a[oe]},v=u.length;v--;)c(v);var m=n.fragments[n.fragments.length-1];if(l.length!==0&&(0,R.isFiniteNumber)(m==null?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var _=m.programDateTime/1e3-m.start,S=At(),P=function(q){var oe=l[q],Ee=s[oe],he=a[oe],Ae=(he==null?void 0:he.cues)||{},He=(he==null?void 0:he.durationKnown)||!1,ze=ut(Ee.startDate,_),be=pt,Ge=Ee.endDate;if(Ge)be=ut(Ge,_),He=!0;else if(Ee.endOnNext&&!He){var Me=l.reduce(function(zt,Kt){var er=s[Kt];return er.class===Ee.class&&er.id!==Kt&&er.startDate>Ee.startDate&&zt.push(er),zt},[]).sort(function(zt,Kt){return zt.startDate.getTime()-Kt.startDate.getTime()})[0];Me&&(be=ut(Me.startDate,_),He=!0)}for(var ct,Ot=Object.keys(Ee.attr),ft=0;ft<Ot.length;ft++){var Tt=Ot[ft];if(Tt!==j.ID&&Tt!==j.CLASS&&Tt!==j.START_DATE&&Tt!==j.DURATION&&Tt!==j.END_DATE&&Tt!==j.END_ON_NEXT){var Dt=Ae[Tt];if(Dt)He&&!he.durationKnown&&(Dt.endTime=be);else{var Zt=Ee.attr[Tt];Dt=new S(ze,be,""),Tt!==j.SCTE35_OUT&&Tt!==j.SCTE35_IN||(ct=Zt,Zt=Uint8Array.from(ct.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),Dt.value={key:Tt,data:Zt},Dt.type=St.MetadataSchema.dateRange,i.id3Track.addCue(Dt),Ae[Tt]=Dt}}}a[oe]={cues:Ae,dateRange:Ee,durationKnown:He}},I=0;I<l.length;I++)P(I)}}},d}();function Ct(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var Ht=function(){function d(i){var n=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 n.timeupdate()},this.hls=i,this.config=i.config,this.registerListeners()}var o,e,t=d.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},t.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(p.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(p.Events.ERROR,this.onError)},t.onMediaAttached=function(i,n){this.media=n.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(i,n){var a=n.details;this.levelDetails=a,a.advanced&&this.timeupdate(),!a.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},t.onError=function(i,n){n.details===w.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,k.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},t.timeupdate=function(){var i=this.media,n=this.levelDetails;if(i&&n){this.currentTime=i.currentTime;var a=this.computeLatency();if(a!==null){this._latency=a;var r=this.config,s=r.lowLatencyMode,l=r.maxLiveSyncPlaybackRate;if(s&&l!==1){var u=this.targetLatency;if(u!==null){var c=a-u,v=c<Math.min(this.maxLatency,u+n.targetduration);if(n.live&&v&&c>.05&&this.forwardBufferLength>1){var m=Math.min(2,Math.max(1,l)),_=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20;i.playbackRate=Math.min(m,Math.max(1,_))}else i.playbackRate!==1&&i.playbackRate!==0&&(i.playbackRate=1)}}}}},t.estimateLiveEdge=function(){var i=this.levelDetails;return i===null?null:i.edge+i.age},t.computeLatency=function(){var i=this.estimateLiveEdge();return i===null?null:i-this.currentTime},o=d,(e=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var i=this.config,n=this.levelDetails;return i.liveMaxLatencyDuration!==void 0?i.liveMaxLatencyDuration:n?i.liveMaxLatencyDurationCount*n.targetduration:0}},{key:"targetLatency",get:function(){var i=this.levelDetails;if(i===null)return null;var n=i.holdBack,a=i.partHoldBack,r=i.targetduration,s=this.config,l=s.liveSyncDuration,u=s.liveSyncDurationCount,c=s.lowLatencyMode,v=this.hls.userConfig,m=c&&a||n;(v.liveSyncDuration||v.liveSyncDurationCount||m===0)&&(m=l!==void 0?l:u*r);var _=r;return m+Math.min(1*this.stallCount,_)}},{key:"liveSyncPosition",get:function(){var i=this.estimateLiveEdge(),n=this.targetLatency,a=this.levelDetails;if(i===null||n===null||a===null)return null;var r=a.edge,s=i-n-this.edgeStalled,l=r-a.totalduration,u=r-(this.config.lowLatencyMode&&a.partTarget||a.targetduration);return Math.min(Math.max(l,s),u)}},{key:"drift",get:function(){var i=this.levelDetails;return i===null?1:i.drift}},{key:"edgeStalled",get:function(){var i=this.levelDetails;if(i===null)return 0;var n=3*(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.max(i.age-n,0)}},{key:"forwardBufferLength",get:function(){var i=this.media,n=this.levelDetails;if(!i||!n)return 0;var a=i.buffered.length;return(a?i.buffered.end(a-1):n.edge)-this.currentTime}}])&&Ct(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function Qt(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var Ut,ur=["NONE","TYPE-0","TYPE-1","TYPE-2",null];(function(d){d.No="",d.Yes="YES",d.v2="v2"})(Ut||(Ut={}));var ee=function(){function d(o,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=o,this.part=e,this.skip=t}return d.prototype.addDirectives=function(o){var e=new self.URL(o);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},d}(),F=function(){function d(t){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=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(function(i){return i}).join(",").replace(/\.[^.,]+/g,"")}var o,e;return o=d,(e=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var i=t%this.url.length;this._urlId!==i&&(this.details=void 0,this._urlId=i)}}])&&Qt(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function T(){return T=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},T.apply(this,arguments)}function C(d,o,e){switch(o){case"audio":d.audioGroupIds||(d.audioGroupIds=[]),d.audioGroupIds.push(e);break;case"text":d.textGroupIds||(d.textGroupIds=[]),d.textGroupIds.push(e)}}function L(d){var o={};d.forEach(function(e){var t=e.groupId||"";e.id=o[t]=o[t]||0,o[t]++})}function B(d,o){var e=o.startPTS;if((0,R.isFiniteNumber)(e)){var t,i=0;o.sn>d.sn?(i=e-d.start,t=d):(i=d.start-e,t=o),t.duration!==i&&(t.duration=i)}else o.sn>d.sn?d.cc===o.cc&&d.minEndPTS?o.start=d.start+(d.minEndPTS-d.start):o.start=d.start+d.duration:o.start=Math.max(d.start-o.duration,0)}function Y(d,o,e,t,i,n){t-e<=0&&(k.logger.warn("Fragment should have a positive duration",o),t=e+o.duration,n=i+o.duration);var a=e,r=t,s=o.startPTS,l=o.endPTS;if((0,R.isFiniteNumber)(s)){var u=Math.abs(s-e);(0,R.isFiniteNumber)(o.deltaPTS)?o.deltaPTS=Math.max(u,o.deltaPTS):o.deltaPTS=u,a=Math.max(e,s),e=Math.min(e,s),i=Math.min(i,o.startDTS),r=Math.min(t,l),t=Math.max(t,l),n=Math.max(n,o.endDTS)}o.duration=t-e;var c=e-o.start;o.start=o.startPTS=e,o.maxStartPTS=a,o.startDTS=i,o.endPTS=t,o.minEndPTS=r,o.endDTS=n;var v,m=o.sn;if(!d||m<d.startSN||m>d.endSN)return 0;var _=m-d.startSN,S=d.fragments;for(S[_]=o,v=_;v>0;v--)B(S[v],S[v-1]);for(v=_;v<S.length-1;v++)B(S[v],S[v+1]);return d.fragmentHint&&B(S[S.length-1],d.fragmentHint),d.PTSKnown=d.alignedSliding=!0,c}function Q(d,o){var e=o.startSN+o.skippedSegments-d.startSN,t=d.fragments;e<0||e>=t.length||ge(o,t[e].start)}function ge(d,o){if(o){for(var e=d.fragments,t=d.skippedSegments;t<e.length;t++)e[t].start+=o;d.fragmentHint&&(d.fragmentHint.start+=o)}}var we=function(){function d(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=k.logger.log.bind(k.logger,t+":"),this.warn=k.logger.warn.bind(k.logger,t+":"),this.hls=e}var o=d.prototype;return o.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},o.onError=function(e,t){!t.fatal||t.type!==w.ErrorTypes.NETWORK_ERROR&&t.type!==w.ErrorTypes.KEY_SYSTEM_ERROR||this.stopLoad()},o.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},o.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},o.stopLoad=function(){this.canLoad=!1,this.clearTimer()},o.switchParams=function(e,t){var i=t==null?void 0:t.renditionReports;if(i)for(var n=0;n<i.length;n++){var a=i[n],r=void 0;try{r=new self.URL(a.URI,t.url).href}catch(c){k.logger.warn("Could not construct new URL for Rendition Report: "+c),r=a.URI||""}if(r===e.slice(-r.length)){var s=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn),l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}return new ee(s,l>=0?l:void 0,Ut.No)}}},o.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},o.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},o.playlistLoaded=function(e,t,i){var n=this,a=t.details,r=t.stats,s=self.performance.now(),l=r.loading.first?Math.max(0,s-r.loading.first):0;if(a.advancedDateTime=Date.now()-l,a.live||i!=null&&i.live){if(a.reloaded(i),i&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),i&&a.fragments.length>0&&function(Ge,Me){for(var ct=null,Ot=Ge.fragments,ft=Ot.length-1;ft>=0;ft--){var Tt=Ot[ft].initSegment;if(Tt){ct=Tt;break}}Ge.fragmentHint&&delete Ge.fragmentHint.endPTS;var Dt,Zt,zt,Kt,er,Er=0;if(function(st,vt,yi){for(var Ur=vt.skippedSegments,Or=Math.max(st.startSN,vt.startSN)-vt.startSN,Ei=(st.fragmentHint?1:0)+(Ur?vt.endSN:Math.min(st.endSN,vt.endSN))-vt.startSN,Dr=vt.startSN-st.startSN,Br=vt.fragmentHint?vt.fragments.concat(vt.fragmentHint):vt.fragments,Xr=st.fragmentHint?st.fragments.concat(st.fragmentHint):st.fragments,Ar=Or;Ar<=Ei;Ar++){var zr=Xr[Dr+Ar],dn=Br[Ar];Ur&&!dn&&Ar<Ur&&(dn=vt.fragments[Ar]=zr),zr&&dn&&yi(zr,dn)}}(Ge,Me,function(st,vt){st.relurl&&(Er=st.cc-vt.cc),(0,R.isFiniteNumber)(st.startPTS)&&(0,R.isFiniteNumber)(st.endPTS)&&(vt.start=vt.startPTS=st.startPTS,vt.startDTS=st.startDTS,vt.appendedPTS=st.appendedPTS,vt.maxStartPTS=st.maxStartPTS,vt.endPTS=st.endPTS,vt.endDTS=st.endDTS,vt.minEndPTS=st.minEndPTS,vt.duration=st.endPTS-st.startPTS,vt.duration&&(Dt=vt),Me.PTSKnown=Me.alignedSliding=!0),vt.elementaryStreams=st.elementaryStreams,vt.loader=st.loader,vt.stats=st.stats,vt.urlId=st.urlId,st.initSegment&&(vt.initSegment=st.initSegment,ct=st.initSegment)}),ct&&(Me.fragmentHint?Me.fragments.concat(Me.fragmentHint):Me.fragments).forEach(function(st){var vt;st.initSegment&&st.initSegment.relurl!==((vt=ct)===null||vt===void 0?void 0:vt.relurl)||(st.initSegment=ct)}),Me.skippedSegments)if(Me.deltaUpdateFailed=Me.fragments.some(function(st){return!st}),Me.deltaUpdateFailed){k.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var Gn=Me.skippedSegments;Gn--;)Me.fragments.shift();Me.startSN=Me.fragments[0].sn,Me.startCC=Me.fragments[0].cc}else Me.canSkipDateRanges&&(Me.dateRanges=(Zt=Ge.dateRanges,zt=Me.dateRanges,Kt=Me.recentlyRemovedDateranges,er=T({},Zt),Kt&&Kt.forEach(function(st){delete er[st]}),Object.keys(zt).forEach(function(st){var vt=new ve(zt[st].attr,er[st]);vt.isValid?er[st]=vt:k.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(zt[st].attr)+'"')}),er));var Cr=Me.fragments;if(Er){k.logger.warn("discontinuity sliding from playlist, take drift into account");for(var Ni=0;Ni<Cr.length;Ni++)Cr[Ni].cc+=Er}Me.skippedSegments&&(Me.startCC=Me.fragments[0].cc),function(st,vt,yi){if(st&&vt)for(var Ur=0,Or=0,Ei=st.length;Or<=Ei;Or++){var Dr=st[Or],Br=vt[Or+Ur];Dr&&Br&&Dr.index===Br.index&&Dr.fragment.sn===Br.fragment.sn?(Xr=Dr,(Ar=Br).elementaryStreams=Xr.elementaryStreams,Ar.stats=Xr.stats):Ur--}var Xr,Ar}(Ge.partList,Me.partList),Dt?Y(Me,Dt,Dt.startPTS,Dt.endPTS,Dt.startDTS,Dt.endDTS):Q(Ge,Me),Cr.length&&(Me.totalduration=Me.edge-Cr[0].start),Me.driftStartTime=Ge.driftStartTime,Me.driftStart=Ge.driftStart;var Ui=Me.advancedDateTime;if(Me.advanced&&Ui){var Bi=Me.edge;Me.driftStart||(Me.driftStartTime=Ui,Me.driftStart=Bi),Me.driftEndTime=Ui,Me.driftEnd=Bi}else Me.driftEndTime=Ge.driftEndTime,Me.driftEnd=Ge.driftEnd,Me.advancedDateTime=Ge.advancedDateTime}(i,a),!this.canLoad||!a.live)return;var u,c=void 0,v=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var m=this.hls.config.lowLatencyMode,_=a.lastPartSn,S=a.endSN,P=a.lastPartIndex,I=_===S;P!==-1?(c=I?S+1:_,v=I?m?0:P:P+1):c=S+1;var q=a.age,oe=q+a.ageHeader,Ee=Math.min(oe-a.partTarget,1.5*a.targetduration);if(Ee>0){if(i&&Ee>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+Ee+" with playlist age: "+a.age),Ee=0;else{var he=Math.floor(Ee/a.targetduration);c+=he,v!==void 0&&(v+=Math.round(Ee%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+q.toFixed(2)+"s goal: "+Ee+" skip sn "+he+" to part "+v)}a.tuneInGoal=Ee}if(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,v),m||!I)return void this.loadPlaylist(u)}else u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,v);var Ae=this.hls.mainForwardBufferInfo,He=Ae?Ae.end-Ae.len:0,ze=function(Ge,Me){Me===void 0&&(Me=1/0);var ct=1e3*Ge.targetduration;if(Ge.updated){var Ot=Ge.fragments;if(Ot.length&&4*ct>Me){var ft=1e3*Ot[Ot.length-1].duration;ft<ct&&(ct=ft)}}else ct/=2;return Math.round(ct)}(a,1e3*(a.edge-He));a.updated?s>this.requestScheduled+ze&&(this.requestScheduled=r.loading.start):this.requestScheduled=-1,c!==void 0&&a.canBlockReload?this.requestScheduled=r.loading.first+ze-(1e3*a.partTarget||1e3):this.requestScheduled=(this.requestScheduled===-1?s:this.requestScheduled)+ze;var be=this.requestScheduled-s;be=Math.max(0,be),this.log("reload live playlist "+e+" in "+Math.round(be)+" ms"),this.timer=self.setTimeout(function(){return n.loadPlaylist(u)},be)}else this.clearTimer()},o.getDeliveryDirectives=function(e,t,i,n){var a=function(r,s){var l=r.canSkipUntil,u=r.canSkipDateRanges,c=r.endSN;return l&&(s!==void 0?s-c:0)<l?u?Ut.v2:Ut.Yes:Ut.No}(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=Ut.No),new ee(i,n,a)},o.retryLoadingOrFail=function(e){var t,i=this,n=this.hls.config,a=this.retryCount<n.levelLoadingMaxRetry;if(a)if(this.requestScheduled=-1,this.retryCount++,e.details.indexOf("LoadTimeOut")>-1&&(t=e.context)!==null&&t!==void 0&&t.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+e.details+'"'),this.loadPlaylist();else{var r=Math.min(Math.pow(2,this.retryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return i.loadPlaylist()},r),this.warn("retry playlist loading #"+this.retryCount+" in "+r+' ms after "'+e.details+'"')}else this.warn('cannot recover from error "'+e.details+'"'),this.clearTimer(),e.fatal=!0;return a},d}();function Le(){return Le=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},Le.apply(this,arguments)}function Fe(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Ve(d,o){return Ve=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ve(d,o)}var Ue,Qe=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),ot=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[level-controller]")||this)._levels=[],s._firstLevel=-1,s._startLevel=void 0,s.currentLevelIndex=-1,s.manualLevelIndex=-1,s.onParsedComplete=void 0,s._registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ve(o,e);var i,n,a=t.prototype;return a._registerListeners=function(){var r=this.hls;r.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),r.on(p.Events.ERROR,this.onError,this)},a._unregisterListeners=function(){var r=this.hls;r.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),r.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),r.off(p.Events.ERROR,this.onError,this)},a.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,d.prototype.destroy.call(this)},a.startLoad=function(){this._levels.forEach(function(r){r.loadError=0}),d.prototype.startLoad.call(this)},a.onManifestLoaded=function(r,s){var l,u,c=[],v=[],m=[],_={},S=!1,P=!1,I=!1;if(s.levels.forEach(function(he){var Ae=he.attrs;S=S||!(!he.width||!he.height),P=P||!!he.videoCodec,I=I||!!he.audioCodec,Qe&&he.audioCodec&&he.audioCodec.indexOf("mp4a.40.34")!==-1&&(he.audioCodec=void 0);var He=he.bitrate+"-"+he.attrs.RESOLUTION+"-"+he.attrs.CODECS;(u=_[He])?u.url.push(he.url):(u=new F(he),_[He]=u,c.push(u)),Ae&&(Ae.AUDIO&&C(u,"audio",Ae.AUDIO),Ae.SUBTITLES&&C(u,"text",Ae.SUBTITLES))}),(S||P)&&I&&(c=c.filter(function(he){var Ae=he.videoCodec,He=he.width,ze=he.height;return!!Ae||!(!He||!ze)})),c=c.filter(function(he){var Ae=he.audioCodec,He=he.videoCodec;return(!Ae||Oe(Ae,"audio"))&&(!He||Oe(He,"video"))}),s.audioTracks&&L(v=s.audioTracks.filter(function(he){return!he.audioCodec||Oe(he.audioCodec,"audio")})),s.subtitles&&L(m=s.subtitles),c.length>0){l=c[0].bitrate,c.sort(function(he,Ae){return he.attrs["HDCP-LEVEL"]!==Ae.attrs["HDCP-LEVEL"]?(he.attrs["HDCP-LEVEL"]||"")>(Ae.attrs["HDCP-LEVEL"]||"")?1:-1:he.bitrate!==Ae.bitrate?he.bitrate-Ae.bitrate:he.attrs.SCORE!==Ae.attrs.SCORE?he.attrs.decimalFloatingPoint("SCORE")-Ae.attrs.decimalFloatingPoint("SCORE"):S&&he.height!==Ae.height?he.height-Ae.height:0}),this._levels=c;for(var q=0;q<c.length;q++)if(c[q].bitrate===l){this._firstLevel=q,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+l);break}var oe=I&&!P,Ee={levels:c,audioTracks:v,subtitleTracks:m,sessionData:s.sessionData,sessionKeys:s.sessionKeys,firstLevel:this._firstLevel,stats:s.stats,audio:I,video:P,altAudio:!oe&&v.some(function(he){return!!he.url})};this.hls.trigger(p.Events.MANIFEST_PARSED,Ee),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:s.url,reason:"no level with compatible codecs found in manifest"})},a.onError=function(r,s){var l,u;if(d.prototype.onError.call(this,r,s),!s.fatal){var c=s.context,v=this._levels[this.currentLevelIndex];if(c&&(c.type===pe.PlaylistContextType.AUDIO_TRACK&&v.audioGroupIds&&c.groupId===v.audioGroupIds[v.urlId]||c.type===pe.PlaylistContextType.SUBTITLE_TRACK&&v.textGroupIds&&c.groupId===v.textGroupIds[v.urlId]))this.redundantFailover(this.currentLevelIndex);else{var m,_=!1,S=!0;switch(s.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:if(s.frag){var P=s.frag.type===pe.PlaylistLevelType.MAIN?s.frag.level:this.currentLevelIndex,I=this._levels[P];I?(I.fragmentError++,I.fragmentError>this.hls.config.fragLoadingMaxRetry&&(m=P)):m=P}break;case w.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var q=v.attrs["HDCP-LEVEL"];q&&(this.hls.maxHdcpLevel=ur[ur.indexOf(q)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'));case w.ErrorDetails.FRAG_PARSING_ERROR:case w.ErrorDetails.KEY_SYSTEM_NO_SESSION:m=((l=s.frag)===null||l===void 0?void 0:l.type)===pe.PlaylistLevelType.MAIN?s.frag.level:this.currentLevelIndex,s.levelRetry=!1;break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(S=!1),m=c.level),_=!0;break;case w.ErrorDetails.REMUX_ALLOC_ERROR:m=(u=s.level)!=null?u:this.currentLevelIndex,_=!0}m!==void 0&&this.recoverLevel(s,m,_,S)}}},a.recoverLevel=function(r,s,l,u){var c=r.details,v=this._levels[s];if(v.loadError++,l){if(!this.retryLoadingOrFail(r))return void(this.currentLevelIndex=-1);r.levelRetry=!0}if(u){var m=v.url.length;if(m>1&&v.loadError<m)r.levelRetry=!0,this.redundantFailover(s);else if(this.manualLevelIndex===-1){for(var _=-1,S=this._levels,P=S.length;P--;){var I=(P+this.currentLevelIndex)%S.length;if(I!==this.currentLevelIndex&&S[I].loadError===0){_=I;break}}_>-1&&this.currentLevelIndex!==_?(this.warn(c+": switch to "+_),r.levelRetry=!0,this.hls.nextAutoLevel=_):r.levelRetry===!1&&(r.fatal=!0)}}},a.redundantFailover=function(r){var s=this._levels[r],l=s.url.length;if(l>1){var u=(s.urlId+1)%l;this.warn("Switching to redundant URL-id "+u),this._levels.forEach(function(c){c.urlId=u}),this.level=r}},a.onFragLoaded=function(r,s){var l=s.frag;if(l!==void 0&&l.type===pe.PlaylistLevelType.MAIN){var u=this._levels[l.level];u!==void 0&&(u.fragmentError=0,u.loadError=0)}},a.onLevelLoaded=function(r,s){var l,u,c=s.level,v=s.details,m=this._levels[c];if(!m)return this.warn("Invalid level index "+c),void((u=s.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(v.deltaUpdateFailed=!0));c===this.currentLevelIndex?(m.fragmentError===0&&(m.loadError=0,this.retryCount=0),this.playlistLoaded(c,s,m.details)):(l=s.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(v.deltaUpdateFailed=!0)},a.onAudioTrackSwitched=function(r,s){var l=this.hls.levels[this.currentLevelIndex];if(l&&l.audioGroupIds){for(var u=-1,c=this.hls.audioTracks[s.id].groupId,v=0;v<l.audioGroupIds.length;v++)if(l.audioGroupIds[v]===c){u=v;break}u!==l.urlId&&(l.urlId=u,this.startLoad())}},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.currentLevelIndex,l=this._levels[s];if(this.canLoad&&l&&l.url.length>0){var u=l.urlId,c=l.url[u];if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("Attempt loading level index "+s+(r?" at sn "+r.msn+" part "+r.part:"")+" with URL-id "+u+" "+c),this.clearTimer(),this.hls.trigger(p.Events.LEVEL_LOADING,{url:c,level:s,id:u,deliveryDirectives:r||null})}},a.removeLevel=function(r,s){var l=function(c,v){return v!==s},u=this._levels.filter(function(c,v){return v!==r||c.url.length>1&&s!==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)}).map(function(c,v){var m=c.details;return m!=null&&m.fragments&&m.fragments.forEach(function(_){_.level=v}),c});this._levels=u,this.hls.trigger(p.Events.LEVELS_UPDATED,{levels:u})},i=t,(n=[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(r){var s,l=this._levels;if(l.length!==0&&(this.currentLevelIndex!==r||(s=l[r])===null||s===void 0||!s.details)){if(r<0||r>=l.length){var u=r<0;if(this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.LEVEL_SWITCH_ERROR,level:r,fatal:u,reason:"invalid level idx"}),u)return;r=Math.min(r,l.length-1)}this.clearTimer();var c=this.currentLevelIndex,v=l[c],m=l[r];this.log("switching to level "+r+" from "+c),this.currentLevelIndex=r;var _=Le({},m,{level:r,maxBitrate:m.maxBitrate,uri:m.uri,urlId:m.urlId});delete _._urlId,this.hls.trigger(p.Events.LEVEL_SWITCHING,_);var S=m.details;if(!S||S.live){var P=this.switchParams(m.uri,v==null?void 0:v.details);this.loadPlaylist(P)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(r){this.manualLevelIndex=r,this._startLevel===void 0&&(this._startLevel=r),r!==-1&&(this.level=r)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(r){this._firstLevel=r}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var r=this.hls.config.startLevel;return r!==void 0?r:this._firstLevel}return this._startLevel},set:function(r){this._startLevel=r}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(r){this.level=r,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=r)}}])&&Fe(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(we);(function(d){d.NOT_LOADED="NOT_LOADED",d.APPENDING="APPENDING",d.PARTIAL="PARTIAL",d.OK="OK"})(Ue||(Ue={}));var bt=function(){function d(e){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}var o=d.prototype;return o._registerListeners=function(){var e=this.hls;e.on(p.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.Events.FRAG_LOADED,this.onFragLoaded,this)},o._unregisterListeners=function(){var e=this.hls;e.off(p.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.Events.FRAG_LOADED,this.onFragLoaded,this)},o.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},o.getAppendedFrag=function(e,t){if(t===pe.PlaylistLevelType.MAIN){var i=this.activeFragment,n=this.activeParts;if(!i)return null;if(n)for(var a=n.length;a--;){var r=n[a],s=r?r.end:i.appendedPTS;if(r.start<=e&&s!==void 0&&e<=s)return a>9&&(this.activeParts=n.slice(a-9)),r}else if(i.start<=e&&i.appendedPTS!==void 0&&e<=i.appendedPTS)return i}return this.getBufferedFrag(e,t)},o.getBufferedFrag=function(e,t){for(var i=this.fragments,n=Object.keys(i),a=n.length;a--;){var r=i[n[a]];if((r==null?void 0:r.body.type)===t&&r.buffered){var s=r.body;if(s.start<=e&&e<=s.end)return s}}return null},o.detectEvictedFragments=function(e,t,i){var n=this;this.timeRanges&&(this.timeRanges[e]=t),Object.keys(this.fragments).forEach(function(a){var r=n.fragments[a];if(r)if(r.buffered||r.loaded){var s=r.range[e];s&&s.time.some(function(l){var u=!n.isTimeBuffered(l.startPTS,l.endPTS,t);return u&&n.removeFragment(r.body),u})}else r.body.type===i&&n.removeFragment(r.body)})},o.detectPartialFragments=function(e){var t=this,i=this.timeRanges,n=e.frag,a=e.part;if(i&&n.sn!=="initSegment"){var r=kt(n),s=this.fragments[r];s&&(Object.keys(i).forEach(function(l){var u=n.elementaryStreams[l];if(u){var c=i[l],v=a!==null||u.partial===!0;s.range[l]=t.getBufferedTimes(n,a,v,c)}}),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,s.body.endList&&(this.endListFragments[s.body.type]=s)):this.removeFragment(s.body))}},o.fragBuffered=function(e){var t=kt(e),i=this.fragments[t];i&&(i.loaded=null,i.buffered=!0)},o.getBufferedTimes=function(e,t,i,n){for(var a={time:[],partial:i},r=t?t.start:e.start,s=t?t.end:e.end,l=e.minEndPTS||s,u=e.maxStartPTS||r,c=0;c<n.length;c++){var v=n.start(c)-this.bufferPadding,m=n.end(c)+this.bufferPadding;if(u>=v&&l<=m){a.time.push({startPTS:Math.max(r,n.start(c)),endPTS:Math.min(s,n.end(c))});break}if(r<m&&s>v)a.partial=!0,a.time.push({startPTS:Math.max(r,n.start(c)),endPTS:Math.min(s,n.end(c))});else if(s<=v)break}return a},o.getPartialFragment=function(e){var t,i,n,a=null,r=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach(function(u){var c=l[u];c&&We(c)&&(i=c.body.start-s,n=c.body.end+s,e>=i&&e<=n&&(t=Math.min(e-i,n-e),r<=t&&(a=c.body,r=t)))}),a},o.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||We(t))},o.getState=function(e){var t=kt(e),i=this.fragments[t];return i?i.buffered?We(i)?Ue.PARTIAL:Ue.OK:Ue.APPENDING:Ue.NOT_LOADED},o.isTimeBuffered=function(e,t,i){for(var n,a,r=0;r<i.length;r++){if(n=i.start(r)-this.bufferPadding,a=i.end(r)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1},o.onFragLoaded=function(e,t){var i=t.frag,n=t.part;if(i.sn!=="initSegment"&&!i.bitrateTest&&!n){var a=kt(i);this.fragments[a]={body:i,loaded:t,buffered:!1,range:Object.create(null)}}},o.onBufferAppended=function(e,t){var i=this,n=t.frag,a=t.part,r=t.timeRanges;if(n.type===pe.PlaylistLevelType.MAIN)if(this.activeFragment!==n&&(this.activeFragment=n,n.appendedPTS=void 0),a){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(a)}else this.activeParts=null;this.timeRanges=r,Object.keys(r).forEach(function(l){var u=r[l];if(i.detectEvictedFragments(l,u),!a&&n.type===pe.PlaylistLevelType.MAIN){var c=n.elementaryStreams[l];if(!c)return;for(var v=0;v<u.length;v++){var m=u.end(v);m<=c.endPTS&&m>c.startPTS?n.appendedPTS=Math.max(m,n.appendedPTS||0):n.appendedPTS=c.endPTS}}})},o.onFragBuffered=function(e,t){this.detectPartialFragments(t)},o.hasFragment=function(e){var t=kt(e);return!!this.fragments[t]},o.removeFragmentsInRange=function(e,t,i){var n=this;Object.keys(this.fragments).forEach(function(a){var r=n.fragments[a];if(r&&r.buffered){var s=r.body;s.type===i&&s.start<t&&s.end>e&&n.removeFragment(s)}})},o.removeFragment=function(e){var t=kt(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),e.appendedPTS=void 0,delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},o.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},d}();function We(d){var o,e;return d.buffered&&(((o=d.range.video)===null||o===void 0?void 0:o.partial)||((e=d.range.audio)===null||e===void 0?void 0:e.partial))}function kt(d){return d.type+"_"+d.level+"_"+d.urlId+"_"+d.sn}function Jt(d){var o=typeof Map=="function"?new Map:void 0;return Jt=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(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return Ft(e,arguments,Ze(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Bt(i,e)},Jt(d)}function Ft(d,o,e){return Ft=Pt()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Bt(r,n.prototype),r},Ft.apply(null,arguments)}function Pt(){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 Bt(d,o){return Bt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Bt(d,o)}function Ze(d){return Ze=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},Ze(d)}var ir=Math.pow(2,17),br=function(){function d(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var o=d.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(e,t){var i=this,n=e.url;if(!n)return Promise.reject(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var a=this.config,r=a.fLoader,s=a.loader;return new Promise(function(l,u){i.loader&&i.loader.destroy();var c=i.loader=e.loader=r?new r(a):new s(a),v=Nt(e),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:e.sn==="initSegment"?1/0:ir};e.stats=c.stats,c.load(v,m,{onSuccess:function(_,S,P,I){i.resetLoader(e,c);var q=_.data;P.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(q.slice(0,16)),q=q.slice(16)),l({frag:e,part:null,payload:q,networkDetails:I})},onError:function(_,S,P){i.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:_,networkDetails:P}))},onAbort:function(_,S,P){i.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:P}))},onTimeout:function(_,S,P){i.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:P}))},onProgress:function(_,S,P,I){t&&t({frag:e,part:null,payload:P,networkDetails:I})}})})},o.loadPart=function(e,t,i){var n=this;this.abort();var a=this.config,r=a.fLoader,s=a.loader;return new Promise(function(l,u){n.loader&&n.loader.destroy();var c=n.loader=e.loader=r?new r(a):new s(a),v=Nt(e,t),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:ir};t.stats=c.stats,c.load(v,m,{onSuccess:function(_,S,P,I){n.resetLoader(e,c),n.updateStatsFromPart(e,t);var q={frag:e,part:t,payload:_.data,networkDetails:I};i(q),l(q)},onError:function(_,S,P){n.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:_,networkDetails:P}))},onAbort:function(_,S,P){e.stats.aborted=t.stats.aborted,n.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:P}))},onTimeout:function(_,S,P){n.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:P}))}})})},o.updateStatsFromPart=function(e,t){var i=e.stats,n=t.stats,a=n.total;if(i.loaded+=n.loaded,a){var r=Math.round(e.duration/t.duration),s=Math.min(Math.round(i.loaded/a),r),l=(r-s)*Math.round(i.loaded/s);i.total=i.loaded+l}else i.total=Math.max(i.loaded,i.total);var u=i.loading,c=n.loading;u.start?u.first+=c.first-c.start:(u.start=c.start,u.first=c.first),u.end=c.end},o.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},d}();function Nt(d,o){o===void 0&&(o=null);var e=o||d,t={frag:d,part:o,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},i=e.byteRangeStartOffset,n=e.byteRangeEndOffset;if((0,R.isFiniteNumber)(i)&&(0,R.isFiniteNumber)(n)){var a,r=i,s=n;if(d.sn==="initSegment"&&((a=d.decryptdata)===null||a===void 0?void 0:a.method)==="AES-128"){var l=n-i;l%16&&(s=n+(16-l%16)),i!==0&&(t.resetIV=!0,r=i-16)}t.rangeStart=r,t.rangeEnd=s}return t}var Yt=function(d){var o,e;function t(i){for(var n,a=arguments.length,r=new Array(a>1?a-1:0),s=1;s<a;s++)r[s-1]=arguments[s];return(n=d.call.apply(d,[this].concat(r))||this).data=void 0,n.data=i,n}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Bt(o,e),t}(Jt(Error)),cr=function(){function d(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var o=d.prototype;return o.abort=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.abort()}},o.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},o.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},o.createKeyLoadError=function(e,t,i,n){return t===void 0&&(t=w.ErrorDetails.KEY_LOAD_ERROR),new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:t,fatal:!1,frag:e,networkDetails:i})},o.loadClear=function(e,t){var i=this;if(this.emeController&&this.config.emeEnabled)for(var n=e.sn,a=e.cc,r=function(l){var u=t[l];if(a<=u.cc&&(n==="initSegment"||n<u.sn))return i.emeController.selectKeySystemFormat(u).then(function(c){u.setKeyFormat(c)}),"break"},s=0;s<t.length&&r(s)!=="break";s++);},o.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)},o.loadInternal=function(e,t){var i,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var r=t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(e,w.ErrorDetails.KEY_LOAD_ERROR,null,r))}var s=a.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,w.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+s+'"'));var l,u=this.keyUriToKeyInfo[s];if((i=u)!==null&&i!==void 0&&i.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if((n=u)!==null&&n!==void 0&&n.keyLoadPromise)switch((l=u.mediaKeySessionContext)===null||l===void 0?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise}switch(u=this.keyUriToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return a.keyFormat==="identity"?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,w.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+a.method+'"'))}},o.loadKeyEME=function(e,t){var i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n=this.emeController.loadKey(i);if(n)return(e.keyLoadPromise=n.then(function(a){return e.mediaKeySessionContext=a,i})).catch(function(a){throw e.keyLoadPromise=null,a})}return Promise.resolve(i)},o.loadKeyHTTP=function(e,t){var i=this,n=this.config,a=new n.loader(n);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise(function(r,s){var l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:n.fragLoadingRetryDelay,maxRetryDelay:n.fragLoadingMaxRetryTimeout,highWaterMark:0},c={onSuccess:function(v,m,_,S){var P=_.frag,I=_.keyInfo,q=_.url;if(!P.decryptdata||I!==i.keyUriToKeyInfo[q])return s(i.createKeyLoadError(P,w.ErrorDetails.KEY_LOAD_ERROR,S,"after key load, decryptdata unset or changed"));I.decryptdata.key=P.decryptdata.key=new Uint8Array(v.data),P.keyLoader=null,I.loader=null,r({frag:P,keyInfo:I})},onError:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,w.ErrorDetails.KEY_LOAD_ERROR,_))},onTimeout:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,w.ErrorDetails.KEY_LOAD_TIMEOUT,_))},onAbort:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,w.ErrorDetails.INTERNAL_ABORTED,_))}};a.load(l,u,c)})},o.resetLoader=function(e){var t=e.frag,i=e.keyInfo,n=e.url,a=i.loader;t.keyLoader===a&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],a&&a.destroy()},d}(),Ir=function(){function d(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var o=d.prototype;return o.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},o.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},o.onHandlerDestroyed=function(){},o.hasInterval=function(){return!!this._tickInterval},o.hasNextTick=function(){return!!this._tickTimer},o.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},o.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},o.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},o.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},o.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},o.doTick=function(){},d}(),dr={length:0,start:function(){return 0},end:function(){return 0}},Mt=function(){function d(){}return d.isBuffered=function(o,e){try{if(o){for(var t=d.getBuffered(o),i=0;i<t.length;i++)if(e>=t.start(i)&&e<=t.end(i))return!0}}catch{}return!1},d.bufferInfo=function(o,e,t){try{if(o){var i,n=d.getBuffered(o),a=[];for(i=0;i<n.length;i++)a.push({start:n.start(i),end:n.end(i)});return this.bufferedInfo(a,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},d.bufferedInfo=function(o,e,t){e=Math.max(0,e),o.sort(function(S,P){return S.start-P.start||P.end-S.end});var i=[];if(t)for(var n=0;n<o.length;n++){var a=i.length;if(a){var r=i[a-1].end;o[n].start-r<t?o[n].end>r&&(i[a-1].end=o[n].end):i.push(o[n])}else i.push(o[n])}else i=o;for(var s,l=0,u=e,c=e,v=0;v<i.length;v++){var m=i[v].start,_=i[v].end;if(e+t>=m&&e<_)u=m,l=(c=_)-e;else if(e+t<m){s=m;break}}return{len:l,start:u||0,end:c||0,nextStart:s}},d.getBuffered=function(o){try{return o.buffered}catch(e){return k.logger.log("failed to get media.buffered",e),dr}},d}(),ki=function(d,o,e,t,i,n){t===void 0&&(t=0),i===void 0&&(i=-1),n===void 0&&(n=!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=d,this.sn=o,this.id=e,this.size=t,this.part=i,this.partial=n};function zi(d,o){for(var e=null,t=0,i=d.length;t<i;t++){var n=d[t];if(n&&n.cc===o){e=n;break}}return e}function _r(d,o){if(d){var e=d.start+o;d.start=d.startPTS=e,d.endPTS=e+d.duration}}function oi(d,o){for(var e=o.fragments,t=0,i=e.length;t<i;t++)_r(e[t],d);o.fragmentHint&&_r(o.fragmentHint,d),o.alignedSliding=!0}function Qi(d,o){if(d.hasProgramDateTime&&o.hasProgramDateTime){var e=d.fragments,t=o.fragments;if(e.length&&t.length){var i=t[Math.round(t.length/2)-1],n=zi(e,i.cc)||e[Math.round(e.length/2)-1],a=i.programDateTime,r=n.programDateTime;a!==null&&r!==null&&oi((r-a)/1e3-(n.start-i.start),d)}}}let Ji=function(d,o){for(var e=0,t=d.length-1,i=null,n=null;e<=t;){var a=o(n=d[i=(e+t)/2|0]);if(a>0)e=i+1;else{if(!(a<0))return n;t=i-1}}return null};function li(d,o,e,t){e===void 0&&(e=0),t===void 0&&(t=0);var i=null;if(d?i=o[d.sn-o[0].sn+1]||null:e===0&&o[0].start===0&&(i=o[0]),i&&ui(e,t,i)===0)return i;var n=Ji(o,ui.bind(null,e,t));return!n||n===d&&i?i:n}function ui(d,o,e){if(d===void 0&&(d=0),o===void 0&&(o=0),e.start<=d&&e.start+e.duration>d)return 0;var t=Math.min(o,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-t<=d?1:e.start-t>d&&e.start?-1:0}function jr(d,o,e){var t=1e3*Math.min(o,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>d}var Qr=M(21);let pn=function(d){for(var o="",e=d.length,t=0;t<e;t++)o+="["+d.start(t).toFixed(3)+","+d.end(t).toFixed(3)+"]";return o};function $i(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Gr(d,o){return Gr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Gr(d,o)}var yr="STOPPED",Et="IDLE",Zi="KEY_LOADING",Kr="FRAG_LOADING",Fr="FRAG_LOADING_WAITING_RETRY",di="WAITING_TRACK",Sr="PARSING",Hr="PARSED",Jr="ENDED",kr="ERROR",Mr="WAITING_INIT_PTS",qr="WAITING_LEVEL",ci=function(d){var o,e;function t(r,s,l,u){var c;return(c=d.call(this)||this).hls=void 0,c.fragPrevious=null,c.fragCurrent=null,c.fragmentTracker=void 0,c.transmuxer=null,c._state=yr,c.media=null,c.mediaBuffer=null,c.config=void 0,c.bitrateTest=!1,c.lastCurrentTime=0,c.nextLoadPosition=0,c.startPosition=0,c.loadedmetadata=!1,c.fragLoadError=0,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.logPrefix=u,c.log=k.logger.log.bind(k.logger,u+":"),c.warn=k.logger.warn.bind(k.logger,u+":"),c.hls=r,c.fragmentLoader=new br(r.config),c.keyLoader=l,c.fragmentTracker=s,c.config=r.config,c.decrypter=new Qr.default(r.config),r.on(p.Events.LEVEL_SWITCHING,c.onLevelSwitching,function(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}(c)),c}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Gr(o,e);var i,n,a=t.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(r){},a.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var r=this.fragCurrent;r&&(r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=yr},a._streamEnded=function(r,s){if(s.live||r.nextStart||!r.end||!this.media)return!1;var l=s.partList;if(l!=null&&l.length){var u=l[l.length-1];return Mt.isBuffered(this.media,u.start+u.duration/2)}var c=s.fragments[s.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(c)},a.getLevelDetails=function(){var r;if(this.levels&&this.levelLastLoaded!==null)return(r=this.levels[this.levelLastLoaded])===null||r===void 0?void 0:r.details},a.onMediaAttached=function(r,s){var l=this.media=this.mediaBuffer=s.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),l.addEventListener("seeking",this.onvseeking),l.addEventListener("ended",this.onvended);var u=this.config;this.levels&&u.autoStartLoad&&this.state===yr&&this.startLoad(u.startPosition)},a.onMediaDetaching=function(){var r=this.media;r!=null&&r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),r&&this.onvseeking&&this.onvended&&(r.removeEventListener("seeking",this.onvseeking),r.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()},a.onMediaSeeking=function(){var r=this.config,s=this.fragCurrent,l=this.media,u=this.mediaBuffer,c=this.state,v=l?l.currentTime:0,m=Mt.bufferInfo(u||l,v,r.maxBufferHole);if(this.log("media seeking to "+((0,R.isFiniteNumber)(v)?v.toFixed(3):v)+", state: "+c),this.state===Jr)this.resetLoadingState();else if(s){var _=r.maxFragLookUpTolerance,S=s.start-_,P=s.start+s.duration+_;if(!m.len||P<m.start||S>m.end){var I=v>P;(v<S||I)&&(I&&s.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),s.abortRequests()),this.resetLoadingState())}}l&&(this.lastCurrentTime=v),this.loadedmetadata||m.len||(this.nextLoadPosition=this.startPosition=v),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onLevelSwitching=function(r,s){this.fragLoadError=0},a.onHandlerDestroying=function(){this.stopLoad(),d.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=yr,this.hls.off(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,d.prototype.onHandlerDestroyed.call(this)},a.loadFragment=function(r,s,l){this._loadFragForPlayback(r,s,l)},a._loadFragForPlayback=function(r,s,l){var u=this;this._doFragLoad(r,s,l,function(c){if(u.fragContextChanged(r))return u.warn("Fragment "+r.sn+(c.part?" p: "+c.part.index:"")+" of level "+r.level+" was dropped during download."),void u.fragmentTracker.removeFragment(r);r.stats.chunkCount++,u._handleFragmentLoadProgress(c)}).then(function(c){if(c){u.fragLoadError=0;var v=u.state;u.fragContextChanged(r)?(v===Kr||!u.fragCurrent&&v===Sr)&&(u.fragmentTracker.removeFragment(r),u.state=Et):("payload"in c&&(u.log("Loaded fragment "+r.sn+" of level "+r.level),u.hls.trigger(p.Events.FRAG_LOADED,c)),u._handleFragmentLoadComplete(c))}}).catch(function(c){u.state!==yr&&u.state!==kr&&(u.warn(c),u.resetFragmentLoading(r))})},a.flushMainBuffer=function(r,s,l){if(l===void 0&&(l=null),r-s){var u={startOffset:r,endOffset:s,type:l};this.fragLoadError=0,this.hls.trigger(p.Events.BUFFER_FLUSHING,u)}},a._loadInitSegment=function(r,s){var l=this;this._doFragLoad(r,s).then(function(u){if(!u||l.fragContextChanged(r)||!l.levels)throw new Error("init load aborted");return u}).then(function(u){var c=l.hls,v=u.payload,m=r.decryptdata;if(v&&v.byteLength>0&&m&&m.key&&m.iv&&m.method==="AES-128"){var _=self.performance.now();return l.decrypter.decrypt(new Uint8Array(v),m.key.buffer,m.iv.buffer).then(function(S){var P=self.performance.now();return c.trigger(p.Events.FRAG_DECRYPTED,{frag:r,payload:S,stats:{tstart:_,tdecrypt:P}}),u.payload=S,u})}return u}).then(function(u){var c=l.fragCurrent,v=l.hls,m=l.levels;if(!m)throw new Error("init load aborted, missing levels");m[r.level].details;var _=r.stats;l.state=Et,l.fragLoadError=0,r.data=new Uint8Array(u.payload),_.parsing.start=_.buffering.start=self.performance.now(),_.parsing.end=_.buffering.end=self.performance.now(),u.frag===c&&v.trigger(p.Events.FRAG_BUFFERED,{stats:_,frag:c,part:null,id:r.type}),l.tick()}).catch(function(u){l.state!==yr&&l.state!==kr&&(l.warn(u),l.resetFragmentLoading(r))})},a.fragContextChanged=function(r){var s=this.fragCurrent;return!r||!s||r.level!==s.level||r.sn!==s.sn||r.urlId!==s.urlId},a.fragBufferedComplete=function(r,s){var l,u,c=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+r.type+" sn: "+r.sn+(s?" part: "+s.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+r.level+" "+(c?pn(Mt.getBuffered(c)):"(detached)")),this.state=Et,c&&(!this.loadedmetadata&&r.type==pe.PlaylistLevelType.MAIN&&c.buffered.length&&((l=this.fragCurrent)===null||l===void 0?void 0:l.sn)===((u=this.fragPrevious)===null||u===void 0?void 0:u.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(r){var s=this.transmuxer;if(s){var l=r.frag,u=r.part,c=r.partsLoaded,v=!c||c.length===0||c.some(function(_){return!_}),m=new ki(l.level,l.sn,l.stats.chunkCount+1,0,u?u.index:-1,!v);s.flush(m)}},a._handleFragmentLoadProgress=function(r){},a._doFragLoad=function(r,s,l,u){var c,v=this;if(l===void 0&&(l=null),!this.levels)throw new Error("frag load aborted, missing levels");var m=null;if(!r.encrypted||(c=r.decryptdata)!==null&&c!==void 0&&c.key?!r.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(r,s.encryptedFragments):(this.log("Loading key for "+r.sn+" of ["+s.startSN+"-"+s.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+r.level),this.state=Zi,this.fragCurrent=r,m=this.keyLoader.load(r).then(function(q){if(!v.fragContextChanged(q.frag))return v.hls.trigger(p.Events.KEY_LOADED,q),q}),this.hls.trigger(p.Events.KEY_LOADING,{frag:r}),this.throwIfFragContextChanged("KEY_LOADING")),l=Math.max(r.start,l||0),this.config.lowLatencyMode&&s){var _=s.partList;if(_&&u){l>r.end&&s.fragmentHint&&(r=s.fragmentHint);var S=this.getNextPart(_,r,l);if(S>-1){var P=_[S];return this.log("Loading part sn: "+r.sn+" p: "+P.index+" cc: "+r.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+S+"-"+(_.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(l.toFixed(3))),this.nextLoadPosition=P.start+P.duration,this.state=Kr,this.hls.trigger(p.Events.FRAG_LOADING,{frag:r,part:_[S],targetBufferTime:l}),this.throwIfFragContextChanged("FRAG_LOADING parts"),m?m.then(function(q){return!q||v.fragContextChanged(q.frag)?null:v.doFragPartsLoad(r,_,S,u)}).catch(function(q){return v.handleFragLoadError(q)}):this.doFragPartsLoad(r,_,S,u).catch(function(q){return v.handleFragLoadError(q)})}if(!r.url||this.loadedEndOfParts(_,l))return Promise.resolve(null)}}this.log("Loading fragment "+r.sn+" cc: "+r.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(l.toFixed(3))),(0,R.isFiniteNumber)(r.sn)&&!this.bitrateTest&&(this.nextLoadPosition=r.start+r.duration),this.state=Kr,this.hls.trigger(p.Events.FRAG_LOADING,{frag:r,targetBufferTime:l}),this.throwIfFragContextChanged("FRAG_LOADING");var I=this.config.progressive;return I&&m?m.then(function(q){return!q||v.fragContextChanged(q==null?void 0:q.frag)?null:v.fragmentLoader.load(r,u)}).catch(function(q){return v.handleFragLoadError(q)}):Promise.all([this.fragmentLoader.load(r,I?u:void 0),m]).then(function(q){var oe=q[0];return!I&&oe&&u&&u(oe),oe}).catch(function(q){return v.handleFragLoadError(q)})},a.throwIfFragContextChanged=function(r){if(this.fragCurrent===null)throw new Error("frag load aborted, context changed in "+r)},a.doFragPartsLoad=function(r,s,l,u){var c=this;return new Promise(function(v,m){var _=[];(function S(P){var I=s[P];c.fragmentLoader.loadPart(r,I,u).then(function(q){_[I.index]=q;var oe=q.part;c.hls.trigger(p.Events.FRAG_LOADED,q);var Ee=s[P+1];if(!Ee||Ee.fragment!==r)return v({frag:r,part:oe,partsLoaded:_});S(P+1)}).catch(m)})(l)})},a.handleFragLoadError=function(r){if("data"in r){var s=r.data;r.data&&s.details===w.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(s.frag,s.part):this.hls.trigger(p.Events.ERROR,s)}else this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.INTERNAL_EXCEPTION,err:r,fatal:!0});return null},a._handleTransmuxerFlush=function(r){var s=this.getCurrentContext(r);if(s&&this.state===Sr){var l=s.frag,u=s.part,c=s.level,v=self.performance.now();l.stats.parsing.end=v,u&&(u.stats.parsing.end=v),this.updateLevelTiming(l,u,c,r.partial)}else this.fragCurrent||this.state===yr||this.state===kr||(this.state=Et)},a.getCurrentContext=function(r){var s=this.levels,l=r.level,u=r.sn,c=r.part;if(!s||!s[l])return this.warn("Levels object was unset while buffering fragment "+u+" of level "+l+". The current chunk will not be buffered."),null;var v=s[l],m=c>-1?function(S,P,I){if(!S||!S.details)return null;var q=S.details.partList;if(q)for(var oe=q.length;oe--;){var Ee=q[oe];if(Ee.index===I&&Ee.fragment.sn===P)return Ee}return null}(v,u,c):null,_=m?m.fragment:function(S,P,I){if(!S||!S.details)return null;var q=S.details,oe=q.fragments[P-q.startSN];return oe||((oe=q.fragmentHint)&&oe.sn===P?oe:P<q.startSN&&I&&I.sn===P?I:null)}(v,u,this.fragCurrent);return _?{frag:_,part:m,level:v}:null},a.bufferFragmentData=function(r,s,l,u){if(r&&this.state===Sr){var c=r.data1,v=r.data2,m=c;if(c&&v&&(m=(0,J.appendUint8Array)(c,v)),m&&m.length){var _={type:r.type,frag:s,part:l,chunkMeta:u,parent:s.type,data:m};this.hls.trigger(p.Events.BUFFER_APPENDING,_),r.dropped&&r.independent&&!l&&this.flushBufferGap(s)}}},a.flushBufferGap=function(r){var s=this.media;if(s)if(Mt.isBuffered(s,s.currentTime)){var l=s.currentTime,u=Mt.bufferInfo(s,l,0),c=r.duration,v=Math.min(2*this.config.maxFragLookUpTolerance,.25*c),m=Math.max(Math.min(r.start-v,u.end-v),l+v);r.start-m>v&&this.flushMainBuffer(m,r.start)}else this.flushMainBuffer(0,r.start)},a.getFwdBufferInfo=function(r,s){var l=this.config,u=this.getLoadPosition();if(!(0,R.isFiniteNumber)(u))return null;var c=Mt.bufferInfo(r,u,l.maxBufferHole);if(c.len===0&&c.nextStart!==void 0){var v=this.fragmentTracker.getBufferedFrag(u,s);if(v&&c.nextStart<v.end)return Mt.bufferInfo(r,u,Math.max(c.nextStart,l.maxBufferHole))}return c},a.getMaxBufferLength=function(r){var s,l=this.config;return s=r?Math.max(8*l.maxBufferSize/r,l.maxBufferLength):l.maxBufferLength,Math.min(s,l.maxMaxBufferLength)},a.reduceMaxBufferLength=function(r){var s=this.config,l=r||s.maxBufferLength;return s.maxMaxBufferLength>=l&&(s.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+s.maxMaxBufferLength+"s"),!0)},a.getNextFragment=function(r,s){var l=s.fragments,u=l.length;if(!u)return null;var c,v=this.config,m=l[0].start;if(s.live){var _=v.initialLiveManifestSize;if(u<_)return this.warn("Not enough fragments to start playback (have: "+u+", need: "+_+")"),null;s.PTSKnown||this.startFragRequested||this.startPosition!==-1||(c=this.getInitialLiveFragment(s,l),this.startPosition=c?this.hls.liveSyncPosition||c.start:r)}else r<=m&&(c=l[0]);if(!c){var S=v.lowLatencyMode?s.partEnd:s.fragmentEnd;c=this.getFragmentAtPosition(r,S,s)}return this.mapToInitFragWhenRequired(c)},a.mapToInitFragWhenRequired=function(r){return r==null||!r.initSegment||r!=null&&r.initSegment.data||this.bitrateTest?r:r.initSegment},a.getNextPart=function(r,s,l){for(var u=-1,c=!1,v=!0,m=0,_=r.length;m<_;m++){var S=r[m];if(v=v&&!S.independent,u>-1&&l<S.start)break;var P=S.loaded;P?u=-1:(c||S.independent||v)&&S.fragment===s&&(u=m),c=P}return u},a.loadedEndOfParts=function(r,s){var l=r[r.length-1];return l&&s>l.start&&l.loaded},a.getInitialLiveFragment=function(r,s){var l=this.fragPrevious,u=null;if(l){if(r.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+l.programDateTime),u=function(_,S,P){if(S===null||!Array.isArray(_)||!_.length||!(0,R.isFiniteNumber)(S)||S<(_[0].programDateTime||0)||S>=(_[_.length-1].endProgramDateTime||0))return null;P=P||0;for(var I=0;I<_.length;++I){var q=_[I];if(jr(S,P,q))return q}return null}(s,l.endProgramDateTime,this.config.maxFragLookUpTolerance)),!u){var c=l.sn+1;if(c>=r.startSN&&c<=r.endSN){var v=s[c-r.startSN];l.cc===v.cc&&(u=v,this.log("Live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=function(_,S){return Ji(_,function(P){return P.cc<S?1:P.cc>S?-1:0})}(s,l.cc),u&&this.log("Live playlist, switching playlist, load frag with same CC: "+u.sn))}}else{var m=this.hls.liveSyncPosition;m!==null&&(u=this.getFragmentAtPosition(m,this.bitrateTest?r.fragmentEnd:r.edge,r))}return u},a.getFragmentAtPosition=function(r,s,l){var u,c=this.config,v=this.fragPrevious,m=l.fragments,_=l.endSN,S=l.fragmentHint,P=c.maxFragLookUpTolerance,I=!!(c.lowLatencyMode&&l.partList&&S);if(I&&S&&!this.bitrateTest&&(m=m.concat(S),_=S.sn),u=r<s?li(v,m,r,r>s-P?0:P):m[m.length-1]){var q=u.sn-l.startSN;if(this.fragmentTracker.getState(u)===Ue.OK&&(v=u),v&&u.sn===v.sn&&!I&&v&&u.level===v.level){var oe=m[q+1];u.sn<_&&this.fragmentTracker.getState(oe)!==Ue.OK?(this.log("SN "+u.sn+" just loaded, load next one: "+oe.sn),u=oe):u=null}}return u},a.synchronizeToLiveEdge=function(r){var s=this.config,l=this.media;if(l){var u=this.hls.liveSyncPosition,c=l.currentTime,v=r.fragments[0].start,m=r.edge,_=c>=v-s.maxFragLookUpTolerance&&c<=m;if(u!==null&&l.duration>u&&(c<u||!_)){var S=s.liveMaxLatencyDuration!==void 0?s.liveMaxLatencyDuration:s.liveMaxLatencyDurationCount*r.targetduration;(!_&&l.readyState<4||c<m-S)&&(this.loadedmetadata||(this.nextLoadPosition=u),l.readyState&&(this.warn("Playback: "+c.toFixed(3)+" is located too far from the end of live sliding playlist: "+m+", reset currentTime to : "+u.toFixed(3)),l.currentTime=u))}}},a.alignPlaylists=function(r,s){var l=this.levels,u=this.levelLastLoaded,c=this.fragPrevious,v=u!==null?l[u]:null,m=r.fragments.length;if(!m)return this.warn("No fragments in live playlist"),0;var _=r.fragments[0].start,S=!s,P=r.alignedSliding&&(0,R.isFiniteNumber)(_);if(S||!P&&!_){(function(q,oe,Ee){oe&&(function(he,Ae,He){if(function(be,Ge,Me){return!(!Ge.details||!(Me.endCC>Me.startCC||be&&be.cc<Me.startCC))}(he,He,Ae)){var ze=function(be,Ge,Me){Me===void 0&&(Me=0);var ct=be.fragments,Ot=Ge.fragments;if(Ot.length&&ct.length){var ft=zi(ct,Ot[0].cc);if(ft&&(!ft||ft.startPTS))return ft;k.logger.log("No frag in previous level to align on")}else k.logger.log("No fragments to align")}(He.details,Ae);ze&&(0,R.isFiniteNumber)(ze.start)&&(k.logger.log("Adjusting PTS using last level due to CC increase within current level "+Ae.url),oi(ze.start,Ae))}}(q,Ee,oe),!Ee.alignedSliding&&oe.details&&function(he,Ae){if(Ae.fragments.length&&he.hasProgramDateTime&&Ae.hasProgramDateTime){var He=Ae.fragments[0].programDateTime,ze=he.fragments[0].programDateTime,be=(ze-He)/1e3+Ae.fragments[0].start;be&&(0,R.isFiniteNumber)(be)&&(k.logger.log("Adjusting PTS using programDateTime delta "+(ze-He)+"ms, sliding:"+be.toFixed(3)+" "+he.url+" "),oi(be,he))}}(Ee,oe.details),Ee.alignedSliding||!oe.details||Ee.skippedSegments||Q(oe.details,Ee))})(c,v,r);var I=r.fragments[0].start;return this.log("Live playlist sliding: "+I.toFixed(2)+" start-sn: "+(s?s.startSN:"na")+"->"+r.startSN+" prev-sn: "+(c?c.sn:"na")+" fragments: "+m),I}return _},a.waitForCdnTuneIn=function(r){return r.live&&r.canBlockReload&&r.partTarget&&r.tuneInGoal>Math.max(r.partHoldBack,3*r.partTarget)},a.setStartPosition=function(r,s){var l=this.startPosition;if(l<s&&(l=-1),l===-1||this.lastCurrentTime===-1){var u=r.startTimeOffset;(0,R.isFiniteNumber)(u)?(l=s+u,u<0&&(l+=r.totalduration),l=Math.min(Math.max(s,l),s+r.totalduration),this.log("Start time offset "+u+" found in playlist, adjust startPosition to "+l),this.startPosition=l):r.live?l=this.hls.liveSyncPosition||s:this.startPosition=l=0,this.lastCurrentTime=l}this.nextLoadPosition=l},a.getLoadPosition=function(){var r=this.media,s=0;return this.loadedmetadata&&r?s=r.currentTime:this.nextLoadPosition&&(s=this.nextLoadPosition),s},a.handleFragLoadAborted=function(r,s){this.transmuxer&&r.sn!=="initSegment"&&r.stats.aborted&&(this.warn("Fragment "+r.sn+(s?" part"+s.index:"")+" of level "+r.level+" was aborted"),this.resetFragmentLoading(r))},a.resetFragmentLoading=function(r){this.fragCurrent&&(this.fragContextChanged(r)||this.state===Fr)||(this.state=Et)},a.onFragmentOrKeyLoadError=function(r,s){if(s.fatal)return this.stopLoad(),void(this.state=kr);var l=this.config;if(s.chunkMeta){var u=this.getCurrentContext(s.chunkMeta);u&&(s.frag=u.frag,s.levelRetry=!0,this.fragLoadError=l.fragLoadingMaxRetry)}var c=s.frag;if(c&&c.type===r)if(this.fragCurrent,this.fragLoadError+1<=l.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var v=Math.min(Math.pow(2,this.fragLoadError)*l.fragLoadingRetryDelay,l.fragLoadingMaxRetryTimeout);this.warn("Fragment "+c.sn+" of "+r+" "+c.level+" failed to load, retrying in "+v+"ms"),this.retryDate=self.performance.now()+v,this.fragLoadError++,this.state=Fr}else s.levelRetry?(r===pe.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=Et):(k.logger.error(s.details+" reaches max retry, redispatch as fatal ..."),s.fatal=!0,this.hls.stopLoad(),this.state=kr)},a.afterBufferFlushed=function(r,s,l){if(r){var u=Mt.getBuffered(r);this.fragmentTracker.detectEvictedFragments(s,u,l),this.state===Jr&&this.resetLoadingState()}},a.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Et},a.resetStartWhenNotLoaded=function(r){if(!this.loadedmetadata){this.startFragRequested=!1;var s=this.levels?this.levels[r].details:null;s!=null&&s.live?(this.startPosition=-1,this.setStartPosition(s,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.updateLevelTiming=function(r,s,l,u){var c=this,v=l.details;Object.keys(r.elementaryStreams).reduce(function(m,_){var S=r.elementaryStreams[_];if(S){var P=S.endPTS-S.startPTS;if(P<=0)return c.warn("Could not parse fragment "+r.sn+" "+_+" duration reliably ("+P+")"),m||!1;var I=u?0:Y(v,r,S.startPTS,S.endPTS,S.startDTS,S.endDTS);return c.hls.trigger(p.Events.LEVEL_PTS_UPDATED,{details:v,level:l,drift:I,type:_,frag:r,start:S.startPTS,end:S.endPTS}),!0}return m},!1)||(this.warn("Found no media in fragment "+r.sn+" of level "+l.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=Hr,this.hls.trigger(p.Events.FRAG_PARSED,{frag:r,part:s})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i=t,(n=[{key:"state",get:function(){return this._state},set:function(r){var s=this._state;s!==r&&(this._state=r,this.log(s+"->"+r))}}])&&$i(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Ir);function hi(){return self.MediaSource||self.WebKitMediaSource}function fi(){return self.SourceBuffer||self.WebKitSourceBuffer}var wi=function(){var d=ENTRY_MODULE,o={},e=function i(n){var a=o[n];if(a!==void 0)return a.exports;var r=o[n]={exports:{}};return d[n].call(r.exports,r,r.exports,i),r.exports};e.m=d,e.n=function(i){var n=i&&i.__esModule?function(){return i.default}:function(){return i};return e.d(n,{a:n}),n},e.d=function(i,n){for(var a in n)e.o(n,a)&&!e.o(i,a)&&Object.defineProperty(i,a,{enumerable:!0,get:n[a]})},e.o=function(i,n){return Object.prototype.hasOwnProperty.call(i,n)},e.r=function(i){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var t=e(ENTRY_MODULE);return t.default||t}.toString().split("ENTRY_MODULE"),en="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function Wt(d){return(d+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function vi(d,o,e){var t={};t[e]=[];var i=o.toString().replace(/^"[^"]+"/,"function"),n=i.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||i.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!n)return t;for(var a,r=n[1],s=new RegExp("(\\\\n|\\W)"+Wt(r)+en,"g");a=s.exec(i);)a[3]!=="dll-reference"&&t[e].push(a[3]);for(s=new RegExp("\\("+Wt(r)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)'+en,"g");a=s.exec(i);)d[a[2]]||(t[e].push(a[1]),d[a[2]]=M(a[1]).m),t[a[2]]=t[a[2]]||[],t[a[2]].push(a[4]);for(var l,u=Object.keys(t),c=0;c<u.length;c++)for(var v=0;v<t[u[c]].length;v++)l=t[u[c]][v],isNaN(1*l)||(t[u[c]][v]=1*t[u[c]][v]);return t}function mn(d){return Object.keys(d).reduce(function(o,e){return o||d[e].length>0},!1)}function tn(d,o,e,t){var i=d[t].map(function(n){return'"'+n+'": '+o[t][n].toString().replace(/^"[^"]+"/,"function")}).join(",");return wi[0]+"{"+i+"}"+wi[1]+'"'+e+'"'+wi[2]}var Nr=M(544),Di=M(729),$r=M.n(Di),Zr=hi()||{isTypeSupported:function(){return!1}},Li=function(){function d(e,t,i,n){var a=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;var s=function(v,m){(m=m||{}).frag=a.frag,m.id=a.id,a.hls.trigger(v,m)};this.observer=new Di.EventEmitter,this.observer.on(p.Events.FRAG_DECRYPTED,s),this.observer.on(p.Events.ERROR,s);var l={mp4:Zr.isTypeSupported("video/mp4"),mpeg:Zr.isTypeSupported("audio/mpeg"),mp3:Zr.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"){var c;k.logger.log("demuxing in webworker");try{c=this.worker=function(v,m){m=m||{};var _={main:M.m},S=m.all?{main:Object.keys(_.main)}:function(Ee,he){for(var Ae={main:[he]},He={main:[]},ze={main:{}};mn(Ae);)for(var be=Object.keys(Ae),Ge=0;Ge<be.length;Ge++){var Me=be[Ge],ct=Ae[Me].pop();if(ze[Me]=ze[Me]||{},!ze[Me][ct]&&Ee[Me][ct]){ze[Me][ct]=!0,He[Me]=He[Me]||[],He[Me].push(ct);for(var Ot=vi(Ee,Ee[Me][ct],Me),ft=Object.keys(Ot),Tt=0;Tt<ft.length;Tt++)Ae[ft[Tt]]=Ae[ft[Tt]]||[],Ae[ft[Tt]]=Ae[ft[Tt]].concat(Ot[ft[Tt]])}}return He}(_,v),P="";Object.keys(S).filter(function(Ee){return Ee!=="main"}).forEach(function(Ee){for(var he=0;S[Ee][he];)he++;S[Ee].push(he),_[Ee][he]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",P=P+"var "+Ee+" = ("+tn(S,_,he,modules)+`)();
|
|
9
|
-
`
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
initSegmentChange: `+Me);var Ot=new Nr.TransmuxConfig(i,n,t,s,c);this.configureTransmuxer(Ot)}if(this.frag=a,this.part=r,P)P.postMessage({cmd:"demux",data:e,decryptdata:q,chunkMeta:u,state:ct},e instanceof ArrayBuffer?[e]:[]);else if(S){var ft=S.push(e,q,u,ct);(0,Nr.isPromise)(ft)?(S.async=!0,ft.then(function(Tt){_.handleTransmuxComplete(Tt)}).catch(function(Tt){_.transmuxerError(Tt,u,"transmuxer-interface push error")})):(S.async=!1,this.handleTransmuxComplete(ft))}},o.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var i=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:e});else if(i){var a=i.flush(e);(0,Nr.isPromise)(a)||i.async?((0,Nr.isPromise)(a)||(a=Promise.resolve(a)),a.then(function(r){t.handleFlushResult(r,e)}).catch(function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(a,e)}},o.transmuxerError=function(e,t,i){this.hls&&this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i})},o.handleFlushResult=function(e,t){var i=this;e.forEach(function(n){i.handleTransmuxComplete(n)}),this.onFlush(t)},o.onWorkerMessage=function(e){var t=e.data,i=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":k.logger[t.data.logType]&&k.logger[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)}},o.configureTransmuxer=function(e){var t=this.worker,i=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):i&&i.configure(e)},o.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},d}(),rn=function(){function d(e,t,i,n){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=n}var o=d.prototype;return o.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},o.poll=function(e,t){var i=this.config,n=this.media,a=this.stalled;if(n!==null){var r=n.currentTime,s=n.seeking,l=this.seeking&&!s,u=!this.seeking&&s;if(this.seeking=s,r===e){if((u||l)&&(this.stalled=null),!(n.paused&&!s||n.ended||n.playbackRate===0)&&Mt.getBuffered(n).length){var c=Mt.bufferInfo(n,r,0),v=c.len>0,m=c.nextStart||0;if(v||m){if(s){var _=c.len>2,S=!m||t&&t.start<=r||m-r>2&&!this.fragmentTracker.getPartialFragment(r);if(_||S)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var P,I=Math.max(m,c.start||0)-r,q=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,oe=!(q==null||(P=q.details)===null||P===void 0)&&P.live?2*q.details.targetduration:2;if(I>0&&I<=oe)return void this._trySkipBufferHole(null)}var Ee=self.performance.now();if(a!==null){var he=Ee-a;if(s||!(he>=250)||(this._reportStall(c),this.media)){var Ae=Mt.bufferInfo(n,r,i.maxBufferHole);this._tryFixBufferStall(Ae,he)}}else this.stalled=Ee}}}else if(this.moved=!0,a!==null){if(this.stallReported){var He=self.performance.now()-a;k.logger.warn("playback not stuck anymore @"+r+", after "+Math.round(He)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},o._tryFixBufferStall=function(e,t){var i=this.config,n=this.fragmentTracker,a=this.media;if(a!==null){var r=a.currentTime,s=n.getPartialFragment(r);if(s&&(this._trySkipBufferHole(s)||!this.media))return;e.len>i.maxBufferHole&&t>1e3*i.highBufferWatchdogPeriod&&(k.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},o._reportStall=function(e){var t=this.hls,i=this.media;!this.stallReported&&i&&(this.stallReported=!0,k.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(e)+")"),t.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e.len}))},o._trySkipBufferHole=function(e){var t=this.config,i=this.hls,n=this.media;if(n===null)return 0;for(var a=n.currentTime,r=0,s=Mt.getBuffered(n),l=0;l<s.length;l++){var u=s.start(l);if(a+t.maxBufferHole>=r&&a<u){var c=Math.max(u+.05,n.currentTime+.1);return k.logger.warn("skipping hole, adjusting currentTime from "+a+" to "+c),this.moved=!0,this.stalled=null,n.currentTime=c,e&&i.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+a+" to "+c,frag:e}),c}r=s.end(l)}return 0},o._tryNudgeBuffer=function(){var e=this.config,t=this.hls,i=this.media,n=this.nudgeRetry;if(i!==null){var a=i.currentTime;if(this.nudgeRetry++,n<e.nudgeMaxRetry){var r=a+(n+1)*e.nudgeOffset;k.logger.warn("Nudging 'currentTime' from "+a+" to "+r),i.currentTime=r,t.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else k.logger.error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},d}();function Vr(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Ri(d,o){return Ri=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ri(d,o)}var yn=function(d){var o,e;function t(r,s,l){var u;return(u=d.call(this,r,s,l,"[stream-controller]")||this).audioCodecSwap=!1,u.gapController=null,u.level=-1,u._forceStartLoad=!1,u.altAudio=!1,u.audioOnly=!1,u.fragPlaying=null,u.onvplaying=null,u.onvseeked=null,u.fragLastKbps=0,u.couldBacktrack=!1,u.backtrackFragment=null,u.audioCodecSwitch=!1,u.videoBuffer=null,u._registerListeners(),u}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ri(o,e);var i,n,a=t.prototype;return a._registerListeners=function(){var r=this.hls;r.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(p.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(p.Events.ERROR,this.onError,this),r.on(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(p.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(p.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var r=this.hls;r.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(p.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(p.Events.ERROR,this.onError,this),r.off(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(p.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(p.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},a.startLoad=function(r){if(this.levels){var s=this.lastCurrentTime,l=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var u=l.startLevel;u===-1&&(l.config.testBandwidth&&this.levels.length>1?(u=0,this.bitrateTest=!0):u=l.nextAutoLevel),this.level=l.nextLoadLevel=u,this.loadedmetadata=!1}s>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+s.toFixed(3)),r=s),this.state=Et,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=yr},a.stopLoad=function(){this._forceStartLoad=!1,d.prototype.stopLoad.call(this)},a.doTick=function(){switch(this.state){case Et:this.doTickIdle();break;case qr:var r,s=this.levels,l=this.level,u=s==null||(r=s[l])===null||r===void 0?void 0:r.details;if(u&&(!u.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(u))break;this.state=Et;break}break;case Fr:var c,v=self.performance.now(),m=this.retryDate;(!m||v>=m||(c=this.media)!==null&&c!==void 0&&c.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=Et)}this.onTickEnd()},a.onTickEnd=function(){d.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},a.doTickIdle=function(){var r=this.hls,s=this.levelLastLoaded,l=this.levels,u=this.media,c=r.config,v=r.nextLoadLevel;if(s!==null&&(u||!this.startFragRequested&&c.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&l&&l[v]){var m=l[v],_=this.getMainFwdBufferInfo();if(_!==null){var S=this.getLevelDetails();if(S&&this._streamEnded(_,S)){var P={};return this.altAudio&&(P.type="video"),this.hls.trigger(p.Events.BUFFER_EOS,P),void(this.state=Jr)}this.level=r.nextLoadLevel=v;var I=m.details;if(!I||this.state===qr||I.live&&this.levelLastLoaded!==v)return this.level=v,void(this.state=qr);if(!(_.len>=this.getMaxBufferLength(m.maxBitrate))){this.backtrackFragment&&this.backtrackFragment.start>_.end&&(this.backtrackFragment=null);var q=this.backtrackFragment?this.backtrackFragment.start:_.end,oe=this.getNextFragment(q,I);if(this.couldBacktrack&&!this.fragPrevious&&oe&&oe.sn!=="initSegment"&&this.fragmentTracker.getState(oe)!==Ue.OK){var Ee,he=((Ee=this.backtrackFragment)!=null?Ee:oe).sn-I.startSN,Ae=I.fragments[he-1];Ae&&oe.cc===Ae.cc&&(oe=Ae,this.fragmentTracker.removeFragment(Ae))}else this.backtrackFragment&&_.len&&(this.backtrackFragment=null);if(oe&&this.fragmentTracker.getState(oe)===Ue.OK&&this.nextLoadPosition>q){var He=this.audioOnly&&!this.altAudio?$.ElementaryStreamTypes.AUDIO:$.ElementaryStreamTypes.VIDEO,ze=(He===$.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;ze&&this.afterBufferFlushed(ze,He,pe.PlaylistLevelType.MAIN),oe=this.getNextFragment(this.nextLoadPosition,I)}oe&&(!oe.initSegment||oe.initSegment.data||this.bitrateTest||(oe=oe.initSegment),this.loadFragment(oe,I,q))}}}},a.loadFragment=function(r,s,l){var u,c=this.fragmentTracker.getState(r);this.fragCurrent=r,c===Ue.NOT_LOADED?r.sn==="initSegment"?this._loadInitSegment(r,s):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r,s)):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,s,l)):c===Ue.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((u=this.media)===null||u===void 0?void 0:u.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},a.getAppendedFrag=function(r){var s=this.fragmentTracker.getAppendedFrag(r,pe.PlaylistLevelType.MAIN);return s&&"fragment"in s?s.fragment:s},a.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,pe.PlaylistLevelType.MAIN)},a.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},a.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},a.nextLevelSwitch=function(){var r=this.levels,s=this.media;if(s!=null&&s.readyState){var l,u=this.getAppendedFrag(s.currentTime);if(u&&u.start>1&&this.flushMainBuffer(0,u.start-1),!s.paused&&r){var c=r[this.hls.nextLoadLevel],v=this.fragLastKbps;l=v&&this.fragCurrent?this.fragCurrent.duration*c.maxBitrate/(1e3*v)+1:0}else l=0;var m=this.getBufferedFrag(s.currentTime+l);if(m){var _=this.followingBufferedFrag(m);if(_){this.abortCurrentFrag();var S=_.maxStartPTS?_.maxStartPTS:_.start,P=_.duration,I=Math.max(m.end,S+Math.min(Math.max(P-this.config.maxFragLookUpTolerance,.5*P),.75*P));this.flushMainBuffer(I,Number.POSITIVE_INFINITY)}}}},a.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r&&r.abortRequests(),this.state){case Zi:case Kr:case Fr:case Sr:case Hr:this.state=Et}this.nextLoadPosition=this.getLoadPosition()},a.flushMainBuffer=function(r,s){d.prototype.flushMainBuffer.call(this,r,s,this.altAudio?"video":null)},a.onMediaAttached=function(r,s){d.prototype.onMediaAttached.call(this,r,s);var l=s.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),l.addEventListener("playing",this.onvplaying),l.addEventListener("seeked",this.onvseeked),this.gapController=new rn(this.config,l,this.fragmentTracker,this.hls)},a.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),d.prototype.onMediaDetaching.call(this)},a.onMediaPlaying=function(){this.tick()},a.onMediaSeeked=function(){var r=this.media,s=r?r.currentTime:null;(0,R.isFiniteNumber)(s)&&this.log("Media seeked to "+s.toFixed(3)),this.tick()},a.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},a.onManifestParsed=function(r,s){var l,u,c,v=!1,m=!1;s.levels.forEach(function(_){(l=_.audioCodec)&&(l.indexOf("mp4a.40.2")!==-1&&(v=!0),l.indexOf("mp4a.40.5")!==-1&&(m=!0))}),this.audioCodecSwitch=v&&m&&typeof((c=fi())==null||(u=c.prototype)===null||u===void 0?void 0:u.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=s.levels,this.startFragRequested=!1},a.onLevelLoading=function(r,s){var l=this.levels;if(l&&this.state===Et){var u=l[s.level];(!u.details||u.details.live&&this.levelLastLoaded!==s.level||this.waitForCdnTuneIn(u.details))&&(this.state=qr)}},a.onLevelLoaded=function(r,s){var l,u=this.levels,c=s.level,v=s.details,m=v.totalduration;if(u){this.log("Level "+c+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+m);var _=this.fragCurrent;!_||this.state!==Kr&&this.state!==Fr||_.level!==s.level&&_.loader&&(this.state=Et,this.backtrackFragment=null,_.abortRequests());var S=u[c],P=0;if(v.live||(l=S.details)!==null&&l!==void 0&&l.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;P=this.alignPlaylists(v,S.details)}if(S.details=v,this.levelLastLoaded=c,this.hls.trigger(p.Events.LEVEL_UPDATED,{details:v,level:c}),this.state===qr){if(this.waitForCdnTuneIn(v))return;this.state=Et}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,P),this.tick()}else this.warn("Levels were reset while loading level "+c)},a._handleFragmentLoadProgress=function(r){var s,l=r.frag,u=r.part,c=r.payload,v=this.levels;if(v){var m=v[l.level],_=m.details;if(_){var S=m.videoCodec,P=_.PTSKnown||!_.live,I=(s=l.initSegment)===null||s===void 0?void 0:s.data,q=this._getAudioCodec(m),oe=this.transmuxer=this.transmuxer||new Li(this.hls,pe.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),Ee=u?u.index:-1,he=Ee!==-1,Ae=new ki(l.level,l.sn,l.stats.chunkCount,c.byteLength,Ee,he),He=this.initPTS[l.cc];oe.push(c,I,q,S,l,u,_.totalduration,P,Ae,He)}else this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered")},a.onAudioTrackSwitching=function(r,s){var l=this.altAudio,u=!!s.url,c=s.id;if(!u){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v&&(this.log("Switching to main audio track, cancel main fragment load"),v.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var m=this.hls;l&&m.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),m.trigger(p.Events.AUDIO_TRACK_SWITCHED,{id:c})}},a.onAudioTrackSwitched=function(r,s){var l=s.id,u=!!this.hls.audioTracks[l].url;if(u){var c=this.videoBuffer;c&&this.mediaBuffer!==c&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=c)}this.altAudio=u,this.tick()},a.onBufferCreated=function(r,s){var l,u,c=s.tracks,v=!1;for(var m in c){var _=c[m];if(_.id==="main"){if(u=m,l=_,m==="video"){var S=c[m];S&&(this.videoBuffer=S.buffer)}}else v=!0}v&&l?(this.log("Alternate track found, use "+u+".buffered to schedule main fragment loading"),this.mediaBuffer=l.buffer):this.mediaBuffer=this.media},a.onFragBuffered=function(r,s){var l=s.frag,u=s.part;if(!l||l.type===pe.PlaylistLevelType.MAIN){if(this.fragContextChanged(l))return this.warn("Fragment "+l.sn+(u?" p: "+u.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Hr&&(this.state=Et));var c=u?u.stats:l.stats;this.fragLastKbps=Math.round(8*c.total/(c.buffering.end-c.loading.first)),l.sn!=="initSegment"&&(this.fragPrevious=l),this.fragBufferedComplete(l,u)}},a.onError=function(r,s){if(s.type!==w.ErrorTypes.KEY_SYSTEM_ERROR)switch(s.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.FRAG_PARSING_ERROR:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.MAIN,s);break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==kr&&(s.fatal?(this.warn(""+s.details),this.state=kr):s.levelRetry||this.state!==qr||(this.state=Et));break;case w.ErrorDetails.BUFFER_FULL_ERROR:if(s.parent==="main"&&(this.state===Sr||this.state===Hr)){var l=!0,u=this.getFwdBufferInfo(this.media,pe.PlaylistLevelType.MAIN);u&&u.len>.5&&(l=!this.reduceMaxBufferLength(u.len)),l&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.MAIN,s)},a.checkBuffer=function(){var r=this.media,s=this.gapController;if(r&&s&&r.readyState){if(this.loadedmetadata||!Mt.getBuffered(r).length){var l=this.state!==Et?this.fragCurrent:null;s.poll(this.lastCurrentTime,l)}this.lastCurrentTime=r.currentTime}},a.onFragLoadEmergencyAborted=function(){this.state=Et,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},a.onBufferFlushed=function(r,s){var l=s.type;if(l!==$.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var u=(l===$.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(u,l,pe.PlaylistLevelType.MAIN)}},a.onLevelsUpdated=function(r,s){this.levels=s.levels},a.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},a.seekToStartPos=function(){var r=this.media;if(r){var s=r.currentTime,l=this.startPosition;if(l>=0&&s<l){if(r.seeking)return void this.log("could not seek to "+l+", already seeking at "+s);var u=Mt.getBuffered(r),c=(u.length?u.start(0):0)-l;c>0&&(c<this.config.maxBufferHole||c<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+c+" to match buffer start"),l+=c,this.startPosition=l),this.log("seek to target start position "+l+" from current time "+s),r.currentTime=l}}},a._getAudioCodec=function(r){var s=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&s&&(this.log("Swapping audio codec"),s=s.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),s},a._loadBitrateTestFrag=function(r,s){var l=this;r.bitrateTest=!0,this._doFragLoad(r,s).then(function(u){var c=l.hls;if(u&&!c.nextLoadLevel&&!l.fragContextChanged(r)){l.fragLoadError=0,l.state=Et,l.startFragRequested=!1,l.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),c.trigger(p.Events.FRAG_LOADED,u),r.bitrateTest=!1}})},a._handleTransmuxComplete=function(r){var s,l="main",u=this.hls,c=r.remuxResult,v=r.chunkMeta,m=this.getCurrentContext(v);if(!m)return this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(v.level);var _=m.frag,S=m.part,P=m.level,I=c.video,q=c.text,oe=c.id3,Ee=c.initSegment,he=P.details,Ae=this.altAudio?void 0:c.audio;if(!this.fragContextChanged(_)){if(this.state=Sr,Ee){Ee.tracks&&(this._bufferInitSegment(P,Ee.tracks,_,v),u.trigger(p.Events.FRAG_PARSING_INIT_SEGMENT,{frag:_,id:l,tracks:Ee.tracks}));var He=Ee.initPTS,ze=Ee.timescale;(0,R.isFiniteNumber)(He)&&(this.initPTS[_.cc]=He,u.trigger(p.Events.INIT_PTS_FOUND,{frag:_,id:l,initPTS:He,timescale:ze}))}if(I&&c.independent!==!1){if(he){var be=I.startPTS,Ge=I.endPTS,Me=I.startDTS,ct=I.endDTS;if(S)S.elementaryStreams[I.type]={startPTS:be,endPTS:Ge,startDTS:Me,endDTS:ct};else if(I.firstKeyFrame&&I.independent&&v.id===1&&(this.couldBacktrack=!0),I.dropped&&I.independent){var Ot=this.getMainFwdBufferInfo();if((Ot?Ot.end:this.getLoadPosition())+this.config.maxBufferHole<(I.firstKeyFramePTS?I.firstKeyFramePTS:be)-this.config.maxBufferHole)return void this.backtrack(_);_.setElementaryStreamInfo(I.type,_.start,Ge,_.start,ct,!0)}_.setElementaryStreamInfo(I.type,be,Ge,Me,ct),this.backtrackFragment&&(this.backtrackFragment=_),this.bufferFragmentData(I,_,S,v)}}else if(c.independent===!1)return void this.backtrack(_);if(Ae){var ft=Ae.startPTS,Tt=Ae.endPTS,Dt=Ae.startDTS,Zt=Ae.endDTS;S&&(S.elementaryStreams[$.ElementaryStreamTypes.AUDIO]={startPTS:ft,endPTS:Tt,startDTS:Dt,endDTS:Zt}),_.setElementaryStreamInfo($.ElementaryStreamTypes.AUDIO,ft,Tt,Dt,Zt),this.bufferFragmentData(Ae,_,S,v)}if(he&&oe!=null&&(s=oe.samples)!==null&&s!==void 0&&s.length){var zt={id:l,frag:_,details:he,samples:oe.samples};u.trigger(p.Events.FRAG_PARSING_METADATA,zt)}if(he&&q){var Kt={id:l,frag:_,details:he,samples:q.samples};u.trigger(p.Events.FRAG_PARSING_USERDATA,Kt)}}},a._bufferInitSegment=function(r,s,l,u){var c=this;if(this.state===Sr){this.audioOnly=!!s.audio&&!s.video,this.altAudio&&!this.audioOnly&&delete s.audio;var v=s.audio,m=s.video,_=s.audiovideo;if(v){var S=r.audioCodec,P=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(S&&(S=S.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),v.metadata.channelCount!==1&&P.indexOf("firefox")===-1&&(S="mp4a.40.5")),P.indexOf("android")!==-1&&v.container!=="audio/mpeg"&&(S="mp4a.40.2",this.log("Android: force audio codec to "+S)),r.audioCodec&&r.audioCodec!==S&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+S+'"'),v.levelCodec=S,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(S||"")+"/"+(r.audioCodec||"")+"/"+v.codec+"]")}m&&(m.levelCodec=r.videoCodec,m.id="main",this.log("Init video buffer, container:"+m.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+m.codec+"]")),_&&this.log("Init audiovideo buffer, container:"+_.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+_.codec+"]"),this.hls.trigger(p.Events.BUFFER_CODECS,s),Object.keys(s).forEach(function(I){var q=s[I].initSegment;q!=null&&q.byteLength&&c.hls.trigger(p.Events.BUFFER_APPENDING,{type:I,data:q,frag:l,part:null,chunkMeta:u,parent:l.type})}),this.tick()}},a.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,pe.PlaylistLevelType.MAIN)},a.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=Et},a.checkFragmentChanged=function(){var r=this.media,s=null;if(r&&r.readyState>1&&r.seeking===!1){var l=r.currentTime;if(Mt.isBuffered(r,l)?s=this.getAppendedFrag(l):Mt.isBuffered(r,l+.1)&&(s=this.getAppendedFrag(l+.1)),s){this.backtrackFragment=null;var u=this.fragPlaying,c=s.level;u&&s.sn===u.sn&&u.level===c&&s.urlId===u.urlId||(this.fragPlaying=s,this.hls.trigger(p.Events.FRAG_CHANGED,{frag:s}),u&&u.level===c||this.hls.trigger(p.Events.LEVEL_SWITCHED,{level:c}))}}},i=t,(n=[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var s=r.currentTime,l=this.currentFrag;if(l&&(0,R.isFiniteNumber)(s)&&(0,R.isFiniteNumber)(l.programDateTime)){var u=l.programDateTime+1e3*(s-l.start);return new Date(u)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&Vr(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(ci);let gi=function(){function d(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 o=d.prototype;return o.sample=function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e},o.getTotalWeight=function(){return this.totalWeight_},o.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},d}(),En=function(){function d(e,t,i){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new gi(e),this.fast_=new gi(t)}var o=d.prototype;return o.update=function(e,t){var i=this.slow_,n=this.fast_;this.slow_.halfLife!==e&&(this.slow_=new gi(e,i.getEstimate(),i.getTotalWeight())),this.fast_.halfLife!==t&&(this.fast_=new gi(t,n.getEstimate(),n.getTotalWeight()))},o.sample=function(e,t){var i=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/i;this.fast_.sample(i,n),this.slow_.sample(i,n)},o.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},o.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},o.destroy=function(){},d}();function Tn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}let bn=function(){function d(i){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=i;var n=i.config;this.bwEstimator=new En(n.abrEwmaSlowVoD,n.abrEwmaFastVoD,n.abrEwmaDefaultEstimate),this.registerListeners()}var o,e,t=d.prototype;return t.registerListeners=function(){var i=this.hls;i.on(p.Events.FRAG_LOADING,this.onFragLoading,this),i.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),i.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(p.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){var i=this.hls;i.off(p.Events.FRAG_LOADING,this.onFragLoading,this),i.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),i.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(p.Events.ERROR,this.onError,this)},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},t.onFragLoading=function(i,n){var a,r=n.frag;r.type===pe.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=r,this.partCurrent=(a=n.part)!=null?a:null,this.timer=self.setInterval(this.onCheck,100)))},t.onLevelLoaded=function(i,n){var a=this.hls.config;n.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD)},t._abandonRulesCheck=function(){var i=this.fragCurrent,n=this.partCurrent,a=this.hls,r=a.autoLevelEnabled,s=a.media;if(i&&s){var l=n?n.stats:i.stats,u=n?n.duration:i.duration;if(l.aborted||l.loaded&&l.loaded===l.total||i.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(r&&!s.paused&&s.playbackRate&&s.readyState){var c=a.mainForwardBufferInfo;if(c!==null){var v=performance.now()-l.loading.start,m=Math.abs(s.playbackRate);if(!(v<=500*u/m)){var _=l.loaded&&l.loading.first,S=this.bwEstimator.getEstimate(),P=a.levels,I=a.minAutoLevel,q=P[i.level],oe=l.total||Math.max(l.loaded,Math.round(u*q.maxBitrate/8)),Ee=_?1e3*l.loaded/v:0,he=Ee?(oe-l.loaded)/Ee:8*oe/S,Ae=c.len/m;if(!(he<=Ae)){var He,ze=Number.POSITIVE_INFINITY;for(He=i.level-1;He>I;He--){var be=P[He].maxBitrate;if((ze=Ee?u*be/(6.4*Ee):u*be/S)<Ae)break}ze>=he||(k.logger.warn("Fragment "+i.sn+(n?" part "+n.index:"")+" of level "+i.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+He+`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Time to underbuffer: `+Ae.toFixed(3)+" s"),a.nextLoadLevel=He,_&&this.bwEstimator.sample(v,l.loaded),this.clearTimer(),(i.loader||i.keyLoader)&&(this.fragCurrent=this.partCurrent=null,i.abortRequests()),a.trigger(p.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:n,stats:l}))}}}}}},t.onFragLoaded=function(i,n){var a=n.frag,r=n.part;if(a.type===pe.PlaylistLevelType.MAIN&&(0,R.isFiniteNumber)(a.sn)){var s=r?r.stats:a.stats,l=r?r.duration:a.duration;if(this.clearTimer(),this.lastLoadedFragLevel=a.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[a.level],c=(u.loaded?u.loaded.bytes:0)+s.loaded,v=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:c,duration:v},u.realBitrate=Math.round(8*c/v)}if(a.bitrateTest){var m={stats:s,frag:a,part:r,id:a.type};this.onFragBuffered(p.Events.FRAG_BUFFERED,m)}}},t.onFragBuffered=function(i,n){var a=n.frag,r=n.part,s=r?r.stats:a.stats;if(!s.aborted&&a.type===pe.PlaylistLevelType.MAIN&&a.sn!=="initSegment"){var l=s.parsing.end-s.loading.start;this.bwEstimator.sample(l,s.loaded),s.bwEstimate=this.bwEstimator.getEstimate(),a.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}},t.onError=function(i,n){var a;if(((a=n.frag)===null||a===void 0?void 0:a.type)===pe.PlaylistLevelType.MAIN){if(n.type===w.ErrorTypes.KEY_SYSTEM_ERROR)return void this.clearTimer();switch(n.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer()}}},t.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},t.getNextABRAutoLevel=function(){var i=this.fragCurrent,n=this.partCurrent,a=this.hls,r=a.maxAutoLevel,s=a.config,l=a.minAutoLevel,u=a.media,c=n?n.duration:i?i.duration:0,v=u&&u.playbackRate!==0?Math.abs(u.playbackRate):1,m=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,_=a.mainForwardBufferInfo,S=(_?_.len:0)/v,P=this.findBestLevel(m,l,r,S,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(P>=0)return P;k.logger.trace((S?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var I=c?Math.min(c,s.maxStarvationDelay):s.maxStarvationDelay,q=s.abrBandWidthFactor,oe=s.abrBandWidthUpFactor;if(!S){var Ee=this.bitrateTestDelay;Ee&&(I=(c?Math.min(c,s.maxLoadingDelay):s.maxLoadingDelay)-Ee,k.logger.trace("bitrate test took "+Math.round(1e3*Ee)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*I)+" ms"),q=oe=1)}return P=this.findBestLevel(m,l,r,S+I,q,oe),Math.max(P,0)},t.findBestLevel=function(i,n,a,r,s,l){for(var u,c=this.fragCurrent,v=this.partCurrent,m=this.lastLoadedFragLevel,_=this.hls.levels,S=_[m],P=!(S==null||(u=S.details)===null||u===void 0||!u.live),I=S==null?void 0:S.codecSet,q=v?v.duration:c?c.duration:0,oe=a;oe>=n;oe--){var Ee=_[oe];if(Ee&&(!I||Ee.codecSet===I)){var he,Ae=Ee.details,He=(v?Ae==null?void 0:Ae.partTarget:Ae==null?void 0:Ae.averagetargetduration)||q;he=oe<=m?s*i:l*i;var ze=_[oe].maxBitrate,be=ze*He/he;if(k.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+oe+"/"+Math.round(he)+"/"+ze+"/"+He+"/"+r+"/"+be),he>ze&&(be===0||!(0,R.isFiniteNumber)(be)||P&&!this.bitrateTestDelay||be<r))return oe}}return-1},o=d,(e=[{key:"nextAutoLevel",get:function(){var i=this._nextAutoLevel,n=this.bwEstimator;if(i!==-1&&!n.canEstimate())return i;var a=this.getNextABRAutoLevel();return i!==-1&&this.hls.levels[a].loadError?i:(i!==-1&&(a=Math.min(i,a)),a)},set:function(i){this._nextAutoLevel=i}}])&&Tn(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();var nn=function(){function d(){this.chunks=[],this.dataLength=0}var o=d.prototype;return o.push=function(e){this.chunks.push(e),this.dataLength+=e.length},o.flush=function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=t.length===1?t[0]:function(n,a){for(var r=new Uint8Array(a),s=0,l=0;l<n.length;l++){var u=n[l];r.set(u,s),s+=u.length}return r}(t,i),this.reset(),e):new Uint8Array(0)},o.reset=function(){this.chunks.length=0,this.dataLength=0},d}();function pi(){return pi=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},pi.apply(this,arguments)}function Ii(d,o){return Ii=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ii(d,o)}var mi=function(d){var o,e;function t(n,a,r){var s;return(s=d.call(this,n,a,r,"[audio-stream-controller]")||this).videoBuffer=null,s.videoTrackCC=-1,s.waitingVideoCC=-1,s.audioSwitch=!1,s.trackId=-1,s.waitingData=null,s.mainDetails=null,s.bufferFlushed=!1,s.cachedTrackLoadedData=null,s._registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ii(o,e);var i=t.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var n=this.hls;n.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(p.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(p.Events.ERROR,this.onError,this),n.on(p.Events.BUFFER_RESET,this.onBufferReset,this),n.on(p.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var n=this.hls;n.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(p.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(p.Events.ERROR,this.onError,this),n.off(p.Events.BUFFER_RESET,this.onBufferReset,this),n.off(p.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i.onInitPtsFound=function(n,a){var r=a.frag,s=a.id,l=a.initPTS;if(s==="main"){var u=r.cc;this.initPTS[r.cc]=l,this.log("InitPTS for cc: "+u+" found from main: "+l),this.videoTrackCC=u,this.state===Mr&&this.tick()}},i.startLoad=function(n){if(!this.levels)return this.startPosition=n,void(this.state=yr);var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,a>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),n=a,this.state=Et):(this.loadedmetadata=!1,this.state=di),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},i.doTick=function(){switch(this.state){case Et:this.doTickIdle();break;case di:var n,a=this.levels,r=this.trackId,s=a==null||(n=a[r])===null||n===void 0?void 0:n.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=Mr}break;case Fr:var l,u=performance.now(),c=this.retryDate;(!c||u>=c||(l=this.media)!==null&&l!==void 0&&l.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Et);break;case Mr:var v=this.waitingData;if(v){var m=v.frag,_=v.part,S=v.cache,P=v.complete;if(this.initPTS[m.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Kr;var I={frag:m,part:_,payload:S.flush(),networkDetails:null};this._handleFragmentLoadProgress(I),P&&d.prototype._handleFragmentLoadComplete.call(this,I)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+m.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var q=this.getLoadPosition(),oe=Mt.bufferInfo(this.mediaBuffer,q,this.config.maxBufferHole);ui(oe.end,this.config.maxFragLookUpTolerance,m)<0&&(this.log("Waiting fragment cc ("+m.cc+") @ "+m.start+" cancelled because another fragment at "+oe.end+" is needed"),this.clearWaitingFragment())}}else this.state=Et}this.onTickEnd()},i.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Et)},i.resetLoadingState=function(){this.clearWaitingFragment(),d.prototype.resetLoadingState.call(this)},i.onTickEnd=function(){var n=this.media;n&&n.readyState&&(this.lastCurrentTime=n.currentTime)},i.doTickIdle=function(){var n=this.hls,a=this.levels,r=this.media,s=this.trackId,l=n.config;if(a&&a[s]&&(r||!this.startFragRequested&&l.startFragPrefetch)){var u=a[s].details;if(!u||u.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(u))this.state=di;else{var c=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&c&&(this.bufferFlushed=!1,this.afterBufferFlushed(c,$.ElementaryStreamTypes.AUDIO,pe.PlaylistLevelType.AUDIO));var v=this.getFwdBufferInfo(c,pe.PlaylistLevelType.AUDIO);if(v!==null){var m=this.audioSwitch;if(!m&&this._streamEnded(v,u))return n.trigger(p.Events.BUFFER_EOS,{type:"audio"}),void(this.state=Jr);var _=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,pe.PlaylistLevelType.MAIN);if(!(v.len>=this.getMaxBufferLength(_==null?void 0:_.len))||m){var S=u.fragments[0].start,P=v.end;if(m&&r){var I=this.getLoadPosition();P=I,u.PTSKnown&&I<S&&(v.end>S||v.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=S+.05)}if(!(_&&P>_.end+u.targetduration)&&(_&&_.len||!v.len)){var q=this.getNextFragment(P,u);q?this.loadFragment(q,u,P):this.bufferFlushed=!0}}}}}},i.getMaxBufferLength=function(n){var a=d.prototype.getMaxBufferLength.call(this);return n?Math.max(a,n):a},i.onMediaDetaching=function(){this.videoBuffer=null,d.prototype.onMediaDetaching.call(this)},i.onAudioTracksUpdated=function(n,a){var r=a.audioTracks;this.resetTransmuxer(),this.levels=r.map(function(s){return new F(s)})},i.onAudioTrackSwitching=function(n,a){var r=!!a.url;this.trackId=a.id;var s=this.fragCurrent;s&&s.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=Et):this.state=yr,this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},i.onLevelLoaded=function(n,a){this.mainDetails=a.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},i.onAudioTrackLoaded=function(n,a){var r;if(this.mainDetails!=null){var s=this.levels,l=a.details,u=a.id;if(s){this.log("Track "+u+" loaded ["+l.startSN+","+l.endSN+"],duration:"+l.totalduration);var c=s[u],v=0;if(l.live||(r=c.details)!==null&&r!==void 0&&r.live){var m=this.mainDetails;if(l.fragments[0]||(l.deltaUpdateFailed=!0),l.deltaUpdateFailed||!m)return;!c.details&&l.hasProgramDateTime&&m.hasProgramDateTime?(Qi(l,m),v=l.fragments[0].start):v=this.alignPlaylists(l,c.details)}c.details=l,this.levelLastLoaded=u,this.startFragRequested||!this.mainDetails&&l.live||this.setStartPosition(c.details,v),this.state!==di||this.waitForCdnTuneIn(l)||(this.state=Et),this.tick()}else this.warn("Audio tracks were reset while loading level "+u)}else this.cachedTrackLoadedData=a},i._handleFragmentLoadProgress=function(n){var a,r=n.frag,s=n.part,l=n.payload,u=this.config,c=this.trackId,v=this.levels;if(v){var m=v[c],_=m.details,S=u.defaultAudioCodec||m.audioCodec||"mp4a.40.2",P=this.transmuxer;P||(P=this.transmuxer=new Li(this.hls,pe.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var I=this.initPTS[r.cc],q=(a=r.initSegment)===null||a===void 0?void 0:a.data;if(I!==void 0){var oe=s?s.index:-1,Ee=oe!==-1,he=new ki(r.level,r.sn,r.stats.chunkCount,l.byteLength,oe,Ee);P.push(l,q,S,"",r,s,_.totalduration,!1,he,I)}else this.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+_.startSN+" ,"+_.endSN+"],track "+c),(this.waitingData=this.waitingData||{frag:r,part:s,cache:new nn,complete:!1}).cache.push(new Uint8Array(l)),this.waitingVideoCC=this.videoTrackCC,this.state=Mr}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},i._handleFragmentLoadComplete=function(n){this.waitingData?this.waitingData.complete=!0:d.prototype._handleFragmentLoadComplete.call(this,n)},i.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},i.onBufferCreated=function(n,a){var r=a.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer||null)},i.onFragBuffered=function(n,a){var r,s=a.frag,l=a.part;s.type===pe.PlaylistLevelType.AUDIO?this.fragContextChanged(s)?this.warn("Fragment "+s.sn+(l?" p: "+l.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):(s.sn!=="initSegment"&&(this.fragPrevious=s,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(p.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(s,l)):this.loadedmetadata||s.type!==pe.PlaylistLevelType.MAIN||(r=this.videoBuffer||this.media)!==null&&r!==void 0&&r.buffered.length&&(this.loadedmetadata=!0)},i.onError=function(n,a){if(a.type!==w.ErrorTypes.KEY_SYSTEM_ERROR)switch(a.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.FRAG_PARSING_ERROR:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.AUDIO,a);break;case w.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case w.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==kr&&this.state!==yr&&(this.state=a.fatal?kr:Et,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case w.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===Sr||this.state===Hr)){var r=!0,s=this.getFwdBufferInfo(this.mediaBuffer,pe.PlaylistLevelType.AUDIO);s&&s.len>.5&&(r=!this.reduceMaxBufferLength(s.len)),r&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.AUDIO,a)},i.onBufferFlushed=function(n,a){a.type===$.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===Jr&&(this.state=Et))},i._handleTransmuxComplete=function(n){var a,r="audio",s=this.hls,l=n.remuxResult,u=n.chunkMeta,c=this.getCurrentContext(u);if(!c)return this.warn("The loading context changed while buffering fragment "+u.sn+" of level "+u.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(u.level);var v=c.frag,m=c.part,_=c.level.details,S=l.audio,P=l.text,I=l.id3,q=l.initSegment;if(!this.fragContextChanged(v)&&_){if(this.state=Sr,this.audioSwitch&&S&&this.completeAudioSwitch(),q!=null&&q.tracks&&(this._bufferInitSegment(q.tracks,v,u),s.trigger(p.Events.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:r,tracks:q.tracks})),S){var oe=S.startPTS,Ee=S.endPTS,he=S.startDTS,Ae=S.endDTS;m&&(m.elementaryStreams[$.ElementaryStreamTypes.AUDIO]={startPTS:oe,endPTS:Ee,startDTS:he,endDTS:Ae}),v.setElementaryStreamInfo($.ElementaryStreamTypes.AUDIO,oe,Ee,he,Ae),this.bufferFragmentData(S,v,m,u)}if(I!=null&&(a=I.samples)!==null&&a!==void 0&&a.length){var He=pi({id:r,frag:v,details:_},I);s.trigger(p.Events.FRAG_PARSING_METADATA,He)}if(P){var ze=pi({id:r,frag:v,details:_},P);s.trigger(p.Events.FRAG_PARSING_USERDATA,ze)}}},i._bufferInitSegment=function(n,a,r){if(this.state===Sr){n.video&&delete n.video;var s=n.audio;if(s){s.levelCodec=s.codec,s.id="audio",this.log("Init audio buffer, container:"+s.container+", codecs[parsed]=["+s.codec+"]"),this.hls.trigger(p.Events.BUFFER_CODECS,n);var l=s.initSegment;if(l!=null&&l.byteLength){var u={type:"audio",frag:a,part:null,chunkMeta:r,parent:a.type,data:l};this.hls.trigger(p.Events.BUFFER_APPENDING,u)}this.tick()}}},i.loadFragment=function(n,a,r){var s=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||s===Ue.NOT_LOADED||s===Ue.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n,a):a.live&&!(0,R.isFiniteNumber)(this.initPTS[n.cc])?(this.log("Waiting for video PTS in continuity counter "+n.cc+" of live stream before loading audio fragment "+n.sn+" of level "+this.trackId),this.state=Mr):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,n,a,r)))},i.completeAudioSwitch=function(){var n=this.hls,a=this.media,r=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(p.Events.AUDIO_TRACK_SWITCHED,{id:r})},t}(ci);let Ci=mi;function an(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function ei(d,o){return ei=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ei(d,o)}let _n=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[audio-track-controller]")||this).tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.trackName="",s.selectDefaultTrack=!0,s.registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,ei(o,e);var i,n,a=t.prototype;return a.registerListeners=function(){var r=this.hls;r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(p.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var r=this.hls;r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(p.Events.ERROR,this.onError,this)},a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,d.prototype.destroy.call(this)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},a.onManifestParsed=function(r,s){this.tracks=s.audioTracks||[]},a.onAudioTrackLoaded=function(r,s){var l=s.id,u=s.details,c=this.tracksInGroup[l];if(c){var v=c.details;c.details=s.details,this.log("audioTrack "+l+" loaded ["+u.startSN+"-"+u.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,v))}else this.warn("Invalid audio track id "+l)},a.onLevelLoading=function(r,s){this.switchLevel(s.level)},a.onLevelSwitching=function(r,s){this.switchLevel(s.level)},a.switchLevel=function(r){var s=this.hls.levels[r];if(s!=null&&s.audioGroupIds){var l=s.audioGroupIds[s.urlId];if(this.groupId!==l){this.groupId=l;var u=this.tracks.filter(function(v){return!l||v.groupId===l});this.selectDefaultTrack&&!u.some(function(v){return v.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=u;var c={audioTracks:u};this.log("Updating audio tracks, "+u.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(p.Events.AUDIO_TRACKS_UPDATED,c),this.selectInitialTrack()}}},a.onError=function(r,s){d.prototype.onError.call(this,r,s),!s.fatal&&s.context&&s.context.type===pe.PlaylistContextType.AUDIO_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.setAudioTrack=function(r){var s=this.tracksInGroup;if(r<0||r>=s.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var l=s[this.trackId];this.log("Now switching to audio-track index "+r);var u=s[r],c=u.id,v=u.groupId,m=v===void 0?"":v,_=u.name,S=u.type,P=u.url;if(this.trackId=r,this.trackName=_,this.selectDefaultTrack=!1,this.hls.trigger(p.Events.AUDIO_TRACK_SWITCHING,{id:c,groupId:m,name:_,type:S,url:P}),!u.details||u.details.live){var I=this.switchParams(u.url,l==null?void 0:l.details);this.loadPlaylist(I)}}},a.selectInitialTrack=function(){this.tracksInGroup;var r=this.trackName,s=this.findTrackId(r)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},a.findTrackId=function(r){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var u=s[l];if((!this.selectDefaultTrack||u.default)&&(!r||r===u.name))return u.id}return-1},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,u=s.groupId,c=s.url;if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(p.Events.AUDIO_TRACK_LOADING,{url:c,id:l,groupId:u,deliveryDirectives:r||null})}},i=t,(n=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1,this.setAudioTrack(r)}}])&&an(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(we);function Sn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Oi(d,o){return Oi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Oi(d,o)}var An=function(d){var o,e;function t(r,s,l){var u;return(u=d.call(this,r,s,l,"[subtitle-stream-controller]")||this).levels=[],u.currentTrackId=-1,u.tracksBuffered=[],u.mainDetails=null,u._registerListeners(),u}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Oi(o,e);var i,n,a=t.prototype;return a.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},a._registerListeners=function(){var r=this.hls;r.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(p.Events.ERROR,this.onError,this),r.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(p.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.on(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(p.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var r=this.hls;r.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(p.Events.ERROR,this.onError,this),r.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.off(p.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.off(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(p.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a.startLoad=function(r){this.stopLoad(),this.state=Et,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},a.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},a.onLevelLoaded=function(r,s){this.mainDetails=s.details},a.onSubtitleFragProcessed=function(r,s){var l=s.frag,u=s.success;if(this.fragPrevious=l,this.state=Et,u){var c=this.tracksBuffered[this.currentTrackId];if(c){for(var v,m=l.start,_=0;_<c.length;_++)if(m>=c[_].start&&m<=c[_].end){v=c[_];break}var S=l.start+l.duration;v?v.end=S:(v={start:m,end:S},c.push(v)),this.fragmentTracker.fragBuffered(l)}}},a.onBufferFlushing=function(r,s){var l=s.startOffset,u=s.endOffset;if(l===0&&u!==Number.POSITIVE_INFINITY){var c=this.currentTrackId,v=this.levels;if(!v.length||!v[c]||!v[c].details)return;var m=u-v[c].details.targetduration;if(m<=0)return;s.endOffsetSubtitles=Math.max(0,m),this.tracksBuffered.forEach(function(_){for(var S=0;S<_.length;)if(_[S].end<=m)_.shift();else{if(!(_[S].start<m))break;_[S].start=m,S++}}),this.fragmentTracker.removeFragmentsInRange(l,m,pe.PlaylistLevelType.SUBTITLE)}},a.onFragBuffered=function(r,s){var l;this.loadedmetadata||s.frag.type!==pe.PlaylistLevelType.MAIN||(l=this.media)!==null&&l!==void 0&&l.buffered.length&&(this.loadedmetadata=!0)},a.onError=function(r,s){var l=s.frag;l&&l.type===pe.PlaylistLevelType.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=Et)},a.onSubtitleTracksUpdated=function(r,s){var l=this,u=s.subtitleTracks;this.tracksBuffered=[],this.levels=u.map(function(c){return new F(c)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(c){l.tracksBuffered[c.id]=[]}),this.mediaBuffer=null},a.onSubtitleTrackSwitch=function(r,s){if(this.currentTrackId=s.id,this.levels.length&&this.currentTrackId!==-1){var l=this.levels[this.currentTrackId];l!=null&&l.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,l&&this.setInterval(500)}else this.clearInterval()},a.onSubtitleTrackLoaded=function(r,s){var l,u=s.details,c=s.id,v=this.currentTrackId,m=this.levels;if(m.length){var _=m[v];if(!(c>=m.length||c!==v)&&_){this.mediaBuffer=this.mediaBufferTimeRanges;var S=0;if(u.live||(l=_.details)!==null&&l!==void 0&&l.live){var P=this.mainDetails;if(u.deltaUpdateFailed||!P)return;var I=P.fragments[0];_.details?(S=this.alignPlaylists(u,_.details))===0&&I&&ge(u,S=I.start):u.hasProgramDateTime&&P.hasProgramDateTime?(Qi(u,P),S=u.fragments[0].start):I&&ge(u,S=I.start)}_.details=u,this.levelLastLoaded=c,this.startFragRequested||!this.mainDetails&&u.live||this.setStartPosition(_.details,S),this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===Et&&(li(null,u.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),_.details=void 0))}}},a._handleFragmentLoadComplete=function(r){var s=this,l=r.frag,u=r.payload,c=l.decryptdata,v=this.hls;if(!this.fragContextChanged(l)&&u&&u.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var m=performance.now();this.decrypter.decrypt(new Uint8Array(u),c.key.buffer,c.iv.buffer).then(function(_){var S=performance.now();v.trigger(p.Events.FRAG_DECRYPTED,{frag:l,payload:_,stats:{tstart:m,tdecrypt:S}})}).catch(function(_){s.warn(_.name+": "+_.message),s.state=Et})}},a.doTick=function(){if(this.media){if(this.state===Et){var r=this.currentTrackId,s=this.levels;if(!s.length||!s[r]||!s[r].details)return;var l=s[r].details,u=l.targetduration,c=this.config,v=this.getLoadPosition(),m=Mt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],v-u,c.maxBufferHole),_=m.end,S=m.len,P=this.getFwdBufferInfo(this.media,pe.PlaylistLevelType.MAIN);if(S>this.getMaxBufferLength(P==null?void 0:P.len)+u)return;var I=l.fragments,q=I.length,oe=l.edge,Ee=null,he=this.fragPrevious;if(_<oe){var Ae=c.maxFragLookUpTolerance;!(Ee=li(he,I,Math.max(I[0].start,_),Ae))&&he&&he.start<I[0].start&&(Ee=I[0])}else Ee=I[q-1];if(!Ee)return;Ee=this.mapToInitFragWhenRequired(Ee),this.fragmentTracker.getState(Ee)===Ue.NOT_LOADED&&this.loadFragment(Ee,l,_)}}else this.state=Et},a.getMaxBufferLength=function(r){var s=d.prototype.getMaxBufferLength.call(this);return r?Math.max(s,r):s},a.loadFragment=function(r,s,l){this.fragCurrent=r,r.sn==="initSegment"?this._loadInitSegment(r,s):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,s,l))},i=t,(n=[{key:"mediaBufferTimeRanges",get:function(){return new kn(this.tracksBuffered[this.currentTrackId]||[])}}])&&Sn(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(ci),kn=function(d){this.buffered=void 0;var o=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 d[t][e]};this.buffered={get length(){return d.length},end:function(e){return o("end",e,d.length)},start:function(e){return o("start",e,d.length)}}};function wn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Pi(d,o){return Pi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Pi(d,o)}function xi(d){for(var o=[],e=0;e<d.length;e++){var t=d[e];t.kind==="subtitles"&&t.label&&o.push(d[e])}return o}let Dn=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[subtitle-track-controller]")||this).media=null,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.selectDefaultTrack=!0,s.queuedDefaultTrack=-1,s.trackChangeListener=function(){return s.onTextTracksChanged()},s.asyncPollTrackChange=function(){return s.pollTrackChange(0)},s.useTextTrackPolling=!1,s.subtitlePollingInterval=-1,s._subtitleDisplay=!0,s.registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Pi(o,e);var i,n,a=t.prototype;return a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,d.prototype.destroy.call(this)},a.registerListeners=function(){var r=this.hls;r.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(p.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var r=this.hls;r.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(p.Events.ERROR,this.onError,this)},a.onMediaAttached=function(r,s){this.media=s.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))},a.pollTrackChange=function(r){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,r)},a.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),xi(this.media.textTracks).forEach(function(r){ht(r)}),this.subtitleTrack=-1,this.media=null)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},a.onManifestParsed=function(r,s){this.tracks=s.subtitleTracks},a.onSubtitleTrackLoaded=function(r,s){var l=s.id,u=s.details,c=this.trackId,v=this.tracksInGroup[c];if(v){var m=v.details;v.details=s.details,this.log("subtitle track "+l+" loaded ["+u.startSN+"-"+u.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,m))}else this.warn("Invalid subtitle track id "+l)},a.onLevelLoading=function(r,s){this.switchLevel(s.level)},a.onLevelSwitching=function(r,s){this.switchLevel(s.level)},a.switchLevel=function(r){var s=this.hls.levels[r];if(s!=null&&s.textGroupIds){var l=s.textGroupIds[s.urlId];if(this.groupId!==l){var u=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,c=this.tracks.filter(function(_){return!l||_.groupId===l});this.tracksInGroup=c;var v=this.findTrackId(u==null?void 0:u.name)||this.findTrackId();this.groupId=l;var m={subtitleTracks:c};this.log("Updating subtitle tracks, "+c.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(p.Events.SUBTITLE_TRACKS_UPDATED,m),v!==-1&&this.setSubtitleTrack(v,u)}}},a.findTrackId=function(r){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var u=s[l];if((!this.selectDefaultTrack||u.default)&&(!r||r===u.name))return u.id}return-1},a.onError=function(r,s){d.prototype.onError.call(this,r,s),!s.fatal&&s.context&&s.context.type===pe.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,u=s.groupId,c=s.url;if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("Loading subtitle playlist for id "+l),this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADING,{url:c,id:l,groupId:u,deliveryDirectives:r||null})}},a.toggleTrackModes=function(r){var s=this,l=this.media,u=this.trackId;if(l){var c=xi(l.textTracks),v=c.filter(function(S){return S.groupId===s.groupId});if(r===-1)[].slice.call(c).forEach(function(S){S.mode="disabled"});else{var m=v[u];m&&(m.mode="disabled")}var _=v[r];_&&(_.mode=this.subtitleDisplay?"showing":"hidden")}},a.setSubtitleTrack=function(r,s){var l,u=this.tracksInGroup;if(this.media){if(this.trackId!==r&&this.toggleTrackModes(r),!(this.trackId===r&&(r===-1||(l=u[r])!==null&&l!==void 0&&l.details)||r<-1||r>=u.length)){this.clearTimer();var c=u[r];if(this.log("Switching to subtitle track "+r),this.trackId=r,c){var v=c.id,m=c.groupId,_=m===void 0?"":m,S=c.name,P=c.type,I=c.url;this.hls.trigger(p.Events.SUBTITLE_TRACK_SWITCH,{id:v,groupId:_,name:S,type:P,url:I});var q=this.switchParams(c.url,s==null?void 0:s.details);this.loadPlaylist(q)}else this.hls.trigger(p.Events.SUBTITLE_TRACK_SWITCH,{id:r})}}else this.queuedDefaultTrack=r},a.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var r=-1,s=xi(this.media.textTracks),l=0;l<s.length;l++)if(s[l].mode==="hidden")r=l;else if(s[l].mode==="showing"){r=l;break}this.subtitleTrack!==r&&(this.subtitleTrack=r)}},i=t,(n=[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(r){this._subtitleDisplay=r,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(r,s)}}])&&wn(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(we);var gt,hr=function(){function d(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var o=d.prototype;return o.append=function(e,t){var i=this.queues[t];i.push(e),i.length===1&&this.buffers[t]&&this.executeNext(t)},o.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},o.appendBlocker=function(e){var t,i=new Promise(function(a){t=a}),n={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(n,e),i},o.executeNext=function(e){var t=this.buffers,i=this.queues,n=t[e],a=i[e];if(a.length){var r=a[0];try{r.execute()}catch(s){k.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),r.onError(s),n&&n.updating||(a.shift(),this.executeNext(e))}}},o.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},o.current=function(e){return this.queues[e][0]},d}(),Yr=hi(),sn=/([ha]vc.)(?:\.[^.,]+)+/,Ln=function(){function d(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.hls,n=t.media,a=t.mediaSource;k.logger.log("[buffer-controller]: Media source opened"),n&&(t.updateMediaElementDuration(),i.trigger(p.Events.MEDIA_ATTACHED,{media:n})),a&&a.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){k.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){k.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var o=d.prototype;return o.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},o.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},o.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.Events.BUFFER_RESET,this.onBufferReset,this),e.on(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.Events.BUFFER_EOS,this.onBufferEos,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.Events.FRAG_PARSED,this.onFragParsed,this),e.on(p.Events.FRAG_CHANGED,this.onFragChanged,this)},o.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.Events.BUFFER_RESET,this.onBufferReset,this),e.off(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.Events.BUFFER_EOS,this.onBufferEos,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.Events.FRAG_PARSED,this.onFragParsed,this),e.off(p.Events.FRAG_CHANGED,this.onFragChanged,this)},o._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new hr(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},o.onManifestParsed=function(e,t){var i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.details=null,k.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},o.onMediaAttaching=function(e,t){var i=this.media=t.media;if(i&&Yr){var n=this.mediaSource=new Yr;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(n),this._objectUrl=i.src}},o.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,i=this._objectUrl;if(t){if(k.logger.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(n){k.logger.warn("[buffer-controller]: onMediaDetaching: "+n.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):k.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.Events.MEDIA_DETACHED,void 0)},o.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(n){k.logger.warn("[buffer-controller]: Failed to reset the "+t+" buffer",n)}}),this._initSourceBuffer()},o.onBufferCodecs=function(e,t){var i=this,n=this.getSourceBufferTypes().length;Object.keys(t).forEach(function(a){if(n){var r=i.tracks[a];if(r&&typeof r.buffer.changeType=="function"){var s=t[a],l=s.id,u=s.codec,c=s.levelCodec,v=s.container,m=s.metadata,_=(r.levelCodec||r.codec).replace(sn,"$1"),S=(c||u).replace(sn,"$1");if(_!==S){var P=v+";codecs="+(c||u);i.appendChangeType(a,P),k.logger.log("[buffer-controller]: switching codec "+_+" to "+S),i.tracks[a]={buffer:r.buffer,codec:u,container:v,levelCodec:c,metadata:m,id:l}}}}else i.pendingTracks[a]=t[a]}),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},o.appendChangeType=function(e,t){var i=this,n=this.operationQueue,a={execute:function(){var r=i.sourceBuffer[e];r&&(k.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),r.changeType(t)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(r){k.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",r)}};n.append(a,e)},o.onBufferAppending=function(e,t){var i=this,n=this.hls,a=this.operationQueue,r=this.tracks,s=t.data,l=t.type,u=t.frag,c=t.part,v=t.chunkMeta,m=v.buffering[l],_=self.performance.now();m.start=_;var S=u.stats.buffering,P=c?c.stats.buffering:null;S.start===0&&(S.start=_),P&&P.start===0&&(P.start=_);var I=r.audio,q=!1;l==="audio"&&(I==null?void 0:I.container)==="audio/mpeg"&&(q=!this.lastMpegAudioChunk||v.id===1||this.lastMpegAudioChunk.sn!==v.sn,this.lastMpegAudioChunk=v);var oe=u.start,Ee={execute:function(){if(m.executeStart=self.performance.now(),q){var he=i.sourceBuffer[l];if(he){var Ae=oe-he.timestampOffset;Math.abs(Ae)>=.1&&(k.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+oe+" (delta: "+Ae+") sn: "+u.sn+")"),he.timestampOffset=oe)}}i.appendExecutor(s,l)},onStart:function(){},onComplete:function(){var he=self.performance.now();m.executeEnd=m.end=he,S.first===0&&(S.first=he),P&&P.first===0&&(P.first=he);var Ae=i.sourceBuffer,He={};for(var ze in Ae)He[ze]=Mt.getBuffered(Ae[ze]);i.appendError=0,i.hls.trigger(p.Events.BUFFER_APPENDED,{type:l,frag:u,part:c,chunkMeta:v,parent:u.type,timeRanges:He})},onError:function(he){k.logger.error("[buffer-controller]: Error encountered while trying to append to the "+l+" SourceBuffer",he);var Ae={type:w.ErrorTypes.MEDIA_ERROR,parent:u.type,details:w.ErrorDetails.BUFFER_APPEND_ERROR,err:he,fatal:!1};he.code===DOMException.QUOTA_EXCEEDED_ERR?Ae.details=w.ErrorDetails.BUFFER_FULL_ERROR:(i.appendError++,Ae.details=w.ErrorDetails.BUFFER_APPEND_ERROR,i.appendError>n.config.appendErrorMaxRetry&&(k.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),Ae.fatal=!0,n.stopLoad())),n.trigger(p.Events.ERROR,Ae)}};a.append(Ee,l)},o.onBufferFlushing=function(e,t){var i=this,n=this.operationQueue,a=function(r){return{execute:i.removeExecutor.bind(i,r,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(p.Events.BUFFER_FLUSHED,{type:r})},onError:function(s){k.logger.warn("[buffer-controller]: Failed to remove from "+r+" SourceBuffer",s)}}};t.type?n.append(a(t.type),t.type):this.getSourceBufferTypes().forEach(function(r){n.append(a(r),r)})},o.onFragParsed=function(e,t){var i=this,n=t.frag,a=t.part,r=[],s=a?a.elementaryStreams:n.elementaryStreams;s[$.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(s[$.ElementaryStreamTypes.AUDIO]&&r.push("audio"),s[$.ElementaryStreamTypes.VIDEO]&&r.push("video")),r.length===0&&k.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers(function(){var l=self.performance.now();n.stats.buffering.end=l,a&&(a.stats.buffering.end=l);var u=a?a.stats:n.stats;i.hls.trigger(p.Events.FRAG_BUFFERED,{frag:n,part:a,stats:u,id:n.type})},r)},o.onFragChanged=function(e,t){this.flushBackBuffer()},o.onBufferEos=function(e,t){var i=this;this.getSourceBufferTypes().reduce(function(n,a){var r=i.sourceBuffer[a];return!r||t.type&&t.type!==a||(r.ending=!0,r.ended||(r.ended=!0,k.logger.log("[buffer-controller]: "+a+" sourceBuffer now EOS"))),n&&!(r&&!r.ended)},!0)&&(k.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){i.getSourceBufferTypes().forEach(function(a){var r=i.sourceBuffer[a];r&&(r.ending=!1)});var n=i.mediaSource;n&&n.readyState==="open"?(k.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),n.endOfStream()):n&&k.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+n.readyState)}))},o.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())},o.flushBackBuffer=function(){var e=this.hls,t=this.details,i=this.media,n=this.sourceBuffer;if(i&&t!==null){var a=this.getSourceBufferTypes();if(a.length){var r=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if((0,R.isFiniteNumber)(r)&&!(r<0)){var s=i.currentTime,l=t.levelTargetDuration,u=Math.max(r,l),c=Math.floor(s/l)*l-u;a.forEach(function(v){var m=n[v];if(m){var _=Mt.getBuffered(m);if(_.length>0&&c>_.start(0)){if(e.trigger(p.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(p.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(m.ended&&_.end(_.length-1)-s<2*l)return void k.logger.info("[buffer-controller]: Cannot flush "+v+" back buffer while SourceBuffer is in ended state");e.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:v})}}})}}}},o.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,t=this.hls,i=this.media,n=this.mediaSource,a=e.fragments[0].start+e.totalduration,r=i.duration,s=(0,R.isFiniteNumber)(n.duration)?n.duration:0;e.live&&t.config.liveDurationInfinity?(k.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(a>s&&a>r||!(0,R.isFiniteNumber)(r))&&(k.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},o.updateSeekableRange=function(e){var t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){var n=Math.max(0,i[0].start),a=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,a)}},o.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,i=this.pendingTracks,n=Object.keys(i).length;if(n&&!e||n===2){this.createSourceBuffers(i),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length===0)return void this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});a.forEach(function(r){t.executeNext(r)})}},o.createSourceBuffers=function(e){var t=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var a in e)if(!t[a]){var r=e[a];if(!r)throw Error("source buffer exists for track "+a+", however track does not");var s=r.levelCodec||r.codec,l=r.container+";codecs="+s;k.logger.log("[buffer-controller]: creating sourceBuffer("+l+")");try{var u=t[a]=i.addSourceBuffer(l),c=a;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[a]={buffer:u,codec:s,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},n++}catch(v){k.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+v.message),this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,mimeType:l})}}n&&this.hls.trigger(p.Events.BUFFER_CREATED,{tracks:this.tracks})},o._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},o._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},o._onSBUpdateError=function(e,t){k.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var i=this.operationQueue.current(e);i&&i.onError(t)},o.removeExecutor=function(e,t,i){var n=this.media,a=this.mediaSource,r=this.operationQueue,s=this.sourceBuffer[e];if(!n||!a||!s)return k.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);var l=(0,R.isFiniteNumber)(n.duration)?n.duration:1/0,u=(0,R.isFiniteNumber)(a.duration)?a.duration:1/0,c=Math.max(0,t),v=Math.min(i,l,u);v>c&&!s.ending?(s.ended=!1,k.logger.log("[buffer-controller]: Removing ["+c+","+v+"] from the "+e+" SourceBuffer"),s.remove(c,v)):r.shiftAndExecuteNext(e)},o.appendExecutor=function(e,t){var i=this.operationQueue,n=this.sourceBuffer[t];if(!n)return k.logger.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void i.shiftAndExecuteNext(t);n.ended=!1,n.appendBuffer(e)},o.blockBuffers=function(e,t){var i=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length)return k.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var n=this.operationQueue,a=t.map(function(r){return n.appendBlocker(r)});Promise.all(a).then(function(){e(),t.forEach(function(r){var s=i.sourceBuffer[r];s&&s.updating||n.shiftAndExecuteNext(r)})})},o.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},o.addBufferListener=function(e,t,i){var n=this.sourceBuffer[e];if(n){var a=i.bind(this,e);this.listeners[e].push({event:t,listener:a}),n.addEventListener(t,a)}},o.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(i){t.removeEventListener(i.event,i.listener)})},d}(),g={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},h=function(d){var o=d;return g.hasOwnProperty(d)&&(o=g[d]),String.fromCharCode(o)},f=15,y=100,b={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},O={17:2,18:4,21:6,22:8,23:10,19:13,20:15},D={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},H={25:2,26:4,29:6,30:8,31:10,27:13,28:15},le=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];(function(d){d[d.ERROR=0]="ERROR",d[d.TEXT=1]="TEXT",d[d.WARNING=2]="WARNING",d[d.INFO=2]="INFO",d[d.DEBUG=3]="DEBUG",d[d.DATA=3]="DATA"})(gt||(gt={}));var Z=function(){function d(){this.time=null,this.verboseLevel=gt.ERROR}return d.prototype.log=function(o,e){if(this.verboseLevel>=o){var t=typeof e=="function"?e():e;k.logger.log(this.time+" ["+o+"] "+t)}},d}(),Ce=function(d){for(var o=[],e=0;e<d.length;e++)o.push(d[e].toString(16));return o},at=function(){function d(e,t,i,n,a){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=n||"black",this.flash=a||!1}var o=d.prototype;return o.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},o.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}},o.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},o.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},o.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},o.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},d}(),Je=function(){function d(e,t,i,n,a,r){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new at(t,i,n,a,r)}var o=d.prototype;return o.reset=function(){this.uchar=" ",this.penState.reset()},o.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},o.setPenState=function(e){this.penState.copy(e)},o.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},o.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},o.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},d}(),it=function(){function d(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<y;t++)this.chars.push(new Je);this.logger=e,this.pos=0,this.currPenState=new at}var o=d.prototype;return o.equals=function(e){for(var t=!0,i=0;i<y;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t},o.copy=function(e){for(var t=0;t<y;t++)this.chars[t].copy(e.chars[t])},o.isEmpty=function(){for(var e=!0,t=0;t<y;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},o.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(gt.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>y&&(this.logger.log(gt.DEBUG,"Too large cursor position "+this.pos),this.pos=y)},o.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)},o.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},o.insertChar=function(e){var t=this;e>=144&&this.backSpace();var i=h(e);this.pos>=y?this.logger.log(gt.ERROR,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))},o.clearFromPos=function(e){var t;for(t=e;t<y;t++)this.chars[t].reset()},o.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},o.clearToEndOfRow=function(){this.clearFromPos(this.pos)},o.getTextString=function(){for(var e=[],t=!0,i=0;i<y;i++){var n=this.chars[i].uchar;n!==" "&&(t=!1),e.push(n)}return t?"":e.join("")},o.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},d}(),Xe=function(){function d(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<f;t++)this.rows.push(new it(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var o=d.prototype;return o.reset=function(){for(var e=0;e<f;e++)this.rows[e].clear();this.currRow=14},o.equals=function(e){for(var t=!0,i=0;i<f;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t},o.copy=function(e){for(var t=0;t<f;t++)this.rows[t].copy(e.rows[t])},o.isEmpty=function(){for(var e=!0,t=0;t<f;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},o.backSpace=function(){this.rows[this.currRow].backSpace()},o.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},o.insertChar=function(e){this.rows[this.currRow].insertChar(e)},o.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},o.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},o.setCursor=function(e){this.logger.log(gt.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},o.setPAC=function(e){this.logger.log(gt.INFO,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<f;i++)this.rows[i].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var r=a.rows[n].cueStartTime,s=this.logger.time;if(r&&s!==null&&r<s)for(var l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(a.rows[n+l])}}this.currRow=t;var u=this.rows[this.currRow];if(e.indent!==null){var c=e.indent,v=Math.max(c-1,0);u.setCursor(e.indent),e.color=u.chars[v].penState.foreground}var m={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(m)},o.setBkgData=function(e){this.logger.log(gt.INFO,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},o.setRollUpRows=function(e){this.nrRollUpRows=e},o.rollUp=function(){var e=this;if(this.nrRollUpRows!==null){this.logger.log(gt.TEXT,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(gt.INFO,"Rolling up")}else this.logger.log(gt.DEBUG,"roll_up but nrRollUpRows not set yet")},o.getDisplayText=function(e){e=e||!1;for(var t=[],i="",n=-1,a=0;a<f;a++){var r=this.rows[a].getTextString();r&&(n=a+1,e?t.push("Row "+n+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join(`
|
|
20
|
-
`)),i},o.getTextAndFormat=function(){return this.rows},d}(),nt=function(){function d(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 Xe(i),this.nonDisplayedMemory=new Xe(i),this.lastOutputScreen=new Xe(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}var o=d.prototype;return o.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},o.getHandler=function(){return this.outputFilter},o.setHandler=function(e){this.outputFilter=e},o.setPAC=function(e){this.writeScreen.setPAC(e)},o.setBkgData=function(e){this.writeScreen.setBkgData(e)},o.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(gt.INFO,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)},o.insertChars=function(e){for(var t=this,i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);var n=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(gt.INFO,function(){return n+": "+t.writeScreen.getDisplayText(!0)}),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(gt.TEXT,function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},o.ccRCL=function(){this.logger.log(gt.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},o.ccBS=function(){this.logger.log(gt.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},o.ccAOF=function(){},o.ccAON=function(){},o.ccDER=function(){this.logger.log(gt.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},o.ccRU=function(e){this.logger.log(gt.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},o.ccFON=function(){this.logger.log(gt.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},o.ccRDC=function(){this.logger.log(gt.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},o.ccTR=function(){this.logger.log(gt.INFO,"TR"),this.setMode("MODE_TEXT")},o.ccRTD=function(){this.logger.log(gt.INFO,"RTD"),this.setMode("MODE_TEXT")},o.ccEDM=function(){this.logger.log(gt.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},o.ccCR=function(){this.logger.log(gt.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},o.ccENM=function(){this.logger.log(gt.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},o.ccEOC=function(){var e=this;if(this.logger.log(gt.INFO,"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(gt.TEXT,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},o.ccTO=function(e){this.logger.log(gt.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},o.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(gt.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},o.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))},o.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},d}(),wt=function(){function d(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new Z;this.channels=[null,new nt(e,t,n),new nt(e+1,i,n)],this.cmdHistory={a:null,b:null},this.logger=n}var o=d.prototype;return o.getHandler=function(e){return this.channels[e].getHandler()},o.setHandler=function(e,t){this.channels[e].setHandler(t)},o.addData=function(e,t){var i,n,a,r=!1;this.logger.time=e;for(var s=0;s<t.length;s+=2)if(n=127&t[s],a=127&t[s+1],n!==0||a!==0){if(this.logger.log(gt.DATA,"["+Ce([t[s],t[s+1]])+"] -> ("+Ce([n,a])+")"),(i=this.parseCmd(n,a))||(i=this.parseMidrow(n,a)),i||(i=this.parsePAC(n,a)),i||(i=this.parseBackgroundAttributes(n,a)),!i&&(r=this.parseChars(n,a))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(r):this.logger.log(gt.WARNING,"No channel found yet. TEXT-MODE?")}i||r||this.logger.log(gt.WARNING,"Couldn't parse cleaned data "+Ce([n,a])+" orig: "+Ce([t[s],t[s+1]]))}},o.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($t(e,t,i))return jt(null,null,i),this.logger.log(gt.DEBUG,"Repeated command ("+Ce([e,t])+") is dropped"),!0;var n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),jt(e,t,i),this.currentChannel=n,!0},o.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(gt.ERROR,"Mismatch channel in midrow parsing"),!1;var n=this.channels[i];return!!n&&(n.ccMIDROW(t),this.logger.log(gt.DEBUG,"MIDROW ("+Ce([e,t])+")"),!0)}return!1},o.parsePAC=function(e,t){var i,n=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($t(e,t,n))return jt(null,null,n),!0;var a=e<=23?1:2;i=t>=64&&t<=95?a===1?b[e]:D[e]:a===1?O[e]:H[e];var r=this.channels[a];return!!r&&(r.setPAC(this.interpretPAC(i,t)),jt(e,t,n),this.currentChannel=a,!0)},o.interpretPAC=function(e,t){var i,n={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,n.underline=(1&i)==1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n},o.parseChars=function(e,t){var i,n,a=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19?(n=r===17?t+80:r===18?t+112:t+144,this.logger.log(gt.INFO,"Special char '"+h(n)+"' in channel "+i),a=[n]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var s=Ce(a);this.logger.log(gt.DEBUG,"Char codes = "+s.join(",")),jt(e,t,this.cmdHistory)}return a},o.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 n={};e===16||e===24?(i=Math.floor((t-32)/2),n.background=le[i],t%2==1&&(n.background=n.background+"_semi")):t===45?n.background="transparent":(n.foreground="black",t===47&&(n.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(n),jt(e,t,this.cmdHistory),!0},o.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}},o.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}},d}();function jt(d,o,e){e.a=d,e.b=o}function $t(d,o,e){return e.a===d&&e.b===o}let nr=wt;var mt=function(){function d(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 o=d.prototype;return o.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},o.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)},o.reset=function(){this.cueRanges=[],this.startTime=null},d}();let Xt=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var d=["","lr","rl"],o=["start","middle","end","left","right"];function e(a,r){if(typeof r!="string"||!Array.isArray(a))return!1;var s=r.toLowerCase();return!!~a.indexOf(s)&&s}function t(a){return e(o,a)}function i(a){for(var r=arguments.length,s=new Array(r>1?r-1:0),l=1;l<r;l++)s[l-1]=arguments[l];for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var v in c)a[v]=c[v]}return a}function n(a,r,s){var l=this,u={enumerable:!0};l.hasBeenReset=!1;var c="",v=!1,m=a,_=r,S=s,P=null,I="",q=!0,oe="auto",Ee="start",he=50,Ae="middle",He=50,ze="middle";Object.defineProperty(l,"id",i({},u,{get:function(){return c},set:function(be){c=""+be}})),Object.defineProperty(l,"pauseOnExit",i({},u,{get:function(){return v},set:function(be){v=!!be}})),Object.defineProperty(l,"startTime",i({},u,{get:function(){return m},set:function(be){if(typeof be!="number")throw new TypeError("Start time must be set to a number.");m=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"endTime",i({},u,{get:function(){return _},set:function(be){if(typeof be!="number")throw new TypeError("End time must be set to a number.");_=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"text",i({},u,{get:function(){return S},set:function(be){S=""+be,this.hasBeenReset=!0}})),Object.defineProperty(l,"region",i({},u,{get:function(){return P},set:function(be){P=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"vertical",i({},u,{get:function(){return I},set:function(be){var Ge=function(Me){return e(d,Me)}(be);if(Ge===!1)throw new SyntaxError("An invalid or illegal string was specified.");I=Ge,this.hasBeenReset=!0}})),Object.defineProperty(l,"snapToLines",i({},u,{get:function(){return q},set:function(be){q=!!be,this.hasBeenReset=!0}})),Object.defineProperty(l,"line",i({},u,{get:function(){return oe},set:function(be){if(typeof be!="number"&&be!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");oe=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"lineAlign",i({},u,{get:function(){return Ee},set:function(be){var Ge=t(be);if(!Ge)throw new SyntaxError("An invalid or illegal string was specified.");Ee=Ge,this.hasBeenReset=!0}})),Object.defineProperty(l,"position",i({},u,{get:function(){return he},set:function(be){if(be<0||be>100)throw new Error("Position must be between 0 and 100.");he=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"positionAlign",i({},u,{get:function(){return Ae},set:function(be){var Ge=t(be);if(!Ge)throw new SyntaxError("An invalid or illegal string was specified.");Ae=Ge,this.hasBeenReset=!0}})),Object.defineProperty(l,"size",i({},u,{get:function(){return He},set:function(be){if(be<0||be>100)throw new Error("Size must be between 0 and 100.");He=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"align",i({},u,{get:function(){return ze},set:function(be){var Ge=t(be);if(!Ge)throw new SyntaxError("An invalid or illegal string was specified.");ze=Ge,this.hasBeenReset=!0}})),l.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}();var tr=function(){function d(){}return d.prototype.decode=function(o,e){if(!o)return"";if(typeof o!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(o))},d}();function _t(d){function o(t,i,n,a){return 3600*(0|t)+60*(0|i)+(0|n)+parseFloat(a||0)}var e=d.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?o(e[2],e[3],0,e[4]):o(e[1],e[2],e[3],e[4]):null}var et=function(){function d(){this.values=Object.create(null)}var o=d.prototype;return o.set=function(e,t){this.get(e)||t===""||(this.values[e]=t)},o.get=function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},o.has=function(e){return e in this.values},o.alt=function(e,t,i){for(var n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}},o.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},o.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},d}();function dt(d,o,e,t){var i=t?d.split(t):[d];for(var n in i)if(typeof i[n]=="string"){var a=i[n].split(e);a.length===2&&o(a[0],a[1])}}var $e=new Xt(0,0,""),lt=$e.align==="middle"?"middle":"center";function Gt(d,o,e){var t=d;function i(){var a=_t(d);if(a===null)throw new Error("Malformed timestamp: "+t);return d=d.replace(/^[^\sa-zA-Z-]+/,""),a}function n(){d=d.replace(/^\s+/,"")}if(n(),o.startTime=i(),n(),d.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+t);d=d.slice(3),n(),o.endTime=i(),n(),function(a,r){var s=new et;dt(a,function(c,v){var m;switch(c){case"region":for(var _=e.length-1;_>=0;_--)if(e[_].id===v){s.set(c,e[_].region);break}break;case"vertical":s.alt(c,v,["rl","lr"]);break;case"line":m=v.split(","),s.integer(c,m[0]),s.percent(c,m[0])&&s.set("snapToLines",!1),s.alt(c,m[0],["auto"]),m.length===2&&s.alt("lineAlign",m[1],["start",lt,"end"]);break;case"position":m=v.split(","),s.percent(c,m[0]),m.length===2&&s.alt("positionAlign",m[1],["start",lt,"end","line-left","line-right","auto"]);break;case"size":s.percent(c,v);break;case"align":s.alt(c,v,["start",lt,"end","left","right"])}},/:/,/\s/),r.region=s.get("region",null),r.vertical=s.get("vertical","");var l=s.get("line","auto");l==="auto"&&$e.line===-1&&(l=-1),r.line=l,r.lineAlign=s.get("lineAlign","start"),r.snapToLines=s.get("snapToLines",!0),r.size=s.get("size",100),r.align=s.get("align",lt);var u=s.get("position","auto");u==="auto"&&$e.position===50&&(u=r.align==="start"||r.align==="left"?0:r.align==="end"||r.align==="right"?100:50),r.position=u}(d,o)}function qt(d){return d.replace(/<br(?: \/)?>/gi,`
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
"use strict";(()=>{var Pl=Object.create;var Hs=Object.defineProperty;var Ol=Object.getOwnPropertyDescriptor;var Ml=Object.getOwnPropertyNames;var Fl=Object.getPrototypeOf,Nl=Object.prototype.hasOwnProperty;var Ks=(I,M)=>()=>(M||I((M={exports:{}}).exports,M),M.exports);var Ul=(I,M,D,B)=>{if(M&&typeof M=="object"||typeof M=="function")for(let K of Ml(M))!Nl.call(I,K)&&K!==D&&Hs(I,K,{get:()=>M[K],enumerable:!(B=Ol(M,K))||B.enumerable});return I};var qs=(I,M,D)=>(D=I!=null?Pl(Fl(I)):{},Ul(M||!I||!I.__esModule?Hs(D,"default",{value:I,enumerable:!0}):D,I));var xa=(I,M,D)=>{if(!M.has(I))throw TypeError("Cannot "+D)};var pt=(I,M,D)=>(xa(I,M,"read from private field"),D?D.call(I):M.get(I)),Gt=(I,M,D)=>{if(M.has(I))throw TypeError("Cannot add the same private member more than once");M instanceof WeakSet?M.add(I):M.set(I,D)},Ht=(I,M,D,B)=>(xa(I,M,"write to private field"),B?B.call(I,D):M.set(I,D),D);var br=(I,M,D)=>(xa(I,M,"access private method"),D);var Ys=Ks((Mn,Fa)=>{(function(){var I,M;I=this,M=function(){return function(){var D={80:function(H,J,j){H.exports=j(728).default},728:function(H,J,j){"use strict";j.d(J,{default:function(){return Wr}});var se=j(48),z=j.n(se),fe=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(m){var f=16*Math.random()|0;return(m==="x"?f:3&f|8).toString(16)})},be=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},ve=function(m){return m&&m.nodeName!==void 0?(m.muxId||(m.muxId=m.id||be()),m.muxId):m},Se=function(m){var f;m&&m.nodeName!==void 0?m=ve(f=m):f=document.querySelector(m);var g=f&&f.nodeName?f.nodeName.toLowerCase():"";return[f,m,g]},we=j(640),Oe=j.n(we),ot=Oe().methodFactory;Oe().methodFactory=function(m,f,g){var b=ot(m,f,g);return function(){for(var S=["[mux]"],R=0;R<arguments.length;R++)S.push(arguments[R]);b.apply(void 0,S)}},Oe().setLevel(Oe().getLevel());var Le=Oe();function lt(){return(z().doNotTrack||z().navigator&&z().navigator.doNotTrack)==="1"}var Me={now:function(){var m=z().performance,f=m&&m.timing,g=f&&f.navigationStart,b=typeof g=="number"&&typeof m.now=="function"?g+m.now():Date.now();return Math.round(b)}},E=function(m){return te(m)[0]},te=function(m){if(typeof m!="string"||m==="")return["localhost"];var f,g=(m.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return g&&(f=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,f]},U={exists:function(){var m=z().performance;return(m&&m.timing)!==void 0},domContentLoadedEventEnd:function(){var m=z().performance,f=m&&m.timing;return f&&f.domContentLoadedEventEnd},navigationStart:function(){var m=z().performance,f=m&&m.timing;return f&&f.navigationStart}};function Q(m,f,g){g=g===void 0?1:g,m[f]=m[f]||0,m[f]+=g}var qe=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],At=["x-cdn","content-type"].concat(qe);function ke(m){var f={};return(m=m||"").trim().split(/[\r\n]+/).forEach(function(g){if(g){var b=g.split(": "),S=b.shift();S&&(At.indexOf(S.toLowerCase())>=0||S.toLowerCase().indexOf("x-litix-")===0)&&(f[S]=b.join(": "))}}),f}function We(m){if(m){var f=qe.find(function(g){return m[g]!==void 0});return f?m[f]:void 0}}var $e=function(m){var f={};for(var g in m){var b=m[g];b["DATA-ID"].search("io.litix.data.")!==-1&&(f[b["DATA-ID"].replace("io.litix.data.","")]=b.VALUE)}return f};function P(m,f){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(m);f&&(b=b.filter(function(S){return Object.getOwnPropertyDescriptor(m,S).enumerable})),g.push.apply(g,b)}return g}function He(m){for(var f=1;f<arguments.length;f++){var g=arguments[f]!=null?arguments[f]:{};f%2?P(Object(g),!0).forEach(function(b){ut(m,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):P(Object(g)).forEach(function(b){Object.defineProperty(m,b,Object.getOwnPropertyDescriptor(g,b))})}return m}function ut(m,f,g){return f in m?Object.defineProperty(m,f,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[f]=g,m}var Ge=function(m){if(!m)return{};var f=U.navigationStart(),g=m.loading,b=g?g.start:m.trequest,S=g?g.first:m.tfirst,R=g?g.end:m.tload;return{bytesLoaded:m.total,requestStart:Math.round(f+b),responseStart:Math.round(f+S),responseEnd:Math.round(f+R)}},Kt=function(m){if(m&&typeof m.getAllResponseHeaders=="function")return ke(m.getAllResponseHeaders())};function cr(m,f){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(m);f&&(b=b.filter(function(S){return Object.getOwnPropertyDescriptor(m,S).enumerable})),g.push.apply(g,b)}return g}function Pt(m){for(var f=1;f<arguments.length;f++){var g=arguments[f]!=null?arguments[f]:{};f%2?cr(Object(g),!0).forEach(function(b){_e(m,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):cr(Object(g)).forEach(function(b){Object.defineProperty(m,b,Object.getOwnPropertyDescriptor(g,b))})}return m}function _e(m,f,g){return f in m?Object.defineProperty(m,f,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[f]=g,m}var ze=function(m,f){if(!m||typeof m.getRequests!="function")return{};var g=m.getRequests({state:"executed"});if(g.length===0)return{};var b,S=g[g.length-1],R=E(S.url),k=S.url,C=S.bytesLoaded,N=new Date(S.requestStartDate).getTime(),O=new Date(S.firstByteDate).getTime(),Y=new Date(S.requestEndDate).getTime(),ge=isNaN(S.duration)?0:S.duration,re=typeof f.getMetricsFor=="function"?f.getMetricsFor(S.mediaType).HttpList:f.getDashMetrics().getHttpRequests(S.mediaType);return re.length>0&&(b=ke(re[re.length-1]._responseHeaders||"")),{requestStart:N,requestResponseStart:O,requestResponseEnd:Y,requestBytesLoaded:C,requestResponseHeaders:b,requestMediaDuration:ge,requestHostname:R,requestUrl:k,requestId:b?We(b):void 0}},qt=function(m,f){var g=f.getQualityFor(m),b=f.getCurrentTrackFor(m).bitrateList;return b?{currentLevel:g,renditionWidth:b[g].width||null,renditionHeight:b[g].height||null,renditionBitrate:b[g].bandwidth}:{}},Rr=function(m){var f;return(f=m.match(/.*codecs\*?="(.*)"/))===null||f===void 0?void 0:f[1]};function Lr(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}var ji=0,Gn=function(){function m(){(function(S,R){if(!(S instanceof R))throw new TypeError("Cannot call a class as a function")})(this,m)}var f,g,b;return f=m,g=[{key:"on",value:function(S,R,k){return R._eventEmitterGuid=R._eventEmitterGuid||++ji,this._listeners=this._listeners||{},this._listeners[S]=this._listeners[S]||[],k&&(R=R.bind(k)),this._listeners[S].push(R),R}},{key:"off",value:function(S,R){var k=this._listeners&&this._listeners[S];k&&k.forEach(function(C,N){C._eventEmitterGuid===R._eventEmitterGuid&&k.splice(N,1)})}},{key:"one",value:function(S,R,k){var C=this;R._eventEmitterGuid=R._eventEmitterGuid||++ji;var N=function O(){C.off(S,O),R.apply(k||this,arguments)};N._eventEmitterGuid=R._eventEmitterGuid,this.on(S,N)}},{key:"emit",value:function(S,R){var k=this;if(this._listeners){R=R||{};var C=this._listeners["before*"]||[],N=this._listeners[S]||[],O=this._listeners["after"+S]||[],Y=function(ge,re){(ge=ge.slice()).forEach(function(ce){ce.call(k,{type:S},re)})};Y(C,R),Y(N,R),Y(O,R)}}}],g&&Lr(f.prototype,g),b&&Lr(f,b),Object.defineProperty(f,"prototype",{writable:!1}),m}(),ai=Gn;function Vi(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}var Yi=function(){function m(S){var R=this;(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=S,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,S.on("playing",function(){R._playheadShouldBeProgressing=!0}),S.on("play",this._startPlaybackHeartbeatInterval.bind(this)),S.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),S.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),S.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),S.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),S.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),S.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),S.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),S.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),S.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),S.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),S.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),S.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),S.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),S.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),S.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),S.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),S.on("seeked",function(){S.data.player_is_paused?R._stopPlaybackHeartbeatInterval():R._startPlaybackHeartbeatInterval()}),S.on("timeupdate",function(){R._playbackHeartbeatInterval!==null&&S.emit("playbackheartbeat")}),S.on("devicesleep",function(k,C){R._playbackHeartbeatInterval!==null&&(z().clearInterval(R._playbackHeartbeatInterval),S.emit("playbackheartbeatend",{viewer_time:C.viewer_time}),R._playbackHeartbeatInterval=null)})}var f,g,b;return f=m,(g=[{key:"_startPlaybackHeartbeatInterval",value:function(){var S=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=z().setInterval(function(){S.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(z().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Vi(f.prototype,g),b&&Vi(f,b),Object.defineProperty(f,"prototype",{writable:!1}),m}();function je(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}function si(m,f,g){return f&&je(m.prototype,f),g&&je(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var oi=si(function m(f){var g=this;(function(b,S){if(!(b instanceof S))throw new TypeError("Cannot call a class as a function")})(this,m),f.on("viewinit",function(){g.viewErrored=!1}),f.on("error",function(b,S){try{var R=f.errorTranslator({player_error_code:S.player_error_code,player_error_message:S.player_error_message,player_error_context:S.player_error_context});R?(f.data.player_error_code=R.player_error_code||S.player_error_code,f.data.player_error_message=R.player_error_message||S.player_error_message,f.data.player_error_context=R.player_error_context||S.player_error_context,g.viewErrored=!0):(delete f.data.player_error_code,delete f.data.player_error_message,delete f.data.player_error_context)}catch(k){f.mux.log.warn("Exception in error translator callback.",k),g.viewErrored=!0}})});function hr(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}var wr=function(){function m(S){(function(R,k){if(!(R instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=S,this._watchTimeTrackerLastCheckedTime=null,S.on("playbackheartbeat",this._updateWatchTime.bind(this)),S.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var f,g,b;return f=m,(g=[{key:"_updateWatchTime",value:function(S,R){var k=R.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=k),Q(this.pm.data,"view_watch_time",k-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=k}},{key:"_clearWatchTimeState",value:function(S,R){this._updateWatchTime(S,R),this._watchTimeTrackerLastCheckedTime=null}}])&&hr(f.prototype,g),b&&hr(f,b),Object.defineProperty(f,"prototype",{writable:!1}),m}();function li(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}var Wi=function(){function m(S){(function(R,k){if(!(R instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=S,this._playbackTimeTrackerLastPlayheadPosition=-1,S.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),S.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),S.on("seeking",this._clearPlaybackTimeState.bind(this))}var f,g,b;return f=m,(g=[{key:"_updatePlaybackTime",value:function(){var S=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&S>this._playbackTimeTrackerLastPlayheadPosition){var R=S-this._playbackTimeTrackerLastPlayheadPosition;R<=1e3&&Q(this.pm.data,"view_content_playback_time",R)}this._playbackTimeTrackerLastPlayheadPosition=S}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&li(f.prototype,g),b&&li(f,b),Object.defineProperty(f,"prototype",{writable:!1}),m}();function ui(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}var di=function(){function m(S){(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=S;var R=this._updatePlayheadTime.bind(this);S.on("playbackheartbeat",R),S.on("playbackheartbeatend",R),S.on("timeupdate",R),S.on("destroy",function(){S.off("timeupdate",R)})}var f,g,b;return f=m,(g=[{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(S,R){var k=this,C=function(){k.pm.currentFragmentPDT&&k.pm.currentFragmentStart&&(k.pm.data.player_program_time=k.pm.currentFragmentPDT+k.pm.data.player_playhead_time-k.pm.currentFragmentStart)};if(R&&R.player_playhead_time)this.pm.data.player_playhead_time=R.player_playhead_time,C(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var N=this.pm.getPlayheadTime();N!==void 0&&(this.pm.data.player_playhead_time=N,C(),this._updateMaxPlayheadPosition())}}}])&&ui(f.prototype,g),b&&ui(f,b),Object.defineProperty(f,"prototype",{writable:!1}),m}();function ci(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}function $t(m,f,g){return f&&ci(m.prototype,f),g&&ci(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Dr=3e5,hi=$t(function m(f){if(function(R,k){if(!(R instanceof k))throw new TypeError("Cannot call a class as a function")}(this,m),!f.disableRebufferTracking){var g,b=function(R,k){S(k),g=void 0},S=function(R){if(g){var k=R.viewer_time-g;Q(f.data,"view_rebuffer_duration",k),g=R.viewer_time,f.data.view_rebuffer_duration>Dr&&(f.emit("viewend"),f.send("viewend"),f.mux.log.warn("Ending view after rebuffering for longer than ".concat(Dr,"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(R,k){return S(k)}),f.on("rebufferstart",function(R,k){g||(Q(f.data,"view_rebuffer_count",1),g=k.viewer_time,f.one("rebufferend",b))}),f.on("viewinit",function(){g=void 0,f.off("rebufferend",b)})}});function fi(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}var Ir=function(){function m(S){var R=this;(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=S,S.disableRebufferTracking||S.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,S.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),S.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),S.on("seeking",function(){R._cleanupRebufferTracker(null,{viewer_time:Me.now()})}))}var f,g,b;return f=m,g=[{key:"_checkIfRebuffering",value:function(S,R){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(S,R);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var k=R.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&k>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=R.viewer_time}else this._cleanupRebufferTracker(S,R,!0);else this._prepareRebufferTrackerState(R.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(S){this._lastCheckedTime=S,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=S}},{key:"_cleanupRebufferTracker",value:function(S,R){var k=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:R.viewer_time});else{if(this._lastCheckedTime===null)return;var C=this.pm.data.player_playhead_time-this._lastPlayheadTime,N=R.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&C>0&&N-C>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+N-C}))}k?this._prepareRebufferTrackerState(R.viewer_time):this._clearRebufferTrackerState()}}],g&&fi(f.prototype,g),b&&fi(f,b),Object.defineProperty(f,"prototype",{writable:!1}),m}(),Cr=Ir;function zi(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}var Xi=function(){function m(S){var R=this;(function(k,C){if(!(k instanceof C))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=S,S.on("viewinit",function(){var k=S.data,C=k.view_id;if(!k.view_program_changed){var N=function(O,Y){var ge=Y.viewer_time;O.type==="playing"&&S.data.view_time_to_first_frame===void 0?R.calculateTimeToFirstFrame(ge||Me.now(),C):O.type!=="adplaying"||S.data.view_time_to_first_frame!==void 0&&!R._inPrerollPosition()||R.calculateTimeToFirstFrame(ge||Me.now(),C)};S.one("playing",N),S.one("adplaying",N),S.one("viewend",function(){S.off("playing",N),S.off("adplaying",N)})}})}var f,g,b;return f=m,(g=[{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(S,R){R===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:S}),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))}}])&&zi(f.prototype,g),b&&zi(f,b),Object.defineProperty(f,"prototype",{writable:!1}),m}();function Qi(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}function Ji(m,f,g){return f&&Qi(m.prototype,f),g&&Qi(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Hn=Ji(function m(f){var g=this;(function(b,S){if(!(b instanceof S))throw new TypeError("Cannot call a class as a function")})(this,m),f.on("viewinit",function(){g._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(b){f.on(b,function(){if(g._lastPlayheadPosition>=0&&f.data.player_playhead_time>=0&&g._lastPlayerWidth>=0&&g._lastSourceWidth>0&&g._lastPlayerHeight>=0&&g._lastSourceHeight>0){var S=f.data.player_playhead_time-g._lastPlayheadPosition;if(S<0)return void(g._lastPlayheadPosition=-1);var R=Math.min(g._lastPlayerWidth/g._lastSourceWidth,g._lastPlayerHeight/g._lastSourceHeight),k=Math.max(0,R-1),C=Math.max(0,1-R);f.data.view_max_upscale_percentage=Math.max(f.data.view_max_upscale_percentage||0,k),f.data.view_max_downscale_percentage=Math.max(f.data.view_max_downscale_percentage||0,C),Q(f.data,"view_total_content_playback_time",S),Q(f.data,"view_total_upscaling",k*S),Q(f.data,"view_total_downscaling",C*S)}g._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(b){f.on(b,function(){g._lastPlayheadPosition=f.data.player_playhead_time,g._lastPlayerWidth=f.data.player_width,g._lastPlayerHeight=f.data.player_height,g._lastSourceWidth=f.data.video_source_width,g._lastSourceHeight=f.data.video_source_height})})});function $i(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}function Kn(m,f,g){return f&&$i(m.prototype,f),g&&$i(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var qn=Kn(function m(f){var g=this;(function(b,S){if(!(b instanceof S))throw new TypeError("Cannot call a class as a function")})(this,m),this.isSeeking=!1,f.on("seeking",function(b,S){Object.assign(f.data,S),g._lastSeekingTime=Me.now(),g.isSeeking===!1&&(g.isSeeking=!0,f.send("seeking"))}),f.on("seeked",function(){g.isSeeking=!1;var b=g._lastSeekingTime||Me.now(),S=Me.now()-b;Q(f.data,"view_seek_count",1),Q(f.data,"view_seek_duration",S);var R=f.data.view_max_seek_time||0;f.data.view_max_seek_time=Math.max(R,S)}),f.on("viewend",function(){g.isSeeking=!1})});function Zi(m,f){return function(g){if(Array.isArray(g))return g}(m)||function(g,b){var S=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(S!=null){var R,k,C=[],N=!0,O=!1;try{for(S=S.call(g);!(N=(R=S.next()).done)&&(C.push(R.value),!b||C.length!==b);N=!0);}catch(Y){O=!0,k=Y}finally{try{N||S.return==null||S.return()}finally{if(O)throw k}}return C}}(m,f)||function(g,b){if(g){if(typeof g=="string")return Tt(g,b);var S=Object.prototype.toString.call(g).slice(8,-1);return S==="Object"&&g.constructor&&(S=g.constructor.name),S==="Map"||S==="Set"?Array.from(g):S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S)?Tt(g,b):void 0}}(m,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 Tt(m,f){(f==null||f>m.length)&&(f=m.length);for(var g=0,b=new Array(f);g<f;g++)b[g]=m[g];return b}function en(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}var Et=function(m,f){m.push(f),m.sort(function(g,b){return g.viewer_time-b.viewer_time})},xr=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],jn=function(){function m(S){var R=this;(function(C,N){if(!(C instanceof N))throw new TypeError("Cannot call a class as a function")})(this,m),this.pm=S,S.on("viewinit",function(){R.isAdBreak=!1,R._currentAdRequestNumber=0,R._currentAdResponseNumber=0,R._adRequests=[],R._adResponses=[],R._adHasPlayed=!1,R._wouldBeNewAdPlay=!0,R._prerollPlayTime=void 0}),xr.forEach(function(C){return S.on(C,R._updateAdData.bind(R))});var k=function(){R.isAdBreak=!1};S.on("adbreakstart",function(){R.isAdBreak=!0}),S.on("play",k),S.on("playing",k),S.on("viewend",k),S.on("adrequest",function(C,N){N=Object.assign({ad_request_id:"generatedAdRequestId"+R._currentAdRequestNumber++},N),Et(R._adRequests,N),Q(S.data,"view_ad_request_count"),R.inPrerollPosition()&&(S.data.view_preroll_requested=!0,R._adHasPlayed||Q(S.data,"view_preroll_request_count"))}),S.on("adresponse",function(C,N){N=Object.assign({ad_request_id:"generatedAdRequestId"+R._currentAdResponseNumber++},N),Et(R._adResponses,N);var O=R.findAdRequest(N.ad_request_id);O&&Q(S.data,"view_ad_request_time",Math.max(0,N.viewer_time-O.viewer_time))}),S.on("adplay",function(C,N){R._adHasPlayed=!0,R._wouldBeNewAdPlay&&(R._wouldBeNewAdPlay=!1,Q(S.data,"view_ad_played_count")),R.inPrerollPosition()&&!S.data.view_preroll_played&&(S.data.view_preroll_played=!0,R._adRequests.length>0&&(S.data.view_preroll_request_time=Math.max(0,N.viewer_time-R._adRequests[0].viewer_time)),S.data.view_start&&(S.data.view_startup_preroll_request_time=Math.max(0,N.viewer_time-S.data.view_start)),R._prerollPlayTime=N.viewer_time)}),S.on("adplaying",function(C,N){R.inPrerollPosition()&&S.data.view_preroll_load_time===void 0&&R._prerollPlayTime!==void 0&&(S.data.view_preroll_load_time=N.viewer_time-R._prerollPlayTime,S.data.view_startup_preroll_load_time=N.viewer_time-R._prerollPlayTime)}),S.on("adended",function(){R._wouldBeNewAdPlay=!0}),S.on("aderror",function(){R._wouldBeNewAdPlay=!0})}var f,g,b;return f=m,(g=[{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(S){for(var R=0;R<this._adRequests.length;R++)if(this._adRequests[R].ad_request_id===S)return this._adRequests[R]}},{key:"_updateAdData",value:function(S,R){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&R.ad_tag_url){var k=Zi(te(R.ad_tag_url),2),C=k[0],N=k[1];this.pm.data.view_preroll_ad_tag_domain=N,this.pm.data.view_preroll_ad_tag_hostname=C}if(!this.pm.data.view_preroll_ad_asset_hostname&&R.ad_asset_url){var O=Zi(te(R.ad_asset_url),2),Y=O[0],ge=O[1];this.pm.data.view_preroll_ad_asset_domain=ge,this.pm.data.view_preroll_ad_asset_hostname=Y}}this.pm.data.ad_asset_url=R==null?void 0:R.ad_asset_url,this.pm.data.ad_tag_url=R==null?void 0:R.ad_tag_url,this.pm.data.ad_creative_id=R==null?void 0:R.ad_creative_id,this.pm.data.ad_id=R==null?void 0:R.ad_id,this.pm.data.ad_universal_id=R==null?void 0:R.ad_universal_id}}])&&en(f.prototype,g),b&&en(f,b),Object.defineProperty(f,"prototype",{writable:!1}),m}();function vi(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}function et(m,f,g){return f&&vi(m.prototype,f),g&&vi(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var tn=et(function m(f){var g,b;(function(C,N){if(!(C instanceof N))throw new TypeError("Cannot call a class as a function")})(this,m);var S=function(){f.disableRebufferTracking||g&&(Q(f.data,"view_waiting_rebuffer_duration",Me.now()-g),g=!1,z().clearInterval(b))},R=!1,k=function(){R=!1,S()};f.on("waiting",function(){R&&(f.disableRebufferTracking||(Q(f.data,"view_waiting_rebuffer_count",1),g=Me.now(),b=z().setInterval(function(){if(g){var C=Me.now();Q(f.data,"view_waiting_rebuffer_duration",C-g),g=C}},250)))}),f.on("playing",function(){S(),R=!0}),f.on("pause",k),f.on("seeking",k)});function Te(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}function rn(m,f,g){return f&&Te(m.prototype,f),g&&Te(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var gi=rn(function m(f){var g=this;(function(R,k){if(!(R instanceof k))throw new TypeError("Cannot call a class as a function")})(this,m);var b=function(){g.lastWallClockTime=Me.now(),f.on("before*",S)},S=function(R){var k=Me.now(),C=g.lastWallClockTime;g.lastWallClockTime=k,k-C>3e4&&(f.emit("devicesleep",{viewer_time:C}),Object.assign(f.data,{viewer_time:C}),f.send("devicesleep"),f.emit("devicewake",{viewer_time:k}),Object.assign(f.data,{viewer_time:k}),f.send("devicewake"))};f.one("playbackheartbeat",b),f.on("playbackheartbeatend",function(){f.off("before*",S),f.one("playbackheartbeat",b)})}),Ce=j(375),Vn=j(655),mi=j.n(Vn),pi="muxData",nn=function(){var m;try{m=Ce.parse(mi().get(pi)||"")}catch{m={}}return m},jt=function(m){try{mi().set(pi,Ce.stringify(m),{expires:7300})}catch{}},an=function(){var m=nn();return m.mux_viewer_id=m.mux_viewer_id||fe(),m.msn=m.msn||Math.random(),jt(m),{mux_viewer_id:m.mux_viewer_id,mux_sample_number:m.msn}};function Yn(m,f){var g=f.beaconCollectionDomain,b=f.beaconDomain;if(g)return"https://"+g;var S=b||"litix.io";return(m=m||"inferred").match(/^[a-z0-9]+$/)?"https://"+m+"."+S:"https://img.litix.io/a.gif"}var yi=function(){var m;switch(Ti()){case"cellular":m="cellular";break;case"ethernet":m="wired";break;case"wifi":m="wifi";break;case void 0:break;default:m="other"}return m},Ti=function(){var m=z().navigator,f=m&&(m.connection||m.mozConnection||m.webkitConnection);return f&&f.type};yi.getConnectionFromAPI=Ti;var Wn=yi,Pr=Ei({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"}),Or=Ei({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 Ei(m){var f={};for(var g in m)m.hasOwnProperty(g)&&(f[m[g]]=g);return f}function Mr(m){var f={},g={};return Object.keys(m).forEach(function(b){var S=!1;if(m.hasOwnProperty(b)&&m[b]!==void 0){var R=b.split("_"),k=R[0],C=Pr[k];C||(Le.info("Data key word `"+R[0]+"` not expected in "+b),C=k+"_"),R.splice(1).forEach(function(N){N==="url"&&(S=!0),Or[N]?C+=Or[N]:Number(N)&&Math.floor(Number(N))===Number(N)?C+=N:(Le.info("Data key word `"+N+"` not expected in "+b),C+="_"+N+"_")}),S?g[C]=m[b]:f[C]=m[b]}}),Object.assign(f,g)}var dt={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},_i=["hb","requestcompleted","requestfailed","requestcanceled"],sn="https://img.litix.io",Ot=function(m){var f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=m||sn,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},dt,f)};Ot.prototype.queueEvent=function(m,f){var g=Object.assign({},f);return(this._eventQueue.length<=this._options.maxQueueLength||m==="eventrateexceeded")&&(this._eventQueue.push(g),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},Ot.prototype.flushEvents=function(){var m=arguments.length>0&&arguments[0]!==void 0&&arguments[0];m&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},Ot.prototype.destroy=function(){var m=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,m?this._clearBeaconQueue():this.flushEvents(),z().clearTimeout(this._sendTimeout)},Ot.prototype._clearBeaconQueue=function(){var m=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,f=this._eventQueue.slice(m);m>0&&Object.assign(f[f.length-1],Mr({mux_view_message:"event queue truncated"}));var g=this._createPayload(f);Fr(this._beaconUrl,g,!0,function(){})},Ot.prototype._sendBeaconQueue=function(){var m=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 g=this._createPayload(f),b=Me.now();Fr(this._beaconUrl,g,!1,function(S,R){R?(m._eventQueue=f.concat(m._eventQueue),m._failureCount+=1,Le.info("Error sending beacon: "+R)):m._failureCount=0,m._roundTripTime=Me.now()-b,m._postInFlight=!1})}},Ot.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var m=Math.pow(2,this._failureCount-1);return(1+(m*=Math.random()))*this._options.baseTimeBetweenBeacons},Ot.prototype._startBeaconSending=function(){var m=this;z().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=z().setTimeout(function(){m._eventQueue.length&&m._sendBeaconQueue(),m._startBeaconSending()},this._getNextBeaconTime()))},Ot.prototype._createPayload=function(m){var f,g,b,S=this,R={transmission_timestamp:Math.round(Me.now())};this._roundTripTime&&(R.rtt_ms=Math.round(this._roundTripTime));var k=function(){f=JSON.stringify({metadata:R,events:g||m}),b=f.length/1024},C=function(){return b<=S._options.maxPayloadKBSize};return k(),C()||(Le.info("Payload size is too big ("+b+" kb). Removing unnecessary events."),g=m.filter(function(N){return _i.indexOf(N.e)===-1}),k()),C()||(Le.info("Payload size still too big ("+b+" kb). Cropping fields.."),g.forEach(function(N){for(var O in N){var Y=N[O];typeof Y=="string"&&Y.length>51200&&(N[O]=Y.substring(0,51200))}}),k()),f};var zn=function(m){return m.length<=57344},Fr=function(m,f,g,b){if(g&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(m,f))b();else if(z().fetch)z().fetch(m,{method:"POST",body:f,headers:{"Content-Type":"text/plain"},keepalive:zn(f)}).then(function(R){return b(null,R.ok?null:"Error")}).catch(function(R){return b(null,R)});else{if(z().XMLHttpRequest){var S=new(z()).XMLHttpRequest;return S.onreadystatechange=function(){if(S.readyState===4)return b(null,S.status!==200?"error":void 0)},S.open("POST",m),S.setRequestHeader("Content-Type","text/plain"),void S.send(f)}b()}},on=Ot;function ln(m,f){return function(g){if(Array.isArray(g))return g}(m)||function(g,b){var S=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(S!=null){var R,k,C=[],N=!0,O=!1;try{for(S=S.call(g);!(N=(R=S.next()).done)&&(C.push(R.value),!b||C.length!==b);N=!0);}catch(Y){O=!0,k=Y}finally{try{N||S.return==null||S.return()}finally{if(O)throw k}}return C}}(m,f)||function(g,b){if(g){if(typeof g=="string")return un(g,b);var S=Object.prototype.toString.call(g).slice(8,-1);return S==="Object"&&g.constructor&&(S=g.constructor.name),S==="Map"||S==="Set"?Array.from(g):S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S)?un(g,b):void 0}}(m,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 un(m,f){(f==null||f>m.length)&&(f=m.length);for(var g=0,b=new Array(f);g<f;g++)b[g]=m[g];return b}function bi(m,f){var g=Object.keys(m);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(m);f&&(b=b.filter(function(S){return Object.getOwnPropertyDescriptor(m,S).enumerable})),g.push.apply(g,b)}return g}function ar(m){for(var f=1;f<arguments.length;f++){var g=arguments[f]!=null?arguments[f]:{};f%2?bi(Object(g),!0).forEach(function(b){Nr(m,b,g[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(g)):bi(Object(g)).forEach(function(b){Object.defineProperty(m,b,Object.getOwnPropertyDescriptor(g,b))})}return m}function Mt(m){return Mt=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},Mt(m)}function dn(m,f){if(!(m instanceof f))throw new TypeError("Cannot call a class as a function")}function Si(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}function Nr(m,f,g){return f in m?Object.defineProperty(m,f,{value:g,enumerable:!0,configurable:!0,writable:!0}):m[f]=g,m}var cn=["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"],hn=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse"],fn=["viewstart","error","ended","viewend"],vn=function(){function m(S,R){var k,C,N,O,Y,ge,re,ce,ne,he,xe,Ke,tt,ct,vt,le=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};dn(this,m),Nr(this,"previousBeaconData",null),Nr(this,"lastEventTime",0),Nr(this,"rateLimited",!1),this.mux=S,this.envKey=R,this.options=le,this.eventQueue=new on(Yn(this.envKey,this.options)),this.sampleRate=(k=this.options.sampleRate)!==null&&k!==void 0?k:1,this.disableCookies=(C=this.options.disableCookies)!==null&&C!==void 0&&C,this.respectDoNotTrack=(N=this.options.respectDoNotTrack)!==null&&N!==void 0&&N,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:(O=this.options.platform)===null||O===void 0?void 0:O.name,viewer_application_version:(Y=this.options.platform)===null||Y===void 0?void 0:Y.version,viewer_application_engine:(ge=this.options.platform)===null||ge===void 0?void 0:ge.layout,viewer_device_name:(re=this.options.platform)===null||re===void 0?void 0:re.product,viewer_device_category:"",viewer_device_manufacturer:(ce=this.options.platform)===null||ce===void 0?void 0:ce.manufacturer,viewer_os_family:(ne=this.options.platform)===null||ne===void 0||(he=ne.os)===null||he===void 0?void 0:he.family,viewer_os_architecture:(xe=this.options.platform)===null||xe===void 0||(Ke=xe.os)===null||Ke===void 0?void 0:Ke.architecture,viewer_os_version:(tt=this.options.platform)===null||tt===void 0||(ct=tt.os)===null||ct===void 0?void 0:ct.version,viewer_connection_type:Wn(),page_url:z()===null||z()===void 0||(vt=z().location)===null||vt===void 0?void 0:vt.href},this.viewerData=this.disableCookies?{}:an()}var f,g,b;return f=m,(g=[{key:"send",value:function(S,R){var k;if(S&&R!=null&&R.view_id){if(this.respectDoNotTrack&<())return Le.info("Not sending `"+S+"` because Do Not Track is enabled");if(!R||Mt(R)!=="object")return Le.error("A data object was expected in send() but was not provided");var C,N,O=this.disableCookies?{}:(C=nn(),N=Me.now(),C.session_start&&(C.sst=C.session_start,delete C.session_start),C.session_id&&(C.sid=C.session_id,delete C.session_id),C.session_expires&&(C.sex=C.session_expires,delete C.session_expires),(!C.sex||C.sex<N)&&(C.sid=fe(),C.sst=N),C.sex=N+15e5,jt(C),{session_id:C.sid,session_start:C.sst,session_expires:C.sex}),Y=ar(ar(ar(ar(ar({},this.pageLevelData),R),O),this.viewerData),{},{event:S,env_key:this.envKey});Y.user_id&&(Y.viewer_user_id=Y.user_id,delete Y.user_id);var ge=((k=Y.mux_sample_number)!==null&&k!==void 0?k:0)>=this.sampleRate,re=Mr(this._deduplicateBeaconData(S,Y));if(this.lastEventTime=this.mux.utils.now(),ge)return Le.info("Not sending event due to sample rate restriction",S,Y,re);if(this.envKey||Le.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",S,Y,re),!this.rateLimited){if(Le.info("Sending event",S,Y,re),this.rateLimited=!this.eventQueue.queueEvent(S,re),this.mux.WINDOW_UNLOADING&&S==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&S==="hb"?this.eventQueue.flushEvents(!0):fn.indexOf(S)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return Y.event="eventrateexceeded",re=Mr(Y),this.eventQueue.queueEvent(Y.event,re),Le.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(S,R){var k=this,C={},N=R.view_id;if(N==="-1"||S==="viewstart"||S==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)C=ar({},R),N&&(this.previousBeaconData=C),N&&S==="viewend"&&(this.previousBeaconData=null);else{var O=S.indexOf("request")===0;Object.entries(R).forEach(function(Y){var ge=ln(Y,2),re=ge[0],ce=ge[1];k.previousBeaconData&&(ce!==k.previousBeaconData[re]||cn.indexOf(re)>-1||k.objectHasChanged(O,re,ce,k.previousBeaconData[re])||k.eventRequiresKey(S,re))&&(C[re]=ce,k.previousBeaconData[re]=ce)})}return C}},{key:"objectHasChanged",value:function(S,R,k,C){return!(!S||R.indexOf("request_")!==0||R!=="request_response_headers"&&Mt(k)==="object"&&Mt(C)==="object"&&Object.keys(k||{}).length===Object.keys(C||{}).length)}},{key:"eventRequiresKey",value:function(S,R){return S==="renditionchange"&&R.indexOf("video_source_")===0||!(R.indexOf("ad_id")!==0||!hn.includes(S))}}])&&Si(f.prototype,g),b&&Si(f,b),Object.defineProperty(f,"prototype",{writable:!1}),m}();function Zt(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}function er(m,f,g){return f&&Zt(m.prototype,f),g&&Zt(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var kt=er(function m(f){(function(O,Y){if(!(O instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,m);var g=0,b=0,S=0,R=0,k=0,C=0,N=0;f.on("requestcompleted",function(O,Y){var ge,re,ce=Y.request_start,ne=Y.request_response_start,he=Y.request_response_end,xe=Y.request_bytes_loaded;if(R++,ne?(ge=ne-(ce!=null?ce:0),re=(he!=null?he:0)-ne):re=(he!=null?he:0)-(ce!=null?ce:0),re>0&&xe&&xe>0){var Ke=xe/re*8e3;k++,b+=xe,S+=re,f.data.view_min_request_throughput=Math.min(f.data.view_min_request_throughput||1/0,Ke),f.data.view_average_request_throughput=b/S*8e3,f.data.view_request_count=R,ge>0&&(g+=ge,f.data.view_max_request_latency=Math.max(f.data.view_max_request_latency||0,ge),f.data.view_average_request_latency=g/k)}}),f.on("requestfailed",function(O,Y){R++,C++,f.data.view_request_count=R,f.data.view_request_failed_count=C}),f.on("requestcanceled",function(O,Y){R++,N++,f.data.view_request_count=R,f.data.view_request_canceled_count=N})});function Rt(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}function Ne(m,f,g){return f&&Rt(m.prototype,f),g&&Rt(m,g),Object.defineProperty(m,"prototype",{writable:!1}),m}var Ft=Ne(function m(f){var g=this;(function(b,S){if(!(b instanceof S))throw new TypeError("Cannot call a class as a function")})(this,m),f.on("before*",function(b,S){var R=S.viewer_time,k=Me.now(),C=g._lastEventTime;if(g._lastEventTime=k,C&&k-C>36e5){var N=Object.keys(f.data).reduce(function(O,Y){return Y.indexOf("video_")===0?Object.assign(O,function(ge,re,ce){return re in ge?Object.defineProperty(ge,re,{value:ce,enumerable:!0,configurable:!0,writable:!0}):ge[re]=ce,ge}({},Y,f.data[Y])):O},{});f.mux.log.info("Received event after at least an hour inactivity, creating a new view"),f.emit("viewinit",Object.assign({viewer_time:R},N)),f.playbackHeartbeat._playheadShouldBeProgressing&&b.type!=="play"&&b.type!=="adbreakstart"&&(f.emit("play",{viewer_time:R}),b.type!=="playing"&&f.emit("playing",{viewer_time:R}))}})});function Nt(m){return Nt=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},Nt(m)}function gn(m,f){return function(g){if(Array.isArray(g))return g}(m)||function(g,b){var S=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(S!=null){var R,k,C=[],N=!0,O=!1;try{for(S=S.call(g);!(N=(R=S.next()).done)&&(C.push(R.value),!b||C.length!==b);N=!0);}catch(Y){O=!0,k=Y}finally{try{N||S.return==null||S.return()}finally{if(O)throw k}}return C}}(m,f)||function(g,b){if(g){if(typeof g=="string")return Ur(g,b);var S=Object.prototype.toString.call(g).slice(8,-1);return S==="Object"&&g.constructor&&(S=g.constructor.name),S==="Map"||S==="Set"?Array.from(g):S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S)?Ur(g,b):void 0}}(m,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 Ur(m,f){(f==null||f>m.length)&&(f=m.length);for(var g=0,b=new Array(f);g<f;g++)b[g]=m[g];return b}function mn(m,f){for(var g=0;g<f.length;g++){var b=f[g];b.enumerable=b.enumerable||!1,b.configurable=!0,"value"in b&&(b.writable=!0),Object.defineProperty(m,b.key,b)}}function Br(m,f){return Br=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,b){return g.__proto__=b,g},Br(m,f)}function pn(m){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 g,b=Vt(m);if(f){var S=Vt(this).constructor;g=Reflect.construct(b,arguments,S)}else g=b.apply(this,arguments);return sr(this,g)}}function sr(m,f){if(f&&(Nt(f)==="object"||typeof f=="function"))return f;if(f!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Xe(m)}function Xe(m){if(m===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return m}function Vt(m){return Vt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(f){return f.__proto__||Object.getPrototypeOf(f)},Vt(m)}var Xn=["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"],fr=function(m){(function(k,C){if(typeof C!="function"&&C!==null)throw new TypeError("Super expression must either be null or a function");k.prototype=Object.create(C&&C.prototype,{constructor:{value:k,writable:!0,configurable:!0}}),Object.defineProperty(k,"prototype",{writable:!1}),C&&Br(k,C)})(R,m);var f,g,b,S=pn(R);function R(k,C,N){var O;(function(ne,he){if(!(ne instanceof he))throw new TypeError("Cannot call a class as a function")})(this,R),(O=S.call(this)).DOM_CONTENT_LOADED_EVENT_END=U.domContentLoadedEventEnd(),O.NAVIGATION_START=U.navigationStart(),O.mux=k,O.id=C,(N=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(ne){return ne}},N)).data=N.data||{},N.data.property_key&&(N.data.env_key=N.data.property_key,delete N.data.property_key),Le.setLevel(N.debug?"debug":"warn"),O.getPlayheadTime=N.getPlayheadTime,O.getStateData=N.getStateData||function(){return{}},O.getAdData=N.getAdData||function(){},O.minimumRebufferDuration=N.minimumRebufferDuration,O.sustainedRebufferThreshold=N.sustainedRebufferThreshold,O.playbackHeartbeatTime=N.playbackHeartbeatTime,O.disableRebufferTracking=N.disableRebufferTracking,O.disableRebufferTracking&&O.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."),O.disablePlayheadRebufferTracking=N.disablePlayheadRebufferTracking,O.errorTranslator=N.errorTranslator,O.playbackEventDispatcher=new vn(k,N.data.env_key,N),O.data={player_instance_id:fe(),mux_sample_rate:N.sampleRate,beacon_domain:N.beaconCollectionDomain?N.beaconCollectionDomain:N.beaconDomain},O.data.view_sequence_number=1,O.data.player_sequence_number=1,O.oldEmit=O.emit,O.emit=function(ne,he){he=Object.assign({viewer_time:this.mux.utils.now()},he),this.oldEmit(ne,he)};var Y=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Xe(O));O.on("viewinit",function(ne,he){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,he),this._initializeViewData(),this.one("play",Y),this.one("adbreakstart",Y)});var ge=function(ne){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",ne)}.bind(Xe(O));if(O.on("videochange",function(ne,he){ge(he)}),O.on("programchange",function(ne,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."),ge(Object.assign(he,{view_program_changed:!0})),Y(),this.emit("play"),this.emit("playing")}),O.on("fragmentchange",function(ne,he){this.currentFragmentPDT=he.currentFragmentPDT,this.currentFragmentStart=he.currentFragmentStart}),O.on("destroy",O.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var re=function(){var ne=O.data.view_start!==void 0;O.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",ne&&O.mux.WINDOW_HIDDEN&&(O.data.player_is_paused||O.emit("hb"))};window.addEventListener("visibilitychange",re,!1);var ce=function(ne){ne.persisted||O.destroy()};window.addEventListener("pagehide",ce,!1),O.on("destroy",function(){window.removeEventListener("visibilitychange",re),window.removeEventListener("pagehide",ce)})}return O.on("playerready",function(ne,he){Object.assign(this.data,he)}),Xn.forEach(function(ne){O.on(ne,function(he,xe){ne.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,xe),this._sanitizeData()}),O.on("after"+ne,function(){(ne!=="error"||this.errorTracker.viewErrored)&&this.send(ne)})}),O.on("viewend",function(ne,he){Object.assign(O.data,he)}),O.one("playerready",function(ne){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}),O.longResumeTracker=new Ft(Xe(O)),O.errorTracker=new oi(Xe(O)),new gi(Xe(O)),O.seekingTracker=new qn(Xe(O)),O.playheadTime=new di(Xe(O)),O.playbackHeartbeat=new Yi(Xe(O)),new Hn(Xe(O)),O.watchTimeTracker=new wr(Xe(O)),new Wi(Xe(O)),O.adTracker=new jn(Xe(O)),new Cr(Xe(O)),new hi(Xe(O)),new Xi(Xe(O)),new tn(Xe(O)),new kt(Xe(O)),N.hlsjs&&O.addHLSJS(N),N.dashjs&&O.addDashJS(N),O.emit("viewinit",N.data),O}return f=R,g=[{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(k){if(this.data.view_id){var C=Object.assign({},this.data);if(C.video_source_is_live===void 0&&(C.player_source_duration===1/0||C.video_source_duration===1/0?C.video_source_is_live=!0:(C.player_source_duration>0||C.video_source_duration>0)&&(C.video_source_is_live=!1)),C.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(ge){C[ge]=void 0}),C.video_source_url=C.video_source_url||C.player_source_url,C.video_source_url){var N=gn(te(C.video_source_url),2),O=N[0],Y=N[1];C.video_source_domain=Y,C.video_source_hostname=O}delete C.ad_request_id,this.playbackEventDispatcher.send(k,C),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),k==="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 k=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(C){var N=parseInt(k.data[C],10);k.data[C]=isNaN(N)?void 0:N}),["player_source_url","video_source_url"].forEach(function(C){if(k.data[C]){var N=k.data[C].toLowerCase();N.indexOf("data:")!==0&&N.indexOf("blob:")!==0||(k.data[C]="MSE style URL")}})}},{key:"_resetVideoData",value:function(k,C){var N=this;Object.keys(this.data).forEach(function(O){O.indexOf("video_")===0&&delete N.data[O]})}},{key:"_resetViewData",value:function(){var k=this;Object.keys(this.data).forEach(function(C){C.indexOf("view_")===0&&delete k.data[C]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(k,C){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var k=this,C=this.data.view_id=fe(),N=function(){C===k.data.view_id&&Q(k.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",N):N()}},{key:"_restartHeartBeat",value:function(){var k=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){k.data.player_is_paused||k.emit("hb")},1e4))}},{key:"addHLSJS",value:function(k){k.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=k.hlsjs,function(C,N,O){var Y=arguments.length>4?arguments[4]:void 0,ge=C.log,re=C.utils.secondsToMs,ce=function(Pe){var $,ue=parseInt(Y.version);return ue===1&&Pe.programDateTime!==null&&($=Pe.programDateTime),ue===0&&Pe.pdt!==null&&($=Pe.pdt),$};if(U.exists()){var ne=function(Pe,$){return C.emit(N,Pe,$)},he=function(Pe,$){var ue=$.levels,ee=$.audioTracks,Ee=$.url,De=$.stats,Qe=$.networkDetails,ht=$.sessionData,Je={},nt={};ue.forEach(function(Ye,ft){Je[ft]={width:Ye.width,height:Ye.height,bitrate:Ye.bitrate,attrs:Ye.attrs}}),ee.forEach(function(Ye,ft){nt[ft]={name:Ye.name,language:Ye.lang,bitrate:Ye.bitrate}});var Fe=Ge(De),de=Fe.bytesLoaded,Lt=Fe.requestStart,wt=Fe.responseStart,gt=Fe.responseEnd;ne("requestcompleted",He(He({},$e(ht)),{},{request_event_type:Pe,request_bytes_loaded:de,request_start:Lt,request_response_start:wt,request_response_end:gt,request_type:"manifest",request_hostname:E(Ee),request_response_headers:Kt(Qe),request_rendition_lists:{media:Je,audio:nt,video:{}}}))};O.on(Y.Events.MANIFEST_LOADED,he);var xe=function(Pe,$){var ue=$.details,ee=$.level,Ee=$.networkDetails,De=$.stats,Qe=Ge(De),ht=Qe.bytesLoaded,Je=Qe.requestStart,nt=Qe.responseStart,Fe=Qe.responseEnd,de=ue.fragments[ue.fragments.length-1],Lt=ce(de)+re(de.duration);ne("requestcompleted",{request_event_type:Pe,request_bytes_loaded:ht,request_start:Je,request_response_start:nt,request_response_end:Fe,request_current_level:ee,request_type:"manifest",request_hostname:E(ue.url),request_response_headers:Kt(Ee),video_holdback:ue.holdBack&&re(ue.holdBack),video_part_holdback:ue.partHoldBack&&re(ue.partHoldBack),video_part_target_duration:ue.partTarget&&re(ue.partTarget),video_target_duration:ue.targetduration&&re(ue.targetduration),video_source_is_live:ue.live,player_manifest_newest_program_time:isNaN(Lt)?void 0:Lt})};O.on(Y.Events.LEVEL_LOADED,xe);var Ke=function(Pe,$){var ue=$.details,ee=$.networkDetails,Ee=$.stats,De=Ge(Ee),Qe=De.bytesLoaded,ht=De.requestStart,Je=De.responseStart,nt=De.responseEnd;ne("requestcompleted",{request_event_type:Pe,request_bytes_loaded:Qe,request_start:ht,request_response_start:Je,request_response_end:nt,request_type:"manifest",request_hostname:E(ue.url),request_response_headers:Kt(ee)})};O.on(Y.Events.AUDIO_TRACK_LOADED,Ke);var tt=function(Pe,$){var ue=$.stats,ee=$.networkDetails,Ee=$.frag;ue=ue||Ee.stats;var De=Ge(ue),Qe=De.bytesLoaded,ht=De.requestStart,Je=De.responseStart,nt=De.responseEnd,Fe=ee?Kt(ee):void 0,de={request_event_type:Pe,request_bytes_loaded:Qe,request_start:ht,request_response_start:Je,request_response_end:nt,request_hostname:ee?E(ee.responseURL):void 0,request_id:Fe?We(Fe):void 0,request_response_headers:Fe,request_media_duration:Ee.duration,request_url:ee==null?void 0:ee.responseURL};Ee.type==="main"?(de.request_type="media",de.request_current_level=Ee.level,de.request_video_width=(O.levels[Ee.level]||{}).width,de.request_video_height=(O.levels[Ee.level]||{}).height,de.request_labeled_bitrate=(O.levels[Ee.level]||{}).bitrate):de.request_type=Ee.type,ne("requestcompleted",de)};O.on(Y.Events.FRAG_LOADED,tt);var ct=function(Pe,$){var ue=$.frag,ee=ue.start,Ee={currentFragmentPDT:ce(ue),currentFragmentStart:re(ee)};ne("fragmentchange",Ee)};O.on(Y.Events.FRAG_CHANGED,ct);var vt=function(Pe,$){var ue=$.type,ee=$.details,Ee=$.response,De=$.fatal,Qe=$.frag,ht=$.networkDetails,Je=(Qe==null?void 0:Qe.url)||$.url||"",nt=ht?Kt(ht):void 0;if(ee!==Y.ErrorDetails.MANIFEST_LOAD_ERROR&&ee!==Y.ErrorDetails.MANIFEST_LOAD_TIMEOUT&&ee!==Y.ErrorDetails.FRAG_LOAD_ERROR&&ee!==Y.ErrorDetails.FRAG_LOAD_TIMEOUT&&ee!==Y.ErrorDetails.LEVEL_LOAD_ERROR&&ee!==Y.ErrorDetails.LEVEL_LOAD_TIMEOUT&&ee!==Y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&ee!==Y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT&&ee!==Y.ErrorDetails.SUBTITLE_LOAD_ERROR&&ee!==Y.ErrorDetails.SUBTITLE_LOAD_TIMEOUT&&ee!==Y.ErrorDetails.KEY_LOAD_ERROR&&ee!==Y.ErrorDetails.KEY_LOAD_TIMEOUT||ne("requestfailed",{request_error:ee,request_url:Je,request_hostname:E(Je),request_id:nt?We(nt):void 0,request_type:ee===Y.ErrorDetails.FRAG_LOAD_ERROR||ee===Y.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":ee===Y.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||ee===Y.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":ee===Y.ErrorDetails.SUBTITLE_LOAD_ERROR||ee===Y.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":ee===Y.ErrorDetails.KEY_LOAD_ERROR||ee===Y.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:Ee==null?void 0:Ee.code,request_error_text:Ee==null?void 0:Ee.text}),De){var Fe,de="".concat(Je?"url: ".concat(Je,`
|
|
5
|
+
`):"")+"".concat(Ee&&(Ee.code||Ee.text)?"response: ".concat(Ee.code,", ").concat(Ee.text,`
|
|
6
|
+
`):"")+"".concat($.reason?"failure reason: ".concat($.reason,`
|
|
7
|
+
`):"")+"".concat($.level?"level: ".concat($.level,`
|
|
8
|
+
`):"")+"".concat($.parent?"parent stream controller: ".concat($.parent,`
|
|
9
|
+
`):"")+"".concat($.buffer?"buffer length: ".concat($.buffer,`
|
|
10
|
+
`):"")+"".concat($.error?"error: ".concat($.error,`
|
|
11
|
+
`):"")+"".concat($.event?"event: ".concat($.event,`
|
|
12
|
+
`):"")+"".concat($.err?"error message: ".concat((Fe=$.err)===null||Fe===void 0?void 0:Fe.message,`
|
|
13
|
+
`):"");ne("error",{player_error_code:ue,player_error_message:ee,player_error_context:de})}};O.on(Y.Events.ERROR,vt);var le=function(Pe,$){var ue=$.frag,ee=ue&&ue._url||"";ne("requestcanceled",{request_event_type:Pe,request_url:ee,request_type:"media",request_hostname:E(ee)})};O.on(Y.Events.FRAG_LOAD_EMERGENCY_ABORTED,le);var Ve=function(Pe,$){var ue=$.level,ee=O.levels[ue];if(ee&&ee.attrs&&ee.attrs.BANDWIDTH){var Ee,De=ee.attrs.BANDWIDTH,Qe=parseFloat(ee.attrs["FRAME-RATE"]);isNaN(Qe)||(Ee=Qe),De?ne("renditionchange",{video_source_fps:Ee,video_source_bitrate:De,video_source_width:ee.width,video_source_height:ee.height,video_source_rendition_name:ee.name,video_source_codec:ee==null?void 0:ee.videoCodec}):ge.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};O.on(Y.Events.LEVEL_SWITCHED,Ve),O._stopMuxMonitor=function(){O.off(Y.Events.MANIFEST_LOADED,he),O.off(Y.Events.LEVEL_LOADED,xe),O.off(Y.Events.AUDIO_TRACK_LOADED,Ke),O.off(Y.Events.FRAG_LOADED,tt),O.off(Y.Events.FRAG_CHANGED,ct),O.off(Y.Events.ERROR,vt),O.off(Y.Events.FRAG_LOAD_EMERGENCY_ABORTED,le),O.off(Y.Events.LEVEL_SWITCHED,Ve),O.off(Y.Events.DESTROYING,O._stopMuxMonitor),delete O._stopMuxMonitor},O.on(Y.Events.DESTROYING,O._stopMuxMonitor)}else ge.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,k.hlsjs,{},k.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var k;this.hlsjs&&((k=this.hlsjs)&&typeof k._stopMuxMonitor=="function"&&k._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(k){k.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=k.dashjs,function(C,N,O){var Y=C.log;if(O&&O.on){var ge=function(le,Ve){return C.emit(N,le,Ve)},re=function(le){var Ve=le.type,Pe=(le.data||{}).url;ge("requestcompleted",{request_event_type:Ve,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:E(Pe),request_url:Pe})};O.on("manifestLoaded",re);var ce={},ne=function(le){var Ve=le.type,Pe=le.fragmentModel,$=(le.chunk||{}).mediaInfo||{},ue=$.type,ee=$.bitrateList,Ee={};(ee=ee||[]).forEach(function(gt,Ye){Ee[Ye]={},Ee[Ye].width=gt.width,Ee[Ye].height=gt.height,Ee[Ye].bitrate=gt.bandwidth,Ee[Ye].attrs={}}),ue==="video"?ce.video=Ee:ue==="audio"?ce.audio=Ee:ce.media=Ee;var De=ze(Pe,O),Qe=De.requestStart,ht=De.requestResponseStart,Je=De.requestResponseEnd,nt=De.requestResponseHeaders,Fe=De.requestMediaDuration,de=De.requestHostname,Lt=De.requestUrl,wt=De.requestId;ge("requestcompleted",{request_event_type:Ve,request_start:Qe,request_response_start:ht,request_response_end:Je,request_bytes_loaded:-1,request_type:ue+"_init",request_response_headers:nt,request_hostname:de,request_id:wt,request_url:Lt,request_media_duration:Fe,request_rendition_lists:ce})};O.on("initFragmentLoaded",ne);var he=function(le){var Ve=le.type,Pe=le.fragmentModel,$=le.chunk||{},ue=$.mediaInfo,ee=$.start,Ee=(ue||{}).type,De=ze(Pe,O),Qe=De.requestStart,ht=De.requestResponseStart,Je=De.requestResponseEnd,nt=De.requestBytesLoaded,Fe=De.requestResponseHeaders,de=De.requestMediaDuration,Lt=De.requestHostname,wt=De.requestUrl,gt=De.requestId,Ye=qt(Ee,O),ft=Ye.currentLevel,zr=Ye.renditionWidth,pr=Ye.renditionHeight,lr=Ye.renditionBitrate;ge("requestcompleted",{request_event_type:Ve,request_start:Qe,request_response_start:ht,request_response_end:Je,request_bytes_loaded:nt,request_type:Ee,request_response_headers:Fe,request_hostname:Lt,request_id:gt,request_url:wt,request_media_start_time:ee,request_media_duration:de,request_current_level:ft,request_labeled_bitrate:lr,request_video_width:zr,request_video_height:pr})};O.on("mediaFragmentLoaded",he);var xe={video:void 0,audio:void 0,totalBitrate:void 0},Ke=function(){if(xe.video&&typeof xe.video.bitrate=="number"){if(xe.video.width&&xe.video.height){var le=xe.video.bitrate;return xe.audio&&typeof xe.audio.bitrate=="number"&&(le+=xe.audio.bitrate),le!==xe.totalBitrate?(xe.totalBitrate=le,{video_source_bitrate:le,video_source_height:xe.video.height,video_source_width:xe.video.width,video_source_codec:Rr(xe.video.codec)}):void 0}Y.warn("have bitrate info for video but missing width/height")}},tt=function(le,Ve,Pe){if(typeof le.newQuality=="number"){var $=le.mediaType;if($==="audio"||$==="video"){var ue=O.getBitrateInfoListFor($).find(function(Ee){return Ee.qualityIndex===le.newQuality});if(ue&&typeof ue.bitrate=="number"){xe[$]=Pt(Pt({},ue),{},{codec:O.getCurrentTrackFor($).codec});var ee=Ke();ee&&ge("renditionchange",ee)}else Y.warn("missing bitrate info for ".concat($))}}else Y.warn("missing evt.newQuality in qualityChangeRendered event",le)};O.on("qualityChangeRendered",tt);var ct=function(le){var Ve=le.request,Pe=le.mediaType;ge("requestcanceled",{request_event_type:(Ve=Ve||{}).type+"_"+Ve.action,request_url:Ve.url,request_type:Pe,request_hostname:E(Ve.url)})};O.on("fragmentLoadingAbandoned",ct);var vt=function(le){var Ve,Pe,$=le.error,ue=($==null||(Ve=$.data)===null||Ve===void 0?void 0:Ve.request)||{},ee=($==null||(Pe=$.data)===null||Pe===void 0?void 0:Pe.response)||{};($==null?void 0:$.code)===27&&ge("requestfailed",{request_error:ue.type+"_"+ue.action,request_url:ue.url,request_hostname:E(ue.url),request_type:ue.mediaType,request_error_code:ee.status,request_error_text:ee.statusText});var Ee="".concat(ue!=null&&ue.url?"url: ".concat(ue.url,`
|
|
14
|
+
`):"")+"".concat(ee!=null&&ee.status||ee!=null&&ee.statusText?"response: ".concat(ee==null?void 0:ee.status,", ").concat(ee==null?void 0:ee.statusText,`
|
|
15
|
+
`):"");ge("error",{player_error_code:$==null?void 0:$.code,player_error_message:$==null?void 0:$.message,player_error_context:Ee})};O.on("error",vt),O._stopMuxMonitor=function(){O.off("manifestLoaded",re),O.off("initFragmentLoaded",ne),O.off("mediaFragmentLoaded",he),O.off("qualityChangeRendered",tt),O.off("error",vt),O.off("fragmentLoadingAbandoned",ct),delete O._stopMuxMonitor}}else Y.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,k.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var k;this.dashjs&&((k=this.dashjs)&&typeof k._stopMuxMonitor=="function"&&k._stopMuxMonitor(),this.dashjs=void 0)}}],g&&mn(f.prototype,g),b&&mn(f,b),Object.defineProperty(f,"prototype",{writable:!1}),R}(ai),Ai=fr,Gr=j(153),tr=j.n(Gr);function ki(m){return ki=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},ki(m)}function yn(m,f){return function(g){if(Array.isArray(g))return g}(m)||function(g,b){var S=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(S!=null){var R,k,C=[],N=!0,O=!1;try{for(S=S.call(g);!(N=(R=S.next()).done)&&(C.push(R.value),!b||C.length!==b);N=!0);}catch(Y){O=!0,k=Y}finally{try{N||S.return==null||S.return()}finally{if(O)throw k}}return C}}(m,f)||function(g,b){if(g){if(typeof g=="string")return Hr(g,b);var S=Object.prototype.toString.call(g).slice(8,-1);return S==="Object"&&g.constructor&&(S=g.constructor.name),S==="Map"||S==="Set"?Array.from(g):S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S)?Hr(g,b):void 0}}(m,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 Hr(m,f){(f==null||f>m.length)&&(f=m.length);for(var g=0,b=new Array(f);g<f;g++)b[g]=m[g];return b}var Yt,Qn=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Jn={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};z()&&z().WeakMap&&(Yt=new WeakMap);var Tn="#EXT-X-TARGETDURATION",Kr="#EXT-X-PART-INF",Ri="#EXT-X-SERVER-CONTROL",En="#EXTINF",$n="#EXT-X-PROGRAM-DATE-TIME",_n="#EXT-X-VERSION",Li="#EXT-X-SESSION-DATA",vr=function(m){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(m),this.manifest};vr.prototype.process=function(m){var f;for(this.buffer+=m,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)},vr.prototype.processLine=function(m){var f=m.indexOf(":"),g=Sn(m,f),b=g[0],S=g.length===2?jr(g[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 Tn:if(!isFinite(S)||S<0)return;this.manifest.targetDuration=S,this.setHoldBack();break;case Kr:qr(this.manifest,g),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Ri:qr(this.manifest,g),this.setHoldBack();break;case En:S===0?this.currentUri.duration=.01:S>0&&(this.currentUri.duration=S);break;case $n:var R=S,k=new Date(R);this.manifest.dateTimeString||(this.manifest.dateTimeString=R,this.manifest.dateTimeObject=k),this.currentUri.dateTimeString=R,this.currentUri.dateTimeObject=k;break;case _n:qr(this.manifest,g);break;case Li:var C=mr(g[1]),N=$e(C);Object.assign(this.manifest.sessionData,N)}},vr.prototype.setHoldBack=function(){var m=this.manifest,f=m.serverControl,g=m.targetDuration,b=m.partTargetDuration;if(f){var S="holdBack",R="partHoldBack",k=g&&3*g,C=b&&2*b;g&&!f.hasOwnProperty(S)&&(f[S]=k),k&&f[S]<k&&(f[S]=k),b&&!f.hasOwnProperty(R)&&(f[R]=3*b),b&&f[R]<C&&(f[R]=C)}};var qr=function(m,f){var g,b=gr(f[0].replace("#EXT-X-",""));Vr(f[1])?(g={},g=Object.assign(bn(f[1]),g)):g=jr(f[1]),m[b]=g},gr=function(m){return m.toLowerCase().replace(/-(\w)/g,function(f){return f[1].toUpperCase()})},jr=function(m){if(m.toLowerCase()==="yes"||m.toLowerCase()==="no")return m.toLowerCase()==="yes";var f=m.indexOf(":")!==-1?m:parseFloat(m);return isNaN(f)?m:f},wi=function(m){var f={},g=m.split("=");return g.length>1&&(f[gr(g[0])]=jr(g[1])),f},bn=function(m){for(var f=m.split(","),g={},b=0;f.length>b;b++){var S=f[b],R=wi(S);g=Object.assign(R,g)}return g},Vr=function(m){return m.indexOf("=")>-1},Sn=function(m,f){return f===-1?[m]:[m.substring(0,f),m.substring(f+1)]},mr=function(m){var f={};if(m){var g=m.search(",");return[m.slice(0,g),m.slice(g+1)].forEach(function(b,S){for(var R=b.replace(/['"]+/g,"").split("="),k=0;k<R.length;k++)R[k]==="DATA-ID"&&(f["DATA-ID"]=R[1-k]),R[k]==="VALUE"&&(f.VALUE=R[1-k])}),{data:f}}},Di=vr,Zn={safeCall:function(m,f,g,b){var S=b;if(m&&typeof m[f]=="function")try{S=m[f].apply(m,g)}catch(R){Le.info("safeCall error",R)}return S},safeIncrement:Q,getComputedStyle:function(m,f){var g;if(m&&f&&z()&&typeof z().getComputedStyle=="function")return Yt&&Yt.has(m)&&(g=Yt.get(m)),g||(g=z().getComputedStyle(m,null),Yt&&Yt.set(m,g)),g.getPropertyValue(f)},secondsToMs:function(m){return Math.floor(1e3*m)},assign:Object.assign,headersStringToObject:ke,cdnHeadersToRequestId:We,extractHostnameAndDomain:te,extractHostname:E,manifestParser:Di,generateShortID:be,generateUUID:fe,now:Me.now},Ii={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 ea(m,f){return function(g){if(Array.isArray(g))return g}(m)||function(g,b){var S=g==null?null:typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(S!=null){var R,k,C=[],N=!0,O=!1;try{for(S=S.call(g);!(N=(R=S.next()).done)&&(C.push(R.value),!b||C.length!==b);N=!0);}catch(Y){O=!0,k=Y}finally{try{N||S.return==null||S.return()}finally{if(O)throw k}}return C}}(m,f)||function(g,b){if(g){if(typeof g=="string")return Yr(g,b);var S=Object.prototype.toString.call(g).slice(8,-1);return S==="Object"&&g.constructor&&(S=g.constructor.name),S==="Map"||S==="Set"?Array.from(g):S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S)?Yr(g,b):void 0}}(m,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 Yr(m,f){(f==null||f>m.length)&&(f=m.length);for(var g=0,b=new Array(f);g<f;g++)b[g]=m[g];return b}var Ze={},Wt=function m(f){var g=arguments;typeof f=="string"?m.hasOwnProperty(f)?z().setTimeout(function(){g=Array.prototype.splice.call(g,1),m[f].apply(null,g)},0):Le.warn("`"+f+"` is an unknown task"):typeof f=="function"?z().setTimeout(function(){f(m)},0):Le.warn("`"+f+"` is invalid.")},or={loaded:Me.now(),NAME:"mux-embed",VERSION:"4.24.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(m,f){return function(g,b,S){var R=yn(Se(b),3),k=R[0],C=R[1],N=R[2],O=g.log,Y=g.utils.getComputedStyle,ge=g.utils.secondsToMs;if(!k)return O.error("No element was found with the `"+C+"` query selector.");if(N!=="video"&&N!=="audio")return O.error("The element of `"+C+"` was not a media element.");k.mux&&(k.mux.destroy(),delete k.mux,O.warn("Already monitoring this video element, replacing existing event listeners")),(S=Object.assign({automaticErrorTracking:!0},S)).data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:g.VERSION},S.data),S.getPlayheadTime=function(){return ge(k.currentTime)},S.getStateData=function(){var ce,ne,he=this.hlsjs&&this.hlsjs.url,xe=this.dashjs&&ki(this.dashjs.getSource==="function")&&this.dashjs.getSource(),Ke={player_is_paused:k.paused,player_playhead_time:ge(k.currentTime),player_width:parseInt(Y(k,"width")),player_height:parseInt(Y(k,"height")),player_autoplay_on:k.autoplay,player_preload_on:k.preload,player_language_code:k.lang,player_is_fullscreen:tr()&&!!(tr().fullscreenElement||tr().webkitFullscreenElement||tr().mozFullScreenElement||tr().msFullscreenElement),video_poster_url:k.poster,video_source_url:he||xe||k.currentSrc,video_source_duration:ge(k.duration),video_source_height:k.videoHeight,video_source_width:k.videoWidth,view_dropped_frame_count:(ce=k)===null||ce===void 0||(ne=ce.getVideoPlaybackQuality)===null||ne===void 0?void 0:ne.call(ce).droppedVideoFrames},tt=S.getPlayheadTime();if(k.getStartDate&&tt>0){var ct=k.getStartDate();if(ct&&typeof ct.getTime=="function"&&ct.getTime()){var vt=ct.getTime();if(Ke.player_program_time=vt+tt,k.seekable.length>0){var le=vt+k.seekable.end(k.seekable.length-1);Ke.player_live_edge_program_time=le}}}return Ke},k.mux=k.mux||{},k.mux.deleted=!1,k.mux.emit=function(ce,ne){g.emit(C,ce,ne)};var re=function(){O.error("The monitor for this video element has already been destroyed.")};k.mux.destroy=function(){Object.keys(k.mux.listeners).forEach(function(ce){k.removeEventListener(ce,k.mux.listeners[ce],!1)}),delete k.mux.listeners,k.mux.destroy=re,k.mux.swapElement=re,k.mux.emit=re,k.mux.addHLSJS=re,k.mux.addDashJS=re,k.mux.removeHLSJS=re,k.mux.removeDashJS=re,k.mux.deleted=!0,g.emit(C,"destroy")},k.mux.swapElement=function(ce){var ne=yn(Se(ce),3),he=ne[0],xe=ne[1],Ke=ne[2];return he?Ke!=="video"&&Ke!=="audio"?g.log.error("The element of `"+xe+"` was not a media element."):(he.muxId=k.muxId,delete k.muxId,he.mux=he.mux||{},he.mux.listeners=Object.assign({},k.mux.listeners),delete k.mux.listeners,Object.keys(he.mux.listeners).forEach(function(tt){k.removeEventListener(tt,he.mux.listeners[tt],!1),he.addEventListener(tt,he.mux.listeners[tt],!1)}),he.mux.swapElement=k.mux.swapElement,he.mux.destroy=k.mux.destroy,delete k.mux,void(k=he)):g.log.error("No element was found with the `"+xe+"` query selector.")},k.mux.addHLSJS=function(ce){g.addHLSJS(C,ce)},k.mux.addDashJS=function(ce){g.addDashJS(C,ce)},k.mux.removeHLSJS=function(){g.removeHLSJS(C)},k.mux.removeDashJS=function(){g.removeDashJS(C)},g.init(C,S),g.emit(C,"playerready"),k.paused||(g.emit(C,"play"),k.readyState>2&&g.emit(C,"playing")),k.mux.listeners={},Qn.forEach(function(ce){(ce!=="error"||S.automaticErrorTracking)&&(k.mux.listeners[ce]=function(){var ne={};if(ce==="error"){if(!k.error||k.error.code===1)return;ne.player_error_code=k.error.code,ne.player_error_message=Jn[k.error.code]||k.error.message}g.emit(C,ce,ne)},k.addEventListener(ce,k.mux.listeners[ce],!1))})}(Wt,m,f)},destroyMonitor:function(m){var f=ea(Se(m),1)[0];f&&f.mux&&typeof f.mux.destroy=="function"?f.mux.destroy():Le.error("A video element monitor for `"+m+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(m,f){var g=ve(m);Ze[g]?Ze[g].addHLSJS(f):Le.error("A monitor for `"+g+"` has not been initialized.")},addDashJS:function(m,f){var g=ve(m);Ze[g]?Ze[g].addDashJS(f):Le.error("A monitor for `"+g+"` has not been initialized.")},removeHLSJS:function(m){var f=ve(m);Ze[f]?Ze[f].removeHLSJS():Le.error("A monitor for `"+f+"` has not been initialized.")},removeDashJS:function(m){var f=ve(m);Ze[f]?Ze[f].removeDashJS():Le.error("A monitor for `"+f+"` has not been initialized.")},init:function(m,f){lt()&&f&&f.respectDoNotTrack&&Le.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var g=ve(m);Ze[g]=new Ai(Wt,g,f)},emit:function(m,f,g){var b=ve(m);Ze[b]?(Ze[b].emit(f,g),f==="destroy"&&delete Ze[b]):Le.error("A monitor for `"+b+"` has not been initialized.")},checkDoNotTrack:lt,log:Le,utils:Zn,events:Ii,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Wt,or),z()!==void 0&&typeof z().addEventListener=="function"&&z().addEventListener("pagehide",function(m){m.persisted||(Wt.WINDOW_UNLOADING=!0)},!1);var Wr=Wt},655:function(H,J,j){var se,z;function fe(be){return fe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(ve){return typeof ve}:function(ve){return ve&&typeof Symbol=="function"&&ve.constructor===Symbol&&ve!==Symbol.prototype?"symbol":typeof ve},fe(be);}(function(be){var ve=!1;if((z=typeof(se=be)=="function"?se.call(J,j,J,H):se)===void 0||(H.exports=z),ve=!0,fe(J)==="object"&&(H.exports=be(),ve=!0),!ve){var Se=window.Cookies,we=window.Cookies=be();we.noConflict=function(){return window.Cookies=Se,we}}})(function(){var be=function(){for(var ve=0,Se={};ve<arguments.length;ve++){var we=arguments[ve];for(var Oe in we)Se[Oe]=we[Oe]}return Se};return function ve(Se){function we(Oe,ot,Le){var lt;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(Le=be({path:"/"},we.defaults,Le)).expires=="number"){var Me=new Date;Me.setMilliseconds(Me.getMilliseconds()+864e5*Le.expires),Le.expires=Me}try{lt=JSON.stringify(ot),/^[\{\[]/.test(lt)&&(ot=lt)}catch{}return ot=Se.write?Se.write(ot,Oe):encodeURIComponent(String(ot)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),Oe=(Oe=(Oe=encodeURIComponent(String(Oe))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[Oe,"=",ot,Le.expires?"; expires="+Le.expires.toUTCString():"",Le.path?"; path="+Le.path:"",Le.domain?"; domain="+Le.domain:"",Le.secure?"; secure":""].join("")}Oe||(lt={});for(var E=document.cookie?document.cookie.split("; "):[],te=/(%[0-9A-Z]{2})+/g,U=0;U<E.length;U++){var Q=E[U].split("="),qe=Q.slice(1).join("=");qe.charAt(0)==='"'&&(qe=qe.slice(1,-1));try{var At=Q[0].replace(te,decodeURIComponent);if(qe=Se.read?Se.read(qe,At):Se(qe,At)||qe.replace(te,decodeURIComponent),this.json)try{qe=JSON.parse(qe)}catch{}if(Oe===At){lt=qe;break}Oe||(lt[At]=qe)}catch{}}return lt}}return we.set=we,we.get=function(Oe){return we.call(we,Oe)},we.getJSON=function(){return we.apply({json:!0},[].slice.call(arguments))},we.defaults={},we.remove=function(Oe,ot){we(Oe,"",be(ot,{expires:-1}))},we.withConverter=ve,we}(function(){})})},153:function(H,J,j){var se,z=j.g!==void 0?j.g:typeof window!="undefined"?window:{},fe=j(558);typeof document!="undefined"?se=document:(se=z["__GLOBAL_DOCUMENT_CACHE@4"])||(se=z["__GLOBAL_DOCUMENT_CACHE@4"]=fe),H.exports=se},48:function(H,J,j){var se;se=typeof window!="undefined"?window:j.g!==void 0?j.g:typeof self!="undefined"?self:{},H.exports=se},640:function(H,J,j){var se,z;(function(fe,be){"use strict";se=function(){var ve=function(){},Se="undefined",we=typeof window!==Se&&typeof window.navigator!==Se&&/Trident\/|MSIE /.test(window.navigator.userAgent),Oe=["trace","debug","info","warn","error"];function ot(ke,We){var $e=ke[We];if(typeof $e.bind=="function")return $e.bind(ke);try{return Function.prototype.bind.call($e,ke)}catch{return function(){return Function.prototype.apply.apply($e,[ke,arguments])}}}function Le(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function lt(ke){return ke==="debug"&&(ke="log"),typeof console!==Se&&(ke==="trace"&&we?Le:console[ke]!==void 0?ot(console,ke):console.log!==void 0?ot(console,"log"):ve)}function Me(ke,We){for(var $e=0;$e<Oe.length;$e++){var P=Oe[$e];this[P]=$e<ke?ve:this.methodFactory(P,ke,We)}this.log=this.debug}function E(ke,We,$e){return function(){typeof console!==Se&&(Me.call(this,We,$e),this[ke].apply(this,arguments))}}function te(ke,We,$e){return lt(ke)||E.apply(this,arguments)}function U(ke,We,$e){var P,He=this;We=We==null?"WARN":We;var ut="loglevel";function Ge(_e){var ze=(Oe[_e]||"silent").toUpperCase();if(typeof window!==Se&&ut){try{return void(window.localStorage[ut]=ze)}catch{}try{window.document.cookie=encodeURIComponent(ut)+"="+ze+";"}catch{}}}function Kt(){var _e;if(typeof window!==Se&&ut){try{_e=window.localStorage[ut]}catch{}if(typeof _e===Se)try{var ze=window.document.cookie,qt=ze.indexOf(encodeURIComponent(ut)+"=");qt!==-1&&(_e=/^([^;]+)/.exec(ze.slice(qt))[1])}catch{}return He.levels[_e]===void 0&&(_e=void 0),_e}}function cr(){if(typeof window!==Se&&ut){try{return void window.localStorage.removeItem(ut)}catch{}try{window.document.cookie=encodeURIComponent(ut)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof ke=="string"?ut+=":"+ke:typeof ke=="symbol"&&(ut=void 0),He.name=ke,He.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},He.methodFactory=$e||te,He.getLevel=function(){return P},He.setLevel=function(_e,ze){if(typeof _e=="string"&&He.levels[_e.toUpperCase()]!==void 0&&(_e=He.levels[_e.toUpperCase()]),!(typeof _e=="number"&&_e>=0&&_e<=He.levels.SILENT))throw"log.setLevel() called with invalid level: "+_e;if(P=_e,ze!==!1&&Ge(_e),Me.call(He,_e,ke),typeof console===Se&&_e<He.levels.SILENT)return"No console available for logging"},He.setDefaultLevel=function(_e){We=_e,Kt()||He.setLevel(_e,!1)},He.resetLevel=function(){He.setLevel(We,!1),cr()},He.enableAll=function(_e){He.setLevel(He.levels.TRACE,_e)},He.disableAll=function(_e){He.setLevel(He.levels.SILENT,_e)};var Pt=Kt();Pt==null&&(Pt=We),He.setLevel(Pt,!1)}var Q=new U,qe={};Q.getLogger=function(ke){if(typeof ke!="symbol"&&typeof ke!="string"||ke==="")throw new TypeError("You must supply a name when creating a logger.");var We=qe[ke];return We||(We=qe[ke]=new U(ke,Q.getLevel(),Q.methodFactory)),We};var At=typeof window!==Se?window.log:void 0;return Q.noConflict=function(){return typeof window!==Se&&window.log===Q&&(window.log=At),Q},Q.getLoggers=function(){return qe},Q.default=Q,Q},(z=typeof se=="function"?se.call(J,j,J,H):se)===void 0||(H.exports=z)})()},375:function(H,J){"use strict";var j=Object.prototype.hasOwnProperty;function se(fe){try{return decodeURIComponent(fe.replace(/\+/g," "))}catch{return null}}function z(fe){try{return encodeURIComponent(fe)}catch{return null}}J.stringify=function(fe,be){be=be||"";var ve,Se,we=[];for(Se in typeof be!="string"&&(be="?"),fe)if(j.call(fe,Se)){if((ve=fe[Se])||ve!=null&&!isNaN(ve)||(ve=""),Se=z(Se),ve=z(ve),Se===null||ve===null)continue;we.push(Se+"="+ve)}return we.length?be+we.join("&"):""},J.parse=function(fe){for(var be,ve=/([^=?#&]+)=?([^&]*)/g,Se={};be=ve.exec(fe);){var we=se(be[1]),Oe=se(be[2]);we===null||Oe===null||we in Se||(Se[we]=Oe)}return Se}},558:function(){}},B={};function K(H){var J=B[H];if(J!==void 0)return J.exports;var j=B[H]={exports:{}};return D[H].call(j.exports,j,j.exports,K),j.exports}return K.n=function(H){var J=H&&H.__esModule?function(){return H.default}:function(){return H};return K.d(J,{a:J}),J},K.d=function(H,J){for(var j in J)K.o(J,j)&&!K.o(H,j)&&Object.defineProperty(H,j,{enumerable:!0,get:J[j]})},K.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),K.o=function(H,J){return Object.prototype.hasOwnProperty.call(H,J)},K(80)}()},typeof Mn=="object"&&typeof Fa=="object"?Fa.exports=M():typeof Mn=="object"?Mn.mux=M():I.mux=M()})()});var zs=Ks((Ws,Na)=>{(function I(M){var D,B;D=this,B=function(){"use strict";function K(s,n){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);n&&(t=t.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),e.push.apply(e,t)}return e}function H(s){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?K(Object(e),!0).forEach(function(t){se(s,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):K(Object(e)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(e,t))})}return s}function J(s,n){for(var e=0;e<n.length;e++){var t=n[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,lt(t.key),t)}}function j(s,n,e){return n&&J(s.prototype,n),e&&J(s,e),Object.defineProperty(s,"prototype",{writable:!1}),s}function se(s,n,e){return(n=lt(n))in s?Object.defineProperty(s,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[n]=e,s}function z(){return z=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(s[t]=e[t])}return s},z.apply(this,arguments)}function fe(s,n){s.prototype=Object.create(n.prototype),s.prototype.constructor=s,ve(s,n)}function be(s){return be=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},be(s)}function ve(s,n){return ve=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ve(s,n)}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 we(s,n,e){return we=Se()?Reflect.construct.bind():function(t,r,i){var a=[null];a.push.apply(a,r);var o=new(Function.bind.apply(t,a));return i&&ve(o,i.prototype),o},we.apply(null,arguments)}function Oe(s){var n=typeof Map=="function"?new Map:void 0;return Oe=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(n!==void 0){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return we(e,arguments,be(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),ve(r,e)},Oe(s)}function ot(s,n){(n==null||n>s.length)&&(n=s.length);for(var e=0,t=new Array(n);e<n;e++)t[e]=s[e];return t}function Le(s,n){var e=typeof Symbol!="undefined"&&s[Symbol.iterator]||s["@@iterator"];if(e)return(e=e.call(s)).next.bind(e);if(Array.isArray(s)||(e=function(r,i){if(r){if(typeof r=="string")return ot(r,i);var a=Object.prototype.toString.call(r).slice(8,-1);return a==="Object"&&r.constructor&&(a=r.constructor.name),a==="Map"||a==="Set"?Array.from(r):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?ot(r,i):void 0}}(s))||n&&s&&typeof s.length=="number"){e&&(s=e);var t=0;return function(){return t>=s.length?{done:!0}:{done:!1,value:s[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 lt(s){var n=function(e,t){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}(s,"string");return typeof n=="symbol"?n:String(n)}var Me={};(function(s,n){var e,t,r,i,a;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,t=/^(?=([^\/?#]*))\1([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(o,l,d){if(d=d||{},o=o.trim(),!(l=l.trim())){if(!d.alwaysNormalize)return o;var u=a.parseURL(o);if(!u)throw new Error("Error trying to parse base URL.");return u.path=a.normalizePath(u.path),a.buildURLFromParts(u)}var c=a.parseURL(l);if(!c)throw new Error("Error trying to parse relative URL.");if(c.scheme)return d.alwaysNormalize?(c.path=a.normalizePath(c.path),a.buildURLFromParts(c)):l;var h=a.parseURL(o);if(!h)throw new Error("Error trying to parse base URL.");if(!h.netLoc&&h.path&&h.path[0]!=="/"){var v=t.exec(h.path);h.netLoc=v[1],h.path=v[2]}h.netLoc&&!h.path&&(h.path="/");var y={scheme:h.scheme,netLoc:c.netLoc,path:null,params:c.params,query:c.query,fragment:c.fragment};if(!c.netLoc&&(y.netLoc=h.netLoc,c.path[0]!=="/"))if(c.path){var T=h.path,A=T.substring(0,T.lastIndexOf("/")+1)+c.path;y.path=a.normalizePath(A)}else y.path=h.path,c.params||(y.params=h.params,c.query||(y.query=h.query));return y.path===null&&(y.path=d.alwaysNormalize?a.normalizePath(c.path):c.path),a.buildURLFromParts(y)},parseURL:function(o){var l=e.exec(o);return l?{scheme:l[1]||"",netLoc:l[2]||"",path:l[3]||"",params:l[4]||"",query:l[5]||"",fragment:l[6]||""}:null},normalizePath:function(o){for(o=o.split("").reverse().join("").replace(r,"");o.length!==(o=o.replace(i,"")).length;);return o.split("").reverse().join("")},buildURLFromParts:function(o){return o.scheme+o.netLoc+o.path+o.params+o.query+o.fragment}},s.exports=a})({get exports(){return Me},set exports(s){Me=s}});var E,te,U,Q=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)};(function(s){s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached"})(E||(E={})),function(s){s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError"}(te||(te={})),function(s){s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown"}(U||(U={}));var qe=function(){},At={trace:qe,debug:qe,log:qe,warn:qe,info:qe,error:qe},ke=At;function We(s){var n=self.console[s];return n?n.bind(self.console,"["+s+"] >"):qe}function $e(s,n){if(self.console&&s===!0||typeof s=="object"){(function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach(function(a){ke[a]=e[a]?e[a].bind(e):We(a)})})(s,"debug","log","info","warn","error");try{ke.log('Debug logs enabled for "'+n+'" in hls.js version 1.4.0-beta.2')}catch{ke=At}}else ke=At}var P=ke,He=/^(\d+)x(\d+)$/,ut=/(.+?)=(".*?"|.*?)(?:,|$)/g,Ge=function(){function s(e){for(var t in typeof e=="string"&&(e=s.parseAttrList(e)),e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}var n=s.prototype;return n.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},n.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},n.decimalFloatingPoint=function(e){return parseFloat(this[e])},n.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},n.enumeratedString=function(e){return this[e]},n.bool=function(e){return this[e]==="YES"},n.decimalResolution=function(e){var t=He.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},s.parseAttrList=function(e){var t,r={};for(ut.lastIndex=0;(t=ut.exec(e))!==null;){var i=t[2];i.indexOf('"')===0&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1].trim()]=i}return r},s}();function Kt(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}var cr=function(){function s(n,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 r in t)if(Object.prototype.hasOwnProperty.call(n,r)&&n[r]!==t[r]){P.warn('DATERANGE tag attribute: "'+r+'" does not match for tags with ID: "'+n.ID+'"'),this._badValueForSameId=r;break}n=z(new Ge({}),t,n)}if(this.attr=n,this._startDate=new Date(n["START-DATE"]),"END-DATE"in this.attr){var i=new Date(this.attr["END-DATE"]);Q(i.getTime())&&(this._endDate=i)}}return j(s,[{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 n=this.duration;return n!==null?new Date(this._startDate.getTime()+1e3*n):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var n=this.attr.decimalFloatingPoint("DURATION");if(Q(n))return n}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&&Q(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),s}(),Pt=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}},_e="audio",ze="video",qt="audiovideo",Rr=function(){function s(n){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[_e]=null,e[ze]=null,e[qt]=null,e),this.baseurl=n}return s.prototype.setByteRange=function(n,e){var t=n.split("@",2),r=[];t.length===1?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(t[1]),r[1]=parseInt(t[0])+r[0],this._byteRange=r},j(s,[{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=Me.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(n){this._url=n}}]),s}(),Lr=function(s){function n(t,r){var i;return(i=s.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new Pt,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.type=t,i}fe(n,s);var e=n.prototype;return e.setKeyFormat=function(t){if(this.levelkeys){var r=this.levelkeys[t];r&&!this._decryptdata&&(this._decryptdata=r.getDecryptData(this.sn))}},e.abortRequests=function(){var t,r;(t=this.loader)==null||t.abort(),(r=this.keyLoader)==null||r.abort()},e.setElementaryStreamInfo=function(t,r,i,a,o,l){l===void 0&&(l=!1);var d=this.elementaryStreams,u=d[t];u?(u.startPTS=Math.min(u.startPTS,r),u.endPTS=Math.max(u.endPTS,i),u.startDTS=Math.min(u.startDTS,a),u.endDTS=Math.max(u.endDTS,o)):d[t]={startPTS:r,endPTS:i,startDTS:a,endDTS:o,partial:l}},e.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[_e]=null,t[ze]=null,t[qt]=null},j(n,[{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 r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Q(this.programDateTime))return null;var t=Q(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 r=Object.keys(this.levelkeys),i=r.length;if(i>1||i===1&&this.levelkeys[r[0]].encrypted)return!0}return!1}}]),n}(Rr),ji=function(s){function n(e,t,r,i,a){var o;(o=s.call(this,r)||this).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.stats=new Pt,o.duration=e.decimalFloatingPoint("DURATION"),o.gap=e.bool("GAP"),o.independent=e.bool("INDEPENDENT"),o.relurl=e.enumeratedString("URI"),o.fragment=t,o.index=i;var l=e.enumeratedString("BYTERANGE");return l&&o.setByteRange(l,a),a&&(o.fragOffset=a.fragOffset+a.duration),o}return fe(n,s),j(n,[{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)}}]),n}(Rr),Gn=function(){function s(n){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=n}return s.prototype.reloaded=function(n){if(!n)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-n.lastPartSn,t=this.lastPartIndex-n.lastPartIndex;this.updated=this.endSN!==n.endSN||!!t||!!e,this.advanced=this.endSN>n.endSN||e>0||e===0&&t>0,this.updated||this.advanced?this.misses=Math.floor(.6*n.misses):this.misses=n.misses+1,this.availabilityDelay=n.availabilityDelay},j(s,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Q(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var n=this.driftEndTime-this.driftStartTime;return n>0?1e3*(this.driftEnd-this.driftStart)/n:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var n;return(n=this.fragments)!=null&&n.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 n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var n;return(n=this.partList)!=null&&n.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),s}();function ai(s){return Uint8Array.from(atob(s),function(n){return n.charCodeAt(0)})}function Vi(s){var n,e,t=s.split(":"),r=null;if(t[0]==="data"&&t.length===2){var i=t[1].split(";"),a=i[i.length-1].split(",");if(a.length===2){var o=a[0]==="base64",l=a[1];o?(i.splice(-1,1),r=ai(l)):(n=Yi(l).subarray(0,16),(e=new Uint8Array(16)).set(n,16-n.length),r=e)}}return r}function Yi(s){return Uint8Array.from(unescape(encodeURIComponent(s)),function(n){return n.charCodeAt(0)})}var je={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},si="org.w3.clearkey",oi="com.apple.streamingkeydelivery",hr="com.microsoft.playready",wr="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function li(s){switch(s){case oi:return je.FAIRPLAY;case hr:return je.PLAYREADY;case wr:return je.WIDEVINE;case si:return je.CLEARKEY}}var Wi="edef8ba979d64acea3c827dcd51d21ed";function ui(s){switch(s){case je.FAIRPLAY:return oi;case je.PLAYREADY:return hr;case je.WIDEVINE:return wr;case je.CLEARKEY:return si}}function di(s){var n=s.drmSystems,e=s.widevineLicenseUrl,t=n?[je.FAIRPLAY,je.WIDEVINE,je.PLAYREADY,je.CLEARKEY].filter(function(r){return!!n[r]}):[];return!t[je.WIDEVINE]&&e&&t.push(je.WIDEVINE),t}var ci=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function $t(s,n,e){return Uint8Array.prototype.slice?s.slice(n,e):new Uint8Array(Array.prototype.slice.call(s,n,e))}var Dr,hi=function(s,n){return n+10<=s.length&&s[n]===73&&s[n+1]===68&&s[n+2]===51&&s[n+3]<255&&s[n+4]<255&&s[n+6]<128&&s[n+7]<128&&s[n+8]<128&&s[n+9]<128},fi=function(s,n){return n+10<=s.length&&s[n]===51&&s[n+1]===68&&s[n+2]===73&&s[n+3]<255&&s[n+4]<255&&s[n+6]<128&&s[n+7]<128&&s[n+8]<128&&s[n+9]<128},Ir=function(s,n){for(var e=n,t=0;hi(s,n);)t+=10,t+=Cr(s,n+6),fi(s,n+10)&&(t+=10),n+=t;if(t>0)return s.subarray(e,e+t)},Cr=function(s,n){var e=0;return e=(127&s[n])<<21,e|=(127&s[n+1])<<14,e|=(127&s[n+2])<<7,e|=127&s[n+3]},zi=function(s,n){return hi(s,n)&&Cr(s,n+6)+10<=s.length-n},Xi=function(s){return s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp"},Qi=function(s){var n=String.fromCharCode(s[0],s[1],s[2],s[3]),e=Cr(s,4);return{type:n,size:e,data:s.subarray(10,10+e)}},Ji=function(s){for(var n=0,e=[];hi(s,n);){for(var t=Cr(s,n+6),r=(n+=10)+t;n+8<r;){var i=Qi(s.subarray(n)),a=Hn(i);a&&e.push(a),n+=i.size+10}fi(s,n)&&(n+=10)}return e},Hn=function(s){return s.type==="PRIV"?$i(s):s.type[0]==="W"?qn(s):Kn(s)},$i=function(s){if(!(s.size<2)){var n=Tt(s.data,!0),e=new Uint8Array(s.data.subarray(n.length+1));return{key:s.type,info:n,data:e.buffer}}},Kn=function(s){if(!(s.size<2)){if(s.type==="TXXX"){var n=1,e=Tt(s.data.subarray(n),!0);n+=e.length+1;var t=Tt(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=Tt(s.data.subarray(1));return{key:s.type,data:r}}},qn=function(s){if(s.type==="WXXX"){if(s.size<2)return;var n=1,e=Tt(s.data.subarray(n),!0);n+=e.length+1;var t=Tt(s.data.subarray(n));return{key:s.type,info:e,data:t}}var r=Tt(s.data);return{key:s.type,data:r}},Zi=function(s){if(s.data.byteLength===8){var n=new Uint8Array(s.data),e=1&n[3],t=(n[4]<<23)+(n[5]<<15)+(n[6]<<7)+n[7];return t/=45,e&&(t+=4772185884e-2),Math.round(t)}},Tt=function(s,n){n===void 0&&(n=!1);var e=en();if(e){var t=e.decode(s);if(n){var r=t.indexOf("\0");return r!==-1?t.substring(0,r):t}return t.replace(/\0/g,"")}for(var i,a,o,l=s.length,d="",u=0;u<l;){if((i=s[u++])===0&&n)return d;if(i!==0&&i!==3)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(i);break;case 12:case 13:a=s[u++],d+=String.fromCharCode((31&i)<<6|63&a);break;case 14:a=s[u++],o=s[u++],d+=String.fromCharCode((15&i)<<12|(63&a)<<6|(63&o)<<0)}}return d};function en(){return Dr||self.TextDecoder===void 0||(Dr=new self.TextDecoder("utf-8")),Dr}var Et=function(s){for(var n="",e=0;e<s.length;e++){var t=s[e].toString(16);t.length<2&&(t="0"+t),n+=t}return n},xr=Math.pow(2,32)-1,jn=[].push,vi={video:1,audio:2,id3:3,text:4};function et(s){return String.fromCharCode.apply(null,s)}function tn(s,n){var e=s[n]<<8|s[n+1];return e<0?65536+e:e}function Te(s,n){var e=rn(s,n);return e<0?4294967296+e:e}function rn(s,n){return s[n]<<24|s[n+1]<<16|s[n+2]<<8|s[n+3]}function gi(s,n,e){s[n]=e>>24,s[n+1]=e>>16&255,s[n+2]=e>>8&255,s[n+3]=255&e}function Ce(s,n){var e=[];if(!n.length)return e;for(var t=s.byteLength,r=0;r<t;){var i=Te(s,r),a=i>1?r+i:t;if(et(s.subarray(r+4,r+8))===n[0])if(n.length===1)e.push(s.subarray(r+8,a));else{var o=Ce(s.subarray(r+8,a),n.slice(1));o.length&&jn.apply(e,o)}r=a}return e}function Vn(s){var n=[],e=s[0],t=8,r=Te(s,t);t+=4,t+=e===0?8:16,t+=2;var i=s.length+0,a=tn(s,t);t+=2;for(var o=0;o<a;o++){var l=t,d=Te(s,l);l+=4;var u=2147483647&d;if((2147483648&d)>>>31==1)return P.warn("SIDX has hierarchical references (not supported)"),null;var c=Te(s,l);l+=4,n.push({referenceSize:u,subsegmentDuration:c,info:{duration:c/r,start:i,end:i+u-1}}),i+=u,t=l+=4}return{earliestPresentationTime:0,timescale:r,version:e,referencesCount:a,references:n}}function mi(s){for(var n=[],e=Ce(s,["moov","trak"]),t=0;t<e.length;t++){var r=e[t],i=Ce(r,["tkhd"])[0];if(i){var a=i[0],o=a===0?12:20,l=Te(i,o),d=Ce(r,["mdia","mdhd"])[0];if(d){var u=Te(d,o=(a=d[0])===0?12:20),c=Ce(r,["mdia","hdlr"])[0];if(c){var h=et(c.subarray(8,12)),v={soun:_e,vide:ze}[h];if(v){var y=Ce(r,["mdia","minf","stbl","stsd"])[0],T=void 0;y&&(T=et(y.subarray(12,16))),n[l]={timescale:u,type:v},n[v]={timescale:u,id:l,codec:T}}}}}}return Ce(s,["moov","mvex","trex"]).forEach(function(A){var p=Te(A,4),_=n[p];_&&(_.default={duration:Te(A,12),flags:Te(A,20)})}),n}function pi(s){var n=Ce(s,["schm"])[0];if(n){var e=et(n.subarray(4,8));if(e==="cbcs"||e==="cenc")return Ce(s,["schi","tenc"])[0]}return P.error("[eme] missing 'schm' box"),null}function nn(s){var n=Te(s,0),e=8;1&n&&(e+=4),4&n&&(e+=4);for(var t=0,r=Te(s,4),i=0;i<r;i++)256&n&&(t+=Te(s,e),e+=4),512&n&&(e+=4),1024&n&&(e+=4),2048&n&&(e+=4);return t}function jt(s,n){var e=new Uint8Array(s.length+n.length);return e.set(s),e.set(n,s.length),e}function an(s,n){var e=[],t=n.samples,r=n.timescale,i=n.id,a=!1;return Ce(t,["moof"]).map(function(o){var l=o.byteOffset-8;Ce(o,["traf"]).map(function(d){var u=Ce(d,["tfdt"]).map(function(c){var h=c[0],v=Te(c,4);return h===1&&(v*=Math.pow(2,32),v+=Te(c,8)),v/r})[0];return u!==void 0&&(s=u),Ce(d,["tfhd"]).map(function(c){var h=Te(c,4),v=16777215&Te(c,0),y=0,T=(16&v)!=0,A=0,p=(32&v)!=0,_=8;h===i&&((1&v)!=0&&(_+=8),(2&v)!=0&&(_+=4),(8&v)!=0&&(y=Te(c,_),_+=4),T&&(A=Te(c,_),_+=4),p&&(_+=4),n.type==="video"&&(a=function(L){if(!L)return!1;var w=L.indexOf("."),x=w<0?L:L.substring(0,w);return x==="hvc1"||x==="hev1"||x==="dvh1"||x==="dvhe"}(n.codec)),Ce(d,["trun"]).map(function(L){var w=L[0],x=16777215&Te(L,0),F=(1&x)!=0,G=0,W=(4&x)!=0,q=(256&x)!=0,V=0,Z=(512&x)!=0,X=0,ie=(1024&x)!=0,ye=(2048&x)!=0,ae=0,pe=Te(L,4),oe=8;F&&(G=Te(L,oe),oe+=4),W&&(oe+=4);for(var me=G+l,Ae=0;Ae<pe;Ae++){if(q?(V=Te(L,oe),oe+=4):V=y,Z?(X=Te(L,oe),oe+=4):X=A,ie&&(oe+=4),ye&&(ae=w===0?Te(L,oe):rn(L,oe),oe+=4),n.type===ze)for(var Ie=0;Ie<X;){var Re=Te(t,me);Yn(a,t[me+=4])&&yi(t.subarray(me,me+Re),a?2:1,s+ae/r,e),me+=Re,Ie+=Re+4}s+=V/r}}))})})}),e}function Yn(s,n){if(s){var e=n>>1&63;return e===39||e===40}return(31&n)==6}function yi(s,n,e,t){var r=Ti(s),i=0;i+=n;for(var a=0,o=0,l=!1,d=0;i<r.length;){a=0;do{if(i>=r.length)break;a+=d=r[i++]}while(d===255);o=0;do{if(i>=r.length)break;o+=d=r[i++]}while(d===255);var u=r.length-i;if(!l&&a===4&&i<r.length){if(l=!0,r[i++]===181){var c=tn(r,i);if(i+=2,c===49){var h=Te(r,i);if(i+=4,h===1195456820){var v=r[i++];if(v===3){var y=r[i++],T=64&y,A=T?2+3*(31&y):0,p=new Uint8Array(A);if(T){p[0]=y;for(var _=1;_<A;_++)p[_]=r[i++]}t.push({type:v,payloadType:a,pts:e,bytes:p})}}}}}else if(a===5&&o<u){if(l=!0,o>16){for(var L=[],w=0;w<16;w++){var x=r[i++].toString(16);L.push(x.length==1?"0"+x:x),w!==3&&w!==5&&w!==7&&w!==9||L.push("-")}for(var F=o-16,G=new Uint8Array(F),W=0;W<F;W++)G[W]=r[i++];t.push({payloadType:a,pts:e,uuid:L.join(""),userData:Tt(G),userDataBytes:G})}}else if(o<u)i+=o;else if(o>u)break}}function Ti(s){for(var n=s.byteLength,e=[],t=1;t<n-2;)s[t]===0&&s[t+1]===0&&s[t+2]===3?(e.push(t+2),t+=2):t++;if(e.length===0)return s;var r=n-e.length,i=new Uint8Array(r),a=0;for(t=0;t<r;a++,t++)a===e[0]&&(a++,e.shift()),i[t]=s[a];return i}function Wn(s,n,e){if(s.byteLength!==16)throw new RangeError("Invalid system id");var t,r,i;if(n){t=1,r=new Uint8Array(16*n.length);for(var a=0;a<n.length;a++){var o=n[a];if(o.byteLength!==16)throw new RangeError("Invalid key");r.set(o,16*a)}}else t=0,r=new Uint8Array;t>0?(i=new Uint8Array(4),n.length>0&&new DataView(i.buffer).setUint32(0,n.length,!1)):i=new Uint8Array;var l=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(l.buffer).setUint32(0,e.byteLength,!1),function(d){for(var u=arguments.length,c=new Array(u>1?u-1:0),h=1;h<u;h++)c[h-1]=arguments[h];for(var v=c.length,y=8,T=v;T--;)y+=c[T].byteLength;var A=new Uint8Array(y);for(A[0]=y>>24&255,A[1]=y>>16&255,A[2]=y>>8&255,A[3]=255&y,A.set(d,4),T=0,y=8;T<v;T++)A.set(c[T],y),y+=c[T].byteLength;return A}([112,115,115,104],new Uint8Array([t,0,0,0]),s,i,r,l,e||new Uint8Array)}var Pr={},Or=function(){function s(e,t,r,i,a){i===void 0&&(i=[1]),a===void 0&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=a,this.encrypted=!!e&&e!=="NONE",this.isCommonEncryption=this.encrypted&&e!=="AES-128"}s.clearKeyUriToKeyIdMap=function(){Pr={}};var n=s.prototype;return n.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 oi:case wr:case hr:case si:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},n.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||P.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=function(A){for(var p=new Uint8Array(16),_=12;_<16;_++)p[_]=A>>8*(15-_)&255;return p}(e);return new s(this.method,this.uri,"identity",this.keyFormatVersions,t)}var r=Vi(this.uri);if(r)switch(this.keyFormat){case wr:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case hr:var i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Wn(i,null,r);var a=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),o=String.fromCharCode.apply(null,Array.from(a)),l=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(d){var u=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(u){var c=ai(u).subarray(0,16);(function(A){var p=function(_,L,w){var x=_[L];_[L]=_[w],_[w]=x};p(A,0,3),p(A,1,2),p(A,4,5),p(A,6,7)})(c),this.keyId=c}}break;default:var h=r.subarray(0,16);if(h.length!==16){var v=new Uint8Array(16);v.set(h,16-h.length),h=v}this.keyId=h}if(!this.keyId||this.keyId.byteLength!==16){var y=Pr[this.uri];if(!y){var T=Object.keys(Pr).length%Number.MAX_SAFE_INTEGER;y=new Uint8Array(16),new DataView(y.buffer,12,4).setUint32(0,T),Pr[this.uri]=y}this.keyId=y}return this},s}(),Ei=/\{\$([a-zA-Z0-9-_]+)\}/g;function Mr(s){return Ei.test(s)}function dt(s,n,e){if(s.variableList!==null||s.hasVariableRefs)for(var t=e.length;t--;){var r=e[t],i=n[r];i&&(n[r]=_i(s,i))}}function _i(s,n){if(s.variableList!==null||s.hasVariableRefs){var e=s.variableList;return n.replace(Ei,function(t){var r=t.substring(2,t.length-1),i=e==null?void 0:e[r];return i===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+r+'"')),t):i})}return n}function sn(s,n,e){var t,r,i=s.variableList;if(i||(s.variableList=i={}),"QUERYPARAM"in n){t=n.QUERYPARAM;try{var a=new self.URL(e).searchParams;if(!a.has(t))throw new Error('"'+t+'" does not match any query parameter in URI: "'+e+'"');r=a.get(t)}catch(o){s.playlistParsingError||(s.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+o.message))}}else t=n.NAME,r=n.VALUE;t in i?s.playlistParsingError||(s.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+t+'"')):i[t]=r||""}function Ot(s,n,e){var t=n.IMPORT;if(e&&t in e){var r=s.variableList;r||(s.variableList=r={}),r[t]=e[t]}else s.playlistParsingError||(s.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+t+'"'))}var zn={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function Fr(s,n){return MediaSource.isTypeSupported((n||"video")+'/mp4;codecs="'+s+'"')}var on=/#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,ln=/#EXT-X-MEDIA:(.*)/g,un=/^#EXT(?:INF|-X-TARGETDURATION):/m,bi=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ar=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("|")),Mt=function(){function s(){}return s.findGroup=function(n,e){for(var t=0;t<n.length;t++){var r=n[t];if(r.id===e)return r}},s.convertAVC1ToAVCOTI=function(n){var e=n.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 n},s.resolve=function(n,e){return Me.buildAbsoluteURL(e,n,{alwaysNormalize:!0})},s.isMediaPlaylist=function(n){return un.test(n)},s.parseMasterPlaylist=function(n,e){var t,r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Mr(n)},i=[];for(on.lastIndex=0;(t=on.exec(n))!=null;)if(t[1]){var a,o=new Ge(t[1]);dt(r,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=_i(r,t[2]),d={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:s.resolve(l,e)},u=o.decimalResolution("RESOLUTION");u&&(d.width=u.width,d.height=u.height),Nr((o.CODECS||"").split(/[ ,]+/).filter(function(L){return L}),d),d.videoCodec&&d.videoCodec.indexOf("avc1")!==-1&&(d.videoCodec=s.convertAVC1ToAVCOTI(d.videoCodec)),(a=d.unknownCodecs)!=null&&a.length||i.push(d),r.levels.push(d)}else if(t[3]){var c=t[3],h=t[4];switch(c){case"SESSION-DATA":var v=new Ge(h);dt(r,v,["DATA-ID","LANGUAGE","VALUE","URI"]);var y=v["DATA-ID"];y&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[y]=v);break;case"SESSION-KEY":var T=dn(h,e,r);T.encrypted&&T.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(T)):P.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+h+'"');break;case"DEFINE":var A=new Ge(h);dt(r,A,["NAME","VALUE","QUERYPARAM"]),sn(r,A,e);break;case"CONTENT-STEERING":var p=new Ge(h);dt(r,p,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:s.resolve(p["SERVER-URI"],e),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":r.startTimeOffset=Si(h)}}var _=i.length>0&&i.length<r.levels.length;return r.levels=_?i:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r},s.parseMasterPlaylistMedia=function(n,e,t){var r,i={},a=t.levels,o={AUDIO:a.map(function(T){return{id:T.attrs.AUDIO,audioCodec:T.audioCodec}}),SUBTITLES:a.map(function(T){return{id:T.attrs.SUBTITLES,textCodec:T.textCodec}}),"CLOSED-CAPTIONS":[]},l=0;for(ln.lastIndex=0;(r=ln.exec(n))!==null;){var d=new Ge(r[1]),u=d.TYPE;if(u){var c=o[u],h=i[u]||[];i[u]=h,dt(t,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);var v={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?s.resolve(d.URI,e):""};if(c!=null&&c.length){var y=s.findGroup(c,v.groupId)||c[0];cn(v,y,"audioCodec"),cn(v,y,"textCodec")}h.push(v)}}return i},s.parseLevelPlaylist=function(n,e,t,r,i,a){var o,l,d,u=new Gn(e),c=u.fragments,h=null,v=0,y=0,T=0,A=0,p=null,_=new Lr(r,e),L=-1,w=!1;for(bi.lastIndex=0,u.m3u8=n,u.hasVariableRefs=Mr(n);(o=bi.exec(n))!==null;){w&&(w=!1,(_=new Lr(r,e)).start=T,_.sn=v,_.cc=A,_.level=t,h&&(_.initSegment=h,_.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null));var x=o[1];if(x){_.duration=parseFloat(x);var F=(" "+o[2]).slice(1);_.title=F||null,_.tagList.push(F?["INF",x,F]:["INF",x])}else if(o[3]){if(Q(_.duration)){_.start=T,d&&vn(_,d,u),_.sn=v,_.level=t,_.cc=A,_.urlId=i,c.push(_);var G=(" "+o[3]).slice(1);_.relurl=_i(u,G),hn(_,p),p=_,T+=_.duration,v++,y=0,w=!0}}else if(o[4]){var W=(" "+o[4]).slice(1);p?_.setByteRange(W,p):_.setByteRange(W)}else if(o[5])_.rawProgramDateTime=(" "+o[5]).slice(1),_.tagList.push(["PROGRAM-DATE-TIME",_.rawProgramDateTime]),L===-1&&(L=c.length);else{if(!(o=o[0].match(ar))){P.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<o.length&&o[l]===void 0;l++);var q=(" "+o[l]).slice(1),V=(" "+o[l+1]).slice(1),Z=o[l+2]?(" "+o[l+2]).slice(1):"";switch(q){case"PLAYLIST-TYPE":u.type=V.toUpperCase();break;case"MEDIA-SEQUENCE":v=u.startSN=parseInt(V);break;case"SKIP":var X=new Ge(V);dt(u,X,["RECENTLY-REMOVED-DATERANGES"]);var ie=X.decimalInteger("SKIPPED-SEGMENTS");if(Q(ie)){u.skippedSegments=ie;for(var ye=ie;ye--;)c.unshift(null);v+=ie}var ae=X.enumeratedString("RECENTLY-REMOVED-DATERANGES");ae&&(u.recentlyRemovedDateranges=ae.split(" "));break;case"TARGETDURATION":u.targetduration=Math.max(parseInt(V),1);break;case"VERSION":u.version=parseInt(V);break;case"EXTM3U":break;case"ENDLIST":u.live=!1;break;case"#":(V||Z)&&_.tagList.push(Z?[V,Z]:[V]);break;case"DISCONTINUITY":A++,_.tagList.push(["DIS"]);break;case"GAP":_.gap=!0,_.tagList.push([q]);break;case"BITRATE":_.tagList.push([q,V]);break;case"DATERANGE":var pe=new Ge(V);dt(u,pe,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),dt(u,pe,pe.clientAttrs);var oe=new cr(pe,u.dateRanges[pe.ID]);oe.isValid||u.skippedSegments?u.dateRanges[oe.id]=oe:P.warn('Ignoring invalid DATERANGE tag: "'+V+'"'),_.tagList.push(["EXT-X-DATERANGE",V]);break;case"DEFINE":var me=new Ge(V);dt(u,me,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in me?Ot(u,me,a):sn(u,me,e);break;case"DISCONTINUITY-SEQUENCE":A=parseInt(V);break;case"KEY":var Ae=dn(V,e,u);if(Ae.isSupported()){if(Ae.method==="NONE"){d=void 0;break}d||(d={}),d[Ae.keyFormat]&&(d=z({},d)),d[Ae.keyFormat]=Ae}else P.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+V+'"');break;case"START":u.startTimeOffset=Si(V);break;case"MAP":var Ie=new Ge(V);if(dt(u,Ie,["BYTERANGE","URI"]),_.duration){var Re=new Lr(r,e);fn(Re,Ie,t,d),h=Re,_.initSegment=h,h.rawProgramDateTime&&!_.rawProgramDateTime&&(_.rawProgramDateTime=h.rawProgramDateTime)}else fn(_,Ie,t,d),h=_,w=!0;break;case"SERVER-CONTROL":var Ue=new Ge(V);u.canBlockReload=Ue.bool("CAN-BLOCK-RELOAD"),u.canSkipUntil=Ue.optionalFloat("CAN-SKIP-UNTIL",0),u.canSkipDateRanges=u.canSkipUntil>0&&Ue.bool("CAN-SKIP-DATERANGES"),u.partHoldBack=Ue.optionalFloat("PART-HOLD-BACK",0),u.holdBack=Ue.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var mt=new Ge(V);u.partTarget=mt.decimalFloatingPoint("PART-TARGET");break;case"PART":var rt=u.partList;rt||(rt=u.partList=[]);var Ut=y>0?rt[rt.length-1]:void 0,Ct=y++,xt=new Ge(V);dt(u,xt,["BYTERANGE","URI"]);var it=new ji(xt,_,e,Ct,Ut);rt.push(it),_.duration+=it.duration;break;case"PRELOAD-HINT":var st=new Ge(V);dt(u,st,["URI"]),u.preloadHint=st;break;case"RENDITION-REPORT":var Xt=new Ge(V);dt(u,Xt,["URI"]),u.renditionReports=u.renditionReports||[],u.renditionReports.push(Xt);break;default:P.warn("line parsed but not handled: "+o)}}}p&&!p.relurl?(c.pop(),T-=p.duration,u.partList&&(u.fragmentHint=p)):u.partList&&(hn(_,p),_.cc=A,u.fragmentHint=_,d&&vn(_,d,u));var dr=c.length,bt=c[0],Pi=c[dr-1];if((T+=u.skippedSegments*u.targetduration)>0&&dr&&Pi){u.averagetargetduration=T/dr;var Oi=Pi.sn;u.endSN=Oi!=="initSegment"?Oi:0,u.live||(Pi.endList=!0),bt&&(u.startCC=bt.cc)}else u.endSN=0,u.startCC=0;return u.fragmentHint&&(T+=u.fragmentHint.duration),u.totalduration=T,u.endCC=A,L>0&&function(Pn,Zr){for(var _r=Pn[Zr],Mi=Zr;Mi--;){var nr=Pn[Mi];if(!nr)return;nr.programDateTime=_r.programDateTime-1e3*nr.duration,_r=nr}}(c,L),u},s}();function dn(s,n,e){var t,r,i=new Ge(s);dt(e,i,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var a=(t=i.METHOD)!=null?t:"",o=i.URI,l=i.hexadecimalInteger("IV"),d=i.KEYFORMATVERSIONS,u=(r=i.KEYFORMAT)!=null?r:"identity";o&&i.IV&&!l&&P.error("Invalid IV: "+i.IV);var c=o?Mt.resolve(o,n):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Or(a,c,u,h,l)}function Si(s){var n=new Ge(s).decimalFloatingPoint("TIME-OFFSET");return Q(n)?n:null}function Nr(s,n){["video","audio","text"].forEach(function(e){var t=s.filter(function(i){return function(a,o){var l=zn[o];return!!l&&l[a.slice(0,4)]===!0}(i,e)});if(t.length){var r=t.filter(function(i){return i.lastIndexOf("avc1",0)===0||i.lastIndexOf("mp4a",0)===0});n[e+"Codec"]=r.length>0?r[0]:t[0],s=s.filter(function(i){return t.indexOf(i)===-1})}}),n.unknownCodecs=s}function cn(s,n,e){var t=n[e];t&&(s[e]=t)}function hn(s,n){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):n!=null&&n.programDateTime&&(s.programDateTime=n.endProgramDateTime),Q(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function fn(s,n,e,t){s.relurl=n.URI,n.BYTERANGE&&s.setByteRange(n.BYTERANGE),s.level=e,s.sn="initSegment",t&&(s.levelkeys=t),s.initSegment=null}function vn(s,n,e){s.levelkeys=n;var t=e.encryptedFragments;t.length&&t[t.length-1].levelkeys===n||!Object.keys(n).some(function(r){return n[r].isCommonEncryption})||t.push(s)}var Zt="manifest",er="level",kt="audioTrack",Rt="subtitleTrack",Ne="main",Ft="audio",Nt="subtitle";function gn(s){switch(s.type){case kt:return Ft;case Rt:return Nt;default:return Ne}}function Ur(s,n){var e=s.url;return e!==void 0&&e.indexOf("data:")!==0||(e=n.url),e}var mn=function(){function s(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}var n=s.prototype;return n.startLoad=function(e){},n.stopLoad=function(){this.destroyInternalLoaders()},n.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},n.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,a=new(r||i)(t);return this.loaders[e.type]=a,a},n.getInternalLoader=function(e){return this.loaders[e.type]},n.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},n.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},n.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},n.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Zt,url:r,deliveryDirectives:null})},n.onLevelLoading=function(e,t){var r=t.id,i=t.level,a=t.url,o=t.deliveryDirectives;this.load({id:r,level:i,responseType:"text",type:er,url:a,deliveryDirectives:o})},n.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,o=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:kt,url:a,deliveryDirectives:o})},n.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,o=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:Rt,url:a,deliveryDirectives:o})},n.load=function(e){var t,r,i,a=this,o=this.hls.config,l=this.getInternalLoader(e);if(l){var d=l.context;if(d&&d.url===e.url)return void P.trace("[playlist-loader]: playlist request ongoing");P.log("[playlist-loader]: aborting previous loader for type: "+e.type),l.abort()}if(r=e.type===Zt?o.manifestLoadPolicy.default:z({},o.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),l=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part&&(e.type===er&&e.level!==null?i=this.hls.levels[e.level].details:e.type===kt&&e.id!==null?i=this.hls.audioTracks[e.id].details:e.type===Rt&&e.id!==null&&(i=this.hls.subtitleTracks[e.id].details),i)){var u=i.partTarget,c=i.targetduration;if(u&&c){var h=1e3*Math.max(3*u,.8*c);r=z({},r,{maxTimeToFirstByteMs:Math.min(h,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,r.maxTimeToFirstByteMs)})}}var v=r.errorRetry||r.timeoutRetry||{},y={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:v.maxNumRetry||0,retryDelay:v.retryDelayMs||0,maxRetryDelay:v.maxRetryDelayMs||0},T={onSuccess:function(A,p,_,L){var w=a.getInternalLoader(_);a.resetInternalLoader(_.type);var x=A.data;x.indexOf("#EXTM3U")===0?(p.parsing.start=performance.now(),Mt.isMediaPlaylist(x)?a.handleTrackOrLevelPlaylist(A,p,_,L||null,w):a.handleMasterPlaylist(A,p,_,L)):a.handleManifestParsingError(A,_,new Error("no EXTM3U delimiter"),L||null,p)},onError:function(A,p,_,L){a.handleNetworkError(p,_,!1,A,L)},onTimeout:function(A,p,_){a.handleNetworkError(p,_,!0,void 0,A)}};l.load(e,y,T)},n.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,o=e.data,l=Ur(e,r),d=Mt.parseMasterPlaylist(o,l);if(d.playlistParsingError)this.handleManifestParsingError(e,r,d.playlistParsingError,i,t);else{var u=d.contentSteering,c=d.levels,h=d.sessionData,v=d.sessionKeys,y=d.startTimeOffset,T=d.variableList;this.variableList=T;var A=Mt.parseMasterPlaylistMedia(o,l,d),p=A.AUDIO,_=p===void 0?[]:p,L=A.SUBTITLES,w=A["CLOSED-CAPTIONS"];_.length&&(_.some(function(x){return!x.url})||!c[0].audioCodec||c[0].attrs.AUDIO||(P.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),_.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Ge({}),bitrate:0,url:""}))),a.trigger(E.MANIFEST_LOADED,{levels:c,audioTracks:_,subtitles:L,captions:w,contentSteering:u,url:l,stats:t,networkDetails:i,sessionData:h,sessionKeys:v,startTimeOffset:y,variableList:T})}},n.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var o=this.hls,l=r.id,d=r.level,u=r.type,c=Ur(e,r),h=Q(l)?l:0,v=Q(d)?d:h,y=gn(r),T=Mt.parseLevelPlaylist(e.data,c,v,y,h,this.variableList);if(u===Zt){var A={attrs:new Ge({}),bitrate:0,details:T,name:"",url:c};o.trigger(E.MANIFEST_LOADED,{levels:[A],audioTracks:[],url:c,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=T,this.handlePlaylistLoaded(T,e,t,r,i,a)},n.handleManifestParsingError=function(e,t,r,i,a){this.hls.trigger(E.ERROR,{type:te.NETWORK_ERROR,details:U.MANIFEST_PARSING_ERROR,fatal:t.type===Zt,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:a})},n.handleNetworkError=function(e,t,r,i,a){r===void 0&&(r=!1);var o="A network "+(r?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+e.type;e.type===er?o+=": "+e.level+" id: "+e.id:e.type!==kt&&e.type!==Rt||(o+=" id: "+e.id+' group-id: "'+e.groupId+'"');var l=new Error(o);P.warn("[playlist-loader]: "+o);var d=U.UNKNOWN,u=!1,c=this.getInternalLoader(e);switch(e.type){case Zt:d=r?U.MANIFEST_LOAD_TIMEOUT:U.MANIFEST_LOAD_ERROR,u=!0;break;case er:d=r?U.LEVEL_LOAD_TIMEOUT:U.LEVEL_LOAD_ERROR,u=!1;break;case kt:d=r?U.AUDIO_TRACK_LOAD_TIMEOUT:U.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case Rt:d=r?U.SUBTITLE_TRACK_LOAD_TIMEOUT:U.SUBTITLE_LOAD_ERROR,u=!1}c&&this.resetInternalLoader(e.type);var h={type:te.NETWORK_ERROR,details:d,fatal:u,url:e.url,loader:c,context:e,error:l,networkDetails:t,stats:a};if(i){var v=(t==null?void 0:t.url)||e.url;h.response=H({url:v,data:void 0},i)}this.hls.trigger(E.ERROR,h)},n.handlePlaylistLoaded=function(e,t,r,i,a,o){var l=this.hls,d=i.type,u=i.level,c=i.id,h=i.groupId,v=i.deliveryDirectives,y=Ur(t,i),T=gn(i),A=typeof i.level=="number"&&T===Ne?u:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var p=e.playlistParsingError;if(p)l.trigger(E.ERROR,{type:te.NETWORK_ERROR,details:U.LEVEL_PARSING_ERROR,fatal:!1,url:y,error:p,reason:p.message,response:t,context:i,level:A,parent:T,networkDetails:a,stats:r});else switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),o.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),d){case Zt:case er:l.trigger(E.LEVEL_LOADED,{details:e,level:A||0,id:c||0,stats:r,networkDetails:a,deliveryDirectives:v});break;case kt:l.trigger(E.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:h||"",stats:r,networkDetails:a,deliveryDirectives:v});break;case Rt:l.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:h||"",stats:r,networkDetails:a,deliveryDirectives:v})}}else{var _=new Error("No Segments found in Playlist");l.trigger(E.ERROR,{type:te.NETWORK_ERROR,details:U.LEVEL_EMPTY_ERROR,fatal:!1,url:y,error:_,reason:_.message,response:t,context:i,level:A,parent:T,networkDetails:a,stats:r})}},s}();function Br(s,n){var e;try{e=new Event("addtrack")}catch{(e=document.createEvent("Event")).initEvent("addtrack",!1,!1)}e.track=s,n.dispatchEvent(e)}function pn(s,n){var e=s.mode;if(e==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(n.id))try{if(s.addCue(n),!s.cues.getCueById(n.id))throw new Error("addCue is failed for: "+n)}catch(r){P.debug("[texttrack-utils]: "+r);var t=new self.TextTrackCue(n.startTime,n.endTime,n.text);t.id=n.id,s.addCue(t)}e==="disabled"&&(s.mode=e)}function sr(s){var n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues)for(var e=s.cues.length;e--;)s.removeCue(s.cues[e]);n==="disabled"&&(s.mode=n)}function Xe(s,n,e,t){var r=s.mode;if(r==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0)for(var i=function(o,l,d){var u=[],c=function(T,A){if(A<T[0].startTime)return 0;var p=T.length-1;if(A>T[p].endTime)return-1;for(var _=0,L=p;_<=L;){var w=Math.floor((L+_)/2);if(A<T[w].startTime)L=w-1;else{if(!(A>T[w].startTime&&_<p))return w;_=w+1}}return T[_].startTime-A<A-T[L].startTime?_:L}(o,l);if(c>-1)for(var h=c,v=o.length;h<v;h++){var y=o[h];if(y.startTime>=l&&y.endTime<=d)u.push(y);else if(y.startTime>d)return u}return u}(s.cues,n,e),a=0;a<i.length;a++)t&&!t(i[a])||s.removeCue(i[a]);r==="disabled"&&(s.mode=r)}var Vt="org.id3",Xn="com.apple.quicktime.HLS",fr="https://aomedia.org/emsg/ID3";function Ai(){if(typeof self!="undefined")return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var Gr=function(){var s=Ai();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function tr(s,n){return s.getTime()/1e3-n}var ki=function(){function s(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var n=s.prototype;return n.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},n._registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)},n._unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this)},n.onMediaAttached=function(e,t){this.media=t.media},n.onMediaDetaching=function(){this.id3Track&&(sr(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},n.onManifestLoading=function(){this.dateRangeCuesAppended={}},n.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},n.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Br(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},n.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,a=r.enableID3MetadataCues;if(i||a){var o=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var l=Ai(),d=0;d<o.length;d++){var u=o[d].type;if((u!==fr||i)&&a){var c=Ji(o[d].data);if(c){var h=o[d].pts,v=h+o[d].duration;v>Gr&&(v=Gr),v-h<=0&&(v=h+.25);for(var y=0;y<c.length;y++){var T=c[y];if(!Xi(T)){this.updateId3CueEnds(h);var A=new l(h,v,"");A.value=T,u&&(A.type=u),this.id3Track.addCue(A)}}}}}}}},n.updateId3CueEnds=function(e){var t,r=(t=this.id3Track)==null?void 0:t.cues;if(r)for(var i=r.length;i--;){var a=r[i];a.startTime<e&&a.endTime===Gr&&(a.endTime=e)}},n.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.type,o=this.id3Track,l=this.hls;if(l){var d=l.config,u=d.enableEmsgMetadataCues,c=d.enableID3MetadataCues;o&&(u||c)&&Xe(o,r,i,a==="audio"?function(h){return h.type===Vt&&c}:a==="video"?function(h){return h.type===fr&&u}:function(h){return h.type===Vt&&c||h.type===fr&&u})}},n.onLevelUpdated=function(e,t){var r=this,i=t.details;if(this.media&&i.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,o=this.id3Track,l=i.dateRanges,d=Object.keys(l);if(o)for(var u=Object.keys(a).filter(function(_){return!d.includes(_)}),c=function(_){var L=u[_];Object.keys(a[L].cues).forEach(function(w){o.removeCue(a[L].cues[w])}),delete a[L]},h=u.length;h--;)c(h);var v=i.fragments[i.fragments.length-1];if(d.length!==0&&Q(v==null?void 0:v.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var y=v.programDateTime/1e3-v.start,T=Ai(),A=function(_){var L=d[_],w=l[L],x=a[L],F=(x==null?void 0:x.cues)||{},G=(x==null?void 0:x.durationKnown)||!1,W=tr(w.startDate,y),q=Gr,V=w.endDate;if(V)q=tr(V,y),G=!0;else if(w.endOnNext&&!G){var Z=d.reduce(function(Ae,Ie){var Re=l[Ie];return Re.class===w.class&&Re.id!==Ie&&Re.startDate>w.startDate&&Ae.push(Re),Ae},[]).sort(function(Ae,Ie){return Ae.startDate.getTime()-Ie.startDate.getTime()})[0];Z&&(q=tr(Z.startDate,y),G=!0)}for(var X,ie,ye=Object.keys(w.attr),ae=0;ae<ye.length;ae++){var pe=ye[ae];if((ie=pe)!=="ID"&&ie!=="CLASS"&&ie!=="START-DATE"&&ie!=="DURATION"&&ie!=="END-DATE"&&ie!=="END-ON-NEXT"){var oe=F[pe];if(oe)G&&!x.durationKnown&&(oe.endTime=q);else{var me=w.attr[pe];oe=new T(W,q,""),Kt(pe)&&(X=me,me=Uint8Array.from(X.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),oe.value={key:pe,data:me},oe.type=Xn,oe.id=L,r.id3Track.addCue(oe),F[pe]=oe}}}a[L]={cues:F,dateRange:w,durationKnown:G}},p=0;p<d.length;p++)A(p)}}},s}(),yn=function(){function s(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 n=s.prototype;return n.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},n.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(E.ERROR,this.onError,this)},n.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(E.ERROR,this.onError,this)},n.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},n.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},n.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},n.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},n.onError=function(e,t){var r;t.details===U.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&P.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},n.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(r!==null){this._latency=r;var i=this.config,a=i.lowLatencyMode,o=i.maxLiveSyncPlaybackRate;if(a&&o!==1){var l=this.targetLatency;if(l!==null){var d=r-l,u=d<Math.min(this.maxLatency,l+t.targetduration);if(t.live&&u&&d>.05&&this.forwardBufferLength>1){var c=Math.min(2,Math.max(1,o)),h=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,h))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}}}}},n.estimateLiveEdge=function(){var e=this.levelDetails;return e===null?null:e.edge+e.age},n.computeLatency=function(){var e=this.estimateLiveEdge();return e===null?null:e-this.currentTime},j(s,[{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,r=e.partHoldBack,i=e.targetduration,a=this.config,o=a.liveSyncDuration,l=a.liveSyncDurationCount,d=a.lowLatencyMode,u=this.hls.userConfig,c=d&&r||t;(u.liveSyncDuration||u.liveSyncDurationCount||c===0)&&(c=o!==void 0?o:l*i);var h=i;return c+Math.min(1*this.stallCount,h)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;var i=r.edge,a=e-t-this.edgeStalled,o=i-r.totalduration,l=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(o,a),l)}},{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 r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}]),s}(),Hr=["NONE","TYPE-0","TYPE-1",null],Yt="",Qn="YES",Jn="v2",Tn=function(){function s(n,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=n,this.part=e,this.skip=t}return s.prototype.addDirectives=function(n){var e=new self.URL(n);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},s}(),Kr=function(){function s(n){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=[n.url],this._attrs=[n.attrs],this.bitrate=n.bitrate,n.details&&(this.details=n.details),this.id=n.id||0,this.name=n.name,this.width=n.width||0,this.height=n.height||0,this.audioCodec=n.audioCodec,this.videoCodec=n.videoCodec,this.unknownCodecs=n.unknownCodecs,this.codecSet=[n.videoCodec,n.audioCodec].filter(function(e){return e}).join(",").replace(/\.[^.,]+/g,"")}return s.prototype.addFallback=function(n){this.url.push(n.url),this._attrs.push(n.attrs)},j(s,[{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(n){var e=n%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.details=void 0,this._urlId=e)}},{key:"audioGroupId",get:function(){var n;return(n=this.audioGroupIds)==null?void 0:n[this.urlId]}},{key:"textGroupId",get:function(){var n;return(n=this.textGroupIds)==null?void 0:n[this.urlId]}}]),s}();function Ri(s,n){var e=n.startPTS;if(Q(e)){var t,r=0;n.sn>s.sn?(r=e-s.start,t=s):(r=s.start-e,t=n),t.duration!==r&&(t.duration=r)}else n.sn>s.sn?s.cc===n.cc&&s.minEndPTS?n.start=s.start+(s.minEndPTS-s.start):n.start=s.start+s.duration:n.start=Math.max(s.start-n.duration,0)}function En(s,n,e,t,r,i){t-e<=0&&(P.warn("Fragment should have a positive duration",n),t=e+n.duration,i=r+n.duration);var a=e,o=t,l=n.startPTS,d=n.endPTS;if(Q(l)){var u=Math.abs(l-e);Q(n.deltaPTS)?n.deltaPTS=Math.max(u,n.deltaPTS):n.deltaPTS=u,a=Math.max(e,l),e=Math.min(e,l),r=Math.min(r,n.startDTS),o=Math.min(t,d),t=Math.max(t,d),i=Math.max(i,n.endDTS)}n.duration=t-e;var c=e-n.start;n.start=n.startPTS=e,n.maxStartPTS=a,n.startDTS=r,n.endPTS=t,n.minEndPTS=o,n.endDTS=i;var h,v=n.sn;if(!s||v<s.startSN||v>s.endSN)return 0;var y=v-s.startSN,T=s.fragments;for(T[y]=n,h=y;h>0;h--)Ri(T[h],T[h-1]);for(h=y;h<T.length-1;h++)Ri(T[h],T[h+1]);return s.fragmentHint&&Ri(T[T.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,c}function $n(s,n){for(var e=null,t=s.fragments,r=t.length-1;r>=0;r--){var i=t[r].initSegment;if(i){e=i;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;var a,o,l,d,u,c=0;if(function(p,_,L){for(var w=_.skippedSegments,x=Math.max(p.startSN,_.startSN)-_.startSN,F=(p.fragmentHint?1:0)+(w?_.endSN:Math.min(p.endSN,_.endSN))-_.startSN,G=_.startSN-p.startSN,W=_.fragmentHint?_.fragments.concat(_.fragmentHint):_.fragments,q=p.fragmentHint?p.fragments.concat(p.fragmentHint):p.fragments,V=x;V<=F;V++){var Z=q[G+V],X=W[V];w&&!X&&V<w&&(X=_.fragments[V]=Z),Z&&X&&L(Z,X)}}(s,n,function(p,_){p.relurl&&(c=p.cc-_.cc),Q(p.startPTS)&&Q(p.endPTS)&&(_.start=_.startPTS=p.startPTS,_.startDTS=p.startDTS,_.maxStartPTS=p.maxStartPTS,_.endPTS=p.endPTS,_.endDTS=p.endDTS,_.minEndPTS=p.minEndPTS,_.duration=p.endPTS-p.startPTS,_.duration&&(a=_),n.PTSKnown=n.alignedSliding=!0),_.elementaryStreams=p.elementaryStreams,_.loader=p.loader,_.stats=p.stats,_.urlId=p.urlId,p.initSegment&&(_.initSegment=p.initSegment,e=p.initSegment)}),e&&(n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments).forEach(function(p){var _;p.initSegment&&p.initSegment.relurl!==((_=e)==null?void 0:_.relurl)||(p.initSegment=e)}),n.skippedSegments)if(n.deltaUpdateFailed=n.fragments.some(function(p){return!p}),n.deltaUpdateFailed){P.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var h=n.skippedSegments;h--;)n.fragments.shift();n.startSN=n.fragments[0].sn,n.startCC=n.fragments[0].cc}else n.canSkipDateRanges&&(n.dateRanges=(o=s.dateRanges,l=n.dateRanges,d=n.recentlyRemovedDateranges,u=z({},o),d&&d.forEach(function(p){delete u[p]}),Object.keys(l).forEach(function(p){var _=new cr(l[p].attr,u[p]);_.isValid?u[p]=_:P.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(l[p].attr)+'"')}),u));var v=n.fragments;if(c){P.warn("discontinuity sliding from playlist, take drift into account");for(var y=0;y<v.length;y++)v[y].cc+=c}n.skippedSegments&&(n.startCC=n.fragments[0].cc),function(p,_,L){if(p&&_)for(var w=0,x=0,F=p.length;x<=F;x++){var G=p[x],W=_[x+w];G&&W&&G.index===W.index&&G.fragment.sn===W.fragment.sn?L(G,W):w--}}(s.partList,n.partList,function(p,_){_.elementaryStreams=p.elementaryStreams,_.stats=p.stats}),a?En(n,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):_n(s,n),v.length&&(n.totalduration=n.edge-v[0].start),n.driftStartTime=s.driftStartTime,n.driftStart=s.driftStart;var T=n.advancedDateTime;if(n.advanced&&T){var A=n.edge;n.driftStart||(n.driftStartTime=T,n.driftStart=A),n.driftEndTime=T,n.driftEnd=A}else n.driftEndTime=s.driftEndTime,n.driftEnd=s.driftEnd,n.advancedDateTime=s.advancedDateTime}function _n(s,n){var e=n.startSN+n.skippedSegments-s.startSN,t=s.fragments;e<0||e>=t.length||Li(n,t[e].start)}function Li(s,n){if(n){for(var e=s.fragments,t=s.skippedSegments;t<e.length;t++)e[t].start+=n;s.fragmentHint&&(s.fragmentHint.start+=n)}}function vr(s,n,e){var t;return s!=null&&s.details?qr((t=s.details)==null?void 0:t.partList,n,e):null}function qr(s,n,e){if(s)for(var t=s.length;t--;){var r=s[t];if(r.index===e&&r.fragment.sn===n)return r}return null}function gr(s){switch(s.details){case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_TIMEOUT:case U.LEVEL_LOAD_TIMEOUT:case U.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function jr(s,n){var e=gr(n);return s.default[(e?"timeout":"error")+"Retry"]}function wi(s,n){var e=s.backoff==="linear"?1:Math.pow(2,n);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function bn(s){return H(H({},s),{errorRetry:null,timeoutRetry:null})}function Vr(s,n,e,t){return!!s&&n<s.maxNumRetry&&(function(r){return r===0&&navigator.onLine===!1||!!r&&(r<400||r>499)}(t)||!!e)}var Sn=function(s,n){for(var e=0,t=s.length-1,r=null,i=null;e<=t;){var a=n(i=s[r=(e+t)/2|0]);if(a>0)e=r+1;else{if(!(a<0))return i;t=r-1}}return null};function mr(s,n,e,t){e===void 0&&(e=0),t===void 0&&(t=0);var r=null;if(s?r=n[s.sn-n[0].sn+1]||null:e===0&&n[0].start===0&&(r=n[0]),r&&Di(e,t,r)===0)return r;var i=Sn(n,Di.bind(null,e,t));return!i||i===s&&r?r:i}function Di(s,n,e){if(s===void 0&&(s=0),n===void 0&&(n=0),e.start<=s&&e.start+e.duration>s)return 0;var t=Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-t<=s?1:e.start-t>s&&e.start?-1:0}function Zn(s,n,e){var t=1e3*Math.min(n,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>s}var Ii,ea=3e5,Yr=0,Ze=2,Wt=5,or=0,Wr=1,m=2,f=function(){function s(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=P.log.bind(P,"[info]:"),this.warn=P.warn.bind(P,"[warning]:"),this.error=P.error.bind(P,"[error]:"),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this))},n.destroy=function(){this.unregisterListeners(),this.hls=null},n.startLoad=function(e){this.playlistError=0},n.stopLoad=function(){},n.getVariantLevelIndex=function(e){return(e==null?void 0:e.type)===Ne?e.level:this.hls.loadLevel},n.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},n.onError=function(e,t){var r;if(!t.fatal){var i=this.hls,a=t.context;switch(t.details){case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case U.FRAG_GAP:case U.FRAG_PARSING_ERROR:case U.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=Ze);case U.LEVEL_EMPTY_ERROR:case U.LEVEL_PARSING_ERROR:var o,l,d=t.parent===Ne?t.level:i.loadLevel;return void(t.details===U.LEVEL_EMPTY_ERROR&&(o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d)));case U.LEVEL_LOAD_ERROR:case U.LEVEL_LOAD_TIMEOUT:return void(typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case U.AUDIO_TRACK_LOAD_ERROR:case U.AUDIO_TRACK_LOAD_TIMEOUT:case U.SUBTITLE_LOAD_ERROR:case U.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var u=i.levels[i.loadLevel];if(u&&(a.type===kt&&a.groupId===u.audioGroupId||a.type===Rt&&a.groupId===u.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=Ze,void(t.errorAction.flags=Wr)}return;case U.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var c=i.levels[i.loadLevel],h=c==null?void 0:c.attrs["HDCP-LEVEL"];return void(h&&(t.errorAction={action:Ze,flags:m,hdcpLevel:h}));case U.BUFFER_ADD_CODEC_ERROR:case U.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:i.loadLevel));case U.INTERNAL_EXCEPTION:case U.BUFFER_APPENDING_ERROR:case U.BUFFER_APPEND_ERROR:case U.BUFFER_FULL_ERROR:case U.LEVEL_SWITCH_ERROR:case U.BUFFER_STALLED_ERROR:case U.BUFFER_SEEK_OVER_HOLE:case U.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:Yr,flags:or})}if(t.type===te.KEY_SYSTEM_ERROR){var v=this.getVariantLevelIndex(t.frag);return t.levelRetry=!1,void(t.errorAction=this.getLevelSwitchAction(t,v))}}},n.getPlaylistRetryOrSwitchAction=function(e,t){var r,i,a=jr(this.hls.config.playlistLoadPolicy,e),o=this.playlistError++,l=(r=e.response)==null?void 0:r.code;return Vr(a,o,gr(e),l)?{action:Wt,flags:or,retryConfig:a,retryCount:o}:(i=e.context)!=null&&i.deliveryDirectives?{action:Yr,flags:or,retryConfig:a||{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},retryCount:o}:this.getLevelSwitchAction(e,t)},n.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],a=t.config,o=a.fragLoadPolicy,l=a.keyLoadPolicy,d=jr(e.details.startsWith("key")?l:o,e),u=t.levels.reduce(function(y,T){return y+T.fragmentError},0);if(i){var c;e.details!==U.FRAG_GAP&&i.fragmentError++;var h=(c=e.response)==null?void 0:c.code;if(Vr(d,u,gr(e),h))return{action:Wt,flags:or,retryConfig:d,retryCount:u}}var v=this.getLevelSwitchAction(e,r);return d&&(v.retryConfig=d,v.retryCount=u),v},n.getLevelSwitchAction=function(e,t){var r=this.hls;t==null&&(t=r.loadLevel);var i=this.hls.levels[t];if(i&&(e.details!==U.FRAG_GAP&&i.loadError++,r.autoLevelEnabled)){for(var a,o,l=-1,d=r.levels,u=(a=e.frag)==null?void 0:a.type,c=(o=e.context)!=null?o:{},h=c.type,v=c.groupId,y=d.length;y--;){var T=(y+r.loadLevel)%d.length;if(T!==r.loadLevel&&d[T].loadError===0){var A=d[T];if(e.details===U.FRAG_GAP&&e.frag){var p=d[T].details;if(p){var _=mr(e.frag,p.fragments,e.frag.start);if(_!=null&&_.gap)continue}}else if(h===kt&&v===A.audioGroupId||h===Rt&&v===A.textGroupId||u===Ft&&i.audioGroupId===A.audioGroupId||u===Nt&&i.textGroupId===A.textGroupId)continue;l=T;break}}if(l>-1&&r.loadLevel!==l)return e.levelRetry=!0,{action:Ze,flags:or,nextAutoLevel:l}}return{action:Ze,flags:Wr}},n.onErrorOut=function(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case Yr:break;case Ze:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===U.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()},n.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.flags,a=r.hdcpLevel,o=r.nextAutoLevel;switch(i){case or:this.switchLevel(e,o);break;case Wr:r.resolved||(r.resolved=this.redundantFailover(e));break;case m:a&&(t.maxHdcpLevel=Hr[Hr.indexOf(a)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(e,o)}},n.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)},n.redundantFailover=function(e){var t=this,r=this.hls,i=this.penalizedRenditions,a=e.parent===Ne?e.level:r.loadLevel,o=r.levels[a],l=o.url.length;this.penalizeRendition(o,e);for(var d=function(h){var v=(o.urlId+h)%l,y=i[v];if(!y||function(T,A,p){if(performance.now()-T.lastErrorPerfMs>ea)return!0;var _=T.details;if(A.details===U.FRAG_GAP&&_&&A.frag){var L=A.frag.start,w=mr(null,_.fragments,L);if(w&&!w.gap)return!0}if(p&&T.errors.length<p.errors.length){var x=T.errors[T.errors.length-1];if(_&&x.frag&&A.frag&&Math.abs(x.frag.start-A.frag.start)>3*_.targetduration)return!0}return!1}(y,e,i[o.urlId]))return t.warn("Switching to Redundant Stream "+(v+1)+"/"+l+': "'+o.url[v]+'" after '+e.details),t.playlistError=0,r.levels.forEach(function(T){T.urlId=v}),r.nextLoadLevel=a,{v:!0}},u=1;u<l;u++){var c=d(u);if(typeof c=="object")return c.v}return!1},n.penalizeRendition=function(e,t){var r=this.penalizedRenditions,i=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(t),i.details=e.details,r[e.urlId]=i},s}(),g=function(){function s(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=P.log.bind(P,t+":"),this.warn=P.warn.bind(P,t+":"),this.hls=e}var n=s.prototype;return n.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},n.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},n.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},n.stopLoad=function(){this.canLoad=!1,this.clearTimer()},n.switchParams=function(e,t){var r=t==null?void 0:t.renditionReports;if(r){for(var i=-1,a=0;a<r.length;a++){var o=r[a],l=void 0;try{l=new self.URL(o.URI,t.url).href}catch(v){P.warn("Could not construct new URL for Rendition Report: "+v),l=o.URI||""}if(l===e){i=a;break}l===e.substring(0,l.length)&&(i=a)}if(i!==-1){var d=r[i],u=parseInt(d["LAST-MSN"])||(t==null?void 0:t.lastPartSn),c=parseInt(d["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);c>=0&&h>t.partTarget&&(c+=1)}return new Tn(u,c>=0?c:void 0,Yt)}}},n.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},n.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},n.shouldReloadPlaylist=function(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)},n.playlistLoaded=function(e,t,r){var i=this,a=t.details,o=t.stats,l=self.performance.now(),d=o.loading.first?Math.max(0,l-o.loading.first):0;if(a.advancedDateTime=Date.now()-d,a.live||r!=null&&r.live){if(a.reloaded(r),r&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),r&&a.fragments.length>0&&$n(r,a),!this.canLoad||!a.live)return;var u,c=void 0,h=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var v=this.hls.config.lowLatencyMode,y=a.lastPartSn,T=a.endSN,A=a.lastPartIndex,p=y===T;A!==-1?(c=p?T+1:y,h=p?v?0:A:A+1):c=T+1;var _=a.age,L=_+a.ageHeader,w=Math.min(L-a.partTarget,1.5*a.targetduration);if(w>0){if(r&&w>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+w+" with playlist age: "+a.age),w=0;else{var x=Math.floor(w/a.targetduration);c+=x,h!==void 0&&(h+=Math.round(w%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+_.toFixed(2)+"s goal: "+w+" skip sn "+x+" to part "+h)}a.tuneInGoal=w}if(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,h),v||!p)return void this.loadPlaylist(u)}else a.canBlockReload&&(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,h));var F=this.hls.mainForwardBufferInfo,G=F?F.end-F.len:0,W=function(V,Z){Z===void 0&&(Z=1/0);var X=1e3*V.targetduration;if(V.updated){var ie=V.fragments;if(ie.length&&4*X>Z){var ye=1e3*ie[ie.length-1].duration;ye<X&&(X=ye)}}else X/=2;return Math.round(X)}(a,1e3*(a.edge-G));a.updated&&l>this.requestScheduled+W&&(this.requestScheduled=o.loading.start),c!==void 0&&a.canBlockReload?this.requestScheduled=o.loading.first+W-(1e3*a.partTarget||1e3):this.requestScheduled===-1||this.requestScheduled+W<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=W);var q=this.requestScheduled-l;q=Math.max(0,q),this.log("reload live playlist "+e+" in "+Math.round(q)+" ms"),this.timer=self.setTimeout(function(){return i.loadPlaylist(u)},q)}else this.clearTimer()},n.getDeliveryDirectives=function(e,t,r,i){var a=function(o,l){var d=o.canSkipUntil,u=o.canSkipDateRanges,c=o.endSN;return d&&(l!==void 0?l-c:0)<d?u?Jn:Qn:Yt}(e,r);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=Yt),new Tn(r,i,a)},n.checkRetry=function(e){var t=this,r=e.details,i=gr(e),a=e.errorAction,o=a||{},l=o.action,d=o.retryCount,u=d===void 0?0:d,c=o.retryConfig,h=l===Wt&&!!a&&!!c;if(h){var v;if(this.requestScheduled=-1,i&&(v=e.context)!=null&&v.deliveryDirectives)this.warn("Retrying playlist loading "+(u+1)+"/"+c.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var y=wi(c,u);this.timer=self.setTimeout(function(){return t.loadPlaylist()},y),this.warn("Retrying playlist loading "+(u+1)+"/"+c.maxNumRetry+' after "'+r+'" in '+y+"ms")}e.levelRetry=!0,a.resolved=!0}return h},s}(),b=function(s){function n(t,r){var i;return(i=s.call(this,t,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}fe(n,s);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(E.FRAG_LOADED,this.onFragLoaded,this),t.on(E.ERROR,this.onError,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(E.FRAG_LOADED,this.onFragLoaded,this),t.off(E.ERROR,this.onError,this)},e.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),s.prototype.destroy.call(this)},e.startLoad=function(){this._levels.forEach(function(t){t.loadError=0,t.fragmentError=0}),s.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,r){this.resetLevels()},e.onManifestLoaded=function(t,r){var i,a=[],o={};r.levels.forEach(function(l){var d,u=l.attrs;((d=l.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(Ii||(Ii=/chrome|firefox/i.test(navigator.userAgent)),Ii&&(l.audioCodec=void 0));var c=u.AUDIO,h=u.CODECS,v=u["FRAME-RATE"],y=u["PATHWAY-ID"],T=u.RESOLUTION,A=u.SUBTITLES,p=(y||".")+"-"+l.bitrate+"-"+T+"-"+v+"-"+h;(i=o[p])?i.addFallback(l):(i=new Kr(l),o[p]=i,a.push(i)),S(i,"audio",c),S(i,"text",A)}),this.filterAndSortMediaOptions(a,r)},e.filterAndSortMediaOptions=function(t,r){var i=this,a=[],o=[],l=!1,d=!1,u=!1,c=t.filter(function(_){var L=_.audioCodec,w=_.videoCodec,x=_.width,F=_.height,G=_.unknownCodecs;return l||(l=!(!x||!F)),d||(d=!!w),u||(u=!!L),!(G!=null&&G.length)&&(!L||Fr(L,"audio"))&&(!w||Fr(w,"video"))});if((l||d)&&u&&(c=c.filter(function(_){var L=_.videoCodec,w=_.width,x=_.height;return!!L||!(!w||!x)})),c.length!==0){r.audioTracks&&R(a=r.audioTracks.filter(function(_){return!_.audioCodec||Fr(_.audioCodec,"audio")})),r.subtitles&&R(o=r.subtitles);var h=c.slice(0);c.sort(function(_,L){return _.attrs["HDCP-LEVEL"]!==L.attrs["HDCP-LEVEL"]?(_.attrs["HDCP-LEVEL"]||"")>(L.attrs["HDCP-LEVEL"]||"")?1:-1:_.bitrate!==L.bitrate?_.bitrate-L.bitrate:_.attrs["FRAME-RATE"]!==L.attrs["FRAME-RATE"]?_.attrs.decimalFloatingPoint("FRAME-RATE")-L.attrs.decimalFloatingPoint("FRAME-RATE"):_.attrs.SCORE!==L.attrs.SCORE?_.attrs.decimalFloatingPoint("SCORE")-L.attrs.decimalFloatingPoint("SCORE"):l&&_.height!==L.height?_.height-L.height:0});var v=h[0];if(this.steering&&(c=this.steering.filterParsedLevels(c)).length!==h.length){for(var y=0;y<h.length;y++)if(h[y].pathwayId===c[0].pathwayId){v=h[y];break}}this._levels=c;for(var T=0;T<c.length;T++)if(c[T]===v){this._firstLevel=T,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+v.bitrate);break}var A=u&&!d,p={levels:c,audioTracks:a,subtitleTracks:o,sessionData:r.sessionData,sessionKeys:r.sessionKeys,firstLevel:this._firstLevel,stats:r.stats,audio:u,video:d,altAudio:!A&&a.some(function(_){return!!_.url})};this.hls.trigger(E.MANIFEST_PARSED,p),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then(function(){if(i.hls){var _=new Error("no level with compatible codecs found in manifest");i.hls.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:_,reason:_.message})}})},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===er&&r.context.level===this.level&&this.checkRetry(r)},e.onFragLoaded=function(t,r){var i=r.frag;if(i!==void 0&&i.type===Ne){var a=this._levels[i.level];a!==void 0&&(a.loadError=0)}},e.onLevelLoaded=function(t,r){var i,a,o=r.level,l=r.details,d=this._levels[o];if(!d)return this.warn("Invalid level index "+o),void((a=r.deliveryDirectives)!=null&&a.skip&&(l.deltaUpdateFailed=!0));o===this.currentLevelIndex?(d.fragmentError===0&&(d.loadError=0),this.playlistLoaded(o,r,d.details)):(i=r.deliveryDirectives)!=null&&i.skip&&(l.deltaUpdateFailed=!0)},e.onAudioTrackSwitched=function(t,r){var i=this.currentLevel;if(i){var a=this.hls.audioTracks[r.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==a){for(var o=-1,l=0;l<i.audioGroupIds.length;l++)if(i.audioGroupIds[l]===a){o=l;break}o!==-1&&o!==i.urlId&&(i.urlId=o,this.canLoad&&this.startLoad())}}},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var a=i.urlId,o=i.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn("Could not construct new URL with HLS Delivery Directives: "+d)}var l=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+((t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:"")+" with"+(l?" Pathway "+l:"")+" URI "+(a+1)+"/"+i.url.length+" "+o),this.clearTimer(),this.hls.trigger(E.LEVEL_LOADING,{url:o,level:r,id:a,deliveryDirectives:t||null})}},e.removeLevel=function(t,r){var i=this,a=function(l,d){return d!==r},o=this._levels.filter(function(l,d){return d!==t||(l.url.length>1&&r!==void 0?(l.url=l.url.filter(a),l.audioGroupIds&&(l.audioGroupIds=l.audioGroupIds.filter(a)),l.textGroupIds&&(l.textGroupIds=l.textGroupIds.filter(a)),l.urlId=0,!0):(i.steering&&i.steering.removeLevel(l),!1))});this.hls.trigger(E.LEVELS_UPDATED,{levels:o})},e.onLevelsUpdated=function(t,r){var i=r.levels;i.forEach(function(a,o){var l=a.details;l!=null&&l.fragments&&l.fragments.forEach(function(d){d.level=o})}),this._levels=i},j(n,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var r=this._levels;if(r.length!==0){if(t<0||t>=r.length){var i=new Error("invalid level idx"),a=t<0;if(this.hls.trigger(E.ERROR,{type:te.OTHER_ERROR,details:U.LEVEL_SWITCH_ERROR,level:t,fatal:a,error:i,reason:i.message}),a)return;t=Math.min(t,r.length-1)}var o=this.currentLevelIndex,l=this.currentLevel,d=l?l.attrs["PATHWAY-ID"]:void 0,u=r[t],c=u.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=u,o!==t||!u.details||!l||d!==c){this.log("Switching to level "+t+(c?" with Pathway "+c:"")+" from level "+o+(d?" with Pathway "+d:""));var h=z({},u,{level:t,maxBitrate:u.maxBitrate,attrs:u.attrs,uri:u.uri,urlId:u.urlId});delete h._attrs,delete h._urlId,this.hls.trigger(E.LEVEL_SWITCHING,h);var v=u.details;if(!v||v.live){var y=this.switchParams(u.uri,l==null?void 0:l.details);this.loadPlaylist(y)}}}}},{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)}}]),n}(g);function S(s,n,e){e&&(n==="audio"?(s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds[s.url.length-1]=e):n==="text"&&(s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds[s.url.length-1]=e))}function R(s){var n={};s.forEach(function(e){var t=e.groupId||"";e.id=n[t]=n[t]||0,n[t]++})}var k="NOT_LOADED",C="APPENDING",N="PARTIAL",O="OK",Y=function(){function s(e){this.mainFragEntity=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}var n=s.prototype;return n._registerListeners=function(){var e=this.hls;e.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this)},n._unregisterListeners=function(){var e=this.hls;e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this)},n.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.mainFragEntity=this.activeParts=null},n.getAppendedFrag=function(e,t){if(t===Ne){var r=this.mainFragEntity,i=this.activeParts;if(r){if(r&&i)for(var a=i.length;a--;){var o=i[a],l=o?o.end:r.appendedPTS;if(o.start<=e&&l!==null&&e<=l)return a>9&&(this.activeParts=i.slice(a-9)),o}else if(r.body.start<=e&&r.appendedPTS!==null&&e<=r.appendedPTS)return r.body}}return this.getBufferedFrag(e,t)},n.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),a=i.length;a--;){var o=r[i[a]];if((o==null?void 0:o.body.type)===t&&o.buffered){var l=o.body;if(l.start<=e&&e<=l.end)return l}}return null},n.detectEvictedFragments=function(e,t,r){var i=this;this.timeRanges&&(this.timeRanges[e]=t),Object.keys(this.fragments).forEach(function(a){var o=i.fragments[a];if(o)if(o.buffered||o.loaded){var l=o.range[e];l&&l.time.some(function(d){var u=!i.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&i.removeFragment(o.body),u})}else o.body.type===r&&i.removeFragment(o.body)})},n.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,a=e.part;if(r&&i.sn!=="initSegment"){var o=re(i),l=this.fragments[o];l&&(Object.keys(r).forEach(function(d){var u=i.elementaryStreams[d];if(u){var c=r[d],h=a!==null||u.partial===!0;l.range[d]=t.getBufferedTimes(i,a,h,c)}}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,l.body.endList&&(this.endListFragments[l.body.type]=l)):this.removeFragment(l.body))}},n.fragBuffered=function(e,t){var r=re(e),i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)}),i&&(i.loaded=null,i.buffered=!0)},n.getBufferedTimes=function(e,t,r,i){for(var a={time:[],partial:r},o=t?t.start:e.start,l=t?t.end:e.end,d=e.minEndPTS||l,u=e.maxStartPTS||o,c=0;c<i.length;c++){var h=i.start(c)-this.bufferPadding,v=i.end(c)+this.bufferPadding;if(u>=h&&d<=v){a.time.push({startPTS:Math.max(o,i.start(c)),endPTS:Math.min(l,i.end(c))});break}if(o<v&&l>h)a.partial=!0,a.time.push({startPTS:Math.max(o,i.start(c)),endPTS:Math.min(l,i.end(c))});else if(l<=h)break}return a},n.getPartialFragment=function(e){var t,r,i,a=null,o=0,l=this.bufferPadding,d=this.fragments;return Object.keys(d).forEach(function(u){var c=d[u];c&&ge(c)&&(r=c.body.start-l,i=c.body.end+l,e>=r&&e<=i&&(t=Math.min(e-r,i-e),o<=t&&(a=c.body,o=t)))}),a},n.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||ge(t))},n.getState=function(e){var t=re(e),r=this.fragments[t];return r?r.buffered?ge(r)?N:O:C:k},n.isTimeBuffered=function(e,t,r){for(var i,a,o=0;o<r.length;o++){if(i=r.start(o)-this.bufferPadding,a=r.end(o)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1},n.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if(r.sn!=="initSegment"&&!r.bitrateTest&&!i){var a=re(r);this.fragments[a]={body:r,appendedPTS:null,loaded:t,buffered:!1,range:Object.create(null)}}},n.onBufferAppended=function(e,t){var r=this,i=t.frag,a=t.part,o=t.timeRanges,l=this.mainFragEntity;if(i.type===Ne){var d=l?l.body:null;if(d!==i){l&&d&&d.sn!==i.sn&&(l.buffered=!0,this.fragments[re(d)]=l);var u=re(i);l=this.mainFragEntity=this.fragments[u]||{body:i,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)}}if(a){var c=this.activeParts;c||(this.activeParts=c=[]),c.push(a)}else this.activeParts=null}this.timeRanges=o,Object.keys(o).forEach(function(h){var v=o[h];if(r.detectEvictedFragments(h,v),!a&&l){var y=i.elementaryStreams[h];if(!y)return;for(var T=0;T<v.length;T++){var A=v.end(T);A<=y.endPTS&&A>y.startPTS?l.appendedPTS=Math.max(A,l.appendedPTS||0):l.appendedPTS=y.endPTS}}})},n.onFragBuffered=function(e,t){this.detectPartialFragments(t)},n.hasFragment=function(e){var t=re(e);return!!this.fragments[t]},n.removeFragmentsInRange=function(e,t,r){var i=this;Object.keys(this.fragments).forEach(function(a){var o=i.fragments[a];if(o&&o.buffered){var l=o.body;l.type===r&&l.start<t&&l.end>e&&i.removeFragment(l)}})},n.removeFragment=function(e){var t=re(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),this.mainFragEntity===this.fragments[t]&&(this.mainFragEntity=null),delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},n.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.mainFragEntity=null,this.activeParts=null},s}();function ge(s){var n,e;return s.buffered&&(s.body.gap||((n=s.range.video)==null?void 0:n.partial)||((e=s.range.audio)==null?void 0:e.partial))}function re(s){return s.type+"_"+s.level+"_"+s.urlId+"_"+s.sn}var ce=Math.pow(2,17),ne=function(){function s(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var n=s.prototype;return n.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},n.abort=function(){this.loader&&this.loader.abort()},n.load=function(e,t){var r=this,i=e.url;if(!i)return Promise.reject(new Ke({type:te.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,o=a.fLoader,l=a.loader;return new Promise(function(d,u){if(r.loader&&r.loader.destroy(),e.gap)u(xe(e));else{var c=r.loader=e.loader=o?new o(a):new l(a),h=he(e),v=bn(a.fragLoadPolicy.default),y={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:ce};e.stats=c.stats,c.load(h,y,{onSuccess:function(T,A,p,_){r.resetLoader(e,c);var L=T.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(L.slice(0,16)),L=L.slice(16)),d({frag:e,part:null,payload:L,networkDetails:_})},onError:function(T,A,p,_){r.resetLoader(e,c),u(new Ke({type:te.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:H({url:i,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:p,stats:_}))},onAbort:function(T,A,p){r.resetLoader(e,c),u(new Ke({type:te.NETWORK_ERROR,details:U.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:T}))},onTimeout:function(T,A,p){r.resetLoader(e,c),u(new Ke({type:te.NETWORK_ERROR,details:U.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+y.timeout+"ms"),networkDetails:p,stats:T}))},onProgress:function(T,A,p,_){t&&t({frag:e,part:null,payload:p,networkDetails:_})}})}})},n.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,o=a.fLoader,l=a.loader;return new Promise(function(d,u){if(i.loader&&i.loader.destroy(),e.gap||t.gap)u(xe(e,t));else{var c=i.loader=e.loader=o?new o(a):new l(a),h=he(e,t),v=bn(a.fragLoadPolicy.default),y={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:ce};t.stats=c.stats,c.load(h,y,{onSuccess:function(T,A,p,_){i.resetLoader(e,c),i.updateStatsFromPart(e,t);var L={frag:e,part:t,payload:T.data,networkDetails:_};r(L),d(L)},onError:function(T,A,p,_){i.resetLoader(e,c),u(new Ke({type:te.NETWORK_ERROR,details:U.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:H({url:h.url,data:void 0},T),error:new Error("HTTP Error "+T.code+" "+T.text),networkDetails:p,stats:_}))},onAbort:function(T,A,p){e.stats.aborted=t.stats.aborted,i.resetLoader(e,c),u(new Ke({type:te.NETWORK_ERROR,details:U.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:T}))},onTimeout:function(T,A,p){i.resetLoader(e,c),u(new Ke({type:te.NETWORK_ERROR,details:U.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+y.timeout+"ms"),networkDetails:p,stats:T}))}})}})},n.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,a=i.total;if(r.loaded+=i.loaded,a){var o=Math.round(e.duration/t.duration),l=Math.min(Math.round(r.loaded/a),o),d=(o-l)*Math.round(r.loaded/l);r.total=r.loaded+d}else r.total=Math.max(r.loaded,r.total);var u=r.loading,c=i.loading;u.start?u.first+=c.first-c.start:(u.start=c.start,u.first=c.first),u.end=c.end},n.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},s}();function he(s,n){n===void 0&&(n=null);var e=n||s,t={frag:s,part:n,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},r=e.byteRangeStartOffset,i=e.byteRangeEndOffset;if(Q(r)&&Q(i)){var a,o=r,l=i;if(s.sn==="initSegment"&&((a=s.decryptdata)==null?void 0:a.method)==="AES-128"){var d=i-r;d%16&&(l=i+(16-d%16)),r!==0&&(t.resetIV=!0,o=r-16)}t.rangeStart=o,t.rangeEnd=l}return t}function xe(s,n){var e=new Error("GAP "+(s.gap?"tag":"attribute")+" found"),t={type:te.MEDIA_ERROR,details:U.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return n&&(t.part=n),(n||s).stats.aborted=!0,new Ke(t)}var Ke=function(s){function n(e){var t;return(t=s.call(this,e.error.message)||this).data=void 0,t.data=e,t}return fe(n,s),n}(Oe(Error)),tt=function(){function s(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var n=s.prototype;return n.abort=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.abort()}},n.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},n.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},n.createKeyLoadError=function(e,t,r,i,a){return t===void 0&&(t=U.KEY_LOAD_ERROR),new Ke({type:te.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:r,networkDetails:i})},n.loadClear=function(e,t){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=e.sn,a=e.cc,o=function(d){var u=t[d];if(a<=u.cc&&(i==="initSegment"||u.sn==="initSegment"||i<u.sn))return r.emeController.selectKeySystemFormat(u).then(function(c){u.setKeyFormat(c)}),"break"},l=0;l<t.length&&o(l)!=="break";l++);},n.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(r){return t.loadInternal(e,r)}):this.loadInternal(e)},n.loadInternal=function(e,t){var r,i;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var o=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,U.KEY_LOAD_ERROR,o))}var l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,U.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+l+'"')));var d,u=this.keyUriToKeyInfo[l];if((r=u)!=null&&r.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if((i=u)!=null&&i.keyLoadPromise)switch((d=u.mediaKeySessionContext)==null?void 0:d.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise.then(function(c){return a.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:u}})}switch(u=this.keyUriToKeyInfo[l]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return a.keyFormat==="identity"?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,U.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+a.method+'"')))}},n.loadKeyEME=function(e,t){var r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var i=this.emeController.loadKey(r);if(i)return(e.keyLoadPromise=i.then(function(a){return e.mediaKeySessionContext=a,r})).catch(function(a){throw e.keyLoadPromise=null,a})}return Promise.resolve(r)},n.loadKeyHTTP=function(e,t){var r=this,i=this.config,a=new i.loader(i);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise(function(o,l){var d={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u=i.keyLoadPolicy.default,c={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(v,y,T,A){var p=T.frag,_=T.keyInfo,L=T.url;if(!p.decryptdata||_!==r.keyUriToKeyInfo[L])return l(r.createKeyLoadError(p,U.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),A));_.decryptdata.key=p.decryptdata.key=new Uint8Array(v.data),p.keyLoader=null,_.loader=null,o({frag:p,keyInfo:_})},onError:function(v,y,T,A){r.resetLoader(y),l(r.createKeyLoadError(t,U.KEY_LOAD_ERROR,new Error("HTTP Error "+v.code+" loading key "+v.text),T,H({url:d.url,data:void 0},v)))},onTimeout:function(v,y,T){r.resetLoader(y),l(r.createKeyLoadError(t,U.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:function(v,y,T){r.resetLoader(y),l(r.createKeyLoadError(t,U.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};a.load(d,c,h)})},n.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],a&&a.destroy()},s}(),ct=function(){function s(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var n=s.prototype;return n.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},n.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},n.onHandlerDestroyed=function(){},n.hasInterval=function(){return!!this._tickInterval},n.hasNextTick=function(){return!!this._tickTimer},n.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},n.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},n.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},n.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},n.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},n.doTick=function(){},s}(),vt={length:0,start:function(){return 0},end:function(){return 0}},le=function(){function s(){}return s.isBuffered=function(n,e){try{if(n){for(var t=s.getBuffered(n),r=0;r<t.length;r++)if(e>=t.start(r)&&e<=t.end(r))return!0}}catch{}return!1},s.bufferInfo=function(n,e,t){try{if(n){var r,i=s.getBuffered(n),a=[];for(r=0;r<i.length;r++)a.push({start:i.start(r),end:i.end(r)});return this.bufferedInfo(a,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},s.bufferedInfo=function(n,e,t){e=Math.max(0,e),n.sort(function(T,A){var p=T.start-A.start;return p||A.end-T.end});var r=[];if(t)for(var i=0;i<n.length;i++){var a=r.length;if(a){var o=r[a-1].end;n[i].start-o<t?n[i].end>o&&(r[a-1].end=n[i].end):r.push(n[i])}else r.push(n[i])}else r=n;for(var l,d=0,u=e,c=e,h=0;h<r.length;h++){var v=r[h].start,y=r[h].end;if(e+t>=v&&e<y)u=v,d=(c=y)-e;else if(e+t<v){l=v;break}}return{len:d,start:u||0,end:c||0,nextStart:l}},s.getBuffered=function(n){try{return n.buffered}catch(e){return P.log("failed to get media.buffered",e),vt}},s}(),Ve=function(s,n,e,t,r,i){t===void 0&&(t=0),r===void 0&&(r=-1),i===void 0&&(i=!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=s,this.sn=n,this.id=e,this.size=t,this.part=r,this.partial=i};function Pe(s,n){for(var e=null,t=0,r=s.length;t<r;t++){var i=s[t];if(i&&i.cc===n){e=i;break}}return e}function $(s,n){if(s){var e=s.start+n;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function ue(s,n){for(var e=n.fragments,t=0,r=e.length;t<r;t++)$(e[t],s);n.fragmentHint&&$(n.fragmentHint,s),n.alignedSliding=!0}function ee(s,n,e){n&&(function(t,r,i){if(function(o,l,d){return!(!l.details||!(d.endCC>d.startCC||o&&o.cc<d.startCC))}(t,i,r)){var a=function(o,l,d){var u=o.fragments,c=l.fragments;if(c.length&&u.length){var h=Pe(u,c[0].cc);if(h&&(!h||h.startPTS))return h;P.log("No frag in previous level to align on")}else P.log("No fragments to align")}(i.details,r);a&&Q(a.start)&&(P.log("Adjusting PTS using last level due to CC increase within current level "+r.url),ue(a.start,r))}}(s,e,n),!e.alignedSliding&&n.details&&function(t,r){if(r.fragments.length&&t.hasProgramDateTime&&r.hasProgramDateTime){var i=r.fragments[0].programDateTime,a=t.fragments[0].programDateTime,o=(a-i)/1e3+r.fragments[0].start;o&&Q(o)&&(P.log("Adjusting PTS using programDateTime delta "+(a-i)+"ms, sliding:"+o.toFixed(3)+" "+t.url+" "),ue(o,t))}}(e,n.details),e.alignedSliding||!n.details||e.skippedSegments||_n(n.details,e))}function Ee(s,n){if(s.hasProgramDateTime&&n.hasProgramDateTime){var e=s.fragments,t=n.fragments;if(e.length&&t.length){var r=t[Math.round(t.length/2)-1],i=Pe(e,r.cc)||e[Math.round(e.length/2)-1],a=r.programDateTime,o=i.programDateTime;a!==null&&o!==null&&ue((o-a)/1e3-(i.start-r.start),s)}}}var De=function(){function s(n,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=n,this.aesIV=e}return s.prototype.decrypt=function(n,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,n)},s}(),Qe=function(){function s(n,e){this.subtle=void 0,this.key=void 0,this.subtle=n,this.key=e}return s.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},s}(),ht=function(){function s(){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 n=s.prototype;return n.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},n.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],o=r[2],l=r[3],d=this.invSubMix,u=d[0],c=d[1],h=d[2],v=d[3],y=new Uint32Array(256),T=0,A=0,p=0;for(p=0;p<256;p++)y[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){var _=A^A<<1^A<<2^A<<3^A<<4;_=_>>>8^255&_^99,e[T]=_,t[_]=T;var L=y[T],w=y[L],x=y[w],F=257*y[_]^16843008*_;i[T]=F<<24|F>>>8,a[T]=F<<16|F>>>16,o[T]=F<<8|F>>>24,l[T]=F,F=16843009*x^65537*w^257*L^16843008*T,u[_]=F<<24|F>>>8,c[_]=F<<16|F>>>16,h[_]=F<<8|F>>>24,v[_]=F,T?(T=L^y[y[y[x^L]]],A^=y[y[A]]):T=A=1}},n.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var a=this.keySize=t.length;if(a!==4&&a!==6&&a!==8)throw new Error("Invalid aes key size="+a);var o,l,d,u,c=this.ksRows=4*(a+6+1),h=this.keySchedule=new Uint32Array(c),v=this.invKeySchedule=new Uint32Array(c),y=this.sBox,T=this.rcon,A=this.invSubMix,p=A[0],_=A[1],L=A[2],w=A[3];for(o=0;o<c;o++)o<a?d=h[o]=t[o]:(u=d,o%a==0?(u=y[(u=u<<8|u>>>24)>>>24]<<24|y[u>>>16&255]<<16|y[u>>>8&255]<<8|y[255&u],u^=T[o/a|0]<<24):a>6&&o%a==4&&(u=y[u>>>24]<<24|y[u>>>16&255]<<16|y[u>>>8&255]<<8|y[255&u]),h[o]=d=(h[o-a]^u)>>>0);for(l=0;l<c;l++)o=c-l,u=3&l?h[o]:h[o-4],v[l]=l<4||o<=4?u:p[y[u>>>24]]^_[y[u>>>16&255]]^L[y[u>>>8&255]]^w[y[255&u]],v[l]=v[l]>>>0}},n.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},n.decrypt=function(e,t,r){for(var i,a,o,l,d,u,c,h,v,y,T,A,p,_,L=this.keySize+6,w=this.invKeySchedule,x=this.invSBox,F=this.invSubMix,G=F[0],W=F[1],q=F[2],V=F[3],Z=this.uint8ArrayToUint32Array_(r),X=Z[0],ie=Z[1],ye=Z[2],ae=Z[3],pe=new Int32Array(e),oe=new Int32Array(pe.length),me=this.networkToHostOrderSwap;t<pe.length;){for(v=me(pe[t]),y=me(pe[t+1]),T=me(pe[t+2]),A=me(pe[t+3]),d=v^w[0],u=A^w[1],c=T^w[2],h=y^w[3],p=4,_=1;_<L;_++)i=G[d>>>24]^W[u>>16&255]^q[c>>8&255]^V[255&h]^w[p],a=G[u>>>24]^W[c>>16&255]^q[h>>8&255]^V[255&d]^w[p+1],o=G[c>>>24]^W[h>>16&255]^q[d>>8&255]^V[255&u]^w[p+2],l=G[h>>>24]^W[d>>16&255]^q[u>>8&255]^V[255&c]^w[p+3],d=i,u=a,c=o,h=l,p+=4;i=x[d>>>24]<<24^x[u>>16&255]<<16^x[c>>8&255]<<8^x[255&h]^w[p],a=x[u>>>24]<<24^x[c>>16&255]<<16^x[h>>8&255]<<8^x[255&d]^w[p+1],o=x[c>>>24]<<24^x[h>>16&255]<<16^x[d>>8&255]<<8^x[255&u]^w[p+2],l=x[h>>>24]<<24^x[d>>16&255]<<16^x[u>>8&255]<<8^x[255&c]^w[p+3],oe[t]=me(i^X),oe[t+1]=me(l^ie),oe[t+2]=me(o^ye),oe[t+3]=me(a^ae),X=v,ie=y,ye=T,ae=A,t+=4}return oe.buffer},s}(),Je=function(){function s(e,t){var r=(t===void 0?{}:t).removePKCS7Padding,i=r===void 0||r;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=i,i)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var n=s.prototype;return n.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},n.isSync=function(){return this.useSoftware},n.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,i,a,o=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(i=(r=o).byteLength,(a=i&&new DataView(r.buffer).getUint8(i-1))?$t(r,0,i-a):r):o},n.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},n.decrypt=function(e,t,r){var i=this;return this.useSoftware?new Promise(function(a,o){i.softwareDecrypt(new Uint8Array(e),t,r);var l=i.flush();l?a(l.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)},n.softwareDecrypt=function(e,t,r){var i=this.currentIV,a=this.currentResult,o=this.remainderData;this.logOnce("JS AES decrypt"),o&&(e=jt(o,e),this.remainderData=null);var l=this.getValidChunk(e);if(!l.length)return null;i&&(r=i);var d=this.softwareDecrypter;d||(d=this.softwareDecrypter=new ht),d.expandKey(t);var u=a;return this.currentResult=d.decrypt(l.buffer,0,r),this.currentIV=$t(l,-16).buffer,u||null},n.webCryptoDecrypt=function(e,t,r){var i=this,a=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new Qe(a,t)),this.fastAesKey.expandKey().then(function(o){return a?(i.logOnce("WebCrypto AES decrypt"),new De(a,new Uint8Array(r)).decrypt(e.buffer,o)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(o){return P.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+o.name+": "+o.message),i.onWebCryptoError(e,t,r)})},n.onWebCryptoError=function(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);var i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},n.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=$t(e,0,r),this.remainderData=$t(e,r)),t},n.logOnce=function(e){this.logEnabled&&(P.log("[decrypter]: "+e),this.logEnabled=!1)},s}(),nt=function(s){for(var n="",e=s.length,t=0;t<e;t++)n+="["+s.start(t).toFixed(3)+"-"+s.end(t).toFixed(3)+"]";return n},Fe="STOPPED",de="IDLE",Lt="KEY_LOADING",wt="FRAG_LOADING",gt="FRAG_LOADING_WAITING_RETRY",Ye="WAITING_TRACK",ft="PARSING",zr="PARSED",pr="ENDED",lr="ERROR",Ci="WAITING_INIT_PTS",Xr="WAITING_LEVEL",ta=function(s){function n(t,r,i,a){var o;return(o=s.call(this)||this).hls=void 0,o.fragPrevious=null,o.fragCurrent=null,o.fragmentTracker=void 0,o.transmuxer=null,o._state=Fe,o.media=null,o.mediaBuffer=null,o.config=void 0,o.bitrateTest=!1,o.lastCurrentTime=0,o.nextLoadPosition=0,o.startPosition=0,o.startTimeOffset=null,o.loadedmetadata=!1,o.retryDate=0,o.levels=null,o.fragmentLoader=void 0,o.keyLoader=void 0,o.levelLastLoaded=null,o.startFragRequested=!1,o.decrypter=void 0,o.initPTS=[],o.onvseeking=null,o.onvended=null,o.logPrefix="",o.log=void 0,o.warn=void 0,o.logPrefix=a,o.log=P.log.bind(P,a+":"),o.warn=P.warn.bind(P,a+":"),o.hls=t,o.fragmentLoader=new ne(t.config),o.keyLoader=i,o.fragmentTracker=r,o.config=t.config,o.decrypter=new Je(t.config),t.on(E.MANIFEST_LOADED,o.onManifestLoaded,function(l){if(l===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return l}(o)),o}fe(n,s);var e=n.prototype;return e.doTick=function(){this.onTickEnd()},e.onTickEnd=function(){},e.startLoad=function(t){},e.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();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=Fe},e._streamEnded=function(t,r){if(r.live||t.nextStart||!t.end||!this.media)return!1;var i=r.partList;if(i!=null&&i.length){var a=i[i.length-1];return le.isBuffered(this.media,a.start+a.duration/2)}var o=r.fragments[r.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)},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,r){var i=this.media=this.mediaBuffer=r.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);var a=this.config;this.levels&&a.autoStartLoad&&this.state===Fe&&this.startLoad(a.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,r=this.fragCurrent,i=this.media,a=this.mediaBuffer,o=this.state,l=i?i.currentTime:0,d=le.bufferInfo(a||i,l,t.maxBufferHole);if(this.log("media seeking to "+(Q(l)?l.toFixed(3):l)+", state: "+o),this.state===pr)this.resetLoadingState();else if(r){var u=t.maxFragLookUpTolerance,c=r.start-u,h=r.start+r.duration+u;if(!d.len||h<d.start||c>d.end){var v=l>h;(l<c||v)&&(v&&r.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),r.abortRequests()),this.resetLoadingState())}}i&&(this.lastCurrentTime=l),this.loadedmetadata||d.len||(this.nextLoadPosition=this.startPosition=l),this.tickImmediate()},e.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},e.onManifestLoaded=function(t,r){this.startTimeOffset=r.startTimeOffset},e.onHandlerDestroying=function(){this.stopLoad(),s.prototype.onHandlerDestroying.call(this)},e.onHandlerDestroyed=function(){this.state=Fe,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,s.prototype.onHandlerDestroyed.call(this)},e.loadFragment=function(t,r,i){this._loadFragForPlayback(t,r,i)},e._loadFragForPlayback=function(t,r,i){var a=this;this._doFragLoad(t,r,i,function(o){if(a.fragContextChanged(t))return a.warn("Fragment "+t.sn+(o.part?" p: "+o.part.index:"")+" of level "+t.level+" was dropped during download."),void a.fragmentTracker.removeFragment(t);t.stats.chunkCount++,a._handleFragmentLoadProgress(o)}).then(function(o){if(o){var l=a.state;a.fragContextChanged(t)?(l===wt||!a.fragCurrent&&l===ft)&&(a.fragmentTracker.removeFragment(t),a.state=de):("payload"in o&&(a.log("Loaded fragment "+t.sn+" of level "+t.level),a.hls.trigger(E.FRAG_LOADED,o)),a._handleFragmentLoadComplete(o))}}).catch(function(o){a.state!==Fe&&a.state!==lr&&(a.warn(o),a.resetFragmentLoading(t))})},e.clearTrackerIfNeeded=function(t){var r;if(this.fragmentTracker.getState(t)===C){var i=t.type,a=this.getFwdBufferInfo(this.mediaBuffer,i),o=Math.max(t.duration,a?a.len:this.config.maxBufferLength);this.reduceMaxBufferLength(o)&&this.fragmentTracker.removeFragment(t)}else((r=this.mediaBuffer)==null?void 0:r.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},e.flushMainBuffer=function(t,r,i){if(i===void 0&&(i=null),t-r){var a={startOffset:t,endOffset:r,type:i};this.hls.trigger(E.BUFFER_FLUSHING,a)}},e._loadInitSegment=function(t,r){var i=this;this._doFragLoad(t,r).then(function(a){if(!a||i.fragContextChanged(t)||!i.levels)throw new Error("init load aborted");return a}).then(function(a){var o=i.hls,l=a.payload,d=t.decryptdata;if(l&&l.byteLength>0&&d&&d.key&&d.iv&&d.method==="AES-128"){var u=self.performance.now();return i.decrypter.decrypt(new Uint8Array(l),d.key.buffer,d.iv.buffer).catch(function(c){throw o.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.FRAG_DECRYPT_ERROR,fatal:!1,error:c,reason:c.message,frag:t}),c}).then(function(c){var h=self.performance.now();return o.trigger(E.FRAG_DECRYPTED,{frag:t,payload:c,stats:{tstart:u,tdecrypt:h}}),a.payload=c,a})}return a}).then(function(a){var o=i.fragCurrent,l=i.hls;if(!i.levels)throw new Error("init load aborted, missing levels");var d=t.stats;i.state=de,r.fragmentError=0,t.data=new Uint8Array(a.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),a.frag===o&&l.trigger(E.FRAG_BUFFERED,{stats:d,frag:o,part:null,id:t.type}),i.tick()}).catch(function(a){i.state!==Fe&&i.state!==lr&&(i.warn(a),i.resetFragmentLoading(t))})},e.fragContextChanged=function(t){var r=this.fragCurrent;return!t||!r||t.level!==r.level||t.sn!==r.sn||t.urlId!==r.urlId},e.fragBufferedComplete=function(t,r){var i,a,o,l,d=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(r?" part: "+r.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level+" (frag:["+((i=t.startPTS)!=null?i:NaN).toFixed(3)+"-"+((a=t.endPTS)!=null?a:NaN).toFixed(3)+"] > buffer:"+(d?nt(le.getBuffered(d)):"(detached)")+")"),this.state=de,d&&(!this.loadedmetadata&&t.type==Ne&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},e.seekToStartPos=function(){},e._handleFragmentLoadComplete=function(t){var r=this.transmuxer;if(r){var i=t.frag,a=t.part,o=t.partsLoaded,l=!o||o.length===0||o.some(function(u){return!u}),d=new Ve(i.level,i.sn,i.stats.chunkCount+1,0,a?a.index:-1,!l);r.flush(d)}},e._handleFragmentLoadProgress=function(t){},e._doFragLoad=function(t,r,i,a){var o,l=this;i===void 0&&(i=null);var d=r==null?void 0:r.details;if(!this.levels||!d)throw new Error("frag load aborted, missing level"+(d?"":" detail")+"s");var u=null;if(!t.encrypted||(o=t.decryptdata)!=null&&o.key?!t.encrypted&&d.encryptedFragments.length&&this.keyLoader.loadClear(t,d.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+d.startSN+"-"+d.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+t.level),this.state=Lt,this.fragCurrent=t,u=this.keyLoader.load(t).then(function(p){if(!l.fragContextChanged(p.frag))return l.hls.trigger(E.KEY_LOADED,p),l.state===Lt&&(l.state=de),p}),this.hls.trigger(E.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(u=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),i=Math.max(t.start,i||0),this.config.lowLatencyMode){var c=d.partList;if(c&&a){i>t.end&&d.fragmentHint&&(t=d.fragmentHint);var h=this.getNextPart(c,t,i);if(h>-1){var v,y=c[h];return this.log("Loading part sn: "+t.sn+" p: "+y.index+" cc: "+t.cc+" of playlist ["+d.startSN+"-"+d.endSN+"] parts [0-"+h+"-"+(c.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=y.start+y.duration,this.state=wt,v=u?u.then(function(p){return!p||l.fragContextChanged(p.frag)?null:l.doFragPartsLoad(t,y,r,a)}).catch(function(p){return l.handleFragLoadError(p)}):this.doFragPartsLoad(t,y,r,a).catch(function(p){return l.handleFragLoadError(p)}),this.hls.trigger(E.FRAG_LOADING,{frag:t,part:y,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):v}if(!t.url||this.loadedEndOfParts(c,i))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(d?"of ["+d.startSN+"-"+d.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+t.level+", target: "+parseFloat(i.toFixed(3))),Q(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=wt;var T,A=this.config.progressive;return T=A&&u?u.then(function(p){return!p||l.fragContextChanged(p==null?void 0:p.frag)?null:l.fragmentLoader.load(t,a)}).catch(function(p){return l.handleFragLoadError(p)}):Promise.all([this.fragmentLoader.load(t,A?a:void 0),u]).then(function(p){var _=p[0];return!A&&_&&a&&a(_),_}).catch(function(p){return l.handleFragLoadError(p)}),this.hls.trigger(E.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):T},e.doFragPartsLoad=function(t,r,i,a){var o=this;return new Promise(function(l,d){var u,c=[],h=(u=i.details)==null?void 0:u.partList;(function v(y){o.fragmentLoader.loadPart(t,y,a).then(function(T){c[y.index]=T;var A=T.part;o.hls.trigger(E.FRAG_LOADED,T);var p=vr(i,t.sn,y.index+1)||qr(h,t.sn,y.index+1);if(!p)return l({frag:t,part:A,partsLoaded:c});v(p)}).catch(d)})(r)})},e.handleFragLoadError=function(t){if("data"in t){var r=t.data;t.data&&r.details===U.INTERNAL_ABORTED?this.handleFragLoadAborted(r.frag,r.part):this.hls.trigger(E.ERROR,r)}else this.hls.trigger(E.ERROR,{type:te.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},e._handleTransmuxerFlush=function(t){var r=this.getCurrentContext(t);if(r&&this.state===ft){var i=r.frag,a=r.part,o=r.level,l=self.performance.now();i.stats.parsing.end=l,a&&(a.stats.parsing.end=l),this.updateLevelTiming(i,a,o,t.partial)}else this.fragCurrent||this.state===Fe||this.state===lr||(this.state=de)},e.getCurrentContext=function(t){var r=this.levels,i=this.fragCurrent,a=t.level,o=t.sn,l=t.part;if(r==null||!r[a])return this.warn("Levels object was unset while buffering fragment "+o+" of level "+a+". The current chunk will not be buffered."),null;var d=r[a],u=l>-1?vr(d,o,l):null,c=u?u.fragment:function(h,v,y){if(h==null||!h.details)return null;var T=h.details,A=T.fragments[v-T.startSN];return A||((A=T.fragmentHint)&&A.sn===v?A:v<T.startSN&&y&&y.sn===v?y:null)}(d,o,i);return c?(i&&i!==c&&(c.stats=i.stats),{frag:c,part:u,level:d}):null},e.bufferFragmentData=function(t,r,i,a){var o;if(t&&this.state===ft){var l=t.data1,d=t.data2,u=l;if(l&&d&&(u=jt(l,d)),(o=u)!=null&&o.length){var c={type:t.type,frag:r,part:i,chunkMeta:a,parent:r.type,data:u};this.hls.trigger(E.BUFFER_APPENDING,c),t.dropped&&t.independent&&!i&&this.flushBufferGap(r)}}},e.flushBufferGap=function(t){var r=this.media;if(r)if(le.isBuffered(r,r.currentTime)){var i=r.currentTime,a=le.bufferInfo(r,i,0),o=t.duration,l=Math.min(2*this.config.maxFragLookUpTolerance,.25*o),d=Math.max(Math.min(t.start-l,a.end-l),i+l);t.start-d>l&&this.flushMainBuffer(d,t.start)}else this.flushMainBuffer(0,t.start)},e.getFwdBufferInfo=function(t,r){var i=this.getLoadPosition();return Q(i)?this.getFwdBufferInfoAtPos(t,i,r):null},e.getFwdBufferInfoAtPos=function(t,r,i){var a=this.config.maxBufferHole,o=le.bufferInfo(t,r,a);if(o.len===0&&o.nextStart!==void 0){var l=this.fragmentTracker.getBufferedFrag(r,i);if(l&&o.nextStart<l.end)return le.bufferInfo(t,r,Math.max(o.nextStart,a))}return o},e.getMaxBufferLength=function(t){var r,i=this.config;return r=t?Math.max(8*i.maxBufferSize/t,i.maxBufferLength):i.maxBufferLength,Math.min(r,i.maxMaxBufferLength)},e.reduceMaxBufferLength=function(t){var r=this.config,i=t||r.maxBufferLength;return r.maxMaxBufferLength>=i&&(r.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+r.maxMaxBufferLength+"s"),!0)},e.getNextFragment=function(t,r){var i=r.fragments,a=i.length;if(!a)return null;var o,l=this.config,d=i[0].start;if(r.live){var u=l.initialLiveManifestSize;if(a<u)return this.warn("Not enough fragments to start playback (have: "+a+", need: "+u+")"),null;r.PTSKnown||this.startFragRequested||this.startPosition!==-1||(o=this.getInitialLiveFragment(r,i),this.startPosition=o?this.hls.liveSyncPosition||o.start:t)}else t<=d&&(o=i[0]);if(!o){var c=l.lowLatencyMode?r.partEnd:r.fragmentEnd;o=this.getFragmentAtPosition(t,c,r)}return this.mapToInitFragWhenRequired(o)},e.isLoopLoading=function(t,r){var i=this.fragmentTracker.getState(t);return(i===O||i===N&&!!t.gap)&&this.nextLoadPosition>r},e.getNextFragmentLoopLoading=function(t,r,i,a,o){var l=t.gap,d=this.getNextFragment(this.nextLoadPosition,r);if(d===null)return d;if(t=d,l&&t&&!t.gap&&i.nextStart){var u=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,a);if(u!==null&&i.len+u.len>=o)return this.log('buffer full after gaps in "'+a+'" 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,r,i){for(var a=-1,o=!1,l=!0,d=0,u=t.length;d<u;d++){var c=t[d];if(l=l&&!c.independent,a>-1&&i<c.start)break;var h=c.loaded;h?a=-1:(o||c.independent||l)&&c.fragment===r&&(a=d),o=h}return a},e.loadedEndOfParts=function(t,r){var i=t[t.length-1];return i&&r>i.start&&i.loaded},e.getInitialLiveFragment=function(t,r){var i=this.fragPrevious,a=null;if(i){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),a=function(u,c,h){if(c===null||!Array.isArray(u)||!u.length||!Q(c)||c<(u[0].programDateTime||0)||c>=(u[u.length-1].endProgramDateTime||0))return null;h=h||0;for(var v=0;v<u.length;++v){var y=u[v];if(Zn(c,h,y))return y}return null}(r,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!a){var o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){var l=r[o-t.startSN];i.cc===l.cc&&(a=l,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn))}a||(a=function(u,c){return Sn(u,function(h){return h.cc<c?1:h.cc>c?-1:0})}(r,i.cc),a&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn))}}else{var d=this.hls.liveSyncPosition;d!==null&&(a=this.getFragmentAtPosition(d,this.bitrateTest?t.fragmentEnd:t.edge,t))}return a},e.getFragmentAtPosition=function(t,r,i){var a,o=this.config,l=this.fragPrevious,d=i.fragments,u=i.endSN,c=i.fragmentHint,h=o.maxFragLookUpTolerance,v=!!(o.lowLatencyMode&&i.partList&&c);if(v&&c&&!this.bitrateTest&&(d=d.concat(c),u=c.sn),a=t<r?mr(l,d,t,t>r-h?0:h):d[d.length-1]){var y=a.sn-i.startSN,T=this.fragmentTracker.getState(a);if((T===O||T===N&&a.gap)&&(l=a),l&&a.sn===l.sn&&!v&&l&&a.level===l.level){var A=d[y+1];a=a.sn<u&&this.fragmentTracker.getState(A)!==O?A:null}}return a},e.synchronizeToLiveEdge=function(t){var r=this.config,i=this.media;if(i){var a=this.hls.liveSyncPosition,o=i.currentTime,l=t.fragments[0].start,d=t.edge,u=o>=l-r.maxFragLookUpTolerance&&o<=d;if(a!==null&&i.duration>a&&(o<a||!u)){var c=r.liveMaxLatencyDuration!==void 0?r.liveMaxLatencyDuration:r.liveMaxLatencyDurationCount*t.targetduration;(!u&&i.readyState<4||o<d-c)&&(this.loadedmetadata||(this.nextLoadPosition=a),i.readyState&&(this.warn("Playback: "+o.toFixed(3)+" is located too far from the end of live sliding playlist: "+d+", reset currentTime to : "+a.toFixed(3)),i.currentTime=a))}}},e.alignPlaylists=function(t,r){var i=this.levels,a=this.levelLastLoaded,o=this.fragPrevious,l=a!==null?i[a]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;var u=t.fragments[0].start,c=!r,h=t.alignedSliding&&Q(u);if(c||!h&&!u){ee(o,l,t);var v=t.fragments[0].start;return this.log("Live playlist sliding: "+v.toFixed(2)+" start-sn: "+(r?r.startSN:"na")+"->"+t.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+d),v}return u},e.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},e.setStartPosition=function(t,r){var i=this.startPosition;if(i<r&&(i=-1),i===-1||this.lastCurrentTime===-1){var a=this.startTimeOffset!==null,o=a?this.startTimeOffset:t.startTimeOffset;o!==null&&Q(o)?(i=r+o,o<0&&(i+=t.totalduration),i=Math.min(Math.max(r,i),r+t.totalduration),this.log("Start time offset "+o+" found in "+(a?"multivariant":"media")+" playlist, adjust startPosition to "+i),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||r:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i},e.getLoadPosition=function(){var t=this.media,r=0;return this.loadedmetadata&&t?r=t.currentTime:this.nextLoadPosition&&(r=this.nextLoadPosition),r},e.handleFragLoadAborted=function(t,r){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(r?" part"+r.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},e.resetFragmentLoading=function(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===gt)||(this.state=de)},e.onFragmentOrKeyLoadError=function(t,r){if(r.chunkMeta&&!r.frag){var i=this.getCurrentContext(r.chunkMeta);i&&(r.frag=i.frag)}var a=r.frag;if(a&&a.type===t&&this.levels)if(this.fragContextChanged(a)){var o;this.warn("Frag load error must match current frag to retry "+a.url+" > "+((o=this.fragCurrent)==null?void 0:o.url))}else{var l=r.details===U.FRAG_GAP;l&&this.fragmentTracker.fragBuffered(a,!0);var d=r.errorAction,u=d||{},c=u.action,h=u.retryCount,v=h===void 0?0:h,y=u.retryConfig;if(d&&c===Wt&&y){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var T=wi(y,v);this.warn("Fragment "+a.sn+" of "+t+" "+a.level+" errored with "+r.details+", retrying loading "+(v+1)+"/"+y.maxNumRetry+" in "+T+"ms"),d.resolved=!0,this.retryDate=self.performance.now()+T,this.state=gt}else y&&d?(this.resetFragmentErrors(t),v<y.maxNumRetry?l||(d.resolved=!0):P.warn(r.details+" reached or exceeded max retry ("+v+")")):this.state=lr;this.tickImmediate()}},e.reduceLengthAndFlushBuffer=function(t){if(this.state===ft||this.state===zr){var r=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),a=i&&i.len>.5;a&&this.reduceMaxBufferLength(i.len);var o=!a;return o&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+r+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),o}return!1},e.resetFragmentErrors=function(t){t===Ft&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Fe&&(this.state=de)},e.afterBufferFlushed=function(t,r,i){if(t){var a=le.getBuffered(t);this.fragmentTracker.detectEvictedFragments(r,a,i),this.state===pr&&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 r=this.levels?this.levels[t].details:null;r!=null&&r.live?(this.startPosition=-1,this.setStartPosition(r,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},e.updateLevelTiming=function(t,r,i,a){var o,l=this,d=i.details;if(d){if(Object.keys(t.elementaryStreams).reduce(function(c,h){var v=t.elementaryStreams[h];if(v){var y=v.endPTS-v.startPTS;if(y<=0)return l.warn("Could not parse fragment "+t.sn+" "+h+" duration reliably ("+y+")"),c||!1;var T=a?0:En(d,t,v.startPTS,v.endPTS,v.startDTS,v.endDTS);return l.hls.trigger(E.LEVEL_PTS_UPDATED,{details:d,level:i,drift:T,type:h,frag:t,start:v.startPTS,end:v.endPTS}),!0}return c},!1))i.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){var u=new Error("Found no media in fragment "+t.sn+" of level "+i.id+" resetting transmuxer to fallback to playlist timing");if(this.warn(u.message),this.hls.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,error:u,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+i.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=zr,this.hls.trigger(E.FRAG_PARSED,{frag:t,part:r})}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())},j(n,[{key:"state",get:function(){return this._state},set:function(t){var r=this._state;r!==t&&(this._state=t,this.log(r+"->"+t))}}]),n}(ct);function ra(){if(typeof self!="undefined")return self.MediaSource||self.WebKitMediaSource}function Wa(){return self.SourceBuffer||self.WebKitSourceBuffer}function zt(s,n){return s===void 0&&(s=""),n===void 0&&(n=9e4),{type:s,id:-1,pid:-1,inputTimeScale:n,sequenceNumber:-1,samples:[],dropped:0}}var za=function(){function s(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var n=s.prototype;return n.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},n.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},n.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},n.canParse=function(e,t){return!1},n.appendFrame=function(e,t,r){},n.demux=function(e,t){this.cachedData&&(e=jt(this.cachedData,e),this.cachedData=null);var r,i=Ir(e,0),a=i?i.length:0,o=this._audioTrack,l=this._id3Track,d=i?function(v){for(var y=Ji(v),T=0;T<y.length;T++){var A=y[T];if(Xi(A))return Zi(A)}}(i):void 0,u=e.length;for((this.basePTS===null||this.frameIndex===0&&Q(d))&&(this.basePTS=Eo(d,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Vt,duration:Number.POSITIVE_INFINITY});a<u;){if(this.canParse(e,a)){var c=this.appendFrame(o,e,a);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r=a+=c.length):a=u}else zi(e,a)?(i=Ir(e,a),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Vt,duration:Number.POSITIVE_INFINITY}),r=a+=i.length):a++;if(a===u&&r!==u){var h=$t(e,r);this.cachedData?this.cachedData=jt(this.cachedData,h):this.cachedData=h}}return{audioTrack:o,videoTrack:zt(),id3Track:l,textTrack:zt()}},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},n.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:zt(),id3Track:this._id3Track,textTrack:zt()}},n.destroy=function(){},s}(),Eo=function(s,n,e){return Q(s)?90*s:9e4*n+(e?9e4*e.baseTime/e.timescale:0)};function Xa(s,n){return s[n]===255&&(246&s[n+1])==240}function Qa(s,n){return 1&s[n+1]?7:9}function ia(s,n){return(3&s[n+3])<<11|s[n+4]<<3|(224&s[n+5])>>>5}function An(s,n){return n+1<s.length&&Xa(s,n)}function _o(s,n){if(An(s,n)){var e=Qa(s,n);if(n+e>=s.length)return!1;var t=ia(s,n);if(t<=e)return!1;var r=n+t;return r===s.length||An(s,r)}return!1}function Ja(s,n,e,t,r){if(!s.samplerate){var i=function(a,o,l,d){var u,c,h,v,y=navigator.userAgent.toLowerCase(),T=d,A=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];u=1+((192&o[l+2])>>>6);var p=(60&o[l+2])>>>2;if(!(p>A.length-1))return h=(1&o[l+2])<<2,h|=(192&o[l+3])>>>6,P.log("manifest codec:"+d+", ADTS type:"+u+", samplingIndex:"+p),/firefox/i.test(y)?p>=6?(u=5,v=new Array(4),c=p-3):(u=2,v=new Array(2),c=p):y.indexOf("android")!==-1?(u=2,v=new Array(2),c=p):(u=5,v=new Array(4),d&&(d.indexOf("mp4a.40.29")!==-1||d.indexOf("mp4a.40.5")!==-1)||!d&&p>=6?c=p-3:((d&&d.indexOf("mp4a.40.2")!==-1&&(p>=6&&h===1||/vivaldi/i.test(y))||!d&&h===1)&&(u=2,v=new Array(2)),c=p)),v[0]=u<<3,v[0]|=(14&p)>>1,v[1]|=(1&p)<<7,v[1]|=h<<3,u===5&&(v[1]|=(14&c)>>1,v[2]=(1&c)<<7,v[2]|=8,v[3]=0),{config:v,samplerate:A[p],channelCount:h,codec:"mp4a.40."+u,manifestCodec:T};a.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+p})}(n,e,t,r);if(!i)return;s.config=i.config,s.samplerate=i.samplerate,s.channelCount=i.channelCount,s.codec=i.codec,s.manifestCodec=i.manifestCodec,P.log("parsed codec:"+s.codec+", rate:"+i.samplerate+", channels:"+i.channelCount)}}function $a(s){return 9216e4/s}function Za(s,n,e,t,r){var i,a=t+r*$a(s.samplerate),o=function(y,T){var A=Qa(y,T);if(T+A<=y.length){var p=ia(y,T)-A;if(p>0)return{headerLength:A,frameLength:p}}}(n,e);if(o){var l=o.frameLength,d=o.headerLength,u=d+l,c=Math.max(0,e+u-n.length);c?(i=new Uint8Array(u-d)).set(n.subarray(e+d,n.length),0):i=n.subarray(e+d,e+u);var h={unit:i,pts:a};return c||s.samples.push(h),{sample:h,length:u,missing:c}}var v=n.length-e;return(i=new Uint8Array(v)).set(n.subarray(e,n.length),0),{sample:{unit:i,pts:a},length:v,missing:-1}}var bo=function(s){function n(t,r){var i;return(i=s.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}fe(n,s);var e=n.prototype;return e.resetInitSegment=function(t,r,i,a){s.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var r=(Ir(t,0)||[]).length,i=t.length;r<i;r++)if(_o(t,r))return P.log("ADTS sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return function(o,l){return l+5<o.length}(i,a)&&Xa(i,a)&&ia(i,a)<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){Ja(t,this.observer,r,i,t.manifestCodec);var a=Za(t,r,i,this.basePTS,this.frameIndex);if(a&&a.missing===0)return a},n}(za),So=/\/emsg[-/]ID3/i,Ao=function(){function s(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 n=s.prototype;return n.resetTimeStamp=function(){},n.resetInitSegment=function(e,t,r,i){var a=this.videoTrack=zt("video",1),o=this.audioTrack=zt("audio",1),l=this.txtTrack=zt("text",1);if(this.id3Track=zt("id3",1),this.timeOffset=0,e!=null&&e.byteLength){var d=mi(e);if(d.video){var u=d.video,c=u.id,h=u.timescale,v=u.codec;a.id=c,a.timescale=l.timescale=h,a.codec=v}if(d.audio){var y=d.audio,T=y.id,A=y.timescale,p=y.codec;o.id=T,o.timescale=A,o.codec=p}l.id=vi.text,a.sampleDuration=0,a.duration=o.duration=i}},n.resetContiguity=function(){},s.probe=function(e){return Ce(e=e.length>16384?e.subarray(0,16384):e,["moof"]).length>0},n.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=jt(this.remainderData,e));var o=function(d){var u={valid:null,remainder:null},c=Ce(d,["moof"]);if(!c)return u;if(c.length<2)return u.remainder=d,u;var h=c[c.length-1];return u.valid=$t(d,0,h.byteOffset-8),u.remainder=$t(d,h.byteOffset-8),u}(r);this.remainderData=o.remainder,i.samples=o.valid||new Uint8Array}else i.samples=r;var l=this.extractID3Track(i,t);return a.samples=an(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}},n.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=an(e,t),{videoTrack:t,audioTrack:zt(),id3Track:i,textTrack:zt()}},n.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var i=Ce(e.samples,["emsg"]);i&&i.forEach(function(a){var o=function(c){var h=c[0],v="",y="",T=0,A=0,p=0,_=0,L=0,w=0;if(h===0){for(;et(c.subarray(w,w+1))!=="\0";)v+=et(c.subarray(w,w+1)),w+=1;for(v+=et(c.subarray(w,w+1)),w+=1;et(c.subarray(w,w+1))!=="\0";)y+=et(c.subarray(w,w+1)),w+=1;y+=et(c.subarray(w,w+1)),w+=1,T=Te(c,12),A=Te(c,16),_=Te(c,20),L=Te(c,24),w=28}else if(h===1){T=Te(c,w+=4);var x=Te(c,w+=4),F=Te(c,w+=4);for(w+=4,p=Math.pow(2,32)*x+F,Number.isSafeInteger(p)||(p=Number.MAX_SAFE_INTEGER,P.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),_=Te(c,w),L=Te(c,w+=4),w+=4;et(c.subarray(w,w+1))!=="\0";)v+=et(c.subarray(w,w+1)),w+=1;for(v+=et(c.subarray(w,w+1)),w+=1;et(c.subarray(w,w+1))!=="\0";)y+=et(c.subarray(w,w+1)),w+=1;y+=et(c.subarray(w,w+1)),w+=1}return{schemeIdUri:v,value:y,timeScale:T,presentationTime:p,presentationTimeDelta:A,eventDuration:_,id:L,payload:c.subarray(w,c.byteLength)}}(a);if(So.test(o.schemeIdUri)){var l=Q(o.presentationTime)?o.presentationTime/o.timeScale:t+o.presentationTimeDelta/o.timeScale,d=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var u=o.payload;r.samples.push({data:u,len:u.byteLength,dts:l,pts:l,type:fr,duration:d})}})}return r},n.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},n.destroy=function(){},s}(),kn=null,ko=[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],Ro=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Lo=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],wo=[0,1,1,4];function es(s,n,e,t,r){if(!(e+24>n.length)){var i=ts(n,e);if(i&&e+i.frameLength<=n.length){var a=t+r*(9e4*i.samplesPerFrame/i.sampleRate),o={unit:n.subarray(e,e+i.frameLength),pts:a,dts:a};return s.config=[],s.channelCount=i.channelCount,s.samplerate=i.sampleRate,s.samples.push(o),{sample:o,length:i.frameLength,missing:0}}}}function ts(s,n){var e=s[n+1]>>3&3,t=s[n+1]>>1&3,r=s[n+2]>>4&15,i=s[n+2]>>2&3;if(e!==1&&r!==0&&r!==15&&i!==3){var a=s[n+2]>>1&1,o=s[n+3]>>6,l=1e3*ko[14*(e===3?3-t:t===3?3:4)+r-1],d=Ro[3*(e===3?0:e===2?1:2)+i],u=o===3?1:2,c=Lo[e][t],h=wo[t],v=8*c*h,y=Math.floor(c*l/d+a)*h;if(kn===null){var T=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);kn=T?parseInt(T[1]):0}return!!kn&&kn<=87&&t===2&&l>=224e3&&o===0&&(s[n+3]=128|s[n+3]),{sampleRate:d,channelCount:u,frameLength:y,samplesPerFrame:v}}}function na(s,n){return s[n]===255&&(224&s[n+1])==224&&(6&s[n+1])!=0}function rs(s,n){return n+1<s.length&&na(s,n)}function Do(s,n){if(n+1<s.length&&na(s,n)){var e=ts(s,n),t=4;e!=null&&e.frameLength&&(t=e.frameLength);var r=n+t;return r===s.length||rs(s,r)}return!1}var is=function(){function s(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 n=s.prototype;return n.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(a===0)throw new Error("no bytes available");i.set(e.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},n.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)},n.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&P.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?r<<t|this.readBits(t):r},n.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()},n.skipUEG=function(){this.skipBits(1+this.skipLZ())},n.skipEG=function(){this.skipBits(1+this.skipLZ())},n.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},n.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},n.readBoolean=function(){return this.readBits(1)===1},n.readUByte=function(){return this.readBits(8)},n.readUShort=function(){return this.readBits(16)},n.readUInt=function(){return this.readBits(32)},n.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)r!==0&&(r=(t+this.readEG()+256)%256),t=r===0?t:r},n.readSPS=function(){var e,t,r,i=0,a=0,o=0,l=0,d=this.readUByte.bind(this),u=this.readBits.bind(this),c=this.readUEG.bind(this),h=this.readBoolean.bind(this),v=this.skipBits.bind(this),y=this.skipEG.bind(this),T=this.skipUEG.bind(this),A=this.skipScalingList.bind(this);d();var p=d();if(u(5),v(3),d(),T(),p===100||p===110||p===122||p===244||p===44||p===83||p===86||p===118||p===128){var _=c();if(_===3&&v(1),T(),T(),v(1),h())for(t=_!==3?8:12,r=0;r<t;r++)h()&&A(r<6?16:64)}T();var L=c();if(L===0)c();else if(L===1)for(v(1),y(),y(),e=c(),r=0;r<e;r++)y();T(),v(1);var w=c(),x=c(),F=u(1);F===0&&v(1),v(1),h()&&(i=c(),a=c(),o=c(),l=c());var G=[1,1];if(h()&&h())switch(d()){case 1:G=[1,1];break;case 2:G=[12,11];break;case 3:G=[10,11];break;case 4:G=[16,11];break;case 5:G=[40,33];break;case 6:G=[24,11];break;case 7:G=[20,11];break;case 8:G=[32,11];break;case 9:G=[80,33];break;case 10:G=[18,11];break;case 11:G=[15,11];break;case 12:G=[64,33];break;case 13:G=[160,99];break;case 14:G=[4,3];break;case 15:G=[3,2];break;case 16:G=[2,1];break;case 255:G=[d()<<8|d(),d()<<8|d()]}return{width:Math.ceil(16*(w+1)-2*i-2*a),height:(2-F)*(x+1)*16-(F?2:4)*(o+l),pixelRatio:G}},n.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},s}(),Io=function(){function s(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Je(t,{removePKCS7Padding:!1})}var n=s.prototype;return n.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)},n.decryptAacSample=function(e,t,r){var i=this,a=e[t].unit;if(!(a.length<=16)){var o=a.subarray(16,a.length-a.length%16),l=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(l).then(function(d){var u=new Uint8Array(d);a.set(u,16),i.decrypter.isSync()||i.decryptAacSamples(e,t+1,r)})}},n.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},n.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)r.set(e.subarray(a,a+16),i);return r},n.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,a=32;a<e.length-16;a+=160,i+=16)e.set(r.subarray(i,i+16),a);return e},n.decryptAvcSample=function(e,t,r,i,a){var o=this,l=Ti(a.data),d=this.getAvcEncryptedData(l);this.decryptBuffer(d.buffer).then(function(u){a.data=o.getAvcDecryptedUnit(l,u),o.decrypter.isSync()||o.decryptAvcSamples(e,t,r+1,i)})},n.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var o=a[r];if(!(o.data.length<=48||o.type!==1&&o.type!==5||(this.decryptAvcSample(e,t,r,i,o),this.decrypter.isSync())))return}}},s}(),_t=188,Co=function(){function s(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}s.probe=function(e){var t=s.syncOffset(e);return t>0&&P.warn("MPEG2-TS detected but first sync word found @ offset "+t),t!==-1},s.syncOffset=function(e){for(var t=e.length,r=Math.min(940,e.length-_t)+1,i=0;i<r;){for(var a=!1,o=i;o<t&&e[o]===71;o+=_t)if(a||aa(e,o)!==0||(a=!0),a&&o+_t>r)return i;i++}return-1},s.createTrack=function(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:vi[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}};var n=s.prototype;return n.resetInitSegment=function(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=s.createTrack("video"),this._audioTrack=s.createTrack("audio",i),this._id3Track=s.createTrack("id3"),this._txtTrack=s.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i},n.resetTimeStamp=function(){},n.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},n.demux=function(e,t,r,i){var a;r===void 0&&(r=!1),i===void 0&&(i=!1),r||(this.sampleAes=null);var o=this._avcTrack,l=this._audioTrack,d=this._id3Track,u=this._txtTrack,c=o.pid,h=o.pesData,v=l.pid,y=d.pid,T=l.pesData,A=d.pesData,p=null,_=this.pmtParsed,L=this._pmtId,w=e.length;if(this.remainderData&&(w=(e=jt(this.remainderData,e)).length,this.remainderData=null),w<_t&&!i)return this.remainderData=e,{audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};var x=Math.max(0,s.syncOffset(e));(w-=(w-x)%_t)<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,w,e.buffer.byteLength-w));for(var F=0,G=x;G<w;G+=_t)if(e[G]===71){var W=!!(64&e[G+1]),q=aa(e,G),V=void 0;if((48&e[G+3])>>4>1){if((V=G+5+e[G+4])===G+_t)continue}else V=G+4;switch(q){case c:W&&(h&&(a=Qr(h))&&this.parseAVCPES(o,u,a,!1),h={data:[],size:0}),h&&(h.data.push(e.subarray(V,G+_t)),h.size+=G+_t-V);break;case v:if(W){if(T&&(a=Qr(T)))switch(l.segmentCodec){case"aac":this.parseAACPES(l,a);break;case"mp3":this.parseMPEGPES(l,a)}T={data:[],size:0}}T&&(T.data.push(e.subarray(V,G+_t)),T.size+=G+_t-V);break;case y:W&&(A&&(a=Qr(A))&&this.parseID3PES(d,a),A={data:[],size:0}),A&&(A.data.push(e.subarray(V,G+_t)),A.size+=G+_t-V);break;case 0:W&&(V+=e[V]+1),L=this._pmtId=xo(e,V);break;case L:W&&(V+=e[V]+1);var Z=Po(e,V,this.typeSupported,r);(c=Z.avc)>0&&(o.pid=c),(v=Z.audio)>0&&(l.pid=v,l.segmentCodec=Z.segmentCodec),(y=Z.id3)>0&&(d.pid=y),p===null||_||(P.warn("MPEG-TS PMT found at "+G+" after unknown PID '"+p+"'. Backtracking to sync byte @"+x+" to parse all TS packets."),p=null,G=x-188),_=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=q}}else F++;if(F>0){var X=new Error("Found "+F+" TS packet/s that do not start with 0x47");this.observer.emit(E.ERROR,E.ERROR,{type:te.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,error:X,reason:X.message})}o.pesData=h,l.pesData=T,d.pesData=A;var ie={audioTrack:l,videoTrack:o,id3Track:d,textTrack:u};return i&&this.extractRemainingSamples(ie),ie},n.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},n.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,a=e.id3Track,o=e.textTrack,l=i.pesData,d=r.pesData,u=a.pesData;if(l&&(t=Qr(l))?(this.parseAVCPES(i,o,t,!0),i.pesData=null):i.pesData=l,d&&(t=Qr(d))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else d!=null&&d.size&&P.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=d;u&&(t=Qr(u))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=u},n.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),a=this.sampleAes=new Io(this.observer,this.config,t);return this.decrypt(i,a)},n.decrypt=function(e,t){return new Promise(function(r){var i=e.audioTrack,a=e.videoTrack;i.samples&&i.segmentCodec==="aac"?t.decryptAacSamples(i.samples,0,function(){a.samples?t.decryptAvcSamples(a.samples,0,0,function(){r(e)}):r(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,function(){r(e)})})},n.destroy=function(){this._duration=0},n.parseAVCPES=function(e,t,r,i){var a,o=this,l=this.parseAVCNALu(e,r.data),d=this.avcSample,u=!1;r.data=null,d&&l.length&&!e.audFound&&(sa(d,e),d=this.avcSample=Rn(!1,r.pts,r.dts,"")),l.forEach(function(c){switch(c.type){case 1:a=!0,d||(d=o.avcSample=Rn(!0,r.pts,r.dts,"")),d.frame=!0;var h=c.data;if(u&&h.length>4){var v=new is(h).readSliceType();v!==2&&v!==4&&v!==7&&v!==9||(d.key=!0)}break;case 5:a=!0,d||(d=o.avcSample=Rn(!0,r.pts,r.dts,"")),d.key=!0,d.frame=!0;break;case 6:a=!0,yi(c.data,1,r.pts,t.samples);break;case 7:if(a=!0,u=!0,!e.sps){var y=c.data,T=new is(y).readSPS();e.width=T.width,e.height=T.height,e.pixelRatio=T.pixelRatio,e.sps=[y],e.duration=o._duration;for(var A=y.subarray(1,4),p="avc1.",_=0;_<3;_++){var L=A[_].toString(16);L.length<2&&(L="0"+L),p+=L}e.codec=p}break;case 8:a=!0,e.pps||(e.pps=[c.data]);break;case 9:a=!1,e.audFound=!0,d&&sa(d,e),d=o.avcSample=Rn(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,d&&(d.debug+="unknown NAL "+c.type+" ")}d&&a&&d.units.push(c)}),i&&d&&(sa(d,e),this.avcSample=null)},n.getLastNalUnit=function(e){var t,r,i=this.avcSample;if(i&&i.units.length!==0||(i=e[e.length-1]),(t=i)!=null&&t.units){var a=i.units;r=a[a.length-1]}return r},n.parseAVCNALu=function(e,t){var r,i,a=t.byteLength,o=e.naluState||0,l=o,d=[],u=0,c=-1,h=0;for(o===-1&&(c=0,h=31&t[0],o=0,u=1);u<a;)if(r=t[u++],o)if(o!==1)if(r)if(r===1){if(c>=0){var v={data:t.subarray(c,u-o-1),type:h};d.push(v)}else{var y=this.getLastNalUnit(e.samples);if(y&&(l&&u<=4-l&&y.state&&(y.data=y.data.subarray(0,y.data.byteLength-l)),(i=u-o-1)>0)){var T=new Uint8Array(y.data.byteLength+i);T.set(y.data,0),T.set(t.subarray(0,i),y.data.byteLength),y.data=T,y.state=0}}u<a?(c=u,h=31&t[u],o=0):o=-1}else o=0;else o=3;else o=r?0:2;else o=r?0:1;if(c>=0&&o>=0){var A={data:t.subarray(c,a),type:h,state:o};d.push(A)}if(d.length===0){var p=this.getLastNalUnit(e.samples);if(p){var _=new Uint8Array(p.data.byteLength+t.byteLength);_.set(p.data,0),_.set(t,p.data.byteLength),p.data=_}}return e.naluState=o,d},n.parseAACPES=function(e,t){var r,i,a,o=0,l=this.aacOverFlow,d=t.data;if(l){this.aacOverFlow=null;var u=l.missing,c=l.sample.unit.byteLength;if(u===-1){var h=new Uint8Array(c+d.byteLength);h.set(l.sample.unit,0),h.set(d,c),d=h}else{var v=c-u;l.sample.unit.set(d.subarray(0,u),v),e.samples.push(l.sample),o=l.missing}}for(r=o,i=d.length;r<i-1&&!An(d,r);r++);if(r!==o){var y,T=r<i-1;y=T?"AAC PES did not start with ADTS header,offset:"+r:"No ADTS header found in AAC PES";var A=new Error(y);if(P.warn("parsing error: "+y),this.observer.emit(E.ERROR,E.ERROR,{type:te.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,levelRetry:T,error:A,reason:y}),!T)return}if(Ja(e,this.observer,d,r,this.audioCodec),t.pts!==void 0)a=t.pts;else{if(!l)return void P.warn("[tsdemuxer]: AAC PES unknown PTS");var p=$a(e.samplerate);a=l.sample.pts+p}for(var _,L=0;r<i;){if(r+=(_=Za(e,d,r,a,L)).length,_.missing){this.aacOverFlow=_;break}for(L++;r<i-1&&!An(d,r);r++);}},n.parseMPEGPES=function(e,t){var r=t.data,i=r.length,a=0,o=0,l=t.pts;if(l!==void 0)for(;o<i;)if(rs(r,o)){var d=es(e,r,o,l,a);if(!d)break;o+=d.length,a++}else o++;else P.warn("[tsdemuxer]: MPEG PES unknown PTS")},n.parseID3PES=function(e,t){if(t.pts!==void 0){var r=z({},t,{type:this._avcTrack?fr:Vt,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else P.warn("[tsdemuxer]: ID3 PES unknown PTS")},s}();function Rn(s,n,e,t){return{key:s,frame:!1,pts:n,dts:e,units:[],debug:t,length:0}}function aa(s,n){return((31&s[n+1])<<8)+s[n+2]}function xo(s,n){return(31&s[n+10])<<8|s[n+11]}function Po(s,n,e,t){var r={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},i=n+3+((15&s[n+1])<<8|s[n+2])-4;for(n+=12+((15&s[n+10])<<8|s[n+11]);n<i;){var a=aa(s,n);switch(s[n]){case 207:if(!t){P.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:r.audio===-1&&(r.audio=a);break;case 21:r.id3===-1&&(r.id3=a);break;case 219:if(!t){P.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:r.avc===-1&&(r.avc=a);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?P.log("MPEG audio found, not supported in this browser"):r.audio===-1&&(r.audio=a,r.segmentCodec="mp3");break;case 36:P.warn("Unsupported HEVC stream type found")}n+=5+((15&s[n+3])<<8|s[n+4])}return r}function Qr(s){var n,e,t,r,i,a=0,o=s.data;if(!s||s.size===0)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(((n=o[0])[0]<<16)+(n[1]<<8)+n[2]===1){if((e=(n[4]<<8)+n[5])&&e>s.size-6)return null;var d=n[7];192&d&&(r=536870912*(14&n[9])+4194304*(255&n[10])+16384*(254&n[11])+128*(255&n[12])+(254&n[13])/2,64&d?r-(i=536870912*(14&n[14])+4194304*(255&n[15])+16384*(254&n[16])+128*(255&n[17])+(254&n[18])/2)>54e5&&(P.warn(Math.round((r-i)/9e4)+"s delta between PTS and DTS, align them"),r=i):i=r);var u=(t=n[8])+9;if(s.size<=u)return null;s.size-=u;for(var c=new Uint8Array(s.size),h=0,v=o.length;h<v;h++){var y=(n=o[h]).byteLength;if(u){if(u>y){u-=y;continue}n=n.subarray(u),y-=u,u=0}c.set(n,a),a+=y}return e&&(e-=t+3),{data:c,pts:r,dts:i,len:e}}return null}function sa(s,n){if(s.units.length&&s.frame){if(s.pts===void 0){var e=n.samples,t=e.length;if(!t)return void n.dropped++;var r=e[t-1];s.pts=r.pts,s.dts=r.dts}n.samples.push(s)}s.debug.length&&P.log(s.pts+"/"+s.dts+":"+s.debug)}var Oo=function(s){function n(){return s.apply(this,arguments)||this}fe(n,s);var e=n.prototype;return e.resetInitSegment=function(t,r,i,a){s.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},n.probe=function(t){if(!t)return!1;for(var r=(Ir(t,0)||[]).length,i=t.length;r<i;r++)if(Do(t,r))return P.log("MPEG Audio sync word found !"),!0;return!1},e.canParse=function(t,r){return function(i,a){return na(i,a)&&4<=i.length-a}(t,r)},e.appendFrame=function(t,r,i){if(this.basePTS!==null)return es(t,r,i,this.basePTS,this.frameIndex)},n}(za),ns=function(){function s(){}return s.getSilentFrame=function(n,e){if(n==="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])}},s}(),ur=Math.pow(2,32)-1,at=function(){function s(){}return s.init=function(){var n;for(n in s.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:[]},s.types)s.types.hasOwnProperty(n)&&(s.types[n]=[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.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]);s.HDLR_TYPES={video:e,audio:t};var r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);s.STTS=s.STSC=s.STCO=i,s.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),s.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),s.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),s.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);s.FTYP=s.box(s.types.ftyp,a,l,a,o),s.DINF=s.box(s.types.dinf,s.box(s.types.dref,r))},s.box=function(n){for(var e=8,t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var a=r.length,o=a;a--;)e+=r[a].byteLength;var l=new Uint8Array(e);for(l[0]=e>>24&255,l[1]=e>>16&255,l[2]=e>>8&255,l[3]=255&e,l.set(n,4),a=0,e=8;a<o;a++)l.set(r[a],e),e+=r[a].byteLength;return l},s.hdlr=function(n){return s.box(s.types.hdlr,s.HDLR_TYPES[n])},s.mdat=function(n){return s.box(s.types.mdat,n)},s.mdhd=function(n,e){e*=n;var t=Math.floor(e/(ur+1)),r=Math.floor(e%(ur+1));return s.box(s.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,85,196,0,0]))},s.mdia=function(n){return s.box(s.types.mdia,s.mdhd(n.timescale,n.duration),s.hdlr(n.type),s.minf(n))},s.mfhd=function(n){return s.box(s.types.mfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n]))},s.minf=function(n){return n.type==="audio"?s.box(s.types.minf,s.box(s.types.smhd,s.SMHD),s.DINF,s.stbl(n)):s.box(s.types.minf,s.box(s.types.vmhd,s.VMHD),s.DINF,s.stbl(n))},s.moof=function(n,e,t){return s.box(s.types.moof,s.mfhd(n),s.traf(t,e))},s.moov=function(n){for(var e=n.length,t=[];e--;)t[e]=s.trak(n[e]);return s.box.apply(null,[s.types.moov,s.mvhd(n[0].timescale,n[0].duration)].concat(t).concat(s.mvex(n)))},s.mvex=function(n){for(var e=n.length,t=[];e--;)t[e]=s.trex(n[e]);return s.box.apply(null,[s.types.mvex].concat(t))},s.mvhd=function(n,e){e*=n;var t=Math.floor(e/(ur+1)),r=Math.floor(e%(ur+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,t>>24,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,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 s.box(s.types.mvhd,i)},s.sdtp=function(n){var e,t,r=n.samples||[],i=new Uint8Array(4+r.length);for(e=0;e<r.length;e++)t=r[e].flags,i[e+4]=t.dependsOn<<4|t.isDependedOn<<2|t.hasRedundancy;return s.box(s.types.sdtp,i)},s.stbl=function(n){return s.box(s.types.stbl,s.stsd(n),s.box(s.types.stts,s.STTS),s.box(s.types.stsc,s.STSC),s.box(s.types.stsz,s.STSZ),s.box(s.types.stco,s.STCO))},s.avc1=function(n){var e,t,r,i=[],a=[];for(e=0;e<n.sps.length;e++)r=(t=n.sps[e]).byteLength,i.push(r>>>8&255),i.push(255&r),i=i.concat(Array.prototype.slice.call(t));for(e=0;e<n.pps.length;e++)r=(t=n.pps[e]).byteLength,a.push(r>>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(t));var o=s.box(s.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|n.sps.length].concat(i).concat([n.pps.length]).concat(a))),l=n.width,d=n.height,u=n.pixelRatio[0],c=n.pixelRatio[1];return s.box(s.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,255&l,d>>8&255,255&d,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,s.box(s.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),s.box(s.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,c>>24,c>>16&255,c>>8&255,255&c])))},s.esds=function(n){var e=n.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(n.config).concat([6,1,2]))},s.mp4a=function(n){var e=n.samplerate;return s.box(s.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),s.box(s.types.esds,s.esds(n)))},s.mp3=function(n){var e=n.samplerate;return s.box(s.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,n.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))},s.stsd=function(n){return n.type==="audio"?n.segmentCodec==="mp3"&&n.codec==="mp3"?s.box(s.types.stsd,s.STSD,s.mp3(n)):s.box(s.types.stsd,s.STSD,s.mp4a(n)):s.box(s.types.stsd,s.STSD,s.avc1(n))},s.tkhd=function(n){var e=n.id,t=n.duration*n.timescale,r=n.width,i=n.height,a=Math.floor(t/(ur+1)),o=Math.floor(t%(ur+1));return s.box(s.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,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o,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,r>>8&255,255&r,0,0,i>>8&255,255&i,0,0]))},s.traf=function(n,e){var t=s.sdtp(n),r=n.id,i=Math.floor(e/(ur+1)),a=Math.floor(e%(ur+1));return s.box(s.types.traf,s.box(s.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),s.box(s.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a])),s.trun(n,t.length+16+20+8+16+8+8),t)},s.trak=function(n){return n.duration=n.duration||4294967295,s.box(s.types.trak,s.tkhd(n),s.mdia(n))},s.trex=function(n){var e=n.id;return s.box(s.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]))},s.trun=function(n,e){var t,r,i,a,o,l,d=n.samples||[],u=d.length,c=12+16*u,h=new Uint8Array(c);for(e+=8+c,h.set([n.type==="video"?1:0,0,15,1,u>>>24&255,u>>>16&255,u>>>8&255,255&u,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),t=0;t<u;t++)i=(r=d[t]).duration,a=r.size,o=r.flags,l=r.cts,h.set([i>>>24&255,i>>>16&255,i>>>8&255,255&i,a>>>24&255,a>>>16&255,a>>>8&255,255&a,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*t);return s.box(s.types.trun,h)},s.initSegment=function(n){s.types||s.init();var e=s.moov(n),t=new Uint8Array(s.FTYP.byteLength+e.byteLength);return t.set(s.FTYP),t.set(e,s.FTYP.byteLength),t},s}();function oa(s,n,e,t){e===void 0&&(e=1),t===void 0&&(t=!1);var r=s*n*e;return t?Math.round(r):r}function xi(s,n){return n===void 0&&(n=!1),oa(s,1e3,1/9e4,n)}at.types=void 0,at.HDLR_TYPES=void 0,at.STTS=void 0,at.STSC=void 0,at.STCO=void 0,at.STSZ=void 0,at.VMHD=void 0,at.SMHD=void 0,at.STSD=void 0,at.FTYP=void 0,at.DINF=void 0;var Ln=null,la=null,ua=function(){function s(e,t,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,Ln===null){var a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ln=a?parseInt(a[1]):0}if(la===null){var o=navigator.userAgent.match(/Safari\/(\d+)/i);la=o?parseInt(o[1]):0}}var n=s.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){P.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},n.resetNextTimestamp=function(){P.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},n.resetInitSegment=function(){P.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},n.getVideoStartPts=function(e){var t=!1,r=e.reduce(function(i,a){var o=a.pts-i;return o<-4294967296?(t=!0,Dt(i,a.pts)):o>0?i:a.pts},e[0].pts);return t&&P.debug("PTS rollover detected"),r},n.remux=function(e,t,r,i,a,o,l,d){var u,c,h,v,y,T,A=a,p=a,_=e.pid>-1,L=t.pid>-1,w=t.samples.length,x=e.samples.length>0,F=l&&w>0||w>1;if((!_||x)&&(!L||F)||this.ISGenerated||l){this.ISGenerated||(h=this.generateIS(e,t,a,o));var G,W=this.isVideoContiguous,q=-1;if(F&&(q=function(ye){for(var ae=0;ae<ye.length;ae++)if(ye[ae].key)return ae;return-1}(t.samples),!W&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,q>0){P.warn("[mp4-remuxer]: Dropped "+q+" out of "+w+" video samples due to a missing keyframe");var V=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(q),t.dropped+=q,G=p+=(t.samples[0].pts-V)/t.inputTimeScale}else q===-1&&(P.warn("[mp4-remuxer]: No keyframe found out of "+w+" video samples"),T=!1);if(this.ISGenerated){if(x&&F){var Z=this.getVideoStartPts(t.samples),X=(Dt(e.samples[0].pts,Z)-Z)/t.inputTimeScale;A+=Math.max(0,X),p+=Math.max(0,-X)}if(x){if(e.samplerate||(P.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(e,t,a,o)),c=this.remuxAudio(e,A,this.isAudioContiguous,o,L||F||d===Ft?p:void 0),F){var ie=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(P.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(e,t,a,o)),u=this.remuxVideo(t,p,W,ie)}}else F&&(u=this.remuxVideo(t,p,W,0));u&&(u.firstKeyFrame=q,u.independent=q!==-1,u.firstKeyFramePTS=G)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(y=as(r,a,this._initPTS,this._initDTS)),i.samples.length&&(v=ss(i,a,this._initPTS))),{audio:c,video:u,initSegment:h,independent:T,text:v,id3:y}},n.generateIS=function(e,t,r,i){var a,o,l,d=e.samples,u=t.samples,c=this.typeSupported,h={},v=this._initPTS,y=!v||i,T="audio/mp4";if(y&&(a=o=1/0),e.config&&d.length&&(e.timescale=e.samplerate,e.segmentCodec==="mp3"&&(c.mpeg?(T="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),h.audio={id:"audio",container:T,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&c.mpeg?new Uint8Array(0):at.initSegment([e]),metadata:{channelCount:e.channelCount}},y&&(l=e.inputTimeScale,v&&l===v.timescale?y=!1:a=o=d[0].pts-Math.round(l*r))),t.sps&&t.pps&&u.length&&(t.timescale=t.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:at.initSegment([t]),metadata:{width:t.width,height:t.height}},y))if(l=t.inputTimeScale,v&&l===v.timescale)y=!1;else{var A=this.getVideoStartPts(u),p=Math.round(l*r);o=Math.min(o,Dt(u[0].dts,A)-p),a=Math.min(a,A-p)}if(Object.keys(h).length)return this.ISGenerated=!0,y?(this._initPTS={baseTime:a,timescale:l},this._initDTS={baseTime:o,timescale:l}):a=l=void 0,{tracks:h,initPTS:a,timescale:l}},n.remuxVideo=function(e,t,r,i){var a,o,l=e.inputTimeScale,d=e.samples,u=[],c=d.length,h=this._initPTS,v=this.nextAvcDts,y=8,T=this.videoSampleDuration,A=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,_=!1;r&&v!==null||(v=t*l-(d[0].pts-Dt(d[0].dts,d[0].pts)));for(var L=h.baseTime*l/h.timescale,w=0;w<c;w++){var x=d[w];x.pts=Dt(x.pts-L,v),x.dts=Dt(x.dts-L,v),x.dts<d[w>0?w-1:w].dts&&(_=!0)}_&&d.sort(function(On,Gs){var Cl=On.dts-Gs.dts,xl=On.pts-Gs.pts;return Cl||xl}),a=d[0].dts;var F=(o=d[d.length-1].dts)-a,G=F?Math.round(F/(c-1)):T||e.inputTimeScale/30;if(r){var W=a-v,q=W>G,V=W<-1;if((q||V)&&(q?P.warn("AVC: "+xi(W,!0)+" ms ("+W+"dts) hole between fragments detected, filling it"):P.warn("AVC: "+xi(-W,!0)+" ms ("+W+"dts) overlapping between fragments detected"),!V||v>d[0].pts)){a=v;var Z=d[0].pts-W;d[0].dts=a,d[0].pts=Z,P.log("Video: First PTS/DTS adjusted: "+xi(Z,!0)+"/"+xi(a,!0)+", delta: "+xi(W,!0)+" ms")}}a=Math.max(0,a);for(var X=0,ie=0,ye=0;ye<c;ye++){for(var ae=d[ye],pe=ae.units,oe=pe.length,me=0,Ae=0;Ae<oe;Ae++)me+=pe[Ae].data.length;ie+=me,X+=oe,ae.length=me,ae.dts=Math.max(ae.dts,a),A=Math.min(ae.pts,A),p=Math.max(ae.pts,p)}o=d[c-1].dts;var Ie,Re=ie+4*X+8;try{Ie=new Uint8Array(Re)}catch(On){return void this.observer.emit(E.ERROR,E.ERROR,{type:te.MUX_ERROR,details:U.REMUX_ALLOC_ERROR,fatal:!1,error:On,bytes:Re,reason:"fail allocating video mdat "+Re})}var Ue=new DataView(Ie.buffer);Ue.setUint32(0,Re),Ie.set(at.types.mdat,4);for(var mt=!1,rt=Number.POSITIVE_INFINITY,Ut=Number.POSITIVE_INFINITY,Ct=Number.NEGATIVE_INFINITY,xt=Number.NEGATIVE_INFINITY,it=0;it<c;it++){for(var st=d[it],Xt=st.units,dr=0,bt=0,Pi=Xt.length;bt<Pi;bt++){var Oi=Xt[bt],Pn=Oi.data,Zr=Oi.data.byteLength;Ue.setUint32(y,Zr),y+=4,Ie.set(Pn,y),y+=Zr,dr+=4+Zr}var _r=void 0;if(it<c-1)T=d[it+1].dts-st.dts,_r=d[it+1].pts-st.pts;else{var Mi=this.config,nr=it>0?st.dts-d[it-1].dts:G;if(_r=it>0?st.pts-d[it-1].pts:G,Mi.stretchShortVideoTrack&&this.nextAudioPts!==null){var Rl=Math.floor(Mi.maxBufferHole*l),Ia=(i?A+i*l:this.nextAudioPts)-st.pts;Ia>Rl?((T=Ia-nr)<0?T=nr:mt=!0,P.log("[mp4-remuxer]: It is approximately "+Ia/90+" ms to the next segment; using duration "+T/90+" ms for the last video frame.")):T=nr}else T=nr}var Ll=Math.round(st.pts-st.dts);rt=Math.min(rt,T),Ct=Math.max(Ct,T),Ut=Math.min(Ut,_r),xt=Math.max(xt,_r),u.push(new os(st.key,T,dr,Ll))}if(u.length){if(Ln){if(Ln<70){var Ns=u[0].flags;Ns.dependsOn=2,Ns.isNonSync=0}}else if(la&&xt-Ut<Ct-rt&&G/Ct<.025&&u[0].cts===0){P.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Ca=a,Bt=0,Us=u.length;Bt<Us;Bt++){var Bs=Ca+u[Bt].duration,wl=Ca+u[Bt].cts;if(Bt<Us-1){var Dl=Bs+u[Bt+1].cts;u[Bt].duration=Dl-wl}else u[Bt].duration=Bt?u[Bt-1].duration:G;u[Bt].cts=0,Ca=Bs}}}T=mt||!T?G:T,this.nextAvcDts=v=o+T,this.videoSampleDuration=T,this.isVideoContiguous=!0;var Il={data1:at.moof(e.sequenceNumber++,a,z({},e,{samples:u})),data2:Ie,startPTS:A/l,endPTS:(p+T)/l,startDTS:a/l,endDTS:v/l,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,Il},n.remuxAudio=function(e,t,r,i,a){var o=e.inputTimeScale,l=o/(e.samplerate?e.samplerate:o),d=e.segmentCodec==="aac"?1024:1152,u=d*l,c=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,v=[],y=a!==void 0,T=e.samples,A=h?0:8,p=this.nextAudioPts||-1,_=t*o,L=c.baseTime*o/c.timescale;if(this.isAudioContiguous=r=r||T.length&&p>0&&(i&&Math.abs(_-p)<9e3||Math.abs(Dt(T[0].pts-L,_)-p)<20*u),T.forEach(function(bt){bt.pts=Dt(bt.pts-L,_)}),!r||p<0){if(T=T.filter(function(bt){return bt.pts>=0}),!T.length)return;p=a===0?0:i&&!y?Math.max(0,_):T[0].pts}if(e.segmentCodec==="aac")for(var w=this.config.maxAudioFramesDrift,x=0,F=p;x<T.length;x++){var G=T[x],W=G.pts,q=W-F,V=Math.abs(1e3*q/o);if(q<=-w*u&&y)x===0&&(P.warn("Audio frame @ "+(W/o).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*q/o)+" ms."),this.nextAudioPts=p=F=W);else if(q>=w*u&&V<1e4&&y){var Z=Math.round(q/u);(F=W-Z*u)<0&&(Z--,F+=u),x===0&&(this.nextAudioPts=p=F),P.warn("[mp4-remuxer]: Injecting "+Z+" audio frame @ "+(F/o).toFixed(3)+"s due to "+Math.round(1e3*q/o)+" ms gap.");for(var X=0;X<Z;X++){var ie=Math.max(F,0),ye=ns.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);ye||(P.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),ye=G.unit.subarray()),T.splice(x,0,{unit:ye,pts:ie}),F+=u,x++}}G.pts=F,F+=u}for(var ae,pe=null,oe=null,me=0,Ae=T.length;Ae--;)me+=T[Ae].unit.byteLength;for(var Ie=0,Re=T.length;Ie<Re;Ie++){var Ue=T[Ie],mt=Ue.unit,rt=Ue.pts;if(oe!==null)v[Ie-1].duration=Math.round((rt-oe)/l);else{if(r&&e.segmentCodec==="aac"&&(rt=p),pe=rt,!(me>0))return;me+=A;try{ae=new Uint8Array(me)}catch(bt){return void this.observer.emit(E.ERROR,E.ERROR,{type:te.MUX_ERROR,details:U.REMUX_ALLOC_ERROR,fatal:!1,error:bt,bytes:me,reason:"fail allocating audio mdat "+me})}h||(new DataView(ae.buffer).setUint32(0,me),ae.set(at.types.mdat,4))}ae.set(mt,A);var Ut=mt.byteLength;A+=Ut,v.push(new os(!0,d,Ut,0)),oe=rt}var Ct=v.length;if(Ct){var xt=v[v.length-1];this.nextAudioPts=p=oe+l*xt.duration;var it=h?new Uint8Array(0):at.moof(e.sequenceNumber++,pe/l,z({},e,{samples:v}));e.samples=[];var st=pe/o,Xt=p/o,dr={data1:it,data2:ae,startPTS:st,endPTS:Xt,startDTS:st,endDTS:Xt,type:"audio",hasAudio:!0,hasVideo:!1,nb:Ct};return this.isAudioContiguous=!0,dr}},n.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,o=a/(e.samplerate?e.samplerate:a),l=this.nextAudioPts,d=this._initDTS,u=9e4*d.baseTime/d.timescale,c=(l!==null?l:i.startDTS*a)+u,h=i.endDTS*a+u,v=1024*o,y=Math.ceil((h-c)/v),T=ns.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(P.warn("[mp4-remuxer]: remux empty Audio"),T){for(var A=[],p=0;p<y;p++){var _=c+p*v;A.push({unit:T,pts:_,dts:_})}return e.samples=A,this.remuxAudio(e,t,r,!1)}P.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},s}();function Dt(s,n){var e;if(n===null)return s;for(e=n<s?-8589934592:8589934592;Math.abs(s-n)>4294967296;)s+=e;return s}function as(s,n,e,t){var r=s.samples.length;if(r){for(var i=s.inputTimeScale,a=0;a<r;a++){var o=s.samples[a];o.pts=Dt(o.pts-9e4*e.baseTime/e.timescale,n*i)/i,o.dts=Dt(o.dts-9e4*t.baseTime/t.timescale,n*i)/i}var l=s.samples;return s.samples=[],{samples:l}}}function ss(s,n,e){var t=s.samples.length;if(t){for(var r=s.inputTimeScale,i=0;i<t;i++){var a=s.samples[i];a.pts=Dt(a.pts-9e4*e.baseTime/e.timescale,n*r)/r}s.samples.sort(function(l,d){return l.pts-d.pts});var o=s.samples;return s.samples=[],{samples:o}}}var rr,os=function(s,n,e,t){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=n,this.size=e,this.cts=t,this.flags=new Mo(s)},Mo=function(s){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=s?2:1,this.isNonSync=s?0:1},Fo=function(){function s(){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 n=s.prototype;return n.destroy=function(){},n.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},n.resetNextTimestamp=function(){this.lastEndTime=null},n.resetInitSegment=function(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(a,o){if(!a||!o)return a;var l=o.keyId;return l&&o.isCommonEncryption&&Ce(a,["moov","trak"]).forEach(function(d){var u=Ce(d,["mdia","minf","stbl","stsd"])[0].subarray(8),c=Ce(u,["enca"]),h=c.length>0;h||(c=Ce(u,["encv"])),c.forEach(function(v){Ce(h?v.subarray(28):v.subarray(78),["sinf"]).forEach(function(y){var T=pi(y);if(T){var A=T.subarray(8,24);A.some(function(p){return p!==0})||(P.log("[eme] Patching keyId in 'enc"+(h?"a":"v")+">sinf>>tenc' box: "+Et(A)+" -> "+Et(l)),T.set(l,8))}})})}),a}(e,i)),this.emitInitSegment=!0},n.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(e==null||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=mi(e);t||(t=ls(i.audio,_e)),r||(r=ls(i.video,ze));var a={};i.audio&&i.video?a.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?a.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:P.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a},n.remux=function(e,t,r,i,a,o){var l,d,u=this.initPTS,c=this.lastEndTime,h={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};Q(c)||(c=this.lastEndTime=a||0);var v=t.samples;if(v==null||!v.length)return h;var y={initPTS:void 0,timescale:1},T=this.initData;if((l=T)!=null&&l.length||(this.generateInitSegment(v),T=this.initData),(d=T)==null||!d.length)return P.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(y.tracks=this.initTracks,this.emitInitSegment=!1);var A=function(q,V){return Ce(V,["moof","traf"]).reduce(function(Z,X){var ie=Ce(X,["tfdt"])[0],ye=ie[0],ae=Ce(X,["tfhd"]).reduce(function(pe,oe){var me=Te(oe,4),Ae=q[me];if(Ae){var Ie=Te(ie,4);if(ye===1){if(Ie===xr)return P.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),pe;Ie*=xr+1,Ie+=Te(ie,8)}var Re=Ie/(Ae.timescale||9e4);if(isFinite(Re)&&(pe===null||Re<pe))return Re}return pe},null);return ae!==null&&isFinite(ae)&&(Z===null||ae<Z)?ae:Z},null)}(T,v),p=A===null?a:A;(function(q,V,Z){if(q===null)return!0;var X=V-q.baseTime/q.timescale;return X<0&&Math.abs(X-Z)>1}(u,p,a)||y.timescale!==u.timescale&&o)&&(y.initPTS=p-a,this.initPTS=u={baseTime:y.initPTS,timescale:1});var _=function(q,V){for(var Z=0,X=0,ie=0,ye=Ce(q,["moof","traf"]),ae=0;ae<ye.length;ae++){var pe=ye[ae],oe=Ce(pe,["tfhd"])[0],me=V[Te(oe,4)];if(me){var Ae=me.default,Ie=Te(oe,0)|(Ae==null?void 0:Ae.flags),Re=Ae==null?void 0:Ae.duration;8&Ie&&(Re=Te(oe,2&Ie?12:8));for(var Ue=me.timescale||9e4,mt=Ce(pe,["trun"]),rt=0;rt<mt.length;rt++)!(Z=nn(mt[rt]))&&Re&&(Z=Re*Te(mt[rt],4)),me.type===ze?X+=Z/Ue:me.type===_e&&(ie+=Z/Ue)}}if(X===0&&ie===0){for(var Ut=0,Ct=Ce(q,["sidx"]),xt=0;xt<Ct.length;xt++){var it=Vn(Ct[xt]);it!=null&&it.references&&(Ut+=it.references.reduce(function(st,Xt){return st+Xt.info.duration||0},0))}return Ut}return X||ie}(v,T),L=e?p-u.baseTime/u.timescale:c,w=L+_;(function(q,V,Z){Ce(V,["moof","traf"]).forEach(function(X){Ce(X,["tfhd"]).forEach(function(ie){var ye=Te(ie,4),ae=q[ye];if(ae){var pe=ae.timescale||9e4;Ce(X,["tfdt"]).forEach(function(oe){var me=oe[0],Ae=Te(oe,4);if(me===0)Ae-=Z*pe,gi(oe,4,Ae=Math.max(Ae,0));else{Ae*=Math.pow(2,32),Ae+=Te(oe,8),Ae-=Z*pe,Ae=Math.max(Ae,0);var Ie=Math.floor(Ae/(xr+1)),Re=Math.floor(Ae%(xr+1));gi(oe,4,Ie),gi(oe,8,Re)}})}})})})(T,v,u.baseTime/u.timescale),_>0?this.lastEndTime=w:(P.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var x=!!T.audio,F=!!T.video,G="";x&&(G+="audio"),F&&(G+="video");var W={data1:v,startPTS:L,startDTS:L,endPTS:w,endDTS:w,type:G,hasAudio:x,hasVideo:F,nb:1,dropped:0};return h.audio=W.type==="audio"?W:void 0,h.video=W.type!=="audio"?W:void 0,h.initSegment=y,h.id3=as(r,a,u,u),i.samples.length&&(h.text=ss(i,a,u)),h},s}();function ls(s,n){var e=s==null?void 0:s.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.c.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||n===ze?"avc1.42e01e":"mp4a.40.5"}try{rr=self.performance.now.bind(self.performance)}catch{P.debug("Unable to use Performance API on this environment"),rr=typeof self!="undefined"&&self.Date.now}var da=[{demux:Ao,remux:Fo},{demux:Co,remux:ua},{demux:bo,remux:ua},{demux:Oo,remux:ua}],ca=function(){function s(e,t,r,i,a){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=a}var n=s.prototype;return n.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},n.push=function(e,t,r,i){var a=this,o=r.transmuxing;o.executeStart=rr();var l=new Uint8Array(e),d=this.currentTransmuxState,u=this.transmuxConfig;i&&(this.currentTransmuxState=i);var c=i||d,h=c.contiguous,v=c.discontinuity,y=c.trackSwitch,T=c.accurateTimeOffset,A=c.timeOffset,p=c.initSegmentChange,_=u.audioCodec,L=u.videoCodec,w=u.defaultInitPts,x=u.duration,F=u.initSegmentData,G=function(ye,ae){var pe=null;return ye.byteLength>0&&ae!=null&&ae.key!=null&&ae.iv!==null&&ae.method!=null&&(pe=ae),pe}(l,t);if(G&&G.method==="AES-128"){var W=this.getDecrypter();if(!W.isSync())return this.decryptionPromise=W.webCryptoDecrypt(l,G.key.buffer,G.iv.buffer).then(function(ye){var ae=a.push(ye,null,r);return a.decryptionPromise=null,ae}),this.decryptionPromise;var q=W.softwareDecrypt(l,G.key.buffer,G.iv.buffer);if(r.part>-1&&(q=W.flush()),!q)return o.executeEnd=rr(),ha(r);l=new Uint8Array(q)}var V=this.needsProbing(v,y);if(V){var Z=this.configureTransmuxer(l);if(Z)return P.warn("[transmuxer] "+Z.message),this.observer.emit(E.ERROR,E.ERROR,{type:te.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,fatal:!1,error:Z,reason:Z.message}),o.executeEnd=rr(),ha(r)}(v||y||p||V)&&this.resetInitSegment(F,_,L,x,t),(v||p||V)&&this.resetInitialTimestamp(w),h||this.resetContiguity();var X=this.transmux(l,G,A,T,r),ie=this.currentTransmuxState;return ie.contiguous=!0,ie.discontinuity=!1,ie.trackSwitch=!1,o.executeEnd=rr(),X},n.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=rr();var i=this.decrypter,a=this.currentTransmuxState,o=this.decryptionPromise;if(o)return o.then(function(){return t.flush(e)});var l=[],d=a.timeOffset;if(i){var u=i.flush();u&&l.push(this.push(u,null,e))}var c=this.demuxer,h=this.remuxer;if(!c||!h)return r.executeEnd=rr(),[ha(e)];var v=c.flush(d);return yr(v)?v.then(function(y){return t.flushRemux(l,y,e),l}):(this.flushRemux(l,v,e),l)},n.flushRemux=function(e,t,r){var i=t.audioTrack,a=t.videoTrack,o=t.id3Track,l=t.textTrack,d=this.currentTransmuxState,u=d.accurateTimeOffset,c=d.timeOffset;P.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var h=this.remuxer.remux(i,a,o,l,c,u,!0,this.id);e.push({remuxResult:h,chunkMeta:r}),r.transmuxing.executeEnd=rr()},n.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},n.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},n.resetInitSegment=function(e,t,r,i,a){var o=this.demuxer,l=this.remuxer;o&&l&&(o.resetInitSegment(e,t,r,i),l.resetInitSegment(e,t,r,a))},n.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},n.transmux=function(e,t,r,i,a){return t&&t.method==="SAMPLE-AES"?this.transmuxSampleAes(e,t,r,i,a):this.transmuxUnencrypted(e,r,i,a)},n.transmuxUnencrypted=function(e,t,r,i){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),o=a.audioTrack,l=a.videoTrack,d=a.id3Track,u=a.textTrack;return{remuxResult:this.remuxer.remux(o,l,d,u,t,r,!1,this.id),chunkMeta:i}},n.transmuxSampleAes=function(e,t,r,i,a){var o=this;return this.demuxer.demuxSampleAes(e,t,r).then(function(l){return{remuxResult:o.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,r,i,!1,o.id),chunkMeta:a}})},n.configureTransmuxer=function(e){for(var t,r=this.config,i=this.observer,a=this.typeSupported,o=this.vendor,l=0,d=da.length;l<d;l++)if(da[l].demux.probe(e)){t=da[l];break}if(!t)return new Error("Failed to find demuxer by probing fragment data");var u=this.demuxer,c=this.remuxer,h=t.remux,v=t.demux;c&&c instanceof h||(this.remuxer=new h(i,r,a,o)),u&&u instanceof v||(this.demuxer=new v(i,r,a),this.probe=v.probe)},n.needsProbing=function(e,t){return!this.demuxer||!this.remuxer||e||t},n.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new Je(this.config)),e},s}(),ha=function(s){return{remuxResult:{},chunkMeta:s}};function yr(s){return"then"in s&&s.then instanceof Function}var No=function(s,n,e,t,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=s,this.videoCodec=n,this.initSegmentData=e,this.duration=t,this.defaultInitPts=r||null},Uo=function(s,n,e,t,r,i){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=s,this.contiguous=n,this.accurateTimeOffset=e,this.trackSwitch=t,this.timeOffset=r,this.initSegmentChange=i},fa={};(function(s){var n=Object.prototype.hasOwnProperty,e="~";function t(){}function r(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function i(l,d,u,c,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var v=new r(u,c||l,h),y=e?e+d:d;return l._events[y]?l._events[y].fn?l._events[y]=[l._events[y],v]:l._events[y].push(v):(l._events[y]=v,l._eventsCount++),l}function a(l,d){--l._eventsCount==0?l._events=new t:delete l._events[d]}function o(){this._events=new t,this._eventsCount=0}Object.create&&(t.prototype=Object.create(null),new t().__proto__||(e=!1)),o.prototype.eventNames=function(){var l,d,u=[];if(this._eventsCount===0)return u;for(d in l=this._events)n.call(l,d)&&u.push(e?d.slice(1):d);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(l)):u},o.prototype.listeners=function(l){var d=e?e+l:l,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var c=0,h=u.length,v=new Array(h);c<h;c++)v[c]=u[c].fn;return v},o.prototype.listenerCount=function(l){var d=e?e+l:l,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,d,u,c,h,v){var y=e?e+l:l;if(!this._events[y])return!1;var T,A,p=this._events[y],_=arguments.length;if(p.fn){switch(p.once&&this.removeListener(l,p.fn,void 0,!0),_){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,d),!0;case 3:return p.fn.call(p.context,d,u),!0;case 4:return p.fn.call(p.context,d,u,c),!0;case 5:return p.fn.call(p.context,d,u,c,h),!0;case 6:return p.fn.call(p.context,d,u,c,h,v),!0}for(A=1,T=new Array(_-1);A<_;A++)T[A-1]=arguments[A];p.fn.apply(p.context,T)}else{var L,w=p.length;for(A=0;A<w;A++)switch(p[A].once&&this.removeListener(l,p[A].fn,void 0,!0),_){case 1:p[A].fn.call(p[A].context);break;case 2:p[A].fn.call(p[A].context,d);break;case 3:p[A].fn.call(p[A].context,d,u);break;case 4:p[A].fn.call(p[A].context,d,u,c);break;default:if(!T)for(L=1,T=new Array(_-1);L<_;L++)T[L-1]=arguments[L];p[A].fn.apply(p[A].context,T)}}return!0},o.prototype.on=function(l,d,u){return i(this,l,d,u,!1)},o.prototype.once=function(l,d,u){return i(this,l,d,u,!0)},o.prototype.removeListener=function(l,d,u,c){var h=e?e+l:l;if(!this._events[h])return this;if(!d)return a(this,h),this;var v=this._events[h];if(v.fn)v.fn!==d||c&&!v.once||u&&v.context!==u||a(this,h);else{for(var y=0,T=[],A=v.length;y<A;y++)(v[y].fn!==d||c&&!v[y].once||u&&v[y].context!==u)&&T.push(v[y]);T.length?this._events[h]=T.length===1?T[0]:T:a(this,h)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=e?e+l:l,this._events[d]&&a(this,d)):(this._events=new t,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=e,o.EventEmitter=o,s.exports=o})({get exports(){return fa},set exports(s){fa=s}});var wn=fa;function va(s,n){if(!((e=n.remuxResult).audio||e.video||e.text||e.id3||e.initSegment))return!1;var e,t=[],r=n.remuxResult,i=r.audio,a=r.video;return i&&us(t,i),a&&us(t,a),s.postMessage({event:"transmuxComplete",data:n},t),!0}function us(s,n){n.data1&&s.push(n.data1.buffer),n.data2&&s.push(n.data2.buffer)}function ds(s,n,e){n.reduce(function(t,r){return va(s,r)||t},!1)||s.postMessage({event:"transmuxComplete",data:n[0]}),s.postMessage({event:"flush",data:e})}M!==void 0&&M&&function(s){var n=new wn,e=function(r,i){s.postMessage({event:r,data:i})};n.on(E.FRAG_DECRYPTED,e),n.on(E.ERROR,e);var t=function(){var r=function(a){var o=function(l){e("workerLog",{logType:a,message:l})};P[a]=o};for(var i in P)r(i)};s.addEventListener("message",function(r){var i=r.data;switch(i.cmd){case"init":var a=JSON.parse(i.config);s.transmuxer=new ca(n,i.typeSupported,a,i.vendor,i.id),$e(a.debug,i.id),t(),e("init",null);break;case"configure":s.transmuxer.configure(i.config);break;case"demux":var o=s.transmuxer.push(i.data,i.decryptdata,i.chunkMeta,i.state);yr(o)?(s.transmuxer.async=!0,o.then(function(u){va(s,u)}).catch(function(u){e(E.ERROR,{type:te.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker push error"})})):(s.transmuxer.async=!1,va(s,o));break;case"flush":var l=i.chunkMeta,d=s.transmuxer.flush(l);yr(d)||s.transmuxer.async?(yr(d)||(d=Promise.resolve(d)),d.then(function(u){ds(s,u,l)}).catch(function(u){e(E.ERROR,{type:te.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,chunkMeta:i.chunkMeta,fatal:!1,error:u,err:u,reason:"transmuxer-worker flush error"})})):ds(s,d,l)}})}(self);var ga=ra()||{isTypeSupported:function(){return!1}},cs=function(){function s(e,t,r,i){var a=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 o=e.config;this.hls=e,this.id=t,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;var l=function(A,p){(p=p||{}).frag=a.frag,p.id=a.id,A===E.ERROR&&(a.error=p.error),a.hls.trigger(A,p)};this.observer=new wn,this.observer.on(E.FRAG_DECRYPTED,l),this.observer.on(E.ERROR,l);var d,u,c,h,v={mp4:ga.isTypeSupported("video/mp4"),mpeg:ga.isTypeSupported("audio/mpeg"),mp3:ga.isTypeSupported('audio/mp4; codecs="mp3"')},y=navigator.vendor;if(!this.useWorker||typeof Worker=="undefined"||(o.workerPath,0))this.transmuxer=new ca(this.observer,v,o,y,t);else try{o.workerPath?(P.log("loading Web Worker "+o.workerPath+' for "'+t+'"'),this.workerContext=(c=o.workerPath,h=new self.URL(c,self.location.href).href,{worker:new self.Worker(h),scriptURL:h})):(P.log('injecting Web Worker for "'+t+'"'),this.workerContext=(d=new self.Blob(["var exports={};var module={exports:exports};function define(f){f()};define.amd=true;("+I.toString()+")(true);"],{type:"text/javascript"}),u=self.URL.createObjectURL(d),{worker:new self.Worker(u),objectURL:u})),this.onwmsg=function(A){return a.onWorkerMessage(A)};var T=this.workerContext.worker;T.addEventListener("message",this.onwmsg),T.onerror=function(A){var p=new Error(A.message+" ("+A.filename+":"+A.lineno+")");o.enableWorker=!1,P.warn('Error in "'+t+'" Web Worker, fallback to inline'),a.hls.trigger(E.ERROR,{type:te.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:p})},T.postMessage({cmd:"init",typeSupported:v,vendor:y,id:t,config:JSON.stringify(o)})}catch(A){P.warn('Error setting up "'+t+'" Web Worker, fallback to inline',A),this.resetWorker(),this.error=null,this.transmuxer=new ca(this.observer,v,o,y,t)}}var n=s.prototype;return n.resetWorker=function(){if(this.workerContext){var e=this.workerContext,t=e.worker,r=e.objectURL;r&&self.URL.revokeObjectURL(r),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}},n.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},n.push=function(e,t,r,i,a,o,l,d,u,c){var h,v,y=this;u.transmuxing.start=self.performance.now();var T=this.transmuxer,A=o?o.start:a.start,p=a.decryptdata,_=this.frag,L=!(_&&a.cc===_.cc),w=!(_&&u.level===_.level),x=_?u.sn-_.sn:-1,F=this.part?u.part-this.part.index:-1,G=x===0&&u.id>1&&u.id===(_==null?void 0:_.stats.chunkCount),W=!w&&(x===1||x===0&&(F===1||G&&F<=0)),q=self.performance.now();(w||x||a.stats.parsing.start===0)&&(a.stats.parsing.start=q),!o||!F&&W||(o.stats.parsing.start=q);var V=!(_&&((h=a.initSegment)==null?void 0:h.url)===((v=_.initSegment)==null?void 0:v.url)),Z=new Uo(L,W,d,w,A,V);if(!W||L||V){P.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
21
|
+
discontinuity: `+L+`
|
|
22
|
+
trackSwitch: `+w+`
|
|
23
|
+
contiguous: `+W+`
|
|
24
|
+
accurateTimeOffset: `+d+`
|
|
25
|
+
timeOffset: `+A+`
|
|
26
|
+
initSegmentChange: `+V);var X=new No(r,i,t,l,c);this.configureTransmuxer(X)}if(this.frag=a,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:u,state:Z},e instanceof ArrayBuffer?[e]:[]);else if(T){var ie=T.push(e,p,u,Z);yr(ie)?(T.async=!0,ie.then(function(ye){y.handleTransmuxComplete(ye)}).catch(function(ye){y.transmuxerError(ye,u,"transmuxer-interface push error")})):(T.async=!1,this.handleTransmuxComplete(ie))}},n.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){var i=r.flush(e);yr(i)||r.async?(yr(i)||(i=Promise.resolve(i)),i.then(function(a){t.handleFlushResult(a,e)}).catch(function(a){t.transmuxerError(a,e,"transmuxer-interface flush error")})):this.handleFlushResult(i,e)}},n.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))},n.handleFlushResult=function(e,t){var r=this;e.forEach(function(i){r.handleTransmuxComplete(i)}),this.onFlush(t)},n.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":var i,a=(i=this.workerContext)==null?void 0:i.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":P[t.data.logType]&&P[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},n.configureTransmuxer=function(e){var t=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},n.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},s}(),Bo=function(){function s(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}var n=s.prototype;return n.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},n.poll=function(e,t){var r=this.config,i=this.media,a=this.stalled;if(i!==null){var o=i.currentTime,l=i.seeking,d=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,o===e){if(u||d)this.stalled=null;else if(!(i.paused&&!l||i.ended||i.playbackRate===0)&&le.getBuffered(i).length){var c=le.bufferInfo(i,o,0),h=c.len>0,v=c.nextStart||0;if(h||v){if(l){var y=c.len>2,T=!v||t&&t.start<=o||v-o>2&&!this.fragmentTracker.getPartialFragment(o);if(y||T)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var A,p=Math.max(v,c.start||0)-o,_=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=!(_==null||(A=_.details)==null)&&A.live?2*_.details.targetduration:2,w=this.fragmentTracker.getPartialFragment(o);if(p>0&&(p<=L||w))return void this._trySkipBufferHole(w)}var x=self.performance.now();if(a!==null){var F=x-a;if(l||!(F>=250)||(this._reportStall(c),this.media)){var G=le.bufferInfo(i,o,r.maxBufferHole);this._tryFixBufferStall(G,F)}}else this.stalled=x}}}else if(this.moved=!0,a!==null){if(this.stallReported){var W=self.performance.now()-a;P.warn("playback not stuck anymore @"+o+", after "+Math.round(W)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},n._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,a=this.media;if(a!==null){var o=a.currentTime,l=i.getPartialFragment(o);if(l&&(this._trySkipBufferHole(l)||!this.media))return;(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-o<r.maxBufferHole)&&t>1e3*r.highBufferWatchdogPeriod&&(P.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},n._reportStall=function(e){var t=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var i=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")");P.warn(i.message),t.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}},n._trySkipBufferHole=function(e){var t=this.config,r=this.hls,i=this.media;if(i===null)return 0;var a=i.currentTime,o=le.bufferInfo(i,a,0),l=a<o.start?o.start:o.nextStart;if(l){var d=o.len<=t.maxBufferHole,u=o.len>0&&o.len<1&&i.readyState<3;if(a<l&&(d||u)){var c=Math.max(l+.05,a+.1);if(P.warn("skipping hole, adjusting currentTime from "+a+" to "+c),this.moved=!0,this.stalled=null,i.currentTime=c,e&&!e.gap){var h=new Error("fragment loaded with buffer holes, seeking from "+a+" to "+c);r.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return c}}return 0},n._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(r!==null){var a=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var o=a+(i+1)*e.nudgeOffset,l=new Error("Nudging 'currentTime' from "+a+" to "+o);P.warn(l.message),r.currentTime=o,t.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.BUFFER_NUDGE_ON_STALL,error:l,fatal:!1})}else{var d=new Error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges");P.error(d.message),t.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.BUFFER_STALLED_ERROR,error:d,fatal:!0})}}},s}(),Go=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[stream-controller]")||this).audioCodecSwap=!1,a.gapController=null,a.level=-1,a._forceStartLoad=!1,a.altAudio=!1,a.audioOnly=!1,a.fragPlaying=null,a.onvplaying=null,a.onvseeked=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a._registerListeners(),a}fe(n,s);var e=n.prototype;return e._registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(E.ERROR,this.onError,this),t.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(E.BUFFER_CREATED,this.onBufferCreated,this),t.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(E.ERROR,this.onError,this),t.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(E.BUFFER_CREATED,this.onBufferCreated,this),t.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},e.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},e.startLoad=function(t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=i.startLevel;a===-1&&(i.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=i.nextAutoLevel),this.level=i.nextLoadLevel=a,this.loadedmetadata=!1}r>0&&t===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r),this.state=de,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Fe},e.stopLoad=function(){this._forceStartLoad=!1,s.prototype.stopLoad.call(this)},e.doTick=function(){switch(this.state){case Xr:var t,r=this.levels,i=this.level,a=r==null||(t=r[i])==null?void 0:t.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=de;break}break;case gt:var o,l=self.performance.now(),d=this.retryDate;(!d||l>=d||(o=this.media)!=null&&o.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=de)}this.state===de&&this.doTickIdle(),this.onTickEnd()},e.onTickEnd=function(){s.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},e.doTickIdle=function(){var t=this.hls,r=this.levelLastLoaded,i=this.levels,a=this.media,o=t.config,l=t.nextLoadLevel;if(r!==null&&(a||!this.startFragRequested&&o.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&i!=null&&i[l]){var d=i[l],u=this.getMainFwdBufferInfo();if(u!==null){var c=this.getLevelDetails();if(c&&this._streamEnded(u,c)){var h={};return this.altAudio&&(h.type="video"),this.hls.trigger(E.BUFFER_EOS,h),void(this.state=pr)}this.level=t.nextLoadLevel=l;var v=d.details;if(!v||this.state===Xr||v.live&&this.levelLastLoaded!==l)return this.level=l,void(this.state=Xr);var y=u.len,T=this.getMaxBufferLength(d.maxBitrate);if(!(y>=T)){this.backtrackFragment&&this.backtrackFragment.start>u.end&&(this.backtrackFragment=null);var A=this.backtrackFragment?this.backtrackFragment.start:u.end,p=this.getNextFragment(A,v);if(this.couldBacktrack&&!this.fragPrevious&&p&&p.sn!=="initSegment"&&this.fragmentTracker.getState(p)!==O){var _,L=((_=this.backtrackFragment)!=null?_:p).sn-v.startSN,w=v.fragments[L-1];w&&p.cc===w.cc&&(p=w,this.fragmentTracker.removeFragment(w))}else this.backtrackFragment&&u.len&&(this.backtrackFragment=null);if(p&&this.isLoopLoading(p,A)){if(!p.gap){var x=this.audioOnly&&!this.altAudio?_e:ze,F=(x===ze?this.videoBuffer:this.mediaBuffer)||this.media;F&&this.afterBufferFlushed(F,x,Ne)}p=this.getNextFragmentLoopLoading(p,v,u,Ne,T)}p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),this.loadFragment(p,d,A))}}}},e.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);this.fragCurrent=t,a===k?t.sn==="initSegment"?this._loadInitSegment(t,r):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,r)):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},e.getAppendedFrag=function(t){var r=this.fragmentTracker.getAppendedFrag(t,Ne);return r&&"fragment"in r?r.fragment:r},e.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,Ne)},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,r=this.media;if(r!=null&&r.readyState){var i,a=this.getAppendedFrag(r.currentTime);if(a&&a.start>1&&this.flushMainBuffer(0,a.start-1),!r.paused&&t){var o=t[this.hls.nextLoadLevel],l=this.fragLastKbps;i=l&&this.fragCurrent?this.fragCurrent.duration*o.maxBitrate/(1e3*l)+1:0}else i=0;var d=this.getBufferedFrag(r.currentTime+i);if(d){var u=this.followingBufferedFrag(d);if(u){this.abortCurrentFrag();var c=u.maxStartPTS?u.maxStartPTS:u.start,h=u.duration,v=Math.max(d.end,c+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,.5*h),.75*h));this.flushMainBuffer(v,Number.POSITIVE_INFINITY)}}}},e.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&t.abortRequests(),this.state){case Lt:case wt:case gt:case ft:case zr:this.state=de}this.nextLoadPosition=this.getLoadPosition()},e.flushMainBuffer=function(t,r){s.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},e.onMediaAttached=function(t,r){s.prototype.onMediaAttached.call(this,t,r);var i=r.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 Bo(this.config,i,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),s.prototype.onMediaDetaching.call(this)},e.onMediaPlaying=function(){this.tick()},e.onMediaSeeked=function(){var t=this.media,r=t?t.currentTime:null;Q(r)&&this.log("Media seeked to "+r.toFixed(3));var i=this.getMainFwdBufferInfo();i!==null&&i.len!==0?this.tick():this.warn('Main forward buffer length on "seeked" event '+(i?i.len:"empty")+")")},e.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},e.onManifestParsed=function(t,r){var i,a,o,l=!1,d=!1;r.levels.forEach(function(u){(i=u.audioCodec)&&(i.indexOf("mp4a.40.2")!==-1&&(l=!0),i.indexOf("mp4a.40.5")!==-1&&(d=!0))}),this.audioCodecSwitch=l&&d&&typeof((o=Wa())==null||(a=o.prototype)==null?void 0:a.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=r.levels,this.startFragRequested=!1},e.onLevelLoading=function(t,r){var i=this.levels;if(i&&this.state===de){var a=i[r.level];(!a.details||a.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(a.details))&&(this.state=Xr)}},e.onLevelLoaded=function(t,r){var i,a=this.levels,o=r.level,l=r.details,d=l.totalduration;if(a){this.log("Level "+o+" loaded ["+l.startSN+","+l.endSN+"], cc ["+l.startCC+", "+l.endCC+"] duration:"+d);var u=this.fragCurrent;!u||this.state!==wt&&this.state!==gt||u.level!==r.level&&u.loader&&this.abortCurrentFrag();var c=a[o],h=0;if(l.live||(i=c.details)!=null&&i.live){if(l.fragments[0]||(l.deltaUpdateFailed=!0),l.deltaUpdateFailed)return;h=this.alignPlaylists(l,c.details)}if(c.details=l,this.levelLastLoaded=o,this.hls.trigger(E.LEVEL_UPDATED,{details:l,level:o}),this.state===Xr){if(this.waitForCdnTuneIn(l))return;this.state=de}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,h),this.tick()}else this.warn("Levels were reset while loading level "+o)},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.levels;if(l){var d=l[i.level],u=d.details;if(u){var c=d.videoCodec,h=u.PTSKnown||!u.live,v=(r=i.initSegment)==null?void 0:r.data,y=this._getAudioCodec(d),T=this.transmuxer=this.transmuxer||new cs(this.hls,Ne,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),A=a?a.index:-1,p=A!==-1,_=new Ve(i.level,i.sn,i.stats.chunkCount,o.byteLength,A,p),L=this.initPTS[i.cc];T.push(o,v,y,c,i,a,u.totalduration,h,_,L)}else this.warn("Dropping fragment "+i.sn+" of level "+i.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},e.onAudioTrackSwitching=function(t,r){var i=this.altAudio;if(!r.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 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();var o=this.hls;i&&(o.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),o.trigger(E.AUDIO_TRACK_SWITCHED,r)}},e.onAudioTrackSwitched=function(t,r){var i=r.id,a=!!this.hls.audioTracks[i].url;if(a){var o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=a,this.tick()},e.onBufferCreated=function(t,r){var i,a,o=r.tracks,l=!1;for(var d in o){var u=o[d];if(u.id==="main"){if(a=d,i=u,d==="video"){var c=o[d];c&&(this.videoBuffer=c.buffer)}}else l=!0}l&&i?(this.log("Alternate track found, use "+a+".buffered to schedule main fragment loading"),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media},e.onFragBuffered=function(t,r){var i=r.frag,a=r.part;if(!i||i.type===Ne){if(this.fragContextChanged(i))return this.warn("Fragment "+i.sn+(a?" p: "+a.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===zr&&(this.state=de));var o=a?a.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,a)}},e.onError=function(t,r){var i;if(r.fatal)this.state=lr;else switch(r.details){case U.FRAG_GAP:case U.FRAG_PARSING_ERROR:case U.FRAG_DECRYPT_ERROR:case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Ne,r);break;case U.LEVEL_LOAD_ERROR:case U.LEVEL_LOAD_TIMEOUT:case U.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==Xr||((i=r.context)==null?void 0:i.type)!==er||(this.state=de);break;case U.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="main")return;this.reduceLengthAndFlushBuffer(r)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case U.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.checkBuffer=function(){var t=this.media,r=this.gapController;if(t&&r&&t.readyState){if(this.loadedmetadata||!le.getBuffered(t).length){var i=this.state!==de?this.fragCurrent:null;r.poll(this.lastCurrentTime,i)}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,r){var i=r.type;if(i!==_e||this.audioOnly&&!this.altAudio){var a=(i===ze?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(a,i,Ne)}},e.onLevelsUpdated=function(t,r){this.levels=r.levels},e.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},e.seekToStartPos=function(){var t=this.media;if(t){var r=t.currentTime,i=this.startPosition;if(i>=0&&r<i){if(t.seeking)return void this.log("could not seek to "+i+", already seeking at "+r);var a=le.getBuffered(t),o=(a.length?a.start(0):0)-i;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+o+" to match buffer start"),i+=o,this.startPosition=i),this.log("seek to target start position "+i+" from current time "+r),t.currentTime=i}}},e._getAudioCodec=function(t){var r=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r=r.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),r},e._loadBitrateTestFrag=function(t,r){var i=this;t.bitrateTest=!0,this._doFragLoad(t,r).then(function(a){var o=i.hls;if(a&&!i.fragContextChanged(t)){r.fragmentError=0,i.state=de,i.startFragRequested=!1,i.bitrateTest=!1;var l=t.stats;l.parsing.start=l.parsing.end=l.buffering.start=l.buffering.end=self.performance.now(),o.trigger(E.FRAG_LOADED,a),t.bitrateTest=!1}})},e._handleTransmuxComplete=function(t){var r,i="main",a=this.hls,o=t.remuxResult,l=t.chunkMeta,d=this.getCurrentContext(l);if(!d)return this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(l.level);var u=d.frag,c=d.part,h=d.level,v=o.video,y=o.text,T=o.id3,A=o.initSegment,p=h.details,_=this.altAudio?void 0:o.audio;if(this.fragContextChanged(u))this.fragmentTracker.removeFragment(u);else{if(this.state=ft,A){A.tracks&&(this._bufferInitSegment(h,A.tracks,u,l),a.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:i,tracks:A.tracks}));var L=A.initPTS,w=A.timescale;Q(L)&&(this.initPTS[u.cc]={baseTime:L,timescale:w},a.trigger(E.INIT_PTS_FOUND,{frag:u,id:i,initPTS:L,timescale:w}))}if(v&&o.independent!==!1){if(p){var x=v.startPTS,F=v.endPTS,G=v.startDTS,W=v.endDTS;if(c)c.elementaryStreams[v.type]={startPTS:x,endPTS:F,startDTS:G,endDTS:W};else if(v.firstKeyFrame&&v.independent&&l.id===1&&(this.couldBacktrack=!0),v.dropped&&v.independent){var q=this.getMainFwdBufferInfo();if((q?q.end:this.getLoadPosition())+this.config.maxBufferHole<(v.firstKeyFramePTS?v.firstKeyFramePTS:x)-this.config.maxBufferHole)return void this.backtrack(u);u.setElementaryStreamInfo(v.type,u.start,F,u.start,W,!0)}u.setElementaryStreamInfo(v.type,x,F,G,W),this.backtrackFragment&&(this.backtrackFragment=u),this.bufferFragmentData(v,u,c,l)}}else if(o.independent===!1)return void this.backtrack(u);if(_){var V=_.startPTS,Z=_.endPTS,X=_.startDTS,ie=_.endDTS;c&&(c.elementaryStreams[_e]={startPTS:V,endPTS:Z,startDTS:X,endDTS:ie}),u.setElementaryStreamInfo(_e,V,Z,X,ie),this.bufferFragmentData(_,u,c,l)}if(p&&T!=null&&(r=T.samples)!=null&&r.length){var ye={id:i,frag:u,details:p,samples:T.samples};a.trigger(E.FRAG_PARSING_METADATA,ye)}if(p&&y){var ae={id:i,frag:u,details:p,samples:y.samples};a.trigger(E.FRAG_PARSING_USERDATA,ae)}}},e._bufferInitSegment=function(t,r,i,a){var o=this;if(this.state===ft){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var l=r.audio,d=r.video,u=r.audiovideo;if(l){var c=t.audioCodec,h=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(c&&(c=c.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),l.metadata.channelCount!==1&&h.indexOf("firefox")===-1&&(c="mp4a.40.5")),h.indexOf("android")!==-1&&l.container!=="audio/mpeg"&&(c="mp4a.40.2",this.log("Android: force audio codec to "+c)),t.audioCodec&&t.audioCodec!==c&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+c+'"'),l.levelCodec=c,l.id="main",this.log("Init audio buffer, container:"+l.container+", codecs[selected/level/parsed]=["+(c||"")+"/"+(t.audioCodec||"")+"/"+l.codec+"]")}d&&(d.levelCodec=t.videoCodec,d.id="main",this.log("Init video buffer, container:"+d.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+d.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(E.BUFFER_CODECS,r),Object.keys(r).forEach(function(v){var y=r[v].initSegment;y!=null&&y.byteLength&&o.hls.trigger(E.BUFFER_APPENDING,{type:v,data:y,frag:i,part:null,chunkMeta:a,parent:i.type})}),this.tick()}},e.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Ne)},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,r=null;if(t&&t.readyState>1&&t.seeking===!1){var i=t.currentTime;if(le.isBuffered(t,i)?r=this.getAppendedFrag(i):le.isBuffered(t,i+.1)&&(r=this.getAppendedFrag(i+.1)),r){this.backtrackFragment=null;var a=this.fragPlaying,o=r.level;a&&r.sn===a.sn&&a.level===o&&r.urlId===a.urlId||(this.fragPlaying=r,this.hls.trigger(E.FRAG_CHANGED,{frag:r}),a&&a.level===o||this.hls.trigger(E.LEVEL_SWITCHED,{level:o}))}}},j(n,[{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 r=t.currentTime,i=this.currentFrag;if(i&&Q(r)&&Q(i.programDateTime)){var a=i.programDateTime+1e3*(r-i.start);return new Date(a)}}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}}]),n}(ta),Jr=function(){function s(e,t,r){t===void 0&&(t=0),r===void 0&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var n=s.prototype;return n.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},n.getTotalWeight=function(){return this.totalWeight_},n.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},s}(),Ho=function(){function s(e,t,r,i){i===void 0&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Jr(e),this.fast_=new Jr(t),this.defaultTTFB_=i,this.ttfb_=new Jr(e)}var n=s.prototype;return n.update=function(e,t){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new Jr(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new Jr(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new Jr(e,a.getEstimate(),a.getTotalWeight()))},n.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},n.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},n.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},n.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},n.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},n.destroy=function(){},s}(),Ko=function(){function s(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 Ho(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this)},n.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},n.onFragLoading=function(e,t){var r,i=t.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=(r=t.part)!=null?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},n.onLevelSwitching=function(e,t){this.clearTimer()},n.getTimeToLoadFrag=function(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)},n.onLevelLoaded=function(e,t){var r=this.hls.config,i=t.stats,a=i.total,o=i.bwEstimate;Q(a)&&Q(o)&&(this.lastLevelLoadSec=8*a/o),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},n._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.autoLevelEnabled,a=r.media;if(e&&a){var o=performance.now(),l=t?t.stats:e.stats,d=t?t.duration:e.duration,u=o-l.loading.start;if(l.aborted||l.loaded&&l.loaded===l.total||e.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(i&&!a.paused&&a.playbackRate&&a.readyState){var c=r.mainForwardBufferInfo;if(c!==null){var h=this.bwEstimator.getEstimateTTFB(),v=Math.abs(a.playbackRate);if(!(u<=Math.max(h,d/(2*v)*1e3))){var y=c.len/v;if(!(y>=2*d/v)){var T=l.loading.first?l.loading.first-l.loading.start:-1,A=l.loaded&&T>-1,p=this.bwEstimator.getEstimate(),_=r.levels,L=r.minAutoLevel,w=_[e.level],x=l.total||Math.max(l.loaded,Math.round(d*w.maxBitrate/8)),F=u-T;F<1&&A&&(F=Math.min(u,8*l.loaded/p));var G=A?1e3*l.loaded/F:0,W=G?(x-l.loaded)/G:8*x/p+h/1e3;if(!(W<=y)){var q,V=G?8*G:p,Z=Number.POSITIVE_INFINITY;for(q=e.level-1;q>L;q--){var X=_[q].maxBitrate;if((Z=this.getTimeToLoadFrag(h/1e3,V,d*X,!_[q].details))<y)break}Z>=W||Z>10*d||(r.nextLoadLevel=q,A?this.bwEstimator.sample(u-Math.min(h,T),l.loaded):this.bwEstimator.sampleTTFB(u),this.clearTimer(),P.warn("[abr] Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+` is loading too slowly;
|
|
27
|
+
Time to underbuffer: `+y.toFixed(3)+` s
|
|
28
|
+
Estimated load time for current fragment: `+W.toFixed(3)+` s
|
|
29
|
+
Estimated load time for down switch fragment: `+Z.toFixed(3)+` s
|
|
30
|
+
TTFB estimate: `+T+`
|
|
31
|
+
Current BW estimate: `+(Q(p)?(p/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()),r.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:l}))}}}}}}},n.onFragLoaded=function(e,t){var r=t.frag,i=t.part,a=i?i.stats:r.stats;if(r.type===Ne&&this.bwEstimator.sampleTTFB(a.loading.first-a.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var o=i?i.duration:r.duration,l=this.hls.levels[r.level],d=(l.loaded?l.loaded.bytes:0)+a.loaded,u=(l.loaded?l.loaded.duration:0)+o;l.loaded={bytes:d,duration:u},l.realBitrate=Math.round(8*d/u)}if(r.bitrateTest){var c={stats:a,frag:r,part:i,id:r.type};this.onFragBuffered(E.FRAG_BUFFERED,c),r.bitrateTest=!1}}},n.onFragBuffered=function(e,t){var r=t.frag,i=t.part,a=i!=null&&i.stats.loaded?i.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var o=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}},n.ignoreFragment=function(e){return e.type!==Ne||e.sn==="initSegment"},n.clearTimer=function(){self.clearInterval(this.timer)},n.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,a=r.config,o=r.minAutoLevel,l=r.media,d=t?t.duration:e?e.duration:0,u=l&&l.playbackRate!==0?Math.abs(l.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,h=r.mainForwardBufferInfo,v=(h?h.len:0)/u,y=this.findBestLevel(c,o,i,v,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(y>=0)return y;P.trace("[abr] "+(v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var T=d?Math.min(d,a.maxStarvationDelay):a.maxStarvationDelay,A=a.abrBandWidthFactor,p=a.abrBandWidthUpFactor;if(!v){var _=this.bitrateTestDelay;_&&(T=(d?Math.min(d,a.maxLoadingDelay):a.maxLoadingDelay)-_,P.trace("[abr] bitrate test took "+Math.round(1e3*_)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*T)+" ms"),A=p=1)}return y=this.findBestLevel(c,o,i,v+T,A,p),Math.max(y,0)},n.findBestLevel=function(e,t,r,i,a,o){for(var l,d=this.fragCurrent,u=this.partCurrent,c=this.lastLoadedFragLevel,h=this.hls.levels,v=h[c],y=!(v==null||(l=v.details)==null||!l.live),T=v==null?void 0:v.codecSet,A=u?u.duration:d?d.duration:0,p=this.bwEstimator.getEstimateTTFB()/1e3,_=t,L=-1,w=r;w>=t;w--){var x=h[w];if(!x||T&&x.codecSet!==T)x&&(_=Math.min(w,_),L=Math.max(w,L));else{L!==-1&&P.trace("[abr] Skipped level(s) "+_+"-"+L+' with CODECS:"'+h[L].attrs.CODECS+'"; not compatible with "'+v.attrs.CODECS+'"');var F=x.details,G=(u?F==null?void 0:F.partTarget:F==null?void 0:F.averagetargetduration)||A,W=void 0;W=w<=c?a*e:o*e;var q=h[w].maxBitrate,V=this.getTimeToLoadFrag(p,W,q*G,F===void 0);if(P.trace("[abr] level:"+w+" adjustedbw-bitrate:"+Math.round(W-q)+" avgDuration:"+G.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+V.toFixed(1)),W>q&&(V===0||!Q(V)||y&&!this.bitrateTestDelay||V<i))return w}}return-1},j(s,[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;var r=this.getNextABRAutoLevel();return e!==-1&&this.hls.levels[r].loadError?e:(e!==-1&&(r=Math.min(e,r)),r)},set:function(e){this._nextAutoLevel=e}}]),s}(),hs=function(){function s(){this.chunks=[],this.dataLength=0}var n=s.prototype;return n.push=function(e){this.chunks.push(e),this.dataLength+=e.length},n.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=t.length===1?t[0]:function(i,a){for(var o=new Uint8Array(a),l=0,d=0;d<i.length;d++){var u=i[d];o.set(u,l),l+=u.length}return o}(t,r),this.reset(),e):new Uint8Array(0)},n.reset=function(){this.chunks.length=0,this.dataLength=0},s}(),qo=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[audio-stream-controller]")||this).videoBuffer=null,a.videoTrackCC=-1,a.waitingVideoCC=-1,a.bufferedTrack=null,a.switchingTrack=null,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.bufferFlushed=!1,a.cachedTrackLoadedData=null,a._registerListeners(),a}fe(n,s);var e=n.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(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(E.ERROR,this.onError,this),t.on(E.BUFFER_RESET,this.onBufferReset,this),t.on(E.BUFFER_CREATED,this.onBufferCreated,this),t.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(E.ERROR,this.onError,this),t.off(E.BUFFER_RESET,this.onBufferReset,this),t.off(E.BUFFER_CREATED,this.onBufferCreated,this),t.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(E.FRAG_BUFFERED,this.onFragBuffered,this)},e.onInitPtsFound=function(t,r){var i=r.frag,a=r.id,o=r.initPTS,l=r.timescale;if(a==="main"){var d=i.cc;this.initPTS[i.cc]={baseTime:o,timescale:l},this.log("InitPTS for cc: "+d+" found from main: "+o),this.videoTrackCC=d,this.state===Ci&&this.tick()}},e.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=Fe);var r=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),r>0&&t===-1?(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),t=r,this.state=de):(this.loadedmetadata=!1,this.state=Ye),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},e.doTick=function(){switch(this.state){case de:this.doTickIdle();break;case Ye:var t,r=this.levels,i=this.trackId,a=r==null||(t=r[i])==null?void 0:t.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=Ci}break;case gt:var o,l=performance.now(),d=this.retryDate;(!d||l>=d||(o=this.media)!=null&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=de);break;case Ci:var u=this.waitingData;if(u){var c=u.frag,h=u.part,v=u.cache,y=u.complete;if(this.initPTS[c.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=wt;var T={frag:c,part:h,payload:v.flush(),networkDetails:null};this._handleFragmentLoadProgress(T),y&&s.prototype._handleFragmentLoadComplete.call(this,T)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var A=this.getLoadPosition(),p=le.bufferInfo(this.mediaBuffer,A,this.config.maxBufferHole);Di(p.end,this.config.maxFragLookUpTolerance,c)<0&&(this.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+p.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(),s.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,r=this.levels,i=this.media,a=this.trackId,o=t.config;if(r!=null&&r[a]&&(i||!this.startFragRequested&&o.startFragPrefetch)){var l=r[a],d=l.details;if(!d||d.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(d))this.state=Ye;else{var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,_e,Ft));var c=this.getFwdBufferInfo(u,Ft);if(c!==null){var h=!!this.switchingTrack;if(!h&&this._streamEnded(c,d))return t.trigger(E.BUFFER_EOS,{type:"audio"}),void(this.state=pr);var v=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Ne),y=c.len,T=this.getMaxBufferLength(v==null?void 0:v.len);if(!(y>=T)||h){var A=d.fragments[0].start,p=c.end;if(h&&i){var _=this.getLoadPosition();p=_,d.PTSKnown&&_<A&&(c.end>A||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=A+.05)}var L=this.getNextFragment(p,d),w=!1;if(L&&this.isLoopLoading(L,p)&&(w=!!L.gap,L=this.getNextFragmentLoopLoading(L,d,c,Ne,T)),L){var x=v&&L.start>v.end+d.targetduration;if(x||(v==null||!v.len)&&c.len){var F=this.fragmentTracker.getBufferedFrag(L.start,Ne);if(F===null||(w||(w=!!F.gap||!!x&&v.len===0),x&&!w||w&&c.nextStart&&c.nextStart<F.end))return}this.loadFragment(L,l,p)}else this.bufferFlushed=!0}}}}},e.getMaxBufferLength=function(t){var r=s.prototype.getMaxBufferLength.call(this);return t?Math.min(Math.max(r,t),this.config.maxMaxBufferLength):r},e.onMediaDetaching=function(){this.videoBuffer=null,s.prototype.onMediaDetaching.call(this)},e.onAudioTracksUpdated=function(t,r){var i=r.audioTracks;this.resetTransmuxer(),this.levels=i.map(function(a){return new Kr(a)})},e.onAudioTrackSwitching=function(t,r){var i=!!r.url;this.trackId=r.id;var a=this.fragCurrent;a&&(a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetLoadingState(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.switchingTrack=r,this.state=de):(this.switchingTrack=null,this.bufferedTrack=r,this.state=Fe),this.tick()},e.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.bufferedTrack=null,this.switchingTrack=null},e.onLevelLoaded=function(t,r){this.mainDetails=r.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(E.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},e.onAudioTrackLoaded=function(t,r){var i;if(this.mainDetails!=null){var a=this.levels,o=r.details,l=r.id;if(a){this.log("Track "+l+" loaded ["+o.startSN+","+o.endSN+"],duration:"+o.totalduration);var d=a[l],u=0;if(o.live||(i=d.details)!=null&&i.live){var c=this.mainDetails;if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed||!c)return;!d.details&&o.hasProgramDateTime&&c.hasProgramDateTime?(Ee(o,c),u=o.fragments[0].start):u=this.alignPlaylists(o,d.details)}d.details=o,this.levelLastLoaded=l,this.startFragRequested||!this.mainDetails&&o.live||this.setStartPosition(d.details,u),this.state!==Ye||this.waitForCdnTuneIn(o)||(this.state=de),this.tick()}else this.warn("Audio tracks were reset while loading level "+l)}else this.cachedTrackLoadedData=r},e._handleFragmentLoadProgress=function(t){var r,i=t.frag,a=t.part,o=t.payload,l=this.config,d=this.trackId,u=this.levels;if(u){var c=u[d];if(c){var h=c.details;if(h){var v=l.defaultAudioCodec||c.audioCodec||"mp4a.40.2",y=this.transmuxer;y||(y=this.transmuxer=new cs(this.hls,Ft,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var T=this.initPTS[i.cc],A=(r=i.initSegment)==null?void 0:r.data;if(T!==void 0){var p=a?a.index:-1,_=p!==-1,L=new Ve(i.level,i.sn,i.stats.chunkCount,o.byteLength,p,_);y.push(o,A,v,"",i,a,h.totalduration,!1,L,T)}else this.log("Unknown video PTS for cc "+i.cc+", waiting for video PTS before demuxing audio frag "+i.sn+" of ["+h.startSN+" ,"+h.endSN+"],track "+d),(this.waitingData=this.waitingData||{frag:i,part:a,cache:new hs,complete:!1}).cache.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=Ci}else this.warn("Audio track details undefined on fragment load progress")}else this.warn("Audio track is defined on fragment load progress")}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},e._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:s.prototype._handleFragmentLoadComplete.call(this,t)},e.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},e.onBufferCreated=function(t,r){var i=r.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),r.tracks.video&&(this.videoBuffer=r.tracks.video.buffer||null)},e.onFragBuffered=function(t,r){var i,a=r.frag,o=r.part;if(a.type===Ft)if(this.fragContextChanged(a))this.warn("Fragment "+a.sn+(o?" p: "+o.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 l=this.switchingTrack;l&&(this.bufferedTrack=l,this.switchingTrack=null,this.hls.trigger(E.AUDIO_TRACK_SWITCHED,H({},l)))}this.fragBufferedComplete(a,o)}else this.loadedmetadata||a.type!==Ne||(i=this.videoBuffer||this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)},e.onError=function(t,r){var i;if(r.fatal)this.state=lr;else switch(r.details){case U.FRAG_GAP:case U.FRAG_PARSING_ERROR:case U.FRAG_DECRYPT_ERROR:case U.FRAG_LOAD_ERROR:case U.FRAG_LOAD_TIMEOUT:case U.KEY_LOAD_ERROR:case U.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Ft,r);break;case U.AUDIO_TRACK_LOAD_ERROR:case U.AUDIO_TRACK_LOAD_TIMEOUT:case U.LEVEL_PARSING_ERROR:r.levelRetry||this.state!==Ye||((i=r.context)==null?void 0:i.type)!==kt||(this.state=de);break;case U.BUFFER_FULL_ERROR:if(!r.parent||r.parent!=="audio")return;this.reduceLengthAndFlushBuffer(r)&&(this.bufferedTrack=null,s.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case U.INTERNAL_EXCEPTION:this.recoverWorkerError(r)}},e.onBufferFlushed=function(t,r){r.type===_e&&(this.bufferFlushed=!0,this.state===pr&&(this.state=de))},e._handleTransmuxComplete=function(t){var r,i="audio",a=this.hls,o=t.remuxResult,l=t.chunkMeta,d=this.getCurrentContext(l);if(!d)return this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(l.level);var u=d.frag,c=d.part,h=d.level.details,v=o.audio,y=o.text,T=o.id3,A=o.initSegment;if(!this.fragContextChanged(u)&&h){if(this.state=ft,this.switchingTrack&&v&&this.completeAudioSwitch(this.switchingTrack),A!=null&&A.tracks&&(this._bufferInitSegment(A.tracks,u,l),a.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:i,tracks:A.tracks})),v){var p=v.startPTS,_=v.endPTS,L=v.startDTS,w=v.endDTS;c&&(c.elementaryStreams[_e]={startPTS:p,endPTS:_,startDTS:L,endDTS:w}),u.setElementaryStreamInfo(_e,p,_,L,w),this.bufferFragmentData(v,u,c,l)}if(T!=null&&(r=T.samples)!=null&&r.length){var x=z({id:i,frag:u,details:h},T);a.trigger(E.FRAG_PARSING_METADATA,x)}if(y){var F=z({id:i,frag:u,details:h},y);a.trigger(E.FRAG_PARSING_USERDATA,F)}}else this.fragmentTracker.removeFragment(u)},e._bufferInitSegment=function(t,r,i){if(this.state===ft){t.video&&delete t.video;var a=t.audio;if(a){a.levelCodec=a.codec,a.id="audio",this.log("Init audio buffer, container:"+a.container+", codecs[parsed]=["+a.codec+"]"),this.hls.trigger(E.BUFFER_CODECS,t);var o=a.initSegment;if(o!=null&&o.byteLength){var l={type:"audio",frag:r,part:null,chunkMeta:i,parent:r.type,data:o};this.hls.trigger(E.BUFFER_APPENDING,l)}this.tick()}}},e.loadFragment=function(t,r,i){var a,o=this.fragmentTracker.getState(t);this.fragCurrent=t,this.switchingTrack||o===k||o===N?t.sn==="initSegment"?this._loadInitSegment(t,r):(a=r.details)!=null&&a.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=Ci):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i)):this.clearTrackerIfNeeded(t)},e.completeAudioSwitch=function(t){var r=this.hls,i=this.media,a=this.bufferedTrack,o=a==null?void 0:a.attrs,l=t.attrs;i&&o&&(o.CHANNELS!==l.CHANNELS||o.NAME!==l.NAME||o.LANGUAGE!==l.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),s.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,r.trigger(E.AUDIO_TRACK_SWITCHED,H({},t))},n}(ta),jo=function(s){function n(t){var r;return(r=s.call(this,t,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.currentTrack=null,r.selectDefaultTrack=!0,r.registerListeners(),r}fe(n,s);var e=n.prototype;return e.registerListeners=function(){var t=this.hls;t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(E.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADING,this.onLevelLoading,this),t.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(E.ERROR,this.onError,this)},e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,s.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,r){this.tracks=r.audioTracks||[]},e.onAudioTrackLoaded=function(t,r){var i=r.id,a=r.groupId,o=r.details,l=this.tracksInGroup[i];if(l&&l.groupId===a){var d=l.details;l.details=r.details,this.log("audio-track "+i+' "'+l.name+'" lang:'+l.lang+" group:"+a+" loaded ["+o.startSN+"-"+o.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,r,d)}else this.warn("Track with id:"+i+" and group:"+a+" not found in active group "+l.groupId)},e.onLevelLoading=function(t,r){this.switchLevel(r.level)},e.onLevelSwitching=function(t,r){this.switchLevel(r.level)},e.switchLevel=function(t){var r=this.hls.levels[t];if(r!=null&&r.audioGroupIds){var i=r.audioGroupIds[r.urlId];if(this.groupId!==i){this.groupId=i||null;var a=this.tracks.filter(function(l){return!i||l.groupId===i});this.selectDefaultTrack&&!a.some(function(l){return l.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=a;var o={audioTracks:a};this.log("Updating audio tracks, "+a.length+" track(s) found in group:"+i),this.hls.trigger(E.AUDIO_TRACKS_UPDATED,o),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===kt&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(r))},e.setAudioTrack=function(t){var r=this.tracksInGroup;if(t<0||t>=r.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var i=this.currentTrack;r[this.trackId];var a=r[t],o=a.groupId,l=a.name;if(this.log("Switching to audio-track "+t+' "'+l+'" lang:'+a.lang+" group:"+o),this.trackId=t,this.currentTrack=a,this.selectDefaultTrack=!1,this.hls.trigger(E.AUDIO_TRACK_SWITCHING,H({},a)),!a.details||a.details.live){var d=this.switchParams(a.url,i==null?void 0:i.details);this.loadPlaylist(d)}}},e.selectInitialTrack=function(){var t=this.tracksInGroup,r=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(r!==-1)this.setAudioTrack(r);else{var i=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+t.length);this.warn(i.message),this.hls.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}},e.findTrackId=function(t){for(var r=this.tracksInGroup,i=0;i<r.length;i++){var a=r[i];if((!this.selectDefaultTrack||a.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]===a.attrs["STABLE-RENDITION-ID"]||t.name===a.name&&t.lang===a.lang))return a.id}return-1},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,a=r.groupId,o=r.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("loading audio-track playlist "+i+' "'+r.name+'" lang:'+r.lang+" group:"+a),this.clearTimer(),this.hls.trigger(E.AUDIO_TRACK_LOADING,{url:o,id:i,groupId:a,deliveryDirectives:t||null})}},j(n,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}]),n}(g),Vo=function(s){function n(t,r,i){var a;return(a=s.call(this,t,r,i,"[subtitle-stream-controller]")||this).levels=[],a.currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a._registerListeners(),a}fe(n,s);var e=n.prototype;return e.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},e._registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.LEVEL_LOADED,this.onLevelLoaded,this),t.on(E.ERROR,this.onError,this),t.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(E.FRAG_BUFFERED,this.onFragBuffered,this)},e._unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.LEVEL_LOADED,this.onLevelLoaded,this),t.off(E.ERROR,this.onError,this),t.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(E.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=[],s.prototype.onMediaDetaching.call(this)},e.onLevelLoaded=function(t,r){this.mainDetails=r.details},e.onSubtitleFragProcessed=function(t,r){var i=r.frag,a=r.success;if(this.fragPrevious=i,this.state=de,a){var o=this.tracksBuffered[this.currentTrackId];if(o){for(var l,d=i.start,u=0;u<o.length;u++)if(d>=o[u].start&&d<=o[u].end){l=o[u];break}var c=i.start+i.duration;l?l.end=c:(l={start:d,end:c},o.push(l)),this.fragmentTracker.fragBuffered(i)}}},e.onBufferFlushing=function(t,r){var i=r.startOffset,a=r.endOffset;if(i===0&&a!==Number.POSITIVE_INFINITY){var o=this.currentTrackId,l=this.levels;if(!l.length||!l[o]||!l[o].details)return;var d=a-l[o].details.targetduration;if(d<=0)return;r.endOffsetSubtitles=Math.max(0,d),this.tracksBuffered.forEach(function(u){for(var c=0;c<u.length;)if(u[c].end<=d)u.shift();else{if(!(u[c].start<d))break;u[c].start=d,c++}}),this.fragmentTracker.removeFragmentsInRange(i,d,Nt)}},e.onFragBuffered=function(t,r){var i;this.loadedmetadata||r.frag.type!==Ne||(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)},e.onError=function(t,r){var i=r.frag;(i==null?void 0:i.type)===Nt&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Fe&&(this.state=de))},e.onSubtitleTracksUpdated=function(t,r){var i=this,a=r.subtitleTracks;this.tracksBuffered=[],this.levels=a.map(function(o){return new Kr(o)}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Nt),this.fragPrevious=null,this.levels.forEach(function(o){i.tracksBuffered[o.id]=[]}),this.mediaBuffer=null},e.onSubtitleTrackSwitch=function(t,r){if(this.currentTrackId=r.id,this.levels.length&&this.currentTrackId!==-1){var i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(500)}else this.clearInterval()},e.onSubtitleTrackLoaded=function(t,r){var i,a=r.details,o=r.id,l=this.currentTrackId,d=this.levels;if(d.length){var u=d[l];if(!(o>=d.length||o!==l)&&u){this.mediaBuffer=this.mediaBufferTimeRanges;var c=0;if(a.live||(i=u.details)!=null&&i.live){var h=this.mainDetails;if(a.deltaUpdateFailed||!h)return;var v=h.fragments[0];u.details?(c=this.alignPlaylists(a,u.details))===0&&v&&Li(a,c=v.start):a.hasProgramDateTime&&h.hasProgramDateTime?(Ee(a,h),c=a.fragments[0].start):v&&Li(a,c=v.start)}u.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(u.details,c),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===de&&(mr(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),u.details=void 0))}}},e._handleFragmentLoadComplete=function(t){var r=this,i=t.frag,a=t.payload,o=i.decryptdata,l=this.hls;if(!this.fragContextChanged(i)&&a&&a.byteLength>0&&o&&o.key&&o.iv&&o.method==="AES-128"){var d=performance.now();this.decrypter.decrypt(new Uint8Array(a),o.key.buffer,o.iv.buffer).catch(function(u){throw l.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.FRAG_DECRYPT_ERROR,fatal:!1,error:u,reason:u.message,frag:i}),u}).then(function(u){var c=performance.now();l.trigger(E.FRAG_DECRYPTED,{frag:i,payload:u,stats:{tstart:d,tdecrypt:c}})}).catch(function(u){r.warn(u.name+": "+u.message),r.state=de})}},e.doTick=function(){if(this.media){if(this.state===de){var t=this.currentTrackId,r=this.levels,i=r[t];if(!r.length||!i||!i.details)return;var a=i.details,o=a.targetduration,l=this.config,d=this.getLoadPosition(),u=le.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],d-o,l.maxBufferHole),c=u.end,h=u.len,v=this.getFwdBufferInfo(this.media,Ne);if(h>this.getMaxBufferLength(v==null?void 0:v.len)+o)return;var y=a.fragments,T=y.length,A=a.edge,p=null,_=this.fragPrevious;if(c<A){var L=l.maxFragLookUpTolerance;!(p=mr(_,y,Math.max(y[0].start,c),L))&&_&&_.start<y[0].start&&(p=y[0])}else p=y[T-1];if(!p)return;p=this.mapToInitFragWhenRequired(p),this.fragmentTracker.getState(p)===k&&this.loadFragment(p,i,c)}}else this.state=de},e.getMaxBufferLength=function(t){var r=s.prototype.getMaxBufferLength.call(this);return t?Math.max(r,t):r},e.loadFragment=function(t,r,i){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,r):(this.startFragRequested=!0,s.prototype.loadFragment.call(this,t,r,i))},j(n,[{key:"mediaBufferTimeRanges",get:function(){return new Yo(this.tracksBuffered[this.currentTrackId]||[])}}]),n}(ta),Yo=function(s){this.buffered=void 0;var n=function(e,t,r){if((t>>>=0)>r-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+t+") is greater than the maximum bound ("+r+")");return s[t][e]};this.buffered={get length(){return s.length},end:function(e){return n("end",e,s.length)},start:function(e){return n("start",e,s.length)}}},Wo=function(s){function n(t){var r;return(r=s.call(this,t,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.registerListeners(),r}fe(n,s);var e=n.prototype;return e.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,s.prototype.destroy.call(this)},e.registerListeners=function(){var t=this.hls;t.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(E.MANIFEST_LOADING,this.onManifestLoading,this),t.on(E.MANIFEST_PARSED,this.onManifestParsed,this),t.on(E.LEVEL_LOADING,this.onLevelLoading,this),t.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(E.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(E.MANIFEST_LOADING,this.onManifestLoading,this),t.off(E.MANIFEST_PARSED,this.onManifestParsed,this),t.off(E.LEVEL_LOADING,this.onLevelLoading,this),t.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(E.ERROR,this.onError,this)},e.onMediaAttached=function(t,r){this.media=r.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),ma(this.media.textTracks).forEach(function(t){sr(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,r){this.tracks=r.subtitleTracks},e.onSubtitleTrackLoaded=function(t,r){var i=r.id,a=r.details,o=this.trackId,l=this.tracksInGroup[o];if(l){var d=l.details;l.details=r.details,this.log("subtitle track "+i+" loaded ["+a.startSN+"-"+a.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,r,d)}else this.warn("Invalid subtitle track id "+i)},e.onLevelLoading=function(t,r){this.switchLevel(r.level)},e.onLevelSwitching=function(t,r){this.switchLevel(r.level)},e.switchLevel=function(t){var r=this.hls.levels[t];if(r!=null&&r.textGroupIds){var i=r.textGroupIds[r.urlId],a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){var o=this.tracks.filter(function(u){return!i||u.groupId===i});this.tracksInGroup=o;var l=this.findTrackId(a==null?void 0:a.name)||this.findTrackId();this.groupId=i||null;var d={subtitleTracks:o};this.log("Updating subtitle tracks, "+o.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(E.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.setSubtitleTrack(l,a)}else this.shouldReloadPlaylist(a)&&this.setSubtitleTrack(this.trackId,a)}},e.findTrackId=function(t){for(var r=this.tracksInGroup,i=0;i<r.length;i++){var a=r[i];if((!this.selectDefaultTrack||a.default)&&(!t||t===a.name))return a.id}return-1},e.onError=function(t,r){!r.fatal&&r.context&&r.context.type===Rt&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.checkRetry(r)},e.loadPlaylist=function(t){s.prototype.loadPlaylist.call(this);var r=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(r)){var i=r.id,a=r.groupId,o=r.url;if(t)try{o=t.addDirectives(o)}catch(l){this.warn("Could not construct new URL with HLS Delivery Directives: "+l)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(E.SUBTITLE_TRACK_LOADING,{url:o,id:i,groupId:a,deliveryDirectives:t||null})}},e.toggleTrackModes=function(t){var r=this,i=this.media,a=this.trackId;if(i){var o=ma(i.textTracks),l=o.filter(function(c){return c.groupId===r.groupId});if(t===-1)[].slice.call(o).forEach(function(c){c.mode="disabled"});else{var d=l[a];d&&(d.mode="disabled")}var u=l[t];u&&(u.mode=this.subtitleDisplay?"showing":"hidden")}},e.setSubtitleTrack=function(t,r){var i,a=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(t===-1||(i=a[t])!=null&&i.details)||t<-1||t>=a.length)){this.clearTimer();var o=a[t];if(this.log("Switching to subtitle-track "+t+(o?' "'+o.name+'" lang:'+o.lang+" group:"+o.groupId:"")),this.trackId=t,o){var l=o.id,d=o.groupId,u=d===void 0?"":d,c=o.name,h=o.type,v=o.url;this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:l,groupId:u,name:c,type:h,url:v});var y=this.switchParams(o.url,r==null?void 0:r.details);this.loadPlaylist(y)}else this.hls.trigger(E.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,r=ma(this.media.textTracks),i=0;i<r.length;i++)if(r[i].mode==="hidden")t=i;else if(r[i].mode==="showing"){t=i;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},j(n,[{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 r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,r)}}]),n}(g);function ma(s){for(var n=[],e=0;e<s.length;e++){var t=s[e];t.kind!=="subtitles"&&t.kind!=="captions"||!t.label||n.push(s[e])}return n}var zo=function(){function s(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var n=s.prototype;return n.append=function(e,t){var r=this.queues[t];r.push(e),r.length===1&&this.buffers[t]&&this.executeNext(t)},n.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},n.appendBlocker=function(e){var t,r=new Promise(function(a){t=a}),i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,e),r},n.executeNext=function(e){var t=this.buffers,r=this.queues,i=t[e],a=r[e];if(a.length){var o=a[0];try{o.execute()}catch(l){P.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),o.onError(l),i!=null&&i.updating||(a.shift(),this.executeNext(e))}}},n.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},n.current=function(e){return this.queues[e][0]},s}(),fs=ra(),vs=/([ha]vc.)(?:\.[^.,]+)+/,Xo=function(){function s(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 r=t.media,i=t.mediaSource;P.log("[buffer-controller]: Media source opened"),r&&(r.removeEventListener("emptied",t._onMediaEmptied),t.updateMediaElementDuration(),t.hls.trigger(E.MEDIA_ATTACHED,{media:r})),i&&i.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){P.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){P.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=function(){var r=t.media,i=t._objectUrl;r&&r.src!==i&&P.error("Media element src was set while attaching MediaSource ("+i+" > "+r.src+")")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var n=s.prototype;return n.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},n.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},n.registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this)},n._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new zo(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},n.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,P.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},n.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&fs){var i=this.mediaSource=new fs;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}},n.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(P.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(i){P.warn("[buffer-controller]: onMediaDetaching: "+i.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):P.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(E.MEDIA_DETACHED,void 0)},n.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){var r=e.sourceBuffer[t];try{r&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(r),e.sourceBuffer[t]=void 0)}catch(i){P.warn("[buffer-controller]: Failed to reset the "+t+" buffer",i)}}),this._initSourceBuffer()},n.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length;Object.keys(t).forEach(function(a){if(i){var o=r.tracks[a];if(o&&typeof o.buffer.changeType=="function"){var l=t[a],d=l.id,u=l.codec,c=l.levelCodec,h=l.container,v=l.metadata,y=(o.levelCodec||o.codec).replace(vs,"$1"),T=(c||u).replace(vs,"$1");if(y!==T){var A=h+";codecs="+(c||u);r.appendChangeType(a,A),P.log("[buffer-controller]: switching codec "+y+" to "+T),r.tracks[a]={buffer:o.buffer,codec:u,container:h,levelCodec:c,metadata:v,id:d}}}}else r.pendingTracks[a]=t[a]}),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},n.appendChangeType=function(e,t){var r=this,i=this.operationQueue,a={execute:function(){var o=r.sourceBuffer[e];o&&(P.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),o.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(o){P.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",o)}};i.append(a,e)},n.onBufferAppending=function(e,t){var r=this,i=this.hls,a=this.operationQueue,o=this.tracks,l=t.data,d=t.type,u=t.frag,c=t.part,h=t.chunkMeta,v=h.buffering[d],y=self.performance.now();v.start=y;var T=u.stats.buffering,A=c?c.stats.buffering:null;T.start===0&&(T.start=y),A&&A.start===0&&(A.start=y);var p=o.audio,_=!1;d==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(_=!this.lastMpegAudioChunk||h.id===1||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);var L=u.start,w={execute:function(){if(v.executeStart=self.performance.now(),_){var x=r.sourceBuffer[d];if(x){var F=L-x.timestampOffset;Math.abs(F)>=.1&&(P.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+L+" (delta: "+F+") sn: "+u.sn+")"),x.timestampOffset=L)}}r.appendExecutor(l,d)},onStart:function(){},onComplete:function(){var x=self.performance.now();v.executeEnd=v.end=x,T.first===0&&(T.first=x),A&&A.first===0&&(A.first=x);var F=r.sourceBuffer,G={};for(var W in F)G[W]=le.getBuffered(F[W]);r.appendError=0,r.hls.trigger(E.BUFFER_APPENDED,{type:d,frag:u,part:c,chunkMeta:h,parent:u.type,timeRanges:G})},onError:function(x){P.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",x);var F={type:te.MEDIA_ERROR,parent:u.type,details:U.BUFFER_APPEND_ERROR,frag:u,part:c,chunkMeta:h,error:x,err:x,fatal:!1};x.code===DOMException.QUOTA_EXCEEDED_ERR?F.details=U.BUFFER_FULL_ERROR:(r.appendError++,F.details=U.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(P.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),F.fatal=!0)),i.trigger(E.ERROR,F)}};a.append(w,d)},n.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,a=function(o){return{execute:r.removeExecutor.bind(r,o,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(E.BUFFER_FLUSHED,{type:o})},onError:function(l){P.warn("[buffer-controller]: Failed to remove from "+o+" SourceBuffer",l)}}};t.type?i.append(a(t.type),t.type):this.getSourceBufferTypes().forEach(function(o){i.append(a(o),o)})},n.onFragParsed=function(e,t){var r=this,i=t.frag,a=t.part,o=[],l=a?a.elementaryStreams:i.elementaryStreams;l[qt]?o.push("audiovideo"):(l[_e]&&o.push("audio"),l[ze]&&o.push("video")),o.length===0&&P.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers(function(){var d=self.performance.now();i.stats.buffering.end=d,a&&(a.stats.buffering.end=d);var u=a?a.stats:i.stats;r.hls.trigger(E.FRAG_BUFFERED,{frag:i,part:a,stats:u,id:i.type})},o)},n.onFragChanged=function(e,t){this.flushBackBuffer()},n.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce(function(i,a){var o=r.sourceBuffer[a];return!o||t.type&&t.type!==a||(o.ending=!0,o.ended||(o.ended=!0,P.log("[buffer-controller]: "+a+" sourceBuffer now EOS"))),i&&!(o&&!o.ended)},!0)&&(P.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){r.getSourceBufferTypes().forEach(function(a){var o=r.sourceBuffer[a];o&&(o.ending=!1)});var i=r.mediaSource;i&&i.readyState==="open"?(P.log("[buffer-controller]: Calling mediaSource.endOfStream()"),i.endOfStream()):i&&P.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+i.readyState)}))},n.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},n.flushBackBuffer=function(){var e=this.hls,t=this.details,r=this.media,i=this.sourceBuffer;if(r&&t!==null){var a=this.getSourceBufferTypes();if(a.length){var o=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(Q(o)&&!(o<0)){var l=r.currentTime,d=t.levelTargetDuration,u=Math.max(o,d),c=Math.floor(l/d)*d-u;a.forEach(function(h){var v=i[h];if(v){var y=le.getBuffered(v);if(y.length>0&&c>y.start(0)){if(e.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(v.ended&&y.end(y.length-1)-l<2*d)return void P.info("[buffer-controller]: Cannot flush "+h+" back buffer while SourceBuffer is in ended state");e.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:h})}}})}}}},n.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,t=this.hls,r=this.media,i=this.mediaSource,a=e.fragments[0].start+e.totalduration,o=r.duration,l=Q(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(P.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(a>l&&a>o||!Q(o))&&(P.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),i.duration=a)}},n.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){var i=Math.max(0,r[0].start),a=Math.max(i,i+e.totalduration);t.setLiveSeekableRange(i,a)}},n.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!e||i===2){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length)this.hls.trigger(E.BUFFER_CREATED,{tracks:this.tracks}),a.forEach(function(l){t.executeNext(l)});else{var o=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:o,reason:o.message})}}},n.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var i in e)if(!t[i]){var a=e[i];if(!a)throw Error("source buffer exists for track "+i+", however track does not");var o=a.levelCodec||a.codec,l=a.container+";codecs="+o;P.log("[buffer-controller]: creating sourceBuffer("+l+")");try{var d=t[i]=r.addSourceBuffer(l),u=i;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.tracks[i]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(c){P.error("[buffer-controller]: error while trying to add sourceBuffer: "+c.message),this.hls.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:c,mimeType:l})}}},n._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},n._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},n._onSBUpdateError=function(e,t){var r=new Error(e+" SourceBuffer error");P.error("[buffer-controller]: "+r,t),this.hls.trigger(E.ERROR,{type:te.MEDIA_ERROR,details:U.BUFFER_APPENDING_ERROR,error:r,fatal:!1});var i=this.operationQueue.current(e);i&&i.onError(t)},n.removeExecutor=function(e,t,r){var i=this.media,a=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[e];if(!i||!a||!l)return P.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(e);var d=Q(i.duration)?i.duration:1/0,u=Q(a.duration)?a.duration:1/0,c=Math.max(0,t),h=Math.min(r,d,u);h>c&&!l.ending?(l.ended=!1,P.log("[buffer-controller]: Removing ["+c+","+h+"] from the "+e+" SourceBuffer"),l.remove(c,h)):o.shiftAndExecuteNext(e)},n.appendExecutor=function(e,t){var r=this.operationQueue,i=this.sourceBuffer[t];if(!i)return P.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(t);i.ended=!1,i.appendBuffer(e)},n.blockBuffers=function(e,t){var r=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length)return P.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var i=this.operationQueue,a=t.map(function(o){return i.appendBlocker(o)});Promise.all(a).then(function(){e(),t.forEach(function(o){var l=r.sourceBuffer[o];l!=null&&l.updating||i.shiftAndExecuteNext(o)})})},n.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},n.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(i){var a=r.bind(this,e);this.listeners[e].push({event:t,listener:a}),i.addEventListener(t,a)}},n.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(r){t.removeEventListener(r.event,r.listener)})},s}(),gs={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},ms=function(s){var n=s;return gs.hasOwnProperty(s)&&(n=gs[s]),String.fromCharCode(n)},Tr=15,ir=100,Qo={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Jo={17:2,18:4,21:6,22:8,23:10,19:13,20:15},$o={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Zo={25:2,26:4,29:6,30:8,31:10,27:13,28:15},el=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],tl=function(){function s(){this.time=null,this.verboseLevel=0}return s.prototype.log=function(n,e){if(this.verboseLevel>=n){var t=typeof e=="function"?e():e;P.log(this.time+" ["+n+"] "+t)}},s}(),Er=function(s){for(var n=[],e=0;e<s.length;e++)n.push(s[e].toString(16));return n},ps=function(){function s(e,t,r,i,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=a||!1}var n=s.prototype;return n.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},n.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}},n.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},n.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},n.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},n.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},s}(),rl=function(){function s(e,t,r,i,a,o){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new ps(t,r,i,a,o)}var n=s.prototype;return n.reset=function(){this.uchar=" ",this.penState.reset()},n.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},n.setPenState=function(e){this.penState.copy(e)},n.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},n.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},n.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},s}(),il=function(){function s(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<ir;t++)this.chars.push(new rl);this.logger=e,this.pos=0,this.currPenState=new ps}var n=s.prototype;return n.equals=function(e){for(var t=!0,r=0;r<ir;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<ir;t++)this.chars[t].copy(e.chars[t])},n.isEmpty=function(){for(var e=!0,t=0;t<ir;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},n.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>ir&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ir)},n.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},n.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},n.insertChar=function(e){var t=this;e>=144&&this.backSpace();var r=ms(e);this.pos>=ir?this.logger.log(0,function(){return"Cannot insert "+e.toString(16)+" ("+r+") at position "+t.pos+". Skipping it!"}):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))},n.clearFromPos=function(e){var t;for(t=e;t<ir;t++)this.chars[t].reset()},n.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},n.clearToEndOfRow=function(){this.clearFromPos(this.pos)},n.getTextString=function(){for(var e=[],t=!0,r=0;r<ir;r++){var i=this.chars[r].uchar;i!==" "&&(t=!1),e.push(i)}return t?"":e.join("")},n.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},s}(),pa=function(){function s(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<Tr;t++)this.rows.push(new il(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var n=s.prototype;return n.reset=function(){for(var e=0;e<Tr;e++)this.rows[e].clear();this.currRow=14},n.equals=function(e){for(var t=!0,r=0;r<Tr;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},n.copy=function(e){for(var t=0;t<Tr;t++)this.rows[t].copy(e.rows[t])},n.isEmpty=function(){for(var e=!0,t=0;t<Tr;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},n.backSpace=function(){this.rows[this.currRow].backSpace()},n.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},n.insertChar=function(e){this.rows[this.currRow].insertChar(e)},n.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},n.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},n.setCursor=function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},n.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 r=0;r<Tr;r++)this.rows[r].clear();var i=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var o=a.rows[i].cueStartTime,l=this.logger.time;if(o&&l!==null&&o<l)for(var d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[i+d])}}this.currRow=t;var u=this.rows[this.currRow];if(e.indent!==null){var c=e.indent,h=Math.max(c-1,0);u.setCursor(e.indent),e.color=u.chars[h].penState.foreground}var v={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(v)},n.setBkgData=function(e){this.logger.log(2,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},n.setRollUpRows=function(e){this.nrRollUpRows=e},n.rollUp=function(){var e=this;if(this.nrRollUpRows!==null){this.logger.log(1,function(){return e.getDisplayText()});var t=this.currRow+1-this.nrRollUpRows,r=this.rows.splice(t,1)[0];r.clear(),this.rows.splice(this.currRow,0,r),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")},n.getDisplayText=function(e){e=e||!1;for(var t=[],r="",i=-1,a=0;a<Tr;a++){var o=this.rows[a].getTextString();o&&(i=a+1,e?t.push("Row "+i+": '"+o+"'"):t.push(o.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join(`
|
|
34
|
+
`)),r},n.getTextAndFormat=function(){return this.rows},s}(),ys=function(){function s(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new pa(r),this.nonDisplayedMemory=new pa(r),this.lastOutputScreen=new pa(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var n=s.prototype;return n.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},n.getHandler=function(){return this.outputFilter},n.setHandler=function(e){this.outputFilter=e},n.setPAC=function(e){this.writeScreen.setPAC(e)},n.setBkgData=function(e){this.writeScreen.setBkgData(e)},n.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)},n.insertChars=function(e){for(var t=this,r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,function(){return i+": "+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())},n.ccRCL=function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},n.ccBS=function(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},n.ccAOF=function(){},n.ccAON=function(){},n.ccDER=function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},n.ccRU=function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},n.ccFON=function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},n.ccRDC=function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},n.ccTR=function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")},n.ccRTD=function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")},n.ccEDM=function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},n.ccCR=function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},n.ccENM=function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},n.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)},n.ccTO=function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},n.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},n.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))},n.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},s}(),Ts=function(){function s(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new tl;this.channels=[null,new ys(e,t,i),new ys(e+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}var n=s.prototype;return n.getHandler=function(e){return this.channels[e].getHandler()},n.setHandler=function(e,t){this.channels[e].setHandler(t)},n.addData=function(e,t){var r,i,a,o=!1;this.logger.time=e;for(var l=0;l<t.length;l+=2)if(i=127&t[l],a=127&t[l+1],i!==0||a!==0){if(this.logger.log(3,"["+Er([t[l],t[l+1]])+"] -> ("+Er([i,a])+")"),(r=this.parseCmd(i,a))||(r=this.parseMidrow(i,a)),r||(r=this.parsePAC(i,a)),r||(r=this.parseBackgroundAttributes(i,a)),!r&&(o=this.parseChars(i,a))){var d=this.currentChannel;d&&d>0?this.channels[d].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||o||this.logger.log(2,"Couldn't parse cleaned data "+Er([i,a])+" orig: "+Er([t[l],t[l+1]]))}},n.parseCmd=function(e,t){var r=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(Es(e,t,r))return $r(null,null,r),this.logger.log(3,"Repeated command ("+Er([e,t])+") is dropped"),!0;var i=e===20||e===21||e===23?1:2,a=this.channels[i];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),$r(e,t,r),this.currentChannel=i,!0},n.parseMidrow=function(e,t){var r=0;if((e===17||e===25)&&t>=32&&t<=47){if((r=e===17?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Er([e,t])+")"),!0)}return!1},n.parsePAC=function(e,t){var r,i=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(Es(e,t,i))return $r(null,null,i),!0;var a=e<=23?1:2;r=t>=64&&t<=95?a===1?Qo[e]:$o[e]:a===1?Jo[e]:Zo[e];var o=this.channels[a];return!!o&&(o.setPAC(this.interpretPAC(r,t)),$r(e,t,i),this.currentChannel=a,!0)},n.interpretPAC=function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=(1&r)==1,r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},n.parseChars=function(e,t){var r,i,a=null,o=null;if(e>=25?(r=2,o=e-8):(r=1,o=e),o>=17&&o<=19?(i=o===17?t+80:o===18?t+112:t+144,this.logger.log(2,"Special char '"+ms(i)+"' in channel "+r),a=[i]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var l=Er(a);this.logger.log(3,"Char codes = "+l.join(",")),$r(e,t,this.cmdHistory)}return a},n.parseBackgroundAttributes=function(e,t){var r;if(!((e===16||e===24)&&t>=32&&t<=47||(e===23||e===31)&&t>=45&&t<=47))return!1;var i={};e===16||e===24?(r=Math.floor((t-32)/2),i.background=el[r],t%2==1&&(i.background=i.background+"_semi")):t===45?i.background="transparent":(i.foreground="black",t===47&&(i.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(i),$r(e,t,this.cmdHistory),!0},n.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}},n.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}},s}();function $r(s,n,e){e.a=s,e.b=n}function Es(s,n,e){return e.a===s&&e.b===n}var Dn=function(){function s(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 n=s.prototype;return n.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},n.newCue=function(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},n.reset=function(){this.cueRanges=[],this.startTime=null},s}(),ya=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var s=["","lr","rl"],n=["start","middle","end","left","right"];function e(a,o){if(typeof o!="string"||!Array.isArray(a))return!1;var l=o.toLowerCase();return!!~a.indexOf(l)&&l}function t(a){return e(n,a)}function r(a){for(var o=arguments.length,l=new Array(o>1?o-1:0),d=1;d<o;d++)l[d-1]=arguments[d];for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var h in c)a[h]=c[h]}return a}function i(a,o,l){var d=this,u={enumerable:!0};d.hasBeenReset=!1;var c="",h=!1,v=a,y=o,T=l,A=null,p="",_=!0,L="auto",w="start",x=50,F="middle",G=50,W="middle";Object.defineProperty(d,"id",r({},u,{get:function(){return c},set:function(q){c=""+q}})),Object.defineProperty(d,"pauseOnExit",r({},u,{get:function(){return h},set:function(q){h=!!q}})),Object.defineProperty(d,"startTime",r({},u,{get:function(){return v},set:function(q){if(typeof q!="number")throw new TypeError("Start time must be set to a number.");v=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"endTime",r({},u,{get:function(){return y},set:function(q){if(typeof q!="number")throw new TypeError("End time must be set to a number.");y=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"text",r({},u,{get:function(){return T},set:function(q){T=""+q,this.hasBeenReset=!0}})),Object.defineProperty(d,"region",r({},u,{get:function(){return A},set:function(q){A=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"vertical",r({},u,{get:function(){return p},set:function(q){var V=function(Z){return e(s,Z)}(q);if(V===!1)throw new SyntaxError("An invalid or illegal string was specified.");p=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"snapToLines",r({},u,{get:function(){return _},set:function(q){_=!!q,this.hasBeenReset=!0}})),Object.defineProperty(d,"line",r({},u,{get:function(){return L},set:function(q){if(typeof q!="number"&&q!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");L=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"lineAlign",r({},u,{get:function(){return w},set:function(q){var V=t(q);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");w=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"position",r({},u,{get:function(){return x},set:function(q){if(q<0||q>100)throw new Error("Position must be between 0 and 100.");x=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"positionAlign",r({},u,{get:function(){return F},set:function(q){var V=t(q);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");F=V,this.hasBeenReset=!0}})),Object.defineProperty(d,"size",r({},u,{get:function(){return G},set:function(q){if(q<0||q>100)throw new Error("Size must be between 0 and 100.");G=q,this.hasBeenReset=!0}})),Object.defineProperty(d,"align",r({},u,{get:function(){return W},set:function(q){var V=t(q);if(!V)throw new SyntaxError("An invalid or illegal string was specified.");W=V,this.hasBeenReset=!0}})),d.displayState=void 0}return i.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},i}(),nl=function(){function s(){}return s.prototype.decode=function(n,e){if(!n)return"";if(typeof n!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(n))},s}();function _s(s){function n(t,r,i,a){return 3600*(0|t)+60*(0|r)+(0|i)+parseFloat(a||0)}var e=s.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?n(e[2],e[3],0,e[4]):n(e[1],e[2],e[3],e[4]):null}var al=function(){function s(){this.values=Object.create(null)}var n=s.prototype;return n.set=function(e,t){this.get(e)||t===""||(this.values[e]=t)},n.get=function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},n.has=function(e){return e in this.values},n.alt=function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}},n.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},n.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1},s}();function bs(s,n,e,t){var r=t?s.split(t):[s];for(var i in r)if(typeof r[i]=="string"){var a=r[i].split(e);a.length===2&&n(a[0],a[1])}}var Ta=new ya(0,0,""),In=Ta.align==="middle"?"middle":"center";function sl(s,n,e){var t=s;function r(){var a=_s(s);if(a===null)throw new Error("Malformed timestamp: "+t);return s=s.replace(/^[^\sa-zA-Z-]+/,""),a}function i(){s=s.replace(/^\s+/,"")}if(i(),n.startTime=r(),i(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+t);s=s.slice(3),i(),n.endTime=r(),i(),function(a,o){var l=new al;bs(a,function(c,h){var v;switch(c){case"region":for(var y=e.length-1;y>=0;y--)if(e[y].id===h){l.set(c,e[y].region);break}break;case"vertical":l.alt(c,h,["rl","lr"]);break;case"line":v=h.split(","),l.integer(c,v[0]),l.percent(c,v[0])&&l.set("snapToLines",!1),l.alt(c,v[0],["auto"]),v.length===2&&l.alt("lineAlign",v[1],["start",In,"end"]);break;case"position":v=h.split(","),l.percent(c,v[0]),v.length===2&&l.alt("positionAlign",v[1],["start",In,"end","line-left","line-right","auto"]);break;case"size":l.percent(c,h);break;case"align":l.alt(c,h,["start",In,"end","left","right"])}},/:/,/\s/),o.region=l.get("region",null),o.vertical=l.get("vertical","");var d=l.get("line","auto");d==="auto"&&Ta.line===-1&&(d=-1),o.line=d,o.lineAlign=l.get("lineAlign","start"),o.snapToLines=l.get("snapToLines",!0),o.size=l.get("size",100),o.align=l.get("align",In);var u=l.get("position","auto");u==="auto"&&Ta.position===50&&(u=o.align==="start"||o.align==="left"?0:o.align==="end"||o.align==="right"?100:50),o.position=u}(s,n)}function Ss(s){return s.replace(/<br(?: \/)?>/gi,`
|
|
35
|
+
`)}var ol=function(){function s(){this.state="INITIAL",this.buffer="",this.decoder=new nl,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var n=s.prototype;return n.parse=function(e){var t=this;function r(){var d=t.buffer,u=0;for(d=Ss(d);u<d.length&&d[u]!=="\r"&&d[u]!==`
|
|
36
|
+
`;)++u;var c=d.slice(0,u);return d[u]==="\r"&&++u,d[u]===`
|
|
37
|
+
`&&++u,t.buffer=d.slice(u),c}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var i="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;var a=(i=r()).match(/^()?WEBVTT([ \t].*)?$/);if(a==null||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var o=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:i=r(),t.state){case"HEADER":/:/.test(i)?bs(i,function(d,u){},/:/):i||(t.state="ID");continue;case"NOTE":i||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(i)){t.state="NOTE";break}if(!i)continue;if(t.cue=new ya(0,0,""),t.state="CUE",i.indexOf("-->")===-1){t.cue.id=i;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{sl(i,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var l=i.indexOf("-->")!==-1;if(!i||l&&(o=!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+=i;continue;case"BADCUE":i||(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},n.flush=function(){var e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
|
25
39
|
|
|
26
|
-
`,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},
|
|
27
|
-
`:(n=t.childNodes)!==null&&n!==void 0&&n.length?aa(t,o):o?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function In(d,o,e){return d&&d.hasAttributeNS(o,e)?d.getAttributeNS(o,e):null}function sa(d){return new Error("Could not parse ttml timestamp "+d)}function Cn(d,o){if(!d)return null;var e=_t(d);return e===null&&(Wr.test(d)?e=function(t,i){var n=Wr.exec(t),a=(0|n[4])+(0|n[5])/i.subFrameRate;return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+a/i.frameRate}(d,o):on.test(d)&&(e=function(t,i){var n=on.exec(t),a=Number(n[1]);switch(n[2]){case"h":return 3600*a;case"m":return 60*a;case"ms":return 1e3*a;case"f":return a/i.frameRate;case"t":return a/i.tickRate}return a}(d,o))),e}var $a=function(){function d(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.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={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 mt(this,"textTrack1"),i=new mt(this,"textTrack2"),n=new mt(this,"textTrack3"),a=new mt(this,"textTrack4");this.cea608Parser1=new nr(1,t,i),this.cea608Parser2=new nr(3,n,a)}e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.Events.FRAG_LOADING,this.onFragLoading,this),e.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=d.prototype;return o.destroy=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.Events.FRAG_LOADING,this.onFragLoading,this),e.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(e,t,i,n,a){for(var r,s,l,u,c=!1,v=a.length;v--;){var m=a[v],_=(r=m[0],s=m[1],l=t,u=i,Math.min(s,u)-Math.max(r,l));if(_>=0&&(m[0]=Math.min(m[0],t),m[1]=Math.max(m[1],i),c=!0,_/(i-t)>.5))return}if(c||a.push([t,i]),this.config.renderTextTracksNatively){var S=this.captionsTracks[e];this.Cues.newCue(S,t,i,n)}else{var P=this.Cues.newCue(null,t,i,n);this.hls.trigger(p.Events.CUES_PARSED,{type:"captions",cues:P,track:e})}},o.onInitPtsFound=function(e,t){var i=this,n=t.frag,a=t.id,r=t.initPTS,s=t.timescale,l=this.unparsedVttFrags;a==="main"&&(this.initPTS[n.cc]=r,this.timescale[n.cc]=s),l.length&&(this.unparsedVttFrags=[],l.forEach(function(u){i.onFragLoaded(p.Events.FRAG_LOADED,u)}))},o.getExistingTrack=function(e){var t=this.media;if(t)for(var i=0;i<t.textTracks.length;i++){var n=t.textTracks[i];if(n[e])return n}return null},o.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},o.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,i=this.captionsTracks,n=this.media,a=t[e],r=a.label,s=a.languageCode,l=this.getExistingTrack(e);if(l)i[e]=l,ht(i[e]),rt(i[e],n);else{var u=this.createTextTrack("captions",r,s);u&&(u[e]=!0,i[e]=u)}}},o.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(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}},o.createTextTrack=function(e,t,i){var n=this.media;if(n)return n.addTextTrack(e,t,i)},o.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},o.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){ht(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}},o.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.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)ht(t[i])}},o.onSubtitleTracksUpdated=function(e,t){var i=this;this.textTracks=[];var n=t.subtitleTracks||[],a=n.some(function(u){return u.textCodec===gr});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var r=this.tracks&&n&&this.tracks.length===n.length;if(this.tracks=n||[],this.config.renderTextTracksNatively){var s=this.media?this.media.textTracks:[];this.tracks.forEach(function(u,c){var v;if(c<s.length){for(var m=null,_=0;_<s.length;_++)if(Za(s[_],u)){m=s[_];break}m&&(v=m)}if(v)ht(v);else{var S=i._captionsOrSubtitlesFromCharacteristics(u);(v=i.createTextTrack(S,u.name,u.lang))&&(v.mode="disabled")}v&&(v.groupId=u.groupId,i.textTracks.push(v))})}else if(!r&&this.tracks&&this.tracks.length){var l=this.tracks.map(function(u){return{label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}});this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},o._captionsOrSubtitlesFromCharacteristics=function(e){var t;if((t=e.attrs)!==null&&t!==void 0&&t.CHARACTERISTICS){var i=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),n=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(i&&n)return"captions"}return"subtitles"},o.onManifestLoaded=function(e,t){var i=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(function(n){var a=/(?:CC|SERVICE)([1-4])/.exec(n.instreamId);if(a){var r="textTrack"+a[1],s=i.captionsProperties[r];s&&(s.label=n.name,n.lang&&(s.languageCode=n.lang),s.media=n)}})},o.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]},o.onFragLoading=function(e,t){var i=this.cea608Parser1,n=this.cea608Parser2,a=this.lastSn,r=this.lastPartIndex;if(this.enabled&&i&&n&&t.frag.type===pe.PlaylistLevelType.MAIN){var s,l,u=t.frag.sn,c=(s=t==null||(l=t.part)===null||l===void 0?void 0:l.index)!=null?s:-1;u===a+1||u===a&&c===r+1||(i.reset(),n.reset()),this.lastSn=u,this.lastPartIndex=c}},o.onFragLoaded=function(e,t){var i=t.frag,n=t.payload,a=this.initPTS,r=this.unparsedVttFrags;if(i.type===pe.PlaylistLevelType.SUBTITLE)if(n.byteLength){if(!(0,R.isFiniteNumber)(a[i.cc]))return r.push(t),void(a.length&&this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")}));var s=i.decryptdata,l="stats"in t;if(s==null||!s.encrypted||l){var u=this.tracks[i.level],c=this.vttCCs;c[i.cc]||(c[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),u&&u.textCodec===gr?this._parseIMSC1(i,n):this._parseVTTs(i,n,c)}}else this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(e,t){var i=this,n=this.hls;ia(t,this.initPTS[e.cc],this.timescale[e.cc],function(a){i._appendCues(a,e.level),n.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(a){k.logger.log("Failed to parse IMSC1: "+a),n.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:a})})},o._parseVTTs=function(e,t,i){var n,a=this,r=this.hls;(function(s,l,u,c,v,m,_,S){var P,I=new ar,q=(0,Lt.utf8ArrayToStr)(new Uint8Array(s)).trim().replace(sr,`
|
|
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},s}(),ll=/\r\n|\n\r|\n|\r/g,Ea=function(s,n,e){return e===void 0&&(e=0),s.slice(e,e+n.length)===n},_a=function(s){for(var n=5381,e=s.length;e;)n=33*n^s.charCodeAt(--e);return(n>>>0).toString()};function ba(s,n,e){return _a(s.toString())+_a(n.toString())+_a(e)}function ul(s,n,e,t,r,i,a){var o,l,d,u=new ol,c=Tt(new Uint8Array(s)).trim().replace(ll,`
|
|
28
41
|
`).split(`
|
|
29
|
-
`),
|
|
30
|
-
`)}),I.flush()})((n=e.initSegment)!==null&&n!==void 0&&n.data?(0,J.appendUint8Array)(e.initSegment.data,new Uint8Array(t)):t,this.initPTS[e.cc],this.timescale[e.cc],i,e.cc,e.start,function(s){a._appendCues(s,e.level),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(s){a._fallbackToIMSC1(e,t),k.logger.log("Failed to parse VTT cue: "+s),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})},o._fallbackToIMSC1=function(e,t){var i=this,n=this.tracks[e.level];n.textCodec||ia(t,this.initPTS[e.cc],this.timescale[e.cc],function(){n.textCodec=gr,i._parseIMSC1(e,t)},function(){n.textCodec="wvtt"})},o._appendCues=function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||n.mode==="disabled")return;e.forEach(function(s){return yt(n,s)})}else{var a=this.tracks[t];if(!a)return;var r=a.default?"default":"subtitles"+t;i.trigger(p.Events.CUES_PARSED,{type:"subtitles",cues:e,track:r})}},o.onFragDecrypted=function(e,t){var i=t.frag;if(i.type===pe.PlaylistLevelType.SUBTITLE){if(!(0,R.isFiniteNumber)(this.initPTS[i.cc]))return void this.unparsedVttFrags.push(t);this.onFragLoaded(p.Events.FRAG_LOADED,t)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(e,t){var i=this.cea608Parser1,n=this.cea608Parser2;if(this.enabled&&i&&n){var a=t.frag,r=t.samples;if(a.type!==pe.PlaylistLevelType.MAIN||this.closedCaptionsForLevel(a)!=="NONE")for(var s=0;s<r.length;s++){var l=r[s].bytes;if(l){var u=this.extractCea608Data(l);i.addData(r[s].pts,u[0]),n.addData(r[s].pts,u[1])}}}},o.onBufferFlushing=function(e,t){var i=t.startOffset,n=t.endOffset,a=t.endOffsetSubtitles,r=t.type,s=this.media;if(s&&!(s.currentTime<n)){if(!r||r==="video"){var l=this.captionsTracks;Object.keys(l).forEach(function(c){return It(l[c],i,n)})}if(this.config.renderTextTracksNatively&&i===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return It(u[c],i,a)})}}},o.extractCea608Data=function(e){for(var t=[[],[]],i=31&e[0],n=2,a=0;a<i;a++){var r=e[n++],s=127&e[n++],l=127&e[n++];if((s!==0||l!==0)&&(4&r)!=0){var u=3&r;u!==0&&u!==1||(t[u].push(s),t[u].push(l))}}return t},d}();function Za(d,o){return d&&d.label===o.name&&!(d.textTrack1||d.textTrack2)}function es(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}let ts=function(){function d(i){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var o,e,t=d.prototype;return t.setStreamController=function(i){this.streamController=i},t.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var i=this.hls;i.on(p.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),i.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var i=this.hls;i.off(p.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),i.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(i,n){d.isLevelAllowed(n.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(n.droppedLevel)},t.onMediaAttaching=function(i,n){this.media=n.media instanceof HTMLVideoElement?n.media:null,this.clientRect=null},t.onManifestParsed=function(i,n){var a=this.hls;this.restrictedLevels=[],this.firstLevel=n.firstLevel,a.config.capLevelToPlayerSize&&n.video&&this.startCapping()},t.onBufferCodecs=function(i,n){this.hls.config.capLevelToPlayerSize&&n.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping()},t.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var i=this.hls.levels;if(i.length){var n=this.hls;n.autoLevelCapping=this.getMaxLevel(i.length-1),n.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=n.autoLevelCapping}}},t.getMaxLevel=function(i){var n=this,a=this.hls.levels;if(!a.length)return-1;var r=a.filter(function(s,l){return d.isLevelAllowed(l,n.restrictedLevels)&&l<=i});return this.clientRect=null,d.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)},t.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())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var i=this.media,n={width:0,height:0};if(i){var a=i.getBoundingClientRect();n.width=a.width,n.height=a.height,n.width||n.height||(n.width=a.right-a.left||i.width||0,n.height=a.bottom-a.top||i.height||0)}return this.clientRect=n,n},d.isLevelAllowed=function(i,n){return n===void 0&&(n=[]),n.indexOf(i)===-1},d.getMaxLevelByMediaSize=function(i,n,a){if(!i||!i.length)return-1;for(var r,s,l=i.length-1,u=0;u<i.length;u+=1){var c=i[u];if((c.width>=n||c.height>=a)&&(r=c,!(s=i[u+1])||r.width!==s.width||r.height!==s.height)){l=u;break}}return l},o=d,(e=[{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 i=1;if(!this.hls.config.ignoreDevicePixelRatio)try{i=self.devicePixelRatio}catch{}return i}}])&&es(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}(),rs=function(){function d(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 o=d.prototype;return o.setStreamController=function(e){this.streamController=e},o.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},o.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching)},o.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},o.onMediaAttaching=function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}},o.checkFPS=function(e,t,i){var n=performance.now();if(t){if(this.lastTime){var a=n-this.lastTime,r=i-this.lastDroppedFrames,s=t-this.lastDecodedFrames,l=1e3*r/a,u=this.hls;if(u.trigger(p.Events.FPS_DROP,{currentDropped:r,currentDecoded:s,totalDroppedFrames:i}),l>0&&r>u.config.fpsDroppedMonitoringThreshold*s){var c=u.currentLevel;k.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=c)&&(c-=1,u.trigger(p.Events.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:u.currentLevel}),u.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}},o.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)},d}();var ri=M(300);function On(d){var o=typeof Map=="function"?new Map:void 0;return On=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(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return Pn(e,arguments,xn(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Fi(i,e)},On(d)}function Pn(d,o,e){return Pn=is()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Fi(r,n.prototype),r},Pn.apply(null,arguments)}function is(){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 Fi(d,o){return Fi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Fi(d,o)}function xn(d){return xn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},xn(d)}var ln="[eme]",oa=function(){function d(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=d.CDMCleanupPromise?[d.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=k.logger.debug.bind(k.logger,ln),this.log=k.logger.log.bind(k.logger,ln),this.warn=k.logger.warn.bind(k.logger,ln),this.error=k.logger.error.bind(k.logger,ln),this.hls=e,this.config=e.config,this.registerListeners()}var o=d.prototype;return o.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},o.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},o.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},o.getLicenseServerUrl=function(e){var t=this.config,i=t.drmSystems,n=t.widevineLicenseUrl,a=i[e];if(a)return a.licenseUrl;if(e===G.WIDEVINE&&n)return n;throw new Error('no license server URL configured for key-system "'+e+'"')},o.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},o.attemptKeySystemAccess=function(e){var t=this,i=this.hls.levels,n=function(s,l,u){return!!s&&u.indexOf(s)===l},a=i.map(function(s){return s.audioCodec}).filter(n),r=i.map(function(s){return s.videoCodec}).filter(n);return a.length+r.length===0&&r.push("avc1.42e01e"),new Promise(function(s,l){(function u(c){var v=c.shift();t.getMediaKeysPromise(v,a,r).then(function(m){return s({keySystem:v,mediaKeys:m})}).catch(function(m){c.length?u(c):l(m instanceof wr?m:new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:m,fatal:!0},m.message))})})(e)})},o.requestMediaKeySystemAccess=function(e,t){var i=this.config.requestMediaKeySystemAccessFunc;if(typeof i!="function"){var n="Configured requestMediaKeySystemAccess is not a function "+i;return Te===null&&self.location.protocol==="http:"&&(n="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(n))}return i(e,t)},o.getMediaKeysPromise=function(e,t,i){var n=this,a=function(u,c,v,m){var _;switch(u){case G.FAIRPLAY:_=["cenc","sinf"];break;case G.WIDEVINE:case G.PLAYREADY:_=["cenc"];break;case G.CLEARKEY:_=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+u)}return function(S,P,I,q){return[{initDataTypes:S,persistentState:q.persistentState||"not-allowed",distinctiveIdentifier:q.distinctiveIdentifier||"not-allowed",sessionTypes:q.sessionTypes||[q.sessionType||"temporary"],audioCapabilities:P.map(function(oe){return{contentType:'audio/mp4; codecs="'+oe+'"',robustness:q.audioRobustness||"",encryptionScheme:q.audioEncryptionScheme||null}}),videoCapabilities:I.map(function(oe){return{contentType:'video/mp4; codecs="'+oe+'"',robustness:q.videoRobustness||"",encryptionScheme:q.videoEncryptionScheme||null}})}]}(_,c,v,m)}(e,t,i,this.config.drmSystemOptions),r=this.keySystemAccessPromises[e],s=r==null?void 0:r.keySystemAccess;if(!s){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(a)),s=this.requestMediaKeySystemAccess(e,a);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch(function(u){n.log('Failed to obtain access to key-system "'+e+'": '+u)}),s.then(function(u){n.log('Access for key-system "'+u.keySystem+'" obtained');var c=n.fetchServerCertificate(e);return n.log('Create media-keys for "'+e+'"'),l.mediaKeys=u.createMediaKeys().then(function(v){return n.log('Media-keys created for "'+e+'"'),c.then(function(m){return m?n.setMediaKeysServerCertificate(v,e,m):v})}),l.mediaKeys.catch(function(v){n.error('Failed to create media-keys for "'+e+'"}: '+v)}),l.mediaKeys})}return s.then(function(){return r.mediaKeys})},o.createMediaKeySessionContext=function(e){var t=e.decryptdata,i=e.keySystem,n=e.mediaKeys;this.log('Creating key-system session "'+i+'" keyId: '+ri.default.hexDump(t.keyId||[]));var a=n.createSession(),r={decryptdata:t,keySystem:i,mediaKeys:n,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r},o.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var i=this.createMediaKeySessionContext(e),n=this.getKeyIdString(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},o.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 ri.default.hexDump(e.keyId)},o.updateKeySession=function(e,t){var i,n=e.mediaKeysSession;return this.log('Updating key-session "'+n.sessionId+'" for keyID '+ri.default.hexDump(((i=e.decryptdata)===null||i===void 0?void 0:i.keyId)||[])+`
|
|
31
|
-
} (data length: `+(t&&t.byteLength)+")"),n.update(t)},o.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},o.getKeyFormatPromise=function(e){var t=this;return new Promise(function(i,n){var a=ue(t.config),r=e.map(U).filter(function(s){return!!s&&a.indexOf(s)!==-1});return t.getKeySystemSelectionPromise(r).then(function(s){var l=s.keySystem,u=A(l);u?i(u):n(new Error('Unable to find format for key-system "'+l+'"'))}).catch(n)})},o.loadKey=function(e){var t=this,i=e.keyInfo.decryptdata,n=this.getKeyIdString(i),a="(keyId: "+n+' format: "'+i.keyFormat+'" method: '+i.method+" uri: "+i.uri+")";this.log("Starting session for key "+a);var r=this.keyIdToKeySessionPromise[n];return r||(r=this.keyIdToKeySessionPromise[n]=this.getKeySystemForKeyPromise(i).then(function(s){var l=s.keySystem,u=s.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+a),t.attemptSetMediaKeys(l,u).then(function(){t.throwIfDestroyed();var c=t.createMediaKeySessionContext({keySystem:l,mediaKeys:u,decryptdata:i});return t.generateRequestWithPreferredKeySession(c,"cenc",i.pssh,"playlist-key")})})).catch(function(s){return t.handleError(s)}),r},o.throwIfDestroyed=function(e){if(e===void 0&&(e="Invalid state"),!this.hls)throw new Error("invalid state")},o.handleError=function(e){this.hls&&(this.error(e.message),e instanceof wr?this.hls.trigger(p.Events.ERROR,e.data):this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},o.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){var n=U(e.keyFormat),a=n?[n]:ue(this.config);return this.attemptKeySystemAccess(a)}return i},o.getKeySystemSelectionPromise=function(e){if(e.length||(e=ue(this.config)),e.length===0)throw new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},o._onMediaEncrypted=function(e){var t=this,i=e.initDataType,n=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+i+'"'),n!==null){var a,r;if(i==="sinf"&&this.config.drmSystems[G.FAIRPLAY]){var s=(0,J.bin2str)(new Uint8Array(n));try{var l=V(JSON.parse(s).sinf),u=(0,J.parseSinf)(new Uint8Array(l));if(!u)return;a=u.subarray(8,24),r=G.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=(0,J.parsePssh)(n);if(c===null)return;c.version===0&&c.systemId===ke.WIDEVINE&&c.data&&(a=c.data.subarray(8,24)),r=function(oe){if(oe===ke.WIDEVINE)return G.WIDEVINE}(c.systemId)}if(r&&a){for(var v=ri.default.hexDump(a),m=this.keyIdToKeySessionPromise,_=this.mediaKeySessions,S=m[v],P=function(oe){var Ee=_[oe],he=Ee.decryptdata;if(he.pssh||!he.keyId)return"continue";var Ae=ri.default.hexDump(he.keyId);return v===Ae||he.uri.replace(/-/g,"").indexOf(v)!==-1?(S=m[Ae],delete m[Ae],he.pssh=new Uint8Array(n),he.keyId=a,S=m[v]=S.then(function(){return t.generateRequestWithPreferredKeySession(Ee,i,n,"encrypted-event-key-match")}),"break"):void 0},I=0;I<_.length;I++){var q=P(I);if(q!=="continue"&&q==="break")break}S||(S=m[v]=this.getKeySystemSelectionPromise([r]).then(function(oe){var Ee,he=oe.keySystem,Ae=oe.mediaKeys;t.throwIfDestroyed();var He=new De("ISO-23001-7",v,(Ee=A(he))!=null?Ee:"");return He.pssh=new Uint8Array(n),He.keyId=a,t.attemptSetMediaKeys(he,Ae).then(function(){t.throwIfDestroyed();var ze=t.createMediaKeySessionContext({decryptdata:He,keySystem:he,mediaKeys:Ae});return t.generateRequestWithPreferredKeySession(ze,i,n,"encrypted-event-no-match")})})),S.catch(function(oe){return t.handleError(oe)})}}},o._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},o.attemptSetMediaKeys=function(e,t){var i=this,n=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var a=Promise.all(n).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(a),a.then(function(){i.log('Media-keys set for "'+e+'"'),n.push(a),i.setMediaKeysQueue=i.setMediaKeysQueue.filter(function(r){return n.indexOf(r)===-1})})},o.generateRequestWithPreferredKeySession=function(e,t,i,n){var a,r,s=this,l=(a=this.config.drmSystems)===null||a===void 0||(r=a[e.keySystem])===null||r===void 0?void 0:r.generateRequest;if(l)try{var u=l.call(this.hls,t,i,e);if(!u)throw new Error("Invalid response from configured generateRequest filter");t=u.initDataType,i=e.decryptdata.pssh=u.initData?new Uint8Array(u.initData):null}catch(S){var c;if(this.warn(S.message),(c=this.hls)!==null&&c!==void 0&&c.config.debug)throw S}if(i===null)return this.log('Skipping key-session request for "'+n+'" (no initData)'),Promise.resolve(e);var v=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+n+'": '+v+" (init data type: "+t+" length: "+(i?i.byteLength:null)+")");var m=new($r());e.mediaKeysSession.onmessage=function(S){var P=e.mediaKeysSession;if(P){var I=S.messageType,q=S.message;s.log('"'+I+'" message event for session "'+P.sessionId+'" message size: '+q.byteLength),I==="license-request"||I==="license-renewal"?s.renewLicense(e,q).catch(function(oe){s.handleError(oe),m.emit("error",oe)}):I==="license-release"?e.keySystem===G.FAIRPLAY&&(s.updateKeySession(e,E("acknowledged")),s.removeSession(e)):s.warn('unhandled media key message type "'+I+'"')}else m.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(S){if(e.mediaKeysSession){s.onKeyStatusChange(e);var P=e.keyStatus;m.emit("keyStatus",P),P==="expired"&&(s.warn(e.keySystem+" expired for key "+v),s.renewKeySession(e))}else m.emit("error",new Error("invalid state"))};var _=new Promise(function(S,P){m.on("error",P),m.on("keyStatus",function(I){I.startsWith("usable")?S():I==="output-restricted"?P(new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):I==="internal-error"?P(new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+I+'"')):I==="expired"?P(new Error("key expired while generating request")):s.warn('unhandled key status change "'+I+'"')})});return e.mediaKeysSession.generateRequest(t,i).then(function(){var S;s.log('Request generated for key-session "'+((S=e.mediaKeysSession)===null||S===void 0?void 0:S.sessionId)+'" keyId: '+v)}).catch(function(S){throw new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:S,fatal:!1},"Error generating key-session request: "+S)}).then(function(){return _}).catch(function(S){throw m.removeAllListeners(),s.removeSession(e),S}).then(function(){return m.removeAllListeners(),e})},o.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach(function(i,n){t.log('key status change "'+i+'" for keyStatuses keyId: '+ri.default.hexDump("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))+" session keyId: "+ri.default.hexDump(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=i})},o.fetchServerCertificate=function(e){var t=this;return new Promise(function(i,n){var a=t.getServerCertificateUrl(e);if(!a)return i();t.log('Fetching serverCertificate for "'+e+'"');var r=new XMLHttpRequest;r.open("GET",a,!0),r.responseType="arraybuffer",r.onreadystatechange=function(){r.readyState===XMLHttpRequest.DONE&&(r.status===200?i(r.response):n(new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r},'"'+e+'" certificate request XHR failed ('+a+"). Status: "+r.status+" ("+r.statusText+")")))},r.send()})},o.setMediaKeysServerCertificate=function(e,t,i){var n=this;return new Promise(function(a,r){e.setServerCertificate(i).then(function(s){n.log("setServerCertificate "+(s?"success":"not supported by CDM")+" ("+(i==null?void 0:i.byteLength)+') on "'+t+'"'),a(e)}).catch(function(s){r(new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:s,fatal:!0},s.message))})})},o.renewLicense=function(e,t){var i=this;return this.requestLicense(e,new Uint8Array(t)).then(function(n){return i.updateKeySession(e,new Uint8Array(n)).catch(function(a){throw new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:a,fatal:!0},a.message)})})},o.setupLicenseXHR=function(e,t,i,n){var a=this,r=this.config.licenseXhrSetup;return r?Promise.resolve().then(function(){if(!i.decryptdata)throw new Error("Key removed");return r.call(a.hls,e,t,i,n)}).catch(function(s){if(!i.decryptdata)throw s;return e.open("POST",t,!0),r.call(a.hls,e,t,i,n)}).then(function(s){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:s||n}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))},o.requestLicense=function(e,t){var i=this;return new Promise(function(n,a){var r=i.getLicenseServerUrl(e.keySystem);i.log("Sending license request to URL: "+r);var s=new XMLHttpRequest;s.responseType="arraybuffer",s.onreadystatechange=function(){if(!i.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(s.readyState===4)if(s.status===200){i._requestLicenseFailureCount=0;var l=s.response;i.log("License received "+(l instanceof ArrayBuffer?l.byteLength:l));var u=i.config.licenseResponseCallback;if(u)try{l=u.call(i.hls,s,r,e)}catch(v){i.error(v)}n(l)}else if(i._requestLicenseFailureCount++,i._requestLicenseFailureCount>3||s.status>=400&&s.status<500)a(new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:s},"License Request XHR failed ("+r+"). Status: "+s.status+" ("+s.statusText+")"));else{var c=3-i._requestLicenseFailureCount+1;i.warn("Retrying license request, "+c+" attempts left"),i.requestLicense(e,t).then(n,a)}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=s,i.setupLicenseXHR(s,r,e,t).then(function(l){var u=l.xhr,c=l.licenseChallenge;u.send(c)})})},o.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)}},o.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={},De.clearKeyUriToKeyIdMap();var n=i.length;d.CDMCleanupPromise=Promise.all(i.map(function(a){return e.removeSession(a)}).concat(t==null?void 0:t.setMediaKeys(null).catch(function(a){e.log("Could not clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))}))).then(function(){n&&(e.log("finished closing key sessions and clearing media keys"),i.length=0)}).catch(function(a){e.log("Could not close sessions and clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))})},o.onManifestLoaded=function(e,t){var i=t.sessionKeys;if(i&&this.config.emeEnabled&&!this.keyFormatPromise){var n=i.reduce(function(a,r){return a.indexOf(r.keyFormat)===-1&&a.push(r.keyFormat),a},[]);this.log("Selecting key-system from session-keys "+n.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(n)}},o.removeSession=function(e){var t=this,i=e.mediaKeysSession,n=e.licenseXhr;if(i){this.log("Remove licenses and keys and close session "+i.sessionId),i.onmessage=null,i.onkeystatuseschange=null,n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);return a>-1&&this.mediaKeySessions.splice(a,1),i.remove().catch(function(r){t.log("Could not remove session: "+r)}).then(function(){return i.close()}).catch(function(r){t.log("Could not close session: "+r)})}},d}();oa.CDMCleanupPromise=void 0;var wr=function(d){var o,e;function t(i,n){var a;return(a=d.call(this,n)||this).data=void 0,a.data=i,i.err=i.error,a}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Fi(o,e),t}(On(Error));let ns=oa;var lr,Fn,la;function ua(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function da(d,o,e){return o&&ua(d.prototype,o),e&&ua(d,e),Object.defineProperty(d,"prototype",{writable:!1}),d}function ca(d,o){var e=typeof Symbol!="undefined"&&d[Symbol.iterator]||d["@@iterator"];if(e)return(e=e.call(d)).next.bind(e);if(Array.isArray(d)||(e=function(i,n){if(i){if(typeof i=="string")return ha(i,n);var a=Object.prototype.toString.call(i).slice(8,-1);return a==="Object"&&i.constructor&&(a=i.constructor.name),a==="Map"||a==="Set"?Array.from(i):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?ha(i,n):void 0}}(d))||o&&d&&typeof d.length=="number"){e&&(d=e);var t=0;return function(){return t>=d.length?{done:!0}:{done:!1,value:d[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
32
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ha(d,o){(o==null||o>d.length)&&(o=d.length);for(var e=0,t=new Array(o);e<o;e++)t[e]=d[e];return t}function un(){return un=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},un.apply(this,arguments)}(function(d){d.MANIFEST="m",d.AUDIO="a",d.VIDEO="v",d.MUXED="av",d.INIT="i",d.CAPTION="c",d.TIMED_TEXT="tt",d.KEY="k",d.OTHER="o"})(lr||(lr={})),function(d){d.DASH="d",d.HLS="h",d.SMOOTH="s",d.OTHER="o"}(Fn||(Fn={})),function(d){d.VOD="v",d.LIVE="l"}(la||(la={}));var as=function(){function d(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(a){try{t.apply(a,{ot:lr.MANIFEST,su:!t.initialized})}catch(r){k.logger.warn("Could not generate manifest CMCD data.",r)}},this.applyFragmentData=function(a){try{var r=a.frag,s=t.hls.levels[r.level],l=t.getObjectType(r),u={d:1e3*r.duration,ot:l};l!==lr.VIDEO&&l!==lr.AUDIO&&l!=lr.MUXED||(u.br=s.bitrate/1e3,u.tb=t.getTopBandwidth(l)/1e3,u.bl=t.getBufferLength(l)),t.apply(a,u)}catch(c){k.logger.warn("Could not generate segment CMCD data.",c)}},this.hls=e;var i=this.config=e.config,n=i.cmcd;n!=null&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||d.uuid(),this.cid=n.contentId,this.useHeaders=n.useHeaders===!0,this.registerListeners())}var o=d.prototype;return o.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(p.Events.BUFFER_CREATED,this.onBufferCreated,this)},o.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(p.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},o.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},o.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},o.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},o.onBufferCreated=function(e,t){var i,n;this.audioBuffer=(i=t.tracks.audio)===null||i===void 0?void 0:i.buffer,this.videoBuffer=(n=t.tracks.video)===null||n===void 0?void 0:n.buffer},o.createData=function(){var e;return{v:1,sf:Fn.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},o.apply=function(e,t){t===void 0&&(t={}),un(t,this.createData());var i=t.ot===lr.INIT||t.ot===lr.VIDEO||t.ot===lr.MUXED;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){var n=d.toHeaders(t);if(!Object.keys(n).length)return;e.headers||(e.headers={}),un(e.headers,n)}else{var a=d.toQuery(t);if(!a)return;e.url=d.appendQueryToUri(e.url,a)}},o.getObjectType=function(e){var t=e.type;return t==="subtitle"?lr.TIMED_TEXT:e.sn==="initSegment"?lr.INIT:t==="audio"?lr.AUDIO:t==="main"?this.hls.audioTracks.length?lr.VIDEO:lr.MUXED:void 0},o.getTopBandwidth=function(e){var t,i=0,n=this.hls;if(e===lr.AUDIO)t=n.audioTracks;else{var a=n.maxAutoLevel,r=a>-1?a+1:n.levels.length;t=n.levels.slice(0,r)}for(var s,l=ca(t);!(s=l()).done;){var u=s.value;u.bitrate>i&&(i=u.bitrate)}return i>0?i:NaN},o.getBufferLength=function(e){var t=this.hls.media,i=e===lr.AUDIO?this.audioBuffer:this.videoBuffer;return i&&t?1e3*Mt.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN},o.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return function(){function n(r){this.loader=void 0,this.loader=new i(r)}var a=n.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(r,s,l){t(r),this.loader.load(r,s,l)},da(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},o.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return function(){function n(r){this.loader=void 0,this.loader=new i(r)}var a=n.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(r,s,l){t(r),this.loader.load(r,s,l)},da(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},d.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},d.serialize=function(e){for(var t,i=[],n=function(S){return!Number.isNaN(S)&&S!=null&&S!==""&&S!==!1},a=function(S){return Math.round(S)},r=function(S){return 100*a(S/100)},s={br:a,d:a,bl:r,dl:r,mtp:r,nor:function(S){return encodeURIComponent(S)},rtp:r,tb:a},l=ca(Object.keys(e||{}).sort());!(t=l()).done;){var u=t.value,c=e[u];if(n(c)&&!(u==="v"&&c===1||u=="pr"&&c===1)){var v=s[u];v&&(c=v(c));var m,_=typeof c;m=u==="ot"||u==="sf"||u==="st"?u+"="+c:_==="boolean"?u:_==="number"?u+"="+c:u+"="+JSON.stringify(c),i.push(m)}}return i.join(",")},d.toHeaders=function(e){for(var t={},i=["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},r=0,s=Object.keys(e);r<s.length;r++){var l=s[r];n[a[l]!=null?a[l]:1][l]=e[l]}for(var u=0;u<n.length;u++){var c=d.serialize(n[u]);c&&(t["CMCD-"+i[u]]=c)}return t},d.toQuery=function(e){return"CMCD="+encodeURIComponent(d.serialize(e))},d.appendQueryToUri=function(e,t){if(!t)return e;var i=e.includes("?")?"&":"?";return""+e+i+t},d}(),fa=M(408),ss=/^age:\s*[\d.]+\s*$/m;let va=function(){function d(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 fa.LoadStats,this.retryDelay=0}var o=d.prototype;return o.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},o.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()))},o.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!==null&&e!==void 0&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},o.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.retryDelay=t.retryDelay,this.loadInternal()},o.loadInternal=function(){var e=this.config,t=this.context;if(e){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0;var a=this.xhrSetup;try{if(a)try{a(i,t.url)}catch{i.open("GET",t.url,!0),a(i,t.url)}i.readyState||i.open("GET",t.url,!0);var r=this.context.headers;if(r)for(var s in r)i.setRequestHeader(s,r[s])}catch(l){return void this.callbacks.onError({code:i.status,text:l.message},t,i)}t.rangeEnd&&i.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),i.onreadystatechange=this.readystatechange.bind(this),i.onprogress=this.loadprogress.bind(this),i.responseType=t.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout),i.send()}},o.readystatechange=function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!i.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start)),n===4){t.onreadystatechange=null,t.onprogress=null;var r=t.status,s=t.responseType==="arraybuffer";if(r>=200&&r<300&&(s&&t.response||t.responseText!==null)){var l,u;if(i.loading.end=Math.max(self.performance.now(),i.loading.first),u=s?(l=t.response).byteLength:(l=t.responseText).length,i.loaded=i.total=u,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(i,e,l,t),!this.callbacks)return;var v={url:t.responseURL,data:l};this.callbacks.onSuccess(v,i,e,t)}else i.retry>=a.maxRetry||r>=400&&r<499?(k.logger.error(r+" while loading "+e.url),this.callbacks.onError({code:r,text:t.statusText},e,t)):(k.logger.warn(r+" while loading "+e.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),i.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}},o.loadtimeout=function(){k.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},o.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},o.getCacheAge=function(){var e=null;if(this.loader&&ss.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},d}();function Mn(d){var o=typeof Map=="function"?new Map:void 0;return Mn=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(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return Nn(e,arguments,Un(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Mi(i,e)},Mn(d)}function Nn(d,o,e){return Nn=os()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Mi(r,n.prototype),r},Nn.apply(null,arguments)}function os(){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 Mi(d,o){return Mi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Mi(d,o)}function Un(d){return Un=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},Un(d)}function Bn(){return Bn=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},Bn.apply(this,arguments)}var ls=function(){function d(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||us,this.controller=new self.AbortController,this.stats=new fa.LoadStats}var o=d.prototype;return o.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},o.abortInternal=function(){var e=this.response;e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},o.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!==null&&e!==void 0&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},o.load=function(e,t,i){var n=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var r=function(c,v){var m={method:"GET",mode:"cors",credentials:"same-origin",signal:v,headers:new self.Headers(Bn({},c.headers))};return c.rangeEnd&&m.headers.set("Range","bytes="+c.rangeStart+"-"+String(c.rangeEnd-1)),m}(e,this.controller.signal),s=i.onProgress,l=e.responseType==="arraybuffer",u=l?"byteLength":"length";this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){n.abortInternal(),i.onTimeout(a,e,n.response)},t.timeout),self.fetch(this.request).then(function(c){if(n.response=n.loader=c,!c.ok){var v=c.status,m=c.statusText;throw new ds(m||"fetch, bad network response",v,c)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(c.headers.get("Content-Length")||"0"),s&&(0,R.isFiniteNumber)(t.highWaterMark)?n.loadProgressively(c,a,e,t.highWaterMark,s):l?c.arrayBuffer():c.text()}).then(function(c){var v=n.response;self.clearTimeout(n.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var m=c[u];m&&(a.loaded=a.total=m);var _={url:v.url,data:c};s&&!(0,R.isFiniteNumber)(t.highWaterMark)&&s(a,e,c,v),i.onSuccess(_,a,e,v)}).catch(function(c){if(self.clearTimeout(n.requestTimeout),!a.aborted){var v=c&&c.code||0,m=c?c.message:null;i.onError({code:v,text:m},e,c?c.details:null)}})},o.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},o.loadProgressively=function(e,t,i,n,a){n===void 0&&(n=0);var r=new nn,s=e.body.getReader();return function l(){return s.read().then(function(u){if(u.done)return r.dataLength&&a(t,i,r.flush(),e),Promise.resolve(new ArrayBuffer(0));var c=u.value,v=c.length;return t.loaded+=v,v<n||r.dataLength?(r.push(c),r.dataLength>=n&&a(t,i,r.flush(),e)):a(t,i,c,e),l()}).catch(function(){return Promise.reject()})}()},d}();function us(d,o){return new self.Request(d.url,o)}var ds=function(d){var o,e;function t(i,n,a){var r;return(r=d.call(this,i)||this).code=void 0,r.details=void 0,r.code=n,r.details=a,r}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Mi(o,e),t}(Mn(Error));let ga=ls;var cs=/\s/;function jn(){return jn=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},jn.apply(this,arguments)}function pa(d,o){var e=Object.keys(d);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(d);o&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(d,i).enumerable})),e.push.apply(e,t)}return e}function ma(d){for(var o=1;o<arguments.length;o++){var e=arguments[o]!=null?arguments[o]:{};o%2?pa(Object(e),!0).forEach(function(t){hs(d,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(e)):pa(Object(e)).forEach(function(t){Object.defineProperty(d,t,Object.getOwnPropertyDescriptor(e,t))})}return d}function hs(d,o,e){return(o=function(t){var i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t,"string");return typeof i=="symbol"?i:String(i)}(o))in d?Object.defineProperty(d,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):d[o]=e,d}var fs=ma(ma({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,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:va,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:bn,bufferController:Ln,capLevelController:ts,fpsController:rs,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:Te,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:{newCue:function(d,o,e,t){for(var i,n,a,r,s,l=[],u=self.VTTCue||self.TextTrackCue,c=0;c<t.rows.length;c++)if(a=!0,r=0,s="",!(i=t.rows[c]).isEmpty()){for(var v=0;v<i.chars.length;v++)cs.test(i.chars[v].uchar)&&a?r++:(s+=i.chars[v].uchar,a=!1);i.cueStartTime=o,o===e&&(e+=1e-4),r>=16?r--:r++;var m=qt(s.trim()),_=or(o,e,m);d&&d.cues&&d.cues.getCueById(_)||((n=new u(o,e,m)).id=_,n.line=c+1,n.align="left",n.position=10+Math.min(80,10*Math.floor(8*r/32)),l.push(n))}return d&&l.length&&(l.sort(function(S,P){return S.line==="auto"||P.line==="auto"?0:S.line>8&&P.line>8?P.line-S.line:S.line-P.line}),l.forEach(function(S){return yt(d,S)})),l}},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:An,subtitleTrackController:Dn,timelineController:$a,audioStreamController:Ci,audioTrackController:_n,emeController:ns,cmcdController:as});function ya(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var Ea=function(){function d(n){n===void 0&&(n={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Di.EventEmitter,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var a=this.config=function(be,Ge){if((Ge.liveSyncDurationCount||Ge.liveMaxLatencyDurationCount)&&(Ge.liveSyncDuration||Ge.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(Ge.liveMaxLatencyDurationCount!==void 0&&(Ge.liveSyncDurationCount===void 0||Ge.liveMaxLatencyDurationCount<=Ge.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(Ge.liveMaxLatencyDuration!==void 0&&(Ge.liveSyncDuration===void 0||Ge.liveMaxLatencyDuration<=Ge.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return jn({},be,Ge)}(d.DefaultConfig,n);this.userConfig=n,(0,k.enableLogs)(a.debug,"Hls instance"),this._autoLevelCapping=-1,a.progressive&&function(be){var Ge=be.loader;Ge!==ga&&Ge!==va?(k.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),be.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(be.loader=ga,be.progressive=!0,be.enableSoftwareAES=!0,k.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}(a);var r=a.abrController,s=a.bufferController,l=a.capLevelController,u=a.fpsController,c=this.abrController=new r(this),v=this.bufferController=new s(this),m=this.capLevelController=new l(this),_=new u(this),S=new Ye(this),P=new Rt(this),I=this.levelController=new ot(this),q=new bt(this),oe=new cr(this.config),Ee=this.streamController=new yn(this,q,oe);m.setStreamController(Ee),_.setStreamController(Ee);var he=[S,I,Ee];this.networkControllers=he;var Ae=[c,v,m,_,P,q];this.audioTrackController=this.createController(a.audioTrackController,he);var He=a.audioStreamController;He&&he.push(new He(this,q,oe)),this.subtitleTrackController=this.createController(a.subtitleTrackController,he);var ze=a.subtitleStreamController;ze&&he.push(new ze(this,q,oe)),this.createController(a.timelineController,Ae),oe.emeController=this.emeController=this.createController(a.emeController,Ae),this.cmcdController=this.createController(a.cmcdController,Ae),this.latencyController=this.createController(Ht,Ae),this.coreComponents=Ae}d.isSupported=function(){return function(){var n=hi();if(!n)return!1;var a=fi(),r=n&&typeof n.isTypeSupported=="function"&&n.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),s=!a||a.prototype&&typeof a.prototype.appendBuffer=="function"&&typeof a.prototype.remove=="function";return!!r&&!!s}()};var o,e,t,i=d.prototype;return i.createController=function(n,a){if(n){var r=new n(this);return a&&a.push(r),r}return null},i.on=function(n,a,r){r===void 0&&(r=this),this._emitter.on(n,a,r)},i.once=function(n,a,r){r===void 0&&(r=this),this._emitter.once(n,a,r)},i.removeAllListeners=function(n){this._emitter.removeAllListeners(n)},i.off=function(n,a,r,s){r===void 0&&(r=this),this._emitter.off(n,a,r,s)},i.listeners=function(n){return this._emitter.listeners(n)},i.emit=function(n,a,r){return this._emitter.emit(n,a,r)},i.trigger=function(n,a){if(this.config.debug)return this.emit(n,n,a);try{return this.emit(n,n,a)}catch(r){k.logger.error("An internal error happened while handling event "+n+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:n,error:r})}return!1},i.listenerCount=function(n){return this._emitter.listenerCount(n)},i.destroy=function(){k.logger.log("destroy"),this.trigger(p.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(n){return n.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(n){return n.destroy()}),this.coreComponents.length=0},i.attachMedia=function(n){k.logger.log("attachMedia"),this._media=n,this.trigger(p.Events.MEDIA_ATTACHING,{media:n})},i.detachMedia=function(){k.logger.log("detachMedia"),this.trigger(p.Events.MEDIA_DETACHING,void 0),this._media=null},i.loadSource=function(n){this.stopLoad();var a=this.media,r=this.url,s=this.url=te.buildAbsoluteURL(self.location.href,n,{alwaysNormalize:!0});k.logger.log("loadSource:"+s),a&&r&&r!==s&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(a)),this.trigger(p.Events.MANIFEST_LOADING,{url:n})},i.startLoad=function(n){n===void 0&&(n=-1),k.logger.log("startLoad("+n+")"),this.networkControllers.forEach(function(a){a.startLoad(n)})},i.stopLoad=function(){k.logger.log("stopLoad"),this.networkControllers.forEach(function(n){n.stopLoad()})},i.swapAudioCodec=function(){k.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},i.recoverMediaError=function(){k.logger.log("recoverMediaError");var n=this._media;this.detachMedia(),n&&this.attachMedia(n)},i.removeLevel=function(n,a){a===void 0&&(a=0),this.levelController.removeLevel(n,a)},o=d,t=[{key:"version",get:function(){return"1.3.1"}},{key:"Events",get:function(){return p.Events}},{key:"ErrorTypes",get:function(){return w.ErrorTypes}},{key:"ErrorDetails",get:function(){return w.ErrorDetails}},{key:"DefaultConfig",get:function(){return d.defaultConfig?d.defaultConfig:fs},set:function(n){d.defaultConfig=n}}],(e=[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(n){k.logger.log("set currentLevel:"+n),this.loadLevel=n,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(n){k.logger.log("set nextLevel:"+n),this.levelController.manualLevel=n,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(n){k.logger.log("set loadLevel:"+n),this.levelController.manualLevel=n}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(n){this.levelController.nextLoadLevel=n}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(n){k.logger.log("set firstLevel:"+n),this.levelController.firstLevel=n}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(n){k.logger.log("set startLevel:"+n),n!==-1&&(n=Math.max(n,this.minAutoLevel)),this.levelController.startLevel=n}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(n){var a=!!n;a!==this.config.capLevelToPlayerSize&&(a?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=a)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(n){this._autoLevelCapping!==n&&(k.logger.log("set autoLevelCapping:"+n),this._autoLevelCapping=n)}},{key:"bandwidthEstimate",get:function(){var n=this.abrController.bwEstimator;return n?n.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(n){ur.indexOf(n)>-1&&(this._maxHdcpLevel=n)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var n=this.levels,a=this.config.minAutoBitrate;if(!n)return 0;for(var r=n.length,s=0;s<r;s++)if(n[s].maxBitrate>=a)return s;return 0}},{key:"maxAutoLevel",get:function(){var n,a=this.levels,r=this.autoLevelCapping,s=this.maxHdcpLevel;if(n=r===-1&&a&&a.length?a.length-1:r,s)for(var l=n;l--;){var u=a[l].attrs["HDCP-LEVEL"];if(u&&u<=s)return l}return n}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(n){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,n)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var n=this.audioTrackController;return n?n.audioTracks:[]}},{key:"audioTrack",get:function(){var n=this.audioTrackController;return n?n.audioTrack:-1},set:function(n){var a=this.audioTrackController;a&&(a.audioTrack=n)}},{key:"subtitleTracks",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTrack:-1},set:function(n){var a=this.subtitleTrackController;a&&(a.subtitleTrack=n)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var n=this.subtitleTrackController;return!!n&&n.subtitleDisplay},set:function(n){var a=this.subtitleTrackController;a&&(a.subtitleDisplay=n)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(n){this.config.lowLatencyMode=n}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&ya(o.prototype,e),t&&ya(o,t),Object.defineProperty(o,"prototype",{writable:!1}),d}();Ea.defaultConfig=void 0},923:(se,X,M)=>{"use strict";M.r(X),M.d(X,{BaseSegment:()=>de,ElementaryStreamTypes:()=>j,Fragment:()=>_e,Part:()=>K});var j,te=M(965),R=M(945),p=M(408);function w(ve,$){ve.prototype=Object.create($.prototype),ve.prototype.constructor=ve,k(ve,$)}function k(ve,$){return k=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(ae,G){return ae.__proto__=G,ae},k(ve,$)}function me(ve,$){for(var ae=0;ae<$.length;ae++){var G=$[ae];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(ve,typeof(Se=function(ke,je){if(typeof ke!="object"||ke===null)return ke;var V=ke[Symbol.toPrimitive];if(V!==void 0){var E=V.call(ke,je);if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(ke)}(G.key,"string"))=="symbol"?Se:String(Se),G)}var Se}function re(ve,$,ae){return $&&me(ve.prototype,$),ae&&me(ve,ae),Object.defineProperty(ve,"prototype",{writable:!1}),ve}(function(ve){ve.AUDIO="audio",ve.VIDEO="video",ve.AUDIOVIDEO="audiovideo"})(j||(j={}));var de=function(){function ve($){var ae;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((ae={})[j.AUDIO]=null,ae[j.VIDEO]=null,ae[j.AUDIOVIDEO]=null,ae),this.baseurl=$}return ve.prototype.setByteRange=function($,ae){var G=$.split("@",2),Se=[];G.length===1?Se[0]=ae?ae.byteRangeEndOffset:0:Se[0]=parseInt(G[1]),Se[1]=parseInt(G[0])+Se[0],this._byteRange=Se},re(ve,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,R.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function($){this._url=$}}]),ve}(),_e=function(ve){function $(G,Se){var ke;return(ke=ve.call(this,Se)||this)._decryptdata=null,ke.rawProgramDateTime=null,ke.programDateTime=null,ke.tagList=[],ke.duration=0,ke.sn=0,ke.levelkeys=void 0,ke.type=void 0,ke.loader=null,ke.keyLoader=null,ke.level=-1,ke.cc=0,ke.startPTS=void 0,ke.endPTS=void 0,ke.appendedPTS=void 0,ke.startDTS=void 0,ke.endDTS=void 0,ke.start=0,ke.deltaPTS=void 0,ke.maxStartPTS=void 0,ke.minEndPTS=void 0,ke.stats=new p.LoadStats,ke.urlId=0,ke.data=void 0,ke.bitrateTest=!1,ke.title=null,ke.initSegment=null,ke.endList=void 0,ke.type=G,ke}w($,ve);var ae=$.prototype;return ae.setKeyFormat=function(G){if(this.levelkeys){var Se=this.levelkeys[G];Se&&!this._decryptdata&&(this._decryptdata=Se.getDecryptData(this.sn))}},ae.abortRequests=function(){var G,Se;(G=this.loader)===null||G===void 0||G.abort(),(Se=this.keyLoader)===null||Se===void 0||Se.abort()},ae.setElementaryStreamInfo=function(G,Se,ke,je,V,E){E===void 0&&(E=!1);var U=this.elementaryStreams,A=U[G];A?(A.startPTS=Math.min(A.startPTS,Se),A.endPTS=Math.max(A.endPTS,ke),A.startDTS=Math.min(A.startDTS,je),A.endDTS=Math.max(A.endDTS,V)):U[G]={startPTS:Se,endPTS:ke,startDTS:je,endDTS:V,partial:E}},ae.clearElementaryStreamInfo=function(){var G=this.elementaryStreams;G[j.AUDIO]=null,G[j.VIDEO]=null,G[j.AUDIOVIDEO]=null},re($,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var G=this.levelkeys.identity;if(G)this._decryptdata=G.getDecryptData(this.sn);else{var Se=Object.keys(this.levelkeys);if(Se.length===1)return this._decryptdata=this.levelkeys[Se[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!(0,te.isFiniteNumber)(this.programDateTime))return null;var G=(0,te.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*G}},{key:"encrypted",get:function(){var G;if((G=this._decryptdata)!==null&&G!==void 0&&G.encrypted)return!0;if(this.levelkeys){var Se=Object.keys(this.levelkeys),ke=Se.length;if(ke>1||ke===1&&this.levelkeys[Se[0]].encrypted)return!0}return!1}}]),$}(de),K=function(ve){function $(ae,G,Se,ke,je){var V;(V=ve.call(this,Se)||this).fragOffset=0,V.duration=0,V.gap=!1,V.independent=!1,V.relurl=void 0,V.fragment=void 0,V.index=void 0,V.stats=new p.LoadStats,V.duration=ae.decimalFloatingPoint("DURATION"),V.gap=ae.bool("GAP"),V.independent=ae.bool("INDEPENDENT"),V.relurl=ae.enumeratedString("URI"),V.fragment=G,V.index=ke;var E=ae.enumeratedString("BYTERANGE");return E&&V.setByteRange(E,je),je&&(V.fragOffset=je.fragOffset+je.duration),V}return w($,ve),re($,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var ae=this.elementaryStreams;return!!(ae.audio||ae.video||ae.audiovideo)}}]),$}(de)},408:(se,X,M)=>{"use strict";M.r(X),M.d(X,{LoadStats:()=>j});var j=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}}},965:(se,X,M)=>{"use strict";M.r(X),M.d(X,{MAX_SAFE_INTEGER:()=>te,isFiniteNumber:()=>j});var j=Number.isFinite||function(R){return typeof R=="number"&&isFinite(R)},te=Number.MAX_SAFE_INTEGER||9007199254740991},524:(se,X,M)=>{"use strict";M.r(X),M.d(X,{default:()=>ae,flushTextTrackMetadataCueSamples:()=>Se,flushTextTrackUserdataCueSamples:()=>ke,normalizePts:()=>G});var j=M(965);let te=function(){function E(){}return E.getSilentFrame=function(U,A){if(U==="mp4a.40.2"){if(A===1)return new Uint8Array([0,200,0,128,35,128]);if(A===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(A===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(A===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(A===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(A===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(A===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(A===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(A===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])}},E}();var R=Math.pow(2,32)-1,p=function(){function E(){}return E.init=function(){var U;for(U in E.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:[]},E.types)E.types.hasOwnProperty(U)&&(E.types[U]=[U.charCodeAt(0),U.charCodeAt(1),U.charCodeAt(2),U.charCodeAt(3)]);var A=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),ue=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]);E.HDLR_TYPES={video:A,audio:ue};var Te=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),J=new Uint8Array([0,0,0,0,0,0,0,0]);E.STTS=E.STSC=E.STCO=J,E.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),E.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),E.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),E.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var z=new Uint8Array([105,115,111,109]),De=new Uint8Array([97,118,99,49]),Re=new Uint8Array([0,0,0,1]);E.FTYP=E.box(E.types.ftyp,z,Re,z,De),E.DINF=E.box(E.types.dinf,E.box(E.types.dref,Te))},E.box=function(U){for(var A=8,ue=arguments.length,Te=new Array(ue>1?ue-1:0),J=1;J<ue;J++)Te[J-1]=arguments[J];for(var z=Te.length,De=z;z--;)A+=Te[z].byteLength;var Re=new Uint8Array(A);for(Re[0]=A>>24&255,Re[1]=A>>16&255,Re[2]=A>>8&255,Re[3]=255&A,Re.set(U,4),z=0,A=8;z<De;z++)Re.set(Te[z],A),A+=Te[z].byteLength;return Re},E.hdlr=function(U){return E.box(E.types.hdlr,E.HDLR_TYPES[U])},E.mdat=function(U){return E.box(E.types.mdat,U)},E.mdhd=function(U,A){A*=U;var ue=Math.floor(A/(R+1)),Te=Math.floor(A%(R+1));return E.box(E.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,255&U,ue>>24,ue>>16&255,ue>>8&255,255&ue,Te>>24,Te>>16&255,Te>>8&255,255&Te,85,196,0,0]))},E.mdia=function(U){return E.box(E.types.mdia,E.mdhd(U.timescale,U.duration),E.hdlr(U.type),E.minf(U))},E.mfhd=function(U){return E.box(E.types.mfhd,new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,255&U]))},E.minf=function(U){return U.type==="audio"?E.box(E.types.minf,E.box(E.types.smhd,E.SMHD),E.DINF,E.stbl(U)):E.box(E.types.minf,E.box(E.types.vmhd,E.VMHD),E.DINF,E.stbl(U))},E.moof=function(U,A,ue){return E.box(E.types.moof,E.mfhd(U),E.traf(ue,A))},E.moov=function(U){for(var A=U.length,ue=[];A--;)ue[A]=E.trak(U[A]);return E.box.apply(null,[E.types.moov,E.mvhd(U[0].timescale,U[0].duration)].concat(ue).concat(E.mvex(U)))},E.mvex=function(U){for(var A=U.length,ue=[];A--;)ue[A]=E.trex(U[A]);return E.box.apply(null,[E.types.mvex].concat(ue))},E.mvhd=function(U,A){A*=U;var ue=Math.floor(A/(R+1)),Te=Math.floor(A%(R+1)),J=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,255&U,ue>>24,ue>>16&255,ue>>8&255,255&ue,Te>>24,Te>>16&255,Te>>8&255,255&Te,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 E.box(E.types.mvhd,J)},E.sdtp=function(U){var A,ue,Te=U.samples||[],J=new Uint8Array(4+Te.length);for(A=0;A<Te.length;A++)ue=Te[A].flags,J[A+4]=ue.dependsOn<<4|ue.isDependedOn<<2|ue.hasRedundancy;return E.box(E.types.sdtp,J)},E.stbl=function(U){return E.box(E.types.stbl,E.stsd(U),E.box(E.types.stts,E.STTS),E.box(E.types.stsc,E.STSC),E.box(E.types.stsz,E.STSZ),E.box(E.types.stco,E.STCO))},E.avc1=function(U){var A,ue,Te,J=[],z=[];for(A=0;A<U.sps.length;A++)Te=(ue=U.sps[A]).byteLength,J.push(Te>>>8&255),J.push(255&Te),J=J.concat(Array.prototype.slice.call(ue));for(A=0;A<U.pps.length;A++)Te=(ue=U.pps[A]).byteLength,z.push(Te>>>8&255),z.push(255&Te),z=z.concat(Array.prototype.slice.call(ue));var De=E.box(E.types.avcC,new Uint8Array([1,J[3],J[4],J[5],255,224|U.sps.length].concat(J).concat([U.pps.length]).concat(z))),Re=U.width,Oe=U.height,ye=U.pixelRatio[0],qe=U.pixelRatio[1];return E.box(E.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,Re>>8&255,255&Re,Oe>>8&255,255&Oe,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]),De,E.box(E.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),E.box(E.types.pasp,new Uint8Array([ye>>24,ye>>16&255,ye>>8&255,255&ye,qe>>24,qe>>16&255,qe>>8&255,255&qe])))},E.esds=function(U){var A=U.config.length;return new Uint8Array([0,0,0,0,3,23+A,0,1,0,4,15+A,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([A]).concat(U.config).concat([6,1,2]))},E.mp4a=function(U){var A=U.samplerate;return E.box(E.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,A>>8&255,255&A,0,0]),E.box(E.types.esds,E.esds(U)))},E.mp3=function(U){var A=U.samplerate;return E.box(E.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,A>>8&255,255&A,0,0]))},E.stsd=function(U){return U.type==="audio"?U.segmentCodec==="mp3"&&U.codec==="mp3"?E.box(E.types.stsd,E.STSD,E.mp3(U)):E.box(E.types.stsd,E.STSD,E.mp4a(U)):E.box(E.types.stsd,E.STSD,E.avc1(U))},E.tkhd=function(U){var A=U.id,ue=U.duration*U.timescale,Te=U.width,J=U.height,z=Math.floor(ue/(R+1)),De=Math.floor(ue%(R+1));return E.box(E.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,A>>24&255,A>>16&255,A>>8&255,255&A,0,0,0,0,z>>24,z>>16&255,z>>8&255,255&z,De>>24,De>>16&255,De>>8&255,255&De,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,Te>>8&255,255&Te,0,0,J>>8&255,255&J,0,0]))},E.traf=function(U,A){var ue=E.sdtp(U),Te=U.id,J=Math.floor(A/(R+1)),z=Math.floor(A%(R+1));return E.box(E.types.traf,E.box(E.types.tfhd,new Uint8Array([0,0,0,0,Te>>24,Te>>16&255,Te>>8&255,255&Te])),E.box(E.types.tfdt,new Uint8Array([1,0,0,0,J>>24,J>>16&255,J>>8&255,255&J,z>>24,z>>16&255,z>>8&255,255&z])),E.trun(U,ue.length+16+20+8+16+8+8),ue)},E.trak=function(U){return U.duration=U.duration||4294967295,E.box(E.types.trak,E.tkhd(U),E.mdia(U))},E.trex=function(U){var A=U.id;return E.box(E.types.trex,new Uint8Array([0,0,0,0,A>>24,A>>16&255,A>>8&255,255&A,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},E.trun=function(U,A){var ue,Te,J,z,De,Re,Oe=U.samples||[],ye=Oe.length,qe=12+16*ye,tt=new Uint8Array(qe);for(A+=8+qe,tt.set([U.type==="video"?1:0,0,15,1,ye>>>24&255,ye>>>16&255,ye>>>8&255,255&ye,A>>>24&255,A>>>16&255,A>>>8&255,255&A],0),ue=0;ue<ye;ue++)J=(Te=Oe[ue]).duration,z=Te.size,De=Te.flags,Re=Te.cts,tt.set([J>>>24&255,J>>>16&255,J>>>8&255,255&J,z>>>24&255,z>>>16&255,z>>>8&255,255&z,De.isLeading<<2|De.dependsOn,De.isDependedOn<<6|De.hasRedundancy<<4|De.paddingValue<<1|De.isNonSync,61440&De.degradPrio,15&De.degradPrio,Re>>>24&255,Re>>>16&255,Re>>>8&255,255&Re],12+16*ue);return E.box(E.types.trun,tt)},E.initSegment=function(U){E.types||E.init();var A=E.moov(U),ue=new Uint8Array(E.FTYP.byteLength+A.byteLength);return ue.set(E.FTYP),ue.set(A,E.FTYP.byteLength),ue},E}();p.types=void 0,p.HDLR_TYPES=void 0,p.STTS=void 0,p.STSC=void 0,p.STCO=void 0,p.STSZ=void 0,p.VMHD=void 0,p.SMHD=void 0,p.STSD=void 0,p.FTYP=void 0,p.DINF=void 0;let w=p;var k=M(851),me=M(973),re=M(93),de=M(308),_e=M(673);function K(){return K=Object.assign?Object.assign.bind():function(E){for(var U=1;U<arguments.length;U++){var A=arguments[U];for(var ue in A)Object.prototype.hasOwnProperty.call(A,ue)&&(E[ue]=A[ue])}return E},K.apply(this,arguments)}var ve=null,$=null,ae=function(){function E(A,ue,Te,J){if(J===void 0&&(J=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=A,this.config=ue,this.typeSupported=Te,this.ISGenerated=!1,ve===null){var z=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ve=z?parseInt(z[1]):0}if($===null){var De=navigator.userAgent.match(/Safari\/(\d+)/i);$=De?parseInt(De[1]):0}}var U=E.prototype;return U.destroy=function(){},U.resetTimeStamp=function(A){re.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=A},U.resetNextTimestamp=function(){re.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},U.resetInitSegment=function(){re.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},U.getVideoStartPts=function(A){var ue=!1,Te=A.reduce(function(J,z){var De=z.pts-J;return De<-4294967296?(ue=!0,G(J,z.pts)):De>0?J:z.pts},A[0].pts);return ue&&re.logger.debug("PTS rollover detected"),Te},U.remux=function(A,ue,Te,J,z,De,Re,Oe){var ye,qe,tt,ie,ce,ne,xe=z,Pe=z,Ne=A.pid>-1,Be=ue.pid>-1,Ke=ue.samples.length,pe=A.samples.length>0,Ie=Re&&Ke>0||Ke>1;if((!Ne||pe)&&(!Be||Ie)||this.ISGenerated||Re){this.ISGenerated||(tt=this.generateIS(A,ue,z));var Ye,rt=this.isVideoContiguous,yt=-1;if(Ie&&(yt=function(At){for(var pt=0;pt<At.length;pt++)if(At[pt].key)return pt;return-1}(ue.samples),!rt&&this.config.forceKeyFrameOnDiscontinuity))if(ne=!0,yt>0){re.logger.warn("[mp4-remuxer]: Dropped "+yt+" out of "+Ke+" video samples due to a missing keyframe");var ht=this.getVideoStartPts(ue.samples);ue.samples=ue.samples.slice(yt),ue.dropped+=yt,Ye=Pe+=(ue.samples[0].pts-ht)/ue.inputTimeScale}else yt===-1&&(re.logger.warn("[mp4-remuxer]: No keyframe found out of "+Ke+" video samples"),ne=!1);if(this.ISGenerated){if(pe&&Ie){var It=this.getVideoStartPts(ue.samples),Lt=(G(A.samples[0].pts,It)-It)/ue.inputTimeScale;xe+=Math.max(0,Lt),Pe+=Math.max(0,-Lt)}if(pe){if(A.samplerate||(re.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),tt=this.generateIS(A,ue,z)),qe=this.remuxAudio(A,xe,this.isAudioContiguous,De,Be||Ie||Oe===de.PlaylistLevelType.AUDIO?Pe:void 0),Ie){var St=qe?qe.endPTS-qe.startPTS:0;ue.inputTimeScale||(re.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),tt=this.generateIS(A,ue,z)),ye=this.remuxVideo(ue,Pe,rt,St)}}else Ie&&(ye=this.remuxVideo(ue,Pe,rt,0));ye&&(ye.firstKeyFrame=yt,ye.independent=yt!==-1,ye.firstKeyFramePTS=Ye)}}return this.ISGenerated&&(Te.samples.length&&(ce=Se(Te,z,this._initPTS,this._initDTS)),J.samples.length&&(ie=ke(J,z,this._initPTS))),{audio:qe,video:ye,initSegment:tt,independent:ne,text:ie,id3:ce}},U.generateIS=function(A,ue,Te){var J,z,De,Re=A.samples,Oe=ue.samples,ye=this.typeSupported,qe={},tt=!(0,j.isFiniteNumber)(this._initPTS),ie="audio/mp4";if(tt&&(J=z=1/0),A.config&&Re.length&&(A.timescale=A.samplerate,A.segmentCodec==="mp3"&&(ye.mpeg?(ie="audio/mpeg",A.codec=""):ye.mp3&&(A.codec="mp3")),qe.audio={id:"audio",container:ie,codec:A.codec,initSegment:A.segmentCodec==="mp3"&&ye.mpeg?new Uint8Array(0):w.initSegment([A]),metadata:{channelCount:A.channelCount}},tt&&(De=A.inputTimeScale,J=z=Re[0].pts-Math.round(De*Te))),ue.sps&&ue.pps&&Oe.length&&(ue.timescale=ue.inputTimeScale,qe.video={id:"main",container:"video/mp4",codec:ue.codec,initSegment:w.initSegment([ue]),metadata:{width:ue.width,height:ue.height}},tt)){De=ue.inputTimeScale;var ce=this.getVideoStartPts(Oe),ne=Math.round(De*Te);z=Math.min(z,G(Oe[0].dts,ce)-ne),J=Math.min(J,ce-ne)}if(Object.keys(qe).length)return this.ISGenerated=!0,tt&&(this._initPTS=J,this._initDTS=z),{tracks:qe,initPTS:J,timescale:De}},U.remuxVideo=function(A,ue,Te,J){var z,De,Re=A.inputTimeScale,Oe=A.samples,ye=[],qe=Oe.length,tt=this._initPTS,ie=this.nextAvcDts,ce=8,ne=this.videoSampleDuration,xe=Number.POSITIVE_INFINITY,Pe=Number.NEGATIVE_INFINITY,Ne=!1;Te&&ie!==null||(ie=ue*Re-(Oe[0].pts-G(Oe[0].dts,Oe[0].pts)));for(var Be=0;Be<qe;Be++){var Ke=Oe[Be];Ke.pts=G(Ke.pts-tt,ie),Ke.dts=G(Ke.dts-tt,ie),Ke.dts<Oe[Be>0?Be-1:Be].dts&&(Ne=!0)}Ne&&Oe.sort(function(Yt,cr){var Ir=Yt.dts-cr.dts,dr=Yt.pts-cr.pts;return Ir||dr}),z=Oe[0].dts;var pe=Oe[Oe.length-1].dts-z,Ie=pe?Math.round(pe/(qe-1)):ne||A.inputTimeScale/30;if(Te){var Ye=z-ie,rt=Ye>Ie,yt=Ye<-1;if((rt||yt)&&(rt?re.logger.warn("AVC: "+(0,_e.toMsFromMpegTsClock)(Ye,!0)+" ms ("+Ye+"dts) hole between fragments detected, filling it"):re.logger.warn("AVC: "+(0,_e.toMsFromMpegTsClock)(-Ye,!0)+" ms ("+Ye+"dts) overlapping between fragments detected"),!yt||ie>Oe[0].pts)){z=ie;var ht=Oe[0].pts-Ye;Oe[0].dts=z,Oe[0].pts=ht,re.logger.log("Video: First PTS/DTS adjusted: "+(0,_e.toMsFromMpegTsClock)(ht,!0)+"/"+(0,_e.toMsFromMpegTsClock)(z,!0)+", delta: "+(0,_e.toMsFromMpegTsClock)(Ye,!0)+" ms")}}z=Math.max(0,z);for(var It=0,Lt=0,St=0;St<qe;St++){for(var At=Oe[St],pt=At.units,ut=pt.length,Rt=0,Ct=0;Ct<ut;Ct++)Rt+=pt[Ct].data.length;Lt+=Rt,It+=ut,At.length=Rt,At.dts=Math.max(At.dts,z),xe=Math.min(At.pts,xe),Pe=Math.max(At.pts,Pe)}De=Oe[qe-1].dts;var Ht,Qt=Lt+4*It+8;try{Ht=new Uint8Array(Qt)}catch{return void this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:me.ErrorTypes.MUX_ERROR,details:me.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Qt,reason:"fail allocating video mdat "+Qt})}var Ut=new DataView(Ht.buffer);Ut.setUint32(0,Qt),Ht.set(w.types.mdat,4);for(var ur=!1,ee=Number.POSITIVE_INFINITY,F=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,C=Number.NEGATIVE_INFINITY,L=0;L<qe;L++){for(var B=Oe[L],Y=B.units,Q=0,ge=0,we=Y.length;ge<we;ge++){var Le=Y[ge],Fe=Le.data,Ve=Le.data.byteLength;Ut.setUint32(ce,Ve),ce+=4,Ht.set(Fe,ce),ce+=Ve,Q+=4+Ve}var Ue=void 0;if(L<qe-1)ne=Oe[L+1].dts-B.dts,Ue=Oe[L+1].pts-B.pts;else{var Qe=this.config,ot=L>0?B.dts-Oe[L-1].dts:Ie;if(Ue=L>0?B.pts-Oe[L-1].pts:Ie,Qe.stretchShortVideoTrack&&this.nextAudioPts!==null){var bt=Math.floor(Qe.maxBufferHole*Re),We=(J?xe+J*Re:this.nextAudioPts)-B.pts;We>bt?((ne=We-ot)<0?ne=ot:ur=!0,re.logger.log("[mp4-remuxer]: It is approximately "+We/90+" ms to the next segment; using duration "+ne/90+" ms for the last video frame.")):ne=ot}else ne=ot}var kt=Math.round(B.pts-B.dts);ee=Math.min(ee,ne),T=Math.max(T,ne),F=Math.min(F,Ue),C=Math.max(C,Ue),ye.push(new je(B.key,ne,Q,kt))}if(ye.length){if(ve){if(ve<70){var Jt=ye[0].flags;Jt.dependsOn=2,Jt.isNonSync=0}}else if($&&C-F<T-ee&&Ie/T<.025&&ye[0].cts===0){re.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Ft=z,Pt=0,Bt=ye.length;Pt<Bt;Pt++){var Ze=Ft+ye[Pt].duration,ir=Ft+ye[Pt].cts;if(Pt<Bt-1){var br=Ze+ye[Pt+1].cts;ye[Pt].duration=br-ir}else ye[Pt].duration=Pt?ye[Pt-1].duration:Ie;ye[Pt].cts=0,Ft=Ze}}}ne=ur||!ne?Ie:ne,this.nextAvcDts=ie=De+ne,this.videoSampleDuration=ne,this.isVideoContiguous=!0;var Nt={data1:w.moof(A.sequenceNumber++,z,K({},A,{samples:ye})),data2:Ht,startPTS:xe/Re,endPTS:(Pe+ne)/Re,startDTS:z/Re,endDTS:ie/Re,type:"video",hasAudio:!1,hasVideo:!0,nb:ye.length,dropped:A.dropped};return A.samples=[],A.dropped=0,Nt},U.remuxAudio=function(A,ue,Te,J,z){var De=A.inputTimeScale,Re=De/(A.samplerate?A.samplerate:De),Oe=A.segmentCodec==="aac"?1024:1152,ye=Oe*Re,qe=this._initPTS,tt=A.segmentCodec==="mp3"&&this.typeSupported.mpeg,ie=[],ce=z!==void 0,ne=A.samples,xe=tt?0:8,Pe=this.nextAudioPts||-1,Ne=ue*De;if(this.isAudioContiguous=Te=Te||ne.length&&Pe>0&&(J&&Math.abs(Ne-Pe)<9e3||Math.abs(G(ne[0].pts-qe,Ne)-Pe)<20*ye),ne.forEach(function(ge){ge.pts=G(ge.pts-qe,Ne)}),!Te||Pe<0){if(ne=ne.filter(function(ge){return ge.pts>=0}),!ne.length)return;Pe=z===0?0:J&&!ce?Math.max(0,Ne):ne[0].pts}if(A.segmentCodec==="aac")for(var Be=this.config.maxAudioFramesDrift,Ke=0,pe=Pe;Ke<ne.length;Ke++){var Ie=ne[Ke],Ye=Ie.pts,rt=Ye-pe,yt=Math.abs(1e3*rt/De);if(rt<=-Be*ye&&ce)Ke===0&&(re.logger.warn("Audio frame @ "+(Ye/De).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*rt/De)+" ms."),this.nextAudioPts=Pe=pe=Ye);else if(rt>=Be*ye&&yt<1e4&&ce){var ht=Math.round(rt/ye);(pe=Ye-ht*ye)<0&&(ht--,pe+=ye),Ke===0&&(this.nextAudioPts=Pe=pe),re.logger.warn("[mp4-remuxer]: Injecting "+ht+" audio frame @ "+(pe/De).toFixed(3)+"s due to "+Math.round(1e3*rt/De)+" ms gap.");for(var It=0;It<ht;It++){var Lt=Math.max(pe,0),St=te.getSilentFrame(A.manifestCodec||A.codec,A.channelCount);St||(re.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),St=Ie.unit.subarray()),ne.splice(Ke,0,{unit:St,pts:Lt}),pe+=ye,Ke++}}Ie.pts=pe,pe+=ye}for(var At,pt=null,ut=null,Rt=0,Ct=ne.length;Ct--;)Rt+=ne[Ct].unit.byteLength;for(var Ht=0,Qt=ne.length;Ht<Qt;Ht++){var Ut=ne[Ht],ur=Ut.unit,ee=Ut.pts;if(ut!==null)ie[Ht-1].duration=Math.round((ee-ut)/Re);else{if(Te&&A.segmentCodec==="aac"&&(ee=Pe),pt=ee,!(Rt>0))return;Rt+=xe;try{At=new Uint8Array(Rt)}catch{return void this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:me.ErrorTypes.MUX_ERROR,details:me.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Rt,reason:"fail allocating audio mdat "+Rt})}tt||(new DataView(At.buffer).setUint32(0,Rt),At.set(w.types.mdat,4))}At.set(ur,xe);var F=ur.byteLength;xe+=F,ie.push(new je(!0,Oe,F,0)),ut=ee}var T=ie.length;if(T){var C=ie[ie.length-1];this.nextAudioPts=Pe=ut+Re*C.duration;var L=tt?new Uint8Array(0):w.moof(A.sequenceNumber++,pt/Re,K({},A,{samples:ie}));A.samples=[];var B=pt/De,Y=Pe/De,Q={data1:L,data2:At,startPTS:B,endPTS:Y,startDTS:B,endDTS:Y,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,Q}},U.remuxEmptyAudio=function(A,ue,Te,J){var z=A.inputTimeScale,De=z/(A.samplerate?A.samplerate:z),Re=this.nextAudioPts,Oe=(Re!==null?Re:J.startDTS*z)+this._initDTS,ye=J.endDTS*z+this._initDTS,qe=1024*De,tt=Math.ceil((ye-Oe)/qe),ie=te.getSilentFrame(A.manifestCodec||A.codec,A.channelCount);if(re.logger.warn("[mp4-remuxer]: remux empty Audio"),ie){for(var ce=[],ne=0;ne<tt;ne++){var xe=Oe+ne*qe;ce.push({unit:ie,pts:xe,dts:xe})}return A.samples=ce,this.remuxAudio(A,ue,Te,!1)}re.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},E}();function G(E,U){var A;if(U===null)return E;for(A=U<E?-8589934592:8589934592;Math.abs(E-U)>4294967296;)E+=A;return E}function Se(E,U,A,ue){var Te=E.samples.length;if(Te){for(var J=E.inputTimeScale,z=0;z<Te;z++){var De=E.samples[z];De.pts=G(De.pts-A,U*J)/J,De.dts=G(De.dts-ue,U*J)/J}var Re=E.samples;return E.samples=[],{samples:Re}}}function ke(E,U,A){var ue=E.samples.length;if(ue){for(var Te=E.inputTimeScale,J=0;J<ue;J++){var z=E.samples[J];z.pts=G(z.pts-A,U*Te)/Te}E.samples.sort(function(Re,Oe){return Re.pts-Oe.pts});var De=E.samples;return E.samples=[],{samples:De}}}var je=function(E,U,A,ue){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=U,this.size=A,this.cts=ue,this.flags=new V(E)},V=function(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}},856:(se,X,M)=>{"use strict";var j;M.r(X),M.d(X,{MetadataSchema:()=>j}),function(te){te.audioId3="org.id3",te.dateRange="com.apple.quicktime.HLS",te.emsg="https://aomedia.org/emsg/ID3"}(j||(j={}))},308:(se,X,M)=>{"use strict";var j,te;M.r(X),M.d(X,{PlaylistContextType:()=>j,PlaylistLevelType:()=>te}),function(R){R.MANIFEST="manifest",R.LEVEL="level",R.AUDIO_TRACK="audioTrack",R.SUBTITLE_TRACK="subtitleTrack"}(j||(j={})),function(R){R.MAIN="main",R.AUDIO="audio",R.SUBTITLE="subtitle"}(te||(te={}))},300:(se,X,M)=>{"use strict";M.r(X),M.d(X,{default:()=>j});let j={hexDump:function(te){for(var R="",p=0;p<te.length;p++){var w=te[p].toString(16);w.length<2&&(w="0"+w),R+=w}return R}}},93:(se,X,M)=>{"use strict";M.r(X),M.d(X,{enableLogs:()=>w,logger:()=>k});var j=function(){},te={trace:j,debug:j,log:j,warn:j,info:j,error:j},R=te;function p(me){var re=self.console[me];return re?re.bind(self.console,"["+me+"] >"):j}function w(me,re){if(self.console&&me===!0||typeof me=="object"){(function(de){for(var _e=arguments.length,K=new Array(_e>1?_e-1:0),ve=1;ve<_e;ve++)K[ve-1]=arguments[ve];K.forEach(function($){R[$]=de[$]?de[$].bind(de):p($)})})(me,"debug","log","info","warn","error");try{R.log('Debug logs enabled for "'+re+'"')}catch{R=te}}else R=te}var k=te},63:(se,X,M)=>{"use strict";M.r(X),M.d(X,{RemuxerTrackIdConfig:()=>re,appendUint8Array:()=>Te,bin2str:()=>de,computeRawDurationFromSamples:()=>U,discardEPB:()=>Re,findBox:()=>ae,getDuration:()=>E,getStartDTS:()=>V,mp4Box:()=>ye,mp4pssh:()=>qe,offsetStartDTS:()=>A,parseEmsg:()=>Oe,parseInitSegment:()=>Se,parsePssh:()=>tt,parseSEIMessageFromNALu:()=>De,parseSamples:()=>J,parseSegmentIndex:()=>G,parseSinf:()=>je,patchEncyptionData:()=>ke,readSint32:()=>ve,readUint16:()=>_e,readUint32:()=>K,segmentValidRange:()=>ue,writeUint32:()=>$});var j=M(923),te=M(145),R=M(181),p=M(93),w=M(300),k=Math.pow(2,32)-1,me=[].push,re={video:1,audio:2,id3:3,text:4};function de(ie){return String.fromCharCode.apply(null,ie)}function _e(ie,ce){var ne=ie[ce]<<8|ie[ce+1];return ne<0?65536+ne:ne}function K(ie,ce){var ne=ve(ie,ce);return ne<0?4294967296+ne:ne}function ve(ie,ce){return ie[ce]<<24|ie[ce+1]<<16|ie[ce+2]<<8|ie[ce+3]}function $(ie,ce,ne){ie[ce]=ne>>24,ie[ce+1]=ne>>16&255,ie[ce+2]=ne>>8&255,ie[ce+3]=255&ne}function ae(ie,ce){var ne=[];if(!ce.length)return ne;for(var xe=ie.byteLength,Pe=0;Pe<xe;){var Ne=K(ie,Pe),Be=Ne>1?Pe+Ne:xe;if(de(ie.subarray(Pe+4,Pe+8))===ce[0])if(ce.length===1)ne.push(ie.subarray(Pe+8,Be));else{var Ke=ae(ie.subarray(Pe+8,Be),ce.slice(1));Ke.length&&me.apply(ne,Ke)}Pe=Be}return ne}function G(ie){var ce=[],ne=ie[0],xe=8,Pe=K(ie,xe);xe+=4,xe+=ne===0?8:16,xe+=2;var Ne=ie.length+0,Be=_e(ie,xe);xe+=2;for(var Ke=0;Ke<Be;Ke++){var pe=xe,Ie=K(ie,pe);pe+=4;var Ye=2147483647&Ie;if((2147483648&Ie)>>>31==1)return console.warn("SIDX has hierarchical references (not supported)"),null;var rt=K(ie,pe);pe+=4,ce.push({referenceSize:Ye,subsegmentDuration:rt,info:{duration:rt/Pe,start:Ne,end:Ne+Ye-1}}),Ne+=Ye,xe=pe+=4}return{earliestPresentationTime:0,timescale:Pe,version:ne,referencesCount:Be,references:ce}}function Se(ie){for(var ce=[],ne=ae(ie,["moov","trak"]),xe=0;xe<ne.length;xe++){var Pe=ne[xe],Ne=ae(Pe,["tkhd"])[0];if(Ne){var Be=Ne[0],Ke=Be===0?12:20,pe=K(Ne,Ke),Ie=ae(Pe,["mdia","mdhd"])[0];if(Ie){var Ye=K(Ie,Ke=(Be=Ie[0])===0?12:20),rt=ae(Pe,["mdia","hdlr"])[0];if(rt){var yt=de(rt.subarray(8,12)),ht={soun:j.ElementaryStreamTypes.AUDIO,vide:j.ElementaryStreamTypes.VIDEO}[yt];if(ht){var It=ae(Pe,["mdia","minf","stbl","stsd"])[0],Lt=void 0;It&&(Lt=de(It.subarray(12,16))),ce[pe]={timescale:Ye,type:ht},ce[ht]={timescale:Ye,id:pe,codec:Lt}}}}}}return ae(ie,["moov","mvex","trex"]).forEach(function(St){var At=K(St,4),pt=ce[At];pt&&(pt.default={duration:K(St,12),flags:K(St,20)})}),ce}function ke(ie,ce){if(!ie||!ce)return ie;var ne=ce.keyId;return ne&&ce.isCommonEncryption&&ae(ie,["moov","trak"]).forEach(function(xe){var Pe=ae(xe,["mdia","minf","stbl","stsd"])[0].subarray(8),Ne=ae(Pe,["enca"]),Be=Ne.length>0;Be||(Ne=ae(Pe,["encv"])),Ne.forEach(function(Ke){ae(Be?Ke.subarray(28):Ke.subarray(78),["sinf"]).forEach(function(pe){var Ie=je(pe);if(Ie){var Ye=Ie.subarray(8,24);Ye.some(function(rt){return rt!==0})||(p.logger.log("[eme] Patching keyId in 'enc"+(Be?"a":"v")+">sinf>>tenc' box: "+w.default.hexDump(Ye)+" -> "+w.default.hexDump(ne)),Ie.set(ne,8))}})})}),ie}function je(ie){var ce=ae(ie,["schm"])[0];if(ce){var ne=de(ce.subarray(4,8));if(ne==="cbcs"||ne==="cenc")return ae(ie,["schi","tenc"])[0]}return p.logger.error("[eme] missing 'schm' box"),null}function V(ie,ce){return ae(ce,["moof","traf"]).reduce(function(ne,xe){var Pe=ae(xe,["tfdt"])[0],Ne=Pe[0],Be=ae(xe,["tfhd"]).reduce(function(Ke,pe){var Ie=K(pe,4),Ye=ie[Ie];if(Ye){var rt=K(Pe,4);Ne===1&&(rt*=Math.pow(2,32),rt+=K(Pe,8));var yt=rt/(Ye.timescale||9e4);if(isFinite(yt)&&(Ke===null||yt<Ke))return yt}return Ke},null);return Be!==null&&isFinite(Be)&&(ne===null||Be<ne)?Be:ne},null)||0}function E(ie,ce){for(var ne=0,xe=0,Pe=0,Ne=ae(ie,["moof","traf"]),Be=0;Be<Ne.length;Be++){var Ke=Ne[Be],pe=ae(Ke,["tfhd"])[0],Ie=ce[K(pe,4)];if(Ie){var Ye=Ie.default,rt=K(pe,0)|(Ye==null?void 0:Ye.flags),yt=Ye==null?void 0:Ye.duration;8&rt&&(yt=K(pe,2&rt?12:8));for(var ht=Ie.timescale||9e4,It=ae(Ke,["trun"]),Lt=0;Lt<It.length;Lt++)!(ne=U(It[Lt]))&&yt&&(ne=yt*K(It[Lt],4)),Ie.type===j.ElementaryStreamTypes.VIDEO?xe+=ne/ht:Ie.type===j.ElementaryStreamTypes.AUDIO&&(Pe+=ne/ht)}}if(xe===0&&Pe===0){for(var St=0,At=ae(ie,["sidx"]),pt=0;pt<At.length;pt++){var ut=G(At[pt]);ut!=null&&ut.references&&(St+=ut.references.reduce(function(Rt,Ct){return Rt+Ct.info.duration||0},0))}return St}return xe||Pe}function U(ie){var ce=K(ie,0),ne=8;1&ce&&(ne+=4),4&ce&&(ne+=4);for(var xe=0,Pe=K(ie,4),Ne=0;Ne<Pe;Ne++)256&ce&&(xe+=K(ie,ne),ne+=4),512&ce&&(ne+=4),1024&ce&&(ne+=4),2048&ce&&(ne+=4);return xe}function A(ie,ce,ne){ae(ce,["moof","traf"]).forEach(function(xe){ae(xe,["tfhd"]).forEach(function(Pe){var Ne=K(Pe,4),Be=ie[Ne];if(Be){var Ke=Be.timescale||9e4;ae(xe,["tfdt"]).forEach(function(pe){var Ie=pe[0],Ye=K(pe,4);if(Ie===0)Ye-=ne*Ke,$(pe,4,Ye=Math.max(Ye,0));else{Ye*=Math.pow(2,32),Ye+=K(pe,8),Ye-=ne*Ke,Ye=Math.max(Ye,0);var rt=Math.floor(Ye/(k+1)),yt=Math.floor(Ye%(k+1));$(pe,4,rt),$(pe,8,yt)}})}})})}function ue(ie){var ce={valid:null,remainder:null},ne=ae(ie,["moof"]);if(!ne)return ce;if(ne.length<2)return ce.remainder=ie,ce;var xe=ne[ne.length-1];return ce.valid=(0,te.sliceUint8)(ie,0,xe.byteOffset-8),ce.remainder=(0,te.sliceUint8)(ie,xe.byteOffset-8),ce}function Te(ie,ce){var ne=new Uint8Array(ie.length+ce.length);return ne.set(ie),ne.set(ce,ie.length),ne}function J(ie,ce){var ne=[],xe=ce.samples,Pe=ce.timescale,Ne=ce.id,Be=!1;return ae(xe,["moof"]).map(function(Ke){var pe=Ke.byteOffset-8;ae(Ke,["traf"]).map(function(Ie){var Ye=ae(Ie,["tfdt"]).map(function(rt){var yt=rt[0],ht=K(rt,4);return yt===1&&(ht*=Math.pow(2,32),ht+=K(rt,8)),ht/Pe})[0];return Ye!==void 0&&(ie=Ye),ae(Ie,["tfhd"]).map(function(rt){var yt=K(rt,4),ht=16777215&K(rt,0),It=0,Lt=(16&ht)!=0,St=0,At=(32&ht)!=0,pt=8;yt===Ne&&((1&ht)!=0&&(pt+=8),(2&ht)!=0&&(pt+=4),(8&ht)!=0&&(It=K(rt,pt),pt+=4),Lt&&(St=K(rt,pt),pt+=4),At&&(pt+=4),ce.type==="video"&&(Be=function(ut){if(!ut)return!1;var Rt=ut.indexOf("."),Ct=Rt<0?ut:ut.substring(0,Rt);return Ct==="hvc1"||Ct==="hev1"||Ct==="dvh1"||Ct==="dvhe"}(ce.codec)),ae(Ie,["trun"]).map(function(ut){var Rt=ut[0],Ct=16777215&K(ut,0),Ht=(1&Ct)!=0,Qt=0,Ut=(4&Ct)!=0,ur=(256&Ct)!=0,ee=0,F=(512&Ct)!=0,T=0,C=(1024&Ct)!=0,L=(2048&Ct)!=0,B=0,Y=K(ut,4),Q=8;Ht&&(Qt=K(ut,Q),Q+=4),Ut&&(Q+=4);for(var ge=Qt+pe,we=0;we<Y;we++){if(ur?(ee=K(ut,Q),Q+=4):ee=It,F?(T=K(ut,Q),Q+=4):T=St,C&&(Q+=4),L&&(B=Rt===0?K(ut,Q):ve(ut,Q),Q+=4),ce.type===j.ElementaryStreamTypes.VIDEO)for(var Le=0;Le<T;){var Fe=K(xe,ge);z(Be,xe[ge+=4])&&De(xe.subarray(ge,ge+Fe),Be?2:1,ie+B/Pe,ne),ge+=Fe,Le+=Fe+4}ie+=ee/Pe}}))})})}),ne}function z(ie,ce){if(ie){var ne=ce>>1&63;return ne===39||ne===40}return(31&ce)==6}function De(ie,ce,ne,xe){var Pe=Re(ie),Ne=0;Ne+=ce;for(var Be=0,Ke=0,pe=!1,Ie=0;Ne<Pe.length;){Be=0;do{if(Ne>=Pe.length)break;Be+=Ie=Pe[Ne++]}while(Ie===255);Ke=0;do{if(Ne>=Pe.length)break;Ke+=Ie=Pe[Ne++]}while(Ie===255);var Ye=Pe.length-Ne;if(!pe&&Be===4&&Ne<Pe.length){if(pe=!0,Pe[Ne++]===181){var rt=_e(Pe,Ne);if(Ne+=2,rt===49){var yt=K(Pe,Ne);if(Ne+=4,yt===1195456820){var ht=Pe[Ne++];if(ht===3){var It=Pe[Ne++],Lt=64&It,St=Lt?2+3*(31&It):0,At=new Uint8Array(St);if(Lt){At[0]=It;for(var pt=1;pt<St;pt++)At[pt]=Pe[Ne++]}xe.push({type:ht,payloadType:Be,pts:ne,bytes:At})}}}}}else if(Be===5&&Ke<Ye){if(pe=!0,Ke>16){for(var ut=[],Rt=0;Rt<16;Rt++){var Ct=Pe[Ne++].toString(16);ut.push(Ct.length==1?"0"+Ct:Ct),Rt!==3&&Rt!==5&&Rt!==7&&Rt!==9||ut.push("-")}for(var Ht=Ke-16,Qt=new Uint8Array(Ht),Ut=0;Ut<Ht;Ut++)Qt[Ut]=Pe[Ne++];xe.push({payloadType:Be,pts:ne,uuid:ut.join(""),userData:(0,R.utf8ArrayToStr)(Qt),userDataBytes:Qt})}}else if(Ke<Ye)Ne+=Ke;else if(Ke>Ye)break}}function Re(ie){for(var ce=ie.byteLength,ne=[],xe=1;xe<ce-2;)ie[xe]===0&&ie[xe+1]===0&&ie[xe+2]===3?(ne.push(xe+2),xe+=2):xe++;if(ne.length===0)return ie;var Pe=ce-ne.length,Ne=new Uint8Array(Pe),Be=0;for(xe=0;xe<Pe;Be++,xe++)Be===ne[0]&&(Be++,ne.shift()),Ne[xe]=ie[Be];return Ne}function Oe(ie){var ce=ie[0],ne="",xe="",Pe=0,Ne=0,Be=0,Ke=0,pe=0,Ie=0;if(ce===0){for(;de(ie.subarray(Ie,Ie+1))!=="\0";)ne+=de(ie.subarray(Ie,Ie+1)),Ie+=1;for(ne+=de(ie.subarray(Ie,Ie+1)),Ie+=1;de(ie.subarray(Ie,Ie+1))!=="\0";)xe+=de(ie.subarray(Ie,Ie+1)),Ie+=1;xe+=de(ie.subarray(Ie,Ie+1)),Ie+=1,Pe=K(ie,12),Ne=K(ie,16),Ke=K(ie,20),pe=K(ie,24),Ie=28}else if(ce===1){Pe=K(ie,Ie+=4);var Ye=K(ie,Ie+=4),rt=K(ie,Ie+=4);for(Ie+=4,Be=Math.pow(2,32)*Ye+rt,Number.isSafeInteger(Be)||(Be=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),Ke=K(ie,Ie),pe=K(ie,Ie+=4),Ie+=4;de(ie.subarray(Ie,Ie+1))!=="\0";)ne+=de(ie.subarray(Ie,Ie+1)),Ie+=1;for(ne+=de(ie.subarray(Ie,Ie+1)),Ie+=1;de(ie.subarray(Ie,Ie+1))!=="\0";)xe+=de(ie.subarray(Ie,Ie+1)),Ie+=1;xe+=de(ie.subarray(Ie,Ie+1)),Ie+=1}return{schemeIdUri:ne,value:xe,timeScale:Pe,presentationTime:Be,presentationTimeDelta:Ne,eventDuration:Ke,id:pe,payload:ie.subarray(Ie,ie.byteLength)}}function ye(ie){for(var ce=arguments.length,ne=new Array(ce>1?ce-1:0),xe=1;xe<ce;xe++)ne[xe-1]=arguments[xe];for(var Pe=ne.length,Ne=8,Be=Pe;Be--;)Ne+=ne[Be].byteLength;var Ke=new Uint8Array(Ne);for(Ke[0]=Ne>>24&255,Ke[1]=Ne>>16&255,Ke[2]=Ne>>8&255,Ke[3]=255&Ne,Ke.set(ie,4),Be=0,Ne=8;Be<Pe;Be++)Ke.set(ne[Be],Ne),Ne+=ne[Be].byteLength;return Ke}function qe(ie,ce,ne){if(ie.byteLength!==16)throw new RangeError("Invalid system id");var xe,Pe,Ne;if(ce){xe=1,Pe=new Uint8Array(16*ce.length);for(var Be=0;Be<ce.length;Be++){var Ke=ce[Be];if(Ke.byteLength!==16)throw new RangeError("Invalid key");Pe.set(Ke,16*Be)}}else xe=0,Pe=new Uint8Array;xe>0?(Ne=new Uint8Array(4),ce.length>0&&new DataView(Ne.buffer).setUint32(0,ce.length,!1)):Ne=new Uint8Array;var pe=new Uint8Array(4);return ne&&ne.byteLength>0&&new DataView(pe.buffer).setUint32(0,ne.byteLength,!1),ye([112,115,115,104],new Uint8Array([xe,0,0,0]),ie,Ne,Pe,pe,ne||new Uint8Array)}function tt(ie){if(!(ie instanceof ArrayBuffer)||ie.byteLength<32)return null;var ce={version:0,systemId:"",kids:null,data:null},ne=new DataView(ie),xe=ne.getUint32(0);if(ie.byteLength!==xe&&xe>44||ne.getUint32(4)!==1886614376||(ce.version=ne.getUint32(8)>>>24,ce.version>1))return null;ce.systemId=w.default.hexDump(new Uint8Array(ie,12,16));var Pe=ne.getUint32(28);if(ce.version===0){if(xe-32<Pe)return null;ce.data=new Uint8Array(ie,32,Pe)}else if(ce.version===1){ce.kids=[];for(var Ne=0;Ne<Pe;Ne++)ce.kids.push(new Uint8Array(ie,32+16*Ne,16))}return ce}},673:(se,X,M)=>{"use strict";function j(w,k,me,re){me===void 0&&(me=1),re===void 0&&(re=!1);var de=w*k*me;return re?Math.round(de):de}function te(w,k,me,re){return me===void 0&&(me=1),re===void 0&&(re=!1),j(w,k,1/me,re)}function R(w,k){return k===void 0&&(k=!1),j(w,1e3,11111111111111112e-21,k)}function p(w,k){return k===void 0&&(k=1),j(w,9e4,1/k)}M.r(X),M.d(X,{toMpegTsClockFromTimescale:()=>p,toMsFromMpegTsClock:()=>R,toTimescaleFromBase:()=>j,toTimescaleFromScale:()=>te})},145:(se,X,M)=>{"use strict";function j(te,R,p){return Uint8Array.prototype.slice?te.slice(R,p):new Uint8Array(Array.prototype.slice.call(te,R,p))}M.r(X),M.d(X,{sliceUint8:()=>j})},729:se=>{"use strict";var X=Object.prototype.hasOwnProperty,M="~";function j(){}function te(k,me,re){this.fn=k,this.context=me,this.once=re||!1}function R(k,me,re,de,_e){if(typeof re!="function")throw new TypeError("The listener must be a function");var K=new te(re,de||k,_e),ve=M?M+me:me;return k._events[ve]?k._events[ve].fn?k._events[ve]=[k._events[ve],K]:k._events[ve].push(K):(k._events[ve]=K,k._eventsCount++),k}function p(k,me){--k._eventsCount==0?k._events=new j:delete k._events[me]}function w(){this._events=new j,this._eventsCount=0}Object.create&&(j.prototype=Object.create(null),new j().__proto__||(M=!1)),w.prototype.eventNames=function(){var k,me,re=[];if(this._eventsCount===0)return re;for(me in k=this._events)X.call(k,me)&&re.push(M?me.slice(1):me);return Object.getOwnPropertySymbols?re.concat(Object.getOwnPropertySymbols(k)):re},w.prototype.listeners=function(k){var me=M?M+k:k,re=this._events[me];if(!re)return[];if(re.fn)return[re.fn];for(var de=0,_e=re.length,K=new Array(_e);de<_e;de++)K[de]=re[de].fn;return K},w.prototype.listenerCount=function(k){var me=M?M+k:k,re=this._events[me];return re?re.fn?1:re.length:0},w.prototype.emit=function(k,me,re,de,_e,K){var ve=M?M+k:k;if(!this._events[ve])return!1;var $,ae,G=this._events[ve],Se=arguments.length;if(G.fn){switch(G.once&&this.removeListener(k,G.fn,void 0,!0),Se){case 1:return G.fn.call(G.context),!0;case 2:return G.fn.call(G.context,me),!0;case 3:return G.fn.call(G.context,me,re),!0;case 4:return G.fn.call(G.context,me,re,de),!0;case 5:return G.fn.call(G.context,me,re,de,_e),!0;case 6:return G.fn.call(G.context,me,re,de,_e,K),!0}for(ae=1,$=new Array(Se-1);ae<Se;ae++)$[ae-1]=arguments[ae];G.fn.apply(G.context,$)}else{var ke,je=G.length;for(ae=0;ae<je;ae++)switch(G[ae].once&&this.removeListener(k,G[ae].fn,void 0,!0),Se){case 1:G[ae].fn.call(G[ae].context);break;case 2:G[ae].fn.call(G[ae].context,me);break;case 3:G[ae].fn.call(G[ae].context,me,re);break;case 4:G[ae].fn.call(G[ae].context,me,re,de);break;default:if(!$)for(ke=1,$=new Array(Se-1);ke<Se;ke++)$[ke-1]=arguments[ke];G[ae].fn.apply(G[ae].context,$)}}return!0},w.prototype.on=function(k,me,re){return R(this,k,me,re,!1)},w.prototype.once=function(k,me,re){return R(this,k,me,re,!0)},w.prototype.removeListener=function(k,me,re,de){var _e=M?M+k:k;if(!this._events[_e])return this;if(!me)return p(this,_e),this;var K=this._events[_e];if(K.fn)K.fn!==me||de&&!K.once||re&&K.context!==re||p(this,_e);else{for(var ve=0,$=[],ae=K.length;ve<ae;ve++)(K[ve].fn!==me||de&&!K[ve].once||re&&K[ve].context!==re)&&$.push(K[ve]);$.length?this._events[_e]=$.length===1?$[0]:$:p(this,_e)}return this},w.prototype.removeAllListeners=function(k){var me;return k?(me=M?M+k:k,this._events[me]&&p(this,me)):(this._events=new j,this._eventsCount=0),this},w.prototype.off=w.prototype.removeListener,w.prototype.addListener=w.prototype.on,w.prefixed=M,w.EventEmitter=w,se.exports=w},945:function(se){var X,M,j,te,R;X=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,M=/^(?=([^\/?#]*))\1([^]*)$/,j=/(?:\/|^)\.(?=\/)/g,te=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,R={buildAbsoluteURL:function(p,w,k){if(k=k||{},p=p.trim(),!(w=w.trim())){if(!k.alwaysNormalize)return p;var me=R.parseURL(p);if(!me)throw new Error("Error trying to parse base URL.");return me.path=R.normalizePath(me.path),R.buildURLFromParts(me)}var re=R.parseURL(w);if(!re)throw new Error("Error trying to parse relative URL.");if(re.scheme)return k.alwaysNormalize?(re.path=R.normalizePath(re.path),R.buildURLFromParts(re)):w;var de=R.parseURL(p);if(!de)throw new Error("Error trying to parse base URL.");if(!de.netLoc&&de.path&&de.path[0]!=="/"){var _e=M.exec(de.path);de.netLoc=_e[1],de.path=_e[2]}de.netLoc&&!de.path&&(de.path="/");var K={scheme:de.scheme,netLoc:re.netLoc,path:null,params:re.params,query:re.query,fragment:re.fragment};if(!re.netLoc&&(K.netLoc=de.netLoc,re.path[0]!=="/"))if(re.path){var ve=de.path,$=ve.substring(0,ve.lastIndexOf("/")+1)+re.path;K.path=R.normalizePath($)}else K.path=de.path,re.params||(K.params=de.params,re.query||(K.query=de.query));return K.path===null&&(K.path=k.alwaysNormalize?R.normalizePath(re.path):re.path),R.buildURLFromParts(K)},parseURL:function(p){var w=X.exec(p);return w?{scheme:w[1]||"",netLoc:w[2]||"",path:w[3]||"",params:w[4]||"",query:w[5]||"",fragment:w[6]||""}:null},normalizePath:function(p){for(p=p.split("").reverse().join("").replace(j,"");p.length!==(p=p.replace(te,"")).length;);return p.split("").reverse().join("")},buildURLFromParts:function(p){return p.scheme+p.netLoc+p.path+p.params+p.query+p.fragment}},se.exports=R}},W={};function x(se){var X=W[se];if(X!==void 0)return X.exports;var M=W[se]={exports:{}};return N[se].call(M.exports,M,M.exports,x),M.exports}x.m=N,x.n=se=>{var X=se&&se.__esModule?()=>se.default:()=>se;return x.d(X,{a:X}),X},x.d=(se,X)=>{for(var M in X)x.o(X,M)&&!x.o(se,M)&&Object.defineProperty(se,M,{enumerable:!0,get:X[M]})},x.o=(se,X)=>Object.prototype.hasOwnProperty.call(se,X),x.r=se=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(se,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(se,"__esModule",{value:!0})};var fe=x(76);return fe.default})())});var Ti=class{addEventListener(){}removeEventListener(){}dispatchEvent(W){return!0}};if(typeof DocumentFragment=="undefined"){class N extends Ti{}globalThis.DocumentFragment=N}var ji=class extends Ti{},Hn=class extends Ti{},Ts={get(N){},define(N,W,x){},upgrade(N){},whenDefined(N){return Promise.resolve(ji)}},Gi,qn=class{constructor(W,x={}){Lr(this,Gi,void 0);Rr(this,Gi,x==null?void 0:x.detail)}get detail(){return pr(this,Gi)}initCustomEvent(){}};Gi=new WeakMap;function bs(N,W){return new ji}var Sa={document:{createElement:bs},DocumentFragment,customElements:Ts,CustomEvent:qn,EventTarget:Ti,HTMLElement:ji,HTMLVideoElement:Hn},Aa=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Pr=Aa?Sa:globalThis,Vn=Aa?Sa.document:globalThis.document;var fn=_a(ka(),1),Oa=_a(wa(),1),_s=Oa.default,Tr=_s,Hi=class extends Error{constructor(N,W=Hi.MEDIA_ERR_CUSTOM,x){var fe;super(N),this.name="MediaError",this.code=W,this.fatal=x!=null?x:W>=Hi.MEDIA_ERR_NETWORK&&W<=Hi.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(fe=Hi.defaultMessages[this.code])!=null?fe:"")}},mr=Hi;mr.MEDIA_ERR_ABORTED=1,mr.MEDIA_ERR_NETWORK=2,mr.MEDIA_ERR_DECODE=3,mr.MEDIA_ERR_SRC_NOT_SUPPORTED=4,mr.MEDIA_ERR_ENCRYPTED=5,mr.MEDIA_ERR_CUSTOM=100,mr.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 Ss=N=>N==null,Pa=(N,W)=>Ss(W)?!1:N in W,zn={ANY:"any",MUTED:"muted"},hn={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},ai={MSE:"mse",NATIVE:"native"},Qn={HEADER:"header",QUERY:"query",NONE:"none"},ro=Object.values(Qn),bi={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Jn={HLS:bi.M3U8},io=Object.keys(Jn),no=[...Object.values(bi),"hls","HLS"],ni=(N,W,x,fe,se=N)=>{se.addEventListener(W,x,fe),N.addEventListener("teardown",()=>{se.removeEventListener(W,x)},{once:!0})};function As(N,W,x){W&&x>W&&(x=W);for(let fe=0;fe<N.length;fe++)if(N.start(fe)<=x&&N.end(fe)>=x)return!0;return!1}var ks=N=>{let W=N.indexOf("?");if(W<0)return[N];let x=N.slice(0,W),fe=N.slice(W);return[x,fe]},xa=N=>{let W=N.type;if(W){let fe=W.toUpperCase();return Pa(fe,Jn)?Jn[fe]:W}let{src:x}=N;return x?ws(x):""},ws=N=>{let W="";try{W=new URL(N).pathname}catch{console.error("invalid url")}let x=W.lastIndexOf(".");if(x<0)return"";let fe=W.slice(x+1).toUpperCase();return Pa(fe,bi)?bi[fe]:""},Ds=Object.values(zn),Da=N=>typeof N=="boolean"||typeof N=="string"&&Ds.includes(N),Ls=({autoplay:N},W,x)=>{let fe=!1,se=!1,X=Da(N)?N:!!N,M=()=>{fe||ni(W,"playing",()=>{fe=!0},{once:!0})};if(M(),ni(W,"loadstart",()=>{fe=!1,M(),Xn(W,X)},{once:!0}),ni(W,"loadstart",()=>{x||(se=!Number.isFinite(W.duration)),Xn(W,X)},{once:!0}),x&&x.once(Tr.Events.LEVEL_LOADED,(j,te)=>{var R;se=(R=te.details.live)!=null?R:!1}),!X){let j=()=>{!se||(x!=null&&x.liveSyncPosition?W.currentTime=x.liveSyncPosition:Number.isFinite(W.seekable.end(0))&&(W.currentTime=W.seekable.end(0)))};x&&ni(W,"play",()=>{W.preload==="metadata"?x.once(Tr.Events.LEVEL_UPDATED,j):j()},{once:!0})}return j=>{fe||(X=Da(j)?j:!!j,Xn(W,X))}},Xn=(N,W)=>{if(!W)return;let x=N.muted,fe=()=>N.muted=x;switch(W){case zn.ANY:N.play().catch(()=>{N.muted=!0,N.play().catch(fe)});break;case zn.MUTED:N.muted=!0,N.play().catch(fe);break;default:N.play().catch(()=>{});break}},Rs=({preload:N,src:W},x,fe)=>{let se=w=>{w!=null&&["","none","metadata","auto"].includes(w)?x.setAttribute("preload",w):x.removeAttribute("preload")};if(!fe)return se(N),se;let X=!1,M=!1,j=fe.config.maxBufferLength,te=fe.config.maxBufferSize,R=w=>{se(w);let k=w!=null?w:x.preload;M||k==="none"||(k==="metadata"?(fe.config.maxBufferLength=1,fe.config.maxBufferSize=1):(fe.config.maxBufferLength=j,fe.config.maxBufferSize=te),p())},p=()=>{!X&&W&&(X=!0,fe.loadSource(W))};return ni(x,"play",()=>{M=!0,fe.config.maxBufferLength=j,fe.config.maxBufferSize=te,p()},{once:!0}),R(N),R};function Is(N,W){W.on(Tr.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(se,{tracks:X})=>{X.forEach(M=>{var j;let te=(j=M.subtitleTrack)!=null?j:M.closedCaptions,R=W.subtitleTracks.findIndex(({lang:p,name:w,type:k})=>p==(te==null?void 0:te.lang)&&w===M.label&&k.toLowerCase()===M.kind);Fa(N,M.kind,M.label,te==null?void 0:te.lang,`${M.kind}${R}`)})});let x=()=>{var se;if(!W.subtitleTracks.length)return;let X=Array.from(N.textTracks).find(j=>j.id&&j.mode==="showing"&&["subtitles","captions"].includes(j.kind)),M=`${(se=W.subtitleTracks[W.subtitleTrack])==null?void 0:se.type.toLowerCase()}${W.subtitleTrack}`;if(X&&(W.subtitleTrack<0||(X==null?void 0:X.id)!==M)){let j=W.subtitleTracks.findIndex(({lang:te,name:R,type:p})=>te==X.language&&R===X.label&&p.toLowerCase()===X.kind);W.subtitleTrack=j}X&&(X==null?void 0:X.id)===M&&X.cues&&Array.from(X.cues).forEach(j=>{X.addCue(j)})};N.textTracks.addEventListener("change",x),W.on(Tr.Events.CUES_PARSED,(se,{track:X,cues:M})=>{let j=N.textTracks.getTrackById(X);if(!j)return;let te=j.mode==="disabled";te&&(j.mode="hidden"),M.forEach(R=>{var p;(p=j.cues)!=null&&p.getCueById(R.id)||j.addCue(R)}),te&&(j.mode="disabled")}),W.once(Tr.Events.DESTROYING,()=>{N.textTracks.removeEventListener("change",x),N.querySelectorAll("track[data-removeondestroy]").forEach(se=>{se.remove()})});let fe=()=>{Array.from(N.textTracks).forEach(se=>{var X,M;if(!["subtitles","caption"].includes(se.kind)&&se.label==="thumbnails"){if(!((X=se.cues)!=null&&X.length)){let j=N.querySelector('track[label="thumbnails"]'),te=(M=j==null?void 0:j.getAttribute("src"))!=null?M:"";j==null||j.removeAttribute("src"),setTimeout(()=>{j==null||j.setAttribute("src",te)},0)}se.mode!=="hidden"&&(se.mode="hidden")}})};W.once(Tr.Events.MANIFEST_LOADED,fe),W.once(Tr.Events.MEDIA_ATTACHED,fe)}function Fa(N,W,x,fe,se){let X=document.createElement("track");return X.kind=W,X.label=x,fe&&(X.srclang=fe),se&&(X.id=se),X.track.mode=["subtitles","captions"].includes(W)?"disabled":"hidden",X.setAttribute("data-removeondestroy",""),N.append(X),X.track}var vn="cuepoints",Zn=Object.freeze({label:vn}),Ma=(N,{label:W=vn}=Zn)=>{var x;return(x=Array.from(N.querySelectorAll("track")).find(fe=>fe.track.label===W&&fe.track.kind==="metadata"))==null?void 0:x.track};async function Cs(N,W,x=Zn){let fe=Ma(N,x);if(!fe){let{label:se=vn}=x;fe=Fa(N,"metadata",se),fe.mode="hidden",await new Promise(X=>setTimeout(()=>X(void 0),0))}return fe.mode!=="hidden"&&(fe.mode="hidden"),[...W].sort(({time:se},{time:X})=>X-se).forEach(({time:se,value:X})=>{var M,j;let te=Array.prototype.findIndex.call(fe==null?void 0:fe.cues,me=>me.startTime>=se),R=(M=fe==null?void 0:fe.cues)==null?void 0:M[te],p=R?R.startTime:Number.isFinite(N.duration)?N.duration:Number.MAX_SAFE_INTEGER,w=(j=fe==null?void 0:fe.cues)==null?void 0:j[te-1];w&&(w.endTime=se);let k=new VTTCue(se,p,JSON.stringify(X!=null?X:null));fe.addCue(k)}),fe}var Os=N=>({time:N.startTime,value:JSON.parse(N.text)});function Ps(N,W={label:vn}){var x;let fe=Ma(N,W);if((x=fe==null?void 0:fe.activeCues)!=null&&x.length)return Os(fe.activeCues[0])}async function xs(N,W=Zn){return new Promise(x=>{ni(N,"loadstart",async()=>{let fe=await Cs(N,[],W);ni(N,"cuechange",()=>{let se=Ps(N);if(se){let X=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:se});N.dispatchEvent(X)}},{},fe),x(fe)})})}var La,Ra,Fs=(Ra=(La=globalThis==null?void 0:globalThis.navigator)==null?void 0:La.userAgent)!=null?Ra:"",Ms=Fs.toLowerCase().indexOf("android")!==-1,qi=new WeakMap,Na="mux.com",Ia,Ca,Ua=(Ca=(Ia=Tr).isSupported)==null?void 0:Ca.call(Ia),Ns=Ms,Ba=()=>fn.default.utils.now(),Us=fn.default.utils.generateUUID,ja=(N,{domain:W=Na,maxResolution:x=""}={})=>{if(!N)return;let[fe,se=""]=ks(N),X=new URL(`https://stream.${W}/${fe}.m3u8${se}`);return x&&X.searchParams.set("max_resolution",x),X.toString()},Bs=N=>{if(!N)return;let[W]=N.split("?");return W||void 0},js=N=>{if(!N||!N.startsWith("https://stream."))return;let[W]=new URL(N).pathname.slice(1).split(".m3u8");return W||void 0},Gs=N=>{var W,x,fe;return(W=N==null?void 0:N.metadata)!=null&&W.video_id?N.metadata.video_id:Ha(N)&&(fe=(x=Bs(N.playbackId))!=null?x:js(N.src))!=null?fe:N.src};var Ga=(N,W,x)=>{ea(W,x);let{metadata:fe={}}=N,{view_session_id:se=Us()}=fe,X=Gs(N);fe.view_session_id=se,fe.video_id=X,N.metadata=fe,qi.set(W,{});let M=Ks(N,W);qs(N,W,M),Vs(N,W,M),xs(W);let j=Ls(N,W,M),te=Rs(N,W,M);return{engine:M,setAutoplay:j,setPreload:te}},ea=(N,W)=>{let x=W==null?void 0:W.engine;x&&(x.detachMedia(),x.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",Va),N.removeEventListener("error",$n),N.removeEventListener("durationchange",qa),qi.delete(N),N.dispatchEvent(new Event("teardown")))};function Ka(N,W){var x;let fe=xa(N);if(fe!==bi.M3U8)return!0;let se=!fe||((x=W.canPlayType(fe))!=null?x:!0),{preferPlayback:X}=N,M=X===ai.MSE,j=X===ai.NATIVE;return se&&(j||!(Ua&&(M||Ns)))}var Ks=(N,W)=>{let{debug:x,streamType:fe,startTime:se=-1,metadata:X,preferCmcd:M}=N,j=xa(N)===bi.M3U8,te=Ka(N,W);if(j&&!te&&Ua){let R={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},p=Hs(fe),w=M!==Qn.NONE?{useHeaders:M===Qn.HEADER,sessionId:X.view_session_id,contentId:X.video_id}:void 0;return new Tr({debug:x,startPosition:se,cmcd:w,...R,...p})}},Hs=N=>[hn.LIVE,hn.DVR].includes(N)?{backBufferLength:8}:[hn.LL_LIVE,hn.LL_DVR].includes(N)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Ha=({playbackId:N,src:W,customDomain:x})=>{if(N)return!0;if(typeof W!="string")return!1;let fe=window==null?void 0:window.location.href,se=new URL(W,fe).hostname.toLocaleLowerCase();return se.includes(Na)||!!x&&se.includes(x.toLocaleLowerCase())},qs=(N,W,x)=>{var fe;let{envKey:se}=N,X=Ha(N);if(se||X){let{playerInitTime:M,playerSoftwareName:j,playerSoftwareVersion:te,beaconCollectionDomain:R,debug:p,disableCookies:w}=N,k={...N.metadata,video_title:((fe=N==null?void 0:N.metadata)==null?void 0:fe.video_title)||void 0},me=re=>typeof re.player_error_code=="string"?!1:typeof N.errorTranslator=="function"?N.errorTranslator(re):re;fn.default.monitor(W,{debug:p,beaconCollectionDomain:R,hlsjs:x,Hls:x?Tr:void 0,automaticErrorTracking:!1,errorTranslator:me,disableCookies:w,data:{...se?{env_key:se}:{},player_software_name:j,player_software:j,player_software_version:te,player_init_time:M,...k}})}},Vs=(N,W,x)=>{var fe;let se=Ka(N,W),{src:X}=N;W&&se?(typeof X=="string"?(W.setAttribute("src",X),N.startTime&&(((fe=qi.get(W))!=null?fe:{}).startTime=N.startTime,W.addEventListener("durationchange",qa,{once:!0}))):W.removeAttribute("src"),W.addEventListener("error",Va),W.addEventListener("error",$n),W.addEventListener("emptied",()=>{W.querySelectorAll("track[data-removeondestroy]").forEach(M=>{M.remove()})},{once:!0})):x&&X?(x.on(Tr.Events.ERROR,(M,j)=>{let te={[Tr.ErrorTypes.NETWORK_ERROR]:mr.MEDIA_ERR_NETWORK,[Tr.ErrorTypes.MEDIA_ERROR]:mr.MEDIA_ERR_DECODE},R=new mr("",te[j.type]);R.fatal=j.fatal,R.data=j,W.dispatchEvent(new CustomEvent("error",{detail:R}))}),W.addEventListener("error",$n),Is(W,x),x.attachMedia(W)):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 qa(N){var W;let x=N.target,fe=(W=qi.get(x))==null?void 0:W.startTime;if(!!fe&&As(x.seekable,x.duration,fe)){let se=x.preload==="auto";se&&(x.preload="none"),x.currentTime=fe,se&&(x.preload="auto")}}async function Va(N){if(!N.isTrusted)return;N.stopImmediatePropagation();let W=N.target;if(!(W!=null&&W.error))return;let{message:x,code:fe}=W.error,se=new mr(x,fe);if(W.src&&(fe!==mr.MEDIA_ERR_DECODE||fe!==void 0))try{let{status:X}=await fetch(W.src);se.data={response:{code:X}}}catch{}W.dispatchEvent(new CustomEvent("error",{detail:se}))}function $n(N){var W,x;if(!(N instanceof CustomEvent)||!(N.detail instanceof mr))return;let fe=N.target,se=N.detail;!se||!se.fatal||(((W=qi.get(fe))!=null?W:{}).error=se,(x=fe.mux)==null||x.emit("error",{player_error_code:se.code,player_error_message:se.message}))}var Ys=()=>{try{return"0.9.5"}catch{}return"UNKNOWN"},Ws=Ys(),Ya=()=>Ws;var Wa=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],Xa=Vn.createElement("template");Xa.innerHTML=`
|
|
42
|
+
`),h=[],v=(o=n.baseTime,(l=n.timescale)===void 0&&(l=1),oa(o,9e4,1/l)),y="00:00.000",T=0,A=0,p=!0;u.oncue=function(_){var L=e[t],w=e.ccOffset,x=(T-v)/9e4;L!=null&&L.new&&(A!==void 0?w=e.ccOffset=L.start:function(q,V,Z){var X=q[V],ie=q[X.prevCC];if(!ie||!ie.new&&X.new)return q.ccOffset=q.presentationOffset=X.start,void(X.new=!1);for(;(ye=ie)!=null&&ye.new;){var ye;q.ccOffset+=X.start-ie.start,X.new=!1,ie=q[(X=ie).prevCC]}q.presentationOffset=Z}(e,t,x)),x&&(w=x-e.presentationOffset);var F=_.endTime-_.startTime,G=Dt(9e4*(_.startTime+w-A),9e4*r)/9e4;_.startTime=Math.max(G,0),_.endTime=Math.max(G+F,0);var W=_.text.trim();_.text=decodeURIComponent(encodeURIComponent(W)),_.id||(_.id=ba(_.startTime,_.endTime,W)),_.endTime>0&&h.push(_)},u.onparsingerror=function(_){d=_},u.onflush=function(){d?a(d):i(h)},c.forEach(function(_){if(p){if(Ea(_,"X-TIMESTAMP-MAP=")){p=!1,_.slice(16).split(",").forEach(function(L){Ea(L,"LOCAL:")?y=L.slice(6):Ea(L,"MPEGTS:")&&(T=parseInt(L.slice(7)))});try{A=function(L){var w=parseInt(L.slice(-3)),x=parseInt(L.slice(-6,-4)),F=parseInt(L.slice(-9,-7)),G=L.length>9?parseInt(L.substring(0,L.indexOf(":"))):0;if(!(Q(w)&&Q(x)&&Q(F)&&Q(G)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+L);return w+=1e3*x,(w+=6e4*F)+36e5*G}(y)/1e3}catch(L){d=L}return}_===""&&(p=!1)}u.parse(_+`
|
|
43
|
+
`)}),u.flush()}var Sa="stpp.ttml.im1t",As=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,ks=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,dl={left:"start",center:"center",right:"end",start:"start",end:"end"};function Rs(s,n,e,t){var r=Ce(new Uint8Array(s),["mdat"]);if(r.length!==0){var i,a,o,l,d=r.map(function(c){return Tt(c)}),u=(i=n.baseTime,a=1,(o=n.timescale)===void 0&&(o=1),l===void 0&&(l=!1),oa(i,a,1/o,l));try{d.forEach(function(c){return e(function(h,v){var y=new DOMParser().parseFromString(h,"text/xml").getElementsByTagName("tt")[0];if(!y)throw new Error("Invalid ttml");var T={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},A=Object.keys(T).reduce(function(x,F){return x[F]=y.getAttribute("ttp:"+F)||T[F],x},{}),p=y.getAttribute("xml:space")!=="preserve",_=Ls(Aa(y,"styling","style")),L=Ls(Aa(y,"layout","region")),w=Aa(y,"body","[begin]");return[].map.call(w,function(x){var F=ws(x,p);if(!F||!x.hasAttribute("begin"))return null;var G=Ra(x.getAttribute("begin"),A),W=Ra(x.getAttribute("dur"),A),q=Ra(x.getAttribute("end"),A);if(G===null)throw Ds(x);if(q===null){if(W===null)throw Ds(x);q=G+W}var V=new ya(G-v,q-v,F);V.id=ba(V.startTime,V.endTime,V.text);var Z=function(ye,ae,pe){var oe="http://www.w3.org/ns/ttml#styling",me=null,Ae=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],Ie=ye!=null&&ye.hasAttribute("style")?ye.getAttribute("style"):null;return Ie&&pe.hasOwnProperty(Ie)&&(me=pe[Ie]),Ae.reduce(function(Re,Ue){var mt=ka(ae,oe,Ue)||ka(ye,oe,Ue)||ka(me,oe,Ue);return mt&&(Re[Ue]=mt),Re},{})}(L[x.getAttribute("region")],_[x.getAttribute("style")],_),X=Z.textAlign;if(X){var ie=dl[X];ie&&(V.lineAlign=ie),V.align=X}return z(V,Z),V}).filter(function(x){return x!==null})}(c,u))})}catch(c){t(c)}}else t(new Error("Could not parse IMSC1 mdat"))}function Aa(s,n,e){var t=s.getElementsByTagName(n)[0];return t?[].slice.call(t.querySelectorAll(e)):[]}function Ls(s){return s.reduce(function(n,e){var t=e.getAttribute("xml:id");return t&&(n[t]=e),n},{})}function ws(s,n){return[].slice.call(s.childNodes).reduce(function(e,t,r){var i;return t.nodeName==="br"&&r?e+`
|
|
44
|
+
`:(i=t.childNodes)!=null&&i.length?ws(t,n):n?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function ka(s,n,e){return s&&s.hasAttributeNS(n,e)?s.getAttributeNS(n,e):null}function Ds(s){return new Error("Could not parse ttml timestamp "+s)}function Ra(s,n){if(!s)return null;var e=_s(s);return e===null&&(As.test(s)?e=function(t,r){var i=As.exec(t),a=(0|i[4])+(0|i[5])/r.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+a/r.frameRate}(s,n):ks.test(s)&&(e=function(t,r){var i=ks.exec(t),a=Number(i[1]);switch(i[2]){case"h":return 3600*a;case"m":return 60*a;case"ms":return 1e3*a;case"f":return a/r.frameRate;case"t":return a/r.tickRate}return a}(s,n))),e}var cl=function(){function s(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 Dn(this,"textTrack1"),r=new Dn(this,"textTrack2"),i=new Dn(this,"textTrack3"),a=new Dn(this,"textTrack4");this.cea608Parser1=new Ts(1,t,r),this.cea608Parser2=new Ts(3,i,a)}e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}var n=s.prototype;return n.destroy=function(){var e=this.hls;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},n.addCues=function(e,t,r,i,a){for(var o,l,d,u,c=!1,h=a.length;h--;){var v=a[h],y=(o=v[0],l=v[1],d=t,u=r,Math.min(l,u)-Math.max(o,d));if(y>=0&&(v[0]=Math.min(v[0],t),v[1]=Math.max(v[1],r),c=!0,y/(r-t)>.5))return}if(c||a.push([t,r]),this.config.renderTextTracksNatively){var T=this.captionsTracks[e];this.Cues.newCue(T,t,r,i)}else{var A=this.Cues.newCue(null,t,r,i);this.hls.trigger(E.CUES_PARSED,{type:"captions",cues:A,track:e})}},n.onInitPtsFound=function(e,t){var r=this,i=t.frag,a=t.id,o=t.initPTS,l=t.timescale,d=this.unparsedVttFrags;a==="main"&&(this.initPTS[i.cc]={baseTime:o,timescale:l}),d.length&&(this.unparsedVttFrags=[],d.forEach(function(u){r.onFragLoaded(E.FRAG_LOADED,u)}))},n.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e])return i}return null},n.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},n.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,i=this.media,a=t[e],o=a.label,l=a.languageCode,d=this.getExistingTrack(e);if(d)r[e]=d,sr(r[e]),Br(r[e],i);else{var u=this.createTextTrack("captions",o,l);u&&(u[e]=!0,r[e]=u)}}},n.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},n.createTextTrack=function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)},n.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},n.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){sr(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}},n.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())},n._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)sr(t[r])}},n.onSubtitleTracksUpdated=function(e,t){var r=this;this.textTracks=[];var i=t.subtitleTracks||[],a=i.some(function(u){return u.textCodec===Sa});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var o=this.tracks&&i&&this.tracks.length===i.length;if(this.tracks=i||[],this.config.renderTextTracksNatively){var l=this.media?this.media.textTracks:[];this.tracks.forEach(function(u,c){var h;if(c<l.length){for(var v=null,y=0;y<l.length;y++)if(hl(l[y],u)){v=l[y];break}v&&(h=v)}if(h)sr(h);else{var T=r._captionsOrSubtitlesFromCharacteristics(u);(h=r.createTextTrack(T,u.name,u.lang))&&(h.mode="disabled")}h&&(h.groupId=u.groupId,r.textTracks.push(h))})}else if(!o&&this.tracks&&this.tracks.length){var d=this.tracks.map(function(u){return{label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}});this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:d})}}},n._captionsOrSubtitlesFromCharacteristics=function(e){var t;if((t=e.attrs)!=null&&t.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(r&&i)return"captions"}return"subtitles"},n.onManifestLoaded=function(e,t){var r=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(function(i){var a=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(a){var o="textTrack"+a[1],l=r.captionsProperties[o];l&&(l.label=i.name,i.lang&&(l.languageCode=i.lang),l.media=i)}})},n.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]},n.onFragLoading=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2,a=this.lastSn,o=this.lastPartIndex;if(this.enabled&&r&&i&&t.frag.type===Ne){var l,d,u=t.frag.sn,c=(l=t==null||(d=t.part)==null?void 0:d.index)!=null?l:-1;u===a+1||u===a&&c===o+1||(r.reset(),i.reset()),this.lastSn=u,this.lastPartIndex=c}},n.onFragLoaded=function(e,t){var r=t.frag,i=t.payload,a=this.initPTS,o=this.unparsedVttFrags;if(r.type===Nt)if(i.byteLength){if(!a[r.cc])return o.push(t),void(a.length&&this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var l=r.decryptdata,d="stats"in t;if(l==null||!l.encrypted||d){var u=this.tracks[r.level],c=this.vttCCs;c[r.cc]||(c[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),u&&u.textCodec===Sa?this._parseIMSC1(r,i):this._parseVTTs(r,i,c)}}else this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},n._parseIMSC1=function(e,t){var r=this,i=this.hls;Rs(t,this.initPTS[e.cc],function(a){r._appendCues(a,e.level),i.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(a){P.log("Failed to parse IMSC1: "+a),i.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:a})})},n._parseVTTs=function(e,t,r){var i,a=this,o=this.hls;ul((i=e.initSegment)!=null&&i.data?jt(e.initSegment.data,new Uint8Array(t)):t,this.initPTS[e.cc],r,e.cc,e.start,function(l){a._appendCues(l,e.level),o.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(l){a._fallbackToIMSC1(e,t),P.log("Failed to parse VTT cue: "+l),o.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:l})})},n._fallbackToIMSC1=function(e,t){var r=this,i=this.tracks[e.level];i.textCodec||Rs(t,this.initPTS[e.cc],function(){i.textCodec=Sa,r._parseIMSC1(e,t)},function(){i.textCodec="wvtt"})},n._appendCues=function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||i.mode==="disabled")return;e.forEach(function(l){return pn(i,l)})}else{var a=this.tracks[t];if(!a)return;var o=a.default?"default":"subtitles"+t;r.trigger(E.CUES_PARSED,{type:"subtitles",cues:e,track:o})}},n.onFragDecrypted=function(e,t){var r=t.frag;if(r.type===Nt){if(!this.initPTS[r.cc])return void this.unparsedVttFrags.push(t);this.onFragLoaded(E.FRAG_LOADED,t)}},n.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},n.onFragParsingUserdata=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i){var a=t.frag,o=t.samples;if(a.type!==Ne||this.closedCaptionsForLevel(a)!=="NONE")for(var l=0;l<o.length;l++){var d=o[l].bytes;if(d){var u=this.extractCea608Data(d);r.addData(o[l].pts,u[0]),i.addData(o[l].pts,u[1])}}}},n.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,a=t.endOffsetSubtitles,o=t.type,l=this.media;if(l&&!(l.currentTime<i)){if(!o||o==="video"){var d=this.captionsTracks;Object.keys(d).forEach(function(c){return Xe(d[c],r,i)})}if(this.config.renderTextTracksNatively&&r===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return Xe(u[c],r,a)})}}},n.extractCea608Data=function(e){for(var t=[[],[]],r=31&e[0],i=2,a=0;a<r;a++){var o=e[i++],l=127&e[i++],d=127&e[i++];if((l!==0||d!==0)&&(4&o)!=0){var u=3&o;u!==0&&u!==1||(t[u].push(l),t[u].push(d))}}return t},s}();function hl(s,n){return s&&s.label===n.name&&!(s.textTrack1||s.textTrack2)}var fl=function(){function s(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 n=s.prototype;return n.setStreamController=function(e){this.streamController=e},n.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},n.registerListeners=function(){var e=this.hls;e.on(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)},n.unregisterListener=function(){var e=this.hls;e.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this)},n.onFpsDropLevelCapping=function(e,t){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})},n.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null},n.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},n.onMediaDetaching=function(){this.stopCapping()},n.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}}},n.getMaxLevel=function(e){var t=this,r=this.hls.levels;if(!r.length)return-1;var i=r.filter(function(a,o){return t.isLevelAllowed(a)&&o<=e});return this.clientRect=null,s.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)},n.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())},n.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},n.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},n.isLevelAllowed=function(e){return!this.restrictedLevels.some(function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height})},s.getMaxLevelByMediaSize=function(e,t,r){if(e==null||!e.length)return-1;for(var i,a,o=e.length-1,l=0;l<e.length;l+=1){var d=e[l];if((d.width>=t||d.height>=r)&&(i=d,!(a=e[l+1])||i.width!==a.width||i.height!==a.height)){o=l;break}}return o},j(s,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}}]),s}(),vl=function(){function s(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 n=s.prototype;return n.setStreamController=function(e){this.streamController=e},n.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this)},n.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},n.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&typeof i.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},n.checkFPS=function(e,t,r){var i=performance.now();if(t){if(this.lastTime){var a=i-this.lastTime,o=r-this.lastDroppedFrames,l=t-this.lastDecodedFrames,d=1e3*o/a,u=this.hls;if(u.trigger(E.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),d>0&&o>u.config.fpsDroppedMonitoringThreshold*l){var c=u.currentLevel;P.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=c)&&(c-=1,u.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:u.currentLevel}),u.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},n.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)},s}(),Cn="[eme]",Is=function(){function s(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=s.CDMCleanupPromise?[s.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=P.debug.bind(P,Cn),this.log=P.log.bind(P,Cn),this.warn=P.warn.bind(P,Cn),this.error=P.error.bind(P,Cn),this.hls=e,this.config=e.config,this.registerListeners()}var n=s.prototype;return n.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},n.registerListeners=function(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)},n.unregisterListeners=function(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this)},n.getLicenseServerUrl=function(e){var t=this.config,r=t.drmSystems,i=t.widevineLicenseUrl,a=r[e];if(a)return a.licenseUrl;if(e===je.WIDEVINE&&i)return i;throw new Error('no license server URL configured for key-system "'+e+'"')},n.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},n.attemptKeySystemAccess=function(e){var t=this,r=this.hls.levels,i=function(l,d,u){return!!l&&u.indexOf(l)===d},a=r.map(function(l){return l.audioCodec}).filter(i),o=r.map(function(l){return l.videoCodec}).filter(i);return a.length+o.length===0&&o.push("avc1.42e01e"),new Promise(function(l,d){(function u(c){var h=c.shift();t.getMediaKeysPromise(h,a,o).then(function(v){return l({keySystem:h,mediaKeys:v})}).catch(function(v){c.length?u(c):d(v instanceof It?v:new It({type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_ACCESS,error:v,fatal:!0},v.message))})})(e)})},n.requestMediaKeySystemAccess=function(e,t){var r=this.config.requestMediaKeySystemAccessFunc;if(typeof r!="function"){var i="Configured requestMediaKeySystemAccess is not a function "+r;return ci===null&&self.location.protocol==="http:"&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(i))}return r(e,t)},n.getMediaKeysPromise=function(e,t,r){var i=this,a=function(u,c,h,v){var y;switch(u){case je.FAIRPLAY:y=["cenc","sinf"];break;case je.WIDEVINE:case je.PLAYREADY:y=["cenc"];break;case je.CLEARKEY:y=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+u)}return function(T,A,p,_){return[{initDataTypes:T,persistentState:_.persistentState||"not-allowed",distinctiveIdentifier:_.distinctiveIdentifier||"not-allowed",sessionTypes:_.sessionTypes||[_.sessionType||"temporary"],audioCapabilities:A.map(function(L){return{contentType:'audio/mp4; codecs="'+L+'"',robustness:_.audioRobustness||"",encryptionScheme:_.audioEncryptionScheme||null}}),videoCapabilities:p.map(function(L){return{contentType:'video/mp4; codecs="'+L+'"',robustness:_.videoRobustness||"",encryptionScheme:_.videoEncryptionScheme||null}})}]}(y,c,h,v)}(e,t,r,this.config.drmSystemOptions),o=this.keySystemAccessPromises[e],l=o==null?void 0:o.keySystemAccess;if(!l){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(a)),l=this.requestMediaKeySystemAccess(e,a);var d=this.keySystemAccessPromises[e]={keySystemAccess:l};return l.catch(function(u){i.log('Failed to obtain access to key-system "'+e+'": '+u)}),l.then(function(u){i.log('Access for key-system "'+u.keySystem+'" obtained');var c=i.fetchServerCertificate(e);return i.log('Create media-keys for "'+e+'"'),d.mediaKeys=u.createMediaKeys().then(function(h){return i.log('Media-keys created for "'+e+'"'),c.then(function(v){return v?i.setMediaKeysServerCertificate(h,e,v):h})}),d.mediaKeys.catch(function(h){i.error('Failed to create media-keys for "'+e+'"}: '+h)}),d.mediaKeys})}return l.then(function(){return o.mediaKeys})},n.createMediaKeySessionContext=function(e){var t=e.decryptdata,r=e.keySystem,i=e.mediaKeys;this.log('Creating key-system session "'+r+'" keyId: '+Et(t.keyId||[]));var a=i.createSession(),o={decryptdata:t,keySystem:r,mediaKeys:i,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o},n.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var r=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},n.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 Et(e.keyId)},n.updateKeySession=function(e,t){var r,i=e.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+Et(((r=e.decryptdata)==null?void 0:r.keyId)||[])+`
|
|
45
|
+
} (data length: `+(t&&t.byteLength)+")"),i.update(t)},n.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},n.getKeyFormatPromise=function(e){var t=this;return new Promise(function(r,i){var a=di(t.config),o=e.map(li).filter(function(l){return!!l&&a.indexOf(l)!==-1});return t.getKeySystemSelectionPromise(o).then(function(l){var d=l.keySystem,u=ui(d);u?r(u):i(new Error('Unable to find format for key-system "'+d+'"'))}).catch(i)})},n.loadKey=function(e){var t=this,r=e.keyInfo.decryptdata,i=this.getKeyIdString(r),a="(keyId: "+i+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+a);var o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(r).then(function(l){var d=l.keySystem,u=l.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+a),t.attemptSetMediaKeys(d,u).then(function(){t.throwIfDestroyed();var c=t.createMediaKeySessionContext({keySystem:d,mediaKeys:u,decryptdata:r});return t.generateRequestWithPreferredKeySession(c,"cenc",r.pssh,"playlist-key")})})).catch(function(l){return t.handleError(l)}),o},n.throwIfDestroyed=function(e){if(!this.hls)throw new Error("invalid state")},n.handleError=function(e){this.hls&&(this.error(e.message),e instanceof It?this.hls.trigger(E.ERROR,e.data):this.hls.trigger(E.ERROR,{type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},n.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){var i=li(e.keyFormat),a=i?[i]:di(this.config);return this.attemptKeySystemAccess(a)}return r},n.getKeySystemSelectionPromise=function(e){if(e.length||(e=di(this.config)),e.length===0)throw new It({type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},n._onMediaEncrypted=function(e){var t=this,r=e.initDataType,i=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+r+'"'),i!==null){var a,o;if(r==="sinf"&&this.config.drmSystems[je.FAIRPLAY]){var l=et(new Uint8Array(i));try{var d=ai(JSON.parse(l).sinf),u=pi(new Uint8Array(d));if(!u)return;a=u.subarray(8,24),o=je.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=function(L){if(!(L instanceof ArrayBuffer)||L.byteLength<32)return null;var w={version:0,systemId:"",kids:null,data:null},x=new DataView(L),F=x.getUint32(0);if(L.byteLength!==F&&F>44||x.getUint32(4)!==1886614376||(w.version=x.getUint32(8)>>>24,w.version>1))return null;w.systemId=Et(new Uint8Array(L,12,16));var G=x.getUint32(28);if(w.version===0){if(F-32<G)return null;w.data=new Uint8Array(L,32,G)}else if(w.version===1){w.kids=[];for(var W=0;W<G;W++)w.kids.push(new Uint8Array(L,32+16*W,16))}return w}(i);if(c===null)return;c.version===0&&c.systemId===Wi&&c.data&&(a=c.data.subarray(8,24)),o=function(L){if(L===Wi)return je.WIDEVINE}(c.systemId)}if(o&&a){for(var h=Et(a),v=this.keyIdToKeySessionPromise,y=this.mediaKeySessions,T=v[h],A=function(L){var w=y[L],x=w.decryptdata;if(x.pssh||!x.keyId)return"continue";var F=Et(x.keyId);return h===F||x.uri.replace(/-/g,"").indexOf(h)!==-1?(T=v[F],delete v[F],x.pssh=new Uint8Array(i),x.keyId=a,T=v[h]=T.then(function(){return t.generateRequestWithPreferredKeySession(w,r,i,"encrypted-event-key-match")}),"break"):void 0},p=0;p<y.length;p++){var _=A(p);if(_!=="continue"&&_==="break")break}T||(T=v[h]=this.getKeySystemSelectionPromise([o]).then(function(L){var w,x=L.keySystem,F=L.mediaKeys;t.throwIfDestroyed();var G=new Or("ISO-23001-7",h,(w=ui(x))!=null?w:"");return G.pssh=new Uint8Array(i),G.keyId=a,t.attemptSetMediaKeys(x,F).then(function(){t.throwIfDestroyed();var W=t.createMediaKeySessionContext({decryptdata:G,keySystem:x,mediaKeys:F});return t.generateRequestWithPreferredKeySession(W,r,i,"encrypted-event-no-match")})})),T.catch(function(L){return t.handleError(L)})}}},n._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},n.attemptSetMediaKeys=function(e,t){var r=this,i=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var a=Promise.all(i).then(function(){if(!r.media)throw new Error("Attempted to set mediaKeys without media element attached");return r.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(a),a.then(function(){r.log('Media-keys set for "'+e+'"'),i.push(a),r.setMediaKeysQueue=r.setMediaKeysQueue.filter(function(o){return i.indexOf(o)===-1})})},n.generateRequestWithPreferredKeySession=function(e,t,r,i){var a,o,l=this,d=(a=this.config.drmSystems)==null||(o=a[e.keySystem])==null?void 0:o.generateRequest;if(d)try{var u=d.call(this.hls,t,r,e);if(!u)throw new Error("Invalid response from configured generateRequest filter");t=u.initDataType,r=e.decryptdata.pssh=u.initData?new Uint8Array(u.initData):null}catch(T){var c;if(this.warn(T.message),(c=this.hls)!=null&&c.config.debug)throw T}if(r===null)return this.log('Skipping key-session request for "'+i+'" (no initData)'),Promise.resolve(e);var h=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+i+'": '+h+" (init data type: "+t+" length: "+(r?r.byteLength:null)+")");var v=new wn;e.mediaKeysSession.onmessage=function(T){var A=e.mediaKeysSession;if(A){var p=T.messageType,_=T.message;l.log('"'+p+'" message event for session "'+A.sessionId+'" message size: '+_.byteLength),p==="license-request"||p==="license-renewal"?l.renewLicense(e,_).catch(function(L){l.handleError(L),v.emit("error",L)}):p==="license-release"?e.keySystem===je.FAIRPLAY&&(l.updateKeySession(e,Yi("acknowledged")),l.removeSession(e)):l.warn('unhandled media key message type "'+p+'"')}else v.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(T){if(e.mediaKeysSession){l.onKeyStatusChange(e);var A=e.keyStatus;v.emit("keyStatus",A),A==="expired"&&(l.warn(e.keySystem+" expired for key "+h),l.renewKeySession(e))}else v.emit("error",new Error("invalid state"))};var y=new Promise(function(T,A){v.on("error",A),v.on("keyStatus",function(p){p.startsWith("usable")?T():p==="output-restricted"?A(new It({type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):p==="internal-error"?A(new It({type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+p+'"')):p==="expired"?A(new Error("key expired while generating request")):l.warn('unhandled key status change "'+p+'"')})});return e.mediaKeysSession.generateRequest(t,r).then(function(){var T;l.log('Request generated for key-session "'+((T=e.mediaKeysSession)==null?void 0:T.sessionId)+'" keyId: '+h)}).catch(function(T){throw new It({type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_NO_SESSION,error:T,fatal:!1},"Error generating key-session request: "+T)}).then(function(){return y}).catch(function(T){throw v.removeAllListeners(),l.removeSession(e),T}).then(function(){return v.removeAllListeners(),e})},n.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach(function(r,i){t.log('key status change "'+r+'" for keyStatuses keyId: '+Et("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))+" session keyId: "+Et(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=r})},n.fetchServerCertificate=function(e){var t=this.config,r=new t.loader(t),i=this.getServerCertificateUrl(e);return i?(this.log('Fetching serverCertificate for "'+e+'"'),new Promise(function(a,o){var l={responseType:"arraybuffer",url:i},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:function(h,v,y,T){a(h.data)},onError:function(h,v,y,T){o(new It({type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:y,response:H({url:l.url,data:void 0},h)},'"'+e+'" certificate request failed ('+i+"). Status: "+h.code+" ("+h.text+")"))},onTimeout:function(h,v,y){o(new It({type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:y,response:{url:l.url,data:void 0}},'"'+e+'" certificate request timed out ('+i+")"))},onAbort:function(h,v,y){o(new Error("aborted"))}};r.load(l,u,c)})):Promise.resolve()},n.setMediaKeysServerCertificate=function(e,t,r){var i=this;return new Promise(function(a,o){e.setServerCertificate(r).then(function(l){i.log("setServerCertificate "+(l?"success":"not supported by CDM")+" ("+(r==null?void 0:r.byteLength)+') on "'+t+'"'),a(e)}).catch(function(l){o(new It({type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:l,fatal:!0},l.message))})})},n.renewLicense=function(e,t){var r=this;return this.requestLicense(e,new Uint8Array(t)).then(function(i){return r.updateKeySession(e,new Uint8Array(i)).catch(function(a){throw new It({type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:a,fatal:!0},a.message)})})},n.setupLicenseXHR=function(e,t,r,i){var a=this,o=this.config.licenseXhrSetup;return o?Promise.resolve().then(function(){if(!r.decryptdata)throw new Error("Key removed");return o.call(a.hls,e,t,r,i)}).catch(function(l){if(!r.decryptdata)throw l;return e.open("POST",t,!0),o.call(a.hls,e,t,r,i)}).then(function(l){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:l||i}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))},n.requestLicense=function(e,t){var r=this,i=this.config.keyLoadPolicy.default;return new Promise(function(a,o){var l=r.getLicenseServerUrl(e.keySystem);r.log("Sending license request to URL: "+l);var d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=function(){if(!r.hls||!e.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){r._requestLicenseFailureCount=0;var u=d.response;r.log("License received "+(u instanceof ArrayBuffer?u.byteLength:u));var c=r.config.licenseResponseCallback;if(c)try{u=c.call(r.hls,d,l,e)}catch(T){r.error(T)}a(u)}else{var h=i.errorRetry,v=h?h.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>v||d.status>=400&&d.status<500)o(new It({type:te.KEY_SYSTEM_ERROR,details:U.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:l,data:void 0,code:d.status,text:d.statusText}},"License Request XHR failed ("+l+"). Status: "+d.status+" ("+d.statusText+")"));else{var y=v-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+y+" attempts left"),r.requestLicense(e,t).then(a,o)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=d,r.setupLicenseXHR(d,l,e,t).then(function(u){var c=u.xhr,h=u.licenseChallenge;c.send(h)})})},n.onMediaAttached=function(e,t){if(this.config.emeEnabled){var r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},n.onMediaDetached=function(){var e=this,t=this.media,r=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={},Or.clearKeyUriToKeyIdMap();var i=r.length;s.CDMCleanupPromise=Promise.all(r.map(function(a){return e.removeSession(a)}).concat(t==null?void 0:t.setMediaKeys(null).catch(function(a){e.log("Could not clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))}))).then(function(){i&&(e.log("finished closing key sessions and clearing media keys"),r.length=0)}).catch(function(a){e.log("Could not close sessions and clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))})},n.onManifestLoaded=function(e,t){var r=t.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var i=r.reduce(function(a,o){return a.indexOf(o.keyFormat)===-1&&a.push(o.keyFormat),a},[]);this.log("Selecting key-system from session-keys "+i.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(i)}},n.removeSession=function(e){var t=this,r=e.mediaKeysSession,i=e.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),r.onmessage=null,r.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);return a>-1&&this.mediaKeySessions.splice(a,1),r.remove().catch(function(o){t.log("Could not remove session: "+o)}).then(function(){return r.close()}).catch(function(o){t.log("Could not close session: "+o)})}},s}();Is.CDMCleanupPromise=void 0;var It=function(s){function n(e,t){var r;return(r=s.call(this,t)||this).data=void 0,e.error||(e.error=new Error(t)),r.data=e,e.err=e.error,r}return fe(n,s),n}(Oe(Error)),gl="m",xn="a",La="v",wa="av",Cs="i",ml="tt",pl=function(){function s(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(a){try{t.apply(a,{ot:gl,su:!t.initialized})}catch(o){P.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=function(a){try{var o=a.frag,l=t.hls.levels[o.level],d=t.getObjectType(o),u={d:1e3*o.duration,ot:d};d!==La&&d!==xn&&d!=wa||(u.br=l.bitrate/1e3,u.tb=t.getTopBandwidth(d)/1e3,u.bl=t.getBufferLength(d)),t.apply(a,u)}catch(c){P.warn("Could not generate segment CMCD data.",c)}},this.hls=e;var r=this.config=e.config,i=r.cmcd;i!=null&&(r.pLoader=this.createPlaylistLoader(),r.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||s.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this)},n.unregisterListeners=function(){var e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this)},n.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},n.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},n.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},n.onBufferCreated=function(e,t){var r,i;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(i=t.tracks.video)==null?void 0:i.buffer},n.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}},n.apply=function(e,t){t===void 0&&(t={}),z(t,this.createData());var r=t.ot===Cs||t.ot===La||t.ot===wa;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){var i=s.toHeaders(t);if(!Object.keys(i).length)return;e.headers||(e.headers={}),z(e.headers,i)}else{var a=s.toQuery(t);if(!a)return;e.url=s.appendQueryToUri(e.url,a)}},n.getObjectType=function(e){var t=e.type;return t==="subtitle"?ml:e.sn==="initSegment"?Cs:t==="audio"?xn:t==="main"?this.hls.audioTracks.length?La:wa:void 0},n.getTopBandwidth=function(e){var t,r=0,i=this.hls;if(e===xn)t=i.audioTracks;else{var a=i.maxAutoLevel,o=a>-1?a+1:i.levels.length;t=i.levels.slice(0,o)}for(var l,d=Le(t);!(l=d()).done;){var u=l.value;u.bitrate>r&&(r=u.bitrate)}return r>0?r:NaN},n.getBufferLength=function(e){var t=this.hls.media,r=e===xn?this.audioBuffer:this.videoBuffer;return r&&t?1e3*le.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN},n.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function i(o){this.loader=void 0,this.loader=new r(o)}var a=i.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(o,l,d){t(o),this.loader.load(o,l,d)},j(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},n.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function i(o){this.loader=void 0,this.loader=new r(o)}var a=i.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(o,l,d){t(o),this.loader.load(o,l,d)},j(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},s.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},s.serialize=function(e){for(var t,r=[],i=function(T){return!Number.isNaN(T)&&T!=null&&T!==""&&T!==!1},a=function(T){return Math.round(T)},o=function(T){return 100*a(T/100)},l={br:a,d:a,bl:o,dl:o,mtp:o,nor:function(T){return encodeURIComponent(T)},rtp:o,tb:a},d=Le(Object.keys(e||{}).sort());!(t=d()).done;){var u=t.value,c=e[u];if(i(c)&&!(u==="v"&&c===1||u=="pr"&&c===1)){var h=l[u];h&&(c=h(c));var v=typeof c,y=void 0;y=u==="ot"||u==="sf"||u==="st"?u+"="+c:v==="boolean"?u:v==="number"?u+"="+c:u+"="+JSON.stringify(c),r.push(y)}}return r.join(",")},s.toHeaders=function(e){for(var t={},r=["Object","Request","Session","Status"],i=[{},{},{},{}],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},o=0,l=Object.keys(e);o<l.length;o++){var d=l[o];i[a[d]!=null?a[d]:1][d]=e[d]}for(var u=0;u<i.length;u++){var c=s.serialize(i[u]);c&&(t["CMCD-"+r[u]]=c)}return t},s.toQuery=function(e){return"CMCD="+encodeURIComponent(s.serialize(e))},s.appendQueryToUri=function(e,t){if(!t)return e;var r=e.includes("?")?"&":"?";return""+e+r+t},s}(),yl=function(){function s(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=P.log.bind(P,"[content-steering]:"),this.registerListeners()}var n=s.prototype;return n.registerListeners=function(){var e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)},n.unregisterListeners=function(){var e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))},n.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)},n.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)},n.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},n.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter(function(r){return r!==e}))},n.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},n.onManifestLoaded=function(e,t){var r=t.contentSteering;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},n.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},n.onError=function(e,t){var r=t.errorAction;if((r==null?void 0:r.action)===Ze&&r.flags===Wr){var i=this.pathwayPriority,a=this.pathwayId;this.penalizedPathways[a]||(this.penalizedPathways[a]=performance.now()),!i&&this.levels&&(i=this.levels.reduce(function(o,l){return o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o},[])),i&&i.length>1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==a)}},n.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t):e},n.getLevelsForPathway=function(e){return this.levels===null?[]:this.levels.filter(function(t){return e===t.pathwayId})},n.updatePathwayPriority=function(e){var t;this.pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(function(c){i-r[c]>3e5&&delete r[c]});for(var a=0;a<e.length;a++){var o=e[a];if(!r[o]){if(o===this.pathwayId)return;var l=this.hls.nextLoadLevel,d=this.hls.levels[l];if((t=this.getLevelsForPathway(o)).length>0){this.log('Setting Pathway to "'+o+'"'),this.pathwayId=o,this.hls.trigger(E.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[l];d&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==d.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==d.bitrate&&this.log("Unstable Pathways change from bitrate "+d.bitrate+" to "+u.bitrate),this.hls.nextLoadLevel=l);break}}}},n.clonePathways=function(e){var t=this,r=this.levels;if(r){var i={},a={};e.forEach(function(o){var l=o.ID,d=o["BASE-ID"],u=o["URI-REPLACEMENT"];if(!r.some(function(h){return h.pathwayId===l})){var c=t.getLevelsForPathway(d).map(function(h){var v=z({},h);v.details=void 0,v.url=Ps(h.uri,h.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",u);var y=new Ge(h.attrs);y["PATHWAY-ID"]=l;var T=y.AUDIO&&y.AUDIO+"_clone_"+l,A=y.SUBTITLES&&y.SUBTITLES+"_clone_"+l;T&&(i[y.AUDIO]=T,y.AUDIO=T),A&&(a[y.SUBTITLES]=A,y.SUBTITLES=A),v.attrs=y;var p=new Kr(v);return S(p,"audio",T),S(p,"text",A),p});r.push.apply(r,c),xs(t.audioTracks,i,u,l),xs(t.subtitleTracks,a,u,l)}})}},n.loadSteeringManifest=function(e){var t,r=this,i=this.hls.config,a=i.loader;this.loader&&this.loader.destroy(),this.loader=new a(i);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 o=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+o)}var l={responseType:"json",url:t.href},d=i.steeringManifestLoadPolicy.default,u=d.errorRetry||d.timeoutRetry||{},c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:u.maxNumRetry||0,retryDelay:u.retryDelayMs||0,maxRetryDelay:u.maxRetryDelayMs||0},h={onSuccess:function(v,y,T,A){r.log('Loaded steering manifest: "'+t+'"');var p=v.data;if(p.VERSION===1){r.updated=performance.now(),r.timeToLoad=p.TTL;var _=p["RELOAD-URI"],L=p["PATHWAY-CLONES"],w=p["PATHWAY-PRIORITY"];if(_)try{r.uri=new self.URL(_,t).href}catch{return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+_)}r.scheduleRefresh(r.uri||T.url),L&&r.clonePathways(L),w&&r.updatePathwayPriority(w)}else r.log("Steering VERSION "+p.VERSION+" not supported!")},onError:function(v,y,T,A){if(r.log("Error loading steering manifest: "+v.code+" "+v.text+" ("+y.url+")"),r.stopLoad(),v.code===410)return r.enabled=!1,void r.log("Steering manifest "+y.url+" no longer available");var p=1e3*r.timeToLoad;if(v.code!==429)r.scheduleRefresh(r.uri||y.url,p);else{var _=r.loader;if(typeof(_==null?void 0:_.getResponseHeader)=="function"){var L=_.getResponseHeader("Retry-After");L&&(p=1e3*parseFloat(L))}r.log("Steering manifest "+y.url+" rate limited")}},onTimeout:function(v,y,T){r.log("Timeout loading steering manifest ("+y.url+")"),r.scheduleRefresh(r.uri||y.url)}};this.log("Requesting steering manifest: "+t),this.loader.load(l,c,h)},n.scheduleRefresh=function(e,t){var r=this;t===void 0&&(t=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(function(){r.loadSteeringManifest(e)},t)},s}();function xs(s,n,e,t){s&&Object.keys(n).forEach(function(r){var i=s.filter(function(a){return a.groupId===r}).map(function(a){var o=z({},a);return o.details=void 0,o.attrs=new Ge(o.attrs),o.url=o.attrs.URI=Ps(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),o.groupId=o.attrs["GROUP-ID"]=n[r],o.attrs["PATHWAY-ID"]=t,o});s.push.apply(s,i)})}function Ps(s,n,e,t){var r,i=t.HOST,a=t.PARAMS,o=t[e];n&&(r=o==null?void 0:o[n])&&(s=r);var l=new self.URL(s);return i&&!r&&(l.host=i),a&&Object.keys(a).sort().forEach(function(d){d&&l.searchParams.set(d,a[d])}),l.href}var Tl=/^age:\s*[\d.]+\s*$/im,Os=function(){function s(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 Pt,this.retryDelay=0}var n=s.prototype;return n.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},n.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()))},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},n.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},n.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t){var i=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0;var o=this.xhrSetup;o?Promise.resolve().then(function(){if(!e.stats.aborted)return o(i,r.url)}).catch(function(l){return i.open("GET",r.url,!0),o(i,r.url)}).then(function(){e.stats.aborted||e.openAndSendXhr(i,r,t)}).catch(function(l){e.callbacks.onError({code:i.status,text:l.message},r,i,a)}):this.openAndSendXhr(i,r,t)}},n.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=this.context.headers;if(i)for(var a in i)e.setRequestHeader(a,i[a]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxTimeToFirstByteMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxTimeToFirstByteMs),e.send()},n.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start))),i===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var o=t.status,l=t.responseType!=="text";if(o>=200&&o<300&&(l&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var d=l?t.response:t.responseText,u=t.responseType==="arraybuffer"?d.byteLength:d.length;if(r.loaded=r.total=u,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(r,e,d,t),!this.callbacks)return;var h={url:t.responseURL,data:d,code:o};this.callbacks.onSuccess(h,r,e,t)}else{var v=a.loadPolicy.errorRetry;Vr(v,r.retry,!1,o)?this.retry(v):(P.error(o+" while loading "+e.url),this.callbacks.onError({code:o,text:t.statusText},e,t,r))}}}},n.loadtimeout=function(){var e,t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry;if(Vr(t,this.stats.retry,!0))this.retry(t);else{P.warn("timeout while loading "+this.context.url);var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}},n.retry=function(e){var t=this.context,r=this.stats;this.retryDelay=wi(e,r.retry),r.retry++,P.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+t.url+", retrying "+r.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},n.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},n.getCacheAge=function(){var e=null;if(this.loader&&Tl.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},s}(),El=/(\d+)-(\d+)\/(\d+)/,Ms=function(){function s(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||_l,this.controller=new self.AbortController,this.stats=new Pt}var n=s.prototype;return n.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},n.abortInternal=function(){var e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())},n.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},n.load=function(e,t,r){var i=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var o=function(c,h){var v={method:"GET",mode:"cors",credentials:"same-origin",signal:h,headers:new self.Headers(z({},c.headers))};return c.rangeEnd&&v.headers.set("Range","bytes="+c.rangeStart+"-"+String(c.rangeEnd-1)),v}(e,this.controller.signal),l=r.onProgress,d=e.responseType==="arraybuffer",u=d?"byteLength":"length";this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,o),self.clearTimeout(this.requestTimeout),t.timeout=t.loadPolicy.maxTimeToFirstByteMs,this.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},t.timeout),self.fetch(this.request).then(function(c){i.response=i.loader=c;var h=Math.max(self.performance.now(),a.loading.start);if(self.clearTimeout(i.requestTimeout),t.timeout=t.loadPolicy.maxLoadTimeMs,i.requestTimeout=self.setTimeout(function(){i.abortInternal(),r.onTimeout(a,e,i.response)},t.loadPolicy.maxLoadTimeMs-(h-a.loading.start)),!c.ok){var v=c.status,y=c.statusText;throw new bl(y||"fetch, bad network response",v,c)}return a.loading.first=h,a.total=function(T){var A=T.get("Content-Range");if(A){var p=function(L){var w=El.exec(L);if(w)return parseInt(w[2])-parseInt(w[1])+1}(A);if(Q(p))return p}var _=T.get("Content-Length");if(_)return parseInt(_)}(c.headers)||a.total,l&&Q(t.highWaterMark)?i.loadProgressively(c,a,e,t.highWaterMark,l):d?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(function(c){var h=i.response;self.clearTimeout(i.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var v=c[u];v&&(a.loaded=a.total=v);var y={url:h.url,data:c,code:h.status};l&&!Q(t.highWaterMark)&&l(a,e,c,h),r.onSuccess(y,a,e,h)}).catch(function(c){if(self.clearTimeout(i.requestTimeout),!a.aborted){var h=c&&c.code||0,v=c?c.message:null;r.onError({code:h,text:v},e,c?c.details:null,a)}})},n.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},n.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},n.loadProgressively=function(e,t,r,i,a){i===void 0&&(i=0);var o=new hs,l=e.body.getReader();return function d(){return l.read().then(function(u){if(u.done)return o.dataLength&&a(t,r,o.flush(),e),Promise.resolve(new ArrayBuffer(0));var c=u.value,h=c.length;return t.loaded+=h,h<i||o.dataLength?(o.push(c),o.dataLength>=i&&a(t,r,o.flush(),e)):a(t,r,c,e),d()}).catch(function(){return Promise.reject()})}()},s}();function _l(s,n){return new self.Request(s.url,n)}var bl=function(s){function n(e,t,r){var i;return(i=s.call(this,e)||this).code=void 0,i.details=void 0,i.code=t,i.details=r,i}return fe(n,s),n}(Oe(Error)),Sl=/\s/,Al=H(H({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:Os,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Ko,bufferController:Xo,capLevelController:fl,errorController:f,fpsController:vl,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:ci,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:1e4,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(s,n,e,t){for(var r,i,a,o,l,d=[],u=self.VTTCue||self.TextTrackCue,c=0;c<t.rows.length;c++)if(a=!0,o=0,l="",!(r=t.rows[c]).isEmpty()){for(var h,v=0;v<r.chars.length;v++)Sl.test(r.chars[v].uchar)&&a?o++:(l+=r.chars[v].uchar,a=!1);r.cueStartTime=n,n===e&&(e+=1e-4),o>=16?o--:o++;var y=Ss(l.trim()),T=ba(n,e,y);s!=null&&(h=s.cues)!=null&&h.getCueById(T)||((i=new u(n,e,y)).id=T,i.line=c+1,i.align="left",i.position=10+Math.min(80,10*Math.floor(8*o/32)),d.push(i))}return s&&d.length&&(d.sort(function(A,p){return A.line==="auto"||p.line==="auto"?0:A.line>8&&p.line>8?p.line-A.line:A.line-p.line}),d.forEach(function(A){return pn(s,A)})),d}},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:Vo,subtitleTrackController:Wo,timelineController:cl,audioStreamController:qo,audioTrackController:jo,emeController:Is,cmcdController:pl,contentSteeringController:yl});function Da(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(Da):Object.keys(s).reduce(function(n,e){return n[e]=Da(s[e]),n},{}):s}function kl(s){var n=s.loader;n!==Ms&&n!==Os?(P.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(s.loader=Ms,s.progressive=!0,s.enableSoftwareAES=!0,P.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Fs=function(){function s(e){e===void 0&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new wn,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,$e(e.debug||!1,"Hls instance");var t=this.config=function(Z,X){if((X.liveSyncDurationCount||X.liveMaxLatencyDurationCount)&&(X.liveSyncDuration||X.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(X.liveMaxLatencyDurationCount!==void 0&&(X.liveSyncDurationCount===void 0||X.liveMaxLatencyDurationCount<=X.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(X.liveMaxLatencyDuration!==void 0&&(X.liveSyncDuration===void 0||X.liveMaxLatencyDuration<=X.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var ie=Da(Z),ye=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(function(ae){var pe=(ae==="level"?"playlist":ae)+"LoadPolicy",oe=X[pe]===void 0,me=[];ye.forEach(function(Ae){var Ie=ae+"Loading"+Ae,Re=X[Ie];if(Re!==void 0&&oe){me.push(Ie);var Ue=ie[pe].default;switch(X[pe]={default:Ue},Ae){case"TimeOut":Ue.maxLoadTimeMs=Re,Ue.maxTimeToFirstByteMs=Re;break;case"MaxRetry":Ue.errorRetry.maxNumRetry=Re,Ue.timeoutRetry.maxNumRetry=Re;break;case"RetryDelay":Ue.errorRetry.retryDelayMs=Re,Ue.timeoutRetry.retryDelayMs=Re;break;case"MaxRetryTimeout":Ue.errorRetry.maxRetryDelayMs=Re,Ue.timeoutRetry.maxRetryDelayMs=Re}}}),me.length&&P.warn('hls.js config: "'+me.join('", "')+'" setting(s) are deprecated, use "'+pe+'": '+JSON.stringify(X[pe]))}),H(H({},ie),X)}(s.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&kl(t);var r=t.abrController,i=t.bufferController,a=t.capLevelController,o=t.errorController,l=t.fpsController,d=new o(this),u=this.abrController=new r(this),c=this.bufferController=new i(this),h=this.capLevelController=new a(this),v=new l(this),y=new mn(this),T=new ki(this),A=t.contentSteeringController,p=A?new A(this):null,_=this.levelController=new b(this,p),L=new Y(this),w=new tt(this.config),x=this.streamController=new Go(this,L,w);h.setStreamController(x),v.setStreamController(x);var F=[y,_,x];p&&F.splice(1,0,p),this.networkControllers=F;var G=[u,c,h,v,T,L];this.audioTrackController=this.createController(t.audioTrackController,F);var W=t.audioStreamController;W&&F.push(new W(this,L,w)),this.subtitleTrackController=this.createController(t.subtitleTrackController,F);var q=t.subtitleStreamController;q&&F.push(new q(this,L,w)),this.createController(t.timelineController,G),w.emeController=this.emeController=this.createController(t.emeController,G),this.cmcdController=this.createController(t.cmcdController,G),this.latencyController=this.createController(yn,G),this.coreComponents=G,F.push(d);var V=d.onErrorOut;typeof V=="function"&&this.on(E.ERROR,V,d)}s.isSupported=function(){return function(){var e=ra();if(!e)return!1;var t=Wa(),r=e&&typeof e.isTypeSupported=="function"&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!r&&!!i}()};var n=s.prototype;return n.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},n.on=function(e,t,r){r===void 0&&(r=this),this._emitter.on(e,t,r)},n.once=function(e,t,r){r===void 0&&(r=this),this._emitter.once(e,t,r)},n.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},n.off=function(e,t,r,i){r===void 0&&(r=this),this._emitter.off(e,t,r,i)},n.listeners=function(e){return this._emitter.listeners(e)},n.emit=function(e,t,r){return this._emitter.emit(e,t,r)},n.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){P.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(E.ERROR,{type:te.OTHER_ERROR,details:U.INTERNAL_EXCEPTION,fatal:!1,event:e,error:r})}return!1},n.listenerCount=function(e){return this._emitter.listenerCount(e)},n.destroy=function(){P.log("destroy"),this.trigger(E.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},n.attachMedia=function(e){P.log("attachMedia"),this._media=e,this.trigger(E.MEDIA_ATTACHING,{media:e})},n.detachMedia=function(){P.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,void 0),this._media=null},n.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,i=this.url=Me.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});P.log("loadSource:"+i),t&&r&&r!==i&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(E.MANIFEST_LOADING,{url:e})},n.startLoad=function(e){e===void 0&&(e=-1),P.log("startLoad("+e+")"),this.networkControllers.forEach(function(t){t.startLoad(e)})},n.stopLoad=function(){P.log("stopLoad"),this.networkControllers.forEach(function(e){e.stopLoad()})},n.swapAudioCodec=function(){P.log("swapAudioCodec"),this.streamController.swapAudioCodec()},n.recoverMediaError=function(){P.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},n.removeLevel=function(e,t){t===void 0&&(t=0),this.levelController.removeLevel(e,t)},j(s,[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){P.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){P.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){P.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){P.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){P.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&&(P.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){Hr.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 r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=r===-1&&t&&t.length?t.length-1:r,i)for(var a=e;a--;){var o=t[a].attrs["HDCP-LEVEL"];if(o&&o<=i)return a}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.0-beta.2"}},{key:"Events",get:function(){return E}},{key:"ErrorTypes",get:function(){return te}},{key:"ErrorDetails",get:function(){return U}},{key:"DefaultConfig",get:function(){return s.defaultConfig?s.defaultConfig:Al},set:function(e){s.defaultConfig=e}}]),s}();return Fs.defaultConfig=void 0,Fs},typeof Ws=="object"&&typeof Na!="undefined"?Na.exports=B():typeof define=="function"&&define.amd?define(B):(D=typeof globalThis!="undefined"?globalThis:D||self).Hls=B()})(!1)});var ei=class{addEventListener(){}removeEventListener(){}dispatchEvent(M){return!0}};if(typeof DocumentFragment=="undefined"){class I extends ei{}globalThis.DocumentFragment=I}var Fi=class extends ei{},Pa=class extends ei{},Bl={get(I){},define(I,M,D){},upgrade(I){},whenDefined(I){return Promise.resolve(Fi)}},Ni,Oa=class{constructor(M,D={}){Gt(this,Ni,void 0);Ht(this,Ni,D==null?void 0:D.detail)}get detail(){return pt(this,Ni)}initCustomEvent(){}};Ni=new WeakMap;function Gl(I,M){return new Fi}var js={document:{createElement:Gl},DocumentFragment,customElements:Bl,CustomEvent:Oa,EventTarget:ei,HTMLElement:Fi,HTMLVideoElement:Pa},Vs=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Qt=Vs?js:globalThis,Ma=Vs?js.document:globalThis.document;var Nn=qs(Ys(),1),eo=qs(zs(),1),Hl=eo.default,St=Hl,Ui=class extends Error{constructor(I,M=Ui.MEDIA_ERR_CUSTOM,D,B){var K;super(I),this.name="MediaError",this.code=M,this.context=B,this.fatal=D!=null?D:M>=Ui.MEDIA_ERR_NETWORK&&M<=Ui.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(K=Ui.defaultMessages[this.code])!=null?K:"")}},yt=Ui;yt.MEDIA_ERR_ABORTED=1,yt.MEDIA_ERR_NETWORK=2,yt.MEDIA_ERR_DECODE=3,yt.MEDIA_ERR_SRC_NOT_SUPPORTED=4,yt.MEDIA_ERR_ENCRYPTED=5,yt.MEDIA_ERR_CUSTOM=100,yt.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 Kl=I=>I==null,to=(I,M)=>Kl(M)?!1:I in M,Ba={ANY:"any",MUTED:"muted"},Fn={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Ar={MSE:"mse",NATIVE:"native"},Ga={HEADER:"header",QUERY:"query",NONE:"none"},_u=Object.values(Ga),ti={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Ha={HLS:ti.M3U8},bu=Object.keys(Ha),Su=[...Object.values(ti),"hls","HLS"],Sr=(I,M,D,B,K=I)=>{K.addEventListener(M,D,B),I.addEventListener("teardown",()=>{K.removeEventListener(M,D)},{once:!0})};function ql(I,M,D){M&&D>M&&(D=M);for(let B=0;B<I.length;B++)if(I.start(B)<=D&&I.end(B)>=D)return!0;return!1}var jl=I=>{let M=I.indexOf("?");if(M<0)return[I];let D=I.slice(0,M),B=I.slice(M);return[D,B]},ro=I=>{let M=I.type;if(M){let B=M.toUpperCase();return to(B,Ha)?Ha[B]:M}let{src:D}=I;return D?Vl(D):""},Vl=I=>{let M="";try{M=new URL(I).pathname}catch{console.error("invalid url")}let D=M.lastIndexOf(".");if(D<0)return"";let B=M.slice(D+1).toUpperCase();return to(B,ti)?ti[B]:""},Yl=Object.values(Ba),Xs=I=>typeof I=="boolean"||typeof I=="string"&&Yl.includes(I),Wl=({autoplay:I},M,D)=>{let B=!1,K=!1,H=Xs(I)?I:!!I,J=()=>{B||Sr(M,"playing",()=>{B=!0},{once:!0})};if(J(),Sr(M,"loadstart",()=>{B=!1,J(),Ua(M,H)},{once:!0}),Sr(M,"loadstart",()=>{D||(K=!Number.isFinite(M.duration)),Ua(M,H)},{once:!0}),D&&D.once(St.Events.LEVEL_LOADED,(j,se)=>{var z;K=(z=se.details.live)!=null?z:!1}),!H){let j=()=>{!K||(D!=null&&D.liveSyncPosition?M.currentTime=D.liveSyncPosition:Number.isFinite(M.seekable.end(0))&&(M.currentTime=M.seekable.end(0)))};D&&Sr(M,"play",()=>{M.preload==="metadata"?D.once(St.Events.LEVEL_UPDATED,j):j()},{once:!0})}return j=>{B||(H=Xs(j)?j:!!j,Ua(M,H))}},Ua=(I,M)=>{if(!M)return;let D=I.muted,B=()=>I.muted=D;switch(M){case Ba.ANY:I.play().catch(()=>{I.muted=!0,I.play().catch(B)});break;case Ba.MUTED:I.muted=!0,I.play().catch(B);break;default:I.play().catch(()=>{});break}},zl=({preload:I,src:M},D,B)=>{let K=be=>{be!=null&&["","none","metadata","auto"].includes(be)?D.setAttribute("preload",be):D.removeAttribute("preload")};if(!B)return K(I),K;let H=!1,J=!1,j=B.config.maxBufferLength,se=B.config.maxBufferSize,z=be=>{K(be);let ve=be!=null?be:D.preload;J||ve==="none"||(ve==="metadata"?(B.config.maxBufferLength=1,B.config.maxBufferSize=1):(B.config.maxBufferLength=j,B.config.maxBufferSize=se),fe())},fe=()=>{!H&&M&&(H=!0,B.loadSource(M))};return Sr(D,"play",()=>{J=!0,B.config.maxBufferLength=j,B.config.maxBufferSize=se,fe()},{once:!0}),z(I),z};function Xl(I,M){M.on(St.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(K,{tracks:H})=>{H.forEach(J=>{var j;let se=(j=J.subtitleTrack)!=null?j:J.closedCaptions,z=M.subtitleTracks.findIndex(({lang:fe,name:be,type:ve})=>fe==(se==null?void 0:se.lang)&&be===J.label&&ve.toLowerCase()===J.kind);io(I,J.kind,J.label,se==null?void 0:se.lang,`${J.kind}${z}`)})});let D=()=>{var K;if(!M.subtitleTracks.length)return;let H=Array.from(I.textTracks).find(j=>j.id&&j.mode==="showing"&&["subtitles","captions"].includes(j.kind)),J=`${(K=M.subtitleTracks[M.subtitleTrack])==null?void 0:K.type.toLowerCase()}${M.subtitleTrack}`;if(H&&(M.subtitleTrack<0||(H==null?void 0:H.id)!==J)){let j=M.subtitleTracks.findIndex(({lang:se,name:z,type:fe})=>se==H.language&&z===H.label&&fe.toLowerCase()===H.kind);M.subtitleTrack=j}H&&(H==null?void 0:H.id)===J&&H.cues&&Array.from(H.cues).forEach(j=>{H.addCue(j)})};I.textTracks.addEventListener("change",D),M.on(St.Events.CUES_PARSED,(K,{track:H,cues:J})=>{let j=I.textTracks.getTrackById(H);if(!j)return;let se=j.mode==="disabled";se&&(j.mode="hidden"),J.forEach(z=>{var fe;(fe=j.cues)!=null&&fe.getCueById(z.id)||j.addCue(z)}),se&&(j.mode="disabled")}),M.once(St.Events.DESTROYING,()=>{I.textTracks.removeEventListener("change",D),I.querySelectorAll("track[data-removeondestroy]").forEach(K=>{K.remove()})});let B=()=>{Array.from(I.textTracks).forEach(K=>{var H,J;if(!["subtitles","caption"].includes(K.kind)&&K.label==="thumbnails"){if(!((H=K.cues)!=null&&H.length)){let j=I.querySelector('track[label="thumbnails"]'),se=(J=j==null?void 0:j.getAttribute("src"))!=null?J:"";j==null||j.removeAttribute("src"),setTimeout(()=>{j==null||j.setAttribute("src",se)},0)}K.mode!=="hidden"&&(K.mode="hidden")}})};M.once(St.Events.MANIFEST_LOADED,B),M.once(St.Events.MEDIA_ATTACHED,B)}function io(I,M,D,B,K){let H=document.createElement("track");return H.kind=M,H.label=D,B&&(H.srclang=B),K&&(H.id=K),H.track.mode=["subtitles","captions"].includes(M)?"disabled":"hidden",H.setAttribute("data-removeondestroy",""),I.append(H),H.track}var Un="cuepoints",qa=Object.freeze({label:Un}),no=(I,{label:M=Un}=qa)=>{var D;return(D=Array.from(I.querySelectorAll("track")).find(B=>B.track.label===M&&B.track.kind==="metadata"))==null?void 0:D.track};async function Ql(I,M,D=qa){let B=no(I,D);if(!B){let{label:K=Un}=D;B=io(I,"metadata",K),B.mode="hidden",await new Promise(H=>setTimeout(()=>H(void 0),0))}return B.mode!=="hidden"&&(B.mode="hidden"),[...M].sort(({time:K},{time:H})=>H-K).forEach(({time:K,value:H})=>{var J,j;let se=Array.prototype.findIndex.call(B==null?void 0:B.cues,Se=>Se.startTime>=K),z=(J=B==null?void 0:B.cues)==null?void 0:J[se],fe=z?z.startTime:Number.isFinite(I.duration)?I.duration:Number.MAX_SAFE_INTEGER,be=(j=B==null?void 0:B.cues)==null?void 0:j[se-1];be&&(be.endTime=K);let ve=new VTTCue(K,fe,JSON.stringify(H!=null?H:null));B.addCue(ve)}),B}var Jl=I=>({time:I.startTime,value:JSON.parse(I.text)});function $l(I,M={label:Un}){var D,B;let K=no(I,M);if(!((D=K==null?void 0:K.activeCues)!=null&&D.length))return;let{currentTime:H}=I,J=Array.prototype.find.call((B=K.activeCues)!=null?B:[],({startTime:j,endTime:se})=>j<=H&&se>H);return Jl(J)}async function Zl(I,M=qa){return new Promise(D=>{Sr(I,"loadstart",async()=>{let B=await Ql(I,[],M);Sr(I,"cuechange",()=>{let K=$l(I);if(K){let H=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:K});I.dispatchEvent(H)}},{},B),D(B)})})}var Qs,Js,eu=(Js=(Qs=globalThis==null?void 0:globalThis.navigator)==null?void 0:Qs.userAgent)!=null?Js:"",tu=eu.toLowerCase().indexOf("android")!==-1,Bi=new WeakMap,ao="mux.com",$s,Zs,so=(Zs=($s=St).isSupported)==null?void 0:Zs.call($s),ru=tu,oo=()=>Nn.default.utils.now(),iu=Nn.default.utils.generateUUID,lo=(I,{domain:M=ao,maxResolution:D=""}={})=>{if(!I)return;let[B,K=""]=jl(I),H=new URL(`https://stream.${M}/${B}.m3u8${K}`);return D&&H.searchParams.set("max_resolution",D),H.toString()},nu=I=>{if(!I)return;let[M]=I.split("?");return M||void 0},au=I=>{if(!I||!I.startsWith("https://stream."))return;let[M]=new URL(I).pathname.slice(1).split(".m3u8");return M||void 0},su=I=>{var M,D,B;return(M=I==null?void 0:I.metadata)!=null&&M.video_id?I.metadata.video_id:ho(I)&&(B=(D=nu(I.playbackId))!=null?D:au(I.src))!=null?B:I.src};var uo=(I,M,D)=>{ja(M,D);let{metadata:B={}}=I,{view_session_id:K=iu()}=B,H=su(I);B.view_session_id=K,B.video_id=H,I.metadata=B,Bi.set(M,{});let J=ou(I,M);uu(I,M,J),du(I,M,J),Zl(M);let j=Wl(I,M,J),se=zl(I,M,J);return{engine:J,setAutoplay:j,setPreload:se}},ja=(I,M)=>{let D=M==null?void 0:M.engine;D&&(D.detachMedia(),D.destroy()),(I==null?void 0:I.mux)&&!I.mux.deleted&&(I.mux.destroy(),delete I.mux),I&&(I.removeAttribute("src"),I.load(),I.removeEventListener("error",vo),I.removeEventListener("error",Ka),I.removeEventListener("durationchange",fo),Bi.delete(I),I.dispatchEvent(new Event("teardown")))};function co(I,M){var D;let B=ro(I);if(B!==ti.M3U8)return!0;let K=!B||((D=M.canPlayType(B))!=null?D:!0),{preferPlayback:H}=I,J=H===Ar.MSE,j=H===Ar.NATIVE;return K&&(j||!(so&&(J||ru)))}var ou=(I,M)=>{let{debug:D,streamType:B,startTime:K=-1,metadata:H,preferCmcd:J}=I,j=ro(I)===ti.M3U8,se=co(I,M);if(j&&!se&&so){let z={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},fe=lu(B),be=J!==Ga.NONE?{useHeaders:J===Ga.HEADER,sessionId:H==null?void 0:H.view_session_id,contentId:H==null?void 0:H.video_id}:void 0;return new St({debug:D,startPosition:K,cmcd:be,...z,...fe})}},lu=I=>[Fn.LIVE,Fn.DVR].includes(I)?{backBufferLength:8}:[Fn.LL_LIVE,Fn.LL_DVR].includes(I)?{backBufferLength:4,maxFragLookUpTolerance:.001,abrBandWidthUpFactor:.95}:{},ho=({playbackId:I,src:M,customDomain:D})=>{if(I)return!0;if(typeof M!="string")return!1;let B=window==null?void 0:window.location.href,K=new URL(M,B).hostname.toLocaleLowerCase();return K.includes(ao)||!!D&&K.includes(D.toLocaleLowerCase())},uu=(I,M,D)=>{var B;let{envKey:K}=I,H=ho(I);if(K||H){let{playerInitTime:J,playerSoftwareName:j,playerSoftwareVersion:se,beaconCollectionDomain:z,debug:fe,disableCookies:be}=I,ve={...I.metadata,video_title:((B=I==null?void 0:I.metadata)==null?void 0:B.video_title)||void 0},Se=we=>typeof we.player_error_code=="string"?!1:typeof I.errorTranslator=="function"?I.errorTranslator(we):we;Nn.default.monitor(M,{debug:fe,beaconCollectionDomain:z,hlsjs:D,Hls:D?St:void 0,automaticErrorTracking:!1,errorTranslator:Se,disableCookies:be,data:{...K?{env_key:K}:{},player_software_name:j,player_software:j,player_software_version:se,player_init_time:J,...ve}})}},du=(I,M,D)=>{var B;let K=co(I,M),{src:H}=I;M&&K?(typeof H=="string"?(M.setAttribute("src",H),I.startTime&&(((B=Bi.get(M))!=null?B:{}).startTime=I.startTime,M.addEventListener("durationchange",fo,{once:!0}))):M.removeAttribute("src"),M.addEventListener("error",vo),M.addEventListener("error",Ka),M.addEventListener("emptied",()=>{M.querySelectorAll("track[data-removeondestroy]").forEach(J=>{J.remove()})},{once:!0})):D&&H?(D.on(St.Events.ERROR,(J,j)=>{let se={[St.ErrorTypes.NETWORK_ERROR]:yt.MEDIA_ERR_NETWORK,[St.ErrorTypes.MEDIA_ERROR]:yt.MEDIA_ERR_DECODE},z=new yt("",se[j.type]);z.fatal=j.fatal,z.data=j,M.dispatchEvent(new CustomEvent("error",{detail:z}))}),M.addEventListener("error",Ka),Xl(M,D),D.attachMedia(M)):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 fo(I){var M;let D=I.target,B=(M=Bi.get(D))==null?void 0:M.startTime;if(!!B&&ql(D.seekable,D.duration,B)){let K=D.preload==="auto";K&&(D.preload="none"),D.currentTime=B,K&&(D.preload="auto")}}async function vo(I){if(!I.isTrusted)return;I.stopImmediatePropagation();let M=I.target;if(!(M!=null&&M.error))return;let{message:D,code:B}=M.error,K=new yt(D,B);if(M.src&&(B!==yt.MEDIA_ERR_DECODE||B!==void 0))try{let{status:H}=await fetch(M.src);K.data={response:{code:H}}}catch{}M.dispatchEvent(new CustomEvent("error",{detail:K}))}function Ka(I){var M,D;if(!(I instanceof CustomEvent)||!(I.detail instanceof yt))return;let B=I.target,K=I.detail;!K||!K.fatal||(((M=Bi.get(B))!=null?M:{}).error=K,(D=B.mux)==null||D.emit("error",{player_error_code:K.code,player_error_message:K.message,player_error_context:K.context}))}var cu=()=>{try{return"0.9.6"}catch{}return"UNKNOWN"},hu=cu(),go=()=>hu;var mo=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],po=Ma.createElement("template");po.innerHTML=`
|
|
33
46
|
<style>
|
|
34
47
|
:host {
|
|
35
48
|
/* display:inline (like the native el) makes it so you can't fill
|
|
@@ -52,7 +65,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
52
65
|
|
|
53
66
|
<audio part="audio" crossorigin></audio>
|
|
54
67
|
<slot></slot>
|
|
55
|
-
`;var
|
|
68
|
+
`;var Gi,ri,Bn,kr=class extends Qt.HTMLElement{constructor(){super();Gt(this,ri);Gt(this,Gi,void 0);this.attachShadow({mode:"open"}),this.isConnected&&br(this,ri,Bn).call(this)}static get observedAttributes(){let D=[];Object.getOwnPropertyNames(this.prototype).forEach(K=>{let H=!1;try{typeof this.prototype[K]=="function"&&(H=!0)}catch{}!H&&K!==K.toUpperCase()&&D.push(K.toLowerCase())});let B=Object.getPrototypeOf(this).observedAttributes;return B&&(D=D.concat(B)),D}attributeChangedCallback(D,B,K){br(this,ri,Bn).call(this),this.forwardAttribute(D,B,K)}forwardAttribute(D,B,K){let H=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),J=vu(H,D),j=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;J&&!j?typeof this[J]=="boolean"?K===null?this[J]=!1:this[J]=!0:this[J]=K:K===null?this.nativeEl.removeAttribute(D):["id","class"].indexOf(D)===-1&&this.nativeEl.setAttribute(D,K)}connectedCallback(){br(this,ri,Bn).call(this)}};Gi=new WeakMap,ri=new WeakSet,Bn=function(){if(pt(this,Gi))return;Ht(this,Gi,!0),this.shadowRoot.append(po.content.cloneNode(!0));let D=this.nativeEl=this.shadowRoot.querySelector("audio");mo.forEach(K=>{D.addEventListener(K,H=>{this.dispatchEvent(new CustomEvent(H.type,{detail:H.detail}))})});let B=this.shadowRoot.querySelector("slot");B.addEventListener("slotchange",()=>{B.assignedElements().forEach(K=>{!["track","source"].includes(K.localName)||D.append(K)})}),Array.from(this.attributes).forEach(K=>{this.forwardAttribute(K.name,null,K.value)}),D.defaultMuted&&(D.muted=!0)};var yo=[],To=Ma.createElement("audio"),fu=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let I=Object.getPrototypeOf(To);I&&I!==Qt.HTMLElement.prototype;I=Object.getPrototypeOf(I))Object.keys(I).forEach(M=>{fu.indexOf(M)===-1&&yo.push(M)});yo.forEach(I=>{if(typeof To[I]=="function")kr.prototype[I]=function(){return this.nativeEl[I].apply(this.nativeEl,arguments)};else{let D={get(){return this.nativeEl[I]}};I!==I.toUpperCase()&&(D.set=function(B){this.nativeEl[I]=B}),Object.defineProperty(kr.prototype,I,D)}});function vu(I,M){let D=null;return I.forEach(B=>{B.toLowerCase()==M.toLowerCase()&&(D=B)}),D}Qt.customElements.get("custom-audio")||(Qt.customElements.define("custom-audio",kr),Qt.CustomAudioElement=kr);var Va=kr;var Be={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},gu=Object.values(Be),mu=go(),pu="mux-audio",Jt,ii,Ki,ni,qi,Ya,Hi=class extends Va{constructor(){super();Gt(this,qi);Gt(this,Jt,void 0);Gt(this,ii,void 0);Gt(this,Ki,void 0);Gt(this,ni,{});Ht(this,Ki,oo())}static get observedAttributes(){var D;return[...gu,...(D=Va.observedAttributes)!=null?D:[]]}get playerInitTime(){return pt(this,Ki)}get playerSoftwareName(){return pu}get playerSoftwareVersion(){return mu}get _hls(){var D;return(D=pt(this,Jt))==null?void 0:D.engine}get mux(){return this.nativeEl.mux}get src(){return this.getAttribute("src")}set src(D){D!==this.src&&(D==null?this.removeAttribute("src"):this.setAttribute("src",D))}get preload(){let D=this.getAttribute("preload");return D===""?"auto":["none","metadata","auto"].includes(D)?D:super.preload}set preload(D){D!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(D)?this.setAttribute("preload",D):this.removeAttribute("preload"))}get debug(){return this.getAttribute(Be.DEBUG)!=null}set debug(D){D!==this.debug&&(D?this.setAttribute(Be.DEBUG,""):this.removeAttribute(Be.DEBUG))}get disableCookies(){return this.hasAttribute(Be.DISABLE_COOKIES)}set disableCookies(D){D!==this.disableCookies&&(D?this.setAttribute(Be.DISABLE_COOKIES,""):this.removeAttribute(Be.DISABLE_COOKIES))}get startTime(){let D=this.getAttribute(Be.START_TIME);if(D==null)return;let B=+D;return Number.isNaN(B)?void 0:B}set startTime(D){D!==this.startTime&&(D==null?this.removeAttribute(Be.START_TIME):this.setAttribute(Be.START_TIME,`${D}`))}get playbackId(){var D;return(D=this.getAttribute(Be.PLAYBACK_ID))!=null?D:void 0}set playbackId(D){D!==this.playbackId&&(D?this.setAttribute(Be.PLAYBACK_ID,D):this.removeAttribute(Be.PLAYBACK_ID))}get envKey(){var D;return(D=this.getAttribute(Be.ENV_KEY))!=null?D:void 0}set envKey(D){D!==this.envKey&&(D?this.setAttribute(Be.ENV_KEY,D):this.removeAttribute(Be.ENV_KEY))}get beaconCollectionDomain(){var D;return(D=this.getAttribute(Be.BEACON_COLLECTION_DOMAIN))!=null?D:void 0}set beaconCollectionDomain(D){D!==this.beaconCollectionDomain&&(D?this.setAttribute(Be.BEACON_COLLECTION_DOMAIN,D):this.removeAttribute(Be.BEACON_COLLECTION_DOMAIN))}get streamType(){var D;return(D=this.getAttribute(Be.STREAM_TYPE))!=null?D:void 0}set streamType(D){D!==this.streamType&&(D?this.setAttribute(Be.STREAM_TYPE,D):this.removeAttribute(Be.STREAM_TYPE))}get preferPlayback(){let D=this.getAttribute(Be.PREFER_PLAYBACK);if(D===Ar.MSE||D===Ar.NATIVE)return D}set preferPlayback(D){D!==this.preferPlayback&&(D===Ar.MSE||D===Ar.NATIVE?this.setAttribute(Be.PREFER_PLAYBACK,D):this.removeAttribute(Be.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(B=>B.startsWith("metadata-")&&![Be.METADATA_URL].includes(B)).reduce((B,K)=>{let H=this.getAttribute(K);return H!=null&&(B[K.replace(/^metadata-/,"").replace(/-/g,"_")]=H),B},{}),...pt(this,ni)}}set metadata(D){Ht(this,ni,D!=null?D:{}),this.mux&&(console.info("Some metadata values may not be overridable at this time. Make sure you set all metadata to override before setting the src."),this.mux.emit("hb",pt(this,ni)))}load(){Ht(this,Jt,uo(this,this.nativeEl,pt(this,Jt)))}unload(){ja(this.nativeEl,pt(this,Jt)),Ht(this,Jt,void 0)}attributeChangedCallback(D,B,K){var H,J;switch(super.attributeChangedCallback(D,B,K),D){case"src":{let j=!!B,se=!!K;!j&&se?br(this,qi,Ya).call(this):j&&!se?this.unload():j&&se&&(this.unload(),br(this,qi,Ya).call(this));break}case"autoplay":if(K===B)break;(H=pt(this,Jt))==null||H.setAutoplay(this.autoplay);break;case"preload":if(K===B)break;(J=pt(this,Jt))==null||J.setPreload(K);break;case Be.PLAYBACK_ID:this.src=lo(K!=null?K:void 0);break;case Be.DEBUG:{let j=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=j);break}case Be.METADATA_URL:K&&fetch(K).then(j=>j.json()).then(j=>this.metadata=j).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${K}!`));break;default:break}}disconnectedCallback(){this.unload()}};Jt=new WeakMap,ii=new WeakMap,Ki=new WeakMap,ni=new WeakMap,qi=new WeakSet,Ya=async function(){pt(this,ii)||(await Ht(this,ii,Promise.resolve()),Ht(this,ii,null),this.load())};Qt.customElements.get("mux-audio")||(Qt.customElements.define("mux-audio",Hi),Qt.MuxAudioElement=Hi);var Uu=Hi;})();
|
|
56
69
|
/*!
|
|
57
70
|
* JavaScript Cookie v2.1.3
|
|
58
71
|
* https://github.com/js-cookie/js-cookie
|
|
@@ -62,7 +75,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
62
75
|
*/
|
|
63
76
|
/*!
|
|
64
77
|
* mux-embed
|
|
65
|
-
* @version 4.
|
|
66
|
-
* @copyright
|
|
78
|
+
* @version 4.24.0
|
|
79
|
+
* @copyright 2023 Mux, Inc
|
|
67
80
|
*/
|
|
68
81
|
//# sourceMappingURL=mux-audio.js.map
|