/*! JW Player version 8.38.3 Copyright (c) 2025, JW Player, All Rights Reserved This source code and its use and distribution is subject to the terms and conditions of the applicable license agreement. https://www.jwplayer.com/tos/ This product includes portions of other software. For the full text of licenses, see https://ssl.p.jwpcdn.com/player/v/8.38.3/notice.txt */ (self.webpackChunkjwplayer=self.webpackChunkjwplayer||[]).push([[98],{8377:(e,t,i)=>{"use strict";i.d(t,{M:()=>r,_:()=>n});const r=function(e,t){let i;const r=e.kind||"cc";return i=e.default||e.defaulttrack?"default":e._id||e.file||r+t,i},n=function(e,t){let i=e.label||e.name||e.language;return i||(i="CC",(t+=1)>1&&(i+=` [${t}]`)),{label:i,unknownCount:t}}},6103:(e,t,i)=>{"use strict";i.d(t,{VS:()=>g,xl:()=>f});var r=i(7477),n=i(2894),a=i(6886),s=i(7941),o=i(7387),l=i(2957),u=i(4446);const d=e=>{throw new u.rG(null,e)};const h=function(e){return e.map((e=>new r.Z(e.begin,e.end,e.text)))},c=function(e,t,r,a){let c,f,g=e.responseXML?e.responseXML.firstChild:null;if(g)for("xml"===(0,s.r1)(g)&&(g=g.nextSibling);g&&g.nodeType===g.COMMENT_NODE;)g=g.nextSibling;try{if(g&&"tt"===(0,s.r1)(g)){if(!e.responseXML)throw new Error("Empty XML response");c=function(e){e||d(306007);const t=[];let i=e.getElementsByTagName("p"),r=30;const n=e.getElementsByTagName("tt");if(null!=n&&n[0]){const e=parseFloat(n[0].getAttribute("ttp:frameRate")||"");isNaN(e)||(r=e)}i||d(306005),i.length||(i=e.getElementsByTagName("tt:p"),i.length||(i=e.getElementsByTagName("tts:p")));for(let n=0;n\s+<").replace(/(<\/?)tts?:/g,"$1").replace(//g,"\r\n");if(u){const e=a.getAttribute("begin")||"",i=a.getAttribute("dur")||"",n=a.getAttribute("end")||"",s={begin:(0,l.m9)(e,r),text:u};n?s.end=(0,l.m9)(n,r):i&&(s.end=(s.begin||0)+(0,l.m9)(i,r)),t.push(s)}}return t.length||d(306005),t}(e.responseXML),f=h(c),delete t.xhr,r(f)}else{const s=e.responseText;s.indexOf("WEBVTT")>=0?i.e(347).then(function(e){return i(2776).default}.bind(null,i)).catch((0,n.Jt)(301131)).then((e=>{const i=new e(window);f=[],i.oncue=function(e){f.push(e)},i.onflush=function(){delete t.xhr,r(f)},i.parse(s)})).catch((e=>{delete t.xhr,a((0,u.Mm)(null,u.Y7,e))})):(c=(0,o.Z)(s),f=h(c),delete t.xhr,r(f))}}catch(e){delete t.xhr,a((0,u.Mm)(null,u.Y7,e))}},f=function(e,t,i){e.xhr=(0,a.h)(e.file,(function(r){c(r,e,t,i)}),((e,t,r,n)=>{i((0,u.l9)(n,u.Y7))}))},g=function(e){e&&e.forEach((e=>{const t=e.xhr;t&&(t.onload=null,t.onreadystatechange=null,t.onerror=null,"abort"in t&&t.abort()),delete e.xhr}))}},7387:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var r=i(2957);const n=e=>{const t={},i=e.split(/\r?\n/);let n=1;if(i[0].indexOf(" --\x3e ")>0&&(n=0),i.length>n+1&&i[n+1]){const e=i[n],a=e.indexOf(" --\x3e ");a>0&&(t.begin=(0,r.m9)(e.substr(0,a)),t.end=(0,r.m9)(e.substr(a+5)),t.text=i.slice(n+1).join("\r\n"))}return t};function a(e){const t=[],i=(e=(0,r.fy)(e)).split(/(\r?\n){2}/);for(let e=0;e{"use strict";i.d(t,{Z:()=>a});let r=window.VTTCue;const n=e=>{if("string"!=typeof e)return!1;return!!{start:!0,middle:!0,end:!0,left:!0,right:!0}[e.toLowerCase()]&&e.toLowerCase()};if(!r){const e="auto";r=function(t,i,r){const a=this;a.hasBeenReset=!1;let s="",o=!1,l=t,u=i,d=r,h=null,c="",f=!0,g=e,v="start",m=e,p=100,y="middle";Object.defineProperty(a,"id",{enumerable:!0,get:()=>s,set(e){s=`${e}`}}),Object.defineProperty(a,"pauseOnExit",{enumerable:!0,get:()=>o,set(e){o=Boolean(e)}}),Object.defineProperty(a,"startTime",{enumerable:!0,get:()=>l,set(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");l=e,this.hasBeenReset=!0}}),Object.defineProperty(a,"endTime",{enumerable:!0,get:()=>u,set(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");u=e,this.hasBeenReset=!0}}),Object.defineProperty(a,"text",{enumerable:!0,get:()=>d,set(e){d=`${e}`,this.hasBeenReset=!0}}),Object.defineProperty(a,"region",{enumerable:!0,get:()=>h,set(e){h=e,this.hasBeenReset=!0}}),Object.defineProperty(a,"vertical",{enumerable:!0,get:()=>c,set(e){const t=(e=>"string"==typeof e&&(!!{"":!0,lr:!0,rl:!0}[e.toLowerCase()]&&e.toLowerCase()))(e);if(!1===t)throw new SyntaxError("An invalid or illegal string was specified.");c=t,this.hasBeenReset=!0}}),Object.defineProperty(a,"snapToLines",{enumerable:!0,get:()=>f,set(e){f=Boolean(e),this.hasBeenReset=!0}}),Object.defineProperty(a,"line",{enumerable:!0,get:()=>g,set(t){if("number"!=typeof t&&t!==e)throw new SyntaxError("An invalid number or illegal string was specified.");g=t,this.hasBeenReset=!0}}),Object.defineProperty(a,"lineAlign",{enumerable:!0,get:()=>v,set(e){const t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");v=t,this.hasBeenReset=!0}}),Object.defineProperty(a,"position",{enumerable:!0,get:()=>m,set(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");m=e,this.hasBeenReset=!0}}),Object.defineProperty(a,"size",{enumerable:!0,get:()=>p,set(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");p=e,this.hasBeenReset=!0}}),Object.defineProperty(a,"align",{enumerable:!0,get:()=>y,set(e){const t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}}),a.displayState=void 0},r.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)}}const a=r},2728:(e,t,i)=>{"use strict";i.d(t,{Z:()=>a});var r=i(1643),n=i(6042);function a(e,t){let i,a=t;return{start(){this.stop(),i=window.setInterval((()=>{const t=e.getBandwidthEstimate();(0,n.qh)(t)&&(a=t,e.trigger(r.qG,{bandwidthEstimate:a}))}),1e3)},stop(){clearInterval(i)},getEstimate:()=>a}}},548:(e,t,i)=>{"use strict";i.d(t,{Zv:()=>r,i0:()=>a,pR:()=>n});const r=1,n=r+1,a=25},4506:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});const r=e=>({bitrate:e.bitrate,label:e.label,width:e.width,height:e.height})},3328:(e,t,i)=>{"use strict";i.d(t,{Z:()=>A});var r=i(6103),n=i(8377);const a={TIT2:"title",TT2:"title",WXXX:"url",TPE1:"artist",TP1:"artist",TALB:"album",TAL:"album"},s=(e,t)=>{const i=e.length;let r,n,a,s="",o=t||0;for(;o>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:s+=String.fromCharCode(r);break;case 12:case 13:n=e[o++],s+=String.fromCharCode((31&r)<<6|63&n);break;case 14:n=e[o++],a=e[o++],s+=String.fromCharCode((15&r)<<12|(63&n)<<6|63&a)}return s},o=e=>{const t=(e=>{let t="0x";for(let i=0;i>1|(8323072&t)>>2|(2130706432&t)>>3},l=e=>{const t={};if(!("value"in e)&&"data"in e&&e.data instanceof ArrayBuffer){const t=new Uint8Array(e.data);let i=t.length;e={value:{key:"",data:""}};let r=10;for(;r<14&&r0){const i=s(t.subarray(n,n+=l),0);if("PRIV"===e.value.key){if("com.apple.streaming.transportStreamTimestamp"===i){const i=1&o(t.subarray(n,n+=4)),r=o(t.subarray(n,n+=4))+(i?4294967296:0);e.value.data=r}else e.value.data=s(t,n+1);e.value.info=i}else e.value.info=i,e.value.data=s(t,n+1)}else{const i=t[n];e.value.data=1===i||2===i?((e,t)=>{const i=e.length-1;let r="",n=t||0;for(;n{null!=t&&t.length&&(0,h.S6)(t,(function(t){const r=t._id||"";if(i&&(t._id=void 0),!u.Browser.ie&&!u.Browser.safari||!e||!/^(native|subtitle|cc)/.test(r)){if(u.Browser.ie&&"disabled"===t.mode||(t.mode="disabled",t.mode="hidden"),t.cues)for(let e=t.cues.length;e--;)t.removeCue(t.cues[e]);t.embedded||(t.mode="disabled"),t.inuse=!1}}))},g=e=>/^native(?:captions|subtitles)/.test(e),v=e=>"captions"===e||"subtitles"===e,m=function(e){const t=e.target,{activeCues:i,cues:r}=t,n=t._id,a=this._cues,s=this._activeCues;if(null!=r&&r.length){const e=a[n];a[n]=Array.prototype.slice.call(r),this.parseNativeID3Cues(r,e)}else delete a[n];if(null!=i&&i.length){const e=s[n],r=s[n]=Array.prototype.slice.call(i);this.triggerActiveCues(r,e,t)}else delete s[n]},p=(e,t,i)=>{if(u.Browser.ie){let r=i;(e||"metadata"===t.kind)&&(r=new window.TextTrackCue(i.startTime,i.endTime,i.text),i.value&&(r.value=i.value)),((e,t)=>{const i=[],r=e.mode;e.mode="hidden";const n=e.cues;if(n)for(let r=n.length-1;r>=0&&n[r].startTime>t.startTime;r--)i.unshift(n[r]),e.removeCue(n[r]);try{e.addCue(t),i.forEach((t=>e.addCue(t)))}catch(e){c.error(e)}e.mode=r})(t,r)}else try{t.addCue(i)}catch(e){c.error(e)}},y=function(e){const t=this._textTracks,i=this._tracksById;if(e.length>t.length)return!0;for(let t=0;te.startTime===t.startTime&&e.endTime===t.endTime&&e.text===t.text&&e.data===t.data&&JSON.stringify(e.value)===JSON.stringify(t.value),L=e=>{const t=l(e);return{metadataType:"id3",metadataTime:e.startTime,metadata:t}},A={_itemTracks:null,_textTracks:null,_currentTextTrackIndex:-1,_tracksById:null,_cuesByTrackId:null,_cachedVTTCues:null,_metaCuesByTextTime:null,_unknownCount:0,_activeCues:null,_cues:null,textTrackChangeHandler:null,addTrackHandler:null,cueChangeHandler:null,renderNatively:!1,_initTextTracks(){this._textTracks=[],this._tracksById={},this._metaCuesByTextTime={},this._cuesByTrackId={},this._cachedVTTCues={},this._cues={},this._activeCues={},this._unknownCount=0},addTracksListener(e,t,i){e&&(this.removeTracksListener(e,t,i),this.instreamMode||(e.addEventListener?e.addEventListener(t,i):e[`on${t}`]=i))},removeTracksListener(e,t,i){e&&(e.removeEventListener&&i?e.removeEventListener(t,i):e[`on${t}`]=null)},clearTracks(){(0,r.VS)(this._itemTracks);const{_tracksById:e}=this;if(e&&Object.keys(e).forEach((t=>{if(0===t.indexOf("nativemetadata")){const i=e[t];this.cueChangeHandler&&i.removeEventListener("cuechange",this.cueChangeHandler),f(this.renderNatively,[i],!0)}})),this._itemTracks=null,this._textTracks=null,this._tracksById=null,this._cuesByTrackId=null,this._metaCuesByTextTime=null,this._unknownCount=0,this._currentTextTrackIndex=-1,this._activeCues={},this._cues={},this.renderNatively){const e=this.video.textTracks;this.textTrackChangeHandler&&this.removeTracksListener(e,"change",this.textTrackChangeHandler),f(this.renderNatively,e,!0)}},clearMetaCues(){const{_tracksById:e,_cachedVTTCues:t}=this;e&&t&&Object.keys(e).forEach((i=>{if(0===i.indexOf("nativemetadata")){const r=e[i];f(this.renderNatively,[r],!1),r.mode="hidden",r.inuse=!0,r._id&&(t[r._id]={})}}))},clearCueData(e){const t=this._cachedVTTCues;var i;null!=t&&t[e]&&(t[e]={},null!=(i=this._tracksById)&&i[e]&&(this._tracksById[e].data=[]))},disableTextTrack(){const e=this.getCurrentTextTrack();if(e){e.mode="disabled";const t=e._id;(t&&g(t)||this.renderNatively&&u.OS.iOS)&&(e.mode="hidden")}},enableTextTrack(){const e=this.getCurrentTextTrack();e&&(e.mode="showing")},getCurrentTextTrack(){if(this._textTracks)return this._textTracks[this._currentTextTrackIndex]},getSubtitlesTrack(){return this._currentTextTrackIndex},addTextTracks(e){var t;const i=[];return e?(this._textTracks||this._initTextTracks(),e.forEach((e=>{if(e.includedInManifest||e.kind&&!v(e.kind))return;const t=this._createTrack(e);this._addTrackToList(t),i.push(t),e.file&&(e.data=[],(0,r.xl)(e,(e=>{t.sideloaded=!0,this.addVTTCuesToTrack(t,e)}),(e=>{this.trigger(d.cM,e)})))})),null!=this&&null!=(t=this._textTracks)&&t.length&&this.trigger(d.jt,{tracks:this._textTracks}),i):i},setTextTracks(e){var t;if(this._currentTextTrackIndex=-1,e){if(this._textTracks){const e=this._tracksById;this._activeCues={},this._cues={},this._unknownCount=0,this._textTracks=this._textTracks.filter((t=>{const i=t._id;return this.renderNatively&&i&&g(i)?(delete e[i],!1):(t.name&&0===t.name.indexOf("CC")&&this._unknownCount++,0===i.indexOf("nativemetadata")&&"com.apple.streaming"===t.inBandMetadataTrackDispatchType&&delete e[i],!0)}),this)}else this._initTextTracks();if(e.length){let t=0;const i=e.length,r=this._tracksById,a=this._cuesByTrackId;for(;t{e.mode=e.embedded?"hidden":"disabled"})),this._currentTextTrackIndex===e-1)return;this.disableTextTrack(),this._currentTextTrackIndex=e-1;const t=this.getCurrentTextTrack();if(t){const e=this.cueChangeHandler=this.cueChangeHandler||m.bind(this);t.removeEventListener("cuechange",e),t.addEventListener("cuechange",e),t.mode="showing"}this.trigger(d.UF,{currentTrack:this._currentTextTrackIndex+1,tracks:this._textTracks})},createCue:(e,t,i)=>new(window.VTTCue||window.TextTrackCue)(e,Math.max(t||0,e+.25),i),addVTTCue(e,t){this._tracksById||this._initTextTracks();const i=e.track?e.track:`native${e.type}`;let r=this._tracksById[i];const n="captions"===e.type?"CC":"ID3 Metadata",a=e.cue;if(!r){const t={kind:e.type,_id:i,label:n,default:!1};this.renderNatively||"metadata"===t.kind?(r=this._createTrack(t),r.embedded=!0,this.setTextTracks(this.video.textTracks)):r=this.addTextTracks([t])[0]}if(this._cacheVTTCue(r,a,t)){const e=this.renderNatively||"metadata"===r.kind;return e?p(e,r,a):r.data.push(a),a}return null},addVTTCuesToTrack(e,t){var i,r;if(!this.renderNatively)return;const n=e._id,a=this._tracksById;let s=this._cuesByTrackId;const o=a[n];if(!o)return s||(s=this._cuesByTrackId={}),void(s[n]={cues:t,loaded:!1});if(null!=(i=s)&&null!=(r=i[n])&&r.loaded)return;let l;for(s[n]={cues:t,loaded:!0};l=t.shift();)p(this.renderNatively,o,l)},parseNativeID3Cues(e,t){const i=e[e.length-1];if(t&&t.length===e.length&&(i._parsed||S(t[t.length-1],i)))return;const r=[],n=[];let a=-1,s=-1,o=-1;for(let t=0;t0)for(let t=0;t{const t=L(e);this.trigger(d.O1,t)}))},triggerActiveCues(e,t,i){const r=e[0];if(null!=r&&r.track&&"showing"===r.track.mode){const{kind:e,label:t,language:n,mode:a,activeCues:s}=r.track,{_id:o}=i;this.trigger(d.zs,{id:o,kind:e,label:t,language:n,mode:a,activeCues:s?Array.from(s):null})}const n=e.filter((e=>{if(null!=t&&t.some((t=>S(e,t))))return!1;if(e.data)return!0;const i=e.text?(e=>{let t;try{t=JSON.parse(e.text)}catch(e){return null}const i={metadataType:t.metadataType,metadataTime:e.startTime,metadata:t};return t.programDateTime&&(i.programDateTime=t.programDateTime),i})(e):null;if(i)"emsg"===i.metadataType&&(i.metadata=i.metadata||{},i.metadata.messageData=e.value),this.trigger(d.rx,i);else if(e.value)return!0;return!1}));n.length&&n.forEach((e=>{const t=L(e);this.trigger(d.rx,t)}))},ensureMetaTracksActive(){const e=this.video.textTracks,t=e.length;for(let i=0;ie.embedded||"subs"===e.groupid));this._initTextTracks();const t=this._tracksById;e.forEach((e=>{t[e._id]=e})),this._textTracks=e}}},9601:(e,t,i)=>{"use strict";i.d(t,{E:()=>n,Z:()=>a});var r=i(4446);const n=e=>e>=400&&e<600?e:6;function a(e,t,i){let a=e+1e3,s=r.ul;return t>0?(403===t&&(s=r.H4),a+=n(t)):"http:"===`${i}`.substring(0,5)&&"https:"===document.location.protocol?a+=12:0===t&&(a+=11),{code:a,key:s}}},5099:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});const r=(e,t,i)=>{const r=new Error(i);return r.name=e,r.code=t,r};function n(e){return new Promise((function(t,i){if(e.paused)return i(r("NotAllowedError",0,"play() failed."));let n;const a=function(e){if(n(),"playing"!==e.type){const t=`The play() request was interrupted by a "${e.type}" event.`;return"error"===e.type?i(r("NotSupportedError",9,t)):i(r("AbortError",20,t))}t()},s=function(){e.addEventListener("playing",a),e.addEventListener("abort",a),e.addEventListener("error",a),e.addEventListener("pause",a)};n=function(){e.removeEventListener("play",s),e.removeEventListener("playing",a),e.removeEventListener("pause",a),e.removeEventListener("abort",a),e.removeEventListener("error",a)},e.addEventListener("play",s)}))}},5256:(e,t,i)=>{"use strict";i.d(t,{_T:()=>r,c3:()=>o,ji:()=>a});const r=e=>Math.floor(e/1e3),n=(e,t)=>{let i=null;if(t&&e){const n=Object.keys(e);if(n.length){const a=((e,t)=>{let i,r=null,n=1/0;return e.forEach((e=>{i=Math.abs(parseFloat(e)-t),i{if(!e)return"";const a=e.bitrate||e.bandwidth;return n(t,a)||((e,t,i)=>{if(!e&&!t)return"";let n="",a="";return t&&(a=`${r(t)} kbps`,n=a),e&&(n=`${e}p`,t&&i&&(n+=` (${a})`)),n})(e.height,a,i)},s=function(e,t){return e.some((function(e){let i;for(let r=0;r!!Array.isArray(e)&&s(e,["height","bitrate","bandwidth"])},686:(e,t,i)=>{"use strict";i.d(t,{s:()=>n,v:()=>a});const r=e=>void 0===e?120:Math.max(e,0),n=(e,t)=>e!==1/0&&Math.abs(e)>=Math.max(r(t),0),a=(e,t)=>{let i="VOD";return e===1/0?i="LIVE":e<0&&(i=n(e,r(t))?"DVR":"LIVE"),i}},3949:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var r=i(9974);const n={container:null,volume(e){this.video.volume=Math.min(Math.max(0,e/100),1)},mute(e){this.video.muted=Boolean(e),this.video.muted||this.video.removeAttribute("muted")},getContainer(){return this.container},setContainer(e){this.container=e,this.video.parentNode!==e&&e.appendChild(this.video)},removeFromContainer(){const{container:e,video:t}=this;this.container=null,e&&e===t.parentNode&&e.removeChild(t)},remove(){this.stop(),this.destroy(),this.removeFromContainer()},atEdgeOfLiveStream(){if(!this.isLive())return!1;return(0,r.Z)(this.video.buffered)-this.video.currentTime<=2}}},186:(e,t,i)=>{"use strict";i.d(t,{Z:()=>r});const r={_eventsOn(){},_eventsOff(){},attachMedia(){this._eventsOn()},detachMedia(){return this._eventsOff()}}},8702:(e,t,i)=>{"use strict";i.d(t,{Z:()=>s});var r=i(1643),n=i(1261),a=i(5678);const s={canplay(){this.renderNatively&&this.setTextTracks(this.video.textTracks),this.trigger(r.Jl)},play(){this.stallTime=-1,this.video.paused||this.state===r._5||this.state===r.r0||this.setState(r.ik)},loadedmetadata(){const e={metadataType:"media",duration:this.getDuration(),height:this.video.videoHeight,width:this.video.videoWidth,seekRange:this.getSeekRange()},t=this.drmUsed;t&&(e.drm=t),this.trigger(r.rx,e)},timeupdate(){const e=this.video.currentTime,t=this.getCurrentTime(),i=this.getDuration();if(isNaN(i))return;this.seeking||this.video.paused||this.state!==r.nQ&&this.state!==r.ik||this.stallTime===e||(this.stallTime=-1,this.setState(r.r0),this.trigger(r.Gj));const n={position:t,duration:i,currentTime:e,seekRange:this.getSeekRange(),metadata:{currentTime:e},absolutePosition:(0,a.e)(this)},s=this.getLiveLatency();if(null!==s&&(n.latency=s,this.getTargetLatency)){const e=this.getTargetLatency();null!==e&&(n.targetLatency=e)}(this.state===r.r0||this.seeking&&this.state!==r.bc)&&this.trigger(r.R2,n)},click(e){this.trigger(r.ot,e)},volumechange(){const e=this.video;this.trigger(r.yH,{volume:Math.round(100*e.volume)}),this.trigger(r.gy,{mute:e.muted})},seeking(){if(this.state===r.ik){const e=this.video.buffered.length?this.video.buffered.start(0):-1;if(this.video.currentTime===e)return}else if(this.state===r.bc)return;this.seeking=!0},seeked(){this.seeking&&(this.seeking=!1,this.trigger(r.aQ))},playing(){-1===this.stallTime&&this.setState(r.r0),this.trigger(r.Gj)},pause(){this.state!==r.xQ&&(this.video.ended||this.video.error||this.video.currentTime!==this.video.duration&&this.setState(r._5))},progress(){const e=this.getDuration();if(e<=0||e===1/0)return;const t=this.video.buffered;if(!t||0===t.length)return;const i=(0,n.v)(t.end(t.length-1)/e,0,1);this.trigger(r.uT,{bufferPercent:100*i,position:this.getCurrentTime(),duration:e,currentTime:this.video.currentTime,seekRange:this.getSeekRange(),absolutePosition:(0,a.e)(this)})},ratechange(){this.trigger(r.TJ,{playbackRate:this.video.playbackRate})},ended(){this.state!==r.bc&&this.state!==r.xQ&&this.trigger(r.Ms)}}},5678:(e,t,i)=>{"use strict";i.d(t,{e:()=>r});const r=e=>{var t;const i=1e3*(null==e||null==(t=e.video)?void 0:t.currentTime);return null!=e&&e.startDateTime&&i?new Date(e.startDateTime+i):null}},9974:(e,t,i)=>{"use strict";function r(e){return e&&e.length?e.end(e.length-1):0}i.d(t,{Z:()=>r})},9054:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>q});var r={};i.r(r),i.d(r,{debug:()=>g,error:()=>y,info:()=>m,log:()=>v,warn:()=>p});var n=i(6042);class a{constructor(e,t,i,r){this.video=e,this.hlsjs=i,this.videoListeners=t,this.hlsjsListeners=r}on(){this.off(),(0,n.S6)(this.videoListeners,((e,t)=>{this.video.addEventListener(t,e,!1)})),(0,n.S6)(this.hlsjsListeners,((e,t)=>{this.hlsjs.on(t,e)}))}off(){(0,n.S6)(this.videoListeners,((e,t)=>{this.video.removeEventListener(t,e)})),(0,n.S6)(this.hlsjsListeners,((e,t)=>{this.hlsjs.off(t,e)}))}}var s=i(5256),o=i(8348);const l=e=>e.audioGroupIds?e.audioGroupIds[e._urlId||e.urlId]:void 0,u=(e,t)=>{const i=(0,s.c3)(e),r=(0,n.UI)(e,((e,r)=>({label:(0,s.ji)(e,t,i),level_id:e.id,hlsjsIndex:r,bitrate:e.bitrate,height:e.height,width:e.width,audioGroupId:l(e)})));return r.sort(((e,t)=>e.height&&t.height&&e.height!==t.height?t.height-e.height:(t.bitrate||0)-(e.bitrate||0))),r.length>1&&r.unshift({label:"Auto",level_id:"auto",hlsjsIndex:-1}),r},d=(e,t)=>Math.max(0,(0,n.cq)(t,(0,n.sE)(t,(t=>t.hlsjsIndex===e)))),h=(e,t,i,r=e.length)=>{const n=(()=>{try{return window.devicePixelRatio}catch(e){}return 1})();t*=n,i*=n,o.OS.tizen&&(t=1/0,i=1/0);for(let n=0;n=t||r.height>=i)&&(a=r,!(s=e[n+1])||a.width!==s.width||a.height!==s.height))return n}var a,s;return r-1};const c=i(8494).Z.logger.child("providers/hlsjs"),f=e=>c[e].bind(c),g=f("debug"),v=f("log"),m=f("info"),p=f("warn"),y=f("error");var T=i(548),E=i(5083),S=i(4742);function L(e){const{withCredentials:t,aesToken:i,renderTextTracksNatively:a,onXhrOpen:s,liveSyncDuration:o,hlsjsConfig:l,cmcd:u}=e,d=(0,n.ei)(l||{},["liveSyncDuration","liveSyncDurationCount","liveMaxLatencyDuration","liveMaxLatencyDurationCount","liveBackBufferLength","backBufferLength","loader","pLoader","fLoader","fragLoadingMaxRetry","fragLoadingRetryDelay","enableWorker","debug"]),h={autoStartLoad:!1,capLevelToPlayerSize:!1,captionsTextTrack1Label:"",captionsTextTrack2Label:"",captionsTextTrack3Label:"",captionsTextTrack4Label:"",captionsTextTrack1LanguageCode:"",captionsTextTrack2LanguageCode:"",captionsTextTrack3LanguageCode:"",captionsTextTrack4LanguageCode:"",debug:!!S.Z.debug&&r,fragLoadingMaxRetry:2,fragLoadingRetryDelay:4e3,maxMaxBufferLength:T.i0,renderTextTracksNatively:a,startLevel:-1,testBandwidth:!1};u&&(h.cmcd={sessionId:u.sessionId,contentId:u.contentId,useHeaders:u.useHeaders});const{liveSyncDurationCount:c,liveMaxLatencyDurationCount:f,liveMaxLatencyDuration:g}=d;return void 0!==c||void 0!==f?(d.liveSyncDuration=d.liveMaxLatencyDuration=void 0,d.liveSyncDurationCount=(0,n.xV)(c)?c:1/0,d.liveMaxLatencyDurationCount=(0,n.xV)(f)?f:1/0):void 0===o&&void 0===g||(d.liveSyncDurationCount=d.liveMaxLatencyDurationCount=void 0,h.liveSyncDuration=(0,E.G0)(o),d.liveMaxLatencyDuration=(0,n.xV)(g)?g:1/0),t||i||s?Object.assign({},h,((e,t,i)=>({xhrSetup(r,n){if(e&&(r.withCredentials=!0),t){const e=n.indexOf("?")>0?"&token=":"?token=";r.open("GET",n+e+t,!0)}"function"==typeof i&&i(r,n)},fetchSetup(i,r){if(t){const e=i.url.indexOf("?")>0?"&token=":"?token=";i.url=i.url+e+t}return e&&(r.credentials="include"),new Request(i.url,r)}}))(t,i,s),d):Object.assign({},h,d)}var A=i(9601),R=i(4446);let k=function(e){return e[e.BASE_ERROR=23e4]="BASE_ERROR",e[e.ERROR_LIVE_STREAM_DOWN_OR_ENDED=230001]="ERROR_LIVE_STREAM_DOWN_OR_ENDED",e[e.MANIFEST_ERROR_CONNECTION_LOST=232002]="MANIFEST_ERROR_CONNECTION_LOST",e[e.ERROR_CONNECTION_LOST=230002]="ERROR_CONNECTION_LOST",e[e.MANIFEST_PARSING_ERROR=232600]="MANIFEST_PARSING_ERROR",e[e.LEVEL_EMPTY_ERROR=232631]="LEVEL_EMPTY_ERROR",e[e.MANIFEST_INCOMPATIBLE_CODECS_ERROR=232632]="MANIFEST_INCOMPATIBLE_CODECS_ERROR",e[e.FRAG_PARSING_ERROR=233600]="FRAG_PARSING_ERROR",e[e.FRAG_DECRYPT_ERROR=233650]="FRAG_DECRYPT_ERROR",e[e.BUFFER_STALLED_ERROR=234001]="BUFFER_STALLED_ERROR",e[e.BUFFER_APPEND_ERROR=234002]="BUFFER_APPEND_ERROR",e[e.PROTECTED_CONTENT_ACCESS_ERROR=232403]="PROTECTED_CONTENT_ACCESS_ERROR",e}({});const b=e=>{if(e){if(/^frag/.test(e))return 2e3;if(/^(manifest|level|audioTrack)/.test(e))return 1e3;if(/^key/.test(e))return 4e3}return 0};var I=i(328),D=i(3949),_=i(186),C=i(3328);class P extends I.ZP{}Object.assign(P.prototype,D.Z,_.Z,C.Z);const w=P;var x=i(4506),O=i(3343),M=i(686),F=i(1643),N=i(5004),B=i(8702),U=i(386),G=i(5099),K=i(2728),V=i(7477),H=i(1384);const j=(e,t,i)=>{const r=e.sources[0];return void 0!==r[i]?r[i]:void 0!==e[i]?e[i]:t[i]};var Y=i(4560);const W=function(e){const{MEDIA_ATTACHED:t,MEDIA_DETACHED:i,MANIFEST_PARSED:r,LEVEL_LOADED:s,LEVEL_UPDATED:c,LEVEL_PTS_UPDATED:f,FRAG_CHANGED:g,FRAG_LOADED:v,LEVEL_SWITCHED:m,FRAG_PARSING_METADATA:y,BUFFER_APPENDED:E,BUFFER_CODECS:S,FRAG_BUFFERED:I,INIT_PTS_FOUND:D,NON_NATIVE_TEXT_TRACKS_FOUND:_,CUES_PARSED:C,AUDIO_TRACKS_UPDATED:P,ERROR:Y}=e.Events,{MEDIA_ERROR:W,NETWORK_ERROR:q}=e.ErrorTypes,X=function(e){const{NETWORK_ERROR:t}=e.ErrorTypes,{MANIFEST_PARSING_ERROR:i,LEVEL_EMPTY_ERROR:r,MANIFEST_INCOMPATIBLE_CODECS_ERROR:n,FRAG_PARSING_ERROR:a,FRAG_DECRYPT_ERROR:s,BUFFER_STALLED_ERROR:o,BUFFER_APPEND_ERROR:l,INTERNAL_EXCEPTION:u,MANIFEST_LOAD_ERROR:d,MANIFEST_LOAD_TIMEOUT:h,LEVEL_LOAD_ERROR:c,LEVEL_LOAD_TIMEOUT:f,FRAG_LOAD_ERROR:g,FRAG_LOAD_TIMEOUT:v,BUFFER_SEEK_OVER_HOLE:m,BUFFER_NUDGE_ON_STALL:p}=e.ErrorDetails,y=[d,h,i,n,c,f,g,v],T=[o,m,p],E=[r,c,f];return function(e){const{details:d,response:h,type:c}=e;let f=e.fatal,g=y.indexOf(d)<0;const v=T.indexOf(d)>=0;let m=E.indexOf(d)>=0,p=R.ul,S=k.BASE_ERROR;switch(d){case i:S=k.MANIFEST_PARSING_ERROR;break;case r:S=k.LEVEL_EMPTY_ERROR;break;case n:p=R.zO,S=k.MANIFEST_INCOMPATIBLE_CODECS_ERROR;break;case a:S=k.FRAG_PARSING_ERROR;break;case s:S=k.FRAG_DECRYPT_ERROR;break;case o:S=k.BUFFER_STALLED_ERROR;break;case l:S=k.BUFFER_APPEND_ERROR;break;case u:S=239e3;break;default:c===t&&(!1===navigator.onLine?(g=!1,f="manifestLoadError"===d,m=!1,S=f?k.MANIFEST_ERROR_CONNECTION_LOST:k.ERROR_CONNECTION_LOST,p=R.MD):/TimeOut$/.test(d)?S=k.BASE_ERROR+1001+b(d):h&&(({code:S,key:p}=(0,A.Z)(k.BASE_ERROR,h.code,e.url)),S+=b(d)))}return{key:p,code:S,recoverable:g,stalling:v,suppressLevel:m,fatal:f,error:e}}}(e);return class A extends w{constructor(e,t,i){var r;super(),this.bandwidthMonitor=(0,K.Z)(this,t.bandwidthEstimate),this.bitrateSelection=t.bitrateSelection,this.bufferStallTimeout=1e3,this.connectionTimeoutDuration=1e4,this.dvrEnd=null,this.dvrPosition=null,this.dvrUpdatedTime=0,this.eventHandler=null,this.hlsjs=null,this.hlsjsConfig=null,this.hlsjsOptions=null,this.jwConfig=t,this.lastPosition=0,this.maxRetries=3,this.playerId=e,this.processPlaylistMetadata=O.q,this.recoveryInterval=5e3,this.renderNatively=(r=t.renderCaptionsNatively,!(!o.OS.iOS&&!o.Browser.safari)||o.Browser.chrome&&r),this.savedVideoProperties=!1,this.seeking=!1,this.staleManifestDurationMultiplier=3e3,this.state=F.bc,this.supports=A.supports,this.supportsPlaybackRate=!0,this.video=i,this.playerWidth=0,this.playerHeight=0,this.playerStretching=null,this.capLevels=!1,this.levelDuration=0,this.live=!1,this.liveEdgePosition=null,this.liveEdgeUpdated=0,this.staleManifestTimeout=-1,this.connectionTimeout=-1,this.programDateSyncTime=0,this.retryCount=0,this.stallTime=-1,this.jwLevels=[],this.audioTracks=null,this.audioTracksArray=null,this.resetLifecycleVariables()}resetLifecycleVariables(){this.resetRecovery(),this.stopStaleTimeout(),this.stopConnectionTimeout(),this.stallTime=-1,this.streamBitrate=-1,this.videoFound=!1,this.videoHeight=0,this.src=null,this.currentHlsjsLevel=null,this.currentAudioTrackIndex=null,this.currentJwItem=null,this.jwLevels=[],this.audioTracks=null,this.audioTracksArray=null,this.lastRecoveryTime=null,this.lastEndSn=null,this.levelDuration=0,this.live=!1,this.liveEdgePosition=null,this.liveEdgeUpdated=0,this.liveEdgeSn=-1,this.isLiveStreamUnloaded=!1,this.recoveringMediaError=!1,this.recoveringNetworkError=!1,this.streamType="VOD",this.lastProgramDateTime=0,this.programDateSyncTime=0}resetRecovery(){this.retryCount=0}stopStaleTimeout(){-1!==this.staleManifestTimeout&&clearTimeout(this.staleManifestTimeout),this.staleManifestTimeout=-1}stopConnectionTimeout(){-1!==this.connectionTimeout&&clearTimeout(this.connectionTimeout),this.connectionTimeout=-1}startConnectionTimeout(){-1===this.connectionTimeout&&(this.connectionTimeout=window.setTimeout((()=>{navigator.onLine?this.hlsjs.startLoad():this.handleError(k.ERROR_CONNECTION_LOST,null,R.MD)}),this.connectionTimeoutDuration))}initHlsjs(t){var i;const r=this.jwConfig.hlsjsConfig,s=Boolean(this.jwConfig.cmcd),o=Boolean(this.hlsjsOptions);let l=null==(i=this.hlsjsOptions)?void 0:i.cmcd;!o&&s&&(l=Object.assign({},{contentId:null==t?void 0:t.mediaid},this.jwConfig.cmcd));const u={cmcd:l,withCredentials:Boolean(j(t,this.jwConfig,"withCredentials")),aesToken:j(t,this.jwConfig,"aestoken"),renderTextTracksNatively:this.renderNatively,onXhrOpen:t.sources[0].onXhrOpen,liveSyncDuration:j(t,this.jwConfig,"liveSyncDuration"),hlsjsConfig:r};if(this.setupSideloadedTracks(t.tracks),this.capLevels=!t.stereomode,this.hlsjs&&(0,n.wB)(this.hlsjsOptions)(u))return;this.hlsjsOptions=u,this.restoreVideoProperties(),this.stopStaleTimeout(),this.stopConnectionTimeout(),this.hlsjsConfig=L(u);const d=Object.assign({},this.hlsjsConfig),h=this.bandwidthMonitor.getEstimate();(0,n.qh)(h)&&(d.abrEwmaDefaultEstimate=h),d.appendErrorMaxRetry=1,this.hlsjs=new e(d),this.eventHandler=new a(this.video,this.createVideoListeners(),this.hlsjs,this.createHlsjsListeners())}init(e){this.destroy(),this.initHlsjs(e)}preload(e){"metadata"===e.preload&&(this.maxBufferLength=T.Zv),this.load(e)}load(e){const{hlsjs:t,video:i,src:r}=this;if(!t)return;const n=e.sources[0].file,a=n.url&&"string"==typeof n.url?n.url:n;if(r===a&&this.videoSrc===i.src)return void(this.maxBufferLength=T.i0);let s=e.starttime||-1;s<-1&&(s=this.lastPosition),this.initHlsjs(e),this.currentJwItem=e,this.src=a,this.videoHeight=0,this._eventsOn(),t.config.startPosition=s,t.loadSource(a),t.attachMedia(i),this.videoSrc=i.src}restartStream(e){const t=Object.assign({},this.currentJwItem);e?t.starttime=e:delete t.starttime,this.src=null,this._clearNonNativeCues(),this.clearMetaCues(),this.clearTracks(),this.init(t),this.load(t),delete t.starttime}play(){return this.isLiveStreamUnloaded&&(this.isLiveStreamUnloaded=!1,this.restartStream()),this.video.play()||(0,G.Z)(this.video)}pause(){this.stopConnectionTimeout(),this.live&&"LIVE"===this.streamType&&!this.isLiveStreamUnloaded&&this.unloadLiveStream(),this.video.pause()}unloadLiveStream(){this.hlsjs&&(this.isLiveStreamUnloaded=!0,this.hlsjs.stopLoad(),this.stopStaleTimeout())}stop(){this.clearTracks(),this.hlsjs&&(this._eventsOff(),this.hlsjs.stopLoad()),this.pause(),this.setState(F.bc)}seek(e){const t=this.getDuration();if(!t||t===1/0||(0,n.i2)(t))return;this.stopStaleTimeout(),this.stopConnectionTimeout();let i=this.dvrEnd&&e<0?this.dvrEnd+e:e;const r=this.getSeekRange();if("DVR"===this.streamType&&null!==this.dvrEnd&&(this.dvrPosition=i-this.dvrEnd,e<0)){i+=Math.min(12,((0,N.z)()-this.dvrUpdatedTime)/1e3)}this.seeking=!0;const a=this.video.currentTime;this.trigger(F.NZ,{position:this.getCurrentTime(),offset:i,duration:t,currentTime:a,seekRange:r,metadata:{currentTime:a}}),this.video.currentTime=i;const s=this.video.currentTime,o={position:this.getCurrentTime(),duration:t,currentTime:s,seekRange:r,metadata:{currentTime:s}};this.trigger("time",o)}getCurrentQuality(){let e=0;return this.hlsjs&&!this.hlsjs.autoLevelEnabled&&(e=d(this.hlsjs.manualLevel,this.jwLevels)),e}getQualityLevels(){return(0,n.UI)(this.jwLevels,(e=>(0,x.Z)(e)))}getCurrentAudioTrack(){return(0,n.hj)(this.currentAudioTrackIndex)?this.currentAudioTrackIndex:-1}getAudioTracks(){return this.audioTracks||[]}getCurrentTime(){return this.live&&"DVR"===this.streamType?(this.dvrPosition||this.updateDvrPosition(this.getSeekRange()),this.dvrPosition):this.video.currentTime}getDuration(){if(this.live&&this.currentJwItem){const e=this.levelDuration,t=this.currentJwItem.minDvrWindow;return(0,M.s)(e,t)?(this.streamType="DVR",-e):(this.streamType="LIVE",1/0)}return this.streamType="VOD",this.video.duration}getCurrentHlsjsLevel(){let e=0;const{hlsjs:t}=this;return t&&(e=t.streamController.loadedmetadata&&t.currentLevel>0?t.currentLevel:t.firstLevel),e}getName(){return{name:"hlsjs"}}getPlaybackRate(){return this.video.playbackRate}getSeekRange(){const{levelDuration:e,video:t}=this,{seekable:i,duration:r}=t,a=i.length?Math.max(i.end(0),i.end(i.length-1)):r;return(0,n.i2)(r)?{start:0,end:0}:{start:Math.max(0,a-e),end:a}}getBandwidthEstimate(){const{hlsjs:e}=this;return e?e.bandwidthEstimate:null}getLiveLatency(){let e=null;if(this.live&&null!==this.liveEdgePosition){const t=(0,N.z)();e=this.liveEdgePosition+(t-this.liveEdgeUpdated)/1e3-this.video.currentTime;const i=this.lastProgramDateTime;if(i){const r=t/1e3-(i/1e3+(this.video.currentTime-this.programDateSyncTime))-e;r>0&&r<10&&(e+=r)}}return e}getTargetLatency(){return this.hlsjs&&this.hlsjs.targetLatency||null}setCurrentQuality(e){if(e<0)return;const t=((e,t)=>{let i=-1;return e>-1&&t[e]&&(i=t[e].hlsjsIndex),i})(e,this.jwLevels);this.hlsjs.nextLevel=t,this.trigger(F.aM,{levels:this.jwLevels,currentQuality:e}),this.bitrateSelection=this.jwLevels[e].bitrate}setCurrentAudioTrack(e){const t=this.getCurrentHlsjsLevel(),i=this.hlsjs.levels[t],r=d(t,this.jwLevels);if(!this.jwLevels||!this.jwLevels[r]||!i)return;if(!this.audioTracksArray||!(0,n.dp)(this.audioTracksArray)||!(0,n.hj)(e))return;let a=this.audioTracks=this.audioTracksArray;if(!a||!(0,n.dp)(a)||!a[e]||this.currentAudioTrackIndex===e)return;this.trigger(F.j0,{tracks:a,currentTrack:e}),a=this.audioTracks;let s=a[e];null!==this.currentAudioTrackIndex&&s.hlsjsIndex!==this.hlsjs.audioTrack&&(this.trigger(F._B,{tracks:a,currentTrack:e}),s=this.audioTracks[e]),this.currentAudioTrackIndex=e,s.hlsjsIndex!==this.hlsjs.audioTrack&&(this.hlsjs.audioTrack=s.hlsjsIndex)}updateAudioTrack(e){if(!this.hlsjs||!this.hlsjs.audioTracks.length)return;let t=this.currentAudioTrackIndex;(0,n.hj)(t)?this.audioTracks&&this.audioTracks[t].hlsjsIndex===this.hlsjs.audioTrack||(this.currentAudioTrackIndex=null):t=this.audioTracksArray?((e=[])=>Math.max((0,n.cq)(e,(0,n.sE)(e,(e=>e.defaulttrack))),0))(this.audioTracksArray):0,this.setCurrentAudioTrack(t)}updateDvrPosition(e){this.dvrPosition=this.video.currentTime-e.end,this.dvrEnd=e.end,this.dvrUpdatedTime=(0,N.z)()}setCurrentSubtitleTrack(e){this.hlsjs.subtitleTrack=e}setPlaybackRate(e){this.video.playbackRate=this.video.defaultPlaybackRate=e}get maxBufferLength(){return this.hlsjs?this.hlsjs.config.maxMaxBufferLength:NaN}set maxBufferLength(e){this.hlsjs&&(this.hlsjs.config.maxMaxBufferLength=e)}isLive(){return this.live}checkAdaptation(e){const{levels:t,autoLevelEnabled:i}=this.hlsjs,r=t[e];if(!r)return;let{width:n,height:a,bitrate:s}=r;if(n=n||this.video.videoWidth,a=a||this.video.videoHeight,a===this.videoHeight&&s===this.streamBitrate)return;const l=d(e,this.jwLevels);let u="api";-1!==this.streamBitrate&&this.streamBitrate||this.videoHeight?i&&(u="auto"):u="initial choice",this.videoHeight=a,this.streamBitrate=s;const h=i?"auto":"manual",c=i&&t.length>1?"auto":this.jwLevels[l].label,f=()=>{this.trigger(F.ug,{reason:u,mode:h,level:{bitrate:s,index:l,label:c,width:n,height:a}})};o.Browser.ie?this.once("time",f,this):f()}createVideoListeners(){const e={waiting:()=>{this.startConnectionTimeout(),this.seeking?this.setState(F.ik):this.state===F.r0&&(this.atEdgeOfLiveStream()&&this.setPlaybackRate(1),this.stallTime=this.video.currentTime,this.setState(F.nQ))}};return Object.keys(B.Z).forEach((t=>{const i=B.Z[t];"playing"===t?e[t]=function(){const e=this.getCurrentHlsjsLevel();this.checkAdaptation(e),i.call(this)}.bind(this):"ended"===t?e[t]=function(){this.videoHeight=0,this.streamBitrate=-1,i.call(this)}.bind(this):"error"!==t&&(e[t]=i.bind(this))})),e}createHlsjsListeners(){const e={};return e[t]=()=>{this.recoveringMediaError&&(this.hlsjs.startLoad(),this.recoveringMediaError=!1,this.resetRecovery(),this.stopStaleTimeout(),this.stopConnectionTimeout())},e[i]=()=>{this._clearNonNativeCues()},e[r]=(e,t)=>{const{levels:i}=t,r=this.hlsjs,{bitrateSelection:a,jwConfig:s}=this;let o=-1,l=-1;if(this.currentHlsjsLevel=null,this.jwLevels=u(i,s.qualityLabels),this.capLevels&&(this.playerWidth||this.playerHeight)&&this.playerStretching){const e=h(i,this.playerWidth,this.playerHeight,t.firstLevel+1);r.levelController.firstLevel!==e&&(r.firstLevel=e),this.resize(this.playerWidth,this.playerHeight,this.playerStretching)}(0,n.qh)(a)&&(o=((e,t)=>{if(!t)return-1;let i=Number.MAX_VALUE,r=-1;for(let n=0;n{const{endSN:i,live:r,targetduration:n}=t.details;this.checkStaleManifest(i,r,n)},e[c]=(e,t)=>{const{live:i,totalduration:r}=t.details;this.live=i,this.levelDuration=r;const n=this.getSeekRange(),a=null!==this.dvrEnd&&Math.abs(this.dvrEnd-n.end)>1;"DVR"===this.streamType&&a&&this.updateDvrPosition(n),i&&this.state===F.bc&&this.unloadLiveStream()},e[f]=(e,t)=>{const{fragments:i,totalduration:r}=t.details;if(this.levelDuration=r,i.length){const e=i[i.length-1];e.sn!==this.liveEdgeSn&&(this.liveEdgeUpdated=(0,N.z)(),this.liveEdgeSn=e.sn,this.liveEdgePosition=e.start+e.duration)}},e[m]=(e,t)=>{const{level:i}=t;i!==this.currentHlsjsLevel?this.setCurrentLevel(i):this.checkAdaptation(i)},e[v]=(e,t)=>{this.lastProgramDateTime=t.frag.programDateTime,this.programDateSyncTime=t.frag.start,this.lastProgramDateTime&&!this.startDateTime&&(this.startDateTime=this.lastProgramDateTime,this.trigger(F.AQ,{ready:!0,startDateTime:this.startDateTime}))},e[g]=(e,t)=>{this.lastProgramDateTime=t.frag.programDateTime,this.programDateSyncTime=t.frag.start},e[y]=(e,t)=>{t.samples&&([].some.call(this.video.textTracks,(e=>!e.inuse))&&this.setTextTracks(this.video.textTracks),null!=t&&t.samples&&t.samples.forEach((e=>{this.trigger(F.rx,{metadataType:"dai-hls",metadata:{messageData:e.data,start:e.pts,type:"ID3"}})})))},e[E]=()=>{-1!==this.connectionTimeout&&this.stopConnectionTimeout(),this.atEdgeOfLiveStream()||this.stopStaleTimeout(),this.recoveringNetworkError&&(this.resetRecovery(),this.recoveringNetworkError=!1)},e[S]=(e,t)=>{if(t.audio&&this.videoFound)return;const i=t.audiovideo||t.video?"video":"audio";this.videoFound=this.videoFound||"video"===i,this.trigger(F.oZ,{mediaType:i})},e[I]=(e,t)=>{const i=t.frag;(i.tagList||[]).forEach((([e,t])=>this.processPlaylistMetadata(e,t,i)))},e[D]=(e,t)=>{const{frag:i,initPTS:r}=t;this.processPlaylistMetadata("DISCONTINUITY",r,i)},this.renderNatively||(e[_]=(e,t)=>{this.addTextTracks(t.tracks)},e[C]=(e,t)=>{var i;if(null!=t&&null!=(i=t.cues)&&i.length){let e;const i=!(t.cues[0]instanceof V.Z);t.cues.forEach((r=>{if(i){const e=r;(r=new V.Z(e.startTime,e.endTime,e.text)).position=e.position}e||(e=t.cues.filter((e=>e.startTime===r.startTime)).length),r.align="center",r.line=90-5*e,r.position=50,this.addVTTCue({type:t.type,cue:r,track:t.track}),e--}))}}),e[P]=(e,t)=>{const{audioTracks:i}=t,r=this.hlsjs.levels,a=this.getCurrentHlsjsLevel();null!=i&&i.length&&(this.audioTracksArray=(e=>(0,n.u4)(e,((e,t,i)=>(e.push({autoselect:t.autoselect,defaulttrack:t.default,groupid:t.groupId,language:t.lang,name:t.name,hlsjsIndex:i}),e)),[]))(i),this.jwLevels.forEach((e=>{const t=e.hlsjsIndex>0?r[e.hlsjsIndex]:null;t&&(e.audioGroupId=l(t))})),this.updateAudioTrack(r[a]))},e[Y]=(e,t)=>{const i=this.hlsjs,r=X(t),{type:n}=t,{key:a}=r;let s;if(p(t),"DVR"===this.streamType&&n===q){const e=this.getSeekRange();this.updateDvrPosition(e)}if(232403===r.code&&this.retryCount=this.lastRecoveryTime+this.recoveryInterval)&&(p("Attempting to recover, retry count:",l),n===q?/^manifest/.test(t.details)||s?(this.recoverManifestError(),this.retryCount=l):i.startLoad():n===W&&("bufferAppendError"===t.details?(p("Encountered a bufferAppendError in hls not attempting to recover media and destroying instance"),i.destroy()):(this.recoveringMediaError=!0,i.recoverMediaError())),this.recoveringNetworkError=!0,this.retryCount+=1,this.lastRecoveryTime=e)}this.trigger(F.cM,new R.rG(null,r.code+1e5,t))},e}resize(e,t,i){if(this.playerWidth=e,this.playerHeight=t,this.playerStretching=i,this.capLevels){const e=this.hlsjs;if(null!=e&&e.levels){const t=e.autoLevelCapping,i=h(e.levels,this.playerWidth,this.playerHeight);i!==t&&(e.autoLevelCapping=i,i>t&&-1!==t&&this.state!==F.bc&&this.state!==F.xQ&&e.streamController.nextLevelSwitch())}}}recoverManifestError(){const{currentTime:e,paused:t}=this.video;e||!t?(this.restartStream(e),t||this.play().catch((()=>{}))):(this.hlsjs.stopLoad(),this.hlsjs.loadSource(this.src))}_eventsOn(){const{bandwidthMonitor:e,eventHandler:t,video:i}=this;t&&t.on(),e.start(),(0,H.Nm)(this,i)}_eventsOff(){const{bandwidthMonitor:e,eventHandler:t,hlsjs:i,video:r}=this;i&&t&&(this.disableTextTrack(),this.lastPosition=this.video.currentTime,i.detachMedia(),t.off()),this.off(null,null,this),e.stop(),this.resetLifecycleVariables(),(0,H.IP)(r)}handleError(e,t,i){this.resetLifecycleVariables(),this.trigger(F.Ew,new R.rG(i,e,t))}destroy(){this.hlsjs&&(this._eventsOff(),this.hlsjs.destroy(),this.hlsjs=null,this.hlsjsOptions=null)}restoreVideoProperties(){this.savedVideoProperties&&(this.volume(this.jwConfig.volume),this.mute(this.jwConfig.mute),this.savedVideoProperties=!1)}checkStaleManifest(e,t,i){const r=null!==this.jwConfig.liveTimeout?1e3*this.jwConfig.liveTimeout:this.staleManifestDurationMultiplier*i;t&&this.lastEndSn===e&&0!==r?-1===this.staleManifestTimeout&&(this.staleManifestTimeout=window.setTimeout((()=>{this.checkStreamEnded()}),r)):this.stopStaleTimeout(),this.lastEndSn=e,this.live=t}checkStreamEnded(){this.hlsjs&&(this.video.ended||this.atEdgeOfLiveStream())&&(this.hlsjs.stopLoad(),this.handleError(k.ERROR_LIVE_STREAM_DOWN_OR_ENDED,null,R.Sp))}setCurrentLevel(e){this.currentHlsjsLevel=e,this.checkAdaptation(e),this.updateAudioTrack(this.hlsjs.levels[e])}_clearNonNativeCues(){!this.renderNatively&&this._textTracks&&this._textTracks.forEach((e=>{this.clearCueData(e._id)}))}static setEdition(e){A.supports=(0,U.Z)(e)}}}(i.n(Y)());class q extends W{getName(){return{name:"hlsjs"}}static getName(){return{name:"hlsjs"}}}},3343:(e,t,i)=>{"use strict";i.d(t,{q:()=>s});var r=i(6042),n=i(1643);const a=(e,t)=>{const i=e[t];return(0,r.xV)(i)&&i>=0?i:null},s=function(e,t,i){const s=((e,t,i)=>{let n,s;if(n=(0,r.xV)(i.startPTS)?a(i,"startPTS"):a(i,"start"),null===n)return null;switch(e){case"PROGRAM-DATE-TIME":return s="program-date-time",{metadataType:s,programDateTime:t,start:n,end:n+a(i,"duration")};case"EXT-X-DATERANGE":{const a={},o=t.split(",").map((e=>{const t=e.split("="),i=t[0],r=(t[1]||"").replace(/^"|"$/g,"");return a[i]=r,{name:i,value:r}})),l=a["START-DATE"];if(!l)return null;const u=a["END-DATE"];let d=n;if((0,r.xV)(i.programDateTime)&&(d+=(new Date(l).getTime()-new Date(i.programDateTime).getTime())/1e3),isNaN(d))return null;let h=parseFloat(a["PLANNED-DURATION"]||a.DURATION)||0;return!h&&u&&(h=(new Date(u).getTime()-new Date(l).getTime())/1e3),s="date-range",{metadataType:"date-range",tag:e,content:t,attributes:o,start:d,end:d+h,startDate:l,endDate:u,duration:h}}case"EXT-X-CUE-IN":case"EXT-X-CUE-OUT":return s="scte-35",{metadataType:s,tag:e,content:t,start:n,end:n+(parseFloat(t)||0)};case"DISCONTINUITY":{const r=n+a(i,"duration");let o;return"cc"in i&&(o=i.cc),s="discontinuity",{metadataType:s,tag:e,discontinuitySequence:o,PTS:t,start:n,end:r}}default:return null}})(e,t,i);if(s){if(!(0,r.xV)(s.start))return;const a=this.createCue(s.start,s.end,JSON.stringify(s)),o=`${i.sn}_${e}_${t}`;if(this.addVTTCue({type:"metadata",cue:a},o)){const e=s.metadataType;delete s.metadataType,this.trigger(n.O1,{metadataType:e,metadata:s})}}}},4560:function(e,t){!function i(r){var n,a;n=this,a=function(){"use strict";function e(e,t){for(var i=0;i=this.minWeight_},i.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},i.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},i.destroy=function(){},t(e,[{key:"defaultEstimate",get:function(){return this.defaultEstimate_}}])}(),F=function(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var i="["+e+"]:";this.trace=N,this.debug=t.debug.bind(null,i),this.log=t.log.bind(null,i),this.warn=t.warn.bind(null,i),this.info=t.info.bind(null,i),this.error=t.error.bind(null,i)},N=function(){},B={trace:N,debug:N,log:N,warn:N,info:N,error:N};function U(){return a({},B)}function G(e,t,i){return t[e]?t[e].bind(t):function(e,t){var i=self.console[e];return i?i.bind(self.console,(t?"["+t+"] ":"")+"["+e+"] >"):N}(e,i)}var K=U();function V(e,t,i){var r=U();if("object"==typeof console&&!0===e||"object"==typeof e){var n=["debug","log","info","warn","error"];n.forEach((function(t){r[t]=G(t,e,i)}));try{r.log('Debug logs enabled for "'+t+'" in hls.js version 1.6.5')}catch(e){return U()}n.forEach((function(t){K[t]=G(t,e)}))}else a(K,r);return r}var H=K;function j(e){if(void 0===e&&(e=!0),"undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function Y(e,t){var i=Object.keys(e),r=Object.keys(t),n=i.length,a=r.length;return!n||!a||n===a&&!i.some((function(e){return-1===r.indexOf(e)}))}function W(e,t){if(void 0===t&&(t=!1),"undefined"!=typeof TextDecoder){var i=new TextDecoder("utf-8").decode(e);if(t){var r=i.indexOf("\0");return-1!==r?i.substring(0,r):i}return i.replace(/\0/g,"")}for(var n,a,s,o=e.length,l="",u=0;u>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(n);break;case 12:case 13:a=e[u++],l+=String.fromCharCode((31&n)<<6|63&a);break;case 14:a=e[u++],s=e[u++],l+=String.fromCharCode((15&n)<<12|(63&a)<<6|63&s)}}return l}var q=function(e){for(var t="",i=0;i1||1===i&&this.levelkeys[t[0]].encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){S(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return J(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}}])}($),te=function(e){function i(t,i,r,n,a){var s;(s=e.call(this,r)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=i,s.index=n;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return o(i,e),t(i,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}])}($);function ie(e,t){var i=Object.getPrototypeOf(e);if(i)return Object.getOwnPropertyDescriptor(i,t)||ie(i,t)}var re=Math.pow(2,32)-1,ne=[].push,ae={video:1,audio:2,id3:3,text:4};function se(e){return String.fromCharCode.apply(null,e)}function oe(e,t){var i=e[t]<<8|e[t+1];return i<0?65536+i:i}function le(e,t){var i=de(e,t);return i<0?4294967296+i:i}function ue(e,t){var i=le(e,t);return(i*=Math.pow(2,32))+le(e,t+4)}function de(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function he(e,t,i){e[t]=i>>24,e[t+1]=i>>16&255,e[t+2]=i>>8&255,e[t+3]=255&i}function ce(e,t){var i=[];if(!t.length)return i;for(var r=e.byteLength,n=0;n1?n+a:r;if(se(e.subarray(n+4,n+8))===t[0])if(1===t.length)i.push(e.subarray(n+8,s));else{var o=ce(e.subarray(n+8,s),t.slice(1));o.length&&ne.apply(i,o)}n=s}return i}function fe(e){var t=[],i=e[0],r=8,n=le(e,r);r+=4;var a=0,s=0;0===i?(a=le(e,r),s=le(e,r+4),r+=8):(a=ue(e,r),s=ue(e,r+8),r+=16),r+=2;var o=e.length+s,l=oe(e,r);r+=2;for(var u=0;u>>31)return H.warn("SIDX has hierarchical references (not supported)"),null;var f=le(e,d);d+=4,t.push({referenceSize:c,subsegmentDuration:f,info:{duration:f/n,start:o,end:o+c-1}}),o+=c,r=d+=4}return{earliestPresentationTime:a,timescale:n,version:i,referencesCount:l,references:t}}function ge(e){for(var t=[],i=ce(e,["moov","trak"]),r=0;r3&&(a+="."+ye(u[1])+ye(u[2])+ye(u[3]),t=me("avc1"===l?"dva1":"dvav",r));break;case"mp4a":var d=ce(i,[n])[0],h=ce(d.subarray(28),["esds"])[0];if(h&&h.length>7){var c=4;if(3!==h[c++])break;c=pe(h,c),c+=2;var f=h[c++];if(128&f&&(c+=2),64&f&&(c+=h[c++]),4!==h[c++])break;c=pe(h,c);var g=h[c++];if(64!==g)break;if(a+="."+ye(g),c+=12,5!==h[c++])break;c=pe(h,c);var v=h[c++],m=(248&v)>>3;31===m&&(m+=1+((7&v)<<3)+((224&h[c])>>5)),a+="."+m}break;case"hvc1":case"hev1":var p=ce(r,["hvcC"])[0];if(p&&p.length>12){var y=p[1],T=["","A","B","C"][y>>6],E=31&y,S=le(p,2),L=(32&y)>>5?"H":"L",A=p[12],R=p.subarray(6,12);a+="."+T+E,a+="."+function(e){for(var t=0,i=0;i<32;i++)t|=(e>>i&1)<<31-i;return t>>>0}(S).toString(16).toUpperCase(),a+="."+L+A;for(var k="",b=R.length;b--;){var I=R[b];(I||k)&&(k="."+I.toString(16).toUpperCase()+k)}a+=k}t=me("hev1"==l?"dvhe":"dvh1",r);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":a=me(a,r)||a;break;case"vp09":var D=ce(r,["vpcC"])[0];if(D&&D.length>6){var _=D[4],C=D[5],P=D[6]>>4&15;a+="."+Te(_)+"."+Te(C)+"."+Te(P)}break;case"av01":var w=ce(r,["av1C"])[0];if(w&&w.length>2){var x=w[1]>>>5,O=31&w[1],M=w[2]>>>7?"H":"M",F=(64&w[2])>>6,N=(32&w[2])>>5,B=2===x&&F?N?12:10:F?10:8,U=(16&w[2])>>4,G=(8&w[2])>>3,K=(4&w[2])>>2,V=3&w[2];a+="."+x+"."+Te(O)+M+"."+Te(B)+"."+U+"."+G+K+V+"."+Te(1)+"."+Te(1)+"."+Te(1)+".0",t=me("dav1",r)}}return{codec:a,encrypted:s,supplemental:t}}function me(e,t){var i=ce(t,["dvvC"]),r=i.length?i[0]:ce(t,["dvcC"])[0];if(r){var n=r[2]>>1&127,a=r[2]<<5&32|r[3]>>3&31;return e+"."+Te(n)+"."+Te(a)}}function pe(e,t){for(var i=t+5;128&e[t++]&&t>1&63;return 39===i||40===i}return 6==(31&t)}function ke(e,t,i,r){var n=be(e),a=0;a+=t;for(var s=0,o=0,l=0;a=n.length)break;s+=l=n[a++]}while(255===l);o=0;do{if(a>=n.length)break;o+=l=n[a++]}while(255===l);var u=n.length-a,d=a;if(ou){H.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(4===s){if(181===n[d++]){var h=oe(n,d);if(d+=2,49===h){var c=le(n,d);if(d+=4,1195456820===c){var f=n[d++];if(3===f){var g=n[d++],v=64&g,m=v?2+3*(31&g):0,p=new Uint8Array(m);if(v){p[0]=g;for(var y=1;y16){for(var T=[],E=0;E<16;E++){var S=n[d++].toString(16);T.push(1==S.length?"0"+S:S),3!==E&&5!==E&&7!==E&&9!==E||T.push("-")}for(var L=o-16,A=new Uint8Array(L),R=0;R>>24;if(0!==n&&1!==n)return{offset:i,size:t};var a=e.buffer,s=q(new Uint8Array(a,i+12,16)),o=e.getUint32(28),l=null,u=null;if(0===n){if(t-324||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e)))return e;if(t){var i=t.split(",");if(i.length>1){if(e)for(var r=i.length;r--;)if(i[r].substring(0,4)===e.substring(0,4))return i[r];return i[0]}}return t||e}function Ge(e){if(e.startsWith("av01.")){for(var t=e.split("."),i=["0","111","01","01","01","0"],r=t.length;r>4&&r<10;r++)t[r]=i[r-4];return t.join(".")}return e}function Ke(e){var t=j(e)||{isTypeSupported:function(){return!1}};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Ve(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var He={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function je(e,t){return{supported:!1,configurations:t,decodingInfoResults:[{supported:!1,smooth:!1,powerEfficient:!1}],error:e}}var Ye={};function We(e,t,i){var r=e.videoCodec,n=e.audioCodec;if(!r&&!n||!i)return Promise.resolve(He);var a=[];if(r){var s={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},o=e.videoRange;"SDR"!==o&&(s.transferFunction=o.toLowerCase());var l=r.split(","),u=navigator.userAgent;if(l.some((function(e){return Ae(e)}))&&De())return Promise.resolve(je(new Error("Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent sting: ("+u+")"),a));a.push.apply(a,l.map((function(e){return{type:"media-source",video:d(d({},s),{},{contentType:xe(Ge(e),"video")})}})))}return n&&e.audioGroups&&e.audioGroups.forEach((function(e){var i;e&&(null==(i=t.groups[e])||i.tracks.forEach((function(t){if(t.groupId===e){var i=t.channels||"",r=parseFloat(i);S(r)&&r>2&&a.push.apply(a,n.split(",").map((function(e){return{type:"media-source",audio:{contentType:xe(e,"audio"),channels:""+r}}})))}})))})),Promise.all(a.map((function(e){var t=function(e){var t=e.audio,i=e.video,r=i||t;if(r){var n=Ve(r.contentType);if(i)return"r"+i.height+"x"+i.width+"f"+Math.ceil(i.framerate)+(i.transferFunction||"sd")+"_"+n+"_"+Math.ceil(i.bitrate/1e5);if(t)return"c"+t.channels+(t.spatialRendering?"s":"n")+"_"+n}return""}(e);return Ye[t]||(Ye[t]=i.decodingInfo(e))}))).then((function(e){return{supported:!e.some((function(e){return!e.supported})),configurations:a,decodingInfoResults:e}})).catch((function(e){return{supported:!1,configurations:a,decodingInfoResults:[],error:e}}))}var qe=["NONE","TYPE-0","TYPE-1",null],Xe=["SDR","PQ","HLG"];function ze(e){var t=e.canSkipUntil,i=e.canSkipDateRanges,r=e.age;return t&&r-1;r--)if(i(e[r]))return r;for(var n=t+1;n-1&&v!==g,p=!!e||m;if(p||!l.paused&&l.playbackRate&&l.readyState){var y=s.mainForwardBufferInfo;if(p||null!==y){var T=i.bwEstimator.getEstimateTTFB(),E=Math.abs(l.playbackRate);if(!(c<=Math.max(T,h/(2*E)*1e3))){var L=y?y.len/E:0,A=d.loading.first?d.loading.first-d.loading.start:-1,R=d.loaded&&A>-1,k=i.getBwEstimate(),I=s.levels,D=I[g],_=Math.max(d.loaded,Math.round(h*(n.bitrate||D.averageBitrate)/8)),C=R?c-A:c;C<1&&R&&(C=Math.min(c,8*d.loaded/k));var P=R?1e3*d.loaded/C:0,w=T/1e3,x=P?(_-d.loaded)/P:8*_/k+w;if(!(x<=L)){var O,M=P?8*P:k,F=!0===(null==(t=(null==e?void 0:e.details)||i.hls.latestLevelDetails)?void 0:t.live),N=i.hls.config.abrBandWidthUpFactor,B=Number.POSITIVE_INFINITY;for(O=g-1;O>f;O--){var U=I[O].maxBitrate,G=!I[O].details||F;if((B=i.getTimeToLoadFrag(w,M,h*U,G))=x||B>10*h)){R?i.bwEstimator.sample(c-Math.min(T,A),d.loaded):i.bwEstimator.sampleTTFB(c);var K=I[O].maxBitrate;i.getBwEstimate()*N>K&&i.resetEstimator(K);var V=i.findBestLevel(K,f,O,0,L,1,1);V>-1&&(O=V),i.warn("Fragment "+n.sn+(a?" part "+a.index:"")+" of level "+g+" is loading too slowly;\n Fragment duration: "+n.duration.toFixed(3)+"\n Time to underbuffer: "+L.toFixed(3)+" s\n Estimated load time for current fragment: "+x.toFixed(3)+" s\n Estimated load time for down switch fragment: "+B.toFixed(3)+" s\n TTFB estimate: "+(0|A)+" ms\n Current BW estimate: "+(S(k)?0|k:"Unknown")+" bps\n New BW estimate: "+(0|i.getBwEstimate())+" bps\n Switching to level "+O+" @ "+(0|K)+" bps"),s.nextLoadLevel=s.nextAutoLevel=O,i.clearTimer();var H=function(){if(i.clearTimer(),i.fragCurrent===n&&i.hls.loadLevel===O&&O>0){var e=i.getStarvationDelay();if(i.warn("Aborting inflight request "+(O>0?"and switching down":"")+"\n Fragment duration: "+n.duration.toFixed(3)+" s\n Time to underbuffer: "+e.toFixed(3)+" s"),n.abortRequests(),i.fragCurrent=i.partCurrent=null,O>f){var t=i.findBestLevel(i.hls.levels[f].bitrate,f,O,0,e,1,1);-1===t&&(t=f),i.hls.nextLoadLevel=i.hls.nextAutoLevel=t,i.resetEstimator(i.hls.levels[t].bitrate)}}};m||x>2*B?H():i.timer=self.setInterval(H,1e3*B),s.trigger(b.FRAG_LOAD_EMERGENCY_ABORTED,{frag:n,part:a,stats:d})}}}}}}}},i.hls=t,i.bwEstimator=i.initEstimator(),i.registerListeners(),i}o(i,e);var r=i.prototype;return r.resetEstimator=function(e){e&&(this.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},r.initEstimator=function(){var e=this.hls.config;return new M(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},r.registerListeners=function(){var e=this.hls;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.FRAG_LOADING,this.onFragLoading,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(b.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.FRAG_LOADING,this.onFragLoading,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(b.ERROR,this.onError,this))},r.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},r.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},r.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},r.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},r.onFragLoading=function(e,t){var i,r=t.frag;this.ignoreFragment(r)||(r.bitrateTest||(this.fragCurrent=r,this.partCurrent=null!=(i=t.part)?i:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},r.onLevelSwitching=function(e,t){this.clearTimer()},r.onError=function(e,t){if(!t.fatal)switch(t.details){case k.BUFFER_ADD_CODEC_ERROR:case k.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case k.FRAG_LOAD_TIMEOUT:var i=t.frag,r=this.fragCurrent,n=this.partCurrent;if(i&&r&&i.sn===r.sn&&i.level===r.level){var a=performance.now(),s=n?n.stats:i.stats,o=a-s.loading.start,l=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&l>-1){var u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(u,l),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}},r.getTimeToLoadFrag=function(e,t,i,r){return e+i/t+(r?e+this.lastLevelLoadSec:0)},r.onLevelLoaded=function(e,t){var i=this.hls.config,r=t.stats.loading,n=r.end-r.first;S(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)},r.onFragLoaded=function(e,t){var i=t.frag,r=t.part,n=r?r.stats:i.stats;if(i.type===P&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(i)){if(this.clearTimer(),i.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=r?r.duration:i.duration,s=this.hls.levels[i.level],o=(s.loaded?s.loaded.bytes:0)+n.loaded,l=(s.loaded?s.loaded.duration:0)+a;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(i.bitrateTest){var u={stats:n,frag:i,part:r,id:i.type};this.onFragBuffered(b.FRAG_BUFFERED,u),i.bitrateTest=!1}else this.lastLoadedFragLevel=i.level}},r.onFragBuffered=function(e,t){var i=t.frag,r=t.part,n=null!=r&&r.stats.loaded?r.stats:i.stats;if(!n.aborted&&!this.ignoreFragment(i)){var a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},r.ignoreFragment=function(e){return e.type!==P||"initSegment"===e.sn},r.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},r.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},r.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var r=i.maxAutoLevel,n=i.config,a=i.minAutoLevel,s=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay(),u=n.abrBandWidthFactor,d=n.abrBandWidthUpFactor;if(l){var h=this.findBestLevel(o,a,r,l,0,u,d);if(h>=0)return this.rebufferNotice=-1,h}var c=s?Math.min(s,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){var f=this.bitrateTestDelay;f&&(c=(s?Math.min(s,n.maxLoadingDelay):n.maxLoadingDelay)-f,this.info("bitrate test took "+Math.round(1e3*f)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*c)+" ms"),u=d=1)}var g=this.findBestLevel(o,a,r,l,c,u,d);if(this.rebufferNotice!==g&&(this.rebufferNotice=g,this.info((l?"rebuffering expected":"buffer is empty")+", optimal quality level "+g)),g>-1)return g;var v=i.levels[a],m=i.loadLevelObj;return m&&(null==v?void 0:v.bitrate)0),c=Math.min(c,t.minHeight),f=Math.min(f,t.minFramerate),g=Math.min(g,t.minBitrate),E.filter((function(e){return t.videoRanges[e]>0})).length>0&&(h=!0)},A=a.length;A--;)L();c=S(c)?c:0,f=S(f)?f:0;var R=Math.max(1080,c),k=Math.max(30,f);g=S(g)?g:i,i=Math.max(g,i),h||(t=void 0);var b=a.length>1;return{codecSet:a.reduce((function(t,r){var n=e[r];if(r===t)return t;if(p=h?E.filter((function(e){return n.videoRanges[e]>0})):[],b){if(n.minBitrate>i)return et(r,"min bitrate of "+n.minBitrate+" > current estimate of "+i),t;if(!n.hasDefaultAudio)return et(r,"no renditions with default or auto-select sound found"),t;if(o&&r.indexOf(o.substring(0,4))%5!=0)return et(r,'audio codec preference "'+o+'" not found'),t;if(s&&!u){if(!n.channels[s])return et(r,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(n.channels)+")"),t}else if((!o||u)&&d&&0===n.channels[2])return et(r,"no renditions with stereo sound found"),t;if(n.minHeight>R)return et(r,"min resolution of "+n.minHeight+" > maximum of "+R),t;if(n.minFramerate>k)return et(r,"min framerate of "+n.minFramerate+" > maximum of "+k),t;if(!p.some((function(e){return n.videoRanges[e]>0})))return et(r,"no variants with VIDEO-RANGE of "+Je(p)+" found"),t;if(l&&r.indexOf(l.substring(0,4))%5!=0)return et(r,'video codec preference "'+l+'" not found'),t;if(n.maxScore=Me(t)||n.fragmentError>e[t].fragmentError)?t:(v=n.minIndex,m=n.maxScore,r)}),void 0),videoRanges:p,preferHDR:T,minFramerate:f,minBitrate:g,minIndex:v}}(C,R,e,b,I),w=P.codecSet,x=P.videoRanges,O=P.minFramerate,M=P.minBitrate,F=P.minIndex,N=P.preferHDR;_=F,T=w,R=N?x[x.length-1]:x[0],k=O,e=Math.max(e,M),this.log("picked start tier "+Je(P))}else T=null==E?void 0:E.codecSet,R=null==E?void 0:E.videoRange;for(var B,U=f?f.duration:c?c.duration:0,G=this.bwEstimator.getEstimateTTFB()/1e3,K=[],V=function(){var t,o=v[H],c=H>h;if(!o)return 0;if(y.useMediaCapabilities&&!o.supportedResult&&!o.supportedPromise){var g=navigator.mediaCapabilities;"function"==typeof(null==g?void 0:g.decodingInfo)&&(function(e,t,i,r,n,a){var s=e.audioCodec?e.audioGroups:null,o=null==a?void 0:a.audioCodec,l=null==a?void 0:a.channels,u=l?parseInt(l):o?1/0:2,d=null;if(null!=s&&s.length)try{d=1===s.length&&s[0]?t.groups[s[0]].channels:s.reduce((function(e,i){if(i){var r=t.groups[i];if(!r)throw new Error("Audio track group "+i+" not found");Object.keys(r.channels).forEach((function(t){e[t]=(e[t]||0)+r.channels[t]}))}return e}),{2:0})}catch(e){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(r,30)||"SDR"!==e.videoRange&&e.videoRange!==i||e.bitrate>Math.max(n,8e6))||!!d&&S(u)&&Object.keys(d).some((function(e){return parseInt(e)>u}))}(o,D,R,k,e,b)||Ae(o.videoCodec))?(o.supportedPromise=We(o,D,g),o.supportedPromise.then((function(e){if(l.hls){o.supportedResult=e;var t=l.hls.levels,i=t.indexOf(o);e.error?l.warn('MediaCapabilities decodingInfo error: "'+e.error+'" for level '+i+" "+Je(e)):e.supported||(l.warn("Unsupported MediaCapabilities decodingInfo result for level "+i+" "+Je(e)),i>-1&&t.length>1&&(l.log("Removing unsupported level "+i),l.hls.removeLevel(i),-1===l.hls.loadLevel&&(l.hls.nextLoadLevel=0)))}}))):o.supportedResult=He}if((T&&o.codecSet!==T||R&&o.videoRange!==R||c&&k>o.frameRate||!c&&k>0&&k=2*U&&0===n?o.averageBitrate:o.maxBitrate,P=l.getTimeToLoadFrag(G,m,C*I,void 0===E);if(m>=C&&(H===d||0===o.loadError&&0===o.fragmentError)&&(P<=G||!S(P)||L&&!l.bitrateTestDelay||P"+H+" adjustedbw("+Math.round(m)+")-bitrate="+Math.round(m-C)+" ttfb:"+G.toFixed(1)+" avgDuration:"+I.toFixed(1)+" maxFetchDuration:"+u.toFixed(1)+" fetchDuration:"+P.toFixed(1)+" firstSelection:"+A+" codecSet:"+o.codecSet+" videoRange:"+o.videoRange+" hls.loadLevel:"+p)),A&&(l.firstSelection=H),{v:H}}},H=i;H>=t;H--)if(0!==(B=V())&&B)return B.v;return-1},r.deriveNextAutoLevel=function(e){var t=this.hls,i=t.maxAutoLevel,r=t.minAutoLevel;return Math.min(Math.max(e,r),i)},t(i,[{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,i=e.minAutoLevel,r=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,a=this.findBestLevel(r,i,t,0,n,1,1);if(a>-1)return a;var s=this.hls.firstLevel,o=Math.min(Math.max(s,i),t);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+s+" clamped to "+o),o}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var r=t&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var n=this.hls.levels;if(n.length>Math.max(e,r)&&n[e].loadError<=n[r].loadError)return e}return this._nextAutoLevel=r,this.nextAutoLevelKey=this.getAutoLevelKey(),r},set:function(e){var t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}}])}(F),ut=function(e,t){for(var i=0,r=e.length-1,n=null,a=null;i<=r;){var s=t(a=e[n=(i+r)/2|0]);if(s>0)i=n+1;else{if(!(s<0))return a;r=n-1}}return null};function dt(e,t,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=.005);var a=null;if(e){a=t[1+e.sn-t[0].sn]||null;var s=e.endDTS-i;s>0&&s<15e-7&&(i+=15e-7),a&&e.level!==a.level&&a.end<=e.end&&(a=t[2+e.sn-t[0].sn]||null)}else 0===i&&0===t[0].start&&(a=t[0]);if(a&&((!e||e.level===a.level)&&0===ht(i,r,a)||function(e,t,i){if(t&&0===t.start&&t.level0){var r=t.tagList.reduce((function(e,t){return"INF"===t[0]&&(e+=parseFloat(t[1])),e}),i);return e.start<=r}return!1}(a,e,Math.min(n,r))))return a;var o=ut(t,ht.bind(null,i,r));return!o||o===e&&a?a:o}function ht(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=0),i.start<=e&&i.start+i.duration>e)return 0;var r=Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-r<=e?1:i.start-r>e&&i.start?-1:0}function ct(e,t,i){var r=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-r>e}function ft(e,t,i){if(e&&e.startCC<=t&&e.endCC>=t){var r,n=e.fragments,a=e.fragmentHint;return a&&(n=n.concat(a)),ut(n,(function(e){return e.cct?-1:(r=e,e.end<=i?1:e.start>i?-1:0)})),r||null}return null}function gt(e){switch(e.details){case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_TIMEOUT:case k.LEVEL_LOAD_TIMEOUT:case k.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function vt(e,t){var i=gt(t);return e.default[(i?"timeout":"error")+"Retry"]}function mt(e,t){var i="linear"===e.backoff?1:Math.pow(2,t);return Math.min(i*e.retryDelayMs,e.maxRetryDelayMs)}function pt(e){return d(d({},e),{errorRetry:null,timeoutRetry:null})}function yt(e,t,i,r){if(!e)return!1;var n=null==r?void 0:r.code,a=t499)}(n)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,r,a):a}var Tt=function(e){function t(t){var i;return(i=e.call(this,"error-controller",t.logger)||this).hls=void 0,i.playlistError=0,i.penalizedRenditions={},i.hls=t,i.registerListeners(),i}o(t,e);var i=t.prototype;return i.registerListeners=function(){var e=this.hls;e.on(b.ERROR,this.onError,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this)},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(b.ERROR,this.onError,this),e.off(b.ERROR,this.onErrorOut,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this))},i.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},i.startLoad=function(e){},i.stopLoad=function(){this.playlistError=0},i.getVariantLevelIndex=function(e){return(null==e?void 0:e.type)===P?e.level:this.hls.loadLevel},i.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},i.onLevelUpdated=function(){this.playlistError=0},i.onError=function(e,t){var i;if(!t.fatal){var r=this.hls,n=t.context;switch(t.details){case k.FRAG_LOAD_ERROR:case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_ERROR:case k.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case k.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap)return void(t.errorAction=Et());case k.FRAG_GAP:case k.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=2);case k.LEVEL_EMPTY_ERROR:case k.LEVEL_PARSING_ERROR:var a,s,o=t.parent===P?t.level:r.loadLevel;return void(t.details===k.LEVEL_EMPTY_ERROR&&null!=(a=t.context)&&null!=(s=a.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case k.LEVEL_LOAD_ERROR:case k.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==n?void 0:n.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.level)));case k.AUDIO_TRACK_LOAD_ERROR:case k.AUDIO_TRACK_LOAD_TIMEOUT:case k.SUBTITLE_LOAD_ERROR:case k.SUBTITLE_TRACK_LOAD_TIMEOUT:if(n){var l=r.loadLevelObj;if(l&&(n.type===_&&l.hasAudioGroup(n.groupId)||n.type===C&&l.hasSubtitleGroup(n.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.loadLevel),t.errorAction.action=2,void(t.errorAction.flags=1)}return;case k.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var u=r.loadLevelObj,d=null==u?void 0:u.attrs["HDCP-LEVEL"];return void(d?t.errorAction={action:2,flags:2,hdcpLevel:d}:this.keySystemError(t));case k.BUFFER_ADD_CODEC_ERROR:case k.REMUX_ALLOC_ERROR:case k.BUFFER_APPEND_ERROR:var h;return void(t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,null!=(h=t.level)?h:r.loadLevel)));case k.INTERNAL_EXCEPTION:case k.BUFFER_APPENDING_ERROR:case k.BUFFER_FULL_ERROR:case k.LEVEL_SWITCH_ERROR:case k.BUFFER_STALLED_ERROR:case k.BUFFER_SEEK_OVER_HOLE:case k.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=Et())}t.type===R.KEY_SYSTEM_ERROR&&this.keySystemError(t)}},i.keySystemError=function(e){var t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)},i.getPlaylistRetryOrSwitchAction=function(e,t){var i=vt(this.hls.config.playlistLoadPolicy,e),r=this.playlistError++;if(yt(i,r,gt(e),e.response))return{action:5,flags:0,retryConfig:i,retryCount:r};var n=this.getLevelSwitchAction(e,t);return i&&(n.retryConfig=i,n.retryCount=r),n},i.getFragRetryOrSwitchAction=function(e){var t=this.hls,i=this.getVariantLevelIndex(e.frag),r=t.levels[i],n=t.config,a=n.fragLoadPolicy,s=n.keyLoadPolicy,o=vt(e.details.startsWith("key")?s:a,e),l=t.levels.reduce((function(e,t){return e+t.fragmentError}),0);if(r&&(e.details!==k.FRAG_GAP&&r.fragmentError++,yt(o,l,gt(e),e.response)))return{action:5,flags:0,retryConfig:o,retryCount:l};var u=this.getLevelSwitchAction(e,i);return o&&(u.retryConfig=o,u.retryCount=l),u},i.getLevelSwitchAction=function(e,t){var i=this.hls;null==t&&(t=i.loadLevel);var r=this.hls.levels[t];if(r){var n,a,s=e.details;r.loadError++,s===k.BUFFER_APPEND_ERROR&&r.fragmentError++;var o=-1,l=i.levels,u=i.loadLevel,d=i.minAutoLevel,h=i.maxAutoLevel;i.autoLevelEnabled||i.config.preserveManualLevelOnError||(i.loadLevel=-1);for(var c,f=null==(n=e.frag)?void 0:n.type,g=(f===w&&s===k.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(s===k.BUFFER_ADD_CODEC_ERROR||s===k.BUFFER_APPEND_ERROR))&&l.some((function(e){var t=e.audioCodec;return r.audioCodec!==t})),v="video"===e.sourceBufferName&&(s===k.BUFFER_ADD_CODEC_ERROR||s===k.BUFFER_APPEND_ERROR)&&l.some((function(e){var t=e.codecSet,i=e.audioCodec;return r.codecSet!==t&&r.audioCodec===i})),m=null!=(a=e.context)?a:{},p=m.type,y=m.groupId,T=function(){var t=(E+u)%l.length;if(t!==u&&t>=d&&t<=h&&0===l[t].loadError){var i,n,a=l[t];if(s===k.FRAG_GAP&&f===P&&e.frag){var c=l[t].details;if(c){var m=dt(e.frag,c.fragments,e.frag.start);if(null!=m&&m.gap)return 0}}else{if(p===_&&a.hasAudioGroup(y)||p===C&&a.hasSubtitleGroup(y))return 0;if(f===w&&null!=(i=r.audioGroups)&&i.some((function(e){return a.hasAudioGroup(e)}))||f===x&&null!=(n=r.subtitleGroups)&&n.some((function(e){return a.hasSubtitleGroup(e)}))||g&&r.audioCodec===a.audioCodec||!g&&r.audioCodec!==a.audioCodec||v&&r.codecSet===a.codecSet)return 0}return o=t,1}},E=l.length;E--&&(0===(c=T())||1!==c););if(o>-1&&i.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:o}}return{action:2,flags:1}},i.onErrorOut=function(e,t){var i;switch(null==(i=t.errorAction)?void 0:i.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===k.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn('MediaSource ended after "'+t.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()},i.sendAlternateToPenaltyBox=function(e){var t=this.hls,i=e.errorAction;if(i){var r=i.flags,n=i.hdcpLevel,a=i.nextAutoLevel;switch(r){case 0:this.switchLevel(e,a);break;case 2:n&&(t.maxHdcpLevel=qe[qe.indexOf(n)-1],i.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')}i.resolved||this.switchLevel(e,a)}},i.switchLevel=function(e,t){if(void 0!==t&&e.errorAction&&(this.warn("switching to level "+t+" after "+e.details),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===k.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName))for(var i=Ve(e.mimeType),r=this.hls.levels,n=r.length;n--;)r[n][e.sourceBufferName+"Codec"]===i&&this.hls.removeLevel(n)},t}(F);function Et(e){var t={action:0,flags:0};return e&&(t.resolved=!0),t}var St="NOT_LOADED",Lt="APPENDING",At="PARTIAL",Rt="OK",kt=function(){function e(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.BUFFER_APPENDED,this.onBufferAppended,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.BUFFER_APPENDED,this.onBufferAppended,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){var i=this.activePartLists[t];if(i)for(var r=i.length;r--;){var n=i[r];if(!n)break;var a=n.end;if(n.start<=e&&null!==a&&e<=a)return n}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){return this.getFragAtPos(e,t,!0)},t.getFragAtPos=function(e,t,i){for(var r=this.fragments,n=Object.keys(r),a=n.length;a--;){var s=r[n[a]];if((null==s?void 0:s.body.type)===t&&(!i||s.buffered)){var o=s.body;if(o.start<=e&&e<=o.end)return o}}return null},t.detectEvictedFragments=function(e,t,i,r,n){var a=this;this.timeRanges&&(this.timeRanges[e]=t);var s=(null==r?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(r){var o=a.fragments[r];if(o&&!(s>=o.body.sn))if(o.buffered||o.loaded&&!n){var l=o.range[e];l&&(0!==l.time.length?l.time.some((function(e){var i=!a.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&a.removeFragment(o.body),i})):a.removeFragment(o.body))}else o.body.type===i&&a.removeFragment(o.body)}))},t.detectPartialFragments=function(e){var t=this,i=this.timeRanges;if(i&&"initSegment"!==e.frag.sn){var r=e.frag,n=It(r),a=this.fragments[n];if(!(!a||a.buffered&&r.gap)){var s=!r.relurl;Object.keys(i).forEach((function(n){var o=r.elementaryStreams[n];if(o){var l=i[n],u=s||!0===o.partial;a.range[n]=t.getBufferedTimes(r,e.part,u,l)}})),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),bt(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}}},t.removeParts=function(e,t){var i=this.activePartLists[t];i&&(this.activePartLists[t]=Dt(i,(function(t){return t.fragment.sn>=e})))},t.fragBuffered=function(e,t){var i=It(e),r=this.fragments[i];!r&&t&&(r=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)},t.getBufferedTimes=function(e,t,i,r){for(var n={time:[],partial:i},a=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a,u=0;u=d&&o<=h){n.time.push({startPTS:Math.max(a,r.start(u)),endPTS:Math.min(s,r.end(u))});break}if(ad){var c=Math.max(a,r.start(u)),f=Math.min(s,r.end(u));f>c&&(n.partial=!0,n.time.push({startPTS:c,endPTS:f}))}else if(s<=d)break}return n},t.getPartialFragment=function(e){var t,i,r,n=null,a=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(l){var u=o[l];u&&bt(u)&&(i=u.body.start-s,r=u.body.end+s,e>=i&&e<=r&&(t=Math.min(e-i,r-e),a<=t&&(n=u.body,a=t)))})),n},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||bt(t))},t.getState=function(e){var t=It(e),i=this.fragments[t];return i?i.buffered?bt(i)?At:Rt:Lt:St},t.isTimeBuffered=function(e,t,i){for(var r,n,a=0;a=r&&t<=n)return!0;if(t<=r)return!1}return!1},t.onManifestLoading=function(){this.removeAllFragments()},t.onFragLoaded=function(e,t){if("initSegment"!==t.frag.sn&&!t.frag.bitrateTest){var i=t.frag,r=t.part?null:t,n=It(i);this.fragments[n]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var i=t.frag,r=t.part,n=t.timeRanges,a=t.type;if("initSegment"!==i.sn){var s=i.type;if(r){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(r)}this.timeRanges=n;var l=n[a];this.detectEvictedFragments(a,l,s,r)}},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=It(e);return!!this.fragments[t]},t.hasFragments=function(e){var t=this.fragments,i=Object.keys(t);if(!e)return i.length>0;for(var r=i.length;r--;){var n=t[i[r]];if((null==n?void 0:n.body.type)===e)return!0}return!1},t.hasParts=function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)},t.removeFragmentsInRange=function(e,t,i,r,n){var a=this;r&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=a.fragments[s];if(o){var l=o.body;l.type!==i||r&&!l.gap||l.starte&&(o.buffered||n)&&a.removeFragment(l)}}))},t.removeFragment=function(e){var t=It(e);e.clearElementaryStreamInfo();var i=this.activePartLists[e.type];if(i){var r=e.sn;this.activePartLists[e.type]=Dt(i,(function(e){return e.fragment.sn!==r}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.removeAllFragments=function(){var e,t;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var i=null==(e=this.hls)||null==(t=e.latestLevelDetails)?void 0:t.partList;i&&i.forEach((function(e){return e.clearElementaryStreamInfo()}))},e}();function bt(e){var t,i,r;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(i=e.range.audio)?void 0:i.partial)||(null==(r=e.range.audiovideo)?void 0:r.partial))}function It(e){return e.type+"_"+e.level+"_"+e.sn}function Dt(e,t){return e.filter((function(e){var i=t(e);return i||e.clearElementaryStreamInfo(),i}))}var _t=function(){function e(e,t,i){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=i}return e.prototype.decrypt=function(e,t){switch(this.aesMode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},e}(),Ct=function(){function e(){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 t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),i=new Uint32Array(4),r=0;r<4;r++)i[r]=t.getUint32(4*r);return i},t.initTable=function(){var e=this.sBox,t=this.invSBox,i=this.subMix,r=i[0],n=i[1],a=i[2],s=i[3],o=this.invSubMix,l=o[0],u=o[1],d=o[2],h=o[3],c=new Uint32Array(256),f=0,g=0,v=0;for(v=0;v<256;v++)c[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var m=g^g<<1^g<<2^g<<3^g<<4;m=m>>>8^255&m^99,e[f]=m,t[m]=f;var p=c[f],y=c[p],T=c[y],E=257*c[m]^16843008*m;r[f]=E<<24|E>>>8,n[f]=E<<16|E>>>16,a[f]=E<<8|E>>>24,s[f]=E,E=16843009*T^65537*y^257*p^16843008*f,l[m]=E<<24|E>>>8,u[m]=E<<16|E>>>16,d[m]=E<<8|E>>>24,h[m]=E,f?(f=p^c[c[c[T^p]]],g^=c[c[g]]):f=g=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),i=!0,r=0;r1&&this.tickImmediate(),this._tickCallCount=0)},i.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},i.doTick=function(){},t}(F),Ut=function(e,t,i,r,n,a){void 0===r&&(r=0),void 0===n&&(n=-1),void 0===a&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=i,this.size=r,this.part=n,this.partial=a},Gt={length:0,start:function(){return 0},end:function(){return 0}},Kt=function(){function e(){}return e.isBuffered=function(t,i){if(t)for(var r=e.getBuffered(t),n=r.length;n--;)if(i>=r.start(n)&&i<=r.end(n))return!0;return!1},e.bufferedRanges=function(t){if(t){var i=e.getBuffered(t);return e.timeRangesToArray(i)}return[]},e.timeRangesToArray=function(e){for(var t=[],i=0;i1&&e.sort((function(e,t){return e.start-t.start||t.end-e.end}));var r=-1,n=[];if(i)for(var a=0;a=e[a].start&&t<=e[a].end&&(r=a);var s=n.length;if(s){var o=n[s-1].end;e[a].start-oo&&(n[s-1].end=e[a].end):n.push(e[a])}else n.push(e[a])}else n=e;for(var l,u=0,d=t,h=t,c=0;c=f&&t<=g&&(r=c),t+i>=f&&tNumber.MAX_SAFE_INTEGER?1/0:t},i.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),r=0;rNumber.MAX_SAFE_INTEGER?1/0:t},i.decimalFloatingPoint=function(e){return parseFloat(this[e])},i.optionalFloat=function(e,t){var i=this[e];return i?parseFloat(i):t},i.enumeratedString=function(e){return this[e]},i.enumeratedStringList=function(e,t){var i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((function(e,t){return e[t.toLowerCase()]=!0,e}),t)},i.bool=function(e){return"YES"===this[e]},i.decimalResolution=function(e){var t=qt.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e,t){var i,r={};for(Xt.lastIndex=0;null!==(i=Xt.exec(e));){var n=i[1].trim(),a=i[2],s=0===a.indexOf('"')&&a.lastIndexOf('"')===a.length-1,o=!1;if(s)a=a.slice(1,-1);else switch(n){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(s||o))a=jt(t,a);else if(!o&&!s)switch(n){case"CLOSED-CAPTIONS":if("NONE"===a)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":H.warn(e+": attribute "+n+" is missing quotes")}r[n]=a}return r},t(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(e){return"X-"===e.substring(0,2)}))}}])}();function Qt(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var Zt=t((function(e,t,i){var r;if(void 0===i&&(i=0),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(r=null==t?void 0:t.tagOrder)?r:i,t){var n=t.attr;for(var s in n)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==n[s]){H.warn('DATERANGE tag attribute: "'+s+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=s;break}e=a(new zt({}),n,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){var o=(null==t?void 0:t.endDate)||new Date(this.attr["END-DATE"]);S(o.getTime())&&(this._endDate=o)}}),[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e=this.tagAnchor;return null===e||null===e.programDateTime?(H.warn('Expected tagAnchor Fragment with PDT set for DateRange "'+this.id+'": '+e),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(S(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&S(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}]),$t=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1},t(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&S(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}])}();function Jt(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function ei(e){switch(e){case"AES-128":case"AES-256":return 0;case"AES-256-CTR":return 1;default:throw new Error("invalid full segment method "+e)}}function ti(e){return Uint8Array.from(atob(e),(function(e){return e.charCodeAt(0)}))}function ii(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(function(e){return e.charCodeAt(0)}))}var ri="undefined"!=typeof self?self:void 0,ni={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ai="org.w3.clearkey",si="com.apple.streamingkeydelivery",oi="com.microsoft.playready",li="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function ui(e){switch(e){case si:return ni.FAIRPLAY;case oi:return ni.PLAYREADY;case li:return ni.WIDEVINE;case ai:return ni.CLEARKEY}}function di(e){return"edef8ba979d64acea3c827dcd51d21ed"===e?ni.WIDEVINE:"9a04f07998404286ab92e65be0885f95"===e?ni.PLAYREADY:"1077efecc0b24d02ace33c1e52e2fb4b"===e||"e2719d58a985b3c9781ab030af78d30e"===e?ni.CLEARKEY:void 0}function hi(e){switch(e){case ni.FAIRPLAY:return si;case ni.PLAYREADY:return oi;case ni.WIDEVINE:return li;case ni.CLEARKEY:return ai}}function ci(e){var t=e.drmSystems,i=e.widevineLicenseUrl,r=t?[ni.FAIRPLAY,ni.WIDEVINE,ni.PLAYREADY,ni.CLEARKEY].filter((function(e){return!!t[e]})):[];return!r[ni.WIDEVINE]&&i&&r.push(ni.WIDEVINE),r}var fi,gi=null!=ri&&null!=(fi=ri.navigator)&&fi.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function vi(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),i=String.fromCharCode.apply(null,Array.from(t)),r=i.substring(i.indexOf("<"),i.length),n=(new DOMParser).parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(n){var a=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE");if(a){var s=ti(a).subarray(0,16);return function(e){var t=function(e,t,i){var r=e[t];e[t]=e[i],e[i]=r};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(s),s}}return null}var mi={},pi=function(){function e(e,t,i,r,n){void 0===r&&(r=[1]),void 0===n&&(n=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=r,this.iv=n,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!Jt(e)}e.clearKeyUriToKeyIdMap=function(){mi={}};var t=e.prototype;return t.isSupported=function(){if(this.method){if(Jt(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case si:case li:case oi:case ai:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1},t.getDecryptData=function(t){if(!this.encrypted||!this.uri)return null;if(Jt(this.method)&&this.uri&&!this.iv){"number"!=typeof t&&(H.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0);var i=function(e){for(var t=new Uint8Array(16),i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(t);return new e(this.method,this.uri,"identity",this.keyFormatVersions,i)}var r=function(e){var t,i,r=e.split(":"),n=null;if("data"===r[0]&&2===r.length){var a=r[1].split(";"),s=a[a.length-1].split(",");if(2===s.length){var o="base64"===s[0],l=s[1];o?(a.splice(-1,1),n=ti(l)):(t=ii(l).subarray(0,16),(i=new Uint8Array(16)).set(t,16-t.length),n=i)}}return n}(this.uri);if(r)switch(this.keyFormat){case li:this.pssh=r,r.length>=22&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case oi:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(e,t,i){if(16!==e.byteLength)throw new RangeError("Invalid system id");var r,n;r=new Uint8Array,n=new Uint8Array;var a=new Uint8Array(4);return i&&i.byteLength>0&&new DataView(a.buffer).setUint32(0,i.byteLength,!1),function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r>24&255,o[1]=a>>16&255,o[2]=a>>8&255,o[3]=255&a,o.set(e,4),s=0,a=8;s0&&a.length0&&Oi(f,P,l),p=f.startSN=parseInt(w);break;case"SKIP":f.skippedSegments&&xi(f,P,l);var O=new zt(w,f),M=O.decimalInteger("SKIPPED-SEGMENTS");if(S(M)){f.skippedSegments+=M;for(var F=M;F--;)g.push(null);p+=M}var N=O.enumeratedString("RECENTLY-REMOVED-DATERANGES");N&&(f.recentlyRemovedDateranges=(f.recentlyRemovedDateranges||[]).concat(N.split("\t")));break;case"TARGETDURATION":0!==f.targetduration&&xi(f,P,l),f.targetduration=Math.max(parseInt(w),1);break;case"VERSION":null!==f.version&&xi(f,P,l),f.version=parseInt(w);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":f.live||xi(f,P,l),f.live=!1;break;case"#":(w||x)&&R.tagList.push(x?[w,x]:[w]);break;case"DISCONTINUITY":E++,R.tagList.push(["DIS"]);break;case"GAP":R.gap=!0,R.tagList.push([P]);break;case"BITRATE":R.tagList.push([P,w]),L=1e3*parseInt(w),S(L)?R.bitrate=L:L=0;break;case"DATERANGE":var B=new zt(w,f),U=new Zt(B,f.dateRanges[B.ID],f.dateRangeTagCount);f.dateRangeTagCount++,U.isValid||f.skippedSegments?f.dateRanges[U.id]=U:H.warn('Ignoring invalid DATERANGE tag: "'+w+'"'),R.tagList.push(["EXT-X-DATERANGE",w]);break;case"DEFINE":var G=new zt(w,f);"IMPORT"in G?Wt(f,G,s):Yt(f,G,t);break;case"DISCONTINUITY-SEQUENCE":0!==f.startCC?xi(f,P,l):g.length>0&&Oi(f,P,l),f.startCC=E=parseInt(w);break;case"KEY":var K=bi(w,t,f);if(K.isSupported()){if("NONE"===K.method){d=void 0;break}d||(d={}),d[K.keyFormat]&&(d=a({},d)),d[K.keyFormat]=K}else H.warn('[Keys] Ignoring invalid EXT-X-KEY tag: "'+w+'"');break;case"START":f.startTimeOffset=Ii(w);break;case"MAP":var V=new zt(w,f);if(R.duration){var j=new ee(r,c);Pi(j,V,i,d),m=j,R.initSegment=m,m.rawProgramDateTime&&!R.rawProgramDateTime&&(R.rawProgramDateTime=m.rawProgramDateTime)}else{var Y=R.byteRangeEndOffset;if(Y){var W=R.byteRangeStartOffset;I=Y-W+"@"+W}else I=null;Pi(R,V,i,d),m=R,b=!0}m.cc=E;break;case"SERVER-CONTROL":h&&xi(f,P,l),h=new zt(w),f.canBlockReload=h.bool("CAN-BLOCK-RELOAD"),f.canSkipUntil=h.optionalFloat("CAN-SKIP-UNTIL",0),f.canSkipDateRanges=f.canSkipUntil>0&&h.bool("CAN-SKIP-DATERANGES"),f.partHoldBack=h.optionalFloat("PART-HOLD-BACK",0),f.holdBack=h.optionalFloat("HOLD-BACK",0);break;case"PART-INF":f.partTarget&&xi(f,P,l);var q=new zt(w);f.partTarget=q.decimalFloatingPoint("PART-TARGET");break;case"PART":var X=f.partList;X||(X=f.partList=[]);var z=y>0?X[X.length-1]:void 0,Q=y++,Z=new zt(w,f),$=new te(Z,R,c,Q,z);X.push($),R.duration+=$.duration;break;case"PRELOAD-HINT":var J=new zt(w,f);f.preloadHint=J;break;case"RENDITION-REPORT":var ie=new zt(w,f);f.renditionReports=f.renditionReports||[],f.renditionReports.push(ie);break;default:H.warn("line parsed but not handled: "+l)}}}A&&!A.relurl?(g.pop(),T-=A.duration,f.partList&&(f.fragmentHint=A)):f.partList&&(Ci(R,A,v),R.cc=E,f.fragmentHint=R,d&&wi(R,d,f)),f.targetduration||(f.playlistParsingError=new Error("#EXT-X-TARGETDURATION is required"));var re=g.length,ne=g[0],ae=g[re-1];if((T+=f.skippedSegments*f.targetduration)>0&&re&&ae){f.averagetargetduration=T/re;var se=ae.sn;f.endSN="initSegment"!==se?se:0,f.live||(ae.endList=!0),ne&&void 0===f.startCC&&(f.startCC=ne.cc),k>0&&(function(e,t){for(var i=e[t],r=t;r--;){var n=e[r];if(!n)return;n.programDateTime=i.programDateTime-1e3*n.duration,i=n}}(g,k),ne&&v.unshift(ne))}else f.endSN=0,f.startCC=0;return f.fragmentHint&&(T+=f.fragmentHint.duration),f.totalduration=T,v.length&&f.dateRangeTagCount&&ne&&Ri(v,f),f.endCC=E,f},e}();function Ri(e,t){var i=e.length;if(i)for(var r=e[i-1],n=t.live?1/0:t.totalduration,a=Object.keys(t.dateRanges),s=a.length;s--;){var o=t.dateRanges[a[s]],l=o.startDate.getTime();o.tagAnchor=r.ref;for(var u=i;u--;){var d=ki(t,l,e,u,n);if(-1!==d){o.tagAnchor=t.fragments[d].ref;break}}}}function ki(e,t,i,r,n){var a=i[r];if(a){var s,o=a.programDateTime;if((t>=o||0===r)&&t<=o+1e3*(((null==(s=i[r+1])?void 0:s.start)||n)-a.start)){var l=i[r].sn-e.startSN,u=e.fragments;if(u.length>i.length)for(var d=(i[r+1]||u[u.length-1]).sn-e.startSN;d>l;d--){var h=u[d].programDateTime;if(t>=h&&te.sn?(n=i-e.start,r=e):(n=e.start-i,r=t),r.duration!==n&&r.setDuration(n)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration):t.setStart(Math.max(e.start-t.duration,0))}function Fi(e,t,i,r,n,a){r-i<=0&&(H.warn("Fragment should have a positive duration",t),r=i+t.duration,a=n+t.duration);var s=i,o=r,l=t.startPTS,u=t.endPTS;if(S(l)){var d=Math.abs(l-i);S(t.deltaPTS)?t.deltaPTS=Math.max(d,t.deltaPTS):t.deltaPTS=d,s=Math.max(i,l),i=Math.min(i,l),n=Math.min(n,t.startDTS),o=Math.min(r,u),r=Math.max(r,u),a=Math.max(a,t.endDTS)}var h=i-t.start;0!==t.start&&t.setStart(i),t.setDuration(r-t.start),t.startPTS=i,t.maxStartPTS=s,t.startDTS=n,t.endPTS=r,t.minEndPTS=o,t.endDTS=a;var c,f=t.sn;if(!e||fe.endSN)return 0;var g=f-e.startSN,v=e.fragments;for(v[g]=t,c=g;c>0;c--)Mi(v[c],v[c-1]);for(c=g;c=0;s--){var o=n[s].initSegment;if(o){r=o;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,i){for(var r=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(r?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=n;u<=a;u++){var d=l[s+u],h=o[u];if(r&&!h&&d&&(h=t.fragments[u]=d),d&&h){if(i(d,h,u,o),d.url&&d.url!==h.url)return void(t.playlistParsingError=Bi("media sequence mismatch "+h.sn+":",e,t,0,h));if(d.cc!==h.cc)return void(t.playlistParsingError=Bi("discontinuity sequence mismatch ("+d.cc+"!="+h.cc+")",e,t,0,h))}}}(e,t,(function(e,n,a,s){if((!t.startCC||t.skippedSegments)&&n.cc!==e.cc){for(var o=e.cc-n.cc,l=a;l=0,s=0;if(a&&rt){var n=1e3*r[r.length-1].duration;ne.startCC)}(t,e)){var i=Math.min(t.endCC,e.endCC),r=Wi(t.fragments,i),n=Wi(e.fragments,i);r&&n&&(H.log("Aligning playlist at start of dicontinuity sequence "+i),Xi(r.start-n.start,e))}}function Qi(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var i=e.fragments,r=t.fragments;if(i.length&&r.length){var n,a,s=Math.min(t.endCC,e.endCC);t.startCCl.end){var c=o>h;(os.lastCurrentTime&&(s.lastCurrentTime=o),!s.loadingParts)){var f=Math.max(l.end,o),g=s.shouldLoadParts(s.getLevelDetails(),f);g&&(s.log("LL-Part loading ON after seeking to "+o.toFixed(2)+" with buffer @"+f.toFixed(2)),s.loadingParts=g)}s.hls.hasEnoughToStart||l.len||(s.log("setting startPosition to "+o+" because of seek before start"),s.nextLoadPosition=s.startPosition=o),s.tickImmediate()},s.onMediaEnded=function(){s.log("setting startPosition to 0 because media ended"),s.startPosition=s.lastCurrentTime=0},s.playlistType=a,s.hls=t,s.fragmentLoader=new Ot(t.config),s.keyLoader=r,s.fragmentTracker=i,s.config=t.config,s.decrypter=new wt(t.config),s}o(i,e);var r=i.prototype;return r.registerListeners=function(){var e=this.hls;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.ERROR,this.onError,this)},r.doTick=function(){this.onTickEnd()},r.onTickEnd=function(){},r.startLoad=function(e){},r.stopLoad=function(){if(this.state!==Zi){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Zi}},r.pauseBuffering=function(){this.buffering=!1},r.resumeBuffering=function(){this.buffering=!0},r._streamEnded=function(e,t){if(t.live||!this.media)return!1;var i=e.end||0,r=this.config.timelineOffset||0;if(i<=r)return!1;var n=e.buffered;this.config.maxBufferHole&&n&&n.length>1&&(e=Kt.bufferedInfo(n,e.start,0));var a=e.nextStart;if(a&&a>r&&a0&&null!=a&&a.key&&a.iv&&Jt(a.method)){var s=self.performance.now();return i.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,ei(a.method)).catch((function(e){throw t.trigger(b.ERROR,{type:R.MEDIA_ERROR,details:k.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:r}),e})).then((function(n){var a=self.performance.now();return t.trigger(b.FRAG_DECRYPTED,{frag:r,payload:n,stats:{tstart:s,tdecrypt:a}}),e.payload=n,i.completeInitSegmentLoad(e)}))}return i.completeInitSegmentLoad(e)})).catch((function(t){i.state!==Zi&&i.state!==sr&&(i.warn(t),i.resetFragmentLoading(e))}))},r.completeInitSegmentLoad=function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==Zi&&(this.state=$i),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()},r.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level},r.fragBufferedComplete=function(e,t){var i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+this.fragInfo(e,!1,t)+" > buffer:"+(i?function(e){for(var t="",i=e.length,r=0;r"+e.sn),this.loadingParts=u)}if(i=Math.max(e.start,i||0),this.loadingParts&&J(e)){var d=s.partList;if(d&&r){i>e.end&&s.fragmentHint&&(e=s.fragmentHint);var h=this.getNextPart(d,e,i);if(h>-1){var c,f=d[h];return e=this.fragCurrent=f.fragment,this.log("Loading "+e.type+" sn: "+e.sn+" part: "+f.index+" ("+h+"/"+(d.length-1)+") of "+this.fragInfo(e,!1,f)+") cc: "+e.cc+" ["+s.startSN+"-"+s.endSN+"], target: "+parseFloat(i.toFixed(3))),this.nextLoadPosition=f.start+f.duration,this.state=er,c=o?o.then((function(i){return!i||a.fragContextChanged(i.frag)?null:a.doFragPartsLoad(e,f,t,r)})).catch((function(e){return a.handleFragLoadError(e)})):this.doFragPartsLoad(e,f,t,r).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(b.FRAG_LOADING,{frag:e,part:f,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(d,i))return Promise.resolve(null)}}if(J(e)&&this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+i.toFixed(2)),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log("Loading "+e.type+" sn: "+e.sn+" of "+this.fragInfo(e,!1)+") cc: "+e.cc+" "+(s?"["+s.startSN+"-"+s.endSN+"]":"")+", target: "+parseFloat(i.toFixed(3))),S(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=er;var g,v=this.config.progressive;return g=v&&o?o.then((function(t){return!t||a.fragContextChanged(null==t?void 0:t.frag)?null:a.fragmentLoader.load(e,r)})).catch((function(e){return a.handleFragLoadError(e)})):Promise.all([this.fragmentLoader.load(e,v?r:void 0),o]).then((function(e){var t=e[0];return!v&&t&&r&&r(t),t})).catch((function(e){return a.handleFragLoadError(e)})),this.hls.trigger(b.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):g},r.doFragPartsLoad=function(e,t,i,r){var n=this;return new Promise((function(a,s){var o,l=[],u=null==(o=i.details)?void 0:o.partList,d=function(t){n.fragmentLoader.loadPart(e,t,r).then((function(r){l[t.index]=r;var s=r.part;n.hls.trigger(b.FRAG_LOADED,r);var o=Hi(i.details,e.sn,t.index+1)||ji(u,e.sn,t.index+1);if(!o)return a({frag:e,part:s,partsLoaded:l});d(o)})).catch(s)};d(t)}))},r.handleFragLoadError=function(e){if("data"in e){var t=e.data;e.data&&t.details===k.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(b.ERROR,t)}else this.hls.trigger(b.ERROR,{type:R.OTHER_ERROR,details:k.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},r._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===rr){var i=t.frag,r=t.part,n=t.level,a=self.performance.now();i.stats.parsing.end=a,r&&(r.stats.parsing.end=a);var s=this.getLevelDetails(),o=s&&i.sn>s.endSN||this.shouldLoadParts(s,i.end);o!==this.loadingParts&&(this.log("LL-Part loading "+(o?"ON":"OFF")+" after parsing segment ending @"+i.end.toFixed(2)),this.loadingParts=o),this.updateLevelTiming(i,r,n,e.partial)}else this.fragCurrent||this.state===Zi||this.state===sr||(this.state=$i)},r.shouldLoadParts=function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(null!=e&&e.partList){var i,r,n=e.partList[0];if(t>=n.end+((null==(i=e.fragmentHint)?void 0:i.duration)||0)&&(this.hls.hasEnoughToStart?(null==(r=this.media)?void 0:r.currentTime)||this.lastCurrentTime:this.getLoadPosition())>n.start-n.fragment.duration)return!0}}return!1},r.getCurrentContext=function(e){var t=this.levels,i=this.fragCurrent,r=e.level,n=e.sn,a=e.part;if(null==t||!t[r])return this.warn("Levels object was unset while buffering fragment "+n+" of "+this.playlistLabel()+" "+r+". The current chunk will not be buffered."),null;var s=t[r],o=s.details,l=a>-1?Hi(o,n,a):null,u=l?l.fragment:Vi(o,n,i);return u?(i&&i!==u&&(u.stats=i.stats),{frag:u,part:l,level:s}):null},r.bufferFragmentData=function(e,t,i,r,n){var a;if(e&&this.state===rr){var s=e.data1,o=e.data2,l=s;if(s&&o&&(l=Se(s,o)),null!=(a=l)&&a.length){var u={type:e.type,frag:t,part:i,chunkMeta:r,parent:t.type,data:l};if(this.hls.trigger(b.BUFFER_APPENDING,u),e.dropped&&e.independent&&!i){if(n)return;this.flushBufferGap(t)}}}},r.flushBufferGap=function(e){var t=this.media;if(t)if(Kt.isBuffered(t,t.currentTime)){var i=t.currentTime,r=Kt.bufferInfo(t,i,0),n=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),s=Math.max(Math.min(e.start-a,r.end-a),i+a);e.start-s>a&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)},r.getFwdBufferInfo=function(e,t){var i,r=this.getLoadPosition();if(!S(r))return null;var n=this.lastCurrentTime>r||null!=(i=this.media)&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,r,t,n)},r.getFwdBufferInfoAtPos=function(e,t,i,r){var n=Kt.bufferInfo(e,t,r);if(0===n.len&&void 0!==n.nextStart){var a=this.fragmentTracker.getBufferedFrag(t,i);if(a&&(n.nextStart<=a.end||a.gap)){var s=Math.max(Math.min(n.nextStart,a.end)-t,r);return Kt.bufferInfo(e,t,s)}}return n},r.getMaxBufferLength=function(e){var t,i=this.config;return t=e?Math.max(8*i.maxBufferSize/e,i.maxBufferLength):i.maxBufferLength,Math.min(t,i.maxMaxBufferLength)},r.reduceMaxBufferLength=function(e,t){var i=this.config,r=Math.max(Math.min(e-t,i.maxBufferLength),t),n=Math.max(e-3*t,i.maxMaxBufferLength/2,r);return n>=r&&(i.maxMaxBufferLength=n,this.warn("Reduce max buffer length to "+n+"s"),!0)},r.getAppendedFrag=function(e,t){var i;void 0===t&&(t=P);var r=null==(i=this.fragmentTracker)?void 0:i.getAppendedFrag(e,t);return r&&"fragment"in r?r.fragment:r},r.getNextFragment=function(e,t){var i=t.fragments,r=i.length;if(!r)return null;var n=this.config,a=i[0].start,s=n.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l=n.initialLiveManifestSize;if(r=a?d:h)||o.start:e;this.log("Setting startPosition to "+c+" to match start frag at live edge. mainStart: "+d+" liveSyncPosition: "+h+" frag.start: "+(null==(u=o)?void 0:u.start)),this.startPosition=this.nextLoadPosition=c}}else e<=a&&(o=i[0]);if(!o){var f=this.loadingParts?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,f,t)}var g=this.filterReplacedPrimary(o,t);if(!g&&o){var v=o.sn-t.startSN;g=this.filterReplacedPrimary(i[v+1]||null,t)}return this.mapToInitFragWhenRequired(g)},r.isLoopLoading=function(e,t){var i=this.fragmentTracker.getState(e);return(i===Rt||i===At&&!!e.gap)&&this.nextLoadPosition>t},r.getNextFragmentLoopLoading=function(e,t,i,r,n){var a=null;if(e.gap&&(a=this.getNextFragment(this.nextLoadPosition,t))&&!a.gap&&i.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,r,0);if(null!==s&&i.len+s.len>=n){var o=a.sn;return this.loopSn!==o&&(this.log('buffer full after gaps in "'+r+'" playlist starting at sn: '+o),this.loopSn=o),null}}return this.loopSn=void 0,a},r.filterReplacedPrimary=function(e,t){if(!e)return e;if(dr(this.hls.config)&&e.type!==x){var i=this.hls.interstitialsManager,r=null==i?void 0:i.bufferingItem;if(r){var n=r.event;if(n){if(n.appendInPlace||Math.abs(e.start-r.start)>1||0===r.start)return null}else{if(e.end<=r.start&&!1===(null==t?void 0:t.live))return null;if(e.start>r.end&&r.nextEvent&&(r.nextEvent.appendInPlace||e.start-r.end>1))return null}}var a=null==i?void 0:i.playerQueue;if(a)for(var s=a.length;s--;){var o=a[s].interstitial;if(o.appendInPlace&&e.start>=o.startTime&&e.end<=o.resumeTime)return null}}return e},r.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},r.getNextPart=function(e,t,i){for(var r=-1,n=!1,a=!0,s=0,o=e.length;s-1&&ii.start&&i.loaded},r.getInitialLiveFragment=function(e){var t=e.fragments,i=this.fragPrevious,r=null;if(i){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),r=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!S(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(var r=0;r=e.startSN&&n<=e.endSN){var a=t[n-e.startSN];i.cc===a.cc&&(r=a,this.log("Live playlist, switching playlist, load frag with next SN: "+r.sn))}r||(r=ft(e,i.cc,i.end))&&this.log("Live playlist, switching playlist, load frag with same CC: "+r.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(r=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r},r.getFragmentAtPosition=function(e,t,i){var r,n,a=this.config,s=this.fragPrevious,o=i.fragments,l=i.endSN,u=i.fragmentHint,d=a.maxFragLookUpTolerance,h=i.partList,c=!!(this.loadingParts&&null!=h&&h.length&&u);if(c&&u&&!this.bitrateTest&&h[h.length-1].fragment.sn===u.sn&&(o=o.concat(u),l=u.sn),r=et-d||null!=(n=this.media)&&n.paused||!this.startFragRequested?0:d):o[o.length-1]){var f=r.sn-i.startSN,g=this.fragmentTracker.getState(r);if((g===Rt||g===At&&r.gap)&&(s=r),s&&r.sn===s.sn&&(!c||h[0].fragment.sn>r.sn||!i.live&&!c)&&s&&r.level===s.level){var v=o[f+1];r=r.sn"+e.startSN+" fragments: "+r),o}return n},r.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},r.setStartPosition=function(e,t){var i=this.startPosition;i=0&&(i=this.nextLoadPosition),i},r.handleFragLoadAborted=function(e,t){this.transmuxer&&e.type===this.playlistType&&J(e)&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of "+this.playlistLabel()+" "+e.level+" was aborted"),this.resetFragmentLoading(e))},r.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===tr)||(this.state=$i)},r.onFragmentOrKeyLoadError=function(e,t){if(t.chunkMeta&&!t.frag){var i=this.getCurrentContext(t.chunkMeta);i&&(t.frag=i.frag)}var r=t.frag;if(r&&r.type===e&&this.levels)if(this.fragContextChanged(r)){var n;this.warn("Frag load error must match current frag to retry "+r.url+" > "+(null==(n=this.fragCurrent)?void 0:n.url))}else{var a=t.details===k.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(r,!0);var s=t.errorAction,o=s||{},l=o.action,u=o.flags,d=o.retryCount,h=void 0===d?0:d,c=o.retryConfig,f=!!s&&!!c,g=f&&5===l,v=f&&!s.resolved&&1===u;if(!g&&v&&J(r)&&!r.endList)this.resetFragmentErrors(e),this.treatAsGap(r),s.resolved=!0;else if((g||v)&&h.5;n&&this.reduceMaxBufferLength(r.len,(null==t?void 0:t.duration)||10);var a=!n;return a&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+i+" buffer"),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1},r.resetFragmentErrors=function(e){e===w&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Zi&&(this.state=$i)},r.afterBufferFlushed=function(e,t,i){if(e){var r=Kt.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,i),this.state===ar&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Zi&&(this.state=$i)},r.resetStartWhenNotLoaded=function(e){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(e){this.warn("The loading context changed while buffering fragment "+e.sn+" of "+this.playlistLabel()+" "+e.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},r.removeUnbufferedFrags=function(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(e,t,i,r){var n=this,a=i.details;if(a){var s;if(!Object.keys(e.elementaryStreams).reduce((function(t,s){var o=e.elementaryStreams[s];if(o){var l=o.endPTS-o.startPTS;if(l<=0)return n.warn("Could not parse fragment "+e.sn+" "+s+" duration reliably ("+l+")"),t||!1;var u=r?0:Fi(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(b.LEVEL_PTS_UPDATED,{details:a,level:i,drift:u,type:s,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)&&(0===i.fragmentError&&this.treatAsGap(e,i),null===(null==(s=this.transmuxer)?void 0:s.error))){var o=new Error("Found no media in fragment "+e.sn+" of "+this.playlistLabel()+" "+e.level+" resetting transmuxer to fallback to playlist timing");if(this.warn(o.message),this.hls.trigger(b.ERROR,{type:R.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:e,reason:"Found no media in msn "+e.sn+" of "+this.playlistLabel()+' "'+i.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=nr,this.log("Parsed "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+this.fragInfo(e,!1,t)+")"),this.hls.trigger(b.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")},r.playlistLabel=function(){return this.playlistType===P?"level":"track"},r.fragInfo=function(e,t,i){var r,n;return void 0===t&&(t=!0),this.playlistLabel()+" "+e.level+" ("+(i?"part":"frag")+":["+(null!=(r=t&&!i?e.startPTS:(i||e).start)?r:NaN).toFixed(3)+"-"+(null!=(n=t&&!i?e.endPTS:(i||e).end)?n:NaN).toFixed(3)+"]"+(i&&"main"===e.type?"INDEPENDENT="+(i.independent?"YES":"NO"):"")},r.treatAsGap=function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)},r.resetTransmuxer=function(){var e;null==(e=this.transmuxer)||e.reset()},r.recoverWorkerError=function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},t(i,[{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;return-1===t&&e?e:t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function(){var e,t=this.config.timelineOffset;return t?(null==(e=this.getLevelDetails())?void 0:e.appliedTimelineOffset)||t:0}},{key:"primaryPrefetch",get:function(){var e,t;return!(!dr(this.hls.config)||!(null==(e=this.hls.interstitialsManager)||null==(t=e.playingItem)?void 0:t.event))}},{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}])}(Bt);function dr(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}var hr=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var i=new Uint8Array(t),r=0,n=0;n0)return e.subarray(i,i+r)}function mr(e,t){return 255===e[t]&&240==(246&e[t+1])}function pr(e,t){return 1&e[t+1]?7:9}function yr(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Tr(e,t){return t+1=e.length)return!1;var r=yr(e,t);if(r<=i)return!1;var n=t+r;return n===e.length||Tr(e,n)}return!1}function Sr(e,t,i,r,n){if(!e.samplerate){var s=function(e,t,i,r){var n=t[i+2],a=n>>2&15;if(!(a>12)){var s=1+(n>>6&3),o=t[i+3]>>6&3|(1&n)<<2,l="mp4a.40."+s,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][a],d=a;5!==s&&29!==s||(d-=3);var h=[s<<3|(14&d)>>1,(1&d)<<7|o<<3];return H.log("manifest codec:"+r+", parsed codec:"+l+", channels:"+o+", rate:"+u+" (ADTS object type:"+s+" sampling index:"+a+")"),{config:h,samplerate:u,channelCount:o,codec:l,parsedCodec:l,manifestCodec:r}}var c=new Error("invalid ADTS sampling index:"+a);e.emit(b.ERROR,b.ERROR,{type:R.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!0,error:c,reason:c.message})}(t,i,r,n);if(!s)return;a(e,s)}}function Lr(e){return 9216e4/e}function Ar(e,t,i,r,n){var a,s=r+n*Lr(e.samplerate),o=function(e,t){var i=pr(e,t);if(t+i<=e.length){var r=yr(e,t)-i;if(r>0)return{headerLength:i,frameLength:r}}}(t,i);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,h=Math.max(0,i+d-t.length);h?(a=new Uint8Array(d-u)).set(t.subarray(i+u,t.length),0):a=t.subarray(i+u,i+d);var c={unit:a,pts:s};return h||e.samples.push(c),{sample:c,length:d,missing:h}}var f=t.length-i;return(a=new Uint8Array(f)).set(t.subarray(i,t.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}function Rr(e,t){return fr(e,t)&&gr(e,t+6)+10<=e.length-t}function kr(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1/0),function(e,t,i,r){var n=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e),a=1;"BYTES_PER_ELEMENT"in r&&(a=r.BYTES_PER_ELEMENT);var s,o=(s=e)&&s.buffer instanceof ArrayBuffer&&void 0!==s.byteLength&&void 0!==s.byteOffset?e.byteOffset:0,l=(o+e.byteLength)/a,u=(o+t)/a,d=Math.floor(Math.max(0,Math.min(u,l)));return new r(n,d,Math.floor(Math.min(d+Math.max(i,0),l))-d)}(e,t,i,Uint8Array)}function br(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=W(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,i=W(e.data.subarray(t),!0);t+=i.length+1;var r=W(e.data.subarray(t));return{key:e.type,info:i,data:r}}var n=W(e.data);return{key:e.type,info:"",data:n}}(e):"APIC"===e.type?function(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var i=e.data.subarray(1).indexOf(0);if(-1!==i){var r=W(kr(e.data,1,i)),n=e.data[2+i],a=e.data.subarray(3+i).indexOf(0);if(-1!==a){var s,o=W(kr(e.data,3+i,a));return s="--\x3e"===r?W(kr(e.data,4+i+a)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+i+a)),t.mimeType=r,t.pictureType=n,t.description=o,t.data=s,t}}}else console.log("Ignore frame with unrecognized character encoding")}(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,i=W(e.data.subarray(t),!0);t+=i.length+1;var r=W(e.data.subarray(t));return{key:e.type,info:i,data:r}}var n=W(e.data.subarray(1));return{key:e.type,info:"",data:n}}}(e)}function Ir(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=gr(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}}function Dr(e){for(var t=0,i=[];fr(e,t);){var r=gr(e,t+6);e[t+5]>>6&1&&(t+=10);for(var n=(t+=10)+r;t+100&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:wr.audioId3,duration:Number.POSITIVE_INFINITY});nt.length)){var a=Vr(t,i);if(a&&i+a.frameLength<=t.length){var s=r+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(i,i+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function Vr(e,t){var i=e[t+1]>>3&3,r=e[t+1]>>1&3,n=e[t+2]>>4&15,a=e[t+2]>>2&3;if(1!==i&&0!==n&&15!==n&&3!==a){var s=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*Nr[14*(3===i?3-r:3===r?3:4)+n-1],u=Br[3*(3===i?0:2===i?1:2)+a],d=3===o?1:2,h=Ur[i][r],c=Gr[r],f=8*h*c,g=Math.floor(h*l/u+s)*c;if(null===Fr){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Fr=v?parseInt(v[1]):0}return!!Fr&&Fr<=87&&2===r&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:d,frameLength:g,samplesPerFrame:f}}}function Hr(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function jr(e,t){return t+10;){s[0]=e[t];var o=Math.min(r,8),l=8-o;a[0]=4278190080>>>24+l<>l,i=i?i<t.length)return-1;if(11!==t[i]||119!==t[i+1])return-1;var a=t[i+4]>>6;if(a>=3)return-1;var s=[48e3,44100,32e3][a],o=63&t[i+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+a];if(i+l>t.length)return-1;var u=t[i+6]>>5,d=0;2===u?d+=2:(1&u&&1!==u&&(d+=2),4&u&&(d+=2));var h=(t[i+6]<<8|t[i+7])>>12-d&1,c=[2,1,2,3,3,4,4,5][u]+h,f=t[i+5]>>3,g=7&t[i+5],v=new Uint8Array([a<<6|f<<1|g>>2,(3&g)<<6|u<<3|h<<2|o>>4,o<<4&224]),m=r+n*(1536/s*9e4),p=t.subarray(i,i+l);return e.config=v,e.channelCount=c,e.samplerate=s,e.samples.push({unit:p,pts:m}),l}var Qr=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var i=t.prototype;return i.resetInitSegment=function(t,i,r,n){e.prototype.resetInitSegment.call(this,t,i,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:i,duration:n,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=vr(e,0),i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==Pr(t)&&qr(e,i)<=16)return!1;for(var r=e.length;i8&&109===e[i+4]&&111===e[i+5]&&111===e[i+6]&&102===e[i+7])return!0;i=r>1?i+r:t}return!1}(e)},t.demux=function(e,t){this.timeOffset=t;var i=e,r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=Se(this.remainderData,e));var a=function(e){var t={valid:null,remainder:null},i=ce(e,["moof"]);if(i.length<2)return t.remainder=e,t;var r=i[i.length-1];return t.valid=e.slice(0,r.byteOffset-8),t.remainder=e.slice(r.byteOffset-8),t}(i);this.remainderData=a.remainder,r.samples=a.valid||new Uint8Array}else r.samples=i;var s=this.extractID3Track(r,t);return n.samples=Le(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var r=this.extractID3Track(t,this.timeOffset);return i.samples=Le(e,t),{videoTrack:t,audioTrack:xr(),id3Track:r,textTrack:xr()}},t.extractID3Track=function(e,t){var i=this,r=this.id3Track;if(e.samples.length){var n=ce(e.samples,["emsg"]);n&&n.forEach((function(e){var n=function(e){var t=e[0],i="",r="",n=0,a=0,s=0,o=0,l=0,u=0;if(0===t){for(;"\0"!==se(e.subarray(u,u+1));)i+=se(e.subarray(u,u+1)),u+=1;for(i+=se(e.subarray(u,u+1)),u+=1;"\0"!==se(e.subarray(u,u+1));)r+=se(e.subarray(u,u+1)),u+=1;r+=se(e.subarray(u,u+1)),u+=1,n=le(e,12),a=le(e,16),o=le(e,20),l=le(e,24),u=28}else if(1===t){n=le(e,u+=4);var d=le(e,u+=4),h=le(e,u+=4);for(u+=4,s=Math.pow(2,32)*d+h,L(s)||(s=Number.MAX_SAFE_INTEGER,H.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=le(e,u),l=le(e,u+=4),u+=4;"\0"!==se(e.subarray(u,u+1));)i+=se(e.subarray(u,u+1)),u+=1;for(i+=se(e.subarray(u,u+1)),u+=1;"\0"!==se(e.subarray(u,u+1));)r+=se(e.subarray(u,u+1)),u+=1;r+=se(e.subarray(u,u+1)),u+=1}return{schemeIdUri:i,value:r,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:e.subarray(u,e.byteLength)}}(e);if(Zr.test(n.schemeIdUri)){var a=Jr(n,t),s=4294967295===n.eventDuration?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;s<=.001&&(s=Number.POSITIVE_INFINITY);var o=n.payload;r.samples.push({data:o,len:o.byteLength,dts:a,pts:a,type:wr.emsg,duration:s})}else if(i.config.enableEmsgKLVMetadata&&n.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var l=Jr(n,t);r.samples.push({data:n.payload,len:n.payload.byteLength,dts:l,pts:l,type:wr.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return r},t.demuxSampleAes=function(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},e}();function Jr(e,t){return S(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var en=function(){function e(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new wt(t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,0)},t.decryptAacSample=function(e,t,i){var r=this,n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(s).then((function(a){var s=new Uint8Array(a);n.set(s,16),r.decrypter.isSync()||r.decryptAacSamples(e,t+1,i)}))}},t.decryptAacSamples=function(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,i),this.decrypter.isSync())))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),r=0,n=32;n=e.length)return void r();for(var n=e[t].units;!(i>=n.length);i++){var a=n[i];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,i,r,a),this.decrypter.isSync())))return}}},e}(),tn=function(){function e(){this.VideoSample=null}var t=e.prototype;return t.createVideoSample=function(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}},t.getLastNalUnit=function(e){var t,i,r=this.VideoSample;if(r&&0!==r.units.length||(r=e[e.length-1]),null!=(t=r)&&t.units){var n=r.units;i=n[n.length-1]}return i},t.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var i=t.samples,r=i.length;if(!r)return void t.dropped++;var n=i[r-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}},t.parseNALu=function(e,t,i){var r,n,a=t.byteLength,s=e.naluState||0,o=s,l=[],u=0,d=-1,h=0;for(-1===s&&(d=0,h=this.getNALuType(t,0),s=0,u=1);u=0){var c={data:t.subarray(d,n),type:h};l.push(c)}else{var f=this.getLastNalUnit(e.samples);f&&(o&&u<=4-o&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-o)),n>0&&(f.data=Se(f.data,t.subarray(0,n)),f.state=0))}u=0&&s>=0){var g={data:t.subarray(d,a),type:h,state:s};l.push(g)}if(0===l.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=Se(v.data,t))}return e.naluState=s,l},e}(),rn=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,i=e.byteLength-t,r=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");r.set(e.subarray(i,i+n)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&H.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?i<>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},e}(),nn=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var i=t.prototype;return i.parsePES=function(e,t,i,r){var n,a=this,s=this.parseNALu(e,i.data,r),o=this.VideoSample,l=!1;i.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),s.forEach((function(r){var s,u;switch(r.type){case 1:var d=!1;n=!0;var h,c=r.data;if(l&&c.length>4){var f=a.readSliceType(c);2!==f&&4!==f&&7!==f&&9!==f||(d=!0)}d&&null!=(h=o)&&h.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null),o||(o=a.VideoSample=a.createVideoSample(!0,i.pts,i.dts)),o.frame=!0,o.key=d;break;case 5:n=!0,null!=(s=o)&&s.frame&&!o.key&&(a.pushAccessUnit(o,e),o=a.VideoSample=null),o||(o=a.VideoSample=a.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 6:n=!0,ke(r.data,1,i.pts,t.samples);break;case 7:var g,v;n=!0,l=!0;var m=r.data,p=a.readSPS(m);if(!e.sps||e.width!==p.width||e.height!==p.height||(null==(g=e.pixelRatio)?void 0:g[0])!==p.pixelRatio[0]||(null==(v=e.pixelRatio)?void 0:v[1])!==p.pixelRatio[1]){e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[m];for(var y=m.subarray(1,4),T="avc1.",E=0;E<3;E++){var S=y[E].toString(16);S.length<2&&(S="0"+S),T+=S}e.codec=T}break;case 8:n=!0,e.pps=[r.data];break;case 9:n=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(a.pushAccessUnit(o,e),o=null),o||(o=a.VideoSample=a.createVideoSample(!1,i.pts,i.dts));break;case 12:n=!0;break;default:n=!1}o&&n&&o.units.push(r)})),r&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)},i.getNALuType=function(e,t){return 31&e[t]},i.readSliceType=function(e){var t=new rn(e);return t.readUByte(),t.readUEG(),t.readUEG()},i.skipScalingList=function(e,t){for(var i=8,r=8,n=0;n>>1},i.ebsp2rbsp=function(e){for(var t=new Uint8Array(e.byteLength),i=0,r=0;r=2&&3===e[r]&&0===e[r-1]&&0===e[r-2]||(t[i]=e[r],i++);return new Uint8Array(t.buffer,0,i)},i.pushAccessUnit=function(t,i){e.prototype.pushAccessUnit.call(this,t,i),this.initVPS&&(this.initVPS=null)},i.readVPS=function(e){var t=new rn(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}},i.readSPS=function(e){var t=new rn(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);var i=t.readBits(3);t.readBoolean();for(var r=t.readBits(2),n=t.readBoolean(),a=t.readBits(5),s=t.readUByte(),o=t.readUByte(),l=t.readUByte(),u=t.readUByte(),d=t.readUByte(),h=t.readUByte(),c=t.readUByte(),f=t.readUByte(),g=t.readUByte(),v=t.readUByte(),m=t.readUByte(),p=[],y=[],T=0;T0)for(var E=i;E<8;E++)t.readBits(2);for(var S=0;S1&&t.readEG();for(var N=0;N0&&se<16?(ee=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][se-1],te=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][se-1]):255===se&&(ee=t.readBits(16),te=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean()&&(t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte())),t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),(ae=t.readBoolean())&&(b+=t.readUEG(),I+=t.readUEG(),D+=t.readUEG(),_+=t.readUEG()),t.readBoolean()&&(re=t.readBits(32),ne=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean())){var oe=t.readBoolean(),le=t.readBoolean(),ue=!1;(oe||le)&&((ue=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ue&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(var de=0;de<=i;de++){var he=!1;(ie=t.readBoolean())||t.readBoolean()?t.readEG():he=t.readBoolean();var ce=he?1:t.readUEG()+1;if(oe)for(var fe=0;fe>Le&1)<<31-Le)>>>0;var Ae=Se.toString(16);return 1===a&&"2"===Ae&&(Ae="6"),{codecString:"hvc1."+Te+a+"."+Ae+"."+(n?"H":"L")+m+".B0",params:{general_tier_flag:n,general_profile_idc:a,general_profile_space:r,general_profile_compatibility_flags:[s,o,l,u],general_constraint_indicator_flags:[d,h,c,f,g,v],general_level_idc:m,bit_depth:C+8,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:P,min_spatial_segmentation_idc:J,chroma_format_idc:L,frame_rate:{fixed:ie,fps:ne/re}},width:ve,height:me,pixelRatio:[ee,te]}},i.readPPS=function(e){var t=new rn(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var i=t.readBoolean(),r=t.readBoolean(),n=1;return r&&i?n=0:r?n=3:i&&(n=2),{parallelismType:n}},i.matchSPS=function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)},t}(tn),sn=188,on=function(){function e(e,t,i,r){this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.logger=r,this.videoParser=null}e.probe=function(t,i){var r=e.syncOffset(t);return r>0&&i.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},e.syncOffset=function(e){for(var t=e.length,i=Math.min(940,t-sn)+1,r=0;r1&&(0===a&&s>2||o+sn>i))return a}r++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:ae[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,i,r,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=n,this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=i,this.videoCodec=r},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,i=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null},t.demux=function(t,i,r,n){var a;void 0===r&&(r=!1),void 0===n&&(n=!1),r||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,d=s.pid,h=s.pesData,c=o.pid,f=l.pid,g=o.pesData,v=l.pesData,m=null,p=this.pmtParsed,y=this._pmtId,T=t.length;if(this.remainderData&&(T=(t=Se(this.remainderData,t)).length,this.remainderData=null),T>4>1){if((k=L+5+t[L+4])===L+sn)continue}else k=L+4;switch(R){case d:if(A){if(h&&(a=fn(h,this.logger))){if(null===this.videoParser)switch(s.segmentCodec){case"avc":this.videoParser=new nn;break;case"hevc":this.videoParser=new an}null!==this.videoParser&&this.videoParser.parsePES(s,u,a,!1)}h={data:[],size:0}}h&&(h.data.push(t.subarray(k,L+sn)),h.size+=L+sn-k);break;case c:if(A){if(g&&(a=fn(g,this.logger)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,a);break;case"mp3":this.parseMPEGPES(o,a);break;case"ac3":this.parseAC3PES(o,a)}g={data:[],size:0}}g&&(g.data.push(t.subarray(k,L+sn)),g.size+=L+sn-k);break;case f:A&&(v&&(a=fn(v,this.logger))&&this.parseID3PES(l,a),v={data:[],size:0}),v&&(v.data.push(t.subarray(k,L+sn)),v.size+=L+sn-k);break;case 0:A&&(k+=t[k]+1),y=this._pmtId=un(t,k);break;case y:A&&(k+=t[k]+1);var b=dn(t,k,this.typeSupported,r,this.observer,this.logger);(d=b.videoPid)>0&&(s.pid=d,s.segmentCodec=b.segmentVideoCodec),(c=b.audioPid)>0&&(o.pid=c,o.segmentCodec=b.segmentAudioCodec),(f=b.id3Pid)>0&&(l.pid=f),null===m||p||(this.logger.warn("MPEG-TS PMT found at "+L+" after unknown PID '"+m+"'. Backtracking to sync byte @"+E+" to parse all TS packets."),m=null,L=E-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=R}}else S++;S>0&&hn(this.observer,new Error("Found "+S+" TS packet/s that do not start with 0x47"),void 0,this.logger),s.pesData=h,o.pesData=g,l.pesData=v;var I={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return n&&this.extractRemainingSamples(I),I},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,i=e.audioTrack,r=e.videoTrack,n=e.id3Track,a=e.textTrack,s=r.pesData,o=i.pesData,l=n.pesData;if(s&&(t=fn(s,this.logger))){if(null===this.videoParser)switch(r.segmentCodec){case"avc":this.videoParser=new nn;break;case"hevc":this.videoParser=new an}null!==this.videoParser&&(this.videoParser.parsePES(r,a,t,!0),r.pesData=null)}else r.pesData=s;if(o&&(t=fn(o,this.logger))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,t);break;case"mp3":this.parseMPEGPES(i,t);break;case"ac3":this.parseAC3PES(i,t)}i.pesData=null}else null!=o&&o.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=o;l&&(t=fn(l,this.logger))?(this.parseID3PES(n,t),n.pesData=null):n.pesData=l},t.demuxSampleAes=function(e,t,i){var r=this.demux(e,i,!0,!this.config.progressive),n=this.sampleAes=new en(this.observer,this.config,t);return this.decrypt(r,n)},t.decrypt=function(e,t){return new Promise((function(i){var r=e.audioTrack,n=e.videoTrack;r.samples&&"aac"===r.segmentCodec?t.decryptAacSamples(r.samples,0,(function(){n.samples?t.decryptAvcSamples(n.samples,0,0,(function(){i(e)})):i(e)})):n.samples&&t.decryptAvcSamples(n.samples,0,0,(function(){i(e)}))}))},t.destroy=function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0},t.parseAACPES=function(e,t){var i,r,n,a=0,s=this.aacOverFlow,o=t.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l)o=Se(s.sample.unit,o);else{var d=u-l;s.sample.unit.set(o.subarray(0,l),d),e.samples.push(s.sample),a=s.missing}}for(i=a,r=o.length;i0;)o+=n;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")},t.parseID3PES=function(e,t){if(void 0!==t.pts){var i=a({},t,{type:this._videoTrack?wr.emsg:wr.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}();function ln(e,t){return((31&e[t+1])<<8)+e[t+2]}function un(e,t){return(31&e[t+10])<<8|e[t+11]}function dn(e,t,i,r,n,a){var s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t0)for(var d=t+5,h=u;h>2;){106===e[d]&&(!0!==i.ac3?a.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=l,s.segmentAudioCodec="ac3"));var c=e[d+1]+2;d+=c,h-=c}break;case 194:case 135:return hn(n,new Error("Unsupported EC-3 in M2TS found"),void 0,a),s;case 36:-1===s.videoPid&&(s.videoPid=l,s.segmentVideoCodec="hevc",a.log("HEVC in M2TS found"))}t+=u+5}return s}function hn(e,t,i,r){r.warn("parsing error: "+t.message),e.emit(b.ERROR,b.ERROR,{type:R.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:t,reason:t.message})}function cn(e,t){t.log(e+" with AES-128-CBC encryption found in unencrypted stream")}function fn(e,t){var i,r,n,a,s,o=0,l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=Se(l[0],l[1]),l.splice(1,1);if(1===((i=l[0])[0]<<16)+(i[1]<<8)+i[2]){if((r=(i[4]<<8)+i[5])&&r>e.size-6)return null;var u=i[7];192&u&&(a=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&u?a-(s=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2)>54e5&&(t.warn(Math.round((a-s)/9e4)+"s delta between PTS and DTS, align them"),a=s):s=a);var d=(n=i[8])+9;if(e.size<=d)return null;e.size-=d;for(var h=new Uint8Array(e.size),c=0,f=l.length;cg){d-=g;continue}i=i.subarray(d),g-=d,d=0}h.set(i,o),o+=g}return r&&(r-=n+3),{data:h,pts:a,dts:s,len:r}}return null}var gn=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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(1===t)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(2===t)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(3===t)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}(),vn=Math.pow(2,32)-1,mn=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=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]),r=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:i,audio:r};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,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 s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))},e.box=function(e){for(var t=8,i=arguments.length,r=new Array(i>1?i-1:0),n=1;n>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale||0,t.duration||0),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,i,r){return e.box(e.types.moof,e.mfhd(t),e.traf(r,i))},e.moov=function(t){for(var i=t.length,r=[];i--;)r[i]=e.trak(t[i]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale||0,t[0].duration||0)].concat(r).concat(e.mvex(t)))},e.mvex=function(t){for(var i=t.length,r=[];i--;)r[i]=e.trex(t[i]);return e.box.apply(null,[e.types.mvex].concat(r))},e.mvhd=function(t,i){i*=t;var r=Math.floor(i/(vn+1)),n=Math.floor(i%(vn+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n,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,a)},e.sdtp=function(t){var i,r,n=t.samples||[],a=new Uint8Array(4+n.length);for(i=0;i>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(r));for(i=0;i>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(r));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,d=t.pixelRatio[0],h=t.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,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,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([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))},e.esds=function(e){var t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2].concat(t,[6,1,2]))},e.audioStsd=function(e){var t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])},e.mp4a=function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){return e.box(e.types[".mp3"],e.audioStsd(t))},e.ac3=function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))},e.stsd=function(t){var i=t.segmentCodec;if("audio"===t.type){if("aac"===i)return e.box(e.types.stsd,e.STSD,e.mp4a(t));if("ac3"===i&&t.config)return e.box(e.types.stsd,e.STSD,e.ac3(t));if("mp3"===i&&"mp3"===t.codec)return e.box(e.types.stsd,e.STSD,e.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===i)return e.box(e.types.stsd,e.STSD,e.avc1(t));if("hevc"===i&&t.vps)return e.box(e.types.stsd,e.STSD,e.hvc1(t))}throw new Error("unsupported "+t.type+" segment codec ("+i+"/"+t.codec+")")},e.tkhd=function(t){var i=t.id,r=(t.duration||0)*(t.timescale||0),n=t.width||0,a=t.height||0,s=Math.floor(r/(vn+1)),o=Math.floor(r%(vn+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,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,a>>8&255,255&a,0,0]))},e.traf=function(t,i){var r=e.sdtp(t),n=t.id,a=Math.floor(i/(vn+1)),s=Math.floor(i%(vn+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,r.length+16+20+8+16+8+8),r)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var i=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,i){var r,n,a,s,o,l,u=t.samples||[],d=u.length,h=12+16*d,c=new Uint8Array(h);for(i+=8+h,c.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0),r=0;r>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*r);return e.box(e.types.trun,c)},e.initSegment=function(t){e.types||e.init();var i=e.moov(t);return Se(e.FTYP,i)},e.hvc1=function(t){for(var i=t.params,r=[t.vps,t.sps,t.pps],n=new Uint8Array([1,i.general_profile_space<<6|(i.general_tier_flag?32:0)|i.general_profile_idc,i.general_profile_compatibility_flags[0],i.general_profile_compatibility_flags[1],i.general_profile_compatibility_flags[2],i.general_profile_compatibility_flags[3],i.general_constraint_indicator_flags[0],i.general_constraint_indicator_flags[1],i.general_constraint_indicator_flags[2],i.general_constraint_indicator_flags[3],i.general_constraint_indicator_flags[4],i.general_constraint_indicator_flags[5],i.general_level_idc,240|i.min_spatial_segmentation_idc>>8,255&i.min_spatial_segmentation_idc,252|i.parallelismType,252|i.chroma_format_idc,248|i.bit_depth_luma_minus8,248|i.bit_depth_chroma_minus8,0,parseInt(i.frame_rate.fps),3|i.temporal_id_nested<<2|i.num_temporal_layers<<3|(i.frame_rate.fixed?64:0),r.length]),a=n.length,s=0;s>8,255&r[d][h].length]),a),a+=2,l.set(r[d][h],a),a+=r[d][h].length}var c=e.box(e.types.hvcC,l),f=t.width,g=t.height,v=t.pixelRatio[0],m=t.pixelRatio[1];return e.box(e.types.hvc1,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,f>>8&255,255&f,g>>8&255,255&g,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]),c,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([v>>24,v>>16&255,v>>8&255,255&v,m>>24,m>>16&255,m>>8&255,255&m])))},e}();mn.types=void 0,mn.HDLR_TYPES=void 0,mn.STTS=void 0,mn.STSC=void 0,mn.STCO=void 0,mn.STSZ=void 0,mn.VMHD=void 0,mn.SMHD=void 0,mn.STSD=void 0,mn.FTYP=void 0,mn.DINF=void 0;function pn(e,t,i,r){void 0===i&&(i=1),void 0===r&&(r=!1);var n=e*t*i;return r?Math.round(n):n}function yn(e,t){return pn(e,1e3,1/9e4,t)}var Tn=null,En=null;function Sn(e,t,i,r){return{duration:t,size:i,cts:r,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}var Ln=function(){function e(e,t,i,r){if(this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=i,this.logger=r,this.ISGenerated=!1,null===Tn){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Tn=n?parseInt(n[1]):0}if(null===En){var a=navigator.userAgent.match(/Safari\/(\d+)/i);En=a?parseInt(a[1]):0}}var t=e.prototype;return t.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},t.resetTimeStamp=function(e){this.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){this.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){this.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},t.getVideoStartPts=function(e){var t=!1,i=e[0].pts,r=e.reduce((function(e,r){var n=r.pts,a=n-e;return a<-4294967296&&(t=!0,a=(n=An(n,i))-e),a>0?e:n}),i);return t&&this.logger.debug("PTS rollover detected"),r},t.remux=function(e,t,i,r,n,a,s,o){var l,u,d,h,c,f,g=n,v=n,m=e.pid>-1,p=t.pid>-1,y=t.samples.length,T=e.samples.length>0,E=s&&y>0||y>1;if((!m||T)&&(!p||E)||this.ISGenerated||s){if(this.ISGenerated){var S,L,A,R,k=this.videoTrackConfig;(k&&(t.width!==k.width||t.height!==k.height||(null==(S=t.pixelRatio)?void 0:S[0])!==(null==(L=k.pixelRatio)?void 0:L[0])||(null==(A=t.pixelRatio)?void 0:A[1])!==(null==(R=k.pixelRatio)?void 0:R[1]))||!k&&E||null===this.nextAudioPts&&T)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,n,a));var b,I=this.isVideoContiguous,D=-1;if(E&&(D=function(e){for(var t=0;t0){this.logger.warn("[mp4-remuxer]: Dropped "+D+" out of "+y+" video samples due to a missing keyframe");var _=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(D),t.dropped+=D,b=v+=(t.samples[0].pts-_)/t.inputTimeScale}else-1===D&&(this.logger.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),f=!1);if(this.ISGenerated){if(T&&E){var C=this.getVideoStartPts(t.samples),P=(An(e.samples[0].pts,C)-C)/t.inputTimeScale;g+=Math.max(0,P),v+=Math.max(0,-P)}if(T){if(e.samplerate||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),d=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,g,this.isAudioContiguous,a,p||E||o===w?v:void 0),E){var x=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(this.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),d=this.generateIS(e,t,n,a)),l=this.remuxVideo(t,v,I,x)}}else E&&(l=this.remuxVideo(t,v,I,0));l&&(l.firstKeyFrame=D,l.independent=-1!==D,l.firstKeyFramePTS=b)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(c=Rn(i,n,this._initPTS,this._initDTS)),r.samples.length&&(h=kn(r,n,this._initPTS))),{audio:u,video:l,initSegment:d,independent:f,text:h,id3:c}},t.generateIS=function(e,t,i,r){var n,a,s,o,l=e.samples,u=t.samples,d=this.typeSupported,h={},c=this._initPTS,f=!c||r,g="audio/mp4";if(f&&(n=a=1/0),e.config&&l.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":d.mpeg?(g="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}h.audio={id:"audio",container:g,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&d.mpeg?new Uint8Array(0):mn.initSegment([e]),metadata:{channelCount:e.channelCount}},f&&(o=e.id,s=e.inputTimeScale,c&&s===c.timescale?f=!1:n=a=l[0].pts-Math.round(s*i))}if(t.sps&&t.pps&&u.length){if(t.timescale=t.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:mn.initSegment([t]),metadata:{width:t.width,height:t.height}},f)if(o=t.id,s=t.inputTimeScale,c&&s===c.timescale)f=!1;else{var v=this.getVideoStartPts(u),m=Math.round(s*i);a=Math.min(a,An(u[0].dts,v)-m),n=Math.min(n,v-m)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(h).length)return this.ISGenerated=!0,f?(this._initPTS={baseTime:n,timescale:s},this._initDTS={baseTime:a,timescale:s}):n=s=void 0,{tracks:h,initPTS:n,timescale:s,trackId:o}},t.remuxVideo=function(e,t,i,r){var n,s,o=e.inputTimeScale,l=e.samples,u=[],d=l.length,h=this._initPTS,c=this.nextAvcDts,f=8,g=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,p=!1;if(!i||null===c){var y=t*o,T=l[0].pts-An(l[0].dts,l[0].pts);Tn&&null!==c&&Math.abs(y-T-c)<15e3?i=!0:c=y-T}for(var E=h.baseTime*o/h.timescale,S=0;S0?S-1:S].dts&&(p=!0)}p&&l.sort((function(e,t){var i=e.dts-t.dts,r=e.pts-t.pts;return i||r})),n=l[0].dts;var A=l[l.length-1].dts-n,I=A?Math.round(A/(d-1)):g||e.inputTimeScale/30;if(i){var D=n-c,_=D>I,C=D<-1;if((_||C)&&(_?this.logger.warn((e.segmentCodec||"").toUpperCase()+": "+yn(D,!0)+" ms ("+D+"dts) hole between fragments detected at "+t.toFixed(3)):this.logger.warn((e.segmentCodec||"").toUpperCase()+": "+yn(-D,!0)+" ms ("+D+"dts) overlapping between fragments detected at "+t.toFixed(3)),!C||c>=l[0].pts||Tn)){n=c;var P=l[0].pts-D;if(_)l[0].dts=n,l[0].pts=P;else for(var w=!0,x=0;xP&&w);x++){var O=l[x].pts;if(l[x].dts-=D,l[x].pts-=D,x0?ee.dts-l[J-1].dts:I;if(le=J>0?ee.pts-l[J-1].pts:I,ue.stretchShortVideoTrack&&null!==this.nextAudioPts){var he=Math.floor(ue.maxBufferHole*o),ce=(r?v+r*o:this.nextAudioPts)-ee.pts;ce>he?((g=ce-de)<0?g=de:X=!0,this.logger.log("[mp4-remuxer]: It is approximately "+ce/90+" ms to the next segment; using duration "+g/90+" ms for the last video frame.")):g=de}else g=de}var fe=Math.round(ee.pts-ee.dts);z=Math.min(z,g),Z=Math.max(Z,g),Q=Math.min(Q,le),$=Math.max($,le),u.push(Sn(ee.key,g,ie,fe))}if(u.length)if(Tn){if(Tn<70){var ge=u[0].flags;ge.dependsOn=2,ge.isNonSync=0}}else if(En&&$-Q0&&(r&&Math.abs(p-m)<9e3||Math.abs(An(g[0].pts-y,p)-m)<20*u),g.forEach((function(e){e.pts=An(e.pts-y,p)})),!i||m<0){if(g=g.filter((function(e){return e.pts>=0})),!g.length)return;m=0===n?0:r&&!f?Math.max(0,p):g[0].pts}if("aac"===e.segmentCodec)for(var T=this.config.maxAudioFramesDrift,E=0,S=m;E=T*u&&D<1e4&&f){var _=Math.round(I/u);(S=A-_*u)<0&&(_--,S+=u),0===E&&(this.nextAudioPts=m=S),this.logger.warn("[mp4-remuxer]: Injecting "+_+" audio frame @ "+(S/s).toFixed(3)+"s due to "+Math.round(1e3*I/s)+" ms gap.");for(var C=0;C<_;C++){var P=Math.max(S,0),w=gn.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);w||(this.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),w=L.unit.subarray()),g.splice(E,0,{unit:w,pts:P}),S+=u,E++}}L.pts=S,S+=u}for(var x,O=null,M=null,F=0,N=g.length;N--;)F+=g[N].unit.byteLength;for(var B=0,U=g.length;B0))return;F+=v;try{x=new Uint8Array(F)}catch(e){return void this.observer.emit(b.ERROR,b.ERROR,{type:R.MUX_ERROR,details:k.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:F,reason:"fail allocating audio mdat "+F})}h||(new DataView(x.buffer).setUint32(0,F),x.set(mn.types.mdat,4))}x.set(K,v);var H=K.byteLength;v+=H,c.push(Sn(!0,l,H,0)),M=V}var j=c.length;if(j){var Y=c[c.length-1];this.nextAudioPts=m=M+o*Y.duration;var W=h?new Uint8Array(0):mn.moof(e.sequenceNumber++,O/o,a({},e,{samples:c}));e.samples=[];var q=O/s,X=m/s,z={data1:W,data2:x,startPTS:q,endPTS:X,startDTS:q,endDTS:X,type:"audio",hasAudio:!0,hasVideo:!1,nb:j};return this.isAudioContiguous=!0,z}},e}();function An(e,t){var i;if(null===t)return e;for(i=t4294967296;)e+=i;return e}function Rn(e,t,i,r){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s0;n||(r=ce(t,["encv"])),r.forEach((function(e){ce(n?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var t=Ee(e);if(t){var r=t.subarray(8,24);r.some((function(e){return 0!==e}))||(H.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+q(r)+" -> "+q(i)),t.set(i,8))}}))}))})),e}(e,r)),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,i=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var r=this.initData=ge(e);r.audio&&(t=_n(r.audio,z,this.logger)),r.video&&(i=_n(r.video,Q,this.logger));var n={};r.audio&&r.video?n.audiovideo={container:"video/mp4",codec:t+","+i,supplemental:r.video.supplemental,initSegment:e,id:"main"}:r.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?n.video={container:"video/mp4",codec:i,supplemental:r.video.supplemental,initSegment:e,id:"main"}:this.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},t.remux=function(e,t,i,r,n,a){var s,o,l=this.initPTS,u=this.lastEndTime,d={audio:void 0,video:void 0,text:r,id3:i,initSegment:void 0};S(u)||(u=this.lastEndTime=n||0);var h=t.samples;if(null==h||!h.length)return d;var c={initPTS:void 0,timescale:void 0,trackId:void 0},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(h),f=this.initData),null==(o=f)||!o.length)return this.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),d;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var g,v=function(e,t,i){for(var r={},n=ce(e,["moof","traf"]),a=0;an}(l,A,n,R)&&c.timescale===l.timescale||(c.initPTS=A-n,l&&1===l.timescale&&this.logger.warn("Adjusting initPTS @"+n+" from "+l.baseTime/l.timescale+" to "+c.initPTS),this.initPTS=l={baseTime:c.initPTS,timescale:1});var b=e?A-l.baseTime/l.timescale:u;!function(e,t,i){ce(t,["moof","traf"]).forEach((function(t){ce(t,["tfhd"]).forEach((function(r){var n=le(r,4),a=e[n];if(a){var s=a.timescale||9e4;ce(t,["tfdt"]).forEach((function(e){var t=e[0],r=i*s;if(r){var n=le(e,4);if(0===t)n-=r,he(e,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=le(e,8),n-=r,n=Math.max(n,0);var a=Math.floor(n/(re+1)),o=Math.floor(n%(re+1));he(e,4,a),he(e,8,o)}}}))}}))}))}(f,h,l.baseTime/l.timescale);var I=b+R;R>0?this.lastEndTime=I:(this.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var D=!!f.audio,_=!!f.video,C="";D&&(C+="audio"),_&&(C+="video");var P={data1:h,startPTS:b,startDTS:b,endPTS:I,endDTS:I,type:C,hasAudio:D,hasVideo:_,nb:1,dropped:0};d.audio=D&&!_?P:void 0,d.video=_?P:void 0;var w=null==p?void 0:p.sampleCount;if(w){var x=p.keyFrameIndex,O=-1!==x;P.nb=w,P.dropped=0===x||this.isVideoContiguous?0:O?x:w,P.independent=O,P.firstKeyFrame=x,O&&p.keyFrameStart&&(P.firstKeyFramePTS=p.keyFrameStart-l.baseTime/l.timescale),this.isVideoContiguous||(d.independent=O),this.isVideoContiguous||(this.isVideoContiguous=O),P.dropped&&this.logger.warn("fmp4 does not start with IDR: firstIDR "+x+"/"+w+" dropped: "+P.dropped+" pts: "+(P.firstKeyFramePTS||"NA"))}return d.initSegment=c,d.id3=Rn(i,n,l,l),r.samples.length&&(d.text=kn(r,n,l)),d},e}();function Dn(e,t,i){return void 0===i&&(i=!1),void 0!==(null==e?void 0:e.start)?(e.start+(i?e.duration:0))/e.timescale:t}function _n(e,t,i){var r=null==e?void 0:e.codec;return r&&r.length>4?r:t===z?"ec-3"===r||"ac-3"===r||"alac"===r?r:"fLaC"===r||"Opus"===r?Be(r,!1):(i.warn('Unhandled audio codec "'+r+'" in mp4 MAP'),r||"mp4a"):(i.warn('Unhandled video codec "'+r+'" in mp4 MAP'),r||"avc1")}try{bn=self.performance.now.bind(self.performance)}catch(e){bn=Date.now}var Cn=[{demux:$r,remux:In},{demux:on,remux:Ln},{demux:Wr,remux:Ln},{demux:Qr,remux:Ln}];Cn.splice(2,0,{demux:Xr,remux:Ln});var Pn=function(){function e(e,t,i,r,n,a){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.id=n,this.logger=a}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,i,r){var n=this,a=i.transmuxing;a.executeStart=bn();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;r&&(this.currentTransmuxState=r);var u=r||o,d=u.contiguous,h=u.discontinuity,c=u.trackSwitch,f=u.accurateTimeOffset,g=u.timeOffset,v=u.initSegmentChange,m=l.audioCodec,p=l.videoCodec,y=l.defaultInitPts,T=l.duration,E=l.initSegmentData,S=function(e,t){var i=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(i=t),i}(s,t);if(S&&Jt(S.method)){var L=this.getDecrypter(),A=ei(S.method);if(!L.isSync())return this.asyncResult=!0,this.decryptionPromise=L.webCryptoDecrypt(s,S.key.buffer,S.iv.buffer,A).then((function(e){var t=n.push(e,null,i);return n.decryptionPromise=null,t})),this.decryptionPromise;var I=L.softwareDecrypt(s,S.key.buffer,S.iv.buffer,A);if(i.part>-1){var D=L.flush();I=D?D.buffer:D}if(!I)return a.executeEnd=bn(),wn(i);s=new Uint8Array(I)}var _=this.needsProbing(h,c);if(_){var C=this.configureTransmuxer(s);if(C)return this.logger.warn("[transmuxer] "+C.message),this.observer.emit(b.ERROR,b.ERROR,{type:R.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,fatal:!1,error:C,reason:C.message}),a.executeEnd=bn(),wn(i)}(h||c||v||_)&&this.resetInitSegment(E,m,p,T,t),(h||v||_)&&this.resetInitialTimestamp(y),d||this.resetContiguity();var P=this.transmux(s,S,g,f,i);this.asyncResult=xn(P);var w=this.currentTransmuxState;return w.contiguous=!0,w.discontinuity=!1,w.trackSwitch=!1,a.executeEnd=bn(),P},t.flush=function(e){var t=this,i=e.transmuxing;i.executeStart=bn();var r=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return this.asyncResult=!0,a.then((function(){return t.flush(e)}));var s=[],o=n.timeOffset;if(r){var l=r.flush();l&&s.push(this.push(l.buffer,null,e))}var u=this.demuxer,d=this.remuxer;if(!u||!d){i.executeEnd=bn();var h=[wn(e)];return this.asyncResult?Promise.resolve(h):h}var c=u.flush(o);return xn(c)?(this.asyncResult=!0,c.then((function(i){return t.flushRemux(s,i,e),s}))):(this.flushRemux(s,c,e),this.asyncResult?Promise.resolve(s):s)},t.flushRemux=function(e,t,i){var r=t.audioTrack,n=t.videoTrack,a=t.id3Track,s=t.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+i.sn+(i.part>-1?" part: "+i.part:"")+" of "+(this.id===P?"level":"track")+" "+i.level);var d=this.remuxer.remux(r,n,a,s,u,l,!0,this.id);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=bn()},t.resetInitialTimestamp=function(e){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,i,r,n){var a=this.demuxer,s=this.remuxer;a&&s&&(a.resetInitSegment(e,t,i,r),s.resetInitSegment(e,t,i,n))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,i,r,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,r,n):this.transmuxUnencrypted(e,i,r,n)},t.transmuxUnencrypted=function(e,t,i,r){var n=this.demuxer.demux(e,t,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,t,i,!1,this.id),chunkMeta:r}},t.transmuxSampleAes=function(e,t,i,r,n){var a=this;return this.demuxer.demuxSampleAes(e,t,i).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,r,!1,a.id),chunkMeta:n}}))},t.configureTransmuxer=function(e){for(var t,i=this.config,r=this.observer,n=this.typeSupported,a=0,s=Cn.length;a1&&l.id===(null==p?void 0:p.stats.chunkCount),A=!T&&(1===E||0===E&&(1===S||L&&S<=0)),R=self.performance.now();(T||E||0===n.stats.parsing.start)&&(n.stats.parsing.start=R),!a||!S&&A||(a.stats.parsing.start=R);var k=!(p&&(null==(d=n.initSegment)?void 0:d.url)===(null==(h=p.initSegment)?void 0:h.url)),b=new Mn(y,A,o,T,v,k);if(!A||y||k){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+n.type+" sn: "+l.sn+(l.part>-1?" part: "+l.part:"")+" "+(this.id===P?"level":"track")+": "+l.level+" id: "+l.id+"\n discontinuity: "+y+"\n trackSwitch: "+T+"\n contiguous: "+A+"\n accurateTimeOffset: "+o+"\n timeOffset: "+v+"\n initSegmentChange: "+k);var I=new On(i,r,t,s,u);this.configureTransmuxer(I)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({instanceNo:f,cmd:"demux",data:e,decryptdata:m,chunkMeta:l,state:b},e instanceof ArrayBuffer?[e]:[]);else if(g){var D=g.push(e,m,l,b);xn(D)?D.then((function(e){c.handleTransmuxComplete(e)})).catch((function(e){c.transmuxerError(e,l,"transmuxer-interface push error")})):this.handleTransmuxComplete(D)}},t.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var i=this.instanceNo,r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:i,cmd:"flush",chunkMeta:e});else if(r){var n=r.flush(e);xn(n)?n.then((function(i){t.handleFlushResult(i,e)})).catch((function(i){t.transmuxerError(i,e,"transmuxer-interface flush error")})):this.handleFlushResult(n,e)}},t.transmuxerError=function(e,t,i){this.hls&&(this.error=e,this.hls.trigger(b.ERROR,{type:R.MEDIA_ERROR,details:k.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))},t.handleFlushResult=function(e,t){var i=this;e.forEach((function(e){i.handleTransmuxComplete(e)})),this.onFlush(t)},t.configureTransmuxer=function(e){var t=this.instanceNo,i=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)},t.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}(),Yn=function(e){function t(t,i,r){var n;return(n=e.call(this,t,i,r,"audio-stream-controller",w)||this).mainAnchor=null,n.mainFragLoading=null,n.audioOnly=!1,n.bufferedTrack=null,n.switchingTrack=null,n.trackId=-1,n.waitingData=null,n.mainDetails=null,n.flushing=!1,n.bufferFlushed=!1,n.cachedTrackLoadedData=null,n.registerListeners(),n}o(t,e);var i=t.prototype;return i.onHandlerDestroying=function(){this.unregisterListeners(),e.prototype.onHandlerDestroying.call(this),this.resetItem()},i.resetItem=function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null},i.registerListeners=function(){e.prototype.registerListeners.call(this);var t=this.hls;t.on(b.LEVEL_LOADED,this.onLevelLoaded,this),t.on(b.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(b.BUFFER_RESET,this.onBufferReset,this),t.on(b.BUFFER_CREATED,this.onBufferCreated,this),t.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(b.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(b.FRAG_LOADING,this.onFragLoading,this),t.on(b.FRAG_BUFFERED,this.onFragBuffered,this)},i.unregisterListeners=function(){var t=this.hls;t&&(e.prototype.unregisterListeners.call(this),t.off(b.LEVEL_LOADED,this.onLevelLoaded,this),t.off(b.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(b.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(b.BUFFER_RESET,this.onBufferReset,this),t.off(b.BUFFER_CREATED,this.onBufferCreated,this),t.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(b.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(b.FRAG_LOADING,this.onFragLoading,this),t.off(b.FRAG_BUFFERED,this.onFragBuffered,this))},i.onInitPtsFound=function(e,t){var i=t.frag,r=t.id,n=t.initPTS,a=t.timescale;if(r===P){var s=i.cc,o=this.fragCurrent;if(this.initPTS[s]={baseTime:n,timescale:a},this.log("InitPTS for cc: "+s+" found from main: "+n+"/"+a),this.mainAnchor=i,this.state===or){var l=this.waitingData;(!l&&!this.loadingParts||l&&l.frag.cc!==s)&&this.syncWithAnchor(i,null==l?void 0:l.frag)}else!this.hls.hasEnoughToStart&&o&&o.cc!==s?(o.abortRequests(),this.syncWithAnchor(i,o)):this.state===$i&&this.tick()}},i.getLoadPosition=function(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:e.prototype.getLoadPosition.call(this)},i.syncWithAnchor=function(e,t){var i,r=(null==(i=this.mainFragLoading)?void 0:i.frag)||null;if(!t||(null==r?void 0:r.cc)!==t.cc){var n=(r||e).cc,a=ft(this.getLevelDetails(),n,this.getLoadPosition());a&&(this.log("Waiting fragment cc ("+(null==t?void 0:t.cc)+") cancelled because video is at cc "+e.cc),this.startFragRequested=!1,this.nextLoadPosition=a.start,this.resetLoadingState(),this.state===$i&&this.doTickIdle())}},i.startLoad=function(e,t){if(!this.levels)return this.startPosition=e,void(this.state=Zi);var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),i>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),e=i,this.state=$i):this.state=ir,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()},i.doTick=function(){switch(this.state){case $i:this.doTickIdle();break;case ir:var t=this.levels,i=this.trackId,r=null==t?void 0:t[i],n=null==r?void 0:r.details;if(n&&!this.waitForLive(r)){if(this.waitForCdnTuneIn(n))break;this.state=or}break;case tr:var a,s=performance.now(),o=this.retryDate;if(!o||s>=o||null!=(a=this.media)&&a.seeking){var l=this.levels,u=this.trackId;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==l?void 0:l[u])||null),this.state=$i}break;case or:var d=this.waitingData;if(d){var h=d.frag,c=d.part,f=d.cache,g=d.complete,v=this.mainAnchor;if(void 0!==this.initPTS[h.cc]){this.waitingData=null,this.state=er;var m={frag:h,part:c,payload:f.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(m),g&&e.prototype._handleFragmentLoadComplete.call(this,m)}else v&&v.cc!==d.frag.cc&&this.syncWithAnchor(v,d.frag)}else this.state=$i}this.onTickEnd()},i.resetLoadingState=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null),e.prototype.resetLoadingState.call(this)},i.onTickEnd=function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)},i.doTickIdle=function(){var e,t=this.hls,i=this.levels,r=this.media,n=this.trackId,a=t.config;if(this.buffering&&(r||this.primaryPrefetch||!this.startFragRequested&&a.startFragPrefetch)&&null!=i&&i[n]){var s=i[n],o=s.details;if(!o||this.waitForLive(s)||this.waitForCdnTuneIn(o))return this.state=ir,void(this.startFragRequested=!1);var l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,z,w));var u=this.getFwdBufferInfo(l,w);if(null!==u){if(!this.switchingTrack&&this._streamEnded(u,o))return t.trigger(b.BUFFER_EOS,{type:"audio"}),void(this.state=ar);var d=u.len,h=t.maxBufferLength,c=o.fragments,f=c[0].start,g=this.getLoadPosition(),v=this.flushing?g:u.end;if(this.switchingTrack&&r){var m=g;o.PTSKnown&&mf||u.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=f+.05)}if(!(d>=h&&!this.switchingTrack&&vy.end){var T=this.fragmentTracker.getFragAtPos(v,P);T&&T.end>y.end&&(y=T,this.mainFragLoading={frag:T,targetBufferTime:null})}if(p.start>y.end)return}this.loadFragment(p,s,v)}else this.bufferFlushed=!0}}}},i.onMediaDetaching=function(t,i){this.bufferFlushed=this.flushing=!1,e.prototype.onMediaDetaching.call(this,t,i)},i.onAudioTracksUpdated=function(e,t){var i=t.audioTracks;this.resetTransmuxer(),this.levels=i.map((function(e){return new Ze(e)}))},i.onAudioTrackSwitching=function(e,t){var i=!!t.url;this.trackId=t.id;var r=this.fragCurrent;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==Zi&&(this.setInterval(100),this.state=$i,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())},i.onManifestLoading=function(){e.prototype.onManifestLoading.call(this),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1},i.onLevelLoaded=function(e,t){this.mainDetails=t.details;var i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(b.AUDIO_TRACK_LOADED,i))},i.onAudioTrackLoaded=function(e,t){var i,r=this.levels,n=t.details,a=t.id,s=t.groupId,o=t.track;if(r){var l=this.mainDetails;if(!l||n.endCC>l.endCC||l.expired)return this.cachedTrackLoadedData=t,void(this.state!==Zi&&(this.state=ir));this.cachedTrackLoadedData=null,this.log("Audio track "+a+' "'+o.name+'" of "'+s+'" loaded ['+n.startSN+","+n.endSN+"]"+(n.lastPartSn?"[part-"+n.lastPartSn+"-"+n.lastPartIndex+"]":"")+",duration:"+n.totalduration);var u=r[a],d=0;if(n.live||null!=(i=u.details)&&i.live){if(this.checkLiveUpdate(n),n.deltaUpdateFailed)return;var h;u.details&&(d=this.alignPlaylists(n,u.details,null==(h=this.levelLastLoaded)?void 0:h.details)),n.alignedSliding||(zi(n,l),n.alignedSliding||Qi(n,l),d=n.fragmentStart)}u.details=n,this.levelLastLoaded=u,this.startFragRequested||this.setStartPosition(l,d),this.hls.trigger(b.AUDIO_TRACK_UPDATED,{details:n,id:a,groupId:t.groupId}),this.state!==ir||this.waitForCdnTuneIn(n)||(this.state=$i),this.tick()}else this.warn("Audio tracks reset while loading track "+a+' "'+o.name+'" of "'+s+'"')},i._handleFragmentLoadProgress=function(e){var t,i=e.frag,r=e.part,n=e.payload,a=this.config,s=this.trackId,o=this.levels;if(o){var l=o[s];if(l){var u=l.details;if(!u)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);var d=a.defaultAudioCodec||l.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new jn(this.hls,w,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var c=this.initPTS[i.cc],f=null==(t=i.initSegment)?void 0:t.data;if(void 0!==c){var g=r?r.index:-1,v=-1!==g,m=new Ut(i.level,i.sn,i.stats.chunkCount,n.byteLength,g,v);h.push(n,f,d,"",i,r,u.totalduration,!1,m,c)}else this.log("Unknown video PTS for cc "+i.cc+", waiting for video PTS before demuxing audio frag "+i.sn+" of ["+u.startSN+" ,"+u.endSN+"],track "+s),(this.waitingData=this.waitingData||{frag:i,part:r,cache:new hr,complete:!1}).cache.push(new Uint8Array(n)),this.state!==Zi&&(this.state=or)}else this.warn("Audio track is undefined on fragment load progress")}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+i.sn+" of level "+i.level+" will not be buffered")},i._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:e.prototype._handleFragmentLoadComplete.call(this,t)},i.onBufferReset=function(){this.mediaBuffer=null},i.onBufferCreated=function(e,t){this.bufferFlushed=this.flushing=!1;var i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)},i.onFragLoading=function(e,t){!this.audioOnly&&t.frag.type===P&&J(t.frag)&&(this.mainFragLoading=t,this.state===$i&&this.tick())},i.onFragBuffered=function(e,t){var i=t.frag,r=t.part;if(i.type===w)if(this.fragContextChanged(i))this.warn("Fragment "+i.sn+(r?" p: "+r.index:"")+" of level "+i.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+(this.switchingTrack?this.switchingTrack.name:"false"));else{if(J(i)){this.fragPrevious=i;var n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(b.AUDIO_TRACK_SWITCHED,d({},n)))}this.fragBufferedComplete(i,r),this.media&&this.tick()}else this.audioOnly||i.type!==P||i.elementaryStreams.video||i.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)},i.onError=function(t,i){var r;if(i.fatal)this.state=sr;else switch(i.details){case k.FRAG_GAP:case k.FRAG_PARSING_ERROR:case k.FRAG_DECRYPT_ERROR:case k.FRAG_LOAD_ERROR:case k.FRAG_LOAD_TIMEOUT:case k.KEY_LOAD_ERROR:case k.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(w,i);break;case k.AUDIO_TRACK_LOAD_ERROR:case k.AUDIO_TRACK_LOAD_TIMEOUT:case k.LEVEL_PARSING_ERROR:i.levelRetry||this.state!==ir||(null==(r=i.context)?void 0:r.type)!==_||(this.state=$i);break;case k.BUFFER_ADD_CODEC_ERROR:case k.BUFFER_APPEND_ERROR:if("audio"!==i.parent)return;this.resetLoadingState();break;case k.BUFFER_FULL_ERROR:if("audio"!==i.parent)return;this.reduceLengthAndFlushBuffer(i)&&(this.bufferedTrack=null,e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"));break;case k.INTERNAL_EXCEPTION:this.recoverWorkerError(i)}},i.onBufferFlushing=function(e,t){t.type!==Q&&(this.flushing=!0)},i.onBufferFlushed=function(e,t){var i=t.type;if(i!==Q){this.flushing=!1,this.bufferFlushed=!0,this.state===ar&&(this.state=$i);var r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,i,w),this.tick())}},i._handleTransmuxComplete=function(e){var t,i="audio",r=this.hls,n=e.remuxResult,s=e.chunkMeta,o=this.getCurrentContext(s);if(o){var l=o.frag,u=o.part,d=o.level,h=d.details,c=n.audio,f=n.text,g=n.id3,v=n.initSegment;if(!this.fragContextChanged(l)&&h){if(this.state=rr,this.switchingTrack&&c&&this.completeAudioSwitch(this.switchingTrack),null!=v&&v.tracks){var m=l.initSegment||l;this._bufferInitSegment(d,v.tracks,m,s),r.trigger(b.FRAG_PARSING_INIT_SEGMENT,{frag:m,id:i,tracks:v.tracks})}if(c){var p=c.startPTS,y=c.endPTS,T=c.startDTS,E=c.endDTS;u&&(u.elementaryStreams[z]={startPTS:p,endPTS:y,startDTS:T,endDTS:E}),l.setElementaryStreamInfo(z,p,y,T,E),this.bufferFragmentData(c,l,u,s)}if(null!=g&&null!=(t=g.samples)&&t.length){var S=a({id:i,frag:l,details:h},g);r.trigger(b.FRAG_PARSING_METADATA,S)}if(f){var L=a({id:i,frag:l,details:h},f);r.trigger(b.FRAG_PARSING_USERDATA,L)}}else this.fragmentTracker.removeFragment(l)}else this.resetWhenMissingContext(s)},i._bufferInitSegment=function(e,t,i,r){if(this.state===rr&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var n=t.audio;n.id=w;var a=e.audioCodec;this.log("Init audio buffer, container:"+n.container+", codecs[level/parsed]=["+a+"/"+n.codec+"]"),a&&1===a.split(",").length&&(n.levelCodec=a),this.hls.trigger(b.BUFFER_CODECS,t);var s=n.initSegment;if(null!=s&&s.byteLength){var o={type:"audio",frag:i,part:null,chunkMeta:r,parent:i.type,data:s};this.hls.trigger(b.BUFFER_APPENDING,o)}this.tickImmediate()}},i.loadFragment=function(t,i,r){var n,a=this.fragmentTracker.getState(t);if(this.switchingTrack||a===St||a===At)if(J(t))if(null!=(n=i.details)&&n.live&&!this.initPTS[t.cc]){this.log("Waiting for video PTS in continuity counter "+t.cc+" of live stream before loading audio fragment "+t.sn+" of level "+this.trackId),this.state=or;var s=this.mainDetails;s&&s.fragmentStart!==i.details.fragmentStart&&Qi(i.details,s)}else e.prototype.loadFragment.call(this,t,i,r);else this._loadInitSegment(t,i);else this.clearTrackerIfNeeded(t)},i.flushAudioIfNeeded=function(t){if(this.media&&this.bufferedTrack){var i=this.bufferedTrack;nt({name:i.name,lang:i.lang,assocLang:i.assocLang,characteristics:i.characteristics,audioCodec:i.audioCodec,channels:i.channels},t,at)||(ot(t.url,this.hls)?(this.log("Switching audio track : flushing all audio"),e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=t)}},i.completeAudioSwitch=function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(b.AUDIO_TRACK_SWITCHED,d({},e))},t}(ur),Wn=function(e){function t(t,i){var r;return(r=e.call(this,i,t.logger)||this).hls=void 0,r.canLoad=!1,r.timer=-1,r.hls=t,r}o(t,e);var i=t.prototype;return i.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},i.clearTimer=function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},i.startLoad=function(){this.canLoad=!0,this.loadPlaylist()},i.stopLoad=function(){this.canLoad=!1,this.clearTimer()},i.switchParams=function(e,t,i){var r=null==t?void 0:t.renditionReports;if(r){for(var n=-1,a=0;a=0&&h>t.partTarget&&(d+=1)}var c=i&&ze(i);return new Qe(u,d>=0?d:void 0,c)}}},i.loadPlaylist=function(e){this.clearTimer()},i.loadingPlaylist=function(e,t){this.clearTimer()},i.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},i.getUrlWithDirectives=function(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}return e},i.playlistLoaded=function(e,t,i){var r=t.details,n=t.stats,a=self.performance.now(),s=n.loading.first?Math.max(0,a-n.loading.first):0;r.advancedDateTime=Date.now()-s;var o=this.hls.config.timelineOffset;if(o!==r.appliedTimelineOffset){var l=Math.max(o||0,0);r.appliedTimelineOffset=l,r.fragments.forEach((function(e){e.start=e.playlistOffset+l}))}if(r.live||null!=i&&i.live){var u="levelInfo"in t?t.levelInfo:t.track;if(r.reloaded(i),i&&r.fragments.length>0){Ni(i,r);var d=r.playlistParsingError;if(d){this.warn(d);var h=this.hls;if(!h.config.ignorePlaylistParsingErrors){var c,f=t.networkDetails;return void h.trigger(b.ERROR,{type:R.NETWORK_ERROR,details:k.LEVEL_PARSING_ERROR,fatal:!1,url:r.url,error:d,reason:d.message,level:t.level||void 0,parent:null==(c=r.fragments[0])?void 0:c.type,networkDetails:f,stats:n})}r.playlistParsingError=null}}-1===r.requestScheduled&&(r.requestScheduled=n.loading.start);var g,v=this.hls.mainForwardBufferInfo,m=v?v.end-v.len:0,p=Ki(r,1e3*(r.edge-m));if(r.requestScheduled+p0){if(_>3*r.targetduration)this.log("Playlist last advanced "+D.toFixed(2)+"s ago. Omitting segment and part directives."),y=void 0,T=void 0;else if(null!=i&&i.tuneInGoal&&_-r.partTarget>i.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+i.tuneInGoal+" to: "+C+" with playlist age: "+r.age),C=0;else{var P=Math.floor(C/r.targetduration);y+=P,void 0!==T&&(T+=Math.round(C%r.targetduration/r.partTarget)),this.log("CDN Tune-in age: "+r.ageHeader+"s last advanced "+D.toFixed(2)+"s goal: "+C+" skip sn "+P+" to part "+T)}r.tuneInGoal=C}if(g=this.getDeliveryDirectives(r,t.deliveryDirectives,y,T),E||!I)return r.requestScheduled=a,void this.loadingPlaylist(u,g)}else(r.canBlockReload||r.canSkipUntil)&&(g=this.getDeliveryDirectives(r,t.deliveryDirectives,y,T));g&&void 0!==y&&r.canBlockReload&&(r.requestScheduled=n.loading.first+Math.max(p-2*s,p/2)),this.scheduleLoading(u,g,r)}else this.clearTimer()},i.scheduleLoading=function(e,t,i){var r=this,n=i||e.details;if(n){var a=self.performance.now(),s=n.requestScheduled;if(a>=s)this.loadingPlaylist(e,t);else{var o=s-a;this.log("reload live playlist "+(e.name||e.bitrate+"bps")+" in "+Math.round(o)+" ms"),this.clearTimer(),this.timer=self.setTimeout((function(){return r.loadingPlaylist(e,t)}),o)}}else this.loadingPlaylist(e,t)},i.getDeliveryDirectives=function(e,t,i,r){var n=ze(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,r=t.part,n=""),new Qe(i,r,n)},i.checkRetry=function(e){var t=this,i=e.details,r=gt(e),n=e.errorAction,a=n||{},s=a.action,o=a.retryCount,l=void 0===o?0:o,u=a.retryConfig,d=!!n&&!!u&&(5===s||!n.resolved&&2===s);if(d){var h;if(l>=u.maxNumRetry)return!1;if(r&&null!=(h=e.context)&&h.deliveryDirectives)this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+i+'" without delivery-directives'),this.loadPlaylist();else{var c=mt(u,l);this.clearTimer(),this.timer=self.setTimeout((function(){return t.loadPlaylist()}),c),this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+i+'" in '+c+"ms")}e.levelRetry=!0,n.resolved=!0}return d},t}(F);function qn(e,t){if(e.length!==t.length)return!1;for(var i=0;i-1)n=a[o];else{var l=rt(s,this.tracks);n=this.tracks[l]}}var u=this.findTrackId(n);-1===u&&n&&(u=this.findTrackId(null));var d={audioTracks:a};this.log("Updating audio tracks, "+a.length+" track(s) found in group(s): "+(null==i?void 0:i.join(","))),this.hls.trigger(b.AUDIO_TRACKS_UPDATED,d);var h=this.trackId;if(-1!==u&&-1===h)this.setAudioTrack(u);else if(a.length&&-1===h){var c,f=new Error("No audio track selected for current audio group-ID(s): "+(null==(c=this.groupIds)?void 0:c.join(","))+" track count: "+a.length);this.warn(f.message),this.hls.trigger(b.ERROR,{type:R.MEDIA_ERROR,details:k.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:f})}}}},r.onError=function(e,t){!t.fatal&&t.context&&(t.context.type!==_||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))},r.setAudioOption=function(e){var t=this.hls;if(t.config.audioPreference=e,e){var i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){var r=this.currentTrack;if(r&&nt(e,r,at))return r;var n=rt(e,this.tracksInGroup,at);if(n>-1){var a=this.tracksInGroup[n];return this.setAudioTrack(n),a}if(r){var s=t.loadLevel;-1===s&&(s=t.firstAutoLevel);var o=function(e,t,i,r,n){var a=t[r],s=t.reduce((function(e,t,i){var r=t.uri;return(e[r]||(e[r]=[])).push(i),e}),{})[a.uri];s.length>1&&(r=Math.max.apply(Math,s));var o=a.videoRange,l=a.frameRate,u=a.codecSet.substring(0,4),d=st(t,r,(function(t){if(t.videoRange!==o||t.frameRate!==l||t.codecSet.substring(0,4)!==u)return!1;var r=t.audioGroups,a=i.filter((function(e){return!r||-1!==r.indexOf(e.groupId)}));return rt(e,a,n)>-1}));return d>-1?d:st(t,r,(function(t){var r=t.audioGroups,a=i.filter((function(e){return!r||-1!==r.indexOf(e.groupId)}));return rt(e,a,n)>-1}))}(e,t.levels,i,s,at);if(-1===o)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){var l=rt(e,i);if(l>-1)return i[l]}}}return null},r.setAudioTrack=function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn("Invalid audio track id: "+e);else{this.selectDefaultTrack=!1;var i=this.currentTrack,r=t[e],n=r.details&&!r.details.live;if(!(e===this.trackId&&r===i&&n||(this.log("Switching to audio-track "+e+' "'+r.name+'" lang:'+r.lang+" group:"+r.groupId+" channels:"+r.channels),this.trackId=e,this.currentTrack=r,this.hls.trigger(b.AUDIO_TRACK_SWITCHING,d({},r)),n))){var a=this.switchParams(r.url,null==i?void 0:i.details,r.details);this.loadPlaylist(a)}}},r.findTrackId=function(e){for(var t=this.tracksInGroup,i=0;i":"\n"+this.list("video")+"\n"+this.list("audio")+"\n"+this.list("audiovideo")+"}"},t.list=function(e){var t,i;return null!=(t=this.queues)&&t[e]||null!=(i=this.tracks)&&i[e]?e+": ("+this.listSbInfo(e)+") "+this.listOps(e):""},t.listSbInfo=function(e){var t,i=null==(t=this.tracks)?void 0:t[e],r=null==i?void 0:i.buffer;return r?"SourceBuffer"+(r.updating?" updating":"")+(i.ended?" ended":"")+(i.ending?" ending":""):"none"},t.listOps=function(e){var t;return(null==(t=this.queues)?void 0:t[e].map((function(e){return e.label})).join(", "))||""},e}(),$n=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Jn="HlsJsTrackRemovedError",ea=function(e){function t(t){var i;return(i=e.call(this,t)||this).name=Jn,i}return o(t,e),t}(f(Error)),ta=function(e){function i(t,i){var r,n;return(r=e.call(this,"buffer-controller",t.logger)||this).hls=void 0,r.fragmentTracker=void 0,r.details=null,r._objectUrl=null,r.operationQueue=null,r.bufferCodecEventsTotal=0,r.media=null,r.mediaSource=null,r.lastMpegAudioChunk=null,r.blockedAudioAppend=null,r.lastVideoAppendEnd=0,r.appendSource=void 0,r.transferData=void 0,r.overrides=void 0,r.appendErrors={audio:0,video:0,audiovideo:0},r.tracks={},r.sourceBuffers=[[null,null],[null,null]],r._onEndStreaming=function(e){var t;r.hls&&"open"===(null==(t=r.mediaSource)?void 0:t.readyState)&&r.hls.pauseBuffering()},r._onStartStreaming=function(e){r.hls&&r.hls.resumeBuffering()},r._onMediaSourceOpen=function(e){var t=r,i=t.media,n=t.mediaSource;e&&r.log("Media source opened"),i&&n&&(n.removeEventListener("sourceopen",r._onMediaSourceOpen),i.removeEventListener("emptied",r._onMediaEmptied),r.updateDuration(),r.hls.trigger(b.MEDIA_ATTACHED,{media:i,mediaSource:n}),null!==r.mediaSource&&r.checkPendingTracks())},r._onMediaSourceClose=function(){r.log("Media source closed")},r._onMediaSourceEnded=function(){r.log("Media source ended")},r._onMediaEmptied=function(){var e=r,t=e.mediaSrc,i=e._objectUrl;t!==i&&r.error("Media element src was set while attaching MediaSource ("+i+" > "+t+")")},r.hls=t,r.fragmentTracker=i,r.appendSource=(n=j(t.config.preferManagedMediaSource),"undefined"!=typeof self&&n===self.ManagedMediaSource),r.initTracks(),r.registerListeners(),r}o(i,e);var r=i.prototype;return r.hasSourceTypes=function(){return Object.keys(this.tracks).length>0},r.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null},r.registerListeners=function(){var e=this.hls;e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.BUFFER_RESET,this.onBufferReset,this),e.on(b.BUFFER_APPENDING,this.onBufferAppending,this),e.on(b.BUFFER_CODECS,this.onBufferCodecs,this),e.on(b.BUFFER_EOS,this.onBufferEos,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(b.FRAG_PARSED,this.onFragParsed,this),e.on(b.FRAG_CHANGED,this.onFragChanged,this),e.on(b.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.BUFFER_RESET,this.onBufferReset,this),e.off(b.BUFFER_APPENDING,this.onBufferAppending,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.BUFFER_EOS,this.onBufferEos,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(b.FRAG_PARSED,this.onFragParsed,this),e.off(b.FRAG_CHANGED,this.onFragChanged,this),e.off(b.ERROR,this.onError,this)},r.transferMedia=function(){var e=this,t=this.media,i=this.mediaSource;if(!t)return null;var r={};if(this.operationQueue){var n=this.isUpdating();n||this.operationQueue.removeBlockers();var s=this.isQueued();(n||s)&&this.warn("Transfering MediaSource with"+(s?" operations in queue":"")+(n?" updating SourceBuffer(s)":"")+" "+this.operationQueue),this.operationQueue.destroy()}var o=this.transferData;return!this.sourceBufferCount&&o&&o.mediaSource===i?a(r,o.tracks):this.sourceBuffers.forEach((function(t){var i=t[0];i&&(r[i]=a({},e.tracks[i]),e.removeBuffer(i)),t[0]=t[1]=null})),{media:t,mediaSource:i,tracks:r}},r.initTracks=function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0},r.onManifestLoading=function(){this.bufferCodecEventsTotal=0,this.details=null},r.onManifestParsed=function(e,t){var i,r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsTotal=r,this.log(r+" bufferCodec event(s) expected."),null!=(i=this.transferData)&&i.mediaSource&&this.sourceBufferCount&&r&&this.bufferCreated()},r.onMediaAttaching=function(e,t){var i=this.media=t.media,r=j(this.appendSource);if(this.transferData=this.overrides=void 0,i&&r){var n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var a=this.mediaSource=t.mediaSource||new r;if(this.assignMediaSource(a),n)this._objectUrl=i.src,this.attachTransferred();else{var s=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{i.removeAttribute("src");var o=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||o&&a instanceof o,ia(i),function(e,t){var i=self.document.createElement("source");i.type="video/mp4",i.src=t,e.appendChild(i)}(i,s),i.load()}catch(e){i.src=s}else i.src=s}i.addEventListener("emptied",this._onMediaEmptied)}},r.assignMediaSource=function(e){var t,i;this.log(((null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created")+" media source: "+(null==(i=e.constructor)?void 0:i.name)),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))},r.attachTransferred=function(){var e=this,t=this.media,i=this.transferData;if(i&&t){var r=this.tracks,n=i.tracks,a=n?Object.keys(n):null,s=a?a.length:0,o=function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()};if(n&&a&&s){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log("attachTransferred: (bufferCodecEventsTotal "+this.bufferCodecEventsTotal+")\nrequired tracks: "+Je(r,(function(e,t){return"initSegment"===e?void 0:t}))+";\ntransfer tracks: "+Je(n,(function(e,t){return"initSegment"===e?void 0:t}))+"}"),!Y(n,r)){i.mediaSource=null,i.tracks=void 0;var l=t.currentTime,u=this.details,d=Math.max(l,(null==u?void 0:u.fragments[0].start)||0);return d-l>1?void this.log("attachTransferred: waiting for playback to reach new tracks start time "+l+" -> "+d):(this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(n)+'"->"'+Object.keys(r)+'") start time: '+d+" currentTime: "+l),this.onMediaDetaching(b.MEDIA_DETACHING,{}),this.onMediaAttaching(b.MEDIA_ATTACHING,i),void(t.currentTime=d))}this.transferData=void 0,a.forEach((function(t){var i=t,r=n[i];if(r){var a=r.buffer;if(a){var s=e.fragmentTracker,o=r.id;if(s.hasFragments(o)||s.hasParts(o)){var l=Kt.getBuffered(a);s.detectEvictedFragments(i,l,o,null,!0)}var u=ra(i),d=[i,a];e.sourceBuffers[u]=d,a.updating&&e.operationQueue&&e.operationQueue.prependBlocker(i),e.trackSourceBuffer(i,r)}}})),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}},r.onMediaDetaching=function(e,t){var i=this,r=!!t.transferMedia;this.transferData=this.overrides=void 0;var n=this.media,a=this.mediaSource,s=this._objectUrl;if(a){if(this.log("media source "+(r?"transferring":"detaching")),r)this.sourceBuffers.forEach((function(e){var t=e[0];t&&i.removeBuffer(t)})),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var o="open"===a.readyState;try{for(var l=a.sourceBuffers,u=l.length;u--;)o&&l[u].abort(),a.removeSourceBuffer(l[u]);o&&a.endOfStream()}catch(e){this.warn("onMediaDetaching: "+e.message+" while calling endOfStream")}}this.sourceBufferCount&&this.onBufferReset()}a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.removeEventListener("startstreaming",this._onStartStreaming),a.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}n&&(n.removeEventListener("emptied",this._onMediaEmptied),r||(s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(n.removeAttribute("src"),this.appendSource&&ia(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(b.MEDIA_DETACHED,t)},r.onBufferReset=function(){var e=this;this.sourceBuffers.forEach((function(t){var i=t[0];i&&e.resetBuffer(i)})),this.initTracks()},r.resetBuffer=function(e){var t,i=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),i)try{var r;null!=(r=this.mediaSource)&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(t){this.warn("onBufferReset "+e,t)}delete this.tracks[e]},r.removeBuffer=function(e){this.removeBufferListeners(e),this.sourceBuffers[ra(e)]=[null,null];var t=this.tracks[e];t&&(t.buffer=void 0)},r.resetQueue=function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Zn(this.tracks)},r.onBufferCodecs=function(e,t){var i=this,r=this.tracks,n=Object.keys(t);this.log('BUFFER_CODECS: "'+n+'" (current SB count '+this.sourceBufferCount+")");var a="audiovideo"in t&&(r.audio||r.video)||r.audiovideo&&("audio"in t||"video"in t),s=!a&&this.sourceBufferCount&&this.media&&n.some((function(e){return!r[e]}));a||s?this.warn('Unsupported transition between "'+Object.keys(r)+'" and "'+n+'" SourceBuffers'):(n.forEach((function(e){var n,a,s,o=t[e],l=o.id,u=o.codec,d=o.levelCodec,h=o.container,c=o.metadata,f=o.supplemental,g=r[e],v=null==(n=i.transferData)||null==(a=n.tracks)?void 0:a[e],m=null!=v&&v.buffer?v:g,p=(null==m?void 0:m.pendingCodec)||(null==m?void 0:m.codec),y=null==m?void 0:m.levelCodec;g||(g=r[e]={buffer:void 0,listeners:[],codec:u,supplemental:f,container:h,levelCodec:d,metadata:c,id:l});var T=Ue(p,y),E=null==T?void 0:T.replace($n,"$1"),S=Ue(u,d),L=null==(s=S)?void 0:s.replace($n,"$1");S&&T&&E!==L&&("audio"===e.slice(0,5)&&(S=Be(S,i.appendSource)),i.log("switching codec "+p+" to "+S),S!==(g.pendingCodec||g.codec)&&(g.pendingCodec=S),g.container=h,i.appendChangeType(e,h,S))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||this.mediaSourceOpenOrEnded&&this.checkPendingTracks())},r.appendChangeType=function(e,t,i){var r=this,n=t+";codecs="+i,a={label:"change-type="+n,execute:function(){var a=r.tracks[e];if(a){var s=a.buffer;null!=s&&s.changeType&&(r.log("changing "+e+" sourceBuffer type to "+n),s.changeType(n),a.codec=i,a.container=t)}r.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){r.warn("Failed to change "+e+" SourceBuffer type",t)}};this.append(a,e,this.isPending(this.tracks[e]))},r.blockAudio=function(e){var t,i=this,r=e.start,n=r+.05*e.duration;if(!0!==(null==(t=this.fragmentTracker.getAppendedFrag(r,P))?void 0:t.gap)){var a={label:"block-audio",execute:function(){var e,t=i.tracks.video;(i.lastVideoAppendEnd>n||null!=t&&t.buffer&&Kt.isBuffered(t.buffer,n)||!0===(null==(e=i.fragmentTracker.getAppendedFrag(n,P))?void 0:e.gap))&&(i.blockedAudioAppend=null,i.shiftAndExecuteNext("audio"))},onStart:function(){},onComplete:function(){},onError:function(e){i.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",!0)}},r.unblockAudio=function(){var e=this.blockedAudioAppend,t=this.operationQueue;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))},r.onBufferAppending=function(e,t){var i=this,r=this.tracks,n=t.data,a=t.type,s=t.parent,o=t.frag,l=t.part,u=t.chunkMeta,d=u.buffering[a],h=o.sn,c=self.performance.now();d.start=c;var f=o.stats.buffering,g=l?l.stats.buffering:null;0===f.start&&(f.start=c),g&&0===g.start&&(g.start=c);var v=r.audio,m=!1;"audio"===a&&"audio/mpeg"===(null==v?void 0:v.container)&&(m=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var p=this.tracks.video,y=null==p?void 0:p.buffer;if(y&&"initSegment"!==h){var T=l||o,E=this.blockedAudioAppend;if("audio"!==a||"main"===s||this.blockedAudioAppend){if("video"===a){var S=T.end;if(E){var L=E.frag.start;(S>L||S=.1&&(i.log("Updating audio SourceBuffer timestampOffset to "+_+" (delta: "+r+") sn: "+h+")"),t.timestampOffset=_)}}}i.appendExecutor(n,a)},onStart:function(){},onComplete:function(){var e=self.performance.now();d.executeEnd=d.end=e,0===f.first&&(f.first=e),g&&0===g.first&&(g.first=e);var t={};i.sourceBuffers.forEach((function(e){var i=e[0],r=e[1];i&&(t[i]=Kt.getBuffered(r))})),i.appendErrors[a]=0,"audio"===a||"video"===a?i.appendErrors.audiovideo=0:(i.appendErrors.audio=0,i.appendErrors.video=0),i.hls.trigger(b.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:u,parent:o.type,timeRanges:t})},onError:function(e){var t,r={type:R.MEDIA_ERROR,parent:o.type,details:k.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:o,part:l,chunkMeta:u,error:e,err:e,fatal:!1},n=null==(t=i.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR)r.details=k.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&i.mediaSourceOpenOrEnded&&!n)r.errorAction=Et(!0);else if(e.name===Jn&&0===i.sourceBufferCount)r.errorAction=Et(!0);else{var s=++i.appendErrors[a];i.warn("Failed "+s+"/"+i.hls.config.appendErrorMaxRetry+' times to append segment in "'+a+'" sourceBuffer ('+(n||"no media error")+")"),(s>=i.hls.config.appendErrorMaxRetry||n)&&(r.fatal=!0)}i.hls.trigger(b.ERROR,r)}};this.append(C,a,this.isPending(this.tracks[a]))},r.getFlushOp=function(e,t,i){var r=this;return this.log('queuing "'+e+'" remove '+t+"-"+i),{label:"remove",execute:function(){r.removeExecutor(e,t,i)},onStart:function(){},onComplete:function(){r.hls.trigger(b.BUFFER_FLUSHED,{type:e})},onError:function(n){r.warn("Failed to remove "+t+"-"+i+' from "'+e+'" SourceBuffer',n)}}},r.onBufferFlushing=function(e,t){var i=this,r=t.type,n=t.startOffset,a=t.endOffset;r?this.append(this.getFlushOp(r,n,a),r):this.sourceBuffers.forEach((function(e){var t=e[0];t&&i.append(i.getFlushOp(t,n,a),t)}))},r.onFragParsed=function(e,t){var i=this,r=t.frag,n=t.part,a=[],s=n?n.elementaryStreams:r.elementaryStreams;s[Z]?a.push("audiovideo"):(s[z]&&a.push("audio"),s[Q]&&a.push("video")),0===a.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers((function(){var e=self.performance.now();r.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:r.stats;i.hls.trigger(b.FRAG_BUFFERED,{frag:r,part:n,stats:t,id:r.type})}),a).catch((function(e){i.warn("Fragment buffered callback "+e),i.stepOperationQueue(i.sourceBufferTypes)}))},r.onFragChanged=function(e,t){this.trimBuffers()},r.onBufferEos=function(e,t){var i,r=this;this.sourceBuffers.forEach((function(e){var i=e[0];if(i){var n=r.tracks[i];t.type&&t.type!==i||(n.ending=!0,n.ended||(n.ended=!0,r.log(i+" buffer reached EOS")))}}));var n=!1!==(null==(i=this.overrides)?void 0:i.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some((function(e){var t,i=e[0];return i&&!(null!=(t=r.tracks[i])&&t.ended)}))&&(n?(this.log("Queueing EOS"),this.blockUntilOpen((function(){r.tracksEnded();var e=r.mediaSource;e&&"open"===e.readyState?(r.log("Calling mediaSource.endOfStream()"),e.endOfStream(),r.hls.trigger(b.BUFFERED_TO_END,void 0)):e&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)}))):(this.tracksEnded(),this.hls.trigger(b.BUFFERED_TO_END,void 0)))},r.tracksEnded=function(){var e=this;this.sourceBuffers.forEach((function(t){var i=t[0];if(null!==i){var r=e.tracks[i];r&&(r.ending=!1)}}))},r.onLevelUpdated=function(e,t){var i=t.details;i.fragments.length&&(this.details=i,this.updateDuration())},r.updateDuration=function(){var e=this,t=this.getDurationAndRange();t&&this.blockUntilOpen((function(){return e.updateMediaSource(t)}))},r.onError=function(e,t){if(t.details===k.BUFFER_APPEND_ERROR&&t.frag){var i,r=null==(i=t.errorAction)?void 0:i.nextAutoLevel;S(r)&&r!==t.frag.level&&this.resetAppendErrors()}},r.resetAppendErrors=function(){this.appendErrors={audio:0,video:0,audiovideo:0}},r.trimBuffers=function(){var e=this.hls,t=this.details,i=this.media;if(i&&null!==t&&this.sourceBufferCount){var r=e.config,n=i.currentTime,a=t.levelTargetDuration,s=t.live&&null!==r.liveBackBufferLength?r.liveBackBufferLength:r.backBufferLength;if(S(s)&&s>=0){var o=Math.max(s,a),l=Math.floor(n/a)*a-o;this.flushBackBuffer(n,a,l)}if(S(r.frontBufferFlushThreshold)&&r.frontBufferFlushThreshold>0){var u=Math.max(r.maxBufferLength,r.frontBufferFlushThreshold),d=Math.max(u,a),h=Math.floor(n/a)*a+d;this.flushFrontBuffer(n,a,h)}}},r.flushBackBuffer=function(e,t,i){var r=this;this.sourceBuffers.forEach((function(e){var t=e[0],n=e[1];if(n){var a=Kt.getBuffered(n);if(a.length>0&&i>a.start(0)){var s;r.hls.trigger(b.BACK_BUFFER_REACHED,{bufferEnd:i});var o=r.tracks[t];if(null!=(s=r.details)&&s.live)r.hls.trigger(b.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=o&&o.ended)return void r.log("Cannot flush "+t+" back buffer while SourceBuffer is in ended state");r.hls.trigger(b.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:t})}}}))},r.flushFrontBuffer=function(e,t,i){var r=this;this.sourceBuffers.forEach((function(t){var n=t[0],a=t[1];if(a){var s=Kt.getBuffered(a),o=s.length;if(o<2)return;var l=s.start(o-1),u=s.end(o-1);if(i>l||e>=l&&e<=u)return;r.hls.trigger(b.BUFFER_FLUSHING,{startOffset:l,endOffset:1/0,type:n})}}))},r.getDurationAndRange=function(){var e,t=this.details,i=this.mediaSource;if(!t||!this.media||"open"!==(null==i?void 0:i.readyState))return null;var r=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&t.live&&i.setLiveSeekableRange){var n=Math.max(0,t.fragmentStart);return{duration:1/0,start:n,end:Math.max(n,r)}}return{duration:1/0}}var a=null==(e=this.overrides)?void 0:e.duration;if(a)return S(a)?{duration:a}:null;var s=this.media.duration;return r>(S(i.duration)?i.duration:0)&&r>s||!S(s)?{duration:r}:null},r.updateMediaSource=function(e){var t=e.duration,i=e.start,r=e.end,n=this.mediaSource;this.media&&n&&"open"===n.readyState&&(n.duration!==t&&(S(t)&&this.log("Updating MediaSource duration to "+t.toFixed(3)),n.duration=t),void 0!==i&&void 0!==r&&(this.log("MediaSource duration is set to "+n.duration+". Setting seekable range to "+i+"-"+r+"."),n.setLiveSeekableRange(i,r)))},r.checkPendingTracks=function(){var e=this.bufferCodecEventsTotal,t=this.pendingTrackCount,i=this.tracks;if(this.log("checkPendingTracks (pending: "+t+" codec events expected: "+e+") "+Je(i)),this.tracksReady){var r,n=null==(r=this.transferData)?void 0:r.tracks;n&&Object.keys(n).length?this.attachTransferred():this.createSourceBuffers()}},r.bufferCreated=function(){var e=this;if(this.sourceBufferCount){var t={};this.sourceBuffers.forEach((function(i){var r=i[0],n=i[1];if(r){var a=e.tracks[r];t[r]={buffer:n,container:a.container,codec:a.codec,supplemental:a.supplemental,levelCodec:a.levelCodec,id:a.id,metadata:a.metadata}}})),this.hls.trigger(b.BUFFER_CREATED,{tracks:t}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach((function(t){var i=t[0];e.executeNext(i)}))}else{var i=new Error("could not create source buffer for media codec(s)");this.hls.trigger(b.ERROR,{type:R.MEDIA_ERROR,details:k.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:i,reason:i.message})}},r.createSourceBuffers=function(){var e=this.tracks,t=this.sourceBuffers,i=this.mediaSource;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(var r in e){var n=r,a=e[n];if(this.isPending(a)){var s=this.getTrackCodec(a,n),o=a.container+";codecs="+s;a.codec=s,this.log("creating sourceBuffer("+o+")"+(this.currentOp(n)?" Queued":"")+" "+Je(a));try{var l=i.addSourceBuffer(o),u=ra(n),d=[n,l];t[u]=d,a.buffer=l}catch(e){var h;return this.error("error while trying to add sourceBuffer: "+e.message),this.shiftAndExecuteNext(n),null==(h=this.operationQueue)||h.removeBlockers(),delete this.tracks[n],void this.hls.trigger(b.ERROR,{type:R.MEDIA_ERROR,details:k.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:n,mimeType:o,parent:a.id})}this.trackSourceBuffer(n,a)}}this.bufferCreated()},r.getTrackCodec=function(e,t){var i=e.supplemental,r=e.codec;i&&("video"===t||"audiovideo"===t)&&Pe(i,"video")&&(r=function(e,t){var i=[];if(e)for(var r=e.split(","),n=0;nu&&(!a.ending||a.ended)?(a.ended=!1,this.log("Removing ["+u+","+d+"] from the "+e+" SourceBuffer"),s.remove(u,d)):this.shiftAndExecuteNext(e)},r.appendExecutor=function(e,t){var i=this.tracks[t],r=null==i?void 0:i.buffer;if(!r)throw new ea("Attempting to append to the "+t+" SourceBuffer, but it does not exist");i.ending=!1,i.ended=!1,r.appendBuffer(e)},r.blockUntilOpen=function(e){var t=this;if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch((function(e){t.warn("SourceBuffer blocked callback "+e),t.stepOperationQueue(t.sourceBufferTypes)}));else try{e()}catch(e){this.warn("Callback run without blocking "+this.operationQueue+" "+e)}},r.isUpdating=function(){return this.sourceBuffers.some((function(e){var t=e[0],i=e[1];return t&&i.updating}))},r.isQueued=function(){var e=this;return this.sourceBuffers.some((function(t){var i=t[0];return i&&!!e.currentOp(i)}))},r.isPending=function(e){return!!e&&!e.buffer},r.blockBuffers=function(e,t){var i=this;if(void 0===t&&(t=this.sourceBufferTypes),!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);var r=this.operationQueue,n=t.map((function(e){return i.appendBlocker(e)}));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(n).then((function(t){r===i.operationQueue&&(e(),i.stepOperationQueue(i.sourceBufferTypes))}))},r.stepOperationQueue=function(e){var t=this;e.forEach((function(e){var i,r=null==(i=t.tracks[e])?void 0:i.buffer;r&&!r.updating&&t.shiftAndExecuteNext(e)}))},r.append=function(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)},r.appendBlocker=function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)},r.currentOp=function(e){return this.operationQueue?this.operationQueue.current(e):null},r.executeNext=function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)},r.shiftAndExecuteNext=function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)},r.addBufferListener=function(e,t,i){var r=this.tracks[e];if(r){var n=r.buffer;if(n){var a=i.bind(this,e);r.listeners.push({event:t,listener:a}),n.addEventListener(t,a)}}},r.removeBufferListeners=function(e){var t=this.tracks[e];if(t){var i=t.buffer;i&&(t.listeners.forEach((function(e){i.removeEventListener(e.event,e.listener)})),t.listeners.length=0)}},t(i,[{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"sourceBufferTracks",get:function(){var e=this;return Object.keys(this.tracks).reduce((function(t,i){var r=e.tracks[i];return t[i]={id:r.id,container:r.container,codec:r.codec,levelCodec:r.levelCodec},t}),{})}},{key:"bufferedToEnd",get:function(){var e=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some((function(t){var i,r,n=t[0];return n&&(!(null!=(i=e.tracks[n])&&i.ended)||(null==(r=e.tracks[n])?void 0:r.ending))}))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function(){var e,t,i=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==i?void 0:i.src}},{key:"pendingTrackCount",get:function(){var e=this;return Object.keys(this.tracks).reduce((function(t,i){return t+(e.isPending(e.tracks[i])?1:0)}),0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce((function(e,t){return e+(t[0]?1:0)}),0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map((function(e){return e[0]})).filter((function(e){return!!e}))}}])}(F);function ia(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach((function(t){e.removeChild(t)}))}function ra(e){return"audio"===e?1:0}var na,aa=function(){function e(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var i=e.prototype;return i.setStreamController=function(e){this.streamController=e},i.destroy=function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},i.registerListeners=function(){var e=this.hls;e.on(b.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.BUFFER_CODECS,this.onBufferCodecs,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this)},i.unregisterListener=function(){var e=this.hls;e.off(b.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this)},i.onFpsDropLevelCapping=function(e,t){var i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})},i.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()},i.onManifestParsed=function(e,t){var i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()},i.onLevelsUpdated=function(e,t){this.timer&&S(this.autoLevelCapping)&&this.detectPlayerSize()},i.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},i.onMediaDetaching=function(){this.stopCapping(),this.media=null},i.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log("Setting autoLevelCapping to "+i+": "+e[i].height+"p@"+e[i].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},i.getMaxLevel=function(t){var i=this,r=this.hls.levels;if(!r.length)return-1;var n=r.filter((function(e,r){return i.isLevelAllowed(e)&&r<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},i.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},i.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},i.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,t.width||t.height||(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t},i.isLevelAllowed=function(e){return!this.restrictedLevels.some((function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))},e.getMaxLevelByMediaSize=function(e,t,i){if(null==e||!e.length)return-1;for(var r,n,a=e.length-1,s=Math.max(t,i),o=0;o=s||l.height>=s)&&(r=l,!(n=e[o+1])||r.width!==n.width||r.height!==n.height)){a=o;break}}return a},t(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 e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}}])}(),sa="m",oa="a",la="v",ua="av",da="i",ha="tt",ca="h",fa="CMCD-Request",ga="CMCD-Session",va="CMCD-Status",ma=((na={})["CMCD-Object"]=["br","d","ot","tb"],na[fa]=["bl","dl","mtp","nor","nrr","su"],na[ga]=["cid","pr","sf","sid","st","v"],na[va]=["bs","rtp"],na),pa=function e(t,i){Array.isArray(t)&&(t=t.map((function(t){return t instanceof e?t:new e(t)}))),this.value=t,this.params=i};function ya(e,t,i){return function(e,t,i,r){return new Error("failed to "+e+' "'+(n=t,(Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":"object"==typeof n?JSON.stringify(n):String(n))+'" as ')+i,{cause:r});var n}("serialize",e,t,i)}var Ta=function(e){this.description=e},Ea="Bare Item";function Sa(e){if(function(e){return e<-999999999999999||99999999999999912)throw ya(e,"Decimal");var i=t.toString();return i.includes(".")?i:i+".0"}var Ra=/[\x00-\x1f\x7f]+/;function ka(e){var t,i=(t=e).description||t.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw ya(i,"Token");return i}function ba(e){switch(typeof e){case"number":if(!S(e))throw ya(e,Ea);return Number.isInteger(e)?Sa(e):Aa(e);case"string":return function(e){if(Ra.test(e))throw ya(e,"String");return'"'+e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}(e);case"symbol":return ka(e);case"boolean":return function(e){if("boolean"!=typeof e)throw ya(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return"@"+Sa(e.getTime()/1e3)}(e);if(e instanceof Uint8Array)return function(e){if(!1===ArrayBuffer.isView(e))throw ya(e,"Byte Sequence");return":"+(t=e,btoa(String.fromCharCode.apply(String,t))+":");var t}(e);if(e instanceof Ta)return ka(e);default:throw ya(e,Ea)}}function Ia(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw ya(e,"Key");return e}function Da(e){return null==e?"":Object.entries(e).map((function(e){var t=e[0],i=e[1];return!0===i?";"+Ia(t):";"+Ia(t)+"="+ba(i)})).join("")}function _a(e){return e instanceof pa?""+ba(e.value)+Da(e.params):ba(e)}var Ca=function(e){return Math.round(e)},Pa=function(e){return 100*Ca(e/100)},wa={br:Ca,d:Ca,bl:Pa,dl:Pa,mtp:Pa,nor:function(e,t){return(null==t?void 0:t.baseUrl)&&(e=function(e,t){var i=new URL(e),r=new URL(t);if(i.origin!==r.origin)return e;for(var n=i.pathname.split("/").slice(1),a=r.pathname.split("/").slice(1,-1);n[0]===a[0];)n.shift(),a.shift();for(;a.length;)a.shift(),n.unshift("..");return n.join("/")}(e,t.baseUrl)),encodeURIComponent(e)},rtp:Pa,tb:Ca};function xa(e,t){return void 0===t&&(t={}),e?function(e,t){return function(e,t){if(void 0===t&&(t={whitespace:!0}),"object"!=typeof e)throw ya(e,"Dict");var i=e instanceof Map?e.entries():Object.entries(e),r=(null==t?void 0:t.whitespace)?" ":"";return Array.from(i).map((function(e){var t=e[0],i=e[1];i instanceof pa==0&&(i=new pa(i));var r,n=Ia(t);return!0===i.value?n+=Da(i.params):(n+="=",Array.isArray(i.value)?n+="("+(r=i).value.map(_a).join(" ")+")"+Da(r.params):n+=_a(i)),n})).join(","+r)}(e,t)}(function(e,t){var i={};if(null==e||"object"!=typeof e)return i;var r=Object.keys(e).sort(),n=a({},wa,null==t?void 0:t.formatters),s=null==t?void 0:t.filter;return r.forEach((function(r){if(!(null==s?void 0:s(r))){var a=e[r],o=n[r];o&&(a=o(a,t)),"v"===r&&1===a||"pr"==r&&1===a||function(e){return"number"==typeof e?S(e):null!=e&&""!==e&&!1!==e}(a)&&(function(e){return"ot"===e||"sf"===e||"st"===e}(r)&&"string"==typeof a&&(a=new Ta(a)),i[r]=a)}})),i}(e,t),a({whitespace:!1},t)):""}var Oa=/CMCD=[^&#]+/;var Ma=function(){function e(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.includeKeys=void 0,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(e){try{t.apply(e,{ot:sa,su:!t.initialized})}catch(e){t.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=function(e){try{var i=e.frag,r=e.part,n=t.hls.levels[i.level],a=t.getObjectType(i),s={d:1e3*(r||i).duration,ot:a};a!==la&&a!==oa&&a!=ua||(s.br=n.bitrate/1e3,s.tb=t.getTopBandwidth(a)/1e3,s.bl=t.getBufferLength(a));var o=r?t.getNextPart(r):t.getNextFrag(i);null!=o&&o.url&&o.url!==i.url&&(s.nor=o.url),t.apply(e,s)}catch(e){t.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=e;var i=this.config=e.config,r=i.cmcd;null!=r&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||e.sessionId,this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}var i=e.prototype;return i.registerListeners=function(){var e=this.hls;e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHED,this.onMediaDetached,this),e.on(b.BUFFER_CREATED,this.onBufferCreated,this)},i.unregisterListeners=function(){var e=this.hls;e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHED,this.onMediaDetached,this),e.off(b.BUFFER_CREATED,this.onBufferCreated,this)},i.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null},i.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},i.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},i.onBufferCreated=function(e,t){var i,r;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(r=t.tracks.video)?void 0:r.buffer},i.createData=function(){var e;return{v:1,sf:ca,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},i.apply=function(e,t){void 0===t&&(t={}),a(t,this.createData());var i=t.ot===da||t.ot===la||t.ot===ua;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var r=this.includeKeys;r&&(t=Object.keys(t).reduce((function(e,i){return r.includes(i)&&(e[i]=t[i]),e}),{}));var n={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),function(e,t,i){a(e,function(e,t){void 0===t&&(t={});var i={};if(!e)return i;var r=Object.entries(e),n=Object.entries(ma).concat(Object.entries((null==t?void 0:t.customHeaderMap)||{})),a=r.reduce((function(e,t){var i,r,a=t[0],s=t[1],o=(null===(i=n.find((function(e){return e[1].includes(a)})))||void 0===i?void 0:i[0])||fa;return null!==(r=e[o])&&void 0!==r||(e[o]={}),e[o][a]=s,e}),{});return Object.entries(a).reduce((function(e,i){var r=i[0],n=i[1];return e[r]=xa(n,t),e}),i)}(t,i))}(e.headers,t,n)):e.url=function(e,t,i){var r=function(e,t){if(void 0===t&&(t={}),!e)return"";var i=xa(e,t);return"CMCD="+encodeURIComponent(i)}(t,i);if(!r)return e;if(Oa.test(e))return e.replace(Oa,r);var n=e.includes("?")?"&":"?";return""+e+n+r}(e.url,t,n)},i.getNextFrag=function(e){var t,i=null==(t=this.hls.levels[e.level])?void 0:t.details;if(i){var r=e.sn-i.startSN;return i.fragments[r+1]}},i.getNextPart=function(e){var t,i,r=e.index,n=e.fragment,a=null==(t=this.hls.levels[n.level])||null==(i=t.details)?void 0:i.partList;if(a)for(var s=n.sn,o=a.length-1;o>=0;o--){var l=a[o];if(l.index===r&&l.fragment.sn===s)return a[o+1]}},i.getObjectType=function(e){var t=e.type;return"subtitle"===t?ha:"initSegment"===e.sn?da:"audio"===t?oa:"main"===t?this.hls.audioTracks.length?la:ua:void 0},i.getTopBandwidth=function(e){var t,i=0,r=this.hls;if(e===oa)t=r.audioTracks;else{var n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;t=r.levels.slice(0,a)}return t.forEach((function(e){e.bitrate>i&&(i=e.bitrate)})),i>0?i:NaN},i.getBufferLength=function(e){var t=this.media,i=e===oa?this.audioBuffer:this.videoBuffer;return i&&t?1e3*Kt.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN},i.createPlaylistLoader=function(){var e=this.config.pLoader,i=this.applyPlaylistData,r=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new r(e)}var n=e.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(e,t,r){i(e),this.loader.load(e,t,r)},t(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}])}()},i.createFragmentLoader=function(){var e=this.config.fLoader,i=this.applyFragmentData,r=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new r(e)}var n=e.prototype;return n.destroy=function(){this.loader.destroy()},n.abort=function(){this.loader.abort()},n.load=function(e,t,r){i(e),this.loader.load(e,t,r)},t(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}])}()},e}(),Fa=function(e){function i(t){var i;return(i=e.call(this,"content-steering",t.logger)||this).hls=void 0,i.loader=null,i.uri=null,i.pathwayId=".",i._pathwayPriority=null,i.timeToLoad=300,i.reloadTimer=-1,i.updated=0,i.started=!1,i.enabled=!0,i.levels=null,i.audioTracks=null,i.subtitleTracks=null,i.penalizedPathways={},i.hls=t,i.registerListeners(),i}o(i,e);var r=i.prototype;return r.registerListeners=function(){var e=this.hls;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.ERROR,this.onError,this))},r.pathways=function(){return(this.levels||[]).reduce((function(e,t){return-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e}),[])},r.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}},r.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},r.clearTimeout=function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},r.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},r.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter((function(t){return t!==e})))},r.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},r.onManifestLoaded=function(e,t){var i=t.contentSteering;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())},r.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},r.onError=function(e,t){var i=t.errorAction;if(2===(null==i?void 0:i.action)&&1===i.flags){var r=this.levels,n=this._pathwayPriority,a=this.pathwayId;if(t.context){var s=t.context,o=s.groupId,l=s.pathwayId,u=s.type;o&&r?a=this.getPathwayForGroupId(o,u,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&r&&(n=this.pathways()),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a),i.resolved||this.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+a+" levels: "+(r?r.length:r)+" priorities: "+Je(n)+" penalized: "+Je(this.penalizedPathways))}},r.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var i=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+i+'"'),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t},r.getLevelsForPathway=function(e){return null===this.levels?[]:this.levels.filter((function(t){return e===t.pathwayId}))},r.updatePathwayPriority=function(e){var t;this._pathwayPriority=e;var i=this.penalizedPathways,r=performance.now();Object.keys(i).forEach((function(e){r-i[e]>3e5&&delete i[e]}));for(var n=0;n0){this.log('Setting Pathway to "'+a+'"'),this.pathwayId=a,Yi(t),this.hls.trigger(b.LEVELS_UPDATED,{levels:t});var l=this.hls.levels[s];o&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate "+o.bitrate+" to "+l.bitrate),this.hls.nextLoadLevel=s);break}}}},r.getPathwayForGroupId=function(e,t,i){for(var r=this.getLevelsForPathway(i).concat(this.levels||[]),n=0;n tenc");s=new Uint8Array(d.subarray(8,24)),o=ni.FAIRPLAY}catch(e){return void r.warn(n+" Failed to parse sinf: "+e)}}else{if(l!==ni.WIDEVINE&&l!==ni.PLAYREADY)return void r.warn('Ignoring unexpected "'+e.type+'" event with init data type: "'+t+'" for selected key-system '+l);var h=function(e){var t=[];if(e instanceof ArrayBuffer)for(var i=e.byteLength,r=0;r+321&&r.warn(n+" Using first of "+c.length+" pssh found for selected key-system "+l);var f=c[0];if(!f)return void(0===h.length||h.some((function(e){return!e.systemId}))?r.warn(n+" contains incomplete or invalid pssh data"):r.log("ignoring "+n+" for "+h.map((function(e){return di(e.systemId)})).join(",")+" pssh data in favor of playlist keys"));if(o=di(f.systemId),0===f.version&&f.data)if(o===ni.WIDEVINE){var g=f.data.length-22;s=new Uint8Array(f.data.subarray(g,g+16))}else o===ni.PLAYREADY&&(s=vi(f.data))}if(o&&s){for(var v,m=q(s),p=r,y=p.keyIdToKeySessionPromise,T=p.mediaKeySessions,E=y[m],S=function(){var e=T[L],n=e.decryptdata;if(!n.keyId)return 0;var a=q(n.keyId);return m===a||-1!==n.uri.replace(/-/g,"").indexOf(m)?(E=y[a],n.pssh||(delete y[a],n.pssh=new Uint8Array(i),n.keyId=s,(E=y[m]=E.then((function(){return r.generateRequestWithPreferredKeySession(e,t,i,"encrypted-event-key-match")}))).catch((function(e){return r.handleError(e)}))),1):void 0},L=0;L0)for(var a,s=0,o=n.length;s in key message");return ii(atob(f))},i.setupLicenseXHR=function(e,t,i,r){var n=this,a=this.config.licenseXhrSetup;return a?Promise.resolve().then((function(){if(!i.decryptdata)throw new Error("Key removed");return a.call(n.hls,e,t,i,r)})).catch((function(s){if(!i.decryptdata)throw s;return e.open("POST",t,!0),a.call(n.hls,e,t,i,r)})).then((function(i){return e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:i||r}})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))},i.requestLicense=function(e,t){var i=this,r=this.config.keyLoadPolicy.default;return new Promise((function(n,a){var s=i.getLicenseServerUrlOrThrow(e.keySystem);i.log("Sending license request to URL: "+s);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!i.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(4===o.readyState)if(200===o.status){i._requestLicenseFailureCount=0;var l=o.response;i.log("License received "+(l instanceof ArrayBuffer?l.byteLength:l));var u=i.config.licenseResponseCallback;if(u)try{l=u.call(i.hls,o,s,e)}catch(e){i.error(e)}n(l)}else{var d=r.errorRetry,h=d?d.maxNumRetry:0;if(i._requestLicenseFailureCount++,i._requestLicenseFailureCount>h||o.status>=400&&o.status<500)a(new Va({type:R.KEY_SYSTEM_ERROR,details:k.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},"License Request XHR failed ("+s+"). Status: "+o.status+" ("+o.statusText+")"));else{var c=h-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=o,i.setupLicenseXHR(o,s,e,t).then((function(t){var r=t.xhr,n=t.licenseChallenge;e.keySystem==ni.PLAYREADY&&(n=i.unpackPlayReadyKeyMessage(r,n)),r.send(n)}))}))},i.onDestroying=function(){this.unregisterListeners(),this._clear()},i.onMediaAttached=function(e,t){if(this.config.emeEnabled){var i=t.media;this.media=i,Ua(i,"encrypted",this.onMediaEncrypted),Ua(i,"waitingforkey",this.onWaitingForKey)}},i.onMediaDetached=function(){var e=this.media;e&&(Ga(e,"encrypted",this.onMediaEncrypted),Ga(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)},i._clear=function(){var e,i=this;if(this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.mediaKeys||this.mediaKeySessions.length){var r=this.media,n=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,pi.clearKeyUriToKeyIdMap();var a=n.length;t.CDMCleanupPromise=Promise.all(n.map((function(e){return i.removeSession(e)})).concat(null==r||null==(e=r.setMediaKeys(null))?void 0:e.catch((function(e){var t;i.log("Could not clear media keys: "+e),null==(t=i.hls)||t.trigger(b.ERROR,{type:R.OTHER_ERROR,details:k.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error("Could not clear media keys: "+e)})})))).catch((function(e){var t;i.log("Could not close sessions and clear media keys: "+e),null==(t=i.hls)||t.trigger(b.ERROR,{type:R.OTHER_ERROR,details:k.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close sessions and clear media keys: "+e)})})).then((function(){a&&i.log("finished closing key sessions and clearing media keys")}))}},i.onManifestLoading=function(){this.keyFormatPromise=null},i.onManifestLoaded=function(e,t){var i=t.sessionKeys;if(i&&this.config.emeEnabled&&!this.keyFormatPromise){var r=i.reduce((function(e,t){return-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e}),[]);this.log("Selecting key-system from session-keys "+r.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(r)}},i.removeSession=function(e){var t=this,i=e.mediaKeysSession,r=e.licenseXhr;if(i){this.log("Remove licenses and keys and close session "+i.sessionId),e._onmessage&&(i.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(i.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var n=this.mediaKeySessions.indexOf(e);n>-1&&this.mediaKeySessions.splice(n,1);var a=function(e){var t;return"persistent-license"===e.sessionType||!(null==(t=e.sessionTypes)||!t.some((function(e){return"persistent-license"===e})))}(this.config.drmSystemOptions)?new Promise((function(e,t){self.setTimeout((function(){return t(new Error("MediaKeySession.remove() timeout"))}),8e3),i.remove().then(e)})):Promise.resolve();return a.catch((function(e){var i;t.log("Could not remove session: "+e),null==(i=t.hls)||i.trigger(b.ERROR,{type:R.OTHER_ERROR,details:k.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error("Could not remove session: "+e)})})).then((function(){return i.close()})).catch((function(e){var i;t.log("Could not close session: "+e),null==(i=t.hls)||i.trigger(b.ERROR,{type:R.OTHER_ERROR,details:k.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error("Could not close session: "+e)})}))}},t}(F);Ka.CDMCleanupPromise=void 0;var Va=function(e){function t(t,i){var r;return(r=e.call(this,i)||this).data=void 0,t.error||(t.error=new Error(i)),r.data=t,t.err=t.error,r}return o(t,e),t}(f(Error)),Ha=function(){function e(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 t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(b.MEDIA_DETACHING,this.onMediaDetaching,this)},t.unregisterListeners=function(){this.hls.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(b.MEDIA_DETACHING,this.onMediaDetaching,this)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&"function"==typeof r.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}},t.onMediaDetaching=function(){this.media=null},t.checkFPS=function(e,t,i){var r=performance.now();if(t){if(this.lastTime){var n=r-this.lastTime,a=i-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*a/n,l=this.hls;if(l.trigger(b.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:i}),o>0&&a>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(b.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=i,this.lastDecodedFrames=t}},t.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)},e}();function ja(e){for(var t=5381,i=e.length;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()}var Ya=.025,Wa=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function qa(e,t,i){return e.identifier+"-"+(i+1)+"-"+ja(t)}var Xa=function(){function e(e,t){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=t,this.dateRange=e,this.setDateRange(e)}var i=e.prototype;return i.setDateRange=function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)},i.reset=function(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)},i.isAssetPastPlayoutLimit=function(e){var t;if(e>0&&e>=this.assetList.length)return!0;var i=this.playoutLimit;return!(e<=0||isNaN(i))&&(0===i||((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>i)},i.findAssetIndex=function(e){return this.assetList.indexOf(e)},i.toString=function(){return'["'+(e=this).identifier+'" '+(e.cue.pre?"
":e.cue.post?"":"")+e.timelineStart.toFixed(2)+"-"+e.resumeTime.toFixed(2)+"]";var e},t(e,[{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return za(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"startIsAligned",get:function(){if(0===this.startTime||this.snapOptions.out)return!0;var e=this.dateRange.tagAnchor;if(e){var t=this.dateRange.startTime;return t-za(t,e)<.1}return!1}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=S(e)?e:this.duration;return this.cumulativeDuration+t}},{key:"resumeTime",get:function(){var e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){var t=this.resumeAnchor;if(t)return za(e,t)}return e}},{key:"appendInPlace",get:function(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)0||null!==this.assetListResponse}}])}();function za(e,t){return e-t.start=this._bufferedEosTime-.02},i.reachedPlayout=function(e){var t=this.interstitial.playoutLimit;return this.startOffset+e>=t},i.getAssetTime=function(e){var t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)},i.removeMediaListeners=function(){var e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))},i.bufferSnapShot=function(){var e;this.mediaAttached&&null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)},i.destroy=function(){this.removeMediaListeners(),this.hls.destroy(),this.hls=this.interstitial=null,this.tracks=this.mediaAttached=this.checkPlayout=null},i.attachMedia=function(e){this.hls.attachMedia(e)},i.detachMedia=function(){this.removeMediaListeners(),this.mediaAttached=null,this.hls.detachMedia()},i.resumeBuffering=function(){this.hls.resumeBuffering()},i.pauseBuffering=function(){this.hls.pauseBuffering()},i.transferMedia=function(){return this.bufferSnapShot(),this.hls.transferMedia()},i.resetDetails=function(){var e=this.hls;if(this.hasDetails){e.stopLoad();var t=function(e){return delete e.details};e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}},i.on=function(e,t,i){this.hls.on(e,t)},i.once=function(e,t,i){this.hls.once(e,t)},i.off=function(e,t,i){this.hls.off(e,t)},i.toString=function(){var e;return"HlsAssetPlayer: "+$a(this.assetItem)+" "+(null==(e=this.hls)?void 0:e.sessionId)+" "+(this.appendInPlace?"append-in-place":"")},t(e,[{key:"appendInPlace",get:function(){var e;return(null==(e=this.interstitial)?void 0:e.appendInPlace)||!1}},{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){var e;return(null==(e=this.hls)?void 0:e.media)||null}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;var t=Kt.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}},{key:"duration",get:function(){return this.assetItem.duration||0}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"startOffset",get:function(){return this.assetItem.startOffset}},{key:"timelineOffset",get:function(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0},set:function(e){var t=this.timelineOffset;if(e!==t){var i=e-t;if(Math.abs(i)>1/9e4){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}}])}(),es=function(e){function i(t,i){var r;return(r=e.call(this,"interstitials-sched",i)||this).onScheduleUpdate=void 0,r.eventMap={},r.events=null,r.items=null,r.durations={primary:0,playout:0,integrated:0},r.onScheduleUpdate=t,r}o(i,e);var r=i.prototype;return r.destroy=function(){this.reset(),this.onScheduleUpdate=null},r.reset=function(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach((function(e){return e.reset()})),this.events=this.items=null},r.resetErrorsInRange=function(e,t){return this.events?this.events.reduce((function(i,r){return e<=r.startOffset&&t>r.startOffset?(delete r.error,i+1):i}),0):0},r.getEvent=function(e){return e&&this.eventMap[e]||null},r.hasEvent=function(e){return e in this.eventMap},r.findItemIndex=function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);var r=this.items;if(r)for(r[i]||(void 0===t&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&null!=(n=r[i])&&n.event;){var n;i--}return i},r.findItemIndexAtTime=function(e,t){var i=this.items;if(i)for(var r=0;rn.start&&e1)for(var n=0;ns&&t.005||Math.abs(e.playout.end-r[t].playout.end)>.005})))&&(this.items=n,this.onScheduleUpdate(t,r))}},r.parseDateRanges=function(e,t,i){for(var r=[],n=Object.keys(e),a=0;a.033){var L=s,A=o;o+=S;var R=a;a+=S;var k={previousEvent:e[r-1]||null,nextEvent:t,start:L,end:L+S,playout:{start:R,end:a},integrated:{start:A,end:o}};i.push(k)}else S>0&&d&&(d.cumulativeDuration+=S,i[i.length-1].end=c)}u&&(y=p),t.timelineStart=p;var b=o;o+=g;var I=a;a+=f,i.push({event:t,start:p,end:y,playout:{start:I,end:a},integrated:{start:b,end:o}})}var D=t.resumeTime;s=u||D>n?n:D})),sYa?(this.log('"'+e.identifier+'" resumption '+r+" not aligned with estimated timeline end "+n),!1):t?!Object.keys(t).some((function(n){var a=t[n].details,s=a.edge;if(r>=s)return i.log('"'+e.identifier+'" resumption '+r+" past "+n+" playlist end "+s),!1;var o=dt(null,a.fragments,r);if(!o)return i.log('"'+e.identifier+'" resumption '+r+" does not align with any fragments in "+n+" playlist ("+a.fragStart+"-"+a.fragmentEnd+")"),!0;var l="audio"===n?.175:0;return!(Math.abs(o.start-r)=n.end){var a,s=r.schedule.findItemIndexAtTime(r.timelinePos);if(!r.isInterstitial(n)&&null!=(a=r.media)&&a.paused&&(r.shouldPlay=!1),!i){var o=r.findItemIndex(n);if(s>o){var l=r.schedule.findJumpRestrictedIndex(o+1,s);if(l>o)return void r.setSchedulePosition(l)}}r.setSchedulePosition(s)}else{var u=r.playingAsset;if(u){var d=u.timelineStart,h=u.duration||0;(i&&e=d+h)&&r.setScheduleToAssetAtTime(e,u)}else if(r.playingLastItem&&r.isInterstitial(n)){var c=n.event.assetList[0];c&&(r.endedItem=r.playingItem,r.playingItem=null,r.setScheduleToAssetAtTime(e,c))}}else r.checkBuffer()}}},r.onTimeupdate=function(){var e=r.currentTime;if(void 0!==e&&!r.playbackDisabled&&e>r.timelinePos){r.timelinePos=e,e>r.bufferedPos&&r.checkBuffer();var t=r.playingItem;if(t&&!r.playingLastItem){if(e>=t.end){r.timelinePos=t.end;var i=r.findItemIndex(t);r.setSchedulePosition(i+1)}var n=r.playingAsset;n&&e>=n.timelineStart+(n.duration||0)&&r.setScheduleToAssetAtTime(e,n)}}},r.onScheduleUpdate=function(e,t){var i=r.schedule,n=r.playingItem,a=i.events||[],s=i.items||[],o=i.durations,l=e.map((function(e){return e.identifier})),u=!(!a.length&&!l.length);(u||t)&&r.log("INTERSTITIALS_UPDATED ("+a.length+"): "+a+"\nSchedule: "+s.map((function(e){return ts(e)}))+" pos: "+r.timelinePos),l.length&&r.log("Removed events "+l),r.playerQueue.forEach((function(e){if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,i=e.timelineOffset-t;if(i)try{e.timelineOffset=t}catch(n){Math.abs(i)>Ya&&r.warn(n+' ("'+e.assetId+'" '+e.timelineOffset+"->"+t+")")}}}));var d=null;if(n){var h=r.updateItem(n,r.timelinePos);r.itemsMatch(n,h)&&(r.playingItem=h,r.waitingItem=r.endedItem=null,d=function(){return r.trimInPlace(h,n)})}else r.waitingItem=r.updateItem(r.waitingItem),r.endedItem=r.updateItem(r.endedItem);var c=r.bufferingItem;if(c){var f=r.updateItem(c,r.bufferedPos);r.itemsMatch(c,f)?(r.bufferingItem=f,d||(d=function(){return r.trimInPlace(f,c)})):c.event&&(r.bufferingItem=r.playingItem,r.clearInterstitial(c.event,null))}if(e.forEach((function(e){e.assetList.forEach((function(e){r.clearAssetPlayer(e.identifier,null)}))})),u||t){if(r.hls.trigger(b.INTERSTITIALS_UPDATED,{events:a.slice(0),schedule:s.slice(0),durations:o,removedIds:l}),r.isInterstitial(n)&&l.includes(n.event.identifier))return r.warn('Interstitial "'+n.event.identifier+'" removed while playing'),void r.primaryFallback(n.event);d&&d(),r.checkBuffer()}},r.hls=t,r.HlsPlayerClass=i,r.assetListLoader=new is(t),r.schedule=new es(r.onScheduleUpdate,t.logger),r.registerListeners(),r}o(i,e);var r=i.prototype;return r.registerListeners=function(){var e=this.hls;e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(b.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(b.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(b.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(b.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(b.BUFFER_APPENDED,this.onBufferAppended,this),e.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(b.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(b.MEDIA_ENDED,this.onMediaEnded,this),e.on(b.ERROR,this.onError,this),e.on(b.DESTROYING,this.onDestroying,this)},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(b.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(b.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(b.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(b.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(b.BUFFER_CODECS,this.onBufferCodecs,this),e.off(b.BUFFER_APPENDED,this.onBufferAppended,this),e.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(b.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(b.MEDIA_ENDED,this.onMediaEnded,this),e.off(b.ERROR,this.onError,this),e.off(b.DESTROYING,this.onDestroying,this))},r.startLoad=function(){this.resumeBuffering()},r.stopLoad=function(){this.pauseBuffering()},r.resumeBuffering=function(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()},r.pauseBuffering=function(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()},r.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.manager=null,this.hls=this.HlsPlayerClass=this.schedule=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null},r.onDestroying=function(){var e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)},r.removeMediaListeners=function(e){Ga(e,"play",this.onPlay),Ga(e,"pause",this.onPause),Ga(e,"seeking",this.onSeeking),Ga(e,"timeupdate",this.onTimeupdate)},r.onMediaAttaching=function(e,t){var i=this.media=t.media;Ua(i,"seeking",this.onSeeking),Ua(i,"timeupdate",this.onTimeupdate),Ua(i,"play",this.onPlay),Ua(i,"pause",this.onPause)},r.onMediaAttached=function(e,t){var i=this.effectivePlayingItem,r=this.detachedData;if(this.detachedData=null,null===i)this.checkStart();else if(!r){this.clearScheduleState();var n=this.findItemIndex(i);this.setSchedulePosition(n)}},r.clearScheduleState=function(){this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null},r.onMediaDetaching=function(e,t){var i=!!t.transferMedia,r=this.media;if(this.media=null,!i&&(r&&this.removeMediaListeners(r),this.detachedData)){var n=this.getBufferingPlayer();n&&(this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,n.detachMedia()),this.shouldPlay=!1}},r.isInterstitial=function(e){return!(null==e||!e.event)},r.retreiveMediaSource=function(e,t){var i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)},r.transferMediaFromPlayer=function(e,t){var i=e.interstitial.appendInPlace,r=e.media;if(i&&r===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&r)return void(this.detachedData={media:r});var n=e.transferMedia();this.log("transfer MediaSource from "+e+" "+Je(n)),this.detachedData=n}else t&&r&&(this.shouldPlay||(this.shouldPlay=!r.paused))},r.transferMediaTo=function(e,t){var i,r,n=this;if(e.media!==t){var a,s=null,o=this.hls,l=e!==o,u=l&&e.interstitial.appendInPlace,d=null==(i=this.detachedData)?void 0:i.mediaSource;if(o.media)u&&(s=o.transferMedia(),this.detachedData=s),a="Primary";else if(d){var h=this.getBufferingPlayer();h?(s=h.transferMedia(),a=""+h):a="detached MediaSource"}else a="detached media";if(!s)if(d)s=this.detachedData,this.log("using detachedData: MediaSource "+Je(s));else if(!this.detachedData||o.media===t){var c=this.playerQueue;c.length>1&&c.forEach((function(e){if(l&&e.interstitial.appendInPlace!==u){var t=e.interstitial;n.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&n.warn("Could not change append strategy for queued assets "+t)}})),this.hls.detachMedia(),this.detachedData={media:t}}var f=s&&"mediaSource"in s&&"closed"!==(null==(r=s.mediaSource)?void 0:r.readyState),g=f&&s?s:t;if(this.log((f?"transfering MediaSource":"attaching media")+" to "+(l?e:"Primary")+" from "+a),g===s){var v=l&&e.assetId===this.schedule.assetIdAtEnd;g.overrides={duration:this.schedule.duration,endOfStream:!l||v,cueRemoval:!l}}e.attachMedia(g)}},r.onInterstitialCueEnter=function(){this.onTimeupdate()},r.checkStart=function(){var e=this.schedule,t=e.events;if(t&&!this.playbackDisabled&&this.media){-1===this.bufferedPos&&(this.bufferedPos=0);var i=this.timelinePos,r=this.effectivePlayingItem;if(-1===i){var n=this.hls.startPosition;if(this.timelinePos=n,t.length&&t[0].cue.pre){var a=e.findEventIndex(t[0].identifier);this.setSchedulePosition(a)}else if(n>=0||!this.primaryLive){var s=this.timelinePos=n>0?n:0,o=e.findItemIndexAtTime(s);this.setSchedulePosition(o)}}else if(r&&!this.playingItem){var l=e.findItemIndex(r);this.setSchedulePosition(l)}}},r.advanceAfterAssetEnded=function(e,t,i){var r=Za(e,i);if(e.isAssetPastPlayoutLimit(r)){var n=this.schedule.items;if(n){var a=t+1;if(a>=n.length)return void this.setSchedulePosition(-1);var s=e.resumeTime;this.timelinePos=0?i[e]:null,n=this.playingItem,a=this.playingLastItem;if(this.isInterstitial(n)){var s,o=n.event,l=this.playingAsset,u=null==l?void 0:l.identifier,d=u?this.getAssetPlayer(u):null;if(d&&u&&(!this.eventItemsMatch(n,r)||void 0!==t&&u!==(null==(s=o.assetList)?void 0:s[t].identifier))){var h,c=o.findAssetIndex(l);this.log("INTERSTITIAL_ASSET_ENDED "+(c+1)+"/"+o.assetList.length+" "+$a(l)),this.endedAsset=l,this.playingAsset=null,this.hls.trigger(b.INTERSTITIAL_ASSET_ENDED,{asset:l,assetListIndex:c,event:o,schedule:i.slice(0),scheduleIndex:e,player:d}),this.retreiveMediaSource(u,r),!d.media||null!=(h=this.detachedData)&&h.mediaSource||d.detachMedia()}if(!this.eventItemsMatch(n,r)&&(this.endedItem=n,this.playingItem=null,this.log("INTERSTITIAL_ENDED "+o+" "+ts(n)),o.hasPlayed=!0,this.hls.trigger(b.INTERSTITIAL_ENDED,{event:o,schedule:i.slice(0),scheduleIndex:e}),o.cue.once)){this.updateSchedule();var f=this.schedule.items;if(r&&f){var g=this.schedule.findItemIndex(r);this.advanceSchedule(g,f,t,n,a)}return}}this.advanceSchedule(e,i,t,n,a)}},r.advanceSchedule=function(e,t,i,r,n){var a=this,s=e>=0?t[e]:null,o=this.primaryMedia,l=this.playerQueue;if(l.length&&l.forEach((function(t){var i=t.interstitial,r=a.schedule.findEventIndex(i.identifier);(re+1)&&a.clearInterstitial(i,s)})),this.isInterstitial(s)){this.timelinePos=Math.min(Math.max(this.timelinePos,s.start),s.end);var u=s.event;if(void 0===i){var d=Za(u,(i=this.schedule.findAssetIndex(u,this.timelinePos))-1);if(u.isAssetPastPlayoutLimit(d))return void this.advanceAfterAssetEnded(u,e,i);i=d}var h=this.waitingItem;this.assetsBuffered(s,o)||this.setBufferingItem(s);var c=this.preloadAssets(u,i);if(this.eventItemsMatch(s,h||r)||(this.waitingItem=s,this.log("INTERSTITIAL_STARTED "+ts(s)+" "+(u.appendInPlace?"append in place":"")),this.hls.trigger(b.INTERSTITIAL_STARTED,{event:u,schedule:t.slice(0),scheduleIndex:e})),!u.assetListLoaded)return void this.log("Waiting for ASSET-LIST to complete loading "+u);if(u.assetListLoader&&(u.assetListLoader.destroy(),u.assetListLoader=void 0),!o)return void this.log("Waiting for attachMedia to start Interstitial "+u);this.waitingItem=this.endedItem=null,this.playingItem=s;var f=u.assetList[i];if(!f){var g=t[e+1],v=this.media;return g&&v&&!this.isInterstitial(g)&&v.currentTime=e.end)&&(n=this.getPrimaryResumption(e,t),this.timelinePos=n),this.attachPrimary(n,e)}if(i){var a=this.schedule.items;a&&(this.log("INTERSTITIALS_PRIMARY_RESUMED "+ts(e)),this.hls.trigger(b.INTERSTITIALS_PRIMARY_RESUMED,{schedule:a.slice(0),scheduleIndex:t}),this.checkBuffer())}},r.getPrimaryResumption=function(e,t){var i=e.start;if(this.primaryLive){var r=this.primaryDetails;if(0===t)return this.hls.startPosition;if(r&&(ir.edge))return this.hls.liveSyncPosition||-1}return i},r.isAssetBuffered=function(e){var t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:Kt.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)},r.attachPrimary=function(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;var r=this.primaryMedia;if(r){var n=this.hls;n.media?this.checkBuffer():(this.transferMediaTo(n,r),i&&this.startLoadingPrimaryAt(e,i)),i||(this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}},r.startLoadingPrimaryAt=function(e,t){var i,r=this.hls;!r.loadingEnabled||!r.media||Math.abs(((null==(i=r.mainForwardBufferInfo)?void 0:i.start)||r.media.currentTime)-e)>.5?r.startLoad(e,t):r.bufferingEnabled||r.resumeBuffering()},r.onManifestLoading=function(){this.stopLoad(),this.schedule.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(b.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(b.BUFFER_CODECS,this.onBufferCodecs,this)},r.onLevelUpdated=function(e,t){if(-1!==t.level){var i=this.hls.levels[t.level],r=d(d({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=r,this.schedule.parseInterstitialDateRanges(r,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}},r.onAudioTrackUpdated=function(e,t){var i=this.hls.audioTracks[t.id],r=this.mediaSelection;if(r){var n=d(d({},r),{},{audio:i});this.mediaSelection=n}else this.altSelection=d(d({},this.altSelection),{},{audio:i})},r.onSubtitleTrackUpdated=function(e,t){var i=this.hls.subtitleTracks[t.id],r=this.mediaSelection;if(r){var n=d(d({},r),{},{subtitles:i});this.mediaSelection=n}else this.altSelection=d(d({},this.altSelection),{},{subtitles:i})},r.onAudioTrackSwitching=function(e,t){var i=it(t);this.playerQueue.forEach((function(e){return e.hls.setAudioOption(t)||e.hls.setAudioOption(i)}))},r.onSubtitleTrackSwitch=function(e,t){var i=it(t);this.playerQueue.forEach((function(e){return e.hls.setSubtitleOption(t)||-1!==t.id&&e.hls.setSubtitleOption(i)}))},r.onBufferCodecs=function(e,t){var i=t.tracks;i&&(this.requiredTracks=i)},r.onBufferAppended=function(e,t){this.checkBuffer()},r.onBufferFlushed=function(e,t){var i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){var r=this.timelinePos;this.bufferedPos=r,this.checkBuffer()}},r.onBufferedToEnd=function(e){var t=this.schedule.events;if(this.bufferedPos.25){e.event.assetList.forEach((function(t,r){e.event.isAssetPastPlayoutLimit(r)&&i.clearAssetPlayer(t.identifier,null)}));var r=e.end+.25,n=Kt.bufferInfo(this.primaryMedia,r,0);(n.end>r||(n.nextStart||0)>r)&&(this.attachPrimary(r,null),this.flushFrontBuffer(r))}},r.itemsMatch=function(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))},r.eventItemsMatch=function(e,t){var i;return!!t&&(e===t||e.event.identifier===(null==(i=t.event)?void 0:i.identifier))},r.findItemIndex=function(e,t){return e?this.schedule.findItemIndex(e,t):-1},r.updateSchedule=function(){var e=this.mediaSelection;e&&this.schedule.updateSchedule(e,[])},r.checkBuffer=function(e){var t=this.schedule.items;if(t){var i=Kt.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=i.len<1),this.updateBufferedPos(i.end,t,e)}},r.updateBufferedPos=function(e,t,i){var r=this.schedule,n=this.bufferingItem;if(!(this.bufferedPos>e))if(1===t.length&&this.itemsMatch(t[0],n))this.bufferedPos=e;else{var a=this.playingItem,s=this.findItemIndex(a),o=r.findItemIndexAtTime(e);if(this.bufferedPos=n.end||null!=(l=c.event)&&l.appendInPlace&&e+.01>=c.start)&&(o=h),h-s>1&&!1===(null==n||null==(u=n.event)?void 0:u.appendInPlace))return;if(this.bufferedPos=e,o>d&&o>s)this.bufferedToItem(c);else{var f=this.primaryDetails;this.primaryLive&&f&&e>f.edge-f.targetduration&&c.start0&&(s=Math.round(1e3*h)/1e3)}if(this.log("Load interstitial asset "+(t+1)+"/"+(i?1:r)+" "+e+(s?" live-start: "+d+" start-offset: "+s:"")),i)return this.createAsset(e,0,0,o,e.duration,i);var c=this.assetListLoader.loadAssetList(e,s);c&&(e.assetListLoader=c)}else if(!a&&r){for(var f=t;f1){var g=t.duration;g&&fl)&&(r.log('Interstitial asset "'+v+'" duration change '+l+" > "+o),t.duration=o,r.updateSchedule())}};y.on(b.LEVEL_UPDATED,(function(e,t){var i=t.details;return T(i)})),y.on(b.LEVEL_PTS_UPDATED,(function(e,t){var i=t.details;return T(i)}));var E=function(e,t){var i=r.getAssetPlayer(v);if(i&&t.tracks){i.off(b.BUFFER_CODECS,E),i.tracks=t.tracks;var n=r.primaryMedia;r.bufferingAsset===i.assetItem&&n&&!i.media&&r.bufferAssetPlayer(i,n)}};y.on(b.BUFFER_CODECS,E);var S=function(){var i,n=r.getAssetPlayer(v);if(r.log("buffered to end of asset "+n),n){var a=r.schedule.findEventIndex(e.identifier),s=null==(i=r.schedule.items)?void 0:i[a];if(r.isInterstitial(s)){var o=e.findAssetIndex(t),l=Za(e,o);if(e.isAssetPastPlayoutLimit(l)){var u,d=null==(u=r.schedule.items)?void 0:u[a+1];d&&r.bufferedToItem(d)}else r.bufferedToItem(s,l)}}};y.on(b.BUFFERED_TO_END,S);var L=function(t){return function(){if(r.getAssetPlayer(v)){r.shouldPlay=!0;var i=r.schedule.findEventIndex(e.identifier);r.advanceAfterAssetEnded(e,i,t)}}};return y.once(b.MEDIA_ENDED,L(i)),y.once(b.PLAYOUT_LIMIT_REACHED,L(1/0)),y.on(b.ERROR,(function(t,n){var a=r.getAssetPlayer(v);if(n.details!==k.BUFFER_STALLED_ERROR)r.handleAssetItemError(n,e,r.schedule.findEventIndex(e.identifier),i,"Asset player error "+n.error+" "+e);else if(null!=a&&a.media){var s=a.currentTime,o=a.duration-s;s&&e.appendInPlace&&o/a.media.playbackRate<.5?(r.log("Advancing buffer past end of asset "+v+" "+e+" at "+a.media.currentTime),S()):(r.warn("Stalled at "+s+" of "+(s+o)+" in asset "+v+" "+e),r.onTimeupdate(),r.checkBuffer(!0))}})),y.on(b.DESTROYING,(function(){if(r.getAssetPlayer(v)){var t=new Error("Asset player destroyed unexpectedly "+v),n={fatal:!0,type:R.OTHER_ERROR,details:k.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};r.handleAssetItemError(n,e,r.schedule.findEventIndex(e.identifier),i,t.message)}})),this.log("INTERSTITIAL_ASSET_PLAYER_CREATED "+$a(t)),this.hls.trigger(b.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:y}),y},r.clearInterstitial=function(e,t){var i=this;e.assetList.forEach((function(e){i.clearAssetPlayer(e.identifier,t)})),e.reset()},r.resetAssetPlayer=function(e){var t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log('reset asset player "'+e+'" after error');var i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}},r.clearAssetPlayer=function(e,t){var i=this.getAssetPlayerQueueIndex(e);if(-1!==i){this.log('clear asset player "'+e+'" toSegment: '+(t?ts(t):t));var r=this.playerQueue[i];this.transferMediaFromPlayer(r,t),this.playerQueue.splice(i,1),r.destroy()}},r.emptyPlayerQueue=function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]},r.startAssetPlayer=function(e,t,i,r,n){var a=e.interstitial,s=e.assetItem,o=e.assetId,l=a.assetList.length,u=this.playingAsset;this.endedAsset=null,this.playingAsset=s,u&&u.identifier===o||(u&&(this.clearAssetPlayer(u.identifier,i[r]),delete u.error),this.log("INTERSTITIAL_ASSET_STARTED "+(t+1)+"/"+l+" "+$a(s)),this.hls.trigger(b.INTERSTITIAL_ASSET_STARTED,{asset:s,assetListIndex:t,event:a,schedule:i.slice(0),scheduleIndex:r,player:e})),this.bufferAssetPlayer(e,n)},r.bufferAssetPlayer=function(e,t){var i,r,n=e.interstitial,a=e.assetItem,s=this.schedule.findEventIndex(n.identifier),o=null==(i=this.schedule.items)?void 0:i[s];if(o){this.setBufferingItem(o),this.bufferingAsset=a;var l=this.getBufferingPlayer();if(l!==e){var u=n.appendInPlace;if(!u||!1!==(null==l?void 0:l.interstitial.appendInPlace)){var d=(null==l?void 0:l.tracks)||(null==(r=this.detachedData)?void 0:r.tracks)||this.requiredTracks;if(u&&a!==this.playingAsset){if(!e.tracks)return;if(d&&!Y(d,e.tracks)){var h=new Error("Asset "+$a(a)+" SourceBuffer tracks ('"+Object.keys(e.tracks)+"') are not compatible with primary content tracks ('"+Object.keys(d)+"')"),c={fatal:!0,type:R.OTHER_ERROR,details:k.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},f=n.findAssetIndex(a);return void this.handleAssetItemError(c,n,s,f,h.message)}}this.transferMediaTo(e,t)}}}},r.handleAssetItemError=function(e,t,i,r,n){if(e.details!==k.BUFFER_STALLED_ERROR){var s=t.assetList[r];this.warn("INTERSTITIAL_ASSET_ERROR "+(s?$a(s):s)+" "+e.error);var o=null==s?void 0:s.identifier,l=this.getAssetPlayerQueueIndex(o),u=this.playerQueue[l]||null,d=this.schedule.items,h=a({},e,{fatal:!1,errorAction:Et(!0),asset:s,assetListIndex:r,event:t,schedule:d,scheduleIndex:i,player:u});if(this.hls.trigger(b.INTERSTITIAL_ASSET_ERROR,h),e.fatal){var c=this.playingAsset,f=new Error(n);if(s&&(this.clearAssetPlayer(o,null),s.error=f),t.assetList.some((function(e){return!e.error}))){if(t.appendInPlace){for(var g=r;g")+" error: "+e.error);var r=this.timelinePos;-1===r&&(r=this.hls.startPosition);var n=this.updateItem(i,r);this.itemsMatch(i,n)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t));var a=this.schedule.findItemIndexAtTime(r);this.setSchedulePosition(a)}else this.checkStart()},r.onAssetListLoaded=function(e,t){var i,r=this,n=t.event,a=n.identifier,s=t.assetListResponse.ASSETS;if(this.schedule.hasEvent(a)){var o=n.timelineStart,l=n.duration,u=0;s.forEach((function(e,t){var i=parseFloat(e.DURATION);r.createAsset(n,t,u,o+u,i,e.URI),u+=i})),n.duration=u,this.log("Loaded asset-list with duration: "+u+" (was: "+l+") "+n);var d=this.waitingItem,h=(null==d?void 0:d.event.identifier)===a;this.updateSchedule();var c=null==(i=this.bufferingItem)?void 0:i.event;if(h){var f,g=this.schedule.findEventIndex(a),v=null==(f=this.schedule.items)?void 0:f[g];if(v){if(!this.playingItem&&this.timelinePos>v.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==g)return n.error=new Error("Interstitial no longer within playback range "+this.timelinePos+" "+n),void this.primaryFallback(n);this.setBufferingItem(v)}this.setSchedulePosition(g)}else if((null==c?void 0:c.identifier)===a&&c.appendInPlace){var m=n.assetList[0],p=this.getAssetPlayer(m.identifier),y=this.primaryMedia;m&&p&&y&&this.bufferAssetPlayer(p,y)}}},r.onError=function(e,t){switch(t.details){case k.ASSET_LIST_PARSING_ERROR:case k.ASSET_LIST_LOAD_ERROR:case k.ASSET_LIST_LOAD_TIMEOUT:var i=t.interstitial;i&&this.primaryFallback(i);break;case k.BUFFER_STALLED_ERROR:this.onTimeupdate(),this.checkBuffer(!0)}},t(i,[{key:"interstitialsManager",get:function(){if(!this.manager){if(!this.hls)return null;var e=this,t=function(){return e.bufferingItem||e.waitingItem},i=function(t){return t?e.getAssetPlayer(t.identifier):t},r=function(t,r,a,s,o){if(t){var l=t[r].start,u=t.event;if(u){if("playout"===r||u.timelineOccupancy!==Wa.Point){var d=i(a);(null==d?void 0:d.interstitial)===u&&(l+=d.assetItem.startOffset+d[o])}}else l+=("bufferedPos"===s?n():e[s])-t.start;return l}return 0},n=function(){var t=e.bufferedPos;return t===Number.MAX_VALUE?a("primary"):Math.max(t,0)},a=function(t){var i;return null!=(i=e.primaryDetails)&&i.live?e.primaryDetails.edge:e.schedule.durations[t]},s=function(t,n){var a,s,o=e.effectivePlayingItem;if(null==o||null==(a=o.event)||!a.restrictions.skip){e.log("seek to "+t+' "'+n+'"');var l=e.effectivePlayingItem,u=e.schedule.findItemIndexAtTime(t,n),d=null==(s=e.schedule.items)?void 0:s[u],h=e.getBufferingPlayer(),c=null==h?void 0:h.interstitial,f=null==c?void 0:c.appendInPlace,g=l&&e.itemsMatch(l,d);if(l&&(f||g)){var v=i(e.playingAsset),m=(null==v?void 0:v.media)||e.primaryMedia;if(m){var p="primary"===n?m.currentTime:r(l,n,e.playingAsset,"timelinePos","currentTime"),y=t-p,T=(f?p:m.currentTime)+y;if(T>=0&&(!v||f||T<=v.duration))return void(m.currentTime=T)}}if(d){var E=t;if("primary"!==n){var S=t-d[n].start;E=d.start+S}var L=!e.isInterstitial(d);if(e.isInterstitial(l)&&!l.event.appendInPlace||!L&&!d.event.appendInPlace){if(l){var A=e.findItemIndex(l);if(u>A){var R=e.schedule.findJumpRestrictedIndex(A+1,u);if(R>A)return void e.setSchedulePosition(R)}var k=0;if(L)e.timelinePos=E,e.checkBuffer();else{var b,I=null==d||null==(b=d.event)?void 0:b.assetList;if(I)for(var D=t-(d[n]||d).start,_=I.length;_--;){var C=I[_];if(C.duration&&D>=C.startOffset&&D0?t:0},set currentTime(e){s(e,"primary")},get duration(){return a("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return r(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return r(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){s(e,"integrated")},get duration(){return a("integrated")},get seekableStart(){var t;return function(t,i){if(0!==t&&e.schedule.length){var r,n=e.schedule.findItemIndexAtTime(t),a=null==(r=e.schedule.items)?void 0:r[n];if(a)return t+(a[i].start-a.start)}return t}((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:function(){var t=e.effectivePlayingItem,i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){var r=e.findItemIndex(t);if(i.appendInPlace){var n=t.playout.start+t.event.duration;s(n+.001,"playout")}else e.advanceAfterAssetEnded(i,r,1/0)}}}}return this.manager}},{key:"effectivePlayingItem",get:function(){return this.waitingItem||this.playingItem||this.endedItem}},{key:"effectivePlayingAsset",get:function(){return this.playingAsset||this.endedAsset}},{key:"playingLastItem",get:function(){var e,t=this.playingItem,i=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&i)&&this.findItemIndex(t)===i.length-1}},{key:"playbackStarted",get:function(){return null!==this.effectivePlayingItem}},{key:"currentTime",get:function(){var e,t,i;if(null!==this.mediaSelection){var r=this.waitingItem||this.playingItem;if(!this.isInterstitial(r)||r.event.appendInPlace){var n=this.media;!n&&null!=(e=this.bufferingItem)&&null!=(t=e.event)&&t.appendInPlace&&(n=this.primaryMedia);var a=null==(i=n)?void 0:i.currentTime;if(void 0!==a&&S(a))return a}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"playbackDisabled",get:function(){return!1===this.hls.config.enableInterstitialPlayback}},{key:"primaryDetails",get:function(){var e,t;return null==(e=this.mediaSelection)||null==(t=e.main)?void 0:t.details}},{key:"primaryLive",get:function(){var e;return!(null==(e=this.primaryDetails)||!e.live)}}])}(F),as=function(e){function i(t,i,r){var n;return(n=e.call(this,t,i,r,"subtitle-stream-controller",x)||this).currentTrackId=-1,n.tracksBuffered=[],n.mainDetails=null,n.registerListeners(),n}o(i,e);var r=i.prototype;return r.onHandlerDestroying=function(){this.unregisterListeners(),e.prototype.onHandlerDestroying.call(this),this.mainDetails=null},r.registerListeners=function(){e.prototype.registerListeners.call(this);var t=this.hls;t.on(b.LEVEL_LOADED,this.onLevelLoaded,this),t.on(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(b.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this)},r.unregisterListeners=function(){e.prototype.unregisterListeners.call(this);var t=this.hls;t.off(b.LEVEL_LOADED,this.onLevelLoaded,this),t.off(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(b.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(b.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(b.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this)},r.startLoad=function(e,t){this.stopLoad(),this.state=$i,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()},r.onManifestLoading=function(){e.prototype.onManifestLoading.call(this),this.mainDetails=null},r.onMediaDetaching=function(t,i){this.tracksBuffered=[],e.prototype.onMediaDetaching.call(this,t,i)},r.onLevelLoaded=function(e,t){this.mainDetails=t.details},r.onSubtitleFragProcessed=function(e,t){var i=t.frag,r=t.success;if(J(i)&&(this.fragPrevious=i),this.state=$i,r){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var a,s=i.start,o=0;o=n[o].start&&s<=n[o].end){a=n[o];break}var l=i.start+i.duration;a?a.end=l:(a={start:s,end:l},n.push(a)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}}},r.onBufferFlushing=function(e,t){var i=t.startOffset,r=t.endOffset;if(0===i&&r!==Number.POSITIVE_INFINITY){var n=r-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach((function(e){for(var t=0;t=n.length)&&o){if(this.log("Subtitle track "+s+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+",duration:"+a.totalduration),this.mediaBuffer=this.mediaBufferTimeRanges,a.live||null!=(i=o.details)&&i.live){var l=this.mainDetails;if(a.deltaUpdateFailed||!l)return;var u,d=l.fragments[0];o.details?0===this.alignPlaylists(a,o.details,null==(u=this.levelLastLoaded)?void 0:u.details)&&d&&Gi(a,d.start):a.hasProgramDateTime&&l.hasProgramDateTime?(Qi(a,l),a.fragmentStart):d&&Gi(a,d.start)}o.details=a,this.levelLastLoaded=o,s===r&&(this.hls.trigger(b.SUBTITLE_TRACK_UPDATED,{details:a,id:s,groupId:t.groupId}),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===$i&&(dt(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)))}}else this.warn("Subtitle tracks were reset while loading level "+s)},r._handleFragmentLoadComplete=function(e){var t=this,i=e.frag,r=e.payload,n=i.decryptdata,a=this.hls;if(!this.fragContextChanged(i)&&r&&r.byteLength>0&&null!=n&&n.key&&n.iv&&Jt(n.method)){var s=performance.now();this.decrypter.decrypt(new Uint8Array(r),n.key.buffer,n.iv.buffer,ei(n.method)).catch((function(e){throw a.trigger(b.ERROR,{type:R.MEDIA_ERROR,details:k.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e})).then((function(e){var t=performance.now();a.trigger(b.FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:s,tdecrypt:t}})})).catch((function(e){t.warn(e.name+": "+e.message),t.state=$i}))}},r.doTick=function(){if(this.media){if(this.state===$i){var e=this.currentTrackId,t=this.levels,i=null==t?void 0:t[e];if(!i||!t.length||!i.details)return;if(this.waitForLive(i))return;var r=this.config,n=this.getLoadPosition(),a=Kt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),s=a.end,o=a.len,l=i.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;var u=l.fragments,d=u.length,h=l.edge,c=null,f=this.fragPrevious;if(sh-g?0:g;!(c=dt(f,u,Math.max(u[0].start,s),v))&&f&&f.start>>=0)>r-1)throw new DOMException("Failed to execute '"+t+"' on 'TimeRanges': The index provided ("+i+") is greater than the maximum bound ("+r+")");return e[i][t]};this.buffered={get length(){return e.length},end:function(i){return t("end",i,e.length)},start:function(i){return t("start",i,e.length)}}};function os(e,t){var i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function ls(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(i){H.debug("[texttrack-utils]: "+i);try{var r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){H.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+e)}}"disabled"===i&&(e.mode=i)}function us(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)t&&e.cues[r].removeEventListener("enter",t),e.removeCue(e.cues[r]);"disabled"===i&&(e.mode=i)}function ds(e,t,i,r){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=function(e,t,i){var r=[],n=function(e,t){if(t<=e[0].startTime)return 0;var i=e.length-1;if(t>e[i].endTime)return-1;for(var r,n=0,a=i;n<=a;)if(te[r].startTime&&n-1)for(var a=n,s=e.length;a=t&&o.endTime<=i)r.push(o);else if(o.startTime>i)return r}return r}(e.cues,t,i),s=0;s-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))},r.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)},r.onMediaDetaching=function(e,t){var i=this.media;if(i){var r=!!t.transferMedia;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,r||hs(i.textTracks).forEach((function(e){us(e)}))}},r.onManifestLoading=function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},r.onManifestParsed=function(e,t){this.tracks=t.subtitleTracks},r.onSubtitleTrackLoaded=function(e,t){var i=t.id,r=t.groupId,n=t.details,a=this.tracksInGroup[i];if(a&&a.groupId===r){var s=a.details;a.details=t.details,this.log("Subtitle track "+i+' "'+a.name+'" lang:'+a.lang+" group:"+r+" loaded ["+n.startSN+"-"+n.endSN+"]"),i===this.trackId&&this.playlistLoaded(i,t,s)}else this.warn("Subtitle track with id:"+i+" and group:"+r+" not found in active group "+(null==a?void 0:a.groupId))},r.onLevelLoading=function(e,t){this.switchLevel(t.level)},r.onLevelSwitching=function(e,t){this.switchLevel(t.level)},r.switchLevel=function(e){var t=this.hls.levels[e];if(t){var i=t.subtitleGroups||null,r=this.groupIds,n=this.currentTrack;if(!i||(null==r?void 0:r.length)!==(null==i?void 0:i.length)||null!=i&&i.some((function(e){return-1===(null==r?void 0:r.indexOf(e))}))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var a=this.tracks.filter((function(e){return!i||-1!==i.indexOf(e.groupId)}));if(a.length)this.selectDefaultTrack&&!a.some((function(e){return e.default}))&&(this.selectDefaultTrack=!1),a.forEach((function(e,t){e.id=t}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;var s=this.hls.config.subtitlePreference;if(!n&&s){this.selectDefaultTrack=!1;var o=rt(s,a);if(o>-1)n=a[o];else{var l=rt(s,this.tracks);n=this.tracks[l]}}var u=this.findTrackId(n);-1===u&&n&&(u=this.findTrackId(null));var d={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+(null==i?void 0:i.join(","))+'" group-id'),this.hls.trigger(b.SUBTITLE_TRACKS_UPDATED,d),-1!==u&&-1===this.trackId&&this.setSubtitleTrack(u)}}},r.findTrackId=function(e){for(var t=this.tracksInGroup,i=this.selectDefaultTrack,r=0;r-1){var n=this.tracksInGroup[r];return this.setSubtitleTrack(r),n}if(i)return null;var a=rt(e,t);if(a>-1)return t[a]}}return null},r.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,t)},r.loadingPlaylist=function(t,i){e.prototype.loadingPlaylist.call(this,t,i);var r=t.id,n=t.groupId,a=this.getUrlWithDirectives(t.url,i),s=t.details,o=null==s?void 0:s.age;this.log("Loading subtitle "+r+' "'+t.name+'" lang:'+t.lang+" group:"+n+(void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:"")+(o&&s.live?" age "+o.toFixed(1)+(s.type&&" "+s.type||""):"")+" "+a),this.hls.trigger(b.SUBTITLE_TRACK_LOADING,{url:a,id:r,groupId:n,deliveryDirectives:i||null,track:t})},r.toggleTrackModes=function(){var e=this.media;if(e){var t,i=hs(e.textTracks),r=this.currentTrack;if(r&&((t=i.filter((function(e){return zn(r,e)}))[0])||this.warn('Unable to find subtitle TextTrack with name "'+r.name+'" and language "'+r.lang+'"')),[].slice.call(i).forEach((function(e){"disabled"!==e.mode&&e!==t&&(e.mode="disabled")})),t){var n=this.subtitleDisplay?"showing":"hidden";t.mode!==n&&(t.mode=n)}}},r.setSubtitleTrack=function(e){var t=this.tracksInGroup;if(this.media)if(e<-1||e>=t.length||!S(e))this.warn("Invalid subtitle track id: "+e);else{this.selectDefaultTrack=!1;var i=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),r){var n=!!r.details&&!r.details.live;if(e!==this.trackId||r!==i||!n){this.log("Switching to subtitle-track "+e+(r?' "'+r.name+'" lang:'+r.lang+" group:"+r.groupId:""));var a=r.id,s=r.groupId,o=void 0===s?"":s,l=r.name,u=r.type,d=r.url;this.hls.trigger(b.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:u,url:d});var h=this.switchParams(r.url,null==i?void 0:i.details,r.details);this.loadPlaylist(h)}}else this.hls.trigger(b.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e},t(i,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}}])}(Wn),fs={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},gs=function(e){return String.fromCharCode(fs[e]||e)},vs=15,ms=100,ps={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},ys={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Ts={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Es={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ss=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Ls=function(){function e(){this.time=null,this.verboseLevel=0}return e.prototype.log=function(e,t){if(this.verboseLevel>=e){var i="function"==typeof t?t():t;H.log(this.time+" ["+e+"] "+i)}},e}(),As=function(e){for(var t=[],i=0;ims&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ms)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i=144&&this.backSpace();var i=gs(e);this.pos>=ms?this.logger.log(0,(function(){return"Cannot insert "+e.toString(16)+" ("+i+") at position "+t.pos+". Skipping it!"})):(this.chars[this.pos].setChar(i,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i},t.getTextAndFormat=function(){return this.rows},e}(),Ds=function(){function e(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 Is(i),this.nonDisplayedMemory=new Is(i),this.lastOutputScreen=new Is(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}var t=e.prototype;return t.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},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,(function(){return"MODE="+e})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=this,i=0;i=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(2,"MIDROW: "+Je(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||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))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}(),_s=function(){function e(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var r=this.logger=new Ls;this.channels=[null,new Ds(e,t,r),new Ds(e+1,i,r)]}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var i=this;this.logger.time=e;for(var r=function(e){var r=127&t[e],n=127&t[e+1],a=!1,s=null;if(0===r&&0===n)return 0;i.logger.log(3,(function(){return"["+As([t[e],t[e+1]])+"] -> ("+As([r,n])+")"}));var o=i.cmdHistory;if(r>=16&&r<=31){if(function(e,t,i){return i.a===e&&i.b===t}(r,n,o))return Cs(null,null,o),i.logger.log(3,(function(){return"Repeated command ("+As([r,n])+") is dropped"})),0;Cs(r,n,i.cmdHistory),(a=i.parseCmd(r,n))||(a=i.parseMidrow(r,n)),a||(a=i.parsePAC(r,n)),a||(a=i.parseBackgroundAttributes(r,n))}else Cs(null,null,o);if(!a&&(s=i.parseChars(r,n))){var l=i.currentChannel;l&&l>0?i.channels[l].insertChars(s):i.logger.log(2,"No channel found yet. TEXT-MODE?")}a||s||i.logger.log(2,(function(){return"Couldn't parse cleaned data "+As([r,n])+" orig: "+As([t[e],t[e+1]])}))},n=0;n=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;var i=20===e||21===e||23===e?1:2,r=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?r.ccRCL():33===t?r.ccBS():34===t?r.ccAOF():35===t?r.ccAON():36===t?r.ccDER():37===t?r.ccRU(2):38===t?r.ccRU(3):39===t?r.ccRU(4):40===t?r.ccFON():41===t?r.ccRDC():42===t?r.ccTR():43===t?r.ccRTD():44===t?r.ccEDM():45===t?r.ccCR():46===t?r.ccENM():47===t&&r.ccEOC():r.ccTO(t-32),this.currentChannel=i,!0},t.parseMidrow=function(e,t){var i=0;if((17===e||25===e)&&t>=32&&t<=47){if((i=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var r=this.channels[i];return!!r&&(r.ccMIDROW(t),this.logger.log(3,(function(){return"MIDROW ("+As([e,t])+")"})),!0)}return!1},t.parsePAC=function(e,t){var i;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;var r=e<=23?1:2;i=t>=64&&t<=95?1===r?ps[e]:Ts[e]:1===r?ys[e]:Es[e];var n=this.channels[r];return!!n&&(n.setPAC(this.interpretPAC(i,t)),this.currentChannel=r,!0)},t.interpretPAC=function(e,t){var i,r={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,r.underline=!(1&~i),i<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(r.italics=!0,r.color="white"):r.indent=4*Math.floor((i-16)/2),r},t.parseChars=function(e,t){var i,r,n=null,a=null;return e>=25?(i=2,a=e-8):(i=1,a=e),a>=17&&a<=19?(r=17===a?t+80:18===a?t+112:t+144,this.logger.log(2,(function(){return"Special char '"+gs(r)+"' in channel "+i})),n=[r]):e>=32&&e<=127&&(n=0===t?[e]:[e,t]),n&&this.logger.log(3,(function(){return"Char codes =  "+As(n).join(",")})),n},t.parseBackgroundAttributes=function(e,t){var i;if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;var r={};16===e||24===e?(i=Math.floor((t-32)/2),r.background=Ss[i],t%2==1&&(r.background=r.background+"_semi")):45===t?r.background="transparent":(r.foreground="black",47===t&&(r.underline=!0));var n=e<=23?1:2;return this.channels[n].setBkgData(r),!0},t.reset=function(){for(var e=0;e1?t-1:0),r=1;r100)throw new Error("Position must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return E},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return S},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");S=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return L},set:function(e){var t=r(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");L=t,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),ws=function(){function e(){}return e.prototype.decode=function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))},e}();function xs(e){function t(e,t,i,r){return 3600*(0|e)+60*(0|t)+(0|i)+parseFloat(r||0)}var i=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?t(i[2],i[3],0,i[4]):t(i[1],i[2],i[3],i[4]):null}var Os=function(){function e(){this.values=Object.create(null)}var t=e.prototype;return t.set=function(e,t){this.get(e)||""===t||(this.values[e]=t)},t.get=function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t},t.has=function(e){return e in this.values},t.alt=function(e,t,i){for(var r=0;r=0&&i<=100)return this.set(e,i),!0}return!1},e}();function Ms(e,t,i,r){var n=r?e.split(r):[e];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(i);2===s.length&&t(s[0],s[1])}}var Fs=new Ps(0,0,""),Ns="middle"===Fs.align?"middle":"center";function Bs(e,t,i){var r=e;function n(){var t=xs(e);if(null===t)throw new Error("Malformed timestamp: "+r);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=n(),a(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);e=e.slice(3),a(),t.endTime=n(),a(),function(e,t){var r=new Os;Ms(e,(function(e,t){var n;switch(e){case"region":for(var a=i.length-1;a>=0;a--)if(i[a].id===t){r.set(e,i[a].region);break}break;case"vertical":r.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),r.integer(e,n[0]),r.percent(e,n[0])&&r.set("snapToLines",!1),r.alt(e,n[0],["auto"]),2===n.length&&r.alt("lineAlign",n[1],["start",Ns,"end"]);break;case"position":n=t.split(","),r.percent(e,n[0]),2===n.length&&r.alt("positionAlign",n[1],["start",Ns,"end","line-left","line-right","auto"]);break;case"size":r.percent(e,t);break;case"align":r.alt(e,t,["start",Ns,"end","left","right"])}}),/:/,/\s/),t.region=r.get("region",null),t.vertical=r.get("vertical","");var n=r.get("line","auto");"auto"===n&&-1===Fs.line&&(n=-1),t.line=n,t.lineAlign=r.get("lineAlign","start"),t.snapToLines=r.get("snapToLines",!0),t.size=r.get("size",100),t.align=r.get("align",Ns);var a=r.get("position","auto");"auto"===a&&50===Fs.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function Us(e){return e.replace(//gi,"\n")}var Gs=function(){function e(){this.state="INITIAL",this.buffer="",this.decoder=new ws,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var t=e.prototype;return t.parse=function(e){var t=this;function i(){var e=t.buffer,i=0;for(e=Us(e);ie)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)},t.reset=function(){this.cueRanges=[],this.startTime=null},e}(),io=function(){function e(e){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,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}},e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(b.FRAG_LOADING,this.onFragLoading,this),e.on(b.FRAG_LOADED,this.onFragLoaded,this),e.on(b.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(b.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(b.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this)}var t=e.prototype;return t.destroy=function(){var e=this.hls;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(b.FRAG_LOADING,this.onFragLoading,this),e.off(b.FRAG_LOADED,this.onFragLoaded,this),e.off(b.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(b.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(b.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(b.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0},t.initCea608Parsers=function(){var e=new to(this,"textTrack1"),t=new to(this,"textTrack2"),i=new to(this,"textTrack3"),r=new to(this,"textTrack4");this.cea608Parser1=new _s(1,e,t),this.cea608Parser2=new _s(3,i,r)},t.addCues=function(e,t,i,r,n){for(var a,s,o,l,u=!1,d=n.length;d--;){var h=n[d],c=(a=h[0],s=h[1],o=t,l=i,Math.min(s,l)-Math.max(a,o));if(c>=0&&(h[0]=Math.min(h[0],t),h[1]=Math.max(h[1],i),u=!0,c/(i-t)>.5))return}if(u||n.push([t,i]),this.config.renderTextTracksNatively){var f=this.captionsTracks[e];this.Cues.newCue(f,t,i,r)}else{var g=this.Cues.newCue(null,t,i,r);this.hls.trigger(b.CUES_PARSED,{type:"captions",cues:g,track:e})}},t.onInitPtsFound=function(e,t){var i=this,r=t.frag,n=t.id,a=t.initPTS,s=t.timescale,o=this.unparsedVttFrags;n===P&&(this.initPTS[r.cc]={baseTime:a,timescale:s}),o.length&&(this.unparsedVttFrags=[],o.forEach((function(e){i.onFragLoaded(b.FRAG_LOADED,e)})))},t.getExistingTrack=function(e,t){var i=this.media;if(i)for(var r=0;r0&&c.push(e)},d.onparsingerror=function(e){u=e},d.onflush=function(){u?s(u):a(c)},h.forEach((function(e){if(p){if(Vs(e,"X-TIMESTAMP-MAP=")){p=!1,e.slice(16).split(",").forEach((function(e){Vs(e,"LOCAL:")?g=e.slice(6):Vs(e,"MPEGTS:")&&(v=parseInt(e.slice(7)))}));try{m=function(e){var t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(S(t)&&S(i)&&S(r)&&S(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*i,(t+=6e4*r)+36e5*n}(g)/1e3}catch(e){u=e}return}""===e&&(p=!1)}d.parse(e+"\n")})),d.flush()}(null!=(t=r.initSegment)&&t.data?Se(r.initSegment.data,new Uint8Array(n)).buffer:n,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,(function(e){i._appendCues(e,r.level),l.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})}),(function(t){var a="Missing initPTS for VTT MPEGTS"===t.message;a?s.push(e):i._fallbackToIMSC1(r,n),l.logger.log("Failed to parse VTT cue: "+t),a&&o>r.cc||l.trigger(b.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})}))}else s.push(e)},t._fallbackToIMSC1=function(e,t){var i=this,r=this.tracks[e.level];r.textCodec||Xs(t,this.initPTS[e.cc],(function(){r.textCodec=js,i._parseIMSC1(e,t)}),(function(){r.textCodec="wvtt"}))},t._appendCues=function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var r=this.textTracks[t];if(!r||"disabled"===r.mode)return;e.forEach((function(e){return ls(r,e)}))}else{var n=this.tracks[t];if(!n)return;var a=n.default?"default":"subtitles"+t;i.trigger(b.CUES_PARSED,{type:"subtitles",cues:e,track:a})}},t.onFragDecrypted=function(e,t){t.frag.type===x&&this.onFragLoaded(b.FRAG_LOADED,t)},t.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},t.onFragParsingUserdata=function(e,t){if(this.enabled&&this.config.enableCEA708Captions){var i=t.frag,r=t.samples;if(i.type!==P||"NONE"!==this.closedCaptionsForLevel(i))for(var n=0;n=16?o--:o++;var g=Us(l.trim()),v=Hs(t,i,g);null!=e&&null!=(c=e.cues)&&c.getCueById(v)||((a=new d(t,i,g)).id=v,a.line=h+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*o/32)),u.push(a))}return e&&u.length&&(u.sort((function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),u.forEach((function(t){return ls(e,t)}))),u}},oo=/(\d+)-(\d+)\/(\d+)/,lo=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||uo,this.controller=new self.AbortController,this.stats=new X}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},t.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,i){var r=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var s=function(e,t){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(a({},e.headers))};return e.rangeEnd&&i.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),i}(e,this.controller.signal),o="arraybuffer"===e.responseType,l=o?"byteLength":"length",u=t.loadPolicy,d=u.maxTimeToFirstByteMs,h=u.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),t.timeout=d&&S(d)?d:h,this.requestTimeout=self.setTimeout((function(){r.callbacks&&(r.abortInternal(),r.callbacks.onTimeout(n,e,r.response))}),t.timeout),(xn(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then((function(i){var a;r.response=r.loader=i;var s=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(r.requestTimeout),t.timeout=h,r.requestTimeout=self.setTimeout((function(){r.callbacks&&(r.abortInternal(),r.callbacks.onTimeout(n,e,r.response))}),h-(s-n.loading.start)),!i.ok){var l=i.status,u=i.statusText;throw new ho(u||"fetch, bad network response",l,i)}n.loading.first=s,n.total=function(e){var t=e.get("Content-Range");if(t){var i=function(e){var t=oo.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(S(i))return i}var r=e.get("Content-Length");if(r)return parseInt(r)}(i.headers)||n.total;var d=null==(a=r.callbacks)?void 0:a.onProgress;return d&&S(t.highWaterMark)?r.loadProgressively(i,n,e,t.highWaterMark,d):o?i.arrayBuffer():"json"===e.responseType?i.json():i.text()})).then((function(i){var a,s,o=r.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(r.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=i[l];u&&(n.loaded=n.total=u);var d={url:o.url,data:i,code:o.status},h=null==(a=r.callbacks)?void 0:a.onProgress;h&&!S(t.highWaterMark)&&h(n,e,i,o),null==(s=r.callbacks)||s.onSuccess(d,n,e,o)})).catch((function(t){var i;if(self.clearTimeout(r.requestTimeout),!n.aborted){var a=t&&t.code||0,s=t?t.message:null;null==(i=r.callbacks)||i.onError({code:a,text:s},e,t?t.details:null,n)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.response?this.response.headers.get(e):null},t.loadProgressively=function(e,t,i,r,n){void 0===r&&(r=0);var a=new hr,s=e.body.getReader(),o=function(){return s.read().then((function(s){if(s.done)return a.dataLength&&n(t,i,a.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return t.loaded+=u,u=r&&n(t,i,a.flush().buffer,e)):n(t,i,l.buffer,e),o()})).catch((function(){return Promise.reject()}))};return o()},e}();function uo(e,t){return new self.Request(e.url,t)}var ho=function(e){function t(t,i,r){var n;return(n=e.call(this,t)||this).code=void 0,n.details=void 0,n.code=i,n.details=r,n}return o(t,e),t}(f(Error)),co=/^age:\s*[\d.]+\s*$/im,fo=function(){function e(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=null,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new X,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()},t.loadInternal=function(){var e=this,t=this.config,i=this.context;if(t&&i){var r=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then((function(){if(e.loader===r&&!e.stats.aborted)return a(r,i.url)})).catch((function(t){if(e.loader===r&&!e.stats.aborted)return r.open("GET",i.url,!0),a(r,i.url)})).then((function(){e.loader!==r||e.stats.aborted||e.openAndSendXhr(r,i,t)})).catch((function(t){var a;null==(a=e.callbacks)||a.onError({code:r.status,text:t.message},i,r,n)})):this.openAndSendXhr(r,i,t)}},t.openAndSendXhr=function(e,t,i){e.readyState||e.open("GET",t.url,!0);var r=t.headers,n=i.loadPolicy,a=n.maxTimeToFirstByteMs,s=n.maxLoadTimeMs;if(r)for(var o in r)e.setRequestHeader(o,r[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=a&&S(a)?a:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()},t.readystatechange=function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var r=t.readyState,n=this.config;if(!i.aborted&&r>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===r)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var a=t.status,s="text"===t.responseType?t.responseText:null;if(a>=200&&a<300){var o=null!=s?s:t.response;if(null!=o){var l,u;i.loading.end=Math.max(self.performance.now(),i.loading.first);var d="arraybuffer"===t.responseType?o.byteLength:o.length;i.loaded=i.total=d,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first);var h=null==(l=this.callbacks)?void 0:l.onProgress;h&&h(i,e,o,t);var c={url:t.responseURL,data:o,code:a};return void(null==(u=this.callbacks)||u.onSuccess(c,i,e,t))}}var f,g=n.loadPolicy.errorRetry;yt(g,i.retry,!1,{url:e.url,data:void 0,code:a})?this.retry(g):(H.error(a+" while loading "+e.url),null==(f=this.callbacks)||f.onError({code:a,text:t.statusText},e,t,i))}}},t.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(yt(e,this.stats.retry,!0))this.retry(e);else{var t;H.warn("timeout while loading "+(null==(t=this.context)?void 0:t.url));var i=this.callbacks;i&&(this.abortInternal(),i.onTimeout(this.stats,this.context,this.loader))}}},t.retry=function(e){var t=this.context,i=this.stats;this.retryDelay=mt(e,i.retry),i.retry++,H.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==t?void 0:t.url)+", retrying "+i.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&co.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},t.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},e}(),go=d(d({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:fo,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:lt,bufferController:ta,capLevelController:aa,errorController:Tt,fpsController:Ha,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:gi,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:so,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:as,subtitleTrackController:cs,timelineController:io,audioStreamController:Yn,audioTrackController:Qn,emeController:Ka,cmcdController:Ma,contentSteeringController:Fa,interstitialsController:ns});function vo(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(vo):Object.keys(e).reduce((function(t,i){return t[i]=vo(e[i]),t}),{}):e}var mo=function(e){function i(t,i){var r;return(r=e.call(this,"gap-controller",t.logger)||this).hls=null,r.fragmentTracker=null,r.media=null,r.mediaSource=void 0,r.nudgeRetry=0,r.stallReported=!1,r.stalled=null,r.moved=!1,r.seeking=!1,r.buffered={},r.lastCurrentTime=0,r.ended=0,r.waiting=0,r.onMediaPlaying=function(){r.ended=0,r.waiting=0},r.onMediaWaiting=function(){var e;null!=(e=r.media)&&e.seeking||(r.waiting=self.performance.now(),r.tick())},r.onMediaEnded=function(){var e;r.hls&&(r.ended=(null==(e=r.media)?void 0:e.currentTime)||1,r.hls.trigger(b.MEDIA_ENDED,{stalled:!1}))},r.hls=t,r.fragmentTracker=i,r.registerListeners(),r}o(i,e);var r=i.prototype;return r.registerListeners=function(){var e=this.hls;e&&(e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.BUFFER_APPENDED,this.onBufferAppended,this))},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.BUFFER_APPENDED,this.onBufferAppended,this))},r.destroy=function(){e.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},r.onMediaAttached=function(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;var i=this.media=t.media;Ua(i,"playing",this.onMediaPlaying),Ua(i,"waiting",this.onMediaWaiting),Ua(i,"ended",this.onMediaEnded)},r.onMediaDetaching=function(e,t){this.clearInterval();var i=this.media;i&&(Ga(i,"playing",this.onMediaPlaying),Ga(i,"waiting",this.onMediaWaiting),Ga(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0},r.onBufferAppended=function(e,t){this.buffered=t.timeRanges},r.tick=function(){var e;if(null!=(e=this.media)&&e.readyState&&this.hasBuffered){var t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}},r.poll=function(e,t){var i,r,n=null==(i=this.hls)?void 0:i.config;if(n){var a=this.media;if(a){var s=a.seeking,o=this.seeking&&!s,l=!this.seeking&&s,u=a.paused&&!s||a.ended||0===a.playbackRate;if(this.seeking=s,e!==t)return t&&(this.ended=0),this.moved=!0,s||(this.nudgeRetry=0,n.nudgeOnVideoHole&&!u&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)o&&this.stallResolved(e);else{if(u)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&a.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(b.MEDIA_ENDED,{stalled:!1})));if(Kt.getBuffered(a).length){var d=Kt.bufferInfo(a,e,0),h=d.nextStart||0,c=this.fragmentTracker;if(s&&c&&this.hls){var f=po(this.hls.inFlightFragments,e),g=d.len>2,v=!h||f||h-e>2&&!c.getPartialFragment(e);if(g||v)return;this.moved=!1}var m=null==(r=this.hls)?void 0:r.latestLevelDetails;if(!this.moved&&null!==this.stalled&&c){if(!(d.len>0||h))return;var p=Math.max(h,d.start||0)-e,y=null!=m&&m.live?2*m.targetduration:2,T=c.getPartialFragment(e);if(p>0&&(p<=y||T))return void(a.paused||this._trySkipBufferHole(T))}var E=n.detectStallWithCurrentTimeMs,S=self.performance.now(),L=this.waiting,A=this.stalled;if(null===A){if(!(L>0&&S-L=E||L)&&this.hls){var k;if("ended"===(null==(k=this.mediaSource)?void 0:k.readyState)&&(null==m||!m.live)&&Math.abs(e-((null==m?void 0:m.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(b.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}var I=Kt.bufferInfo(a,e,n.maxBufferHole);this._tryFixBufferStall(I,R,e)}else this.nudgeRetry=0}}}},r.stallResolved=function(e){var t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){var i=self.performance.now()-t;this.log("playback not stuck anymore @"+e+", after "+Math.round(i)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger(b.STALL_RESOLVED,{})}},r.nudgeOnVideoHole=function(e,t){var i,r=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(i=this.buffered.audio)&&i.length&&r&&r.length>1&&e>r.end(0)){var n=Kt.bufferedInfo(Kt.timeRangesToArray(this.buffered.audio),e,0);if(n.len>1&&t>=n.start){var a=Kt.timeRangesToArray(r),s=Kt.bufferedInfo(a,t,0).bufferedIndex;if(s>-1&&ss)&&u-l<1&&e-l<2){var d=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+e+" hole: "+l+" -> "+u+" buffered index: "+o);this.warn(d.message),this.media.currentTime+=1e-6;var h=this.fragmentTracker.getPartialFragment(e)||void 0,c=Kt.bufferInfo(this.media,e,0);this.hls.trigger(b.ERROR,{type:R.MEDIA_ERROR,details:k.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:d,reason:d.message,frag:h,buffer:c.len,bufferInfo:c})}}}}},r._tryFixBufferStall=function(e,t,i){var r,n,a=this.fragmentTracker,s=this.media,o=null==(r=this.hls)?void 0:r.config;if(s&&a&&o){var l=null==(n=this.hls)?void 0:n.latestLevelDetails,u=a.getPartialFragment(i);if((u||null!=l&&l.live&&i1&&e.len>o.maxBufferHole||e.nextStart&&(e.nextStart-i1e3*o.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}},r.adjacentTraversal=function(e,t){var i=this.fragmentTracker,r=e.nextStart;if(i&&r){var n=i.getFragAtPos(t,P),a=i.getFragAtPos(r,P);if(n&&a)return a.sn-n.sn<2}return!1},r._reportStall=function(e){var t=this.hls,i=this.media,r=this.stallReported,n=this.stalled;if(!r&&null!==n&&i&&t){this.stallReported=!0;var a=new Error("Playback stalling at @"+i.currentTime+" due to low buffer ("+Je(e)+")");this.warn(a.message),t.trigger(b.ERROR,{type:R.MEDIA_ERROR,details:k.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len,bufferInfo:e,stalled:{start:n}})}},r._trySkipBufferHole=function(e){var t,i=this.fragmentTracker,r=this.media,n=null==(t=this.hls)?void 0:t.config;if(!r||!i||!n)return 0;var a=r.currentTime,s=Kt.bufferInfo(r,a,0),o=a0&&s.len<1&&r.readyState<3,d=o-a;if(d>0&&(l||u)){if(d>n.maxBufferHole){var h=!1;if(0===a){var c=i.getAppendedFrag(0,P);c&&o0}}])}(Bt);function po(e,t){var i=yo(e.main);if(i&&i.start<=t)return i;var r=yo(e.audio);return r&&r.start<=t?r:null}function yo(e){if(!e)return null;switch(e.state){case $i:case Zi:case ar:case sr:return null}return e.frag}function To(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function Eo(e,t,i,r,n){var a=new e(t,i,"");try{a.value=r,n&&(a.type=n)}catch(s){a=new e(t,i,Je(n?d({type:n},r):r))}return a}var So=function(){var e=To();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}(),Lo=function(){function e(e){var t=this;this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.onEventCueEnter=function(){t.hls&&t.hls.trigger(b.EVENT_CUE_ENTER,{})},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null},t._registerListeners=function(){var e=this.hls;e.on(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(b.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(b.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(b.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(b.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this)},t.onMediaAttaching=function(e,t){var i;this.media=t.media,!1===(null==(i=t.overrides)?void 0:i.cueRemoval)&&(this.removeCues=!1)},t.onMediaAttached=function(){var e=this.hls.latestLevelDetails;e&&this.updateDateRangeCues(e)},t.onMediaDetaching=function(e,t){this.media=null,t.transferMedia||(this.id3Track&&(this.removeCues&&us(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},t.getID3Track=function(e){if(this.media){for(var t=0;tSo&&(h=So),h-d<=0&&(h=d+.25);for(var c=0;c.01&&this.updateDateRangeCues(t.details)},t.updateDateRangeCues=function(e,t){var i=this;if(this.media&&e.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var r,n=this.id3Track,a=e.dateRanges,s=Object.keys(a),o=this.dateRangeCuesAppended;if(n&&t)if(null!=(r=n.cues)&&r.length)for(var l=Object.keys(o).filter((function(e){return!s.includes(e)})),u=function(){var e=l[d],t=o[e].cues;delete o[e],Object.keys(t).forEach((function(e){try{var r=t[e];r.removeEventListener("enter",i.onEventCueEnter),n.removeCue(r)}catch(e){}}))},d=l.length;d--;)u();else o=this.dateRangeCuesAppended={};var h=e.fragments[e.fragments.length-1];if(0!==s.length&&S(null==h?void 0:h.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var c=To(),f=function(){var e=s[g],t=a[e],r=t.startTime,n=o[e],l=(null==n?void 0:n.cues)||{},u=(null==n?void 0:n.durationKnown)||!1,d=So,h=t.duration;if(t.endDate&&null!==h)d=r+h,u=!0;else if(t.endOnNext&&!u){var f=s.reduce((function(e,i){if(i!==t.id){var r=a[i];if(r.class===t.class&&r.startDate>t.startDate&&(!e||t.startDate.01&&(E.startTime=r,E.endTime=d);else if(c){var S=t.attr[T];Qt(T)&&(v=S,S=Uint8Array.from(v.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);var L=Eo(c,r,d,{key:T,data:S},wr.dateRange);L&&(L.id=e,i.id3Track.addCue(L),l[T]=L,i.hls.config.interstitialsController&&("X-ASSET-LIST"!==T&&"X-ASSET-URL"!==T||L.addEventListener("enter",i.onEventCueEnter)))}}}o[e]={cues:l,dateRange:t,durationKnown:u}},g=0;g.05&&t.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),d=Math.round(2/(1+Math.exp(-.75*l-t.edgeStalled))*20)/20,h=Math.min(u,Math.max(1,d));t.changeMediaPlaybackRate(e,h)}else 1!==e.playbackRate&&0!==e.playbackRate&&t.changeMediaPlaybackRate(e,1)}}}}},this.hls=e,this.config=e.config,this.registerListeners()}var i=e.prototype;return i.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},i.registerListeners=function(){var e=this.hls;e&&(e.on(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(b.ERROR,this.onError,this))},i.unregisterListeners=function(){var e=this.hls;e&&(e.off(b.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(b.ERROR,this.onError,this))},i.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},i.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)},i.onManifestLoading=function(){this._latency=null,this.stallCount=0},i.onLevelUpdated=function(e,t){var i=t.details;i.advanced&&this.onTimeupdate(),!i.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)},i.onError=function(e,t){var i;t.details===k.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(i=this.levelDetails)&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))},i.changeMediaPlaybackRate=function(e,t){var i,r;e.playbackRate!==t&&(null==(i=this.hls)||i.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+(null==(r=this.targetLatency)?void 0:r.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+e.playbackRate+" to "+t),e.playbackRate=t)},i.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},i.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},t(e,[{key:"levelDetails",get:function(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;var t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e||null===this.hls)return null;var t=e.holdBack,i=e.partHoldBack,r=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&i||t;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*r);var d=r;return u+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var i=this.levelDetails;if(null===i)return null;var r=i.edge,n=e-t-this.edgeStalled,a=r-i.totalduration,s=r-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}}])}(),Ro=function(e){function i(t,i){var r;return(r=e.call(this,t,"level-controller")||this)._levels=[],r._firstLevel=-1,r._maxAutoLevel=-1,r._startLevel=void 0,r.currentLevel=null,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.steering=void 0,r.onParsedComplete=void 0,r.steering=i,r._registerListeners(),r}o(i,e);var r=i.prototype;return r._registerListeners=function(){var e=this.hls;e.on(b.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(b.LEVEL_LOADED,this.onLevelLoaded,this),e.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(b.FRAG_BUFFERED,this.onFragBuffered,this),e.on(b.ERROR,this.onError,this)},r._unregisterListeners=function(){var e=this.hls;e.off(b.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(b.LEVEL_LOADED,this.onLevelLoaded,this),e.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(b.FRAG_BUFFERED,this.onFragBuffered,this),e.off(b.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),e.prototype.destroy.call(this)},r.stopLoad=function(){this._levels.forEach((function(e){e.loadError=0,e.fragmentError=0})),e.prototype.stopLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},r.onManifestLoading=function(e,t){this.resetLevels()},r.onManifestLoaded=function(e,t){var i=this,r=this.hls.config.preferManagedMediaSource,n=[],a={},s={},o=!1,l=!1,u=!1;t.levels.forEach((function(e){var t=e.attrs,d=e.audioCodec,h=e.videoCodec;d&&(e.audioCodec=d=Be(d,r)||void 0),h&&(h=e.videoCodec=function(e){for(var t=e.split(","),i=0;i2&&"avc1"===r[0]&&(t[i]="avc1."+parseInt(r[1]).toString(16)+("000"+parseInt(r[2]).toString(16)).slice(-4))}return t.join(",")}(h));var c=e.width,f=e.height,g=e.unknownCodecs,v=g?g.length:0;if(g)for(var m=v;m--;){var p=g[m];i.isAudioSupported(p)?(e.audioCodec=d=d?d+","+p:p,v--,_e.audio[d.substring(0,4)]=2):i.isVideoSupported(p)&&(e.videoCodec=h=h?h+","+p:p,v--,_e.video[h.substring(0,4)]=2)}if(o||(o=!(!c||!f)),l||(l=!!h),u||(u=!!d),v||d&&!i.isAudioSupported(d)||h&&!i.isVideoSupported(h))i.log('Some or all CODECS not supported "'+t.CODECS+'"');else{var y=t.CODECS,T=t["FRAME-RATE"],E=t["HDCP-LEVEL"],S=t["PATHWAY-ID"],L=t.RESOLUTION,A=t["VIDEO-RANGE"],R=(S||".")+"-"+e.bitrate+"-"+L+"-"+T+"-"+y+"-"+A+"-"+E;if(a[R])if(a[R].uri===e.url||e.attrs["PATHWAY-ID"])a[R].addGroupId("audio",t.AUDIO),a[R].addGroupId("text",t.SUBTITLES);else{var k=s[R]+=1;e.attrs["PATHWAY-ID"]=new Array(k+1).join(".");var b=i.createLevel(e);a[R]=b,n.push(b)}else{var I=i.createLevel(e);a[R]=I,s[R]=1,n.push(I)}}})),this.filterAndSortMediaOptions(n,t,o,l,u)},r.createLevel=function(e){var t=new Ze(e),i=e.supplemental;if(null!=i&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){var r=new Error('SUPPLEMENTAL-CODECS not supported "'+i.videoCodec+'"');this.log(r.message),t.supportedResult=je(r,[])}return t},r.isAudioSupported=function(e){return Pe(e,"audio",this.hls.config.preferManagedMediaSource)},r.isVideoSupported=function(e){return Pe(e,"video",this.hls.config.preferManagedMediaSource)},r.filterAndSortMediaOptions=function(e,t,i,r,n){var a=this,s=[],o=[],l=e;if((i||r)&&n&&(l=l.filter((function(e){var t,i=e.videoCodec,r=e.videoRange,n=e.width,a=e.height;return(!!i||!(!n||!a))&&!!(t=r)&&Xe.indexOf(t)>-1}))),0!==l.length){t.audioTracks&&ko(s=t.audioTracks.filter((function(e){return!e.audioCodec||a.isAudioSupported(e.audioCodec)}))),t.subtitles&&ko(o=t.subtitles);var u=l.slice(0);l.sort((function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return Xe.indexOf(e.videoRange)-Xe.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var r=Oe(e.videoCodec),n=Oe(t.videoCodec);if(r!==n)return n-r}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var a=Me(e.codecSet),s=Me(t.codecSet);if(a!==s)return s-a}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var d=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==u.length)for(var h=0;hv&&v===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=m)}break}var p=n&&!r,y=this.hls.config,T=!(!y.audioStreamController||!y.audioTrackController),E={levels:l,audioTracks:s,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:T&&!p&&s.some((function(e){return!!e.url}))};this.hls.trigger(b.MANIFEST_PARSED,E)}else Promise.resolve().then((function(){if(a.hls){var e="no level with compatible codecs found in manifest",i=e;t.levels.length&&(i="one or more CODECS in variant not supported: "+Je(t.levels.map((function(e){return e.attrs.CODECS})).filter((function(e,t,i){return i.indexOf(e)===t}))),a.warn(i),e+=" ("+i+")");var r=new Error(e);a.hls.trigger(b.ERROR,{type:R.MEDIA_ERROR,details:k.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:r,reason:i})}}))},r.onError=function(e,t){!t.fatal&&t.context&&t.context.type===D&&t.context.level===this.level&&this.checkRetry(t)},r.onFragBuffered=function(e,t){var i=t.frag;if(void 0!==i&&i.type===P){var r=i.elementaryStreams;if(!Object.keys(r).some((function(e){return!!r[e]})))return;var n=this._levels[i.level];null!=n&&n.loadError&&(this.log("Resetting level error count of "+n.loadError+" on frag buffered"),n.loadError=0)}},r.onLevelLoaded=function(e,t){var i,r,n=t.level,a=t.details,s=t.levelInfo;if(!s)return this.warn("Invalid level index "+n),void(null!=(r=t.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);var o=s.details;o===t.details&&o.advanced&&(o=void 0),this.playlistLoaded(n,t,o)}else null!=(i=t.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0)},r.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)},r.loadingPlaylist=function(t,i){e.prototype.loadingPlaylist.call(this,t,i);var r=this.getUrlWithDirectives(t.uri,i),n=this.currentLevelIndex,a=t.attrs["PATHWAY-ID"],s=t.details,o=null==s?void 0:s.age;this.log("Loading level index "+n+(void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:"")+(a?" Pathway "+a:"")+(o&&s.live?" age "+o.toFixed(1)+(s.type&&" "+s.type||""):"")+" "+r),this.hls.trigger(b.LEVEL_LOADING,{url:r,level:n,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:i||null})},r.removeLevel=function(e){var t,i=this;if(1!==this._levels.length){var r=this._levels.filter((function(t,r){return r!==e||(i.steering&&i.steering.removeLevel(t),t===i.currentLevel&&(i.currentLevel=null,i.currentLevelIndex=-1,t.details&&t.details.fragments.forEach((function(e){return e.level=-1}))),!1)}));Yi(r),this._levels=r,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var n=r.length-1;this._firstLevel=Math.min(this._firstLevel,n),this._startLevel&&(this._startLevel=Math.min(this._startLevel,n)),this.hls.trigger(b.LEVELS_UPDATED,{levels:r})}},r.onLevelsUpdated=function(e,t){var i=t.levels;this._levels=i},r.checkMaxAutoUpdated=function(){var e=this.hls,t=e.autoLevelCapping,i=e.maxAutoLevel,r=e.maxHdcpLevel;this._maxAutoLevel!==i&&(this._maxAutoLevel=i,this.hls.trigger(b.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:i,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))},t(i,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var i=new Error("invalid level idx"),r=e<0;if(this.hls.trigger(b.ERROR,{type:R.OTHER_ERROR,details:k.LEVEL_SWITCH_ERROR,level:e,fatal:r,error:i,reason:i.message}),r)return;e=Math.min(e,t.length-1)}var n=this.currentLevelIndex,a=this.currentLevel,s=a?a.attrs["PATHWAY-ID"]:void 0,o=t[e],l=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,n!==e||!a||s!==l){this.log("Switching to level "+e+" ("+(o.height?o.height+"p ":"")+(o.videoRange?o.videoRange+" ":"")+(o.codecSet?o.codecSet+" ":"")+"@"+o.bitrate+")"+(l?" with Pathway "+l:"")+" from level "+n+(s?" with Pathway "+s:""));var u={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(b.LEVEL_SWITCHING,u);var d=o.details;if(!d||d.live){var h=this.switchParams(o.uri,null==a?void 0:a.details,d);this.loadPlaylist(h)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t=this.steering.pathways(),i=e.filter((function(e){return-1!==t.indexOf(e)}));if(e.length<1)return void this.warn("pathwayPriority "+e+" should contain at least one pathway from list: "+t);this.steering.pathwayPriority=i}}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])}(Wn);function ko(e){var t={};e.forEach((function(e){var i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++}))}function bo(){return self.SourceBuffer||self.WebKitSourceBuffer}function Io(){if(!j())return!1;var e=bo();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var Do=function(e){function i(t,i,r){var n;return(n=e.call(this,t,i,r,"stream-controller",P)||this).audioCodecSwap=!1,n.level=-1,n._forceStartLoad=!1,n._hasEnoughToStart=!1,n.altAudio=0,n.audioOnly=!1,n.fragPlaying=null,n.fragLastKbps=0,n.couldBacktrack=!1,n.backtrackFragment=null,n.audioCodecSwitch=!1,n.videoBuffer=null,n.onMediaPlaying=function(){n.tick()},n.onMediaSeeked=function(){var e=n.media,t=e?e.currentTime:null;if(null!==t&&S(t)&&(n.log("Media seeked to "+t.toFixed(3)),n.getBufferedFrag(t))){var i=n.getFwdBufferInfoAtPos(e,t,P,0);null!==i&&0!==i.len?n.tick():n.warn("Main forward buffer length at "+t+' on "seeked" event '+(i?i.len:"empty")+")")}},n.registerListeners(),n}o(i,e);var r=i.prototype;return r.registerListeners=function(){e.prototype.registerListeners.call(this);var t=this.hls;t.on(b.MANIFEST_PARSED,this.onManifestParsed,this),t.on(b.LEVEL_LOADING,this.onLevelLoading,this),t.on(b.LEVEL_LOADED,this.onLevelLoaded,this),t.on(b.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(b.BUFFER_CREATED,this.onBufferCreated,this),t.on(b.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(b.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(b.FRAG_BUFFERED,this.onFragBuffered,this)},r.unregisterListeners=function(){e.prototype.unregisterListeners.call(this);var t=this.hls;t.off(b.MANIFEST_PARSED,this.onManifestParsed,this),t.off(b.LEVEL_LOADED,this.onLevelLoaded,this),t.off(b.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(b.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(b.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(b.BUFFER_CREATED,this.onBufferCreated,this),t.off(b.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(b.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(b.FRAG_BUFFERED,this.onFragBuffered,this)},r.onHandlerDestroying=function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),e.prototype.onHandlerDestroying.call(this)},r.startLoad=function(e,t){if(this.levels){var i=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var n=r.startLevel;-1===n&&(r.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=r.firstAutoLevel),r.nextLoadLevel=n,this.level=r.loadLevel,this._hasEnoughToStart=!!t}i>0&&-1===e&&!t&&(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),e=i),this.state=$i,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=Zi},r.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case lr:var e=this.levels,t=this.level,i=null==e?void 0:e[t],r=null==i?void 0:i.details;if(r&&(!r.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(r))break;this.state=$i;break}if(this.hls.nextLoadLevel!==this.level){this.state=$i;break}break;case tr:var n,a=self.performance.now(),s=this.retryDate;if(!s||a>=s||null!=(n=this.media)&&n.seeking){var o=this.levels,l=this.level,u=null==o?void 0:o[l];this.resetStartWhenNotLoaded(u||null),this.state=$i}}this.state===$i&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){var t;e.prototype.onTickEnd.call(this),null!=(t=this.media)&&t.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()},r.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,i=this.levels,r=this.media;if(null!==t&&(r||this.primaryPrefetch||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var n=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=i&&i[n]){var a=i[n],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var l={};return 2===this.altAudio&&(l.type="video"),this.hls.trigger(b.BUFFER_EOS,l),void(this.state=ar)}if(this.buffering){e.loadLevel!==n&&-1===e.manualLevel&&this.log("Adapting to level "+n+" from level "+this.level),this.level=e.nextLoadLevel=n;var u=a.details;if(!u||this.state===lr||this.waitForLive(a))return this.level=n,this.state=lr,void(this.startFragRequested=!1);var d=s.len,h=this.getMaxBufferLength(a.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:s.end,f=this.getNextFragment(c,u);if(this.couldBacktrack&&!this.fragPrevious&&f&&J(f)&&this.fragmentTracker.getState(f)!==Rt){var g,v=(null!=(g=this.backtrackFragment)?g:f).sn-u.startSN,m=u.fragments[v-1];m&&f.cc===m.cc&&(f=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,c)){if(!f.gap){var p=this.audioOnly&&!this.altAudio?z:Q,y=(p===Q?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,p,P)}f=this.getNextFragmentLoopLoading(f,u,s,P,h)}f&&(!f.initSegment||f.initSegment.data||this.bitrateTest||(f=f.initSegment),this.loadFragment(f,a,c))}}}}}},r.loadFragment=function(t,i,r){var n=this.fragmentTracker.getState(t);n===St||n===At?J(t)?this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,i)):e.prototype.loadFragment.call(this,t,i,r):this._loadInitSegment(t,i):this.clearTrackerIfNeeded(t)},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,P)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var i,r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);var n=this.getLevelDetails();if(null!=n&&n.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*n.targetduration)return}if(!t.paused&&e){var s=e[this.hls.nextLoadLevel],o=this.fragLastKbps;i=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else i=0;var l=this.getBufferedFrag(t.currentTime+i);if(l){var u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var d=u.maxStartPTS?u.maxStartPTS:u.start,h=u.duration,c=Math.max(l.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Ji:case er:case tr:case rr:case nr:this.state=$i}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(t,i){e.prototype.flushMainBuffer.call(this,t,i,2===this.altAudio?"video":null)},r.onMediaAttached=function(t,i){e.prototype.onMediaAttached.call(this,t,i);var r=i.media;Ua(r,"playing",this.onMediaPlaying),Ua(r,"seeked",this.onMediaSeeked)},r.onMediaDetaching=function(t,i){var r=this.media;r&&(Ga(r,"playing",this.onMediaPlaying),Ga(r,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,e.prototype.onMediaDetaching.call(this,t,i),i.transferMedia||(this._hasEnoughToStart=!1)},r.onManifestLoading=function(){e.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(b.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1},r.onManifestParsed=function(e,t){var i,r,n=!1,a=!1;t.levels.forEach((function(e){var t=e.audioCodec;t&&(n=n||-1!==t.indexOf("mp4a.40.2"),a=a||-1!==t.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=n&&a&&!("function"==typeof(null==(r=bo())||null==(i=r.prototype)?void 0:i.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},r.onLevelLoading=function(e,t){if(this.levels&&this.state===$i){var i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=lr)}},r.onLevelLoaded=function(e,t){var i,r=this.levels,n=this.startFragRequested,a=t.level,s=t.details,o=s.totalduration;if(r){this.log("Level "+a+" loaded ["+s.startSN+","+s.endSN+"]"+(s.lastPartSn?"[part-"+s.lastPartSn+"-"+s.lastPartIndex+"]":"")+", cc ["+s.startCC+", "+s.endCC+"] duration:"+o);var l=t.levelInfo,u=this.fragCurrent;!u||this.state!==er&&this.state!==tr||u.level!==t.level&&u.loader&&this.abortCurrentFrag();var d=0;if(s.live||null!=(i=l.details)&&i.live){var h;if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;d=this.alignPlaylists(s,l.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(l.details=s,this.levelLastLoaded=l,n||this.setStartPosition(s,d),this.hls.trigger(b.LEVEL_UPDATED,{details:s,level:a}),this.state===lr){if(this.waitForCdnTuneIn(s))return;this.state=$i}n&&s.live&&this.synchronizeToLiveEdge(s),this.tick()}else this.warn("Levels were reset while loading level "+a)},r.synchronizeToLiveEdge=function(e){var t=this.config,i=this.media;if(i){var r=this.hls.liveSyncPosition,n=this.getLoadPosition(),a=e.fragmentStart,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==r&&i.duration>r&&(n-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,i=this.startPosition;if(i>=0&&t0&&(oT.cc;if(!1!==n.independent){var A=d.startPTS,R=d.endPTS,k=d.startDTS,I=d.endDTS;if(l)l.elementaryStreams[d.type]={startPTS:A,endPTS:R,startDTS:k,endDTS:I};else if(d.firstKeyFrame&&d.independent&&1===a.id&&!L&&(this.couldBacktrack=!0),d.dropped&&d.independent){var D=this.getMainFwdBufferInfo(),_=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,C=d.firstKeyFramePTS?d.firstKeyFramePTS:A;if(!E&&_2&&(o.gap=!0);o.setElementaryStreamInfo(d.type,A,R,k,I),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(d,o,l,a,E||L)}else{if(!E&&!L)return void this.backtrack(o);o.gap=!0}}if(v){var P=v.startPTS,w=v.endPTS,x=v.startDTS,O=v.endDTS;l&&(l.elementaryStreams[z]={startPTS:P,endPTS:w,startDTS:x,endDTS:O}),o.setElementaryStreamInfo(z,P,w,x,O),this.bufferFragmentData(v,o,l,a)}if(g&&null!=c&&null!=(t=c.samples)&&t.length){var M={id:i,frag:o,details:g,samples:c.samples};r.trigger(b.FRAG_PARSING_METADATA,M)}if(g&&h){var F={id:i,frag:o,details:g,samples:h.samples};r.trigger(b.FRAG_PARSING_USERDATA,F)}}}else this.resetWhenMissingContext(a)},r.logMuxedErr=function(e){this.warn((J(e)?"Media":"Init")+" segment with muxed audiovideo where only video expected: "+e.url)},r._bufferInitSegment=function(e,t,i,r){var n=this;if(this.state===rr){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));var a=t.audio,s=t.video,o=t.audiovideo;if(a){var l=Ue(a.codec,e.audioCodec);"mp4a"===l&&(l="mp4a.40.5");var u=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l=-1!==l.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=a.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&-1===u.indexOf("firefox")&&(l="mp4a.40.5")}l&&-1!==l.indexOf("mp4a.40.5")&&-1!==u.indexOf("android")&&"audio/mpeg"!==a.container&&(l="mp4a.40.2",this.log("Android: force audio codec to "+l)),e.audioCodec&&e.audioCodec!==l&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+l+'"'),a.levelCodec=l,a.id=P,this.log("Init audio buffer, container:"+a.container+", codecs[selected/level/parsed]=["+(l||"")+"/"+(e.audioCodec||"")+"/"+a.codec+"]"),delete t.audiovideo}if(s){s.levelCodec=e.videoCodec,s.id=P;var h=s.codec;if(4===(null==h?void 0:h.length))switch(h){case"hvc1":case"hev1":s.codec="hvc1.1.6.L120.90";break;case"av01":s.codec="av01.0.04M.08";break;case"avc1":s.codec="avc1.42e01e"}this.log("Init video buffer, container:"+s.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+h+"]"+(s.codec!==h?" parsed-corrected="+s.codec:"")+(s.supplemental?" supplemental="+s.supplemental:"")),delete t.audiovideo}o&&(this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+e.codecs+"/"+o.codec+"]"),delete t.video,delete t.audio);var c=Object.keys(t);if(c.length){if(this.hls.trigger(b.BUFFER_CODECS,t),!this.hls)return;c.forEach((function(e){var a=t[e].initSegment;null!=a&&a.byteLength&&n.hls.trigger(b.BUFFER_APPENDING,{type:e,data:a,frag:i,part:null,chunkMeta:r,parent:i.type})}))}this.tickImmediate()}},r.getMainFwdBufferInfo=function(){var e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,P)},r.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=$i},r.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var i=e.currentTime;if(Kt.isBuffered(e,i)?t=this.getAppendedFrag(i):Kt.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;var r=this.fragPlaying,n=t.level;r&&t.sn===r.sn&&r.level===n||(this.fragPlaying=t,this.hls.trigger(b.FRAG_CHANGED,{frag:t}),r&&r.level===n||this.hls.trigger(b.LEVEL_SWITCHED,{level:n}))}}},t(i,[{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,i=null==e?void 0:e[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return S(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(S(t)){var i=this.getLevelDetails(),r=this.currentFrag||(i?dt(null,i.fragments,t):null);if(r){var n=r.programDateTime;if(null!==n){var a=n+1e3*(t-r.start);return new Date(a)}}}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}}])}(ur),_o=function(){function e(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}var t=e.prototype;return t.abort=function(e){for(var t in this.keyUriToKeyInfo){var i=this.keyUriToKeyInfo[t].loader;if(i){var r;if(e&&e!==(null==(r=i.context)?void 0:r.frag.type))return;i.abort()}}},t.detach=function(){for(var e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}},t.destroy=function(){for(var e in this.detach(),this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}},t.createKeyLoadError=function(e,t,i,r,n){return void 0===t&&(t=k.KEY_LOAD_ERROR),new Nt({type:R.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:i,networkDetails:r})},t.loadClear=function(e,t){var i=this;if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length)if(t.length){for(var r,n=e.sn,a=e.cc,s=function(){var e=t[o];if(a<=e.cc&&("initSegment"===n||"initSegment"===e.sn||n":"")+")"),this.started=!0,this.resumeBuffering();for(var i=0;i-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return qe.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var i=e.length,r=0;r=t)return r;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,i=this.autoLevelCapping,r=this.maxHdcpLevel;if(e=-1===i&&null!=t&&t.length?t.length-1:i,r)for(var n=e;n--;){var a=t[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}}],[{key:"version",get:function(){return Kn}},{key:"Events",get:function(){return b}},{key:"MetadataSchema",get:function(){return wr}},{key:"ErrorTypes",get:function(){return R}},{key:"ErrorDetails",get:function(){return k}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:go},set:function(t){e.defaultConfig=t}}])}();return xo.defaultConfig=void 0,xo},"object"==typeof t&&void 0!==e?e.exports=a():"function"==typeof define&&define.amd?define(a):(n="undefined"!=typeof globalThis?globalThis:n||self).Hls=a()}(!1)}}]);