var LivePlayer=function(l){function t(t){for(var e,r,n=t[0],i=t[1],a=t[2],s=0,o=[];s=t.length?void 0:t)&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,a=r.call(t),s=[];try{for(;(void 0===e||0=r.length?(l=!!(c=p(a,u)))&&"get"in c&&!("originalValue"in c.get)?c.get:a[u]:(l=E(a,u),a[u]),l&&!s&&(v[h]=a)}}return a}},,,,,,,function(e,t){function r(t){return e.exports=r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e.exports.__esModule=!0,e.exports.default=e.exports,r(t)}e.exports=r,e.exports.__esModule=!0,e.exports.default=e.exports},function(t,e,r){var n=r(354),i=r(355),a=r(154),s=r(356);t.exports=function(t){return n(t)||i(t)||a(t)||s()},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){r=r(358)();t.exports=r;try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},,,,,,,,,,,,,,,,,,,,,,,,function(t,e){function l(t,e,r,n,i,a,s){try{var o=t[a](s),l=o.value}catch(t){return void r(t)}o.done?e(l):Promise.resolve(l).then(n,i)}t.exports=function(o){return function(){var t=this,s=arguments;return new Promise(function(e,r){var n=o.apply(t,s);function i(t){l(n,e,r,i,a,"next",t)}function a(t){l(n,e,r,i,a,"throw",t)}i(void 0)})}},t.exports.__esModule=!0,t.exports.default=t.exports},,function(t,e,r){"use strict";r.d(e,"a",function(){return a}),r.d(e,"b",function(){return s});var e=r(17),n=r.n(e);r(121);function i(e,t){var r,n=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)),n}function a(t){var e=function(e){for(var t=1;tt.dom.width&&(e.media.height=t.media.height*t.dom.width/t.media.width,e.media.width=t.media.width*e.media.height/t.media.height),e.media.width`):tt)})}const V=rt,it=/^(\d+)x(\d+)$/,at=/(.+?)=(".*?"|.*?)(?:,|$)/g;class B{constructor(t){for(const e in t="string"==typeof t?B.parseAttrList(t):t)t.hasOwnProperty(e)&&("X-"===e.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){t=parseInt(this[t],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(t){if(this[t]){var e=(1&(e=(this[t]||"0x").slice(2)).length?"0":"")+e,r=new Uint8Array(e.length/2);for(let t=0;tNumber.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){t=this[t];return t?parseFloat(t):e}enumeratedString(t){return this[t]}bool(t){return"YES"===this[t]}decimalResolution(t){t=it.exec(this[t]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(t){var e,r={};for(at.lastIndex=0;null!==(e=at.exec(t));){let t=e[2];0===t.indexOf('"')&&t.lastIndexOf('"')===t.length-1&&(t=t.slice(1,-1)),r[e[1].trim()]=t}return r}}class st{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var r=e.attr;for(const n in r)if(Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==r[n]){V.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=n;break}t=G(new B({}),r,t)}this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr&&(e=new Date(this.attr["END-DATE"]),N(e.getTime()))&&(this._endDate=e)}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){var t;return this._endDate||(null!==(t=this.duration)?new Date(this._startDate.getTime()+1e3*t):null)}get duration(){if("DURATION"in this.attr){var t=this.attr.decimalFloatingPoint("DURATION");if(N(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&N(this.startDate.getTime())&&(null===this.duration||0<=this.duration)&&(!this.endOnNext||!!this.class)}}class ot{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var y="audio",k="video",lt="audiovideo";class ut{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[y]:null,[k]:null,[lt]:null},this.baseurl=t}setByteRange(t,e){var t=t.split("@",2),r=[];1===t.length?r[0]=e?e.byteRangeEndOffset:0:r[0]=parseInt(t[1]),r[1]=parseInt(t[0])+r[0],this._byteRange=r}get byteRange(){return this._byteRange||[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Q.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class ht extends ut{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new ot,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){var t=this["levelkeys"];if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{t=Object.keys(this.levelkeys);if(1===t.length)return this._decryptdata=this.levelkeys[t[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){var t;return null!==this.programDateTime&&N(this.programDateTime)?(t=N(this.duration)?this.duration:0,this.programDateTime+1e3*t):null}get encrypted(){if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){var t=Object.keys(this.levelkeys),e=t.length;if(1t.endSN||0t.charCodeAt(0))}function pt(t){function e(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}e(t,0,3),e(t,1,2),e(t,4,5),e(t,6,7)}function gt(t){var e,r,t=t.split(":");let n=null;return"data"===t[0]&&2===t.length&&2===(e=(t=t[1].split(";"))[t.length-1].split(",")).length&&(r="base64"===e[0],e=e[1],n=r?(t.splice(-1,1),ft(e)):(r=vt(r=e).subarray(0,16),(t=new Uint8Array(16)).set(r,16-r.length),t)),n}function vt(t){return Uint8Array.from(unescape(encodeURIComponent(t)),t=>t.charCodeAt(0))}var p={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},mt="org.w3.clearkey",yt="com.apple.streamingkeydelivery",Et="com.microsoft.playready",Tt="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function bt(t){switch(t){case yt:return p.FAIRPLAY;case Et:return p.PLAYREADY;case Tt:return p.WIDEVINE;case mt:return p.CLEARKEY}}var At="edef8ba979d64acea3c827dcd51d21ed";function _t(t){switch(t){case p.FAIRPLAY:return yt;case p.PLAYREADY:return Et;case p.WIDEVINE:return Tt;case p.CLEARKEY:return mt}}function St(t){const{drmSystems:e,widevineLicenseUrl:r}=t;t=e?[p.FAIRPLAY,p.WIDEVINE,p.PLAYREADY,p.CLEARKEY].filter(t=>!!e[t]):[];return!t[p.WIDEVINE]&&r&&t.push(p.WIDEVINE),t}const Lt="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function kt(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}const Rt=(t,e)=>e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,wt=(t,e)=>e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128,It=(t,e)=>{var r=e;let n=0;for(;Rt(t,e);){n+=10;var i=Dt(t,e+6);n+=i,wt(t,e+10)&&(n+=10),e+=n}if(0{var r=(127&t[e])<<21;return(r|=(127&t[e+1])<<14)|(127&t[e+2])<<7|127&t[e+3]},Ct=t=>{var e=xt(t);for(let t=0;tt&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info,xt=t=>{let e=0;for(var r,n=[];Rt(t,e);){for(var i=Dt(t,e+6),a=(e+=10)+i;e+8{if(t.type==="PRIV")return Ot(t);else if(t.type[0]==="W")return Ft(t);return Mt(t)})(s);o&&n.push(o),e+=s.size+10}wt(t,e)&&(e+=10)}return n},Ot=t=>{var e,r;if(!(t.size<2))return e=T(t.data,!0),r=new Uint8Array(t.data.subarray(e.length+1)),{key:t.type,info:e,data:r.buffer}},Mt=t=>{var e,r;if(!(t.size<2))return"TXXX"===t.type?(e=1,e+=(r=T(t.data.subarray(1),!0)).length+1,e=T(t.data.subarray(e)),{key:t.type,info:r,data:e}):(r=T(t.data.subarray(1)),{key:t.type,data:r})},Ft=t=>{var e,r;return"WXXX"===t.type?t.size<2?void 0:(e=1,e+=(r=T(t.data.subarray(1),!0)).length+1,e=T(t.data.subarray(e)),{key:t.type,info:r,data:e}):(r=T(t.data),{key:t.type,data:r})},T=(t,e=!1)=>{var r,n=function(){if(!navigator.userAgent.includes("PlayStation 4"))return Nt=Nt||void 0===self.TextDecoder?Nt:new self.TextDecoder("utf-8")}();if(n)return n=n.decode(t),e?-1!==(r=n.indexOf("\0"))?n.substring(0,r):n:n.replace(/\0/g,"");var i,a,s=t.length;let o,l="",u=0;for(;u>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(i);break;case 12:case 13:o=t[u++],l+=String.fromCharCode((31&i)<<6|63&o);break;case 14:o=t[u++],a=t[u++],l+=String.fromCharCode((15&i)<<12|(63&o)<<6|(63&a)<<0)}}return l};let Nt;const g={hexDump:function(r){let n="";for(let e=0;e>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function w(e,r){var n=[];if(r.length){var i=e.byteLength;for(let t=0;t{var e=R(t,4),e=r[e];e&&(e.default={duration:R(t,12),flags:R(t,20)})}),r}function Vt(t){var e=w(t,["schm"])[0];if(e){e=v(e.subarray(4,8));if("cbcs"===e||"cenc"===e)return w(t,["schi","tenc"])[0]}return V.error("[eme] missing 'schm' box"),null}function Wt(t,e){let r=0,n=0,i=0;var a=w(t,["moof","traf"]);for(let t=0;t>>31)return V.warn("SIDX has hierarchical references (not supported)"),null;l=R(e,o);o+=4,r.push({referenceSize:u,subsegmentDuration:l,info:{duration:l/i,start:a,end:a+u-1}}),a+=u,o+=4,n=o}return{earliestPresentationTime:0,timescale:i,version:t,referencesCount:s,references:r}}(p[t]);null!=g&&g.references&&(e+=g.references.reduce((t,e)=>t+e.info.duration||0,0))}return e}}function Yt(t,e){var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function qt(T,b){const A=[],_=b.samples,S=b.timescale,u=b.id;let L=!1;return w(_,["moof"]).map(t=>{const E=t.byteOffset-8;w(t,["traf"]).map(l=>{var t=w(l,["tfdt"]).map(t=>{var e=t[0];let r=R(t,4);return(r=1===e?(r*=Math.pow(2,32))+R(t,8):r)/S})[0];return void 0!==t&&(T=t),w(l,["tfhd"]).map(t=>{var e=R(t,4),r=16777215&R(t,0),n=0!=(1&r),i=0!=(2&r),a=0!=(8&r);let m=0;var s=0!=(16&r);let y=0;r=0!=(32&r);let o=8;e===u&&(n&&(o+=8),i&&(o+=4),a&&(m=R(t,o),o+=4),s&&(y=R(t,o),o+=4),r&&(o+=4),"video"===b.type&&(L=function(t){if(!t)return!1;var e=t.indexOf("."),t=e<0?t:t.substring(0,e);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}(b.codec)),w(l,["trun"]).map(e=>{var r=e[0],t=16777215&R(e,0);let n=0;var i=0!=(256&t);let a=0;var s=0!=(512&t);let o=0;var l=0!=(1024&t),u=0!=(2048&t);let h=0;var c,d,f=R(e,4);let p=8,g=(0!=(1&t)&&(n=R(e,p),p+=4),0!=(4&t)&&(p+=4),n+E);for(let t=0;t>1&63)||40==c:6==(31&d))&&zt(_.subarray(g,g+v),L?2:1,T+h/S,A),g+=v,t+=v+4}}T+=a/S}}))})})}),A}function zt(t,e,r,n){var i=Qt(t);let a=0,s=(a+=e,0),o=0,l=!1,u=0;for(;a=i.length)&&(u=i[a++],s+=u,255===u););for(o=0;!(a>=i.length)&&(u=i[a++],o+=u,255===u););var h=i.length-a;if(!l&&4===s&&ah)break}}function Qt(t){var e=t.byteLength,r=[];let n=1;for(;n>24&255,d[1]=t>>16&255,d[2]=t>>8&255,d[3]=255&t,d.set(u,4),e=0,t=8;e>8*(15-t)&255;return r}(e),new Zt(this.method,this.uri,"identity",this.keyFormatVersions,e);var r=gt(this.uri);if(r)switch(this.keyFormat){case Tt:22<=(this.pssh=r).length&&(this.keyId=r.subarray(r.length-22,r.length-6));break;case Et:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]),n=(this.pssh=Xt(n,null,r),new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2)),n=String.fromCharCode.apply(null,Array.from(n)),n=n.substring(n.indexOf("<"),n.length),n=(new DOMParser).parseFromString(n,"text/xml").getElementsByTagName("KID")[0];n&&(n=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE"))&&(pt(n=ft(n).subarray(0,16)),this.keyId=n);break;default:{let t=r.subarray(0,16);16!==t.length&&((n=new Uint8Array(16)).set(t,16-t.length),t=n),this.keyId=t;break}}if(!this.keyId||16!==this.keyId.byteLength){let t=Jt[this.uri];t||(e=Object.keys(Jt).length%Number.MAX_SAFE_INTEGER,t=new Uint8Array(16),new DataView(t.buffer,12,4).setUint32(0,e),Jt[this.uri]=t),this.keyId=t}return this}}const te=/\{\$([a-zA-Z0-9-_]+)\}/g;function ee(t){return te.test(t)}function U(e,r,n){if(null!==e.variableList||e.hasVariableRefs)for(let t=n.length;t--;){var i=n[t],a=r[i];a&&(r[i]=re(e,a))}}function re(n,t){if(null!==n.variableList||n.hasVariableRefs){const i=n.variableList;return t.replace(te,t=>{var e=t.substring(2,t.length-1),r=null==i?void 0:i[e];return void 0===r?(n.playlistParsingError||(n.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${e}"`)),t):r})}return t}function ne(e,t,r){let n=e.variableList;n||(e.variableList=n={});let i,a;if("QUERYPARAM"in t){i=t.QUERYPARAM;try{var s=new self.URL(r).searchParams;if(!s.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);a=s.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+t.message))}}else i=t.NAME,a=t.VALUE;i in n?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):n[i]=a||""}function ie(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const ae={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},se=ie();function oe(t,e){return null!=(e=null==se?void 0:se.isTypeSupported(`${e||"video"}/mp4;codecs="${t}"`))&&e}const le=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,ue=/#EXT-X-MEDIA:(.*)/g,he=/^#EXT(?:INF|-X-TARGETDURATION):/m,ce=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),de=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class m{static findGroup(e,r){for(let t=0;t{const e=n.filter(t=>{return t=t,e=r,!!(e=ae[e])&&!0===e[t.slice(0,4)];var e});var t;e.length&&(t=e.filter(t=>0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)),i[r+"Codec"]=(0-1===e.indexOf(t)))}),i.unknownCodecs=n}((a.CODECS||"").split(/[ ,]+/).filter(t=>t),s),s.videoCodec&&-1!==s.videoCodec.indexOf("avc1")&&(s.videoCodec=m.convertAVC1ToAVCOTI(s.videoCodec)),null!=(o=s.unknownCodecs)&&o.length||i.push(s),n.levels.push(s)}else if(r[3]){var a=r[3],l=r[4];switch(a){case"SESSION-DATA":var u=new B(l),h=(U(n,u,["DATA-ID","LANGUAGE","VALUE","URI"]),u["DATA-ID"]);h&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[h]=u);break;case"SESSION-KEY":h=fe(l,e,n);h.encrypted&&h.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(h)):V.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${l}"`);break;case"DEFINE":u=new B(l);U(n,u,["NAME","VALUE","QUERYPARAM"]),ne(n,u,e);break;case"CONTENT-STEERING":var c=new B(l);U(n,c,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:m.resolve(c["SERVER-URI"],e),pathwayId:c["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=pe(l)}}var d=0({id:t.attrs.AUDIO,audioCodec:t.audioCodec})),SUBTITLES:i.map(t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec})),"CLOSED-CAPTIONS":[]};let s=0;for(ue.lastIndex=0;null!==(u=ue.exec(t));){var o,l,u=new B(u[1]),h=u.TYPE;h&&(o=a[h],l=n[h]||[],n[h]=l,U(r,u,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]),h={attrs:u,bitrate:0,id:s++,groupId:u["GROUP-ID"]||"",instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:h,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?m.resolve(u.URI,e):""},null!=o&&o.length&&(ge(h,u=m.findGroup(o,h.groupId)||o[0],"audioCodec"),ge(h,u,"textCodec")),l.push(h))}return n}static parseLevelPlaylist(t,e,r,n,i,F){var a=new dt(e),s=a.fragments;let o=null,l=0,u=0,h=0,c=0,d=null,f=new ht(n,e),p,g,v,m=-1,y=!1;for(ce.lastIndex=0,a.m3u8=t,a.hasVariableRefs=ee(t);null!==(p=ce.exec(t));){y&&(y=!1,(f=new ht(n,e)).start=h,f.sn=l,f.cc=c,f.level=r,o)&&(f.initSegment=o,f.rawProgramDateTime=o.rawProgramDateTime,o.rawProgramDateTime=null);var E=p[1];if(E){f.duration=parseFloat(E);var T=(" "+p[2]).slice(1);f.title=T||null,f.tagList.push(T?["INF",E,T]:["INF",E])}else if(p[3])N(f.duration)&&(f.start=h,v&&ye(f,v,a),f.sn=l,f.level=r,f.cc=c,f.urlId=i,s.push(f),T=(" "+p[3]).slice(1),f.relurl=re(a,T),ve(f,d),d=f,h+=f.duration,l++,u=0,y=!0);else if(p[4]){E=(" "+p[4]).slice(1);d?f.setByteRange(E,d):f.setByteRange(E)}else if(p[5])f.rawProgramDateTime=(" "+p[5]).slice(1),f.tagList.push(["PROGRAM-DATE-TIME",f.rawProgramDateTime]),-1===m&&(m=s.length);else if(p=p[0].match(de)){for(g=1;ge[t].isCommonEncryption)||r.push(t)}var Ee="manifest",Te="level",E="audioTrack",b="subtitleTrack",A="main",_="audio",be="subtitle";function Ae(t){t=t.type;switch(t){case E:return _;case b:return be;default:return A}}function _e(t,e){let r=t.url;return r=void 0!==r&&0!==r.indexOf("data:")?r:e.url}class Se{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){var t=this["hls"];t.on($.MANIFEST_LOADING,this.onManifestLoading,this),t.on($.LEVEL_LOADING,this.onLevelLoading,this),t.on($.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on($.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){var t=this["hls"];t.off($.MANIFEST_LOADING,this.onManifestLoading,this),t.off($.LEVEL_LOADING,this.onLevelLoading,this),t.off($.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off($.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){var e=this.hls.config,r=e.pLoader,n=e.loader,r=new(r||n)(e);return this.loaders[t.type]=r}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){e=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ee,url:e,deliveryDirectives:null})}onLevelLoading(t,e){var{id:e,level:r,url:n,deliveryDirectives:i}=e;this.load({id:e,level:r,responseType:"text",type:Te,url:n,deliveryDirectives:i})}onAudioTrackLoading(t,e){var{id:e,groupId:r,url:n,deliveryDirectives:i}=e;this.load({id:e,groupId:r,level:null,responseType:"text",type:E,url:n,deliveryDirectives:i})}onSubtitleTrackLoading(t,e){var{id:e,groupId:r,url:n,deliveryDirectives:i}=e;this.load({id:e,groupId:r,level:null,responseType:"text",type:b,url:n,deliveryDirectives:i})}load(e){var r=this.hls.config;let t=this.getInternalLoader(e);if(t){var n=t.context;if(n&&n.url===e.url)return void V.trace("[playlist-loader]: playlist request ongoing");V.log("[playlist-loader]: aborting previous loader for type: "+e.type),t.abort()}let i;if(i=e.type===Ee?r.manifestLoadPolicy.default:G({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),t=this.createInternalLoader(e),null!=(n=e.deliveryDirectives)&&n.part){let t;e.type===Te&&null!==e.level?t=this.hls.levels[e.level].details:e.type===E&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===b&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t&&(r=t.partTarget,n=t.targetduration,r)&&n&&(r=1e3*Math.max(3*r,.8*n),i=G({},i,{maxTimeToFirstByteMs:Math.min(r,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(r,i.maxTimeToFirstByteMs)}))}n=i.errorRetry||i.timeoutRetry||{},r={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0};t.load(e,r,{onSuccess:(t,e,r,n)=>{var i=this.getInternalLoader(r),a=(this.resetInternalLoader(r.type),t.data);0!==a.indexOf("#EXTM3U")?this.handleManifestParsingError(t,r,new Error("no EXTM3U delimiter"),n||null,e):(e.parsing.start=performance.now(),m.isMediaPlaylist(a)?this.handleTrackOrLevelPlaylist(t,e,r,n||null,i):this.handleMasterPlaylist(t,e,r,n))},onError:(t,e,r,n)=>{this.handleNetworkError(e,r,!1,t,n)},onTimeout:(t,e,r)=>{this.handleNetworkError(e,r,!0,void 0,t)}})}handleMasterPlaylist(t,e,r,n){var i,a,s,o,l,u=this.hls,h=t.data,c=_e(t,r),d=m.parseMasterPlaylist(h,c);d.playlistParsingError?this.handleManifestParsingError(t,r,d.playlistParsingError,n,e):({contentSteering:t,levels:r,sessionData:i,sessionKeys:a,startTimeOffset:s,variableList:o}=d,{AUDIO:h=[],SUBTITLES:d,"CLOSED-CAPTIONS":l}=(this.variableList=o,m.parseMasterPlaylistMedia(h,c,d)),h.length&&!h.some(t=>!t.url)&&r[0].audioCodec&&!r[0].attrs.AUDIO&&(V.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),h.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new B({}),bitrate:0,url:""})),u.trigger($.MANIFEST_LOADED,{levels:r,audioTracks:h,subtitles:d,captions:l,contentSteering:t,url:c,stats:e,networkDetails:n,sessionData:i,sessionKeys:a,startTimeOffset:s,variableList:o}))}handleTrackOrLevelPlaylist(t,e,r,n,i){var a=this.hls,{id:s,level:o,type:l}=r,u=_e(t,r),s=N(s)?s:0,o=N(o)?o:s,h=Ae(r),o=m.parseLevelPlaylist(t.data,u,o,h,s,this.variableList);l===Ee&&(h={attrs:new B({}),bitrate:0,details:o,name:"",url:u},a.trigger($.MANIFEST_LOADED,{levels:[h],audioTracks:[],url:u,stats:e,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})),e.parsing.end=performance.now(),r.levelDetails=o,this.handlePlaylistLoaded(o,t,e,r,n,i)}handleManifestParsingError(t,e,r,n,i){this.hls.trigger($.ERROR,{type:K.NETWORK_ERROR,details:H.MANIFEST_PARSING_ERROR,fatal:e.type===Ee,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:n,stats:i})}handleNetworkError(t,e,r=!1,n,i){let a=`A network ${r?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading `+t.type;t.type===Te?a+=`: ${t.level} id: `+t.id:t.type!==E&&t.type!==b||(a+=` id: ${t.id} group-id: "${t.groupId}"`);var s=new Error(a);V.warn("[playlist-loader]: "+a);let o=H.UNKNOWN,l=!1;var u=this.getInternalLoader(t);switch(t.type){case Ee:o=r?H.MANIFEST_LOAD_TIMEOUT:H.MANIFEST_LOAD_ERROR,l=!0;break;case Te:o=r?H.LEVEL_LOAD_TIMEOUT:H.LEVEL_LOAD_ERROR,l=!1;break;case E:o=r?H.AUDIO_TRACK_LOAD_TIMEOUT:H.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case b:o=r?H.SUBTITLE_TRACK_LOAD_TIMEOUT:H.SUBTITLE_LOAD_ERROR,l=!1}u&&this.resetInternalLoader(t.type);u={type:K.NETWORK_ERROR,details:o,fatal:l,url:t.url,loader:u,context:t,error:s,networkDetails:e,stats:i};n&&(s=(null==e?void 0:e.url)||t.url,u.response=f({url:s,data:void 0},n)),this.hls.trigger($.ERROR,u)}handlePlaylistLoaded(t,e,r,n,i,a){var s=this.hls,{type:o,level:l,id:u,groupId:h,deliveryDirectives:c}=n,d=_e(e,n),f=Ae(n),p="number"==typeof n.level&&f===A?l:void 0;if(t.fragments.length){t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var l=t.playlistParsingError;if(l)s.trigger($.ERROR,{type:K.NETWORK_ERROR,details:H.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:l,reason:l.message,response:e,context:n,level:p,parent:f,networkDetails:i,stats:r});else switch(t.live&&a&&(a.getCacheAge&&(t.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case Ee:case Te:s.trigger($.LEVEL_LOADED,{details:t,level:p||0,id:u||0,stats:r,networkDetails:i,deliveryDirectives:c});break;case E:s.trigger($.AUDIO_TRACK_LOADED,{details:t,id:u||0,groupId:h||"",stats:r,networkDetails:i,deliveryDirectives:c});break;case b:s.trigger($.SUBTITLE_TRACK_LOADED,{details:t,id:u||0,groupId:h||"",stats:r,networkDetails:i,deliveryDirectives:c})}}else l=new Error("No Segments found in Playlist"),s.trigger($.ERROR,{type:K.NETWORK_ERROR,details:H.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:l,reason:l.message,response:e,context:n,level:p,parent:f,networkDetails:i,stats:r})}}function Le(t,e){let r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function ke(e,r){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(r.id))try{if(e.addCue(r),!e.cues.getCueById(r.id))throw new Error("addCue is failed for: "+r)}catch(t){V.debug("[texttrack-utils]: "+t);try{var n=new self.TextTrackCue(r.startTime,r.endTime,r.text);n.id=r.id,e.addCue(n)}catch(t){V.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+t)}}"disabled"===t&&(e.mode=t)}function Re(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let t=e.cues.length;t--;)e.removeCue(e.cues[t]);"disabled"===t&&(e.mode=t)}function we(e,t,r,n){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&0t[r].endTime)return-1;let n=0,i=r;for(;n<=i;){var a=Math.floor((i+n)/2);if(et[a].startTime&&n=n&&o.endTime<=i)a.push(o);else if(o.startTime>i)return a}return a}(e.cues,t,r);for(let t=0;t{var t=Pe();try{t&&new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Me(t,e){return t.getTime()/1e3-e}class Fe{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){var t=this["hls"];t.on($.MEDIA_ATTACHED,this.onMediaAttached,this),t.on($.MEDIA_DETACHING,this.onMediaDetaching,this),t.on($.MANIFEST_LOADING,this.onManifestLoading,this),t.on($.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on($.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on($.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){var t=this["hls"];t.off($.MEDIA_ATTACHED,this.onMediaAttached,this),t.off($.MEDIA_DETACHING,this.onMediaDetaching,this),t.off($.MANIFEST_LOADING,this.onManifestLoading,this),t.off($.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off($.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off($.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Re(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){t=this.getID3Track(t.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;tOe?Oe:e)-l<=0&&(e=l+.25);for(let t=0;tt.type===Ie&&o:"video"===n?t=>t.type===Ce&&s:t=>t.type===Ie&&o||t.type===Ce&&s)}}}onLevelUpdated(t,{details:e}){if(this.media&&e.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){const{dateRangeCuesAppended:f,id3Track:p}=this,g=e["dateRanges"],v=Object.keys(g);if(p){var r=Object.keys(f).filter(t=>!v.includes(t));for(let t=r.length;t--;){const m=r[t];Object.keys(f[m].cues).forEach(t=>{p.removeCue(f[m].cues[t])}),delete f[m]}}e=e.fragments[e.fragments.length-1];if(0!==v.length&&N(null==e?void 0:e.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));var n=e.programDateTime/1e3-e.start,i=Pe();for(let t=0;t{var r=g[e];return r.class===y.class&&r.id!==e&&r.startDate>y.startDate&&t.push(r),t},[]).sort((t,e)=>t.startDate.getTime()-e.startDate.getTime())[0])&&(r=Me(u.startDate,n),e=!0),Object.keys(y.attr));for(let t=0;tthis.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){var{config:t,levelDetails:e}=this;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){var t=this["levelDetails"];if(null===t)return null;var{holdBack:t,partHoldBack:e,targetduration:r}=t,{liveSyncDuration:n,liveSyncDurationCount:i,lowLatencyMode:a}=this.config,s=this.hls.userConfig;let o=a&&e||t;return(o=s.liveSyncDuration||s.liveSyncDurationCount||0===o?void 0!==n?n:i*r:o)+Math.min(+this.stallCount,r)}get liveSyncPosition(){var t,e=this.estimateLiveEdge(),r=this.targetLatency,n=this.levelDetails;return null===e||null===r||null===n?null:(t=n.edge,e=e-r-this.edgeStalled,r=t-n.totalduration,t=t-(this.config.lowLatencyMode&&n.partTarget||n.targetduration),Math.min(Math.max(r,e),t))}get drift(){var t=this["levelDetails"];return null===t?1:t.drift}get edgeStalled(){var t,e=this["levelDetails"];return null===e?0:(t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration),Math.max(e.age-t,0))}get forwardBufferLength(){var t,{media:e,levelDetails:r}=this;return e&&r?((t=e.buffered.length)?e.buffered.end(t-1):r.edge)-this.currentTime:0}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on($.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on($.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on($.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on($.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on($.ERROR,this.onError,this)}unregisterListeners(){this.hls.off($.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off($.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off($.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off($.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off($.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){(this.levelDetails=e).advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){e.details===H.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(e=this.levelDetails))&&e.live&&V.warn("[playback-rate-controller]: Stall detected, adjusting target latency")}timeupdate(){var t,e,r,{media:n,levelDetails:i}=this;n&&i&&(this.currentTime=n.currentTime,null!==(e=this.computeLatency()))&&(this._latency=e,{lowLatencyMode:r,maxLiveSyncPlaybackRate:t}=this.config,r)&&1!==t&&null!==(r=this.targetLatency)&&(e=e-r,r=Math.min(this.maxLatency,r+i.targetduration),i.live&&et).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){t%=this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var t;return null==(t=this.audioGroupIds)?void 0:t[this.urlId]}get textGroupId(){var t;return null==(t=this.textGroupIds)?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function He(r,n){var i=n.startPTS;if(N(i)){let t=0,e;(e=n.sn>r.sn?(t=i-r.start,r):(t=r.start-i,n)).duration!==t&&(e.duration=t)}else n.sn>r.sn?r.cc===n.cc&&r.minEndPTS?n.start=r.start+(r.minEndPTS-r.start):n.start=r.start+r.duration:n.start=Math.max(r.start-n.duration,0)}function Ve(t,e,r,n,i,a){n-r<=0&&(V.warn("Fragment should have a positive duration",e),n=r+e.duration,a=i+e.duration);let s=r,o=n;var l=e.startPTS,u=e.endPTS,h=(N(l)&&(h=Math.abs(l-r),N(e.deltaPTS)?e.deltaPTS=Math.max(h,e.deltaPTS):e.deltaPTS=h,s=Math.max(r,l),r=Math.min(r,l),i=Math.min(i,e.startDTS),o=Math.min(n,u),n=Math.max(n,u),a=Math.max(a,e.endDTS)),r-e.start),l=(0!==e.start&&(e.start=r),e.duration=n-e.start,e.startPTS=r,e.maxStartPTS=s,e.startDTS=i,e.endPTS=n,e.minEndPTS=o,e.endDTS=a,e.sn);if(!t||lt.endSN)return 0;let c;var u=l-t.startSN,d=t.fragments;for(d[u]=e,c=u;0{t.relurl&&(a=t.cc-e.cc),N(t.startPTS)&&N(t.endPTS)&&(e.start=e.startPTS=t.startPTS,e.startDTS=t.startDTS,e.maxStartPTS=t.maxStartPTS,e.endPTS=t.endPTS,e.endDTS=t.endDTS,e.minEndPTS=t.minEndPTS,e.duration=t.endPTS-t.startPTS,e.duration&&(s=e),r.PTSKnown=r.alignedSliding=!0),e.elementaryStreams=t.elementaryStreams,e.loader=t.loader,e.stats=t.stats,e.urlId=t.urlId,t.initSegment&&(e.initSegment=t.initSegment,n=t.initSegment)},h=l.skippedSegments,c=Math.max(o.startSN,l.startSN)-l.startSN,d=(o.fragmentHint?1:0)+(h?l.endSN:Math.min(o.endSN,l.endSN))-l.startSN,f=l.startSN-o.startSN,p=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,g=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments;for(let e=c;e<=d;e++){var v=g[f+e];let t=p[e];h&&!t&&e{var e;t.initSegment&&t.initSegment.relurl!==(null==(e=n)?void 0:e.relurl)||(t.initSegment=n)}),r.skippedSegments)if(r.deltaUpdateFailed=r.fragments.some(t=>!t),r.deltaUpdateFailed){V.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let t=r.skippedSegments;t--;)r.fragments.shift();r.startSN=r.fragments[0].sn,r.startCC=r.fragments[0].cc}else r.canSkipDateRanges&&(r.dateRanges=function(t,r,e){const n=G({},t);e&&e.forEach(t=>{delete n[t]});return Object.keys(r).forEach(t=>{var e=new st(r[t].attr,n[t]);e.isValid?n[t]=e:V.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(r[t].attr)}"`)}),n}(t.dateRanges,r.dateRanges,r.recentlyRemovedDateranges));var m=r.fragments;if(a){V.warn("discontinuity sliding from playlist, take drift into account");for(let t=0;t{e.elementaryStreams=t.elementaryStreams,e.stats=t.stats};if(y&&E){let r=0;for(let t=0,e=y.length;t<=e;t++){var b=y[t],A=E[t+r];b&&A&&b.index===A.index&&b.fragment.sn===A.fragment.sn?T(b,A):r--}}s?Ve(r,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):Ye(t,r),m.length&&(r.totalduration=r.edge-m[0].start),r.driftStartTime=t.driftStartTime,r.driftStart=t.driftStart;o=r.advancedDateTime;r.advanced&&o?(c=r.edge,r.driftStart||(r.driftStartTime=o,r.driftStart=c),r.driftEndTime=o,r.driftEnd=c):(r.driftEndTime=t.driftEndTime,r.driftEnd=t.driftEnd,r.advancedDateTime=t.advancedDateTime)}function Ye(t,e){var r=e.startSN+e.skippedSegments-t.startSN,t=t.fragments;r<0||r>=t.length||qe(e,t[r].start)}function qe(e,r){if(r){var n=e.fragments;for(let t=e.skippedSegments;tt?0:(e=Math.min(e,r.duration+(r.deltaPTS||0)),r.start+r.duration-e<=t?1:r.start-e>t&&r.start?-1:0)}var sr=0,or=2,lr=5,ur=0,hr=1,cr=2;class dr{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=V.log.bind(V,e+":"),this.warn=V.warn.bind(V,e+":"),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(n,i){var a=null==i?void 0:i.renditionReports;if(a){let r=-1;for(let t=0;ti.partTarget&&(t+=1),new $e(o,0<=t?t:void 0,Ue)}}}loadPlaylist(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)}playlistLoaded(t,i,a){var{details:s,stats:o}=i,l=self.performance.now(),u=o.loading.first?Math.max(0,l-o.loading.first):0;if(s.advancedDateTime=Date.now()-u,s.live||null!=a&&a.live){if(s.reloaded(a),a&&this.log(`live playlist ${t} `+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED")),a&&0a.tuneInGoal?(this.warn(`CDN Tune-in goal increased from: ${a.tuneInGoal} to: ${t} with playlist age: `+s.age),t=0):(c=Math.floor(t/s.targetduration),r+=c,void 0!==n&&(d=Math.round(t%s.targetduration/s.partTarget),n+=d),this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${h.toFixed(2)}s goal: ${t} skip sn ${c} to part `+n)),s.tuneInGoal=t),e=this.getDeliveryDirectives(s,i.deliveryDirectives,r,n),u||!f)return void this.loadPlaylist(e)}else(s.canBlockReload||s.canSkipUntil)&&(e=this.getDeliveryDirectives(s,i.deliveryDirectives,r,n));a=this.hls.mainForwardBufferInfo,d=a?a.end-a.len:0,h=function(t,e){let r=1e3*t.targetduration;return t.updated?(t=t.fragments).length&&4*r>e&&(e=1e3*t[t.length-1].duration)this.requestScheduled+h&&(this.requestScheduled=o.loading.start),void 0!==r&&s.canBlockReload?this.requestScheduled=o.loading.first+h-(1e3*s.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+hthis.loadPlaylist(e),c)}}else this.clearTimer()}getDeliveryDirectives(t,e,r,n){let i=function(t,e){var{canSkipUntil:t,canSkipDateRanges:r,endSN:n}=t;return t&&(void 0!==e?e-n:0)=s.maxNumRetry)return!1;r&&null!=(r=t.context)&&r.deliveryDirectives?(this.warn(`Retrying playlist loading ${a+1}/${s.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist()):(r=Ze(s,a),this.timer=self.setTimeout(()=>this.loadPlaylist(),r),this.warn(`Retrying playlist loading ${a+1}/${s.maxNumRetry} after "${e}" in ${r}ms`)),t.levelRetry=!0,n.resolved=!0}return i}}let fr;class pr extends dr{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){var t=this["hls"];t.on($.MANIFEST_LOADING,this.onManifestLoading,this),t.on($.MANIFEST_LOADED,this.onManifestLoaded,this),t.on($.LEVEL_LOADED,this.onLevelLoaded,this),t.on($.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on($.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on($.FRAG_LOADED,this.onFragLoaded,this),t.on($.ERROR,this.onError,this)}_unregisterListeners(){var t=this["hls"];t.off($.MANIFEST_LOADING,this.onManifestLoading,this),t.off($.MANIFEST_LOADED,this.onManifestLoaded,this),t.off($.LEVEL_LOADED,this.onLevelLoaded,this),t.off($.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off($.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off($.FRAG_LOADED,this.onFragLoaded,this),t.off($.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const o=[],l={};let u;e.levels.forEach(t=>{var e=t.attrs,{AUDIO:r,CODECS:e,"FRAME-RATE":n,"PATHWAY-ID":i,RESOLUTION:a,SUBTITLES:s}=(-1!==(null==(r=t.audioCodec)?void 0:r.indexOf("mp4a.40.34"))&&(fr=fr||/chrome|firefox/i.test(navigator.userAgent))&&(t.audioCodec=void 0),e),i=`${i||"."}-`+t.bitrate+`-${a}-${n}-`+e;(u=l[i])?u.addFallback(t):(u=new Ke(t),l[i]=u,o.push(u)),gr(u,"audio",r),gr(u,"text",s)}),this.filterAndSortMediaOptions(o,e)}filterAndSortMediaOptions(t,r){let n=[],i=[],a=!1,s=!1,o=!1,l=t.filter(({audioCodec:t,videoCodec:e,width:r,height:n,unknownCodecs:i})=>(a=a||!(!r||!n),s=s||!!e,o=o||!!t,!(null!=i&&i.length)&&(!t||oe(t,"audio"))&&(!e||oe(e,"video"))));if(0===(l=(a||s)&&o?l.filter(({videoCodec:t,width:e,height:r})=>!!t||!(!e||!r)):l).length)Promise.resolve().then(()=>{var t;this.hls&&(t=new Error("no level with compatible codecs found in manifest"),this.hls.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:r.url,error:t,reason:t.message}))});else{r.audioTracks&&vr(n=r.audioTracks.filter(t=>!t.audioCodec||oe(t.audioCodec,"audio"))),r.subtitles&&vr(i=r.subtitles);var u=l.slice(0);l.sort((t,e)=>t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs["FRAME-RATE"]!==e.attrs["FRAME-RATE"]?t.attrs.decimalFloatingPoint("FRAME-RATE")-e.attrs.decimalFloatingPoint("FRAME-RATE"):t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):a&&t.height!==e.height?t.height-e.height:0);let e=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==u.length)for(let t=0;t!!t.url)};this.hls.trigger($.MANIFEST_PARSED,t),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(t){var e=this._levels;if(0!==e.length){if(t<0||t>=e.length){var r=new Error("invalid level idx"),n=t<0;if(this.hls.trigger($.ERROR,{type:K.OTHER_ERROR,details:H.LEVEL_SWITCH_ERROR,level:t,fatal:n,error:r,reason:r.message}),n)return;t=Math.min(t,e.length-1)}var r=this.currentLevelIndex,n=this.currentLevel,i=n?n.attrs["PATHWAY-ID"]:void 0,e=e[t],a=e.attrs["PATHWAY-ID"];this.currentLevelIndex=t,this.currentLevel=e,r===t&&e.details&&n&&i===a||(this.log(`Switching to level ${t}${a?" with Pathway "+a:""} from level `+r+(i?" with Pathway "+i:"")),delete(a=G({},e,{level:t,maxBitrate:e.maxBitrate,attrs:e.attrs,uri:e.uri,urlId:e.urlId}))._attrs,delete a._urlId,this.hls.trigger($.LEVEL_SWITCHING,a),(r=e.details)&&!r.live)||(i=this.switchParams(e.uri,null==n?void 0:n.details),this.loadPlaylist(i))}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){var t;return void 0===this._startLevel?void 0!==(t=this.hls.config.startLevel)?t:this._firstLevel:this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){!e.fatal&&e.context&&e.context.type===Te&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){void 0!==e&&e.type===A&&void 0!==(e=this._levels[e.level])&&(e.loadError=0)}onLevelLoaded(t,e){var{level:r,details:n}=e,i=this._levels[r];i?r===this.currentLevelIndex?(0===i.fragmentError&&(i.loadError=0),this.playlistLoaded(r,e,i.details)):null!=(i=e.deliveryDirectives)&&i.skip&&(n.deltaUpdateFailed=!0):(this.warn("Invalid level index "+r),null!=(i=e.deliveryDirectives)&&i.skip&&(n.deltaUpdateFailed=!0))}onAudioTrackSwitched(t,e){var r=this.currentLevel;if(r){var n=this.hls.audioTracks[e.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==n){let e=-1;for(let t=0;te!==n;var t=this._levels.filter((t,e)=>!(e===r&&(1{t=t.details;null!=t&&t.fragments&&t.fragments.forEach(t=>{t.level=e})}),this._levels=e}}function gr(t,e,r){r&&("audio"===e?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=r):"text"===e&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=r))}function vr(t){const r={};t.forEach(t=>{var e=t.groupId||"";t.id=r[e]=r[e]||0,r[e]++})}var mr="NOT_LOADED",yr="APPENDING",Er="PARTIAL",Tr="OK";class br{constructor(t){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=t,this._registerListeners()}_registerListeners(){var t=this["hls"];t.on($.BUFFER_APPENDED,this.onBufferAppended,this),t.on($.FRAG_BUFFERED,this.onFragBuffered,this),t.on($.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){var t=this["hls"];t.off($.BUFFER_APPENDED,this.onBufferAppended,this),t.off($.FRAG_BUFFERED,this.onFragBuffered,this),t.off($.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){var r=this.activePartLists[t];if(r)for(let t=r.length;t--;){var n=r[t];if(!n)break;var i=n.end;if(n.start<=e&&null!==i&&e<=i)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,r){var n=this["fragments"],i=Object.keys(n);for(let t=i.length;t--;){var a=n[i[t]];if((null==a?void 0:a.body.type)===r&&a.buffered){a=a.body;if(a.start<=e&&e<=a.end)return a}}return null}detectEvictedFragments(r,n,i,t){this.timeRanges&&(this.timeRanges[r]=n);const a=(null==t?void 0:t.fragment.sn)||-1;Object.keys(this.fragments).forEach(t=>{const e=this.fragments[t];!e||a>=e.body.sn||(e.buffered||e.loaded?(t=e.range[r])&&t.time.some(t=>{t=!this.isTimeBuffered(t.startPTS,t.endPTS,n);return t&&this.removeFragment(e.body),t}):e.body.type===i&&this.removeFragment(e.body))})}detectPartialFragments(t){const n=this.timeRanges,{frag:i,part:a}=t;if(n&&"initSegment"!==i.sn){t=_r(i);const s=this.fragments[t];if(!(!s||s.buffered&&i.gap)){const o=!i.relurl;Object.keys(n).forEach(t=>{var e,r=i.elementaryStreams[t];r&&(e=n[t],r=o||!0===r.partial,s.range[t]=this.getBufferedTimes(i,a,r,e))}),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,(s.body.endList=i.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),Ar(s)||this.removeParts(i.sn-1,i.type)):this.removeFragment(s.body)}}}removeParts(e,t){var r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(t=>t.fragment.sn>=e))}fragBuffered(t,e){var r=_r(t);let n=this.fragments[r];!n&&e&&(n=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap)&&(this.hasGaps=!0),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(t,e,r,n){var i={time:[],partial:r},a=t.start,s=t.end,o=t.minEndPTS||s,l=t.maxStartPTS||a;for(let t=0;t{t=l[t];t&&Ar(t)&&(i=t.body.start-o,a=t.body.end+o,e>=i)&&e<=a&&(n=Math.min(e-i,a-e),s<=n)&&(r=t.body,s=n)}),r}isEndListAppended(t){t=this.endListFragments[t];return void 0!==t&&(t.buffered||Ar(t))}getState(t){t=_r(t),t=this.fragments[t];return t?t.buffered?Ar(t)?Er:Tr:yr:mr}isTimeBuffered(e,r,n){var i,a;for(let t=0;t{var e=i[t];this.detectEvictedFragments(t,e,a,n)})}}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){t=_r(t);return!!this.fragments[t]}hasParts(t){return!(null==(t=this.activePartLists[t])||!t.length)}removeFragmentsInRange(r,n,i,a,s){a&&!this.hasGaps||Object.keys(this.fragments).forEach(t=>{var e,t=this.fragments[t];!t||(e=t.body).type!==i||a&&!e.gap||e.startr&&(t.buffered||s)&&this.removeFragment(e)})}removeFragment(t){var e=_r(t),r=(t.stats.loaded=0,t.clearElementaryStreamInfo(),this.activePartLists[t.type]);if(r){const n=t.sn;this.activePartLists[t.type]=r.filter(t=>t.fragment.sn!==n)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Ar(t){var e;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(e=t.range.audio)?void 0:e.partial)||(null==(e=t.range.audiovideo)?void 0:e.partial))}function _r(t){return`${t.type}_${t.level}_${t.urlId}_`+t.sn}const Sr=Math.pow(2,17);class Lr{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(o,l){const u=o.url;if(!u)return Promise.reject(new wr({type:K.NETWORK_ERROR,details:H.FRAG_LOAD_ERROR,fatal:!1,frag:o,error:new Error("Fragment does not have a "+(u?"part list":"url")),networkDetails:null}));this.abort();const r=this.config,h=r.fLoader,c=r.loader;return new Promise((a,i)=>{if(this.loader&&this.loader.destroy(),o.gap){if(o.tagList.some(t=>"GAP"===t[0]))return void i(Rr(o));o.gap=!1}const s=this.loader=o.loader=new(h||c)(r);var t=kr(o),e=tr(r.fragLoadPolicy.default);const n={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===o.sn?1/0:Sr};o.stats=s.stats,s.load(t,n,{onSuccess:(t,e,r,n)=>{this.resetLoader(o,s);let i=t.data;r.resetIV&&o.decryptdata&&(o.decryptdata.iv=new Uint8Array(i.slice(0,16)),i=i.slice(16)),a({frag:o,part:null,payload:i,networkDetails:n})},onError:(t,e,r,n)=>{this.resetLoader(o,s),i(new wr({type:K.NETWORK_ERROR,details:H.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:f({url:u,data:void 0},t),error:new Error(`HTTP Error ${t.code} `+t.text),networkDetails:r,stats:n}))},onAbort:(t,e,r)=>{this.resetLoader(o,s),i(new wr({type:K.NETWORK_ERROR,details:H.INTERNAL_ABORTED,fatal:!1,frag:o,error:new Error("Aborted"),networkDetails:r,stats:t}))},onTimeout:(t,e,r)=>{this.resetLoader(o,s),i(new wr({type:K.NETWORK_ERROR,details:H.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,error:new Error(`Timeout after ${n.timeout}ms`),networkDetails:r,stats:t}))},onProgress:(t,e,r,n)=>{l&&l({frag:o,part:null,payload:r,networkDetails:n})}})})}loadPart(l,u,h){this.abort();const e=this.config,r=e.fLoader,c=e.loader;return new Promise((i,a)=>{if(this.loader&&this.loader.destroy(),l.gap||u.gap)a(Rr(l,u));else{const s=this.loader=l.loader=new(r||c)(e),o=kr(l,u);var t=tr(e.fragLoadPolicy.default);const n={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Sr};u.stats=s.stats,s.load(o,n,{onSuccess:(t,e,r,n)=>{this.resetLoader(l,s),this.updateStatsFromPart(l,u);t={frag:l,part:u,payload:t.data,networkDetails:n};h(t),i(t)},onError:(t,e,r,n)=>{this.resetLoader(l,s),a(new wr({type:K.NETWORK_ERROR,details:H.FRAG_LOAD_ERROR,fatal:!1,frag:l,part:u,response:f({url:o.url,data:void 0},t),error:new Error(`HTTP Error ${t.code} `+t.text),networkDetails:r,stats:n}))},onAbort:(t,e,r)=>{l.stats.aborted=u.stats.aborted,this.resetLoader(l,s),a(new wr({type:K.NETWORK_ERROR,details:H.INTERNAL_ABORTED,fatal:!1,frag:l,part:u,error:new Error("Aborted"),networkDetails:r,stats:t}))},onTimeout:(t,e,r)=>{this.resetLoader(l,s),a(new wr({type:K.NETWORK_ERROR,details:H.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,part:u,error:new Error(`Timeout after ${n.timeout}ms`),networkDetails:r,stats:t}))}})}})}updateStatsFromPart(t,e){var r=t.stats,n=e.stats,i=n.total,t=(r.loaded+=n.loaded,i?(i=((t=Math.round(t.duration/e.duration))-(e=Math.min(Math.round(r.loaded/i),t)))*Math.round(r.loaded/e),r.total=r.loaded+i):r.total=Math.max(r.loaded,r.total),r.loading),e=n.loading;t.start?t.first+=e.first-e.start:(t.start=e.start,t.first=e.first),t.end=e.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function kr(r,n=null){var i=n||r,n={frag:r,part:n,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},a=i.byteRangeStartOffset,i=i.byteRangeEndOffset;if(N(a)&&N(i)){let t=a,e=i;"initSegment"===r.sn&&"AES-128"===(null==(r=r.decryptdata)?void 0:r.method)&&((r=i-a)%16&&(e=i+(16-r%16)),0!==a)&&(n.resetIV=!0,t=a-16),n.rangeStart=t,n.rangeEnd=e}return n}function Rr(t,e){var r=new Error(`GAP ${t.gap?"tag":"attribute"} found`),r={type:K.MEDIA_ERROR,details:H.FRAG_GAP,fatal:!1,frag:t,error:r,networkDetails:null};return e&&(r.part=e),(e||t).stats.aborted=!0,new wr(r)}class wr extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class Ir{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const r in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[r].loader;if(e){if(t&&t!==e.context.frag.type)return;e.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=H.KEY_LOAD_ERROR,r,n,i){return new wr({type:K.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:i,error:r,networkDetails:n})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){var{sn:r,cc:n}=t;for(let t=0;t{i.setKeyFormat(t)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){t&&e.setKeyFormat(t);const r=e.decryptdata;if(!r)return t=new Error(t?"Expected frag.decryptdata to be defined after setting format "+t:"Missing decryption data on fragment in onKeyLoading"),Promise.reject(this.createKeyLoadError(e,H.KEY_LOAD_ERROR,t));var n,t=r.uri;if(!t)return Promise.reject(this.createKeyLoadError(e,H.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${t}"`)));let i=this.keyUriToKeyInfo[t];if(null!=(n=i)&&n.decryptdata.key)return r.key=i.decryptdata.key,Promise.resolve({frag:e,keyInfo:i});if(null!=(n=i)&&n.keyLoadPromise)switch(null==(n=i.mediaKeySessionContext)?void 0:n.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return i.keyLoadPromise.then(t=>(r.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:i}))}switch(i=this.keyUriToKeyInfo[t]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(i,e):this.loadKeyEME(i,e);case"AES-128":return this.loadKeyHTTP(i,e);default:return Promise.reject(this.createKeyLoadError(e,H.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){t=this.emeController.loadKey(r);if(t)return(e.keyLoadPromise=t.then(t=>(e.mediaKeySessionContext=t,r))).catch(t=>{throw e.keyLoadPromise=null,t})}return Promise.resolve(r)}loadKeyHTTP(r,a){const n=this.config;const l=new n.loader(n);return a.keyLoader=r.loader=l,r.keyLoadPromise=new Promise((s,o)=>{const i={keyInfo:r,frag:a,responseType:"arraybuffer",url:r.decryptdata.uri};var t=n.keyLoadPolicy.default,t={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},e={onSuccess:(t,e,r,n)=>{var{frag:r,keyInfo:i,url:a}=r;if(!r.decryptdata||i!==this.keyUriToKeyInfo[a])return o(this.createKeyLoadError(r,H.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));i.decryptdata.key=r.decryptdata.key=new Uint8Array(t.data),r.keyLoader=null,i.loader=null,s({frag:r,keyInfo:i})},onError:(t,e,r,n)=>{this.resetLoader(e),o(this.createKeyLoadError(a,H.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key `+t.text),r,f({url:i.url,data:void 0},t)))},onTimeout:(t,e,r)=>{this.resetLoader(e),o(this.createKeyLoadError(a,H.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),r))},onAbort:(t,e,r)=>{this.resetLoader(e),o(this.createKeyLoadError(a,H.INTERNAL_ABORTED,new Error("key loading aborted"),r))}};l.load(i,t,e)})}resetLoader(t){var{frag:t,keyInfo:e,url:r}=t,n=e.loader;t.keyLoader===n&&(t.keyLoader=null,e.loader=null),delete this.keyUriToKeyInfo[r],n&&n.destroy()}}const Dr={length:0,start:()=>0,end:()=>0};class S{static isBuffered(t,e){try{if(t){var r=S.getBuffered(t);for(let t=0;t=r.start(t)&&e<=r.end(t))return!0}}catch(t){}return!1}static bufferInfo(e,r,n){try{if(e){var i=S.getBuffered(e),a=[];let t;for(t=0;ta&&(i[s-1].end=e[t].end):i.push(e[t])}else i=e;let o=0,l,u=r,h=r;for(let t=0;tr.startCC||t&&t.cc>>8^255&g^99,v=c[e[t[d]=g]=d],m=c[v],y=c[m],E=257*c[g]^16843008*g;n[d]=E<<24|E>>>8,i[d]=E<<16|E>>>16,a[d]=E<<8|E>>>24,s[d]=E,E=16843009*y^65537*m^257*v^16843008*d,o[g]=E<<24|E>>>8,l[g]=E<<16|E>>>16,u[g]=E<<8|E>>>24,h[g]=E,d?(d=v^c[c[c[y^v]]],f^=c[c[f]]):d=f=1}}expandKey(i){var a=this.uint8ArrayToUint32Array_(i);let t=!0,e=0;for(;e{return i?(this.logOnce("WebCrypto AES decrypt"),new Br(i,new Uint8Array(n)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))}).catch(t=>(V.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${t.name}: `+t.message),this.onWebCryptoError(e,r,n)))}onWebCryptoError(t,e,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r);t=this.flush();if(t)return t.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;var r=t.length-t.length%16;return r!==t.length&&(e=kt(t,0,r),this.remainderData=kt(t,r)),e}logOnce(t){this.logEnabled&&(V.log("[decrypter]: "+t),this.logEnabled=!1)}}const $r={toString:function(e){let r="";var n=e.length;for(let t=0;tn.end)&&(i=i{this.fragContextChanged(r)?(this.warn(`Fragment ${r.sn}${t.part?" p: "+t.part.index:""} of level ${r.level} was dropped during download.`),this.fragmentTracker.removeFragment(r)):(r.stats.chunkCount++,this._handleFragmentLoadProgress(t))}).then(t=>{var e;t&&(e=this.state,this.fragContextChanged(r)?e!==L.FRAG_LOADING&&(this.fragCurrent||e!==L.PARSING)||(this.fragmentTracker.removeFragment(r),this.state=L.IDLE):("payload"in t&&(this.log(`Loaded fragment ${r.sn} of level `+r.level),this.hls.trigger($.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t)))}).catch(t=>{this.state!==L.STOPPED&&this.state!==L.ERROR&&(this.warn(t),this.resetFragmentLoading(r))})}clearTrackerIfNeeded(t){var e,r=this["fragmentTracker"];r.getState(t)===yr?(e=t.type,e=this.getFwdBufferInfo(this.mediaBuffer,e),e=Math.max(t.duration,e?e.len:this.config.maxBufferLength),this.reduceMaxBufferLength(e)&&r.removeFragment(t)):0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?r.removeAllFragments():r.hasParts(t.type)&&(r.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),r.getState(t)===Er)&&r.removeFragment(t)}checkLiveUpdate(t){var e;t.updated&&!t.live&&(e=t.fragments[t.fragments.length-1],this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})),t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,r=null){t-e&&(t={startOffset:t,endOffset:e,type:r},this.hls.trigger($.BUFFER_FLUSHING,t))}_loadInitSegment(a,i){this._doFragLoad(a,i).then(t=>{if(t&&!this.fragContextChanged(a)&&this.levels)return t;throw new Error("init load aborted")}).then(r=>{const n=this["hls"];var t=r["payload"],e=a.decryptdata;if(t&&0{throw n.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:a}),t}).then(t=>{var e=self.performance.now();return n.trigger($.FRAG_DECRYPTED,{frag:a,payload:t,stats:{tstart:i,tdecrypt:e}}),r.payload=t,r})}return r}).then(t=>{var{fragCurrent:e,hls:r,levels:n}=this;if(!n)throw new Error("init load aborted, missing levels");n=a.stats;this.state=L.IDLE,i.fragmentError=0,a.data=new Uint8Array(t.payload),n.parsing.start=n.buffering.start=self.performance.now(),n.parsing.end=n.buffering.end=self.performance.now(),t.frag===e&&r.trigger($.FRAG_BUFFERED,{stats:n,frag:e,part:null,id:a.type}),this.tick()}).catch(t=>{this.state!==L.STOPPED&&this.state!==L.ERROR&&(this.warn(t),this.resetFragmentLoading(a))})}fragContextChanged(t){var e=this["fragCurrent"];return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var r=this.mediaBuffer||this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===A?"level":"track"} ${t.level} (frag:[${(null!=(e=t.startPTS)?e:NaN).toFixed(3)}-${(null!=(e=t.endPTS)?e:NaN).toFixed(3)}] > buffer:${r?$r.toString(S.getBuffered(r)):"(detached)"})`),this.state=L.IDLE,r&&(!this.loadedmetadata&&t.type==A&&r.buffered.length&&(null==(e=this.fragCurrent)?void 0:e.sn)===(null==(t=this.fragPrevious)?void 0:t.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){var e,r,n=this["transmuxer"];n&&({frag:t,part:e,partsLoaded:r}=t,r=!r||0===r.length||r.some(t=>!t),t=new Cr(t.level,t.sn,t.stats.chunkCount+1,0,e?e.index:-1,!r),n.flush(t))}_handleFragmentLoadProgress(t){}_doFragLoad(e,r,n=null,i){var a=null==r?void 0:r.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let s=null;if(!e.encrypted||null!=(o=e.decryptdata)&&o.key?!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments):(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} `+e.level),this.state=L.KEY_LOADING,this.fragCurrent=e,s=this.keyLoader.load(e).then(t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger($.KEY_LOADED,t),this.state===L.KEY_LOADING&&(this.state=L.IDLE),t}),this.hls.trigger($.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(s=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),n=Math.max(e.start,n||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){var o=a.partList;if(o&&i){n>e.end&&a.fragmentHint&&(e=a.fragmentHint);var l=this.getNextPart(o,e,n);if(-1!t||this.fragContextChanged(t.frag)?null:this.doFragPartsLoad(e,h,r,i)).catch(t=>this.handleFragLoadError(t)):this.doFragPartsLoad(e,h,r,i).catch(t=>this.handleFragLoadError(t)),this.hls.trigger($.FRAG_LOADING,{frag:e,part:h,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):t}if(!e.url||this.loadedEndOfParts(o,n))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: `+parseFloat(n.toFixed(3))),N(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=L.FRAG_LOADING;const u=this.config.progressive;let t;return t=u&&s?s.then(t=>!t||this.fragContextChanged(null==t?void 0:t.frag)?null:this.fragmentLoader.load(e,i)).catch(t=>this.handleFragLoadError(t)):Promise.all([this.fragmentLoader.load(e,u?i:void 0),s]).then(([t])=>(!u&&t&&i&&i(t),t)).catch(t=>this.handleFragLoadError(t)),this.hls.trigger($.FRAG_LOADING,{frag:e,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):t}doFragPartsLoad(o,r,l,u){return new Promise((n,t)=>{var e;const i=[],a=null==(e=l.details)?void 0:e.partList,s=r=>{this.fragmentLoader.loadPart(o,r,u).then(t=>{var e=(i[r.index]=t).part,t=(this.hls.trigger($.FRAG_LOADED,t),ze(l,o.sn,r.index+1)||Qe(a,o.sn,r.index+1));if(!t)return n({frag:o,part:e,partsLoaded:i});s(t)}).catch(t)};s(r)})}handleFragLoadError(t){var e;return"data"in t?(e=t.data,t.data&&e.details===H.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger($.ERROR,e)):this.hls.trigger($.ERROR,{type:K.OTHER_ERROR,details:H.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0}),null}_handleTransmuxerFlush(t){var e,r,n,i=this.getCurrentContext(t);i&&this.state===L.PARSING?({frag:i,part:e,level:r}=i,n=self.performance.now(),i.stats.parsing.end=n,e&&(e.stats.parsing.end=n),this.updateLevelTiming(i,e,r,t.partial)):this.fragCurrent||this.state===L.STOPPED||this.state===L.ERROR||(this.state=L.IDLE)}getCurrentContext(t){var e,r,n,i,{levels:a,fragCurrent:s}=this,{level:t,sn:o,part:l}=t;return null!=a&&a[t]?(a=a[t],(i=(l=-1r&&this.flushMainBuffer(n,t.start)):this.flushMainBuffer(0,t.start))}getFwdBufferInfo(t,e){var r=this.getLoadPosition();return N(r)?this.getFwdBufferInfoAtPos(t,r,e):null}getFwdBufferInfoAtPos(t,e,r){var n=this["config"]["maxBufferHole"],i=S.bufferInfo(t,e,n);if(0===i.len&&void 0!==i.nextStart){r=this.fragmentTracker.getBufferedFrag(e,r);if(r&&i.nextStart=t&&(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0)}getAppendedFrag(t,e=0){t=this.fragmentTracker.getAppendedFrag(t,A);return t&&"fragment"in t?t.fragment:t}getNextFragment(t,e){var r=e.fragments,n=r.length;if(!n)return null;var i=this["config"],a=r[0].start;let s;if(e.live){var o=i.initialLiveManifestSize;if(ne}getNextFragmentLoopLoading(t,e,r,n,i){var a=t.gap,e=this.getNextFragment(this.nextLoadPosition,e);if(null===e)return e;if(t=e,a&&t&&!t.gap&&r.nextStart){e=this.getFwdBufferInfoAtPos(this.mediaBuffer||this.media,r.nextStart,n);if(null!==e&&r.len+e.len>=i)return this.log(`buffer full after gaps in "${n}" playlist starting at sn: `+t.sn),null}return t}mapToInitFragWhenRequired(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment}getNextPart(r,n,i){let a=-1,s=!1,o=!0;for(let t=0,e=r.length;tt.start&&t.loaded}getInitialLiveFragment(t,e){var r,n,i=this.fragPrevious;let a=null;return i?(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+i.programDateTime),a=nr(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),a||((r=i.sn+1)>=t.startSN&&r<=t.endSN&&(r=e[r-t.startSN],i.cc===r.cc)&&(a=r,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn)),a)||(a=(r=e,n=i.cc,rr.search(r,t=>t.ccn?-1:0)))&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn)):null!==(e=this.hls.liveSyncPosition)&&(a=this.getFragmentAtPosition(e,this.bitrateTest?t.fragmentEnd:t.edge,t)),a}getFragmentAtPosition(t,e,r){var n=this["config"];let i=this["fragPrevious"],{fragments:a,endSN:s}=r;var o=r["fragmentHint"],l=n.maxFragLookUpTolerance,u=r.partList,n=!!(n.lowLatencyMode&&null!=u&&u.length&&o);n&&o&&!this.bitrateTest&&(a=a.concat(o),s=o.sn);let h;return(h=th.sn)&&i&&h.level===i.level&&(t=a[1+o],h=h.sn=i-a.maxFragLookUpTolerance&&r<=n,null!==e)&&s.duration>e&&(r${t.startSN} prev-sn: ${o?o.sn:"na"} fragments: `+s),i):r):(this.warn("No fragments in live playlist"),0)}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)}setStartPosition(t,e){let r=this.startPosition;var n,i;-1!==(r=r `+(null==(r=this.fragCurrent)?void 0:r.url)):((r=e.details===H.FRAG_GAP)&&this.fragmentTracker.fragBuffered(o,!0),{action:s,retryCount:i=0,retryConfig:a}=(n=e.errorAction)||{},n&&s===lr&&a?(this.resetStartWhenNotLoaded(null!=(s=this.levelLastLoaded)?s:o.level),s=Ze(a,i),this.warn(`Fragment ${o.sn} of ${t} ${o.level} errored with ${e.details}, retrying loading ${i+1}/${a.maxNumRetry} in ${s}ms`),n.resolved=!0,this.retryDate=self.performance.now()+s,this.state=L.FRAG_LOADING_WAITING_RETRY):a&&n?(this.resetFragmentErrors(t),i{var r,n=i.elementaryStreams[e];return n?(r=n.endPTS-n.startPTS)<=0?(this.warn(`Could not parse fragment ${i.sn} ${e} duration reliably (${r})`),t||!1):(r=s?0:Ve(o,i,n.startPTS,n.endPTS,n.startDTS,n.endDTS),this.hls.trigger($.LEVEL_PTS_UPDATED,{details:o,level:a,drift:r,type:e,frag:i,start:n.startPTS,end:n.endPTS}),!0):t},!1))a.fragmentError=0;else if(null===(null==(e=this.transmuxer)?void 0:e.error)){var e=new Error(`Found no media in fragment ${i.sn} of level ${i.level} resetting transmuxer to fallback to playlist timing`);if(0===a.fragmentError&&(a.fragmentError++,i.gap=!0,this.fragmentTracker.removeFragment(i),this.fragmentTracker.fragBuffered(i,!0)),this.warn(e.message),this.hls.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:i,reason:`Found no media in msn ${i.sn} of level "${a.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=L.PARSED,this.hls.trigger($.FRAG_PARSED,{frag:i,part:t})}else this.warn("level.details undefined")}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(t=null!=(t=this.levelLastLoaded)?t:null==(t=this.fragCurrent)?void 0:t.level)?t:0),this.resetLoadingState())}set state(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}get state(){return this._state}}function Hr(){return self.SourceBuffer||self.WebKitSourceBuffer}function c(t="",e=9e4){return{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Vr{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,r,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,r){}demux(t,e){this.cachedData&&(t=Yt(this.cachedData,t),this.cachedData=null);let r=It(t,0),n=r?r.length:0,i;var a,s,o=this._audioTrack,l=this._id3Track,u=r?Ct(r):void 0,h=t.length;for((null===this.basePTS||0===this.frameIndex&&N(u))&&(this.basePTS=Wr(u,e,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),r&&0{return N(t)?90*t:9e4*e+(r?9e4*r.baseTime/r.timescale:0)};function Yr(t,e){return 255===t[e]&&240==(246&t[e+1])}function qr(t,e){return 1&t[e+1]?7:9}function zr(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function Qr(t,e){return e+1>>6),(60&e[r+2])>>>2);if(!(h.length-1>>6,V.log(`manifest codec:${n}, ADTS type:${i}, samplingIndex:`+c),a=/firefox/i.test(l)?6<=c?(i=5,o=new Array(4),c-3):(i=2,o=new Array(2),c):-1!==l.indexOf("android")?(i=2,o=new Array(2),c):(i=5,o=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&6<=c?c-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(6<=c&&1==s||/vivaldi/i.test(l))||!n&&1==s)&&(i=2,o=new Array(2)),c)),o[0]=i<<3,o[0]|=(14&c)>>1,o[1]|=(1&c)<<7,o[1]|=s<<3,5===i&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[c],channelCount:s,codec:"mp4a.40."+i,manifestCodec:u};t.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+c})}(e,r,n,i))&&(t.config=e.config,t.samplerate=e.samplerate,t.channelCount=e.channelCount,t.codec=e.codec,t.manifestCodec=e.manifestCodec,V.log(`parsed codec:${t.codec}, rate:${e.samplerate}, channels:`+e.channelCount))}function Jr(t){return 9216e4/t}function Zr(t,e,r,n,i){var a,s,n=n+i*Jr(t.samplerate),i=function(t,e){var r=qr(t,e);if(e+r<=t.length){t=zr(t,e)-r;if(0e.length)&&(a=ln(e,r))&&r+a.frameLength<=e.length?(n=n+i*(9e4*a.samplesPerFrame/a.sampleRate),i={unit:e.subarray(r,r+a.frameLength),pts:n,dts:n},t.config=[],t.channelCount=a.channelCount,t.samplerate=a.sampleRate,t.samples.push(i),{sample:i,length:a.frameLength,missing:0}):void 0}function ln(t,e){var r,n,i,a,s,o=t[e+1]>>3&3,l=t[e+1]>>1&3,u=t[e+2]>>4&15,h=t[e+2]>>2&3;if(1!=o&&0!=u&&15!=u&&3!=h)return s=t[e+2]>>1&1,r=t[e+3]>>6,n=3==o?3-l:3==l?3:4,n=1e3*rn[14*n+u-1],u=3==o?0:2==o?1:2,u=nn[3*u+h],h=3==r?1:2,a=8*(o=an[o][l])*(i=sn[l]),o=Math.floor(o*n/u+s)*i,null===en&&(s=(navigator.userAgent||"").match(/Chrome\/(\d+)/i),en=s?parseInt(s[1]):0),!!en&&en<=87&&2==l&&224e3<=n&&0==r&&(t[e+3]=128|t[e+3]),{sampleRate:u,channelCount:h,frameLength:o,samplesPerFrame:a}}function un(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function hn(t,e){return e+1t||(t=(t-=this.bitsAvailable)-((e=t>>3)<<3),this.bytesAvailable-=e,this.loadWord()),this.word<<=t,this.bitsAvailable-=t}readBits(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(32>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){var t=this.skipLZ();return this.readBits(t+1)-1}readEG(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let r=8,n=8;var i;for(let t=0;t{t=new Uint8Array(t);i.set(t,16),this.decrypter.isSync()||this.decryptAacSamples(e,r+1,n)}))}decryptAacSamples(t,e,r){for(;;e++){if(e>=t.length)return void r();if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t);let n=0;for(let t=32;t{a.data=this.getAvcDecryptedUnit(s,t),this.decrypter.isSync()||this.decryptAvcSamples(e,r,n+1,i)})}decryptAvcSamples(t,e,r,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,r=0){if(e>=t.length)return void n();for(var i=t[e].units;!(r>=i.length);r++){var a=i[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(t,e,r,n,a),this.decrypter.isSync())))return}}}}const I=188;class fn{constructor(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=r}static probe(t){t=fn.syncOffset(t);return 0s))return r}o++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:jt[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}}resetInitSegment(t,e,r,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=fn.createTrack("video"),this._audioTrack=fn.createTrack("audio",n),this._id3Track=fn.createTrack("id3"),this._txtTrack=fn.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r,this._duration=n}resetTimeStamp(){}resetContiguity(){var{_audioTrack:t,_avcTrack:e,_id3Track:r}=this;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(r,t,n=!1,e=!1){n||(this.sampleAes=null);let i;var a=this._avcTrack,s=this._audioTrack,o=this._id3Track,l=this._txtTrack;let u=a.pid,h=a.pesData,c=s.pid,d=o.pid,f=s.pesData,p=o.pesData,g=null,v=this.pmtParsed,m=this._pmtId,y=r.length;if(this.remainderData&&(r=Yt(this.remainderData,r),y=r.length,this.remainderData=null),y>4){if((t=e+5+r[e+4])===e+I)continue}else t=e+4;switch(_){case u:A&&(h&&(i=vn(h))&&this.parseAVCPES(a,l,i,!1),h={data:[],size:0}),h&&(h.data.push(r.subarray(t,e+I)),h.size+=e+I-t);break;case c:if(A){if(f&&(i=vn(f)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,i);break;case"mp3":this.parseMPEGPES(s,i)}f={data:[],size:0}}f&&(f.data.push(r.subarray(t,e+I)),f.size+=e+I-t);break;case d:A&&(p&&(i=vn(p))&&this.parseID3PES(o,i),p={data:[],size:0}),p&&(p.data.push(r.subarray(t,e+I)),p.size+=e+I-t);break;case 0:A&&(t+=r[t]+1),m=this._pmtId=(S=r,E=t,(31&S[E+10])<<8|S[E+11]);break;case m:A&&(t+=r[t]+1);var S=function(t,e,r,n){var i={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=(15&t[e+1])<<8|t[e+2],s=e+3+a-4,a=(15&t[e+10])<<8|t[e+11];e+=12+a;for(;e{const{audioTrack:e,videoTrack:r}=n;e.samples&&"aac"===e.segmentCodec?i.decryptAacSamples(e.samples,0,()=>{r.samples?i.decryptAvcSamples(r.samples,0,0,()=>{t(n)}):t(n)}):r.samples&&i.decryptAvcSamples(r.samples,0,0,()=>{t(n)})})}destroy(){this._duration=0}parseAVCPES(a,r,s,t){var e=this.parseAVCNALu(a,s.data);let o=this.avcSample,l,u=!1;s.data=null,o&&e.length&&!a.audFound&&(mn(o,a),o=this.avcSample=pn(!1,s.pts,s.dts,"")),e.forEach(e=>{switch(e.type){case 1:{let t=!1;l=!0;var n=e.data;u&&4t.size-6)return null;var l=i[7];192&l&&(a=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&l?(s=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2,54e5t){r-=t;continue}i=i.subarray(r),t-=r,r=0}u.set(i,n),n+=t}return e&&(e-=l+3),{data:u,pts:a,dts:s,len:e}}}function mn(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,n=r.length;if(!n)return void e.dropped++;r=r[n-1];t.pts=r.pts,t.dts=r.dts}e.samples.push(t)}t.debug.length&&V.log(t.pts+"/"+t.dts+":"+t.debug)}class yn{static getSilentFrame(t,e){if("mp4a.40.2"===t){if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)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===e)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===e)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===e)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===e)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])}}}const En=Math.pow(2,32)-1;class W{static init(){W.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let t;for(t in W.types)W.types.hasOwnProperty(t)&&(W.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),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=(W.HDLR_TYPES={video:e,audio:r},new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),r=new Uint8Array([0,0,0,0,0,0,0,0]),r=(W.STTS=W.STSC=W.STCO=r,W.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),W.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),W.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),W.STSD=new Uint8Array([0,0,0,0,0,0,0,1]),new Uint8Array([105,115,111,109])),n=new Uint8Array([97,118,99,49]),i=new Uint8Array([0,0,0,1]);W.FTYP=W.box(W.types.ftyp,r,i,r,n),W.DINF=W.box(W.types.dinf,W.box(W.types.dref,e))}static box(t,...e){let r=8,n=e.length;for(var i=n;n--;)r+=e[n].byteLength;var a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=255&r,a.set(t,4),n=0,r=8;n>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,e>>24,e>>16&255,e>>8&255,255&e,85,196,0,0]))}static mdia(t){return W.box(W.types.mdia,W.mdhd(t.timescale,t.duration),W.hdlr(t.type),W.minf(t))}static mfhd(t){return W.box(W.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}static minf(t){return"audio"===t.type?W.box(W.types.minf,W.box(W.types.smhd,W.SMHD),W.DINF,W.stbl(t)):W.box(W.types.minf,W.box(W.types.vmhd,W.VMHD),W.DINF,W.stbl(t))}static moof(t,e,r){return W.box(W.types.moof,W.mfhd(t),W.traf(r,e))}static moov(t){let e=t.length;for(var r=[];e--;)r[e]=W.trak(t[e]);return W.box.apply(null,[W.types.moov,W.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(W.mvex(t)))}static mvex(t){let e=t.length;for(var r=[];e--;)r[e]=W.trex(t[e]);return W.box.apply(null,[W.types.mvex,...r])}static mvhd(t,e){e*=t;var r=Math.floor(e/(1+En)),e=Math.floor(e%(1+En)),t=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,e>>24,e>>16&255,e>>8&255,255&e,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 W.box(W.types.mvhd,t)}static sdtp(t){var e,r=t.samples||[],n=new Uint8Array(4+r.length);let i;for(i=0;i>>8&255),e.push(255&a),e=e.concat(Array.prototype.slice.call(i));for(n=0;n>>8&255),r.push(255&a),r=r.concat(Array.prototype.slice.call(i));var s=W.box(W.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|t.sps.length].concat(e).concat([t.pps.length]).concat(r))),o=t.width,l=t.height,u=t.pixelRatio[0],h=t.pixelRatio[1];return W.box(W.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,o>>8&255,255&o,l>>8&255,255&l,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]),s,W.box(W.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),W.box(W.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,h>>24,h>>16&255,h>>8&255,255&h])))}static esds(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){var e=t.samplerate;return W.box(W.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]),W.box(W.types.esds,W.esds(t)))}static mp3(t){var e=t.samplerate;return W.box(W.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0]))}static stsd(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?W.box(W.types.stsd,W.STSD,W.mp3(t)):W.box(W.types.stsd,W.STSD,W.mp4a(t)):W.box(W.types.stsd,W.STSD,W.avc1(t))}static tkhd(t){var e=t.id,r=t.duration*t.timescale,n=t.width,t=t.height,i=Math.floor(r/(1+En)),r=Math.floor(r%(1+En));return W.box(W.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,r>>24,r>>16&255,r>>8&255,255&r,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,t>>8&255,255&t,0,0]))}static traf(t,e){var r=W.sdtp(t),n=t.id,i=Math.floor(e/(1+En)),e=Math.floor(e%(1+En));return W.box(W.types.traf,W.box(W.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),W.box(W.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,e>>24,e>>16&255,e>>8&255,255&e])),W.trun(t,r.length+16+20+8+16+8+8),r)}static trak(t){return t.duration=t.duration||4294967295,W.box(W.types.trak,W.tkhd(t),W.mdia(t))}static trex(t){t=t.id;return W.box(W.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){var r,n,i,a,s=t.samples||[],o=s.length,l=12+16*o,u=new Uint8Array(l);let h;for(u.set(["video"===t.type?1:0,0,15,1,o>>>24&255,o>>>16&255,o>>>8&255,255&o,(e+=8+l)>>>24&255,e>>>16&255,e>>>8&255,255&e],0),h=0;h>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,i.isLeading<<2|i.dependsOn,i.isDependedOn<<6|i.hasRedundancy<<4|i.paddingValue<<1|i.isNonSync,61440&i.degradPrio,15&i.degradPrio,a>>>24&255,a>>>16&255,a>>>8&255,255&a],12+16*h);return W.box(W.types.trun,u)}static initSegment(t){W.types||W.init();var t=W.moov(t),e=new Uint8Array(W.FTYP.byteLength+t.byteLength);return e.set(W.FTYP),e.set(t,W.FTYP.byteLength),e}}W.types=void 0,W.HDLR_TYPES=void 0,W.STTS=void 0,W.STSC=void 0,W.STCO=void 0,W.STSZ=void 0,W.VMHD=void 0,W.SMHD=void 0,W.STSD=void 0,W.FTYP=void 0,W.DINF=void 0;const Tn=9e4;function bn(t,e,r=1,n=!1){t=t*e*r;return n?Math.round(t):t}function An(t,e=!1){return bn(t,1e3,1/Tn,e)}let _n=null,Sn=null;class Ln{constructor(t,e,r,n=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.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===_n&&(t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i),_n=t?parseInt(t[1]):0),null===Sn&&(e=navigator.userAgent.match(/Safari\/(\d+)/i),Sn=e?parseInt(e[1]):0)}destroy(){}resetTimeStamp(t){V.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){V.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){V.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let n=!1;t=t.reduce((t,e)=>{var r=e.pts-t;return r<-4294967296?(n=!0,Y(t,e.pts)):0=a[0].pts)&&(d=u,r=a[0].pts-M,a[0].dts=d,a[0].pts=r,V.log(`Video: First PTS/DTS adjusted: ${An(r,!0)}/${An(d,!0)}, delta: ${An(M,!0)} ms`)),d=Math.max(0,d);let E=0,T=0;for(let t=0;t0<=t.pts)).length)return;g=0===n?0:e&&!d?Math.max(0,v):f[0].pts}if("aac"===i.segmentCodec){var y=this.config.maxAudioFramesDrift;for(let r=0,n=g;rt.pts-e.pts);var t=e.samples;return e.samples=[],{samples:t}}}class wn{constructor(t,e,r,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=r,this.cts=n,this.flags=new In(t)}}class In{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}function Dn(t,e){t=null==t?void 0:t.codec;return t&&4{e=function(t){var e=t[0];let r="",n="",i=0,a=0,s=0,o=0,l=0,u=0;if(0===e){for(;"\0"!==v(t.subarray(u,u+1));)r+=v(t.subarray(u,u+1)),u+=1;for(r+=v(t.subarray(u,u+1)),u+=1;"\0"!==v(t.subarray(u,u+1));)n+=v(t.subarray(u,u+1)),u+=1;n+=v(t.subarray(u,u+1)),u+=1,i=R(t,12),a=R(t,16),o=R(t,20),l=R(t,24),u=28}else if(1===e){u+=4,i=R(t,u);var e=R(t,u+=4),h=R(t,u+=4);for(u+=4,s=2**32*e+h,J(s)||(s=Number.MAX_SAFE_INTEGER,V.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=R(t,u),u+=4,l=R(t,u),u+=4;"\0"!==v(t.subarray(u,u+1));)r+=v(t.subarray(u,u+1)),u+=1;for(r+=v(t.subarray(u,u+1)),u+=1;"\0"!==v(t.subarray(u,u+1));)n+=v(t.subarray(u,u+1)),u+=1;n+=v(t.subarray(u,u+1)),u+=1}return e=t.subarray(u,t.byteLength),{schemeIdUri:r,value:n,timeScale:i,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:e}}(e);if(tn.test(e.schemeIdUri)){var r=N(e.presentationTime)?e.presentationTime/e.timeScale:n+e.presentationTimeDelta/e.timeScale;let t=4294967295===e.eventDuration?Number.POSITIVE_INFINITY:e.eventDuration/e.timeScale;t<=.001&&(t=Number.POSITIVE_INFINITY);e=e.payload;i.samples.push({data:e,len:e.byteLength,dts:r,pts:r,type:Ce,duration:t})}}),i}demuxSampleAes(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,r,n){this.audioCodec=e,this.videoCodec=r,this.generateInitSegment(function(t,e){if(t&&e){const n=e.keyId;n&&e.isCommonEncryption&&w(t,["moov","trak"]).forEach(t=>{t=w(t,["mdia","minf","stbl","stsd"])[0].subarray(8);let e=w(t,["enca"]);const r=0{w(r?t.subarray(28):t.subarray(78),["sinf"]).forEach(t=>{var e,t=Vt(t);t&&!(e=t.subarray(8,24)).some(t=>0!==t)&&(V.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${g.hexDump(e)} -> `+g.hexDump(n)),t.set(n,8))})})})}return t}(t,n)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:r}=this;var n,i;null!=t&&t.byteLength?(n=this.initData=Ht(t),e=e||Dn(n.audio,y),r=r||Dn(n.video,k),i={},n.audio&&n.video?i.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:n.audio?i.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:n.video?i.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:V.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i):(this.initTracks=void 0,this.initData=void 0)}remux(r,n,i,a,s,o){let{initPTS:l,lastEndTime:u}=this;var h={audio:void 0,video:void 0,text:a,id3:i,initSegment:void 0},n=(N(u)||(u=this.lastEndTime=s||0),n.samples);if(null!=n&&n.length){var c={initPTS:void 0,timescale:1};let e=this.initData;if(null!=(g=e)&&g.length||(this.generateInitSegment(n),e=this.initData),null!=(g=e)&&g.length){this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var d,f,p,g=Wt(n,e),v=(d=e,w(n,["moof","traf"]).reduce((t,e)=>{const n=w(e,["tfdt"])[0],i=n[0];e=w(e,["tfhd"]).reduce((e,r)=>{r=R(r,4),r=d[r];if(r){let t=R(n,4);if(1===i){if(t===Bt)return V.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t=(t*=1+Bt)+R(n,8)}r=r.timescale||9e4,r=t/r;if(N(r)&&(null===e||rn}(l,v,s,g)||c.timescale!==l.timescale&&o)&&(c.initPTS=v-s,l&&1===l.timescale&&V.warn("Adjusting initPTS by "+(c.initPTS-l.baseTime)),this.initPTS=l={baseTime:c.initPTS,timescale:1}),r?v-l.baseTime/l.timescale:u),r=o+g,v=(f=e,p=l.baseTime/l.timescale,w(n,["moof","traf"]).forEach(e=>{w(e,["tfhd"]).forEach(t=>{t=R(t,4),t=f[t];if(t){const i=t.timescale||9e4;w(e,["tfdt"]).forEach(t=>{var e,r=t[0];let n=R(t,4);0===r?(n-=p*i,Kt(t,4,n=Math.max(n,0))):(n=(n=(n*=Math.pow(2,32))+R(t,8))-p*i,n=Math.max(n,0),r=Math.floor(n/(1+Bt)),e=Math.floor(n%(1+Bt)),Kt(t,4,r),Kt(t,8,e))})}})}),0=r.length?void 0:!((i=zr(r,n))<=a)&&((a=n+i)===r.length||Qr(r,a)))return V.log("ADTS sync word found !"),!0}return!1}canParse(t,e){return(e=e)+5<(t=t).length&&Yr(t,e)&&zr(t,e)<=t.length-e}appendFrame(t,e,r){Xr(t,this.observer,e,r,t.manifestCodec);t=Zr(t,e,r,this.basePTS,this.frameIndex);if(t&&0===t.missing)return t}},remux:Ln},{demux:class extends Vr{resetInitSegment(t,e,r,n){super.resetInitSegment(t,e,r,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e){if(e){let t=(It(e,0)||[]).length;for(var r=e.length;t{t=this.push(t,null,r);return this.decryptionPromise=null,t}),this.decryptionPromise;{let t=v.softwareDecrypt(a,g.key.buffer,g.iv.buffer);var m=-1this.flush(e));const a=[];var i=n["timeOffset"],{demuxer:r,remuxer:n}=(r&&(n=r.flush())&&a.push(this.push(n,null,e)),this);return r&&n?Mn(n=r.flush(i))?n.then(t=>(this.flushRemux(a,t,e),a)):(this.flushRemux(a,n,e),a):(t.executeEnd=Cn(),[On(e)])}flushRemux(t,e,r){var{audioTrack:e,videoTrack:n,id3Track:i,textTrack:a}=e,{accurateTimeOffset:s,timeOffset:o}=this.currentTransmuxState,e=(V.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${-1{return{remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,n,!1,this.id),chunkMeta:i}})}configureTransmuxer(r){var{config:t,observer:e,typeSupported:n,vendor:i}=this;let a;for(let t=0,e=Pn.length;t({remuxResult:{},chunkMeta:t});function Mn(t){return"then"in t&&t.then instanceof Function}class Fn{constructor(t,e,r,n,i){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=r,this.duration=n,this.defaultInitPts=i||null}}class Nn{constructor(t,e,r,n,i,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=r,this.trackSwitch=n,this.timeOffset=i,this.initSegmentChange=a}}var Bn,D,t={exports:{}};function Un(){}function jn(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function Gn(t,e,r,n,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");r=new jn(r,n||t,i),n=D?D+e:e;return t._events[n]?t._events[n].fn?t._events[n]=[t._events[n],r]:t._events[n].push(r):(t._events[n]=r,t._eventsCount++),t}function $n(t,e){0==--t._eventsCount?t._events=new Un:delete t._events[e]}function r(){this._events=new Un,this._eventsCount=0}e=t,Bn=Object.prototype.hasOwnProperty,D="~",Object.create&&(Un.prototype=Object.create(null),(new Un).__proto__||(D=!1)),r.prototype.eventNames=function(){var t,e,r=[];if(0===this._eventsCount)return r;for(e in t=this._events)Bn.call(t,e)&&r.push(D?e.slice(1):e);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},r.prototype.listeners=function(t){var t=D?D+t:t,e=this._events[t];if(!e)return[];if(e.fn)return[e.fn];for(var r=0,n=e.length,i=new Array(n);r!1};class Vn{constructor(t,e,r,n){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const i=t.config;this.hls=t,this.id=e,this.useWorker=!!i.enableWorker,this.onTransmuxComplete=r,this.onFlush=n;var a,s,t=(t,e)=>{(e=e||{}).frag=this.frag,e.id=this.id,t===$.ERROR&&(this.error=e.error),this.hls.trigger(t,e)},r=(this.observer=new Kn,this.observer.on($.FRAG_DECRYPTED,t),this.observer.on($.ERROR,t),{mp4:Hn.isTypeSupported("video/mp4"),mpeg:Hn.isTypeSupported("audio/mpeg"),mp3:Hn.isTypeSupported('audio/mp4; codecs="mp3"')}),n=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker&&(i.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__)){try{i.workerPath?(V.log(`loading Web Worker ${i.workerPath} for "${e}"`),this.workerContext=(s=i.workerPath,s=new self.URL(s,self.location.href).href,{worker:new self.Worker(s),scriptURL:s})):(V.log(`injecting Web Worker for "${e}"`),this.workerContext=(a=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),a=self.URL.createObjectURL(a),{worker:new self.Worker(a),objectURL:a})),this.onwmsg=t=>this.onWorkerMessage(t);var o=this.workerContext["worker"];o.addEventListener("message",this.onwmsg),o.onerror=t=>{t=new Error(`${t.message} (${t.filename}:${t.lineno})`);i.enableWorker=!1,V.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger($.ERROR,{type:K.OTHER_ERROR,details:H.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})},o.postMessage({cmd:"init",typeSupported:r,vendor:n,id:e,config:JSON.stringify(i)})}catch(t){V.warn(`Error setting up "${e}" Web Worker, fallback to inline`,t),this.resetWorker(),this.error=null,this.transmuxer=new xn(this.observer,r,i,n,e)}return}this.transmuxer=new xn(this.observer,r,i,n,e)}resetWorker(){var t,e;this.workerContext&&({worker:t,objectURL:e}=this.workerContext,e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null)}destroy(){this.workerContext?(this.resetWorker(),this.onwmsg=void 0):(t=this.transmuxer)&&(t.destroy(),this.transmuxer=null);var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,r,n,i,a,s,o,l,u){var h=(l.transmuxing.start=self.performance.now(),this)["transmuxer"],c=(a||i).start,d=i.decryptdata,f=this.frag,p=!(f&&i.cc===f.cc),g=!(f&&l.level===f.level),v=f?l.sn-f.sn:-1,m=this.part?l.part-this.part.index:-1,y=0==v&&1{this.handleTransmuxComplete(t)}).catch(t=>{this.transmuxerError(t,l,"transmuxer-interface push error")})):(h.async=!1,this.handleTransmuxComplete(m)))}flush(e){e.transmuxing.start=self.performance.now();var r=this["transmuxer"];if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(r){let t=r.flush(e);Mn(t)||r.async?(t=Mn(t)?t:Promise.resolve(t)).then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(t,e)}}transmuxerError(t,e,r){this.hls&&(this.error=t,this.hls.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:r}))}handleFlushResult(t,e){t.forEach(t=>{this.handleTransmuxComplete(t)}),this.onFlush(e)}onWorkerMessage(t){var e=t.data,r=this.hls;switch(e.event){case"init":var n=null==(n=this.workerContext)?void 0:n.objectURL;n&&self.URL.revokeObjectURL(n);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":V[e.data.logType]&&V[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data)}}configureTransmuxer(t){var e=this["transmuxer"];this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}class Wn{constructor(t,e,r,n){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=r,this.hls=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){var{config:r,media:n,stalled:i}=this;if(null!==n){var{currentTime:a,seeking:s}=n,o=this.seeking&&!s,l=!this.seeking&&s;if(this.seeking=s,a!==t)this.moved=!0,null!==i&&(this.stallReported&&(t=self.performance.now()-i,V.warn(`playback not stuck anymore @${a}, after ${Math.round(t)}ms`),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0);else if(l||o)this.stalled=null;else if(!(n.paused&&!s||n.ended||0===n.playbackRate)&&S.getBuffered(n).length){t=S.bufferInfo(n,a,0),l=0r.maxBufferHole||t.nextStart&&t.nextStart-i1e3*r.highBufferWatchdogPeriod&&(V.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}}_reportStall(t){var{hls:e,media:r,stallReported:n}=this;!n&&r&&(this.stallReported=!0,n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(t)})`),V.warn(n.message),e.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:t.len}))}_trySkipBufferHole(e){var{config:t,hls:r,media:n}=this;if(null!==n){var i=n.currentTime,a=S.bufferInfo(n,i,0),s=it.maxBufferHole){var u=this["fragmentTracker"];let t=!1;if(!(t=0===i&&(o=u.getAppendedFrag(0,A))&&si.end&&(this.backtrackFragment=null);var o,s=this.backtrackFragment?this.backtrackFragment.start:i.end;let t=this.getNextFragment(s,a);this.couldBacktrack&&!this.fragPrevious&&t&&"initSegment"!==t.sn&&this.fragmentTracker.getState(t)!==Tr?(n=(null!=(n=this.backtrackFragment)?n:t).sn-a.startSN,(n=a.fragments[n-1])&&t.cc===n.cc&&(t=n,this.fragmentTracker.removeFragment(n))):this.backtrackFragment&&i.len&&(this.backtrackFragment=null),t&&this.isLoopLoading(t,s)&&(t.gap||(o=((n=this.audioOnly&&!this.altAudio?y:k)===k?this.videoBuffer:this.mediaBuffer)||this.media)&&this.afterBufferFlushed(o,n,A),t=this.getNextFragmentLoopLoading(t,a,i,A,e)),t&&(!t.initSegment||t.initSegment.data||this.bitrateTest||(t=t.initSegment),this.loadFragment(t,r,s))}}}}}}loadFragment(t,e,r){var n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===mr||n===Er?"initSegment"===t.sn?this._loadInitSegment(t,e):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,e)):(this.startFragRequested=!0,super.loadFragment(t,e,r)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,A)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){var{levels:e,media:r}=this;if(null!=r&&r.readyState){let t;var n=this.getAppendedFrag(r.currentTime),n=(n&&1{(i=t.audioCodec)&&(-1!==i.indexOf("mp4a.40.2")&&(r=!0),-1!==i.indexOf("mp4a.40.5"))&&(n=!0)}),this.audioCodecSwitch=r&&n&&!("function"==typeof(null==(a=Hr())||null==(a=a.prototype)?void 0:a.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){var r=this["levels"];r&&this.state===L.IDLE&&(!(r=r[e.level]).details||r.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(r.details))&&(this.state=L.WAITING_LEVEL)}onLevelLoaded(t,e){var r=this["levels"],n=e.level,i=e.details,a=i.totalduration;if(r){this.log(`Level ${n} loaded [${i.startSN},${i.endSN}]${i.lastPartSn?`[part-${i.lastPartSn}-${i.lastPartIndex}]`:""}, cc [${i.startCC}, ${i.endCC}] duration:`+a);a=r[n],r=this.fragCurrent;!r||this.state!==L.FRAG_LOADING&&this.state!==L.FRAG_LOADING_WAITING_RETRY||r.level===e.level&&r.urlId===a.urlId||!r.loader||this.abortCurrentFrag();let t=0;if(i.live||null!=(e=a.details)&&e.live){if(this.checkLiveUpdate(i),i.deltaUpdateFailed)return;t=this.alignPlaylists(i,a.details)}if(a.details=i,this.levelLastLoaded=n,this.hls.trigger($.LEVEL_UPDATED,{details:i,level:n}),this.state===L.WAITING_LEVEL){if(this.waitForCdnTuneIn(i))return;this.state=L.IDLE}this.startFragRequested?i.live&&this.synchronizeToLiveEdge(i):this.setStartPosition(i,t),this.tick()}else this.warn("Levels were reset while loading level "+n)}_handleFragmentLoadProgress(t){var e,r,n,i,a,s,o,{frag:t,part:l,payload:u}=t,h=this["levels"];h?(e=(h=h[t.level]).details)?(r=h.videoCodec,n=e.PTSKnown||!e.live,i=null==(i=t.initSegment)?void 0:i.data,h=this._getAudioCodec(h),a=this.transmuxer=this.transmuxer||new Vn(this.hls,A,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),o=-1!==(s=l?l.index:-1),s=new Cr(t.level,t.sn,t.stats.chunkCount,u.byteLength,s,o),o=this.initPTS[t.cc],a.push(u,i,h,r,t,l,e.totalduration,n,s,o)):(this.warn(`Dropping fragment ${t.sn} of level ${t.level} after level details were reset`),this.fragmentTracker.removeFragment(t)):this.warn(`Levels were reset while fragment load was in progress. Fragment ${t.sn} of level ${t.level} will not be buffered`)}onAudioTrackSwitching(t,e){var r,n=this.altAudio;!e.url&&(this.mediaBuffer!==this.media?(this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media,(r=this.fragCurrent)&&(this.log("Switching to main audio track, cancel main fragment load"),r.abortRequests(),this.fragmentTracker.removeFragment(r)),this.resetTransmuxer(),this.resetLoadingState()):this.audioOnly&&this.resetTransmuxer(),r=this.hls,n&&(r.trigger($.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),r.trigger($.AUDIO_TRACK_SWITCHED,e))}onAudioTrackSwitched(t,e){var r,e=e.id,e=!!this.hls.audioTracks[e].url;e&&(r=this.videoBuffer)&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r),this.altAudio=e,this.tick()}onBufferCreated(t,e){var r=e.tracks;let n,i,a=!1;for(const o in r){var s=r[o];"main"===s.id?(i=o,n=s,"video"===o&&(s=r[o])&&(this.videoBuffer=s.buffer)):a=!0}a&&n?(this.log(`Alternate track found, use ${i}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){var r,{frag:e,part:n}=e;e&&e.type!==A||(this.fragContextChanged(e)?(this.warn(`Fragment ${e.sn}${n?" p: "+n.index:""} of level ${e.level} finished buffering, but was aborted. state: `+this.state),this.state===L.PARSED&&(this.state=L.IDLE)):(r=(n||e).stats,this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),"initSegment"!==e.sn&&(this.fragPrevious=e),this.fragBufferedComplete(e,n)))}onError(t,e){var r;if(e.fatal)this.state=L.ERROR;else switch(e.details){case H.FRAG_GAP:case H.FRAG_PARSING_ERROR:case H.FRAG_DECRYPT_ERROR:case H.FRAG_LOAD_ERROR:case H.FRAG_LOAD_TIMEOUT:case H.KEY_LOAD_ERROR:case H.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(A,e);break;case H.LEVEL_LOAD_ERROR:case H.LEVEL_LOAD_TIMEOUT:case H.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==L.WAITING_LEVEL||(null==(r=e.context)?void 0:r.type)!==Te||(this.state=L.IDLE);break;case H.BUFFER_FULL_ERROR:e.parent&&"main"===e.parent&&this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case H.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}checkBuffer(){var t,{media:e,gapController:r}=this;e&&r&&e.readyState&&(!this.loadedmetadata&&S.getBuffered(e).length||(t=this.state!==L.IDLE?this.fragCurrent:null,r.poll(this.lastCurrentTime,t)),this.lastCurrentTime=e.currentTime)}onFragLoadEmergencyAborted(){this.state=L.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){var r;(e!==y||this.audioOnly&&!this.altAudio)&&(r=(e===k?this.videoBuffer:this.mediaBuffer)||this.media,this.afterBufferFlushed(r,e,A))}onLevelsUpdated(t,e){this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){var e=this["media"];if(e){var r,n=e.currentTime;let t=this.startPosition;0<=t&&n{var e,r=this["hls"];t&&!this.fragContextChanged(n)&&(i.fragmentError=0,this.state=L.IDLE,this.startFragRequested=!1,this.bitrateTest=!1,(e=n.stats).parsing.start=e.parsing.end=e.buffering.start=e.buffering.end=self.performance.now(),r.trigger($.FRAG_LOADED,t),n.bitrateTest=!1)})}_handleTransmuxComplete(t){var e="main",r=this["hls"],{remuxResult:t,chunkMeta:n}=t,i=this.getCurrentContext(n);if(i){var{frag:i,part:a,level:s}=i,{video:o,text:l,id3:u,initSegment:h}=t,c=s["details"],d=this.altAudio?void 0:t.audio;if(this.fragContextChanged(i))this.fragmentTracker.removeFragment(i);else{if(this.state=L.PARSING,h&&(null!=h&&h.tracks&&(f=i.initSegment||i,this._bufferInitSegment(s,h.tracks,f,n),r.trigger($.FRAG_PARSING_INIT_SEGMENT,{frag:f,id:e,tracks:h.tracks})),s=h.initPTS,f=h.timescale,N(s))&&(this.initPTS[i.cc]={baseTime:s,timescale:f},r.trigger($.INIT_PTS_FOUND,{frag:i,id:e,initPTS:s,timescale:f})),o&&c&&"initSegment"!==i.sn){var h=c.fragments[i.sn-1-c.startSN],s=i.sn===c.startSN,f=!h||i.cc>h.cc;if(!1!==t.independent){var{startPTS:h,endPTS:t,startDTS:p,endDTS:g}=o;if(a)a.elementaryStreams[o.type]={startPTS:h,endPTS:t,startDTS:p,endDTS:g};else if(o.firstKeyFrame&&o.independent&&1===n.id&&!f&&(this.couldBacktrack=!0),o.dropped&&o.independent){var v=this.getMainFwdBufferInfo(),v=(v?v.end:this.getLoadPosition())+this.config.maxBufferHole,m=o.firstKeyFramePTS||h;if(!s&&v{var e=r[t].initSegment;null!=e&&e.byteLength&&this.hls.trigger($.BUFFER_APPENDING,{type:t,data:e,frag:n,part:null,chunkMeta:i,parent:n.type})}),this.tick()}}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer||this.media,A)}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=L.IDLE}checkFragmentChanged(){var t,e=this.media;let r=null;e&&1=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class Qn{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){var{chunks:t,dataLength:e}=this;let r;return t.length?(r=1===t.length?t[0]:function(e,t){var r=new Uint8Array(t);let n=0;for(let t=0;te[t]!==r[t])}(e[t].attrs,r[t].attrs))return!1;return!0}class Jn{constructor(n){this.buffered=void 0;const e=(t,e,r)=>{if(r-1<(e>>>=0))throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${e}) is greater than the maximum bound (${r})`);return n[e][t]};this.buffered={get length(){return n.length},end(t){return e("end",t,n.length)},start(t){return e("start",t,n.length)}}}}function Zn(e){var r=[];for(let t=0;t{e=t}),n={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,t),r}executeNext(e){var{buffers:r,queues:n}=this,r=r[e],n=n[e];if(n.length){var i=n[0];try{i.execute()}catch(t){V.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),i.onError(t),null!=r&&r.updating||(n.shift(),this.executeNext(e))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const ei=ie(),ri=/([ha]vc.)(?:\.[^.,]+)+/;function ni(t){let e=t;return ii.hasOwnProperty(t)&&(e=ii[t]),String.fromCharCode(e)}const ii={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},ai=100,si={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},oi={17:2,18:4,21:6,22:8,23:10,19:13,20:15},li={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},ui={25:2,26:4,29:6,30:8,31:10,27:13,28:15},hi=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class ci{constructor(){this.time=null,this.verboseLevel=0}log(t,e){this.verboseLevel>=t&&(e="function"==typeof e?e():e,V.log(this.time+` [${t}] `+e))}}function di(e){var r=[];for(let t=0;tai&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ai)}moveCursor(t){var e=this.pos+t;if(1=ai?this.logger.log(0,()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1))}clearFromPos(t){let e;for(e=t;e"pacData = "+JSON.stringify(t));let e=t.row-1;if(this.nrRollUpRows&&e"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){var t;null===this.nrRollUpRows?this.logger.log(3,"roll_up but nrRollUpRows not set yet"):(this.logger.log(1,()=>this.getDisplayText()),t=this.currRow+1-this.nrRollUpRows,(t=this.rows.splice(t,1)[0]).clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up"))}getDisplayText(e){e=e||!1;var r=[];let t="";var n;for(let t=0;t<15;t++){var i=this.rows[t].getTextString();i&&(n=t+1,r.push(e?"Row "+n+": '"+i+"'":i.trim()))}return t=0"MODE="+t),"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=t)}insertChars(e){for(let t=0;tt+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory)&&this.outputDataUpdate()}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){var t;this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode&&(t=this.displayedMemory,this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())),this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){var e={flash:!1};e.underline=t%2==1,e.italics=46<=t,e.italics?e.foreground="white":(t=Math.floor(t/2)-16,e.foreground=["white","green","blue","cyan","red","yellow","magenta"][t]),this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){var e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){!this.outputFilter||this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t)}}class yi{constructor(t,e,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new ci;this.channels=[null,new mi(t,e,n),new mi(t+1,r,n)],this.cmdHistory=bi(),this.logger=n}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let r;let n=!1;this.logger.time=t;for(let t=0;t ("+di([a,s])+")"),(r=(r=(r=(r=this.parseCmd(a,s))||this.parseMidrow(a,s))||this.parsePAC(a,s))||this.parseBackgroundAttributes(a,s))||(n=this.parseChars(a,s))&&((i=this.currentChannel)&&0t)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var _i=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;const E=["","lr","rl"],e=["start","middle","end","left","right"];function T(t,e){return"string"==typeof e&&!!Array.isArray(t)&&(e=e.toLowerCase(),!!~t.indexOf(e))&&e}function b(t){return T(e,t)}function A(t){let e=1;for(;e/gi,"\n")}class Ci{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Si,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const n=this;function r(){var t=n.buffer;let e=0;for(t=Di(t);e>>0).toString()};function Mi(t,e,r){return Oi(t.toString())+Oi(e.toString())+Oi(r)}function Fi(t,o,l,u,h,e,r){const n=new Ci;var i,a,t=T(new Uint8Array(t)).trim().replace(xi,"\n").split("\n");const c=[],d=o?([i,a=1]=[o.baseTime,o.timescale],bn(i,Tn,1/a)):0;let s="00:00.000",f=0,p=0,g,v=!0;n.oncue=function(t){var r=l[u];let e=l.ccOffset;var n,i=(f-d)/9e4;if(null!=r&&r.new)if(void 0!==p)e=l.ccOffset=r.start;else{var a=l;r=u;var s=i;let t=a[r],e=a[t.prevCC];if(!e||!e.new&&t.new)a.ccOffset=a.presentationOffset=t.start,t.new=!1;else{for(;null!=(n=e)&&n.new;)a.ccOffset+=t.start-e.start,t.new=!1,e=a[(t=e).prevCC];a.presentationOffset=s}}if(i){if(!o)return void(g=new Error("Missing initPTS for VTT MPEGTS"));e=i-l.presentationOffset}r=t.endTime-t.startTime,s=Y(9e4*(t.startTime+e-p),9e4*h)/9e4,t.startTime=Math.max(s,0),t.endTime=Math.max(s+r,0),i=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(i)),t.id||(t.id=Mi(t.startTime,t.endTime,i)),0{if(v){if(Pi(t,"X-TIMESTAMP-MAP=")){v=!1,t.slice(16).split(",").forEach(t=>{Pi(t,"LOCAL:")?s=t.slice(6):Pi(t,"MPEGTS:")&&(f=parseInt(t.slice(7)))});try{p=function(t){var e=parseInt(t.slice(-3)),r=parseInt(t.slice(-6,-4)),n=parseInt(t.slice(-9,-7)),i=9T(t));[e,i,a=1,s=!1]=[e.baseTime,1,e.timescale];const o=bn(e,i,1/a,s);try{t.forEach(t=>r(function(t,a){const e=new DOMParser,r=e.parseFromString(t,"text/xml"),n=r.getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(i).reduce((t,e)=>(t[e]=n.getAttribute("ttp:"+e)||i[e],t),{}),o="preserve"!==n.getAttribute("xml:space"),l=Ki($i(n,"styling","style")),u=Ki($i(n,"layout","region")),h=$i(n,"body","[begin]");return[].map.call(h,t=>{var e=function n(t,i){return[].slice.call(t.childNodes).reduce((t,e,r)=>{return"br"===e.nodeName&&r?t+"\n":null!=(r=e.childNodes)&&r.length?n(e,i):i?t+e.textContent.trim().replace(/\s+/g," "):t+e.textContent},"")}(t,o);if(!e||!t.hasAttribute("begin"))return null;var r=Wi(t.getAttribute("begin"),s),n=Wi(t.getAttribute("dur"),s);let i=Wi(t.getAttribute("end"),s);if(null===r)throw Vi(t);if(null===i){if(null===n)throw Vi(t);i=r+n}n=new _i(r-a,i-a,e),n.id=Mi(n.startTime,n.endTime,n.text),r=u[t.getAttribute("region")],e=function(n,i,t){const a="http://www.w3.org/ns/ttml#styling";let s=null;var e=null!=n&&n.hasAttribute("style")?n.getAttribute("style"):null;e&&t.hasOwnProperty(e)&&(s=t[e]);return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((t,e)=>{var r=Hi(i,a,e)||Hi(n,a,e)||Hi(s,a,e);return r&&(t[e]=r),t},{})}(r,l[t.getAttribute("style")],l),r=e.textAlign;return r&&((t=ji[r])&&(n.lineAlign=t),n.align=r),G(n,e),n}).filter(t=>null!==t)}(t,o)))}catch(t){n(t)}}}function $i(t,e,r){t=t.getElementsByTagName(e)[0];return t?[].slice.call(t.querySelectorAll(r)):[]}function Ki(t){return t.reduce((t,e)=>{var r=e.getAttribute("xml:id");return r&&(t[r]=e),t},{})}function Hi(t,e,r){return t&&t.hasAttributeNS(e,r)?t.getAttributeNS(e,r):null}function Vi(t){return new Error("Could not parse ttml timestamp "+t)}function Wi(t,e){if(!t)return null;let r=Li(t);var n,i,a;return null===r&&(Bi.test(t)?r=(n=t,i=e,n=Bi.exec(n),a=(0|n[4])+(0|n[5])/i.subFrameRate,3600*(0|n[1])+60*(0|n[2])+(0|n[3])+a/i.frameRate):Ui.test(t)&&(r=function(t,e){var t=Ui.exec(t),r=Number(t[1]),t=t[2];switch(t){case"h":return 3600*r;case"m":return 60*r;case"ms":return 1e3*r;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}(t,e))),r}function Yi(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class qi{constructor(t){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=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){var t=this["hls"];t.on($.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on($.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on($.MANIFEST_PARSED,this.onManifestParsed,this),t.on($.BUFFER_CODECS,this.onBufferCodecs,this),t.on($.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){var t=this["hls"];t.off($.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off($.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off($.MANIFEST_PARSED,this.onManifestParsed,this),t.off($.BUFFER_CODECS,this.onBufferCodecs,this),t.off($.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){e=this.hls.levels[e.droppedLevel];this.isLevelAllowed(e)&&this.restrictedLevels.push({bitrate:e.bitrate,height:e.height,width:e.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){var r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){var t,e;this.media&&0this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping)}getMaxLevel(r){var t=this.hls.levels;return t.length?(t=t.filter((t,e)=>this.isLevelAllowed(t)&&e<=r),this.clientRect=null,qi.getMaxLevelByMediaSize(t,this.mediaWidth,this.mediaHeight)):-1}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){var t,e,r;return this.clientRect||(e={width:0,height:0},(t=this.media)&&(r=t.getBoundingClientRect(),e.width=r.width,e.height=r.height,e.width||e.height||(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)),this.clientRect=e)}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return t}isLevelAllowed(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}static getMaxLevelByMediaSize(e,r,n){if(null==e||!e.length)return-1;var i;let a=e.length-1;for(let t=0;t=r||s.height>=n)&&(s=s,!(i=e[t+1])||s.width!==i.width||s.height!==i.height)){a=t;break}}return a}}const zi="[eme]";class Qi{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Qi.CDMCleanupPromise?[Qi.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=V.debug.bind(V,zi),this.log=V.log.bind(V,zi),this.warn=V.warn.bind(V,zi),this.error=V.error.bind(V,zi),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();var t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on($.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on($.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on($.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on($.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off($.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off($.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off($.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off($.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){var{drmSystems:e,widevineLicenseUrl:r}=this.config,e=e[t];if(e)return e.licenseUrl;if(t===p.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){var e=this.config["drmSystems"],e=e[t];if(e)return e.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){var e=this.hls.levels,r=(t,e,r)=>!!t&&r.indexOf(t)===e;const s=e.map(t=>t.audioCodec).filter(r),o=e.map(t=>t.videoCodec).filter(r);return s.length+o.length===0&&o.push("avc1.42e01e"),new Promise((n,i)=>{const a=e=>{const r=e.shift();this.getMediaKeysPromise(r,s,o).then(t=>n({keySystem:r,mediaKeys:t})).catch(t=>{e.length?a(e):t instanceof h?i(t):i(new h({type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};a(t)})}requestMediaKeySystemAccess(t,e){var r=this.config["requestMediaKeySystemAccessFunc"];if("function"==typeof r)return r(t,e);{let t="Configured requestMediaKeySystemAccess is not a function "+r;return null===Lt&&"http:"===self.location.protocol&&(t="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(t))}}getMediaKeysPromise(n,t,e){t=function(t,e,r,n){let i;switch(t){case p.FAIRPLAY:i=["cenc","sinf"];break;case p.WIDEVINE:case p.PLAYREADY:i=["cenc"];break;case p.CLEARKEY:i=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+t)}var a=i,s=n;return[a={initDataTypes:a,persistentState:s.persistentState||"not-allowed",distinctiveIdentifier:s.distinctiveIdentifier||"not-allowed",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:e.map(t=>({contentType:`audio/mp4; codecs="${t}"`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null})),videoCapabilities:r.map(t=>({contentType:`video/mp4; codecs="${t}"`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null}))}]}(n,t,e,this.config.drmSystemOptions);const r=this.keySystemAccessPromises[n];let i=null==r?void 0:r.keySystemAccess;if(i)return i.then(()=>r.mediaKeys);{this.log(`Requesting encrypted media "${n}" key-system access with config: `+JSON.stringify(t)),i=this.requestMediaKeySystemAccess(n,t);const a=this.keySystemAccessPromises[n]={keySystemAccess:i};return i.catch(t=>{this.log(`Failed to obtain access to key-system "${n}": `+t)}),i.then(t=>{this.log(`Access for key-system "${t.keySystem}" obtained`);const r=this.fetchServerCertificate(n);return this.log(`Create media-keys for "${n}"`),a.mediaKeys=t.createMediaKeys().then(e=>(this.log(`Media-keys created for "${n}"`),r.then(t=>t?this.setMediaKeysServerCertificate(e,n,t):e))),a.mediaKeys.catch(t=>{this.error(`Failed to create media-keys for "${n}"}: `+t)}),a.mediaKeys})}}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:r}){this.log(`Creating key-system session "${e}" keyId: `+g.hexDump(t.keyId||[]));var n=r.createSession(),t={decryptdata:t,keySystem:e,mediaKeys:r,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(t),t}renewKeySession(t){var e,r,n=t.decryptdata;n.pssh?(e=this.createMediaKeySessionContext(t),r=this.getKeyIdString(n),this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(e,"cenc",n.pssh,"expired")):this.warn("Could not renew expired session. Missing pssh initData."),this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return g.hexDump(t.keyId)}updateKeySession(t,e){var r=t.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${g.hexDump((null==(t=t.decryptdata)?void 0:t.keyId)||[])} } (data length: ${e&&e.byteLength})`),r.update(e)}selectKeySystemFormat(t){var e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats `+e.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(i){return new Promise((r,n)=>{const e=St(this.config);var t=i.map(bt).filter(t=>!!t&&-1!==e.indexOf(t));return this.getKeySystemSelectionPromise(t).then(({keySystem:t})=>{var e=_t(t);e?r(e):n(new Error(`Unable to find format for key-system "${t}"`))}).catch(n)})}loadKey(t){const n=t.keyInfo.decryptdata;var e=this.getKeyIdString(n);const i=`(keyId: ${e} format: "${n.keyFormat}" method: ${n.method} uri: ${n.uri})`;this.log("Starting session for key "+i);let r=this.keyIdToKeySessionPromise[e];return r||(r=this.keyIdToKeySessionPromise[e]=this.getKeySystemForKeyPromise(n).then(({keySystem:e,mediaKeys:r})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key `+i),this.attemptSetMediaKeys(e,r).then(()=>{this.throwIfDestroyed();var t=this.createMediaKeySessionContext({keySystem:e,mediaKeys:r,decryptdata:n});return this.generateRequestWithPreferredKeySession(t,"cenc",n.pssh,"playlist-key")})))).catch(t=>this.handleError(t)),r}throwIfDestroyed(t=0){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof h?this.hls.trigger($.ERROR,t.data):this.hls.trigger($.ERROR,{type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){var e=this.getKeyIdString(t),e=this.keyIdToKeySessionPromise[e];return e||(t=(e=bt(t.keyFormat))?[e]:St(this.config),this.attemptKeySystemAccess(t))}getKeySystemSelectionPromise(t){if(0===(t=t.length?t:St(this.config)).length)throw new h({type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)}_onMediaEncrypted(e){const{initDataType:a,initData:s}=e;if(this.debug(`"${e.type}" event: init data type: "${a}"`),null!==s){let i,t;if("sinf"===a&&this.config.drmSystems[p.FAIRPLAY]){e=v(new Uint8Array(s));try{var r=ft(JSON.parse(e).sinf),n=Vt(new Uint8Array(r));if(!n)return;i=n.subarray(8,24),t=p.FAIRPLAY}catch(t){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{e=function(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;var r={version:0,systemId:"",kids:null,data:null},t=new DataView(e),n=t.getUint32(0);if(e.byteLength!==n&&44>>24,1this.generateRequestWithPreferredKeySession(d,a,s,"encrypted-event-key-match"));break}}}(e=e||(o[c]=this.getKeySystemSelectionPromise([t]).then(({keySystem:e,mediaKeys:r})=>{var t;this.throwIfDestroyed();const n=new Zt("ISO-23001-7",c,null!=(t=_t(e))?t:"");return n.pssh=new Uint8Array(s),n.keyId=i,this.attemptSetMediaKeys(e,r).then(()=>{this.throwIfDestroyed();var t=this.createMediaKeySessionContext({decryptdata:n,keySystem:e,mediaKeys:r});return this.generateRequestWithPreferredKeySession(t,a,s,"encrypted-event-no-match")})}))).catch(t=>this.handleError(t))}}}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const r=this.setMediaKeysQueue.slice(),n=(this.log(`Setting media-keys for "${t}"`),Promise.all(r).then(()=>{if(this.media)return this.media.setMediaKeys(e);throw new Error("Attempted to set mediaKeys without media element attached")}));return this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${t}"`),r.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(t=>-1===r.indexOf(t))})}generateRequestWithPreferredKeySession(n,t,e,r){var i=null==(i=this.config.drmSystems)||null==(i=i[n.keySystem])?void 0:i.generateRequest;if(i)try{var a=i.call(this.hls,t,e,n);if(!a)throw new Error("Invalid response from configured generateRequest filter");t=a.initDataType,e=n.decryptdata.pssh=a.initData?new Uint8Array(a.initData):null}catch(t){if(this.warn(t.message),null!=(i=this.hls)&&i.config.debug)throw t}if(null===e)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(n);const s=this.getKeyIdString(n.decryptdata),o=(this.log(`Generating key-session request for "${r}": ${s} (init data type: ${t} length: ${e?e.byteLength:null})`),new Kn),l=(n.mediaKeysSession.onmessage=t=>{var e,r=n.mediaKeysSession;r?({messageType:t,message:e}=t,this.log(`"${t}" message event for session "${r.sessionId}" message size: `+e.byteLength),"license-request"===t||"license-renewal"===t?this.renewLicense(n,e).catch(t=>{this.handleError(t),o.emit("error",t)}):"license-release"===t?n.keySystem===p.FAIRPLAY&&(this.updateKeySession(n,vt("acknowledged")),this.removeSession(n)):this.warn(`unhandled media key message type "${t}"`)):o.emit("error",new Error("invalid state"))},n.mediaKeysSession.onkeystatuseschange=t=>{var e;n.mediaKeysSession?(this.onKeyStatusChange(n),e=n.keyStatus,o.emit("keyStatus",e),"expired"===e&&(this.warn(n.keySystem+" expired for key "+s),this.renewKeySession(n))):o.emit("error",new Error("invalid state"))},new Promise((e,r)=>{o.on("error",r),o.on("keyStatus",t=>{t.startsWith("usable")?e():"output-restricted"===t?r(new h({type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===t?r(new h({type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${t}"`)):"expired"===t?r(new Error("key expired while generating request")):this.warn(`unhandled key status change "${t}"`)})}));return n.mediaKeysSession.generateRequest(t,e).then(()=>{var t;this.log(`Request generated for key-session "${null==(t=n.mediaKeysSession)?void 0:t.sessionId}" keyId: `+s)}).catch(t=>{throw new h({type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_NO_SESSION,error:t,fatal:!1},"Error generating key-session request: "+t)}).then(()=>l).catch(t=>{throw o.removeAllListeners(),this.removeSession(n),t}).then(()=>(o.removeAllListeners(),n))}onKeyStatusChange(r){r.mediaKeysSession.keyStatuses.forEach((t,e)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${g.hexDump("buffer"in e?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e))} session keyId: ${g.hexDump(new Uint8Array(r.decryptdata.keyId||[]))} uri: `+r.decryptdata.uri),r.keyStatus=t})}fetchServerCertificate(o){const r=this.config;const n=new r.loader(r),l=this.getServerCertificateUrl(o);return l?(this.log(`Fetching serverCertificate for "${o}"`),new Promise((i,a)=>{const s={responseType:"arraybuffer",url:l};var t=r.certLoadPolicy.default,t={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},e={onSuccess:(t,e,r,n)=>{i(t.data)},onError:(t,e,r,n)=>{a(new h({type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:f({url:s.url,data:void 0},t)},`"${o}" certificate request failed (${l}). Status: ${t.code} (${t.text})`))},onTimeout:(t,e,r)=>{a(new h({type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:s.url,data:void 0}},`"${o}" certificate request timed out (${l})`))},onAbort:(t,e,r)=>{a(new Error("aborted"))}};n.load(s,t,e)})):Promise.resolve()}setMediaKeysServerCertificate(n,i,a){return new Promise((e,r)=>{n.setServerCertificate(a).then(t=>{this.log(`setServerCertificate ${t?"success":"not supported by CDM"} (${null==a?void 0:a.byteLength}) on "${i}"`),e(n)}).catch(t=>{r(new h({type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:t,fatal:!0},t.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new h({type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)}))}setupLicenseXHR(e,r,n,i){const a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>{if(n.decryptdata)return a.call(this.hls,e,r,n,i);throw new Error("Key removed")}).catch(t=>{if(n.decryptdata)return e.open("POST",r,!0),a.call(this.hls,e,r,n,i);throw t}).then(t=>{return e.readyState||e.open("POST",r,!0),{xhr:e,licenseChallenge:t||i}}):(e.open("POST",r,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(a,s){const o=this.config.keyLoadPolicy.default;return new Promise((r,t)=>{const n=this.getLicenseServerUrl(a.keySystem),i=(this.log("Sending license request to URL: "+n),new XMLHttpRequest);i.responseType="arraybuffer",i.onreadystatechange=()=>{if(!this.hls||!a.mediaKeysSession)return t(new Error("invalid state"));if(4===i.readyState)if(200===i.status){this._requestLicenseFailureCount=0;let t=i.response;this.log("License received "+(t instanceof ArrayBuffer?t.byteLength:t));var e=this.config.licenseResponseCallback;if(e)try{t=e.call(this.hls,i,n,a)}catch(t){this.error(t)}r(t)}else{var e=o.errorRetry,e=e?e.maxNumRetry:0;this._requestLicenseFailureCount++,this._requestLicenseFailureCount>e||400<=i.status&&i.status<500?t(new h({type:K.KEY_SYSTEM_ERROR,details:H.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:{url:n,data:void 0,code:i.status,text:i.statusText}},`License Request XHR failed (${n}). Status: ${i.status} (${i.statusText})`)):(e=e-this._requestLicenseFailureCount+1,this.warn(`Retrying license request, ${e} attempts left`),this.requestLicense(a,s).then(r,t))}},a.licenseXhr&&a.licenseXhr.readyState!==XMLHttpRequest.DONE&&a.licenseXhr.abort(),a.licenseXhr=i,this.setupLicenseXHR(i,n,a,s).then(({xhr:t,licenseChallenge:e})=>{t.send(e)})})}onMediaAttached(t,e){this.config.emeEnabled&&(e=e.media,(this.media=e).addEventListener("encrypted",this.onMediaEncrypted),e.addEventListener("waitingforkey",this.onWaitingForKey))}onMediaDetached(){const e=this.media,t=this.mediaKeySessions,r=(e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Zt.clearKeyUriToKeyIdMap(),t.length);Qi.CDMCleanupPromise=Promise.all(t.map(t=>this.removeSession(t)).concat(null==e?void 0:e.setMediaKeys(null).catch(t=>{this.log(`Could not clear media keys: ${t}. media.src: `+(null==e?void 0:e.src))}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(t=>{this.log(`Could not close sessions and clear media keys: ${t}. media.src: `+(null==e?void 0:e.src))})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){e&&this.config.emeEnabled&&(this.keyFormatPromise||(e=e.reduce((t,e)=>(-1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t),[]),this.log("Selecting key-system from session-keys "+e.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(e)))}removeSession(t){const{mediaKeysSession:e,licenseXhr:r}=t;if(e)return this.log("Remove licenses and keys and close session "+e.sessionId),e.onmessage=null,e.onkeystatuseschange=null,r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0,-1<(t=this.mediaKeySessions.indexOf(t))&&this.mediaKeySessions.splice(t,1),e.remove().catch(t=>{this.log("Could not remove session: "+t)}).then(()=>e.close()).catch(t=>{this.log("Could not close session: "+t)})}}Qi.CDMCleanupPromise=void 0;class h extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),(this.data=t).err=t.error}}var Xi="m",Ji="a",Zi="v",ta="av",ea="i",ra="tt";class na{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=t=>{try{this.apply(t,{ot:Xi,su:!this.initialized})}catch(t){V.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=t=>{try{var e=t.frag,r=this.hls.levels[e.level],n=this.getObjectType(e),i={d:1e3*e.duration,ot:n};n!==Zi&&n!==Ji&&n!=ta||(i.br=r.bitrate/1e3,i.tb=this.getTopBandwidth(n)/1e3,i.bl=this.getBufferLength(n)),this.apply(t,i)}catch(t){V.warn("Could not generate segment CMCD data.",t)}},this.hls=t;var t=this.config=t.config,e=t["cmcd"];null!=e&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=e.sessionId||na.uuid(),this.cid=e.contentId,this.useHeaders=!0===e.useHeaders,this.registerListeners())}registerListeners(){var t=this.hls;t.on($.MEDIA_ATTACHED,this.onMediaAttached,this),t.on($.MEDIA_DETACHED,this.onMediaDetached,this),t.on($.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){var t=this.hls;t.off($.MEDIA_ATTACHED,this.onMediaAttached,this),t.off($.MEDIA_DETACHED,this.onMediaDetached,this),t.off($.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(t,e){var r;this.audioBuffer=null==(r=e.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(r=e.tracks.video)?void 0:r.buffer}createData(){var t;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){G(e,this.createData());var r=e.ot===ea||e.ot===Zi||e.ot===ta;this.starved&&r&&(e.bs=!0,e.su=!0,this.starved=!1),null==e.su&&(e.su=this.buffering),this.useHeaders?(r=na.toHeaders(e),Object.keys(r).length&&(t.headers||(t.headers={}),G(t.headers,r))):(r=na.toQuery(e))&&(t.url=na.appendQueryToUri(t.url,r))}getObjectType(t){var e=t["type"];return"subtitle"===e?ra:"initSegment"===t.sn?ea:"audio"===e?Ji:"main"===e?this.hls.audioTracks.length?Zi:ta:void 0}getTopBandwidth(t){let e=0,r;var n=this.hls;for(const i of r=t===Ji?n.audioTracks:(t=-1<(t=n.maxAutoLevel)?t+1:n.levels.length,n.levels.slice(0,t)))i.bitrate>e&&(e=i.bitrate);return 0Math.round(t);var n=t=>100*e(t/100),i={br:e,d:e,bl:n,dl:n,mtp:n,nor:t=>encodeURIComponent(t),rtp:n,tb:e};for(const s of Object.keys(t||{}).sort()){let e=t[s];if((a=e,!Number.isNaN(a)&&null!=a&&""!==a&&!1!==a)&&!("v"===s&&1===e||"pr"==s&&1===e)){var a=i[s],a=typeof(e=a?a(e):e);let t;t="ot"===s||"sf"===s||"st"===s?s+"="+e:"boolean"==a?s:"number"==a?s+"="+e:s+"="+JSON.stringify(e),r.push(t)}}return r.join(",")}static toHeaders(t){var e={},r=["Object","Request","Session","Status"],n=[{},{},{},{}],i={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const s of Object.keys(t))n[null!=i[s]?i[s]:1][s]=t[s];for(let t=0;t{var t=e.filter(t=>t.groupId===r).map(t=>{var e=G({},t);return e.details=void 0,e.attrs=new B(e.attrs),e.url=e.attrs.URI=aa(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),e.groupId=e.attrs["GROUP-ID"]=n[r],e.attrs["PATHWAY-ID"]=a,e});e.push(...t)})}function aa(t,e,r,n){const{HOST:i,PARAMS:a,[r]:s}=n;let o;e&&(o=null==s?void 0:s[e])&&(t=o);const l=new self.URL(t);return i&&!o&&(l.host=i),a&&Object.keys(a).sort().forEach(t=>{t&&l.searchParams.set(t,a[t])}),l.href}const sa=/^age:\s*[\d.]+\s*$/im;class oa{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new ot,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState)&&(this.stats.aborted=!0,t.abort())}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(t){const r=this.loader=new self.XMLHttpRequest,n=this.stats,i=(n.loading.first=0,n.loaded=0,n.aborted=!1,this.xhrSetup);i?Promise.resolve().then(()=>{if(!this.stats.aborted)return i(r,e.url)}).catch(t=>(r.open("GET",e.url,!0),i(r,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,e,t)}).catch(t=>{this.callbacks.onError({code:r.status,text:t.message},e,r,n)}):this.openAndSendXhr(r,e,t)}}openAndSendXhr(t,e,r){t.readyState||t.open("GET",e.url,!0);var n=this.context.headers,{maxTimeToFirstByteMs:i,maxLoadTimeMs:a}=r.loadPolicy;if(n)for(const s in n)t.setRequestHeader(s,n[s]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),r.timeout=i&&N(i)?i:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()}readystatechange(){var t,e,r,n,{context:i,loader:a,stats:s}=this;i&&a&&(e=a.readyState,t=this.config,s.aborted||2<=e&&(0===s.loading.first&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),t.timeout!==t.loadPolicy.maxLoadTimeMs)&&(self.clearTimeout(this.requestTimeout),t.timeout=t.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start))),4===e)&&(self.clearTimeout(this.requestTimeout),a.onreadystatechange=null,a.onprogress=null,e=a.status,n="text"!==a.responseType,200<=e&&e<300&&(n&&a.response||null!==a.responseText)?(s.loading.end=Math.max(self.performance.now(),s.loading.first),n=n?a.response:a.responseText,r="arraybuffer"===a.responseType?n.byteLength:n.length,s.loaded=s.total=r,s.bwEstimate=8e3*s.total/(s.loading.end-s.loading.first),this.callbacks&&((r=this.callbacks.onProgress)&&r(s,i,n,a),this.callbacks)&&(r={url:a.responseURL,data:n,code:e},this.callbacks.onSuccess(r,s,i,a))):er(n=t.loadPolicy.errorRetry,s.retry,!1,e)?this.retry(n):(V.error(e+" while loading "+i.url),this.callbacks.onError({code:e,text:a.statusText},i,a,s))))}loadtimeout(){var t=null==(t=this.config)?void 0:t.loadPolicy.timeoutRetry;er(t,this.stats.retry,!0)?this.retry(t):(V.warn("timeout while loading "+this.context.url),(t=this.callbacks)&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader)))}retry(t){var{context:e,stats:r}=this;this.retryDelay=Ze(t,r.retry),r.retry++,V.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${r.retry}/${t.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;var e;return this.loader&&sa.test(this.loader.getAllResponseHeaders())&&(e=this.loader.getResponseHeader("age"),t=e?parseFloat(e):null),t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}const la=/(\d+)-(\d+)\/(\d+)/;class ua{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||ha,this.controller=new self.AbortController,this.stats=new ot}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){var t=this.response;null!=t&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(n,i,a){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();var t=function(t,e){e={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(G({},t.headers))};t.rangeEnd&&e.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1));return e}(n,this.controller.signal);const o=a.onProgress,l="arraybuffer"===n.responseType,u=l?"byteLength":"length",{maxTimeToFirstByteMs:e,maxLoadTimeMs:h}=i.loadPolicy;this.context=n,this.config=i,this.callbacks=a,this.request=this.fetchSetup(n,t),self.clearTimeout(this.requestTimeout),i.timeout=e&&N(e)?e:h,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),a.onTimeout(s,n,this.response)},i.timeout),self.fetch(this.request).then(t=>{this.response=this.loader=t;var e,r=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),i.timeout=h,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),a.onTimeout(s,n,this.response)},h-(r-s.loading.start)),t.ok)return s.loading.first=r,s.total=function(t){var e=t.get("Content-Range");if(e){e=function(t){t=la.exec(t);if(t)return parseInt(t[2])-parseInt(t[1])+1}(e);if(N(e))return e}e=t.get("Content-Length");if(e)return parseInt(e)}(t.headers)||s.total,o&&N(i.highWaterMark)?this.loadProgressively(t,s,n,i.highWaterMark,o):l?t.arrayBuffer():"json"===n.responseType?t.json():t.text();throw{status:r,statusText:e}=t,new ca(e||"fetch, bad network response",r,t)}).then(t=>{var e=this["response"],r=(self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first),t[u]),r=(r&&(s.loaded=s.total=r),{url:e.url,data:t,code:e.status});o&&!N(i.highWaterMark)&&o(s,n,t,e),a.onSuccess(r,s,n,e)}).catch(t=>{var e,r;self.clearTimeout(this.requestTimeout),s.aborted||(e=t&&t.code||0,r=t?t.message:null,a.onError({code:e,text:r},n,t?t.details:null,s))})}getCacheAge(){let t=null;var e;return this.response&&(e=this.response.headers.get("age"),t=e?parseFloat(e):null),t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(r,n,i,a=0,s){const o=new Qn,t=r.body.getReader(),l=()=>t.read().then(t=>{var e;return t.done?(o.dataLength&&s(n,i,o.flush(),r),Promise.resolve(new ArrayBuffer(0))):(e=(t=t.value).length,n.loaded+=e,e=a&&s(n,i,o.flush(),r)):s(n,i,t,r),l())}).catch(()=>Promise.reject());return l()}}function ha(t,e){return new self.Request(t.url,e)}class ca extends Error{constructor(t,e,r){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=r}}const da=/\s/,fa={newCue(e,r,n,i){var a,s=[];let o,l,u;var h,c=self.VTTCue||self.TextTrackCue;for(let t=0;t"auto"===t.line||"auto"===e.line?0:8ke(e,t))),s}};const pa=f(f({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:oa,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class{constructor(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0;t=(this.hls=t).config;this.bwEstimator=new zn(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){var t=this["hls"];t.on($.FRAG_LOADING,this.onFragLoading,this),t.on($.FRAG_LOADED,this.onFragLoaded,this),t.on($.FRAG_BUFFERED,this.onFragBuffered,this),t.on($.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on($.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){var t=this["hls"];t.off($.FRAG_LOADING,this.onFragLoading,this),t.off($.FRAG_LOADED,this.onFragLoaded,this),t.off($.FRAG_BUFFERED,this.onFragBuffered,this),t.off($.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off($.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(t,e){var r=e.frag;this.ignoreFragment(r)||(this.fragCurrent=r,this.partCurrent=null!=(r=e.part)?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(t,e){this.clearTimer()}getTimeToLoadFrag(t,e,r,n){return t+r/e+(n?this.lastLevelLoadSec:0)}onLevelLoaded(t,e){var r=this.hls.config,{total:n,bwEstimate:i}=e.stats;N(n)&&N(i)&&(this.lastLevelLoadSec=8*n/i),e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}_abandonRulesCheck(){var{fragCurrent:r,partCurrent:n,hls:i}=this,{autoLevelEnabled:a,media:s}=i;if(r&&s){var o=performance.now(),l=(n||r).stats,u=(n||r).duration,o=o-l.loading.start;if(l.aborted||l.loaded&&l.loaded===l.total||0===r.level)this.clearTimer(),this._nextAutoLevel=-1;else if(a&&!s.paused&&s.playbackRate&&s.readyState){a=i.mainForwardBufferInfo;if(null!==a){var h=this.bwEstimator.getEstimateTTFB(),s=Math.abs(s.playbackRate);if(!(o<=Math.max(h,u/(2*s)*1e3))){var c=a.len/s;if(!(2*u/s<=c)){var a=l.loading.first?l.loading.first-l.loading.start:-1,s=l.loaded&&-1p;e--){var y=f[e].maxBitrate;if((t=this.getTimeToLoadFrag(h/1e3,m,u*y,!f[e].details))=g||t>10*u||(i.nextLoadLevel=e,s?this.bwEstimator.sample(o-Math.min(h,a),l.loaded):this.bwEstimator.sampleTTFB(o),this.clearTimer(),V.warn(`[abr] Fragment ${r.sn}${n?" part "+n.index:""} of level ${r.level} is loading too slowly; Time to underbuffer: ${c.toFixed(3)} s Estimated load time for current fragment: ${g.toFixed(3)} s Estimated load time for down switch fragment: ${t.toFixed(3)} s TTFB estimate: ${a} Current BW estimate: ${N(d)?(d/1024).toFixed(3):"Unknown"} Kb/s New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s Aborting and switching to level `+e),r.loader&&(this.fragCurrent=this.partCurrent=null,r.abortRequests()),i.trigger($.FRAG_LOAD_EMERGENCY_ABORTED,{frag:r,part:n,stats:l}))}}}}}}}onFragLoaded(t,{frag:e,part:r}){var n,i,a,s=(r||e).stats;e.type===A&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),this.ignoreFragment(e)||(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate&&(i=(r||e).duration,n=((a=this.hls.levels[e.level]).loaded?a.loaded.bytes:0)+s.loaded,i=(a.loaded?a.loaded.duration:0)+i,a.loaded={bytes:n,duration:i},a.realBitrate=Math.round(8*n/i)),e.bitrateTest&&(a={stats:s,frag:e,part:r,id:e.type},this.onFragBuffered($.FRAG_BUFFERED,a),e.bitrateTest=!1))}onFragBuffered(t,e){var r,{frag:e,part:n}=e,n=(null!=n&&n.stats.loaded?n:e).stats;n.aborted||this.ignoreFragment(e)||(r=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB()),this.bwEstimator.sample(r,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),e.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0)}ignoreFragment(t){return t.type!==A||"initSegment"===t.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){var t=this._nextAutoLevel,e=this.bwEstimator;if(-1!==t&&!e.canEstimate())return t;let r=this.getNextABRAutoLevel();if(-1!==t){e=this.hls.levels;if(e.length>Math.max(t,r)&&e[t].loadError<=e[r].loadError)return t}return r=-1!==t?Math.min(t,r):r}getNextABRAutoLevel(){var t,{fragCurrent:e,partCurrent:r,hls:n}=this,{maxAutoLevel:i,config:a,minAutoLevel:s,media:o}=n,r=r?r.duration:e?e.duration:0,e=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,o=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,n=n.mainForwardBufferInfo,n=(n?n.len:0)/e,e=this.findBestLevel(o,s,i,n,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(0<=e)return e;V.trace(`[abr] ${n?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let l=r?Math.min(r,a.maxStarvationDelay):a.maxStarvationDelay,u=a.abrBandWidthFactor,h=a.abrBandWidthUpFactor;return n||(t=this.bitrateTestDelay)&&(r=r?Math.min(r,a.maxLoadingDelay):a.maxLoadingDelay,l=r-t,V.trace(`[abr] bitrate test took ${Math.round(1e3*t)}ms, set first fragment max fetchDuration to ${Math.round(1e3*l)} ms`),u=h=1),e=this.findBestLevel(o,s,i,n+l,u,h),Math.max(e,0)}findBestLevel(r,t,n,i,a,s){var e,{fragCurrent:o,partCurrent:l,lastLoadedFragLevel:u}=this,h=this.hls["levels"],c=h[u],d=!(null==c||null==(e=c.details)||!e.live),f=null==c?void 0:c.codecSet,p=l?l.duration:o?o.duration:0,g=this.bwEstimator.getEstimateTTFB()/1e3;let v=t,m=-1;for(let e=n;e>=t;e--){var y=h[e];if(!y||f&&y.codecSet!==f)y&&(v=Math.min(e,v),m=Math.max(e,m));else{-1!==m&&V.trace(`[abr] Skipped level(s) ${v}-${m} with CODECS:"${h[m].attrs.CODECS}"; not compatible with "${c.attrs.CODECS}"`);var y=y.details,E=(l?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||p;let t;t=e<=u?a*r:s*r;var T=h[e].maxBitrate,y=this.getTimeToLoadFrag(g,t,T*E,void 0===y);if(V.trace(`[abr] level:${e} adjustedbw-bitrate:${Math.round(t-T)} avgDuration:${E.toFixed(1)} maxFetchDuration:${i.toFixed(1)} fetchDuration:`+y.toFixed(1)),t>T&&(0===y||!N(y)||d&&!this.bitrateTestDelay||y{var{media:t,mediaSource:e}=this;V.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger($.MEDIA_ATTACHED,{media:t})),e&&e.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{V.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{V.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{var{media:t,_objectUrl:e}=this;t&&t.src!==e&&V.error(`Media element src was set while attaching MediaSource (${e} > ${t.src})`)},this.hls=t,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return 0{var t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(t){V.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,t)}}),this._initSourceBuffer()}onBufferCodecs(t,u){const h=this.getSourceBufferTypes().length;Object.keys(u).forEach(t=>{var e,r,n,i,a,s,o,l;h?(e=this.tracks[t])&&"function"==typeof e.buffer.changeType&&({id:r,codec:n,levelCodec:i,container:a,metadata:s}=u[t],(o=(e.levelCodec||e.codec).replace(ri,"$1"))!==(l=(i||n).replace(ri,"$1")))&&(this.appendChangeType(t,a+";codecs="+(i||n)),V.log(`[buffer-controller]: switching codec ${o} to `+l),this.tracks[t]={buffer:e.buffer,codec:n,container:a,levelCodec:i,metadata:s,id:r}):this.pendingTracks[t]=u[t]}),h||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(e,r){const n=this["operationQueue"];n.append({execute:()=>{var t=this.sourceBuffer[e];t&&(V.log(`[buffer-controller]: changing ${e} sourceBuffer type to `+r),t.changeType(r)),n.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{V.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,t)}},e)}onBufferAppending(t,e){const{hls:r,operationQueue:n,tracks:i}=this,{data:a,type:s,frag:o,part:l,chunkMeta:u}=e,h=u.buffering[s];e=self.performance.now();h.start=e;const c=o.stats.buffering,d=l?l.stats.buffering:null;0===c.start&&(c.start=e),d&&0===d.start&&(d.start=e);e=i.audio;let f=!1;"audio"===s&&"audio/mpeg"===(null==e?void 0:e.container)&&(f=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);const p=o.start;n.append({execute:()=>{var t,e;h.executeStart=self.performance.now(),f&&(t=this.sourceBuffer[s])&&(e=p-t.timestampOffset,.1<=Math.abs(e))&&(V.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${p} (delta: ${e}) sn: ${o.sn})`),t.timestampOffset=p),this.appendExecutor(a,s)},onStart:()=>{},onComplete:()=>{var t=self.performance.now(),e=(h.executeEnd=h.end=t,0===c.first&&(c.first=t),d&&0===d.first&&(d.first=t),this)["sourceBuffer"],r={};for(const s in e)r[s]=S.getBuffered(e[s]);this.appendError=0,this.hls.trigger($.BUFFER_APPENDED,{type:s,frag:o,part:l,chunkMeta:u,parent:o.type,timeRanges:r})},onError:t=>{V.error(`[buffer-controller]: Error encountered while trying to append to the ${s} SourceBuffer`,t);var e={type:K.MEDIA_ERROR,parent:o.type,details:H.BUFFER_APPEND_ERROR,frag:o,part:l,chunkMeta:u,error:t,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=H.BUFFER_FULL_ERROR:(this.appendError++,e.details=H.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(V.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),e.fatal=!0)),r.trigger($.ERROR,e)}},s)}onBufferFlushing(t,r){const e=this["operationQueue"],n=e=>({execute:this.removeExecutor.bind(this,e,r.startOffset,r.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger($.BUFFER_FLUSHED,{type:e})},onError:t=>{V.warn(`[buffer-controller]: Failed to remove from ${e} SourceBuffer`,t)}});r.type?e.append(n(r.type),r.type):this.getSourceBufferTypes().forEach(t=>{e.append(n(t),t)})}onFragParsed(t,e){const{frag:r,part:n}=e;var e=[],i=(n||r).elementaryStreams;i[lt]?e.push("audiovideo"):(i[y]&&e.push("audio"),i[k]&&e.push("video"));0===e.length&&V.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: `+r.sn),this.blockBuffers(()=>{var t=self.performance.now(),t=(r.stats.buffering.end=t,n&&(n.stats.buffering.end=t),(n||r).stats);this.hls.trigger($.FRAG_BUFFERED,{frag:r,part:n,stats:t,id:r.type})},e)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,n){this.getSourceBufferTypes().reduce((t,e)=>{var r=this.sourceBuffer[e];return!r||n.type&&n.type!==e||(r.ending=!0,r.ended)||(r.ended=!0,V.log(`[buffer-controller]: ${e} sourceBuffer now EOS`)),t&&!(r&&!r.ended)},!0)&&(V.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(t=>{t=this.sourceBuffer[t];t&&(t.ending=!1)});var t=this["mediaSource"];t&&"open"===t.readyState?(V.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&V.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState)}))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:n,details:i,media:t,sourceBuffer:a}=this;if(t&&null!==i){var e=this.getSourceBufferTypes();if(e.length){var r=i.live&&null!==n.config.liveBackBufferLength?n.config.liveBackBufferLength:n.config.backBufferLength;if(N(r)&&!(r<0)){const s=t.currentTime,o=i.levelTargetDuration;r=Math.max(r,o);const l=Math.floor(s/o)*o-r;e.forEach(t=>{var e=a[t];if(e){var r=S.getBuffered(e);if(0r.start(0)){if(n.trigger($.BACK_BUFFER_REACHED,{bufferEnd:l}),i.live)n.trigger($.LIVE_BACK_BUFFER_REACHED,{bufferEnd:l});else if(e.ended&&r.end(r.length-1)-s<2*o)return void V.info(`[buffer-controller]: Cannot flush ${t} back buffer while SourceBuffer is in ended state`);n.trigger($.BUFFER_FLUSHING,{startOffset:0,endOffset:l,type:t})}}})}}}}updateMediaElementDuration(){var t,e,r,n,i,a;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&({details:t,hls:e,media:i,mediaSource:r}=this,n=t.fragments[0].start+t.totalduration,i=i.duration,a=N(r.duration)?r.duration:0,t.live&&e.config.liveDurationInfinity?(V.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(t)):(a{e.executeNext(t)})):(n=new Error("could not create source buffer for media codec(s)"),this.hls.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.message})))}createSourceBuffers(t){var{sourceBuffer:e,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const l in t)if(!e[l]){var n=t[l];if(!n)throw Error(`source buffer exists for track ${l}, however track does not`);var i=n.levelCodec||n.codec,a=n.container+";codecs="+i;V.log(`[buffer-controller]: creating sourceBuffer(${a})`);try{var s=e[l]=r.addSourceBuffer(a),o=l;this.addBufferListener(o,"updatestart",this._onSBUpdateStart),this.addBufferListener(o,"updateend",this._onSBUpdateEnd),this.addBufferListener(o,"error",this._onSBUpdateError),this.tracks[l]={buffer:s,codec:i,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(t){V.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:a})}}}_onSBUpdateStart(t){var e=this["operationQueue"];e.current(t).onStart()}_onSBUpdateEnd(t){var e=this["operationQueue"];e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){var r=new Error(t+" SourceBuffer error"),r=(V.error("[buffer-controller]: "+r,e),this.hls.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.BUFFER_APPENDING_ERROR,error:r,fatal:!1}),this.operationQueue.current(t));r&&r.onError(e)}removeExecutor(t,e,r){var{media:n,mediaSource:i,operationQueue:a,sourceBuffer:s}=this,s=s[t];n&&i&&s?(n=N(n.duration)?n.duration:1/0,i=N(i.duration)?i.duration:1/0,(e=Math.max(0,e))<(r=Math.min(r,n,i))&&!s.ending?(s.ended=!1,V.log(`[buffer-controller]: Removing [${e},${r}] from the ${t} SourceBuffer`),s.remove(e,r)):a.shiftAndExecuteNext(t)):(V.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(t))}appendExecutor(t,e){var{operationQueue:r,sourceBuffer:n}=this,n=n[e];n?(n.ended=!1,n.appendBuffer(t)):(V.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),r.shiftAndExecuteNext(e))}blockBuffers(t,e=this.getSourceBufferTypes()){if(e.length){const n=this["operationQueue"];var r=e.map(t=>n.appendBlocker(t));Promise.all(r).then(()=>{t(),e.forEach(t=>{var e=this.sourceBuffer[t];null!=e&&e.updating||n.shiftAndExecuteNext(t)})})}else V.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t)}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,r){var n=this.sourceBuffer[t];n&&(r=r.bind(this,t),this.listeners[t].push({event:e,listener:r}),n.addEventListener(e,r))}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(t=>{e.removeEventListener(t.event,t.listener)})}},capLevelController:qi,errorController:class{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=V.log.bind(V,"[info]:"),this.warn=V.warn.bind(V,"[warning]:"),this.error=V.error.bind(V,"[error]:"),this.registerListeners()}registerListeners(){var t=this.hls;t.on($.ERROR,this.onError,this),t.on($.MANIFEST_LOADING,this.onManifestLoading,this),t.on($.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){var t=this.hls;t&&(t.off($.ERROR,this.onError,this),t.off($.ERROR,this.onErrorOut,this),t.off($.MANIFEST_LOADING,this.onManifestLoading,this),t.off($.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(null==t?void 0:t.type)===A?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){if(!e.fatal){var r,n=this.hls,i=e.context;switch(e.details){case H.FRAG_LOAD_ERROR:case H.FRAG_LOAD_TIMEOUT:case H.KEY_LOAD_ERROR:case H.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case H.FRAG_PARSING_ERROR:if(null!=(a=e.frag)&&a.gap)return void(e.errorAction={action:sr,flags:ur});case H.FRAG_GAP:case H.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=or);case H.LEVEL_EMPTY_ERROR:case H.LEVEL_PARSING_ERROR:var a=e.parent===A?e.level:n.loadLevel;return void(e.details===H.LEVEL_EMPTY_ERROR&&null!=(s=e.context)&&null!=(s=s.levelDetails)&&s.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,a):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,a)));case H.LEVEL_LOAD_ERROR:case H.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==i?void 0:i.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,i.level)));case H.AUDIO_TRACK_LOAD_ERROR:case H.AUDIO_TRACK_LOAD_TIMEOUT:case H.SUBTITLE_LOAD_ERROR:case H.SUBTITLE_TRACK_LOAD_TIMEOUT:if(i){var s=n.levels[n.loadLevel];if(s&&(i.type===E&&i.groupId===s.audioGroupId||i.type===b&&i.groupId===s.textGroupId))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.loadLevel),e.errorAction.action=or,void(e.errorAction.flags=hr)}return;case H.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var a=n.levels[n.loadLevel],s=null==a?void 0:a.attrs["HDCP-LEVEL"];return void(s&&(e.errorAction={action:or,flags:cr,hdcpLevel:s}));case H.BUFFER_ADD_CODEC_ERROR:case H.REMUX_ALLOC_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(a=e.level)?a:n.loadLevel));case H.INTERNAL_EXCEPTION:case H.BUFFER_APPENDING_ERROR:case H.BUFFER_APPEND_ERROR:case H.BUFFER_FULL_ERROR:case H.LEVEL_SWITCH_ERROR:case H.BUFFER_STALLED_ERROR:case H.BUFFER_SEEK_OVER_HOLE:case H.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:sr,flags:ur})}e.type===K.KEY_SYSTEM_ERROR&&(r=this.getVariantLevelIndex(e.frag),e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,r))}}getPlaylistRetryOrSwitchAction(t,e){var r=Je(this.hls.config.playlistLoadPolicy,t),n=this.playlistError++,i=null==(i=t.response)?void 0:i.code;return er(r,n,Xe(t),i)?{action:lr,flags:ur,retryConfig:r,retryCount:n}:(i=this.getLevelSwitchAction(t,e),r&&(i.retryConfig=r,i.retryCount=n),i)}getFragRetryOrSwitchAction(t){var e=this.hls,r=this.getVariantLevelIndex(t.frag),n=e.levels[r],{fragLoadPolicy:i,keyLoadPolicy:a}=e.config,a=Je(t.details.startsWith("key")?a:i,t),i=e.levels.reduce((t,e)=>t+e.fragmentError,0);if(n){t.details!==H.FRAG_GAP&&n.fragmentError++;n=null==(e=t.response)?void 0:e.code;if(er(a,i,Xe(t),n))return{action:lr,flags:ur,retryConfig:a,retryCount:i}}e=this.getLevelSwitchAction(t,r);return a&&(e.retryConfig=a,e.retryCount=i),e}getLevelSwitchAction(r,t){var n=this.hls,i=(null==t&&(t=n.loadLevel),this.hls.levels[t]);if(i&&(i.loadError++,n.autoLevelEnabled)){let e=-1;var{levels:a,loadLevel:s,minAutoLevel:o,maxAutoLevel:l}=n,u=null==(t=r.frag)?void 0:t.type,{type:h,groupId:c}=null!=(t=r.context)?t:{};for(let t=a.length;t--;){var d=(t+s)%a.length;if(d!==s&&o<=d&&d<=l&&0===a[d].loadError){var f=a[d];if(r.details===H.FRAG_GAP&&r.frag){var p=a[d].details;if(p){p=ir(r.frag,p.fragments,r.frag.start);if(null!=p&&p.gap)continue}}else{if(h===E&&c===f.audioGroupId||h===b&&c===f.textGroupId)continue;if(u===_&&i.audioGroupId===f.audioGroupId||u===be&&i.textGroupId===f.textGroupId)continue}e=d;break}}if(-13*n.targetduration)return 1}return}(l,e,n[o]))return this.warn(`Switching to Redundant Stream ${1+u}/${s}: "${a.url[u]}" after `+e.details),this.playlistError=0,r.levels.forEach(t=>{t.urlId=u}),r.nextLoadLevel=i,!0}return!1}penalizeRendition(t,e){var r=this["penalizedRenditions"],n=r[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(e),n.details=t.details,r[t.urlId]=n}},fpsController:class{constructor(t){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=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on($.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off($.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){var r=this.hls.config;r.capLevelOnFPSDrop&&(e=e.media instanceof self.HTMLVideoElement?e.media:null,(this.media=e)&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod))}checkFPS(t,e,r){var n,i,a,s,o=performance.now();e&&(this.lastTime&&(s=o-this.lastTime,n=r-this.lastDroppedFrames,i=e-this.lastDecodedFrames,s=1e3*n/s,(a=this.hls).trigger($.FPS_DROP,{currentDropped:n,currentDecoded:i,totalDroppedFrames:r}),0a.config.fpsDroppedMonitoringThreshold*i&&(s=a.currentLevel,V.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),0=s)&&(s-=1,a.trigger($.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:a.currentLevel}),a.autoLevelCapping=s,this.streamController.nextLevelSwitch()),this.lastTime=o,this.lastDroppedFrames=r,this.lastDecodedFrames=e)}checkFPSInterval(){var t,e=this.media;e&&(this.isVideoPlaybackQualityAvailable?(t=e.getVideoPlaybackQuality(),this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)):this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount))}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Lt,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:fa,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:class extends Kr{constructor(t,e,r){super(t,e,r,"[subtitle-stream-controller]",be),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){var t=this["hls"];t.on($.MEDIA_ATTACHED,this.onMediaAttached,this),t.on($.MEDIA_DETACHING,this.onMediaDetaching,this),t.on($.MANIFEST_LOADING,this.onManifestLoading,this),t.on($.LEVEL_LOADED,this.onLevelLoaded,this),t.on($.ERROR,this.onError,this),t.on($.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on($.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on($.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on($.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on($.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on($.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){var t=this["hls"];t.off($.MEDIA_ATTACHED,this.onMediaAttached,this),t.off($.MEDIA_DETACHING,this.onMediaDetaching,this),t.off($.MANIFEST_LOADING,this.onManifestLoading,this),t.off($.LEVEL_LOADED,this.onLevelLoaded,this),t.off($.ERROR,this.onError,this),t.off($.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off($.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off($.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off($.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off($.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off($.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=L.IDLE,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,r){var{frag:r,success:n}=r;if(this.fragPrevious=r,this.state=L.IDLE,n){var i=this.tracksBuffered[this.currentTrackId];if(i){let e;var a=r.start;for(let t=0;t=i[t].start&&a<=i[t].end){e=i[t];break}n=r.start+r.duration;e?e.end=n:(e={start:a,end:n},i.push(e)),this.fragmentTracker.fragBuffered(r)}}}onBufferFlushing(t,e){var{startOffset:r,endOffset:n}=e;if(0===r&&n!==Number.POSITIVE_INFINITY){const i=n-1;i<=0||(e.endOffsetSubtitles=Math.max(0,i),this.tracksBuffered.forEach(e=>{for(let t=0;tnew Ke(t)):(this.tracksBuffered=[],this.levels=e.map(t=>{t=new Ke(t);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,be),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){this.currentTrackId=e.id,this.levels.length&&-1!==this.currentTrackId?(null!=(e=this.levels[this.currentTrackId])&&e.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,e&&this.setInterval(500)):this.clearInterval()}onSubtitleTrackLoaded(t,e){var{details:e,id:r}=e,{currentTrackId:n,levels:i}=this;if(i.length){var a=i[n];if(!(r>=i.length||r!==n)&&a){this.mediaBuffer=this.mediaBufferTimeRanges;let t=0;if(e.live||null!=(i=a.details)&&i.live){n=this.mainDetails;if(e.deltaUpdateFailed||!n)return;i=n.fragments[0];a.details?0===(t=this.alignPlaylists(e,a.details))&&i&&qe(e,t=i.start):e.hasProgramDateTime&&n.hasProgramDateTime?(Nr(e,n),t=e.fragments[0].start):i&&qe(e,t=i.start)}a.details=e,this.levelLastLoaded=r,this.startFragRequested||!this.mainDetails&&e.live||this.setStartPosition(a.details,t),this.tick(),e.live&&!this.fragCurrent&&this.media&&this.state===L.IDLE&&!ir(null,e.fragments,this.media.currentTime,0)&&(this.warn("Subtitle playlist not aligned with playback"),a.details=void 0)}}}_handleFragmentLoadComplete(t){const{frag:r,payload:e}=t;t=r.decryptdata;const n=this.hls;if(!this.fragContextChanged(r)&&e&&0{throw n.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:r}),t}).then(t=>{var e=performance.now();n.trigger($.FRAG_DECRYPTED,{frag:r,payload:t,stats:{tstart:i,tdecrypt:e}})}).catch(t=>{this.warn(t.name+": "+t.message),this.state=L.IDLE})}}doTick(){if(this.media){if(this.state===L.IDLE){var{currentTrackId:e,levels:r}=this,e=r[e];if(r.length&&e&&e.details){var r=this["config"],n=this.getLoadPosition(),{end:n,len:i}=S.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),a=this.getFwdBufferInfo(this.media,A),s=e.details,a=this.getMaxBufferLength(null==a?void 0:a.len)+s.levelTargetDuration;if(!(athis.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,-1{Re(t)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){var r,{id:n,details:i}=e,a=this["trackId"],a=this.tracksInGroup[a];a?(r=a.details,a.details=e.details,this.log(`subtitle track ${n} loaded [${i.startSN}-${i.endSN}]`),n===this.trackId&&this.playlistLoaded(n,e,r)):this.warn("Invalid subtitle track id "+n)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){t=this.hls.levels[t];if(null!=t&&t.textGroupIds){const i=t.textGroupIds[t.urlId];var e,r,n,t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.groupId!==i?(e=this.tracks.filter(t=>!i||t.groupId===i),this.tracksInGroup=e,r=this.findTrackId(null==t?void 0:t.name)||this.findTrackId(),this.groupId=i||null,n={subtitleTracks:e},this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${i}" group-id`),this.hls.trigger($.SUBTITLE_TRACKS_UPDATED,n),-1!==r&&this.setSubtitleTrack(r,t)):this.shouldReloadPlaylist(t)&&this.setSubtitleTrack(this.trackId,t)}}findTrackId(e){var r=this.tracksInGroup;for(let t=0;tt.groupId===this.groupId),-1===t?[].slice.call(r).forEach(t=>{t.mode="disabled"}):(r=e[n])&&(r.mode="disabled"),n=e[t])&&(n.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var r,n,i,a,s,o=this.tracksInGroup;this.media?(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(-1===t||null!=(r=o[t])&&r.details)||t<-1||t>=o.length||(this.clearTimer(),r=o[t],this.log("Switching to subtitle-track "+t+(r?` "${r.name}" lang:${r.lang} group:`+r.groupId:"")),this.trackId=t,r?({id:o,groupId:n="",name:i,type:a,url:s}=r,this.hls.trigger($.SUBTITLE_TRACK_SWITCH,{id:o,groupId:n,name:i,type:a,url:s}),o=this.switchParams(r.url,null==e?void 0:e.details),this.loadPlaylist(o)):this.hls.trigger($.SUBTITLE_TRACK_SWITCH,{id:t}))):this.queuedDefaultTrack=t}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){let e=-1;var r=Zn(this.media.textTracks);for(let t=0;t{this.onFragLoaded($.FRAG_LOADED,t)}))}getExistingTrack(e){var r=this["media"];if(r)for(let t=0;t{Re(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Yi(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){var t=this["media"];if(t){var e=t.textTracks;if(e)for(let t=0;tt.textCodec===Ni);if(this.config.enableWebVTT||r&&this.config.enableIMSC1)if(Xn(this.tracks,e))this.tracks=e;else if(this.textTracks=[],this.tracks=e,this.config.renderTextTracksNatively){const s=this.media?this.media.textTracks:null;this.tracks.forEach((r,t)=>{let n;if(s&&t({label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t})),this.hls.trigger($.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:r}))}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){var e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),t=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&t)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(t=>{var e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);e&&(e="textTrack"+e[1],e=this.captionsProperties[e])&&(e.label=t.name,t.lang&&(e.languageCode=t.lang),e.media=t)})}closedCaptionsForLevel(t){t=this.hls.levels[t.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){var r,{cea608Parser1:n,cea608Parser2:i,lastSn:a,lastPartIndex:s}=this;this.enabled&&n&&i&&e.frag.type===A&&(r=e.frag.sn,e=null!=(e=null==e||null==(e=e.part)?void 0:e.index)?e:-1,r===a+1||r===a&&e===s+1||(n.reset(),i.reset()),this.lastSn=r,this.lastPartIndex=e)}onFragLoaded(t,e){var r,n,{frag:i,payload:a}=e;i.type===be&&(a.byteLength?(r=i.decryptdata,n="stats"in e,null!=r&&r.encrypted&&!n||(r=this.tracks[i.level],(n=this.vttCCs)[i.cc]||(n[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),r&&r.textCodec===Ni?this._parseIMSC1(i,a):this._parseVTTs(e))):this.hls.trigger($.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")}))}_parseIMSC1(e,t){const r=this.hls;Gi(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger($.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{V.log("Failed to parse IMSC1: "+t),r.trigger($.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(r){var t;const{frag:n,payload:i}=r,{initPTS:e,unparsedVttFrags:a}=this,s=e.length-1;if(e[n.cc]||-1!=s){const o=this.hls;Fi(null!=(t=n.initSegment)&&t.data?Yt(n.initSegment.data,new Uint8Array(i)):i,this.initPTS[n.cc],this.vttCCs,n.cc,n.start,t=>{this._appendCues(t,n.level),o.trigger($.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},t=>{var e="Missing initPTS for VTT MPEGTS"===t.message;e?a.push(r):this._fallbackToIMSC1(n,i),V.log("Failed to parse VTT cue: "+t),e&&s>n.cc||o.trigger($.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:t})})}else a.push(r)}_fallbackToIMSC1(t,e){const r=this.tracks[t.level];r.textCodec||Gi(e,this.initPTS[t.cc],()=>{r.textCodec=Ni,this._parseIMSC1(t,e)},()=>{r.textCodec="wvtt"})}_appendCues(t,e){var r=this.hls;if(this.config.renderTextTracksNatively){const i=this.textTracks[e];i&&"disabled"!==i.mode&&t.forEach(t=>ke(i,t))}else{var n=this.tracks[e];n&&(n=n.default?"default":"subtitles"+e,r.trigger($.CUES_PARSED,{type:"subtitles",cues:t,track:n}))}}onFragDecrypted(t,e){var r=e["frag"];r.type===be&&this.onFragLoaded($.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){var{cea608Parser1:r,cea608Parser2:n}=this;if(this.enabled&&r&&n){var{frag:e,samples:i}=e;if(e.type!==A||"NONE"!==this.closedCaptionsForLevel(e))for(let t=0;twe(s[t],e,r))}if(this.config.renderTextTracksNatively&&0===e&&void 0!==n){const o=this["textTracks"];Object.keys(o).forEach(t=>we(o[t],e,n))}}}extractCea608Data(e){var r=[[],[]],n=31&e[0];let i=2;for(let t=0;th||s.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),a.currentTime=h+.05),this.getNextFragment(t,i)),r=!1;if(e&&this.isLoopLoading(e,t)&&(r=!!e.gap,e=this.getNextFragmentLoopLoading(e,i,s,A,c)),e){u=n&&e.start>n.end+i.targetduration;if(u||(null==n||!n.len)&&s.len){l=this.getAppendedFrag(e.start,A);if(null===l)return;if(r=r||!!l.gap||!!u&&0===n.len,u&&!r||r&&s.nextStart&&s.nextStartnew Ke(t))}onAudioTrackSwitching(t,e){var r=!!e.url,n=(this.trackId=e.id,this)["fragCurrent"];n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.switchingTrack=e,this.state=L.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=L.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(t,e){this.mainDetails=e.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger($.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){if(null==this.mainDetails)this.cachedTrackLoadedData=e;else{var r=this["levels"],{details:e,id:n}=e;if(r){this.log(`Track ${n} loaded [${e.startSN},${e.endSN}]${e.lastPartSn?`[part-${e.lastPartSn}-${e.lastPartIndex}]`:""},duration:`+e.totalduration);r=r[n];let t=0;if(e.live||null!=(i=r.details)&&i.live){this.checkLiveUpdate(e);var i=this.mainDetails;if(e.deltaUpdateFailed||!i)return;t=!r.details&&e.hasProgramDateTime&&i.hasProgramDateTime?(Nr(e,i),e.fragments[0].start):this.alignPlaylists(e,r.details)}r.details=e,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&e.live||this.setStartPosition(r.details,t),this.state!==L.WAITING_TRACK||this.waitForCdnTuneIn(e)||(this.state=L.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+n)}}_handleFragmentLoadProgress(e){var{frag:e,part:r,payload:n}=e,{config:i,trackId:a,levels:s}=this;if(s){s=s[a];if(s){var o=s.details;if(o){i=i.defaultAudioCodec||s.audioCodec||"mp4a.40.2";let t=this.transmuxer;t=t||(this.transmuxer=new Vn(this.hls,_,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var l,u,s=this.initPTS[e.cc],h=null==(h=e.initSegment)?void 0:h.data;void 0!==s?(u=-1!==(l=r?r.index:-1),l=new Cr(e.level,e.sn,e.stats.chunkCount,n.byteLength,l,u),t.push(n,h,i,"",e,r,o.totalduration,!1,l,s)):(this.log(`Unknown video PTS for cc ${e.cc}, waiting for video PTS before demuxing audio frag ${e.sn} of [${o.startSN} ,${o.endSN}],track `+a),u=(this.waitingData=this.waitingData||{frag:e,part:r,cache:new Qn,complete:!1})["cache"],u.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=L.WAITING_INIT_PTS)}else this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(e.start)}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 ${e.sn} of level ${e.level} will not be buffered`)}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){var r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){var r,{frag:e,part:n}=e;e.type!==_?this.loadedmetadata||e.type!==A||(r=this.videoBuffer||this.media)&&S.getBuffered(r).length&&(this.loadedmetadata=!0):this.fragContextChanged(e)?this.warn(`Fragment ${e.sn}${n?" p: "+n.index:""} of level ${e.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: `+(this.switchingTrack?this.switchingTrack.name:"false")):("initSegment"!==e.sn&&(this.fragPrevious=e,r=this.switchingTrack)&&(this.bufferedTrack=r,this.switchingTrack=null,this.hls.trigger($.AUDIO_TRACK_SWITCHED,f({},r))),this.fragBufferedComplete(e,n))}onError(t,e){var r;if(e.fatal)this.state=L.ERROR;else switch(e.details){case H.FRAG_GAP:case H.FRAG_PARSING_ERROR:case H.FRAG_DECRYPT_ERROR:case H.FRAG_LOAD_ERROR:case H.FRAG_LOAD_TIMEOUT:case H.KEY_LOAD_ERROR:case H.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_,e);break;case H.AUDIO_TRACK_LOAD_ERROR:case H.AUDIO_TRACK_LOAD_TIMEOUT:case H.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==L.WAITING_TRACK||(null==(r=e.context)?void 0:r.type)!==E||(this.state=L.IDLE);break;case H.BUFFER_FULL_ERROR:e.parent&&"audio"===e.parent&&this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case H.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushed(t,{type:e}){e===y&&(this.bufferFlushed=!0,this.state===L.ENDED)&&(this.state=L.IDLE)}_handleTransmuxComplete(t){var e,r,n,i,a,s,o,l,u=this["hls"],{remuxResult:t,chunkMeta:h}=t,c=this.getCurrentContext(h);c?({frag:c,part:e,level:r}=c,r=r.details,{audio:t,text:n,id3:i,initSegment:o}=t,this.fragContextChanged(c)||!r?this.fragmentTracker.removeFragment(c):(this.state=L.PARSING,this.switchingTrack&&t&&this.completeAudioSwitch(this.switchingTrack),null!=o&&o.tracks&&(a=c.initSegment||c,this._bufferInitSegment(o.tracks,a,h),u.trigger($.FRAG_PARSING_INIT_SEGMENT,{frag:a,id:"audio",tracks:o.tracks})),t&&({startPTS:a,endPTS:o,startDTS:l,endDTS:s}=t,e&&(e.elementaryStreams[y]={startPTS:a,endPTS:o,startDTS:l,endDTS:s}),c.setElementaryStreamInfo(y,a,o,l,s),this.bufferFragmentData(t,c,e,h)),null!=i&&null!=(a=i.samples)&&a.length&&(o=G({id:"audio",frag:c,details:r},i),u.trigger($.FRAG_PARSING_METADATA,o)),n&&(l=G({id:"audio",frag:c,details:r},n),u.trigger($.FRAG_PARSING_USERDATA,l)))):this.resetWhenMissingContext(h)}_bufferInitSegment(t,e,r){var n;this.state===L.PARSING&&(t.video&&delete t.video,n=t.audio)&&(n.levelCodec=n.codec,n.id="audio",this.log(`Init audio buffer, container:${n.container}, codecs[parsed]=[${n.codec}]`),this.hls.trigger($.BUFFER_CODECS,t),null!=(t=n.initSegment)&&t.byteLength&&(n={type:"audio",frag:e,part:null,chunkMeta:r,parent:e.type,data:t},this.hls.trigger($.BUFFER_APPENDING,n)),this.tick())}loadFragment(t,e,r){var n=this.fragmentTracker.getState(t);this.fragCurrent=t,this.switchingTrack||n===mr||n===Er?"initSegment"===t.sn?this._loadInitSegment(t,e):null!=(n=e.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=L.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,r)):this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){var{hls:e,media:r,bufferedTrack:n}=this,n=null==n?void 0:n.attrs,i=t.attrs;r&&n&&(n.CHANNELS!==i.CHANNELS||n.NAME!==i.NAME||n.LANGUAGE!==i.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger($.AUDIO_TRACK_SWITCHED,f({},t))}},audioTrackController:class extends dr{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){var t=this["hls"];t.on($.MANIFEST_LOADING,this.onManifestLoading,this),t.on($.MANIFEST_PARSED,this.onManifestParsed,this),t.on($.LEVEL_LOADING,this.onLevelLoading,this),t.on($.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on($.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on($.ERROR,this.onError,this)}unregisterListeners(){var t=this["hls"];t.off($.MANIFEST_LOADING,this.onManifestLoading,this),t.off($.MANIFEST_PARSED,this.onManifestParsed,this),t.off($.LEVEL_LOADING,this.onLevelLoading,this),t.off($.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off($.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off($.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){var r,{id:n,groupId:i,details:a}=e,s=this.tracksInGroup[n];s&&s.groupId===i?(r=s.details,s.details=e.details,this.log(`audio-track ${n} "${s.name}" lang:${s.lang} group:${i} loaded [${a.startSN}-${a.endSN}]`),n===this.trackId&&this.playlistLoaded(n,e,r)):this.warn(`Track with id:${n} and group:${i} not found in active group `+s.groupId)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){var e,t=this.hls.levels[t];if(null!=t&&t.audioGroupIds){const r=t.audioGroupIds[t.urlId];this.groupId!==r?(this.groupId=r||null,t=this.tracks.filter(t=>!r||t.groupId===r),this.selectDefaultTrack&&!t.some(t=>t.default)&&(this.selectDefaultTrack=!1),e={audioTracks:this.tracksInGroup=t},this.log(`Updating audio tracks, ${t.length} track(s) found in group:`+r),this.hls.trigger($.AUDIO_TRACKS_UPDATED,e),this.selectInitialTrack()):this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}}onError(t,e){!e.fatal&&e.context&&e.context.type===E&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){var e,r,n,i=this.tracksInGroup;t<0||t>=i.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),e=this.currentTrack,i[this.trackId],{groupId:r,name:n}=i=i[t],this.log(`Switching to audio-track ${t} "${n}" lang:${i.lang} group:`+r),this.trackId=t,this.currentTrack=i,this.selectDefaultTrack=!1,this.hls.trigger($.AUDIO_TRACK_SWITCHING,f({},i)),i.details&&!i.details.live||(n=this.switchParams(i.url,null==e?void 0:e.details),this.loadPlaylist(n)))}selectInitialTrack(){var t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);-1!=e?this.setAudioTrack(e):(e=new Error(`No track found for running audio group-ID: ${this.groupId} track count: `+t.length),this.warn(e.message),this.hls.trigger($.ERROR,{type:K.MEDIA_ERROR,details:H.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e}))}findTrackId(e){var r=this.tracksInGroup;for(let t=0;tt!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){e=e.contentSteering;null!==e&&(this.pathwayId=e.pathwayId,this.uri=e.uri,this.started)&&this.startLoad()}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){e=e.errorAction;if((null==e?void 0:e.action)===or&&e.flags===hr){let t=this.pathwayPriority;var r=this.pathwayId;this.penalizedPathways[r]||(this.penalizedPathways[r]=performance.now()),(t=!t&&this.levels?this.levels.reduce((t,e)=>(-1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t),[]):t)&&1e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;const r=this.penalizedPathways,n=performance.now();Object.keys(r).forEach(t=>{3e5{const{ID:i,"BASE-ID":e,"URI-REPLACEMENT":a}=t;r.some(t=>t.pathwayId===i)||(t=this.getLevelsForPathway(e).map(t=>{var e=G({},t),t=(e.details=void 0,e.url=aa(t.uri,t.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),new B(t.attrs)),r=(t["PATHWAY-ID"]=i,t.AUDIO&&t.AUDIO+"_clone_"+i),n=t.SUBTITLES&&t.SUBTITLES+"_clone_"+i,t=(r&&(s[t.AUDIO]=r,t.AUDIO=r),n&&(o[t.SUBTITLES]=n,t.SUBTITLES=n),e.attrs=t,new Ke(e));return gr(t,"audio",r),gr(t,"text",n),t}),r.push(...t),ia(this.audioTracks,s,a,i),ia(this.subtitleTracks,o,a,i))})}}loadSteeringManifest(e){var t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+e)}"data:"!==s.protocol&&(r=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate),s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+r));e={responseType:"json",url:s.href},r=t.steeringManifestLoadPolicy.default,t=r.errorRetry||r.timeoutRetry||{},r={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:t.maxNumRetry||0,retryDelay:t.retryDelayMs||0,maxRetryDelay:t.maxRetryDelayMs||0},t={onSuccess:(e,t,r,n)=>{this.log(`Loaded steering manifest: "${s}"`);e=e.data;if(1!==e.VERSION)this.log(`Steering VERSION ${e.VERSION} not supported!`);else{this.updated=performance.now(),this.timeToLoad=e.TTL;var{"RELOAD-URI":e,"PATHWAY-CLONES":i,"PATHWAY-PRIORITY":a}=e;if(e)try{this.uri=new self.URL(e,s).href}catch(t){return this.enabled=!1,void this.log("Failed to parse Steering Manifest RELOAD-URI: "+e)}this.scheduleRefresh(this.uri||r.url),i&&this.clonePathways(i),a&&this.updatePathwayPriority(a)}},onError:(e,r,t,n)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${r.url})`),this.stopLoad(),410===e.code)this.enabled=!1,this.log(`Steering manifest ${r.url} no longer available`);else{let t=1e3*this.timeToLoad;429===e.code?("function"==typeof(null==(e=this.loader)?void 0:e.getResponseHeader)&&(e=e.getResponseHeader("Retry-After"))&&(t=1e3*parseFloat(e)),this.log(`Steering manifest ${r.url} rate limited`)):this.scheduleRefresh(this.uri||r.url,t)}},onTimeout:(t,e,r)=>{this.log(`Timeout loading steering manifest (${e.url})`),this.scheduleRefresh(this.uri||e.url)}};this.log("Requesting steering manifest: "+s),this.loader.load(e,r,t)}scheduleRefresh(t,e=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}});function ga(r){return r&&"object"==typeof r?Array.isArray(r)?r.map(ga):Object.keys(r).reduce((t,e)=>(t[e]=ga(r[e]),t),{}):r}function va(t){var e=t.loader;e!==ua&&e!==oa?(V.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}()&&(t.loader=ua,t.progressive=!0,t.enableSoftwareAES=!0,V.log("[config]: Progressive streaming enabled, using FetchLoader"))}class C{static get version(){return"1.4.14"}static isSupported(){return!!(e=ie())&&(t=Hr(),e=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),t=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove,!!e)&&!!t;var t,e}static get Events(){return $}static get ErrorTypes(){return K}static get ErrorDetails(){return H}static get DefaultConfig(){return C.defaultConfig||pa}static set DefaultConfig(t){C.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Kn,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var e=t.debug||!1,r="Hls instance";if(self.console&&!0===e||"object"==typeof e){nt(e,"debug","log","info","warn","error");try{rt.log(`Debug logs enabled for "${r}" in hls.js version 1.4.14`)}catch(t){rt=et}}else rt=et;var e=this.config=function(t,l){if((l.liveSyncDurationCount||l.liveMaxLatencyDurationCount)&&(l.liveSyncDuration||l.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==l.liveMaxLatencyDurationCount&&(void 0===l.liveSyncDurationCount||l.liveMaxLatencyDurationCount<=l.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==l.liveMaxLatencyDuration&&(void 0===l.liveSyncDuration||l.liveMaxLatencyDuration<=l.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const u=ga(t),e=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(i=>{const a=`${"level"===i?"playlist":i}LoadPolicy`,s=void 0===l[a],o=[];e.forEach(t=>{var e=i+"Loading"+t,r=l[e];if(void 0!==r&&s){o.push(e);var n=u[a].default;switch(l[a]={default:n},t){case"TimeOut":n.maxLoadTimeMs=r,n.maxTimeToFirstByteMs=r;break;case"MaxRetry":n.errorRetry.maxNumRetry=r,n.timeoutRetry.maxNumRetry=r;break;case"RetryDelay":n.errorRetry.retryDelayMs=r,n.timeoutRetry.retryDelayMs=r;break;case"MaxRetryTimeout":n.errorRetry.maxRetryDelayMs=r,n.timeoutRetry.maxRetryDelayMs=r}}}),o.length&&V.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${a}": `+JSON.stringify(l[a]))}),f(f({},u),l)}(C.DefaultConfig,t),{abrController:r,bufferController:t,capLevelController:n,errorController:i,fpsController:a}=(this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&va(e),e),i=new i(this),r=this.abrController=new r(this),t=this.bufferController=new t(this),n=this.capLevelController=new n(this),a=new a(this),s=new Se(this),o=new Fe(this),l=e.contentSteeringController,l=l?new l(this):null,u=this.levelController=new pr(this,l),h=new br(this),c=new Ir(this.config),d=this.streamController=new Yn(this,h,c),s=(n.setStreamController(d),a.setStreamController(d),[s,u,d]),u=(l&&s.splice(1,0,l),this.networkControllers=s,[r,t,n,a,o,h]),d=(this.audioTrackController=this.createController(e.audioTrackController,s),e.audioStreamController),l=(d&&s.push(new d(this,h,c)),this.subtitleTrackController=this.createController(e.subtitleTrackController,s),e.subtitleStreamController),r=(l&&s.push(new l(this,h,c)),this.createController(e.timelineController,u),c.emeController=this.emeController=this.createController(e.emeController,u),this.cmcdController=this.createController(e.cmcdController,u),this.latencyController=this.createController(Ne,u),this.coreComponents=u,s.push(i),i.onErrorOut);"function"==typeof r&&this.on($.ERROR,r,i)}createController(t,e){return t?(t=new t(this),e&&e.push(t),t):null}on(t,e,r=this){this._emitter.on(t,e,r)}once(t,e,r=this){this._emitter.once(t,e,r)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,r=this,n){this._emitter.off(t,e,r,n)}listeners(t){return this._emitter.listeners(t)}emit(t,e,r){return this._emitter.emit(t,e,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){V.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger($.ERROR,{type:K.OTHER_ERROR,details:H.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){V.log("destroy"),this.trigger($.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){V.log("attachMedia"),this._media=t,this.trigger($.MEDIA_ATTACHING,{media:t})}detachMedia(){V.log("detachMedia"),this.trigger($.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();var e=this.media,r=this.url,n=this.url=Q.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});V.log("loadSource:"+n),e&&r&&(r!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger($.MANIFEST_LOADING,{url:t})}startLoad(e=-1){V.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){V.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){V.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){V.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){var t=this.levelController.levels;return t||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){V.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){V.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){V.log("set loadLevel:"+t),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){V.log("set firstLevel:"+t),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){V.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){t=!!t;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){var t=this.abrController["bwEstimator"];return t?t.getEstimate():NaN}get ttfbEstimate(){var t=this.abrController["bwEstimator"];return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(V.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){-1=r)return t}return 0}get maxAutoLevel(){var{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let n;if(n=-1===t&&e&&e.length?e.length-1:t,r)for(let t=n;t--;){var i=e[t].attrs["HDCP-LEVEL"];if(i&&i<=r)return t}return n}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){var t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){var t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay}set subtitleDisplay(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}function ma(e,t){var r,n=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)),n}function ya(e){for(var t=1;t=t[r].start&&this.el.currentTime<=t[r].end&&(e=r);var n={start:t[e].start,current:t[e].end,total:this.getDuration()};this.trigger(u.a.PLAYBACK_PROGRESS,n,t)}}},{key:"play",value:function(){this._hls||this._setup(),this._manifestParsed||this.options.hlsPlayback.preload||this._hls.loadSource(this.options.src),d()(O()(a.prototype),"play",this).call(this),this._startTimeUpdateTimer()}},{key:"pause",value:function(){this._hls&&(this.el.pause(),this.dvrEnabled)&&this._updateDvr(!0)}},{key:"stop",value:function(){this._stopTimeUpdateTimer(),this._hls&&(d()(O()(a.prototype),"stop",this).call(this),this._hls.destroy(),delete this._hls)}},{key:"destroy",value:function(){this._stopTimeUpdateTimer(),this._hls&&(this._hls.destroy(),delete this._hls),d()(O()(a.prototype),"destroy",this).call(this)}},{key:"_updatePlaybackType",value:function(t,e){this._playbackType=e.details.live?u.d.LIVE:u.d.VOD,this._onLevelUpdated(t,e),this._ccTracksUpdated&&this._playbackType===u.d.LIVE&&this.hasClosedCaptionsTracks&&this._onSubtitleLoaded()}},{key:"_fillLevels",value:function(){this._levels=this._hls.levels.map(function(t,e){return{id:e,level:t,label:"".concat(t.bitrate/1e3,"Kbps")}}),this.trigger(u.a.PLAYBACK_LEVELS_AVAILABLE,this._levels)}},{key:"_onLevelUpdated",value:function(t,e){this._segmentTargetDuration=e.details.targetduration,this._playlistType=e.details.type||null;var r,n,i=!1,a=!1,s=e.details.fragments,o=this._playableRegionStartTime,l=this._playableRegionDuration;0!==s.length&&(s[0].rawProgramDateTime&&(this._programDateTime=s[0].rawProgramDateTime),this._playableRegionStartTime!==s[0].start&&(i=!0,this._playableRegionStartTime=s[0].start),i&&(this._localStartTimeCorrelation?(r=this._localStartTimeCorrelation,n=this._now-r.local,(r=(r.remote+n)/1e3)o+this._extrapolatedWindowDuration&&(this._localStartTimeCorrelation={local:this._now,remote:1e3*Math.max(s[0].start,o+this._extrapolatedWindowDuration)})):this._localStartTimeCorrelation={local:this._now,remote:1e3*(s[0].start+this._extrapolatedWindowDuration/2)}),n=e.details.totalduration,this._playbackType===u.d.LIVE&&((r=e.details.targetduration*((this.options.playback.hlsjsConfig||{}).liveSyncDurationCount||C.DefaultConfig.liveSyncDurationCount))<=n?(n-=r,this._durationExcludesAfterLiveSyncPoint=!0):this._durationExcludesAfterLiveSyncPoint=!1),n!==this._playableRegionDuration&&(a=!0,this._playableRegionDuration=n),(e=s[0].start+n)!==(r=o+l)&&(!this._localEndTimeCorrelation||(s=this._localEndTimeCorrelation,n=this._now-s.local,e<(o=(s.remote+n)/1e3))?this._localEndTimeCorrelation={local:this._now,remote:1e3*e}:o=this._minDvrSize&&this.getPlaybackType()===u.d.LIVE}},{key:"getPlaybackType",value:function(){return this._playbackType}},{key:"isSeekEnabled",value:function(){return this._playbackType===u.d.VOD||this.dvrEnabled}},{key:"checkIfCritical",value:function(){var r=this;this._options.mediaInfo.then(function(t){var e=t.criticalError,t=t.errorCodec;e&&(r._isReadyState=!1,r.stop(),r.trigger(u.a.PLAYBACK_ERROR,{UI:{title:"Playback error",message:"Could not play ".concat(t||"this"," codec")},raw:{response:{critical:!0}}}),r._hls)&&r._hls.destroy()})}}],[{key:"HLSJS",get:function(){return C}}]),a}(u.b));_a.canPlay=function(t,e){t=t.split("?")[0].match(/.*\.(.*)$/)||[],t=1t.length)&&(e=t.length);for(var r=0,n=new Array(e);r>6]+h[128|63&l]:l<55296||57344<=l?s+=h[224|l>>12]+h[128|l>>6&63]+h[128|63&l]:(o+=1,l=65536+((1023&l)<<10|1023&a.charCodeAt(o)),s+=h[240|l>>18]+h[128|l>>12&63]+h[128|l>>6&63]+h[128|63&l])}return s},isBuffer:function(t){return!(!t||"object"!=typeof t||!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t)))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(g(t)){for(var r=[],n=0;n * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */!function(){var ja,Ga="Expected a function",vs="__lodash_hash_undefined__",ms="__lodash_placeholder__",$a=9007199254740991,ys=NaN,Ka=4294967295,Es=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],Ha="[object Arguments]",Ts="[object Array]",Va="[object Boolean]",Wa="[object Date]",bs="[object Error]",As="[object Function]",_s="[object GeneratorFunction]",Ya="[object Map]",qa="[object Number]",za="[object Object]",Ss="[object Promise]",Qa="[object RegExp]",Xa="[object Set]",Ja="[object String]",Ls="[object Symbol]",Za="[object WeakMap]",ts="[object ArrayBuffer]",es="[object DataView]",ks="[object Float32Array]",Rs="[object Float64Array]",ws="[object Int8Array]",Is="[object Int16Array]",Ds="[object Int32Array]",Cs="[object Uint8Array]",Ps="[object Uint8ClampedArray]",xs="[object Uint16Array]",Os="[object Uint32Array]",Ms=/\b__p \+= '';/g,Fs=/\b(__p \+=) '' \+/g,Ns=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Bs=/&(?:amp|lt|gt|quot|#39);/g,Us=/[&<>"']/g,js=RegExp(Bs.source),Gs=RegExp(Us.source),$s=/<%-([\s\S]+?)%>/g,Ks=/<%([\s\S]+?)%>/g,Hs=/<%=([\s\S]+?)%>/g,Vs=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ws=/^\w*$/,Ys=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,qs=/[\\^$.*+?()[\]{}|]/g,zs=RegExp(qs.source),Qs=/^\s+/,s=/\s/,Xs=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Js=/\{\n\/\* \[wrapped with (.+)\] \*/,Zs=/,? & /,to=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,eo=/[()=,{}\[\]\/\s]/,ro=/\\(\\)?/g,no=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,io=/\w*$/,ao=/^[-+]0x[0-9a-f]+$/i,so=/^0b[01]+$/i,oo=/^\[object .+?Constructor\]$/,lo=/^0o[0-7]+$/i,uo=/^(?:0|[1-9]\d*)$/,ho=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,co=/($^)/,fo=/['\n\r\u2028\u2029\\]/g,o="\\ud800-\\udfff",l="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",t="\\u2700-\\u27bf",e="a-z\\xdf-\\xf6\\xf8-\\xff",r="A-Z\\xc0-\\xd6\\xd8-\\xde",u="\\ufe0e\\ufe0f",n="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",i="["+o+"]",h="["+n+"]",c="["+l+"]",d="["+t+"]",f="["+e+"]",n="[^"+o+n+"\\d+"+t+e+r+"]",t="\\ud83c[\\udffb-\\udfff]",e="[^"+o+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",r="["+r+"]",g="(?:"+f+"|"+n+")",n="(?:"+r+"|"+n+")",v="(?:['’](?:d|ll|m|re|s|t|ve))?",m="(?:['’](?:D|LL|M|RE|S|T|VE))?",y="(?:"+c+"|"+t+")"+"?",E="["+u+"]?",E=E+y+("(?:\\u200d(?:"+[e,p,a].join("|")+")"+E+y+")*"),y="(?:"+[d,p,a].join("|")+")"+E,d="(?:"+[e+c+"?",c,p,a,i].join("|")+")",po=RegExp("['’]","g"),go=RegExp(c,"g"),T=RegExp(t+"(?="+t+")|"+d+E,"g"),vo=RegExp([r+"?"+f+"+"+v+"(?="+[h,r,"$"].join("|")+")",n+"+"+m+"(?="+[h,r+g,"$"].join("|")+")",r+"?"+g+"+"+v,r+"+"+m,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])","\\d+",y].join("|"),"g"),b=RegExp("[\\u200d"+o+l+u+"]"),mo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,yo=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Eo=-1,rs={},ns=(rs[ks]=rs[Rs]=rs[ws]=rs[Is]=rs[Ds]=rs[Cs]=rs[Ps]=rs[xs]=rs[Os]=!0,rs[Ha]=rs[Ts]=rs[ts]=rs[Va]=rs[es]=rs[Wa]=rs[bs]=rs[As]=rs[Ya]=rs[qa]=rs[za]=rs[Qa]=rs[Xa]=rs[Ja]=rs[Za]=!1,{}),A=(ns[Ha]=ns[Ts]=ns[ts]=ns[es]=ns[Va]=ns[Wa]=ns[ks]=ns[Rs]=ns[ws]=ns[Is]=ns[Ds]=ns[Ya]=ns[qa]=ns[za]=ns[Qa]=ns[Xa]=ns[Ja]=ns[Ls]=ns[Cs]=ns[Ps]=ns[xs]=ns[Os]=!0,ns[bs]=ns[As]=ns[Za]=!1,{"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"}),To=parseFloat,bo=parseInt,e="object"==typeof R&&R&&R.Object===Object&&R,p="object"==typeof self&&self&&self.Object===Object&&self,is=e||p||Function("return this")(),a=D&&!D.nodeType&&D,_=a&&"object"==typeof w&&w&&!w.nodeType&&w,Ao=_&&_.exports===a,S=Ao&&e.process,i=function(){try{var t=_&&_.require&&_.require("util").types;return t?t:S&&S.binding&&S.binding("util")}catch(t){}}(),_o=i&&i.isArrayBuffer,So=i&&i.isDate,Lo=i&&i.isMap,ko=i&&i.isRegExp,Ro=i&&i.isSet,wo=i&&i.isTypedArray;function as(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function Io(t,e,r,n){for(var i=-1,a=null==t?0:t.length;++i":">",'"':""","'":"'"});function Zo(t){return"\\"+A[t]}function ds(t){return b.test(t)}function tl(t){var r=-1,n=Array(t.size);return t.forEach(function(t,e){n[++r]=[e,t]}),n}function el(e,r){return function(t){return e(r(t))}}function fs(t,e){for(var r=-1,n=t.length,i=0,a=[];++r",""":'"',"'":"'"});var al=function i(t){var A=(t=null==t?is:al.defaults(is.Object(),t,al.pick(is,yo))).Array,a=t.Date,P=t.Error,x=t.Function,O=t.Math,g=t.Object,M=t.RegExp,$=t.String,_=t.TypeError,K=A.prototype,H=x.prototype,V=g.prototype,W=t["__core-js_shared__"],Y=H.toString,F=V.hasOwnProperty,q=0,z=(H=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+H:"",Q=V.toString,X=Y.call(g),J=is._,Z=M("^"+Y.call(F).replace(qs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),H=Ao?t.Buffer:ja,e=t.Symbol,tt=t.Uint8Array,et=H?H.allocUnsafe:ja,rt=el(g.getPrototypeOf,g),nt=g.create,it=V.propertyIsEnumerable,at=K.splice,st=e?e.isConcatSpreadable:ja,ot=e?e.iterator:ja,lt=e?e.toStringTag:ja,ut=function(){try{var t=Xr(g,"defineProperty");return t({},"",{}),t}catch(t){}}(),ht=t.clearTimeout!==is.clearTimeout&&t.clearTimeout,ct=a&&a.now!==is.Date.now&&a.now,dt=t.setTimeout!==is.setTimeout&&t.setTimeout,ft=O.ceil,pt=O.floor,gt=g.getOwnPropertySymbols,H=H?H.isBuffer:ja,vt=t.isFinite,mt=K.join,yt=el(g.keys,g),S=O.max,L=O.min,Et=a.now,Tt=t.parseInt,bt=O.random,At=K.reverse,a=Xr(t,"DataView"),_t=Xr(t,"Map"),St=Xr(t,"Promise"),Lt=Xr(t,"Set"),t=Xr(t,"WeakMap"),kt=Xr(g,"create"),Rt=t&&new t,wt={},It=_n(a),Dt=_n(_t),Ct=_n(St),Pt=_n(Lt),xt=_n(t),e=e?e.prototype:ja,Ot=e?e.valueOf:ja,Mt=e?e.toString:ja;function p(t){if(G(t)&&!j(t)&&!(t instanceof m)){if(t instanceof v)return t;if(F.call(t,"__wrapped__"))return Sn(t)}return new v(t)}var Ft=function(t){if(!b(t))return{};if(nt)return nt(t);Nt.prototype=t;t=new Nt;return Nt.prototype=ja,t};function Nt(){}function Bt(){}function v(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=ja}function m(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ka,this.__views__=[]}function Ut(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e>>0,e>>>=0,A(i));++n>>1,s=t[a];null!==s&&!E(s)&&(r?s<=e:s>>0)?(t=f(t))&&("string"==typeof e||null!=e&&!Ri(e))&&!(e=u(e))&&ds(t)?or(gs(t),0,r):t.split(e,r):[]},p.spread=function(r,n){if("function"!=typeof r)throw new _(Ga);return n=null==n?0:S(R(n),0),s(function(t){var e=t[n],t=or(t,0,n);return e&&us(t,e),as(r,this,t)})},p.tail=function(t){var e=null==t?0:t.length;return e?o(t,1,e):[]},p.take=function(t,e,r){return t&&t.length?o(t,0,(e=r||e===ja?1:R(e))<0?0:e):[]},p.takeRight=function(t,e,r){var n=null==t?0:t.length;return n?o(t,(e=n-(e=r||e===ja?1:R(e)))<0?0:e,n):[]},p.takeRightWhile=function(t,e){return t&&t.length?Ze(t,c(e,3),!1,!0):[]},p.takeWhile=function(t,e){return t&&t.length?Ze(t,c(e,3)):[]},p.tap=function(t,e){return e(t),t},p.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new _(Ga);return b(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),li(t,e,{leading:n,maxWait:e,trailing:i})},p.thru=Hn,p.toArray=xi,p.toPairs=ta,p.toPairsIn=ea,p.toPath=function(t){return j(t)?ls(t,An):E(t)?[t]:k(bn(f(t)))},p.toPlainObject=Fi,p.transform=function(t,n,i){var e,r=j(t),a=r||Ei(t)||Di(t);return n=c(n,4),null==i&&(e=t&&t.constructor,i=a?r?new e:[]:b(t)&&bi(e)?Ft(rt(t)):{}),(a?ss:ce)(t,function(t,e,r){return n(i,t,e,r)}),i},p.unary=function(t){return ii(t,1)},p.union=Pn,p.unionBy=xn,p.unionWith=On,p.uniq=function(t){return t&&t.length?Qe(t):[]},p.uniqBy=function(t,e){return t&&t.length?Qe(t,c(e,2)):[]},p.uniqWith=function(t,e){return e="function"==typeof e?e:ja,t&&t.length?Qe(t,ja,e):[]},p.unset=function(t,e){return null==t||Xe(t,e)},p.unzip=Mn,p.unzipWith=Fn,p.update=function(t,e,r){return null==t?t:Je(t,e,ir(r))},p.updateWith=function(t,e,r,n){return n="function"==typeof n?n:ja,null==t?t:Je(t,e,ir(r),n)},p.values=ra,p.valuesIn=function(t){return null==t?[]:Yo(t,D(t))},p.without=Nn,p.words=fa,p.wrap=function(t,e){return di(ir(e),t)},p.xor=Bn,p.xorBy=Un,p.xorWith=jn,p.zip=Gn,p.zipObject=function(t,e){return rr(t||[],e||[],qt)},p.zipObjectDeep=function(t,e){return rr(t||[],e||[],$e)},p.zipWith=$n,p.entries=ta,p.entriesIn=ea,p.extend=Bi,p.extendWith=Ui,Aa(p,p),p.add=Pa,p.attempt=pa,p.camelCase=na,p.capitalize=ia,p.ceil=xa,p.clamp=function(t,e,r){return r===ja&&(r=e,e=ja),r!==ja&&(r=(r=w(r))==r?r:0),e!==ja&&(e=(e=w(e))==e?e:0),te(w(t),e,r)},p.clone=function(t){return y(t,4)},p.cloneDeep=function(t){return y(t,5)},p.cloneDeepWith=function(t,e){return y(t,5,e="function"==typeof e?e:ja)},p.cloneWith=function(t,e){return y(t,4,e="function"==typeof e?e:ja)},p.conformsTo=function(t,e){return null==e||ee(t,e,I(e))},p.deburr=aa,p.defaultTo=function(t,e){return null==t||t!=t?e:t},p.divide=Oa,p.endsWith=function(t,e,r){t=f(t),e=u(e);var n=t.length,n=r=r===ja?n:te(R(r),0,n);return 0<=(r-=e.length)&&t.slice(r,n)==e},p.eq=U,p.escape=function(t){return(t=f(t))&&Gs.test(t)?t.replace(Us,Jo):t},p.escapeRegExp=function(t){return(t=f(t))&&zs.test(t)?t.replace(qs,"\\$&"):t},p.every=function(t,e,r){return(j(t)?Co:se)(t,c(e=r&&d(t,e,r)?ja:e,3))},p.find=Yn,p.findIndex=Ln,p.findKey=function(t,e){return No(t,c(e,3),ce)},p.findLast=qn,p.findLastIndex=kn,p.findLastKey=function(t,e){return No(t,c(e,3),de)},p.floor=Ma,p.forEach=zn,p.forEachRight=Qn,p.forIn=function(t,e){return null==t?t:ue(t,c(e,3),D)},p.forInRight=function(t,e){return null==t?t:he(t,c(e,3),D)},p.forOwn=function(t,e){return t&&ce(t,c(e,3))},p.forOwnRight=function(t,e){return t&&de(t,c(e,3))},p.get=Hi,p.gt=gi,p.gte=vi,p.has=function(t,e){return null!=t&&tn(t,e,me)},p.hasIn=Vi,p.head=wn,p.identity=C,p.includes=function(t,e,r,n){return t=h(t)?t:ra(t),r=r&&!n?R(r):0,n=t.length,r<0&&(r=S(n+r,0)),Ii(t)?r<=n&&-1=L(e=e,r=r)&&t=this.__values__.length;return{done:t,value:t?ja:this.__values__[this.__index__++]}},p.prototype.plant=function(t){for(var e,r=this;r instanceof Bt;)var n=Sn(r),i=(n.__index__=0,n.__values__=ja,e?i.__wrapped__=n:e=n,n),r=r.__wrapped__;return i.__wrapped__=t,e},p.prototype.reverse=function(){var t=this.__wrapped__;return t instanceof m?(t=t,(t=(t=this.__actions__.length?new m(this):t).reverse()).__actions__.push({func:Hn,args:[Cn],thisArg:ja}),new v(t,this.__chain__)):this.thru(Cn)},p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=function(){return tr(this.__wrapped__,this.__actions__)},p.prototype.first=p.prototype.head,ot&&(p.prototype[ot]=function(){return this}),p}();is._=al,(I=function(){return al}.call(D,C,D,w))!==ja&&(w.exports=I)}.call(this)}.call(this,C(31),C(155)(t))},function(t,e,r){var n=r(359),i=r(360),a=r(154),s=r(361);t.exports=function(t,e){return n(t)||i(t,e)||a(t,e)||s()},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,r,f){"use strict";!function(n){f.d(r,"a",function(){return e});var t=f(5),i=f.n(t),t=f(6),a=f.n(t),t=f(8),s=f.n(t),t=f(9),o=f.n(t),t=f(3),l=f.n(t),u=f(1),t=f(164),h=f.n(t),t=f(165),c=f.n(t);function d(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=l()(r);return t=n?(t=l()(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),o()(this,t)}}var e=function(t){s()(r,t);var e=d(r);function r(){return i()(this,r),e.apply(this,arguments)}return a()(r,[{key:"name",get:function(){return"level_selector"}},{key:"template",get:function(){return Object(u.template)(h.a)}},{key:"supportedVersion",get:function(){return{min:u.version}}},{key:"attributes",get:function(){return{class:this.name,"data-level-selector":""}}},{key:"events",get:function(){return{"click [data-level-selector-select]":"onLevelSelect","click [data-level-selector-button]":"onShowLevelSelectMenu"}}},{key:"container",get:function(){return this.core.activeContainer||this.core.mediaControl.container}},{key:"playback",get:function(){return this.core.activePlayback||this.core.getCurrentPlayback()}},{key:"bindEvents",value:function(){this.listenTo(this.core,u.Events.CORE_READY,this.bindPlaybackEvents),u.Events.CORE_ACTIVE_CONTAINER_CHANGED?this.listenTo(this.core,u.Events.CORE_ACTIVE_CONTAINER_CHANGED,this.reload):this.listenTo(this.core.mediaControl,u.Events.MEDIACONTROL_CONTAINERCHANGED,this.reload),this.listenTo(this.core.mediaControl,u.Events.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,u.Events.MEDIACONTROL_HIDE,this.hideSelectLevelMenu)}},{key:"bindPlaybackEvents",value:function(){this.playback&&(this.listenTo(this.playback,u.Events.PLAYBACK_LEVELS_AVAILABLE,this.fillLevels),this.listenTo(this.playback,u.Events.PLAYBACK_LEVEL_SWITCH_START,this.startLevelSwitch),this.listenTo(this.playback,u.Events.PLAYBACK_LEVEL_SWITCH_END,this.stopLevelSwitch),this.listenTo(this.playback,u.Events.PLAYBACK_BITRATE,this.updateCurrentLevel),this.playback.levels)&&0\n Auto\n\n'},function(t,e,r){var n=r(379),i=("string"==typeof n&&(n=[[t.i,n,""]]),{hmr:!0});i.transform=void 0,i.insertInto=void 0,r(381)(n,i);n.locals&&(t.exports=n.locals)},function(t,e,r){"use strict";r.d(e,"a",function(){return n});var e=r(5),i=r.n(e),e=r(6),a=r.n(e),e=r(7),s=r.n(e),e=r(8),o=r.n(e),e=r(9),l=r.n(e),e=r(3),u=r.n(e),h=r(1),e=r(89),c=r.n(e),e=r(167),d=r.n(e),e=r(168),f=r.n(e),p=r(90);function g(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=u()(r);return t=n?(t=u()(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),l()(this,t)}}var v="blinkPoster",n=function(t){o()(n,t);var r=g(n);function n(t){var e;return i()(this,n),(e=r.call(this,t)).startBlinkPoster(),e.container=t,e}return a()(n,[{key:"name",get:function(){return"poster"}},{key:"bindEvents",value:function(){s()(u()(n.prototype),"bindEvents",this).call(this),this.listenTo(this.container,h.Events.CONTAINER_OPTIONS_CHANGE,this.changeOptsRuntime)}},{key:"destroy",value:function(){s()(u()(n.prototype),"destroy",this).call(this),this.stopBlinkPoster()}},{key:"changeOptsRuntime",value:function(){this.options[v]?this.startBlinkPoster():this.stopBlinkPoster()}},{key:"startBlinkPoster",value:function(){var t;this.options[v]&&!this.hasStartedPlaying&&(t=this.options.blinkPosterDelay||5e3,this.posterChangeSource=this.posterChangeSource.bind(this),this.posterTimer=setTimeout(this.posterChangeSource,t))}},{key:"stopBlinkPoster",value:function(){clearTimeout(this.posterTimer)}},{key:"onStop",value:function(){s()(u()(n.prototype),"onStop",this).call(this),this.startBlinkPoster()}},{key:"onPlay",value:function(){s()(u()(n.prototype),"onPlay",this).call(this),this.stopBlinkPoster()}},{key:"posterChangeSource",value:function(){var t=this,e=this.options.authToken?"&":"?",e=this.getPosterSource({postfix:"".concat(e,"_t=").concat(Number(new Date))});this.setPosterSource(e).then(function(){t.posterTimer=setTimeout(t.posterChangeSource,5e3)})}},{key:"templateVideo",get:function(){return Object(h.template)(f.a)}},{key:"shouldRender",get:function(){var t=!!this.options.poster;return"html_img"!==this.container.playback.name&&("no_op"!==this.container.playback.getPlaybackType()||t)}},{key:"showOnVideoEnd",get:function(){return!this.options.poster||this.options.poster.showOnVideoEnd||void 0===this.options.poster.showOnVideoEnd}},{key:"setPosterSource",value:function(n){var i=this;return Object(p.b)(this.$el[0])?new Promise(function(t){var e=i._videoPoster,r=i.$el.find(".poster-video:not(.visible)");r.one("loadeddata",function(){e.removeClass("visible"),r.addClass("visible"),i._videoPoster=r,t()}),r.attr({src:n})}):Promise.resolve()}},{key:"renderVideoPoster",value:function(){this.$el.html(this.templateVideo()),this.setPosterStyles(),this.setVideoPoster()}},{key:"setPosterStyles",value:function(){this.$el.append(''),this.$el.find(".clappr-style").html(Object(h.template)(d.a.toString()))}},{key:"setVideoPoster",value:function(){this._videoPoster=this.$el.find(".poster-video"),this._videoPoster.attr({src:this.getPosterSource()})}},{key:"renderPlayButton",value:function(){this.container.$el.append(this.el),this.$playWrapper=this.$el.find(".play-wrapper"),this.$playWrapper.append(c.a),this.$playButton=this.$playWrapper.find("svg"),this.$playButton.addClass("poster-icon"),this.$playButton.attr("data-poster","");var t=this.options.mediacontrol&&this.options.mediacontrol.buttons;t&&this.$el.find("svg path").css("fill",t),this.options.mediacontrol&&this.options.mediacontrol.buttons&&(t=this.options.mediacontrol.buttons,this.$playButton.css("color",t))}},{key:"getPosterSource",value:function(){var t=(0'),this.$el.find(".clappr-style").html(Object(u.template)(c.a.toString()))}},{key:"render",value:function(){var t,e=this;if(this.shouldRender)return this.$el[0].addEventListener("touchstart",function(){e.container.play()}),this.$el.html(this.template()),this.setPosterStyles(),this.options.poster&&null==this.options.poster.custom?(t=this.options.poster.url||this.options.poster,this.$el.css({"background-image":"url(".concat(t,")")})):this.options.poster&&this.$el.css({background:this.options.poster.custom}),this.container.$el.append(this.el),this.$playWrapper=this.$el.find(".play-wrapper"),this.$playWrapper.append(h.a),this.$playButton=this.$playWrapper.find("svg"),this.$playButton.addClass("poster-icon"),this.$playButton.attr("data-poster",""),(t=this.options.mediacontrol&&this.options.mediacontrol.buttons)&&this.$el.find("svg path").css("fill",t),this.options.mediacontrol&&this.options.mediacontrol.buttons&&(t=this.options.mediacontrol.buttons,this.$playButton.css("color",t)),this.update(),this}}]),n}(u.Poster)},function(t,e,r){},function(t,e,r){"use strict";r.d(e,"a",function(){return p});var e=r(5),n=r.n(e),e=r(6),i=r.n(e),e=r(8),a=r.n(e),e=r(9),s=r.n(e),e=r(7),o=r.n(e),e=r(3),l=r.n(e),u=r(1),h=r(90),e=r(172),c=r.n(e),e=r(173),d=r.n(e);function f(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=l()(r);return t=n?(t=l()(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),s()(this,t)}}var p=function(t){a()(r,t);var e=f(r);function r(t){return n()(this,r),(t=e.call(this,t)).hasStartedPlaying=!1,t.playRequested=!1,t.render(),t}return i()(r,[{key:"name",get:function(){return"logo"}},{key:"template",get:function(){return Object(u.template)(c.a)}},{key:"attributes",get:function(){return{class:"player-logo","data-logo":""}}},{key:"shouldRender",get:function(){return!!this.options.logo.path}},{key:"bindEvents",value:function(){this.setPositionBinded=this.setPosition.bind(this),window.addEventListener("resize",this.setPositionBinded),(u.Browser.isSafari||u.Browser.isIE)&&this.container.playback.el.addEventListener("loadeddata",this.setPositionBinded),this.listenTo(this.container,u.Events.CONTAINER_STOP,this.onStop),this.listenTo(this.container,u.Events.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,u.Events.CONTAINER_LOADEDMETADATA,this.setPositionBinded)}},{key:"stopListening",value:function(){window.removeEventListener("resize",this.setPositionBinded),(u.Browser.isSafari||u.Browser.isIE)&&window.removeEventListener("loadeddata",this.setPositionBinded),o()(l()(r.prototype),"stopListening",this).call(this)}},{key:"onPlay",value:function(){this.hasStartedPlaying=!0,this.update()}},{key:"onStop",value:function(){this.hasStartedPlaying=!1,this.playRequested=!1,this.update()}},{key:"update",value:function(){this.shouldRender&&(this.hasStartedPlaying?this.$el.show():this.$el.hide())}},{key:"render",value:function(){if(this.shouldRender)return this.$el.html(this.template()),this.setLogoStyles(),this.setLogoImgAttrs(),this.container.$el.append(this.$el),this.update(),this}},{key:"setLogoImgAttrs",value:function(){var t=this.options,e=t.logo,r=e.path,n=e.width,n=void 0===n?60:n,e=e.height,e=void 0===e?60:e,t=t.authToken;this.$logoContainer=this.$el.find(".live-logo"),this.$logoContainer.find(".live-logo-img").attr({src:"".concat(r.includes("http")||r.includes("https")?"":"/").concat(r).concat(t?"?".concat(t):""),style:"width: ".concat(n,"px;height: ").concat(e,"px;")})}},{key:"setPosition",value:function(){var t,e,r,n;this.shouldRender&&(r=(e=this.container).$el,e=e.currentSize,t=(r=r.find("video[data-html5-video]").get(0)).videoWidth,r=r.videoHeight,e=Object(h.a)({dom:{width:e.width,height:e.height},media:{width:t,height:r}}),t=this.options.logo,e=(r=e.letterboxing).vertical,r=r.horizontal,n=this.$logoContainer.get(0),this.setStyles(t,["top","bottom"],n,e),this.setStyles(t,["left","right"],n,r),this.update())}},{key:"setStyles",value:function(e,t,r,n){var i=this;t.forEach(function(t){return i.setStyle(e,t,r,n)})}},{key:"setStyle",value:function(t,e,r,n){t[e]&&(r.style[e]="".concat(parseInt(t[e],10)+n,"px"))}},{key:"setLogoStyles",value:function(){this.$el.append(''),this.$el.find(".clappr-style").html(Object(u.template)(d.a.toString()))}}]),r}(u.UIContainerPlugin)},function(t,e){t.exports='\n'},function(t,e,r){},function(t,e,r){"use strict";r.d(e,"a",function(){return h});var e=r(5),n=r.n(e),e=r(6),i=r.n(e),e=r(8),a=r.n(e),e=r(9),s=r.n(e),e=r(3),o=r.n(e),l=r(1);function u(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=o()(r);return t=n?(t=o()(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),s()(this,t)}}var h=function(t){a()(r,t);var e=u(r);function r(){return n()(this,r),e.apply(this,arguments)}return i()(r,[{key:"name",get:function(){return"volumePlugin"}},{key:"bindEvents",value:function(){0=this._minDvrSize&&"live"===this.getPlaybackType()}},{key:"getDuration",value:function(){return this._duration}},{key:"_duration",get:function(){return this.shakaPlayerInstance?this.seekRange.end-this.seekRange.start:0}},{key:"getCurrentTime",value:function(){return this.shakaPlayerInstance?this.shakaPlayerInstance.getMediaElement().currentTime-this.seekRange.start:0}},{key:"_startTime",get:function(){return this.seekRange.start}},{key:"presentationStartTimeAsDate",get:function(){return this.shakaPlayerInstance&&this.shakaPlayerInstance.getPresentationStartTimeAsDate()?new Date(this.shakaPlayerInstance.getPresentationStartTimeAsDate().getTime()+1e3*this.seekRange.start):0}},{key:"bandwidthEstimate",get:function(){return this.shakaPlayerInstance?this.shakaPlayerInstance.getStats().estimatedBandwidth:null}},{key:"getProgramDateTime",value:function(){return this.presentationStartTimeAsDate}},{key:"_updateDvr",value:function(t){this.trigger(c.Events.PLAYBACK_DVR,t),this.trigger(c.Events.PLAYBACK_STATS_ADD,{dvr:t})}},{key:"seek",value:function(t){t<0&&(c.Log.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),t=this._duration),this.dvrEnabled&&this._updateDvr(ts.left&&(n=s.left,a=!0),o.top>s.top&&(i=s.top,a=!0),o.right\n<% } else { %>\n\n<% }; %>\n'},function(t,e,r){"use strict";r.d(e,"a",function(){return n});var e=r(5),i=r.n(e),e=r(6),a=r.n(e),e=r(8),s=r.n(e),e=r(9),o=r.n(e),e=r(3),l=r.n(e),u=r(1),h=r(183),e=r(184),c=r.n(e);function d(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=l()(r);return t=n?(t=l()(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),o()(this,t)}}var n=function(t){s()(n,t);var e=d(n);function n(t){var r;return i()(this,n),(r=e.call(this,t)).$el.addClass("media-control-button media-control-icon").css({float:"right",height:"100%"}).append(c.a),r.$el.click(function(){var t=r.core.mediaControl.container.playback.el,e=document.createElement("canvas");e.width=t.videoWidth,e.height=t.videoHeight;e.getContext("2d").drawImage(t,0,0);t=e.toDataURL("image/jpeg");r.core.mediaControl.trigger("capture:base64",t)}),r}return a()(n,[{key:"name",get:function(){return"Flussonic capture plugin"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"tagName",get:function(){return"button"}},{key:"attributes",get:function(){return{class:this.name}}},{key:"bindEvents",value:function(){this.listenToOnce(this.core,u.Events.CORE_ACTIVE_CONTAINER_CHANGED,function(){this.listenTo(this.core.mediaControl,u.Events.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,"capture:base64",function(t){Object(h.saveAs)(t,"screenshot_".concat(Date.now(),".jpg"))})})}},{key:"unBindEvents",value:function(){this.stopListening(this.core.mediaControl,u.Events.MEDIACONTROL_RENDERED)}},{key:"render",value:function(){return this.core.mediaControl.$el.find(".media-control-right-panel").append(this.el),this}}]),n}(u.UICorePlugin)},function(r,n,t){!function(t){var e;void 0!==(e="function"==typeof(e=function(){"use strict";function i(t,e){return"undefined"==typeof e?e={autoBom:!1}:"object"!=typeof e&&(console.warn("Deprecated: Expected third argument to be a object"),e={autoBom:!e}),e.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\ufeff",t],{type:t.type}):t}function h(t,e,r){var n=new XMLHttpRequest;n.open("GET",t),n.responseType="blob",n.onload=function(){o(n.response,e,r)},n.onerror=function(){console.error("could not download file")},n.send()}function a(t){var e=new XMLHttpRequest;e.open("HEAD",t,!1);try{e.send()}catch(t){}return 200<=e.status&&299>=e.status}function s(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(t){var r=document.createEvent("MouseEvents");r.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(r)}}var c="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof t&&t.global===t?t:void 0,d=c.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),o=c.saveAs||("object"!=typeof window||window!==c?function(){}:"download"in HTMLAnchorElement.prototype&&!d?function(t,e,r){var n=c.URL||c.webkitURL,i=document.createElement("a");e=e||t.name||"download",i.download=e,i.rel="noopener","string"==typeof t?(i.href=t,i.origin===location.origin?s(i):a(i.href)?h(t,e,r):s(i,i.target="_blank")):(i.href=n.createObjectURL(t),setTimeout(function(){n.revokeObjectURL(i.href)},4e4),setTimeout(function(){s(i)},0))}:"msSaveOrOpenBlob"in navigator?function(t,e,r){if(e=e||t.name||"download","string"!=typeof t)navigator.msSaveOrOpenBlob(i(t,r),e);else if(a(t))h(t,e,r);else{var n=document.createElement("a");n.href=t,n.target="_blank",setTimeout(function(){s(n)})}}:function(t,e,r,n){if(n=n||open("","_blank"),n&&(n.document.title=n.document.body.innerText="downloading..."),"string"==typeof t)return h(t,e,r);var i="application/octet-stream"===t.type,a=/constructor/i.test(c.HTMLElement)||c.safari,s=/CriOS\/[\d]+/.test(navigator.userAgent);if((s||i&&a||d)&&"undefined"!=typeof FileReader){var o=new FileReader;o.onloadend=function(){var t=o.result;t=s?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"),n?n.location.href=t:location=t,n=null},o.readAsDataURL(t)}else{var l=c.URL||c.webkitURL,u=l.createObjectURL(t);n?n.location=u:location.href=u,n=null,setTimeout(function(){l.revokeObjectURL(u)},4e4)}});c.saveAs=o.saveAs=o,true&&(r.exports=o)})?e.apply(n,[]):e)&&(r.exports=e)}.call(this,t(31))},function(t,e){t.exports=''},function(t,e,r){"use strict";r.d(e,"a",function(){return f});var e=r(5),n=r.n(e),e=r(6),i=r.n(e),e=r(46),s=r.n(e),e=r(7),a=r.n(e),e=r(8),o=r.n(e),e=r(9),l=r.n(e),e=r(3),u=r.n(e),e=r(17),h=r.n(e),c=r(1);r(393);function d(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=u()(r);return t=n?(t=u()(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),l()(this,t)}}var f=function(t){o()(r,t);var e=d(r);function r(t){var a;return n()(this,r),a=e.call(this,t),h()(s()(a),"frameLooper",function(){if(a.audioConnected){for(var t,e=new Uint8Array(a.analyser.frequencyBinCount),r=(a.analyser.getByteFrequencyData(e),0),n=0;n
'),this.canvas=this.container.$el.find(".equalizer")[0],this.eqBar=this.container.$el.find(".eq-bar")[0],this.eqBarBack=this.container.$el.find(".eq-bar-back")[0],this}}]),r}(c.ContainerPlugin)},function(t,e,r){"use strict";r.d(e,"a",function(){return c});var e=r(5),n=r.n(e),e=r(6),i=r.n(e),e=r(7),a=r.n(e),e=r(8),s=r.n(e),e=r(9),o=r.n(e),e=r(3),l=r.n(e),u=r(1);function h(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=l()(r);return t=n?(t=l()(this).constructor,Reflect.construct(e,arguments,t)):e.apply(this,arguments),o()(this,t)}}var c=function(t){s()(r,t);var e=h(r);function r(t){return n()(this,r),(t=e.call(this,t)).background="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAFoBAMAAAA1HFdiAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAG1BMVEX5+fn//wAA//8A/wD/AP//AAAAAP8XFxf///8H5gWfAAAAAWJLR0QIht6VegAAAAd0SU1FB98IBRIsAXmGk48AAAI5SURBVHja7dJBDYBADADBs4AFLGABC1iohbOPhv1BMvu+NLlp10odqTN1pe7Uk5pQ8wMIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECDA/wKWxzM71T7ZZrfltNnppgACBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAL8B+ALjSfYzPnmdzgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNS0wOC0wNVQxODo0NDowMSswMTowMCL95a4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTUtMDgtMDVUMTg6NDQ6MDErMDE6MDBToF0SAAAAAElFTkSuQmCC","boolean"==typeof t.options.calmError&&t.options.calmError&&(t.background=""),t.options.dontShowError&&(t.dontShowError=parseInt(t.options.dontShowError,10),1==t.options.dontShowError)&&(t.dontShowError=1),t.listenTo(t.container,u.Events.CONTAINER_ERROR,t.onError),t}return i()(r,[{key:"name",get:function(){return"Flussonic error plugin"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"destroy",value:function(){this.t="stop",a()(l()(r.prototype),"destroy",this).call(this)}},{key:"hide",value:function(){this._err&&this._err.remove()}},{key:"show",value:function(t,e){var r,n=t.title,i=t.message,n=(this.hide(),t&&n?n:""),t=t&&i?i:"A fatal error occured.",i="";e&&(r=e.code,e=void 0===(e=e.text)?"":e,i=(r=void 0===r?"":r)||e?"Code:".concat(r||""," - ").concat(e||""):""),this._err=$("
").css({position:"absolute","z-index":"999",width:"100%",height:"100%",display:"flex","align-items":"center","justify-content":" center","flex-direction":"column","background-image":"url(".concat(this.background,")"),"background-size":"100% 100%","background-repeat":"no-repeat","background-color":"#777","text-align":"center","font-weight":"bold","text-shadow":"1px 1px ".concat(this.options.calmError?"#000":"#fff"),color:"".concat(this.options.calmError?"#fff":"#000")}).append($("

").text(n).css({"font-size":"200%"})).append($("

").text(t).css({"font-size":"150%","margin-top":"8px"})).append($("

").text(i).css({"font-size":"100%","margin-top":"8px","margin-bottom":"16px"})).append($('

').html('Retrying in 10 seconds ...').css({"font-size":"120%",margin:"15px"})),this.dontShowError&&0current<% }; %>">\n \n <%= tracks[i].label %> <% if (tracks[i].track.language) { %> (<%=\n tracks[i].track.language %>) <% }; %>\n \n <% }; %>\n\n'},function(t,e,r){"use strict";r.d(e,"a",function(){return v});var e=r(63),a=r.n(e),e=r(5),s=r.n(e),e=r(6),o=r.n(e),e=r(46),l=r.n(e),e=r(7),u=r.n(e),e=r(8),h=r.n(e),e=r(9),i=r.n(e),e=r(3),c=r.n(e),e=r(17),d=r.n(e),f=r(1);function n(e,t){var r,n=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)),n}function p(e){for(var t=1;te[0]?1:0}),r._entries&&(r._entries={});for(var t=0;t",'"',"`"," ","\r","\n","\t"]),k=["'"].concat(i),R=["%","/","?",";","#"].concat(k),w=["/","?","#"],I=/^[+a-z0-9A-Z_-]{0,63}$/,D=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,C={javascript:!0,"javascript:":!0},P={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},O=r(364);function a(t,e,r){var n;return t&&"object"==typeof t&&t instanceof b?t:((n=new b).parse(t,e,r),n)}b.prototype.parse=function(t,e,r){if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var n=t.indexOf("?"),n=-1!==n&&n>>10&1023|55296),t=56320|1023&t),e+=T(t)}).join("")}function _(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function S(t,e,r){var n=0;for(t=r?E(t/a):t>>1,t+=E(t/e);u*y>>1E((v-h)/a))&&b("overflow"),h+=o*a,!(o<(o=s<=d?1:d+y<=s?y:s-d));s+=m)a>E(v/(o=m-o))&&b("overflow"),a*=o;d=S(h-i,e=l.length+1,0==i),E(h/e)>v-c&&b("overflow"),c+=E(h/e),h%=e,l.splice(h++,0,c)}return p(l)}function f(t){for(var e,r,n,i,a,s,o,l,u,h,c=[],d=(t=A(t)).length,f=128,p=72,g=e=0;gE((v-e)/(l=r+1))&&b("overflow"),e+=(i-f)*l,f=i,g=0;gv&&b("overflow"),o==f){for(a=e,s=m;!(a<(u=s<=p?1:p+y<=s?y:s-p));s+=m)c.push(T(_(u+(h=a-u)%(u=m-u),0))),a=E(h/u);c.push(T(_(a,0))),p=S(e,l,r==n),e=0,++r}++e,++f}return c.join("")}g&&g.nodeType,t&&t.nodeType,(e="object"==typeof e&&e).global!==e&&e.window!==e&&e.self,v=2147483647,y=26,i=38,a=700,n=/^xn--/,s=/[^\x20-\x7E]/,o=/[\x2E\u3002\uFF0E\uFF61]/g,l={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},u=(m=36)-1,E=Math.floor,T=String.fromCharCode,r={version:"1.4.1",ucs2:{decode:A,encode:p},decode:d,encode:f,toASCII:function(t){return c(t,function(t){return s.test(t)?"xn--"+f(t):t})},toUnicode:function(t){return c(t,function(t){return n.test(t)?d(t.slice(4).toLowerCase()):t})}},void 0!==(e=function(){return r}.call(g,L,g,t))&&(t.exports=e)}.call(this,L(155)(t),L(31))},function(t,e,r){"use strict";var n=r(365),i=r(378),r=r(119);t.exports={formats:r,parse:i,stringify:n}},function(t,e,r){"use strict";function I(t,e){n.apply(t,x(e)?e:[e])}function D(t,e,r,n,i,a,s,o,l,u,h,c,d,f,p,g){for(var v=t,m=g,y=0,E=!1;void 0!==(m=m.get(M))&&!E;){var T=m.get(t);if(y+=1,void 0!==T){if(T===y)throw new RangeError("Cyclic object value");E=!0}void 0===m.get(M)&&(y=0)}if("function"==typeof o?v=o(e,v):v instanceof Date?v=h(v):"comma"===r&&x(v)&&(v=P.maybeMap(v,function(t){return t instanceof Date?h(t):t})),null===v){if(i)return s&&!f?s(e,O.encoder,p,"key",c):e;v=""}if("string"==typeof(A=v)||"number"==typeof A||"boolean"==typeof A||"symbol"==typeof A||"bigint"==typeof A||P.isBuffer(v))return s?[d(f?e:s(e,O.encoder,p,"key",c))+"="+d(s(v,O.encoder,p,"value",c))]:[d(e)+"="+d(String(v))];var b=[];if(void 0!==v)for(var A,_,_="comma"===r&&x(v)?[{value:0<(v=f&&s?P.maybeMap(v,s):v).length?v.join(",")||null:void 0}]:x(o)?o:(A=Object.keys(v),l?A.sort(l):A),S=n&&x(v)&&1===v.length?e+"[]":e,L=0;L<_.length;++L){var k,R=_[L],w="object"==typeof R&&void 0!==R.value?R.value:v[R];a&&null===w||(R=x(v)?"function"==typeof r?r(S,R):S:S+(u?"."+R:"["+R+"]"),g.set(t,y),(k=C()).set(M,g),I(b,D(w,R,r,n,i,a,"comma"===r&&f&&x(v)?null:s,o,l,u,h,c,d,f,p,k)))}return b}var C=r(366),P=r(158),c=r(119),d=Object.prototype.hasOwnProperty,f={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},x=Array.isArray,n=Array.prototype.push,i=Date.prototype.toISOString,r=c.default,O={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:P.encode,encodeValuesOnly:!1,format:r,formatter:c.formatters[r],indices:!1,serializeDate:function(t){return i.call(t)},skipNulls:!1,strictNullHandling:!1},M={};t.exports=function(t,e){var r=t,n=function(t){if(!t)return O;if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||O.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=c.default;if(void 0!==t.format){if(!d.call(c.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var n=c.formatters[r],i=O.filter;return"function"!=typeof t.filter&&!x(t.filter)||(i=t.filter),{addQueryPrefix:("boolean"==typeof t.addQueryPrefix?t:O).addQueryPrefix,allowDots:void 0===t.allowDots?O.allowDots:!!t.allowDots,charset:e,charsetSentinel:("boolean"==typeof t.charsetSentinel?t:O).charsetSentinel,delimiter:(void 0===t.delimiter?O:t).delimiter,encode:("boolean"==typeof t.encode?t:O).encode,encoder:("function"==typeof t.encoder?t:O).encoder,encodeValuesOnly:("boolean"==typeof t.encodeValuesOnly?t:O).encodeValuesOnly,filter:i,format:r,formatter:n,serializeDate:("function"==typeof t.serializeDate?t:O).serializeDate,skipNulls:("boolean"==typeof t.skipNulls?t:O).skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:("boolean"==typeof t.strictNullHandling?t:O).strictNullHandling}}(e),i=("function"==typeof n.filter?r=(0,n.filter)("",r):x(n.filter)&&(o=n.filter),[]);if("object"!=typeof r||null===r)return"";var t=e&&e.arrayFormat in f?e.arrayFormat:!(e&&"indices"in e)||e.indices?"indices":"repeat",a=f[t];if(e&&"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var s="comma"===a&&e&&e.commaRoundTrip,o=o||Object.keys(r);n.sort&&o.sort(n.sort);for(var l=C(),u=0;u 0, or `null`');if(H(s,"numericSeparator")&&"boolean"!=typeof s.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var e=s.numericSeparator;if(void 0===r)return"undefined";if(null===r)return"null";if("boolean"==typeof r)return r?"true":"false";if("string"==typeof r)return function t(e,r){if(e.length>r.maxStringLength)return n=e.length-r.maxStringLength,n="... "+n+" more character"+(1"}if(G(r))return 0===r.length?"[]":(l=z(r,g),p&&!function(t){for(var e=0;e "+g(t,r))}),nt("Map",E.call(r),u,p)):function(t){if(b&&t&&"object"==typeof t)try{b.call(t);try{E.call(t)}catch(t){return 1}return t instanceof Set}catch(t){}return}(r)?(h=[],A&&A.call(r,function(t){h.push(g(t,r))}),nt("Set",b.call(r),h,p)):function(t){if(_&&t&&"object"==typeof t)try{_.call(t,_);try{S.call(t,S)}catch(t){return 1}return t instanceof WeakMap}catch(t){}return}(r)?Y("WeakMap"):function(t){if(S&&t&&"object"==typeof t)try{S.call(t,S);try{_.call(t,_)}catch(t){return 1}return t instanceof WeakSet}catch(t){}return}(r)?Y("WeakSet"):function(t){if(L&&t&&"object"==typeof t)try{return L.call(t),1}catch(t){}return}(r)?Y("WeakRef"):"[object Number]"!==V(c=r)||O&&"object"==typeof c&&O in c?function(t){if(t&&"object"==typeof t&&C)try{return C.call(t),1}catch(t){}return}(r)?W(g(C.call(r))):"[object Boolean]"!==V(e=r)||O&&"object"==typeof e&&O in e?"[object String]"!==V(t=r)||O&&"object"==typeof t&&O in t?"undefined"!=typeof window&&r===window?"{ [object Window] }":r===Q?"{ [object globalThis] }":("[object Date]"!==V(e=r)||O&&"object"==typeof e&&O in e)&&!$(r)?(t=z(r,g),e=F?F(r)===Object.prototype:r instanceof Object||r.constructor===Object,d=r instanceof Object?"":"null prototype",f=!e&&O&&Object(r)===r&&O in r?k.call(V(r),8,-1):d?"Object":"",e=(!e&&"function"==typeof r.constructor&&r.constructor.name?r.constructor.name+" ":"")+(f||d?"["+D.call(I.call([],f||[],d||[]),": ")+"] ":""),0===t.length?e+"{}":p?e+"{"+q(t,p)+"}":e+"{ "+D.call(t,", ")+" }"):String(r):W(g(String(r))):W(X.call(r)):W(g(Number(r)))};var a=Object.prototype.hasOwnProperty||function(t){return t in this};function H(t,e){return a.call(t,e)}function V(t){return r.call(t)}function et(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;rul{overflow-x:hidden;overflow-y:auto;list-style-type:none;position:absolute;bottom:100%;display:none;background-color:rgba(28,28,28,.9);white-space:nowrap}.level_selector[data-level-selector] li{font-size:12px;color:#eee}.level_selector[data-level-selector] li[data-title]{background-color:#333;padding:8px 25px}.level_selector[data-level-selector] li a{color:#eee;padding:5px 18px;display:block;text-decoration:none}.level_selector[data-level-selector] li a:hover{background-color:rgba(255,255,255,.1);color:#fff}.level_selector[data-level-selector] li a:hover a{color:#fff;text-decoration:none}.level_selector[data-level-selector] li.current a{color:#2ecc71}@-webkit-keyframes pulse{0%{color:#fff}50%{color:#ff0101}100%{color:#b80000}}',""])},function(t,e){t.exports=function(r){var s=[];return s.toString=function(){return this.map(function(t){var e=function(t,e){var r=t[1]||"",n=t[3];if(!n)return r;if(e&&"function"==typeof btoa)return t=function(t){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(t))))+" */"}(n),e=n.sources.map(function(t){return"/*# sourceURL="+n.sourceRoot+t+" */"}),[r].concat(e).concat([t]).join("\n");return[r].join("\n")}(t,r);return t[2]?"@media "+t[2]+"{"+e+"}":e}).join("")},s.i=function(t,e){"string"==typeof t&&(t=[[null,t,""]]);for(var r={},n=0;n_&&++y