@mux/mux-audio 0.9.3 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/mux-audio.js +31 -31
- package/dist/mux-audio.js.map +4 -4
- package/dist/mux-audio.mjs +31 -31
- package/dist/mux-audio.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/mux-audio.mjs
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
var gn=Object.create;var ii=Object.defineProperty;var mn=Object.getOwnPropertyDescriptor;var pn=Object.getOwnPropertyNames;var yn=Object.getPrototypeOf,En=Object.prototype.hasOwnProperty;var ni=($,q)=>()=>(q||$((q={exports:{}}).exports,q),q.exports);var _n=($,q,X,ne)=>{if(q&&typeof q=="object"||typeof q=="function")for(let z of pn(q))!En.call($,z)&&z!==X&&ii($,z,{get:()=>q[z],enumerable:!(ne=mn(q,z))||ne.enumerable});return $};var fr=($,q,X)=>(X=$!=null?gn(yn($)):{},_n(q||!$||!$.__esModule?ii(X,"default",{value:$,enumerable:!0}):X,$));var Ir=($,q,X)=>{if(!q.has($))throw TypeError("Cannot "+X)};var lt=($,q,X)=>(Ir($,q,"read from private field"),X?X.call($):q.get($)),mt=($,q,X)=>{if(q.has($))throw TypeError("Cannot add the same private member more than once");q instanceof WeakSet?q.add($):q.set($,X)},pt=($,q,X,ne)=>(Ir($,q,"write to private field"),ne?ne.call($,X):q.set($,X),X);var bt=($,q,X)=>(Ir($,q,"access private method"),X);var oi=ni((cr,wr)=>{(function(){var $,q;$=this,q=function(){return function(){var X={80:function(N,_,C){N.exports=C(728).default},728:function(N,_,C){"use strict";C.d(_,{default:function(){return hn}});var D=C(48),M=C.n(D),P=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(U){var O=16*Math.random()|0;return(U==="x"?O:3&O|8).toString(16)})},B=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},b=function(U){return U&&U.nodeName!==void 0?(U.muxId||(U.muxId=U.id||B()),U.muxId):U},A=function(U){var O;U&&U.nodeName!==void 0?U=b(O=U):O=document.querySelector(U);var w=O&&O.nodeName?O.nodeName.toLowerCase():"";return[O,U,w]},S=C(640),T=C.n(S),x=T().methodFactory;T().methodFactory=function(U,O,w){var W=x(U,O,w);return function(){for(var G=["[mux]"],Q=0;Q<arguments.length;Q++)G.push(arguments[Q]);W.apply(void 0,G)}},T().setLevel(T().getLevel());var f=T();function E(){return(M().doNotTrack||M().navigator&&M().navigator.doNotTrack)==="1"}var p={now:function(){var U=M().performance,O=U&&U.timing,w=O&&O.navigationStart,W=typeof w=="number"&&typeof U.now=="function"?w+U.now():Date.now();return Math.round(W)}},h=C(678),a=C.n(h),o=function(U){return n(U)[0]},n=function(U){if(typeof U!="string"||U==="")return["localhost"];var O,w=(U.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return w&&(O=(w.match(/[^\.]+\.[^\.]+$/)||[])[0]),[w,O]},v={exists:function(){var U=M().performance;return(U&&U.timing)!==void 0},domContentLoadedEventEnd:function(){var U=M().performance,O=U&&U.timing;return O&&O.domContentLoadedEventEnd},navigationStart:function(){var U=M().performance,O=U&&U.timing;return O&&O.navigationStart}};function l(U,O,w){w=w===void 0?1:w,U[O]=U[O]||0,U[O]+=w}var i=["x-cdn","content-type","x-request-id"];function u(U){var O={};return(U=U||"").trim().split(/[\r\n]+/).forEach(function(w){if(w){var W=w.split(": "),G=W.shift();G&&(i.indexOf(G.toLowerCase())>=0||G.toLowerCase().indexOf("x-litix-")===0)&&(O[G]=W.join(": "))}}),O}var g=function(U){var O={};for(var w in U){var W=U[w];W["DATA-ID"].search("io.litix.data.")!==-1&&(O[W["DATA-ID"].replace("io.litix.data.","")]=W.VALUE)}return O};function c(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function m(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?c(Object(w),!0).forEach(function(W){e(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):c(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function e(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var r=function(U){if(!U)return{};var O=v.navigationStart(),w=U.loading,W=w?w.start:U.trequest,G=w?w.first:U.tfirst,Q=w?w.end:U.tload;return{bytesLoaded:U.total,requestStart:Math.round(O+W),responseStart:Math.round(O+G),responseEnd:Math.round(O+Q)}},t=function(U){if(U&&typeof U.getAllResponseHeaders=="function")return u(U.getAllResponseHeaders())};function s(U,O){var w=Object.keys(U);if(Object.getOwnPropertySymbols){var W=Object.getOwnPropertySymbols(U);O&&(W=W.filter(function(G){return Object.getOwnPropertyDescriptor(U,G).enumerable})),w.push.apply(w,W)}return w}function y(U){for(var O=1;O<arguments.length;O++){var w=arguments[O]!=null?arguments[O]:{};O%2?s(Object(w),!0).forEach(function(W){d(U,W,w[W])}):Object.getOwnPropertyDescriptors?Object.defineProperties(U,Object.getOwnPropertyDescriptors(w)):s(Object(w)).forEach(function(W){Object.defineProperty(U,W,Object.getOwnPropertyDescriptor(w,W))})}return U}function d(U,O,w){return O in U?Object.defineProperty(U,O,{value:w,enumerable:!0,configurable:!0,writable:!0}):U[O]=w,U}var L=function(U,O){if(!U||typeof U.getRequests!="function")return{};var w=U.getRequests({state:"executed"});if(w.length===0)return{};var W,G=w[w.length-1],Q=o(G.url),V=G.url,Z=G.bytesLoaded,ie=new Date(G.requestStartDate).getTime(),ee=new Date(G.firstByteDate).getTime(),oe=new Date(G.requestEndDate).getTime(),Ee=isNaN(G.duration)?0:G.duration,ve=typeof O.getMetricsFor=="function"?O.getMetricsFor(G.mediaType).HttpList:O.getDashMetrics().getHttpRequests(G.mediaType);return ve.length>0&&(W=u(ve[ve.length-1]._responseHeaders||"")),{requestStart:ie,requestResponseStart:ee,requestResponseEnd:oe,requestBytesLoaded:Z,requestResponseHeaders:W,requestMediaDuration:Ee,requestHostname:Q,requestUrl:V}},R=function(U,O){var w=O.getQualityFor(U),W=O.getCurrentTrackFor(U).bitrateList;return W?{currentLevel:w,renditionWidth:W[w].width||null,renditionHeight:W[w].height||null,renditionBitrate:W[w].bandwidth}:{}},I=function(U){var O;return(O=U.match(/.*codecs\*?="(.*)"/))===null||O===void 0?void 0:O[1]};function k(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var F=0,K=function(){function U(){(function(G,Q){if(!(G instanceof Q))throw new TypeError("Cannot call a class as a function")})(this,U)}var O,w,W;return O=U,w=[{key:"on",value:function(G,Q,V){return Q._eventEmitterGuid=Q._eventEmitterGuid||++F,this._listeners=this._listeners||{},this._listeners[G]=this._listeners[G]||[],V&&(Q=Q.bind(V)),this._listeners[G].push(Q),Q}},{key:"off",value:function(G,Q){var V=this._listeners&&this._listeners[G];V&&V.forEach(function(Z,ie){Z._eventEmitterGuid===Q._eventEmitterGuid&&V.splice(ie,1)})}},{key:"one",value:function(G,Q,V){var Z=this;Q._eventEmitterGuid=Q._eventEmitterGuid||++F;var ie=function ee(){Z.off(G,ee),Q.apply(V||this,arguments)};ie._eventEmitterGuid=Q._eventEmitterGuid,this.on(G,ie)}},{key:"emit",value:function(G,Q){var V=this;if(this._listeners){Q=Q||{};var Z=this._listeners["before*"]||[],ie=this._listeners[G]||[],ee=this._listeners["after"+G]||[],oe=function(Ee,ve){(Ee=Ee.slice()).forEach(function(pe){pe.call(V,{type:G},ve)})};oe(Z,Q),oe(ie,Q),oe(ee,Q)}}}],w&&k(O.prototype,w),W&&k(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}(),H=K;function j(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Y=function(){function U(G){var Q=this;(function(V,Z){if(!(V instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,G.on("playing",function(){Q._playheadShouldBeProgressing=!0}),G.on("play",this._startPlaybackHeartbeatInterval.bind(this)),G.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),G.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),G.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),G.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),G.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),G.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),G.on("seeked",function(){G.data.player_is_paused?Q._stopPlaybackHeartbeatInterval():Q._startPlaybackHeartbeatInterval()}),G.on("timeupdate",function(){Q._playbackHeartbeatInterval!==null&&G.emit("playbackheartbeat")}),G.on("devicesleep",function(V,Z){Q._playbackHeartbeatInterval!==null&&(M().clearInterval(Q._playbackHeartbeatInterval),G.emit("playbackheartbeatend",{viewer_time:Z.viewer_time}),Q._playbackHeartbeatInterval=null)})}var O,w,W;return O=U,(w=[{key:"_startPlaybackHeartbeatInterval",value:function(){var G=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=M().setInterval(function(){G.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)}}])&&j(O.prototype,w),W&&j(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function J(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function te(U,O,w){return O&&J(U.prototype,O),w&&J(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ae=te(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("viewinit",function(){w.viewErrored=!1}),O.on("error",function(W,G){try{var Q=O.errorTranslator({player_error_code:G.player_error_code,player_error_message:G.player_error_message,player_error_context:G.player_error_context});Q?(O.data.player_error_code=Q.player_error_code||G.player_error_code,O.data.player_error_message=Q.player_error_message||G.player_error_message,O.data.player_error_context=Q.player_error_context||G.player_error_context,w.viewErrored=!0):(delete O.data.player_error_code,delete O.data.player_error_message,delete O.data.player_error_context)}catch(V){O.mux.log.warn("Exception in error translator callback.",V),w.viewErrored=!0}})});function re(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var se=function(){function U(G){(function(Q,V){if(!(Q instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._watchTimeTrackerLastCheckedTime=null,G.on("playbackheartbeat",this._updateWatchTime.bind(this)),G.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var O,w,W;return O=U,(w=[{key:"_updateWatchTime",value:function(G,Q){var V=Q.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=V),l(this.pm.data,"view_watch_time",V-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=V}},{key:"_clearWatchTimeState",value:function(G,Q){this._updateWatchTime(G,Q),this._watchTimeTrackerLastCheckedTime=null}}])&&re(O.prototype,w),W&&re(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function ue(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var ce=function(){function U(G){(function(Q,V){if(!(Q instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,this._playbackTimeTrackerLastPlayheadPosition=-1,G.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),G.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),G.on("seeking",this._clearPlaybackTimeState.bind(this))}var O,w,W;return O=U,(w=[{key:"_updatePlaybackTime",value:function(){var G=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&G>this._playbackTimeTrackerLastPlayheadPosition){var Q=G-this._playbackTimeTrackerLastPlayheadPosition;Q<=1e3&&l(this.pm.data,"view_content_playback_time",Q)}this._playbackTimeTrackerLastPlayheadPosition=G}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&ue(O.prototype,w),W&&ue(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function le(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var de=function(){function U(G){(function(V,Z){if(!(V instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G;var Q=this._updatePlayheadTime.bind(this);G.on("playbackheartbeat",Q),G.on("playbackheartbeatend",Q),G.on("timeupdate",Q),G.on("destroy",function(){G.off("timeupdate",Q)})}var O,w,W;return O=U,(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(G,Q){var V=this,Z=function(){V.pm.currentFragmentPDT&&V.pm.currentFragmentStart&&(V.pm.data.player_program_time=V.pm.currentFragmentPDT+V.pm.data.player_playhead_time-V.pm.currentFragmentStart)};if(Q&&Q.player_playhead_time)this.pm.data.player_playhead_time=Q.player_playhead_time,Z(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var ie=this.pm.getPlayheadTime();ie!==void 0&&(this.pm.data.player_playhead_time=ie,Z(),this._updateMaxPlayheadPosition())}}}])&&le(O.prototype,w),W&&le(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function fe(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Se(U,O,w){return O&&fe(U.prototype,O),w&&fe(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var be=Se(function U(O){if(function(Q,V){if(!(Q instanceof V))throw new TypeError("Cannot call a class as a function")}(this,U),!O.disableRebufferTracking){var w,W=function(Q,V){G(V),w=void 0},G=function(Q){if(w){var V=Q.viewer_time-w;l(O.data,"view_rebuffer_duration",V),w=Q.viewer_time}O.data.view_watch_time>=0&&O.data.view_rebuffer_count>0&&(O.data.view_rebuffer_frequency=O.data.view_rebuffer_count/O.data.view_watch_time,O.data.view_rebuffer_percentage=O.data.view_rebuffer_duration/O.data.view_watch_time)};O.on("playbackheartbeat",function(Q,V){return G(V)}),O.on("rebufferstart",function(Q,V){w||(l(O.data,"view_rebuffer_count",1),w=V.viewer_time,O.one("rebufferend",W))}),O.on("viewinit",function(){w=void 0,O.off("rebufferend",W)})}});function Oe(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Re=function(){function U(G){var Q=this;(function(V,Z){if(!(V instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.disableRebufferTracking||G.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,G.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),G.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),G.on("seeking",function(){Q._cleanupRebufferTracker(null,{viewer_time:p.now()})}))}var O,w,W;return O=U,w=[{key:"_checkIfRebuffering",value:function(G,Q){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(G,Q);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var V=Q.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&V>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=Q.viewer_time}else this._cleanupRebufferTracker(G,Q,!0);else this._prepareRebufferTrackerState(Q.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(G){this._lastCheckedTime=G,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=G}},{key:"_cleanupRebufferTracker",value:function(G,Q){var V=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:Q.viewer_time});else{if(this._lastCheckedTime===null)return;var Z=this.pm.data.player_playhead_time-this._lastPlayheadTime,ie=Q.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&Z>0&&ie-Z>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+ie-Z}))}V?this._prepareRebufferTrackerState(Q.viewer_time):this._clearRebufferTrackerState()}}],w&&Oe(O.prototype,w),W&&Oe(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}(),Ce=Re;function Pe(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var Me=function(){function U(G){var Q=this;(function(V,Z){if(!(V instanceof Z))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.on("viewinit",function(){var V=G.data,Z=V.view_id;if(!V.view_program_changed){var ie=function(ee,oe){var Ee=oe.viewer_time;ee.type==="playing"&&G.data.view_time_to_first_frame===void 0?Q.calculateTimeToFirstFrame(Ee||p.now(),Z):ee.type!=="adplaying"||G.data.view_time_to_first_frame!==void 0&&!Q._inPrerollPosition()||Q.calculateTimeToFirstFrame(Ee||p.now(),Z)};G.one("playing",ie),G.one("adplaying",ie),G.one("viewend",function(){G.off("playing",ie),G.off("adplaying",ie)})}})}var O,w,W;return O=U,(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(G,Q){Q===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:G}),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))}}])&&Pe(O.prototype,w),W&&Pe(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function De(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Fe(U,O,w){return O&&De(U.prototype,O),w&&De(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var Ne=Fe(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),O.on("viewinit",function(){w._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(W){O.on(W,function(){if(w._lastPlayheadPosition>=0&&O.data.player_playhead_time>=0&&w._lastPlayerWidth>=0&&w._lastSourceWidth>0&&w._lastPlayerHeight>=0&&w._lastSourceHeight>0){var G=O.data.player_playhead_time-w._lastPlayheadPosition;if(G<0)return void(w._lastPlayheadPosition=-1);var Q=Math.min(w._lastPlayerWidth/w._lastSourceWidth,w._lastPlayerHeight/w._lastSourceHeight),V=Math.max(0,Q-1),Z=Math.max(0,1-Q);O.data.view_max_upscale_percentage=Math.max(O.data.view_max_upscale_percentage||0,V),O.data.view_max_downscale_percentage=Math.max(O.data.view_max_downscale_percentage||0,Z),l(O.data,"view_total_content_playback_time",G),l(O.data,"view_total_upscaling",V*G),l(O.data,"view_total_downscaling",Z*G)}w._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(W){O.on(W,function(){w._lastPlayheadPosition=O.data.player_playhead_time,w._lastPlayerWidth=O.data.player_width,w._lastPlayerHeight=O.data.player_height,w._lastSourceWidth=O.data.video_source_width,w._lastSourceHeight=O.data.video_source_height})})});function ke(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Xe(U,O,w){return O&&ke(U.prototype,O),w&&ke(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ze=Xe(function U(O){var w=this;(function(W,G){if(!(W instanceof G))throw new TypeError("Cannot call a class as a function")})(this,U),this.isSeeking=!1,O.on("seeking",function(W,G){a()(O.data,G),w._lastSeekingTime=p.now(),w.isSeeking===!1&&(w.isSeeking=!0,O.send("seeking"))}),O.on("seeked",function(){w.isSeeking=!1;var W=w._lastSeekingTime||p.now(),G=p.now()-W;l(O.data,"view_seek_count",1),l(O.data,"view_seek_duration",G);var Q=O.data.view_max_seek_time||0;O.data.view_max_seek_time=Math.max(Q,G)}),O.on("viewend",function(){w.isSeeking=!1})});function rt(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var Q,V,Z=[],ie=!0,ee=!1;try{for(G=G.call(w);!(ie=(Q=G.next()).done)&&(Z.push(Q.value),!W||Z.length!==W);ie=!0);}catch(oe){ee=!0,V=oe}finally{try{ie||G.return==null||G.return()}finally{if(ee)throw V}}return Z}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Qe(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Qe(w,W):void 0}}(U,O)||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 Qe(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function it(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}var nt=function(U,O){U.push(O),U.sort(function(w,W){return w.viewer_time-W.viewer_time})},Je=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],Ke=function(){function U(G){var Q=this;(function(Z,ie){if(!(Z instanceof ie))throw new TypeError("Cannot call a class as a function")})(this,U),this.pm=G,G.on("viewinit",function(){Q.isAdBreak=!1,Q._currentAdRequestNumber=0,Q._currentAdResponseNumber=0,Q._adRequests=[],Q._adResponses=[],Q._adHasPlayed=!1,Q._wouldBeNewAdPlay=!0,Q._prerollPlayTime=void 0}),Je.forEach(function(Z){return G.on(Z,Q._updateAdData.bind(Q))});var V=function(){Q.isAdBreak=!1};G.on("adbreakstart",function(){Q.isAdBreak=!0}),G.on("play",V),G.on("playing",V),G.on("viewend",V),G.on("adrequest",function(Z,ie){ie=a()({ad_request_id:"generatedAdRequestId"+Q._currentAdRequestNumber++},ie),nt(Q._adRequests,ie),l(G.data,"view_ad_request_count"),Q.inPrerollPosition()&&(G.data.view_preroll_requested=!0,Q._adHasPlayed||l(G.data,"view_preroll_request_count"))}),G.on("adresponse",function(Z,ie){ie=a()({ad_request_id:"generatedAdRequestId"+Q._currentAdResponseNumber++},ie),nt(Q._adResponses,ie);var ee=Q.findAdRequest(ie.ad_request_id);ee&&l(G.data,"view_ad_request_time",Math.max(0,ie.viewer_time-ee.viewer_time))}),G.on("adplay",function(Z,ie){Q._adHasPlayed=!0,Q._wouldBeNewAdPlay&&(Q._wouldBeNewAdPlay=!1,l(G.data,"view_ad_played_count")),Q.inPrerollPosition()&&!G.data.view_preroll_played&&(G.data.view_preroll_played=!0,Q._adRequests.length>0&&(G.data.view_preroll_request_time=Math.max(0,ie.viewer_time-Q._adRequests[0].viewer_time)),G.data.view_start&&(G.data.view_startup_preroll_request_time=Math.max(0,ie.viewer_time-G.data.view_start)),Q._prerollPlayTime=ie.viewer_time)}),G.on("adplaying",function(Z,ie){Q.inPrerollPosition()&&G.data.view_preroll_load_time===void 0&&Q._prerollPlayTime!==void 0&&(G.data.view_preroll_load_time=ie.viewer_time-Q._prerollPlayTime,G.data.view_startup_preroll_load_time=ie.viewer_time-Q._prerollPlayTime)}),G.on("adended",function(){Q._wouldBeNewAdPlay=!0}),G.on("aderror",function(){Q._wouldBeNewAdPlay=!0})}var O,w,W;return O=U,(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(G){for(var Q=0;Q<this._adRequests.length;Q++)if(this._adRequests[Q].ad_request_id===G)return this._adRequests[Q]}},{key:"_updateAdData",value:function(G,Q){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&Q.ad_tag_url){var V=rt(n(Q.ad_tag_url),2),Z=V[0],ie=V[1];this.pm.data.view_preroll_ad_tag_domain=ie,this.pm.data.view_preroll_ad_tag_hostname=Z}if(!this.pm.data.view_preroll_ad_asset_hostname&&Q.ad_asset_url){var ee=rt(n(Q.ad_asset_url),2),oe=ee[0],Ee=ee[1];this.pm.data.view_preroll_ad_asset_domain=Ee,this.pm.data.view_preroll_ad_asset_hostname=oe}}}}])&&it(O.prototype,w),W&&it(O,W),Object.defineProperty(O,"prototype",{writable:!1}),U}();function We(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Ze(U,O,w){return O&&We(U.prototype,O),w&&We(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var ct=Ze(function U(O){var w,W;(function(Z,ie){if(!(Z instanceof ie))throw new TypeError("Cannot call a class as a function")})(this,U);var G=function(){O.disableRebufferTracking||w&&(l(O.data,"view_waiting_rebuffer_duration",p.now()-w),w=!1,M().clearInterval(W))},Q=!1,V=function(){Q=!1,G()};O.on("waiting",function(){Q&&(O.disableRebufferTracking||(l(O.data,"view_waiting_rebuffer_count",1),w=p.now(),W=M().setInterval(function(){if(w){var Z=p.now();l(O.data,"view_waiting_rebuffer_duration",Z-w),w=Z}},250)))}),O.on("playing",function(){G(),Q=!0}),O.on("pause",V),O.on("seeking",V)});function we(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function qe(U,O,w){return O&&we(U.prototype,O),w&&we(U,w),Object.defineProperty(U,"prototype",{writable:!1}),U}var et=qe(function U(O){var w=this;(function(Q,V){if(!(Q instanceof V))throw new TypeError("Cannot call a class as a function")})(this,U);var W=function(){w.lastWallClockTime=p.now(),O.on("before*",G)},G=function(Q){var V=p.now(),Z=w.lastWallClockTime;w.lastWallClockTime=V,V-Z>3e4&&(O.emit("devicesleep",{viewer_time:Z}),a()(O.data,{viewer_time:Z}),O.send("devicesleep"),O.emit("devicewake",{viewer_time:V}),a()(O.data,{viewer_time:V}),O.send("devicewake"))};O.one("playbackheartbeat",W),O.on("playbackheartbeatend",function(){O.off("before*",G),O.one("playbackheartbeat",W)})}),At=C(375),St=C(655),xt=C.n(St),Kt="muxData",Dt=function(){var U;try{U=At.parse(xt().get(Kt)||"")}catch{U={}}return U},ar=function(U){try{xt().set(Kt,At.stringify(U),{expires:7300})}catch{}},Wt=function(){var U=Dt();return U.mux_viewer_id=U.mux_viewer_id||P(),U.msn=U.msn||Math.random(),ar(U),{mux_viewer_id:U.mux_viewer_id,mux_sample_number:U.msn}};function yr(U,O){var w=O.beaconCollectionDomain,W=O.beaconDomain;if(w)return"https://"+w;var G=W||"litix.io";return(U=U||"inferred").match(/^[a-z0-9]+$/)?"https://"+U+"."+G:"https://img.litix.io/a.gif"}var Gt=function(){var U;switch(It()){case"cellular":U="cellular";break;case"ethernet":U="wired";break;case"wifi":U="wifi";break;case void 0:break;default:U="other"}return U},It=function(){var U=M().navigator,O=U&&(U.connection||U.mozConnection||U.webkitConnection);return O&&O.type};Gt.getConnectionFromAPI=It;var dt=Gt,sr=or({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"}),Ht=or({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 or(U){var O={};for(var w in U)U.hasOwnProperty(w)&&(O[U[w]]=w);return O}function jt(U){var O={},w={};return Object.keys(U).forEach(function(W){var G=!1;if(U.hasOwnProperty(W)&&U[W]!==void 0){var Q=W.split("_"),V=Q[0],Z=sr[V];Z||(f.info("Data key word `"+Q[0]+"` not expected in "+W),Z=V+"_"),Q.splice(1).forEach(function(ie){ie==="url"&&(G=!0),Ht[ie]?Z+=Ht[ie]:Number(ie)&&Math.floor(Number(ie))===Number(ie)?Z+=ie:(f.info("Data key word `"+ie+"` not expected in "+W),Z+="_"+ie+"_")}),G?w[Z]=U[W]:O[Z]=U[W]}}),a()(O,w)}var Er={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},_r=["hb","requestcompleted","requestfailed","requestcanceled"],Tr="https://img.litix.io",ft=function(U){var O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=U||Tr,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=a()({},Er,O)};ft.prototype.queueEvent=function(U,O){var w=a()({},O);return(this._eventQueue.length<=this._options.maxQueueLength||U==="eventrateexceeded")&&(this._eventQueue.push(w),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},ft.prototype.flushEvents=function(){var U=arguments.length>0&&arguments[0]!==void 0&&arguments[0];U&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},ft.prototype.destroy=function(){var U=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,U?this._clearBeaconQueue():this.flushEvents(),M().clearTimeout(this._sendTimeout)},ft.prototype._clearBeaconQueue=function(){var U=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,O=this._eventQueue.slice(U);U>0&&a()(O[O.length-1],jt({mux_view_message:"event queue truncated"}));var w=this._createPayload(O);Vt(this._beaconUrl,w,!0,function(){})},ft.prototype._sendBeaconQueue=function(){var U=this;if(!this._postInFlight){var O=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var w=this._createPayload(O),W=p.now();Vt(this._beaconUrl,w,!1,function(G,Q){Q?(U._eventQueue=O.concat(U._eventQueue),U._failureCount+=1,f.info("Error sending beacon: "+Q)):U._failureCount=0,U._roundTripTime=p.now()-W,U._postInFlight=!1})}},ft.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var U=Math.pow(2,this._failureCount-1);return(1+(U*=Math.random()))*this._options.baseTimeBetweenBeacons},ft.prototype._startBeaconSending=function(){var U=this;M().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=M().setTimeout(function(){U._eventQueue.length&&U._sendBeaconQueue(),U._startBeaconSending()},this._getNextBeaconTime()))},ft.prototype._createPayload=function(U){var O,w,W,G=this,Q={transmission_timestamp:Math.round(p.now())};this._roundTripTime&&(Q.rtt_ms=Math.round(this._roundTripTime));var V=function(){O=JSON.stringify({metadata:Q,events:w||U}),W=O.length/1024},Z=function(){return W<=G._options.maxPayloadKBSize};return V(),Z()||(f.info("Payload size is too big ("+W+" kb). Removing unnecessary events."),w=U.filter(function(ie){return _r.indexOf(ie.e)===-1}),V()),Z()||(f.info("Payload size still too big ("+W+" kb). Cropping fields.."),w.forEach(function(ie){for(var ee in ie){var oe=ie[ee];typeof oe=="string"&&oe.length>51200&&(ie[ee]=oe.substring(0,51200))}}),V()),O};var Vt=function(U,O,w,W){if(w&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(U,O))W();else if(M().fetch)M().fetch(U,{method:"POST",body:O,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(Q){return W(null,Q.ok?null:"Error")}).catch(function(Q){return W(null,Q)});else{if(M().XMLHttpRequest){var G=new(M()).XMLHttpRequest;return G.onreadystatechange=function(){if(G.readyState===4)return W(null,G.status!==200?"error":void 0)},G.open("POST",U),G.setRequestHeader("Content-Type","text/plain"),void G.send(O)}W()}},Sr=ft;function xr(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var Q,V,Z=[],ie=!0,ee=!1;try{for(G=G.call(w);!(ie=(Q=G.next()).done)&&(Z.push(Q.value),!W||Z.length!==W);ie=!0);}catch(oe){ee=!0,V=oe}finally{try{ie||G.return==null||G.return()}finally{if(ee)throw V}}return Z}}(U,O)||function(w,W){if(w){if(typeof w=="string")return Yr(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?Yr(w,W):void 0}}(U,O)||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 Jr(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}function Zr(U,O){for(var w=0;w<O.length;w++){var W=O[w];W.enumerable=W.enumerable||!1,W.configurable=!0,"value"in W&&(W.writable=!0),Object.defineProperty(U,W.key,W)}}function Dr(U,O){return Dr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(w,W){return w.__proto__=W,w},Dr(U,O)}function Wi(U){var O=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,W=ur(U);if(O){var G=ur(this).constructor;w=Reflect.construct(W,arguments,G)}else w=W.apply(this,arguments);return Gi(this,w)}}function Gi(U,O){if(O&&(Ar(O)==="object"||typeof O=="function"))return O;if(O!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ge(U)}function Ge(U){if(U===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return U}function ur(U){return ur=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(O){return O.__proto__||Object.getPrototypeOf(O)},ur(U)}var Hi=["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"],ji=function(U){(function(V,Z){if(typeof Z!="function"&&Z!==null)throw new TypeError("Super expression must either be null or a function");V.prototype=Object.create(Z&&Z.prototype,{constructor:{value:V,writable:!0,configurable:!0}}),Object.defineProperty(V,"prototype",{writable:!1}),Z&&Dr(V,Z)})(Q,U);var O,w,W,G=Wi(Q);function Q(V,Z,ie){var ee;(function(he,ye){if(!(he instanceof ye))throw new TypeError("Cannot call a class as a function")})(this,Q),(ee=G.call(this)).DOM_CONTENT_LOADED_EVENT_END=v.domContentLoadedEventEnd(),ee.NAVIGATION_START=v.navigationStart(),ee.mux=V,ee.id=Z,(ie=a()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(he){return he}},ie)).data=ie.data||{},ie.data.property_key&&(ie.data.env_key=ie.data.property_key,delete ie.data.property_key),f.setLevel(ie.debug?"debug":"warn"),ee.getPlayheadTime=ie.getPlayheadTime,ee.getStateData=ie.getStateData||function(){return{}},ee.getAdData=ie.getAdData||function(){},ee.minimumRebufferDuration=ie.minimumRebufferDuration,ee.sustainedRebufferThreshold=ie.sustainedRebufferThreshold,ee.playbackHeartbeatTime=ie.playbackHeartbeatTime,ee.disableRebufferTracking=ie.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=ie.disablePlayheadRebufferTracking,ee.errorTranslator=ie.errorTranslator,ee.playbackEventDispatcher=new ki(V,ie.data.env_key,ie),ee.data={player_instance_id:P(),mux_sample_rate:ie.sampleRate,beacon_domain:ie.beaconCollectionDomain?ie.beaconCollectionDomain:ie.beaconDomain},ee.data.view_sequence_number=1,ee.data.player_sequence_number=1,ee.oldEmit=ee.emit,ee.emit=function(he,ye){ye=a()({viewer_time:this.mux.utils.now()},ye),this.oldEmit(he,ye)};var oe=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Ge(ee));ee.on("viewinit",function(he,ye){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),a()(this.data,ye),this._initializeViewData(),this.one("play",oe),this.one("adbreakstart",oe)});var Ee=function(he){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",he)}.bind(Ge(ee));if(ee.on("videochange",function(he,ye){Ee(ye)}),ee.on("programchange",function(he,ye){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."),Ee(a()(ye,{view_program_changed:!0})),oe(),this.emit("play"),this.emit("playing")}),ee.on("fragmentchange",function(he,ye){this.currentFragmentPDT=ye.currentFragmentPDT,this.currentFragmentStart=ye.currentFragmentStart}),ee.on("destroy",ee.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var ve=function(){var he=ee.data.view_start!==void 0;ee.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",he&&ee.mux.WINDOW_HIDDEN&&(ee.data.player_is_paused||ee.emit("hb"))};window.addEventListener("visibilitychange",ve,!1);var pe=function(he){he.persisted||ee.destroy()};window.addEventListener("pagehide",pe,!1),ee.on("destroy",function(){window.removeEventListener("visibilitychange",ve),window.removeEventListener("pagehide",pe)})}return ee.on("playerready",function(he,ye){a()(this.data,ye)}),Hi.forEach(function(he){ee.on(he,function(ye,Le){he.indexOf("ad")!==0&&this._updateStateData(),a()(this.data,Le),this._sanitizeData()}),ee.on("after"+he,function(){(he!=="error"||this.errorTracker.viewErrored)&&this.send(he)})}),ee.on("viewend",function(he,ye){a()(ee.data,ye)}),ee.one("playerready",function(he){var ye=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ye-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 Ni(Ge(ee)),ee.errorTracker=new ae(Ge(ee)),new et(Ge(ee)),ee.seekingTracker=new ze(Ge(ee)),ee.playheadTime=new de(Ge(ee)),ee.playbackHeartbeat=new Y(Ge(ee)),new Ne(Ge(ee)),ee.watchTimeTracker=new se(Ge(ee)),new ce(Ge(ee)),ee.adTracker=new Ke(Ge(ee)),new Ce(Ge(ee)),new be(Ge(ee)),new Me(Ge(ee)),new ct(Ge(ee)),new Ui(Ge(ee)),ie.hlsjs&&ee.addHLSJS(ie),ie.dashjs&&ee.addDashJS(ie),ee.emit("viewinit",ie.data),ee}return O=Q,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(V){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(Ee){Z[Ee]=void 0}),Z.video_source_url=Z.video_source_url||Z.player_source_url,Z.video_source_url){var ie=Ki(n(Z.video_source_url),2),ee=ie[0],oe=ie[1];Z.video_source_domain=oe,Z.video_source_hostname=ee}delete Z.ad_request_id,this.playbackEventDispatcher.send(V,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 V=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Z){var ie=parseInt(V.data[Z],10);V.data[Z]=isNaN(ie)?void 0:ie}),["player_source_url","video_source_url"].forEach(function(Z){if(V.data[Z]){var ie=V.data[Z].toLowerCase();ie.indexOf("data:")!==0&&ie.indexOf("blob:")!==0||(V.data[Z]="MSE style URL")}})}},{key:"_resetVideoData",value:function(V,Z){var ie=this;Object.keys(this.data).forEach(function(ee){ee.indexOf("video_")===0&&delete ie.data[ee]})}},{key:"_resetViewData",value:function(){var V=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("view_")===0&&delete V.data[Z]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(V,Z){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var V=this,Z=this.data.view_id=P(),ie=function(){Z===V.data.view_id&&l(V.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",ie):ie()}},{key:"_restartHeartBeat",value:function(){var V=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){V.data.player_is_paused||V.emit("hb")},1e4))}},{key:"addHLSJS",value:function(V){V.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=V.hlsjs,function(Z,ie,ee){var oe=arguments.length>4?arguments[4]:void 0,Ee=Z.log,ve=Z.utils.secondsToMs,pe=function(Ae){var me,_e=parseInt(oe.version);return _e===1&&Ae.programDateTime!==null&&(me=Ae.programDateTime),_e===0&&Ae.pdt!==null&&(me=Ae.pdt),me};if(v.exists()){var he=function(Ae,me){return Z.emit(ie,Ae,me)},ye=function(Ae,me){var _e=me.levels,ge=me.audioTracks,Te=me.url,Ue=me.stats,Be=me.networkDetails,st=me.sessionData,tt={},vt={};_e.forEach(function(Et,Qt){tt[Qt]={width:Et.width,height:Et.height,bitrate:Et.bitrate,attrs:Et.attrs}}),ge.forEach(function(Et,Qt){vt[Qt]={name:Et.name,language:Et.lang,bitrate:Et.bitrate}});var ot=r(Ue),yt=ot.bytesLoaded,He=ot.requestStart,gt=ot.responseStart,Rr=ot.responseEnd;he("requestcompleted",m(m({},g(st)),{},{request_event_type:Ae,request_bytes_loaded:yt,request_start:He,request_response_start:gt,request_response_end:Rr,request_type:"manifest",request_hostname:o(Te),request_response_headers:t(Be),request_rendition_lists:{media:tt,audio:vt,video:{}}}))};ee.on(oe.Events.MANIFEST_LOADED,ye);var Le=function(Ae,me){var _e=me.details,ge=me.level,Te=me.networkDetails,Ue=me.stats,Be=r(Ue),st=Be.bytesLoaded,tt=Be.requestStart,vt=Be.responseStart,ot=Be.responseEnd,yt=_e.fragments[_e.fragments.length-1],He=pe(yt)+ve(yt.duration);he("requestcompleted",{request_event_type:Ae,request_bytes_loaded:st,request_start:tt,request_response_start:vt,request_response_end:ot,request_current_level:ge,request_type:"manifest",request_hostname:o(_e.url),request_response_headers:t(Te),video_holdback:_e.holdBack&&ve(_e.holdBack),video_part_holdback:_e.partHoldBack&&ve(_e.partHoldBack),video_part_target_duration:_e.partTarget&&ve(_e.partTarget),video_target_duration:_e.targetduration&&ve(_e.targetduration),video_source_is_live:_e.live,player_manifest_newest_program_time:isNaN(He)?void 0:He})};ee.on(oe.Events.LEVEL_LOADED,Le);var je=function(Ae,me){var _e=me.details,ge=me.networkDetails,Te=me.stats,Ue=r(Te),Be=Ue.bytesLoaded,st=Ue.requestStart,tt=Ue.responseStart,vt=Ue.responseEnd;he("requestcompleted",{request_event_type:Ae,request_bytes_loaded:Be,request_start:st,request_response_start:tt,request_response_end:vt,request_type:"manifest",request_hostname:o(_e.url),request_response_headers:t(ge)})};ee.on(oe.Events.AUDIO_TRACK_LOADED,je);var Ve=function(Ae,me){var _e=me.stats,ge=me.networkDetails,Te=me.frag;_e=_e||Te.stats;var Ue=r(_e),Be=Ue.bytesLoaded,st=Ue.requestStart,tt=Ue.responseStart,vt=Ue.responseEnd,ot=t(ge),yt=ot==null?void 0:ot["x-request-id"],He={request_event_type:Ae,request_bytes_loaded:Be,request_start:st,request_response_start:tt,request_response_end:vt,request_hostname:ge?o(ge.responseURL):void 0,request_id:yt,request_response_headers:ot,request_media_duration:Te.duration,request_url:ge==null?void 0:ge.responseURL};Te.type==="main"?(He.request_type="media",He.request_current_level=Te.level,He.request_video_width=(ee.levels[Te.level]||{}).width,He.request_video_height=(ee.levels[Te.level]||{}).height,He.request_labeled_bitrate=(ee.levels[Te.level]||{}).bitrate):He.request_type=Te.type,he("requestcompleted",He)};ee.on(oe.Events.FRAG_LOADED,Ve);var at=function(Ae,me){var _e=me.frag,ge=_e.start,Te={currentFragmentPDT:pe(_e),currentFragmentStart:ve(ge)};he("fragmentchange",Te)};ee.on(oe.Events.FRAG_CHANGED,at);var xe=function(Ae,me){var _e=me.type,ge=me.details,Te=me.response,Ue=me.fatal,Be=me.context,st=me.frag;if(ge===oe.ErrorDetails.MANIFEST_LOAD_ERROR||ge===oe.ErrorDetails.MANIFEST_LOAD_TIMEOUT||ge===oe.ErrorDetails.FRAG_LOAD_ERROR||ge===oe.ErrorDetails.FRAG_LOAD_TIMEOUT||ge===oe.ErrorDetails.LEVEL_LOAD_ERROR||ge===oe.ErrorDetails.LEVEL_LOAD_TIMEOUT){var tt=st&&st.url||Be&&Be.url||"";he("requestfailed",{request_error:ge,request_url:tt,request_hostname:o(tt),request_type:ge===oe.ErrorDetails.FRAG_LOAD_ERROR||ge===oe.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:Te&&Te.code,request_error_text:Te&&Te.text})}Ue&&he("error",{player_error_code:_e,player_error_message:ge})};ee.on(oe.Events.ERROR,xe);var Ye=function(Ae,me){var _e=me.frag,ge=_e&&_e._url||"";he("requestcanceled",{request_event_type:Ae,request_url:ge,request_type:"media",request_hostname:o(ge)})};ee.on(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ye);var $e=function(Ae,me){var _e=me.level,ge=ee.levels[_e];if(ge&&ge.attrs&&ge.attrs.BANDWIDTH){var Te,Ue=ge.attrs.BANDWIDTH,Be=parseFloat(ge.attrs["FRAME-RATE"]);isNaN(Be)||(Te=Be),Ue?he("renditionchange",{video_source_fps:Te,video_source_bitrate:Ue,video_source_width:ge.width,video_source_height:ge.height,video_source_rendition_name:ge.name,video_source_codec:ge==null?void 0:ge.videoCodec}):Ee.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};ee.on(oe.Events.LEVEL_SWITCHED,$e),ee._stopMuxMonitor=function(){ee.off(oe.Events.MANIFEST_LOADED,ye),ee.off(oe.Events.LEVEL_LOADED,Le),ee.off(oe.Events.AUDIO_TRACK_LOADED,je),ee.off(oe.Events.FRAG_LOADED,Ve),ee.off(oe.Events.FRAG_CHANGED,at),ee.off(oe.Events.ERROR,xe),ee.off(oe.Events.FRAG_LOAD_EMERGENCY_ABORTED,Ye),ee.off(oe.Events.LEVEL_SWITCHED,$e),ee.off(oe.Events.DESTROYING,ee._stopMuxMonitor),delete ee._stopMuxMonitor},ee.on(oe.Events.DESTROYING,ee._stopMuxMonitor)}else Ee.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,V.hlsjs,{},V.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var V;this.hlsjs&&((V=this.hlsjs)&&typeof V._stopMuxMonitor=="function"&&V._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(V){V.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=V.dashjs,function(Z,ie,ee){var oe=Z.log;if(ee&&ee.on){var Ee=function(xe,Ye){return Z.emit(ie,xe,Ye)},ve=function(xe){var Ye=xe.type,$e=(xe.data||{}).url;Ee("requestcompleted",{request_event_type:Ye,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:o($e),request_url:$e})};ee.on("manifestLoaded",ve);var pe={},he=function(xe){var Ye=xe.type,$e=xe.fragmentModel,Ae=(xe.chunk||{}).mediaInfo||{},me=Ae.type,_e=Ae.bitrateList,ge={};(_e=_e||[]).forEach(function(He,gt){ge[gt]={},ge[gt].width=He.width,ge[gt].height=He.height,ge[gt].bitrate=He.bandwidth,ge[gt].attrs={}}),me==="video"?pe.video=ge:me==="audio"?pe.audio=ge:pe.media=ge;var Te=L($e,ee),Ue=Te.requestStart,Be=Te.requestResponseStart,st=Te.requestResponseEnd,tt=Te.requestResponseHeaders,vt=Te.requestMediaDuration,ot=Te.requestHostname,yt=Te.requestUrl;Ee("requestcompleted",{request_event_type:Ye,request_start:Ue,request_response_start:Be,request_response_end:st,request_bytes_loaded:-1,request_type:me+"_init",request_response_headers:tt,request_hostname:ot,request_url:yt,request_media_duration:vt,request_rendition_lists:pe})};ee.on("initFragmentLoaded",he);var ye=function(xe){var Ye=xe.type,$e=xe.fragmentModel,Ae=xe.chunk||{},me=Ae.mediaInfo,_e=Ae.start,ge=(me||{}).type,Te=L($e,ee),Ue=Te.requestStart,Be=Te.requestResponseStart,st=Te.requestResponseEnd,tt=Te.requestBytesLoaded,vt=Te.requestResponseHeaders,ot=Te.requestMediaDuration,yt=Te.requestHostname,He=Te.requestUrl,gt=R(ge,ee),Rr=gt.currentLevel,Et=gt.renditionWidth,Qt=gt.renditionHeight,vn=gt.renditionBitrate;Ee("requestcompleted",{request_event_type:Ye,request_start:Ue,request_response_start:Be,request_response_end:st,request_bytes_loaded:tt,request_type:ge,request_response_headers:vt,request_hostname:yt,request_url:He,request_media_start_time:_e,request_media_duration:ot,request_current_level:Rr,request_labeled_bitrate:vn,request_video_width:Et,request_video_height:Qt})};ee.on("mediaFragmentLoaded",ye);var Le={video:void 0,audio:void 0,totalBitrate:void 0},je=function(){if(Le.video&&typeof Le.video.bitrate=="number"){if(Le.video.width&&Le.video.height){var xe=Le.video.bitrate;return Le.audio&&typeof Le.audio.bitrate=="number"&&(xe+=Le.audio.bitrate),xe!==Le.totalBitrate?(Le.totalBitrate=xe,{video_source_bitrate:xe,video_source_height:Le.video.height,video_source_width:Le.video.width,video_source_codec:I(Le.video.codec)}):void 0}oe.warn("have bitrate info for video but missing width/height")}},Ve=function(xe,Ye,$e){if(typeof xe.newQuality=="number"){var Ae=xe.mediaType;if(Ae==="audio"||Ae==="video"){var me=ee.getBitrateInfoListFor(Ae).find(function(ge){return ge.qualityIndex===xe.newQuality});if(me&&typeof me.bitrate=="number"){Le[Ae]=y(y({},me),{},{codec:ee.getCurrentTrackFor(Ae).codec});var _e=je();_e&&Ee("renditionchange",_e)}else oe.warn("missing bitrate info for ".concat(Ae))}}else oe.warn("missing evt.newQuality in qualityChangeRendered event",xe)};ee.on("qualityChangeRendered",Ve);var at=function(xe){var Ye=xe.error,$e=xe.event,Ae=($e=$e||{}).request||{},me=M().event&&M().event.currentTarget||{};Ee("requestfailed",{request_error:Ye+"_"+$e.id+"_"+Ae.type,request_url:$e.url,request_hostname:o($e.url),request_type:Ae.mediaType,request_error_code:me.status,request_error_type:me.statusText})};ee.on("error",at),ee._stopMuxMonitor=function(){ee.off("manifestLoaded",ve),ee.off("initFragmentLoaded",he),ee.off("mediaFragmentLoaded",ye),ee.off("qualityChangeRendered",Ve),ee.off("error",at),delete ee._stopMuxMonitor}}else oe.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,V.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var V;this.dashjs&&((V=this.dashjs)&&typeof V._stopMuxMonitor=="function"&&V._stopMuxMonitor(),this.dashjs=void 0)}}],w&&Zr(O.prototype,w),W&&Zr(O,W),Object.defineProperty(O,"prototype",{writable:!1}),Q}(H),Vi=ji,Yi=C(153),Xt=C.n(Yi);function br(U){return br=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(O){return typeof O}:function(O){return O&&typeof Symbol=="function"&&O.constructor===Symbol&&O!==Symbol.prototype?"symbol":typeof O},br(U)}function qr(U,O){return function(w){if(Array.isArray(w))return w}(U)||function(w,W){var G=w==null?null:typeof Symbol!="undefined"&&w[Symbol.iterator]||w["@@iterator"];if(G!=null){var Q,V,Z=[],ie=!0,ee=!1;try{for(G=G.call(w);!(ie=(Q=G.next()).done)&&(Z.push(Q.value),!W||Z.length!==W);ie=!0);}catch(oe){ee=!0,V=oe}finally{try{ie||G.return==null||G.return()}finally{if(ee)throw V}}return Z}}(U,O)||function(w,W){if(w){if(typeof w=="string")return ei(w,W);var G=Object.prototype.toString.call(w).slice(8,-1);return G==="Object"&&w.constructor&&(G=w.constructor.name),G==="Map"||G==="Set"?Array.from(w):G==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(G)?ei(w,W):void 0}}(U,O)||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 ri(U,O){(O==null||O>U.length)&&(O=U.length);for(var w=0,W=new Array(O);w<O;w++)W[w]=U[w];return W}var ht={},zt=function U(O){var w=arguments;typeof O=="string"?U.hasOwnProperty(O)?M().setTimeout(function(){w=Array.prototype.splice.call(w,1),U[O].apply(null,w)},0):f.warn("`"+O+"` is an unknown task"):typeof O=="function"?M().setTimeout(function(){O(U)},0):f.warn("`"+O+"` is invalid.")},cn={loaded:p.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(U,O){return function(w,W,G){var Q=qr(A(W),3),V=Q[0],Z=Q[1],ie=Q[2],ee=w.log,oe=w.utils.getComputedStyle,Ee=w.utils.secondsToMs;if(!V)return ee.error("No element was found with the `"+Z+"` query selector.");if(ie!=="video"&&ie!=="audio")return ee.error("The element of `"+Z+"` was not a media element.");V.mux&&(V.mux.destroy(),delete V.mux,ee.warn("Already monitoring this video element, replacing existing event listeners")),(G=a()({automaticErrorTracking:!0},G)).data=a()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:w.VERSION},G.data),G.getPlayheadTime=function(){return Ee(V.currentTime)},G.getStateData=function(){var pe,he,ye=this.hlsjs&&this.hlsjs.url,Le=this.dashjs&&br(this.dashjs.getSource==="function")&&this.dashjs.getSource(),je={player_is_paused:V.paused,player_playhead_time:Ee(V.currentTime),player_width:parseInt(oe(V,"width")),player_height:parseInt(oe(V,"height")),player_autoplay_on:V.autoplay,player_preload_on:V.preload,player_language_code:V.lang,player_is_fullscreen:Xt()&&!!(Xt().fullscreenElement||Xt().webkitFullscreenElement||Xt().mozFullScreenElement||Xt().msFullscreenElement),video_poster_url:V.poster,video_source_url:ye||Le||V.currentSrc,video_source_duration:Ee(V.duration),video_source_height:V.videoHeight,video_source_width:V.videoWidth,view_dropped_frame_count:(pe=V)===null||pe===void 0||(he=pe.getVideoPlaybackQuality)===null||he===void 0?void 0:he.call(pe).droppedVideoFrames},Ve=G.getPlayheadTime();if(V.getStartDate&&Ve>0){var at=V.getStartDate();if(at&&typeof at.getTime=="function"&&at.getTime()){var xe=at.getTime();if(je.player_program_time=xe+Ve,V.seekable.length>0){var Ye=xe+V.seekable.end(V.seekable.length-1);je.player_live_edge_program_time=Ye}}}return je},V.mux=V.mux||{},V.mux.deleted=!1,V.mux.emit=function(pe,he){w.emit(Z,pe,he)};var ve=function(){ee.error("The monitor for this video element has already been destroyed.")};V.mux.destroy=function(){Object.keys(V.mux.listeners).forEach(function(pe){V.removeEventListener(pe,V.mux.listeners[pe],!1)}),delete V.mux.listeners,V.mux.destroy=ve,V.mux.swapElement=ve,V.mux.emit=ve,V.mux.addHLSJS=ve,V.mux.addDashJS=ve,V.mux.removeHLSJS=ve,V.mux.removeDashJS=ve,V.mux.deleted=!0,w.emit(Z,"destroy")},V.mux.swapElement=function(pe){var he=qr(A(pe),3),ye=he[0],Le=he[1],je=he[2];return ye?je!=="video"&&je!=="audio"?w.log.error("The element of `"+Le+"` was not a media element."):(ye.muxId=V.muxId,delete V.muxId,ye.mux=ye.mux||{},ye.mux.listeners=a()({},V.mux.listeners),delete V.mux.listeners,Object.keys(ye.mux.listeners).forEach(function(Ve){V.removeEventListener(Ve,ye.mux.listeners[Ve],!1),ye.addEventListener(Ve,ye.mux.listeners[Ve],!1)}),ye.mux.swapElement=V.mux.swapElement,ye.mux.destroy=V.mux.destroy,delete V.mux,void(V=ye)):w.log.error("No element was found with the `"+Le+"` query selector.")},V.mux.addHLSJS=function(pe){w.addHLSJS(Z,pe)},V.mux.addDashJS=function(pe){w.addDashJS(Z,pe)},V.mux.removeHLSJS=function(){w.removeHLSJS(Z)},V.mux.removeDashJS=function(){w.removeDashJS(Z)},w.init(Z,G),w.emit(Z,"playerready"),V.paused||(w.emit(Z,"play"),V.readyState>2&&w.emit(Z,"playing")),V.mux.listeners={},Xi.forEach(function(pe){(pe!=="error"||G.automaticErrorTracking)&&(V.mux.listeners[pe]=function(){var he={};if(pe==="error"){if(!V.error||V.error.code===1)return;he.player_error_code=V.error.code,he.player_error_message=zi[V.error.code]||V.error.message}w.emit(Z,pe,he)},V.addEventListener(pe,V.mux.listeners[pe],!1))})}(zt,U,O)},destroyMonitor:function(U){var O=fn(A(U),1)[0];O&&O.mux&&typeof O.mux.destroy=="function"?O.mux.destroy():f.error("A video element monitor for `"+U+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(U,O){var w=b(U);ht[w]?ht[w].addHLSJS(O):f.error("A monitor for `"+w+"` has not been initialized.")},addDashJS:function(U,O){var w=b(U);ht[w]?ht[w].addDashJS(O):f.error("A monitor for `"+w+"` has not been initialized.")},removeHLSJS:function(U){var O=b(U);ht[O]?ht[O].removeHLSJS():f.error("A monitor for `"+O+"` has not been initialized.")},removeDashJS:function(U){var O=b(U);ht[O]?ht[O].removeDashJS():f.error("A monitor for `"+O+"` has not been initialized.")},init:function(U,O){E()&&O&&O.respectDoNotTrack&&f.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var w=b(U);ht[w]=new Vi(zt,w,O)},emit:function(U,O,w){var W=b(U);ht[W]?(ht[W].emit(O,w),O==="destroy"&&delete ht[W]):f.error("A monitor for `"+W+"` has not been initialized.")},checkDoNotTrack:E,log:f,utils:un,events:dn,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(zt,cn),M()!==void 0&&typeof M().addEventListener=="function"&&M().addEventListener("pagehide",function(U){U.persisted||(zt.WINDOW_UNLOADING=!0)},!1);var hn=zt},655:function(N,_,C){var D,M;function P(B){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(B);}(function(B){var b=!1;if((M=typeof(D=B)=="function"?D.call(_,C,_,N):D)===void 0||(N.exports=M),b=!0,P(_)==="object"&&(N.exports=B(),b=!0),!b){var A=window.Cookies,S=window.Cookies=B();S.noConflict=function(){return window.Cookies=A,S}}})(function(){var B=function(){for(var b=0,A={};b<arguments.length;b++){var S=arguments[b];for(var T in S)A[T]=S[T]}return A};return function b(A){function S(T,x,f){var E;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(f=B({path:"/"},S.defaults,f)).expires=="number"){var p=new Date;p.setMilliseconds(p.getMilliseconds()+864e5*f.expires),f.expires=p}try{E=JSON.stringify(x),/^[\{\[]/.test(E)&&(x=E)}catch{}return x=A.write?A.write(x,T):encodeURIComponent(String(x)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),T=(T=(T=encodeURIComponent(String(T))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[T,"=",x,f.expires?"; expires="+f.expires.toUTCString():"",f.path?"; path="+f.path:"",f.domain?"; domain="+f.domain:"",f.secure?"; secure":""].join("")}T||(E={});for(var h=document.cookie?document.cookie.split("; "):[],a=/(%[0-9A-Z]{2})+/g,o=0;o<h.length;o++){var n=h[o].split("="),v=n.slice(1).join("=");v.charAt(0)==='"'&&(v=v.slice(1,-1));try{var l=n[0].replace(a,decodeURIComponent);if(v=A.read?A.read(v,l):A(v,l)||v.replace(a,decodeURIComponent),this.json)try{v=JSON.parse(v)}catch{}if(T===l){E=v;break}T||(E[l]=v)}catch{}}return E}}return S.set=S,S.get=function(T){return S.call(S,T)},S.getJSON=function(){return S.apply({json:!0},[].slice.call(arguments))},S.defaults={},S.remove=function(T,x){S(T,"",B(x,{expires:-1}))},S.withConverter=b,S}(function(){})})},153:function(N,_,C){var D,M=C.g!==void 0?C.g:typeof window!="undefined"?window:{},P=C(558);typeof document!="undefined"?D=document:(D=M["__GLOBAL_DOCUMENT_CACHE@4"])||(D=M["__GLOBAL_DOCUMENT_CACHE@4"]=P),N.exports=D},48:function(N,_,C){var D;D=typeof window!="undefined"?window:C.g!==void 0?C.g:typeof self!="undefined"?self:{},N.exports=D},678:function(N){var _=9007199254740991,C="[object Arguments]",D="[object Function]",M="[object GeneratorFunction]",P=/^(?:0|[1-9]\d*)$/;function B(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,T=S.hasOwnProperty,x=S.toString,f=S.propertyIsEnumerable,E=(b=Object.keys,A=Object,function(e){return b(A(e))}),p=Math.max,h=!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)&&T.call(L,"callee")&&(!f.call(L,"callee")||x.call(L)==C)}(e)?function(L,R){for(var I=-1,k=Array(L);++I<L;)k[I]=R(I);return k}(e.length,String):[],s=t.length,y=!!s;for(var d in e)!r&&!T.call(e,d)||y&&(d=="length"||n(d,s))||t.push(d);return t}function o(e,r,t){var s=e[r];T.call(e,r)&&l(s,t)&&(t!==void 0||r in e)||(e[r]=t)}function n(e,r){return!!(r=r==null?_:r)&&(typeof e=="number"||P.test(e))&&e>-1&&e%1==0&&e<r}function v(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<=_}(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(h||v(r)||u(r))(function(s,y,d,L){d||(d={});for(var R=-1,I=y.length;++R<I;){var k=y[R],F=L?L(d[k],s[k],k,d,s):void 0;o(d,k,F===void 0?s[k]:F)}})(r,function(s){return u(s)?a(s):function(y){if(!v(y))return E(y);var d=[];for(var L in Object(y))T.call(y,L)&&L!="constructor"&&d.push(L);return d}(s)}(r),e);else for(var t in r)T.call(r,t)&&o(e,t,r[t])},function(e,r){return r=p(r===void 0?e.length-1:r,0),function(){for(var t=arguments,s=-1,y=p(t.length-r,0),d=Array(y);++s<y;)d[s]=t[r+s];s=-1;for(var L=Array(r+1);++s<r;)L[s]=t[s];return L[r]=d,B(e,this,L)}}(function(e,r){var t=-1,s=r.length,y=s>1?r[s-1]:void 0,d=s>2?r[2]:void 0;for(y=c.length>3&&typeof y=="function"?(s--,y):void 0,d&&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],d)&&(y=s<3?void 0:y,s=1),e=Object(e);++t<s;){var L=r[t];L&&c(e,L,t,y)}return e}));N.exports=m},640:function(N,_,C){var D,M;(function(P,B){"use strict";D=function(){var b=function(){},A="undefined",S=typeof window!==A&&typeof window.navigator!==A&&/Trident\/|MSIE /.test(window.navigator.userAgent),T=["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 E(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<T.length;g++){var c=T[g];this[c]=g<i?b:this.methodFactory(c,i,u)}this.log=this.debug}function h(i,u,g){return function(){typeof console!==A&&(p.call(this,u,g),this[i].apply(this,arguments))}}function a(i,u,g){return E(i)||h.apply(this,arguments)}function o(i,u,g){var c,m=this;u=u==null?"WARN":u;var e="loglevel";function r(d){var L=(T[d]||"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 d;if(typeof window!==A&&e){try{d=window.localStorage[e]}catch{}if(typeof d===A)try{var L=window.document.cookie,R=L.indexOf(encodeURIComponent(e)+"=");R!==-1&&(d=/^([^;]+)/.exec(L.slice(R))[1])}catch{}return m.levels[d]===void 0&&(d=void 0),d}}function s(){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(d,L){if(typeof d=="string"&&m.levels[d.toUpperCase()]!==void 0&&(d=m.levels[d.toUpperCase()]),!(typeof d=="number"&&d>=0&&d<=m.levels.SILENT))throw"log.setLevel() called with invalid level: "+d;if(c=d,L!==!1&&r(d),p.call(m,d,i),typeof console===A&&d<m.levels.SILENT)return"No console available for logging"},m.setDefaultLevel=function(d){u=d,t()||m.setLevel(d,!1)},m.resetLevel=function(){m.setLevel(u,!1),s()},m.enableAll=function(d){m.setLevel(m.levels.TRACE,d)},m.disableAll=function(d){m.setLevel(m.levels.SILENT,d)};var y=t();y==null&&(y=u),m.setLevel(y,!1)}var n=new o,v={};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=v[i];return u||(u=v[i]=new o(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 v},n.default=n,n},(M=typeof D=="function"?D.call(_,C,_,N):D)===void 0||(N.exports=M)})()},375:function(N,_){"use strict";var C=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}}_.stringify=function(P,B){B=B||"";var b,A,S=[];for(A in typeof B!="string"&&(B="?"),P)if(C.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?B+S.join("&"):""},_.parse=function(P){for(var B,b=/([^=?#&]+)=?([^&]*)/g,A={};B=b.exec(P);){var S=D(B[1]),T=D(B[2]);S===null||T===null||S in A||(A[S]=T)}return A}},558:function(){}},ne={};function z(N){var _=ne[N];if(_!==void 0)return _.exports;var C=ne[N]={exports:{}};return X[N].call(C.exports,C,C.exports,z),C.exports}return z.n=function(N){var _=N&&N.__esModule?function(){return N.default}:function(){return N};return z.d(_,{a:_}),_},z.d=function(N,_){for(var C in _)z.o(_,C)&&!z.o(N,C)&&Object.defineProperty(N,C,{enumerable:!0,get:_[C]})},z.g=function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}}(),z.o=function(N,_){return Object.prototype.hasOwnProperty.call(N,_)},z(80)}()},typeof cr=="object"&&typeof wr=="object"?wr.exports=q():typeof cr=="object"?cr.mux=q():$.mux=q()})()});var hr=ni((Zt,kr)=>{typeof window!="undefined"&&function(q,X){typeof Zt=="object"&&typeof kr=="object"?kr.exports=X():typeof define=="function"&&define.amd?define([],X):typeof Zt=="object"?Zt.Hls=X():q.Hls=X()}(Zt,()=>(()=>{var $={"./src/config.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{enableStreamingMode:()=>r,hlsDefaultConfig:()=>c,mergeConfig:()=>e});var C=_("./src/controller/abr-controller.ts"),D=_("./src/controller/audio-stream-controller.ts"),M=_("./src/controller/audio-track-controller.ts"),P=_("./src/controller/subtitle-stream-controller.ts"),B=_("./src/controller/subtitle-track-controller.ts"),b=_("./src/controller/buffer-controller.ts"),A=_("./src/controller/timeline-controller.ts"),S=_("./src/controller/cap-level-controller.ts"),T=_("./src/controller/fps-controller.ts"),x=_("./src/controller/eme-controller.ts"),f=_("./src/controller/cmcd-controller.ts"),E=_("./src/utils/xhr-loader.ts"),p=_("./src/utils/fetch-loader.ts"),h=_("./src/utils/cues.ts"),a=_("./src/utils/mediakeys-helper.ts"),o=_("./src/utils/logger.ts");function n(){return n=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var y=arguments[s];for(var d in y)Object.prototype.hasOwnProperty.call(y,d)&&(t[d]=y[d])}return t},n.apply(this,arguments)}function v(t,s){var y=Object.keys(t);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(t);s&&(d=d.filter(function(L){return Object.getOwnPropertyDescriptor(t,L).enumerable})),y.push.apply(y,d)}return y}function l(t){for(var s=1;s<arguments.length;s++){var y=arguments[s]!=null?arguments[s]:{};s%2?v(Object(y),!0).forEach(function(d){i(t,d,y[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(y)):v(Object(y)).forEach(function(d){Object.defineProperty(t,d,Object.getOwnPropertyDescriptor(y,d))})}return t}function i(t,s,y){return s=u(s),s in t?Object.defineProperty(t,s,{value:y,enumerable:!0,configurable:!0,writable:!0}):t[s]=y,t}function u(t){var s=g(t,"string");return typeof s=="symbol"?s:String(s)}function g(t,s){if(typeof t!="object"||t===null)return t;var y=t[Symbol.toPrimitive];if(y!==void 0){var d=y.call(t,s||"default");if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="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:E.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:C.default,bufferController:b.default,capLevelController:S.default,fpsController:T.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:B.default,timelineController:A.TimelineController,audioStreamController:D.default,audioTrackController:M.default,emeController:x.default,cmcdController:f.default});function m(){return{cueHandler:h.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,s){if((s.liveSyncDurationCount||s.liveMaxLatencyDurationCount)&&(s.liveSyncDuration||s.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(s.liveMaxLatencyDurationCount!==void 0&&(s.liveSyncDurationCount===void 0||s.liveMaxLatencyDurationCount<=s.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(s.liveMaxLatencyDuration!==void 0&&(s.liveSyncDuration===void 0||s.liveMaxLatencyDuration<=s.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return n({},t,s)}function r(t){var s=t.loader;if(s!==p.default&&s!==E.default)o.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,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>E});var C=_("./src/polyfills/number.ts"),D=_("./src/utils/ewma-bandwidth-estimator.ts"),M=_("./src/events.ts"),P=_("./src/errors.ts"),B=_("./src/types/loader.ts"),b=_("./src/utils/logger.ts");function A(p,h){for(var a=0;a<h.length;a++){var o=h[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(p,T(o.key),o)}}function S(p,h,a){return h&&A(p.prototype,h),a&&A(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function T(p){var h=x(p,"string");return typeof h=="symbol"?h:String(h)}function x(p,h){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var o=a.call(p,h||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(h==="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 o=a.config;this.bwEstimator=new D.default(o.abrEwmaSlowVoD,o.abrEwmaFastVoD,o.abrEwmaDefaultEstimate),this.registerListeners()}var h=p.prototype;return h.registerListeners=function(){var o=this.hls;o.on(M.Events.FRAG_LOADING,this.onFragLoading,this),o.on(M.Events.FRAG_LOADED,this.onFragLoaded,this),o.on(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.on(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(M.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var o=this.hls;o.off(M.Events.FRAG_LOADING,this.onFragLoading,this),o.off(M.Events.FRAG_LOADED,this.onFragLoaded,this),o.off(M.Events.FRAG_BUFFERED,this.onFragBuffered,this),o.off(M.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(M.Events.ERROR,this.onError,this)},h.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},h.onFragLoading=function(o,n){var v=n.frag;if(v.type===B.PlaylistLevelType.MAIN&&!this.timer){var l;this.fragCurrent=v,this.partCurrent=(l=n.part)!=null?l:null,this.timer=self.setInterval(this.onCheck,100)}},h.onLevelLoaded=function(o,n){var v=this.hls.config;n.details.live?this.bwEstimator.update(v.abrEwmaSlowLive,v.abrEwmaFastLive):this.bwEstimator.update(v.abrEwmaSlowVoD,v.abrEwmaFastVoD)},h._abandonRulesCheck=function(){var o=this.fragCurrent,n=this.partCurrent,v=this.hls,l=v.autoLevelEnabled,i=v.media;if(!(!o||!i)){var u=n?n.stats:o.stats,g=n?n.duration:o.duration;if(u.aborted||u.loaded&&u.loaded===u.total||o.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!l||i.paused||!i.playbackRate||!i.readyState)){var c=v.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(),s=v.levels,y=v.minAutoLevel,d=s[o.level],L=u.total||Math.max(u.loaded,Math.round(g*d.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,K;for(K=o.level-1;K>y;K--){var H=s[K].maxBitrate;if(F=R?g*H/(8*.8*R):g*H/t,F<k)break}F>=I||(b.logger.warn("Fragment "+o.sn+(n?" part "+n.index:"")+" of level "+o.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+K+`
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Time to underbuffer: `+k.toFixed(3)+" s"),v.nextLoadLevel=K,r&&this.bwEstimator.sample(m,u.loaded),this.clearTimer(),(o.loader||o.keyLoader)&&(this.fragCurrent=this.partCurrent=null,o.abortRequests()),v.trigger(M.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:o,part:n,stats:u}))}}}}}},h.onFragLoaded=function(o,n){var v=n.frag,l=n.part;if(v.type===B.PlaylistLevelType.MAIN&&(0,C.isFiniteNumber)(v.sn)){var i=l?l.stats:v.stats,u=l?l.duration:v.duration;if(this.clearTimer(),this.lastLoadedFragLevel=v.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var g=this.hls.levels[v.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(v.bitrateTest){var e={stats:i,frag:v,part:l,id:v.type};this.onFragBuffered(M.Events.FRAG_BUFFERED,e)}}},h.onFragBuffered=function(o,n){var v=n.frag,l=n.part,i=l?l.stats:v.stats;if(!i.aborted&&!(v.type!==B.PlaylistLevelType.MAIN||v.sn==="initSegment")){var u=i.parsing.end-i.loading.start;this.bwEstimator.sample(u,i.loaded),i.bwEstimate=this.bwEstimator.getEstimate(),v.bitrateTest?this.bitrateTestDelay=u/1e3:this.bitrateTestDelay=0}},h.onError=function(o,n){var v;if(((v=n.frag)===null||v===void 0?void 0:v.type)===B.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}}},h.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},h.getNextABRAutoLevel=function(){var o=this.fragCurrent,n=this.partCurrent,v=this.hls,l=v.maxAutoLevel,i=v.config,u=v.minAutoLevel,g=v.media,c=n?n.duration:o?o.duration:0,m=g&&g.playbackRate!==0?Math.abs(g.playbackRate):1,e=this.bwEstimator?this.bwEstimator.getEstimate():i.abrEwmaDefaultEstimate,r=v.mainForwardBufferInfo,t=(r?r.len:0)/m,s=this.findBestLevel(e,u,l,t,i.abrBandWidthFactor,i.abrBandWidthUpFactor);if(s>=0)return s;b.logger.trace((t?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var y=c?Math.min(c,i.maxStarvationDelay):i.maxStarvationDelay,d=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"),d=L=1}}return s=this.findBestLevel(e,u,l,t+y,d,L),Math.max(s,0)},h.findBestLevel=function(o,n,v,l,i,u){for(var g,c=this.fragCurrent,m=this.partCurrent,e=this.lastLoadedFragLevel,r=this.hls.levels,t=r[e],s=!!(t!=null&&(g=t.details)!==null&&g!==void 0&&g.live),y=t==null?void 0:t.codecSet,d=m?m.duration:c?c.duration:0,L=v;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)||d,F=void 0;L<=e?F=i*o:F=u*o;var K=r[L].maxBitrate,H=K*k/F;if(b.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+L+"/"+Math.round(F)+"/"+K+"/"+k+"/"+l+"/"+H),F>K&&(H===0||!(0,C.isFiniteNumber)(H)||s&&!this.bitrateTestDelay||H<l))return L}}return-1},S(p,[{key:"nextAutoLevel",get:function(){var o=this._nextAutoLevel,n=this.bwEstimator;if(o!==-1&&!n.canEstimate())return o;var v=this.getNextABRAutoLevel();return o!==-1&&this.hls.levels[v].loadError?o:(o!==-1&&(v=Math.min(o,v)),v)},set:function(o){this._nextAutoLevel=o}}]),p}();let E=f},"./src/controller/audio-stream-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>i});var C=_("./src/polyfills/number.ts"),D=_("./src/controller/base-stream-controller.ts"),M=_("./src/events.ts"),P=_("./src/utils/buffer-helper.ts"),B=_("./src/controller/fragment-tracker.ts"),b=_("./src/types/level.ts"),A=_("./src/types/loader.ts"),S=_("./src/loader/fragment.ts"),T=_("./src/demux/chunk-cache.ts"),x=_("./src/demux/transmuxer-interface.ts"),f=_("./src/types/transmuxer.ts"),E=_("./src/controller/fragment-finders.ts"),p=_("./src/utils/discontinuities.ts"),h=_("./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 o(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 v=100,l=function(u){o(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,s=r.id,y=r.initPTS;if(s==="main"){var d=t.cc;this.initPTS[t.cc]=y,this.log("InitPTS for cc: "+d+" found from main: "+y),this.videoTrackCC=d,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(v),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,s=r==null||(e=r[t])===null||e===void 0?void 0:e.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=D.State.WAITING_INIT_PTS}break}case D.State.FRAG_LOADING_WAITING_RETRY:{var y,d=performance.now(),L=this.retryDate;(!L||d>=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,K=R.complete;if(this.initPTS[I.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=D.State.FRAG_LOADING;var H=F.flush(),j={frag:I,part:k,payload:H,networkDetails:null};this._handleFragmentLoadProgress(j),K&&u.prototype._handleFragmentLoadComplete.call(this,j)}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(),J=P.BufferHelper.bufferInfo(this.mediaBuffer,Y,this.config.maxBufferHole),te=(0,E.fragmentWithinToleranceTest)(J.end,this.config.maxFragLookUpTolerance,I);te<0&&(this.log("Waiting fragment cc ("+I.cc+") @ "+I.start+" cancelled because another fragment at "+J.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,s=this.trackId,y=e.config;if(!(!r||!r[s])&&!(!t&&(this.startFragRequested||!y.startFragPrefetch))){var d=r[s],L=d.details;if(!L||L.live&&this.levelLastLoaded!==s||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),K=I.len,H=this.getMaxBufferLength(F==null?void 0:F.len);if(!(K>=H&&!k)){var j=L.fragments,Y=j[0].start,J=I.end;if(k&&t){var te=this.getLoadPosition();J=te,L.PTSKnown&&te<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&&J>F.end+L.targetduration)&&!((!F||!F.len)&&I.len)){var ae=this.getNextFragment(J,L);if(!ae){this.bufferFlushed=!0;return}this.loadFragment(ae,L,J)}}}}},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(s){return new b.Level(s)})},c.onAudioTrackSwitching=function(e,r){var t=!!r.url;this.trackId=r.id;var s=this.fragCurrent;s&&s.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),t?this.setInterval(v):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 s=this.levels,y=r.details,d=r.id;if(!s){this.warn("Audio tracks were reset while loading level "+d);return}this.log("Track "+d+" loaded ["+y.startSN+","+y.endSN+"],duration:"+y.totalduration);var L=s[d],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=d,!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,s=e.part,y=e.payload,d=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=d.defaultAudioCodec||I.audioCodec||"mp4a.40.2",K=this.transmuxer;K||(K=this.transmuxer=new x.default(this.hls,A.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var H=this.initPTS[t.cc],j=(r=t.initSegment)===null||r===void 0?void 0:r.data;if(H!==void 0){var Y=!1,J=s?s.index:-1,te=J!==-1,ae=new f.ChunkMetadata(t.level,t.sn,t.stats.chunkCount,y.byteLength,J,te);K.push(y,j,F,"",t,s,k.totalduration,Y,ae,H)}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:s,cache:new T.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,s=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+(s?" p: "+s.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,s)},c.onError=function(e,r){if(r.type===h.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,r);return}switch(r.details){case h.ErrorDetails.FRAG_LOAD_ERROR:case h.ErrorDetails.FRAG_LOAD_TIMEOUT:case h.ErrorDetails.FRAG_PARSING_ERROR:case h.ErrorDetails.KEY_LOAD_ERROR:case h.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.AUDIO,r);break;case h.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case h.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 h.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="audio"&&(this.state===D.State.PARSING||this.state===D.State.PARSED)){var t=!0,s=this.getFwdBufferInfo(this.mediaBuffer,A.PlaylistLevelType.AUDIO);s&&s.len>.5&&(t=!this.reduceMaxBufferLength(s.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",s=this.hls,y=e.remuxResult,d=e.chunkMeta,L=this.getCurrentContext(d);if(!L){this.warn("The loading context changed while buffering fragment "+d.sn+" of level "+d.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(d.level);return}var R=L.frag,I=L.part,k=L.level.details,F=y.audio,K=y.text,H=y.id3,j=y.initSegment;if(!(this.fragContextChanged(R)||!k)){if(this.state=D.State.PARSING,this.audioSwitch&&F&&this.completeAudioSwitch(),j!=null&&j.tracks&&(this._bufferInitSegment(j.tracks,R,d),s.trigger(M.Events.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:t,tracks:j.tracks})),F){var Y=F.startPTS,J=F.endPTS,te=F.startDTS,ae=F.endDTS;I&&(I.elementaryStreams[S.ElementaryStreamTypes.AUDIO]={startPTS:Y,endPTS:J,startDTS:te,endDTS:ae}),R.setElementaryStreamInfo(S.ElementaryStreamTypes.AUDIO,Y,J,te,ae),this.bufferFragmentData(F,R,I,d)}if(H!=null&&(r=H.samples)!==null&&r!==void 0&&r.length){var re=a({id:t,frag:R,details:k},H);s.trigger(M.Events.FRAG_PARSING_METADATA,re)}if(K){var se=a({id:t,frag:R,details:k},K);s.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 s=e.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(M.Events.BUFFER_CODECS,e);var y=s.initSegment;if(y!=null&&y.byteLength){var d={type:"audio",frag:r,part:null,chunkMeta:t,parent:r.type,data:y};this.hls.trigger(M.Events.BUFFER_APPENDING,d)}this.tick()}}},c.loadFragment=function(e,r,t){var s=this.fragmentTracker.getState(e);this.fragCurrent=e,(this.audioSwitch||s===B.FragmentState.NOT_LOADED||s===B.FragmentState.PARTIAL)&&(e.sn==="initSegment"?this._loadInitSegment(e,r):r.live&&!(0,C.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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>E});var C=_("./src/events.ts"),D=_("./src/errors.ts"),M=_("./src/controller/base-playlist-controller.ts"),P=_("./src/types/loader.ts");function B(p,h){for(var a=0;a<h.length;a++){var o=h[a];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(p,A(o.key),o)}}function b(p,h,a){return h&&B(p.prototype,h),a&&B(p,a),Object.defineProperty(p,"prototype",{writable:!1}),p}function A(p){var h=S(p,"string");return typeof h=="symbol"?h:String(h)}function S(p,h){if(typeof p!="object"||p===null)return p;var a=p[Symbol.toPrimitive];if(a!==void 0){var o=a.call(p,h||"default");if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(h==="string"?String:Number)(p)}function T(p,h){p.prototype=Object.create(h.prototype),p.prototype.constructor=p,x(p,h)}function x(p,h){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,n){return o.__proto__=n,o},x(p,h)}var f=function(p){T(h,p);function h(o){var n;return n=p.call(this,o,"[audio-track-controller]")||this,n.tracks=[],n.groupId=null,n.tracksInGroup=[],n.trackId=-1,n.trackName="",n.selectDefaultTrack=!0,n.registerListeners(),n}var a=h.prototype;return a.registerListeners=function(){var n=this.hls;n.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.on(C.Events.LEVEL_LOADING,this.onLevelLoading,this),n.on(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),n.on(C.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(C.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var n=this.hls;n.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),n.off(C.Events.LEVEL_LOADING,this.onLevelLoading,this),n.off(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),n.off(C.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(C.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,v){this.tracks=v.audioTracks||[]},a.onAudioTrackLoaded=function(n,v){var l=v.id,i=v.details,u=this.tracksInGroup[l];if(!u){this.warn("Invalid audio track id "+l);return}var g=u.details;u.details=v.details,this.log("audioTrack "+l+" loaded ["+i.startSN+"-"+i.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,v,g))},a.onLevelLoading=function(n,v){this.switchLevel(v.level)},a.onLevelSwitching=function(n,v){this.switchLevel(v.level)},a.switchLevel=function(n){var v=this.hls.levels[n];if(!!(v!=null&&v.audioGroupIds)){var l=v.audioGroupIds[v.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(C.Events.AUDIO_TRACKS_UPDATED,u),this.selectInitialTrack()}}},a.onError=function(n,v){p.prototype.onError.call(this,n,v),!(v.fatal||!v.context)&&v.context.type===P.PlaylistContextType.AUDIO_TRACK&&v.context.id===this.trackId&&v.context.groupId===this.groupId&&this.retryLoadingOrFail(v)},a.setAudioTrack=function(n){var v=this.tracksInGroup;if(n<0||n>=v.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var l=v[this.trackId];this.log("Now switching to audio-track index "+n);var i=v[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(C.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 v=this.trackName,l=this.findTrackId(v)||this.findTrackId();l!==-1?this.setAudioTrack(l):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(C.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},a.findTrackId=function(n){for(var v=this.tracksInGroup,l=0;l<v.length;l++){var i=v[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 v=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(v)){var l=v.id,i=v.groupId,u=v.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(C.Events.AUDIO_TRACK_LOADING,{url:u,id:l,groupId:i,deliveryDirectives:n||null})}},b(h,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(n){this.selectDefaultTrack=!1,this.setAudioTrack(n)}}]),h}(M.default);let E=f},"./src/controller/base-playlist-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>B});var C=_("./src/types/level.ts"),D=_("./src/controller/level-helper.ts"),M=_("./src/utils/logger.ts"),P=_("./src/errors.ts"),B=function(){function b(S,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=M.logger.log.bind(M.logger,T+":"),this.warn=M.logger.warn.bind(M.logger,T+":"),this.hls=S}var A=b.prototype;return A.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},A.onError=function(T,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(T,x){var f=x==null?void 0:x.renditionReports;if(f)for(var E=0;E<f.length;E++){var p=f[E],h=void 0;try{h=new self.URL(p.URI,x.url).href}catch(v){M.logger.warn("Could not construct new URL for Rendition Report: "+v),h=p.URI||""}if(h===T.slice(-h.length)){var a=parseInt(p["LAST-MSN"])||(x==null?void 0:x.lastPartSn),o=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);o>=0&&n>x.partTarget&&(o+=1)}return new C.HlsUrlParameters(a,o>=0?o:void 0,C.HlsSkip.No)}}},A.loadPlaylist=function(T){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},A.shouldLoadTrack=function(T){return this.canLoad&&T&&!!T.url&&(!T.details||T.details.live)},A.playlistLoaded=function(T,x,f){var E=this,p=x.details,h=x.stats,a=self.performance.now(),o=h.loading.first?Math.max(0,a-h.loading.first):0;if(p.advancedDateTime=Date.now()-o,p.live||f!=null&&f.live){if(p.reloaded(f),f&&this.log("live playlist "+T+" "+(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,v=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?(v=e?g+1:u,l=e?r:c+1):v=g+1;var t=p.age,s=t+p.ageHeader,y=Math.min(s-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 d=Math.floor(y/p.targetduration);if(v+=d,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 "+d+" to part "+l)}p.tuneInGoal=y}if(n=this.getDeliveryDirectives(p,x.deliveryDirectives,v,l),i||!e){this.loadPlaylist(n);return}}else n=this.getDeliveryDirectives(p,x.deliveryDirectives,v,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=h.loading.start):this.requestScheduled=-1,v!==void 0&&p.canBlockReload?this.requestScheduled=h.loading.first+F-(p.partTarget*1e3||1e3):this.requestScheduled=(this.requestScheduled===-1?a:this.requestScheduled)+F;var K=this.requestScheduled-a;K=Math.max(0,K),this.log("reload live playlist "+T+" in "+Math.round(K)+" ms"),this.timer=self.setTimeout(function(){return E.loadPlaylist(n)},K)}else this.clearTimer()},A.getDeliveryDirectives=function(T,x,f,E){var p=(0,C.getSkipValue)(T,f);return x!=null&&x.skip&&T.deltaUpdateFailed&&(f=x.msn,E=x.part,p=C.HlsSkip.No),new C.HlsUrlParameters(f,E,p)},A.retryLoadingOrFail=function(T){var x=this,f=this.hls.config,E=this.retryCount<f.levelLoadingMaxRetry;if(E){var p;if(this.requestScheduled=-1,this.retryCount++,T.details.indexOf("LoadTimeOut")>-1&&(p=T.context)!==null&&p!==void 0&&p.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+T.details+'"'),this.loadPlaylist();else{var h=Math.min(Math.pow(2,this.retryCount)*f.levelLoadingRetryDelay,f.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return x.loadPlaylist()},h),this.warn("retry playlist loading #"+this.retryCount+" in "+h+' ms after "'+T.details+'"')}}else this.warn('cannot recover from error "'+T.details+'"'),this.clearTimer(),T.fatal=!0;return E},b}()},"./src/controller/base-stream-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{State:()=>m,default:()=>e});var C=_("./src/polyfills/number.ts"),D=_("./src/task-loop.ts"),M=_("./src/controller/fragment-tracker.ts"),P=_("./src/utils/buffer-helper.ts"),B=_("./src/utils/logger.ts"),b=_("./src/events.ts"),A=_("./src/errors.ts"),S=_("./src/types/transmuxer.ts"),T=_("./src/utils/mp4-tools.ts"),x=_("./src/utils/discontinuities.ts"),f=_("./src/controller/fragment-finders.ts"),E=_("./src/controller/level-helper.ts"),p=_("./src/loader/fragment-loader.ts"),h=_("./src/crypt/decrypter.ts"),a=_("./src/utils/time-ranges.ts"),o=_("./src/types/loader.ts");function n(r,t){for(var s=0;s<t.length;s++){var y=t[s];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(r,l(y.key),y)}}function v(r,t,s){return t&&n(r.prototype,t),s&&n(r,s),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 s=r[Symbol.toPrimitive];if(s!==void 0){var y=s.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,d){return y.__proto__=d,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,d,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=B.logger.log.bind(B.logger,R+":"),I.warn=B.logger.warn.bind(B.logger,R+":"),I.hls=y,I.fragmentLoader=new p.default(y.config),I.keyLoader=L,I.fragmentTracker=d,I.config=y.config,I.decrypter=new h.default(y.config),y.on(b.Events.LEVEL_SWITCHING,I.onLevelSwitching,u(I)),I}var s=t.prototype;return s.doTick=function(){this.onTickEnd()},s.onTickEnd=function(){},s.startLoad=function(d){},s.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var d=this.fragCurrent;d&&(d.abortRequests(),this.fragmentTracker.removeFragment(d)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=m.STOPPED},s._streamEnded=function(d,L){if(L.live||d.nextStart||!d.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)},s.getLevelDetails=function(){if(this.levels&&this.levelLastLoaded!==null){var d;return(d=this.levels[this.levelLastLoaded])===null||d===void 0?void 0:d.details}},s.onMediaAttached=function(d,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)},s.onMediaDetaching=function(){var d=this.media;d!=null&&d.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),d&&this.onvseeking&&this.onvended&&(d.removeEventListener("seeking",this.onvseeking),d.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()},s.onMediaSeeking=function(){var d=this.config,L=this.fragCurrent,R=this.media,I=this.mediaBuffer,k=this.state,F=R?R.currentTime:0,K=P.BufferHelper.bufferInfo(I||R,F,d.maxBufferHole);if(this.log("media seeking to "+((0,C.isFiniteNumber)(F)?F.toFixed(3):F)+", state: "+k),this.state===m.ENDED)this.resetLoadingState();else if(L){var H=d.maxFragLookUpTolerance,j=L.start-H,Y=L.start+L.duration+H;if(!K.len||Y<K.start||j>K.end){var J=F>Y;(F<j||J)&&(J&&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&&!K.len&&(this.nextLoadPosition=this.startPosition=F),this.tickImmediate()},s.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},s.onLevelSwitching=function(d,L){this.fragLoadError=0},s.onHandlerDestroying=function(){this.stopLoad(),r.prototype.onHandlerDestroying.call(this)},s.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)},s.loadFragment=function(d,L,R){this._loadFragForPlayback(d,L,R)},s._loadFragForPlayback=function(d,L,R){var I=this,k=function(K){if(I.fragContextChanged(d)){I.warn("Fragment "+d.sn+(K.part?" p: "+K.part.index:"")+" of level "+d.level+" was dropped during download."),I.fragmentTracker.removeFragment(d);return}d.stats.chunkCount++,I._handleFragmentLoadProgress(K)};this._doFragLoad(d,L,R,k).then(function(F){if(!!F){I.fragLoadError=0;var K=I.state;if(I.fragContextChanged(d)){(K===m.FRAG_LOADING||!I.fragCurrent&&K===m.PARSING)&&(I.fragmentTracker.removeFragment(d),I.state=m.IDLE);return}"payload"in F&&(I.log("Loaded fragment "+d.sn+" of level "+d.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(d))})},s.flushMainBuffer=function(d,L,R){if(R===void 0&&(R=null),!!(d-L)){var I={startOffset:d,endOffset:L,type:R};this.fragLoadError=0,this.hls.trigger(b.Events.BUFFER_FLUSHING,I)}},s._loadInitSegment=function(d,L){var R=this;this._doFragLoad(d,L).then(function(I){if(!I||R.fragContextChanged(d)||!R.levels)throw new Error("init load aborted");return I}).then(function(I){var k=R.hls,F=I.payload,K=d.decryptdata;if(F&&F.byteLength>0&&K&&K.key&&K.iv&&K.method==="AES-128"){var H=self.performance.now();return R.decrypter.decrypt(new Uint8Array(F),K.key.buffer,K.iv.buffer).then(function(j){var Y=self.performance.now();return k.trigger(b.Events.FRAG_DECRYPTED,{frag:d,payload:j,stats:{tstart:H,tdecrypt:Y}}),I.payload=j,I})}return I}).then(function(I){var k=R.fragCurrent,F=R.hls,K=R.levels;if(!K)throw new Error("init load aborted, missing levels");var H=K[d.level].details;console.assert(H,"Level details are defined when init segment is loaded");var j=d.stats;R.state=m.IDLE,R.fragLoadError=0,d.data=new Uint8Array(I.payload),j.parsing.start=j.buffering.start=self.performance.now(),j.parsing.end=j.buffering.end=self.performance.now(),I.frag===k&&F.trigger(b.Events.FRAG_BUFFERED,{stats:j,frag:k,part:null,id:d.type}),R.tick()}).catch(function(I){R.state===m.STOPPED||R.state===m.ERROR||(R.warn(I),R.resetFragmentLoading(d))})},s.fragContextChanged=function(d){var L=this.fragCurrent;return!d||!L||d.level!==L.level||d.sn!==L.sn||d.urlId!==L.urlId},s.fragBufferedComplete=function(d,L){var R,I,k=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+d.type+" sn: "+d.sn+(L?" part: "+L.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+d.level+" "+(k?a.default.toString(P.BufferHelper.getBuffered(k)):"(detached)")),this.state=m.IDLE,k&&(!this.loadedmetadata&&d.type==o.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())},s.seekToStartPos=function(){},s._handleFragmentLoadComplete=function(d){var L=this.transmuxer;if(!!L){var R=d.frag,I=d.part,k=d.partsLoaded,F=!k||k.length===0||k.some(function(H){return!H}),K=new S.ChunkMetadata(R.level,R.sn,R.stats.chunkCount+1,0,I?I.index:-1,!F);L.flush(K)}},s._handleFragmentLoadProgress=function(d){},s._doFragLoad=function(d,L,R,I){var k,F=this;if(R===void 0&&(R=null),!this.levels)throw new Error("frag load aborted, missing levels");var K=null;if(d.encrypted&&!((k=d.decryptdata)!==null&&k!==void 0&&k.key)?(this.log("Loading key for "+d.sn+" of ["+L.startSN+"-"+L.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+d.level),this.state=m.KEY_LOADING,this.fragCurrent=d,K=this.keyLoader.load(d).then(function(te){if(!F.fragContextChanged(te.frag))return F.hls.trigger(b.Events.KEY_LOADED,te),te}),this.hls.trigger(b.Events.KEY_LOADING,{frag:d}),this.throwIfFragContextChanged("KEY_LOADING")):!d.encrypted&&L.encryptedFragments.length&&this.keyLoader.loadClear(d,L.encryptedFragments),R=Math.max(d.start,R||0),this.config.lowLatencyMode&&L){var H=L.partList;if(H&&I){R>d.end&&L.fragmentHint&&(d=L.fragmentHint);var j=this.getNextPart(H,d,R);if(j>-1){var Y=H[j];return this.log("Loading part sn: "+d.sn+" p: "+Y.index+" cc: "+d.cc+" of playlist ["+L.startSN+"-"+L.endSN+"] parts [0-"+j+"-"+(H.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+d.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:d,part:H[j],targetBufferTime:R}),this.throwIfFragContextChanged("FRAG_LOADING parts"),K?K.then(function(te){return!te||F.fragContextChanged(te.frag)?null:F.doFragPartsLoad(d,H,j,I)}).catch(function(te){return F.handleFragLoadError(te)}):this.doFragPartsLoad(d,H,j,I).catch(function(te){return F.handleFragLoadError(te)})}else if(!d.url||this.loadedEndOfParts(H,R))return Promise.resolve(null)}}this.log("Loading fragment "+d.sn+" cc: "+d.cc+" "+(L?"of ["+L.startSN+"-"+L.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+d.level+", target: "+parseFloat(R.toFixed(3))),(0,C.isFiniteNumber)(d.sn)&&!this.bitrateTest&&(this.nextLoadPosition=d.start+d.duration),this.state=m.FRAG_LOADING,this.hls.trigger(b.Events.FRAG_LOADING,{frag:d,targetBufferTime:R}),this.throwIfFragContextChanged("FRAG_LOADING");var J=this.config.progressive;return J&&K?K.then(function(te){return!te||F.fragContextChanged(te==null?void 0:te.frag)?null:F.fragmentLoader.load(d,I)}).catch(function(te){return F.handleFragLoadError(te)}):Promise.all([this.fragmentLoader.load(d,J?I:void 0),K]).then(function(te){var ae=te[0];return!J&&ae&&I&&I(ae),ae}).catch(function(te){return F.handleFragLoadError(te)})},s.throwIfFragContextChanged=function(d){if(this.fragCurrent===null)throw new Error("frag load aborted, context changed in "+d)},s.doFragPartsLoad=function(d,L,R,I){var k=this;return new Promise(function(F,K){var H=[],j=function Y(J){var te=L[J];k.fragmentLoader.loadPart(d,te,I).then(function(ae){H[te.index]=ae;var re=ae.part;k.hls.trigger(b.Events.FRAG_LOADED,ae);var se=L[J+1];if(se&&se.fragment===d)Y(J+1);else return F({frag:d,part:re,partsLoaded:H})}).catch(K)};j(R)})},s.handleFragLoadError=function(d){if("data"in d){var L=d.data;d.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:d,fatal:!0});return null},s._handleTransmuxerFlush=function(d){var L=this.getCurrentContext(d);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,d.partial)},s.getCurrentContext=function(d){var L=this.levels,R=d.level,I=d.sn,k=d.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],K=k>-1?(0,E.getPartWith)(F,I,k):null,H=K?K.fragment:(0,E.getFragmentWithSN)(F,I,this.fragCurrent);return H?{frag:H,part:K,level:F}:null},s.bufferFragmentData=function(d,L,R,I){if(!(!d||this.state!==m.PARSING)){var k=d.data1,F=d.data2,K=k;if(k&&F&&(K=(0,T.appendUint8Array)(k,F)),!(!K||!K.length)){var H={type:d.type,frag:L,part:R,chunkMeta:I,parent:L.type,data:K};this.hls.trigger(b.Events.BUFFER_APPENDING,H),d.dropped&&d.independent&&!R&&this.flushBufferGap(L)}}},s.flushBufferGap=function(d){var L=this.media;if(!!L){if(!P.BufferHelper.isBuffered(L,L.currentTime)){this.flushMainBuffer(0,d.start);return}var R=L.currentTime,I=P.BufferHelper.bufferInfo(L,R,0),k=d.duration,F=Math.min(this.config.maxFragLookUpTolerance*2,k*.25),K=Math.max(Math.min(d.start-F,I.end-F),R+F);d.start-K>F&&this.flushMainBuffer(K,d.start)}},s.getFwdBufferInfo=function(d,L){var R=this.config,I=this.getLoadPosition();if(!(0,C.isFiniteNumber)(I))return null;var k=P.BufferHelper.bufferInfo(d,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(d,I,Math.max(k.nextStart,R.maxBufferHole))}return k},s.getMaxBufferLength=function(d){var L=this.config,R;return d?R=Math.max(8*L.maxBufferSize/d,L.maxBufferLength):R=L.maxBufferLength,Math.min(R,L.maxMaxBufferLength)},s.reduceMaxBufferLength=function(d){var L=this.config,R=d||L.maxBufferLength;return L.maxMaxBufferLength>=R?(L.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+L.maxMaxBufferLength+"s"),!0):!1},s.getNextFragment=function(d,L){var R=L.fragments,I=R.length;if(!I)return null;var k=this.config,F=R[0].start,K;if(L.live){var H=k.initialLiveManifestSize;if(I<H)return this.warn("Not enough fragments to start playback (have: "+I+", need: "+H+")"),null;!L.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(K=this.getInitialLiveFragment(L,R),this.startPosition=K?this.hls.liveSyncPosition||K.start:d)}else d<=F&&(K=R[0]);if(!K){var j=k.lowLatencyMode?L.partEnd:L.fragmentEnd;K=this.getFragmentAtPosition(d,j,L)}return this.mapToInitFragWhenRequired(K)},s.mapToInitFragWhenRequired=function(d){return d!=null&&d.initSegment&&!(d!=null&&d.initSegment.data)&&!this.bitrateTest?d.initSegment:d},s.getNextPart=function(d,L,R){for(var I=-1,k=!1,F=!0,K=0,H=d.length;K<H;K++){var j=d[K];if(F=F&&!j.independent,I>-1&&R<j.start)break;var Y=j.loaded;Y?I=-1:(k||j.independent||F)&&j.fragment===L&&(I=K),k=Y}return I},s.loadedEndOfParts=function(d,L){var R=d[d.length-1];return R&&L>R.start&&R.loaded},s.getInitialLiveFragment=function(d,L){var R=this.fragPrevious,I=null;if(R){if(d.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>=d.startSN&&k<=d.endSN){var F=L[k-d.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 K=this.hls.liveSyncPosition;K!==null&&(I=this.getFragmentAtPosition(K,this.bitrateTest?d.fragmentEnd:d.edge,d))}return I},s.getFragmentAtPosition=function(d,L,R){var I=this.config,k=this.fragPrevious,F=R.fragments,K=R.endSN,H=R.fragmentHint,j=I.maxFragLookUpTolerance,Y=!!(I.lowLatencyMode&&R.partList&&H);Y&&H&&!this.bitrateTest&&(F=F.concat(H),K=H.sn);var J;if(d<L){var te=d>L-j?0:j;J=(0,f.findFragmentByPTS)(k,F,d,te)}else J=F[F.length-1];if(J){var ae=J.sn-R.startSN;if(this.fragmentTracker.getState(J)===M.FragmentState.OK&&(k=J),k&&J.sn===k.sn&&!Y){var re=k&&J.level===k.level;if(re){var se=F[ae+1];J.sn<K&&this.fragmentTracker.getState(se)!==M.FragmentState.OK?(this.log("SN "+J.sn+" just loaded, load next one: "+se.sn),J=se):J=null}}}return J},s.synchronizeToLiveEdge=function(d){var L=this.config,R=this.media;if(!!R){var I=this.hls.liveSyncPosition,k=R.currentTime,F=d.fragments[0].start,K=d.edge,H=k>=F-L.maxFragLookUpTolerance&&k<=K;if(I!==null&&R.duration>I&&(k<I||!H)){var j=L.liveMaxLatencyDuration!==void 0?L.liveMaxLatencyDuration:L.liveMaxLatencyDurationCount*d.targetduration;(!H&&R.readyState<4||k<K-j)&&(this.loadedmetadata||(this.nextLoadPosition=I),R.readyState&&(this.warn("Playback: "+k.toFixed(3)+" is located too far from the end of live sliding playlist: "+K+", reset currentTime to : "+I.toFixed(3)),R.currentTime=I))}}},s.alignPlaylists=function(d,L){var R=this.levels,I=this.levelLastLoaded,k=this.fragPrevious,F=I!==null?R[I]:null,K=d.fragments.length;if(!K)return this.warn("No fragments in live playlist"),0;var H=d.fragments[0].start,j=!L,Y=d.alignedSliding&&(0,C.isFiniteNumber)(H);if(j||!Y&&!H){(0,x.alignStream)(k,F,d);var J=d.fragments[0].start;return this.log("Live playlist sliding: "+J.toFixed(2)+" start-sn: "+(L?L.startSN:"na")+"->"+d.startSN+" prev-sn: "+(k?k.sn:"na")+" fragments: "+K),J}return H},s.waitForCdnTuneIn=function(d){var L=3;return d.live&&d.canBlockReload&&d.partTarget&&d.tuneInGoal>Math.max(d.partHoldBack,d.partTarget*L)},s.setStartPosition=function(d,L){var R=this.startPosition;if(R<L&&(R=-1),R===-1||this.lastCurrentTime===-1){var I=d.startTimeOffset;(0,C.isFiniteNumber)(I)?(R=L+I,I<0&&(R+=d.totalduration),R=Math.min(Math.max(L,R),L+d.totalduration),this.log("Start time offset "+I+" found in playlist, adjust startPosition to "+R),this.startPosition=R):d.live?R=this.hls.liveSyncPosition||L:this.startPosition=R=0,this.lastCurrentTime=R}this.nextLoadPosition=R},s.getLoadPosition=function(){var d=this.media,L=0;return this.loadedmetadata&&d?L=d.currentTime:this.nextLoadPosition&&(L=this.nextLoadPosition),L},s.handleFragLoadAborted=function(d,L){this.transmuxer&&d.sn!=="initSegment"&&d.stats.aborted&&(this.warn("Fragment "+d.sn+(L?" part"+L.index:"")+" of level "+d.level+" was aborted"),this.resetFragmentLoading(d))},s.resetFragmentLoading=function(d){(!this.fragCurrent||!this.fragContextChanged(d)&&this.state!==m.FRAG_LOADING_WAITING_RETRY)&&(this.state=m.IDLE)},s.onFragmentOrKeyLoadError=function(d,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!==d)){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 K=Math.min(Math.pow(2,this.fragLoadError)*R.fragLoadingRetryDelay,R.fragLoadingMaxRetryTimeout);this.warn("Fragment "+k.sn+" of "+d+" "+k.level+" failed to load, retrying in "+K+"ms"),this.retryDate=self.performance.now()+K,this.fragLoadError++,this.state=m.FRAG_LOADING_WAITING_RETRY}else L.levelRetry?(d===o.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=m.IDLE):(B.logger.error(L.details+" reaches max retry, redispatch as fatal ..."),L.fatal=!0,this.hls.stopLoad(),this.state=m.ERROR)}},s.afterBufferFlushed=function(d,L,R){if(!!d){var I=P.BufferHelper.getBuffered(d);this.fragmentTracker.detectEvictedFragments(L,I,R),this.state===m.ENDED&&this.resetLoadingState()}},s.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=m.IDLE},s.resetStartWhenNotLoaded=function(d){if(!this.loadedmetadata){this.startFragRequested=!1;var L=this.levels?this.levels[d].details:null;L!=null&&L.live?(this.startPosition=-1,this.setStartPosition(L,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},s.updateLevelTiming=function(d,L,R,I){var k=this,F=R.details;console.assert(!!F,"level.details must be defined");var K=Object.keys(d.elementaryStreams).reduce(function(H,j){var Y=d.elementaryStreams[j];if(Y){var J=Y.endPTS-Y.startPTS;if(J<=0)return k.warn("Could not parse fragment "+d.sn+" "+j+" duration reliably ("+J+")"),H||!1;var te=I?0:(0,E.updateFragPTSDTS)(F,d,Y.startPTS,Y.endPTS,Y.startDTS,Y.endDTS);return k.hls.trigger(b.Events.LEVEL_PTS_UPDATED,{details:F,level:R,drift:te,type:j,frag:d,start:Y.startPTS,end:Y.endPTS}),!0}return H},!1);K||(this.warn("Found no media in fragment "+d.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:d,part:L})},s.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},v(t,[{key:"state",get:function(){return this._state},set:function(d){var L=this._state;L!==d&&(this._state=d,this.log(L+"->"+d))}}]),t}(D.default)},"./src/controller/buffer-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>f});var C=_("./src/polyfills/number.ts"),D=_("./src/events.ts"),M=_("./src/utils/logger.ts"),P=_("./src/errors.ts"),B=_("./src/utils/buffer-helper.ts"),b=_("./src/utils/mediasource-helper.ts"),A=_("./src/loader/fragment.ts"),S=_("./src/controller/buffer-operation-queue.ts"),T=(0,b.getMediaSource)(),x=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function E(h){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 o=a.hls,n=a.media,v=a.mediaSource;M.logger.log("[buffer-controller]: Media source opened"),n&&(a.updateMediaElementDuration(),o.trigger(D.Events.MEDIA_ATTACHED,{media:n})),v&&v.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=h,this._initSourceBuffer(),this.registerListeners()}var p=E.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,o){var n=2;(o.audio&&!o.video||!o.altAudio)&&(n=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=n,this.details=null,M.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},p.onMediaAttaching=function(a,o){var n=this.media=o.media;if(n&&T){var v=this.mediaSource=new T;v.addEventListener("sourceopen",this._onMediaSourceOpen),v.addEventListener("sourceended",this._onMediaSourceEnded),v.addEventListener("sourceclose",this._onMediaSourceClose),n.src=self.URL.createObjectURL(v),this._objectUrl=n.src}},p.onMediaDetaching=function(){var a=this.media,o=this.mediaSource,n=this._objectUrl;if(o){if(M.logger.log("[buffer-controller]: media source detaching"),o.readyState==="open")try{o.endOfStream()}catch(v){M.logger.warn("[buffer-controller]: onMediaDetaching: "+v.message+" while calling endOfStream")}this.onBufferReset(),o.removeEventListener("sourceopen",this._onMediaSourceOpen),o.removeEventListener("sourceended",this._onMediaSourceEnded),o.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(o){var n=a.sourceBuffer[o];try{n&&(a.removeBufferListeners(o),a.mediaSource&&a.mediaSource.removeSourceBuffer(n),a.sourceBuffer[o]=void 0)}catch(v){M.logger.warn("[buffer-controller]: Failed to reset the "+o+" buffer",v)}}),this._initSourceBuffer()},p.onBufferCodecs=function(a,o){var n=this,v=this.getSourceBufferTypes().length;Object.keys(o).forEach(function(l){if(v){var i=n.tracks[l];if(i&&typeof i.buffer.changeType=="function"){var u=o[l],g=u.id,c=u.codec,m=u.levelCodec,e=u.container,r=u.metadata,t=(i.levelCodec||i.codec).replace(x,"$1"),s=(m||c).replace(x,"$1");if(t!==s){var y=e+";codecs="+(m||c);n.appendChangeType(l,y),M.logger.log("[buffer-controller]: switching codec "+t+" to "+s),n.tracks[l]={buffer:i.buffer,codec:c,container:e,levelCodec:m,metadata:r,id:g}}}}else n.pendingTracks[l]=o[l]}),!v&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},p.appendChangeType=function(a,o){var n=this,v=this.operationQueue,l={execute:function(){var u=n.sourceBuffer[a];u&&(M.logger.log("[buffer-controller]: changing "+a+" sourceBuffer type to "+o),u.changeType(o)),v.shiftAndExecuteNext(a)},onStart:function(){},onComplete:function(){},onError:function(u){M.logger.warn("[buffer-controller]: Failed to change "+a+" SourceBuffer type",u)}};v.append(l,a)},p.onBufferAppending=function(a,o){var n=this,v=this.hls,l=this.operationQueue,i=this.tracks,u=o.data,g=o.type,c=o.frag,m=o.part,e=o.chunkMeta,r=e.buffering[g],t=self.performance.now();r.start=t;var s=c.stats.buffering,y=m?m.stats.buffering:null;s.start===0&&(s.start=t),y&&y.start===0&&(y.start=t);var d=i.audio,L=!1;g==="audio"&&(d==null?void 0:d.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 K=R-F.timestampOffset;Math.abs(K)>=.1&&(M.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+R+" (delta: "+K+") sn: "+c.sn+")"),F.timestampOffset=R)}}n.appendExecutor(u,g)},onStart:function(){},onComplete:function(){var F=self.performance.now();r.executeEnd=r.end=F,s.first===0&&(s.first=F),y&&y.first===0&&(y.first=F);var K=n.sourceBuffer,H={};for(var j in K)H[j]=B.BufferHelper.getBuffered(K[j]);n.appendError=0,n.hls.trigger(D.Events.BUFFER_APPENDED,{type:g,frag:c,part:m,chunkMeta:e,parent:c.type,timeRanges:H})},onError:function(F){M.logger.error("[buffer-controller]: Error encountered while trying to append to the "+g+" SourceBuffer",F);var K={type:P.ErrorTypes.MEDIA_ERROR,parent:c.type,details:P.ErrorDetails.BUFFER_APPEND_ERROR,err:F,fatal:!1};F.code===DOMException.QUOTA_EXCEEDED_ERR?K.details=P.ErrorDetails.BUFFER_FULL_ERROR:(n.appendError++,K.details=P.ErrorDetails.BUFFER_APPEND_ERROR,n.appendError>v.config.appendErrorMaxRetry&&(M.logger.error("[buffer-controller]: Failed "+v.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),K.fatal=!0,v.stopLoad())),v.trigger(D.Events.ERROR,K)}};l.append(I,g)},p.onBufferFlushing=function(a,o){var n=this,v=this.operationQueue,l=function(u){return{execute:n.removeExecutor.bind(n,u,o.startOffset,o.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)}}};o.type?v.append(l(o.type),o.type):this.getSourceBufferTypes().forEach(function(i){v.append(l(i),i)})},p.onFragParsed=function(a,o){var n=this,v=o.frag,l=o.part,i=[],u=l?l.elementaryStreams:v.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();v.stats.buffering.end=m,l&&(l.stats.buffering.end=m);var e=l?l.stats:v.stats;n.hls.trigger(D.Events.FRAG_BUFFERED,{frag:v,part:l,stats:e,id:v.type})};i.length===0&&M.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+v.type+" level: "+v.level+" sn: "+v.sn),this.blockBuffers(g,i)},p.onFragChanged=function(a,o){this.flushBackBuffer()},p.onBufferEos=function(a,o){var n=this,v=this.getSourceBufferTypes().reduce(function(l,i){var u=n.sourceBuffer[i];return u&&(!o.type||o.type===i)&&(u.ending=!0,u.ended||(u.ended=!0,M.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS"))),l&&!!(!u||u.ended)},!0);v&&(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,o){var n=o.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,o=this.details,n=this.media,v=this.sourceBuffer;if(!(!n||o===null)){var l=this.getSourceBufferTypes();if(!!l.length){var i=o.live&&a.config.liveBackBufferLength!==null?a.config.liveBackBufferLength:a.config.backBufferLength;if(!(!(0,C.isFiniteNumber)(i)||i<0)){var u=n.currentTime,g=o.levelTargetDuration,c=Math.max(i,g),m=Math.floor(u/g)*g-c;l.forEach(function(e){var r=v[e];if(r){var t=B.BufferHelper.getBuffered(r);if(t.length>0&&m>t.start(0)){if(a.trigger(D.Events.BACK_BUFFER_REACHED,{bufferEnd:m}),o.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,o=this.hls,n=this.media,v=this.mediaSource,l=a.fragments[0].start+a.totalduration,i=n.duration,u=(0,C.isFiniteNumber)(v.duration)?v.duration:0;a.live&&o.config.liveDurationInfinity?(M.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),v.duration=1/0,this.updateSeekableRange(a)):(l>u&&l>i||!(0,C.isFiniteNumber)(i))&&(M.logger.log("[buffer-controller]: Updating Media Source duration to "+l.toFixed(3)),v.duration=l)}},p.updateSeekableRange=function(a){var o=this.mediaSource,n=a.fragments,v=n.length;if(v&&a.live&&o!==null&&o!==void 0&&o.setLiveSeekableRange){var l=Math.max(0,n[0].start),i=Math.max(l,l+a.totalduration);o.setLiveSeekableRange(l,i)}},p.checkPendingTracks=function(){var a=this.bufferCodecEventsExpected,o=this.operationQueue,n=this.pendingTracks,v=Object.keys(n).length;if(v&&!a||v===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){o.executeNext(i)})}},p.createSourceBuffers=function(a){var o=this.sourceBuffer,n=this.mediaSource;if(!n)throw Error("createSourceBuffers called when mediaSource was null");var v=0;for(var l in a)if(!o[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=o[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},v++}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})}}v&&this.hls.trigger(D.Events.BUFFER_CREATED,{tracks:this.tracks})},p._onSBUpdateStart=function(a){var o=this.operationQueue,n=o.current(a);n.onStart()},p._onSBUpdateEnd=function(a){var o=this.operationQueue,n=o.current(a);n.onComplete(),o.shiftAndExecuteNext(a)},p._onSBUpdateError=function(a,o){M.logger.error("[buffer-controller]: "+a+" SourceBuffer error",o),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(o)},p.removeExecutor=function(a,o,n){var v=this.media,l=this.mediaSource,i=this.operationQueue,u=this.sourceBuffer,g=u[a];if(!v||!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,C.isFiniteNumber)(v.duration)?v.duration:1/0,m=(0,C.isFiniteNumber)(l.duration)?l.duration:1/0,e=Math.max(0,o),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,o){var n=this.operationQueue,v=this.sourceBuffer,l=v[o];if(!l){M.logger.warn("[buffer-controller]: Attempting to append to the "+o+" SourceBuffer, but it does not exist"),n.shiftAndExecuteNext(o);return}l.ended=!1,console.assert(!l.updating,o+" sourceBuffer must not be updating"),l.appendBuffer(a)},p.blockBuffers=function(a,o){var n=this;if(o===void 0&&(o=this.getSourceBufferTypes()),!o.length){M.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(a);return}var v=this.operationQueue,l=o.map(function(i){return v.appendBlocker(i)});Promise.all(l).then(function(){a(),o.forEach(function(i){var u=n.sourceBuffer[i];(!u||!u.updating)&&v.shiftAndExecuteNext(i)})})},p.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},p.addBufferListener=function(a,o,n){var v=this.sourceBuffer[a];if(!!v){var l=n.bind(this,a);this.listeners[a].push({event:o,listener:l}),v.addEventListener(o,l)}},p.removeBufferListeners=function(a){var o=this.sourceBuffer[a];!o||this.listeners[a].forEach(function(n){o.removeEventListener(n.event,n.listener)})},E}()},"./src/controller/buffer-operation-queue.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>D});var C=_("./src/utils/logger.ts"),D=function(){function M(B){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=B}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}),T={execute:A,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(T,b),S},P.executeNext=function(b){var A=this.buffers,S=this.queues,T=A[b],x=S[b];if(x.length){var f=x[0];try{f.execute()}catch(E){C.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),f.onError(E),(!T||!T.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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>A});var C=_("./src/events.ts");function D(S,T){for(var x=0;x<T.length;x++){var f=T[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,T,x){return T&&D(S.prototype,T),x&&D(S,x),Object.defineProperty(S,"prototype",{writable:!1}),S}function P(S){var T=B(S,"string");return typeof T=="symbol"?T:String(T)}function B(S,T){if(typeof S!="object"||S===null)return S;var x=S[Symbol.toPrimitive];if(x!==void 0){var f=x.call(S,T||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(T==="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 T=S.prototype;return T.setStreamController=function(f){this.streamController=f},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 f=this.hls;f.on(C.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),f.on(C.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.on(C.Events.BUFFER_CODECS,this.onBufferCodecs,this),f.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},T.unregisterListener=function(){var f=this.hls;f.off(C.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),f.off(C.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),f.off(C.Events.BUFFER_CODECS,this.onBufferCodecs,this),f.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},T.onFpsDropLevelCapping=function(f,E){S.isLevelAllowed(E.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(E.droppedLevel)},T.onMediaAttaching=function(f,E){this.media=E.media instanceof HTMLVideoElement?E.media:null,this.clientRect=null},T.onManifestParsed=function(f,E){var p=this.hls;this.restrictedLevels=[],this.firstLevel=E.firstLevel,p.config.capLevelToPlayerSize&&E.video&&this.startCapping()},T.onBufferCodecs=function(f,E){var p=this.hls;p.config.capLevelToPlayerSize&&E.video&&this.startCapping()},T.onMediaDetaching=function(){this.stopCapping()},T.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var f=this.hls.levels;if(f.length){var E=this.hls;E.autoLevelCapping=this.getMaxLevel(f.length-1),E.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=E.autoLevelCapping}}},T.getMaxLevel=function(f){var E=this,p=this.hls.levels;if(!p.length)return-1;var h=p.filter(function(a,o){return S.isLevelAllowed(o,E.restrictedLevels)&&o<=f});return this.clientRect=null,S.getMaxLevelByMediaSize(h,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 f=this.media,E={width:0,height:0};if(f){var p=f.getBoundingClientRect();E.width=p.width,E.height=p.height,!E.width&&!E.height&&(E.width=p.right-p.left||f.width||0,E.height=p.bottom-p.top||f.height||0)}return this.clientRect=E,E},S.isLevelAllowed=function(f,E){return E===void 0&&(E=[]),E.indexOf(f)===-1},S.getMaxLevelByMediaSize=function(f,E,p){if(!f||!f.length)return-1;for(var h=function(l,i){return i?l.width!==i.width||l.height!==i.height:!0},a=f.length-1,o=0;o<f.length;o+=1){var n=f[o];if((n.width>=E||n.height>=p)&&h(n,f[o+1])){a=o;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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>p});var C=_("./src/events.ts"),D=_("./src/types/cmcd.ts"),M=_("./src/utils/buffer-helper.ts"),P=_("./src/utils/logger.ts");function B(h,a){for(var o=0;o<a.length;o++){var n=a[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,A(n.key),n)}}function b(h,a,o){return a&&B(h.prototype,a),o&&B(h,o),Object.defineProperty(h,"prototype",{writable:!1}),h}function A(h){var a=S(h,"string");return typeof a=="symbol"?a:String(a)}function S(h,a){if(typeof h!="object"||h===null)return h;var o=h[Symbol.toPrimitive];if(o!==void 0){var n=o.call(h,a||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(h)}function T(h,a){var o=typeof Symbol!="undefined"&&h[Symbol.iterator]||h["@@iterator"];if(o)return(o=o.call(h)).next.bind(o);if(Array.isArray(h)||(o=x(h))||a&&h&&typeof h.length=="number"){o&&(h=o);var n=0;return function(){return n>=h.length?{done:!0}:{done:!1,value:h[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(h,a){if(!!h){if(typeof h=="string")return f(h,a);var o=Object.prototype.toString.call(h).slice(8,-1);if(o==="Object"&&h.constructor&&(o=h.constructor.name),o==="Map"||o==="Set")return Array.from(h);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return f(h,a)}}function f(h,a){(a==null||a>h.length)&&(a=h.length);for(var o=0,n=new Array(a);o<a;o++)n[o]=h[o];return n}function E(){return E=Object.assign?Object.assign.bind():function(h){for(var a=1;a<arguments.length;a++){var o=arguments[a];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(h[n]=o[n])}return h},E.apply(this,arguments)}var p=function(){function h(o){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=o;var v=this.config=o.config,l=v.cmcd;l!=null&&(v.pLoader=this.createPlaylistLoader(),v.fLoader=this.createFragmentLoader(),this.sid=l.sessionId||h.uuid(),this.cid=l.contentId,this.useHeaders=l.useHeaders===!0,this.registerListeners())}var a=h.prototype;return a.registerListeners=function(){var n=this.hls;n.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),n.on(C.Events.BUFFER_CREATED,this.onBufferCreated,this)},a.unregisterListeners=function(){var n=this.hls;n.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),n.off(C.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,v){this.media=v.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,v){var l,i;this.audioBuffer=(l=v.tracks.audio)===null||l===void 0?void 0:l.buffer,this.videoBuffer=(i=v.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,v){v===void 0&&(v={}),E(v,this.createData());var l=v.ot===D.CMCDObjectType.INIT||v.ot===D.CMCDObjectType.VIDEO||v.ot===D.CMCDObjectType.MUXED;if(this.starved&&l&&(v.bs=!0,v.su=!0,this.starved=!1),v.su==null&&(v.su=this.buffering),this.useHeaders){var i=h.toHeaders(v);if(!Object.keys(i).length)return;n.headers||(n.headers={}),E(n.headers,i)}else{var u=h.toQuery(v);if(!u)return;n.url=h.appendQueryToUri(n.url,u)}},a.getObjectType=function(n){var v=n.type;if(v==="subtitle")return D.CMCDObjectType.TIMED_TEXT;if(n.sn==="initSegment")return D.CMCDObjectType.INIT;if(v==="audio")return D.CMCDObjectType.AUDIO;if(v==="main")return this.hls.audioTracks.length?D.CMCDObjectType.VIDEO:D.CMCDObjectType.MUXED},a.getTopBandwidth=function(n){var v=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=T(l),m;!(m=c()).done;){var e=m.value;e.bitrate>v&&(v=e.bitrate)}return v>0?v:NaN},a.getBufferLength=function(n){var v=this.hls.media,l=n===D.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!l||!v)return NaN;var i=M.BufferHelper.bufferInfo(l,v.currentTime,this.config.maxBufferHole);return i.len*1e3},a.createPlaylistLoader=function(){var n=this.config.pLoader,v=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){v(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,v=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){v(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}()},h.uuid=function(){var n=URL.createObjectURL(new Blob),v=n.toString();return URL.revokeObjectURL(n),v.slice(v.lastIndexOf("/")+1)},h.serialize=function(n){for(var v=[],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=T(m),r;!(r=e()).done;){var t=r.value,s=n[t];if(!!l(s)&&!(t==="v"&&s===1)&&!(t=="pr"&&s===1)){var y=c[t];y&&(s=y(s));var d=typeof s,L=void 0;t==="ot"||t==="sf"||t==="st"?L=t+"="+s:d==="boolean"?L=t:d==="number"?L=t+"="+s:L=t+"="+JSON.stringify(s),v.push(L)}}return v.join(",")},h.toHeaders=function(n){for(var v=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=v;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 s=h.serialize(u[t]);s&&(l["CMCD-"+i[t]]=s)}return l},h.toQuery=function(n){return"CMCD="+encodeURIComponent(h.serialize(n))},h.appendQueryToUri=function(n,v){if(!v)return n;var l=n.includes("?")?"&":"?";return""+n+l+v},h}()},"./src/controller/eme-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>c});var C=_("./src/events.ts"),D=_("./src/errors.ts"),M=_("./src/utils/logger.ts"),P=_("./src/utils/mediakeys-helper.ts"),B=_("./src/utils/keysystem-util.ts"),b=_("./src/utils/numeric-encoding-utils.ts"),A=_("./src/loader/level-key.ts"),S=_("./src/utils/hex.ts"),T=_("./src/utils/mp4-tools.ts"),x=_("./node_modules/eventemitter3/index.js"),f=_.n(x);function E(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||!o(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,s)}function s(){return h(t,arguments,v(this).constructor)}return s.prototype=Object.create(t.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),n(s,t)},p(m)}function h(m,e,r){return a()?h=Reflect.construct.bind():h=function(s,y,d){var L=[null];L.push.apply(L,y);var R=Function.bind.apply(s,L),I=new R;return d&&n(I,d.prototype),I},h.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 o(m){return Function.toString.call(m).indexOf("[native code]")!==-1}function n(m,e){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,s){return t.__proto__=s,t},n(m,e)}function v(m){return v=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},v(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(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(C.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},e.unregisterListeners=function(){this.hls.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(C.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(C.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},e.getLicenseServerUrl=function(t){var s=this.config,y=s.drmSystems,d=s.widevineLicenseUrl,L=y[t];if(L)return L.licenseUrl;if(t===P.KeySystems.WIDEVINE&&d)return d;throw new Error('no license server URL configured for key-system "'+t+'"')},e.getServerCertificateUrl=function(t){var s=this.config.drmSystems,y=s[t];if(y)return y.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},e.attemptKeySystemAccess=function(t){var s=this,y=this.hls.levels,d=function(k,F,K){return!!k&&K.indexOf(k)===F},L=y.map(function(I){return I.audioCodec}).filter(d),R=y.map(function(I){return I.videoCodec}).filter(d);return L.length+R.length===0&&R.push("avc1.42e01e"),new Promise(function(I,k){var F=function K(H){var j=H.shift();s.getMediaKeysPromise(j,L,R).then(function(Y){return I({keySystem:j,mediaKeys:Y})}).catch(function(Y){H.length?K(H):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,s){var y=this.config.requestMediaKeySystemAccessFunc;if(typeof y!="function"){var d="Configured requestMediaKeySystemAccess is not a function "+y;return P.requestMediaKeySystemAccess===null&&self.location.protocol==="http:"&&(d="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(d))}return y(t,s)},e.getMediaKeysPromise=function(t,s,y){var d=this,L=(0,P.getSupportedMediaKeySystemConfigurations)(t,s,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){d.log('Failed to obtain access to key-system "'+t+'": '+F)}),I.then(function(F){d.log('Access for key-system "'+F.keySystem+'" obtained');var K=d.fetchServerCertificate(t);return d.log('Create media-keys for "'+t+'"'),k.mediaKeys=F.createMediaKeys().then(function(H){return d.log('Media-keys created for "'+t+'"'),K.then(function(j){return j?d.setMediaKeysServerCertificate(H,t,j):H})}),k.mediaKeys.catch(function(H){d.error('Failed to create media-keys for "'+t+'"}: '+H)}),k.mediaKeys})}return I.then(function(){return R.mediaKeys})},e.createMediaKeySessionContext=function(t){var s=t.decryptdata,y=t.keySystem,d=t.mediaKeys;console.assert(!!d,"mediaKeys is defined"),this.log('Creating key-system session "'+y+'" keyId: '+S.default.hexDump(s.keyId||[]));var L=d.createSession(),R={decryptdata:s,keySystem:y,mediaKeys:d,mediaKeysSession:L,keyStatus:"status-pending"};return this.mediaKeySessions.push(R),R},e.renewKeySession=function(t){var s=t.decryptdata;if(s.pssh){var y=this.createMediaKeySessionContext(t),d=this.getKeyIdString(s),L="cenc";this.keyIdToKeySessionPromise[d]=this.generateRequestWithPreferredKeySession(y,L,s.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,s){var y,d=t.mediaKeysSession;return this.log('Updating key-session "'+d.sessionId+'" for keyID '+S.default.hexDump(((y=t.decryptdata)===null||y===void 0?void 0:y.keyId)||[])+`
|
|
14
|
-
} (data length: `+(s&&s.byteLength)+")"),d.update(s)},e.selectKeySystemFormat=function(t){var s=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+s.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(s)),this.keyFormatPromise},e.getKeyFormatPromise=function(t){var s=this;return new Promise(function(y,d){var L=(0,P.getKeySystemsForConfig)(s.config),R=t.map(P.keySystemFormatToKeySystemDomain).filter(function(I){return!!I&&L.indexOf(I)!==-1});return s.getKeySystemSelectionPromise(R).then(function(I){var k=I.keySystem,F=(0,P.keySystemDomainToKeySystemFormat)(k);F?y(F):d(new Error('Unable to find format for key-system "'+k+'"'))}).catch(d)})},e.loadKey=function(t){var s=this,y=t.keyInfo.decryptdata,d=this.getKeyIdString(y),L="(keyId: "+d+' format: "'+y.keyFormat+'" method: '+y.method+" uri: "+y.uri+")";this.log("Starting session for key "+L);var R=this.keyIdToKeySessionPromise[d];return R||(R=this.keyIdToKeySessionPromise[d]=this.getKeySystemForKeyPromise(y).then(function(I){var k=I.keySystem,F=I.mediaKeys;return s.throwIfDestroyed(),s.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+L),s.attemptSetMediaKeys(k,F).then(function(){s.throwIfDestroyed();var K=s.createMediaKeySessionContext({keySystem:k,mediaKeys:F,decryptdata:y}),H="cenc";return s.generateRequestWithPreferredKeySession(K,H,y.pssh,"playlist-key")})}),R.catch(function(I){return s.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(C.Events.ERROR,t.data):this.hls.trigger(C.Events.ERROR,{type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},e.getKeySystemForKeyPromise=function(t){var s=this.getKeyIdString(t),y=this.keyIdToKeySessionPromise[s];if(!y){var d=(0,P.keySystemFormatToKeySystemDomain)(t.keyFormat),L=d?[d]:(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 s=this,y=t.initDataType,d=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+y+'"'),d!==null){var L,R;if(y==="sinf"&&this.config.drmSystems[P.KeySystems.FAIRPLAY]){var I=(0,T.bin2str)(new Uint8Array(d));try{var k=(0,b.base64Decode)(JSON.parse(I).sinf),F=(0,T.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 K=(0,T.parsePssh)(d);if(K===null)return;K.version===0&&K.systemId===P.KeySystemIds.WIDEVINE&&K.data&&(L=K.data.subarray(8,24)),R=(0,P.keySystemIdToKeySystemDomain)(K.systemId)}if(!(!R||!L)){for(var H=S.default.hexDump(L),j=this.keyIdToKeySessionPromise,Y=this.mediaKeySessions,J=j[H],te=function(ue){var ce=Y[ue],le=ce.decryptdata;if(le.pssh||!le.keyId)return"continue";var de=S.default.hexDump(le.keyId);if(H===de||le.uri.replace(/-/g,"").indexOf(H)!==-1)return J=j[de],delete j[de],le.pssh=new Uint8Array(d),le.keyId=L,J=j[H]=J.then(function(){return s.generateRequestWithPreferredKeySession(ce,y,d,"encrypted-event-key-match")}),"break"},ae=0;ae<Y.length;ae++){var re=te(ae);if(re!=="continue"&&re==="break")break}J||(J=j[H]=this.getKeySystemSelectionPromise([R]).then(function(se){var ue,ce=se.keySystem,le=se.mediaKeys;s.throwIfDestroyed();var de=new A.LevelKey("ISO-23001-7",H,(ue=(0,P.keySystemDomainToKeySystemFormat)(ce))!=null?ue:"");return de.pssh=new Uint8Array(d),de.keyId=L,s.attemptSetMediaKeys(ce,le).then(function(){s.throwIfDestroyed();var fe=s.createMediaKeySessionContext({decryptdata:de,keySystem:ce,mediaKeys:le});return s.generateRequestWithPreferredKeySession(fe,y,d,"encrypted-event-no-match")})})),J.catch(function(se){return s.handleError(se)})}}},e._onWaitingForKey=function(t){this.log('"'+t.type+'" event')},e.attemptSetMediaKeys=function(t,s){var y=this,d=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+t+'"');var L=Promise.all(d).then(function(){if(!y.media)throw new Error("Attempted to set mediaKeys without media element attached");return y.media.setMediaKeys(s)});return this.setMediaKeysQueue.push(L),L.then(function(){y.log('Media-keys set for "'+t+'"'),d.push(L),y.setMediaKeysQueue=y.setMediaKeysQueue.filter(function(R){return d.indexOf(R)===-1})})},e.generateRequestWithPreferredKeySession=function(t,s,y,d){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,s,y,t);if(!F)throw new Error("Invalid response from configured generateRequest filter");s=F.initDataType,y=t.decryptdata.pssh=F.initData?new Uint8Array(F.initData):null}catch(J){var K;if(this.warn(J.message),(K=this.hls)!==null&&K!==void 0&&K.config.debug)throw J}if(y===null)return this.log('Skipping key-session request for "'+d+'" (no initData)'),Promise.resolve(t);var H=this.getKeyIdString(t.decryptdata);this.log('Generating key-session request for "'+d+'": '+H+" (init data type: "+s+" length: "+(y?y.byteLength:null)+")");var j=new(f());t.mediaKeysSession.onmessage=function(J){var te=t.mediaKeysSession;if(!te){j.emit("error",new Error("invalid state"));return}var ae=J.messageType,re=J.message;I.log('"'+ae+'" message event for session "'+te.sessionId+'" message size: '+re.byteLength),ae==="license-request"||ae==="license-renewal"?I.renewLicense(t,re).catch(function(se){I.handleError(se),j.emit("error",se)}):ae==="license-release"?t.keySystem===P.KeySystems.FAIRPLAY&&(I.updateKeySession(t,(0,B.strToUtf8array)("acknowledged")),I.removeSession(t)):I.warn('unhandled media key message type "'+ae+'"')},t.mediaKeysSession.onkeystatuseschange=function(J){var te=t.mediaKeysSession;if(!te){j.emit("error",new Error("invalid state"));return}I.onKeyStatusChange(t);var ae=t.keyStatus;j.emit("keyStatus",ae),ae==="expired"&&(I.warn(t.keySystem+" expired for key "+H),I.renewKeySession(t))};var Y=new Promise(function(J,te){j.on("error",te),j.on("keyStatus",function(ae){ae.startsWith("usable")?J():ae==="output-restricted"?te(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"?te(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"?te(new Error("key expired while generating request")):I.warn('unhandled key status change "'+ae+'"')})});return t.mediaKeysSession.generateRequest(s,y).then(function(){var J;I.log('Request generated for key-session "'+((J=t.mediaKeysSession)===null||J===void 0?void 0:J.sessionId)+'" keyId: '+H)}).catch(function(J){throw new g({type:D.ErrorTypes.KEY_SYSTEM_ERROR,details:D.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:J,fatal:!1},"Error generating key-session request: "+J)}).then(function(){return Y}).catch(function(J){throw j.removeAllListeners(),I.removeSession(t),J}).then(function(){return j.removeAllListeners(),t})},e.onKeyStatusChange=function(t){var s=this;t.mediaKeysSession.keyStatuses.forEach(function(y,d){s.log('key status change "'+y+'" for keyStatuses keyId: '+S.default.hexDump("buffer"in d?new Uint8Array(d.buffer,d.byteOffset,d.byteLength):new Uint8Array(d))+" session keyId: "+S.default.hexDump(new Uint8Array(t.decryptdata.keyId||[]))+" uri: "+t.decryptdata.uri),t.keyStatus=y})},e.fetchServerCertificate=function(t){var s=this;return new Promise(function(y,d){var L=s.getServerCertificateUrl(t);if(!L)return y();s.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):d(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,s,y){var d=this;return new Promise(function(L,R){t.setServerCertificate(y).then(function(I){d.log("setServerCertificate "+(I?"success":"not supported by CDM")+" ("+(y==null?void 0:y.byteLength)+') on "'+s+'"'),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,s){var y=this;return this.requestLicense(t,new Uint8Array(s)).then(function(d){return y.updateKeySession(t,new Uint8Array(d)).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,s,y,d){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,s,y,d)}).catch(function(I){if(!y.decryptdata)throw I;return t.open("POST",s,!0),R.call(L.hls,t,s,y,d)}).then(function(I){t.readyState||t.open("POST",s,!0);var k=I||d;return{xhr:t,licenseChallenge:k}}):(t.open("POST",s,!0),Promise.resolve({xhr:t,licenseChallenge:d}))},e.requestLicense=function(t,s){var y=this;return new Promise(function(d,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(H){y.error(H)}d(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 K=l-y._requestLicenseFailureCount+1;y.warn("Retrying license request, "+K+" attempts left"),y.requestLicense(t,s).then(d,L)}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=I,y.setupLicenseXHR(I,R,t,s).then(function(k){var F=k.xhr,K=k.licenseChallenge;F.send(K)})})},e.onMediaAttached=function(t,s){if(!!this.config.emeEnabled){var y=s.media;this.media=y,y.addEventListener("encrypted",this.onMediaEncrypted),y.addEventListener("waitingforkey",this.onWaitingForKey)}},e.onMediaDetached=function(){var t=this,s=this.media,y=this.mediaKeySessions;s&&(s.removeEventListener("encrypted",this.onMediaEncrypted),s.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},A.LevelKey.clearKeyUriToKeyIdMap();var d=y.length;m.CDMCleanupPromise=Promise.all(y.map(function(L){return t.removeSession(L)}).concat(s==null?void 0:s.setMediaKeys(null).catch(function(L){t.log("Could not clear media keys: "+L+". media.src: "+(s==null?void 0:s.src))}))).then(function(){d&&(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: "+(s==null?void 0:s.src))})},e.onManifestLoaded=function(t,s){var y=s.sessionKeys;if(!(!y||!this.config.emeEnabled)&&!this.keyFormatPromise){var d=y.reduce(function(L,R){return L.indexOf(R.keyFormat)===-1&&L.push(R.keyFormat),L},[]);this.log("Selecting key-system from session-keys "+d.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(d)}},e.removeSession=function(t){var s=this,y=t.mediaKeysSession,d=t.licenseXhr;if(y){this.log("Remove licenses and keys and close session "+y.sessionId),y.onmessage=null,y.onkeystatuseschange=null,d&&d.readyState!==XMLHttpRequest.DONE&&d.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){s.log("Could not remove session: "+R)}).then(function(){return y.close()}).catch(function(R){s.log("Could not close session: "+R)})}},m}();u.CDMCleanupPromise=void 0;var g=function(m){E(e,m);function e(r,t){var s;return s=m.call(this,t)||this,s.data=void 0,s.data=r,r.err=r.error,s}return e}(p(Error));let c=u},"./src/controller/fps-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>P});var C=_("./src/events.ts"),D=_("./src/utils/logger.ts"),M=function(){function B(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=B.prototype;return b.setStreamController=function(S){this.streamController=S},b.registerListeners=function(){this.hls.on(C.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},b.unregisterListeners=function(){this.hls.off(C.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,T){var x=this.hls.config;if(x.capLevelOnFPSDrop){var f=T.media instanceof self.HTMLVideoElement?T.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,T,x){var f=performance.now();if(T){if(this.lastTime){var E=f-this.lastTime,p=x-this.lastDroppedFrames,h=T-this.lastDecodedFrames,a=1e3*p/E,o=this.hls;if(o.trigger(C.Events.FPS_DROP,{currentDropped:p,currentDecoded:h,totalDroppedFrames:x}),a>0&&p>o.config.fpsDroppedMonitoringThreshold*h){var n=o.currentLevel;D.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+n),n>0&&(o.autoLevelCapping===-1||o.autoLevelCapping>=n)&&(n=n-1,o.trigger(C.Events.FPS_DROP_LEVEL_CAPPING,{level:n,droppedLevel:o.currentLevel}),o.autoLevelCapping=n,this.streamController.nextLevelSwitch())}}this.lastTime=f,this.lastDroppedFrames=x,this.lastDecodedFrames=T}},b.checkFPSInterval=function(){var S=this.media;if(S)if(this.isVideoPlaybackQualityAvailable){var T=S.getVideoPlaybackQuality();this.checkFPS(S,T.totalVideoFrames,T.droppedVideoFrames)}else this.checkFPS(S,S.webkitDecodedFrameCount,S.webkitDroppedFrameCount)},B}();let P=M},"./src/controller/fragment-finders.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{findFragWithCC:()=>A,findFragmentByPDT:()=>M,findFragmentByPTS:()=>P,fragmentWithinToleranceTest:()=>B,pdtWithinToleranceTest:()=>b});var C=_("./src/polyfills/number.ts"),D=_("./src/utils/binary-search.ts");function M(S,T,x){if(T===null||!Array.isArray(S)||!S.length||!(0,C.isFiniteNumber)(T))return null;var f=S[0].programDateTime;if(T<(f||0))return null;var E=S[S.length-1].endProgramDateTime;if(T>=(E||0))return null;x=x||0;for(var p=0;p<S.length;++p){var h=S[p];if(b(T,x,h))return h}return null}function P(S,T,x,f){x===void 0&&(x=0),f===void 0&&(f=0);var E=null;if(S?E=T[S.sn-T[0].sn+1]||null:x===0&&T[0].start===0&&(E=T[0]),E&&B(x,f,E)===0)return E;var p=D.default.search(T,B.bind(null,x,f));return p&&(p!==S||!E)?p:E}function B(S,T,x){if(S===void 0&&(S=0),T===void 0&&(T=0),x.start<=S&&x.start+x.duration>S)return 0;var f=Math.min(T,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,T,x){var f=Math.min(T,x.duration+(x.deltaPTS?x.deltaPTS:0))*1e3,E=x.endProgramDateTime||0;return E-f>S}function A(S,T){return D.default.search(S,function(x){return x.cc<T?1:x.cc>T?-1:0})}},"./src/controller/fragment-tracker.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{FragmentState:()=>M,FragmentTracker:()=>P});var C=_("./src/events.ts"),D=_("./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(T){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=T,this._registerListeners()}var S=A.prototype;return S._registerListeners=function(){var x=this.hls;x.on(C.Events.BUFFER_APPENDED,this.onBufferAppended,this),x.on(C.Events.FRAG_BUFFERED,this.onFragBuffered,this),x.on(C.Events.FRAG_LOADED,this.onFragLoaded,this)},S._unregisterListeners=function(){var x=this.hls;x.off(C.Events.BUFFER_APPENDED,this.onBufferAppended,this),x.off(C.Events.FRAG_BUFFERED,this.onFragBuffered,this),x.off(C.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 E=this.activeFragment,p=this.activeParts;if(!E)return null;if(p)for(var h=p.length;h--;){var a=p[h],o=a?a.end:E.appendedPTS;if(a.start<=x&&o!==void 0&&x<=o)return h>9&&(this.activeParts=p.slice(h-9)),a}else if(E.start<=x&&E.appendedPTS!==void 0&&x<=E.appendedPTS)return E}return this.getBufferedFrag(x,f)},S.getBufferedFrag=function(x,f){for(var E=this.fragments,p=Object.keys(E),h=p.length;h--;){var a=E[p[h]];if((a==null?void 0:a.body.type)===f&&a.buffered){var o=a.body;if(o.start<=x&&x<=o.end)return o}}return null},S.detectEvictedFragments=function(x,f,E){var p=this;this.timeRanges&&(this.timeRanges[x]=f),Object.keys(this.fragments).forEach(function(h){var a=p.fragments[h];if(!!a){if(!a.buffered&&!a.loaded){a.body.type===E&&p.removeFragment(a.body);return}var o=a.range[x];!o||o.time.some(function(n){var v=!p.isTimeBuffered(n.startPTS,n.endPTS,f);return v&&p.removeFragment(a.body),v})}})},S.detectPartialFragments=function(x){var f=this,E=this.timeRanges,p=x.frag,h=x.part;if(!(!E||p.sn==="initSegment")){var a=b(p),o=this.fragments[a];!o||(Object.keys(E).forEach(function(n){var v=p.elementaryStreams[n];if(!!v){var l=E[n],i=h!==null||v.partial===!0;o.range[n]=f.getBufferedTimes(p,h,i,l)}}),o.loaded=null,Object.keys(o.range).length?(o.buffered=!0,o.body.endList&&(this.endListFragments[o.body.type]=o)):this.removeFragment(o.body))}},S.fragBuffered=function(x){var f=b(x),E=this.fragments[f];E&&(E.loaded=null,E.buffered=!0)},S.getBufferedTimes=function(x,f,E,p){for(var h={time:[],partial:E},a=f?f.start:x.start,o=f?f.end:x.end,n=x.minEndPTS||o,v=x.maxStartPTS||a,l=0;l<p.length;l++){var i=p.start(l)-this.bufferPadding,u=p.end(l)+this.bufferPadding;if(v>=i&&n<=u){h.time.push({startPTS:Math.max(a,p.start(l)),endPTS:Math.min(o,p.end(l))});break}else if(a<u&&o>i)h.partial=!0,h.time.push({startPTS:Math.max(a,p.start(l)),endPTS:Math.min(o,p.end(l))});else if(o<=i)break}return h},S.getPartialFragment=function(x){var f=null,E,p,h,a=0,o=this.bufferPadding,n=this.fragments;return Object.keys(n).forEach(function(v){var l=n[v];!l||B(l)&&(p=l.body.start-o,h=l.body.end+o,x>=p&&x<=h&&(E=Math.min(x-p,h-x),a<=E&&(f=l.body,a=E)))}),f},S.isEndListAppended=function(x){var f=this.endListFragments[x];return f!==void 0&&(f.buffered||B(f))},S.getState=function(x){var f=b(x),E=this.fragments[f];return E?E.buffered?B(E)?M.PARTIAL:M.OK:M.APPENDING:M.NOT_LOADED},S.isTimeBuffered=function(x,f,E){for(var p,h,a=0;a<E.length;a++){if(p=E.start(a)-this.bufferPadding,h=E.end(a)+this.bufferPadding,x>=p&&f<=h)return!0;if(f<=p)return!1}return!1},S.onFragLoaded=function(x,f){var E=f.frag,p=f.part;if(!(E.sn==="initSegment"||E.bitrateTest||p)){var h=b(E);this.fragments[h]={body:E,loaded:f,buffered:!1,range:Object.create(null)}}},S.onBufferAppended=function(x,f){var E=this,p=f.frag,h=f.part,a=f.timeRanges;if(p.type===D.PlaylistLevelType.MAIN)if(this.activeFragment!==p&&(this.activeFragment=p,p.appendedPTS=void 0),h){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(h)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach(function(n){var v=a[n];if(E.detectEvictedFragments(n,v),!h&&p.type===D.PlaylistLevelType.MAIN){var l=p.elementaryStreams[n];if(!l)return;for(var i=0;i<v.length;i++){var u=v.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,E){var p=this;Object.keys(this.fragments).forEach(function(h){var a=p.fragments[h];if(!!a&&a.buffered){var o=a.body;o.type===E&&o.start<f&&o.end>x&&p.removeFragment(o)}})},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 B(A){var S,T;return A.buffered&&(((S=A.range.video)===null||S===void 0?void 0:S.partial)||((T=A.range.audio)===null||T===void 0?void 0:T.partial))}function b(A){return A.type+"_"+A.level+"_"+A.urlId+"_"+A.sn}},"./src/controller/gap-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{MAX_START_GAP_JUMP:()=>b,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>A,SKIP_BUFFER_RANGE_START:()=>S,STALL_MINIMUM_DURATION_MS:()=>B,default:()=>T});var C=_("./src/utils/buffer-helper.ts"),D=_("./src/errors.ts"),M=_("./src/events.ts"),P=_("./src/utils/logger.ts"),B=250,b=2,A=.1,S=.05,T=function(){function x(E,p,h,a){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=E,this.media=p,this.fragmentTracker=h,this.hls=a}var f=x.prototype;return f.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},f.poll=function(p,h){var a=this.config,o=this.media,n=this.stalled;if(o!==null){var v=o.currentTime,l=o.seeking,i=this.seeking&&!l,u=!this.seeking&&l;if(this.seeking=l,v!==p){if(this.moved=!0,n!==null){if(this.stallReported){var g=self.performance.now()-n;P.logger.warn("playback not stuck anymore @"+v+", after "+Math.round(g)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((u||i)&&(this.stalled=null),!(o.paused&&!l||o.ended||o.playbackRate===0||!C.BufferHelper.getBuffered(o).length)){var c=C.BufferHelper.bufferInfo(o,v,0),m=c.len>0,e=c.nextStart||0;if(!(!m&&!e)){if(l){var r=c.len>b,t=!e||h&&h.start<=v||e-v>b&&!this.fragmentTracker.getPartialFragment(v);if(r||t)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var s,y=Math.max(e,c.start||0)-v,d=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,L=d==null||(s=d.details)===null||s===void 0?void 0:s.live,R=L?d.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>=B&&(this._reportStall(c),!this.media))){var F=C.BufferHelper.bufferInfo(o,v,a.maxBufferHole);this._tryFixBufferStall(F,k)}}}}},f._tryFixBufferStall=function(p,h){var a=this.config,o=this.fragmentTracker,n=this.media;if(n!==null){var v=n.currentTime,l=o.getPartialFragment(v);if(l){var i=this._trySkipBufferHole(l);if(i||!this.media)return}p.len>a.maxBufferHole&&h>a.highBufferWatchdogPeriod*1e3&&(P.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},f._reportStall=function(p){var h=this.hls,a=this.media,o=this.stallReported;!o&&a&&(this.stallReported=!0,P.logger.warn("Playback stalling at @"+a.currentTime+" due to low buffer ("+JSON.stringify(p)+")"),h.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 h=this.config,a=this.hls,o=this.media;if(o===null)return 0;for(var n=o.currentTime,v=0,l=C.BufferHelper.getBuffered(o),i=0;i<l.length;i++){var u=l.start(i);if(n+h.maxBufferHole>=v&&n<u){var g=Math.max(u+S,o.currentTime+A);return P.logger.warn("skipping hole, adjusting currentTime from "+n+" to "+g),this.moved=!0,this.stalled=null,o.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}v=l.end(i)}return 0},f._tryNudgeBuffer=function(){var p=this.config,h=this.hls,a=this.media,o=this.nudgeRetry;if(a!==null){var n=a.currentTime;if(this.nudgeRetry++,o<p.nudgeMaxRetry){var v=n+(o+1)*p.nudgeOffset;P.logger.warn("Nudging 'currentTime' from "+n+" to "+v),a.currentTime=v,h.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"),h.trigger(M.Events.ERROR,{type:D.ErrorTypes.MEDIA_ERROR,details:D.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},x}()},"./src/controller/id3-track-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>p});var C=_("./src/polyfills/number.ts"),D=_("./src/events.ts"),M=_("./src/utils/texttrack-utils.ts"),P=_("./src/demux/id3.ts"),B=_("./src/loader/date-range.ts"),b=_("./src/types/demuxer.ts"),A=.25;function S(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var T=function(){var h=S();try{new h(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function x(h,a){return h.getTime()/1e3-a}function f(h){return Uint8Array.from(h.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var E=function(){function h(o){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=o,this._registerListeners()}var a=h.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,v){this.media=v.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 v=this.getID3Track(n.textTracks);return v.mode="hidden",v},a.getID3Track=function(n){if(!!this.media){for(var v=0;v<n.length;v++){var l=n[v];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,v){if(!!this.media){var l=this.hls.config,i=l.enableEmsgMetadataCues,u=l.enableID3MetadataCues;if(!(!i&&!u)){var g=v.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,s=t+g[m].duration;s>T&&(s=T);var y=s-t;y<=0&&(s=t+A);for(var d=0;d<r.length;d++){var L=r[d];if(!P.isTimeStampFrame(L)){this.updateId3CueEnds(t);var R=new c(t,s,"");R.value=L,e&&(R.type=e),this.id3Track.addCue(R)}}}}}}}},a.updateId3CueEnds=function(n){var v,l=(v=this.id3Track)===null||v===void 0?void 0:v.cues;if(l)for(var i=l.length;i--;){var u=l[i];u.startTime<n&&u.endTime===T&&(u.endTime=n)}},a.onBufferFlushing=function(n,v){var l=v.startOffset,i=v.endOffset,u=v.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,v){var l=this,i=v.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(K){g.removeCue(u[F].cues[K])}),delete u[F]},t=e.length;t--;)r(t);var s=i.fragments[i.fragments.length-1];if(!(m.length===0||!(0,C.isFiniteNumber)(s==null?void 0:s.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var y=s.programDateTime/1e3-s.start,d=S(),L=function(k){var F=m[k],K=c[F],H=u[F],j=(H==null?void 0:H.cues)||{},Y=(H==null?void 0:H.durationKnown)||!1,J=x(K.startDate,y),te=T,ae=K.endDate;if(ae)te=x(ae,y),Y=!0;else if(K.endOnNext&&!Y){var re=m.reduce(function(fe,Se){var be=c[Se];return be.class===K.class&&be.id!==Se&&be.startDate>K.startDate&&fe.push(be),fe},[]).sort(function(fe,Se){return fe.startDate.getTime()-Se.startDate.getTime()})[0];re&&(te=x(re.startDate,y),Y=!0)}for(var se=Object.keys(K.attr),ue=0;ue<se.length;ue++){var ce=se[ue];if(!(ce===B.DateRangeAttribute.ID||ce===B.DateRangeAttribute.CLASS||ce===B.DateRangeAttribute.START_DATE||ce===B.DateRangeAttribute.DURATION||ce===B.DateRangeAttribute.END_DATE||ce===B.DateRangeAttribute.END_ON_NEXT)){var le=j[ce];if(le)Y&&!H.durationKnown&&(le.endTime=te);else{var de=K.attr[ce];le=new d(J,te,""),(ce===B.DateRangeAttribute.SCTE35_OUT||ce===B.DateRangeAttribute.SCTE35_IN)&&(de=f(de)),le.value={key:ce,data:de},le.type=b.MetadataSchema.dateRange,l.id3Track.addCue(le),j[ce]=le}}}u[F]={cues:j,dateRange:K,durationKnown:Y}},R=0;R<m.length;R++)L(R)}}},h}();let p=E},"./src/controller/latency-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>S});var C=_("./src/errors.ts"),D=_("./src/events.ts"),M=_("./src/utils/logger.ts");function P(T,x){for(var f=0;f<x.length;f++){var E=x[f];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(T,b(E.key),E)}}function B(T,x,f){return x&&P(T.prototype,x),f&&P(T,f),Object.defineProperty(T,"prototype",{writable:!1}),T}function b(T){var x=A(T,"string");return typeof x=="symbol"?x:String(x)}function A(T,x){if(typeof T!="object"||T===null)return T;var f=T[Symbol.toPrimitive];if(f!==void 0){var E=f.call(T,x||"default");if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return(x==="string"?String:Number)(T)}var S=function(){function T(f){var E=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 E.timeupdate()},this.hls=f,this.config=f.config,this.registerListeners()}var x=T.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(E,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(E,p){var h=p.details;this.levelDetails=h,h.advanced&&this.timeupdate(),!h.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},x.onError=function(E,p){p.details===C.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,M.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},x.timeupdate=function(){var E=this.media,p=this.levelDetails;if(!(!E||!p)){this.currentTime=E.currentTime;var h=this.computeLatency();if(h!==null){this._latency=h;var a=this.config,o=a.lowLatencyMode,n=a.maxLiveSyncPlaybackRate;if(!(!o||n===1)){var v=this.targetLatency;if(v!==null){var l=h-v,i=Math.min(this.maxLatency,v+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;E.playbackRate=Math.min(g,Math.max(1,c))}else E.playbackRate!==1&&E.playbackRate!==0&&(E.playbackRate=1)}}}}},x.estimateLiveEdge=function(){var E=this.levelDetails;return E===null?null:E.edge+E.age},x.computeLatency=function(){var E=this.estimateLiveEdge();return E===null?null:E-this.currentTime},B(T,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var E=this.config,p=this.levelDetails;return E.liveMaxLatencyDuration!==void 0?E.liveMaxLatencyDuration:p?E.liveMaxLatencyDurationCount*p.targetduration:0}},{key:"targetLatency",get:function(){var E=this.levelDetails;if(E===null)return null;var p=E.holdBack,h=E.partHoldBack,a=E.targetduration,o=this.config,n=o.liveSyncDuration,v=o.liveSyncDurationCount,l=o.lowLatencyMode,i=this.hls.userConfig,u=l&&h||p;(i.liveSyncDuration||i.liveSyncDurationCount||u===0)&&(u=n!==void 0?n:v*a);var g=a,c=1;return u+Math.min(this.stallCount*c,g)}},{key:"liveSyncPosition",get:function(){var E=this.estimateLiveEdge(),p=this.targetLatency,h=this.levelDetails;if(E===null||p===null||h===null)return null;var a=h.edge,o=E-p-this.edgeStalled,n=a-h.totalduration,v=a-(this.config.lowLatencyMode&&h.partTarget||h.targetduration);return Math.min(Math.max(n,o),v)}},{key:"drift",get:function(){var E=this.levelDetails;return E===null?1:E.drift}},{key:"edgeStalled",get:function(){var E=this.levelDetails;if(E===null)return 0;var p=(this.config.lowLatencyMode&&E.partTarget||E.targetduration)*3;return Math.max(E.age-p,0)}},{key:"forwardBufferLength",get:function(){var E=this.media,p=this.levelDetails;if(!E||!p)return 0;var h=E.buffered.length;return(h?E.buffered.end(h-1):p.edge)-this.currentTime}}]),T}()},"./src/controller/level-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>o});var C=_("./src/types/level.ts"),D=_("./src/events.ts"),M=_("./src/errors.ts"),P=_("./src/utils/codecs.ts"),B=_("./src/controller/level-helper.ts"),b=_("./src/controller/base-playlist-controller.ts"),A=_("./src/types/loader.ts");function S(){return S=Object.assign?Object.assign.bind():function(n){for(var v=1;v<arguments.length;v++){var l=arguments[v];for(var i in l)Object.prototype.hasOwnProperty.call(l,i)&&(n[i]=l[i])}return n},S.apply(this,arguments)}function T(n,v){for(var l=0;l<v.length;l++){var i=v[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,v,l){return v&&T(n.prototype,v),l&&T(n,l),Object.defineProperty(n,"prototype",{writable:!1}),n}function f(n){var v=E(n,"string");return typeof v=="symbol"?v:String(v)}function E(n,v){if(typeof n!="object"||n===null)return n;var l=n[Symbol.toPrimitive];if(l!==void 0){var i=l.call(n,v||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(v==="string"?String:Number)(n)}function p(n,v){n.prototype=Object.create(v.prototype),n.prototype.constructor=n,h(n,v)}function h(n,v){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,u){return i.__proto__=u,i},h(n,v)}var a=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),o=function(n){p(v,n);function v(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=v.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={},s,y=!1,d=!1,L=!1;if(g.levels.forEach(function(F){var K=F.attrs;y=y||!!(F.width&&F.height),d=d||!!F.videoCodec,L=L||!!F.audioCodec,a&&F.audioCodec&&F.audioCodec.indexOf("mp4a.40.34")!==-1&&(F.audioCodec=void 0);var H=F.bitrate+"-"+F.attrs.RESOLUTION+"-"+F.attrs.CODECS;s=t[H],s?s.url.push(F.url):(s=new C.Level(F),t[H]=s,c.push(s)),K&&(K.AUDIO&&(0,B.addGroupId)(s,"audio",K.AUDIO),K.SUBTITLES&&(0,B.addGroupId)(s,"text",K.SUBTITLES))}),(y||d)&&L&&(c=c.filter(function(F){var K=F.videoCodec,H=F.width,j=F.height;return!!K||!!(H&&j)})),c=c.filter(function(F){var K=F.audioCodec,H=F.videoCodec;return(!K||(0,P.isCodecSupportedInMp4)(K,"audio"))&&(!H||(0,P.isCodecSupportedInMp4)(H,"video"))}),g.audioTracks&&(m=g.audioTracks.filter(function(F){return!F.audioCodec||(0,P.isCodecSupportedInMp4)(F.audioCodec,"audio")}),(0,B.assignTrackIdsByGroup)(m)),g.subtitles&&(e=g.subtitles,(0,B.assignTrackIdsByGroup)(e)),c.length>0){r=c[0].bitrate,c.sort(function(F,K){return F.attrs["HDCP-LEVEL"]!==K.attrs["HDCP-LEVEL"]?(F.attrs["HDCP-LEVEL"]||"")>(K.attrs["HDCP-LEVEL"]||"")?1:-1:F.bitrate!==K.bitrate?F.bitrate-K.bitrate:F.attrs.SCORE!==K.attrs.SCORE?F.attrs.decimalFloatingPoint("SCORE")-K.attrs.decimalFloatingPoint("SCORE"):y&&F.height!==K.height?F.height-K.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&&!d,k={levels:c,audioTracks:m,subtitleTracks:e,sessionData:g.sessionData,sessionKeys:g.sessionKeys,firstLevel:this._firstLevel,stats:g.stats,audio:L,video:d,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,s=!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 d=g.frag.type===A.PlaylistLevelType.MAIN?g.frag.level:this.currentLevelIndex,L=this._levels[d];L?(L.fragmentError++,L.fragmentError>this.hls.config.fragLoadingMaxRetry&&(y=d)):y=d}break;case M.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{var R=r.attrs["HDCP-LEVEL"];R&&(this.hls.maxHdcpLevel=C.HdcpLevels[C.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&&(s=!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,s)}},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 s=r.url.length;if(s>1&&r.loadError<s)u.levelRetry=!0,this.redundantFailover(g);else if(this.manualLevelIndex===-1){for(var y=-1,d=this._levels,L=d.length;L--;){var R=(L+this.currentLevelIndex)%d.length;if(R!==this.currentLevelIndex&&d[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(s){s.level=r}),e});this._levels=m,this.hls.trigger(D.Events.LEVELS_UPDATED,{levels:m})},x(v,[{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 s=S({},t,{level:u,maxBitrate:t.maxBitrate,uri:t.uri,urlId:t.urlId});delete s._urlId,this.hls.trigger(D.Events.LEVEL_SWITCHING,s);var y=t.details;if(!y||y.live){var d=this.switchParams(t.uri,r==null?void 0:r.details);this.loadPlaylist(d)}}}},{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)}}]),v}(b.default)},"./src/controller/level-helper.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{addGroupId:()=>B,addSliding:()=>a,adjustSliding:()=>h,assignTrackIdsByGroup:()=>b,computeReloadInterval:()=>o,getFragmentWithSN:()=>n,getPartWith:()=>v,mapFragmentIntersection:()=>p,mapPartIntersection:()=>E,mergeDetails:()=>x,updateFragPTSDTS:()=>T,updatePTS:()=>A});var C=_("./src/polyfills/number.ts"),D=_("./src/utils/logger.ts"),M=_("./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 B(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,C.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 T(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,s=i.startPTS,y=i.endPTS;if((0,C.isFiniteNumber)(s)){var d=Math.abs(s-u);(0,C.isFiniteNumber)(i.deltaPTS)?i.deltaPTS=Math.max(d,i.deltaPTS):i.deltaPTS=d,r=Math.max(u,s),u=Math.min(u,s),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,C.isFiniteNumber)(I.startPTS)&&(0,C.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 s=i.skippedSegments;s--;)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 d=0;d<y.length;d++)y[d].cc+=e}i.skippedSegments&&(i.startCC=i.fragments[0].cc),E(l.partList,i.partList,function(I,k){k.elementaryStreams=I.elementaryStreams,k.stats=I.stats}),r?T(i,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):h(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 E(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,s=c;s<=m;s++){var y=t[e+s],d=r[s];g&&!d&&s<g&&(d=i.fragments[s]=y),y&&d&&u(y,d)}}function h(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 o(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 v(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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>i});var C=_("./src/polyfills/number.ts"),D=_("./src/controller/base-stream-controller.ts"),M=_("./src/is-supported.ts"),P=_("./src/events.ts"),B=_("./src/utils/buffer-helper.ts"),b=_("./src/controller/fragment-tracker.ts"),A=_("./src/types/loader.ts"),S=_("./src/loader/fragment.ts"),T=_("./src/demux/transmuxer-interface.ts"),x=_("./src/types/transmuxer.ts"),f=_("./src/controller/gap-controller.ts"),E=_("./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 h(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=o(u,"string");return typeof g=="symbol"?g:String(g)}function o(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,v(u,g)}function v(u,g){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(m,e){return m.__proto__=e,m},v(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 s=t.startLevel;s===-1&&(t.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=t.nextAutoLevel),this.level=t.nextLoadLevel=s,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,s=r==null||(e=r[t])===null||e===void 0?void 0:e.details;if(s&&(!s.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(s))break;this.state=D.State.IDLE;break}break}case D.State.FRAG_LOADING_WAITING_RETRY:{var y,d=self.performance.now(),L=this.retryDate;(!L||d>=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,s=this.media,y=e.config,d=e.nextLoadLevel;if(!(r===null||!s&&(this.startFragRequested||!y.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!t||!t[d])){var L=t[d],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=d;var F=L.details;if(!F||this.state===D.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==d){this.level=d,this.state=D.State.WAITING_LEVEL;return}var K=R.len,H=this.getMaxBufferLength(L.maxBitrate);if(!(K>=H)){this.backtrackFragment&&this.backtrackFragment.start>R.end&&(this.backtrackFragment=null);var j=this.backtrackFragment?this.backtrackFragment.start:R.end,Y=this.getNextFragment(j,F);if(this.couldBacktrack&&!this.fragPrevious&&Y&&Y.sn!=="initSegment"&&this.fragmentTracker.getState(Y)!==b.FragmentState.OK){var J,te=((J=this.backtrackFragment)!=null?J:Y).sn,ae=te-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>j){var se=this.audioOnly&&!this.altAudio?S.ElementaryStreamTypes.AUDIO:S.ElementaryStreamTypes.VIDEO,ue=(se===S.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;ue&&this.afterBufferFlushed(ue,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,j))}}}},c.loadFragment=function(e,r,t){var s,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):((s=this.media)===null||s===void 0?void 0:s.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,s=this.getAppendedFrag(r.currentTime);if(s&&s.start>1&&this.flushMainBuffer(0,s.start-1),!r.paused&&e){var y=this.hls.nextLoadLevel,d=e[y],L=this.fragLastKbps;L&&this.fragCurrent?t=this.fragCurrent.duration*d.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,K=Math.max(R.end,k+Math.min(Math.max(F-this.config.maxFragLookUpTolerance,F*.5),F*.75));this.flushMainBuffer(K,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,C.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,s=!1,y;r.levels.forEach(function(d){y=d.audioCodec,y&&(y.indexOf("mp4a.40.2")!==-1&&(t=!0),y.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=t&&s&&!(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 s=t[r.level];(!s.details||s.details.live&&this.levelLastLoaded!==r.level||this.waitForCdnTuneIn(s.details))&&(this.state=D.State.WAITING_LEVEL)}},c.onLevelLoaded=function(e,r){var t,s=this.levels,y=r.level,d=r.details,L=d.totalduration;if(!s){this.warn("Levels were reset while loading level "+y);return}this.log("Level "+y+" loaded ["+d.startSN+","+d.endSN+"], cc ["+d.startCC+", "+d.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=s[y],k=0;if(d.live||(t=I.details)!==null&&t!==void 0&&t.live){if(d.fragments[0]||(d.deltaUpdateFailed=!0),d.deltaUpdateFailed)return;k=this.alignPlaylists(d,I.details)}if(I.details=d,this.levelLastLoaded=y,this.hls.trigger(P.Events.LEVEL_UPDATED,{details:d,level:y}),this.state===D.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(d))return;this.state=D.State.IDLE}this.startFragRequested?d.live&&this.synchronizeToLiveEdge(d):this.setStartPosition(d,k),this.tick()},c._handleFragmentLoadProgress=function(e){var r,t=e.frag,s=e.part,y=e.payload,d=this.levels;if(!d){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=d[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,K=this._getAudioCodec(L),H=this.transmuxer=this.transmuxer||new T.default(this.hls,A.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),j=s?s.index:-1,Y=j!==-1,J=new x.ChunkMetadata(t.level,t.sn,t.stats.chunkCount,y.byteLength,j,Y),te=this.initPTS[t.cc];H.push(y,F,K,I,t,s,R.totalduration,k,J,te)},c.onAudioTrackSwitching=function(e,r){var t=this.altAudio,s=!!r.url,y=r.id;if(!s){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var d=this.fragCurrent;d&&(this.log("Switching to main audio track, cancel main fragment load"),d.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,s=!!this.hls.audioTracks[t].url;if(s){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=s,this.tick()},c.onBufferCreated=function(e,r){var t=r.tracks,s,y,d=!1;for(var L in t){var R=t[L];if(R.id==="main"){if(y=L,s=R,L==="video"){var I=t[L];I&&(this.videoBuffer=I.buffer)}}else d=!0}d&&s?(this.log("Alternate track found, use "+y+".buffered to schedule main fragment loading"),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media},c.onFragBuffered=function(e,r){var t=r.frag,s=r.part;if(!(t&&t.type!==A.PlaylistLevelType.MAIN)){if(this.fragContextChanged(t)){this.warn("Fragment "+t.sn+(s?" p: "+s.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=s?s.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,s)}},c.onError=function(e,r){if(r.type===E.ErrorTypes.KEY_SYSTEM_ERROR){this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,r);return}switch(r.details){case E.ErrorDetails.FRAG_LOAD_ERROR:case E.ErrorDetails.FRAG_LOAD_TIMEOUT:case E.ErrorDetails.FRAG_PARSING_ERROR:case E.ErrorDetails.KEY_LOAD_ERROR:case E.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A.PlaylistLevelType.MAIN,r);break;case E.ErrorDetails.LEVEL_LOAD_ERROR:case E.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 E.ErrorDetails.BUFFER_FULL_ERROR:if(r.parent==="main"&&(this.state===D.State.PARSING||this.state===D.State.PARSED)){var t=!0,s=this.getFwdBufferInfo(this.media,A.PlaylistLevelType.MAIN);s&&s.len>.5&&(t=!this.reduceMaxBufferLength(s.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||!B.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 s=(t===S.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,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 s=B.BufferHelper.getBuffered(e),y=s.length?s.start(0):0,d=y-t;d>0&&(d<this.config.maxBufferHole||d<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+d+" to match buffer start"),t+=d,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(s){var y=t.hls;if(!(!s||y.nextLoadLevel||t.fragContextChanged(e))){t.fragLoadError=0,t.state=D.State.IDLE,t.startFragRequested=!1,t.bitrateTest=!1;var d=e.stats;d.parsing.start=d.parsing.end=d.buffering.start=d.buffering.end=self.performance.now(),y.trigger(P.Events.FRAG_LOADED,s),e.bitrateTest=!1}})},c._handleTransmuxComplete=function(e){var r,t="main",s=this.hls,y=e.remuxResult,d=e.chunkMeta,L=this.getCurrentContext(d);if(!L){this.warn("The loading context changed while buffering fragment "+d.sn+" of level "+d.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(d.level);return}var R=L.frag,I=L.part,k=L.level,F=y.video,K=y.text,H=y.id3,j=y.initSegment,Y=k.details,J=this.altAudio?void 0:y.audio;if(!this.fragContextChanged(R)){if(this.state=D.State.PARSING,j){j.tracks&&(this._bufferInitSegment(k,j.tracks,R,d),s.trigger(P.Events.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:t,tracks:j.tracks}));var te=j.initPTS,ae=j.timescale;(0,C.isFiniteNumber)(te)&&(this.initPTS[R.cc]=te,s.trigger(P.Events.INIT_PTS_FOUND,{frag:R,id:t,initPTS:te,timescale:ae}))}if(F&&y.independent!==!1){if(Y){var re=F.startPTS,se=F.endPTS,ue=F.startDTS,ce=F.endDTS;if(I)I.elementaryStreams[F.type]={startPTS:re,endPTS:se,startDTS:ue,endDTS:ce};else if(F.firstKeyFrame&&F.independent&&d.id===1&&(this.couldBacktrack=!0),F.dropped&&F.independent){var le=this.getMainFwdBufferInfo(),de=(le?le.end:this.getLoadPosition())+this.config.maxBufferHole,fe=F.firstKeyFramePTS?F.firstKeyFramePTS:re;if(de<fe-this.config.maxBufferHole){this.backtrack(R);return}R.setElementaryStreamInfo(F.type,R.start,se,R.start,ce,!0)}R.setElementaryStreamInfo(F.type,re,se,ue,ce),this.backtrackFragment&&(this.backtrackFragment=R),this.bufferFragmentData(F,R,I,d)}}else if(y.independent===!1){this.backtrack(R);return}if(J){var Se=J.startPTS,be=J.endPTS,Oe=J.startDTS,Re=J.endDTS;I&&(I.elementaryStreams[S.ElementaryStreamTypes.AUDIO]={startPTS:Se,endPTS:be,startDTS:Oe,endDTS:Re}),R.setElementaryStreamInfo(S.ElementaryStreamTypes.AUDIO,Se,be,Oe,Re),this.bufferFragmentData(J,R,I,d)}if(Y&&H!==null&&H!==void 0&&(r=H.samples)!==null&&r!==void 0&&r.length){var Ce={id:t,frag:R,details:Y,samples:H.samples};s.trigger(P.Events.FRAG_PARSING_METADATA,Ce)}if(Y&&K){var Pe={id:t,frag:R,details:Y,samples:K.samples};s.trigger(P.Events.FRAG_PARSING_USERDATA,Pe)}}},c._bufferInitSegment=function(e,r,t,s){var y=this;if(this.state===D.State.PARSING){this.audioOnly=!!r.audio&&!r.video,this.altAudio&&!this.audioOnly&&delete r.audio;var d=r.audio,L=r.video,R=r.audiovideo;if(d){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"),d.metadata.channelCount!==1&&k.indexOf("firefox")===-1&&(I="mp4a.40.5")),k.indexOf("android")!==-1&&d.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+'"'),d.levelCodec=I,d.id="main",this.log("Init audio buffer, container:"+d.container+", codecs[selected/level/parsed]=["+(I||"")+"/"+(e.audioCodec||"")+"/"+d.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 K=r[F],H=K.initSegment;H!=null&&H.byteLength&&y.hls.trigger(P.Events.BUFFER_APPENDING,{type:F,data:H,frag:t,part:null,chunkMeta:s,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(B.BufferHelper.isBuffered(e,t)?r=this.getAppendedFrag(t):B.BufferHelper.isBuffered(e,t+.1)&&(r=this.getAppendedFrag(t+.1)),r){this.backtrackFragment=null;var s=this.fragPlaying,y=r.level;(!s||r.sn!==s.sn||s.level!==y||r.urlId!==s.urlId)&&(this.fragPlaying=r,this.hls.trigger(P.Events.FRAG_CHANGED,{frag:r}),(!s||s.level!==y)&&this.hls.trigger(P.Events.LEVEL_SWITCHED,{level:y}))}}},h(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,C.isFiniteNumber)(r)&&(0,C.isFiniteNumber)(t.programDateTime)){var s=t.programDateTime+(r-t.start)*1e3;return new Date(s)}}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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{SubtitleStreamController:()=>n});var C=_("./src/events.ts"),D=_("./src/utils/buffer-helper.ts"),M=_("./src/controller/fragment-finders.ts"),P=_("./src/utils/discontinuities.ts"),B=_("./src/controller/level-helper.ts"),b=_("./src/controller/fragment-tracker.ts"),A=_("./src/controller/base-stream-controller.ts"),S=_("./src/types/loader.ts"),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,E(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 E(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 h(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 o=500,n=function(l){h(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(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.on(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.on(C.Events.ERROR,this.onError,this),c.on(C.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.on(C.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),c.on(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),c.on(C.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),c.on(C.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),c.on(C.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u._unregisterListeners=function(){var c=this.hls;c.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),c.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),c.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),c.off(C.Events.LEVEL_LOADED,this.onLevelLoaded,this),c.off(C.Events.ERROR,this.onError,this),c.off(C.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),c.off(C.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),c.off(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),c.off(C.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),c.off(C.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),c.off(C.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u.startLoad=function(c){this.stopLoad(),this.state=A.State.IDLE,this.setInterval(o),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 s,y=e.start,d=0;d<t.length;d++)if(y>=t[d].start&&y<=t[d].end){s=t[d];break}var L=e.start+e.duration;s?s.end=L:(s={start:y,end:L},t.push(s)),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,s=this.levels;if(!s.length||!s[t]||!s[t].details)return;var y=s[t].details,d=y.targetduration,L=r-d;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 T.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(o)},u.onSubtitleTrackLoaded=function(c,m){var e,r=m.details,t=m.id,s=this.currentTrackId,y=this.levels;if(!!y.length){var d=y[s];if(!(t>=y.length||t!==s||!d)){this.mediaBuffer=this.mediaBufferTimeRanges;var L=0;if(r.live||(e=d.details)!==null&&e!==void 0&&e.live){var R=this.mainDetails;if(r.deltaUpdateFailed||!R)return;var I=R.fragments[0];d.details?(L=this.alignPlaylists(r,d.details),L===0&&I&&(L=I.start,(0,B.addSliding)(r,L))):r.hasProgramDateTime&&R.hasProgramDateTime?((0,P.alignMediaPlaylistByPDT)(r,R),L=r.fragments[0].start):I&&(L=I.start,(0,B.addSliding)(r,L))}if(d.details=r,this.levelLastLoaded=t,!this.startFragRequested&&(this.mainDetails||!r.live)&&this.setStartPosition(d.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"),d.details=void 0)}}}},u._handleFragmentLoadComplete=function(c){var m=this,e=c.frag,r=c.payload,t=e.decryptdata,s=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(d){var L=performance.now();s.trigger(C.Events.FRAG_DECRYPTED,{frag:e,payload:d,stats:{tstart:y,tdecrypt:L}})}).catch(function(d){m.warn(d.name+": "+d.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,s=this.getLoadPosition(),y=D.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],s-r,t.maxBufferHole),d=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,K=e.edge,H=null,j=this.fragPrevious;if(d<K){var Y=t.maxFragLookUpTolerance;H=(0,M.findFragmentByPTS)(j,k,Math.max(k[0].start,d),Y),!H&&j&&j.start<k[0].start&&(H=k[0])}else H=k[F-1];if(!H)return;H=this.mapToInitFragWhenRequired(H),this.fragmentTracker.getState(H)===b.FragmentState.NOT_LOADED&&this.loadFragment(H,e,d)}},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 v(this.tracksBuffered[this.currentTrackId]||[])}}]),i}(A.default),v=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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>p});var C=_("./src/events.ts"),D=_("./src/utils/texttrack-utils.ts"),M=_("./src/controller/base-playlist-controller.ts"),P=_("./src/types/loader.ts");function B(h,a){for(var o=0;o<a.length;o++){var n=a[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,A(n.key),n)}}function b(h,a,o){return a&&B(h.prototype,a),o&&B(h,o),Object.defineProperty(h,"prototype",{writable:!1}),h}function A(h){var a=S(h,"string");return typeof a=="symbol"?a:String(a)}function S(h,a){if(typeof h!="object"||h===null)return h;var o=h[Symbol.toPrimitive];if(o!==void 0){var n=o.call(h,a||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(a==="string"?String:Number)(h)}function T(h,a){h.prototype=Object.create(a.prototype),h.prototype.constructor=h,x(h,a)}function x(h,a){return x=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,v){return n.__proto__=v,n},x(h,a)}var f=function(h){T(a,h);function a(n){var v;return v=h.call(this,n,"[subtitle-track-controller]")||this,v.media=null,v.tracks=[],v.groupId=null,v.tracksInGroup=[],v.trackId=-1,v.selectDefaultTrack=!0,v.queuedDefaultTrack=-1,v.trackChangeListener=function(){return v.onTextTracksChanged()},v.asyncPollTrackChange=function(){return v.pollTrackChange(0)},v.useTextTrackPolling=!1,v.subtitlePollingInterval=-1,v._subtitleDisplay=!0,v.registerListeners(),v}var o=a.prototype;return o.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,h.prototype.destroy.call(this)},o.registerListeners=function(){var v=this.hls;v.on(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),v.on(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.on(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.on(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.on(C.Events.LEVEL_LOADING,this.onLevelLoading,this),v.on(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),v.on(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),v.on(C.Events.ERROR,this.onError,this)},o.unregisterListeners=function(){var v=this.hls;v.off(C.Events.MEDIA_ATTACHED,this.onMediaAttached,this),v.off(C.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.off(C.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(C.Events.MANIFEST_PARSED,this.onManifestParsed,this),v.off(C.Events.LEVEL_LOADING,this.onLevelLoading,this),v.off(C.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),v.off(C.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),v.off(C.Events.ERROR,this.onError,this)},o.onMediaAttached=function(v,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))},o.pollTrackChange=function(v){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,v)},o.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 v=E(this.media.textTracks);v.forEach(function(l){(0,D.clearCurrentCues)(l)}),this.subtitleTrack=-1,this.media=null}},o.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},o.onManifestParsed=function(v,l){this.tracks=l.subtitleTracks},o.onSubtitleTrackLoaded=function(v,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))},o.onLevelLoading=function(v,l){this.switchLevel(l.level)},o.onLevelSwitching=function(v,l){this.switchLevel(l.level)},o.switchLevel=function(v){var l=this.hls.levels[v];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(C.Events.SUBTITLE_TRACKS_UPDATED,m),c!==-1&&this.setSubtitleTrack(c,u)}}},o.findTrackId=function(v){for(var l=this.tracksInGroup,i=0;i<l.length;i++){var u=l[i];if((!this.selectDefaultTrack||u.default)&&(!v||v===u.name))return u.id}return-1},o.onError=function(v,l){h.prototype.onError.call(this,v,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)},o.loadPlaylist=function(v){h.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(v)try{g=v.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(C.Events.SUBTITLE_TRACK_LOADING,{url:g,id:i,groupId:u,deliveryDirectives:v||null})}},o.toggleTrackModes=function(v){var l=this,i=this.media,u=this.trackId;if(!!i){var g=E(i.textTracks),c=g.filter(function(r){return r.groupId===l.groupId});if(v===-1)[].slice.call(g).forEach(function(r){r.mode="disabled"});else{var m=c[u];m&&(m.mode="disabled")}var e=c[v];e&&(e.mode=this.subtitleDisplay?"showing":"hidden")}},o.setSubtitleTrack=function(v,l){var i,u=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=v;return}if(this.trackId!==v&&this.toggleTrackModes(v),!(this.trackId===v&&(v===-1||(i=u[v])!==null&&i!==void 0&&i.details)||v<-1||v>=u.length)){this.clearTimer();var g=u[v];if(this.log("Switching to subtitle track "+v),this.trackId=v,g){var c=g.id,m=g.groupId,e=m===void 0?"":m,r=g.name,t=g.type,s=g.url;this.hls.trigger(C.Events.SUBTITLE_TRACK_SWITCH,{id:c,groupId:e,name:r,type:t,url:s});var y=this.switchParams(g.url,l==null?void 0:l.details);this.loadPlaylist(y)}else this.hls.trigger(C.Events.SUBTITLE_TRACK_SWITCH,{id:v})}},o.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var v=-1,l=E(this.media.textTracks),i=0;i<l.length;i++)if(l[i].mode==="hidden")v=i;else if(l[i].mode==="showing"){v=i;break}this.subtitleTrack!==v&&(this.subtitleTrack=v)}},b(a,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(v){this._subtitleDisplay=v,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(v){this.selectDefaultTrack=!1;var l=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(v,l)}}]),a}(M.default);function E(h){for(var a=[],o=0;o<h.length;o++){var n=h[o];n.kind==="subtitles"&&n.label&&a.push(h[o])}return a}let p=f},"./src/controller/timeline-controller.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{TimelineController:()=>f});var C=_("./src/polyfills/number.ts"),D=_("./src/events.ts"),M=_("./src/utils/cea-608-parser.ts"),P=_("./src/utils/output-filter.ts"),B=_("./src/utils/webvtt-parser.ts"),b=_("./src/utils/texttrack-utils.ts"),A=_("./src/utils/imsc1-ttml-parser.ts"),S=_("./src/utils/mp4-tools.ts"),T=_("./src/types/loader.ts"),x=_("./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=h(),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 v=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,v,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 o=a.prototype;return o.destroy=function(){var v=this.hls;v.off(D.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),v.off(D.Events.MEDIA_DETACHING,this.onMediaDetaching,this),v.off(D.Events.MANIFEST_LOADING,this.onManifestLoading,this),v.off(D.Events.MANIFEST_LOADED,this.onManifestLoaded,this),v.off(D.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),v.off(D.Events.FRAG_LOADING,this.onFragLoading,this),v.off(D.Events.FRAG_LOADED,this.onFragLoaded,this),v.off(D.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),v.off(D.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),v.off(D.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),v.off(D.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),v.off(D.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(v,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[v];this.Cues.newCue(t,l,i,u)}else{var s=this.Cues.newCue(null,l,i,u);this.hls.trigger(D.Events.CUES_PARSED,{type:"captions",cues:s,track:v})}},o.onInitPtsFound=function(v,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)}))},o.getExistingTrack=function(v){var l=this.media;if(l)for(var i=0;i<l.textTracks.length;i++){var u=l.textTracks[i];if(u[v])return u}return null},o.createCaptionsTrack=function(v){this.config.renderTextTracksNatively?this.createNativeTrack(v):this.createNonNativeTrack(v)},o.createNativeTrack=function(v){if(!this.captionsTracks[v]){var l=this.captionsProperties,i=this.captionsTracks,u=this.media,g=l[v],c=g.label,m=g.languageCode,e=this.getExistingTrack(v);if(e)i[v]=e,(0,b.clearCurrentCues)(i[v]),(0,b.sendAddTrackEvent)(i[v],u);else{var r=this.createTextTrack("captions",c,m);r&&(r[v]=!0,i[v]=r)}}},o.createNonNativeTrack=function(v){if(!this.nonNativeCaptionsTracks[v]){var l=this.captionsProperties[v];if(!!l){var i=l.label,u={_id:v,label:i,kind:"captions",default:l.media?!!l.media.default:!1,closedCaptions:l.media};this.nonNativeCaptionsTracks[v]=u,this.hls.trigger(D.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[u]})}}},o.createTextTrack=function(v,l,i){var u=this.media;if(!!u)return u.addTextTrack(v,l,i)},o.onMediaAttaching=function(v,l){this.media=l.media,this._cleanTracks()},o.onMediaDetaching=function(){var v=this.captionsTracks;Object.keys(v).forEach(function(l){(0,b.clearCurrentCues)(v[l]),delete v[l]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=h(),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 v=this.media;if(!!v){var l=v.textTracks;if(l)for(var i=0;i<l.length;i++)(0,b.clearCurrentCues)(l[i])}},o.onSubtitleTracksUpdated=function(v,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 s;if(t<m.length){for(var y=null,d=0;d<m.length;d++)if(E(m[d],r)){y=m[d];break}y&&(s=y)}if(s)(0,b.clearCurrentCues)(s);else{var L=i._captionsOrSubtitlesFromCharacteristics(r);s=i.createTextTrack(L,r.name,r.lang),s&&(s.mode="disabled")}s&&(s.groupId=r.groupId,i.textTracks.push(s))})}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})}}},o._captionsOrSubtitlesFromCharacteristics=function(v){var l;if((l=v.attrs)!==null&&l!==void 0&&l.CHARACTERISTICS){var i=/transcribes-spoken-dialog/gi.test(v.attrs.CHARACTERISTICS),u=/describes-music-and-sound/gi.test(v.attrs.CHARACTERISTICS);if(i&&u)return"captions"}return"subtitles"},o.onManifestLoaded=function(v,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)}})},o.closedCaptionsForLevel=function(v){var l=this.hls.levels[v.level];return l==null?void 0:l.attrs["CLOSED-CAPTIONS"]},o.onFragLoading=function(v,l){var i=this.cea608Parser1,u=this.cea608Parser2,g=this.lastSn,c=this.lastPartIndex;if(!(!this.enabled||!(i&&u))&&l.frag.type===T.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}},o.onFragLoaded=function(v,l){var i=l.frag,u=l.payload,g=this.initPTS,c=this.unparsedVttFrags;if(i.type===T.PlaylistLevelType.SUBTITLE)if(u.byteLength){if(!(0,C.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")})},o._parseIMSC1=function(v,l){var i=this,u=this.hls;(0,A.parseIMSC1)(l,this.initPTS[v.cc],this.timescale[v.cc],function(g){i._appendCues(g,v.level),u.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},function(g){x.logger.log("Failed to parse IMSC1: "+g),u.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:g})})},o._parseVTTs=function(v,l,i){var u,g=this,c=this.hls,m=(u=v.initSegment)!==null&&u!==void 0&&u.data?(0,S.appendUint8Array)(v.initSegment.data,new Uint8Array(l)):l;(0,B.parseWebVTT)(m,this.initPTS[v.cc],this.timescale[v.cc],i,v.cc,v.start,function(e){g._appendCues(e,v.level),c.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:v})},function(e){g._fallbackToIMSC1(v,l),x.logger.log("Failed to parse VTT cue: "+e),c.trigger(D.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:v,error:e})})},o._fallbackToIMSC1=function(v,l){var i=this,u=this.tracks[v.level];u.textCodec||(0,A.parseIMSC1)(l,this.initPTS[v.cc],this.timescale[v.cc],function(){u.textCodec=A.IMSC1_CODEC,i._parseIMSC1(v,l)},function(){u.textCodec="wvtt"})},o._appendCues=function(v,l){var i=this.hls;if(this.config.renderTextTracksNatively){var u=this.textTracks[l];if(!u||u.mode==="disabled")return;v.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:v,track:c})}},o.onFragDecrypted=function(v,l){var i=l.frag;if(i.type===T.PlaylistLevelType.SUBTITLE){if(!(0,C.isFiniteNumber)(this.initPTS[i.cc])){this.unparsedVttFrags.push(l);return}this.onFragLoaded(D.Events.FRAG_LOADED,l)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(v,l){var i=this.cea608Parser1,u=this.cea608Parser2;if(!(!this.enabled||!(i&&u))){var g=l.frag,c=l.samples;if(!(g.type===T.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])}}}},o.onBufferFlushing=function(v,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)})}}},o.extractCea608Data=function(v){for(var l=[[],[]],i=v[0]&31,u=2,g=0;g<i;g++){var c=v[u++],m=127&v[u++],e=127&v[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 E(a,o){return a&&a.label===o.name&&!(a.textTrack1||a.textTrack2)}function p(a,o,n,v){return Math.min(o,v)-Math.max(a,n)}function h(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>C});var C=function(){function D(P,B){this.subtle=void 0,this.aesIV=void 0,this.subtle=P,this.aesIV=B}var M=D.prototype;return M.decrypt=function(B,b){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},b,B)},D}()},"./src/crypt/aes-decryptor.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>M,removePadding:()=>D});var C=_("./src/utils/typed-array.ts");function D(P){var B=P.byteLength,b=B&&new DataView(P.buffer).getUint8(B-1);return b?(0,C.sliceUint8)(P,0,B-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 B=P.prototype;return B.uint8ArrayToUint32Array_=function(A){for(var S=new DataView(A),T=new Uint32Array(4),x=0;x<4;x++)T[x]=S.getUint32(x*4);return T},B.initTable=function(){var A=this.sBox,S=this.invSBox,T=this.subMix,x=T[0],f=T[1],E=T[2],p=T[3],h=this.invSubMix,a=h[0],o=h[1],n=h[2],v=h[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,E[i]=t<<8|t>>>24,p[i]=t,t=r*16843009^e*65537^m*257^i*16843008,a[c]=t<<24|t>>>8,o[c]=t<<16|t>>>16,n[c]=t<<8|t>>>24,v[c]=t,i?(i=m^l[l[l[r^m]]],u^=l[l[u]]):i=u=1}},B.expandKey=function(A){for(var S=this.uint8ArrayToUint32Array_(A),T=!0,x=0;x<S.length&&T;)T=S[x]===this.key[x],x++;if(!T){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 E=this.ksRows=(f+6+1)*4,p,h,a=this.keySchedule=new Uint32Array(E),o=this.invKeySchedule=new Uint32Array(E),n=this.sBox,v=this.rcon,l=this.invSubMix,i=l[0],u=l[1],g=l[2],c=l[3],m,e;for(p=0;p<E;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^=v[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(h=0;h<E;h++)p=E-h,h&3?e=a[p]:e=a[p-4],h<4||p<=4?o[h]=e:o[h]=i[n[e>>>24]]^u[n[e>>>16&255]]^g[n[e>>>8&255]]^c[n[e&255]],o[h]=o[h]>>>0}},B.networkToHostOrderSwap=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},B.decrypt=function(A,S,T){for(var x=this.keySize+6,f=this.invKeySchedule,E=this.invSBox,p=this.invSubMix,h=p[0],a=p[1],o=p[2],n=p[3],v=this.uint8ArrayToUint32Array_(T),l=v[0],i=v[1],u=v[2],g=v[3],c=new Int32Array(A),m=new Int32Array(c.length),e,r,t,s,y,d,L,R,I,k,F,K,H,j,Y=this.networkToHostOrderSwap;S<c.length;){for(I=Y(c[S]),k=Y(c[S+1]),F=Y(c[S+2]),K=Y(c[S+3]),y=I^f[0],d=K^f[1],L=F^f[2],R=k^f[3],H=4,j=1;j<x;j++)e=h[y>>>24]^a[d>>16&255]^o[L>>8&255]^n[R&255]^f[H],r=h[d>>>24]^a[L>>16&255]^o[R>>8&255]^n[y&255]^f[H+1],t=h[L>>>24]^a[R>>16&255]^o[y>>8&255]^n[d&255]^f[H+2],s=h[R>>>24]^a[y>>16&255]^o[d>>8&255]^n[L&255]^f[H+3],y=e,d=r,L=t,R=s,H=H+4;e=E[y>>>24]<<24^E[d>>16&255]<<16^E[L>>8&255]<<8^E[R&255]^f[H],r=E[d>>>24]<<24^E[L>>16&255]<<16^E[R>>8&255]<<8^E[y&255]^f[H+1],t=E[L>>>24]<<24^E[R>>16&255]<<16^E[y>>8&255]<<8^E[d&255]^f[H+2],s=E[R>>>24]<<24^E[y>>16&255]<<16^E[d>>8&255]<<8^E[L&255]^f[H+3],m[S]=Y(e^l),m[S+1]=Y(s^i),m[S+2]=Y(t^u),m[S+3]=Y(r^g),l=I,i=k,u=F,g=K,S=S+4}return m.buffer},P}()},"./src/crypt/decrypter.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>S});var C=_("./src/crypt/aes-crypto.ts"),D=_("./src/crypt/fast-aes-key.ts"),M=_("./src/crypt/aes-decryptor.ts"),P=_("./src/utils/logger.ts"),B=_("./src/utils/mp4-tools.ts"),b=_("./src/utils/typed-array.ts"),A=16,S=function(){function T(f,E){var p=E===void 0?{}:E,h=p.removePKCS7Padding,a=h===void 0?!0:h;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 o=self.crypto;o&&(this.subtle=o.subtle||o.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var x=T.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 E=this.currentResult,p=this.remainderData;if(!E||p)return P.logger.error("[softwareDecrypt] "+(p?"overflow bytes: "+p.byteLength:"no result")),this.reset(),null;var h=new Uint8Array(E);return this.reset(),this.removePKCS7Padding?(0,M.removePadding)(h):h},x.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},x.decrypt=function(E,p,h){var a=this;return this.useSoftware?new Promise(function(o,n){a.softwareDecrypt(new Uint8Array(E),p,h);var v=a.flush();v?o(v.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(E),p,h)},x.softwareDecrypt=function(E,p,h){var a=this.currentIV,o=this.currentResult,n=this.remainderData;this.logOnce("JS AES decrypt"),n&&(E=(0,B.appendUint8Array)(n,E),this.remainderData=null);var v=this.getValidChunk(E);if(!v.length)return null;a&&(h=a);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new M.default),l.expandKey(p);var i=o;return this.currentResult=l.decrypt(v.buffer,0,h),this.currentIV=(0,b.sliceUint8)(v,-16).buffer,i||null},x.webCryptoDecrypt=function(E,p,h){var a=this,o=this.subtle;return(this.key!==p||!this.fastAesKey)&&(this.key=p,this.fastAesKey=new D.default(o,p)),this.fastAesKey.expandKey().then(function(n){if(!o)return Promise.reject(new Error("web crypto not initialized"));a.logOnce("WebCrypto AES decrypt");var v=new C.default(o,new Uint8Array(h));return v.decrypt(E.buffer,n)}).catch(function(n){return P.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),a.onWebCryptoError(E,p,h)})},x.onWebCryptoError=function(E,p,h){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(E,p,h);var a=this.flush();if(a)return a.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},x.getValidChunk=function(E){var p=E,h=E.length-E.length%A;return h!==E.length&&(p=(0,b.sliceUint8)(E,0,h),this.remainderData=(0,b.sliceUint8)(E,h)),p},x.logOnce=function(E){!this.logEnabled||(P.logger.log("[decrypter]: "+E),this.logEnabled=!1)},T}()},"./src/crypt/fast-aes-key.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>C});var C=function(){function D(P,B){this.subtle=void 0,this.key=void 0,this.subtle=P,this.key=B}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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>S});var C=_("./src/demux/base-audio-demuxer.ts"),D=_("./src/demux/adts.ts"),M=_("./src/utils/logger.ts"),P=_("./src/demux/id3.ts");function B(T,x){T.prototype=Object.create(x.prototype),T.prototype.constructor=T,b(T,x)}function b(T,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,p){return E.__proto__=p,E},b(T,x)}var A=function(T){B(x,T);function x(E,p){var h;return h=T.call(this)||this,h.observer=void 0,h.config=void 0,h.observer=E,h.config=p,h}var f=x.prototype;return f.resetInitSegment=function(p,h,a,o){T.prototype.resetInitSegment.call(this,p,h,a,o),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:h,duration:o,inputTimeScale:9e4,dropped:0}},x.probe=function(p){if(!p)return!1;for(var h=P.getID3Data(p,0)||[],a=h.length,o=p.length;a<o;a++)if(D.probe(p,a))return M.logger.log("ADTS sync word found !"),!0;return!1},f.canParse=function(p,h){return D.canParse(p,h)},f.appendFrame=function(p,h,a){D.initTrackConfig(p,this.observer,h,a,p.manifestCodec);var o=D.appendFrame(p,h,a,this.basePTS,this.frameIndex);if(o&&o.missing===0)return o},x}(C.default);let S=A},"./src/demux/adts.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{appendFrame:()=>a,canGetFrameLength:()=>S,canParse:()=>x,getAudioConfig:()=>P,getFrameDuration:()=>p,getFullFrameLength:()=>A,getHeaderLength:()=>b,initTrackConfig:()=>E,isHeader:()=>T,isHeaderPattern:()=>B,parseFrameHeader:()=>h,probe:()=>f});var C=_("./src/utils/logger.ts"),D=_("./src/errors.ts"),M=_("./src/events.ts");function P(o,n,v,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[v+2]&192)>>>6)+1;var t=(n[v+2]&60)>>>2;if(t>r.length-1){o.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[v+2]&1)<<2,g|=(n[v+3]&192)>>>6,C.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 B(o,n){return o[n]===255&&(o[n+1]&246)===240}function b(o,n){return o[n+1]&1?7:9}function A(o,n){return(o[n+3]&3)<<11|o[n+4]<<3|(o[n+5]&224)>>>5}function S(o,n){return n+5<o.length}function T(o,n){return n+1<o.length&&B(o,n)}function x(o,n){return S(o,n)&&B(o,n)&&A(o,n)<=o.length-n}function f(o,n){if(T(o,n)){var v=b(o,n);if(n+v>=o.length)return!1;var l=A(o,n);if(l<=v)return!1;var i=n+l;return i===o.length||T(o,i)}return!1}function E(o,n,v,l,i){if(!o.samplerate){var u=P(n,v,l,i);if(!u)return;o.config=u.config,o.samplerate=u.samplerate,o.channelCount=u.channelCount,o.codec=u.codec,o.manifestCodec=u.manifestCodec,C.logger.log("parsed codec:"+o.codec+", rate:"+u.samplerate+", channels:"+u.channelCount)}}function p(o){return 9216e4/o}function h(o,n){var v=b(o,n);if(n+v<=o.length){var l=A(o,n)-v;if(l>0)return{headerLength:v,frameLength:l}}}function a(o,n,v,l,i){var u=p(o.samplerate),g=l+i*u,c=h(n,v),m;if(c){var e=c.frameLength,r=c.headerLength,t=r+e,s=Math.max(0,v+t-n.length);s?(m=new Uint8Array(t-r),m.set(n.subarray(v+r,n.length),0)):m=n.subarray(v+r,v+t);var y={unit:m,pts:g};return s||o.samples.push(y),{sample:y,length:t,missing:s}}var d=n.length-v;m=new Uint8Array(d),m.set(n.subarray(v,n.length),0);var L={unit:m,pts:g};return{sample:L,length:d,missing:-1}}},"./src/demux/base-audio-demuxer.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>T,initPTSFn:()=>S});var C=_("./src/polyfills/number.ts"),D=_("./src/demux/id3.ts"),M=_("./src/types/demuxer.ts"),P=_("./src/demux/dummy-demuxed-track.ts"),B=_("./src/utils/mp4-tools.ts"),b=_("./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,h,a,o){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,h){return!1},f.appendFrame=function(p,h,a){},f.demux=function(p,h){this.cachedData&&(p=(0,B.appendUint8Array)(this.cachedData,p),this.cachedData=null);var a=D.getID3Data(p,0),o=a?a.length:0,n,v=this._audioTrack,l=this._id3Track,i=a?D.getTimeStamp(a):void 0,u=p.length;for((this.basePTS===null||this.frameIndex===0&&(0,C.isFiniteNumber)(i))&&(this.basePTS=S(i,h,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});o<u;){if(this.canParse(p,o)){var g=this.appendFrame(v,p,o);g?(this.frameIndex++,this.lastPTS=g.sample.pts,o+=g.length,n=o):o=u}else D.canParse(p,o)?(a=D.getID3Data(p,o),l.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:M.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),o+=a.length,n=o):o++;if(o===u&&n!==u){var c=(0,b.sliceUint8)(p,n);this.cachedData?this.cachedData=(0,B.appendUint8Array)(this.cachedData,c):this.cachedData=c}}return{audioTrack:v,videoTrack:(0,P.dummyTrack)(),id3Track:l,textTrack:(0,P.dummyTrack)()}},f.demuxSampleAes=function(p,h,a){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},f.flush=function(p){var h=this.cachedData;return h&&(this.cachedData=null,this.demux(h,0)),{audioTrack:this._audioTrack,videoTrack:(0,P.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,P.dummyTrack)()}},f.destroy=function(){},x}(),S=function(f,E,p){return(0,C.isFiniteNumber)(f)?f*90:E*9e4+(p||0)};let T=A},"./src/demux/chunk-cache.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>C});var C=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 B=new Uint8Array(P),b=0,A=0;A<M.length;A++){var S=M[A];B.set(S,b),b+=S.length}return B}},"./src/demux/dummy-demuxed-track.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{dummyTrack:()=>C});function C(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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>M});var C=_("./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 B=P.prototype;return B.loadWord=function(){var A=this.data,S=this.bytesAvailable,T=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(T,T+f)),this.word=new DataView(x.buffer).getUint32(0),this.bitsAvailable=f*8,this.bytesAvailable-=f},B.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)},B.readBits=function(A){var S=Math.min(this.bitsAvailable,A),T=this.word>>>32-S;if(A>32&&C.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?T<<S|this.readBits(S):T},B.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()},B.skipUEG=function(){this.skipBits(1+this.skipLZ())},B.skipEG=function(){this.skipBits(1+this.skipLZ())},B.readUEG=function(){var A=this.skipLZ();return this.readBits(A+1)-1},B.readEG=function(){var A=this.readUEG();return 1&A?1+A>>>1:-1*(A>>>1)},B.readBoolean=function(){return this.readBits(1)===1},B.readUByte=function(){return this.readBits(8)},B.readUShort=function(){return this.readBits(16)},B.readUInt=function(){return this.readBits(32)},B.skipScalingList=function(A){for(var S=8,T=8,x,f=0;f<A;f++)T!==0&&(x=this.readEG(),T=(S+x+256)%256),S=T===0?S:T},B.readSPS=function(){var A=0,S=0,T=0,x=0,f,E,p,h=this.readUByte.bind(this),a=this.readBits.bind(this),o=this.readUEG.bind(this),n=this.readBoolean.bind(this),v=this.skipBits.bind(this),l=this.skipEG.bind(this),i=this.skipUEG.bind(this),u=this.skipScalingList.bind(this);h();var g=h();if(a(5),v(3),h(),i(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){var c=o();if(c===3&&v(1),i(),i(),v(1),n())for(E=c!==3?8:12,p=0;p<E;p++)n()&&(p<6?u(16):u(64))}i();var m=o();if(m===0)o();else if(m===1)for(v(1),l(),l(),f=o(),p=0;p<f;p++)l();i(),v(1);var e=o(),r=o(),t=a(1);t===0&&v(1),v(1),n()&&(A=o(),S=o(),T=o(),x=o());var s=[1,1];if(n()&&n()){var y=h();switch(y){case 1:s=[1,1];break;case 2:s=[12,11];break;case 3:s=[10,11];break;case 4:s=[16,11];break;case 5:s=[40,33];break;case 6:s=[24,11];break;case 7:s=[20,11];break;case 8:s=[32,11];break;case 9:s=[80,33];break;case 10:s=[18,11];break;case 11:s=[15,11];break;case 12:s=[64,33];break;case 13:s=[160,99];break;case 14:s=[4,3];break;case 15:s=[3,2];break;case 16:s=[2,1];break;case 255:{s=[h()<<8|h(),h()<<8|h()];break}}}return{width:Math.ceil((e+1)*16-A*2-S*2),height:(2-t)*(r+1)*16-(t?2:4)*(T+x),pixelRatio:s}},B.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},P}();let M=D},"./src/demux/id3.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{canParse:()=>B,decodeFrame:()=>x,getID3Data:()=>M,getID3Frames:()=>T,getTimeStamp:()=>b,isFooter:()=>D,isHeader:()=>C,isTimeStampFrame:()=>A,testables:()=>o,utf8ArrayToStr:()=>a});var C=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;C(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},B=function(i,u){return C(i,u)&&P(i,u+6)+10<=i.length-u},b=function(i){for(var u=T(i),g=0;g<u.length;g++){var c=u[g];if(A(c))return h(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)}},T=function(i){for(var u=0,g=[];C(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):E(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}}},E=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}},h=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=v();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,s,y="",d=0;d<e;){if(r=i[d++],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[d++],y+=String.fromCharCode((r&31)<<6|t&63);break;case 14:t=i[d++],s=i[d++],y+=String.fromCharCode((r&15)<<12|(t&63)<<6|(s&63)<<0);break;default:}}return y},o={decodeTextFrame:E},n;function v(){return!n&&typeof self.TextDecoder!="undefined"&&(n=new self.TextDecoder("utf-8")),n}},"./src/demux/mp3demuxer.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>S});var C=_("./src/demux/base-audio-demuxer.ts"),D=_("./src/demux/id3.ts"),M=_("./src/utils/logger.ts"),P=_("./src/demux/mpegaudio.ts");function B(T,x){T.prototype=Object.create(x.prototype),T.prototype.constructor=T,b(T,x)}function b(T,x){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(E,p){return E.__proto__=p,E},b(T,x)}var A=function(T){B(x,T);function x(){return T.apply(this,arguments)||this}var f=x.prototype;return f.resetInitSegment=function(p,h,a,o){T.prototype.resetInitSegment.call(this,p,h,a,o),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:h,duration:o,inputTimeScale:9e4,dropped:0}},x.probe=function(p){if(!p)return!1;for(var h=D.getID3Data(p,0)||[],a=h.length,o=p.length;a<o;a++)if(P.probe(p,a))return M.logger.log("MPEG Audio sync word found !"),!0;return!1},f.canParse=function(p,h){return P.canParse(p,h)},f.appendFrame=function(p,h,a){if(this.basePTS!==null)return P.appendFrame(p,h,a,this.basePTS,this.frameIndex)},x}(C.default);let S=A},"./src/demux/mp4demuxer.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>A});var C=_("./src/polyfills/number.ts"),D=_("./src/types/demuxer.ts"),M=_("./src/utils/mp4-tools.ts"),P=_("./src/demux/dummy-demuxed-track.ts"),B=/\/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 T=S.prototype;return T.resetTimeStamp=function(){},T.resetInitSegment=function(f,E,p,h){var a=this.videoTrack=(0,P.dummyTrack)("video",1),o=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 v=(0,M.parseInitSegment)(f);if(v.video){var l=v.video,i=l.id,u=l.timescale,g=l.codec;a.id=i,a.timescale=n.timescale=u,a.codec=g}if(v.audio){var c=v.audio,m=c.id,e=c.timescale,r=c.codec;o.id=m,o.timescale=e,o.codec=r}n.id=M.RemuxerTrackIdConfig.text,a.sampleDuration=0,a.duration=o.duration=h}},T.resetContiguity=function(){},S.probe=function(f){return f=f.length>16384?f.subarray(0,16384):f,(0,M.findBox)(f,["moof"]).length>0},T.demux=function(f,E){this.timeOffset=E;var p=f,h=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(p=(0,M.appendUint8Array)(this.remainderData,f));var o=(0,M.segmentValidRange)(p);this.remainderData=o.remainder,h.samples=o.valid||new Uint8Array}else h.samples=p;var n=this.extractID3Track(h,E);return a.samples=(0,M.parseSamples)(E,h),{videoTrack:h,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}},T.flush=function(){var f=this.timeOffset,E=this.videoTrack,p=this.txtTrack;E.samples=this.remainderData||new Uint8Array,this.remainderData=null;var h=this.extractID3Track(E,this.timeOffset);return p.samples=(0,M.parseSamples)(f,E),{videoTrack:E,audioTrack:(0,P.dummyTrack)(),id3Track:h,textTrack:(0,P.dummyTrack)()}},T.extractID3Track=function(f,E){var p=this.id3Track;if(f.samples.length){var h=(0,M.findBox)(f.samples,["emsg"]);h&&h.forEach(function(a){var o=(0,M.parseEmsg)(a);if(B.test(o.schemeIdUri)){var n=(0,C.isFiniteNumber)(o.presentationTime)?o.presentationTime/o.timeScale:E+o.presentationTimeDelta/o.timeScale,v=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;v<=.001&&(v=Number.POSITIVE_INFINITY);var l=o.payload;p.samples.push({data:l,len:l.byteLength,dts:n,pts:n,type:D.MetadataSchema.emsg,duration:v})}})}return p},T.demuxSampleAes=function(f,E,p){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},T.destroy=function(){},S}();let A=b},"./src/demux/mpegaudio.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{appendFrame:()=>b,canParse:()=>x,isHeader:()=>T,isHeaderPattern:()=>S,parseHeader:()=>A,probe:()=>f});var C=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]],B=[0,1,1,4];function b(E,p,h,a,o){if(!(h+24>p.length)){var n=A(p,h);if(n&&h+n.frameLength<=p.length){var v=n.samplesPerFrame*9e4/n.sampleRate,l=a+o*v,i={unit:p.subarray(h,h+n.frameLength),pts:l,dts:l};return E.config=[],E.channelCount=n.channelCount,E.samplerate=n.sampleRate,E.samples.push(i),{sample:i,length:n.frameLength,missing:0}}}}function A(E,p){var h=E[p+1]>>3&3,a=E[p+1]>>1&3,o=E[p+2]>>4&15,n=E[p+2]>>2&3;if(h!==1&&o!==0&&o!==15&&n!==3){var v=E[p+2]>>1&1,l=E[p+3]>>6,i=h===3?3-a:a===3?3:4,u=D[i*14+o-1]*1e3,g=h===3?0:h===2?1:2,c=M[g*3+n],m=l===3?1:2,e=P[h][a],r=B[a],t=e*8*r,s=Math.floor(e*u/c+v)*r;if(C===null){var y=navigator.userAgent||"",d=y.match(/Chrome\/(\d+)/i);C=d?parseInt(d[1]):0}var L=!!C&&C<=87;return L&&a===2&&u>=224e3&&l===0&&(E[p+3]=E[p+3]|128),{sampleRate:c,channelCount:m,frameLength:s,samplesPerFrame:t}}}function S(E,p){return E[p]===255&&(E[p+1]&224)===224&&(E[p+1]&6)!==0}function T(E,p){return p+1<E.length&&S(E,p)}function x(E,p){var h=4;return S(E,p)&&h<=E.length-p}function f(E,p){if(p+1<E.length&&S(E,p)){var h=4,a=A(E,p),o=h;a!=null&&a.frameLength&&(o=a.frameLength);var n=p+o;return n===E.length||T(E,n)}return!1}},"./src/demux/sample-aes.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>P});var C=_("./src/crypt/decrypter.ts"),D=_("./src/utils/mp4-tools.ts"),M=function(){function B(A,S,T){this.keyData=void 0,this.decrypter=void 0,this.keyData=T,this.decrypter=new C.default(S,{removePKCS7Padding:!1})}var b=B.prototype;return b.decryptBuffer=function(S){return this.decrypter.decrypt(S,this.keyData.key.buffer,this.keyData.iv.buffer)},b.decryptAacSample=function(S,T,x){var f=this,E=S[T].unit;if(!(E.length<=16)){var p=E.subarray(16,E.length-E.length%16),h=p.buffer.slice(p.byteOffset,p.byteOffset+p.length);this.decryptBuffer(h).then(function(a){var o=new Uint8Array(a);E.set(o,16),f.decrypter.isSync()||f.decryptAacSamples(S,T+1,x)})}},b.decryptAacSamples=function(S,T,x){for(;;T++){if(T>=S.length){x();return}if(!(S[T].unit.length<32)&&(this.decryptAacSample(S,T,x),!this.decrypter.isSync()))return}},b.getAvcEncryptedData=function(S){for(var T=Math.floor((S.length-48)/160)*16+16,x=new Int8Array(T),f=0,E=32;E<S.length-16;E+=160,f+=16)x.set(S.subarray(E,E+16),f);return x},b.getAvcDecryptedUnit=function(S,T){for(var x=new Uint8Array(T),f=0,E=32;E<S.length-16;E+=160,f+=16)S.set(x.subarray(f,f+16),E);return S},b.decryptAvcSample=function(S,T,x,f,E){var p=this,h=(0,D.discardEPB)(E.data),a=this.getAvcEncryptedData(h);this.decryptBuffer(a.buffer).then(function(o){E.data=p.getAvcDecryptedUnit(h,o),p.decrypter.isSync()||p.decryptAvcSamples(S,T,x+1,f)})},b.decryptAvcSamples=function(S,T,x,f){if(S instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;T++,x=0){if(T>=S.length){f();return}for(var E=S[T].units;!(x>=E.length);x++){var p=E[x];if(!(p.data.length<=48||p.type!==1&&p.type!==5)&&(this.decryptAvcSample(S,T,x,f,p),!this.decrypter.isSync()))return}}},B}();let P=M},"./src/demux/transmuxer-interface.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>x});var C=_("./src/demux/webworkify-webpack.js"),D=_("./src/events.ts"),M=_("./src/demux/transmuxer.ts"),P=_("./src/utils/logger.ts"),B=_("./src/errors.ts"),b=_("./src/utils/mediasource-helper.ts"),A=_("./node_modules/eventemitter3/index.js"),S=_.n(A),T=(0,b.getMediaSource)()||{isTypeSupported:function(){return!1}},x=function(){function f(p,h,a,o){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 v=p.config;this.hls=p,this.id=h,this.useWorker=!!v.enableWorker,this.onTransmuxComplete=a,this.onFlush=o;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:T.isTypeSupported("video/mp4"),mpeg:T.isTypeSupported("audio/mpeg"),mp3:T.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,C.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:B.ErrorTypes.OTHER_ERROR,details:B.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:h,config:JSON.stringify(v)})}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,v,u,h),this.worker=null}}else this.transmuxer=new M.default(this.observer,i,v,u,h)}var E=f.prototype;return E.destroy=function(){var h=this.worker;if(h)h.removeEventListener("message",this.onwmsg),h.terminate(),this.worker=null,this.onwmsg=void 0;else{var a=this.transmuxer;a&&(a.destroy(),this.transmuxer=null)}var o=this.observer;o&&o.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},E.push=function(h,a,o,n,v,l,i,u,g,c){var m,e,r=this;g.transmuxing.start=self.performance.now();var t=this.transmuxer,s=this.worker,y=l?l.start:v.start,d=v.decryptdata,L=this.frag,R=!(L&&v.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,K=k===0&&g.id>1&&g.id===(L==null?void 0:L.stats.chunkCount),H=!I&&(k===1||k===0&&(F===1||K&&F<=0)),j=self.performance.now();(I||k||v.stats.parsing.start===0)&&(v.stats.parsing.start=j),l&&(F||!H)&&(l.stats.parsing.start=j);var Y=!(L&&((m=v.initSegment)===null||m===void 0?void 0:m.url)===((e=L.initSegment)===null||e===void 0?void 0:e.url)),J=new M.TransmuxState(R,H,u,I,y,Y);if(!H||R||Y){P.logger.log("[transmuxer-interface, "+v.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 te=new M.TransmuxConfig(o,n,a,i,c);this.configureTransmuxer(te)}if(this.frag=v,this.part=l,s)s.postMessage({cmd:"demux",data:h,decryptdata:d,chunkMeta:g,state:J},h instanceof ArrayBuffer?[h]:[]);else if(t){var ae=t.push(h,d,g,J);(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))}},E.flush=function(h){var a=this;h.transmuxing.start=self.performance.now();var o=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:h});else if(o){var v=o.flush(h),l=(0,M.isPromise)(v);l||o.async?((0,M.isPromise)(v)||(v=Promise.resolve(v)),v.then(function(i){a.handleFlushResult(i,h)}).catch(function(i){a.transmuxerError(i,h,"transmuxer-interface flush error")})):this.handleFlushResult(v,h)}},E.transmuxerError=function(h,a,o){!this.hls||this.hls.trigger(D.Events.ERROR,{type:B.ErrorTypes.MEDIA_ERROR,details:B.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:a,fatal:!1,error:h,err:h,reason:o})},E.handleFlushResult=function(h,a){var o=this;h.forEach(function(n){o.handleTransmuxComplete(n)}),this.onFlush(a)},E.onWorkerMessage=function(h){var a=h.data,o=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,o.trigger(a.event,a.data);break}}},E.configureTransmuxer=function(h){var a=this.worker,o=this.transmuxer;a?a.postMessage({cmd:"configure",config:h}):o&&o.configure(h)},E.handleTransmuxComplete=function(h){h.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(h)},f}()},"./src/demux/transmuxer-worker.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>A});var C=_("./src/demux/transmuxer.ts"),D=_("./src/events.ts"),M=_("./src/utils/logger.ts"),P=_("./node_modules/eventemitter3/index.js"),B=_.n(P),b=_("./src/errors.ts");function A(E){var p=new P.EventEmitter,h=function(n,v){E.postMessage({event:n,data:v})};p.on(D.Events.FRAG_DECRYPTED,h),p.on(D.Events.ERROR,h);var a=function(){var n=function(i){var u=function(c){h("workerLog",{logType:i,message:c})};M.logger[i]=u};for(var v in M.logger)n(v)};E.addEventListener("message",function(o){var n=o.data;switch(n.cmd){case"init":{var v=JSON.parse(n.config);E.transmuxer=new C.default(p,n.typeSupported,v,n.vendor,n.id),(0,M.enableLogs)(v.debug,n.id),a(),h("init",null);break}case"configure":{E.transmuxer.configure(n.config);break}case"demux":{var l=E.transmuxer.push(n.data,n.decryptdata,n.chunkMeta,n.state);(0,C.isPromise)(l)?(E.transmuxer.async=!0,l.then(function(c){S(E,c)}).catch(function(c){h(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"})})):(E.transmuxer.async=!1,S(E,l));break}case"flush":{var i=n.chunkMeta,u=E.transmuxer.flush(i),g=(0,C.isPromise)(u);g||E.transmuxer.async?((0,C.isPromise)(u)||(u=Promise.resolve(u)),u.then(function(c){x(E,c,i)}).catch(function(c){h(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(E,u,i);break}default:break}})}function S(E,p){if(f(p.remuxResult))return!1;var h=[],a=p.remuxResult,o=a.audio,n=a.video;return o&&T(h,o),n&&T(h,n),E.postMessage({event:"transmuxComplete",data:p},h),!0}function T(E,p){p.data1&&E.push(p.data1.buffer),p.data2&&E.push(p.data2.buffer)}function x(E,p,h){var a=p.reduce(function(o,n){return S(E,n)||o},!1);a||E.postMessage({event:"transmuxComplete",data:p[0]}),E.postMessage({event:"flush",data:h})}function f(E){return!E.audio&&!E.video&&!E.text&&!E.id3&&!E.initSegment}},"./src/demux/transmuxer.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{TransmuxConfig:()=>n,TransmuxState:()=>v,default:()=>p,isPromise:()=>o});var C=_("./src/events.ts"),D=_("./src/errors.ts"),M=_("./src/crypt/decrypter.ts"),P=_("./src/demux/aacdemuxer.ts"),B=_("./src/demux/mp4demuxer.ts"),b=_("./src/demux/tsdemuxer.ts"),A=_("./src/demux/mp3demuxer.ts"),S=_("./src/remux/mp4-remuxer.ts"),T=_("./src/remux/passthrough-remuxer.ts"),x=_("./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 E=[{demux:B.default,remux:T.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 s=new Uint8Array(g),y=this.currentTransmuxState,d=this.transmuxConfig;e&&(this.currentTransmuxState=e);var L=e||y,R=L.contiguous,I=L.discontinuity,k=L.trackSwitch,F=L.accurateTimeOffset,K=L.timeOffset,H=L.initSegmentChange,j=d.audioCodec,Y=d.videoCodec,J=d.defaultInitPts,te=d.duration,ae=d.initSegmentData,re=h(s,c);if(re&&re.method==="AES-128"){var se=this.getDecrypter();if(se.isSync()){var ue=se.softwareDecrypt(s,re.key.buffer,re.iv.buffer);if(!ue)return t.executeEnd=f(),a(m);s=new Uint8Array(ue)}else return this.decryptionPromise=se.webCryptoDecrypt(s,re.key.buffer,re.iv.buffer).then(function(fe){var Se=r.push(fe,null,m);return r.decryptionPromise=null,Se}),this.decryptionPromise}var ce=this.needsProbing(I,k);ce&&this.configureTransmuxer(s),(I||k||H||ce)&&this.resetInitSegment(ae,j,Y,te,c),(I||H||ce)&&this.resetInitialTimestamp(J),R||this.resetContiguity();var le=this.transmux(s,re,K,F,m),de=this.currentTransmuxState;return de.contiguous=!0,de.discontinuity=!1,de.trackSwitch=!1,t.executeEnd=f(),le},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 s=[],y=r.timeOffset;if(e){var d=e.flush();d&&s.push(this.push(d,null,g))}var L=this.demuxer,R=this.remuxer;if(!L||!R)return this.observer.emit(C.Events.ERROR,C.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 o(I)?I.then(function(k){return c.flushRemux(s,k,g),s}):(this.flushRemux(s,I,g),s)},i.flushRemux=function(g,c,m){var e=c.audioTrack,r=c.videoTrack,t=c.id3Track,s=c.textTrack,y=this.currentTransmuxState,d=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,s,L,d,!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,s=this.remuxer;!t||!s||(t.resetInitSegment(g,c,m,e),s.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,s=r.videoTrack,y=r.id3Track,d=r.textTrack,L=this.remuxer.remux(t,s,y,d,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(s){var y=t.remuxer.remux(s.audioTrack,s.videoTrack,s.id3Track,s.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,s=0,y=E.length;s<y;s++)if(E[s].demux.probe(g)){t=E[s];break}t||(x.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),t={demux:B.default,remux:T.default});var d=this.demuxer,L=this.remuxer,R=t.remux,I=t.demux;(!L||!(L instanceof R))&&(this.remuxer=new R(m,c,e,r)),(!d||!(d 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 h(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 o(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},v=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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>v});var C=_("./src/demux/adts.ts"),D=_("./src/demux/mpegaudio.ts"),M=_("./src/demux/exp-golomb.ts"),P=_("./src/demux/sample-aes.ts"),B=_("./src/events.ts"),b=_("./src/utils/mp4-tools.ts"),A=_("./src/utils/logger.ts"),S=_("./src/errors.ts"),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,E=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,s=this._audioTrack,y=this._id3Track,d=this._txtTrack,L=t.pid,R=t.pesData,I=s.pid,k=y.pid,F=s.pesData,K=y.pesData,H=null,j=this.pmtParsed,Y=this._pmtId,J=g.length;if(this.remainderData&&(g=(0,b.appendUint8Array)(this.remainderData,g),J=g.length,this.remainderData=null),J<f&&!e)return this.remainderData=g,{audioTrack:s,videoTrack:t,id3Track:y,textTrack:d};var te=Math.max(0,l.syncOffset(g));J-=(J-te)%f,J<g.byteLength&&!e&&(this.remainderData=new Uint8Array(g.buffer,J,g.buffer.byteLength-J));for(var ae=0,re=te;re<J;re+=f)if(g[re]===71){var se=!!(g[re+1]&64),ue=((g[re+1]&31)<<8)+g[re+2],ce=(g[re+3]&48)>>4,le=void 0;if(ce>1){if(le=re+5+g[re+4],le===re+f)continue}else le=re+4;switch(ue){case L:se&&(R&&(r=o(R))&&this.parseAVCPES(t,d,r,!1),R={data:[],size:0}),R&&(R.data.push(g.subarray(le,re+f)),R.size+=re+f-le);break;case I:if(se){if(F&&(r=o(F)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,r);break;case"mp3":this.parseMPEGPES(s,r);break}F={data:[],size:0}}F&&(F.data.push(g.subarray(le,re+f)),F.size+=re+f-le);break;case k:se&&(K&&(r=o(K))&&this.parseID3PES(y,r),K={data:[],size:0}),K&&(K.data.push(g.subarray(le,re+f)),K.size+=re+f-le);break;case 0:se&&(le+=g[le]+1),Y=this._pmtId=h(g,le);break;case Y:{se&&(le+=g[le]+1);var de=a(g,le,this.typeSupported,m);L=de.avc,L>0&&(t.pid=L),I=de.audio,I>0&&(s.pid=I,s.segmentCodec=de.segmentCodec),k=de.id3,k>0&&(y.pid=k),H!==null&&!j&&(A.logger.log("unknown PID '"+H+"' in TS found"),H=null,re=te-188),j=this.pmtParsed=!0;break}case 17:case 8191:break;default:H=ue;break}}else ae++;ae>0&&this.observer.emit(B.Events.ERROR,B.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,s.pesData=F,y.pesData=K;var fe={audioTrack:s,videoTrack:t,id3Track:y,textTrack:d};return e&&this.extractRemainingSamples(fe),fe},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,s=c.pesData,y=e.pesData,d;if(t&&(d=o(t))?(this.parseAVCPES(m,r,d,!0),m.pesData=null):m.pesData=t,s&&(d=o(s))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,d);break;case"mp3":this.parseMPEGPES(c,d);break}c.pesData=null}else s!=null&&s.size&&A.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=s;y&&(d=o(y))?(this.parseID3PES(e,d),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),s=!1,y=this.avcSample,d,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:{d=!0,y||(y=r.avcSample=p(!0,m.pts,m.dts,"")),s&&(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:d=!0,y||(y=r.avcSample=p(!0,m.pts,m.dts,"")),s&&(y.debug+="IDR "),y.key=!0,y.frame=!0;break;case 6:{d=!0,s&&y&&(y.debug+="SEI "),(0,b.parseSEIMessageFromNALu)(R.data,1,m.pts,c.samples);break}case 7:if(d=!0,L=!0,s&&y&&(y.debug+="SPS "),!g.sps){var F=new M.default(R.data),K=F.readSPS();g.width=K.width,g.height=K.height,g.pixelRatio=K.pixelRatio,g.sps=[R.data],g.duration=r._duration;for(var H=R.data.subarray(1,4),j="avc1.",Y=0;Y<3;Y++){var J=H[Y].toString(16);J.length<2&&(J="0"+J),j+=J}g.codec=j}break;case 8:d=!0,s&&y&&(y.debug+="PPS "),g.pps||(g.pps=[R.data]);break;case 9:d=!1,g.audFound=!0,y&&n(y,g),y=r.avcSample=p(!1,m.pts,m.dts,s?"AUD ":"");break;case 12:d=!0;break;default:d=!1,y&&(y.debug+="unknown NAL "+R.type+" ");break}if(y&&d){var te=y.units;te.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=[],s=0,y,d,L,R=-1,I=0;for(e===-1&&(R=0,I=c[0]&31,e=0,s=1);s<m;){if(y=c[s++],!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,s-e-1),type:I};t.push(k)}else{var F=this.getLastNalUnit(g.samples);if(F&&(r&&s<=4-r&&F.state&&(F.data=F.data.subarray(0,F.data.byteLength-r)),d=s-e-1,d>0)){var K=new Uint8Array(F.data.byteLength+d);K.set(F.data,0),K.set(c.subarray(0,d),F.data.byteLength),F.data=K,F.state=0}}s<m?(L=c[s]&31,R=s,I=L,e=0):e=-1}else e=0}if(R>=0&&e>=0){var H={data:c.subarray(R,m),type:I,state:e};t.push(H)}if(t.length===0){var j=this.getLastNalUnit(g.samples);if(j){var Y=new Uint8Array(j.data.byteLength+c.byteLength);Y.set(j.data,0),Y.set(c,j.data.byteLength),j.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,s=e.sample.unit.byteLength;if(t===-1){var y=new Uint8Array(s+r.byteLength);y.set(e.sample.unit,0),y.set(r,s),r=y}else{var d=s-t;e.sample.unit.set(r.subarray(0,t),d),g.samples.push(e.sample),m=e.missing}}var L,R;for(L=m,R=r.length;L<R-1&&!C.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(B.Events.ERROR,B.Events.ERROR,{type:S.ErrorTypes.MEDIA_ERROR,details:S.ErrorDetails.FRAG_PARSING_ERROR,fatal:k,reason:I}),k)return}C.initTrackConfig(g,this.observer,r,L,this.audioCodec);var F;if(c.pts!==void 0)F=c.pts;else if(e){var K=C.getFrameDuration(g.samplerate);F=e.sample.pts+K}else{A.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var H=0,j;L<R;)if(j=C.appendFrame(g,r,L,F,H),L+=j.length,j.missing){this.aacOverFlow=j;break}else for(H++;L<R-1&&!C.isHeader(r,L);L++);},i.parseMPEGPES=function(g,c){var m=c.data,e=m.length,r=0,t=0,s=c.pts;if(s===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,s,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?T.MetadataSchema.emsg:T.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 h(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 o(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 s=(u[0]<<16)+(u[1]<<8)+u[2];if(s===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 d=c+9;if(l.size<=d)return null;l.size-=d;for(var L=new Uint8Array(l.size),R=0,I=r.length;R<I;R++){u=r[R];var k=u.byteLength;if(d)if(d>k){d-=k;continue}else u=u.subarray(d),k-=d,d=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 v=E},"./src/demux/webworkify-webpack.js":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>f});var C=function(){var p=ENTRY_MODULE,h={},a=function n(v){var l=h[v];if(l!==void 0)return l.exports;var i=h[v]={exports:{}};return p[v].call(i.exports,i,i.exports,n),i.exports};a.m=p,function(){a.n=function(n){var v=n&&n.__esModule?function(){return n.default}:function(){return n};return a.d(v,{a:v}),v}}(),function(){a.d=function(n,v){for(var l in v)a.o(v,l)&&!a.o(n,l)&&Object.defineProperty(n,l,{enumerable:!0,get:v[l]})}}(),function(){a.o=function(n,v){return Object.prototype.hasOwnProperty.call(n,v)}}(),function(){a.r=function(n){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}}();var o=a(ENTRY_MODULE);return o.default||o},D=C.toString().split("ENTRY_MODULE"),M="[\\.|\\-|\\+|\\w|/|@]+",P="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+M+").*?\\)";function B(E){return(E+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function b(E){return!isNaN(1*E)}function A(E,p,h){var a={};a[h]=[];var o=p.toString().replace(/^"[^"]+"/,"function"),n=o.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||o.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!n)return a;for(var v=n[1],l=new RegExp("(\\\\n|\\W)"+B(v)+P,"g"),i;i=l.exec(o);)i[3]!=="dll-reference"&&a[h].push(i[3]);for(l=new RegExp("\\("+B(v)+'\\("(dll-reference\\s('+M+'))"\\)\\)'+P,"g");i=l.exec(o);)E[i[2]]||(a[h].push(i[1]),E[i[2]]=_(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(E){var p=Object.keys(E);return p.reduce(function(h,a){return h||E[a].length>0},!1)}function T(E,p){for(var h={main:[p]},a={main:[]},o={main:{}};S(h);)for(var n=Object.keys(h),v=0;v<n.length;v++){var l=n[v],i=h[l],u=i.pop();if(o[l]=o[l]||{},!(o[l][u]||!E[l][u])){o[l][u]=!0,a[l]=a[l]||[],a[l].push(u);for(var g=A(E,E[l][u],l),c=Object.keys(g),m=0;m<c.length;m++)h[c[m]]=h[c[m]]||[],h[c[m]]=h[c[m]].concat(g[c[m]])}}return a}function x(E,p,h,a){var o=E[a].map(function(n){return'"'+n+'": '+p[a][n].toString().replace(/^"[^"]+"/,"function")}).join(",");return D[0]+"{"+o+"}"+D[1]+'"'+h+'"'+D[2]}function f(E,p){p=p||{};var h={main:_.m},a=p.all?{main:Object.keys(h.main)}:T(h,E),o="";Object.keys(a).filter(function(u){return u!=="main"}).forEach(function(u){for(var g=0;a[u][g];)g++;a[u].push(g),h[u][g]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",o=o+("var "+u+" = ("+x(a,h,g,modules)+`)();
|
|
21
|
-
`)}),o=o+("new (("+x(a,h,E,"main")+")())(self);");var n=new window.Blob([o],{type:"text/javascript"}),v=window.URL||window.webkitURL||window.mozURL||window.msURL,l=v.createObjectURL(n),i=new window.Worker(l);return i.objectURL=l,i}},"./src/errors.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{ErrorDetails:()=>D,ErrorTypes:()=>C});var C;(function(M){M.NETWORK_ERROR="networkError",M.MEDIA_ERROR="mediaError",M.KEY_SYSTEM_ERROR="keySystemError",M.MUX_ERROR="muxError",M.OTHER_ERROR="otherError"})(C||(C={}));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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{Events:()=>C});var C;(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"})(C||(C={}))},"./src/hls.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>g});var C=_("./node_modules/url-toolkit/src/url-toolkit.js"),D=_.n(C),M=_("./src/loader/playlist-loader.ts"),P=_("./src/controller/id3-track-controller.ts"),B=_("./src/controller/latency-controller.ts"),b=_("./src/controller/level-controller.ts"),A=_("./src/controller/fragment-tracker.ts"),S=_("./src/loader/key-loader.ts"),T=_("./src/controller/stream-controller.ts"),x=_("./src/is-supported.ts"),f=_("./src/utils/logger.ts"),E=_("./src/config.ts"),p=_("./node_modules/eventemitter3/index.js"),h=_.n(p),a=_("./src/events.ts"),o=_("./src/errors.ts"),n=_("./src/types/level.ts");function v(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&&v(c.prototype,m),e&&v(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,E.mergeConfig)(c.DefaultConfig,e);this.userConfig=e,(0,f.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,E.enableStreamingMode)(r);var t=r.abrController,s=r.bufferController,y=r.capLevelController,d=r.fpsController,L=this.abrController=new t(this),R=this.bufferController=new s(this),I=this.capLevelController=new y(this),k=new d(this),F=new M.default(this),K=new P.default(this),H=this.levelController=new b.default(this),j=new A.FragmentTracker(this),Y=new S.default(this.config),J=this.streamController=new T.default(this,j,Y);I.setStreamController(J),k.setStreamController(J);var te=[F,H,J];this.networkControllers=te;var ae=[L,R,I,k,K,j];this.audioTrackController=this.createController(r.audioTrackController,te);var re=r.audioStreamController;re&&te.push(new re(this,j,Y)),this.subtitleTrackController=this.createController(r.subtitleTrackController,te);var se=r.subtitleStreamController;se&&te.push(new se(this,j,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(B.default,ae),this.coreComponents=ae}var m=c.prototype;return m.createController=function(r,t){if(r){var s=new r(this);return t&&t.push(s),s}return null},m.on=function(r,t,s){s===void 0&&(s=this),this._emitter.on(r,t,s)},m.once=function(r,t,s){s===void 0&&(s=this),this._emitter.once(r,t,s)},m.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},m.off=function(r,t,s,y){s===void 0&&(s=this),this._emitter.off(r,t,s,y)},m.listeners=function(r){return this._emitter.listeners(r)},m.emit=function(r,t,s){return this._emitter.emit(r,t,s)},m.trigger=function(r,t){if(this.config.debug)return this.emit(r,r,t);try{return this.emit(r,r,t)}catch(s){f.logger.error("An internal error happened while handling event "+r+'. Error message: "'+s.message+'". Here is a stacktrace:',s),this.trigger(a.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:s})}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,s=this.url,y=this.url=C.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});f.logger.log("loadSource:"+y),t&&s&&s!==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 s=r.length,y=0;y<s;y++)if(r[y].maxBitrate>=t)return y;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,t=this.autoLevelCapping,s=this.maxHdcpLevel,y;if(t===-1&&r&&r.length?y=r.length-1:y=t,s)for(var d=y;d--;){var L=r[d].attrs["HDCP-LEVEL"];if(L&&L<=s)return d}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 o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.ErrorDetails}},{key:"DefaultConfig",get:function(){return c.defaultConfig?c.defaultConfig:E.hlsDefaultConfig},set:function(r){c.defaultConfig=r}}]),c}();g.defaultConfig=void 0},"./src/is-supported.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{changeTypeSupported:()=>P,isSupported:()=>M});var C=_("./src/utils/mediasource-helper.ts");function D(){return self.SourceBuffer||self.WebKitSourceBuffer}function M(){var B=(0,C.getMediaSource)();if(!B)return!1;var b=D(),A=B&&typeof B.isTypeSupported=="function"&&B.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 B,b=D();return typeof(b==null||(B=b.prototype)===null||B===void 0?void 0:B.changeType)=="function"}},"./src/loader/date-range.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{DateRange:()=>x,DateRangeAttribute:()=>T});var C=_("./src/polyfills/number.ts"),D=_("./src/utils/attr-list.ts"),M=_("./src/utils/logger.ts");function P(){return P=Object.assign?Object.assign.bind():function(f){for(var E=1;E<arguments.length;E++){var p=arguments[E];for(var h in p)Object.prototype.hasOwnProperty.call(p,h)&&(f[h]=p[h])}return f},P.apply(this,arguments)}function B(f,E){for(var p=0;p<E.length;p++){var h=E[p];h.enumerable=h.enumerable||!1,h.configurable=!0,"value"in h&&(h.writable=!0),Object.defineProperty(f,A(h.key),h)}}function b(f,E,p){return E&&B(f.prototype,E),p&&B(f,p),Object.defineProperty(f,"prototype",{writable:!1}),f}function A(f){var E=S(f,"string");return typeof E=="symbol"?E:String(E)}function S(f,E){if(typeof f!="object"||f===null)return f;var p=f[Symbol.toPrimitive];if(p!==void 0){var h=p.call(f,E||"default");if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(E==="string"?String:Number)(f)}var T;(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"})(T||(T={}));var x=function(){function f(E,p){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,p){var h=p.attr;for(var a in h)if(Object.prototype.hasOwnProperty.call(E,a)&&E[a]!==h[a]){M.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+E.ID+'"'),this._badValueForSameId=a;break}E=P(new D.AttrList({}),h,E)}if(this.attr=E,this._startDate=new Date(E[T.START_DATE]),T.END_DATE in this.attr){var o=new Date(this.attr[T.END_DATE]);(0,C.isFiniteNumber)(o.getTime())&&(this._endDate=o)}}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(T.DURATION in this.attr){var p=this.attr.decimalFloatingPoint(T.DURATION);if((0,C.isFiniteNumber)(p))return p}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return T.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(T.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(T.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,C.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),f}()},"./src/loader/fragment-loader.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{LoadError:()=>p,default:()=>f});var C=_("./src/polyfills/number.ts"),D=_("./src/errors.ts");function M(h,a){h.prototype=Object.create(a.prototype),h.prototype.constructor=h,S(h,a)}function P(h){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,v)}function v(){return B(n,arguments,T(this).constructor)}return v.prototype=Object.create(n.prototype,{constructor:{value:v,enumerable:!1,writable:!0,configurable:!0}}),S(v,n)},P(h)}function B(h,a,o){return b()?B=Reflect.construct.bind():B=function(v,l,i){var u=[null];u.push.apply(u,l);var g=Function.bind.apply(v,u),c=new g;return i&&S(c,i.prototype),c},B.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(h){return Function.toString.call(h).indexOf("[native code]")!==-1}function S(h,a){return S=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,v){return n.__proto__=v,n},S(h,a)}function T(h){return T=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},T(h)}var x=Math.pow(2,17),f=function(){function h(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}var a=h.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,v){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=E(n),s={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:n.sn==="initSegment"?1/0:x};n.stats=r.stats,r.load(t,s,{onSuccess:function(d,L,R,I){l.resetLoader(n,r);var k=d.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(d,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:d,networkDetails:R}))},onAbort:function(d,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(d,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(d,L,R,I){v&&v({frag:n,part:null,payload:R,networkDetails:I})}})})},a.loadPart=function(n,v,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=E(n,v),s={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:x};v.stats=r.stats,r.load(t,s,{onSuccess:function(d,L,R,I){i.resetLoader(n,r),i.updateStatsFromPart(n,v);var k={frag:n,part:v,payload:d.data,networkDetails:I};l(k),m(k)},onError:function(d,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:v,response:d,networkDetails:R}))},onAbort:function(d,L,R){n.stats.aborted=v.stats.aborted,i.resetLoader(n,r),e(new p({type:D.ErrorTypes.NETWORK_ERROR,details:D.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:n,part:v,networkDetails:R}))},onTimeout:function(d,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:v,networkDetails:R}))}})})},a.updateStatsFromPart=function(n,v){var l=n.stats,i=v.stats,u=i.total;if(l.loaded+=i.loaded,u){var g=Math.round(n.duration/v.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,v){n.loader=null,this.loader===v&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),v.destroy()},h}();function E(h,a){a===void 0&&(a=null);var o=a||h,n={frag:h,part:a,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},v=o.byteRangeStartOffset,l=o.byteRangeEndOffset;if((0,C.isFiniteNumber)(v)&&(0,C.isFiniteNumber)(l)){var i,u=v,g=l;if(h.sn==="initSegment"&&((i=h.decryptdata)===null||i===void 0?void 0:i.method)==="AES-128"){var c=l-v;c%16&&(g=l+(16-c%16)),v!==0&&(n.resetIV=!0,u=v-16)}n.rangeStart=u,n.rangeEnd=g}return n}var p=function(h){M(a,h);function a(o){for(var n,v=arguments.length,l=new Array(v>1?v-1:0),i=1;i<v;i++)l[i-1]=arguments[i];return n=h.call.apply(h,[this].concat(l))||this,n.data=void 0,n.data=o,n}return a}(P(Error))},"./src/loader/fragment.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{BaseSegment:()=>E,ElementaryStreamTypes:()=>f,Fragment:()=>p,Part:()=>h});var C=_("./src/polyfills/number.ts"),D=_("./node_modules/url-toolkit/src/url-toolkit.js"),M=_.n(D),P=_("./src/loader/load-stats.ts");function B(a,o){a.prototype=Object.create(o.prototype),a.prototype.constructor=a,b(a,o)}function b(a,o){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,l){return v.__proto__=l,v},b(a,o)}function A(a,o){for(var n=0;n<o.length;n++){var v=o[n];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(a,T(v.key),v)}}function S(a,o,n){return o&&A(a.prototype,o),n&&A(a,n),Object.defineProperty(a,"prototype",{writable:!1}),a}function T(a){var o=x(a,"string");return typeof o=="symbol"?o:String(o)}function x(a,o){if(typeof a!="object"||a===null)return a;var n=a[Symbol.toPrimitive];if(n!==void 0){var v=n.call(a,o||"default");if(typeof v!="object")return v;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(a)}var f;(function(a){a.AUDIO="audio",a.VIDEO="video",a.AUDIOVIDEO="audiovideo"})(f||(f={}));var E=function(){function a(n){var v;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(v={},v[f.AUDIO]=null,v[f.VIDEO]=null,v[f.AUDIOVIDEO]=null,v),this.baseurl=n}var o=a.prototype;return o.setByteRange=function(v,l){var i=v.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(v){this._url=v}}]),a}(),p=function(a){B(o,a);function o(v,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=v,i}var n=o.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(o,[{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,C.isFiniteNumber)(this.programDateTime))return null;var l=(0,C.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}}]),o}(E),h=function(a){B(o,a);function o(n,v,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=v,g.index=i;var c=n.enumeratedString("BYTERANGE");return c&&g.setByteRange(c,u),u&&(g.fragOffset=u.fragOffset+u.duration),g}return S(o,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var v=this.elementaryStreams;return!!(v.audio||v.video||v.audiovideo)}}]),o}(E)},"./src/loader/key-loader.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>M});var C=_("./src/errors.ts"),D=_("./src/loader/fragment-loader.ts"),M=function(){function P(b){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=b}var B=P.prototype;return B.abort=function(){for(var A in this.keyUriToKeyInfo){var S=this.keyUriToKeyInfo[A].loader;S&&S.abort()}},B.detach=function(){for(var A in this.keyUriToKeyInfo){var S=this.keyUriToKeyInfo[A];(S.mediaKeySessionContext||S.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[A]}},B.destroy=function(){this.detach();for(var A in this.keyUriToKeyInfo){var S=this.keyUriToKeyInfo[A].loader;S&&S.destroy()}this.keyUriToKeyInfo={}},B.createKeyLoadError=function(A,S,T,x){return S===void 0&&(S=C.ErrorDetails.KEY_LOAD_ERROR),new D.LoadError({type:C.ErrorTypes.NETWORK_ERROR,details:S,fatal:!1,frag:A,networkDetails:T})},B.loadClear=function(A,S){var T=this;if(this.emeController&&this.config.emeEnabled)for(var x=A.sn,f=A.cc,E=function(o){var n=S[o];if(f<=n.cc&&(x==="initSegment"||x<n.sn))return T.emeController.selectKeySystemFormat(n).then(function(v){n.setKeyFormat(v)}),"break"},p=0;p<S.length;p++){var h=E(p);if(h==="break")break}},B.load=function(A){var S=this;return!A.decryptdata&&A.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(A).then(function(T){return S.loadInternal(A,T)}):this.loadInternal(A)},B.loadInternal=function(A,S){var T,x;S&&A.setKeyFormat(S);var f=A.decryptdata;if(!f){var E=S?"Expected frag.decryptdata to be defined after setting format "+S:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(A,C.ErrorDetails.KEY_LOAD_ERROR,null,E))}var p=f.uri;if(!p)return Promise.reject(this.createKeyLoadError(A,C.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+p+'"'));var h=this.keyUriToKeyInfo[p];if((T=h)!==null&&T!==void 0&&T.decryptdata.key)return f.key=h.decryptdata.key,Promise.resolve({frag:A,keyInfo:h});if((x=h)!==null&&x!==void 0&&x.keyLoadPromise){var a;switch((a=h.mediaKeySessionContext)===null||a===void 0?void 0:a.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return h.keyLoadPromise}}switch(h=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(h,A):this.loadKeyEME(h,A);case"AES-128":return this.loadKeyHTTP(h,A);default:return Promise.reject(this.createKeyLoadError(A,C.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+f.method+'"'))}},B.loadKeyEME=function(A,S){var T={frag:S,keyInfo:A};if(this.emeController&&this.config.emeEnabled){var x=this.emeController.loadKey(T);if(x)return(A.keyLoadPromise=x.then(function(f){return A.mediaKeySessionContext=f,T})).catch(function(f){throw A.keyLoadPromise=null,f})}return Promise.resolve(T)},B.loadKeyHTTP=function(A,S){var T=this,x=this.config,f=x.loader,E=new f(x);return S.keyLoader=A.loader=E,A.keyLoadPromise=new Promise(function(p,h){var a={keyInfo:A,frag:S,responseType:"arraybuffer",url:A.decryptdata.uri},o={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!==T.keyUriToKeyInfo[e])return h(T.createKeyLoadError(c,C.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){T.resetLoader(i),h(T.createKeyLoadError(S,C.ErrorDetails.KEY_LOAD_ERROR,u))},onTimeout:function(l,i,u){T.resetLoader(i),h(T.createKeyLoadError(S,C.ErrorDetails.KEY_LOAD_TIMEOUT,u))},onAbort:function(l,i,u){T.resetLoader(i),h(T.createKeyLoadError(S,C.ErrorDetails.INTERNAL_ABORTED,u))}};E.load(a,o,n)})},B.resetLoader=function(A){var S=A.frag,T=A.keyInfo,x=A.url,f=T.loader;S.keyLoader===f&&(S.keyLoader=null,T.loader=null),delete this.keyUriToKeyInfo[x],f&&f.destroy()},P}()},"./src/loader/level-details.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{LevelDetails:()=>A});var C=_("./src/polyfills/number.ts");function D(S,T){for(var x=0;x<T.length;x++){var f=T[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,T,x){return T&&D(S.prototype,T),x&&D(S,x),Object.defineProperty(S,"prototype",{writable:!1}),S}function P(S){var T=B(S,"string");return typeof T=="symbol"?T:String(T)}function B(S,T){if(typeof S!="object"||S===null)return S;var x=S[Symbol.toPrimitive];if(x!==void 0){var f=x.call(S,T||"default");if(typeof f!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(T==="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 T=S.prototype;return T.reloaded=function(f){if(!f){this.advanced=!0,this.updated=!0;return}var E=this.lastPartSn-f.lastPartSn,p=this.lastPartIndex-f.lastPartIndex;this.updated=this.endSN!==f.endSN||!!p||!!E,this.advanced=this.endSN>f.endSN||E>0||E===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,C.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 E=this.driftEnd-this.driftStart;return E*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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{LevelKey:()=>A});var C=_("./src/utils/keysystem-util.ts"),D=_("./src/utils/mediakeys-helper.ts"),M=_("./src/utils/mp4-tools.ts"),P=_("./src/utils/logger.ts"),B=_("./src/utils/numeric-encoding-utils.ts"),b={},A=function(){T.clearKeyUriToKeyIdMap=function(){b={}};function T(f,E,p,h,a){h===void 0&&(h=[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=E,this.keyFormat=p,this.keyFormatVersions=h,this.iv=a,this.encrypted=f?f!=="NONE":!1,this.isCommonEncryption=this.encrypted&&f!=="AES-128"}var x=T.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(E){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof E!="number"&&(this.method==="AES-128"&&!this.iv&&P.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),E=0);var p=S(E),h=new T(this.method,this.uri,"identity",this.keyFormatVersions,p);return h}var a=(0,C.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 o=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,M.mp4pssh)(o,null,a);var n=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2),v=String.fromCharCode.apply(null,Array.from(n)),l=v.substring(v.indexOf("<"),v.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,B.base64Decode)(c).subarray(0,16);(0,C.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 s=Object.keys(b).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16);var y=new DataView(t.buffer,12,4);y.setUint32(0,s),b[this.uri]=t}this.keyId=t}return this},T}();function S(T){for(var x=new Uint8Array(16),f=12;f<16;f++)x[f]=T>>8*(15-f)&255;return x}},"./src/loader/load-stats.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{LoadStats:()=>C});var C=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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>o});var C=_("./src/polyfills/number.ts"),D=_("./node_modules/url-toolkit/src/url-toolkit.js"),M=_.n(D),P=_("./src/loader/date-range.ts"),B=_("./src/loader/fragment.ts"),b=_("./src/loader/level-details.ts"),A=_("./src/loader/level-key.ts"),S=_("./src/utils/attr-list.ts"),T=_("./src/utils/logger.ts"),x=_("./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 E=/#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,h=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("|")),o=function(){function c(){}return c.findGroup=function(e,r){for(var t=0;t<e.length;t++){var s=e[t];if(s.id===r)return s}},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=[],s=[],y={},d=[],L=!1;E.lastIndex=0;for(var R;(R=E.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)},K=k.decimalResolution("RESOLUTION");K&&(F.width=K.width,F.height=K.height),v((k.CODECS||"").split(/[ ,]+/).filter(function(te){return te}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=c.convertAVC1ToAVCOTI(F.videoCodec)),(I=F.unknownCodecs)!==null&&I!==void 0&&I.length||s.push(F),t.push(F)}else if(R[3]){var H=new S.AttrList(R[3]);H["DATA-ID"]&&(L=!0,y[H["DATA-ID"]]=H)}else if(R[4]){var j=R[4],Y=n(j,r);Y.encrypted&&Y.isSupported()?d.push(Y):T.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+j+'"')}var J=s.length>0&&s.length<t.length;return{levels:J?s:t,sessionData:L?y:null,sessionKeys:d.length?d:null}},c.parseMasterPlaylistMedia=function(e,r,t,s){s===void 0&&(s=[]);var y,d=[],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(s.length){var k=c.findGroup(s,I.groupId)||s[0];l(I,k,"audioCodec"),l(I,k,"textCodec")}d.push(I)}}return d},c.parseLevelPlaylist=function(e,r,t,s,y){var d=new b.LevelDetails(r),L=d.fragments,R=null,I=0,k=0,F=0,K=0,H=null,j=new B.Fragment(s,r),Y,J,te,ae=-1,re=!1;for(h.lastIndex=0,d.m3u8=e;(Y=h.exec(e))!==null;){re&&(re=!1,j=new B.Fragment(s,r),j.start=F,j.sn=I,j.cc=K,j.level=t,R&&(j.initSegment=R,j.rawProgramDateTime=R.rawProgramDateTime,R.rawProgramDateTime=null));var se=Y[1];if(se){j.duration=parseFloat(se);var ue=(" "+Y[2]).slice(1);j.title=ue||null,j.tagList.push(ue?["INF",se,ue]:["INF",se])}else if(Y[3]){if((0,C.isFiniteNumber)(j.duration)){if(j.start=F,te){j.levelkeys=te;var ce=d.encryptedFragments;j.levelkeys&&Object.keys(j.levelkeys).some(function(et){return j.levelkeys[et].isCommonEncryption})&&(!ce.length||ce[ce.length-1].levelkeys!==te)&&ce.push(j)}j.sn=I,j.level=t,j.cc=K,j.urlId=y,L.push(j),j.relurl=(" "+Y[3]).slice(1),u(j,H),H=j,F+=j.duration,I++,k=0,re=!0}}else if(Y[4]){var le=(" "+Y[4]).slice(1);H?j.setByteRange(le,H):j.setByteRange(le)}else if(Y[5])j.rawProgramDateTime=(" "+Y[5]).slice(1),j.tagList.push(["PROGRAM-DATE-TIME",j.rawProgramDateTime]),ae===-1&&(ae=L.length);else{if(Y=Y[0].match(a),!Y){T.logger.warn("No matches on slow regex match for level playlist!");continue}for(J=1;J<Y.length&&typeof Y[J]=="undefined";J++);var de=(" "+Y[J]).slice(1),fe=(" "+Y[J+1]).slice(1),Se=Y[J+2]?(" "+Y[J+2]).slice(1):"";switch(de){case"PLAYLIST-TYPE":d.type=fe.toUpperCase();break;case"MEDIA-SEQUENCE":I=d.startSN=parseInt(fe);break;case"SKIP":{var be=new S.AttrList(fe),Oe=be.decimalInteger("SKIPPED-SEGMENTS");if((0,C.isFiniteNumber)(Oe)){d.skippedSegments=Oe;for(var Re=Oe;Re--;)L.unshift(null);I+=Oe}var Ce=be.enumeratedString("RECENTLY-REMOVED-DATERANGES");Ce&&(d.recentlyRemovedDateranges=Ce.split(" "));break}case"TARGETDURATION":d.targetduration=parseFloat(fe);break;case"VERSION":d.version=parseInt(fe);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(fe||Se)&&j.tagList.push(Se?[fe,Se]:[fe]);break;case"DISCONTINUITY":K++,j.tagList.push(["DIS"]);break;case"GAP":j.tagList.push([de]);break;case"BITRATE":j.tagList.push([de,fe]);break;case"DATERANGE":{var Pe=new S.AttrList(fe),Me=new P.DateRange(Pe,d.dateRanges[Pe.ID]);Me.isValid||d.skippedSegments?d.dateRanges[Me.id]=Me:T.logger.warn('Ignoring invalid DATERANGE tag: "'+fe+'"'),j.tagList.push(["EXT-X-DATERANGE",fe]);break}case"DISCONTINUITY-SEQUENCE":K=parseInt(fe);break;case"KEY":{var De=n(fe,r);if(De.isSupported()){if(De.method==="NONE"){te=void 0;break}te||(te={}),te[De.keyFormat]&&(te=f({},te)),te[De.keyFormat]=De}else T.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+fe+'"');break}case"START":{var Fe=new S.AttrList(fe),Ne=Fe.decimalFloatingPoint("TIME-OFFSET");(0,C.isFiniteNumber)(Ne)&&(d.startTimeOffset=Ne);break}case"MAP":{var ke=new S.AttrList(fe);if(j.duration){var Xe=new B.Fragment(s,r);g(Xe,ke,t,te),R=Xe,j.initSegment=R,R.rawProgramDateTime&&!j.rawProgramDateTime&&(j.rawProgramDateTime=R.rawProgramDateTime)}else g(j,ke,t,te),R=j,re=!0;break}case"SERVER-CONTROL":{var ze=new S.AttrList(fe);d.canBlockReload=ze.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=ze.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&ze.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=ze.optionalFloat("PART-HOLD-BACK",0),d.holdBack=ze.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var rt=new S.AttrList(fe);d.partTarget=rt.decimalFloatingPoint("PART-TARGET");break}case"PART":{var Qe=d.partList;Qe||(Qe=d.partList=[]);var it=k>0?Qe[Qe.length-1]:void 0,nt=k++,Je=new B.Part(new S.AttrList(fe),j,r,nt,it);Qe.push(Je),j.duration+=Je.duration;break}case"PRELOAD-HINT":{var Ke=new S.AttrList(fe);d.preloadHint=Ke;break}case"RENDITION-REPORT":{var We=new S.AttrList(fe);d.renditionReports=d.renditionReports||[],d.renditionReports.push(We);break}default:T.logger.warn("line parsed but not handled: "+Y);break}}}H&&!H.relurl?(L.pop(),F-=H.duration,d.partList&&(d.fragmentHint=H)):d.partList&&(u(j,H),j.cc=K,d.fragmentHint=j);var Ze=L.length,ct=L[0],we=L[Ze-1];if(F+=d.skippedSegments*d.targetduration,F>0&&Ze&&we){d.averagetargetduration=F/Ze;var qe=we.sn;d.endSN=qe!=="initSegment"?qe:0,d.live||(we.endList=!0),ct&&(d.startCC=ct.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(F+=d.fragmentHint.duration),d.totalduration=F,d.endCC=K,ae>0&&i(L,ae),d},c}();function n(c,m){var e,r,t=new S.AttrList(c),s=(e=t.enumeratedString("METHOD"))!=null?e:"",y=t.URI,d=t.hexadecimalInteger("IV"),L=t.enumeratedString("KEYFORMATVERSIONS"),R=(r=t.enumeratedString("KEYFORMAT"))!=null?r:"identity";y&&t.IV&&!d&&T.logger.error("Invalid IV: "+t.IV);var I=y?o.resolve(y,m):"",k=(L||"1").split("/").map(Number).filter(Number.isFinite);return new A.LevelKey(s,I,R,k,d)}function v(c,m){["video","audio","text"].forEach(function(e){var r=c.filter(function(s){return(0,x.isCodecType)(s,e)});if(r.length){var t=r.filter(function(s){return s.lastIndexOf("avc1",0)===0||s.lastIndexOf("mp4a",0)===0});m[e+"Codec"]=t.length>0?t[0]:r[0],c=c.filter(function(s){return r.indexOf(s)===-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,C.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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>f});var C=_("./src/polyfills/number.ts"),D=_("./src/events.ts"),M=_("./src/errors.ts"),P=_("./src/utils/logger.ts"),B=_("./src/loader/m3u8-parser.ts"),b=_("./src/types/loader.ts"),A=_("./src/utils/attr-list.ts");function S(E){var p=E.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 T(E,p){var h=E.url;return(h===void 0||h.indexOf("data:")===0)&&(h=p.url),h}var x=function(){function E(h){this.hls=void 0,this.loaders=Object.create(null),this.hls=h,this.registerListeners()}var p=E.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 o=this.hls.config,n=o.pLoader,v=o.loader,l=n||v,i=new l(o);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 o=this.loaders[a];o&&o.destroy(),this.resetInternalLoader(a)}},p.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},p.onManifestLoading=function(a,o){var n=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:b.PlaylistContextType.MANIFEST,url:n,deliveryDirectives:null})},p.onLevelLoading=function(a,o){var n=o.id,v=o.level,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:null,level:v,responseType:"text",type:b.PlaylistContextType.LEVEL,url:l,deliveryDirectives:i})},p.onAudioTrackLoading=function(a,o){var n=o.id,v=o.groupId,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:v,level:null,responseType:"text",type:b.PlaylistContextType.AUDIO_TRACK,url:l,deliveryDirectives:i})},p.onSubtitleTrackLoading=function(a,o){var n=o.id,v=o.groupId,l=o.url,i=o.deliveryDirectives;this.load({id:n,groupId:v,level:null,responseType:"text",type:b.PlaylistContextType.SUBTITLE_TRACK,url:l,deliveryDirectives:i})},p.load=function(a){var o,n=this.hls.config,v=this.getInternalLoader(a);if(v){var l=v.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),v.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(v=this.createInternalLoader(a),(o=a.deliveryDirectives)!==null&&o!==void 0&&o.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},s={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};v.load(a,t,s)},p.loadsuccess=function(a,o,n,v){v===void 0&&(v=null),this.resetInternalLoader(n.type);var l=a.data;if(l.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(a,n,"no EXTM3U delimiter",v);return}o.parsing.start=performance.now(),l.indexOf("#EXTINF:")>0||l.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(a,o,n,v):this.handleMasterPlaylist(a,o,n,v)},p.loaderror=function(a,o,n){n===void 0&&(n=null),this.handleNetworkError(o,n,!1,a)},p.loadtimeout=function(a,o,n){n===void 0&&(n=null),this.handleNetworkError(o,n,!0)},p.handleMasterPlaylist=function(a,o,n,v){var l=this.hls,i=a.data,u=T(a,n),g=B.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",v);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}}),s=B.default.parseMasterPlaylistMedia(i,u,"AUDIO",r),y=B.default.parseMasterPlaylistMedia(i,u,"SUBTITLES",t),d=B.default.parseMasterPlaylistMedia(i,u,"CLOSED-CAPTIONS");if(s.length){var L=s.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"),s.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:s,subtitles:y,captions:d,url:u,stats:o,networkDetails:v,sessionData:m,sessionKeys:e})},p.handleTrackOrLevelPlaylist=function(a,o,n,v){var l=this.hls,i=n.id,u=n.level,g=n.type,c=T(a,n),m=(0,C.isFiniteNumber)(i)?i:0,e=(0,C.isFiniteNumber)(u)?u:m,r=S(n),t=B.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 s={attrs:new A.AttrList({}),bitrate:0,details:t,name:"",url:c};l.trigger(D.Events.MANIFEST_LOADED,{levels:[s],audioTracks:[],url:c,stats:o,networkDetails:v,sessionData:null,sessionKeys:null})}o.parsing.end=performance.now(),n.levelDetails=t,this.handlePlaylistLoaded(a,o,n,v)},p.handleManifestParsingError=function(a,o,n,v){this.hls.trigger(D.Events.ERROR,{type:M.ErrorTypes.NETWORK_ERROR,details:M.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===b.PlaylistContextType.MANIFEST,url:a.url,reason:n,response:a,context:o,networkDetails:v})},p.handleNetworkError=function(a,o,n,v){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:o};v&&(g.response=v),this.hls.trigger(D.Events.ERROR,g)},p.handlePlaylistLoaded=function(a,o,n,v){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",v);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:o,networkDetails:v,deliveryDirectives:e});break;case b.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(D.Events.AUDIO_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:o,networkDetails:v,deliveryDirectives:e});break;case b.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(D.Events.SUBTITLE_TRACK_LOADED,{details:m,id:u||0,groupId:g||"",stats:o,networkDetails:v,deliveryDirectives:e});break}},E}();let f=x},"./src/polyfills/number.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{MAX_SAFE_INTEGER:()=>D,isFiniteNumber:()=>C});var C=Number.isFinite||function(M){return typeof M=="number"&&isFinite(M)},D=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>D});var C=function(){function M(){}return M.getSilentFrame=function(B,b){switch(B){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=C},"./src/remux/mp4-generator.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>M});var C=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 T=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]),E=new Uint8Array([97,118,99,49]),p=new Uint8Array([0,0,0,1]);P.FTYP=P.box(P.types.ftyp,f,p,f,E),P.DINF=P.box(P.types.dinf,P.box(P.types.dref,T))},P.box=function(b){for(var A=8,S=arguments.length,T=new Array(S>1?S-1:0),x=1;x<S;x++)T[x-1]=arguments[x];for(var f=T.length,E=f;f--;)A+=T[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<E;f++)p.set(T[f],A),A+=T[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/(C+1)),T=Math.floor(A%(C+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,T>>24,T>>16&255,T>>8&255,T&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/(C+1)),T=Math.floor(A%(C+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,T>>24,T>>16&255,T>>8&255,T&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),T,x;for(T=0;T<A.length;T++)x=A[T].flags,S[T+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=[],T,x,f;for(T=0;T<b.sps.length;T++)x=b.sps[T],f=x.byteLength,A.push(f>>>8&255),A.push(f&255),A=A.concat(Array.prototype.slice.call(x));for(T=0;T<b.pps.length;T++)x=b.pps[T],f=x.byteLength,S.push(f>>>8&255),S.push(f&255),S=S.concat(Array.prototype.slice.call(x));var E=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,h=b.height,a=b.pixelRatio[0],o=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,h>>8&255,h&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]),E,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,o>>24,o>>16&255,o>>8&255,o&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,T=b.width,x=b.height,f=Math.floor(S/(C+1)),E=Math.floor(S%(C+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,E>>24,E>>16&255,E>>8&255,E&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,T>>8&255,T&255,0,0,x>>8&255,x&255,0,0]))},P.traf=function(b,A){var S=P.sdtp(b),T=b.id,x=Math.floor(A/(C+1)),f=Math.floor(A%(C+1));return P.box(P.types.traf,P.box(P.types.tfhd,new Uint8Array([0,0,0,0,T>>24,T>>16&255,T>>8&255,T&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||[],T=S.length,x=12+16*T,f=new Uint8Array(x),E,p,h,a,o,n;for(A+=8+x,f.set([b.type==="video"?1:0,0,15,1,T>>>24&255,T>>>16&255,T>>>8&255,T&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255],0),E=0;E<T;E++)p=S[E],h=p.duration,a=p.size,o=p.flags,n=p.cts,f.set([h>>>24&255,h>>>16&255,h>>>8&255,h&255,a>>>24&255,a>>>16&255,a>>>8&255,a&255,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,o.degradPrio&240<<8,o.degradPrio&15,n>>>24&255,n>>>16&255,n>>>8&255,n&255],12+16*E);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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>a,flushTextTrackMetadataCueSamples:()=>v,flushTextTrackUserdataCueSamples:()=>l,normalizePts:()=>o});var C=_("./src/polyfills/number.ts"),D=_("./src/remux/aac-helper.ts"),M=_("./src/remux/mp4-generator.ts"),P=_("./src/events.ts"),B=_("./src/errors.ts"),b=_("./src/utils/logger.ts"),A=_("./src/types/loader.ts"),S=_("./src/utils/timescale-conversion.ts");function T(){return T=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},T.apply(this,arguments)}var x=10*1e3,f=1024,E=1152,p=null,h=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 s=navigator.userAgent||"",y=s.match(/Chrome\/(\d+)/i);p=y?parseInt(y[1]):0}if(h===null){var d=navigator.userAgent.match(/Safari\/(\d+)/i);h=d?parseInt(d[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(s,y){var d=y.pts-s;return d<-4294967296?(r=!0,o(s,y.pts)):d>0?s:y.pts},e[0].pts);return r&&b.logger.debug("PTS rollover detected"),t},c.remux=function(e,r,t,s,y,d,L,R){var I,k,F,K,H,j,Y=y,J=y,te=e.pid>-1,ae=r.pid>-1,re=r.samples.length,se=e.samples.length>0,ue=L&&re>0||re>1,ce=(!te||se)&&(!ae||ue)||this.ISGenerated||L;if(ce){this.ISGenerated||(F=this.generateIS(e,r,y));var le=this.isVideoContiguous,de=-1,fe;if(ue&&(de=n(r.samples),!le&&this.config.forceKeyFrameOnDiscontinuity))if(j=!0,de>0){b.logger.warn("[mp4-remuxer]: Dropped "+de+" out of "+re+" video samples due to a missing keyframe");var Se=this.getVideoStartPts(r.samples);r.samples=r.samples.slice(de),r.dropped+=de,J+=(r.samples[0].pts-Se)/r.inputTimeScale,fe=J}else de===-1&&(b.logger.warn("[mp4-remuxer]: No keyframe found out of "+re+" video samples"),j=!1);if(this.ISGenerated){if(se&&ue){var be=this.getVideoStartPts(r.samples),Oe=o(e.samples[0].pts,be)-be,Re=Oe/r.inputTimeScale;Y+=Math.max(0,Re),J+=Math.max(0,-Re)}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,d,ae||ue||R===A.PlaylistLevelType.AUDIO?J:void 0),ue){var Ce=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,J,le,Ce)}}else ue&&(I=this.remuxVideo(r,J,le,0));I&&(I.firstKeyFrame=de,I.independent=de!==-1,I.firstKeyFramePTS=fe)}}return this.ISGenerated&&(t.samples.length&&(H=v(t,y,this._initPTS,this._initDTS)),s.samples.length&&(K=l(s,y,this._initPTS))),{audio:k,video:I,initSegment:F,independent:j,text:K,id3:H}},c.generateIS=function(e,r,t){var s=e.samples,y=r.samples,d=this.typeSupported,L={},R=!(0,C.isFiniteNumber)(this._initPTS),I="audio/mp4",k,F,K;if(R&&(k=F=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?(I="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break}L.audio={id:"audio",container:I,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):M.default.initSegment([e]),metadata:{channelCount:e.channelCount}},R&&(K=e.inputTimeScale,k=F=s[0].pts-Math.round(K*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)){K=r.inputTimeScale;var H=this.getVideoStartPts(y),j=Math.round(K*t);F=Math.min(F,o(y[0].dts,H)-j),k=Math.min(k,H-j)}if(Object.keys(L).length)return this.ISGenerated=!0,R&&(this._initPTS=k,this._initDTS=F),{tracks:L,initPTS:k,timescale:K}},c.remuxVideo=function(e,r,t,s){var y=e.inputTimeScale,d=e.samples,L=[],R=d.length,I=this._initPTS,k=this.nextAvcDts,F=8,K=this.videoSampleDuration,H,j,Y=Number.POSITIVE_INFINITY,J=Number.NEGATIVE_INFINITY,te=!1;if(!t||k===null){var ae=r*y,re=d[0].pts-o(d[0].dts,d[0].pts);k=ae-re}for(var se=0;se<R;se++){var ue=d[se];ue.pts=o(ue.pts-I,k),ue.dts=o(ue.dts-I,k),ue.dts<d[se>0?se-1:se].dts&&(te=!0)}te&&d.sort(function(ft,Vt){var Sr=ft.dts-Vt.dts,xr=ft.pts-Vt.pts;return Sr||xr}),H=d[0].dts,j=d[d.length-1].dts;var ce=j-H,le=ce?Math.round(ce/(R-1)):K||e.inputTimeScale/30;if(t){var de=H-k,fe=de>le,Se=de<-1;if((fe||Se)&&(fe?b.logger.warn("AVC: "+(0,S.toMsFromMpegTsClock)(de,!0)+" ms ("+de+"dts) hole between fragments detected, filling it"):b.logger.warn("AVC: "+(0,S.toMsFromMpegTsClock)(-de,!0)+" ms ("+de+"dts) overlapping between fragments detected"),!Se||k>d[0].pts)){H=k;var be=d[0].pts-de;d[0].dts=H,d[0].pts=be,b.logger.log("Video: First PTS/DTS adjusted: "+(0,S.toMsFromMpegTsClock)(be,!0)+"/"+(0,S.toMsFromMpegTsClock)(H,!0)+", delta: "+(0,S.toMsFromMpegTsClock)(de,!0)+" ms")}}H=Math.max(0,H);for(var Oe=0,Re=0,Ce=0;Ce<R;Ce++){for(var Pe=d[Ce],Me=Pe.units,De=Me.length,Fe=0,Ne=0;Ne<De;Ne++)Fe+=Me[Ne].data.length;Re+=Fe,Oe+=De,Pe.length=Fe,Pe.dts=Math.max(Pe.dts,H),Y=Math.min(Pe.pts,Y),J=Math.max(Pe.pts,J)}j=d[R-1].dts;var ke=Re+4*Oe+8,Xe;try{Xe=new Uint8Array(ke)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ke,reason:"fail allocating video mdat "+ke});return}var ze=new DataView(Xe.buffer);ze.setUint32(0,ke),Xe.set(M.default.types.mdat,4);for(var rt=!1,Qe=Number.POSITIVE_INFINITY,it=Number.POSITIVE_INFINITY,nt=Number.NEGATIVE_INFINITY,Je=Number.NEGATIVE_INFINITY,Ke=0;Ke<R;Ke++){for(var We=d[Ke],Ze=We.units,ct=0,we=0,qe=Ze.length;we<qe;we++){var et=Ze[we],At=et.data,St=et.data.byteLength;ze.setUint32(F,St),F+=4,Xe.set(At,F),F+=St,ct+=4+St}var xt=void 0;if(Ke<R-1)K=d[Ke+1].dts-We.dts,xt=d[Ke+1].pts-We.pts;else{var Kt=this.config,Dt=Ke>0?We.dts-d[Ke-1].dts:le;if(xt=Ke>0?We.pts-d[Ke-1].pts:le,Kt.stretchShortVideoTrack&&this.nextAudioPts!==null){var ar=Math.floor(Kt.maxBufferHole*y),Wt=(s?Y+s*y:this.nextAudioPts)-We.pts;Wt>ar?(K=Wt-Dt,K<0?K=Dt:rt=!0,b.logger.log("[mp4-remuxer]: It is approximately "+Wt/90+" ms to the next segment; using duration "+K/90+" ms for the last video frame.")):K=Dt}else K=Dt}var yr=Math.round(We.pts-We.dts);Qe=Math.min(Qe,K),nt=Math.max(nt,K),it=Math.min(it,xt),Je=Math.max(Je,xt),L.push(new i(We.key,K,ct,yr))}if(L.length){if(p){if(p<70){var Gt=L[0].flags;Gt.dependsOn=2,Gt.isNonSync=0}}else if(h&&Je-it<nt-Qe&&le/nt<.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 It=H,dt=0,sr=L.length;dt<sr;dt++){var Ht=It+L[dt].duration,or=It+L[dt].cts;if(dt<sr-1){var jt=Ht+L[dt+1].cts;L[dt].duration=jt-or}else L[dt].duration=dt?L[dt-1].duration:le;L[dt].cts=0,It=Ht}}}console.assert(K!==null,"mp4SampleDuration must be computed"),K=rt||!K?le:K,this.nextAvcDts=k=j+K,this.videoSampleDuration=K,this.isVideoContiguous=!0;var Er=M.default.moof(e.sequenceNumber++,H,T({},e,{samples:L})),_r="video",Tr={data1:Er,data2:Xe,startPTS:Y/y,endPTS:(J+K)/y,startDTS:H/y,endDTS:k/y,type:_r,hasAudio:!1,hasVideo:!0,nb:L.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(Xe.length,"MDAT length must not be zero"),Tr},c.remuxAudio=function(e,r,t,s,y){var d=e.inputTimeScale,L=e.samplerate?e.samplerate:d,R=d/L,I=e.segmentCodec==="aac"?f:E,k=I*R,F=this._initPTS,K=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,H=[],j=y!==void 0,Y=e.samples,J=K?0:8,te=this.nextAudioPts||-1,ae=r*d;if(this.isAudioContiguous=t=t||Y.length&&te>0&&(s&&Math.abs(ae-te)<9e3||Math.abs(o(Y[0].pts-F,ae)-te)<20*k),Y.forEach(function(et){et.pts=o(et.pts-F,ae)}),!t||te<0){if(Y=Y.filter(function(et){return et.pts>=0}),!Y.length)return;y===0?te=0:s&&!j?te=Math.max(0,ae):te=Y[0].pts}if(e.segmentCodec==="aac")for(var re=this.config.maxAudioFramesDrift,se=0,ue=te;se<Y.length;se++){var ce=Y[se],le=ce.pts,de=le-ue,fe=Math.abs(1e3*de/d);if(de<=-re*k&&j)se===0&&(b.logger.warn("Audio frame @ "+(le/d).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*de/d)+" ms."),this.nextAudioPts=te=ue=le);else if(de>=re*k&&fe<x&&j){var Se=Math.round(de/k);ue=le-Se*k,ue<0&&(Se--,ue+=k),se===0&&(this.nextAudioPts=te=ue),b.logger.warn("[mp4-remuxer]: Injecting "+Se+" audio frame @ "+(ue/d).toFixed(3)+"s due to "+Math.round(1e3*de/d)+" ms gap.");for(var be=0;be<Se;be++){var Oe=Math.max(ue,0),Re=D.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Re||(b.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Re=ce.unit.subarray()),Y.splice(se,0,{unit:Re,pts:Oe}),ue+=k,se++}}ce.pts=ue,ue+=k}for(var Ce=null,Pe=null,Me,De=0,Fe=Y.length;Fe--;)De+=Y[Fe].unit.byteLength;for(var Ne=0,ke=Y.length;Ne<ke;Ne++){var Xe=Y[Ne],ze=Xe.unit,rt=Xe.pts;if(Pe!==null){var Qe=H[Ne-1];Qe.duration=Math.round((rt-Pe)/R)}else if(t&&e.segmentCodec==="aac"&&(rt=te),Ce=rt,De>0){De+=J;try{Me=new Uint8Array(De)}catch{this.observer.emit(P.Events.ERROR,P.Events.ERROR,{type:B.ErrorTypes.MUX_ERROR,details:B.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:De,reason:"fail allocating audio mdat "+De});return}if(!K){var it=new DataView(Me.buffer);it.setUint32(0,De),Me.set(M.default.types.mdat,4)}}else return;Me.set(ze,J);var nt=ze.byteLength;J+=nt,H.push(new i(!0,I,nt,0)),Pe=rt}var Je=H.length;if(!!Je){var Ke=H[H.length-1];this.nextAudioPts=te=Pe+R*Ke.duration;var We=K?new Uint8Array(0):M.default.moof(e.sequenceNumber++,Ce/R,T({},e,{samples:H}));e.samples=[];var Ze=Ce/d,ct=te/d,we="audio",qe={data1:We,data2:Me,startPTS:Ze,endPTS:ct,startDTS:Ze,endDTS:ct,type:we,hasAudio:!0,hasVideo:!1,nb:Je};return this.isAudioContiguous=!0,console.assert(Me.length,"MDAT length must not be zero"),qe}},c.remuxEmptyAudio=function(e,r,t,s){var y=e.inputTimeScale,d=e.samplerate?e.samplerate:y,L=y/d,R=this.nextAudioPts,I=(R!==null?R:s.startDTS*y)+this._initDTS,k=s.endDTS*y+this._initDTS,F=L*f,K=Math.ceil((k-I)/F),H=D.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(b.logger.warn("[mp4-remuxer]: remux empty Audio"),!H){b.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var j=[],Y=0;Y<K;Y++){var J=I+Y*F;j.push({unit:H,pts:J,dts:J})}return e.samples=j,this.remuxAudio(e,r,t,!1)},g}();function o(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 v(g,c,m,e){var r=g.samples.length;if(!!r){for(var t=g.inputTimeScale,s=0;s<r;s++){var y=g.samples[s];y.pts=o(y.pts-m,c*t)/t,y.dts=o(y.dts-e,c*t)/t}var d=g.samples;return g.samples=[],{samples:d}}}function l(g,c,m){var e=g.samples.length;if(!!e){for(var r=g.inputTimeScale,t=0;t<e;t++){var s=g.samples[t];s.pts=o(s.pts-m,c*r)/r}g.samples.sort(function(d,L){return d.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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>S});var C=_("./src/polyfills/number.ts"),D=_("./src/remux/mp4-remuxer.ts"),M=_("./src/utils/mp4-tools.ts"),P=_("./src/loader/fragment.ts"),B=_("./src/utils/logger.ts"),b=function(){function T(){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=T.prototype;return x.destroy=function(){},x.resetTimeStamp=function(E){this.initPTS=E,this.lastEndTime=null},x.resetNextTimestamp=function(){this.lastEndTime=null},x.resetInitSegment=function(E,p,h,a){this.audioCodec=p,this.videoCodec=h,this.generateInitSegment((0,M.patchEncyptionData)(E,a)),this.emitInitSegment=!0},x.generateInitSegment=function(E){var p=this.audioCodec,h=this.videoCodec;if(!E||!E.byteLength){this.initTracks=void 0,this.initData=void 0;return}var a=this.initData=(0,M.parseInitSegment)(E);p||(p=A(a.audio,P.ElementaryStreamTypes.AUDIO)),h||(h=A(a.video,P.ElementaryStreamTypes.VIDEO));var o={};a.audio&&a.video?o.audiovideo={container:"video/mp4",codec:p+","+h,initSegment:E,id:"main"}:a.audio?o.audio={container:"audio/mp4",codec:p,initSegment:E,id:"audio"}:a.video?o.video={container:"video/mp4",codec:h,initSegment:E,id:"main"}:B.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},x.remux=function(E,p,h,a,o){var n,v=this.initPTS,l=this.lastEndTime,i={audio:void 0,video:void 0,text:a,id3:h,initSegment:void 0};(0,C.isFiniteNumber)(l)||(l=this.lastEndTime=o||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 B.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,C.isFiniteNumber)(v)||(this.initPTS=g.initPTS=v=m-o);var e=(0,M.getDuration)(u,c),r=E?m-v:l,t=r+e;(0,M.offsetStartDTS)(c,u,v),e>0?this.lastEndTime=t:(B.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var s=!!c.audio,y=!!c.video,d="";s&&(d+="audio"),y&&(d+="video");var L={data1:u,startPTS:r,startDTS:r,endPTS:t,endDTS:t,type:d,hasAudio:s,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)(h,o,R,R),a.samples.length&&(i.text=(0,D.flushTextTrackUserdataCueSamples)(a,o,R)),i},T}();function A(T,x){var f=T==null?void 0:T.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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>C});var C=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(B){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,B),!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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{CMCDObjectType:()=>D,CMCDStreamType:()=>P,CMCDStreamingFormat:()=>M,CMCDVersion:()=>C});var C=1,D;(function(B){B.MANIFEST="m",B.AUDIO="a",B.VIDEO="v",B.MUXED="av",B.INIT="i",B.CAPTION="c",B.TIMED_TEXT="tt",B.KEY="k",B.OTHER="o"})(D||(D={}));var M;(function(B){B.DASH="d",B.HLS="h",B.SMOOTH="s",B.OTHER="o"})(M||(M={}));var P;(function(B){B.VOD="v",B.LIVE="l"})(P||(P={}))},"./src/types/demuxer.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{MetadataSchema:()=>C});var C;(function(D){D.audioId3="org.id3",D.dateRange="com.apple.quicktime.HLS",D.emsg="https://aomedia.org/emsg/ID3"})(C||(C={}))},"./src/types/level.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{HdcpLevels:()=>B,HlsSkip:()=>b,HlsUrlParameters:()=>S,Level:()=>T,getSkipValue:()=>A});function C(x,f){for(var E=0;E<f.length;E++){var p=f[E];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,E){return f&&C(x.prototype,f),E&&C(x,E),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 E=x[Symbol.toPrimitive];if(E!==void 0){var p=E.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 B=["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 E=x.canSkipUntil,p=x.canSkipDateRanges,h=x.endSN,a=f!==void 0?f-h:0;return E&&a<E?p?b.v2:b.Yes:b.No}var S=function(){function x(E,p,h){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=E,this.part=p,this.skip=h}var f=x.prototype;return f.addDirectives=function(p){var h=new self.URL(p);return this.msn!==void 0&&h.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&h.searchParams.set("_HLS_part",this.part.toString()),this.skip&&h.searchParams.set("_HLS_skip",this.skip),h.href},x}(),T=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(E){return E}).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(E){var p=E%this.url.length;this._urlId!==p&&(this.details=void 0,this._urlId=p)}}]),x}()},"./src/types/loader.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{PlaylistContextType:()=>C,PlaylistLevelType:()=>D});var C;(function(M){M.MANIFEST="manifest",M.LEVEL="level",M.AUDIO_TRACK="audioTrack",M.SUBTITLE_TRACK="subtitleTrack"})(C||(C={}));var D;(function(M){M.MAIN="main",M.AUDIO="audio",M.SUBTITLE="subtitle"})(D||(D={}))},"./src/types/transmuxer.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{ChunkMetadata:()=>C});var C=function(P,B,b,A,S,T){A===void 0&&(A=0),S===void 0&&(S=-1),T===void 0&&(T=!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=B,this.id=b,this.size=A,this.part=S,this.partial=T};function D(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{AttrList:()=>M});var C=/^(\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 B=P.prototype;return B.decimalInteger=function(A){var S=parseInt(this[A],10);return S>Number.MAX_SAFE_INTEGER?1/0:S},B.hexadecimalInteger=function(A){if(this[A]){var S=(this[A]||"0x").slice(2);S=(S.length&1?"0":"")+S;for(var T=new Uint8Array(S.length/2),x=0;x<S.length/2;x++)T[x]=parseInt(S.slice(x*2,x*2+2),16);return T}else return null},B.hexadecimalIntegerAsNumber=function(A){var S=parseInt(this[A],16);return S>Number.MAX_SAFE_INTEGER?1/0:S},B.decimalFloatingPoint=function(A){return parseFloat(this[A])},B.optionalFloat=function(A,S){var T=this[A];return T?parseFloat(T):S},B.enumeratedString=function(A){return this[A]},B.bool=function(A){return this[A]==="YES"},B.decimalResolution=function(A){var S=C.exec(this[A]);if(S!==null)return{width:parseInt(S[1],10),height:parseInt(S[2],10)}},P.parseAttrList=function(A){var S,T={},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)),T[S[1]]=f}return T},P}()},"./src/utils/binary-search.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>D});var C={search:function(P,B){for(var b=0,A=P.length-1,S=null,T=null;b<=A;){S=(b+A)/2|0,T=P[S];var x=B(T);if(x>0)b=S+1;else if(x<0)A=S-1;else return T}return null}};let D=C},"./src/utils/buffer-helper.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{BufferHelper:()=>M});var C=_("./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),T=0;T<S.length;T++)if(A>=S.start(T)&&A<=S.end(T))return!0}}catch{}return!1},P.bufferInfo=function(b,A,S){try{if(b){var T=P.getBuffered(b),x=[],f;for(f=0;f<T.length;f++)x.push({start:T.start(f),end:T.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 T=[];if(S)for(var x=0;x<b.length;x++){var f=T.length;if(f){var E=T[f-1].end;b[x].start-E<S?b[x].end>E&&(T[f-1].end=b[x].end):T.push(b[x])}else T.push(b[x])}else T=b;for(var p=0,h,a=A,o=A,n=0;n<T.length;n++){var v=T[n].start,l=T[n].end;if(A+S>=v&&A<l)a=v,o=l,p=o-A;else if(A+S<v){h=v;break}}return{len:p,start:a||0,end:o||0,nextStart:h}},P.getBuffered=function(b){try{return b.buffered}catch(A){return C.logger.log("failed to get media.buffered",A),D}},P}()},"./src/utils/cea-608-parser.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{CaptionScreen:()=>n,Row:()=>o,default:()=>c});var C=_("./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,B=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},T={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 E=function(){function m(){this.time=null,this.verboseLevel=f.ERROR}var e=m.prototype;return e.log=function(t,s){if(this.verboseLevel>=t){var y=typeof s=="function"?s():s;C.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},h=function(){function m(r,t,s,y,d){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=s||!1,this.background=y||"black",this.flash=d||!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 s=["foreground","underline","italics","background","flash"],y=0;y<s.length;y++){var d=s[y];t.hasOwnProperty(d)&&(this[d]=t[d])}},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,s,y,d,L){this.uchar=void 0,this.penState=void 0,this.uchar=r||" ",this.penState=new h(t,s,y,d,L)}var e=m.prototype;return e.reset=function(){this.uchar=" ",this.penState.reset()},e.setChar=function(t,s){this.uchar=t,this.penState.copy(s)},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}(),o=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<B;t++)this.chars.push(new a);this.logger=r,this.pos=0,this.currPenState=new h}var e=m.prototype;return e.equals=function(t){for(var s=!0,y=0;y<B;y++)if(!this.chars[y].equals(t.chars[y])){s=!1;break}return s},e.copy=function(t){for(var s=0;s<B;s++)this.chars[s].copy(t.chars[s])},e.isEmpty=function(){for(var t=!0,s=0;s<B;s++)if(!this.chars[s].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>B&&(this.logger.log(f.DEBUG,"Too large cursor position "+this.pos),this.pos=B)},e.moveCursor=function(t){var s=this.pos+t;if(t>1)for(var y=this.pos+1;y<s+1;y++)this.chars[y].setPenState(this.currPenState);this.setCursor(s)},e.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},e.insertChar=function(t){var s=this;t>=144&&this.backSpace();var y=M(t);if(this.pos>=B){this.logger.log(f.ERROR,function(){return"Cannot insert "+t.toString(16)+" ("+y+") at position "+s.pos+". Skipping it!"});return}this.chars[this.pos].setChar(y,this.currPenState),this.moveCursor(1)},e.clearFromPos=function(t){var s;for(s=t;s<B;s++)this.chars[s].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=[],s=!0,y=0;y<B;y++){var d=this.chars[y].uchar;d!==" "&&(s=!1),t.push(d)}return s?"":t.join("")},e.setPenStyles=function(t){this.currPenState.setStyles(t);var s=this.chars[this.pos];s.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 o(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 s=!0,y=0;y<P;y++)if(!this.rows[y].equals(t.rows[y])){s=!1;break}return s},e.copy=function(t){for(var s=0;s<P;s++)this.rows[s].copy(t.rows[s])},e.isEmpty=function(){for(var t=!0,s=0;s<P;s++)if(!this.rows[s].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 s=this.rows[this.currRow];s.insertChar(t)},e.setPen=function(t){var s=this.rows[this.currRow];s.setPenStyles(t)},e.moveCursor=function(t){var s=this.rows[this.currRow];s.moveCursor(t)},e.setCursor=function(t){this.logger.log(f.INFO,"setCursor: "+t);var s=this.rows[this.currRow];s.setCursor(t)},e.setPAC=function(t){this.logger.log(f.INFO,function(){return"pacData = "+JSON.stringify(t)});var s=t.row-1;if(this.nrRollUpRows&&s<this.nrRollUpRows-1&&(s=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==s){for(var y=0;y<P;y++)this.rows[y].clear();var d=this.currRow+1-this.nrRollUpRows,L=this.lastOutputScreen;if(L){var R=L.rows[d].cueStartTime,I=this.logger.time;if(R&&I!==null&&R<I)for(var k=0;k<this.nrRollUpRows;k++)this.rows[s-this.nrRollUpRows+k+1].copy(L.rows[d+k])}}this.currRow=s;var F=this.rows[this.currRow];if(t.indent!==null){var K=t.indent,H=Math.max(K-1,0);F.setCursor(t.indent),t.color=F.chars[H].penState.foreground}var j={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(j)},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 s=this.currRow+1-this.nrRollUpRows,y=this.rows.splice(s,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 s=[],y="",d=-1,L=0;L<P;L++){var R=this.rows[L].getTextString();R&&(d=L+1,t?s.push("Row "+d+": '"+R+"'"):s.push(R.trim()))}return s.length>0&&(t?y="["+s.join(" | ")+"]":y=s.join(`
|
|
22
|
-
`)),y},e.getTextAndFormat=function(){return this.rows},m}(),v=function(){function m(r,t,s){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(s),this.nonDisplayedMemory=new n(s),this.lastOutputScreen=new n(s),this.currRollUpRow=this.displayedMemory.rows[P-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}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 s=this,y=0;y<t.length;y++)this.writeScreen.insertChar(t[y]);var d=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(f.INFO,function(){return d+": "+s.writeScreen.getDisplayText(!0)}),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(f.TEXT,function(){return"DISPLAYED: "+s.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 s=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=s,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 s={flash:!1};if(s.underline=t%2===1,s.italics=t>=46,s.italics)s.foreground="white";else{var y=Math.floor(t/2)-16,d=["white","green","blue","cyan","red","yellow","magenta"];s.foreground=d[y]}this.logger.log(f.INFO,"MIDROW: "+JSON.stringify(s)),this.writeScreen.setPen(s)},e.outputDataUpdate=function(t){t===void 0&&(t=!1);var s=this.logger.time;s!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=s:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,s,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:s),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,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var y=new E;this.channels=[null,new v(r,t,y),new v(r+1,s,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,s){this.channels[t].setHandler(s)},e.addData=function(t,s){var y,d,L,R=!1;this.logger.time=t;for(var I=0;I<s.length;I+=2)if(d=s[I]&127,L=s[I+1]&127,!(d===0&&L===0)){if(this.logger.log(f.DATA,"["+p([s[I],s[I+1]])+"] -> ("+p([d,L])+")"),y=this.parseCmd(d,L),y||(y=this.parseMidrow(d,L)),y||(y=this.parsePAC(d,L)),y||(y=this.parseBackgroundAttributes(d,L)),!y&&(R=this.parseChars(d,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([d,L])+" orig: "+p([s[I],s[I+1]]))}},e.parseCmd=function(t,s){var y=this.cmdHistory,d=(t===20||t===28||t===21||t===29)&&s>=32&&s<=47,L=(t===23||t===31)&&s>=33&&s<=35;if(!(d||L))return!1;if(u(t,s,y))return i(null,null,y),this.logger.log(f.DEBUG,"Repeated command ("+p([t,s])+") 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?s===32?I.ccRCL():s===33?I.ccBS():s===34?I.ccAOF():s===35?I.ccAON():s===36?I.ccDER():s===37?I.ccRU(2):s===38?I.ccRU(3):s===39?I.ccRU(4):s===40?I.ccFON():s===41?I.ccRDC():s===42?I.ccTR():s===43?I.ccRTD():s===44?I.ccEDM():s===45?I.ccCR():s===46?I.ccENM():s===47&&I.ccEOC():I.ccTO(s-32),i(t,s,y),this.currentChannel=R,!0},e.parseMidrow=function(t,s){var y=0;if((t===17||t===25)&&s>=32&&s<=47){if(t===17?y=1:y=2,y!==this.currentChannel)return this.logger.log(f.ERROR,"Mismatch channel in midrow parsing"),!1;var d=this.channels[y];return d?(d.ccMIDROW(s),this.logger.log(f.DEBUG,"MIDROW ("+p([t,s])+")"),!0):!1}return!1},e.parsePAC=function(t,s){var y,d=this.cmdHistory,L=(t>=17&&t<=23||t>=25&&t<=31)&&s>=64&&s<=127,R=(t===16||t===24)&&s>=64&&s<=95;if(!(L||R))return!1;if(u(t,s,d))return i(null,null,d),!0;var I=t<=23?1:2;s>=64&&s<=95?y=I===1?b[t]:S[t]:y=I===1?A[t]:T[t];var k=this.channels[I];return k?(k.setPAC(this.interpretPAC(y,s)),i(t,s,d),this.currentChannel=I,!0):!1},e.interpretPAC=function(t,s){var y,d={color:null,italics:!1,indent:null,underline:!1,row:t};return s>95?y=s-96:y=s-64,d.underline=(y&1)===1,y<=13?d.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(y/2)]:y<=15?(d.italics=!0,d.color="white"):d.indent=Math.floor((y-16)/2)*4,d},e.parseChars=function(t,s){var y,d=null,L=null;if(t>=25?(y=2,L=t-8):(y=1,L=t),L>=17&&L<=19){var R;L===17?R=s+80:L===18?R=s+112:R=s+144,this.logger.log(f.INFO,"Special char '"+M(R)+"' in channel "+y),d=[R]}else t>=32&&t<=127&&(d=s===0?[t]:[t,s]);if(d){var I=p(d);this.logger.log(f.DEBUG,"Char codes = "+I.join(",")),i(t,s,this.cmdHistory)}return d},e.parseBackgroundAttributes=function(t,s){var y=(t===16||t===24)&&s>=32&&s<=47,d=(t===23||t===31)&&s>=45&&s<=47;if(!(y||d))return!1;var L,R={};t===16||t===24?(L=Math.floor((s-32)/2),R.background=x[L],s%2===1&&(R.background=R.background+"_semi")):s===45?R.background="transparent":(R.foreground="black",s===47&&(R.underline=!0));var I=t<=23?1:2,k=this.channels[I];return k.setBkgData(R),i(t,s,this.cmdHistory),!0},e.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var s=this.channels[t];s&&s.reset()}this.cmdHistory=g()},e.cueSplitAtTime=function(t){for(var s=0;s<this.channels.length;s++){var y=this.channels[s];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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{isCodecSupportedInMp4:()=>M,isCodecType:()=>D});var C={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,B){var b=C[B];return!!b&&b[P.slice(0,4)]===!0}function M(P,B){return MediaSource.isTypeSupported((B||"video")+'/mp4;codecs="'+P+'"')}},"./src/utils/cues.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>b});var C=_("./src/utils/vttparser.ts"),D=_("./src/utils/webvtt-parser.ts"),M=_("./src/utils/texttrack-utils.ts"),P=/\s/,B={newCue:function(S,T,x,f){for(var E=[],p,h,a,o,n,v=self.VTTCue||self.TextTrackCue,l=0;l<f.rows.length;l++)if(p=f.rows[l],a=!0,o=0,n="",!p.isEmpty()){for(var i=0;i<p.chars.length;i++)P.test(p.chars[i].uchar)&&a?o++:(n+=p.chars[i].uchar,a=!1);p.cueStartTime=T,T===x&&(x+=1e-4),o>=16?o--:o++;var u=(0,C.fixLineBreaks)(n.trim()),g=(0,D.generateCueId)(T,x,u);(!S||!S.cues||!S.cues.getCueById(g))&&(h=new v(T,x,u),h.id=g,h.line=l+1,h.align="left",h.position=10+Math.min(80,Math.floor(o*8/32)*10),E.push(h))}return S&&E.length&&(E.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}),E.forEach(function(c){return(0,M.addCueToTrack)(S,c)})),E}};let b=B},"./src/utils/discontinuities.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{adjustSlidingStart:()=>S,alignMediaPlaylistByPDT:()=>E,alignPDT:()=>f,alignStream:()=>T,findDiscontinuousReferenceFrag:()=>b,findFirstFragWithCC:()=>P,shouldAlignOnDiscontinuities:()=>B});var C=_("./src/polyfills/number.ts"),D=_("./src/utils/logger.ts"),M=_("./src/controller/level-helper.ts");function P(p,h){for(var a=null,o=0,n=p.length;o<n;o++){var v=p[o];if(v&&v.cc===h){a=v;break}}return a}function B(p,h,a){return!!(h.details&&(a.endCC>a.startCC||p&&p.cc<a.startCC))}function b(p,h,a){a===void 0&&(a=0);var o=p.fragments,n=h.fragments;if(!n.length||!o.length){D.logger.log("No fragments to align");return}var v=P(o,n[0].cc);if(!v||v&&!v.startPTS){D.logger.log("No frag in previous level to align on");return}return v}function A(p,h){if(p){var a=p.start+h;p.start=p.startPTS=a,p.endPTS=a+p.duration}}function S(p,h){for(var a=h.fragments,o=0,n=a.length;o<n;o++)A(a[o],p);h.fragmentHint&&A(h.fragmentHint,p),h.alignedSliding=!0}function T(p,h,a){!h||(x(p,a,h),!a.alignedSliding&&h.details&&f(a,h.details),!a.alignedSliding&&h.details&&!a.skippedSegments&&(0,M.adjustSliding)(h.details,a))}function x(p,h,a){if(B(p,a,h)){var o=b(a.details,h);o&&(0,C.isFiniteNumber)(o.start)&&(D.logger.log("Adjusting PTS using last level due to CC increase within current level "+h.url),S(o.start,h))}}function f(p,h){if(!(!h.fragments.length||!p.hasProgramDateTime||!h.hasProgramDateTime)){var a=h.fragments[0].programDateTime,o=p.fragments[0].programDateTime,n=(o-a)/1e3+h.fragments[0].start;n&&(0,C.isFiniteNumber)(n)&&(D.logger.log("Adjusting PTS using programDateTime delta "+(o-a)+"ms, sliding:"+n.toFixed(3)+" "+p.url+" "),S(n,p))}}function E(p,h){if(!(!p.hasProgramDateTime||!h.hasProgramDateTime)){var a=p.fragments,o=h.fragments;if(!(!a.length||!o.length)){var n=Math.round(o.length/2)-1,v=o[n],l=P(a,v.cc)||a[Math.round(a.length/2)-1],i=v.programDateTime,u=l.programDateTime;if(!(i===null||u===null)){var g=(u-i)/1e3-(l.start-v.start);S(g,p)}}}}},"./src/utils/ewma-bandwidth-estimator.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>M});var C=_("./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 C.default(b),this.fast_=new C.default(A)}var B=P.prototype;return B.update=function(A,S){var T=this.slow_,x=this.fast_;this.slow_.halfLife!==A&&(this.slow_=new C.default(A,T.getEstimate(),T.getTotalWeight())),this.fast_.halfLife!==S&&(this.fast_=new C.default(S,x.getEstimate(),x.getTotalWeight()))},B.sample=function(A,S){A=Math.max(A,this.minDelayMs_);var T=8*S,x=A/1e3,f=T/x;this.fast_.sample(x,f),this.slow_.sample(x,f)},B.canEstimate=function(){var A=this.fast_;return A&&A.getTotalWeight()>=this.minWeight_},B.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},B.destroy=function(){},P}();let M=D},"./src/utils/ewma.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>D});var C=function(){function M(B,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=B,this.alpha_=B?Math.exp(Math.log(.5)/B):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=C},"./src/utils/fetch-loader.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>n,fetchSupported:()=>E});var C=_("./src/polyfills/number.ts"),D=_("./src/loader/load-stats.ts"),M=_("./src/demux/chunk-cache.ts");function P(v,l){v.prototype=Object.create(l.prototype),v.prototype.constructor=v,T(v,l)}function B(v){var l=typeof Map=="function"?new Map:void 0;return B=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}}),T(g,u)},B(v)}function b(v,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&&T(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(v){return Function.toString.call(v).indexOf("[native code]")!==-1}function T(v,l){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(u,g){return u.__proto__=g,u},T(v,l)}function x(v){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},x(v)}function f(){return f=Object.assign?Object.assign.bind():function(v){for(var l=1;l<arguments.length;l++){var i=arguments[l];for(var u in i)Object.prototype.hasOwnProperty.call(i,u)&&(v[u]=i[u])}return v},f.apply(this,arguments)}function E(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var p=function(){function v(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=v.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=h(u,this.controller.signal),t=c.onProgress,s=u.responseType==="arraybuffer",y=s?"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(d){if(m.response=m.loader=d,!d.ok){var L=d.status,R=d.statusText;throw new o(R||"fetch, bad network response",L,d)}return e.loading.first=Math.max(self.performance.now(),e.loading.start),e.total=parseInt(d.headers.get("Content-Length")||"0"),t&&(0,C.isFiniteNumber)(g.highWaterMark)?m.loadProgressively(d,e,u,g.highWaterMark,t):s?d.arrayBuffer():d.text()}).then(function(d){var L=m.response;self.clearTimeout(m.requestTimeout),e.loading.end=Math.max(self.performance.now(),e.loading.first);var R=d[y];R&&(e.loaded=e.total=R);var I={url:L.url,data:d};t&&!(0,C.isFiniteNumber)(g.highWaterMark)&&t(e,u,d,L),c.onSuccess(I,e,u,L)}).catch(function(d){if(self.clearTimeout(m.requestTimeout),!e.aborted){var L=d&&d.code||0,R=d?d.message:null;c.onError({code:L,text:R},u,d?d.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(),s=function y(){return t.read().then(function(d){if(d.done)return r.dataLength&&e(g,c,r.flush(),u),Promise.resolve(new ArrayBuffer(0));var L=d.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 s()},v}();function h(v,l){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:l,headers:new self.Headers(f({},v.headers))};return v.rangeEnd&&i.headers.set("Range","bytes="+v.rangeStart+"-"+String(v.rangeEnd-1)),i}function a(v,l){return new self.Request(v.url,l)}var o=function(v){P(l,v);function l(i,u,g){var c;return c=v.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=u,c.details=g,c}return l}(B(Error));let n=p},"./src/utils/hex.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>D});var C={hexDump:function(P){for(var B="",b=0;b<P.length;b++){var A=P[b].toString(16);A.length<2&&(A="0"+A),B+=A}return B}};let D=C},"./src/utils/imsc1-ttml-parser.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{IMSC1_CODEC:()=>S,parseIMSC1:()=>E});var C=_("./src/utils/mp4-tools.ts"),D=_("./src/utils/vttparser.ts"),M=_("./src/utils/vttcue.ts"),P=_("./src/demux/id3.ts"),B=_("./src/utils/timescale-conversion.ts"),b=_("./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",T=/^(\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 E(c,m,e,r,t){var s=(0,C.findBox)(new Uint8Array(c),["mdat"]);if(s.length===0){t(new Error("Could not parse IMSC1 mdat"));return}var y=s.map(function(L){return(0,P.utf8ArrayToStr)(L)}),d=(0,B.toTimescaleFromScale)(m,1,e);try{y.forEach(function(L){return r(p(L,d))})}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 s={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},y=Object.keys(s).reduce(function(k,F){return k[F]=t.getAttribute("ttp:"+F)||s[F],k},{}),d=t.getAttribute("xml:space")!=="preserve",L=a(h(t,"styling","style")),R=a(h(t,"layout","region")),I=h(t,"body","[begin]");return[].map.call(I,function(k){var F=o(k,d);if(!F||!k.hasAttribute("begin"))return null;var K=i(k.getAttribute("begin"),y),H=i(k.getAttribute("dur"),y),j=i(k.getAttribute("end"),y);if(K===null)throw l(k);if(j===null){if(H===null)throw l(k);j=K+H}var Y=new M.default(K-m,j-m,F);Y.id=(0,b.generateCueId)(Y.startTime,Y.endTime,Y.text);var J=R[k.getAttribute("region")],te=L[k.getAttribute("style")],ae=n(J,te,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 h(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 o(c,m){return[].slice.call(c.childNodes).reduce(function(e,r,t){var s;return r.nodeName==="br"&&t?e+`
|
|
23
|
-
`:(s=r.childNodes)!==null&&s!==void 0&&s.length?o(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,s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],y=c!=null&&c.hasAttribute("style")?c.getAttribute("style"):null;return y&&e.hasOwnProperty(y)&&(t=e[y]),s.reduce(function(d,L){var R=v(m,r,L)||v(c,r,L)||v(t,r,L);return R&&(d[L]=R),d},{})}function v(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&&(T.test(c)?e=u(c,m):x.test(c)&&(e=g(c,m))),e}function u(c,m){var e=T.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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{changeEndianness:()=>M,convertDataUriToArrayBytes:()=>P,strToUtf8array:()=>B});var C=_("./src/utils/numeric-encoding-utils.ts");function D(b){var A=B(b).subarray(0,16),S=new Uint8Array(16);return S.set(A,16-A.length),S}function M(b){var A=function(T,x,f){var E=T[x];T[x]=T[f],T[f]=E};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 T=A[1].split(";"),x=T[T.length-1].split(",");if(x.length===2){var f=x[0]==="base64",E=x[1];f?(T.splice(-1,1),S=(0,C.base64Decode)(E)):S=D(E)}}return S}function B(b){return Uint8Array.from(unescape(encodeURIComponent(b)),function(A){return A.charCodeAt(0)})}},"./src/utils/logger.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{enableLogs:()=>b,logger:()=>A});var C=function(){},D={trace:C,debug:C,log:C,warn:C,info:C,error:C},M=D;function P(S){var T=self.console[S];return T?T.bind(self.console,"["+S+"] >"):C}function B(S){for(var T=arguments.length,x=new Array(T>1?T-1:0),f=1;f<T;f++)x[f-1]=arguments[f];x.forEach(function(E){M[E]=S[E]?S[E].bind(S):P(E)})}function b(S,T){if(self.console&&S===!0||typeof S=="object"){B(S,"debug","log","info","warn","error");try{M.log('Debug logs enabled for "'+T+'"')}catch{M=D}}else M=D}var A=M},"./src/utils/mediakeys-helper.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{KeySystemFormats:()=>D,KeySystemIds:()=>P,KeySystems:()=>C,getKeySystemsForConfig:()=>A,getSupportedMediaKeySystemConfigurations:()=>T,keySystemDomainToKeySystemFormat:()=>b,keySystemFormatToKeySystemDomain:()=>M,keySystemIdToKeySystemDomain:()=>B,requestMediaKeySystemAccess:()=>S});var C;(function(f){f.CLEARKEY="org.w3.clearkey",f.FAIRPLAY="com.apple.fps",f.PLAYREADY="com.microsoft.playready",f.WIDEVINE="com.widevine.alpha"})(C||(C={}));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 C.FAIRPLAY;case D.PLAYREADY:return C.PLAYREADY;case D.WIDEVINE:return C.WIDEVINE;case D.CLEARKEY:return C.CLEARKEY}}var P;(function(f){f.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"})(P||(P={}));function B(f){if(f===P.WIDEVINE)return C.WIDEVINE}function b(f){switch(f){case C.FAIRPLAY:return D.FAIRPLAY;case C.PLAYREADY:return D.PLAYREADY;case C.WIDEVINE:return D.WIDEVINE;case C.CLEARKEY:return D.CLEARKEY}}function A(f){var E=f.drmSystems,p=f.widevineLicenseUrl,h=E?[C.FAIRPLAY,C.WIDEVINE,C.PLAYREADY,C.CLEARKEY].filter(function(a){return!!E[a]}):[];return!h[C.WIDEVINE]&&p&&h.push(C.WIDEVINE),h}var S=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function T(f,E,p,h){var a;switch(f){case C.FAIRPLAY:a=["cenc","sinf"];break;case C.WIDEVINE:case C.PLAYREADY:a=["cenc"];break;case C.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+f)}return x(a,E,p,h)}function x(f,E,p,h){var a={initDataTypes:f,persistentState:h.persistentState||"not-allowed",distinctiveIdentifier:h.distinctiveIdentifier||"not-allowed",sessionTypes:h.sessionTypes||[h.sessionType||"temporary"],audioCapabilities:E.map(function(o){return{contentType:'audio/mp4; codecs="'+o+'"',robustness:h.audioRobustness||"",encryptionScheme:h.audioEncryptionScheme||null}}),videoCapabilities:p.map(function(o){return{contentType:'video/mp4; codecs="'+o+'"',robustness:h.videoRobustness||"",encryptionScheme:h.videoEncryptionScheme||null}})};return[a]}},"./src/utils/mediasource-helper.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{getMediaSource:()=>C});function C(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{RemuxerTrackIdConfig:()=>S,appendUint8Array:()=>m,bin2str:()=>T,computeRawDurationFromSamples:()=>u,discardEPB:()=>y,findBox:()=>h,getDuration:()=>i,getStartDTS:()=>l,mp4Box:()=>L,mp4pssh:()=>R,offsetStartDTS:()=>g,parseEmsg:()=>d,parseInitSegment:()=>o,parsePssh:()=>I,parseSEIMessageFromNALu:()=>s,parseSamples:()=>e,parseSegmentIndex:()=>a,parseSinf:()=>v,patchEncyptionData:()=>n,readSint32:()=>E,readUint16:()=>x,readUint32:()=>f,segmentValidRange:()=>c,writeUint32:()=>p});var C=_("./src/loader/fragment.ts"),D=_("./src/utils/typed-array.ts"),M=_("./src/demux/id3.ts"),P=_("./src/utils/logger.ts"),B=_("./src/utils/hex.ts"),b=Math.pow(2,32)-1,A=[].push,S={video:1,audio:2,id3:3,text:4};function T(k){return String.fromCharCode.apply(null,k)}function x(k,F){var K=k[F]<<8|k[F+1];return K<0?65536+K:K}function f(k,F){var K=E(k,F);return K<0?4294967296+K:K}function E(k,F){return k[F]<<24|k[F+1]<<16|k[F+2]<<8|k[F+3]}function p(k,F,K){k[F]=K>>24,k[F+1]=K>>16&255,k[F+2]=K>>8&255,k[F+3]=K&255}function h(k,F){var K=[];if(!F.length)return K;for(var H=k.byteLength,j=0;j<H;){var Y=f(k,j),J=T(k.subarray(j+4,j+8)),te=Y>1?j+Y:H;if(J===F[0])if(F.length===1)K.push(k.subarray(j+8,te));else{var ae=h(k.subarray(j+8,te),F.slice(1));ae.length&&A.apply(K,ae)}j=te}return K}function a(k){var F=[],K=k[0],H=8,j=f(k,H);H+=4;var Y=0,J=0;K===0?H+=8:H+=16,H+=2;var te=k.length+J,ae=x(k,H);H+=2;for(var re=0;re<ae;re++){var se=H,ue=f(k,se);se+=4;var ce=ue&2147483647,le=(ue&2147483648)>>>31;if(le===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var de=f(k,se);se+=4,F.push({referenceSize:ce,subsegmentDuration:de,info:{duration:de/j,start:te,end:te+ce-1}}),te+=ce,se+=4,H=se}return{earliestPresentationTime:Y,timescale:j,version:K,referencesCount:ae,references:F}}function o(k){for(var F=[],K=h(k,["moov","trak"]),H=0;H<K.length;H++){var j=K[H],Y=h(j,["tkhd"])[0];if(Y){var J=Y[0],te=J===0?12:20,ae=f(Y,te),re=h(j,["mdia","mdhd"])[0];if(re){J=re[0],te=J===0?12:20;var se=f(re,te),ue=h(j,["mdia","hdlr"])[0];if(ue){var ce=T(ue.subarray(8,12)),le={soun:C.ElementaryStreamTypes.AUDIO,vide:C.ElementaryStreamTypes.VIDEO}[ce];if(le){var de=h(j,["mdia","minf","stbl","stsd"])[0],fe=void 0;de&&(fe=T(de.subarray(12,16))),F[ae]={timescale:se,type:le},F[le]={timescale:se,id:ae,codec:fe}}}}}}var Se=h(k,["moov","mvex","trex"]);return Se.forEach(function(be){var Oe=f(be,4),Re=F[Oe];Re&&(Re.default={duration:f(be,12),flags:f(be,20)})}),F}function n(k,F){if(!k||!F)return k;var K=F.keyId;if(K&&F.isCommonEncryption){var H=h(k,["moov","trak"]);H.forEach(function(j){var Y=h(j,["mdia","minf","stbl","stsd"])[0],J=Y.subarray(8),te=h(J,["enca"]),ae=te.length>0;ae||(te=h(J,["encv"])),te.forEach(function(re){var se=ae?re.subarray(28):re.subarray(78),ue=h(se,["sinf"]);ue.forEach(function(ce){var le=v(ce);if(le){var de=le.subarray(8,24);de.some(function(fe){return fe!==0})||(P.logger.log("[eme] Patching keyId in 'enc"+(ae?"a":"v")+">sinf>>tenc' box: "+B.default.hexDump(de)+" -> "+B.default.hexDump(K)),le.set(K,8))}})})})}return k}function v(k){var F=h(k,["schm"])[0];if(F){var K=T(F.subarray(4,8));if(K==="cbcs"||K==="cenc")return h(k,["schi","tenc"])[0]}return P.logger.error("[eme] missing 'schm' box"),null}function l(k,F){return h(F,["moof","traf"]).reduce(function(K,H){var j=h(H,["tfdt"])[0],Y=j[0],J=h(H,["tfhd"]).reduce(function(te,ae){var re=f(ae,4),se=k[re];if(se){var ue=f(j,4);Y===1&&(ue*=Math.pow(2,32),ue+=f(j,8));var ce=se.timescale||9e4,le=ue/ce;if(isFinite(le)&&(te===null||le<te))return le}return te},null);return J!==null&&isFinite(J)&&(K===null||J<K)?J:K},null)||0}function i(k,F){for(var K=0,H=0,j=0,Y=h(k,["moof","traf"]),J=0;J<Y.length;J++){var te=Y[J],ae=h(te,["tfhd"])[0],re=f(ae,4),se=F[re];if(!!se){var ue=se.default,ce=f(ae,0)|(ue==null?void 0:ue.flags),le=ue==null?void 0:ue.duration;ce&8&&(ce&2?le=f(ae,12):le=f(ae,8));for(var de=se.timescale||9e4,fe=h(te,["trun"]),Se=0;Se<fe.length;Se++){if(K=u(fe[Se]),!K&&le){var be=f(fe[Se],4);K=le*be}se.type===C.ElementaryStreamTypes.VIDEO?H+=K/de:se.type===C.ElementaryStreamTypes.AUDIO&&(j+=K/de)}}}if(H===0&&j===0){for(var Oe=0,Re=h(k,["sidx"]),Ce=0;Ce<Re.length;Ce++){var Pe=a(Re[Ce]);Pe!=null&&Pe.references&&(Oe+=Pe.references.reduce(function(Me,De){return Me+De.info.duration||0},0))}return Oe}return H||j}function u(k){var F=f(k,0),K=8;F&1&&(K+=4),F&4&&(K+=4);for(var H=0,j=f(k,4),Y=0;Y<j;Y++){if(F&256){var J=f(k,K);H+=J,K+=4}F&512&&(K+=4),F&1024&&(K+=4),F&2048&&(K+=4)}return H}function g(k,F,K){h(F,["moof","traf"]).forEach(function(H){h(H,["tfhd"]).forEach(function(j){var Y=f(j,4),J=k[Y];if(!!J){var te=J.timescale||9e4;h(H,["tfdt"]).forEach(function(ae){var re=ae[0],se=f(ae,4);if(re===0)se-=K*te,se=Math.max(se,0),p(ae,4,se);else{se*=Math.pow(2,32),se+=f(ae,8),se-=K*te,se=Math.max(se,0);var ue=Math.floor(se/(b+1)),ce=Math.floor(se%(b+1));p(ae,4,ue),p(ae,8,ce)}})}})})}function c(k){var F={valid:null,remainder:null},K=h(k,["moof"]);if(K){if(K.length<2)return F.remainder=k,F}else return F;var H=K[K.length-1];return F.valid=(0,D.sliceUint8)(k,0,H.byteOffset-8),F.remainder=(0,D.sliceUint8)(k,H.byteOffset-8),F}function m(k,F){var K=new Uint8Array(k.length+F.length);return K.set(k),K.set(F,k.length),K}function e(k,F){var K=[],H=F.samples,j=F.timescale,Y=F.id,J=!1,te=h(H,["moof"]);return te.map(function(ae){var re=ae.byteOffset-8,se=h(ae,["traf"]);se.map(function(ue){var ce=h(ue,["tfdt"]).map(function(le){var de=le[0],fe=f(le,4);return de===1&&(fe*=Math.pow(2,32),fe+=f(le,8)),fe/j})[0];return ce!==void 0&&(k=ce),h(ue,["tfhd"]).map(function(le){var de=f(le,4),fe=f(le,0)&16777215,Se=(fe&1)!==0,be=(fe&2)!==0,Oe=(fe&8)!==0,Re=0,Ce=(fe&16)!==0,Pe=0,Me=(fe&32)!==0,De=8;de===Y&&(Se&&(De+=8),be&&(De+=4),Oe&&(Re=f(le,De),De+=4),Ce&&(Pe=f(le,De),De+=4),Me&&(De+=4),F.type==="video"&&(J=r(F.codec)),h(ue,["trun"]).map(function(Fe){var Ne=Fe[0],ke=f(Fe,0)&16777215,Xe=(ke&1)!==0,ze=0,rt=(ke&4)!==0,Qe=(ke&256)!==0,it=0,nt=(ke&512)!==0,Je=0,Ke=(ke&1024)!==0,We=(ke&2048)!==0,Ze=0,ct=f(Fe,4),we=8;Xe&&(ze=f(Fe,we),we+=4),rt&&(we+=4);for(var qe=ze+re,et=0;et<ct;et++){if(Qe?(it=f(Fe,we),we+=4):it=Re,nt?(Je=f(Fe,we),we+=4):Je=Pe,Ke&&(we+=4),We&&(Ne===0?Ze=f(Fe,we):Ze=E(Fe,we),we+=4),F.type===C.ElementaryStreamTypes.VIDEO)for(var At=0;At<Je;){var St=f(H,qe);if(qe+=4,t(J,H[qe])){var xt=H.subarray(qe,qe+St);s(xt,J?2:1,k+Ze/j,K)}qe+=St,At+=St+4}k+=it/j}}))})})}),K}function r(k){if(!k)return!1;var F=k.indexOf("."),K=F<0?k:k.substring(0,F);return K==="hvc1"||K==="hev1"||K==="dvh1"||K==="dvhe"}function t(k,F){if(k){var K=F>>1&63;return K===39||K===40}else{var H=F&31;return H===6}}function s(k,F,K,H){var j=y(k),Y=0;Y+=F;for(var J=0,te=0,ae=!1,re=0;Y<j.length;){J=0;do{if(Y>=j.length)break;re=j[Y++],J+=re}while(re===255);te=0;do{if(Y>=j.length)break;re=j[Y++],te+=re}while(re===255);var se=j.length-Y;if(!ae&&J===4&&Y<j.length){ae=!0;var ue=j[Y++];if(ue===181){var ce=x(j,Y);if(Y+=2,ce===49){var le=f(j,Y);if(Y+=4,le===1195456820){var de=j[Y++];if(de===3){var fe=j[Y++],Se=31&fe,be=64&fe,Oe=be?2+Se*3:0,Re=new Uint8Array(Oe);if(be){Re[0]=fe;for(var Ce=1;Ce<Oe;Ce++)Re[Ce]=j[Y++]}H.push({type:de,payloadType:J,pts:K,bytes:Re})}}}}}else if(J===5&&te<se){if(ae=!0,te>16){for(var Pe=[],Me=0;Me<16;Me++){var De=j[Y++].toString(16);Pe.push(De.length==1?"0"+De:De),(Me===3||Me===5||Me===7||Me===9)&&Pe.push("-")}for(var Fe=te-16,Ne=new Uint8Array(Fe),ke=0;ke<Fe;ke++)Ne[ke]=j[Y++];H.push({payloadType:J,pts:K,uuid:Pe.join(""),userData:(0,M.utf8ArrayToStr)(Ne),userDataBytes:Ne})}}else if(te<se)Y+=te;else if(te>se)break}}function y(k){for(var F=k.byteLength,K=[],H=1;H<F-2;)k[H]===0&&k[H+1]===0&&k[H+2]===3?(K.push(H+2),H+=2):H++;if(K.length===0)return k;var j=F-K.length,Y=new Uint8Array(j),J=0;for(H=0;H<j;J++,H++)J===K[0]&&(J++,K.shift()),Y[H]=k[J];return Y}function d(k){var F=k[0],K="",H="",j=0,Y=0,J=0,te=0,ae=0,re=0;if(F===0){for(;T(k.subarray(re,re+1))!=="\0";)K+=T(k.subarray(re,re+1)),re+=1;for(K+=T(k.subarray(re,re+1)),re+=1;T(k.subarray(re,re+1))!=="\0";)H+=T(k.subarray(re,re+1)),re+=1;H+=T(k.subarray(re,re+1)),re+=1,j=f(k,12),Y=f(k,16),te=f(k,20),ae=f(k,24),re=28}else if(F===1){re+=4,j=f(k,re),re+=4;var se=f(k,re);re+=4;var ue=f(k,re);for(re+=4,J=Math.pow(2,32)*se+ue,Number.isSafeInteger(J)||(J=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),te=f(k,re),re+=4,ae=f(k,re),re+=4;T(k.subarray(re,re+1))!=="\0";)K+=T(k.subarray(re,re+1)),re+=1;for(K+=T(k.subarray(re,re+1)),re+=1;T(k.subarray(re,re+1))!=="\0";)H+=T(k.subarray(re,re+1)),re+=1;H+=T(k.subarray(re,re+1)),re+=1}var ce=k.subarray(re,k.byteLength);return{schemeIdUri:K,value:H,timeScale:j,presentationTime:J,presentationTimeDelta:Y,eventDuration:te,id:ae,payload:ce}}function L(k){for(var F=arguments.length,K=new Array(F>1?F-1:0),H=1;H<F;H++)K[H-1]=arguments[H];for(var j=K.length,Y=8,J=j;J--;)Y+=K[J].byteLength;var te=new Uint8Array(Y);for(te[0]=Y>>24&255,te[1]=Y>>16&255,te[2]=Y>>8&255,te[3]=Y&255,te.set(k,4),J=0,Y=8;J<j;J++)te.set(K[J],Y),Y+=K[J].byteLength;return te}function R(k,F,K){if(k.byteLength!==16)throw new RangeError("Invalid system id");var H,j;if(F){H=1,j=new Uint8Array(F.length*16);for(var Y=0;Y<F.length;Y++){var J=F[Y];if(J.byteLength!==16)throw new RangeError("Invalid key");j.set(J,Y*16)}}else H=0,j=new Uint8Array;var te;H>0?(te=new Uint8Array(4),F.length>0&&new DataView(te.buffer).setUint32(0,F.length,!1)):te=new Uint8Array;var ae=new Uint8Array(4);return K&&K.byteLength>0&&new DataView(ae.buffer).setUint32(0,K.byteLength,!1),L([112,115,115,104],new Uint8Array([H,0,0,0]),k,te,j,ae,K||new Uint8Array)}function I(k){if(!(k instanceof ArrayBuffer)||k.byteLength<32)return null;var F={version:0,systemId:"",kids:null,data:null},K=new DataView(k),H=K.getUint32(0);if(k.byteLength!==H&&H>44)return null;var j=K.getUint32(4);if(j!==1886614376||(F.version=K.getUint32(8)>>>24,F.version>1))return null;F.systemId=B.default.hexDump(new Uint8Array(k,12,16));var Y=K.getUint32(28);if(F.version===0){if(H-32<Y)return null;F.data=new Uint8Array(k,32,Y)}else if(F.version===1){F.kids=[];for(var J=0;J<Y;J++)F.kids.push(new Uint8Array(k,32+J*16,16))}return F}},"./src/utils/numeric-encoding-utils.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{base64Decode:()=>b,base64DecodeToStr:()=>M,base64Encode:()=>P,base64ToBase64Url:()=>C,base64UrlEncode:()=>B,strToBase64Encode:()=>D});function C(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 B(A){return C(P(A))}function b(A){return Uint8Array.from(atob(A),function(S){return S.charCodeAt(0)})}},"./src/utils/output-filter.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>C});var C=function(){function D(P,B){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=P,this.trackName=B}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(B,b,A){(this.startTime===null||this.startTime>B)&&(this.startTime=B),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":(z,N,_)=>{"use strict";_.r(N),_.d(N,{addCueToTrack:()=>M,clearCurrentCues:()=>P,getCuesInRange:()=>A,removeCuesInRange:()=>B,sendAddTrackEvent:()=>D});var C=_("./src/utils/logger.ts");function D(S,T){var x;try{x=new Event("addtrack")}catch{x=document.createEvent("Event"),x.initEvent("addtrack",!1,!1)}x.track=S,T.dispatchEvent(x)}function M(S,T){var x=S.mode;if(x==="disabled"&&(S.mode="hidden"),S.cues&&!S.cues.getCueById(T.id))try{if(S.addCue(T),!S.cues.getCueById(T.id))throw new Error("addCue is failed for: "+T)}catch(E){C.logger.debug("[texttrack-utils]: "+E);var f=new self.TextTrackCue(T.startTime,T.endTime,T.text);f.id=T.id,S.addCue(f)}x==="disabled"&&(S.mode=x)}function P(S){var T=S.mode;if(T==="disabled"&&(S.mode="hidden"),S.cues)for(var x=S.cues.length;x--;)S.removeCue(S.cues[x]);T==="disabled"&&(S.mode=T)}function B(S,T,x,f){var E=S.mode;if(E==="disabled"&&(S.mode="hidden"),S.cues&&S.cues.length>0)for(var p=A(S.cues,T,x),h=0;h<p.length;h++)(!f||f(p[h]))&&S.removeCue(p[h]);E==="disabled"&&(S.mode=E)}function b(S,T){if(T<S[0].startTime)return 0;var x=S.length-1;if(T>S[x].endTime)return-1;for(var f=0,E=x;f<=E;){var p=Math.floor((E+f)/2);if(T<S[p].startTime)E=p-1;else if(T>S[p].startTime&&f<x)f=p+1;else return p}return S[f].startTime-T<T-S[E].startTime?f:E}function A(S,T,x){var f=[],E=b(S,T);if(E>-1)for(var p=E,h=S.length;p<h;p++){var a=S[p];if(a.startTime>=T&&a.endTime<=x)f.push(a);else if(a.startTime>x)return f}return f}},"./src/utils/time-ranges.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>D});var C={toString:function(P){for(var B="",b=P.length,A=0;A<b;A++)B+="["+P.start(A).toFixed(3)+","+P.end(A).toFixed(3)+"]";return B}};let D=C},"./src/utils/timescale-conversion.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{toMpegTsClockFromTimescale:()=>B,toMsFromMpegTsClock:()=>P,toTimescaleFromBase:()=>D,toTimescaleFromScale:()=>M});var C=9e4;function D(b,A,S,T){S===void 0&&(S=1),T===void 0&&(T=!1);var x=b*A*S;return T?Math.round(x):x}function M(b,A,S,T){return S===void 0&&(S=1),T===void 0&&(T=!1),D(b,A,1/S,T)}function P(b,A){return A===void 0&&(A=!1),D(b,1e3,1/C,A)}function B(b,A){return A===void 0&&(A=1),D(b,C,1/A)}},"./src/utils/typed-array.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{sliceUint8:()=>C});function C(D,M,P){return Uint8Array.prototype.slice?D.slice(M,P):new Uint8Array(Array.prototype.slice.call(D,M,P))}},"./src/utils/vttcue.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>C});let C=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var D=["","lr","rl"],M=["start","middle","end","left","right"];function P(T,x){if(typeof x!="string"||!Array.isArray(T))return!1;var f=x.toLowerCase();return~T.indexOf(f)?f:!1}function B(T){return P(D,T)}function b(T){return P(M,T)}function A(T){for(var x=arguments.length,f=new Array(x>1?x-1:0),E=1;E<x;E++)f[E-1]=arguments[E];for(var p=1;p<arguments.length;p++){var h=arguments[p];for(var a in h)T[a]=h[a]}return T}function S(T,x,f){var E=this,p={enumerable:!0};E.hasBeenReset=!1;var h="",a=!1,o=T,n=x,v=f,l=null,i="",u=!0,g="auto",c="start",m=50,e="middle",r=50,t="middle";Object.defineProperty(E,"id",A({},p,{get:function(){return h},set:function(y){h=""+y}})),Object.defineProperty(E,"pauseOnExit",A({},p,{get:function(){return a},set:function(y){a=!!y}})),Object.defineProperty(E,"startTime",A({},p,{get:function(){return o},set:function(y){if(typeof y!="number")throw new TypeError("Start time must be set to a number.");o=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"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(E,"text",A({},p,{get:function(){return v},set:function(y){v=""+y,this.hasBeenReset=!0}})),Object.defineProperty(E,"region",A({},p,{get:function(){return l},set:function(y){l=y,this.hasBeenReset=!0}})),Object.defineProperty(E,"vertical",A({},p,{get:function(){return i},set:function(y){var d=B(y);if(d===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=d,this.hasBeenReset=!0}})),Object.defineProperty(E,"snapToLines",A({},p,{get:function(){return u},set:function(y){u=!!y,this.hasBeenReset=!0}})),Object.defineProperty(E,"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(E,"lineAlign",A({},p,{get:function(){return c},set:function(y){var d=b(y);if(!d)throw new SyntaxError("An invalid or illegal string was specified.");c=d,this.hasBeenReset=!0}})),Object.defineProperty(E,"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(E,"positionAlign",A({},p,{get:function(){return e},set:function(y){var d=b(y);if(!d)throw new SyntaxError("An invalid or illegal string was specified.");e=d,this.hasBeenReset=!0}})),Object.defineProperty(E,"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(E,"align",A({},p,{get:function(){return t},set:function(y){var d=b(y);if(!d)throw new SyntaxError("An invalid or illegal string was specified.");t=d,this.hasBeenReset=!0}})),E.displayState=void 0}return S.prototype.getCueAsHTML=function(){var T=self.WebVTT;return T.convertCueToDOMTree(self,this.text)},S}()},"./src/utils/vttparser.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{VTTParser:()=>x,fixLineBreaks:()=>T,parseTimeStamp:()=>M});var C=_("./src/utils/vttcue.ts"),D=function(){function f(){}var E=f.prototype;return E.decode=function(h,a){if(!h)return"";if(typeof h!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(h))},f}();function M(f){function E(h,a,o,n){return(h|0)*3600+(a|0)*60+(o|0)+parseFloat(n||0)}var p=f.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return p?parseFloat(p[2])>59?E(p[2],p[3],0,p[4]):E(p[1],p[2],p[3],p[4]):null}var P=function(){function f(){this.values=Object.create(null)}var E=f.prototype;return E.set=function(h,a){!this.get(h)&&a!==""&&(this.values[h]=a)},E.get=function(h,a,o){return o?this.has(h)?this.values[h]:a[o]:this.has(h)?this.values[h]:a},E.has=function(h){return h in this.values},E.alt=function(h,a,o){for(var n=0;n<o.length;++n)if(a===o[n]){this.set(h,a);break}},E.integer=function(h,a){/^-?\d+$/.test(a)&&this.set(h,parseInt(a,10))},E.percent=function(h,a){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(a)){var o=parseFloat(a);if(o>=0&&o<=100)return this.set(h,o),!0}return!1},f}();function B(f,E,p,h){var a=h?f.split(h):[f];for(var o in a)if(typeof a[o]=="string"){var n=a[o].split(p);if(n.length===2){var v=n[0],l=n[1];E(v,l)}}}var b=new C.default(0,0,""),A=b.align==="middle"?"middle":"center";function S(f,E,p){var h=f;function a(){var v=M(f);if(v===null)throw new Error("Malformed timestamp: "+h);return f=f.replace(/^[^\sa-zA-Z-]+/,""),v}function o(v,l){var i=new P;B(v,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(),E.startTime=a(),n(),f.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+h);f=f.slice(3),n(),E.endTime=a(),n(),o(f,E)}function T(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){B(g,function(c,m){},/:/)}try{var v="";if(a.state==="INITIAL"){if(!/\r\n|\n/.test(a.buffer))return this;v=o();var l=v.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:v=o(),a.state){case"HEADER":/:/.test(v)?n(v):v||(a.state="ID");continue;case"NOTE":v||(a.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(v)){a.state="NOTE";break}if(!v)continue;if(a.cue=new C.default(0,0,""),a.state="CUE",v.indexOf("-->")===-1){a.cue.id=v;continue}case"CUE":if(!a.cue){a.state="BADCUE";continue}try{S(v,a.cue,a.regionList)}catch{a.cue=null,a.state="BADCUE";continue}a.state="CUETEXT";continue;case"CUETEXT":{var u=v.indexOf("-->")!==-1;if(!v||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+=v}continue;case"BADCUE":v||(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},E.flush=function(){var h=this;try{if((h.cue||h.state==="HEADER")&&(h.buffer+=`
|
|
1
|
+
var vs=Object.create;var Ta=Object.defineProperty;var gs=Object.getOwnPropertyDescriptor;var ps=Object.getOwnPropertyNames;var ms=Object.getPrototypeOf,ys=Object.prototype.hasOwnProperty;var ba=(M,X)=>()=>(X||M((X={exports:{}}).exports,X),X.exports);var Es=(M,X,x,fe)=>{if(X&&typeof X=="object"||typeof X=="function")for(let oe of ps(X))!ys.call(M,oe)&&oe!==x&&Ta(M,oe,{get:()=>X[oe],enumerable:!(fe=gs(X,oe))||fe.enumerable});return M};var _a=(M,X,x)=>(x=M!=null?vs(ms(M)):{},Es(X||!M||!M.__esModule?Ta(x,"default",{value:M,enumerable:!0}):x,M));var Kn=(M,X,x)=>{if(!X.has(M))throw TypeError("Cannot "+x)};var pr=(M,X,x)=>(Kn(M,X,"read from private field"),x?x.call(M):X.get(M)),Lr=(M,X,x)=>{if(X.has(M))throw TypeError("Cannot add the same private member more than once");X instanceof WeakSet?X.add(M):X.set(M,x)},Rr=(M,X,x,fe)=>(Kn(M,X,"write to private field"),fe?fe.call(M,x):X.set(M,x),x);var ii=(M,X,x)=>(Kn(M,X,"access private method"),x);var ka=ba((cn,Yn)=>{(function(){var M,X;M=this,X=function(){return function(){var x={80:function(Q,N,j){Q.exports=j(728).default},728:function(Q,N,j){"use strict";j.d(N,{default:function(){return Ln}});var te=j(48),R=j.n(te),p=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(g){var h=16*Math.random()|0;return(g==="x"?h:3&h|8).toString(16)})},w=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},k=function(g){return g&&g.nodeName!==void 0?(g.muxId||(g.muxId=g.id||w()),g.muxId):g},me=function(g){var h;g&&g.nodeName!==void 0?g=k(h=g):h=document.querySelector(g);var f=h&&h.nodeName?h.nodeName.toLowerCase():"";return[h,g,f]},re=j(640),de=j.n(re),_e=de().methodFactory;de().methodFactory=function(g,h,f){var y=_e(g,h,f);return function(){for(var b=["[mux]"],O=0;O<arguments.length;O++)b.push(arguments[O]);y.apply(void 0,b)}},de().setLevel(de().getLevel());var K=de();function ve(){return(R().doNotTrack||R().navigator&&R().navigator.doNotTrack)==="1"}var $={now:function(){var g=R().performance,h=g&&g.timing,f=h&&h.navigationStart,y=typeof f=="number"&&typeof g.now=="function"?f+g.now():Date.now();return Math.round(y)}},ae=j(678),G=j.n(ae),Se=function(g){return ke(g)[0]},ke=function(g){if(typeof g!="string"||g==="")return["localhost"];var h,f=(g.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)||[])[4];return f&&(h=(f.match(/[^\.]+\.[^\.]+$/)||[])[0]),[f,h]},je={exists:function(){var g=R().performance;return(g&&g.timing)!==void 0},domContentLoadedEventEnd:function(){var g=R().performance,h=g&&g.timing;return h&&h.domContentLoadedEventEnd},navigationStart:function(){var g=R().performance,h=g&&g.timing;return h&&h.navigationStart}};function V(g,h,f){f=f===void 0?1:f,g[h]=g[h]||0,g[h]+=f}var E=["x-cdn","content-type","x-request-id"];function U(g){var h={};return(g=g||"").trim().split(/[\r\n]+/).forEach(function(f){if(f){var y=f.split(": "),b=y.shift();b&&(E.indexOf(b.toLowerCase())>=0||b.toLowerCase().indexOf("x-litix-")===0)&&(h[b]=y.join(": "))}}),h}var A=function(g){var h={};for(var f in g){var y=g[f];y["DATA-ID"].search("io.litix.data.")!==-1&&(h[y["DATA-ID"].replace("io.litix.data.","")]=y.VALUE)}return h};function ue(g,h){var f=Object.keys(g);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(g);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(g,b).enumerable})),f.push.apply(f,y)}return f}function Te(g){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?ue(Object(f),!0).forEach(function(y){J(g,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(f)):ue(Object(f)).forEach(function(y){Object.defineProperty(g,y,Object.getOwnPropertyDescriptor(f,y))})}return g}function J(g,h,f){return h in g?Object.defineProperty(g,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):g[h]=f,g}var W=function(g){if(!g)return{};var h=je.navigationStart(),f=g.loading,y=f?f.start:g.trequest,b=f?f.first:g.tfirst,O=f?f.end:g.tload;return{bytesLoaded:g.total,requestStart:Math.round(h+y),responseStart:Math.round(h+b),responseEnd:Math.round(h+O)}},De=function(g){if(g&&typeof g.getAllResponseHeaders=="function")return U(g.getAllResponseHeaders())};function Re(g,h){var f=Object.keys(g);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(g);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(g,b).enumerable})),f.push.apply(f,y)}return f}function Oe(g){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?Re(Object(f),!0).forEach(function(y){ye(g,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(f)):Re(Object(f)).forEach(function(y){Object.defineProperty(g,y,Object.getOwnPropertyDescriptor(f,y))})}return g}function ye(g,h,f){return h in g?Object.defineProperty(g,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):g[h]=f,g}var qe=function(g,h){if(!g||typeof g.getRequests!="function")return{};var f=g.getRequests({state:"executed"});if(f.length===0)return{};var y,b=f[f.length-1],O=Se(b.url),D=b.url,H=b.bytesLoaded,le=new Date(b.requestStartDate).getTime(),Z=new Date(b.firstByteDate).getTime(),Ce=new Date(b.requestEndDate).getTime(),at=isNaN(b.duration)?0:b.duration,Je=typeof h.getMetricsFor=="function"?h.getMetricsFor(b.mediaType).HttpList:h.getDashMetrics().getHttpRequests(b.mediaType);return Je.length>0&&(y=U(Je[Je.length-1]._responseHeaders||"")),{requestStart:le,requestResponseStart:Z,requestResponseEnd:Ce,requestBytesLoaded:H,requestResponseHeaders:y,requestMediaDuration:at,requestHostname:O,requestUrl:D}},tt=function(g,h){var f=h.getQualityFor(g),y=h.getCurrentTrackFor(g).bitrateList;return y?{currentLevel:f,renditionWidth:y[f].width||null,renditionHeight:y[f].height||null,renditionBitrate:y[f].bandwidth}:{}},ie=function(g){var h;return(h=g.match(/.*codecs\*?="(.*)"/))===null||h===void 0?void 0:h[1]};function ce(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var ne=0,xe=function(){function g(){(function(b,O){if(!(b instanceof O))throw new TypeError("Cannot call a class as a function")})(this,g)}var h,f,y;return h=g,f=[{key:"on",value:function(b,O,D){return O._eventEmitterGuid=O._eventEmitterGuid||++ne,this._listeners=this._listeners||{},this._listeners[b]=this._listeners[b]||[],D&&(O=O.bind(D)),this._listeners[b].push(O),O}},{key:"off",value:function(b,O){var D=this._listeners&&this._listeners[b];D&&D.forEach(function(H,le){H._eventEmitterGuid===O._eventEmitterGuid&&D.splice(le,1)})}},{key:"one",value:function(b,O,D){var H=this;O._eventEmitterGuid=O._eventEmitterGuid||++ne;var le=function Z(){H.off(b,Z),O.apply(D||this,arguments)};le._eventEmitterGuid=O._eventEmitterGuid,this.on(b,le)}},{key:"emit",value:function(b,O){var D=this;if(this._listeners){O=O||{};var H=this._listeners["before*"]||[],le=this._listeners[b]||[],Z=this._listeners["after"+b]||[],Ce=function(at,Je){(at=at.slice()).forEach(function(it){it.call(D,{type:b},Je)})};Ce(H,O),Ce(le,O),Ce(Z,O)}}}],f&&ce(h.prototype,f),y&&ce(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}(),Pe=xe;function Ne(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Be=function(){function g(b){var O=this;(function(D,H){if(!(D instanceof H))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,b.on("playing",function(){O._playheadShouldBeProgressing=!0}),b.on("play",this._startPlaybackHeartbeatInterval.bind(this)),b.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),b.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),b.on("seeking",this._startPlaybackHeartbeatInterval.bind(this)),b.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),b.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),b.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),b.on("seeked",function(){b.data.player_is_paused?O._stopPlaybackHeartbeatInterval():O._startPlaybackHeartbeatInterval()}),b.on("timeupdate",function(){O._playbackHeartbeatInterval!==null&&b.emit("playbackheartbeat")}),b.on("devicesleep",function(D,H){O._playbackHeartbeatInterval!==null&&(R().clearInterval(O._playbackHeartbeatInterval),b.emit("playbackheartbeatend",{viewer_time:H.viewer_time}),O._playbackHeartbeatInterval=null)})}var h,f,y;return h=g,(f=[{key:"_startPlaybackHeartbeatInterval",value:function(){var b=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=R().setInterval(function(){b.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(R().clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}])&&Ne(h.prototype,f),y&&Ne(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function Ke(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function pe(g,h,f){return h&&Ke(g.prototype,h),f&&Ke(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var Ie=pe(function g(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,g),h.on("viewinit",function(){f.viewErrored=!1}),h.on("error",function(y,b){try{var O=h.errorTranslator({player_error_code:b.player_error_code,player_error_message:b.player_error_message,player_error_context:b.player_error_context});O?(h.data.player_error_code=O.player_error_code||b.player_error_code,h.data.player_error_message=O.player_error_message||b.player_error_message,h.data.player_error_context=O.player_error_context||b.player_error_context,f.viewErrored=!0):(delete h.data.player_error_code,delete h.data.player_error_message,delete h.data.player_error_context)}catch(D){h.mux.log.warn("Exception in error translator callback.",D),f.viewErrored=!0}})});function Ye(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var rt=function(){function g(b){(function(O,D){if(!(O instanceof D))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,this._watchTimeTrackerLastCheckedTime=null,b.on("playbackheartbeat",this._updateWatchTime.bind(this)),b.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}var h,f,y;return h=g,(f=[{key:"_updateWatchTime",value:function(b,O){var D=O.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=D),V(this.pm.data,"view_watch_time",D-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=D}},{key:"_clearWatchTimeState",value:function(b,O){this._updateWatchTime(b,O),this._watchTimeTrackerLastCheckedTime=null}}])&&Ye(h.prototype,f),y&&Ye(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function yt(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var ht=function(){function g(b){(function(O,D){if(!(O instanceof D))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,this._playbackTimeTrackerLastPlayheadPosition=-1,b.on("playbackheartbeat",this._updatePlaybackTime.bind(this)),b.on("playbackheartbeatend",this._clearPlaybackTimeState.bind(this)),b.on("seeking",this._clearPlaybackTimeState.bind(this))}var h,f,y;return h=g,(f=[{key:"_updatePlaybackTime",value:function(){var b=this.pm.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&b>this._playbackTimeTrackerLastPlayheadPosition){var O=b-this._playbackTimeTrackerLastPlayheadPosition;O<=1e3&&V(this.pm.data,"view_content_playback_time",O)}this._playbackTimeTrackerLastPlayheadPosition=b}},{key:"_clearPlaybackTimeState",value:function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1}}])&&yt(h.prototype,f),y&&yt(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function It(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Lt=function(){function g(b){(function(D,H){if(!(D instanceof H))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b;var O=this._updatePlayheadTime.bind(this);b.on("playbackheartbeat",O),b.on("playbackheartbeatend",O),b.on("timeupdate",O),b.on("destroy",function(){b.off("timeupdate",O)})}var h,f,y;return h=g,(f=[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=this.pm.data.view_max_playhead_position===void 0?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(b,O){var D=this,H=function(){D.pm.currentFragmentPDT&&D.pm.currentFragmentStart&&(D.pm.data.player_program_time=D.pm.currentFragmentPDT+D.pm.data.player_playhead_time-D.pm.currentFragmentStart)};if(O&&O.player_playhead_time)this.pm.data.player_playhead_time=O.player_playhead_time,H(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var le=this.pm.getPlayheadTime();le!==void 0&&(this.pm.data.player_playhead_time=le,H(),this._updateMaxPlayheadPosition())}}}])&&It(h.prototype,f),y&&It(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function St(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function At(g,h,f){return h&&St(g.prototype,h),f&&St(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var pt=At(function g(h){if(function(O,D){if(!(O instanceof D))throw new TypeError("Cannot call a class as a function")}(this,g),!h.disableRebufferTracking){var f,y=function(O,D){b(D),f=void 0},b=function(O){if(f){var D=O.viewer_time-f;V(h.data,"view_rebuffer_duration",D),f=O.viewer_time}h.data.view_watch_time>=0&&h.data.view_rebuffer_count>0&&(h.data.view_rebuffer_frequency=h.data.view_rebuffer_count/h.data.view_watch_time,h.data.view_rebuffer_percentage=h.data.view_rebuffer_duration/h.data.view_watch_time)};h.on("playbackheartbeat",function(O,D){return b(D)}),h.on("rebufferstart",function(O,D){f||(V(h.data,"view_rebuffer_count",1),f=D.viewer_time,h.one("rebufferend",y))}),h.on("viewinit",function(){f=void 0,h.off("rebufferend",y)})}});function ut(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Rt=function(){function g(b){var O=this;(function(D,H){if(!(D instanceof H))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,b.disableRebufferTracking||b.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,b.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),b.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),b.on("seeking",function(){O._cleanupRebufferTracker(null,{viewer_time:$.now()})}))}var h,f,y;return h=g,f=[{key:"_checkIfRebuffering",value:function(b,O){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing)this._cleanupRebufferTracker(b,O);else if(this._lastCheckedTime!==null)if(this._lastPlayheadTime===this.pm.data.player_playhead_time){var D=O.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&D>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=O.viewer_time}else this._cleanupRebufferTracker(b,O,!0);else this._prepareRebufferTrackerState(O.viewer_time)}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(b){this._lastCheckedTime=b,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=b}},{key:"_cleanupRebufferTracker",value:function(b,O){var D=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:O.viewer_time});else{if(this._lastCheckedTime===null)return;var H=this.pm.data.player_playhead_time-this._lastPlayheadTime,le=O.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&H>0&&le-H>this.pm.minimumRebufferDuration&&(this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+le-H}))}D?this._prepareRebufferTrackerState(O.viewer_time):this._clearRebufferTrackerState()}}],f&&ut(h.prototype,f),y&&ut(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}(),Ct=Rt;function Ht(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var Qt=function(){function g(b){var O=this;(function(D,H){if(!(D instanceof H))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,b.on("viewinit",function(){var D=b.data,H=D.view_id;if(!D.view_program_changed){var le=function(Z,Ce){var at=Ce.viewer_time;Z.type==="playing"&&b.data.view_time_to_first_frame===void 0?O.calculateTimeToFirstFrame(at||$.now(),H):Z.type!=="adplaying"||b.data.view_time_to_first_frame!==void 0&&!O._inPrerollPosition()||O.calculateTimeToFirstFrame(at||$.now(),H)};b.one("playing",le),b.one("adplaying",le),b.one("viewend",function(){b.off("playing",le),b.off("adplaying",le)})}})}var h,f,y;return h=g,(f=[{key:"_inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(b,O){O===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:b}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}])&&Ht(h.prototype,f),y&&Ht(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function Ut(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function ur(g,h,f){return h&&Ut(g.prototype,h),f&&Ut(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var ee=ur(function g(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,g),h.on("viewinit",function(){f._lastPlayheadPosition=-1}),["pause","rebufferstart","seeking","error","adbreakstart","hb"].forEach(function(y){h.on(y,function(){if(f._lastPlayheadPosition>=0&&h.data.player_playhead_time>=0&&f._lastPlayerWidth>=0&&f._lastSourceWidth>0&&f._lastPlayerHeight>=0&&f._lastSourceHeight>0){var b=h.data.player_playhead_time-f._lastPlayheadPosition;if(b<0)return void(f._lastPlayheadPosition=-1);var O=Math.min(f._lastPlayerWidth/f._lastSourceWidth,f._lastPlayerHeight/f._lastSourceHeight),D=Math.max(0,O-1),H=Math.max(0,1-O);h.data.view_max_upscale_percentage=Math.max(h.data.view_max_upscale_percentage||0,D),h.data.view_max_downscale_percentage=Math.max(h.data.view_max_downscale_percentage||0,H),V(h.data,"view_total_content_playback_time",b),V(h.data,"view_total_upscaling",D*b),V(h.data,"view_total_downscaling",H*b)}f._lastPlayheadPosition=-1})}),["playing","hb"].forEach(function(y){h.on(y,function(){f._lastPlayheadPosition=h.data.player_playhead_time,f._lastPlayerWidth=h.data.player_width,f._lastPlayerHeight=h.data.player_height,f._lastSourceWidth=h.data.video_source_width,f._lastSourceHeight=h.data.video_source_height})})});function F(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function T(g,h,f){return h&&F(g.prototype,h),f&&F(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var C=T(function g(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,g),this.isSeeking=!1,h.on("seeking",function(y,b){G()(h.data,b),f._lastSeekingTime=$.now(),f.isSeeking===!1&&(f.isSeeking=!0,h.send("seeking"))}),h.on("seeked",function(){f.isSeeking=!1;var y=f._lastSeekingTime||$.now(),b=$.now()-y;V(h.data,"view_seek_count",1),V(h.data,"view_seek_duration",b);var O=h.data.view_max_seek_time||0;h.data.view_max_seek_time=Math.max(O,b)}),h.on("viewend",function(){f.isSeeking=!1})});function L(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var O,D,H=[],le=!0,Z=!1;try{for(b=b.call(f);!(le=(O=b.next()).done)&&(H.push(O.value),!y||H.length!==y);le=!0);}catch(Ce){Z=!0,D=Ce}finally{try{le||b.return==null||b.return()}finally{if(Z)throw D}}return H}}(g,h)||function(f,y){if(f){if(typeof f=="string")return B(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?B(f,y):void 0}}(g,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function B(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}function Y(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}var z=function(g,h){g.push(h),g.sort(function(f,y){return f.viewer_time-y.viewer_time})},ge=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],we=function(){function g(b){var O=this;(function(H,le){if(!(H instanceof le))throw new TypeError("Cannot call a class as a function")})(this,g),this.pm=b,b.on("viewinit",function(){O.isAdBreak=!1,O._currentAdRequestNumber=0,O._currentAdResponseNumber=0,O._adRequests=[],O._adResponses=[],O._adHasPlayed=!1,O._wouldBeNewAdPlay=!0,O._prerollPlayTime=void 0}),ge.forEach(function(H){return b.on(H,O._updateAdData.bind(O))});var D=function(){O.isAdBreak=!1};b.on("adbreakstart",function(){O.isAdBreak=!0}),b.on("play",D),b.on("playing",D),b.on("viewend",D),b.on("adrequest",function(H,le){le=G()({ad_request_id:"generatedAdRequestId"+O._currentAdRequestNumber++},le),z(O._adRequests,le),V(b.data,"view_ad_request_count"),O.inPrerollPosition()&&(b.data.view_preroll_requested=!0,O._adHasPlayed||V(b.data,"view_preroll_request_count"))}),b.on("adresponse",function(H,le){le=G()({ad_request_id:"generatedAdRequestId"+O._currentAdResponseNumber++},le),z(O._adResponses,le);var Z=O.findAdRequest(le.ad_request_id);Z&&V(b.data,"view_ad_request_time",Math.max(0,le.viewer_time-Z.viewer_time))}),b.on("adplay",function(H,le){O._adHasPlayed=!0,O._wouldBeNewAdPlay&&(O._wouldBeNewAdPlay=!1,V(b.data,"view_ad_played_count")),O.inPrerollPosition()&&!b.data.view_preroll_played&&(b.data.view_preroll_played=!0,O._adRequests.length>0&&(b.data.view_preroll_request_time=Math.max(0,le.viewer_time-O._adRequests[0].viewer_time)),b.data.view_start&&(b.data.view_startup_preroll_request_time=Math.max(0,le.viewer_time-b.data.view_start)),O._prerollPlayTime=le.viewer_time)}),b.on("adplaying",function(H,le){O.inPrerollPosition()&&b.data.view_preroll_load_time===void 0&&O._prerollPlayTime!==void 0&&(b.data.view_preroll_load_time=le.viewer_time-O._prerollPlayTime,b.data.view_startup_preroll_load_time=le.viewer_time-O._prerollPlayTime)}),b.on("adended",function(){O._wouldBeNewAdPlay=!0}),b.on("aderror",function(){O._wouldBeNewAdPlay=!0})}var h,f,y;return h=g,(f=[{key:"inPrerollPosition",value:function(){return this.pm.data.view_content_playback_time===void 0||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(b){for(var O=0;O<this._adRequests.length;O++)if(this._adRequests[O].ad_request_id===b)return this._adRequests[O]}},{key:"_updateAdData",value:function(b,O){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&O.ad_tag_url){var D=L(ke(O.ad_tag_url),2),H=D[0],le=D[1];this.pm.data.view_preroll_ad_tag_domain=le,this.pm.data.view_preroll_ad_tag_hostname=H}if(!this.pm.data.view_preroll_ad_asset_hostname&&O.ad_asset_url){var Z=L(ke(O.ad_asset_url),2),Ce=Z[0],at=Z[1];this.pm.data.view_preroll_ad_asset_domain=at,this.pm.data.view_preroll_ad_asset_hostname=Ce}}}}])&&Y(h.prototype,f),y&&Y(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function Le(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function Fe(g,h,f){return h&&Le(g.prototype,h),f&&Le(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var Ve=Fe(function g(h){var f,y;(function(H,le){if(!(H instanceof le))throw new TypeError("Cannot call a class as a function")})(this,g);var b=function(){h.disableRebufferTracking||f&&(V(h.data,"view_waiting_rebuffer_duration",$.now()-f),f=!1,R().clearInterval(y))},O=!1,D=function(){O=!1,b()};h.on("waiting",function(){O&&(h.disableRebufferTracking||(V(h.data,"view_waiting_rebuffer_count",1),f=$.now(),y=R().setInterval(function(){if(f){var H=$.now();V(h.data,"view_waiting_rebuffer_duration",H-f),f=H}},250)))}),h.on("playing",function(){b(),O=!0}),h.on("pause",D),h.on("seeking",D)});function Ue(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function Qe(g,h,f){return h&&Ue(g.prototype,h),f&&Ue(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var ot=Qe(function g(h){var f=this;(function(O,D){if(!(O instanceof D))throw new TypeError("Cannot call a class as a function")})(this,g);var y=function(){f.lastWallClockTime=$.now(),h.on("before*",b)},b=function(O){var D=$.now(),H=f.lastWallClockTime;f.lastWallClockTime=D,D-H>3e4&&(h.emit("devicesleep",{viewer_time:H}),G()(h.data,{viewer_time:H}),h.send("devicesleep"),h.emit("devicewake",{viewer_time:D}),G()(h.data,{viewer_time:D}),h.send("devicewake"))};h.one("playbackheartbeat",y),h.on("playbackheartbeatend",function(){h.off("before*",b),h.one("playbackheartbeat",y)})}),bt=j(375),We=j(655),kt=j.n(We),Jt="muxData",Ft=function(){var g;try{g=bt.parse(kt().get(Jt)||"")}catch{g={}}return g},Pt=function(g){try{kt().set(Jt,bt.stringify(g),{expires:7300})}catch{}},Bt=function(){var g=Ft();return g.mux_viewer_id=g.mux_viewer_id||p(),g.msn=g.msn||Math.random(),Pt(g),{mux_viewer_id:g.mux_viewer_id,mux_sample_number:g.msn}};function Ze(g,h){var f=h.beaconCollectionDomain,y=h.beaconDomain;if(f)return"https://"+f;var b=y||"litix.io";return(g=g||"inferred").match(/^[a-z0-9]+$/)?"https://"+g+"."+b:"https://img.litix.io/a.gif"}var ir=function(){var g;switch(br()){case"cellular":g="cellular";break;case"ethernet":g="wired";break;case"wifi":g="wifi";break;case void 0:break;default:g="other"}return g},br=function(){var g=R().navigator,h=g&&(g.connection||g.mozConnection||g.webkitConnection);return h&&h.type};ir.getConnectionFromAPI=br;var Nt=ir,Yt=Ir({a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"}),cr=Ir({ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"});function Ir(g){var h={};for(var f in g)g.hasOwnProperty(f)&&(h[g[f]]=f);return h}function dr(g){var h={},f={};return Object.keys(g).forEach(function(y){var b=!1;if(g.hasOwnProperty(y)&&g[y]!==void 0){var O=y.split("_"),D=O[0],H=Yt[D];H||(K.info("Data key word `"+O[0]+"` not expected in "+y),H=D+"_"),O.splice(1).forEach(function(le){le==="url"&&(b=!0),cr[le]?H+=cr[le]:Number(le)&&Math.floor(Number(le))===Number(le)?H+=le:(K.info("Data key word `"+le+"` not expected in "+y),H+="_"+le+"_")}),b?f[H]=g[y]:h[H]=g[y]}}),G()(h,f)}var Mt={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},ki=["hb","requestcompleted","requestfailed","requestcanceled"],zi="https://img.litix.io",_r=function(g){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=g||zi,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=G()({},Mt,h)};_r.prototype.queueEvent=function(g,h){var f=G()({},h);return(this._eventQueue.length<=this._options.maxQueueLength||g==="eventrateexceeded")&&(this._eventQueue.push(f),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength)},_r.prototype.flushEvents=function(){var g=arguments.length>0&&arguments[0]!==void 0&&arguments[0];g&&this._eventQueue.length===1?this._eventQueue.pop():(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},_r.prototype.destroy=function(){var g=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,g?this._clearBeaconQueue():this.flushEvents(),R().clearTimeout(this._sendTimeout)},_r.prototype._clearBeaconQueue=function(){var g=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,h=this._eventQueue.slice(g);g>0&&G()(h[h.length-1],dr({mux_view_message:"event queue truncated"}));var f=this._createPayload(h);oi(this._beaconUrl,f,!0,function(){})},_r.prototype._sendBeaconQueue=function(){var g=this;if(!this._postInFlight){var h=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var f=this._createPayload(h),y=$.now();oi(this._beaconUrl,f,!1,function(b,O){O?(g._eventQueue=h.concat(g._eventQueue),g._failureCount+=1,K.info("Error sending beacon: "+O)):g._failureCount=0,g._roundTripTime=$.now()-y,g._postInFlight=!1})}},_r.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var g=Math.pow(2,this._failureCount-1);return(1+(g*=Math.random()))*this._options.baseTimeBetweenBeacons},_r.prototype._startBeaconSending=function(){var g=this;R().clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=R().setTimeout(function(){g._eventQueue.length&&g._sendBeaconQueue(),g._startBeaconSending()},this._getNextBeaconTime()))},_r.prototype._createPayload=function(g){var h,f,y,b=this,O={transmission_timestamp:Math.round($.now())};this._roundTripTime&&(O.rtt_ms=Math.round(this._roundTripTime));var D=function(){h=JSON.stringify({metadata:O,events:f||g}),y=h.length/1024},H=function(){return y<=b._options.maxPayloadKBSize};return D(),H()||(K.info("Payload size is too big ("+y+" kb). Removing unnecessary events."),f=g.filter(function(le){return ki.indexOf(le.e)===-1}),D()),H()||(K.info("Payload size still too big ("+y+" kb). Cropping fields.."),f.forEach(function(le){for(var Z in le){var Ce=le[Z];typeof Ce=="string"&&Ce.length>51200&&(le[Z]=Ce.substring(0,51200))}}),D()),h};var oi=function(g,h,f,y){if(f&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(g,h))y();else if(R().fetch)R().fetch(g,{method:"POST",body:h,headers:{"Content-Type":"text/plain"},keepalive:!0}).then(function(O){return y(null,O.ok?null:"Error")}).catch(function(O){return y(null,O)});else{if(R().XMLHttpRequest){var b=new(R()).XMLHttpRequest;return b.onreadystatechange=function(){if(b.readyState===4)return y(null,b.status!==200?"error":void 0)},b.open("POST",g),b.setRequestHeader("Content-Type","text/plain"),void b.send(h)}y()}},Qi=_r;function Ji(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var O,D,H=[],le=!0,Z=!1;try{for(b=b.call(f);!(le=(O=b.next()).done)&&(H.push(O.value),!y||H.length!==y);le=!0);}catch(Ce){Z=!0,D=Ce}finally{try{le||b.return==null||b.return()}finally{if(Z)throw D}}return H}}(g,h)||function(f,y){if(f){if(typeof f=="string")return li(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?li(f,y):void 0}}(g,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function li(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}function ui(g,h){var f=Object.keys(g);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(g);h&&(y=y.filter(function(b){return Object.getOwnPropertyDescriptor(g,b).enumerable})),f.push.apply(f,y)}return f}function jr(g){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?ui(Object(f),!0).forEach(function(y){Gr(g,y,f[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(g,Object.getOwnPropertyDescriptors(f)):ui(Object(f)).forEach(function(y){Object.defineProperty(g,y,Object.getOwnPropertyDescriptor(f,y))})}return g}function Qr(g){return Qr=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},Qr(g)}function pn(g,h){if(!(g instanceof h))throw new TypeError("Cannot call a class as a function")}function $i(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function Gr(g,h,f){return h in g?Object.defineProperty(g,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):g[h]=f,g}var yr=["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"],Et=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended"],Zi=["viewstart","error","ended","viewend"],Kr=function(){function g(b,O){var D,H,le,Z,Ce,at,Je,it,Xe,nt,wt,jt,$t,nr,mt,Xt=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};pn(this,g),Gr(this,"previousBeaconData",null),Gr(this,"lastEventTime",0),Gr(this,"rateLimited",!1),this.mux=b,this.envKey=O,this.options=Xt,this.eventQueue=new Qi(Ze(this.envKey,this.options)),this.sampleRate=(D=this.options.sampleRate)!==null&&D!==void 0?D:1,this.disableCookies=(H=this.options.disableCookies)!==null&&H!==void 0&&H,this.respectDoNotTrack=(le=this.options.respectDoNotTrack)!==null&&le!==void 0&&le,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:(Z=this.options.platform)===null||Z===void 0?void 0:Z.name,viewer_application_version:(Ce=this.options.platform)===null||Ce===void 0?void 0:Ce.version,viewer_application_engine:(at=this.options.platform)===null||at===void 0?void 0:at.layout,viewer_device_name:(Je=this.options.platform)===null||Je===void 0?void 0:Je.product,viewer_device_category:"",viewer_device_manufacturer:(it=this.options.platform)===null||it===void 0?void 0:it.manufacturer,viewer_os_family:(Xe=this.options.platform)===null||Xe===void 0||(nt=Xe.os)===null||nt===void 0?void 0:nt.family,viewer_os_architecture:(wt=this.options.platform)===null||wt===void 0||(jt=wt.os)===null||jt===void 0?void 0:jt.architecture,viewer_os_version:($t=this.options.platform)===null||$t===void 0||(nr=$t.os)===null||nr===void 0?void 0:nr.version,viewer_connection_type:Nt(),page_url:R()===null||R()===void 0||(mt=R().location)===null||mt===void 0?void 0:mt.href},this.viewerData=this.disableCookies?{}:Bt()}var h,f,y;return h=g,(f=[{key:"send",value:function(b,O){var D;if(b){if(this.respectDoNotTrack&&ve())return K.info("Not sending `"+b+"` because Do Not Track is enabled");if(!O||Qr(O)!=="object")return K.error("A data object was expected in send() but was not provided");var H,le,Z=this.disableCookies?{}:(H=Ft(),le=$.now(),H.session_start&&(H.sst=H.session_start,delete H.session_start),H.session_id&&(H.sid=H.session_id,delete H.session_id),H.session_expires&&(H.sex=H.session_expires,delete H.session_expires),(!H.sex||H.sex<le)&&(H.sid=p(),H.sst=le),H.sex=le+15e5,Pt(H),{session_id:H.sid,session_start:H.sst,session_expires:H.sex}),Ce=jr(jr(jr(jr(jr({},this.pageLevelData),O),Z),this.viewerData),{},{event:b,env_key:this.envKey});Ce.user_id&&(Ce.viewer_user_id=Ce.user_id,delete Ce.user_id);var at=((D=Ce.mux_sample_number)!==null&&D!==void 0?D:0)>=this.sampleRate,Je=dr(this._deduplicateBeaconData(b,Ce));if(this.lastEventTime=this.mux.utils.now(),at)return K.info("Not sending event due to sample rate restriction",b,Ce,Je);if(this.envKey||K.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",b,Ce,Je),!this.rateLimited){if(K.info("Sending event",b,Ce,Je),this.rateLimited=!this.eventQueue.queueEvent(b,Je),this.mux.WINDOW_UNLOADING&&b==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&b==="hb"?this.eventQueue.flushEvents(!0):Zi.indexOf(b)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return Ce.event="eventrateexceeded",Je=dr(Ce),this.eventQueue.queueEvent(Ce.event,Je),K.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(b,O){var D=this,H={},le=O.view_id;if(!le||b==="viewstart"||b==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)H=jr({},O),le&&(this.previousBeaconData=H),le&&b==="viewend"&&(this.previousBeaconData=null);else{var Z=b.indexOf("request")===0;Object.entries(O).forEach(function(Ce){var at=Ji(Ce,2),Je=at[0],it=at[1];D.previousBeaconData&&(it!==D.previousBeaconData[Je]||yr.indexOf(Je)>-1||D.objectHasChanged(Z,Je,it,D.previousBeaconData[Je])||D.eventRequiresKey(b,Je))&&(H[Je]=it,D.previousBeaconData[Je]=it)})}return H}},{key:"objectHasChanged",value:function(b,O,D,H){return!(!b||O.indexOf("request_")!==0||O!=="request_response_headers"&&Qr(D)==="object"&&Qr(H)==="object"&&Object.keys(D||{}).length===Object.keys(H||{}).length)}},{key:"eventRequiresKey",value:function(b,O){return b==="renditionchange"&&O.indexOf("video_source_")===0||!(O.indexOf("ad_")!==0||!Et.includes(b))}}])&&$i(h.prototype,f),y&&$i(h,y),Object.defineProperty(h,"prototype",{writable:!1}),g}();function Fr(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function di(g,h,f){return h&&Fr(g.prototype,h),f&&Fr(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var Sr=di(function g(h){(function(Z,Ce){if(!(Z instanceof Ce))throw new TypeError("Cannot call a class as a function")})(this,g);var f=0,y=0,b=0,O=0,D=0,H=0,le=0;h.on("requestcompleted",function(Z,Ce){var at,Je,it=Ce.request_start,Xe=Ce.request_response_start,nt=Ce.request_response_end,wt=Ce.request_bytes_loaded;if(O++,Xe?(at=Xe-it,Je=nt-Xe):Je=nt-it,Je>0&&wt>0){var jt=wt/Je*8e3;D++,y+=wt,b+=Je,h.data.view_min_request_throughput=Math.min(h.data.view_min_request_throughput||1/0,jt),h.data.view_average_request_throughput=y/b*8e3,h.data.view_request_count=O,at>0&&(f+=at,h.data.view_max_request_latency=Math.max(h.data.view_max_request_latency||0,at),h.data.view_average_request_latency=f/D)}}),h.on("requestfailed",function(Z,Ce){O++,H++,h.data.view_request_count=O,h.data.view_request_failed_count=H}),h.on("requestcanceled",function(Z,Ce){O++,le++,h.data.view_request_count=O,h.data.view_request_canceled_count=le})});function Hr(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function Jr(g,h,f){return h&&Hr(g.prototype,h),f&&Hr(g,f),Object.defineProperty(g,"prototype",{writable:!1}),g}var kr=Jr(function g(h){var f=this;(function(y,b){if(!(y instanceof b))throw new TypeError("Cannot call a class as a function")})(this,g),h.on("before*",function(y,b){var O=b.viewer_time,D=$.now(),H=f._lastEventTime;if(f._lastEventTime=D,H&&D-H>36e5){var le=Object.keys(h.data).reduce(function(Z,Ce){return Ce.indexOf("video_")===0?G()(Z,function(at,Je,it){return Je in at?Object.defineProperty(at,Je,{value:it,enumerable:!0,configurable:!0,writable:!0}):at[Je]=it,at}({},Ce,h.data[Ce])):Z},{});h.mux.log.info("Received event after at least an hour inactivity, creating a new view"),h.emit("viewinit",G()({viewer_time:O},le)),h.playbackHeartbeat._playheadShouldBeProgressing&&y.type!=="play"&&y.type!=="adbreakstart"&&(h.emit("play",{viewer_time:O}),y.type!=="playing"&&h.emit("playing",{viewer_time:O}))}})});function Mr(g){return Mr=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},Mr(g)}function qr(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var O,D,H=[],le=!0,Z=!1;try{for(b=b.call(f);!(le=(O=b.next()).done)&&(H.push(O.value),!y||H.length!==y);le=!0);}catch(Ce){Z=!0,D=Ce}finally{try{le||b.return==null||b.return()}finally{if(Z)throw D}}return H}}(g,h)||function(f,y){if(f){if(typeof f=="string")return ci(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)?ci(f,y):void 0}}(g,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 ci(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}function hi(g,h){for(var f=0;f<h.length;f++){var y=h[f];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(g,y.key,y)}}function fi(g,h){return fi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,y){return f.__proto__=y,f},fi(g,h)}function wi(g){var h=function(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}();return function(){var f,y=vi(g);if(h){var b=vi(this).constructor;f=Reflect.construct(y,arguments,b)}else f=y.apply(this,arguments);return en(this,f)}}function en(g,h){if(h&&(Mr(h)==="object"||typeof h=="function"))return h;if(h!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wt(g)}function Wt(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}function vi(g){return vi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(h){return h.__proto__||Object.getPrototypeOf(h)},vi(g)}var mn=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],tn=function(g){(function(D,H){if(typeof H!="function"&&H!==null)throw new TypeError("Super expression must either be null or a function");D.prototype=Object.create(H&&H.prototype,{constructor:{value:D,writable:!0,configurable:!0}}),Object.defineProperty(D,"prototype",{writable:!1}),H&&fi(D,H)})(O,g);var h,f,y,b=wi(O);function O(D,H,le){var Z;(function(Xe,nt){if(!(Xe instanceof nt))throw new TypeError("Cannot call a class as a function")})(this,O),(Z=b.call(this)).DOM_CONTENT_LOADED_EVENT_END=je.domContentLoadedEventEnd(),Z.NAVIGATION_START=je.navigationStart(),Z.mux=D,Z.id=H,(le=G()({debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(Xe){return Xe}},le)).data=le.data||{},le.data.property_key&&(le.data.env_key=le.data.property_key,delete le.data.property_key),K.setLevel(le.debug?"debug":"warn"),Z.getPlayheadTime=le.getPlayheadTime,Z.getStateData=le.getStateData||function(){return{}},Z.getAdData=le.getAdData||function(){},Z.minimumRebufferDuration=le.minimumRebufferDuration,Z.sustainedRebufferThreshold=le.sustainedRebufferThreshold,Z.playbackHeartbeatTime=le.playbackHeartbeatTime,Z.disableRebufferTracking=le.disableRebufferTracking,Z.disableRebufferTracking&&Z.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),Z.disablePlayheadRebufferTracking=le.disablePlayheadRebufferTracking,Z.errorTranslator=le.errorTranslator,Z.playbackEventDispatcher=new Kr(D,le.data.env_key,le),Z.data={player_instance_id:p(),mux_sample_rate:le.sampleRate,beacon_domain:le.beaconCollectionDomain?le.beaconCollectionDomain:le.beaconDomain},Z.data.view_sequence_number=1,Z.data.player_sequence_number=1,Z.oldEmit=Z.emit,Z.emit=function(Xe,nt){nt=G()({viewer_time:this.mux.utils.now()},nt),this.oldEmit(Xe,nt)};var Ce=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(Wt(Z));Z.on("viewinit",function(Xe,nt){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),G()(this.data,nt),this._initializeViewData(),this.one("play",Ce),this.one("adbreakstart",Ce)});var at=function(Xe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",Xe)}.bind(Wt(Z));if(Z.on("videochange",function(Xe,nt){at(nt)}),Z.on("programchange",function(Xe,nt){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),at(G()(nt,{view_program_changed:!0})),Ce(),this.emit("play"),this.emit("playing")}),Z.on("fragmentchange",function(Xe,nt){this.currentFragmentPDT=nt.currentFragmentPDT,this.currentFragmentStart=nt.currentFragmentStart}),Z.on("destroy",Z.destroy),typeof window!="undefined"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var Je=function(){var Xe=Z.data.view_start!==void 0;Z.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",Xe&&Z.mux.WINDOW_HIDDEN&&(Z.data.player_is_paused||Z.emit("hb"))};window.addEventListener("visibilitychange",Je,!1);var it=function(Xe){Xe.persisted||Z.destroy()};window.addEventListener("pagehide",it,!1),Z.on("destroy",function(){window.removeEventListener("visibilitychange",Je),window.removeEventListener("pagehide",it)})}return Z.on("playerready",function(Xe,nt){G()(this.data,nt)}),mn.forEach(function(Xe){Z.on(Xe,function(nt,wt){Xe.indexOf("ad")!==0&&this._updateStateData(),G()(this.data,wt),this._sanitizeData()}),Z.on("after"+Xe,function(){(Xe!=="error"||this.errorTracker.viewErrored)&&this.send(Xe)})}),Z.on("viewend",function(Xe,nt){G()(Z.data,nt)}),Z.one("playerready",function(Xe){var nt=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=nt-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time}),Z.longResumeTracker=new kr(Wt(Z)),Z.errorTracker=new Ie(Wt(Z)),new ot(Wt(Z)),Z.seekingTracker=new C(Wt(Z)),Z.playheadTime=new Lt(Wt(Z)),Z.playbackHeartbeat=new Be(Wt(Z)),new ee(Wt(Z)),Z.watchTimeTracker=new rt(Wt(Z)),new ht(Wt(Z)),Z.adTracker=new we(Wt(Z)),new Ct(Wt(Z)),new pt(Wt(Z)),new Qt(Wt(Z)),new Ve(Wt(Z)),new Sr(Wt(Z)),le.hlsjs&&Z.addHLSJS(le),le.dashjs&&Z.addDashJS(le),Z.emit("viewinit",le.data),Z}return h=O,f=[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(D){var H=G()({},this.data);if(H.video_source_is_live===void 0&&(H.player_source_duration===1/0||H.video_source_duration===1/0?H.video_source_is_live=!0:(H.player_source_duration>0||H.video_source_duration>0)&&(H.video_source_is_live=!1)),H.video_source_is_live||["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"].forEach(function(at){H[at]=void 0}),H.video_source_url=H.video_source_url||H.player_source_url,H.video_source_url){var le=qr(ke(H.video_source_url),2),Z=le[0],Ce=le[1];H.video_source_domain=Ce,H.video_source_hostname=Z}delete H.ad_request_id,this.playbackEventDispatcher.send(D,H),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()}},{key:"_updateStateData",value:function(){G()(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var D=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(H){var le=parseInt(D.data[H],10);D.data[H]=isNaN(le)?void 0:le}),["player_source_url","video_source_url"].forEach(function(H){if(D.data[H]){var le=D.data[H].toLowerCase();le.indexOf("data:")!==0&&le.indexOf("blob:")!==0||(D.data[H]="MSE style URL")}})}},{key:"_resetVideoData",value:function(D,H){var le=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("video_")===0&&delete le.data[Z]})}},{key:"_resetViewData",value:function(){var D=this;Object.keys(this.data).forEach(function(H){H.indexOf("view_")===0&&delete D.data[H]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(D,H){delete this.data.player_error_code,delete this.data.player_error_message}},{key:"_initializeViewData",value:function(){var D=this,H=this.data.view_id=p(),le=function(){H===D.data.view_id&&V(D.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",le):le()}},{key:"_restartHeartBeat",value:function(){var D=this;window.clearTimeout(this._heartBeatTimeout),this.errorTracker.viewErrored||(this._heartBeatTimeout=window.setTimeout(function(){D.data.player_is_paused||D.emit("hb")},1e4))}},{key:"addHLSJS",value:function(D){D.hlsjs?this.hlsjs?this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=D.hlsjs,function(H,le,Z){var Ce=arguments.length>4?arguments[4]:void 0,at=H.log,Je=H.utils.secondsToMs,it=function(_t){var et,dt=parseInt(Ce.version);return dt===1&&_t.programDateTime!==null&&(et=_t.programDateTime),dt===0&&_t.pdt!==null&&(et=_t.pdt),et};if(je.exists()){var Xe=function(_t,et){return H.emit(le,_t,et)},nt=function(_t,et){var dt=et.levels,$e=et.audioTracks,lt=et.url,Gt=et.stats,qt=et.networkDetails,ar=et.sessionData,rr={},fr={};dt.forEach(function(gr,Wr){rr[Wr]={width:gr.width,height:gr.height,bitrate:gr.bitrate,attrs:gr.attrs}}),$e.forEach(function(gr,Wr){fr[Wr]={name:gr.name,language:gr.lang,bitrate:gr.bitrate}});var sr=W(Gt),vr=sr.bytesLoaded,Vt=sr.requestStart,or=sr.responseStart,ti=sr.responseEnd;Xe("requestcompleted",Te(Te({},A(ar)),{},{request_event_type:_t,request_bytes_loaded:vr,request_start:Vt,request_response_start:or,request_response_end:ti,request_type:"manifest",request_hostname:Se(lt),request_response_headers:De(qt),request_rendition_lists:{media:rr,audio:fr,video:{}}}))};Z.on(Ce.Events.MANIFEST_LOADED,nt);var wt=function(_t,et){var dt=et.details,$e=et.level,lt=et.networkDetails,Gt=et.stats,qt=W(Gt),ar=qt.bytesLoaded,rr=qt.requestStart,fr=qt.responseStart,sr=qt.responseEnd,vr=dt.fragments[dt.fragments.length-1],Vt=it(vr)+Je(vr.duration);Xe("requestcompleted",{request_event_type:_t,request_bytes_loaded:ar,request_start:rr,request_response_start:fr,request_response_end:sr,request_current_level:$e,request_type:"manifest",request_hostname:Se(dt.url),request_response_headers:De(lt),video_holdback:dt.holdBack&&Je(dt.holdBack),video_part_holdback:dt.partHoldBack&&Je(dt.partHoldBack),video_part_target_duration:dt.partTarget&&Je(dt.partTarget),video_target_duration:dt.targetduration&&Je(dt.targetduration),video_source_is_live:dt.live,player_manifest_newest_program_time:isNaN(Vt)?void 0:Vt})};Z.on(Ce.Events.LEVEL_LOADED,wt);var jt=function(_t,et){var dt=et.details,$e=et.networkDetails,lt=et.stats,Gt=W(lt),qt=Gt.bytesLoaded,ar=Gt.requestStart,rr=Gt.responseStart,fr=Gt.responseEnd;Xe("requestcompleted",{request_event_type:_t,request_bytes_loaded:qt,request_start:ar,request_response_start:rr,request_response_end:fr,request_type:"manifest",request_hostname:Se(dt.url),request_response_headers:De($e)})};Z.on(Ce.Events.AUDIO_TRACK_LOADED,jt);var $t=function(_t,et){var dt=et.stats,$e=et.networkDetails,lt=et.frag;dt=dt||lt.stats;var Gt=W(dt),qt=Gt.bytesLoaded,ar=Gt.requestStart,rr=Gt.responseStart,fr=Gt.responseEnd,sr=De($e),vr=sr==null?void 0:sr["x-request-id"],Vt={request_event_type:_t,request_bytes_loaded:qt,request_start:ar,request_response_start:rr,request_response_end:fr,request_hostname:$e?Se($e.responseURL):void 0,request_id:vr,request_response_headers:sr,request_media_duration:lt.duration,request_url:$e==null?void 0:$e.responseURL};lt.type==="main"?(Vt.request_type="media",Vt.request_current_level=lt.level,Vt.request_video_width=(Z.levels[lt.level]||{}).width,Vt.request_video_height=(Z.levels[lt.level]||{}).height,Vt.request_labeled_bitrate=(Z.levels[lt.level]||{}).bitrate):Vt.request_type=lt.type,Xe("requestcompleted",Vt)};Z.on(Ce.Events.FRAG_LOADED,$t);var nr=function(_t,et){var dt=et.frag,$e=dt.start,lt={currentFragmentPDT:it(dt),currentFragmentStart:Je($e)};Xe("fragmentchange",lt)};Z.on(Ce.Events.FRAG_CHANGED,nr);var mt=function(_t,et){var dt=et.type,$e=et.details,lt=et.response,Gt=et.fatal,qt=et.context,ar=et.frag;if($e===Ce.ErrorDetails.MANIFEST_LOAD_ERROR||$e===Ce.ErrorDetails.MANIFEST_LOAD_TIMEOUT||$e===Ce.ErrorDetails.FRAG_LOAD_ERROR||$e===Ce.ErrorDetails.FRAG_LOAD_TIMEOUT||$e===Ce.ErrorDetails.LEVEL_LOAD_ERROR||$e===Ce.ErrorDetails.LEVEL_LOAD_TIMEOUT){var rr=ar&&ar.url||qt&&qt.url||"";Xe("requestfailed",{request_error:$e,request_url:rr,request_hostname:Se(rr),request_type:$e===Ce.ErrorDetails.FRAG_LOAD_ERROR||$e===Ce.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:lt&<.code,request_error_text:lt&<.text})}Gt&&Xe("error",{player_error_code:dt,player_error_message:$e})};Z.on(Ce.Events.ERROR,mt);var Xt=function(_t,et){var dt=et.frag,$e=dt&&dt._url||"";Xe("requestcanceled",{request_event_type:_t,request_url:$e,request_type:"media",request_hostname:Se($e)})};Z.on(Ce.Events.FRAG_LOAD_EMERGENCY_ABORTED,Xt);var tr=function(_t,et){var dt=et.level,$e=Z.levels[dt];if($e&&$e.attrs&&$e.attrs.BANDWIDTH){var lt,Gt=$e.attrs.BANDWIDTH,qt=parseFloat($e.attrs["FRAME-RATE"]);isNaN(qt)||(lt=qt),Gt?Xe("renditionchange",{video_source_fps:lt,video_source_bitrate:Gt,video_source_width:$e.width,video_source_height:$e.height,video_source_rendition_name:$e.name,video_source_codec:$e==null?void 0:$e.videoCodec}):at.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};Z.on(Ce.Events.LEVEL_SWITCHED,tr),Z._stopMuxMonitor=function(){Z.off(Ce.Events.MANIFEST_LOADED,nt),Z.off(Ce.Events.LEVEL_LOADED,wt),Z.off(Ce.Events.AUDIO_TRACK_LOADED,jt),Z.off(Ce.Events.FRAG_LOADED,$t),Z.off(Ce.Events.FRAG_CHANGED,nr),Z.off(Ce.Events.ERROR,mt),Z.off(Ce.Events.FRAG_LOAD_EMERGENCY_ABORTED,Xt),Z.off(Ce.Events.LEVEL_SWITCHED,tr),Z.off(Ce.Events.DESTROYING,Z._stopMuxMonitor),delete Z._stopMuxMonitor},Z.on(Ce.Events.DESTROYING,Z._stopMuxMonitor)}else at.warn("performance timing not supported. Not tracking HLS.js.")}(this.mux,this.id,D.hlsjs,{},D.Hls||window.Hls)):this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")}},{key:"removeHLSJS",value:function(){var D;this.hlsjs&&((D=this.hlsjs)&&typeof D._stopMuxMonitor=="function"&&D._stopMuxMonitor(),this.hlsjs=void 0)}},{key:"addDashJS",value:function(D){D.dashjs?this.dashjs?this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=D.dashjs,function(H,le,Z){var Ce=H.log;if(Z&&Z.on){var at=function(mt,Xt){return H.emit(le,mt,Xt)},Je=function(mt){var Xt=mt.type,tr=(mt.data||{}).url;at("requestcompleted",{request_event_type:Xt,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:Se(tr),request_url:tr})};Z.on("manifestLoaded",Je);var it={},Xe=function(mt){var Xt=mt.type,tr=mt.fragmentModel,_t=(mt.chunk||{}).mediaInfo||{},et=_t.type,dt=_t.bitrateList,$e={};(dt=dt||[]).forEach(function(Vt,or){$e[or]={},$e[or].width=Vt.width,$e[or].height=Vt.height,$e[or].bitrate=Vt.bandwidth,$e[or].attrs={}}),et==="video"?it.video=$e:et==="audio"?it.audio=$e:it.media=$e;var lt=qe(tr,Z),Gt=lt.requestStart,qt=lt.requestResponseStart,ar=lt.requestResponseEnd,rr=lt.requestResponseHeaders,fr=lt.requestMediaDuration,sr=lt.requestHostname,vr=lt.requestUrl;at("requestcompleted",{request_event_type:Xt,request_start:Gt,request_response_start:qt,request_response_end:ar,request_bytes_loaded:-1,request_type:et+"_init",request_response_headers:rr,request_hostname:sr,request_url:vr,request_media_duration:fr,request_rendition_lists:it})};Z.on("initFragmentLoaded",Xe);var nt=function(mt){var Xt=mt.type,tr=mt.fragmentModel,_t=mt.chunk||{},et=_t.mediaInfo,dt=_t.start,$e=(et||{}).type,lt=qe(tr,Z),Gt=lt.requestStart,qt=lt.requestResponseStart,ar=lt.requestResponseEnd,rr=lt.requestBytesLoaded,fr=lt.requestResponseHeaders,sr=lt.requestMediaDuration,vr=lt.requestHostname,Vt=lt.requestUrl,or=tt($e,Z),ti=or.currentLevel,gr=or.renditionWidth,Wr=or.renditionHeight,on=or.renditionBitrate;at("requestcompleted",{request_event_type:Xt,request_start:Gt,request_response_start:qt,request_response_end:ar,request_bytes_loaded:rr,request_type:$e,request_response_headers:fr,request_hostname:vr,request_url:Vt,request_media_start_time:dt,request_media_duration:sr,request_current_level:ti,request_labeled_bitrate:on,request_video_width:gr,request_video_height:Wr})};Z.on("mediaFragmentLoaded",nt);var wt={video:void 0,audio:void 0,totalBitrate:void 0},jt=function(){if(wt.video&&typeof wt.video.bitrate=="number"){if(wt.video.width&&wt.video.height){var mt=wt.video.bitrate;return wt.audio&&typeof wt.audio.bitrate=="number"&&(mt+=wt.audio.bitrate),mt!==wt.totalBitrate?(wt.totalBitrate=mt,{video_source_bitrate:mt,video_source_height:wt.video.height,video_source_width:wt.video.width,video_source_codec:ie(wt.video.codec)}):void 0}Ce.warn("have bitrate info for video but missing width/height")}},$t=function(mt,Xt,tr){if(typeof mt.newQuality=="number"){var _t=mt.mediaType;if(_t==="audio"||_t==="video"){var et=Z.getBitrateInfoListFor(_t).find(function($e){return $e.qualityIndex===mt.newQuality});if(et&&typeof et.bitrate=="number"){wt[_t]=Oe(Oe({},et),{},{codec:Z.getCurrentTrackFor(_t).codec});var dt=jt();dt&&at("renditionchange",dt)}else Ce.warn("missing bitrate info for ".concat(_t))}}else Ce.warn("missing evt.newQuality in qualityChangeRendered event",mt)};Z.on("qualityChangeRendered",$t);var nr=function(mt){var Xt=mt.error,tr=mt.event,_t=(tr=tr||{}).request||{},et=R().event&&R().event.currentTarget||{};at("requestfailed",{request_error:Xt+"_"+tr.id+"_"+_t.type,request_url:tr.url,request_hostname:Se(tr.url),request_type:_t.mediaType,request_error_code:et.status,request_error_type:et.statusText})};Z.on("error",nr),Z._stopMuxMonitor=function(){Z.off("manifestLoaded",Je),Z.off("initFragmentLoaded",Xe),Z.off("mediaFragmentLoaded",nt),Z.off("qualityChangeRendered",$t),Z.off("error",nr),delete Z._stopMuxMonitor}}else Ce.warn("Invalid dash.js player reference. Monitoring blocked.")}(this.mux,this.id,D.dashjs)):this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")}},{key:"removeDashJS",value:function(){var D;this.dashjs&&((D=this.dashjs)&&typeof D._stopMuxMonitor=="function"&&D._stopMuxMonitor(),this.dashjs=void 0)}}],f&&hi(h.prototype,f),y&&hi(h,y),Object.defineProperty(h,"prototype",{writable:!1}),O}(Pe),Nr=tn,Di=j(153),$r=j.n(Di);function Zr(g){return Zr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},Zr(g)}function Li(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var O,D,H=[],le=!0,Z=!1;try{for(b=b.call(f);!(le=(O=b.next()).done)&&(H.push(O.value),!y||H.length!==y);le=!0);}catch(Ce){Z=!0,D=Ce}finally{try{le||b.return==null||b.return()}finally{if(Z)throw D}}return H}}(g,h)||function(f,y){if(f){if(typeof f=="string")return rn(f,y);var b=Object.prototype.toString.call(f).slice(8,-1);return b==="Object"&&f.constructor&&(b=f.constructor.name),b==="Map"||b==="Set"?Array.from(f):b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b)?rn(f,y):void 0}}(g,h)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function rn(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}var Vr,Ri=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],yn={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};R()&&R().WeakMap&&(Vr=new WeakMap);var gi="#EXT-X-TARGETDURATION",En="#EXT-X-PART-INF",Tn="#EXT-X-SERVER-CONTROL",bn="#EXTINF",nn="#EXT-X-PROGRAM-DATE-TIME",pi="#EXT-X-VERSION",Ii="#EXT-X-SESSION-DATA",mi=function(g){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(g),this.manifest};mi.prototype.process=function(g){var h;for(this.buffer+=g,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)},mi.prototype.processLine=function(g){var h=g.indexOf(":"),f=An(g,h),y=f[0],b=f.length===2?ei(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 En:Ci(this.manifest,f),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case Tn:Ci(this.manifest,f),this.setHoldBack();break;case bn:b===0?this.currentUri.duration=.01:b>0&&(this.currentUri.duration=b);break;case nn:var O=b,D=new Date(O);this.manifest.dateTimeString||(this.manifest.dateTimeString=O,this.manifest.dateTimeObject=D),this.currentUri.dateTimeString=O,this.currentUri.dateTimeObject=D;break;case pi:Ci(this.manifest,f);break;case Ii:var H=kn(f[1]),le=A(H);G()(this.manifest.sessionData,le)}},mi.prototype.setHoldBack=function(){var g=this.manifest,h=g.serverControl,f=g.targetDuration,y=g.partTargetDuration;if(h){var b="holdBack",O="partHoldBack",D=f&&3*f,H=y&&2*y;f&&!h.hasOwnProperty(b)&&(h[b]=D),D&&h[b]<D&&(h[b]=D),y&&!h.hasOwnProperty(O)&&(h[O]=3*y),y&&h[O]<H&&(h[O]=H)}};var Ci=function(g,h){var f,y=an(h[0].replace("#EXT-X-",""));Oi(h[1])?(f={},f=G()(Sn(h[1]),f)):f=ei(h[1]),g[y]=f},an=function(g){return g.toLowerCase().replace(/-(\w)/g,function(h){return h[1].toUpperCase()})},ei=function(g){if(g.toLowerCase()==="yes"||g.toLowerCase()==="no")return g.toLowerCase()==="yes";var h=g.indexOf(":")!==-1?g:parseFloat(g);return isNaN(h)?g:h},_n=function(g){var h={},f=g.split("=");return f.length>1&&(h[an(f[0])]=ei(f[1])),h},Sn=function(g){for(var h=g.split(","),f={},y=0;h.length>y;y++){var b=h[y],O=_n(b);f=G()(O,f)}return f},Oi=function(g){return g.indexOf("=")>-1},An=function(g,h){return h===-1?[g]:[g.substring(0,h),g.substring(h+1)]},kn=function(g){var h={};if(g){var f=g.search(",");return[g.slice(0,f),g.slice(f+1)].forEach(function(y,b){for(var O=y.replace(/['"]+/g,"").split("="),D=0;D<O.length;D++)O[D]==="DATA-ID"&&(h["DATA-ID"]=O[1-D]),O[D]==="VALUE"&&(h.VALUE=O[1-D])}),{data:h}}},wn=mi,Pi={safeCall:function(g,h,f,y){var b=y;if(g&&typeof g[h]=="function")try{b=g[h].apply(g,f)}catch(O){K.info("safeCall error",O)}return b},safeIncrement:V,getComputedStyle:function(g,h){var f;if(g&&h&&R()&&typeof R().getComputedStyle=="function")return Vr&&Vr.has(g)&&(f=Vr.get(g)),f||(f=R().getComputedStyle(g,null),Vr&&Vr.set(g,f)),f.getPropertyValue(h)},secondsToMs:function(g){return Math.floor(1e3*g)},assign:G(),headersStringToObject:U,extractHostnameAndDomain:ke,extractHostname:Se,manifestParser:wn,generateShortID:w,generateUUID:p,now:$.now},xi={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 Dn(g,h){return function(f){if(Array.isArray(f))return f}(g)||function(f,y){var b=f==null?null:typeof Symbol!="undefined"&&f[Symbol.iterator]||f["@@iterator"];if(b!=null){var O,D,H=[],le=!0,Z=!1;try{for(b=b.call(f);!(le=(O=b.next()).done)&&(H.push(O.value),!y||H.length!==y);le=!0);}catch(Ce){Z=!0,D=Ce}finally{try{le||b.return==null||b.return()}finally{if(Z)throw D}}return H}}(g,h)||function(f,y){if(f){if(typeof f=="string")return gt(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)?gt(f,y):void 0}}(g,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 gt(g,h){(h==null||h>g.length)&&(h=g.length);for(var f=0,y=new Array(h);f<h;f++)y[f]=g[f];return y}var hr={},Yr=function g(h){var f=arguments;typeof h=="string"?g.hasOwnProperty(h)?R().setTimeout(function(){f=Array.prototype.splice.call(f,1),g[h].apply(null,f)},0):K.warn("`"+h+"` is an unknown task"):typeof h=="function"?R().setTimeout(function(){h(g)},0):K.warn("`"+h+"` is invalid.")},sn={loaded:$.now(),NAME:"mux-embed",VERSION:"4.17.0",API_VERSION:"2.1",PLAYER_TRACKED:!1,monitor:function(g,h){return function(f,y,b){var O=Li(me(y),3),D=O[0],H=O[1],le=O[2],Z=f.log,Ce=f.utils.getComputedStyle,at=f.utils.secondsToMs;if(!D)return Z.error("No element was found with the `"+H+"` query selector.");if(le!=="video"&&le!=="audio")return Z.error("The element of `"+H+"` was not a media element.");D.mux&&(D.mux.destroy(),delete D.mux,Z.warn("Already monitoring this video element, replacing existing event listeners")),(b=G()({automaticErrorTracking:!0},b)).data=G()({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:f.VERSION},b.data),b.getPlayheadTime=function(){return at(D.currentTime)},b.getStateData=function(){var it,Xe,nt=this.hlsjs&&this.hlsjs.url,wt=this.dashjs&&Zr(this.dashjs.getSource==="function")&&this.dashjs.getSource(),jt={player_is_paused:D.paused,player_playhead_time:at(D.currentTime),player_width:parseInt(Ce(D,"width")),player_height:parseInt(Ce(D,"height")),player_autoplay_on:D.autoplay,player_preload_on:D.preload,player_language_code:D.lang,player_is_fullscreen:$r()&&!!($r().fullscreenElement||$r().webkitFullscreenElement||$r().mozFullScreenElement||$r().msFullscreenElement),video_poster_url:D.poster,video_source_url:nt||wt||D.currentSrc,video_source_duration:at(D.duration),video_source_height:D.videoHeight,video_source_width:D.videoWidth,view_dropped_frame_count:(it=D)===null||it===void 0||(Xe=it.getVideoPlaybackQuality)===null||Xe===void 0?void 0:Xe.call(it).droppedVideoFrames},$t=b.getPlayheadTime();if(D.getStartDate&&$t>0){var nr=D.getStartDate();if(nr&&typeof nr.getTime=="function"&&nr.getTime()){var mt=nr.getTime();if(jt.player_program_time=mt+$t,D.seekable.length>0){var Xt=mt+D.seekable.end(D.seekable.length-1);jt.player_live_edge_program_time=Xt}}}return jt},D.mux=D.mux||{},D.mux.deleted=!1,D.mux.emit=function(it,Xe){f.emit(H,it,Xe)};var Je=function(){Z.error("The monitor for this video element has already been destroyed.")};D.mux.destroy=function(){Object.keys(D.mux.listeners).forEach(function(it){D.removeEventListener(it,D.mux.listeners[it],!1)}),delete D.mux.listeners,D.mux.destroy=Je,D.mux.swapElement=Je,D.mux.emit=Je,D.mux.addHLSJS=Je,D.mux.addDashJS=Je,D.mux.removeHLSJS=Je,D.mux.removeDashJS=Je,D.mux.deleted=!0,f.emit(H,"destroy")},D.mux.swapElement=function(it){var Xe=Li(me(it),3),nt=Xe[0],wt=Xe[1],jt=Xe[2];return nt?jt!=="video"&&jt!=="audio"?f.log.error("The element of `"+wt+"` was not a media element."):(nt.muxId=D.muxId,delete D.muxId,nt.mux=nt.mux||{},nt.mux.listeners=G()({},D.mux.listeners),delete D.mux.listeners,Object.keys(nt.mux.listeners).forEach(function($t){D.removeEventListener($t,nt.mux.listeners[$t],!1),nt.addEventListener($t,nt.mux.listeners[$t],!1)}),nt.mux.swapElement=D.mux.swapElement,nt.mux.destroy=D.mux.destroy,delete D.mux,void(D=nt)):f.log.error("No element was found with the `"+wt+"` query selector.")},D.mux.addHLSJS=function(it){f.addHLSJS(H,it)},D.mux.addDashJS=function(it){f.addDashJS(H,it)},D.mux.removeHLSJS=function(){f.removeHLSJS(H)},D.mux.removeDashJS=function(){f.removeDashJS(H)},f.init(H,b),f.emit(H,"playerready"),D.paused||(f.emit(H,"play"),D.readyState>2&&f.emit(H,"playing")),D.mux.listeners={},Ri.forEach(function(it){(it!=="error"||b.automaticErrorTracking)&&(D.mux.listeners[it]=function(){var Xe={};if(it==="error"){if(!D.error||D.error.code===1)return;Xe.player_error_code=D.error.code,Xe.player_error_message=yn[D.error.code]||D.error.message}f.emit(H,it,Xe)},D.addEventListener(it,D.mux.listeners[it],!1))})}(Yr,g,h)},destroyMonitor:function(g){var h=Dn(me(g),1)[0];h&&h.mux&&typeof h.mux.destroy=="function"?h.mux.destroy():K.error("A video element monitor for `"+g+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(g,h){var f=k(g);hr[f]?hr[f].addHLSJS(h):K.error("A monitor for `"+f+"` has not been initialized.")},addDashJS:function(g,h){var f=k(g);hr[f]?hr[f].addDashJS(h):K.error("A monitor for `"+f+"` has not been initialized.")},removeHLSJS:function(g){var h=k(g);hr[h]?hr[h].removeHLSJS():K.error("A monitor for `"+h+"` has not been initialized.")},removeDashJS:function(g){var h=k(g);hr[h]?hr[h].removeDashJS():K.error("A monitor for `"+h+"` has not been initialized.")},init:function(g,h){ve()&&h&&h.respectDoNotTrack&&K.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var f=k(g);hr[f]=new Nr(Yr,f,h)},emit:function(g,h,f){var y=k(g);hr[y]?(hr[y].emit(h,f),h==="destroy"&&delete hr[y]):K.error("A monitor for `"+y+"` has not been initialized.")},checkDoNotTrack:ve,log:K,utils:Pi,events:xi,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Yr,sn),R()!==void 0&&typeof R().addEventListener=="function"&&R().addEventListener("pagehide",function(g){g.persisted||(Yr.WINDOW_UNLOADING=!0)},!1);var Ln=Yr},655:function(Q,N,j){var te,R;function p(w){return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(k){return typeof k}:function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},p(w);}(function(w){var k=!1;if((R=typeof(te=w)=="function"?te.call(N,j,N,Q):te)===void 0||(Q.exports=R),k=!0,p(N)==="object"&&(Q.exports=w(),k=!0),!k){var me=window.Cookies,re=window.Cookies=w();re.noConflict=function(){return window.Cookies=me,re}}})(function(){var w=function(){for(var k=0,me={};k<arguments.length;k++){var re=arguments[k];for(var de in re)me[de]=re[de]}return me};return function k(me){function re(de,_e,K){var ve;if(typeof document!="undefined"){if(arguments.length>1){if(typeof(K=w({path:"/"},re.defaults,K)).expires=="number"){var $=new Date;$.setMilliseconds($.getMilliseconds()+864e5*K.expires),K.expires=$}try{ve=JSON.stringify(_e),/^[\{\[]/.test(ve)&&(_e=ve)}catch{}return _e=me.write?me.write(_e,de):encodeURIComponent(String(_e)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),de=(de=(de=encodeURIComponent(String(de))).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent)).replace(/[\(\)]/g,escape),document.cookie=[de,"=",_e,K.expires?"; expires="+K.expires.toUTCString():"",K.path?"; path="+K.path:"",K.domain?"; domain="+K.domain:"",K.secure?"; secure":""].join("")}de||(ve={});for(var ae=document.cookie?document.cookie.split("; "):[],G=/(%[0-9A-Z]{2})+/g,Se=0;Se<ae.length;Se++){var ke=ae[Se].split("="),je=ke.slice(1).join("=");je.charAt(0)==='"'&&(je=je.slice(1,-1));try{var V=ke[0].replace(G,decodeURIComponent);if(je=me.read?me.read(je,V):me(je,V)||je.replace(G,decodeURIComponent),this.json)try{je=JSON.parse(je)}catch{}if(de===V){ve=je;break}de||(ve[V]=je)}catch{}}return ve}}return re.set=re,re.get=function(de){return re.call(re,de)},re.getJSON=function(){return re.apply({json:!0},[].slice.call(arguments))},re.defaults={},re.remove=function(de,_e){re(de,"",w(_e,{expires:-1}))},re.withConverter=k,re}(function(){})})},153:function(Q,N,j){var te,R=j.g!==void 0?j.g:typeof window!="undefined"?window:{},p=j(558);typeof document!="undefined"?te=document:(te=R["__GLOBAL_DOCUMENT_CACHE@4"])||(te=R["__GLOBAL_DOCUMENT_CACHE@4"]=p),Q.exports=te},48:function(Q,N,j){var te;te=typeof window!="undefined"?window:j.g!==void 0?j.g:typeof self!="undefined"?self:{},Q.exports=te},678:function(Q){var N=9007199254740991,j="[object Arguments]",te="[object Function]",R="[object GeneratorFunction]",p=/^(?:0|[1-9]\d*)$/;function w(J,W,De){switch(De.length){case 0:return J.call(W);case 1:return J.call(W,De[0]);case 2:return J.call(W,De[0],De[1]);case 3:return J.call(W,De[0],De[1],De[2])}return J.apply(W,De)}var k,me,re=Object.prototype,de=re.hasOwnProperty,_e=re.toString,K=re.propertyIsEnumerable,ve=(k=Object.keys,me=Object,function(J){return k(me(J))}),$=Math.max,ae=!K.call({valueOf:1},"valueOf");function G(J,W){var De=E(J)||function(qe){return function(tt){return function(ie){return!!ie&&typeof ie=="object"}(tt)&&U(tt)}(qe)&&de.call(qe,"callee")&&(!K.call(qe,"callee")||_e.call(qe)==j)}(J)?function(qe,tt){for(var ie=-1,ce=Array(qe);++ie<qe;)ce[ie]=tt(ie);return ce}(J.length,String):[],Re=De.length,Oe=!!Re;for(var ye in J)!W&&!de.call(J,ye)||Oe&&(ye=="length"||ke(ye,Re))||De.push(ye);return De}function Se(J,W,De){var Re=J[W];de.call(J,W)&&V(Re,De)&&(De!==void 0||W in J)||(J[W]=De)}function ke(J,W){return!!(W=W==null?N:W)&&(typeof J=="number"||p.test(J))&&J>-1&&J%1==0&&J<W}function je(J){var W=J&&J.constructor;return J===(typeof W=="function"&&W.prototype||re)}function V(J,W){return J===W||J!=J&&W!=W}var E=Array.isArray;function U(J){return J!=null&&function(W){return typeof W=="number"&&W>-1&&W%1==0&&W<=N}(J.length)&&!function(W){var De=A(W)?_e.call(W):"";return De==te||De==R}(J)}function A(J){var W=typeof J;return!!J&&(W=="object"||W=="function")}var ue,Te=(ue=function(J,W){if(ae||je(W)||U(W))(function(Re,Oe,ye,qe){ye||(ye={});for(var tt=-1,ie=Oe.length;++tt<ie;){var ce=Oe[tt],ne=qe?qe(ye[ce],Re[ce],ce,ye,Re):void 0;Se(ye,ce,ne===void 0?Re[ce]:ne)}})(W,function(Re){return U(Re)?G(Re):function(Oe){if(!je(Oe))return ve(Oe);var ye=[];for(var qe in Object(Oe))de.call(Oe,qe)&&qe!="constructor"&&ye.push(qe);return ye}(Re)}(W),J);else for(var De in W)de.call(W,De)&&Se(J,De,W[De])},function(J,W){return W=$(W===void 0?J.length-1:W,0),function(){for(var De=arguments,Re=-1,Oe=$(De.length-W,0),ye=Array(Oe);++Re<Oe;)ye[Re]=De[W+Re];Re=-1;for(var qe=Array(W+1);++Re<W;)qe[Re]=De[Re];return qe[W]=ye,w(J,this,qe)}}(function(J,W){var De=-1,Re=W.length,Oe=Re>1?W[Re-1]:void 0,ye=Re>2?W[2]:void 0;for(Oe=ue.length>3&&typeof Oe=="function"?(Re--,Oe):void 0,ye&&function(tt,ie,ce){if(!A(ce))return!1;var ne=typeof ie;return!!(ne=="number"?U(ce)&&ke(ie,ce.length):ne=="string"&&ie in ce)&&V(ce[ie],tt)}(W[0],W[1],ye)&&(Oe=Re<3?void 0:Oe,Re=1),J=Object(J);++De<Re;){var qe=W[De];qe&&ue(J,qe,De,Oe)}return J}));Q.exports=Te},640:function(Q,N,j){var te,R;(function(p,w){"use strict";te=function(){var k=function(){},me="undefined",re=typeof window!==me&&typeof window.navigator!==me&&/Trident\/|MSIE /.test(window.navigator.userAgent),de=["trace","debug","info","warn","error"];function _e(E,U){var A=E[U];if(typeof A.bind=="function")return A.bind(E);try{return Function.prototype.bind.call(A,E)}catch{return function(){return Function.prototype.apply.apply(A,[E,arguments])}}}function K(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function ve(E){return E==="debug"&&(E="log"),typeof console!==me&&(E==="trace"&&re?K:console[E]!==void 0?_e(console,E):console.log!==void 0?_e(console,"log"):k)}function $(E,U){for(var A=0;A<de.length;A++){var ue=de[A];this[ue]=A<E?k:this.methodFactory(ue,E,U)}this.log=this.debug}function ae(E,U,A){return function(){typeof console!==me&&($.call(this,U,A),this[E].apply(this,arguments))}}function G(E,U,A){return ve(E)||ae.apply(this,arguments)}function Se(E,U,A){var ue,Te=this;U=U==null?"WARN":U;var J="loglevel";function W(ye){var qe=(de[ye]||"silent").toUpperCase();if(typeof window!==me&&J){try{return void(window.localStorage[J]=qe)}catch{}try{window.document.cookie=encodeURIComponent(J)+"="+qe+";"}catch{}}}function De(){var ye;if(typeof window!==me&&J){try{ye=window.localStorage[J]}catch{}if(typeof ye===me)try{var qe=window.document.cookie,tt=qe.indexOf(encodeURIComponent(J)+"=");tt!==-1&&(ye=/^([^;]+)/.exec(qe.slice(tt))[1])}catch{}return Te.levels[ye]===void 0&&(ye=void 0),ye}}function Re(){if(typeof window!==me&&J){try{return void window.localStorage.removeItem(J)}catch{}try{window.document.cookie=encodeURIComponent(J)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}typeof E=="string"?J+=":"+E:typeof E=="symbol"&&(J=void 0),Te.name=E,Te.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},Te.methodFactory=A||G,Te.getLevel=function(){return ue},Te.setLevel=function(ye,qe){if(typeof ye=="string"&&Te.levels[ye.toUpperCase()]!==void 0&&(ye=Te.levels[ye.toUpperCase()]),!(typeof ye=="number"&&ye>=0&&ye<=Te.levels.SILENT))throw"log.setLevel() called with invalid level: "+ye;if(ue=ye,qe!==!1&&W(ye),$.call(Te,ye,E),typeof console===me&&ye<Te.levels.SILENT)return"No console available for logging"},Te.setDefaultLevel=function(ye){U=ye,De()||Te.setLevel(ye,!1)},Te.resetLevel=function(){Te.setLevel(U,!1),Re()},Te.enableAll=function(ye){Te.setLevel(Te.levels.TRACE,ye)},Te.disableAll=function(ye){Te.setLevel(Te.levels.SILENT,ye)};var Oe=De();Oe==null&&(Oe=U),Te.setLevel(Oe,!1)}var ke=new Se,je={};ke.getLogger=function(E){if(typeof E!="symbol"&&typeof E!="string"||E==="")throw new TypeError("You must supply a name when creating a logger.");var U=je[E];return U||(U=je[E]=new Se(E,ke.getLevel(),ke.methodFactory)),U};var V=typeof window!==me?window.log:void 0;return ke.noConflict=function(){return typeof window!==me&&window.log===ke&&(window.log=V),ke},ke.getLoggers=function(){return je},ke.default=ke,ke},(R=typeof te=="function"?te.call(N,j,N,Q):te)===void 0||(Q.exports=R)})()},375:function(Q,N){"use strict";var j=Object.prototype.hasOwnProperty;function te(p){try{return decodeURIComponent(p.replace(/\+/g," "))}catch{return null}}function R(p){try{return encodeURIComponent(p)}catch{return null}}N.stringify=function(p,w){w=w||"";var k,me,re=[];for(me in typeof w!="string"&&(w="?"),p)if(j.call(p,me)){if((k=p[me])||k!=null&&!isNaN(k)||(k=""),me=R(me),k=R(k),me===null||k===null)continue;re.push(me+"="+k)}return re.length?w+re.join("&"):""},N.parse=function(p){for(var w,k=/([^=?#&]+)=?([^&]*)/g,me={};w=k.exec(p);){var re=te(w[1]),de=te(w[2]);re===null||de===null||re in me||(me[re]=de)}return me}},558:function(){}},fe={};function oe(Q){var N=fe[Q];if(N!==void 0)return N.exports;var j=fe[Q]={exports:{}};return x[Q].call(j.exports,j,j.exports,oe),j.exports}return oe.n=function(Q){var N=Q&&Q.__esModule?function(){return Q.default}:function(){return Q};return oe.d(N,{a:N}),N},oe.d=function(Q,N){for(var j in N)oe.o(N,j)&&!oe.o(Q,j)&&Object.defineProperty(Q,j,{enumerable:!0,get:N[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(Q,N){return Object.prototype.hasOwnProperty.call(Q,N)},oe(80)}()},typeof cn=="object"&&typeof Yn=="object"?Yn.exports=X():typeof cn=="object"?cn.mux=X():M.mux=X()})()});var wa=ba((Ki,Wn)=>{typeof window!="undefined"&&function(M,X){typeof Ki=="object"&&typeof Wn=="object"?Wn.exports=X():typeof define=="function"&&define.amd?define([],X):typeof Ki=="object"?Ki.Hls=X():M.Hls=X()}(Ki,()=>(()=>{var M={21:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{default:()=>me});var j=function(){function re(de,_e){this.subtle=void 0,this.aesIV=void 0,this.subtle=de,this.aesIV=_e}return re.prototype.decrypt=function(de,_e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},_e,de)},re}(),te=function(){function re(de,_e){this.subtle=void 0,this.key=void 0,this.subtle=de,this.key=_e}return re.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},re}(),R=N(145),p=function(){function re(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var de=re.prototype;return de.uint8ArrayToUint32Array_=function(_e){for(var K=new DataView(_e),ve=new Uint32Array(4),$=0;$<4;$++)ve[$]=K.getUint32(4*$);return ve},de.initTable=function(){var _e=this.sBox,K=this.invSBox,ve=this.subMix,$=ve[0],ae=ve[1],G=ve[2],Se=ve[3],ke=this.invSubMix,je=ke[0],V=ke[1],E=ke[2],U=ke[3],A=new Uint32Array(256),ue=0,Te=0,J=0;for(J=0;J<256;J++)A[J]=J<128?J<<1:J<<1^283;for(J=0;J<256;J++){var W=Te^Te<<1^Te<<2^Te<<3^Te<<4;W=W>>>8^255&W^99,_e[ue]=W,K[W]=ue;var De=A[ue],Re=A[De],Oe=A[Re],ye=257*A[W]^16843008*W;$[ue]=ye<<24|ye>>>8,ae[ue]=ye<<16|ye>>>16,G[ue]=ye<<8|ye>>>24,Se[ue]=ye,ye=16843009*Oe^65537*Re^257*De^16843008*ue,je[W]=ye<<24|ye>>>8,V[W]=ye<<16|ye>>>16,E[W]=ye<<8|ye>>>24,U[W]=ye,ue?(ue=De^A[A[A[Oe^De]]],Te^=A[A[Te]]):ue=Te=1}},de.expandKey=function(_e){for(var K=this.uint8ArrayToUint32Array_(_e),ve=!0,$=0;$<K.length&&ve;)ve=K[$]===this.key[$],$++;if(!ve){this.key=K;var ae=this.keySize=K.length;if(ae!==4&&ae!==6&&ae!==8)throw new Error("Invalid aes key size="+ae);var G,Se,ke,je,V=this.ksRows=4*(ae+6+1),E=this.keySchedule=new Uint32Array(V),U=this.invKeySchedule=new Uint32Array(V),A=this.sBox,ue=this.rcon,Te=this.invSubMix,J=Te[0],W=Te[1],De=Te[2],Re=Te[3];for(G=0;G<V;G++)G<ae?ke=E[G]=K[G]:(je=ke,G%ae==0?(je=A[(je=je<<8|je>>>24)>>>24]<<24|A[je>>>16&255]<<16|A[je>>>8&255]<<8|A[255&je],je^=ue[G/ae|0]<<24):ae>6&&G%ae==4&&(je=A[je>>>24]<<24|A[je>>>16&255]<<16|A[je>>>8&255]<<8|A[255&je]),E[G]=ke=(E[G-ae]^je)>>>0);for(Se=0;Se<V;Se++)G=V-Se,je=3&Se?E[G]:E[G-4],U[Se]=Se<4||G<=4?je:J[A[je>>>24]]^W[A[je>>>16&255]]^De[A[je>>>8&255]]^Re[A[255&je]],U[Se]=U[Se]>>>0}},de.networkToHostOrderSwap=function(_e){return _e<<24|(65280&_e)<<8|(16711680&_e)>>8|_e>>>24},de.decrypt=function(_e,K,ve){for(var $,ae,G,Se,ke,je,V,E,U,A,ue,Te,J,W,De=this.keySize+6,Re=this.invKeySchedule,Oe=this.invSBox,ye=this.invSubMix,qe=ye[0],tt=ye[1],ie=ye[2],ce=ye[3],ne=this.uint8ArrayToUint32Array_(ve),xe=ne[0],Pe=ne[1],Ne=ne[2],Be=ne[3],Ke=new Int32Array(_e),pe=new Int32Array(Ke.length),Ie=this.networkToHostOrderSwap;K<Ke.length;){for(U=Ie(Ke[K]),A=Ie(Ke[K+1]),ue=Ie(Ke[K+2]),Te=Ie(Ke[K+3]),ke=U^Re[0],je=Te^Re[1],V=ue^Re[2],E=A^Re[3],J=4,W=1;W<De;W++)$=qe[ke>>>24]^tt[je>>16&255]^ie[V>>8&255]^ce[255&E]^Re[J],ae=qe[je>>>24]^tt[V>>16&255]^ie[E>>8&255]^ce[255&ke]^Re[J+1],G=qe[V>>>24]^tt[E>>16&255]^ie[ke>>8&255]^ce[255&je]^Re[J+2],Se=qe[E>>>24]^tt[ke>>16&255]^ie[je>>8&255]^ce[255&V]^Re[J+3],ke=$,je=ae,V=G,E=Se,J+=4;$=Oe[ke>>>24]<<24^Oe[je>>16&255]<<16^Oe[V>>8&255]<<8^Oe[255&E]^Re[J],ae=Oe[je>>>24]<<24^Oe[V>>16&255]<<16^Oe[E>>8&255]<<8^Oe[255&ke]^Re[J+1],G=Oe[V>>>24]<<24^Oe[E>>16&255]<<16^Oe[ke>>8&255]<<8^Oe[255&je]^Re[J+2],Se=Oe[E>>>24]<<24^Oe[ke>>16&255]<<16^Oe[je>>8&255]<<8^Oe[255&V]^Re[J+3],pe[K]=Ie($^xe),pe[K+1]=Ie(Se^Pe),pe[K+2]=Ie(G^Ne),pe[K+3]=Ie(ae^Be),xe=U,Pe=A,Ne=ue,Be=Te,K+=4}return pe.buffer},re}(),w=N(93),k=N(63),me=function(){function re(_e,K){var ve=(K===void 0?{}:K).removePKCS7Padding,$=ve===void 0||ve;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=_e.enableSoftwareAES,this.removePKCS7Padding=$,$)try{var ae=self.crypto;ae&&(this.subtle=ae.subtle||ae.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}var de=re.prototype;return de.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},de.isSync=function(){return this.useSoftware},de.flush=function(){var _e=this.currentResult,K=this.remainderData;if(!_e||K)return w.logger.error("[softwareDecrypt] "+(K?"overflow bytes: "+K.byteLength:"no result")),this.reset(),null;var ve,$,ae,G=new Uint8Array(_e);return this.reset(),this.removePKCS7Padding?(ae=($=(ve=G).byteLength)&&new DataView(ve.buffer).getUint8($-1))?(0,R.sliceUint8)(ve,0,$-ae):ve:G},de.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},de.decrypt=function(_e,K,ve){var $=this;return this.useSoftware?new Promise(function(ae,G){$.softwareDecrypt(new Uint8Array(_e),K,ve);var Se=$.flush();Se?ae(Se.buffer):G(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(_e),K,ve)},de.softwareDecrypt=function(_e,K,ve){var $=this.currentIV,ae=this.currentResult,G=this.remainderData;this.logOnce("JS AES decrypt"),G&&(_e=(0,k.appendUint8Array)(G,_e),this.remainderData=null);var Se=this.getValidChunk(_e);if(!Se.length)return null;$&&(ve=$);var ke=this.softwareDecrypter;ke||(ke=this.softwareDecrypter=new p),ke.expandKey(K);var je=ae;return this.currentResult=ke.decrypt(Se.buffer,0,ve),this.currentIV=(0,R.sliceUint8)(Se,-16).buffer,je||null},de.webCryptoDecrypt=function(_e,K,ve){var $=this,ae=this.subtle;return this.key===K&&this.fastAesKey||(this.key=K,this.fastAesKey=new te(ae,K)),this.fastAesKey.expandKey().then(function(G){return ae?($.logOnce("WebCrypto AES decrypt"),new j(ae,new Uint8Array(ve)).decrypt(_e.buffer,G)):Promise.reject(new Error("web crypto not initialized"))}).catch(function(G){return w.logger.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+G.name+": "+G.message),$.onWebCryptoError(_e,K,ve)})},de.onWebCryptoError=function(_e,K,ve){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(_e,K,ve);var $=this.flush();if($)return $.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")},de.getValidChunk=function(_e){var K=_e,ve=_e.length-_e.length%16;return ve!==_e.length&&(K=(0,R.sliceUint8)(_e,0,ve),this.remainderData=(0,R.sliceUint8)(_e,ve)),K},de.logOnce=function(_e){this.logEnabled&&(w.logger.log("[decrypter]: "+_e),this.logEnabled=!1)},re}()},181:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{canParse:()=>k,decodeFrame:()=>K,getID3Data:()=>p,getID3Frames:()=>_e,getTimeStamp:()=>me,isFooter:()=>R,isHeader:()=>te,isTimeStampFrame:()=>re,testables:()=>ke,utf8ArrayToStr:()=>Se});var j,te=function(V,E){return E+10<=V.length&&V[E]===73&&V[E+1]===68&&V[E+2]===51&&V[E+3]<255&&V[E+4]<255&&V[E+6]<128&&V[E+7]<128&&V[E+8]<128&&V[E+9]<128},R=function(V,E){return E+10<=V.length&&V[E]===51&&V[E+1]===68&&V[E+2]===73&&V[E+3]<255&&V[E+4]<255&&V[E+6]<128&&V[E+7]<128&&V[E+8]<128&&V[E+9]<128},p=function(V,E){for(var U=E,A=0;te(V,E);)A+=10,A+=w(V,E+6),R(V,E+10)&&(A+=10),E+=A;if(A>0)return V.subarray(U,U+A)},w=function(V,E){var U=0;return U=(127&V[E])<<21,U|=(127&V[E+1])<<14,(U|=(127&V[E+2])<<7)|127&V[E+3]},k=function(V,E){return te(V,E)&&w(V,E+6)+10<=V.length-E},me=function(V){for(var E=_e(V),U=0;U<E.length;U++){var A=E[U];if(re(A))return G(A)}},re=function(V){return V&&V.key==="PRIV"&&V.info==="com.apple.streaming.transportStreamTimestamp"},de=function(V){var E=String.fromCharCode(V[0],V[1],V[2],V[3]),U=w(V,4);return{type:E,size:U,data:V.subarray(10,10+U)}},_e=function(V){for(var E=0,U=[];te(V,E);){for(var A=w(V,E+6),ue=(E+=10)+A;E+8<ue;){var Te=de(V.subarray(E)),J=K(Te);J&&U.push(J),E+=Te.size+10}R(V,E)&&(E+=10)}return U},K=function(V){return V.type==="PRIV"?ve(V):V.type[0]==="W"?ae(V):$(V)},ve=function(V){if(!(V.size<2)){var E=Se(V.data,!0),U=new Uint8Array(V.data.subarray(E.length+1));return{key:V.type,info:E,data:U.buffer}}},$=function(V){if(!(V.size<2)){if(V.type==="TXXX"){var E=1,U=Se(V.data.subarray(E),!0);E+=U.length+1;var A=Se(V.data.subarray(E));return{key:V.type,info:U,data:A}}var ue=Se(V.data.subarray(1));return{key:V.type,data:ue}}},ae=function(V){if(V.type==="WXXX"){if(V.size<2)return;var E=1,U=Se(V.data.subarray(E),!0);E+=U.length+1;var A=Se(V.data.subarray(E));return{key:V.type,info:U,data:A}}var ue=Se(V.data);return{key:V.type,data:ue}},G=function(V){if(V.data.byteLength===8){var E=new Uint8Array(V.data),U=1&E[3],A=(E[4]<<23)+(E[5]<<15)+(E[6]<<7)+E[7];return A/=45,U&&(A+=4772185884e-2),Math.round(A)}},Se=function(V,E){E===void 0&&(E=!1);var U=je();if(U){var A=U.decode(V);if(E){var ue=A.indexOf("\0");return ue!==-1?A.substring(0,ue):A}return A.replace(/\0/g,"")}for(var Te,J,W,De=V.length,Re="",Oe=0;Oe<De;){if((Te=V[Oe++])===0&&E)return Re;if(Te!==0&&Te!==3)switch(Te>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:Re+=String.fromCharCode(Te);break;case 12:case 13:J=V[Oe++],Re+=String.fromCharCode((31&Te)<<6|63&J);break;case 14:J=V[Oe++],W=V[Oe++],Re+=String.fromCharCode((15&Te)<<12|(63&J)<<6|(63&W)<<0)}}return Re},ke={decodeTextFrame:$};function je(){return j||self.TextDecoder===void 0||(j=new self.TextDecoder("utf-8")),j}},182:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{default:()=>k});var j=N(544),te=N(851),R=N(93),p=N(729),w=N(973);function k(_e){var K=new p.EventEmitter,ve=function($,ae){_e.postMessage({event:$,data:ae})};K.on(te.Events.FRAG_DECRYPTED,ve),K.on(te.Events.ERROR,ve),_e.addEventListener("message",function($){var ae=$.data;switch(ae.cmd){case"init":var G=JSON.parse(ae.config);_e.transmuxer=new j.default(K,ae.typeSupported,G,ae.vendor,ae.id),(0,R.enableLogs)(G.debug,ae.id),function(){var V=function(U){R.logger[U]=function(A){ve("workerLog",{logType:U,message:A})}};for(var E in R.logger)V(E)}(),ve("init",null);break;case"configure":_e.transmuxer.configure(ae.config);break;case"demux":var Se=_e.transmuxer.push(ae.data,ae.decryptdata,ae.chunkMeta,ae.state);(0,j.isPromise)(Se)?(_e.transmuxer.async=!0,Se.then(function(V){me(_e,V)}).catch(function(V){ve(te.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:ae.chunkMeta,fatal:!1,error:V,err:V,reason:"transmuxer-worker push error"})})):(_e.transmuxer.async=!1,me(_e,Se));break;case"flush":var ke=ae.chunkMeta,je=_e.transmuxer.flush(ke);(0,j.isPromise)(je)||_e.transmuxer.async?((0,j.isPromise)(je)||(je=Promise.resolve(je)),je.then(function(V){de(_e,V,ke)}).catch(function(V){ve(te.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:ae.chunkMeta,fatal:!1,error:V,err:V,reason:"transmuxer-worker flush error"})})):de(_e,je,ke)}})}function me(_e,K){if(!((ve=K.remuxResult).audio||ve.video||ve.text||ve.id3||ve.initSegment))return!1;var ve,$=[],ae=K.remuxResult,G=ae.audio,Se=ae.video;return G&&re($,G),Se&&re($,Se),_e.postMessage({event:"transmuxComplete",data:K},$),!0}function re(_e,K){K.data1&&_e.push(K.data1.buffer),K.data2&&_e.push(K.data2.buffer)}function de(_e,K,ve){K.reduce(function($,ae){return me(_e,ae)||$},!1)||_e.postMessage({event:"transmuxComplete",data:K[0]}),_e.postMessage({event:"flush",data:ve})}},544:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{TransmuxConfig:()=>Ut,TransmuxState:()=>ur,default:()=>Ct,isPromise:()=>Qt});var j=N(851),te=N(973),R=N(21),p=N(965),w=N(181),k=N(856);function me(ee,F){return ee===void 0&&(ee=""),F===void 0&&(F=9e4),{type:ee,id:-1,pid:-1,inputTimeScale:F,sequenceNumber:-1,samples:[],dropped:0}}var re=N(63),de=N(145),_e=function(){function ee(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var F=ee.prototype;return F.resetInitSegment=function(T,C,L,B){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},F.resetTimeStamp=function(T){this.initPTS=T,this.resetContiguity()},F.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},F.canParse=function(T,C){return!1},F.appendFrame=function(T,C,L){},F.demux=function(T,C){this.cachedData&&(T=(0,re.appendUint8Array)(this.cachedData,T),this.cachedData=null);var L,B=w.getID3Data(T,0),Y=B?B.length:0,z=this._audioTrack,ge=this._id3Track,we=B?w.getTimeStamp(B):void 0,Le=T.length;for((this.basePTS===null||this.frameIndex===0&&(0,p.isFiniteNumber)(we))&&(this.basePTS=K(we,C,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),B&&B.length>0&&ge.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:B,type:k.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});Y<Le;){if(this.canParse(T,Y)){var Fe=this.appendFrame(z,T,Y);Fe?(this.frameIndex++,this.lastPTS=Fe.sample.pts,L=Y+=Fe.length):Y=Le}else w.canParse(T,Y)?(B=w.getID3Data(T,Y),ge.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:B,type:k.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),L=Y+=B.length):Y++;if(Y===Le&&L!==Le){var Ve=(0,de.sliceUint8)(T,L);this.cachedData?this.cachedData=(0,re.appendUint8Array)(this.cachedData,Ve):this.cachedData=Ve}}return{audioTrack:z,videoTrack:me(),id3Track:ge,textTrack:me()}},F.demuxSampleAes=function(T,C,L){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},F.flush=function(T){var C=this.cachedData;return C&&(this.cachedData=null,this.demux(C,0)),{audioTrack:this._audioTrack,videoTrack:me(),id3Track:this._id3Track,textTrack:me()}},F.destroy=function(){},ee}(),K=function(ee,F,T){return(0,p.isFiniteNumber)(ee)?90*ee:9e4*F+(T||0)};let ve=_e;var $=N(93);function ae(ee,F){return ee[F]===255&&(246&ee[F+1])==240}function G(ee,F){return 1&ee[F+1]?7:9}function Se(ee,F){return(3&ee[F+3])<<11|ee[F+4]<<3|(224&ee[F+5])>>>5}function ke(ee,F){return F+1<ee.length&&ae(ee,F)}function je(ee,F){if(ke(ee,F)){var T=G(ee,F);if(F+T>=ee.length)return!1;var C=Se(ee,F);if(C<=T)return!1;var L=F+C;return L===ee.length||ke(ee,L)}return!1}function V(ee,F,T,C,L){if(!ee.samplerate){var B=function(Y,z,ge,we){var Le,Fe,Ve,Ue,Qe=navigator.userAgent.toLowerCase(),ot=we,bt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Le=1+((192&z[ge+2])>>>6);var We=(60&z[ge+2])>>>2;if(!(We>bt.length-1))return Ve=(1&z[ge+2])<<2,Ve|=(192&z[ge+3])>>>6,$.logger.log("manifest codec:"+we+", ADTS type:"+Le+", samplingIndex:"+We),/firefox/i.test(Qe)?We>=6?(Le=5,Ue=new Array(4),Fe=We-3):(Le=2,Ue=new Array(2),Fe=We):Qe.indexOf("android")!==-1?(Le=2,Ue=new Array(2),Fe=We):(Le=5,Ue=new Array(4),we&&(we.indexOf("mp4a.40.29")!==-1||we.indexOf("mp4a.40.5")!==-1)||!we&&We>=6?Fe=We-3:((we&&we.indexOf("mp4a.40.2")!==-1&&(We>=6&&Ve===1||/vivaldi/i.test(Qe))||!we&&Ve===1)&&(Le=2,Ue=new Array(2)),Fe=We)),Ue[0]=Le<<3,Ue[0]|=(14&We)>>1,Ue[1]|=(1&We)<<7,Ue[1]|=Ve<<3,Le===5&&(Ue[1]|=(14&Fe)>>1,Ue[2]=(1&Fe)<<7,Ue[2]|=8,Ue[3]=0),{config:Ue,samplerate:bt[We],channelCount:Ve,codec:"mp4a.40."+Le,manifestCodec:ot};Y.trigger(j.Events.ERROR,{type:te.ErrorTypes.MEDIA_ERROR,details:te.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+We})}(F,T,C,L);if(!B)return;ee.config=B.config,ee.samplerate=B.samplerate,ee.channelCount=B.channelCount,ee.codec=B.codec,ee.manifestCodec=B.manifestCodec,$.logger.log("parsed codec:"+ee.codec+", rate:"+B.samplerate+", channels:"+B.channelCount)}}function E(ee){return 9216e4/ee}function U(ee,F,T,C,L){var B,Y=C+L*E(ee.samplerate),z=function(Qe,ot){var bt=G(Qe,ot);if(ot+bt<=Qe.length){var We=Se(Qe,ot)-bt;if(We>0)return{headerLength:bt,frameLength:We}}}(F,T);if(z){var ge=z.frameLength,we=z.headerLength,Le=we+ge,Fe=Math.max(0,T+Le-F.length);Fe?(B=new Uint8Array(Le-we)).set(F.subarray(T+we,F.length),0):B=F.subarray(T+we,T+Le);var Ve={unit:B,pts:Y};return Fe||ee.samples.push(Ve),{sample:Ve,length:Le,missing:Fe}}var Ue=F.length-T;return(B=new Uint8Array(Ue)).set(F.subarray(T,F.length),0),{sample:{unit:B,pts:Y},length:Ue,missing:-1}}function A(ee,F){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,C){return T.__proto__=C,T},A(ee,F)}let ue=function(ee){var F,T;function C(B,Y){var z;return(z=ee.call(this)||this).observer=void 0,z.config=void 0,z.observer=B,z.config=Y,z}T=ee,(F=C).prototype=Object.create(T.prototype),F.prototype.constructor=F,A(F,T);var L=C.prototype;return L.resetInitSegment=function(B,Y,z,ge){ee.prototype.resetInitSegment.call(this,B,Y,z,ge),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:Y,duration:ge,inputTimeScale:9e4,dropped:0}},C.probe=function(B){if(!B)return!1;for(var Y=(w.getID3Data(B,0)||[]).length,z=B.length;Y<z;Y++)if(je(B,Y))return $.logger.log("ADTS sync word found !"),!0;return!1},L.canParse=function(B,Y){return function(z,ge){return function(we,Le){return Le+5<we.length}(z,ge)&&ae(z,ge)&&Se(z,ge)<=z.length-ge}(B,Y)},L.appendFrame=function(B,Y,z){V(B,this.observer,Y,z,B.manifestCodec);var ge=U(B,Y,z,this.basePTS,this.frameIndex);if(ge&&ge.missing===0)return ge},C}(ve);var Te=/\/emsg[-/]ID3/i;let J=function(){function ee(T,C){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=C}var F=ee.prototype;return F.resetTimeStamp=function(){},F.resetInitSegment=function(T,C,L,B){var Y=this.videoTrack=me("video",1),z=this.audioTrack=me("audio",1),ge=this.txtTrack=me("text",1);if(this.id3Track=me("id3",1),this.timeOffset=0,T&&T.byteLength){var we=(0,re.parseInitSegment)(T);if(we.video){var Le=we.video,Fe=Le.id,Ve=Le.timescale,Ue=Le.codec;Y.id=Fe,Y.timescale=ge.timescale=Ve,Y.codec=Ue}if(we.audio){var Qe=we.audio,ot=Qe.id,bt=Qe.timescale,We=Qe.codec;z.id=ot,z.timescale=bt,z.codec=We}ge.id=re.RemuxerTrackIdConfig.text,Y.sampleDuration=0,Y.duration=z.duration=B}},F.resetContiguity=function(){},ee.probe=function(T){return T=T.length>16384?T.subarray(0,16384):T,(0,re.findBox)(T,["moof"]).length>0},F.demux=function(T,C){this.timeOffset=C;var L=T,B=this.videoTrack,Y=this.txtTrack;if(this.config.progressive){this.remainderData&&(L=(0,re.appendUint8Array)(this.remainderData,T));var z=(0,re.segmentValidRange)(L);this.remainderData=z.remainder,B.samples=z.valid||new Uint8Array}else B.samples=L;var ge=this.extractID3Track(B,C);return Y.samples=(0,re.parseSamples)(C,B),{videoTrack:B,audioTrack:this.audioTrack,id3Track:ge,textTrack:this.txtTrack}},F.flush=function(){var T=this.timeOffset,C=this.videoTrack,L=this.txtTrack;C.samples=this.remainderData||new Uint8Array,this.remainderData=null;var B=this.extractID3Track(C,this.timeOffset);return L.samples=(0,re.parseSamples)(T,C),{videoTrack:C,audioTrack:me(),id3Track:B,textTrack:me()}},F.extractID3Track=function(T,C){var L=this.id3Track;if(T.samples.length){var B=(0,re.findBox)(T.samples,["emsg"]);B&&B.forEach(function(Y){var z=(0,re.parseEmsg)(Y);if(Te.test(z.schemeIdUri)){var ge=(0,p.isFiniteNumber)(z.presentationTime)?z.presentationTime/z.timeScale:C+z.presentationTimeDelta/z.timeScale,we=z.eventDuration===4294967295?Number.POSITIVE_INFINITY:z.eventDuration/z.timeScale;we<=.001&&(we=Number.POSITIVE_INFINITY);var Le=z.payload;L.samples.push({data:Le,len:Le.byteLength,dts:ge,pts:ge,type:k.MetadataSchema.emsg,duration:we})}})}return L},F.demuxSampleAes=function(T,C,L){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},F.destroy=function(){},ee}();var W=null,De=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Re=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Oe=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ye=[0,1,1,4];function qe(ee,F,T,C,L){if(!(T+24>F.length)){var B=tt(F,T);if(B&&T+B.frameLength<=F.length){var Y=C+L*(9e4*B.samplesPerFrame/B.sampleRate),z={unit:F.subarray(T,T+B.frameLength),pts:Y,dts:Y};return ee.config=[],ee.channelCount=B.channelCount,ee.samplerate=B.sampleRate,ee.samples.push(z),{sample:z,length:B.frameLength,missing:0}}}}function tt(ee,F){var T=ee[F+1]>>3&3,C=ee[F+1]>>1&3,L=ee[F+2]>>4&15,B=ee[F+2]>>2&3;if(T!==1&&L!==0&&L!==15&&B!==3){var Y=ee[F+2]>>1&1,z=ee[F+3]>>6,ge=1e3*De[14*(T===3?3-C:C===3?3:4)+L-1],we=Re[3*(T===3?0:T===2?1:2)+B],Le=z===3?1:2,Fe=Oe[T][C],Ve=ye[C],Ue=8*Fe*Ve,Qe=Math.floor(Fe*ge/we+Y)*Ve;if(W===null){var ot=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);W=ot?parseInt(ot[1]):0}return!!W&&W<=87&&C===2&&ge>=224e3&&z===0&&(ee[F+3]=128|ee[F+3]),{sampleRate:we,channelCount:Le,frameLength:Qe,samplesPerFrame:Ue}}}function ie(ee,F){return ee[F]===255&&(224&ee[F+1])==224&&(6&ee[F+1])!=0}function ce(ee,F){return F+1<ee.length&&ie(ee,F)}function ne(ee,F){if(F+1<ee.length&&ie(ee,F)){var T=tt(ee,F),C=4;T!=null&&T.frameLength&&(C=T.frameLength);var L=F+C;return L===ee.length||ce(ee,L)}return!1}let xe=function(){function ee(T){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=T,this.bytesAvailable=T.byteLength,this.word=0,this.bitsAvailable=0}var F=ee.prototype;return F.loadWord=function(){var T=this.data,C=this.bytesAvailable,L=T.byteLength-C,B=new Uint8Array(4),Y=Math.min(4,C);if(Y===0)throw new Error("no bytes available");B.set(T.subarray(L,L+Y)),this.word=new DataView(B.buffer).getUint32(0),this.bitsAvailable=8*Y,this.bytesAvailable-=Y},F.skipBits=function(T){var C;T=Math.min(T,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>T?(this.word<<=T,this.bitsAvailable-=T):(T-=this.bitsAvailable,T-=(C=T>>3)<<3,this.bytesAvailable-=C,this.loadWord(),this.word<<=T,this.bitsAvailable-=T)},F.readBits=function(T){var C=Math.min(this.bitsAvailable,T),L=this.word>>>32-C;if(T>32&&$.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=C,this.bitsAvailable>0)this.word<<=C;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(C=T-C)>0&&this.bitsAvailable?L<<C|this.readBits(C):L},F.skipLZ=function(){var T;for(T=0;T<this.bitsAvailable;++T)if((this.word&2147483648>>>T)!=0)return this.word<<=T,this.bitsAvailable-=T,T;return this.loadWord(),T+this.skipLZ()},F.skipUEG=function(){this.skipBits(1+this.skipLZ())},F.skipEG=function(){this.skipBits(1+this.skipLZ())},F.readUEG=function(){var T=this.skipLZ();return this.readBits(T+1)-1},F.readEG=function(){var T=this.readUEG();return 1&T?1+T>>>1:-1*(T>>>1)},F.readBoolean=function(){return this.readBits(1)===1},F.readUByte=function(){return this.readBits(8)},F.readUShort=function(){return this.readBits(16)},F.readUInt=function(){return this.readBits(32)},F.skipScalingList=function(T){for(var C=8,L=8,B=0;B<T;B++)L!==0&&(L=(C+this.readEG()+256)%256),C=L===0?C:L},F.readSPS=function(){var T,C,L,B=0,Y=0,z=0,ge=0,we=this.readUByte.bind(this),Le=this.readBits.bind(this),Fe=this.readUEG.bind(this),Ve=this.readBoolean.bind(this),Ue=this.skipBits.bind(this),Qe=this.skipEG.bind(this),ot=this.skipUEG.bind(this),bt=this.skipScalingList.bind(this);we();var We=we();if(Le(5),Ue(3),we(),ot(),We===100||We===110||We===122||We===244||We===44||We===83||We===86||We===118||We===128){var kt=Fe();if(kt===3&&Ue(1),ot(),ot(),Ue(1),Ve())for(C=kt!==3?8:12,L=0;L<C;L++)Ve()&&bt(L<6?16:64)}ot();var Jt=Fe();if(Jt===0)Fe();else if(Jt===1)for(Ue(1),Qe(),Qe(),T=Fe(),L=0;L<T;L++)Qe();ot(),Ue(1);var Ft=Fe(),Pt=Fe(),Bt=Le(1);Bt===0&&Ue(1),Ue(1),Ve()&&(B=Fe(),Y=Fe(),z=Fe(),ge=Fe());var Ze=[1,1];if(Ve()&&Ve())switch(we()){case 1:Ze=[1,1];break;case 2:Ze=[12,11];break;case 3:Ze=[10,11];break;case 4:Ze=[16,11];break;case 5:Ze=[40,33];break;case 6:Ze=[24,11];break;case 7:Ze=[20,11];break;case 8:Ze=[32,11];break;case 9:Ze=[80,33];break;case 10:Ze=[18,11];break;case 11:Ze=[15,11];break;case 12:Ze=[64,33];break;case 13:Ze=[160,99];break;case 14:Ze=[4,3];break;case 15:Ze=[3,2];break;case 16:Ze=[2,1];break;case 255:Ze=[we()<<8|we(),we()<<8|we()]}return{width:Math.ceil(16*(Ft+1)-2*B-2*Y),height:(2-Bt)*(Pt+1)*16-(Bt?2:4)*(z+ge),pixelRatio:Ze}},F.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},ee}(),Pe=function(){function ee(T,C,L){this.keyData=void 0,this.decrypter=void 0,this.keyData=L,this.decrypter=new R.default(C,{removePKCS7Padding:!1})}var F=ee.prototype;return F.decryptBuffer=function(T){return this.decrypter.decrypt(T,this.keyData.key.buffer,this.keyData.iv.buffer)},F.decryptAacSample=function(T,C,L){var B=this,Y=T[C].unit;if(!(Y.length<=16)){var z=Y.subarray(16,Y.length-Y.length%16),ge=z.buffer.slice(z.byteOffset,z.byteOffset+z.length);this.decryptBuffer(ge).then(function(we){var Le=new Uint8Array(we);Y.set(Le,16),B.decrypter.isSync()||B.decryptAacSamples(T,C+1,L)})}},F.decryptAacSamples=function(T,C,L){for(;;C++){if(C>=T.length)return void L();if(!(T[C].unit.length<32||(this.decryptAacSample(T,C,L),this.decrypter.isSync())))return}},F.getAvcEncryptedData=function(T){for(var C=16*Math.floor((T.length-48)/160)+16,L=new Int8Array(C),B=0,Y=32;Y<T.length-16;Y+=160,B+=16)L.set(T.subarray(Y,Y+16),B);return L},F.getAvcDecryptedUnit=function(T,C){for(var L=new Uint8Array(C),B=0,Y=32;Y<T.length-16;Y+=160,B+=16)T.set(L.subarray(B,B+16),Y);return T},F.decryptAvcSample=function(T,C,L,B,Y){var z=this,ge=(0,re.discardEPB)(Y.data),we=this.getAvcEncryptedData(ge);this.decryptBuffer(we.buffer).then(function(Le){Y.data=z.getAvcDecryptedUnit(ge,Le),z.decrypter.isSync()||z.decryptAvcSamples(T,C,L+1,B)})},F.decryptAvcSamples=function(T,C,L,B){if(T instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;C++,L=0){if(C>=T.length)return void B();for(var Y=T[C].units;!(L>=Y.length);L++){var z=Y[L];if(!(z.data.length<=48||z.type!==1&&z.type!==5||(this.decryptAvcSample(T,C,L,B,z),this.decrypter.isSync())))return}}},ee}();function Ne(){return Ne=Object.assign?Object.assign.bind():function(ee){for(var F=1;F<arguments.length;F++){var T=arguments[F];for(var C in T)Object.prototype.hasOwnProperty.call(T,C)&&(ee[C]=T[C])}return ee},Ne.apply(this,arguments)}var Be=188;function Ke(ee,F,T,C){return{key:ee,frame:!1,pts:F,dts:T,units:[],debug:C,length:0}}function pe(ee,F){return(31&ee[F+10])<<8|ee[F+11]}function Ie(ee,F,T,C){var L={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},B=F+3+((15&ee[F+1])<<8|ee[F+2])-4;for(F+=12+((15&ee[F+10])<<8|ee[F+11]);F<B;){var Y=(31&ee[F+1])<<8|ee[F+2];switch(ee[F]){case 207:if(!C){$.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:L.audio===-1&&(L.audio=Y);break;case 21:L.id3===-1&&(L.id3=Y);break;case 219:if(!C){$.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:L.avc===-1&&(L.avc=Y);break;case 3:case 4:T.mpeg!==!0&&T.mp3!==!0?$.logger.log("MPEG audio found, not supported in this browser"):L.audio===-1&&(L.audio=Y,L.segmentCodec="mp3");break;case 36:$.logger.warn("Unsupported HEVC stream type found")}F+=5+((15&ee[F+3])<<8|ee[F+4])}return L}function Ye(ee){var F,T,C,L,B,Y=0,z=ee.data;if(!ee||ee.size===0)return null;for(;z[0].length<19&&z.length>1;){var ge=new Uint8Array(z[0].length+z[1].length);ge.set(z[0]),ge.set(z[1],z[0].length),z[0]=ge,z.splice(1,1)}if(((F=z[0])[0]<<16)+(F[1]<<8)+F[2]===1){if((T=(F[4]<<8)+F[5])&&T>ee.size-6)return null;var we=F[7];192&we&&(L=536870912*(14&F[9])+4194304*(255&F[10])+16384*(254&F[11])+128*(255&F[12])+(254&F[13])/2,64&we?L-(B=536870912*(14&F[14])+4194304*(255&F[15])+16384*(254&F[16])+128*(255&F[17])+(254&F[18])/2)>54e5&&($.logger.warn(Math.round((L-B)/9e4)+"s delta between PTS and DTS, align them"),L=B):B=L);var Le=(C=F[8])+9;if(ee.size<=Le)return null;ee.size-=Le;for(var Fe=new Uint8Array(ee.size),Ve=0,Ue=z.length;Ve<Ue;Ve++){var Qe=(F=z[Ve]).byteLength;if(Le){if(Le>Qe){Le-=Qe;continue}F=F.subarray(Le),Qe-=Le,Le=0}Fe.set(F,Y),Y+=Qe}return T&&(T-=C+3),{data:Fe,pts:L,dts:B,len:T}}return null}function rt(ee,F){if(ee.units.length&&ee.frame){if(ee.pts===void 0){var T=F.samples,C=T.length;if(!C)return void F.dropped++;var L=T[C-1];ee.pts=L.pts,ee.dts=L.dts}F.samples.push(ee)}ee.debug.length&&$.logger.log(ee.pts+"/"+ee.dts+":"+ee.debug)}let yt=function(){function ee(T,C,L){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=T,this.config=C,this.typeSupported=L}ee.probe=function(T){var C=ee.syncOffset(T);return C>0&&$.logger.warn("MPEG2-TS detected but first sync word found @ offset "+C),C!==-1},ee.syncOffset=function(T){for(var C=Math.min(940,T.length-376)+1,L=0;L<C;){if(T[L]===71&&T[L+Be]===71)return L;L++}return-1},ee.createTrack=function(T,C){return{container:T==="video"||T==="audio"?"video/mp2t":void 0,type:T,id:re.RemuxerTrackIdConfig[T],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:T==="audio"?C:void 0}};var F=ee.prototype;return F.resetInitSegment=function(T,C,L,B){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=ee.createTrack("video"),this._audioTrack=ee.createTrack("audio",B),this._id3Track=ee.createTrack("id3"),this._txtTrack=ee.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=C,this.videoCodec=L,this._duration=B},F.resetTimeStamp=function(){},F.resetContiguity=function(){var T=this._audioTrack,C=this._avcTrack,L=this._id3Track;T&&(T.pesData=null),C&&(C.pesData=null),L&&(L.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},F.demux=function(T,C,L,B){var Y;L===void 0&&(L=!1),B===void 0&&(B=!1),L||(this.sampleAes=null);var z=this._avcTrack,ge=this._audioTrack,we=this._id3Track,Le=this._txtTrack,Fe=z.pid,Ve=z.pesData,Ue=ge.pid,Qe=we.pid,ot=ge.pesData,bt=we.pesData,We=null,kt=this.pmtParsed,Jt=this._pmtId,Ft=T.length;if(this.remainderData&&(Ft=(T=(0,re.appendUint8Array)(this.remainderData,T)).length,this.remainderData=null),Ft<Be&&!B)return this.remainderData=T,{audioTrack:ge,videoTrack:z,id3Track:we,textTrack:Le};var Pt=Math.max(0,ee.syncOffset(T));(Ft-=(Ft-Pt)%Be)<T.byteLength&&!B&&(this.remainderData=new Uint8Array(T.buffer,Ft,T.buffer.byteLength-Ft));for(var Bt=0,Ze=Pt;Ze<Ft;Ze+=Be)if(T[Ze]===71){var ir=!!(64&T[Ze+1]),br=((31&T[Ze+1])<<8)+T[Ze+2],Nt=void 0;if((48&T[Ze+3])>>4>1){if((Nt=Ze+5+T[Ze+4])===Ze+Be)continue}else Nt=Ze+4;switch(br){case Fe:ir&&(Ve&&(Y=Ye(Ve))&&this.parseAVCPES(z,Le,Y,!1),Ve={data:[],size:0}),Ve&&(Ve.data.push(T.subarray(Nt,Ze+Be)),Ve.size+=Ze+Be-Nt);break;case Ue:if(ir){if(ot&&(Y=Ye(ot)))switch(ge.segmentCodec){case"aac":this.parseAACPES(ge,Y);break;case"mp3":this.parseMPEGPES(ge,Y)}ot={data:[],size:0}}ot&&(ot.data.push(T.subarray(Nt,Ze+Be)),ot.size+=Ze+Be-Nt);break;case Qe:ir&&(bt&&(Y=Ye(bt))&&this.parseID3PES(we,Y),bt={data:[],size:0}),bt&&(bt.data.push(T.subarray(Nt,Ze+Be)),bt.size+=Ze+Be-Nt);break;case 0:ir&&(Nt+=T[Nt]+1),Jt=this._pmtId=pe(T,Nt);break;case Jt:ir&&(Nt+=T[Nt]+1);var Yt=Ie(T,Nt,this.typeSupported,L);(Fe=Yt.avc)>0&&(z.pid=Fe),(Ue=Yt.audio)>0&&(ge.pid=Ue,ge.segmentCodec=Yt.segmentCodec),(Qe=Yt.id3)>0&&(we.pid=Qe),We===null||kt||($.logger.log("unknown PID '"+We+"' in TS found"),We=null,Ze=Pt-188),kt=this.pmtParsed=!0;break;case 17:case 8191:break;default:We=br}}else Bt++;Bt>0&&this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:te.ErrorTypes.MEDIA_ERROR,details:te.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Bt+" TS packet/s that do not start with 0x47"}),z.pesData=Ve,ge.pesData=ot,we.pesData=bt;var cr={audioTrack:ge,videoTrack:z,id3Track:we,textTrack:Le};return B&&this.extractRemainingSamples(cr),cr},F.flush=function(){var T,C=this.remainderData;return this.remainderData=null,T=C?this.demux(C,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(T),this.sampleAes?this.decrypt(T,this.sampleAes):T},F.extractRemainingSamples=function(T){var C,L=T.audioTrack,B=T.videoTrack,Y=T.id3Track,z=T.textTrack,ge=B.pesData,we=L.pesData,Le=Y.pesData;if(ge&&(C=Ye(ge))?(this.parseAVCPES(B,z,C,!0),B.pesData=null):B.pesData=ge,we&&(C=Ye(we))){switch(L.segmentCodec){case"aac":this.parseAACPES(L,C);break;case"mp3":this.parseMPEGPES(L,C)}L.pesData=null}else we!=null&&we.size&&$.logger.log("last AAC PES packet truncated,might overlap between fragments"),L.pesData=we;Le&&(C=Ye(Le))?(this.parseID3PES(Y,C),Y.pesData=null):Y.pesData=Le},F.demuxSampleAes=function(T,C,L){var B=this.demux(T,L,!0,!this.config.progressive),Y=this.sampleAes=new Pe(this.observer,this.config,C);return this.decrypt(B,Y)},F.decrypt=function(T,C){return new Promise(function(L){var B=T.audioTrack,Y=T.videoTrack;B.samples&&B.segmentCodec==="aac"?C.decryptAacSamples(B.samples,0,function(){Y.samples?C.decryptAvcSamples(Y.samples,0,0,function(){L(T)}):L(T)}):Y.samples&&C.decryptAvcSamples(Y.samples,0,0,function(){L(T)})})},F.destroy=function(){this._duration=0},F.parseAVCPES=function(T,C,L,B){var Y,z=this,ge=this.parseAVCNALu(T,L.data),we=this.avcSample,Le=!1;L.data=null,we&&ge.length&&!T.audFound&&(rt(we,T),we=this.avcSample=Ke(!1,L.pts,L.dts,"")),ge.forEach(function(Fe){switch(Fe.type){case 1:Y=!0,we||(we=z.avcSample=Ke(!0,L.pts,L.dts,"")),we.frame=!0;var Ve=Fe.data;if(Le&&Ve.length>4){var Ue=new xe(Ve).readSliceType();Ue!==2&&Ue!==4&&Ue!==7&&Ue!==9||(we.key=!0)}break;case 5:Y=!0,we||(we=z.avcSample=Ke(!0,L.pts,L.dts,"")),we.key=!0,we.frame=!0;break;case 6:Y=!0,(0,re.parseSEIMessageFromNALu)(Fe.data,1,L.pts,C.samples);break;case 7:if(Y=!0,Le=!0,!T.sps){var Qe=new xe(Fe.data).readSPS();T.width=Qe.width,T.height=Qe.height,T.pixelRatio=Qe.pixelRatio,T.sps=[Fe.data],T.duration=z._duration;for(var ot=Fe.data.subarray(1,4),bt="avc1.",We=0;We<3;We++){var kt=ot[We].toString(16);kt.length<2&&(kt="0"+kt),bt+=kt}T.codec=bt}break;case 8:Y=!0,T.pps||(T.pps=[Fe.data]);break;case 9:Y=!1,T.audFound=!0,we&&rt(we,T),we=z.avcSample=Ke(!1,L.pts,L.dts,"");break;case 12:Y=!0;break;default:Y=!1,we&&(we.debug+="unknown NAL "+Fe.type+" ")}we&&Y&&we.units.push(Fe)}),B&&we&&(rt(we,T),this.avcSample=null)},F.getLastNalUnit=function(T){var C,L,B=this.avcSample;if(B&&B.units.length!==0||(B=T[T.length-1]),(C=B)!==null&&C!==void 0&&C.units){var Y=B.units;L=Y[Y.length-1]}return L},F.parseAVCNALu=function(T,C){var L,B,Y=C.byteLength,z=T.naluState||0,ge=z,we=[],Le=0,Fe=-1,Ve=0;for(z===-1&&(Fe=0,Ve=31&C[0],z=0,Le=1);Le<Y;)if(L=C[Le++],z)if(z!==1)if(L)if(L===1){if(Fe>=0){var Ue={data:C.subarray(Fe,Le-z-1),type:Ve};we.push(Ue)}else{var Qe=this.getLastNalUnit(T.samples);if(Qe&&(ge&&Le<=4-ge&&Qe.state&&(Qe.data=Qe.data.subarray(0,Qe.data.byteLength-ge)),(B=Le-z-1)>0)){var ot=new Uint8Array(Qe.data.byteLength+B);ot.set(Qe.data,0),ot.set(C.subarray(0,B),Qe.data.byteLength),Qe.data=ot,Qe.state=0}}Le<Y?(Fe=Le,Ve=31&C[Le],z=0):z=-1}else z=0;else z=3;else z=L?0:2;else z=L?0:1;if(Fe>=0&&z>=0){var bt={data:C.subarray(Fe,Y),type:Ve,state:z};we.push(bt)}if(we.length===0){var We=this.getLastNalUnit(T.samples);if(We){var kt=new Uint8Array(We.data.byteLength+C.byteLength);kt.set(We.data,0),kt.set(C,We.data.byteLength),We.data=kt}}return T.naluState=z,we},F.parseAACPES=function(T,C){var L,B,Y,z,ge,we=0,Le=this.aacOverFlow,Fe=C.data;if(Le){this.aacOverFlow=null;var Ve=Le.missing,Ue=Le.sample.unit.byteLength;if(Ve===-1){var Qe=new Uint8Array(Ue+Fe.byteLength);Qe.set(Le.sample.unit,0),Qe.set(Fe,Ue),Fe=Qe}else{var ot=Ue-Ve;Le.sample.unit.set(Fe.subarray(0,Ve),ot),T.samples.push(Le.sample),we=Le.missing}}for(L=we,B=Fe.length;L<B-1&&!ke(Fe,L);L++);if(L===we||(L<B-1?(Y="AAC PES did not start with ADTS header,offset:"+L,z=!1):(Y="no ADTS header found in AAC PES",z=!0),$.logger.warn("parsing error:"+Y),this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:te.ErrorTypes.MEDIA_ERROR,details:te.ErrorDetails.FRAG_PARSING_ERROR,fatal:z,reason:Y}),!z)){if(V(T,this.observer,Fe,L,this.audioCodec),C.pts!==void 0)ge=C.pts;else{if(!Le)return void $.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var bt=E(T.samplerate);ge=Le.sample.pts+bt}for(var We,kt=0;L<B;){if(L+=(We=U(T,Fe,L,ge,kt)).length,We.missing){this.aacOverFlow=We;break}for(kt++;L<B-1&&!ke(Fe,L);L++);}}},F.parseMPEGPES=function(T,C){var L=C.data,B=L.length,Y=0,z=0,ge=C.pts;if(ge!==void 0)for(;z<B;)if(ce(L,z)){var we=qe(T,L,z,ge,Y);if(!we)break;z+=we.length,Y++}else z++;else $.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},F.parseID3PES=function(T,C){if(C.pts!==void 0){var L=Ne({},C,{type:this._avcTrack?k.MetadataSchema.emsg:k.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});T.samples.push(L)}else $.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},ee}();function ht(ee,F){return ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(T,C){return T.__proto__=C,T},ht(ee,F)}let It=function(ee){var F,T;function C(){return ee.apply(this,arguments)||this}T=ee,(F=C).prototype=Object.create(T.prototype),F.prototype.constructor=F,ht(F,T);var L=C.prototype;return L.resetInitSegment=function(B,Y,z,ge){ee.prototype.resetInitSegment.call(this,B,Y,z,ge),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:Y,duration:ge,inputTimeScale:9e4,dropped:0}},C.probe=function(B){if(!B)return!1;for(var Y=(w.getID3Data(B,0)||[]).length,z=B.length;Y<z;Y++)if(ne(B,Y))return $.logger.log("MPEG Audio sync word found !"),!0;return!1},L.canParse=function(B,Y){return function(z,ge){return ie(z,ge)&&4<=z.length-ge}(B,Y)},L.appendFrame=function(B,Y,z){if(this.basePTS!==null)return qe(B,Y,z,this.basePTS,this.frameIndex)},C}(ve);var Lt=N(524),St=N(923);function At(ee,F){var T=ee==null?void 0:ee.codec;return T&&T.length>4?T:T==="hvc1"||T==="hev1"?"hvc1.1.c.L120.90":T==="av01"?"av01.0.04M.08":T==="avc1"||F===St.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}let pt=function(){function ee(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var F=ee.prototype;return F.destroy=function(){},F.resetTimeStamp=function(T){this.initPTS=T,this.lastEndTime=null},F.resetNextTimestamp=function(){this.lastEndTime=null},F.resetInitSegment=function(T,C,L,B){this.audioCodec=C,this.videoCodec=L,this.generateInitSegment((0,re.patchEncyptionData)(T,B)),this.emitInitSegment=!0},F.generateInitSegment=function(T){var C=this.audioCodec,L=this.videoCodec;if(!T||!T.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var B=this.initData=(0,re.parseInitSegment)(T);C||(C=At(B.audio,St.ElementaryStreamTypes.AUDIO)),L||(L=At(B.video,St.ElementaryStreamTypes.VIDEO));var Y={};B.audio&&B.video?Y.audiovideo={container:"video/mp4",codec:C+","+L,initSegment:T,id:"main"}:B.audio?Y.audio={container:"audio/mp4",codec:C,initSegment:T,id:"audio"}:B.video?Y.video={container:"video/mp4",codec:L,initSegment:T,id:"main"}:$.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=Y},F.remux=function(T,C,L,B,Y){var z,ge=this.initPTS,we=this.lastEndTime,Le={audio:void 0,video:void 0,text:B,id3:L,initSegment:void 0};(0,p.isFiniteNumber)(we)||(we=this.lastEndTime=Y||0);var Fe=C.samples;if(!Fe||!Fe.length)return Le;var Ve={initPTS:void 0,timescale:1},Ue=this.initData;if(Ue&&Ue.length||(this.generateInitSegment(Fe),Ue=this.initData),!Ue||!Ue.length)return $.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),Le;this.emitInitSegment&&(Ve.tracks=this.initTracks,this.emitInitSegment=!1);var Qe=(0,re.getStartDTS)(Ue,Fe);(0,p.isFiniteNumber)(ge)||(this.initPTS=Ve.initPTS=ge=Qe-Y);var ot=(0,re.getDuration)(Fe,Ue),bt=T?Qe-ge:we,We=bt+ot;(0,re.offsetStartDTS)(Ue,Fe,ge),ot>0?this.lastEndTime=We:($.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var kt=!!Ue.audio,Jt=!!Ue.video,Ft="";kt&&(Ft+="audio"),Jt&&(Ft+="video");var Pt={data1:Fe,startPTS:bt,startDTS:bt,endPTS:We,endDTS:We,type:Ft,hasAudio:kt,hasVideo:Jt,nb:1,dropped:0};Le.audio=Pt.type==="audio"?Pt:void 0,Le.video=Pt.type!=="audio"?Pt:void 0,Le.initSegment=Ve;var Bt=(z=this.initPTS)!=null?z:0;return Le.id3=(0,Lt.flushTextTrackMetadataCueSamples)(L,Y,Bt,Bt),B.samples.length&&(Le.text=(0,Lt.flushTextTrackUserdataCueSamples)(B,Y,Bt)),Le},ee}();var ut;try{ut=self.performance.now.bind(self.performance)}catch{$.logger.debug("Unable to use Performance API on this environment"),ut=self.Date.now}var Rt=[{demux:J,remux:pt},{demux:yt,remux:Lt.default},{demux:ue,remux:Lt.default},{demux:It,remux:Lt.default}],Ct=function(){function ee(T,C,L,B,Y){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=T,this.typeSupported=C,this.config=L,this.vendor=B,this.id=Y}var F=ee.prototype;return F.configure=function(T){this.transmuxConfig=T,this.decrypter&&this.decrypter.reset()},F.push=function(T,C,L,B){var Y=this,z=L.transmuxing;z.executeStart=ut();var ge=new Uint8Array(T),we=this.currentTransmuxState,Le=this.transmuxConfig;B&&(this.currentTransmuxState=B);var Fe=B||we,Ve=Fe.contiguous,Ue=Fe.discontinuity,Qe=Fe.trackSwitch,ot=Fe.accurateTimeOffset,bt=Fe.timeOffset,We=Fe.initSegmentChange,kt=Le.audioCodec,Jt=Le.videoCodec,Ft=Le.defaultInitPts,Pt=Le.duration,Bt=Le.initSegmentData,Ze=function(Ir,dr){var Mt=null;return Ir.byteLength>0&&dr!=null&&dr.key!=null&&dr.iv!==null&&dr.method!=null&&(Mt=dr),Mt}(ge,C);if(Ze&&Ze.method==="AES-128"){var ir=this.getDecrypter();if(!ir.isSync())return this.decryptionPromise=ir.webCryptoDecrypt(ge,Ze.key.buffer,Ze.iv.buffer).then(function(Ir){var dr=Y.push(Ir,null,L);return Y.decryptionPromise=null,dr}),this.decryptionPromise;var br=ir.softwareDecrypt(ge,Ze.key.buffer,Ze.iv.buffer);if(!br)return z.executeEnd=ut(),Ht(L);ge=new Uint8Array(br)}var Nt=this.needsProbing(Ue,Qe);Nt&&this.configureTransmuxer(ge),(Ue||Qe||We||Nt)&&this.resetInitSegment(Bt,kt,Jt,Pt,C),(Ue||We||Nt)&&this.resetInitialTimestamp(Ft),Ve||this.resetContiguity();var Yt=this.transmux(ge,Ze,bt,ot,L),cr=this.currentTransmuxState;return cr.contiguous=!0,cr.discontinuity=!1,cr.trackSwitch=!1,z.executeEnd=ut(),Yt},F.flush=function(T){var C=this,L=T.transmuxing;L.executeStart=ut();var B=this.decrypter,Y=this.currentTransmuxState,z=this.decryptionPromise;if(z)return z.then(function(){return C.flush(T)});var ge=[],we=Y.timeOffset;if(B){var Le=B.flush();Le&&ge.push(this.push(Le,null,T))}var Fe=this.demuxer,Ve=this.remuxer;if(!Fe||!Ve)return this.observer.emit(j.Events.ERROR,j.Events.ERROR,{type:te.ErrorTypes.MEDIA_ERROR,details:te.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),L.executeEnd=ut(),[Ht(T)];var Ue=Fe.flush(we);return Qt(Ue)?Ue.then(function(Qe){return C.flushRemux(ge,Qe,T),ge}):(this.flushRemux(ge,Ue,T),ge)},F.flushRemux=function(T,C,L){var B=C.audioTrack,Y=C.videoTrack,z=C.id3Track,ge=C.textTrack,we=this.currentTransmuxState,Le=we.accurateTimeOffset,Fe=we.timeOffset;$.logger.log("[transmuxer.ts]: Flushed fragment "+L.sn+(L.part>-1?" p: "+L.part:"")+" of level "+L.level);var Ve=this.remuxer.remux(B,Y,z,ge,Fe,Le,!0,this.id);T.push({remuxResult:Ve,chunkMeta:L}),L.transmuxing.executeEnd=ut()},F.resetInitialTimestamp=function(T){var C=this.demuxer,L=this.remuxer;C&&L&&(C.resetTimeStamp(T),L.resetTimeStamp(T))},F.resetContiguity=function(){var T=this.demuxer,C=this.remuxer;T&&C&&(T.resetContiguity(),C.resetNextTimestamp())},F.resetInitSegment=function(T,C,L,B,Y){var z=this.demuxer,ge=this.remuxer;z&&ge&&(z.resetInitSegment(T,C,L,B),ge.resetInitSegment(T,C,L,Y))},F.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},F.transmux=function(T,C,L,B,Y){return C&&C.method==="SAMPLE-AES"?this.transmuxSampleAes(T,C,L,B,Y):this.transmuxUnencrypted(T,L,B,Y)},F.transmuxUnencrypted=function(T,C,L,B){var Y=this.demuxer.demux(T,C,!1,!this.config.progressive),z=Y.audioTrack,ge=Y.videoTrack,we=Y.id3Track,Le=Y.textTrack;return{remuxResult:this.remuxer.remux(z,ge,we,Le,C,L,!1,this.id),chunkMeta:B}},F.transmuxSampleAes=function(T,C,L,B,Y){var z=this;return this.demuxer.demuxSampleAes(T,C,L).then(function(ge){return{remuxResult:z.remuxer.remux(ge.audioTrack,ge.videoTrack,ge.id3Track,ge.textTrack,L,B,!1,z.id),chunkMeta:Y}})},F.configureTransmuxer=function(T){for(var C,L=this.config,B=this.observer,Y=this.typeSupported,z=this.vendor,ge=0,we=Rt.length;ge<we;ge++)if(Rt[ge].demux.probe(T)){C=Rt[ge];break}C||($.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),C={demux:J,remux:pt});var Le=this.demuxer,Fe=this.remuxer,Ve=C.remux,Ue=C.demux;Fe&&Fe instanceof Ve||(this.remuxer=new Ve(B,L,Y,z)),Le&&Le instanceof Ue||(this.demuxer=new Ue(B,L,Y),this.probe=Ue.probe)},F.needsProbing=function(T,C){return!this.demuxer||!this.remuxer||T||C},F.getDecrypter=function(){var T=this.decrypter;return T||(T=this.decrypter=new R.default(this.config)),T},ee}(),Ht=function(ee){return{remuxResult:{},chunkMeta:ee}};function Qt(ee){return"then"in ee&&ee.then instanceof Function}var Ut=function(ee,F,T,C,L){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=ee,this.videoCodec=F,this.initSegmentData=T,this.duration=C,this.defaultInitPts=L},ur=function(ee,F,T,C,L,B){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=ee,this.contiguous=F,this.accurateTimeOffset=T,this.trackSwitch=C,this.timeOffset=L,this.initSegmentChange=B}},973:(oe,Q,N)=>{"use strict";var j,te;N.r(Q),N.d(Q,{ErrorDetails:()=>te,ErrorTypes:()=>j}),function(R){R.NETWORK_ERROR="networkError",R.MEDIA_ERROR="mediaError",R.KEY_SYSTEM_ERROR="keySystemError",R.MUX_ERROR="muxError",R.OTHER_ERROR="otherError"}(j||(j={})),function(R){R.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",R.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",R.KEY_SYSTEM_NO_SESSION="keySystemNoSession",R.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",R.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",R.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",R.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",R.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",R.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",R.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",R.MANIFEST_LOAD_ERROR="manifestLoadError",R.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",R.MANIFEST_PARSING_ERROR="manifestParsingError",R.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",R.LEVEL_EMPTY_ERROR="levelEmptyError",R.LEVEL_LOAD_ERROR="levelLoadError",R.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",R.LEVEL_SWITCH_ERROR="levelSwitchError",R.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",R.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",R.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",R.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",R.FRAG_LOAD_ERROR="fragLoadError",R.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",R.FRAG_DECRYPT_ERROR="fragDecryptError",R.FRAG_PARSING_ERROR="fragParsingError",R.REMUX_ALLOC_ERROR="remuxAllocError",R.KEY_LOAD_ERROR="keyLoadError",R.KEY_LOAD_TIMEOUT="keyLoadTimeOut",R.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",R.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",R.BUFFER_APPEND_ERROR="bufferAppendError",R.BUFFER_APPENDING_ERROR="bufferAppendingError",R.BUFFER_STALLED_ERROR="bufferStalledError",R.BUFFER_FULL_ERROR="bufferFullError",R.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",R.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",R.INTERNAL_EXCEPTION="internalException",R.INTERNAL_ABORTED="aborted",R.UNKNOWN="unknown"}(te||(te={}))},851:(oe,Q,N)=>{"use strict";var j;N.r(Q),N.d(Q,{Events:()=>j}),function(te){te.MEDIA_ATTACHING="hlsMediaAttaching",te.MEDIA_ATTACHED="hlsMediaAttached",te.MEDIA_DETACHING="hlsMediaDetaching",te.MEDIA_DETACHED="hlsMediaDetached",te.BUFFER_RESET="hlsBufferReset",te.BUFFER_CODECS="hlsBufferCodecs",te.BUFFER_CREATED="hlsBufferCreated",te.BUFFER_APPENDING="hlsBufferAppending",te.BUFFER_APPENDED="hlsBufferAppended",te.BUFFER_EOS="hlsBufferEos",te.BUFFER_FLUSHING="hlsBufferFlushing",te.BUFFER_FLUSHED="hlsBufferFlushed",te.MANIFEST_LOADING="hlsManifestLoading",te.MANIFEST_LOADED="hlsManifestLoaded",te.MANIFEST_PARSED="hlsManifestParsed",te.LEVEL_SWITCHING="hlsLevelSwitching",te.LEVEL_SWITCHED="hlsLevelSwitched",te.LEVEL_LOADING="hlsLevelLoading",te.LEVEL_LOADED="hlsLevelLoaded",te.LEVEL_UPDATED="hlsLevelUpdated",te.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",te.LEVELS_UPDATED="hlsLevelsUpdated",te.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",te.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",te.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",te.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",te.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",te.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",te.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",te.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",te.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",te.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",te.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",te.CUES_PARSED="hlsCuesParsed",te.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",te.INIT_PTS_FOUND="hlsInitPtsFound",te.FRAG_LOADING="hlsFragLoading",te.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",te.FRAG_LOADED="hlsFragLoaded",te.FRAG_DECRYPTED="hlsFragDecrypted",te.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",te.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",te.FRAG_PARSING_METADATA="hlsFragParsingMetadata",te.FRAG_PARSED="hlsFragParsed",te.FRAG_BUFFERED="hlsFragBuffered",te.FRAG_CHANGED="hlsFragChanged",te.FPS_DROP="hlsFpsDrop",te.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",te.ERROR="hlsError",te.DESTROYING="hlsDestroying",te.KEY_LOADING="hlsKeyLoading",te.KEY_LOADED="hlsKeyLoaded",te.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",te.BACK_BUFFER_REACHED="hlsBackBufferReached"}(j||(j={}))},76:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{default:()=>Ea});var j,te=N(945),R=N(965),p=N(851),w=N(973),k=N(93),me=/^(\d+)x(\d+)$/,re=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,de=function(){function d(e){for(var t in typeof e=="string"&&(e=d.parseAttrList(e)),e)e.hasOwnProperty(t)&&(this[t]=e[t])}var o=d.prototype;return o.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},o.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var i=new Uint8Array(t.length/2),n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(2*n,2*n+2),16);return i}return null},o.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},o.decimalFloatingPoint=function(e){return parseFloat(this[e])},o.optionalFloat=function(e,t){var i=this[e];return i?parseFloat(i):t},o.enumeratedString=function(e){return this[e]},o.bool=function(e){return this[e]==="YES"},o.decimalResolution=function(e){var t=me.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},d.parseAttrList=function(e){var t,i={};for(re.lastIndex=0;(t=re.exec(e))!==null;){var n=t[2];n.indexOf('"')===0&&n.lastIndexOf('"')===n.length-1&&(n=n.slice(1,-1)),i[t[1]]=n}return i},d}();function _e(){return _e=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},_e.apply(this,arguments)}function K(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}(function(d){d.ID="ID",d.CLASS="CLASS",d.START_DATE="START-DATE",d.DURATION="DURATION",d.END_DATE="END-DATE",d.END_ON_NEXT="END-ON-NEXT",d.PLANNED_DURATION="PLANNED-DURATION",d.SCTE35_OUT="SCTE35-OUT",d.SCTE35_IN="SCTE35-IN"})(j||(j={}));var ve=function(){function d(t,i){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,i){var n=i.attr;for(var a in n)if(Object.prototype.hasOwnProperty.call(t,a)&&t[a]!==n[a]){k.logger.warn('DATERANGE tag attribute: "'+a+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=a;break}t=_e(new de({}),n,t)}if(this.attr=t,this._startDate=new Date(t[j.START_DATE]),j.END_DATE in this.attr){var r=new Date(this.attr[j.END_DATE]);(0,R.isFiniteNumber)(r.getTime())&&(this._endDate=r)}}var o,e;return o=d,(e=[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var t=this.duration;return t!==null?new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if(j.DURATION in this.attr){var t=this.attr.decimalFloatingPoint(j.DURATION);if((0,R.isFiniteNumber)(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return j.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(j.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(j.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,R.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}])&&K(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}(),$=N(923);function ae(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var G,Se,ke,je=function(){function d(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}var o,e;return d.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var i=this.lastPartSn-t.lastPartSn,n=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!n||!!i,this.advanced=this.endSN>t.endSN||i>0||i===0&&n>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},o=d,(e=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&(0,R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return(t=this.fragments)!==null&&t!==void 0&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return(t=this.partList)!==null&&t!==void 0&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&ae(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function V(d){return Uint8Array.from(atob(d),function(o){return o.charCodeAt(0)})}function E(d){return Uint8Array.from(unescape(encodeURIComponent(d)),function(o){return o.charCodeAt(0)})}function U(d){switch(d){case Se.FAIRPLAY:return G.FAIRPLAY;case Se.PLAYREADY:return G.PLAYREADY;case Se.WIDEVINE:return G.WIDEVINE;case Se.CLEARKEY:return G.CLEARKEY}}function A(d){switch(d){case G.FAIRPLAY:return Se.FAIRPLAY;case G.PLAYREADY:return Se.PLAYREADY;case G.WIDEVINE:return Se.WIDEVINE;case G.CLEARKEY:return Se.CLEARKEY}}function ue(d){var o=d.drmSystems,e=d.widevineLicenseUrl,t=o?[G.FAIRPLAY,G.WIDEVINE,G.PLAYREADY,G.CLEARKEY].filter(function(i){return!!o[i]}):[];return!t[G.WIDEVINE]&&e&&t.push(G.WIDEVINE),t}(function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.fps",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="com.widevine.alpha"})(G||(G={})),function(d){d.CLEARKEY="org.w3.clearkey",d.FAIRPLAY="com.apple.streamingkeydelivery",d.PLAYREADY="com.microsoft.playready",d.WIDEVINE="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"}(Se||(Se={})),function(d){d.WIDEVINE="edef8ba979d64acea3c827dcd51d21ed"}(ke||(ke={}));var Te=typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null,J=N(63),W={},De=function(){function d(e,t,i,n,a){n===void 0&&(n=[1]),a===void 0&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=n,this.iv=a,this.encrypted=!!e&&e!=="NONE",this.isCommonEncryption=this.encrypted&&e!=="AES-128"}d.clearKeyUriToKeyIdMap=function(){W={}};var o=d.prototype;return o.isSupported=function(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;switch(this.keyFormat){case"identity":return this.method==="SAMPLE-AES";case Se.FAIRPLAY:case Se.WIDEVINE:case Se.PLAYREADY:case Se.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1},o.getDecryptData=function(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method!=="AES-128"||this.iv||k.logger.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),e=0);var t=function(P){for(var I=new Uint8Array(16),q=12;q<16;q++)I[q]=P>>8*(15-q)&255;return I}(e);return new d(this.method,this.uri,"identity",this.keyFormatVersions,t)}var i=function(P){var I,q,se=P.split(":"),Ee=null;if(se[0]==="data"&&se.length===2){var he=se[1].split(";"),Ae=he[he.length-1].split(",");if(Ae.length===2){var He=Ae[0]==="base64",ze=Ae[1];He?(he.splice(-1,1),Ee=V(ze)):(I=E(ze).subarray(0,16),(q=new Uint8Array(16)).set(I,16-I.length),Ee=q)}}return Ee}(this.uri);if(i)switch(this.keyFormat){case Se.WIDEVINE:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case Se.PLAYREADY:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=(0,J.mp4pssh)(n,null,i);var a=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),r=String.fromCharCode.apply(null,Array.from(a)),s=r.substring(r.indexOf("<"),r.length),l=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("KID")[0];if(l){var u=l.childNodes[0]?l.childNodes[0].nodeValue:l.getAttribute("VALUE");if(u){var c=V(u).subarray(0,16);(function(P){var I=function(q,se,Ee){var he=q[se];q[se]=q[Ee],q[Ee]=he};I(P,0,3),I(P,1,2),I(P,4,5),I(P,6,7)})(c),this.keyId=c}}break;default:var v=i.subarray(0,16);if(v.length!==16){var m=new Uint8Array(16);m.set(v,16-v.length),v=m}this.keyId=v}if(!this.keyId||this.keyId.byteLength!==16){var _=W[this.uri];if(!_){var S=Object.keys(W).length%Number.MAX_SAFE_INTEGER;_=new Uint8Array(16),new DataView(_.buffer,12,4).setUint32(0,S),W[this.uri]=_}this.keyId=_}return this},d}(),Re={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function Oe(d,o){return MediaSource.isTypeSupported((o||"video")+'/mp4;codecs="'+d+'"')}function ye(){return ye=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},ye.apply(this,arguments)}var qe=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+|#EXT-X-SESSION-KEY:([^\n\r]*)[\r\n]+/g,tt=/#EXT-X-MEDIA:(.*)/g,ie=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ce=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),ne=function(){function d(){}return d.findGroup=function(o,e){for(var t=0;t<o.length;t++){var i=o[t];if(i.id===e)return i}},d.convertAVC1ToAVCOTI=function(o){var e=o.split(".");if(e.length>2){var t=e.shift()+".";return(t+=parseInt(e.shift()).toString(16))+("000"+parseInt(e.shift()).toString(16)).slice(-4)}return o},d.resolve=function(o,e){return(0,te.buildAbsoluteURL)(e,o,{alwaysNormalize:!0})},d.parseMasterPlaylist=function(o,e){var t,i=[],n=[],a={},r=[],s=!1;for(qe.lastIndex=0;(t=qe.exec(o))!=null;)if(t[1]){var l,u=new de(t[1]),c={attrs:u,bitrate:u.decimalInteger("AVERAGE-BANDWIDTH")||u.decimalInteger("BANDWIDTH"),name:u.NAME,url:d.resolve(t[2],e)},v=u.decimalResolution("RESOLUTION");v&&(c.width=v.width,c.height=v.height),Pe((u.CODECS||"").split(/[ ,]+/).filter(function(P){return P}),c),c.videoCodec&&c.videoCodec.indexOf("avc1")!==-1&&(c.videoCodec=d.convertAVC1ToAVCOTI(c.videoCodec)),(l=c.unknownCodecs)!==null&&l!==void 0&&l.length||n.push(c),i.push(c)}else if(t[3]){var m=new de(t[3]);m["DATA-ID"]&&(s=!0,a[m["DATA-ID"]]=m)}else if(t[4]){var _=t[4],S=xe(_,e);S.encrypted&&S.isSupported()?r.push(S):k.logger.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+_+'"')}return{levels:n.length>0&&n.length<i.length?n:i,sessionData:s?a:null,sessionKeys:r.length?r:null}},d.parseMasterPlaylistMedia=function(o,e,t,i){var n;i===void 0&&(i=[]);var a=[],r=0;for(tt.lastIndex=0;(n=tt.exec(o))!==null;){var s=new de(n[1]);if(s.TYPE===t){var l={attrs:s,bitrate:0,id:r++,groupId:s["GROUP-ID"],instreamId:s["INSTREAM-ID"],name:s.NAME||s.LANGUAGE||"",type:t,default:s.bool("DEFAULT"),autoselect:s.bool("AUTOSELECT"),forced:s.bool("FORCED"),lang:s.LANGUAGE,url:s.URI?d.resolve(s.URI,e):""};if(i.length){var u=d.findGroup(i,l.groupId)||i[0];Ne(l,u,"audioCodec"),Ne(l,u,"textCodec")}a.push(l)}}return a},d.parseLevelPlaylist=function(o,e,t,i,n){var a,r,s,l=new je(e),u=l.fragments,c=null,v=0,m=0,_=0,S=0,P=null,I=new $.Fragment(i,e),q=-1,se=!1;for(ie.lastIndex=0,l.m3u8=o;(a=ie.exec(o))!==null;){se&&(se=!1,(I=new $.Fragment(i,e)).start=_,I.sn=v,I.cc=S,I.level=t,c&&(I.initSegment=c,I.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null));var Ee=a[1];if(Ee){I.duration=parseFloat(Ee);var he=(" "+a[2]).slice(1);I.title=he||null,I.tagList.push(he?["INF",Ee,he]:["INF",Ee])}else if(a[3]){if((0,R.isFiniteNumber)(I.duration)){if(I.start=_,s){I.levelkeys=s;var Ae=l.encryptedFragments;!I.levelkeys||!Object.keys(I.levelkeys).some(function(Dr){return I.levelkeys[Dr].isCommonEncryption})||Ae.length&&Ae[Ae.length-1].levelkeys===s||Ae.push(I)}I.sn=v,I.level=t,I.cc=S,I.urlId=n,u.push(I),I.relurl=(" "+a[3]).slice(1),Be(I,P),P=I,_+=I.duration,v++,m=0,se=!0}}else if(a[4]){var He=(" "+a[4]).slice(1);P?I.setByteRange(He,P):I.setByteRange(He)}else if(a[5])I.rawProgramDateTime=(" "+a[5]).slice(1),I.tagList.push(["PROGRAM-DATE-TIME",I.rawProgramDateTime]),q===-1&&(q=u.length);else{if(!(a=a[0].match(ce))){k.logger.warn("No matches on slow regex match for level playlist!");continue}for(r=1;r<a.length&&a[r]===void 0;r++);var ze=(" "+a[r]).slice(1),be=(" "+a[r+1]).slice(1),Ge=a[r+2]?(" "+a[r+2]).slice(1):"";switch(ze){case"PLAYLIST-TYPE":l.type=be.toUpperCase();break;case"MEDIA-SEQUENCE":v=l.startSN=parseInt(be);break;case"SKIP":var Me=new de(be),ct=Me.decimalInteger("SKIPPED-SEGMENTS");if((0,R.isFiniteNumber)(ct)){l.skippedSegments=ct;for(var Ot=ct;Ot--;)u.unshift(null);v+=ct}var ft=Me.enumeratedString("RECENTLY-REMOVED-DATERANGES");ft&&(l.recentlyRemovedDateranges=ft.split(" "));break;case"TARGETDURATION":l.targetduration=parseFloat(be);break;case"VERSION":l.version=parseInt(be);break;case"EXTM3U":break;case"ENDLIST":l.live=!1;break;case"#":(be||Ge)&&I.tagList.push(Ge?[be,Ge]:[be]);break;case"DISCONTINUITY":S++,I.tagList.push(["DIS"]);break;case"GAP":I.tagList.push([ze]);break;case"BITRATE":I.tagList.push([ze,be]);break;case"DATERANGE":var Tt=new de(be),Dt=new ve(Tt,l.dateRanges[Tt.ID]);Dt.isValid||l.skippedSegments?l.dateRanges[Dt.id]=Dt:k.logger.warn('Ignoring invalid DATERANGE tag: "'+be+'"'),I.tagList.push(["EXT-X-DATERANGE",be]);break;case"DISCONTINUITY-SEQUENCE":S=parseInt(be);break;case"KEY":var Zt=xe(be,e);if(Zt.isSupported()){if(Zt.method==="NONE"){s=void 0;break}s||(s={}),s[Zt.keyFormat]&&(s=ye({},s)),s[Zt.keyFormat]=Zt}else k.logger.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+be+'"');break;case"START":var zt=new de(be).decimalFloatingPoint("TIME-OFFSET");(0,R.isFiniteNumber)(zt)&&(l.startTimeOffset=zt);break;case"MAP":var Kt=new de(be);if(I.duration){var er=new $.Fragment(i,e);Ke(er,Kt,t,s),c=er,I.initSegment=c,c.rawProgramDateTime&&!I.rawProgramDateTime&&(I.rawProgramDateTime=c.rawProgramDateTime)}else Ke(I,Kt,t,s),c=I,se=!0;break;case"SERVER-CONTROL":var Er=new de(be);l.canBlockReload=Er.bool("CAN-BLOCK-RELOAD"),l.canSkipUntil=Er.optionalFloat("CAN-SKIP-UNTIL",0),l.canSkipDateRanges=l.canSkipUntil>0&&Er.bool("CAN-SKIP-DATERANGES"),l.partHoldBack=Er.optionalFloat("PART-HOLD-BACK",0),l.holdBack=Er.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var Gn=new de(be);l.partTarget=Gn.decimalFloatingPoint("PART-TARGET");break;case"PART":var Cr=l.partList;Cr||(Cr=l.partList=[]);var Ni=m>0?Cr[Cr.length-1]:void 0,Ui=m++,Bi=new $.Part(new de(be),I,e,Ui,Ni);Cr.push(Bi),I.duration+=Bi.duration;break;case"PRELOAD-HINT":var st=new de(be);l.preloadHint=st;break;case"RENDITION-REPORT":var vt=new de(be);l.renditionReports=l.renditionReports||[],l.renditionReports.push(vt);break;default:k.logger.warn("line parsed but not handled: "+a)}}}P&&!P.relurl?(u.pop(),_-=P.duration,l.partList&&(l.fragmentHint=P)):l.partList&&(Be(I,P),I.cc=S,l.fragmentHint=I);var yi=u.length,Ur=u[0],Or=u[yi-1];if((_+=l.skippedSegments*l.targetduration)>0&&yi&&Or){l.averagetargetduration=_/yi;var Ei=Or.sn;l.endSN=Ei!=="initSegment"?Ei:0,l.live||(Or.endList=!0),Ur&&(l.startCC=Ur.cc)}else l.endSN=0,l.startCC=0;return l.fragmentHint&&(_+=l.fragmentHint.duration),l.totalduration=_,l.endCC=S,q>0&&function(Dr,Br){for(var Xr=Dr[Br],Ar=Br;Ar--;){var zr=Dr[Ar];if(!zr)return;zr.programDateTime=Xr.programDateTime-1e3*zr.duration,Xr=zr}}(u,q),l},d}();function xe(d,o){var e,t,i=new de(d),n=(e=i.enumeratedString("METHOD"))!=null?e:"",a=i.URI,r=i.hexadecimalInteger("IV"),s=i.enumeratedString("KEYFORMATVERSIONS"),l=(t=i.enumeratedString("KEYFORMAT"))!=null?t:"identity";a&&i.IV&&!r&&k.logger.error("Invalid IV: "+i.IV);var u=a?ne.resolve(a,o):"",c=(s||"1").split("/").map(Number).filter(Number.isFinite);return new De(n,u,l,c,r)}function Pe(d,o){["video","audio","text"].forEach(function(e){var t=d.filter(function(n){return function(a,r){var s=Re[r];return!!s&&s[a.slice(0,4)]===!0}(n,e)});if(t.length){var i=t.filter(function(n){return n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0});o[e+"Codec"]=i.length>0?i[0]:t[0],d=d.filter(function(n){return t.indexOf(n)===-1})}}),o.unknownCodecs=d}function Ne(d,o,e){var t=o[e];t&&(d[e]=t)}function Be(d,o){d.rawProgramDateTime?d.programDateTime=Date.parse(d.rawProgramDateTime):o!=null&&o.programDateTime&&(d.programDateTime=o.endProgramDateTime),(0,R.isFiniteNumber)(d.programDateTime)||(d.programDateTime=null,d.rawProgramDateTime=null)}function Ke(d,o,e,t){d.relurl=o.URI,o.BYTERANGE&&d.setByteRange(o.BYTERANGE),d.level=e,d.sn="initSegment",t&&(d.levelkeys=t),d.initSegment=null}var pe=N(308);function Ie(d,o){var e=d.url;return e!==void 0&&e.indexOf("data:")!==0||(e=o.url),e}let Ye=function(){function d(e){this.hls=void 0,this.loaders=Object.create(null),this.hls=e,this.registerListeners()}var o=d.prototype;return o.startLoad=function(e){},o.stopLoad=function(){this.destroyInternalLoaders()},o.registerListeners=function(){var e=this.hls;e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},o.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},o.createInternalLoader=function(e){var t=this.hls.config,i=t.pLoader,n=t.loader,a=new(i||n)(t);return e.loader=a,this.loaders[e.type]=a,a},o.getInternalLoader=function(e){return this.loaders[e.type]},o.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},o.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},o.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},o.onManifestLoading=function(e,t){var i=t.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:pe.PlaylistContextType.MANIFEST,url:i,deliveryDirectives:null})},o.onLevelLoading=function(e,t){var i=t.id,n=t.level,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:null,level:n,responseType:"text",type:pe.PlaylistContextType.LEVEL,url:a,deliveryDirectives:r})},o.onAudioTrackLoading=function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:n,level:null,responseType:"text",type:pe.PlaylistContextType.AUDIO_TRACK,url:a,deliveryDirectives:r})},o.onSubtitleTrackLoading=function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives;this.load({id:i,groupId:n,level:null,responseType:"text",type:pe.PlaylistContextType.SUBTITLE_TRACK,url:a,deliveryDirectives:r})},o.load=function(e){var t,i,n,a,r,s,l=this.hls.config,u=this.getInternalLoader(e);if(u){var c=u.context;if(c&&c.url===e.url)return void k.logger.trace("[playlist-loader]: playlist request ongoing");k.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),u.abort()}switch(e.type){case pe.PlaylistContextType.MANIFEST:i=l.manifestLoadingMaxRetry,n=l.manifestLoadingTimeOut,a=l.manifestLoadingRetryDelay,r=l.manifestLoadingMaxRetryTimeout;break;case pe.PlaylistContextType.LEVEL:case pe.PlaylistContextType.AUDIO_TRACK:case pe.PlaylistContextType.SUBTITLE_TRACK:i=0,n=l.levelLoadingTimeOut;break;default:i=l.levelLoadingMaxRetry,n=l.levelLoadingTimeOut,a=l.levelLoadingRetryDelay,r=l.levelLoadingMaxRetryTimeout}if(u=this.createInternalLoader(e),(t=e.deliveryDirectives)!==null&&t!==void 0&&t.part&&(e.type===pe.PlaylistContextType.LEVEL&&e.level!==null?s=this.hls.levels[e.level].details:e.type===pe.PlaylistContextType.AUDIO_TRACK&&e.id!==null?s=this.hls.audioTracks[e.id].details:e.type===pe.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(s=this.hls.subtitleTracks[e.id].details),s)){var v=s.partTarget,m=s.targetduration;v&&m&&(n=Math.min(1e3*Math.max(3*v,.8*m),n))}var _={timeout:n,maxRetry:i,retryDelay:a,maxRetryDelay:r,highWaterMark:0},S={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(e,_,S)},o.loadsuccess=function(e,t,i,n){n===void 0&&(n=null),this.resetInternalLoader(i.type);var a=e.data;a.indexOf("#EXTM3U")===0?(t.parsing.start=performance.now(),a.indexOf("#EXTINF:")>0||a.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,t,i,n):this.handleMasterPlaylist(e,t,i,n)):this.handleManifestParsingError(e,i,"no EXTM3U delimiter",n)},o.loaderror=function(e,t,i){i===void 0&&(i=null),this.handleNetworkError(t,i,!1,e)},o.loadtimeout=function(e,t,i){i===void 0&&(i=null),this.handleNetworkError(t,i,!0)},o.handleMasterPlaylist=function(e,t,i,n){var a=this.hls,r=e.data,s=Ie(e,i),l=ne.parseMasterPlaylist(r,s),u=l.levels,c=l.sessionData,v=l.sessionKeys;if(u.length){var m=u.map(function(q){return{id:q.attrs.AUDIO,audioCodec:q.audioCodec}}),_=u.map(function(q){return{id:q.attrs.SUBTITLES,textCodec:q.textCodec}}),S=ne.parseMasterPlaylistMedia(r,s,"AUDIO",m),P=ne.parseMasterPlaylistMedia(r,s,"SUBTITLES",_),I=ne.parseMasterPlaylistMedia(r,s,"CLOSED-CAPTIONS");S.length&&(S.some(function(q){return!q.url})||!u[0].audioCodec||u[0].attrs.AUDIO||(k.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),S.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new de({}),bitrate:0,url:""}))),a.trigger(p.Events.MANIFEST_LOADED,{levels:u,audioTracks:S,subtitles:P,captions:I,url:s,stats:t,networkDetails:n,sessionData:c,sessionKeys:v})}else this.handleManifestParsingError(e,i,"no level found in manifest",n)},o.handleTrackOrLevelPlaylist=function(e,t,i,n){var a=this.hls,r=i.id,s=i.level,l=i.type,u=Ie(e,i),c=(0,R.isFiniteNumber)(r)?r:0,v=(0,R.isFiniteNumber)(s)?s:c,m=function(P){switch(P.type){case pe.PlaylistContextType.AUDIO_TRACK:return pe.PlaylistLevelType.AUDIO;case pe.PlaylistContextType.SUBTITLE_TRACK:return pe.PlaylistLevelType.SUBTITLE;default:return pe.PlaylistLevelType.MAIN}}(i),_=ne.parseLevelPlaylist(e.data,u,v,m,c);if(_.fragments.length){if(l===pe.PlaylistContextType.MANIFEST){var S={attrs:new de({}),bitrate:0,details:_,name:"",url:u};a.trigger(p.Events.MANIFEST_LOADED,{levels:[S],audioTracks:[],url:u,stats:t,networkDetails:n,sessionData:null,sessionKeys:null})}t.parsing.end=performance.now(),i.levelDetails=_,this.handlePlaylistLoaded(e,t,i,n)}else a.trigger(p.Events.ERROR,{type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:u,reason:"no fragments found in level",level:typeof i.level=="number"?i.level:void 0})},o.handleManifestParsingError=function(e,t,i,n){this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===pe.PlaylistContextType.MANIFEST,url:e.url,reason:i,response:e,context:t,networkDetails:n})},o.handleNetworkError=function(e,t,i,n){i===void 0&&(i=!1),k.logger.warn("[playlist-loader]: A network "+(i?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var a=w.ErrorDetails.UNKNOWN,r=!1,s=this.getInternalLoader(e);switch(e.type){case pe.PlaylistContextType.MANIFEST:a=i?w.ErrorDetails.MANIFEST_LOAD_TIMEOUT:w.ErrorDetails.MANIFEST_LOAD_ERROR,r=!0;break;case pe.PlaylistContextType.LEVEL:a=i?w.ErrorDetails.LEVEL_LOAD_TIMEOUT:w.ErrorDetails.LEVEL_LOAD_ERROR,r=!1;break;case pe.PlaylistContextType.AUDIO_TRACK:a=i?w.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:w.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,r=!1;break;case pe.PlaylistContextType.SUBTITLE_TRACK:a=i?w.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:w.ErrorDetails.SUBTITLE_LOAD_ERROR,r=!1}s&&this.resetInternalLoader(e.type);var l={type:w.ErrorTypes.NETWORK_ERROR,details:a,fatal:r,url:e.url,loader:s,context:e,networkDetails:t};n&&(l.response=n),this.hls.trigger(p.Events.ERROR,l)},o.handlePlaylistLoaded=function(e,t,i,n){var a=i.type,r=i.level,s=i.id,l=i.groupId,u=i.loader,c=i.levelDetails,v=i.deliveryDirectives;if(c!=null&&c.targetduration){if(u)switch(c.live&&(u.getCacheAge&&(c.ageHeader=u.getCacheAge()||0),u.getCacheAge&&!isNaN(c.ageHeader)||(c.ageHeader=0)),a){case pe.PlaylistContextType.MANIFEST:case pe.PlaylistContextType.LEVEL:this.hls.trigger(p.Events.LEVEL_LOADED,{details:c,level:r||0,id:s||0,stats:t,networkDetails:n,deliveryDirectives:v});break;case pe.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,{details:c,id:s||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:v});break;case pe.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADED,{details:c,id:s||0,groupId:l||"",stats:t,networkDetails:n,deliveryDirectives:v})}}else this.handleManifestParsingError(e,i,"invalid target duration",n)},d}();function rt(d,o){var e;try{e=new Event("addtrack")}catch{(e=document.createEvent("Event")).initEvent("addtrack",!1,!1)}e.track=d,o.dispatchEvent(e)}function yt(d,o){var e=d.mode;if(e==="disabled"&&(d.mode="hidden"),d.cues&&!d.cues.getCueById(o.id))try{if(d.addCue(o),!d.cues.getCueById(o.id))throw new Error("addCue is failed for: "+o)}catch(i){k.logger.debug("[texttrack-utils]: "+i);var t=new self.TextTrackCue(o.startTime,o.endTime,o.text);t.id=o.id,d.addCue(t)}e==="disabled"&&(d.mode=e)}function ht(d){var o=d.mode;if(o==="disabled"&&(d.mode="hidden"),d.cues)for(var e=d.cues.length;e--;)d.removeCue(d.cues[e]);o==="disabled"&&(d.mode=o)}function It(d,o,e,t){var i=d.mode;if(i==="disabled"&&(d.mode="hidden"),d.cues&&d.cues.length>0)for(var n=function(r,s,l){var u=[],c=function(S,P){if(P<S[0].startTime)return 0;var I=S.length-1;if(P>S[I].endTime)return-1;for(var q=0,se=I;q<=se;){var Ee=Math.floor((se+q)/2);if(P<S[Ee].startTime)se=Ee-1;else{if(!(P>S[Ee].startTime&&q<I))return Ee;q=Ee+1}}return S[q].startTime-P<P-S[se].startTime?q:se}(r,s);if(c>-1)for(var v=c,m=r.length;v<m;v++){var _=r[v];if(_.startTime>=s&&_.endTime<=l)u.push(_);else if(_.startTime>l)return u}return u}(d.cues,o,e),a=0;a<n.length;a++)t&&!t(n[a])||d.removeCue(n[a]);i==="disabled"&&(d.mode=i)}var Lt=N(181),St=N(856);function At(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var pt=function(){var d=At();try{new d(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function ut(d,o){return d.getTime()/1e3-o}let Rt=function(){function d(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var o=d.prototype;return o.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},o._registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},o._unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},o.onMediaAttached=function(e,t){this.media=t.media},o.onMediaDetaching=function(){this.id3Track&&(ht(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},o.onManifestLoading=function(){this.dateRangeCuesAppended={}},o.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},o.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var i=e[t];if(i.kind==="metadata"&&i.label==="id3")return rt(i,this.media),i}return this.media.addTextTrack("metadata","id3")}},o.onFragParsingMetadata=function(e,t){if(this.media){var i=this.hls.config,n=i.enableEmsgMetadataCues,a=i.enableID3MetadataCues;if(n||a){var r=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var s=At(),l=0;l<r.length;l++){var u=r[l].type;if((u!==St.MetadataSchema.emsg||n)&&a){var c=Lt.getID3Frames(r[l].data);if(c){var v=r[l].pts,m=v+r[l].duration;m>pt&&(m=pt),m-v<=0&&(m=v+.25);for(var _=0;_<c.length;_++){var S=c[_];if(!Lt.isTimeStampFrame(S)){this.updateId3CueEnds(v);var P=new s(v,m,"");P.value=S,u&&(P.type=u),this.id3Track.addCue(P)}}}}}}}},o.updateId3CueEnds=function(e){var t,i=(t=this.id3Track)===null||t===void 0?void 0:t.cues;if(i)for(var n=i.length;n--;){var a=i[n];a.startTime<e&&a.endTime===pt&&(a.endTime=e)}},o.onBufferFlushing=function(e,t){var i=t.startOffset,n=t.endOffset,a=t.type,r=this.id3Track,s=this.hls;if(s){var l=s.config,u=l.enableEmsgMetadataCues,c=l.enableID3MetadataCues;r&&(u||c)&&It(r,i,n,a==="audio"?function(v){return v.type===St.MetadataSchema.audioId3&&c}:a==="video"?function(v){return v.type===St.MetadataSchema.emsg&&u}:function(v){return v.type===St.MetadataSchema.audioId3&&c||v.type===St.MetadataSchema.emsg&&u})}},o.onLevelUpdated=function(e,t){var i=this,n=t.details;if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,r=this.id3Track,s=n.dateRanges,l=Object.keys(s);if(r)for(var u=Object.keys(a).filter(function(q){return!l.includes(q)}),c=function(q){var se=u[q];Object.keys(a[se].cues).forEach(function(Ee){r.removeCue(a[se].cues[Ee])}),delete a[se]},v=u.length;v--;)c(v);var m=n.fragments[n.fragments.length-1];if(l.length!==0&&(0,R.isFiniteNumber)(m==null?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var _=m.programDateTime/1e3-m.start,S=At(),P=function(q){var se=l[q],Ee=s[se],he=a[se],Ae=(he==null?void 0:he.cues)||{},He=(he==null?void 0:he.durationKnown)||!1,ze=ut(Ee.startDate,_),be=pt,Ge=Ee.endDate;if(Ge)be=ut(Ge,_),He=!0;else if(Ee.endOnNext&&!He){var Me=l.reduce(function(zt,Kt){var er=s[Kt];return er.class===Ee.class&&er.id!==Kt&&er.startDate>Ee.startDate&&zt.push(er),zt},[]).sort(function(zt,Kt){return zt.startDate.getTime()-Kt.startDate.getTime()})[0];Me&&(be=ut(Me.startDate,_),He=!0)}for(var ct,Ot=Object.keys(Ee.attr),ft=0;ft<Ot.length;ft++){var Tt=Ot[ft];if(Tt!==j.ID&&Tt!==j.CLASS&&Tt!==j.START_DATE&&Tt!==j.DURATION&&Tt!==j.END_DATE&&Tt!==j.END_ON_NEXT){var Dt=Ae[Tt];if(Dt)He&&!he.durationKnown&&(Dt.endTime=be);else{var Zt=Ee.attr[Tt];Dt=new S(ze,be,""),Tt!==j.SCTE35_OUT&&Tt!==j.SCTE35_IN||(ct=Zt,Zt=Uint8Array.from(ct.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),Dt.value={key:Tt,data:Zt},Dt.type=St.MetadataSchema.dateRange,i.id3Track.addCue(Dt),Ae[Tt]=Dt}}}a[se]={cues:Ae,dateRange:Ee,durationKnown:He}},I=0;I<l.length;I++)P(I)}}},d}();function Ct(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var Ht=function(){function d(i){var n=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return n.timeupdate()},this.hls=i,this.config=i.config,this.registerListeners()}var o,e,t=d.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},t.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(p.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(p.Events.ERROR,this.onError)},t.onMediaAttached=function(i,n){this.media=n.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},t.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},t.onLevelUpdated=function(i,n){var a=n.details;this.levelDetails=a,a.advanced&&this.timeupdate(),!a.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},t.onError=function(i,n){n.details===w.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,k.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},t.timeupdate=function(){var i=this.media,n=this.levelDetails;if(i&&n){this.currentTime=i.currentTime;var a=this.computeLatency();if(a!==null){this._latency=a;var r=this.config,s=r.lowLatencyMode,l=r.maxLiveSyncPlaybackRate;if(s&&l!==1){var u=this.targetLatency;if(u!==null){var c=a-u,v=c<Math.min(this.maxLatency,u+n.targetduration);if(n.live&&v&&c>.05&&this.forwardBufferLength>1){var m=Math.min(2,Math.max(1,l)),_=Math.round(2/(1+Math.exp(-.75*c-this.edgeStalled))*20)/20;i.playbackRate=Math.min(m,Math.max(1,_))}else i.playbackRate!==1&&i.playbackRate!==0&&(i.playbackRate=1)}}}}},t.estimateLiveEdge=function(){var i=this.levelDetails;return i===null?null:i.edge+i.age},t.computeLatency=function(){var i=this.estimateLiveEdge();return i===null?null:i-this.currentTime},o=d,(e=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var i=this.config,n=this.levelDetails;return i.liveMaxLatencyDuration!==void 0?i.liveMaxLatencyDuration:n?i.liveMaxLatencyDurationCount*n.targetduration:0}},{key:"targetLatency",get:function(){var i=this.levelDetails;if(i===null)return null;var n=i.holdBack,a=i.partHoldBack,r=i.targetduration,s=this.config,l=s.liveSyncDuration,u=s.liveSyncDurationCount,c=s.lowLatencyMode,v=this.hls.userConfig,m=c&&a||n;(v.liveSyncDuration||v.liveSyncDurationCount||m===0)&&(m=l!==void 0?l:u*r);var _=r;return m+Math.min(1*this.stallCount,_)}},{key:"liveSyncPosition",get:function(){var i=this.estimateLiveEdge(),n=this.targetLatency,a=this.levelDetails;if(i===null||n===null||a===null)return null;var r=a.edge,s=i-n-this.edgeStalled,l=r-a.totalduration,u=r-(this.config.lowLatencyMode&&a.partTarget||a.targetduration);return Math.min(Math.max(l,s),u)}},{key:"drift",get:function(){var i=this.levelDetails;return i===null?1:i.drift}},{key:"edgeStalled",get:function(){var i=this.levelDetails;if(i===null)return 0;var n=3*(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.max(i.age-n,0)}},{key:"forwardBufferLength",get:function(){var i=this.media,n=this.levelDetails;if(!i||!n)return 0;var a=i.buffered.length;return(a?i.buffered.end(a-1):n.edge)-this.currentTime}}])&&Ct(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function Qt(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var Ut,ur=["NONE","TYPE-0","TYPE-1","TYPE-2",null];(function(d){d.No="",d.Yes="YES",d.v2="v2"})(Ut||(Ut={}));var ee=function(){function d(o,e,t){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=o,this.part=e,this.skip=t}return d.prototype.addDirectives=function(o){var e=new self.URL(o);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},d}(),F=function(){function d(t){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(function(i){return i}).join(",").replace(/\.[^.,]+/g,"")}var o,e;return o=d,(e=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var i=t%this.url.length;this._urlId!==i&&(this.details=void 0,this._urlId=i)}}])&&Qt(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();function T(){return T=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},T.apply(this,arguments)}function C(d,o,e){switch(o){case"audio":d.audioGroupIds||(d.audioGroupIds=[]),d.audioGroupIds.push(e);break;case"text":d.textGroupIds||(d.textGroupIds=[]),d.textGroupIds.push(e)}}function L(d){var o={};d.forEach(function(e){var t=e.groupId||"";e.id=o[t]=o[t]||0,o[t]++})}function B(d,o){var e=o.startPTS;if((0,R.isFiniteNumber)(e)){var t,i=0;o.sn>d.sn?(i=e-d.start,t=d):(i=d.start-e,t=o),t.duration!==i&&(t.duration=i)}else o.sn>d.sn?d.cc===o.cc&&d.minEndPTS?o.start=d.start+(d.minEndPTS-d.start):o.start=d.start+d.duration:o.start=Math.max(d.start-o.duration,0)}function Y(d,o,e,t,i,n){t-e<=0&&(k.logger.warn("Fragment should have a positive duration",o),t=e+o.duration,n=i+o.duration);var a=e,r=t,s=o.startPTS,l=o.endPTS;if((0,R.isFiniteNumber)(s)){var u=Math.abs(s-e);(0,R.isFiniteNumber)(o.deltaPTS)?o.deltaPTS=Math.max(u,o.deltaPTS):o.deltaPTS=u,a=Math.max(e,s),e=Math.min(e,s),i=Math.min(i,o.startDTS),r=Math.min(t,l),t=Math.max(t,l),n=Math.max(n,o.endDTS)}o.duration=t-e;var c=e-o.start;o.start=o.startPTS=e,o.maxStartPTS=a,o.startDTS=i,o.endPTS=t,o.minEndPTS=r,o.endDTS=n;var v,m=o.sn;if(!d||m<d.startSN||m>d.endSN)return 0;var _=m-d.startSN,S=d.fragments;for(S[_]=o,v=_;v>0;v--)B(S[v],S[v-1]);for(v=_;v<S.length-1;v++)B(S[v],S[v+1]);return d.fragmentHint&&B(S[S.length-1],d.fragmentHint),d.PTSKnown=d.alignedSliding=!0,c}function z(d,o){var e=o.startSN+o.skippedSegments-d.startSN,t=d.fragments;e<0||e>=t.length||ge(o,t[e].start)}function ge(d,o){if(o){for(var e=d.fragments,t=d.skippedSegments;t<e.length;t++)e[t].start+=o;d.fragmentHint&&(d.fragmentHint.start+=o)}}var we=function(){function d(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=k.logger.log.bind(k.logger,t+":"),this.warn=k.logger.warn.bind(k.logger,t+":"),this.hls=e}var o=d.prototype;return o.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},o.onError=function(e,t){!t.fatal||t.type!==w.ErrorTypes.NETWORK_ERROR&&t.type!==w.ErrorTypes.KEY_SYSTEM_ERROR||this.stopLoad()},o.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},o.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.requestScheduled=-1,this.loadPlaylist()},o.stopLoad=function(){this.canLoad=!1,this.clearTimer()},o.switchParams=function(e,t){var i=t==null?void 0:t.renditionReports;if(i)for(var n=0;n<i.length;n++){var a=i[n],r=void 0;try{r=new self.URL(a.URI,t.url).href}catch(c){k.logger.warn("Could not construct new URL for Rendition Report: "+c),r=a.URI||""}if(r===e.slice(-r.length)){var s=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn),l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){var u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}return new ee(s,l>=0?l:void 0,Ut.No)}}},o.loadPlaylist=function(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())},o.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},o.playlistLoaded=function(e,t,i){var n=this,a=t.details,r=t.stats,s=self.performance.now(),l=r.loading.first?Math.max(0,s-r.loading.first):0;if(a.advancedDateTime=Date.now()-l,a.live||i!=null&&i.live){if(a.reloaded(i),i&&this.log("live playlist "+e+" "+(a.advanced?"REFRESHED "+a.lastPartSn+"-"+a.lastPartIndex:"MISSED")),i&&a.fragments.length>0&&function(Ge,Me){for(var ct=null,Ot=Ge.fragments,ft=Ot.length-1;ft>=0;ft--){var Tt=Ot[ft].initSegment;if(Tt){ct=Tt;break}}Ge.fragmentHint&&delete Ge.fragmentHint.endPTS;var Dt,Zt,zt,Kt,er,Er=0;if(function(st,vt,yi){for(var Ur=vt.skippedSegments,Or=Math.max(st.startSN,vt.startSN)-vt.startSN,Ei=(st.fragmentHint?1:0)+(Ur?vt.endSN:Math.min(st.endSN,vt.endSN))-vt.startSN,Dr=vt.startSN-st.startSN,Br=vt.fragmentHint?vt.fragments.concat(vt.fragmentHint):vt.fragments,Xr=st.fragmentHint?st.fragments.concat(st.fragmentHint):st.fragments,Ar=Or;Ar<=Ei;Ar++){var zr=Xr[Dr+Ar],dn=Br[Ar];Ur&&!dn&&Ar<Ur&&(dn=vt.fragments[Ar]=zr),zr&&dn&&yi(zr,dn)}}(Ge,Me,function(st,vt){st.relurl&&(Er=st.cc-vt.cc),(0,R.isFiniteNumber)(st.startPTS)&&(0,R.isFiniteNumber)(st.endPTS)&&(vt.start=vt.startPTS=st.startPTS,vt.startDTS=st.startDTS,vt.appendedPTS=st.appendedPTS,vt.maxStartPTS=st.maxStartPTS,vt.endPTS=st.endPTS,vt.endDTS=st.endDTS,vt.minEndPTS=st.minEndPTS,vt.duration=st.endPTS-st.startPTS,vt.duration&&(Dt=vt),Me.PTSKnown=Me.alignedSliding=!0),vt.elementaryStreams=st.elementaryStreams,vt.loader=st.loader,vt.stats=st.stats,vt.urlId=st.urlId,st.initSegment&&(vt.initSegment=st.initSegment,ct=st.initSegment)}),ct&&(Me.fragmentHint?Me.fragments.concat(Me.fragmentHint):Me.fragments).forEach(function(st){var vt;st.initSegment&&st.initSegment.relurl!==((vt=ct)===null||vt===void 0?void 0:vt.relurl)||(st.initSegment=ct)}),Me.skippedSegments)if(Me.deltaUpdateFailed=Me.fragments.some(function(st){return!st}),Me.deltaUpdateFailed){k.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var Gn=Me.skippedSegments;Gn--;)Me.fragments.shift();Me.startSN=Me.fragments[0].sn,Me.startCC=Me.fragments[0].cc}else Me.canSkipDateRanges&&(Me.dateRanges=(Zt=Ge.dateRanges,zt=Me.dateRanges,Kt=Me.recentlyRemovedDateranges,er=T({},Zt),Kt&&Kt.forEach(function(st){delete er[st]}),Object.keys(zt).forEach(function(st){var vt=new ve(zt[st].attr,er[st]);vt.isValid?er[st]=vt:k.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(zt[st].attr)+'"')}),er));var Cr=Me.fragments;if(Er){k.logger.warn("discontinuity sliding from playlist, take drift into account");for(var Ni=0;Ni<Cr.length;Ni++)Cr[Ni].cc+=Er}Me.skippedSegments&&(Me.startCC=Me.fragments[0].cc),function(st,vt,yi){if(st&&vt)for(var Ur=0,Or=0,Ei=st.length;Or<=Ei;Or++){var Dr=st[Or],Br=vt[Or+Ur];Dr&&Br&&Dr.index===Br.index&&Dr.fragment.sn===Br.fragment.sn?(Xr=Dr,(Ar=Br).elementaryStreams=Xr.elementaryStreams,Ar.stats=Xr.stats):Ur--}var Xr,Ar}(Ge.partList,Me.partList),Dt?Y(Me,Dt,Dt.startPTS,Dt.endPTS,Dt.startDTS,Dt.endDTS):z(Ge,Me),Cr.length&&(Me.totalduration=Me.edge-Cr[0].start),Me.driftStartTime=Ge.driftStartTime,Me.driftStart=Ge.driftStart;var Ui=Me.advancedDateTime;if(Me.advanced&&Ui){var Bi=Me.edge;Me.driftStart||(Me.driftStartTime=Ui,Me.driftStart=Bi),Me.driftEndTime=Ui,Me.driftEnd=Bi}else Me.driftEndTime=Ge.driftEndTime,Me.driftEnd=Ge.driftEnd,Me.advancedDateTime=Ge.advancedDateTime}(i,a),!this.canLoad||!a.live)return;var u,c=void 0,v=void 0;if(a.canBlockReload&&a.endSN&&a.advanced){var m=this.hls.config.lowLatencyMode,_=a.lastPartSn,S=a.endSN,P=a.lastPartIndex,I=_===S;P!==-1?(c=I?S+1:_,v=I?m?0:P:P+1):c=S+1;var q=a.age,se=q+a.ageHeader,Ee=Math.min(se-a.partTarget,1.5*a.targetduration);if(Ee>0){if(i&&Ee>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+Ee+" with playlist age: "+a.age),Ee=0;else{var he=Math.floor(Ee/a.targetduration);c+=he,v!==void 0&&(v+=Math.round(Ee%a.targetduration/a.partTarget)),this.log("CDN Tune-in age: "+a.ageHeader+"s last advanced "+q.toFixed(2)+"s goal: "+Ee+" skip sn "+he+" to part "+v)}a.tuneInGoal=Ee}if(u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,v),m||!I)return void this.loadPlaylist(u)}else u=this.getDeliveryDirectives(a,t.deliveryDirectives,c,v);var Ae=this.hls.mainForwardBufferInfo,He=Ae?Ae.end-Ae.len:0,ze=function(Ge,Me){Me===void 0&&(Me=1/0);var ct=1e3*Ge.targetduration;if(Ge.updated){var Ot=Ge.fragments;if(Ot.length&&4*ct>Me){var ft=1e3*Ot[Ot.length-1].duration;ft<ct&&(ct=ft)}}else ct/=2;return Math.round(ct)}(a,1e3*(a.edge-He));a.updated?s>this.requestScheduled+ze&&(this.requestScheduled=r.loading.start):this.requestScheduled=-1,c!==void 0&&a.canBlockReload?this.requestScheduled=r.loading.first+ze-(1e3*a.partTarget||1e3):this.requestScheduled=(this.requestScheduled===-1?s:this.requestScheduled)+ze;var be=this.requestScheduled-s;be=Math.max(0,be),this.log("reload live playlist "+e+" in "+Math.round(be)+" ms"),this.timer=self.setTimeout(function(){return n.loadPlaylist(u)},be)}else this.clearTimer()},o.getDeliveryDirectives=function(e,t,i,n){var a=function(r,s){var l=r.canSkipUntil,u=r.canSkipDateRanges,c=r.endSN;return l&&(s!==void 0?s-c:0)<l?u?Ut.v2:Ut.Yes:Ut.No}(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=Ut.No),new ee(i,n,a)},o.retryLoadingOrFail=function(e){var t,i=this,n=this.hls.config,a=this.retryCount<n.levelLoadingMaxRetry;if(a)if(this.requestScheduled=-1,this.retryCount++,e.details.indexOf("LoadTimeOut")>-1&&(t=e.context)!==null&&t!==void 0&&t.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+e.details+'"'),this.loadPlaylist();else{var r=Math.min(Math.pow(2,this.retryCount)*n.levelLoadingRetryDelay,n.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return i.loadPlaylist()},r),this.warn("retry playlist loading #"+this.retryCount+" in "+r+' ms after "'+e.details+'"')}else this.warn('cannot recover from error "'+e.details+'"'),this.clearTimer(),e.fatal=!0;return a},d}();function Le(){return Le=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},Le.apply(this,arguments)}function Fe(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Ve(d,o){return Ve=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ve(d,o)}var Ue,Qe=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),ot=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[level-controller]")||this)._levels=[],s._firstLevel=-1,s._startLevel=void 0,s.currentLevelIndex=-1,s.manualLevelIndex=-1,s.onParsedComplete=void 0,s._registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ve(o,e);var i,n,a=t.prototype;return a._registerListeners=function(){var r=this.hls;r.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),r.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),r.on(p.Events.ERROR,this.onError,this)},a._unregisterListeners=function(){var r=this.hls;r.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),r.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),r.off(p.Events.ERROR,this.onError,this)},a.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,d.prototype.destroy.call(this)},a.startLoad=function(){this._levels.forEach(function(r){r.loadError=0}),d.prototype.startLoad.call(this)},a.onManifestLoaded=function(r,s){var l,u,c=[],v=[],m=[],_={},S=!1,P=!1,I=!1;if(s.levels.forEach(function(he){var Ae=he.attrs;S=S||!(!he.width||!he.height),P=P||!!he.videoCodec,I=I||!!he.audioCodec,Qe&&he.audioCodec&&he.audioCodec.indexOf("mp4a.40.34")!==-1&&(he.audioCodec=void 0);var He=he.bitrate+"-"+he.attrs.RESOLUTION+"-"+he.attrs.CODECS;(u=_[He])?u.url.push(he.url):(u=new F(he),_[He]=u,c.push(u)),Ae&&(Ae.AUDIO&&C(u,"audio",Ae.AUDIO),Ae.SUBTITLES&&C(u,"text",Ae.SUBTITLES))}),(S||P)&&I&&(c=c.filter(function(he){var Ae=he.videoCodec,He=he.width,ze=he.height;return!!Ae||!(!He||!ze)})),c=c.filter(function(he){var Ae=he.audioCodec,He=he.videoCodec;return(!Ae||Oe(Ae,"audio"))&&(!He||Oe(He,"video"))}),s.audioTracks&&L(v=s.audioTracks.filter(function(he){return!he.audioCodec||Oe(he.audioCodec,"audio")})),s.subtitles&&L(m=s.subtitles),c.length>0){l=c[0].bitrate,c.sort(function(he,Ae){return he.attrs["HDCP-LEVEL"]!==Ae.attrs["HDCP-LEVEL"]?(he.attrs["HDCP-LEVEL"]||"")>(Ae.attrs["HDCP-LEVEL"]||"")?1:-1:he.bitrate!==Ae.bitrate?he.bitrate-Ae.bitrate:he.attrs.SCORE!==Ae.attrs.SCORE?he.attrs.decimalFloatingPoint("SCORE")-Ae.attrs.decimalFloatingPoint("SCORE"):S&&he.height!==Ae.height?he.height-Ae.height:0}),this._levels=c;for(var q=0;q<c.length;q++)if(c[q].bitrate===l){this._firstLevel=q,this.log("manifest loaded, "+c.length+" level(s) found, first bitrate: "+l);break}var se=I&&!P,Ee={levels:c,audioTracks:v,subtitleTracks:m,sessionData:s.sessionData,sessionKeys:s.sessionKeys,firstLevel:this._firstLevel,stats:s.stats,audio:I,video:P,altAudio:!se&&v.some(function(he){return!!he.url})};this.hls.trigger(p.Events.MANIFEST_PARSED,Ee),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:s.url,reason:"no level with compatible codecs found in manifest"})},a.onError=function(r,s){var l,u;if(d.prototype.onError.call(this,r,s),!s.fatal){var c=s.context,v=this._levels[this.currentLevelIndex];if(c&&(c.type===pe.PlaylistContextType.AUDIO_TRACK&&v.audioGroupIds&&c.groupId===v.audioGroupIds[v.urlId]||c.type===pe.PlaylistContextType.SUBTITLE_TRACK&&v.textGroupIds&&c.groupId===v.textGroupIds[v.urlId]))this.redundantFailover(this.currentLevelIndex);else{var m,_=!1,S=!0;switch(s.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:if(s.frag){var P=s.frag.type===pe.PlaylistLevelType.MAIN?s.frag.level:this.currentLevelIndex,I=this._levels[P];I?(I.fragmentError++,I.fragmentError>this.hls.config.fragLoadingMaxRetry&&(m=P)):m=P}break;case w.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var q=v.attrs["HDCP-LEVEL"];q&&(this.hls.maxHdcpLevel=ur[ur.indexOf(q)-1],this.warn('Restricting playback to HDCP-LEVEL of "'+this.hls.maxHdcpLevel+'" or lower'));case w.ErrorDetails.FRAG_PARSING_ERROR:case w.ErrorDetails.KEY_SYSTEM_NO_SESSION:m=((l=s.frag)===null||l===void 0?void 0:l.type)===pe.PlaylistLevelType.MAIN?s.frag.level:this.currentLevelIndex,s.levelRetry=!1;break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(S=!1),m=c.level),_=!0;break;case w.ErrorDetails.REMUX_ALLOC_ERROR:m=(u=s.level)!=null?u:this.currentLevelIndex,_=!0}m!==void 0&&this.recoverLevel(s,m,_,S)}}},a.recoverLevel=function(r,s,l,u){var c=r.details,v=this._levels[s];if(v.loadError++,l){if(!this.retryLoadingOrFail(r))return void(this.currentLevelIndex=-1);r.levelRetry=!0}if(u){var m=v.url.length;if(m>1&&v.loadError<m)r.levelRetry=!0,this.redundantFailover(s);else if(this.manualLevelIndex===-1){for(var _=-1,S=this._levels,P=S.length;P--;){var I=(P+this.currentLevelIndex)%S.length;if(I!==this.currentLevelIndex&&S[I].loadError===0){_=I;break}}_>-1&&this.currentLevelIndex!==_?(this.warn(c+": switch to "+_),r.levelRetry=!0,this.hls.nextAutoLevel=_):r.levelRetry===!1&&(r.fatal=!0)}}},a.redundantFailover=function(r){var s=this._levels[r],l=s.url.length;if(l>1){var u=(s.urlId+1)%l;this.warn("Switching to redundant URL-id "+u),this._levels.forEach(function(c){c.urlId=u}),this.level=r}},a.onFragLoaded=function(r,s){var l=s.frag;if(l!==void 0&&l.type===pe.PlaylistLevelType.MAIN){var u=this._levels[l.level];u!==void 0&&(u.fragmentError=0,u.loadError=0)}},a.onLevelLoaded=function(r,s){var l,u,c=s.level,v=s.details,m=this._levels[c];if(!m)return this.warn("Invalid level index "+c),void((u=s.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(v.deltaUpdateFailed=!0));c===this.currentLevelIndex?(m.fragmentError===0&&(m.loadError=0,this.retryCount=0),this.playlistLoaded(c,s,m.details)):(l=s.deliveryDirectives)!==null&&l!==void 0&&l.skip&&(v.deltaUpdateFailed=!0)},a.onAudioTrackSwitched=function(r,s){var l=this.hls.levels[this.currentLevelIndex];if(l&&l.audioGroupIds){for(var u=-1,c=this.hls.audioTracks[s.id].groupId,v=0;v<l.audioGroupIds.length;v++)if(l.audioGroupIds[v]===c){u=v;break}u!==l.urlId&&(l.urlId=u,this.startLoad())}},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.currentLevelIndex,l=this._levels[s];if(this.canLoad&&l&&l.url.length>0){var u=l.urlId,c=l.url[u];if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("Attempt loading level index "+s+(r?" at sn "+r.msn+" part "+r.part:"")+" with URL-id "+u+" "+c),this.clearTimer(),this.hls.trigger(p.Events.LEVEL_LOADING,{url:c,level:s,id:u,deliveryDirectives:r||null})}},a.removeLevel=function(r,s){var l=function(c,v){return v!==s},u=this._levels.filter(function(c,v){return v!==r||c.url.length>1&&s!==void 0&&(c.url=c.url.filter(l),c.audioGroupIds&&(c.audioGroupIds=c.audioGroupIds.filter(l)),c.textGroupIds&&(c.textGroupIds=c.textGroupIds.filter(l)),c.urlId=0,!0)}).map(function(c,v){var m=c.details;return m!=null&&m.fragments&&m.fragments.forEach(function(_){_.level=v}),c});this._levels=u,this.hls.trigger(p.Events.LEVELS_UPDATED,{levels:u})},i=t,(n=[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(r){var s,l=this._levels;if(l.length!==0&&(this.currentLevelIndex!==r||(s=l[r])===null||s===void 0||!s.details)){if(r<0||r>=l.length){var u=r<0;if(this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.LEVEL_SWITCH_ERROR,level:r,fatal:u,reason:"invalid level idx"}),u)return;r=Math.min(r,l.length-1)}this.clearTimer();var c=this.currentLevelIndex,v=l[c],m=l[r];this.log("switching to level "+r+" from "+c),this.currentLevelIndex=r;var _=Le({},m,{level:r,maxBitrate:m.maxBitrate,uri:m.uri,urlId:m.urlId});delete _._urlId,this.hls.trigger(p.Events.LEVEL_SWITCHING,_);var S=m.details;if(!S||S.live){var P=this.switchParams(m.uri,v==null?void 0:v.details);this.loadPlaylist(P)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(r){this.manualLevelIndex=r,this._startLevel===void 0&&(this._startLevel=r),r!==-1&&(this.level=r)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(r){this._firstLevel=r}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var r=this.hls.config.startLevel;return r!==void 0?r:this._firstLevel}return this._startLevel},set:function(r){this._startLevel=r}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(r){this.level=r,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=r)}}])&&Fe(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(we);(function(d){d.NOT_LOADED="NOT_LOADED",d.APPENDING="APPENDING",d.PARTIAL="PARTIAL",d.OK="OK"})(Ue||(Ue={}));var bt=function(){function d(e){this.activeFragment=null,this.activeParts=null,this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}var o=d.prototype;return o._registerListeners=function(){var e=this.hls;e.on(p.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.Events.FRAG_LOADED,this.onFragLoaded,this)},o._unregisterListeners=function(){var e=this.hls;e.off(p.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.Events.FRAG_LOADED,this.onFragLoaded,this)},o.destroy=function(){this._unregisterListeners(),this.fragments=this.endListFragments=this.timeRanges=this.activeFragment=this.activeParts=null},o.getAppendedFrag=function(e,t){if(t===pe.PlaylistLevelType.MAIN){var i=this.activeFragment,n=this.activeParts;if(!i)return null;if(n)for(var a=n.length;a--;){var r=n[a],s=r?r.end:i.appendedPTS;if(r.start<=e&&s!==void 0&&e<=s)return a>9&&(this.activeParts=n.slice(a-9)),r}else if(i.start<=e&&i.appendedPTS!==void 0&&e<=i.appendedPTS)return i}return this.getBufferedFrag(e,t)},o.getBufferedFrag=function(e,t){for(var i=this.fragments,n=Object.keys(i),a=n.length;a--;){var r=i[n[a]];if((r==null?void 0:r.body.type)===t&&r.buffered){var s=r.body;if(s.start<=e&&e<=s.end)return s}}return null},o.detectEvictedFragments=function(e,t,i){var n=this;this.timeRanges&&(this.timeRanges[e]=t),Object.keys(this.fragments).forEach(function(a){var r=n.fragments[a];if(r)if(r.buffered||r.loaded){var s=r.range[e];s&&s.time.some(function(l){var u=!n.isTimeBuffered(l.startPTS,l.endPTS,t);return u&&n.removeFragment(r.body),u})}else r.body.type===i&&n.removeFragment(r.body)})},o.detectPartialFragments=function(e){var t=this,i=this.timeRanges,n=e.frag,a=e.part;if(i&&n.sn!=="initSegment"){var r=kt(n),s=this.fragments[r];s&&(Object.keys(i).forEach(function(l){var u=n.elementaryStreams[l];if(u){var c=i[l],v=a!==null||u.partial===!0;s.range[l]=t.getBufferedTimes(n,a,v,c)}}),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,s.body.endList&&(this.endListFragments[s.body.type]=s)):this.removeFragment(s.body))}},o.fragBuffered=function(e){var t=kt(e),i=this.fragments[t];i&&(i.loaded=null,i.buffered=!0)},o.getBufferedTimes=function(e,t,i,n){for(var a={time:[],partial:i},r=t?t.start:e.start,s=t?t.end:e.end,l=e.minEndPTS||s,u=e.maxStartPTS||r,c=0;c<n.length;c++){var v=n.start(c)-this.bufferPadding,m=n.end(c)+this.bufferPadding;if(u>=v&&l<=m){a.time.push({startPTS:Math.max(r,n.start(c)),endPTS:Math.min(s,n.end(c))});break}if(r<m&&s>v)a.partial=!0,a.time.push({startPTS:Math.max(r,n.start(c)),endPTS:Math.min(s,n.end(c))});else if(s<=v)break}return a},o.getPartialFragment=function(e){var t,i,n,a=null,r=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach(function(u){var c=l[u];c&&We(c)&&(i=c.body.start-s,n=c.body.end+s,e>=i&&e<=n&&(t=Math.min(e-i,n-e),r<=t&&(a=c.body,r=t)))}),a},o.isEndListAppended=function(e){var t=this.endListFragments[e];return t!==void 0&&(t.buffered||We(t))},o.getState=function(e){var t=kt(e),i=this.fragments[t];return i?i.buffered?We(i)?Ue.PARTIAL:Ue.OK:Ue.APPENDING:Ue.NOT_LOADED},o.isTimeBuffered=function(e,t,i){for(var n,a,r=0;r<i.length;r++){if(n=i.start(r)-this.bufferPadding,a=i.end(r)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1},o.onFragLoaded=function(e,t){var i=t.frag,n=t.part;if(i.sn!=="initSegment"&&!i.bitrateTest&&!n){var a=kt(i);this.fragments[a]={body:i,loaded:t,buffered:!1,range:Object.create(null)}}},o.onBufferAppended=function(e,t){var i=this,n=t.frag,a=t.part,r=t.timeRanges;if(n.type===pe.PlaylistLevelType.MAIN)if(this.activeFragment!==n&&(this.activeFragment=n,n.appendedPTS=void 0),a){var s=this.activeParts;s||(this.activeParts=s=[]),s.push(a)}else this.activeParts=null;this.timeRanges=r,Object.keys(r).forEach(function(l){var u=r[l];if(i.detectEvictedFragments(l,u),!a&&n.type===pe.PlaylistLevelType.MAIN){var c=n.elementaryStreams[l];if(!c)return;for(var v=0;v<u.length;v++){var m=u.end(v);m<=c.endPTS&&m>c.startPTS?n.appendedPTS=Math.max(m,n.appendedPTS||0):n.appendedPTS=c.endPTS}}})},o.onFragBuffered=function(e,t){this.detectPartialFragments(t)},o.hasFragment=function(e){var t=kt(e);return!!this.fragments[t]},o.removeFragmentsInRange=function(e,t,i){var n=this;Object.keys(this.fragments).forEach(function(a){var r=n.fragments[a];if(r&&r.buffered){var s=r.body;s.type===i&&s.start<t&&s.end>e&&n.removeFragment(s)}})},o.removeFragment=function(e){var t=kt(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),e.appendedPTS=void 0,delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},o.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activeFragment=null,this.activeParts=null},d}();function We(d){var o,e;return d.buffered&&(((o=d.range.video)===null||o===void 0?void 0:o.partial)||((e=d.range.audio)===null||e===void 0?void 0:e.partial))}function kt(d){return d.type+"_"+d.level+"_"+d.urlId+"_"+d.sn}function Jt(d){var o=typeof Map=="function"?new Map:void 0;return Jt=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return Ft(e,arguments,Ze(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Bt(i,e)},Jt(d)}function Ft(d,o,e){return Ft=Pt()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Bt(r,n.prototype),r},Ft.apply(null,arguments)}function Pt(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Bt(d,o){return Bt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Bt(d,o)}function Ze(d){return Ze=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},Ze(d)}var ir=Math.pow(2,17),br=function(){function d(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var o=d.prototype;return o.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},o.abort=function(){this.loader&&this.loader.abort()},o.load=function(e,t){var i=this,n=e.url;if(!n)return Promise.reject(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(n?"part list":"url")));this.abort();var a=this.config,r=a.fLoader,s=a.loader;return new Promise(function(l,u){i.loader&&i.loader.destroy();var c=i.loader=e.loader=r?new r(a):new s(a),v=Nt(e),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:e.sn==="initSegment"?1/0:ir};e.stats=c.stats,c.load(v,m,{onSuccess:function(_,S,P,I){i.resetLoader(e,c);var q=_.data;P.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(q.slice(0,16)),q=q.slice(16)),l({frag:e,part:null,payload:q,networkDetails:I})},onError:function(_,S,P){i.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:_,networkDetails:P}))},onAbort:function(_,S,P){i.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:P}))},onTimeout:function(_,S,P){i.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:P}))},onProgress:function(_,S,P,I){t&&t({frag:e,part:null,payload:P,networkDetails:I})}})})},o.loadPart=function(e,t,i){var n=this;this.abort();var a=this.config,r=a.fLoader,s=a.loader;return new Promise(function(l,u){n.loader&&n.loader.destroy();var c=n.loader=e.loader=r?new r(a):new s(a),v=Nt(e,t),m={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:ir};t.stats=c.stats,c.load(v,m,{onSuccess:function(_,S,P,I){n.resetLoader(e,c),n.updateStatsFromPart(e,t);var q={frag:e,part:t,payload:_.data,networkDetails:I};i(q),l(q)},onError:function(_,S,P){n.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:_,networkDetails:P}))},onAbort:function(_,S,P){e.stats.aborted=t.stats.aborted,n.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:P}))},onTimeout:function(_,S,P){n.resetLoader(e,c),u(new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:w.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:P}))}})})},o.updateStatsFromPart=function(e,t){var i=e.stats,n=t.stats,a=n.total;if(i.loaded+=n.loaded,a){var r=Math.round(e.duration/t.duration),s=Math.min(Math.round(i.loaded/a),r),l=(r-s)*Math.round(i.loaded/s);i.total=i.loaded+l}else i.total=Math.max(i.loaded,i.total);var u=i.loading,c=n.loading;u.start?u.first+=c.first-c.start:(u.start=c.start,u.first=c.first),u.end=c.end},o.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},d}();function Nt(d,o){o===void 0&&(o=null);var e=o||d,t={frag:d,part:o,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},i=e.byteRangeStartOffset,n=e.byteRangeEndOffset;if((0,R.isFiniteNumber)(i)&&(0,R.isFiniteNumber)(n)){var a,r=i,s=n;if(d.sn==="initSegment"&&((a=d.decryptdata)===null||a===void 0?void 0:a.method)==="AES-128"){var l=n-i;l%16&&(s=n+(16-l%16)),i!==0&&(t.resetIV=!0,r=i-16)}t.rangeStart=r,t.rangeEnd=s}return t}var Yt=function(d){var o,e;function t(i){for(var n,a=arguments.length,r=new Array(a>1?a-1:0),s=1;s<a;s++)r[s-1]=arguments[s];return(n=d.call.apply(d,[this].concat(r))||this).data=void 0,n.data=i,n}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Bt(o,e),t}(Jt(Error)),cr=function(){function d(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var o=d.prototype;return o.abort=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.abort()}},o.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},o.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},o.createKeyLoadError=function(e,t,i,n){return t===void 0&&(t=w.ErrorDetails.KEY_LOAD_ERROR),new Yt({type:w.ErrorTypes.NETWORK_ERROR,details:t,fatal:!1,frag:e,networkDetails:i})},o.loadClear=function(e,t){var i=this;if(this.emeController&&this.config.emeEnabled)for(var n=e.sn,a=e.cc,r=function(l){var u=t[l];if(a<=u.cc&&(n==="initSegment"||n<u.sn))return i.emeController.selectKeySystemFormat(u).then(function(c){u.setKeyFormat(c)}),"break"},s=0;s<t.length&&r(s)!=="break";s++);},o.load=function(e){var t=this;return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(function(i){return t.loadInternal(e,i)}):this.loadInternal(e)},o.loadInternal=function(e,t){var i,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var r=t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading";return Promise.reject(this.createKeyLoadError(e,w.ErrorDetails.KEY_LOAD_ERROR,null,r))}var s=a.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,w.ErrorDetails.KEY_LOAD_ERROR,null,'Invalid key URI: "'+s+'"'));var l,u=this.keyUriToKeyInfo[s];if((i=u)!==null&&i!==void 0&&i.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if((n=u)!==null&&n!==void 0&&n.keyLoadPromise)switch((l=u.mediaKeySessionContext)===null||l===void 0?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return u.keyLoadPromise}switch(u=this.keyUriToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return a.keyFormat==="identity"?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,w.ErrorDetails.KEY_LOAD_ERROR,null,'Key supplied with unsupported METHOD: "'+a.method+'"'))}},o.loadKeyEME=function(e,t){var i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n=this.emeController.loadKey(i);if(n)return(e.keyLoadPromise=n.then(function(a){return e.mediaKeySessionContext=a,i})).catch(function(a){throw e.keyLoadPromise=null,a})}return Promise.resolve(i)},o.loadKeyHTTP=function(e,t){var i=this,n=this.config,a=new n.loader(n);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise(function(r,s){var l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},u={timeout:n.fragLoadingTimeOut,maxRetry:0,retryDelay:n.fragLoadingRetryDelay,maxRetryDelay:n.fragLoadingMaxRetryTimeout,highWaterMark:0},c={onSuccess:function(v,m,_,S){var P=_.frag,I=_.keyInfo,q=_.url;if(!P.decryptdata||I!==i.keyUriToKeyInfo[q])return s(i.createKeyLoadError(P,w.ErrorDetails.KEY_LOAD_ERROR,S,"after key load, decryptdata unset or changed"));I.decryptdata.key=P.decryptdata.key=new Uint8Array(v.data),P.keyLoader=null,I.loader=null,r({frag:P,keyInfo:I})},onError:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,w.ErrorDetails.KEY_LOAD_ERROR,_))},onTimeout:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,w.ErrorDetails.KEY_LOAD_TIMEOUT,_))},onAbort:function(v,m,_){i.resetLoader(m),s(i.createKeyLoadError(t,w.ErrorDetails.INTERNAL_ABORTED,_))}};a.load(l,u,c)})},o.resetLoader=function(e){var t=e.frag,i=e.keyInfo,n=e.url,a=i.loader;t.keyLoader===a&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],a&&a.destroy()},d}(),Ir=function(){function d(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var o=d.prototype;return o.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},o.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},o.onHandlerDestroyed=function(){},o.hasInterval=function(){return!!this._tickInterval},o.hasNextTick=function(){return!!this._tickTimer},o.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},o.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},o.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},o.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},o.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},o.doTick=function(){},d}(),dr={length:0,start:function(){return 0},end:function(){return 0}},Mt=function(){function d(){}return d.isBuffered=function(o,e){try{if(o){for(var t=d.getBuffered(o),i=0;i<t.length;i++)if(e>=t.start(i)&&e<=t.end(i))return!0}}catch{}return!1},d.bufferInfo=function(o,e,t){try{if(o){var i,n=d.getBuffered(o),a=[];for(i=0;i<n.length;i++)a.push({start:n.start(i),end:n.end(i)});return this.bufferedInfo(a,e,t)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}},d.bufferedInfo=function(o,e,t){e=Math.max(0,e),o.sort(function(S,P){return S.start-P.start||P.end-S.end});var i=[];if(t)for(var n=0;n<o.length;n++){var a=i.length;if(a){var r=i[a-1].end;o[n].start-r<t?o[n].end>r&&(i[a-1].end=o[n].end):i.push(o[n])}else i.push(o[n])}else i=o;for(var s,l=0,u=e,c=e,v=0;v<i.length;v++){var m=i[v].start,_=i[v].end;if(e+t>=m&&e<_)u=m,l=(c=_)-e;else if(e+t<m){s=m;break}}return{len:l,start:u||0,end:c||0,nextStart:s}},d.getBuffered=function(o){try{return o.buffered}catch(e){return k.logger.log("failed to get media.buffered",e),dr}},d}(),ki=function(d,o,e,t,i,n){t===void 0&&(t=0),i===void 0&&(i=-1),n===void 0&&(n=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=d,this.sn=o,this.id=e,this.size=t,this.part=i,this.partial=n};function zi(d,o){for(var e=null,t=0,i=d.length;t<i;t++){var n=d[t];if(n&&n.cc===o){e=n;break}}return e}function _r(d,o){if(d){var e=d.start+o;d.start=d.startPTS=e,d.endPTS=e+d.duration}}function oi(d,o){for(var e=o.fragments,t=0,i=e.length;t<i;t++)_r(e[t],d);o.fragmentHint&&_r(o.fragmentHint,d),o.alignedSliding=!0}function Qi(d,o){if(d.hasProgramDateTime&&o.hasProgramDateTime){var e=d.fragments,t=o.fragments;if(e.length&&t.length){var i=t[Math.round(t.length/2)-1],n=zi(e,i.cc)||e[Math.round(e.length/2)-1],a=i.programDateTime,r=n.programDateTime;a!==null&&r!==null&&oi((r-a)/1e3-(n.start-i.start),d)}}}let Ji=function(d,o){for(var e=0,t=d.length-1,i=null,n=null;e<=t;){var a=o(n=d[i=(e+t)/2|0]);if(a>0)e=i+1;else{if(!(a<0))return n;t=i-1}}return null};function li(d,o,e,t){e===void 0&&(e=0),t===void 0&&(t=0);var i=null;if(d?i=o[d.sn-o[0].sn+1]||null:e===0&&o[0].start===0&&(i=o[0]),i&&ui(e,t,i)===0)return i;var n=Ji(o,ui.bind(null,e,t));return!n||n===d&&i?i:n}function ui(d,o,e){if(d===void 0&&(d=0),o===void 0&&(o=0),e.start<=d&&e.start+e.duration>d)return 0;var t=Math.min(o,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-t<=d?1:e.start-t>d&&e.start?-1:0}function jr(d,o,e){var t=1e3*Math.min(o,e.duration+(e.deltaPTS?e.deltaPTS:0));return(e.endProgramDateTime||0)-t>d}var Qr=N(21);let pn=function(d){for(var o="",e=d.length,t=0;t<e;t++)o+="["+d.start(t).toFixed(3)+","+d.end(t).toFixed(3)+"]";return o};function $i(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Gr(d,o){return Gr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Gr(d,o)}var yr="STOPPED",Et="IDLE",Zi="KEY_LOADING",Kr="FRAG_LOADING",Fr="FRAG_LOADING_WAITING_RETRY",di="WAITING_TRACK",Sr="PARSING",Hr="PARSED",Jr="ENDED",kr="ERROR",Mr="WAITING_INIT_PTS",qr="WAITING_LEVEL",ci=function(d){var o,e;function t(r,s,l,u){var c;return(c=d.call(this)||this).hls=void 0,c.fragPrevious=null,c.fragCurrent=null,c.fragmentTracker=void 0,c.transmuxer=null,c._state=yr,c.media=null,c.mediaBuffer=null,c.config=void 0,c.bitrateTest=!1,c.lastCurrentTime=0,c.nextLoadPosition=0,c.startPosition=0,c.loadedmetadata=!1,c.fragLoadError=0,c.retryDate=0,c.levels=null,c.fragmentLoader=void 0,c.keyLoader=void 0,c.levelLastLoaded=null,c.startFragRequested=!1,c.decrypter=void 0,c.initPTS=[],c.onvseeking=null,c.onvended=null,c.logPrefix="",c.log=void 0,c.warn=void 0,c.logPrefix=u,c.log=k.logger.log.bind(k.logger,u+":"),c.warn=k.logger.warn.bind(k.logger,u+":"),c.hls=r,c.fragmentLoader=new br(r.config),c.keyLoader=l,c.fragmentTracker=s,c.config=r.config,c.decrypter=new Qr.default(r.config),r.on(p.Events.LEVEL_SWITCHING,c.onLevelSwitching,function(v){if(v===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return v}(c)),c}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Gr(o,e);var i,n,a=t.prototype;return a.doTick=function(){this.onTickEnd()},a.onTickEnd=function(){},a.startLoad=function(r){},a.stopLoad=function(){this.fragmentLoader.abort(),this.keyLoader.abort();var r=this.fragCurrent;r&&(r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=yr},a._streamEnded=function(r,s){if(s.live||r.nextStart||!r.end||!this.media)return!1;var l=s.partList;if(l!=null&&l.length){var u=l[l.length-1];return Mt.isBuffered(this.media,u.start+u.duration/2)}var c=s.fragments[s.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(c)},a.getLevelDetails=function(){var r;if(this.levels&&this.levelLastLoaded!==null)return(r=this.levels[this.levelLastLoaded])===null||r===void 0?void 0:r.details},a.onMediaAttached=function(r,s){var l=this.media=this.mediaBuffer=s.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),l.addEventListener("seeking",this.onvseeking),l.addEventListener("ended",this.onvended);var u=this.config;this.levels&&u.autoStartLoad&&this.state===yr&&this.startLoad(u.startPosition)},a.onMediaDetaching=function(){var r=this.media;r!=null&&r.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),r&&this.onvseeking&&this.onvended&&(r.removeEventListener("seeking",this.onvseeking),r.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},a.onMediaSeeking=function(){var r=this.config,s=this.fragCurrent,l=this.media,u=this.mediaBuffer,c=this.state,v=l?l.currentTime:0,m=Mt.bufferInfo(u||l,v,r.maxBufferHole);if(this.log("media seeking to "+((0,R.isFiniteNumber)(v)?v.toFixed(3):v)+", state: "+c),this.state===Jr)this.resetLoadingState();else if(s){var _=r.maxFragLookUpTolerance,S=s.start-_,P=s.start+s.duration+_;if(!m.len||P<m.start||S>m.end){var I=v>P;(v<S||I)&&(I&&s.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),s.abortRequests()),this.resetLoadingState())}}l&&(this.lastCurrentTime=v),this.loadedmetadata||m.len||(this.nextLoadPosition=this.startPosition=v),this.tickImmediate()},a.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},a.onLevelSwitching=function(r,s){this.fragLoadError=0},a.onHandlerDestroying=function(){this.stopLoad(),d.prototype.onHandlerDestroying.call(this)},a.onHandlerDestroyed=function(){this.state=yr,this.hls.off(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,d.prototype.onHandlerDestroyed.call(this)},a.loadFragment=function(r,s,l){this._loadFragForPlayback(r,s,l)},a._loadFragForPlayback=function(r,s,l){var u=this;this._doFragLoad(r,s,l,function(c){if(u.fragContextChanged(r))return u.warn("Fragment "+r.sn+(c.part?" p: "+c.part.index:"")+" of level "+r.level+" was dropped during download."),void u.fragmentTracker.removeFragment(r);r.stats.chunkCount++,u._handleFragmentLoadProgress(c)}).then(function(c){if(c){u.fragLoadError=0;var v=u.state;u.fragContextChanged(r)?(v===Kr||!u.fragCurrent&&v===Sr)&&(u.fragmentTracker.removeFragment(r),u.state=Et):("payload"in c&&(u.log("Loaded fragment "+r.sn+" of level "+r.level),u.hls.trigger(p.Events.FRAG_LOADED,c)),u._handleFragmentLoadComplete(c))}}).catch(function(c){u.state!==yr&&u.state!==kr&&(u.warn(c),u.resetFragmentLoading(r))})},a.flushMainBuffer=function(r,s,l){if(l===void 0&&(l=null),r-s){var u={startOffset:r,endOffset:s,type:l};this.fragLoadError=0,this.hls.trigger(p.Events.BUFFER_FLUSHING,u)}},a._loadInitSegment=function(r,s){var l=this;this._doFragLoad(r,s).then(function(u){if(!u||l.fragContextChanged(r)||!l.levels)throw new Error("init load aborted");return u}).then(function(u){var c=l.hls,v=u.payload,m=r.decryptdata;if(v&&v.byteLength>0&&m&&m.key&&m.iv&&m.method==="AES-128"){var _=self.performance.now();return l.decrypter.decrypt(new Uint8Array(v),m.key.buffer,m.iv.buffer).then(function(S){var P=self.performance.now();return c.trigger(p.Events.FRAG_DECRYPTED,{frag:r,payload:S,stats:{tstart:_,tdecrypt:P}}),u.payload=S,u})}return u}).then(function(u){var c=l.fragCurrent,v=l.hls,m=l.levels;if(!m)throw new Error("init load aborted, missing levels");m[r.level].details;var _=r.stats;l.state=Et,l.fragLoadError=0,r.data=new Uint8Array(u.payload),_.parsing.start=_.buffering.start=self.performance.now(),_.parsing.end=_.buffering.end=self.performance.now(),u.frag===c&&v.trigger(p.Events.FRAG_BUFFERED,{stats:_,frag:c,part:null,id:r.type}),l.tick()}).catch(function(u){l.state!==yr&&l.state!==kr&&(l.warn(u),l.resetFragmentLoading(r))})},a.fragContextChanged=function(r){var s=this.fragCurrent;return!r||!s||r.level!==s.level||r.sn!==s.sn||r.urlId!==s.urlId},a.fragBufferedComplete=function(r,s){var l,u,c=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+r.type+" sn: "+r.sn+(s?" part: "+s.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+r.level+" "+(c?pn(Mt.getBuffered(c)):"(detached)")),this.state=Et,c&&(!this.loadedmetadata&&r.type==pe.PlaylistLevelType.MAIN&&c.buffered.length&&((l=this.fragCurrent)===null||l===void 0?void 0:l.sn)===((u=this.fragPrevious)===null||u===void 0?void 0:u.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},a.seekToStartPos=function(){},a._handleFragmentLoadComplete=function(r){var s=this.transmuxer;if(s){var l=r.frag,u=r.part,c=r.partsLoaded,v=!c||c.length===0||c.some(function(_){return!_}),m=new ki(l.level,l.sn,l.stats.chunkCount+1,0,u?u.index:-1,!v);s.flush(m)}},a._handleFragmentLoadProgress=function(r){},a._doFragLoad=function(r,s,l,u){var c,v=this;if(l===void 0&&(l=null),!this.levels)throw new Error("frag load aborted, missing levels");var m=null;if(!r.encrypted||(c=r.decryptdata)!==null&&c!==void 0&&c.key?!r.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(r,s.encryptedFragments):(this.log("Loading key for "+r.sn+" of ["+s.startSN+"-"+s.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+r.level),this.state=Zi,this.fragCurrent=r,m=this.keyLoader.load(r).then(function(q){if(!v.fragContextChanged(q.frag))return v.hls.trigger(p.Events.KEY_LOADED,q),q}),this.hls.trigger(p.Events.KEY_LOADING,{frag:r}),this.throwIfFragContextChanged("KEY_LOADING")),l=Math.max(r.start,l||0),this.config.lowLatencyMode&&s){var _=s.partList;if(_&&u){l>r.end&&s.fragmentHint&&(r=s.fragmentHint);var S=this.getNextPart(_,r,l);if(S>-1){var P=_[S];return this.log("Loading part sn: "+r.sn+" p: "+P.index+" cc: "+r.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+S+"-"+(_.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(l.toFixed(3))),this.nextLoadPosition=P.start+P.duration,this.state=Kr,this.hls.trigger(p.Events.FRAG_LOADING,{frag:r,part:_[S],targetBufferTime:l}),this.throwIfFragContextChanged("FRAG_LOADING parts"),m?m.then(function(q){return!q||v.fragContextChanged(q.frag)?null:v.doFragPartsLoad(r,_,S,u)}).catch(function(q){return v.handleFragLoadError(q)}):this.doFragPartsLoad(r,_,S,u).catch(function(q){return v.handleFragLoadError(q)})}if(!r.url||this.loadedEndOfParts(_,l))return Promise.resolve(null)}}this.log("Loading fragment "+r.sn+" cc: "+r.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+r.level+", target: "+parseFloat(l.toFixed(3))),(0,R.isFiniteNumber)(r.sn)&&!this.bitrateTest&&(this.nextLoadPosition=r.start+r.duration),this.state=Kr,this.hls.trigger(p.Events.FRAG_LOADING,{frag:r,targetBufferTime:l}),this.throwIfFragContextChanged("FRAG_LOADING");var I=this.config.progressive;return I&&m?m.then(function(q){return!q||v.fragContextChanged(q==null?void 0:q.frag)?null:v.fragmentLoader.load(r,u)}).catch(function(q){return v.handleFragLoadError(q)}):Promise.all([this.fragmentLoader.load(r,I?u:void 0),m]).then(function(q){var se=q[0];return!I&&se&&u&&u(se),se}).catch(function(q){return v.handleFragLoadError(q)})},a.throwIfFragContextChanged=function(r){if(this.fragCurrent===null)throw new Error("frag load aborted, context changed in "+r)},a.doFragPartsLoad=function(r,s,l,u){var c=this;return new Promise(function(v,m){var _=[];(function S(P){var I=s[P];c.fragmentLoader.loadPart(r,I,u).then(function(q){_[I.index]=q;var se=q.part;c.hls.trigger(p.Events.FRAG_LOADED,q);var Ee=s[P+1];if(!Ee||Ee.fragment!==r)return v({frag:r,part:se,partsLoaded:_});S(P+1)}).catch(m)})(l)})},a.handleFragLoadError=function(r){if("data"in r){var s=r.data;r.data&&s.details===w.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(s.frag,s.part):this.hls.trigger(p.Events.ERROR,s)}else this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.INTERNAL_EXCEPTION,err:r,fatal:!0});return null},a._handleTransmuxerFlush=function(r){var s=this.getCurrentContext(r);if(s&&this.state===Sr){var l=s.frag,u=s.part,c=s.level,v=self.performance.now();l.stats.parsing.end=v,u&&(u.stats.parsing.end=v),this.updateLevelTiming(l,u,c,r.partial)}else this.fragCurrent||this.state===yr||this.state===kr||(this.state=Et)},a.getCurrentContext=function(r){var s=this.levels,l=r.level,u=r.sn,c=r.part;if(!s||!s[l])return this.warn("Levels object was unset while buffering fragment "+u+" of level "+l+". The current chunk will not be buffered."),null;var v=s[l],m=c>-1?function(S,P,I){if(!S||!S.details)return null;var q=S.details.partList;if(q)for(var se=q.length;se--;){var Ee=q[se];if(Ee.index===I&&Ee.fragment.sn===P)return Ee}return null}(v,u,c):null,_=m?m.fragment:function(S,P,I){if(!S||!S.details)return null;var q=S.details,se=q.fragments[P-q.startSN];return se||((se=q.fragmentHint)&&se.sn===P?se:P<q.startSN&&I&&I.sn===P?I:null)}(v,u,this.fragCurrent);return _?{frag:_,part:m,level:v}:null},a.bufferFragmentData=function(r,s,l,u){if(r&&this.state===Sr){var c=r.data1,v=r.data2,m=c;if(c&&v&&(m=(0,J.appendUint8Array)(c,v)),m&&m.length){var _={type:r.type,frag:s,part:l,chunkMeta:u,parent:s.type,data:m};this.hls.trigger(p.Events.BUFFER_APPENDING,_),r.dropped&&r.independent&&!l&&this.flushBufferGap(s)}}},a.flushBufferGap=function(r){var s=this.media;if(s)if(Mt.isBuffered(s,s.currentTime)){var l=s.currentTime,u=Mt.bufferInfo(s,l,0),c=r.duration,v=Math.min(2*this.config.maxFragLookUpTolerance,.25*c),m=Math.max(Math.min(r.start-v,u.end-v),l+v);r.start-m>v&&this.flushMainBuffer(m,r.start)}else this.flushMainBuffer(0,r.start)},a.getFwdBufferInfo=function(r,s){var l=this.config,u=this.getLoadPosition();if(!(0,R.isFiniteNumber)(u))return null;var c=Mt.bufferInfo(r,u,l.maxBufferHole);if(c.len===0&&c.nextStart!==void 0){var v=this.fragmentTracker.getBufferedFrag(u,s);if(v&&c.nextStart<v.end)return Mt.bufferInfo(r,u,Math.max(c.nextStart,l.maxBufferHole))}return c},a.getMaxBufferLength=function(r){var s,l=this.config;return s=r?Math.max(8*l.maxBufferSize/r,l.maxBufferLength):l.maxBufferLength,Math.min(s,l.maxMaxBufferLength)},a.reduceMaxBufferLength=function(r){var s=this.config,l=r||s.maxBufferLength;return s.maxMaxBufferLength>=l&&(s.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+s.maxMaxBufferLength+"s"),!0)},a.getNextFragment=function(r,s){var l=s.fragments,u=l.length;if(!u)return null;var c,v=this.config,m=l[0].start;if(s.live){var _=v.initialLiveManifestSize;if(u<_)return this.warn("Not enough fragments to start playback (have: "+u+", need: "+_+")"),null;s.PTSKnown||this.startFragRequested||this.startPosition!==-1||(c=this.getInitialLiveFragment(s,l),this.startPosition=c?this.hls.liveSyncPosition||c.start:r)}else r<=m&&(c=l[0]);if(!c){var S=v.lowLatencyMode?s.partEnd:s.fragmentEnd;c=this.getFragmentAtPosition(r,S,s)}return this.mapToInitFragWhenRequired(c)},a.mapToInitFragWhenRequired=function(r){return r==null||!r.initSegment||r!=null&&r.initSegment.data||this.bitrateTest?r:r.initSegment},a.getNextPart=function(r,s,l){for(var u=-1,c=!1,v=!0,m=0,_=r.length;m<_;m++){var S=r[m];if(v=v&&!S.independent,u>-1&&l<S.start)break;var P=S.loaded;P?u=-1:(c||S.independent||v)&&S.fragment===s&&(u=m),c=P}return u},a.loadedEndOfParts=function(r,s){var l=r[r.length-1];return l&&s>l.start&&l.loaded},a.getInitialLiveFragment=function(r,s){var l=this.fragPrevious,u=null;if(l){if(r.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+l.programDateTime),u=function(_,S,P){if(S===null||!Array.isArray(_)||!_.length||!(0,R.isFiniteNumber)(S)||S<(_[0].programDateTime||0)||S>=(_[_.length-1].endProgramDateTime||0))return null;P=P||0;for(var I=0;I<_.length;++I){var q=_[I];if(jr(S,P,q))return q}return null}(s,l.endProgramDateTime,this.config.maxFragLookUpTolerance)),!u){var c=l.sn+1;if(c>=r.startSN&&c<=r.endSN){var v=s[c-r.startSN];l.cc===v.cc&&(u=v,this.log("Live playlist, switching playlist, load frag with next SN: "+u.sn))}u||(u=function(_,S){return Ji(_,function(P){return P.cc<S?1:P.cc>S?-1:0})}(s,l.cc),u&&this.log("Live playlist, switching playlist, load frag with same CC: "+u.sn))}}else{var m=this.hls.liveSyncPosition;m!==null&&(u=this.getFragmentAtPosition(m,this.bitrateTest?r.fragmentEnd:r.edge,r))}return u},a.getFragmentAtPosition=function(r,s,l){var u,c=this.config,v=this.fragPrevious,m=l.fragments,_=l.endSN,S=l.fragmentHint,P=c.maxFragLookUpTolerance,I=!!(c.lowLatencyMode&&l.partList&&S);if(I&&S&&!this.bitrateTest&&(m=m.concat(S),_=S.sn),u=r<s?li(v,m,r,r>s-P?0:P):m[m.length-1]){var q=u.sn-l.startSN;if(this.fragmentTracker.getState(u)===Ue.OK&&(v=u),v&&u.sn===v.sn&&!I&&v&&u.level===v.level){var se=m[q+1];u.sn<_&&this.fragmentTracker.getState(se)!==Ue.OK?(this.log("SN "+u.sn+" just loaded, load next one: "+se.sn),u=se):u=null}}return u},a.synchronizeToLiveEdge=function(r){var s=this.config,l=this.media;if(l){var u=this.hls.liveSyncPosition,c=l.currentTime,v=r.fragments[0].start,m=r.edge,_=c>=v-s.maxFragLookUpTolerance&&c<=m;if(u!==null&&l.duration>u&&(c<u||!_)){var S=s.liveMaxLatencyDuration!==void 0?s.liveMaxLatencyDuration:s.liveMaxLatencyDurationCount*r.targetduration;(!_&&l.readyState<4||c<m-S)&&(this.loadedmetadata||(this.nextLoadPosition=u),l.readyState&&(this.warn("Playback: "+c.toFixed(3)+" is located too far from the end of live sliding playlist: "+m+", reset currentTime to : "+u.toFixed(3)),l.currentTime=u))}}},a.alignPlaylists=function(r,s){var l=this.levels,u=this.levelLastLoaded,c=this.fragPrevious,v=u!==null?l[u]:null,m=r.fragments.length;if(!m)return this.warn("No fragments in live playlist"),0;var _=r.fragments[0].start,S=!s,P=r.alignedSliding&&(0,R.isFiniteNumber)(_);if(S||!P&&!_){(function(q,se,Ee){se&&(function(he,Ae,He){if(function(be,Ge,Me){return!(!Ge.details||!(Me.endCC>Me.startCC||be&&be.cc<Me.startCC))}(he,He,Ae)){var ze=function(be,Ge,Me){Me===void 0&&(Me=0);var ct=be.fragments,Ot=Ge.fragments;if(Ot.length&&ct.length){var ft=zi(ct,Ot[0].cc);if(ft&&(!ft||ft.startPTS))return ft;k.logger.log("No frag in previous level to align on")}else k.logger.log("No fragments to align")}(He.details,Ae);ze&&(0,R.isFiniteNumber)(ze.start)&&(k.logger.log("Adjusting PTS using last level due to CC increase within current level "+Ae.url),oi(ze.start,Ae))}}(q,Ee,se),!Ee.alignedSliding&&se.details&&function(he,Ae){if(Ae.fragments.length&&he.hasProgramDateTime&&Ae.hasProgramDateTime){var He=Ae.fragments[0].programDateTime,ze=he.fragments[0].programDateTime,be=(ze-He)/1e3+Ae.fragments[0].start;be&&(0,R.isFiniteNumber)(be)&&(k.logger.log("Adjusting PTS using programDateTime delta "+(ze-He)+"ms, sliding:"+be.toFixed(3)+" "+he.url+" "),oi(be,he))}}(Ee,se.details),Ee.alignedSliding||!se.details||Ee.skippedSegments||z(se.details,Ee))})(c,v,r);var I=r.fragments[0].start;return this.log("Live playlist sliding: "+I.toFixed(2)+" start-sn: "+(s?s.startSN:"na")+"->"+r.startSN+" prev-sn: "+(c?c.sn:"na")+" fragments: "+m),I}return _},a.waitForCdnTuneIn=function(r){return r.live&&r.canBlockReload&&r.partTarget&&r.tuneInGoal>Math.max(r.partHoldBack,3*r.partTarget)},a.setStartPosition=function(r,s){var l=this.startPosition;if(l<s&&(l=-1),l===-1||this.lastCurrentTime===-1){var u=r.startTimeOffset;(0,R.isFiniteNumber)(u)?(l=s+u,u<0&&(l+=r.totalduration),l=Math.min(Math.max(s,l),s+r.totalduration),this.log("Start time offset "+u+" found in playlist, adjust startPosition to "+l),this.startPosition=l):r.live?l=this.hls.liveSyncPosition||s:this.startPosition=l=0,this.lastCurrentTime=l}this.nextLoadPosition=l},a.getLoadPosition=function(){var r=this.media,s=0;return this.loadedmetadata&&r?s=r.currentTime:this.nextLoadPosition&&(s=this.nextLoadPosition),s},a.handleFragLoadAborted=function(r,s){this.transmuxer&&r.sn!=="initSegment"&&r.stats.aborted&&(this.warn("Fragment "+r.sn+(s?" part"+s.index:"")+" of level "+r.level+" was aborted"),this.resetFragmentLoading(r))},a.resetFragmentLoading=function(r){this.fragCurrent&&(this.fragContextChanged(r)||this.state===Fr)||(this.state=Et)},a.onFragmentOrKeyLoadError=function(r,s){if(s.fatal)return this.stopLoad(),void(this.state=kr);var l=this.config;if(s.chunkMeta){var u=this.getCurrentContext(s.chunkMeta);u&&(s.frag=u.frag,s.levelRetry=!0,this.fragLoadError=l.fragLoadingMaxRetry)}var c=s.frag;if(c&&c.type===r)if(this.fragCurrent,this.fragLoadError+1<=l.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var v=Math.min(Math.pow(2,this.fragLoadError)*l.fragLoadingRetryDelay,l.fragLoadingMaxRetryTimeout);this.warn("Fragment "+c.sn+" of "+r+" "+c.level+" failed to load, retrying in "+v+"ms"),this.retryDate=self.performance.now()+v,this.fragLoadError++,this.state=Fr}else s.levelRetry?(r===pe.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=Et):(k.logger.error(s.details+" reaches max retry, redispatch as fatal ..."),s.fatal=!0,this.hls.stopLoad(),this.state=kr)},a.afterBufferFlushed=function(r,s,l){if(r){var u=Mt.getBuffered(r);this.fragmentTracker.detectEvictedFragments(s,u,l),this.state===Jr&&this.resetLoadingState()}},a.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Et},a.resetStartWhenNotLoaded=function(r){if(!this.loadedmetadata){this.startFragRequested=!1;var s=this.levels?this.levels[r].details:null;s!=null&&s.live?(this.startPosition=-1,this.setStartPosition(s,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},a.updateLevelTiming=function(r,s,l,u){var c=this,v=l.details;Object.keys(r.elementaryStreams).reduce(function(m,_){var S=r.elementaryStreams[_];if(S){var P=S.endPTS-S.startPTS;if(P<=0)return c.warn("Could not parse fragment "+r.sn+" "+_+" duration reliably ("+P+")"),m||!1;var I=u?0:Y(v,r,S.startPTS,S.endPTS,S.startDTS,S.endDTS);return c.hls.trigger(p.Events.LEVEL_PTS_UPDATED,{details:v,level:l,drift:I,type:_,frag:r,start:S.startPTS,end:S.endPTS}),!0}return m},!1)||(this.warn("Found no media in fragment "+r.sn+" of level "+l.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=Hr,this.hls.trigger(p.Events.FRAG_PARSED,{frag:r,part:s})},a.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},i=t,(n=[{key:"state",get:function(){return this._state},set:function(r){var s=this._state;s!==r&&(this._state=r,this.log(s+"->"+r))}}])&&$i(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(Ir);function hi(){return self.MediaSource||self.WebKitMediaSource}function fi(){return self.SourceBuffer||self.WebKitSourceBuffer}var wi=function(){var d=ENTRY_MODULE,o={},e=function i(n){var a=o[n];if(a!==void 0)return a.exports;var r=o[n]={exports:{}};return d[n].call(r.exports,r,r.exports,i),r.exports};e.m=d,e.n=function(i){var n=i&&i.__esModule?function(){return i.default}:function(){return i};return e.d(n,{a:n}),n},e.d=function(i,n){for(var a in n)e.o(n,a)&&!e.o(i,a)&&Object.defineProperty(i,a,{enumerable:!0,get:n[a]})},e.o=function(i,n){return Object.prototype.hasOwnProperty.call(i,n)},e.r=function(i){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var t=e(ENTRY_MODULE);return t.default||t}.toString().split("ENTRY_MODULE"),en="\\(\\s*(/\\*.*?\\*/)?\\s*.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)";function Wt(d){return(d+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function vi(d,o,e){var t={};t[e]=[];var i=o.toString().replace(/^"[^"]+"/,"function"),n=i.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||i.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!n)return t;for(var a,r=n[1],s=new RegExp("(\\\\n|\\W)"+Wt(r)+en,"g");a=s.exec(i);)a[3]!=="dll-reference"&&t[e].push(a[3]);for(s=new RegExp("\\("+Wt(r)+'\\("(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))"\\)\\)'+en,"g");a=s.exec(i);)d[a[2]]||(t[e].push(a[1]),d[a[2]]=N(a[1]).m),t[a[2]]=t[a[2]]||[],t[a[2]].push(a[4]);for(var l,u=Object.keys(t),c=0;c<u.length;c++)for(var v=0;v<t[u[c]].length;v++)l=t[u[c]][v],isNaN(1*l)||(t[u[c]][v]=1*t[u[c]][v]);return t}function mn(d){return Object.keys(d).reduce(function(o,e){return o||d[e].length>0},!1)}function tn(d,o,e,t){var i=d[t].map(function(n){return'"'+n+'": '+o[t][n].toString().replace(/^"[^"]+"/,"function")}).join(",");return wi[0]+"{"+i+"}"+wi[1]+'"'+e+'"'+wi[2]}var Nr=N(544),Di=N(729),$r=N.n(Di),Zr=hi()||{isTypeSupported:function(){return!1}},Li=function(){function d(e,t,i,n){var a=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;var s=function(v,m){(m=m||{}).frag=a.frag,m.id=a.id,a.hls.trigger(v,m)};this.observer=new Di.EventEmitter,this.observer.on(p.Events.FRAG_DECRYPTED,s),this.observer.on(p.Events.ERROR,s);var l={mp4:Zr.isTypeSupported("video/mp4"),mpeg:Zr.isTypeSupported("audio/mpeg"),mp3:Zr.isTypeSupported('audio/mp4; codecs="mp3"')},u=navigator.vendor;if(this.useWorker&&typeof Worker!="undefined"){var c;k.logger.log("demuxing in webworker");try{c=this.worker=function(v,m){m=m||{};var _={main:N.m},S=m.all?{main:Object.keys(_.main)}:function(Ee,he){for(var Ae={main:[he]},He={main:[]},ze={main:{}};mn(Ae);)for(var be=Object.keys(Ae),Ge=0;Ge<be.length;Ge++){var Me=be[Ge],ct=Ae[Me].pop();if(ze[Me]=ze[Me]||{},!ze[Me][ct]&&Ee[Me][ct]){ze[Me][ct]=!0,He[Me]=He[Me]||[],He[Me].push(ct);for(var Ot=vi(Ee,Ee[Me][ct],Me),ft=Object.keys(Ot),Tt=0;Tt<ft.length;Tt++)Ae[ft[Tt]]=Ae[ft[Tt]]||[],Ae[ft[Tt]]=Ae[ft[Tt]].concat(Ot[ft[Tt]])}}return He}(_,v),P="";Object.keys(S).filter(function(Ee){return Ee!=="main"}).forEach(function(Ee){for(var he=0;S[Ee][he];)he++;S[Ee].push(he),_[Ee][he]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",P=P+"var "+Ee+" = ("+tn(S,_,he,modules)+`)();
|
|
9
|
+
`}),P=P+"new (("+tn(S,_,v,"main")+")())(self);";var I=new window.Blob([P],{type:"text/javascript"}),q=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(I),se=new window.Worker(q);return se.objectURL=q,se}(182),this.onwmsg=this.onWorkerMessage.bind(this),c.addEventListener("message",this.onwmsg),c.onerror=function(v){a.useWorker=!1,k.logger.warn("Exception in webworker, fallback to inline"),a.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.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){k.logger.warn("Error in worker:",v),k.logger.error("Error while initializing DemuxerWorker, fallback to inline"),c&&self.URL.revokeObjectURL(c.objectURL),this.transmuxer=new Nr.default(this.observer,l,r,u,t),this.worker=null}}else this.transmuxer=new Nr.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,P=this.worker,I=r?r.start:a.start,q=a.decryptdata,se=this.frag,Ee=!(se&&a.cc===se.cc),he=!(se&&u.level===se.level),Ae=se?u.sn-se.sn:-1,He=this.part?u.part-this.part.index:-1,ze=Ae===0&&u.id>1&&u.id===(se==null?void 0:se.stats.chunkCount),be=!he&&(Ae===1||Ae===0&&(He===1||ze&&He<=0)),Ge=self.performance.now();(he||Ae||a.stats.parsing.start===0)&&(a.stats.parsing.start=Ge),!r||!He&&be||(r.stats.parsing.start=Ge);var Me=!(se&&((v=a.initSegment)===null||v===void 0?void 0:v.url)===((m=se.initSegment)===null||m===void 0?void 0:m.url)),ct=new Nr.TransmuxState(Ee,be,l,he,I,Me);if(!be||Ee||Me){k.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: `+Ee+`
|
|
11
|
+
trackSwitch: `+he+`
|
|
12
|
+
contiguous: `+be+`
|
|
13
|
+
accurateTimeOffset: `+l+`
|
|
14
|
+
timeOffset: `+I+`
|
|
15
|
+
initSegmentChange: `+Me);var Ot=new Nr.TransmuxConfig(i,n,t,s,c);this.configureTransmuxer(Ot)}if(this.frag=a,this.part=r,P)P.postMessage({cmd:"demux",data:e,decryptdata:q,chunkMeta:u,state:ct},e instanceof ArrayBuffer?[e]:[]);else if(S){var ft=S.push(e,q,u,ct);(0,Nr.isPromise)(ft)?(S.async=!0,ft.then(function(Tt){_.handleTransmuxComplete(Tt)}).catch(function(Tt){_.transmuxerError(Tt,u,"transmuxer-interface push error")})):(S.async=!1,this.handleTransmuxComplete(ft))}},o.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var i=this.transmuxer,n=this.worker;if(n)n.postMessage({cmd:"flush",chunkMeta:e});else if(i){var a=i.flush(e);(0,Nr.isPromise)(a)||i.async?((0,Nr.isPromise)(a)||(a=Promise.resolve(a)),a.then(function(r){t.handleFlushResult(r,e)}).catch(function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(a,e)}},o.transmuxerError=function(e,t,i){this.hls&&this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i})},o.handleFlushResult=function(e,t){var i=this;e.forEach(function(n){i.handleTransmuxComplete(n)}),this.onFlush(t)},o.onWorkerMessage=function(e){var t=e.data,i=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":k.logger[t.data.logType]&&k.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data)}},o.configureTransmuxer=function(e){var t=this.worker,i=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):i&&i.configure(e)},o.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},d}(),rn=function(){function d(e,t,i,n){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=i,this.hls=n}var o=d.prototype;return o.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},o.poll=function(e,t){var i=this.config,n=this.media,a=this.stalled;if(n!==null){var r=n.currentTime,s=n.seeking,l=this.seeking&&!s,u=!this.seeking&&s;if(this.seeking=s,r===e){if((u||l)&&(this.stalled=null),!(n.paused&&!s||n.ended||n.playbackRate===0)&&Mt.getBuffered(n).length){var c=Mt.bufferInfo(n,r,0),v=c.len>0,m=c.nextStart||0;if(v||m){if(s){var _=c.len>2,S=!m||t&&t.start<=r||m-r>2&&!this.fragmentTracker.getPartialFragment(r);if(_||S)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var P,I=Math.max(m,c.start||0)-r,q=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,se=!(q==null||(P=q.details)===null||P===void 0)&&P.live?2*q.details.targetduration:2;if(I>0&&I<=se)return void this._trySkipBufferHole(null)}var Ee=self.performance.now();if(a!==null){var he=Ee-a;if(s||!(he>=250)||(this._reportStall(c),this.media)){var Ae=Mt.bufferInfo(n,r,i.maxBufferHole);this._tryFixBufferStall(Ae,he)}}else this.stalled=Ee}}}else if(this.moved=!0,a!==null){if(this.stallReported){var He=self.performance.now()-a;k.logger.warn("playback not stuck anymore @"+r+", after "+Math.round(He)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},o._tryFixBufferStall=function(e,t){var i=this.config,n=this.fragmentTracker,a=this.media;if(a!==null){var r=a.currentTime,s=n.getPartialFragment(r);if(s&&(this._trySkipBufferHole(s)||!this.media))return;e.len>i.maxBufferHole&&t>1e3*i.highBufferWatchdogPeriod&&(k.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},o._reportStall=function(e){var t=this.hls,i=this.media;!this.stallReported&&i&&(this.stallReported=!0,k.logger.warn("Playback stalling at @"+i.currentTime+" due to low buffer ("+JSON.stringify(e)+")"),t.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e.len}))},o._trySkipBufferHole=function(e){var t=this.config,i=this.hls,n=this.media;if(n===null)return 0;for(var a=n.currentTime,r=0,s=Mt.getBuffered(n),l=0;l<s.length;l++){var u=s.start(l);if(a+t.maxBufferHole>=r&&a<u){var c=Math.max(u+.05,n.currentTime+.1);return k.logger.warn("skipping hole, adjusting currentTime from "+a+" to "+c),this.moved=!0,this.stalled=null,n.currentTime=c,e&&i.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+a+" to "+c,frag:e}),c}r=s.end(l)}return 0},o._tryNudgeBuffer=function(){var e=this.config,t=this.hls,i=this.media,n=this.nudgeRetry;if(i!==null){var a=i.currentTime;if(this.nudgeRetry++,n<e.nudgeMaxRetry){var r=a+(n+1)*e.nudgeOffset;k.logger.warn("Nudging 'currentTime' from "+a+" to "+r),i.currentTime=r,t.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else k.logger.error("Playhead still not moving while enough data buffered @"+a+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},d}();function Vr(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Ri(d,o){return Ri=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ri(d,o)}var yn=function(d){var o,e;function t(r,s,l){var u;return(u=d.call(this,r,s,l,"[stream-controller]")||this).audioCodecSwap=!1,u.gapController=null,u.level=-1,u._forceStartLoad=!1,u.altAudio=!1,u.audioOnly=!1,u.fragPlaying=null,u.onvplaying=null,u.onvseeked=null,u.fragLastKbps=0,u.couldBacktrack=!1,u.backtrackFragment=null,u.audioCodecSwitch=!1,u.videoBuffer=null,u._registerListeners(),u}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ri(o,e);var i,n,a=t.prototype;return a._registerListeners=function(){var r=this.hls;r.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(p.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(p.Events.ERROR,this.onError,this),r.on(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(p.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(p.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var r=this.hls;r.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(p.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(p.Events.ERROR,this.onError,this),r.off(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(p.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(p.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},a.startLoad=function(r){if(this.levels){var s=this.lastCurrentTime,l=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var u=l.startLevel;u===-1&&(l.config.testBandwidth&&this.levels.length>1?(u=0,this.bitrateTest=!0):u=l.nextAutoLevel),this.level=l.nextLoadLevel=u,this.loadedmetadata=!1}s>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+s.toFixed(3)),r=s),this.state=Et,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=yr},a.stopLoad=function(){this._forceStartLoad=!1,d.prototype.stopLoad.call(this)},a.doTick=function(){switch(this.state){case Et:this.doTickIdle();break;case qr:var r,s=this.levels,l=this.level,u=s==null||(r=s[l])===null||r===void 0?void 0:r.details;if(u&&(!u.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(u))break;this.state=Et;break}break;case Fr:var c,v=self.performance.now(),m=this.retryDate;(!m||v>=m||(c=this.media)!==null&&c!==void 0&&c.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=Et)}this.onTickEnd()},a.onTickEnd=function(){d.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},a.doTickIdle=function(){var r=this.hls,s=this.levelLastLoaded,l=this.levels,u=this.media,c=r.config,v=r.nextLoadLevel;if(s!==null&&(u||!this.startFragRequested&&c.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&l&&l[v]){var m=l[v],_=this.getMainFwdBufferInfo();if(_!==null){var S=this.getLevelDetails();if(S&&this._streamEnded(_,S)){var P={};return this.altAudio&&(P.type="video"),this.hls.trigger(p.Events.BUFFER_EOS,P),void(this.state=Jr)}this.level=r.nextLoadLevel=v;var I=m.details;if(!I||this.state===qr||I.live&&this.levelLastLoaded!==v)return this.level=v,void(this.state=qr);if(!(_.len>=this.getMaxBufferLength(m.maxBitrate))){this.backtrackFragment&&this.backtrackFragment.start>_.end&&(this.backtrackFragment=null);var q=this.backtrackFragment?this.backtrackFragment.start:_.end,se=this.getNextFragment(q,I);if(this.couldBacktrack&&!this.fragPrevious&&se&&se.sn!=="initSegment"&&this.fragmentTracker.getState(se)!==Ue.OK){var Ee,he=((Ee=this.backtrackFragment)!=null?Ee:se).sn-I.startSN,Ae=I.fragments[he-1];Ae&&se.cc===Ae.cc&&(se=Ae,this.fragmentTracker.removeFragment(Ae))}else this.backtrackFragment&&_.len&&(this.backtrackFragment=null);if(se&&this.fragmentTracker.getState(se)===Ue.OK&&this.nextLoadPosition>q){var He=this.audioOnly&&!this.altAudio?$.ElementaryStreamTypes.AUDIO:$.ElementaryStreamTypes.VIDEO,ze=(He===$.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;ze&&this.afterBufferFlushed(ze,He,pe.PlaylistLevelType.MAIN),se=this.getNextFragment(this.nextLoadPosition,I)}se&&(!se.initSegment||se.initSegment.data||this.bitrateTest||(se=se.initSegment),this.loadFragment(se,I,q))}}}},a.loadFragment=function(r,s,l){var u,c=this.fragmentTracker.getState(r);this.fragCurrent=r,c===Ue.NOT_LOADED?r.sn==="initSegment"?this._loadInitSegment(r,s):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r,s)):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,s,l)):c===Ue.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((u=this.media)===null||u===void 0?void 0:u.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},a.getAppendedFrag=function(r){var s=this.fragmentTracker.getAppendedFrag(r,pe.PlaylistLevelType.MAIN);return s&&"fragment"in s?s.fragment:s},a.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,pe.PlaylistLevelType.MAIN)},a.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},a.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},a.nextLevelSwitch=function(){var r=this.levels,s=this.media;if(s!=null&&s.readyState){var l,u=this.getAppendedFrag(s.currentTime);if(u&&u.start>1&&this.flushMainBuffer(0,u.start-1),!s.paused&&r){var c=r[this.hls.nextLoadLevel],v=this.fragLastKbps;l=v&&this.fragCurrent?this.fragCurrent.duration*c.maxBitrate/(1e3*v)+1:0}else l=0;var m=this.getBufferedFrag(s.currentTime+l);if(m){var _=this.followingBufferedFrag(m);if(_){this.abortCurrentFrag();var S=_.maxStartPTS?_.maxStartPTS:_.start,P=_.duration,I=Math.max(m.end,S+Math.min(Math.max(P-this.config.maxFragLookUpTolerance,.5*P),.75*P));this.flushMainBuffer(I,Number.POSITIVE_INFINITY)}}}},a.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r&&r.abortRequests(),this.state){case Zi:case Kr:case Fr:case Sr:case Hr:this.state=Et}this.nextLoadPosition=this.getLoadPosition()},a.flushMainBuffer=function(r,s){d.prototype.flushMainBuffer.call(this,r,s,this.altAudio?"video":null)},a.onMediaAttached=function(r,s){d.prototype.onMediaAttached.call(this,r,s);var l=s.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),l.addEventListener("playing",this.onvplaying),l.addEventListener("seeked",this.onvseeked),this.gapController=new rn(this.config,l,this.fragmentTracker,this.hls)},a.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),d.prototype.onMediaDetaching.call(this)},a.onMediaPlaying=function(){this.tick()},a.onMediaSeeked=function(){var r=this.media,s=r?r.currentTime:null;(0,R.isFiniteNumber)(s)&&this.log("Media seeked to "+s.toFixed(3)),this.tick()},a.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},a.onManifestParsed=function(r,s){var l,u,c,v=!1,m=!1;s.levels.forEach(function(_){(l=_.audioCodec)&&(l.indexOf("mp4a.40.2")!==-1&&(v=!0),l.indexOf("mp4a.40.5")!==-1&&(m=!0))}),this.audioCodecSwitch=v&&m&&typeof((c=fi())==null||(u=c.prototype)===null||u===void 0?void 0:u.changeType)!="function",this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=s.levels,this.startFragRequested=!1},a.onLevelLoading=function(r,s){var l=this.levels;if(l&&this.state===Et){var u=l[s.level];(!u.details||u.details.live&&this.levelLastLoaded!==s.level||this.waitForCdnTuneIn(u.details))&&(this.state=qr)}},a.onLevelLoaded=function(r,s){var l,u=this.levels,c=s.level,v=s.details,m=v.totalduration;if(u){this.log("Level "+c+" loaded ["+v.startSN+","+v.endSN+"], cc ["+v.startCC+", "+v.endCC+"] duration:"+m);var _=this.fragCurrent;!_||this.state!==Kr&&this.state!==Fr||_.level!==s.level&&_.loader&&(this.state=Et,this.backtrackFragment=null,_.abortRequests());var S=u[c],P=0;if(v.live||(l=S.details)!==null&&l!==void 0&&l.live){if(v.fragments[0]||(v.deltaUpdateFailed=!0),v.deltaUpdateFailed)return;P=this.alignPlaylists(v,S.details)}if(S.details=v,this.levelLastLoaded=c,this.hls.trigger(p.Events.LEVEL_UPDATED,{details:v,level:c}),this.state===qr){if(this.waitForCdnTuneIn(v))return;this.state=Et}this.startFragRequested?v.live&&this.synchronizeToLiveEdge(v):this.setStartPosition(v,P),this.tick()}else this.warn("Levels were reset while loading level "+c)},a._handleFragmentLoadProgress=function(r){var s,l=r.frag,u=r.part,c=r.payload,v=this.levels;if(v){var m=v[l.level],_=m.details;if(_){var S=m.videoCodec,P=_.PTSKnown||!_.live,I=(s=l.initSegment)===null||s===void 0?void 0:s.data,q=this._getAudioCodec(m),se=this.transmuxer=this.transmuxer||new Li(this.hls,pe.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),Ee=u?u.index:-1,he=Ee!==-1,Ae=new ki(l.level,l.sn,l.stats.chunkCount,c.byteLength,Ee,he),He=this.initPTS[l.cc];se.push(c,I,q,S,l,u,_.totalduration,P,Ae,He)}else this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered")},a.onAudioTrackSwitching=function(r,s){var l=this.altAudio,u=!!s.url,c=s.id;if(!u){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var v=this.fragCurrent;v&&(this.log("Switching to main audio track, cancel main fragment load"),v.abortRequests()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var m=this.hls;l&&m.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),m.trigger(p.Events.AUDIO_TRACK_SWITCHED,{id:c})}},a.onAudioTrackSwitched=function(r,s){var l=s.id,u=!!this.hls.audioTracks[l].url;if(u){var c=this.videoBuffer;c&&this.mediaBuffer!==c&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=c)}this.altAudio=u,this.tick()},a.onBufferCreated=function(r,s){var l,u,c=s.tracks,v=!1;for(var m in c){var _=c[m];if(_.id==="main"){if(u=m,l=_,m==="video"){var S=c[m];S&&(this.videoBuffer=S.buffer)}}else v=!0}v&&l?(this.log("Alternate track found, use "+u+".buffered to schedule main fragment loading"),this.mediaBuffer=l.buffer):this.mediaBuffer=this.media},a.onFragBuffered=function(r,s){var l=s.frag,u=s.part;if(!l||l.type===pe.PlaylistLevelType.MAIN){if(this.fragContextChanged(l))return this.warn("Fragment "+l.sn+(u?" p: "+u.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Hr&&(this.state=Et));var c=u?u.stats:l.stats;this.fragLastKbps=Math.round(8*c.total/(c.buffering.end-c.loading.first)),l.sn!=="initSegment"&&(this.fragPrevious=l),this.fragBufferedComplete(l,u)}},a.onError=function(r,s){if(s.type!==w.ErrorTypes.KEY_SYSTEM_ERROR)switch(s.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.FRAG_PARSING_ERROR:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.MAIN,s);break;case w.ErrorDetails.LEVEL_LOAD_ERROR:case w.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==kr&&(s.fatal?(this.warn(""+s.details),this.state=kr):s.levelRetry||this.state!==qr||(this.state=Et));break;case w.ErrorDetails.BUFFER_FULL_ERROR:if(s.parent==="main"&&(this.state===Sr||this.state===Hr)){var l=!0,u=this.getFwdBufferInfo(this.media,pe.PlaylistLevelType.MAIN);u&&u.len>.5&&(l=!this.reduceMaxBufferLength(u.len)),l&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.MAIN,s)},a.checkBuffer=function(){var r=this.media,s=this.gapController;if(r&&s&&r.readyState){if(this.loadedmetadata||!Mt.getBuffered(r).length){var l=this.state!==Et?this.fragCurrent:null;s.poll(this.lastCurrentTime,l)}this.lastCurrentTime=r.currentTime}},a.onFragLoadEmergencyAborted=function(){this.state=Et,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},a.onBufferFlushed=function(r,s){var l=s.type;if(l!==$.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var u=(l===$.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(u,l,pe.PlaylistLevelType.MAIN)}},a.onLevelsUpdated=function(r,s){this.levels=s.levels},a.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},a.seekToStartPos=function(){var r=this.media;if(r){var s=r.currentTime,l=this.startPosition;if(l>=0&&s<l){if(r.seeking)return void this.log("could not seek to "+l+", already seeking at "+s);var u=Mt.getBuffered(r),c=(u.length?u.start(0):0)-l;c>0&&(c<this.config.maxBufferHole||c<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+c+" to match buffer start"),l+=c,this.startPosition=l),this.log("seek to target start position "+l+" from current time "+s),r.currentTime=l}}},a._getAudioCodec=function(r){var s=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&s&&(this.log("Swapping audio codec"),s=s.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),s},a._loadBitrateTestFrag=function(r,s){var l=this;r.bitrateTest=!0,this._doFragLoad(r,s).then(function(u){var c=l.hls;if(u&&!c.nextLoadLevel&&!l.fragContextChanged(r)){l.fragLoadError=0,l.state=Et,l.startFragRequested=!1,l.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),c.trigger(p.Events.FRAG_LOADED,u),r.bitrateTest=!1}})},a._handleTransmuxComplete=function(r){var s,l="main",u=this.hls,c=r.remuxResult,v=r.chunkMeta,m=this.getCurrentContext(v);if(!m)return this.warn("The loading context changed while buffering fragment "+v.sn+" of level "+v.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(v.level);var _=m.frag,S=m.part,P=m.level,I=c.video,q=c.text,se=c.id3,Ee=c.initSegment,he=P.details,Ae=this.altAudio?void 0:c.audio;if(!this.fragContextChanged(_)){if(this.state=Sr,Ee){Ee.tracks&&(this._bufferInitSegment(P,Ee.tracks,_,v),u.trigger(p.Events.FRAG_PARSING_INIT_SEGMENT,{frag:_,id:l,tracks:Ee.tracks}));var He=Ee.initPTS,ze=Ee.timescale;(0,R.isFiniteNumber)(He)&&(this.initPTS[_.cc]=He,u.trigger(p.Events.INIT_PTS_FOUND,{frag:_,id:l,initPTS:He,timescale:ze}))}if(I&&c.independent!==!1){if(he){var be=I.startPTS,Ge=I.endPTS,Me=I.startDTS,ct=I.endDTS;if(S)S.elementaryStreams[I.type]={startPTS:be,endPTS:Ge,startDTS:Me,endDTS:ct};else if(I.firstKeyFrame&&I.independent&&v.id===1&&(this.couldBacktrack=!0),I.dropped&&I.independent){var Ot=this.getMainFwdBufferInfo();if((Ot?Ot.end:this.getLoadPosition())+this.config.maxBufferHole<(I.firstKeyFramePTS?I.firstKeyFramePTS:be)-this.config.maxBufferHole)return void this.backtrack(_);_.setElementaryStreamInfo(I.type,_.start,Ge,_.start,ct,!0)}_.setElementaryStreamInfo(I.type,be,Ge,Me,ct),this.backtrackFragment&&(this.backtrackFragment=_),this.bufferFragmentData(I,_,S,v)}}else if(c.independent===!1)return void this.backtrack(_);if(Ae){var ft=Ae.startPTS,Tt=Ae.endPTS,Dt=Ae.startDTS,Zt=Ae.endDTS;S&&(S.elementaryStreams[$.ElementaryStreamTypes.AUDIO]={startPTS:ft,endPTS:Tt,startDTS:Dt,endDTS:Zt}),_.setElementaryStreamInfo($.ElementaryStreamTypes.AUDIO,ft,Tt,Dt,Zt),this.bufferFragmentData(Ae,_,S,v)}if(he&&se!=null&&(s=se.samples)!==null&&s!==void 0&&s.length){var zt={id:l,frag:_,details:he,samples:se.samples};u.trigger(p.Events.FRAG_PARSING_METADATA,zt)}if(he&&q){var Kt={id:l,frag:_,details:he,samples:q.samples};u.trigger(p.Events.FRAG_PARSING_USERDATA,Kt)}}},a._bufferInitSegment=function(r,s,l,u){var c=this;if(this.state===Sr){this.audioOnly=!!s.audio&&!s.video,this.altAudio&&!this.audioOnly&&delete s.audio;var v=s.audio,m=s.video,_=s.audiovideo;if(v){var S=r.audioCodec,P=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(S&&(S=S.indexOf("mp4a.40.5")!==-1?"mp4a.40.2":"mp4a.40.5"),v.metadata.channelCount!==1&&P.indexOf("firefox")===-1&&(S="mp4a.40.5")),P.indexOf("android")!==-1&&v.container!=="audio/mpeg"&&(S="mp4a.40.2",this.log("Android: force audio codec to "+S)),r.audioCodec&&r.audioCodec!==S&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+S+'"'),v.levelCodec=S,v.id="main",this.log("Init audio buffer, container:"+v.container+", codecs[selected/level/parsed]=["+(S||"")+"/"+(r.audioCodec||"")+"/"+v.codec+"]")}m&&(m.levelCodec=r.videoCodec,m.id="main",this.log("Init video buffer, container:"+m.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+m.codec+"]")),_&&this.log("Init audiovideo buffer, container:"+_.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+_.codec+"]"),this.hls.trigger(p.Events.BUFFER_CODECS,s),Object.keys(s).forEach(function(I){var q=s[I].initSegment;q!=null&&q.byteLength&&c.hls.trigger(p.Events.BUFFER_APPENDING,{type:I,data:q,frag:l,part:null,chunkMeta:u,parent:l.type})}),this.tick()}},a.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,pe.PlaylistLevelType.MAIN)},a.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=Et},a.checkFragmentChanged=function(){var r=this.media,s=null;if(r&&r.readyState>1&&r.seeking===!1){var l=r.currentTime;if(Mt.isBuffered(r,l)?s=this.getAppendedFrag(l):Mt.isBuffered(r,l+.1)&&(s=this.getAppendedFrag(l+.1)),s){this.backtrackFragment=null;var u=this.fragPlaying,c=s.level;u&&s.sn===u.sn&&u.level===c&&s.urlId===u.urlId||(this.fragPlaying=s,this.hls.trigger(p.Events.FRAG_CHANGED,{frag:s}),u&&u.level===c||this.hls.trigger(p.Events.LEVEL_SWITCHED,{level:c}))}}},i=t,(n=[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var s=r.currentTime,l=this.currentFrag;if(l&&(0,R.isFiniteNumber)(s)&&(0,R.isFiniteNumber)(l.programDateTime)){var u=l.programDateTime+1e3*(s-l.start);return new Date(u)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&Vr(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(ci);let gi=function(){function d(e,t,i){t===void 0&&(t=0),i===void 0&&(i=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}var o=d.prototype;return o.sample=function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e},o.getTotalWeight=function(){return this.totalWeight_},o.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},d}(),En=function(){function d(e,t,i){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new gi(e),this.fast_=new gi(t)}var o=d.prototype;return o.update=function(e,t){var i=this.slow_,n=this.fast_;this.slow_.halfLife!==e&&(this.slow_=new gi(e,i.getEstimate(),i.getTotalWeight())),this.fast_.halfLife!==t&&(this.fast_=new gi(t,n.getEstimate(),n.getTotalWeight()))},o.sample=function(e,t){var i=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/i;this.fast_.sample(i,n),this.slow_.sample(i,n)},o.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},o.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},o.destroy=function(){},d}();function Tn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}let bn=function(){function d(i){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=i;var n=i.config;this.bwEstimator=new En(n.abrEwmaSlowVoD,n.abrEwmaFastVoD,n.abrEwmaDefaultEstimate),this.registerListeners()}var o,e,t=d.prototype;return t.registerListeners=function(){var i=this.hls;i.on(p.Events.FRAG_LOADING,this.onFragLoading,this),i.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),i.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(p.Events.ERROR,this.onError,this)},t.unregisterListeners=function(){var i=this.hls;i.off(p.Events.FRAG_LOADING,this.onFragLoading,this),i.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this),i.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(p.Events.ERROR,this.onError,this)},t.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},t.onFragLoading=function(i,n){var a,r=n.frag;r.type===pe.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=r,this.partCurrent=(a=n.part)!=null?a:null,this.timer=self.setInterval(this.onCheck,100)))},t.onLevelLoaded=function(i,n){var a=this.hls.config;n.details.live?this.bwEstimator.update(a.abrEwmaSlowLive,a.abrEwmaFastLive):this.bwEstimator.update(a.abrEwmaSlowVoD,a.abrEwmaFastVoD)},t._abandonRulesCheck=function(){var i=this.fragCurrent,n=this.partCurrent,a=this.hls,r=a.autoLevelEnabled,s=a.media;if(i&&s){var l=n?n.stats:i.stats,u=n?n.duration:i.duration;if(l.aborted||l.loaded&&l.loaded===l.total||i.level===0)return this.clearTimer(),void(this._nextAutoLevel=-1);if(r&&!s.paused&&s.playbackRate&&s.readyState){var c=a.mainForwardBufferInfo;if(c!==null){var v=performance.now()-l.loading.start,m=Math.abs(s.playbackRate);if(!(v<=500*u/m)){var _=l.loaded&&l.loading.first,S=this.bwEstimator.getEstimate(),P=a.levels,I=a.minAutoLevel,q=P[i.level],se=l.total||Math.max(l.loaded,Math.round(u*q.maxBitrate/8)),Ee=_?1e3*l.loaded/v:0,he=Ee?(se-l.loaded)/Ee:8*se/S,Ae=c.len/m;if(!(he<=Ae)){var He,ze=Number.POSITIVE_INFINITY;for(He=i.level-1;He>I;He--){var be=P[He].maxBitrate;if((ze=Ee?u*be/(6.4*Ee):u*be/S)<Ae)break}ze>=he||(k.logger.warn("Fragment "+i.sn+(n?" part "+n.index:"")+" of level "+i.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+He+`
|
|
16
|
+
Current BW estimate: `+((0,R.isFiniteNumber)(S)?(S/1024).toFixed(3):"Unknown")+` Kb/s
|
|
17
|
+
Estimated load time for current fragment: `+he.toFixed(3)+` s
|
|
18
|
+
Estimated load time for the next fragment: `+ze.toFixed(3)+` s
|
|
19
|
+
Time to underbuffer: `+Ae.toFixed(3)+" s"),a.nextLoadLevel=He,_&&this.bwEstimator.sample(v,l.loaded),this.clearTimer(),(i.loader||i.keyLoader)&&(this.fragCurrent=this.partCurrent=null,i.abortRequests()),a.trigger(p.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:n,stats:l}))}}}}}},t.onFragLoaded=function(i,n){var a=n.frag,r=n.part;if(a.type===pe.PlaylistLevelType.MAIN&&(0,R.isFiniteNumber)(a.sn)){var s=r?r.stats:a.stats,l=r?r.duration:a.duration;if(this.clearTimer(),this.lastLoadedFragLevel=a.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[a.level],c=(u.loaded?u.loaded.bytes:0)+s.loaded,v=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:c,duration:v},u.realBitrate=Math.round(8*c/v)}if(a.bitrateTest){var m={stats:s,frag:a,part:r,id:a.type};this.onFragBuffered(p.Events.FRAG_BUFFERED,m)}}},t.onFragBuffered=function(i,n){var a=n.frag,r=n.part,s=r?r.stats:a.stats;if(!s.aborted&&a.type===pe.PlaylistLevelType.MAIN&&a.sn!=="initSegment"){var l=s.parsing.end-s.loading.start;this.bwEstimator.sample(l,s.loaded),s.bwEstimate=this.bwEstimator.getEstimate(),a.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}},t.onError=function(i,n){var a;if(((a=n.frag)===null||a===void 0?void 0:a.type)===pe.PlaylistLevelType.MAIN){if(n.type===w.ErrorTypes.KEY_SYSTEM_ERROR)return void this.clearTimer();switch(n.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.clearTimer()}}},t.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},t.getNextABRAutoLevel=function(){var i=this.fragCurrent,n=this.partCurrent,a=this.hls,r=a.maxAutoLevel,s=a.config,l=a.minAutoLevel,u=a.media,c=n?n.duration:i?i.duration:0,v=u&&u.playbackRate!==0?Math.abs(u.playbackRate):1,m=this.bwEstimator?this.bwEstimator.getEstimate():s.abrEwmaDefaultEstimate,_=a.mainForwardBufferInfo,S=(_?_.len:0)/v,P=this.findBestLevel(m,l,r,S,s.abrBandWidthFactor,s.abrBandWidthUpFactor);if(P>=0)return P;k.logger.trace((S?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var I=c?Math.min(c,s.maxStarvationDelay):s.maxStarvationDelay,q=s.abrBandWidthFactor,se=s.abrBandWidthUpFactor;if(!S){var Ee=this.bitrateTestDelay;Ee&&(I=(c?Math.min(c,s.maxLoadingDelay):s.maxLoadingDelay)-Ee,k.logger.trace("bitrate test took "+Math.round(1e3*Ee)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*I)+" ms"),q=se=1)}return P=this.findBestLevel(m,l,r,S+I,q,se),Math.max(P,0)},t.findBestLevel=function(i,n,a,r,s,l){for(var u,c=this.fragCurrent,v=this.partCurrent,m=this.lastLoadedFragLevel,_=this.hls.levels,S=_[m],P=!(S==null||(u=S.details)===null||u===void 0||!u.live),I=S==null?void 0:S.codecSet,q=v?v.duration:c?c.duration:0,se=a;se>=n;se--){var Ee=_[se];if(Ee&&(!I||Ee.codecSet===I)){var he,Ae=Ee.details,He=(v?Ae==null?void 0:Ae.partTarget:Ae==null?void 0:Ae.averagetargetduration)||q;he=se<=m?s*i:l*i;var ze=_[se].maxBitrate,be=ze*He/he;if(k.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+se+"/"+Math.round(he)+"/"+ze+"/"+He+"/"+r+"/"+be),he>ze&&(be===0||!(0,R.isFiniteNumber)(be)||P&&!this.bitrateTestDelay||be<r))return se}}return-1},o=d,(e=[{key:"nextAutoLevel",get:function(){var i=this._nextAutoLevel,n=this.bwEstimator;if(i!==-1&&!n.canEstimate())return i;var a=this.getNextABRAutoLevel();return i!==-1&&this.hls.levels[a].loadError?i:(i!==-1&&(a=Math.min(i,a)),a)},set:function(i){this._nextAutoLevel=i}}])&&Tn(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}();var nn=function(){function d(){this.chunks=[],this.dataLength=0}var o=d.prototype;return o.push=function(e){this.chunks.push(e),this.dataLength+=e.length},o.flush=function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=t.length===1?t[0]:function(n,a){for(var r=new Uint8Array(a),s=0,l=0;l<n.length;l++){var u=n[l];r.set(u,s),s+=u.length}return r}(t,i),this.reset(),e):new Uint8Array(0)},o.reset=function(){this.chunks.length=0,this.dataLength=0},d}();function pi(){return pi=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},pi.apply(this,arguments)}function Ii(d,o){return Ii=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ii(d,o)}var mi=function(d){var o,e;function t(n,a,r){var s;return(s=d.call(this,n,a,r,"[audio-stream-controller]")||this).videoBuffer=null,s.videoTrackCC=-1,s.waitingVideoCC=-1,s.audioSwitch=!1,s.trackId=-1,s.waitingData=null,s.mainDetails=null,s.bufferFlushed=!1,s.cachedTrackLoadedData=null,s._registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Ii(o,e);var i=t.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var n=this.hls;n.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(p.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.on(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.on(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.on(p.Events.ERROR,this.onError,this),n.on(p.Events.BUFFER_RESET,this.onBufferReset,this),n.on(p.Events.BUFFER_CREATED,this.onBufferCreated,this),n.on(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i._unregisterListeners=function(){var n=this.hls;n.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(p.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),n.off(p.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),n.off(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),n.off(p.Events.ERROR,this.onError,this),n.off(p.Events.BUFFER_RESET,this.onBufferReset,this),n.off(p.Events.BUFFER_CREATED,this.onBufferCreated,this),n.off(p.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),n.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),n.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},i.onInitPtsFound=function(n,a){var r=a.frag,s=a.id,l=a.initPTS;if(s==="main"){var u=r.cc;this.initPTS[r.cc]=l,this.log("InitPTS for cc: "+u+" found from main: "+l),this.videoTrackCC=u,this.state===Mr&&this.tick()}},i.startLoad=function(n){if(!this.levels)return this.startPosition=n,void(this.state=yr);var a=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,a>0&&n===-1?(this.log("Override startPosition with lastCurrentTime @"+a.toFixed(3)),n=a,this.state=Et):(this.loadedmetadata=!1,this.state=di),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=n,this.tick()},i.doTick=function(){switch(this.state){case Et:this.doTickIdle();break;case di:var n,a=this.levels,r=this.trackId,s=a==null||(n=a[r])===null||n===void 0?void 0:n.details;if(s){if(this.waitForCdnTuneIn(s))break;this.state=Mr}break;case Fr:var l,u=performance.now(),c=this.retryDate;(!c||u>=c||(l=this.media)!==null&&l!==void 0&&l.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Et);break;case Mr:var v=this.waitingData;if(v){var m=v.frag,_=v.part,S=v.cache,P=v.complete;if(this.initPTS[m.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Kr;var I={frag:m,part:_,payload:S.flush(),networkDetails:null};this._handleFragmentLoadProgress(I),P&&d.prototype._handleFragmentLoadComplete.call(this,I)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+m.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var q=this.getLoadPosition(),se=Mt.bufferInfo(this.mediaBuffer,q,this.config.maxBufferHole);ui(se.end,this.config.maxFragLookUpTolerance,m)<0&&(this.log("Waiting fragment cc ("+m.cc+") @ "+m.start+" cancelled because another fragment at "+se.end+" is needed"),this.clearWaitingFragment())}}else this.state=Et}this.onTickEnd()},i.clearWaitingFragment=function(){var n=this.waitingData;n&&(this.fragmentTracker.removeFragment(n.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Et)},i.resetLoadingState=function(){this.clearWaitingFragment(),d.prototype.resetLoadingState.call(this)},i.onTickEnd=function(){var n=this.media;n&&n.readyState&&(this.lastCurrentTime=n.currentTime)},i.doTickIdle=function(){var n=this.hls,a=this.levels,r=this.media,s=this.trackId,l=n.config;if(a&&a[s]&&(r||!this.startFragRequested&&l.startFragPrefetch)){var u=a[s].details;if(!u||u.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(u))this.state=di;else{var c=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&c&&(this.bufferFlushed=!1,this.afterBufferFlushed(c,$.ElementaryStreamTypes.AUDIO,pe.PlaylistLevelType.AUDIO));var v=this.getFwdBufferInfo(c,pe.PlaylistLevelType.AUDIO);if(v!==null){var m=this.audioSwitch;if(!m&&this._streamEnded(v,u))return n.trigger(p.Events.BUFFER_EOS,{type:"audio"}),void(this.state=Jr);var _=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,pe.PlaylistLevelType.MAIN);if(!(v.len>=this.getMaxBufferLength(_==null?void 0:_.len))||m){var S=u.fragments[0].start,P=v.end;if(m&&r){var I=this.getLoadPosition();P=I,u.PTSKnown&&I<S&&(v.end>S||v.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=S+.05)}if(!(_&&P>_.end+u.targetduration)&&(_&&_.len||!v.len)){var q=this.getNextFragment(P,u);q?this.loadFragment(q,u,P):this.bufferFlushed=!0}}}}}},i.getMaxBufferLength=function(n){var a=d.prototype.getMaxBufferLength.call(this);return n?Math.max(a,n):a},i.onMediaDetaching=function(){this.videoBuffer=null,d.prototype.onMediaDetaching.call(this)},i.onAudioTracksUpdated=function(n,a){var r=a.audioTracks;this.resetTransmuxer(),this.levels=r.map(function(s){return new F(s)})},i.onAudioTrackSwitching=function(n,a){var r=!!a.url;this.trackId=a.id;var s=this.fragCurrent;s&&s.abortRequests(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=Et):this.state=yr,this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},i.onLevelLoaded=function(n,a){this.mainDetails=a.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},i.onAudioTrackLoaded=function(n,a){var r;if(this.mainDetails!=null){var s=this.levels,l=a.details,u=a.id;if(s){this.log("Track "+u+" loaded ["+l.startSN+","+l.endSN+"],duration:"+l.totalduration);var c=s[u],v=0;if(l.live||(r=c.details)!==null&&r!==void 0&&r.live){var m=this.mainDetails;if(l.fragments[0]||(l.deltaUpdateFailed=!0),l.deltaUpdateFailed||!m)return;!c.details&&l.hasProgramDateTime&&m.hasProgramDateTime?(Qi(l,m),v=l.fragments[0].start):v=this.alignPlaylists(l,c.details)}c.details=l,this.levelLastLoaded=u,this.startFragRequested||!this.mainDetails&&l.live||this.setStartPosition(c.details,v),this.state!==di||this.waitForCdnTuneIn(l)||(this.state=Et),this.tick()}else this.warn("Audio tracks were reset while loading level "+u)}else this.cachedTrackLoadedData=a},i._handleFragmentLoadProgress=function(n){var a,r=n.frag,s=n.part,l=n.payload,u=this.config,c=this.trackId,v=this.levels;if(v){var m=v[c],_=m.details,S=u.defaultAudioCodec||m.audioCodec||"mp4a.40.2",P=this.transmuxer;P||(P=this.transmuxer=new Li(this.hls,pe.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var I=this.initPTS[r.cc],q=(a=r.initSegment)===null||a===void 0?void 0:a.data;if(I!==void 0){var se=s?s.index:-1,Ee=se!==-1,he=new ki(r.level,r.sn,r.stats.chunkCount,l.byteLength,se,Ee);P.push(l,q,S,"",r,s,_.totalduration,!1,he,I)}else this.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+_.startSN+" ,"+_.endSN+"],track "+c),(this.waitingData=this.waitingData||{frag:r,part:s,cache:new nn,complete:!1}).cache.push(new Uint8Array(l)),this.waitingVideoCC=this.videoTrackCC,this.state=Mr}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},i._handleFragmentLoadComplete=function(n){this.waitingData?this.waitingData.complete=!0:d.prototype._handleFragmentLoadComplete.call(this,n)},i.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},i.onBufferCreated=function(n,a){var r=a.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),a.tracks.video&&(this.videoBuffer=a.tracks.video.buffer||null)},i.onFragBuffered=function(n,a){var r,s=a.frag,l=a.part;s.type===pe.PlaylistLevelType.AUDIO?this.fragContextChanged(s)?this.warn("Fragment "+s.sn+(l?" p: "+l.index:"")+" of level "+s.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):(s.sn!=="initSegment"&&(this.fragPrevious=s,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(p.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(s,l)):this.loadedmetadata||s.type!==pe.PlaylistLevelType.MAIN||(r=this.videoBuffer||this.media)!==null&&r!==void 0&&r.buffered.length&&(this.loadedmetadata=!0)},i.onError=function(n,a){if(a.type!==w.ErrorTypes.KEY_SYSTEM_ERROR)switch(a.details){case w.ErrorDetails.FRAG_LOAD_ERROR:case w.ErrorDetails.FRAG_LOAD_TIMEOUT:case w.ErrorDetails.FRAG_PARSING_ERROR:case w.ErrorDetails.KEY_LOAD_ERROR:case w.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.AUDIO,a);break;case w.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case w.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==kr&&this.state!==yr&&(this.state=a.fatal?kr:Et,this.warn(a.details+" while loading frag, switching to "+this.state+" state"));break;case w.ErrorDetails.BUFFER_FULL_ERROR:if(a.parent==="audio"&&(this.state===Sr||this.state===Hr)){var r=!0,s=this.getFwdBufferInfo(this.mediaBuffer,pe.PlaylistLevelType.AUDIO);s&&s.len>.5&&(r=!this.reduceMaxBufferLength(s.len)),r&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}else this.onFragmentOrKeyLoadError(pe.PlaylistLevelType.AUDIO,a)},i.onBufferFlushed=function(n,a){a.type===$.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0,this.state===Jr&&(this.state=Et))},i._handleTransmuxComplete=function(n){var a,r="audio",s=this.hls,l=n.remuxResult,u=n.chunkMeta,c=this.getCurrentContext(u);if(!c)return this.warn("The loading context changed while buffering fragment "+u.sn+" of level "+u.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(u.level);var v=c.frag,m=c.part,_=c.level.details,S=l.audio,P=l.text,I=l.id3,q=l.initSegment;if(!this.fragContextChanged(v)&&_){if(this.state=Sr,this.audioSwitch&&S&&this.completeAudioSwitch(),q!=null&&q.tracks&&(this._bufferInitSegment(q.tracks,v,u),s.trigger(p.Events.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:r,tracks:q.tracks})),S){var se=S.startPTS,Ee=S.endPTS,he=S.startDTS,Ae=S.endDTS;m&&(m.elementaryStreams[$.ElementaryStreamTypes.AUDIO]={startPTS:se,endPTS:Ee,startDTS:he,endDTS:Ae}),v.setElementaryStreamInfo($.ElementaryStreamTypes.AUDIO,se,Ee,he,Ae),this.bufferFragmentData(S,v,m,u)}if(I!=null&&(a=I.samples)!==null&&a!==void 0&&a.length){var He=pi({id:r,frag:v,details:_},I);s.trigger(p.Events.FRAG_PARSING_METADATA,He)}if(P){var ze=pi({id:r,frag:v,details:_},P);s.trigger(p.Events.FRAG_PARSING_USERDATA,ze)}}},i._bufferInitSegment=function(n,a,r){if(this.state===Sr){n.video&&delete n.video;var s=n.audio;if(s){s.levelCodec=s.codec,s.id="audio",this.log("Init audio buffer, container:"+s.container+", codecs[parsed]=["+s.codec+"]"),this.hls.trigger(p.Events.BUFFER_CODECS,n);var l=s.initSegment;if(l!=null&&l.byteLength){var u={type:"audio",frag:a,part:null,chunkMeta:r,parent:a.type,data:l};this.hls.trigger(p.Events.BUFFER_APPENDING,u)}this.tick()}}},i.loadFragment=function(n,a,r){var s=this.fragmentTracker.getState(n);this.fragCurrent=n,(this.audioSwitch||s===Ue.NOT_LOADED||s===Ue.PARTIAL)&&(n.sn==="initSegment"?this._loadInitSegment(n,a):a.live&&!(0,R.isFiniteNumber)(this.initPTS[n.cc])?(this.log("Waiting for video PTS in continuity counter "+n.cc+" of live stream before loading audio fragment "+n.sn+" of level "+this.trackId),this.state=Mr):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,n,a,r)))},i.completeAudioSwitch=function(){var n=this.hls,a=this.media,r=this.trackId;a&&(this.log("Switching audio track : flushing all audio"),d.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,n.trigger(p.Events.AUDIO_TRACK_SWITCHED,{id:r})},t}(ci);let Ci=mi;function an(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function ei(d,o){return ei=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ei(d,o)}let _n=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[audio-track-controller]")||this).tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.trackName="",s.selectDefaultTrack=!0,s.registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,ei(o,e);var i,n,a=t.prototype;return a.registerListeners=function(){var r=this.hls;r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.on(p.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var r=this.hls;r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(p.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),r.off(p.Events.ERROR,this.onError,this)},a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,d.prototype.destroy.call(this)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},a.onManifestParsed=function(r,s){this.tracks=s.audioTracks||[]},a.onAudioTrackLoaded=function(r,s){var l=s.id,u=s.details,c=this.tracksInGroup[l];if(c){var v=c.details;c.details=s.details,this.log("audioTrack "+l+" loaded ["+u.startSN+"-"+u.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,v))}else this.warn("Invalid audio track id "+l)},a.onLevelLoading=function(r,s){this.switchLevel(s.level)},a.onLevelSwitching=function(r,s){this.switchLevel(s.level)},a.switchLevel=function(r){var s=this.hls.levels[r];if(s!=null&&s.audioGroupIds){var l=s.audioGroupIds[s.urlId];if(this.groupId!==l){this.groupId=l;var u=this.tracks.filter(function(v){return!l||v.groupId===l});this.selectDefaultTrack&&!u.some(function(v){return v.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=u;var c={audioTracks:u};this.log("Updating audio tracks, "+u.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(p.Events.AUDIO_TRACKS_UPDATED,c),this.selectInitialTrack()}}},a.onError=function(r,s){d.prototype.onError.call(this,r,s),!s.fatal&&s.context&&s.context.type===pe.PlaylistContextType.AUDIO_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.setAudioTrack=function(r){var s=this.tracksInGroup;if(r<0||r>=s.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var l=s[this.trackId];this.log("Now switching to audio-track index "+r);var u=s[r],c=u.id,v=u.groupId,m=v===void 0?"":v,_=u.name,S=u.type,P=u.url;if(this.trackId=r,this.trackName=_,this.selectDefaultTrack=!1,this.hls.trigger(p.Events.AUDIO_TRACK_SWITCHING,{id:c,groupId:m,name:_,type:S,url:P}),!u.details||u.details.live){var I=this.switchParams(u.url,l==null?void 0:l.details);this.loadPlaylist(I)}}},a.selectInitialTrack=function(){this.tracksInGroup;var r=this.trackName,s=this.findTrackId(r)||this.findTrackId();s!==-1?this.setAudioTrack(s):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},a.findTrackId=function(r){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var u=s[l];if((!this.selectDefaultTrack||u.default)&&(!r||r===u.name))return u.id}return-1},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,u=s.groupId,c=s.url;if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("loading audio-track playlist for id: "+l),this.clearTimer(),this.hls.trigger(p.Events.AUDIO_TRACK_LOADING,{url:c,id:l,groupId:u,deliveryDirectives:r||null})}},i=t,(n=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1,this.setAudioTrack(r)}}])&&an(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(we);function Sn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Oi(d,o){return Oi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Oi(d,o)}var An=function(d){var o,e;function t(r,s,l){var u;return(u=d.call(this,r,s,l,"[subtitle-stream-controller]")||this).levels=[],u.currentTrackId=-1,u.tracksBuffered=[],u.mainDetails=null,u._registerListeners(),u}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Oi(o,e);var i,n,a=t.prototype;return a.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},a._registerListeners=function(){var r=this.hls;r.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(p.Events.ERROR,this.onError,this),r.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.on(p.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.on(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(p.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.on(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a._unregisterListeners=function(){var r=this.hls;r.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(p.Events.ERROR,this.onError,this),r.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),r.off(p.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),r.off(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(p.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),r.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),r.off(p.Events.FRAG_BUFFERED,this.onFragBuffered,this)},a.startLoad=function(r){this.stopLoad(),this.state=Et,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()},a.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},a.onLevelLoaded=function(r,s){this.mainDetails=s.details},a.onSubtitleFragProcessed=function(r,s){var l=s.frag,u=s.success;if(this.fragPrevious=l,this.state=Et,u){var c=this.tracksBuffered[this.currentTrackId];if(c){for(var v,m=l.start,_=0;_<c.length;_++)if(m>=c[_].start&&m<=c[_].end){v=c[_];break}var S=l.start+l.duration;v?v.end=S:(v={start:m,end:S},c.push(v)),this.fragmentTracker.fragBuffered(l)}}},a.onBufferFlushing=function(r,s){var l=s.startOffset,u=s.endOffset;if(l===0&&u!==Number.POSITIVE_INFINITY){var c=this.currentTrackId,v=this.levels;if(!v.length||!v[c]||!v[c].details)return;var m=u-v[c].details.targetduration;if(m<=0)return;s.endOffsetSubtitles=Math.max(0,m),this.tracksBuffered.forEach(function(_){for(var S=0;S<_.length;)if(_[S].end<=m)_.shift();else{if(!(_[S].start<m))break;_[S].start=m,S++}}),this.fragmentTracker.removeFragmentsInRange(l,m,pe.PlaylistLevelType.SUBTITLE)}},a.onFragBuffered=function(r,s){var l;this.loadedmetadata||s.frag.type!==pe.PlaylistLevelType.MAIN||(l=this.media)!==null&&l!==void 0&&l.buffered.length&&(this.loadedmetadata=!0)},a.onError=function(r,s){var l=s.frag;l&&l.type===pe.PlaylistLevelType.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state=Et)},a.onSubtitleTracksUpdated=function(r,s){var l=this,u=s.subtitleTracks;this.tracksBuffered=[],this.levels=u.map(function(c){return new F(c)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(c){l.tracksBuffered[c.id]=[]}),this.mediaBuffer=null},a.onSubtitleTrackSwitch=function(r,s){if(this.currentTrackId=s.id,this.levels.length&&this.currentTrackId!==-1){var l=this.levels[this.currentTrackId];l!=null&&l.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,l&&this.setInterval(500)}else this.clearInterval()},a.onSubtitleTrackLoaded=function(r,s){var l,u=s.details,c=s.id,v=this.currentTrackId,m=this.levels;if(m.length){var _=m[v];if(!(c>=m.length||c!==v)&&_){this.mediaBuffer=this.mediaBufferTimeRanges;var S=0;if(u.live||(l=_.details)!==null&&l!==void 0&&l.live){var P=this.mainDetails;if(u.deltaUpdateFailed||!P)return;var I=P.fragments[0];_.details?(S=this.alignPlaylists(u,_.details))===0&&I&&ge(u,S=I.start):u.hasProgramDateTime&&P.hasProgramDateTime?(Qi(u,P),S=u.fragments[0].start):I&&ge(u,S=I.start)}_.details=u,this.levelLastLoaded=c,this.startFragRequested||!this.mainDetails&&u.live||this.setStartPosition(_.details,S),this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===Et&&(li(null,u.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),_.details=void 0))}}},a._handleFragmentLoadComplete=function(r){var s=this,l=r.frag,u=r.payload,c=l.decryptdata,v=this.hls;if(!this.fragContextChanged(l)&&u&&u.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){var m=performance.now();this.decrypter.decrypt(new Uint8Array(u),c.key.buffer,c.iv.buffer).then(function(_){var S=performance.now();v.trigger(p.Events.FRAG_DECRYPTED,{frag:l,payload:_,stats:{tstart:m,tdecrypt:S}})}).catch(function(_){s.warn(_.name+": "+_.message),s.state=Et})}},a.doTick=function(){if(this.media){if(this.state===Et){var r=this.currentTrackId,s=this.levels;if(!s.length||!s[r]||!s[r].details)return;var l=s[r].details,u=l.targetduration,c=this.config,v=this.getLoadPosition(),m=Mt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],v-u,c.maxBufferHole),_=m.end,S=m.len,P=this.getFwdBufferInfo(this.media,pe.PlaylistLevelType.MAIN);if(S>this.getMaxBufferLength(P==null?void 0:P.len)+u)return;var I=l.fragments,q=I.length,se=l.edge,Ee=null,he=this.fragPrevious;if(_<se){var Ae=c.maxFragLookUpTolerance;!(Ee=li(he,I,Math.max(I[0].start,_),Ae))&&he&&he.start<I[0].start&&(Ee=I[0])}else Ee=I[q-1];if(!Ee)return;Ee=this.mapToInitFragWhenRequired(Ee),this.fragmentTracker.getState(Ee)===Ue.NOT_LOADED&&this.loadFragment(Ee,l,_)}}else this.state=Et},a.getMaxBufferLength=function(r){var s=d.prototype.getMaxBufferLength.call(this);return r?Math.max(s,r):s},a.loadFragment=function(r,s,l){this.fragCurrent=r,r.sn==="initSegment"?this._loadInitSegment(r,s):(this.startFragRequested=!0,d.prototype.loadFragment.call(this,r,s,l))},i=t,(n=[{key:"mediaBufferTimeRanges",get:function(){return new kn(this.tracksBuffered[this.currentTrackId]||[])}}])&&Sn(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(ci),kn=function(d){this.buffered=void 0;var o=function(e,t,i){if((t>>>=0)>i-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+t+") is greater than the maximum bound ("+i+")");return d[t][e]};this.buffered={get length(){return d.length},end:function(e){return o("end",e,d.length)},start:function(e){return o("start",e,d.length)}}};function wn(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function Pi(d,o){return Pi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Pi(d,o)}function xi(d){for(var o=[],e=0;e<d.length;e++){var t=d[e];t.kind==="subtitles"&&t.label&&o.push(d[e])}return o}let Dn=function(d){var o,e;function t(r){var s;return(s=d.call(this,r,"[subtitle-track-controller]")||this).media=null,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.selectDefaultTrack=!0,s.queuedDefaultTrack=-1,s.trackChangeListener=function(){return s.onTextTracksChanged()},s.asyncPollTrackChange=function(){return s.pollTrackChange(0)},s.useTextTrackPolling=!1,s.subtitlePollingInterval=-1,s._subtitleDisplay=!0,s.registerListeners(),s}e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Pi(o,e);var i,n,a=t.prototype;return a.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,d.prototype.destroy.call(this)},a.registerListeners=function(){var r=this.hls;r.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.on(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.on(p.Events.ERROR,this.onError,this)},a.unregisterListeners=function(){var r=this.hls;r.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),r.off(p.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),r.off(p.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),r.off(p.Events.ERROR,this.onError,this)},a.onMediaAttached=function(r,s){this.media=s.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},a.pollTrackChange=function(r){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,r)},a.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),xi(this.media.textTracks).forEach(function(r){ht(r)}),this.subtitleTrack=-1,this.media=null)},a.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},a.onManifestParsed=function(r,s){this.tracks=s.subtitleTracks},a.onSubtitleTrackLoaded=function(r,s){var l=s.id,u=s.details,c=this.trackId,v=this.tracksInGroup[c];if(v){var m=v.details;v.details=s.details,this.log("subtitle track "+l+" loaded ["+u.startSN+"-"+u.endSN+"]"),l===this.trackId&&(this.retryCount=0,this.playlistLoaded(l,s,m))}else this.warn("Invalid subtitle track id "+l)},a.onLevelLoading=function(r,s){this.switchLevel(s.level)},a.onLevelSwitching=function(r,s){this.switchLevel(s.level)},a.switchLevel=function(r){var s=this.hls.levels[r];if(s!=null&&s.textGroupIds){var l=s.textGroupIds[s.urlId];if(this.groupId!==l){var u=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,c=this.tracks.filter(function(_){return!l||_.groupId===l});this.tracksInGroup=c;var v=this.findTrackId(u==null?void 0:u.name)||this.findTrackId();this.groupId=l;var m={subtitleTracks:c};this.log("Updating subtitle tracks, "+c.length+' track(s) found in "'+l+'" group-id'),this.hls.trigger(p.Events.SUBTITLE_TRACKS_UPDATED,m),v!==-1&&this.setSubtitleTrack(v,u)}}},a.findTrackId=function(r){for(var s=this.tracksInGroup,l=0;l<s.length;l++){var u=s[l];if((!this.selectDefaultTrack||u.default)&&(!r||r===u.name))return u.id}return-1},a.onError=function(r,s){d.prototype.onError.call(this,r,s),!s.fatal&&s.context&&s.context.type===pe.PlaylistContextType.SUBTITLE_TRACK&&s.context.id===this.trackId&&s.context.groupId===this.groupId&&this.retryLoadingOrFail(s)},a.loadPlaylist=function(r){d.prototype.loadPlaylist.call(this);var s=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(s)){var l=s.id,u=s.groupId,c=s.url;if(r)try{c=r.addDirectives(c)}catch(v){this.warn("Could not construct new URL with HLS Delivery Directives: "+v)}this.log("Loading subtitle playlist for id "+l),this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADING,{url:c,id:l,groupId:u,deliveryDirectives:r||null})}},a.toggleTrackModes=function(r){var s=this,l=this.media,u=this.trackId;if(l){var c=xi(l.textTracks),v=c.filter(function(S){return S.groupId===s.groupId});if(r===-1)[].slice.call(c).forEach(function(S){S.mode="disabled"});else{var m=v[u];m&&(m.mode="disabled")}var _=v[r];_&&(_.mode=this.subtitleDisplay?"showing":"hidden")}},a.setSubtitleTrack=function(r,s){var l,u=this.tracksInGroup;if(this.media){if(this.trackId!==r&&this.toggleTrackModes(r),!(this.trackId===r&&(r===-1||(l=u[r])!==null&&l!==void 0&&l.details)||r<-1||r>=u.length)){this.clearTimer();var c=u[r];if(this.log("Switching to subtitle track "+r),this.trackId=r,c){var v=c.id,m=c.groupId,_=m===void 0?"":m,S=c.name,P=c.type,I=c.url;this.hls.trigger(p.Events.SUBTITLE_TRACK_SWITCH,{id:v,groupId:_,name:S,type:P,url:I});var q=this.switchParams(c.url,s==null?void 0:s.details);this.loadPlaylist(q)}else this.hls.trigger(p.Events.SUBTITLE_TRACK_SWITCH,{id:r})}}else this.queuedDefaultTrack=r},a.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var r=-1,s=xi(this.media.textTracks),l=0;l<s.length;l++)if(s[l].mode==="hidden")r=l;else if(s[l].mode==="showing"){r=l;break}this.subtitleTrack!==r&&(this.subtitleTrack=r)}},i=t,(n=[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(r){this._subtitleDisplay=r,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(r){this.selectDefaultTrack=!1;var s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(r,s)}}])&&wn(i.prototype,n),Object.defineProperty(i,"prototype",{writable:!1}),t}(we);var gt,hr=function(){function d(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var o=d.prototype;return o.append=function(e,t){var i=this.queues[t];i.push(e),i.length===1&&this.buffers[t]&&this.executeNext(t)},o.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},o.appendBlocker=function(e){var t,i=new Promise(function(a){t=a}),n={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(n,e),i},o.executeNext=function(e){var t=this.buffers,i=this.queues,n=t[e],a=i[e];if(a.length){var r=a[0];try{r.execute()}catch(s){k.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),r.onError(s),n&&n.updating||(a.shift(),this.executeNext(e))}}},o.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},o.current=function(e){return this.queues[e][0]},d}(),Yr=hi(),sn=/([ha]vc.)(?:\.[^.,]+)+/,Ln=function(){function d(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var i=t.hls,n=t.media,a=t.mediaSource;k.logger.log("[buffer-controller]: Media source opened"),n&&(t.updateMediaElementDuration(),i.trigger(p.Events.MEDIA_ATTACHED,{media:n})),a&&a.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){k.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){k.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var o=d.prototype;return o.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},o.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},o.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.Events.BUFFER_RESET,this.onBufferReset,this),e.on(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.Events.BUFFER_EOS,this.onBufferEos,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.Events.FRAG_PARSED,this.onFragParsed,this),e.on(p.Events.FRAG_CHANGED,this.onFragChanged,this)},o.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.Events.BUFFER_RESET,this.onBufferReset,this),e.off(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.Events.BUFFER_EOS,this.onBufferEos,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.Events.FRAG_PARSED,this.onFragParsed,this),e.off(p.Events.FRAG_CHANGED,this.onFragChanged,this)},o._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new hr(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},o.onManifestParsed=function(e,t){var i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.details=null,k.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},o.onMediaAttaching=function(e,t){var i=this.media=t.media;if(i&&Yr){var n=this.mediaSource=new Yr;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(n),this._objectUrl=i.src}},o.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,i=this._objectUrl;if(t){if(k.logger.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(n){k.logger.warn("[buffer-controller]: onMediaDetaching: "+n.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):k.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.Events.MEDIA_DETACHED,void 0)},o.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(t){var i=e.sourceBuffer[t];try{i&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(i),e.sourceBuffer[t]=void 0)}catch(n){k.logger.warn("[buffer-controller]: Failed to reset the "+t+" buffer",n)}}),this._initSourceBuffer()},o.onBufferCodecs=function(e,t){var i=this,n=this.getSourceBufferTypes().length;Object.keys(t).forEach(function(a){if(n){var r=i.tracks[a];if(r&&typeof r.buffer.changeType=="function"){var s=t[a],l=s.id,u=s.codec,c=s.levelCodec,v=s.container,m=s.metadata,_=(r.levelCodec||r.codec).replace(sn,"$1"),S=(c||u).replace(sn,"$1");if(_!==S){var P=v+";codecs="+(c||u);i.appendChangeType(a,P),k.logger.log("[buffer-controller]: switching codec "+_+" to "+S),i.tracks[a]={buffer:r.buffer,codec:u,container:v,levelCodec:c,metadata:m,id:l}}}}else i.pendingTracks[a]=t[a]}),n||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},o.appendChangeType=function(e,t){var i=this,n=this.operationQueue,a={execute:function(){var r=i.sourceBuffer[e];r&&(k.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),r.changeType(t)),n.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(r){k.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",r)}};n.append(a,e)},o.onBufferAppending=function(e,t){var i=this,n=this.hls,a=this.operationQueue,r=this.tracks,s=t.data,l=t.type,u=t.frag,c=t.part,v=t.chunkMeta,m=v.buffering[l],_=self.performance.now();m.start=_;var S=u.stats.buffering,P=c?c.stats.buffering:null;S.start===0&&(S.start=_),P&&P.start===0&&(P.start=_);var I=r.audio,q=!1;l==="audio"&&(I==null?void 0:I.container)==="audio/mpeg"&&(q=!this.lastMpegAudioChunk||v.id===1||this.lastMpegAudioChunk.sn!==v.sn,this.lastMpegAudioChunk=v);var se=u.start,Ee={execute:function(){if(m.executeStart=self.performance.now(),q){var he=i.sourceBuffer[l];if(he){var Ae=se-he.timestampOffset;Math.abs(Ae)>=.1&&(k.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+se+" (delta: "+Ae+") sn: "+u.sn+")"),he.timestampOffset=se)}}i.appendExecutor(s,l)},onStart:function(){},onComplete:function(){var he=self.performance.now();m.executeEnd=m.end=he,S.first===0&&(S.first=he),P&&P.first===0&&(P.first=he);var Ae=i.sourceBuffer,He={};for(var ze in Ae)He[ze]=Mt.getBuffered(Ae[ze]);i.appendError=0,i.hls.trigger(p.Events.BUFFER_APPENDED,{type:l,frag:u,part:c,chunkMeta:v,parent:u.type,timeRanges:He})},onError:function(he){k.logger.error("[buffer-controller]: Error encountered while trying to append to the "+l+" SourceBuffer",he);var Ae={type:w.ErrorTypes.MEDIA_ERROR,parent:u.type,details:w.ErrorDetails.BUFFER_APPEND_ERROR,err:he,fatal:!1};he.code===DOMException.QUOTA_EXCEEDED_ERR?Ae.details=w.ErrorDetails.BUFFER_FULL_ERROR:(i.appendError++,Ae.details=w.ErrorDetails.BUFFER_APPEND_ERROR,i.appendError>n.config.appendErrorMaxRetry&&(k.logger.error("[buffer-controller]: Failed "+n.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),Ae.fatal=!0,n.stopLoad())),n.trigger(p.Events.ERROR,Ae)}};a.append(Ee,l)},o.onBufferFlushing=function(e,t){var i=this,n=this.operationQueue,a=function(r){return{execute:i.removeExecutor.bind(i,r,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){i.hls.trigger(p.Events.BUFFER_FLUSHED,{type:r})},onError:function(s){k.logger.warn("[buffer-controller]: Failed to remove from "+r+" SourceBuffer",s)}}};t.type?n.append(a(t.type),t.type):this.getSourceBufferTypes().forEach(function(r){n.append(a(r),r)})},o.onFragParsed=function(e,t){var i=this,n=t.frag,a=t.part,r=[],s=a?a.elementaryStreams:n.elementaryStreams;s[$.ElementaryStreamTypes.AUDIOVIDEO]?r.push("audiovideo"):(s[$.ElementaryStreamTypes.AUDIO]&&r.push("audio"),s[$.ElementaryStreamTypes.VIDEO]&&r.push("video")),r.length===0&&k.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+n.type+" level: "+n.level+" sn: "+n.sn),this.blockBuffers(function(){var l=self.performance.now();n.stats.buffering.end=l,a&&(a.stats.buffering.end=l);var u=a?a.stats:n.stats;i.hls.trigger(p.Events.FRAG_BUFFERED,{frag:n,part:a,stats:u,id:n.type})},r)},o.onFragChanged=function(e,t){this.flushBackBuffer()},o.onBufferEos=function(e,t){var i=this;this.getSourceBufferTypes().reduce(function(n,a){var r=i.sourceBuffer[a];return!r||t.type&&t.type!==a||(r.ending=!0,r.ended||(r.ended=!0,k.logger.log("[buffer-controller]: "+a+" sourceBuffer now EOS"))),n&&!(r&&!r.ended)},!0)&&(k.logger.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(function(){i.getSourceBufferTypes().forEach(function(a){var r=i.sourceBuffer[a];r&&(r.ending=!1)});var n=i.mediaSource;n&&n.readyState==="open"?(k.logger.log("[buffer-controller]: Calling mediaSource.endOfStream()"),n.endOfStream()):n&&k.logger.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+n.readyState)}))},o.onLevelUpdated=function(e,t){var i=t.details;i.fragments.length&&(this.details=i,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},o.flushBackBuffer=function(){var e=this.hls,t=this.details,i=this.media,n=this.sourceBuffer;if(i&&t!==null){var a=this.getSourceBufferTypes();if(a.length){var r=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if((0,R.isFiniteNumber)(r)&&!(r<0)){var s=i.currentTime,l=t.levelTargetDuration,u=Math.max(r,l),c=Math.floor(s/l)*l-u;a.forEach(function(v){var m=n[v];if(m){var _=Mt.getBuffered(m);if(_.length>0&&c>_.start(0)){if(e.trigger(p.Events.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(p.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(m.ended&&_.end(_.length-1)-s<2*l)return void k.logger.info("[buffer-controller]: Cannot flush "+v+" back buffer while SourceBuffer is in ended state");e.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:v})}}})}}}},o.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&this.mediaSource.readyState==="open"){var e=this.details,t=this.hls,i=this.media,n=this.mediaSource,a=e.fragments[0].start+e.totalduration,r=i.duration,s=(0,R.isFiniteNumber)(n.duration)?n.duration:0;e.live&&t.config.liveDurationInfinity?(k.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(a>s&&a>r||!(0,R.isFiniteNumber)(r))&&(k.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),n.duration=a)}},o.updateSeekableRange=function(e){var t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){var n=Math.max(0,i[0].start),a=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,a)}},o.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,i=this.pendingTracks,n=Object.keys(i).length;if(n&&!e||n===2){this.createSourceBuffers(i),this.pendingTracks={};var a=this.getSourceBufferTypes();if(a.length===0)return void this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});a.forEach(function(r){t.executeNext(r)})}},o.createSourceBuffers=function(e){var t=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var n=0;for(var a in e)if(!t[a]){var r=e[a];if(!r)throw Error("source buffer exists for track "+a+", however track does not");var s=r.levelCodec||r.codec,l=r.container+";codecs="+s;k.logger.log("[buffer-controller]: creating sourceBuffer("+l+")");try{var u=t[a]=i.addSourceBuffer(l),c=a;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[a]={buffer:u,codec:s,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id},n++}catch(v){k.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+v.message),this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:v,mimeType:l})}}n&&this.hls.trigger(p.Events.BUFFER_CREATED,{tracks:this.tracks})},o._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},o._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},o._onSBUpdateError=function(e,t){k.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.MEDIA_ERROR,details:w.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var i=this.operationQueue.current(e);i&&i.onError(t)},o.removeExecutor=function(e,t,i){var n=this.media,a=this.mediaSource,r=this.operationQueue,s=this.sourceBuffer[e];if(!n||!a||!s)return k.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);var l=(0,R.isFiniteNumber)(n.duration)?n.duration:1/0,u=(0,R.isFiniteNumber)(a.duration)?a.duration:1/0,c=Math.max(0,t),v=Math.min(i,l,u);v>c&&!s.ending?(s.ended=!1,k.logger.log("[buffer-controller]: Removing ["+c+","+v+"] from the "+e+" SourceBuffer"),s.remove(c,v)):r.shiftAndExecuteNext(e)},o.appendExecutor=function(e,t){var i=this.operationQueue,n=this.sourceBuffer[t];if(!n)return k.logger.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void i.shiftAndExecuteNext(t);n.ended=!1,n.appendBuffer(e)},o.blockBuffers=function(e,t){var i=this;if(t===void 0&&(t=this.getSourceBufferTypes()),!t.length)return k.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var n=this.operationQueue,a=t.map(function(r){return n.appendBlocker(r)});Promise.all(a).then(function(){e(),t.forEach(function(r){var s=i.sourceBuffer[r];s&&s.updating||n.shiftAndExecuteNext(r)})})},o.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},o.addBufferListener=function(e,t,i){var n=this.sourceBuffer[e];if(n){var a=i.bind(this,e);this.listeners[e].push({event:t,listener:a}),n.addEventListener(t,a)}},o.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach(function(i){t.removeEventListener(i.event,i.listener)})},d}(),g={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},h=function(d){var o=d;return g.hasOwnProperty(d)&&(o=g[d]),String.fromCharCode(o)},f=15,y=100,b={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},O={17:2,18:4,21:6,22:8,23:10,19:13,20:15},D={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},H={25:2,26:4,29:6,30:8,31:10,27:13,28:15},le=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];(function(d){d[d.ERROR=0]="ERROR",d[d.TEXT=1]="TEXT",d[d.WARNING=2]="WARNING",d[d.INFO=2]="INFO",d[d.DEBUG=3]="DEBUG",d[d.DATA=3]="DATA"})(gt||(gt={}));var Z=function(){function d(){this.time=null,this.verboseLevel=gt.ERROR}return d.prototype.log=function(o,e){if(this.verboseLevel>=o){var t=typeof e=="function"?e():e;k.logger.log(this.time+" ["+o+"] "+t)}},d}(),Ce=function(d){for(var o=[],e=0;e<d.length;e++)o.push(d[e].toString(16));return o},at=function(){function d(e,t,i,n,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=i||!1,this.background=n||"black",this.flash=a||!1}var o=d.prototype;return o.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},o.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}},o.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},o.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},o.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},o.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},d}(),Je=function(){function d(e,t,i,n,a,r){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new at(t,i,n,a,r)}var o=d.prototype;return o.reset=function(){this.uchar=" ",this.penState.reset()},o.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},o.setPenState=function(e){this.penState.copy(e)},o.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},o.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},o.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},d}(),it=function(){function d(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<y;t++)this.chars.push(new Je);this.logger=e,this.pos=0,this.currPenState=new at}var o=d.prototype;return o.equals=function(e){for(var t=!0,i=0;i<y;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t},o.copy=function(e){for(var t=0;t<y;t++)this.chars[t].copy(e.chars[t])},o.isEmpty=function(){for(var e=!0,t=0;t<y;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},o.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(gt.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>y&&(this.logger.log(gt.DEBUG,"Too large cursor position "+this.pos),this.pos=y)},o.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)},o.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},o.insertChar=function(e){var t=this;e>=144&&this.backSpace();var i=h(e);this.pos>=y?this.logger.log(gt.ERROR,function(){return"Cannot insert "+e.toString(16)+" ("+i+") at position "+t.pos+". Skipping it!"}):(this.chars[this.pos].setChar(i,this.currPenState),this.moveCursor(1))},o.clearFromPos=function(e){var t;for(t=e;t<y;t++)this.chars[t].reset()},o.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},o.clearToEndOfRow=function(){this.clearFromPos(this.pos)},o.getTextString=function(){for(var e=[],t=!0,i=0;i<y;i++){var n=this.chars[i].uchar;n!==" "&&(t=!1),e.push(n)}return t?"":e.join("")},o.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},d}(),Xe=function(){function d(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<f;t++)this.rows.push(new it(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var o=d.prototype;return o.reset=function(){for(var e=0;e<f;e++)this.rows[e].clear();this.currRow=14},o.equals=function(e){for(var t=!0,i=0;i<f;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t},o.copy=function(e){for(var t=0;t<f;t++)this.rows[t].copy(e.rows[t])},o.isEmpty=function(){for(var e=!0,t=0;t<f;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},o.backSpace=function(){this.rows[this.currRow].backSpace()},o.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},o.insertChar=function(e){this.rows[this.currRow].insertChar(e)},o.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},o.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},o.setCursor=function(e){this.logger.log(gt.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},o.setPAC=function(e){this.logger.log(gt.INFO,function(){return"pacData = "+JSON.stringify(e)});var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var i=0;i<f;i++)this.rows[i].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var r=a.rows[n].cueStartTime,s=this.logger.time;if(r&&s!==null&&r<s)for(var l=0;l<this.nrRollUpRows;l++)this.rows[t-this.nrRollUpRows+l+1].copy(a.rows[n+l])}}this.currRow=t;var u=this.rows[this.currRow];if(e.indent!==null){var c=e.indent,v=Math.max(c-1,0);u.setCursor(e.indent),e.color=u.chars[v].penState.foreground}var m={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(m)},o.setBkgData=function(e){this.logger.log(gt.INFO,function(){return"bkgData = "+JSON.stringify(e)}),this.backSpace(),this.setPen(e),this.insertChar(32)},o.setRollUpRows=function(e){this.nrRollUpRows=e},o.rollUp=function(){var e=this;if(this.nrRollUpRows!==null){this.logger.log(gt.TEXT,function(){return e.getDisplayText()});var t=this.currRow+1-this.nrRollUpRows,i=this.rows.splice(t,1)[0];i.clear(),this.rows.splice(this.currRow,0,i),this.logger.log(gt.INFO,"Rolling up")}else this.logger.log(gt.DEBUG,"roll_up but nrRollUpRows not set yet")},o.getDisplayText=function(e){e=e||!1;for(var t=[],i="",n=-1,a=0;a<f;a++){var r=this.rows[a].getTextString();r&&(n=a+1,e?t.push("Row "+n+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join(`
|
|
20
|
+
`)),i},o.getTextAndFormat=function(){return this.rows},d}(),nt=function(){function d(e,t,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Xe(i),this.nonDisplayedMemory=new Xe(i),this.lastOutputScreen=new Xe(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}var o=d.prototype;return o.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},o.getHandler=function(){return this.outputFilter},o.setHandler=function(e){this.outputFilter=e},o.setPAC=function(e){this.writeScreen.setPAC(e)},o.setBkgData=function(e){this.writeScreen.setBkgData(e)},o.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(gt.INFO,function(){return"MODE="+e}),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},o.insertChars=function(e){for(var t=this,i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);var n=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(gt.INFO,function(){return n+": "+t.writeScreen.getDisplayText(!0)}),this.mode!=="MODE_PAINT-ON"&&this.mode!=="MODE_ROLL-UP"||(this.logger.log(gt.TEXT,function(){return"DISPLAYED: "+t.displayedMemory.getDisplayText(!0)}),this.outputDataUpdate())},o.ccRCL=function(){this.logger.log(gt.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},o.ccBS=function(){this.logger.log(gt.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},o.ccAOF=function(){},o.ccAON=function(){},o.ccDER=function(){this.logger.log(gt.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},o.ccRU=function(e){this.logger.log(gt.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},o.ccFON=function(){this.logger.log(gt.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},o.ccRDC=function(){this.logger.log(gt.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},o.ccTR=function(){this.logger.log(gt.INFO,"TR"),this.setMode("MODE_TEXT")},o.ccRTD=function(){this.logger.log(gt.INFO,"RTD"),this.setMode("MODE_TEXT")},o.ccEDM=function(){this.logger.log(gt.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},o.ccCR=function(){this.logger.log(gt.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},o.ccENM=function(){this.logger.log(gt.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},o.ccEOC=function(){var e=this;if(this.logger.log(gt.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(gt.TEXT,function(){return"DISP: "+e.displayedMemory.getDisplayText()})}this.outputDataUpdate(!0)},o.ccTO=function(e){this.logger.log(gt.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},o.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(gt.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},o.outputDataUpdate=function(e){e===void 0&&(e=!1);var t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime!==null||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},o.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},d}(),wt=function(){function d(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new Z;this.channels=[null,new nt(e,t,n),new nt(e+1,i,n)],this.cmdHistory={a:null,b:null},this.logger=n}var o=d.prototype;return o.getHandler=function(e){return this.channels[e].getHandler()},o.setHandler=function(e,t){this.channels[e].setHandler(t)},o.addData=function(e,t){var i,n,a,r=!1;this.logger.time=e;for(var s=0;s<t.length;s+=2)if(n=127&t[s],a=127&t[s+1],n!==0||a!==0){if(this.logger.log(gt.DATA,"["+Ce([t[s],t[s+1]])+"] -> ("+Ce([n,a])+")"),(i=this.parseCmd(n,a))||(i=this.parseMidrow(n,a)),i||(i=this.parsePAC(n,a)),i||(i=this.parseBackgroundAttributes(n,a)),!i&&(r=this.parseChars(n,a))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(r):this.logger.log(gt.WARNING,"No channel found yet. TEXT-MODE?")}i||r||this.logger.log(gt.WARNING,"Couldn't parse cleaned data "+Ce([n,a])+" orig: "+Ce([t[s],t[s+1]]))}},o.parseCmd=function(e,t){var i=this.cmdHistory;if(!((e===20||e===28||e===21||e===29)&&t>=32&&t<=47||(e===23||e===31)&&t>=33&&t<=35))return!1;if($t(e,t,i))return jt(null,null,i),this.logger.log(gt.DEBUG,"Repeated command ("+Ce([e,t])+") is dropped"),!0;var n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),jt(e,t,i),this.currentChannel=n,!0},o.parseMidrow=function(e,t){var i=0;if((e===17||e===25)&&t>=32&&t<=47){if((i=e===17?1:2)!==this.currentChannel)return this.logger.log(gt.ERROR,"Mismatch channel in midrow parsing"),!1;var n=this.channels[i];return!!n&&(n.ccMIDROW(t),this.logger.log(gt.DEBUG,"MIDROW ("+Ce([e,t])+")"),!0)}return!1},o.parsePAC=function(e,t){var i,n=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(e===16||e===24)&&t>=64&&t<=95))return!1;if($t(e,t,n))return jt(null,null,n),!0;var a=e<=23?1:2;i=t>=64&&t<=95?a===1?b[e]:D[e]:a===1?O[e]:H[e];var r=this.channels[a];return!!r&&(r.setPAC(this.interpretPAC(i,t)),jt(e,t,n),this.currentChannel=a,!0)},o.interpretPAC=function(e,t){var i,n={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,n.underline=(1&i)==1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n},o.parseChars=function(e,t){var i,n,a=null,r=null;if(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19?(n=r===17?t+80:r===18?t+112:t+144,this.logger.log(gt.INFO,"Special char '"+h(n)+"' in channel "+i),a=[n]):e>=32&&e<=127&&(a=t===0?[e]:[e,t]),a){var s=Ce(a);this.logger.log(gt.DEBUG,"Char codes = "+s.join(",")),jt(e,t,this.cmdHistory)}return a},o.parseBackgroundAttributes=function(e,t){var i;if(!((e===16||e===24)&&t>=32&&t<=47||(e===23||e===31)&&t>=45&&t<=47))return!1;var n={};e===16||e===24?(i=Math.floor((t-32)/2),n.background=le[i],t%2==1&&(n.background=n.background+"_semi")):t===45?n.background="transparent":(n.foreground="black",t===47&&(n.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(n),jt(e,t,this.cmdHistory),!0},o.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},o.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}},d}();function jt(d,o,e){e.a=d,e.b=o}function $t(d,o,e){return e.a===d&&e.b===o}let nr=wt;var mt=function(){function d(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}var o=d.prototype;return o.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},o.newCue=function(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)},o.reset=function(){this.cueRanges=[],this.startTime=null},d}();let Xt=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var d=["","lr","rl"],o=["start","middle","end","left","right"];function e(a,r){if(typeof r!="string"||!Array.isArray(a))return!1;var s=r.toLowerCase();return!!~a.indexOf(s)&&s}function t(a){return e(o,a)}function i(a){for(var r=arguments.length,s=new Array(r>1?r-1:0),l=1;l<r;l++)s[l-1]=arguments[l];for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var v in c)a[v]=c[v]}return a}function n(a,r,s){var l=this,u={enumerable:!0};l.hasBeenReset=!1;var c="",v=!1,m=a,_=r,S=s,P=null,I="",q=!0,se="auto",Ee="start",he=50,Ae="middle",He=50,ze="middle";Object.defineProperty(l,"id",i({},u,{get:function(){return c},set:function(be){c=""+be}})),Object.defineProperty(l,"pauseOnExit",i({},u,{get:function(){return v},set:function(be){v=!!be}})),Object.defineProperty(l,"startTime",i({},u,{get:function(){return m},set:function(be){if(typeof be!="number")throw new TypeError("Start time must be set to a number.");m=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"endTime",i({},u,{get:function(){return _},set:function(be){if(typeof be!="number")throw new TypeError("End time must be set to a number.");_=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"text",i({},u,{get:function(){return S},set:function(be){S=""+be,this.hasBeenReset=!0}})),Object.defineProperty(l,"region",i({},u,{get:function(){return P},set:function(be){P=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"vertical",i({},u,{get:function(){return I},set:function(be){var Ge=function(Me){return e(d,Me)}(be);if(Ge===!1)throw new SyntaxError("An invalid or illegal string was specified.");I=Ge,this.hasBeenReset=!0}})),Object.defineProperty(l,"snapToLines",i({},u,{get:function(){return q},set:function(be){q=!!be,this.hasBeenReset=!0}})),Object.defineProperty(l,"line",i({},u,{get:function(){return se},set:function(be){if(typeof be!="number"&&be!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");se=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"lineAlign",i({},u,{get:function(){return Ee},set:function(be){var Ge=t(be);if(!Ge)throw new SyntaxError("An invalid or illegal string was specified.");Ee=Ge,this.hasBeenReset=!0}})),Object.defineProperty(l,"position",i({},u,{get:function(){return he},set:function(be){if(be<0||be>100)throw new Error("Position must be between 0 and 100.");he=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"positionAlign",i({},u,{get:function(){return Ae},set:function(be){var Ge=t(be);if(!Ge)throw new SyntaxError("An invalid or illegal string was specified.");Ae=Ge,this.hasBeenReset=!0}})),Object.defineProperty(l,"size",i({},u,{get:function(){return He},set:function(be){if(be<0||be>100)throw new Error("Size must be between 0 and 100.");He=be,this.hasBeenReset=!0}})),Object.defineProperty(l,"align",i({},u,{get:function(){return ze},set:function(be){var Ge=t(be);if(!Ge)throw new SyntaxError("An invalid or illegal string was specified.");ze=Ge,this.hasBeenReset=!0}})),l.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}();var tr=function(){function d(){}return d.prototype.decode=function(o,e){if(!o)return"";if(typeof o!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(o))},d}();function _t(d){function o(t,i,n,a){return 3600*(0|t)+60*(0|i)+(0|n)+parseFloat(a||0)}var e=d.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?o(e[2],e[3],0,e[4]):o(e[1],e[2],e[3],e[4]):null}var et=function(){function d(){this.values=Object.create(null)}var o=d.prototype;return o.set=function(e,t){this.get(e)||t===""||(this.values[e]=t)},o.get=function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},o.has=function(e){return e in this.values},o.alt=function(e,t,i){for(var n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}},o.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},o.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1},d}();function dt(d,o,e,t){var i=t?d.split(t):[d];for(var n in i)if(typeof i[n]=="string"){var a=i[n].split(e);a.length===2&&o(a[0],a[1])}}var $e=new Xt(0,0,""),lt=$e.align==="middle"?"middle":"center";function Gt(d,o,e){var t=d;function i(){var a=_t(d);if(a===null)throw new Error("Malformed timestamp: "+t);return d=d.replace(/^[^\sa-zA-Z-]+/,""),a}function n(){d=d.replace(/^\s+/,"")}if(n(),o.startTime=i(),n(),d.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+t);d=d.slice(3),n(),o.endTime=i(),n(),function(a,r){var s=new et;dt(a,function(c,v){var m;switch(c){case"region":for(var _=e.length-1;_>=0;_--)if(e[_].id===v){s.set(c,e[_].region);break}break;case"vertical":s.alt(c,v,["rl","lr"]);break;case"line":m=v.split(","),s.integer(c,m[0]),s.percent(c,m[0])&&s.set("snapToLines",!1),s.alt(c,m[0],["auto"]),m.length===2&&s.alt("lineAlign",m[1],["start",lt,"end"]);break;case"position":m=v.split(","),s.percent(c,m[0]),m.length===2&&s.alt("positionAlign",m[1],["start",lt,"end","line-left","line-right","auto"]);break;case"size":s.percent(c,v);break;case"align":s.alt(c,v,["start",lt,"end","left","right"])}},/:/,/\s/),r.region=s.get("region",null),r.vertical=s.get("vertical","");var l=s.get("line","auto");l==="auto"&&$e.line===-1&&(l=-1),r.line=l,r.lineAlign=s.get("lineAlign","start"),r.snapToLines=s.get("snapToLines",!0),r.size=s.get("size",100),r.align=s.get("align",lt);var u=s.get("position","auto");u==="auto"&&$e.position===50&&(u=r.align==="start"||r.align==="left"?0:r.align==="end"||r.align==="right"?100:50),r.position=u}(d,o)}function qt(d){return d.replace(/<br(?: \/)?>/gi,`
|
|
21
|
+
`)}var ar=function(){function d(){this.state="INITIAL",this.buffer="",this.decoder=new tr,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=qt(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)?dt(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 Xt(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Gt(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}(),rr=N(673),fr=N(524),sr=/\r\n|\n\r|\n|\r/g,vr=function(d,o,e){return e===void 0&&(e=0),d.slice(e,e+o.length)===o},Vt=function(d){for(var o=5381,e=d.length;e;)o=33*o^d.charCodeAt(--e);return(o>>>0).toString()};function or(d,o,e){return Vt(d.toString())+Vt(o.toString())+Vt(e)}function ti(){return ti=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},ti.apply(this,arguments)}var gr="stpp.ttml.im1t",Wr=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,on=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Ja={left:"start",center:"center",right:"end",start:"start",end:"end"};function ia(d,o,e,t,i){var n=(0,J.findBox)(new Uint8Array(d),["mdat"]);if(n.length!==0){var a=n.map(function(s){return(0,Lt.utf8ArrayToStr)(s)}),r=(0,rr.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(q,se){return q[se]=c.getAttribute("ttp:"+se)||v[se],q},{}),_=c.getAttribute("xml:space")!=="preserve",S=na(Rn(c,"styling","style")),P=na(Rn(c,"layout","region")),I=Rn(c,"body","[begin]");return[].map.call(I,function(q){var se=aa(q,_);if(!se||!q.hasAttribute("begin"))return null;var Ee=Cn(q.getAttribute("begin"),m),he=Cn(q.getAttribute("dur"),m),Ae=Cn(q.getAttribute("end"),m);if(Ee===null)throw sa(q);if(Ae===null){if(he===null)throw sa(q);Ae=Ee+he}var He=new Xt(Ee-u,Ae-u,se);He.id=or(He.startTime,He.endTime,He.text);var ze=function(Me,ct,Ot){var ft="http://www.w3.org/ns/ttml#styling",Tt=null,Dt=Me!=null&&Me.hasAttribute("style")?Me.getAttribute("style"):null;return Dt&&Ot.hasOwnProperty(Dt)&&(Tt=Ot[Dt]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce(function(Zt,zt){var Kt=In(ct,ft,zt)||In(Me,ft,zt)||In(Tt,ft,zt);return Kt&&(Zt[zt]=Kt),Zt},{})}(P[q.getAttribute("region")],S[q.getAttribute("style")],S),be=ze.textAlign;if(be){var Ge=Ja[be];Ge&&(He.lineAlign=Ge),He.align=be}return ti(He,ze),He}).filter(function(q){return q!==null})}(s,r))})}catch(s){i(s)}}else i(new Error("Could not parse IMSC1 mdat"))}function Rn(d,o,e){var t=d.getElementsByTagName(o)[0];return t?[].slice.call(t.querySelectorAll(e)):[]}function na(d){return d.reduce(function(o,e){var t=e.getAttribute("xml:id");return t&&(o[t]=e),o},{})}function aa(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?aa(t,o):o?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}function In(d,o,e){return d&&d.hasAttributeNS(o,e)?d.getAttributeNS(o,e):null}function sa(d){return new Error("Could not parse ttml timestamp "+d)}function Cn(d,o){if(!d)return null;var e=_t(d);return e===null&&(Wr.test(d)?e=function(t,i){var n=Wr.exec(t),a=(0|n[4])+(0|n[5])/i.subFrameRate;return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+a/i.frameRate}(d,o):on.test(d)&&(e=function(t,i){var n=on.exec(t),a=Number(n[1]);switch(n[2]){case"h":return 3600*a;case"m":return 60*a;case"ms":return 1e3*a;case"f":return a/i.frameRate;case"t":return a/i.tickRate}return a}(d,o))),e}var $a=function(){function d(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var t=new mt(this,"textTrack1"),i=new mt(this,"textTrack2"),n=new mt(this,"textTrack3"),a=new mt(this,"textTrack4");this.cea608Parser1=new nr(1,t,i),this.cea608Parser2=new nr(3,n,a)}e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.Events.FRAG_LOADING,this.onFragLoading,this),e.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=d.prototype;return o.destroy=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.Events.FRAG_LOADING,this.onFragLoading,this),e.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(e,t,i,n,a){for(var r,s,l,u,c=!1,v=a.length;v--;){var m=a[v],_=(r=m[0],s=m[1],l=t,u=i,Math.min(s,u)-Math.max(r,l));if(_>=0&&(m[0]=Math.min(m[0],t),m[1]=Math.max(m[1],i),c=!0,_/(i-t)>.5))return}if(c||a.push([t,i]),this.config.renderTextTracksNatively){var S=this.captionsTracks[e];this.Cues.newCue(S,t,i,n)}else{var P=this.Cues.newCue(null,t,i,n);this.hls.trigger(p.Events.CUES_PARSED,{type:"captions",cues:P,track:e})}},o.onInitPtsFound=function(e,t){var i=this,n=t.frag,a=t.id,r=t.initPTS,s=t.timescale,l=this.unparsedVttFrags;a==="main"&&(this.initPTS[n.cc]=r,this.timescale[n.cc]=s),l.length&&(this.unparsedVttFrags=[],l.forEach(function(u){i.onFragLoaded(p.Events.FRAG_LOADED,u)}))},o.getExistingTrack=function(e){var t=this.media;if(t)for(var i=0;i<t.textTracks.length;i++){var n=t.textTracks[i];if(n[e])return n}return null},o.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},o.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,i=this.captionsTracks,n=this.media,a=t[e],r=a.label,s=a.languageCode,l=this.getExistingTrack(e);if(l)i[e]=l,ht(i[e]),rt(i[e],n);else{var u=this.createTextTrack("captions",r,s);u&&(u[e]=!0,i[e]=u)}}},o.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}},o.createTextTrack=function(e,t,i){var n=this.media;if(n)return n.addTextTrack(e,t,i)},o.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},o.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach(function(t){ht(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)ht(t[i])}},o.onSubtitleTracksUpdated=function(e,t){var i=this;this.textTracks=[];var n=t.subtitleTracks||[],a=n.some(function(u){return u.textCodec===gr});if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var r=this.tracks&&n&&this.tracks.length===n.length;if(this.tracks=n||[],this.config.renderTextTracksNatively){var s=this.media?this.media.textTracks:[];this.tracks.forEach(function(u,c){var v;if(c<s.length){for(var m=null,_=0;_<s.length;_++)if(Za(s[_],u)){m=s[_];break}m&&(v=m)}if(v)ht(v);else{var S=i._captionsOrSubtitlesFromCharacteristics(u);(v=i.createTextTrack(S,u.name,u.lang))&&(v.mode="disabled")}v&&(v.groupId=u.groupId,i.textTracks.push(v))})}else if(!r&&this.tracks&&this.tracks.length){var l=this.tracks.map(function(u){return{label:u.name,kind:u.type.toLowerCase(),default:u.default,subtitleTrack:u}});this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}},o._captionsOrSubtitlesFromCharacteristics=function(e){var t;if((t=e.attrs)!==null&&t!==void 0&&t.CHARACTERISTICS){var i=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),n=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(i&&n)return"captions"}return"subtitles"},o.onManifestLoaded=function(e,t){var i=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(function(n){var a=/(?:CC|SERVICE)([1-4])/.exec(n.instreamId);if(a){var r="textTrack"+a[1],s=i.captionsProperties[r];s&&(s.label=n.name,n.lang&&(s.languageCode=n.lang),s.media=n)}})},o.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]},o.onFragLoading=function(e,t){var i=this.cea608Parser1,n=this.cea608Parser2,a=this.lastSn,r=this.lastPartIndex;if(this.enabled&&i&&n&&t.frag.type===pe.PlaylistLevelType.MAIN){var s,l,u=t.frag.sn,c=(s=t==null||(l=t.part)===null||l===void 0?void 0:l.index)!=null?s:-1;u===a+1||u===a&&c===r+1||(i.reset(),n.reset()),this.lastSn=u,this.lastPartIndex=c}},o.onFragLoaded=function(e,t){var i=t.frag,n=t.payload,a=this.initPTS,r=this.unparsedVttFrags;if(i.type===pe.PlaylistLevelType.SUBTITLE)if(n.byteLength){if(!(0,R.isFiniteNumber)(a[i.cc]))return r.push(t),void(a.length&&this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Missing initial subtitle PTS")}));var s=i.decryptdata,l="stats"in t;if(s==null||!s.encrypted||l){var u=this.tracks[i.level],c=this.vttCCs;c[i.cc]||(c[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),u&&u.textCodec===gr?this._parseIMSC1(i,n):this._parseVTTs(i,n,c)}}else this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(e,t){var i=this,n=this.hls;ia(t,this.initPTS[e.cc],this.timescale[e.cc],function(a){i._appendCues(a,e.level),n.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(a){k.logger.log("Failed to parse IMSC1: "+a),n.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:a})})},o._parseVTTs=function(e,t,i){var n,a=this,r=this.hls;(function(s,l,u,c,v,m,_,S){var P,I=new ar,q=(0,Lt.utf8ArrayToStr)(new Uint8Array(s)).trim().replace(sr,`
|
|
30
28
|
`).split(`
|
|
31
|
-
`),
|
|
32
|
-
`)}),u.flush()}},"./src/utils/xhr-loader.ts":(z,N,_)=>{"use strict";_.r(N),_.d(N,{default:()=>B});var C=_("./src/utils/logger.ts"),D=_("./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 T=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),T&&(T.onreadystatechange=null,T.onprogress=null,T.readyState!==4&&(this.stats.aborted=!0,T.abort()))},A.abort=function(){var T;this.abortInternal(),(T=this.callbacks)!==null&&T!==void 0&&T.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},A.load=function(T,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=T,this.config=x,this.callbacks=f,this.retryDelay=x.retryDelay,this.loadInternal()},A.loadInternal=function(){var T=this.config,x=this.context;if(!!T){var f=this.loader=new self.XMLHttpRequest,E=this.stats;E.loading.first=0,E.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 h=this.context.headers;if(h)for(var a in h)f.setRequestHeader(a,h[a])}catch(o){this.callbacks.onError({code:f.status,text:o.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),T.timeout),f.send()}},A.readystatechange=function(){var T=this.context,x=this.loader,f=this.stats;if(!(!T||!x)){var E=x.readyState,p=this.config;if(!f.aborted&&E>=2)if(self.clearTimeout(this.requestTimeout),f.loading.first===0&&(f.loading.first=Math.max(self.performance.now(),f.loading.start)),E===4){x.onreadystatechange=null,x.onprogress=null;var h=x.status,a=x.responseType==="arraybuffer";if(h>=200&&h<300&&(a&&x.response||x.responseText!==null)){f.loading.end=Math.max(self.performance.now(),f.loading.first);var o,n;if(a?(o=x.response,n=o.byteLength):(o=x.responseText,n=o.length),f.loaded=f.total=n,!this.callbacks)return;var v=this.callbacks.onProgress;if(v&&v(f,T,o,x),!this.callbacks)return;var l={url:x.responseURL,data:o};this.callbacks.onSuccess(l,f,T,x)}else f.retry>=p.maxRetry||h>=400&&h<499?(C.logger.error(h+" while loading "+T.url),this.callbacks.onError({code:h,text:x.statusText},T,x)):(C.logger.warn(h+" while loading "+T.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(){C.logger.warn("timeout while loading "+this.context.url);var T=this.callbacks;T&&(this.abortInternal(),T.onTimeout(this.stats,this.context,this.loader))},A.loadprogress=function(T){var x=this.stats;x.loaded=T.loaded,T.lengthComputable&&(x.total=T.total)},A.getCacheAge=function(){var T=null;if(this.loader&&M.test(this.loader.getAllResponseHeaders())){var x=this.loader.getResponseHeader("age");T=x?parseFloat(x):null}return T},b}();let B=P},"./node_modules/eventemitter3/index.js":z=>{"use strict";var N=Object.prototype.hasOwnProperty,_="~";function C(){}Object.create&&(C.prototype=Object.create(null),new C().__proto__||(_=!1));function D(b,A,S){this.fn=b,this.context=A,this.once=S||!1}function M(b,A,S,T,x){if(typeof S!="function")throw new TypeError("The listener must be a function");var f=new D(S,T||b,x),E=_?_+A:A;return b._events[E]?b._events[E].fn?b._events[E]=[b._events[E],f]:b._events[E].push(f):(b._events[E]=f,b._eventsCount++),b}function P(b,A){--b._eventsCount===0?b._events=new C:delete b._events[A]}function B(){this._events=new C,this._eventsCount=0}B.prototype.eventNames=function(){var A=[],S,T;if(this._eventsCount===0)return A;for(T in S=this._events)N.call(S,T)&&A.push(_?T.slice(1):T);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(S)):A},B.prototype.listeners=function(A){var S=_?_+A:A,T=this._events[S];if(!T)return[];if(T.fn)return[T.fn];for(var x=0,f=T.length,E=new Array(f);x<f;x++)E[x]=T[x].fn;return E},B.prototype.listenerCount=function(A){var S=_?_+A:A,T=this._events[S];return T?T.fn?1:T.length:0},B.prototype.emit=function(A,S,T,x,f,E){var p=_?_+A:A;if(!this._events[p])return!1;var h=this._events[p],a=arguments.length,o,n;if(h.fn){switch(h.once&&this.removeListener(A,h.fn,void 0,!0),a){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,S),!0;case 3:return h.fn.call(h.context,S,T),!0;case 4:return h.fn.call(h.context,S,T,x),!0;case 5:return h.fn.call(h.context,S,T,x,f),!0;case 6:return h.fn.call(h.context,S,T,x,f,E),!0}for(n=1,o=new Array(a-1);n<a;n++)o[n-1]=arguments[n];h.fn.apply(h.context,o)}else{var v=h.length,l;for(n=0;n<v;n++)switch(h[n].once&&this.removeListener(A,h[n].fn,void 0,!0),a){case 1:h[n].fn.call(h[n].context);break;case 2:h[n].fn.call(h[n].context,S);break;case 3:h[n].fn.call(h[n].context,S,T);break;case 4:h[n].fn.call(h[n].context,S,T,x);break;default:if(!o)for(l=1,o=new Array(a-1);l<a;l++)o[l-1]=arguments[l];h[n].fn.apply(h[n].context,o)}}return!0},B.prototype.on=function(A,S,T){return M(this,A,S,T,!1)},B.prototype.once=function(A,S,T){return M(this,A,S,T,!0)},B.prototype.removeListener=function(A,S,T,x){var f=_?_+A:A;if(!this._events[f])return this;if(!S)return P(this,f),this;var E=this._events[f];if(E.fn)E.fn===S&&(!x||E.once)&&(!T||E.context===T)&&P(this,f);else{for(var p=0,h=[],a=E.length;p<a;p++)(E[p].fn!==S||x&&!E[p].once||T&&E[p].context!==T)&&h.push(E[p]);h.length?this._events[f]=h.length===1?h[0]:h:P(this,f)}return this},B.prototype.removeAllListeners=function(A){var S;return A?(S=_?_+A:A,this._events[S]&&P(this,S)):(this._events=new C,this._eventsCount=0),this},B.prototype.off=B.prototype.removeListener,B.prototype.addListener=B.prototype.on,B.prefixed=_,B.EventEmitter=B,z.exports=B},"./node_modules/url-toolkit/src/url-toolkit.js":function(z){(function(N){var _=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,C=/^(?=([^\/?#]*))\1([^]*)$/,D=/(?:\/|^)\.(?=\/)/g,M=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,P={buildAbsoluteURL:function(B,b,A){if(A=A||{},B=B.trim(),b=b.trim(),!b){if(!A.alwaysNormalize)return B;var S=P.parseURL(B);if(!S)throw new Error("Error trying to parse base URL.");return S.path=P.normalizePath(S.path),P.buildURLFromParts(S)}var T=P.parseURL(b);if(!T)throw new Error("Error trying to parse relative URL.");if(T.scheme)return A.alwaysNormalize?(T.path=P.normalizePath(T.path),P.buildURLFromParts(T)):b;var x=P.parseURL(B);if(!x)throw new Error("Error trying to parse base URL.");if(!x.netLoc&&x.path&&x.path[0]!=="/"){var f=C.exec(x.path);x.netLoc=f[1],x.path=f[2]}x.netLoc&&!x.path&&(x.path="/");var E={scheme:x.scheme,netLoc:T.netLoc,path:null,params:T.params,query:T.query,fragment:T.fragment};if(!T.netLoc&&(E.netLoc=x.netLoc,T.path[0]!=="/"))if(!T.path)E.path=x.path,T.params||(E.params=x.params,T.query||(E.query=x.query));else{var p=x.path,h=p.substring(0,p.lastIndexOf("/")+1)+T.path;E.path=P.normalizePath(h)}return E.path===null&&(E.path=A.alwaysNormalize?P.normalizePath(T.path):T.path),P.buildURLFromParts(E)},parseURL:function(B){var b=_.exec(B);return b?{scheme:b[1]||"",netLoc:b[2]||"",path:b[3]||"",params:b[4]||"",query:b[5]||"",fragment:b[6]||""}:null},normalizePath:function(B){for(B=B.split("").reverse().join("").replace(D,"");B.length!==(B=B.replace(M,"")).length;);return B.split("").reverse().join("")},buildURLFromParts:function(B){return B.scheme+B.netLoc+B.path+B.params+B.query+B.fragment}};z.exports=P})(this)}},q={};function X(z){var N=q[z];if(N!==void 0)return N.exports;var _=q[z]={exports:{}};return $[z].call(_.exports,_,_.exports,X),_.exports}X.m=$,X.n=z=>{var N=z&&z.__esModule?()=>z.default:()=>z;return X.d(N,{a:N}),N},X.d=(z,N)=>{for(var _ in N)X.o(N,_)&&!X.o(z,_)&&Object.defineProperty(z,_,{enumerable:!0,get:N[_]})},X.o=(z,N)=>Object.prototype.hasOwnProperty.call(z,N),X.r=z=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(z,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(z,"__esModule",{value:!0})};var ne=X("./src/hls.ts");return ne=ne.default,ne})())});var Mt=class{addEventListener(){}removeEventListener(){}dispatchEvent(q){return!0}};if(typeof DocumentFragment=="undefined"){class $ extends Mt{}globalThis.DocumentFragment=$}var $t=class extends Mt{},Or=class extends Mt{},Tn={get($){},define($,q,X){},upgrade($){},whenDefined($){return Promise.resolve($t)}},Jt,Cr=class{constructor(q,X={}){mt(this,Jt,void 0);pt(this,Jt,X==null?void 0:X.detail)}get detail(){return lt(this,Jt)}initCustomEvent(){}};Jt=new WeakMap;function Sn($,q){return new $t}var ai={document:{createElement:Sn},DocumentFragment,customElements:Tn,CustomEvent:Cr,EventTarget:Mt,HTMLElement:$t,HTMLVideoElement:Or},si=typeof window=="undefined"||typeof globalThis.customElements=="undefined",_t=si?ai:globalThis,Mr=si?ai.document:globalThis.document;var gr=fr(oi(),1),Lt=fr(hr(),1),Ur=fr(hr(),1),wt=fr(hr(),1),qt=class extends Error{constructor($,q=qt.MEDIA_ERR_CUSTOM,X){var ne;super($),this.name="MediaError",this.code=q,this.fatal=X!=null?X:q>=qt.MEDIA_ERR_NETWORK&&q<=qt.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(ne=qt.defaultMessages[this.code])!=null?ne:"")}},ut=qt;ut.MEDIA_ERR_ABORTED=1,ut.MEDIA_ERR_NETWORK=2,ut.MEDIA_ERR_DECODE=3,ut.MEDIA_ERR_SRC_NOT_SUPPORTED=4,ut.MEDIA_ERR_ENCRYPTED=5,ut.MEDIA_ERR_CUSTOM=100,ut.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 xn=$=>$==null,hi=($,q)=>xn(q)?!1:$ in q,Br={ANY:"any",MUTED:"muted"},vr={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Pt={MSE:"mse",NATIVE:"native"},Nr={HEADER:"header",QUERY:"query",NONE:"none"},ra=Object.values(Nr),Ft={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Kr={HLS:Ft.M3U8},ia=Object.keys(Kr),na=[...Object.values(Ft),"hls","HLS"],kt=($,q,X,ne,z=$)=>{z.addEventListener(q,X,ne),$.addEventListener("teardown",()=>{z.removeEventListener(q,X)},{once:!0})};function An($,q,X){q&&X>q&&(X=q);for(let ne=0;ne<$.length;ne++)if($.start(ne)<=X&&$.end(ne)>=X)return!0;return!1}var Dn=$=>{let q=$.indexOf("?");if(q<0)return[$];let X=$.slice(0,q),ne=$.slice(q);return[X,ne]},vi=$=>{let q=$.type;if(q){let ne=q.toUpperCase();return hi(ne,Kr)?Kr[ne]:q}let{src:X}=$;return X?bn(X):""},bn=$=>{let q="";try{q=new URL($).pathname}catch{console.error("invalid url")}let X=q.lastIndexOf(".");if(X<0)return"";let ne=q.slice(X+1).toUpperCase();return hi(ne,Ft)?Ft[ne]:""},Ln=Object.values(Br),li=$=>typeof $=="boolean"||typeof $=="string"&&Ln.includes($),Pn=({autoplay:$},q,X)=>{let ne=!1,z=!1,N=li($)?$:!!$,_=()=>{ne||kt(q,"playing",()=>{ne=!0},{once:!0})};if(_(),kt(q,"loadstart",()=>{ne=!1,_(),Fr(q,N)},{once:!0}),kt(q,"loadstart",()=>{X||(z=!Number.isFinite(q.duration)),Fr(q,N)},{once:!0}),X&&X.once(Ur.default.Events.LEVEL_LOADED,(C,D)=>{var M;z=(M=D.details.live)!=null?M:!1}),!N){let C=()=>{!z||(X!=null&&X.liveSyncPosition?q.currentTime=X.liveSyncPosition:Number.isFinite(q.seekable.end(0))&&(q.currentTime=q.seekable.end(0)))};X&&kt(q,"play",()=>{q.preload==="metadata"?X.once(Ur.default.Events.LEVEL_UPDATED,C):C()},{once:!0})}return C=>{ne||(N=li(C)?C:!!C,Fr(q,N))}},Fr=($,q)=>{if(!q)return;let X=$.muted,ne=()=>$.muted=X;switch(q){case Br.ANY:$.play().catch(()=>{$.muted=!0,$.play().catch(ne)});break;case Br.MUTED:$.muted=!0,$.play().catch(ne);break;default:$.play().catch(()=>{});break}},Rn=({preload:$,src:q},X,ne)=>{let z=B=>{B!=null&&["","none","metadata","auto"].includes(B)?X.setAttribute("preload",B):X.removeAttribute("preload")};if(!ne)return z($),z;let N=!1,_=!1,C=ne.config.maxBufferLength,D=ne.config.maxBufferSize,M=B=>{z(B);let b=B!=null?B:X.preload;_||b==="none"||(b==="metadata"?(ne.config.maxBufferLength=1,ne.config.maxBufferSize=1):(ne.config.maxBufferLength=C,ne.config.maxBufferSize=D),P())},P=()=>{!N&&q&&(N=!0,ne.loadSource(q))};return kt(X,"play",()=>{_=!0,ne.config.maxBufferLength=C,ne.config.maxBufferSize=D,P()},{once:!0}),M($),M};function In($,q){q.on(wt.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(z,{tracks:N})=>{N.forEach(_=>{var C;let D=(C=_.subtitleTrack)!=null?C:_.closedCaptions,M=q.subtitleTracks.findIndex(({lang:P,name:B,type:b})=>P==(D==null?void 0:D.lang)&&B===_.label&&b.toLowerCase()===_.kind);gi($,_.kind,_.label,D==null?void 0:D.lang,`${_.kind}${M}`)})});let X=()=>{var z;if(!q.subtitleTracks.length)return;let N=Array.from($.textTracks).find(C=>C.id&&C.mode==="showing"&&["subtitles","captions"].includes(C.kind)),_=`${(z=q.subtitleTracks[q.subtitleTrack])==null?void 0:z.type.toLowerCase()}${q.subtitleTrack}`;if(N&&(q.subtitleTrack<0||(N==null?void 0:N.id)!==_)){let C=q.subtitleTracks.findIndex(({lang:D,name:M,type:P})=>D==N.language&&M===N.label&&P.toLowerCase()===N.kind);q.subtitleTrack=C}N&&(N==null?void 0:N.id)===_&&N.cues&&Array.from(N.cues).forEach(C=>{N.addCue(C)})};$.textTracks.addEventListener("change",X),q.on(wt.default.Events.CUES_PARSED,(z,{track:N,cues:_})=>{let C=$.textTracks.getTrackById(N);if(!C)return;let D=C.mode==="disabled";D&&(C.mode="hidden"),_.forEach(M=>{var P;(P=C.cues)!=null&&P.getCueById(M.id)||C.addCue(M)}),D&&(C.mode="disabled")}),q.once(wt.default.Events.DESTROYING,()=>{$.textTracks.removeEventListener("change",X),$.querySelectorAll("track[data-removeondestroy]").forEach(z=>{z.remove()})});let ne=()=>{Array.from($.textTracks).forEach(z=>{var N,_;if(!["subtitles","caption"].includes(z.kind)&&z.label==="thumbnails"){if(!((N=z.cues)!=null&&N.length)){let C=$.querySelector('track[label="thumbnails"]'),D=(_=C==null?void 0:C.getAttribute("src"))!=null?_:"";C==null||C.removeAttribute("src"),setTimeout(()=>{C==null||C.setAttribute("src",D)},0)}z.mode!=="hidden"&&(z.mode="hidden")}})};q.once(wt.default.Events.MANIFEST_LOADED,ne),q.once(wt.default.Events.MEDIA_ATTACHED,ne)}function gi($,q,X,ne,z){let N=document.createElement("track");return N.kind=q,N.label=X,ne&&(N.srclang=ne),z&&(N.id=z),N.track.mode="disabled",N.setAttribute("data-removeondestroy",""),$.append(N),N.track}var mr="cuepoints",Gr=Object.freeze({label:mr}),mi=($,{label:q=mr}=Gr)=>{var X;return(X=Array.from($.querySelectorAll("track")).find(ne=>ne.track.label===q&&ne.track.kind==="metadata"))==null?void 0:X.track};async function On($,q,X=Gr){let ne=mi($,X);if(!ne){let{label:z=mr}=X;ne=gi($,"metadata",z),ne.mode="hidden",await new Promise(N=>setTimeout(()=>N(void 0),0))}return[...q].sort(({time:z},{time:N})=>N-z).forEach(({time:z,value:N})=>{var _,C;let D=Array.prototype.findIndex.call(ne==null?void 0:ne.cues,A=>A.startTime>=z),M=(_=ne==null?void 0:ne.cues)==null?void 0:_[D],P=M?M.startTime:Number.isFinite($.duration)?$.duration:Number.MAX_SAFE_INTEGER,B=(C=ne==null?void 0:ne.cues)==null?void 0:C[D-1];B&&(B.endTime=z);let b=new VTTCue(z,P,JSON.stringify(N!=null?N:null));ne.addCue(b)}),ne}var Cn=$=>({time:$.startTime,value:JSON.parse($.text)});function Mn($,q={label:mr}){var X;let ne=mi($,q);if((X=ne==null?void 0:ne.activeCues)!=null&&X.length)return Cn(ne.activeCues[0])}async function wn($,q=Gr){let X=await On($,[],q);return kt($,"cuechange",()=>{let ne=Mn($);if(ne){let z=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:ne});$.dispatchEvent(z)}},{},X),X}var ui,di,kn=(di=(ui=globalThis==null?void 0:globalThis.navigator)==null?void 0:ui.userAgent)!=null?di:"",Fn=kn.toLowerCase().indexOf("android")!==-1,er=new WeakMap,pi="mux.com",fi,ci,yi=(ci=(fi=Lt.default).isSupported)==null?void 0:ci.call(fi),Un=Fn,Ei=()=>gr.default.utils.now(),Bn=gr.default.utils.generateUUID,_i=($,{domain:q=pi}={})=>{if(!$)return;let[X,ne=""]=Dn($);return`https://stream.${q}/${X}.m3u8${ne}`},Nn=$=>{if(!$)return;let[q]=$.split("?");return q||void 0},Kn=$=>{if(!$||!$.startsWith("https://stream."))return;let[q]=new URL($).pathname.slice(1).split(".m3u8");return q||void 0},Wn=$=>{var q,X,ne;return(q=$==null?void 0:$.metadata)!=null&&q.video_id?$.metadata.video_id:xi($)&&(ne=(X=Nn($.playbackId))!=null?X:Kn($.src))!=null?ne:$.src};var Ti=($,q,X)=>{Hr(q,X);let{metadata:ne={}}=$,{view_session_id:z=Bn()}=ne,N=Wn($);ne.view_session_id=z,ne.video_id=N,$.metadata=ne,er.set(q,{});let _=Gn($,q);jn($,q,_),Vn($,q,_),_&&wn(q);let C=Pn($,q,_),D=Rn($,q,_);return{engine:_,setAutoplay:C,setPreload:D}},Hr=($,q)=>{let X=q==null?void 0:q.engine;X&&(X.detachMedia(),X.destroy()),($==null?void 0:$.mux)&&!$.mux.deleted&&($.mux.destroy(),delete $.mux),$&&($.removeAttribute("src"),$.load(),$.removeEventListener("error",Di),$.removeEventListener("error",Wr),$.removeEventListener("durationchange",Ai),er.delete($),$.dispatchEvent(new Event("teardown")))};function Si($,q){var X;let ne=vi($);if(ne!==Ft.M3U8)return!0;let z=!ne||((X=q.canPlayType(ne))!=null?X:!0),{preferPlayback:N}=$,_=N===Pt.MSE,C=N===Pt.NATIVE;return z&&(C||!(yi&&(_||Un)))}var Gn=($,q)=>{let{debug:X,streamType:ne,startTime:z=-1,metadata:N,preferCmcd:_}=$,C=vi($)===Ft.M3U8,D=Si($,q);if(C&&!D&&yi){let M={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},P=Hn(ne),B=_!==Nr.NONE?{useHeaders:_===Nr.HEADER,sessionId:N.view_session_id,contentId:N.video_id}:void 0;return new Lt.default({debug:X,startPosition:z,cmcd:B,...M,...P})}},Hn=$=>[vr.LIVE,vr.DVR].includes($)?{backBufferLength:8}:[vr.LL_LIVE,vr.LL_DVR].includes($)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},xi=({playbackId:$,src:q,customDomain:X})=>{if($)return!0;if(typeof q!="string")return!1;let ne=window==null?void 0:window.location.href,z=new URL(q,ne).hostname.toLocaleLowerCase();return z.includes(pi)||!!X&&z.includes(X.toLocaleLowerCase())},jn=($,q,X)=>{var ne;let{envKey:z}=$,N=xi($);if(z||N){let{playerInitTime:_,playerSoftwareName:C,playerSoftwareVersion:D,beaconCollectionDomain:M,debug:P,disableCookies:B}=$,b={...$.metadata,video_title:((ne=$==null?void 0:$.metadata)==null?void 0:ne.video_title)||void 0},A=S=>typeof S.player_error_code=="string"?!1:typeof $.errorTranslator=="function"?$.errorTranslator(S):S;gr.default.monitor(q,{debug:P,beaconCollectionDomain:M,hlsjs:X,Hls:X?Lt.default:void 0,automaticErrorTracking:!1,errorTranslator:A,disableCookies:B,data:{...z?{env_key:z}:{},player_software_name:C,player_software:C,player_software_version:D,player_init_time:_,...b}})}},Vn=($,q,X)=>{var ne;let z=Si($,q),{src:N}=$;q&&z?(typeof N=="string"?(q.setAttribute("src",N),$.startTime&&(((ne=er.get(q))!=null?ne:{}).startTime=$.startTime,q.addEventListener("durationchange",Ai,{once:!0}))):q.removeAttribute("src"),q.addEventListener("error",Di),q.addEventListener("error",Wr)):X&&N?(X.on(Lt.default.Events.ERROR,(_,C)=>{let D={[Lt.default.ErrorTypes.NETWORK_ERROR]:ut.MEDIA_ERR_NETWORK,[Lt.default.ErrorTypes.MEDIA_ERROR]:ut.MEDIA_ERR_DECODE},M=new ut("",D[C.type]);M.fatal=C.fatal,M.data=C,q.dispatchEvent(new CustomEvent("error",{detail:M}))}),q.addEventListener("error",Wr),In(q,X),X.attachMedia(q)):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 Ai($){var q;let X=$.target,ne=(q=er.get(X))==null?void 0:q.startTime;if(!!ne&&An(X.seekable,X.duration,ne)){let z=X.preload==="auto";z&&(X.preload="none"),X.currentTime=ne,z&&(X.preload="auto")}}async function Di($){if(!$.isTrusted)return;$.stopImmediatePropagation();let q=$.target;if(!(q!=null&&q.error))return;let{message:X,code:ne}=q.error,z=new ut(X,ne);if(q.src&&(ne!==ut.MEDIA_ERR_DECODE||ne!==void 0))try{let{status:N}=await fetch(q.src);z.data={response:{code:N}}}catch{}q.dispatchEvent(new CustomEvent("error",{detail:z}))}function Wr($){var q,X;if(!($ instanceof CustomEvent)||!($.detail instanceof ut))return;let ne=$.target,z=$.detail;!z||!z.fatal||(((q=er.get(ne))!=null?q:{}).error=z,(X=ne.mux)==null||X.emit("error",{player_error_code:z.code,player_error_message:z.message}))}var Yn=()=>{try{return"0.9.3"}catch{}return"UNKNOWN"},Xn=Yn(),bi=()=>Xn;var Li=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],Pi=Mr.createElement("template");Pi.innerHTML=`
|
|
29
|
+
`),se=[],Ee=(0,rr.toMpegTsClockFromTimescale)(l,u),he="00:00.000",Ae=0,He=0,ze=!0;I.oncue=function(be){var Ge=c[v],Me=c.ccOffset,ct=(Ae-Ee)/9e4;Ge!=null&&Ge.new&&(He!==void 0?Me=c.ccOffset=Ge.start:function(Dt,Zt,zt){var Kt=Dt[Zt],er=Dt[Kt.prevCC];if(!er||!er.new&&Kt.new)return Dt.ccOffset=Dt.presentationOffset=Kt.start,void(Kt.new=!1);for(;(Er=er)!==null&&Er!==void 0&&Er.new;){var Er;Dt.ccOffset+=Kt.start-er.start,Kt.new=!1,er=Dt[(Kt=er).prevCC]}Dt.presentationOffset=zt}(c,v,ct)),ct&&(Me=ct-c.presentationOffset);var Ot=be.endTime-be.startTime,ft=(0,fr.normalizePts)(9e4*(be.startTime+Me-He),9e4*m)/9e4;be.startTime=Math.max(ft,0),be.endTime=Math.max(ft+Ot,0);var Tt=be.text.trim();be.text=decodeURIComponent(encodeURIComponent(Tt)),be.id||(be.id=or(be.startTime,be.endTime,Tt)),be.endTime>0&&se.push(be)},I.onparsingerror=function(be){P=be},I.onflush=function(){P?S(P):_(se)},q.forEach(function(be){if(ze){if(vr(be,"X-TIMESTAMP-MAP=")){ze=!1,be.slice(16).split(",").forEach(function(Ge){vr(Ge,"LOCAL:")?he=Ge.slice(6):vr(Ge,"MPEGTS:")&&(Ae=parseInt(Ge.slice(7)))});try{He=function(Ge){var Me=parseInt(Ge.slice(-3)),ct=parseInt(Ge.slice(-6,-4)),Ot=parseInt(Ge.slice(-9,-7)),ft=Ge.length>9?parseInt(Ge.substring(0,Ge.indexOf(":"))):0;if(!((0,R.isFiniteNumber)(Me)&&(0,R.isFiniteNumber)(ct)&&(0,R.isFiniteNumber)(Ot)&&(0,R.isFiniteNumber)(ft)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+Ge);return Me+=1e3*ct,(Me+=6e4*Ot)+36e5*ft}(he)/1e3}catch(Ge){P=Ge}return}be===""&&(ze=!1)}I.parse(be+`
|
|
30
|
+
`)}),I.flush()})((n=e.initSegment)!==null&&n!==void 0&&n.data?(0,J.appendUint8Array)(e.initSegment.data,new Uint8Array(t)):t,this.initPTS[e.cc],this.timescale[e.cc],i,e.cc,e.start,function(s){a._appendCues(s,e.level),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},function(s){a._fallbackToIMSC1(e,t),k.logger.log("Failed to parse VTT cue: "+s),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})},o._fallbackToIMSC1=function(e,t){var i=this,n=this.tracks[e.level];n.textCodec||ia(t,this.initPTS[e.cc],this.timescale[e.cc],function(){n.textCodec=gr,i._parseIMSC1(e,t)},function(){n.textCodec="wvtt"})},o._appendCues=function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||n.mode==="disabled")return;e.forEach(function(s){return yt(n,s)})}else{var a=this.tracks[t];if(!a)return;var r=a.default?"default":"subtitles"+t;i.trigger(p.Events.CUES_PARSED,{type:"subtitles",cues:e,track:r})}},o.onFragDecrypted=function(e,t){var i=t.frag;if(i.type===pe.PlaylistLevelType.SUBTITLE){if(!(0,R.isFiniteNumber)(this.initPTS[i.cc]))return void this.unparsedVttFrags.push(t);this.onFragLoaded(p.Events.FRAG_LOADED,t)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(e,t){var i=this.cea608Parser1,n=this.cea608Parser2;if(this.enabled&&i&&n){var a=t.frag,r=t.samples;if(a.type!==pe.PlaylistLevelType.MAIN||this.closedCaptionsForLevel(a)!=="NONE")for(var s=0;s<r.length;s++){var l=r[s].bytes;if(l){var u=this.extractCea608Data(l);i.addData(r[s].pts,u[0]),n.addData(r[s].pts,u[1])}}}},o.onBufferFlushing=function(e,t){var i=t.startOffset,n=t.endOffset,a=t.endOffsetSubtitles,r=t.type,s=this.media;if(s&&!(s.currentTime<n)){if(!r||r==="video"){var l=this.captionsTracks;Object.keys(l).forEach(function(c){return It(l[c],i,n)})}if(this.config.renderTextTracksNatively&&i===0&&a!==void 0){var u=this.textTracks;Object.keys(u).forEach(function(c){return It(u[c],i,a)})}}},o.extractCea608Data=function(e){for(var t=[[],[]],i=31&e[0],n=2,a=0;a<i;a++){var r=e[n++],s=127&e[n++],l=127&e[n++];if((s!==0||l!==0)&&(4&r)!=0){var u=3&r;u!==0&&u!==1||(t[u].push(s),t[u].push(l))}}return t},d}();function Za(d,o){return d&&d.label===o.name&&!(d.textTrack1||d.textTrack2)}function es(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}let ts=function(){function d(i){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=i,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var o,e,t=d.prototype;return t.setStreamController=function(i){this.streamController=i},t.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},t.registerListeners=function(){var i=this.hls;i.on(p.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),i.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListener=function(){var i=this.hls;i.off(p.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),i.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),i.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),i.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),i.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},t.onFpsDropLevelCapping=function(i,n){d.isLevelAllowed(n.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(n.droppedLevel)},t.onMediaAttaching=function(i,n){this.media=n.media instanceof HTMLVideoElement?n.media:null,this.clientRect=null},t.onManifestParsed=function(i,n){var a=this.hls;this.restrictedLevels=[],this.firstLevel=n.firstLevel,a.config.capLevelToPlayerSize&&n.video&&this.startCapping()},t.onBufferCodecs=function(i,n){this.hls.config.capLevelToPlayerSize&&n.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping()},t.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var i=this.hls.levels;if(i.length){var n=this.hls;n.autoLevelCapping=this.getMaxLevel(i.length-1),n.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=n.autoLevelCapping}}},t.getMaxLevel=function(i){var n=this,a=this.hls.levels;if(!a.length)return-1;var r=a.filter(function(s,l){return d.isLevelAllowed(l,n.restrictedLevels)&&l<=i});return this.clientRect=null,d.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)},t.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var i=this.media,n={width:0,height:0};if(i){var a=i.getBoundingClientRect();n.width=a.width,n.height=a.height,n.width||n.height||(n.width=a.right-a.left||i.width||0,n.height=a.bottom-a.top||i.height||0)}return this.clientRect=n,n},d.isLevelAllowed=function(i,n){return n===void 0&&(n=[]),n.indexOf(i)===-1},d.getMaxLevelByMediaSize=function(i,n,a){if(!i||!i.length)return-1;for(var r,s,l=i.length-1,u=0;u<i.length;u+=1){var c=i[u];if((c.width>=n||c.height>=a)&&(r=c,!(s=i[u+1])||r.width!==s.width||r.height!==s.height)){l=u;break}}return l},o=d,(e=[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var i=1;if(!this.hls.config.ignoreDevicePixelRatio)try{i=self.devicePixelRatio}catch{}return i}}])&&es(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),d}(),rs=function(){function d(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var o=d.prototype;return o.setStreamController=function(e){this.streamController=e},o.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},o.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching)},o.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},o.onMediaAttaching=function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}},o.checkFPS=function(e,t,i){var n=performance.now();if(t){if(this.lastTime){var a=n-this.lastTime,r=i-this.lastDroppedFrames,s=t-this.lastDecodedFrames,l=1e3*r/a,u=this.hls;if(u.trigger(p.Events.FPS_DROP,{currentDropped:r,currentDecoded:s,totalDroppedFrames:i}),l>0&&r>u.config.fpsDroppedMonitoringThreshold*s){var c=u.currentLevel;k.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(u.autoLevelCapping===-1||u.autoLevelCapping>=c)&&(c-=1,u.trigger(p.Events.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:u.currentLevel}),u.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}},o.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},d}();var ri=N(300);function On(d){var o=typeof Map=="function"?new Map:void 0;return On=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return Pn(e,arguments,xn(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Fi(i,e)},On(d)}function Pn(d,o,e){return Pn=is()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Fi(r,n.prototype),r},Pn.apply(null,arguments)}function is(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Fi(d,o){return Fi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Fi(d,o)}function xn(d){return xn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},xn(d)}var ln="[eme]",oa=function(){function d(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=d.CDMCleanupPromise?[d.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=k.logger.debug.bind(k.logger,ln),this.log=k.logger.log.bind(k.logger,ln),this.warn=k.logger.warn.bind(k.logger,ln),this.error=k.logger.error.bind(k.logger,ln),this.hls=e,this.config=e.config,this.registerListeners()}var o=d.prototype;return o.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null},o.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},o.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this)},o.getLicenseServerUrl=function(e){var t=this.config,i=t.drmSystems,n=t.widevineLicenseUrl,a=i[e];if(a)return a.licenseUrl;if(e===G.WIDEVINE&&n)return n;throw new Error('no license server URL configured for key-system "'+e+'"')},o.getServerCertificateUrl=function(e){var t=this.config.drmSystems[e];if(t)return t.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+e+'"]')},o.attemptKeySystemAccess=function(e){var t=this,i=this.hls.levels,n=function(s,l,u){return!!s&&u.indexOf(s)===l},a=i.map(function(s){return s.audioCodec}).filter(n),r=i.map(function(s){return s.videoCodec}).filter(n);return a.length+r.length===0&&r.push("avc1.42e01e"),new Promise(function(s,l){(function u(c){var v=c.shift();t.getMediaKeysPromise(v,a,r).then(function(m){return s({keySystem:v,mediaKeys:m})}).catch(function(m){c.length?u(c):l(m instanceof wr?m:new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_ACCESS,error:m,fatal:!0},m.message))})})(e)})},o.requestMediaKeySystemAccess=function(e,t){var i=this.config.requestMediaKeySystemAccessFunc;if(typeof i!="function"){var n="Configured requestMediaKeySystemAccess is not a function "+i;return Te===null&&self.location.protocol==="http:"&&(n="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(n))}return i(e,t)},o.getMediaKeysPromise=function(e,t,i){var n=this,a=function(u,c,v,m){var _;switch(u){case G.FAIRPLAY:_=["cenc","sinf"];break;case G.WIDEVINE:case G.PLAYREADY:_=["cenc"];break;case G.CLEARKEY:_=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+u)}return function(S,P,I,q){return[{initDataTypes:S,persistentState:q.persistentState||"not-allowed",distinctiveIdentifier:q.distinctiveIdentifier||"not-allowed",sessionTypes:q.sessionTypes||[q.sessionType||"temporary"],audioCapabilities:P.map(function(se){return{contentType:'audio/mp4; codecs="'+se+'"',robustness:q.audioRobustness||"",encryptionScheme:q.audioEncryptionScheme||null}}),videoCapabilities:I.map(function(se){return{contentType:'video/mp4; codecs="'+se+'"',robustness:q.videoRobustness||"",encryptionScheme:q.videoEncryptionScheme||null}})}]}(_,c,v,m)}(e,t,i,this.config.drmSystemOptions),r=this.keySystemAccessPromises[e],s=r==null?void 0:r.keySystemAccess;if(!s){this.log('Requesting encrypted media "'+e+'" key-system access with config: '+JSON.stringify(a)),s=this.requestMediaKeySystemAccess(e,a);var l=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch(function(u){n.log('Failed to obtain access to key-system "'+e+'": '+u)}),s.then(function(u){n.log('Access for key-system "'+u.keySystem+'" obtained');var c=n.fetchServerCertificate(e);return n.log('Create media-keys for "'+e+'"'),l.mediaKeys=u.createMediaKeys().then(function(v){return n.log('Media-keys created for "'+e+'"'),c.then(function(m){return m?n.setMediaKeysServerCertificate(v,e,m):v})}),l.mediaKeys.catch(function(v){n.error('Failed to create media-keys for "'+e+'"}: '+v)}),l.mediaKeys})}return s.then(function(){return r.mediaKeys})},o.createMediaKeySessionContext=function(e){var t=e.decryptdata,i=e.keySystem,n=e.mediaKeys;this.log('Creating key-system session "'+i+'" keyId: '+ri.default.hexDump(t.keyId||[]));var a=n.createSession(),r={decryptdata:t,keySystem:i,mediaKeys:n,mediaKeysSession:a,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r},o.renewKeySession=function(e){var t=e.decryptdata;if(t.pssh){var i=this.createMediaKeySessionContext(e),n=this.getKeyIdString(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)},o.getKeyIdString=function(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return ri.default.hexDump(e.keyId)},o.updateKeySession=function(e,t){var i,n=e.mediaKeysSession;return this.log('Updating key-session "'+n.sessionId+'" for keyID '+ri.default.hexDump(((i=e.decryptdata)===null||i===void 0?void 0:i.keyId)||[])+`
|
|
31
|
+
} (data length: `+(t&&t.byteLength)+")"),n.update(t)},o.selectKeySystemFormat=function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+e.sn+" "+e.type+": "+e.level+") key formats "+t.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise},o.getKeyFormatPromise=function(e){var t=this;return new Promise(function(i,n){var a=ue(t.config),r=e.map(U).filter(function(s){return!!s&&a.indexOf(s)!==-1});return t.getKeySystemSelectionPromise(r).then(function(s){var l=s.keySystem,u=A(l);u?i(u):n(new Error('Unable to find format for key-system "'+l+'"'))}).catch(n)})},o.loadKey=function(e){var t=this,i=e.keyInfo.decryptdata,n=this.getKeyIdString(i),a="(keyId: "+n+' format: "'+i.keyFormat+'" method: '+i.method+" uri: "+i.uri+")";this.log("Starting session for key "+a);var r=this.keyIdToKeySessionPromise[n];return r||(r=this.keyIdToKeySessionPromise[n]=this.getKeySystemForKeyPromise(i).then(function(s){var l=s.keySystem,u=s.mediaKeys;return t.throwIfDestroyed(),t.log("Handle encrypted media sn: "+e.frag.sn+" "+e.frag.type+": "+e.frag.level+" using key "+a),t.attemptSetMediaKeys(l,u).then(function(){t.throwIfDestroyed();var c=t.createMediaKeySessionContext({keySystem:l,mediaKeys:u,decryptdata:i});return t.generateRequestWithPreferredKeySession(c,"cenc",i.pssh,"playlist-key")})})).catch(function(s){return t.handleError(s)}),r},o.throwIfDestroyed=function(e){if(e===void 0&&(e="Invalid state"),!this.hls)throw new Error("invalid state")},o.handleError=function(e){this.hls&&(this.error(e.message),e instanceof wr?this.hls.trigger(p.Events.ERROR,e.data):this.hls.trigger(p.Events.ERROR,{type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))},o.getKeySystemForKeyPromise=function(e){var t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){var n=U(e.keyFormat),a=n?[n]:ue(this.config);return this.attemptKeySystemAccess(a)}return i},o.getKeySystemSelectionPromise=function(e){if(e.length||(e=ue(this.config)),e.length===0)throw new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)},o._onMediaEncrypted=function(e){var t=this,i=e.initDataType,n=e.initData;if(this.debug('"'+e.type+'" event: init data type: "'+i+'"'),n!==null){var a,r;if(i==="sinf"&&this.config.drmSystems[G.FAIRPLAY]){var s=(0,J.bin2str)(new Uint8Array(n));try{var l=V(JSON.parse(s).sinf),u=(0,J.parseSinf)(new Uint8Array(l));if(!u)return;a=u.subarray(8,24),r=G.FAIRPLAY}catch{return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var c=(0,J.parsePssh)(n);if(c===null)return;c.version===0&&c.systemId===ke.WIDEVINE&&c.data&&(a=c.data.subarray(8,24)),r=function(se){if(se===ke.WIDEVINE)return G.WIDEVINE}(c.systemId)}if(r&&a){for(var v=ri.default.hexDump(a),m=this.keyIdToKeySessionPromise,_=this.mediaKeySessions,S=m[v],P=function(se){var Ee=_[se],he=Ee.decryptdata;if(he.pssh||!he.keyId)return"continue";var Ae=ri.default.hexDump(he.keyId);return v===Ae||he.uri.replace(/-/g,"").indexOf(v)!==-1?(S=m[Ae],delete m[Ae],he.pssh=new Uint8Array(n),he.keyId=a,S=m[v]=S.then(function(){return t.generateRequestWithPreferredKeySession(Ee,i,n,"encrypted-event-key-match")}),"break"):void 0},I=0;I<_.length;I++){var q=P(I);if(q!=="continue"&&q==="break")break}S||(S=m[v]=this.getKeySystemSelectionPromise([r]).then(function(se){var Ee,he=se.keySystem,Ae=se.mediaKeys;t.throwIfDestroyed();var He=new De("ISO-23001-7",v,(Ee=A(he))!=null?Ee:"");return He.pssh=new Uint8Array(n),He.keyId=a,t.attemptSetMediaKeys(he,Ae).then(function(){t.throwIfDestroyed();var ze=t.createMediaKeySessionContext({decryptdata:He,keySystem:he,mediaKeys:Ae});return t.generateRequestWithPreferredKeySession(ze,i,n,"encrypted-event-no-match")})})),S.catch(function(se){return t.handleError(se)})}}},o._onWaitingForKey=function(e){this.log('"'+e.type+'" event')},o.attemptSetMediaKeys=function(e,t){var i=this,n=this.setMediaKeysQueue.slice();this.log('Setting media-keys for "'+e+'"');var a=Promise.all(n).then(function(){if(!i.media)throw new Error("Attempted to set mediaKeys without media element attached");return i.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(a),a.then(function(){i.log('Media-keys set for "'+e+'"'),n.push(a),i.setMediaKeysQueue=i.setMediaKeysQueue.filter(function(r){return n.indexOf(r)===-1})})},o.generateRequestWithPreferredKeySession=function(e,t,i,n){var a,r,s=this,l=(a=this.config.drmSystems)===null||a===void 0||(r=a[e.keySystem])===null||r===void 0?void 0:r.generateRequest;if(l)try{var u=l.call(this.hls,t,i,e);if(!u)throw new Error("Invalid response from configured generateRequest filter");t=u.initDataType,i=e.decryptdata.pssh=u.initData?new Uint8Array(u.initData):null}catch(S){var c;if(this.warn(S.message),(c=this.hls)!==null&&c!==void 0&&c.config.debug)throw S}if(i===null)return this.log('Skipping key-session request for "'+n+'" (no initData)'),Promise.resolve(e);var v=this.getKeyIdString(e.decryptdata);this.log('Generating key-session request for "'+n+'": '+v+" (init data type: "+t+" length: "+(i?i.byteLength:null)+")");var m=new($r());e.mediaKeysSession.onmessage=function(S){var P=e.mediaKeysSession;if(P){var I=S.messageType,q=S.message;s.log('"'+I+'" message event for session "'+P.sessionId+'" message size: '+q.byteLength),I==="license-request"||I==="license-renewal"?s.renewLicense(e,q).catch(function(se){s.handleError(se),m.emit("error",se)}):I==="license-release"?e.keySystem===G.FAIRPLAY&&(s.updateKeySession(e,E("acknowledged")),s.removeSession(e)):s.warn('unhandled media key message type "'+I+'"')}else m.emit("error",new Error("invalid state"))},e.mediaKeysSession.onkeystatuseschange=function(S){if(e.mediaKeysSession){s.onKeyStatusChange(e);var P=e.keyStatus;m.emit("keyStatus",P),P==="expired"&&(s.warn(e.keySystem+" expired for key "+v),s.renewKeySession(e))}else m.emit("error",new Error("invalid state"))};var _=new Promise(function(S,P){m.on("error",P),m.on("keyStatus",function(I){I.startsWith("usable")?S():I==="output-restricted"?P(new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):I==="internal-error"?P(new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},'key status changed to "'+I+'"')):I==="expired"?P(new Error("key expired while generating request")):s.warn('unhandled key status change "'+I+'"')})});return e.mediaKeysSession.generateRequest(t,i).then(function(){var S;s.log('Request generated for key-session "'+((S=e.mediaKeysSession)===null||S===void 0?void 0:S.sessionId)+'" keyId: '+v)}).catch(function(S){throw new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_NO_SESSION,error:S,fatal:!1},"Error generating key-session request: "+S)}).then(function(){return _}).catch(function(S){throw m.removeAllListeners(),s.removeSession(e),S}).then(function(){return m.removeAllListeners(),e})},o.onKeyStatusChange=function(e){var t=this;e.mediaKeysSession.keyStatuses.forEach(function(i,n){t.log('key status change "'+i+'" for keyStatuses keyId: '+ri.default.hexDump("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))+" session keyId: "+ri.default.hexDump(new Uint8Array(e.decryptdata.keyId||[]))+" uri: "+e.decryptdata.uri),e.keyStatus=i})},o.fetchServerCertificate=function(e){var t=this;return new Promise(function(i,n){var a=t.getServerCertificateUrl(e);if(!a)return i();t.log('Fetching serverCertificate for "'+e+'"');var r=new XMLHttpRequest;r.open("GET",a,!0),r.responseType="arraybuffer",r.onreadystatechange=function(){r.readyState===XMLHttpRequest.DONE&&(r.status===200?i(r.response):n(new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r},'"'+e+'" certificate request XHR failed ('+a+"). Status: "+r.status+" ("+r.statusText+")")))},r.send()})},o.setMediaKeysServerCertificate=function(e,t,i){var n=this;return new Promise(function(a,r){e.setServerCertificate(i).then(function(s){n.log("setServerCertificate "+(s?"success":"not supported by CDM")+" ("+(i==null?void 0:i.byteLength)+') on "'+t+'"'),a(e)}).catch(function(s){r(new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:s,fatal:!0},s.message))})})},o.renewLicense=function(e,t){var i=this;return this.requestLicense(e,new Uint8Array(t)).then(function(n){return i.updateKeySession(e,new Uint8Array(n)).catch(function(a){throw new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:a,fatal:!0},a.message)})})},o.setupLicenseXHR=function(e,t,i,n){var a=this,r=this.config.licenseXhrSetup;return r?Promise.resolve().then(function(){if(!i.decryptdata)throw new Error("Key removed");return r.call(a.hls,e,t,i,n)}).catch(function(s){if(!i.decryptdata)throw s;return e.open("POST",t,!0),r.call(a.hls,e,t,i,n)}).then(function(s){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:s||n}}):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))},o.requestLicense=function(e,t){var i=this;return new Promise(function(n,a){var r=i.getLicenseServerUrl(e.keySystem);i.log("Sending license request to URL: "+r);var s=new XMLHttpRequest;s.responseType="arraybuffer",s.onreadystatechange=function(){if(!i.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(s.readyState===4)if(s.status===200){i._requestLicenseFailureCount=0;var l=s.response;i.log("License received "+(l instanceof ArrayBuffer?l.byteLength:l));var u=i.config.licenseResponseCallback;if(u)try{l=u.call(i.hls,s,r,e)}catch(v){i.error(v)}n(l)}else if(i._requestLicenseFailureCount++,i._requestLicenseFailureCount>3||s.status>=400&&s.status<500)a(new wr({type:w.ErrorTypes.KEY_SYSTEM_ERROR,details:w.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:s},"License Request XHR failed ("+r+"). Status: "+s.status+" ("+s.statusText+")"));else{var c=3-i._requestLicenseFailureCount+1;i.warn("Retrying license request, "+c+" attempts left"),i.requestLicense(e,t).then(n,a)}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=s,i.setupLicenseXHR(s,r,e,t).then(function(l){var u=l.xhr,c=l.licenseChallenge;u.send(c)})})},o.onMediaAttached=function(e,t){if(this.config.emeEnabled){var i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}},o.onMediaDetached=function(){var e=this,t=this.media,i=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},De.clearKeyUriToKeyIdMap();var n=i.length;d.CDMCleanupPromise=Promise.all(i.map(function(a){return e.removeSession(a)}).concat(t==null?void 0:t.setMediaKeys(null).catch(function(a){e.log("Could not clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))}))).then(function(){n&&(e.log("finished closing key sessions and clearing media keys"),i.length=0)}).catch(function(a){e.log("Could not close sessions and clear media keys: "+a+". media.src: "+(t==null?void 0:t.src))})},o.onManifestLoaded=function(e,t){var i=t.sessionKeys;if(i&&this.config.emeEnabled&&!this.keyFormatPromise){var n=i.reduce(function(a,r){return a.indexOf(r.keyFormat)===-1&&a.push(r.keyFormat),a},[]);this.log("Selecting key-system from session-keys "+n.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(n)}},o.removeSession=function(e){var t=this,i=e.mediaKeysSession,n=e.licenseXhr;if(i){this.log("Remove licenses and keys and close session "+i.sessionId),i.onmessage=null,i.onkeystatuseschange=null,n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);return a>-1&&this.mediaKeySessions.splice(a,1),i.remove().catch(function(r){t.log("Could not remove session: "+r)}).then(function(){return i.close()}).catch(function(r){t.log("Could not close session: "+r)})}},d}();oa.CDMCleanupPromise=void 0;var wr=function(d){var o,e;function t(i,n){var a;return(a=d.call(this,n)||this).data=void 0,a.data=i,i.err=i.error,a}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Fi(o,e),t}(On(Error));let ns=oa;var lr,Fn,la;function ua(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}function da(d,o,e){return o&&ua(d.prototype,o),e&&ua(d,e),Object.defineProperty(d,"prototype",{writable:!1}),d}function ca(d,o){var e=typeof Symbol!="undefined"&&d[Symbol.iterator]||d["@@iterator"];if(e)return(e=e.call(d)).next.bind(e);if(Array.isArray(d)||(e=function(i,n){if(i){if(typeof i=="string")return ha(i,n);var a=Object.prototype.toString.call(i).slice(8,-1);return a==="Object"&&i.constructor&&(a=i.constructor.name),a==="Map"||a==="Set"?Array.from(i):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?ha(i,n):void 0}}(d))||o&&d&&typeof d.length=="number"){e&&(d=e);var t=0;return function(){return t>=d.length?{done:!0}:{done:!1,value:d[t++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
32
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ha(d,o){(o==null||o>d.length)&&(o=d.length);for(var e=0,t=new Array(o);e<o;e++)t[e]=d[e];return t}function un(){return un=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},un.apply(this,arguments)}(function(d){d.MANIFEST="m",d.AUDIO="a",d.VIDEO="v",d.MUXED="av",d.INIT="i",d.CAPTION="c",d.TIMED_TEXT="tt",d.KEY="k",d.OTHER="o"})(lr||(lr={})),function(d){d.DASH="d",d.HLS="h",d.SMOOTH="s",d.OTHER="o"}(Fn||(Fn={})),function(d){d.VOD="v",d.LIVE="l"}(la||(la={}));var as=function(){function d(e){var t=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){t.initialized&&(t.starved=!0),t.buffering=!0},this.onPlaying=function(){t.initialized||(t.initialized=!0),t.buffering=!1},this.applyPlaylistData=function(a){try{t.apply(a,{ot:lr.MANIFEST,su:!t.initialized})}catch(r){k.logger.warn("Could not generate manifest CMCD data.",r)}},this.applyFragmentData=function(a){try{var r=a.frag,s=t.hls.levels[r.level],l=t.getObjectType(r),u={d:1e3*r.duration,ot:l};l!==lr.VIDEO&&l!==lr.AUDIO&&l!=lr.MUXED||(u.br=s.bitrate/1e3,u.tb=t.getTopBandwidth(l)/1e3,u.bl=t.getBufferLength(l)),t.apply(a,u)}catch(c){k.logger.warn("Could not generate segment CMCD data.",c)}},this.hls=e;var i=this.config=e.config,n=i.cmcd;n!=null&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||d.uuid(),this.cid=n.contentId,this.useHeaders=n.useHeaders===!0,this.registerListeners())}var o=d.prototype;return o.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(p.Events.BUFFER_CREATED,this.onBufferCreated,this)},o.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(p.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},o.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},o.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},o.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},o.onBufferCreated=function(e,t){var i,n;this.audioBuffer=(i=t.tracks.audio)===null||i===void 0?void 0:i.buffer,this.videoBuffer=(n=t.tracks.video)===null||n===void 0?void 0:n.buffer},o.createData=function(){var e;return{v:1,sf:Fn.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},o.apply=function(e,t){t===void 0&&(t={}),un(t,this.createData());var i=t.ot===lr.INIT||t.ot===lr.VIDEO||t.ot===lr.MUXED;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){var n=d.toHeaders(t);if(!Object.keys(n).length)return;e.headers||(e.headers={}),un(e.headers,n)}else{var a=d.toQuery(t);if(!a)return;e.url=d.appendQueryToUri(e.url,a)}},o.getObjectType=function(e){var t=e.type;return t==="subtitle"?lr.TIMED_TEXT:e.sn==="initSegment"?lr.INIT:t==="audio"?lr.AUDIO:t==="main"?this.hls.audioTracks.length?lr.VIDEO:lr.MUXED:void 0},o.getTopBandwidth=function(e){var t,i=0,n=this.hls;if(e===lr.AUDIO)t=n.audioTracks;else{var a=n.maxAutoLevel,r=a>-1?a+1:n.levels.length;t=n.levels.slice(0,r)}for(var s,l=ca(t);!(s=l()).done;){var u=s.value;u.bitrate>i&&(i=u.bitrate)}return i>0?i:NaN},o.getBufferLength=function(e){var t=this.hls.media,i=e===lr.AUDIO?this.audioBuffer:this.videoBuffer;return i&&t?1e3*Mt.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN},o.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return function(){function n(r){this.loader=void 0,this.loader=new i(r)}var a=n.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(r,s,l){t(r),this.loader.load(r,s,l)},da(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},o.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return function(){function n(r){this.loader=void 0,this.loader=new i(r)}var a=n.prototype;return a.destroy=function(){this.loader.destroy()},a.abort=function(){this.loader.abort()},a.load=function(r,s,l){t(r),this.loader.load(r,s,l)},da(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},d.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},d.serialize=function(e){for(var t,i=[],n=function(S){return!Number.isNaN(S)&&S!=null&&S!==""&&S!==!1},a=function(S){return Math.round(S)},r=function(S){return 100*a(S/100)},s={br:a,d:a,bl:r,dl:r,mtp:r,nor:function(S){return encodeURIComponent(S)},rtp:r,tb:a},l=ca(Object.keys(e||{}).sort());!(t=l()).done;){var u=t.value,c=e[u];if(n(c)&&!(u==="v"&&c===1||u=="pr"&&c===1)){var v=s[u];v&&(c=v(c));var m,_=typeof c;m=u==="ot"||u==="sf"||u==="st"?u+"="+c:_==="boolean"?u:_==="number"?u+"="+c:u+"="+JSON.stringify(c),i.push(m)}}return i.join(",")},d.toHeaders=function(e){for(var t={},i=["Object","Request","Session","Status"],n=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},r=0,s=Object.keys(e);r<s.length;r++){var l=s[r];n[a[l]!=null?a[l]:1][l]=e[l]}for(var u=0;u<n.length;u++){var c=d.serialize(n[u]);c&&(t["CMCD-"+i[u]]=c)}return t},d.toQuery=function(e){return"CMCD="+encodeURIComponent(d.serialize(e))},d.appendQueryToUri=function(e,t){if(!t)return e;var i=e.includes("?")?"&":"?";return""+e+i+t},d}(),fa=N(408),ss=/^age:\s*[\d.]+\s*$/m;let va=function(){function d(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e?e.xhrSetup:null,this.stats=new fa.LoadStats,this.retryDelay=0}var o=d.prototype;return o.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},o.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))},o.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!==null&&e!==void 0&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},o.load=function(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.retryDelay=t.retryDelay,this.loadInternal()},o.loadInternal=function(){var e=this.config,t=this.context;if(e){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0;var a=this.xhrSetup;try{if(a)try{a(i,t.url)}catch{i.open("GET",t.url,!0),a(i,t.url)}i.readyState||i.open("GET",t.url,!0);var r=this.context.headers;if(r)for(var s in r)i.setRequestHeader(s,r[s])}catch(l){return void this.callbacks.onError({code:i.status,text:l.message},t,i)}t.rangeEnd&&i.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),i.onreadystatechange=this.readystatechange.bind(this),i.onprogress=this.loadprogress.bind(this),i.responseType=t.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout),i.send()}},o.readystatechange=function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!i.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start)),n===4){t.onreadystatechange=null,t.onprogress=null;var r=t.status,s=t.responseType==="arraybuffer";if(r>=200&&r<300&&(s&&t.response||t.responseText!==null)){var l,u;if(i.loading.end=Math.max(self.performance.now(),i.loading.first),u=s?(l=t.response).byteLength:(l=t.responseText).length,i.loaded=i.total=u,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(i,e,l,t),!this.callbacks)return;var v={url:t.responseURL,data:l};this.callbacks.onSuccess(v,i,e,t)}else i.retry>=a.maxRetry||r>=400&&r<499?(k.logger.error(r+" while loading "+e.url),this.callbacks.onError({code:r,text:t.statusText},e,t)):(k.logger.warn(r+" while loading "+e.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),i.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}},o.loadtimeout=function(){k.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},o.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},o.getCacheAge=function(){var e=null;if(this.loader&&ss.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},d}();function Mn(d){var o=typeof Map=="function"?new Map:void 0;return Mn=function(e){if(e===null||(t=e,Function.toString.call(t).indexOf("[native code]")===-1))return e;var t;if(typeof e!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(e))return o.get(e);o.set(e,i)}function i(){return Nn(e,arguments,Un(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Mi(i,e)},Mn(d)}function Nn(d,o,e){return Nn=os()?Reflect.construct.bind():function(t,i,n){var a=[null];a.push.apply(a,i);var r=new(Function.bind.apply(t,a));return n&&Mi(r,n.prototype),r},Nn.apply(null,arguments)}function os(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Mi(d,o){return Mi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Mi(d,o)}function Un(d){return Un=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},Un(d)}function Bn(){return Bn=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},Bn.apply(this,arguments)}var ls=function(){function d(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||us,this.controller=new self.AbortController,this.stats=new fa.LoadStats}var o=d.prototype;return o.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},o.abortInternal=function(){var e=this.response;e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},o.abort=function(){var e;this.abortInternal(),(e=this.callbacks)!==null&&e!==void 0&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},o.load=function(e,t,i){var n=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var r=function(c,v){var m={method:"GET",mode:"cors",credentials:"same-origin",signal:v,headers:new self.Headers(Bn({},c.headers))};return c.rangeEnd&&m.headers.set("Range","bytes="+c.rangeStart+"-"+String(c.rangeEnd-1)),m}(e,this.controller.signal),s=i.onProgress,l=e.responseType==="arraybuffer",u=l?"byteLength":"length";this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,r),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){n.abortInternal(),i.onTimeout(a,e,n.response)},t.timeout),self.fetch(this.request).then(function(c){if(n.response=n.loader=c,!c.ok){var v=c.status,m=c.statusText;throw new ds(m||"fetch, bad network response",v,c)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(c.headers.get("Content-Length")||"0"),s&&(0,R.isFiniteNumber)(t.highWaterMark)?n.loadProgressively(c,a,e,t.highWaterMark,s):l?c.arrayBuffer():c.text()}).then(function(c){var v=n.response;self.clearTimeout(n.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var m=c[u];m&&(a.loaded=a.total=m);var _={url:v.url,data:c};s&&!(0,R.isFiniteNumber)(t.highWaterMark)&&s(a,e,c,v),i.onSuccess(_,a,e,v)}).catch(function(c){if(self.clearTimeout(n.requestTimeout),!a.aborted){var v=c&&c.code||0,m=c?c.message:null;i.onError({code:v,text:m},e,c?c.details:null)}})},o.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},o.loadProgressively=function(e,t,i,n,a){n===void 0&&(n=0);var r=new nn,s=e.body.getReader();return function l(){return s.read().then(function(u){if(u.done)return r.dataLength&&a(t,i,r.flush(),e),Promise.resolve(new ArrayBuffer(0));var c=u.value,v=c.length;return t.loaded+=v,v<n||r.dataLength?(r.push(c),r.dataLength>=n&&a(t,i,r.flush(),e)):a(t,i,c,e),l()}).catch(function(){return Promise.reject()})}()},d}();function us(d,o){return new self.Request(d.url,o)}var ds=function(d){var o,e;function t(i,n,a){var r;return(r=d.call(this,i)||this).code=void 0,r.details=void 0,r.code=n,r.details=a,r}return e=d,(o=t).prototype=Object.create(e.prototype),o.prototype.constructor=o,Mi(o,e),t}(Mn(Error));let ga=ls;var cs=/\s/;function jn(){return jn=Object.assign?Object.assign.bind():function(d){for(var o=1;o<arguments.length;o++){var e=arguments[o];for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(d[t]=e[t])}return d},jn.apply(this,arguments)}function pa(d,o){var e=Object.keys(d);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(d);o&&(t=t.filter(function(i){return Object.getOwnPropertyDescriptor(d,i).enumerable})),e.push.apply(e,t)}return e}function ma(d){for(var o=1;o<arguments.length;o++){var e=arguments[o]!=null?arguments[o]:{};o%2?pa(Object(e),!0).forEach(function(t){hs(d,t,e[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(e)):pa(Object(e)).forEach(function(t){Object.defineProperty(d,t,Object.getOwnPropertyDescriptor(e,t))})}return d}function hs(d,o,e){return(o=function(t){var i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t,"string");return typeof i=="symbol"?i:String(i)}(o))in d?Object.defineProperty(d,o,{value:e,enumerable:!0,configurable:!0,writable:!0}):d[o]=e,d}var fs=ma(ma({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:va,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:bn,bufferController:Ln,capLevelController:ts,fpsController:rs,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Te,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:{newCue:function(d,o,e,t){for(var i,n,a,r,s,l=[],u=self.VTTCue||self.TextTrackCue,c=0;c<t.rows.length;c++)if(a=!0,r=0,s="",!(i=t.rows[c]).isEmpty()){for(var v=0;v<i.chars.length;v++)cs.test(i.chars[v].uchar)&&a?r++:(s+=i.chars[v].uchar,a=!1);i.cueStartTime=o,o===e&&(e+=1e-4),r>=16?r--:r++;var m=qt(s.trim()),_=or(o,e,m);d&&d.cues&&d.cues.getCueById(_)||((n=new u(o,e,m)).id=_,n.line=c+1,n.align="left",n.position=10+Math.min(80,10*Math.floor(8*r/32)),l.push(n))}return d&&l.length&&(l.sort(function(S,P){return S.line==="auto"||P.line==="auto"?0:S.line>8&&P.line>8?P.line-S.line:S.line-P.line}),l.forEach(function(S){return yt(d,S)})),l}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:An,subtitleTrackController:Dn,timelineController:$a,audioStreamController:Ci,audioTrackController:_n,emeController:ns,cmcdController:as});function ya(d,o){for(var e=0;e<o.length;e++){var t=o[e];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(d,typeof(i=function(n,a){if(typeof n!="object"||n===null)return n;var r=n[Symbol.toPrimitive];if(r!==void 0){var s=r.call(n,a);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}(t.key,"string"))=="symbol"?i:String(i),t)}var i}var Ea=function(){function d(n){n===void 0&&(n={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Di.EventEmitter,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var a=this.config=function(be,Ge){if((Ge.liveSyncDurationCount||Ge.liveMaxLatencyDurationCount)&&(Ge.liveSyncDuration||Ge.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(Ge.liveMaxLatencyDurationCount!==void 0&&(Ge.liveSyncDurationCount===void 0||Ge.liveMaxLatencyDurationCount<=Ge.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(Ge.liveMaxLatencyDuration!==void 0&&(Ge.liveSyncDuration===void 0||Ge.liveMaxLatencyDuration<=Ge.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return jn({},be,Ge)}(d.DefaultConfig,n);this.userConfig=n,(0,k.enableLogs)(a.debug,"Hls instance"),this._autoLevelCapping=-1,a.progressive&&function(be){var Ge=be.loader;Ge!==ga&&Ge!==va?(k.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),be.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}()&&(be.loader=ga,be.progressive=!0,be.enableSoftwareAES=!0,k.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}(a);var r=a.abrController,s=a.bufferController,l=a.capLevelController,u=a.fpsController,c=this.abrController=new r(this),v=this.bufferController=new s(this),m=this.capLevelController=new l(this),_=new u(this),S=new Ye(this),P=new Rt(this),I=this.levelController=new ot(this),q=new bt(this),se=new cr(this.config),Ee=this.streamController=new yn(this,q,se);m.setStreamController(Ee),_.setStreamController(Ee);var he=[S,I,Ee];this.networkControllers=he;var Ae=[c,v,m,_,P,q];this.audioTrackController=this.createController(a.audioTrackController,he);var He=a.audioStreamController;He&&he.push(new He(this,q,se)),this.subtitleTrackController=this.createController(a.subtitleTrackController,he);var ze=a.subtitleStreamController;ze&&he.push(new ze(this,q,se)),this.createController(a.timelineController,Ae),se.emeController=this.emeController=this.createController(a.emeController,Ae),this.cmcdController=this.createController(a.cmcdController,Ae),this.latencyController=this.createController(Ht,Ae),this.coreComponents=Ae}d.isSupported=function(){return function(){var n=hi();if(!n)return!1;var a=fi(),r=n&&typeof n.isTypeSupported=="function"&&n.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),s=!a||a.prototype&&typeof a.prototype.appendBuffer=="function"&&typeof a.prototype.remove=="function";return!!r&&!!s}()};var o,e,t,i=d.prototype;return i.createController=function(n,a){if(n){var r=new n(this);return a&&a.push(r),r}return null},i.on=function(n,a,r){r===void 0&&(r=this),this._emitter.on(n,a,r)},i.once=function(n,a,r){r===void 0&&(r=this),this._emitter.once(n,a,r)},i.removeAllListeners=function(n){this._emitter.removeAllListeners(n)},i.off=function(n,a,r,s){r===void 0&&(r=this),this._emitter.off(n,a,r,s)},i.listeners=function(n){return this._emitter.listeners(n)},i.emit=function(n,a,r){return this._emitter.emit(n,a,r)},i.trigger=function(n,a){if(this.config.debug)return this.emit(n,n,a);try{return this.emit(n,n,a)}catch(r){k.logger.error("An internal error happened while handling event "+n+'. Error message: "'+r.message+'". Here is a stacktrace:',r),this.trigger(p.Events.ERROR,{type:w.ErrorTypes.OTHER_ERROR,details:w.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:n,error:r})}return!1},i.listenerCount=function(n){return this._emitter.listenerCount(n)},i.destroy=function(){k.logger.log("destroy"),this.trigger(p.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(n){return n.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(n){return n.destroy()}),this.coreComponents.length=0},i.attachMedia=function(n){k.logger.log("attachMedia"),this._media=n,this.trigger(p.Events.MEDIA_ATTACHING,{media:n})},i.detachMedia=function(){k.logger.log("detachMedia"),this.trigger(p.Events.MEDIA_DETACHING,void 0),this._media=null},i.loadSource=function(n){this.stopLoad();var a=this.media,r=this.url,s=this.url=te.buildAbsoluteURL(self.location.href,n,{alwaysNormalize:!0});k.logger.log("loadSource:"+s),a&&r&&r!==s&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(a)),this.trigger(p.Events.MANIFEST_LOADING,{url:n})},i.startLoad=function(n){n===void 0&&(n=-1),k.logger.log("startLoad("+n+")"),this.networkControllers.forEach(function(a){a.startLoad(n)})},i.stopLoad=function(){k.logger.log("stopLoad"),this.networkControllers.forEach(function(n){n.stopLoad()})},i.swapAudioCodec=function(){k.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},i.recoverMediaError=function(){k.logger.log("recoverMediaError");var n=this._media;this.detachMedia(),n&&this.attachMedia(n)},i.removeLevel=function(n,a){a===void 0&&(a=0),this.levelController.removeLevel(n,a)},o=d,t=[{key:"version",get:function(){return"1.3.1"}},{key:"Events",get:function(){return p.Events}},{key:"ErrorTypes",get:function(){return w.ErrorTypes}},{key:"ErrorDetails",get:function(){return w.ErrorDetails}},{key:"DefaultConfig",get:function(){return d.defaultConfig?d.defaultConfig:fs},set:function(n){d.defaultConfig=n}}],(e=[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(n){k.logger.log("set currentLevel:"+n),this.loadLevel=n,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(n){k.logger.log("set nextLevel:"+n),this.levelController.manualLevel=n,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(n){k.logger.log("set loadLevel:"+n),this.levelController.manualLevel=n}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(n){this.levelController.nextLoadLevel=n}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(n){k.logger.log("set firstLevel:"+n),this.levelController.firstLevel=n}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(n){k.logger.log("set startLevel:"+n),n!==-1&&(n=Math.max(n,this.minAutoLevel)),this.levelController.startLevel=n}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(n){var a=!!n;a!==this.config.capLevelToPlayerSize&&(a?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=a)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(n){this._autoLevelCapping!==n&&(k.logger.log("set autoLevelCapping:"+n),this._autoLevelCapping=n)}},{key:"bandwidthEstimate",get:function(){var n=this.abrController.bwEstimator;return n?n.getEstimate():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(n){ur.indexOf(n)>-1&&(this._maxHdcpLevel=n)}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var n=this.levels,a=this.config.minAutoBitrate;if(!n)return 0;for(var r=n.length,s=0;s<r;s++)if(n[s].maxBitrate>=a)return s;return 0}},{key:"maxAutoLevel",get:function(){var n,a=this.levels,r=this.autoLevelCapping,s=this.maxHdcpLevel;if(n=r===-1&&a&&a.length?a.length-1:r,s)for(var l=n;l--;){var u=a[l].attrs["HDCP-LEVEL"];if(u&&u<=s)return l}return n}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(n){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,n)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var n=this.audioTrackController;return n?n.audioTracks:[]}},{key:"audioTrack",get:function(){var n=this.audioTrackController;return n?n.audioTrack:-1},set:function(n){var a=this.audioTrackController;a&&(a.audioTrack=n)}},{key:"subtitleTracks",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var n=this.subtitleTrackController;return n?n.subtitleTrack:-1},set:function(n){var a=this.subtitleTrackController;a&&(a.subtitleTrack=n)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var n=this.subtitleTrackController;return!!n&&n.subtitleDisplay},set:function(n){var a=this.subtitleTrackController;a&&(a.subtitleDisplay=n)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(n){this.config.lowLatencyMode=n}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&ya(o.prototype,e),t&&ya(o,t),Object.defineProperty(o,"prototype",{writable:!1}),d}();Ea.defaultConfig=void 0},923:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{BaseSegment:()=>de,ElementaryStreamTypes:()=>j,Fragment:()=>_e,Part:()=>K});var j,te=N(965),R=N(945),p=N(408);function w(ve,$){ve.prototype=Object.create($.prototype),ve.prototype.constructor=ve,k(ve,$)}function k(ve,$){return k=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(ae,G){return ae.__proto__=G,ae},k(ve,$)}function me(ve,$){for(var ae=0;ae<$.length;ae++){var G=$[ae];G.enumerable=G.enumerable||!1,G.configurable=!0,"value"in G&&(G.writable=!0),Object.defineProperty(ve,typeof(Se=function(ke,je){if(typeof ke!="object"||ke===null)return ke;var V=ke[Symbol.toPrimitive];if(V!==void 0){var E=V.call(ke,je);if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(ke)}(G.key,"string"))=="symbol"?Se:String(Se),G)}var Se}function re(ve,$,ae){return $&&me(ve.prototype,$),ae&&me(ve,ae),Object.defineProperty(ve,"prototype",{writable:!1}),ve}(function(ve){ve.AUDIO="audio",ve.VIDEO="video",ve.AUDIOVIDEO="audiovideo"})(j||(j={}));var de=function(){function ve($){var ae;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((ae={})[j.AUDIO]=null,ae[j.VIDEO]=null,ae[j.AUDIOVIDEO]=null,ae),this.baseurl=$}return ve.prototype.setByteRange=function($,ae){var G=$.split("@",2),Se=[];G.length===1?Se[0]=ae?ae.byteRangeEndOffset:0:Se[0]=parseInt(G[1]),Se[1]=parseInt(G[0])+Se[0],this._byteRange=Se},re(ve,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,R.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function($){this._url=$}}]),ve}(),_e=function(ve){function $(G,Se){var ke;return(ke=ve.call(this,Se)||this)._decryptdata=null,ke.rawProgramDateTime=null,ke.programDateTime=null,ke.tagList=[],ke.duration=0,ke.sn=0,ke.levelkeys=void 0,ke.type=void 0,ke.loader=null,ke.keyLoader=null,ke.level=-1,ke.cc=0,ke.startPTS=void 0,ke.endPTS=void 0,ke.appendedPTS=void 0,ke.startDTS=void 0,ke.endDTS=void 0,ke.start=0,ke.deltaPTS=void 0,ke.maxStartPTS=void 0,ke.minEndPTS=void 0,ke.stats=new p.LoadStats,ke.urlId=0,ke.data=void 0,ke.bitrateTest=!1,ke.title=null,ke.initSegment=null,ke.endList=void 0,ke.type=G,ke}w($,ve);var ae=$.prototype;return ae.setKeyFormat=function(G){if(this.levelkeys){var Se=this.levelkeys[G];Se&&!this._decryptdata&&(this._decryptdata=Se.getDecryptData(this.sn))}},ae.abortRequests=function(){var G,Se;(G=this.loader)===null||G===void 0||G.abort(),(Se=this.keyLoader)===null||Se===void 0||Se.abort()},ae.setElementaryStreamInfo=function(G,Se,ke,je,V,E){E===void 0&&(E=!1);var U=this.elementaryStreams,A=U[G];A?(A.startPTS=Math.min(A.startPTS,Se),A.endPTS=Math.max(A.endPTS,ke),A.startDTS=Math.min(A.startDTS,je),A.endDTS=Math.max(A.endDTS,V)):U[G]={startPTS:Se,endPTS:ke,startDTS:je,endDTS:V,partial:E}},ae.clearElementaryStreamInfo=function(){var G=this.elementaryStreams;G[j.AUDIO]=null,G[j.VIDEO]=null,G[j.AUDIOVIDEO]=null},re($,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var G=this.levelkeys.identity;if(G)this._decryptdata=G.getDecryptData(this.sn);else{var Se=Object.keys(this.levelkeys);if(Se.length===1)return this._decryptdata=this.levelkeys[Se[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!(0,te.isFiniteNumber)(this.programDateTime))return null;var G=(0,te.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*G}},{key:"encrypted",get:function(){var G;if((G=this._decryptdata)!==null&&G!==void 0&&G.encrypted)return!0;if(this.levelkeys){var Se=Object.keys(this.levelkeys),ke=Se.length;if(ke>1||ke===1&&this.levelkeys[Se[0]].encrypted)return!0}return!1}}]),$}(de),K=function(ve){function $(ae,G,Se,ke,je){var V;(V=ve.call(this,Se)||this).fragOffset=0,V.duration=0,V.gap=!1,V.independent=!1,V.relurl=void 0,V.fragment=void 0,V.index=void 0,V.stats=new p.LoadStats,V.duration=ae.decimalFloatingPoint("DURATION"),V.gap=ae.bool("GAP"),V.independent=ae.bool("INDEPENDENT"),V.relurl=ae.enumeratedString("URI"),V.fragment=G,V.index=ke;var E=ae.enumeratedString("BYTERANGE");return E&&V.setByteRange(E,je),je&&(V.fragOffset=je.fragOffset+je.duration),V}return w($,ve),re($,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var ae=this.elementaryStreams;return!!(ae.audio||ae.video||ae.audiovideo)}}]),$}(de)},408:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{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,Q,N)=>{"use strict";N.r(Q),N.d(Q,{MAX_SAFE_INTEGER:()=>te,isFiniteNumber:()=>j});var j=Number.isFinite||function(R){return typeof R=="number"&&isFinite(R)},te=Number.MAX_SAFE_INTEGER||9007199254740991},524:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{default:()=>ae,flushTextTrackMetadataCueSamples:()=>Se,flushTextTrackUserdataCueSamples:()=>ke,normalizePts:()=>G});var j=N(965);let te=function(){function E(){}return E.getSilentFrame=function(U,A){if(U==="mp4a.40.2"){if(A===1)return new Uint8Array([0,200,0,128,35,128]);if(A===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(A===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(A===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(A===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(A===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(A===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(A===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(A===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},E}();var R=Math.pow(2,32)-1,p=function(){function E(){}return E.init=function(){var U;for(U in E.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},E.types)E.types.hasOwnProperty(U)&&(E.types[U]=[U.charCodeAt(0),U.charCodeAt(1),U.charCodeAt(2),U.charCodeAt(3)]);var A=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),ue=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);E.HDLR_TYPES={video:A,audio:ue};var Te=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),J=new Uint8Array([0,0,0,0,0,0,0,0]);E.STTS=E.STSC=E.STCO=J,E.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),E.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),E.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),E.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var W=new Uint8Array([105,115,111,109]),De=new Uint8Array([97,118,99,49]),Re=new Uint8Array([0,0,0,1]);E.FTYP=E.box(E.types.ftyp,W,Re,W,De),E.DINF=E.box(E.types.dinf,E.box(E.types.dref,Te))},E.box=function(U){for(var A=8,ue=arguments.length,Te=new Array(ue>1?ue-1:0),J=1;J<ue;J++)Te[J-1]=arguments[J];for(var W=Te.length,De=W;W--;)A+=Te[W].byteLength;var Re=new Uint8Array(A);for(Re[0]=A>>24&255,Re[1]=A>>16&255,Re[2]=A>>8&255,Re[3]=255&A,Re.set(U,4),W=0,A=8;W<De;W++)Re.set(Te[W],A),A+=Te[W].byteLength;return Re},E.hdlr=function(U){return E.box(E.types.hdlr,E.HDLR_TYPES[U])},E.mdat=function(U){return E.box(E.types.mdat,U)},E.mdhd=function(U,A){A*=U;var ue=Math.floor(A/(R+1)),Te=Math.floor(A%(R+1));return E.box(E.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,255&U,ue>>24,ue>>16&255,ue>>8&255,255&ue,Te>>24,Te>>16&255,Te>>8&255,255&Te,85,196,0,0]))},E.mdia=function(U){return E.box(E.types.mdia,E.mdhd(U.timescale,U.duration),E.hdlr(U.type),E.minf(U))},E.mfhd=function(U){return E.box(E.types.mfhd,new Uint8Array([0,0,0,0,U>>24,U>>16&255,U>>8&255,255&U]))},E.minf=function(U){return U.type==="audio"?E.box(E.types.minf,E.box(E.types.smhd,E.SMHD),E.DINF,E.stbl(U)):E.box(E.types.minf,E.box(E.types.vmhd,E.VMHD),E.DINF,E.stbl(U))},E.moof=function(U,A,ue){return E.box(E.types.moof,E.mfhd(U),E.traf(ue,A))},E.moov=function(U){for(var A=U.length,ue=[];A--;)ue[A]=E.trak(U[A]);return E.box.apply(null,[E.types.moov,E.mvhd(U[0].timescale,U[0].duration)].concat(ue).concat(E.mvex(U)))},E.mvex=function(U){for(var A=U.length,ue=[];A--;)ue[A]=E.trex(U[A]);return E.box.apply(null,[E.types.mvex].concat(ue))},E.mvhd=function(U,A){A*=U;var ue=Math.floor(A/(R+1)),Te=Math.floor(A%(R+1)),J=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,U>>24&255,U>>16&255,U>>8&255,255&U,ue>>24,ue>>16&255,ue>>8&255,255&ue,Te>>24,Te>>16&255,Te>>8&255,255&Te,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return E.box(E.types.mvhd,J)},E.sdtp=function(U){var A,ue,Te=U.samples||[],J=new Uint8Array(4+Te.length);for(A=0;A<Te.length;A++)ue=Te[A].flags,J[A+4]=ue.dependsOn<<4|ue.isDependedOn<<2|ue.hasRedundancy;return E.box(E.types.sdtp,J)},E.stbl=function(U){return E.box(E.types.stbl,E.stsd(U),E.box(E.types.stts,E.STTS),E.box(E.types.stsc,E.STSC),E.box(E.types.stsz,E.STSZ),E.box(E.types.stco,E.STCO))},E.avc1=function(U){var A,ue,Te,J=[],W=[];for(A=0;A<U.sps.length;A++)Te=(ue=U.sps[A]).byteLength,J.push(Te>>>8&255),J.push(255&Te),J=J.concat(Array.prototype.slice.call(ue));for(A=0;A<U.pps.length;A++)Te=(ue=U.pps[A]).byteLength,W.push(Te>>>8&255),W.push(255&Te),W=W.concat(Array.prototype.slice.call(ue));var De=E.box(E.types.avcC,new Uint8Array([1,J[3],J[4],J[5],255,224|U.sps.length].concat(J).concat([U.pps.length]).concat(W))),Re=U.width,Oe=U.height,ye=U.pixelRatio[0],qe=U.pixelRatio[1];return E.box(E.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,Re>>8&255,255&Re,Oe>>8&255,255&Oe,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),De,E.box(E.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),E.box(E.types.pasp,new Uint8Array([ye>>24,ye>>16&255,ye>>8&255,255&ye,qe>>24,qe>>16&255,qe>>8&255,255&qe])))},E.esds=function(U){var A=U.config.length;return new Uint8Array([0,0,0,0,3,23+A,0,1,0,4,15+A,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([A]).concat(U.config).concat([6,1,2]))},E.mp4a=function(U){var A=U.samplerate;return E.box(E.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,A>>8&255,255&A,0,0]),E.box(E.types.esds,E.esds(U)))},E.mp3=function(U){var A=U.samplerate;return E.box(E.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,U.channelCount,0,16,0,0,0,0,A>>8&255,255&A,0,0]))},E.stsd=function(U){return U.type==="audio"?U.segmentCodec==="mp3"&&U.codec==="mp3"?E.box(E.types.stsd,E.STSD,E.mp3(U)):E.box(E.types.stsd,E.STSD,E.mp4a(U)):E.box(E.types.stsd,E.STSD,E.avc1(U))},E.tkhd=function(U){var A=U.id,ue=U.duration*U.timescale,Te=U.width,J=U.height,W=Math.floor(ue/(R+1)),De=Math.floor(ue%(R+1));return E.box(E.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,A>>24&255,A>>16&255,A>>8&255,255&A,0,0,0,0,W>>24,W>>16&255,W>>8&255,255&W,De>>24,De>>16&255,De>>8&255,255&De,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,Te>>8&255,255&Te,0,0,J>>8&255,255&J,0,0]))},E.traf=function(U,A){var ue=E.sdtp(U),Te=U.id,J=Math.floor(A/(R+1)),W=Math.floor(A%(R+1));return E.box(E.types.traf,E.box(E.types.tfhd,new Uint8Array([0,0,0,0,Te>>24,Te>>16&255,Te>>8&255,255&Te])),E.box(E.types.tfdt,new Uint8Array([1,0,0,0,J>>24,J>>16&255,J>>8&255,255&J,W>>24,W>>16&255,W>>8&255,255&W])),E.trun(U,ue.length+16+20+8+16+8+8),ue)},E.trak=function(U){return U.duration=U.duration||4294967295,E.box(E.types.trak,E.tkhd(U),E.mdia(U))},E.trex=function(U){var A=U.id;return E.box(E.types.trex,new Uint8Array([0,0,0,0,A>>24,A>>16&255,A>>8&255,255&A,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},E.trun=function(U,A){var ue,Te,J,W,De,Re,Oe=U.samples||[],ye=Oe.length,qe=12+16*ye,tt=new Uint8Array(qe);for(A+=8+qe,tt.set([U.type==="video"?1:0,0,15,1,ye>>>24&255,ye>>>16&255,ye>>>8&255,255&ye,A>>>24&255,A>>>16&255,A>>>8&255,255&A],0),ue=0;ue<ye;ue++)J=(Te=Oe[ue]).duration,W=Te.size,De=Te.flags,Re=Te.cts,tt.set([J>>>24&255,J>>>16&255,J>>>8&255,255&J,W>>>24&255,W>>>16&255,W>>>8&255,255&W,De.isLeading<<2|De.dependsOn,De.isDependedOn<<6|De.hasRedundancy<<4|De.paddingValue<<1|De.isNonSync,61440&De.degradPrio,15&De.degradPrio,Re>>>24&255,Re>>>16&255,Re>>>8&255,255&Re],12+16*ue);return E.box(E.types.trun,tt)},E.initSegment=function(U){E.types||E.init();var A=E.moov(U),ue=new Uint8Array(E.FTYP.byteLength+A.byteLength);return ue.set(E.FTYP),ue.set(A,E.FTYP.byteLength),ue},E}();p.types=void 0,p.HDLR_TYPES=void 0,p.STTS=void 0,p.STSC=void 0,p.STCO=void 0,p.STSZ=void 0,p.VMHD=void 0,p.SMHD=void 0,p.STSD=void 0,p.FTYP=void 0,p.DINF=void 0;let w=p;var k=N(851),me=N(973),re=N(93),de=N(308),_e=N(673);function K(){return K=Object.assign?Object.assign.bind():function(E){for(var U=1;U<arguments.length;U++){var A=arguments[U];for(var ue in A)Object.prototype.hasOwnProperty.call(A,ue)&&(E[ue]=A[ue])}return E},K.apply(this,arguments)}var ve=null,$=null,ae=function(){function E(A,ue,Te,J){if(J===void 0&&(J=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=A,this.config=ue,this.typeSupported=Te,this.ISGenerated=!1,ve===null){var W=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ve=W?parseInt(W[1]):0}if($===null){var De=navigator.userAgent.match(/Safari\/(\d+)/i);$=De?parseInt(De[1]):0}}var U=E.prototype;return U.destroy=function(){},U.resetTimeStamp=function(A){re.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=A},U.resetNextTimestamp=function(){re.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},U.resetInitSegment=function(){re.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},U.getVideoStartPts=function(A){var ue=!1,Te=A.reduce(function(J,W){var De=W.pts-J;return De<-4294967296?(ue=!0,G(J,W.pts)):De>0?J:W.pts},A[0].pts);return ue&&re.logger.debug("PTS rollover detected"),Te},U.remux=function(A,ue,Te,J,W,De,Re,Oe){var ye,qe,tt,ie,ce,ne,xe=W,Pe=W,Ne=A.pid>-1,Be=ue.pid>-1,Ke=ue.samples.length,pe=A.samples.length>0,Ie=Re&&Ke>0||Ke>1;if((!Ne||pe)&&(!Be||Ie)||this.ISGenerated||Re){this.ISGenerated||(tt=this.generateIS(A,ue,W));var Ye,rt=this.isVideoContiguous,yt=-1;if(Ie&&(yt=function(At){for(var pt=0;pt<At.length;pt++)if(At[pt].key)return pt;return-1}(ue.samples),!rt&&this.config.forceKeyFrameOnDiscontinuity))if(ne=!0,yt>0){re.logger.warn("[mp4-remuxer]: Dropped "+yt+" out of "+Ke+" video samples due to a missing keyframe");var ht=this.getVideoStartPts(ue.samples);ue.samples=ue.samples.slice(yt),ue.dropped+=yt,Ye=Pe+=(ue.samples[0].pts-ht)/ue.inputTimeScale}else yt===-1&&(re.logger.warn("[mp4-remuxer]: No keyframe found out of "+Ke+" video samples"),ne=!1);if(this.ISGenerated){if(pe&&Ie){var It=this.getVideoStartPts(ue.samples),Lt=(G(A.samples[0].pts,It)-It)/ue.inputTimeScale;xe+=Math.max(0,Lt),Pe+=Math.max(0,-Lt)}if(pe){if(A.samplerate||(re.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),tt=this.generateIS(A,ue,W)),qe=this.remuxAudio(A,xe,this.isAudioContiguous,De,Be||Ie||Oe===de.PlaylistLevelType.AUDIO?Pe:void 0),Ie){var St=qe?qe.endPTS-qe.startPTS:0;ue.inputTimeScale||(re.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),tt=this.generateIS(A,ue,W)),ye=this.remuxVideo(ue,Pe,rt,St)}}else Ie&&(ye=this.remuxVideo(ue,Pe,rt,0));ye&&(ye.firstKeyFrame=yt,ye.independent=yt!==-1,ye.firstKeyFramePTS=Ye)}}return this.ISGenerated&&(Te.samples.length&&(ce=Se(Te,W,this._initPTS,this._initDTS)),J.samples.length&&(ie=ke(J,W,this._initPTS))),{audio:qe,video:ye,initSegment:tt,independent:ne,text:ie,id3:ce}},U.generateIS=function(A,ue,Te){var J,W,De,Re=A.samples,Oe=ue.samples,ye=this.typeSupported,qe={},tt=!(0,j.isFiniteNumber)(this._initPTS),ie="audio/mp4";if(tt&&(J=W=1/0),A.config&&Re.length&&(A.timescale=A.samplerate,A.segmentCodec==="mp3"&&(ye.mpeg?(ie="audio/mpeg",A.codec=""):ye.mp3&&(A.codec="mp3")),qe.audio={id:"audio",container:ie,codec:A.codec,initSegment:A.segmentCodec==="mp3"&&ye.mpeg?new Uint8Array(0):w.initSegment([A]),metadata:{channelCount:A.channelCount}},tt&&(De=A.inputTimeScale,J=W=Re[0].pts-Math.round(De*Te))),ue.sps&&ue.pps&&Oe.length&&(ue.timescale=ue.inputTimeScale,qe.video={id:"main",container:"video/mp4",codec:ue.codec,initSegment:w.initSegment([ue]),metadata:{width:ue.width,height:ue.height}},tt)){De=ue.inputTimeScale;var ce=this.getVideoStartPts(Oe),ne=Math.round(De*Te);W=Math.min(W,G(Oe[0].dts,ce)-ne),J=Math.min(J,ce-ne)}if(Object.keys(qe).length)return this.ISGenerated=!0,tt&&(this._initPTS=J,this._initDTS=W),{tracks:qe,initPTS:J,timescale:De}},U.remuxVideo=function(A,ue,Te,J){var W,De,Re=A.inputTimeScale,Oe=A.samples,ye=[],qe=Oe.length,tt=this._initPTS,ie=this.nextAvcDts,ce=8,ne=this.videoSampleDuration,xe=Number.POSITIVE_INFINITY,Pe=Number.NEGATIVE_INFINITY,Ne=!1;Te&&ie!==null||(ie=ue*Re-(Oe[0].pts-G(Oe[0].dts,Oe[0].pts)));for(var Be=0;Be<qe;Be++){var Ke=Oe[Be];Ke.pts=G(Ke.pts-tt,ie),Ke.dts=G(Ke.dts-tt,ie),Ke.dts<Oe[Be>0?Be-1:Be].dts&&(Ne=!0)}Ne&&Oe.sort(function(Yt,cr){var Ir=Yt.dts-cr.dts,dr=Yt.pts-cr.pts;return Ir||dr}),W=Oe[0].dts;var pe=Oe[Oe.length-1].dts-W,Ie=pe?Math.round(pe/(qe-1)):ne||A.inputTimeScale/30;if(Te){var Ye=W-ie,rt=Ye>Ie,yt=Ye<-1;if((rt||yt)&&(rt?re.logger.warn("AVC: "+(0,_e.toMsFromMpegTsClock)(Ye,!0)+" ms ("+Ye+"dts) hole between fragments detected, filling it"):re.logger.warn("AVC: "+(0,_e.toMsFromMpegTsClock)(-Ye,!0)+" ms ("+Ye+"dts) overlapping between fragments detected"),!yt||ie>Oe[0].pts)){W=ie;var ht=Oe[0].pts-Ye;Oe[0].dts=W,Oe[0].pts=ht,re.logger.log("Video: First PTS/DTS adjusted: "+(0,_e.toMsFromMpegTsClock)(ht,!0)+"/"+(0,_e.toMsFromMpegTsClock)(W,!0)+", delta: "+(0,_e.toMsFromMpegTsClock)(Ye,!0)+" ms")}}W=Math.max(0,W);for(var It=0,Lt=0,St=0;St<qe;St++){for(var At=Oe[St],pt=At.units,ut=pt.length,Rt=0,Ct=0;Ct<ut;Ct++)Rt+=pt[Ct].data.length;Lt+=Rt,It+=ut,At.length=Rt,At.dts=Math.max(At.dts,W),xe=Math.min(At.pts,xe),Pe=Math.max(At.pts,Pe)}De=Oe[qe-1].dts;var Ht,Qt=Lt+4*It+8;try{Ht=new Uint8Array(Qt)}catch{return void this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:me.ErrorTypes.MUX_ERROR,details:me.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Qt,reason:"fail allocating video mdat "+Qt})}var Ut=new DataView(Ht.buffer);Ut.setUint32(0,Qt),Ht.set(w.types.mdat,4);for(var ur=!1,ee=Number.POSITIVE_INFINITY,F=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY,C=Number.NEGATIVE_INFINITY,L=0;L<qe;L++){for(var B=Oe[L],Y=B.units,z=0,ge=0,we=Y.length;ge<we;ge++){var Le=Y[ge],Fe=Le.data,Ve=Le.data.byteLength;Ut.setUint32(ce,Ve),ce+=4,Ht.set(Fe,ce),ce+=Ve,z+=4+Ve}var Ue=void 0;if(L<qe-1)ne=Oe[L+1].dts-B.dts,Ue=Oe[L+1].pts-B.pts;else{var Qe=this.config,ot=L>0?B.dts-Oe[L-1].dts:Ie;if(Ue=L>0?B.pts-Oe[L-1].pts:Ie,Qe.stretchShortVideoTrack&&this.nextAudioPts!==null){var bt=Math.floor(Qe.maxBufferHole*Re),We=(J?xe+J*Re:this.nextAudioPts)-B.pts;We>bt?((ne=We-ot)<0?ne=ot:ur=!0,re.logger.log("[mp4-remuxer]: It is approximately "+We/90+" ms to the next segment; using duration "+ne/90+" ms for the last video frame.")):ne=ot}else ne=ot}var kt=Math.round(B.pts-B.dts);ee=Math.min(ee,ne),T=Math.max(T,ne),F=Math.min(F,Ue),C=Math.max(C,Ue),ye.push(new je(B.key,ne,z,kt))}if(ye.length){if(ve){if(ve<70){var Jt=ye[0].flags;Jt.dependsOn=2,Jt.isNonSync=0}}else if($&&C-F<T-ee&&Ie/T<.025&&ye[0].cts===0){re.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var Ft=W,Pt=0,Bt=ye.length;Pt<Bt;Pt++){var Ze=Ft+ye[Pt].duration,ir=Ft+ye[Pt].cts;if(Pt<Bt-1){var br=Ze+ye[Pt+1].cts;ye[Pt].duration=br-ir}else ye[Pt].duration=Pt?ye[Pt-1].duration:Ie;ye[Pt].cts=0,Ft=Ze}}}ne=ur||!ne?Ie:ne,this.nextAvcDts=ie=De+ne,this.videoSampleDuration=ne,this.isVideoContiguous=!0;var Nt={data1:w.moof(A.sequenceNumber++,W,K({},A,{samples:ye})),data2:Ht,startPTS:xe/Re,endPTS:(Pe+ne)/Re,startDTS:W/Re,endDTS:ie/Re,type:"video",hasAudio:!1,hasVideo:!0,nb:ye.length,dropped:A.dropped};return A.samples=[],A.dropped=0,Nt},U.remuxAudio=function(A,ue,Te,J,W){var De=A.inputTimeScale,Re=De/(A.samplerate?A.samplerate:De),Oe=A.segmentCodec==="aac"?1024:1152,ye=Oe*Re,qe=this._initPTS,tt=A.segmentCodec==="mp3"&&this.typeSupported.mpeg,ie=[],ce=W!==void 0,ne=A.samples,xe=tt?0:8,Pe=this.nextAudioPts||-1,Ne=ue*De;if(this.isAudioContiguous=Te=Te||ne.length&&Pe>0&&(J&&Math.abs(Ne-Pe)<9e3||Math.abs(G(ne[0].pts-qe,Ne)-Pe)<20*ye),ne.forEach(function(ge){ge.pts=G(ge.pts-qe,Ne)}),!Te||Pe<0){if(ne=ne.filter(function(ge){return ge.pts>=0}),!ne.length)return;Pe=W===0?0:J&&!ce?Math.max(0,Ne):ne[0].pts}if(A.segmentCodec==="aac")for(var Be=this.config.maxAudioFramesDrift,Ke=0,pe=Pe;Ke<ne.length;Ke++){var Ie=ne[Ke],Ye=Ie.pts,rt=Ye-pe,yt=Math.abs(1e3*rt/De);if(rt<=-Be*ye&&ce)Ke===0&&(re.logger.warn("Audio frame @ "+(Ye/De).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*rt/De)+" ms."),this.nextAudioPts=Pe=pe=Ye);else if(rt>=Be*ye&&yt<1e4&&ce){var ht=Math.round(rt/ye);(pe=Ye-ht*ye)<0&&(ht--,pe+=ye),Ke===0&&(this.nextAudioPts=Pe=pe),re.logger.warn("[mp4-remuxer]: Injecting "+ht+" audio frame @ "+(pe/De).toFixed(3)+"s due to "+Math.round(1e3*rt/De)+" ms gap.");for(var It=0;It<ht;It++){var Lt=Math.max(pe,0),St=te.getSilentFrame(A.manifestCodec||A.codec,A.channelCount);St||(re.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),St=Ie.unit.subarray()),ne.splice(Ke,0,{unit:St,pts:Lt}),pe+=ye,Ke++}}Ie.pts=pe,pe+=ye}for(var At,pt=null,ut=null,Rt=0,Ct=ne.length;Ct--;)Rt+=ne[Ct].unit.byteLength;for(var Ht=0,Qt=ne.length;Ht<Qt;Ht++){var Ut=ne[Ht],ur=Ut.unit,ee=Ut.pts;if(ut!==null)ie[Ht-1].duration=Math.round((ee-ut)/Re);else{if(Te&&A.segmentCodec==="aac"&&(ee=Pe),pt=ee,!(Rt>0))return;Rt+=xe;try{At=new Uint8Array(Rt)}catch{return void this.observer.emit(k.Events.ERROR,k.Events.ERROR,{type:me.ErrorTypes.MUX_ERROR,details:me.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Rt,reason:"fail allocating audio mdat "+Rt})}tt||(new DataView(At.buffer).setUint32(0,Rt),At.set(w.types.mdat,4))}At.set(ur,xe);var F=ur.byteLength;xe+=F,ie.push(new je(!0,Oe,F,0)),ut=ee}var T=ie.length;if(T){var C=ie[ie.length-1];this.nextAudioPts=Pe=ut+Re*C.duration;var L=tt?new Uint8Array(0):w.moof(A.sequenceNumber++,pt/Re,K({},A,{samples:ie}));A.samples=[];var B=pt/De,Y=Pe/De,z={data1:L,data2:At,startPTS:B,endPTS:Y,startDTS:B,endDTS:Y,type:"audio",hasAudio:!0,hasVideo:!1,nb:T};return this.isAudioContiguous=!0,z}},U.remuxEmptyAudio=function(A,ue,Te,J){var W=A.inputTimeScale,De=W/(A.samplerate?A.samplerate:W),Re=this.nextAudioPts,Oe=(Re!==null?Re:J.startDTS*W)+this._initDTS,ye=J.endDTS*W+this._initDTS,qe=1024*De,tt=Math.ceil((ye-Oe)/qe),ie=te.getSilentFrame(A.manifestCodec||A.codec,A.channelCount);if(re.logger.warn("[mp4-remuxer]: remux empty Audio"),ie){for(var ce=[],ne=0;ne<tt;ne++){var xe=Oe+ne*qe;ce.push({unit:ie,pts:xe,dts:xe})}return A.samples=ce,this.remuxAudio(A,ue,Te,!1)}re.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},E}();function G(E,U){var A;if(U===null)return E;for(A=U<E?-8589934592:8589934592;Math.abs(E-U)>4294967296;)E+=A;return E}function Se(E,U,A,ue){var Te=E.samples.length;if(Te){for(var J=E.inputTimeScale,W=0;W<Te;W++){var De=E.samples[W];De.pts=G(De.pts-A,U*J)/J,De.dts=G(De.dts-ue,U*J)/J}var Re=E.samples;return E.samples=[],{samples:Re}}}function ke(E,U,A){var ue=E.samples.length;if(ue){for(var Te=E.inputTimeScale,J=0;J<ue;J++){var W=E.samples[J];W.pts=G(W.pts-A,U*Te)/Te}E.samples.sort(function(Re,Oe){return Re.pts-Oe.pts});var De=E.samples;return E.samples=[],{samples:De}}}var je=function(E,U,A,ue){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=U,this.size=A,this.cts=ue,this.flags=new V(E)},V=function(E){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=E?2:1,this.isNonSync=E?0:1}},856:(oe,Q,N)=>{"use strict";var j;N.r(Q),N.d(Q,{MetadataSchema:()=>j}),function(te){te.audioId3="org.id3",te.dateRange="com.apple.quicktime.HLS",te.emsg="https://aomedia.org/emsg/ID3"}(j||(j={}))},308:(oe,Q,N)=>{"use strict";var j,te;N.r(Q),N.d(Q,{PlaylistContextType:()=>j,PlaylistLevelType:()=>te}),function(R){R.MANIFEST="manifest",R.LEVEL="level",R.AUDIO_TRACK="audioTrack",R.SUBTITLE_TRACK="subtitleTrack"}(j||(j={})),function(R){R.MAIN="main",R.AUDIO="audio",R.SUBTITLE="subtitle"}(te||(te={}))},300:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{default:()=>j});let j={hexDump:function(te){for(var R="",p=0;p<te.length;p++){var w=te[p].toString(16);w.length<2&&(w="0"+w),R+=w}return R}}},93:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{enableLogs:()=>w,logger:()=>k});var j=function(){},te={trace:j,debug:j,log:j,warn:j,info:j,error:j},R=te;function p(me){var re=self.console[me];return re?re.bind(self.console,"["+me+"] >"):j}function w(me,re){if(self.console&&me===!0||typeof me=="object"){(function(de){for(var _e=arguments.length,K=new Array(_e>1?_e-1:0),ve=1;ve<_e;ve++)K[ve-1]=arguments[ve];K.forEach(function($){R[$]=de[$]?de[$].bind(de):p($)})})(me,"debug","log","info","warn","error");try{R.log('Debug logs enabled for "'+re+'"')}catch{R=te}}else R=te}var k=te},63:(oe,Q,N)=>{"use strict";N.r(Q),N.d(Q,{RemuxerTrackIdConfig:()=>re,appendUint8Array:()=>Te,bin2str:()=>de,computeRawDurationFromSamples:()=>U,discardEPB:()=>Re,findBox:()=>ae,getDuration:()=>E,getStartDTS:()=>V,mp4Box:()=>ye,mp4pssh:()=>qe,offsetStartDTS:()=>A,parseEmsg:()=>Oe,parseInitSegment:()=>Se,parsePssh:()=>tt,parseSEIMessageFromNALu:()=>De,parseSamples:()=>J,parseSegmentIndex:()=>G,parseSinf:()=>je,patchEncyptionData:()=>ke,readSint32:()=>ve,readUint16:()=>_e,readUint32:()=>K,segmentValidRange:()=>ue,writeUint32:()=>$});var j=N(923),te=N(145),R=N(181),p=N(93),w=N(300),k=Math.pow(2,32)-1,me=[].push,re={video:1,audio:2,id3:3,text:4};function de(ie){return String.fromCharCode.apply(null,ie)}function _e(ie,ce){var ne=ie[ce]<<8|ie[ce+1];return ne<0?65536+ne:ne}function K(ie,ce){var ne=ve(ie,ce);return ne<0?4294967296+ne:ne}function ve(ie,ce){return ie[ce]<<24|ie[ce+1]<<16|ie[ce+2]<<8|ie[ce+3]}function $(ie,ce,ne){ie[ce]=ne>>24,ie[ce+1]=ne>>16&255,ie[ce+2]=ne>>8&255,ie[ce+3]=255&ne}function ae(ie,ce){var ne=[];if(!ce.length)return ne;for(var xe=ie.byteLength,Pe=0;Pe<xe;){var Ne=K(ie,Pe),Be=Ne>1?Pe+Ne:xe;if(de(ie.subarray(Pe+4,Pe+8))===ce[0])if(ce.length===1)ne.push(ie.subarray(Pe+8,Be));else{var Ke=ae(ie.subarray(Pe+8,Be),ce.slice(1));Ke.length&&me.apply(ne,Ke)}Pe=Be}return ne}function G(ie){var ce=[],ne=ie[0],xe=8,Pe=K(ie,xe);xe+=4,xe+=ne===0?8:16,xe+=2;var Ne=ie.length+0,Be=_e(ie,xe);xe+=2;for(var Ke=0;Ke<Be;Ke++){var pe=xe,Ie=K(ie,pe);pe+=4;var Ye=2147483647&Ie;if((2147483648&Ie)>>>31==1)return console.warn("SIDX has hierarchical references (not supported)"),null;var rt=K(ie,pe);pe+=4,ce.push({referenceSize:Ye,subsegmentDuration:rt,info:{duration:rt/Pe,start:Ne,end:Ne+Ye-1}}),Ne+=Ye,xe=pe+=4}return{earliestPresentationTime:0,timescale:Pe,version:ne,referencesCount:Be,references:ce}}function Se(ie){for(var ce=[],ne=ae(ie,["moov","trak"]),xe=0;xe<ne.length;xe++){var Pe=ne[xe],Ne=ae(Pe,["tkhd"])[0];if(Ne){var Be=Ne[0],Ke=Be===0?12:20,pe=K(Ne,Ke),Ie=ae(Pe,["mdia","mdhd"])[0];if(Ie){var Ye=K(Ie,Ke=(Be=Ie[0])===0?12:20),rt=ae(Pe,["mdia","hdlr"])[0];if(rt){var yt=de(rt.subarray(8,12)),ht={soun:j.ElementaryStreamTypes.AUDIO,vide:j.ElementaryStreamTypes.VIDEO}[yt];if(ht){var It=ae(Pe,["mdia","minf","stbl","stsd"])[0],Lt=void 0;It&&(Lt=de(It.subarray(12,16))),ce[pe]={timescale:Ye,type:ht},ce[ht]={timescale:Ye,id:pe,codec:Lt}}}}}}return ae(ie,["moov","mvex","trex"]).forEach(function(St){var At=K(St,4),pt=ce[At];pt&&(pt.default={duration:K(St,12),flags:K(St,20)})}),ce}function ke(ie,ce){if(!ie||!ce)return ie;var ne=ce.keyId;return ne&&ce.isCommonEncryption&&ae(ie,["moov","trak"]).forEach(function(xe){var Pe=ae(xe,["mdia","minf","stbl","stsd"])[0].subarray(8),Ne=ae(Pe,["enca"]),Be=Ne.length>0;Be||(Ne=ae(Pe,["encv"])),Ne.forEach(function(Ke){ae(Be?Ke.subarray(28):Ke.subarray(78),["sinf"]).forEach(function(pe){var Ie=je(pe);if(Ie){var Ye=Ie.subarray(8,24);Ye.some(function(rt){return rt!==0})||(p.logger.log("[eme] Patching keyId in 'enc"+(Be?"a":"v")+">sinf>>tenc' box: "+w.default.hexDump(Ye)+" -> "+w.default.hexDump(ne)),Ie.set(ne,8))}})})}),ie}function je(ie){var ce=ae(ie,["schm"])[0];if(ce){var ne=de(ce.subarray(4,8));if(ne==="cbcs"||ne==="cenc")return ae(ie,["schi","tenc"])[0]}return p.logger.error("[eme] missing 'schm' box"),null}function V(ie,ce){return ae(ce,["moof","traf"]).reduce(function(ne,xe){var Pe=ae(xe,["tfdt"])[0],Ne=Pe[0],Be=ae(xe,["tfhd"]).reduce(function(Ke,pe){var Ie=K(pe,4),Ye=ie[Ie];if(Ye){var rt=K(Pe,4);Ne===1&&(rt*=Math.pow(2,32),rt+=K(Pe,8));var yt=rt/(Ye.timescale||9e4);if(isFinite(yt)&&(Ke===null||yt<Ke))return yt}return Ke},null);return Be!==null&&isFinite(Be)&&(ne===null||Be<ne)?Be:ne},null)||0}function E(ie,ce){for(var ne=0,xe=0,Pe=0,Ne=ae(ie,["moof","traf"]),Be=0;Be<Ne.length;Be++){var Ke=Ne[Be],pe=ae(Ke,["tfhd"])[0],Ie=ce[K(pe,4)];if(Ie){var Ye=Ie.default,rt=K(pe,0)|(Ye==null?void 0:Ye.flags),yt=Ye==null?void 0:Ye.duration;8&rt&&(yt=K(pe,2&rt?12:8));for(var ht=Ie.timescale||9e4,It=ae(Ke,["trun"]),Lt=0;Lt<It.length;Lt++)!(ne=U(It[Lt]))&&yt&&(ne=yt*K(It[Lt],4)),Ie.type===j.ElementaryStreamTypes.VIDEO?xe+=ne/ht:Ie.type===j.ElementaryStreamTypes.AUDIO&&(Pe+=ne/ht)}}if(xe===0&&Pe===0){for(var St=0,At=ae(ie,["sidx"]),pt=0;pt<At.length;pt++){var ut=G(At[pt]);ut!=null&&ut.references&&(St+=ut.references.reduce(function(Rt,Ct){return Rt+Ct.info.duration||0},0))}return St}return xe||Pe}function U(ie){var ce=K(ie,0),ne=8;1&ce&&(ne+=4),4&ce&&(ne+=4);for(var xe=0,Pe=K(ie,4),Ne=0;Ne<Pe;Ne++)256&ce&&(xe+=K(ie,ne),ne+=4),512&ce&&(ne+=4),1024&ce&&(ne+=4),2048&ce&&(ne+=4);return xe}function A(ie,ce,ne){ae(ce,["moof","traf"]).forEach(function(xe){ae(xe,["tfhd"]).forEach(function(Pe){var Ne=K(Pe,4),Be=ie[Ne];if(Be){var Ke=Be.timescale||9e4;ae(xe,["tfdt"]).forEach(function(pe){var Ie=pe[0],Ye=K(pe,4);if(Ie===0)Ye-=ne*Ke,$(pe,4,Ye=Math.max(Ye,0));else{Ye*=Math.pow(2,32),Ye+=K(pe,8),Ye-=ne*Ke,Ye=Math.max(Ye,0);var rt=Math.floor(Ye/(k+1)),yt=Math.floor(Ye%(k+1));$(pe,4,rt),$(pe,8,yt)}})}})})}function ue(ie){var ce={valid:null,remainder:null},ne=ae(ie,["moof"]);if(!ne)return ce;if(ne.length<2)return ce.remainder=ie,ce;var xe=ne[ne.length-1];return ce.valid=(0,te.sliceUint8)(ie,0,xe.byteOffset-8),ce.remainder=(0,te.sliceUint8)(ie,xe.byteOffset-8),ce}function Te(ie,ce){var ne=new Uint8Array(ie.length+ce.length);return ne.set(ie),ne.set(ce,ie.length),ne}function J(ie,ce){var ne=[],xe=ce.samples,Pe=ce.timescale,Ne=ce.id,Be=!1;return ae(xe,["moof"]).map(function(Ke){var pe=Ke.byteOffset-8;ae(Ke,["traf"]).map(function(Ie){var Ye=ae(Ie,["tfdt"]).map(function(rt){var yt=rt[0],ht=K(rt,4);return yt===1&&(ht*=Math.pow(2,32),ht+=K(rt,8)),ht/Pe})[0];return Ye!==void 0&&(ie=Ye),ae(Ie,["tfhd"]).map(function(rt){var yt=K(rt,4),ht=16777215&K(rt,0),It=0,Lt=(16&ht)!=0,St=0,At=(32&ht)!=0,pt=8;yt===Ne&&((1&ht)!=0&&(pt+=8),(2&ht)!=0&&(pt+=4),(8&ht)!=0&&(It=K(rt,pt),pt+=4),Lt&&(St=K(rt,pt),pt+=4),At&&(pt+=4),ce.type==="video"&&(Be=function(ut){if(!ut)return!1;var Rt=ut.indexOf("."),Ct=Rt<0?ut:ut.substring(0,Rt);return Ct==="hvc1"||Ct==="hev1"||Ct==="dvh1"||Ct==="dvhe"}(ce.codec)),ae(Ie,["trun"]).map(function(ut){var Rt=ut[0],Ct=16777215&K(ut,0),Ht=(1&Ct)!=0,Qt=0,Ut=(4&Ct)!=0,ur=(256&Ct)!=0,ee=0,F=(512&Ct)!=0,T=0,C=(1024&Ct)!=0,L=(2048&Ct)!=0,B=0,Y=K(ut,4),z=8;Ht&&(Qt=K(ut,z),z+=4),Ut&&(z+=4);for(var ge=Qt+pe,we=0;we<Y;we++){if(ur?(ee=K(ut,z),z+=4):ee=It,F?(T=K(ut,z),z+=4):T=St,C&&(z+=4),L&&(B=Rt===0?K(ut,z):ve(ut,z),z+=4),ce.type===j.ElementaryStreamTypes.VIDEO)for(var Le=0;Le<T;){var Fe=K(xe,ge);W(Be,xe[ge+=4])&&De(xe.subarray(ge,ge+Fe),Be?2:1,ie+B/Pe,ne),ge+=Fe,Le+=Fe+4}ie+=ee/Pe}}))})})}),ne}function W(ie,ce){if(ie){var ne=ce>>1&63;return ne===39||ne===40}return(31&ce)==6}function De(ie,ce,ne,xe){var Pe=Re(ie),Ne=0;Ne+=ce;for(var Be=0,Ke=0,pe=!1,Ie=0;Ne<Pe.length;){Be=0;do{if(Ne>=Pe.length)break;Be+=Ie=Pe[Ne++]}while(Ie===255);Ke=0;do{if(Ne>=Pe.length)break;Ke+=Ie=Pe[Ne++]}while(Ie===255);var Ye=Pe.length-Ne;if(!pe&&Be===4&&Ne<Pe.length){if(pe=!0,Pe[Ne++]===181){var rt=_e(Pe,Ne);if(Ne+=2,rt===49){var yt=K(Pe,Ne);if(Ne+=4,yt===1195456820){var ht=Pe[Ne++];if(ht===3){var It=Pe[Ne++],Lt=64&It,St=Lt?2+3*(31&It):0,At=new Uint8Array(St);if(Lt){At[0]=It;for(var pt=1;pt<St;pt++)At[pt]=Pe[Ne++]}xe.push({type:ht,payloadType:Be,pts:ne,bytes:At})}}}}}else if(Be===5&&Ke<Ye){if(pe=!0,Ke>16){for(var ut=[],Rt=0;Rt<16;Rt++){var Ct=Pe[Ne++].toString(16);ut.push(Ct.length==1?"0"+Ct:Ct),Rt!==3&&Rt!==5&&Rt!==7&&Rt!==9||ut.push("-")}for(var Ht=Ke-16,Qt=new Uint8Array(Ht),Ut=0;Ut<Ht;Ut++)Qt[Ut]=Pe[Ne++];xe.push({payloadType:Be,pts:ne,uuid:ut.join(""),userData:(0,R.utf8ArrayToStr)(Qt),userDataBytes:Qt})}}else if(Ke<Ye)Ne+=Ke;else if(Ke>Ye)break}}function Re(ie){for(var ce=ie.byteLength,ne=[],xe=1;xe<ce-2;)ie[xe]===0&&ie[xe+1]===0&&ie[xe+2]===3?(ne.push(xe+2),xe+=2):xe++;if(ne.length===0)return ie;var Pe=ce-ne.length,Ne=new Uint8Array(Pe),Be=0;for(xe=0;xe<Pe;Be++,xe++)Be===ne[0]&&(Be++,ne.shift()),Ne[xe]=ie[Be];return Ne}function Oe(ie){var ce=ie[0],ne="",xe="",Pe=0,Ne=0,Be=0,Ke=0,pe=0,Ie=0;if(ce===0){for(;de(ie.subarray(Ie,Ie+1))!=="\0";)ne+=de(ie.subarray(Ie,Ie+1)),Ie+=1;for(ne+=de(ie.subarray(Ie,Ie+1)),Ie+=1;de(ie.subarray(Ie,Ie+1))!=="\0";)xe+=de(ie.subarray(Ie,Ie+1)),Ie+=1;xe+=de(ie.subarray(Ie,Ie+1)),Ie+=1,Pe=K(ie,12),Ne=K(ie,16),Ke=K(ie,20),pe=K(ie,24),Ie=28}else if(ce===1){Pe=K(ie,Ie+=4);var Ye=K(ie,Ie+=4),rt=K(ie,Ie+=4);for(Ie+=4,Be=Math.pow(2,32)*Ye+rt,Number.isSafeInteger(Be)||(Be=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),Ke=K(ie,Ie),pe=K(ie,Ie+=4),Ie+=4;de(ie.subarray(Ie,Ie+1))!=="\0";)ne+=de(ie.subarray(Ie,Ie+1)),Ie+=1;for(ne+=de(ie.subarray(Ie,Ie+1)),Ie+=1;de(ie.subarray(Ie,Ie+1))!=="\0";)xe+=de(ie.subarray(Ie,Ie+1)),Ie+=1;xe+=de(ie.subarray(Ie,Ie+1)),Ie+=1}return{schemeIdUri:ne,value:xe,timeScale:Pe,presentationTime:Be,presentationTimeDelta:Ne,eventDuration:Ke,id:pe,payload:ie.subarray(Ie,ie.byteLength)}}function ye(ie){for(var ce=arguments.length,ne=new Array(ce>1?ce-1:0),xe=1;xe<ce;xe++)ne[xe-1]=arguments[xe];for(var Pe=ne.length,Ne=8,Be=Pe;Be--;)Ne+=ne[Be].byteLength;var Ke=new Uint8Array(Ne);for(Ke[0]=Ne>>24&255,Ke[1]=Ne>>16&255,Ke[2]=Ne>>8&255,Ke[3]=255&Ne,Ke.set(ie,4),Be=0,Ne=8;Be<Pe;Be++)Ke.set(ne[Be],Ne),Ne+=ne[Be].byteLength;return Ke}function qe(ie,ce,ne){if(ie.byteLength!==16)throw new RangeError("Invalid system id");var xe,Pe,Ne;if(ce){xe=1,Pe=new Uint8Array(16*ce.length);for(var Be=0;Be<ce.length;Be++){var Ke=ce[Be];if(Ke.byteLength!==16)throw new RangeError("Invalid key");Pe.set(Ke,16*Be)}}else xe=0,Pe=new Uint8Array;xe>0?(Ne=new Uint8Array(4),ce.length>0&&new DataView(Ne.buffer).setUint32(0,ce.length,!1)):Ne=new Uint8Array;var pe=new Uint8Array(4);return ne&&ne.byteLength>0&&new DataView(pe.buffer).setUint32(0,ne.byteLength,!1),ye([112,115,115,104],new Uint8Array([xe,0,0,0]),ie,Ne,Pe,pe,ne||new Uint8Array)}function tt(ie){if(!(ie instanceof ArrayBuffer)||ie.byteLength<32)return null;var ce={version:0,systemId:"",kids:null,data:null},ne=new DataView(ie),xe=ne.getUint32(0);if(ie.byteLength!==xe&&xe>44||ne.getUint32(4)!==1886614376||(ce.version=ne.getUint32(8)>>>24,ce.version>1))return null;ce.systemId=w.default.hexDump(new Uint8Array(ie,12,16));var Pe=ne.getUint32(28);if(ce.version===0){if(xe-32<Pe)return null;ce.data=new Uint8Array(ie,32,Pe)}else if(ce.version===1){ce.kids=[];for(var Ne=0;Ne<Pe;Ne++)ce.kids.push(new Uint8Array(ie,32+16*Ne,16))}return ce}},673:(oe,Q,N)=>{"use strict";function j(w,k,me,re){me===void 0&&(me=1),re===void 0&&(re=!1);var de=w*k*me;return re?Math.round(de):de}function te(w,k,me,re){return me===void 0&&(me=1),re===void 0&&(re=!1),j(w,k,1/me,re)}function R(w,k){return k===void 0&&(k=!1),j(w,1e3,11111111111111112e-21,k)}function p(w,k){return k===void 0&&(k=1),j(w,9e4,1/k)}N.r(Q),N.d(Q,{toMpegTsClockFromTimescale:()=>p,toMsFromMpegTsClock:()=>R,toTimescaleFromBase:()=>j,toTimescaleFromScale:()=>te})},145:(oe,Q,N)=>{"use strict";function j(te,R,p){return Uint8Array.prototype.slice?te.slice(R,p):new Uint8Array(Array.prototype.slice.call(te,R,p))}N.r(Q),N.d(Q,{sliceUint8:()=>j})},729:oe=>{"use strict";var Q=Object.prototype.hasOwnProperty,N="~";function j(){}function te(k,me,re){this.fn=k,this.context=me,this.once=re||!1}function R(k,me,re,de,_e){if(typeof re!="function")throw new TypeError("The listener must be a function");var K=new te(re,de||k,_e),ve=N?N+me:me;return k._events[ve]?k._events[ve].fn?k._events[ve]=[k._events[ve],K]:k._events[ve].push(K):(k._events[ve]=K,k._eventsCount++),k}function p(k,me){--k._eventsCount==0?k._events=new j:delete k._events[me]}function w(){this._events=new j,this._eventsCount=0}Object.create&&(j.prototype=Object.create(null),new j().__proto__||(N=!1)),w.prototype.eventNames=function(){var k,me,re=[];if(this._eventsCount===0)return re;for(me in k=this._events)Q.call(k,me)&&re.push(N?me.slice(1):me);return Object.getOwnPropertySymbols?re.concat(Object.getOwnPropertySymbols(k)):re},w.prototype.listeners=function(k){var me=N?N+k:k,re=this._events[me];if(!re)return[];if(re.fn)return[re.fn];for(var de=0,_e=re.length,K=new Array(_e);de<_e;de++)K[de]=re[de].fn;return K},w.prototype.listenerCount=function(k){var me=N?N+k:k,re=this._events[me];return re?re.fn?1:re.length:0},w.prototype.emit=function(k,me,re,de,_e,K){var ve=N?N+k:k;if(!this._events[ve])return!1;var $,ae,G=this._events[ve],Se=arguments.length;if(G.fn){switch(G.once&&this.removeListener(k,G.fn,void 0,!0),Se){case 1:return G.fn.call(G.context),!0;case 2:return G.fn.call(G.context,me),!0;case 3:return G.fn.call(G.context,me,re),!0;case 4:return G.fn.call(G.context,me,re,de),!0;case 5:return G.fn.call(G.context,me,re,de,_e),!0;case 6:return G.fn.call(G.context,me,re,de,_e,K),!0}for(ae=1,$=new Array(Se-1);ae<Se;ae++)$[ae-1]=arguments[ae];G.fn.apply(G.context,$)}else{var ke,je=G.length;for(ae=0;ae<je;ae++)switch(G[ae].once&&this.removeListener(k,G[ae].fn,void 0,!0),Se){case 1:G[ae].fn.call(G[ae].context);break;case 2:G[ae].fn.call(G[ae].context,me);break;case 3:G[ae].fn.call(G[ae].context,me,re);break;case 4:G[ae].fn.call(G[ae].context,me,re,de);break;default:if(!$)for(ke=1,$=new Array(Se-1);ke<Se;ke++)$[ke-1]=arguments[ke];G[ae].fn.apply(G[ae].context,$)}}return!0},w.prototype.on=function(k,me,re){return R(this,k,me,re,!1)},w.prototype.once=function(k,me,re){return R(this,k,me,re,!0)},w.prototype.removeListener=function(k,me,re,de){var _e=N?N+k:k;if(!this._events[_e])return this;if(!me)return p(this,_e),this;var K=this._events[_e];if(K.fn)K.fn!==me||de&&!K.once||re&&K.context!==re||p(this,_e);else{for(var ve=0,$=[],ae=K.length;ve<ae;ve++)(K[ve].fn!==me||de&&!K[ve].once||re&&K[ve].context!==re)&&$.push(K[ve]);$.length?this._events[_e]=$.length===1?$[0]:$:p(this,_e)}return this},w.prototype.removeAllListeners=function(k){var me;return k?(me=N?N+k:k,this._events[me]&&p(this,me)):(this._events=new j,this._eventsCount=0),this},w.prototype.off=w.prototype.removeListener,w.prototype.addListener=w.prototype.on,w.prefixed=N,w.EventEmitter=w,oe.exports=w},945:function(oe){var Q,N,j,te,R;Q=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,N=/^(?=([^\/?#]*))\1([^]*)$/,j=/(?:\/|^)\.(?=\/)/g,te=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,R={buildAbsoluteURL:function(p,w,k){if(k=k||{},p=p.trim(),!(w=w.trim())){if(!k.alwaysNormalize)return p;var me=R.parseURL(p);if(!me)throw new Error("Error trying to parse base URL.");return me.path=R.normalizePath(me.path),R.buildURLFromParts(me)}var re=R.parseURL(w);if(!re)throw new Error("Error trying to parse relative URL.");if(re.scheme)return k.alwaysNormalize?(re.path=R.normalizePath(re.path),R.buildURLFromParts(re)):w;var de=R.parseURL(p);if(!de)throw new Error("Error trying to parse base URL.");if(!de.netLoc&&de.path&&de.path[0]!=="/"){var _e=N.exec(de.path);de.netLoc=_e[1],de.path=_e[2]}de.netLoc&&!de.path&&(de.path="/");var K={scheme:de.scheme,netLoc:re.netLoc,path:null,params:re.params,query:re.query,fragment:re.fragment};if(!re.netLoc&&(K.netLoc=de.netLoc,re.path[0]!=="/"))if(re.path){var ve=de.path,$=ve.substring(0,ve.lastIndexOf("/")+1)+re.path;K.path=R.normalizePath($)}else K.path=de.path,re.params||(K.params=de.params,re.query||(K.query=de.query));return K.path===null&&(K.path=k.alwaysNormalize?R.normalizePath(re.path):re.path),R.buildURLFromParts(K)},parseURL:function(p){var w=Q.exec(p);return w?{scheme:w[1]||"",netLoc:w[2]||"",path:w[3]||"",params:w[4]||"",query:w[5]||"",fragment:w[6]||""}:null},normalizePath:function(p){for(p=p.split("").reverse().join("").replace(j,"");p.length!==(p=p.replace(te,"")).length;);return p.split("").reverse().join("")},buildURLFromParts:function(p){return p.scheme+p.netLoc+p.path+p.params+p.query+p.fragment}},oe.exports=R}},X={};function x(oe){var Q=X[oe];if(Q!==void 0)return Q.exports;var N=X[oe]={exports:{}};return M[oe].call(N.exports,N,N.exports,x),N.exports}x.m=M,x.n=oe=>{var Q=oe&&oe.__esModule?()=>oe.default:()=>oe;return x.d(Q,{a:Q}),Q},x.d=(oe,Q)=>{for(var N in Q)x.o(Q,N)&&!x.o(oe,N)&&Object.defineProperty(oe,N,{enumerable:!0,get:Q[N]})},x.o=(oe,Q)=>Object.prototype.hasOwnProperty.call(oe,Q),x.r=oe=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(oe,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(oe,"__esModule",{value:!0})};var fe=x(76);return fe.default})())});var Ti=class{addEventListener(){}removeEventListener(){}dispatchEvent(X){return!0}};if(typeof DocumentFragment=="undefined"){class M extends Ti{}globalThis.DocumentFragment=M}var ji=class extends Ti{},Hn=class extends Ti{},Ts={get(M){},define(M,X,x){},upgrade(M){},whenDefined(M){return Promise.resolve(ji)}},Gi,qn=class{constructor(X,x={}){Lr(this,Gi,void 0);Rr(this,Gi,x==null?void 0:x.detail)}get detail(){return pr(this,Gi)}initCustomEvent(){}};Gi=new WeakMap;function bs(M,X){return new ji}var Sa={document:{createElement:bs},DocumentFragment,customElements:Ts,CustomEvent:qn,EventTarget:Ti,HTMLElement:ji,HTMLVideoElement:Hn},Aa=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Pr=Aa?Sa:globalThis,Vn=Aa?Sa.document:globalThis.document;var fn=_a(ka(),1),Oa=_a(wa(),1),_s=Oa.default,Tr=_s,Hi=class extends Error{constructor(M,X=Hi.MEDIA_ERR_CUSTOM,x){var fe;super(M),this.name="MediaError",this.code=X,this.fatal=x!=null?x:X>=Hi.MEDIA_ERR_NETWORK&&X<=Hi.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(fe=Hi.defaultMessages[this.code])!=null?fe:"")}},mr=Hi;mr.MEDIA_ERR_ABORTED=1,mr.MEDIA_ERR_NETWORK=2,mr.MEDIA_ERR_DECODE=3,mr.MEDIA_ERR_SRC_NOT_SUPPORTED=4,mr.MEDIA_ERR_ENCRYPTED=5,mr.MEDIA_ERR_CUSTOM=100,mr.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var Ss=M=>M==null,Pa=(M,X)=>Ss(X)?!1:M in X,zn={ANY:"any",MUTED:"muted"},hn={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},ai={MSE:"mse",NATIVE:"native"},Qn={HEADER:"header",QUERY:"query",NONE:"none"},ro=Object.values(Qn),bi={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Jn={HLS:bi.M3U8},io=Object.keys(Jn),no=[...Object.values(bi),"hls","HLS"],ni=(M,X,x,fe,oe=M)=>{oe.addEventListener(X,x,fe),M.addEventListener("teardown",()=>{oe.removeEventListener(X,x)},{once:!0})};function As(M,X,x){X&&x>X&&(x=X);for(let fe=0;fe<M.length;fe++)if(M.start(fe)<=x&&M.end(fe)>=x)return!0;return!1}var ks=M=>{let X=M.indexOf("?");if(X<0)return[M];let x=M.slice(0,X),fe=M.slice(X);return[x,fe]},xa=M=>{let X=M.type;if(X){let fe=X.toUpperCase();return Pa(fe,Jn)?Jn[fe]:X}let{src:x}=M;return x?ws(x):""},ws=M=>{let X="";try{X=new URL(M).pathname}catch{console.error("invalid url")}let x=X.lastIndexOf(".");if(x<0)return"";let fe=X.slice(x+1).toUpperCase();return Pa(fe,bi)?bi[fe]:""},Ds=Object.values(zn),Da=M=>typeof M=="boolean"||typeof M=="string"&&Ds.includes(M),Ls=({autoplay:M},X,x)=>{let fe=!1,oe=!1,Q=Da(M)?M:!!M,N=()=>{fe||ni(X,"playing",()=>{fe=!0},{once:!0})};if(N(),ni(X,"loadstart",()=>{fe=!1,N(),Xn(X,Q)},{once:!0}),ni(X,"loadstart",()=>{x||(oe=!Number.isFinite(X.duration)),Xn(X,Q)},{once:!0}),x&&x.once(Tr.Events.LEVEL_LOADED,(j,te)=>{var R;oe=(R=te.details.live)!=null?R:!1}),!Q){let j=()=>{!oe||(x!=null&&x.liveSyncPosition?X.currentTime=x.liveSyncPosition:Number.isFinite(X.seekable.end(0))&&(X.currentTime=X.seekable.end(0)))};x&&ni(X,"play",()=>{X.preload==="metadata"?x.once(Tr.Events.LEVEL_UPDATED,j):j()},{once:!0})}return j=>{fe||(Q=Da(j)?j:!!j,Xn(X,Q))}},Xn=(M,X)=>{if(!X)return;let x=M.muted,fe=()=>M.muted=x;switch(X){case zn.ANY:M.play().catch(()=>{M.muted=!0,M.play().catch(fe)});break;case zn.MUTED:M.muted=!0,M.play().catch(fe);break;default:M.play().catch(()=>{});break}},Rs=({preload:M,src:X},x,fe)=>{let oe=w=>{w!=null&&["","none","metadata","auto"].includes(w)?x.setAttribute("preload",w):x.removeAttribute("preload")};if(!fe)return oe(M),oe;let Q=!1,N=!1,j=fe.config.maxBufferLength,te=fe.config.maxBufferSize,R=w=>{oe(w);let k=w!=null?w:x.preload;N||k==="none"||(k==="metadata"?(fe.config.maxBufferLength=1,fe.config.maxBufferSize=1):(fe.config.maxBufferLength=j,fe.config.maxBufferSize=te),p())},p=()=>{!Q&&X&&(Q=!0,fe.loadSource(X))};return ni(x,"play",()=>{N=!0,fe.config.maxBufferLength=j,fe.config.maxBufferSize=te,p()},{once:!0}),R(M),R};function Is(M,X){X.on(Tr.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(oe,{tracks:Q})=>{Q.forEach(N=>{var j;let te=(j=N.subtitleTrack)!=null?j:N.closedCaptions,R=X.subtitleTracks.findIndex(({lang:p,name:w,type:k})=>p==(te==null?void 0:te.lang)&&w===N.label&&k.toLowerCase()===N.kind);Fa(M,N.kind,N.label,te==null?void 0:te.lang,`${N.kind}${R}`)})});let x=()=>{var oe;if(!X.subtitleTracks.length)return;let Q=Array.from(M.textTracks).find(j=>j.id&&j.mode==="showing"&&["subtitles","captions"].includes(j.kind)),N=`${(oe=X.subtitleTracks[X.subtitleTrack])==null?void 0:oe.type.toLowerCase()}${X.subtitleTrack}`;if(Q&&(X.subtitleTrack<0||(Q==null?void 0:Q.id)!==N)){let j=X.subtitleTracks.findIndex(({lang:te,name:R,type:p})=>te==Q.language&&R===Q.label&&p.toLowerCase()===Q.kind);X.subtitleTrack=j}Q&&(Q==null?void 0:Q.id)===N&&Q.cues&&Array.from(Q.cues).forEach(j=>{Q.addCue(j)})};M.textTracks.addEventListener("change",x),X.on(Tr.Events.CUES_PARSED,(oe,{track:Q,cues:N})=>{let j=M.textTracks.getTrackById(Q);if(!j)return;let te=j.mode==="disabled";te&&(j.mode="hidden"),N.forEach(R=>{var p;(p=j.cues)!=null&&p.getCueById(R.id)||j.addCue(R)}),te&&(j.mode="disabled")}),X.once(Tr.Events.DESTROYING,()=>{M.textTracks.removeEventListener("change",x),M.querySelectorAll("track[data-removeondestroy]").forEach(oe=>{oe.remove()})});let fe=()=>{Array.from(M.textTracks).forEach(oe=>{var Q,N;if(!["subtitles","caption"].includes(oe.kind)&&oe.label==="thumbnails"){if(!((Q=oe.cues)!=null&&Q.length)){let j=M.querySelector('track[label="thumbnails"]'),te=(N=j==null?void 0:j.getAttribute("src"))!=null?N:"";j==null||j.removeAttribute("src"),setTimeout(()=>{j==null||j.setAttribute("src",te)},0)}oe.mode!=="hidden"&&(oe.mode="hidden")}})};X.once(Tr.Events.MANIFEST_LOADED,fe),X.once(Tr.Events.MEDIA_ATTACHED,fe)}function Fa(M,X,x,fe,oe){let Q=document.createElement("track");return Q.kind=X,Q.label=x,fe&&(Q.srclang=fe),oe&&(Q.id=oe),Q.track.mode=["subtitles","captions"].includes(X)?"disabled":"hidden",Q.setAttribute("data-removeondestroy",""),M.append(Q),Q.track}var vn="cuepoints",Zn=Object.freeze({label:vn}),Ma=(M,{label:X=vn}=Zn)=>{var x;return(x=Array.from(M.querySelectorAll("track")).find(fe=>fe.track.label===X&&fe.track.kind==="metadata"))==null?void 0:x.track};async function Cs(M,X,x=Zn){let fe=Ma(M,x);if(!fe){let{label:oe=vn}=x;fe=Fa(M,"metadata",oe),fe.mode="hidden",await new Promise(Q=>setTimeout(()=>Q(void 0),0))}return fe.mode!=="hidden"&&(fe.mode="hidden"),[...X].sort(({time:oe},{time:Q})=>Q-oe).forEach(({time:oe,value:Q})=>{var N,j;let te=Array.prototype.findIndex.call(fe==null?void 0:fe.cues,me=>me.startTime>=oe),R=(N=fe==null?void 0:fe.cues)==null?void 0:N[te],p=R?R.startTime:Number.isFinite(M.duration)?M.duration:Number.MAX_SAFE_INTEGER,w=(j=fe==null?void 0:fe.cues)==null?void 0:j[te-1];w&&(w.endTime=oe);let k=new VTTCue(oe,p,JSON.stringify(Q!=null?Q:null));fe.addCue(k)}),fe}var Os=M=>({time:M.startTime,value:JSON.parse(M.text)});function Ps(M,X={label:vn}){var x;let fe=Ma(M,X);if((x=fe==null?void 0:fe.activeCues)!=null&&x.length)return Os(fe.activeCues[0])}async function xs(M,X=Zn){return new Promise(x=>{ni(M,"loadstart",async()=>{let fe=await Cs(M,[],X);ni(M,"cuechange",()=>{let oe=Ps(M);if(oe){let Q=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:oe});M.dispatchEvent(Q)}},{},fe),x(fe)})})}var La,Ra,Fs=(Ra=(La=globalThis==null?void 0:globalThis.navigator)==null?void 0:La.userAgent)!=null?Ra:"",Ms=Fs.toLowerCase().indexOf("android")!==-1,qi=new WeakMap,Na="mux.com",Ia,Ca,Ua=(Ca=(Ia=Tr).isSupported)==null?void 0:Ca.call(Ia),Ns=Ms,Ba=()=>fn.default.utils.now(),Us=fn.default.utils.generateUUID,ja=(M,{domain:X=Na}={})=>{if(!M)return;let[x,fe=""]=ks(M);return`https://stream.${X}/${x}.m3u8${fe}`},Bs=M=>{if(!M)return;let[X]=M.split("?");return X||void 0},js=M=>{if(!M||!M.startsWith("https://stream."))return;let[X]=new URL(M).pathname.slice(1).split(".m3u8");return X||void 0},Gs=M=>{var X,x,fe;return(X=M==null?void 0:M.metadata)!=null&&X.video_id?M.metadata.video_id:Ha(M)&&(fe=(x=Bs(M.playbackId))!=null?x:js(M.src))!=null?fe:M.src};var Ga=(M,X,x)=>{ea(X,x);let{metadata:fe={}}=M,{view_session_id:oe=Us()}=fe,Q=Gs(M);fe.view_session_id=oe,fe.video_id=Q,M.metadata=fe,qi.set(X,{});let N=Ks(M,X);qs(M,X,N),Vs(M,X,N),xs(X);let j=Ls(M,X,N),te=Rs(M,X,N);return{engine:N,setAutoplay:j,setPreload:te}},ea=(M,X)=>{let x=X==null?void 0:X.engine;x&&(x.detachMedia(),x.destroy()),(M==null?void 0:M.mux)&&!M.mux.deleted&&(M.mux.destroy(),delete M.mux),M&&(M.removeAttribute("src"),M.load(),M.removeEventListener("error",Va),M.removeEventListener("error",$n),M.removeEventListener("durationchange",qa),qi.delete(M),M.dispatchEvent(new Event("teardown")))};function Ka(M,X){var x;let fe=xa(M);if(fe!==bi.M3U8)return!0;let oe=!fe||((x=X.canPlayType(fe))!=null?x:!0),{preferPlayback:Q}=M,N=Q===ai.MSE,j=Q===ai.NATIVE;return oe&&(j||!(Ua&&(N||Ns)))}var Ks=(M,X)=>{let{debug:x,streamType:fe,startTime:oe=-1,metadata:Q,preferCmcd:N}=M,j=xa(M)===bi.M3U8,te=Ka(M,X);if(j&&!te&&Ua){let R={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},p=Hs(fe),w=N!==Qn.NONE?{useHeaders:N===Qn.HEADER,sessionId:Q.view_session_id,contentId:Q.video_id}:void 0;return new Tr({debug:x,startPosition:oe,cmcd:w,...R,...p})}},Hs=M=>[hn.LIVE,hn.DVR].includes(M)?{backBufferLength:8}:[hn.LL_LIVE,hn.LL_DVR].includes(M)?{backBufferLength:4,maxFragLookUpTolerance:.001}:{},Ha=({playbackId:M,src:X,customDomain:x})=>{if(M)return!0;if(typeof X!="string")return!1;let fe=window==null?void 0:window.location.href,oe=new URL(X,fe).hostname.toLocaleLowerCase();return oe.includes(Na)||!!x&&oe.includes(x.toLocaleLowerCase())},qs=(M,X,x)=>{var fe;let{envKey:oe}=M,Q=Ha(M);if(oe||Q){let{playerInitTime:N,playerSoftwareName:j,playerSoftwareVersion:te,beaconCollectionDomain:R,debug:p,disableCookies:w}=M,k={...M.metadata,video_title:((fe=M==null?void 0:M.metadata)==null?void 0:fe.video_title)||void 0},me=re=>typeof re.player_error_code=="string"?!1:typeof M.errorTranslator=="function"?M.errorTranslator(re):re;fn.default.monitor(X,{debug:p,beaconCollectionDomain:R,hlsjs:x,Hls:x?Tr:void 0,automaticErrorTracking:!1,errorTranslator:me,disableCookies:w,data:{...oe?{env_key:oe}:{},player_software_name:j,player_software:j,player_software_version:te,player_init_time:N,...k}})}},Vs=(M,X,x)=>{var fe;let oe=Ka(M,X),{src:Q}=M;X&&oe?(typeof Q=="string"?(X.setAttribute("src",Q),M.startTime&&(((fe=qi.get(X))!=null?fe:{}).startTime=M.startTime,X.addEventListener("durationchange",qa,{once:!0}))):X.removeAttribute("src"),X.addEventListener("error",Va),X.addEventListener("error",$n)):x&&Q?(x.on(Tr.Events.ERROR,(N,j)=>{let te={[Tr.ErrorTypes.NETWORK_ERROR]:mr.MEDIA_ERR_NETWORK,[Tr.ErrorTypes.MEDIA_ERROR]:mr.MEDIA_ERR_DECODE},R=new mr("",te[j.type]);R.fatal=j.fatal,R.data=j,X.dispatchEvent(new CustomEvent("error",{detail:R}))}),X.addEventListener("error",$n),Is(X,x),x.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 qa(M){var X;let x=M.target,fe=(X=qi.get(x))==null?void 0:X.startTime;if(!!fe&&As(x.seekable,x.duration,fe)){let oe=x.preload==="auto";oe&&(x.preload="none"),x.currentTime=fe,oe&&(x.preload="auto")}}async function Va(M){if(!M.isTrusted)return;M.stopImmediatePropagation();let X=M.target;if(!(X!=null&&X.error))return;let{message:x,code:fe}=X.error,oe=new mr(x,fe);if(X.src&&(fe!==mr.MEDIA_ERR_DECODE||fe!==void 0))try{let{status:Q}=await fetch(X.src);oe.data={response:{code:Q}}}catch{}X.dispatchEvent(new CustomEvent("error",{detail:oe}))}function $n(M){var X,x;if(!(M instanceof CustomEvent)||!(M.detail instanceof mr))return;let fe=M.target,oe=M.detail;!oe||!oe.fatal||(((X=qi.get(fe))!=null?X:{}).error=oe,(x=fe.mux)==null||x.emit("error",{player_error_code:oe.code,player_error_message:oe.message}))}var Ys=()=>{try{return"0.9.4"}catch{}return"UNKNOWN"},Ws=Ys(),Ya=()=>Ws;var Wa=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],Xa=Vn.createElement("template");Xa.innerHTML=`
|
|
33
33
|
<style>
|
|
34
34
|
:host {
|
|
35
35
|
/* display:inline (like the native el) makes it so you can't fill
|
|
@@ -52,7 +52,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
52
52
|
|
|
53
53
|
<audio part="audio" crossorigin></audio>
|
|
54
54
|
<slot></slot>
|
|
55
|
-
`;var
|
|
55
|
+
`;var Vi,_i,gn,si=class extends Pr.HTMLElement{constructor(){super();Lr(this,_i);Lr(this,Vi,void 0);this.attachShadow({mode:"open"}),this.isConnected&&ii(this,_i,gn).call(this)}static get observedAttributes(){let x=[];Object.getOwnPropertyNames(this.prototype).forEach(oe=>{let Q=!1;try{typeof this.prototype[oe]=="function"&&(Q=!0)}catch{}!Q&&oe!==oe.toUpperCase()&&x.push(oe.toLowerCase())});let fe=Object.getPrototypeOf(this).observedAttributes;return fe&&(x=x.concat(fe)),x}attributeChangedCallback(x,fe,oe){ii(this,_i,gn).call(this),this.forwardAttribute(x,fe,oe)}forwardAttribute(x,fe,oe){let Q=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),N=zs(Q,x),j=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;N&&!j?typeof this[N]=="boolean"?oe===null?this[N]=!1:this[N]=!0:this[N]=oe:oe===null?this.nativeEl.removeAttribute(x):["id","class"].indexOf(x)===-1&&this.nativeEl.setAttribute(x,oe)}connectedCallback(){ii(this,_i,gn).call(this)}};Vi=new WeakMap,_i=new WeakSet,gn=function(){if(pr(this,Vi))return;Rr(this,Vi,!0),this.shadowRoot.append(Xa.content.cloneNode(!0));let x=this.nativeEl=this.shadowRoot.querySelector("audio");Wa.forEach(oe=>{x.addEventListener(oe,Q=>{this.dispatchEvent(new CustomEvent(Q.type,{detail:Q.detail}))})});let fe=this.shadowRoot.querySelector("slot");fe.addEventListener("slotchange",()=>{fe.assignedElements().forEach(oe=>{!["track","source"].includes(oe.localName)||x.append(oe)})}),Array.from(this.attributes).forEach(oe=>{this.forwardAttribute(oe.name,null,oe.value)}),x.defaultMuted&&(x.muted=!0)};var za=[],Qa=Vn.createElement("audio"),Xs=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let M=Object.getPrototypeOf(Qa);M&&M!==Pr.HTMLElement.prototype;M=Object.getPrototypeOf(M))Object.keys(M).forEach(X=>{Xs.indexOf(X)===-1&&za.push(X)});za.forEach(M=>{if(typeof Qa[M]=="function")si.prototype[M]=function(){return this.nativeEl[M].apply(this.nativeEl,arguments)};else{let x={get(){return this.nativeEl[M]}};M!==M.toUpperCase()&&(x.set=function(fe){this.nativeEl[M]=fe}),Object.defineProperty(si.prototype,M,x)}});function zs(M,X){let x=null;return M.forEach(fe=>{fe.toLowerCase()==X.toLowerCase()&&(x=fe)}),x}Pr.customElements.get("custom-audio")||(Pr.customElements.define("custom-audio",si),Pr.CustomAudioElement=si);var ta=si;var xt={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_PLAYBACK:"prefer-playback",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",DISABLE_COOKIES:"disable-cookies",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},Qs=Object.values(xt),Js=Ya(),$s="mux-audio",xr,Si,Wi,Ai,Xi,ra,Yi=class extends ta{constructor(){super();Lr(this,Xi);Lr(this,xr,void 0);Lr(this,Si,void 0);Lr(this,Wi,void 0);Lr(this,Ai,{});Rr(this,Wi,Ba())}static get observedAttributes(){var x;return[...Qs,...(x=ta.observedAttributes)!=null?x:[]]}get playerInitTime(){return pr(this,Wi)}get playerSoftwareName(){return $s}get playerSoftwareVersion(){return Js}get _hls(){var x;return(x=pr(this,xr))==null?void 0:x.engine}get mux(){return this.nativeEl.mux}get src(){return this.getAttribute("src")}set src(x){x!==this.src&&(x==null?this.removeAttribute("src"):this.setAttribute("src",x))}get preload(){let x=this.getAttribute("preload");return x===""?"auto":["none","metadata","auto"].includes(x)?x:super.preload}set preload(x){x!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(x)?this.setAttribute("preload",x):this.removeAttribute("preload"))}get debug(){return this.getAttribute(xt.DEBUG)!=null}set debug(x){x!==this.debug&&(x?this.setAttribute(xt.DEBUG,""):this.removeAttribute(xt.DEBUG))}get disableCookies(){return this.hasAttribute(xt.DISABLE_COOKIES)}set disableCookies(x){x!==this.disableCookies&&(x?this.setAttribute(xt.DISABLE_COOKIES,""):this.removeAttribute(xt.DISABLE_COOKIES))}get startTime(){let x=this.getAttribute(xt.START_TIME);if(x==null)return;let fe=+x;return Number.isNaN(fe)?void 0:fe}set startTime(x){x!==this.startTime&&(x==null?this.removeAttribute(xt.START_TIME):this.setAttribute(xt.START_TIME,`${x}`))}get playbackId(){var x;return(x=this.getAttribute(xt.PLAYBACK_ID))!=null?x:void 0}set playbackId(x){x!==this.playbackId&&(x?this.setAttribute(xt.PLAYBACK_ID,x):this.removeAttribute(xt.PLAYBACK_ID))}get envKey(){var x;return(x=this.getAttribute(xt.ENV_KEY))!=null?x:void 0}set envKey(x){x!==this.envKey&&(x?this.setAttribute(xt.ENV_KEY,x):this.removeAttribute(xt.ENV_KEY))}get beaconCollectionDomain(){var x;return(x=this.getAttribute(xt.BEACON_COLLECTION_DOMAIN))!=null?x:void 0}set beaconCollectionDomain(x){x!==this.beaconCollectionDomain&&(x?this.setAttribute(xt.BEACON_COLLECTION_DOMAIN,x):this.removeAttribute(xt.BEACON_COLLECTION_DOMAIN))}get streamType(){var x;return(x=this.getAttribute(xt.STREAM_TYPE))!=null?x:void 0}set streamType(x){x!==this.streamType&&(x?this.setAttribute(xt.STREAM_TYPE,x):this.removeAttribute(xt.STREAM_TYPE))}get preferPlayback(){let x=this.getAttribute(xt.PREFER_PLAYBACK);if(x===ai.MSE||x===ai.NATIVE)return x}set preferPlayback(x){x!==this.preferPlayback&&(x===ai.MSE||x===ai.NATIVE?this.setAttribute(xt.PREFER_PLAYBACK,x):this.removeAttribute(xt.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(fe=>fe.startsWith("metadata-")&&![xt.METADATA_URL].includes(fe)).reduce((fe,oe)=>{let Q=this.getAttribute(oe);return Q!=null&&(fe[oe.replace(/^metadata-/,"").replace(/-/g,"_")]=Q),fe},{}),...pr(this,Ai)}}set metadata(x){Rr(this,Ai,x!=null?x:{}),this.mux&&(console.info("Some metadata values may not be overridable at this time. Make sure you set all metadata to override before setting the src."),this.mux.emit("hb",pr(this,Ai)))}load(){Rr(this,xr,Ga(this,this.nativeEl,pr(this,xr)))}unload(){ea(this.nativeEl,pr(this,xr)),Rr(this,xr,void 0)}attributeChangedCallback(x,fe,oe){var Q,N;switch(super.attributeChangedCallback(x,fe,oe),x){case"src":{let j=!!fe,te=!!oe;!j&&te?ii(this,Xi,ra).call(this):j&&!te?this.unload():j&&te&&(this.unload(),ii(this,Xi,ra).call(this));break}case"autoplay":if(oe===fe)break;(Q=pr(this,xr))==null||Q.setAutoplay(this.autoplay);break;case"preload":if(oe===fe)break;(N=pr(this,xr))==null||N.setPreload(oe);break;case xt.PLAYBACK_ID:this.src=ja(oe!=null?oe:void 0);break;case xt.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 xt.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()}};xr=new WeakMap,Si=new WeakMap,Wi=new WeakMap,Ai=new WeakMap,Xi=new WeakSet,ra=async function(){pr(this,Si)||(await Rr(this,Si,Promise.resolve()),Rr(this,Si,null),this.load())};Pr.customElements.get("mux-audio")||(Pr.customElements.define("mux-audio",Yi),Pr.MuxAudioElement=Yi);var To=Yi;export{Wa as AudioEvents,mr as MediaError,To as default};
|
|
56
56
|
/*!
|
|
57
57
|
* JavaScript Cookie v2.1.3
|
|
58
58
|
* https://github.com/js-cookie/js-cookie
|