@mux/mux-video 0.13.0 → 0.13.2
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 +1 -1
- package/dist/index.mjs +1 -1
- package/dist/mux-video.js +31 -31
- package/dist/mux-video.js.map +4 -4
- package/dist/mux-video.mjs +31 -31
- package/dist/mux-video.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/mux-video.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";(()=>{var Hn=Object.create;var Kr=Object.defineProperty;var jn=Object.getOwnPropertyDescriptor;var Vn=Object.getOwnPropertyNames;var Yn=Object.getPrototypeOf,Xn=Object.prototype.hasOwnProperty;var zn=($,X,V)=>X in $?Kr($,X,{enumerable:!0,configurable:!0,writable:!0,value:V}):$[X]=V;var Ai=($,X)=>()=>(X||$((X={exports:{}}).exports,X),X.exports);var Qn=($,X,V,ie)=>{if(X&&typeof X=="object"||typeof X=="function")for(let Q of Vn(X))!Xn.call($,Q)&&Q!==V&&Kr($,Q,{get:()=>X[Q],enumerable:!(ie=jn(X,Q))||ie.enumerable});return $};var Er=($,X,V)=>(V=$!=null?Hn(Yn($)):{},Qn(X||!$||!$.__esModule?Kr(V,"default",{value:$,enumerable:!0}):V,$));var qt=($,X,V)=>(zn($,typeof X!="symbol"?X+"":X,V),V),Wr=($,X,V)=>{if(!X.has($))throw TypeError("Cannot "+V)};var he=($,X,V)=>(Wr($,X,"read from private field"),V?V.call($):X.get($)),Ae=($,X,V)=>{if(X.has($))throw TypeError("Cannot add the same private member more than once");X instanceof WeakSet?X.add($):X.set($,V)},Fe=($,X,V,ie)=>(Wr($,X,"write to private field"),ie?ie.call($,V):X.set($,V),V);var Ke=($,X,V)=>(Wr($,X,"access private method"),V);var Li=Ai((_r,Vr)=>{(function(){var $,X;$=this,X=function(){return function(){var V={80:function(B,T,O){B.exports=O(728).default},728:function(B,T,O){"use strict";O.d(T,{default:function(){return Wn}});var D=O(48),M=O.n(D),P=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(N){var C=16*Math.random()|0;return(N==="x"?C:3&C|8).toString(16)})},U=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},b=function(N){return N&&N.nodeName!==void 0?(N.muxId||(N.muxId=N.id||U()),N.muxId):N},A=function(N){var C;N&&N.nodeName!==void 0?N=b(C=N):C=document.querySelector(N);var w=C&&C.nodeName?C.nodeName.toLowerCase():"";return[C,N,w]},S=O(640),E=O.n(S),x=E().methodFactory;E().methodFactory=function(N,C,w){var G=x(N,C,w);return function(){for(var j=["[mux]"],J=0;J<arguments.length;J++)j.push(arguments[J]);G.apply(void 0,j)}},E().setLevel(E().getLevel());var f=E();function _(){return(M().doNotTrack||M().navigator&&M().navigator.doNotTrack)==="1"}var p={now:function(){var N=M().performance,C=N&&N.timing,w=C&&C.navigationStart,G=typeof w=="number"&&typeof N.now=="function"?w+N.now():Date.now();return Math.round(G)}},v=O(678),a=O.n(v),s=function(N){return n(N)[0]},n=function(N){if(typeof N!="string"||N==="")return["localhost"];var C,w=(N.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return w&&(C=(w.match(/[^\.]+\.[^\.]+$/)||[])[0]),[w,C]},d={exists:function(){var N=M().performance;return(N&&N.timing)!==void 0},domContentLoadedEventEnd:function(){var N=M().performance,C=N&&N.timing;return C&&C.domContentLoadedEventEnd},navigationStart:function(){var N=M().performance,C=N&&N.timing;return C&&C.navigationStart}};function l(N,C,w){w=w===void 0?1:w,N[C]=N[C]||0,N[C]+=w}var i=["x-cdn","content-type","x-request-id"];function u(N){var C={};return(N=N||"").trim().split(/[\r\n]+/).forEach(function(w){if(w){var G=w.split(": "),j=G.shift();j&&(i.indexOf(j.toLowerCase())>=0||j.toLowerCase().indexOf("x-litix-")===0)&&(C[j]=G.join(": "))}}),C}var g=function(N){var C={};for(var w in N){var G=N[w];G["DATA-ID"].search("io.litix.data.")!==-1&&(C[G["DATA-ID"].replace("io.litix.data.","")]=G.VALUE)}return C};function c(N,C){var w=Object.keys(N);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(N);C&&(G=G.filter(function(j){return Object.getOwnPropertyDescriptor(N,j).enumerable})),w.push.apply(w,G)}return w}function m(N){for(var C=1;C<arguments.length;C++){var w=arguments[C]!=null?arguments[C]:{};C%2?c(Object(w),!0).forEach(function(G){e(N,G,w[G])}):Object.getOwnPropertyDescriptors?Object.defineProperties(N,Object.getOwnPropertyDescriptors(w)):c(Object(w)).forEach(function(G){Object.defineProperty(N,G,Object.getOwnPropertyDescriptor(w,G))})}return N}function e(N,C,w){return C in N?Object.defineProperty(N,C,{value:w,enumerable:!0,configurable:!0,writable:!0}):N[C]=w,N}var r=function(N){if(!N)return{};var C=d.navigationStart(),w=N.loading,G=w?w.start:N.trequest,j=w?w.first:N.tfirst,J=w?w.end:N.tload;return{bytesLoaded:N.total,requestStart:Math.round(C+G),responseStart:Math.round(C+j),responseEnd:Math.round(C+J)}},t=function(N){if(N&&typeof N.getAllResponseHeaders=="function")return u(N.getAllResponseHeaders())};function o(N,C){var w=Object.keys(N);if(Object.getOwnPropertySymbols){var G=Object.getOwnPropertySymbols(N);C&&(G=G.filter(function(j){return Object.getOwnPropertyDescriptor(N,j).enumerable})),w.push.apply(w,G)}return w}function y(N){for(var C=1;C<arguments.length;C++){var w=arguments[C]!=null?arguments[C]:{};C%2?o(Object(w),!0).forEach(function(G){h(N,G,w[G])}):Object.getOwnPropertyDescriptors?Object.defineProperties(N,Object.getOwnPropertyDescriptors(w)):o(Object(w)).forEach(function(G){Object.defineProperty(N,G,Object.getOwnPropertyDescriptor(w,G))})}return N}function h(N,C,w){return C in N?Object.defineProperty(N,C,{value:w,enumerable:!0,configurable:!0,writable:!0}):N[C]=w,N}var L=function(N,C){if(!N||typeof N.getRequests!="function")return{};var w=N.getRequests({state:"executed"});if(w.length===0)return{};var G,j=w[w.length-1],J=s(j.url),z=j.url,Z=j.bytesLoaded,ne=new Date(j.requestStartDate).getTime(),te=new Date(j.firstByteDate).getTime(),oe=new Date(j.requestEndDate).getTime(),Te=isNaN(j.duration)?0:j.duration,ge=typeof C.getMetricsFor=="function"?C.getMetricsFor(j.mediaType).HttpList:C.getDashMetrics().getHttpRequests(j.mediaType);return ge.length>0&&(G=u(ge[ge.length-1]._responseHeaders||"")),{requestStart:ne,requestResponseStart:te,requestResponseEnd:oe,requestBytesLoaded:Z,requestResponseHeaders:G,requestMediaDuration:Te,requestHostname:J,requestUrl:z}},R=function(N,C){var w=C.getQualityFor(N),G=C.getCurrentTrackFor(N).bitrateList;return G?{currentLevel:w,renditionWidth:G[w].width||null,renditionHeight:G[w].height||null,renditionBitrate:G[w].bandwidth}:{}},I=function(N){var C;return(C=N.match(/.*codecs\*?="(.*)"/))===null||C===void 0?void 0:C[1]};function k(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var F=0,W=function(){function N(){(function(j,J){if(!(j instanceof J))throw new TypeError("Cannot call a class as a function")})(this,N)}var C,w,G;return C=N,w=[{key:"on",value:function(j,J,z){return J._eventEmitterGuid=J._eventEmitterGuid||++F,this._listeners=this._listeners||{},this._listeners[j]=this._listeners[j]||[],z&&(J=J.bind(z)),this._listeners[j].push(J),J}},{key:"off",value:function(j,J){var z=this._listeners&&this._listeners[j];z&&z.forEach(function(Z,ne){Z._eventEmitterGuid===J._eventEmitterGuid&&z.splice(ne,1)})}},{key:"one",value:function(j,J,z){var Z=this;J._eventEmitterGuid=J._eventEmitterGuid||++F;var ne=function te(){Z.off(j,te),J.apply(z||this,arguments)};ne._eventEmitterGuid=J._eventEmitterGuid,this.on(j,ne)}},{key:"emit",value:function(j,J){var z=this;if(this._listeners){J=J||{};var Z=this._listeners["before*"]||[],ne=this._listeners[j]||[],te=this._listeners["after"+j]||[],oe=function(Te,ge){(Te=Te.slice()).forEach(function(Ee){Ee.call(z,{type:j},ge)})};oe(Z,J),oe(ne,J),oe(te,J)}}}],w&&k(C.prototype,w),G&&k(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}(),K=W;function H(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var Y=function(){function N(j){var J=this;(function(z,Z){if(!(z instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,j.on("playing",function(){J._playheadShouldBeProgressing=!0}),j.on("play",this._startPlaybackHeartbeatInterval.bind(this)),j.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),j.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),j.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),j.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),j.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),j.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),j.on("seeked",function(){j.data.player_is_paused?J._stopPlaybackHeartbeatInterval():J._startPlaybackHeartbeatInterval()}),j.on("timeupdate",function(){J._playbackHeartbeatInterval!==null&&j.emit("playbackheartbeat")}),j.on("devicesleep",function(z,Z){J._playbackHeartbeatInterval!==null&&(M().clearInterval(J._playbackHeartbeatInterval),j.emit("playbackheartbeatend",{viewer_time:Z.viewer_time}),J._playbackHeartbeatInterval=null)})}var C,w,G;return C=N,(w=[{key:"_startPlaybackHeartbeatInterval",value:function(){var j=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=M().setInterval(function(){j.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(M().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&H(C.prototype,w),G&&H(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function q(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function ee(N,C,w){return C&&q(N.prototype,C),w&&q(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var ae=ee(function N(C){var w=this;(function(G,j){if(!(G instanceof j))throw new TypeError("Cannot call a class as a function")})(this,N),C.on("viewinit",function(){w.viewErrored=!1}),C.on("error",function(G,j){try{var J=C.errorTranslator({player_error_code:j.player_error_code,player_error_message:j.player_error_message,player_error_context:j.player_error_context});J?(C.data.player_error_code=J.player_error_code||j.player_error_code,C.data.player_error_message=J.player_error_message||j.player_error_message,C.data.player_error_context=J.player_error_context||j.player_error_context,w.viewErrored=!0):(delete C.data.player_error_code,delete C.data.player_error_message,delete C.data.player_error_context)}catch(z){C.mux.log.warn("Exception in error translator callback.",z),w.viewErrored=!0}})});function re(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var se=function(){function N(j){(function(J,z){if(!(J instanceof z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,this._watchTimeTrackerLastCheckedTime=null,j.on("playbackheartbeat",this._updateWatchTime.bind(this)),j.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var C,w,G;return C=N,(w=[{key:"_updateWatchTime",value:function(j,J){var z=J.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=z),l(this.pm.data,"view_watch_time",z-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=z}},{key:"_clearWatchTimeState",value:function(j,J){this._updateWatchTime(j,J),this._watchTimeTrackerLastCheckedTime=null}}])&&re(C.prototype,w),G&&re(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function le(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var de=function(){function N(j){(function(J,z){if(!(J instanceof z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,this._playbackTimeTrackerLastPlayheadPosition=-1,j.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),j.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),j.on("seeking",this._clearPlaybackTimeState.bind(this))}var C,w,G;return C=N,(w=[{key:"_updatePlaybackTime",value:function(){var j=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&j>this._playbackTimeTrackerLastPlayheadPosition){var J=j-this._playbackTimeTrackerLastPlayheadPosition;J<=1e3&&l(this.pm.data,"view_content_playback_time",J)}this._playbackTimeTrackerLastPlayheadPosition=j}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&le(C.prototype,w),G&&le(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function ue(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var fe=function(){function N(j){(function(z,Z){if(!(z instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j;var J=this._updatePlayheadTime.bind(this);j.on("playbackheartbeat",J),j.on("playbackheartbeatend",J),j.on("timeupdate",J),j.on("destroy",function(){j.off("timeupdate",J)})}var C,w,G;return C=N,(w=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(j,J){var z=this,Z=function(){z.pm.currentFragmentPDT&&z.pm.currentFragmentStart&&(z.pm.data.player_program_time=z.pm.currentFragmentPDT+z.pm.data.player_playhead_time-z.pm.currentFragmentStart)};if(J&&J.player_playhead_time)this.pm.data.player_playhead_time=J.player_playhead_time,Z(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var ne=this.pm.getPlayheadTime();ne!==void 0&&(this.pm.data.player_playhead_time=ne,Z(),this._updateMaxPlayheadPosition())}}}])&&ue(C.prototype,w),G&&ue(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function ce(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function be(N,C,w){return C&&ce(N.prototype,C),w&&ce(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var Pe=be(function N(C){if(function(J,z){if(!(J instanceof z))throw new TypeError("Cannot call a class as a function")}(this,N),!C.disableRebufferTracking){var w,G=function(J,z){j(z),w=void 0},j=function(J){if(w){var z=J.viewer_time-w;l(C.data,"view_rebuffer_duration",z),w=J.viewer_time}C.data.view_watch_time>=0&&C.data.view_rebuffer_count>0&&(C.data.view_rebuffer_frequency=C.data.view_rebuffer_count/C.data.view_watch_time,C.data.view_rebuffer_percentage=C.data.view_rebuffer_duration/C.data.view_watch_time)};C.on("playbackheartbeat",function(J,z){return j(z)}),C.on("rebufferstart",function(J,z){w||(l(C.data,"view_rebuffer_count",1),w=z.viewer_time,C.one("rebufferend",G))}),C.on("viewinit",function(){w=void 0,C.off("rebufferend",G)})}});function we(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var pe=function(){function N(j){var J=this;(function(z,Z){if(!(z instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,j.disableRebufferTracking||j.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,j.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),j.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),j.on("seeking",function(){J._cleanupRebufferTracker(null,{viewer_time:p.now()})}))}var C,w,G;return C=N,w=[{key:"_checkIfRebuffering",value:function(j,J){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(j,J);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var z=J.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&z>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=J.viewer_time}else this._cleanupRebufferTracker(j,J,!0);else this._prepareRebufferTrackerState(J.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(j){this._lastCheckedTime=j,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=j}},{key:"_cleanupRebufferTracker",value:function(j,J){var z=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:J.viewer_time});else{if(this._lastCheckedTime===null)return;var Z=this.pm.data.player_playhead_time-this._lastPlayheadTime,ne=J.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Z>0&&ne-Z>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+ne-Z}))}z?this._prepareRebufferTrackerState(J.viewer_time):this._clearRebufferTrackerState()}}],w&&we(C.prototype,w),G&&we(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}(),Me=pe;function Re(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var ke=function(){function N(j){var J=this;(function(z,Z){if(!(z instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,j.on("viewinit",function(){var z=j.data,Z=z.view_id;if(!z.view_program_changed){var ne=function(te,oe){var Te=oe.viewer_time;te.type==="playing"&&j.data.view_time_to_first_frame===void 0?J.calculateTimeToFirstFrame(Te||p.now(),Z):te.type!=="adplaying"||j.data.view_time_to_first_frame!==void 0&&!J._inPrerollPosition()||J.calculateTimeToFirstFrame(Te||p.now(),Z)};j.one("playing",ne),j.one("adplaying",ne),j.one("viewend",function(){j.off("playing",ne),j.off("adplaying",ne)})}})}var C,w,G;return C=N,(w=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(j,J){J===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:j}),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))}}])&&Re(C.prototype,w),G&&Re(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function Le(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function Ue(N,C,w){return C&&Le(N.prototype,C),w&&Le(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var He=Ue(function N(C){var w=this;(function(G,j){if(!(G instanceof j))throw new TypeError("Cannot call a class as a function")})(this,N),C.on("viewinit",function(){w._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(G){C.on(G,function(){if(w._lastPlayheadPosition>=0&&C.data.player_playhead_time>=0&&w._lastPlayerWidth>=0&&w._lastSourceWidth>0&&w._lastPlayerHeight>=0&&w._lastSourceHeight>0){var j=C.data.player_playhead_time-w._lastPlayheadPosition;if(j<0)return void(w._lastPlayheadPosition=-1);var J=Math.min(w._lastPlayerWidth/w._lastSourceWidth,w._lastPlayerHeight/w._lastSourceHeight),z=Math.max(0,J-1),Z=Math.max(0,1-J);C.data.view_max_upscale_percentage=Math.max(C.data.view_max_upscale_percentage||0,z),C.data.view_max_downscale_percentage=Math.max(C.data.view_max_downscale_percentage||0,Z),l(C.data,"view_total_content_playback_time",j),l(C.data,"view_total_upscaling",z*j),l(C.data,"view_total_downscaling",Z*j)}w._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(G){C.on(G,function(){w._lastPlayheadPosition=C.data.player_playhead_time,w._lastPlayerWidth=C.data.player_width,w._lastPlayerHeight=C.data.player_height,w._lastSourceWidth=C.data.video_source_width,w._lastSourceHeight=C.data.video_source_height})})});function Be(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function Je(N,C,w){return C&&Be(N.prototype,C),w&&Be(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var qe=Je(function N(C){var w=this;(function(G,j){if(!(G instanceof j))throw new TypeError("Cannot call a class as a function")})(this,N),this.isSeeking=!1,C.on("seeking",function(G,j){a()(C.data,j),w._lastSeekingTime=p.now(),w.isSeeking===!1&&(w.isSeeking=!0,C.send("seeking"))}),C.on("seeked",function(){w.isSeeking=!1;var G=w._lastSeekingTime||p.now(),j=p.now()-G;l(C.data,"view_seek_count",1),l(C.data,"view_seek_duration",j);var J=C.data.view_max_seek_time||0;C.data.view_max_seek_time=Math.max(J,j)}),C.on("viewend",function(){w.isSeeking=!1})});function st(N,C){return function(w){if(Array.isArray(w))return w}(N)||function(w,G){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var J,z,Z=[],ne=!0,te=!1;try{for(j=j.call(w);!(ne=(J=j.next()).done)&&(Z.push(J.value),!G||Z.length!==G);ne=!0);}catch(oe){te=!0,z=oe}finally{try{ne||j.return==null||j.return()}finally{if(te)throw z}}return Z}}(N,C)||function(w,G){if(w){if(typeof w=="string")return Ze(w,G);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?Ze(w,G):void 0}}(N,C)||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 Ze(N,C){(C==null||C>N.length)&&(C=N.length);for(var w=0,G=new Array(C);w<C;w++)G[w]=N[w];return G}function ot(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}var lt=function(N,C){N.push(C),N.sort(function(w,G){return w.viewer_time-G.viewer_time})},tt=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],je=function(){function N(j){var J=this;(function(Z,ne){if(!(Z instanceof ne))throw new TypeError("Cannot call a class as a function")})(this,N),this.pm=j,j.on("viewinit",function(){J.isAdBreak=!1,J._currentAdRequestNumber=0,J._currentAdResponseNumber=0,J._adRequests=[],J._adResponses=[],J._adHasPlayed=!1,J._wouldBeNewAdPlay=!0,J._prerollPlayTime=void 0}),tt.forEach(function(Z){return j.on(Z,J._updateAdData.bind(J))});var z=function(){J.isAdBreak=!1};j.on("adbreakstart",function(){J.isAdBreak=!0}),j.on("play",z),j.on("playing",z),j.on("viewend",z),j.on("adrequest",function(Z,ne){ne=a()({ad_request_id:"generatedAdRequestId"+J._currentAdRequestNumber++},ne),lt(J._adRequests,ne),l(j.data,"view_ad_request_count"),J.inPrerollPosition()&&(j.data.view_preroll_requested=!0,J._adHasPlayed||l(j.data,"view_preroll_request_count"))}),j.on("adresponse",function(Z,ne){ne=a()({ad_request_id:"generatedAdRequestId"+J._currentAdResponseNumber++},ne),lt(J._adResponses,ne);var te=J.findAdRequest(ne.ad_request_id);te&&l(j.data,"view_ad_request_time",Math.max(0,ne.viewer_time-te.viewer_time))}),j.on("adplay",function(Z,ne){J._adHasPlayed=!0,J._wouldBeNewAdPlay&&(J._wouldBeNewAdPlay=!1,l(j.data,"view_ad_played_count")),J.inPrerollPosition()&&!j.data.view_preroll_played&&(j.data.view_preroll_played=!0,J._adRequests.length>0&&(j.data.view_preroll_request_time=Math.max(0,ne.viewer_time-J._adRequests[0].viewer_time)),j.data.view_start&&(j.data.view_startup_preroll_request_time=Math.max(0,ne.viewer_time-j.data.view_start)),J._prerollPlayTime=ne.viewer_time)}),j.on("adplaying",function(Z,ne){J.inPrerollPosition()&&j.data.view_preroll_load_time===void 0&&J._prerollPlayTime!==void 0&&(j.data.view_preroll_load_time=ne.viewer_time-J._prerollPlayTime,j.data.view_startup_preroll_load_time=ne.viewer_time-J._prerollPlayTime)}),j.on("adended",function(){J._wouldBeNewAdPlay=!0}),j.on("aderror",function(){J._wouldBeNewAdPlay=!0})}var C,w,G;return C=N,(w=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(j){for(var J=0;J<this._adRequests.length;J++)if(this._adRequests[J].ad_request_id===j)return this._adRequests[J]}},{key:"_updateAdData",value:function(j,J){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&J.ad_tag_url){var z=st(n(J.ad_tag_url),2),Z=z[0],ne=z[1];this.pm.data.view_preroll_ad_tag_domain=ne,this.pm.data.view_preroll_ad_tag_hostname=Z}if(!this.pm.data.view_preroll_ad_asset_hostname&&J.ad_asset_url){var te=st(n(J.ad_asset_url),2),oe=te[0],Te=te[1];this.pm.data.view_preroll_ad_asset_domain=Te,this.pm.data.view_preroll_ad_asset_hostname=oe}}}}])&&ot(C.prototype,w),G&&ot(C,G),Object.defineProperty(C,"prototype",{writable:!1}),N}();function Ve(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function rt(N,C,w){return C&&Ve(N.prototype,C),w&&Ve(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var gt=rt(function N(C){var w,G;(function(Z,ne){if(!(Z instanceof ne))throw new TypeError("Cannot call a class as a function")})(this,N);var j=function(){C.disableRebufferTracking||w&&(l(C.data,"view_waiting_rebuffer_duration",p.now()-w),w=!1,M().clearInterval(G))},J=!1,z=function(){J=!1,j()};C.on("waiting",function(){J&&(C.disableRebufferTracking||(l(C.data,"view_waiting_rebuffer_count",1),w=p.now(),G=M().setInterval(function(){if(w){var Z=p.now();l(C.data,"view_waiting_rebuffer_duration",Z-w),w=Z}},250)))}),C.on("playing",function(){j(),J=!0}),C.on("pause",z),C.on("seeking",z)});function Ne(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function it(N,C,w){return C&&Ne(N.prototype,C),w&&Ne(N,w),Object.defineProperty(N,"prototype",{writable:!1}),N}var nt=it(function N(C){var w=this;(function(J,z){if(!(J instanceof z))throw new TypeError("Cannot call a class as a function")})(this,N);var G=function(){w.lastWallClockTime=p.now(),C.on("before*",j)},j=function(J){var z=p.now(),Z=w.lastWallClockTime;w.lastWallClockTime=z,z-Z>3e4&&(C.emit("devicesleep",{viewer_time:Z}),a()(C.data,{viewer_time:Z}),C.send("devicesleep"),C.emit("devicewake",{viewer_time:z}),a()(C.data,{viewer_time:z}),C.send("devicewake"))};C.one("playbackheartbeat",G),C.on("playbackheartbeatend",function(){C.off("before*",j),C.one("playbackheartbeat",G)})}),Lt=O(375),At=O(655),Dt=O.n(At),Gt="muxData",Pt=function(){var N;try{N=Lt.parse(Dt().get(Gt)||"")}catch{N={}}return N},hr=function(N){try{Dt().set(Gt,Lt.stringify(N),{expires:7300})}catch{}},Ht=function(){var N=Pt();return N.mux_viewer_id=N.mux_viewer_id||P(),N.msn=N.msn||Math.random(),hr(N),{mux_viewer_id:N.mux_viewer_id,mux_sample_number:N.msn}};function Pr(N,C){var w=C.beaconCollectionDomain,G=C.beaconDomain;if(w)return"https://"+w;var j=G||"litix.io";return(N=N||"inferred").match(/^[a-z0-9]+$/)?"https://"+N+"."+j:"https://img.litix.io/a.gif"}var jt=function(){var N;switch(Ot()){case"cellular":N="cellular";break;case"ethernet":N="wired";break;case"wifi":N="wifi";break;case void 0:break;default:N="other"}return N},Ot=function(){var N=M().navigator,C=N&&(N.connection||N.mozConnection||N.webkitConnection);return C&&C.type};jt.getConnectionFromAPI=Ot;var ht=jt,vr=gr({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"}),Vt=gr({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 gr(N){var C={};for(var w in N)N.hasOwnProperty(w)&&(C[N[w]]=w);return C}function Yt(N){var C={},w={};return Object.keys(N).forEach(function(G){var j=!1;if(N.hasOwnProperty(G)&&N[G]!==void 0){var J=G.split("_"),z=J[0],Z=vr[z];Z||(f.info("Data key word `"+J[0]+"` not expected in "+G),Z=z+"_"),J.splice(1).forEach(function(ne){ne==="url"&&(j=!0),Vt[ne]?Z+=Vt[ne]:Number(ne)&&Math.floor(Number(ne))===Number(ne)?Z+=ne:(f.info("Data key word `"+ne+"` not expected in "+G),Z+="_"+ne+"_")}),j?w[Z]=N[G]:C[Z]=N[G]}}),a()(C,w)}var Rr={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Ir=["hb","requestcompleted","requestfailed","requestcanceled"],Or="https://img.litix.io",vt=function(N){var C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=N||Or,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=a()({},Rr,C)};vt.prototype.queueEvent=function(N,C){var w=a()({},C);return(this._eventQueue.length<=this._options.maxQueueLength||N==="eventrateexceeded")&&(this._eventQueue.push(w),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},vt.prototype.flushEvents=function(){var N=arguments.length>0&&arguments[0]!==void 0&&arguments[0];N&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},vt.prototype.destroy=function(){var N=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,N?this._clearBeaconQueue():this.flushEvents(),M().clearTimeout(this._sendTimeout)},vt.prototype._clearBeaconQueue=function(){var N=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,C=this._eventQueue.slice(N);N>0&&a()(C[C.length-1],Yt({mux_view_message:"event queue truncated"}));var w=this._createPayload(C);Xt(this._beaconUrl,w,!0,function(){})},vt.prototype._sendBeaconQueue=function(){var N=this;if(!this._postInFlight){var C=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var w=this._createPayload(C),G=p.now();Xt(this._beaconUrl,w,!1,function(j,J){J?(N._eventQueue=C.concat(N._eventQueue),N._failureCount+=1,f.info("Error sending beacon: "+J)):N._failureCount=0,N._roundTripTime=p.now()-G,N._postInFlight=!1})}},vt.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var N=Math.pow(2,this._failureCount-1);return(1+(N*=Math.random()))*this._options.baseTimeBetweenBeacons},vt.prototype._startBeaconSending=function(){var N=this;M().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=M().setTimeout(function(){N._eventQueue.length&&N._sendBeaconQueue(),N._startBeaconSending()},this._getNextBeaconTime()))},vt.prototype._createPayload=function(N){var C,w,G,j=this,J={transmission_timestamp:Math.round(p.now())};this._roundTripTime&&(J.rtt_ms=Math.round(this._roundTripTime));var z=function(){C=JSON.stringify({metadata:J,events:w||N}),G=C.length/1024},Z=function(){return G<=j._options.maxPayloadKBSize};return z(),Z()||(f.info("Payload size is too big ("+G+" kb). Removing unnecessary events."),w=N.filter(function(ne){return Ir.indexOf(ne.e)===-1}),z()),Z()||(f.info("Payload size still too big ("+G+" kb). Cropping fields.."),w.forEach(function(ne){for(var te in ne){var oe=ne[te];typeof oe=="string"&&oe.length>51200&&(ne[te]=oe.substring(0,51200))}}),z()),C};var Xt=function(N,C,w,G){if(w&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(N,C))G();else if(M().fetch)M().fetch(N,{method:"POST",body:C,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(J){return G(null,J.ok?null:"Error")}).catch(function(J){return G(null,J)});else{if(M().XMLHttpRequest){var j=new(M()).XMLHttpRequest;return j.onreadystatechange=function(){if(j.readyState===4)return G(null,j.status!==200?"error":void 0)},j.open("POST",N),j.setRequestHeader("Content-Type","text/plain"),void j.send(C)}G()}},Cr=vt;function Mr(N,C){return function(w){if(Array.isArray(w))return w}(N)||function(w,G){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var J,z,Z=[],ne=!0,te=!1;try{for(j=j.call(w);!(ne=(J=j.next()).done)&&(Z.push(J.value),!G||Z.length!==G);ne=!0);}catch(oe){te=!0,z=oe}finally{try{ne||j.return==null||j.return()}finally{if(te)throw z}}return Z}}(N,C)||function(w,G){if(w){if(typeof w=="string")return hi(w,G);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?hi(w,G):void 0}}(N,C)||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 yi(N,C){(C==null||C>N.length)&&(C=N.length);for(var w=0,G=new Array(C);w<C;w++)G[w]=N[w];return G}function Ei(N,C){for(var w=0;w<C.length;w++){var G=C[w];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(N,G.key,G)}}function kr(N,C){return kr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,G){return w.__proto__=G,w},kr(N,C)}function mn(N){var C=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var w,G=pr(N);if(C){var j=pr(this).constructor;w=Reflect.construct(G,arguments,j)}else w=G.apply(this,arguments);return pn(this,w)}}function pn(N,C){if(C&&(wr(C)==="object"||typeof C=="function"))return C;if(C!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ye(N)}function Ye(N){if(N===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return N}function pr(N){return pr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(C){return C.__proto__||Object.getPrototypeOf(C)},pr(N)}var yn=["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"],En=function(N){(function(z,Z){if(typeof Z!="function"&&Z!==null)throw new TypeError("Super expression must either be null or a function");z.prototype=Object.create(Z&&Z.prototype,{constructor:{value:z,writable:!0,configurable:!0}}),Object.defineProperty(z,"prototype",{writable:!1}),Z&&kr(z,Z)})(J,N);var C,w,G,j=mn(J);function J(z,Z,ne){var te;(function(ve,_e){if(!(ve instanceof _e))throw new TypeError("Cannot call a class as a function")})(this,J),(te=j.call(this)).DOM_CONTENT_LOADED_EVENT_END=d.domContentLoadedEventEnd(),te.NAVIGATION_START=d.navigationStart(),te.mux=z,te.id=Z,(ne=a()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(ve){return ve}},ne)).data=ne.data||{},ne.data.property_key&&(ne.data.env_key=ne.data.property_key,delete ne.data.property_key),f.setLevel(ne.debug?"debug":"warn"),te.getPlayheadTime=ne.getPlayheadTime,te.getStateData=ne.getStateData||function(){return{}},te.getAdData=ne.getAdData||function(){},te.minimumRebufferDuration=ne.minimumRebufferDuration,te.sustainedRebufferThreshold=ne.sustainedRebufferThreshold,te.playbackHeartbeatTime=ne.playbackHeartbeatTime,te.disableRebufferTracking=ne.disableRebufferTracking,te.disableRebufferTracking&&te.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."),te.disablePlayheadRebufferTracking=ne.disablePlayheadRebufferTracking,te.errorTranslator=ne.errorTranslator,te.playbackEventDispatcher=new dn(z,ne.data.env_key,ne),te.data={player_instance_id:P(),mux_sample_rate:ne.sampleRate,beacon_domain:ne.beaconCollectionDomain?ne.beaconCollectionDomain:ne.beaconDomain},te.data.view_sequence_number=1,te.data.player_sequence_number=1,te.oldEmit=te.emit,te.emit=function(ve,_e){_e=a()({viewer_time:this.mux.utils.now()},_e),this.oldEmit(ve,_e)};var oe=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Ye(te));te.on("viewinit",function(ve,_e){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),a()(this.data,_e),this._initializeViewData(),this.one("play",oe),this.one("adbreakstart",oe)});var Te=function(ve){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",ve)}.bind(Ye(te));if(te.on("videochange",function(ve,_e){Te(_e)}),te.on("programchange",function(ve,_e){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."),Te(a()(_e,{view_program_changed:!0})),oe(),this.emit("play"),this.emit("playing")}),te.on("fragmentchange",function(ve,_e){this.currentFragmentPDT=_e.currentFragmentPDT,this.currentFragmentStart=_e.currentFragmentStart}),te.on("destroy",te.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ge=function(){var ve=te.data.view_start!==void 0;te.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",ve&&te.mux.WINDOW_HIDDEN&&(te.data.player_is_paused||te.emit("hb"))};window.addEventListener("visibilitychange",ge,!1);var Ee=function(ve){ve.persisted||te.destroy()};window.addEventListener("pagehide",Ee,!1),te.on("destroy",function(){window.removeEventListener("visibilitychange",ge),window.removeEventListener("pagehide",Ee)})}return te.on("playerready",function(ve,_e){a()(this.data,_e)}),yn.forEach(function(ve){te.on(ve,function(_e,Ce){ve.indexOf("ad")!==0&&this._updateStateData(),a()(this.data,Ce),this._sanitizeData()}),te.on("after"+ve,function(){(ve!=="error"||this.errorTracker.viewErrored)&&this.send(ve)})}),te.on("viewend",function(ve,_e){a()(te.data,_e)}),te.one("playerready",function(ve){var _e=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=_e-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}),te.longResumeTracker=new vn(Ye(te)),te.errorTracker=new ae(Ye(te)),new nt(Ye(te)),te.seekingTracker=new qe(Ye(te)),te.playheadTime=new fe(Ye(te)),te.playbackHeartbeat=new Y(Ye(te)),new He(Ye(te)),te.watchTimeTracker=new se(Ye(te)),new de(Ye(te)),te.adTracker=new je(Ye(te)),new Me(Ye(te)),new Pe(Ye(te)),new ke(Ye(te)),new gt(Ye(te)),new cn(Ye(te)),ne.hlsjs&&te.addHLSJS(ne),ne.dashjs&&te.addDashJS(ne),te.emit("viewinit",ne.data),te}return C=J,w=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(z){var Z=a()({},this.data);if(Z.video_source_is_live===void 0&&(Z.player_source_duration===1/0||Z.video_source_duration===1/0?Z.video_source_is_live=!0:(Z.player_source_duration>0||Z.video_source_duration>0)&&(Z.video_source_is_live=!1)),Z.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(Te){Z[Te]=void 0}),Z.video_source_url=Z.video_source_url||Z.player_source_url,Z.video_source_url){var ne=gn(n(Z.video_source_url),2),te=ne[0],oe=ne[1];Z.video_source_domain=oe,Z.video_source_hostname=te}delete Z.ad_request_id,this.playbackEventDispatcher.send(z,Z),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){a()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var z=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Z){var ne=parseInt(z.data[Z],10);z.data[Z]=isNaN(ne)?void 0:ne}),["player_source_url","video_source_url"].forEach(function(Z){if(z.data[Z]){var ne=z.data[Z].toLowerCase();ne.indexOf("data:")!==0&&ne.indexOf("blob:")!==0||(z.data[Z]="MSE style URL")}})}},{key:"_resetVideoData",value:function(z,Z){var ne=this;Object.keys(this.data).forEach(function(te){te.indexOf("video_")===0&&delete ne.data[te]})}},{key:"_resetViewData",value:function(){var z=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("view_")===0&&delete z.data[Z]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(z,Z){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var z=this,Z=this.data.view_id=P(),ne=function(){Z===z.data.view_id&&l(z.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",ne):ne()}},{key:"_restartHeartBeat",value:function(){var z=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){z.data.player_is_paused||z.emit("hb")},1e4))}},{key:"addHLSJS",value:function(z){z.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=z.hlsjs,function(Z,ne,te){var oe=arguments.length>4?arguments[4]:void 0,Te=Z.log,ge=Z.utils.secondsToMs,Ee=function(Oe){var ye,Se=parseInt(oe.version);return Se===1&&Oe.programDateTime!==null&&(ye=Oe.programDateTime),Se===0&&Oe.pdt!==null&&(ye=Oe.pdt),ye};if(d.exists()){var ve=function(Oe,ye){return Z.emit(ne,Oe,ye)},_e=function(Oe,ye){var Se=ye.levels,me=ye.audioTracks,xe=ye.url,We=ye.stats,Ge=ye.networkDetails,dt=ye.sessionData,at={},pt={};Se.forEach(function(_t,Jt){at[Jt]={width:_t.width,height:_t.height,bitrate:_t.bitrate,attrs:_t.attrs}}),me.forEach(function(_t,Jt){pt[Jt]={name:_t.name,language:_t.lang,bitrate:_t.bitrate}});var ft=r(We),Et=ft.bytesLoaded,Xe=ft.requestStart,yt=ft.responseStart,Br=ft.responseEnd;ve("requestcompleted",m(m({},g(dt)),{},{request_event_type:Oe,request_bytes_loaded:Et,request_start:Xe,request_response_start:yt,request_response_end:Br,request_type:"manifest",request_hostname:s(xe),request_response_headers:t(Ge),request_rendition_lists:{media:at,audio:pt,video:{}}}))};te.on(oe.Events.MANIFEST_LOADED,_e);var Ce=function(Oe,ye){var Se=ye.details,me=ye.level,xe=ye.networkDetails,We=ye.stats,Ge=r(We),dt=Ge.bytesLoaded,at=Ge.requestStart,pt=Ge.responseStart,ft=Ge.responseEnd,Et=Se.fragments[Se.fragments.length-1],Xe=Ee(Et)+ge(Et.duration);ve("requestcompleted",{request_event_type:Oe,request_bytes_loaded:dt,request_start:at,request_response_start:pt,request_response_end:ft,request_current_level:me,request_type:"manifest",request_hostname:s(Se.url),request_response_headers:t(xe),video_holdback:Se.holdBack&&ge(Se.holdBack),video_part_holdback:Se.partHoldBack&&ge(Se.partHoldBack),video_part_target_duration:Se.partTarget&&ge(Se.partTarget),video_target_duration:Se.targetduration&&ge(Se.targetduration),video_source_is_live:Se.live,player_manifest_newest_program_time:isNaN(Xe)?void 0:Xe})};te.on(oe.Events.LEVEL_LOADED,Ce);var ze=function(Oe,ye){var Se=ye.details,me=ye.networkDetails,xe=ye.stats,We=r(xe),Ge=We.bytesLoaded,dt=We.requestStart,at=We.responseStart,pt=We.responseEnd;ve("requestcompleted",{request_event_type:Oe,request_bytes_loaded:Ge,request_start:dt,request_response_start:at,request_response_end:pt,request_type:"manifest",request_hostname:s(Se.url),request_response_headers:t(me)})};te.on(oe.Events.AUDIO_TRACK_LOADED,ze);var Qe=function(Oe,ye){var Se=ye.stats,me=ye.networkDetails,xe=ye.frag;Se=Se||xe.stats;var We=r(Se),Ge=We.bytesLoaded,dt=We.requestStart,at=We.responseStart,pt=We.responseEnd,ft=t(me),Et=ft==null?void 0:ft["x-request-id"],Xe={request_event_type:Oe,request_bytes_loaded:Ge,request_start:dt,request_response_start:at,request_response_end:pt,request_hostname:me?s(me.responseURL):void 0,request_id:Et,request_response_headers:ft,request_media_duration:xe.duration,request_url:me==null?void 0:me.responseURL};xe.type==="main"?(Xe.request_type="media",Xe.request_current_level=xe.level,Xe.request_video_width=(te.levels[xe.level]||{}).width,Xe.request_video_height=(te.levels[xe.level]||{}).height,Xe.request_labeled_bitrate=(te.levels[xe.level]||{}).bitrate):Xe.request_type=xe.type,ve("requestcompleted",Xe)};te.on(oe.Events.FRAG_LOADED,Qe);var ut=function(Oe,ye){var Se=ye.frag,me=Se.start,xe={currentFragmentPDT:Ee(Se),currentFragmentStart:ge(me)};ve("fragmentchange",xe)};te.on(oe.Events.FRAG_CHANGED,ut);var Ie=function(Oe,ye){var Se=ye.type,me=ye.details,xe=ye.response,We=ye.fatal,Ge=ye.context,dt=ye.frag;if(me===oe.ErrorDetails.MANIFEST_LOAD_ERROR||me===oe.ErrorDetails.MANIFEST_LOAD_TIMEOUT||me===oe.ErrorDetails.FRAG_LOAD_ERROR||me===oe.ErrorDetails.FRAG_LOAD_TIMEOUT||me===oe.ErrorDetails.LEVEL_LOAD_ERROR||me===oe.ErrorDetails.LEVEL_LOAD_TIMEOUT){var at=dt&&dt.url||Ge&&Ge.url||"";ve("requestfailed",{request_error:me,request_url:at,request_hostname:s(at),request_type:me===oe.ErrorDetails.FRAG_LOAD_ERROR||me===oe.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:xe&&xe.code,request_error_text:xe&&xe.text})}We&&ve("error",{player_error_code:Se,player_error_message:me})};te.on(oe.Events.ERROR,Ie);var $e=function(Oe,ye){var Se=ye.frag,me=Se&&Se._url||"";ve("requestcanceled",{request_event_type:Oe,request_url:me,request_type:"media",request_hostname:s(me)})};te.on(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,$e);var et=function(Oe,ye){var Se=ye.level,me=te.levels[Se];if(me&&me.attrs&&me.attrs.BANDWIDTH){var xe,We=me.attrs.BANDWIDTH,Ge=parseFloat(me.attrs["FRAME-RATE"]);isNaN(Ge)||(xe=Ge),We?ve("renditionchange",{video_source_fps:xe,video_source_bitrate:We,video_source_width:me.width,video_source_height:me.height,video_source_rendition_name:me.name,video_source_codec:me==null?void 0:me.videoCodec}):Te.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};te.on(oe.Events.LEVEL_SWITCHED,et),te._stopMuxMonitor=function(){te.off(oe.Events.MANIFEST_LOADED,_e),te.off(oe.Events.LEVEL_LOADED,Ce),te.off(oe.Events.AUDIO_TRACK_LOADED,ze),te.off(oe.Events.FRAG_LOADED,Qe),te.off(oe.Events.FRAG_CHANGED,ut),te.off(oe.Events.ERROR,Ie),te.off(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,$e),te.off(oe.Events.LEVEL_SWITCHED,et),te.off(oe.Events.DESTROYING,te._stopMuxMonitor),delete te._stopMuxMonitor},te.on(oe.Events.DESTROYING,te._stopMuxMonitor)}else Te.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,z.hlsjs,{},z.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var z;this.hlsjs&&((z=this.hlsjs)&&typeof z._stopMuxMonitor=="function"&&z._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(z){z.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=z.dashjs,function(Z,ne,te){var oe=Z.log;if(te&&te.on){var Te=function(Ie,$e){return Z.emit(ne,Ie,$e)},ge=function(Ie){var $e=Ie.type,et=(Ie.data||{}).url;Te("requestcompleted",{request_event_type:$e,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:s(et),request_url:et})};te.on("manifestLoaded",ge);var Ee={},ve=function(Ie){var $e=Ie.type,et=Ie.fragmentModel,Oe=(Ie.chunk||{}).mediaInfo||{},ye=Oe.type,Se=Oe.bitrateList,me={};(Se=Se||[]).forEach(function(Xe,yt){me[yt]={},me[yt].width=Xe.width,me[yt].height=Xe.height,me[yt].bitrate=Xe.bandwidth,me[yt].attrs={}}),ye==="video"?Ee.video=me:ye==="audio"?Ee.audio=me:Ee.media=me;var xe=L(et,te),We=xe.requestStart,Ge=xe.requestResponseStart,dt=xe.requestResponseEnd,at=xe.requestResponseHeaders,pt=xe.requestMediaDuration,ft=xe.requestHostname,Et=xe.requestUrl;Te("requestcompleted",{request_event_type:$e,request_start:We,request_response_start:Ge,request_response_end:dt,request_bytes_loaded:-1,request_type:ye+"_init",request_response_headers:at,request_hostname:ft,request_url:Et,request_media_duration:pt,request_rendition_lists:Ee})};te.on("initFragmentLoaded",ve);var _e=function(Ie){var $e=Ie.type,et=Ie.fragmentModel,Oe=Ie.chunk||{},ye=Oe.mediaInfo,Se=Oe.start,me=(ye||{}).type,xe=L(et,te),We=xe.requestStart,Ge=xe.requestResponseStart,dt=xe.requestResponseEnd,at=xe.requestBytesLoaded,pt=xe.requestResponseHeaders,ft=xe.requestMediaDuration,Et=xe.requestHostname,Xe=xe.requestUrl,yt=R(me,te),Br=yt.currentLevel,_t=yt.renditionWidth,Jt=yt.renditionHeight,Gn=yt.renditionBitrate;Te("requestcompleted",{request_event_type:$e,request_start:We,request_response_start:Ge,request_response_end:dt,request_bytes_loaded:at,request_type:me,request_response_headers:pt,request_hostname:Et,request_url:Xe,request_media_start_time:Se,request_media_duration:ft,request_current_level:Br,request_labeled_bitrate:Gn,request_video_width:_t,request_video_height:Jt})};te.on("mediaFragmentLoaded",_e);var Ce={video:void 0,audio:void 0,totalBitrate:void 0},ze=function(){if(Ce.video&&typeof Ce.video.bitrate=="number"){if(Ce.video.width&&Ce.video.height){var Ie=Ce.video.bitrate;return Ce.audio&&typeof Ce.audio.bitrate=="number"&&(Ie+=Ce.audio.bitrate),Ie!==Ce.totalBitrate?(Ce.totalBitrate=Ie,{video_source_bitrate:Ie,video_source_height:Ce.video.height,video_source_width:Ce.video.width,video_source_codec:I(Ce.video.codec)}):void 0}oe.warn("have bitrate info for video but missing width/height")}},Qe=function(Ie,$e,et){if(typeof Ie.newQuality=="number"){var Oe=Ie.mediaType;if(Oe==="audio"||Oe==="video"){var ye=te.getBitrateInfoListFor(Oe).find(function(me){return me.qualityIndex===Ie.newQuality});if(ye&&typeof ye.bitrate=="number"){Ce[Oe]=y(y({},ye),{},{codec:te.getCurrentTrackFor(Oe).codec});var Se=ze();Se&&Te("renditionchange",Se)}else oe.warn("missing bitrate info for ".concat(Oe))}}else oe.warn("missing evt.newQuality in qualityChangeRendered event",Ie)};te.on("qualityChangeRendered",Qe);var ut=function(Ie){var $e=Ie.error,et=Ie.event,Oe=(et=et||{}).request||{},ye=M().event&&M().event.currentTarget||{};Te("requestfailed",{request_error:$e+"_"+et.id+"_"+Oe.type,request_url:et.url,request_hostname:s(et.url),request_type:Oe.mediaType,request_error_code:ye.status,request_error_type:ye.statusText})};te.on("error",ut),te._stopMuxMonitor=function(){te.off("manifestLoaded",ge),te.off("initFragmentLoaded",ve),te.off("mediaFragmentLoaded",_e),te.off("qualityChangeRendered",Qe),te.off("error",ut),delete te._stopMuxMonitor}}else oe.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,z.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var z;this.dashjs&&((z=this.dashjs)&&typeof z._stopMuxMonitor=="function"&&z._stopMuxMonitor(),this.dashjs=void 0)}}],w&&Ei(C.prototype,w),G&&Ei(C,G),Object.defineProperty(C,"prototype",{writable:!1}),J}(K),_n=En,Tn=O(153),Qt=O.n(Tn);function Fr(N){return Fr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(C){return typeof C}:function(C){return C&&typeof Symbol=="function"&&C.constructor===Symbol&&C!==Symbol.prototype?"symbol":typeof C},Fr(N)}function _i(N,C){return function(w){if(Array.isArray(w))return w}(N)||function(w,G){var j=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(j!=null){var J,z,Z=[],ne=!0,te=!1;try{for(j=j.call(w);!(ne=(J=j.next()).done)&&(Z.push(J.value),!G||Z.length!==G);ne=!0);}catch(oe){te=!0,z=oe}finally{try{ne||j.return==null||j.return()}finally{if(te)throw z}}return Z}}(N,C)||function(w,G){if(w){if(typeof w=="string")return Ti(w,G);var j=Object.prototype.toString.call(w).slice(8,-1);return j==="Object"&&w.constructor&&(j=w.constructor.name),j==="Map"||j==="Set"?Array.from(w):j==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(j)?Ti(w,G):void 0}}(N,C)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function
|
|
6
|
-
`);
|
|
7
|
-
`))this.processLine(this.buffer.substring(0,
|
|
8
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function xi(N,C){(C==null||C>N.length)&&(C=N.length);for(var w=0,G=new Array(C);w<C;w++)G[w]=N[w];return G}var mt={},$t=function N(C){var w=arguments;typeof C=="string"?N.hasOwnProperty(C)?M().setTimeout(function(){w=Array.prototype.splice.call(w,1),N[C].apply(null,w)},0):f.warn("`"+C+"` is an unknown task"):typeof C=="function"?M().setTimeout(function(){C(N)},0):f.warn("`"+C+"` is invalid.")},Kn={loaded:p.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(N,C){return function(w,G,j){var J=_i(A(G),3),z=J[0],Z=J[1],ne=J[2],te=w.log,oe=w.utils.getComputedStyle,Te=w.utils.secondsToMs;if(!z)return te.error("No element was found with the `"+Z+"` query selector.");if(ne!=="video"&&ne!=="audio")return te.error("The element of `"+Z+"` was not a media element.");z.mux&&(z.mux.destroy(),delete z.mux,te.warn("Already monitoring this video element, replacing existing event listeners")),(j=a()({automaticErrorTracking:!0},j)).data=a()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:w.VERSION},j.data),j.getPlayheadTime=function(){return Te(z.currentTime)},j.getStateData=function(){var Ee,ve,_e=this.hlsjs&&this.hlsjs.url,Ce=this.dashjs&&Fr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),ze={player_is_paused:z.paused,player_playhead_time:Te(z.currentTime),player_width:parseInt(oe(z,"width")),player_height:parseInt(oe(z,"height")),player_autoplay_on:z.autoplay,player_preload_on:z.preload,player_language_code:z.lang,player_is_fullscreen:Qt()&&!!(Qt().fullscreenElement||Qt().webkitFullscreenElement||Qt().mozFullScreenElement||Qt().msFullscreenElement),video_poster_url:z.poster,video_source_url:_e||Ce||z.currentSrc,video_source_duration:Te(z.duration),video_source_height:z.videoHeight,video_source_width:z.videoWidth,view_dropped_frame_count:(Ee=z)===null||Ee===void 0||(ve=Ee.getVideoPlaybackQuality)===null||ve===void 0?void 0:ve.call(Ee).droppedVideoFrames},Qe=j.getPlayheadTime();if(z.getStartDate&&Qe>0){var ut=z.getStartDate();if(ut&&typeof ut.getTime=="function"&&ut.getTime()){var Ie=ut.getTime();if(ze.player_program_time=Ie+Qe,z.seekable.length>0){var $e=Ie+z.seekable.end(z.seekable.length-1);ze.player_live_edge_program_time=$e}}}return ze},z.mux=z.mux||{},z.mux.deleted=!1,z.mux.emit=function(Ee,ve){w.emit(Z,Ee,ve)};var ge=function(){te.error("The monitor for this video element has already been destroyed.")};z.mux.destroy=function(){Object.keys(z.mux.listeners).forEach(function(Ee){z.removeEventListener(Ee,z.mux.listeners[Ee],!1)}),delete z.mux.listeners,z.mux.destroy=ge,z.mux.swapElement=ge,z.mux.emit=ge,z.mux.addHLSJS=ge,z.mux.addDashJS=ge,z.mux.removeHLSJS=ge,z.mux.removeDashJS=ge,z.mux.deleted=!0,w.emit(Z,"destroy")},z.mux.swapElement=function(Ee){var ve=_i(A(Ee),3),_e=ve[0],Ce=ve[1],ze=ve[2];return _e?ze!=="video"&&ze!=="audio"?w.log.error("The element of `"+Ce+"` was not a media element."):(_e.muxId=z.muxId,delete z.muxId,_e.mux=_e.mux||{},_e.mux.listeners=a()({},z.mux.listeners),delete z.mux.listeners,Object.keys(_e.mux.listeners).forEach(function(Qe){z.removeEventListener(Qe,_e.mux.listeners[Qe],!1),_e.addEventListener(Qe,_e.mux.listeners[Qe],!1)}),_e.mux.swapElement=z.mux.swapElement,_e.mux.destroy=z.mux.destroy,delete z.mux,void(z=_e)):w.log.error("No element was found with the `"+Ce+"` query selector.")},z.mux.addHLSJS=function(Ee){w.addHLSJS(Z,Ee)},z.mux.addDashJS=function(Ee){w.addDashJS(Z,Ee)},z.mux.removeHLSJS=function(){w.removeHLSJS(Z)},z.mux.removeDashJS=function(){w.removeDashJS(Z)},w.init(Z,j),w.emit(Z,"playerready"),z.paused||(w.emit(Z,"play"),z.readyState>2&&w.emit(Z,"playing")),z.mux.listeners={},Sn.forEach(function(Ee){(Ee!=="error"||j.automaticErrorTracking)&&(z.mux.listeners[Ee]=function(){var ve={};if(Ee==="error"){if(!z.error||z.error.code===1)return;ve.player_error_code=z.error.code,ve.player_error_message=xn[z.error.code]||z.error.message}w.emit(Z,Ee,ve)},z.addEventListener(Ee,z.mux.listeners[Ee],!1))})}($t,N,C)},destroyMonitor:function(N){var C=Bn(A(N),1)[0];C&&C.mux&&typeof C.mux.destroy=="function"?C.mux.destroy():f.error("A video element monitor for `"+N+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(N,C){var w=b(N);mt[w]?mt[w].addHLSJS(C):f.error("A monitor for `"+w+"` has not been initialized.")},addDashJS:function(N,C){var w=b(N);mt[w]?mt[w].addDashJS(C):f.error("A monitor for `"+w+"` has not been initialized.")},removeHLSJS:function(N){var C=b(N);mt[C]?mt[C].removeHLSJS():f.error("A monitor for `"+C+"` has not been initialized.")},removeDashJS:function(N){var C=b(N);mt[C]?mt[C].removeDashJS():f.error("A monitor for `"+C+"` has not been initialized.")},init:function(N,C){_()&&C&&C.respectDoNotTrack&&f.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var w=b(N);mt[w]=new _n($t,w,C)},emit:function(N,C,w){var G=b(N);mt[G]?(mt[G].emit(C,w),C==="destroy"&&delete mt[G]):f.error("A monitor for `"+G+"` has not been initialized.")},checkDoNotTrack:_,log:f,utils:Un,events:Nn,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign($t,Kn),M()!==void 0&&typeof M().addEventListener=="function"&&M().addEventListener("pagehide",function(N){N.persisted||($t.WINDOW_UNLOADING=!0)},!1);var Wn=$t},655:function(B,T,O){var D,M;function P(U){return P=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(b){return typeof b}:function(b){return b&&typeof Symbol=="function"&&b.constructor===Symbol&&b!==Symbol.prototype?"symbol":typeof b},P(U);}(function(U){var b=!1;if((M=typeof(D=U)=="function"?D.call(T,O,T,B):D)===void 0||(B.exports=M),b=!0,P(T)==="object"&&(B.exports=U(),b=!0),!b){var A=window.Cookies,S=window.Cookies=U();S.noConflict=function(){return window.Cookies=A,S}}})(function(){var U=function(){for(var b=0,A={};b<arguments.length;b++){var S=arguments[b];for(var E in S)A[E]=S[E]}return A};return function b(A){function S(E,x,f){var _;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(f=U({path:"/"},S.defaults,f)).expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*f.expires),f.expires=p}try{_=JSON.stringify(x),/^[\{\[]/.test(_)&&(x=_)}catch{}return x=A.write?A.write(x,E):encodeURIComponent(String(x)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),E=(E=(E=encodeURIComponent(String(E))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[E,"=",x,f.expires?"; expires="+f.expires.toUTCString():"",f.path?"; path="+f.path:"",f.domain?"; domain="+f.domain:"",f.secure?"; secure":""].join("")}E||(_={});for(var v=document.cookie?document.cookie.split("; "):[],a=/(%[0-9A-Z]{2})+/g,s=0;s<v.length;s++){var n=v[s].split("="),d=n.slice(1).join("=");d.charAt(0)==='"'&&(d=d.slice(1,-1));try{var l=n[0].replace(a,decodeURIComponent);if(d=A.read?A.read(d,l):A(d,l)||d.replace(a,decodeURIComponent),this.json)try{d=JSON.parse(d)}catch{}if(E===l){_=d;break}E||(_[l]=d)}catch{}}return _}}return S.set=S,S.get=function(E){return S.call(S,E)},S.getJSON=function(){return S.apply({json:!0},[].slice.call(arguments))},S.defaults={},S.remove=function(E,x){S(E,"",U(x,{expires:-1}))},S.withConverter=b,S}(function(){})})},153:function(B,T,O){var D,M=O.g!==void 0?O.g:typeof window!="undefined"?window:{},P=O(558);typeof document!="undefined"?D=document:(D=M["__GLOBAL_DOCUMENT_CACHE@4"])||(D=M["__GLOBAL_DOCUMENT_CACHE@4"]=P),B.exports=D},48:function(B,T,O){var D;D=typeof window!="undefined"?window:O.g!==void 0?O.g:typeof self!="undefined"?self:{},B.exports=D},678:function(B){var T=9007199254740991,O="[object Arguments]",D="[object Function]",M="[object GeneratorFunction]",P=/^(?:0|[1-9]\d*)$/;function U(e,r,t){switch(t.length){case 0:return e.call(r);case 1:return e.call(r,t[0]);case 2:return e.call(r,t[0],t[1]);case 3:return e.call(r,t[0],t[1],t[2])}return e.apply(r,t)}var b,A,S=Object.prototype,E=S.hasOwnProperty,x=S.toString,f=S.propertyIsEnumerable,_=(b=Object.keys,A=Object,function(e){return b(A(e))}),p=Math.max,v=!f.call({valueOf:1},"valueOf");function a(e,r){var t=i(e)||function(L){return function(R){return function(I){return!!I&&typeof I=="object"}(R)&&u(R)}(L)&&E.call(L,"callee")&&(!f.call(L,"callee")||x.call(L)==O)}(e)?function(L,R){for(var I=-1,k=Array(L);++I<L;)k[I]=R(I);return k}(e.length,String):[],o=t.length,y=!!o;for(var h in e)!r&&!E.call(e,h)||y&&(h=="length"||n(h,o))||t.push(h);return t}function s(e,r,t){var o=e[r];E.call(e,r)&&l(o,t)&&(t!==void 0||r in e)||(e[r]=t)}function n(e,r){return!!(r=r==null?T:r)&&(typeof e=="number"||P.test(e))&&e>-1&&e%1==0&&e<r}function d(e){var r=e&&e.constructor;return e===(typeof r=="function"&&r.prototype||S)}function l(e,r){return e===r||e!=e&&r!=r}var i=Array.isArray;function u(e){return e!=null&&function(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=T}(e.length)&&!function(r){var t=g(r)?x.call(r):"";return t==D||t==M}(e)}function g(e){var r=typeof e;return!!e&&(r=="object"||r=="function")}var c,m=(c=function(e,r){if(v||d(r)||u(r))(function(o,y,h,L){h||(h={});for(var R=-1,I=y.length;++R<I;){var k=y[R],F=L?L(h[k],o[k],k,h,o):void 0;s(h,k,F===void 0?o[k]:F)}})(r,function(o){return u(o)?a(o):function(y){if(!d(y))return _(y);var h=[];for(var L in Object(y))E.call(y,L)&&L!="constructor"&&h.push(L);return h}(o)}(r),e);else for(var t in r)E.call(r,t)&&s(e,t,r[t])},function(e,r){return r=p(r===void 0?e.length-1:r,0),function(){for(var t=arguments,o=-1,y=p(t.length-r,0),h=Array(y);++o<y;)h[o]=t[r+o];o=-1;for(var L=Array(r+1);++o<r;)L[o]=t[o];return L[r]=h,U(e,this,L)}}(function(e,r){var t=-1,o=r.length,y=o>1?r[o-1]:void 0,h=o>2?r[2]:void 0;for(y=c.length>3&&typeof y=="function"?(o--,y):void 0,h&&function(R,I,k){if(!g(k))return!1;var F=typeof I;return!!(F=="number"?u(k)&&n(I,k.length):F=="string"&&I in k)&&l(k[I],R)}(r[0],r[1],h)&&(y=o<3?void 0:y,o=1),e=Object(e);++t<o;){var L=r[t];L&&c(e,L,t,y)}return e}));B.exports=m},640:function(B,T,O){var D,M;(function(P,U){"use strict";D=function(){var b=function(){},A="undefined",S=typeof window!==A&&typeof window.navigator!==A&&/Trident\/|MSIE /.test(window.navigator.userAgent),E=["trace","debug","info","warn","error"];function x(i,u){var g=i[u];if(typeof g.bind=="function")return g.bind(i);try{return Function.prototype.bind.call(g,i)}catch{return function(){return Function.prototype.apply.apply(g,[i,arguments])}}}function f(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function _(i){return i==="debug"&&(i="log"),typeof console!==A&&(i==="trace"&&S?f:console[i]!==void 0?x(console,i):console.log!==void 0?x(console,"log"):b)}function p(i,u){for(var g=0;g<E.length;g++){var c=E[g];this[c]=g<i?b:this.methodFactory(c,i,u)}this.log=this.debug}function v(i,u,g){return function(){typeof console!==A&&(p.call(this,u,g),this[i].apply(this,arguments))}}function a(i,u,g){return _(i)||v.apply(this,arguments)}function s(i,u,g){var c,m=this;u=u==null?"WARN":u;var e="loglevel";function r(h){var L=(E[h]||"silent").toUpperCase();if(typeof window!==A&&e){try{return void(window.localStorage[e]=L)}catch{}try{window.document.cookie=encodeURIComponent(e)+"="+L+";"}catch{}}}function t(){var h;if(typeof window!==A&&e){try{h=window.localStorage[e]}catch{}if(typeof h===A)try{var L=window.document.cookie,R=L.indexOf(encodeURIComponent(e)+"=");R!==-1&&(h=/^([^;]+)/.exec(L.slice(R))[1])}catch{}return m.levels[h]===void 0&&(h=void 0),h}}function o(){if(typeof window!==A&&e){try{return void window.localStorage.removeItem(e)}catch{}try{window.document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof i=="string"?e+=":"+i:typeof i=="symbol"&&(e=void 0),m.name=i,m.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},m.methodFactory=g||a,m.getLevel=function(){return c},m.setLevel=function(h,L){if(typeof h=="string"&&m.levels[h.toUpperCase()]!==void 0&&(h=m.levels[h.toUpperCase()]),!(typeof h=="number"&&h>=0&&h<=m.levels.SILENT))throw"log.setLevel() called with invalid level: "+h;if(c=h,L!==!1&&r(h),p.call(m,h,i),typeof console===A&&h<m.levels.SILENT)return"No console available for logging"},m.setDefaultLevel=function(h){u=h,t()||m.setLevel(h,!1)},m.resetLevel=function(){m.setLevel(u,!1),o()},m.enableAll=function(h){m.setLevel(m.levels.TRACE,h)},m.disableAll=function(h){m.setLevel(m.levels.SILENT,h)};var y=t();y==null&&(y=u),m.setLevel(y,!1)}var n=new s,d={};n.getLogger=function(i){if(typeof i!="symbol"&&typeof i!="string"||i==="")throw new TypeError("You must supply a name when creating a logger.");var u=d[i];return u||(u=d[i]=new s(i,n.getLevel(),n.methodFactory)),u};var l=typeof window!==A?window.log:void 0;return n.noConflict=function(){return typeof window!==A&&window.log===n&&(window.log=l),n},n.getLoggers=function(){return d},n.default=n,n},(M=typeof D=="function"?D.call(T,O,T,B):D)===void 0||(B.exports=M)})()},375:function(B,T){"use strict";var O=Object.prototype.hasOwnProperty;function D(P){try{return decodeURIComponent(P.replace(/\+/g," "))}catch{return null}}function M(P){try{return encodeURIComponent(P)}catch{return null}}T.stringify=function(P,U){U=U||"";var b,A,S=[];for(A in typeof U!="string"&&(U="?"),P)if(O.call(P,A)){if((b=P[A])||b!=null&&!isNaN(b)||(b=""),A=M(A),b=M(b),A===null||b===null)continue;S.push(A+"="+b)}return S.length?U+S.join("&"):""},T.parse=function(P){for(var U,b=/([^=?#&]+)=?([^&]*)/g,A={};U=b.exec(P);){var S=D(U[1]),E=D(U[2]);S===null||E===null||S in A||(A[S]=E)}return A}},558:function(){}},ie={};function Q(B){var T=ie[B];if(T!==void 0)return T.exports;var O=ie[B]={exports:{}};return V[B].call(O.exports,O,O.exports,Q),O.exports}return Q.n=function(B){var T=B&&B.__esModule?function(){return B.default}:function(){return B};return Q.d(T,{a:T}),T},Q.d=function(B,T){for(var O in T)Q.o(T,O)&&!Q.o(B,O)&&Object.defineProperty(B,O,{enumerable:!0,get:T[O]})},Q.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),Q.o=function(B,T){return Object.prototype.hasOwnProperty.call(B,T)},Q(80)}()},typeof _r=="object"&&typeof Vr=="object"?Vr.exports=X():typeof _r=="object"?_r.mux=X():$.mux=X()})()});var Tr=Ai((tr,Yr)=>{typeof window!="undefined"&&function(X,V){typeof tr=="object"&&typeof Yr=="object"?Yr.exports=V():typeof define=="function"&&define.amd?define([],V):typeof tr=="object"?tr.Hls=V():X.Hls=V()}(tr,()=>(()=>{var $={"./src/config.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{enableStreamingMode:()=>r,hlsDefaultConfig:()=>c,mergeConfig:()=>e});var O=T("./src/controller/abr-controller.ts"),D=T("./src/controller/audio-stream-controller.ts"),M=T("./src/controller/audio-track-controller.ts"),P=T("./src/controller/subtitle-stream-controller.ts"),U=T("./src/controller/subtitle-track-controller.ts"),b=T("./src/controller/buffer-controller.ts"),A=T("./src/controller/timeline-controller.ts"),S=T("./src/controller/cap-level-controller.ts"),E=T("./src/controller/fps-controller.ts"),x=T("./src/controller/eme-controller.ts"),f=T("./src/controller/cmcd-controller.ts"),_=T("./src/utils/xhr-loader.ts"),p=T("./src/utils/fetch-loader.ts"),v=T("./src/utils/cues.ts"),a=T("./src/utils/mediakeys-helper.ts"),s=T("./src/utils/logger.ts");function n(){return n=Object.assign?Object.assign.bind():function(t){for(var o=1;o<arguments.length;o++){var y=arguments[o];for(var h in y)Object.prototype.hasOwnProperty.call(y,h)&&(t[h]=y[h])}return t},n.apply(this,arguments)}function d(t,o){var y=Object.keys(t);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(t);o&&(h=h.filter(function(L){return Object.getOwnPropertyDescriptor(t,L).enumerable})),y.push.apply(y,h)}return y}function l(t){for(var o=1;o<arguments.length;o++){var y=arguments[o]!=null?arguments[o]:{};o%2?d(Object(y),!0).forEach(function(h){i(t,h,y[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(y)):d(Object(y)).forEach(function(h){Object.defineProperty(t,h,Object.getOwnPropertyDescriptor(y,h))})}return t}function i(t,o,y){return o=u(o),o in t?Object.defineProperty(t,o,{value:y,enumerable:!0,configurable:!0,writable:!0}):t[o]=y,t}function u(t){var o=g(t,"string");return typeof o=="symbol"?o:String(o)}function g(t,o){if(typeof t!="object"||t===null)return t;var y=t[Symbol.toPrimitive];if(y!==void 0){var h=y.call(t,o||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(t)}var c=l(l({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:_.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:O.default,bufferController:b.default,capLevelController:S.default,fpsController:E.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:a.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},m()),{},{subtitleStreamController:P.SubtitleStreamController,subtitleTrackController:U.default,timelineController:A.TimelineController,audioStreamController:D.default,audioTrackController:M.default,emeController:x.default,cmcdController:f.default});function m(){return{cueHandler:v.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function e(t,o){if((o.liveSyncDurationCount||o.liveMaxLatencyDurationCount)&&(o.liveSyncDuration||o.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(o.liveMaxLatencyDurationCount!==void 0&&(o.liveSyncDurationCount===void 0||o.liveMaxLatencyDurationCount<=o.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(o.liveMaxLatencyDuration!==void 0&&(o.liveSyncDuration===void 0||o.liveMaxLatencyDuration<=o.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return n({},t,o)}function r(t){var o=t.loader;if(o!==p.default&&o!==_.default)s.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1;else{var y=(0,p.fetchSupported)();y&&(t.loader=p.default,t.progressive=!0,t.enableSoftwareAES=!0,s.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>_});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/ewma-bandwidth-estimator.ts"),M=T("./src/events.ts"),P=T("./src/errors.ts"),U=T("./src/types/loader.ts"),b=T("./src/utils/logger.ts");function A(p,v){for(var a=0;a<v.length;a++){var s=v[a];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(p,E(s.key),s)}}function S(p,v,a){return v&&A(p.prototype,v),a&&A(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function E(p){var v=x(p,"string");return typeof v=="symbol"?v:String(v)}function x(p,v){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var s=a.call(p,v||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(v==="string"?String:Number)(p)}var f=function(){function p(a){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=a;var s=a.config;this.bwEstimator=new D.default(s.abrEwmaSlowVoD,s.abrEwmaFastVoD,s.abrEwmaDefaultEstimate),this.registerListeners()}var v=p.prototype;return v.registerListeners=function(){var s=this.hls;s.on(M.Events.FRAG_LOADING,this.onFragLoading,this),s.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.on(M.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){var s=this.hls;s.off(M.Events.FRAG_LOADING,this.onFragLoading,this),s.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),s.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.off(M.Events.ERROR,this.onError,this)},v.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},v.onFragLoading=function(s,n){var d=n.frag;if(d.type===U.PlaylistLevelType.MAIN&&!this.timer){var l;this.fragCurrent=d,this.partCurrent=(l=n.part)!=null?l:null,this.timer=self.setInterval(this.onCheck,100)}},v.onLevelLoaded=function(s,n){var d=this.hls.config;n.details.live?this.bwEstimator.update(d.abrEwmaSlowLive,d.abrEwmaFastLive):this.bwEstimator.update(d.abrEwmaSlowVoD,d.abrEwmaFastVoD)},v._abandonRulesCheck=function(){var s=this.fragCurrent,n=this.partCurrent,d=this.hls,l=d.autoLevelEnabled,i=d.media;if(!(!s||!i)){var u=n?n.stats:s.stats,g=n?n.duration:s.duration;if(u.aborted||u.loaded&&u.loaded===u.total||s.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!l||i.paused||!i.playbackRate||!i.readyState)){var c=d.mainForwardBufferInfo;if(c!==null){var m=performance.now()-u.loading.start,e=Math.abs(i.playbackRate);if(!(m<=500*g/e)){var r=u.loaded&&u.loading.first,t=this.bwEstimator.getEstimate(),o=d.levels,y=d.minAutoLevel,h=o[s.level],L=u.total||Math.max(u.loaded,Math.round(g*h.maxBitrate/8)),R=r?u.loaded*1e3/m:0,I=R?(L-u.loaded)/R:L*8/t,k=c.len/e;if(!(I<=k)){var F=Number.POSITIVE_INFINITY,W;for(W=s.level-1;W>y;W--){var K=o[W].maxBitrate;if(F=R?g*K/(8*.8*R):g*K/t,F<k)break}F>=I||(b.logger.warn("Fragment "+s.sn+(n?" part "+n.index:"")+" of level "+s.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+W+`
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Time to underbuffer: `+k.toFixed(3)+" s"),d.nextLoadLevel=W,r&&this.bwEstimator.sample(m,u.loaded),this.clearTimer(),(s.loader||s.keyLoader)&&(this.fragCurrent=this.partCurrent=null,s.abortRequests()),d.trigger(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:n,stats:u}))}}}}}},v.onFragLoaded=function(s,n){var d=n.frag,l=n.part;if(d.type===U.PlaylistLevelType.MAIN&&(0,O.isFiniteNumber)(d.sn)){var i=l?l.stats:d.stats,u=l?l.duration:d.duration;if(this.clearTimer(),this.lastLoadedFragLevel=d.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var g=this.hls.levels[d.level],c=(g.loaded?g.loaded.bytes:0)+i.loaded,m=(g.loaded?g.loaded.duration:0)+u;g.loaded={bytes:c,duration:m},g.realBitrate=Math.round(8*c/m)}if(d.bitrateTest){var e={stats:i,frag:d,part:l,id:d.type};this.onFragBuffered(M.Events.FRAG_BUFFERED,e)}}},v.onFragBuffered=function(s,n){var d=n.frag,l=n.part,i=l?l.stats:d.stats;if(!i.aborted&&!(d.type!==U.PlaylistLevelType.MAIN||d.sn==="initSegment")){var u=i.parsing.end-i.loading.start;this.bwEstimator.sample(u,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),d.bitrateTest?this.bitrateTestDelay=u/1e3:this.bitrateTestDelay=0}},v.onError=function(s,n){var d;if(((d=n.frag)===null||d===void 0?void 0:d.type)===U.PlaylistLevelType.MAIN){if(n.type===P.ErrorTypes.KEY_SYSTEM_ERROR){this.clearTimer();return}switch(n.details){case P.ErrorDetails.FRAG_LOAD_ERROR:case P.ErrorDetails.FRAG_LOAD_TIMEOUT:case P.ErrorDetails.KEY_LOAD_ERROR:case P.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer();break;default:break}}},v.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},v.getNextABRAutoLevel=function(){var s=this.fragCurrent,n=this.partCurrent,d=this.hls,l=d.maxAutoLevel,i=d.config,u=d.minAutoLevel,g=d.media,c=n?n.duration:s?s.duration:0,m=g&&g.playbackRate!==0?Math.abs(g.playbackRate):1,e=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,r=d.mainForwardBufferInfo,t=(r?r.len:0)/m,o=this.findBestLevel(e,u,l,t,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(o>=0)return o;b.logger.trace((t?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var y=c?Math.min(c,i.maxStarvationDelay):i.maxStarvationDelay,h=i.abrBandWidthFactor,L=i.abrBandWidthUpFactor;if(!t){var R=this.bitrateTestDelay;if(R){var I=c?Math.min(c,i.maxLoadingDelay):i.maxLoadingDelay;y=I-R,b.logger.trace("bitrate test took "+Math.round(1e3*R)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*y)+" ms"),h=L=1}}return o=this.findBestLevel(e,u,l,t+y,h,L),Math.max(o,0)},v.findBestLevel=function(s,n,d,l,i,u){for(var g,c=this.fragCurrent,m=this.partCurrent,e=this.lastLoadedFragLevel,r=this.hls.levels,t=r[e],o=!!(t!=null&&(g=t.details)!==null&&g!==void 0&&g.live),y=t==null?void 0:t.codecSet,h=m?m.duration:c?c.duration:0,L=d;L>=n;L--){var R=r[L];if(!(!R||y&&R.codecSet!==y)){var I=R.details,k=(m?I==null?void 0:I.partTarget:I==null?void 0:I.averagetargetduration)||h,F=void 0;L<=e?F=i*s:F=u*s;var W=r[L].maxBitrate,K=W*k/F;if(b.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+L+"/"+Math.round(F)+"/"+W+"/"+k+"/"+l+"/"+K),F>W&&(K===0||!(0,O.isFiniteNumber)(K)||o&&!this.bitrateTestDelay||K<l))return L}}return-1},S(p,[{key:"nextAutoLevel",get:function(){var s=this._nextAutoLevel,n=this.bwEstimator;if(s!==-1&&!n.canEstimate())return s;var d=this.getNextABRAutoLevel();return s!==-1&&this.hls.levels[d].loadError?s:(s!==-1&&(d=Math.min(s,d)),d)},set:function(s){this._nextAutoLevel=s}}]),p}();let _=f},"./src/controller/audio-stream-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>i});var O=T("./src/polyfills/number.ts"),D=T("./src/controller/base-stream-controller.ts"),M=T("./src/events.ts"),P=T("./src/utils/buffer-helper.ts"),U=T("./src/controller/fragment-tracker.ts"),b=T("./src/types/level.ts"),A=T("./src/types/loader.ts"),S=T("./src/loader/fragment.ts"),E=T("./src/demux/chunk-cache.ts"),x=T("./src/demux/transmuxer-interface.ts"),f=T("./src/types/transmuxer.ts"),_=T("./src/controller/fragment-finders.ts"),p=T("./src/utils/discontinuities.ts"),v=T("./src/errors.ts");function a(){return a=Object.assign?Object.assign.bind():function(u){for(var g=1;g<arguments.length;g++){var c=arguments[g];for(var m in c)Object.prototype.hasOwnProperty.call(c,m)&&(u[m]=c[m])}return u},a.apply(this,arguments)}function s(u,g){u.prototype=Object.create(g.prototype),u.prototype.constructor=u,n(u,g)}function n(u,g){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,e){return m.__proto__=e,m},n(u,g)}var d=100,l=function(u){s(g,u);function g(m,e,r){var t;return t=u.call(this,m,e,r,"[audio-stream-controller]")||this,t.videoBuffer=null,t.videoTrackCC=-1,t.waitingVideoCC=-1,t.audioSwitch=!1,t.trackId=-1,t.waitingData=null,t.mainDetails=null,t.bufferFlushed=!1,t.cachedTrackLoadedData=null,t._registerListeners(),t}var c=g.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var e=this.hls;e.on(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(M.Events.ERROR,this.onError,this),e.on(M.Events.BUFFER_RESET,this.onBufferReset,this),e.on(M.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var e=this.hls;e.off(M.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(M.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(M.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(M.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(M.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(M.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(M.Events.ERROR,this.onError,this),e.off(M.Events.BUFFER_RESET,this.onBufferReset,this),e.off(M.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(M.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(M.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(e,r){var t=r.frag,o=r.id,y=r.initPTS;if(o==="main"){var h=t.cc;this.initPTS[t.cc]=y,this.log("InitPTS for cc: "+h+" found from main: "+y),this.videoTrackCC=h,this.state===D.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(e){if(!this.levels){this.startPosition=e,this.state=D.State.STOPPED;return}var r=this.lastCurrentTime;this.stopLoad(),this.setInterval(d),this.fragLoadError=0,r>0&&e===-1?(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),e=r,this.state=D.State.IDLE):(this.loadedmetadata=!1,this.state=D.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},c.doTick=function(){switch(this.state){case D.State.IDLE:this.doTickIdle();break;case D.State.WAITING_TRACK:{var e,r=this.levels,t=this.trackId,o=r==null||(e=r[t])===null||e===void 0?void 0:e.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=D.State.WAITING_INIT_PTS}break}case D.State.FRAG_LOADING_WAITING_RETRY:{var y,h=performance.now(),L=this.retryDate;(!L||h>=L||(y=this.media)!==null&&y!==void 0&&y.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=D.State.IDLE);break}case D.State.WAITING_INIT_PTS:{var R=this.waitingData;if(R){var I=R.frag,k=R.part,F=R.cache,W=R.complete;if(this.initPTS[I.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=D.State.FRAG_LOADING;var K=F.flush(),H={frag:I,part:k,payload:K,networkDetails:null};this._handleFragmentLoadProgress(H),W&&u.prototype._handleFragmentLoadComplete.call(this,H)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+I.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var Y=this.getLoadPosition(),q=P.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),ee=(0,_.fragmentWithinToleranceTest)(q.end,this.config.maxFragLookUpTolerance,I);ee<0&&(this.log("Waiting fragment cc ("+I.cc+") @ "+I.start+" cancelled because another fragment at "+q.end+" is needed"),this.clearWaitingFragment())}}else this.state=D.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=D.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),u.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var e=this.media;!e||!e.readyState||(this.lastCurrentTime=e.currentTime)},c.doTickIdle=function(){var e=this.hls,r=this.levels,t=this.media,o=this.trackId,y=e.config;if(!(!r||!r[o])&&!(!t&&(this.startFragRequested||!y.startFragPrefetch))){var h=r[o],L=h.details;if(!L||L.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(L)){this.state=D.State.WAITING_TRACK;return}var R=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&R&&(this.bufferFlushed=!1,this.afterBufferFlushed(R,S.ElementaryStreamTypes.AUDIO,A.PlaylistLevelType.AUDIO));var I=this.getFwdBufferInfo(R,A.PlaylistLevelType.AUDIO);if(I!==null){var k=this.audioSwitch;if(!k&&this._streamEnded(I,L)){e.trigger(M.Events.BUFFER_EOS,{type:"audio"}),this.state=D.State.ENDED;return}var F=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,A.PlaylistLevelType.MAIN),W=I.len,K=this.getMaxBufferLength(F==null?void 0:F.len);if(!(W>=K&&!k)){var H=L.fragments,Y=H[0].start,q=I.end;if(k&&t){var ee=this.getLoadPosition();q=ee,L.PTSKnown&&ee<Y&&(I.end>Y||I.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),t.currentTime=Y+.05)}if(!(F&&q>F.end+L.targetduration)&&!((!F||!F.len)&&I.len)){var ae=this.getNextFragment(q,L);if(!ae){this.bufferFlushed=!0;return}this.loadFragment(ae,L,q)}}}}},c.getMaxBufferLength=function(e){var r=u.prototype.getMaxBufferLength.call(this);return e?Math.max(r,e):r},c.onMediaDetaching=function(){this.videoBuffer=null,u.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(e,r){var t=r.audioTracks;this.resetTransmuxer(),this.levels=t.map(function(o){return new b.Level(o)})},c.onAudioTrackSwitching=function(e,r){var t=!!r.url;this.trackId=r.id;var o=this.fragCurrent;o&&o.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),t?this.setInterval(d):this.resetTransmuxer(),t?(this.audioSwitch=!0,this.state=D.State.IDLE):this.state=D.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(e,r){this.mainDetails=r.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(M.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(e,r){var t;if(this.mainDetails==null){this.cachedTrackLoadedData=r;return}var o=this.levels,y=r.details,h=r.id;if(!o){this.warn("Audio tracks were reset while loading level "+h);return}this.log("Track "+h+" loaded ["+y.startSN+","+y.endSN+"],duration:"+y.totalduration);var L=o[h],R=0;if(y.live||(t=L.details)!==null&&t!==void 0&&t.live){var I=this.mainDetails;if(y.fragments[0]||(y.deltaUpdateFailed=!0),y.deltaUpdateFailed||!I)return;!L.details&&y.hasProgramDateTime&&I.hasProgramDateTime?((0,p.alignMediaPlaylistByPDT)(y,I),R=y.fragments[0].start):R=this.alignPlaylists(y,L.details)}L.details=y,this.levelLastLoaded=h,!this.startFragRequested&&(this.mainDetails||!y.live)&&this.setStartPosition(L.details,R),this.state===D.State.WAITING_TRACK&&!this.waitForCdnTuneIn(y)&&(this.state=D.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(e){var r,t=e.frag,o=e.part,y=e.payload,h=this.config,L=this.trackId,R=this.levels;if(!R){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+t.sn+" of level "+t.level+" will not be buffered");return}var I=R[L];console.assert(I,"Audio track is defined on fragment load progress");var k=I.details;console.assert(k,"Audio track details are defined on fragment load progress");var F=h.defaultAudioCodec||I.audioCodec||"mp4a.40.2",W=this.transmuxer;W||(W=this.transmuxer=new x.default(this.hls,A.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var K=this.initPTS[t.cc],H=(r=t.initSegment)===null||r===void 0?void 0:r.data;if(K!==void 0){var Y=!1,q=o?o.index:-1,ee=q!==-1,ae=new f.ChunkMetadata(t.level,t.sn,t.stats.chunkCount,y.byteLength,q,ee);W.push(y,H,F,"",t,o,k.totalduration,Y,ae,K)}else{this.log("Unknown video PTS for cc "+t.cc+", waiting for video PTS before demuxing audio frag "+t.sn+" of ["+k.startSN+" ,"+k.endSN+"],track "+L);var re=this.waitingData=this.waitingData||{frag:t,part:o,cache:new E.default,complete:!1},se=re.cache;se.push(new Uint8Array(y)),this.waitingVideoCC=this.videoTrackCC,this.state=D.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(e){if(this.waitingData){this.waitingData.complete=!0;return}u.prototype._handleFragmentLoadComplete.call(this,e)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(e,r){var t=r.tracks.audio;t&&(this.mediaBuffer=t.buffer||null),r.tracks.video&&(this.videoBuffer=r.tracks.video.buffer||null)},c.onFragBuffered=function(e,r){var t=r.frag,o=r.part;if(t.type!==A.PlaylistLevelType.AUDIO){if(!this.loadedmetadata&&t.type===A.PlaylistLevelType.MAIN){var y;(y=this.videoBuffer||this.media)!==null&&y!==void 0&&y.buffered.length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(t)){this.warn("Fragment "+t.sn+(o?" p: "+o.index:"")+" of level "+t.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}t.sn!=="initSegment"&&(this.fragPrevious=t,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(t,o)},c.onError=function(e,r){if(r.type===v.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,r);return}switch(r.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.FRAG_PARSING_ERROR:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,r);break;case v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==D.State.ERROR&&this.state!==D.State.STOPPED&&(this.state=r.fatal?D.State.ERROR:D.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="audio"&&(this.state===D.State.PARSING||this.state===D.State.PARSED)){var t=!0,o=this.getFwdBufferInfo(this.mediaBuffer,A.PlaylistLevelType.AUDIO);o&&o.len>.5&&(t=!this.reduceMaxBufferLength(o.len)),t&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,u.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(e,r){var t=r.type;t===S.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===D.State.ENDED&&(this.state=D.State.IDLE))},c._handleTransmuxComplete=function(e){var r,t="audio",o=this.hls,y=e.remuxResult,h=e.chunkMeta,L=this.getCurrentContext(h);if(!L){this.warn("The loading context changed while buffering fragment "+h.sn+" of level "+h.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(h.level);return}var R=L.frag,I=L.part,k=L.level.details,F=y.audio,W=y.text,K=y.id3,H=y.initSegment;if(!(this.fragContextChanged(R)||!k)){if(this.state=D.State.PARSING,this.audioSwitch&&F&&this.completeAudioSwitch(),H!=null&&H.tracks&&(this._bufferInitSegment(H.tracks,R,h),o.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:t,tracks:H.tracks})),F){var Y=F.startPTS,q=F.endPTS,ee=F.startDTS,ae=F.endDTS;I&&(I.elementaryStreams[S.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:q,startDTS:ee,endDTS:ae}),R.setElementaryStreamInfo(S.ElementaryStreamTypes.AUDIO,Y,q,ee,ae),this.bufferFragmentData(F,R,I,h)}if(K!=null&&(r=K.samples)!==null&&r!==void 0&&r.length){var re=a({id:t,frag:R,details:k},K);o.trigger(M.Events.FRAG_PARSING_METADATA,re)}if(W){var se=a({id:t,frag:R,details:k},W);o.trigger(M.Events.FRAG_PARSING_USERDATA,se)}}},c._bufferInitSegment=function(e,r,t){if(this.state===D.State.PARSING){e.video&&delete e.video;var o=e.audio;if(!!o){o.levelCodec=o.codec,o.id="audio",this.log("Init audio buffer, container:"+o.container+", codecs[parsed]=["+o.codec+"]"),this.hls.trigger(M.Events.BUFFER_CODECS,e);var y=o.initSegment;if(y!=null&&y.byteLength){var h={type:"audio",frag:r,part:null,chunkMeta:t,parent:r.type,data:y};this.hls.trigger(M.Events.BUFFER_APPENDING,h)}this.tick()}}},c.loadFragment=function(e,r,t){var o=this.fragmentTracker.getState(e);this.fragCurrent=e,(this.audioSwitch||o===U.FragmentState.NOT_LOADED||o===U.FragmentState.PARTIAL)&&(e.sn==="initSegment"?this._loadInitSegment(e,r):r.live&&!(0,O.isFiniteNumber)(this.initPTS[e.cc])?(this.log("Waiting for video PTS in continuity counter "+e.cc+" of live stream before loading audio fragment "+e.sn+" of level "+this.trackId),this.state=D.State.WAITING_INIT_PTS):(this.startFragRequested=!0,u.prototype.loadFragment.call(this,e,r,t)))},c.completeAudioSwitch=function(){var e=this.hls,r=this.media,t=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),u.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,e.trigger(M.Events.AUDIO_TRACK_SWITCHED,{id:t})},g}(D.default);let i=l},"./src/controller/audio-track-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>_});var O=T("./src/events.ts"),D=T("./src/errors.ts"),M=T("./src/controller/base-playlist-controller.ts"),P=T("./src/types/loader.ts");function U(p,v){for(var a=0;a<v.length;a++){var s=v[a];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(p,A(s.key),s)}}function b(p,v,a){return v&&U(p.prototype,v),a&&U(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function A(p){var v=S(p,"string");return typeof v=="symbol"?v:String(v)}function S(p,v){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var s=a.call(p,v||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(v==="string"?String:Number)(p)}function E(p,v){p.prototype=Object.create(v.prototype),p.prototype.constructor=p,x(p,v)}function x(p,v){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,n){return s.__proto__=n,s},x(p,v)}var f=function(p){E(v,p);function v(s){var n;return n=p.call(this,s,"[audio-track-controller]")||this,n.tracks=[],n.groupId=null,n.tracksInGroup=[],n.trackId=-1,n.trackName="",n.selectDefaultTrack=!0,n.registerListeners(),n}var a=v.prototype;return a.registerListeners=function(){var n=this.hls;n.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.on(O.Events.LEVEL_LOADING,this.onLevelLoading,this),n.on(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),n.on(O.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(O.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var n=this.hls;n.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.off(O.Events.LEVEL_LOADING,this.onLevelLoading,this),n.off(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),n.off(O.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(O.Events.ERROR,this.onError,this)},a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,p.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(n,d){this.tracks=d.audioTracks||[]},a.onAudioTrackLoaded=function(n,d){var l=d.id,i=d.details,u=this.tracksInGroup[l];if(!u){this.warn("Invalid audio track id "+l);return}var g=u.details;u.details=d.details,this.log("audioTrack "+l+" loaded ["+i.startSN+"-"+i.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,d,g))},a.onLevelLoading=function(n,d){this.switchLevel(d.level)},a.onLevelSwitching=function(n,d){this.switchLevel(d.level)},a.switchLevel=function(n){var d=this.hls.levels[n];if(!!(d!=null&&d.audioGroupIds)){var l=d.audioGroupIds[d.urlId];if(this.groupId!==l){this.groupId=l;var i=this.tracks.filter(function(g){return!l||g.groupId===l});this.selectDefaultTrack&&!i.some(function(g){return g.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=i;var u={audioTracks:i};this.log("Updating audio tracks, "+i.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(O.Events.AUDIO_TRACKS_UPDATED,u),this.selectInitialTrack()}}},a.onError=function(n,d){p.prototype.onError.call(this,n,d),!(d.fatal||!d.context)&&d.context.type===P.PlaylistContextType.AUDIO_TRACK&&d.context.id===this.trackId&&d.context.groupId===this.groupId&&this.retryLoadingOrFail(d)},a.setAudioTrack=function(n){var d=this.tracksInGroup;if(n<0||n>=d.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=d[this.trackId];this.log("Now switching to audio-track index "+n);var i=d[n],u=i.id,g=i.groupId,c=g===void 0?"":g,m=i.name,e=i.type,r=i.url;if(this.trackId=n,this.trackName=m,this.selectDefaultTrack=!1,this.hls.trigger(O.Events.AUDIO_TRACK_SWITCHING,{id:u,groupId:c,name:m,type:e,url:r}),!(i.details&&!i.details.live)){var t=this.switchParams(i.url,l==null?void 0:l.details);this.loadPlaylist(t)}},a.selectInitialTrack=function(){var n=this.tracksInGroup;console.assert(n.length,"Initial audio track should be selected when tracks are known");var d=this.trackName,l=this.findTrackId(d)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(O.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},a.findTrackId=function(n){for(var d=this.tracksInGroup,l=0;l<d.length;l++){var i=d[l];if((!this.selectDefaultTrack||i.default)&&(!n||n===i.name))return i.id}return-1},a.loadPlaylist=function(n){p.prototype.loadPlaylist.call(this);var d=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(d)){var l=d.id,i=d.groupId,u=d.url;if(n)try{u=n.addDirectives(u)}catch(g){this.warn("Could not construct new URL with HLS Delivery Directives: "+g)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(O.Events.AUDIO_TRACK_LOADING,{url:u,id:l,groupId:i,deliveryDirectives:n||null})}},b(v,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(n){this.selectDefaultTrack=!1,this.setAudioTrack(n)}}]),v}(M.default);let _=f},"./src/controller/base-playlist-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>U});var O=T("./src/types/level.ts"),D=T("./src/controller/level-helper.ts"),M=T("./src/utils/logger.ts"),P=T("./src/errors.ts"),U=function(){function b(S,E){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=M.logger.log.bind(M.logger,E+":"),this.warn=M.logger.warn.bind(M.logger,E+":"),this.hls=S}var A=b.prototype;return A.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},A.onError=function(E,x){x.fatal&&(x.type===P.ErrorTypes.NETWORK_ERROR||x.type===P.ErrorTypes.KEY_SYSTEM_ERROR)&&this.stopLoad()},A.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},A.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},A.stopLoad=function(){this.canLoad=!1,this.clearTimer()},A.switchParams=function(E,x){var f=x==null?void 0:x.renditionReports;if(f)for(var _=0;_<f.length;_++){var p=f[_],v=void 0;try{v=new self.URL(p.URI,x.url).href}catch(d){M.logger.warn("Could not construct new URL for Rendition Report: "+d),v=p.URI||""}if(v===E.slice(-v.length)){var a=parseInt(p["LAST-MSN"])||(x==null?void 0:x.lastPartSn),s=parseInt(p["LAST-PART"])||(x==null?void 0:x.lastPartIndex);if(this.hls.config.lowLatencyMode){var n=Math.min(x.age-x.partTarget,x.targetduration);s>=0&&n>x.partTarget&&(s+=1)}return new O.HlsUrlParameters(a,s>=0?s:void 0,O.HlsSkip.No)}}},A.loadPlaylist=function(E){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},A.shouldLoadTrack=function(E){return this.canLoad&&E&&!!E.url&&(!E.details||E.details.live)},A.playlistLoaded=function(E,x,f){var _=this,p=x.details,v=x.stats,a=self.performance.now(),s=v.loading.first?Math.max(0,a-v.loading.first):0;if(p.advancedDateTime=Date.now()-s,p.live||f!=null&&f.live){if(p.reloaded(f),f&&this.log("live playlist "+E+" "+(p.advanced?"REFRESHED "+p.lastPartSn+"-"+p.lastPartIndex:"MISSED")),f&&p.fragments.length>0&&(0,D.mergeDetails)(f,p),!this.canLoad||!p.live)return;var n,d=void 0,l=void 0;if(p.canBlockReload&&p.endSN&&p.advanced){var i=this.hls.config.lowLatencyMode,u=p.lastPartSn,g=p.endSN,c=p.lastPartIndex,m=c!==-1,e=u===g,r=i?0:c;m?(d=e?g+1:u,l=e?r:c+1):d=g+1;var t=p.age,o=t+p.ageHeader,y=Math.min(o-p.partTarget,p.targetduration*1.5);if(y>0){if(f&&y>f.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+f.tuneInGoal+" to: "+y+" with playlist age: "+p.age),y=0;else{var h=Math.floor(y/p.targetduration);if(d+=h,l!==void 0){var L=Math.round(y%p.targetduration/p.partTarget);l+=L}this.log("CDN Tune-in age: "+p.ageHeader+"s last advanced "+t.toFixed(2)+"s goal: "+y+" skip sn "+h+" to part "+l)}p.tuneInGoal=y}if(n=this.getDeliveryDirectives(p,x.deliveryDirectives,d,l),i||!e){this.loadPlaylist(n);return}}else n=this.getDeliveryDirectives(p,x.deliveryDirectives,d,l);var R=this.hls.mainForwardBufferInfo,I=R?R.end-R.len:0,k=(p.edge-I)*1e3,F=(0,D.computeReloadInterval)(p,k);p.updated?a>this.requestScheduled+F&&(this.requestScheduled=v.loading.start):this.requestScheduled=-1,d!==void 0&&p.canBlockReload?this.requestScheduled=v.loading.first+F-(p.partTarget*1e3||1e3):this.requestScheduled=(this.requestScheduled===-1?a:this.requestScheduled)+F;var W=this.requestScheduled-a;W=Math.max(0,W),this.log("reload live playlist "+E+" in "+Math.round(W)+" ms"),this.timer=self.setTimeout(function(){return _.loadPlaylist(n)},W)}else this.clearTimer()},A.getDeliveryDirectives=function(E,x,f,_){var p=(0,O.getSkipValue)(E,f);return x!=null&&x.skip&&E.deltaUpdateFailed&&(f=x.msn,_=x.part,p=O.HlsSkip.No),new O.HlsUrlParameters(f,_,p)},A.retryLoadingOrFail=function(E){var x=this,f=this.hls.config,_=this.retryCount<f.levelLoadingMaxRetry;if(_){var p;if(this.requestScheduled=-1,this.retryCount++,E.details.indexOf("LoadTimeOut")>-1&&(p=E.context)!==null&&p!==void 0&&p.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+E.details+'"'),this.loadPlaylist();else{var v=Math.min(Math.pow(2,this.retryCount)*f.levelLoadingRetryDelay,f.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return x.loadPlaylist()},v),this.warn("retry playlist loading #"+this.retryCount+" in "+v+' ms after "'+E.details+'"')}}else this.warn('cannot recover from error "'+E.details+'"'),this.clearTimer(),E.fatal=!0;return _},b}()},"./src/controller/base-stream-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{State:()=>m,default:()=>e});var O=T("./src/polyfills/number.ts"),D=T("./src/task-loop.ts"),M=T("./src/controller/fragment-tracker.ts"),P=T("./src/utils/buffer-helper.ts"),U=T("./src/utils/logger.ts"),b=T("./src/events.ts"),A=T("./src/errors.ts"),S=T("./src/types/transmuxer.ts"),E=T("./src/utils/mp4-tools.ts"),x=T("./src/utils/discontinuities.ts"),f=T("./src/controller/fragment-finders.ts"),_=T("./src/controller/level-helper.ts"),p=T("./src/loader/fragment-loader.ts"),v=T("./src/crypt/decrypter.ts"),a=T("./src/utils/time-ranges.ts"),s=T("./src/types/loader.ts");function n(r,t){for(var o=0;o<t.length;o++){var y=t[o];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(r,l(y.key),y)}}function d(r,t,o){return t&&n(r.prototype,t),o&&n(r,o),Object.defineProperty(r,"prototype",{writable:!1}),r}function l(r){var t=i(r,"string");return typeof t=="symbol"?t:String(t)}function i(r,t){if(typeof r!="object"||r===null)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var y=o.call(r,t||"default");if(typeof y!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function u(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function g(r,t){r.prototype=Object.create(t.prototype),r.prototype.constructor=r,c(r,t)}function c(r,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,h){return y.__proto__=h,y},c(r,t)}var m={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},e=function(r){g(t,r);function t(y,h,L,R){var I;return I=r.call(this)||this,I.hls=void 0,I.fragPrevious=null,I.fragCurrent=null,I.fragmentTracker=void 0,I.transmuxer=null,I._state=m.STOPPED,I.media=null,I.mediaBuffer=null,I.config=void 0,I.bitrateTest=!1,I.lastCurrentTime=0,I.nextLoadPosition=0,I.startPosition=0,I.loadedmetadata=!1,I.fragLoadError=0,I.retryDate=0,I.levels=null,I.fragmentLoader=void 0,I.keyLoader=void 0,I.levelLastLoaded=null,I.startFragRequested=!1,I.decrypter=void 0,I.initPTS=[],I.onvseeking=null,I.onvended=null,I.logPrefix="",I.log=void 0,I.warn=void 0,I.logPrefix=R,I.log=U.logger.log.bind(U.logger,R+":"),I.warn=U.logger.warn.bind(U.logger,R+":"),I.hls=y,I.fragmentLoader=new p.default(y.config),I.keyLoader=L,I.fragmentTracker=h,I.config=y.config,I.decrypter=new v.default(y.config),y.on(b.Events.LEVEL_SWITCHING,I.onLevelSwitching,u(I)),I}var o=t.prototype;return o.doTick=function(){this.onTickEnd()},o.onTickEnd=function(){},o.startLoad=function(h){},o.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var h=this.fragCurrent;h&&(h.abortRequests(),this.fragmentTracker.removeFragment(h)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=m.STOPPED},o._streamEnded=function(h,L){if(L.live||h.nextStart||!h.end||!this.media)return!1;var R=L.partList;if(R!=null&&R.length){var I=R[R.length-1],k=P.BufferHelper.isBuffered(this.media,I.start+I.duration/2);return k}var F=L.fragments[L.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(F)},o.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var h;return(h=this.levels[this.levelLastLoaded])===null||h===void 0?void 0:h.details}},o.onMediaAttached=function(h,L){var R=this.media=this.mediaBuffer=L.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),R.addEventListener("seeking",this.onvseeking),R.addEventListener("ended",this.onvended);var I=this.config;this.levels&&I.autoStartLoad&&this.state===m.STOPPED&&this.startLoad(I.startPosition)},o.onMediaDetaching=function(){var h=this.media;h!=null&&h.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),h&&this.onvseeking&&this.onvended&&(h.removeEventListener("seeking",this.onvseeking),h.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()},o.onMediaSeeking=function(){var h=this.config,L=this.fragCurrent,R=this.media,I=this.mediaBuffer,k=this.state,F=R?R.currentTime:0,W=P.BufferHelper.bufferInfo(I||R,F,h.maxBufferHole);if(this.log("media seeking to "+((0,O.isFiniteNumber)(F)?F.toFixed(3):F)+", state: "+k),this.state===m.ENDED)this.resetLoadingState();else if(L){var K=h.maxFragLookUpTolerance,H=L.start-K,Y=L.start+L.duration+K;if(!W.len||Y<W.start||H>W.end){var q=F>Y;(F<H||q)&&(q&&L.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),L.abortRequests()),this.resetLoadingState())}}R&&(this.lastCurrentTime=F),!this.loadedmetadata&&!W.len&&(this.nextLoadPosition=this.startPosition=F),this.tickImmediate()},o.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},o.onLevelSwitching=function(h,L){this.fragLoadError=0},o.onHandlerDestroying=function(){this.stopLoad(),r.prototype.onHandlerDestroying.call(this)},o.onHandlerDestroyed=function(){this.state=m.STOPPED,this.hls.off(b.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,r.prototype.onHandlerDestroyed.call(this)},o.loadFragment=function(h,L,R){this._loadFragForPlayback(h,L,R)},o._loadFragForPlayback=function(h,L,R){var I=this,k=function(W){if(I.fragContextChanged(h)){I.warn("Fragment "+h.sn+(W.part?" p: "+W.part.index:"")+" of level "+h.level+" was dropped during download."),I.fragmentTracker.removeFragment(h);return}h.stats.chunkCount++,I._handleFragmentLoadProgress(W)};this._doFragLoad(h,L,R,k).then(function(F){if(!!F){I.fragLoadError=0;var W=I.state;if(I.fragContextChanged(h)){(W===m.FRAG_LOADING||!I.fragCurrent&&W===m.PARSING)&&(I.fragmentTracker.removeFragment(h),I.state=m.IDLE);return}"payload"in F&&(I.log("Loaded fragment "+h.sn+" of level "+h.level),I.hls.trigger(b.Events.FRAG_LOADED,F)),I._handleFragmentLoadComplete(F)}}).catch(function(F){I.state===m.STOPPED||I.state===m.ERROR||(I.warn(F),I.resetFragmentLoading(h))})},o.flushMainBuffer=function(h,L,R){if(R===void 0&&(R=null),!!(h-L)){var I={startOffset:h,endOffset:L,type:R};this.fragLoadError=0,this.hls.trigger(b.Events.BUFFER_FLUSHING,I)}},o._loadInitSegment=function(h,L){var R=this;this._doFragLoad(h,L).then(function(I){if(!I||R.fragContextChanged(h)||!R.levels)throw new Error("init load aborted");return I}).then(function(I){var k=R.hls,F=I.payload,W=h.decryptdata;if(F&&F.byteLength>0&&W&&W.key&&W.iv&&W.method==="AES-128"){var K=self.performance.now();return R.decrypter.decrypt(new Uint8Array(F),W.key.buffer,W.iv.buffer).then(function(H){var Y=self.performance.now();return k.trigger(b.Events.FRAG_DECRYPTED,{frag:h,payload:H,stats:{tstart:K,tdecrypt:Y}}),I.payload=H,I})}return I}).then(function(I){var k=R.fragCurrent,F=R.hls,W=R.levels;if(!W)throw new Error("init load aborted, missing levels");var K=W[h.level].details;console.assert(K,"Level details are defined when init segment is loaded");var H=h.stats;R.state=m.IDLE,R.fragLoadError=0,h.data=new Uint8Array(I.payload),H.parsing.start=H.buffering.start=self.performance.now(),H.parsing.end=H.buffering.end=self.performance.now(),I.frag===k&&F.trigger(b.Events.FRAG_BUFFERED,{stats:H,frag:k,part:null,id:h.type}),R.tick()}).catch(function(I){R.state===m.STOPPED||R.state===m.ERROR||(R.warn(I),R.resetFragmentLoading(h))})},o.fragContextChanged=function(h){var L=this.fragCurrent;return!h||!L||h.level!==L.level||h.sn!==L.sn||h.urlId!==L.urlId},o.fragBufferedComplete=function(h,L){var R,I,k=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+h.type+" sn: "+h.sn+(L?" part: "+L.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+h.level+" "+(k?a.default.toString(P.BufferHelper.getBuffered(k)):"(detached)")),this.state=m.IDLE,k&&(!this.loadedmetadata&&h.type==s.PlaylistLevelType.MAIN&&k.buffered.length&&((R=this.fragCurrent)===null||R===void 0?void 0:R.sn)===((I=this.fragPrevious)===null||I===void 0?void 0:I.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},o.seekToStartPos=function(){},o._handleFragmentLoadComplete=function(h){var L=this.transmuxer;if(!!L){var R=h.frag,I=h.part,k=h.partsLoaded,F=!k||k.length===0||k.some(function(K){return!K}),W=new S.ChunkMetadata(R.level,R.sn,R.stats.chunkCount+1,0,I?I.index:-1,!F);L.flush(W)}},o._handleFragmentLoadProgress=function(h){},o._doFragLoad=function(h,L,R,I){var k,F=this;if(R===void 0&&(R=null),!this.levels)throw new Error("frag load aborted, missing levels");var W=null;if(h.encrypted&&!((k=h.decryptdata)!==null&&k!==void 0&&k.key)?(this.log("Loading key for "+h.sn+" of ["+L.startSN+"-"+L.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+h.level),this.state=m.KEY_LOADING,this.fragCurrent=h,W=this.keyLoader.load(h).then(function(ee){if(!F.fragContextChanged(ee.frag))return F.hls.trigger(b.Events.KEY_LOADED,ee),ee}),this.hls.trigger(b.Events.KEY_LOADING,{frag:h}),this.throwIfFragContextChanged("KEY_LOADING")):!h.encrypted&&L.encryptedFragments.length&&this.keyLoader.loadClear(h,L.encryptedFragments),R=Math.max(h.start,R||0),this.config.lowLatencyMode&&L){var K=L.partList;if(K&&I){R>h.end&&L.fragmentHint&&(h=L.fragmentHint);var H=this.getNextPart(K,h,R);if(H>-1){var Y=K[H];return this.log("Loading part sn: "+h.sn+" p: "+Y.index+" cc: "+h.cc+" of playlist ["+L.startSN+"-"+L.endSN+"] parts [0-"+H+"-"+(K.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+h.level+", target: "+parseFloat(R.toFixed(3))),this.nextLoadPosition=Y.start+Y.duration,this.state=m.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:h,part:K[H],targetBufferTime:R}),this.throwIfFragContextChanged("FRAG_LOADING parts"),W?W.then(function(ee){return!ee||F.fragContextChanged(ee.frag)?null:F.doFragPartsLoad(h,K,H,I)}).catch(function(ee){return F.handleFragLoadError(ee)}):this.doFragPartsLoad(h,K,H,I).catch(function(ee){return F.handleFragLoadError(ee)})}else if(!h.url||this.loadedEndOfParts(K,R))return Promise.resolve(null)}}this.log("Loading fragment "+h.sn+" cc: "+h.cc+" "+(L?"of ["+L.startSN+"-"+L.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+h.level+", target: "+parseFloat(R.toFixed(3))),(0,O.isFiniteNumber)(h.sn)&&!this.bitrateTest&&(this.nextLoadPosition=h.start+h.duration),this.state=m.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:h,targetBufferTime:R}),this.throwIfFragContextChanged("FRAG_LOADING");var q=this.config.progressive;return q&&W?W.then(function(ee){return!ee||F.fragContextChanged(ee==null?void 0:ee.frag)?null:F.fragmentLoader.load(h,I)}).catch(function(ee){return F.handleFragLoadError(ee)}):Promise.all([this.fragmentLoader.load(h,q?I:void 0),W]).then(function(ee){var ae=ee[0];return!q&&ae&&I&&I(ae),ae}).catch(function(ee){return F.handleFragLoadError(ee)})},o.throwIfFragContextChanged=function(h){if(this.fragCurrent===null)throw new Error("frag load aborted, context changed in "+h)},o.doFragPartsLoad=function(h,L,R,I){var k=this;return new Promise(function(F,W){var K=[],H=function Y(q){var ee=L[q];k.fragmentLoader.loadPart(h,ee,I).then(function(ae){K[ee.index]=ae;var re=ae.part;k.hls.trigger(b.Events.FRAG_LOADED,ae);var se=L[q+1];if(se&&se.fragment===h)Y(q+1);else return F({frag:h,part:re,partsLoaded:K})}).catch(W)};H(R)})},o.handleFragLoadError=function(h){if("data"in h){var L=h.data;h.data&&L.details===A.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(L.frag,L.part):this.hls.trigger(b.Events.ERROR,L)}else this.hls.trigger(b.Events.ERROR,{type:A.ErrorTypes.OTHER_ERROR,details:A.ErrorDetails.INTERNAL_EXCEPTION,err:h,fatal:!0});return null},o._handleTransmuxerFlush=function(h){var L=this.getCurrentContext(h);if(!L||this.state!==m.PARSING){!this.fragCurrent&&this.state!==m.STOPPED&&this.state!==m.ERROR&&(this.state=m.IDLE);return}var R=L.frag,I=L.part,k=L.level,F=self.performance.now();R.stats.parsing.end=F,I&&(I.stats.parsing.end=F),this.updateLevelTiming(R,I,k,h.partial)},o.getCurrentContext=function(h){var L=this.levels,R=h.level,I=h.sn,k=h.part;if(!L||!L[R])return this.warn("Levels object was unset while buffering fragment "+I+" of level "+R+". The current chunk will not be buffered."),null;var F=L[R],W=k>-1?(0,_.getPartWith)(F,I,k):null,K=W?W.fragment:(0,_.getFragmentWithSN)(F,I,this.fragCurrent);return K?{frag:K,part:W,level:F}:null},o.bufferFragmentData=function(h,L,R,I){if(!(!h||this.state!==m.PARSING)){var k=h.data1,F=h.data2,W=k;if(k&&F&&(W=(0,E.appendUint8Array)(k,F)),!(!W||!W.length)){var K={type:h.type,frag:L,part:R,chunkMeta:I,parent:L.type,data:W};this.hls.trigger(b.Events.BUFFER_APPENDING,K),h.dropped&&h.independent&&!R&&this.flushBufferGap(L)}}},o.flushBufferGap=function(h){var L=this.media;if(!!L){if(!P.BufferHelper.isBuffered(L,L.currentTime)){this.flushMainBuffer(0,h.start);return}var R=L.currentTime,I=P.BufferHelper.bufferInfo(L,R,0),k=h.duration,F=Math.min(this.config.maxFragLookUpTolerance*2,k*.25),W=Math.max(Math.min(h.start-F,I.end-F),R+F);h.start-W>F&&this.flushMainBuffer(W,h.start)}},o.getFwdBufferInfo=function(h,L){var R=this.config,I=this.getLoadPosition();if(!(0,O.isFiniteNumber)(I))return null;var k=P.BufferHelper.bufferInfo(h,I,R.maxBufferHole);if(k.len===0&&k.nextStart!==void 0){var F=this.fragmentTracker.getBufferedFrag(I,L);if(F&&k.nextStart<F.end)return P.BufferHelper.bufferInfo(h,I,Math.max(k.nextStart,R.maxBufferHole))}return k},o.getMaxBufferLength=function(h){var L=this.config,R;return h?R=Math.max(8*L.maxBufferSize/h,L.maxBufferLength):R=L.maxBufferLength,Math.min(R,L.maxMaxBufferLength)},o.reduceMaxBufferLength=function(h){var L=this.config,R=h||L.maxBufferLength;return L.maxMaxBufferLength>=R?(L.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+L.maxMaxBufferLength+"s"),!0):!1},o.getNextFragment=function(h,L){var R=L.fragments,I=R.length;if(!I)return null;var k=this.config,F=R[0].start,W;if(L.live){var K=k.initialLiveManifestSize;if(I<K)return this.warn("Not enough fragments to start playback (have: "+I+", need: "+K+")"),null;!L.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(W=this.getInitialLiveFragment(L,R),this.startPosition=W?this.hls.liveSyncPosition||W.start:h)}else h<=F&&(W=R[0]);if(!W){var H=k.lowLatencyMode?L.partEnd:L.fragmentEnd;W=this.getFragmentAtPosition(h,H,L)}return this.mapToInitFragWhenRequired(W)},o.mapToInitFragWhenRequired=function(h){return h!=null&&h.initSegment&&!(h!=null&&h.initSegment.data)&&!this.bitrateTest?h.initSegment:h},o.getNextPart=function(h,L,R){for(var I=-1,k=!1,F=!0,W=0,K=h.length;W<K;W++){var H=h[W];if(F=F&&!H.independent,I>-1&&R<H.start)break;var Y=H.loaded;Y?I=-1:(k||H.independent||F)&&H.fragment===L&&(I=W),k=Y}return I},o.loadedEndOfParts=function(h,L){var R=h[h.length-1];return R&&L>R.start&&R.loaded},o.getInitialLiveFragment=function(h,L){var R=this.fragPrevious,I=null;if(R){if(h.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+R.programDateTime),I=(0,f.findFragmentByPDT)(L,R.endProgramDateTime,this.config.maxFragLookUpTolerance)),!I){var k=R.sn+1;if(k>=h.startSN&&k<=h.endSN){var F=L[k-h.startSN];R.cc===F.cc&&(I=F,this.log("Live playlist, switching playlist, load frag with next SN: "+I.sn))}I||(I=(0,f.findFragWithCC)(L,R.cc),I&&this.log("Live playlist, switching playlist, load frag with same CC: "+I.sn))}}else{var W=this.hls.liveSyncPosition;W!==null&&(I=this.getFragmentAtPosition(W,this.bitrateTest?h.fragmentEnd:h.edge,h))}return I},o.getFragmentAtPosition=function(h,L,R){var I=this.config,k=this.fragPrevious,F=R.fragments,W=R.endSN,K=R.fragmentHint,H=I.maxFragLookUpTolerance,Y=!!(I.lowLatencyMode&&R.partList&&K);Y&&K&&!this.bitrateTest&&(F=F.concat(K),W=K.sn);var q;if(h<L){var ee=h>L-H?0:H;q=(0,f.findFragmentByPTS)(k,F,h,ee)}else q=F[F.length-1];if(q){var ae=q.sn-R.startSN;if(this.fragmentTracker.getState(q)===M.FragmentState.OK&&(k=q),k&&q.sn===k.sn&&!Y){var re=k&&q.level===k.level;if(re){var se=F[ae+1];q.sn<W&&this.fragmentTracker.getState(se)!==M.FragmentState.OK?(this.log("SN "+q.sn+" just loaded, load next one: "+se.sn),q=se):q=null}}}return q},o.synchronizeToLiveEdge=function(h){var L=this.config,R=this.media;if(!!R){var I=this.hls.liveSyncPosition,k=R.currentTime,F=h.fragments[0].start,W=h.edge,K=k>=F-L.maxFragLookUpTolerance&&k<=W;if(I!==null&&R.duration>I&&(k<I||!K)){var H=L.liveMaxLatencyDuration!==void 0?L.liveMaxLatencyDuration:L.liveMaxLatencyDurationCount*h.targetduration;(!K&&R.readyState<4||k<W-H)&&(this.loadedmetadata||(this.nextLoadPosition=I),R.readyState&&(this.warn("Playback: "+k.toFixed(3)+" is located too far from the end of live sliding playlist: "+W+", reset currentTime to : "+I.toFixed(3)),R.currentTime=I))}}},o.alignPlaylists=function(h,L){var R=this.levels,I=this.levelLastLoaded,k=this.fragPrevious,F=I!==null?R[I]:null,W=h.fragments.length;if(!W)return this.warn("No fragments in live playlist"),0;var K=h.fragments[0].start,H=!L,Y=h.alignedSliding&&(0,O.isFiniteNumber)(K);if(H||!Y&&!K){(0,x.alignStream)(k,F,h);var q=h.fragments[0].start;return this.log("Live playlist sliding: "+q.toFixed(2)+" start-sn: "+(L?L.startSN:"na")+"->"+h.startSN+" prev-sn: "+(k?k.sn:"na")+" fragments: "+W),q}return K},o.waitForCdnTuneIn=function(h){var L=3;return h.live&&h.canBlockReload&&h.partTarget&&h.tuneInGoal>Math.max(h.partHoldBack,h.partTarget*L)},o.setStartPosition=function(h,L){var R=this.startPosition;if(R<L&&(R=-1),R===-1||this.lastCurrentTime===-1){var I=h.startTimeOffset;(0,O.isFiniteNumber)(I)?(R=L+I,I<0&&(R+=h.totalduration),R=Math.min(Math.max(L,R),L+h.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+R),this.startPosition=R):h.live?R=this.hls.liveSyncPosition||L:this.startPosition=R=0,this.lastCurrentTime=R}this.nextLoadPosition=R},o.getLoadPosition=function(){var h=this.media,L=0;return this.loadedmetadata&&h?L=h.currentTime:this.nextLoadPosition&&(L=this.nextLoadPosition),L},o.handleFragLoadAborted=function(h,L){this.transmuxer&&h.sn!=="initSegment"&&h.stats.aborted&&(this.warn("Fragment "+h.sn+(L?" part"+L.index:"")+" of level "+h.level+" was aborted"),this.resetFragmentLoading(h))},o.resetFragmentLoading=function(h){(!this.fragCurrent||!this.fragContextChanged(h)&&this.state!==m.FRAG_LOADING_WAITING_RETRY)&&(this.state=m.IDLE)},o.onFragmentOrKeyLoadError=function(h,L){if(L.fatal){this.stopLoad(),this.state=m.ERROR;return}var R=this.config;if(L.chunkMeta){var I=this.getCurrentContext(L.chunkMeta);I&&(L.frag=I.frag,L.levelRetry=!0,this.fragLoadError=R.fragLoadingMaxRetry)}var k=L.frag;if(!(!k||k.type!==h)){var F=this.fragCurrent;if(console.assert(F&&k.sn===F.sn&&k.level===F.level&&k.urlId===F.urlId,"Frag load error must match current frag to retry"),this.fragLoadError+1<=R.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var W=Math.min(Math.pow(2,this.fragLoadError)*R.fragLoadingRetryDelay,R.fragLoadingMaxRetryTimeout);this.warn("Fragment "+k.sn+" of "+h+" "+k.level+" failed to load, retrying in "+W+"ms"),this.retryDate=self.performance.now()+W,this.fragLoadError++,this.state=m.FRAG_LOADING_WAITING_RETRY}else L.levelRetry?(h===s.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=m.IDLE):(U.logger.error(L.details+" reaches max retry, redispatch as fatal ..."),L.fatal=!0,this.hls.stopLoad(),this.state=m.ERROR)}},o.afterBufferFlushed=function(h,L,R){if(!!h){var I=P.BufferHelper.getBuffered(h);this.fragmentTracker.detectEvictedFragments(L,I,R),this.state===m.ENDED&&this.resetLoadingState()}},o.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=m.IDLE},o.resetStartWhenNotLoaded=function(h){if(!this.loadedmetadata){this.startFragRequested=!1;var L=this.levels?this.levels[h].details:null;L!=null&&L.live?(this.startPosition=-1,this.setStartPosition(L,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},o.updateLevelTiming=function(h,L,R,I){var k=this,F=R.details;console.assert(!!F,"level.details must be defined");var W=Object.keys(h.elementaryStreams).reduce(function(K,H){var Y=h.elementaryStreams[H];if(Y){var q=Y.endPTS-Y.startPTS;if(q<=0)return k.warn("Could not parse fragment "+h.sn+" "+H+" duration reliably ("+q+")"),K||!1;var ee=I?0:(0,_.updateFragPTSDTS)(F,h,Y.startPTS,Y.endPTS,Y.startDTS,Y.endDTS);return k.hls.trigger(b.Events.LEVEL_PTS_UPDATED,{details:F,level:R,drift:ee,type:H,frag:h,start:Y.startPTS,end:Y.endPTS}),!0}return K},!1);W||(this.warn("Found no media in fragment "+h.sn+" of level "+R.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=m.PARSED,this.hls.trigger(b.Events.FRAG_PARSED,{frag:h,part:L})},o.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},d(t,[{key:"state",get:function(){return this._state},set:function(h){var L=this._state;L!==h&&(this._state=h,this.log(L+"->"+h))}}]),t}(D.default)},"./src/controller/buffer-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>f});var O=T("./src/polyfills/number.ts"),D=T("./src/events.ts"),M=T("./src/utils/logger.ts"),P=T("./src/errors.ts"),U=T("./src/utils/buffer-helper.ts"),b=T("./src/utils/mediasource-helper.ts"),A=T("./src/loader/fragment.ts"),S=T("./src/controller/buffer-operation-queue.ts"),E=(0,b.getMediaSource)(),x=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function _(v){var a=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 s=a.hls,n=a.media,d=a.mediaSource;M.logger.log("[buffer-controller]: Media source opened"),n&&(a.updateMediaElementDuration(),s.trigger(D.Events.MEDIA_ATTACHED,{media:n})),d&&d.removeEventListener("sourceopen",a._onMediaSourceOpen),a.checkPendingTracks()},this._onMediaSourceClose=function(){M.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){M.logger.log("[buffer-controller]: Media source ended")},this.hls=v,this._initSourceBuffer(),this.registerListeners()}var p=_.prototype;return p.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},p.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},p.registerListeners=function(){var a=this.hls;a.on(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.on(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.on(D.Events.BUFFER_RESET,this.onBufferReset,this),a.on(D.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.on(D.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.on(D.Events.BUFFER_EOS,this.onBufferEos,this),a.on(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.on(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.on(D.Events.FRAG_PARSED,this.onFragParsed,this),a.on(D.Events.FRAG_CHANGED,this.onFragChanged,this)},p.unregisterListeners=function(){var a=this.hls;a.off(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(D.Events.MANIFEST_PARSED,this.onManifestParsed,this),a.off(D.Events.BUFFER_RESET,this.onBufferReset,this),a.off(D.Events.BUFFER_APPENDING,this.onBufferAppending,this),a.off(D.Events.BUFFER_CODECS,this.onBufferCodecs,this),a.off(D.Events.BUFFER_EOS,this.onBufferEos,this),a.off(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),a.off(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this),a.off(D.Events.FRAG_PARSED,this.onFragParsed,this),a.off(D.Events.FRAG_CHANGED,this.onFragChanged,this)},p._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new S.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},p.onManifestParsed=function(a,s){var n=2;(s.audio&&!s.video||!s.altAudio)&&(n=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=n,this.details=null,M.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(a,s){var n=this.media=s.media;if(n&&E){var d=this.mediaSource=new E;d.addEventListener("sourceopen",this._onMediaSourceOpen),d.addEventListener("sourceended",this._onMediaSourceEnded),d.addEventListener("sourceclose",this._onMediaSourceClose),n.src=self.URL.createObjectURL(d),this._objectUrl=n.src}},p.onMediaDetaching=function(){var a=this.media,s=this.mediaSource,n=this._objectUrl;if(s){if(M.logger.log("[buffer-controller]: media source detaching"),s.readyState==="open")try{s.endOfStream()}catch(d){M.logger.warn("[buffer-controller]: onMediaDetaching: "+d.message+" while calling endOfStream")}this.onBufferReset(),s.removeEventListener("sourceopen",this._onMediaSourceOpen),s.removeEventListener("sourceended",this._onMediaSourceEnded),s.removeEventListener("sourceclose",this._onMediaSourceClose),a&&(n&&self.URL.revokeObjectURL(n),a.src===n?(a.removeAttribute("src"),a.load()):M.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(D.Events.MEDIA_DETACHED,void 0)},p.onBufferReset=function(){var a=this;this.getSourceBufferTypes().forEach(function(s){var n=a.sourceBuffer[s];try{n&&(a.removeBufferListeners(s),a.mediaSource&&a.mediaSource.removeSourceBuffer(n),a.sourceBuffer[s]=void 0)}catch(d){M.logger.warn("[buffer-controller]: Failed to reset the "+s+" buffer",d)}}),this._initSourceBuffer()},p.onBufferCodecs=function(a,s){var n=this,d=this.getSourceBufferTypes().length;Object.keys(s).forEach(function(l){if(d){var i=n.tracks[l];if(i&&typeof i.buffer.changeType=="function"){var u=s[l],g=u.id,c=u.codec,m=u.levelCodec,e=u.container,r=u.metadata,t=(i.levelCodec||i.codec).replace(x,"$1"),o=(m||c).replace(x,"$1");if(t!==o){var y=e+";codecs="+(m||c);n.appendChangeType(l,y),M.logger.log("[buffer-controller]: switching codec "+t+" to "+o),n.tracks[l]={buffer:i.buffer,codec:c,container:e,levelCodec:m,metadata:r,id:g}}}}else n.pendingTracks[l]=s[l]}),!d&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(a,s){var n=this,d=this.operationQueue,l={execute:function(){var u=n.sourceBuffer[a];u&&(M.logger.log("[buffer-controller]: changing "+a+" sourceBuffer type to "+s),u.changeType(s)),d.shiftAndExecuteNext(a)},onStart:function(){},onComplete:function(){},onError:function(u){M.logger.warn("[buffer-controller]: Failed to change "+a+" SourceBuffer type",u)}};d.append(l,a)},p.onBufferAppending=function(a,s){var n=this,d=this.hls,l=this.operationQueue,i=this.tracks,u=s.data,g=s.type,c=s.frag,m=s.part,e=s.chunkMeta,r=e.buffering[g],t=self.performance.now();r.start=t;var o=c.stats.buffering,y=m?m.stats.buffering:null;o.start===0&&(o.start=t),y&&y.start===0&&(y.start=t);var h=i.audio,L=!1;g==="audio"&&(h==null?void 0:h.container)==="audio/mpeg"&&(L=!this.lastMpegAudioChunk||e.id===1||this.lastMpegAudioChunk.sn!==e.sn,this.lastMpegAudioChunk=e);var R=c.start,I={execute:function(){if(r.executeStart=self.performance.now(),L){var F=n.sourceBuffer[g];if(F){var W=R-F.timestampOffset;Math.abs(W)>=.1&&(M.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+R+" (delta: "+W+") sn: "+c.sn+")"),F.timestampOffset=R)}}n.appendExecutor(u,g)},onStart:function(){},onComplete:function(){var F=self.performance.now();r.executeEnd=r.end=F,o.first===0&&(o.first=F),y&&y.first===0&&(y.first=F);var W=n.sourceBuffer,K={};for(var H in W)K[H]=U.BufferHelper.getBuffered(W[H]);n.appendError=0,n.hls.trigger(D.Events.BUFFER_APPENDED,{type:g,frag:c,part:m,chunkMeta:e,parent:c.type,timeRanges:K})},onError:function(F){M.logger.error("[buffer-controller]: Error encountered while trying to append to the "+g+" SourceBuffer",F);var W={type:P.ErrorTypes.MEDIA_ERROR,parent:c.type,details:P.ErrorDetails.BUFFER_APPEND_ERROR,err:F,fatal:!1};F.code===DOMException.QUOTA_EXCEEDED_ERR?W.details=P.ErrorDetails.BUFFER_FULL_ERROR:(n.appendError++,W.details=P.ErrorDetails.BUFFER_APPEND_ERROR,n.appendError>d.config.appendErrorMaxRetry&&(M.logger.error("[buffer-controller]: Failed "+d.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),W.fatal=!0,d.stopLoad())),d.trigger(D.Events.ERROR,W)}};l.append(I,g)},p.onBufferFlushing=function(a,s){var n=this,d=this.operationQueue,l=function(u){return{execute:n.removeExecutor.bind(n,u,s.startOffset,s.endOffset),onStart:function(){},onComplete:function(){n.hls.trigger(D.Events.BUFFER_FLUSHED,{type:u})},onError:function(c){M.logger.warn("[buffer-controller]: Failed to remove from "+u+" SourceBuffer",c)}}};s.type?d.append(l(s.type),s.type):this.getSourceBufferTypes().forEach(function(i){d.append(l(i),i)})},p.onFragParsed=function(a,s){var n=this,d=s.frag,l=s.part,i=[],u=l?l.elementaryStreams:d.elementaryStreams;u[A.ElementaryStreamTypes.AUDIOVIDEO]?i.push("audiovideo"):(u[A.ElementaryStreamTypes.AUDIO]&&i.push("audio"),u[A.ElementaryStreamTypes.VIDEO]&&i.push("video"));var g=function(){var m=self.performance.now();d.stats.buffering.end=m,l&&(l.stats.buffering.end=m);var e=l?l.stats:d.stats;n.hls.trigger(D.Events.FRAG_BUFFERED,{frag:d,part:l,stats:e,id:d.type})};i.length===0&&M.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+d.type+" level: "+d.level+" sn: "+d.sn),this.blockBuffers(g,i)},p.onFragChanged=function(a,s){this.flushBackBuffer()},p.onBufferEos=function(a,s){var n=this,d=this.getSourceBufferTypes().reduce(function(l,i){var u=n.sourceBuffer[i];return u&&(!s.type||s.type===i)&&(u.ending=!0,u.ended||(u.ended=!0,M.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS"))),l&&!!(!u||u.ended)},!0);d&&(M.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){n.getSourceBufferTypes().forEach(function(i){var u=n.sourceBuffer[i];u&&(u.ending=!1)});var l=n.mediaSource;if(!l||l.readyState!=="open"){l&&M.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+l.readyState);return}M.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),l.endOfStream()}))},p.onLevelUpdated=function(a,s){var n=s.details;!n.fragments.length||(this.details=n,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},p.flushBackBuffer=function(){var a=this.hls,s=this.details,n=this.media,d=this.sourceBuffer;if(!(!n||s===null)){var l=this.getSourceBufferTypes();if(!!l.length){var i=s.live&&a.config.liveBackBufferLength!==null?a.config.liveBackBufferLength:a.config.backBufferLength;if(!(!(0,O.isFiniteNumber)(i)||i<0)){var u=n.currentTime,g=s.levelTargetDuration,c=Math.max(i,g),m=Math.floor(u/g)*g-c;l.forEach(function(e){var r=d[e];if(r){var t=U.BufferHelper.getBuffered(r);if(t.length>0&&m>t.start(0)){if(a.trigger(D.Events.BACK_BUFFER_REACHED,{bufferEnd:m}),s.live)a.trigger(D.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:m});else if(r.ended&&t.end(t.length-1)-u<g*2){M.logger.info("[buffer-controller]: Cannot flush "+e+" back buffer while SourceBuffer is in ended state");return}a.trigger(D.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:m,type:e})}}})}}}},p.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var a=this.details,s=this.hls,n=this.media,d=this.mediaSource,l=a.fragments[0].start+a.totalduration,i=n.duration,u=(0,O.isFiniteNumber)(d.duration)?d.duration:0;a.live&&s.config.liveDurationInfinity?(M.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),d.duration=1/0,this.updateSeekableRange(a)):(l>u&&l>i||!(0,O.isFiniteNumber)(i))&&(M.logger.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),d.duration=l)}},p.updateSeekableRange=function(a){var s=this.mediaSource,n=a.fragments,d=n.length;if(d&&a.live&&s!==null&&s!==void 0&&s.setLiveSeekableRange){var l=Math.max(0,n[0].start),i=Math.max(l,l+a.totalduration);s.setLiveSeekableRange(l,i)}},p.checkPendingTracks=function(){var a=this.bufferCodecEventsExpected,s=this.operationQueue,n=this.pendingTracks,d=Object.keys(n).length;if(d&&!a||d===2){this.createSourceBuffers(n),this.pendingTracks={};var l=this.getSourceBufferTypes();if(l.length===0){this.hls.trigger(D.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}l.forEach(function(i){s.executeNext(i)})}},p.createSourceBuffers=function(a){var s=this.sourceBuffer,n=this.mediaSource;if(!n)throw Error("createSourceBuffers called when mediaSource was null");var d=0;for(var l in a)if(!s[l]){var i=a[l];if(!i)throw Error("source buffer exists for track "+l+", however track does not");var u=i.levelCodec||i.codec,g=i.container+";codecs="+u;M.logger.log("[buffer-controller]: creating sourceBuffer("+g+")");try{var c=s[l]=n.addSourceBuffer(g),m=l;this.addBufferListener(m,"updatestart",this._onSBUpdateStart),this.addBufferListener(m,"updateend",this._onSBUpdateEnd),this.addBufferListener(m,"error",this._onSBUpdateError),this.tracks[l]={buffer:c,codec:u,container:i.container,levelCodec:i.levelCodec,metadata:i.metadata,id:i.id},d++}catch(e){M.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(D.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:g})}}d&&this.hls.trigger(D.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(a){var s=this.operationQueue,n=s.current(a);n.onStart()},p._onSBUpdateEnd=function(a){var s=this.operationQueue,n=s.current(a);n.onComplete(),s.shiftAndExecuteNext(a)},p._onSBUpdateError=function(a,s){M.logger.error("[buffer-controller]: "+a+" SourceBuffer error",s),this.hls.trigger(D.Events.ERROR,{type:P.ErrorTypes.MEDIA_ERROR,details:P.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var n=this.operationQueue.current(a);n&&n.onError(s)},p.removeExecutor=function(a,s,n){var d=this.media,l=this.mediaSource,i=this.operationQueue,u=this.sourceBuffer,g=u[a];if(!d||!l||!g){M.logger.warn("[buffer-controller]: Attempting to remove from the "+a+" SourceBuffer, but it does not exist"),i.shiftAndExecuteNext(a);return}var c=(0,O.isFiniteNumber)(d.duration)?d.duration:1/0,m=(0,O.isFiniteNumber)(l.duration)?l.duration:1/0,e=Math.max(0,s),r=Math.min(n,c,m);r>e&&!g.ending?(g.ended=!1,M.logger.log("[buffer-controller]: Removing ["+e+","+r+"] from the "+a+" SourceBuffer"),console.assert(!g.updating,a+" sourceBuffer must not be updating"),g.remove(e,r)):i.shiftAndExecuteNext(a)},p.appendExecutor=function(a,s){var n=this.operationQueue,d=this.sourceBuffer,l=d[s];if(!l){M.logger.warn("[buffer-controller]: Attempting to append to the "+s+" SourceBuffer, but it does not exist"),n.shiftAndExecuteNext(s);return}l.ended=!1,console.assert(!l.updating,s+" sourceBuffer must not be updating"),l.appendBuffer(a)},p.blockBuffers=function(a,s){var n=this;if(s===void 0&&(s=this.getSourceBufferTypes()),!s.length){M.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(a);return}var d=this.operationQueue,l=s.map(function(i){return d.appendBlocker(i)});Promise.all(l).then(function(){a(),s.forEach(function(i){var u=n.sourceBuffer[i];(!u||!u.updating)&&d.shiftAndExecuteNext(i)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(a,s,n){var d=this.sourceBuffer[a];if(!!d){var l=n.bind(this,a);this.listeners[a].push({event:s,listener:l}),d.addEventListener(s,l)}},p.removeBufferListeners=function(a){var s=this.sourceBuffer[a];!s||this.listeners[a].forEach(function(n){s.removeEventListener(n.event,n.listener)})},_}()},"./src/controller/buffer-operation-queue.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O=T("./src/utils/logger.ts"),D=function(){function M(U){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=U}var P=M.prototype;return P.append=function(b,A){var S=this.queues[A];S.push(b),S.length===1&&this.buffers[A]&&this.executeNext(A)},P.insertAbort=function(b,A){var S=this.queues[A];S.unshift(b),this.executeNext(A)},P.appendBlocker=function(b){var A,S=new Promise(function(x){A=x}),E={execute:A,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(E,b),S},P.executeNext=function(b){var A=this.buffers,S=this.queues,E=A[b],x=S[b];if(x.length){var f=x[0];try{f.execute()}catch(_){O.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),f.onError(_),(!E||!E.updating)&&(x.shift(),this.executeNext(b))}}},P.shiftAndExecuteNext=function(b){this.queues[b].shift(),this.executeNext(b)},P.current=function(b){return this.queues[b][0]},M}()},"./src/controller/cap-level-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>A});var O=T("./src/events.ts");function D(S,E){for(var x=0;x<E.length;x++){var f=E[x];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(S,P(f.key),f)}}function M(S,E,x){return E&&D(S.prototype,E),x&&D(S,x),Object.defineProperty(S,"prototype",{writable:!1}),S}function P(S){var E=U(S,"string");return typeof E=="symbol"?E:String(E)}function U(S,E){if(typeof S!="object"||S===null)return S;var x=S[Symbol.toPrimitive];if(x!==void 0){var f=x.call(S,E||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(S)}var b=function(){function S(x){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=x,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var E=S.prototype;return E.setStreamController=function(f){this.streamController=f},E.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},E.registerListeners=function(){var f=this.hls;f.on(O.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),f.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.on(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),f.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},E.unregisterListener=function(){var f=this.hls;f.off(O.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),f.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.off(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(O.Events.BUFFER_CODECS,this.onBufferCodecs,this),f.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},E.onFpsDropLevelCapping=function(f,_){S.isLevelAllowed(_.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(_.droppedLevel)},E.onMediaAttaching=function(f,_){this.media=_.media instanceof HTMLVideoElement?_.media:null,this.clientRect=null},E.onManifestParsed=function(f,_){var p=this.hls;this.restrictedLevels=[],this.firstLevel=_.firstLevel,p.config.capLevelToPlayerSize&&_.video&&this.startCapping()},E.onBufferCodecs=function(f,_){var p=this.hls;p.config.capLevelToPlayerSize&&_.video&&this.startCapping()},E.onMediaDetaching=function(){this.stopCapping()},E.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var f=this.hls.levels;if(f.length){var _=this.hls;_.autoLevelCapping=this.getMaxLevel(f.length-1),_.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=_.autoLevelCapping}}},E.getMaxLevel=function(f){var _=this,p=this.hls.levels;if(!p.length)return-1;var v=p.filter(function(a,s){return S.isLevelAllowed(s,_.restrictedLevels)&&s<=f});return this.clientRect=null,S.getMaxLevelByMediaSize(v,this.mediaWidth,this.mediaHeight)},E.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())},E.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},E.getDimensions=function(){if(this.clientRect)return this.clientRect;var f=this.media,_={width:0,height:0};if(f){var p=f.getBoundingClientRect();_.width=p.width,_.height=p.height,!_.width&&!_.height&&(_.width=p.right-p.left||f.width||0,_.height=p.bottom-p.top||f.height||0)}return this.clientRect=_,_},S.isLevelAllowed=function(f,_){return _===void 0&&(_=[]),_.indexOf(f)===-1},S.getMaxLevelByMediaSize=function(f,_,p){if(!f||!f.length)return-1;for(var v=function(l,i){return i?l.width!==i.width||l.height!==i.height:!0},a=f.length-1,s=0;s<f.length;s+=1){var n=f[s];if((n.width>=_||n.height>=p)&&v(n,f[s+1])){a=s;break}}return a},M(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 f=1;if(!this.hls.config.ignoreDevicePixelRatio)try{f=self.devicePixelRatio}catch{}return f}}]),S}();let A=b},"./src/controller/cmcd-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>p});var O=T("./src/events.ts"),D=T("./src/types/cmcd.ts"),M=T("./src/utils/buffer-helper.ts"),P=T("./src/utils/logger.ts");function U(v,a){for(var s=0;s<a.length;s++){var n=a[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(v,A(n.key),n)}}function b(v,a,s){return a&&U(v.prototype,a),s&&U(v,s),Object.defineProperty(v,"prototype",{writable:!1}),v}function A(v){var a=S(v,"string");return typeof a=="symbol"?a:String(a)}function S(v,a){if(typeof v!="object"||v===null)return v;var s=v[Symbol.toPrimitive];if(s!==void 0){var n=s.call(v,a||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(v)}function E(v,a){var s=typeof Symbol!="undefined"&&v[Symbol.iterator]||v["@@iterator"];if(s)return(s=s.call(v)).next.bind(s);if(Array.isArray(v)||(s=x(v))||a&&v&&typeof v.length=="number"){s&&(v=s);var n=0;return function(){return n>=v.length?{done:!0}:{done:!1,value:v[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
13
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function x(v,a){if(!!v){if(typeof v=="string")return f(v,a);var s=Object.prototype.toString.call(v).slice(8,-1);if(s==="Object"&&v.constructor&&(s=v.constructor.name),s==="Map"||s==="Set")return Array.from(v);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return f(v,a)}}function f(v,a){(a==null||a>v.length)&&(a=v.length);for(var s=0,n=new Array(a);s<a;s++)n[s]=v[s];return n}function _(){return _=Object.assign?Object.assign.bind():function(v){for(var a=1;a<arguments.length;a++){var s=arguments[a];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(v[n]=s[n])}return v},_.apply(this,arguments)}var p=function(){function v(s){var n=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(){n.initialized&&(n.starved=!0),n.buffering=!0},this.onPlaying=function(){n.initialized||(n.initialized=!0),n.buffering=!1},this.applyPlaylistData=function(i){try{n.apply(i,{ot:D.CMCDObjectType.MANIFEST,su:!n.initialized})}catch(u){P.logger.warn("Could not generate manifest CMCD data.",u)}},this.applyFragmentData=function(i){try{var u=i.frag,g=n.hls.levels[u.level],c=n.getObjectType(u),m={d:u.duration*1e3,ot:c};(c===D.CMCDObjectType.VIDEO||c===D.CMCDObjectType.AUDIO||c==D.CMCDObjectType.MUXED)&&(m.br=g.bitrate/1e3,m.tb=n.getTopBandwidth(c)/1e3,m.bl=n.getBufferLength(c)),n.apply(i,m)}catch(e){P.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=s;var d=this.config=s.config,l=d.cmcd;l!=null&&(d.pLoader=this.createPlaylistLoader(),d.fLoader=this.createFragmentLoader(),this.sid=l.sessionId||v.uuid(),this.cid=l.contentId,this.useHeaders=l.useHeaders===!0,this.registerListeners())}var a=v.prototype;return a.registerListeners=function(){var n=this.hls;n.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(O.Events.MEDIA_DETACHED,this.onMediaDetached,this),n.on(O.Events.BUFFER_CREATED,this.onBufferCreated,this)},a.unregisterListeners=function(){var n=this.hls;n.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(O.Events.MEDIA_DETACHED,this.onMediaDetached,this),n.off(O.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},a.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},a.onMediaAttached=function(n,d){this.media=d.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},a.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},a.onBufferCreated=function(n,d){var l,i;this.audioBuffer=(l=d.tracks.audio)===null||l===void 0?void 0:l.buffer,this.videoBuffer=(i=d.tracks.video)===null||i===void 0?void 0:i.buffer},a.createData=function(){var n;return{v:D.CMCDVersion,sf:D.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(n=this.media)===null||n===void 0?void 0:n.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},a.apply=function(n,d){d===void 0&&(d={}),_(d,this.createData());var l=d.ot===D.CMCDObjectType.INIT||d.ot===D.CMCDObjectType.VIDEO||d.ot===D.CMCDObjectType.MUXED;if(this.starved&&l&&(d.bs=!0,d.su=!0,this.starved=!1),d.su==null&&(d.su=this.buffering),this.useHeaders){var i=v.toHeaders(d);if(!Object.keys(i).length)return;n.headers||(n.headers={}),_(n.headers,i)}else{var u=v.toQuery(d);if(!u)return;n.url=v.appendQueryToUri(n.url,u)}},a.getObjectType=function(n){var d=n.type;if(d==="subtitle")return D.CMCDObjectType.TIMED_TEXT;if(n.sn==="initSegment")return D.CMCDObjectType.INIT;if(d==="audio")return D.CMCDObjectType.AUDIO;if(d==="main")return this.hls.audioTracks.length?D.CMCDObjectType.VIDEO:D.CMCDObjectType.MUXED},a.getTopBandwidth=function(n){var d=0,l,i=this.hls;if(n===D.CMCDObjectType.AUDIO)l=i.audioTracks;else{var u=i.maxAutoLevel,g=u>-1?u+1:i.levels.length;l=i.levels.slice(0,g)}for(var c=E(l),m;!(m=c()).done;){var e=m.value;e.bitrate>d&&(d=e.bitrate)}return d>0?d:NaN},a.getBufferLength=function(n){var d=this.hls.media,l=n===D.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!l||!d)return NaN;var i=M.BufferHelper.bufferInfo(l,d.currentTime,this.config.maxBufferHole);return i.len*1e3},a.createPlaylistLoader=function(){var n=this.config.pLoader,d=this.applyPlaylistData,l=n||this.config.loader;return function(){function i(g){this.loader=void 0,this.loader=new l(g)}var u=i.prototype;return u.destroy=function(){this.loader.destroy()},u.abort=function(){this.loader.abort()},u.load=function(c,m,e){d(c),this.loader.load(c,m,e)},b(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},a.createFragmentLoader=function(){var n=this.config.fLoader,d=this.applyFragmentData,l=n||this.config.loader;return function(){function i(g){this.loader=void 0,this.loader=new l(g)}var u=i.prototype;return u.destroy=function(){this.loader.destroy()},u.abort=function(){this.loader.abort()},u.load=function(c,m,e){d(c),this.loader.load(c,m,e)},b(i,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),i}()},v.uuid=function(){var n=URL.createObjectURL(new Blob),d=n.toString();return URL.revokeObjectURL(n),d.slice(d.lastIndexOf("/")+1)},v.serialize=function(n){for(var d=[],l=function(I){return!Number.isNaN(I)&&I!=null&&I!==""&&I!==!1},i=function(I){return Math.round(I)},u=function(I){return i(I/100)*100},g=function(I){return encodeURIComponent(I)},c={br:i,d:i,bl:u,dl:u,mtp:u,nor:g,rtp:u,tb:i},m=Object.keys(n||{}).sort(),e=E(m),r;!(r=e()).done;){var t=r.value,o=n[t];if(!!l(o)&&!(t==="v"&&o===1)&&!(t=="pr"&&o===1)){var y=c[t];y&&(o=y(o));var h=typeof o,L=void 0;t==="ot"||t==="sf"||t==="st"?L=t+"="+o:h==="boolean"?L=t:h==="number"?L=t+"="+o:L=t+"="+JSON.stringify(o),d.push(L)}}return d.join(",")},v.toHeaders=function(n){for(var d=Object.keys(n),l={},i=["Object","Request","Session","Status"],u=[{},{},{},{}],g={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},c=0,m=d;c<m.length;c++){var e=m[c],r=g[e]!=null?g[e]:1;u[r][e]=n[e]}for(var t=0;t<u.length;t++){var o=v.serialize(u[t]);o&&(l["CMCD-"+i[t]]=o)}return l},v.toQuery=function(n){return"CMCD="+encodeURIComponent(v.serialize(n))},v.appendQueryToUri=function(n,d){if(!d)return n;var l=n.includes("?")?"&":"?";return""+n+l+d},v}()},"./src/controller/eme-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>c});var O=T("./src/events.ts"),D=T("./src/errors.ts"),M=T("./src/utils/logger.ts"),P=T("./src/utils/mediakeys-helper.ts"),U=T("./src/utils/keysystem-util.ts"),b=T("./src/utils/numeric-encoding-utils.ts"),A=T("./src/loader/level-key.ts"),S=T("./src/utils/hex.ts"),E=T("./src/utils/mp4-tools.ts"),x=T("./node_modules/eventemitter3/index.js"),f=T.n(x);function _(m,e){m.prototype=Object.create(e.prototype),m.prototype.constructor=m,n(m,e)}function p(m){var e=typeof Map=="function"?new Map:void 0;return p=function(t){if(t===null||!s(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(t))return e.get(t);e.set(t,o)}function o(){return v(t,arguments,d(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),n(o,t)},p(m)}function v(m,e,r){return a()?v=Reflect.construct.bind():v=function(o,y,h){var L=[null];L.push.apply(L,y);var R=Function.bind.apply(o,L),I=new R;return h&&n(I,h.prototype),I},v.apply(null,arguments)}function a(){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 s(m){return Function.toString.call(m).indexOf("[native code]")!==-1}function n(m,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,o){return t.__proto__=o,t},n(m,e)}function d(m){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},d(m)}var l=3,i="[eme]",u=function(){function m(r){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=m.CDMCleanupPromise?[m.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=M.logger.debug.bind(M.logger,i),this.log=M.logger.log.bind(M.logger,i),this.warn=M.logger.warn.bind(M.logger,i),this.error=M.logger.error.bind(M.logger,i),this.hls=r,this.config=r.config,this.registerListeners()}var e=m.prototype;return e.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},e.registerListeners=function(){this.hls.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(O.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},e.unregisterListeners=function(){this.hls.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(O.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(O.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},e.getLicenseServerUrl=function(t){var o=this.config,y=o.drmSystems,h=o.widevineLicenseUrl,L=y[t];if(L)return L.licenseUrl;if(t===P.KeySystems.WIDEVINE&&h)return h;throw new Error('no license server URL configured for key-system "'+t+'"')},e.getServerCertificateUrl=function(t){var o=this.config.drmSystems,y=o[t];if(y)return y.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},e.attemptKeySystemAccess=function(t){var o=this,y=this.hls.levels,h=function(k,F,W){return!!k&&W.indexOf(k)===F},L=y.map(function(I){return I.audioCodec}).filter(h),R=y.map(function(I){return I.videoCodec}).filter(h);return L.length+R.length===0&&R.push("avc1.42e01e"),new Promise(function(I,k){var F=function W(K){var H=K.shift();o.getMediaKeysPromise(H,L,R).then(function(Y){return I({keySystem:H,mediaKeys:Y})}).catch(function(Y){K.length?W(K):Y instanceof g?k(Y):k(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:Y,fatal:!0},Y.message))})};F(t)})},e.requestMediaKeySystemAccess=function(t,o){var y=this.config.requestMediaKeySystemAccessFunc;if(typeof y!="function"){var h="Configured requestMediaKeySystemAccess is not a function "+y;return P.requestMediaKeySystemAccess===null&&self.location.protocol==="http:"&&(h="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(h))}return y(t,o)},e.getMediaKeysPromise=function(t,o,y){var h=this,L=(0,P.getSupportedMediaKeySystemConfigurations)(t,o,y,this.config.drmSystemOptions),R=this.keySystemAccessPromises[t],I=R==null?void 0:R.keySystemAccess;if(!I){this.log('Requesting encrypted media "'+t+'" key-system access with config: '+JSON.stringify(L)),I=this.requestMediaKeySystemAccess(t,L);var k=this.keySystemAccessPromises[t]={keySystemAccess:I};return I.catch(function(F){h.log('Failed to obtain access to key-system "'+t+'": '+F)}),I.then(function(F){h.log('Access for key-system "'+F.keySystem+'" obtained');var W=h.fetchServerCertificate(t);return h.log('Create media-keys for "'+t+'"'),k.mediaKeys=F.createMediaKeys().then(function(K){return h.log('Media-keys created for "'+t+'"'),W.then(function(H){return H?h.setMediaKeysServerCertificate(K,t,H):K})}),k.mediaKeys.catch(function(K){h.error('Failed to create media-keys for "'+t+'"}: '+K)}),k.mediaKeys})}return I.then(function(){return R.mediaKeys})},e.createMediaKeySessionContext=function(t){var o=t.decryptdata,y=t.keySystem,h=t.mediaKeys;console.assert(!!h,"mediaKeys is defined"),this.log('Creating key-system session "'+y+'" keyId: '+S.default.hexDump(o.keyId||[]));var L=h.createSession(),R={decryptdata:o,keySystem:y,mediaKeys:h,mediaKeysSession:L,keyStatus:"status-pending"};return this.mediaKeySessions.push(R),R},e.renewKeySession=function(t){var o=t.decryptdata;if(o.pssh){var y=this.createMediaKeySessionContext(t),h=this.getKeyIdString(o),L="cenc";this.keyIdToKeySessionPromise[h]=this.generateRequestWithPreferredKeySession(y,L,o.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)},e.getKeyIdString=function(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return S.default.hexDump(t.keyId)},e.updateKeySession=function(t,o){var y,h=t.mediaKeysSession;return this.log('Updating key-session "'+h.sessionId+'" for keyID '+S.default.hexDump(((y=t.decryptdata)===null||y===void 0?void 0:y.keyId)||[])+`
|
|
14
|
-
} (data length: `+(o&&o.byteLength)+")"),h.update(o)},e.selectKeySystemFormat=function(t){var o=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+o.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(o)),this.keyFormatPromise},e.getKeyFormatPromise=function(t){var o=this;return new Promise(function(y,h){var L=(0,P.getKeySystemsForConfig)(o.config),R=t.map(P.keySystemFormatToKeySystemDomain).filter(function(I){return!!I&&L.indexOf(I)!==-1});return o.getKeySystemSelectionPromise(R).then(function(I){var k=I.keySystem,F=(0,P.keySystemDomainToKeySystemFormat)(k);F?y(F):h(new Error('Unable to find format for key-system "'+k+'"'))}).catch(h)})},e.loadKey=function(t){var o=this,y=t.keyInfo.decryptdata,h=this.getKeyIdString(y),L="(keyId: "+h+' format: "'+y.keyFormat+'" method: '+y.method+" uri: "+y.uri+")";this.log("Starting session for key "+L);var R=this.keyIdToKeySessionPromise[h];return R||(R=this.keyIdToKeySessionPromise[h]=this.getKeySystemForKeyPromise(y).then(function(I){var k=I.keySystem,F=I.mediaKeys;return o.throwIfDestroyed(),o.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+L),o.attemptSetMediaKeys(k,F).then(function(){o.throwIfDestroyed();var W=o.createMediaKeySessionContext({keySystem:k,mediaKeys:F,decryptdata:y}),K="cenc";return o.generateRequestWithPreferredKeySession(W,K,y.pssh,"playlist-key")})}),R.catch(function(I){return o.handleError(I)})),R},e.throwIfDestroyed=function(t){if(t===void 0&&(t="Invalid state"),!this.hls)throw new Error("invalid state")},e.handleError=function(t){!this.hls||(this.error(t.message),t instanceof g?this.hls.trigger(O.Events.ERROR,t.data):this.hls.trigger(O.Events.ERROR,{type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},e.getKeySystemForKeyPromise=function(t){var o=this.getKeyIdString(t),y=this.keyIdToKeySessionPromise[o];if(!y){var h=(0,P.keySystemFormatToKeySystemDomain)(t.keyFormat),L=h?[h]:(0,P.getKeySystemsForConfig)(this.config);return this.attemptKeySystemAccess(L)}return y},e.getKeySystemSelectionPromise=function(t){if(t.length||(t=(0,P.getKeySystemsForConfig)(this.config)),t.length===0)throw new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},e._onMediaEncrypted=function(t){var o=this,y=t.initDataType,h=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+y+'"'),h!==null){var L,R;if(y==="sinf"&&this.config.drmSystems[P.KeySystems.FAIRPLAY]){var I=(0,E.bin2str)(new Uint8Array(h));try{var k=(0,b.base64Decode)(JSON.parse(I).sinf),F=(0,E.parseSinf)(new Uint8Array(k));if(!F)return;L=F.subarray(8,24),R=P.KeySystems.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{var W=(0,E.parsePssh)(h);if(W===null)return;W.version===0&&W.systemId===P.KeySystemIds.WIDEVINE&&W.data&&(L=W.data.subarray(8,24)),R=(0,P.keySystemIdToKeySystemDomain)(W.systemId)}if(!(!R||!L)){for(var K=S.default.hexDump(L),H=this.keyIdToKeySessionPromise,Y=this.mediaKeySessions,q=H[K],ee=function(le){var de=Y[le],ue=de.decryptdata;if(ue.pssh||!ue.keyId)return"continue";var fe=S.default.hexDump(ue.keyId);if(K===fe||ue.uri.replace(/-/g,"").indexOf(K)!==-1)return q=H[fe],delete H[fe],ue.pssh=new Uint8Array(h),ue.keyId=L,q=H[K]=q.then(function(){return o.generateRequestWithPreferredKeySession(de,y,h,"encrypted-event-key-match")}),"break"},ae=0;ae<Y.length;ae++){var re=ee(ae);if(re!=="continue"&&re==="break")break}q||(q=H[K]=this.getKeySystemSelectionPromise([R]).then(function(se){var le,de=se.keySystem,ue=se.mediaKeys;o.throwIfDestroyed();var fe=new A.LevelKey("ISO-23001-7",K,(le=(0,P.keySystemDomainToKeySystemFormat)(de))!=null?le:"");return fe.pssh=new Uint8Array(h),fe.keyId=L,o.attemptSetMediaKeys(de,ue).then(function(){o.throwIfDestroyed();var ce=o.createMediaKeySessionContext({decryptdata:fe,keySystem:de,mediaKeys:ue});return o.generateRequestWithPreferredKeySession(ce,y,h,"encrypted-event-no-match")})})),q.catch(function(se){return o.handleError(se)})}}},e._onWaitingForKey=function(t){this.log('"'+t.type+'" event')},e.attemptSetMediaKeys=function(t,o){var y=this,h=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+t+'"');var L=Promise.all(h).then(function(){if(!y.media)throw new Error("Attempted to set mediaKeys without media element attached");return y.media.setMediaKeys(o)});return this.setMediaKeysQueue.push(L),L.then(function(){y.log('Media-keys set for "'+t+'"'),h.push(L),y.setMediaKeysQueue=y.setMediaKeysQueue.filter(function(R){return h.indexOf(R)===-1})})},e.generateRequestWithPreferredKeySession=function(t,o,y,h){var L,R,I=this,k=(L=this.config.drmSystems)===null||L===void 0||(R=L[t.keySystem])===null||R===void 0?void 0:R.generateRequest;if(k)try{var F=k.call(this.hls,o,y,t);if(!F)throw new Error("Invalid response from configured generateRequest filter");o=F.initDataType,y=t.decryptdata.pssh=F.initData?new Uint8Array(F.initData):null}catch(q){var W;if(this.warn(q.message),(W=this.hls)!==null&&W!==void 0&&W.config.debug)throw q}if(y===null)return this.log('Skipping key-session request for "'+h+'" (no initData)'),Promise.resolve(t);var K=this.getKeyIdString(t.decryptdata);this.log('Generating key-session request for "'+h+'": '+K+" (init data type: "+o+" length: "+(y?y.byteLength:null)+")");var H=new(f());t.mediaKeysSession.onmessage=function(q){var ee=t.mediaKeysSession;if(!ee){H.emit("error",new Error("invalid state"));return}var ae=q.messageType,re=q.message;I.log('"'+ae+'" message event for session "'+ee.sessionId+'" message size: '+re.byteLength),ae==="license-request"||ae==="license-renewal"?I.renewLicense(t,re).catch(function(se){I.handleError(se),H.emit("error",se)}):ae==="license-release"?t.keySystem===P.KeySystems.FAIRPLAY&&(I.updateKeySession(t,(0,U.strToUtf8array)("acknowledged")),I.removeSession(t)):I.warn('unhandled media key message type "'+ae+'"')},t.mediaKeysSession.onkeystatuseschange=function(q){var ee=t.mediaKeysSession;if(!ee){H.emit("error",new Error("invalid state"));return}I.onKeyStatusChange(t);var ae=t.keyStatus;H.emit("keyStatus",ae),ae==="expired"&&(I.warn(t.keySystem+" expired for key "+K),I.renewKeySession(t))};var Y=new Promise(function(q,ee){H.on("error",ee),H.on("keyStatus",function(ae){ae.startsWith("usable")?q():ae==="output-restricted"?ee(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):ae==="internal-error"?ee(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+ae+'"')):ae==="expired"?ee(new Error("key expired while generating request")):I.warn('unhandled key status change "'+ae+'"')})});return t.mediaKeysSession.generateRequest(o,y).then(function(){var q;I.log('Request generated for key-session "'+((q=t.mediaKeysSession)===null||q===void 0?void 0:q.sessionId)+'" keyId: '+K)}).catch(function(q){throw new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:q,fatal:!1},"Error generating key-session request: "+q)}).then(function(){return Y}).catch(function(q){throw H.removeAllListeners(),I.removeSession(t),q}).then(function(){return H.removeAllListeners(),t})},e.onKeyStatusChange=function(t){var o=this;t.mediaKeysSession.keyStatuses.forEach(function(y,h){o.log('key status change "'+y+'" for keyStatuses keyId: '+S.default.hexDump("buffer"in h?new Uint8Array(h.buffer,h.byteOffset,h.byteLength):new Uint8Array(h))+" session keyId: "+S.default.hexDump(new Uint8Array(t.decryptdata.keyId||[]))+" uri: "+t.decryptdata.uri),t.keyStatus=y})},e.fetchServerCertificate=function(t){var o=this;return new Promise(function(y,h){var L=o.getServerCertificateUrl(t);if(!L)return y();o.log('Fetching serverCertificate for "'+t+'"');var R=new XMLHttpRequest;R.open("GET",L,!0),R.responseType="arraybuffer",R.onreadystatechange=function(){R.readyState===XMLHttpRequest.DONE&&(R.status===200?y(R.response):h(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:R},'"'+t+'" certificate request XHR failed ('+L+"). Status: "+R.status+" ("+R.statusText+")")))},R.send()})},e.setMediaKeysServerCertificate=function(t,o,y){var h=this;return new Promise(function(L,R){t.setServerCertificate(y).then(function(I){h.log("setServerCertificate "+(I?"success":"not supported by CDM")+" ("+(y==null?void 0:y.byteLength)+') on "'+o+'"'),L(t)}).catch(function(I){R(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:I,fatal:!0},I.message))})})},e.renewLicense=function(t,o){var y=this;return this.requestLicense(t,new Uint8Array(o)).then(function(h){return y.updateKeySession(t,new Uint8Array(h)).catch(function(L){throw new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:L,fatal:!0},L.message)})})},e.setupLicenseXHR=function(t,o,y,h){var L=this,R=this.config.licenseXhrSetup;return R?Promise.resolve().then(function(){if(!y.decryptdata)throw new Error("Key removed");return R.call(L.hls,t,o,y,h)}).catch(function(I){if(!y.decryptdata)throw I;return t.open("POST",o,!0),R.call(L.hls,t,o,y,h)}).then(function(I){t.readyState||t.open("POST",o,!0);var k=I||h;return{xhr:t,licenseChallenge:k}}):(t.open("POST",o,!0),Promise.resolve({xhr:t,licenseChallenge:h}))},e.requestLicense=function(t,o){var y=this;return new Promise(function(h,L){var R=y.getLicenseServerUrl(t.keySystem);y.log("Sending license request to URL: "+R);var I=new XMLHttpRequest;I.responseType="arraybuffer",I.onreadystatechange=function(){if(!y.hls||!t.mediaKeysSession)return L(new Error("invalid state"));if(I.readyState===4)if(I.status===200){y._requestLicenseFailureCount=0;var k=I.response;y.log("License received "+(k instanceof ArrayBuffer?k.byteLength:k));var F=y.config.licenseResponseCallback;if(F)try{k=F.call(y.hls,I,R,t)}catch(K){y.error(K)}h(k)}else if(y._requestLicenseFailureCount++,y._requestLicenseFailureCount>l||I.status>=400&&I.status<500)L(new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:I},"License Request XHR failed ("+R+"). Status: "+I.status+" ("+I.statusText+")"));else{var W=l-y._requestLicenseFailureCount+1;y.warn("Retrying license request, "+W+" attempts left"),y.requestLicense(t,o).then(h,L)}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=I,y.setupLicenseXHR(I,R,t,o).then(function(k){var F=k.xhr,W=k.licenseChallenge;F.send(W)})})},e.onMediaAttached=function(t,o){if(!!this.config.emeEnabled){var y=o.media;this.media=y,y.addEventListener("encrypted",this.onMediaEncrypted),y.addEventListener("waitingforkey",this.onWaitingForKey)}},e.onMediaDetached=function(){var t=this,o=this.media,y=this.mediaKeySessions;o&&(o.removeEventListener("encrypted",this.onMediaEncrypted),o.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},A.LevelKey.clearKeyUriToKeyIdMap();var h=y.length;m.CDMCleanupPromise=Promise.all(y.map(function(L){return t.removeSession(L)}).concat(o==null?void 0:o.setMediaKeys(null).catch(function(L){t.log("Could not clear media keys: "+L+". media.src: "+(o==null?void 0:o.src))}))).then(function(){h&&(t.log("finished closing key sessions and clearing media keys"),y.length=0)}).catch(function(L){t.log("Could not close sessions and clear media keys: "+L+". media.src: "+(o==null?void 0:o.src))})},e.onManifestLoaded=function(t,o){var y=o.sessionKeys;if(!(!y||!this.config.emeEnabled)&&!this.keyFormatPromise){var h=y.reduce(function(L,R){return L.indexOf(R.keyFormat)===-1&&L.push(R.keyFormat),L},[]);this.log("Selecting key-system from session-keys "+h.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(h)}},e.removeSession=function(t){var o=this,y=t.mediaKeysSession,h=t.licenseXhr;if(y){this.log("Remove licenses and keys and close session "+y.sessionId),y.onmessage=null,y.onkeystatuseschange=null,h&&h.readyState!==XMLHttpRequest.DONE&&h.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;var L=this.mediaKeySessions.indexOf(t);return L>-1&&this.mediaKeySessions.splice(L,1),y.remove().catch(function(R){o.log("Could not remove session: "+R)}).then(function(){return y.close()}).catch(function(R){o.log("Could not close session: "+R)})}},m}();u.CDMCleanupPromise=void 0;var g=function(m){_(e,m);function e(r,t){var o;return o=m.call(this,t)||this,o.data=void 0,o.data=r,r.err=r.error,o}return e}(p(Error));let c=u},"./src/controller/fps-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>P});var O=T("./src/events.ts"),D=T("./src/utils/logger.ts"),M=function(){function U(A){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=A,this.registerListeners()}var b=U.prototype;return b.setStreamController=function(S){this.streamController=S},b.registerListeners=function(){this.hls.on(O.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},b.unregisterListeners=function(){this.hls.off(O.Events.MEDIA_ATTACHING,this.onMediaAttaching)},b.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},b.onMediaAttaching=function(S,E){var x=this.hls.config;if(x.capLevelOnFPSDrop){var f=E.media instanceof self.HTMLVideoElement?E.media:null;this.media=f,f&&typeof f.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),x.fpsDroppedMonitoringPeriod)}},b.checkFPS=function(S,E,x){var f=performance.now();if(E){if(this.lastTime){var _=f-this.lastTime,p=x-this.lastDroppedFrames,v=E-this.lastDecodedFrames,a=1e3*p/_,s=this.hls;if(s.trigger(O.Events.FPS_DROP,{currentDropped:p,currentDecoded:v,totalDroppedFrames:x}),a>0&&p>s.config.fpsDroppedMonitoringThreshold*v){var n=s.currentLevel;D.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+n),n>0&&(s.autoLevelCapping===-1||s.autoLevelCapping>=n)&&(n=n-1,s.trigger(O.Events.FPS_DROP_LEVEL_CAPPING,{level:n,droppedLevel:s.currentLevel}),s.autoLevelCapping=n,this.streamController.nextLevelSwitch())}}this.lastTime=f,this.lastDroppedFrames=x,this.lastDecodedFrames=E}},b.checkFPSInterval=function(){var S=this.media;if(S)if(this.isVideoPlaybackQualityAvailable){var E=S.getVideoPlaybackQuality();this.checkFPS(S,E.totalVideoFrames,E.droppedVideoFrames)}else this.checkFPS(S,S.webkitDecodedFrameCount,S.webkitDroppedFrameCount)},U}();let P=M},"./src/controller/fragment-finders.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{findFragWithCC:()=>A,findFragmentByPDT:()=>M,findFragmentByPTS:()=>P,fragmentWithinToleranceTest:()=>U,pdtWithinToleranceTest:()=>b});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/binary-search.ts");function M(S,E,x){if(E===null||!Array.isArray(S)||!S.length||!(0,O.isFiniteNumber)(E))return null;var f=S[0].programDateTime;if(E<(f||0))return null;var _=S[S.length-1].endProgramDateTime;if(E>=(_||0))return null;x=x||0;for(var p=0;p<S.length;++p){var v=S[p];if(b(E,x,v))return v}return null}function P(S,E,x,f){x===void 0&&(x=0),f===void 0&&(f=0);var _=null;if(S?_=E[S.sn-E[0].sn+1]||null:x===0&&E[0].start===0&&(_=E[0]),_&&U(x,f,_)===0)return _;var p=D.default.search(E,U.bind(null,x,f));return p&&(p!==S||!_)?p:_}function U(S,E,x){if(S===void 0&&(S=0),E===void 0&&(E=0),x.start<=S&&x.start+x.duration>S)return 0;var f=Math.min(E,x.duration+(x.deltaPTS?x.deltaPTS:0));return x.start+x.duration-f<=S?1:x.start-f>S&&x.start?-1:0}function b(S,E,x){var f=Math.min(E,x.duration+(x.deltaPTS?x.deltaPTS:0))*1e3,_=x.endProgramDateTime||0;return _-f>S}function A(S,E){return D.default.search(S,function(x){return x.cc<E?1:x.cc>E?-1:0})}},"./src/controller/fragment-tracker.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{FragmentState:()=>M,FragmentTracker:()=>P});var O=T("./src/events.ts"),D=T("./src/types/loader.ts"),M;(function(A){A.NOT_LOADED="NOT_LOADED",A.APPENDING="APPENDING",A.PARTIAL="PARTIAL",A.OK="OK"})(M||(M={}));var P=function(){function A(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 S=A.prototype;return S._registerListeners=function(){var x=this.hls;x.on(O.Events.BUFFER_APPENDED,this.onBufferAppended,this),x.on(O.Events.FRAG_BUFFERED,this.onFragBuffered,this),x.on(O.Events.FRAG_LOADED,this.onFragLoaded,this)},S._unregisterListeners=function(){var x=this.hls;x.off(O.Events.BUFFER_APPENDED,this.onBufferAppended,this),x.off(O.Events.FRAG_BUFFERED,this.onFragBuffered,this),x.off(O.Events.FRAG_LOADED,this.onFragLoaded,this)},S.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},S.getAppendedFrag=function(x,f){if(f===D.PlaylistLevelType.MAIN){var _=this.activeFragment,p=this.activeParts;if(!_)return null;if(p)for(var v=p.length;v--;){var a=p[v],s=a?a.end:_.appendedPTS;if(a.start<=x&&s!==void 0&&x<=s)return v>9&&(this.activeParts=p.slice(v-9)),a}else if(_.start<=x&&_.appendedPTS!==void 0&&x<=_.appendedPTS)return _}return this.getBufferedFrag(x,f)},S.getBufferedFrag=function(x,f){for(var _=this.fragments,p=Object.keys(_),v=p.length;v--;){var a=_[p[v]];if((a==null?void 0:a.body.type)===f&&a.buffered){var s=a.body;if(s.start<=x&&x<=s.end)return s}}return null},S.detectEvictedFragments=function(x,f,_){var p=this;this.timeRanges&&(this.timeRanges[x]=f),Object.keys(this.fragments).forEach(function(v){var a=p.fragments[v];if(!!a){if(!a.buffered&&!a.loaded){a.body.type===_&&p.removeFragment(a.body);return}var s=a.range[x];!s||s.time.some(function(n){var d=!p.isTimeBuffered(n.startPTS,n.endPTS,f);return d&&p.removeFragment(a.body),d})}})},S.detectPartialFragments=function(x){var f=this,_=this.timeRanges,p=x.frag,v=x.part;if(!(!_||p.sn==="initSegment")){var a=b(p),s=this.fragments[a];!s||(Object.keys(_).forEach(function(n){var d=p.elementaryStreams[n];if(!!d){var l=_[n],i=v!==null||d.partial===!0;s.range[n]=f.getBufferedTimes(p,v,i,l)}}),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,s.body.endList&&(this.endListFragments[s.body.type]=s)):this.removeFragment(s.body))}},S.fragBuffered=function(x){var f=b(x),_=this.fragments[f];_&&(_.loaded=null,_.buffered=!0)},S.getBufferedTimes=function(x,f,_,p){for(var v={time:[],partial:_},a=f?f.start:x.start,s=f?f.end:x.end,n=x.minEndPTS||s,d=x.maxStartPTS||a,l=0;l<p.length;l++){var i=p.start(l)-this.bufferPadding,u=p.end(l)+this.bufferPadding;if(d>=i&&n<=u){v.time.push({startPTS:Math.max(a,p.start(l)),endPTS:Math.min(s,p.end(l))});break}else if(a<u&&s>i)v.partial=!0,v.time.push({startPTS:Math.max(a,p.start(l)),endPTS:Math.min(s,p.end(l))});else if(s<=i)break}return v},S.getPartialFragment=function(x){var f=null,_,p,v,a=0,s=this.bufferPadding,n=this.fragments;return Object.keys(n).forEach(function(d){var l=n[d];!l||U(l)&&(p=l.body.start-s,v=l.body.end+s,x>=p&&x<=v&&(_=Math.min(x-p,v-x),a<=_&&(f=l.body,a=_)))}),f},S.isEndListAppended=function(x){var f=this.endListFragments[x];return f!==void 0&&(f.buffered||U(f))},S.getState=function(x){var f=b(x),_=this.fragments[f];return _?_.buffered?U(_)?M.PARTIAL:M.OK:M.APPENDING:M.NOT_LOADED},S.isTimeBuffered=function(x,f,_){for(var p,v,a=0;a<_.length;a++){if(p=_.start(a)-this.bufferPadding,v=_.end(a)+this.bufferPadding,x>=p&&f<=v)return!0;if(f<=p)return!1}return!1},S.onFragLoaded=function(x,f){var _=f.frag,p=f.part;if(!(_.sn==="initSegment"||_.bitrateTest||p)){var v=b(_);this.fragments[v]={body:_,loaded:f,buffered:!1,range:Object.create(null)}}},S.onBufferAppended=function(x,f){var _=this,p=f.frag,v=f.part,a=f.timeRanges;if(p.type===D.PlaylistLevelType.MAIN)if(this.activeFragment!==p&&(this.activeFragment=p,p.appendedPTS=void 0),v){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(v)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(n){var d=a[n];if(_.detectEvictedFragments(n,d),!v&&p.type===D.PlaylistLevelType.MAIN){var l=p.elementaryStreams[n];if(!l)return;for(var i=0;i<d.length;i++){var u=d.end(i);u<=l.endPTS&&u>l.startPTS?p.appendedPTS=Math.max(u,p.appendedPTS||0):p.appendedPTS=l.endPTS}}})},S.onFragBuffered=function(x,f){this.detectPartialFragments(f)},S.hasFragment=function(x){var f=b(x);return!!this.fragments[f]},S.removeFragmentsInRange=function(x,f,_){var p=this;Object.keys(this.fragments).forEach(function(v){var a=p.fragments[v];if(!!a&&a.buffered){var s=a.body;s.type===_&&s.start<f&&s.end>x&&p.removeFragment(s)}})},S.removeFragment=function(x){var f=b(x);x.stats.loaded=0,x.clearElementaryStreamInfo(),x.appendedPTS=void 0,delete this.fragments[f],x.endList&&delete this.endListFragments[x.type]},S.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},A}();function U(A){var S,E;return A.buffered&&(((S=A.range.video)===null||S===void 0?void 0:S.partial)||((E=A.range.audio)===null||E===void 0?void 0:E.partial))}function b(A){return A.type+"_"+A.level+"_"+A.urlId+"_"+A.sn}},"./src/controller/gap-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{MAX_START_GAP_JUMP:()=>b,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>A,SKIP_BUFFER_RANGE_START:()=>S,STALL_MINIMUM_DURATION_MS:()=>U,default:()=>E});var O=T("./src/utils/buffer-helper.ts"),D=T("./src/errors.ts"),M=T("./src/events.ts"),P=T("./src/utils/logger.ts"),U=250,b=2,A=.1,S=.05,E=function(){function x(_,p,v,a){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=_,this.media=p,this.fragmentTracker=v,this.hls=a}var f=x.prototype;return f.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},f.poll=function(p,v){var a=this.config,s=this.media,n=this.stalled;if(s!==null){var d=s.currentTime,l=s.seeking,i=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,d!==p){if(this.moved=!0,n!==null){if(this.stallReported){var g=self.performance.now()-n;P.logger.warn("playback not stuck anymore @"+d+", after "+Math.round(g)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((u||i)&&(this.stalled=null),!(s.paused&&!l||s.ended||s.playbackRate===0||!O.BufferHelper.getBuffered(s).length)){var c=O.BufferHelper.bufferInfo(s,d,0),m=c.len>0,e=c.nextStart||0;if(!(!m&&!e)){if(l){var r=c.len>b,t=!e||v&&v.start<=d||e-d>b&&!this.fragmentTracker.getPartialFragment(d);if(r||t)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var o,y=Math.max(e,c.start||0)-d,h=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=h==null||(o=h.details)===null||o===void 0?void 0:o.live,R=L?h.details.targetduration*2:b;if(y>0&&y<=R){this._trySkipBufferHole(null);return}}var I=self.performance.now();if(n===null){this.stalled=I;return}var k=I-n;if(!(!l&&k>=U&&(this._reportStall(c),!this.media))){var F=O.BufferHelper.bufferInfo(s,d,a.maxBufferHole);this._tryFixBufferStall(F,k)}}}}},f._tryFixBufferStall=function(p,v){var a=this.config,s=this.fragmentTracker,n=this.media;if(n!==null){var d=n.currentTime,l=s.getPartialFragment(d);if(l){var i=this._trySkipBufferHole(l);if(i||!this.media)return}p.len>a.maxBufferHole&&v>a.highBufferWatchdogPeriod*1e3&&(P.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},f._reportStall=function(p){var v=this.hls,a=this.media,s=this.stallReported;!s&&a&&(this.stallReported=!0,P.logger.warn("Playback stalling at @"+a.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),v.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:p.len}))},f._trySkipBufferHole=function(p){var v=this.config,a=this.hls,s=this.media;if(s===null)return 0;for(var n=s.currentTime,d=0,l=O.BufferHelper.getBuffered(s),i=0;i<l.length;i++){var u=l.start(i);if(n+v.maxBufferHole>=d&&n<u){var g=Math.max(u+S,s.currentTime+A);return P.logger.warn("skipping hole, adjusting currentTime from "+n+" to "+g),this.moved=!0,this.stalled=null,s.currentTime=g,p&&a.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+n+" to "+g,frag:p}),g}d=l.end(i)}return 0},f._tryNudgeBuffer=function(){var p=this.config,v=this.hls,a=this.media,s=this.nudgeRetry;if(a!==null){var n=a.currentTime;if(this.nudgeRetry++,s<p.nudgeMaxRetry){var d=n+(s+1)*p.nudgeOffset;P.logger.warn("Nudging 'currentTime' from "+n+" to "+d),a.currentTime=d,v.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else P.logger.error("Playhead still not moving while enough data buffered @"+n+" after "+p.nudgeMaxRetry+" nudges"),v.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},x}()},"./src/controller/id3-track-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>p});var O=T("./src/polyfills/number.ts"),D=T("./src/events.ts"),M=T("./src/utils/texttrack-utils.ts"),P=T("./src/demux/id3.ts"),U=T("./src/loader/date-range.ts"),b=T("./src/types/demuxer.ts"),A=.25;function S(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var E=function(){var v=S();try{new v(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function x(v,a){return v.getTime()/1e3-a}function f(v){return Uint8Array.from(v.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var _=function(){function v(s){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=s,this._registerListeners()}var a=v.prototype;return a.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},a._registerListeners=function(){var n=this.hls;n.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(D.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),n.on(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),n.on(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},a._unregisterListeners=function(){var n=this.hls;n.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(D.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),n.off(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),n.off(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},a.onMediaAttached=function(n,d){this.media=d.media},a.onMediaDetaching=function(){!this.id3Track||((0,M.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},a.onManifestLoading=function(){this.dateRangeCuesAppended={}},a.createTrack=function(n){var d=this.getID3Track(n.textTracks);return d.mode="hidden",d},a.getID3Track=function(n){if(!!this.media){for(var d=0;d<n.length;d++){var l=n[d];if(l.kind==="metadata"&&l.label==="id3")return(0,M.sendAddTrackEvent)(l,this.media),l}return this.media.addTextTrack("metadata","id3")}},a.onFragParsingMetadata=function(n,d){if(!!this.media){var l=this.hls.config,i=l.enableEmsgMetadataCues,u=l.enableID3MetadataCues;if(!(!i&&!u)){var g=d.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var c=S(),m=0;m<g.length;m++){var e=g[m].type;if(!(e===b.MetadataSchema.emsg&&!i||!u)){var r=P.getID3Frames(g[m].data);if(r){var t=g[m].pts,o=t+g[m].duration;o>E&&(o=E);var y=o-t;y<=0&&(o=t+A);for(var h=0;h<r.length;h++){var L=r[h];if(!P.isTimeStampFrame(L)){this.updateId3CueEnds(t);var R=new c(t,o,"");R.value=L,e&&(R.type=e),this.id3Track.addCue(R)}}}}}}}},a.updateId3CueEnds=function(n){var d,l=(d=this.id3Track)===null||d===void 0?void 0:d.cues;if(l)for(var i=l.length;i--;){var u=l[i];u.startTime<n&&u.endTime===E&&(u.endTime=n)}},a.onBufferFlushing=function(n,d){var l=d.startOffset,i=d.endOffset,u=d.type,g=this.id3Track,c=this.hls;if(!!c){var m=c.config,e=m.enableEmsgMetadataCues,r=m.enableID3MetadataCues;if(g&&(e||r)){var t;u==="audio"?t=function(y){return y.type===b.MetadataSchema.audioId3&&r}:u==="video"?t=function(y){return y.type===b.MetadataSchema.emsg&&e}:t=function(y){return y.type===b.MetadataSchema.audioId3&&r||y.type===b.MetadataSchema.emsg&&e},(0,M.removeCuesInRange)(g,l,i,t)}}},a.onLevelUpdated=function(n,d){var l=this,i=d.details;if(!(!this.media||!i.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var u=this.dateRangeCuesAppended,g=this.id3Track,c=i.dateRanges,m=Object.keys(c);if(g)for(var e=Object.keys(u).filter(function(I){return!m.includes(I)}),r=function(k){var F=e[k];Object.keys(u[F].cues).forEach(function(W){g.removeCue(u[F].cues[W])}),delete u[F]},t=e.length;t--;)r(t);var o=i.fragments[i.fragments.length-1];if(!(m.length===0||!(0,O.isFiniteNumber)(o==null?void 0:o.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var y=o.programDateTime/1e3-o.start,h=S(),L=function(k){var F=m[k],W=c[F],K=u[F],H=(K==null?void 0:K.cues)||{},Y=(K==null?void 0:K.durationKnown)||!1,q=x(W.startDate,y),ee=E,ae=W.endDate;if(ae)ee=x(ae,y),Y=!0;else if(W.endOnNext&&!Y){var re=m.reduce(function(ce,be){var Pe=c[be];return Pe.class===W.class&&Pe.id!==be&&Pe.startDate>W.startDate&&ce.push(Pe),ce},[]).sort(function(ce,be){return ce.startDate.getTime()-be.startDate.getTime()})[0];re&&(ee=x(re.startDate,y),Y=!0)}for(var se=Object.keys(W.attr),le=0;le<se.length;le++){var de=se[le];if(!(de===U.DateRangeAttribute.ID||de===U.DateRangeAttribute.CLASS||de===U.DateRangeAttribute.START_DATE||de===U.DateRangeAttribute.DURATION||de===U.DateRangeAttribute.END_DATE||de===U.DateRangeAttribute.END_ON_NEXT)){var ue=H[de];if(ue)Y&&!K.durationKnown&&(ue.endTime=ee);else{var fe=W.attr[de];ue=new h(q,ee,""),(de===U.DateRangeAttribute.SCTE35_OUT||de===U.DateRangeAttribute.SCTE35_IN)&&(fe=f(fe)),ue.value={key:de,data:fe},ue.type=b.MetadataSchema.dateRange,l.id3Track.addCue(ue),H[de]=ue}}}u[F]={cues:H,dateRange:W,durationKnown:Y}},R=0;R<m.length;R++)L(R)}}},v}();let p=_},"./src/controller/latency-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>S});var O=T("./src/errors.ts"),D=T("./src/events.ts"),M=T("./src/utils/logger.ts");function P(E,x){for(var f=0;f<x.length;f++){var _=x[f];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(E,b(_.key),_)}}function U(E,x,f){return x&&P(E.prototype,x),f&&P(E,f),Object.defineProperty(E,"prototype",{writable:!1}),E}function b(E){var x=A(E,"string");return typeof x=="symbol"?x:String(x)}function A(E,x){if(typeof E!="object"||E===null)return E;var f=E[Symbol.toPrimitive];if(f!==void 0){var _=f.call(E,x||"default");if(typeof _!="object")return _;throw new TypeError("@@toPrimitive must return a primitive value.")}return(x==="string"?String:Number)(E)}var S=function(){function E(f){var _=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 _.timeupdate()},this.hls=f,this.config=f.config,this.registerListeners()}var x=E.prototype;return x.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},x.registerListeners=function(){this.hls.on(D.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(D.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(D.Events.ERROR,this.onError,this)},x.unregisterListeners=function(){this.hls.off(D.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(D.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(D.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(D.Events.ERROR,this.onError)},x.onMediaAttached=function(_,p){this.media=p.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},x.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},x.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},x.onLevelUpdated=function(_,p){var v=p.details;this.levelDetails=v,v.advanced&&this.timeupdate(),!v.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},x.onError=function(_,p){p.details===O.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,M.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},x.timeupdate=function(){var _=this.media,p=this.levelDetails;if(!(!_||!p)){this.currentTime=_.currentTime;var v=this.computeLatency();if(v!==null){this._latency=v;var a=this.config,s=a.lowLatencyMode,n=a.maxLiveSyncPlaybackRate;if(!(!s||n===1)){var d=this.targetLatency;if(d!==null){var l=v-d,i=Math.min(this.maxLatency,d+p.targetduration),u=l<i;if(p.live&&u&&l>.05&&this.forwardBufferLength>1){var g=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*l-this.edgeStalled))*20)/20;_.playbackRate=Math.min(g,Math.max(1,c))}else _.playbackRate!==1&&_.playbackRate!==0&&(_.playbackRate=1)}}}}},x.estimateLiveEdge=function(){var _=this.levelDetails;return _===null?null:_.edge+_.age},x.computeLatency=function(){var _=this.estimateLiveEdge();return _===null?null:_-this.currentTime},U(E,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var _=this.config,p=this.levelDetails;return _.liveMaxLatencyDuration!==void 0?_.liveMaxLatencyDuration:p?_.liveMaxLatencyDurationCount*p.targetduration:0}},{key:"targetLatency",get:function(){var _=this.levelDetails;if(_===null)return null;var p=_.holdBack,v=_.partHoldBack,a=_.targetduration,s=this.config,n=s.liveSyncDuration,d=s.liveSyncDurationCount,l=s.lowLatencyMode,i=this.hls.userConfig,u=l&&v||p;(i.liveSyncDuration||i.liveSyncDurationCount||u===0)&&(u=n!==void 0?n:d*a);var g=a,c=1;return u+Math.min(this.stallCount*c,g)}},{key:"liveSyncPosition",get:function(){var _=this.estimateLiveEdge(),p=this.targetLatency,v=this.levelDetails;if(_===null||p===null||v===null)return null;var a=v.edge,s=_-p-this.edgeStalled,n=a-v.totalduration,d=a-(this.config.lowLatencyMode&&v.partTarget||v.targetduration);return Math.min(Math.max(n,s),d)}},{key:"drift",get:function(){var _=this.levelDetails;return _===null?1:_.drift}},{key:"edgeStalled",get:function(){var _=this.levelDetails;if(_===null)return 0;var p=(this.config.lowLatencyMode&&_.partTarget||_.targetduration)*3;return Math.max(_.age-p,0)}},{key:"forwardBufferLength",get:function(){var _=this.media,p=this.levelDetails;if(!_||!p)return 0;var v=_.buffered.length;return(v?_.buffered.end(v-1):p.edge)-this.currentTime}}]),E}()},"./src/controller/level-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>s});var O=T("./src/types/level.ts"),D=T("./src/events.ts"),M=T("./src/errors.ts"),P=T("./src/utils/codecs.ts"),U=T("./src/controller/level-helper.ts"),b=T("./src/controller/base-playlist-controller.ts"),A=T("./src/types/loader.ts");function S(){return S=Object.assign?Object.assign.bind():function(n){for(var d=1;d<arguments.length;d++){var l=arguments[d];for(var i in l)Object.prototype.hasOwnProperty.call(l,i)&&(n[i]=l[i])}return n},S.apply(this,arguments)}function E(n,d){for(var l=0;l<d.length;l++){var i=d[l];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,f(i.key),i)}}function x(n,d,l){return d&&E(n.prototype,d),l&&E(n,l),Object.defineProperty(n,"prototype",{writable:!1}),n}function f(n){var d=_(n,"string");return typeof d=="symbol"?d:String(d)}function _(n,d){if(typeof n!="object"||n===null)return n;var l=n[Symbol.toPrimitive];if(l!==void 0){var i=l.call(n,d||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(n)}function p(n,d){n.prototype=Object.create(d.prototype),n.prototype.constructor=n,v(n,d)}function v(n,d){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,u){return i.__proto__=u,i},v(n,d)}var a=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),s=function(n){p(d,n);function d(i){var u;return u=n.call(this,i,"[level-controller]")||this,u._levels=[],u._firstLevel=-1,u._startLevel=void 0,u.currentLevelIndex=-1,u.manualLevelIndex=-1,u.onParsedComplete=void 0,u._registerListeners(),u}var l=d.prototype;return l._registerListeners=function(){var u=this.hls;u.on(D.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.on(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(D.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.on(D.Events.FRAG_LOADED,this.onFragLoaded,this),u.on(D.Events.ERROR,this.onError,this)},l._unregisterListeners=function(){var u=this.hls;u.off(D.Events.MANIFEST_LOADED,this.onManifestLoaded,this),u.off(D.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(D.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),u.off(D.Events.FRAG_LOADED,this.onFragLoaded,this),u.off(D.Events.ERROR,this.onError,this)},l.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,n.prototype.destroy.call(this)},l.startLoad=function(){var u=this._levels;u.forEach(function(g){g.loadError=0}),n.prototype.startLoad.call(this)},l.onManifestLoaded=function(u,g){var c=[],m=[],e=[],r,t={},o,y=!1,h=!1,L=!1;if(g.levels.forEach(function(F){var W=F.attrs;y=y||!!(F.width&&F.height),h=h||!!F.videoCodec,L=L||!!F.audioCodec,a&&F.audioCodec&&F.audioCodec.indexOf("mp4a.40.34")!==-1&&(F.audioCodec=void 0);var K=F.bitrate+"-"+F.attrs.RESOLUTION+"-"+F.attrs.CODECS;o=t[K],o?o.url.push(F.url):(o=new O.Level(F),t[K]=o,c.push(o)),W&&(W.AUDIO&&(0,U.addGroupId)(o,"audio",W.AUDIO),W.SUBTITLES&&(0,U.addGroupId)(o,"text",W.SUBTITLES))}),(y||h)&&L&&(c=c.filter(function(F){var W=F.videoCodec,K=F.width,H=F.height;return!!W||!!(K&&H)})),c=c.filter(function(F){var W=F.audioCodec,K=F.videoCodec;return(!W||(0,P.isCodecSupportedInMp4)(W,"audio"))&&(!K||(0,P.isCodecSupportedInMp4)(K,"video"))}),g.audioTracks&&(m=g.audioTracks.filter(function(F){return!F.audioCodec||(0,P.isCodecSupportedInMp4)(F.audioCodec,"audio")}),(0,U.assignTrackIdsByGroup)(m)),g.subtitles&&(e=g.subtitles,(0,U.assignTrackIdsByGroup)(e)),c.length>0){r=c[0].bitrate,c.sort(function(F,W){return F.attrs["HDCP-LEVEL"]!==W.attrs["HDCP-LEVEL"]?(F.attrs["HDCP-LEVEL"]||"")>(W.attrs["HDCP-LEVEL"]||"")?1:-1:F.bitrate!==W.bitrate?F.bitrate-W.bitrate:F.attrs.SCORE!==W.attrs.SCORE?F.attrs.decimalFloatingPoint("SCORE")-W.attrs.decimalFloatingPoint("SCORE"):y&&F.height!==W.height?F.height-W.height:0}),this._levels=c;for(var R=0;R<c.length;R++)if(c[R].bitrate===r){this._firstLevel=R,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+r);break}var I=L&&!h,k={levels:c,audioTracks:m,subtitleTracks:e,sessionData:g.sessionData,sessionKeys:g.sessionKeys,firstLevel:this._firstLevel,stats:g.stats,audio:L,video:h,altAudio:!I&&m.some(function(F){return!!F.url})};this.hls.trigger(D.Events.MANIFEST_PARSED,k),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(D.Events.ERROR,{type:M.ErrorTypes.MEDIA_ERROR,details:M.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:g.url,reason:"no level with compatible codecs found in manifest"})},l.onError=function(u,g){var c,m;if(n.prototype.onError.call(this,u,g),!g.fatal){var e=g.context,r=this._levels[this.currentLevelIndex];if(e&&(e.type===A.PlaylistContextType.AUDIO_TRACK&&r.audioGroupIds&&e.groupId===r.audioGroupIds[r.urlId]||e.type===A.PlaylistContextType.SUBTITLE_TRACK&&r.textGroupIds&&e.groupId===r.textGroupIds[r.urlId])){this.redundantFailover(this.currentLevelIndex);return}var t=!1,o=!0,y;switch(g.details){case M.ErrorDetails.FRAG_LOAD_ERROR:case M.ErrorDetails.FRAG_LOAD_TIMEOUT:case M.ErrorDetails.KEY_LOAD_ERROR:case M.ErrorDetails.KEY_LOAD_TIMEOUT:if(g.frag){var h=g.frag.type===A.PlaylistLevelType.MAIN?g.frag.level:this.currentLevelIndex,L=this._levels[h];L?(L.fragmentError++,L.fragmentError>this.hls.config.fragLoadingMaxRetry&&(y=h)):y=h}break;case M.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var R=r.attrs["HDCP-LEVEL"];R&&(this.hls.maxHdcpLevel=O.HdcpLevels[O.HdcpLevels.indexOf(R)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'))}case M.ErrorDetails.FRAG_PARSING_ERROR:case M.ErrorDetails.KEY_SYSTEM_NO_SESSION:y=((c=g.frag)===null||c===void 0?void 0:c.type)===A.PlaylistLevelType.MAIN?g.frag.level:this.currentLevelIndex,g.levelRetry=!1;break;case M.ErrorDetails.LEVEL_LOAD_ERROR:case M.ErrorDetails.LEVEL_LOAD_TIMEOUT:e&&(e.deliveryDirectives&&(o=!1),y=e.level),t=!0;break;case M.ErrorDetails.REMUX_ALLOC_ERROR:y=(m=g.level)!=null?m:this.currentLevelIndex,t=!0;break}y!==void 0&&this.recoverLevel(g,y,t,o)}},l.recoverLevel=function(u,g,c,m){var e=u.details,r=this._levels[g];if(r.loadError++,c){var t=this.retryLoadingOrFail(u);if(t)u.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(m){var o=r.url.length;if(o>1&&r.loadError<o)u.levelRetry=!0,this.redundantFailover(g);else if(this.manualLevelIndex===-1){for(var y=-1,h=this._levels,L=h.length;L--;){var R=(L+this.currentLevelIndex)%h.length;if(R!==this.currentLevelIndex&&h[R].loadError===0){y=R;break}}y>-1&&this.currentLevelIndex!==y?(this.warn(e+": switch to "+y),u.levelRetry=!0,this.hls.nextAutoLevel=y):u.levelRetry===!1&&(u.fatal=!0)}}},l.redundantFailover=function(u){var g=this._levels[u],c=g.url.length;if(c>1){var m=(g.urlId+1)%c;this.warn("Switching to redundant URL-id "+m),this._levels.forEach(function(e){e.urlId=m}),this.level=u}},l.onFragLoaded=function(u,g){var c=g.frag;if(c!==void 0&&c.type===A.PlaylistLevelType.MAIN){var m=this._levels[c.level];m!==void 0&&(m.fragmentError=0,m.loadError=0)}},l.onLevelLoaded=function(u,g){var c,m=g.level,e=g.details,r=this._levels[m];if(!r){var t;this.warn("Invalid level index "+m),(t=g.deliveryDirectives)!==null&&t!==void 0&&t.skip&&(e.deltaUpdateFailed=!0);return}m===this.currentLevelIndex?(r.fragmentError===0&&(r.loadError=0,this.retryCount=0),this.playlistLoaded(m,g,r.details)):(c=g.deliveryDirectives)!==null&&c!==void 0&&c.skip&&(e.deltaUpdateFailed=!0)},l.onAudioTrackSwitched=function(u,g){var c=this.hls.levels[this.currentLevelIndex];if(!!c&&c.audioGroupIds){for(var m=-1,e=this.hls.audioTracks[g.id].groupId,r=0;r<c.audioGroupIds.length;r++)if(c.audioGroupIds[r]===e){m=r;break}m!==c.urlId&&(c.urlId=m,this.startLoad())}},l.loadPlaylist=function(u){n.prototype.loadPlaylist.call(this);var g=this.currentLevelIndex,c=this._levels[g];if(this.canLoad&&c&&c.url.length>0){var m=c.urlId,e=c.url[m];if(u)try{e=u.addDirectives(e)}catch(r){this.warn("Could not construct new URL with HLS Delivery Directives: "+r)}this.log("Attempt loading level index "+g+(u?" at sn "+u.msn+" part "+u.part:"")+" with URL-id "+m+" "+e),this.clearTimer(),this.hls.trigger(D.Events.LEVEL_LOADING,{url:e,level:g,id:m,deliveryDirectives:u||null})}},l.removeLevel=function(u,g){var c=function(r,t){return t!==g},m=this._levels.filter(function(e,r){return r!==u?!0:e.url.length>1&&g!==void 0?(e.url=e.url.filter(c),e.audioGroupIds&&(e.audioGroupIds=e.audioGroupIds.filter(c)),e.textGroupIds&&(e.textGroupIds=e.textGroupIds.filter(c)),e.urlId=0,!0):!1}).map(function(e,r){var t=e.details;return t!=null&&t.fragments&&t.fragments.forEach(function(o){o.level=r}),e});this._levels=m,this.hls.trigger(D.Events.LEVELS_UPDATED,{levels:m})},x(d,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(u){var g,c=this._levels;if(c.length!==0&&!(this.currentLevelIndex===u&&(g=c[u])!==null&&g!==void 0&&g.details)){if(u<0||u>=c.length){var m=u<0;if(this.hls.trigger(D.Events.ERROR,{type:M.ErrorTypes.OTHER_ERROR,details:M.ErrorDetails.LEVEL_SWITCH_ERROR,level:u,fatal:m,reason:"invalid level idx"}),m)return;u=Math.min(u,c.length-1)}this.clearTimer();var e=this.currentLevelIndex,r=c[e],t=c[u];this.log("switching to level "+u+" from "+e),this.currentLevelIndex=u;var o=S({},t,{level:u,maxBitrate:t.maxBitrate,uri:t.uri,urlId:t.urlId});delete o._urlId,this.hls.trigger(D.Events.LEVEL_SWITCHING,o);var y=t.details;if(!y||y.live){var h=this.switchParams(t.uri,r==null?void 0:r.details);this.loadPlaylist(h)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(u){this.manualLevelIndex=u,this._startLevel===void 0&&(this._startLevel=u),u!==-1&&(this.level=u)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(u){this._firstLevel=u}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var u=this.hls.config.startLevel;return u!==void 0?u:this._firstLevel}else return this._startLevel},set:function(u){this._startLevel=u}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(u){this.level=u,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=u)}}]),d}(b.default)},"./src/controller/level-helper.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{addGroupId:()=>U,addSliding:()=>a,adjustSliding:()=>v,assignTrackIdsByGroup:()=>b,computeReloadInterval:()=>s,getFragmentWithSN:()=>n,getPartWith:()=>d,mapFragmentIntersection:()=>p,mapPartIntersection:()=>_,mergeDetails:()=>x,updateFragPTSDTS:()=>E,updatePTS:()=>A});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/logger.ts"),M=T("./src/loader/date-range.ts");function P(){return P=Object.assign?Object.assign.bind():function(l){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(l[g]=u[g])}return l},P.apply(this,arguments)}function U(l,i,u){switch(i){case"audio":l.audioGroupIds||(l.audioGroupIds=[]),l.audioGroupIds.push(u);break;case"text":l.textGroupIds||(l.textGroupIds=[]),l.textGroupIds.push(u);break}}function b(l){var i={};l.forEach(function(u){var g=u.groupId||"";u.id=i[g]=i[g]||0,i[g]++})}function A(l,i,u){var g=l[i],c=l[u];S(g,c)}function S(l,i){var u=i.startPTS;if((0,O.isFiniteNumber)(u)){var g=0,c;i.sn>l.sn?(g=u-l.start,c=l):(g=l.start-u,c=i),c.duration!==g&&(c.duration=g)}else if(i.sn>l.sn){var m=l.cc===i.cc;m&&l.minEndPTS?i.start=l.start+(l.minEndPTS-l.start):i.start=l.start+l.duration}else i.start=Math.max(l.start-i.duration,0)}function E(l,i,u,g,c,m){var e=g-u;e<=0&&(D.logger.warn("Fragment should have a positive duration",i),g=u+i.duration,m=c+i.duration);var r=u,t=g,o=i.startPTS,y=i.endPTS;if((0,O.isFiniteNumber)(o)){var h=Math.abs(o-u);(0,O.isFiniteNumber)(i.deltaPTS)?i.deltaPTS=Math.max(h,i.deltaPTS):i.deltaPTS=h,r=Math.max(u,o),u=Math.min(u,o),c=Math.min(c,i.startDTS),t=Math.min(g,y),g=Math.max(g,y),m=Math.max(m,i.endDTS)}i.duration=g-u;var L=u-i.start;i.start=i.startPTS=u,i.maxStartPTS=r,i.startDTS=c,i.endPTS=g,i.minEndPTS=t,i.endDTS=m;var R=i.sn;if(!l||R<l.startSN||R>l.endSN)return 0;var I,k=R-l.startSN,F=l.fragments;for(F[k]=i,I=k;I>0;I--)S(F[I],F[I-1]);for(I=k;I<F.length-1;I++)S(F[I],F[I+1]);return l.fragmentHint&&S(F[F.length-1],l.fragmentHint),l.PTSKnown=l.alignedSliding=!0,L}function x(l,i){for(var u=null,g=l.fragments,c=g.length-1;c>=0;c--){var m=g[c].initSegment;if(m){u=m;break}}l.fragmentHint&&delete l.fragmentHint.endPTS;var e=0,r;if(p(l,i,function(I,k){I.relurl&&(e=I.cc-k.cc),(0,O.isFiniteNumber)(I.startPTS)&&(0,O.isFiniteNumber)(I.endPTS)&&(k.start=k.startPTS=I.startPTS,k.startDTS=I.startDTS,k.appendedPTS=I.appendedPTS,k.maxStartPTS=I.maxStartPTS,k.endPTS=I.endPTS,k.endDTS=I.endDTS,k.minEndPTS=I.minEndPTS,k.duration=I.endPTS-I.startPTS,k.duration&&(r=k),i.PTSKnown=i.alignedSliding=!0),k.elementaryStreams=I.elementaryStreams,k.loader=I.loader,k.stats=I.stats,k.urlId=I.urlId,I.initSegment&&(k.initSegment=I.initSegment,u=I.initSegment)}),u){var t=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;t.forEach(function(I){var k;(!I.initSegment||I.initSegment.relurl===((k=u)===null||k===void 0?void 0:k.relurl))&&(I.initSegment=u)})}if(i.skippedSegments)if(i.deltaUpdateFailed=i.fragments.some(function(I){return!I}),i.deltaUpdateFailed){D.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var o=i.skippedSegments;o--;)i.fragments.shift();i.startSN=i.fragments[0].sn,i.startCC=i.fragments[0].cc}else i.canSkipDateRanges&&(i.dateRanges=f(l.dateRanges,i.dateRanges,i.recentlyRemovedDateranges));var y=i.fragments;if(e){D.logger.warn("discontinuity sliding from playlist, take drift into account");for(var h=0;h<y.length;h++)y[h].cc+=e}i.skippedSegments&&(i.startCC=i.fragments[0].cc),_(l.partList,i.partList,function(I,k){k.elementaryStreams=I.elementaryStreams,k.stats=I.stats}),r?E(i,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):v(l,i),y.length&&(i.totalduration=i.edge-y[0].start),i.driftStartTime=l.driftStartTime,i.driftStart=l.driftStart;var L=i.advancedDateTime;if(i.advanced&&L){var R=i.edge;i.driftStart||(i.driftStartTime=L,i.driftStart=R),i.driftEndTime=L,i.driftEnd=R}else i.driftEndTime=l.driftEndTime,i.driftEnd=l.driftEnd,i.advancedDateTime=l.advancedDateTime}function f(l,i,u){var g=P({},l);return u&&u.forEach(function(c){delete g[c]}),Object.keys(i).forEach(function(c){var m=new M.DateRange(i[c].attr,g[c]);m.isValid?g[c]=m:D.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(i[c].attr)+'"')}),g}function _(l,i,u){if(l&&i)for(var g=0,c=0,m=l.length;c<=m;c++){var e=l[c],r=i[c+g];e&&r&&e.index===r.index&&e.fragment.sn===r.fragment.sn?u(e,r):g--}}function p(l,i,u){for(var g=i.skippedSegments,c=Math.max(l.startSN,i.startSN)-i.startSN,m=(l.fragmentHint?1:0)+(g?i.endSN:Math.min(l.endSN,i.endSN))-i.startSN,e=i.startSN-l.startSN,r=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,t=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,o=c;o<=m;o++){var y=t[e+o],h=r[o];g&&!h&&o<g&&(h=i.fragments[o]=y),y&&h&&u(y,h)}}function v(l,i){var u=i.startSN+i.skippedSegments-l.startSN,g=l.fragments;u<0||u>=g.length||a(i,g[u].start)}function a(l,i){if(i){for(var u=l.fragments,g=l.skippedSegments;g<u.length;g++)u[g].start+=i;l.fragmentHint&&(l.fragmentHint.start+=i)}}function s(l,i){i===void 0&&(i=1/0);var u=1e3*l.targetduration;if(l.updated){var g=l.fragments,c=4;if(g.length&&u*c>i){var m=g[g.length-1].duration*1e3;m<u&&(u=m)}}else u/=2;return Math.round(u)}function n(l,i,u){if(!l||!l.details)return null;var g=l.details,c=g.fragments[i-g.startSN];return c||(c=g.fragmentHint,c&&c.sn===i)?c:i<g.startSN&&u&&u.sn===i?u:null}function d(l,i,u){if(!l||!l.details)return null;var g=l.details.partList;if(g)for(var c=g.length;c--;){var m=g[c];if(m.index===u&&m.fragment.sn===i)return m}return null}},"./src/controller/stream-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>i});var O=T("./src/polyfills/number.ts"),D=T("./src/controller/base-stream-controller.ts"),M=T("./src/is-supported.ts"),P=T("./src/events.ts"),U=T("./src/utils/buffer-helper.ts"),b=T("./src/controller/fragment-tracker.ts"),A=T("./src/types/loader.ts"),S=T("./src/loader/fragment.ts"),E=T("./src/demux/transmuxer-interface.ts"),x=T("./src/types/transmuxer.ts"),f=T("./src/controller/gap-controller.ts"),_=T("./src/errors.ts");function p(u,g){for(var c=0;c<g.length;c++){var m=g[c];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(u,a(m.key),m)}}function v(u,g,c){return g&&p(u.prototype,g),c&&p(u,c),Object.defineProperty(u,"prototype",{writable:!1}),u}function a(u){var g=s(u,"string");return typeof g=="symbol"?g:String(g)}function s(u,g){if(typeof u!="object"||u===null)return u;var c=u[Symbol.toPrimitive];if(c!==void 0){var m=c.call(u,g||"default");if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(g==="string"?String:Number)(u)}function n(u,g){u.prototype=Object.create(g.prototype),u.prototype.constructor=u,d(u,g)}function d(u,g){return d=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,e){return m.__proto__=e,m},d(u,g)}var l=100,i=function(u){n(g,u);function g(m,e,r){var t;return t=u.call(this,m,e,r,"[stream-controller]")||this,t.audioCodecSwap=!1,t.gapController=null,t.level=-1,t._forceStartLoad=!1,t.altAudio=!1,t.audioOnly=!1,t.fragPlaying=null,t.onvplaying=null,t.onvseeked=null,t.fragLastKbps=0,t.couldBacktrack=!1,t.backtrackFragment=null,t.audioCodecSwitch=!1,t.videoBuffer=null,t._registerListeners(),t}var c=g.prototype;return c._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.MANIFEST_PARSED,this.onManifestParsed,this),e.on(P.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(P.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(P.Events.ERROR,this.onError,this),e.on(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(P.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(P.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(P.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._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.MANIFEST_PARSED,this.onManifestParsed,this),e.off(P.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(P.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(P.Events.ERROR,this.onError,this),e.off(P.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(P.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(P.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(P.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(P.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(P.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},c.startLoad=function(e){if(this.levels){var r=this.lastCurrentTime,t=this.hls;if(this.stopLoad(),this.setInterval(l),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var o=t.startLevel;o===-1&&(t.config.testBandwidth&&this.levels.length>1?(o=0,this.bitrateTest=!0):o=t.nextAutoLevel),this.level=t.nextLoadLevel=o,this.loadedmetadata=!1}r>0&&e===-1&&(this.log("Override startPosition with lastCurrentTime @"+r.toFixed(3)),e=r),this.state=D.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=D.State.STOPPED},c.stopLoad=function(){this._forceStartLoad=!1,u.prototype.stopLoad.call(this)},c.doTick=function(){switch(this.state){case D.State.IDLE:this.doTickIdle();break;case D.State.WAITING_LEVEL:{var e,r=this.levels,t=this.level,o=r==null||(e=r[t])===null||e===void 0?void 0:e.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=D.State.IDLE;break}break}case D.State.FRAG_LOADING_WAITING_RETRY:{var y,h=self.performance.now(),L=this.retryDate;(!L||h>=L||(y=this.media)!==null&&y!==void 0&&y.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=D.State.IDLE)}break;default:break}this.onTickEnd()},c.onTickEnd=function(){u.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},c.doTickIdle=function(){var e=this.hls,r=this.levelLastLoaded,t=this.levels,o=this.media,y=e.config,h=e.nextLoadLevel;if(!(r===null||!o&&(this.startFragRequested||!y.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!t||!t[h])){var L=t[h],R=this.getMainFwdBufferInfo();if(R!==null){var I=this.getLevelDetails();if(I&&this._streamEnded(R,I)){var k={};this.altAudio&&(k.type="video"),this.hls.trigger(P.Events.BUFFER_EOS,k),this.state=D.State.ENDED;return}this.level=e.nextLoadLevel=h;var F=L.details;if(!F||this.state===D.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==h){this.level=h,this.state=D.State.WAITING_LEVEL;return}var W=R.len,K=this.getMaxBufferLength(L.maxBitrate);if(!(W>=K)){this.backtrackFragment&&this.backtrackFragment.start>R.end&&(this.backtrackFragment=null);var H=this.backtrackFragment?this.backtrackFragment.start:R.end,Y=this.getNextFragment(H,F);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==b.FragmentState.OK){var q,ee=((q=this.backtrackFragment)!=null?q:Y).sn,ae=ee-F.startSN,re=F.fragments[ae-1];re&&Y.cc===re.cc&&(Y=re,this.fragmentTracker.removeFragment(re))}else this.backtrackFragment&&R.len&&(this.backtrackFragment=null);if(Y&&this.fragmentTracker.getState(Y)===b.FragmentState.OK&&this.nextLoadPosition>H){var se=this.audioOnly&&!this.altAudio?S.ElementaryStreamTypes.AUDIO:S.ElementaryStreamTypes.VIDEO,le=(se===S.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;le&&this.afterBufferFlushed(le,se,A.PlaylistLevelType.MAIN),Y=this.getNextFragment(this.nextLoadPosition,F)}!Y||(Y.initSegment&&!Y.initSegment.data&&!this.bitrateTest&&(Y=Y.initSegment),this.loadFragment(Y,F,H))}}}},c.loadFragment=function(e,r,t){var o,y=this.fragmentTracker.getState(e);this.fragCurrent=e,y===b.FragmentState.NOT_LOADED?e.sn==="initSegment"?this._loadInitSegment(e,r):this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):(this.startFragRequested=!0,u.prototype.loadFragment.call(this,e,r,t)):y===b.FragmentState.APPENDING?this.reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e):((o=this.media)===null||o===void 0?void 0:o.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},c.getAppendedFrag=function(e){var r=this.fragmentTracker.getAppendedFrag(e,A.PlaylistLevelType.MAIN);return r&&"fragment"in r?r.fragment:r},c.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,A.PlaylistLevelType.MAIN)},c.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},c.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},c.nextLevelSwitch=function(){var e=this.levels,r=this.media;if(r!=null&&r.readyState){var t,o=this.getAppendedFrag(r.currentTime);if(o&&o.start>1&&this.flushMainBuffer(0,o.start-1),!r.paused&&e){var y=this.hls.nextLoadLevel,h=e[y],L=this.fragLastKbps;L&&this.fragCurrent?t=this.fragCurrent.duration*h.maxBitrate/(1e3*L)+1:t=0}else t=0;var R=this.getBufferedFrag(r.currentTime+t);if(R){var I=this.followingBufferedFrag(R);if(I){this.abortCurrentFrag();var k=I.maxStartPTS?I.maxStartPTS:I.start,F=I.duration,W=Math.max(R.end,k+Math.min(Math.max(F-this.config.maxFragLookUpTolerance,F*.5),F*.75));this.flushMainBuffer(W,Number.POSITIVE_INFINITY)}}}},c.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&e.abortRequests(),this.state){case D.State.KEY_LOADING:case D.State.FRAG_LOADING:case D.State.FRAG_LOADING_WAITING_RETRY:case D.State.PARSING:case D.State.PARSED:this.state=D.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},c.flushMainBuffer=function(e,r){u.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},c.onMediaAttached=function(e,r){u.prototype.onMediaAttached.call(this,e,r);var t=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),t.addEventListener("playing",this.onvplaying),t.addEventListener("seeked",this.onvseeked),this.gapController=new f.default(this.config,t,this.fragmentTracker,this.hls)},c.onMediaDetaching=function(){var e=this.media;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),u.prototype.onMediaDetaching.call(this)},c.onMediaPlaying=function(){this.tick()},c.onMediaSeeked=function(){var e=this.media,r=e?e.currentTime:null;(0,O.isFiniteNumber)(r)&&this.log("Media seeked to "+r.toFixed(3)),this.tick()},c.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},c.onManifestParsed=function(e,r){var t=!1,o=!1,y;r.levels.forEach(function(h){y=h.audioCodec,y&&(y.indexOf("mp4a.40.2")!==-1&&(t=!0),y.indexOf("mp4a.40.5")!==-1&&(o=!0))}),this.audioCodecSwitch=t&&o&&!(0,M.changeTypeSupported)(),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},c.onLevelLoading=function(e,r){var t=this.levels;if(!(!t||this.state!==D.State.IDLE)){var o=t[r.level];(!o.details||o.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(o.details))&&(this.state=D.State.WAITING_LEVEL)}},c.onLevelLoaded=function(e,r){var t,o=this.levels,y=r.level,h=r.details,L=h.totalduration;if(!o){this.warn("Levels were reset while loading level "+y);return}this.log("Level "+y+" loaded ["+h.startSN+","+h.endSN+"], cc ["+h.startCC+", "+h.endCC+"] duration:"+L);var R=this.fragCurrent;R&&(this.state===D.State.FRAG_LOADING||this.state===D.State.FRAG_LOADING_WAITING_RETRY)&&R.level!==r.level&&R.loader&&(this.state=D.State.IDLE,this.backtrackFragment=null,R.abortRequests());var I=o[y],k=0;if(h.live||(t=I.details)!==null&&t!==void 0&&t.live){if(h.fragments[0]||(h.deltaUpdateFailed=!0),h.deltaUpdateFailed)return;k=this.alignPlaylists(h,I.details)}if(I.details=h,this.levelLastLoaded=y,this.hls.trigger(P.Events.LEVEL_UPDATED,{details:h,level:y}),this.state===D.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(h))return;this.state=D.State.IDLE}this.startFragRequested?h.live&&this.synchronizeToLiveEdge(h):this.setStartPosition(h,k),this.tick()},c._handleFragmentLoadProgress=function(e){var r,t=e.frag,o=e.part,y=e.payload,h=this.levels;if(!h){this.warn("Levels were reset while fragment load was in progress. Fragment "+t.sn+" of level "+t.level+" will not be buffered");return}var L=h[t.level],R=L.details;if(!R){this.warn("Dropping fragment "+t.sn+" of level "+t.level+" after level details were reset");return}var I=L.videoCodec,k=R.PTSKnown||!R.live,F=(r=t.initSegment)===null||r===void 0?void 0:r.data,W=this._getAudioCodec(L),K=this.transmuxer=this.transmuxer||new E.default(this.hls,A.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),H=o?o.index:-1,Y=H!==-1,q=new x.ChunkMetadata(t.level,t.sn,t.stats.chunkCount,y.byteLength,H,Y),ee=this.initPTS[t.cc];K.push(y,F,W,I,t,o,R.totalduration,k,q,ee)},c.onAudioTrackSwitching=function(e,r){var t=this.altAudio,o=!!r.url,y=r.id;if(!o){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var h=this.fragCurrent;h&&(this.log("Switching to main audio track, cancel main fragment load"),h.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var L=this.hls;t&&L.trigger(P.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),L.trigger(P.Events.AUDIO_TRACK_SWITCHED,{id:y})}},c.onAudioTrackSwitched=function(e,r){var t=r.id,o=!!this.hls.audioTracks[t].url;if(o){var y=this.videoBuffer;y&&this.mediaBuffer!==y&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=y)}this.altAudio=o,this.tick()},c.onBufferCreated=function(e,r){var t=r.tracks,o,y,h=!1;for(var L in t){var R=t[L];if(R.id==="main"){if(y=L,o=R,L==="video"){var I=t[L];I&&(this.videoBuffer=I.buffer)}}else h=!0}h&&o?(this.log("Alternate track found, use "+y+".buffered to schedule main fragment loading"),this.mediaBuffer=o.buffer):this.mediaBuffer=this.media},c.onFragBuffered=function(e,r){var t=r.frag,o=r.part;if(!(t&&t.type!==A.PlaylistLevelType.MAIN)){if(this.fragContextChanged(t)){this.warn("Fragment "+t.sn+(o?" p: "+o.index:"")+" of level "+t.level+" finished buffering, but was aborted. state: "+this.state),this.state===D.State.PARSED&&(this.state=D.State.IDLE);return}var y=o?o.stats:t.stats;this.fragLastKbps=Math.round(8*y.total/(y.buffering.end-y.loading.first)),t.sn!=="initSegment"&&(this.fragPrevious=t),this.fragBufferedComplete(t,o)}},c.onError=function(e,r){if(r.type===_.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,r);return}switch(r.details){case _.ErrorDetails.FRAG_LOAD_ERROR:case _.ErrorDetails.FRAG_LOAD_TIMEOUT:case _.ErrorDetails.FRAG_PARSING_ERROR:case _.ErrorDetails.KEY_LOAD_ERROR:case _.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,r);break;case _.ErrorDetails.LEVEL_LOAD_ERROR:case _.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==D.State.ERROR&&(r.fatal?(this.warn(""+r.details),this.state=D.State.ERROR):!r.levelRetry&&this.state===D.State.WAITING_LEVEL&&(this.state=D.State.IDLE));break;case _.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="main"&&(this.state===D.State.PARSING||this.state===D.State.PARSED)){var t=!0,o=this.getFwdBufferInfo(this.media,A.PlaylistLevelType.MAIN);o&&o.len>.5&&(t=!this.reduceMaxBufferLength(o.len)),t&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},c.checkBuffer=function(){var e=this.media,r=this.gapController;if(!(!e||!r||!e.readyState)){if(this.loadedmetadata||!U.BufferHelper.getBuffered(e).length){var t=this.state!==D.State.IDLE?this.fragCurrent:null;r.poll(this.lastCurrentTime,t)}this.lastCurrentTime=e.currentTime}},c.onFragLoadEmergencyAborted=function(){this.state=D.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},c.onBufferFlushed=function(e,r){var t=r.type;if(t!==S.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var o=(t===S.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(o,t,A.PlaylistLevelType.MAIN)}},c.onLevelsUpdated=function(e,r){this.levels=r.levels},c.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},c.seekToStartPos=function(){var e=this.media;if(!!e){var r=e.currentTime,t=this.startPosition;if(t>=0&&r<t){if(e.seeking){this.log("could not seek to "+t+", already seeking at "+r);return}var o=U.BufferHelper.getBuffered(e),y=o.length?o.start(0):0,h=y-t;h>0&&(h<this.config.maxBufferHole||h<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+h+" to match buffer start"),t+=h,this.startPosition=t),this.log("seek to target start position "+t+" from current time "+r),e.currentTime=t}}},c._getAudioCodec=function(e){var r=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&r&&(this.log("Swapping audio codec"),r.indexOf("mp4a.40.5")!==-1?r="mp4a.40.2":r="mp4a.40.5"),r},c._loadBitrateTestFrag=function(e,r){var t=this;e.bitrateTest=!0,this._doFragLoad(e,r).then(function(o){var y=t.hls;if(!(!o||y.nextLoadLevel||t.fragContextChanged(e))){t.fragLoadError=0,t.state=D.State.IDLE,t.startFragRequested=!1,t.bitrateTest=!1;var h=e.stats;h.parsing.start=h.parsing.end=h.buffering.start=h.buffering.end=self.performance.now(),y.trigger(P.Events.FRAG_LOADED,o),e.bitrateTest=!1}})},c._handleTransmuxComplete=function(e){var r,t="main",o=this.hls,y=e.remuxResult,h=e.chunkMeta,L=this.getCurrentContext(h);if(!L){this.warn("The loading context changed while buffering fragment "+h.sn+" of level "+h.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(h.level);return}var R=L.frag,I=L.part,k=L.level,F=y.video,W=y.text,K=y.id3,H=y.initSegment,Y=k.details,q=this.altAudio?void 0:y.audio;if(!this.fragContextChanged(R)){if(this.state=D.State.PARSING,H){H.tracks&&(this._bufferInitSegment(k,H.tracks,R,h),o.trigger(P.Events.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:t,tracks:H.tracks}));var ee=H.initPTS,ae=H.timescale;(0,O.isFiniteNumber)(ee)&&(this.initPTS[R.cc]=ee,o.trigger(P.Events.INIT_PTS_FOUND,{frag:R,id:t,initPTS:ee,timescale:ae}))}if(F&&y.independent!==!1){if(Y){var re=F.startPTS,se=F.endPTS,le=F.startDTS,de=F.endDTS;if(I)I.elementaryStreams[F.type]={startPTS:re,endPTS:se,startDTS:le,endDTS:de};else if(F.firstKeyFrame&&F.independent&&h.id===1&&(this.couldBacktrack=!0),F.dropped&&F.independent){var ue=this.getMainFwdBufferInfo(),fe=(ue?ue.end:this.getLoadPosition())+this.config.maxBufferHole,ce=F.firstKeyFramePTS?F.firstKeyFramePTS:re;if(fe<ce-this.config.maxBufferHole){this.backtrack(R);return}R.setElementaryStreamInfo(F.type,R.start,se,R.start,de,!0)}R.setElementaryStreamInfo(F.type,re,se,le,de),this.backtrackFragment&&(this.backtrackFragment=R),this.bufferFragmentData(F,R,I,h)}}else if(y.independent===!1){this.backtrack(R);return}if(q){var be=q.startPTS,Pe=q.endPTS,we=q.startDTS,pe=q.endDTS;I&&(I.elementaryStreams[S.ElementaryStreamTypes.AUDIO]={startPTS:be,endPTS:Pe,startDTS:we,endDTS:pe}),R.setElementaryStreamInfo(S.ElementaryStreamTypes.AUDIO,be,Pe,we,pe),this.bufferFragmentData(q,R,I,h)}if(Y&&K!==null&&K!==void 0&&(r=K.samples)!==null&&r!==void 0&&r.length){var Me={id:t,frag:R,details:Y,samples:K.samples};o.trigger(P.Events.FRAG_PARSING_METADATA,Me)}if(Y&&W){var Re={id:t,frag:R,details:Y,samples:W.samples};o.trigger(P.Events.FRAG_PARSING_USERDATA,Re)}}},c._bufferInitSegment=function(e,r,t,o){var y=this;if(this.state===D.State.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var h=r.audio,L=r.video,R=r.audiovideo;if(h){var I=e.audioCodec,k=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(I&&(I.indexOf("mp4a.40.5")!==-1?I="mp4a.40.2":I="mp4a.40.5"),h.metadata.channelCount!==1&&k.indexOf("firefox")===-1&&(I="mp4a.40.5")),k.indexOf("android")!==-1&&h.container!=="audio/mpeg"&&(I="mp4a.40.2",this.log("Android: force audio codec to "+I)),e.audioCodec&&e.audioCodec!==I&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+I+'"'),h.levelCodec=I,h.id="main",this.log("Init audio buffer, container:"+h.container+", codecs[selected/level/parsed]=["+(I||"")+"/"+(e.audioCodec||"")+"/"+h.codec+"]")}L&&(L.levelCodec=e.videoCodec,L.id="main",this.log("Init video buffer, container:"+L.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+L.codec+"]")),R&&this.log("Init audiovideo buffer, container:"+R.container+", codecs[level/parsed]=["+(e.attrs.CODECS||"")+"/"+R.codec+"]"),this.hls.trigger(P.Events.BUFFER_CODECS,r),Object.keys(r).forEach(function(F){var W=r[F],K=W.initSegment;K!=null&&K.byteLength&&y.hls.trigger(P.Events.BUFFER_APPENDING,{type:F,data:K,frag:t,part:null,chunkMeta:o,parent:t.type})}),this.tick()}},c.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,A.PlaylistLevelType.MAIN)},c.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=D.State.IDLE},c.checkFragmentChanged=function(){var e=this.media,r=null;if(e&&e.readyState>1&&e.seeking===!1){var t=e.currentTime;if(U.BufferHelper.isBuffered(e,t)?r=this.getAppendedFrag(t):U.BufferHelper.isBuffered(e,t+.1)&&(r=this.getAppendedFrag(t+.1)),r){this.backtrackFragment=null;var o=this.fragPlaying,y=r.level;(!o||r.sn!==o.sn||o.level!==y||r.urlId!==o.urlId)&&(this.fragPlaying=r,this.hls.trigger(P.Events.FRAG_CHANGED,{frag:r}),(!o||o.level!==y)&&this.hls.trigger(P.Events.LEVEL_SWITCHED,{level:y}))}}},v(g,[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var r=e.currentTime,t=this.currentFrag;if(t&&(0,O.isFiniteNumber)(r)&&(0,O.isFiniteNumber)(t.programDateTime)){var o=t.programDateTime+(r-t.start)*1e3;return new Date(o)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),g}(D.default)},"./src/controller/subtitle-stream-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{SubtitleStreamController:()=>n});var O=T("./src/events.ts"),D=T("./src/utils/buffer-helper.ts"),M=T("./src/controller/fragment-finders.ts"),P=T("./src/utils/discontinuities.ts"),U=T("./src/controller/level-helper.ts"),b=T("./src/controller/fragment-tracker.ts"),A=T("./src/controller/base-stream-controller.ts"),S=T("./src/types/loader.ts"),E=T("./src/types/level.ts");function x(l,i){for(var u=0;u<i.length;u++){var g=i[u];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(l,_(g.key),g)}}function f(l,i,u){return i&&x(l.prototype,i),u&&x(l,u),Object.defineProperty(l,"prototype",{writable:!1}),l}function _(l){var i=p(l,"string");return typeof i=="symbol"?i:String(i)}function p(l,i){if(typeof l!="object"||l===null)return l;var u=l[Symbol.toPrimitive];if(u!==void 0){var g=u.call(l,i||"default");if(typeof g!="object")return g;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(l)}function v(l,i){l.prototype=Object.create(i.prototype),l.prototype.constructor=l,a(l,i)}function a(l,i){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(g,c){return g.__proto__=c,g},a(l,i)}var s=500,n=function(l){v(i,l);function i(g,c,m){var e;return e=l.call(this,g,c,m,"[subtitle-stream-controller]")||this,e.levels=[],e.currentTrackId=-1,e.tracksBuffered=[],e.mainDetails=null,e._registerListeners(),e}var u=i.prototype;return u.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},u._registerListeners=function(){var c=this.hls;c.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(O.Events.ERROR,this.onError,this),c.on(O.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.on(O.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),c.on(O.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),c.on(O.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),c.on(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),c.on(O.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u._unregisterListeners=function(){var c=this.hls;c.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(O.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(O.Events.ERROR,this.onError,this),c.off(O.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.off(O.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),c.off(O.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),c.off(O.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),c.off(O.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),c.off(O.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u.startLoad=function(c){this.stopLoad(),this.state=A.State.IDLE,this.setInterval(s),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=c,this.tick()},u.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},u.onLevelLoaded=function(c,m){this.mainDetails=m.details},u.onSubtitleFragProcessed=function(c,m){var e=m.frag,r=m.success;if(this.fragPrevious=e,this.state=A.State.IDLE,!!r){var t=this.tracksBuffered[this.currentTrackId];if(!!t){for(var o,y=e.start,h=0;h<t.length;h++)if(y>=t[h].start&&y<=t[h].end){o=t[h];break}var L=e.start+e.duration;o?o.end=L:(o={start:y,end:L},t.push(o)),this.fragmentTracker.fragBuffered(e)}}},u.onBufferFlushing=function(c,m){var e=m.startOffset,r=m.endOffset;if(e===0&&r!==Number.POSITIVE_INFINITY){var t=this.currentTrackId,o=this.levels;if(!o.length||!o[t]||!o[t].details)return;var y=o[t].details,h=y.targetduration,L=r-h;if(L<=0)return;m.endOffsetSubtitles=Math.max(0,L),this.tracksBuffered.forEach(function(R){for(var I=0;I<R.length;){if(R[I].end<=L){R.shift();continue}else if(R[I].start<L)R[I].start=L;else break;I++}}),this.fragmentTracker.removeFragmentsInRange(e,L,S.PlaylistLevelType.SUBTITLE)}},u.onFragBuffered=function(c,m){if(!this.loadedmetadata&&m.frag.type===S.PlaylistLevelType.MAIN){var e;(e=this.media)!==null&&e!==void 0&&e.buffered.length&&(this.loadedmetadata=!0)}},u.onError=function(c,m){var e=m.frag;!e||e.type!==S.PlaylistLevelType.SUBTITLE||(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=A.State.IDLE)},u.onSubtitleTracksUpdated=function(c,m){var e=this,r=m.subtitleTracks;this.tracksBuffered=[],this.levels=r.map(function(t){return new E.Level(t)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(t){e.tracksBuffered[t.id]=[]}),this.mediaBuffer=null},u.onSubtitleTrackSwitch=function(c,m){if(this.currentTrackId=m.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var e=this.levels[this.currentTrackId];e!=null&&e.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,e&&this.setInterval(s)},u.onSubtitleTrackLoaded=function(c,m){var e,r=m.details,t=m.id,o=this.currentTrackId,y=this.levels;if(!!y.length){var h=y[o];if(!(t>=y.length||t!==o||!h)){this.mediaBuffer=this.mediaBufferTimeRanges;var L=0;if(r.live||(e=h.details)!==null&&e!==void 0&&e.live){var R=this.mainDetails;if(r.deltaUpdateFailed||!R)return;var I=R.fragments[0];h.details?(L=this.alignPlaylists(r,h.details),L===0&&I&&(L=I.start,(0,U.addSliding)(r,L))):r.hasProgramDateTime&&R.hasProgramDateTime?((0,P.alignMediaPlaylistByPDT)(r,R),L=r.fragments[0].start):I&&(L=I.start,(0,U.addSliding)(r,L))}if(h.details=r,this.levelLastLoaded=t,!this.startFragRequested&&(this.mainDetails||!r.live)&&this.setStartPosition(h.details,L),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===A.State.IDLE){var k=(0,M.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0);k||(this.warn("Subtitle playlist not aligned with playback"),h.details=void 0)}}}},u._handleFragmentLoadComplete=function(c){var m=this,e=c.frag,r=c.payload,t=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&r&&r.byteLength>0&&t&&t.key&&t.iv&&t.method==="AES-128"){var y=performance.now();this.decrypter.decrypt(new Uint8Array(r),t.key.buffer,t.iv.buffer).then(function(h){var L=performance.now();o.trigger(O.Events.FRAG_DECRYPTED,{frag:e,payload:h,stats:{tstart:y,tdecrypt:L}})}).catch(function(h){m.warn(h.name+": "+h.message),m.state=A.State.IDLE})}},u.doTick=function(){if(!this.media){this.state=A.State.IDLE;return}if(this.state===A.State.IDLE){var c=this.currentTrackId,m=this.levels;if(!m.length||!m[c]||!m[c].details)return;var e=m[c].details,r=e.targetduration,t=this.config,o=this.getLoadPosition(),y=D.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o-r,t.maxBufferHole),h=y.end,L=y.len,R=this.getFwdBufferInfo(this.media,S.PlaylistLevelType.MAIN),I=this.getMaxBufferLength(R==null?void 0:R.len)+r;if(L>I)return;console.assert(e,"Subtitle track details are defined on idle subtitle stream controller tick");var k=e.fragments,F=k.length,W=e.edge,K=null,H=this.fragPrevious;if(h<W){var Y=t.maxFragLookUpTolerance;K=(0,M.findFragmentByPTS)(H,k,Math.max(k[0].start,h),Y),!K&&H&&H.start<k[0].start&&(K=k[0])}else K=k[F-1];if(!K)return;K=this.mapToInitFragWhenRequired(K),this.fragmentTracker.getState(K)===b.FragmentState.NOT_LOADED&&this.loadFragment(K,e,h)}},u.getMaxBufferLength=function(c){var m=l.prototype.getMaxBufferLength.call(this);return c?Math.max(m,c):m},u.loadFragment=function(c,m,e){this.fragCurrent=c,c.sn==="initSegment"?this._loadInitSegment(c,m):(this.startFragRequested=!0,l.prototype.loadFragment.call(this,c,m,e))},f(i,[{key:"mediaBufferTimeRanges",get:function(){return new d(this.tracksBuffered[this.currentTrackId]||[])}}]),i}(A.default),d=function(i){this.buffered=void 0;var u=function(c,m,e){if(m=m>>>0,m>e-1)throw new DOMException("Failed to execute '"+c+"' on 'TimeRanges': The index provided ("+m+") is greater than the maximum bound ("+e+")");return i[m][c]};this.buffered={get length(){return i.length},end:function(c){return u("end",c,i.length)},start:function(c){return u("start",c,i.length)}}}},"./src/controller/subtitle-track-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>p});var O=T("./src/events.ts"),D=T("./src/utils/texttrack-utils.ts"),M=T("./src/controller/base-playlist-controller.ts"),P=T("./src/types/loader.ts");function U(v,a){for(var s=0;s<a.length;s++){var n=a[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(v,A(n.key),n)}}function b(v,a,s){return a&&U(v.prototype,a),s&&U(v,s),Object.defineProperty(v,"prototype",{writable:!1}),v}function A(v){var a=S(v,"string");return typeof a=="symbol"?a:String(a)}function S(v,a){if(typeof v!="object"||v===null)return v;var s=v[Symbol.toPrimitive];if(s!==void 0){var n=s.call(v,a||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(v)}function E(v,a){v.prototype=Object.create(a.prototype),v.prototype.constructor=v,x(v,a)}function x(v,a){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,d){return n.__proto__=d,n},x(v,a)}var f=function(v){E(a,v);function a(n){var d;return d=v.call(this,n,"[subtitle-track-controller]")||this,d.media=null,d.tracks=[],d.groupId=null,d.tracksInGroup=[],d.trackId=-1,d.selectDefaultTrack=!0,d.queuedDefaultTrack=-1,d.trackChangeListener=function(){return d.onTextTracksChanged()},d.asyncPollTrackChange=function(){return d.pollTrackChange(0)},d.useTextTrackPolling=!1,d.subtitlePollingInterval=-1,d._subtitleDisplay=!0,d.registerListeners(),d}var s=a.prototype;return s.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,v.prototype.destroy.call(this)},s.registerListeners=function(){var d=this.hls;d.on(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.on(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.on(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.on(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.on(O.Events.LEVEL_LOADING,this.onLevelLoading,this),d.on(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.on(O.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),d.on(O.Events.ERROR,this.onError,this)},s.unregisterListeners=function(){var d=this.hls;d.off(O.Events.MEDIA_ATTACHED,this.onMediaAttached,this),d.off(O.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(O.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(O.Events.MANIFEST_PARSED,this.onManifestParsed,this),d.off(O.Events.LEVEL_LOADING,this.onLevelLoading,this),d.off(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),d.off(O.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),d.off(O.Events.ERROR,this.onError,this)},s.onMediaAttached=function(d,l){this.media=l.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},s.pollTrackChange=function(d){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,d)},s.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var d=_(this.media.textTracks);d.forEach(function(l){(0,D.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null}},s.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},s.onManifestParsed=function(d,l){this.tracks=l.subtitleTracks},s.onSubtitleTrackLoaded=function(d,l){var i=l.id,u=l.details,g=this.trackId,c=this.tracksInGroup[g];if(!c){this.warn("Invalid subtitle track id "+i);return}var m=c.details;c.details=l.details,this.log("subtitle track "+i+" loaded ["+u.startSN+"-"+u.endSN+"]"),i===this.trackId&&(this.retryCount=0,this.playlistLoaded(i,l,m))},s.onLevelLoading=function(d,l){this.switchLevel(l.level)},s.onLevelSwitching=function(d,l){this.switchLevel(l.level)},s.switchLevel=function(d){var l=this.hls.levels[d];if(!!(l!=null&&l.textGroupIds)){var i=l.textGroupIds[l.urlId];if(this.groupId!==i){var u=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,g=this.tracks.filter(function(e){return!i||e.groupId===i});this.tracksInGroup=g;var c=this.findTrackId(u==null?void 0:u.name)||this.findTrackId();this.groupId=i;var m={subtitleTracks:g};this.log("Updating subtitle tracks, "+g.length+' track(s) found in "'+i+'" group-id'),this.hls.trigger(O.Events.SUBTITLE_TRACKS_UPDATED,m),c!==-1&&this.setSubtitleTrack(c,u)}}},s.findTrackId=function(d){for(var l=this.tracksInGroup,i=0;i<l.length;i++){var u=l[i];if((!this.selectDefaultTrack||u.default)&&(!d||d===u.name))return u.id}return-1},s.onError=function(d,l){v.prototype.onError.call(this,d,l),!(l.fatal||!l.context)&&l.context.type===P.PlaylistContextType.SUBTITLE_TRACK&&l.context.id===this.trackId&&l.context.groupId===this.groupId&&this.retryLoadingOrFail(l)},s.loadPlaylist=function(d){v.prototype.loadPlaylist.call(this);var l=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(l)){var i=l.id,u=l.groupId,g=l.url;if(d)try{g=d.addDirectives(g)}catch(c){this.warn("Could not construct new URL with HLS Delivery Directives: "+c)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(O.Events.SUBTITLE_TRACK_LOADING,{url:g,id:i,groupId:u,deliveryDirectives:d||null})}},s.toggleTrackModes=function(d){var l=this,i=this.media,u=this.trackId;if(!!i){var g=_(i.textTracks),c=g.filter(function(r){return r.groupId===l.groupId});if(d===-1)[].slice.call(g).forEach(function(r){r.mode="disabled"});else{var m=c[u];m&&(m.mode="disabled")}var e=c[d];e&&(e.mode=this.subtitleDisplay?"showing":"hidden")}},s.setSubtitleTrack=function(d,l){var i,u=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=d;return}if(this.trackId!==d&&this.toggleTrackModes(d),!(this.trackId===d&&(d===-1||(i=u[d])!==null&&i!==void 0&&i.details)||d<-1||d>=u.length)){this.clearTimer();var g=u[d];if(this.log("Switching to subtitle track "+d),this.trackId=d,g){var c=g.id,m=g.groupId,e=m===void 0?"":m,r=g.name,t=g.type,o=g.url;this.hls.trigger(O.Events.SUBTITLE_TRACK_SWITCH,{id:c,groupId:e,name:r,type:t,url:o});var y=this.switchParams(g.url,l==null?void 0:l.details);this.loadPlaylist(y)}else this.hls.trigger(O.Events.SUBTITLE_TRACK_SWITCH,{id:d})}},s.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var d=-1,l=_(this.media.textTracks),i=0;i<l.length;i++)if(l[i].mode==="hidden")d=i;else if(l[i].mode==="showing"){d=i;break}this.subtitleTrack!==d&&(this.subtitleTrack=d)}},b(a,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(d){this._subtitleDisplay=d,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(d){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(d,l)}}]),a}(M.default);function _(v){for(var a=[],s=0;s<v.length;s++){var n=v[s];n.kind==="subtitles"&&n.label&&a.push(v[s])}return a}let p=f},"./src/controller/timeline-controller.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{TimelineController:()=>f});var O=T("./src/polyfills/number.ts"),D=T("./src/events.ts"),M=T("./src/utils/cea-608-parser.ts"),P=T("./src/utils/output-filter.ts"),U=T("./src/utils/webvtt-parser.ts"),b=T("./src/utils/texttrack-utils.ts"),A=T("./src/utils/imsc1-ttml-parser.ts"),S=T("./src/utils/mp4-tools.ts"),E=T("./src/types/loader.ts"),x=T("./src/utils/logger.ts"),f=function(){function a(n){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=v(),this.captionsProperties=void 0,this.hls=n,this.config=n.config,this.Cues=n.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 d=new P.default(this,"textTrack1"),l=new P.default(this,"textTrack2"),i=new P.default(this,"textTrack3"),u=new P.default(this,"textTrack4");this.cea608Parser1=new M.default(1,d,l),this.cea608Parser2=new M.default(3,i,u)}n.on(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),n.on(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(D.Events.MANIFEST_LOADED,this.onManifestLoaded,this),n.on(D.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.on(D.Events.FRAG_LOADING,this.onFragLoading,this),n.on(D.Events.FRAG_LOADED,this.onFragLoaded,this),n.on(D.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),n.on(D.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),n.on(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(D.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),n.on(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var s=a.prototype;return s.destroy=function(){var d=this.hls;d.off(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),d.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),d.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),d.off(D.Events.MANIFEST_LOADED,this.onManifestLoaded,this),d.off(D.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),d.off(D.Events.FRAG_LOADING,this.onFragLoading,this),d.off(D.Events.FRAG_LOADED,this.onFragLoaded,this),d.off(D.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),d.off(D.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),d.off(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),d.off(D.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),d.off(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},s.addCues=function(d,l,i,u,g){for(var c=!1,m=g.length;m--;){var e=g[m],r=p(e[0],e[1],l,i);if(r>=0&&(e[0]=Math.min(e[0],l),e[1]=Math.max(e[1],i),c=!0,r/(i-l)>.5))return}if(c||g.push([l,i]),this.config.renderTextTracksNatively){var t=this.captionsTracks[d];this.Cues.newCue(t,l,i,u)}else{var o=this.Cues.newCue(null,l,i,u);this.hls.trigger(D.Events.CUES_PARSED,{type:"captions",cues:o,track:d})}},s.onInitPtsFound=function(d,l){var i=this,u=l.frag,g=l.id,c=l.initPTS,m=l.timescale,e=this.unparsedVttFrags;g==="main"&&(this.initPTS[u.cc]=c,this.timescale[u.cc]=m),e.length&&(this.unparsedVttFrags=[],e.forEach(function(r){i.onFragLoaded(D.Events.FRAG_LOADED,r)}))},s.getExistingTrack=function(d){var l=this.media;if(l)for(var i=0;i<l.textTracks.length;i++){var u=l.textTracks[i];if(u[d])return u}return null},s.createCaptionsTrack=function(d){this.config.renderTextTracksNatively?this.createNativeTrack(d):this.createNonNativeTrack(d)},s.createNativeTrack=function(d){if(!this.captionsTracks[d]){var l=this.captionsProperties,i=this.captionsTracks,u=this.media,g=l[d],c=g.label,m=g.languageCode,e=this.getExistingTrack(d);if(e)i[d]=e,(0,b.clearCurrentCues)(i[d]),(0,b.sendAddTrackEvent)(i[d],u);else{var r=this.createTextTrack("captions",c,m);r&&(r[d]=!0,i[d]=r)}}},s.createNonNativeTrack=function(d){if(!this.nonNativeCaptionsTracks[d]){var l=this.captionsProperties[d];if(!!l){var i=l.label,u={_id:d,label:i,kind:"captions",default:l.media?!!l.media.default:!1,closedCaptions:l.media};this.nonNativeCaptionsTracks[d]=u,this.hls.trigger(D.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[u]})}}},s.createTextTrack=function(d,l,i){var u=this.media;if(!!u)return u.addTextTrack(d,l,i)},s.onMediaAttaching=function(d,l){this.media=l.media,this._cleanTracks()},s.onMediaDetaching=function(){var d=this.captionsTracks;Object.keys(d).forEach(function(l){(0,b.clearCurrentCues)(d[l]),delete d[l]}),this.nonNativeCaptionsTracks={}},s.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=v(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},s._cleanTracks=function(){var d=this.media;if(!!d){var l=d.textTracks;if(l)for(var i=0;i<l.length;i++)(0,b.clearCurrentCues)(l[i])}},s.onSubtitleTracksUpdated=function(d,l){var i=this;this.textTracks=[];var u=l.subtitleTracks||[],g=u.some(function(r){return r.textCodec===A.IMSC1_CODEC});if(this.config.enableWebVTT||g&&this.config.enableIMSC1){var c=this.tracks&&u&&this.tracks.length===u.length;if(this.tracks=u||[],this.config.renderTextTracksNatively){var m=this.media?this.media.textTracks:[];this.tracks.forEach(function(r,t){var o;if(t<m.length){for(var y=null,h=0;h<m.length;h++)if(_(m[h],r)){y=m[h];break}y&&(o=y)}if(o)(0,b.clearCurrentCues)(o);else{var L=i._captionsOrSubtitlesFromCharacteristics(r);o=i.createTextTrack(L,r.name,r.lang),o&&(o.mode="disabled")}o&&(o.groupId=r.groupId,i.textTracks.push(o))})}else if(!c&&this.tracks&&this.tracks.length){var e=this.tracks.map(function(r){return{label:r.name,kind:r.type.toLowerCase(),default:r.default,subtitleTrack:r}});this.hls.trigger(D.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}},s._captionsOrSubtitlesFromCharacteristics=function(d){var l;if((l=d.attrs)!==null&&l!==void 0&&l.CHARACTERISTICS){var i=/transcribes-spoken-dialog/gi.test(d.attrs.CHARACTERISTICS),u=/describes-music-and-sound/gi.test(d.attrs.CHARACTERISTICS);if(i&&u)return"captions"}return"subtitles"},s.onManifestLoaded=function(d,l){var i=this;this.config.enableCEA708Captions&&l.captions&&l.captions.forEach(function(u){var g=/(?:CC|SERVICE)([1-4])/.exec(u.instreamId);if(!!g){var c="textTrack"+g[1],m=i.captionsProperties[c];!m||(m.label=u.name,u.lang&&(m.languageCode=u.lang),m.media=u)}})},s.closedCaptionsForLevel=function(d){var l=this.hls.levels[d.level];return l==null?void 0:l.attrs["CLOSED-CAPTIONS"]},s.onFragLoading=function(d,l){var i=this.cea608Parser1,u=this.cea608Parser2,g=this.lastSn,c=this.lastPartIndex;if(!(!this.enabled||!(i&&u))&&l.frag.type===E.PlaylistLevelType.MAIN){var m,e,r=l.frag.sn,t=(m=l==null||(e=l.part)===null||e===void 0?void 0:e.index)!=null?m:-1;r===g+1||r===g&&t===c+1||(i.reset(),u.reset()),this.lastSn=r,this.lastPartIndex=t}},s.onFragLoaded=function(d,l){var i=l.frag,u=l.payload,g=this.initPTS,c=this.unparsedVttFrags;if(i.type===E.PlaylistLevelType.SUBTITLE)if(u.byteLength){if(!(0,O.isFiniteNumber)(g[i.cc])){c.push(l),g.length&&this.hls.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")});return}var m=i.decryptdata,e="stats"in l;if(m==null||!m.encrypted||e){var r=this.tracks[i.level],t=this.vttCCs;t[i.cc]||(t[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),r&&r.textCodec===A.IMSC1_CODEC?this._parseIMSC1(i,u):this._parseVTTs(i,u,t)}}else this.hls.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},s._parseIMSC1=function(d,l){var i=this,u=this.hls;(0,A.parseIMSC1)(l,this.initPTS[d.cc],this.timescale[d.cc],function(g){i._appendCues(g,d.level),u.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(g){x.logger.log("Failed to parse IMSC1: "+g),u.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:g})})},s._parseVTTs=function(d,l,i){var u,g=this,c=this.hls,m=(u=d.initSegment)!==null&&u!==void 0&&u.data?(0,S.appendUint8Array)(d.initSegment.data,new Uint8Array(l)):l;(0,U.parseWebVTT)(m,this.initPTS[d.cc],this.timescale[d.cc],i,d.cc,d.start,function(e){g._appendCues(e,d.level),c.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:d})},function(e){g._fallbackToIMSC1(d,l),x.logger.log("Failed to parse VTT cue: "+e),c.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:d,error:e})})},s._fallbackToIMSC1=function(d,l){var i=this,u=this.tracks[d.level];u.textCodec||(0,A.parseIMSC1)(l,this.initPTS[d.cc],this.timescale[d.cc],function(){u.textCodec=A.IMSC1_CODEC,i._parseIMSC1(d,l)},function(){u.textCodec="wvtt"})},s._appendCues=function(d,l){var i=this.hls;if(this.config.renderTextTracksNatively){var u=this.textTracks[l];if(!u||u.mode==="disabled")return;d.forEach(function(m){return(0,b.addCueToTrack)(u,m)})}else{var g=this.tracks[l];if(!g)return;var c=g.default?"default":"subtitles"+l;i.trigger(D.Events.CUES_PARSED,{type:"subtitles",cues:d,track:c})}},s.onFragDecrypted=function(d,l){var i=l.frag;if(i.type===E.PlaylistLevelType.SUBTITLE){if(!(0,O.isFiniteNumber)(this.initPTS[i.cc])){this.unparsedVttFrags.push(l);return}this.onFragLoaded(D.Events.FRAG_LOADED,l)}},s.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},s.onFragParsingUserdata=function(d,l){var i=this.cea608Parser1,u=this.cea608Parser2;if(!(!this.enabled||!(i&&u))){var g=l.frag,c=l.samples;if(!(g.type===E.PlaylistLevelType.MAIN&&this.closedCaptionsForLevel(g)==="NONE"))for(var m=0;m<c.length;m++){var e=c[m].bytes;if(e){var r=this.extractCea608Data(e);i.addData(c[m].pts,r[0]),u.addData(c[m].pts,r[1])}}}},s.onBufferFlushing=function(d,l){var i=l.startOffset,u=l.endOffset,g=l.endOffsetSubtitles,c=l.type,m=this.media;if(!(!m||m.currentTime<u)){if(!c||c==="video"){var e=this.captionsTracks;Object.keys(e).forEach(function(t){return(0,b.removeCuesInRange)(e[t],i,u)})}if(this.config.renderTextTracksNatively&&i===0&&g!==void 0){var r=this.textTracks;Object.keys(r).forEach(function(t){return(0,b.removeCuesInRange)(r[t],i,g)})}}},s.extractCea608Data=function(d){for(var l=[[],[]],i=d[0]&31,u=2,g=0;g<i;g++){var c=d[u++],m=127&d[u++],e=127&d[u++];if(!(m===0&&e===0)){var r=(4&c)!==0;if(r){var t=3&c;(t===0||t===1)&&(l[t].push(m),l[t].push(e))}}}return l},a}();function _(a,s){return a&&a.label===s.name&&!(a.textTrack1||a.textTrack2)}function p(a,s,n,d){return Math.min(s,d)-Math.max(a,n)}function v(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});var O=function(){function D(P,U){this.subtle=void 0,this.aesIV=void 0,this.subtle=P,this.aesIV=U}var M=D.prototype;return M.decrypt=function(U,b){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},b,U)},D}()},"./src/crypt/aes-decryptor.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>M,removePadding:()=>D});var O=T("./src/utils/typed-array.ts");function D(P){var U=P.byteLength,b=U&&new DataView(P.buffer).getUint8(U-1);return b?(0,O.sliceUint8)(P,0,U-b):P}var M=function(){function P(){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 U=P.prototype;return U.uint8ArrayToUint32Array_=function(A){for(var S=new DataView(A),E=new Uint32Array(4),x=0;x<4;x++)E[x]=S.getUint32(x*4);return E},U.initTable=function(){var A=this.sBox,S=this.invSBox,E=this.subMix,x=E[0],f=E[1],_=E[2],p=E[3],v=this.invSubMix,a=v[0],s=v[1],n=v[2],d=v[3],l=new Uint32Array(256),i=0,u=0,g=0;for(g=0;g<256;g++)g<128?l[g]=g<<1:l[g]=g<<1^283;for(g=0;g<256;g++){var c=u^u<<1^u<<2^u<<3^u<<4;c=c>>>8^c&255^99,A[i]=c,S[c]=i;var m=l[i],e=l[m],r=l[e],t=l[c]*257^c*16843008;x[i]=t<<24|t>>>8,f[i]=t<<16|t>>>16,_[i]=t<<8|t>>>24,p[i]=t,t=r*16843009^e*65537^m*257^i*16843008,a[c]=t<<24|t>>>8,s[c]=t<<16|t>>>16,n[c]=t<<8|t>>>24,d[c]=t,i?(i=m^l[l[l[r^m]]],u^=l[l[u]]):i=u=1}},U.expandKey=function(A){for(var S=this.uint8ArrayToUint32Array_(A),E=!0,x=0;x<S.length&&E;)E=S[x]===this.key[x],x++;if(!E){this.key=S;var f=this.keySize=S.length;if(f!==4&&f!==6&&f!==8)throw new Error("Invalid aes key size="+f);var _=this.ksRows=(f+6+1)*4,p,v,a=this.keySchedule=new Uint32Array(_),s=this.invKeySchedule=new Uint32Array(_),n=this.sBox,d=this.rcon,l=this.invSubMix,i=l[0],u=l[1],g=l[2],c=l[3],m,e;for(p=0;p<_;p++){if(p<f){m=a[p]=S[p];continue}e=m,p%f===0?(e=e<<8|e>>>24,e=n[e>>>24]<<24|n[e>>>16&255]<<16|n[e>>>8&255]<<8|n[e&255],e^=d[p/f|0]<<24):f>6&&p%f===4&&(e=n[e>>>24]<<24|n[e>>>16&255]<<16|n[e>>>8&255]<<8|n[e&255]),a[p]=m=(a[p-f]^e)>>>0}for(v=0;v<_;v++)p=_-v,v&3?e=a[p]:e=a[p-4],v<4||p<=4?s[v]=e:s[v]=i[n[e>>>24]]^u[n[e>>>16&255]]^g[n[e>>>8&255]]^c[n[e&255]],s[v]=s[v]>>>0}},U.networkToHostOrderSwap=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},U.decrypt=function(A,S,E){for(var x=this.keySize+6,f=this.invKeySchedule,_=this.invSBox,p=this.invSubMix,v=p[0],a=p[1],s=p[2],n=p[3],d=this.uint8ArrayToUint32Array_(E),l=d[0],i=d[1],u=d[2],g=d[3],c=new Int32Array(A),m=new Int32Array(c.length),e,r,t,o,y,h,L,R,I,k,F,W,K,H,Y=this.networkToHostOrderSwap;S<c.length;){for(I=Y(c[S]),k=Y(c[S+1]),F=Y(c[S+2]),W=Y(c[S+3]),y=I^f[0],h=W^f[1],L=F^f[2],R=k^f[3],K=4,H=1;H<x;H++)e=v[y>>>24]^a[h>>16&255]^s[L>>8&255]^n[R&255]^f[K],r=v[h>>>24]^a[L>>16&255]^s[R>>8&255]^n[y&255]^f[K+1],t=v[L>>>24]^a[R>>16&255]^s[y>>8&255]^n[h&255]^f[K+2],o=v[R>>>24]^a[y>>16&255]^s[h>>8&255]^n[L&255]^f[K+3],y=e,h=r,L=t,R=o,K=K+4;e=_[y>>>24]<<24^_[h>>16&255]<<16^_[L>>8&255]<<8^_[R&255]^f[K],r=_[h>>>24]<<24^_[L>>16&255]<<16^_[R>>8&255]<<8^_[y&255]^f[K+1],t=_[L>>>24]<<24^_[R>>16&255]<<16^_[y>>8&255]<<8^_[h&255]^f[K+2],o=_[R>>>24]<<24^_[y>>16&255]<<16^_[h>>8&255]<<8^_[L&255]^f[K+3],m[S]=Y(e^l),m[S+1]=Y(o^i),m[S+2]=Y(t^u),m[S+3]=Y(r^g),l=I,i=k,u=F,g=W,S=S+4}return m.buffer},P}()},"./src/crypt/decrypter.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>S});var O=T("./src/crypt/aes-crypto.ts"),D=T("./src/crypt/fast-aes-key.ts"),M=T("./src/crypt/aes-decryptor.ts"),P=T("./src/utils/logger.ts"),U=T("./src/utils/mp4-tools.ts"),b=T("./src/utils/typed-array.ts"),A=16,S=function(){function E(f,_){var p=_===void 0?{}:_,v=p.removePKCS7Padding,a=v===void 0?!0:v;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=f.enableSoftwareAES,this.removePKCS7Padding=a,a)try{var s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var x=E.prototype;return x.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},x.isSync=function(){return this.useSoftware},x.flush=function(){var _=this.currentResult,p=this.remainderData;if(!_||p)return P.logger.error("[softwareDecrypt] "+(p?"overflow bytes: "+p.byteLength:"no result")),this.reset(),null;var v=new Uint8Array(_);return this.reset(),this.removePKCS7Padding?(0,M.removePadding)(v):v},x.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},x.decrypt=function(_,p,v){var a=this;return this.useSoftware?new Promise(function(s,n){a.softwareDecrypt(new Uint8Array(_),p,v);var d=a.flush();d?s(d.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(_),p,v)},x.softwareDecrypt=function(_,p,v){var a=this.currentIV,s=this.currentResult,n=this.remainderData;this.logOnce("JS AES decrypt"),n&&(_=(0,U.appendUint8Array)(n,_),this.remainderData=null);var d=this.getValidChunk(_);if(!d.length)return null;a&&(v=a);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new M.default),l.expandKey(p);var i=s;return this.currentResult=l.decrypt(d.buffer,0,v),this.currentIV=(0,b.sliceUint8)(d,-16).buffer,i||null},x.webCryptoDecrypt=function(_,p,v){var a=this,s=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new D.default(s,p)),this.fastAesKey.expandKey().then(function(n){if(!s)return Promise.reject(new Error("web crypto not initialized"));a.logOnce("WebCrypto AES decrypt");var d=new O.default(s,new Uint8Array(v));return d.decrypt(_.buffer,n)}).catch(function(n){return P.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),a.onWebCryptoError(_,p,v)})},x.onWebCryptoError=function(_,p,v){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(_,p,v);var a=this.flush();if(a)return a.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},x.getValidChunk=function(_){var p=_,v=_.length-_.length%A;return v!==_.length&&(p=(0,b.sliceUint8)(_,0,v),this.remainderData=(0,b.sliceUint8)(_,v)),p},x.logOnce=function(_){!this.logEnabled||(P.logger.log("[decrypter]: "+_),this.logEnabled=!1)},E}()},"./src/crypt/fast-aes-key.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});var O=function(){function D(P,U){this.subtle=void 0,this.key=void 0,this.subtle=P,this.key=U}var M=D.prototype;return M.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},D}()},"./src/demux/aacdemuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>S});var O=T("./src/demux/base-audio-demuxer.ts"),D=T("./src/demux/adts.ts"),M=T("./src/utils/logger.ts"),P=T("./src/demux/id3.ts");function U(E,x){E.prototype=Object.create(x.prototype),E.prototype.constructor=E,b(E,x)}function b(E,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(_,p){return _.__proto__=p,_},b(E,x)}var A=function(E){U(x,E);function x(_,p){var v;return v=E.call(this)||this,v.observer=void 0,v.config=void 0,v.observer=_,v.config=p,v}var f=x.prototype;return f.resetInitSegment=function(p,v,a,s){E.prototype.resetInitSegment.call(this,p,v,a,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:v,duration:s,inputTimeScale:9e4,dropped:0}},x.probe=function(p){if(!p)return!1;for(var v=P.getID3Data(p,0)||[],a=v.length,s=p.length;a<s;a++)if(D.probe(p,a))return M.logger.log("ADTS sync word found !"),!0;return!1},f.canParse=function(p,v){return D.canParse(p,v)},f.appendFrame=function(p,v,a){D.initTrackConfig(p,this.observer,v,a,p.manifestCodec);var s=D.appendFrame(p,v,a,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s},x}(O.default);let S=A},"./src/demux/adts.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{appendFrame:()=>a,canGetFrameLength:()=>S,canParse:()=>x,getAudioConfig:()=>P,getFrameDuration:()=>p,getFullFrameLength:()=>A,getHeaderLength:()=>b,initTrackConfig:()=>_,isHeader:()=>E,isHeaderPattern:()=>U,parseFrameHeader:()=>v,probe:()=>f});var O=T("./src/utils/logger.ts"),D=T("./src/errors.ts"),M=T("./src/events.ts");function P(s,n,d,l){var i,u,g,c,m=navigator.userAgent.toLowerCase(),e=l,r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];i=((n[d+2]&192)>>>6)+1;var t=(n[d+2]&60)>>>2;if(t>r.length-1){s.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+t});return}return g=(n[d+2]&1)<<2,g|=(n[d+3]&192)>>>6,O.logger.log("manifest codec:"+l+", ADTS type:"+i+", samplingIndex:"+t),/firefox/i.test(m)?t>=6?(i=5,c=new Array(4),u=t-3):(i=2,c=new Array(2),u=t):m.indexOf("android")!==-1?(i=2,c=new Array(2),u=t):(i=5,c=new Array(4),l&&(l.indexOf("mp4a.40.29")!==-1||l.indexOf("mp4a.40.5")!==-1)||!l&&t>=6?u=t-3:((l&&l.indexOf("mp4a.40.2")!==-1&&(t>=6&&g===1||/vivaldi/i.test(m))||!l&&g===1)&&(i=2,c=new Array(2)),u=t)),c[0]=i<<3,c[0]|=(t&14)>>1,c[1]|=(t&1)<<7,c[1]|=g<<3,i===5&&(c[1]|=(u&14)>>1,c[2]=(u&1)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:r[t],channelCount:g,codec:"mp4a.40."+i,manifestCodec:e}}function U(s,n){return s[n]===255&&(s[n+1]&246)===240}function b(s,n){return s[n+1]&1?7:9}function A(s,n){return(s[n+3]&3)<<11|s[n+4]<<3|(s[n+5]&224)>>>5}function S(s,n){return n+5<s.length}function E(s,n){return n+1<s.length&&U(s,n)}function x(s,n){return S(s,n)&&U(s,n)&&A(s,n)<=s.length-n}function f(s,n){if(E(s,n)){var d=b(s,n);if(n+d>=s.length)return!1;var l=A(s,n);if(l<=d)return!1;var i=n+l;return i===s.length||E(s,i)}return!1}function _(s,n,d,l,i){if(!s.samplerate){var u=P(n,d,l,i);if(!u)return;s.config=u.config,s.samplerate=u.samplerate,s.channelCount=u.channelCount,s.codec=u.codec,s.manifestCodec=u.manifestCodec,O.logger.log("parsed codec:"+s.codec+", rate:"+u.samplerate+", channels:"+u.channelCount)}}function p(s){return 9216e4/s}function v(s,n){var d=b(s,n);if(n+d<=s.length){var l=A(s,n)-d;if(l>0)return{headerLength:d,frameLength:l}}}function a(s,n,d,l,i){var u=p(s.samplerate),g=l+i*u,c=v(n,d),m;if(c){var e=c.frameLength,r=c.headerLength,t=r+e,o=Math.max(0,d+t-n.length);o?(m=new Uint8Array(t-r),m.set(n.subarray(d+r,n.length),0)):m=n.subarray(d+r,d+t);var y={unit:m,pts:g};return o||s.samples.push(y),{sample:y,length:t,missing:o}}var h=n.length-d;m=new Uint8Array(h),m.set(n.subarray(d,n.length),0);var L={unit:m,pts:g};return{sample:L,length:h,missing:-1}}},"./src/demux/base-audio-demuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>E,initPTSFn:()=>S});var O=T("./src/polyfills/number.ts"),D=T("./src/demux/id3.ts"),M=T("./src/types/demuxer.ts"),P=T("./src/demux/dummy-demuxed-track.ts"),U=T("./src/utils/mp4-tools.ts"),b=T("./src/utils/typed-array.ts"),A=function(){function x(){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=x.prototype;return f.resetInitSegment=function(p,v,a,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},f.resetTimeStamp=function(p){this.initPTS=p,this.resetContiguity()},f.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},f.canParse=function(p,v){return!1},f.appendFrame=function(p,v,a){},f.demux=function(p,v){this.cachedData&&(p=(0,U.appendUint8Array)(this.cachedData,p),this.cachedData=null);var a=D.getID3Data(p,0),s=a?a.length:0,n,d=this._audioTrack,l=this._id3Track,i=a?D.getTimeStamp(a):void 0,u=p.length;for((this.basePTS===null||this.frameIndex===0&&(0,O.isFiniteNumber)(i))&&(this.basePTS=S(i,v,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),a&&a.length>0&&l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:M.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});s<u;){if(this.canParse(p,s)){var g=this.appendFrame(d,p,s);g?(this.frameIndex++,this.lastPTS=g.sample.pts,s+=g.length,n=s):s=u}else D.canParse(p,s)?(a=D.getID3Data(p,s),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:M.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),s+=a.length,n=s):s++;if(s===u&&n!==u){var c=(0,b.sliceUint8)(p,n);this.cachedData?this.cachedData=(0,U.appendUint8Array)(this.cachedData,c):this.cachedData=c}}return{audioTrack:d,videoTrack:(0,P.dummyTrack)(),id3Track:l,textTrack:(0,P.dummyTrack)()}},f.demuxSampleAes=function(p,v,a){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},f.flush=function(p){var v=this.cachedData;return v&&(this.cachedData=null,this.demux(v,0)),{audioTrack:this._audioTrack,videoTrack:(0,P.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,P.dummyTrack)()}},f.destroy=function(){},x}(),S=function(f,_,p){return(0,O.isFiniteNumber)(f)?f*90:_*9e4+(p||0)};let E=A},"./src/demux/chunk-cache.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});var O=function(){function M(){this.chunks=[],this.dataLength=0}var P=M.prototype;return P.push=function(b){this.chunks.push(b),this.dataLength+=b.length},P.flush=function(){var b=this.chunks,A=this.dataLength,S;if(b.length)b.length===1?S=b[0]:S=D(b,A);else return new Uint8Array(0);return this.reset(),S},P.reset=function(){this.chunks.length=0,this.dataLength=0},M}();function D(M,P){for(var U=new Uint8Array(P),b=0,A=0;A<M.length;A++){var S=M[A];U.set(S,b),b+=S.length}return U}},"./src/demux/dummy-demuxed-track.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{dummyTrack:()=>O});function O(D,M){return D===void 0&&(D=""),M===void 0&&(M=9e4),{type:D,id:-1,pid:-1,inputTimeScale:M,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>M});var O=T("./src/utils/logger.ts"),D=function(){function P(b){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=b,this.bytesAvailable=b.byteLength,this.word=0,this.bitsAvailable=0}var U=P.prototype;return U.loadWord=function(){var A=this.data,S=this.bytesAvailable,E=A.byteLength-S,x=new Uint8Array(4),f=Math.min(4,S);if(f===0)throw new Error("no bytes available");x.set(A.subarray(E,E+f)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=f*8,this.bytesAvailable-=f},U.skipBits=function(A){var S;A=Math.min(A,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>A?(this.word<<=A,this.bitsAvailable-=A):(A-=this.bitsAvailable,S=A>>3,A-=S<<3,this.bytesAvailable-=S,this.loadWord(),this.word<<=A,this.bitsAvailable-=A)},U.readBits=function(A){var S=Math.min(this.bitsAvailable,A),E=this.word>>>32-S;if(A>32&&O.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=S,this.bitsAvailable>0)this.word<<=S;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return S=A-S,S>0&&this.bitsAvailable?E<<S|this.readBits(S):E},U.skipLZ=function(){var A;for(A=0;A<this.bitsAvailable;++A)if((this.word&2147483648>>>A)!==0)return this.word<<=A,this.bitsAvailable-=A,A;return this.loadWord(),A+this.skipLZ()},U.skipUEG=function(){this.skipBits(1+this.skipLZ())},U.skipEG=function(){this.skipBits(1+this.skipLZ())},U.readUEG=function(){var A=this.skipLZ();return this.readBits(A+1)-1},U.readEG=function(){var A=this.readUEG();return 1&A?1+A>>>1:-1*(A>>>1)},U.readBoolean=function(){return this.readBits(1)===1},U.readUByte=function(){return this.readBits(8)},U.readUShort=function(){return this.readBits(16)},U.readUInt=function(){return this.readBits(32)},U.skipScalingList=function(A){for(var S=8,E=8,x,f=0;f<A;f++)E!==0&&(x=this.readEG(),E=(S+x+256)%256),S=E===0?S:E},U.readSPS=function(){var A=0,S=0,E=0,x=0,f,_,p,v=this.readUByte.bind(this),a=this.readBits.bind(this),s=this.readUEG.bind(this),n=this.readBoolean.bind(this),d=this.skipBits.bind(this),l=this.skipEG.bind(this),i=this.skipUEG.bind(this),u=this.skipScalingList.bind(this);v();var g=v();if(a(5),d(3),v(),i(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){var c=s();if(c===3&&d(1),i(),i(),d(1),n())for(_=c!==3?8:12,p=0;p<_;p++)n()&&(p<6?u(16):u(64))}i();var m=s();if(m===0)s();else if(m===1)for(d(1),l(),l(),f=s(),p=0;p<f;p++)l();i(),d(1);var e=s(),r=s(),t=a(1);t===0&&d(1),d(1),n()&&(A=s(),S=s(),E=s(),x=s());var o=[1,1];if(n()&&n()){var y=v();switch(y){case 1:o=[1,1];break;case 2:o=[12,11];break;case 3:o=[10,11];break;case 4:o=[16,11];break;case 5:o=[40,33];break;case 6:o=[24,11];break;case 7:o=[20,11];break;case 8:o=[32,11];break;case 9:o=[80,33];break;case 10:o=[18,11];break;case 11:o=[15,11];break;case 12:o=[64,33];break;case 13:o=[160,99];break;case 14:o=[4,3];break;case 15:o=[3,2];break;case 16:o=[2,1];break;case 255:{o=[v()<<8|v(),v()<<8|v()];break}}}return{width:Math.ceil((e+1)*16-A*2-S*2),height:(2-t)*(r+1)*16-(t?2:4)*(E+x),pixelRatio:o}},U.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},P}();let M=D},"./src/demux/id3.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{canParse:()=>U,decodeFrame:()=>x,getID3Data:()=>M,getID3Frames:()=>E,getTimeStamp:()=>b,isFooter:()=>D,isHeader:()=>O,isTimeStampFrame:()=>A,testables:()=>s,utf8ArrayToStr:()=>a});var O=function(i,u){return u+10<=i.length&&i[u]===73&&i[u+1]===68&&i[u+2]===51&&i[u+3]<255&&i[u+4]<255&&i[u+6]<128&&i[u+7]<128&&i[u+8]<128&&i[u+9]<128},D=function(i,u){return u+10<=i.length&&i[u]===51&&i[u+1]===68&&i[u+2]===73&&i[u+3]<255&&i[u+4]<255&&i[u+6]<128&&i[u+7]<128&&i[u+8]<128&&i[u+9]<128},M=function(i,u){for(var g=u,c=0;O(i,u);){c+=10;var m=P(i,u+6);c+=m,D(i,u+10)&&(c+=10),u+=c}if(c>0)return i.subarray(g,g+c)},P=function(i,u){var g=0;return g=(i[u]&127)<<21,g|=(i[u+1]&127)<<14,g|=(i[u+2]&127)<<7,g|=i[u+3]&127,g},U=function(i,u){return O(i,u)&&P(i,u+6)+10<=i.length-u},b=function(i){for(var u=E(i),g=0;g<u.length;g++){var c=u[g];if(A(c))return v(c)}},A=function(i){return i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp"},S=function(i){var u=String.fromCharCode(i[0],i[1],i[2],i[3]),g=P(i,4),c=10;return{type:u,size:g,data:i.subarray(c,c+g)}},E=function(i){for(var u=0,g=[];O(i,u);){var c=P(i,u+6);u+=10;for(var m=u+c;u+8<m;){var e=S(i.subarray(u)),r=x(e);r&&g.push(r),u+=e.size+10}D(i,u)&&(u+=10)}return g},x=function(i){return i.type==="PRIV"?f(i):i.type[0]==="W"?p(i):_(i)},f=function(i){if(!(i.size<2)){var u=a(i.data,!0),g=new Uint8Array(i.data.subarray(u.length+1));return{key:i.type,info:u,data:g.buffer}}},_=function(i){if(!(i.size<2)){if(i.type==="TXXX"){var u=1,g=a(i.data.subarray(u),!0);u+=g.length+1;var c=a(i.data.subarray(u));return{key:i.type,info:g,data:c}}var m=a(i.data.subarray(1));return{key:i.type,data:m}}},p=function(i){if(i.type==="WXXX"){if(i.size<2)return;var u=1,g=a(i.data.subarray(u),!0);u+=g.length+1;var c=a(i.data.subarray(u));return{key:i.type,info:g,data:c}}var m=a(i.data);return{key:i.type,data:m}},v=function(i){if(i.data.byteLength===8){var u=new Uint8Array(i.data),g=u[3]&1,c=(u[4]<<23)+(u[5]<<15)+(u[6]<<7)+u[7];return c/=45,g&&(c+=4772185884e-2),Math.round(c)}},a=function(i,u){u===void 0&&(u=!1);var g=d();if(g){var c=g.decode(i);if(u){var m=c.indexOf("\0");return m!==-1?c.substring(0,m):c}return c.replace(/\0/g,"")}for(var e=i.length,r,t,o,y="",h=0;h<e;){if(r=i[h++],r===0&&u)return y;if(r===0||r===3)continue;switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:y+=String.fromCharCode(r);break;case 12:case 13:t=i[h++],y+=String.fromCharCode((r&31)<<6|t&63);break;case 14:t=i[h++],o=i[h++],y+=String.fromCharCode((r&15)<<12|(t&63)<<6|(o&63)<<0);break;default:}}return y},s={decodeTextFrame:_},n;function d(){return!n&&typeof self.TextDecoder!="undefined"&&(n=new self.TextDecoder("utf-8")),n}},"./src/demux/mp3demuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>S});var O=T("./src/demux/base-audio-demuxer.ts"),D=T("./src/demux/id3.ts"),M=T("./src/utils/logger.ts"),P=T("./src/demux/mpegaudio.ts");function U(E,x){E.prototype=Object.create(x.prototype),E.prototype.constructor=E,b(E,x)}function b(E,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(_,p){return _.__proto__=p,_},b(E,x)}var A=function(E){U(x,E);function x(){return E.apply(this,arguments)||this}var f=x.prototype;return f.resetInitSegment=function(p,v,a,s){E.prototype.resetInitSegment.call(this,p,v,a,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:v,duration:s,inputTimeScale:9e4,dropped:0}},x.probe=function(p){if(!p)return!1;for(var v=D.getID3Data(p,0)||[],a=v.length,s=p.length;a<s;a++)if(P.probe(p,a))return M.logger.log("MPEG Audio sync word found !"),!0;return!1},f.canParse=function(p,v){return P.canParse(p,v)},f.appendFrame=function(p,v,a){if(this.basePTS!==null)return P.appendFrame(p,v,a,this.basePTS,this.frameIndex)},x}(O.default);let S=A},"./src/demux/mp4demuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>A});var O=T("./src/polyfills/number.ts"),D=T("./src/types/demuxer.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/demux/dummy-demuxed-track.ts"),U=/\/emsg[-/]ID3/i,b=function(){function S(x,f){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=f}var E=S.prototype;return E.resetTimeStamp=function(){},E.resetInitSegment=function(f,_,p,v){var a=this.videoTrack=(0,P.dummyTrack)("video",1),s=this.audioTrack=(0,P.dummyTrack)("audio",1),n=this.txtTrack=(0,P.dummyTrack)("text",1);if(this.id3Track=(0,P.dummyTrack)("id3",1),this.timeOffset=0,!(!f||!f.byteLength)){var d=(0,M.parseInitSegment)(f);if(d.video){var l=d.video,i=l.id,u=l.timescale,g=l.codec;a.id=i,a.timescale=n.timescale=u,a.codec=g}if(d.audio){var c=d.audio,m=c.id,e=c.timescale,r=c.codec;s.id=m,s.timescale=e,s.codec=r}n.id=M.RemuxerTrackIdConfig.text,a.sampleDuration=0,a.duration=s.duration=v}},E.resetContiguity=function(){},S.probe=function(f){return f=f.length>16384?f.subarray(0,16384):f,(0,M.findBox)(f,["moof"]).length>0},E.demux=function(f,_){this.timeOffset=_;var p=f,v=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(p=(0,M.appendUint8Array)(this.remainderData,f));var s=(0,M.segmentValidRange)(p);this.remainderData=s.remainder,v.samples=s.valid||new Uint8Array}else v.samples=p;var n=this.extractID3Track(v,_);return a.samples=(0,M.parseSamples)(_,v),{videoTrack:v,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}},E.flush=function(){var f=this.timeOffset,_=this.videoTrack,p=this.txtTrack;_.samples=this.remainderData||new Uint8Array,this.remainderData=null;var v=this.extractID3Track(_,this.timeOffset);return p.samples=(0,M.parseSamples)(f,_),{videoTrack:_,audioTrack:(0,P.dummyTrack)(),id3Track:v,textTrack:(0,P.dummyTrack)()}},E.extractID3Track=function(f,_){var p=this.id3Track;if(f.samples.length){var v=(0,M.findBox)(f.samples,["emsg"]);v&&v.forEach(function(a){var s=(0,M.parseEmsg)(a);if(U.test(s.schemeIdUri)){var n=(0,O.isFiniteNumber)(s.presentationTime)?s.presentationTime/s.timeScale:_+s.presentationTimeDelta/s.timeScale,d=s.eventDuration===4294967295?Number.POSITIVE_INFINITY:s.eventDuration/s.timeScale;d<=.001&&(d=Number.POSITIVE_INFINITY);var l=s.payload;p.samples.push({data:l,len:l.byteLength,dts:n,pts:n,type:D.MetadataSchema.emsg,duration:d})}})}return p},E.demuxSampleAes=function(f,_,p){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},E.destroy=function(){},S}();let A=b},"./src/demux/mpegaudio.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{appendFrame:()=>b,canParse:()=>x,isHeader:()=>E,isHeaderPattern:()=>S,parseHeader:()=>A,probe:()=>f});var O=null,D=[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],M=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],P=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],U=[0,1,1,4];function b(_,p,v,a,s){if(!(v+24>p.length)){var n=A(p,v);if(n&&v+n.frameLength<=p.length){var d=n.samplesPerFrame*9e4/n.sampleRate,l=a+s*d,i={unit:p.subarray(v,v+n.frameLength),pts:l,dts:l};return _.config=[],_.channelCount=n.channelCount,_.samplerate=n.sampleRate,_.samples.push(i),{sample:i,length:n.frameLength,missing:0}}}}function A(_,p){var v=_[p+1]>>3&3,a=_[p+1]>>1&3,s=_[p+2]>>4&15,n=_[p+2]>>2&3;if(v!==1&&s!==0&&s!==15&&n!==3){var d=_[p+2]>>1&1,l=_[p+3]>>6,i=v===3?3-a:a===3?3:4,u=D[i*14+s-1]*1e3,g=v===3?0:v===2?1:2,c=M[g*3+n],m=l===3?1:2,e=P[v][a],r=U[a],t=e*8*r,o=Math.floor(e*u/c+d)*r;if(O===null){var y=navigator.userAgent||"",h=y.match(/Chrome\/(\d+)/i);O=h?parseInt(h[1]):0}var L=!!O&&O<=87;return L&&a===2&&u>=224e3&&l===0&&(_[p+3]=_[p+3]|128),{sampleRate:c,channelCount:m,frameLength:o,samplesPerFrame:t}}}function S(_,p){return _[p]===255&&(_[p+1]&224)===224&&(_[p+1]&6)!==0}function E(_,p){return p+1<_.length&&S(_,p)}function x(_,p){var v=4;return S(_,p)&&v<=_.length-p}function f(_,p){if(p+1<_.length&&S(_,p)){var v=4,a=A(_,p),s=v;a!=null&&a.frameLength&&(s=a.frameLength);var n=p+s;return n===_.length||E(_,n)}return!1}},"./src/demux/sample-aes.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>P});var O=T("./src/crypt/decrypter.ts"),D=T("./src/utils/mp4-tools.ts"),M=function(){function U(A,S,E){this.keyData=void 0,this.decrypter=void 0,this.keyData=E,this.decrypter=new O.default(S,{removePKCS7Padding:!1})}var b=U.prototype;return b.decryptBuffer=function(S){return this.decrypter.decrypt(S,this.keyData.key.buffer,this.keyData.iv.buffer)},b.decryptAacSample=function(S,E,x){var f=this,_=S[E].unit;if(!(_.length<=16)){var p=_.subarray(16,_.length-_.length%16),v=p.buffer.slice(p.byteOffset,p.byteOffset+p.length);this.decryptBuffer(v).then(function(a){var s=new Uint8Array(a);_.set(s,16),f.decrypter.isSync()||f.decryptAacSamples(S,E+1,x)})}},b.decryptAacSamples=function(S,E,x){for(;;E++){if(E>=S.length){x();return}if(!(S[E].unit.length<32)&&(this.decryptAacSample(S,E,x),!this.decrypter.isSync()))return}},b.getAvcEncryptedData=function(S){for(var E=Math.floor((S.length-48)/160)*16+16,x=new Int8Array(E),f=0,_=32;_<S.length-16;_+=160,f+=16)x.set(S.subarray(_,_+16),f);return x},b.getAvcDecryptedUnit=function(S,E){for(var x=new Uint8Array(E),f=0,_=32;_<S.length-16;_+=160,f+=16)S.set(x.subarray(f,f+16),_);return S},b.decryptAvcSample=function(S,E,x,f,_){var p=this,v=(0,D.discardEPB)(_.data),a=this.getAvcEncryptedData(v);this.decryptBuffer(a.buffer).then(function(s){_.data=p.getAvcDecryptedUnit(v,s),p.decrypter.isSync()||p.decryptAvcSamples(S,E,x+1,f)})},b.decryptAvcSamples=function(S,E,x,f){if(S instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;E++,x=0){if(E>=S.length){f();return}for(var _=S[E].units;!(x>=_.length);x++){var p=_[x];if(!(p.data.length<=48||p.type!==1&&p.type!==5)&&(this.decryptAvcSample(S,E,x,f,p),!this.decrypter.isSync()))return}}},U}();let P=M},"./src/demux/transmuxer-interface.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>x});var O=T("./src/demux/webworkify-webpack.js"),D=T("./src/events.ts"),M=T("./src/demux/transmuxer.ts"),P=T("./src/utils/logger.ts"),U=T("./src/errors.ts"),b=T("./src/utils/mediasource-helper.ts"),A=T("./node_modules/eventemitter3/index.js"),S=T.n(A),E=(0,b.getMediaSource)()||{isTypeSupported:function(){return!1}},x=function(){function f(p,v,a,s){var n=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 d=p.config;this.hls=p,this.id=v,this.useWorker=!!d.enableWorker,this.onTransmuxComplete=a,this.onFlush=s;var l=function(m,e){e=e||{},e.frag=n.frag,e.id=n.id,n.hls.trigger(m,e)};this.observer=new A.EventEmitter,this.observer.on(D.Events.FRAG_DECRYPTED,l),this.observer.on(D.Events.ERROR,l);var i={mp4:E.isTypeSupported("video/mp4"),mpeg:E.isTypeSupported("audio/mpeg"),mp3:E.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"){P.logger.log("demuxing in webworker");var g;try{g=this.worker=(0,O.default)("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),g.addEventListener("message",this.onwmsg),g.onerror=function(c){n.useWorker=!1,P.logger.warn("Exception in webworker, fallback to inline"),n.hls.trigger(D.Events.ERROR,{type:U.ErrorTypes.OTHER_ERROR,details:U.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(c.message+" ("+c.filename+":"+c.lineno+")")})},g.postMessage({cmd:"init",typeSupported:i,vendor:u,id:v,config:JSON.stringify(d)})}catch(c){P.logger.warn("Error in worker:",c),P.logger.error("Error while initializing DemuxerWorker, fallback to inline"),g&&self.URL.revokeObjectURL(g.objectURL),this.transmuxer=new M.default(this.observer,i,d,u,v),this.worker=null}}else this.transmuxer=new M.default(this.observer,i,d,u,v)}var _=f.prototype;return _.destroy=function(){var v=this.worker;if(v)v.removeEventListener("message",this.onwmsg),v.terminate(),this.worker=null,this.onwmsg=void 0;else{var a=this.transmuxer;a&&(a.destroy(),this.transmuxer=null)}var s=this.observer;s&&s.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},_.push=function(v,a,s,n,d,l,i,u,g,c){var m,e,r=this;g.transmuxing.start=self.performance.now();var t=this.transmuxer,o=this.worker,y=l?l.start:d.start,h=d.decryptdata,L=this.frag,R=!(L&&d.cc===L.cc),I=!(L&&g.level===L.level),k=L?g.sn-L.sn:-1,F=this.part?g.part-this.part.index:-1,W=k===0&&g.id>1&&g.id===(L==null?void 0:L.stats.chunkCount),K=!I&&(k===1||k===0&&(F===1||W&&F<=0)),H=self.performance.now();(I||k||d.stats.parsing.start===0)&&(d.stats.parsing.start=H),l&&(F||!K)&&(l.stats.parsing.start=H);var Y=!(L&&((m=d.initSegment)===null||m===void 0?void 0:m.url)===((e=L.initSegment)===null||e===void 0?void 0:e.url)),q=new M.TransmuxState(R,K,u,I,y,Y);if(!K||R||Y){P.logger.log("[transmuxer-interface, "+d.type+"]: Starting new transmux session for sn: "+g.sn+" p: "+g.part+" level: "+g.level+" id: "+g.id+`
|
|
15
|
-
discontinuity: `+R+`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
timeOffset: `+y+`
|
|
20
|
-
initSegmentChange: `+Y);var ee=new M.TransmuxConfig(s,n,a,i,c);this.configureTransmuxer(ee)}if(this.frag=d,this.part=l,o)o.postMessage({cmd:"demux",data:v,decryptdata:h,chunkMeta:g,state:q},v instanceof ArrayBuffer?[v]:[]);else if(t){var ae=t.push(v,h,g,q);(0,M.isPromise)(ae)?(t.async=!0,ae.then(function(re){r.handleTransmuxComplete(re)}).catch(function(re){r.transmuxerError(re,g,"transmuxer-interface push error")})):(t.async=!1,this.handleTransmuxComplete(ae))}},_.flush=function(v){var a=this;v.transmuxing.start=self.performance.now();var s=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:v});else if(s){var d=s.flush(v),l=(0,M.isPromise)(d);l||s.async?((0,M.isPromise)(d)||(d=Promise.resolve(d)),d.then(function(i){a.handleFlushResult(i,v)}).catch(function(i){a.transmuxerError(i,v,"transmuxer-interface flush error")})):this.handleFlushResult(d,v)}},_.transmuxerError=function(v,a,s){!this.hls||this.hls.trigger(D.Events.ERROR,{type:U.ErrorTypes.MEDIA_ERROR,details:U.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:a,fatal:!1,error:v,err:v,reason:s})},_.handleFlushResult=function(v,a){var s=this;v.forEach(function(n){s.handleTransmuxComplete(n)}),this.onFlush(a)},_.onWorkerMessage=function(v){var a=v.data,s=this.hls;switch(a.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(a.data);break}case"flush":{this.onFlush(a.data);break}case"workerLog":P.logger[a.data.logType]&&P.logger[a.data.logType](a.data.message);break;default:{a.data=a.data||{},a.data.frag=this.frag,a.data.id=this.id,s.trigger(a.event,a.data);break}}},_.configureTransmuxer=function(v){var a=this.worker,s=this.transmuxer;a?a.postMessage({cmd:"configure",config:v}):s&&s.configure(v)},_.handleTransmuxComplete=function(v){v.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(v)},f}()},"./src/demux/transmuxer-worker.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>A});var O=T("./src/demux/transmuxer.ts"),D=T("./src/events.ts"),M=T("./src/utils/logger.ts"),P=T("./node_modules/eventemitter3/index.js"),U=T.n(P),b=T("./src/errors.ts");function A(_){var p=new P.EventEmitter,v=function(n,d){_.postMessage({event:n,data:d})};p.on(D.Events.FRAG_DECRYPTED,v),p.on(D.Events.ERROR,v);var a=function(){var n=function(i){var u=function(c){v("workerLog",{logType:i,message:c})};M.logger[i]=u};for(var d in M.logger)n(d)};_.addEventListener("message",function(s){var n=s.data;switch(n.cmd){case"init":{var d=JSON.parse(n.config);_.transmuxer=new O.default(p,n.typeSupported,d,n.vendor,n.id),(0,M.enableLogs)(d.debug,n.id),a(),v("init",null);break}case"configure":{_.transmuxer.configure(n.config);break}case"demux":{var l=_.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);(0,O.isPromise)(l)?(_.transmuxer.async=!0,l.then(function(c){S(_,c)}).catch(function(c){v(D.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker push error"})})):(_.transmuxer.async=!1,S(_,l));break}case"flush":{var i=n.chunkMeta,u=_.transmuxer.flush(i),g=(0,O.isPromise)(u);g||_.transmuxer.async?((0,O.isPromise)(u)||(u=Promise.resolve(u)),u.then(function(c){x(_,c,i)}).catch(function(c){v(D.Events.ERROR,{type:b.ErrorTypes.MEDIA_ERROR,details:b.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:n.chunkMeta,fatal:!1,error:c,err:c,reason:"transmuxer-worker flush error"})})):x(_,u,i);break}default:break}})}function S(_,p){if(f(p.remuxResult))return!1;var v=[],a=p.remuxResult,s=a.audio,n=a.video;return s&&E(v,s),n&&E(v,n),_.postMessage({event:"transmuxComplete",data:p},v),!0}function E(_,p){p.data1&&_.push(p.data1.buffer),p.data2&&_.push(p.data2.buffer)}function x(_,p,v){var a=p.reduce(function(s,n){return S(_,n)||s},!1);a||_.postMessage({event:"transmuxComplete",data:p[0]}),_.postMessage({event:"flush",data:v})}function f(_){return!_.audio&&!_.video&&!_.text&&!_.id3&&!_.initSegment}},"./src/demux/transmuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{TransmuxConfig:()=>n,TransmuxState:()=>d,default:()=>p,isPromise:()=>s});var O=T("./src/events.ts"),D=T("./src/errors.ts"),M=T("./src/crypt/decrypter.ts"),P=T("./src/demux/aacdemuxer.ts"),U=T("./src/demux/mp4demuxer.ts"),b=T("./src/demux/tsdemuxer.ts"),A=T("./src/demux/mp3demuxer.ts"),S=T("./src/remux/mp4-remuxer.ts"),E=T("./src/remux/passthrough-remuxer.ts"),x=T("./src/utils/logger.ts"),f;try{f=self.performance.now.bind(self.performance)}catch{x.logger.debug("Unable to use Performance API on this environment"),f=self.Date.now}var _=[{demux:U.default,remux:E.default},{demux:b.default,remux:S.default},{demux:P.default,remux:S.default},{demux:A.default,remux:S.default}],p=function(){function l(u,g,c,m,e){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=u,this.typeSupported=g,this.config=c,this.vendor=m,this.id=e}var i=l.prototype;return i.configure=function(g){this.transmuxConfig=g,this.decrypter&&this.decrypter.reset()},i.push=function(g,c,m,e){var r=this,t=m.transmuxing;t.executeStart=f();var o=new Uint8Array(g),y=this.currentTransmuxState,h=this.transmuxConfig;e&&(this.currentTransmuxState=e);var L=e||y,R=L.contiguous,I=L.discontinuity,k=L.trackSwitch,F=L.accurateTimeOffset,W=L.timeOffset,K=L.initSegmentChange,H=h.audioCodec,Y=h.videoCodec,q=h.defaultInitPts,ee=h.duration,ae=h.initSegmentData,re=v(o,c);if(re&&re.method==="AES-128"){var se=this.getDecrypter();if(se.isSync()){var le=se.softwareDecrypt(o,re.key.buffer,re.iv.buffer);if(!le)return t.executeEnd=f(),a(m);o=new Uint8Array(le)}else return this.decryptionPromise=se.webCryptoDecrypt(o,re.key.buffer,re.iv.buffer).then(function(ce){var be=r.push(ce,null,m);return r.decryptionPromise=null,be}),this.decryptionPromise}var de=this.needsProbing(I,k);de&&this.configureTransmuxer(o),(I||k||K||de)&&this.resetInitSegment(ae,H,Y,ee,c),(I||K||de)&&this.resetInitialTimestamp(q),R||this.resetContiguity();var ue=this.transmux(o,re,W,F,m),fe=this.currentTransmuxState;return fe.contiguous=!0,fe.discontinuity=!1,fe.trackSwitch=!1,t.executeEnd=f(),ue},i.flush=function(g){var c=this,m=g.transmuxing;m.executeStart=f();var e=this.decrypter,r=this.currentTransmuxState,t=this.decryptionPromise;if(t)return t.then(function(){return c.flush(g)});var o=[],y=r.timeOffset;if(e){var h=e.flush();h&&o.push(this.push(h,null,g))}var L=this.demuxer,R=this.remuxer;if(!L||!R)return this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),m.executeEnd=f(),[a(g)];var I=L.flush(y);return s(I)?I.then(function(k){return c.flushRemux(o,k,g),o}):(this.flushRemux(o,I,g),o)},i.flushRemux=function(g,c,m){var e=c.audioTrack,r=c.videoTrack,t=c.id3Track,o=c.textTrack,y=this.currentTransmuxState,h=y.accurateTimeOffset,L=y.timeOffset;x.logger.log("[transmuxer.ts]: Flushed fragment "+m.sn+(m.part>-1?" p: "+m.part:"")+" of level "+m.level);var R=this.remuxer.remux(e,r,t,o,L,h,!0,this.id);g.push({remuxResult:R,chunkMeta:m}),m.transmuxing.executeEnd=f()},i.resetInitialTimestamp=function(g){var c=this.demuxer,m=this.remuxer;!c||!m||(c.resetTimeStamp(g),m.resetTimeStamp(g))},i.resetContiguity=function(){var g=this.demuxer,c=this.remuxer;!g||!c||(g.resetContiguity(),c.resetNextTimestamp())},i.resetInitSegment=function(g,c,m,e,r){var t=this.demuxer,o=this.remuxer;!t||!o||(t.resetInitSegment(g,c,m,e),o.resetInitSegment(g,c,m,r))},i.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},i.transmux=function(g,c,m,e,r){var t;return c&&c.method==="SAMPLE-AES"?t=this.transmuxSampleAes(g,c,m,e,r):t=this.transmuxUnencrypted(g,m,e,r),t},i.transmuxUnencrypted=function(g,c,m,e){var r=this.demuxer.demux(g,c,!1,!this.config.progressive),t=r.audioTrack,o=r.videoTrack,y=r.id3Track,h=r.textTrack,L=this.remuxer.remux(t,o,y,h,c,m,!1,this.id);return{remuxResult:L,chunkMeta:e}},i.transmuxSampleAes=function(g,c,m,e,r){var t=this;return this.demuxer.demuxSampleAes(g,c,m).then(function(o){var y=t.remuxer.remux(o.audioTrack,o.videoTrack,o.id3Track,o.textTrack,m,e,!1,t.id);return{remuxResult:y,chunkMeta:r}})},i.configureTransmuxer=function(g){for(var c=this.config,m=this.observer,e=this.typeSupported,r=this.vendor,t,o=0,y=_.length;o<y;o++)if(_[o].demux.probe(g)){t=_[o];break}t||(x.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),t={demux:U.default,remux:E.default});var h=this.demuxer,L=this.remuxer,R=t.remux,I=t.demux;(!L||!(L instanceof R))&&(this.remuxer=new R(m,c,e,r)),(!h||!(h instanceof I))&&(this.demuxer=new I(m,c,e),this.probe=I.probe)},i.needsProbing=function(g,c){return!this.demuxer||!this.remuxer||g||c},i.getDecrypter=function(){var g=this.decrypter;return g||(g=this.decrypter=new M.default(this.config)),g},l}();function v(l,i){var u=null;return l.byteLength>0&&i!=null&&i.key!=null&&i.iv!==null&&i.method!=null&&(u=i),u}var a=function(i){return{remuxResult:{},chunkMeta:i}};function s(l){return"then"in l&&l.then instanceof Function}var n=function(i,u,g,c,m){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=i,this.videoCodec=u,this.initSegmentData=g,this.duration=c,this.defaultInitPts=m},d=function(i,u,g,c,m,e){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=i,this.contiguous=u,this.accurateTimeOffset=g,this.trackSwitch=c,this.timeOffset=m,this.initSegmentChange=e}},"./src/demux/tsdemuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>d});var O=T("./src/demux/adts.ts"),D=T("./src/demux/mpegaudio.ts"),M=T("./src/demux/exp-golomb.ts"),P=T("./src/demux/sample-aes.ts"),U=T("./src/events.ts"),b=T("./src/utils/mp4-tools.ts"),A=T("./src/utils/logger.ts"),S=T("./src/errors.ts"),E=T("./src/types/demuxer.ts");function x(){return x=Object.assign?Object.assign.bind():function(l){for(var i=1;i<arguments.length;i++){var u=arguments[i];for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(l[g]=u[g])}return l},x.apply(this,arguments)}var f=188,_=function(){function l(u,g,c){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=u,this.config=g,this.typeSupported=c}l.probe=function(g){var c=l.syncOffset(g);return c>0&&A.logger.warn("MPEG2-TS detected but first sync word found @ offset "+c),c!==-1},l.syncOffset=function(g){for(var c=Math.min(f*5,g.length-f*2)+1,m=0;m<c;){if(g[m]===71&&g[m+f]===71)return m;m++}return-1},l.createTrack=function(g,c){return{container:g==="video"||g==="audio"?"video/mp2t":void 0,type:g,id:b.RemuxerTrackIdConfig[g],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:g==="audio"?c:void 0}};var i=l.prototype;return i.resetInitSegment=function(g,c,m,e){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=l.createTrack("video"),this._audioTrack=l.createTrack("audio",e),this._id3Track=l.createTrack("id3"),this._txtTrack=l.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=m,this._duration=e},i.resetTimeStamp=function(){},i.resetContiguity=function(){var g=this._audioTrack,c=this._avcTrack,m=this._id3Track;g&&(g.pesData=null),c&&(c.pesData=null),m&&(m.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},i.demux=function(g,c,m,e){m===void 0&&(m=!1),e===void 0&&(e=!1),m||(this.sampleAes=null);var r,t=this._avcTrack,o=this._audioTrack,y=this._id3Track,h=this._txtTrack,L=t.pid,R=t.pesData,I=o.pid,k=y.pid,F=o.pesData,W=y.pesData,K=null,H=this.pmtParsed,Y=this._pmtId,q=g.length;if(this.remainderData&&(g=(0,b.appendUint8Array)(this.remainderData,g),q=g.length,this.remainderData=null),q<f&&!e)return this.remainderData=g,{audioTrack:o,videoTrack:t,id3Track:y,textTrack:h};var ee=Math.max(0,l.syncOffset(g));q-=(q-ee)%f,q<g.byteLength&&!e&&(this.remainderData=new Uint8Array(g.buffer,q,g.buffer.byteLength-q));for(var ae=0,re=ee;re<q;re+=f)if(g[re]===71){var se=!!(g[re+1]&64),le=((g[re+1]&31)<<8)+g[re+2],de=(g[re+3]&48)>>4,ue=void 0;if(de>1){if(ue=re+5+g[re+4],ue===re+f)continue}else ue=re+4;switch(le){case L:se&&(R&&(r=s(R))&&this.parseAVCPES(t,h,r,!1),R={data:[],size:0}),R&&(R.data.push(g.subarray(ue,re+f)),R.size+=re+f-ue);break;case I:if(se){if(F&&(r=s(F)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,r);break;case"mp3":this.parseMPEGPES(o,r);break}F={data:[],size:0}}F&&(F.data.push(g.subarray(ue,re+f)),F.size+=re+f-ue);break;case k:se&&(W&&(r=s(W))&&this.parseID3PES(y,r),W={data:[],size:0}),W&&(W.data.push(g.subarray(ue,re+f)),W.size+=re+f-ue);break;case 0:se&&(ue+=g[ue]+1),Y=this._pmtId=v(g,ue);break;case Y:{se&&(ue+=g[ue]+1);var fe=a(g,ue,this.typeSupported,m);L=fe.avc,L>0&&(t.pid=L),I=fe.audio,I>0&&(o.pid=I,o.segmentCodec=fe.segmentCodec),k=fe.id3,k>0&&(y.pid=k),K!==null&&!H&&(A.logger.log("unknown PID '"+K+"' in TS found"),K=null,re=ee-188),H=this.pmtParsed=!0;break}case 17:case 8191:break;default:K=le;break}}else ae++;ae>0&&this.observer.emit(U.Events.ERROR,U.Events.ERROR,{type:S.ErrorTypes.MEDIA_ERROR,details:S.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+ae+" TS packet/s that do not start with 0x47"}),t.pesData=R,o.pesData=F,y.pesData=W;var ce={audioTrack:o,videoTrack:t,id3Track:y,textTrack:h};return e&&this.extractRemainingSamples(ce),ce},i.flush=function(){var g=this.remainderData;this.remainderData=null;var c;return g?c=this.demux(g,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(g){var c=g.audioTrack,m=g.videoTrack,e=g.id3Track,r=g.textTrack,t=m.pesData,o=c.pesData,y=e.pesData,h;if(t&&(h=s(t))?(this.parseAVCPES(m,r,h,!0),m.pesData=null):m.pesData=t,o&&(h=s(o))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,h);break;case"mp3":this.parseMPEGPES(c,h);break}c.pesData=null}else o!=null&&o.size&&A.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=o;y&&(h=s(y))?(this.parseID3PES(e,h),e.pesData=null):e.pesData=y},i.demuxSampleAes=function(g,c,m){var e=this.demux(g,m,!0,!this.config.progressive),r=this.sampleAes=new P.default(this.observer,this.config,c);return this.decrypt(e,r)},i.decrypt=function(g,c){return new Promise(function(m){var e=g.audioTrack,r=g.videoTrack;e.samples&&e.segmentCodec==="aac"?c.decryptAacSamples(e.samples,0,function(){r.samples?c.decryptAvcSamples(r.samples,0,0,function(){m(g)}):m(g)}):r.samples&&c.decryptAvcSamples(r.samples,0,0,function(){m(g)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(g,c,m,e){var r=this,t=this.parseAVCNALu(g,m.data),o=!1,y=this.avcSample,h,L=!1;m.data=null,y&&t.length&&!g.audFound&&(n(y,g),y=this.avcSample=p(!1,m.pts,m.dts,"")),t.forEach(function(R){switch(R.type){case 1:{h=!0,y||(y=r.avcSample=p(!0,m.pts,m.dts,"")),o&&(y.debug+="NDR "),y.frame=!0;var I=R.data;if(L&&I.length>4){var k=new M.default(I).readSliceType();(k===2||k===4||k===7||k===9)&&(y.key=!0)}break}case 5:h=!0,y||(y=r.avcSample=p(!0,m.pts,m.dts,"")),o&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{h=!0,o&&y&&(y.debug+="SEI "),(0,b.parseSEIMessageFromNALu)(R.data,1,m.pts,c.samples);break}case 7:if(h=!0,L=!0,o&&y&&(y.debug+="SPS "),!g.sps){var F=new M.default(R.data),W=F.readSPS();g.width=W.width,g.height=W.height,g.pixelRatio=W.pixelRatio,g.sps=[R.data],g.duration=r._duration;for(var K=R.data.subarray(1,4),H="avc1.",Y=0;Y<3;Y++){var q=K[Y].toString(16);q.length<2&&(q="0"+q),H+=q}g.codec=H}break;case 8:h=!0,o&&y&&(y.debug+="PPS "),g.pps||(g.pps=[R.data]);break;case 9:h=!1,g.audFound=!0,y&&n(y,g),y=r.avcSample=p(!1,m.pts,m.dts,o?"AUD ":"");break;case 12:h=!0;break;default:h=!1,y&&(y.debug+="unknown NAL "+R.type+" ");break}if(y&&h){var ee=y.units;ee.push(R)}}),e&&y&&(n(y,g),this.avcSample=null)},i.getLastNalUnit=function(g){var c,m=this.avcSample,e;if((!m||m.units.length===0)&&(m=g[g.length-1]),(c=m)!==null&&c!==void 0&&c.units){var r=m.units;e=r[r.length-1]}return e},i.parseAVCNALu=function(g,c){var m=c.byteLength,e=g.naluState||0,r=e,t=[],o=0,y,h,L,R=-1,I=0;for(e===-1&&(R=0,I=c[0]&31,e=0,o=1);o<m;){if(y=c[o++],!e){e=y?0:1;continue}if(e===1){e=y?0:2;continue}if(!y)e=3;else if(y===1){if(R>=0){var k={data:c.subarray(R,o-e-1),type:I};t.push(k)}else{var F=this.getLastNalUnit(g.samples);if(F&&(r&&o<=4-r&&F.state&&(F.data=F.data.subarray(0,F.data.byteLength-r)),h=o-e-1,h>0)){var W=new Uint8Array(F.data.byteLength+h);W.set(F.data,0),W.set(c.subarray(0,h),F.data.byteLength),F.data=W,F.state=0}}o<m?(L=c[o]&31,R=o,I=L,e=0):e=-1}else e=0}if(R>=0&&e>=0){var K={data:c.subarray(R,m),type:I,state:e};t.push(K)}if(t.length===0){var H=this.getLastNalUnit(g.samples);if(H){var Y=new Uint8Array(H.data.byteLength+c.byteLength);Y.set(H.data,0),Y.set(c,H.data.byteLength),H.data=Y}}return g.naluState=e,t},i.parseAACPES=function(g,c){var m=0,e=this.aacOverFlow,r=c.data;if(e){this.aacOverFlow=null;var t=e.missing,o=e.sample.unit.byteLength;if(t===-1){var y=new Uint8Array(o+r.byteLength);y.set(e.sample.unit,0),y.set(r,o),r=y}else{var h=o-t;e.sample.unit.set(r.subarray(0,t),h),g.samples.push(e.sample),m=e.missing}}var L,R;for(L=m,R=r.length;L<R-1&&!O.isHeader(r,L);L++);if(L!==m){var I,k;if(L<R-1?(I="AAC PES did not start with ADTS header,offset:"+L,k=!1):(I="no ADTS header found in AAC PES",k=!0),A.logger.warn("parsing error:"+I),this.observer.emit(U.Events.ERROR,U.Events.ERROR,{type:S.ErrorTypes.MEDIA_ERROR,details:S.ErrorDetails.FRAG_PARSING_ERROR,fatal:k,reason:I}),k)return}O.initTrackConfig(g,this.observer,r,L,this.audioCodec);var F;if(c.pts!==void 0)F=c.pts;else if(e){var W=O.getFrameDuration(g.samplerate);F=e.sample.pts+W}else{A.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var K=0,H;L<R;)if(H=O.appendFrame(g,r,L,F,K),L+=H.length,H.missing){this.aacOverFlow=H;break}else for(K++;L<R-1&&!O.isHeader(r,L);L++);},i.parseMPEGPES=function(g,c){var m=c.data,e=m.length,r=0,t=0,o=c.pts;if(o===void 0){A.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;t<e;)if(D.isHeader(m,t)){var y=D.appendFrame(g,m,t,o,r);if(y)t+=y.length,r++;else break}else t++},i.parseID3PES=function(g,c){if(c.pts===void 0){A.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var m=x({},c,{type:this._avcTrack?E.MetadataSchema.emsg:E.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});g.samples.push(m)},l}();function p(l,i,u,g){return{key:l,frame:!1,pts:i,dts:u,units:[],debug:g,length:0}}function v(l,i){return(l[i+10]&31)<<8|l[i+11]}function a(l,i,u,g){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},m=(l[i+1]&15)<<8|l[i+2],e=i+3+m-4,r=(l[i+10]&15)<<8|l[i+11];for(i+=12+r;i<e;){var t=(l[i+1]&31)<<8|l[i+2];switch(l[i]){case 207:if(!g){A.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=t);break;case 21:c.id3===-1&&(c.id3=t);break;case 219:if(!g){A.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=t);break;case 3:case 4:u.mpeg!==!0&&u.mp3!==!0?A.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=t,c.segmentCodec="mp3");break;case 36:A.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((l[i+3]&15)<<8|l[i+4])+5}return c}function s(l){var i=0,u,g,c,m,e,r=l.data;if(!l||l.size===0)return null;for(;r[0].length<19&&r.length>1;){var t=new Uint8Array(r[0].length+r[1].length);t.set(r[0]),t.set(r[1],r[0].length),r[0]=t,r.splice(1,1)}u=r[0];var o=(u[0]<<16)+(u[1]<<8)+u[2];if(o===1){if(g=(u[4]<<8)+u[5],g&&g>l.size-6)return null;var y=u[7];y&192&&(m=(u[9]&14)*536870912+(u[10]&255)*4194304+(u[11]&254)*16384+(u[12]&255)*128+(u[13]&254)/2,y&64?(e=(u[14]&14)*536870912+(u[15]&255)*4194304+(u[16]&254)*16384+(u[17]&255)*128+(u[18]&254)/2,m-e>54e5&&(A.logger.warn(Math.round((m-e)/9e4)+"s delta between PTS and DTS, align them"),m=e)):e=m),c=u[8];var h=c+9;if(l.size<=h)return null;l.size-=h;for(var L=new Uint8Array(l.size),R=0,I=r.length;R<I;R++){u=r[R];var k=u.byteLength;if(h)if(h>k){h-=k;continue}else u=u.subarray(h),k-=h,h=0;L.set(u,i),i+=k}return g&&(g-=c+3),{data:L,pts:m,dts:e,len:g}}return null}function n(l,i){if(l.units.length&&l.frame){if(l.pts===void 0){var u=i.samples,g=u.length;if(g){var c=u[g-1];l.pts=c.pts,l.dts=c.dts}else{i.dropped++;return}}i.samples.push(l)}l.debug.length&&A.logger.log(l.pts+"/"+l.dts+":"+l.debug)}let d=_},"./src/demux/webworkify-webpack.js":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>f});var O=function(){var p=ENTRY_MODULE,v={},a=function n(d){var l=v[d];if(l!==void 0)return l.exports;var i=v[d]={exports:{}};return p[d].call(i.exports,i,i.exports,n),i.exports};a.m=p,function(){a.n=function(n){var d=n&&n.__esModule?function(){return n.default}:function(){return n};return a.d(d,{a:d}),d}}(),function(){a.d=function(n,d){for(var l in d)a.o(d,l)&&!a.o(n,l)&&Object.defineProperty(n,l,{enumerable:!0,get:d[l]})}}(),function(){a.o=function(n,d){return Object.prototype.hasOwnProperty.call(n,d)}}(),function(){a.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}}();var s=a(ENTRY_MODULE);return s.default||s},D=O.toString().split("ENTRY_MODULE"),M="[\\.|\\-|\\+|\\w|/|@]+",P="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+M+").*?\\)";function U(_){return(_+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function b(_){return!isNaN(1*_)}function A(_,p,v){var a={};a[v]=[];var s=p.toString().replace(/^"[^"]+"/,"function"),n=s.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||s.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!n)return a;for(var d=n[1],l=new RegExp("(\\\\n|\\W)"+U(d)+P,"g"),i;i=l.exec(s);)i[3]!=="dll-reference"&&a[v].push(i[3]);for(l=new RegExp("\\("+U(d)+'\\("(dll-reference\\s('+M+'))"\\)\\)'+P,"g");i=l.exec(s);)_[i[2]]||(a[v].push(i[1]),_[i[2]]=T(i[1]).m),a[i[2]]=a[i[2]]||[],a[i[2]].push(i[4]);for(var u=Object.keys(a),g=0;g<u.length;g++)for(var c=0;c<a[u[g]].length;c++)b(a[u[g]][c])&&(a[u[g]][c]=1*a[u[g]][c]);return a}function S(_){var p=Object.keys(_);return p.reduce(function(v,a){return v||_[a].length>0},!1)}function E(_,p){for(var v={main:[p]},a={main:[]},s={main:{}};S(v);)for(var n=Object.keys(v),d=0;d<n.length;d++){var l=n[d],i=v[l],u=i.pop();if(s[l]=s[l]||{},!(s[l][u]||!_[l][u])){s[l][u]=!0,a[l]=a[l]||[],a[l].push(u);for(var g=A(_,_[l][u],l),c=Object.keys(g),m=0;m<c.length;m++)v[c[m]]=v[c[m]]||[],v[c[m]]=v[c[m]].concat(g[c[m]])}}return a}function x(_,p,v,a){var s=_[a].map(function(n){return'"'+n+'": '+p[a][n].toString().replace(/^"[^"]+"/,"function")}).join(",");return D[0]+"{"+s+"}"+D[1]+'"'+v+'"'+D[2]}function f(_,p){p=p||{};var v={main:T.m},a=p.all?{main:Object.keys(v.main)}:E(v,_),s="";Object.keys(a).filter(function(u){return u!=="main"}).forEach(function(u){for(var g=0;a[u][g];)g++;a[u].push(g),v[u][g]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",s=s+("var "+u+" = ("+x(a,v,g,modules)+`)();
|
|
21
|
-
`)}),s=s+("new (("+x(a,v,_,"main")+")())(self);");var n=new window.Blob([s],{type:"text/javascript"}),d=window.URL||window.webkitURL||window.mozURL||window.msURL,l=d.createObjectURL(n),i=new window.Worker(l);return i.objectURL=l,i}},"./src/errors.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{ErrorDetails:()=>D,ErrorTypes:()=>O});var O;(function(M){M.NETWORK_ERROR="networkError",M.MEDIA_ERROR="mediaError",M.KEY_SYSTEM_ERROR="keySystemError",M.MUX_ERROR="muxError",M.OTHER_ERROR="otherError"})(O||(O={}));var D;(function(M){M.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",M.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",M.KEY_SYSTEM_NO_SESSION="keySystemNoSession",M.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",M.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",M.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",M.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",M.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",M.MANIFEST_LOAD_ERROR="manifestLoadError",M.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",M.MANIFEST_PARSING_ERROR="manifestParsingError",M.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",M.LEVEL_EMPTY_ERROR="levelEmptyError",M.LEVEL_LOAD_ERROR="levelLoadError",M.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",M.LEVEL_SWITCH_ERROR="levelSwitchError",M.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",M.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",M.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",M.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",M.FRAG_LOAD_ERROR="fragLoadError",M.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",M.FRAG_DECRYPT_ERROR="fragDecryptError",M.FRAG_PARSING_ERROR="fragParsingError",M.REMUX_ALLOC_ERROR="remuxAllocError",M.KEY_LOAD_ERROR="keyLoadError",M.KEY_LOAD_TIMEOUT="keyLoadTimeOut",M.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",M.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",M.BUFFER_APPEND_ERROR="bufferAppendError",M.BUFFER_APPENDING_ERROR="bufferAppendingError",M.BUFFER_STALLED_ERROR="bufferStalledError",M.BUFFER_FULL_ERROR="bufferFullError",M.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",M.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",M.INTERNAL_EXCEPTION="internalException",M.INTERNAL_ABORTED="aborted",M.UNKNOWN="unknown"})(D||(D={}))},"./src/events.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{Events:()=>O});var O;(function(D){D.MEDIA_ATTACHING="hlsMediaAttaching",D.MEDIA_ATTACHED="hlsMediaAttached",D.MEDIA_DETACHING="hlsMediaDetaching",D.MEDIA_DETACHED="hlsMediaDetached",D.BUFFER_RESET="hlsBufferReset",D.BUFFER_CODECS="hlsBufferCodecs",D.BUFFER_CREATED="hlsBufferCreated",D.BUFFER_APPENDING="hlsBufferAppending",D.BUFFER_APPENDED="hlsBufferAppended",D.BUFFER_EOS="hlsBufferEos",D.BUFFER_FLUSHING="hlsBufferFlushing",D.BUFFER_FLUSHED="hlsBufferFlushed",D.MANIFEST_LOADING="hlsManifestLoading",D.MANIFEST_LOADED="hlsManifestLoaded",D.MANIFEST_PARSED="hlsManifestParsed",D.LEVEL_SWITCHING="hlsLevelSwitching",D.LEVEL_SWITCHED="hlsLevelSwitched",D.LEVEL_LOADING="hlsLevelLoading",D.LEVEL_LOADED="hlsLevelLoaded",D.LEVEL_UPDATED="hlsLevelUpdated",D.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",D.LEVELS_UPDATED="hlsLevelsUpdated",D.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",D.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",D.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",D.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",D.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",D.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",D.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",D.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",D.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",D.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",D.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",D.CUES_PARSED="hlsCuesParsed",D.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",D.INIT_PTS_FOUND="hlsInitPtsFound",D.FRAG_LOADING="hlsFragLoading",D.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",D.FRAG_LOADED="hlsFragLoaded",D.FRAG_DECRYPTED="hlsFragDecrypted",D.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",D.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",D.FRAG_PARSING_METADATA="hlsFragParsingMetadata",D.FRAG_PARSED="hlsFragParsed",D.FRAG_BUFFERED="hlsFragBuffered",D.FRAG_CHANGED="hlsFragChanged",D.FPS_DROP="hlsFpsDrop",D.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",D.ERROR="hlsError",D.DESTROYING="hlsDestroying",D.KEY_LOADING="hlsKeyLoading",D.KEY_LOADED="hlsKeyLoaded",D.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",D.BACK_BUFFER_REACHED="hlsBackBufferReached"})(O||(O={}))},"./src/hls.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>g});var O=T("./node_modules/url-toolkit/src/url-toolkit.js"),D=T.n(O),M=T("./src/loader/playlist-loader.ts"),P=T("./src/controller/id3-track-controller.ts"),U=T("./src/controller/latency-controller.ts"),b=T("./src/controller/level-controller.ts"),A=T("./src/controller/fragment-tracker.ts"),S=T("./src/loader/key-loader.ts"),E=T("./src/controller/stream-controller.ts"),x=T("./src/is-supported.ts"),f=T("./src/utils/logger.ts"),_=T("./src/config.ts"),p=T("./node_modules/eventemitter3/index.js"),v=T.n(p),a=T("./src/events.ts"),s=T("./src/errors.ts"),n=T("./src/types/level.ts");function d(c,m){for(var e=0;e<m.length;e++){var r=m[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(c,i(r.key),r)}}function l(c,m,e){return m&&d(c.prototype,m),e&&d(c,e),Object.defineProperty(c,"prototype",{writable:!1}),c}function i(c){var m=u(c,"string");return typeof m=="symbol"?m:String(m)}function u(c,m){if(typeof c!="object"||c===null)return c;var e=c[Symbol.toPrimitive];if(e!==void 0){var r=e.call(c,m||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(c)}var g=function(){c.isSupported=function(){return(0,x.isSupported)()};function c(e){e===void 0&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.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 r=this.config=(0,_.mergeConfig)(c.DefaultConfig,e);this.userConfig=e,(0,f.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,_.enableStreamingMode)(r);var t=r.abrController,o=r.bufferController,y=r.capLevelController,h=r.fpsController,L=this.abrController=new t(this),R=this.bufferController=new o(this),I=this.capLevelController=new y(this),k=new h(this),F=new M.default(this),W=new P.default(this),K=this.levelController=new b.default(this),H=new A.FragmentTracker(this),Y=new S.default(this.config),q=this.streamController=new E.default(this,H,Y);I.setStreamController(q),k.setStreamController(q);var ee=[F,K,q];this.networkControllers=ee;var ae=[L,R,I,k,W,H];this.audioTrackController=this.createController(r.audioTrackController,ee);var re=r.audioStreamController;re&&ee.push(new re(this,H,Y)),this.subtitleTrackController=this.createController(r.subtitleTrackController,ee);var se=r.subtitleStreamController;se&&ee.push(new se(this,H,Y)),this.createController(r.timelineController,ae),Y.emeController=this.emeController=this.createController(r.emeController,ae),this.cmcdController=this.createController(r.cmcdController,ae),this.latencyController=this.createController(U.default,ae),this.coreComponents=ae}var m=c.prototype;return m.createController=function(r,t){if(r){var o=new r(this);return t&&t.push(o),o}return null},m.on=function(r,t,o){o===void 0&&(o=this),this._emitter.on(r,t,o)},m.once=function(r,t,o){o===void 0&&(o=this),this._emitter.once(r,t,o)},m.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},m.off=function(r,t,o,y){o===void 0&&(o=this),this._emitter.off(r,t,o,y)},m.listeners=function(r){return this._emitter.listeners(r)},m.emit=function(r,t,o){return this._emitter.emit(r,t,o)},m.trigger=function(r,t){if(this.config.debug)return this.emit(r,r,t);try{return this.emit(r,r,t)}catch(o){f.logger.error("An internal error happened while handling event "+r+'. Error message: "'+o.message+'". Here is a stacktrace:',o),this.trigger(a.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:o})}return!1},m.listenerCount=function(r){return this._emitter.listenerCount(r)},m.destroy=function(){f.logger.log("destroy"),this.trigger(a.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0},m.attachMedia=function(r){f.logger.log("attachMedia"),this._media=r,this.trigger(a.Events.MEDIA_ATTACHING,{media:r})},m.detachMedia=function(){f.logger.log("detachMedia"),this.trigger(a.Events.MEDIA_DETACHING,void 0),this._media=null},m.loadSource=function(r){this.stopLoad();var t=this.media,o=this.url,y=this.url=O.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});f.logger.log("loadSource:"+y),t&&o&&o!==y&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(a.Events.MANIFEST_LOADING,{url:r})},m.startLoad=function(r){r===void 0&&(r=-1),f.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(t){t.startLoad(r)})},m.stopLoad=function(){f.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},m.swapAudioCodec=function(){f.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},m.recoverMediaError=function(){f.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},m.removeLevel=function(r,t){t===void 0&&(t=0),this.levelController.removeLevel(r,t)},l(c,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){f.logger.log("set currentLevel:"+r),this.loadLevel=r,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(r){f.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){f.logger.log("set loadLevel:"+r),this.levelController.manualLevel=r}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(r){this.levelController.nextLoadLevel=r}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(r){f.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){f.logger.log("set startLevel:"+r),r!==-1&&(r=Math.max(r,this.minAutoLevel)),this.levelController.startLevel=r}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(r){var t=!!r;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(r){this._autoLevelCapping!==r&&(f.logger.log("set autoLevelCapping:"+r),this._autoLevelCapping=r)}},{key:"bandwidthEstimate",get:function(){var r=this.abrController.bwEstimator;return r?r.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(r){n.HdcpLevels.indexOf(r)>-1&&(this._maxHdcpLevel=r)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var r=this.levels,t=this.config.minAutoBitrate;if(!r)return 0;for(var o=r.length,y=0;y<o;y++)if(r[y].maxBitrate>=t)return y;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,t=this.autoLevelCapping,o=this.maxHdcpLevel,y;if(t===-1&&r&&r.length?y=r.length-1:y=t,o)for(var h=y;h--;){var L=r[h].attrs["HDCP-LEVEL"];if(L&&L<=o)return h}return y}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(r){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,r)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var r=this.audioTrackController;return r?r.audioTracks:[]}},{key:"audioTrack",get:function(){var r=this.audioTrackController;return r?r.audioTrack:-1},set:function(r){var t=this.audioTrackController;t&&(t.audioTrack=r)}},{key:"subtitleTracks",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTrack:-1},set:function(r){var t=this.subtitleTrackController;t&&(t.subtitleTrack=r)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var r=this.subtitleTrackController;return r?r.subtitleDisplay:!1},set:function(r){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=r)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(r){this.config.lowLatencyMode=r}},{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.3.1"}},{key:"Events",get:function(){return a.Events}},{key:"ErrorTypes",get:function(){return s.ErrorTypes}},{key:"ErrorDetails",get:function(){return s.ErrorDetails}},{key:"DefaultConfig",get:function(){return c.defaultConfig?c.defaultConfig:_.hlsDefaultConfig},set:function(r){c.defaultConfig=r}}]),c}();g.defaultConfig=void 0},"./src/is-supported.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{changeTypeSupported:()=>P,isSupported:()=>M});var O=T("./src/utils/mediasource-helper.ts");function D(){return self.SourceBuffer||self.WebKitSourceBuffer}function M(){var U=(0,O.getMediaSource)();if(!U)return!1;var b=D(),A=U&&typeof U.isTypeSupported=="function"&&U.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),S=!b||b.prototype&&typeof b.prototype.appendBuffer=="function"&&typeof b.prototype.remove=="function";return!!A&&!!S}function P(){var U,b=D();return typeof(b==null||(U=b.prototype)===null||U===void 0?void 0:U.changeType)=="function"}},"./src/loader/date-range.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{DateRange:()=>x,DateRangeAttribute:()=>E});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/attr-list.ts"),M=T("./src/utils/logger.ts");function P(){return P=Object.assign?Object.assign.bind():function(f){for(var _=1;_<arguments.length;_++){var p=arguments[_];for(var v in p)Object.prototype.hasOwnProperty.call(p,v)&&(f[v]=p[v])}return f},P.apply(this,arguments)}function U(f,_){for(var p=0;p<_.length;p++){var v=_[p];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(f,A(v.key),v)}}function b(f,_,p){return _&&U(f.prototype,_),p&&U(f,p),Object.defineProperty(f,"prototype",{writable:!1}),f}function A(f){var _=S(f,"string");return typeof _=="symbol"?_:String(_)}function S(f,_){if(typeof f!="object"||f===null)return f;var p=f[Symbol.toPrimitive];if(p!==void 0){var v=p.call(f,_||"default");if(typeof v!="object")return v;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(f)}var E;(function(f){f.ID="ID",f.CLASS="CLASS",f.START_DATE="START-DATE",f.DURATION="DURATION",f.END_DATE="END-DATE",f.END_ON_NEXT="END-ON-NEXT",f.PLANNED_DURATION="PLANNED-DURATION",f.SCTE35_OUT="SCTE35-OUT",f.SCTE35_IN="SCTE35-IN"})(E||(E={}));var x=function(){function f(_,p){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,p){var v=p.attr;for(var a in v)if(Object.prototype.hasOwnProperty.call(_,a)&&_[a]!==v[a]){M.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+_.ID+'"'),this._badValueForSameId=a;break}_=P(new D.AttrList({}),v,_)}if(this.attr=_,this._startDate=new Date(_[E.START_DATE]),E.END_DATE in this.attr){var s=new Date(this.attr[E.END_DATE]);(0,O.isFiniteNumber)(s.getTime())&&(this._endDate=s)}}return b(f,[{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 p=this.duration;return p!==null?new Date(this._startDate.getTime()+p*1e3):null}},{key:"duration",get:function(){if(E.DURATION in this.attr){var p=this.attr.decimalFloatingPoint(E.DURATION);if((0,O.isFiniteNumber)(p))return p}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return E.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(E.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(E.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,O.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),f}()},"./src/loader/fragment-loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{LoadError:()=>p,default:()=>f});var O=T("./src/polyfills/number.ts"),D=T("./src/errors.ts");function M(v,a){v.prototype=Object.create(a.prototype),v.prototype.constructor=v,S(v,a)}function P(v){var a=typeof Map=="function"?new Map:void 0;return P=function(n){if(n===null||!A(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(n))return a.get(n);a.set(n,d)}function d(){return U(n,arguments,E(this).constructor)}return d.prototype=Object.create(n.prototype,{constructor:{value:d,enumerable:!1,writable:!0,configurable:!0}}),S(d,n)},P(v)}function U(v,a,s){return b()?U=Reflect.construct.bind():U=function(d,l,i){var u=[null];u.push.apply(u,l);var g=Function.bind.apply(d,u),c=new g;return i&&S(c,i.prototype),c},U.apply(null,arguments)}function b(){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 A(v){return Function.toString.call(v).indexOf("[native code]")!==-1}function S(v,a){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,d){return n.__proto__=d,n},S(v,a)}function E(v){return E=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(s){return s.__proto__||Object.getPrototypeOf(s)},E(v)}var x=Math.pow(2,17),f=function(){function v(s){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=s}var a=v.prototype;return a.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},a.abort=function(){this.loader&&this.loader.abort()},a.load=function(n,d){var l=this,i=n.url;if(!i)return Promise.reject(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var u=this.config,g=u.fLoader,c=u.loader;return new Promise(function(m,e){l.loader&&l.loader.destroy();var r=l.loader=n.loader=g?new g(u):new c(u),t=_(n),o={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:n.sn==="initSegment"?1/0:x};n.stats=r.stats,r.load(t,o,{onSuccess:function(h,L,R,I){l.resetLoader(n,r);var k=h.data;R.resetIV&&n.decryptdata&&(n.decryptdata.iv=new Uint8Array(k.slice(0,16)),k=k.slice(16)),m({frag:n,part:null,payload:k,networkDetails:I})},onError:function(h,L,R){l.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,response:h,networkDetails:R}))},onAbort:function(h,L,R){l.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,networkDetails:R}))},onTimeout:function(h,L,R){l.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,networkDetails:R}))},onProgress:function(h,L,R,I){d&&d({frag:n,part:null,payload:R,networkDetails:I})}})})},a.loadPart=function(n,d,l){var i=this;this.abort();var u=this.config,g=u.fLoader,c=u.loader;return new Promise(function(m,e){i.loader&&i.loader.destroy();var r=i.loader=n.loader=g?new g(u):new c(u),t=_(n,d),o={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:x};d.stats=r.stats,r.load(t,o,{onSuccess:function(h,L,R,I){i.resetLoader(n,r),i.updateStatsFromPart(n,d);var k={frag:n,part:d,payload:h.data,networkDetails:I};l(k),m(k)},onError:function(h,L,R){i.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:n,part:d,response:h,networkDetails:R}))},onAbort:function(h,L,R){n.stats.aborted=d.stats.aborted,i.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,part:d,networkDetails:R}))},onTimeout:function(h,L,R){i.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:n,part:d,networkDetails:R}))}})})},a.updateStatsFromPart=function(n,d){var l=n.stats,i=d.stats,u=i.total;if(l.loaded+=i.loaded,u){var g=Math.round(n.duration/d.duration),c=Math.min(Math.round(l.loaded/u),g),m=g-c,e=m*Math.round(l.loaded/c);l.total=l.loaded+e}else l.total=Math.max(l.loaded,l.total);var r=l.loading,t=i.loading;r.start?r.first+=t.first-t.start:(r.start=t.start,r.first=t.first),r.end=t.end},a.resetLoader=function(n,d){n.loader=null,this.loader===d&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),d.destroy()},v}();function _(v,a){a===void 0&&(a=null);var s=a||v,n={frag:v,part:a,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},d=s.byteRangeStartOffset,l=s.byteRangeEndOffset;if((0,O.isFiniteNumber)(d)&&(0,O.isFiniteNumber)(l)){var i,u=d,g=l;if(v.sn==="initSegment"&&((i=v.decryptdata)===null||i===void 0?void 0:i.method)==="AES-128"){var c=l-d;c%16&&(g=l+(16-c%16)),d!==0&&(n.resetIV=!0,u=d-16)}n.rangeStart=u,n.rangeEnd=g}return n}var p=function(v){M(a,v);function a(s){for(var n,d=arguments.length,l=new Array(d>1?d-1:0),i=1;i<d;i++)l[i-1]=arguments[i];return n=v.call.apply(v,[this].concat(l))||this,n.data=void 0,n.data=s,n}return a}(P(Error))},"./src/loader/fragment.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{BaseSegment:()=>_,ElementaryStreamTypes:()=>f,Fragment:()=>p,Part:()=>v});var O=T("./src/polyfills/number.ts"),D=T("./node_modules/url-toolkit/src/url-toolkit.js"),M=T.n(D),P=T("./src/loader/load-stats.ts");function U(a,s){a.prototype=Object.create(s.prototype),a.prototype.constructor=a,b(a,s)}function b(a,s){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(d,l){return d.__proto__=l,d},b(a,s)}function A(a,s){for(var n=0;n<s.length;n++){var d=s[n];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,E(d.key),d)}}function S(a,s,n){return s&&A(a.prototype,s),n&&A(a,n),Object.defineProperty(a,"prototype",{writable:!1}),a}function E(a){var s=x(a,"string");return typeof s=="symbol"?s:String(s)}function x(a,s){if(typeof a!="object"||a===null)return a;var n=a[Symbol.toPrimitive];if(n!==void 0){var d=n.call(a,s||"default");if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(a)}var f;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(f||(f={}));var _=function(){function a(n){var d;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(d={},d[f.AUDIO]=null,d[f.VIDEO]=null,d[f.AUDIOVIDEO]=null,d),this.baseurl=n}var s=a.prototype;return s.setByteRange=function(d,l){var i=d.split("@",2),u=[];i.length===1?u[0]=l?l.byteRangeEndOffset:0:u[0]=parseInt(i[1]),u[1]=parseInt(i[0])+u[0],this._byteRange=u},S(a,[{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,D.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(d){this._url=d}}]),a}(),p=function(a){U(s,a);function s(d,l){var i;return i=a.call(this,l)||this,i._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.appendedPTS=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 P.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.type=d,i}var n=s.prototype;return n.setKeyFormat=function(l){if(this.levelkeys){var i=this.levelkeys[l];i&&!this._decryptdata&&(this._decryptdata=i.getDecryptData(this.sn))}},n.abortRequests=function(){var l,i;(l=this.loader)===null||l===void 0||l.abort(),(i=this.keyLoader)===null||i===void 0||i.abort()},n.setElementaryStreamInfo=function(l,i,u,g,c,m){m===void 0&&(m=!1);var e=this.elementaryStreams,r=e[l];if(!r){e[l]={startPTS:i,endPTS:u,startDTS:g,endDTS:c,partial:m};return}r.startPTS=Math.min(r.startPTS,i),r.endPTS=Math.max(r.endPTS,u),r.startDTS=Math.min(r.startDTS,g),r.endDTS=Math.max(r.endDTS,c)},n.clearElementaryStreamInfo=function(){var l=this.elementaryStreams;l[f.AUDIO]=null,l[f.VIDEO]=null,l[f.AUDIOVIDEO]=null},S(s,[{key:"decryptdata",get:function(){var l=this.levelkeys;if(!l&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var i=this.levelkeys.identity;if(i)this._decryptdata=i.getDecryptData(this.sn);else{var u=Object.keys(this.levelkeys);if(u.length===1)return this._decryptdata=this.levelkeys[u[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,O.isFiniteNumber)(this.programDateTime))return null;var l=(0,O.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+l*1e3}},{key:"encrypted",get:function(){var l;if((l=this._decryptdata)!==null&&l!==void 0&&l.encrypted)return!0;if(this.levelkeys){var i=Object.keys(this.levelkeys),u=i.length;if(u>1||u===1&&this.levelkeys[i[0]].encrypted)return!0}return!1}}]),s}(_),v=function(a){U(s,a);function s(n,d,l,i,u){var g;g=a.call(this,l)||this,g.fragOffset=0,g.duration=0,g.gap=!1,g.independent=!1,g.relurl=void 0,g.fragment=void 0,g.index=void 0,g.stats=new P.LoadStats,g.duration=n.decimalFloatingPoint("DURATION"),g.gap=n.bool("GAP"),g.independent=n.bool("INDEPENDENT"),g.relurl=n.enumeratedString("URI"),g.fragment=d,g.index=i;var c=n.enumeratedString("BYTERANGE");return c&&g.setByteRange(c,u),u&&(g.fragOffset=u.fragOffset+u.duration),g}return S(s,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var d=this.elementaryStreams;return!!(d.audio||d.video||d.audiovideo)}}]),s}(_)},"./src/loader/key-loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>M});var O=T("./src/errors.ts"),D=T("./src/loader/fragment-loader.ts"),M=function(){function P(b){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=b}var U=P.prototype;return U.abort=function(){for(var A in this.keyUriToKeyInfo){var S=this.keyUriToKeyInfo[A].loader;S&&S.abort()}},U.detach=function(){for(var A in this.keyUriToKeyInfo){var S=this.keyUriToKeyInfo[A];(S.mediaKeySessionContext||S.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[A]}},U.destroy=function(){this.detach();for(var A in this.keyUriToKeyInfo){var S=this.keyUriToKeyInfo[A].loader;S&&S.destroy()}this.keyUriToKeyInfo={}},U.createKeyLoadError=function(A,S,E,x){return S===void 0&&(S=O.ErrorDetails.KEY_LOAD_ERROR),new D.LoadError({type:O.ErrorTypes.NETWORK_ERROR,details:S,fatal:!1,frag:A,networkDetails:E})},U.loadClear=function(A,S){var E=this;if(this.emeController&&this.config.emeEnabled)for(var x=A.sn,f=A.cc,_=function(s){var n=S[s];if(f<=n.cc&&(x==="initSegment"||x<n.sn))return E.emeController.selectKeySystemFormat(n).then(function(d){n.setKeyFormat(d)}),"break"},p=0;p<S.length;p++){var v=_(p);if(v==="break")break}},U.load=function(A){var S=this;return!A.decryptdata&&A.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(A).then(function(E){return S.loadInternal(A,E)}):this.loadInternal(A)},U.loadInternal=function(A,S){var E,x;S&&A.setKeyFormat(S);var f=A.decryptdata;if(!f){var _=S?"Expected frag.decryptdata to be defined after setting format "+S:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(A,O.ErrorDetails.KEY_LOAD_ERROR,null,_))}var p=f.uri;if(!p)return Promise.reject(this.createKeyLoadError(A,O.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+p+'"'));var v=this.keyUriToKeyInfo[p];if((E=v)!==null&&E!==void 0&&E.decryptdata.key)return f.key=v.decryptdata.key,Promise.resolve({frag:A,keyInfo:v});if((x=v)!==null&&x!==void 0&&x.keyLoadPromise){var a;switch((a=v.mediaKeySessionContext)===null||a===void 0?void 0:a.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return v.keyLoadPromise}}switch(v=this.keyUriToKeyInfo[p]={decryptdata:f,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},f.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return f.keyFormat==="identity"?this.loadKeyHTTP(v,A):this.loadKeyEME(v,A);case"AES-128":return this.loadKeyHTTP(v,A);default:return Promise.reject(this.createKeyLoadError(A,O.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+f.method+'"'))}},U.loadKeyEME=function(A,S){var E={frag:S,keyInfo:A};if(this.emeController&&this.config.emeEnabled){var x=this.emeController.loadKey(E);if(x)return(A.keyLoadPromise=x.then(function(f){return A.mediaKeySessionContext=f,E})).catch(function(f){throw A.keyLoadPromise=null,f})}return Promise.resolve(E)},U.loadKeyHTTP=function(A,S){var E=this,x=this.config,f=x.loader,_=new f(x);return S.keyLoader=A.loader=_,A.keyLoadPromise=new Promise(function(p,v){var a={keyInfo:A,frag:S,responseType:"arraybuffer",url:A.decryptdata.uri},s={timeout:x.fragLoadingTimeOut,maxRetry:0,retryDelay:x.fragLoadingRetryDelay,maxRetryDelay:x.fragLoadingMaxRetryTimeout,highWaterMark:0},n={onSuccess:function(l,i,u,g){var c=u.frag,m=u.keyInfo,e=u.url;if(!c.decryptdata||m!==E.keyUriToKeyInfo[e])return v(E.createKeyLoadError(c,O.ErrorDetails.KEY_LOAD_ERROR,g,"after key load, decryptdata unset or changed"));m.decryptdata.key=c.decryptdata.key=new Uint8Array(l.data),c.keyLoader=null,m.loader=null,p({frag:c,keyInfo:m})},onError:function(l,i,u){E.resetLoader(i),v(E.createKeyLoadError(S,O.ErrorDetails.KEY_LOAD_ERROR,u))},onTimeout:function(l,i,u){E.resetLoader(i),v(E.createKeyLoadError(S,O.ErrorDetails.KEY_LOAD_TIMEOUT,u))},onAbort:function(l,i,u){E.resetLoader(i),v(E.createKeyLoadError(S,O.ErrorDetails.INTERNAL_ABORTED,u))}};_.load(a,s,n)})},U.resetLoader=function(A){var S=A.frag,E=A.keyInfo,x=A.url,f=E.loader;S.keyLoader===f&&(S.keyLoader=null,E.loader=null),delete this.keyUriToKeyInfo[x],f&&f.destroy()},P}()},"./src/loader/level-details.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{LevelDetails:()=>A});var O=T("./src/polyfills/number.ts");function D(S,E){for(var x=0;x<E.length;x++){var f=E[x];f.enumerable=f.enumerable||!1,f.configurable=!0,"value"in f&&(f.writable=!0),Object.defineProperty(S,P(f.key),f)}}function M(S,E,x){return E&&D(S.prototype,E),x&&D(S,x),Object.defineProperty(S,"prototype",{writable:!1}),S}function P(S){var E=U(S,"string");return typeof E=="symbol"?E:String(E)}function U(S,E){if(typeof S!="object"||S===null)return S;var x=S[Symbol.toPrimitive];if(x!==void 0){var f=x.call(S,E||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(S)}var b=10,A=function(){function S(x){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=x}var E=S.prototype;return E.reloaded=function(f){if(!f){this.advanced=!0,this.updated=!0;return}var _=this.lastPartSn-f.lastPartSn,p=this.lastPartIndex-f.lastPartIndex;this.updated=this.endSN!==f.endSN||!!p||!!_,this.advanced=this.endSN>f.endSN||_>0||_===0&&p>0,this.updated||this.advanced?this.misses=Math.floor(f.misses*.6):this.misses=f.misses+1,this.availabilityDelay=f.availabilityDelay},M(S,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?(0,O.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||b}},{key:"drift",get:function(){var f=this.driftEndTime-this.driftStartTime;if(f>0){var _=this.driftEnd-this.driftStart;return _*1e3/f}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var f;return(f=this.partList)!==null&&f!==void 0&&f.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var f;return(f=this.fragments)!==null&&f!==void 0&&f.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 f;return(f=this.partList)!==null&&f!==void 0&&f.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var f;return(f=this.partList)!==null&&f!==void 0&&f.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),S}()},"./src/loader/level-key.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{LevelKey:()=>A});var O=T("./src/utils/keysystem-util.ts"),D=T("./src/utils/mediakeys-helper.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/utils/logger.ts"),U=T("./src/utils/numeric-encoding-utils.ts"),b={},A=function(){E.clearKeyUriToKeyIdMap=function(){b={}};function E(f,_,p,v,a){v===void 0&&(v=[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=f,this.uri=_,this.keyFormat=p,this.keyFormatVersions=v,this.iv=a,this.encrypted=f?f!=="NONE":!1,this.isCommonEncryption=this.encrypted&&f!=="AES-128"}var x=E.prototype;return x.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 D.KeySystemFormats.FAIRPLAY:case D.KeySystemFormats.WIDEVINE:case D.KeySystemFormats.PLAYREADY:case D.KeySystemFormats.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},x.getDecryptData=function(_){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof _!="number"&&(this.method==="AES-128"&&!this.iv&&P.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),_=0);var p=S(_),v=new E(this.method,this.uri,"identity",this.keyFormatVersions,p);return v}var a=(0,O.convertDataUriToArrayBytes)(this.uri);if(a)switch(this.keyFormat){case D.KeySystemFormats.WIDEVINE:this.pssh=a,a.length>=22&&(this.keyId=a.subarray(a.length-22,a.length-6));break;case D.KeySystemFormats.PLAYREADY:{var s=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,M.mp4pssh)(s,null,a);var n=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),d=String.fromCharCode.apply(null,Array.from(n)),l=d.substring(d.indexOf("<"),d.length),i=new DOMParser,u=i.parseFromString(l,"text/xml"),g=u.getElementsByTagName("KID")[0];if(g){var c=g.childNodes[0]?g.childNodes[0].nodeValue:g.getAttribute("VALUE");if(c){var m=(0,U.base64Decode)(c).subarray(0,16);(0,O.changeEndianness)(m),this.keyId=m}}break}default:{var e=a.subarray(0,16);if(e.length!==16){var r=new Uint8Array(16);r.set(e,16-e.length),e=r}this.keyId=e;break}}if(!this.keyId||this.keyId.byteLength!==16){var t=b[this.uri];if(!t){var o=Object.keys(b).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16);var y=new DataView(t.buffer,12,4);y.setUint32(0,o),b[this.uri]=t}this.keyId=t}return this},E}();function S(E){for(var x=new Uint8Array(16),f=12;f<16;f++)x[f]=E>>8*(15-f)&255;return x}},"./src/loader/load-stats.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{LoadStats:()=>O});var O=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>s});var O=T("./src/polyfills/number.ts"),D=T("./node_modules/url-toolkit/src/url-toolkit.js"),M=T.n(D),P=T("./src/loader/date-range.ts"),U=T("./src/loader/fragment.ts"),b=T("./src/loader/level-details.ts"),A=T("./src/loader/level-key.ts"),S=T("./src/utils/attr-list.ts"),E=T("./src/utils/logger.ts"),x=T("./src/utils/codecs.ts");function f(){return f=Object.assign?Object.assign.bind():function(c){for(var m=1;m<arguments.length;m++){var e=arguments[m];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(c[r]=e[r])}return c},f.apply(this,arguments)}var _=/#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,p=/#EXT-X-MEDIA:(.*)/g,v=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),a=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("|")),s=function(){function c(){}return c.findGroup=function(e,r){for(var t=0;t<e.length;t++){var o=e[t];if(o.id===r)return o}},c.convertAVC1ToAVCOTI=function(e){var r=e.split(".");if(r.length>2){var t=r.shift()+".";return t+=parseInt(r.shift()).toString(16),t+=("000"+parseInt(r.shift()).toString(16)).slice(-4),t}return e},c.resolve=function(e,r){return(0,D.buildAbsoluteURL)(r,e,{alwaysNormalize:!0})},c.parseMasterPlaylist=function(e,r){var t=[],o=[],y={},h=[],L=!1;_.lastIndex=0;for(var R;(R=_.exec(e))!=null;)if(R[1]){var I,k=new S.AttrList(R[1]),F={attrs:k,bitrate:k.decimalInteger("AVERAGE-BANDWIDTH")||k.decimalInteger("BANDWIDTH"),name:k.NAME,url:c.resolve(R[2],r)},W=k.decimalResolution("RESOLUTION");W&&(F.width=W.width,F.height=W.height),d((k.CODECS||"").split(/[ ,]+/).filter(function(ee){return ee}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=c.convertAVC1ToAVCOTI(F.videoCodec)),(I=F.unknownCodecs)!==null&&I!==void 0&&I.length||o.push(F),t.push(F)}else if(R[3]){var K=new S.AttrList(R[3]);K["DATA-ID"]&&(L=!0,y[K["DATA-ID"]]=K)}else if(R[4]){var H=R[4],Y=n(H,r);Y.encrypted&&Y.isSupported()?h.push(Y):E.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+H+'"')}var q=o.length>0&&o.length<t.length;return{levels:q?o:t,sessionData:L?y:null,sessionKeys:h.length?h:null}},c.parseMasterPlaylistMedia=function(e,r,t,o){o===void 0&&(o=[]);var y,h=[],L=0;for(p.lastIndex=0;(y=p.exec(e))!==null;){var R=new S.AttrList(y[1]);if(R.TYPE===t){var I={attrs:R,bitrate:0,id:L++,groupId:R["GROUP-ID"],instreamId:R["INSTREAM-ID"],name:R.NAME||R.LANGUAGE||"",type:t,default:R.bool("DEFAULT"),autoselect:R.bool("AUTOSELECT"),forced:R.bool("FORCED"),lang:R.LANGUAGE,url:R.URI?c.resolve(R.URI,r):""};if(o.length){var k=c.findGroup(o,I.groupId)||o[0];l(I,k,"audioCodec"),l(I,k,"textCodec")}h.push(I)}}return h},c.parseLevelPlaylist=function(e,r,t,o,y){var h=new b.LevelDetails(r),L=h.fragments,R=null,I=0,k=0,F=0,W=0,K=null,H=new U.Fragment(o,r),Y,q,ee,ae=-1,re=!1;for(v.lastIndex=0,h.m3u8=e;(Y=v.exec(e))!==null;){re&&(re=!1,H=new U.Fragment(o,r),H.start=F,H.sn=I,H.cc=W,H.level=t,R&&(H.initSegment=R,H.rawProgramDateTime=R.rawProgramDateTime,R.rawProgramDateTime=null));var se=Y[1];if(se){H.duration=parseFloat(se);var le=(" "+Y[2]).slice(1);H.title=le||null,H.tagList.push(le?["INF",se,le]:["INF",se])}else if(Y[3]){if((0,O.isFiniteNumber)(H.duration)){if(H.start=F,ee){H.levelkeys=ee;var de=h.encryptedFragments;H.levelkeys&&Object.keys(H.levelkeys).some(function(nt){return H.levelkeys[nt].isCommonEncryption})&&(!de.length||de[de.length-1].levelkeys!==ee)&&de.push(H)}H.sn=I,H.level=t,H.cc=W,H.urlId=y,L.push(H),H.relurl=(" "+Y[3]).slice(1),u(H,K),K=H,F+=H.duration,I++,k=0,re=!0}}else if(Y[4]){var ue=(" "+Y[4]).slice(1);K?H.setByteRange(ue,K):H.setByteRange(ue)}else if(Y[5])H.rawProgramDateTime=(" "+Y[5]).slice(1),H.tagList.push(["PROGRAM-DATE-TIME",H.rawProgramDateTime]),ae===-1&&(ae=L.length);else{if(Y=Y[0].match(a),!Y){E.logger.warn("No matches on slow regex match for level playlist!");continue}for(q=1;q<Y.length&&typeof Y[q]=="undefined";q++);var fe=(" "+Y[q]).slice(1),ce=(" "+Y[q+1]).slice(1),be=Y[q+2]?(" "+Y[q+2]).slice(1):"";switch(fe){case"PLAYLIST-TYPE":h.type=ce.toUpperCase();break;case"MEDIA-SEQUENCE":I=h.startSN=parseInt(ce);break;case"SKIP":{var Pe=new S.AttrList(ce),we=Pe.decimalInteger("SKIPPED-SEGMENTS");if((0,O.isFiniteNumber)(we)){h.skippedSegments=we;for(var pe=we;pe--;)L.unshift(null);I+=we}var Me=Pe.enumeratedString("RECENTLY-REMOVED-DATERANGES");Me&&(h.recentlyRemovedDateranges=Me.split(" "));break}case"TARGETDURATION":h.targetduration=parseFloat(ce);break;case"VERSION":h.version=parseInt(ce);break;case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"#":(ce||be)&&H.tagList.push(be?[ce,be]:[ce]);break;case"DISCONTINUITY":W++,H.tagList.push(["DIS"]);break;case"GAP":H.tagList.push([fe]);break;case"BITRATE":H.tagList.push([fe,ce]);break;case"DATERANGE":{var Re=new S.AttrList(ce),ke=new P.DateRange(Re,h.dateRanges[Re.ID]);ke.isValid||h.skippedSegments?h.dateRanges[ke.id]=ke:E.logger.warn('Ignoring invalid DATERANGE tag: "'+ce+'"'),H.tagList.push(["EXT-X-DATERANGE",ce]);break}case"DISCONTINUITY-SEQUENCE":W=parseInt(ce);break;case"KEY":{var Le=n(ce,r);if(Le.isSupported()){if(Le.method==="NONE"){ee=void 0;break}ee||(ee={}),ee[Le.keyFormat]&&(ee=f({},ee)),ee[Le.keyFormat]=Le}else E.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+ce+'"');break}case"START":{var Ue=new S.AttrList(ce),He=Ue.decimalFloatingPoint("TIME-OFFSET");(0,O.isFiniteNumber)(He)&&(h.startTimeOffset=He);break}case"MAP":{var Be=new S.AttrList(ce);if(H.duration){var Je=new U.Fragment(o,r);g(Je,Be,t,ee),R=Je,H.initSegment=R,R.rawProgramDateTime&&!H.rawProgramDateTime&&(H.rawProgramDateTime=R.rawProgramDateTime)}else g(H,Be,t,ee),R=H,re=!0;break}case"SERVER-CONTROL":{var qe=new S.AttrList(ce);h.canBlockReload=qe.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=qe.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&qe.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=qe.optionalFloat("PART-HOLD-BACK",0),h.holdBack=qe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var st=new S.AttrList(ce);h.partTarget=st.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Ze=h.partList;Ze||(Ze=h.partList=[]);var ot=k>0?Ze[Ze.length-1]:void 0,lt=k++,tt=new U.Part(new S.AttrList(ce),H,r,lt,ot);Ze.push(tt),H.duration+=tt.duration;break}case"PRELOAD-HINT":{var je=new S.AttrList(ce);h.preloadHint=je;break}case"RENDITION-REPORT":{var Ve=new S.AttrList(ce);h.renditionReports=h.renditionReports||[],h.renditionReports.push(Ve);break}default:E.logger.warn("line parsed but not handled: "+Y);break}}}K&&!K.relurl?(L.pop(),F-=K.duration,h.partList&&(h.fragmentHint=K)):h.partList&&(u(H,K),H.cc=W,h.fragmentHint=H);var rt=L.length,gt=L[0],Ne=L[rt-1];if(F+=h.skippedSegments*h.targetduration,F>0&&rt&&Ne){h.averagetargetduration=F/rt;var it=Ne.sn;h.endSN=it!=="initSegment"?it:0,h.live||(Ne.endList=!0),gt&&(h.startCC=gt.cc)}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(F+=h.fragmentHint.duration),h.totalduration=F,h.endCC=W,ae>0&&i(L,ae),h},c}();function n(c,m){var e,r,t=new S.AttrList(c),o=(e=t.enumeratedString("METHOD"))!=null?e:"",y=t.URI,h=t.hexadecimalInteger("IV"),L=t.enumeratedString("KEYFORMATVERSIONS"),R=(r=t.enumeratedString("KEYFORMAT"))!=null?r:"identity";y&&t.IV&&!h&&E.logger.error("Invalid IV: "+t.IV);var I=y?s.resolve(y,m):"",k=(L||"1").split("/").map(Number).filter(Number.isFinite);return new A.LevelKey(o,I,R,k,h)}function d(c,m){["video","audio","text"].forEach(function(e){var r=c.filter(function(o){return(0,x.isCodecType)(o,e)});if(r.length){var t=r.filter(function(o){return o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0});m[e+"Codec"]=t.length>0?t[0]:r[0],c=c.filter(function(o){return r.indexOf(o)===-1})}}),m.unknownCodecs=c}function l(c,m,e){var r=m[e];r&&(c[e]=r)}function i(c,m){for(var e=c[m],r=m;r--;){var t=c[r];if(!t)return;t.programDateTime=e.programDateTime-t.duration*1e3,e=t}}function u(c,m){c.rawProgramDateTime?c.programDateTime=Date.parse(c.rawProgramDateTime):m!=null&&m.programDateTime&&(c.programDateTime=m.endProgramDateTime),(0,O.isFiniteNumber)(c.programDateTime)||(c.programDateTime=null,c.rawProgramDateTime=null)}function g(c,m,e,r){c.relurl=m.URI,m.BYTERANGE&&c.setByteRange(m.BYTERANGE),c.level=e,c.sn="initSegment",r&&(c.levelkeys=r),c.initSegment=null}},"./src/loader/playlist-loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>f});var O=T("./src/polyfills/number.ts"),D=T("./src/events.ts"),M=T("./src/errors.ts"),P=T("./src/utils/logger.ts"),U=T("./src/loader/m3u8-parser.ts"),b=T("./src/types/loader.ts"),A=T("./src/utils/attr-list.ts");function S(_){var p=_.type;switch(p){case b.PlaylistContextType.AUDIO_TRACK:return b.PlaylistLevelType.AUDIO;case b.PlaylistContextType.SUBTITLE_TRACK:return b.PlaylistLevelType.SUBTITLE;default:return b.PlaylistLevelType.MAIN}}function E(_,p){var v=_.url;return(v===void 0||v.indexOf("data:")===0)&&(v=p.url),v}var x=function(){function _(v){this.hls=void 0,this.loaders=Object.create(null),this.hls=v,this.registerListeners()}var p=_.prototype;return p.startLoad=function(a){},p.stopLoad=function(){this.destroyInternalLoaders()},p.registerListeners=function(){var a=this.hls;a.on(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.on(D.Events.LEVEL_LOADING,this.onLevelLoading,this),a.on(D.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.on(D.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.unregisterListeners=function(){var a=this.hls;a.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(D.Events.LEVEL_LOADING,this.onLevelLoading,this),a.off(D.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),a.off(D.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},p.createInternalLoader=function(a){var s=this.hls.config,n=s.pLoader,d=s.loader,l=n||d,i=new l(s);return a.loader=i,this.loaders[a.type]=i,i},p.getInternalLoader=function(a){return this.loaders[a.type]},p.resetInternalLoader=function(a){this.loaders[a]&&delete this.loaders[a]},p.destroyInternalLoaders=function(){for(var a in this.loaders){var s=this.loaders[a];s&&s.destroy(),this.resetInternalLoader(a)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(a,s){var n=s.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:b.PlaylistContextType.MANIFEST,url:n,deliveryDirectives:null})},p.onLevelLoading=function(a,s){var n=s.id,d=s.level,l=s.url,i=s.deliveryDirectives;this.load({id:n,groupId:null,level:d,responseType:"text",type:b.PlaylistContextType.LEVEL,url:l,deliveryDirectives:i})},p.onAudioTrackLoading=function(a,s){var n=s.id,d=s.groupId,l=s.url,i=s.deliveryDirectives;this.load({id:n,groupId:d,level:null,responseType:"text",type:b.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:i})},p.onSubtitleTrackLoading=function(a,s){var n=s.id,d=s.groupId,l=s.url,i=s.deliveryDirectives;this.load({id:n,groupId:d,level:null,responseType:"text",type:b.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:i})},p.load=function(a){var s,n=this.hls.config,d=this.getInternalLoader(a);if(d){var l=d.context;if(l&&l.url===a.url){P.logger.trace("[playlist-loader]: playlist request ongoing");return}P.logger.log("[playlist-loader]: aborting previous loader for type: "+a.type),d.abort()}var i,u,g,c;switch(a.type){case b.PlaylistContextType.MANIFEST:i=n.manifestLoadingMaxRetry,u=n.manifestLoadingTimeOut,g=n.manifestLoadingRetryDelay,c=n.manifestLoadingMaxRetryTimeout;break;case b.PlaylistContextType.LEVEL:case b.PlaylistContextType.AUDIO_TRACK:case b.PlaylistContextType.SUBTITLE_TRACK:i=0,u=n.levelLoadingTimeOut;break;default:i=n.levelLoadingMaxRetry,u=n.levelLoadingTimeOut,g=n.levelLoadingRetryDelay,c=n.levelLoadingMaxRetryTimeout;break}if(d=this.createInternalLoader(a),(s=a.deliveryDirectives)!==null&&s!==void 0&&s.part){var m;if(a.type===b.PlaylistContextType.LEVEL&&a.level!==null?m=this.hls.levels[a.level].details:a.type===b.PlaylistContextType.AUDIO_TRACK&&a.id!==null?m=this.hls.audioTracks[a.id].details:a.type===b.PlaylistContextType.SUBTITLE_TRACK&&a.id!==null&&(m=this.hls.subtitleTracks[a.id].details),m){var e=m.partTarget,r=m.targetduration;e&&r&&(u=Math.min(Math.max(e*3,r*.8)*1e3,u))}}var t={timeout:u,maxRetry:i,retryDelay:g,maxRetryDelay:c,highWaterMark:0},o={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};d.load(a,t,o)},p.loadsuccess=function(a,s,n,d){d===void 0&&(d=null),this.resetInternalLoader(n.type);var l=a.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,n,"no EXTM3U delimiter",d);return}s.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,s,n,d):this.handleMasterPlaylist(a,s,n,d)},p.loaderror=function(a,s,n){n===void 0&&(n=null),this.handleNetworkError(s,n,!1,a)},p.loadtimeout=function(a,s,n){n===void 0&&(n=null),this.handleNetworkError(s,n,!0)},p.handleMasterPlaylist=function(a,s,n,d){var l=this.hls,i=a.data,u=E(a,n),g=U.default.parseMasterPlaylist(i,u),c=g.levels,m=g.sessionData,e=g.sessionKeys;if(!c.length){this.handleManifestParsingError(a,n,"no level found in manifest",d);return}var r=c.map(function(R){return{id:R.attrs.AUDIO,audioCodec:R.audioCodec}}),t=c.map(function(R){return{id:R.attrs.SUBTITLES,textCodec:R.textCodec}}),o=U.default.parseMasterPlaylistMedia(i,u,"AUDIO",r),y=U.default.parseMasterPlaylistMedia(i,u,"SUBTITLES",t),h=U.default.parseMasterPlaylistMedia(i,u,"CLOSED-CAPTIONS");if(o.length){var L=o.some(function(R){return!R.url});!L&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(P.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),o.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new A.AttrList({}),bitrate:0,url:""}))}l.trigger(D.Events.MANIFEST_LOADED,{levels:c,audioTracks:o,subtitles:y,captions:h,url:u,stats:s,networkDetails:d,sessionData:m,sessionKeys:e})},p.handleTrackOrLevelPlaylist=function(a,s,n,d){var l=this.hls,i=n.id,u=n.level,g=n.type,c=E(a,n),m=(0,O.isFiniteNumber)(i)?i:0,e=(0,O.isFiniteNumber)(u)?u:m,r=S(n),t=U.default.parseLevelPlaylist(a.data,c,e,r,m);if(!t.fragments.length){l.trigger(D.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:c,reason:"no fragments found in level",level:typeof n.level=="number"?n.level:void 0});return}if(g===b.PlaylistContextType.MANIFEST){var o={attrs:new A.AttrList({}),bitrate:0,details:t,name:"",url:c};l.trigger(D.Events.MANIFEST_LOADED,{levels:[o],audioTracks:[],url:c,stats:s,networkDetails:d,sessionData:null,sessionKeys:null})}s.parsing.end=performance.now(),n.levelDetails=t,this.handlePlaylistLoaded(a,s,n,d)},p.handleManifestParsingError=function(a,s,n,d){this.hls.trigger(D.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:s.type===b.PlaylistContextType.MANIFEST,url:a.url,reason:n,response:a,context:s,networkDetails:d})},p.handleNetworkError=function(a,s,n,d){n===void 0&&(n=!1),P.logger.warn("[playlist-loader]: A network "+(n?"timeout":"error")+" occurred while loading "+a.type+" level: "+a.level+" id: "+a.id+' group-id: "'+a.groupId+'"');var l=M.ErrorDetails.UNKNOWN,i=!1,u=this.getInternalLoader(a);switch(a.type){case b.PlaylistContextType.MANIFEST:l=n?M.ErrorDetails.MANIFEST_LOAD_TIMEOUT:M.ErrorDetails.MANIFEST_LOAD_ERROR,i=!0;break;case b.PlaylistContextType.LEVEL:l=n?M.ErrorDetails.LEVEL_LOAD_TIMEOUT:M.ErrorDetails.LEVEL_LOAD_ERROR,i=!1;break;case b.PlaylistContextType.AUDIO_TRACK:l=n?M.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:M.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,i=!1;break;case b.PlaylistContextType.SUBTITLE_TRACK:l=n?M.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:M.ErrorDetails.SUBTITLE_LOAD_ERROR,i=!1;break}u&&this.resetInternalLoader(a.type);var g={type:M.ErrorTypes.NETWORK_ERROR,details:l,fatal:i,url:a.url,loader:u,context:a,networkDetails:s};d&&(g.response=d),this.hls.trigger(D.Events.ERROR,g)},p.handlePlaylistLoaded=function(a,s,n,d){var l=n.type,i=n.level,u=n.id,g=n.groupId,c=n.loader,m=n.levelDetails,e=n.deliveryDirectives;if(!(m!=null&&m.targetduration)){this.handleManifestParsingError(a,n,"invalid target duration",d);return}if(!!c)switch(m.live&&(c.getCacheAge&&(m.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(m.ageHeader))&&(m.ageHeader=0)),l){case b.PlaylistContextType.MANIFEST:case b.PlaylistContextType.LEVEL:this.hls.trigger(D.Events.LEVEL_LOADED,{details:m,level:i||0,id:u||0,stats:s,networkDetails:d,deliveryDirectives:e});break;case b.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(D.Events.AUDIO_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:s,networkDetails:d,deliveryDirectives:e});break;case b.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(D.Events.SUBTITLE_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:s,networkDetails:d,deliveryDirectives:e});break}},_}();let f=x},"./src/polyfills/number.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{MAX_SAFE_INTEGER:()=>D,isFiniteNumber:()=>O});var O=Number.isFinite||function(M){return typeof M=="number"&&isFinite(M)},D=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O=function(){function M(){}return M.getSilentFrame=function(U,b){switch(U){case"mp4a.40.2":if(b===1)return new Uint8Array([0,200,0,128,35,128]);if(b===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(b===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(b===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(b===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(b===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(b===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(b===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(b===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},M}();let D=O},"./src/remux/mp4-generator.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>M});var O=Math.pow(2,32)-1,D=function(){function P(){}return P.init=function(){P.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var b;for(b in P.types)P.types.hasOwnProperty(b)&&(P.types[b]=[b.charCodeAt(0),b.charCodeAt(1),b.charCodeAt(2),b.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]),S=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]);P.HDLR_TYPES={video:A,audio:S};var E=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),x=new Uint8Array([0,0,0,0,0,0,0,0]);P.STTS=P.STSC=P.STCO=x,P.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),P.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),P.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),P.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var f=new Uint8Array([105,115,111,109]),_=new Uint8Array([97,118,99,49]),p=new Uint8Array([0,0,0,1]);P.FTYP=P.box(P.types.ftyp,f,p,f,_),P.DINF=P.box(P.types.dinf,P.box(P.types.dref,E))},P.box=function(b){for(var A=8,S=arguments.length,E=new Array(S>1?S-1:0),x=1;x<S;x++)E[x-1]=arguments[x];for(var f=E.length,_=f;f--;)A+=E[f].byteLength;var p=new Uint8Array(A);for(p[0]=A>>24&255,p[1]=A>>16&255,p[2]=A>>8&255,p[3]=A&255,p.set(b,4),f=0,A=8;f<_;f++)p.set(E[f],A),A+=E[f].byteLength;return p},P.hdlr=function(b){return P.box(P.types.hdlr,P.HDLR_TYPES[b])},P.mdat=function(b){return P.box(P.types.mdat,b)},P.mdhd=function(b,A){A*=b;var S=Math.floor(A/(O+1)),E=Math.floor(A%(O+1));return P.box(P.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,b>>24&255,b>>16&255,b>>8&255,b&255,S>>24,S>>16&255,S>>8&255,S&255,E>>24,E>>16&255,E>>8&255,E&255,85,196,0,0]))},P.mdia=function(b){return P.box(P.types.mdia,P.mdhd(b.timescale,b.duration),P.hdlr(b.type),P.minf(b))},P.mfhd=function(b){return P.box(P.types.mfhd,new Uint8Array([0,0,0,0,b>>24,b>>16&255,b>>8&255,b&255]))},P.minf=function(b){return b.type==="audio"?P.box(P.types.minf,P.box(P.types.smhd,P.SMHD),P.DINF,P.stbl(b)):P.box(P.types.minf,P.box(P.types.vmhd,P.VMHD),P.DINF,P.stbl(b))},P.moof=function(b,A,S){return P.box(P.types.moof,P.mfhd(b),P.traf(S,A))},P.moov=function(b){for(var A=b.length,S=[];A--;)S[A]=P.trak(b[A]);return P.box.apply(null,[P.types.moov,P.mvhd(b[0].timescale,b[0].duration)].concat(S).concat(P.mvex(b)))},P.mvex=function(b){for(var A=b.length,S=[];A--;)S[A]=P.trex(b[A]);return P.box.apply(null,[P.types.mvex].concat(S))},P.mvhd=function(b,A){A*=b;var S=Math.floor(A/(O+1)),E=Math.floor(A%(O+1)),x=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,b>>24&255,b>>16&255,b>>8&255,b&255,S>>24,S>>16&255,S>>8&255,S&255,E>>24,E>>16&255,E>>8&255,E&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return P.box(P.types.mvhd,x)},P.sdtp=function(b){var A=b.samples||[],S=new Uint8Array(4+A.length),E,x;for(E=0;E<A.length;E++)x=A[E].flags,S[E+4]=x.dependsOn<<4|x.isDependedOn<<2|x.hasRedundancy;return P.box(P.types.sdtp,S)},P.stbl=function(b){return P.box(P.types.stbl,P.stsd(b),P.box(P.types.stts,P.STTS),P.box(P.types.stsc,P.STSC),P.box(P.types.stsz,P.STSZ),P.box(P.types.stco,P.STCO))},P.avc1=function(b){var A=[],S=[],E,x,f;for(E=0;E<b.sps.length;E++)x=b.sps[E],f=x.byteLength,A.push(f>>>8&255),A.push(f&255),A=A.concat(Array.prototype.slice.call(x));for(E=0;E<b.pps.length;E++)x=b.pps[E],f=x.byteLength,S.push(f>>>8&255),S.push(f&255),S=S.concat(Array.prototype.slice.call(x));var _=P.box(P.types.avcC,new Uint8Array([1,A[3],A[4],A[5],255,224|b.sps.length].concat(A).concat([b.pps.length]).concat(S))),p=b.width,v=b.height,a=b.pixelRatio[0],s=b.pixelRatio[1];return P.box(P.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,p>>8&255,p&255,v>>8&255,v&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),_,P.box(P.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),P.box(P.types.pasp,new Uint8Array([a>>24,a>>16&255,a>>8&255,a&255,s>>24,s>>16&255,s>>8&255,s&255])))},P.esds=function(b){var A=b.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(b.config).concat([6,1,2]))},P.mp4a=function(b){var A=b.samplerate;return P.box(P.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,b.channelCount,0,16,0,0,0,0,A>>8&255,A&255,0,0]),P.box(P.types.esds,P.esds(b)))},P.mp3=function(b){var A=b.samplerate;return P.box(P.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,b.channelCount,0,16,0,0,0,0,A>>8&255,A&255,0,0]))},P.stsd=function(b){return b.type==="audio"?b.segmentCodec==="mp3"&&b.codec==="mp3"?P.box(P.types.stsd,P.STSD,P.mp3(b)):P.box(P.types.stsd,P.STSD,P.mp4a(b)):P.box(P.types.stsd,P.STSD,P.avc1(b))},P.tkhd=function(b){var A=b.id,S=b.duration*b.timescale,E=b.width,x=b.height,f=Math.floor(S/(O+1)),_=Math.floor(S%(O+1));return P.box(P.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,A&255,0,0,0,0,f>>24,f>>16&255,f>>8&255,f&255,_>>24,_>>16&255,_>>8&255,_&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,E>>8&255,E&255,0,0,x>>8&255,x&255,0,0]))},P.traf=function(b,A){var S=P.sdtp(b),E=b.id,x=Math.floor(A/(O+1)),f=Math.floor(A%(O+1));return P.box(P.types.traf,P.box(P.types.tfhd,new Uint8Array([0,0,0,0,E>>24,E>>16&255,E>>8&255,E&255])),P.box(P.types.tfdt,new Uint8Array([1,0,0,0,x>>24,x>>16&255,x>>8&255,x&255,f>>24,f>>16&255,f>>8&255,f&255])),P.trun(b,S.length+16+20+8+16+8+8),S)},P.trak=function(b){return b.duration=b.duration||4294967295,P.box(P.types.trak,P.tkhd(b),P.mdia(b))},P.trex=function(b){var A=b.id;return P.box(P.types.trex,new Uint8Array([0,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},P.trun=function(b,A){var S=b.samples||[],E=S.length,x=12+16*E,f=new Uint8Array(x),_,p,v,a,s,n;for(A+=8+x,f.set([b.type==="video"?1:0,0,15,1,E>>>24&255,E>>>16&255,E>>>8&255,E&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255],0),_=0;_<E;_++)p=S[_],v=p.duration,a=p.size,s=p.flags,n=p.cts,f.set([v>>>24&255,v>>>16&255,v>>>8&255,v&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,s.degradPrio&240<<8,s.degradPrio&15,n>>>24&255,n>>>16&255,n>>>8&255,n&255],12+16*_);return P.box(P.types.trun,f)},P.initSegment=function(b){P.types||P.init();var A=P.moov(b),S=new Uint8Array(P.FTYP.byteLength+A.byteLength);return S.set(P.FTYP),S.set(A,P.FTYP.byteLength),S},P}();D.types=void 0,D.HDLR_TYPES=void 0,D.STTS=void 0,D.STSC=void 0,D.STCO=void 0,D.STSZ=void 0,D.VMHD=void 0,D.SMHD=void 0,D.STSD=void 0,D.FTYP=void 0,D.DINF=void 0;let M=D},"./src/remux/mp4-remuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>a,flushTextTrackMetadataCueSamples:()=>d,flushTextTrackUserdataCueSamples:()=>l,normalizePts:()=>s});var O=T("./src/polyfills/number.ts"),D=T("./src/remux/aac-helper.ts"),M=T("./src/remux/mp4-generator.ts"),P=T("./src/events.ts"),U=T("./src/errors.ts"),b=T("./src/utils/logger.ts"),A=T("./src/types/loader.ts"),S=T("./src/utils/timescale-conversion.ts");function E(){return E=Object.assign?Object.assign.bind():function(g){for(var c=1;c<arguments.length;c++){var m=arguments[c];for(var e in m)Object.prototype.hasOwnProperty.call(m,e)&&(g[e]=m[e])}return g},E.apply(this,arguments)}var x=10*1e3,f=1024,_=1152,p=null,v=null,a=function(){function g(m,e,r,t){if(t===void 0&&(t=""),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=m,this.config=e,this.typeSupported=r,this.ISGenerated=!1,p===null){var o=navigator.userAgent||"",y=o.match(/Chrome\/(\d+)/i);p=y?parseInt(y[1]):0}if(v===null){var h=navigator.userAgent.match(/Safari\/(\d+)/i);v=h?parseInt(h[1]):0}}var c=g.prototype;return c.destroy=function(){},c.resetTimeStamp=function(e){b.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},c.resetNextTimestamp=function(){b.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},c.resetInitSegment=function(){b.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},c.getVideoStartPts=function(e){var r=!1,t=e.reduce(function(o,y){var h=y.pts-o;return h<-4294967296?(r=!0,s(o,y.pts)):h>0?o:y.pts},e[0].pts);return r&&b.logger.debug("PTS rollover detected"),t},c.remux=function(e,r,t,o,y,h,L,R){var I,k,F,W,K,H,Y=y,q=y,ee=e.pid>-1,ae=r.pid>-1,re=r.samples.length,se=e.samples.length>0,le=L&&re>0||re>1,de=(!ee||se)&&(!ae||le)||this.ISGenerated||L;if(de){this.ISGenerated||(F=this.generateIS(e,r,y));var ue=this.isVideoContiguous,fe=-1,ce;if(le&&(fe=n(r.samples),!ue&&this.config.forceKeyFrameOnDiscontinuity))if(H=!0,fe>0){b.logger.warn("[mp4-remuxer]: Dropped "+fe+" out of "+re+" video samples due to a missing keyframe");var be=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(fe),r.dropped+=fe,q+=(r.samples[0].pts-be)/r.inputTimeScale,ce=q}else fe===-1&&(b.logger.warn("[mp4-remuxer]: No keyframe found out of "+re+" video samples"),H=!1);if(this.ISGenerated){if(se&&le){var Pe=this.getVideoStartPts(r.samples),we=s(e.samples[0].pts,Pe)-Pe,pe=we/r.inputTimeScale;Y+=Math.max(0,pe),q+=Math.max(0,-pe)}if(se){if(e.samplerate||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),F=this.generateIS(e,r,y)),k=this.remuxAudio(e,Y,this.isAudioContiguous,h,ae||le||R===A.PlaylistLevelType.AUDIO?q:void 0),le){var Me=k?k.endPTS-k.startPTS:0;r.inputTimeScale||(b.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),F=this.generateIS(e,r,y)),I=this.remuxVideo(r,q,ue,Me)}}else le&&(I=this.remuxVideo(r,q,ue,0));I&&(I.firstKeyFrame=fe,I.independent=fe!==-1,I.firstKeyFramePTS=ce)}}return this.ISGenerated&&(t.samples.length&&(K=d(t,y,this._initPTS,this._initDTS)),o.samples.length&&(W=l(o,y,this._initPTS))),{audio:k,video:I,initSegment:F,independent:H,text:W,id3:K}},c.generateIS=function(e,r,t){var o=e.samples,y=r.samples,h=this.typeSupported,L={},R=!(0,O.isFiniteNumber)(this._initPTS),I="audio/mp4",k,F,W;if(R&&(k=F=1/0),e.config&&o.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":h.mpeg?(I="audio/mpeg",e.codec=""):h.mp3&&(e.codec="mp3");break}L.audio={id:"audio",container:I,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&h.mpeg?new Uint8Array(0):M.default.initSegment([e]),metadata:{channelCount:e.channelCount}},R&&(W=e.inputTimeScale,k=F=o[0].pts-Math.round(W*t))}if(r.sps&&r.pps&&y.length&&(r.timescale=r.inputTimeScale,L.video={id:"main",container:"video/mp4",codec:r.codec,initSegment:M.default.initSegment([r]),metadata:{width:r.width,height:r.height}},R)){W=r.inputTimeScale;var K=this.getVideoStartPts(y),H=Math.round(W*t);F=Math.min(F,s(y[0].dts,K)-H),k=Math.min(k,K-H)}if(Object.keys(L).length)return this.ISGenerated=!0,R&&(this._initPTS=k,this._initDTS=F),{tracks:L,initPTS:k,timescale:W}},c.remuxVideo=function(e,r,t,o){var y=e.inputTimeScale,h=e.samples,L=[],R=h.length,I=this._initPTS,k=this.nextAvcDts,F=8,W=this.videoSampleDuration,K,H,Y=Number.POSITIVE_INFINITY,q=Number.NEGATIVE_INFINITY,ee=!1;if(!t||k===null){var ae=r*y,re=h[0].pts-s(h[0].dts,h[0].pts);k=ae-re}for(var se=0;se<R;se++){var le=h[se];le.pts=s(le.pts-I,k),le.dts=s(le.dts-I,k),le.dts<h[se>0?se-1:se].dts&&(ee=!0)}ee&&h.sort(function(vt,Xt){var Cr=vt.dts-Xt.dts,Mr=vt.pts-Xt.pts;return Cr||Mr}),K=h[0].dts,H=h[h.length-1].dts;var de=H-K,ue=de?Math.round(de/(R-1)):W||e.inputTimeScale/30;if(t){var fe=K-k,ce=fe>ue,be=fe<-1;if((ce||be)&&(ce?b.logger.warn("AVC: "+(0,S.toMsFromMpegTsClock)(fe,!0)+" ms ("+fe+"dts) hole between fragments detected, filling it"):b.logger.warn("AVC: "+(0,S.toMsFromMpegTsClock)(-fe,!0)+" ms ("+fe+"dts) overlapping between fragments detected"),!be||k>h[0].pts)){K=k;var Pe=h[0].pts-fe;h[0].dts=K,h[0].pts=Pe,b.logger.log("Video: First PTS/DTS adjusted: "+(0,S.toMsFromMpegTsClock)(Pe,!0)+"/"+(0,S.toMsFromMpegTsClock)(K,!0)+", delta: "+(0,S.toMsFromMpegTsClock)(fe,!0)+" ms")}}K=Math.max(0,K);for(var we=0,pe=0,Me=0;Me<R;Me++){for(var Re=h[Me],ke=Re.units,Le=ke.length,Ue=0,He=0;He<Le;He++)Ue+=ke[He].data.length;pe+=Ue,we+=Le,Re.length=Ue,Re.dts=Math.max(Re.dts,K),Y=Math.min(Re.pts,Y),q=Math.max(Re.pts,q)}H=h[R-1].dts;var Be=pe+4*we+8,Je;try{Je=new Uint8Array(Be)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Be,reason:"fail allocating video mdat "+Be});return}var qe=new DataView(Je.buffer);qe.setUint32(0,Be),Je.set(M.default.types.mdat,4);for(var st=!1,Ze=Number.POSITIVE_INFINITY,ot=Number.POSITIVE_INFINITY,lt=Number.NEGATIVE_INFINITY,tt=Number.NEGATIVE_INFINITY,je=0;je<R;je++){for(var Ve=h[je],rt=Ve.units,gt=0,Ne=0,it=rt.length;Ne<it;Ne++){var nt=rt[Ne],Lt=nt.data,At=nt.data.byteLength;qe.setUint32(F,At),F+=4,Je.set(Lt,F),F+=At,gt+=4+At}var Dt=void 0;if(je<R-1)W=h[je+1].dts-Ve.dts,Dt=h[je+1].pts-Ve.pts;else{var Gt=this.config,Pt=je>0?Ve.dts-h[je-1].dts:ue;if(Dt=je>0?Ve.pts-h[je-1].pts:ue,Gt.stretchShortVideoTrack&&this.nextAudioPts!==null){var hr=Math.floor(Gt.maxBufferHole*y),Ht=(o?Y+o*y:this.nextAudioPts)-Ve.pts;Ht>hr?(W=Ht-Pt,W<0?W=Pt:st=!0,b.logger.log("[mp4-remuxer]: It is approximately "+Ht/90+" ms to the next segment; using duration "+W/90+" ms for the last video frame.")):W=Pt}else W=Pt}var Pr=Math.round(Ve.pts-Ve.dts);Ze=Math.min(Ze,W),lt=Math.max(lt,W),ot=Math.min(ot,Dt),tt=Math.max(tt,Dt),L.push(new i(Ve.key,W,gt,Pr))}if(L.length){if(p){if(p<70){var jt=L[0].flags;jt.dependsOn=2,jt.isNonSync=0}}else if(v&&tt-ot<lt-Ze&&ue/lt<.025&&L[0].cts===0){b.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Ot=K,ht=0,vr=L.length;ht<vr;ht++){var Vt=Ot+L[ht].duration,gr=Ot+L[ht].cts;if(ht<vr-1){var Yt=Vt+L[ht+1].cts;L[ht].duration=Yt-gr}else L[ht].duration=ht?L[ht-1].duration:ue;L[ht].cts=0,Ot=Vt}}}console.assert(W!==null,"mp4SampleDuration must be computed"),W=st||!W?ue:W,this.nextAvcDts=k=H+W,this.videoSampleDuration=W,this.isVideoContiguous=!0;var Rr=M.default.moof(e.sequenceNumber++,K,E({},e,{samples:L})),Ir="video",Or={data1:Rr,data2:Je,startPTS:Y/y,endPTS:(q+W)/y,startDTS:K/y,endDTS:k/y,type:Ir,hasAudio:!1,hasVideo:!0,nb:L.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(Je.length,"MDAT length must not be zero"),Or},c.remuxAudio=function(e,r,t,o,y){var h=e.inputTimeScale,L=e.samplerate?e.samplerate:h,R=h/L,I=e.segmentCodec==="aac"?f:_,k=I*R,F=this._initPTS,W=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,K=[],H=y!==void 0,Y=e.samples,q=W?0:8,ee=this.nextAudioPts||-1,ae=r*h;if(this.isAudioContiguous=t=t||Y.length&&ee>0&&(o&&Math.abs(ae-ee)<9e3||Math.abs(s(Y[0].pts-F,ae)-ee)<20*k),Y.forEach(function(nt){nt.pts=s(nt.pts-F,ae)}),!t||ee<0){if(Y=Y.filter(function(nt){return nt.pts>=0}),!Y.length)return;y===0?ee=0:o&&!H?ee=Math.max(0,ae):ee=Y[0].pts}if(e.segmentCodec==="aac")for(var re=this.config.maxAudioFramesDrift,se=0,le=ee;se<Y.length;se++){var de=Y[se],ue=de.pts,fe=ue-le,ce=Math.abs(1e3*fe/h);if(fe<=-re*k&&H)se===0&&(b.logger.warn("Audio frame @ "+(ue/h).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*fe/h)+" ms."),this.nextAudioPts=ee=le=ue);else if(fe>=re*k&&ce<x&&H){var be=Math.round(fe/k);le=ue-be*k,le<0&&(be--,le+=k),se===0&&(this.nextAudioPts=ee=le),b.logger.warn("[mp4-remuxer]: Injecting "+be+" audio frame @ "+(le/h).toFixed(3)+"s due to "+Math.round(1e3*fe/h)+" ms gap.");for(var Pe=0;Pe<be;Pe++){var we=Math.max(le,0),pe=D.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);pe||(b.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),pe=de.unit.subarray()),Y.splice(se,0,{unit:pe,pts:we}),le+=k,se++}}de.pts=le,le+=k}for(var Me=null,Re=null,ke,Le=0,Ue=Y.length;Ue--;)Le+=Y[Ue].unit.byteLength;for(var He=0,Be=Y.length;He<Be;He++){var Je=Y[He],qe=Je.unit,st=Je.pts;if(Re!==null){var Ze=K[He-1];Ze.duration=Math.round((st-Re)/R)}else if(t&&e.segmentCodec==="aac"&&(st=ee),Me=st,Le>0){Le+=q;try{ke=new Uint8Array(Le)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:U.ErrorTypes.MUX_ERROR,details:U.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Le,reason:"fail allocating audio mdat "+Le});return}if(!W){var ot=new DataView(ke.buffer);ot.setUint32(0,Le),ke.set(M.default.types.mdat,4)}}else return;ke.set(qe,q);var lt=qe.byteLength;q+=lt,K.push(new i(!0,I,lt,0)),Re=st}var tt=K.length;if(!!tt){var je=K[K.length-1];this.nextAudioPts=ee=Re+R*je.duration;var Ve=W?new Uint8Array(0):M.default.moof(e.sequenceNumber++,Me/R,E({},e,{samples:K}));e.samples=[];var rt=Me/h,gt=ee/h,Ne="audio",it={data1:Ve,data2:ke,startPTS:rt,endPTS:gt,startDTS:rt,endDTS:gt,type:Ne,hasAudio:!0,hasVideo:!1,nb:tt};return this.isAudioContiguous=!0,console.assert(ke.length,"MDAT length must not be zero"),it}},c.remuxEmptyAudio=function(e,r,t,o){var y=e.inputTimeScale,h=e.samplerate?e.samplerate:y,L=y/h,R=this.nextAudioPts,I=(R!==null?R:o.startDTS*y)+this._initDTS,k=o.endDTS*y+this._initDTS,F=L*f,W=Math.ceil((k-I)/F),K=D.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(b.logger.warn("[mp4-remuxer]: remux empty Audio"),!K){b.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var H=[],Y=0;Y<W;Y++){var q=I+Y*F;H.push({unit:K,pts:q,dts:q})}return e.samples=H,this.remuxAudio(e,r,t,!1)},g}();function s(g,c){var m;if(c===null)return g;for(c<g?m=-8589934592:m=8589934592;Math.abs(g-c)>4294967296;)g+=m;return g}function n(g){for(var c=0;c<g.length;c++)if(g[c].key)return c;return-1}function d(g,c,m,e){var r=g.samples.length;if(!!r){for(var t=g.inputTimeScale,o=0;o<r;o++){var y=g.samples[o];y.pts=s(y.pts-m,c*t)/t,y.dts=s(y.dts-e,c*t)/t}var h=g.samples;return g.samples=[],{samples:h}}}function l(g,c,m){var e=g.samples.length;if(!!e){for(var r=g.inputTimeScale,t=0;t<e;t++){var o=g.samples[t];o.pts=s(o.pts-m,c*r)/r}g.samples.sort(function(h,L){return h.pts-L.pts});var y=g.samples;return g.samples=[],{samples:y}}}var i=function(c,m,e,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=m,this.size=e,this.cts=r,this.flags=new u(c)},u=function(c){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=c?2:1,this.isNonSync=c?0:1}},"./src/remux/passthrough-remuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>S});var O=T("./src/polyfills/number.ts"),D=T("./src/remux/mp4-remuxer.ts"),M=T("./src/utils/mp4-tools.ts"),P=T("./src/loader/fragment.ts"),U=T("./src/utils/logger.ts"),b=function(){function E(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var x=E.prototype;return x.destroy=function(){},x.resetTimeStamp=function(_){this.initPTS=_,this.lastEndTime=null},x.resetNextTimestamp=function(){this.lastEndTime=null},x.resetInitSegment=function(_,p,v,a){this.audioCodec=p,this.videoCodec=v,this.generateInitSegment((0,M.patchEncyptionData)(_,a)),this.emitInitSegment=!0},x.generateInitSegment=function(_){var p=this.audioCodec,v=this.videoCodec;if(!_||!_.byteLength){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=(0,M.parseInitSegment)(_);p||(p=A(a.audio,P.ElementaryStreamTypes.AUDIO)),v||(v=A(a.video,P.ElementaryStreamTypes.VIDEO));var s={};a.audio&&a.video?s.audiovideo={container:"video/mp4",codec:p+","+v,initSegment:_,id:"main"}:a.audio?s.audio={container:"audio/mp4",codec:p,initSegment:_,id:"audio"}:a.video?s.video={container:"video/mp4",codec:v,initSegment:_,id:"main"}:U.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=s},x.remux=function(_,p,v,a,s){var n,d=this.initPTS,l=this.lastEndTime,i={audio:void 0,video:void 0,text:a,id3:v,initSegment:void 0};(0,O.isFiniteNumber)(l)||(l=this.lastEndTime=s||0);var u=p.samples;if(!u||!u.length)return i;var g={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(u),c=this.initData),!c||!c.length)return U.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(g.tracks=this.initTracks,this.emitInitSegment=!1);var m=(0,M.getStartDTS)(c,u);(0,O.isFiniteNumber)(d)||(this.initPTS=g.initPTS=d=m-s);var e=(0,M.getDuration)(u,c),r=_?m-d:l,t=r+e;(0,M.offsetStartDTS)(c,u,d),e>0?this.lastEndTime=t:(U.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var o=!!c.audio,y=!!c.video,h="";o&&(h+="audio"),y&&(h+="video");var L={data1:u,startPTS:r,startDTS:r,endPTS:t,endDTS:t,type:h,hasAudio:o,hasVideo:y,nb:1,dropped:0};i.audio=L.type==="audio"?L:void 0,i.video=L.type!=="audio"?L:void 0,i.initSegment=g;var R=(n=this.initPTS)!=null?n:0;return i.id3=(0,D.flushTextTrackMetadataCueSamples)(v,s,R,R),a.samples.length&&(i.text=(0,D.flushTextTrackUserdataCueSamples)(a,s,R)),i},E}();function A(E,x){var f=E==null?void 0:E.codec;return f&&f.length>4?f:f==="hvc1"||f==="hev1"?"hvc1.1.c.L120.90":f==="av01"?"av01.0.04M.08":f==="avc1"||x===P.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let S=b},"./src/task-loop.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});var O=function(){function D(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var M=D.prototype;return M.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},M.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},M.onHandlerDestroyed=function(){},M.hasInterval=function(){return!!this._tickInterval},M.hasNextTick=function(){return!!this._tickTimer},M.setInterval=function(U){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,U),!0)},M.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},M.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},M.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},M.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},M.doTick=function(){},D}()},"./src/types/cmcd.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{CMCDObjectType:()=>D,CMCDStreamType:()=>P,CMCDStreamingFormat:()=>M,CMCDVersion:()=>O});var O=1,D;(function(U){U.MANIFEST="m",U.AUDIO="a",U.VIDEO="v",U.MUXED="av",U.INIT="i",U.CAPTION="c",U.TIMED_TEXT="tt",U.KEY="k",U.OTHER="o"})(D||(D={}));var M;(function(U){U.DASH="d",U.HLS="h",U.SMOOTH="s",U.OTHER="o"})(M||(M={}));var P;(function(U){U.VOD="v",U.LIVE="l"})(P||(P={}))},"./src/types/demuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{MetadataSchema:()=>O});var O;(function(D){D.audioId3="org.id3",D.dateRange="com.apple.quicktime.HLS",D.emsg="https://aomedia.org/emsg/ID3"})(O||(O={}))},"./src/types/level.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{HdcpLevels:()=>U,HlsSkip:()=>b,HlsUrlParameters:()=>S,Level:()=>E,getSkipValue:()=>A});function O(x,f){for(var _=0;_<f.length;_++){var p=f[_];p.enumerable=p.enumerable||!1,p.configurable=!0,"value"in p&&(p.writable=!0),Object.defineProperty(x,M(p.key),p)}}function D(x,f,_){return f&&O(x.prototype,f),_&&O(x,_),Object.defineProperty(x,"prototype",{writable:!1}),x}function M(x){var f=P(x,"string");return typeof f=="symbol"?f:String(f)}function P(x,f){if(typeof x!="object"||x===null)return x;var _=x[Symbol.toPrimitive];if(_!==void 0){var p=_.call(x,f||"default");if(typeof p!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return(f==="string"?String:Number)(x)}var U=["NONE","TYPE-0","TYPE-1","TYPE-2",null],b;(function(x){x.No="",x.Yes="YES",x.v2="v2"})(b||(b={}));function A(x,f){var _=x.canSkipUntil,p=x.canSkipDateRanges,v=x.endSN,a=f!==void 0?f-v:0;return _&&a<_?p?b.v2:b.Yes:b.No}var S=function(){function x(_,p,v){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=_,this.part=p,this.skip=v}var f=x.prototype;return f.addDirectives=function(p){var v=new self.URL(p);return this.msn!==void 0&&v.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&v.searchParams.set("_HLS_part",this.part.toString()),this.skip&&v.searchParams.set("_HLS_skip",this.skip),v.href},x}(),E=function(){function x(f){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=[f.url],this.attrs=f.attrs,this.bitrate=f.bitrate,f.details&&(this.details=f.details),this.id=f.id||0,this.name=f.name,this.width=f.width||0,this.height=f.height||0,this.audioCodec=f.audioCodec,this.videoCodec=f.videoCodec,this.unknownCodecs=f.unknownCodecs,this.codecSet=[f.videoCodec,f.audioCodec].filter(function(_){return _}).join(",").replace(/\.[^.,]+/g,"")}return D(x,[{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(_){var p=_%this.url.length;this._urlId!==p&&(this.details=void 0,this._urlId=p)}}]),x}()},"./src/types/loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{PlaylistContextType:()=>O,PlaylistLevelType:()=>D});var O;(function(M){M.MANIFEST="manifest",M.LEVEL="level",M.AUDIO_TRACK="audioTrack",M.SUBTITLE_TRACK="subtitleTrack"})(O||(O={}));var D;(function(M){M.MAIN="main",M.AUDIO="audio",M.SUBTITLE="subtitle"})(D||(D={}))},"./src/types/transmuxer.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{ChunkMetadata:()=>O});var O=function(P,U,b,A,S,E){A===void 0&&(A=0),S===void 0&&(S=-1),E===void 0&&(E=!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=D(),this.buffering={audio:D(),video:D(),audiovideo:D()},this.level=P,this.sn=U,this.id=b,this.size=A,this.part=S,this.partial=E};function D(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{AttrList:()=>M});var O=/^(\d+)x(\d+)$/,D=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,M=function(){function P(b){typeof b=="string"&&(b=P.parseAttrList(b));for(var A in b)b.hasOwnProperty(A)&&(this[A]=b[A])}var U=P.prototype;return U.decimalInteger=function(A){var S=parseInt(this[A],10);return S>Number.MAX_SAFE_INTEGER?1/0:S},U.hexadecimalInteger=function(A){if(this[A]){var S=(this[A]||"0x").slice(2);S=(S.length&1?"0":"")+S;for(var E=new Uint8Array(S.length/2),x=0;x<S.length/2;x++)E[x]=parseInt(S.slice(x*2,x*2+2),16);return E}else return null},U.hexadecimalIntegerAsNumber=function(A){var S=parseInt(this[A],16);return S>Number.MAX_SAFE_INTEGER?1/0:S},U.decimalFloatingPoint=function(A){return parseFloat(this[A])},U.optionalFloat=function(A,S){var E=this[A];return E?parseFloat(E):S},U.enumeratedString=function(A){return this[A]},U.bool=function(A){return this[A]==="YES"},U.decimalResolution=function(A){var S=O.exec(this[A]);if(S!==null)return{width:parseInt(S[1],10),height:parseInt(S[2],10)}},P.parseAttrList=function(A){var S,E={},x='"';for(D.lastIndex=0;(S=D.exec(A))!==null;){var f=S[2];f.indexOf(x)===0&&f.lastIndexOf(x)===f.length-1&&(f=f.slice(1,-1)),E[S[1]]=f}return E},P}()},"./src/utils/binary-search.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O={search:function(P,U){for(var b=0,A=P.length-1,S=null,E=null;b<=A;){S=(b+A)/2|0,E=P[S];var x=U(E);if(x>0)b=S+1;else if(x<0)A=S-1;else return E}return null}};let D=O},"./src/utils/buffer-helper.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{BufferHelper:()=>M});var O=T("./src/utils/logger.ts"),D={length:0,start:function(){return 0},end:function(){return 0}},M=function(){function P(){}return P.isBuffered=function(b,A){try{if(b){for(var S=P.getBuffered(b),E=0;E<S.length;E++)if(A>=S.start(E)&&A<=S.end(E))return!0}}catch{}return!1},P.bufferInfo=function(b,A,S){try{if(b){var E=P.getBuffered(b),x=[],f;for(f=0;f<E.length;f++)x.push({start:E.start(f),end:E.end(f)});return this.bufferedInfo(x,A,S)}}catch{}return{len:0,start:A,end:A,nextStart:void 0}},P.bufferedInfo=function(b,A,S){A=Math.max(0,A),b.sort(function(i,u){var g=i.start-u.start;return g||u.end-i.end});var E=[];if(S)for(var x=0;x<b.length;x++){var f=E.length;if(f){var _=E[f-1].end;b[x].start-_<S?b[x].end>_&&(E[f-1].end=b[x].end):E.push(b[x])}else E.push(b[x])}else E=b;for(var p=0,v,a=A,s=A,n=0;n<E.length;n++){var d=E[n].start,l=E[n].end;if(A+S>=d&&A<l)a=d,s=l,p=s-A;else if(A+S<d){v=d;break}}return{len:p,start:a||0,end:s||0,nextStart:v}},P.getBuffered=function(b){try{return b.buffered}catch(A){return O.logger.log("failed to get media.buffered",A),D}},P}()},"./src/utils/cea-608-parser.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{CaptionScreen:()=>n,Row:()=>s,default:()=>c});var O=T("./src/utils/logger.ts"),D={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},M=function(e){var r=e;return D.hasOwnProperty(e)&&(r=D[e]),String.fromCharCode(r)},P=15,U=100,b={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},A={17:2,18:4,21:6,22:8,23:10,19:13,20:15},S={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},E={25:2,26:4,29:6,30:8,31:10,27:13,28:15},x=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],f;(function(m){m[m.ERROR=0]="ERROR",m[m.TEXT=1]="TEXT",m[m.WARNING=2]="WARNING",m[m.INFO=2]="INFO",m[m.DEBUG=3]="DEBUG",m[m.DATA=3]="DATA"})(f||(f={}));var _=function(){function m(){this.time=null,this.verboseLevel=f.ERROR}var e=m.prototype;return e.log=function(t,o){if(this.verboseLevel>=t){var y=typeof o=="function"?o():o;O.logger.log(this.time+" ["+t+"] "+y)}},m}(),p=function(e){for(var r=[],t=0;t<e.length;t++)r.push(e[t].toString(16));return r},v=function(){function m(r,t,o,y,h){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=r||"white",this.underline=t||!1,this.italics=o||!1,this.background=y||"black",this.flash=h||!1}var e=m.prototype;return e.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},e.setStyles=function(t){for(var o=["foreground","underline","italics","background","flash"],y=0;y<o.length;y++){var h=o[y];t.hasOwnProperty(h)&&(this[h]=t[h])}},e.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},e.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},e.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},e.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},m}(),a=function(){function m(r,t,o,y,h,L){this.uchar=void 0,this.penState=void 0,this.uchar=r||" ",this.penState=new v(t,o,y,h,L)}var e=m.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(t,o){this.uchar=t,this.penState.copy(o)},e.setPenState=function(t){this.penState.copy(t)},e.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},e.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},e.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},m}(),s=function(){function m(r){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<U;t++)this.chars.push(new a);this.logger=r,this.pos=0,this.currPenState=new v}var e=m.prototype;return e.equals=function(t){for(var o=!0,y=0;y<U;y++)if(!this.chars[y].equals(t.chars[y])){o=!1;break}return o},e.copy=function(t){for(var o=0;o<U;o++)this.chars[o].copy(t.chars[o])},e.isEmpty=function(){for(var t=!0,o=0;o<U;o++)if(!this.chars[o].isEmpty()){t=!1;break}return t},e.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(f.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>U&&(this.logger.log(f.DEBUG,"Too large cursor position "+this.pos),this.pos=U)},e.moveCursor=function(t){var o=this.pos+t;if(t>1)for(var y=this.pos+1;y<o+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(o)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(t){var o=this;t>=144&&this.backSpace();var y=M(t);if(this.pos>=U){this.logger.log(f.ERROR,function(){return"Cannot insert "+t.toString(16)+" ("+y+") at position "+o.pos+". Skipping it!"});return}this.chars[this.pos].setChar(y,this.currPenState),this.moveCursor(1)},e.clearFromPos=function(t){var o;for(o=t;o<U;o++)this.chars[o].reset()},e.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},e.clearToEndOfRow=function(){this.clearFromPos(this.pos)},e.getTextString=function(){for(var t=[],o=!0,y=0;y<U;y++){var h=this.chars[y].uchar;h!==" "&&(o=!1),t.push(h)}return o?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t);var o=this.chars[this.pos];o.setPenState(this.currPenState)},m}(),n=function(){function m(r){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<P;t++)this.rows.push(new s(r));this.logger=r,this.currRow=P-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var e=m.prototype;return e.reset=function(){for(var t=0;t<P;t++)this.rows[t].clear();this.currRow=P-1},e.equals=function(t){for(var o=!0,y=0;y<P;y++)if(!this.rows[y].equals(t.rows[y])){o=!1;break}return o},e.copy=function(t){for(var o=0;o<P;o++)this.rows[o].copy(t.rows[o])},e.isEmpty=function(){for(var t=!0,o=0;o<P;o++)if(!this.rows[o].isEmpty()){t=!1;break}return t},e.backSpace=function(){var t=this.rows[this.currRow];t.backSpace()},e.clearToEndOfRow=function(){var t=this.rows[this.currRow];t.clearToEndOfRow()},e.insertChar=function(t){var o=this.rows[this.currRow];o.insertChar(t)},e.setPen=function(t){var o=this.rows[this.currRow];o.setPenStyles(t)},e.moveCursor=function(t){var o=this.rows[this.currRow];o.moveCursor(t)},e.setCursor=function(t){this.logger.log(f.INFO,"setCursor: "+t);var o=this.rows[this.currRow];o.setCursor(t)},e.setPAC=function(t){this.logger.log(f.INFO,function(){return"pacData = "+JSON.stringify(t)});var o=t.row-1;if(this.nrRollUpRows&&o<this.nrRollUpRows-1&&(o=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==o){for(var y=0;y<P;y++)this.rows[y].clear();var h=this.currRow+1-this.nrRollUpRows,L=this.lastOutputScreen;if(L){var R=L.rows[h].cueStartTime,I=this.logger.time;if(R&&I!==null&&R<I)for(var k=0;k<this.nrRollUpRows;k++)this.rows[o-this.nrRollUpRows+k+1].copy(L.rows[h+k])}}this.currRow=o;var F=this.rows[this.currRow];if(t.indent!==null){var W=t.indent,K=Math.max(W-1,0);F.setCursor(t.indent),t.color=F.chars[K].penState.foreground}var H={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(H)},e.setBkgData=function(t){this.logger.log(f.INFO,function(){return"bkgData = "+JSON.stringify(t)}),this.backSpace(),this.setPen(t),this.insertChar(32)},e.setRollUpRows=function(t){this.nrRollUpRows=t},e.rollUp=function(){var t=this;if(this.nrRollUpRows===null){this.logger.log(f.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(f.TEXT,function(){return t.getDisplayText()});var o=this.currRow+1-this.nrRollUpRows,y=this.rows.splice(o,1)[0];y.clear(),this.rows.splice(this.currRow,0,y),this.logger.log(f.INFO,"Rolling up")},e.getDisplayText=function(t){t=t||!1;for(var o=[],y="",h=-1,L=0;L<P;L++){var R=this.rows[L].getTextString();R&&(h=L+1,t?o.push("Row "+h+": '"+R+"'"):o.push(R.trim()))}return o.length>0&&(t?y="["+o.join(" | ")+"]":y=o.join(`
|
|
22
|
-
`)),y},e.getTextAndFormat=function(){return this.rows},m}(),d=function(){function m(r,t,o){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=r,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new n(o),this.nonDisplayedMemory=new n(o),this.lastOutputScreen=new n(o),this.currRollUpRow=this.displayedMemory.rows[P-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=o}var e=m.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[P-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(t){this.outputFilter=t},e.setPAC=function(t){this.writeScreen.setPAC(t)},e.setBkgData=function(t){this.writeScreen.setBkgData(t)},e.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(f.INFO,function(){return"MODE="+t}),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=t)},e.insertChars=function(t){for(var o=this,y=0;y<t.length;y++)this.writeScreen.insertChar(t[y]);var h=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(f.INFO,function(){return h+": "+o.writeScreen.getDisplayText(!0)}),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(f.TEXT,function(){return"DISPLAYED: "+o.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},e.ccRCL=function(){this.logger.log(f.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},e.ccBS=function(){this.logger.log(f.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},e.ccAOF=function(){},e.ccAON=function(){},e.ccDER=function(){this.logger.log(f.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},e.ccRU=function(t){this.logger.log(f.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},e.ccFON=function(){this.logger.log(f.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},e.ccRDC=function(){this.logger.log(f.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},e.ccTR=function(){this.logger.log(f.INFO,"TR"),this.setMode("MODE_TEXT")},e.ccRTD=function(){this.logger.log(f.INFO,"RTD"),this.setMode("MODE_TEXT")},e.ccEDM=function(){this.logger.log(f.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},e.ccCR=function(){this.logger.log(f.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},e.ccENM=function(){this.logger.log(f.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},e.ccEOC=function(){var t=this;if(this.logger.log(f.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var o=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=o,this.writeScreen=this.nonDisplayedMemory,this.logger.log(f.TEXT,function(){return"DISP: "+t.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},e.ccTO=function(t){this.logger.log(f.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},e.ccMIDROW=function(t){var o={flash:!1};if(o.underline=t%2===1,o.italics=t>=46,o.italics)o.foreground="white";else{var y=Math.floor(t/2)-16,h=["white","green","blue","cyan","red","yellow","magenta"];o.foreground=h[y]}this.logger.log(f.INFO,"MIDROW: "+JSON.stringify(o)),this.writeScreen.setPen(o)},e.outputDataUpdate=function(t){t===void 0&&(t=!1);var o=this.logger.time;o!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=o:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,o,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:o),this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},m}(),l=function(){function m(r,t,o){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new _;this.channels=[null,new d(r,t,y),new d(r+1,o,y)],this.cmdHistory=g(),this.logger=y}var e=m.prototype;return e.getHandler=function(t){return this.channels[t].getHandler()},e.setHandler=function(t,o){this.channels[t].setHandler(o)},e.addData=function(t,o){var y,h,L,R=!1;this.logger.time=t;for(var I=0;I<o.length;I+=2)if(h=o[I]&127,L=o[I+1]&127,!(h===0&&L===0)){if(this.logger.log(f.DATA,"["+p([o[I],o[I+1]])+"] -> ("+p([h,L])+")"),y=this.parseCmd(h,L),y||(y=this.parseMidrow(h,L)),y||(y=this.parsePAC(h,L)),y||(y=this.parseBackgroundAttributes(h,L)),!y&&(R=this.parseChars(h,L),R)){var k=this.currentChannel;if(k&&k>0){var F=this.channels[k];F.insertChars(R)}else this.logger.log(f.WARNING,"No channel found yet. TEXT-MODE?")}!y&&!R&&this.logger.log(f.WARNING,"Couldn't parse cleaned data "+p([h,L])+" orig: "+p([o[I],o[I+1]]))}},e.parseCmd=function(t,o){var y=this.cmdHistory,h=(t===20||t===28||t===21||t===29)&&o>=32&&o<=47,L=(t===23||t===31)&&o>=33&&o<=35;if(!(h||L))return!1;if(u(t,o,y))return i(null,null,y),this.logger.log(f.DEBUG,"Repeated command ("+p([t,o])+") is dropped"),!0;var R=t===20||t===21||t===23?1:2,I=this.channels[R];return t===20||t===21||t===28||t===29?o===32?I.ccRCL():o===33?I.ccBS():o===34?I.ccAOF():o===35?I.ccAON():o===36?I.ccDER():o===37?I.ccRU(2):o===38?I.ccRU(3):o===39?I.ccRU(4):o===40?I.ccFON():o===41?I.ccRDC():o===42?I.ccTR():o===43?I.ccRTD():o===44?I.ccEDM():o===45?I.ccCR():o===46?I.ccENM():o===47&&I.ccEOC():I.ccTO(o-32),i(t,o,y),this.currentChannel=R,!0},e.parseMidrow=function(t,o){var y=0;if((t===17||t===25)&&o>=32&&o<=47){if(t===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(f.ERROR,"Mismatch channel in midrow parsing"),!1;var h=this.channels[y];return h?(h.ccMIDROW(o),this.logger.log(f.DEBUG,"MIDROW ("+p([t,o])+")"),!0):!1}return!1},e.parsePAC=function(t,o){var y,h=this.cmdHistory,L=(t>=17&&t<=23||t>=25&&t<=31)&&o>=64&&o<=127,R=(t===16||t===24)&&o>=64&&o<=95;if(!(L||R))return!1;if(u(t,o,h))return i(null,null,h),!0;var I=t<=23?1:2;o>=64&&o<=95?y=I===1?b[t]:S[t]:y=I===1?A[t]:E[t];var k=this.channels[I];return k?(k.setPAC(this.interpretPAC(y,o)),i(t,o,h),this.currentChannel=I,!0):!1},e.interpretPAC=function(t,o){var y,h={color:null,italics:!1,indent:null,underline:!1,row:t};return o>95?y=o-96:y=o-64,h.underline=(y&1)===1,y<=13?h.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(h.italics=!0,h.color="white"):h.indent=Math.floor((y-16)/2)*4,h},e.parseChars=function(t,o){var y,h=null,L=null;if(t>=25?(y=2,L=t-8):(y=1,L=t),L>=17&&L<=19){var R;L===17?R=o+80:L===18?R=o+112:R=o+144,this.logger.log(f.INFO,"Special char '"+M(R)+"' in channel "+y),h=[R]}else t>=32&&t<=127&&(h=o===0?[t]:[t,o]);if(h){var I=p(h);this.logger.log(f.DEBUG,"Char codes = "+I.join(",")),i(t,o,this.cmdHistory)}return h},e.parseBackgroundAttributes=function(t,o){var y=(t===16||t===24)&&o>=32&&o<=47,h=(t===23||t===31)&&o>=45&&o<=47;if(!(y||h))return!1;var L,R={};t===16||t===24?(L=Math.floor((o-32)/2),R.background=x[L],o%2===1&&(R.background=R.background+"_semi")):o===45?R.background="transparent":(R.foreground="black",o===47&&(R.underline=!0));var I=t<=23?1:2,k=this.channels[I];return k.setBkgData(R),i(t,o,this.cmdHistory),!0},e.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var o=this.channels[t];o&&o.reset()}this.cmdHistory=g()},e.cueSplitAtTime=function(t){for(var o=0;o<this.channels.length;o++){var y=this.channels[o];y&&y.cueSplitAtTime(t)}},m}();function i(m,e,r){r.a=m,r.b=e}function u(m,e,r){return r.a===m&&r.b===e}function g(){return{a:null,b:null}}let c=l},"./src/utils/codecs.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{isCodecSupportedInMp4:()=>M,isCodecType:()=>D});var O={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 D(P,U){var b=O[U];return!!b&&b[P.slice(0,4)]===!0}function M(P,U){return MediaSource.isTypeSupported((U||"video")+'/mp4;codecs="'+P+'"')}},"./src/utils/cues.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>b});var O=T("./src/utils/vttparser.ts"),D=T("./src/utils/webvtt-parser.ts"),M=T("./src/utils/texttrack-utils.ts"),P=/\s/,U={newCue:function(S,E,x,f){for(var _=[],p,v,a,s,n,d=self.VTTCue||self.TextTrackCue,l=0;l<f.rows.length;l++)if(p=f.rows[l],a=!0,s=0,n="",!p.isEmpty()){for(var i=0;i<p.chars.length;i++)P.test(p.chars[i].uchar)&&a?s++:(n+=p.chars[i].uchar,a=!1);p.cueStartTime=E,E===x&&(x+=1e-4),s>=16?s--:s++;var u=(0,O.fixLineBreaks)(n.trim()),g=(0,D.generateCueId)(E,x,u);(!S||!S.cues||!S.cues.getCueById(g))&&(v=new d(E,x,u),v.id=g,v.line=l+1,v.align="left",v.position=10+Math.min(80,Math.floor(s*8/32)*10),_.push(v))}return S&&_.length&&(_.sort(function(c,m){return c.line==="auto"||m.line==="auto"?0:c.line>8&&m.line>8?m.line-c.line:c.line-m.line}),_.forEach(function(c){return(0,M.addCueToTrack)(S,c)})),_}};let b=U},"./src/utils/discontinuities.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{adjustSlidingStart:()=>S,alignMediaPlaylistByPDT:()=>_,alignPDT:()=>f,alignStream:()=>E,findDiscontinuousReferenceFrag:()=>b,findFirstFragWithCC:()=>P,shouldAlignOnDiscontinuities:()=>U});var O=T("./src/polyfills/number.ts"),D=T("./src/utils/logger.ts"),M=T("./src/controller/level-helper.ts");function P(p,v){for(var a=null,s=0,n=p.length;s<n;s++){var d=p[s];if(d&&d.cc===v){a=d;break}}return a}function U(p,v,a){return!!(v.details&&(a.endCC>a.startCC||p&&p.cc<a.startCC))}function b(p,v,a){a===void 0&&(a=0);var s=p.fragments,n=v.fragments;if(!n.length||!s.length){D.logger.log("No fragments to align");return}var d=P(s,n[0].cc);if(!d||d&&!d.startPTS){D.logger.log("No frag in previous level to align on");return}return d}function A(p,v){if(p){var a=p.start+v;p.start=p.startPTS=a,p.endPTS=a+p.duration}}function S(p,v){for(var a=v.fragments,s=0,n=a.length;s<n;s++)A(a[s],p);v.fragmentHint&&A(v.fragmentHint,p),v.alignedSliding=!0}function E(p,v,a){!v||(x(p,a,v),!a.alignedSliding&&v.details&&f(a,v.details),!a.alignedSliding&&v.details&&!a.skippedSegments&&(0,M.adjustSliding)(v.details,a))}function x(p,v,a){if(U(p,a,v)){var s=b(a.details,v);s&&(0,O.isFiniteNumber)(s.start)&&(D.logger.log("Adjusting PTS using last level due to CC increase within current level "+v.url),S(s.start,v))}}function f(p,v){if(!(!v.fragments.length||!p.hasProgramDateTime||!v.hasProgramDateTime)){var a=v.fragments[0].programDateTime,s=p.fragments[0].programDateTime,n=(s-a)/1e3+v.fragments[0].start;n&&(0,O.isFiniteNumber)(n)&&(D.logger.log("Adjusting PTS using programDateTime delta "+(s-a)+"ms, sliding:"+n.toFixed(3)+" "+p.url+" "),S(n,p))}}function _(p,v){if(!(!p.hasProgramDateTime||!v.hasProgramDateTime)){var a=p.fragments,s=v.fragments;if(!(!a.length||!s.length)){var n=Math.round(s.length/2)-1,d=s[n],l=P(a,d.cc)||a[Math.round(a.length/2)-1],i=d.programDateTime,u=l.programDateTime;if(!(i===null||u===null)){var g=(u-i)/1e3-(l.start-d.start);S(g,p)}}}}},"./src/utils/ewma-bandwidth-estimator.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>M});var O=T("./src/utils/ewma.ts"),D=function(){function P(b,A,S){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=S,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new O.default(b),this.fast_=new O.default(A)}var U=P.prototype;return U.update=function(A,S){var E=this.slow_,x=this.fast_;this.slow_.halfLife!==A&&(this.slow_=new O.default(A,E.getEstimate(),E.getTotalWeight())),this.fast_.halfLife!==S&&(this.fast_=new O.default(S,x.getEstimate(),x.getTotalWeight()))},U.sample=function(A,S){A=Math.max(A,this.minDelayMs_);var E=8*S,x=A/1e3,f=E/x;this.fast_.sample(x,f),this.slow_.sample(x,f)},U.canEstimate=function(){var A=this.fast_;return A&&A.getTotalWeight()>=this.minWeight_},U.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},U.destroy=function(){},P}();let M=D},"./src/utils/ewma.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O=function(){function M(U,b,A){b===void 0&&(b=0),A===void 0&&(A=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=U,this.alpha_=U?Math.exp(Math.log(.5)/U):0,this.estimate_=b,this.totalWeight_=A}var P=M.prototype;return P.sample=function(b,A){var S=Math.pow(this.alpha_,b);this.estimate_=A*(1-S)+S*this.estimate_,this.totalWeight_+=b},P.getTotalWeight=function(){return this.totalWeight_},P.getEstimate=function(){if(this.alpha_){var b=1-Math.pow(this.alpha_,this.totalWeight_);if(b)return this.estimate_/b}return this.estimate_},M}();let D=O},"./src/utils/fetch-loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>n,fetchSupported:()=>_});var O=T("./src/polyfills/number.ts"),D=T("./src/loader/load-stats.ts"),M=T("./src/demux/chunk-cache.ts");function P(d,l){d.prototype=Object.create(l.prototype),d.prototype.constructor=d,E(d,l)}function U(d){var l=typeof Map=="function"?new Map:void 0;return U=function(u){if(u===null||!S(u))return u;if(typeof u!="function")throw new TypeError("Super expression must either be null or a function");if(typeof l!="undefined"){if(l.has(u))return l.get(u);l.set(u,g)}function g(){return b(u,arguments,x(this).constructor)}return g.prototype=Object.create(u.prototype,{constructor:{value:g,enumerable:!1,writable:!0,configurable:!0}}),E(g,u)},U(d)}function b(d,l,i){return A()?b=Reflect.construct.bind():b=function(g,c,m){var e=[null];e.push.apply(e,c);var r=Function.bind.apply(g,e),t=new r;return m&&E(t,m.prototype),t},b.apply(null,arguments)}function A(){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 S(d){return Function.toString.call(d).indexOf("[native code]")!==-1}function E(d,l){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,g){return u.__proto__=g,u},E(d,l)}function x(d){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},x(d)}function f(){return f=Object.assign?Object.assign.bind():function(d){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(d[u]=i[u])}return d},f.apply(this,arguments)}function _(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function d(i){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=i.fetchSetup||a,this.controller=new self.AbortController,this.stats=new D.LoadStats}var l=d.prototype;return l.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},l.abortInternal=function(){var u=this.response;(!u||!u.ok)&&(this.stats.aborted=!0,this.controller.abort())},l.abort=function(){var u;this.abortInternal(),(u=this.callbacks)!==null&&u!==void 0&&u.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},l.load=function(u,g,c){var m=this,e=this.stats;if(e.loading.start)throw new Error("Loader can only be used once.");e.loading.start=self.performance.now();var r=v(u,this.controller.signal),t=c.onProgress,o=u.responseType==="arraybuffer",y=o?"byteLength":"length";this.context=u,this.config=g,this.callbacks=c,this.request=this.fetchSetup(u,r),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){m.abortInternal(),c.onTimeout(e,u,m.response)},g.timeout),self.fetch(this.request).then(function(h){if(m.response=m.loader=h,!h.ok){var L=h.status,R=h.statusText;throw new s(R||"fetch, bad network response",L,h)}return e.loading.first=Math.max(self.performance.now(),e.loading.start),e.total=parseInt(h.headers.get("Content-Length")||"0"),t&&(0,O.isFiniteNumber)(g.highWaterMark)?m.loadProgressively(h,e,u,g.highWaterMark,t):o?h.arrayBuffer():h.text()}).then(function(h){var L=m.response;self.clearTimeout(m.requestTimeout),e.loading.end=Math.max(self.performance.now(),e.loading.first);var R=h[y];R&&(e.loaded=e.total=R);var I={url:L.url,data:h};t&&!(0,O.isFiniteNumber)(g.highWaterMark)&&t(e,u,h,L),c.onSuccess(I,e,u,L)}).catch(function(h){if(self.clearTimeout(m.requestTimeout),!e.aborted){var L=h&&h.code||0,R=h?h.message:null;c.onError({code:L,text:R},u,h?h.details:null)}})},l.getCacheAge=function(){var u=null;if(this.response){var g=this.response.headers.get("age");u=g?parseFloat(g):null}return u},l.loadProgressively=function(u,g,c,m,e){m===void 0&&(m=0);var r=new M.default,t=u.body.getReader(),o=function y(){return t.read().then(function(h){if(h.done)return r.dataLength&&e(g,c,r.flush(),u),Promise.resolve(new ArrayBuffer(0));var L=h.value,R=L.length;return g.loaded+=R,R<m||r.dataLength?(r.push(L),r.dataLength>=m&&e(g,c,r.flush(),u)):e(g,c,L,u),y()}).catch(function(){return Promise.reject()})};return o()},d}();function v(d,l){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:l,headers:new self.Headers(f({},d.headers))};return d.rangeEnd&&i.headers.set("Range","bytes="+d.rangeStart+"-"+String(d.rangeEnd-1)),i}function a(d,l){return new self.Request(d.url,l)}var s=function(d){P(l,d);function l(i,u,g){var c;return c=d.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=u,c.details=g,c}return l}(U(Error));let n=p},"./src/utils/hex.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O={hexDump:function(P){for(var U="",b=0;b<P.length;b++){var A=P[b].toString(16);A.length<2&&(A="0"+A),U+=A}return U}};let D=O},"./src/utils/imsc1-ttml-parser.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{IMSC1_CODEC:()=>S,parseIMSC1:()=>_});var O=T("./src/utils/mp4-tools.ts"),D=T("./src/utils/vttparser.ts"),M=T("./src/utils/vttcue.ts"),P=T("./src/demux/id3.ts"),U=T("./src/utils/timescale-conversion.ts"),b=T("./src/utils/webvtt-parser.ts");function A(){return A=Object.assign?Object.assign.bind():function(c){for(var m=1;m<arguments.length;m++){var e=arguments[m];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(c[r]=e[r])}return c},A.apply(this,arguments)}var S="stpp.ttml.im1t",E=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,x=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,f={left:"start",center:"center",right:"end",start:"start",end:"end"};function _(c,m,e,r,t){var o=(0,O.findBox)(new Uint8Array(c),["mdat"]);if(o.length===0){t(new Error("Could not parse IMSC1 mdat"));return}var y=o.map(function(L){return(0,P.utf8ArrayToStr)(L)}),h=(0,U.toTimescaleFromScale)(m,1,e);try{y.forEach(function(L){return r(p(L,h))})}catch(L){t(L)}}function p(c,m){var e=new DOMParser,r=e.parseFromString(c,"text/xml"),t=r.getElementsByTagName("tt")[0];if(!t)throw new Error("Invalid ttml");var o={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},y=Object.keys(o).reduce(function(k,F){return k[F]=t.getAttribute("ttp:"+F)||o[F],k},{}),h=t.getAttribute("xml:space")!=="preserve",L=a(v(t,"styling","style")),R=a(v(t,"layout","region")),I=v(t,"body","[begin]");return[].map.call(I,function(k){var F=s(k,h);if(!F||!k.hasAttribute("begin"))return null;var W=i(k.getAttribute("begin"),y),K=i(k.getAttribute("dur"),y),H=i(k.getAttribute("end"),y);if(W===null)throw l(k);if(H===null){if(K===null)throw l(k);H=W+K}var Y=new M.default(W-m,H-m,F);Y.id=(0,b.generateCueId)(Y.startTime,Y.endTime,Y.text);var q=R[k.getAttribute("region")],ee=L[k.getAttribute("style")],ae=n(q,ee,L),re=ae.textAlign;if(re){var se=f[re];se&&(Y.lineAlign=se),Y.align=re}return A(Y,ae),Y}).filter(function(k){return k!==null})}function v(c,m,e){var r=c.getElementsByTagName(m)[0];return r?[].slice.call(r.querySelectorAll(e)):[]}function a(c){return c.reduce(function(m,e){var r=e.getAttribute("xml:id");return r&&(m[r]=e),m},{})}function s(c,m){return[].slice.call(c.childNodes).reduce(function(e,r,t){var o;return r.nodeName==="br"&&t?e+`
|
|
23
|
-
`:(o=r.childNodes)!==null&&o!==void 0&&o.length?s(r,m):m?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function n(c,m,e){var r="http://www.w3.org/ns/ttml#styling",t=null,o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],y=c!=null&&c.hasAttribute("style")?c.getAttribute("style"):null;return y&&e.hasOwnProperty(y)&&(t=e[y]),o.reduce(function(h,L){var R=d(m,r,L)||d(c,r,L)||d(t,r,L);return R&&(h[L]=R),h},{})}function d(c,m,e){return c&&c.hasAttributeNS(m,e)?c.getAttributeNS(m,e):null}function l(c){return new Error("Could not parse ttml timestamp "+c)}function i(c,m){if(!c)return null;var e=(0,D.parseTimeStamp)(c);return e===null&&(E.test(c)?e=u(c,m):x.test(c)&&(e=g(c,m))),e}function u(c,m){var e=E.exec(c),r=(e[4]|0)+(e[5]|0)/m.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+r/m.frameRate}function g(c,m){var e=x.exec(c),r=Number(e[1]),t=e[2];switch(t){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/m.frameRate;case"t":return r/m.tickRate}return r}},"./src/utils/keysystem-util.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{changeEndianness:()=>M,convertDataUriToArrayBytes:()=>P,strToUtf8array:()=>U});var O=T("./src/utils/numeric-encoding-utils.ts");function D(b){var A=U(b).subarray(0,16),S=new Uint8Array(16);return S.set(A,16-A.length),S}function M(b){var A=function(E,x,f){var _=E[x];E[x]=E[f],E[f]=_};A(b,0,3),A(b,1,2),A(b,4,5),A(b,6,7)}function P(b){var A=b.split(":"),S=null;if(A[0]==="data"&&A.length===2){var E=A[1].split(";"),x=E[E.length-1].split(",");if(x.length===2){var f=x[0]==="base64",_=x[1];f?(E.splice(-1,1),S=(0,O.base64Decode)(_)):S=D(_)}}return S}function U(b){return Uint8Array.from(unescape(encodeURIComponent(b)),function(A){return A.charCodeAt(0)})}},"./src/utils/logger.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{enableLogs:()=>b,logger:()=>A});var O=function(){},D={trace:O,debug:O,log:O,warn:O,info:O,error:O},M=D;function P(S){var E=self.console[S];return E?E.bind(self.console,"["+S+"] >"):O}function U(S){for(var E=arguments.length,x=new Array(E>1?E-1:0),f=1;f<E;f++)x[f-1]=arguments[f];x.forEach(function(_){M[_]=S[_]?S[_].bind(S):P(_)})}function b(S,E){if(self.console&&S===!0||typeof S=="object"){U(S,"debug","log","info","warn","error");try{M.log('Debug logs enabled for "'+E+'"')}catch{M=D}}else M=D}var A=M},"./src/utils/mediakeys-helper.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{KeySystemFormats:()=>D,KeySystemIds:()=>P,KeySystems:()=>O,getKeySystemsForConfig:()=>A,getSupportedMediaKeySystemConfigurations:()=>E,keySystemDomainToKeySystemFormat:()=>b,keySystemFormatToKeySystemDomain:()=>M,keySystemIdToKeySystemDomain:()=>U,requestMediaKeySystemAccess:()=>S});var O;(function(f){f.CLEARKEY="org.w3.clearkey",f.FAIRPLAY="com.apple.fps",f.PLAYREADY="com.microsoft.playready",f.WIDEVINE="com.widevine.alpha"})(O||(O={}));var D;(function(f){f.CLEARKEY="org.w3.clearkey",f.FAIRPLAY="com.apple.streamingkeydelivery",f.PLAYREADY="com.microsoft.playready",f.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"})(D||(D={}));function M(f){switch(f){case D.FAIRPLAY:return O.FAIRPLAY;case D.PLAYREADY:return O.PLAYREADY;case D.WIDEVINE:return O.WIDEVINE;case D.CLEARKEY:return O.CLEARKEY}}var P;(function(f){f.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"})(P||(P={}));function U(f){if(f===P.WIDEVINE)return O.WIDEVINE}function b(f){switch(f){case O.FAIRPLAY:return D.FAIRPLAY;case O.PLAYREADY:return D.PLAYREADY;case O.WIDEVINE:return D.WIDEVINE;case O.CLEARKEY:return D.CLEARKEY}}function A(f){var _=f.drmSystems,p=f.widevineLicenseUrl,v=_?[O.FAIRPLAY,O.WIDEVINE,O.PLAYREADY,O.CLEARKEY].filter(function(a){return!!_[a]}):[];return!v[O.WIDEVINE]&&p&&v.push(O.WIDEVINE),v}var S=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function E(f,_,p,v){var a;switch(f){case O.FAIRPLAY:a=["cenc","sinf"];break;case O.WIDEVINE:case O.PLAYREADY:a=["cenc"];break;case O.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+f)}return x(a,_,p,v)}function x(f,_,p,v){var a={initDataTypes:f,persistentState:v.persistentState||"not-allowed",distinctiveIdentifier:v.distinctiveIdentifier||"not-allowed",sessionTypes:v.sessionTypes||[v.sessionType||"temporary"],audioCapabilities:_.map(function(s){return{contentType:'audio/mp4; codecs="'+s+'"',robustness:v.audioRobustness||"",encryptionScheme:v.audioEncryptionScheme||null}}),videoCapabilities:p.map(function(s){return{contentType:'video/mp4; codecs="'+s+'"',robustness:v.videoRobustness||"",encryptionScheme:v.videoEncryptionScheme||null}})};return[a]}},"./src/utils/mediasource-helper.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{getMediaSource:()=>O});function O(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{RemuxerTrackIdConfig:()=>S,appendUint8Array:()=>m,bin2str:()=>E,computeRawDurationFromSamples:()=>u,discardEPB:()=>y,findBox:()=>v,getDuration:()=>i,getStartDTS:()=>l,mp4Box:()=>L,mp4pssh:()=>R,offsetStartDTS:()=>g,parseEmsg:()=>h,parseInitSegment:()=>s,parsePssh:()=>I,parseSEIMessageFromNALu:()=>o,parseSamples:()=>e,parseSegmentIndex:()=>a,parseSinf:()=>d,patchEncyptionData:()=>n,readSint32:()=>_,readUint16:()=>x,readUint32:()=>f,segmentValidRange:()=>c,writeUint32:()=>p});var O=T("./src/loader/fragment.ts"),D=T("./src/utils/typed-array.ts"),M=T("./src/demux/id3.ts"),P=T("./src/utils/logger.ts"),U=T("./src/utils/hex.ts"),b=Math.pow(2,32)-1,A=[].push,S={video:1,audio:2,id3:3,text:4};function E(k){return String.fromCharCode.apply(null,k)}function x(k,F){var W=k[F]<<8|k[F+1];return W<0?65536+W:W}function f(k,F){var W=_(k,F);return W<0?4294967296+W:W}function _(k,F){return k[F]<<24|k[F+1]<<16|k[F+2]<<8|k[F+3]}function p(k,F,W){k[F]=W>>24,k[F+1]=W>>16&255,k[F+2]=W>>8&255,k[F+3]=W&255}function v(k,F){var W=[];if(!F.length)return W;for(var K=k.byteLength,H=0;H<K;){var Y=f(k,H),q=E(k.subarray(H+4,H+8)),ee=Y>1?H+Y:K;if(q===F[0])if(F.length===1)W.push(k.subarray(H+8,ee));else{var ae=v(k.subarray(H+8,ee),F.slice(1));ae.length&&A.apply(W,ae)}H=ee}return W}function a(k){var F=[],W=k[0],K=8,H=f(k,K);K+=4;var Y=0,q=0;W===0?K+=8:K+=16,K+=2;var ee=k.length+q,ae=x(k,K);K+=2;for(var re=0;re<ae;re++){var se=K,le=f(k,se);se+=4;var de=le&2147483647,ue=(le&2147483648)>>>31;if(ue===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var fe=f(k,se);se+=4,F.push({referenceSize:de,subsegmentDuration:fe,info:{duration:fe/H,start:ee,end:ee+de-1}}),ee+=de,se+=4,K=se}return{earliestPresentationTime:Y,timescale:H,version:W,referencesCount:ae,references:F}}function s(k){for(var F=[],W=v(k,["moov","trak"]),K=0;K<W.length;K++){var H=W[K],Y=v(H,["tkhd"])[0];if(Y){var q=Y[0],ee=q===0?12:20,ae=f(Y,ee),re=v(H,["mdia","mdhd"])[0];if(re){q=re[0],ee=q===0?12:20;var se=f(re,ee),le=v(H,["mdia","hdlr"])[0];if(le){var de=E(le.subarray(8,12)),ue={soun:O.ElementaryStreamTypes.AUDIO,vide:O.ElementaryStreamTypes.VIDEO}[de];if(ue){var fe=v(H,["mdia","minf","stbl","stsd"])[0],ce=void 0;fe&&(ce=E(fe.subarray(12,16))),F[ae]={timescale:se,type:ue},F[ue]={timescale:se,id:ae,codec:ce}}}}}}var be=v(k,["moov","mvex","trex"]);return be.forEach(function(Pe){var we=f(Pe,4),pe=F[we];pe&&(pe.default={duration:f(Pe,12),flags:f(Pe,20)})}),F}function n(k,F){if(!k||!F)return k;var W=F.keyId;if(W&&F.isCommonEncryption){var K=v(k,["moov","trak"]);K.forEach(function(H){var Y=v(H,["mdia","minf","stbl","stsd"])[0],q=Y.subarray(8),ee=v(q,["enca"]),ae=ee.length>0;ae||(ee=v(q,["encv"])),ee.forEach(function(re){var se=ae?re.subarray(28):re.subarray(78),le=v(se,["sinf"]);le.forEach(function(de){var ue=d(de);if(ue){var fe=ue.subarray(8,24);fe.some(function(ce){return ce!==0})||(P.logger.log("[eme] Patching keyId in 'enc"+(ae?"a":"v")+">sinf>>tenc' box: "+U.default.hexDump(fe)+" -> "+U.default.hexDump(W)),ue.set(W,8))}})})})}return k}function d(k){var F=v(k,["schm"])[0];if(F){var W=E(F.subarray(4,8));if(W==="cbcs"||W==="cenc")return v(k,["schi","tenc"])[0]}return P.logger.error("[eme] missing 'schm' box"),null}function l(k,F){return v(F,["moof","traf"]).reduce(function(W,K){var H=v(K,["tfdt"])[0],Y=H[0],q=v(K,["tfhd"]).reduce(function(ee,ae){var re=f(ae,4),se=k[re];if(se){var le=f(H,4);Y===1&&(le*=Math.pow(2,32),le+=f(H,8));var de=se.timescale||9e4,ue=le/de;if(isFinite(ue)&&(ee===null||ue<ee))return ue}return ee},null);return q!==null&&isFinite(q)&&(W===null||q<W)?q:W},null)||0}function i(k,F){for(var W=0,K=0,H=0,Y=v(k,["moof","traf"]),q=0;q<Y.length;q++){var ee=Y[q],ae=v(ee,["tfhd"])[0],re=f(ae,4),se=F[re];if(!!se){var le=se.default,de=f(ae,0)|(le==null?void 0:le.flags),ue=le==null?void 0:le.duration;de&8&&(de&2?ue=f(ae,12):ue=f(ae,8));for(var fe=se.timescale||9e4,ce=v(ee,["trun"]),be=0;be<ce.length;be++){if(W=u(ce[be]),!W&&ue){var Pe=f(ce[be],4);W=ue*Pe}se.type===O.ElementaryStreamTypes.VIDEO?K+=W/fe:se.type===O.ElementaryStreamTypes.AUDIO&&(H+=W/fe)}}}if(K===0&&H===0){for(var we=0,pe=v(k,["sidx"]),Me=0;Me<pe.length;Me++){var Re=a(pe[Me]);Re!=null&&Re.references&&(we+=Re.references.reduce(function(ke,Le){return ke+Le.info.duration||0},0))}return we}return K||H}function u(k){var F=f(k,0),W=8;F&1&&(W+=4),F&4&&(W+=4);for(var K=0,H=f(k,4),Y=0;Y<H;Y++){if(F&256){var q=f(k,W);K+=q,W+=4}F&512&&(W+=4),F&1024&&(W+=4),F&2048&&(W+=4)}return K}function g(k,F,W){v(F,["moof","traf"]).forEach(function(K){v(K,["tfhd"]).forEach(function(H){var Y=f(H,4),q=k[Y];if(!!q){var ee=q.timescale||9e4;v(K,["tfdt"]).forEach(function(ae){var re=ae[0],se=f(ae,4);if(re===0)se-=W*ee,se=Math.max(se,0),p(ae,4,se);else{se*=Math.pow(2,32),se+=f(ae,8),se-=W*ee,se=Math.max(se,0);var le=Math.floor(se/(b+1)),de=Math.floor(se%(b+1));p(ae,4,le),p(ae,8,de)}})}})})}function c(k){var F={valid:null,remainder:null},W=v(k,["moof"]);if(W){if(W.length<2)return F.remainder=k,F}else return F;var K=W[W.length-1];return F.valid=(0,D.sliceUint8)(k,0,K.byteOffset-8),F.remainder=(0,D.sliceUint8)(k,K.byteOffset-8),F}function m(k,F){var W=new Uint8Array(k.length+F.length);return W.set(k),W.set(F,k.length),W}function e(k,F){var W=[],K=F.samples,H=F.timescale,Y=F.id,q=!1,ee=v(K,["moof"]);return ee.map(function(ae){var re=ae.byteOffset-8,se=v(ae,["traf"]);se.map(function(le){var de=v(le,["tfdt"]).map(function(ue){var fe=ue[0],ce=f(ue,4);return fe===1&&(ce*=Math.pow(2,32),ce+=f(ue,8)),ce/H})[0];return de!==void 0&&(k=de),v(le,["tfhd"]).map(function(ue){var fe=f(ue,4),ce=f(ue,0)&16777215,be=(ce&1)!==0,Pe=(ce&2)!==0,we=(ce&8)!==0,pe=0,Me=(ce&16)!==0,Re=0,ke=(ce&32)!==0,Le=8;fe===Y&&(be&&(Le+=8),Pe&&(Le+=4),we&&(pe=f(ue,Le),Le+=4),Me&&(Re=f(ue,Le),Le+=4),ke&&(Le+=4),F.type==="video"&&(q=r(F.codec)),v(le,["trun"]).map(function(Ue){var He=Ue[0],Be=f(Ue,0)&16777215,Je=(Be&1)!==0,qe=0,st=(Be&4)!==0,Ze=(Be&256)!==0,ot=0,lt=(Be&512)!==0,tt=0,je=(Be&1024)!==0,Ve=(Be&2048)!==0,rt=0,gt=f(Ue,4),Ne=8;Je&&(qe=f(Ue,Ne),Ne+=4),st&&(Ne+=4);for(var it=qe+re,nt=0;nt<gt;nt++){if(Ze?(ot=f(Ue,Ne),Ne+=4):ot=pe,lt?(tt=f(Ue,Ne),Ne+=4):tt=Re,je&&(Ne+=4),Ve&&(He===0?rt=f(Ue,Ne):rt=_(Ue,Ne),Ne+=4),F.type===O.ElementaryStreamTypes.VIDEO)for(var Lt=0;Lt<tt;){var At=f(K,it);if(it+=4,t(q,K[it])){var Dt=K.subarray(it,it+At);o(Dt,q?2:1,k+rt/H,W)}it+=At,Lt+=At+4}k+=ot/H}}))})})}),W}function r(k){if(!k)return!1;var F=k.indexOf("."),W=F<0?k:k.substring(0,F);return W==="hvc1"||W==="hev1"||W==="dvh1"||W==="dvhe"}function t(k,F){if(k){var W=F>>1&63;return W===39||W===40}else{var K=F&31;return K===6}}function o(k,F,W,K){var H=y(k),Y=0;Y+=F;for(var q=0,ee=0,ae=!1,re=0;Y<H.length;){q=0;do{if(Y>=H.length)break;re=H[Y++],q+=re}while(re===255);ee=0;do{if(Y>=H.length)break;re=H[Y++],ee+=re}while(re===255);var se=H.length-Y;if(!ae&&q===4&&Y<H.length){ae=!0;var le=H[Y++];if(le===181){var de=x(H,Y);if(Y+=2,de===49){var ue=f(H,Y);if(Y+=4,ue===1195456820){var fe=H[Y++];if(fe===3){var ce=H[Y++],be=31&ce,Pe=64&ce,we=Pe?2+be*3:0,pe=new Uint8Array(we);if(Pe){pe[0]=ce;for(var Me=1;Me<we;Me++)pe[Me]=H[Y++]}K.push({type:fe,payloadType:q,pts:W,bytes:pe})}}}}}else if(q===5&&ee<se){if(ae=!0,ee>16){for(var Re=[],ke=0;ke<16;ke++){var Le=H[Y++].toString(16);Re.push(Le.length==1?"0"+Le:Le),(ke===3||ke===5||ke===7||ke===9)&&Re.push("-")}for(var Ue=ee-16,He=new Uint8Array(Ue),Be=0;Be<Ue;Be++)He[Be]=H[Y++];K.push({payloadType:q,pts:W,uuid:Re.join(""),userData:(0,M.utf8ArrayToStr)(He),userDataBytes:He})}}else if(ee<se)Y+=ee;else if(ee>se)break}}function y(k){for(var F=k.byteLength,W=[],K=1;K<F-2;)k[K]===0&&k[K+1]===0&&k[K+2]===3?(W.push(K+2),K+=2):K++;if(W.length===0)return k;var H=F-W.length,Y=new Uint8Array(H),q=0;for(K=0;K<H;q++,K++)q===W[0]&&(q++,W.shift()),Y[K]=k[q];return Y}function h(k){var F=k[0],W="",K="",H=0,Y=0,q=0,ee=0,ae=0,re=0;if(F===0){for(;E(k.subarray(re,re+1))!=="\0";)W+=E(k.subarray(re,re+1)),re+=1;for(W+=E(k.subarray(re,re+1)),re+=1;E(k.subarray(re,re+1))!=="\0";)K+=E(k.subarray(re,re+1)),re+=1;K+=E(k.subarray(re,re+1)),re+=1,H=f(k,12),Y=f(k,16),ee=f(k,20),ae=f(k,24),re=28}else if(F===1){re+=4,H=f(k,re),re+=4;var se=f(k,re);re+=4;var le=f(k,re);for(re+=4,q=Math.pow(2,32)*se+le,Number.isSafeInteger(q)||(q=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),ee=f(k,re),re+=4,ae=f(k,re),re+=4;E(k.subarray(re,re+1))!=="\0";)W+=E(k.subarray(re,re+1)),re+=1;for(W+=E(k.subarray(re,re+1)),re+=1;E(k.subarray(re,re+1))!=="\0";)K+=E(k.subarray(re,re+1)),re+=1;K+=E(k.subarray(re,re+1)),re+=1}var de=k.subarray(re,k.byteLength);return{schemeIdUri:W,value:K,timeScale:H,presentationTime:q,presentationTimeDelta:Y,eventDuration:ee,id:ae,payload:de}}function L(k){for(var F=arguments.length,W=new Array(F>1?F-1:0),K=1;K<F;K++)W[K-1]=arguments[K];for(var H=W.length,Y=8,q=H;q--;)Y+=W[q].byteLength;var ee=new Uint8Array(Y);for(ee[0]=Y>>24&255,ee[1]=Y>>16&255,ee[2]=Y>>8&255,ee[3]=Y&255,ee.set(k,4),q=0,Y=8;q<H;q++)ee.set(W[q],Y),Y+=W[q].byteLength;return ee}function R(k,F,W){if(k.byteLength!==16)throw new RangeError("Invalid system id");var K,H;if(F){K=1,H=new Uint8Array(F.length*16);for(var Y=0;Y<F.length;Y++){var q=F[Y];if(q.byteLength!==16)throw new RangeError("Invalid key");H.set(q,Y*16)}}else K=0,H=new Uint8Array;var ee;K>0?(ee=new Uint8Array(4),F.length>0&&new DataView(ee.buffer).setUint32(0,F.length,!1)):ee=new Uint8Array;var ae=new Uint8Array(4);return W&&W.byteLength>0&&new DataView(ae.buffer).setUint32(0,W.byteLength,!1),L([112,115,115,104],new Uint8Array([K,0,0,0]),k,ee,H,ae,W||new Uint8Array)}function I(k){if(!(k instanceof ArrayBuffer)||k.byteLength<32)return null;var F={version:0,systemId:"",kids:null,data:null},W=new DataView(k),K=W.getUint32(0);if(k.byteLength!==K&&K>44)return null;var H=W.getUint32(4);if(H!==1886614376||(F.version=W.getUint32(8)>>>24,F.version>1))return null;F.systemId=U.default.hexDump(new Uint8Array(k,12,16));var Y=W.getUint32(28);if(F.version===0){if(K-32<Y)return null;F.data=new Uint8Array(k,32,Y)}else if(F.version===1){F.kids=[];for(var q=0;q<Y;q++)F.kids.push(new Uint8Array(k,32+q*16,16))}return F}},"./src/utils/numeric-encoding-utils.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{base64Decode:()=>b,base64DecodeToStr:()=>M,base64Encode:()=>P,base64ToBase64Url:()=>O,base64UrlEncode:()=>U,strToBase64Encode:()=>D});function O(A){return A.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function D(A){return btoa(A)}function M(A){return atob(A)}function P(A){return btoa(String.fromCharCode.apply(String,A))}function U(A){return O(P(A))}function b(A){return Uint8Array.from(atob(A),function(S){return S.charCodeAt(0)})}},"./src/utils/output-filter.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});var O=function(){function D(P,U){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=P,this.trackName=U}var M=D.prototype;return M.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},M.newCue=function(U,b,A){(this.startTime===null||this.startTime>U)&&(this.startTime=U),this.endTime=b,this.screen=A,this.timelineController.createCaptionsTrack(this.trackName)},M.reset=function(){this.cueRanges=[],this.startTime=null},D}()},"./src/utils/texttrack-utils.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{addCueToTrack:()=>M,clearCurrentCues:()=>P,getCuesInRange:()=>A,removeCuesInRange:()=>U,sendAddTrackEvent:()=>D});var O=T("./src/utils/logger.ts");function D(S,E){var x;try{x=new Event("addtrack")}catch{x=document.createEvent("Event"),x.initEvent("addtrack",!1,!1)}x.track=S,E.dispatchEvent(x)}function M(S,E){var x=S.mode;if(x==="disabled"&&(S.mode="hidden"),S.cues&&!S.cues.getCueById(E.id))try{if(S.addCue(E),!S.cues.getCueById(E.id))throw new Error("addCue is failed for: "+E)}catch(_){O.logger.debug("[texttrack-utils]: "+_);var f=new self.TextTrackCue(E.startTime,E.endTime,E.text);f.id=E.id,S.addCue(f)}x==="disabled"&&(S.mode=x)}function P(S){var E=S.mode;if(E==="disabled"&&(S.mode="hidden"),S.cues)for(var x=S.cues.length;x--;)S.removeCue(S.cues[x]);E==="disabled"&&(S.mode=E)}function U(S,E,x,f){var _=S.mode;if(_==="disabled"&&(S.mode="hidden"),S.cues&&S.cues.length>0)for(var p=A(S.cues,E,x),v=0;v<p.length;v++)(!f||f(p[v]))&&S.removeCue(p[v]);_==="disabled"&&(S.mode=_)}function b(S,E){if(E<S[0].startTime)return 0;var x=S.length-1;if(E>S[x].endTime)return-1;for(var f=0,_=x;f<=_;){var p=Math.floor((_+f)/2);if(E<S[p].startTime)_=p-1;else if(E>S[p].startTime&&f<x)f=p+1;else return p}return S[f].startTime-E<E-S[_].startTime?f:_}function A(S,E,x){var f=[],_=b(S,E);if(_>-1)for(var p=_,v=S.length;p<v;p++){var a=S[p];if(a.startTime>=E&&a.endTime<=x)f.push(a);else if(a.startTime>x)return f}return f}},"./src/utils/time-ranges.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>D});var O={toString:function(P){for(var U="",b=P.length,A=0;A<b;A++)U+="["+P.start(A).toFixed(3)+","+P.end(A).toFixed(3)+"]";return U}};let D=O},"./src/utils/timescale-conversion.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{toMpegTsClockFromTimescale:()=>U,toMsFromMpegTsClock:()=>P,toTimescaleFromBase:()=>D,toTimescaleFromScale:()=>M});var O=9e4;function D(b,A,S,E){S===void 0&&(S=1),E===void 0&&(E=!1);var x=b*A*S;return E?Math.round(x):x}function M(b,A,S,E){return S===void 0&&(S=1),E===void 0&&(E=!1),D(b,A,1/S,E)}function P(b,A){return A===void 0&&(A=!1),D(b,1e3,1/O,A)}function U(b,A){return A===void 0&&(A=1),D(b,O,1/A)}},"./src/utils/typed-array.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{sliceUint8:()=>O});function O(D,M,P){return Uint8Array.prototype.slice?D.slice(M,P):new Uint8Array(Array.prototype.slice.call(D,M,P))}},"./src/utils/vttcue.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>O});let O=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var D=["","lr","rl"],M=["start","middle","end","left","right"];function P(E,x){if(typeof x!="string"||!Array.isArray(E))return!1;var f=x.toLowerCase();return~E.indexOf(f)?f:!1}function U(E){return P(D,E)}function b(E){return P(M,E)}function A(E){for(var x=arguments.length,f=new Array(x>1?x-1:0),_=1;_<x;_++)f[_-1]=arguments[_];for(var p=1;p<arguments.length;p++){var v=arguments[p];for(var a in v)E[a]=v[a]}return E}function S(E,x,f){var _=this,p={enumerable:!0};_.hasBeenReset=!1;var v="",a=!1,s=E,n=x,d=f,l=null,i="",u=!0,g="auto",c="start",m=50,e="middle",r=50,t="middle";Object.defineProperty(_,"id",A({},p,{get:function(){return v},set:function(y){v=""+y}})),Object.defineProperty(_,"pauseOnExit",A({},p,{get:function(){return a},set:function(y){a=!!y}})),Object.defineProperty(_,"startTime",A({},p,{get:function(){return s},set:function(y){if(typeof y!="number")throw new TypeError("Start time must be set to a number.");s=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"endTime",A({},p,{get:function(){return n},set:function(y){if(typeof y!="number")throw new TypeError("End time must be set to a number.");n=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"text",A({},p,{get:function(){return d},set:function(y){d=""+y,this.hasBeenReset=!0}})),Object.defineProperty(_,"region",A({},p,{get:function(){return l},set:function(y){l=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"vertical",A({},p,{get:function(){return i},set:function(y){var h=U(y);if(h===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=h,this.hasBeenReset=!0}})),Object.defineProperty(_,"snapToLines",A({},p,{get:function(){return u},set:function(y){u=!!y,this.hasBeenReset=!0}})),Object.defineProperty(_,"line",A({},p,{get:function(){return g},set:function(y){if(typeof y!="number"&&y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");g=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"lineAlign",A({},p,{get:function(){return c},set:function(y){var h=b(y);if(!h)throw new SyntaxError("An invalid or illegal string was specified.");c=h,this.hasBeenReset=!0}})),Object.defineProperty(_,"position",A({},p,{get:function(){return m},set:function(y){if(y<0||y>100)throw new Error("Position must be between 0 and 100.");m=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"positionAlign",A({},p,{get:function(){return e},set:function(y){var h=b(y);if(!h)throw new SyntaxError("An invalid or illegal string was specified.");e=h,this.hasBeenReset=!0}})),Object.defineProperty(_,"size",A({},p,{get:function(){return r},set:function(y){if(y<0||y>100)throw new Error("Size must be between 0 and 100.");r=y,this.hasBeenReset=!0}})),Object.defineProperty(_,"align",A({},p,{get:function(){return t},set:function(y){var h=b(y);if(!h)throw new SyntaxError("An invalid or illegal string was specified.");t=h,this.hasBeenReset=!0}})),_.displayState=void 0}return S.prototype.getCueAsHTML=function(){var E=self.WebVTT;return E.convertCueToDOMTree(self,this.text)},S}()},"./src/utils/vttparser.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{VTTParser:()=>x,fixLineBreaks:()=>E,parseTimeStamp:()=>M});var O=T("./src/utils/vttcue.ts"),D=function(){function f(){}var _=f.prototype;return _.decode=function(v,a){if(!v)return"";if(typeof v!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(v))},f}();function M(f){function _(v,a,s,n){return(v|0)*3600+(a|0)*60+(s|0)+parseFloat(n||0)}var p=f.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?_(p[2],p[3],0,p[4]):_(p[1],p[2],p[3],p[4]):null}var P=function(){function f(){this.values=Object.create(null)}var _=f.prototype;return _.set=function(v,a){!this.get(v)&&a!==""&&(this.values[v]=a)},_.get=function(v,a,s){return s?this.has(v)?this.values[v]:a[s]:this.has(v)?this.values[v]:a},_.has=function(v){return v in this.values},_.alt=function(v,a,s){for(var n=0;n<s.length;++n)if(a===s[n]){this.set(v,a);break}},_.integer=function(v,a){/^-?\d+$/.test(a)&&this.set(v,parseInt(a,10))},_.percent=function(v,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var s=parseFloat(a);if(s>=0&&s<=100)return this.set(v,s),!0}return!1},f}();function U(f,_,p,v){var a=v?f.split(v):[f];for(var s in a)if(typeof a[s]=="string"){var n=a[s].split(p);if(n.length===2){var d=n[0],l=n[1];_(d,l)}}}var b=new O.default(0,0,""),A=b.align==="middle"?"middle":"center";function S(f,_,p){var v=f;function a(){var d=M(f);if(d===null)throw new Error("Malformed timestamp: "+v);return f=f.replace(/^[^\sa-zA-Z-]+/,""),d}function s(d,l){var i=new P;U(d,function(c,m){var e;switch(c){case"region":for(var r=p.length-1;r>=0;r--)if(p[r].id===m){i.set(c,p[r].region);break}break;case"vertical":i.alt(c,m,["rl","lr"]);break;case"line":e=m.split(","),i.integer(c,e[0]),i.percent(c,e[0])&&i.set("snapToLines",!1),i.alt(c,e[0],["auto"]),e.length===2&&i.alt("lineAlign",e[1],["start",A,"end"]);break;case"position":e=m.split(","),i.percent(c,e[0]),e.length===2&&i.alt("positionAlign",e[1],["start",A,"end","line-left","line-right","auto"]);break;case"size":i.percent(c,m);break;case"align":i.alt(c,m,["start",A,"end","left","right"]);break}},/:/,/\s/),l.region=i.get("region",null),l.vertical=i.get("vertical","");var u=i.get("line","auto");u==="auto"&&b.line===-1&&(u=-1),l.line=u,l.lineAlign=i.get("lineAlign","start"),l.snapToLines=i.get("snapToLines",!0),l.size=i.get("size",100),l.align=i.get("align",A);var g=i.get("position","auto");g==="auto"&&b.position===50&&(g=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=g}function n(){f=f.replace(/^\s+/,"")}if(n(),_.startTime=a(),n(),f.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+v);f=f.slice(3),n(),_.endTime=a(),n(),s(f,_)}function E(f){return f.replace(/<br(?: \/)?>/gi,`
|
|
24
|
-
`)
|
|
25
|
-
`;)++c;var m=g.slice(0,c);return g[c]==="\r"&&++c,g[c]===`
|
|
26
|
-
`&&++c,a.buffer=g.slice(c),m}function n(g){U(g,function(c,m){},/:/)}try{var d="";if(a.state==="INITIAL"){if(!/\r\n|\n/.test(a.buffer))return this;d=s();var l=d.match(/^()?WEBVTT([ \t].*)?$/);if(!l||!l[0])throw new Error("Malformed WebVTT signature.");a.state="HEADER"}for(var i=!1;a.buffer;){if(!/\r\n|\n/.test(a.buffer))return this;switch(i?i=!1:d=s(),a.state){case"HEADER":/:/.test(d)?n(d):d||(a.state="ID");continue;case"NOTE":d||(a.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(d)){a.state="NOTE";break}if(!d)continue;if(a.cue=new O.default(0,0,""),a.state="CUE",d.indexOf("-->")===-1){a.cue.id=d;continue}case"CUE":if(!a.cue){a.state="BADCUE";continue}try{S(d,a.cue,a.regionList)}catch{a.cue=null,a.state="BADCUE";continue}a.state="CUETEXT";continue;case"CUETEXT":{var u=d.indexOf("-->")!==-1;if(!d||u&&(i=!0)){a.oncue&&a.cue&&a.oncue(a.cue),a.cue=null,a.state="ID";continue}if(a.cue===null)continue;a.cue.text&&(a.cue.text+=`
|
|
27
|
-
`),a.cue.text+=d}continue;case"BADCUE":d||(a.state="ID")}}}catch{a.state==="CUETEXT"&&a.cue&&a.oncue&&a.oncue(a.cue),a.cue=null,a.state=a.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},_.flush=function(){var v=this;try{if((v.cue||v.state==="HEADER")&&(v.buffer+=`
|
|
1
|
+
"use strict";(()=>{var Ks=Object.create;var $n=Object.defineProperty;var Hs=Object.getOwnPropertyDescriptor;var qs=Object.getOwnPropertyNames;var Vs=Object.getPrototypeOf,Ys=Object.prototype.hasOwnProperty;var Ws=(x,w,A)=>w in x?$n(x,w,{enumerable:!0,configurable:!0,writable:!0,value:A}):x[w]=A;var Ga=(x,w)=>()=>(w||x((w={exports:{}}).exports,w),w.exports);var Xs=(x,w,A,le)=>{if(w&&typeof w=="object"||typeof w=="function")for(let oe of qs(w))!Ys.call(x,oe)&&oe!==A&&$n(x,oe,{get:()=>w[oe],enumerable:!(le=Hs(w,oe))||le.enumerable});return x};var Ka=(x,w,A)=>(A=x!=null?Ks(Vs(x)):{},Xs(w||!x||!x.__esModule?$n(A,"default",{value:x,enumerable:!0}):A,x));var Ki=(x,w,A)=>(Ws(x,typeof w!="symbol"?w+"":w,A),A),Zn=(x,w,A)=>{if(!w.has(x))throw TypeError("Cannot "+A)};var Ye=(x,w,A)=>(Zn(x,w,"read from private field"),A?A.call(x):w.get(x)),bt=(x,w,A)=>{if(w.has(x))throw TypeError("Cannot add the same private member more than once");w instanceof WeakSet?w.add(x):w.set(x,A)},Nt=(x,w,A,le)=>(Zn(x,w,"write to private field"),le?le.call(x,A):w.set(x,A),A);var zt=(x,w,A)=>(Zn(x,w,"access private method"),A);var Va=Ga((En,ia)=>{(function(){var x,w;x=this,w=function(){return function(){var A={80:function(X,B,j){X.exports=j(728).default},728:function(X,B,j){"use strict";j.d(B,{default:function(){return Un}});var re=j(48),R=j.n(re),g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(p){var h=16*Math.random()|0;return(p==="x"?h:3&h|8).toString(16)})},k=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},L=function(p){return p&&p.nodeName!==void 0?(p.muxId||(p.muxId=p.id||k()),p.muxId):p},me=function(p){var h;p&&p.nodeName!==void 0?p=L(h=p):h=document.querySelector(p);var f=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,p,f]},ne=j(640),ce=j.n(ne),we=ce().methodFactory;ce().methodFactory=function(p,h,f){var y=we(p,h,f);return function(){for(var b=["[mux]"],M=0;M<arguments.length;M++)b.push(arguments[M]);y.apply(void 0,b)}},ce().setLevel(ce().getLevel());var q=ce();function ye(){return(R().doNotTrack||R().navigator&&R().navigator.doNotTrack)==="1"}var J={now:function(){var p=R().performance,h=p&&p.timing,f=h&&h.navigationStart,y=typeof f=="number"&&typeof p.now=="function"?f+p.now():Date.now();return Math.round(y)}},se=j(678),K=j.n(se),Ee=function(p){return ke(p)[0]},ke=function(p){if(typeof p!="string"||p==="")return["localhost"];var h,f=(p.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return f&&(h=(f.match(/[^\.]+\.[^\.]+$/)||[])[0]),[f,h]},Ne={exists:function(){var p=R().performance;return(p&&p.timing)!==void 0},domContentLoadedEventEnd:function(){var p=R().performance,h=p&&p.timing;return h&&h.domContentLoadedEventEnd},navigationStart:function(){var p=R().performance,h=p&&p.timing;return h&&h.navigationStart}};function V(p,h,f){f=f===void 0?1:f,p[h]=p[h]||0,p[h]+=f}var E=["x-cdn","content-type","x-request-id"];function U(p){var h={};return(p=p||"").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 D=function(p){var h={};for(var f in p){var y=p[f];y["DATA-ID"].search("io.litix.data.")!==-1&&(h[y["DATA-ID"].replace("io.litix.data.","")]=y.VALUE)}return h};function de(p,h){var f=Object.keys(p);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(p);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(p,b).enumerable})),f.push.apply(f,y)}return f}function Se(p){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?de(Object(f),!0).forEach(function(y){z(p,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(f)):de(Object(f)).forEach(function(y){Object.defineProperty(p,y,Object.getOwnPropertyDescriptor(f,y))})}return p}function z(p,h,f){return h in p?Object.defineProperty(p,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):p[h]=f,p}var $=function(p){if(!p)return{};var h=Ne.navigationStart(),f=p.loading,y=f?f.start:p.trequest,b=f?f.first:p.tfirst,M=f?f.end:p.tload;return{bytesLoaded:p.total,requestStart:Math.round(h+y),responseStart:Math.round(h+b),responseEnd:Math.round(h+M)}},Le=function(p){if(p&&typeof p.getAllResponseHeaders=="function")return U(p.getAllResponseHeaders())};function Oe(p,h){var f=Object.keys(p);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(p);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(p,b).enumerable})),f.push.apply(f,y)}return f}function xe(p){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?Oe(Object(f),!0).forEach(function(y){be(p,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(f)):Oe(Object(f)).forEach(function(y){Object.defineProperty(p,y,Object.getOwnPropertyDescriptor(f,y))})}return p}function be(p,h,f){return h in p?Object.defineProperty(p,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):p[h]=f,p}var qe=function(p,h){if(!p||typeof p.getRequests!="function")return{};var f=p.getRequests({state:"executed"});if(f.length===0)return{};var y,b=f[f.length-1],M=Ee(b.url),I=b.url,Y=b.bytesLoaded,he=new Date(b.requestStartDate).getTime(),ee=new Date(b.firstByteDate).getTime(),Me=new Date(b.requestEndDate).getTime(),ut=isNaN(b.duration)?0:b.duration,Ze=typeof h.getMetricsFor=="function"?h.getMetricsFor(b.mediaType).HttpList:h.getDashMetrics().getHttpRequests(b.mediaType);return Ze.length>0&&(y=U(Ze[Ze.length-1]._responseHeaders||"")),{requestStart:he,requestResponseStart:ee,requestResponseEnd:Me,requestBytesLoaded:Y,requestResponseHeaders:y,requestMediaDuration:ut,requestHostname:M,requestUrl:I}},at=function(p,h){var f=h.getQualityFor(p),y=h.getCurrentTrackFor(p).bitrateList;return y?{currentLevel:f,renditionWidth:y[f].width||null,renditionHeight:y[f].height||null,renditionBitrate:y[f].bandwidth}:{}},ie=function(p){var h;return(h=p.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function pe(p,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(p,y.key,y)}}var ae=0,Ue=function(){function p(){(function(b,M){if(!(b instanceof M))throw new TypeError("Cannot call a class as a function")})(this,p)}var h,f,y;return h=p,f=[{key:"on",value:function(b,M,I){return M._eventEmitterGuid=M._eventEmitterGuid||++ae,this._listeners=this._listeners||{},this._listeners[b]=this._listeners[b]||[],I&&(M=M.bind(I)),this._listeners[b].push(M),M}},{key:"off",value:function(b,M){var I=this._listeners&&this._listeners[b];I&&I.forEach(function(Y,he){Y._eventEmitterGuid===M._eventEmitterGuid&&I.splice(he,1)})}},{key:"one",value:function(b,M,I){var Y=this;M._eventEmitterGuid=M._eventEmitterGuid||++ae;var he=function ee(){Y.off(b,ee),M.apply(I||this,arguments)};he._eventEmitterGuid=M._eventEmitterGuid,this.on(b,he)}},{key:"emit",value:function(b,M){var I=this;if(this._listeners){M=M||{};var Y=this._listeners["before*"]||[],he=this._listeners[b]||[],ee=this._listeners["after"+b]||[],Me=function(ut,Ze){(ut=ut.slice()).forEach(function(st){st.call(I,{type:b},Ze)})};Me(Y,M),Me(he,M),Me(ee,M)}}}],f&&pe(h.prototype,f),y&&pe(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}(),H=Ue;function ve(p,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(p,y.key,y)}}var Ie=function(){function p(b){var M=this;(function(I,Y){if(!(I instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,b.on("playing",function(){M._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?M._stopPlaybackHeartbeatInterval():M._startPlaybackHeartbeatInterval()}),b.on("timeupdate",function(){M._playbackHeartbeatInterval!==null&&b.emit("playbackheartbeat")}),b.on("devicesleep",function(I,Y){M._playbackHeartbeatInterval!==null&&(R().clearInterval(M._playbackHeartbeatInterval),b.emit("playbackheartbeatend",{viewer_time:Y.viewer_time}),M._playbackHeartbeatInterval=null)})}var h,f,y;return h=p,(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)}}])&&ve(h.prototype,f),y&&ve(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Fe(p,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(p,y.key,y)}}function fe(p,h,f){return h&&Fe(p.prototype,h),f&&Fe(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var Ce=fe(function p(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("viewinit",function(){f.viewErrored=!1}),h.on("error",function(y,b){try{var M=h.errorTranslator({player_error_code:b.player_error_code,player_error_message:b.player_error_message,player_error_context:b.player_error_context});M?(h.data.player_error_code=M.player_error_code||b.player_error_code,h.data.player_error_message=M.player_error_message||b.player_error_message,h.data.player_error_context=M.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(I){h.mux.log.warn("Exception in error translator callback.",I),f.viewErrored=!0}})});function Ve(p,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(p,y.key,y)}}var Xe=function(){function p(b){(function(M,I){if(!(M instanceof I))throw new TypeError("Cannot call a class as a function")})(this,p),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=p,(f=[{key:"_updateWatchTime",value:function(b,M){var I=M.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=I),V(this.pm.data,"view_watch_time",I-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=I}},{key:"_clearWatchTimeState",value:function(b,M){this._updateWatchTime(b,M),this._watchTimeTrackerLastCheckedTime=null}}])&&Ve(h.prototype,f),y&&Ve(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function it(p,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(p,y.key,y)}}var lt=function(){function p(b){(function(M,I){if(!(M instanceof I))throw new TypeError("Cannot call a class as a function")})(this,p),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=p,(f=[{key:"_updatePlaybackTime",value:function(){var b=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&b>this._playbackTimeTrackerLastPlayheadPosition){var M=b-this._playbackTimeTrackerLastPlayheadPosition;M<=1e3&&V(this.pm.data,"view_content_playback_time",M)}this._playbackTimeTrackerLastPlayheadPosition=b}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&it(h.prototype,f),y&&it(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Ct(p,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(p,y.key,y)}}var Rt=function(){function p(b){(function(I,Y){if(!(I instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b;var M=this._updatePlayheadTime.bind(this);b.on("playbackheartbeat",M),b.on("playbackheartbeatend",M),b.on("timeupdate",M),b.on("destroy",function(){b.off("timeupdate",M)})}var h,f,y;return h=p,(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,M){var I=this,Y=function(){I.pm.currentFragmentPDT&&I.pm.currentFragmentStart&&(I.pm.data.player_program_time=I.pm.currentFragmentPDT+I.pm.data.player_playhead_time-I.pm.currentFragmentStart)};if(M&&M.player_playhead_time)this.pm.data.player_playhead_time=M.player_playhead_time,Y(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var he=this.pm.getPlayheadTime();he!==void 0&&(this.pm.data.player_playhead_time=he,Y(),this._updateMaxPlayheadPosition())}}}])&&Ct(h.prototype,f),y&&Ct(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function St(p,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(p,y.key,y)}}function wt(p,h,f){return h&&St(p.prototype,h),f&&St(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var gt=wt(function p(h){if(function(M,I){if(!(M instanceof I))throw new TypeError("Cannot call a class as a function")}(this,p),!h.disableRebufferTracking){var f,y=function(M,I){b(I),f=void 0},b=function(M){if(f){var I=M.viewer_time-f;V(h.data,"view_rebuffer_duration",I),f=M.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(M,I){return b(I)}),h.on("rebufferstart",function(M,I){f||(V(h.data,"view_rebuffer_count",1),f=I.viewer_time,h.one("rebufferend",y))}),h.on("viewinit",function(){f=void 0,h.off("rebufferend",y)})}});function dt(p,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(p,y.key,y)}}var tt=function(){function p(b){var M=this;(function(I,Y){if(!(I instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,p),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(){M._cleanupRebufferTracker(null,{viewer_time:J.now()})}))}var h,f,y;return h=p,f=[{key:"_checkIfRebuffering",value:function(b,M){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(b,M);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var I=M.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&I>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=M.viewer_time}else this._cleanupRebufferTracker(b,M,!0);else this._prepareRebufferTrackerState(M.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,M){var I=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:M.viewer_time});else{if(this._lastCheckedTime===null)return;var Y=this.pm.data.player_playhead_time-this._lastPlayheadTime,he=M.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Y>0&&he-Y>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+he-Y}))}I?this._prepareRebufferTrackerState(M.viewer_time):this._clearRebufferTrackerState()}}],f&&dt(h.prototype,f),y&&dt(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}(),It=tt;function Ut(p,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(p,y.key,y)}}var Wt=function(){function p(b){var M=this;(function(I,Y){if(!(I instanceof Y))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b,b.on("viewinit",function(){var I=b.data,Y=I.view_id;if(!I.view_program_changed){var he=function(ee,Me){var ut=Me.viewer_time;ee.type==="playing"&&b.data.view_time_to_first_frame===void 0?M.calculateTimeToFirstFrame(ut||J.now(),Y):ee.type!=="adplaying"||b.data.view_time_to_first_frame!==void 0&&!M._inPrerollPosition()||M.calculateTimeToFirstFrame(ut||J.now(),Y)};b.one("playing",he),b.one("adplaying",he),b.one("viewend",function(){b.off("playing",he),b.off("adplaying",he)})}})}var h,f,y;return h=p,(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,M){M===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))}}])&&Ut(h.prototype,f),y&&Ut(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Bt(p,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(p,y.key,y)}}function ar(p,h,f){return h&&Bt(p.prototype,h),f&&Bt(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var te=ar(function p(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,p),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 M=Math.min(f._lastPlayerWidth/f._lastSourceWidth,f._lastPlayerHeight/f._lastSourceHeight),I=Math.max(0,M-1),Y=Math.max(0,1-M);h.data.view_max_upscale_percentage=Math.max(h.data.view_max_upscale_percentage||0,I),h.data.view_max_downscale_percentage=Math.max(h.data.view_max_downscale_percentage||0,Y),V(h.data,"view_total_content_playback_time",b),V(h.data,"view_total_upscaling",I*b),V(h.data,"view_total_downscaling",Y*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 N(p,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(p,y.key,y)}}function T(p,h,f){return h&&N(p.prototype,h),f&&N(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var O=T(function p(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,p),this.isSeeking=!1,h.on("seeking",function(y,b){K()(h.data,b),f._lastSeekingTime=J.now(),f.isSeeking===!1&&(f.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){f.isSeeking=!1;var y=f._lastSeekingTime||J.now(),b=J.now()-y;V(h.data,"view_seek_count",1),V(h.data,"view_seek_duration",b);var M=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(M,b)}),h.on("viewend",function(){f.isSeeking=!1})});function C(p,h){return function(f){if(Array.isArray(f))return f}(p)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var M,I,Y=[],he=!0,ee=!1;try{for(b=b.call(f);!(he=(M=b.next()).done)&&(Y.push(M.value),!y||Y.length!==y);he=!0);}catch(Me){ee=!0,I=Me}finally{try{he||b.return==null||b.return()}finally{if(ee)throw I}}return Y}}(p,h)||function(f,y){if(f){if(typeof f=="string")return G(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)?G(f,y):void 0}}(p,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 G(p,h){(h==null||h>p.length)&&(h=p.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=p[f];return y}function Q(p,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(p,y.key,y)}}var Z=function(p,h){p.push(h),p.sort(function(f,y){return f.viewer_time-y.viewer_time})},Te=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Re=function(){function p(b){var M=this;(function(Y,he){if(!(Y instanceof he))throw new TypeError("Cannot call a class as a function")})(this,p),this.pm=b,b.on("viewinit",function(){M.isAdBreak=!1,M._currentAdRequestNumber=0,M._currentAdResponseNumber=0,M._adRequests=[],M._adResponses=[],M._adHasPlayed=!1,M._wouldBeNewAdPlay=!0,M._prerollPlayTime=void 0}),Te.forEach(function(Y){return b.on(Y,M._updateAdData.bind(M))});var I=function(){M.isAdBreak=!1};b.on("adbreakstart",function(){M.isAdBreak=!0}),b.on("play",I),b.on("playing",I),b.on("viewend",I),b.on("adrequest",function(Y,he){he=K()({ad_request_id:"generatedAdRequestId"+M._currentAdRequestNumber++},he),Z(M._adRequests,he),V(b.data,"view_ad_request_count"),M.inPrerollPosition()&&(b.data.view_preroll_requested=!0,M._adHasPlayed||V(b.data,"view_preroll_request_count"))}),b.on("adresponse",function(Y,he){he=K()({ad_request_id:"generatedAdRequestId"+M._currentAdResponseNumber++},he),Z(M._adResponses,he);var ee=M.findAdRequest(he.ad_request_id);ee&&V(b.data,"view_ad_request_time",Math.max(0,he.viewer_time-ee.viewer_time))}),b.on("adplay",function(Y,he){M._adHasPlayed=!0,M._wouldBeNewAdPlay&&(M._wouldBeNewAdPlay=!1,V(b.data,"view_ad_played_count")),M.inPrerollPosition()&&!b.data.view_preroll_played&&(b.data.view_preroll_played=!0,M._adRequests.length>0&&(b.data.view_preroll_request_time=Math.max(0,he.viewer_time-M._adRequests[0].viewer_time)),b.data.view_start&&(b.data.view_startup_preroll_request_time=Math.max(0,he.viewer_time-b.data.view_start)),M._prerollPlayTime=he.viewer_time)}),b.on("adplaying",function(Y,he){M.inPrerollPosition()&&b.data.view_preroll_load_time===void 0&&M._prerollPlayTime!==void 0&&(b.data.view_preroll_load_time=he.viewer_time-M._prerollPlayTime,b.data.view_startup_preroll_load_time=he.viewer_time-M._prerollPlayTime)}),b.on("adended",function(){M._wouldBeNewAdPlay=!0}),b.on("aderror",function(){M._wouldBeNewAdPlay=!0})}var h,f,y;return h=p,(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 M=0;M<this._adRequests.length;M++)if(this._adRequests[M].ad_request_id===b)return this._adRequests[M]}},{key:"_updateAdData",value:function(b,M){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&M.ad_tag_url){var I=C(ke(M.ad_tag_url),2),Y=I[0],he=I[1];this.pm.data.view_preroll_ad_tag_domain=he,this.pm.data.view_preroll_ad_tag_hostname=Y}if(!this.pm.data.view_preroll_ad_asset_hostname&&M.ad_asset_url){var ee=C(ke(M.ad_asset_url),2),Me=ee[0],ut=ee[1];this.pm.data.view_preroll_ad_asset_domain=ut,this.pm.data.view_preroll_ad_asset_hostname=Me}}}}])&&Q(h.prototype,f),y&&Q(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Pe(p,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(p,y.key,y)}}function Be(p,h,f){return h&&Pe(p.prototype,h),f&&Pe(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var We=Be(function p(h){var f,y;(function(Y,he){if(!(Y instanceof he))throw new TypeError("Cannot call a class as a function")})(this,p);var b=function(){h.disableRebufferTracking||f&&(V(h.data,"view_waiting_rebuffer_duration",J.now()-f),f=!1,R().clearInterval(y))},M=!1,I=function(){M=!1,b()};h.on("waiting",function(){M&&(h.disableRebufferTracking||(V(h.data,"view_waiting_rebuffer_count",1),f=J.now(),y=R().setInterval(function(){if(f){var Y=J.now();V(h.data,"view_waiting_rebuffer_duration",Y-f),f=Y}},250)))}),h.on("playing",function(){b(),M=!0}),h.on("pause",I),h.on("seeking",I)});function Ge(p,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(p,y.key,y)}}function $e(p,h,f){return h&&Ge(p.prototype,h),f&&Ge(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var ht=$e(function p(h){var f=this;(function(M,I){if(!(M instanceof I))throw new TypeError("Cannot call a class as a function")})(this,p);var y=function(){f.lastWallClockTime=J.now(),h.on("before*",b)},b=function(M){var I=J.now(),Y=f.lastWallClockTime;f.lastWallClockTime=I,I-Y>3e4&&(h.emit("devicesleep",{viewer_time:Y}),K()(h.data,{viewer_time:Y}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:I}),K()(h.data,{viewer_time:I}),h.send("devicewake"))};h.one("playbackheartbeat",y),h.on("playbackheartbeatend",function(){h.off("before*",b),h.one("playbackheartbeat",y)})}),Dt=j(375),ze=j(655),Pt=j.n(ze),tr="muxData",jt=function(){var p;try{p=Dt.parse(Pt().get(tr)||"")}catch{p={}}return p},Ft=function(p){try{Pt().set(tr,Dt.stringify(p),{expires:7300})}catch{}},Ht=function(){var p=jt();return p.mux_viewer_id=p.mux_viewer_id||g(),p.msn=p.msn||Math.random(),Ft(p),{mux_viewer_id:p.mux_viewer_id,mux_sample_number:p.msn}};function rt(p,h){var f=h.beaconCollectionDomain,y=h.beaconDomain;if(f)return"https://"+f;var b=y||"litix.io";return(p=p||"inferred").match(/^[a-z0-9]+$/)?"https://"+p+"."+b:"https://img.litix.io/a.gif"}var lr=function(){var p;switch(Ar()){case"cellular":p="cellular";break;case"ethernet":p="wired";break;case"wifi":p="wifi";break;case void 0:break;default:p="other"}return p},Ar=function(){var p=R().navigator,h=p&&(p.connection||p.mozConnection||p.webkitConnection);return h&&h.type};lr.getConnectionFromAPI=Ar;var Kt=lr,Jt=Cr({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"}),pr=Cr({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 Cr(p){var h={};for(var f in p)p.hasOwnProperty(f)&&(h[p[f]]=f);return h}function vr(p){var h={},f={};return Object.keys(p).forEach(function(y){var b=!1;if(p.hasOwnProperty(y)&&p[y]!==void 0){var M=y.split("_"),I=M[0],Y=Jt[I];Y||(q.info("Data key word `"+M[0]+"` not expected in "+y),Y=I+"_"),M.splice(1).forEach(function(he){he==="url"&&(b=!0),pr[he]?Y+=pr[he]:Number(he)&&Math.floor(Number(he))===Number(he)?Y+=he:(q.info("Data key word `"+he+"` not expected in "+y),Y+="_"+he+"_")}),b?f[Y]=p[y]:h[Y]=p[y]}}),K()(h,f)}var Gt={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Di=["hb","requestcompleted","requestfailed","requestcanceled"],nn="https://img.litix.io",kr=function(p){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=p||nn,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=K()({},Gt,h)};kr.prototype.queueEvent=function(p,h){var f=K()({},h);return(this._eventQueue.length<=this._options.maxQueueLength||p==="eventrateexceeded")&&(this._eventQueue.push(f),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},kr.prototype.flushEvents=function(){var p=arguments.length>0&&arguments[0]!==void 0&&arguments[0];p&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},kr.prototype.destroy=function(){var p=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,p?this._clearBeaconQueue():this.flushEvents(),R().clearTimeout(this._sendTimeout)},kr.prototype._clearBeaconQueue=function(){var p=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,h=this._eventQueue.slice(p);p>0&&K()(h[h.length-1],vr({mux_view_message:"event queue truncated"}));var f=this._createPayload(h);li(this._beaconUrl,f,!0,function(){})},kr.prototype._sendBeaconQueue=function(){var p=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=J.now();li(this._beaconUrl,f,!1,function(b,M){M?(p._eventQueue=h.concat(p._eventQueue),p._failureCount+=1,q.info("Error sending beacon: "+M)):p._failureCount=0,p._roundTripTime=J.now()-y,p._postInFlight=!1})}},kr.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var p=Math.pow(2,this._failureCount-1);return(1+(p*=Math.random()))*this._options.baseTimeBetweenBeacons},kr.prototype._startBeaconSending=function(){var p=this;R().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=R().setTimeout(function(){p._eventQueue.length&&p._sendBeaconQueue(),p._startBeaconSending()},this._getNextBeaconTime()))},kr.prototype._createPayload=function(p){var h,f,y,b=this,M={transmission_timestamp:Math.round(J.now())};this._roundTripTime&&(M.rtt_ms=Math.round(this._roundTripTime));var I=function(){h=JSON.stringify({metadata:M,events:f||p}),y=h.length/1024},Y=function(){return y<=b._options.maxPayloadKBSize};return I(),Y()||(q.info("Payload size is too big ("+y+" kb). Removing unnecessary events."),f=p.filter(function(he){return Di.indexOf(he.e)===-1}),I()),Y()||(q.info("Payload size still too big ("+y+" kb). Cropping fields.."),f.forEach(function(he){for(var ee in he){var Me=he[ee];typeof Me=="string"&&Me.length>51200&&(he[ee]=Me.substring(0,51200))}}),I()),h};var li=function(p,h,f,y){if(f&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(p,h))y();else if(R().fetch)R().fetch(p,{method:"POST",body:h,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(M){return y(null,M.ok?null:"Error")}).catch(function(M){return y(null,M)});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",p),b.setRequestHeader("Content-Type","text/plain"),void b.send(h)}y()}},an=kr;function sn(p,h){return function(f){if(Array.isArray(f))return f}(p)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var M,I,Y=[],he=!0,ee=!1;try{for(b=b.call(f);!(he=(M=b.next()).done)&&(Y.push(M.value),!y||Y.length!==y);he=!0);}catch(Me){ee=!0,I=Me}finally{try{he||b.return==null||b.return()}finally{if(ee)throw I}}return Y}}(p,h)||function(f,y){if(f){if(typeof f=="string")return ui(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)?ui(f,y):void 0}}(p,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 ui(p,h){(h==null||h>p.length)&&(h=p.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=p[f];return y}function di(p,h){var f=Object.keys(p);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(p);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(p,b).enumerable})),f.push.apply(f,y)}return f}function Kr(p){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?di(Object(f),!0).forEach(function(y){Hr(p,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(p,Object.getOwnPropertyDescriptors(f)):di(Object(f)).forEach(function(y){Object.defineProperty(p,y,Object.getOwnPropertyDescriptor(f,y))})}return p}function Zr(p){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(p)}function wn(p,h){if(!(p instanceof h))throw new TypeError("Cannot call a class as a function")}function on(p,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(p,y.key,y)}}function Hr(p,h,f){return h in p?Object.defineProperty(p,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):p[h]=f,p}var br=["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"],At=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended"],ln=["viewstart","error","ended","viewend"],qr=function(){function p(b,M){var I,Y,he,ee,Me,ut,Ze,st,Qe,ot,Ot,qt,rr,ur,Tt,Zt=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};wn(this,p),Hr(this,"previousBeaconData",null),Hr(this,"lastEventTime",0),Hr(this,"rateLimited",!1),this.mux=b,this.envKey=M,this.options=Zt,this.eventQueue=new an(rt(this.envKey,this.options)),this.sampleRate=(I=this.options.sampleRate)!==null&&I!==void 0?I:1,this.disableCookies=(Y=this.options.disableCookies)!==null&&Y!==void 0&&Y,this.respectDoNotTrack=(he=this.options.respectDoNotTrack)!==null&&he!==void 0&&he,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:(ee=this.options.platform)===null||ee===void 0?void 0:ee.name,viewer_application_version:(Me=this.options.platform)===null||Me===void 0?void 0:Me.version,viewer_application_engine:(ut=this.options.platform)===null||ut===void 0?void 0:ut.layout,viewer_device_name:(Ze=this.options.platform)===null||Ze===void 0?void 0:Ze.product,viewer_device_category:"",viewer_device_manufacturer:(st=this.options.platform)===null||st===void 0?void 0:st.manufacturer,viewer_os_family:(Qe=this.options.platform)===null||Qe===void 0||(ot=Qe.os)===null||ot===void 0?void 0:ot.family,viewer_os_architecture:(Ot=this.options.platform)===null||Ot===void 0||(qt=Ot.os)===null||qt===void 0?void 0:qt.architecture,viewer_os_version:(rr=this.options.platform)===null||rr===void 0||(ur=rr.os)===null||ur===void 0?void 0:ur.version,viewer_connection_type:Kt(),page_url:R()===null||R()===void 0||(Tt=R().location)===null||Tt===void 0?void 0:Tt.href},this.viewerData=this.disableCookies?{}:Ht()}var h,f,y;return h=p,(f=[{key:"send",value:function(b,M){var I;if(b){if(this.respectDoNotTrack&&ye())return q.info("Not sending `"+b+"` because Do Not Track is enabled");if(!M||Zr(M)!=="object")return q.error("A data object was expected in send() but was not provided");var Y,he,ee=this.disableCookies?{}:(Y=jt(),he=J.now(),Y.session_start&&(Y.sst=Y.session_start,delete Y.session_start),Y.session_id&&(Y.sid=Y.session_id,delete Y.session_id),Y.session_expires&&(Y.sex=Y.session_expires,delete Y.session_expires),(!Y.sex||Y.sex<he)&&(Y.sid=g(),Y.sst=he),Y.sex=he+15e5,Ft(Y),{session_id:Y.sid,session_start:Y.sst,session_expires:Y.sex}),Me=Kr(Kr(Kr(Kr(Kr({},this.pageLevelData),M),ee),this.viewerData),{},{event:b,env_key:this.envKey});Me.user_id&&(Me.viewer_user_id=Me.user_id,delete Me.user_id);var ut=((I=Me.mux_sample_number)!==null&&I!==void 0?I:0)>=this.sampleRate,Ze=vr(this._deduplicateBeaconData(b,Me));if(this.lastEventTime=this.mux.utils.now(),ut)return q.info("Not sending event due to sample rate restriction",b,Me,Ze);if(this.envKey||q.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",b,Me,Ze),!this.rateLimited){if(q.info("Sending event",b,Me,Ze),this.rateLimited=!this.eventQueue.queueEvent(b,Ze),this.mux.WINDOW_UNLOADING&&b==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&b==="hb"?this.eventQueue.flushEvents(!0):ln.indexOf(b)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return Me.event="eventrateexceeded",Ze=vr(Me),this.eventQueue.queueEvent(Me.event,Ze),q.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(b,M){var I=this,Y={},he=M.view_id;if(!he||b==="viewstart"||b==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)Y=Kr({},M),he&&(this.previousBeaconData=Y),he&&b==="viewend"&&(this.previousBeaconData=null);else{var ee=b.indexOf("request")===0;Object.entries(M).forEach(function(Me){var ut=sn(Me,2),Ze=ut[0],st=ut[1];I.previousBeaconData&&(st!==I.previousBeaconData[Ze]||br.indexOf(Ze)>-1||I.objectHasChanged(ee,Ze,st,I.previousBeaconData[Ze])||I.eventRequiresKey(b,Ze))&&(Y[Ze]=st,I.previousBeaconData[Ze]=st)})}return Y}},{key:"objectHasChanged",value:function(b,M,I,Y){return!(!b||M.indexOf("request_")!==0||M!=="request_response_headers"&&Zr(I)==="object"&&Zr(Y)==="object"&&Object.keys(I||{}).length===Object.keys(Y||{}).length)}},{key:"eventRequiresKey",value:function(b,M){return b==="renditionchange"&&M.indexOf("video_source_")===0||!(M.indexOf("ad_")!==0||!At.includes(b))}}])&&on(h.prototype,f),y&&on(h,y),Object.defineProperty(h,"prototype",{writable:!1}),p}();function Nr(p,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(p,y.key,y)}}function ci(p,h,f){return h&&Nr(p.prototype,h),f&&Nr(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var wr=ci(function p(h){(function(ee,Me){if(!(ee instanceof Me))throw new TypeError("Cannot call a class as a function")})(this,p);var f=0,y=0,b=0,M=0,I=0,Y=0,he=0;h.on("requestcompleted",function(ee,Me){var ut,Ze,st=Me.request_start,Qe=Me.request_response_start,ot=Me.request_response_end,Ot=Me.request_bytes_loaded;if(M++,Qe?(ut=Qe-st,Ze=ot-Qe):Ze=ot-st,Ze>0&&Ot>0){var qt=Ot/Ze*8e3;I++,y+=Ot,b+=Ze,h.data.view_min_request_throughput=Math.min(h.data.view_min_request_throughput||1/0,qt),h.data.view_average_request_throughput=y/b*8e3,h.data.view_request_count=M,ut>0&&(f+=ut,h.data.view_max_request_latency=Math.max(h.data.view_max_request_latency||0,ut),h.data.view_average_request_latency=f/I)}}),h.on("requestfailed",function(ee,Me){M++,Y++,h.data.view_request_count=M,h.data.view_request_failed_count=Y}),h.on("requestcanceled",function(ee,Me){M++,he++,h.data.view_request_count=M,h.data.view_request_canceled_count=he})});function Vr(p,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(p,y.key,y)}}function ei(p,h,f){return h&&Vr(p.prototype,h),f&&Vr(p,f),Object.defineProperty(p,"prototype",{writable:!1}),p}var Lr=ei(function p(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,p),h.on("before*",function(y,b){var M=b.viewer_time,I=J.now(),Y=f._lastEventTime;if(f._lastEventTime=I,Y&&I-Y>36e5){var he=Object.keys(h.data).reduce(function(ee,Me){return Me.indexOf("video_")===0?K()(ee,function(ut,Ze,st){return Ze in ut?Object.defineProperty(ut,Ze,{value:st,enumerable:!0,configurable:!0,writable:!0}):ut[Ze]=st,ut}({},Me,h.data[Me])):ee},{});h.mux.log.info("Received event after at least an hour inactivity, creating a new view"),h.emit("viewinit",K()({viewer_time:M},he)),h.playbackHeartbeat._playheadShouldBeProgressing&&y.type!=="play"&&y.type!=="adbreakstart"&&(h.emit("play",{viewer_time:M}),y.type!=="playing"&&h.emit("playing",{viewer_time:M}))}})});function Ur(p){return Ur=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},Ur(p)}function Yr(p,h){return function(f){if(Array.isArray(f))return f}(p)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var M,I,Y=[],he=!0,ee=!1;try{for(b=b.call(f);!(he=(M=b.next()).done)&&(Y.push(M.value),!y||Y.length!==y);he=!0);}catch(Me){ee=!0,I=Me}finally{try{he||b.return==null||b.return()}finally{if(ee)throw I}}return Y}}(p,h)||function(f,y){if(f){if(typeof f=="string")return hi(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)?hi(f,y):void 0}}(p,h)||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 hi(p,h){(h==null||h>p.length)&&(h=p.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=p[f];return y}function fi(p,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(p,y.key,y)}}function vi(p,h){return vi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,y){return f.__proto__=y,f},vi(p,h)}function Li(p){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=pi(p);if(h){var b=pi(this).constructor;f=Reflect.construct(y,arguments,b)}else f=y.apply(this,arguments);return un(this,f)}}function un(p,h){if(h&&(Ur(h)==="object"||typeof h=="function"))return h;if(h!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return $t(p)}function $t(p){if(p===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return p}function pi(p){return pi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},pi(p)}var Dn=["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"],dn=function(p){(function(I,Y){if(typeof Y!="function"&&Y!==null)throw new TypeError("Super expression must either be null or a function");I.prototype=Object.create(Y&&Y.prototype,{constructor:{value:I,writable:!0,configurable:!0}}),Object.defineProperty(I,"prototype",{writable:!1}),Y&&vi(I,Y)})(M,p);var h,f,y,b=Li(M);function M(I,Y,he){var ee;(function(Qe,ot){if(!(Qe instanceof ot))throw new TypeError("Cannot call a class as a function")})(this,M),(ee=b.call(this)).DOM_CONTENT_LOADED_EVENT_END=Ne.domContentLoadedEventEnd(),ee.NAVIGATION_START=Ne.navigationStart(),ee.mux=I,ee.id=Y,(he=K()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(Qe){return Qe}},he)).data=he.data||{},he.data.property_key&&(he.data.env_key=he.data.property_key,delete he.data.property_key),q.setLevel(he.debug?"debug":"warn"),ee.getPlayheadTime=he.getPlayheadTime,ee.getStateData=he.getStateData||function(){return{}},ee.getAdData=he.getAdData||function(){},ee.minimumRebufferDuration=he.minimumRebufferDuration,ee.sustainedRebufferThreshold=he.sustainedRebufferThreshold,ee.playbackHeartbeatTime=he.playbackHeartbeatTime,ee.disableRebufferTracking=he.disableRebufferTracking,ee.disableRebufferTracking&&ee.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."),ee.disablePlayheadRebufferTracking=he.disablePlayheadRebufferTracking,ee.errorTranslator=he.errorTranslator,ee.playbackEventDispatcher=new qr(I,he.data.env_key,he),ee.data={player_instance_id:g(),mux_sample_rate:he.sampleRate,beacon_domain:he.beaconCollectionDomain?he.beaconCollectionDomain:he.beaconDomain},ee.data.view_sequence_number=1,ee.data.player_sequence_number=1,ee.oldEmit=ee.emit,ee.emit=function(Qe,ot){ot=K()({viewer_time:this.mux.utils.now()},ot),this.oldEmit(Qe,ot)};var Me=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind($t(ee));ee.on("viewinit",function(Qe,ot){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),K()(this.data,ot),this._initializeViewData(),this.one("play",Me),this.one("adbreakstart",Me)});var ut=function(Qe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",Qe)}.bind($t(ee));if(ee.on("videochange",function(Qe,ot){ut(ot)}),ee.on("programchange",function(Qe,ot){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."),ut(K()(ot,{view_program_changed:!0})),Me(),this.emit("play"),this.emit("playing")}),ee.on("fragmentchange",function(Qe,ot){this.currentFragmentPDT=ot.currentFragmentPDT,this.currentFragmentStart=ot.currentFragmentStart}),ee.on("destroy",ee.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var Ze=function(){var Qe=ee.data.view_start!==void 0;ee.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",Qe&&ee.mux.WINDOW_HIDDEN&&(ee.data.player_is_paused||ee.emit("hb"))};window.addEventListener("visibilitychange",Ze,!1);var st=function(Qe){Qe.persisted||ee.destroy()};window.addEventListener("pagehide",st,!1),ee.on("destroy",function(){window.removeEventListener("visibilitychange",Ze),window.removeEventListener("pagehide",st)})}return ee.on("playerready",function(Qe,ot){K()(this.data,ot)}),Dn.forEach(function(Qe){ee.on(Qe,function(ot,Ot){Qe.indexOf("ad")!==0&&this._updateStateData(),K()(this.data,Ot),this._sanitizeData()}),ee.on("after"+Qe,function(){(Qe!=="error"||this.errorTracker.viewErrored)&&this.send(Qe)})}),ee.on("viewend",function(Qe,ot){K()(ee.data,ot)}),ee.one("playerready",function(Qe){var ot=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ot-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}),ee.longResumeTracker=new Lr($t(ee)),ee.errorTracker=new Ce($t(ee)),new ht($t(ee)),ee.seekingTracker=new O($t(ee)),ee.playheadTime=new Rt($t(ee)),ee.playbackHeartbeat=new Ie($t(ee)),new te($t(ee)),ee.watchTimeTracker=new Xe($t(ee)),new lt($t(ee)),ee.adTracker=new Re($t(ee)),new It($t(ee)),new gt($t(ee)),new Wt($t(ee)),new We($t(ee)),new wr($t(ee)),he.hlsjs&&ee.addHLSJS(he),he.dashjs&&ee.addDashJS(he),ee.emit("viewinit",he.data),ee}return h=M,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(I){var Y=K()({},this.data);if(Y.video_source_is_live===void 0&&(Y.player_source_duration===1/0||Y.video_source_duration===1/0?Y.video_source_is_live=!0:(Y.player_source_duration>0||Y.video_source_duration>0)&&(Y.video_source_is_live=!1)),Y.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(ut){Y[ut]=void 0}),Y.video_source_url=Y.video_source_url||Y.player_source_url,Y.video_source_url){var he=Yr(ke(Y.video_source_url),2),ee=he[0],Me=he[1];Y.video_source_domain=Me,Y.video_source_hostname=ee}delete Y.ad_request_id,this.playbackEventDispatcher.send(I,Y),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){K()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var I=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Y){var he=parseInt(I.data[Y],10);I.data[Y]=isNaN(he)?void 0:he}),["player_source_url","video_source_url"].forEach(function(Y){if(I.data[Y]){var he=I.data[Y].toLowerCase();he.indexOf("data:")!==0&&he.indexOf("blob:")!==0||(I.data[Y]="MSE style URL")}})}},{key:"_resetVideoData",value:function(I,Y){var he=this;Object.keys(this.data).forEach(function(ee){ee.indexOf("video_")===0&&delete he.data[ee]})}},{key:"_resetViewData",value:function(){var I=this;Object.keys(this.data).forEach(function(Y){Y.indexOf("view_")===0&&delete I.data[Y]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(I,Y){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var I=this,Y=this.data.view_id=g(),he=function(){Y===I.data.view_id&&V(I.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",he):he()}},{key:"_restartHeartBeat",value:function(){var I=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){I.data.player_is_paused||I.emit("hb")},1e4))}},{key:"addHLSJS",value:function(I){I.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=I.hlsjs,function(Y,he,ee){var Me=arguments.length>4?arguments[4]:void 0,ut=Y.log,Ze=Y.utils.secondsToMs,st=function(Lt){var nt,vt=parseInt(Me.version);return vt===1&&Lt.programDateTime!==null&&(nt=Lt.programDateTime),vt===0&&Lt.pdt!==null&&(nt=Lt.pdt),nt};if(Ne.exists()){var Qe=function(Lt,nt){return Y.emit(he,Lt,nt)},ot=function(Lt,nt){var vt=nt.levels,et=nt.audioTracks,ft=nt.url,Vt=nt.stats,Xt=nt.networkDetails,dr=nt.sessionData,or={},mr={};vt.forEach(function(Er,zr){or[zr]={width:Er.width,height:Er.height,bitrate:Er.bitrate,attrs:Er.attrs}}),et.forEach(function(Er,zr){mr[zr]={name:Er.name,language:Er.lang,bitrate:Er.bitrate}});var cr=$(Vt),yr=cr.bytesLoaded,Qt=cr.requestStart,hr=cr.responseStart,ni=cr.responseEnd;Qe("requestcompleted",Se(Se({},D(dr)),{},{request_event_type:Lt,request_bytes_loaded:yr,request_start:Qt,request_response_start:hr,request_response_end:ni,request_type:"manifest",request_hostname:Ee(ft),request_response_headers:Le(Xt),request_rendition_lists:{media:or,audio:mr,video:{}}}))};ee.on(Me.Events.MANIFEST_LOADED,ot);var Ot=function(Lt,nt){var vt=nt.details,et=nt.level,ft=nt.networkDetails,Vt=nt.stats,Xt=$(Vt),dr=Xt.bytesLoaded,or=Xt.requestStart,mr=Xt.responseStart,cr=Xt.responseEnd,yr=vt.fragments[vt.fragments.length-1],Qt=st(yr)+Ze(yr.duration);Qe("requestcompleted",{request_event_type:Lt,request_bytes_loaded:dr,request_start:or,request_response_start:mr,request_response_end:cr,request_current_level:et,request_type:"manifest",request_hostname:Ee(vt.url),request_response_headers:Le(ft),video_holdback:vt.holdBack&&Ze(vt.holdBack),video_part_holdback:vt.partHoldBack&&Ze(vt.partHoldBack),video_part_target_duration:vt.partTarget&&Ze(vt.partTarget),video_target_duration:vt.targetduration&&Ze(vt.targetduration),video_source_is_live:vt.live,player_manifest_newest_program_time:isNaN(Qt)?void 0:Qt})};ee.on(Me.Events.LEVEL_LOADED,Ot);var qt=function(Lt,nt){var vt=nt.details,et=nt.networkDetails,ft=nt.stats,Vt=$(ft),Xt=Vt.bytesLoaded,dr=Vt.requestStart,or=Vt.responseStart,mr=Vt.responseEnd;Qe("requestcompleted",{request_event_type:Lt,request_bytes_loaded:Xt,request_start:dr,request_response_start:or,request_response_end:mr,request_type:"manifest",request_hostname:Ee(vt.url),request_response_headers:Le(et)})};ee.on(Me.Events.AUDIO_TRACK_LOADED,qt);var rr=function(Lt,nt){var vt=nt.stats,et=nt.networkDetails,ft=nt.frag;vt=vt||ft.stats;var Vt=$(vt),Xt=Vt.bytesLoaded,dr=Vt.requestStart,or=Vt.responseStart,mr=Vt.responseEnd,cr=Le(et),yr=cr==null?void 0:cr["x-request-id"],Qt={request_event_type:Lt,request_bytes_loaded:Xt,request_start:dr,request_response_start:or,request_response_end:mr,request_hostname:et?Ee(et.responseURL):void 0,request_id:yr,request_response_headers:cr,request_media_duration:ft.duration,request_url:et==null?void 0:et.responseURL};ft.type==="main"?(Qt.request_type="media",Qt.request_current_level=ft.level,Qt.request_video_width=(ee.levels[ft.level]||{}).width,Qt.request_video_height=(ee.levels[ft.level]||{}).height,Qt.request_labeled_bitrate=(ee.levels[ft.level]||{}).bitrate):Qt.request_type=ft.type,Qe("requestcompleted",Qt)};ee.on(Me.Events.FRAG_LOADED,rr);var ur=function(Lt,nt){var vt=nt.frag,et=vt.start,ft={currentFragmentPDT:st(vt),currentFragmentStart:Ze(et)};Qe("fragmentchange",ft)};ee.on(Me.Events.FRAG_CHANGED,ur);var Tt=function(Lt,nt){var vt=nt.type,et=nt.details,ft=nt.response,Vt=nt.fatal,Xt=nt.context,dr=nt.frag;if(et===Me.ErrorDetails.MANIFEST_LOAD_ERROR||et===Me.ErrorDetails.MANIFEST_LOAD_TIMEOUT||et===Me.ErrorDetails.FRAG_LOAD_ERROR||et===Me.ErrorDetails.FRAG_LOAD_TIMEOUT||et===Me.ErrorDetails.LEVEL_LOAD_ERROR||et===Me.ErrorDetails.LEVEL_LOAD_TIMEOUT){var or=dr&&dr.url||Xt&&Xt.url||"";Qe("requestfailed",{request_error:et,request_url:or,request_hostname:Ee(or),request_type:et===Me.ErrorDetails.FRAG_LOAD_ERROR||et===Me.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:ft&&ft.code,request_error_text:ft&&ft.text})}Vt&&Qe("error",{player_error_code:vt,player_error_message:et})};ee.on(Me.Events.ERROR,Tt);var Zt=function(Lt,nt){var vt=nt.frag,et=vt&&vt._url||"";Qe("requestcanceled",{request_event_type:Lt,request_url:et,request_type:"media",request_hostname:Ee(et)})};ee.on(Me.Events.FRAG_LOAD_EMERGENCY_ABORTED,Zt);var sr=function(Lt,nt){var vt=nt.level,et=ee.levels[vt];if(et&&et.attrs&&et.attrs.BANDWIDTH){var ft,Vt=et.attrs.BANDWIDTH,Xt=parseFloat(et.attrs["FRAME-RATE"]);isNaN(Xt)||(ft=Xt),Vt?Qe("renditionchange",{video_source_fps:ft,video_source_bitrate:Vt,video_source_width:et.width,video_source_height:et.height,video_source_rendition_name:et.name,video_source_codec:et==null?void 0:et.videoCodec}):ut.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};ee.on(Me.Events.LEVEL_SWITCHED,sr),ee._stopMuxMonitor=function(){ee.off(Me.Events.MANIFEST_LOADED,ot),ee.off(Me.Events.LEVEL_LOADED,Ot),ee.off(Me.Events.AUDIO_TRACK_LOADED,qt),ee.off(Me.Events.FRAG_LOADED,rr),ee.off(Me.Events.FRAG_CHANGED,ur),ee.off(Me.Events.ERROR,Tt),ee.off(Me.Events.FRAG_LOAD_EMERGENCY_ABORTED,Zt),ee.off(Me.Events.LEVEL_SWITCHED,sr),ee.off(Me.Events.DESTROYING,ee._stopMuxMonitor),delete ee._stopMuxMonitor},ee.on(Me.Events.DESTROYING,ee._stopMuxMonitor)}else ut.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,I.hlsjs,{},I.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var I;this.hlsjs&&((I=this.hlsjs)&&typeof I._stopMuxMonitor=="function"&&I._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(I){I.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=I.dashjs,function(Y,he,ee){var Me=Y.log;if(ee&&ee.on){var ut=function(Tt,Zt){return Y.emit(he,Tt,Zt)},Ze=function(Tt){var Zt=Tt.type,sr=(Tt.data||{}).url;ut("requestcompleted",{request_event_type:Zt,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:Ee(sr),request_url:sr})};ee.on("manifestLoaded",Ze);var st={},Qe=function(Tt){var Zt=Tt.type,sr=Tt.fragmentModel,Lt=(Tt.chunk||{}).mediaInfo||{},nt=Lt.type,vt=Lt.bitrateList,et={};(vt=vt||[]).forEach(function(Qt,hr){et[hr]={},et[hr].width=Qt.width,et[hr].height=Qt.height,et[hr].bitrate=Qt.bandwidth,et[hr].attrs={}}),nt==="video"?st.video=et:nt==="audio"?st.audio=et:st.media=et;var ft=qe(sr,ee),Vt=ft.requestStart,Xt=ft.requestResponseStart,dr=ft.requestResponseEnd,or=ft.requestResponseHeaders,mr=ft.requestMediaDuration,cr=ft.requestHostname,yr=ft.requestUrl;ut("requestcompleted",{request_event_type:Zt,request_start:Vt,request_response_start:Xt,request_response_end:dr,request_bytes_loaded:-1,request_type:nt+"_init",request_response_headers:or,request_hostname:cr,request_url:yr,request_media_duration:mr,request_rendition_lists:st})};ee.on("initFragmentLoaded",Qe);var ot=function(Tt){var Zt=Tt.type,sr=Tt.fragmentModel,Lt=Tt.chunk||{},nt=Lt.mediaInfo,vt=Lt.start,et=(nt||{}).type,ft=qe(sr,ee),Vt=ft.requestStart,Xt=ft.requestResponseStart,dr=ft.requestResponseEnd,or=ft.requestBytesLoaded,mr=ft.requestResponseHeaders,cr=ft.requestMediaDuration,yr=ft.requestHostname,Qt=ft.requestUrl,hr=at(et,ee),ni=hr.currentLevel,Er=hr.renditionWidth,zr=hr.renditionHeight,pn=hr.renditionBitrate;ut("requestcompleted",{request_event_type:Zt,request_start:Vt,request_response_start:Xt,request_response_end:dr,request_bytes_loaded:or,request_type:et,request_response_headers:mr,request_hostname:yr,request_url:Qt,request_media_start_time:vt,request_media_duration:cr,request_current_level:ni,request_labeled_bitrate:pn,request_video_width:Er,request_video_height:zr})};ee.on("mediaFragmentLoaded",ot);var Ot={video:void 0,audio:void 0,totalBitrate:void 0},qt=function(){if(Ot.video&&typeof Ot.video.bitrate=="number"){if(Ot.video.width&&Ot.video.height){var Tt=Ot.video.bitrate;return Ot.audio&&typeof Ot.audio.bitrate=="number"&&(Tt+=Ot.audio.bitrate),Tt!==Ot.totalBitrate?(Ot.totalBitrate=Tt,{video_source_bitrate:Tt,video_source_height:Ot.video.height,video_source_width:Ot.video.width,video_source_codec:ie(Ot.video.codec)}):void 0}Me.warn("have bitrate info for video but missing width/height")}},rr=function(Tt,Zt,sr){if(typeof Tt.newQuality=="number"){var Lt=Tt.mediaType;if(Lt==="audio"||Lt==="video"){var nt=ee.getBitrateInfoListFor(Lt).find(function(et){return et.qualityIndex===Tt.newQuality});if(nt&&typeof nt.bitrate=="number"){Ot[Lt]=xe(xe({},nt),{},{codec:ee.getCurrentTrackFor(Lt).codec});var vt=qt();vt&&ut("renditionchange",vt)}else Me.warn("missing bitrate info for ".concat(Lt))}}else Me.warn("missing evt.newQuality in qualityChangeRendered event",Tt)};ee.on("qualityChangeRendered",rr);var ur=function(Tt){var Zt=Tt.error,sr=Tt.event,Lt=(sr=sr||{}).request||{},nt=R().event&&R().event.currentTarget||{};ut("requestfailed",{request_error:Zt+"_"+sr.id+"_"+Lt.type,request_url:sr.url,request_hostname:Ee(sr.url),request_type:Lt.mediaType,request_error_code:nt.status,request_error_type:nt.statusText})};ee.on("error",ur),ee._stopMuxMonitor=function(){ee.off("manifestLoaded",Ze),ee.off("initFragmentLoaded",Qe),ee.off("mediaFragmentLoaded",ot),ee.off("qualityChangeRendered",rr),ee.off("error",ur),delete ee._stopMuxMonitor}}else Me.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,I.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var I;this.dashjs&&((I=this.dashjs)&&typeof I._stopMuxMonitor=="function"&&I._stopMuxMonitor(),this.dashjs=void 0)}}],f&&fi(h.prototype,f),y&&fi(h,y),Object.defineProperty(h,"prototype",{writable:!1}),M}(H),Br=dn,Ri=j(153),ti=j.n(Ri);function ri(p){return ri=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},ri(p)}function Ii(p,h){return function(f){if(Array.isArray(f))return f}(p)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var M,I,Y=[],he=!0,ee=!1;try{for(b=b.call(f);!(he=(M=b.next()).done)&&(Y.push(M.value),!y||Y.length!==y);he=!0);}catch(Me){ee=!0,I=Me}finally{try{he||b.return==null||b.return()}finally{if(ee)throw I}}return Y}}(p,h)||function(f,y){if(f){if(typeof f=="string")return cn(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)?cn(f,y):void 0}}(p,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function cn(p,h){(h==null||h>p.length)&&(h=p.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=p[f];return y}var Wr,Ci=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],Ln={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};R()&&R().WeakMap&&(Wr=new WeakMap);var gi="#EXT-X-TARGETDURATION",Rn="#EXT-X-PART-INF",In="#EXT-X-SERVER-CONTROL",Cn="#EXTINF",hn="#EXT-X-PROGRAM-DATE-TIME",mi="#EXT-X-VERSION",Pi="#EXT-X-SESSION-DATA",yi=function(p){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(p),this.manifest};yi.prototype.process=function(p){var h;for(this.buffer+=p,h=this.buffer.indexOf(`
|
|
6
|
+
`);h>-1;h=this.buffer.indexOf(`
|
|
7
|
+
`))this.processLine(this.buffer.substring(0,h)),this.buffer=this.buffer.substring(h+1)},yi.prototype.processLine=function(p){var h=p.indexOf(":"),f=xn(p,h),y=f[0],b=f.length===2?ii(f[1]):void 0;if(y[0]!=="#")this.currentUri.uri=y,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(y){case gi:if(!isFinite(b)||b<0)return;this.manifest.targetDuration=b,this.setHoldBack();break;case Rn:Oi(this.manifest,f),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case In:Oi(this.manifest,f),this.setHoldBack();break;case Cn:b===0?this.currentUri.duration=.01:b>0&&(this.currentUri.duration=b);break;case hn:var M=b,I=new Date(M);this.manifest.dateTimeString||(this.manifest.dateTimeString=M,this.manifest.dateTimeObject=I),this.currentUri.dateTimeString=M,this.currentUri.dateTimeObject=I;break;case mi:Oi(this.manifest,f);break;case Pi:var Y=Mn(f[1]),he=D(Y);K()(this.manifest.sessionData,he)}},yi.prototype.setHoldBack=function(){var p=this.manifest,h=p.serverControl,f=p.targetDuration,y=p.partTargetDuration;if(h){var b="holdBack",M="partHoldBack",I=f&&3*f,Y=y&&2*y;f&&!h.hasOwnProperty(b)&&(h[b]=I),I&&h[b]<I&&(h[b]=I),y&&!h.hasOwnProperty(M)&&(h[M]=3*y),y&&h[M]<Y&&(h[M]=Y)}};var Oi=function(p,h){var f,y=fn(h[0].replace("#EXT-X-",""));xi(h[1])?(f={},f=K()(On(h[1]),f)):f=ii(h[1]),p[y]=f},fn=function(p){return p.toLowerCase().replace(/-(\w)/g,function(h){return h[1].toUpperCase()})},ii=function(p){if(p.toLowerCase()==="yes"||p.toLowerCase()==="no")return p.toLowerCase()==="yes";var h=p.indexOf(":")!==-1?p:parseFloat(p);return isNaN(h)?p:h},Pn=function(p){var h={},f=p.split("=");return f.length>1&&(h[fn(f[0])]=ii(f[1])),h},On=function(p){for(var h=p.split(","),f={},y=0;h.length>y;y++){var b=h[y],M=Pn(b);f=K()(M,f)}return f},xi=function(p){return p.indexOf("=")>-1},xn=function(p,h){return h===-1?[p]:[p.substring(0,h),p.substring(h+1)]},Mn=function(p){var h={};if(p){var f=p.search(",");return[p.slice(0,f),p.slice(f+1)].forEach(function(y,b){for(var M=y.replace(/['"]+/g,"").split("="),I=0;I<M.length;I++)M[I]==="DATA-ID"&&(h["DATA-ID"]=M[1-I]),M[I]==="VALUE"&&(h.VALUE=M[1-I])}),{data:h}}},Fn=yi,Mi={safeCall:function(p,h,f,y){var b=y;if(p&&typeof p[h]=="function")try{b=p[h].apply(p,f)}catch(M){q.info("safeCall error",M)}return b},safeIncrement:V,getComputedStyle:function(p,h){var f;if(p&&h&&R()&&typeof R().getComputedStyle=="function")return Wr&&Wr.has(p)&&(f=Wr.get(p)),f||(f=R().getComputedStyle(p,null),Wr&&Wr.set(p,f)),f.getPropertyValue(h)},secondsToMs:function(p){return Math.floor(1e3*p)},assign:K(),headersStringToObject:U,extractHostnameAndDomain:ke,extractHostname:Ee,manifestParser:Fn,generateShortID:k,generateUUID:g,now:J.now},Fi={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 Nn(p,h){return function(f){if(Array.isArray(f))return f}(p)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var M,I,Y=[],he=!0,ee=!1;try{for(b=b.call(f);!(he=(M=b.next()).done)&&(Y.push(M.value),!y||Y.length!==y);he=!0);}catch(Me){ee=!0,I=Me}finally{try{he||b.return==null||b.return()}finally{if(ee)throw I}}return Y}}(p,h)||function(f,y){if(f){if(typeof f=="string")return Et(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)?Et(f,y):void 0}}(p,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Et(p,h){(h==null||h>p.length)&&(h=p.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=p[f];return y}var gr={},Xr=function p(h){var f=arguments;typeof h=="string"?p.hasOwnProperty(h)?R().setTimeout(function(){f=Array.prototype.splice.call(f,1),p[h].apply(null,f)},0):q.warn("`"+h+"` is an unknown task"):typeof h=="function"?R().setTimeout(function(){h(p)},0):q.warn("`"+h+"` is invalid.")},vn={loaded:J.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(p,h){return function(f,y,b){var M=Ii(me(y),3),I=M[0],Y=M[1],he=M[2],ee=f.log,Me=f.utils.getComputedStyle,ut=f.utils.secondsToMs;if(!I)return ee.error("No element was found with the `"+Y+"` query selector.");if(he!=="video"&&he!=="audio")return ee.error("The element of `"+Y+"` was not a media element.");I.mux&&(I.mux.destroy(),delete I.mux,ee.warn("Already monitoring this video element, replacing existing event listeners")),(b=K()({automaticErrorTracking:!0},b)).data=K()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:f.VERSION},b.data),b.getPlayheadTime=function(){return ut(I.currentTime)},b.getStateData=function(){var st,Qe,ot=this.hlsjs&&this.hlsjs.url,Ot=this.dashjs&&ri(this.dashjs.getSource==="function")&&this.dashjs.getSource(),qt={player_is_paused:I.paused,player_playhead_time:ut(I.currentTime),player_width:parseInt(Me(I,"width")),player_height:parseInt(Me(I,"height")),player_autoplay_on:I.autoplay,player_preload_on:I.preload,player_language_code:I.lang,player_is_fullscreen:ti()&&!!(ti().fullscreenElement||ti().webkitFullscreenElement||ti().mozFullScreenElement||ti().msFullscreenElement),video_poster_url:I.poster,video_source_url:ot||Ot||I.currentSrc,video_source_duration:ut(I.duration),video_source_height:I.videoHeight,video_source_width:I.videoWidth,view_dropped_frame_count:(st=I)===null||st===void 0||(Qe=st.getVideoPlaybackQuality)===null||Qe===void 0?void 0:Qe.call(st).droppedVideoFrames},rr=b.getPlayheadTime();if(I.getStartDate&&rr>0){var ur=I.getStartDate();if(ur&&typeof ur.getTime=="function"&&ur.getTime()){var Tt=ur.getTime();if(qt.player_program_time=Tt+rr,I.seekable.length>0){var Zt=Tt+I.seekable.end(I.seekable.length-1);qt.player_live_edge_program_time=Zt}}}return qt},I.mux=I.mux||{},I.mux.deleted=!1,I.mux.emit=function(st,Qe){f.emit(Y,st,Qe)};var Ze=function(){ee.error("The monitor for this video element has already been destroyed.")};I.mux.destroy=function(){Object.keys(I.mux.listeners).forEach(function(st){I.removeEventListener(st,I.mux.listeners[st],!1)}),delete I.mux.listeners,I.mux.destroy=Ze,I.mux.swapElement=Ze,I.mux.emit=Ze,I.mux.addHLSJS=Ze,I.mux.addDashJS=Ze,I.mux.removeHLSJS=Ze,I.mux.removeDashJS=Ze,I.mux.deleted=!0,f.emit(Y,"destroy")},I.mux.swapElement=function(st){var Qe=Ii(me(st),3),ot=Qe[0],Ot=Qe[1],qt=Qe[2];return ot?qt!=="video"&&qt!=="audio"?f.log.error("The element of `"+Ot+"` was not a media element."):(ot.muxId=I.muxId,delete I.muxId,ot.mux=ot.mux||{},ot.mux.listeners=K()({},I.mux.listeners),delete I.mux.listeners,Object.keys(ot.mux.listeners).forEach(function(rr){I.removeEventListener(rr,ot.mux.listeners[rr],!1),ot.addEventListener(rr,ot.mux.listeners[rr],!1)}),ot.mux.swapElement=I.mux.swapElement,ot.mux.destroy=I.mux.destroy,delete I.mux,void(I=ot)):f.log.error("No element was found with the `"+Ot+"` query selector.")},I.mux.addHLSJS=function(st){f.addHLSJS(Y,st)},I.mux.addDashJS=function(st){f.addDashJS(Y,st)},I.mux.removeHLSJS=function(){f.removeHLSJS(Y)},I.mux.removeDashJS=function(){f.removeDashJS(Y)},f.init(Y,b),f.emit(Y,"playerready"),I.paused||(f.emit(Y,"play"),I.readyState>2&&f.emit(Y,"playing")),I.mux.listeners={},Ci.forEach(function(st){(st!=="error"||b.automaticErrorTracking)&&(I.mux.listeners[st]=function(){var Qe={};if(st==="error"){if(!I.error||I.error.code===1)return;Qe.player_error_code=I.error.code,Qe.player_error_message=Ln[I.error.code]||I.error.message}f.emit(Y,st,Qe)},I.addEventListener(st,I.mux.listeners[st],!1))})}(Xr,p,h)},destroyMonitor:function(p){var h=Nn(me(p),1)[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():q.error("A video element monitor for `"+p+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(p,h){var f=L(p);gr[f]?gr[f].addHLSJS(h):q.error("A monitor for `"+f+"` has not been initialized.")},addDashJS:function(p,h){var f=L(p);gr[f]?gr[f].addDashJS(h):q.error("A monitor for `"+f+"` has not been initialized.")},removeHLSJS:function(p){var h=L(p);gr[h]?gr[h].removeHLSJS():q.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(p){var h=L(p);gr[h]?gr[h].removeDashJS():q.error("A monitor for `"+h+"` has not been initialized.")},init:function(p,h){ye()&&h&&h.respectDoNotTrack&&q.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var f=L(p);gr[f]=new Br(Xr,f,h)},emit:function(p,h,f){var y=L(p);gr[y]?(gr[y].emit(h,f),h==="destroy"&&delete gr[y]):q.error("A monitor for `"+y+"` has not been initialized.")},checkDoNotTrack:ye,log:q,utils:Mi,events:Fi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Xr,vn),R()!==void 0&&typeof R().addEventListener=="function"&&R().addEventListener("pagehide",function(p){p.persisted||(Xr.WINDOW_UNLOADING=!0)},!1);var Un=Xr},655:function(X,B,j){var re,R;function g(k){return g=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(L){return typeof L}:function(L){return L&&typeof Symbol=="function"&&L.constructor===Symbol&&L!==Symbol.prototype?"symbol":typeof L},g(k);}(function(k){var L=!1;if((R=typeof(re=k)=="function"?re.call(B,j,B,X):re)===void 0||(X.exports=R),L=!0,g(B)==="object"&&(X.exports=k(),L=!0),!L){var me=window.Cookies,ne=window.Cookies=k();ne.noConflict=function(){return window.Cookies=me,ne}}})(function(){var k=function(){for(var L=0,me={};L<arguments.length;L++){var ne=arguments[L];for(var ce in ne)me[ce]=ne[ce]}return me};return function L(me){function ne(ce,we,q){var ye;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(q=k({path:"/"},ne.defaults,q)).expires=="number"){var J=new Date;J.setMilliseconds(J.getMilliseconds()+864e5*q.expires),q.expires=J}try{ye=JSON.stringify(we),/^[\{\[]/.test(ye)&&(we=ye)}catch{}return we=me.write?me.write(we,ce):encodeURIComponent(String(we)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),ce=(ce=(ce=encodeURIComponent(String(ce))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[ce,"=",we,q.expires?"; expires="+q.expires.toUTCString():"",q.path?"; path="+q.path:"",q.domain?"; domain="+q.domain:"",q.secure?"; secure":""].join("")}ce||(ye={});for(var se=document.cookie?document.cookie.split("; "):[],K=/(%[0-9A-Z]{2})+/g,Ee=0;Ee<se.length;Ee++){var ke=se[Ee].split("="),Ne=ke.slice(1).join("=");Ne.charAt(0)==='"'&&(Ne=Ne.slice(1,-1));try{var V=ke[0].replace(K,decodeURIComponent);if(Ne=me.read?me.read(Ne,V):me(Ne,V)||Ne.replace(K,decodeURIComponent),this.json)try{Ne=JSON.parse(Ne)}catch{}if(ce===V){ye=Ne;break}ce||(ye[V]=Ne)}catch{}}return ye}}return ne.set=ne,ne.get=function(ce){return ne.call(ne,ce)},ne.getJSON=function(){return ne.apply({json:!0},[].slice.call(arguments))},ne.defaults={},ne.remove=function(ce,we){ne(ce,"",k(we,{expires:-1}))},ne.withConverter=L,ne}(function(){})})},153:function(X,B,j){var re,R=j.g!==void 0?j.g:typeof window!="undefined"?window:{},g=j(558);typeof document!="undefined"?re=document:(re=R["__GLOBAL_DOCUMENT_CACHE@4"])||(re=R["__GLOBAL_DOCUMENT_CACHE@4"]=g),X.exports=re},48:function(X,B,j){var re;re=typeof window!="undefined"?window:j.g!==void 0?j.g:typeof self!="undefined"?self:{},X.exports=re},678:function(X){var B=9007199254740991,j="[object Arguments]",re="[object Function]",R="[object GeneratorFunction]",g=/^(?:0|[1-9]\d*)$/;function k(z,$,Le){switch(Le.length){case 0:return z.call($);case 1:return z.call($,Le[0]);case 2:return z.call($,Le[0],Le[1]);case 3:return z.call($,Le[0],Le[1],Le[2])}return z.apply($,Le)}var L,me,ne=Object.prototype,ce=ne.hasOwnProperty,we=ne.toString,q=ne.propertyIsEnumerable,ye=(L=Object.keys,me=Object,function(z){return L(me(z))}),J=Math.max,se=!q.call({valueOf:1},"valueOf");function K(z,$){var Le=E(z)||function(qe){return function(at){return function(ie){return!!ie&&typeof ie=="object"}(at)&&U(at)}(qe)&&ce.call(qe,"callee")&&(!q.call(qe,"callee")||we.call(qe)==j)}(z)?function(qe,at){for(var ie=-1,pe=Array(qe);++ie<qe;)pe[ie]=at(ie);return pe}(z.length,String):[],Oe=Le.length,xe=!!Oe;for(var be in z)!$&&!ce.call(z,be)||xe&&(be=="length"||ke(be,Oe))||Le.push(be);return Le}function Ee(z,$,Le){var Oe=z[$];ce.call(z,$)&&V(Oe,Le)&&(Le!==void 0||$ in z)||(z[$]=Le)}function ke(z,$){return!!($=$==null?B:$)&&(typeof z=="number"||g.test(z))&&z>-1&&z%1==0&&z<$}function Ne(z){var $=z&&z.constructor;return z===(typeof $=="function"&&$.prototype||ne)}function V(z,$){return z===$||z!=z&&$!=$}var E=Array.isArray;function U(z){return z!=null&&function($){return typeof $=="number"&&$>-1&&$%1==0&&$<=B}(z.length)&&!function($){var Le=D($)?we.call($):"";return Le==re||Le==R}(z)}function D(z){var $=typeof z;return!!z&&($=="object"||$=="function")}var de,Se=(de=function(z,$){if(se||Ne($)||U($))(function(Oe,xe,be,qe){be||(be={});for(var at=-1,ie=xe.length;++at<ie;){var pe=xe[at],ae=qe?qe(be[pe],Oe[pe],pe,be,Oe):void 0;Ee(be,pe,ae===void 0?Oe[pe]:ae)}})($,function(Oe){return U(Oe)?K(Oe):function(xe){if(!Ne(xe))return ye(xe);var be=[];for(var qe in Object(xe))ce.call(xe,qe)&&qe!="constructor"&&be.push(qe);return be}(Oe)}($),z);else for(var Le in $)ce.call($,Le)&&Ee(z,Le,$[Le])},function(z,$){return $=J($===void 0?z.length-1:$,0),function(){for(var Le=arguments,Oe=-1,xe=J(Le.length-$,0),be=Array(xe);++Oe<xe;)be[Oe]=Le[$+Oe];Oe=-1;for(var qe=Array($+1);++Oe<$;)qe[Oe]=Le[Oe];return qe[$]=be,k(z,this,qe)}}(function(z,$){var Le=-1,Oe=$.length,xe=Oe>1?$[Oe-1]:void 0,be=Oe>2?$[2]:void 0;for(xe=de.length>3&&typeof xe=="function"?(Oe--,xe):void 0,be&&function(at,ie,pe){if(!D(pe))return!1;var ae=typeof ie;return!!(ae=="number"?U(pe)&&ke(ie,pe.length):ae=="string"&&ie in pe)&&V(pe[ie],at)}($[0],$[1],be)&&(xe=Oe<3?void 0:xe,Oe=1),z=Object(z);++Le<Oe;){var qe=$[Le];qe&&de(z,qe,Le,xe)}return z}));X.exports=Se},640:function(X,B,j){var re,R;(function(g,k){"use strict";re=function(){var L=function(){},me="undefined",ne=typeof window!==me&&typeof window.navigator!==me&&/Trident\/|MSIE /.test(window.navigator.userAgent),ce=["trace","debug","info","warn","error"];function we(E,U){var D=E[U];if(typeof D.bind=="function")return D.bind(E);try{return Function.prototype.bind.call(D,E)}catch{return function(){return Function.prototype.apply.apply(D,[E,arguments])}}}function q(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function ye(E){return E==="debug"&&(E="log"),typeof console!==me&&(E==="trace"&&ne?q:console[E]!==void 0?we(console,E):console.log!==void 0?we(console,"log"):L)}function J(E,U){for(var D=0;D<ce.length;D++){var de=ce[D];this[de]=D<E?L:this.methodFactory(de,E,U)}this.log=this.debug}function se(E,U,D){return function(){typeof console!==me&&(J.call(this,U,D),this[E].apply(this,arguments))}}function K(E,U,D){return ye(E)||se.apply(this,arguments)}function Ee(E,U,D){var de,Se=this;U=U==null?"WARN":U;var z="loglevel";function $(be){var qe=(ce[be]||"silent").toUpperCase();if(typeof window!==me&&z){try{return void(window.localStorage[z]=qe)}catch{}try{window.document.cookie=encodeURIComponent(z)+"="+qe+";"}catch{}}}function Le(){var be;if(typeof window!==me&&z){try{be=window.localStorage[z]}catch{}if(typeof be===me)try{var qe=window.document.cookie,at=qe.indexOf(encodeURIComponent(z)+"=");at!==-1&&(be=/^([^;]+)/.exec(qe.slice(at))[1])}catch{}return Se.levels[be]===void 0&&(be=void 0),be}}function Oe(){if(typeof window!==me&&z){try{return void window.localStorage.removeItem(z)}catch{}try{window.document.cookie=encodeURIComponent(z)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof E=="string"?z+=":"+E:typeof E=="symbol"&&(z=void 0),Se.name=E,Se.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Se.methodFactory=D||K,Se.getLevel=function(){return de},Se.setLevel=function(be,qe){if(typeof be=="string"&&Se.levels[be.toUpperCase()]!==void 0&&(be=Se.levels[be.toUpperCase()]),!(typeof be=="number"&&be>=0&&be<=Se.levels.SILENT))throw"log.setLevel() called with invalid level: "+be;if(de=be,qe!==!1&&$(be),J.call(Se,be,E),typeof console===me&&be<Se.levels.SILENT)return"No console available for logging"},Se.setDefaultLevel=function(be){U=be,Le()||Se.setLevel(be,!1)},Se.resetLevel=function(){Se.setLevel(U,!1),Oe()},Se.enableAll=function(be){Se.setLevel(Se.levels.TRACE,be)},Se.disableAll=function(be){Se.setLevel(Se.levels.SILENT,be)};var xe=Le();xe==null&&(xe=U),Se.setLevel(xe,!1)}var ke=new Ee,Ne={};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=Ne[E];return U||(U=Ne[E]=new Ee(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 Ne},ke.default=ke,ke},(R=typeof re=="function"?re.call(B,j,B,X):re)===void 0||(X.exports=R)})()},375:function(X,B){"use strict";var j=Object.prototype.hasOwnProperty;function re(g){try{return decodeURIComponent(g.replace(/\+/g," "))}catch{return null}}function R(g){try{return encodeURIComponent(g)}catch{return null}}B.stringify=function(g,k){k=k||"";var L,me,ne=[];for(me in typeof k!="string"&&(k="?"),g)if(j.call(g,me)){if((L=g[me])||L!=null&&!isNaN(L)||(L=""),me=R(me),L=R(L),me===null||L===null)continue;ne.push(me+"="+L)}return ne.length?k+ne.join("&"):""},B.parse=function(g){for(var k,L=/([^=?#&]+)=?([^&]*)/g,me={};k=L.exec(g);){var ne=re(k[1]),ce=re(k[2]);ne===null||ce===null||ne in me||(me[ne]=ce)}return me}},558:function(){}},le={};function oe(X){var B=le[X];if(B!==void 0)return B.exports;var j=le[X]={exports:{}};return A[X].call(j.exports,j,j.exports,oe),j.exports}return oe.n=function(X){var B=X&&X.__esModule?function(){return X.default}:function(){return X};return oe.d(B,{a:B}),B},oe.d=function(X,B){for(var j in B)oe.o(B,j)&&!oe.o(X,j)&&Object.defineProperty(X,j,{enumerable:!0,get:B[j]})},oe.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),oe.o=function(X,B){return Object.prototype.hasOwnProperty.call(X,B)},oe(80)}()},typeof En=="object"&&typeof ia=="object"?ia.exports=w():typeof En=="object"?En.mux=w():x.mux=w()})()});var Ya=Ga((Vi,na)=>{typeof window!="undefined"&&function(x,w){typeof Vi=="object"&&typeof na=="object"?na.exports=w():typeof define=="function"&&define.amd?define([],w):typeof Vi=="object"?Vi.Hls=w():x.Hls=w()}(Vi,()=>(()=>{var x={21:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{default:()=>me});var j=function(){function ne(ce,we){this.subtle=void 0,this.aesIV=void 0,this.subtle=ce,this.aesIV=we}return ne.prototype.decrypt=function(ce,we){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},we,ce)},ne}(),re=function(){function ne(ce,we){this.subtle=void 0,this.key=void 0,this.subtle=ce,this.key=we}return ne.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},ne}(),R=B(145),g=function(){function ne(){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 ce=ne.prototype;return ce.uint8ArrayToUint32Array_=function(we){for(var q=new DataView(we),ye=new Uint32Array(4),J=0;J<4;J++)ye[J]=q.getUint32(4*J);return ye},ce.initTable=function(){var we=this.sBox,q=this.invSBox,ye=this.subMix,J=ye[0],se=ye[1],K=ye[2],Ee=ye[3],ke=this.invSubMix,Ne=ke[0],V=ke[1],E=ke[2],U=ke[3],D=new Uint32Array(256),de=0,Se=0,z=0;for(z=0;z<256;z++)D[z]=z<128?z<<1:z<<1^283;for(z=0;z<256;z++){var $=Se^Se<<1^Se<<2^Se<<3^Se<<4;$=$>>>8^255&$^99,we[de]=$,q[$]=de;var Le=D[de],Oe=D[Le],xe=D[Oe],be=257*D[$]^16843008*$;J[de]=be<<24|be>>>8,se[de]=be<<16|be>>>16,K[de]=be<<8|be>>>24,Ee[de]=be,be=16843009*xe^65537*Oe^257*Le^16843008*de,Ne[$]=be<<24|be>>>8,V[$]=be<<16|be>>>16,E[$]=be<<8|be>>>24,U[$]=be,de?(de=Le^D[D[D[xe^Le]]],Se^=D[D[Se]]):de=Se=1}},ce.expandKey=function(we){for(var q=this.uint8ArrayToUint32Array_(we),ye=!0,J=0;J<q.length&&ye;)ye=q[J]===this.key[J],J++;if(!ye){this.key=q;var se=this.keySize=q.length;if(se!==4&&se!==6&&se!==8)throw new Error("Invalid aes key size="+se);var K,Ee,ke,Ne,V=this.ksRows=4*(se+6+1),E=this.keySchedule=new Uint32Array(V),U=this.invKeySchedule=new Uint32Array(V),D=this.sBox,de=this.rcon,Se=this.invSubMix,z=Se[0],$=Se[1],Le=Se[2],Oe=Se[3];for(K=0;K<V;K++)K<se?ke=E[K]=q[K]:(Ne=ke,K%se==0?(Ne=D[(Ne=Ne<<8|Ne>>>24)>>>24]<<24|D[Ne>>>16&255]<<16|D[Ne>>>8&255]<<8|D[255&Ne],Ne^=de[K/se|0]<<24):se>6&&K%se==4&&(Ne=D[Ne>>>24]<<24|D[Ne>>>16&255]<<16|D[Ne>>>8&255]<<8|D[255&Ne]),E[K]=ke=(E[K-se]^Ne)>>>0);for(Ee=0;Ee<V;Ee++)K=V-Ee,Ne=3&Ee?E[K]:E[K-4],U[Ee]=Ee<4||K<=4?Ne:z[D[Ne>>>24]]^$[D[Ne>>>16&255]]^Le[D[Ne>>>8&255]]^Oe[D[255&Ne]],U[Ee]=U[Ee]>>>0}},ce.networkToHostOrderSwap=function(we){return we<<24|(65280&we)<<8|(16711680&we)>>8|we>>>24},ce.decrypt=function(we,q,ye){for(var J,se,K,Ee,ke,Ne,V,E,U,D,de,Se,z,$,Le=this.keySize+6,Oe=this.invKeySchedule,xe=this.invSBox,be=this.invSubMix,qe=be[0],at=be[1],ie=be[2],pe=be[3],ae=this.uint8ArrayToUint32Array_(ye),Ue=ae[0],H=ae[1],ve=ae[2],Ie=ae[3],Fe=new Int32Array(we),fe=new Int32Array(Fe.length),Ce=this.networkToHostOrderSwap;q<Fe.length;){for(U=Ce(Fe[q]),D=Ce(Fe[q+1]),de=Ce(Fe[q+2]),Se=Ce(Fe[q+3]),ke=U^Oe[0],Ne=Se^Oe[1],V=de^Oe[2],E=D^Oe[3],z=4,$=1;$<Le;$++)J=qe[ke>>>24]^at[Ne>>16&255]^ie[V>>8&255]^pe[255&E]^Oe[z],se=qe[Ne>>>24]^at[V>>16&255]^ie[E>>8&255]^pe[255&ke]^Oe[z+1],K=qe[V>>>24]^at[E>>16&255]^ie[ke>>8&255]^pe[255&Ne]^Oe[z+2],Ee=qe[E>>>24]^at[ke>>16&255]^ie[Ne>>8&255]^pe[255&V]^Oe[z+3],ke=J,Ne=se,V=K,E=Ee,z+=4;J=xe[ke>>>24]<<24^xe[Ne>>16&255]<<16^xe[V>>8&255]<<8^xe[255&E]^Oe[z],se=xe[Ne>>>24]<<24^xe[V>>16&255]<<16^xe[E>>8&255]<<8^xe[255&ke]^Oe[z+1],K=xe[V>>>24]<<24^xe[E>>16&255]<<16^xe[ke>>8&255]<<8^xe[255&Ne]^Oe[z+2],Ee=xe[E>>>24]<<24^xe[ke>>16&255]<<16^xe[Ne>>8&255]<<8^xe[255&V]^Oe[z+3],fe[q]=Ce(J^Ue),fe[q+1]=Ce(Ee^H),fe[q+2]=Ce(K^ve),fe[q+3]=Ce(se^Ie),Ue=U,H=D,ve=de,Ie=Se,q+=4}return fe.buffer},ne}(),k=B(93),L=B(63),me=function(){function ne(we,q){var ye=(q===void 0?{}:q).removePKCS7Padding,J=ye===void 0||ye;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=we.enableSoftwareAES,this.removePKCS7Padding=J,J)try{var se=self.crypto;se&&(this.subtle=se.subtle||se.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var ce=ne.prototype;return ce.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},ce.isSync=function(){return this.useSoftware},ce.flush=function(){var we=this.currentResult,q=this.remainderData;if(!we||q)return k.logger.error("[softwareDecrypt] "+(q?"overflow bytes: "+q.byteLength:"no result")),this.reset(),null;var ye,J,se,K=new Uint8Array(we);return this.reset(),this.removePKCS7Padding?(se=(J=(ye=K).byteLength)&&new DataView(ye.buffer).getUint8(J-1))?(0,R.sliceUint8)(ye,0,J-se):ye:K},ce.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},ce.decrypt=function(we,q,ye){var J=this;return this.useSoftware?new Promise(function(se,K){J.softwareDecrypt(new Uint8Array(we),q,ye);var Ee=J.flush();Ee?se(Ee.buffer):K(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(we),q,ye)},ce.softwareDecrypt=function(we,q,ye){var J=this.currentIV,se=this.currentResult,K=this.remainderData;this.logOnce("JS AES decrypt"),K&&(we=(0,L.appendUint8Array)(K,we),this.remainderData=null);var Ee=this.getValidChunk(we);if(!Ee.length)return null;J&&(ye=J);var ke=this.softwareDecrypter;ke||(ke=this.softwareDecrypter=new g),ke.expandKey(q);var Ne=se;return this.currentResult=ke.decrypt(Ee.buffer,0,ye),this.currentIV=(0,R.sliceUint8)(Ee,-16).buffer,Ne||null},ce.webCryptoDecrypt=function(we,q,ye){var J=this,se=this.subtle;return this.key===q&&this.fastAesKey||(this.key=q,this.fastAesKey=new re(se,q)),this.fastAesKey.expandKey().then(function(K){return se?(J.logOnce("WebCrypto AES decrypt"),new j(se,new Uint8Array(ye)).decrypt(we.buffer,K)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(K){return k.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+K.name+": "+K.message),J.onWebCryptoError(we,q,ye)})},ce.onWebCryptoError=function(we,q,ye){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(we,q,ye);var J=this.flush();if(J)return J.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},ce.getValidChunk=function(we){var q=we,ye=we.length-we.length%16;return ye!==we.length&&(q=(0,R.sliceUint8)(we,0,ye),this.remainderData=(0,R.sliceUint8)(we,ye)),q},ce.logOnce=function(we){this.logEnabled&&(k.logger.log("[decrypter]: "+we),this.logEnabled=!1)},ne}()},181:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{canParse:()=>L,decodeFrame:()=>q,getID3Data:()=>g,getID3Frames:()=>we,getTimeStamp:()=>me,isFooter:()=>R,isHeader:()=>re,isTimeStampFrame:()=>ne,testables:()=>ke,utf8ArrayToStr:()=>Ee});var j,re=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},g=function(V,E){for(var U=E,D=0;re(V,E);)D+=10,D+=k(V,E+6),R(V,E+10)&&(D+=10),E+=D;if(D>0)return V.subarray(U,U+D)},k=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]},L=function(V,E){return re(V,E)&&k(V,E+6)+10<=V.length-E},me=function(V){for(var E=we(V),U=0;U<E.length;U++){var D=E[U];if(ne(D))return K(D)}},ne=function(V){return V&&V.key==="PRIV"&&V.info==="com.apple.streaming.transportStreamTimestamp"},ce=function(V){var E=String.fromCharCode(V[0],V[1],V[2],V[3]),U=k(V,4);return{type:E,size:U,data:V.subarray(10,10+U)}},we=function(V){for(var E=0,U=[];re(V,E);){for(var D=k(V,E+6),de=(E+=10)+D;E+8<de;){var Se=ce(V.subarray(E)),z=q(Se);z&&U.push(z),E+=Se.size+10}R(V,E)&&(E+=10)}return U},q=function(V){return V.type==="PRIV"?ye(V):V.type[0]==="W"?se(V):J(V)},ye=function(V){if(!(V.size<2)){var E=Ee(V.data,!0),U=new Uint8Array(V.data.subarray(E.length+1));return{key:V.type,info:E,data:U.buffer}}},J=function(V){if(!(V.size<2)){if(V.type==="TXXX"){var E=1,U=Ee(V.data.subarray(E),!0);E+=U.length+1;var D=Ee(V.data.subarray(E));return{key:V.type,info:U,data:D}}var de=Ee(V.data.subarray(1));return{key:V.type,data:de}}},se=function(V){if(V.type==="WXXX"){if(V.size<2)return;var E=1,U=Ee(V.data.subarray(E),!0);E+=U.length+1;var D=Ee(V.data.subarray(E));return{key:V.type,info:U,data:D}}var de=Ee(V.data);return{key:V.type,data:de}},K=function(V){if(V.data.byteLength===8){var E=new Uint8Array(V.data),U=1&E[3],D=(E[4]<<23)+(E[5]<<15)+(E[6]<<7)+E[7];return D/=45,U&&(D+=4772185884e-2),Math.round(D)}},Ee=function(V,E){E===void 0&&(E=!1);var U=Ne();if(U){var D=U.decode(V);if(E){var de=D.indexOf("\0");return de!==-1?D.substring(0,de):D}return D.replace(/\0/g,"")}for(var Se,z,$,Le=V.length,Oe="",xe=0;xe<Le;){if((Se=V[xe++])===0&&E)return Oe;if(Se!==0&&Se!==3)switch(Se>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:Oe+=String.fromCharCode(Se);break;case 12:case 13:z=V[xe++],Oe+=String.fromCharCode((31&Se)<<6|63&z);break;case 14:z=V[xe++],$=V[xe++],Oe+=String.fromCharCode((15&Se)<<12|(63&z)<<6|(63&$)<<0)}}return Oe},ke={decodeTextFrame:J};function Ne(){return j||self.TextDecoder===void 0||(j=new self.TextDecoder("utf-8")),j}},182:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{default:()=>L});var j=B(544),re=B(851),R=B(93),g=B(729),k=B(973);function L(we){var q=new g.EventEmitter,ye=function(J,se){we.postMessage({event:J,data:se})};q.on(re.Events.FRAG_DECRYPTED,ye),q.on(re.Events.ERROR,ye),we.addEventListener("message",function(J){var se=J.data;switch(se.cmd){case"init":var K=JSON.parse(se.config);we.transmuxer=new j.default(q,se.typeSupported,K,se.vendor,se.id),(0,R.enableLogs)(K.debug,se.id),function(){var V=function(U){R.logger[U]=function(D){ye("workerLog",{logType:U,message:D})}};for(var E in R.logger)V(E)}(),ye("init",null);break;case"configure":we.transmuxer.configure(se.config);break;case"demux":var Ee=we.transmuxer.push(se.data,se.decryptdata,se.chunkMeta,se.state);(0,j.isPromise)(Ee)?(we.transmuxer.async=!0,Ee.then(function(V){me(we,V)}).catch(function(V){ye(re.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:se.chunkMeta,fatal:!1,error:V,err:V,reason:"transmuxer-worker push error"})})):(we.transmuxer.async=!1,me(we,Ee));break;case"flush":var ke=se.chunkMeta,Ne=we.transmuxer.flush(ke);(0,j.isPromise)(Ne)||we.transmuxer.async?((0,j.isPromise)(Ne)||(Ne=Promise.resolve(Ne)),Ne.then(function(V){ce(we,V,ke)}).catch(function(V){ye(re.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:se.chunkMeta,fatal:!1,error:V,err:V,reason:"transmuxer-worker flush error"})})):ce(we,Ne,ke)}})}function me(we,q){if(!((ye=q.remuxResult).audio||ye.video||ye.text||ye.id3||ye.initSegment))return!1;var ye,J=[],se=q.remuxResult,K=se.audio,Ee=se.video;return K&&ne(J,K),Ee&&ne(J,Ee),we.postMessage({event:"transmuxComplete",data:q},J),!0}function ne(we,q){q.data1&&we.push(q.data1.buffer),q.data2&&we.push(q.data2.buffer)}function ce(we,q,ye){q.reduce(function(J,se){return me(we,se)||J},!1)||we.postMessage({event:"transmuxComplete",data:q[0]}),we.postMessage({event:"flush",data:ye})}},544:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{TransmuxConfig:()=>Bt,TransmuxState:()=>ar,default:()=>It,isPromise:()=>Wt});var j=B(851),re=B(973),R=B(21),g=B(965),k=B(181),L=B(856);function me(te,N){return te===void 0&&(te=""),N===void 0&&(N=9e4),{type:te,id:-1,pid:-1,inputTimeScale:N,sequenceNumber:-1,samples:[],dropped:0}}var ne=B(63),ce=B(145),we=function(){function te(){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=te.prototype;return N.resetInitSegment=function(T,O,C,G){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},N.resetTimeStamp=function(T){this.initPTS=T,this.resetContiguity()},N.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},N.canParse=function(T,O){return!1},N.appendFrame=function(T,O,C){},N.demux=function(T,O){this.cachedData&&(T=(0,ne.appendUint8Array)(this.cachedData,T),this.cachedData=null);var C,G=k.getID3Data(T,0),Q=G?G.length:0,Z=this._audioTrack,Te=this._id3Track,Re=G?k.getTimeStamp(G):void 0,Pe=T.length;for((this.basePTS===null||this.frameIndex===0&&(0,g.isFiniteNumber)(Re))&&(this.basePTS=q(Re,O,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),G&&G.length>0&&Te.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:G,type:L.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});Q<Pe;){if(this.canParse(T,Q)){var Be=this.appendFrame(Z,T,Q);Be?(this.frameIndex++,this.lastPTS=Be.sample.pts,C=Q+=Be.length):Q=Pe}else k.canParse(T,Q)?(G=k.getID3Data(T,Q),Te.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:G,type:L.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),C=Q+=G.length):Q++;if(Q===Pe&&C!==Pe){var We=(0,ce.sliceUint8)(T,C);this.cachedData?this.cachedData=(0,ne.appendUint8Array)(this.cachedData,We):this.cachedData=We}}return{audioTrack:Z,videoTrack:me(),id3Track:Te,textTrack:me()}},N.demuxSampleAes=function(T,O,C){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},N.flush=function(T){var O=this.cachedData;return O&&(this.cachedData=null,this.demux(O,0)),{audioTrack:this._audioTrack,videoTrack:me(),id3Track:this._id3Track,textTrack:me()}},N.destroy=function(){},te}(),q=function(te,N,T){return(0,g.isFiniteNumber)(te)?90*te:9e4*N+(T||0)};let ye=we;var J=B(93);function se(te,N){return te[N]===255&&(246&te[N+1])==240}function K(te,N){return 1&te[N+1]?7:9}function Ee(te,N){return(3&te[N+3])<<11|te[N+4]<<3|(224&te[N+5])>>>5}function ke(te,N){return N+1<te.length&&se(te,N)}function Ne(te,N){if(ke(te,N)){var T=K(te,N);if(N+T>=te.length)return!1;var O=Ee(te,N);if(O<=T)return!1;var C=N+O;return C===te.length||ke(te,C)}return!1}function V(te,N,T,O,C){if(!te.samplerate){var G=function(Q,Z,Te,Re){var Pe,Be,We,Ge,$e=navigator.userAgent.toLowerCase(),ht=Re,Dt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Pe=1+((192&Z[Te+2])>>>6);var ze=(60&Z[Te+2])>>>2;if(!(ze>Dt.length-1))return We=(1&Z[Te+2])<<2,We|=(192&Z[Te+3])>>>6,J.logger.log("manifest codec:"+Re+", ADTS type:"+Pe+", samplingIndex:"+ze),/firefox/i.test($e)?ze>=6?(Pe=5,Ge=new Array(4),Be=ze-3):(Pe=2,Ge=new Array(2),Be=ze):$e.indexOf("android")!==-1?(Pe=2,Ge=new Array(2),Be=ze):(Pe=5,Ge=new Array(4),Re&&(Re.indexOf("mp4a.40.29")!==-1||Re.indexOf("mp4a.40.5")!==-1)||!Re&&ze>=6?Be=ze-3:((Re&&Re.indexOf("mp4a.40.2")!==-1&&(ze>=6&&We===1||/vivaldi/i.test($e))||!Re&&We===1)&&(Pe=2,Ge=new Array(2)),Be=ze)),Ge[0]=Pe<<3,Ge[0]|=(14&ze)>>1,Ge[1]|=(1&ze)<<7,Ge[1]|=We<<3,Pe===5&&(Ge[1]|=(14&Be)>>1,Ge[2]=(1&Be)<<7,Ge[2]|=8,Ge[3]=0),{config:Ge,samplerate:Dt[ze],channelCount:We,codec:"mp4a.40."+Pe,manifestCodec:ht};Q.trigger(j.Events.ERROR,{type:re.ErrorTypes.MEDIA_ERROR,details:re.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+ze})}(N,T,O,C);if(!G)return;te.config=G.config,te.samplerate=G.samplerate,te.channelCount=G.channelCount,te.codec=G.codec,te.manifestCodec=G.manifestCodec,J.logger.log("parsed codec:"+te.codec+", rate:"+G.samplerate+", channels:"+G.channelCount)}}function E(te){return 9216e4/te}function U(te,N,T,O,C){var G,Q=O+C*E(te.samplerate),Z=function($e,ht){var Dt=K($e,ht);if(ht+Dt<=$e.length){var ze=Ee($e,ht)-Dt;if(ze>0)return{headerLength:Dt,frameLength:ze}}}(N,T);if(Z){var Te=Z.frameLength,Re=Z.headerLength,Pe=Re+Te,Be=Math.max(0,T+Pe-N.length);Be?(G=new Uint8Array(Pe-Re)).set(N.subarray(T+Re,N.length),0):G=N.subarray(T+Re,T+Pe);var We={unit:G,pts:Q};return Be||te.samples.push(We),{sample:We,length:Pe,missing:Be}}var Ge=N.length-T;return(G=new Uint8Array(Ge)).set(N.subarray(T,N.length),0),{sample:{unit:G,pts:Q},length:Ge,missing:-1}}function D(te,N){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,O){return T.__proto__=O,T},D(te,N)}let de=function(te){var N,T;function O(G,Q){var Z;return(Z=te.call(this)||this).observer=void 0,Z.config=void 0,Z.observer=G,Z.config=Q,Z}T=te,(N=O).prototype=Object.create(T.prototype),N.prototype.constructor=N,D(N,T);var C=O.prototype;return C.resetInitSegment=function(G,Q,Z,Te){te.prototype.resetInitSegment.call(this,G,Q,Z,Te),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:Q,duration:Te,inputTimeScale:9e4,dropped:0}},O.probe=function(G){if(!G)return!1;for(var Q=(k.getID3Data(G,0)||[]).length,Z=G.length;Q<Z;Q++)if(Ne(G,Q))return J.logger.log("ADTS sync word found !"),!0;return!1},C.canParse=function(G,Q){return function(Z,Te){return function(Re,Pe){return Pe+5<Re.length}(Z,Te)&&se(Z,Te)&&Ee(Z,Te)<=Z.length-Te}(G,Q)},C.appendFrame=function(G,Q,Z){V(G,this.observer,Q,Z,G.manifestCodec);var Te=U(G,Q,Z,this.basePTS,this.frameIndex);if(Te&&Te.missing===0)return Te},O}(ye);var Se=/\/emsg[-/]ID3/i;let z=function(){function te(T,O){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=O}var N=te.prototype;return N.resetTimeStamp=function(){},N.resetInitSegment=function(T,O,C,G){var Q=this.videoTrack=me("video",1),Z=this.audioTrack=me("audio",1),Te=this.txtTrack=me("text",1);if(this.id3Track=me("id3",1),this.timeOffset=0,T&&T.byteLength){var Re=(0,ne.parseInitSegment)(T);if(Re.video){var Pe=Re.video,Be=Pe.id,We=Pe.timescale,Ge=Pe.codec;Q.id=Be,Q.timescale=Te.timescale=We,Q.codec=Ge}if(Re.audio){var $e=Re.audio,ht=$e.id,Dt=$e.timescale,ze=$e.codec;Z.id=ht,Z.timescale=Dt,Z.codec=ze}Te.id=ne.RemuxerTrackIdConfig.text,Q.sampleDuration=0,Q.duration=Z.duration=G}},N.resetContiguity=function(){},te.probe=function(T){return T=T.length>16384?T.subarray(0,16384):T,(0,ne.findBox)(T,["moof"]).length>0},N.demux=function(T,O){this.timeOffset=O;var C=T,G=this.videoTrack,Q=this.txtTrack;if(this.config.progressive){this.remainderData&&(C=(0,ne.appendUint8Array)(this.remainderData,T));var Z=(0,ne.segmentValidRange)(C);this.remainderData=Z.remainder,G.samples=Z.valid||new Uint8Array}else G.samples=C;var Te=this.extractID3Track(G,O);return Q.samples=(0,ne.parseSamples)(O,G),{videoTrack:G,audioTrack:this.audioTrack,id3Track:Te,textTrack:this.txtTrack}},N.flush=function(){var T=this.timeOffset,O=this.videoTrack,C=this.txtTrack;O.samples=this.remainderData||new Uint8Array,this.remainderData=null;var G=this.extractID3Track(O,this.timeOffset);return C.samples=(0,ne.parseSamples)(T,O),{videoTrack:O,audioTrack:me(),id3Track:G,textTrack:me()}},N.extractID3Track=function(T,O){var C=this.id3Track;if(T.samples.length){var G=(0,ne.findBox)(T.samples,["emsg"]);G&&G.forEach(function(Q){var Z=(0,ne.parseEmsg)(Q);if(Se.test(Z.schemeIdUri)){var Te=(0,g.isFiniteNumber)(Z.presentationTime)?Z.presentationTime/Z.timeScale:O+Z.presentationTimeDelta/Z.timeScale,Re=Z.eventDuration===4294967295?Number.POSITIVE_INFINITY:Z.eventDuration/Z.timeScale;Re<=.001&&(Re=Number.POSITIVE_INFINITY);var Pe=Z.payload;C.samples.push({data:Pe,len:Pe.byteLength,dts:Te,pts:Te,type:L.MetadataSchema.emsg,duration:Re})}})}return C},N.demuxSampleAes=function(T,O,C){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},N.destroy=function(){},te}();var $=null,Le=[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],Oe=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],xe=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],be=[0,1,1,4];function qe(te,N,T,O,C){if(!(T+24>N.length)){var G=at(N,T);if(G&&T+G.frameLength<=N.length){var Q=O+C*(9e4*G.samplesPerFrame/G.sampleRate),Z={unit:N.subarray(T,T+G.frameLength),pts:Q,dts:Q};return te.config=[],te.channelCount=G.channelCount,te.samplerate=G.sampleRate,te.samples.push(Z),{sample:Z,length:G.frameLength,missing:0}}}}function at(te,N){var T=te[N+1]>>3&3,O=te[N+1]>>1&3,C=te[N+2]>>4&15,G=te[N+2]>>2&3;if(T!==1&&C!==0&&C!==15&&G!==3){var Q=te[N+2]>>1&1,Z=te[N+3]>>6,Te=1e3*Le[14*(T===3?3-O:O===3?3:4)+C-1],Re=Oe[3*(T===3?0:T===2?1:2)+G],Pe=Z===3?1:2,Be=xe[T][O],We=be[O],Ge=8*Be*We,$e=Math.floor(Be*Te/Re+Q)*We;if($===null){var ht=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);$=ht?parseInt(ht[1]):0}return!!$&&$<=87&&O===2&&Te>=224e3&&Z===0&&(te[N+3]=128|te[N+3]),{sampleRate:Re,channelCount:Pe,frameLength:$e,samplesPerFrame:Ge}}}function ie(te,N){return te[N]===255&&(224&te[N+1])==224&&(6&te[N+1])!=0}function pe(te,N){return N+1<te.length&&ie(te,N)}function ae(te,N){if(N+1<te.length&&ie(te,N)){var T=at(te,N),O=4;T!=null&&T.frameLength&&(O=T.frameLength);var C=N+O;return C===te.length||pe(te,C)}return!1}let Ue=function(){function te(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 N=te.prototype;return N.loadWord=function(){var T=this.data,O=this.bytesAvailable,C=T.byteLength-O,G=new Uint8Array(4),Q=Math.min(4,O);if(Q===0)throw new Error("no bytes available");G.set(T.subarray(C,C+Q)),this.word=new DataView(G.buffer).getUint32(0),this.bitsAvailable=8*Q,this.bytesAvailable-=Q},N.skipBits=function(T){var O;T=Math.min(T,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>T?(this.word<<=T,this.bitsAvailable-=T):(T-=this.bitsAvailable,T-=(O=T>>3)<<3,this.bytesAvailable-=O,this.loadWord(),this.word<<=T,this.bitsAvailable-=T)},N.readBits=function(T){var O=Math.min(this.bitsAvailable,T),C=this.word>>>32-O;if(T>32&&J.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=O,this.bitsAvailable>0)this.word<<=O;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(O=T-O)>0&&this.bitsAvailable?C<<O|this.readBits(O):C},N.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()},N.skipUEG=function(){this.skipBits(1+this.skipLZ())},N.skipEG=function(){this.skipBits(1+this.skipLZ())},N.readUEG=function(){var T=this.skipLZ();return this.readBits(T+1)-1},N.readEG=function(){var T=this.readUEG();return 1&T?1+T>>>1:-1*(T>>>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(T){for(var O=8,C=8,G=0;G<T;G++)C!==0&&(C=(O+this.readEG()+256)%256),O=C===0?O:C},N.readSPS=function(){var T,O,C,G=0,Q=0,Z=0,Te=0,Re=this.readUByte.bind(this),Pe=this.readBits.bind(this),Be=this.readUEG.bind(this),We=this.readBoolean.bind(this),Ge=this.skipBits.bind(this),$e=this.skipEG.bind(this),ht=this.skipUEG.bind(this),Dt=this.skipScalingList.bind(this);Re();var ze=Re();if(Pe(5),Ge(3),Re(),ht(),ze===100||ze===110||ze===122||ze===244||ze===44||ze===83||ze===86||ze===118||ze===128){var Pt=Be();if(Pt===3&&Ge(1),ht(),ht(),Ge(1),We())for(O=Pt!==3?8:12,C=0;C<O;C++)We()&&Dt(C<6?16:64)}ht();var tr=Be();if(tr===0)Be();else if(tr===1)for(Ge(1),$e(),$e(),T=Be(),C=0;C<T;C++)$e();ht(),Ge(1);var jt=Be(),Ft=Be(),Ht=Pe(1);Ht===0&&Ge(1),Ge(1),We()&&(G=Be(),Q=Be(),Z=Be(),Te=Be());var rt=[1,1];if(We()&&We())switch(Re()){case 1:rt=[1,1];break;case 2:rt=[12,11];break;case 3:rt=[10,11];break;case 4:rt=[16,11];break;case 5:rt=[40,33];break;case 6:rt=[24,11];break;case 7:rt=[20,11];break;case 8:rt=[32,11];break;case 9:rt=[80,33];break;case 10:rt=[18,11];break;case 11:rt=[15,11];break;case 12:rt=[64,33];break;case 13:rt=[160,99];break;case 14:rt=[4,3];break;case 15:rt=[3,2];break;case 16:rt=[2,1];break;case 255:rt=[Re()<<8|Re(),Re()<<8|Re()]}return{width:Math.ceil(16*(jt+1)-2*G-2*Q),height:(2-Ht)*(Ft+1)*16-(Ht?2:4)*(Z+Te),pixelRatio:rt}},N.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},te}(),H=function(){function te(T,O,C){this.keyData=void 0,this.decrypter=void 0,this.keyData=C,this.decrypter=new R.default(O,{removePKCS7Padding:!1})}var N=te.prototype;return N.decryptBuffer=function(T){return this.decrypter.decrypt(T,this.keyData.key.buffer,this.keyData.iv.buffer)},N.decryptAacSample=function(T,O,C){var G=this,Q=T[O].unit;if(!(Q.length<=16)){var Z=Q.subarray(16,Q.length-Q.length%16),Te=Z.buffer.slice(Z.byteOffset,Z.byteOffset+Z.length);this.decryptBuffer(Te).then(function(Re){var Pe=new Uint8Array(Re);Q.set(Pe,16),G.decrypter.isSync()||G.decryptAacSamples(T,O+1,C)})}},N.decryptAacSamples=function(T,O,C){for(;;O++){if(O>=T.length)return void C();if(!(T[O].unit.length<32||(this.decryptAacSample(T,O,C),this.decrypter.isSync())))return}},N.getAvcEncryptedData=function(T){for(var O=16*Math.floor((T.length-48)/160)+16,C=new Int8Array(O),G=0,Q=32;Q<T.length-16;Q+=160,G+=16)C.set(T.subarray(Q,Q+16),G);return C},N.getAvcDecryptedUnit=function(T,O){for(var C=new Uint8Array(O),G=0,Q=32;Q<T.length-16;Q+=160,G+=16)T.set(C.subarray(G,G+16),Q);return T},N.decryptAvcSample=function(T,O,C,G,Q){var Z=this,Te=(0,ne.discardEPB)(Q.data),Re=this.getAvcEncryptedData(Te);this.decryptBuffer(Re.buffer).then(function(Pe){Q.data=Z.getAvcDecryptedUnit(Te,Pe),Z.decrypter.isSync()||Z.decryptAvcSamples(T,O,C+1,G)})},N.decryptAvcSamples=function(T,O,C,G){if(T instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;O++,C=0){if(O>=T.length)return void G();for(var Q=T[O].units;!(C>=Q.length);C++){var Z=Q[C];if(!(Z.data.length<=48||Z.type!==1&&Z.type!==5||(this.decryptAvcSample(T,O,C,G,Z),this.decrypter.isSync())))return}}},te}();function ve(){return ve=Object.assign?Object.assign.bind():function(te){for(var N=1;N<arguments.length;N++){var T=arguments[N];for(var O in T)Object.prototype.hasOwnProperty.call(T,O)&&(te[O]=T[O])}return te},ve.apply(this,arguments)}var Ie=188;function Fe(te,N,T,O){return{key:te,frame:!1,pts:N,dts:T,units:[],debug:O,length:0}}function fe(te,N){return(31&te[N+10])<<8|te[N+11]}function Ce(te,N,T,O){var C={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},G=N+3+((15&te[N+1])<<8|te[N+2])-4;for(N+=12+((15&te[N+10])<<8|te[N+11]);N<G;){var Q=(31&te[N+1])<<8|te[N+2];switch(te[N]){case 207:if(!O){J.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:C.audio===-1&&(C.audio=Q);break;case 21:C.id3===-1&&(C.id3=Q);break;case 219:if(!O){J.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:C.avc===-1&&(C.avc=Q);break;case 3:case 4:T.mpeg!==!0&&T.mp3!==!0?J.logger.log("MPEG audio found, not supported in this browser"):C.audio===-1&&(C.audio=Q,C.segmentCodec="mp3");break;case 36:J.logger.warn("Unsupported HEVC stream type found")}N+=5+((15&te[N+3])<<8|te[N+4])}return C}function Ve(te){var N,T,O,C,G,Q=0,Z=te.data;if(!te||te.size===0)return null;for(;Z[0].length<19&&Z.length>1;){var Te=new Uint8Array(Z[0].length+Z[1].length);Te.set(Z[0]),Te.set(Z[1],Z[0].length),Z[0]=Te,Z.splice(1,1)}if(((N=Z[0])[0]<<16)+(N[1]<<8)+N[2]===1){if((T=(N[4]<<8)+N[5])&&T>te.size-6)return null;var Re=N[7];192&Re&&(C=536870912*(14&N[9])+4194304*(255&N[10])+16384*(254&N[11])+128*(255&N[12])+(254&N[13])/2,64&Re?C-(G=536870912*(14&N[14])+4194304*(255&N[15])+16384*(254&N[16])+128*(255&N[17])+(254&N[18])/2)>54e5&&(J.logger.warn(Math.round((C-G)/9e4)+"s delta between PTS and DTS, align them"),C=G):G=C);var Pe=(O=N[8])+9;if(te.size<=Pe)return null;te.size-=Pe;for(var Be=new Uint8Array(te.size),We=0,Ge=Z.length;We<Ge;We++){var $e=(N=Z[We]).byteLength;if(Pe){if(Pe>$e){Pe-=$e;continue}N=N.subarray(Pe),$e-=Pe,Pe=0}Be.set(N,Q),Q+=$e}return T&&(T-=O+3),{data:Be,pts:C,dts:G,len:T}}return null}function Xe(te,N){if(te.units.length&&te.frame){if(te.pts===void 0){var T=N.samples,O=T.length;if(!O)return void N.dropped++;var C=T[O-1];te.pts=C.pts,te.dts=C.dts}N.samples.push(te)}te.debug.length&&J.logger.log(te.pts+"/"+te.dts+":"+te.debug)}let it=function(){function te(T,O,C){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=O,this.typeSupported=C}te.probe=function(T){var O=te.syncOffset(T);return O>0&&J.logger.warn("MPEG2-TS detected but first sync word found @ offset "+O),O!==-1},te.syncOffset=function(T){for(var O=Math.min(940,T.length-376)+1,C=0;C<O;){if(T[C]===71&&T[C+Ie]===71)return C;C++}return-1},te.createTrack=function(T,O){return{container:T==="video"||T==="audio"?"video/mp2t":void 0,type:T,id:ne.RemuxerTrackIdConfig[T],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:T==="audio"?O:void 0}};var N=te.prototype;return N.resetInitSegment=function(T,O,C,G){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=te.createTrack("video"),this._audioTrack=te.createTrack("audio",G),this._id3Track=te.createTrack("id3"),this._txtTrack=te.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=O,this.videoCodec=C,this._duration=G},N.resetTimeStamp=function(){},N.resetContiguity=function(){var T=this._audioTrack,O=this._avcTrack,C=this._id3Track;T&&(T.pesData=null),O&&(O.pesData=null),C&&(C.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},N.demux=function(T,O,C,G){var Q;C===void 0&&(C=!1),G===void 0&&(G=!1),C||(this.sampleAes=null);var Z=this._avcTrack,Te=this._audioTrack,Re=this._id3Track,Pe=this._txtTrack,Be=Z.pid,We=Z.pesData,Ge=Te.pid,$e=Re.pid,ht=Te.pesData,Dt=Re.pesData,ze=null,Pt=this.pmtParsed,tr=this._pmtId,jt=T.length;if(this.remainderData&&(jt=(T=(0,ne.appendUint8Array)(this.remainderData,T)).length,this.remainderData=null),jt<Ie&&!G)return this.remainderData=T,{audioTrack:Te,videoTrack:Z,id3Track:Re,textTrack:Pe};var Ft=Math.max(0,te.syncOffset(T));(jt-=(jt-Ft)%Ie)<T.byteLength&&!G&&(this.remainderData=new Uint8Array(T.buffer,jt,T.buffer.byteLength-jt));for(var Ht=0,rt=Ft;rt<jt;rt+=Ie)if(T[rt]===71){var lr=!!(64&T[rt+1]),Ar=((31&T[rt+1])<<8)+T[rt+2],Kt=void 0;if((48&T[rt+3])>>4>1){if((Kt=rt+5+T[rt+4])===rt+Ie)continue}else Kt=rt+4;switch(Ar){case Be:lr&&(We&&(Q=Ve(We))&&this.parseAVCPES(Z,Pe,Q,!1),We={data:[],size:0}),We&&(We.data.push(T.subarray(Kt,rt+Ie)),We.size+=rt+Ie-Kt);break;case Ge:if(lr){if(ht&&(Q=Ve(ht)))switch(Te.segmentCodec){case"aac":this.parseAACPES(Te,Q);break;case"mp3":this.parseMPEGPES(Te,Q)}ht={data:[],size:0}}ht&&(ht.data.push(T.subarray(Kt,rt+Ie)),ht.size+=rt+Ie-Kt);break;case $e:lr&&(Dt&&(Q=Ve(Dt))&&this.parseID3PES(Re,Q),Dt={data:[],size:0}),Dt&&(Dt.data.push(T.subarray(Kt,rt+Ie)),Dt.size+=rt+Ie-Kt);break;case 0:lr&&(Kt+=T[Kt]+1),tr=this._pmtId=fe(T,Kt);break;case tr:lr&&(Kt+=T[Kt]+1);var Jt=Ce(T,Kt,this.typeSupported,C);(Be=Jt.avc)>0&&(Z.pid=Be),(Ge=Jt.audio)>0&&(Te.pid=Ge,Te.segmentCodec=Jt.segmentCodec),($e=Jt.id3)>0&&(Re.pid=$e),ze===null||Pt||(J.logger.log("unknown PID '"+ze+"' in TS found"),ze=null,rt=Ft-188),Pt=this.pmtParsed=!0;break;case 17:case 8191:break;default:ze=Ar}}else Ht++;Ht>0&&this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:re.ErrorTypes.MEDIA_ERROR,details:re.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Ht+" TS packet/s that do not start with 0x47"}),Z.pesData=We,Te.pesData=ht,Re.pesData=Dt;var pr={audioTrack:Te,videoTrack:Z,id3Track:Re,textTrack:Pe};return G&&this.extractRemainingSamples(pr),pr},N.flush=function(){var T,O=this.remainderData;return this.remainderData=null,T=O?this.demux(O,-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},N.extractRemainingSamples=function(T){var O,C=T.audioTrack,G=T.videoTrack,Q=T.id3Track,Z=T.textTrack,Te=G.pesData,Re=C.pesData,Pe=Q.pesData;if(Te&&(O=Ve(Te))?(this.parseAVCPES(G,Z,O,!0),G.pesData=null):G.pesData=Te,Re&&(O=Ve(Re))){switch(C.segmentCodec){case"aac":this.parseAACPES(C,O);break;case"mp3":this.parseMPEGPES(C,O)}C.pesData=null}else Re!=null&&Re.size&&J.logger.log("last AAC PES packet truncated,might overlap between fragments"),C.pesData=Re;Pe&&(O=Ve(Pe))?(this.parseID3PES(Q,O),Q.pesData=null):Q.pesData=Pe},N.demuxSampleAes=function(T,O,C){var G=this.demux(T,C,!0,!this.config.progressive),Q=this.sampleAes=new H(this.observer,this.config,O);return this.decrypt(G,Q)},N.decrypt=function(T,O){return new Promise(function(C){var G=T.audioTrack,Q=T.videoTrack;G.samples&&G.segmentCodec==="aac"?O.decryptAacSamples(G.samples,0,function(){Q.samples?O.decryptAvcSamples(Q.samples,0,0,function(){C(T)}):C(T)}):Q.samples&&O.decryptAvcSamples(Q.samples,0,0,function(){C(T)})})},N.destroy=function(){this._duration=0},N.parseAVCPES=function(T,O,C,G){var Q,Z=this,Te=this.parseAVCNALu(T,C.data),Re=this.avcSample,Pe=!1;C.data=null,Re&&Te.length&&!T.audFound&&(Xe(Re,T),Re=this.avcSample=Fe(!1,C.pts,C.dts,"")),Te.forEach(function(Be){switch(Be.type){case 1:Q=!0,Re||(Re=Z.avcSample=Fe(!0,C.pts,C.dts,"")),Re.frame=!0;var We=Be.data;if(Pe&&We.length>4){var Ge=new Ue(We).readSliceType();Ge!==2&&Ge!==4&&Ge!==7&&Ge!==9||(Re.key=!0)}break;case 5:Q=!0,Re||(Re=Z.avcSample=Fe(!0,C.pts,C.dts,"")),Re.key=!0,Re.frame=!0;break;case 6:Q=!0,(0,ne.parseSEIMessageFromNALu)(Be.data,1,C.pts,O.samples);break;case 7:if(Q=!0,Pe=!0,!T.sps){var $e=new Ue(Be.data).readSPS();T.width=$e.width,T.height=$e.height,T.pixelRatio=$e.pixelRatio,T.sps=[Be.data],T.duration=Z._duration;for(var ht=Be.data.subarray(1,4),Dt="avc1.",ze=0;ze<3;ze++){var Pt=ht[ze].toString(16);Pt.length<2&&(Pt="0"+Pt),Dt+=Pt}T.codec=Dt}break;case 8:Q=!0,T.pps||(T.pps=[Be.data]);break;case 9:Q=!1,T.audFound=!0,Re&&Xe(Re,T),Re=Z.avcSample=Fe(!1,C.pts,C.dts,"");break;case 12:Q=!0;break;default:Q=!1,Re&&(Re.debug+="unknown NAL "+Be.type+" ")}Re&&Q&&Re.units.push(Be)}),G&&Re&&(Xe(Re,T),this.avcSample=null)},N.getLastNalUnit=function(T){var O,C,G=this.avcSample;if(G&&G.units.length!==0||(G=T[T.length-1]),(O=G)!==null&&O!==void 0&&O.units){var Q=G.units;C=Q[Q.length-1]}return C},N.parseAVCNALu=function(T,O){var C,G,Q=O.byteLength,Z=T.naluState||0,Te=Z,Re=[],Pe=0,Be=-1,We=0;for(Z===-1&&(Be=0,We=31&O[0],Z=0,Pe=1);Pe<Q;)if(C=O[Pe++],Z)if(Z!==1)if(C)if(C===1){if(Be>=0){var Ge={data:O.subarray(Be,Pe-Z-1),type:We};Re.push(Ge)}else{var $e=this.getLastNalUnit(T.samples);if($e&&(Te&&Pe<=4-Te&&$e.state&&($e.data=$e.data.subarray(0,$e.data.byteLength-Te)),(G=Pe-Z-1)>0)){var ht=new Uint8Array($e.data.byteLength+G);ht.set($e.data,0),ht.set(O.subarray(0,G),$e.data.byteLength),$e.data=ht,$e.state=0}}Pe<Q?(Be=Pe,We=31&O[Pe],Z=0):Z=-1}else Z=0;else Z=3;else Z=C?0:2;else Z=C?0:1;if(Be>=0&&Z>=0){var Dt={data:O.subarray(Be,Q),type:We,state:Z};Re.push(Dt)}if(Re.length===0){var ze=this.getLastNalUnit(T.samples);if(ze){var Pt=new Uint8Array(ze.data.byteLength+O.byteLength);Pt.set(ze.data,0),Pt.set(O,ze.data.byteLength),ze.data=Pt}}return T.naluState=Z,Re},N.parseAACPES=function(T,O){var C,G,Q,Z,Te,Re=0,Pe=this.aacOverFlow,Be=O.data;if(Pe){this.aacOverFlow=null;var We=Pe.missing,Ge=Pe.sample.unit.byteLength;if(We===-1){var $e=new Uint8Array(Ge+Be.byteLength);$e.set(Pe.sample.unit,0),$e.set(Be,Ge),Be=$e}else{var ht=Ge-We;Pe.sample.unit.set(Be.subarray(0,We),ht),T.samples.push(Pe.sample),Re=Pe.missing}}for(C=Re,G=Be.length;C<G-1&&!ke(Be,C);C++);if(C===Re||(C<G-1?(Q="AAC PES did not start with ADTS header,offset:"+C,Z=!1):(Q="no ADTS header found in AAC PES",Z=!0),J.logger.warn("parsing error:"+Q),this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:re.ErrorTypes.MEDIA_ERROR,details:re.ErrorDetails.FRAG_PARSING_ERROR,fatal:Z,reason:Q}),!Z)){if(V(T,this.observer,Be,C,this.audioCodec),O.pts!==void 0)Te=O.pts;else{if(!Pe)return void J.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var Dt=E(T.samplerate);Te=Pe.sample.pts+Dt}for(var ze,Pt=0;C<G;){if(C+=(ze=U(T,Be,C,Te,Pt)).length,ze.missing){this.aacOverFlow=ze;break}for(Pt++;C<G-1&&!ke(Be,C);C++);}}},N.parseMPEGPES=function(T,O){var C=O.data,G=C.length,Q=0,Z=0,Te=O.pts;if(Te!==void 0)for(;Z<G;)if(pe(C,Z)){var Re=qe(T,C,Z,Te,Q);if(!Re)break;Z+=Re.length,Q++}else Z++;else J.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},N.parseID3PES=function(T,O){if(O.pts!==void 0){var C=ve({},O,{type:this._avcTrack?L.MetadataSchema.emsg:L.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});T.samples.push(C)}else J.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},te}();function lt(te,N){return lt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,O){return T.__proto__=O,T},lt(te,N)}let Ct=function(te){var N,T;function O(){return te.apply(this,arguments)||this}T=te,(N=O).prototype=Object.create(T.prototype),N.prototype.constructor=N,lt(N,T);var C=O.prototype;return C.resetInitSegment=function(G,Q,Z,Te){te.prototype.resetInitSegment.call(this,G,Q,Z,Te),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:Q,duration:Te,inputTimeScale:9e4,dropped:0}},O.probe=function(G){if(!G)return!1;for(var Q=(k.getID3Data(G,0)||[]).length,Z=G.length;Q<Z;Q++)if(ae(G,Q))return J.logger.log("MPEG Audio sync word found !"),!0;return!1},C.canParse=function(G,Q){return function(Z,Te){return ie(Z,Te)&&4<=Z.length-Te}(G,Q)},C.appendFrame=function(G,Q,Z){if(this.basePTS!==null)return qe(G,Q,Z,this.basePTS,this.frameIndex)},O}(ye);var Rt=B(524),St=B(923);function wt(te,N){var T=te==null?void 0:te.codec;return T&&T.length>4?T:T==="hvc1"||T==="hev1"?"hvc1.1.c.L120.90":T==="av01"?"av01.0.04M.08":T==="avc1"||N===St.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let gt=function(){function te(){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 N=te.prototype;return N.destroy=function(){},N.resetTimeStamp=function(T){this.initPTS=T,this.lastEndTime=null},N.resetNextTimestamp=function(){this.lastEndTime=null},N.resetInitSegment=function(T,O,C,G){this.audioCodec=O,this.videoCodec=C,this.generateInitSegment((0,ne.patchEncyptionData)(T,G)),this.emitInitSegment=!0},N.generateInitSegment=function(T){var O=this.audioCodec,C=this.videoCodec;if(!T||!T.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var G=this.initData=(0,ne.parseInitSegment)(T);O||(O=wt(G.audio,St.ElementaryStreamTypes.AUDIO)),C||(C=wt(G.video,St.ElementaryStreamTypes.VIDEO));var Q={};G.audio&&G.video?Q.audiovideo={container:"video/mp4",codec:O+","+C,initSegment:T,id:"main"}:G.audio?Q.audio={container:"audio/mp4",codec:O,initSegment:T,id:"audio"}:G.video?Q.video={container:"video/mp4",codec:C,initSegment:T,id:"main"}:J.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=Q},N.remux=function(T,O,C,G,Q){var Z,Te=this.initPTS,Re=this.lastEndTime,Pe={audio:void 0,video:void 0,text:G,id3:C,initSegment:void 0};(0,g.isFiniteNumber)(Re)||(Re=this.lastEndTime=Q||0);var Be=O.samples;if(!Be||!Be.length)return Pe;var We={initPTS:void 0,timescale:1},Ge=this.initData;if(Ge&&Ge.length||(this.generateInitSegment(Be),Ge=this.initData),!Ge||!Ge.length)return J.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),Pe;this.emitInitSegment&&(We.tracks=this.initTracks,this.emitInitSegment=!1);var $e=(0,ne.getStartDTS)(Ge,Be);(0,g.isFiniteNumber)(Te)||(this.initPTS=We.initPTS=Te=$e-Q);var ht=(0,ne.getDuration)(Be,Ge),Dt=T?$e-Te:Re,ze=Dt+ht;(0,ne.offsetStartDTS)(Ge,Be,Te),ht>0?this.lastEndTime=ze:(J.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var Pt=!!Ge.audio,tr=!!Ge.video,jt="";Pt&&(jt+="audio"),tr&&(jt+="video");var Ft={data1:Be,startPTS:Dt,startDTS:Dt,endPTS:ze,endDTS:ze,type:jt,hasAudio:Pt,hasVideo:tr,nb:1,dropped:0};Pe.audio=Ft.type==="audio"?Ft:void 0,Pe.video=Ft.type!=="audio"?Ft:void 0,Pe.initSegment=We;var Ht=(Z=this.initPTS)!=null?Z:0;return Pe.id3=(0,Rt.flushTextTrackMetadataCueSamples)(C,Q,Ht,Ht),G.samples.length&&(Pe.text=(0,Rt.flushTextTrackUserdataCueSamples)(G,Q,Ht)),Pe},te}();var dt;try{dt=self.performance.now.bind(self.performance)}catch{J.logger.debug("Unable to use Performance API on this environment"),dt=self.Date.now}var tt=[{demux:z,remux:gt},{demux:it,remux:Rt.default},{demux:de,remux:Rt.default},{demux:Ct,remux:Rt.default}],It=function(){function te(T,O,C,G,Q){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=O,this.config=C,this.vendor=G,this.id=Q}var N=te.prototype;return N.configure=function(T){this.transmuxConfig=T,this.decrypter&&this.decrypter.reset()},N.push=function(T,O,C,G){var Q=this,Z=C.transmuxing;Z.executeStart=dt();var Te=new Uint8Array(T),Re=this.currentTransmuxState,Pe=this.transmuxConfig;G&&(this.currentTransmuxState=G);var Be=G||Re,We=Be.contiguous,Ge=Be.discontinuity,$e=Be.trackSwitch,ht=Be.accurateTimeOffset,Dt=Be.timeOffset,ze=Be.initSegmentChange,Pt=Pe.audioCodec,tr=Pe.videoCodec,jt=Pe.defaultInitPts,Ft=Pe.duration,Ht=Pe.initSegmentData,rt=function(Cr,vr){var Gt=null;return Cr.byteLength>0&&vr!=null&&vr.key!=null&&vr.iv!==null&&vr.method!=null&&(Gt=vr),Gt}(Te,O);if(rt&&rt.method==="AES-128"){var lr=this.getDecrypter();if(!lr.isSync())return this.decryptionPromise=lr.webCryptoDecrypt(Te,rt.key.buffer,rt.iv.buffer).then(function(Cr){var vr=Q.push(Cr,null,C);return Q.decryptionPromise=null,vr}),this.decryptionPromise;var Ar=lr.softwareDecrypt(Te,rt.key.buffer,rt.iv.buffer);if(!Ar)return Z.executeEnd=dt(),Ut(C);Te=new Uint8Array(Ar)}var Kt=this.needsProbing(Ge,$e);Kt&&this.configureTransmuxer(Te),(Ge||$e||ze||Kt)&&this.resetInitSegment(Ht,Pt,tr,Ft,O),(Ge||ze||Kt)&&this.resetInitialTimestamp(jt),We||this.resetContiguity();var Jt=this.transmux(Te,rt,Dt,ht,C),pr=this.currentTransmuxState;return pr.contiguous=!0,pr.discontinuity=!1,pr.trackSwitch=!1,Z.executeEnd=dt(),Jt},N.flush=function(T){var O=this,C=T.transmuxing;C.executeStart=dt();var G=this.decrypter,Q=this.currentTransmuxState,Z=this.decryptionPromise;if(Z)return Z.then(function(){return O.flush(T)});var Te=[],Re=Q.timeOffset;if(G){var Pe=G.flush();Pe&&Te.push(this.push(Pe,null,T))}var Be=this.demuxer,We=this.remuxer;if(!Be||!We)return this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:re.ErrorTypes.MEDIA_ERROR,details:re.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),C.executeEnd=dt(),[Ut(T)];var Ge=Be.flush(Re);return Wt(Ge)?Ge.then(function($e){return O.flushRemux(Te,$e,T),Te}):(this.flushRemux(Te,Ge,T),Te)},N.flushRemux=function(T,O,C){var G=O.audioTrack,Q=O.videoTrack,Z=O.id3Track,Te=O.textTrack,Re=this.currentTransmuxState,Pe=Re.accurateTimeOffset,Be=Re.timeOffset;J.logger.log("[transmuxer.ts]: Flushed fragment "+C.sn+(C.part>-1?" p: "+C.part:"")+" of level "+C.level);var We=this.remuxer.remux(G,Q,Z,Te,Be,Pe,!0,this.id);T.push({remuxResult:We,chunkMeta:C}),C.transmuxing.executeEnd=dt()},N.resetInitialTimestamp=function(T){var O=this.demuxer,C=this.remuxer;O&&C&&(O.resetTimeStamp(T),C.resetTimeStamp(T))},N.resetContiguity=function(){var T=this.demuxer,O=this.remuxer;T&&O&&(T.resetContiguity(),O.resetNextTimestamp())},N.resetInitSegment=function(T,O,C,G,Q){var Z=this.demuxer,Te=this.remuxer;Z&&Te&&(Z.resetInitSegment(T,O,C,G),Te.resetInitSegment(T,O,C,Q))},N.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},N.transmux=function(T,O,C,G,Q){return O&&O.method==="SAMPLE-AES"?this.transmuxSampleAes(T,O,C,G,Q):this.transmuxUnencrypted(T,C,G,Q)},N.transmuxUnencrypted=function(T,O,C,G){var Q=this.demuxer.demux(T,O,!1,!this.config.progressive),Z=Q.audioTrack,Te=Q.videoTrack,Re=Q.id3Track,Pe=Q.textTrack;return{remuxResult:this.remuxer.remux(Z,Te,Re,Pe,O,C,!1,this.id),chunkMeta:G}},N.transmuxSampleAes=function(T,O,C,G,Q){var Z=this;return this.demuxer.demuxSampleAes(T,O,C).then(function(Te){return{remuxResult:Z.remuxer.remux(Te.audioTrack,Te.videoTrack,Te.id3Track,Te.textTrack,C,G,!1,Z.id),chunkMeta:Q}})},N.configureTransmuxer=function(T){for(var O,C=this.config,G=this.observer,Q=this.typeSupported,Z=this.vendor,Te=0,Re=tt.length;Te<Re;Te++)if(tt[Te].demux.probe(T)){O=tt[Te];break}O||(J.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),O={demux:z,remux:gt});var Pe=this.demuxer,Be=this.remuxer,We=O.remux,Ge=O.demux;Be&&Be instanceof We||(this.remuxer=new We(G,C,Q,Z)),Pe&&Pe instanceof Ge||(this.demuxer=new Ge(G,C,Q),this.probe=Ge.probe)},N.needsProbing=function(T,O){return!this.demuxer||!this.remuxer||T||O},N.getDecrypter=function(){var T=this.decrypter;return T||(T=this.decrypter=new R.default(this.config)),T},te}(),Ut=function(te){return{remuxResult:{},chunkMeta:te}};function Wt(te){return"then"in te&&te.then instanceof Function}var Bt=function(te,N,T,O,C){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=te,this.videoCodec=N,this.initSegmentData=T,this.duration=O,this.defaultInitPts=C},ar=function(te,N,T,O,C,G){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=te,this.contiguous=N,this.accurateTimeOffset=T,this.trackSwitch=O,this.timeOffset=C,this.initSegmentChange=G}},973:(oe,X,B)=>{"use strict";var j,re;B.r(X),B.d(X,{ErrorDetails:()=>re,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"}(re||(re={}))},851:(oe,X,B)=>{"use strict";var j;B.r(X),B.d(X,{Events:()=>j}),function(re){re.MEDIA_ATTACHING="hlsMediaAttaching",re.MEDIA_ATTACHED="hlsMediaAttached",re.MEDIA_DETACHING="hlsMediaDetaching",re.MEDIA_DETACHED="hlsMediaDetached",re.BUFFER_RESET="hlsBufferReset",re.BUFFER_CODECS="hlsBufferCodecs",re.BUFFER_CREATED="hlsBufferCreated",re.BUFFER_APPENDING="hlsBufferAppending",re.BUFFER_APPENDED="hlsBufferAppended",re.BUFFER_EOS="hlsBufferEos",re.BUFFER_FLUSHING="hlsBufferFlushing",re.BUFFER_FLUSHED="hlsBufferFlushed",re.MANIFEST_LOADING="hlsManifestLoading",re.MANIFEST_LOADED="hlsManifestLoaded",re.MANIFEST_PARSED="hlsManifestParsed",re.LEVEL_SWITCHING="hlsLevelSwitching",re.LEVEL_SWITCHED="hlsLevelSwitched",re.LEVEL_LOADING="hlsLevelLoading",re.LEVEL_LOADED="hlsLevelLoaded",re.LEVEL_UPDATED="hlsLevelUpdated",re.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",re.LEVELS_UPDATED="hlsLevelsUpdated",re.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",re.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",re.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",re.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",re.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",re.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",re.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",re.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",re.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",re.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",re.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",re.CUES_PARSED="hlsCuesParsed",re.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",re.INIT_PTS_FOUND="hlsInitPtsFound",re.FRAG_LOADING="hlsFragLoading",re.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",re.FRAG_LOADED="hlsFragLoaded",re.FRAG_DECRYPTED="hlsFragDecrypted",re.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",re.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",re.FRAG_PARSING_METADATA="hlsFragParsingMetadata",re.FRAG_PARSED="hlsFragParsed",re.FRAG_BUFFERED="hlsFragBuffered",re.FRAG_CHANGED="hlsFragChanged",re.FPS_DROP="hlsFpsDrop",re.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",re.ERROR="hlsError",re.DESTROYING="hlsDestroying",re.KEY_LOADING="hlsKeyLoading",re.KEY_LOADED="hlsKeyLoaded",re.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",re.BACK_BUFFER_REACHED="hlsBackBufferReached"}(j||(j={}))},76:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{default:()=>ja});var j,re=B(945),R=B(965),g=B(851),k=B(973),L=B(93),me=/^(\d+)x(\d+)$/,ne=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,ce=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(ne.lastIndex=0;(t=ne.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 we(){return we=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},we.apply(this,arguments)}function q(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 ye=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]){L.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=a;break}t=we(new ce({}),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)}}])&&q(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}(),J=B(923);function se(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 K,Ee,ke,Ne=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}}])&&se(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 Ee.FAIRPLAY:return K.FAIRPLAY;case Ee.PLAYREADY:return K.PLAYREADY;case Ee.WIDEVINE:return K.WIDEVINE;case Ee.CLEARKEY:return K.CLEARKEY}}function D(d){switch(d){case K.FAIRPLAY:return Ee.FAIRPLAY;case K.PLAYREADY:return Ee.PLAYREADY;case K.WIDEVINE:return Ee.WIDEVINE;case K.CLEARKEY:return Ee.CLEARKEY}}function de(d){var o=d.drmSystems,e=d.widevineLicenseUrl,t=o?[K.FAIRPLAY,K.WIDEVINE,K.PLAYREADY,K.CLEARKEY].filter(function(i){return!!o[i]}):[];return!t[K.WIDEVINE]&&e&&t.push(K.WIDEVINE),t}(function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.fps",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="com.widevine.alpha"})(K||(K={})),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"}(Ee||(Ee={})),function(d){d.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"}(ke||(ke={}));var Se=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null,z=B(63),$={},Le=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(){$={}};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 Ee.FAIRPLAY:case Ee.WIDEVINE:case Ee.PLAYREADY:case Ee.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||L.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=function(F){for(var P=new Uint8Array(16),W=12;W<16;W++)P[W]=F>>8*(15-W)&255;return P}(e);return new d(this.method,this.uri,"identity",this.keyFormatVersions,t)}var i=function(F){var P,W,ue=F.split(":"),_e=null;if(ue[0]==="data"&&ue.length===2){var ge=ue[1].split(";"),De=ge[ge.length-1].split(",");if(De.length===2){var He=De[0]==="base64",Je=De[1];He?(ge.splice(-1,1),_e=V(Je)):(P=E(Je).subarray(0,16),(W=new Uint8Array(16)).set(P,16-P.length),_e=W)}}return _e}(this.uri);if(i)switch(this.keyFormat){case Ee.WIDEVINE:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case Ee.PLAYREADY:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,z.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(F){var P=function(W,ue,_e){var ge=W[ue];W[ue]=W[_e],W[_e]=ge};P(F,0,3),P(F,1,2),P(F,4,5),P(F,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 _=$[this.uri];if(!_){var S=Object.keys($).length%Number.MAX_SAFE_INTEGER;_=new Uint8Array(16),new DataView(_.buffer,12,4).setUint32(0,S),$[this.uri]=_}this.keyId=_}return this},d}(),Oe={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 xe(d,o){return MediaSource.isTypeSupported((o||"video")+'/mp4;codecs="'+d+'"')}function be(){return be=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},be.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,at=/#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"),pe=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("|")),ae=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,re.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 ce(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),H((u.CODECS||"").split(/[ ,]+/).filter(function(F){return F}),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 ce(t[3]);m["DATA-ID"]&&(s=!0,a[m["DATA-ID"]]=m)}else if(t[4]){var _=t[4],S=Ue(_,e);S.encrypted&&S.isSupported()?r.push(S):L.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(at.lastIndex=0;(n=at.exec(o))!==null;){var s=new ce(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];ve(l,u,"audioCodec"),ve(l,u,"textCodec")}a.push(l)}}return a},d.parseLevelPlaylist=function(o,e,t,i,n){var a,r,s,l=new Ne(e),u=l.fragments,c=null,v=0,m=0,_=0,S=0,F=null,P=new J.Fragment(i,e),W=-1,ue=!1;for(ie.lastIndex=0,l.m3u8=o;(a=ie.exec(o))!==null;){ue&&(ue=!1,(P=new J.Fragment(i,e)).start=_,P.sn=v,P.cc=S,P.level=t,c&&(P.initSegment=c,P.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null));var _e=a[1];if(_e){P.duration=parseFloat(_e);var ge=(" "+a[2]).slice(1);P.title=ge||null,P.tagList.push(ge?["INF",_e,ge]:["INF",_e])}else if(a[3]){if((0,R.isFiniteNumber)(P.duration)){if(P.start=_,s){P.levelkeys=s;var De=l.encryptedFragments;!P.levelkeys||!Object.keys(P.levelkeys).some(function(Ir){return P.levelkeys[Ir].isCommonEncryption})||De.length&&De[De.length-1].levelkeys===s||De.push(P)}P.sn=v,P.level=t,P.cc=S,P.urlId=n,u.push(P),P.relurl=(" "+a[3]).slice(1),Ie(P,F),F=P,_+=P.duration,v++,m=0,ue=!0}}else if(a[4]){var He=(" "+a[4]).slice(1);F?P.setByteRange(He,F):P.setByteRange(He)}else if(a[5])P.rawProgramDateTime=(" "+a[5]).slice(1),P.tagList.push(["PROGRAM-DATE-TIME",P.rawProgramDateTime]),W===-1&&(W=u.length);else{if(!(a=a[0].match(pe))){L.logger.warn("No matches on slow regex match for level playlist!");continue}for(r=1;r<a.length&&a[r]===void 0;r++);var Je=(" "+a[r]).slice(1),Ae=(" "+a[r+1]).slice(1),Ke=a[r+2]?(" "+a[r+2]).slice(1):"";switch(Je){case"PLAYLIST-TYPE":l.type=Ae.toUpperCase();break;case"MEDIA-SEQUENCE":v=l.startSN=parseInt(Ae);break;case"SKIP":var je=new ce(Ae),pt=je.decimalInteger("SKIPPED-SEGMENTS");if((0,R.isFiniteNumber)(pt)){l.skippedSegments=pt;for(var Mt=pt;Mt--;)u.unshift(null);v+=pt}var mt=je.enumeratedString("RECENTLY-REMOVED-DATERANGES");mt&&(l.recentlyRemovedDateranges=mt.split(" "));break;case"TARGETDURATION":l.targetduration=parseFloat(Ae);break;case"VERSION":l.version=parseInt(Ae);break;case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"#":(Ae||Ke)&&P.tagList.push(Ke?[Ae,Ke]:[Ae]);break;case"DISCONTINUITY":S++,P.tagList.push(["DIS"]);break;case"GAP":P.tagList.push([Je]);break;case"BITRATE":P.tagList.push([Je,Ae]);break;case"DATERANGE":var kt=new ce(Ae),xt=new ye(kt,l.dateRanges[kt.ID]);xt.isValid||l.skippedSegments?l.dateRanges[xt.id]=xt:L.logger.warn('Ignoring invalid DATERANGE tag: "'+Ae+'"'),P.tagList.push(["EXT-X-DATERANGE",Ae]);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(Ae);break;case"KEY":var ir=Ue(Ae,e);if(ir.isSupported()){if(ir.method==="NONE"){s=void 0;break}s||(s={}),s[ir.keyFormat]&&(s=be({},s)),s[ir.keyFormat]=ir}else L.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+Ae+'"');break;case"START":var er=new ce(Ae).decimalFloatingPoint("TIME-OFFSET");(0,R.isFiniteNumber)(er)&&(l.startTimeOffset=er);break;case"MAP":var Yt=new ce(Ae);if(P.duration){var nr=new J.Fragment(i,e);Fe(nr,Yt,t,s),c=nr,P.initSegment=c,c.rawProgramDateTime&&!P.rawProgramDateTime&&(P.rawProgramDateTime=c.rawProgramDateTime)}else Fe(P,Yt,t,s),c=P,ue=!0;break;case"SERVER-CONTROL":var _r=new ce(Ae);l.canBlockReload=_r.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=_r.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&_r.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=_r.optionalFloat("PART-HOLD-BACK",0),l.holdBack=_r.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Jn=new ce(Ae);l.partTarget=Jn.decimalFloatingPoint("PART-TARGET");break;case"PART":var Pr=l.partList;Pr||(Pr=l.partList=[]);var Bi=m>0?Pr[Pr.length-1]:void 0,ji=m++,Gi=new J.Part(new ce(Ae),P,e,ji,Bi);Pr.push(Gi),P.duration+=Gi.duration;break;case"PRELOAD-HINT":var ct=new ce(Ae);l.preloadHint=ct;break;case"RENDITION-REPORT":var yt=new ce(Ae);l.renditionReports=l.renditionReports||[],l.renditionReports.push(yt);break;default:L.logger.warn("line parsed but not handled: "+a)}}}F&&!F.relurl?(u.pop(),_-=F.duration,l.partList&&(l.fragmentHint=F)):l.partList&&(Ie(P,F),P.cc=S,l.fragmentHint=P);var Ei=u.length,jr=u[0],Or=u[Ei-1];if((_+=l.skippedSegments*l.targetduration)>0&&Ei&&Or){l.averagetargetduration=_/Ei;var Ti=Or.sn;l.endSN=Ti!=="initSegment"?Ti:0,l.live||(Or.endList=!0),jr&&(l.startCC=jr.cc)}else l.endSN=0,l.startCC=0;return l.fragmentHint&&(_+=l.fragmentHint.duration),l.totalduration=_,l.endCC=S,W>0&&function(Ir,Gr){for(var Qr=Ir[Gr],Dr=Gr;Dr--;){var Jr=Ir[Dr];if(!Jr)return;Jr.programDateTime=Qr.programDateTime-1e3*Jr.duration,Qr=Jr}}(u,W),l},d}();function Ue(d,o){var e,t,i=new ce(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&&L.logger.error("Invalid IV: "+i.IV);var u=a?ae.resolve(a,o):"",c=(s||"1").split("/").map(Number).filter(Number.isFinite);return new Le(n,u,l,c,r)}function H(d,o){["video","audio","text"].forEach(function(e){var t=d.filter(function(n){return function(a,r){var s=Oe[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 ve(d,o,e){var t=o[e];t&&(d[e]=t)}function Ie(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 Fe(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 fe=B(308);function Ce(d,o){var e=d.url;return e!==void 0&&e.indexOf("data:")!==0||(e=o.url),e}let Ve=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(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(g.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(g.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},o.unregisterListeners=function(){var e=this.hls;e.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(g.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(g.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:fe.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:fe.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:fe.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:fe.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 L.logger.trace("[playlist-loader]: playlist request ongoing");L.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),u.abort()}switch(e.type){case fe.PlaylistContextType.MANIFEST:i=l.manifestLoadingMaxRetry,n=l.manifestLoadingTimeOut,a=l.manifestLoadingRetryDelay,r=l.manifestLoadingMaxRetryTimeout;break;case fe.PlaylistContextType.LEVEL:case fe.PlaylistContextType.AUDIO_TRACK:case fe.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===fe.PlaylistContextType.LEVEL&&e.level!==null?s=this.hls.levels[e.level].details:e.type===fe.PlaylistContextType.AUDIO_TRACK&&e.id!==null?s=this.hls.audioTracks[e.id].details:e.type===fe.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=Ce(e,i),l=ae.parseMasterPlaylist(r,s),u=l.levels,c=l.sessionData,v=l.sessionKeys;if(u.length){var m=u.map(function(W){return{id:W.attrs.AUDIO,audioCodec:W.audioCodec}}),_=u.map(function(W){return{id:W.attrs.SUBTITLES,textCodec:W.textCodec}}),S=ae.parseMasterPlaylistMedia(r,s,"AUDIO",m),F=ae.parseMasterPlaylistMedia(r,s,"SUBTITLES",_),P=ae.parseMasterPlaylistMedia(r,s,"CLOSED-CAPTIONS");S.length&&(S.some(function(W){return!W.url})||!u[0].audioCodec||u[0].attrs.AUDIO||(L.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 ce({}),bitrate:0,url:""}))),a.trigger(g.Events.MANIFEST_LOADED,{levels:u,audioTracks:S,subtitles:F,captions:P,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=Ce(e,i),c=(0,R.isFiniteNumber)(r)?r:0,v=(0,R.isFiniteNumber)(s)?s:c,m=function(F){switch(F.type){case fe.PlaylistContextType.AUDIO_TRACK:return fe.PlaylistLevelType.AUDIO;case fe.PlaylistContextType.SUBTITLE_TRACK:return fe.PlaylistLevelType.SUBTITLE;default:return fe.PlaylistLevelType.MAIN}}(i),_=ae.parseLevelPlaylist(e.data,u,v,m,c);if(_.fragments.length){if(l===fe.PlaylistContextType.MANIFEST){var S={attrs:new ce({}),bitrate:0,details:_,name:"",url:u};a.trigger(g.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(g.Events.ERROR,{type:k.ErrorTypes.NETWORK_ERROR,details:k.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(g.Events.ERROR,{type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===fe.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),L.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=k.ErrorDetails.UNKNOWN,r=!1,s=this.getInternalLoader(e);switch(e.type){case fe.PlaylistContextType.MANIFEST:a=i?k.ErrorDetails.MANIFEST_LOAD_TIMEOUT:k.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case fe.PlaylistContextType.LEVEL:a=i?k.ErrorDetails.LEVEL_LOAD_TIMEOUT:k.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case fe.PlaylistContextType.AUDIO_TRACK:a=i?k.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:k.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case fe.PlaylistContextType.SUBTITLE_TRACK:a=i?k.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:k.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1}s&&this.resetInternalLoader(e.type);var l={type:k.ErrorTypes.NETWORK_ERROR,details:a,fatal:r,url:e.url,loader:s,context:e,networkDetails:t};n&&(l.response=n),this.hls.trigger(g.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 fe.PlaylistContextType.MANIFEST:case fe.PlaylistContextType.LEVEL:this.hls.trigger(g.Events.LEVEL_LOADED,{details:c,level:r||0,id:s||0,stats:t,networkDetails:n,deliveryDirectives:v});break;case fe.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(g.Events.AUDIO_TRACK_LOADED,{details:c,id:s||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:v});break;case fe.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(g.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 Xe(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 it(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){L.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 lt(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 Ct(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,F){if(F<S[0].startTime)return 0;var P=S.length-1;if(F>S[P].endTime)return-1;for(var W=0,ue=P;W<=ue;){var _e=Math.floor((ue+W)/2);if(F<S[_e].startTime)ue=_e-1;else{if(!(F>S[_e].startTime&&W<P))return _e;W=_e+1}}return S[W].startTime-F<F-S[ue].startTime?W:ue}(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 Rt=B(181),St=B(856);function wt(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var gt=function(){var d=wt();try{new d(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function dt(d,o){return d.getTime()/1e3-o}let tt=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(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(g.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},o._unregisterListeners=function(){var e=this.hls;e.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(g.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},o.onMediaAttached=function(e,t){this.media=t.media},o.onMediaDetaching=function(){this.id3Track&&(lt(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 Xe(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=wt(),l=0;l<r.length;l++){var u=r[l].type;if((u!==St.MetadataSchema.emsg||n)&&a){var c=Rt.getID3Frames(r[l].data);if(c){var v=r[l].pts,m=v+r[l].duration;m>gt&&(m=gt),m-v<=0&&(m=v+.25);for(var _=0;_<c.length;_++){var S=c[_];if(!Rt.isTimeStampFrame(S)){this.updateId3CueEnds(v);var F=new s(v,m,"");F.value=S,u&&(F.type=u),this.id3Track.addCue(F)}}}}}}}},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===gt&&(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)&&Ct(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(W){return!l.includes(W)}),c=function(W){var ue=u[W];Object.keys(a[ue].cues).forEach(function(_e){r.removeCue(a[ue].cues[_e])}),delete a[ue]},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=wt(),F=function(W){var ue=l[W],_e=s[ue],ge=a[ue],De=(ge==null?void 0:ge.cues)||{},He=(ge==null?void 0:ge.durationKnown)||!1,Je=dt(_e.startDate,_),Ae=gt,Ke=_e.endDate;if(Ke)Ae=dt(Ke,_),He=!0;else if(_e.endOnNext&&!He){var je=l.reduce(function(er,Yt){var nr=s[Yt];return nr.class===_e.class&&nr.id!==Yt&&nr.startDate>_e.startDate&&er.push(nr),er},[]).sort(function(er,Yt){return er.startDate.getTime()-Yt.startDate.getTime()})[0];je&&(Ae=dt(je.startDate,_),He=!0)}for(var pt,Mt=Object.keys(_e.attr),mt=0;mt<Mt.length;mt++){var kt=Mt[mt];if(kt!==j.ID&&kt!==j.CLASS&&kt!==j.START_DATE&&kt!==j.DURATION&&kt!==j.END_DATE&&kt!==j.END_ON_NEXT){var xt=De[kt];if(xt)He&&!ge.durationKnown&&(xt.endTime=Ae);else{var ir=_e.attr[kt];xt=new S(Je,Ae,""),kt!==j.SCTE35_OUT&&kt!==j.SCTE35_IN||(pt=ir,ir=Uint8Array.from(pt.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),xt.value={key:kt,data:ir},xt.type=St.MetadataSchema.dateRange,i.id3Track.addCue(xt),De[kt]=xt}}}a[ue]={cues:De,dateRange:_e,durationKnown:He}},P=0;P<l.length;P++)F(P)}}},d}();function It(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=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(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(g.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(g.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(g.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(g.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(g.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===k.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,L.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}}])&&It(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function Wt(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 Bt,ar=["NONE","TYPE-0","TYPE-1","TYPE-2",null];(function(d){d.No="",d.Yes="YES",d.v2="v2"})(Bt||(Bt={}));var te=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}(),N=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)}}])&&Wt(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 O(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 C(d){var o={};d.forEach(function(e){var t=e.groupId||"";e.id=o[t]=o[t]||0,o[t]++})}function G(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 Q(d,o,e,t,i,n){t-e<=0&&(L.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--)G(S[v],S[v-1]);for(v=_;v<S.length-1;v++)G(S[v],S[v+1]);return d.fragmentHint&&G(S[S.length-1],d.fragmentHint),d.PTSKnown=d.alignedSliding=!0,c}function Z(d,o){var e=o.startSN+o.skippedSegments-d.startSN,t=d.fragments;e<0||e>=t.length||Te(o,t[e].start)}function Te(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 Re=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=L.logger.log.bind(L.logger,t+":"),this.warn=L.logger.warn.bind(L.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!==k.ErrorTypes.NETWORK_ERROR&&t.type!==k.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){L.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 te(s,l>=0?l:void 0,Bt.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(Ke,je){for(var pt=null,Mt=Ke.fragments,mt=Mt.length-1;mt>=0;mt--){var kt=Mt[mt].initSegment;if(kt){pt=kt;break}}Ke.fragmentHint&&delete Ke.fragmentHint.endPTS;var xt,ir,er,Yt,nr,_r=0;if(function(ct,yt,Ei){for(var jr=yt.skippedSegments,Or=Math.max(ct.startSN,yt.startSN)-yt.startSN,Ti=(ct.fragmentHint?1:0)+(jr?yt.endSN:Math.min(ct.endSN,yt.endSN))-yt.startSN,Ir=yt.startSN-ct.startSN,Gr=yt.fragmentHint?yt.fragments.concat(yt.fragmentHint):yt.fragments,Qr=ct.fragmentHint?ct.fragments.concat(ct.fragmentHint):ct.fragments,Dr=Or;Dr<=Ti;Dr++){var Jr=Qr[Ir+Dr],yn=Gr[Dr];jr&&!yn&&Dr<jr&&(yn=yt.fragments[Dr]=Jr),Jr&&yn&&Ei(Jr,yn)}}(Ke,je,function(ct,yt){ct.relurl&&(_r=ct.cc-yt.cc),(0,R.isFiniteNumber)(ct.startPTS)&&(0,R.isFiniteNumber)(ct.endPTS)&&(yt.start=yt.startPTS=ct.startPTS,yt.startDTS=ct.startDTS,yt.appendedPTS=ct.appendedPTS,yt.maxStartPTS=ct.maxStartPTS,yt.endPTS=ct.endPTS,yt.endDTS=ct.endDTS,yt.minEndPTS=ct.minEndPTS,yt.duration=ct.endPTS-ct.startPTS,yt.duration&&(xt=yt),je.PTSKnown=je.alignedSliding=!0),yt.elementaryStreams=ct.elementaryStreams,yt.loader=ct.loader,yt.stats=ct.stats,yt.urlId=ct.urlId,ct.initSegment&&(yt.initSegment=ct.initSegment,pt=ct.initSegment)}),pt&&(je.fragmentHint?je.fragments.concat(je.fragmentHint):je.fragments).forEach(function(ct){var yt;ct.initSegment&&ct.initSegment.relurl!==((yt=pt)===null||yt===void 0?void 0:yt.relurl)||(ct.initSegment=pt)}),je.skippedSegments)if(je.deltaUpdateFailed=je.fragments.some(function(ct){return!ct}),je.deltaUpdateFailed){L.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var Jn=je.skippedSegments;Jn--;)je.fragments.shift();je.startSN=je.fragments[0].sn,je.startCC=je.fragments[0].cc}else je.canSkipDateRanges&&(je.dateRanges=(ir=Ke.dateRanges,er=je.dateRanges,Yt=je.recentlyRemovedDateranges,nr=T({},ir),Yt&&Yt.forEach(function(ct){delete nr[ct]}),Object.keys(er).forEach(function(ct){var yt=new ye(er[ct].attr,nr[ct]);yt.isValid?nr[ct]=yt:L.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(er[ct].attr)+'"')}),nr));var Pr=je.fragments;if(_r){L.logger.warn("discontinuity sliding from playlist, take drift into account");for(var Bi=0;Bi<Pr.length;Bi++)Pr[Bi].cc+=_r}je.skippedSegments&&(je.startCC=je.fragments[0].cc),function(ct,yt,Ei){if(ct&&yt)for(var jr=0,Or=0,Ti=ct.length;Or<=Ti;Or++){var Ir=ct[Or],Gr=yt[Or+jr];Ir&&Gr&&Ir.index===Gr.index&&Ir.fragment.sn===Gr.fragment.sn?(Qr=Ir,(Dr=Gr).elementaryStreams=Qr.elementaryStreams,Dr.stats=Qr.stats):jr--}var Qr,Dr}(Ke.partList,je.partList),xt?Q(je,xt,xt.startPTS,xt.endPTS,xt.startDTS,xt.endDTS):Z(Ke,je),Pr.length&&(je.totalduration=je.edge-Pr[0].start),je.driftStartTime=Ke.driftStartTime,je.driftStart=Ke.driftStart;var ji=je.advancedDateTime;if(je.advanced&&ji){var Gi=je.edge;je.driftStart||(je.driftStartTime=ji,je.driftStart=Gi),je.driftEndTime=ji,je.driftEnd=Gi}else je.driftEndTime=Ke.driftEndTime,je.driftEnd=Ke.driftEnd,je.advancedDateTime=Ke.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,F=a.lastPartIndex,P=_===S;F!==-1?(c=P?S+1:_,v=P?m?0:F:F+1):c=S+1;var W=a.age,ue=W+a.ageHeader,_e=Math.min(ue-a.partTarget,1.5*a.targetduration);if(_e>0){if(i&&_e>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+_e+" with playlist age: "+a.age),_e=0;else{var ge=Math.floor(_e/a.targetduration);c+=ge,v!==void 0&&(v+=Math.round(_e%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+W.toFixed(2)+"s goal: "+_e+" skip sn "+ge+" to part "+v)}a.tuneInGoal=_e}if(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,v),m||!P)return void this.loadPlaylist(u)}else u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,v);var De=this.hls.mainForwardBufferInfo,He=De?De.end-De.len:0,Je=function(Ke,je){je===void 0&&(je=1/0);var pt=1e3*Ke.targetduration;if(Ke.updated){var Mt=Ke.fragments;if(Mt.length&&4*pt>je){var mt=1e3*Mt[Mt.length-1].duration;mt<pt&&(pt=mt)}}else pt/=2;return Math.round(pt)}(a,1e3*(a.edge-He));a.updated?s>this.requestScheduled+Je&&(this.requestScheduled=r.loading.start):this.requestScheduled=-1,c!==void 0&&a.canBlockReload?this.requestScheduled=r.loading.first+Je-(1e3*a.partTarget||1e3):this.requestScheduled=(this.requestScheduled===-1?s:this.requestScheduled)+Je;var Ae=this.requestScheduled-s;Ae=Math.max(0,Ae),this.log("reload live playlist "+e+" in "+Math.round(Ae)+" ms"),this.timer=self.setTimeout(function(){return n.loadPlaylist(u)},Ae)}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?Bt.v2:Bt.Yes:Bt.No}(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=Bt.No),new te(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 Pe(){return Pe=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},Pe.apply(this,arguments)}function Be(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 We(d,o){return We=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},We(d,o)}var Ge,$e=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),ht=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,We(o,e);var i,n,a=t.prototype;return a._registerListeners=function(){var r=this.hls;r.on(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(g.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(g.Events.FRAG_LOADED,this.onFragLoaded,this),r.on(g.Events.ERROR,this.onError,this)},a._unregisterListeners=function(){var r=this.hls;r.off(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this),r.off(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(g.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(g.Events.FRAG_LOADED,this.onFragLoaded,this),r.off(g.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,F=!1,P=!1;if(s.levels.forEach(function(ge){var De=ge.attrs;S=S||!(!ge.width||!ge.height),F=F||!!ge.videoCodec,P=P||!!ge.audioCodec,$e&&ge.audioCodec&&ge.audioCodec.indexOf("mp4a.40.34")!==-1&&(ge.audioCodec=void 0);var He=ge.bitrate+"-"+ge.attrs.RESOLUTION+"-"+ge.attrs.CODECS;(u=_[He])?u.url.push(ge.url):(u=new N(ge),_[He]=u,c.push(u)),De&&(De.AUDIO&&O(u,"audio",De.AUDIO),De.SUBTITLES&&O(u,"text",De.SUBTITLES))}),(S||F)&&P&&(c=c.filter(function(ge){var De=ge.videoCodec,He=ge.width,Je=ge.height;return!!De||!(!He||!Je)})),c=c.filter(function(ge){var De=ge.audioCodec,He=ge.videoCodec;return(!De||xe(De,"audio"))&&(!He||xe(He,"video"))}),s.audioTracks&&C(v=s.audioTracks.filter(function(ge){return!ge.audioCodec||xe(ge.audioCodec,"audio")})),s.subtitles&&C(m=s.subtitles),c.length>0){l=c[0].bitrate,c.sort(function(ge,De){return ge.attrs["HDCP-LEVEL"]!==De.attrs["HDCP-LEVEL"]?(ge.attrs["HDCP-LEVEL"]||"")>(De.attrs["HDCP-LEVEL"]||"")?1:-1:ge.bitrate!==De.bitrate?ge.bitrate-De.bitrate:ge.attrs.SCORE!==De.attrs.SCORE?ge.attrs.decimalFloatingPoint("SCORE")-De.attrs.decimalFloatingPoint("SCORE"):S&&ge.height!==De.height?ge.height-De.height:0}),this._levels=c;for(var W=0;W<c.length;W++)if(c[W].bitrate===l){this._firstLevel=W,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+l);break}var ue=P&&!F,_e={levels:c,audioTracks:v,subtitleTracks:m,sessionData:s.sessionData,sessionKeys:s.sessionKeys,firstLevel:this._firstLevel,stats:s.stats,audio:P,video:F,altAudio:!ue&&v.some(function(ge){return!!ge.url})};this.hls.trigger(g.Events.MANIFEST_PARSED,_e),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.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===fe.PlaylistContextType.AUDIO_TRACK&&v.audioGroupIds&&c.groupId===v.audioGroupIds[v.urlId]||c.type===fe.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 k.ErrorDetails.FRAG_LOAD_ERROR:case k.ErrorDetails.FRAG_LOAD_TIMEOUT:case k.ErrorDetails.KEY_LOAD_ERROR:case k.ErrorDetails.KEY_LOAD_TIMEOUT:if(s.frag){var F=s.frag.type===fe.PlaylistLevelType.MAIN?s.frag.level:this.currentLevelIndex,P=this._levels[F];P?(P.fragmentError++,P.fragmentError>this.hls.config.fragLoadingMaxRetry&&(m=F)):m=F}break;case k.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var W=v.attrs["HDCP-LEVEL"];W&&(this.hls.maxHdcpLevel=ar[ar.indexOf(W)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'));case k.ErrorDetails.FRAG_PARSING_ERROR:case k.ErrorDetails.KEY_SYSTEM_NO_SESSION:m=((l=s.frag)===null||l===void 0?void 0:l.type)===fe.PlaylistLevelType.MAIN?s.frag.level:this.currentLevelIndex,s.levelRetry=!1;break;case k.ErrorDetails.LEVEL_LOAD_ERROR:case k.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(S=!1),m=c.level),_=!0;break;case k.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,F=S.length;F--;){var P=(F+this.currentLevelIndex)%S.length;if(P!==this.currentLevelIndex&&S[P].loadError===0){_=P;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===fe.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(g.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(g.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(g.Events.ERROR,{type:k.ErrorTypes.OTHER_ERROR,details:k.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 _=Pe({},m,{level:r,maxBitrate:m.maxBitrate,uri:m.uri,urlId:m.urlId});delete _._urlId,this.hls.trigger(g.Events.LEVEL_SWITCHING,_);var S=m.details;if(!S||S.live){var F=this.switchParams(m.uri,v==null?void 0:v.details);this.loadPlaylist(F)}}}},{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)}}])&&Be(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Re);(function(d){d.NOT_LOADED="NOT_LOADED",d.APPENDING="APPENDING",d.PARTIAL="PARTIAL",d.OK="OK"})(Ge||(Ge={}));var Dt=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(g.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(g.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(g.Events.FRAG_LOADED,this.onFragLoaded,this)},o._unregisterListeners=function(){var e=this.hls;e.off(g.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(g.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(g.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===fe.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=Pt(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=Pt(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&&ze(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||ze(t))},o.getState=function(e){var t=Pt(e),i=this.fragments[t];return i?i.buffered?ze(i)?Ge.PARTIAL:Ge.OK:Ge.APPENDING:Ge.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=Pt(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===fe.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===fe.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=Pt(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=Pt(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 ze(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 Pt(d){return d.type+"_"+d.level+"_"+d.urlId+"_"+d.sn}function tr(d){var o=typeof Map=="function"?new Map:void 0;return tr=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 jt(e,arguments,rt(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ht(i,e)},tr(d)}function jt(d,o,e){return jt=Ft()?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&&Ht(r,n.prototype),r},jt.apply(null,arguments)}function Ft(){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 Ht(d,o){return Ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ht(d,o)}function rt(d){return rt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},rt(d)}var lr=Math.pow(2,17),Ar=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 Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.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=Kt(e),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:e.sn==="initSegment"?1/0:lr};e.stats=c.stats,c.load(v,m,{onSuccess:function(_,S,F,P){i.resetLoader(e,c);var W=_.data;F.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(W.slice(0,16)),W=W.slice(16)),l({frag:e,part:null,payload:W,networkDetails:P})},onError:function(_,S,F){i.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:_,networkDetails:F}))},onAbort:function(_,S,F){i.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:F}))},onTimeout:function(_,S,F){i.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:F}))},onProgress:function(_,S,F,P){t&&t({frag:e,part:null,payload:F,networkDetails:P})}})})},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=Kt(e,t),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:lr};t.stats=c.stats,c.load(v,m,{onSuccess:function(_,S,F,P){n.resetLoader(e,c),n.updateStatsFromPart(e,t);var W={frag:e,part:t,payload:_.data,networkDetails:P};i(W),l(W)},onError:function(_,S,F){n.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:_,networkDetails:F}))},onAbort:function(_,S,F){e.stats.aborted=t.stats.aborted,n.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:F}))},onTimeout:function(_,S,F){n.resetLoader(e,c),u(new Jt({type:k.ErrorTypes.NETWORK_ERROR,details:k.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:F}))}})})},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 Kt(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 Jt=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,Ht(o,e),t}(tr(Error)),pr=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=k.ErrorDetails.KEY_LOAD_ERROR),new Jt({type:k.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,k.ErrorDetails.KEY_LOAD_ERROR,null,r))}var s=a.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,k.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,k.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 F=_.frag,P=_.keyInfo,W=_.url;if(!F.decryptdata||P!==i.keyUriToKeyInfo[W])return s(i.createKeyLoadError(F,k.ErrorDetails.KEY_LOAD_ERROR,S,"after key load, decryptdata unset or changed"));P.decryptdata.key=F.decryptdata.key=new Uint8Array(v.data),F.keyLoader=null,P.loader=null,r({frag:F,keyInfo:P})},onError:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,k.ErrorDetails.KEY_LOAD_ERROR,_))},onTimeout:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,k.ErrorDetails.KEY_LOAD_TIMEOUT,_))},onAbort:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,k.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}(),Cr=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}(),vr={length:0,start:function(){return 0},end:function(){return 0}},Gt=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,F){return S.start-F.start||F.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 L.logger.log("failed to get media.buffered",e),vr}},d}(),Di=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 nn(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 kr(d,o){if(d){var e=d.start+o;d.start=d.startPTS=e,d.endPTS=e+d.duration}}function li(d,o){for(var e=o.fragments,t=0,i=e.length;t<i;t++)kr(e[t],d);o.fragmentHint&&kr(o.fragmentHint,d),o.alignedSliding=!0}function an(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=nn(e,i.cc)||e[Math.round(e.length/2)-1],a=i.programDateTime,r=n.programDateTime;a!==null&&r!==null&&li((r-a)/1e3-(n.start-i.start),d)}}}let sn=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 ui(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&&di(e,t,i)===0)return i;var n=sn(o,di.bind(null,e,t));return!n||n===d&&i?i:n}function di(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 Kr(d,o,e){var t=1e3*Math.min(o,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>d}var Zr=B(21);let wn=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 on(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 Hr(d,o){return Hr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Hr(d,o)}var br="STOPPED",At="IDLE",ln="KEY_LOADING",qr="FRAG_LOADING",Nr="FRAG_LOADING_WAITING_RETRY",ci="WAITING_TRACK",wr="PARSING",Vr="PARSED",ei="ENDED",Lr="ERROR",Ur="WAITING_INIT_PTS",Yr="WAITING_LEVEL",hi=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=br,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=L.logger.log.bind(L.logger,u+":"),c.warn=L.logger.warn.bind(L.logger,u+":"),c.hls=r,c.fragmentLoader=new Ar(r.config),c.keyLoader=l,c.fragmentTracker=s,c.config=r.config,c.decrypter=new Zr.default(r.config),r.on(g.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,Hr(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=br},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 Gt.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===br&&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=Gt.bufferInfo(u||l,v,r.maxBufferHole);if(this.log("media seeking to "+((0,R.isFiniteNumber)(v)?v.toFixed(3):v)+", state: "+c),this.state===ei)this.resetLoadingState();else if(s){var _=r.maxFragLookUpTolerance,S=s.start-_,F=s.start+s.duration+_;if(!m.len||F<m.start||S>m.end){var P=v>F;(v<S||P)&&(P&&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=br,this.hls.off(g.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===qr||!u.fragCurrent&&v===wr)&&(u.fragmentTracker.removeFragment(r),u.state=At):("payload"in c&&(u.log("Loaded fragment "+r.sn+" of level "+r.level),u.hls.trigger(g.Events.FRAG_LOADED,c)),u._handleFragmentLoadComplete(c))}}).catch(function(c){u.state!==br&&u.state!==Lr&&(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(g.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 F=self.performance.now();return c.trigger(g.Events.FRAG_DECRYPTED,{frag:r,payload:S,stats:{tstart:_,tdecrypt:F}}),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=At,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(g.Events.FRAG_BUFFERED,{stats:_,frag:c,part:null,id:r.type}),l.tick()}).catch(function(u){l.state!==br&&l.state!==Lr&&(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?wn(Gt.getBuffered(c)):"(detached)")),this.state=At,c&&(!this.loadedmetadata&&r.type==fe.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 Di(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=ln,this.fragCurrent=r,m=this.keyLoader.load(r).then(function(W){if(!v.fragContextChanged(W.frag))return v.hls.trigger(g.Events.KEY_LOADED,W),W}),this.hls.trigger(g.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 F=_[S];return this.log("Loading part sn: "+r.sn+" p: "+F.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=F.start+F.duration,this.state=qr,this.hls.trigger(g.Events.FRAG_LOADING,{frag:r,part:_[S],targetBufferTime:l}),this.throwIfFragContextChanged("FRAG_LOADING parts"),m?m.then(function(W){return!W||v.fragContextChanged(W.frag)?null:v.doFragPartsLoad(r,_,S,u)}).catch(function(W){return v.handleFragLoadError(W)}):this.doFragPartsLoad(r,_,S,u).catch(function(W){return v.handleFragLoadError(W)})}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=qr,this.hls.trigger(g.Events.FRAG_LOADING,{frag:r,targetBufferTime:l}),this.throwIfFragContextChanged("FRAG_LOADING");var P=this.config.progressive;return P&&m?m.then(function(W){return!W||v.fragContextChanged(W==null?void 0:W.frag)?null:v.fragmentLoader.load(r,u)}).catch(function(W){return v.handleFragLoadError(W)}):Promise.all([this.fragmentLoader.load(r,P?u:void 0),m]).then(function(W){var ue=W[0];return!P&&ue&&u&&u(ue),ue}).catch(function(W){return v.handleFragLoadError(W)})},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(F){var P=s[F];c.fragmentLoader.loadPart(r,P,u).then(function(W){_[P.index]=W;var ue=W.part;c.hls.trigger(g.Events.FRAG_LOADED,W);var _e=s[F+1];if(!_e||_e.fragment!==r)return v({frag:r,part:ue,partsLoaded:_});S(F+1)}).catch(m)})(l)})},a.handleFragLoadError=function(r){if("data"in r){var s=r.data;r.data&&s.details===k.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(s.frag,s.part):this.hls.trigger(g.Events.ERROR,s)}else this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.OTHER_ERROR,details:k.ErrorDetails.INTERNAL_EXCEPTION,err:r,fatal:!0});return null},a._handleTransmuxerFlush=function(r){var s=this.getCurrentContext(r);if(s&&this.state===wr){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===br||this.state===Lr||(this.state=At)},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,F,P){if(!S||!S.details)return null;var W=S.details.partList;if(W)for(var ue=W.length;ue--;){var _e=W[ue];if(_e.index===P&&_e.fragment.sn===F)return _e}return null}(v,u,c):null,_=m?m.fragment:function(S,F,P){if(!S||!S.details)return null;var W=S.details,ue=W.fragments[F-W.startSN];return ue||((ue=W.fragmentHint)&&ue.sn===F?ue:F<W.startSN&&P&&P.sn===F?P:null)}(v,u,this.fragCurrent);return _?{frag:_,part:m,level:v}:null},a.bufferFragmentData=function(r,s,l,u){if(r&&this.state===wr){var c=r.data1,v=r.data2,m=c;if(c&&v&&(m=(0,z.appendUint8Array)(c,v)),m&&m.length){var _={type:r.type,frag:s,part:l,chunkMeta:u,parent:s.type,data:m};this.hls.trigger(g.Events.BUFFER_APPENDING,_),r.dropped&&r.independent&&!l&&this.flushBufferGap(s)}}},a.flushBufferGap=function(r){var s=this.media;if(s)if(Gt.isBuffered(s,s.currentTime)){var l=s.currentTime,u=Gt.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=Gt.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 Gt.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 F=S.loaded;F?u=-1:(c||S.independent||v)&&S.fragment===s&&(u=m),c=F}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,F){if(S===null||!Array.isArray(_)||!_.length||!(0,R.isFiniteNumber)(S)||S<(_[0].programDateTime||0)||S>=(_[_.length-1].endProgramDateTime||0))return null;F=F||0;for(var P=0;P<_.length;++P){var W=_[P];if(Kr(S,F,W))return W}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 sn(_,function(F){return F.cc<S?1:F.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,F=c.maxFragLookUpTolerance,P=!!(c.lowLatencyMode&&l.partList&&S);if(P&&S&&!this.bitrateTest&&(m=m.concat(S),_=S.sn),u=r<s?ui(v,m,r,r>s-F?0:F):m[m.length-1]){var W=u.sn-l.startSN;if(this.fragmentTracker.getState(u)===Ge.OK&&(v=u),v&&u.sn===v.sn&&!P&&v&&u.level===v.level){var ue=m[W+1];u.sn<_&&this.fragmentTracker.getState(ue)!==Ge.OK?(this.log("SN "+u.sn+" just loaded, load next one: "+ue.sn),u=ue):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,F=r.alignedSliding&&(0,R.isFiniteNumber)(_);if(S||!F&&!_){(function(W,ue,_e){ue&&(function(ge,De,He){if(function(Ae,Ke,je){return!(!Ke.details||!(je.endCC>je.startCC||Ae&&Ae.cc<je.startCC))}(ge,He,De)){var Je=function(Ae,Ke,je){je===void 0&&(je=0);var pt=Ae.fragments,Mt=Ke.fragments;if(Mt.length&&pt.length){var mt=nn(pt,Mt[0].cc);if(mt&&(!mt||mt.startPTS))return mt;L.logger.log("No frag in previous level to align on")}else L.logger.log("No fragments to align")}(He.details,De);Je&&(0,R.isFiniteNumber)(Je.start)&&(L.logger.log("Adjusting PTS using last level due to CC increase within current level "+De.url),li(Je.start,De))}}(W,_e,ue),!_e.alignedSliding&&ue.details&&function(ge,De){if(De.fragments.length&&ge.hasProgramDateTime&&De.hasProgramDateTime){var He=De.fragments[0].programDateTime,Je=ge.fragments[0].programDateTime,Ae=(Je-He)/1e3+De.fragments[0].start;Ae&&(0,R.isFiniteNumber)(Ae)&&(L.logger.log("Adjusting PTS using programDateTime delta "+(Je-He)+"ms, sliding:"+Ae.toFixed(3)+" "+ge.url+" "),li(Ae,ge))}}(_e,ue.details),_e.alignedSliding||!ue.details||_e.skippedSegments||Z(ue.details,_e))})(c,v,r);var P=r.fragments[0].start;return this.log("Live playlist sliding: "+P.toFixed(2)+" start-sn: "+(s?s.startSN:"na")+"->"+r.startSN+" prev-sn: "+(c?c.sn:"na")+" fragments: "+m),P}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===Nr)||(this.state=At)},a.onFragmentOrKeyLoadError=function(r,s){if(s.fatal)return this.stopLoad(),void(this.state=Lr);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=Nr}else s.levelRetry?(r===fe.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=At):(L.logger.error(s.details+" reaches max retry, redispatch as fatal ..."),s.fatal=!0,this.hls.stopLoad(),this.state=Lr)},a.afterBufferFlushed=function(r,s,l){if(r){var u=Gt.getBuffered(r);this.fragmentTracker.detectEvictedFragments(s,u,l),this.state===ei&&this.resetLoadingState()}},a.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=At},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 F=S.endPTS-S.startPTS;if(F<=0)return c.warn("Could not parse fragment "+r.sn+" "+_+" duration reliably ("+F+")"),m||!1;var P=u?0:Q(v,r,S.startPTS,S.endPTS,S.startDTS,S.endDTS);return c.hls.trigger(g.Events.LEVEL_PTS_UPDATED,{details:v,level:l,drift:P,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=Vr,this.hls.trigger(g.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))}}])&&on(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Cr);function fi(){return self.MediaSource||self.WebKitMediaSource}function vi(){return self.SourceBuffer||self.WebKitSourceBuffer}var Li=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"),un="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function $t(d){return(d+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function pi(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)"+$t(r)+un,"g");a=s.exec(i);)a[3]!=="dll-reference"&&t[e].push(a[3]);for(s=new RegExp("\\("+$t(r)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)'+un,"g");a=s.exec(i);)d[a[2]]||(t[e].push(a[1]),d[a[2]]=B(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 Dn(d){return Object.keys(d).reduce(function(o,e){return o||d[e].length>0},!1)}function dn(d,o,e,t){var i=d[t].map(function(n){return'"'+n+'": '+o[t][n].toString().replace(/^"[^"]+"/,"function")}).join(",");return Li[0]+"{"+i+"}"+Li[1]+'"'+e+'"'+Li[2]}var Br=B(544),Ri=B(729),ti=B.n(Ri),ri=fi()||{isTypeSupported:function(){return!1}},Ii=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 Ri.EventEmitter,this.observer.on(g.Events.FRAG_DECRYPTED,s),this.observer.on(g.Events.ERROR,s);var l={mp4:ri.isTypeSupported("video/mp4"),mpeg:ri.isTypeSupported("audio/mpeg"),mp3:ri.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"){var c;L.logger.log("demuxing in webworker");try{c=this.worker=function(v,m){m=m||{};var _={main:B.m},S=m.all?{main:Object.keys(_.main)}:function(_e,ge){for(var De={main:[ge]},He={main:[]},Je={main:{}};Dn(De);)for(var Ae=Object.keys(De),Ke=0;Ke<Ae.length;Ke++){var je=Ae[Ke],pt=De[je].pop();if(Je[je]=Je[je]||{},!Je[je][pt]&&_e[je][pt]){Je[je][pt]=!0,He[je]=He[je]||[],He[je].push(pt);for(var Mt=pi(_e,_e[je][pt],je),mt=Object.keys(Mt),kt=0;kt<mt.length;kt++)De[mt[kt]]=De[mt[kt]]||[],De[mt[kt]]=De[mt[kt]].concat(Mt[mt[kt]])}}return He}(_,v),F="";Object.keys(S).filter(function(_e){return _e!=="main"}).forEach(function(_e){for(var ge=0;S[_e][ge];)ge++;S[_e].push(ge),_[_e][ge]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",F=F+"var "+_e+" = ("+dn(S,_,ge,modules)+`)();
|
|
9
|
+
`}),F=F+"new (("+dn(S,_,v,"main")+")())(self);";var P=new window.Blob([F],{type:"text/javascript"}),W=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(P),ue=new window.Worker(W);return ue.objectURL=W,ue}(182),this.onwmsg=this.onWorkerMessage.bind(this),c.addEventListener("message",this.onwmsg),c.onerror=function(v){a.useWorker=!1,L.logger.warn("Exception in webworker, fallback to inline"),a.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.OTHER_ERROR,details:k.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(v.message+" ("+v.filename+":"+v.lineno+")")})},c.postMessage({cmd:"init",typeSupported:l,vendor:u,id:t,config:JSON.stringify(r)})}catch(v){L.logger.warn("Error in worker:",v),L.logger.error("Error while initializing DemuxerWorker, fallback to inline"),c&&self.URL.revokeObjectURL(c.objectURL),this.transmuxer=new Br.default(this.observer,l,r,u,t),this.worker=null}}else this.transmuxer=new Br.default(this.observer,l,r,u,t)}var o=d.prototype;return o.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var i=this.observer;i&&i.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},o.push=function(e,t,i,n,a,r,s,l,u,c){var v,m,_=this;u.transmuxing.start=self.performance.now();var S=this.transmuxer,F=this.worker,P=r?r.start:a.start,W=a.decryptdata,ue=this.frag,_e=!(ue&&a.cc===ue.cc),ge=!(ue&&u.level===ue.level),De=ue?u.sn-ue.sn:-1,He=this.part?u.part-this.part.index:-1,Je=De===0&&u.id>1&&u.id===(ue==null?void 0:ue.stats.chunkCount),Ae=!ge&&(De===1||De===0&&(He===1||Je&&He<=0)),Ke=self.performance.now();(ge||De||a.stats.parsing.start===0)&&(a.stats.parsing.start=Ke),!r||!He&&Ae||(r.stats.parsing.start=Ke);var je=!(ue&&((v=a.initSegment)===null||v===void 0?void 0:v.url)===((m=ue.initSegment)===null||m===void 0?void 0:m.url)),pt=new Br.TransmuxState(_e,Ae,l,ge,P,je);if(!Ae||_e||je){L.logger.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
10
|
+
discontinuity: `+_e+`
|
|
11
|
+
trackSwitch: `+ge+`
|
|
12
|
+
contiguous: `+Ae+`
|
|
13
|
+
accurateTimeOffset: `+l+`
|
|
14
|
+
timeOffset: `+P+`
|
|
15
|
+
initSegmentChange: `+je);var Mt=new Br.TransmuxConfig(i,n,t,s,c);this.configureTransmuxer(Mt)}if(this.frag=a,this.part=r,F)F.postMessage({cmd:"demux",data:e,decryptdata:W,chunkMeta:u,state:pt},e instanceof ArrayBuffer?[e]:[]);else if(S){var mt=S.push(e,W,u,pt);(0,Br.isPromise)(mt)?(S.async=!0,mt.then(function(kt){_.handleTransmuxComplete(kt)}).catch(function(kt){_.transmuxerError(kt,u,"transmuxer-interface push error")})):(S.async=!1,this.handleTransmuxComplete(mt))}},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,Br.isPromise)(a)||i.async?((0,Br.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(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.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":L.logger[t.data.logType]&&L.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}(),cn=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)&&Gt.getBuffered(n).length){var c=Gt.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 F,P=Math.max(m,c.start||0)-r,W=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,ue=!(W==null||(F=W.details)===null||F===void 0)&&F.live?2*W.details.targetduration:2;if(P>0&&P<=ue)return void this._trySkipBufferHole(null)}var _e=self.performance.now();if(a!==null){var ge=_e-a;if(s||!(ge>=250)||(this._reportStall(c),this.media)){var De=Gt.bufferInfo(n,r,i.maxBufferHole);this._tryFixBufferStall(De,ge)}}else this.stalled=_e}}}else if(this.moved=!0,a!==null){if(this.stallReported){var He=self.performance.now()-a;L.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&&(L.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,L.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(e)+")"),t.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.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=Gt.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 L.logger.warn("skipping hole, adjusting currentTime from "+a+" to "+c),this.moved=!0,this.stalled=null,n.currentTime=c,e&&i.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.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;L.logger.warn("Nudging 'currentTime' from "+a+" to "+r),i.currentTime=r,t.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else L.logger.error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},d}();function Wr(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 Ci(d,o){return Ci=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ci(d,o)}var Ln=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,Ci(o,e);var i,n,a=t.prototype;return a._registerListeners=function(){var r=this.hls;r.on(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(g.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(g.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(g.Events.ERROR,this.onError,this),r.on(g.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(g.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(g.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(g.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(g.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(g.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var r=this.hls;r.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(g.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(g.Events.ERROR,this.onError,this),r.off(g.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(g.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(g.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(g.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(g.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(g.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=At,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=br},a.stopLoad=function(){this._forceStartLoad=!1,d.prototype.stopLoad.call(this)},a.doTick=function(){switch(this.state){case At:this.doTickIdle();break;case Yr: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=At;break}break;case Nr: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=At)}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 F={};return this.altAudio&&(F.type="video"),this.hls.trigger(g.Events.BUFFER_EOS,F),void(this.state=ei)}this.level=r.nextLoadLevel=v;var P=m.details;if(!P||this.state===Yr||P.live&&this.levelLastLoaded!==v)return this.level=v,void(this.state=Yr);if(!(_.len>=this.getMaxBufferLength(m.maxBitrate))){this.backtrackFragment&&this.backtrackFragment.start>_.end&&(this.backtrackFragment=null);var W=this.backtrackFragment?this.backtrackFragment.start:_.end,ue=this.getNextFragment(W,P);if(this.couldBacktrack&&!this.fragPrevious&&ue&&ue.sn!=="initSegment"&&this.fragmentTracker.getState(ue)!==Ge.OK){var _e,ge=((_e=this.backtrackFragment)!=null?_e:ue).sn-P.startSN,De=P.fragments[ge-1];De&&ue.cc===De.cc&&(ue=De,this.fragmentTracker.removeFragment(De))}else this.backtrackFragment&&_.len&&(this.backtrackFragment=null);if(ue&&this.fragmentTracker.getState(ue)===Ge.OK&&this.nextLoadPosition>W){var He=this.audioOnly&&!this.altAudio?J.ElementaryStreamTypes.AUDIO:J.ElementaryStreamTypes.VIDEO,Je=(He===J.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;Je&&this.afterBufferFlushed(Je,He,fe.PlaylistLevelType.MAIN),ue=this.getNextFragment(this.nextLoadPosition,P)}ue&&(!ue.initSegment||ue.initSegment.data||this.bitrateTest||(ue=ue.initSegment),this.loadFragment(ue,P,W))}}}},a.loadFragment=function(r,s,l){var u,c=this.fragmentTracker.getState(r);this.fragCurrent=r,c===Ge.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===Ge.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,fe.PlaylistLevelType.MAIN);return s&&"fragment"in s?s.fragment:s},a.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,fe.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,F=_.duration,P=Math.max(m.end,S+Math.min(Math.max(F-this.config.maxFragLookUpTolerance,.5*F),.75*F));this.flushMainBuffer(P,Number.POSITIVE_INFINITY)}}}},a.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r&&r.abortRequests(),this.state){case ln:case qr:case Nr:case wr:case Vr:this.state=At}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 cn(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(g.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=vi())==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===At){var u=l[s.level];(!u.details||u.details.live&&this.levelLastLoaded!==s.level||this.waitForCdnTuneIn(u.details))&&(this.state=Yr)}},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!==qr&&this.state!==Nr||_.level!==s.level&&_.loader&&(this.state=At,this.backtrackFragment=null,_.abortRequests());var S=u[c],F=0;if(v.live||(l=S.details)!==null&&l!==void 0&&l.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;F=this.alignPlaylists(v,S.details)}if(S.details=v,this.levelLastLoaded=c,this.hls.trigger(g.Events.LEVEL_UPDATED,{details:v,level:c}),this.state===Yr){if(this.waitForCdnTuneIn(v))return;this.state=At}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,F),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,F=_.PTSKnown||!_.live,P=(s=l.initSegment)===null||s===void 0?void 0:s.data,W=this._getAudioCodec(m),ue=this.transmuxer=this.transmuxer||new Ii(this.hls,fe.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),_e=u?u.index:-1,ge=_e!==-1,De=new Di(l.level,l.sn,l.stats.chunkCount,c.byteLength,_e,ge),He=this.initPTS[l.cc];ue.push(c,P,W,S,l,u,_.totalduration,F,De,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(g.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),m.trigger(g.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===fe.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===Vr&&(this.state=At));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!==k.ErrorTypes.KEY_SYSTEM_ERROR)switch(s.details){case k.ErrorDetails.FRAG_LOAD_ERROR:case k.ErrorDetails.FRAG_LOAD_TIMEOUT:case k.ErrorDetails.FRAG_PARSING_ERROR:case k.ErrorDetails.KEY_LOAD_ERROR:case k.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(fe.PlaylistLevelType.MAIN,s);break;case k.ErrorDetails.LEVEL_LOAD_ERROR:case k.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==Lr&&(s.fatal?(this.warn(""+s.details),this.state=Lr):s.levelRetry||this.state!==Yr||(this.state=At));break;case k.ErrorDetails.BUFFER_FULL_ERROR:if(s.parent==="main"&&(this.state===wr||this.state===Vr)){var l=!0,u=this.getFwdBufferInfo(this.media,fe.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(fe.PlaylistLevelType.MAIN,s)},a.checkBuffer=function(){var r=this.media,s=this.gapController;if(r&&s&&r.readyState){if(this.loadedmetadata||!Gt.getBuffered(r).length){var l=this.state!==At?this.fragCurrent:null;s.poll(this.lastCurrentTime,l)}this.lastCurrentTime=r.currentTime}},a.onFragLoadEmergencyAborted=function(){this.state=At,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},a.onBufferFlushed=function(r,s){var l=s.type;if(l!==J.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var u=(l===J.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(u,l,fe.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=Gt.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=At,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(g.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,F=m.level,P=c.video,W=c.text,ue=c.id3,_e=c.initSegment,ge=F.details,De=this.altAudio?void 0:c.audio;if(!this.fragContextChanged(_)){if(this.state=wr,_e){_e.tracks&&(this._bufferInitSegment(F,_e.tracks,_,v),u.trigger(g.Events.FRAG_PARSING_INIT_SEGMENT,{frag:_,id:l,tracks:_e.tracks}));var He=_e.initPTS,Je=_e.timescale;(0,R.isFiniteNumber)(He)&&(this.initPTS[_.cc]=He,u.trigger(g.Events.INIT_PTS_FOUND,{frag:_,id:l,initPTS:He,timescale:Je}))}if(P&&c.independent!==!1){if(ge){var Ae=P.startPTS,Ke=P.endPTS,je=P.startDTS,pt=P.endDTS;if(S)S.elementaryStreams[P.type]={startPTS:Ae,endPTS:Ke,startDTS:je,endDTS:pt};else if(P.firstKeyFrame&&P.independent&&v.id===1&&(this.couldBacktrack=!0),P.dropped&&P.independent){var Mt=this.getMainFwdBufferInfo();if((Mt?Mt.end:this.getLoadPosition())+this.config.maxBufferHole<(P.firstKeyFramePTS?P.firstKeyFramePTS:Ae)-this.config.maxBufferHole)return void this.backtrack(_);_.setElementaryStreamInfo(P.type,_.start,Ke,_.start,pt,!0)}_.setElementaryStreamInfo(P.type,Ae,Ke,je,pt),this.backtrackFragment&&(this.backtrackFragment=_),this.bufferFragmentData(P,_,S,v)}}else if(c.independent===!1)return void this.backtrack(_);if(De){var mt=De.startPTS,kt=De.endPTS,xt=De.startDTS,ir=De.endDTS;S&&(S.elementaryStreams[J.ElementaryStreamTypes.AUDIO]={startPTS:mt,endPTS:kt,startDTS:xt,endDTS:ir}),_.setElementaryStreamInfo(J.ElementaryStreamTypes.AUDIO,mt,kt,xt,ir),this.bufferFragmentData(De,_,S,v)}if(ge&&ue!=null&&(s=ue.samples)!==null&&s!==void 0&&s.length){var er={id:l,frag:_,details:ge,samples:ue.samples};u.trigger(g.Events.FRAG_PARSING_METADATA,er)}if(ge&&W){var Yt={id:l,frag:_,details:ge,samples:W.samples};u.trigger(g.Events.FRAG_PARSING_USERDATA,Yt)}}},a._bufferInitSegment=function(r,s,l,u){var c=this;if(this.state===wr){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,F=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(S&&(S=S.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),v.metadata.channelCount!==1&&F.indexOf("firefox")===-1&&(S="mp4a.40.5")),F.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(g.Events.BUFFER_CODECS,s),Object.keys(s).forEach(function(P){var W=s[P].initSegment;W!=null&&W.byteLength&&c.hls.trigger(g.Events.BUFFER_APPENDING,{type:P,data:W,frag:l,part:null,chunkMeta:u,parent:l.type})}),this.tick()}},a.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,fe.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=At},a.checkFragmentChanged=function(){var r=this.media,s=null;if(r&&r.readyState>1&&r.seeking===!1){var l=r.currentTime;if(Gt.isBuffered(r,l)?s=this.getAppendedFrag(l):Gt.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(g.Events.FRAG_CHANGED,{frag:s}),u&&u.level===c||this.hls.trigger(g.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}}])&&Wr(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(hi);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}(),Rn=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 In(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 Cn=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 Rn(n.abrEwmaSlowVoD,n.abrEwmaFastVoD,n.abrEwmaDefaultEstimate),this.registerListeners()}var o,e,t=d.prototype;return t.registerListeners=function(){var i=this.hls;i.on(g.Events.FRAG_LOADING,this.onFragLoading,this),i.on(g.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(g.Events.FRAG_BUFFERED,this.onFragBuffered,this),i.on(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(g.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){var i=this.hls;i.off(g.Events.FRAG_LOADING,this.onFragLoading,this),i.off(g.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(g.Events.FRAG_BUFFERED,this.onFragBuffered,this),i.off(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(g.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===fe.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(),F=a.levels,P=a.minAutoLevel,W=F[i.level],ue=l.total||Math.max(l.loaded,Math.round(u*W.maxBitrate/8)),_e=_?1e3*l.loaded/v:0,ge=_e?(ue-l.loaded)/_e:8*ue/S,De=c.len/m;if(!(ge<=De)){var He,Je=Number.POSITIVE_INFINITY;for(He=i.level-1;He>P;He--){var Ae=F[He].maxBitrate;if((Je=_e?u*Ae/(6.4*_e):u*Ae/S)<De)break}Je>=ge||(L.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
|
+
Current BW estimate: `+((0,R.isFiniteNumber)(S)?(S/1024).toFixed(3):"Unknown")+` Kb/s
|
|
17
|
+
Estimated load time for current fragment: `+ge.toFixed(3)+` s
|
|
18
|
+
Estimated load time for the next fragment: `+Je.toFixed(3)+` s
|
|
19
|
+
Time to underbuffer: `+De.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(g.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===fe.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(g.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===fe.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)===fe.PlaylistLevelType.MAIN){if(n.type===k.ErrorTypes.KEY_SYSTEM_ERROR)return void this.clearTimer();switch(n.details){case k.ErrorDetails.FRAG_LOAD_ERROR:case k.ErrorDetails.FRAG_LOAD_TIMEOUT:case k.ErrorDetails.KEY_LOAD_ERROR:case k.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,F=this.findBestLevel(m,l,r,S,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(F>=0)return F;L.logger.trace((S?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var P=c?Math.min(c,s.maxStarvationDelay):s.maxStarvationDelay,W=s.abrBandWidthFactor,ue=s.abrBandWidthUpFactor;if(!S){var _e=this.bitrateTestDelay;_e&&(P=(c?Math.min(c,s.maxLoadingDelay):s.maxLoadingDelay)-_e,L.logger.trace("bitrate test took "+Math.round(1e3*_e)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*P)+" ms"),W=ue=1)}return F=this.findBestLevel(m,l,r,S+P,W,ue),Math.max(F,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],F=!(S==null||(u=S.details)===null||u===void 0||!u.live),P=S==null?void 0:S.codecSet,W=v?v.duration:c?c.duration:0,ue=a;ue>=n;ue--){var _e=_[ue];if(_e&&(!P||_e.codecSet===P)){var ge,De=_e.details,He=(v?De==null?void 0:De.partTarget:De==null?void 0:De.averagetargetduration)||W;ge=ue<=m?s*i:l*i;var Je=_[ue].maxBitrate,Ae=Je*He/ge;if(L.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+ue+"/"+Math.round(ge)+"/"+Je+"/"+He+"/"+r+"/"+Ae),ge>Je&&(Ae===0||!(0,R.isFiniteNumber)(Ae)||F&&!this.bitrateTestDelay||Ae<r))return ue}}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}}])&&In(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();var hn=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 mi(){return mi=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},mi.apply(this,arguments)}function Pi(d,o){return Pi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Pi(d,o)}var yi=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,Pi(o,e);var i=t.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var n=this.hls;n.on(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(g.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(g.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(g.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(g.Events.ERROR,this.onError,this),n.on(g.Events.BUFFER_RESET,this.onBufferReset,this),n.on(g.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(g.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(g.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(g.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var n=this.hls;n.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(g.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(g.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(g.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(g.Events.ERROR,this.onError,this),n.off(g.Events.BUFFER_RESET,this.onBufferReset,this),n.off(g.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(g.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(g.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(g.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===Ur&&this.tick()}},i.startLoad=function(n){if(!this.levels)return this.startPosition=n,void(this.state=br);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=At):(this.loadedmetadata=!1,this.state=ci),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},i.doTick=function(){switch(this.state){case At:this.doTickIdle();break;case ci: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=Ur}break;case Nr: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=At);break;case Ur:var v=this.waitingData;if(v){var m=v.frag,_=v.part,S=v.cache,F=v.complete;if(this.initPTS[m.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=qr;var P={frag:m,part:_,payload:S.flush(),networkDetails:null};this._handleFragmentLoadProgress(P),F&&d.prototype._handleFragmentLoadComplete.call(this,P)}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 W=this.getLoadPosition(),ue=Gt.bufferInfo(this.mediaBuffer,W,this.config.maxBufferHole);di(ue.end,this.config.maxFragLookUpTolerance,m)<0&&(this.log("Waiting fragment cc ("+m.cc+") @ "+m.start+" cancelled because another fragment at "+ue.end+" is needed"),this.clearWaitingFragment())}}else this.state=At}this.onTickEnd()},i.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=At)},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=ci;else{var c=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&c&&(this.bufferFlushed=!1,this.afterBufferFlushed(c,J.ElementaryStreamTypes.AUDIO,fe.PlaylistLevelType.AUDIO));var v=this.getFwdBufferInfo(c,fe.PlaylistLevelType.AUDIO);if(v!==null){var m=this.audioSwitch;if(!m&&this._streamEnded(v,u))return n.trigger(g.Events.BUFFER_EOS,{type:"audio"}),void(this.state=ei);var _=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,fe.PlaylistLevelType.MAIN);if(!(v.len>=this.getMaxBufferLength(_==null?void 0:_.len))||m){var S=u.fragments[0].start,F=v.end;if(m&&r){var P=this.getLoadPosition();F=P,u.PTSKnown&&P<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(!(_&&F>_.end+u.targetduration)&&(_&&_.len||!v.len)){var W=this.getNextFragment(F,u);W?this.loadFragment(W,u,F):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 N(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=At):this.state=br,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(g.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?(an(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!==ci||this.waitForCdnTuneIn(l)||(this.state=At),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",F=this.transmuxer;F||(F=this.transmuxer=new Ii(this.hls,fe.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var P=this.initPTS[r.cc],W=(a=r.initSegment)===null||a===void 0?void 0:a.data;if(P!==void 0){var ue=s?s.index:-1,_e=ue!==-1,ge=new Di(r.level,r.sn,r.stats.chunkCount,l.byteLength,ue,_e);F.push(l,W,S,"",r,s,_.totalduration,!1,ge,P)}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 hn,complete:!1}).cache.push(new Uint8Array(l)),this.waitingVideoCC=this.videoTrackCC,this.state=Ur}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===fe.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(g.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(s,l)):this.loadedmetadata||s.type!==fe.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!==k.ErrorTypes.KEY_SYSTEM_ERROR)switch(a.details){case k.ErrorDetails.FRAG_LOAD_ERROR:case k.ErrorDetails.FRAG_LOAD_TIMEOUT:case k.ErrorDetails.FRAG_PARSING_ERROR:case k.ErrorDetails.KEY_LOAD_ERROR:case k.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(fe.PlaylistLevelType.AUDIO,a);break;case k.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case k.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==Lr&&this.state!==br&&(this.state=a.fatal?Lr:At,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case k.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===wr||this.state===Vr)){var r=!0,s=this.getFwdBufferInfo(this.mediaBuffer,fe.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(fe.PlaylistLevelType.AUDIO,a)},i.onBufferFlushed=function(n,a){a.type===J.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===ei&&(this.state=At))},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,F=l.text,P=l.id3,W=l.initSegment;if(!this.fragContextChanged(v)&&_){if(this.state=wr,this.audioSwitch&&S&&this.completeAudioSwitch(),W!=null&&W.tracks&&(this._bufferInitSegment(W.tracks,v,u),s.trigger(g.Events.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:r,tracks:W.tracks})),S){var ue=S.startPTS,_e=S.endPTS,ge=S.startDTS,De=S.endDTS;m&&(m.elementaryStreams[J.ElementaryStreamTypes.AUDIO]={startPTS:ue,endPTS:_e,startDTS:ge,endDTS:De}),v.setElementaryStreamInfo(J.ElementaryStreamTypes.AUDIO,ue,_e,ge,De),this.bufferFragmentData(S,v,m,u)}if(P!=null&&(a=P.samples)!==null&&a!==void 0&&a.length){var He=mi({id:r,frag:v,details:_},P);s.trigger(g.Events.FRAG_PARSING_METADATA,He)}if(F){var Je=mi({id:r,frag:v,details:_},F);s.trigger(g.Events.FRAG_PARSING_USERDATA,Je)}}},i._bufferInitSegment=function(n,a,r){if(this.state===wr){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(g.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(g.Events.BUFFER_APPENDING,u)}this.tick()}}},i.loadFragment=function(n,a,r){var s=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||s===Ge.NOT_LOADED||s===Ge.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=Ur):(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(g.Events.AUDIO_TRACK_SWITCHED,{id:r})},t}(hi);let Oi=yi;function fn(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 ii(d,o){return ii=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ii(d,o)}let Pn=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,ii(o,e);var i,n,a=t.prototype;return a.registerListeners=function(){var r=this.hls;r.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(g.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(g.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(g.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(g.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var r=this.hls;r.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(g.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(g.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(g.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(g.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(g.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===fe.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,F=u.url;if(this.trackId=r,this.trackName=_,this.selectDefaultTrack=!1,this.hls.trigger(g.Events.AUDIO_TRACK_SWITCHING,{id:c,groupId:m,name:_,type:S,url:F}),!u.details||u.details.live){var P=this.switchParams(u.url,l==null?void 0:l.details);this.loadPlaylist(P)}}},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(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.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(g.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)}}])&&fn(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Re);function On(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 xi(d,o){return xi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},xi(d,o)}var xn=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,xi(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(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(g.Events.ERROR,this.onError,this),r.on(g.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(g.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.on(g.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(g.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.on(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(g.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var r=this.hls;r.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(g.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(g.Events.ERROR,this.onError,this),r.off(g.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.off(g.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.off(g.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(g.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.off(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(g.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a.startLoad=function(r){this.stopLoad(),this.state=At,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=At,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,fe.PlaylistLevelType.SUBTITLE)}},a.onFragBuffered=function(r,s){var l;this.loadedmetadata||s.frag.type!==fe.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===fe.PlaylistLevelType.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=At)},a.onSubtitleTracksUpdated=function(r,s){var l=this,u=s.subtitleTracks;this.tracksBuffered=[],this.levels=u.map(function(c){return new N(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 F=this.mainDetails;if(u.deltaUpdateFailed||!F)return;var P=F.fragments[0];_.details?(S=this.alignPlaylists(u,_.details))===0&&P&&Te(u,S=P.start):u.hasProgramDateTime&&F.hasProgramDateTime?(an(u,F),S=u.fragments[0].start):P&&Te(u,S=P.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===At&&(ui(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(g.Events.FRAG_DECRYPTED,{frag:l,payload:_,stats:{tstart:m,tdecrypt:S}})}).catch(function(_){s.warn(_.name+": "+_.message),s.state=At})}},a.doTick=function(){if(this.media){if(this.state===At){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=Gt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],v-u,c.maxBufferHole),_=m.end,S=m.len,F=this.getFwdBufferInfo(this.media,fe.PlaylistLevelType.MAIN);if(S>this.getMaxBufferLength(F==null?void 0:F.len)+u)return;var P=l.fragments,W=P.length,ue=l.edge,_e=null,ge=this.fragPrevious;if(_<ue){var De=c.maxFragLookUpTolerance;!(_e=ui(ge,P,Math.max(P[0].start,_),De))&&ge&&ge.start<P[0].start&&(_e=P[0])}else _e=P[W-1];if(!_e)return;_e=this.mapToInitFragWhenRequired(_e),this.fragmentTracker.getState(_e)===Ge.NOT_LOADED&&this.loadFragment(_e,l,_)}}else this.state=At},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 Mn(this.tracksBuffered[this.currentTrackId]||[])}}])&&On(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(hi),Mn=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 Fn(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 Mi(d,o){return Mi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Mi(d,o)}function Fi(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 Nn=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,Mi(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(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(g.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(g.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(g.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(g.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var r=this.hls;r.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(g.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(g.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(g.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(g.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),Fi(this.media.textTracks).forEach(function(r){lt(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(g.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===fe.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(g.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=Fi(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,F=c.type,P=c.url;this.hls.trigger(g.Events.SUBTITLE_TRACK_SWITCH,{id:v,groupId:_,name:S,type:F,url:P});var W=this.switchParams(c.url,s==null?void 0:s.details);this.loadPlaylist(W)}else this.hls.trigger(g.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=Fi(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)}}])&&Fn(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Re);var Et,gr=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){L.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}(),Xr=fi(),vn=/([ha]vc.)(?:\.[^.,]+)+/,Un=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;L.logger.log("[buffer-controller]: Media source opened"),n&&(t.updateMediaElementDuration(),i.trigger(g.Events.MEDIA_ATTACHED,{media:n})),a&&a.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){L.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){L.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(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(g.Events.BUFFER_RESET,this.onBufferReset,this),e.on(g.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(g.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(g.Events.BUFFER_EOS,this.onBufferEos,this),e.on(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(g.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(g.Events.FRAG_PARSED,this.onFragParsed,this),e.on(g.Events.FRAG_CHANGED,this.onFragChanged,this)},o.unregisterListeners=function(){var e=this.hls;e.off(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(g.Events.BUFFER_RESET,this.onBufferReset,this),e.off(g.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(g.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(g.Events.BUFFER_EOS,this.onBufferEos,this),e.off(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(g.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(g.Events.FRAG_PARSED,this.onFragParsed,this),e.off(g.Events.FRAG_CHANGED,this.onFragChanged,this)},o._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new gr(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,L.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},o.onMediaAttaching=function(e,t){var i=this.media=t.media;if(i&&Xr){var n=this.mediaSource=new Xr;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(L.logger.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(n){L.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()):L.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(g.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){L.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(vn,"$1"),S=(c||u).replace(vn,"$1");if(_!==S){var F=v+";codecs="+(c||u);i.appendChangeType(a,F),L.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&&(L.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),r.changeType(t)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(r){L.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,F=c?c.stats.buffering:null;S.start===0&&(S.start=_),F&&F.start===0&&(F.start=_);var P=r.audio,W=!1;l==="audio"&&(P==null?void 0:P.container)==="audio/mpeg"&&(W=!this.lastMpegAudioChunk||v.id===1||this.lastMpegAudioChunk.sn!==v.sn,this.lastMpegAudioChunk=v);var ue=u.start,_e={execute:function(){if(m.executeStart=self.performance.now(),W){var ge=i.sourceBuffer[l];if(ge){var De=ue-ge.timestampOffset;Math.abs(De)>=.1&&(L.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+ue+" (delta: "+De+") sn: "+u.sn+")"),ge.timestampOffset=ue)}}i.appendExecutor(s,l)},onStart:function(){},onComplete:function(){var ge=self.performance.now();m.executeEnd=m.end=ge,S.first===0&&(S.first=ge),F&&F.first===0&&(F.first=ge);var De=i.sourceBuffer,He={};for(var Je in De)He[Je]=Gt.getBuffered(De[Je]);i.appendError=0,i.hls.trigger(g.Events.BUFFER_APPENDED,{type:l,frag:u,part:c,chunkMeta:v,parent:u.type,timeRanges:He})},onError:function(ge){L.logger.error("[buffer-controller]: Error encountered while trying to append to the "+l+" SourceBuffer",ge);var De={type:k.ErrorTypes.MEDIA_ERROR,parent:u.type,details:k.ErrorDetails.BUFFER_APPEND_ERROR,err:ge,fatal:!1};ge.code===DOMException.QUOTA_EXCEEDED_ERR?De.details=k.ErrorDetails.BUFFER_FULL_ERROR:(i.appendError++,De.details=k.ErrorDetails.BUFFER_APPEND_ERROR,i.appendError>n.config.appendErrorMaxRetry&&(L.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),De.fatal=!0,n.stopLoad())),n.trigger(g.Events.ERROR,De)}};a.append(_e,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(g.Events.BUFFER_FLUSHED,{type:r})},onError:function(s){L.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[J.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(s[J.ElementaryStreamTypes.AUDIO]&&r.push("audio"),s[J.ElementaryStreamTypes.VIDEO]&&r.push("video")),r.length===0&&L.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(g.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,L.logger.log("[buffer-controller]: "+a+" sourceBuffer now EOS"))),n&&!(r&&!r.ended)},!0)&&(L.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"?(L.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),n.endOfStream()):n&&L.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 _=Gt.getBuffered(m);if(_.length>0&&c>_.start(0)){if(e.trigger(g.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(g.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(m.ended&&_.end(_.length-1)-s<2*l)return void L.logger.info("[buffer-controller]: Cannot flush "+v+" back buffer while SourceBuffer is in ended state");e.trigger(g.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?(L.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))&&(L.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(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.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;L.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){L.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+v.message),this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,mimeType:l})}}n&&this.hls.trigger(g.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){L.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.MEDIA_ERROR,details:k.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 L.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,L.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 L.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 L.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}(),p={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 p.hasOwnProperty(d)&&(o=p[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},M={17:2,18:4,21:6,22:8,23:10,19:13,20:15},I={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Y={25:2,26:4,29:6,30:8,31:10,27:13,28:15},he=["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"})(Et||(Et={}));var ee=function(){function d(){this.time=null,this.verboseLevel=Et.ERROR}return d.prototype.log=function(o,e){if(this.verboseLevel>=o){var t=typeof e=="function"?e():e;L.logger.log(this.time+" ["+o+"] "+t)}},d}(),Me=function(d){for(var o=[],e=0;e<d.length;e++)o.push(d[e].toString(16));return o},ut=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}(),Ze=function(){function d(e,t,i,n,a,r){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new ut(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}(),st=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 Ze);this.logger=e,this.pos=0,this.currPenState=new ut}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(Et.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>y&&(this.logger.log(Et.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(Et.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}(),Qe=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 st(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(Et.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},o.setPAC=function(e){this.logger.log(Et.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(Et.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(Et.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(Et.INFO,"Rolling up")}else this.logger.log(Et.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}(),ot=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 Qe(i),this.nonDisplayedMemory=new Qe(i),this.lastOutputScreen=new Qe(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(Et.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(Et.INFO,function(){return n+": "+t.writeScreen.getDisplayText(!0)}),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(Et.TEXT,function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},o.ccRCL=function(){this.logger.log(Et.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},o.ccBS=function(){this.logger.log(Et.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(Et.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},o.ccRU=function(e){this.logger.log(Et.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},o.ccFON=function(){this.logger.log(Et.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},o.ccRDC=function(){this.logger.log(Et.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},o.ccTR=function(){this.logger.log(Et.INFO,"TR"),this.setMode("MODE_TEXT")},o.ccRTD=function(){this.logger.log(Et.INFO,"RTD"),this.setMode("MODE_TEXT")},o.ccEDM=function(){this.logger.log(Et.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},o.ccCR=function(){this.logger.log(Et.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},o.ccENM=function(){this.logger.log(Et.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},o.ccEOC=function(){var e=this;if(this.logger.log(Et.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(Et.TEXT,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},o.ccTO=function(e){this.logger.log(Et.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(Et.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}(),Ot=function(){function d(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new ee;this.channels=[null,new ot(e,t,n),new ot(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(Et.DATA,"["+Me([t[s],t[s+1]])+"] -> ("+Me([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(Et.WARNING,"No channel found yet. TEXT-MODE?")}i||r||this.logger.log(Et.WARNING,"Couldn't parse cleaned data "+Me([n,a])+" orig: "+Me([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(rr(e,t,i))return qt(null,null,i),this.logger.log(Et.DEBUG,"Repeated command ("+Me([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),qt(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(Et.ERROR,"Mismatch channel in midrow parsing"),!1;var n=this.channels[i];return!!n&&(n.ccMIDROW(t),this.logger.log(Et.DEBUG,"MIDROW ("+Me([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(rr(e,t,n))return qt(null,null,n),!0;var a=e<=23?1:2;i=t>=64&&t<=95?a===1?b[e]:I[e]:a===1?M[e]:Y[e];var r=this.channels[a];return!!r&&(r.setPAC(this.interpretPAC(i,t)),qt(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(Et.INFO,"Special char '"+h(n)+"' in channel "+i),a=[n]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var s=Me(a);this.logger.log(Et.DEBUG,"Char codes = "+s.join(",")),qt(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=he[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),qt(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 qt(d,o,e){e.a=d,e.b=o}function rr(d,o,e){return e.a===d&&e.b===o}let ur=Ot;var Tt=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 Zt=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,F=null,P="",W=!0,ue="auto",_e="start",ge=50,De="middle",He=50,Je="middle";Object.defineProperty(l,"id",i({},u,{get:function(){return c},set:function(Ae){c=""+Ae}})),Object.defineProperty(l,"pauseOnExit",i({},u,{get:function(){return v},set:function(Ae){v=!!Ae}})),Object.defineProperty(l,"startTime",i({},u,{get:function(){return m},set:function(Ae){if(typeof Ae!="number")throw new TypeError("Start time must be set to a number.");m=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"endTime",i({},u,{get:function(){return _},set:function(Ae){if(typeof Ae!="number")throw new TypeError("End time must be set to a number.");_=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"text",i({},u,{get:function(){return S},set:function(Ae){S=""+Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"region",i({},u,{get:function(){return F},set:function(Ae){F=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"vertical",i({},u,{get:function(){return P},set:function(Ae){var Ke=function(je){return e(d,je)}(Ae);if(Ke===!1)throw new SyntaxError("An invalid or illegal string was specified.");P=Ke,this.hasBeenReset=!0}})),Object.defineProperty(l,"snapToLines",i({},u,{get:function(){return W},set:function(Ae){W=!!Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"line",i({},u,{get:function(){return ue},set:function(Ae){if(typeof Ae!="number"&&Ae!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");ue=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"lineAlign",i({},u,{get:function(){return _e},set:function(Ae){var Ke=t(Ae);if(!Ke)throw new SyntaxError("An invalid or illegal string was specified.");_e=Ke,this.hasBeenReset=!0}})),Object.defineProperty(l,"position",i({},u,{get:function(){return ge},set:function(Ae){if(Ae<0||Ae>100)throw new Error("Position must be between 0 and 100.");ge=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"positionAlign",i({},u,{get:function(){return De},set:function(Ae){var Ke=t(Ae);if(!Ke)throw new SyntaxError("An invalid or illegal string was specified.");De=Ke,this.hasBeenReset=!0}})),Object.defineProperty(l,"size",i({},u,{get:function(){return He},set:function(Ae){if(Ae<0||Ae>100)throw new Error("Size must be between 0 and 100.");He=Ae,this.hasBeenReset=!0}})),Object.defineProperty(l,"align",i({},u,{get:function(){return Je},set:function(Ae){var Ke=t(Ae);if(!Ke)throw new SyntaxError("An invalid or illegal string was specified.");Je=Ke,this.hasBeenReset=!0}})),l.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}();var sr=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 Lt(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 nt=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 vt(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 et=new Zt(0,0,""),ft=et.align==="middle"?"middle":"center";function Vt(d,o,e){var t=d;function i(){var a=Lt(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 nt;vt(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",ft,"end"]);break;case"position":m=v.split(","),s.percent(c,m[0]),m.length===2&&s.alt("positionAlign",m[1],["start",ft,"end","line-left","line-right","auto"]);break;case"size":s.percent(c,v);break;case"align":s.alt(c,v,["start",ft,"end","left","right"])}},/:/,/\s/),r.region=s.get("region",null),r.vertical=s.get("vertical","");var l=s.get("line","auto");l==="auto"&&et.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",ft);var u=s.get("position","auto");u==="auto"&&et.position===50&&(u=r.align==="start"||r.align==="left"?0:r.align==="end"||r.align==="right"?100:50),r.position=u}(d,o)}function Xt(d){return d.replace(/<br(?: \/)?>/gi,`
|
|
21
|
+
`)}var dr=function(){function d(){this.state="INITIAL",this.buffer="",this.decoder=new sr,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var o=d.prototype;return o.parse=function(e){var t=this;function i(){var l=t.buffer,u=0;for(l=Xt(l);u<l.length&&l[u]!=="\r"&&l[u]!==`
|
|
22
|
+
`;)++u;var c=l.slice(0,u);return l[u]==="\r"&&++u,l[u]===`
|
|
23
|
+
`&&++u,t.buffer=l.slice(u),c}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;var a=(n=i()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var r=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(r?r=!1:n=i(),t.state){case"HEADER":/:/.test(n)?vt(n,function(l,u){},/:/):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Zt(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Vt(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=n.indexOf("-->")!==-1;if(!n||s&&(r=!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+=`
|
|
24
|
+
`),t.cue.text+=n;continue;case"BADCUE":n||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},o.flush=function(){var e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
|
|
28
25
|
|
|
29
|
-
`,
|
|
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},d}(),or=B(673),mr=B(524),cr=/\r\n|\n\r|\n|\r/g,yr=function(d,o,e){return e===void 0&&(e=0),d.slice(e,e+o.length)===o},Qt=function(d){for(var o=5381,e=d.length;e;)o=33*o^d.charCodeAt(--e);return(o>>>0).toString()};function hr(d,o,e){return Qt(d.toString())+Qt(o.toString())+Qt(e)}function ni(){return ni=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},ni.apply(this,arguments)}var Er="stpp.ttml.im1t",zr=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,pn=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,ks={left:"start",center:"center",right:"end",start:"start",end:"end"};function Aa(d,o,e,t,i){var n=(0,z.findBox)(new Uint8Array(d),["mdat"]);if(n.length!==0){var a=n.map(function(s){return(0,Rt.utf8ArrayToStr)(s)}),r=(0,or.toTimescaleFromScale)(o,1,e);try{a.forEach(function(s){return t(function(l,u){var c=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("tt")[0];if(!c)throw new Error("Invalid ttml");var v={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},m=Object.keys(v).reduce(function(W,ue){return W[ue]=c.getAttribute("ttp:"+ue)||v[ue],W},{}),_=c.getAttribute("xml:space")!=="preserve",S=ka(Bn(c,"styling","style")),F=ka(Bn(c,"layout","region")),P=Bn(c,"body","[begin]");return[].map.call(P,function(W){var ue=wa(W,_);if(!ue||!W.hasAttribute("begin"))return null;var _e=Gn(W.getAttribute("begin"),m),ge=Gn(W.getAttribute("dur"),m),De=Gn(W.getAttribute("end"),m);if(_e===null)throw Da(W);if(De===null){if(ge===null)throw Da(W);De=_e+ge}var He=new Zt(_e-u,De-u,ue);He.id=hr(He.startTime,He.endTime,He.text);var Je=function(je,pt,Mt){var mt="http://www.w3.org/ns/ttml#styling",kt=null,xt=je!=null&&je.hasAttribute("style")?je.getAttribute("style"):null;return xt&&Mt.hasOwnProperty(xt)&&(kt=Mt[xt]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(function(ir,er){var Yt=jn(pt,mt,er)||jn(je,mt,er)||jn(kt,mt,er);return Yt&&(ir[er]=Yt),ir},{})}(F[W.getAttribute("region")],S[W.getAttribute("style")],S),Ae=Je.textAlign;if(Ae){var Ke=ks[Ae];Ke&&(He.lineAlign=Ke),He.align=Ae}return ni(He,Je),He}).filter(function(W){return W!==null})}(s,r))})}catch(s){i(s)}}else i(new Error("Could not parse IMSC1 mdat"))}function Bn(d,o,e){var t=d.getElementsByTagName(o)[0];return t?[].slice.call(t.querySelectorAll(e)):[]}function ka(d){return d.reduce(function(o,e){var t=e.getAttribute("xml:id");return t&&(o[t]=e),o},{})}function wa(d,o){return[].slice.call(d.childNodes).reduce(function(e,t,i){var n;return t.nodeName==="br"&&i?e+`
|
|
27
|
+
`:(n=t.childNodes)!==null&&n!==void 0&&n.length?wa(t,o):o?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function jn(d,o,e){return d&&d.hasAttributeNS(o,e)?d.getAttributeNS(o,e):null}function Da(d){return new Error("Could not parse ttml timestamp "+d)}function Gn(d,o){if(!d)return null;var e=Lt(d);return e===null&&(zr.test(d)?e=function(t,i){var n=zr.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):pn.test(d)&&(e=function(t,i){var n=pn.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 ws=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 Tt(this,"textTrack1"),i=new Tt(this,"textTrack2"),n=new Tt(this,"textTrack3"),a=new Tt(this,"textTrack4");this.cea608Parser1=new ur(1,t,i),this.cea608Parser2=new ur(3,n,a)}e.on(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(g.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(g.Events.FRAG_LOADING,this.onFragLoading,this),e.on(g.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(g.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(g.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(g.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(g.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(g.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=d.prototype;return o.destroy=function(){var e=this.hls;e.off(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(g.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(g.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(g.Events.FRAG_LOADING,this.onFragLoading,this),e.off(g.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(g.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(g.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(g.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(g.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(g.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 F=this.Cues.newCue(null,t,i,n);this.hls.trigger(g.Events.CUES_PARSED,{type:"captions",cues:F,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(g.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,lt(i[e]),Xe(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(g.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){lt(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++)lt(t[i])}},o.onSubtitleTracksUpdated=function(e,t){var i=this;this.textTracks=[];var n=t.subtitleTracks||[],a=n.some(function(u){return u.textCodec===Er});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(Ds(s[_],u)){m=s[_];break}m&&(v=m)}if(v)lt(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(g.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===fe.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===fe.PlaylistLevelType.SUBTITLE)if(n.byteLength){if(!(0,R.isFiniteNumber)(a[i.cc]))return r.push(t),void(a.length&&this.hls.trigger(g.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===Er?this._parseIMSC1(i,n):this._parseVTTs(i,n,c)}}else this.hls.trigger(g.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;Aa(t,this.initPTS[e.cc],this.timescale[e.cc],function(a){i._appendCues(a,e.level),n.trigger(g.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(a){L.logger.log("Failed to parse IMSC1: "+a),n.trigger(g.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 F,P=new dr,W=(0,Rt.utf8ArrayToStr)(new Uint8Array(s)).trim().replace(cr,`
|
|
30
28
|
`).split(`
|
|
31
|
-
`),
|
|
32
|
-
`)}),u.flush()}},"./src/utils/xhr-loader.ts":(Q,B,T)=>{"use strict";T.r(B),T.d(B,{default:()=>U});var O=T("./src/utils/logger.ts"),D=T("./src/loader/load-stats.ts"),M=/^age:\s*[\d.]+\s*$/m,P=function(){function b(S){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=S?S.xhrSetup:null,this.stats=new D.LoadStats,this.retryDelay=0}var A=b.prototype;return A.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},A.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()))},A.abort=function(){var E;this.abortInternal(),(E=this.callbacks)!==null&&E!==void 0&&E.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},A.load=function(E,x,f){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=x,this.callbacks=f,this.retryDelay=x.retryDelay,this.loadInternal()},A.loadInternal=function(){var E=this.config,x=this.context;if(!!E){var f=this.loader=new self.XMLHttpRequest,_=this.stats;_.loading.first=0,_.loaded=0;var p=this.xhrSetup;try{if(p)try{p(f,x.url)}catch{f.open("GET",x.url,!0),p(f,x.url)}f.readyState||f.open("GET",x.url,!0);var v=this.context.headers;if(v)for(var a in v)f.setRequestHeader(a,v[a])}catch(s){this.callbacks.onError({code:f.status,text:s.message},x,f);return}x.rangeEnd&&f.setRequestHeader("Range","bytes="+x.rangeStart+"-"+(x.rangeEnd-1)),f.onreadystatechange=this.readystatechange.bind(this),f.onprogress=this.loadprogress.bind(this),f.responseType=x.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout),f.send()}},A.readystatechange=function(){var E=this.context,x=this.loader,f=this.stats;if(!(!E||!x)){var _=x.readyState,p=this.config;if(!f.aborted&&_>=2)if(self.clearTimeout(this.requestTimeout),f.loading.first===0&&(f.loading.first=Math.max(self.performance.now(),f.loading.start)),_===4){x.onreadystatechange=null,x.onprogress=null;var v=x.status,a=x.responseType==="arraybuffer";if(v>=200&&v<300&&(a&&x.response||x.responseText!==null)){f.loading.end=Math.max(self.performance.now(),f.loading.first);var s,n;if(a?(s=x.response,n=s.byteLength):(s=x.responseText,n=s.length),f.loaded=f.total=n,!this.callbacks)return;var d=this.callbacks.onProgress;if(d&&d(f,E,s,x),!this.callbacks)return;var l={url:x.responseURL,data:s};this.callbacks.onSuccess(l,f,E,x)}else f.retry>=p.maxRetry||v>=400&&v<499?(O.logger.error(v+" while loading "+E.url),this.callbacks.onError({code:v,text:x.statusText},E,x)):(O.logger.warn(v+" 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,p.maxRetryDelay),f.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),p.timeout)}},A.loadtimeout=function(){O.logger.warn("timeout while loading "+this.context.url);var E=this.callbacks;E&&(this.abortInternal(),E.onTimeout(this.stats,this.context,this.loader))},A.loadprogress=function(E){var x=this.stats;x.loaded=E.loaded,E.lengthComputable&&(x.total=E.total)},A.getCacheAge=function(){var E=null;if(this.loader&&M.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");E=x?parseFloat(x):null}return E},b}();let U=P},"./node_modules/eventemitter3/index.js":Q=>{"use strict";var B=Object.prototype.hasOwnProperty,T="~";function O(){}Object.create&&(O.prototype=Object.create(null),new O().__proto__||(T=!1));function D(b,A,S){this.fn=b,this.context=A,this.once=S||!1}function M(b,A,S,E,x){if(typeof S!="function")throw new TypeError("The listener must be a function");var f=new D(S,E||b,x),_=T?T+A:A;return b._events[_]?b._events[_].fn?b._events[_]=[b._events[_],f]:b._events[_].push(f):(b._events[_]=f,b._eventsCount++),b}function P(b,A){--b._eventsCount===0?b._events=new O:delete b._events[A]}function U(){this._events=new O,this._eventsCount=0}U.prototype.eventNames=function(){var A=[],S,E;if(this._eventsCount===0)return A;for(E in S=this._events)B.call(S,E)&&A.push(T?E.slice(1):E);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(S)):A},U.prototype.listeners=function(A){var S=T?T+A:A,E=this._events[S];if(!E)return[];if(E.fn)return[E.fn];for(var x=0,f=E.length,_=new Array(f);x<f;x++)_[x]=E[x].fn;return _},U.prototype.listenerCount=function(A){var S=T?T+A:A,E=this._events[S];return E?E.fn?1:E.length:0},U.prototype.emit=function(A,S,E,x,f,_){var p=T?T+A:A;if(!this._events[p])return!1;var v=this._events[p],a=arguments.length,s,n;if(v.fn){switch(v.once&&this.removeListener(A,v.fn,void 0,!0),a){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,S),!0;case 3:return v.fn.call(v.context,S,E),!0;case 4:return v.fn.call(v.context,S,E,x),!0;case 5:return v.fn.call(v.context,S,E,x,f),!0;case 6:return v.fn.call(v.context,S,E,x,f,_),!0}for(n=1,s=new Array(a-1);n<a;n++)s[n-1]=arguments[n];v.fn.apply(v.context,s)}else{var d=v.length,l;for(n=0;n<d;n++)switch(v[n].once&&this.removeListener(A,v[n].fn,void 0,!0),a){case 1:v[n].fn.call(v[n].context);break;case 2:v[n].fn.call(v[n].context,S);break;case 3:v[n].fn.call(v[n].context,S,E);break;case 4:v[n].fn.call(v[n].context,S,E,x);break;default:if(!s)for(l=1,s=new Array(a-1);l<a;l++)s[l-1]=arguments[l];v[n].fn.apply(v[n].context,s)}}return!0},U.prototype.on=function(A,S,E){return M(this,A,S,E,!1)},U.prototype.once=function(A,S,E){return M(this,A,S,E,!0)},U.prototype.removeListener=function(A,S,E,x){var f=T?T+A:A;if(!this._events[f])return this;if(!S)return P(this,f),this;var _=this._events[f];if(_.fn)_.fn===S&&(!x||_.once)&&(!E||_.context===E)&&P(this,f);else{for(var p=0,v=[],a=_.length;p<a;p++)(_[p].fn!==S||x&&!_[p].once||E&&_[p].context!==E)&&v.push(_[p]);v.length?this._events[f]=v.length===1?v[0]:v:P(this,f)}return this},U.prototype.removeAllListeners=function(A){var S;return A?(S=T?T+A:A,this._events[S]&&P(this,S)):(this._events=new O,this._eventsCount=0),this},U.prototype.off=U.prototype.removeListener,U.prototype.addListener=U.prototype.on,U.prefixed=T,U.EventEmitter=U,Q.exports=U},"./node_modules/url-toolkit/src/url-toolkit.js":function(Q){(function(B){var T=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,O=/^(?=([^\/?#]*))\1([^]*)$/,D=/(?:\/|^)\.(?=\/)/g,M=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(U,b,A){if(A=A||{},U=U.trim(),b=b.trim(),!b){if(!A.alwaysNormalize)return U;var S=P.parseURL(U);if(!S)throw new Error("Error trying to parse base URL.");return S.path=P.normalizePath(S.path),P.buildURLFromParts(S)}var E=P.parseURL(b);if(!E)throw new Error("Error trying to parse relative URL.");if(E.scheme)return A.alwaysNormalize?(E.path=P.normalizePath(E.path),P.buildURLFromParts(E)):b;var x=P.parseURL(U);if(!x)throw new Error("Error trying to parse base URL.");if(!x.netLoc&&x.path&&x.path[0]!=="/"){var f=O.exec(x.path);x.netLoc=f[1],x.path=f[2]}x.netLoc&&!x.path&&(x.path="/");var _={scheme:x.scheme,netLoc:E.netLoc,path:null,params:E.params,query:E.query,fragment:E.fragment};if(!E.netLoc&&(_.netLoc=x.netLoc,E.path[0]!=="/"))if(!E.path)_.path=x.path,E.params||(_.params=x.params,E.query||(_.query=x.query));else{var p=x.path,v=p.substring(0,p.lastIndexOf("/")+1)+E.path;_.path=P.normalizePath(v)}return _.path===null&&(_.path=A.alwaysNormalize?P.normalizePath(E.path):E.path),P.buildURLFromParts(_)},parseURL:function(U){var b=T.exec(U);return b?{scheme:b[1]||"",netLoc:b[2]||"",path:b[3]||"",params:b[4]||"",query:b[5]||"",fragment:b[6]||""}:null},normalizePath:function(U){for(U=U.split("").reverse().join("").replace(D,"");U.length!==(U=U.replace(M,"")).length;);return U.split("").reverse().join("")},buildURLFromParts:function(U){return U.scheme+U.netLoc+U.path+U.params+U.query+U.fragment}};Q.exports=P})(this)}},X={};function V(Q){var B=X[Q];if(B!==void 0)return B.exports;var T=X[Q]={exports:{}};return $[Q].call(T.exports,T,T.exports,V),T.exports}V.m=$,V.n=Q=>{var B=Q&&Q.__esModule?()=>Q.default:()=>Q;return V.d(B,{a:B}),B},V.d=(Q,B)=>{for(var T in B)V.o(B,T)&&!V.o(Q,T)&&Object.defineProperty(Q,T,{enumerable:!0,get:B[T]})},V.o=(Q,B)=>Object.prototype.hasOwnProperty.call(Q,B),V.r=Q=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(Q,"__esModule",{value:!0})};var ie=V("./src/hls.ts");return ie=ie.default,ie})())});var wt=class{addEventListener(){}removeEventListener(){}dispatchEvent(X){return!0}};if(typeof DocumentFragment=="undefined"){class $ extends wt{}globalThis.DocumentFragment=$}var Zt=class extends wt{},Gr=class extends wt{},$n={get($){},define($,X,V){},upgrade($){},whenDefined($){return Promise.resolve(Zt)}},er,Hr=class{constructor(X,V={}){Ae(this,er,void 0);Fe(this,er,V==null?void 0:V.detail)}get detail(){return he(this,er)}initCustomEvent(){}};er=new WeakMap;function Jn($,X){return new Zt}var Di={document:{createElement:Jn},DocumentFragment,customElements:$n,CustomEvent:Hr,EventTarget:wt,HTMLElement:Zt,HTMLVideoElement:Gr},bi=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Tt=bi?Di:globalThis,jr=bi?Di.document:globalThis.document;var xr=Er(Li(),1),Rt=Er(Tr(),1),zr=Er(Tr(),1),kt=Er(Tr(),1),rr=class extends Error{constructor($,X=rr.MEDIA_ERR_CUSTOM,V){var ie;super($),this.name="MediaError",this.code=X,this.fatal=V!=null?V:X>=rr.MEDIA_ERR_NETWORK&&X<=rr.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(ie=rr.defaultMessages[this.code])!=null?ie:"")}},ct=rr;ct.MEDIA_ERR_ABORTED=1,ct.MEDIA_ERR_NETWORK=2,ct.MEDIA_ERR_DECODE=3,ct.MEDIA_ERR_SRC_NOT_SUPPORTED=4,ct.MEDIA_ERR_ENCRYPTED=5,ct.MEDIA_ERR_CUSTOM=100,ct.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 qn=$=>$==null,Mi=($,X)=>qn(X)?!1:$ in X,Qr={ANY:"any",MUTED:"muted"},Sr={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},It={MSE:"mse",NATIVE:"native"},$r={HEADER:"header",QUERY:"query",NONE:"none"},Zr=Object.values($r),Ut={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Jr={HLS:Ut.M3U8},Ra=Object.keys(Jr),Ia=[...Object.values(Ut),"hls","HLS"],Ft=($,X,V,ie,Q=$)=>{Q.addEventListener(X,V,ie),$.addEventListener("teardown",()=>{Q.removeEventListener(X,V)},{once:!0})};function Zn($,X,V){X&&V>X&&(V=X);for(let ie=0;ie<$.length;ie++)if($.start(ie)<=V&&$.end(ie)>=V)return!0;return!1}var ea=$=>{let X=$.indexOf("?");if(X<0)return[$];let V=$.slice(0,X),ie=$.slice(X);return[V,ie]},wi=$=>{let X=$.type;if(X){let ie=X.toUpperCase();return Mi(ie,Jr)?Jr[ie]:X}let{src:V}=$;return V?ta(V):""},ta=$=>{let X="";try{X=new URL($).pathname}catch{console.error("invalid url")}let V=X.lastIndexOf(".");if(V<0)return"";let ie=X.slice(V+1).toUpperCase();return Mi(ie,Ut)?Ut[ie]:""},ra=Object.values(Qr),Pi=$=>typeof $=="boolean"||typeof $=="string"&&ra.includes($),ia=({autoplay:$},X,V)=>{let ie=!1,Q=!1,B=Pi($)?$:!!$,T=()=>{ie||Ft(X,"playing",()=>{ie=!0},{once:!0})};if(T(),Ft(X,"loadstart",()=>{ie=!1,T(),Xr(X,B)},{once:!0}),Ft(X,"loadstart",()=>{V||(Q=!Number.isFinite(X.duration)),Xr(X,B)},{once:!0}),V&&V.once(zr.default.Events.LEVEL_LOADED,(O,D)=>{var M;Q=(M=D.details.live)!=null?M:!1}),!B){let O=()=>{!Q||(V!=null&&V.liveSyncPosition?X.currentTime=V.liveSyncPosition:Number.isFinite(X.seekable.end(0))&&(X.currentTime=X.seekable.end(0)))};V&&Ft(X,"play",()=>{X.preload==="metadata"?V.once(zr.default.Events.LEVEL_UPDATED,O):O()},{once:!0})}return O=>{ie||(B=Pi(O)?O:!!O,Xr(X,B))}},Xr=($,X)=>{if(!X)return;let V=$.muted,ie=()=>$.muted=V;switch(X){case Qr.ANY:$.play().catch(()=>{$.muted=!0,$.play().catch(ie)});break;case Qr.MUTED:$.muted=!0,$.play().catch(ie);break;default:$.play().catch(()=>{});break}},na=({preload:$,src:X},V,ie)=>{let Q=U=>{U!=null&&["","none","metadata","auto"].includes(U)?V.setAttribute("preload",U):V.removeAttribute("preload")};if(!ie)return Q($),Q;let B=!1,T=!1,O=ie.config.maxBufferLength,D=ie.config.maxBufferSize,M=U=>{Q(U);let b=U!=null?U:V.preload;T||b==="none"||(b==="metadata"?(ie.config.maxBufferLength=1,ie.config.maxBufferSize=1):(ie.config.maxBufferLength=O,ie.config.maxBufferSize=D),P())},P=()=>{!B&&X&&(B=!0,ie.loadSource(X))};return Ft(V,"play",()=>{T=!0,ie.config.maxBufferLength=O,ie.config.maxBufferSize=D,P()},{once:!0}),M($),M};function aa($,X){X.on(kt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(Q,{tracks:B})=>{B.forEach(T=>{var O;let D=(O=T.subtitleTrack)!=null?O:T.closedCaptions,M=X.subtitleTracks.findIndex(({lang:P,name:U,type:b})=>P==(D==null?void 0:D.lang)&&U===T.label&&b.toLowerCase()===T.kind);ki($,T.kind,T.label,D==null?void 0:D.lang,`${T.kind}${M}`)})});let V=()=>{var Q;if(!X.subtitleTracks.length)return;let B=Array.from($.textTracks).find(O=>O.id&&O.mode==="showing"&&["subtitles","captions"].includes(O.kind)),T=`${(Q=X.subtitleTracks[X.subtitleTrack])==null?void 0:Q.type.toLowerCase()}${X.subtitleTrack}`;if(B&&(X.subtitleTrack<0||(B==null?void 0:B.id)!==T)){let O=X.subtitleTracks.findIndex(({lang:D,name:M,type:P})=>D==B.language&&M===B.label&&P.toLowerCase()===B.kind);X.subtitleTrack=O}B&&(B==null?void 0:B.id)===T&&B.cues&&Array.from(B.cues).forEach(O=>{B.addCue(O)})};$.textTracks.addEventListener("change",V),X.on(kt.default.Events.CUES_PARSED,(Q,{track:B,cues:T})=>{let O=$.textTracks.getTrackById(B);if(!O)return;let D=O.mode==="disabled";D&&(O.mode="hidden"),T.forEach(M=>{var P;(P=O.cues)!=null&&P.getCueById(M.id)||O.addCue(M)}),D&&(O.mode="disabled")}),X.once(kt.default.Events.DESTROYING,()=>{$.textTracks.removeEventListener("change",V),$.querySelectorAll("track[data-removeondestroy]").forEach(Q=>{Q.remove()})});let ie=()=>{Array.from($.textTracks).forEach(Q=>{var B,T;if(!["subtitles","caption"].includes(Q.kind)&&Q.label==="thumbnails"){if(!((B=Q.cues)!=null&&B.length)){let O=$.querySelector('track[label="thumbnails"]'),D=(T=O==null?void 0:O.getAttribute("src"))!=null?T:"";O==null||O.removeAttribute("src"),setTimeout(()=>{O==null||O.setAttribute("src",D)},0)}Q.mode!=="hidden"&&(Q.mode="hidden")}})};X.once(kt.default.Events.MANIFEST_LOADED,ie),X.once(kt.default.Events.MEDIA_ATTACHED,ie)}function ki($,X,V,ie,Q){let B=document.createElement("track");return B.kind=X,B.label=V,ie&&(B.srclang=ie),Q&&(B.id=Q),B.track.mode="disabled",B.setAttribute("data-removeondestroy",""),$.append(B),B.track}var ir="cuepoints",ei=Object.freeze({label:ir}),ti=($,{label:X=ir}=ei)=>{var V;return(V=Array.from($.querySelectorAll("track")).find(ie=>ie.track.label===X&&ie.track.kind==="metadata"))==null?void 0:V.track};async function ri($,X,V=ei){let ie=ti($,V);if(!ie){let{label:Q=ir}=V;ie=ki($,"metadata",Q),ie.mode="hidden",await new Promise(B=>setTimeout(()=>B(void 0),0))}return[...X].sort(({time:Q},{time:B})=>B-Q).forEach(({time:Q,value:B})=>{var T,O;let D=Array.prototype.findIndex.call(ie==null?void 0:ie.cues,A=>A.startTime>=Q),M=(T=ie==null?void 0:ie.cues)==null?void 0:T[D],P=M?M.startTime:Number.isFinite($.duration)?$.duration:Number.MAX_SAFE_INTEGER,U=(O=ie==null?void 0:ie.cues)==null?void 0:O[D-1];U&&(U.endTime=Q);let b=new VTTCue(Q,P,JSON.stringify(B!=null?B:null));ie.addCue(b)}),ie}var Fi=$=>({time:$.startTime,value:JSON.parse($.text)});function Ui($,X={label:ir}){let V=ti($,X);return V!=null&&V.cues?Array.from(V.cues,ie=>Fi(ie)):[]}function ii($,X={label:ir}){var V;let ie=ti($,X);if((V=ie==null?void 0:ie.activeCues)!=null&&V.length)return Fi(ie.activeCues[0])}async function sa($,X=ei){let V=await ri($,[],X);return Ft($,"cuechange",()=>{let ie=ii($);if(ie){let Q=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:ie});$.dispatchEvent(Q)}},{},V),V}var Ri,Ii,oa=(Ii=(Ri=globalThis==null?void 0:globalThis.navigator)==null?void 0:Ri.userAgent)!=null?Ii:"",la=oa.toLowerCase().indexOf("android")!==-1,Nt=new WeakMap,Ni="mux.com",Oi,Ci,Bi=(Ci=(Oi=Rt.default).isSupported)==null?void 0:Ci.call(Oi),ua=la,Ki=()=>xr.default.utils.now(),da=xr.default.utils.generateUUID,Wi=($,{domain:X=Ni}={})=>{if(!$)return;let[V,ie=""]=ea($);return`https://stream.${X}/${V}.m3u8${ie}`},fa=$=>{if(!$)return;let[X]=$.split("?");return X||void 0},ca=$=>{if(!$||!$.startsWith("https://stream."))return;let[X]=new URL($).pathname.slice(1).split(".m3u8");return X||void 0},ha=$=>{var X,V,ie;return(X=$==null?void 0:$.metadata)!=null&&X.video_id?$.metadata.video_id:Vi($)&&(ie=(V=fa($.playbackId))!=null?V:ca($.src))!=null?ie:$.src},Gi=$=>{var X;return(X=Nt.get($))==null?void 0:X.error},Hi=($,X,V)=>{ni(X,V);let{metadata:ie={}}=$,{view_session_id:Q=da()}=ie,B=ha($);ie.view_session_id=Q,ie.video_id=B,$.metadata=ie,Nt.set(X,{});let T=va($,X);ma($,X,T),pa($,X,T),sa(X);let O=ia($,X,T),D=na($,X,T);return{engine:T,setAutoplay:O,setPreload:D}},ni=($,X)=>{let V=X==null?void 0:X.engine;V&&(V.detachMedia(),V.destroy()),($==null?void 0:$.mux)&&!$.mux.deleted&&($.mux.destroy(),delete $.mux),$&&($.removeAttribute("src"),$.load(),$.removeEventListener("error",Xi),$.removeEventListener("error",qr),$.removeEventListener("durationchange",Yi),Nt.delete($),$.dispatchEvent(new Event("teardown")))};function ji($,X){var V;let ie=wi($);if(ie!==Ut.M3U8)return!0;let Q=!ie||((V=X.canPlayType(ie))!=null?V:!0),{preferPlayback:B}=$,T=B===It.MSE,O=B===It.NATIVE;return Q&&(O||!(Bi&&(T||ua)))}var va=($,X)=>{let{debug:V,streamType:ie,startTime:Q=-1,metadata:B,preferCmcd:T}=$,O=wi($)===Ut.M3U8,D=ji($,X);if(O&&!D&&Bi){let M={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},P=ga(ie),U=T!==$r.NONE?{useHeaders:T===$r.HEADER,sessionId:B.view_session_id,contentId:B.video_id}:void 0;return new Rt.default({debug:V,startPosition:Q,cmcd:U,...M,...P})}},ga=$=>[Sr.LIVE,Sr.DVR].includes($)?{backBufferLength:8}:[Sr.LL_LIVE,Sr.LL_DVR].includes($)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Vi=({playbackId:$,src:X,customDomain:V})=>{if($)return!0;if(typeof X!="string")return!1;let ie=window==null?void 0:window.location.href,Q=new URL(X,ie).hostname.toLocaleLowerCase();return Q.includes(Ni)||!!V&&Q.includes(V.toLocaleLowerCase())},ma=($,X,V)=>{var ie;let{envKey:Q}=$,B=Vi($);if(Q||B){let{playerInitTime:T,playerSoftwareName:O,playerSoftwareVersion:D,beaconCollectionDomain:M,debug:P,disableCookies:U}=$,b={...$.metadata,video_title:((ie=$==null?void 0:$.metadata)==null?void 0:ie.video_title)||void 0},A=S=>typeof S.player_error_code=="string"?!1:typeof $.errorTranslator=="function"?$.errorTranslator(S):S;xr.default.monitor(X,{debug:P,beaconCollectionDomain:M,hlsjs:V,Hls:V?Rt.default:void 0,automaticErrorTracking:!1,errorTranslator:A,disableCookies:U,data:{...Q?{env_key:Q}:{},player_software_name:O,player_software:O,player_software_version:D,player_init_time:T,...b}})}},pa=($,X,V)=>{var ie;let Q=ji($,X),{src:B}=$;X&&Q?(typeof B=="string"?(X.setAttribute("src",B),$.startTime&&(((ie=Nt.get(X))!=null?ie:{}).startTime=$.startTime,X.addEventListener("durationchange",Yi,{once:!0}))):X.removeAttribute("src"),X.addEventListener("error",Xi),X.addEventListener("error",qr)):V&&B?(V.on(Rt.default.Events.ERROR,(T,O)=>{let D={[Rt.default.ErrorTypes.NETWORK_ERROR]:ct.MEDIA_ERR_NETWORK,[Rt.default.ErrorTypes.MEDIA_ERROR]:ct.MEDIA_ERR_DECODE},M=new ct("",D[O.type]);M.fatal=O.fatal,M.data=O,X.dispatchEvent(new CustomEvent("error",{detail:M}))}),X.addEventListener("error",qr),aa(X,V),V.attachMedia(X)):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 Yi($){var X;let V=$.target,ie=(X=Nt.get(V))==null?void 0:X.startTime;if(!!ie&&Zn(V.seekable,V.duration,ie)){let Q=V.preload==="auto";Q&&(V.preload="none"),V.currentTime=ie,Q&&(V.preload="auto")}}async function Xi($){if(!$.isTrusted)return;$.stopImmediatePropagation();let X=$.target;if(!(X!=null&&X.error))return;let{message:V,code:ie}=X.error,Q=new ct(V,ie);if(X.src&&(ie!==ct.MEDIA_ERR_DECODE||ie!==void 0))try{let{status:B}=await fetch(X.src);Q.data={response:{code:B}}}catch{}X.dispatchEvent(new CustomEvent("error",{detail:Q}))}function qr($){var X,V;if(!($ instanceof CustomEvent)||!($.detail instanceof ct))return;let ie=$.target,Q=$.detail;!Q||!Q.fatal||(((X=Nt.get(ie))!=null?X:{}).error=Q,(V=ie.mux)==null||V.emit("error",{player_error_code:Q.code,player_error_message:Q.message}))}var ya=()=>{try{return"0.13.0"}catch{}return"UNKNOWN"},Ea=ya(),zi=()=>Ea;var ai=class extends Set{add(X){super.add(new WeakRef(X))}forEach(X){super.forEach(V=>{let ie=V.deref();ie&&X(ie)})}},_a=$=>{var X,V,ie,Q,B,Qi,O,Ar,M,St,U,Dr,A,br,E,$i,f,Ji,p,si,a,s,n,d,l,i,u,nr,c,qi,e,oi,t,Zi,y,li,L,en,I,ui;return X=class extends ${constructor(){super();Ae(this,u);Ae(this,c);Ae(this,e);Ae(this,t);Ae(this,y);Ae(this,L);Ae(this,I);qt(this,"castEnabled",!1);Ae(this,a,{paused:!1});Ae(this,s,void 0);Ae(this,n,{});Ae(this,d,void 0);Ae(this,l,void 0);Ae(this,i,void 0);X.instances.add(this),Ke(this,y,li).call(this)}static get castElement(){return he(X,V)}static get castEnabled(){return he(X,ie)}static get castState(){var K;return(K=he(X,M,St))==null?void 0:K.getCastState()}static async exitCast(){try{await he(X,M,St).endCurrentSession(!0)}catch(H){console.error(H);return}}get castPlayer(){if(X.castElement===this)return he(this,s)}attributeChangedCallback(K){if(!!this.castPlayer)switch(K){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(K={}){var H;Ke(H=X,p,si).call(H,K),Fe(X,V,this),Object.entries(he(this,n)).forEach(([Y,q])=>{he(this,s).controller.addEventListener(Y,q)});try{await he(X,M,St).requestSession()}catch{Fe(X,V,void 0);return}he(this,a).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Y){console.error(Y)}}async load(){var ae,re;if(!this.castPlayer)return super.load();let K=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),H=[...this.querySelectorAll("track")].filter(({kind:se,src:le})=>le&&(se==="subtitles"||se==="captions")),Y=[],q=0;H.length&&(K.tracks=H.map(se=>{let le=++q;Y.length===0&&se.track.mode==="showing"&&Y.push(le);let de=new chrome.cast.media.Track(le,chrome.cast.media.TrackType.TEXT);return de.trackContentId=se.src,de.trackContentType="text/vtt",de.subtype=se.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,de.name=se.label,de.language=se.srclang,de})),this.castStreamType==="live"?K.streamType=chrome.cast.media.StreamType.LIVE:K.streamType=chrome.cast.media.StreamType.BUFFERED,K.metadata=new chrome.cast.media.GenericMediaMetadata,K.metadata.title=this.title,K.metadata.images=[{url:this.poster}];let ee=new chrome.cast.media.LoadRequest(K);ee.currentTime=(ae=super.currentTime)!=null?ae:0,ee.autoplay=!he(this,a).paused,ee.activeTrackIds=Y,await((re=he(X,U,Dr))==null?void 0:re.loadMedia(ee)),this.dispatchEvent(new Event("volumechange"))}play(){var K;if(this.castPlayer){this.castPlayer.isPaused&&((K=this.castPlayer.controller)==null||K.playOrPause());return}return super.play()}pause(){var K;if(this.castPlayer){this.castPlayer.isPaused||(K=this.castPlayer.controller)==null||K.playOrPause();return}super.pause()}get castSrc(){var K,H,Y;return(Y=(H=this.getAttribute("cast-src"))!=null?H:(K=this.querySelector("source"))==null?void 0:K.src)!=null?Y:this.currentSrc}set castSrc(K){this.castSrc!=K&&this.setAttribute("cast-src",`${K}`)}get castContentType(){var K;return(K=this.getAttribute("cast-content-type"))!=null?K:void 0}set castContentType(K){this.setAttribute("cast-content-type",`${K}`)}get castStreamType(){var K;return(K=this.getAttribute("cast-stream-type"))!=null?K:void 0}set castStreamType(K){this.setAttribute("cast-stream-type",`${K}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var K;return this.castPlayer?(K=this.castPlayer)==null?void 0:K.isMuted:super.muted}set muted(K){var H;if(this.castPlayer){(K&&!this.castPlayer.isMuted||!K&&this.castPlayer.isMuted)&&((H=this.castPlayer.controller)==null||H.muteOrUnmute());return}super.muted=K}get volume(){var K,H;return this.castPlayer?(H=(K=this.castPlayer)==null?void 0:K.volumeLevel)!=null?H:1:super.volume}set volume(K){var H;if(this.castPlayer){this.castPlayer.volumeLevel=K,(H=this.castPlayer.controller)==null||H.setVolumeLevel();return}super.volume=K}get duration(){var K,H;return this.castPlayer&&he(this,u,nr)?(H=(K=this.castPlayer)==null?void 0:K.duration)!=null?H:NaN:super.duration}get currentTime(){var K,H;return this.castPlayer&&he(this,u,nr)?(H=(K=this.castPlayer)==null?void 0:K.currentTime)!=null?H:0:super.currentTime}set currentTime(K){var H;if(this.castPlayer){this.castPlayer.currentTime=K,(H=this.castPlayer.controller)==null||H.seek();return}super.currentTime=K}get onentercast(){return he(this,d)}set onentercast(K){he(this,d)&&(this.removeEventListener("entercast",he(this,d)),Fe(this,d,null)),typeof K=="function"&&(Fe(this,d,K),this.addEventListener("entercast",K))}get onleavecast(){return he(this,l)}set onleavecast(K){he(this,l)&&(this.removeEventListener("leavecast",he(this,l)),Fe(this,l,null)),typeof K=="function"&&(Fe(this,l,K),this.addEventListener("leavecast",K))}get oncastchange(){return he(this,i)}set oncastchange(K){he(this,i)&&(this.removeEventListener("castchange",he(this,i)),Fe(this,i,null)),typeof K=="function"&&(Fe(this,i,K),this.addEventListener("castchange",K))}},V=new WeakMap,ie=new WeakMap,Q=new WeakMap,B=new WeakSet,Qi=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},O=new WeakSet,Ar=function(){return typeof cast!="undefined"&&cast.framework},M=new WeakSet,St=function(){if(he(X,O,Ar))return cast.framework.CastContext.getInstance()},U=new WeakSet,Dr=function(){var K;return(K=he(X,M,St))==null?void 0:K.getCurrentSession()},A=new WeakSet,br=function(){var K;return(K=he(X,U,Dr))==null?void 0:K.getSessionObj().media[0]},E=new WeakSet,$i=function(K){return new Promise((H,Y)=>{he(X,A,br).editTracksInfo(K,H,Y)})},f=new WeakSet,Ji=function(K){return new Promise((H,Y)=>{he(X,A,br).getStatus(K,H,Y)})},p=new WeakSet,si=function(K){return he(X,M,St).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...K})},a=new WeakMap,s=new WeakMap,n=new WeakMap,d=new WeakMap,l=new WeakMap,i=new WeakMap,u=new WeakSet,nr=function(){var K;return(K=this.castPlayer)==null?void 0:K.isMediaLoaded},c=new WeakSet,qi=function(){he(X,V)===this&&(Object.entries(he(this,n)).forEach(([K,H])=>{he(this,s).controller.removeEventListener(K,H)}),Fe(X,V,void 0),this.muted=he(this,s).isMuted,this.currentTime=he(this,s).savedPlayerState.currentTime,he(this,s).savedPlayerState.isPaused===!1&&this.play())},e=new WeakSet,oi=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:he(X,M,St).getCastState()}))},t=new WeakSet,Zi=async function(){var H,Y;let{SESSION_RESUMED:K}=cast.framework.SessionState;if(he(X,M,St).getSessionState()===K&&this.castSrc===((H=he(X,A,br))==null?void 0:H.media.contentId)){Fe(X,V,this),Object.entries(he(this,n)).forEach(([q,ee])=>{he(this,s).controller.addEventListener(q,ee)});try{await Ke(Y=X,f,Ji).call(Y,new chrome.cast.media.GetStatusRequest)}catch(q){console.error(q)}he(this,n)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),he(this,n)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},y=new WeakSet,li=function(){var K;!he(X,O,Ar)||this.castEnabled||(this.castEnabled=!0,Ke(K=X,p,si).call(K),this.textTracks.addEventListener("change",Ke(this,I,ui).bind(this)),Ke(this,e,oi).call(this),Fe(this,s,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(he(this,s)),Fe(this,n,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:H})=>{H===!1&&Ke(this,c,qi).call(this),this.dispatchEvent(new Event(H?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!he(this,u,nr)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var H,Y;((H=this.castPlayer)==null?void 0:H.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(Y=this.castPlayer)==null?void 0:Y.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!he(this,u,nr)||(await Promise.resolve(),Ke(this,L,en).call(this))}}))},L=new WeakSet,en=function(){Ke(this,I,ui).call(this)},I=new WeakSet,ui=async function(){var ue,fe,ce,be,Pe,we;if(!this.castPlayer)return;let H=((fe=(ue=he(this,s).mediaInfo)==null?void 0:ue.tracks)!=null?fe:[]).filter(({type:pe})=>pe===chrome.cast.media.TrackType.TEXT),Y=[...this.textTracks].filter(({kind:pe})=>pe==="subtitles"||pe==="captions"),q=H.map(({language:pe,name:Me,trackId:Re})=>{var Le;let{mode:ke}=(Le=Y.find(Ue=>Ue.language===pe&&Ue.label===Me))!=null?Le:{};return ke?{mode:ke,trackId:Re}:!1}).filter(Boolean),ae=q.filter(({mode:pe})=>pe!=="showing").map(({trackId:pe})=>pe),re=q.find(({mode:pe})=>pe==="showing"),se=(Pe=(be=(ce=he(X,U,Dr))==null?void 0:ce.getSessionObj().media[0])==null?void 0:be.activeTrackIds)!=null?Pe:[],le=se;if(se.length&&(le=le.filter(pe=>!ae.includes(pe))),re!=null&&re.trackId&&(le=[...le,re.trackId]),le=[...new Set(le)],!((pe,Me)=>pe.length===Me.length&&pe.every(Re=>Me.includes(Re)))(se,le))try{let pe=new chrome.cast.media.EditTracksInfoRequest(le);await Ke(we=X,E,$i).call(we,pe)}catch(pe){console.error(pe)}},Ae(X,B),Ae(X,O),Ae(X,M),Ae(X,U),Ae(X,A),Ae(X,E),Ae(X,f),Ae(X,p),qt(X,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),qt(X,"instances",new ai),Ae(X,V,void 0),Ae(X,ie,!1),qt(X,"initCast",()=>{var K;he(X,B,Qi)?he(X,O,Ar)?he(K=X,Q).call(K,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var H;return he(H=X,Q).call(H,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var H;return he(H=X,Q).call(H,chrome.cast.isAvailable)})}}),Ae(X,Q,K=>{if(K){Fe(X,ie,!0);let{CAST_STATE_CHANGED:H}=cast.framework.CastContextEventType;he(X,M,St).addEventListener(H,q=>{X.instances.forEach(ee=>{var ae;return Ke(ae=ee,e,oi).call(ae,q)})});let{SESSION_STATE_CHANGED:Y}=cast.framework.CastContextEventType;he(X,M,St).addEventListener(Y,q=>{X.instances.forEach(ee=>{var ae;return Ke(ae=ee,t,Zi).call(ae,q)})}),X.instances.forEach(q=>{var ee;return Ke(ee=q,y,li).call(ee)})}}),X};if(globalThis.HTMLVideoElement&&globalThis.customElements){let $=_a(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",$,{extends:"video"}),globalThis.CastableVideoElement=$),$.initCast()}var tn=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],rn=jr.createElement("template");rn.innerHTML=`
|
|
29
|
+
`),ue=[],_e=(0,or.toMpegTsClockFromTimescale)(l,u),ge="00:00.000",De=0,He=0,Je=!0;P.oncue=function(Ae){var Ke=c[v],je=c.ccOffset,pt=(De-_e)/9e4;Ke!=null&&Ke.new&&(He!==void 0?je=c.ccOffset=Ke.start:function(xt,ir,er){var Yt=xt[ir],nr=xt[Yt.prevCC];if(!nr||!nr.new&&Yt.new)return xt.ccOffset=xt.presentationOffset=Yt.start,void(Yt.new=!1);for(;(_r=nr)!==null&&_r!==void 0&&_r.new;){var _r;xt.ccOffset+=Yt.start-nr.start,Yt.new=!1,nr=xt[(Yt=nr).prevCC]}xt.presentationOffset=er}(c,v,pt)),pt&&(je=pt-c.presentationOffset);var Mt=Ae.endTime-Ae.startTime,mt=(0,mr.normalizePts)(9e4*(Ae.startTime+je-He),9e4*m)/9e4;Ae.startTime=Math.max(mt,0),Ae.endTime=Math.max(mt+Mt,0);var kt=Ae.text.trim();Ae.text=decodeURIComponent(encodeURIComponent(kt)),Ae.id||(Ae.id=hr(Ae.startTime,Ae.endTime,kt)),Ae.endTime>0&&ue.push(Ae)},P.onparsingerror=function(Ae){F=Ae},P.onflush=function(){F?S(F):_(ue)},W.forEach(function(Ae){if(Je){if(yr(Ae,"X-TIMESTAMP-MAP=")){Je=!1,Ae.slice(16).split(",").forEach(function(Ke){yr(Ke,"LOCAL:")?ge=Ke.slice(6):yr(Ke,"MPEGTS:")&&(De=parseInt(Ke.slice(7)))});try{He=function(Ke){var je=parseInt(Ke.slice(-3)),pt=parseInt(Ke.slice(-6,-4)),Mt=parseInt(Ke.slice(-9,-7)),mt=Ke.length>9?parseInt(Ke.substring(0,Ke.indexOf(":"))):0;if(!((0,R.isFiniteNumber)(je)&&(0,R.isFiniteNumber)(pt)&&(0,R.isFiniteNumber)(Mt)&&(0,R.isFiniteNumber)(mt)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+Ke);return je+=1e3*pt,(je+=6e4*Mt)+36e5*mt}(ge)/1e3}catch(Ke){F=Ke}return}Ae===""&&(Je=!1)}P.parse(Ae+`
|
|
30
|
+
`)}),P.flush()})((n=e.initSegment)!==null&&n!==void 0&&n.data?(0,z.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(g.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(s){a._fallbackToIMSC1(e,t),L.logger.log("Failed to parse VTT cue: "+s),r.trigger(g.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||Aa(t,this.initPTS[e.cc],this.timescale[e.cc],function(){n.textCodec=Er,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 it(n,s)})}else{var a=this.tracks[t];if(!a)return;var r=a.default?"default":"subtitles"+t;i.trigger(g.Events.CUES_PARSED,{type:"subtitles",cues:e,track:r})}},o.onFragDecrypted=function(e,t){var i=t.frag;if(i.type===fe.PlaylistLevelType.SUBTITLE){if(!(0,R.isFiniteNumber)(this.initPTS[i.cc]))return void this.unparsedVttFrags.push(t);this.onFragLoaded(g.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!==fe.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 Ct(l[c],i,n)})}if(this.config.renderTextTracksNatively&&i===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return Ct(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 Ds(d,o){return d&&d.label===o.name&&!(d.textTrack1||d.textTrack2)}function Ls(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 Rs=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(g.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),i.on(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.on(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.on(g.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.on(g.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var i=this.hls;i.off(g.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),i.off(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.off(g.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.off(g.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.off(g.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}}])&&Ls(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}(),Is=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(g.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},o.unregisterListeners=function(){this.hls.off(g.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(g.Events.FPS_DROP,{currentDropped:r,currentDecoded:s,totalDroppedFrames:i}),l>0&&r>u.config.fpsDroppedMonitoringThreshold*s){var c=u.currentLevel;L.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(g.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 ai=B(300);function Kn(d){var o=typeof Map=="function"?new Map:void 0;return Kn=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 Hn(e,arguments,qn(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ni(i,e)},Kn(d)}function Hn(d,o,e){return Hn=Cs()?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&&Ni(r,n.prototype),r},Hn.apply(null,arguments)}function Cs(){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 Ni(d,o){return Ni=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ni(d,o)}function qn(d){return qn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},qn(d)}var gn="[eme]",La=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=L.logger.debug.bind(L.logger,gn),this.log=L.logger.log.bind(L.logger,gn),this.warn=L.logger.warn.bind(L.logger,gn),this.error=L.logger.error.bind(L.logger,gn),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(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(g.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(g.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},o.unregisterListeners=function(){this.hls.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(g.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(g.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===K.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 Rr?m:new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.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 Se===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 K.FAIRPLAY:_=["cenc","sinf"];break;case K.WIDEVINE:case K.PLAYREADY:_=["cenc"];break;case K.CLEARKEY:_=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+u)}return function(S,F,P,W){return[{initDataTypes:S,persistentState:W.persistentState||"not-allowed",distinctiveIdentifier:W.distinctiveIdentifier||"not-allowed",sessionTypes:W.sessionTypes||[W.sessionType||"temporary"],audioCapabilities:F.map(function(ue){return{contentType:'audio/mp4; codecs="'+ue+'"',robustness:W.audioRobustness||"",encryptionScheme:W.audioEncryptionScheme||null}}),videoCapabilities:P.map(function(ue){return{contentType:'video/mp4; codecs="'+ue+'"',robustness:W.videoRobustness||"",encryptionScheme:W.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: '+ai.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 ai.default.hexDump(e.keyId)},o.updateKeySession=function(e,t){var i,n=e.mediaKeysSession;return this.log('Updating key-session "'+n.sessionId+'" for keyID '+ai.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=de(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=D(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 Rr?this.hls.trigger(g.Events.ERROR,e.data):this.hls.trigger(g.Events.ERROR,{type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.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]:de(this.config);return this.attemptKeySystemAccess(a)}return i},o.getKeySystemSelectionPromise=function(e){if(e.length||(e=de(this.config)),e.length===0)throw new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.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[K.FAIRPLAY]){var s=(0,z.bin2str)(new Uint8Array(n));try{var l=V(JSON.parse(s).sinf),u=(0,z.parseSinf)(new Uint8Array(l));if(!u)return;a=u.subarray(8,24),r=K.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=(0,z.parsePssh)(n);if(c===null)return;c.version===0&&c.systemId===ke.WIDEVINE&&c.data&&(a=c.data.subarray(8,24)),r=function(ue){if(ue===ke.WIDEVINE)return K.WIDEVINE}(c.systemId)}if(r&&a){for(var v=ai.default.hexDump(a),m=this.keyIdToKeySessionPromise,_=this.mediaKeySessions,S=m[v],F=function(ue){var _e=_[ue],ge=_e.decryptdata;if(ge.pssh||!ge.keyId)return"continue";var De=ai.default.hexDump(ge.keyId);return v===De||ge.uri.replace(/-/g,"").indexOf(v)!==-1?(S=m[De],delete m[De],ge.pssh=new Uint8Array(n),ge.keyId=a,S=m[v]=S.then(function(){return t.generateRequestWithPreferredKeySession(_e,i,n,"encrypted-event-key-match")}),"break"):void 0},P=0;P<_.length;P++){var W=F(P);if(W!=="continue"&&W==="break")break}S||(S=m[v]=this.getKeySystemSelectionPromise([r]).then(function(ue){var _e,ge=ue.keySystem,De=ue.mediaKeys;t.throwIfDestroyed();var He=new Le("ISO-23001-7",v,(_e=D(ge))!=null?_e:"");return He.pssh=new Uint8Array(n),He.keyId=a,t.attemptSetMediaKeys(ge,De).then(function(){t.throwIfDestroyed();var Je=t.createMediaKeySessionContext({decryptdata:He,keySystem:ge,mediaKeys:De});return t.generateRequestWithPreferredKeySession(Je,i,n,"encrypted-event-no-match")})})),S.catch(function(ue){return t.handleError(ue)})}}},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(ti());e.mediaKeysSession.onmessage=function(S){var F=e.mediaKeysSession;if(F){var P=S.messageType,W=S.message;s.log('"'+P+'" message event for session "'+F.sessionId+'" message size: '+W.byteLength),P==="license-request"||P==="license-renewal"?s.renewLicense(e,W).catch(function(ue){s.handleError(ue),m.emit("error",ue)}):P==="license-release"?e.keySystem===K.FAIRPLAY&&(s.updateKeySession(e,E("acknowledged")),s.removeSession(e)):s.warn('unhandled media key message type "'+P+'"')}else m.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(S){if(e.mediaKeysSession){s.onKeyStatusChange(e);var F=e.keyStatus;m.emit("keyStatus",F),F==="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,F){m.on("error",F),m.on("keyStatus",function(P){P.startsWith("usable")?S():P==="output-restricted"?F(new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):P==="internal-error"?F(new Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+P+'"')):P==="expired"?F(new Error("key expired while generating request")):s.warn('unhandled key status change "'+P+'"')})});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 Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.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: '+ai.default.hexDump("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))+" session keyId: "+ai.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 Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.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 Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.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 Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.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 Rr({type:k.ErrorTypes.KEY_SYSTEM_ERROR,details:k.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={},Le.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}();La.CDMCleanupPromise=void 0;var Rr=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,Ni(o,e),t}(Kn(Error));let Ps=La;var fr,Vn,Ra;function Ia(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 Ca(d,o,e){return o&&Ia(d.prototype,o),e&&Ia(d,e),Object.defineProperty(d,"prototype",{writable:!1}),d}function Pa(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 Oa(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)?Oa(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 Oa(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 mn(){return mn=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},mn.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"})(fr||(fr={})),function(d){d.DASH="d",d.HLS="h",d.SMOOTH="s",d.OTHER="o"}(Vn||(Vn={})),function(d){d.VOD="v",d.LIVE="l"}(Ra||(Ra={}));var Os=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:fr.MANIFEST,su:!t.initialized})}catch(r){L.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!==fr.VIDEO&&l!==fr.AUDIO&&l!=fr.MUXED||(u.br=s.bitrate/1e3,u.tb=t.getTopBandwidth(l)/1e3,u.bl=t.getBufferLength(l)),t.apply(a,u)}catch(c){L.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(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(g.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(g.Events.BUFFER_CREATED,this.onBufferCreated,this)},o.unregisterListeners=function(){var e=this.hls;e.off(g.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(g.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(g.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:Vn.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={}),mn(t,this.createData());var i=t.ot===fr.INIT||t.ot===fr.VIDEO||t.ot===fr.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={}),mn(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"?fr.TIMED_TEXT:e.sn==="initSegment"?fr.INIT:t==="audio"?fr.AUDIO:t==="main"?this.hls.audioTracks.length?fr.VIDEO:fr.MUXED:void 0},o.getTopBandwidth=function(e){var t,i=0,n=this.hls;if(e===fr.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=Pa(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===fr.AUDIO?this.audioBuffer:this.videoBuffer;return i&&t?1e3*Gt.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)},Ca(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)},Ca(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=Pa(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}(),xa=B(408),xs=/^age:\s*[\d.]+\s*$/m;let Ma=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 xa.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?(L.logger.error(r+" while loading "+e.url),this.callbacks.onError({code:r,text:t.statusText},e,t)):(L.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(){L.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&&xs.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},d}();function Yn(d){var o=typeof Map=="function"?new Map:void 0;return Yn=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 Wn(e,arguments,Xn(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Ui(i,e)},Yn(d)}function Wn(d,o,e){return Wn=Ms()?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&&Ui(r,n.prototype),r},Wn.apply(null,arguments)}function Ms(){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 Ui(d,o){return Ui=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ui(d,o)}function Xn(d){return Xn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},Xn(d)}function zn(){return zn=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},zn.apply(this,arguments)}var Fs=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||Ns,this.controller=new self.AbortController,this.stats=new xa.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(zn({},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 Us(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 hn,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 Ns(d,o){return new self.Request(d.url,o)}var Us=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,Ui(o,e),t}(Yn(Error));let Fa=Fs;var Bs=/\s/;function Qn(){return Qn=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},Qn.apply(this,arguments)}function Na(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 Ua(d){for(var o=1;o<arguments.length;o++){var e=arguments[o]!=null?arguments[o]:{};o%2?Na(Object(e),!0).forEach(function(t){js(d,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(e)):Na(Object(e)).forEach(function(t){Object.defineProperty(d,t,Object.getOwnPropertyDescriptor(e,t))})}return d}function js(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 Gs=Ua(Ua({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:Ma,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Cn,bufferController:Un,capLevelController:Rs,fpsController:Is,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:Se,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++)Bs.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=Xt(s.trim()),_=hr(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,F){return S.line==="auto"||F.line==="auto"?0:S.line>8&&F.line>8?F.line-S.line:S.line-F.line}),l.forEach(function(S){return it(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:xn,subtitleTrackController:Nn,timelineController:ws,audioStreamController:Oi,audioTrackController:Pn,emeController:Ps,cmcdController:Os});function Ba(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 ja=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 Ri.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(Ae,Ke){if((Ke.liveSyncDurationCount||Ke.liveMaxLatencyDurationCount)&&(Ke.liveSyncDuration||Ke.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(Ke.liveMaxLatencyDurationCount!==void 0&&(Ke.liveSyncDurationCount===void 0||Ke.liveMaxLatencyDurationCount<=Ke.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(Ke.liveMaxLatencyDuration!==void 0&&(Ke.liveSyncDuration===void 0||Ke.liveMaxLatencyDuration<=Ke.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return Qn({},Ae,Ke)}(d.DefaultConfig,n);this.userConfig=n,(0,L.enableLogs)(a.debug,"Hls instance"),this._autoLevelCapping=-1,a.progressive&&function(Ae){var Ke=Ae.loader;Ke!==Fa&&Ke!==Ma?(L.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),Ae.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(Ae.loader=Fa,Ae.progressive=!0,Ae.enableSoftwareAES=!0,L.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 Ve(this),F=new tt(this),P=this.levelController=new ht(this),W=new Dt(this),ue=new pr(this.config),_e=this.streamController=new Ln(this,W,ue);m.setStreamController(_e),_.setStreamController(_e);var ge=[S,P,_e];this.networkControllers=ge;var De=[c,v,m,_,F,W];this.audioTrackController=this.createController(a.audioTrackController,ge);var He=a.audioStreamController;He&&ge.push(new He(this,W,ue)),this.subtitleTrackController=this.createController(a.subtitleTrackController,ge);var Je=a.subtitleStreamController;Je&&ge.push(new Je(this,W,ue)),this.createController(a.timelineController,De),ue.emeController=this.emeController=this.createController(a.emeController,De),this.cmcdController=this.createController(a.cmcdController,De),this.latencyController=this.createController(Ut,De),this.coreComponents=De}d.isSupported=function(){return function(){var n=fi();if(!n)return!1;var a=vi(),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){L.logger.error("An internal error happened while handling event "+n+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(g.Events.ERROR,{type:k.ErrorTypes.OTHER_ERROR,details:k.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:n,error:r})}return!1},i.listenerCount=function(n){return this._emitter.listenerCount(n)},i.destroy=function(){L.logger.log("destroy"),this.trigger(g.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){L.logger.log("attachMedia"),this._media=n,this.trigger(g.Events.MEDIA_ATTACHING,{media:n})},i.detachMedia=function(){L.logger.log("detachMedia"),this.trigger(g.Events.MEDIA_DETACHING,void 0),this._media=null},i.loadSource=function(n){this.stopLoad();var a=this.media,r=this.url,s=this.url=re.buildAbsoluteURL(self.location.href,n,{alwaysNormalize:!0});L.logger.log("loadSource:"+s),a&&r&&r!==s&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(a)),this.trigger(g.Events.MANIFEST_LOADING,{url:n})},i.startLoad=function(n){n===void 0&&(n=-1),L.logger.log("startLoad("+n+")"),this.networkControllers.forEach(function(a){a.startLoad(n)})},i.stopLoad=function(){L.logger.log("stopLoad"),this.networkControllers.forEach(function(n){n.stopLoad()})},i.swapAudioCodec=function(){L.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},i.recoverMediaError=function(){L.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 g.Events}},{key:"ErrorTypes",get:function(){return k.ErrorTypes}},{key:"ErrorDetails",get:function(){return k.ErrorDetails}},{key:"DefaultConfig",get:function(){return d.defaultConfig?d.defaultConfig:Gs},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){L.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){L.logger.log("set nextLevel:"+n),this.levelController.manualLevel=n,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(n){L.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){L.logger.log("set firstLevel:"+n),this.levelController.firstLevel=n}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(n){L.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&&(L.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){ar.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}}])&&Ba(o.prototype,e),t&&Ba(o,t),Object.defineProperty(o,"prototype",{writable:!1}),d}();ja.defaultConfig=void 0},923:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{BaseSegment:()=>ce,ElementaryStreamTypes:()=>j,Fragment:()=>we,Part:()=>q});var j,re=B(965),R=B(945),g=B(408);function k(ye,J){ye.prototype=Object.create(J.prototype),ye.prototype.constructor=ye,L(ye,J)}function L(ye,J){return L=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(se,K){return se.__proto__=K,se},L(ye,J)}function me(ye,J){for(var se=0;se<J.length;se++){var K=J[se];K.enumerable=K.enumerable||!1,K.configurable=!0,"value"in K&&(K.writable=!0),Object.defineProperty(ye,typeof(Ee=function(ke,Ne){if(typeof ke!="object"||ke===null)return ke;var V=ke[Symbol.toPrimitive];if(V!==void 0){var E=V.call(ke,Ne);if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(ke)}(K.key,"string"))=="symbol"?Ee:String(Ee),K)}var Ee}function ne(ye,J,se){return J&&me(ye.prototype,J),se&&me(ye,se),Object.defineProperty(ye,"prototype",{writable:!1}),ye}(function(ye){ye.AUDIO="audio",ye.VIDEO="video",ye.AUDIOVIDEO="audiovideo"})(j||(j={}));var ce=function(){function ye(J){var se;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((se={})[j.AUDIO]=null,se[j.VIDEO]=null,se[j.AUDIOVIDEO]=null,se),this.baseurl=J}return ye.prototype.setByteRange=function(J,se){var K=J.split("@",2),Ee=[];K.length===1?Ee[0]=se?se.byteRangeEndOffset:0:Ee[0]=parseInt(K[1]),Ee[1]=parseInt(K[0])+Ee[0],this._byteRange=Ee},ne(ye,[{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(J){this._url=J}}]),ye}(),we=function(ye){function J(K,Ee){var ke;return(ke=ye.call(this,Ee)||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 g.LoadStats,ke.urlId=0,ke.data=void 0,ke.bitrateTest=!1,ke.title=null,ke.initSegment=null,ke.endList=void 0,ke.type=K,ke}k(J,ye);var se=J.prototype;return se.setKeyFormat=function(K){if(this.levelkeys){var Ee=this.levelkeys[K];Ee&&!this._decryptdata&&(this._decryptdata=Ee.getDecryptData(this.sn))}},se.abortRequests=function(){var K,Ee;(K=this.loader)===null||K===void 0||K.abort(),(Ee=this.keyLoader)===null||Ee===void 0||Ee.abort()},se.setElementaryStreamInfo=function(K,Ee,ke,Ne,V,E){E===void 0&&(E=!1);var U=this.elementaryStreams,D=U[K];D?(D.startPTS=Math.min(D.startPTS,Ee),D.endPTS=Math.max(D.endPTS,ke),D.startDTS=Math.min(D.startDTS,Ne),D.endDTS=Math.max(D.endDTS,V)):U[K]={startPTS:Ee,endPTS:ke,startDTS:Ne,endDTS:V,partial:E}},se.clearElementaryStreamInfo=function(){var K=this.elementaryStreams;K[j.AUDIO]=null,K[j.VIDEO]=null,K[j.AUDIOVIDEO]=null},ne(J,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var K=this.levelkeys.identity;if(K)this._decryptdata=K.getDecryptData(this.sn);else{var Ee=Object.keys(this.levelkeys);if(Ee.length===1)return this._decryptdata=this.levelkeys[Ee[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,re.isFiniteNumber)(this.programDateTime))return null;var K=(0,re.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*K}},{key:"encrypted",get:function(){var K;if((K=this._decryptdata)!==null&&K!==void 0&&K.encrypted)return!0;if(this.levelkeys){var Ee=Object.keys(this.levelkeys),ke=Ee.length;if(ke>1||ke===1&&this.levelkeys[Ee[0]].encrypted)return!0}return!1}}]),J}(ce),q=function(ye){function J(se,K,Ee,ke,Ne){var V;(V=ye.call(this,Ee)||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 g.LoadStats,V.duration=se.decimalFloatingPoint("DURATION"),V.gap=se.bool("GAP"),V.independent=se.bool("INDEPENDENT"),V.relurl=se.enumeratedString("URI"),V.fragment=K,V.index=ke;var E=se.enumeratedString("BYTERANGE");return E&&V.setByteRange(E,Ne),Ne&&(V.fragOffset=Ne.fragOffset+Ne.duration),V}return k(J,ye),ne(J,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var se=this.elementaryStreams;return!!(se.audio||se.video||se.audiovideo)}}]),J}(ce)},408:(oe,X,B)=>{"use strict";B.r(X),B.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:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{MAX_SAFE_INTEGER:()=>re,isFiniteNumber:()=>j});var j=Number.isFinite||function(R){return typeof R=="number"&&isFinite(R)},re=Number.MAX_SAFE_INTEGER||9007199254740991},524:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{default:()=>se,flushTextTrackMetadataCueSamples:()=>Ee,flushTextTrackUserdataCueSamples:()=>ke,normalizePts:()=>K});var j=B(965);let re=function(){function E(){}return E.getSilentFrame=function(U,D){if(U==="mp4a.40.2"){if(D===1)return new Uint8Array([0,200,0,128,35,128]);if(D===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(D===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(D===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(D===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(D===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(D===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(D===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(D===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,g=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 D=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]),de=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:D,audio:de};var Se=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),z=new Uint8Array([0,0,0,0,0,0,0,0]);E.STTS=E.STSC=E.STCO=z,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 $=new Uint8Array([105,115,111,109]),Le=new Uint8Array([97,118,99,49]),Oe=new Uint8Array([0,0,0,1]);E.FTYP=E.box(E.types.ftyp,$,Oe,$,Le),E.DINF=E.box(E.types.dinf,E.box(E.types.dref,Se))},E.box=function(U){for(var D=8,de=arguments.length,Se=new Array(de>1?de-1:0),z=1;z<de;z++)Se[z-1]=arguments[z];for(var $=Se.length,Le=$;$--;)D+=Se[$].byteLength;var Oe=new Uint8Array(D);for(Oe[0]=D>>24&255,Oe[1]=D>>16&255,Oe[2]=D>>8&255,Oe[3]=255&D,Oe.set(U,4),$=0,D=8;$<Le;$++)Oe.set(Se[$],D),D+=Se[$].byteLength;return Oe},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,D){D*=U;var de=Math.floor(D/(R+1)),Se=Math.floor(D%(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,de>>24,de>>16&255,de>>8&255,255&de,Se>>24,Se>>16&255,Se>>8&255,255&Se,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,D,de){return E.box(E.types.moof,E.mfhd(U),E.traf(de,D))},E.moov=function(U){for(var D=U.length,de=[];D--;)de[D]=E.trak(U[D]);return E.box.apply(null,[E.types.moov,E.mvhd(U[0].timescale,U[0].duration)].concat(de).concat(E.mvex(U)))},E.mvex=function(U){for(var D=U.length,de=[];D--;)de[D]=E.trex(U[D]);return E.box.apply(null,[E.types.mvex].concat(de))},E.mvhd=function(U,D){D*=U;var de=Math.floor(D/(R+1)),Se=Math.floor(D%(R+1)),z=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,de>>24,de>>16&255,de>>8&255,255&de,Se>>24,Se>>16&255,Se>>8&255,255&Se,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,z)},E.sdtp=function(U){var D,de,Se=U.samples||[],z=new Uint8Array(4+Se.length);for(D=0;D<Se.length;D++)de=Se[D].flags,z[D+4]=de.dependsOn<<4|de.isDependedOn<<2|de.hasRedundancy;return E.box(E.types.sdtp,z)},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 D,de,Se,z=[],$=[];for(D=0;D<U.sps.length;D++)Se=(de=U.sps[D]).byteLength,z.push(Se>>>8&255),z.push(255&Se),z=z.concat(Array.prototype.slice.call(de));for(D=0;D<U.pps.length;D++)Se=(de=U.pps[D]).byteLength,$.push(Se>>>8&255),$.push(255&Se),$=$.concat(Array.prototype.slice.call(de));var Le=E.box(E.types.avcC,new Uint8Array([1,z[3],z[4],z[5],255,224|U.sps.length].concat(z).concat([U.pps.length]).concat($))),Oe=U.width,xe=U.height,be=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,Oe>>8&255,255&Oe,xe>>8&255,255&xe,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]),Le,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([be>>24,be>>16&255,be>>8&255,255&be,qe>>24,qe>>16&255,qe>>8&255,255&qe])))},E.esds=function(U){var D=U.config.length;return new Uint8Array([0,0,0,0,3,23+D,0,1,0,4,15+D,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([D]).concat(U.config).concat([6,1,2]))},E.mp4a=function(U){var D=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,D>>8&255,255&D,0,0]),E.box(E.types.esds,E.esds(U)))},E.mp3=function(U){var D=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,D>>8&255,255&D,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 D=U.id,de=U.duration*U.timescale,Se=U.width,z=U.height,$=Math.floor(de/(R+1)),Le=Math.floor(de%(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,D>>24&255,D>>16&255,D>>8&255,255&D,0,0,0,0,$>>24,$>>16&255,$>>8&255,255&$,Le>>24,Le>>16&255,Le>>8&255,255&Le,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,Se>>8&255,255&Se,0,0,z>>8&255,255&z,0,0]))},E.traf=function(U,D){var de=E.sdtp(U),Se=U.id,z=Math.floor(D/(R+1)),$=Math.floor(D%(R+1));return E.box(E.types.traf,E.box(E.types.tfhd,new Uint8Array([0,0,0,0,Se>>24,Se>>16&255,Se>>8&255,255&Se])),E.box(E.types.tfdt,new Uint8Array([1,0,0,0,z>>24,z>>16&255,z>>8&255,255&z,$>>24,$>>16&255,$>>8&255,255&$])),E.trun(U,de.length+16+20+8+16+8+8),de)},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 D=U.id;return E.box(E.types.trex,new Uint8Array([0,0,0,0,D>>24,D>>16&255,D>>8&255,255&D,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},E.trun=function(U,D){var de,Se,z,$,Le,Oe,xe=U.samples||[],be=xe.length,qe=12+16*be,at=new Uint8Array(qe);for(D+=8+qe,at.set([U.type==="video"?1:0,0,15,1,be>>>24&255,be>>>16&255,be>>>8&255,255&be,D>>>24&255,D>>>16&255,D>>>8&255,255&D],0),de=0;de<be;de++)z=(Se=xe[de]).duration,$=Se.size,Le=Se.flags,Oe=Se.cts,at.set([z>>>24&255,z>>>16&255,z>>>8&255,255&z,$>>>24&255,$>>>16&255,$>>>8&255,255&$,Le.isLeading<<2|Le.dependsOn,Le.isDependedOn<<6|Le.hasRedundancy<<4|Le.paddingValue<<1|Le.isNonSync,61440&Le.degradPrio,15&Le.degradPrio,Oe>>>24&255,Oe>>>16&255,Oe>>>8&255,255&Oe],12+16*de);return E.box(E.types.trun,at)},E.initSegment=function(U){E.types||E.init();var D=E.moov(U),de=new Uint8Array(E.FTYP.byteLength+D.byteLength);return de.set(E.FTYP),de.set(D,E.FTYP.byteLength),de},E}();g.types=void 0,g.HDLR_TYPES=void 0,g.STTS=void 0,g.STSC=void 0,g.STCO=void 0,g.STSZ=void 0,g.VMHD=void 0,g.SMHD=void 0,g.STSD=void 0,g.FTYP=void 0,g.DINF=void 0;let k=g;var L=B(851),me=B(973),ne=B(93),ce=B(308),we=B(673);function q(){return q=Object.assign?Object.assign.bind():function(E){for(var U=1;U<arguments.length;U++){var D=arguments[U];for(var de in D)Object.prototype.hasOwnProperty.call(D,de)&&(E[de]=D[de])}return E},q.apply(this,arguments)}var ye=null,J=null,se=function(){function E(D,de,Se,z){if(z===void 0&&(z=""),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=D,this.config=de,this.typeSupported=Se,this.ISGenerated=!1,ye===null){var $=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ye=$?parseInt($[1]):0}if(J===null){var Le=navigator.userAgent.match(/Safari\/(\d+)/i);J=Le?parseInt(Le[1]):0}}var U=E.prototype;return U.destroy=function(){},U.resetTimeStamp=function(D){ne.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=D},U.resetNextTimestamp=function(){ne.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},U.resetInitSegment=function(){ne.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},U.getVideoStartPts=function(D){var de=!1,Se=D.reduce(function(z,$){var Le=$.pts-z;return Le<-4294967296?(de=!0,K(z,$.pts)):Le>0?z:$.pts},D[0].pts);return de&&ne.logger.debug("PTS rollover detected"),Se},U.remux=function(D,de,Se,z,$,Le,Oe,xe){var be,qe,at,ie,pe,ae,Ue=$,H=$,ve=D.pid>-1,Ie=de.pid>-1,Fe=de.samples.length,fe=D.samples.length>0,Ce=Oe&&Fe>0||Fe>1;if((!ve||fe)&&(!Ie||Ce)||this.ISGenerated||Oe){this.ISGenerated||(at=this.generateIS(D,de,$));var Ve,Xe=this.isVideoContiguous,it=-1;if(Ce&&(it=function(wt){for(var gt=0;gt<wt.length;gt++)if(wt[gt].key)return gt;return-1}(de.samples),!Xe&&this.config.forceKeyFrameOnDiscontinuity))if(ae=!0,it>0){ne.logger.warn("[mp4-remuxer]: Dropped "+it+" out of "+Fe+" video samples due to a missing keyframe");var lt=this.getVideoStartPts(de.samples);de.samples=de.samples.slice(it),de.dropped+=it,Ve=H+=(de.samples[0].pts-lt)/de.inputTimeScale}else it===-1&&(ne.logger.warn("[mp4-remuxer]: No keyframe found out of "+Fe+" video samples"),ae=!1);if(this.ISGenerated){if(fe&&Ce){var Ct=this.getVideoStartPts(de.samples),Rt=(K(D.samples[0].pts,Ct)-Ct)/de.inputTimeScale;Ue+=Math.max(0,Rt),H+=Math.max(0,-Rt)}if(fe){if(D.samplerate||(ne.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),at=this.generateIS(D,de,$)),qe=this.remuxAudio(D,Ue,this.isAudioContiguous,Le,Ie||Ce||xe===ce.PlaylistLevelType.AUDIO?H:void 0),Ce){var St=qe?qe.endPTS-qe.startPTS:0;de.inputTimeScale||(ne.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),at=this.generateIS(D,de,$)),be=this.remuxVideo(de,H,Xe,St)}}else Ce&&(be=this.remuxVideo(de,H,Xe,0));be&&(be.firstKeyFrame=it,be.independent=it!==-1,be.firstKeyFramePTS=Ve)}}return this.ISGenerated&&(Se.samples.length&&(pe=Ee(Se,$,this._initPTS,this._initDTS)),z.samples.length&&(ie=ke(z,$,this._initPTS))),{audio:qe,video:be,initSegment:at,independent:ae,text:ie,id3:pe}},U.generateIS=function(D,de,Se){var z,$,Le,Oe=D.samples,xe=de.samples,be=this.typeSupported,qe={},at=!(0,j.isFiniteNumber)(this._initPTS),ie="audio/mp4";if(at&&(z=$=1/0),D.config&&Oe.length&&(D.timescale=D.samplerate,D.segmentCodec==="mp3"&&(be.mpeg?(ie="audio/mpeg",D.codec=""):be.mp3&&(D.codec="mp3")),qe.audio={id:"audio",container:ie,codec:D.codec,initSegment:D.segmentCodec==="mp3"&&be.mpeg?new Uint8Array(0):k.initSegment([D]),metadata:{channelCount:D.channelCount}},at&&(Le=D.inputTimeScale,z=$=Oe[0].pts-Math.round(Le*Se))),de.sps&&de.pps&&xe.length&&(de.timescale=de.inputTimeScale,qe.video={id:"main",container:"video/mp4",codec:de.codec,initSegment:k.initSegment([de]),metadata:{width:de.width,height:de.height}},at)){Le=de.inputTimeScale;var pe=this.getVideoStartPts(xe),ae=Math.round(Le*Se);$=Math.min($,K(xe[0].dts,pe)-ae),z=Math.min(z,pe-ae)}if(Object.keys(qe).length)return this.ISGenerated=!0,at&&(this._initPTS=z,this._initDTS=$),{tracks:qe,initPTS:z,timescale:Le}},U.remuxVideo=function(D,de,Se,z){var $,Le,Oe=D.inputTimeScale,xe=D.samples,be=[],qe=xe.length,at=this._initPTS,ie=this.nextAvcDts,pe=8,ae=this.videoSampleDuration,Ue=Number.POSITIVE_INFINITY,H=Number.NEGATIVE_INFINITY,ve=!1;Se&&ie!==null||(ie=de*Oe-(xe[0].pts-K(xe[0].dts,xe[0].pts)));for(var Ie=0;Ie<qe;Ie++){var Fe=xe[Ie];Fe.pts=K(Fe.pts-at,ie),Fe.dts=K(Fe.dts-at,ie),Fe.dts<xe[Ie>0?Ie-1:Ie].dts&&(ve=!0)}ve&&xe.sort(function(Jt,pr){var Cr=Jt.dts-pr.dts,vr=Jt.pts-pr.pts;return Cr||vr}),$=xe[0].dts;var fe=xe[xe.length-1].dts-$,Ce=fe?Math.round(fe/(qe-1)):ae||D.inputTimeScale/30;if(Se){var Ve=$-ie,Xe=Ve>Ce,it=Ve<-1;if((Xe||it)&&(Xe?ne.logger.warn("AVC: "+(0,we.toMsFromMpegTsClock)(Ve,!0)+" ms ("+Ve+"dts) hole between fragments detected, filling it"):ne.logger.warn("AVC: "+(0,we.toMsFromMpegTsClock)(-Ve,!0)+" ms ("+Ve+"dts) overlapping between fragments detected"),!it||ie>xe[0].pts)){$=ie;var lt=xe[0].pts-Ve;xe[0].dts=$,xe[0].pts=lt,ne.logger.log("Video: First PTS/DTS adjusted: "+(0,we.toMsFromMpegTsClock)(lt,!0)+"/"+(0,we.toMsFromMpegTsClock)($,!0)+", delta: "+(0,we.toMsFromMpegTsClock)(Ve,!0)+" ms")}}$=Math.max(0,$);for(var Ct=0,Rt=0,St=0;St<qe;St++){for(var wt=xe[St],gt=wt.units,dt=gt.length,tt=0,It=0;It<dt;It++)tt+=gt[It].data.length;Rt+=tt,Ct+=dt,wt.length=tt,wt.dts=Math.max(wt.dts,$),Ue=Math.min(wt.pts,Ue),H=Math.max(wt.pts,H)}Le=xe[qe-1].dts;var Ut,Wt=Rt+4*Ct+8;try{Ut=new Uint8Array(Wt)}catch{return void this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:me.ErrorTypes.MUX_ERROR,details:me.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Wt,reason:"fail allocating video mdat "+Wt})}var Bt=new DataView(Ut.buffer);Bt.setUint32(0,Wt),Ut.set(k.types.mdat,4);for(var ar=!1,te=Number.POSITIVE_INFINITY,N=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,O=Number.NEGATIVE_INFINITY,C=0;C<qe;C++){for(var G=xe[C],Q=G.units,Z=0,Te=0,Re=Q.length;Te<Re;Te++){var Pe=Q[Te],Be=Pe.data,We=Pe.data.byteLength;Bt.setUint32(pe,We),pe+=4,Ut.set(Be,pe),pe+=We,Z+=4+We}var Ge=void 0;if(C<qe-1)ae=xe[C+1].dts-G.dts,Ge=xe[C+1].pts-G.pts;else{var $e=this.config,ht=C>0?G.dts-xe[C-1].dts:Ce;if(Ge=C>0?G.pts-xe[C-1].pts:Ce,$e.stretchShortVideoTrack&&this.nextAudioPts!==null){var Dt=Math.floor($e.maxBufferHole*Oe),ze=(z?Ue+z*Oe:this.nextAudioPts)-G.pts;ze>Dt?((ae=ze-ht)<0?ae=ht:ar=!0,ne.logger.log("[mp4-remuxer]: It is approximately "+ze/90+" ms to the next segment; using duration "+ae/90+" ms for the last video frame.")):ae=ht}else ae=ht}var Pt=Math.round(G.pts-G.dts);te=Math.min(te,ae),T=Math.max(T,ae),N=Math.min(N,Ge),O=Math.max(O,Ge),be.push(new Ne(G.key,ae,Z,Pt))}if(be.length){if(ye){if(ye<70){var tr=be[0].flags;tr.dependsOn=2,tr.isNonSync=0}}else if(J&&O-N<T-te&&Ce/T<.025&&be[0].cts===0){ne.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var jt=$,Ft=0,Ht=be.length;Ft<Ht;Ft++){var rt=jt+be[Ft].duration,lr=jt+be[Ft].cts;if(Ft<Ht-1){var Ar=rt+be[Ft+1].cts;be[Ft].duration=Ar-lr}else be[Ft].duration=Ft?be[Ft-1].duration:Ce;be[Ft].cts=0,jt=rt}}}ae=ar||!ae?Ce:ae,this.nextAvcDts=ie=Le+ae,this.videoSampleDuration=ae,this.isVideoContiguous=!0;var Kt={data1:k.moof(D.sequenceNumber++,$,q({},D,{samples:be})),data2:Ut,startPTS:Ue/Oe,endPTS:(H+ae)/Oe,startDTS:$/Oe,endDTS:ie/Oe,type:"video",hasAudio:!1,hasVideo:!0,nb:be.length,dropped:D.dropped};return D.samples=[],D.dropped=0,Kt},U.remuxAudio=function(D,de,Se,z,$){var Le=D.inputTimeScale,Oe=Le/(D.samplerate?D.samplerate:Le),xe=D.segmentCodec==="aac"?1024:1152,be=xe*Oe,qe=this._initPTS,at=D.segmentCodec==="mp3"&&this.typeSupported.mpeg,ie=[],pe=$!==void 0,ae=D.samples,Ue=at?0:8,H=this.nextAudioPts||-1,ve=de*Le;if(this.isAudioContiguous=Se=Se||ae.length&&H>0&&(z&&Math.abs(ve-H)<9e3||Math.abs(K(ae[0].pts-qe,ve)-H)<20*be),ae.forEach(function(Te){Te.pts=K(Te.pts-qe,ve)}),!Se||H<0){if(ae=ae.filter(function(Te){return Te.pts>=0}),!ae.length)return;H=$===0?0:z&&!pe?Math.max(0,ve):ae[0].pts}if(D.segmentCodec==="aac")for(var Ie=this.config.maxAudioFramesDrift,Fe=0,fe=H;Fe<ae.length;Fe++){var Ce=ae[Fe],Ve=Ce.pts,Xe=Ve-fe,it=Math.abs(1e3*Xe/Le);if(Xe<=-Ie*be&&pe)Fe===0&&(ne.logger.warn("Audio frame @ "+(Ve/Le).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Xe/Le)+" ms."),this.nextAudioPts=H=fe=Ve);else if(Xe>=Ie*be&&it<1e4&&pe){var lt=Math.round(Xe/be);(fe=Ve-lt*be)<0&&(lt--,fe+=be),Fe===0&&(this.nextAudioPts=H=fe),ne.logger.warn("[mp4-remuxer]: Injecting "+lt+" audio frame @ "+(fe/Le).toFixed(3)+"s due to "+Math.round(1e3*Xe/Le)+" ms gap.");for(var Ct=0;Ct<lt;Ct++){var Rt=Math.max(fe,0),St=re.getSilentFrame(D.manifestCodec||D.codec,D.channelCount);St||(ne.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),St=Ce.unit.subarray()),ae.splice(Fe,0,{unit:St,pts:Rt}),fe+=be,Fe++}}Ce.pts=fe,fe+=be}for(var wt,gt=null,dt=null,tt=0,It=ae.length;It--;)tt+=ae[It].unit.byteLength;for(var Ut=0,Wt=ae.length;Ut<Wt;Ut++){var Bt=ae[Ut],ar=Bt.unit,te=Bt.pts;if(dt!==null)ie[Ut-1].duration=Math.round((te-dt)/Oe);else{if(Se&&D.segmentCodec==="aac"&&(te=H),gt=te,!(tt>0))return;tt+=Ue;try{wt=new Uint8Array(tt)}catch{return void this.observer.emit(L.Events.ERROR,L.Events.ERROR,{type:me.ErrorTypes.MUX_ERROR,details:me.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:tt,reason:"fail allocating audio mdat "+tt})}at||(new DataView(wt.buffer).setUint32(0,tt),wt.set(k.types.mdat,4))}wt.set(ar,Ue);var N=ar.byteLength;Ue+=N,ie.push(new Ne(!0,xe,N,0)),dt=te}var T=ie.length;if(T){var O=ie[ie.length-1];this.nextAudioPts=H=dt+Oe*O.duration;var C=at?new Uint8Array(0):k.moof(D.sequenceNumber++,gt/Oe,q({},D,{samples:ie}));D.samples=[];var G=gt/Le,Q=H/Le,Z={data1:C,data2:wt,startPTS:G,endPTS:Q,startDTS:G,endDTS:Q,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,Z}},U.remuxEmptyAudio=function(D,de,Se,z){var $=D.inputTimeScale,Le=$/(D.samplerate?D.samplerate:$),Oe=this.nextAudioPts,xe=(Oe!==null?Oe:z.startDTS*$)+this._initDTS,be=z.endDTS*$+this._initDTS,qe=1024*Le,at=Math.ceil((be-xe)/qe),ie=re.getSilentFrame(D.manifestCodec||D.codec,D.channelCount);if(ne.logger.warn("[mp4-remuxer]: remux empty Audio"),ie){for(var pe=[],ae=0;ae<at;ae++){var Ue=xe+ae*qe;pe.push({unit:ie,pts:Ue,dts:Ue})}return D.samples=pe,this.remuxAudio(D,de,Se,!1)}ne.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},E}();function K(E,U){var D;if(U===null)return E;for(D=U<E?-8589934592:8589934592;Math.abs(E-U)>4294967296;)E+=D;return E}function Ee(E,U,D,de){var Se=E.samples.length;if(Se){for(var z=E.inputTimeScale,$=0;$<Se;$++){var Le=E.samples[$];Le.pts=K(Le.pts-D,U*z)/z,Le.dts=K(Le.dts-de,U*z)/z}var Oe=E.samples;return E.samples=[],{samples:Oe}}}function ke(E,U,D){var de=E.samples.length;if(de){for(var Se=E.inputTimeScale,z=0;z<de;z++){var $=E.samples[z];$.pts=K($.pts-D,U*Se)/Se}E.samples.sort(function(Oe,xe){return Oe.pts-xe.pts});var Le=E.samples;return E.samples=[],{samples:Le}}}var Ne=function(E,U,D,de){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=U,this.size=D,this.cts=de,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:(oe,X,B)=>{"use strict";var j;B.r(X),B.d(X,{MetadataSchema:()=>j}),function(re){re.audioId3="org.id3",re.dateRange="com.apple.quicktime.HLS",re.emsg="https://aomedia.org/emsg/ID3"}(j||(j={}))},308:(oe,X,B)=>{"use strict";var j,re;B.r(X),B.d(X,{PlaylistContextType:()=>j,PlaylistLevelType:()=>re}),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"}(re||(re={}))},300:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{default:()=>j});let j={hexDump:function(re){for(var R="",g=0;g<re.length;g++){var k=re[g].toString(16);k.length<2&&(k="0"+k),R+=k}return R}}},93:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{enableLogs:()=>k,logger:()=>L});var j=function(){},re={trace:j,debug:j,log:j,warn:j,info:j,error:j},R=re;function g(me){var ne=self.console[me];return ne?ne.bind(self.console,"["+me+"] >"):j}function k(me,ne){if(self.console&&me===!0||typeof me=="object"){(function(ce){for(var we=arguments.length,q=new Array(we>1?we-1:0),ye=1;ye<we;ye++)q[ye-1]=arguments[ye];q.forEach(function(J){R[J]=ce[J]?ce[J].bind(ce):g(J)})})(me,"debug","log","info","warn","error");try{R.log('Debug logs enabled for "'+ne+'"')}catch{R=re}}else R=re}var L=re},63:(oe,X,B)=>{"use strict";B.r(X),B.d(X,{RemuxerTrackIdConfig:()=>ne,appendUint8Array:()=>Se,bin2str:()=>ce,computeRawDurationFromSamples:()=>U,discardEPB:()=>Oe,findBox:()=>se,getDuration:()=>E,getStartDTS:()=>V,mp4Box:()=>be,mp4pssh:()=>qe,offsetStartDTS:()=>D,parseEmsg:()=>xe,parseInitSegment:()=>Ee,parsePssh:()=>at,parseSEIMessageFromNALu:()=>Le,parseSamples:()=>z,parseSegmentIndex:()=>K,parseSinf:()=>Ne,patchEncyptionData:()=>ke,readSint32:()=>ye,readUint16:()=>we,readUint32:()=>q,segmentValidRange:()=>de,writeUint32:()=>J});var j=B(923),re=B(145),R=B(181),g=B(93),k=B(300),L=Math.pow(2,32)-1,me=[].push,ne={video:1,audio:2,id3:3,text:4};function ce(ie){return String.fromCharCode.apply(null,ie)}function we(ie,pe){var ae=ie[pe]<<8|ie[pe+1];return ae<0?65536+ae:ae}function q(ie,pe){var ae=ye(ie,pe);return ae<0?4294967296+ae:ae}function ye(ie,pe){return ie[pe]<<24|ie[pe+1]<<16|ie[pe+2]<<8|ie[pe+3]}function J(ie,pe,ae){ie[pe]=ae>>24,ie[pe+1]=ae>>16&255,ie[pe+2]=ae>>8&255,ie[pe+3]=255&ae}function se(ie,pe){var ae=[];if(!pe.length)return ae;for(var Ue=ie.byteLength,H=0;H<Ue;){var ve=q(ie,H),Ie=ve>1?H+ve:Ue;if(ce(ie.subarray(H+4,H+8))===pe[0])if(pe.length===1)ae.push(ie.subarray(H+8,Ie));else{var Fe=se(ie.subarray(H+8,Ie),pe.slice(1));Fe.length&&me.apply(ae,Fe)}H=Ie}return ae}function K(ie){var pe=[],ae=ie[0],Ue=8,H=q(ie,Ue);Ue+=4,Ue+=ae===0?8:16,Ue+=2;var ve=ie.length+0,Ie=we(ie,Ue);Ue+=2;for(var Fe=0;Fe<Ie;Fe++){var fe=Ue,Ce=q(ie,fe);fe+=4;var Ve=2147483647&Ce;if((2147483648&Ce)>>>31==1)return console.warn("SIDX has hierarchical references (not supported)"),null;var Xe=q(ie,fe);fe+=4,pe.push({referenceSize:Ve,subsegmentDuration:Xe,info:{duration:Xe/H,start:ve,end:ve+Ve-1}}),ve+=Ve,Ue=fe+=4}return{earliestPresentationTime:0,timescale:H,version:ae,referencesCount:Ie,references:pe}}function Ee(ie){for(var pe=[],ae=se(ie,["moov","trak"]),Ue=0;Ue<ae.length;Ue++){var H=ae[Ue],ve=se(H,["tkhd"])[0];if(ve){var Ie=ve[0],Fe=Ie===0?12:20,fe=q(ve,Fe),Ce=se(H,["mdia","mdhd"])[0];if(Ce){var Ve=q(Ce,Fe=(Ie=Ce[0])===0?12:20),Xe=se(H,["mdia","hdlr"])[0];if(Xe){var it=ce(Xe.subarray(8,12)),lt={soun:j.ElementaryStreamTypes.AUDIO,vide:j.ElementaryStreamTypes.VIDEO}[it];if(lt){var Ct=se(H,["mdia","minf","stbl","stsd"])[0],Rt=void 0;Ct&&(Rt=ce(Ct.subarray(12,16))),pe[fe]={timescale:Ve,type:lt},pe[lt]={timescale:Ve,id:fe,codec:Rt}}}}}}return se(ie,["moov","mvex","trex"]).forEach(function(St){var wt=q(St,4),gt=pe[wt];gt&&(gt.default={duration:q(St,12),flags:q(St,20)})}),pe}function ke(ie,pe){if(!ie||!pe)return ie;var ae=pe.keyId;return ae&&pe.isCommonEncryption&&se(ie,["moov","trak"]).forEach(function(Ue){var H=se(Ue,["mdia","minf","stbl","stsd"])[0].subarray(8),ve=se(H,["enca"]),Ie=ve.length>0;Ie||(ve=se(H,["encv"])),ve.forEach(function(Fe){se(Ie?Fe.subarray(28):Fe.subarray(78),["sinf"]).forEach(function(fe){var Ce=Ne(fe);if(Ce){var Ve=Ce.subarray(8,24);Ve.some(function(Xe){return Xe!==0})||(g.logger.log("[eme] Patching keyId in 'enc"+(Ie?"a":"v")+">sinf>>tenc' box: "+k.default.hexDump(Ve)+" -> "+k.default.hexDump(ae)),Ce.set(ae,8))}})})}),ie}function Ne(ie){var pe=se(ie,["schm"])[0];if(pe){var ae=ce(pe.subarray(4,8));if(ae==="cbcs"||ae==="cenc")return se(ie,["schi","tenc"])[0]}return g.logger.error("[eme] missing 'schm' box"),null}function V(ie,pe){return se(pe,["moof","traf"]).reduce(function(ae,Ue){var H=se(Ue,["tfdt"])[0],ve=H[0],Ie=se(Ue,["tfhd"]).reduce(function(Fe,fe){var Ce=q(fe,4),Ve=ie[Ce];if(Ve){var Xe=q(H,4);ve===1&&(Xe*=Math.pow(2,32),Xe+=q(H,8));var it=Xe/(Ve.timescale||9e4);if(isFinite(it)&&(Fe===null||it<Fe))return it}return Fe},null);return Ie!==null&&isFinite(Ie)&&(ae===null||Ie<ae)?Ie:ae},null)||0}function E(ie,pe){for(var ae=0,Ue=0,H=0,ve=se(ie,["moof","traf"]),Ie=0;Ie<ve.length;Ie++){var Fe=ve[Ie],fe=se(Fe,["tfhd"])[0],Ce=pe[q(fe,4)];if(Ce){var Ve=Ce.default,Xe=q(fe,0)|(Ve==null?void 0:Ve.flags),it=Ve==null?void 0:Ve.duration;8&Xe&&(it=q(fe,2&Xe?12:8));for(var lt=Ce.timescale||9e4,Ct=se(Fe,["trun"]),Rt=0;Rt<Ct.length;Rt++)!(ae=U(Ct[Rt]))&&it&&(ae=it*q(Ct[Rt],4)),Ce.type===j.ElementaryStreamTypes.VIDEO?Ue+=ae/lt:Ce.type===j.ElementaryStreamTypes.AUDIO&&(H+=ae/lt)}}if(Ue===0&&H===0){for(var St=0,wt=se(ie,["sidx"]),gt=0;gt<wt.length;gt++){var dt=K(wt[gt]);dt!=null&&dt.references&&(St+=dt.references.reduce(function(tt,It){return tt+It.info.duration||0},0))}return St}return Ue||H}function U(ie){var pe=q(ie,0),ae=8;1&pe&&(ae+=4),4&pe&&(ae+=4);for(var Ue=0,H=q(ie,4),ve=0;ve<H;ve++)256&pe&&(Ue+=q(ie,ae),ae+=4),512&pe&&(ae+=4),1024&pe&&(ae+=4),2048&pe&&(ae+=4);return Ue}function D(ie,pe,ae){se(pe,["moof","traf"]).forEach(function(Ue){se(Ue,["tfhd"]).forEach(function(H){var ve=q(H,4),Ie=ie[ve];if(Ie){var Fe=Ie.timescale||9e4;se(Ue,["tfdt"]).forEach(function(fe){var Ce=fe[0],Ve=q(fe,4);if(Ce===0)Ve-=ae*Fe,J(fe,4,Ve=Math.max(Ve,0));else{Ve*=Math.pow(2,32),Ve+=q(fe,8),Ve-=ae*Fe,Ve=Math.max(Ve,0);var Xe=Math.floor(Ve/(L+1)),it=Math.floor(Ve%(L+1));J(fe,4,Xe),J(fe,8,it)}})}})})}function de(ie){var pe={valid:null,remainder:null},ae=se(ie,["moof"]);if(!ae)return pe;if(ae.length<2)return pe.remainder=ie,pe;var Ue=ae[ae.length-1];return pe.valid=(0,re.sliceUint8)(ie,0,Ue.byteOffset-8),pe.remainder=(0,re.sliceUint8)(ie,Ue.byteOffset-8),pe}function Se(ie,pe){var ae=new Uint8Array(ie.length+pe.length);return ae.set(ie),ae.set(pe,ie.length),ae}function z(ie,pe){var ae=[],Ue=pe.samples,H=pe.timescale,ve=pe.id,Ie=!1;return se(Ue,["moof"]).map(function(Fe){var fe=Fe.byteOffset-8;se(Fe,["traf"]).map(function(Ce){var Ve=se(Ce,["tfdt"]).map(function(Xe){var it=Xe[0],lt=q(Xe,4);return it===1&&(lt*=Math.pow(2,32),lt+=q(Xe,8)),lt/H})[0];return Ve!==void 0&&(ie=Ve),se(Ce,["tfhd"]).map(function(Xe){var it=q(Xe,4),lt=16777215&q(Xe,0),Ct=0,Rt=(16<)!=0,St=0,wt=(32<)!=0,gt=8;it===ve&&((1<)!=0&&(gt+=8),(2<)!=0&&(gt+=4),(8<)!=0&&(Ct=q(Xe,gt),gt+=4),Rt&&(St=q(Xe,gt),gt+=4),wt&&(gt+=4),pe.type==="video"&&(Ie=function(dt){if(!dt)return!1;var tt=dt.indexOf("."),It=tt<0?dt:dt.substring(0,tt);return It==="hvc1"||It==="hev1"||It==="dvh1"||It==="dvhe"}(pe.codec)),se(Ce,["trun"]).map(function(dt){var tt=dt[0],It=16777215&q(dt,0),Ut=(1&It)!=0,Wt=0,Bt=(4&It)!=0,ar=(256&It)!=0,te=0,N=(512&It)!=0,T=0,O=(1024&It)!=0,C=(2048&It)!=0,G=0,Q=q(dt,4),Z=8;Ut&&(Wt=q(dt,Z),Z+=4),Bt&&(Z+=4);for(var Te=Wt+fe,Re=0;Re<Q;Re++){if(ar?(te=q(dt,Z),Z+=4):te=Ct,N?(T=q(dt,Z),Z+=4):T=St,O&&(Z+=4),C&&(G=tt===0?q(dt,Z):ye(dt,Z),Z+=4),pe.type===j.ElementaryStreamTypes.VIDEO)for(var Pe=0;Pe<T;){var Be=q(Ue,Te);$(Ie,Ue[Te+=4])&&Le(Ue.subarray(Te,Te+Be),Ie?2:1,ie+G/H,ae),Te+=Be,Pe+=Be+4}ie+=te/H}}))})})}),ae}function $(ie,pe){if(ie){var ae=pe>>1&63;return ae===39||ae===40}return(31&pe)==6}function Le(ie,pe,ae,Ue){var H=Oe(ie),ve=0;ve+=pe;for(var Ie=0,Fe=0,fe=!1,Ce=0;ve<H.length;){Ie=0;do{if(ve>=H.length)break;Ie+=Ce=H[ve++]}while(Ce===255);Fe=0;do{if(ve>=H.length)break;Fe+=Ce=H[ve++]}while(Ce===255);var Ve=H.length-ve;if(!fe&&Ie===4&&ve<H.length){if(fe=!0,H[ve++]===181){var Xe=we(H,ve);if(ve+=2,Xe===49){var it=q(H,ve);if(ve+=4,it===1195456820){var lt=H[ve++];if(lt===3){var Ct=H[ve++],Rt=64&Ct,St=Rt?2+3*(31&Ct):0,wt=new Uint8Array(St);if(Rt){wt[0]=Ct;for(var gt=1;gt<St;gt++)wt[gt]=H[ve++]}Ue.push({type:lt,payloadType:Ie,pts:ae,bytes:wt})}}}}}else if(Ie===5&&Fe<Ve){if(fe=!0,Fe>16){for(var dt=[],tt=0;tt<16;tt++){var It=H[ve++].toString(16);dt.push(It.length==1?"0"+It:It),tt!==3&&tt!==5&&tt!==7&&tt!==9||dt.push("-")}for(var Ut=Fe-16,Wt=new Uint8Array(Ut),Bt=0;Bt<Ut;Bt++)Wt[Bt]=H[ve++];Ue.push({payloadType:Ie,pts:ae,uuid:dt.join(""),userData:(0,R.utf8ArrayToStr)(Wt),userDataBytes:Wt})}}else if(Fe<Ve)ve+=Fe;else if(Fe>Ve)break}}function Oe(ie){for(var pe=ie.byteLength,ae=[],Ue=1;Ue<pe-2;)ie[Ue]===0&&ie[Ue+1]===0&&ie[Ue+2]===3?(ae.push(Ue+2),Ue+=2):Ue++;if(ae.length===0)return ie;var H=pe-ae.length,ve=new Uint8Array(H),Ie=0;for(Ue=0;Ue<H;Ie++,Ue++)Ie===ae[0]&&(Ie++,ae.shift()),ve[Ue]=ie[Ie];return ve}function xe(ie){var pe=ie[0],ae="",Ue="",H=0,ve=0,Ie=0,Fe=0,fe=0,Ce=0;if(pe===0){for(;ce(ie.subarray(Ce,Ce+1))!=="\0";)ae+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;for(ae+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;ce(ie.subarray(Ce,Ce+1))!=="\0";)Ue+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;Ue+=ce(ie.subarray(Ce,Ce+1)),Ce+=1,H=q(ie,12),ve=q(ie,16),Fe=q(ie,20),fe=q(ie,24),Ce=28}else if(pe===1){H=q(ie,Ce+=4);var Ve=q(ie,Ce+=4),Xe=q(ie,Ce+=4);for(Ce+=4,Ie=Math.pow(2,32)*Ve+Xe,Number.isSafeInteger(Ie)||(Ie=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),Fe=q(ie,Ce),fe=q(ie,Ce+=4),Ce+=4;ce(ie.subarray(Ce,Ce+1))!=="\0";)ae+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;for(ae+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;ce(ie.subarray(Ce,Ce+1))!=="\0";)Ue+=ce(ie.subarray(Ce,Ce+1)),Ce+=1;Ue+=ce(ie.subarray(Ce,Ce+1)),Ce+=1}return{schemeIdUri:ae,value:Ue,timeScale:H,presentationTime:Ie,presentationTimeDelta:ve,eventDuration:Fe,id:fe,payload:ie.subarray(Ce,ie.byteLength)}}function be(ie){for(var pe=arguments.length,ae=new Array(pe>1?pe-1:0),Ue=1;Ue<pe;Ue++)ae[Ue-1]=arguments[Ue];for(var H=ae.length,ve=8,Ie=H;Ie--;)ve+=ae[Ie].byteLength;var Fe=new Uint8Array(ve);for(Fe[0]=ve>>24&255,Fe[1]=ve>>16&255,Fe[2]=ve>>8&255,Fe[3]=255&ve,Fe.set(ie,4),Ie=0,ve=8;Ie<H;Ie++)Fe.set(ae[Ie],ve),ve+=ae[Ie].byteLength;return Fe}function qe(ie,pe,ae){if(ie.byteLength!==16)throw new RangeError("Invalid system id");var Ue,H,ve;if(pe){Ue=1,H=new Uint8Array(16*pe.length);for(var Ie=0;Ie<pe.length;Ie++){var Fe=pe[Ie];if(Fe.byteLength!==16)throw new RangeError("Invalid key");H.set(Fe,16*Ie)}}else Ue=0,H=new Uint8Array;Ue>0?(ve=new Uint8Array(4),pe.length>0&&new DataView(ve.buffer).setUint32(0,pe.length,!1)):ve=new Uint8Array;var fe=new Uint8Array(4);return ae&&ae.byteLength>0&&new DataView(fe.buffer).setUint32(0,ae.byteLength,!1),be([112,115,115,104],new Uint8Array([Ue,0,0,0]),ie,ve,H,fe,ae||new Uint8Array)}function at(ie){if(!(ie instanceof ArrayBuffer)||ie.byteLength<32)return null;var pe={version:0,systemId:"",kids:null,data:null},ae=new DataView(ie),Ue=ae.getUint32(0);if(ie.byteLength!==Ue&&Ue>44||ae.getUint32(4)!==1886614376||(pe.version=ae.getUint32(8)>>>24,pe.version>1))return null;pe.systemId=k.default.hexDump(new Uint8Array(ie,12,16));var H=ae.getUint32(28);if(pe.version===0){if(Ue-32<H)return null;pe.data=new Uint8Array(ie,32,H)}else if(pe.version===1){pe.kids=[];for(var ve=0;ve<H;ve++)pe.kids.push(new Uint8Array(ie,32+16*ve,16))}return pe}},673:(oe,X,B)=>{"use strict";function j(k,L,me,ne){me===void 0&&(me=1),ne===void 0&&(ne=!1);var ce=k*L*me;return ne?Math.round(ce):ce}function re(k,L,me,ne){return me===void 0&&(me=1),ne===void 0&&(ne=!1),j(k,L,1/me,ne)}function R(k,L){return L===void 0&&(L=!1),j(k,1e3,11111111111111112e-21,L)}function g(k,L){return L===void 0&&(L=1),j(k,9e4,1/L)}B.r(X),B.d(X,{toMpegTsClockFromTimescale:()=>g,toMsFromMpegTsClock:()=>R,toTimescaleFromBase:()=>j,toTimescaleFromScale:()=>re})},145:(oe,X,B)=>{"use strict";function j(re,R,g){return Uint8Array.prototype.slice?re.slice(R,g):new Uint8Array(Array.prototype.slice.call(re,R,g))}B.r(X),B.d(X,{sliceUint8:()=>j})},729:oe=>{"use strict";var X=Object.prototype.hasOwnProperty,B="~";function j(){}function re(L,me,ne){this.fn=L,this.context=me,this.once=ne||!1}function R(L,me,ne,ce,we){if(typeof ne!="function")throw new TypeError("The listener must be a function");var q=new re(ne,ce||L,we),ye=B?B+me:me;return L._events[ye]?L._events[ye].fn?L._events[ye]=[L._events[ye],q]:L._events[ye].push(q):(L._events[ye]=q,L._eventsCount++),L}function g(L,me){--L._eventsCount==0?L._events=new j:delete L._events[me]}function k(){this._events=new j,this._eventsCount=0}Object.create&&(j.prototype=Object.create(null),new j().__proto__||(B=!1)),k.prototype.eventNames=function(){var L,me,ne=[];if(this._eventsCount===0)return ne;for(me in L=this._events)X.call(L,me)&&ne.push(B?me.slice(1):me);return Object.getOwnPropertySymbols?ne.concat(Object.getOwnPropertySymbols(L)):ne},k.prototype.listeners=function(L){var me=B?B+L:L,ne=this._events[me];if(!ne)return[];if(ne.fn)return[ne.fn];for(var ce=0,we=ne.length,q=new Array(we);ce<we;ce++)q[ce]=ne[ce].fn;return q},k.prototype.listenerCount=function(L){var me=B?B+L:L,ne=this._events[me];return ne?ne.fn?1:ne.length:0},k.prototype.emit=function(L,me,ne,ce,we,q){var ye=B?B+L:L;if(!this._events[ye])return!1;var J,se,K=this._events[ye],Ee=arguments.length;if(K.fn){switch(K.once&&this.removeListener(L,K.fn,void 0,!0),Ee){case 1:return K.fn.call(K.context),!0;case 2:return K.fn.call(K.context,me),!0;case 3:return K.fn.call(K.context,me,ne),!0;case 4:return K.fn.call(K.context,me,ne,ce),!0;case 5:return K.fn.call(K.context,me,ne,ce,we),!0;case 6:return K.fn.call(K.context,me,ne,ce,we,q),!0}for(se=1,J=new Array(Ee-1);se<Ee;se++)J[se-1]=arguments[se];K.fn.apply(K.context,J)}else{var ke,Ne=K.length;for(se=0;se<Ne;se++)switch(K[se].once&&this.removeListener(L,K[se].fn,void 0,!0),Ee){case 1:K[se].fn.call(K[se].context);break;case 2:K[se].fn.call(K[se].context,me);break;case 3:K[se].fn.call(K[se].context,me,ne);break;case 4:K[se].fn.call(K[se].context,me,ne,ce);break;default:if(!J)for(ke=1,J=new Array(Ee-1);ke<Ee;ke++)J[ke-1]=arguments[ke];K[se].fn.apply(K[se].context,J)}}return!0},k.prototype.on=function(L,me,ne){return R(this,L,me,ne,!1)},k.prototype.once=function(L,me,ne){return R(this,L,me,ne,!0)},k.prototype.removeListener=function(L,me,ne,ce){var we=B?B+L:L;if(!this._events[we])return this;if(!me)return g(this,we),this;var q=this._events[we];if(q.fn)q.fn!==me||ce&&!q.once||ne&&q.context!==ne||g(this,we);else{for(var ye=0,J=[],se=q.length;ye<se;ye++)(q[ye].fn!==me||ce&&!q[ye].once||ne&&q[ye].context!==ne)&&J.push(q[ye]);J.length?this._events[we]=J.length===1?J[0]:J:g(this,we)}return this},k.prototype.removeAllListeners=function(L){var me;return L?(me=B?B+L:L,this._events[me]&&g(this,me)):(this._events=new j,this._eventsCount=0),this},k.prototype.off=k.prototype.removeListener,k.prototype.addListener=k.prototype.on,k.prefixed=B,k.EventEmitter=k,oe.exports=k},945:function(oe){var X,B,j,re,R;X=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,B=/^(?=([^\/?#]*))\1([^]*)$/,j=/(?:\/|^)\.(?=\/)/g,re=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,R={buildAbsoluteURL:function(g,k,L){if(L=L||{},g=g.trim(),!(k=k.trim())){if(!L.alwaysNormalize)return g;var me=R.parseURL(g);if(!me)throw new Error("Error trying to parse base URL.");return me.path=R.normalizePath(me.path),R.buildURLFromParts(me)}var ne=R.parseURL(k);if(!ne)throw new Error("Error trying to parse relative URL.");if(ne.scheme)return L.alwaysNormalize?(ne.path=R.normalizePath(ne.path),R.buildURLFromParts(ne)):k;var ce=R.parseURL(g);if(!ce)throw new Error("Error trying to parse base URL.");if(!ce.netLoc&&ce.path&&ce.path[0]!=="/"){var we=B.exec(ce.path);ce.netLoc=we[1],ce.path=we[2]}ce.netLoc&&!ce.path&&(ce.path="/");var q={scheme:ce.scheme,netLoc:ne.netLoc,path:null,params:ne.params,query:ne.query,fragment:ne.fragment};if(!ne.netLoc&&(q.netLoc=ce.netLoc,ne.path[0]!=="/"))if(ne.path){var ye=ce.path,J=ye.substring(0,ye.lastIndexOf("/")+1)+ne.path;q.path=R.normalizePath(J)}else q.path=ce.path,ne.params||(q.params=ce.params,ne.query||(q.query=ce.query));return q.path===null&&(q.path=L.alwaysNormalize?R.normalizePath(ne.path):ne.path),R.buildURLFromParts(q)},parseURL:function(g){var k=X.exec(g);return k?{scheme:k[1]||"",netLoc:k[2]||"",path:k[3]||"",params:k[4]||"",query:k[5]||"",fragment:k[6]||""}:null},normalizePath:function(g){for(g=g.split("").reverse().join("").replace(j,"");g.length!==(g=g.replace(re,"")).length;);return g.split("").reverse().join("")},buildURLFromParts:function(g){return g.scheme+g.netLoc+g.path+g.params+g.query+g.fragment}},oe.exports=R}},w={};function A(oe){var X=w[oe];if(X!==void 0)return X.exports;var B=w[oe]={exports:{}};return x[oe].call(B.exports,B,B.exports,A),B.exports}A.m=x,A.n=oe=>{var X=oe&&oe.__esModule?()=>oe.default:()=>oe;return A.d(X,{a:X}),X},A.d=(oe,X)=>{for(var B in X)A.o(X,B)&&!A.o(oe,B)&&Object.defineProperty(oe,B,{enumerable:!0,get:X[B]})},A.o=(oe,X)=>Object.prototype.hasOwnProperty.call(oe,X),A.r=oe=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(oe,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(oe,"__esModule",{value:!0})};var le=A(76);return le.default})())});var bi=class{addEventListener(){}removeEventListener(){}dispatchEvent(w){return!0}};if(typeof DocumentFragment=="undefined"){class x extends bi{}globalThis.DocumentFragment=x}var Hi=class extends bi{},ea=class extends bi{},zs={get(x){},define(x,w,A){},upgrade(x){},whenDefined(x){return Promise.resolve(Hi)}},qi,ta=class{constructor(w,A={}){bt(this,qi,void 0);Nt(this,qi,A==null?void 0:A.detail)}get detail(){return Ye(this,qi)}initCustomEvent(){}};qi=new WeakMap;function Qs(x,w){return new Hi}var Ha={document:{createElement:Qs},DocumentFragment,customElements:zs,CustomEvent:ta,EventTarget:bi,HTMLElement:Hi,HTMLVideoElement:ea},qa=typeof window=="undefined"||typeof globalThis.customElements=="undefined",xr=qa?Ha:globalThis,ra=qa?Ha.document:globalThis.document;var bn=Ka(Va(),1),$a=Ka(Ya(),1),Js=$a.default,Sr=Js,Yi=class extends Error{constructor(x,w=Yi.MEDIA_ERR_CUSTOM,A){var le;super(x),this.name="MediaError",this.code=w,this.fatal=A!=null?A:w>=Yi.MEDIA_ERR_NETWORK&&w<=Yi.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(le=Yi.defaultMessages[this.code])!=null?le:"")}},Tr=Yi;Tr.MEDIA_ERR_ABORTED=1,Tr.MEDIA_ERR_NETWORK=2,Tr.MEDIA_ERR_DECODE=3,Tr.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Tr.MEDIA_ERR_ENCRYPTED=5,Tr.MEDIA_ERR_CUSTOM=100,Tr.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 $s=x=>x==null,Za=(x,w)=>$s(w)?!1:x in w,sa={ANY:"any",MUTED:"muted"},Tn={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},oi={MSE:"mse",NATIVE:"native"},oa={HEADER:"header",QUERY:"query",NONE:"none"},da=Object.values(oa),_i={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},la={HLS:_i.M3U8},Io=Object.keys(la),Co=[...Object.values(_i),"hls","HLS"],si=(x,w,A,le,oe=x)=>{oe.addEventListener(w,A,le),x.addEventListener("teardown",()=>{oe.removeEventListener(w,A)},{once:!0})};function Zs(x,w,A){w&&A>w&&(A=w);for(let le=0;le<x.length;le++)if(x.start(le)<=A&&x.end(le)>=A)return!0;return!1}var eo=x=>{let w=x.indexOf("?");if(w<0)return[x];let A=x.slice(0,w),le=x.slice(w);return[A,le]},es=x=>{let w=x.type;if(w){let le=w.toUpperCase();return Za(le,la)?la[le]:w}let{src:A}=x;return A?to(A):""},to=x=>{let w="";try{w=new URL(x).pathname}catch{console.error("invalid url")}let A=w.lastIndexOf(".");if(A<0)return"";let le=w.slice(A+1).toUpperCase();return Za(le,_i)?_i[le]:""},ro=Object.values(sa),Wa=x=>typeof x=="boolean"||typeof x=="string"&&ro.includes(x),io=({autoplay:x},w,A)=>{let le=!1,oe=!1,X=Wa(x)?x:!!x,B=()=>{le||si(w,"playing",()=>{le=!0},{once:!0})};if(B(),si(w,"loadstart",()=>{le=!1,B(),aa(w,X)},{once:!0}),si(w,"loadstart",()=>{A||(oe=!Number.isFinite(w.duration)),aa(w,X)},{once:!0}),A&&A.once(Sr.Events.LEVEL_LOADED,(j,re)=>{var R;oe=(R=re.details.live)!=null?R:!1}),!X){let j=()=>{!oe||(A!=null&&A.liveSyncPosition?w.currentTime=A.liveSyncPosition:Number.isFinite(w.seekable.end(0))&&(w.currentTime=w.seekable.end(0)))};A&&si(w,"play",()=>{w.preload==="metadata"?A.once(Sr.Events.LEVEL_UPDATED,j):j()},{once:!0})}return j=>{le||(X=Wa(j)?j:!!j,aa(w,X))}},aa=(x,w)=>{if(!w)return;let A=x.muted,le=()=>x.muted=A;switch(w){case sa.ANY:x.play().catch(()=>{x.muted=!0,x.play().catch(le)});break;case sa.MUTED:x.muted=!0,x.play().catch(le);break;default:x.play().catch(()=>{});break}},no=({preload:x,src:w},A,le)=>{let oe=k=>{k!=null&&["","none","metadata","auto"].includes(k)?A.setAttribute("preload",k):A.removeAttribute("preload")};if(!le)return oe(x),oe;let X=!1,B=!1,j=le.config.maxBufferLength,re=le.config.maxBufferSize,R=k=>{oe(k);let L=k!=null?k:A.preload;B||L==="none"||(L==="metadata"?(le.config.maxBufferLength=1,le.config.maxBufferSize=1):(le.config.maxBufferLength=j,le.config.maxBufferSize=re),g())},g=()=>{!X&&w&&(X=!0,le.loadSource(w))};return si(A,"play",()=>{B=!0,le.config.maxBufferLength=j,le.config.maxBufferSize=re,g()},{once:!0}),R(x),R};function ao(x,w){w.on(Sr.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(oe,{tracks:X})=>{X.forEach(B=>{var j;let re=(j=B.subtitleTrack)!=null?j:B.closedCaptions,R=w.subtitleTracks.findIndex(({lang:g,name:k,type:L})=>g==(re==null?void 0:re.lang)&&k===B.label&&L.toLowerCase()===B.kind);ts(x,B.kind,B.label,re==null?void 0:re.lang,`${B.kind}${R}`)})});let A=()=>{var oe;if(!w.subtitleTracks.length)return;let X=Array.from(x.textTracks).find(j=>j.id&&j.mode==="showing"&&["subtitles","captions"].includes(j.kind)),B=`${(oe=w.subtitleTracks[w.subtitleTrack])==null?void 0:oe.type.toLowerCase()}${w.subtitleTrack}`;if(X&&(w.subtitleTrack<0||(X==null?void 0:X.id)!==B)){let j=w.subtitleTracks.findIndex(({lang:re,name:R,type:g})=>re==X.language&&R===X.label&&g.toLowerCase()===X.kind);w.subtitleTrack=j}X&&(X==null?void 0:X.id)===B&&X.cues&&Array.from(X.cues).forEach(j=>{X.addCue(j)})};x.textTracks.addEventListener("change",A),w.on(Sr.Events.CUES_PARSED,(oe,{track:X,cues:B})=>{let j=x.textTracks.getTrackById(X);if(!j)return;let re=j.mode==="disabled";re&&(j.mode="hidden"),B.forEach(R=>{var g;(g=j.cues)!=null&&g.getCueById(R.id)||j.addCue(R)}),re&&(j.mode="disabled")}),w.once(Sr.Events.DESTROYING,()=>{x.textTracks.removeEventListener("change",A),x.querySelectorAll("track[data-removeondestroy]").forEach(oe=>{oe.remove()})});let le=()=>{Array.from(x.textTracks).forEach(oe=>{var X,B;if(!["subtitles","caption"].includes(oe.kind)&&oe.label==="thumbnails"){if(!((X=oe.cues)!=null&&X.length)){let j=x.querySelector('track[label="thumbnails"]'),re=(B=j==null?void 0:j.getAttribute("src"))!=null?B:"";j==null||j.removeAttribute("src"),setTimeout(()=>{j==null||j.setAttribute("src",re)},0)}oe.mode!=="hidden"&&(oe.mode="hidden")}})};w.once(Sr.Events.MANIFEST_LOADED,le),w.once(Sr.Events.MEDIA_ATTACHED,le)}function ts(x,w,A,le,oe){let X=document.createElement("track");return X.kind=w,X.label=A,le&&(X.srclang=le),oe&&(X.id=oe),X.track.mode=["subtitles","captions"].includes(w)?"disabled":"hidden",X.setAttribute("data-removeondestroy",""),x.append(X),X.track}var Wi="cuepoints",ca=Object.freeze({label:Wi}),ha=(x,{label:w=Wi}=ca)=>{var A;return(A=Array.from(x.querySelectorAll("track")).find(le=>le.track.label===w&&le.track.kind==="metadata"))==null?void 0:A.track};async function fa(x,w,A=ca){let le=ha(x,A);if(!le){let{label:oe=Wi}=A;le=ts(x,"metadata",oe),le.mode="hidden",await new Promise(X=>setTimeout(()=>X(void 0),0))}return le.mode!=="hidden"&&(le.mode="hidden"),[...w].sort(({time:oe},{time:X})=>X-oe).forEach(({time:oe,value:X})=>{var B,j;let re=Array.prototype.findIndex.call(le==null?void 0:le.cues,me=>me.startTime>=oe),R=(B=le==null?void 0:le.cues)==null?void 0:B[re],g=R?R.startTime:Number.isFinite(x.duration)?x.duration:Number.MAX_SAFE_INTEGER,k=(j=le==null?void 0:le.cues)==null?void 0:j[re-1];k&&(k.endTime=oe);let L=new VTTCue(oe,g,JSON.stringify(X!=null?X:null));le.addCue(L)}),le}var rs=x=>({time:x.startTime,value:JSON.parse(x.text)});function is(x,w={label:Wi}){let A=ha(x,w);return A!=null&&A.cues?Array.from(A.cues,le=>rs(le)):[]}function va(x,w={label:Wi}){var A;let le=ha(x,w);if((A=le==null?void 0:le.activeCues)!=null&&A.length)return rs(le.activeCues[0])}async function so(x,w=ca){return new Promise(A=>{si(x,"loadstart",async()=>{let le=await fa(x,[],w);si(x,"cuechange",()=>{let oe=va(x);if(oe){let X=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:oe});x.dispatchEvent(X)}},{},le),A(le)})})}var Xa,za,oo=(za=(Xa=globalThis==null?void 0:globalThis.navigator)==null?void 0:Xa.userAgent)!=null?za:"",lo=oo.toLowerCase().indexOf("android")!==-1,Si=new WeakMap,ns="mux.com",Qa,Ja,as=(Ja=(Qa=Sr).isSupported)==null?void 0:Ja.call(Qa),uo=lo,ss=()=>bn.default.utils.now(),co=bn.default.utils.generateUUID,os=(x,{domain:w=ns}={})=>{if(!x)return;let[A,le=""]=eo(x);return`https://stream.${w}/${A}.m3u8${le}`},ho=x=>{if(!x)return;let[w]=x.split("?");return w||void 0},fo=x=>{if(!x||!x.startsWith("https://stream."))return;let[w]=new URL(x).pathname.slice(1).split(".m3u8");return w||void 0},vo=x=>{var w,A,le;return(w=x==null?void 0:x.metadata)!=null&&w.video_id?x.metadata.video_id:cs(x)&&(le=(A=ho(x.playbackId))!=null?A:fo(x.src))!=null?le:x.src},ls=x=>{var w;return(w=Si.get(x))==null?void 0:w.error},us=(x,w,A)=>{pa(w,A);let{metadata:le={}}=x,{view_session_id:oe=co()}=le,X=vo(x);le.view_session_id=oe,le.video_id=X,x.metadata=le,Si.set(w,{});let B=po(x,w);mo(x,w,B),yo(x,w,B),so(w);let j=io(x,w,B),re=no(x,w,B);return{engine:B,setAutoplay:j,setPreload:re}},pa=(x,w)=>{let A=w==null?void 0:w.engine;A&&(A.detachMedia(),A.destroy()),(x==null?void 0:x.mux)&&!x.mux.deleted&&(x.mux.destroy(),delete x.mux),x&&(x.removeAttribute("src"),x.load(),x.removeEventListener("error",fs),x.removeEventListener("error",ua),x.removeEventListener("durationchange",hs),Si.delete(x),x.dispatchEvent(new Event("teardown")))};function ds(x,w){var A;let le=es(x);if(le!==_i.M3U8)return!0;let oe=!le||((A=w.canPlayType(le))!=null?A:!0),{preferPlayback:X}=x,B=X===oi.MSE,j=X===oi.NATIVE;return oe&&(j||!(as&&(B||uo)))}var po=(x,w)=>{let{debug:A,streamType:le,startTime:oe=-1,metadata:X,preferCmcd:B}=x,j=es(x)===_i.M3U8,re=ds(x,w);if(j&&!re&&as){let R={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},g=go(le),k=B!==oa.NONE?{useHeaders:B===oa.HEADER,sessionId:X.view_session_id,contentId:X.video_id}:void 0;return new Sr({debug:A,startPosition:oe,cmcd:k,...R,...g})}},go=x=>[Tn.LIVE,Tn.DVR].includes(x)?{backBufferLength:8}:[Tn.LL_LIVE,Tn.LL_DVR].includes(x)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},cs=({playbackId:x,src:w,customDomain:A})=>{if(x)return!0;if(typeof w!="string")return!1;let le=window==null?void 0:window.location.href,oe=new URL(w,le).hostname.toLocaleLowerCase();return oe.includes(ns)||!!A&&oe.includes(A.toLocaleLowerCase())},mo=(x,w,A)=>{var le;let{envKey:oe}=x,X=cs(x);if(oe||X){let{playerInitTime:B,playerSoftwareName:j,playerSoftwareVersion:re,beaconCollectionDomain:R,debug:g,disableCookies:k}=x,L={...x.metadata,video_title:((le=x==null?void 0:x.metadata)==null?void 0:le.video_title)||void 0},me=ne=>typeof ne.player_error_code=="string"?!1:typeof x.errorTranslator=="function"?x.errorTranslator(ne):ne;bn.default.monitor(w,{debug:g,beaconCollectionDomain:R,hlsjs:A,Hls:A?Sr:void 0,automaticErrorTracking:!1,errorTranslator:me,disableCookies:k,data:{...oe?{env_key:oe}:{},player_software_name:j,player_software:j,player_software_version:re,player_init_time:B,...L}})}},yo=(x,w,A)=>{var le;let oe=ds(x,w),{src:X}=x;w&&oe?(typeof X=="string"?(w.setAttribute("src",X),x.startTime&&(((le=Si.get(w))!=null?le:{}).startTime=x.startTime,w.addEventListener("durationchange",hs,{once:!0}))):w.removeAttribute("src"),w.addEventListener("error",fs),w.addEventListener("error",ua)):A&&X?(A.on(Sr.Events.ERROR,(B,j)=>{let re={[Sr.ErrorTypes.NETWORK_ERROR]:Tr.MEDIA_ERR_NETWORK,[Sr.ErrorTypes.MEDIA_ERROR]:Tr.MEDIA_ERR_DECODE},R=new Tr("",re[j.type]);R.fatal=j.fatal,R.data=j,w.dispatchEvent(new CustomEvent("error",{detail:R}))}),w.addEventListener("error",ua),ao(w,A),A.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 hs(x){var w;let A=x.target,le=(w=Si.get(A))==null?void 0:w.startTime;if(!!le&&Zs(A.seekable,A.duration,le)){let oe=A.preload==="auto";oe&&(A.preload="none"),A.currentTime=le,oe&&(A.preload="auto")}}async function fs(x){if(!x.isTrusted)return;x.stopImmediatePropagation();let w=x.target;if(!(w!=null&&w.error))return;let{message:A,code:le}=w.error,oe=new Tr(A,le);if(w.src&&(le!==Tr.MEDIA_ERR_DECODE||le!==void 0))try{let{status:X}=await fetch(w.src);oe.data={response:{code:X}}}catch{}w.dispatchEvent(new CustomEvent("error",{detail:oe}))}function ua(x){var w,A;if(!(x instanceof CustomEvent)||!(x.detail instanceof Tr))return;let le=x.target,oe=x.detail;!oe||!oe.fatal||(((w=Si.get(le))!=null?w:{}).error=oe,(A=le.mux)==null||A.emit("error",{player_error_code:oe.code,player_error_message:oe.message}))}var Eo=()=>{try{return"0.13.2"}catch{}return"UNKNOWN"},To=Eo(),vs=()=>To;var ga=class extends Set{add(w){super.add(new WeakRef(w))}forEach(w){super.forEach(A=>{let le=A.deref();le&&w(le)})}},bo=x=>{var w,A,le,oe,X,ps,j,_n,R,Mr,k,Sn,me,An,ce,gs,q,ms,J,ma,K,Ee,ke,Ne,V,E,U,Xi,de,ys,z,ya,Le,Es,xe,Ea,qe,Ts,ie,Ta;return w=class extends x{constructor(){super();bt(this,U);bt(this,de);bt(this,z);bt(this,Le);bt(this,xe);bt(this,qe);bt(this,ie);Ki(this,"castEnabled",!1);bt(this,K,{paused:!1});bt(this,Ee,void 0);bt(this,ke,{});bt(this,Ne,void 0);bt(this,V,void 0);bt(this,E,void 0);w.instances.add(this),zt(this,xe,Ea).call(this)}static get castElement(){return Ye(w,A)}static get castEnabled(){return Ye(w,le)}static get castState(){var H;return(H=Ye(w,R,Mr))==null?void 0:H.getCastState()}static async exitCast(){try{await Ye(w,R,Mr).endCurrentSession(!0)}catch(ve){console.error(ve);return}}get castPlayer(){if(w.castElement===this)return Ye(this,Ee)}attributeChangedCallback(H){if(!!this.castPlayer)switch(H){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(H={}){var ve;zt(ve=w,J,ma).call(ve,H),Nt(w,A,this),Object.entries(Ye(this,ke)).forEach(([Ie,Fe])=>{Ye(this,Ee).controller.addEventListener(Ie,Fe)});try{await Ye(w,R,Mr).requestSession()}catch{Nt(w,A,void 0);return}Ye(this,K).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Ie){console.error(Ie)}}async load(){var Ce,Ve;if(!this.castPlayer)return super.load();let H=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),ve=[...this.querySelectorAll("track")].filter(({kind:Xe,src:it})=>it&&(Xe==="subtitles"||Xe==="captions")),Ie=[],Fe=0;ve.length&&(H.tracks=ve.map(Xe=>{let it=++Fe;Ie.length===0&&Xe.track.mode==="showing"&&Ie.push(it);let lt=new chrome.cast.media.Track(it,chrome.cast.media.TrackType.TEXT);return lt.trackContentId=Xe.src,lt.trackContentType="text/vtt",lt.subtype=Xe.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,lt.name=Xe.label,lt.language=Xe.srclang,lt})),this.castStreamType==="live"?H.streamType=chrome.cast.media.StreamType.LIVE:H.streamType=chrome.cast.media.StreamType.BUFFERED,H.metadata=new chrome.cast.media.GenericMediaMetadata,H.metadata.title=this.title,H.metadata.images=[{url:this.poster}];let fe=new chrome.cast.media.LoadRequest(H);fe.currentTime=(Ce=super.currentTime)!=null?Ce:0,fe.autoplay=!Ye(this,K).paused,fe.activeTrackIds=Ie,await((Ve=Ye(w,k,Sn))==null?void 0:Ve.loadMedia(fe)),this.dispatchEvent(new Event("volumechange"))}play(){var H;if(this.castPlayer){this.castPlayer.isPaused&&((H=this.castPlayer.controller)==null||H.playOrPause());return}return super.play()}pause(){var H;if(this.castPlayer){this.castPlayer.isPaused||(H=this.castPlayer.controller)==null||H.playOrPause();return}super.pause()}get castSrc(){var H,ve,Ie;return(Ie=(ve=this.getAttribute("cast-src"))!=null?ve:(H=this.querySelector("source"))==null?void 0:H.src)!=null?Ie:this.currentSrc}set castSrc(H){this.castSrc!=H&&this.setAttribute("cast-src",`${H}`)}get castContentType(){var H;return(H=this.getAttribute("cast-content-type"))!=null?H:void 0}set castContentType(H){this.setAttribute("cast-content-type",`${H}`)}get castStreamType(){var H;return(H=this.getAttribute("cast-stream-type"))!=null?H:void 0}set castStreamType(H){this.setAttribute("cast-stream-type",`${H}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var H;return this.castPlayer?(H=this.castPlayer)==null?void 0:H.isMuted:super.muted}set muted(H){var ve;if(this.castPlayer){(H&&!this.castPlayer.isMuted||!H&&this.castPlayer.isMuted)&&((ve=this.castPlayer.controller)==null||ve.muteOrUnmute());return}super.muted=H}get volume(){var H,ve;return this.castPlayer?(ve=(H=this.castPlayer)==null?void 0:H.volumeLevel)!=null?ve:1:super.volume}set volume(H){var ve;if(this.castPlayer){this.castPlayer.volumeLevel=H,(ve=this.castPlayer.controller)==null||ve.setVolumeLevel();return}super.volume=H}get duration(){var H,ve;return this.castPlayer&&Ye(this,U,Xi)?(ve=(H=this.castPlayer)==null?void 0:H.duration)!=null?ve:NaN:super.duration}get currentTime(){var H,ve;return this.castPlayer&&Ye(this,U,Xi)?(ve=(H=this.castPlayer)==null?void 0:H.currentTime)!=null?ve:0:super.currentTime}set currentTime(H){var ve;if(this.castPlayer){this.castPlayer.currentTime=H,(ve=this.castPlayer.controller)==null||ve.seek();return}super.currentTime=H}get onentercast(){return Ye(this,Ne)}set onentercast(H){Ye(this,Ne)&&(this.removeEventListener("entercast",Ye(this,Ne)),Nt(this,Ne,null)),typeof H=="function"&&(Nt(this,Ne,H),this.addEventListener("entercast",H))}get onleavecast(){return Ye(this,V)}set onleavecast(H){Ye(this,V)&&(this.removeEventListener("leavecast",Ye(this,V)),Nt(this,V,null)),typeof H=="function"&&(Nt(this,V,H),this.addEventListener("leavecast",H))}get oncastchange(){return Ye(this,E)}set oncastchange(H){Ye(this,E)&&(this.removeEventListener("castchange",Ye(this,E)),Nt(this,E,null)),typeof H=="function"&&(Nt(this,E,H),this.addEventListener("castchange",H))}},A=new WeakMap,le=new WeakMap,oe=new WeakMap,X=new WeakSet,ps=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},j=new WeakSet,_n=function(){return typeof cast!="undefined"&&cast.framework},R=new WeakSet,Mr=function(){if(Ye(w,j,_n))return cast.framework.CastContext.getInstance()},k=new WeakSet,Sn=function(){var H;return(H=Ye(w,R,Mr))==null?void 0:H.getCurrentSession()},me=new WeakSet,An=function(){var H;return(H=Ye(w,k,Sn))==null?void 0:H.getSessionObj().media[0]},ce=new WeakSet,gs=function(H){return new Promise((ve,Ie)=>{Ye(w,me,An).editTracksInfo(H,ve,Ie)})},q=new WeakSet,ms=function(H){return new Promise((ve,Ie)=>{Ye(w,me,An).getStatus(H,ve,Ie)})},J=new WeakSet,ma=function(H){return Ye(w,R,Mr).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...H})},K=new WeakMap,Ee=new WeakMap,ke=new WeakMap,Ne=new WeakMap,V=new WeakMap,E=new WeakMap,U=new WeakSet,Xi=function(){var H;return(H=this.castPlayer)==null?void 0:H.isMediaLoaded},de=new WeakSet,ys=function(){Ye(w,A)===this&&(Object.entries(Ye(this,ke)).forEach(([H,ve])=>{Ye(this,Ee).controller.removeEventListener(H,ve)}),Nt(w,A,void 0),this.muted=Ye(this,Ee).isMuted,this.currentTime=Ye(this,Ee).savedPlayerState.currentTime,Ye(this,Ee).savedPlayerState.isPaused===!1&&this.play())},z=new WeakSet,ya=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:Ye(w,R,Mr).getCastState()}))},Le=new WeakSet,Es=async function(){var ve,Ie;let{SESSION_RESUMED:H}=cast.framework.SessionState;if(Ye(w,R,Mr).getSessionState()===H&&this.castSrc===((ve=Ye(w,me,An))==null?void 0:ve.media.contentId)){Nt(w,A,this),Object.entries(Ye(this,ke)).forEach(([Fe,fe])=>{Ye(this,Ee).controller.addEventListener(Fe,fe)});try{await zt(Ie=w,q,ms).call(Ie,new chrome.cast.media.GetStatusRequest)}catch(Fe){console.error(Fe)}Ye(this,ke)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),Ye(this,ke)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},xe=new WeakSet,Ea=function(){var H;!Ye(w,j,_n)||this.castEnabled||(this.castEnabled=!0,zt(H=w,J,ma).call(H),this.textTracks.addEventListener("change",zt(this,ie,Ta).bind(this)),zt(this,z,ya).call(this),Nt(this,Ee,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(Ye(this,Ee)),Nt(this,ke,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:ve})=>{ve===!1&&zt(this,de,ys).call(this),this.dispatchEvent(new Event(ve?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!Ye(this,U,Xi)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var ve,Ie;((ve=this.castPlayer)==null?void 0:ve.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(Ie=this.castPlayer)==null?void 0:Ie.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!Ye(this,U,Xi)||(await Promise.resolve(),zt(this,qe,Ts).call(this))}}))},qe=new WeakSet,Ts=function(){zt(this,ie,Ta).call(this)},ie=new WeakSet,Ta=async function(){var Ct,Rt,St,wt,gt,dt;if(!this.castPlayer)return;let ve=((Rt=(Ct=Ye(this,Ee).mediaInfo)==null?void 0:Ct.tracks)!=null?Rt:[]).filter(({type:tt})=>tt===chrome.cast.media.TrackType.TEXT),Ie=[...this.textTracks].filter(({kind:tt})=>tt==="subtitles"||tt==="captions"),Fe=ve.map(({language:tt,name:It,trackId:Ut})=>{var Bt;let{mode:Wt}=(Bt=Ie.find(ar=>ar.language===tt&&ar.label===It))!=null?Bt:{};return Wt?{mode:Wt,trackId:Ut}:!1}).filter(Boolean),Ce=Fe.filter(({mode:tt})=>tt!=="showing").map(({trackId:tt})=>tt),Ve=Fe.find(({mode:tt})=>tt==="showing"),Xe=(gt=(wt=(St=Ye(w,k,Sn))==null?void 0:St.getSessionObj().media[0])==null?void 0:wt.activeTrackIds)!=null?gt:[],it=Xe;if(Xe.length&&(it=it.filter(tt=>!Ce.includes(tt))),Ve!=null&&Ve.trackId&&(it=[...it,Ve.trackId]),it=[...new Set(it)],!((tt,It)=>tt.length===It.length&&tt.every(Ut=>It.includes(Ut)))(Xe,it))try{let tt=new chrome.cast.media.EditTracksInfoRequest(it);await zt(dt=w,ce,gs).call(dt,tt)}catch(tt){console.error(tt)}},bt(w,X),bt(w,j),bt(w,R),bt(w,k),bt(w,me),bt(w,ce),bt(w,q),bt(w,J),Ki(w,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),Ki(w,"instances",new ga),bt(w,A,void 0),bt(w,le,!1),Ki(w,"initCast",()=>{var H;Ye(w,X,ps)?Ye(w,j,_n)?Ye(H=w,oe).call(H,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var ve;return Ye(ve=w,oe).call(ve,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var ve;return Ye(ve=w,oe).call(ve,chrome.cast.isAvailable)})}}),bt(w,oe,H=>{if(H){Nt(w,le,!0);let{CAST_STATE_CHANGED:ve}=cast.framework.CastContextEventType;Ye(w,R,Mr).addEventListener(ve,Fe=>{w.instances.forEach(fe=>{var Ce;return zt(Ce=fe,z,ya).call(Ce,Fe)})});let{SESSION_STATE_CHANGED:Ie}=cast.framework.CastContextEventType;Ye(w,R,Mr).addEventListener(Ie,Fe=>{w.instances.forEach(fe=>{var Ce;return zt(Ce=fe,Le,Es).call(Ce,Fe)})}),w.instances.forEach(Fe=>{var fe;return zt(fe=Fe,xe,Ea).call(fe)})}}),w};if(globalThis.HTMLVideoElement&&globalThis.customElements){let x=bo(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",x,{extends:"video"}),globalThis.CastableVideoElement=x),x.initCast()}var bs=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],_s=ra.createElement("template");_s.innerHTML=`
|
|
33
33
|
<style>
|
|
34
34
|
:host {
|
|
35
35
|
display: inline-block;
|
|
@@ -49,7 +49,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
49
49
|
</style>
|
|
50
50
|
<video is="castable-video" part="video" crossorigin></video>
|
|
51
51
|
<slot></slot>
|
|
52
|
-
`;var
|
|
52
|
+
`;var zi,Ai,kn,Qi,ba,$r=class extends xr.HTMLElement{constructor(){super();bt(this,Ai);bt(this,Qi);bt(this,zi,void 0);this.attachShadow({mode:"open"}),this.isConnected&&zt(this,Ai,kn).call(this)}static get observedAttributes(){let A=[],le=X=>X.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(X=>{let B=!1;try{typeof this.prototype[X]=="function"&&(B=!0)}catch{}!B&&X!==X.toUpperCase()&&A.push(X.toLowerCase(),le(X))});let oe=Object.getPrototypeOf(this).observedAttributes;return oe&&(A=A.concat(oe)),A}attributeChangedCallback(A,le,oe){zt(this,Ai,kn).call(this),zt(this,Qi,ba).call(this,A,le,oe)}connectedCallback(){zt(this,Ai,kn).call(this)}};zi=new WeakMap,Ai=new WeakSet,kn=function(){if(Ye(this,zi))return;Nt(this,zi,!0),this.shadowRoot.append(_s.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),bs.forEach(le=>{this.nativeEl.addEventListener(le,oe=>{this.dispatchEvent(new CustomEvent(oe.type,{detail:oe.detail}))})});let A=this.shadowRoot.querySelector("slot");A.addEventListener("slotchange",()=>{A.assignedElements().forEach(le=>{!["track","source"].includes(le.localName)||this.nativeEl.append(le)})}),Array.prototype.forEach.call(this.attributes,le=>{zt(this,Qi,ba).call(this,le.name,null,le.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},Qi=new WeakSet,ba=function(A,le,oe){let X=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),B=So(X,A),j=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;B&&!j?typeof this[B]=="boolean"?oe===null?this[B]=!1:this[B]=!0:this[B]=oe:oe===null?this.nativeEl.removeAttribute(A):["id","class"].indexOf(A)===-1&&this.nativeEl.setAttribute(A,oe)};var Ss=[],As=ra.createElement("video",{is:"castable-video"}),_o=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let x=Object.getPrototypeOf(As);x&&x!==xr.HTMLElement.prototype;x=Object.getPrototypeOf(x))Object.getOwnPropertyNames(x).forEach(w=>{_o.indexOf(w)===-1&&Ss.push(w)});Ss.forEach(x=>{if(x in $r.prototype)return;if(typeof As[x]=="function")$r.prototype[x]=function(){return this.nativeEl[x].apply(this.nativeEl,arguments)};else{let A={get(){return this.nativeEl[x]}};x!==x.toUpperCase()&&(A.set=function(le){this.nativeEl[x]=le}),Object.defineProperty($r.prototype,x,A)}});function So(x,w){let A=null;return x.forEach(le=>{le.toLowerCase()==w.toLowerCase()&&(A=le)}),A}xr.customElements.get("custom-video")||(xr.customElements.define("custom-video",$r),xr.CustomVideoElement=$r);var _a=$r;var _t={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time",PREFER_CMCD:"prefer-cmcd"},Ao=Object.values(_t),ko=vs(),wo="mux-video",Fr,ki,$i,wi,Zi,en,tn,rn,Sa,Ji=class extends _a{constructor(){super();bt(this,rn);bt(this,Fr,void 0);bt(this,ki,void 0);bt(this,$i,void 0);bt(this,wi,{});bt(this,Zi,void 0);bt(this,en,void 0);bt(this,tn,void 0);Nt(this,$i,ss())}static get observedAttributes(){var A;return[...Ao,...(A=_a.observedAttributes)!=null?A:[]]}get preferCmcd(){var A;return(A=this.getAttribute(_t.PREFER_CMCD))!=null?A:void 0}set preferCmcd(A){A!==this.preferCmcd&&(A?da.includes(A)?this.setAttribute(_t.PREFER_CMCD,A):console.warn(`Invalid value for preferCmcd. Must be one of ${da.join()}`):this.removeAttribute(_t.PREFER_CMCD))}get playerInitTime(){return Ye(this,$i)}get playerSoftwareName(){var A;return(A=Ye(this,en))!=null?A:wo}set playerSoftwareName(A){Nt(this,en,A)}get playerSoftwareVersion(){var A;return(A=Ye(this,Zi))!=null?A:ko}set playerSoftwareVersion(A){Nt(this,Zi,A)}get _hls(){var A;return(A=Ye(this,Fr))==null?void 0:A.engine}get mux(){return this.nativeEl.mux}get error(){var A;return(A=ls(this.nativeEl))!=null?A:null}get errorTranslator(){return Ye(this,tn)}set errorTranslator(A){Nt(this,tn,A)}get src(){return this.getAttribute("src")}set src(A){A!==this.src&&(A==null?this.removeAttribute("src"):this.setAttribute("src",A))}get type(){var A;return(A=this.getAttribute(_t.TYPE))!=null?A:void 0}set type(A){A!==this.type&&(A?this.setAttribute(_t.TYPE,A):this.removeAttribute(_t.TYPE))}get autoplay(){let A=this.getAttribute("autoplay");return A===null?!1:A===""?!0:A}set autoplay(A){let le=this.autoplay;A!==le&&(A?this.setAttribute("autoplay",typeof A=="string"?A:""):this.removeAttribute("autoplay"))}get preload(){let A=this.getAttribute("preload");return A===""?"auto":["none","metadata","auto"].includes(A)?A:super.preload}set preload(A){A!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(A)?this.setAttribute("preload",A):this.removeAttribute("preload"))}get debug(){return this.getAttribute(_t.DEBUG)!=null}set debug(A){A!==this.debug&&(A?this.setAttribute(_t.DEBUG,""):this.removeAttribute(_t.DEBUG))}get disableCookies(){return this.hasAttribute(_t.DISABLE_COOKIES)}set disableCookies(A){A!==this.disableCookies&&(A?this.setAttribute(_t.DISABLE_COOKIES,""):this.removeAttribute(_t.DISABLE_COOKIES))}get startTime(){let A=this.getAttribute(_t.START_TIME);if(A==null)return;let le=+A;return Number.isNaN(le)?void 0:le}set startTime(A){A!==this.startTime&&(A==null?this.removeAttribute(_t.START_TIME):this.setAttribute(_t.START_TIME,`${A}`))}get playbackId(){var A;return(A=this.getAttribute(_t.PLAYBACK_ID))!=null?A:void 0}set playbackId(A){A!==this.playbackId&&(A?this.setAttribute(_t.PLAYBACK_ID,A):this.removeAttribute(_t.PLAYBACK_ID))}get customDomain(){var A;return(A=this.getAttribute(_t.CUSTOM_DOMAIN))!=null?A:void 0}set customDomain(A){A!==this.customDomain&&(A?this.setAttribute(_t.CUSTOM_DOMAIN,A):this.removeAttribute(_t.CUSTOM_DOMAIN))}get envKey(){var A;return(A=this.getAttribute(_t.ENV_KEY))!=null?A:void 0}set envKey(A){A!==this.envKey&&(A?this.setAttribute(_t.ENV_KEY,A):this.removeAttribute(_t.ENV_KEY))}get beaconCollectionDomain(){var A;return(A=this.getAttribute(_t.BEACON_COLLECTION_DOMAIN))!=null?A:void 0}set beaconCollectionDomain(A){A!==this.beaconCollectionDomain&&(A?this.setAttribute(_t.BEACON_COLLECTION_DOMAIN,A):this.removeAttribute(_t.BEACON_COLLECTION_DOMAIN))}get streamType(){var A;return(A=this.getAttribute(_t.STREAM_TYPE))!=null?A:void 0}set streamType(A){A!==this.streamType&&(A?this.setAttribute(_t.STREAM_TYPE,A):this.removeAttribute(_t.STREAM_TYPE))}async addCuePoints(A){return fa(this.nativeEl,A)}get activeCuePoint(){return va(this.nativeEl)}get cuePoints(){return is(this.nativeEl)}get preferPlayback(){let A=this.getAttribute(_t.PREFER_PLAYBACK);if(A===oi.MSE||A===oi.NATIVE)return A}set preferPlayback(A){A!==this.preferPlayback&&(A===oi.MSE||A===oi.NATIVE?this.setAttribute(_t.PREFER_PLAYBACK,A):this.removeAttribute(_t.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(le=>le.startsWith("metadata-")&&![_t.METADATA_URL].includes(le)).reduce((le,oe)=>{let X=this.getAttribute(oe);return X!=null&&(le[oe.replace(/^metadata-/,"").replace(/-/g,"_")]=X),le},{}),...Ye(this,wi)}}set metadata(A){Nt(this,wi,A!=null?A:{}),this.mux&&this.mux.emit("hb",Ye(this,wi))}load(){Nt(this,Fr,us(this,this.nativeEl,Ye(this,Fr)))}unload(){pa(this.nativeEl,Ye(this,Fr)),Nt(this,Fr,void 0)}attributeChangedCallback(A,le,oe){var X,B;switch(super.attributeChangedCallback(A,le,oe),A){case _t.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=oe!=null?oe:void 0;break;case _t.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=oe!=null?oe:void 0;break;case"src":{let j=!!le,re=!!oe;!j&&re?zt(this,rn,Sa).call(this):j&&!re?this.unload():j&&re&&(this.unload(),zt(this,rn,Sa).call(this));break}case"autoplay":if(oe===le)break;(X=Ye(this,Fr))==null||X.setAutoplay(this.autoplay);break;case"preload":if(oe===le)break;(B=Ye(this,Fr))==null||B.setPreload(oe);break;case _t.PLAYBACK_ID:this.src=os(oe!=null?oe:void 0,{domain:this.customDomain});break;case _t.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 _t.METADATA_URL:oe&&fetch(oe).then(j=>j.json()).then(j=>this.metadata=j).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${oe}!`));break;default:break}}disconnectedCallback(){this.unload()}};Fr=new WeakMap,ki=new WeakMap,$i=new WeakMap,wi=new WeakMap,Zi=new WeakMap,en=new WeakMap,tn=new WeakMap,rn=new WeakSet,Sa=async function(){Ye(this,ki)||(await Nt(this,ki,Promise.resolve()),Nt(this,ki,null),this.load())};xr.customElements.get("mux-video")||(xr.customElements.define("mux-video",Ji),xr.MuxVideoElement=Ji);var Xo=Ji;})();
|
|
53
53
|
/*!
|
|
54
54
|
* JavaScript Cookie v2.1.3
|
|
55
55
|
* https://github.com/js-cookie/js-cookie
|