/*! For license information please see main.ba6d63bf3213ba56553b.js.LICENSE.txt */ var LivePlayer=function(t){function e(e){for(var n,a,o=e[0],l=e[1],c=e[2],h=0,d=[];h=t.length&&(t=void 0),{value: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,s=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return a}function l(){for(var t=[],e=0;e=0&&c<=100?c:void 0)),1===v.mute?v.mute=!0:0===v.mute&&(v.mute=!1),function(t,e){var r={};for(var n in t){var i=t[n];"streamName"===n||e&&e.indexOf(n)>-1||null!==i&&"object"===l()(i)?r[n]=i:r[n]=null!=m(i)?m(i):i}return r}(v,[g(v),"volume"])};function v(t){var e=g(t);return[].concat(p,e?[e]:[])}function E(t){var e=g(t),r=t[e];return r?"".concat(e,"=").concat(r):void 0}var b=function(t){var e=t.from,r=t.to;return e&&r&&r-e>0?r-e:void 0},T=function(t,e){return e?"".concat(t).concat(t.includes("?")?"&":"?").concat(e):t};function S(t){if(!1===t.poster)return{isVideoPoster:!1,poster:!1};var e,r,n,i,s,a;return{isVideoPoster:!t.hasPreview,poster:(e=E(t),r=t.host,n=t.protocol,i=t.streamName,s=t.hasPreview?"jpg":"mp4",a="".concat(n,"//").concat(r,"/").concat(i,"/preview.").concat(s),T(a,e))}}var A=function(t,e){var r=t.authToken,n=t.protocol,i=t.host,s=t.streamName;return T("".concat(n,"//").concat(i,"/").concat(s,"/").concat(e),r)},_=function(t,e){var r=t.proto,n=t.streamName,i=t.ago,s=t.from,a=t.duration,o=t.realtime,l=t.protocol,c=t.host,u=t.debug,h=t.authToken,d=t.url,f=t.source,p=t.timeshift,g=t.filterTracks;return function(){var t=d||f,m=".fmp4.m3u8";switch(r){case"dash":m=".mpd";break;case"ll-hls":m=o?".ll.m3u8":".fmp4.m3u8";break;default:m=".fmp4.m3u8"}return window.navigator.userAgent.includes("(Web0S; Linux/SmartTV)")&&(m="dash"),t||(t="//".concat(c,"/").concat(n,"/"),o&&e&&!i?"ll-hls"!==r&&e?t+="mse_ld".concat(s?"?from=".concat(s):""):t="".concat(l).concat(t,"index").concat(m):(t="".concat(l).concat(t),t+=i?"rewind-".concat(i).concat("dash"===r?"?thumbnails=100":""):s?"archive-".concat(s,"-").concat(a||"7200"):!p||"hls"!==r&&r?"index":"timeshift_".concat(p.length>=10?"abs":"rel","-").concat(p),t+=m,(i||s||p&&("hls"===r||!r))&&(t=t.replace(".fmp4","")))),t=T(t,h),g&&(t="".concat(t).concat(t.includes("?")?"&":"?","filter.tracks=").concat(g)),u&&console.info("set source",t),t}},k=function(t){var e=t.streamName,r=t.host,n=t.authToken,i="//".concat(r,"/").concat(e,"/media_info.json");return i=T(i,n)},L=function(){var t=window.navigator.userAgent;if(t.includes("Chrome")){var e=t.split("Chrome/")[1];if(Number(e.split(".")[0])>=107)return!0}else if(t.includes("Safari"))return!0;return!1},w=function(t,e){return e.indexOf(t)>-1};function R(t,e){return function(r){var n=w(r,e)?t[r]:void 0;return"true"===n||"on"===n||"false"!==n&&"off"!==n&&n}}},,,,,function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(t,e,r){"use strict";var n,i=r(374),s=r(375),a=r(376),o=r(377),l=r(157),c=r(70),u=r(378),h=Function,d=function(t){try{return h('"use strict"; return ('+t+").constructor;")()}catch(t){}},f=Object.getOwnPropertyDescriptor;if(f)try{f({},"")}catch(t){f=null}var p=function(){throw new c},g=f?function(){try{return p}catch(t){try{return f(arguments,"callee").get}catch(t){return p}}}():p,m=r(379)(),y=r(381)(),v=Object.getPrototypeOf||(y?function(t){return t.__proto__}:null),E={},b="undefined"!=typeof Uint8Array&&v?v(Uint8Array):n,T={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":m&&v?v([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":E,"%AsyncGenerator%":E,"%AsyncGeneratorFunction%":E,"%AsyncIteratorPrototype%":E,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":s,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":h,"%GeneratorFunction%":E,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":m&&v?v(v([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&m&&v?v((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":a,"%ReferenceError%":o,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&m&&v?v((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":m&&v?v(""[Symbol.iterator]()):n,"%Symbol%":m?Symbol:n,"%SyntaxError%":l,"%ThrowTypeError%":g,"%TypedArray%":b,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":u,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet};if(v)try{null.error}catch(t){var S=v(v(t));T["%Error.prototype%"]=S}var A=function t(e){var r;if("%AsyncFunction%"===e)r=d("async function () {}");else if("%GeneratorFunction%"===e)r=d("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=d("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var i=t("%AsyncGenerator%");i&&v&&(r=v(i.prototype))}return T[e]=r,r},_={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},k=r(118),L=r(383),w=k.call(Function.call,Array.prototype.concat),R=k.call(Function.apply,Array.prototype.splice),C=k.call(Function.call,String.prototype.replace),D=k.call(Function.call,String.prototype.slice),I=k.call(Function.call,RegExp.prototype.exec),x=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,P=/\\(\\)?/g,O=function(t,e){var r,n=t;if(L(_,n)&&(n="%"+(r=_[n])[0]+"%"),L(T,n)){var i=T[n];if(i===E&&(i=A(n)),void 0===i&&!e)throw new c("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new l("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new c('"allowMissing" argument must be a boolean');if(null===I(/^%?[^%]*%?$/,t))throw new l("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=D(t,0,1),r=D(t,-1);if("%"===e&&"%"!==r)throw new l("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new l("invalid intrinsic syntax, expected opening `%`");var n=[];return C(t,x,(function(t,e,r,i){n[n.length]=r?C(i,P,"$1"):e||t})),n}(t),n=r.length>0?r[0]:"",i=O("%"+n+"%",e),s=i.name,a=i.value,o=!1,u=i.alias;u&&(n=u[0],R(r,w([0,1],u)));for(var h=1,d=!0;h=r.length){var y=f(a,p);a=(d=!!y)&&"get"in y&&!("originalValue"in y.get)?y.get:a[p]}else d=L(a,p),a=a[p];d&&!o&&(T[s]=a)}}return a}},function(t,e){function r(e){return t.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},t.exports.__esModule=!0,t.exports.default=t.exports,r(e)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(361),i=r(362),s=r(155),a=r(363);t.exports=function(t){return n(t)||i(t)||s(t)||a()},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(365)();t.exports=n;try{regeneratorRuntime=n}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}},,,,,,,function(t,e,r){"use strict";t.exports=TypeError},,,,,,function(t,e){var r,n,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function o(t){if(r===setTimeout)return setTimeout(t,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(t){r=s}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(t){n=a}}();var l,c=[],u=!1,h=-1;function d(){u&&l&&(u=!1,l.length?c=l.concat(c):h=-1,c.length&&f())}function f(){if(!u){var t=o(d);u=!0;for(var e=c.length;e;){for(l=c,c=[];++h1)for(var r=1;rt.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.width16?(o=e,t(e)):setTimeout((function(){polyfill(t)}),0)});window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame;function c(t){var e=window,r=e.innerWidth,n=e.innerHeight,i=document.documentElement,s=i.clientHeight,a=i.clientWidth,o=t.getBoundingClientRect(),l=o.bottom,c=o.right,u=o.left,h=o.top;return l>=0&&c>=0&&h<=(n||s)&&u<=(r||a)}},,,,function(t,e,r){"use strict";r.d(e,"a",(function(){return ro}));var n=r(62),i=r.n(n),s=r(17),a=r.n(s),o=r(5),l=r.n(o),c=r(6),u=r.n(c),h=r(7),d=r.n(h),f=r(3),p=r.n(f),g=r(15),m=r.n(g),y=r(8),v=r.n(y),E=r(4);function b(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var T={exports:{}};!function(t){var e,r,n,i,s;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(t,e,n){if(n=n||{},t=t.trim(),!(e=e.trim())){if(!n.alwaysNormalize)return t;var i=s.parseURL(t);if(!i)throw new Error("Error trying to parse base URL.");return i.path=s.normalizePath(i.path),s.buildURLFromParts(i)}var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return n.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):e;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=r.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var c={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(c.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var u=o.path,h=u.substring(0,u.lastIndexOf("/")+1)+a.path;c.path=s.normalizePath(h)}else c.path=o.path,a.params||(c.params=o.params,a.query||(c.query=o.query));return null===c.path&&(c.path=n.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(c)},parseURL:function(t){var r=e.exec(t);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(n,"");t.length!==(t=t.replace(i,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=s}(T);var S=T.exports;function A(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function _(t){for(var e=1;e`):O}(e)}))}const N=F,U=/^(\d+)x(\d+)$/,$=/(.+?)=(".*?"|.*?)(?:,|$)/g;class j{constructor(t){"string"==typeof t&&(t=j.parseAttrList(t)),w(this,t)}get clientAttrs(){return Object.keys(this).filter((t=>"X-"===t.substring(0,2)))}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;const r=new Uint8Array(e.length/2);for(let t=0;tNumber.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const r=this[t];return r?parseFloat(r):e}enumeratedString(t){return this[t]}bool(t){return"YES"===this[t]}decimalResolution(t){const e=U.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const r={};for($.lastIndex=0;null!==(e=$.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}}function G(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}class K{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const r=e.attr;for(const e in r)if(Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==r[e]){N.warn(`DATERANGE tag attribute: "${e}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=e;break}t=w(new j({}),r,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const t=new Date(this.attr["END-DATE"]);R(t.getTime())&&(this._endDate=t)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const t=this.duration;return null!==t?new Date(this._startDate.getTime()+1e3*t):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(R(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&&R(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class H{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 V="audio",W="video",Y="audiovideo";class q{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[V]:null,[W]:null,[Y]:null},this.baseurl=t}setByteRange(t,e){const r=t.split("@",2);let n;n=1===r.length?(null==e?void 0:e.byteRangeEndOffset)||0:parseInt(r[1]),this._byteRange=[n,parseInt(r[0])+n]}get byteRange(){return this._byteRange?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=S.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class z extends q{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 H,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const 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(){if(null===this.programDateTime)return null;if(!R(this.programDateTime))return null;const t=R(this.duration)?this.duration:0;return this.programDateTime+1e3*t}get encrypted(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),e=t.length;if(e>1||1===e&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()}setElementaryStreamInfo(t,e,r,n,i,s=!1){const{elementaryStreams:a}=this,o=a[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,n),o.endDTS=Math.max(o.endDTS,i)):a[t]={startPTS:e,endPTS:r,startDTS:n,endDTS:i,partial:s}}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[V]=null,t[W]=null,t[Y]=null}}class X extends q{constructor(t,e,r,n,i){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new H,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=n;const s=t.enumeratedString("BYTERANGE");s&&this.setByteRange(s,i),i&&(this.fragOffset=i.fragOffset+i.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}class Q{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t)return this.advanced=!0,void(this.updated=!0);const e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return!!this.fragments.length&&R(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const t=this.driftEndTime-this.driftStartTime;if(t>0){return 1e3*(this.driftEnd-this.driftStart)/t}return 1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return null!=(t=this.fragments)&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function J(t){return Uint8Array.from(atob(t),(t=>t.charCodeAt(0)))}function Z(t){const e=t.split(":");let r=null;if("data"===e[0]&&2===e.length){const t=e[1].split(";"),n=t[t.length-1].split(",");if(2===n.length){const e="base64"===n[0],i=n[1];e?(t.splice(-1,1),r=J(i)):r=function(t){const e=tt(t).subarray(0,16),r=new Uint8Array(16);return r.set(e,16-e.length),r}(i)}}return r}function tt(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(t=>t.charCodeAt(0)))}const et="undefined"!=typeof self?self:void 0;var rt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},nt="org.w3.clearkey",it="com.apple.streamingkeydelivery",st="com.microsoft.playready",at="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function ot(t){switch(t){case it:return rt.FAIRPLAY;case st:return rt.PLAYREADY;case at:return rt.WIDEVINE;case nt:return rt.CLEARKEY}}var lt="1077efecc0b24d02ace33c1e52e2fb4b",ct="e2719d58a985b3c9781ab030af78d30e",ut="9a04f07998404286ab92e65be0885f95",ht="edef8ba979d64acea3c827dcd51d21ed";function dt(t){return t===ht?rt.WIDEVINE:t===ut?rt.PLAYREADY:t===lt||t===ct?rt.CLEARKEY:void 0}function ft(t){switch(t){case rt.FAIRPLAY:return it;case rt.PLAYREADY:return st;case rt.WIDEVINE:return at;case rt.CLEARKEY:return nt}}function pt(t){const{drmSystems:e,widevineLicenseUrl:r}=t,n=e?[rt.FAIRPLAY,rt.WIDEVINE,rt.PLAYREADY,rt.CLEARKEY].filter((t=>!!e[t])):[];return!n[rt.WIDEVINE]&&r&&n.push(rt.WIDEVINE),n}const gt=null!=et&&null!=(mt=et.navigator)&&mt.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var mt;function yt(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}const vt=(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,Et=(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,bt=(t,e)=>{const r=e;let n=0;for(;vt(t,e);){n+=10;n+=Tt(t,e+6),Et(t,e+10)&&(n+=10),e+=n}if(n>0)return t.subarray(r,r+n)},Tt=(t,e)=>{let r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3],r},St=(t,e)=>vt(t,e)&&Tt(t,e+6)+10<=t.length-e,At=t=>{const e=Lt(t);for(let t=0;tt&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info,kt=t=>{const e=String.fromCharCode(t[0],t[1],t[2],t[3]),r=Tt(t,4);return{type:e,size:r,data:t.subarray(10,10+r)}},Lt=t=>{let e=0;const r=[];for(;vt(t,e);){const n=Tt(t,e+6);e+=10;const i=e+n;for(;e+8"PRIV"===t.type?Rt(t):"W"===t.type[0]?Dt(t):Ct(t),Rt=t=>{if(t.size<2)return;const e=xt(t.data,!0),r=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:r.buffer}},Ct=t=>{if(t.size<2)return;if("TXXX"===t.type){let e=1;const r=xt(t.data.subarray(e),!0);e+=r.length+1;const n=xt(t.data.subarray(e));return{key:t.type,info:r,data:n}}const e=xt(t.data.subarray(1));return{key:t.type,data:e}},Dt=t=>{if("WXXX"===t.type){if(t.size<2)return;let e=1;const r=xt(t.data.subarray(e),!0);e+=r.length+1;const n=xt(t.data.subarray(e));return{key:t.type,info:r,data:n}}const e=xt(t.data);return{key:t.type,data:e}},It=t=>{if(8===t.data.byteLength){const e=new Uint8Array(t.data),r=1&e[3];let n=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return n/=45,r&&(n+=47721858.84),Math.round(n)}},xt=(t,e=!1)=>{const r=Ot();if(r){const n=r.decode(t);if(e){const t=n.indexOf("\0");return-1!==t?n.substring(0,t):n}return n.replace(/\0/g,"")}const n=t.length;let i,s,a,o="",l=0;for(;l>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(i);break;case 12:case 13:s=t[l++],o+=String.fromCharCode((31&i)<<6|63&s);break;case 14:s=t[l++],a=t[l++],o+=String.fromCharCode((15&i)<<12|(63&s)<<6|63&a)}}return o};let Pt;function Ot(){if(!navigator.userAgent.includes("PlayStation 4"))return Pt||void 0===self.TextDecoder||(Pt=new self.TextDecoder("utf-8")),Pt}const Mt=function(t){let e="";for(let r=0;r>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function Vt(t,e){const r=[];if(!e.length)return r;const n=t.byteLength;for(let i=0;i1?i+s:n;if(Ut(t.subarray(i+4,i+8))===e[0])if(1===e.length)r.push(t.subarray(i+8,a));else{const n=Vt(t.subarray(i+8,a),e.slice(1));n.length&&Bt.apply(r,n)}i=a}return r}function Wt(t){const e=[],r=t[0];let n=8;const i=jt(t,n);n+=4;let s=0,a=0;0===r?(s=jt(t,n),a=jt(t,n+4),n+=8):(s=Gt(t,n),a=Gt(t,n+8),n+=16),n+=2;let o=t.length+a;const l=$t(t,n);n+=2;for(let r=0;r>>31)return N.warn("SIDX has hierarchical references (not supported)"),null;const l=jt(t,r);r+=4,e.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/i,start:o,end:o+a-1}}),o+=a,r+=4,n=r}return{earliestPresentationTime:s,timescale:i,version:r,referencesCount:l,references:e}}function Yt(t){const e=[],r=Vt(t,["moov","trak"]);for(let t=0;t{const r=jt(t,4),n=e[r];n&&(n.default={duration:jt(t,12),flags:jt(t,20)})})),e}function qt(t){const e=t.subarray(8),r=e.subarray(86),n=Ut(e.subarray(4,8));let i=n;const s="enca"===n||"encv"===n;if(s){const t=Vt(e,[n])[0];Vt(t.subarray("enca"===n?28:78),["sinf"]).forEach((t=>{const e=Vt(t,["schm"])[0];if(e){const r=Ut(e.subarray(4,8));if("cbcs"===r||"cenc"===r){const e=Vt(t,["frma"])[0];e&&(i=Ut(e))}}}))}switch(i){case"avc1":case"avc2":case"avc3":case"avc4":{const t=Vt(r,["avcC"])[0];i+="."+Xt(t[1])+Xt(t[2])+Xt(t[3]);break}case"mp4a":{const t=Vt(e,[n])[0],r=Vt(t.subarray(28),["esds"])[0];if(r&&r.length>12){let t=4;if(3!==r[t++])break;t=zt(r,t),t+=2;const e=r[t++];if(128&e&&(t+=2),64&e&&(t+=r[t++]),4!==r[t++])break;t=zt(r,t);const n=r[t++];if(64!==n)break;if(i+="."+Xt(n),t+=12,5!==r[t++])break;t=zt(r,t);const s=r[t++];let a=(248&s)>>3;31===a&&(a+=1+((7&s)<<3)+((224&r[t])>>5)),i+="."+a}break}case"hvc1":case"hev1":{const t=Vt(r,["hvcC"])[0],e=t[1],n=["","A","B","C"][e>>6],s=31&e,a=jt(t,2),o=(32&e)>>5?"H":"L",l=t[12],c=t.subarray(6,12);i+="."+n+s,i+="."+a.toString(16).toUpperCase(),i+="."+o+l;let u="";for(let t=c.length;t--;){const e=c[t];if(e||u){u="."+e.toString(16).toUpperCase()+u}}i+=u;break}case"dvh1":case"dvhe":{const t=Vt(r,["dvcC"])[0],e=t[2]>>1&127,n=t[2]<<5&32|t[3]>>3&31;i+="."+Qt(e)+"."+Qt(n);break}case"vp09":{const t=Vt(r,["vpcC"])[0],e=t[4],n=t[5],s=t[6]>>4&15;i+="."+Qt(e)+"."+Qt(n)+"."+Qt(s);break}case"av01":{const t=Vt(r,["av1C"])[0],e=t[1]>>>5,n=31&t[1],s=t[2]>>>7?"H":"M",a=(64&t[2])>>6,o=(32&t[2])>>5,l=2===e&&a?o?12:10:a?10:8,c=(16&t[2])>>4,u=(8&t[2])>>3,h=(4&t[2])>>2,d=3&t[2],f=1,p=1,g=1,m=0;i+="."+e+"."+Qt(n)+s+"."+Qt(l)+"."+c+"."+u+h+d+"."+Qt(f)+"."+Qt(p)+"."+Qt(g)+"."+m;break}}return{codec:i,encrypted:s}}function zt(t,e){const r=e+5;for(;128&t[e++]&&e{const l=o.byteOffset-8;Vt(o,["traf"]).map((o=>{const c=Vt(o,["tfdt"]).map((t=>{const e=t[0];let r=jt(t,4);return 1===e&&(r*=Math.pow(2,32),r+=jt(t,8)),r/i}))[0];return void 0!==c&&(t=c),Vt(o,["tfhd"]).map((c=>{const u=jt(c,4),h=16777215&jt(c,0);let d=0;const f=!!(16&h);let p=0;const g=!!(32&h);let m=8;u===s&&(!!(1&h)&&(m+=8),!!(2&h)&&(m+=4),!!(8&h)&&(d=jt(c,m),m+=4),f&&(p=jt(c,m),m+=4),g&&(m+=4),"video"===e.type&&(a=function(t){if(!t)return!1;const e=t.indexOf("."),r=e<0?t:t.substring(0,e);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(e.codec)),Vt(o,["trun"]).map((s=>{const o=s[0],c=16777215&jt(s,0),u=!!(1&c);let h=0;const f=!!(4&c),g=!!(256&c);let m=0;const y=!!(512&c);let v=0;const E=!!(1024&c),b=!!(2048&c);let T=0;const S=jt(s,4);let A=8;u&&(h=jt(s,A),A+=4),f&&(A+=4);let _=h+l;for(let l=0;l>1&63;return 39===t||40===t}return 6===(31&e)}function ne(t,e,r,n){const i=ie(t);let s=0;s+=e;let a=0,o=0,l=0;for(;s=i.length)break;l=i[s++],a+=l}while(255===l);o=0;do{if(s>=i.length)break;l=i[s++],o+=l}while(255===l);const t=i.length-s;let e=s;if(ot){N.error(`Malformed SEI payload. ${o} is too small, only ${t} bytes left to parse.`);break}if(4===a){if(181===i[e++]){const t=$t(i,e);if(e+=2,49===t){const t=jt(i,e);if(e+=4,1195456820===t){const t=i[e++];if(3===t){const s=i[e++],o=64&s,l=o?2+3*(31&s):0,c=new Uint8Array(l);if(o){c[0]=s;for(let t=1;t16){const t=[];for(let r=0;r<16;r++){const n=i[e++].toString(16);t.push(1==n.length?"0"+n:n),3!==r&&5!==r&&7!==r&&9!==r||t.push("-")}const s=o-16,l=new Uint8Array(s);for(let t=0;t0?(s=new Uint8Array(4),e.length>0&&new DataView(s.buffer).setUint32(0,e.length,!1)):s=new Uint8Array;const a=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(a.buffer).setUint32(0,r.byteLength,!1),function(t,...e){const r=e.length;let n=8,i=r;for(;i--;)n+=e[i].byteLength;const s=new Uint8Array(n);for(s[0]=n>>24&255,s[1]=n>>16&255,s[2]=n>>8&255,s[3]=255&n,s.set(t,4),i=0,n=8;i>>24;if(0!==i&&1!==i)return{offset:r,size:e};const s=t.buffer,a=Mt(new Uint8Array(s,r+12,16)),o=t.getUint32(28);let l=null,c=null;if(0===i){if(e-32>8*(15-r)&255;return e}(t);return new le(this.method,this.uri,"identity",this.keyFormatVersions,e)}const e=Z(this.uri);if(e)switch(this.keyFormat){case at:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case st:{const t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=se(t,null,e);const r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=String.fromCharCode.apply(null,Array.from(r)),i=n.substring(n.indexOf("<"),n.length),s=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(s){const t=s.childNodes[0]?s.childNodes[0].nodeValue:s.getAttribute("VALUE");if(t){const e=J(t).subarray(0,16);!function(t){const e=function(t,e,r){const 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)}(e),this.keyId=e}}break}default:{let t=e.subarray(0,16);if(16!==t.length){const e=new Uint8Array(16);e.set(t,16-t.length),t=e}this.keyId=t;break}}if(!this.keyId||16!==this.keyId.byteLength){let t=oe[this.uri];if(!t){const e=Object.keys(oe).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16);new DataView(t.buffer,12,4).setUint32(0,e),oe[this.uri]=t}this.keyId=t}return this}}const ce=/\{\$([a-zA-Z0-9-_]+)\}/g;function ue(t){return ce.test(t)}function he(t,e,r){if(null!==t.variableList||t.hasVariableRefs)for(let n=r.length;n--;){const i=r[n],s=e[i];s&&(e[i]=de(t,s))}}function de(t,e){if(null!==t.variableList||t.hasVariableRefs){const r=t.variableList;return e.replace(ce,(e=>{const n=e.substring(2,e.length-1),i=null==r?void 0:r[n];return void 0===i?(t.playlistParsingError||(t.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),e):i}))}return e}function fe(t,e,r){let n,i,s=t.variableList;if(s||(t.variableList=s={}),"QUERYPARAM"in e){n=e.QUERYPARAM;try{const t=new self.URL(r).searchParams;if(!t.has(n))throw new Error(`"${n}" does not match any query parameter in URI: "${r}"`);i=t.get(n)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${e.message}`))}}else n=e.NAME,i=e.VALUE;n in s?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):s[n]=i||""}function pe(t,e,r){const n=e.IMPORT;if(r&&n in r){let e=t.variableList;e||(t.variableList=e={}),e[n]=r[n]}else t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${n}"`))}function ge(t=!0){if("undefined"==typeof self)return;return(t||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}const me={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function ye(t,e,r=!0){return!t.split(",").some((t=>!ve(t,e,r)))}function ve(t,e,r=!0){var n;const i=ge(r);return null!=(n=null==i?void 0:i.isTypeSupported(Ee(t,e)))&&n}function Ee(t,e){return`${e}/mp4;codecs="${t}"`}function be(t){if(t){const e=t.substring(0,4);return me.video[e]}return 2}function Te(t){return t.split(",").reduce(((t,e)=>{const r=me.video[e];return r?(2*r+t)/(t?3:2):(me.audio[e]+t)/(t?2:1)}),0)}const Se={};const Ae=/flac|opus/i;function _e(t,e=!0){return t.replace(Ae,(t=>function(t,e=!0){if(Se[t])return Se[t];const r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[t];for(let n=0;n0&&n.length({id:t.attrs.AUDIO,audioCodec:t.audioCodec}))),SUBTITLES:s.map((t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec}))),"CLOSED-CAPTIONS":[]};let o=0;for(we.lastIndex=0;null!==(n=we.exec(t));){const t=new j(n[1]),s=t.TYPE;if(s){const n=a[s],l=i[s]||[];i[s]=l,he(r,t,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const c=t.LANGUAGE,u=t["ASSOC-LANGUAGE"],h=t.CHANNELS,d=t.CHARACTERISTICS,f=t["INSTREAM-ID"],p={attrs:t,bitrate:0,id:o++,groupId:t["GROUP-ID"]||"",name:t.NAME||c||"",type:s,default:t.bool("DEFAULT"),autoselect:t.bool("AUTOSELECT"),forced:t.bool("FORCED"),lang:c,url:t.URI?Ie.resolve(t.URI,e):""};if(u&&(p.assocLang=u),h&&(p.channels=h),d&&(p.characteristics=d),f&&(p.instreamId=f),null!=n&&n.length){const t=Ie.findGroup(n,p.groupId)||n[0];Me(p,t,"audioCodec"),Me(p,t,"textCodec")}l.push(p)}}return i}static parseLevelPlaylist(t,e,r,n,i,s){const a=new Q(e),o=a.fragments;let l,c,u,h=null,d=0,f=0,p=0,g=0,m=null,y=new z(n,e),v=-1,E=!1,b=null;for(Ce.lastIndex=0,a.m3u8=t,a.hasVariableRefs=ue(t);null!==(l=Ce.exec(t));){E&&(E=!1,y=new z(n,e),y.start=p,y.sn=d,y.cc=g,y.level=r,h&&(y.initSegment=h,y.rawProgramDateTime=h.rawProgramDateTime,h.rawProgramDateTime=null,b&&(y.setByteRange(b),b=null)));const t=l[1];if(t){y.duration=parseFloat(t);const e=(" "+l[2]).slice(1);y.title=e||null,y.tagList.push(e?["INF",t,e]:["INF",t])}else if(l[3]){if(R(y.duration)){y.start=p,u&&Ne(y,u,a),y.sn=d,y.level=r,y.cc=g,o.push(y);const t=(" "+l[3]).slice(1);y.relurl=de(a,t),Fe(y,m),m=y,p+=y.duration,d++,f=0,E=!0}}else if(l[4]){const t=(" "+l[4]).slice(1);m?y.setByteRange(t,m):y.setByteRange(t)}else if(l[5])y.rawProgramDateTime=(" "+l[5]).slice(1),y.tagList.push(["PROGRAM-DATE-TIME",y.rawProgramDateTime]),-1===v&&(v=o.length);else{if(l=l[0].match(De),!l){N.warn("No matches on slow regex match for level playlist!");continue}for(c=1;c0&&t.bool("CAN-SKIP-DATERANGES"),a.partHoldBack=t.optionalFloat("PART-HOLD-BACK",0),a.holdBack=t.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const t=new j(i);a.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let t=a.partList;t||(t=a.partList=[]);const r=f>0?t[t.length-1]:void 0,n=f++,s=new j(i);he(a,s,["BYTERANGE","URI"]);const o=new X(s,y,e,n,r);t.push(o),y.duration+=o.duration;break}case"PRELOAD-HINT":{const t=new j(i);he(a,t,["URI"]),a.preloadHint=t;break}case"RENDITION-REPORT":{const t=new j(i);he(a,t,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(t);break}default:N.warn(`line parsed but not handled: ${l}`)}}}m&&!m.relurl?(o.pop(),p-=m.duration,a.partList&&(a.fragmentHint=m)):a.partList&&(Fe(y,m),y.cc=g,a.fragmentHint=y,u&&Ne(y,u,a));const T=o.length,S=o[0],A=o[T-1];if(p+=a.skippedSegments*a.targetduration,p>0&&T&&A){a.averagetargetduration=p/T;const t=A.sn;a.endSN="initSegment"!==t?t:0,a.live||(A.endList=!0),S&&(a.startCC=S.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(p+=a.fragmentHint.duration),a.totalduration=p,a.endCC=g,v>0&&function(t,e){let r=t[e];for(let n=e;n--;){const e=t[n];if(!e)return;e.programDateTime=r.programDateTime-1e3*e.duration,r=e}}(o,v),a}}function xe(t,e,r){var n,i;const s=new j(t);he(r,s,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=null!=(n=s.METHOD)?n:"",o=s.URI,l=s.hexadecimalInteger("IV"),c=s.KEYFORMATVERSIONS,u=null!=(i=s.KEYFORMAT)?i:"identity";o&&s.IV&&!l&&N.error(`Invalid IV: ${s.IV}`);const h=o?Ie.resolve(o,e):"",d=(c||"1").split("/").map(Number).filter(Number.isFinite);return new le(a,h,u,d,l)}function Pe(t){const e=new j(t).decimalFloatingPoint("TIME-OFFSET");return R(e)?e:null}function Oe(t,e){let r=(t||"").split(/[ ,]+/).filter((t=>t));["video","audio","text"].forEach((t=>{const n=r.filter((e=>function(t,e){const r=me[e];return!!r&&!!r[t.slice(0,4)]}(e,t)));n.length&&(e[`${t}Codec`]=n.join(","),r=r.filter((t=>-1===n.indexOf(t))))})),e.unknownCodecs=r}function Me(t,e,r){const n=e[r];n&&(t[r]=n)}function Fe(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),R(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function Be(t,e,r,n){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=r,t.sn="initSegment",n&&(t.levelkeys=n),t.initSegment=null}function Ne(t,e,r){t.levelkeys=e;const{encryptedFragments:n}=r;n.length&&n[n.length-1].levelkeys===e||!Object.keys(e).some((t=>e[t].isCommonEncryption))||n.push(t)}var Ue="manifest",$e="level",je="audioTrack",Ge="subtitleTrack",Ke="main",He="audio",Ve="subtitle";function We(t){const{type:e}=t;switch(e){case je:return He;case Ge:return Ve;default:return Ke}}function Ye(t,e){let r=t.url;return void 0!==r&&0!==r.indexOf("data:")||(r=e.url),r}class qe{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(){const{hls:t}=this;t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_LOADING,this.onLevelLoading,this),t.on(I.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(I.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_LOADING,this.onLevelLoading,this),t.off(I.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(I.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,r=e.pLoader,n=e.loader,i=new(r||n)(e);return this.loaders[t.type]=i,i}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:r}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ue,url:r,deliveryDirectives:null})}onLevelLoading(t,e){const{id:r,level:n,pathwayId:i,url:s,deliveryDirectives:a}=e;this.load({id:r,level:n,pathwayId:i,responseType:"text",type:$e,url:s,deliveryDirectives:a})}onAudioTrackLoading(t,e){const{id:r,groupId:n,url:i,deliveryDirectives:s}=e;this.load({id:r,groupId:n,level:null,responseType:"text",type:je,url:i,deliveryDirectives:s})}onSubtitleTrackLoading(t,e){const{id:r,groupId:n,url:i,deliveryDirectives:s}=e;this.load({id:r,groupId:n,level:null,responseType:"text",type:Ge,url:i,deliveryDirectives:s})}load(t){var e;const r=this.hls.config;let n,i=this.getInternalLoader(t);if(i){const e=i.context;if(e&&e.url===t.url&&e.level===t.level)return void N.trace("[playlist-loader]: playlist request ongoing");N.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),i.abort()}if(n=t.type===Ue?r.manifestLoadPolicy.default:w({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),i=this.createInternalLoader(t),R(null==(e=t.deliveryDirectives)?void 0:e.part)){let e;if(t.type===$e&&null!==t.level?e=this.hls.levels[t.level].details:t.type===je&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===Ge&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e){const t=e.partTarget,r=e.targetduration;if(t&&r){const e=1e3*Math.max(3*t,.8*r);n=w({},n,{maxTimeToFirstByteMs:Math.min(e,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(e,n.maxTimeToFirstByteMs)})}}}const s=n.errorRetry||n.timeoutRetry||{},a={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},o={onSuccess:(t,e,r,n)=>{const i=this.getInternalLoader(r);this.resetInternalLoader(r.type);const s=t.data;0===s.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),Ie.isMediaPlaylist(s)?this.handleTrackOrLevelPlaylist(t,e,r,n||null,i):this.handleMasterPlaylist(t,e,r,n)):this.handleManifestParsingError(t,r,new Error("no EXTM3U delimiter"),n||null,e)},onError:(t,e,r,n)=>{this.handleNetworkError(e,r,!1,t,n)},onTimeout:(t,e,r)=>{this.handleNetworkError(e,r,!0,void 0,t)}};i.load(t,a,o)}handleMasterPlaylist(t,e,r,n){const i=this.hls,s=t.data,a=Ye(t,r),o=Ie.parseMasterPlaylist(s,a);if(o.playlistParsingError)return void this.handleManifestParsingError(t,r,o.playlistParsingError,n,e);const{contentSteering:l,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:d,variableList:f}=o;this.variableList=f;const{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":m}=Ie.parseMasterPlaylistMedia(s,a,o);if(p.length){p.some((t=>!t.url))||!c[0].audioCodec||c[0].attrs.AUDIO||(N.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new j({}),bitrate:0,url:""}))}i.trigger(I.MANIFEST_LOADED,{levels:c,audioTracks:p,subtitles:g,captions:m,contentSteering:l,url:a,stats:e,networkDetails:n,sessionData:u,sessionKeys:h,startTimeOffset:d,variableList:f})}handleTrackOrLevelPlaylist(t,e,r,n,i){const s=this.hls,{id:a,level:o,type:l}=r,c=Ye(t,r),u=R(o)?o:R(a)?a:0,h=We(r),d=Ie.parseLevelPlaylist(t.data,c,u,h,0,this.variableList);if(l===Ue){const t={attrs:new j({}),bitrate:0,details:d,name:"",url:c};s.trigger(I.MANIFEST_LOADED,{levels:[t],audioTracks:[],url:c,stats:e,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=d,this.handlePlaylistLoaded(d,t,e,r,n,i)}handleManifestParsingError(t,e,r,n,i){this.hls.trigger(I.ERROR,{type:x.NETWORK_ERROR,details:P.MANIFEST_PARSING_ERROR,fatal:e.type===Ue,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 s=`A network ${r?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${t.type}`;t.type===$e?s+=`: ${t.level} id: ${t.id}`:t.type!==je&&t.type!==Ge||(s+=` id: ${t.id} group-id: "${t.groupId}"`);const a=new Error(s);N.warn(`[playlist-loader]: ${s}`);let o=P.UNKNOWN,l=!1;const c=this.getInternalLoader(t);switch(t.type){case Ue:o=r?P.MANIFEST_LOAD_TIMEOUT:P.MANIFEST_LOAD_ERROR,l=!0;break;case $e:o=r?P.LEVEL_LOAD_TIMEOUT:P.LEVEL_LOAD_ERROR,l=!1;break;case je:o=r?P.AUDIO_TRACK_LOAD_TIMEOUT:P.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Ge:o=r?P.SUBTITLE_TRACK_LOAD_TIMEOUT:P.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(t.type);const u={type:x.NETWORK_ERROR,details:o,fatal:l,url:t.url,loader:c,context:t,error:a,networkDetails:e,stats:i};if(n){const r=(null==e?void 0:e.url)||t.url;u.response=_({url:r,data:void 0},n)}this.hls.trigger(I.ERROR,u)}handlePlaylistLoaded(t,e,r,n,i,s){const a=this.hls,{type:o,level:l,id:c,groupId:u,deliveryDirectives:h}=n,d=Ye(e,n),f=We(n),p="number"==typeof n.level&&f===Ke?l:void 0;if(!t.fragments.length){const t=new Error("No Segments found in Playlist");return void a.trigger(I.ERROR,{type:x.NETWORK_ERROR,details:P.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:t,reason:t.message,response:e,context:n,level:p,parent:f,networkDetails:i,stats:r})}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const g=t.playlistParsingError;if(g)a.trigger(I.ERROR,{type:x.NETWORK_ERROR,details:P.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:g,reason:g.message,response:e,context:n,level:p,parent:f,networkDetails:i,stats:r});else switch(t.live&&s&&(s.getCacheAge&&(t.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case Ue:case $e:a.trigger(I.LEVEL_LOADED,{details:t,level:p||0,id:c||0,stats:r,networkDetails:i,deliveryDirectives:h});break;case je:a.trigger(I.AUDIO_TRACK_LOADED,{details:t,id:c||0,groupId:u||"",stats:r,networkDetails:i,deliveryDirectives:h});break;case Ge:a.trigger(I.SUBTITLE_TRACK_LOADED,{details:t,id:c||0,groupId:u||"",stats:r,networkDetails:i,deliveryDirectives:h})}}}function ze(t,e){let r;try{r=new Event("addtrack")}catch(t){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function Xe(t,e){const r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){N.debug(`[texttrack-utils]: ${r}`);try{const r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,t.addCue(r)}catch(t){N.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${t}`)}}"disabled"===r&&(t.mode=r)}function Qe(t){const e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(let e=t.cues.length;e--;)t.removeCue(t.cues[e]);"disabled"===e&&(t.mode=e)}function Je(t,e,r,n){const i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues&&t.cues.length>0){const i=function(t,e,r){const n=[],i=function(t,e){if(et[r].endTime)return-1;let n=0,i=r;for(;n<=i;){const s=Math.floor((i+n)/2);if(et[s].startTime&&n-1)for(let s=i,a=t.length;s=e&&i.endTime<=r)n.push(i);else if(i.startTime>r)return n}return n}(t.cues,e,r);for(let e=0;e{const t=nr();try{t&&new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function ar(t,e){return t.getTime()/1e3-e}class or{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(){const{hls:t}=this;t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(I.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(I.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Qe(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;esr&&(n=sr);n-r<=0&&(n=r+.25);for(let t=0;tt.type===tr&&o:"video"===n?t=>t.type===rr&&a:t=>t.type===tr&&o||t.type===rr&&a,Je(i,e,r,t)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:r,id3Track:n}=this,{dateRanges:i}=e,s=Object.keys(i);if(n){const t=Object.keys(r).filter((t=>!s.includes(t)));for(let e=t.length;e--;){const i=t[e];Object.keys(r[i].cues).forEach((t=>{n.removeCue(r[i].cues[t])})),delete r[i]}}const a=e.fragments[e.fragments.length-1];if(0===s.length||!R(null==a?void 0:a.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const o=a.programDateTime/1e3-a.start,l=nr();for(let t=0;t{if(e!==n.id){const r=i[e];if(r.class===n.class&&r.startDate>n.startDate&&(!t||n.startDatethis.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(null===t)return null;const{holdBack:e,partHoldBack:r,targetduration:n}=t,{liveSyncDuration:i,liveSyncDurationCount:s,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&r||e;(o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==i?i:s*n);const c=n;return l+Math.min(1*this.stallCount,c)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(null===t||null===e||null===r)return null;const n=r.edge,i=t-e-this.edgeStalled,s=n-r.totalduration,a=n-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(s,i),a)}get drift(){const{levelDetails:t}=this;return null===t?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(null===t)return 0;const e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(I.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(I.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(I.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(I.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(I.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(I.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,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var r;e.details===P.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&N.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const r=this.computeLatency();if(null===r)return;this._latency=r;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:i}=this.config;if(!n||1===i||!e.live)return;const s=this.targetLatency;if(null===s)return;const a=r-s;if(a.05&&this.forwardBufferLength>1){const e=Math.min(2,Math.max(1,i)),r=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;t.playbackRate=Math.min(e,Math.max(1,r))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return null===t?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return null===t?null:t-this.currentTime}}const cr=["NONE","TYPE-0","TYPE-1",null];const ur=["SDR","PQ","HLG"];var hr="",dr="YES",fr="v2";function pr(t){const{canSkipUntil:e,canSkipDateRanges:r,age:n}=t;return e&&n!!t)).map((t=>t.substring(0,4))).join(","),this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(t){return yr(this._audioGroups,t)}hasSubtitleGroup(t){return yr(this._subtitleGroups,t)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(t,e){if(e)if("audio"===t){let t=this._audioGroups;t||(t=this._audioGroups=[]),-1===t.indexOf(e)&&t.push(e)}else if("text"===t){let t=this._subtitleGroups;t||(t=this._subtitleGroups=[]),-1===t.indexOf(e)&&t.push(e)}}get urlId(){return 0}set urlId(t){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var t;return null==(t=this.audioGroups)?void 0:t[0]}get textGroupId(){var t;return null==(t=this.subtitleGroups)?void 0:t[0]}addFallback(){}}function yr(t,e){return!(!e||!t)&&-1!==t.indexOf(e)}function vr(t,e){const r=e.startPTS;if(R(r)){let n,i=0;e.sn>t.sn?(i=r-t.start,n=t):(i=t.start-r,n=e),n.duration!==i&&(n.duration=i)}else if(e.sn>t.sn){t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration}else e.start=Math.max(t.start-e.duration,0)}function Er(t,e,r,n,i,s){n-r<=0&&(N.warn("Fragment should have a positive duration",e),n=r+e.duration,s=i+e.duration);let a=r,o=n;const l=e.startPTS,c=e.endPTS;if(R(l)){const t=Math.abs(l-r);R(e.deltaPTS)?e.deltaPTS=Math.max(t,e.deltaPTS):e.deltaPTS=t,a=Math.max(r,l),r=Math.min(r,l),i=Math.min(i,e.startDTS),o=Math.min(n,c),n=Math.max(n,c),s=Math.max(s,e.endDTS)}const u=r-e.start;0!==e.start&&(e.start=r),e.duration=n-e.start,e.startPTS=r,e.maxStartPTS=a,e.startDTS=i,e.endPTS=n,e.minEndPTS=o,e.endDTS=s;const h=e.sn;if(!t||ht.endSN)return 0;let d;const f=h-t.startSN,p=t.fragments;for(p[f]=e,d=f;d>0;d--)vr(p[d],p[d-1]);for(d=f;d=0;t--){const e=n[t].initSegment;if(e){r=e;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;let i,s=0;if(function(t,e,r){const n=e.skippedSegments,i=Math.max(t.startSN,e.startSN)-e.startSN,s=(t.fragmentHint?1:0)+(n?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,a=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;for(let t=i;t<=s;t++){const i=l[a+t];let s=o[t];n&&!s&&t{t.relurl&&(s=t.cc-n.cc),R(t.startPTS)&&R(t.endPTS)&&(n.start=n.startPTS=t.startPTS,n.startDTS=t.startDTS,n.maxStartPTS=t.maxStartPTS,n.endPTS=t.endPTS,n.endDTS=t.endDTS,n.minEndPTS=t.minEndPTS,n.duration=t.endPTS-t.startPTS,n.duration&&(i=n),e.PTSKnown=e.alignedSliding=!0),n.elementaryStreams=t.elementaryStreams,n.loader=t.loader,n.stats=t.stats,t.initSegment&&(n.initSegment=t.initSegment,r=t.initSegment)})),r){(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((t=>{var e;!t||t.initSegment&&t.initSegment.relurl!==(null==(e=r)?void 0:e.relurl)||(t.initSegment=r)}))}if(e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some((t=>!t)),e.deltaUpdateFailed){N.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let t=e.skippedSegments;t--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=function(t,e,r){const n=w({},t);r&&r.forEach((t=>{delete n[t]}));return Object.keys(e).forEach((t=>{const r=new K(e[t].attr,n[t]);r.isValid?n[t]=r:N.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[t].attr)}"`)})),n}(t.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const a=e.fragments;if(s){N.warn("discontinuity sliding from playlist, take drift into account");for(let t=0;t{e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),i?Er(e,i,i.startPTS,i.endPTS,i.startDTS,i.endDTS):Tr(t,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;const o=e.advancedDateTime;if(e.advanced&&o){const t=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=t),e.driftEndTime=o,e.driftEnd=t}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime}function Tr(t,e){const r=e.startSN+e.skippedSegments-t.startSN,n=t.fragments;r<0||r>=n.length||Sr(e,n[r].start)}function Sr(t,e){if(e){const r=t.fragments;for(let n=t.skippedSegments;n{const{details:r}=t;null!=r&&r.fragments&&r.fragments.forEach((t=>{t.level=e}))}))}function Lr(t){switch(t.details){case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_TIMEOUT:case P.LEVEL_LOAD_TIMEOUT:case P.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function wr(t,e){const r=Lr(e);return t.default[(r?"timeout":"error")+"Retry"]}function Rr(t,e){const r="linear"===t.backoff?1:Math.pow(2,e);return Math.min(r*t.retryDelayMs,t.maxRetryDelayMs)}function Cr(t){return _(_({},t),{errorRetry:null,timeoutRetry:null})}function Dr(t,e,r,n){if(!t)return!1;const i=null==n?void 0:n.code,s=e499)}(i)||!!r);return t.shouldRetry?t.shouldRetry(t,e,r,n,s):s}const Ir=function(t,e){let r=0,n=t.length-1,i=null,s=null;for(;r<=n;){i=(r+n)/2|0,s=t[i];const a=e(s);if(a>0)r=i+1;else{if(!(a<0))return s;n=i-1}}return null};function xr(t,e,r=0,n=0,i=.005){let s=null;if(t){s=e[t.sn-e[0].sn+1]||null;const n=t.endDTS-r;n>0&&n<15e-7&&(r+=15e-7)}else 0===r&&0===e[0].start&&(s=e[0]);if(s&&((!t||t.level===s.level)&&0===Pr(r,n,s)||function(t,e,r){if(e&&0===e.start&&e.level0){const n=e.tagList.reduce(((t,e)=>("INF"===e[0]&&(t+=parseFloat(e[1])),t)),r);return t.start<=n}return!1}(s,t,Math.min(i,n))))return s;const a=Ir(e,Pr.bind(null,r,n));return!a||a===t&&s?s:a}function Pr(t=0,e=0,r){if(r.start<=t&&r.start+r.duration>t)return 0;const n=Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-n<=t?1:r.start-n>t&&r.start?-1:0}function Or(t,e,r){const n=1e3*Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-n>t}var Mr=0,Fr=2,Br=3,Nr=5,Ur=0,$r=1,jr=2;class Gr{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=N.log.bind(N,`${e}:`),this.warn=N.warn.bind(N,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e,r){const n=null==e?void 0:e.renditionReports;if(n){let i=-1;for(let r=0;r=0&&t>e.partTarget&&(a+=1)}const o=r&&pr(r);return new gr(s,a>=0?a:void 0,o)}}}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,e,r){const{details:n,stats:i}=e,s=self.performance.now(),a=i.loading.first?Math.max(0,s-i.loading.first):0;if(n.advancedDateTime=Date.now()-a,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log(`live playlist ${t} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),r&&n.fragments.length>0&&br(r,n),!this.canLoad||!n.live)return;let a,o,l;if(n.canBlockReload&&n.endSN&&n.advanced){const t=this.hls.config.lowLatencyMode,i=n.lastPartSn,s=n.endSN,c=n.lastPartIndex,u=i===s;-1!==c?(o=u?s+1:i,l=u?t?0:c:c+1):o=s+1;const h=n.age,d=h+n.ageHeader;let f=Math.min(d-n.partTarget,1.5*n.targetduration);if(f>0){if(r&&f>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${f} with playlist age: ${n.age}`),f=0;else{const t=Math.floor(f/n.targetduration);if(o+=t,void 0!==l){l+=Math.round(f%n.targetduration/n.partTarget)}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${h.toFixed(2)}s goal: ${f} skip sn ${t} to part ${l}`)}n.tuneInGoal=f}if(a=this.getDeliveryDirectives(n,e.deliveryDirectives,o,l),t||!u)return void this.loadPlaylist(a)}else(n.canBlockReload||n.canSkipUntil)&&(a=this.getDeliveryDirectives(n,e.deliveryDirectives,o,l));const c=this.hls.mainForwardBufferInfo,u=c?c.end-c.len:0,h=function(t,e=1/0){let r=1e3*t.targetduration;if(t.updated){const n=t.fragments,i=4;if(n.length&&r*i>e){const t=1e3*n[n.length-1].duration;tthis.requestScheduled+h&&(this.requestScheduled=i.loading.start),void 0!==o&&n.canBlockReload?this.requestScheduled=i.loading.first+h-(1e3*n.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+hthis.loadPlaylist(a)),d)}else this.clearTimer()}getDeliveryDirectives(t,e,r,n){let i=pr(t);return null!=e&&e.skip&&t.deltaUpdateFailed&&(r=e.msn,n=e.part,i=hr),new gr(r,n,i)}checkRetry(t){const e=t.details,r=Lr(t),n=t.errorAction,{action:i,retryCount:s=0,retryConfig:a}=n||{},o=!!n&&!!a&&(i===Nr||!n.resolved&&i===Fr);if(o){var l;if(this.requestScheduled=-1,s>=a.maxNumRetry)return!1;if(r&&null!=(l=t.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const t=Rr(a,s);this.timer=self.setTimeout((()=>this.loadPlaylist()),t),this.warn(`Retrying playlist loading ${s+1}/${a.maxNumRetry} after "${e}" in ${t}ms`)}t.levelRetry=!0,n.resolved=!0}return o}}class Kr{constructor(t,e=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r}sample(t,e){const r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class Hr{constructor(t,e,r,n=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Kr(t),this.fast_=new Kr(e),this.defaultTTFB_=n,this.ttfb_=new Kr(t)}update(t,e){const{slow_:r,fast_:n,ttfb_:i}=this;r.halfLife!==t&&(this.slow_=new Kr(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.fast_=new Kr(e,n.getEstimate(),n.getTotalWeight())),i.halfLife!==t&&(this.ttfb_=new Kr(t,i.getEstimate(),i.getTotalWeight()))}sample(t,e){const r=(t=Math.max(t,this.minDelayMs_))/1e3,n=8*e/r;this.fast_.sample(r,n),this.slow_.sample(r,n)}sampleTTFB(t){const e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))}canEstimate(){return this.fast_.getTotalWeight()>=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(){}}const Vr={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},Wr={};function Yr(t,e,r,n,i,s){const a=t.audioCodec?t.audioGroups:null,o=null==s?void 0:s.audioCodec,l=null==s?void 0:s.channels,c=l?parseInt(l):o?1/0:2;let u=null;if(null!=a&&a.length)try{u=1===a.length&&a[0]?e.groups[a[0]].channels:a.reduce(((t,r)=>{if(r){const n=e.groups[r];if(!n)throw new Error(`Audio track group ${r} not found`);Object.keys(n.channels).forEach((e=>{t[e]=(t[e]||0)+n.channels[e]}))}return t}),{2:0})}catch(t){return!0}return void 0!==t.videoCodec&&(t.width>1920&&t.height>1088||t.height>1920&&t.width>1088||t.frameRate>Math.max(n,30)||"SDR"!==t.videoRange&&t.videoRange!==r||t.bitrate>Math.max(i,8e6))||!!u&&R(c)&&Object.keys(u).some((t=>parseInt(t)>c))}function qr(t,e,r){const n=t.videoCodec,i=t.audioCodec;if(!n||!i||!r)return Promise.resolve(Vr);const s={width:t.width,height:t.height,bitrate:Math.ceil(Math.max(.9*t.bitrate,t.averageBitrate)),framerate:t.frameRate||30},a=t.videoRange;"SDR"!==a&&(s.transferFunction=a.toLowerCase());const o=n.split(",").map((t=>({type:"media-source",video:_(_({},s),{},{contentType:Ee(t,"video")})})));return i&&t.audioGroups&&t.audioGroups.forEach((t=>{var r;t&&(null==(r=e.groups[t])||r.tracks.forEach((e=>{if(e.groupId===t){const t=e.channels||"",r=parseFloat(t);R(r)&&r>2&&o.push.apply(o,i.split(",").map((t=>({type:"media-source",audio:{contentType:Ee(t,"audio"),channels:""+r}}))))}})))})),Promise.all(o.map((t=>{const e=function(t){const{audio:e,video:r}=t,n=r||e;if(n){const t=n.contentType.split('"')[1];if(r)return`r${r.height}x${r.width}f${Math.ceil(r.framerate)}${r.transferFunction||"sd"}_${t}_${Math.ceil(r.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${t}`}return""}(t);return Wr[e]||(Wr[e]=r.decodingInfo(t))}))).then((t=>({supported:!t.some((t=>!t.supported)),configurations:o,decodingInfoResults:t}))).catch((t=>({supported:!1,configurations:o,decodingInfoResults:[],error:t})))}function zr(t,e){let r=!1,n=[];return t&&(r="SDR"!==t,n=[t]),e&&(n=e.allowedVideoRanges||ur.slice(0),r=void 0!==e.preferHDR?e.preferHDR:function(){if("function"==typeof matchMedia){const t=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(t.media!==e.media)return!0===t.matches}return!1}(),n=r?n.filter((t=>"SDR"!==t)):["SDR"]),{preferHDR:r,allowedVideoRanges:n}}function Xr(t,e){N.log(`[abr] start candidates with "${t}" ignored because ${e}`)}function Qr(t,e,r){if("attrs"in t){const r=e.indexOf(t);if(-1!==r)return r}for(let n=0;n-1===n.indexOf(t)))}(o,e.characteristics))&&(void 0===r||r(t,e))}function Zr(t,e){const{audioCodec:r,channels:n}=t;return!(void 0!==r&&(e.audioCodec||"").substring(0,4)!==r.substring(0,4)||void 0!==n&&n!==(e.channels||"2"))}function tn(t,e,r){for(let n=e;n>-1;n--)if(r(t[n]))return n;for(let n=e+1;n1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var rn="NOT_LOADED",nn="APPENDING",sn="PARTIAL",an="OK";class on{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(){const{hls:t}=this;t.on(I.BUFFER_APPENDED,this.onBufferAppended,this),t.on(I.FRAG_BUFFERED,this.onFragBuffered,this),t.on(I.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(I.BUFFER_APPENDED,this.onBufferAppended,this),t.off(I.FRAG_BUFFERED,this.onFragBuffered,this),t.off(I.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const r=this.activePartLists[e];if(r)for(let e=r.length;e--;){const n=r[e];if(!n)break;const i=n.end;if(n.start<=t&&null!==i&&t<=i)return n}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:r}=this,n=Object.keys(r);for(let i=n.length;i--;){const s=r[n[i]];if((null==s?void 0:s.body.type)===e&&s.buffered){const e=s.body;if(e.start<=t&&t<=e.end)return e}}return null}detectEvictedFragments(t,e,r,n){this.timeRanges&&(this.timeRanges[t]=e);const i=(null==n?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach((n=>{const s=this.fragments[n];if(!s)return;if(i>=s.body.sn)return;if(!s.buffered&&!s.loaded)return void(s.body.type===r&&this.removeFragment(s.body));const a=s.range[t];a&&a.time.some((t=>{const r=!this.isTimeBuffered(t.startPTS,t.endPTS,e);return r&&this.removeFragment(s.body),r}))}))}detectPartialFragments(t){const e=this.timeRanges,{frag:r,part:n}=t;if(!e||"initSegment"===r.sn)return;const i=cn(r),s=this.fragments[i];if(!s||s.buffered&&r.gap)return;const a=!r.relurl;if(Object.keys(e).forEach((t=>{const i=r.elementaryStreams[t];if(!i)return;const o=e[t],l=a||!0===i.partial;s.range[t]=this.getBufferedTimes(r,n,l,o)})),s.loaded=null,Object.keys(s.range).length){s.buffered=!0;(s.body.endList=r.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),ln(s)||this.removeParts(r.sn-1,r.type)}else this.removeFragment(s.body)}removeParts(t,e){const r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter((e=>e.fragment.sn>=t)))}fragBuffered(t,e){const r=cn(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){const i={time:[],partial:r},s=t.start,a=t.end,o=t.minEndPTS||a,l=t.maxStartPTS||s;for(let t=0;t=e&&o<=r){i.time.push({startPTS:Math.max(s,n.start(t)),endPTS:Math.min(a,n.end(t))});break}if(se){const e=Math.max(s,n.start(t)),r=Math.min(a,n.end(t));r>e&&(i.partial=!0,i.time.push({startPTS:e,endPTS:r}))}else if(a<=e)break}return i}getPartialFragment(t){let e,r,n,i=null,s=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach((l=>{const c=o[l];c&&ln(c)&&(r=c.body.start-a,n=c.body.end+a,t>=r&&t<=n&&(e=Math.min(t-r,n-t),s<=e&&(i=c.body,s=e)))})),i}isEndListAppended(t){const e=this.endListFragments[t];return void 0!==e&&(e.buffered||ln(e))}getState(t){const e=cn(t),r=this.fragments[e];return r?r.buffered?ln(r)?sn:an:nn:rn}isTimeBuffered(t,e,r){let n,i;for(let s=0;s=n&&e<=i)return!0;if(e<=n)return!1}return!1}onFragLoaded(t,e){const{frag:r,part:n}=e;if("initSegment"===r.sn||r.bitrateTest)return;const i=n?null:e,s=cn(r);this.fragments[s]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:r,part:n,timeRanges:i}=e;if("initSegment"===r.sn)return;const s=r.type;if(n){let t=this.activePartLists[s];t||(this.activePartLists[s]=t=[]),t.push(n)}this.timeRanges=i,Object.keys(i).forEach((t=>{const e=i[t];this.detectEvictedFragments(t,e,s,n)}))}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=cn(t);return!!this.fragments[e]}hasParts(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)}removeFragmentsInRange(t,e,r,n,i){n&&!this.hasGaps||Object.keys(this.fragments).forEach((s=>{const a=this.fragments[s];if(!a)return;const o=a.body;o.type!==r||n&&!o.gap||o.startt&&(a.buffered||i)&&this.removeFragment(o)}))}removeFragment(t){const e=cn(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const r=this.activePartLists[t.type];if(r){const e=t.sn;this.activePartLists[t.type]=r.filter((t=>t.fragment.sn!==e))}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 ln(t){var e,r,n;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(r=t.range.audio)?void 0:r.partial)||(null==(n=t.range.audiovideo)?void 0:n.partial))}function cn(t){return`${t.type}_${t.level}_${t.sn}`}const un={length:0,start:()=>0,end:()=>0};class hn{static isBuffered(t,e){try{if(t){const r=hn.getBuffered(t);for(let t=0;t=r.start(t)&&e<=r.end(t))return!0}}catch(t){}return!1}static bufferInfo(t,e,r){try{if(t){const n=hn.getBuffered(t),i=[];let s;for(s=0;ss&&(n[i-1].end=t[e].end):n.push(t[e])}else n.push(t[e])}else n=t;let i,s=0,a=e,o=e;for(let t=0;t=l&&er.startCC||t&&t.cc{if(this.loader&&this.loader.destroy(),t.gap){if(t.tagList.some((t=>"GAP"===t[0])))return void o(Tn(t));t.gap=!1}const l=this.loader=t.loader=i?new i(n):new s(n),c=bn(t),u=Cr(n.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:vn};t.stats=l.stats,l.load(c,h,{onSuccess:(e,r,n,i)=>{this.resetLoader(t,l);let s=e.data;n.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),a({frag:t,part:null,payload:s,networkDetails:i})},onError:(e,n,i,s)=>{this.resetLoader(t,l),o(new Sn({type:x.NETWORK_ERROR,details:P.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:_({url:r,data:void 0},e),error:new Error(`HTTP Error ${e.code} ${e.text}`),networkDetails:i,stats:s}))},onAbort:(e,r,n)=>{this.resetLoader(t,l),o(new Sn({type:x.NETWORK_ERROR,details:P.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:n,stats:e}))},onTimeout:(e,r,n)=>{this.resetLoader(t,l),o(new Sn({type:x.NETWORK_ERROR,details:P.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:n,stats:e}))},onProgress:(r,n,i,s)=>{e&&e({frag:t,part:null,payload:i,networkDetails:s})}})}))}loadPart(t,e,r){this.abort();const n=this.config,i=n.fLoader,s=n.loader;return new Promise(((a,o)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap)return void o(Tn(t,e));const l=this.loader=t.loader=i?new i(n):new s(n),c=bn(t,e),u=Cr(n.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:vn};e.stats=l.stats,l.load(c,h,{onSuccess:(n,i,s,o)=>{this.resetLoader(t,l),this.updateStatsFromPart(t,e);const c={frag:t,part:e,payload:n.data,networkDetails:o};r(c),a(c)},onError:(r,n,i,s)=>{this.resetLoader(t,l),o(new Sn({type:x.NETWORK_ERROR,details:P.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:_({url:c.url,data:void 0},r),error:new Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:i,stats:s}))},onAbort:(r,n,i)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,l),o(new Sn({type:x.NETWORK_ERROR,details:P.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:i,stats:r}))},onTimeout:(r,n,i)=>{this.resetLoader(t,l),o(new Sn({type:x.NETWORK_ERROR,details:P.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:i,stats:r}))}})}))}updateStatsFromPart(t,e){const r=t.stats,n=e.stats,i=n.total;if(r.loaded+=n.loaded,i){const n=Math.round(t.duration/e.duration),s=Math.min(Math.round(r.loaded/i),n),a=(n-s)*Math.round(r.loaded/s);r.total=r.loaded+a}else r.total=Math.max(r.loaded,r.total);const s=r.loading,a=n.loading;s.start?s.first+=a.first-a.start:(s.start=a.start,s.first=a.first),s.end=a.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function bn(t,e=null){const r=e||t,n={frag:t,part:e,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},i=r.byteRangeStartOffset,s=r.byteRangeEndOffset;if(R(i)&&R(s)){var a;let e=i,r=s;if("initSegment"===t.sn&&"AES-128"===(null==(a=t.decryptdata)?void 0:a.method)){const t=s-i;t%16&&(r=s+(16-t%16)),0!==i&&(n.resetIV=!0,e=i-16)}n.rangeStart=e,n.rangeEnd=r}return n}function Tn(t,e){const r=new Error(`GAP ${t.gap?"tag":"attribute"} found`),n={type:x.MEDIA_ERROR,details:P.FRAG_GAP,fatal:!1,frag:t,error:r,networkDetails:null};return e&&(n.part=e),(e||t).stats.aborted=!0,new Sn(n)}class Sn extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class An{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class _n{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}class kn{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),r=new Uint32Array(4);for(let t=0;t<4;t++)r[t]=e.getUint32(4*t);return r}initTable(){const t=this.sBox,e=this.invSBox,r=this.subMix,n=r[0],i=r[1],s=r[2],a=r[3],o=this.invSubMix,l=o[0],c=o[1],u=o[2],h=o[3],d=new Uint32Array(256);let f=0,p=0,g=0;for(g=0;g<256;g++)d[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){let r=p^p<<1^p<<2^p<<3^p<<4;r=r>>>8^255&r^99,t[f]=r,e[r]=f;const o=d[f],g=d[o],m=d[g];let y=257*d[r]^16843008*r;n[f]=y<<24|y>>>8,i[f]=y<<16|y>>>16,s[f]=y<<8|y>>>24,a[f]=y,y=16843009*m^65537*g^257*o^16843008*f,l[r]=y<<24|y>>>8,c[r]=y<<16|y>>>16,u[r]=y<<8|y>>>24,h[r]=y,f?(f=o^d[d[d[m^o]]],p^=d[d[p]]):f=p=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let r=!0,n=0;for(;n{if(!this.subtle)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new An(this.subtle,new Uint8Array(r)).decrypt(t.buffer,e)})).catch((n=>(N.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(t,e,r))))}onWebCryptoError(t,e,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,r);const n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const r=t.length-t.length%16;return r!==t.length&&(e=yt(t,0,r),this.remainderData=yt(t,r)),e}logOnce(t){this.logEnabled&&(N.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const wn=function(t){let e="";const r=t.length;for(let n=0;na.end){const t=s>i;(s{if(this.fragContextChanged(t))return this.warn(`Fragment ${t.sn}${e.part?" p: "+e.part.index:""} of level ${t.level} was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)})).then((e=>{if(!e)return;const r=this.state;this.fragContextChanged(t)?(r===In||!this.fragCurrent&&r===On)&&(this.fragmentTracker.removeFragment(t),this.state=Cn):("payload"in e&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(I.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))})).catch((e=>{this.state!==Rn&&this.state!==Bn&&(this.warn(`Frag error: ${(null==e?void 0:e.message)||e}`),this.resetFragmentLoading(t))}))}clearTrackerIfNeeded(t){var e;const{fragmentTracker:r}=this;if(r.getState(t)===nn){const e=t.type,n=this.getFwdBufferInfo(this.mediaBuffer,e),i=Math.max(t.duration,n?n.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?t.sn-s.sn:0)||this.reduceMaxBufferLength(i,t.duration))&&r.removeFragment(t)}else 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)===sn&&r.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const 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){if(!(t-e))return;const n={startOffset:t,endOffset:e,type:r};this.hls.trigger(I.BUFFER_FLUSHING,n)}_loadInitSegment(t,e){this._doFragLoad(t,e).then((e=>{if(!e||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e})).then((e=>{const{hls:r}=this,{payload:n}=e,i=t.decryptdata;if(n&&n.byteLength>0&&null!=i&&i.key&&i.iv&&"AES-128"===i.method){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),i.key.buffer,i.iv.buffer).catch((e=>{throw r.trigger(I.ERROR,{type:x.MEDIA_ERROR,details:P.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((n=>{const i=self.performance.now();return r.trigger(I.FRAG_DECRYPTED,{frag:t,payload:n,stats:{tstart:s,tdecrypt:i}}),e.payload=n,this.completeInitSegmentLoad(e)}))}return this.completeInitSegmentLoad(e)})).catch((e=>{this.state!==Rn&&this.state!==Bn&&(this.warn(e),this.resetFragmentLoading(t))}))}completeInitSegmentLoad(t){const{levels:e}=this;if(!e)throw new Error("init load aborted, missing levels");const r=t.frag.stats;this.state=Cn,t.frag.data=new Uint8Array(t.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.sn!==e.sn||t.level!==e.level}fragBufferedComplete(t,e){var r,n,i,s;const a=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===Ke?"level":"track"} ${t.level} (frag:[${(null!=(r=t.startPTS)?r:NaN).toFixed(3)}-${(null!=(n=t.endPTS)?n:NaN).toFixed(3)}] > buffer:${a?wn(hn.getBuffered(a)):"(detached)"})`),"initSegment"!==t.sn){var o;if(t.type!==Ve){const e=t.elementaryStreams;if(!Object.keys(e).some((t=>!!e[t])))return void(this.state=Cn)}const e=null==(o=this.levels)?void 0:o[t.level];null!=e&&e.fragmentError&&(this.log(`Resetting level fragment error count of ${e.fragmentError} on frag buffered`),e.fragmentError=0)}this.state=Cn,a&&(!this.loadedmetadata&&t.type==Ke&&a.buffered.length&&(null==(i=this.fragCurrent)?void 0:i.sn)===(null==(s=this.fragPrevious)?void 0:s.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:r,part:n,partsLoaded:i}=t,s=!i||0===i.length||i.some((t=>!t)),a=new dn(r.level,r.sn,r.stats.chunkCount+1,0,n?n.index:-1,!s);e.flush(a)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,r=null,n){var i;const s=null==e?void 0:e.details;if(!this.levels||!s)throw new Error(`frag load aborted, missing level${s?"":" detail"}s`);let a=null;if(!t.encrypted||null!=(i=t.decryptdata)&&i.key?!t.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(t,s.encryptedFragments):(this.log(`Loading key for ${t.sn} of [${s.startSN}-${s.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} ${t.level}`),this.state=Dn,this.fragCurrent=t,a=this.keyLoader.load(t).then((t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger(I.KEY_LOADED,t),this.state===Dn&&(this.state=Cn),t})),this.hls.trigger(I.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(a=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(t.start,r||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){const i=s.partList;if(i&&n){r>t.end&&s.fragmentHint&&(t=s.fragmentHint);const o=this.getNextPart(i,t,r);if(o>-1){const l=i[o];let c;return this.log(`Loading part sn: ${t.sn} p: ${l.index} cc: ${t.cc} of playlist [${s.startSN}-${s.endSN}] parts [0-${o}-${i.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=In,c=a?a.then((r=>!r||this.fragContextChanged(r.frag)?null:this.doFragPartsLoad(t,l,e,n))).catch((t=>this.handleFragLoadError(t))):this.doFragPartsLoad(t,l,e,n).catch((t=>this.handleFragLoadError(t))),this.hls.trigger(I.FRAG_LOADING,{frag:t,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!t.url||this.loadedEndOfParts(i,r))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${s?"of ["+s.startSN+"-"+s.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: ${parseFloat(r.toFixed(3))}`),R(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=In;const o=this.config.progressive;let l;return l=o&&a?a.then((e=>!e||this.fragContextChanged(null==e?void 0:e.frag)?null:this.fragmentLoader.load(t,n))).catch((t=>this.handleFragLoadError(t))):Promise.all([this.fragmentLoader.load(t,o?n:void 0),a]).then((([t])=>(!o&&t&&n&&n(t),t))).catch((t=>this.handleFragLoadError(t))),this.hls.trigger(I.FRAG_LOADING,{frag:t,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):l}doFragPartsLoad(t,e,r,n){return new Promise(((i,s)=>{var a;const o=[],l=null==(a=r.details)?void 0:a.partList,c=e=>{this.fragmentLoader.loadPart(t,e,n).then((n=>{o[e.index]=n;const s=n.part;this.hls.trigger(I.FRAG_LOADED,n);const a=Ar(r,t.sn,e.index+1)||_r(l,t.sn,e.index+1);if(!a)return i({frag:t,part:s,partsLoaded:o});c(a)})).catch(s)};c(e)}))}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===P.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(I.ERROR,e)}else this.hls.trigger(I.ERROR,{type:x.OTHER_ERROR,details:P.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==On)return void(this.fragCurrent||this.state===Rn||this.state===Bn||(this.state=Cn));const{frag:r,part:n,level:i}=e,s=self.performance.now();r.stats.parsing.end=s,n&&(n.stats.parsing.end=s),this.updateLevelTiming(r,n,i,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:r}=this,{level:n,sn:i,part:s}=t;if(null==e||!e[n])return this.warn(`Levels object was unset while buffering fragment ${i} of level ${n}. The current chunk will not be buffered.`),null;const a=e[n],o=s>-1?Ar(a,i,s):null,l=o?o.fragment:function(t,e,r){if(null==t||!t.details)return null;const n=t.details;let i=n.fragments[e-n.startSN];return i||(i=n.fragmentHint,i&&i.sn===e?i:es&&this.flushMainBuffer(a,t.start)}getFwdBufferInfo(t,e){const r=this.getLoadPosition();return R(r)?this.getFwdBufferInfoAtPos(t,r,e):null}getFwdBufferInfoAtPos(t,e,r){const{config:{maxBufferHole:n}}=this,i=hn.bufferInfo(t,e,n);if(0===i.len&&void 0!==i.nextStart){const s=this.fragmentTracker.getBufferedFrag(e,r);if(s&&i.nextStart=n&&(r.maxMaxBufferLength=i,this.warn(`Reduce max buffer length to ${i}s`),!0)}getAppendedFrag(t,e=Ke){const r=this.fragmentTracker.getAppendedFrag(t,Ke);return r&&"fragment"in r?r.fragment:r}getNextFragment(t,e){const r=e.fragments,n=r.length;if(!n)return null;const{config:i}=this,s=r[0].start;let a;if(e.live){const o=i.initialLiveManifestSize;if(ne}getNextFragmentLoopLoading(t,e,r,n,i){const s=t.gap,a=this.getNextFragment(this.nextLoadPosition,e);if(null===a)return a;if(t=a,s&&t&&!t.gap&&r.nextStart){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?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(t,e,r){let n=-1,i=!1,s=!0;for(let a=0,o=t.length;a-1&&rr.start&&r.loaded}getInitialLiveFragment(t,e){const r=this.fragPrevious;let n=null;if(r){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),n=function(t,e,r){if(null===e||!Array.isArray(t)||!t.length||!R(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;r=r||0;for(let n=0;n=t.startSN&&i<=t.endSN){const s=e[i-t.startSN];r.cc===s.cc&&(n=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=function(t,e){return Ir(t,(t=>t.cce?-1:0))}(e,r.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const e=this.hls.liveSyncPosition;null!==e&&(n=this.getFragmentAtPosition(e,this.bitrateTest?t.fragmentEnd:t.edge,t))}return n}getFragmentAtPosition(t,e,r){const{config:n}=this;let{fragPrevious:i}=this,{fragments:s,endSN:a}=r;const{fragmentHint:o}=r,{maxFragLookUpTolerance:l}=n,c=r.partList,u=!!(n.lowLatencyMode&&null!=c&&c.length&&o);let h;if(u&&o&&!this.bitrateTest&&(s=s.concat(o),a=o.sn),te-l?0:l)}else h=s[s.length-1];if(h){const t=h.sn-r.startSN,e=this.fragmentTracker.getState(h);if((e===an||e===sn&&h.gap)&&(i=h),i&&h.sn===i.sn&&(!u||c[0].fragment.sn>h.sn)){if(i&&h.level===i.level){const e=s[t+1];h=h.sn=s-e.maxFragLookUpTolerance&&i<=a;if(null!==n&&r.duration>n&&(i${t.startSN} prev-sn: ${i?i.sn:"na"} fragments: ${n}`),s}return i}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;if(r ${null==(n=this.fragCurrent)?void 0:n.url}`);const i=e.details===P.FRAG_GAP;i&&this.fragmentTracker.fragBuffered(r,!0);const s=e.errorAction,{action:a,retryCount:o=0,retryConfig:l}=s||{};if(s&&a===Nr&&l){this.resetStartWhenNotLoaded(this.levelLastLoaded);const n=Rr(l,o);this.warn(`Fragment ${r.sn} of ${t} ${r.level} errored with ${e.details}, retrying loading ${o+1}/${l.maxNumRetry} in ${n}ms`),s.resolved=!0,this.retryDate=self.performance.now()+n,this.state=xn}else if(l&&s){if(this.resetFragmentErrors(t),!(o.5;i&&this.reduceMaxBufferLength(n.len,(null==e?void 0:e.duration)||10);const s=!i;return s&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${r} buffer`),e&&(this.fragmentTracker.removeFragment(e),this.nextLoadPosition=e.start),this.resetLoadingState(),s}return!1}resetFragmentErrors(t){t===He&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Rn&&(this.state=Cn)}afterBufferFlushed(t,e,r){if(!t)return;const n=hn.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,n,r),this.state===Fn&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Cn}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=t?t.details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,r,n){var i;const s=r.details;if(!s)return void this.warn("level.details undefined");if(!Object.keys(t.elementaryStreams).reduce(((e,i)=>{const a=t.elementaryStreams[i];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${t.sn} ${i} duration reliably (${o})`),e||!1;const l=n?0:Er(s,t,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return this.hls.trigger(I.LEVEL_PTS_UPDATED,{details:s,level:r,drift:l,type:i,frag:t,start:a.startPTS,end:a.endPTS}),!0}return e}),!1)&&null===(null==(i=this.transmuxer)?void 0:i.error)){const e=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(0===r.fragmentError&&(r.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(e.message),this.hls.trigger(I.ERROR,{type:x.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:t,reason:`Found no media in msn ${t.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Mn,this.hls.trigger(I.FRAG_PARSED,{frag:t,part:e})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}class jn{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let r;return t.length?(r=1===t.length?t[0]:function(t,e){const r=new Uint8Array(e);let n=0;for(let e=0;e0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:tr,duration:Number.POSITIVE_INFINITY});i{if(R(t))return 90*t;return 9e4*e+(r?9e4*r.baseTime/r.timescale:0)};function Vn(t,e){return 255===t[e]&&240==(246&t[e+1])}function Wn(t,e){return 1&t[e+1]?7:9}function Yn(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function qn(t,e){return e+1=t.length)return!1;const n=Yn(t,e);if(n<=r)return!1;const i=e+n;return i===t.length||qn(t,i)}return!1}function Xn(t,e,r,n,i){if(!t.samplerate){const s=function(t,e,r,n){let i,s,a,o;const l=navigator.userAgent.toLowerCase(),c=n,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];i=1+((192&e[r+2])>>>6);const h=(60&e[r+2])>>>2;if(!(h>u.length-1))return a=(1&e[r+2])<<2,a|=(192&e[r+3])>>>6,N.log(`manifest codec:${n}, ADTS type:${i}, samplingIndex:${h}`),/firefox/i.test(l)?h>=6?(i=5,o=new Array(4),s=h-3):(i=2,o=new Array(2),s=h):-1!==l.indexOf("android")?(i=2,o=new Array(2),s=h):(i=5,o=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&h>=6?s=h-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(h>=6&&1===a||/vivaldi/i.test(l))||!n&&1===a)&&(i=2,o=new Array(2)),s=h)),o[0]=i<<3,o[0]|=(14&h)>>1,o[1]|=(1&h)<<7,o[1]|=a<<3,5===i&&(o[1]|=(14&s)>>1,o[2]=(1&s)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[h],channelCount:a,codec:"mp4a.40."+i,manifestCodec:c};{const e=new Error(`invalid ADTS sampling index:${h}`);t.emit(I.ERROR,I.ERROR,{type:x.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!0,error:e,reason:e.message})}}(e,r,n,i);if(!s)return;t.config=s.config,t.samplerate=s.samplerate,t.channelCount=s.channelCount,t.codec=s.codec,t.manifestCodec=s.manifestCodec,N.log(`parsed codec:${t.codec}, rate:${s.samplerate}, channels:${s.channelCount}`)}}function Qn(t){return 9216e4/t}function Jn(t,e,r,n,i){const s=n+i*Qn(t.samplerate),a=function(t,e){const r=Wn(t,e);if(e+r<=t.length){const n=Yn(t,e)-r;if(n>0)return{headerLength:r,frameLength:n}}}(e,r);let o;if(a){const{frameLength:n,headerLength:i}=a,l=i+n,c=Math.max(0,r+l-e.length);c?(o=new Uint8Array(l-i),o.set(e.subarray(r+i,e.length),0)):o=e.subarray(r+i,r+l);const u={unit:o,pts:s};return c||t.samples.push(u),{sample:u,length:l,missing:c}}const l=e.length-r;o=new Uint8Array(l),o.set(e.subarray(r,e.length),0);return{sample:{unit:o,pts:s},length:l,missing:-1}}let Zn=null;const ti=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],ei=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ri=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ni=[0,1,1,4];function ii(t,e,r,n,i){if(r+24>e.length)return;const s=si(e,r);if(s&&r+s.frameLength<=e.length){const a=n+i*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:e.subarray(r,r+s.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=s.channelCount,t.samplerate=s.sampleRate,t.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}function si(t,e){const r=t[e+1]>>3&3,n=t[e+1]>>1&3,i=t[e+2]>>4&15,s=t[e+2]>>2&3;if(1!==r&&0!==i&&15!==i&&3!==s){const a=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*ti[14*(3===r?3-n:3===n?3:4)+i-1],c=ei[3*(3===r?0:2===r?1:2)+s],u=3===o?1:2,h=ri[r][n],d=ni[n],f=8*h*d,p=Math.floor(h*l/c+a)*d;if(null===Zn){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Zn=t?parseInt(t[1]):0}return!!Zn&&Zn<=87&&2===n&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:c,channelCount:u,frameLength:p,samplesPerFrame:f}}}function ai(t,e){return!(255!==t[e]||224&~t[e+1]||!(6&t[e+1]))}function oi(t,e){return e+1{let r=0,n=5;e+=n;const i=new Uint32Array(1),s=new Uint32Array(1),a=new Uint8Array(1);for(;n>0;){a[0]=t[e];const o=Math.min(n,8),l=8-o;s[0]=4278190080>>>24+l<>l,r=r?r<e.length)return-1;if(11!==e[r]||119!==e[r+1])return-1;const s=e[r+4]>>6;if(s>=3)return-1;const a=[48e3,44100,32e3][s],o=63&e[r+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+s];if(r+l>e.length)return-1;const c=e[r+6]>>5;let u=0;2===c?u+=2:(1&c&&1!==c&&(u+=2),4&c&&(u+=2));const h=(e[r+6]<<8|e[r+7])>>12-u&1,d=[2,1,2,3,3,4,4,5][c]+h,f=e[r+5]>>3,p=7&e[r+5],g=new Uint8Array([s<<6|f<<1|p>>2,(3&p)<<6|c<<3|h<<2|o>>4,o<<4&224]),m=n+i*(1536/a*9e4),y=e.subarray(r,r+l);return t.config=g,t.channelCount=d,t.samplerate=a,t.samples.push({unit:y,pts:m}),l}class fi{constructor(){this.VideoSample=null}createVideoSample(t,e,r,n){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:n,length:0}}getLastNalUnit(t){var e;let r,n=this.VideoSample;if(n&&0!==n.units.length||(n=t[t.length-1]),null!=(e=n)&&e.units){const t=n.units;r=t[t.length-1]}return r}pushAccessUnit(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){const r=e.samples,n=r.length;if(!n)return void e.dropped++;{const e=r[n-1];t.pts=e.pts,t.dts=e.dts}}e.samples.push(t)}t.debug.length&&N.log(t.pts+"/"+t.dts+":"+t.debug)}}class pi{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,r=t.byteLength-e,n=new Uint8Array(4),i=Math.min(4,e);if(0===i)throw new Error("no bytes available");n.set(t.subarray(r,r+i)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*i,this.bytesAvailable-=i}skipBits(t){let e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(e=(t-=this.bitsAvailable)>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const r=this.word>>>32-e;if(t>32&&N.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return e=t-e,e>0&&this.bitsAvailable?r<>>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(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const 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(t){let e,r=8,n=8;for(let i=0;i{var s;switch(n.type){case 1:{let e=!1;a=!0;const i=n.data;if(l&&i.length>4){const t=new pi(i).readSliceType();2!==t&&4!==t&&7!==t&&9!==t||(e=!0)}var c;if(e)null!=(c=o)&&c.frame&&!o.key&&(this.pushAccessUnit(o,t),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=e;break}case 5:a=!0,null!=(s=o)&&s.frame&&!o.key&&(this.pushAccessUnit(o,t),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:a=!0,ne(n.data,1,r.pts,e.samples);break;case 7:{var u,h;a=!0,l=!0;const e=n.data,r=new pi(e).readSPS();if(!t.sps||t.width!==r.width||t.height!==r.height||(null==(u=t.pixelRatio)?void 0:u[0])!==r.pixelRatio[0]||(null==(h=t.pixelRatio)?void 0:h[1])!==r.pixelRatio[1]){t.width=r.width,t.height=r.height,t.pixelRatio=r.pixelRatio,t.sps=[e],t.duration=i;const n=e.subarray(1,4);let s="avc1.";for(let t=0;t<3;t++){let e=n[t].toString(16);e.length<2&&(e="0"+e),s+=e}t.codec=s}break}case 8:a=!0,t.pps=[n.data];break;case 9:a=!0,t.audFound=!0,o&&this.pushAccessUnit(o,t),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,o&&(o.debug+="unknown NAL "+n.type+" ")}if(o&&a){o.units.push(n)}})),n&&o&&(this.pushAccessUnit(o,t),this.VideoSample=null)}parseAVCNALu(t,e){const r=e.byteLength;let n=t.naluState||0;const i=n,s=[];let a,o,l,c=0,u=-1,h=0;for(-1===n&&(u=0,h=31&e[0],n=0,c=1);c=0){const t={data:e.subarray(u,o),type:h};s.push(t)}else{const r=this.getLastNalUnit(t.samples);r&&(i&&c<=4-i&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-i)),o>0&&(r.data=te(r.data,e.subarray(0,o)),r.state=0))}c=0&&n>=0){const t={data:e.subarray(u,r),type:h,state:n};s.push(t)}if(0===s.length){const r=this.getLastNalUnit(t.samples);r&&(r.data=te(r.data,e))}return t.naluState=n,s}}class mi{constructor(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Ln(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,r){const n=t[e].unit;if(n.length<=16)return;const i=n.subarray(16,n.length-n.length%16),s=i.buffer.slice(i.byteOffset,i.byteOffset+i.length);this.decryptBuffer(s).then((i=>{const s=new Uint8Array(i);n.set(s,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,r)}))}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(t){const e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e);let n=0;for(let e=32;e{i.data=this.getAvcDecryptedUnit(s,a),this.decrypter.isSync()||this.decryptAvcSamples(t,e,r+1,n)}))}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();const i=t[e].units;for(;!(r>=i.length);r++){const s=i[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(t,e,r,n,s),this.decrypter.isSync())))return}}}}const yi=188;class vi{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._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=e,this.typeSupported=r,this.videoParser=new gi}static probe(t){const e=vi.syncOffset(t);return e>0&&N.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),-1!==e}static syncOffset(t){const e=t.length;let r=Math.min(940,e-yi)+1,n=0;for(;n1&&(0===s&&a>2||o+yi>r))return s}n++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:Nt[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._videoTrack=vi.createTrack("video"),this._audioTrack=vi.createTrack("audio",n),this._id3Track=vi.createTrack("id3"),this._txtTrack=vi.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=r,this._duration=n}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_videoTrack:e,_id3Track:r}=this;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(t,e,r=!1,n=!1){let i;r||(this.sampleAes=null);const s=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let c=s.pid,u=s.pesData,h=a.pid,d=o.pid,f=a.pesData,p=o.pesData,g=null,m=this.pmtParsed,y=this._pmtId,v=t.length;if(this.remainderData&&(v=(t=te(this.remainderData,t)).length,this.remainderData=null),v>4>1){if(b=e+5+t[e+4],b===e+yi)continue}else b=e+4;switch(v){case c:n&&(u&&(i=_i(u))&&this.videoParser.parseAVCPES(s,l,i,!1,this._duration),u={data:[],size:0}),u&&(u.data.push(t.subarray(b,e+yi)),u.size+=e+yi-b);break;case h:if(n){if(f&&(i=_i(f)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,i);break;case"mp3":this.parseMPEGPES(a,i);break;case"ac3":this.parseAC3PES(a,i)}f={data:[],size:0}}f&&(f.data.push(t.subarray(b,e+yi)),f.size+=e+yi-b);break;case d:n&&(p&&(i=_i(p))&&this.parseID3PES(o,i),p={data:[],size:0}),p&&(p.data.push(t.subarray(b,e+yi)),p.size+=e+yi-b);break;case 0:n&&(b+=t[b]+1),y=this._pmtId=bi(t,b);break;case y:{n&&(b+=t[b]+1);const i=Ti(t,b,this.typeSupported,r,this.observer);c=i.videoPid,c>0&&(s.pid=c,s.segmentCodec=i.segmentVideoCodec),h=i.audioPid,h>0&&(a.pid=h,a.segmentCodec=i.segmentAudioCodec),d=i.id3Pid,d>0&&(o.pid=d),null===g||m||(N.warn(`MPEG-TS PMT found at ${e} after unknown PID '${g}'. Backtracking to sync byte @${E} to parse all TS packets.`),g=null,e=E-188),m=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=v}}else b++;b>0&&Si(this.observer,new Error(`Found ${b} TS packet/s that do not start with 0x47`)),s.pesData=u,a.pesData=f,o.pesData=p;const T={audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};return n&&this.extractRemainingSamples(T),T}flush(){const{remainderData:t}=this;let e;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:r,id3Track:n,textTrack:i}=t,s=r.pesData,a=e.pesData,o=n.pesData;let l;if(s&&(l=_i(s))?(this.videoParser.parseAVCPES(r,i,l,!0,this._duration),r.pesData=null):r.pesData=s,a&&(l=_i(a))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,l);break;case"mp3":this.parseMPEGPES(e,l);break;case"ac3":this.parseAC3PES(e,l)}e.pesData=null}else null!=a&&a.size&&N.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=a;o&&(l=_i(o))?(this.parseID3PES(n,l),n.pesData=null):n.pesData=o}demuxSampleAes(t,e,r){const n=this.demux(t,r,!0,!this.config.progressive),i=this.sampleAes=new mi(this.observer,this.config,e);return this.decrypt(n,i)}decrypt(t,e){return new Promise((r=>{const{audioTrack:n,videoTrack:i}=t;n.samples&&"aac"===n.segmentCodec?e.decryptAacSamples(n.samples,0,(()=>{i.samples?e.decryptAvcSamples(i.samples,0,0,(()=>{r(t)})):r(t)})):i.samples&&e.decryptAvcSamples(i.samples,0,0,(()=>{r(t)}))}))}destroy(){this._duration=0}parseAACPES(t,e){let r=0;const n=this.aacOverFlow;let i,s,a,o=e.data;if(n){this.aacOverFlow=null;const e=n.missing,i=n.sample.unit.byteLength;if(-1===e)o=te(n.sample.unit,o);else{const s=i-e;n.sample.unit.set(o.subarray(0,e),s),t.samples.push(n.sample),r=n.missing}}for(i=r,s=o.length;i0;)o+=s}}parseID3PES(t,e){if(void 0===e.pts)return void N.warn("[tsdemuxer]: ID3 PES unknown PTS");const r=w({},e,{type:this._videoTrack?rr:tr,duration:Number.POSITIVE_INFINITY});t.samples.push(r)}}function Ei(t,e){return((31&t[e+1])<<8)+t[e+2]}function bi(t,e){return(31&t[e+10])<<8|t[e+11]}function Ti(t,e,r,n,i){const s={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e0){let n=e+5,i=o;for(;i>2;){if(106===t[n])!0!==r.ac3?N.log("AC-3 audio found, not supported in this browser for now"):(s.audioPid=a,s.segmentAudioCodec="ac3");const e=t[n+1]+2;n+=e,i-=e}}break;case 194:case 135:return Si(i,new Error("Unsupported EC-3 in M2TS found")),s;case 36:return Si(i,new Error("Unsupported HEVC in M2TS found")),s}e+=o+5}return s}function Si(t,e,r){N.warn(`parsing error: ${e.message}`),t.emit(I.ERROR,I.ERROR,{type:x.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,levelRetry:r,error:e,reason:e.message})}function Ai(t){N.log(`${t} with AES-128-CBC encryption found in unencrypted stream`)}function _i(t){let e,r,n,i,s,a=0;const o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=te(o[0],o[1]),o.splice(1,1);e=o[0];if(1===(e[0]<<16)+(e[1]<<8)+e[2]){if(r=(e[4]<<8)+e[5],r&&r>t.size-6)return null;const l=e[7];192&l&&(i=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&l?(s=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2,i-s>54e5&&(N.warn(`${Math.round((i-s)/9e4)}s delta between PTS and DTS, align them`),i=s)):s=i),n=e[8];let c=n+9;if(t.size<=c)return null;t.size-=c;const u=new Uint8Array(t.size);for(let t=0,r=o.length;tr){c-=r;continue}e=e.subarray(c),r-=c,c=0}u.set(e,a),a+=r}return r&&(r-=n+3),{data:u,pts:i,dts:s,len:r}}return null}class ki{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 Li=Math.pow(2,32)-1;class wi{static init(){let t;for(t in wi.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},wi.types)wi.types.hasOwnProperty(t)&&(wi.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const 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]);wi.HDLR_TYPES={video:e,audio:r};const n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),i=new Uint8Array([0,0,0,0,0,0,0,0]);wi.STTS=wi.STSC=wi.STCO=i,wi.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),wi.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),wi.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),wi.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const s=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);wi.FTYP=wi.box(wi.types.ftyp,s,o,s,a),wi.DINF=wi.box(wi.types.dinf,wi.box(wi.types.dref,n))}static box(t,...e){let r=8,n=e.length;const i=n;for(;n--;)r+=e[n].byteLength;const s=new Uint8Array(r);for(s[0]=r>>24&255,s[1]=r>>16&255,s[2]=r>>8&255,s[3]=255&r,s.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,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))}static mdia(t){return wi.box(wi.types.mdia,wi.mdhd(t.timescale,t.duration),wi.hdlr(t.type),wi.minf(t))}static mfhd(t){return wi.box(wi.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?wi.box(wi.types.minf,wi.box(wi.types.smhd,wi.SMHD),wi.DINF,wi.stbl(t)):wi.box(wi.types.minf,wi.box(wi.types.vmhd,wi.VMHD),wi.DINF,wi.stbl(t))}static moof(t,e,r){return wi.box(wi.types.moof,wi.mfhd(t),wi.traf(r,e))}static moov(t){let e=t.length;const r=[];for(;e--;)r[e]=wi.trak(t[e]);return wi.box.apply(null,[wi.types.moov,wi.mvhd(t[0].timescale,t[0].duration)].concat(r).concat(wi.mvex(t)))}static mvex(t){let e=t.length;const r=[];for(;e--;)r[e]=wi.trex(t[e]);return wi.box.apply(null,[wi.types.mvex,...r])}static mvhd(t,e){e*=t;const r=Math.floor(e/(Li+1)),n=Math.floor(e%(Li+1)),i=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return wi.box(wi.types.mvhd,i)}static sdtp(t){const e=t.samples||[],r=new Uint8Array(4+e.length);let n,i;for(n=0;n>>8&255),i.push(255&n),i=i.concat(Array.prototype.slice.call(r));for(e=0;e>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(r));const a=wi.box(wi.types.avcC,new Uint8Array([1,i[3],i[4],i[5],255,224|t.sps.length].concat(i).concat([t.pps.length]).concat(s))),o=t.width,l=t.height,c=t.pixelRatio[0],u=t.pixelRatio[1];return wi.box(wi.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]),a,wi.box(wi.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),wi.box(wi.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))}static esds(t){const 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 audioStsd(t){const e=t.samplerate;return 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 mp4a(t){return wi.box(wi.types.mp4a,wi.audioStsd(t),wi.box(wi.types.esds,wi.esds(t)))}static mp3(t){return wi.box(wi.types[".mp3"],wi.audioStsd(t))}static ac3(t){return wi.box(wi.types["ac-3"],wi.audioStsd(t),wi.box(wi.types.dac3,t.config))}static stsd(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?wi.box(wi.types.stsd,wi.STSD,wi.mp3(t)):"ac3"===t.segmentCodec?wi.box(wi.types.stsd,wi.STSD,wi.ac3(t)):wi.box(wi.types.stsd,wi.STSD,wi.mp4a(t)):wi.box(wi.types.stsd,wi.STSD,wi.avc1(t))}static tkhd(t){const e=t.id,r=t.duration*t.timescale,n=t.width,i=t.height,s=Math.floor(r/(Li+1)),a=Math.floor(r%(Li+1));return wi.box(wi.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,s>>24,s>>16&255,s>>8&255,255&s,a>>24,a>>16&255,a>>8&255,255&a,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,i>>8&255,255&i,0,0]))}static traf(t,e){const r=wi.sdtp(t),n=t.id,i=Math.floor(e/(Li+1)),s=Math.floor(e%(Li+1));return wi.box(wi.types.traf,wi.box(wi.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),wi.box(wi.types.tfdt,new Uint8Array([1,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,s>>24,s>>16&255,s>>8&255,255&s])),wi.trun(t,r.length+16+20+8+16+8+8),r)}static trak(t){return t.duration=t.duration||4294967295,wi.box(wi.types.trak,wi.tkhd(t),wi.mdia(t))}static trex(t){const e=t.id;return wi.box(wi.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const r=t.samples||[],n=r.length,i=12+16*n,s=new Uint8Array(i);let a,o,l,c,u,h;for(e+=8+i,s.set(["video"===t.type?1:0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,255&n,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),a=0;a>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,61440&u.degradPrio,15&u.degradPrio,h>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*a);return wi.box(wi.types.trun,s)}static initSegment(t){wi.types||wi.init();const e=wi.moov(t);return te(wi.FTYP,e)}}wi.types=void 0,wi.HDLR_TYPES=void 0,wi.STTS=void 0,wi.STSC=void 0,wi.STCO=void 0,wi.STSZ=void 0,wi.VMHD=void 0,wi.SMHD=void 0,wi.STSD=void 0,wi.FTYP=void 0,wi.DINF=void 0;function Ri(t,e,r=1,n=!1){const i=t*e*r;return n?Math.round(i):i}function Ci(t,e=!1){return Ri(t,1e3,1/9e4,e)}let Di,Ii=null,xi=null;class Pi{constructor(t,e,r,n=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===Ii){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ii=t?parseInt(t[1]):0}if(null===xi){const t=navigator.userAgent.match(/Safari\/(\d+)/i);xi=t?parseInt(t[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(t){N.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){N.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){N.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(t){let e=!1;const r=t.reduce(((t,r)=>{const n=r.pts-t;return n<-4294967296?(e=!0,Oi(t,r.pts)):n>0?t:r.pts}),t[0].pts);return e&&N.debug("PTS rollover detected"),r}remux(t,e,r,n,i,s,a,o){let l,c,u,h,d,f,p=i,g=i;const m=t.pid>-1,y=e.pid>-1,v=e.samples.length,E=t.samples.length>0,b=a&&v>0||v>1;if((!m||E)&&(!y||b)||this.ISGenerated||a){if(this.ISGenerated){var T,S,A,_;const t=this.videoTrackConfig;!t||e.width===t.width&&e.height===t.height&&(null==(T=e.pixelRatio)?void 0:T[0])===(null==(S=t.pixelRatio)?void 0:S[0])&&(null==(A=e.pixelRatio)?void 0:A[1])===(null==(_=t.pixelRatio)?void 0:_[1])||this.resetInitSegment()}else u=this.generateIS(t,e,i,s);const r=this.isVideoContiguous;let n,a=-1;if(b&&(a=function(t){for(let e=0;e0){N.warn(`[mp4-remuxer]: Dropped ${a} out of ${v} video samples due to a missing keyframe`);const t=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(a),e.dropped+=a,g+=(e.samples[0].pts-t)/e.inputTimeScale,n=g}else-1===a&&(N.warn(`[mp4-remuxer]: No keyframe found out of ${v} video samples`),f=!1);if(this.ISGenerated){if(E&&b){const r=this.getVideoStartPts(e.samples),n=(Oi(t.samples[0].pts,r)-r)/e.inputTimeScale;p+=Math.max(0,n),g+=Math.max(0,-n)}if(E){if(t.samplerate||(N.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(t,e,i,s)),c=this.remuxAudio(t,p,this.isAudioContiguous,s,y||b||o===He?g:void 0),b){const n=c?c.endPTS-c.startPTS:0;e.inputTimeScale||(N.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(t,e,i,s)),l=this.remuxVideo(e,g,r,n)}}else b&&(l=this.remuxVideo(e,g,r,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=n)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(d=Mi(r,i,this._initPTS,this._initDTS)),n.samples.length&&(h=Fi(n,i,this._initPTS))),{audio:c,video:l,initSegment:u,independent:f,text:h,id3:d}}generateIS(t,e,r,n){const i=t.samples,s=e.samples,a=this.typeSupported,o={},l=this._initPTS;let c,u,h,d=!l||n,f="audio/mp4";if(d&&(c=u=1/0),t.config&&i.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":a.mpeg?(f="audio/mpeg",t.codec=""):a.mp3&&(t.codec="mp3");break;case"ac3":t.codec="ac-3"}o.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&a.mpeg?new Uint8Array(0):wi.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(h=t.inputTimeScale,l&&h===l.timescale?d=!1:c=u=i[0].pts-Math.round(h*r))}if(e.sps&&e.pps&&s.length){if(e.timescale=e.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:wi.initSegment([e]),metadata:{width:e.width,height:e.height}},d)if(h=e.inputTimeScale,l&&h===l.timescale)d=!1;else{const t=this.getVideoStartPts(s),e=Math.round(h*r);u=Math.min(u,Oi(s[0].dts,t)-e),c=Math.min(c,t-e)}this.videoTrackConfig={width:e.width,height:e.height,pixelRatio:e.pixelRatio}}if(Object.keys(o).length)return this.ISGenerated=!0,d?(this._initPTS={baseTime:c,timescale:h},this._initDTS={baseTime:u,timescale:h}):c=h=void 0,{tracks:o,initPTS:c,timescale:h}}remuxVideo(t,e,r,n){const i=t.inputTimeScale,s=t.samples,a=[],o=s.length,l=this._initPTS;let c,u,h=this.nextAvcDts,d=8,f=this.videoSampleDuration,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,m=!1;if(!r||null===h){const t=e*i,n=s[0].pts-Oi(s[0].dts,s[0].pts);Ii&&null!==h&&Math.abs(t-n-h)<15e3?r=!0:h=t-n}const y=l.baseTime*i/l.timescale;for(let t=0;t0?t-1:t].dts&&(m=!0)}m&&s.sort((function(t,e){const r=t.dts-e.dts,n=t.pts-e.pts;return r||n})),c=s[0].dts,u=s[s.length-1].dts;const v=u-c,E=v?Math.round(v/(o-1)):f||t.inputTimeScale/30;if(r){const t=c-h,r=t>E,n=t<-1;if((r||n)&&(r?N.warn(`AVC: ${Ci(t,!0)} ms (${t}dts) hole between fragments detected at ${e.toFixed(3)}`):N.warn(`AVC: ${Ci(-t,!0)} ms (${t}dts) overlapping between fragments detected at ${e.toFixed(3)}`),!n||h>=s[0].pts||Ii)){c=h;const e=s[0].pts-t;if(r)s[0].dts=c,s[0].pts=e;else for(let r=0;re);r++)s[r].dts-=t,s[r].pts-=t;N.log(`Video: Initial PTS/DTS adjusted: ${Ci(e,!0)}/${Ci(c,!0)}, delta: ${Ci(t,!0)} ms`)}}c=Math.max(0,c);let b=0,T=0,S=c;for(let t=0;t0?e.dts-s[t-1].dts:E;if(l=t>0?e.pts-s[t-1].pts:E,r.stretchShortVideoTrack&&null!==this.nextAudioPts){const t=Math.floor(r.maxBufferHole*i),s=(n?p+n*i:this.nextAudioPts)-e.pts;s>t?(f=s-a,f<0?f=a:L=!0,N.log(`[mp4-remuxer]: It is approximately ${s/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=a}else f=a}const u=Math.round(e.pts-e.dts);R=Math.min(R,f),D=Math.max(D,f),C=Math.min(C,l),O=Math.max(O,l),a.push(new Bi(e.key,f,c,u))}if(a.length)if(Ii){if(Ii<70){const t=a[0].flags;t.dependsOn=2,t.isNonSync=0}}else if(xi&&O-C0&&(n&&Math.abs(m-g)<9e3||Math.abs(Oi(f[0].pts-y,m)-g)<20*l),f.forEach((function(t){t.pts=Oi(t.pts-y,m)})),!r||g<0){if(f=f.filter((t=>t.pts>=0)),!f.length)return;g=0===i?0:n&&!d?Math.max(0,m):f[0].pts}if("aac"===t.segmentCodec){const e=this.config.maxAudioFramesDrift;for(let r=0,n=g;r=e*l&&c<1e4&&d){let e=Math.round(o/l);n=a-e*l,n<0&&(e--,n+=l),0===r&&(this.nextAudioPts=g=n),N.warn(`[mp4-remuxer]: Injecting ${e} audio frame @ ${(n/s).toFixed(3)}s due to ${Math.round(1e3*o/s)} ms gap.`);for(let s=0;s0))return;T+=p;try{v=new Uint8Array(T)}catch(t){return void this.observer.emit(I.ERROR,I.ERROR,{type:x.MUX_ERROR,details:P.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:T,reason:`fail allocating audio mdat ${T}`})}if(!u){new DataView(v.buffer).setUint32(0,T),v.set(wi.types.mdat,4)}}v.set(i,p);const l=i.byteLength;p+=l,h.push(new Bi(!0,o,l,0)),b=s}const A=h.length;if(!A)return;const _=h[h.length-1];this.nextAudioPts=g=b+a*_.duration;const k=u?new Uint8Array(0):wi.moof(t.sequenceNumber++,E/a,w({},t,{samples:h}));t.samples=[];const L=E/s,R=g/s,C={data1:k,data2:v,startPTS:L,endPTS:R,startDTS:L,endDTS:R,type:"audio",hasAudio:!0,hasVideo:!1,nb:A};return this.isAudioContiguous=!0,C}remuxEmptyAudio(t,e,r,n){const i=t.inputTimeScale,s=i/(t.samplerate?t.samplerate:i),a=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,c=(null!==a?a:n.startDTS*i)+l,u=n.endDTS*i+l,h=1024*s,d=Math.ceil((u-c)/h),f=ki.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(N.warn("[mp4-remuxer]: remux empty Audio"),!f)return void N.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const p=[];for(let t=0;t4294967296;)t+=r;return t}function Mi(t,e,r,n){const i=t.samples.length;if(!i)return;const s=t.inputTimeScale;for(let a=0;at.pts-e.pts));const s=t.samples;return t.samples=[],{samples:s}}class Bi{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={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:t?2:1,isNonSync:t?0:1}}}function Ni(t,e){const r=null==t?void 0:t.codec;if(r&&r.length>4)return r;if(e===V){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r){return _e(r,!1)}const t="mp4a.40.5";return N.info(`Parsed audio codec "${r}" or audio object type not handled. Using "${t}"`),t}return N.warn(`Unhandled video codec "${r}"`),"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1.42e01e"}try{Di=self.performance.now.bind(self.performance)}catch(t){N.debug("Unable to use Performance API on this environment"),Di=null==et?void 0:et.Date.now}const Ui=[{demux:class{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,r,n){const i=this.videoTrack=Gn("video",1),s=this.audioTrack=Gn("audio",1),a=this.txtTrack=Gn("text",1);if(this.id3Track=Gn("id3",1),this.timeOffset=0,null==t||!t.byteLength)return;const o=Yt(t);if(o.video){const{id:t,timescale:e,codec:r}=o.video;i.id=t,i.timescale=a.timescale=e,i.codec=r}if(o.audio){const{id:t,timescale:e,codec:r}=o.audio;s.id=t,s.timescale=e,s.codec=r}a.id=Nt.text,i.sampleDuration=0,i.duration=s.duration=n}resetContiguity(){this.remainderData=null}static probe(t){return function(t){const e=t.byteLength;for(let r=0;r8&&109===t[r+4]&&111===t[r+5]&&111===t[r+6]&&102===t[r+7])return!0;r=n>1?r+n:e}return!1}(t)}demux(t,e){this.timeOffset=e;let r=t;const n=this.videoTrack,i=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=te(this.remainderData,t));const e=function(t){const e={valid:null,remainder:null},r=Vt(t,["moof"]);if(r.length<2)return e.remainder=t,e;const n=r[r.length-1];return e.valid=yt(t,0,n.byteOffset-8),e.remainder=yt(t,n.byteOffset-8),e}(r);this.remainderData=e.remainder,n.samples=e.valid||new Uint8Array}else n.samples=r;const s=this.extractID3Track(n,e);return i.samples=ee(e,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(e,this.timeOffset);return r.samples=ee(t,e),{videoTrack:e,audioTrack:Gn(),id3Track:n,textTrack:Gn()}}extractID3Track(t,e){const r=this.id3Track;if(t.samples.length){const n=Vt(t.samples,["emsg"]);n&&n.forEach((t=>{const n=function(t){const e=t[0];let r="",n="",i=0,s=0,a=0,o=0,l=0,c=0;if(0===e){for(;"\0"!==Ut(t.subarray(c,c+1));)r+=Ut(t.subarray(c,c+1)),c+=1;for(r+=Ut(t.subarray(c,c+1)),c+=1;"\0"!==Ut(t.subarray(c,c+1));)n+=Ut(t.subarray(c,c+1)),c+=1;n+=Ut(t.subarray(c,c+1)),c+=1,i=jt(t,12),s=jt(t,16),o=jt(t,20),l=jt(t,24),c=28}else if(1===e){c+=4,i=jt(t,c),c+=4;const e=jt(t,c);c+=4;const s=jt(t,c);for(c+=4,a=2**32*e+s,C(a)||(a=Number.MAX_SAFE_INTEGER,N.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=jt(t,c),c+=4,l=jt(t,c),c+=4;"\0"!==Ut(t.subarray(c,c+1));)r+=Ut(t.subarray(c,c+1)),c+=1;for(r+=Ut(t.subarray(c,c+1)),c+=1;"\0"!==Ut(t.subarray(c,c+1));)n+=Ut(t.subarray(c,c+1)),c+=1;n+=Ut(t.subarray(c,c+1)),c+=1}return{schemeIdUri:r,value:n,timeScale:i,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:t.subarray(c,t.byteLength)}}(t);if(ci.test(n.schemeIdUri)){const t=R(n.presentationTime)?n.presentationTime/n.timeScale:e+n.presentationTimeDelta/n.timeScale;let i=4294967295===n.eventDuration?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;i<=.001&&(i=Number.POSITIVE_INFINITY);const s=n.payload;r.samples.push({data:s,len:s.byteLength,dts:t,pts:t,type:rr,duration:i})}}))}return r}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)return t;const r=e.keyId;r&&e.isCommonEncryption&&Vt(t,["moov","trak"]).forEach((t=>{const e=Vt(t,["mdia","minf","stbl","stsd"])[0].subarray(8);let n=Vt(e,["enca"]);const i=n.length>0;i||(n=Vt(e,["encv"])),n.forEach((t=>{Vt(i?t.subarray(28):t.subarray(78),["sinf"]).forEach((t=>{const e=Jt(t);if(e){const t=e.subarray(8,24);t.some((t=>0!==t))||(N.log(`[eme] Patching keyId in 'enc${i?"a":"v"}>sinf>>tenc' box: ${Mt(t)} -> ${Mt(r)}`),e.set(r,8))}}))}))}));return t}(t,n)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:r}=this;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const n=this.initData=Yt(t);n.audio&&(e=Ni(n.audio,V)),n.video&&(r=Ni(n.video,W));const 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"}:N.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=i}remux(t,e,r,n,i,s){var a,o;let{initPTS:l,lastEndTime:c}=this;const u={audio:void 0,video:void 0,text:n,id3:r,initSegment:void 0};R(c)||(c=this.lastEndTime=i||0);const h=e.samples;if(null==h||!h.length)return u;const d={initPTS:void 0,timescale:1};let f=this.initData;if(null!=(a=f)&&a.length||(this.generateInitSegment(h),f=this.initData),null==(o=f)||!o.length)return N.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);const p=function(t,e){let r=0,n=0,i=0;const s=Vt(t,["moof","traf"]);for(let t=0;tt+e.info.duration||0),0);r=Math.max(r,t+s.earliestPresentationTime/s.timescale),n=r-e}}if(n&&R(n))return n}return n||i}(h,f),g=function(t,e){return Vt(e,["moof","traf"]).reduce(((e,r)=>{const n=Vt(r,["tfdt"])[0],i=n[0],s=Vt(r,["tfhd"]).reduce(((e,r)=>{const s=jt(r,4),a=t[s];if(a){let t=jt(n,4);if(1===i){if(t===Ft)return N.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t*=Ft+1,t+=jt(n,8)}const r=t/(a.timescale||9e4);if(R(r)&&(null===e||ri}(l,m,i,p)||d.timescale!==l.timescale&&s)&&(d.initPTS=m-i,l&&1===l.timescale&&N.warn("Adjusting initPTS by "+(d.initPTS-l.baseTime)),this.initPTS=l={baseTime:d.initPTS,timescale:1});const y=t?m-l.baseTime/l.timescale:c,v=y+p;!function(t,e,r){Vt(e,["moof","traf"]).forEach((e=>{Vt(e,["tfhd"]).forEach((n=>{const i=jt(n,4),s=t[i];if(!s)return;const a=s.timescale||9e4;Vt(e,["tfdt"]).forEach((t=>{const e=t[0],n=r*a;if(n){let r=jt(t,4);if(0===e)r-=n,r=Math.max(r,0),Ht(t,4,r);else{r*=Math.pow(2,32),r+=jt(t,8),r-=n,r=Math.max(r,0);const e=Math.floor(r/(Ft+1)),i=Math.floor(r%(Ft+1));Ht(t,4,e),Ht(t,8,i)}}}))}))}))}(f,h,l.baseTime/l.timescale),p>0?this.lastEndTime=v:(N.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const E=!!f.audio,b=!!f.video;let T="";E&&(T+="audio"),b&&(T+="video");const S={data1:h,startPTS:y,startDTS:y,endPTS:v,endDTS:v,type:T,hasAudio:E,hasVideo:b,nb:1,dropped:0};return u.audio="audio"===S.type?S:void 0,u.video="audio"!==S.type?S:void 0,u.initSegment=d,u.id3=Mi(r,i,l,l),n.samples.length&&(u.text=Fi(n,i,l)),u}}},{demux:vi,remux:Pi},{demux:class extends Kn{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,r,n){super.resetInitSegment(t,e,r,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;const e=bt(t,0);let r=(null==e?void 0:e.length)||0;if(li(t,r))return!1;for(let e=t.length;r0&&null!=(null==e?void 0:e.key)&&null!==e.iv&&null!=e.method&&(r=e);return r}(s,e);if(E&&"AES-128"===E.method){const t=this.getDecrypter();if(!t.isSync())return this.decryptionPromise=t.webCryptoDecrypt(s,E.key.buffer,E.iv.buffer).then((t=>{const e=this.push(t,null,r);return this.decryptionPromise=null,e})),this.decryptionPromise;{let e=t.softwareDecrypt(s,E.key.buffer,E.iv.buffer);if(r.part>-1&&(e=t.flush()),!e)return i.executeEnd=Di(),ji(r);s=new Uint8Array(e)}}const b=this.needsProbing(c,u);if(b){const t=this.configureTransmuxer(s);if(t)return N.warn(`[transmuxer] ${t.message}`),this.observer.emit(I.ERROR,I.ERROR,{type:x.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),i.executeEnd=Di(),ji(r)}(c||u||f||b)&&this.resetInitSegment(v,p,g,y,e),(c||f||b)&&this.resetInitialTimestamp(m),l||this.resetContiguity();const T=this.transmux(s,E,d,h,r),S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,i.executeEnd=Di(),T}flush(t){const e=t.transmuxing;e.executeStart=Di();const{decrypter:r,currentTransmuxState:n,decryptionPromise:i}=this;if(i)return i.then((()=>this.flush(t)));const s=[],{timeOffset:a}=n;if(r){const e=r.flush();e&&s.push(this.push(e,null,t))}const{demuxer:o,remuxer:l}=this;if(!o||!l)return e.executeEnd=Di(),[ji(t)];const c=o.flush(a);return Gi(c)?c.then((e=>(this.flushRemux(s,e,t),s))):(this.flushRemux(s,c,t),s)}flushRemux(t,e,r){const{audioTrack:n,videoTrack:i,id3Track:s,textTrack:a}=e,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;N.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);const c=this.remuxer.remux(n,i,s,a,l,o,!0,this.id);t.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=Di()}resetInitialTimestamp(t){const{demuxer:e,remuxer:r}=this;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,r,n,i){const{demuxer:s,remuxer:a}=this;s&&a&&(s.resetInitSegment(t,e,r,n),a.resetInitSegment(t,e,r,i))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,r,n,i){let s;return s=e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,n,i):this.transmuxUnencrypted(t,r,n,i),s}transmuxUnencrypted(t,e,r,n){const{audioTrack:i,videoTrack:s,id3Track:a,textTrack:o}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(i,s,a,o,e,r,!1,this.id),chunkMeta:n}}transmuxSampleAes(t,e,r,n,i){return this.demuxer.demuxSampleAes(t,e,r).then((t=>({remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,n,!1,this.id),chunkMeta:i})))}configureTransmuxer(t){const{config:e,observer:r,typeSupported:n,vendor:i}=this;let s;for(let e=0,r=Ui.length;e({remuxResult:{},chunkMeta:t});function Gi(t){return"then"in t&&t.then instanceof Function}class Ki{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 Hi{constructor(t,e,r,n,i,s){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=s}}var Vi={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function i(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function s(t,e,n,s,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new i(n,s||t,a),l=r?r+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function o(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),o.prototype.eventNames=function(){var t,n,i=[];if(0===this._eventsCount)return i;for(n in t=this._events)e.call(t,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},o.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,a=new Array(s);i{(e=e||{}).frag=this.frag,e.id=this.id,t===I.ERROR&&(this.error=e.error),this.hls.trigger(t,e)};this.observer=new Wi,this.observer.on(I.FRAG_DECRYPTED,s),this.observer.on(I.ERROR,s);const a=ge(i.preferManagedMediaSource)||{isTypeSupported:()=>!1},o={mpeg:a.isTypeSupported("audio/mpeg"),mp3:a.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:a.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&"undefined"!=typeof Worker){if(i.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{i.workerPath?(N.log(`loading Web Worker ${i.workerPath} for "${e}"`),this.workerContext=function(t){const e=new self.URL(t,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}(i.workerPath)):(N.log(`injecting Web Worker for "${e}"`),this.workerContext=function(){const t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(t);return{worker:new self.Worker(e),objectURL:e}}()),this.onwmsg=t=>this.onWorkerMessage(t);const{worker:t}=this.workerContext;t.addEventListener("message",this.onwmsg),t.onerror=t=>{const r=new Error(`${t.message} (${t.filename}:${t.lineno})`);i.enableWorker=!1,N.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(I.ERROR,{type:x.OTHER_ERROR,details:P.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:r})},t.postMessage({cmd:"init",typeSupported:o,vendor:"",id:e,config:JSON.stringify(i)})}catch(t){N.warn(`Error setting up "${e}" Web Worker, fallback to inline`,t),this.resetWorker(),this.error=null,this.transmuxer=new $i(this.observer,o,i,"",e)}return}}this.transmuxer=new $i(this.observer,o,i,"",e)}resetWorker(){if(this.workerContext){const{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(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,r,n,i,s,a,o,l,c){var u,h;l.transmuxing.start=self.performance.now();const{transmuxer:d}=this,f=s?s.start:i.start,p=i.decryptdata,g=this.frag,m=!(g&&i.cc===g.cc),y=!(g&&l.level===g.level),v=g?l.sn-g.sn:-1,E=this.part?l.part-this.part.index:-1,b=0===v&&l.id>1&&l.id===(null==g?void 0:g.stats.chunkCount),T=!y&&(1===v||0===v&&(1===E||b&&E<=0)),S=self.performance.now();(y||v||0===i.stats.parsing.start)&&(i.stats.parsing.start=S),!s||!E&&T||(s.stats.parsing.start=S);const A=!(g&&(null==(u=i.initSegment)?void 0:u.url)===(null==(h=g.initSegment)?void 0:h.url)),_=new Hi(m,T,o,y,f,A);if(!T||m||A){N.log(`[transmuxer-interface, ${i.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${m}\n trackSwitch: ${y}\n contiguous: ${T}\n accurateTimeOffset: ${o}\n timeOffset: ${f}\n initSegmentChange: ${A}`);const t=new Ki(r,n,e,a,c);this.configureTransmuxer(t)}if(this.frag=i,this.part=s,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:p,chunkMeta:l,state:_},t instanceof ArrayBuffer?[t]:[]);else if(d){const e=d.push(t,p,l,_);Gi(e)?(d.async=!0,e.then((t=>{this.handleTransmuxComplete(t)})).catch((t=>{this.transmuxerError(t,l,"transmuxer-interface push error")}))):(d.async=!1,this.handleTransmuxComplete(e))}}flush(t){t.transmuxing.start=self.performance.now();const{transmuxer:e}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(e){let r=e.flush(t);Gi(r)||e.async?(Gi(r)||(r=Promise.resolve(r)),r.then((e=>{this.handleFlushResult(e,t)})).catch((e=>{this.transmuxerError(e,t,"transmuxer-interface flush error")}))):this.handleFlushResult(r,t)}}transmuxerError(t,e,r){this.hls&&(this.error=t,this.hls.trigger(I.ERROR,{type:x.MEDIA_ERROR,details:P.FRAG_PARSING_ERROR,chunkMeta:e,frag:this.frag||void 0,fatal:!1,error:t,err:t,reason:r}))}handleFlushResult(t,e){t.forEach((t=>{this.handleTransmuxComplete(t)})),this.onFlush(e)}onWorkerMessage(t){const e=t.data;if(null==e||!e.event)return void N.warn("worker message received with no "+(e?"event name":"data"));const r=this.hls;if(this.hls)switch(e.event){case"init":{var n;const t=null==(n=this.workerContext)?void 0:n.objectURL;t&&self.URL.revokeObjectURL(t);break}case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":N[e.data.logType]&&N[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){const{transmuxer:e}=this;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)}}function qi(t,e){if(t.length!==e.length)return!1;for(let r=0;rt[r]!==e[r]))}function Xi(t,e){return e.label.toLowerCase()===t.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(t.lang||"").toLowerCase())}class Qi{constructor(t){this.buffered=void 0;const e=(e,r,n)=>{if((r>>>=0)>n-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${n})`);return t[r][e]};this.buffered={get length(){return t.length},end:r=>e("end",r,t.length),start:r=>e("start",r,t.length)}}}class Ji{constructor(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}append(t,e,r){const n=this.queues[e];n.push(t),1!==n.length||r||this.executeNext(e)}insertAbort(t,e){this.queues[e].unshift(t),this.executeNext(e)}appendBlocker(t){let e;const r=new Promise((t=>{e=t})),n={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,t),r}executeNext(t){const e=this.queues[t];if(e.length){const r=e[0];try{r.execute()}catch(e){N.warn(`[buffer-operation-queue]: Exception executing "${t}" SourceBuffer operation: ${e}`),r.onError(e);const n=this.buffers[t];null!=n&&n.updating||this.shiftAndExecuteNext(t)}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const Zi=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;function ts(t){const e=t.querySelectorAll("source");[].slice.call(e).forEach((e=>{t.removeChild(e)}))}const es={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},rs=t=>String.fromCharCode(es[t]||t),ns=15,is=100,ss={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},as={17:2,18:4,21:6,22:8,23:10,19:13,20:15},os={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},ls={25:2,26:4,29:6,30:8,31:10,27:13,28:15},cs=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class us{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const r="function"==typeof e?e():e;N.log(`${this.time} [${t}] ${r}`)}}}const hs=function(t){const e=[];for(let r=0;ris&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=is)}moveCursor(t){const e=this.pos+t;if(t>1)for(let t=this.pos+1;t=144&&this.backSpace();const e=rs(t);this.pos>=is?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(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,(()=>this.getDisplayText()));const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let r="",n=-1;for(let r=0;r0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r}getTextAndFormat(){return this.rows}}class ms{constructor(t,e,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new gs(r),this.nonDisplayedMemory=new gs(r),this.lastOutputScreen=new gs(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,(()=>"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(t){for(let e=0;ee+": "+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(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const 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){const e={flash:!1};if(e.underline=t%2==1,e.italics=t>=46,e.italics)e.foreground="white";else{const r=Math.floor(t/2)-16,n=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=n[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const 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 ys{constructor(t,e,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const n=this.logger=new us;this.channels=[null,new ms(t,e,n),new ms(t+1,r,n)]}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){this.logger.time=t;for(let t=0;t"["+hs([e[t],e[t+1]])+"] -> ("+hs([r,n])+")"));const a=this.cmdHistory;if(r>=16&&r<=31){if(Es(r,n,a)){vs(null,null,a),this.logger.log(3,(()=>"Repeated command ("+hs([r,n])+") is dropped"));continue}vs(r,n,this.cmdHistory),i=this.parseCmd(r,n),i||(i=this.parseMidrow(r,n)),i||(i=this.parsePAC(r,n)),i||(i=this.parseBackgroundAttributes(r,n))}else vs(null,null,a);if(!i&&(s=this.parseChars(r,n),s)){const t=this.currentChannel;if(t&&t>0){this.channels[t].insertChars(s)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}i||s||this.logger.log(2,(()=>"Couldn't parse cleaned data "+hs([r,n])+" orig: "+hs([e[t],e[t+1]])))}}parseCmd(t,e){if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47)&&!((23===t||31===t)&&e>=33&&e<=35))return!1;const r=20===t||21===t||23===t?1:2,n=this.channels[r];return 20===t||21===t||28===t||29===t?32===e?n.ccRCL():33===e?n.ccBS():34===e?n.ccAOF():35===e?n.ccAON():36===e?n.ccDER():37===e?n.ccRU(2):38===e?n.ccRU(3):39===e?n.ccRU(4):40===e?n.ccFON():41===e?n.ccRDC():42===e?n.ccTR():43===e?n.ccRTD():44===e?n.ccEDM():45===e?n.ccCR():46===e?n.ccENM():47===e&&n.ccEOC():n.ccTO(e-32),this.currentChannel=r,!0}parseMidrow(t,e){let r=0;if((17===t||25===t)&&e>=32&&e<=47){if(r=17===t?1:2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const n=this.channels[r];return!!n&&(n.ccMIDROW(e),this.logger.log(3,(()=>"MIDROW ("+hs([t,e])+")")),!0)}return!1}parsePAC(t,e){let r;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127)&&!((16===t||24===t)&&e>=64&&e<=95))return!1;const n=t<=23?1:2;r=e>=64&&e<=95?1===n?ss[t]:os[t]:1===n?as[t]:ls[t];const i=this.channels[n];return!!i&&(i.setPAC(this.interpretPAC(r,e)),this.currentChannel=n,!0)}interpretPAC(t,e){let r;const n={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,n.underline=!(1&~r),r<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((r-16)/2),n}parseChars(t,e){let r,n=null,i=null;if(t>=25?(r=2,i=t-8):(r=1,i=t),i>=17&&i<=19){let t;t=17===i?e+80:18===i?e+112:e+144,this.logger.log(2,(()=>"Special char '"+rs(t)+"' in channel "+r)),n=[t]}else t>=32&&t<=127&&(n=0===e?[t]:[t,e]);return n&&this.logger.log(3,(()=>"Char codes = "+hs(n).join(","))),n}parseBackgroundAttributes(t,e){if(!((16===t||24===t)&&e>=32&&e<=47)&&!((23===t||31===t)&&e>=45&&e<=47))return!1;let r;const n={};16===t||24===t?(r=Math.floor((e-32)/2),n.background=cs[r],e%2==1&&(n.background=n.background+"_semi")):45===e?n.background="transparent":(n.foreground="black",47===e&&(n.underline=!0));const i=t<=23?1:2;return this.channels[i].setBkgData(n),!0}reset(){for(let t=0;tt)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Ts=function(){if(null!=et&&et.VTTCue)return self.VTTCue;const t=["","lr","rl"],e=["start","middle","end","left","right"];function r(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;const r=e.toLowerCase();return!!~t.indexOf(r)&&r}function n(t){return r(e,t)}function i(t,...e){let r=1;for(;r100)throw new Error("Position must be between 0 and 100.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",i({},l,{get:function(){return b},set:function(t){const e=n(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",i({},l,{get:function(){return T},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");T=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",i({},l,{get:function(){return S},set:function(t){const e=n(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");S=e,this.hasBeenReset=!0}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class Ss{decode(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function As(t){function e(t,e,r,n){return 3600*(0|t)+60*(0|e)+(0|r)+parseFloat(n||0)}const r=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?e(r[2],r[3],0,r[4]):e(r[1],r[2],r[3],r[4]):null}class _s{constructor(){this.values=Object.create(null)}set(t,e){this.get(t)||""===e||(this.values[t]=e)}get(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,r){for(let n=0;n=0&&r<=100)return this.set(t,r),!0}return!1}}function ks(t,e,r,n){const i=n?t.split(n):[t];for(const t in i){if("string"!=typeof i[t])continue;const n=i[t].split(r);if(2!==n.length)continue;e(n[0],n[1])}}const Ls=new Ts(0,0,""),ws="middle"===Ls.align?"middle":"center";function Rs(t,e,r){const n=t;function i(){const e=As(t);if(null===e)throw new Error("Malformed timestamp: "+n);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function s(){t=t.replace(/^\s+/,"")}if(s(),e.startTime=i(),s(),"--\x3e"!==t.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);t=t.slice(3),s(),e.endTime=i(),s(),function(t,e){const n=new _s;ks(t,(function(t,e){let i;switch(t){case"region":for(let i=r.length-1;i>=0;i--)if(r[i].id===e){n.set(t,r[i].region);break}break;case"vertical":n.alt(t,e,["rl","lr"]);break;case"line":i=e.split(","),n.integer(t,i[0]),n.percent(t,i[0])&&n.set("snapToLines",!1),n.alt(t,i[0],["auto"]),2===i.length&&n.alt("lineAlign",i[1],["start",ws,"end"]);break;case"position":i=e.split(","),n.percent(t,i[0]),2===i.length&&n.alt("positionAlign",i[1],["start",ws,"end","line-left","line-right","auto"]);break;case"size":n.percent(t,e);break;case"align":n.alt(t,e,["start",ws,"end","left","right"])}}),/:/,/\s/),e.region=n.get("region",null),e.vertical=n.get("vertical","");let i=n.get("line","auto");"auto"===i&&-1===Ls.line&&(i=-1),e.line=i,e.lineAlign=n.get("lineAlign","start"),e.snapToLines=n.get("snapToLines",!0),e.size=n.get("size",100),e.align=n.get("align",ws);let s=n.get("position","auto");"auto"===s&&50===Ls.position&&(s="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=s}(t,e)}function Cs(t){return t.replace(//gi,"\n")}class Ds{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Ss,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;function r(){let t=e.buffer,r=0;for(t=Cs(t);r>>0).toString()};function Os(t,e,r){return Ps(t.toString())+Ps(e.toString())+Ps(r)}function Ms(t,e,r,n,i,s,a){const o=new Ds,l=xt(new Uint8Array(t)).trim().replace(Is,"\n").split("\n"),c=[],u=e?function(t,e=1){return Ri(t,9e4,1/e)}(e.baseTime,e.timescale):0;let h,d="00:00.000",f=0,p=0,g=!0;o.oncue=function(t){const s=r[n];let a=r.ccOffset;const o=(f-u)/9e4;if(null!=s&&s.new&&(void 0!==p?a=r.ccOffset=s.start:function(t,e,r){let n=t[e],i=t[n.prevCC];if(!i||!i.new&&n.new)return t.ccOffset=t.presentationOffset=n.start,void(n.new=!1);for(;null!=(s=i)&&s.new;){var s;t.ccOffset+=n.start-i.start,n.new=!1,n=i,i=t[n.prevCC]}t.presentationOffset=r}(r,n,o)),o){if(!e)return void(h=new Error("Missing initPTS for VTT MPEGTS"));a=o-r.presentationOffset}const l=t.endTime-t.startTime,d=Oi(9e4*(t.startTime+a-p),9e4*i)/9e4;t.startTime=Math.max(d,0),t.endTime=Math.max(d+l,0);const g=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(g)),t.id||(t.id=Os(t.startTime,t.endTime,g)),t.endTime>0&&c.push(t)},o.onparsingerror=function(t){h=t},o.onflush=function(){h?a(h):s(c)},l.forEach((t=>{if(g){if(xs(t,"X-TIMESTAMP-MAP=")){g=!1,t.slice(16).split(",").forEach((t=>{xs(t,"LOCAL:")?d=t.slice(6):xs(t,"MPEGTS:")&&(f=parseInt(t.slice(7)))}));try{p=function(t){let e=parseInt(t.slice(-3));const r=parseInt(t.slice(-6,-4)),n=parseInt(t.slice(-9,-7)),i=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(R(e)&&R(r)&&R(n)&&R(i)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${t}`);return e+=1e3*r,e+=6e4*n,e+=36e5*i,e}(d)/1e3}catch(t){h=t}return}""===t&&(g=!1)}o.parse(t+"\n")})),o.flush()}const Fs="stpp.ttml.im1t",Bs=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ns=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Us={left:"start",center:"center",right:"end",start:"start",end:"end"};function $s(t,e,r,n){const i=Vt(new Uint8Array(t),["mdat"]);if(0===i.length)return void n(new Error("Could not parse IMSC1 mdat"));const s=i.map((t=>xt(t))),a=function(t,e,r=1,n=!1){return Ri(t,e,1/r,n)}(e.baseTime,1,e.timescale);try{s.forEach((t=>r(function(t,e){const r=(new DOMParser).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)),{}),a="preserve"!==n.getAttribute("xml:space"),o=Gs(js(n,"styling","style")),l=Gs(js(n,"layout","region")),c=js(n,"body","[begin]");return[].map.call(c,(t=>{const r=Ks(t,a);if(!r||!t.hasAttribute("begin"))return null;const n=Ws(t.getAttribute("begin"),s),i=Ws(t.getAttribute("dur"),s);let c=Ws(t.getAttribute("end"),s);if(null===n)throw Vs(t);if(null===c){if(null===i)throw Vs(t);c=n+i}const u=new Ts(n-e,c-e,r);u.id=Os(u.startTime,u.endTime,u.text);const h=function(t,e,r){const n="http://www.w3.org/ns/ttml#styling";let i=null;const s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;a&&r.hasOwnProperty(a)&&(i=r[a]);return s.reduce(((r,s)=>{const a=Hs(e,n,s)||Hs(t,n,s)||Hs(i,n,s);return a&&(r[s]=a),r}),{})}(l[t.getAttribute("region")],o[t.getAttribute("style")],o),{textAlign:d}=h;if(d){const t=Us[d];t&&(u.lineAlign=t),u.align=d}return w(u,h),u})).filter((t=>null!==t))}(t,a))))}catch(t){n(t)}}function js(t,e,r){const n=t.getElementsByTagName(e)[0];return n?[].slice.call(n.querySelectorAll(r)):[]}function Gs(t){return t.reduce(((t,e)=>{const r=e.getAttribute("xml:id");return r&&(t[r]=e),t}),{})}function Ks(t,e){return[].slice.call(t.childNodes).reduce(((t,r,n)=>{var i;return"br"===r.nodeName&&n?t+"\n":null!=(i=r.childNodes)&&i.length?Ks(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent}),"")}function Hs(t,e,r){return t&&t.hasAttributeNS(e,r)?t.getAttributeNS(e,r):null}function Vs(t){return new Error(`Could not parse ttml timestamp ${t}`)}function Ws(t,e){if(!t)return null;let r=As(t);return null===r&&(Bs.test(t)?r=function(t,e){const r=Bs.exec(t),n=(0|r[4])+(0|r[5])/e.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+n/e.frameRate}(t,e):Ns.test(t)&&(r=function(t,e){const r=Ns.exec(t),n=Number(r[1]);switch(r[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/e.frameRate;case"t":return n/e.tickRate}return n}(t,e))),r}function Ys(t){return t.characteristics&&/transcribes-spoken-dialog/gi.test(t.characteristics)&&/describes-music-and-sound/gi.test(t.characteristics)?"captions":"subtitles"}function qs(t,e){return!!t&&t.kind===Ys(e)&&Xi(e,t)}class zs{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.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(I.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(I.BUFFER_CODECS,this.onBufferCodecs,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(I.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(I.BUFFER_CODECS,this.onBufferCodecs,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const r=this.hls.levels[e.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(t,e){const r=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,r.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onLevelsUpdated(t,e){this.timer&&R(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const t=this.hls.levels;if(t.length){const e=this.hls,r=this.getMaxLevel(t.length-1);r!==this.autoLevelCapping&&N.log(`Setting autoLevelCapping to ${r}: ${t[r].height}p@${t[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),e.autoLevelCapping=r,e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const r=e.filter(((e,r)=>this.isLevelAllowed(e)&&r<=t));return this.clientRect=null,zs.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,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(){if(this.clientRect)return this.clientRect;const t=this.media,e={width:0,height:0};if(t){const 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)}return this.clientRect=e,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(t){return!this.restrictedLevels.some((e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height))}static getMaxLevelByMediaSize(t,e,r){if(null==t||!t.length)return-1;let n=t.length-1;const i=Math.max(e,r);for(let e=0;e=i||r.height>=i)&&(s=r,!(a=t[e+1])||s.width!==a.width||s.height!==a.height)){n=e;break}}var s,a;return n}}const Xs="[eme]";class Qs{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=Qs.CDMCleanupPromise?[Qs.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=N.debug.bind(N,Xs),this.log=N.log.bind(N,Xs),this.warn=N.warn.bind(N,Xs),this.error=N.error.bind(N,Xs),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const 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(I.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(I.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(I.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(I.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(I.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(I.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(I.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:r}=this.config,n=e[t];if(n)return n.licenseUrl;if(t===rt.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,r=e[t];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,r=(t,e,r)=>!!t&&r.indexOf(t)===e,n=e.map((t=>t.audioCodec)).filter(r),i=e.map((t=>t.videoCodec)).filter(r);return n.length+i.length===0&&i.push("avc1.42e01e"),new Promise(((e,r)=>{const s=t=>{const a=t.shift();this.getMediaKeysPromise(a,n,i).then((t=>e({keySystem:a,mediaKeys:t}))).catch((e=>{t.length?s(t):r(e instanceof Js?e:new Js({type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))}))};s(t)}))}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!=typeof r){let t=`Configured requestMediaKeySystemAccess is not a function ${r}`;return null===gt&&"http:"===self.location.protocol&&(t=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(t))}return r(t,e)}getMediaKeysPromise(t,e,r){const n=function(t,e,r,n){let i;switch(t){case rt.FAIRPLAY:i=["cenc","sinf"];break;case rt.WIDEVINE:case rt.PLAYREADY:i=["cenc"];break;case rt.CLEARKEY:i=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${t}`)}return function(t,e,r,n){return[{initDataTypes:t,persistentState:n.persistentState||"optional",distinctiveIdentifier:n.distinctiveIdentifier||"optional",sessionTypes:n.sessionTypes||[n.sessionType||"temporary"],audioCapabilities:e.map((t=>({contentType:`audio/mp4; codecs="${t}"`,robustness:n.audioRobustness||"",encryptionScheme:n.audioEncryptionScheme||null}))),videoCapabilities:r.map((t=>({contentType:`video/mp4; codecs="${t}"`,robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null})))}]}(i,e,r,n)}(t,e,r,this.config.drmSystemOptions),i=this.keySystemAccessPromises[t];let s=null==i?void 0:i.keySystemAccess;if(!s){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(n)}`),s=this.requestMediaKeySystemAccess(t,n);const e=this.keySystemAccessPromises[t]={keySystemAccess:s};return s.catch((e=>{this.log(`Failed to obtain access to key-system "${t}": ${e}`)})),s.then((r=>{this.log(`Access for key-system "${r.keySystem}" obtained`);const n=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),e.mediaKeys=r.createMediaKeys().then((e=>(this.log(`Media-keys created for "${t}"`),n.then((r=>r?this.setMediaKeysServerCertificate(e,t,r):e))))),e.mediaKeys.catch((e=>{this.error(`Failed to create media-keys for "${t}"}: ${e}`)})),e.mediaKeys}))}return s.then((()=>i.mediaKeys))}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:r}){this.log(`Creating key-system session "${e}" keyId: ${Mt(t.keyId||[])}`);const n=r.createSession(),i={decryptdata:t,keySystem:e,mediaKeys:r,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(i),i}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const r=this.createMediaKeySessionContext(t),n=this.getKeyIdString(e),i="cenc";this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(r,i,e.pssh,"expired")}else 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 Mt(t.keyId)}updateKeySession(t,e){var r;const n=t.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Mt((null==(r=t.decryptdata)?void 0:r.keyId)||[])}\n } (data length: ${e?e.byteLength:e})`),n.update(e)}selectKeySystemFormat(t){const 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(t){return new Promise(((e,r)=>{const n=pt(this.config),i=t.map(ot).filter((t=>!!t&&-1!==n.indexOf(t)));return this.getKeySystemSelectionPromise(i).then((({keySystem:t})=>{const n=ft(t);n?e(n):r(new Error(`Unable to find format for key-system "${t}"`))})).catch(r)}))}loadKey(t){const e=t.keyInfo.decryptdata,r=this.getKeyIdString(e),n=`(keyId: ${r} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${n}`);let i=this.keyIdToKeySessionPromise[r];return i||(i=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(e).then((({keySystem:r,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${n}`),this.attemptSetMediaKeys(r,i).then((()=>{this.throwIfDestroyed();const t=this.createMediaKeySessionContext({keySystem:r,mediaKeys:i,decryptdata:e});return this.generateRequestWithPreferredKeySession(t,"cenc",e.pssh,"playlist-key")}))))),i.catch((t=>this.handleError(t)))),i}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof Js?this.hls.trigger(I.ERROR,t.data):this.hls.trigger(I.ERROR,{type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),r=this.keyIdToKeySessionPromise[e];if(!r){const e=ot(t.keyFormat),r=e?[e]:pt(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(t){if(t.length||(t=pt(this.config)),0===t.length)throw new Js({type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:r}=t,n=`"${t.type}" event: init data type: "${e}"`;if(this.debug(n),null===r)return;let i,s;if("sinf"===e&&this.config.drmSystems[rt.FAIRPLAY]){const t=Ut(new Uint8Array(r));try{const e=J(JSON.parse(t).sinf),r=Jt(new Uint8Array(e));if(!r)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");i=r.subarray(8,24),s=rt.FAIRPLAY}catch(t){return void this.warn(`${n} Failed to parse sinf: ${t}`)}}else{const t=function(t){const e=[];if(t instanceof ArrayBuffer){const r=t.byteLength;let n=0;for(;n+32t.systemId===ht))[0];if(!e)return void(0===t.length||t.some((t=>!t.systemId))?this.warn(`${n} contains incomplete or invalid pssh data`):this.log(`ignoring ${n} for ${t.map((t=>dt(t.systemId))).join(",")} pssh data in favor of playlist keys`));if(s=dt(e.systemId),0===e.version&&e.data){const t=e.data.length-22;i=e.data.subarray(t,t+16)}}if(!s||!i)return;const a=Mt(i),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this;let c=o[a];for(let t=0;tthis.generateRequestWithPreferredKeySession(n,e,r,"encrypted-event-key-match")));break}}c||(c=o[a]=this.getKeySystemSelectionPromise([s]).then((({keySystem:t,mediaKeys:n})=>{var s;this.throwIfDestroyed();const o=new le("ISO-23001-7",a,null!=(s=ft(t))?s:"");return o.pssh=new Uint8Array(r),o.keyId=i,this.attemptSetMediaKeys(t,n).then((()=>{this.throwIfDestroyed();const i=this.createMediaKeySessionContext({decryptdata:o,keySystem:t,mediaKeys:n});return this.generateRequestWithPreferredKeySession(i,e,r,"encrypted-event-no-match")}))}))),c.catch((t=>this.handleError(t)))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const n=Promise.all(r).then((()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)}));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(t,e,r,n){var i,s;const a=null==(i=this.config.drmSystems)||null==(s=i[t.keySystem])?void 0:s.generateRequest;if(a)try{const n=a.call(this.hls,e,r,t);if(!n)throw new Error("Invalid response from configured generateRequest filter");e=n.initDataType,r=t.decryptdata.pssh=n.initData?new Uint8Array(n.initData):null}catch(t){var o;if(this.warn(t.message),null!=(o=this.hls)&&o.config.debug)throw t}if(null===r)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(t);const l=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${n}": ${l} (init data type: ${e} length: ${r?r.byteLength:null})`);const c=new Wi,u=t._onmessage=e=>{const r=t.mediaKeysSession;if(!r)return void c.emit("error",new Error("invalid state"));const{messageType:n,message:i}=e;this.log(`"${n}" message event for session "${r.sessionId}" message size: ${i.byteLength}`),"license-request"===n||"license-renewal"===n?this.renewLicense(t,i).catch((t=>{this.handleError(t),c.emit("error",t)})):"license-release"===n?t.keySystem===rt.FAIRPLAY&&(this.updateKeySession(t,tt("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${n}"`)},h=t._onkeystatuseschange=e=>{if(!t.mediaKeysSession)return void c.emit("error",new Error("invalid state"));this.onKeyStatusChange(t);const r=t.keyStatus;c.emit("keyStatus",r),"expired"===r&&(this.warn(`${t.keySystem} expired for key ${l}`),this.renewKeySession(t))};t.mediaKeysSession.addEventListener("message",u),t.mediaKeysSession.addEventListener("keystatuseschange",h);const d=new Promise(((t,e)=>{c.on("error",e),c.on("keyStatus",(r=>{r.startsWith("usable")?t():"output-restricted"===r?e(new Js({type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?e(new Js({type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${r}"`)):"expired"===r?e(new Error("key expired while generating request")):this.warn(`unhandled key status change "${r}"`)}))}));return t.mediaKeysSession.generateRequest(e,r).then((()=>{var e;this.log(`Request generated for key-session "${null==(e=t.mediaKeysSession)?void 0:e.sessionId}" keyId: ${l}`)})).catch((t=>{throw new Js({type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_NO_SESSION,error:t,fatal:!1},`Error generating key-session request: ${t}`)})).then((()=>d)).catch((e=>{throw c.removeAllListeners(),this.removeSession(t),e})).then((()=>(c.removeAllListeners(),t)))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach(((e,r)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Mt("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Mt(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e}))}fetchServerCertificate(t){const e=this.config,r=new(0,e.loader)(e),n=this.getServerCertificateUrl(t);return n?(this.log(`Fetching server certificate for "${t}"`),new Promise(((i,s)=>{const a={responseType:"arraybuffer",url:n},o=e.certLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,e,r,n)=>{i(t.data)},onError:(e,r,i,o)=>{s(new Js({type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:_({url:a.url,data:void 0},e)},`"${t}" certificate request failed (${n}). Status: ${e.code} (${e.text})`))},onTimeout:(e,r,i)=>{s(new Js({type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:{url:a.url,data:void 0}},`"${t}" certificate request timed out (${n})`))},onAbort:(t,e,r)=>{s(new Error("aborted"))}};r.load(a,l,c)}))):Promise.resolve()}setMediaKeysServerCertificate(t,e,r){return new Promise(((n,i)=>{t.setServerCertificate(r).then((i=>{this.log(`setServerCertificate ${i?"success":"not supported by CDM"} (${null==r?void 0:r.byteLength}) on "${e}"`),n(t)})).catch((t=>{i(new Js({type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:t,fatal:!0},t.message))}))}))}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then((e=>this.updateKeySession(t,new Uint8Array(e)).catch((t=>{throw new Js({type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)}))))}unpackPlayReadyKeyMessage(t,e){const r=String.fromCharCode.apply(null,new Uint16Array(e.buffer));if(!r.includes("PlayReadyKeyMessage"))return t.setRequestHeader("Content-Type","text/xml; charset=utf-8"),e;const n=(new DOMParser).parseFromString(r,"application/xml"),i=n.querySelectorAll("HttpHeader");if(i.length>0){let e;for(let r=0,n=i.length;r in key message");return tt(atob(l))}setupLicenseXHR(t,e,r,n){const i=this.config.licenseXhrSetup;return i?Promise.resolve().then((()=>{if(!r.decryptdata)throw new Error("Key removed");return i.call(this.hls,t,e,r,n)})).catch((s=>{if(!r.decryptdata)throw s;return t.open("POST",e,!0),i.call(this.hls,t,e,r,n)})).then((r=>{t.readyState||t.open("POST",e,!0);return{xhr:t,licenseChallenge:r||n}})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:n}))}requestLicense(t,e){const r=this.config.keyLoadPolicy.default;return new Promise(((n,i)=>{const s=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${s}`);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return i(new Error("invalid state"));if(4===a.readyState)if(200===a.status){this._requestLicenseFailureCount=0;let e=a.response;this.log(`License received ${e instanceof ArrayBuffer?e.byteLength:e}`);const r=this.config.licenseResponseCallback;if(r)try{e=r.call(this.hls,a,s,t)}catch(t){this.error(t)}n(e)}else{const o=r.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||a.status>=400&&a.status<500)i(new Js({type:x.KEY_SYSTEM_ERROR,details:P.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:s,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${s}). Status: ${a.status} (${a.statusText})`));else{const r=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${r} attempts left`),this.requestLicense(t,e).then(n,i)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=a,this.setupLicenseXHR(a,s,t,e).then((({xhr:e,licenseChallenge:r})=>{t.keySystem==rt.PLAYREADY&&(r=this.unpackPlayReadyKeyMessage(e,r)),e.send(r)}))}))}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const r=e.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},le.clearKeyUriToKeyIdMap();const r=e.length;Qs.CDMCleanupPromise=Promise.all(e.map((t=>this.removeSession(t))).concat(null==t?void 0:t.setMediaKeys(null).catch((t=>{this.log(`Could not clear media keys: ${t}`)})))).then((()=>{r&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)})).catch((t=>{this.log(`Could not close sessions and clear media keys: ${t}`)}))}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(e&&this.config.emeEnabled&&!this.keyFormatPromise){const t=e.reduce(((t,e)=>(-1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t)),[]);this.log(`Selecting key-system from session-keys ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:r}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),t._onmessage&&(e.removeEventListener("message",t._onmessage),t._onmessage=void 0),t._onkeystatuseschange&&(e.removeEventListener("keystatuseschange",t._onkeystatuseschange),t._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),e.remove().catch((t=>{this.log(`Could not remove session: ${t}`)})).then((()=>e.close())).catch((t=>{this.log(`Could not close session: ${t}`)}))}}}Qs.CDMCleanupPromise=void 0;class Js extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}var Zs,ta,ea;!function(t){t.MANIFEST="m",t.AUDIO="a",t.VIDEO="v",t.MUXED="av",t.INIT="i",t.CAPTION="c",t.TIMED_TEXT="tt",t.KEY="k",t.OTHER="o"}(Zs||(Zs={})),function(t){t.DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o"}(ta||(ta={})),function(t){t.OBJECT="CMCD-Object",t.REQUEST="CMCD-Request",t.SESSION="CMCD-Session",t.STATUS="CMCD-Status"}(ea||(ea={}));const ra={[ea.OBJECT]:["br","d","ot","tb"],[ea.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[ea.SESSION]:["cid","pr","sf","sid","st","v"],[ea.STATUS]:["bs","rtp"]};class na{constructor(t,e){this.value=void 0,this.params=void 0,Array.isArray(t)&&(t=t.map((t=>t instanceof na?t:new na(t)))),this.value=t,this.params=e}}class ia{constructor(t){this.description=void 0,this.description=t}}function sa(t,e,r,n){return new Error(`failed to ${t} "${i=e,Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":"object"==typeof i?JSON.stringify(i):String(i)}" as ${r}`,{cause:n});var i}const aa="Bare Item";const oa=/[\x00-\x1f\x7f]+/;function la(t,e,r){return sa("serialize",t,e,r)}function ca(t){if(!1===ArrayBuffer.isView(t))throw la(t,"Byte Sequence");return`:${e=t,btoa(String.fromCharCode(...e))}:`;var e}function ua(t){if(function(t){return t<-999999999999999||99999999999999912)throw la(t,"Decimal");const r=e.toString();return r.includes(".")?r:`${r}.0`}function fa(t){const e=(r=t).description||r.toString().slice(7,-1);var r;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e))throw la(e,"Token");return e}function pa(t){switch(typeof t){case"number":if(!R(t))throw la(t,aa);return Number.isInteger(t)?ua(t):da(t);case"string":return function(t){if(oa.test(t))throw la(t,"String");return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(t);case"symbol":return fa(t);case"boolean":return function(t){if("boolean"!=typeof t)throw la(t,"Boolean");return t?"?1":"?0"}(t);case"object":if(t instanceof Date)return function(t){return`@${ua(t.getTime()/1e3)}`}(t);if(t instanceof Uint8Array)return ca(t);if(t instanceof ia)return fa(t);default:throw la(t,aa)}}function ga(t){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(t))throw la(t,"Key");return t}function ma(t){return null==t?"":Object.entries(t).map((([t,e])=>!0===e?`;${ga(t)}`:`;${ga(t)}=${pa(e)}`)).join("")}function ya(t){return t instanceof na?`${pa(t.value)}${ma(t.params)}`:pa(t)}function va(t,e={whitespace:!0}){if("object"!=typeof t)throw la(t,"Dict");const r=t instanceof Map?t.entries():Object.entries(t),n=null!=e&&e.whitespace?" ":"";return Array.from(r).map((([t,e])=>{e instanceof na==!1&&(e=new na(e));let r=ga(t);var n;return!0===e.value?r+=ma(e.params):(r+="=",Array.isArray(e.value)?r+=`(${(n=e).value.map(ya).join(" ")})${ma(n.params)}`:r+=ya(e)),r})).join(`,${n}`)}const Ea=t=>Math.round(t),ba=t=>100*Ea(t/100),Ta={br:Ea,d:Ea,bl:ba,dl:ba,mtp:ba,nor:(t,e)=>(null!=e&&e.baseUrl&&(t=function(t,e){const r=new URL(t),n=new URL(e);if(r.origin!==n.origin)return t;const i=r.pathname.split("/").slice(1),s=n.pathname.split("/").slice(1,-1);for(;i[0]===s[0];)i.shift(),s.shift();for(;s.length;)s.shift(),i.unshift("..");return i.join("/")}(t,e.baseUrl)),encodeURIComponent(t)),rtp:ba,tb:Ea};function Sa(t,e){const r={};if(null==t||"object"!=typeof t)return r;const n=Object.keys(t).sort(),i=w({},Ta,null==e?void 0:e.formatters),s=null==e?void 0:e.filter;return n.forEach((n=>{if(null!=s&&s(n))return;let a=t[n];const o=i[n];o&&(a=o(a,e)),"v"===n&&1===a||"pr"==n&&1===a||(t=>"number"==typeof t?R(t):null!=t&&""!==t&&!1!==t)(a)&&((t=>"ot"===t||"sf"===t||"st"===t)(n)&&"string"==typeof a&&(a=new ia(a)),r[n]=a)})),r}function Aa(t,e={}){return t?function(t,e){return va(t,e)}(Sa(t,e),w({whitespace:!1},e)):""}function _a(t,e,r){return w(t,function(t,e={}){if(!t)return{};const r=Object.entries(t),n=Object.entries(ra).concat(Object.entries((null==e?void 0:e.customHeaderMap)||{})),i=r.reduce(((t,e)=>{var r;const[i,s]=e,a=(null==(r=n.find((t=>t[1].includes(i))))?void 0:r[0])||ea.REQUEST;return null!=t[a]||(t[a]={}),t[a][i]=s,t}),{});return Object.entries(i).reduce(((t,[r,n])=>(t[r]=Aa(n,e),t)),{})}(e,r))}const ka=/CMCD=[^&#]+/;function La(t,e,r){const n=function(t,e={}){if(!t)return"";const r=Aa(t,e);return`CMCD=${encodeURIComponent(r)}`}(e,r);if(!n)return t;if(ka.test(t))return t.replace(ka,n);const i=t.includes("?")?"&":"?";return`${t}${i}${n}`}function wa(t,e,r,n){t&&Object.keys(e).forEach((i=>{const s=t.filter((t=>t.groupId===i)).map((t=>{const s=w({},t);return s.details=void 0,s.attrs=new j(s.attrs),s.url=s.attrs.URI=Ra(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),s.groupId=s.attrs["GROUP-ID"]=e[i],s.attrs["PATHWAY-ID"]=n,s}));t.push(...s)}))}function Ra(t,e,r,n){const{HOST:i,PARAMS:s,[r]:a}=n;let o;e&&(o=null==a?void 0:a[e],o&&(t=o));const l=new self.URL(t);return i&&!o&&(l.host=i),s&&Object.keys(s).sort().forEach((t=>{t&&l.searchParams.set(t,s[t])})),l.href}const Ca=/^age:\s*[\d.]+\s*$/im;class Da{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=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new H,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const 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||!e)return;const r=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const i=this.xhrSetup;i?Promise.resolve().then((()=>{if(this.loader===r&&!this.stats.aborted)return i(r,e.url)})).catch((t=>{if(this.loader===r&&!this.stats.aborted)return r.open("GET",e.url,!0),i(r,e.url)})).then((()=>{this.loader!==r||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);const n=e.headers,{maxTimeToFirstByteMs:i,maxLoadTimeMs:s}=r.loadPolicy;if(n)for(const e in n)t.setRequestHeader(e,n[e]);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&&R(i)?i:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:r}=this;if(!t||!e)return;const n=e.readyState,i=this.config;if(!r.aborted&&n>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),i.timeout!==i.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),i.timeout=i.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===n)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const n=e.status,s="text"!==e.responseType;if(n>=200&&n<300&&(s&&e.response||null!==e.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);const i=s?e.response:e.responseText,a="arraybuffer"===e.responseType?i.byteLength:i.length;if(r.loaded=r.total=a,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;const o=this.callbacks.onProgress;if(o&&o(r,t,i,e),!this.callbacks)return;const l={url:e.responseURL,data:i,code:n};this.callbacks.onSuccess(l,r,t,e)}else{const s=i.loadPolicy.errorRetry;Dr(s,r.retry,!1,{url:t.url,data:void 0,code:n})?this.retry(s):(N.error(`${n} while loading ${t.url}`),this.callbacks.onError({code:n,text:e.statusText},t,e,r))}}}loadtimeout(){if(!this.config)return;const t=this.config.loadPolicy.timeoutRetry;if(Dr(t,this.stats.retry,!0))this.retry(t);else{var e;N.warn(`timeout while loading ${null==(e=this.context)?void 0:e.url}`);const t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:r}=this;this.retryDelay=Rr(t,r.retry),r.retry++,N.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==e?void 0: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){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&Ca.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}const Ia=/(\d+)-(\d+)\/(\d+)/;class xa{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Pa,this.controller=new self.AbortController,this.stats=new H}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(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(t,e,r){const n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const i=function(t,e){const r={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(w({},t.headers))};t.rangeEnd&&r.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1));return r}(t,this.controller.signal),s=r.onProgress,a="arraybuffer"===t.responseType,o=a?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:c}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,i),self.clearTimeout(this.requestTimeout),e.timeout=l&&R(l)?l:c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),r.onTimeout(n,t,this.response)}),e.timeout),self.fetch(this.request).then((i=>{this.response=this.loader=i;const o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),r.onTimeout(n,t,this.response)}),c-(o-n.loading.start)),!i.ok){const{status:t,statusText:e}=i;throw new Oa(e||"fetch, bad network response",t,i)}return n.loading.first=o,n.total=function(t){const e=t.get("Content-Range");if(e){const t=function(t){const e=Ia.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(R(t))return t}const r=t.get("Content-Length");if(r)return parseInt(r)}(i.headers)||n.total,s&&R(e.highWaterMark)?this.loadProgressively(i,n,t,e.highWaterMark,s):a?i.arrayBuffer():"json"===t.responseType?i.json():i.text()})).then((i=>{const a=this.response;if(!a)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const l=i[o];l&&(n.loaded=n.total=l);const c={url:a.url,data:i,code:a.status};s&&!R(e.highWaterMark)&&s(n,t,i,a),r.onSuccess(c,n,t,a)})).catch((e=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const i=e&&e.code||0,s=e?e.message:null;r.onError({code:i,text:s},t,e?e.details:null,n)}))}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,r,n=0,i){const s=new jn,a=t.body.getReader(),o=()=>a.read().then((a=>{if(a.done)return s.dataLength&&i(e,r,s.flush(),t),Promise.resolve(new ArrayBuffer(0));const l=a.value,c=l.length;return e.loaded+=c,c=n&&i(e,r,s.flush(),t)):i(e,r,l,t),o()})).catch((()=>Promise.reject()));return o()}}function Pa(t,e){return new self.Request(t.url,e)}class Oa extends Error{constructor(t,e,r){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=r}}const Ma=/\s/,Fa={newCue(t,e,r,n){const i=[];let s,a,o,l,c;const u=self.VTTCue||self.TextTrackCue;for(let d=0;d=16?l--:l++;const n=Cs(c.trim()),f=Os(e,r,n);null!=t&&null!=(h=t.cues)&&h.getCueById(f)||(a=new u(e,r,n),a.id=f,a.line=d+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),i.push(a))}return t&&i.length&&(i.sort(((t,e)=>"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line)),i.forEach((e=>Xe(t,e)))),i}},Ba=_(_({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold: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:Da,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=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:t,partCurrent:e,hls:r}=this,{autoLevelEnabled:n,media:i}=r;if(!t||!i)return;const s=performance.now(),a=e?e.stats:t.stats,o=e?e.duration:t.duration,l=s-a.loading.start,c=r.minAutoLevel;if(a.aborted||a.loaded&&a.loaded===a.total||t.level<=c)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!n||i.paused||!i.playbackRate||!i.readyState)return;const u=r.mainForwardBufferInfo;if(null===u)return;const h=this.bwEstimator.getEstimateTTFB(),d=Math.abs(i.playbackRate);if(l<=Math.max(h,o/(2*d)*1e3))return;const f=u.len/d,p=a.loading.first?a.loading.first-a.loading.start:-1,g=a.loaded&&p>-1,m=this.getBwEstimate(),y=r.levels,v=y[t.level],E=a.total||Math.max(a.loaded,Math.round(o*v.averageBitrate/8));let b=g?l-p:l;b<1&&g&&(b=Math.min(l,8*a.loaded/m));const T=g?1e3*a.loaded/b:0,S=T?(E-a.loaded)/T:8*E/m+h/1e3;if(S<=f)return;const A=T?8*T:m;let _,k=Number.POSITIVE_INFINITY;for(_=t.level-1;_>c;_--){const t=y[_].maxBitrate;if(k=this.getTimeToLoadFrag(h/1e3,A,o*t,!y[_].details),k=S)return;if(k>10*o)return;r.nextLoadLevel=r.nextAutoLevel=_,g?this.bwEstimator.sample(l-Math.min(h,p),a.loaded):this.bwEstimator.sampleTTFB(l);const L=y[_].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>L&&this.resetEstimator(L),this.clearTimer(),N.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;\n Time to underbuffer: ${f.toFixed(3)} s\n Estimated load time for current fragment: ${S.toFixed(3)} s\n Estimated load time for down switch fragment: ${k.toFixed(3)} s\n TTFB estimate: ${0|p} ms\n Current BW estimate: ${R(m)?0|m:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${_} @ ${0|L} bps`),r.trigger(I.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:a})},this.hls=t,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(t){t&&(N.log(`setting initial bwe to ${t}`),this.hls.config.abrEwmaDefaultEstimate=t),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const t=this.hls.config;return new Hr(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate)}registerListeners(){const{hls:t}=this;t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.FRAG_LOADING,this.onFragLoading,this),t.on(I.FRAG_LOADED,this.onFragLoaded,this),t.on(I.FRAG_BUFFERED,this.onFragBuffered,this),t.on(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(I.LEVEL_LOADED,this.onLevelLoaded,this),t.on(I.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(I.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.on(I.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t&&(t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.FRAG_LOADING,this.onFragLoading,this),t.off(I.FRAG_LOADED,this.onFragLoaded,this),t.off(I.FRAG_BUFFERED,this.onFragBuffered,this),t.off(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(I.LEVEL_LOADED,this.onLevelLoaded,this),t.off(I.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(I.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.off(I.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(t,e){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(t,e){const r=e.frag;if(!this.ignoreFragment(r)){var n;if(!r.bitrateTest)this.fragCurrent=r,this.partCurrent=null!=(n=e.part)?n:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(t,e){this.clearTimer()}onError(t,e){if(!e.fatal)switch(e.details){case P.BUFFER_ADD_CODEC_ERROR:case P.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case P.FRAG_LOAD_TIMEOUT:{const t=e.frag,{fragCurrent:r,partCurrent:n}=this;if(t&&r&&t.sn===r.sn&&t.level===r.level){const e=performance.now(),r=n?n.stats:t.stats,i=e-r.loading.start,s=r.loading.first?r.loading.first-r.loading.start:-1;if(r.loaded&&s>-1){const t=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(i-Math.min(t,s),r.loaded)}else this.bwEstimator.sampleTTFB(i)}break}}}getTimeToLoadFrag(t,e,r,n){return t+r/e+(n?this.lastLevelLoadSec:0)}onLevelLoaded(t,e){const r=this.hls.config,{loading:n}=e.stats,i=n.end-n.start;R(i)&&(this.lastLevelLoadSec=i/1e3),e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(t,{frag:e,part:r}){const n=r?r.stats:e.stats;if(e.type===Ke&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),e.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const t=r?r.duration:e.duration,i=this.hls.levels[e.level],s=(i.loaded?i.loaded.bytes:0)+n.loaded,a=(i.loaded?i.loaded.duration:0)+t;i.loaded={bytes:s,duration:a},i.realBitrate=Math.round(8*s/a)}if(e.bitrateTest){const t={stats:n,frag:e,part:r,id:e.type};this.onFragBuffered(I.FRAG_BUFFERED,t),e.bitrateTest=!1}else this.lastLoadedFragLevel=e.level}}onFragBuffered(t,e){const{frag:r,part:n}=e,i=null!=n&&n.stats.loaded?n.stats:r.stats;if(i.aborted)return;if(this.ignoreFragment(r))return;const s=i.parsing.end-i.loading.start-Math.min(i.loading.first-i.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(s,i.loaded),i.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==Ke||"initSegment"===t.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:t,minAutoLevel:e}=this.hls,r=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,i=this.findBestLevel(r,e,t,0,n,1,1);if(i>-1)return i;const s=this.hls.firstLevel,a=Math.min(Math.max(s,e),t);return N.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${s} clamped to ${a}`),a}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const t=this.forcedAutoLevel,e=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===t||e&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return t;const n=e&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==t){const e=this.hls.levels;if(e.length>Math.max(t,n)&&e[t].loadError<=e[n].loadError)return t}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:r}=this,{maxAutoLevel:n,config:i,minAutoLevel:s}=r,a=e?e.duration:t?t.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let c=i.abrBandWidthFactor,u=i.abrBandWidthUpFactor;if(l){const t=this.findBestLevel(o,s,n,l,0,c,u);if(t>=0)return t}let h=a?Math.min(a,i.maxStarvationDelay):i.maxStarvationDelay;if(!l){const t=this.bitrateTestDelay;if(t){h=(a?Math.min(a,i.maxLoadingDelay):i.maxLoadingDelay)-t,N.info(`[abr] bitrate test took ${Math.round(1e3*t)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),c=u=1}}const d=this.findBestLevel(o,s,n,l,h,c,u);if(N.info(`[abr] ${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${d}`),d>-1)return d;const f=r.levels[s],p=r.levels[r.loadLevel];return(null==f?void 0:f.bitrate)<(null==p?void 0:p.bitrate)?s:r.loadLevel}getStarvationDelay(){const t=this.hls,e=t.media;if(!e)return 1/0;const r=e&&0!==e.playbackRate?Math.abs(e.playbackRate):1,n=t.mainForwardBufferInfo;return(n?n.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(t,e,r,n,i,s,a){var o;const l=n+i,c=this.lastLoadedFragLevel,u=-1===c?this.hls.firstLevel:c,{fragCurrent:h,partCurrent:d}=this,{levels:f,allAudioTracks:p,loadLevel:g,config:m}=this.hls;if(1===f.length)return 0;const y=f[u],v=!(null==y||null==(o=y.details)||!o.live),E=-1===g||-1===c;let b,T="SDR",S=(null==y?void 0:y.frameRate)||0;const{audioPreference:A,videoPreference:_}=m,k=this.audioTracksByGroup||(this.audioTracksByGroup=function(t){return t.reduce(((t,e)=>{let r=t.groups[e.groupId];r||(r=t.groups[e.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(e);const n=e.channels||"2";return r.channels[n]=(r.channels[n]||0)+1,r.hasDefault=r.hasDefault||e.default,r.hasAutoSelect=r.hasAutoSelect||e.autoselect,r.hasDefault&&(t.hasDefaultAudio=!0),r.hasAutoSelect&&(t.hasAutoSelectAudio=!0),t}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(p));if(E){if(-1!==this.firstSelection)return this.firstSelection;const n=this.codecTiers||(this.codecTiers=function(t,e,r,n){return t.slice(r,n+1).reduce(((t,r)=>{if(!r.codecSet)return t;const n=r.audioGroups;let i=t[r.codecSet];i||(t[r.codecSet]=i={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),i.minBitrate=Math.min(i.minBitrate,r.bitrate);const s=Math.min(r.height,r.width);return i.minHeight=Math.min(i.minHeight,s),i.minFramerate=Math.min(i.minFramerate,r.frameRate),i.maxScore=Math.max(i.maxScore,r.score),i.fragmentError+=r.fragmentError,i.videoRanges[r.videoRange]=(i.videoRanges[r.videoRange]||0)+1,n&&n.forEach((t=>{if(!t)return;const r=e.groups[t];r&&(i.hasDefaultAudio=i.hasDefaultAudio||e.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(r.channels).forEach((t=>{i.channels[t]=(i.channels[t]||0)+r.channels[t]})))})),t}),{})}(f,k,e,r)),i=function(t,e,r,n,i){const s=Object.keys(t),a=null==n?void 0:n.channels,o=null==n?void 0:n.audioCodec,l=a&&2===parseInt(a);let c=!0,u=!1,h=1/0,d=1/0,f=1/0,p=0,g=[];const{preferHDR:m,allowedVideoRanges:y}=zr(e,i);for(let e=s.length;e--;){const r=t[s[e]];c=r.channels[2]>0,h=Math.min(h,r.minHeight),d=Math.min(d,r.minFramerate),f=Math.min(f,r.minBitrate);const n=y.filter((t=>r.videoRanges[t]>0));n.length>0&&(u=!0,g=n)}h=R(h)?h:0,d=R(d)?d:0;const v=Math.max(1080,h),E=Math.max(30,d);return f=R(f)?f:r,r=Math.max(f,r),u||(e=void 0,g=[]),{codecSet:s.reduce(((e,n)=>{const i=t[n];if(n===e)return e;if(i.minBitrate>r)return Xr(n,`min bitrate of ${i.minBitrate} > current estimate of ${r}`),e;if(!i.hasDefaultAudio)return Xr(n,"no renditions with default or auto-select sound found"),e;if(o&&n.indexOf(o.substring(0,4))%5!=0)return Xr(n,`audio codec preference "${o}" not found`),e;if(a&&!l){if(!i.channels[a])return Xr(n,`no renditions with ${a} channel sound found (channels options: ${Object.keys(i.channels)})`),e}else if((!o||l)&&c&&0===i.channels[2])return Xr(n,"no renditions with stereo sound found"),e;return i.minHeight>v?(Xr(n,`min resolution of ${i.minHeight} > maximum of ${v}`),e):i.minFramerate>E?(Xr(n,`min framerate of ${i.minFramerate} > maximum of ${E}`),e):g.some((t=>i.videoRanges[t]>0))?i.maxScore=Te(e)||i.fragmentError>t[e].fragmentError)?e:(p=i.maxScore,n):(Xr(n,`no variants with VIDEO-RANGE of ${JSON.stringify(g)} found`),e)}),void 0),videoRanges:g,preferHDR:m,minFramerate:d,minBitrate:f}}(n,T,t,A,_),{codecSet:s,videoRanges:a,minFramerate:o,minBitrate:l,preferHDR:c}=i;b=s,T=c?a[a.length-1]:a[0],S=o,t=Math.max(t,l),N.log(`[abr] picked start tier ${JSON.stringify(i)}`)}else b=null==y?void 0:y.codecSet,T=null==y?void 0:y.videoRange;const L=d?d.duration:h?h.duration:0,w=this.bwEstimator.getEstimateTTFB()/1e3,C=[];for(let o=r;o>=e;o--){var D;const e=f[o],h=o>u;if(!e)continue;if(m.useMediaCapabilities&&!e.supportedResult&&!e.supportedPromise){const r=navigator.mediaCapabilities;"function"==typeof(null==r?void 0:r.decodingInfo)&&Yr(e,k,T,S,t,A)?(e.supportedPromise=qr(e,k,r),e.supportedPromise.then((t=>{if(!this.hls)return;e.supportedResult=t;const r=this.hls.levels,n=r.indexOf(e);t.error?N.warn(`[abr] MediaCapabilities decodingInfo error: "${t.error}" for level ${n} ${JSON.stringify(t)}`):t.supported||(N.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${n} ${JSON.stringify(t)}`),n>-1&&r.length>1&&(N.log(`[abr] Removing unsupported level ${n}`),this.hls.removeLevel(n)))}))):e.supportedResult=Vr}if(b&&e.codecSet!==b||T&&e.videoRange!==T||h&&S>e.frameRate||!h&&S>0&&S=2*L&&0===i?f[o].averageBitrate:f[o].maxBitrate,P=this.getTimeToLoadFrag(w,I,x*_,void 0===p);if(I>=x&&(o===c||0===e.loadError&&0===e.fragmentError)&&(P<=w||!R(P)||v&&!this.bitrateTestDelay||P${o} adjustedbw(${Math.round(I)})-bitrate=${Math.round(I-x)} ttfb:${w.toFixed(1)} avgDuration:${_.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${P.toFixed(1)} firstSelection:${E} codecSet:${b} videoRange:${T} hls.loadLevel:${g}`)),E&&(this.firstSelection=o),o}}return-1}set nextAutoLevel(t){const{maxAutoLevel:e,minAutoLevel:r}=this.hls,n=Math.min(Math.max(t,r),e);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}},bufferController:class{constructor(t){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=t=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=t=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:t,mediaSource:e}=this;this.log("Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(I.MEDIA_ATTACHED,{media:t,mediaSource:e})),e&&e.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:t,_objectUrl:e}=this;t!==e&&N.error(`Media element src was set while attaching MediaSource (${e} > ${t})`)},this.hls=t;const e="[buffer-controller]";var r;this.appendSource=(r=ge(t.config.preferManagedMediaSource),"undefined"!=typeof self&&r===self.ManagedMediaSource),this.log=N.log.bind(N,e),this.warn=N.warn.bind(N,e),this.error=N.error.bind(N,e),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){const{hls:t}=this;t.on(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.BUFFER_RESET,this.onBufferReset,this),t.on(I.BUFFER_APPENDING,this.onBufferAppending,this),t.on(I.BUFFER_CODECS,this.onBufferCodecs,this),t.on(I.BUFFER_EOS,this.onBufferEos,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(I.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(I.FRAG_PARSED,this.onFragParsed,this),t.on(I.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.BUFFER_RESET,this.onBufferReset,this),t.off(I.BUFFER_APPENDING,this.onBufferAppending,this),t.off(I.BUFFER_CODECS,this.onBufferCodecs,this),t.off(I.BUFFER_EOS,this.onBufferEos,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(I.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(I.FRAG_PARSED,this.onFragParsed,this),t.off(I.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Ji(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let r=2;(e.audio&&!e.video||!e.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const r=this.media=e.media,n=ge(this.appendSource);if(r&&n){var i;const t=this.mediaSource=new n;this.log(`created media source: ${null==(i=t.constructor)?void 0:i.name}`),t.addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.addEventListener("startstreaming",this._onStartStreaming),t.addEventListener("endstreaming",this._onEndStreaming));const e=this._objectUrl=self.URL.createObjectURL(t);if(this.appendSource)try{r.removeAttribute("src");const n=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||n&&t instanceof n,ts(r),function(t,e){const r=self.document.createElement("source");r.type="video/mp4",r.src=e,t.appendChild(r)}(r,e),r.load()}catch(t){r.src=e}else r.src=e;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:r}=this;if(e){if(this.log("media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){this.warn(`onMediaDetaching: ${t.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.removeEventListener("startstreaming",this._onStartStreaming),e.removeEventListener("endstreaming",this._onEndStreaming)),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(t.removeAttribute("src"),this.appendSource&&ts(t),t.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(I.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach((t=>{this.resetBuffer(t)})),this._initSourceBuffer()}resetBuffer(t){const e=this.sourceBuffer[t];try{var r;if(e)this.removeBufferListeners(t),this.sourceBuffer[t]=void 0,null!=(r=this.mediaSource)&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(e)}catch(e){this.warn(`onBufferReset ${t}`,e)}}onBufferCodecs(t,e){const r=this.getSourceBufferTypes().length,n=Object.keys(e);if(n.forEach((t=>{if(r){const r=this.tracks[t];if(r&&"function"==typeof r.buffer.changeType){var n;const{id:i,codec:s,levelCodec:a,container:o,metadata:l}=e[t],c=ke(r.codec,r.levelCodec),u=null==c?void 0:c.replace(Zi,"$1");let h=ke(s,a);const d=null==(n=h)?void 0:n.replace(Zi,"$1");if(h&&u!==d){"audio"===t.slice(0,5)&&(h=_e(h,this.appendSource));const e=`${o};codecs=${h}`;this.appendChangeType(t,e),this.log(`switching codec ${c} to ${h}`),this.tracks[t]={buffer:r.buffer,codec:s,container:o,levelCodec:a,metadata:l,id:i}}}}else this.pendingTracks[t]=e[t]})),r)return;const i=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==i&&(this.log(`${i} bufferCodec event(s) expected ${n.join(",")}`),this.bufferCodecEventsExpected=i),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}appendChangeType(t,e){const{operationQueue:r}=this,n={execute:()=>{const n=this.sourceBuffer[t];n&&(this.log(`changing ${t} sourceBuffer type to ${e}`),n.changeType(e)),r.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn(`Failed to change ${t} SourceBuffer type`,e)}};r.append(n,t,!!this.pendingTracks[t])}onBufferAppending(t,e){const{hls:r,operationQueue:n,tracks:i}=this,{data:s,type:a,frag:o,part:l,chunkMeta:c}=e,u=c.buffering[a],h=self.performance.now();u.start=h;const d=o.stats.buffering,f=l?l.stats.buffering:null;0===d.start&&(d.start=h),f&&0===f.start&&(f.start=h);const p=i.audio;let g=!1;"audio"===a&&"audio/mpeg"===(null==p?void 0:p.container)&&(g=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);const m=o.start,y={execute:()=>{if(u.executeStart=self.performance.now(),g){const t=this.sourceBuffer[a];if(t){const e=m-t.timestampOffset;Math.abs(e)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${m} (delta: ${e}) sn: ${o.sn})`),t.timestampOffset=m)}}this.appendExecutor(s,a)},onStart:()=>{},onComplete:()=>{const t=self.performance.now();u.executeEnd=u.end=t,0===d.first&&(d.first=t),f&&0===f.first&&(f.first=t);const{sourceBuffer:e}=this,r={};for(const t in e)r[t]=hn.getBuffered(e[t]);this.appendErrors[a]=0,"audio"===a||"video"===a?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(I.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:c,parent:o.type,timeRanges:r})},onError:t=>{const e={type:x.MEDIA_ERROR,parent:o.type,details:P.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:o,part:l,chunkMeta:c,error:t,err:t,fatal:!1};if(t.code===DOMException.QUOTA_EXCEEDED_ERR)e.details=P.BUFFER_FULL_ERROR;else{const t=++this.appendErrors[a];e.details=P.BUFFER_APPEND_ERROR,this.warn(`Failed ${t}/${r.config.appendErrorMaxRetry} times to append segment in "${a}" sourceBuffer`),t>=r.config.appendErrorMaxRetry&&(e.fatal=!0)}r.trigger(I.ERROR,e)}};n.append(y,a,!!this.pendingTracks[a])}onBufferFlushing(t,e){const{operationQueue:r}=this,n=t=>({execute:this.removeExecutor.bind(this,t,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(I.BUFFER_FLUSHED,{type:t})},onError:e=>{this.warn(`Failed to remove from ${t} SourceBuffer`,e)}});e.type?r.append(n(e.type),e.type):this.getSourceBufferTypes().forEach((t=>{r.append(n(t),t)}))}onFragParsed(t,e){const{frag:r,part:n}=e,i=[],s=n?n.elementaryStreams:r.elementaryStreams;s[Y]?i.push("audiovideo"):(s[V]&&i.push("audio"),s[W]&&i.push("video"));0===i.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers((()=>{const t=self.performance.now();r.stats.buffering.end=t,n&&(n.stats.buffering.end=t);const e=n?n.stats:r.stats;this.hls.trigger(I.FRAG_BUFFERED,{frag:r,part:n,stats:e,id:r.type})}),i)}onFragChanged(t,e){this.trimBuffers()}onBufferEos(t,e){this.getSourceBufferTypes().reduce(((t,r)=>{const n=this.sourceBuffer[r];return!n||e.type&&e.type!==r||(n.ending=!0,n.ended||(n.ended=!0,this.log(`${r} sourceBuffer now EOS`))),t&&!(n&&!n.ended)}),!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers((()=>{this.getSourceBufferTypes().forEach((t=>{const e=this.sourceBuffer[t];e&&(e.ending=!1)}));const{mediaSource:t}=this;t&&"open"===t.readyState?(this.log("Calling mediaSource.endOfStream()"),t.endOfStream()):t&&this.log(`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())}trimBuffers(){const{hls:t,details:e,media:r}=this;if(!r||null===e)return;if(!this.getSourceBufferTypes().length)return;const n=t.config,i=r.currentTime,s=e.levelTargetDuration,a=e.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(R(a)&&a>0){const t=Math.max(a,s),e=Math.floor(i/s)*s-t;this.flushBackBuffer(i,s,e)}if(R(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){const t=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),e=Math.max(t,s),r=Math.floor(i/s)*s+e;this.flushFrontBuffer(i,s,r)}}flushBackBuffer(t,e,r){const{details:n,sourceBuffer:i}=this;this.getSourceBufferTypes().forEach((s=>{const a=i[s];if(a){const i=hn.getBuffered(a);if(i.length>0&&r>i.start(0)){if(this.hls.trigger(I.BACK_BUFFER_REACHED,{bufferEnd:r}),null!=n&&n.live)this.hls.trigger(I.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(a.ended&&i.end(i.length-1)-t<2*e)return void this.log(`Cannot flush ${s} back buffer while SourceBuffer is in ended state`);this.hls.trigger(I.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))}flushFrontBuffer(t,e,r){const{sourceBuffer:n}=this;this.getSourceBufferTypes().forEach((i=>{const s=n[i];if(s){const n=hn.getBuffered(s),a=n.length;if(a<2)return;const o=n.start(a-1),l=n.end(a-1);if(r>o||t>=o&&t<=l)return;if(s.ended&&t-l<2*e)return void this.log(`Cannot flush ${i} front buffer while SourceBuffer is in ended state`);this.hls.trigger(I.BUFFER_FLUSHING,{startOffset:o,endOffset:1/0,type:i})}}))}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:t,hls:e,media:r,mediaSource:n}=this,i=t.fragments[0].start+t.totalduration,s=r.duration,a=R(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(n.duration=1/0,this.updateSeekableRange(t)):(i>a&&i>s||!R(s))&&(this.log(`Updating Media Source duration to ${i.toFixed(3)}`),n.duration=i)}updateSeekableRange(t){const e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){const n=Math.max(0,r[0].start),i=Math.max(n,n+t.totalduration);this.log(`Media Source duration is set to ${e.duration}. Setting seekable range to ${n}-${i}.`),e.setLiveSeekableRange(n,i)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:r}=this,n=Object.keys(r).length;if(n&&(!t||2===n||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};const t=this.getSourceBufferTypes();if(t.length)this.hls.trigger(I.BUFFER_CREATED,{tracks:this.tracks}),t.forEach((t=>{e.executeNext(t)}));else{const t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(I.ERROR,{type:x.MEDIA_ERROR,details:P.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const i in t)if(!e[i]){var n;const s=t[i];if(!s)throw Error(`source buffer exists for track ${i}, however track does not`);let a=-1===(null==(n=s.levelCodec)?void 0:n.indexOf(","))?s.levelCodec:s.codec;a&&"audio"===i.slice(0,5)&&(a=_e(a,this.appendSource));const o=`${s.container};codecs=${a}`;this.log(`creating sourceBuffer(${o})`);try{const t=e[i]=r.addSourceBuffer(o),n=i;this.addBufferListener(n,"updatestart",this._onSBUpdateStart),this.addBufferListener(n,"updateend",this._onSBUpdateEnd),this.addBufferListener(n,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(n,"bufferedchange",((t,e)=>{const r=e.removedRanges;null!=r&&r.length&&this.hls.trigger(I.BUFFER_FLUSHED,{type:i})})),this.tracks[i]={buffer:t,codec:a,container:s.container,levelCodec:s.levelCodec,metadata:s.metadata,id:s.id}}catch(t){this.error(`error while trying to add sourceBuffer: ${t.message}`),this.hls.trigger(I.ERROR,{type:x.MEDIA_ERROR,details:P.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,sourceBufferName:i,mimeType:o})}}}get mediaSrc(){var t,e;const r=(null==(t=this.media)||null==(e=t.querySelector)?void 0:e.call(t,"source"))||this.media;return null==r?void 0:r.src}_onSBUpdateStart(t){const{operationQueue:e}=this;e.current(t).onStart()}_onSBUpdateEnd(t){var e;if("closed"===(null==(e=this.mediaSource)?void 0:e.readyState))return void this.resetBuffer(t);const{operationQueue:r}=this;r.current(t).onComplete(),r.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){var r;const n=new Error(`${t} SourceBuffer error. MediaSource readyState: ${null==(r=this.mediaSource)?void 0:r.readyState}`);this.error(`${n}`,e),this.hls.trigger(I.ERROR,{type:x.MEDIA_ERROR,details:P.BUFFER_APPENDING_ERROR,sourceBufferName:t,error:n,fatal:!1});const i=this.operationQueue.current(t);i&&i.onError(n)}removeExecutor(t,e,r){const{media:n,mediaSource:i,operationQueue:s,sourceBuffer:a}=this,o=a[t];if(!n||!i||!o)return this.warn(`Attempting to remove from the ${t} SourceBuffer, but it does not exist`),void s.shiftAndExecuteNext(t);const l=R(n.duration)?n.duration:1/0,c=R(i.duration)?i.duration:1/0,u=Math.max(0,e),h=Math.min(r,l,c);h>u&&(!o.ending||o.ended)?(o.ended=!1,this.log(`Removing [${u},${h}] from the ${t} SourceBuffer`),o.remove(u,h)):s.shiftAndExecuteNext(t)}appendExecutor(t,e){const r=this.sourceBuffer[e];if(r)r.ended=!1,r.appendBuffer(t);else if(!this.pendingTracks[e])throw new Error(`Attempting to append to the ${e} SourceBuffer, but it does not exist`)}blockBuffers(t,e=this.getSourceBufferTypes()){if(!e.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);const{operationQueue:r}=this,n=e.map((t=>r.appendBlocker(t)));Promise.all(n).then((()=>{t(),e.forEach((t=>{const e=this.sourceBuffer[t];null!=e&&e.updating||r.shiftAndExecuteNext(t)}))}))}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,r){const n=this.sourceBuffer[t];if(!n)return;const i=r.bind(this,t);this.listeners[t].push({event:e,listener:i}),n.addEventListener(e,i)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach((t=>{e.removeEventListener(t.event,t.listener)}))}},capLevelController:zs,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=N.log.bind(N,"[info]:"),this.warn=N.warn.bind(N,"[warning]:"),this.error=N.error.bind(N,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(I.ERROR,this.onError,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(I.ERROR,this.onError,this),t.off(I.ERROR,this.onErrorOut,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){}stopLoad(){this.playlistError=0}getVariantLevelIndex(t){return(null==t?void 0:t.type)===Ke?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var r,n;if(e.fatal)return;const i=this.hls,s=e.context;switch(e.details){case P.FRAG_LOAD_ERROR:case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_ERROR:case P.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case P.FRAG_PARSING_ERROR:if(null!=(r=e.frag)&&r.gap)return void(e.errorAction={action:Mr,flags:Ur});case P.FRAG_GAP:case P.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=Fr);case P.LEVEL_EMPTY_ERROR:case P.LEVEL_PARSING_ERROR:{var a,o;const t=e.parent===Ke?e.level:i.loadLevel;e.details===P.LEVEL_EMPTY_ERROR&&null!=(a=e.context)&&null!=(o=a.levelDetails)&&o.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,t):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t))}return;case P.LEVEL_LOAD_ERROR:case P.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==s?void 0:s.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,s.level)));case P.AUDIO_TRACK_LOAD_ERROR:case P.AUDIO_TRACK_LOAD_TIMEOUT:case P.SUBTITLE_LOAD_ERROR:case P.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){const t=i.levels[i.loadLevel];if(t&&(s.type===je&&t.hasAudioGroup(s.groupId)||s.type===Ge&&t.hasSubtitleGroup(s.groupId)))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,i.loadLevel),e.errorAction.action=Fr,void(e.errorAction.flags=$r)}return;case P.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const t=i.levels[i.loadLevel],r=null==t?void 0:t.attrs["HDCP-LEVEL"];r?e.errorAction={action:Fr,flags:jr,hdcpLevel:r}:this.keySystemError(e)}return;case P.BUFFER_ADD_CODEC_ERROR:case P.REMUX_ALLOC_ERROR:case P.BUFFER_APPEND_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(n=e.level)?n:i.loadLevel));case P.INTERNAL_EXCEPTION:case P.BUFFER_APPENDING_ERROR:case P.BUFFER_FULL_ERROR:case P.LEVEL_SWITCH_ERROR:case P.BUFFER_STALLED_ERROR:case P.BUFFER_SEEK_OVER_HOLE:case P.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:Mr,flags:Ur})}e.type===x.KEY_SYSTEM_ERROR&&this.keySystemError(e)}keySystemError(t){const e=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e)}getPlaylistRetryOrSwitchAction(t,e){const r=wr(this.hls.config.playlistLoadPolicy,t),n=this.playlistError++;if(Dr(r,n,Lr(t),t.response))return{action:Nr,flags:Ur,retryConfig:r,retryCount:n};const i=this.getLevelSwitchAction(t,e);return r&&(i.retryConfig=r,i.retryCount=n),i}getFragRetryOrSwitchAction(t){const e=this.hls,r=this.getVariantLevelIndex(t.frag),n=e.levels[r],{fragLoadPolicy:i,keyLoadPolicy:s}=e.config,a=wr(t.details.startsWith("key")?s:i,t),o=e.levels.reduce(((t,e)=>t+e.fragmentError),0);if(n){t.details!==P.FRAG_GAP&&n.fragmentError++;if(Dr(a,o,Lr(t),t.response))return{action:Nr,flags:Ur,retryConfig:a,retryCount:o}}const l=this.getLevelSwitchAction(t,r);return a&&(l.retryConfig=a,l.retryCount=o),l}getLevelSwitchAction(t,e){const r=this.hls;null==e&&(e=r.loadLevel);const n=this.hls.levels[e];if(n){var i,s;const e=t.details;n.loadError++,e===P.BUFFER_APPEND_ERROR&&n.fragmentError++;let l=-1;const{levels:c,loadLevel:u,minAutoLevel:h,maxAutoLevel:d}=r;r.autoLevelEnabled||(r.loadLevel=-1);const f=null==(i=t.frag)?void 0:i.type,p=(f===He&&e===P.FRAG_PARSING_ERROR||"audio"===t.sourceBufferName&&(e===P.BUFFER_ADD_CODEC_ERROR||e===P.BUFFER_APPEND_ERROR))&&c.some((({audioCodec:t})=>n.audioCodec!==t)),g="video"===t.sourceBufferName&&(e===P.BUFFER_ADD_CODEC_ERROR||e===P.BUFFER_APPEND_ERROR)&&c.some((({codecSet:t,audioCodec:e})=>n.codecSet!==t&&n.audioCodec===e)),{type:m,groupId:y}=null!=(s=t.context)?s:{};for(let r=c.length;r--;){const i=(r+u)%c.length;if(i!==u&&i>=h&&i<=d&&0===c[i].loadError){var a,o;const r=c[i];if(e===P.FRAG_GAP&&f===Ke&&t.frag){const e=c[i].details;if(e){const r=xr(t.frag,e.fragments,t.frag.start);if(null!=r&&r.gap)continue}}else{if(m===je&&r.hasAudioGroup(y)||m===Ge&&r.hasSubtitleGroup(y))continue;if(f===He&&null!=(a=n.audioGroups)&&a.some((t=>r.hasAudioGroup(t)))||f===Ve&&null!=(o=n.subtitleGroups)&&o.some((t=>r.hasSubtitleGroup(t)))||p&&n.audioCodec===r.audioCodec||!p&&n.audioCodec!==r.audioCodec||g&&n.codecSet===r.codecSet)continue}l=i;break}}if(l>-1&&r.loadLevel!==l)return t.levelRetry=!0,this.playlistError=0,{action:Fr,flags:Ur,nextAutoLevel:l}}return{action:Fr,flags:$r}}onErrorOut(t,e){var r;switch(null==(r=e.errorAction)?void 0:r.action){case Mr:break;case Fr:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===P.FRAG_GAP?/MediaSource readyState: ended/.test(e.error.message)&&(this.warn(`MediaSource ended after "${e.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):e.fatal=!0}e.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(t){const e=this.hls,r=t.errorAction;if(!r)return;const{flags:n,hdcpLevel:i,nextAutoLevel:s}=r;switch(n){case Ur:this.switchLevel(t,s);break;case jr:i&&(e.maxHdcpLevel=cr[cr.indexOf(i)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`)}r.resolved||this.switchLevel(t,s)}switchLevel(t,e){void 0!==e&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}},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(I.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(I.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const r=this.hls.config;if(r.capLevelOnFPSDrop){const t=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=t,t&&"function"==typeof t.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,r){const n=performance.now();if(e){if(this.lastTime){const t=n-this.lastTime,i=r-this.lastDroppedFrames,s=e-this.lastDecodedFrames,a=1e3*i/t,o=this.hls;if(o.trigger(I.FPS_DROP,{currentDropped:i,currentDecoded:s,totalDroppedFrames:r}),a>0&&i>o.config.fpsDroppedMonitoringThreshold*s){let t=o.currentLevel;N.warn("drop FPS ratio greater than max allowed value for currentLevel: "+t),t>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=t)&&(t-=1,o.trigger(I.FPS_DROP_LEVEL_CAPPING,{level:t,droppedLevel:o.currentLevel}),o.autoLevelCapping=t,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=r,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:gt,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!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 $n{constructor(t,e,r){super(t,e,r,"[subtitle-stream-controller]",Ve),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){const{hls:t}=this;t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.LEVEL_LOADED,this.onLevelLoaded,this),t.on(I.ERROR,this.onError,this),t.on(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(I.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(I.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(I.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.LEVEL_LOADED,this.onLevelLoaded,this),t.off(I.ERROR,this.onError,this),t.off(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(I.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(I.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(I.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=Cn,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,e){const{frag:r,success:n}=e;if(this.fragPrevious=r,this.state=Cn,!n)return;const i=this.tracksBuffered[this.currentTrackId];if(!i)return;let s;const a=r.start;for(let t=0;t=i[t].start&&a<=i[t].end){s=i[t];break}const o=r.start+r.duration;s?s.end=o:(s={start:a,end:o},i.push(s)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}onBufferFlushing(t,e){const{startOffset:r,endOffset:n}=e;if(0===r&&n!==Number.POSITIVE_INFINITY){const t=n-1;if(t<=0)return;e.endOffsetSubtitles=Math.max(0,t),this.tracksBuffered.forEach((e=>{for(let r=0;rnew mr(t))):(this.tracksBuffered=[],this.levels=e.map((t=>{const e=new mr(t);return this.tracksBuffered[e.id]=[],e})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Ve),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){var r;if(this.currentTrackId=e.id,null==(r=this.levels)||!r.length||-1===this.currentTrackId)return void this.clearInterval();const n=this.levels[this.currentTrackId];null!=n&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.setInterval(500)}onSubtitleTrackLoaded(t,e){var r;const{currentTrackId:n,levels:i}=this,{details:s,id:a}=e;if(!i)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=i[a];if(a>=i.length||!o)return;this.log(`Subtitle track ${a} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""},duration:${s.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(s.live||null!=(r=o.details)&&r.live){const t=this.mainDetails;if(s.deltaUpdateFailed||!t)return;const e=t.fragments[0];var c;if(o.details)l=this.alignPlaylists(s,o.details,null==(c=this.levelLastLoaded)?void 0:c.details),0===l&&e&&(l=e.start,Sr(s,l));else s.hasProgramDateTime&&t.hasProgramDateTime?(yn(s,t),l=s.fragments[0].start):e&&(l=e.start,Sr(s,l))}if(o.details=s,this.levelLastLoaded=o,a===n&&(this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(this.mainDetails||s,l),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===Cn)){xr(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0)}}_handleFragmentLoadComplete(t){const{frag:e,payload:r}=t,n=e.decryptdata,i=this.hls;if(!this.fragContextChanged(e)&&r&&r.byteLength>0&&null!=n&&n.key&&n.iv&&"AES-128"===n.method){const t=performance.now();this.decrypter.decrypt(new Uint8Array(r),n.key.buffer,n.iv.buffer).catch((t=>{throw i.trigger(I.ERROR,{type:x.MEDIA_ERROR,details:P.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((r=>{const n=performance.now();i.trigger(I.FRAG_DECRYPTED,{frag:e,payload:r,stats:{tstart:t,tdecrypt:n}})})).catch((t=>{this.warn(`${t.name}: ${t.message}`),this.state=Cn}))}}doTick(){if(this.media){if(this.state===Cn){const{currentTrackId:t,levels:e}=this,r=null==e?void 0:e[t];if(!r||!e.length||!r.details)return;const{config:n}=this,i=this.getLoadPosition(),s=hn.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],i,n.maxBufferHole),{end:a,len:o}=s,l=this.getFwdBufferInfo(this.media,Ke),c=r.details;if(o>this.getMaxBufferLength(null==l?void 0:l.len)+c.levelTargetDuration)return;const u=c.fragments,h=u.length,d=c.edge;let f=null;const p=this.fragPrevious;if(ad-t?0:t;f=xr(p,u,Math.max(u[0].start,a),e),!f&&p&&p.startthis.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const e=Ze(this.media.textTracks);for(let r=0;r-1&&this.toggleTrackModes()}registerListeners(){const{hls:t}=this;t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.LEVEL_LOADING,this.onLevelLoading,this),t.on(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(I.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.LEVEL_LOADING,this.onLevelLoading,this),t.off(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(I.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(I.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,t)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);Ze(this.media.textTracks).forEach((t=>{Qe(t)})),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:r,groupId:n,details:i}=e,s=this.tracksInGroup[r];if(!s||s.groupId!==n)return void this.warn(`Subtitle track with id:${r} and group:${n} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=e.details,this.log(`Subtitle track ${r} "${s.name}" lang:${s.lang} group:${n} loaded [${i.startSN}-${i.endSN}]`),r===this.trackId&&this.playlistLoaded(r,e,a)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!e)return;const r=e.subtitleGroups||null,n=this.groupIds;let i=this.currentTrack;if(!r||(null==n?void 0:n.length)!==(null==r?void 0:r.length)||null!=r&&r.some((t=>-1===(null==n?void 0:n.indexOf(t))))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const t=this.tracks.filter((t=>!r||-1!==r.indexOf(t.groupId)));if(t.length)this.selectDefaultTrack&&!t.some((t=>t.default))&&(this.selectDefaultTrack=!1),t.forEach(((t,e)=>{t.id=e}));else if(!i&&!this.tracksInGroup.length)return;this.tracksInGroup=t;const e=this.hls.config.subtitlePreference;if(!i&&e){this.selectDefaultTrack=!1;const r=Qr(e,t);if(r>-1)i=t[r];else{const t=Qr(e,this.tracks);i=this.tracks[t]}}let n=this.findTrackId(i);-1===n&&i&&(n=this.findTrackId(null));const s={subtitleTracks:t};this.log(`Updating subtitle tracks, ${t.length} track(s) found in "${null==r?void 0:r.join(",")}" group-id`),this.hls.trigger(I.SUBTITLE_TRACKS_UPDATED,s),-1!==n&&-1===this.trackId&&this.setSubtitleTrack(n)}else this.shouldReloadPlaylist(i)&&this.setSubtitleTrack(this.trackId)}findTrackId(t){const e=this.tracksInGroup,r=this.selectDefaultTrack;for(let n=0;n-1){const t=this.tracksInGroup[n];return this.setSubtitleTrack(n),t}if(r)return null;{const r=Qr(t,e);if(r>-1)return e[r]}}}return null}loadPlaylist(t){super.loadPlaylist();const e=this.currentTrack;if(this.shouldLoadPlaylist(e)&&e){const r=e.id,n=e.groupId;let i=e.url;if(t)try{i=t.addDirectives(i)}catch(t){this.warn(`Could not construct new URL with HLS Delivery Directives: ${t}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(I.SUBTITLE_TRACK_LOADING,{url:i,id:r,groupId:n,deliveryDirectives:t||null})}}toggleTrackModes(){const{media:t}=this;if(!t)return;const e=Ze(t.textTracks),r=this.currentTrack;let n;if(r&&(n=e.filter((t=>Xi(r,t)))[0],n||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(e).forEach((t=>{"disabled"!==t.mode&&t!==n&&(t.mode="disabled")})),n){const t=this.subtitleDisplay?"showing":"hidden";n.mode!==t&&(n.mode=t)}}setSubtitleTrack(t){const e=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=t);if(t<-1||t>=e.length||!R(t))return void this.warn(`Invalid subtitle track id: ${t}`);this.clearTimer(),this.selectDefaultTrack=!1;const r=this.currentTrack,n=e[t]||null;if(this.trackId=t,this.currentTrack=n,this.toggleTrackModes(),!n)return void this.hls.trigger(I.SUBTITLE_TRACK_SWITCH,{id:t});const i=!!n.details&&!n.details.live;if(t===this.trackId&&n===r&&i)return;this.log(`Switching to subtitle-track ${t}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:""));const{id:s,groupId:a="",name:o,type:l,url:c}=n;this.hls.trigger(I.SUBTITLE_TRACK_SWITCH,{id:s,groupId:a,name:o,type:l,url:c});const u=this.switchParams(n.url,null==r?void 0:r.details,n.details);this.loadPlaylist(u)}},timelineController:class{constructor(t){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},t.on(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(I.FRAG_LOADING,this.onFragLoading,this),t.on(I.FRAG_LOADED,this.onFragLoaded,this),t.on(I.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(I.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(I.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(I.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(I.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(I.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(I.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(I.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(I.FRAG_LOADING,this.onFragLoading,this),t.off(I.FRAG_LOADED,this.onFragLoaded,this),t.off(I.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(I.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(I.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(I.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(I.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const t=new bs(this,"textTrack1"),e=new bs(this,"textTrack2"),r=new bs(this,"textTrack3"),n=new bs(this,"textTrack4");this.cea608Parser1=new ys(1,t,e),this.cea608Parser2=new ys(3,r,n)}}addCues(t,e,r,n,i){let s=!1;for(let t=i.length;t--;){const n=i[t],u=(a=n[0],o=n[1],l=e,c=r,Math.min(o,c)-Math.max(a,l));if(u>=0&&(n[0]=Math.min(n[0],e),n[1]=Math.max(n[1],r),s=!0,u/(r-e)>.5))return}var a,o,l,c;if(s||i.push([e,r]),this.config.renderTextTracksNatively){const i=this.captionsTracks[t];this.Cues.newCue(i,e,r,n)}else{const i=this.Cues.newCue(null,e,r,n);this.hls.trigger(I.CUES_PARSED,{type:"captions",cues:i,track:t})}}onInitPtsFound(t,{frag:e,id:r,initPTS:n,timescale:i}){const{unparsedVttFrags:s}=this;"main"===r&&(this.initPTS[e.cc]={baseTime:n,timescale:i}),s.length&&(this.unparsedVttFrags=[],s.forEach((t=>{this.onFragLoaded(I.FRAG_LOADED,t)})))}getExistingTrack(t,e){const{media:r}=this;if(r)for(let n=0;n{Qe(t[e]),delete t[e]})),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let t=0;tt.textCodec===Fs));if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(qi(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const t=this.media,e=t?Ze(t.textTracks):null;if(this.tracks.forEach(((t,r)=>{let n;if(e){let r=null;for(let n=0;nnull!==t)).map((t=>t.label));t.length&&N.warn(`Media element contains unused subtitle tracks: ${t.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const t=this.tracks.map((t=>({label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t})));this.hls.trigger(I.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:t})}}}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach((t=>{const e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(!e)return;const r=`textTrack${e[1]}`,n=this.captionsProperties[r];n&&(n.label=t.name,t.lang&&(n.languageCode=t.lang),n.media=t)}))}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return null==e?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){if(this.enabled&&e.frag.type===Ke){var r,n;const{cea608Parser1:t,cea608Parser2:i,lastSn:s}=this,{cc:a,sn:o}=e.frag,l=null!=(r=null==(n=e.part)?void 0:n.index)?r:-1;t&&i&&(o!==s+1||o===s&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(t.reset(),i.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(t,e){const{frag:r,payload:n}=e;if(r.type===Ve)if(n.byteLength){const t=r.decryptdata,i="stats"in e;if(null==t||!t.encrypted||i){const t=this.tracks[r.level],i=this.vttCCs;i[r.cc]||(i[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),t&&t.textCodec===Fs?this._parseIMSC1(r,n):this._parseVTTs(e)}}else this.hls.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const r=this.hls;$s(e,this.initPTS[t.cc],(e=>{this._appendCues(e,t.level),r.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(e=>{N.log(`Failed to parse IMSC1: ${e}`),r.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))}_parseVTTs(t){var e;const{frag:r,payload:n}=t,{initPTS:i,unparsedVttFrags:s}=this,a=i.length-1;if(!i[r.cc]&&-1===a)return void s.push(t);const o=this.hls;Ms(null!=(e=r.initSegment)&&e.data?te(r.initSegment.data,new Uint8Array(n)):n,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,(t=>{this._appendCues(t,r.level),o.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})}),(e=>{const i="Missing initPTS for VTT MPEGTS"===e.message;i?s.push(t):this._fallbackToIMSC1(r,n),N.log(`Failed to parse VTT cue: ${e}`),i&&a>r.cc||o.trigger(I.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:e})}))}_fallbackToIMSC1(t,e){const r=this.tracks[t.level];r.textCodec||$s(e,this.initPTS[t.cc],(()=>{r.textCodec=Fs,this._parseIMSC1(t,e)}),(()=>{r.textCodec="wvtt"}))}_appendCues(t,e){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[e];if(!r||"disabled"===r.mode)return;t.forEach((t=>Xe(r,t)))}else{const n=this.tracks[e];if(!n)return;const i=n.default?"default":"subtitles"+e;r.trigger(I.CUES_PARSED,{type:"subtitles",cues:t,track:i})}}onFragDecrypted(t,e){const{frag:r}=e;r.type===Ve&&this.onFragLoaded(I.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){this.initCea608Parsers();const{cea608Parser1:r,cea608Parser2:n}=this;if(!this.enabled||!r||!n)return;const{frag:i,samples:s}=e;if(i.type!==Ke||"NONE"!==this.closedCaptionsForLevel(i))for(let t=0;tJe(t[n],e,r)))}if(this.config.renderTextTracksNatively&&0===e&&void 0!==n){const{textTracks:t}=this;Object.keys(t).forEach((r=>Je(t[r],e,n)))}}}extractCea608Data(t){const e=[[],[]],r=31&t[0];let n=2;for(let i=0;i0&&-1===t?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=Cn):(this.loadedmetadata=!1,this.state=Pn),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case Cn:this.doTickIdle();break;case Pn:{var t;const{levels:e,trackId:r}=this,n=null==e||null==(t=e[r])?void 0:t.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=Nn}break}case xn:{var e;const t=performance.now(),r=this.retryDate;if(!r||t>=r||null!=(e=this.media)&&e.seeking){const{levels:t,trackId:e}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==t?void 0:t[e])||null),this.state=Cn}break}case Nn:{const t=this.waitingData;if(t){const{frag:e,part:r,cache:n,complete:i}=t;if(void 0!==this.initPTS[e.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=In;const t={frag:e,part:r,payload:n.flush(),networkDetails:null};this._handleFragmentLoadProgress(t),i&&super._handleFragmentLoadComplete(t)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${e.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const t=this.getLoadPosition(),r=hn.bufferInfo(this.mediaBuffer,t,this.config.maxBufferHole);Pr(r.end,this.config.maxFragLookUpTolerance,e)<0&&(this.log(`Waiting fragment cc (${e.cc}) @ ${e.start} cancelled because another fragment at ${r.end} is needed`),this.clearWaitingFragment())}}else this.state=Cn}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Cn)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:t,levels:e,media:r,trackId:n}=this,i=t.config;if(!r&&(this.startFragRequested||!i.startFragPrefetch)||null==e||!e[n])return;const s=e[n],a=s.details;if(!a||a.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(a))return void(this.state=Pn);const o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,V,He));const l=this.getFwdBufferInfo(o,He);if(null===l)return;const{bufferedTrack:c,switchingTrack:u}=this;if(!u&&this._streamEnded(l,a))return t.trigger(I.BUFFER_EOS,{type:"audio"}),void(this.state=Fn);const h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Ke),d=l.len,f=this.getMaxBufferLength(null==h?void 0:h.len),p=a.fragments,g=p[0].start;let m=this.flushing?this.getLoadPosition():l.end;if(u&&r){const t=this.getLoadPosition();c&&!zi(u.attrs,c.attrs)&&(m=t),a.PTSKnown&&tg||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}if(d>=f&&!u&&mh.end+a.targetduration;if(E||(null==h||!h.len)&&l.len){const t=this.getAppendedFrag(y.start,Ke);if(null===t)return;if(v||(v=!!t.gap||!!E&&0===h.len),E&&!v||v&&l.nextStart&&l.nextStartnew mr(t)))}onAudioTrackSwitching(t,e){const r=!!e.url;this.trackId=e.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.switchingTrack=e,this.state=Cn,this.flushAudioIfNeeded(e)):(this.switchingTrack=null,this.bufferedTrack=e,this.state=Rn),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!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(I.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var r;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=e);const{levels:n}=this,{details:i,id:s}=e;if(!n)return void this.warn(`Audio tracks were reset while loading level ${s}`);this.log(`Audio track ${s} loaded [${i.startSN},${i.endSN}]${i.lastPartSn?`[part-${i.lastPartSn}-${i.lastPartIndex}]`:""},duration:${i.totalduration}`);const a=n[s];let o=0;if(i.live||null!=(r=a.details)&&r.live){this.checkLiveUpdate(i);const t=this.mainDetails;if(i.deltaUpdateFailed||!t)return;var l;if(!a.details&&i.hasProgramDateTime&&t.hasProgramDateTime)yn(i,t),o=i.fragments[0].start;else o=this.alignPlaylists(i,a.details,null==(l=this.levelLastLoaded)?void 0:l.details)}a.details=i,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(this.mainDetails||i,o),this.state!==Pn||this.waitForCdnTuneIn(i)||(this.state=Cn),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:r,part:n,payload:i}=t,{config:s,trackId:a,levels:o}=this;if(!o)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const l=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const u=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new Yi(this.hls,He,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const d=this.initPTS[r.cc],f=null==(e=r.initSegment)?void 0:e.data;if(void 0!==d){const t=!1,e=n?n.index:-1,s=-1!==e,a=new dn(r.level,r.sn,r.stats.chunkCount,i.byteLength,e,s);h.push(i,f,u,"",r,n,c.totalduration,t,a,d)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${c.startSN} ,${c.endSN}],track ${a}`);const{cache:t}=this.waitingData=this.waitingData||{frag:r,part:n,cache:new jn,complete:!1};t.push(new Uint8Array(i)),this.waitingVideoCC=this.videoTrackCC,this.state=Nn}}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const r=e.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:r,part:n}=e;if(r.type===He)if(this.fragContextChanged(r))this.warn(`Fragment ${r.sn}${n?" p: "+n.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if("initSegment"!==r.sn){this.fragPrevious=r;const t=this.switchingTrack;t&&(this.bufferedTrack=t,this.switchingTrack=null,this.hls.trigger(I.AUDIO_TRACK_SWITCHED,_({},t)))}this.fragBufferedComplete(r,n)}else if(!this.loadedmetadata&&r.type===Ke){const t=this.videoBuffer||this.media;if(t){hn.getBuffered(t).length&&(this.loadedmetadata=!0)}}}onError(t,e){var r;if(e.fatal)this.state=Bn;else switch(e.details){case P.FRAG_GAP:case P.FRAG_PARSING_ERROR:case P.FRAG_DECRYPT_ERROR:case P.FRAG_LOAD_ERROR:case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_ERROR:case P.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(He,e);break;case P.AUDIO_TRACK_LOAD_ERROR:case P.AUDIO_TRACK_LOAD_TIMEOUT:case P.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Pn||(null==(r=e.context)?void 0:r.type)!==je||(this.state=Cn);break;case P.BUFFER_APPEND_ERROR:case P.BUFFER_FULL_ERROR:if(!e.parent||"audio"!==e.parent)return;if(e.details===P.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case P.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushing(t,{type:e}){e!==W&&(this.flushing=!0)}onBufferFlushed(t,{type:e}){if(e!==W){this.flushing=!1,this.bufferFlushed=!0,this.state===Fn&&(this.state=Cn);const t=this.mediaBuffer||this.media;t&&(this.afterBufferFlushed(t,e,He),this.tick())}}_handleTransmuxComplete(t){var e;const r="audio",{hls:n}=this,{remuxResult:i,chunkMeta:s}=t,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:l,level:c}=a,{details:u}=c,{audio:h,text:d,id3:f,initSegment:p}=i;if(!this.fragContextChanged(o)&&u){if(this.state=On,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const t=o.initSegment||o;this._bufferInitSegment(c,p.tracks,t,s),n.trigger(I.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:r,tracks:p.tracks})}if(h){const{startPTS:t,endPTS:e,startDTS:r,endDTS:n}=h;l&&(l.elementaryStreams[V]={startPTS:t,endPTS:e,startDTS:r,endDTS:n}),o.setElementaryStreamInfo(V,t,e,r,n),this.bufferFragmentData(h,o,l,s)}if(null!=f&&null!=(e=f.samples)&&e.length){const t=w({id:r,frag:o,details:u},f);n.trigger(I.FRAG_PARSING_METADATA,t)}if(d){const t=w({id:r,frag:o,details:u},d);n.trigger(I.FRAG_PARSING_USERDATA,t)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(t,e,r,n){if(this.state!==On)return;e.video&&delete e.video;const i=e.audio;if(!i)return;i.id="audio";const s=t.audioCodec;this.log(`Init audio buffer, container:${i.container}, codecs[level/parsed]=[${s}/${i.codec}]`),s&&1===s.split(",").length&&(i.levelCodec=s),this.hls.trigger(I.BUFFER_CODECS,e);const a=i.initSegment;if(null!=a&&a.byteLength){const t={type:"audio",frag:r,part:null,chunkMeta:n,parent:r.type,data:a};this.hls.trigger(I.BUFFER_APPENDING,t)}this.tickImmediate()}loadFragment(t,e,r){const n=this.fragmentTracker.getState(t);var i;if(this.fragCurrent=t,this.switchingTrack||n===rn||n===sn)if("initSegment"===t.sn)this._loadInitSegment(t,e);else if(null!=(i=e.details)&&i.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=Nn;const r=this.mainDetails;r&&r.fragments[0].start!==e.details.fragments[0].start&&yn(e.details,r)}else this.startFragRequested=!0,super.loadFragment(t,e,r);else this.clearTrackerIfNeeded(t)}flushAudioIfNeeded(t){const{media:e,bufferedTrack:r}=this,n=null==r?void 0:r.attrs,i=t.attrs;e&&n&&(n.CHANNELS!==i.CHANNELS||r.name!==t.name||r.lang!==t.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(t){const{hls:e}=this;this.flushAudioIfNeeded(t),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(I.AUDIO_TRACK_SWITCHED,_({},t))}},audioTrackController:class extends Gr{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.LEVEL_LOADING,this.onLevelLoading,this),t.on(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(I.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(I.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.LEVEL_LOADING,this.onLevelLoading,this),t.off(I.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(I.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(I.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:r,groupId:n,details:i}=e,s=this.tracksInGroup[r];if(!s||s.groupId!==n)return void this.warn(`Audio track with id:${r} and group:${n} not found in active group ${null==s?void 0:s.groupId}`);const a=s.details;s.details=e.details,this.log(`Audio track ${r} "${s.name}" lang:${s.lang} group:${n} loaded [${i.startSN}-${i.endSN}]`),r===this.trackId&&this.playlistLoaded(r,e,a)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!e)return;const r=e.audioGroups||null,n=this.groupIds;let i=this.currentTrack;if(!r||(null==n?void 0:n.length)!==(null==r?void 0:r.length)||null!=r&&r.some((t=>-1===(null==n?void 0:n.indexOf(t))))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const t=this.tracks.filter((t=>!r||-1!==r.indexOf(t.groupId)));if(t.length)this.selectDefaultTrack&&!t.some((t=>t.default))&&(this.selectDefaultTrack=!1),t.forEach(((t,e)=>{t.id=e}));else if(!i&&!this.tracksInGroup.length)return;this.tracksInGroup=t;const e=this.hls.config.audioPreference;if(!i&&e){const r=Qr(e,t,Zr);if(r>-1)i=t[r];else{const t=Qr(e,this.tracks);i=this.tracks[t]}}let n=this.findTrackId(i);-1===n&&i&&(n=this.findTrackId(null));const a={audioTracks:t};this.log(`Updating audio tracks, ${t.length} track(s) found in group(s): ${null==r?void 0:r.join(",")}`),this.hls.trigger(I.AUDIO_TRACKS_UPDATED,a);const o=this.trackId;if(-1!==n&&-1===o)this.setAudioTrack(n);else if(t.length&&-1===o){var s;const e=new Error(`No audio track selected for current audio group-ID(s): ${null==(s=this.groupIds)?void 0:s.join(",")} track count: ${t.length}`);this.warn(e.message),this.hls.trigger(I.ERROR,{type:x.MEDIA_ERROR,details:P.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e})}}else this.shouldReloadPlaylist(i)&&this.setAudioTrack(this.trackId)}onError(t,e){!e.fatal&&e.context&&(e.context.type!==je||e.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(e.context.groupId)||(this.requestScheduled=-1,this.checkRetry(e)))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioOption(t){const e=this.hls;if(e.config.audioPreference=t,t){const r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){const n=this.currentTrack;if(n&&Jr(t,n,Zr))return n;const i=Qr(t,this.tracksInGroup,Zr);if(i>-1){const t=this.tracksInGroup[i];return this.setAudioTrack(i),t}if(n){let n=e.loadLevel;-1===n&&(n=e.firstAutoLevel);const i=function(t,e,r,n,i){const s=e[n],a=e.reduce(((t,e,r)=>{const n=e.uri;return(t[n]||(t[n]=[])).push(r),t}),{})[s.uri];a.length>1&&(n=Math.max.apply(Math,a));const o=s.videoRange,l=s.frameRate,c=s.codecSet.substring(0,4),u=tn(e,n,(e=>{if(e.videoRange!==o||e.frameRate!==l||e.codecSet.substring(0,4)!==c)return!1;const n=e.audioGroups,s=r.filter((t=>!n||-1!==n.indexOf(t.groupId)));return Qr(t,s,i)>-1}));return u>-1?u:tn(e,n,(e=>{const n=e.audioGroups,s=r.filter((t=>!n||-1!==n.indexOf(t.groupId)));return Qr(t,s,i)>-1}))}(t,e.levels,r,n,Zr);if(-1===i)return null;e.nextLoadLevel=i}if(t.channels||t.audioCodec){const e=Qr(t,r);if(e>-1)return r[e]}}}return null}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length)return void this.warn(`Invalid audio track id: ${t}`);this.clearTimer(),this.selectDefaultTrack=!1;const r=this.currentTrack,n=e[t],i=n.details&&!n.details.live;if(t===this.trackId&&n===r&&i)return;if(this.log(`Switching to audio-track ${t} "${n.name}" lang:${n.lang} group:${n.groupId} channels:${n.channels}`),this.trackId=t,this.currentTrack=n,this.hls.trigger(I.AUDIO_TRACK_SWITCHING,_({},n)),i)return;const s=this.switchParams(n.url,null==r?void 0:r.details,n.details);this.loadPlaylist(s)}findTrackId(t){const e=this.tracksInGroup;for(let r=0;r{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:Zs.MANIFEST,su:!this.initialized})}catch(t){N.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=t=>{try{const e=t.frag,r=this.hls.levels[e.level],n=this.getObjectType(e),i={d:1e3*e.duration,ot:n};n!==Zs.VIDEO&&n!==Zs.AUDIO&&n!=Zs.MUXED||(i.br=r.bitrate/1e3,i.tb=this.getTopBandwidth(n)/1e3,i.bl=this.getBufferLength(n)),this.apply(t,i)}catch(t){N.warn("Could not generate segment CMCD data.",t)}},this.hls=t;const e=this.config=t.config,{cmcd:r}=e;null!=r&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||function(){try{return crypto.randomUUID()}catch(t){try{const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}catch(t){let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{const r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?r:3&r|8).toString(16)}))}}}(),this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){const t=this.hls;t.on(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(I.MEDIA_DETACHED,this.onMediaDetached,this),t.on(I.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(I.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(I.MEDIA_DETACHED,this.onMediaDetached,this),t.off(I.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=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,n;this.audioBuffer=null==(r=e.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(n=e.tracks.video)?void 0:n.buffer}createData(){var t;return{v:1,sf:ta.HLS,sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){w(e,this.createData());const r=e.ot===Zs.INIT||e.ot===Zs.VIDEO||e.ot===Zs.MUXED;this.starved&&r&&(e.bs=!0,e.su=!0,this.starved=!1),null==e.su&&(e.su=this.buffering);const{includeKeys:n}=this;n&&(e=Object.keys(e).reduce(((t,r)=>(n.includes(r)&&(t[r]=e[r]),t)),{})),this.useHeaders?(t.headers||(t.headers={}),_a(t.headers,e)):t.url=La(t.url,e)}getObjectType(t){const{type:e}=t;return"subtitle"===e?Zs.TIMED_TEXT:"initSegment"===t.sn?Zs.INIT:"audio"===e?Zs.AUDIO:"main"===e?this.hls.audioTracks.length?Zs.VIDEO:Zs.MUXED:void 0}getTopBandwidth(t){let e,r=0;const n=this.hls;if(t===Zs.AUDIO)e=n.audioTracks;else{const t=n.maxAutoLevel,r=t>-1?t+1:n.levels.length;e=n.levels.slice(0,r)}for(const t of e)t.bitrate>r&&(r=t.bitrate);return r>0?r:NaN}getBufferLength(t){const e=this.hls.media,r=t===Zs.AUDIO?this.audioBuffer:this.videoBuffer;if(!r||!e)return NaN;return 1e3*hn.bufferInfo(r,e.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,r=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new r(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,r,n){e(t),this.loader.load(t,r,n)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,r=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new r(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,r,n){e(t),this.loader.load(t,r,n)}}}},contentSteeringController:class{constructor(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=N.log.bind(N,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(I.MANIFEST_PARSED,this.onManifestParsed,this),t.on(I.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(I.MANIFEST_PARSED,this.onManifestParsed,this),t.off(I.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const t=1e3*this.timeToLoad-(performance.now()-this.updated);if(t>0)return void this.scheduleRefresh(this.uri,t)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter((e=>e!==t)))}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){const{contentSteering:r}=e;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:r}=e;if((null==r?void 0:r.action)===Fr&&r.flags===$r){const t=this.levels;let n=this.pathwayPriority,i=this.pathwayId;if(e.context){const{groupId:r,pathwayId:n,type:s}=e.context;r&&t?i=this.getPathwayForGroupId(r,s,i):n&&(i=n)}i in this.penalizedPathways||(this.penalizedPathways[i]=performance.now()),!n&&t&&(n=t.reduce(((t,e)=>(-1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t)),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==i),r.resolved||N.warn(`Could not resolve ${e.details} ("${e.error.message}") with content-steering for Pathway: ${i} levels: ${t?t.length:t} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(0===e.length){const r=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),e=this.getLevelsForPathway(r),this.pathwayId=r}return e.length!==t.length&&this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e}getLevelsForPathway(t){return null===this.levels?[]:this.levels.filter((e=>t===e.pathwayId))}updatePathwayPriority(t){let e;this.pathwayPriority=t;const r=this.penalizedPathways,n=performance.now();Object.keys(r).forEach((t=>{n-r[t]>3e5&&delete r[t]}));for(let n=0;n0){this.log(`Setting Pathway to "${i}"`),this.pathwayId=i,kr(e),this.hls.trigger(I.LEVELS_UPDATED,{levels:e});const t=this.hls.levels[s];a&&t&&this.levels&&(t.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&t.bitrate!==a.bitrate&&this.log(`Unstable Pathways change from bitrate ${a.bitrate} to ${t.bitrate}`),this.hls.nextLoadLevel=s);break}}}getPathwayForGroupId(t,e,r){const n=this.getLevelsForPathway(r).concat(this.levels||[]);for(let r=0;r{const{ID:i,"BASE-ID":s,"URI-REPLACEMENT":a}=t;if(e.some((t=>t.pathwayId===i)))return;const o=this.getLevelsForPathway(s).map((t=>{const e=new j(t.attrs);e["PATHWAY-ID"]=i;const s=e.AUDIO&&`${e.AUDIO}_clone_${i}`,o=e.SUBTITLES&&`${e.SUBTITLES}_clone_${i}`;s&&(r[e.AUDIO]=s,e.AUDIO=s),o&&(n[e.SUBTITLES]=o,e.SUBTITLES=o);const l=Ra(t.uri,e["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),c=new mr({attrs:e,audioCodec:t.audioCodec,bitrate:t.bitrate,height:t.height,name:t.name,url:l,videoCodec:t.videoCodec,width:t.width});if(t.audioGroups)for(let e=1;e{this.log(`Loaded steering manifest: "${n}"`);const s=t.data;if(1!==s.VERSION)return void this.log(`Steering VERSION ${s.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=s.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":l}=s;if(a)try{this.uri=new self.URL(a,n).href}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${a}`)}this.scheduleRefresh(this.uri||r.url),o&&this.clonePathways(o);const c={steeringManifest:s,url:n.toString()};this.hls.trigger(I.STEERING_MANIFEST_LOADED,c),l&&this.updatePathwayPriority(l)},onError:(t,e,r,n)=>{if(this.log(`Error loading steering manifest: ${t.code} ${t.text} (${e.url})`),this.stopLoad(),410===t.code)return this.enabled=!1,void this.log(`Steering manifest ${e.url} no longer available`);let i=1e3*this.timeToLoad;if(429!==t.code)this.scheduleRefresh(this.uri||e.url,i);else{const t=this.loader;if("function"==typeof(null==t?void 0:t.getResponseHeader)){const e=t.getResponseHeader("Retry-After");e&&(i=1e3*parseFloat(e))}this.log(`Steering manifest ${e.url} rate limited`)}},onTimeout:(t,e,r)=>{this.log(`Timeout loading steering manifest (${e.url})`),this.scheduleRefresh(this.uri||e.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(i,o,l)}scheduleRefresh(t,e=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout((()=>{var e;const r=null==(e=this.hls)?void 0:e.media;!r||r.ended?this.scheduleRefresh(t,1e3*this.timeToLoad):this.loadSteeringManifest(t)}),e)}}});function Na(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(Na):Object.keys(t).reduce(((e,r)=>(e[r]=Na(t[r]),e)),{}):t}function Ua(t){const e=t.loader;if(e!==xa&&e!==Da)N.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1;else{(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1})()&&(t.loader=xa,t.progressive=!0,t.enableSoftwareAES=!0,N.log("[config]: Progressive streaming enabled, using FetchLoader"))}}let $a;class ja extends Gr{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-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(){const{hls:t}=this;t.on(I.MANIFEST_LOADING,this.onManifestLoading,this),t.on(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(I.LEVEL_LOADED,this.onLevelLoaded,this),t.on(I.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(I.FRAG_BUFFERED,this.onFragBuffered,this),t.on(I.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(I.MANIFEST_LOADING,this.onManifestLoading,this),t.off(I.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(I.LEVEL_LOADED,this.onLevelLoaded,this),t.off(I.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(I.FRAG_BUFFERED,this.onFragBuffered,this),t.off(I.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach((t=>{t.loadError=0,t.fragmentError=0})),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const r=this.hls.config.preferManagedMediaSource,n=[],i={},s={};let a=!1,o=!1,l=!1;e.levels.forEach((t=>{var e,c;const u=t.attrs;let{audioCodec:h,videoCodec:d}=t;-1!==(null==(e=h)?void 0:e.indexOf("mp4a.40.34"))&&($a||($a=/chrome|firefox/i.test(navigator.userAgent)),$a&&(t.audioCodec=h=void 0)),h&&(t.audioCodec=h=_e(h,r)),0===(null==(c=d)?void 0:c.indexOf("avc1"))&&(d=t.videoCodec=function(t){const e=t.split(",");for(let t=0;t2){let n=r.shift()+".";n+=parseInt(r.shift()).toString(16),n+=("000"+parseInt(r.shift()).toString(16)).slice(-4),e[t]=n}}return e.join(",")}(d));const{width:f,height:p,unknownCodecs:g}=t;if(a||(a=!(!f||!p)),o||(o=!!d),l||(l=!!h),null!=g&&g.length||h&&!ye(h,"audio",r)||d&&!ye(d,"video",r))return;const{CODECS:m,"FRAME-RATE":y,"HDCP-LEVEL":v,"PATHWAY-ID":E,RESOLUTION:b,"VIDEO-RANGE":T}=u,S=`${`${E||"."}-`}${t.bitrate}-${b}-${y}-${m}-${T}-${v}`;if(i[S])if(i[S].uri===t.url||t.attrs["PATHWAY-ID"])i[S].addGroupId("audio",u.AUDIO),i[S].addGroupId("text",u.SUBTITLES);else{const e=s[S]+=1;t.attrs["PATHWAY-ID"]=new Array(e+1).join(".");const r=new mr(t);i[S]=r,n.push(r)}else{const e=new mr(t);i[S]=e,s[S]=1,n.push(e)}})),this.filterAndSortMediaOptions(n,e,a,o,l)}filterAndSortMediaOptions(t,e,r,n,i){let s=[],a=[],o=t;if((r||n)&&i&&(o=o.filter((({videoCodec:t,videoRange:e,width:r,height:n})=>{return(!!t||!(!r||!n))&&(!!(i=e)&&ur.indexOf(i)>-1);var i}))),0===o.length)return void Promise.resolve().then((()=>{if(this.hls){e.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(e.levels[0].attrs)}`);const t=new Error("no level with compatible codecs found in manifest");this.hls.trigger(I.ERROR,{type:x.MEDIA_ERROR,details:P.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:t,reason:t.message})}}));if(e.audioTracks){const{preferManagedMediaSource:t}=this.hls.config;s=e.audioTracks.filter((e=>!e.audioCodec||ye(e.audioCodec,"audio",t))),Ga(s)}e.subtitles&&(a=e.subtitles,Ga(a));const l=o.slice(0);o.sort(((t,e)=>{if(t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"])return(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&t.height!==e.height)return t.height-e.height;if(t.frameRate!==e.frameRate)return t.frameRate-e.frameRate;if(t.videoRange!==e.videoRange)return ur.indexOf(t.videoRange)-ur.indexOf(e.videoRange);if(t.videoCodec!==e.videoCodec){const r=be(t.videoCodec),n=be(e.videoCodec);if(r!==n)return n-r}if(t.uri===e.uri&&t.codecSet!==e.codecSet){const r=Te(t.codecSet),n=Te(e.codecSet);if(r!==n)return n-r}return t.averageBitrate!==e.averageBitrate?t.averageBitrate-e.averageBitrate:0}));let c=l[0];if(this.steering&&(o=this.steering.filterParsedLevels(o),o.length!==l.length))for(let t=0;tr&&r===Ba.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=t)}break}const h=i&&!n,d={levels:o,audioTracks:s,subtitleTracks:a,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:i,video:n,altAudio:!h&&s.some((t=>!!t.url))};this.hls.trigger(I.MANIFEST_PARSED,d),(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){const e=this._levels;if(0===e.length)return;if(t<0||t>=e.length){const r=new Error("invalid level idx"),n=t<0;if(this.hls.trigger(I.ERROR,{type:x.OTHER_ERROR,details:P.LEVEL_SWITCH_ERROR,level:t,fatal:n,error:r,reason:r.message}),n)return;t=Math.min(t,e.length-1)}const r=this.currentLevelIndex,n=this.currentLevel,i=n?n.attrs["PATHWAY-ID"]:void 0,s=e[t],a=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=s,r===t&&s.details&&n&&i===a)return;this.log(`Switching to level ${t} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${a?" with Pathway "+a:""} from level ${r}${i?" with Pathway "+i:""}`);const o={level:t,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger(I.LEVEL_SWITCHING,o);const l=s.details;if(!l||l.live){const t=this.switchParams(s.uri,null==n?void 0:n.details,l);this.loadPlaylist(t)}}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(){if(void 0===this._startLevel){const t=this.hls.config.startLevel;return void 0!==t?t:this.hls.firstAutoLevel}return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){!e.fatal&&e.context&&e.context.type===$e&&e.context.level===this.level&&this.checkRetry(e)}onFragBuffered(t,{frag:e}){if(void 0!==e&&e.type===Ke){const t=e.elementaryStreams;if(!Object.keys(t).some((e=>!!t[e])))return;const r=this._levels[e.level];null!=r&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(t,e){var r;const{level:n,details:i}=e,s=this._levels[n];var a;if(!s)return this.warn(`Invalid level index ${n}`),void(null!=(a=e.deliveryDirectives)&&a.skip&&(i.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(n,e,s.details)):null!=(r=e.deliveryDirectives)&&r.skip&&(i.deltaUpdateFailed=!0)}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let n=r.uri;if(t)try{n=t.addDirectives(n)}catch(t){this.warn(`Could not construct new URL with HLS Delivery Directives: ${t}`)}const i=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${e}${void 0!==(null==t?void 0:t.msn)?" at sn "+t.msn+" part "+t.part:""} with${i?" Pathway "+i:""} ${n}`),this.clearTimer(),this.hls.trigger(I.LEVEL_LOADING,{url:n,level:e,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:t||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}removeLevel(t){var e;const r=this._levels.filter(((e,r)=>r!==t||(this.steering&&this.steering.removeLevel(e),e===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,e.details&&e.details.fragments.forEach((t=>t.level=-1))),!1)));kr(r),this._levels=r,this.currentLevelIndex>-1&&null!=(e=this.currentLevel)&&e.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(I.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(t,{levels:e}){this._levels=e}checkMaxAutoUpdated(){const{autoLevelCapping:t,maxAutoLevel:e,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==e&&(this._maxAutoLevel=e,this.hls.trigger(I.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:e,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function Ga(t){const e={};t.forEach((t=>{const r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++}))}class Ka{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const r in this.keyUriToKeyInfo){const n=this.keyUriToKeyInfo[r].loader;if(n){var e;if(t&&t!==(null==(e=n.context)?void 0:e.frag.type))return;n.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=P.KEY_LOAD_ERROR,r,n,i){return new Sn({type:x.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:i,error:r,networkDetails:n})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:r,cc:n}=t;for(let t=0;t{i.setKeyFormat(t)}));break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then((e=>this.loadInternal(t,e))):this.loadInternal(t)}loadInternal(t,e){var r,n;e&&t.setKeyFormat(e);const i=t.decryptdata;if(!i){const r=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,P.KEY_LOAD_ERROR,r))}const s=i.uri;if(!s)return Promise.reject(this.createKeyLoadError(t,P.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));let a=this.keyUriToKeyInfo[s];if(null!=(r=a)&&r.decryptdata.key)return i.key=a.decryptdata.key,Promise.resolve({frag:t,keyInfo:a});var o;if(null!=(n=a)&&n.keyLoadPromise)switch(null==(o=a.mediaKeySessionContext)?void 0:o.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return a.keyLoadPromise.then((e=>(i.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:a})))}switch(a=this.keyUriToKeyInfo[s]={decryptdata:i,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},i.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===i.keyFormat?this.loadKeyHTTP(a,t):this.loadKeyEME(a,t);case"AES-128":return this.loadKeyHTTP(a,t);default:return Promise.reject(this.createKeyLoadError(t,P.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${i.method}"`)))}}loadKeyEME(t,e){const r={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const e=this.emeController.loadKey(r);if(e)return(t.keyLoadPromise=e.then((e=>(t.mediaKeySessionContext=e,r)))).catch((e=>{throw t.keyLoadPromise=null,e}))}return Promise.resolve(r)}loadKeyHTTP(t,e){const r=this.config,n=new(0,r.loader)(r);return e.keyLoader=t.loader=n,t.keyLoadPromise=new Promise(((i,s)=>{const a={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},o=r.keyLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,e,r,n)=>{const{frag:a,keyInfo:o,url:l}=r;if(!a.decryptdata||o!==this.keyUriToKeyInfo[l])return s(this.createKeyLoadError(a,P.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));o.decryptdata.key=a.decryptdata.key=new Uint8Array(t.data),a.keyLoader=null,o.loader=null,i({frag:a,keyInfo:o})},onError:(t,r,n,i)=>{this.resetLoader(r),s(this.createKeyLoadError(e,P.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key ${t.text}`),n,_({url:a.url,data:void 0},t)))},onTimeout:(t,r,n)=>{this.resetLoader(r),s(this.createKeyLoadError(e,P.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:(t,r,n)=>{this.resetLoader(r),s(this.createKeyLoadError(e,P.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};n.load(a,l,c)}))}resetLoader(t){const{frag:e,keyInfo:r,url:n}=t,i=r.loader;e.keyLoader===i&&(e.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[n],i&&i.destroy()}}function Ha(){return self.SourceBuffer||self.WebKitSourceBuffer}function Va(){if(!ge())return!1;const t=Ha();return!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove}class Wa{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){const{config:r,media:n,stalled:i}=this;if(null===n)return;const{currentTime:s,seeking:a}=n,o=this.seeking&&!a,l=!this.seeking&&a;if(this.seeking=a,s!==t){if(this.moved=!0,a||(this.nudgeRetry=0),null!==i){if(this.stallReported){const t=self.performance.now()-i;N.warn(`playback not stuck anymore @${s}, after ${Math.round(t)}ms`),this.stallReported=!1}this.stalled=null}return}if(l||o)return void(this.stalled=null);if(n.paused&&!a||n.ended||0===n.playbackRate||!hn.getBuffered(n).length)return void(this.nudgeRetry=0);const c=hn.bufferInfo(n,s,0),u=c.nextStart||0;if(a){const t=c.len>2,r=!u||e&&e.start<=s||u-s>2&&!this.fragmentTracker.getPartialFragment(s);if(t||r)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var h;if(!(c.len>0)&&!u)return;const t=Math.max(u,c.start||0)-s,e=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,r=(null==e||null==(h=e.details)?void 0:h.live)?2*e.details.targetduration:2,i=this.fragmentTracker.getPartialFragment(s);if(t>0&&(t<=r||i))return void(n.paused||this._trySkipBufferHole(i))}const d=self.performance.now();if(null===i)return void(this.stalled=d);const f=d-i;if(!a&&f>=250&&(this._reportStall(c),!this.media))return;const p=hn.bufferInfo(n,s,r.maxBufferHole);this._tryFixBufferStall(p,f)}_tryFixBufferStall(t,e){const{config:r,fragmentTracker:n,media:i}=this;if(null===i)return;const s=i.currentTime,a=n.getPartialFragment(s);if(a){if(this._trySkipBufferHole(a)||!this.media)return}(t.len>r.maxBufferHole||t.nextStart&&t.nextStart-s1e3*r.highBufferWatchdogPeriod&&(N.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:r,stallReported:n}=this;if(!n&&r){this.stallReported=!0;const n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(t)})`);N.warn(n.message),e.trigger(I.ERROR,{type:x.MEDIA_ERROR,details:P.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:r,media:n}=this;if(null===n)return 0;const i=n.currentTime,s=hn.bufferInfo(n,i,0),a=i0&&s.len<1&&n.readyState<3,c=a-i;if(c>0&&(o||l)){if(c>e.maxBufferHole){const{fragmentTracker:e}=this;let r=!1;if(0===i){const t=e.getAppendedFrag(0,Ke);t&&a1?(t=0,this.bitrateTest=!0):t=r.firstAutoLevel),r.nextLoadLevel=t,this.level=r.loadLevel,this.loadedmetadata=!1}e>0&&-1===t&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=Cn,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Rn}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Un:{const{levels:t,level:e}=this,r=null==t?void 0:t[e],n=null==r?void 0:r.details;if(n&&(!n.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(n))break;this.state=Cn;break}if(this.hls.nextLoadLevel!==this.level){this.state=Cn;break}break}case xn:{var t;const e=self.performance.now(),r=this.retryDate;if(!r||e>=r||null!=(t=this.media)&&t.seeking){const{levels:t,level:e}=this,r=null==t?void 0:t[e];this.resetStartWhenNotLoaded(r||null),this.state=Cn}}}this.state===Cn&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:r,media:n}=this;if(null===e||!n&&(this.startFragRequested||!t.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const i=t.nextLoadLevel;if(null==r||!r[i])return;const s=r[i],a=this.getMainFwdBufferInfo();if(null===a)return;const o=this.getLevelDetails();if(o&&this._streamEnded(a,o)){const t={};return this.altAudio&&(t.type="video"),this.hls.trigger(I.BUFFER_EOS,t),void(this.state=Fn)}t.loadLevel!==i&&-1===t.manualLevel&&this.log(`Adapting to level ${i} from level ${this.level}`),this.level=t.nextLoadLevel=i;const l=s.details;if(!l||this.state===Un||l.live&&this.levelLastLoaded!==s)return this.level=i,void(this.state=Un);const c=a.len,u=this.getMaxBufferLength(s.maxBitrate);if(c>=u)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:a.end;let d=this.getNextFragment(h,l);if(this.couldBacktrack&&!this.fragPrevious&&d&&"initSegment"!==d.sn&&this.fragmentTracker.getState(d)!==an){var f;const t=(null!=(f=this.backtrackFragment)?f:d).sn-l.startSN,e=l.fragments[t-1];e&&d.cc===e.cc&&(d=e,this.fragmentTracker.removeFragment(e))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(d&&this.isLoopLoading(d,h)){if(!d.gap){const t=this.audioOnly&&!this.altAudio?V:W,e=(t===W?this.videoBuffer:this.mediaBuffer)||this.media;e&&this.afterBufferFlushed(e,t,Ke)}d=this.getNextFragmentLoopLoading(d,l,a,Ke,u)}d&&(!d.initSegment||d.initSegment.data||this.bitrateTest||(d=d.initSegment),this.loadFragment(d,s,h))}loadFragment(t,e,r){const n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===rn||n===sn?"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,Ke)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(null!=e&&e.readyState){let r;const n=this.getAppendedFrag(e.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);const i=this.getLevelDetails();if(null!=i&&i.live){const t=this.getMainFwdBufferInfo();if(!t||t.len<2*i.targetduration)return}if(!e.paused&&t){const e=t[this.hls.nextLoadLevel],n=this.fragLastKbps;r=n&&this.fragCurrent?this.fragCurrent.duration*e.maxBitrate/(1e3*n)+1:0}else r=0;const s=this.getBufferedFrag(e.currentTime+r);if(s){const t=this.followingBufferedFrag(s);if(t){this.abortCurrentFrag();const e=t.maxStartPTS?t.maxStartPTS:t.start,r=t.duration,n=Math.max(s.end,e+Math.min(Math.max(r-this.config.maxFragLookUpTolerance,r*(this.couldBacktrack?.5:.125)),r*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(n,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Dn:case In:case xn:case On:case Mn:this.state=Cn}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const r=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new Wa(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:t}=this;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const t=this.media,e=t?t.currentTime:null;R(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`)}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(I.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(t,e){let r=!1,n=!1;e.levels.forEach((t=>{const e=t.audioCodec;e&&(r=r||-1!==e.indexOf("mp4a.40.2"),n=n||-1!==e.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=r&&n&&!function(){var t;const e=Ha();return"function"==typeof(null==e||null==(t=e.prototype)?void 0:t.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){const{levels:r}=this;if(!r||this.state!==Cn)return;const n=r[e.level];(!n.details||n.details.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(n.details))&&(this.state=Un)}onLevelLoaded(t,e){var r;const{levels:n}=this,i=e.level,s=e.details,a=s.totalduration;if(!n)return void this.warn(`Levels were reset while loading level ${i}`);this.log(`Level ${i} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""}, cc [${s.startCC}, ${s.endCC}] duration:${a}`);const o=n[i],l=this.fragCurrent;!l||this.state!==In&&this.state!==xn||l.level!==e.level&&l.loader&&this.abortCurrentFrag();let c=0;if(s.live||null!=(r=o.details)&&r.live){var u;if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;c=this.alignPlaylists(s,o.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(o.details=s,this.levelLastLoaded=o,this.hls.trigger(I.LEVEL_UPDATED,{details:s,level:i}),this.state===Un){if(this.waitForCdnTuneIn(s))return;this.state=Cn}this.startFragRequested?s.live&&this.synchronizeToLiveEdge(s):this.setStartPosition(s,c),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:r,part:n,payload:i}=t,{levels:s}=this;if(!s)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const a=s[r.level],o=a.details;if(!o)return this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),void this.fragmentTracker.removeFragment(r);const l=a.videoCodec,c=o.PTSKnown||!o.live,u=null==(e=r.initSegment)?void 0:e.data,h=this._getAudioCodec(a),d=this.transmuxer=this.transmuxer||new Yi(this.hls,Ke,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=n?n.index:-1,p=-1!==f,g=new dn(r.level,r.sn,r.stats.chunkCount,i.byteLength,f,p),m=this.initPTS[r.cc];d.push(i,u,h,l,r,n,o.totalduration,c,g,m)}onAudioTrackSwitching(t,e){const r=this.altAudio;if(!!!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const t=this.fragCurrent;t&&(this.log("Switching to main audio track, cancel main fragment load"),t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const t=this.hls;r&&(t.trigger(I.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),t.trigger(I.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const r=e.id,n=!!this.hls.audioTracks[r].url;if(n){const t=this.videoBuffer;t&&this.mediaBuffer!==t&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=t)}this.altAudio=n,this.tick()}onBufferCreated(t,e){const r=e.tracks;let n,i,s=!1;for(const t in r){const e=r[t];if("main"===e.id){if(i=t,n=e,"video"===t){const e=r[t];e&&(this.videoBuffer=e.buffer)}}else s=!0}s&&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){const{frag:r,part:n}=e;if(r&&r.type!==Ke)return;if(this.fragContextChanged(r))return this.warn(`Fragment ${r.sn}${n?" p: "+n.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===Mn&&(this.state=Cn));const i=n?n.stats:r.stats;this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,n)}onError(t,e){var r;if(e.fatal)this.state=Bn;else switch(e.details){case P.FRAG_GAP:case P.FRAG_PARSING_ERROR:case P.FRAG_DECRYPT_ERROR:case P.FRAG_LOAD_ERROR:case P.FRAG_LOAD_TIMEOUT:case P.KEY_LOAD_ERROR:case P.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Ke,e);break;case P.LEVEL_LOAD_ERROR:case P.LEVEL_LOAD_TIMEOUT:case P.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Un||(null==(r=e.context)?void 0:r.type)!==$e||(this.state=Cn);break;case P.BUFFER_APPEND_ERROR:case P.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;if(e.details===P.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case P.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}checkBuffer(){const{media:t,gapController:e}=this;if(t&&e&&t.readyState){if(this.loadedmetadata||!hn.getBuffered(t).length){const t=this.state!==Cn?this.fragCurrent:null;e.poll(this.lastCurrentTime,t)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=Cn,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==V||this.audioOnly&&!this.altAudio){const t=(e===W?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(t,e,Ke),this.tick()}}onLevelsUpdated(t,e){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let r=this.startPosition;if(r>=0&&e0&&(i{const{hls:n}=this;if(!r||this.fragContextChanged(t))return;e.fragmentError=0,this.state=Cn,this.startFragRequested=!1,this.bitrateTest=!1;const i=t.stats;i.parsing.start=i.parsing.end=i.buffering.start=i.buffering.end=self.performance.now(),n.trigger(I.FRAG_LOADED,r),t.bitrateTest=!1}))}_handleTransmuxComplete(t){var e;const r="main",{hls:n}=this,{remuxResult:i,chunkMeta:s}=t,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:l,level:c}=a,{video:u,text:h,id3:d,initSegment:f}=i,{details:p}=c,g=this.altAudio?void 0:i.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=On,f){if(null!=f&&f.tracks){const t=o.initSegment||o;this._bufferInitSegment(c,f.tracks,t,s),n.trigger(I.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:r,tracks:f.tracks})}const t=f.initPTS,e=f.timescale;R(t)&&(this.initPTS[o.cc]={baseTime:t,timescale:e},n.trigger(I.INIT_PTS_FOUND,{frag:o,id:r,initPTS:t,timescale:e}))}if(u&&p&&"initSegment"!==o.sn){const t=p.fragments[o.sn-1-p.startSN],e=o.sn===p.startSN,r=!t||o.cc>t.cc;if(!1!==i.independent){const{startPTS:t,endPTS:n,startDTS:i,endDTS:a}=u;if(l)l.elementaryStreams[u.type]={startPTS:t,endPTS:n,startDTS:i,endDTS:a};else if(u.firstKeyFrame&&u.independent&&1===s.id&&!r&&(this.couldBacktrack=!0),u.dropped&&u.independent){const i=this.getMainFwdBufferInfo(),s=(i?i.end:this.getLoadPosition())+this.config.maxBufferHole,l=u.firstKeyFramePTS?u.firstKeyFramePTS:t;if(!e&&s2&&(o.gap=!0);o.setElementaryStreamInfo(u.type,t,n,i,a),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(u,o,l,s,e||r)}else{if(!e&&!r)return void this.backtrack(o);o.gap=!0}}if(g){const{startPTS:t,endPTS:e,startDTS:r,endDTS:n}=g;l&&(l.elementaryStreams[V]={startPTS:t,endPTS:e,startDTS:r,endDTS:n}),o.setElementaryStreamInfo(V,t,e,r,n),this.bufferFragmentData(g,o,l,s)}if(p&&null!=d&&null!=(e=d.samples)&&e.length){const t={id:r,frag:o,details:p,samples:d.samples};n.trigger(I.FRAG_PARSING_METADATA,t)}if(p&&h){const t={id:r,frag:o,details:p,samples:h.samples};n.trigger(I.FRAG_PARSING_USERDATA,t)}}}_bufferInitSegment(t,e,r,n){if(this.state!==On)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:i,video:s,audiovideo:a}=e;if(i){let e=t.audioCodec;const r=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){e&&(e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const t=i.metadata;t&&"channelCount"in t&&1!==(t.channelCount||1)&&-1===r.indexOf("firefox")&&(e="mp4a.40.5")}e&&-1!==e.indexOf("mp4a.40.5")&&-1!==r.indexOf("android")&&"audio/mpeg"!==i.container&&(e="mp4a.40.2",this.log(`Android: force audio codec to ${e}`)),t.audioCodec&&t.audioCodec!==e&&this.log(`Swapping manifest audio codec "${t.audioCodec}" for "${e}"`),i.levelCodec=e,i.id="main",this.log(`Init audio buffer, container:${i.container}, codecs[selected/level/parsed]=[${e||""}/${t.audioCodec||""}/${i.codec}]`)}s&&(s.levelCodec=t.videoCodec,s.id="main",this.log(`Init video buffer, container:${s.container}, codecs[level/parsed]=[${t.videoCodec||""}/${s.codec}]`)),a&&this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${t.codecs}/${a.codec}]`),this.hls.trigger(I.BUFFER_CODECS,e),Object.keys(e).forEach((t=>{const i=e[t].initSegment;null!=i&&i.byteLength&&this.hls.trigger(I.BUFFER_APPENDING,{type:t,data:i,frag:r,part:null,chunkMeta:n,parent:r.type})})),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Ke)}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=Cn}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&!1===t.seeking){const r=t.currentTime;if(hn.isBuffered(t,r)?e=this.getAppendedFrag(r):hn.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){this.backtrackFragment=null;const t=this.fragPlaying,r=e.level;t&&e.sn===t.sn&&t.level===r||(this.fragPlaying=e,this.hls.trigger(I.FRAG_CHANGED,{frag:e}),t&&t.level===r||this.hls.trigger(I.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){const t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}get currentProgramDateTime(){const t=this.media;if(t){const e=t.currentTime,r=this.currentFrag;if(r&&R(e)&&R(r.programDateTime)){const t=r.programDateTime+1e3*(e-r.start);return new Date(t)}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class qa{static get version(){return"1.5.17"}static isMSESupported(){return Va()}static isSupported(){return function(){if(!Va())return!1;const t=ge();return"function"==typeof(null==t?void 0:t.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((e=>t.isTypeSupported(Ee(e,"video"))))||["mp4a.40.2","fLaC"].some((e=>t.isTypeSupported(Ee(e,"audio")))))}()}static getMediaSource(){return ge()}static get Events(){return I}static get ErrorTypes(){return x}static get ErrorDetails(){return P}static get DefaultConfig(){return qa.defaultConfig?qa.defaultConfig:Ba}static set DefaultConfig(t){qa.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new Wi,this._autoLevelCapping=-1,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,this.triggeringException=void 0,function(t,e){if("object"==typeof console&&!0===t||"object"==typeof t){B(t,"debug","log","info","warn","error");try{F.log(`Debug logs enabled for "${e}" in hls.js version 1.5.17`)}catch(t){F=M}}else F=M}(t.debug||!1,"Hls instance");const e=this.config=function(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const r=Na(t),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((t=>{const i=`${"level"===t?"playlist":t}LoadPolicy`,s=void 0===e[i],a=[];n.forEach((n=>{const o=`${t}Loading${n}`,l=e[o];if(void 0!==l&&s){a.push(o);const t=r[i].default;switch(e[i]={default:t},n){case"TimeOut":t.maxLoadTimeMs=l,t.maxTimeToFirstByteMs=l;break;case"MaxRetry":t.errorRetry.maxNumRetry=l,t.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":t.errorRetry.retryDelayMs=l,t.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":t.errorRetry.maxRetryDelayMs=l,t.timeoutRetry.maxRetryDelayMs=l}}})),a.length&&N.warn(`hls.js config: "${a.join('", "')}" setting(s) are deprecated, use "${i}": ${JSON.stringify(e[i])}`)})),_(_({},r),e)}(qa.DefaultConfig,t);this.userConfig=t,e.progressive&&Ua(e);const{abrController:r,bufferController:n,capLevelController:i,errorController:s,fpsController:a}=e,o=new s(this),l=this.abrController=new r(this),c=this.bufferController=new n(this),u=this.capLevelController=new i(this),h=new a(this),d=new qe(this),f=new or(this),p=e.contentSteeringController,g=p?new p(this):null,m=this.levelController=new ja(this,g),y=new on(this),v=new Ka(this.config),E=this.streamController=new Ya(this,y,v);u.setStreamController(E),h.setStreamController(E);const b=[d,m,E];g&&b.splice(1,0,g),this.networkControllers=b;const T=[l,c,u,h,f,y];this.audioTrackController=this.createController(e.audioTrackController,b);const S=e.audioStreamController;S&&b.push(new S(this,y,v)),this.subtitleTrackController=this.createController(e.subtitleTrackController,b);const A=e.subtitleStreamController;A&&b.push(new A(this,y,v)),this.createController(e.timelineController,T),v.emeController=this.emeController=this.createController(e.emeController,T),this.cmcdController=this.createController(e.cmcdController,T),this.latencyController=this.createController(lr,T),this.coreComponents=T,b.push(o);const k=o.onErrorOut;"function"==typeof k&&this.on(I.ERROR,k,o)}createController(t,e){if(t){const r=new t(this);return e&&e.push(r),r}return 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(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){if(N.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),!this.triggeringException){this.triggeringException=!0;const r=t===I.ERROR;this.trigger(I.ERROR,{type:x.OTHER_ERROR,details:P.INTERNAL_EXCEPTION,fatal:r,event:t,error:e}),this.triggeringException=!1}}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){N.log("destroy"),this.trigger(I.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;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){N.log("attachMedia"),this._media=t,this.trigger(I.MEDIA_ATTACHING,{media:t})}detachMedia(){N.log("detachMedia"),this.trigger(I.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,r=this.url,n=this.url=S.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,N.log(`loadSource:${n}`),e&&r&&(r!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(I.MANIFEST_LOADING,{url:t})}startLoad(t=-1){N.log(`startLoad(${t})`),this.started=!0,this.networkControllers.forEach((e=>{e.startLoad(t)}))}stopLoad(){N.log("stopLoad"),this.started=!1,this.networkControllers.forEach((t=>{t.stopLoad()}))}resumeBuffering(){this.started&&this.networkControllers.forEach((t=>{"fragmentLoader"in t&&t.startLoad(-1)}))}pauseBuffering(){this.networkControllers.forEach((t=>{"fragmentLoader"in t&&t.stopLoad()}))}swapAudioCodec(){N.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){N.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t){this.levelController.removeLevel(t)}get levels(){const t=this.levelController.levels;return t||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){N.log(`set currentLevel:${t}`),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){N.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){N.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){N.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){const t=this.levelController.startLevel;return-1===t&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:t}set startLevel(t){N.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){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}set bandwidthEstimate(t){this.abrController.resetEstimator(t)}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(N.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){(function(t){return cr.indexOf(t)>-1})(t)&&this._maxHdcpLevel!==t&&(this._maxHdcpLevel=t,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const r=t.length;for(let n=0;n=e)return n;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:r}=this;let n;if(n=-1===e&&null!=t&&t.length?t.length-1:e,r)for(let e=n;e--;){const n=t[e].attrs["HDCP-LEVEL"];if(n&&n<=r)return e}return n}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(t){this.abrController.nextAutoLevel=t}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(t){var e;return null==(e=this.audioTrackController)?void 0:e.setAudioOption(t)}setSubtitleOption(t){var e;return null==(e=this.subtitleTrackController)||e.setSubtitleOption(t),null}get allAudioTracks(){const t=this.audioTrackController;return t?t.allAudioTracks:[]}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get allSubtitleTracks(){const t=this.subtitleTrackController;return t?t.allSubtitleTracks:[]}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return!!t&&t.subtitleDisplay}set subtitleDisplay(t){const 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 za(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function Xa(t){for(var e=1;e0&&(e=this._duration*(t/100)),this.seek(e)}},{key:"seek",value:function(t){t<0&&(E.c.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),t=this.getDuration()),this.dvrEnabled&&this._updateDvr(t0)switch(this._recoverAttemptsRemaining-=1,e.type){case qa.ErrorTypes.NETWORK_ERROR:switch(e.details){case qa.ErrorDetails.MANIFEST_LOAD_ERROR:case qa.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case qa.ErrorDetails.MANIFEST_PARSING_ERROR:case qa.ErrorDetails.LEVEL_LOAD_ERROR:case qa.ErrorDetails.LEVEL_LOAD_TIMEOUT:E.c.error("hlsjs: unrecoverable network fatal error.",{evt:t,data:e}),r=this.createError(n),this.trigger(E.a.PLAYBACK_ERROR,r),this.stop();break;default:E.c.warn("hlsjs: trying to recover from network error.",{evt:t,data:e}),n.level=E.e.Levels.WARN,this._hls.startLoad()}break;case qa.ErrorTypes.MEDIA_ERROR:E.c.warn("hlsjs: trying to recover from media error.",{evt:t,data:e}),n.level=E.e.Levels.WARN,this._recover(t,e,n);break;default:E.c.error("hlsjs: could not recover from error.",{evt:t,data:e}),r=this.createError(n),this.trigger(E.a.PLAYBACK_ERROR,r),this.stop()}else E.c.error("hlsjs: could not recover from error after maximum number of attempts.",{evt:t,data:e}),r=this.createError(n),this.trigger(E.a.PLAYBACK_ERROR,r),this.stop();else{if(this.options.playback.triggerFatalErrorOnResourceDenied&&this._keyIsDenied(e))return E.c.error("hlsjs: could not load decrypt key.",{evt:t,data:e}),r=this.createError(n),this.trigger(E.a.PLAYBACK_ERROR,r),void this.stop();n.level=E.e.Levels.WARN,E.c.warn("hlsjs: non-fatal error occurred",{evt:t,data:e})}}},{key:"_keyIsDenied",value:function(t){return t.type===qa.ErrorTypes.NETWORK_ERROR&&t.details===qa.ErrorDetails.KEY_LOAD_ERROR&&t.response&&t.response.code>=400}},{key:"_onTimeUpdate",value:function(){var t={current:this.getCurrentTime(),total:this.getDuration(),firstFragDateTime:this.getProgramDateTime()};this._lastTimeUpdate&&t.current===this._lastTimeUpdate.current&&t.total===this._lastTimeUpdate.total||(this._lastTimeUpdate=t,this.trigger(E.a.PLAYBACK_TIMEUPDATE,t,this.name))}},{key:"_onDurationChange",value:function(){var t=this.getDuration();this._lastDuration!==t&&(this._lastDuration=t,Ja(e,"_onDurationChange",this,3)([]))}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var t=[],e=0,r=0;r=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(E.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),Ja(e,"play",this,3)([]),this._startTimeUpdateTimer()}},{key:"pause",value:function(){this._hls&&(this.el.pause(),this.dvrEnabled&&this._updateDvr(!0))}},{key:"stop",value:function(){this._stopTimeUpdateTimer(),this._hls&&(Ja(e,"stop",this,3)([]),this._hls.destroy(),delete this._hls)}},{key:"destroy",value:function(){this._stopTimeUpdateTimer(),this._hls&&(this._hls.destroy(),delete this._hls),Ja(e,"destroy",this,3)([])}},{key:"_updatePlaybackType",value:function(t,e){this._playbackType=e.details.live?E.d.LIVE:E.d.VOD,this._onLevelUpdated(t,e),this._ccTracksUpdated&&this._playbackType===E.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(E.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=!1,n=!1,i=e.details.fragments,s=this._playableRegionStartTime,a=this._playableRegionDuration;if(0!==i.length){if(i[0].rawProgramDateTime&&(this._programDateTime=i[0].rawProgramDateTime),this._playableRegionStartTime!==i[0].start&&(r=!0,this._playableRegionStartTime=i[0].start),r)if(this._localStartTimeCorrelation){var o=this._localStartTimeCorrelation,l=this._now-o.local,c=(o.remote+l)/1e3;cs+this._extrapolatedWindowDuration&&(this._localStartTimeCorrelation={local:this._now,remote:1e3*Math.max(i[0].start,s+this._extrapolatedWindowDuration)})}else this._localStartTimeCorrelation={local:this._now,remote:1e3*(i[0].start+this._extrapolatedWindowDuration/2)};var u=e.details.totalduration;if(this._playbackType===E.d.LIVE){var h=e.details.targetduration*((this.options.playback.hlsjsConfig||{}).liveSyncDurationCount||qa.DefaultConfig.liveSyncDurationCount);h<=u?(u-=h,this._durationExcludesAfterLiveSyncPoint=!0):this._durationExcludesAfterLiveSyncPoint=!1}u!==this._playableRegionDuration&&(n=!0,this._playableRegionDuration=u);var d=i[0].start+u,f=s+a;if(d!==f)if(this._localEndTimeCorrelation){var p=this._localEndTimeCorrelation,g=this._now-p.local,m=(p.remote+g)/1e3;m>d?this._localEndTimeCorrelation={local:this._now,remote:1e3*d}:mf&&(this._localEndTimeCorrelation={local:this._now,remote:1e3*f})}else this._localEndTimeCorrelation={local:this._now,remote:1e3*d};n&&this._onDurationChange(),r&&this._onProgress()}}},{key:"_onFragmentChanged",value:function(t,e){var r=this.options.onTagCallback;r&&r(e.frag.tagList);this.trigger(E.a.Custom.PLAYBACK_FRAGMENT_CHANGED,e)}},{key:"_onFragmentLoaded",value:function(t,e){this.trigger(E.a.PLAYBACK_FRAGMENT_LOADED,e)}},{key:"_onSubtitleLoaded",value:function(){if(!this._ccIsSetup){this.trigger(E.a.PLAYBACK_SUBTITLE_AVAILABLE);var t=this._playbackType===E.d.LIVE?-1:this.closedCaptionsTrackId;this.closedCaptionsTrackId=t,this._ccIsSetup=!0}}},{key:"_onLevelSwitch",value:function(t,e){this.levels.length||this._fillLevels(),this.trigger(E.a.PLAYBACK_LEVEL_SWITCH_END),this.trigger(E.a.PLAYBACK_LEVEL_SWITCH,e);var r=this._hls.levels[e.level];r&&(this.highDefinition=r.height>=720||r.bitrate/1e3>=2e3,this.trigger(E.a.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(E.a.PLAYBACK_BITRATE,{height:r.height,width:r.width,bandwidth:r.bitrate,bitrate:r.bitrate,level:e.level}))}},{key:"dvrEnabled",get:function(){return this._durationExcludesAfterLiveSyncPoint&&this._duration>=this._minDvrSize&&this.getPlaybackType()===E.d.LIVE}},{key:"getPlaybackType",value:function(){return this._playbackType}},{key:"isSeekEnabled",value:function(){return this._playbackType===E.d.VOD||this.dvrEnabled}},{key:"checkIfCritical",value:function(){var t=this;this._options.mediaInfo.then((function(e){var r=e.criticalError,n=e.errorCodec;r&&(t._isReadyState=!1,t.stop(),t.trigger(E.a.PLAYBACK_ERROR,{UI:{title:"Playback error",message:"Could not play ".concat(n||"this"," codec")},raw:{response:{critical:!0}}}),t._hls&&t._hls.destroy())}))}}],[{key:"HLSJS",get:function(){return qa}}])}(E.b);ro.canPlay=function(t,e){var r=t.split("?")[0].match(/.*\.(.*)$/)||[],n=r.length>1&&"m3u8"===r[1].toLowerCase()||eo(e,["application/vnd.apple.mpegurl","application/x-mpegURL"]);return!(!qa.isSupported()||!n)}},,,,,,,,,,,,,,,,,,,,,,,function(t,e,r){"use strict";var n=r(382);t.exports=Function.prototype.bind||n},function(t,e,r){"use strict";var n=r(60)("%Object.defineProperty%",!0)||!1;if(n)try{n({},"a",{value:1})}catch(t){n=!1}t.exports=n},function(t,e,r){"use strict";var n=String.prototype.replace,i=/%20/g,s="RFC1738",a="RFC3986";t.exports={default:a,formatters:{RFC1738:function(t){return n.call(t,i,"+")},RFC3986:function(t){return String(t)}},RFC1738:s,RFC3986:a}},function(t,e,r){"use strict";var n=r(369),i=n.parse,s=n.Url;function a(t){var e=t.url;if(void 0!==e){var r=t._parsedUrl;return l(e,r)?r:((r=o(e))._raw=e,t._parsedUrl=r)}}function o(t){if("string"!=typeof t||47!==t.charCodeAt(0))return i(t);for(var e=t,r=null,n=null,a=1;a0&&(t._levels=n.filter((function(e){return e.content&&"audio"===e.content&&(t.audio=e),!(!e.content||"video"!==e.content)})).map((function(t,e){return{id:e,level:t.size||0,label:"".concat(t.bitrate,"Kbps"),bitrate:t.bitrate,track_id:t.track_id}})),t.trigger(A.Events.PLAYBACK_LEVELS_AVAILABLE,t._levels)),r(e)}},onProgress:function(){t.playingStarted=!0,t.trigger(A.Events.PLAYBACK_BUFFERFULL);var e=t.options.tracks;if(e&&e.length>=2&&!1!==t.firstPlay){var r=a()(e),n=[];r.forEach((function(t,e){(e+1)%2==0&&n.push(r[e-1]+r[e])})),t.MSE.setTracks(n),t.firstPlay=!1}},onStartStalling:function(){t.trigger(A.Events.PLAYBACK_BUFFERING)},onEndStalling:function(){t.trigger(A.Events.PLAYBACK_BUFFERFULL)},onPause:function(){t.trigger(A.Events.PLAYBACK_STOP)},onEvent:function(t){}}),this.MSE}},{key:"_startTimeUpdateTimer",value:function(){var t=this;this._timeUpdateTimer=setInterval((function(){t._onTimeUpdate()}),100)}},{key:"_onTimeUpdate",value:function(){var t={current:this.getCurrentTime(),total:this.getDuration()};this._lastTimeUpdate&&t.current===this._lastTimeUpdate.current||(this._lastTimeUpdate=t,this.trigger(A.Events.PLAYBACK_TIMEUPDATE,t,this.name))}},{key:"_updateSettings",value:function(){this.settings.left=["playstop"],this.trigger(A.Events.PLAYBACK_SETTINGSUPDATE)}},{key:"_onDurationChange",value:function(){var t=this.getDuration();this._lastDuration!==t&&(this._lastDuration=t,C(e,"_onDurationChange",this,3)([]))}},{key:"_stopTimeUpdateTimer",value:function(){clearInterval(this._timeUpdateTimer)}},{key:"getPlaybackType",value:function(){return A.Playback.LIVE}},{key:"destroy",value:function(){var t=this;this.playPromise?(this.playPromise.catch((function(){t.stop()})).finally((function(){t.stop()})),this._stopTimeUpdateTimer(),C(e,"destroy",this,3)([])):this.mustDestroy=!0}},{key:"resolveRedirect",value:function(t){return fetch(t,{method:"OPTIONS"}).catch((function(e){return t})).then((function(e){return e.headers&&e.headers.get("location")?e.headers.get("location"):t}))}},{key:"getStartTimeOffset",value:function(){return this.getCurrentTime()}},{key:"_handleBufferingEvents",value:function(){}},{key:"isSeekEnabled",value:function(){return!1}},{key:"attemptAutoPlay",value:(r=i()(S.a.mark((function t(){var e=this;return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.checkIfCritical().then((function(){e.criticalError||e.MSE||(e.init(),e._onProgress=e.MSE.onProgress.bind(e),e.play())}));case 2:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"_onError",value:function(){}},{key:"play",value:function(){var t=this;this.criticalError||this.playingStarted||(this.trigger(A.Events.PLAYBACK_PLAY_INTENT),this.MSE||this.init(),this.playPromise=this.MSE.play(),this.playPromise&&this.playPromise.then((function(){t._ready(),t.playingStarted=!0,t._stopped=!1,t.trigger(A.Events.PLAYBACK_BUFFERING),t.mustDestroy&&t.destroy()})).catch((function(){t.mustDestroy&&t.destroy()})).finally((function(){t.trigger(A.Events.MEDIACONTROL_PLAYING)})),this._startTimeUpdateTimer())}},{key:"pause",value:function(){this.MSE&&(this._paused?(this.MSE.play(),this._paused=!1):(this.MSE.pause(),this._paused=!0))}},{key:"isPlaying",value:function(){return this.playingStarted||!1}},{key:"setTracks",value:function(t){var e=-1===t?0:t;if(this.MSE){var r;this.audio&&this.audio.track_id&&(r=this.audio.track_id);var n=[];this._levels[e]&&n.push(this._levels[e].track_id),void 0!==r&&n.push(r),n.length>0&&this.MSE.setTracks(n)}this.trigger(A.Events.PLAYBACK_LEVEL_SWITCH_END)}},{key:"getStats",value:function(){return this.MSE.getStats()}},{key:"_ready",value:function(){this.trigger(A.Events.PLAYBACK_READY)}},{key:"setWaitStatus",value:function(t){this._waitStatus=t}},{key:"stop",value:function(){this.MSE?(this.MSE.stop(),C(e,"stop",this,3)([]),this.trigger(A.Events.PLAYBACK_STOP),this.playingStarted=!1,this.MSE=void 0):this.mustDestroy=!0}},{key:"checkIfCritical",value:function(){var t=this;return new Promise((function(e,r){t._options.mediaInfo.then((function(r){var n=r.criticalError,i=r.errorCodec;return n&&(t.destroy(),t.criticalError=!0,t.stop(),t.trigger(A.Events.PLAYBACK_ERROR,{UI:{title:"Playback error",message:"Could not play ".concat(i||"this"," codec")},raw:{response:{critical:!0}}})),e()}))}))}}],[{key:"MSELD",get:function(){return e}}]);var r}(A.HTML5Video);D.isSupported=function(){return k.a.isSupported()},D.canPlay=function(t,e){return(-1!==t.indexOf("mse_ld")||"application/x-flussonic-mse"===e)&&D.isSupported()}},function(t,e,r){var n=r(61).default,i=r(206);t.exports=function(t){var e=i(t,"string");return"symbol"==n(e)?e:e+""},t.exports.__esModule=!0,t.exports.default=t.exports},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r1;){var e=t.pop(),r=e.obj[e.prop];if(s(r)){for(var n=[],i=0;i=l?o.slice(u,u+l):o,d=[],f=0;f=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||s===n.RFC1738&&(40===p||41===p)?d[d.length]=h.charAt(f):p<128?d[d.length]=a[p]:p<2048?d[d.length]=a[192|p>>6]+a[128|63&p]:p<55296||p>=57344?d[d.length]=a[224|p>>12]+a[128|p>>6&63]+a[128|63&p]:(f+=1,p=65536+((1023&p)<<10|1023&h.charCodeAt(f)),d[d.length]=a[240|p>>18]+a[128|p>>12&63]+a[128|p>>6&63]+a[128|63&p])}c+=d.join("")}return c},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(s(t)){for(var r=[],n=0;n=0&&h.splice(e,1)}function y(t){var e=document.createElement("style");if(void 0===t.attrs.type&&(t.attrs.type="text/css"),void 0===t.attrs.nonce){var n=function(){0;return r.nc}();n&&(t.attrs.nonce=n)}return v(e,t.attrs),g(t,e),e}function v(t,e){Object.keys(e).forEach((function(r){t.setAttribute(r,e[r])}))}function E(t,e){var r,n,i,s;if(e.transform&&t.css){if(!(s="function"==typeof e.transform?e.transform(t.css):e.transform.default(t.css)))return function(){};t.css=s}if(e.singleton){var a=u++;r=c||(c=y(e)),n=S.bind(null,r,a,!1),i=S.bind(null,r,a,!0)}else t.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(r=function(t){var e=document.createElement("link");return void 0===t.attrs.type&&(t.attrs.type="text/css"),t.attrs.rel="stylesheet",v(e,t.attrs),g(t,e),e}(e),n=_.bind(null,r,e),i=function(){m(r),r.href&&URL.revokeObjectURL(r.href)}):(r=y(e),n=A.bind(null,r),i=function(){m(r)});return n(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;n(t=e)}else i()}}t.exports=function(t,e){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(e=e||{}).attrs="object"==typeof e.attrs?e.attrs:{},e.singleton||"boolean"==typeof e.singleton||(e.singleton=a()),e.insertInto||(e.insertInto="head"),e.insertAt||(e.insertAt="bottom");var r=p(t,e);return f(r,e),function(t){for(var n=[],i=0;i0&&void 0!==arguments[0])||arguments[0];return p.f(l,t)},this.getMediaInfo=i()(d.a.mark((function t(){var e,r,n;return d.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=p.d(l),r=p.i(),n={criticalError:!1},t.next=5,fetch(e).then((function(t){return t.json()})).then((function(t){n=m(m({},n),t),t.tracks.forEach((function(t){var e=t.codec;if(e)switch(e){case"mp2v":n.criticalError=!0,n.errorCodec=e;break;case"hevc":if(r)return;n.criticalError=!0,n.errorCodec=e}}))}));case 5:return t.abrupt("return",n);case 6:case"end":return t.stop()}}),t)})))}))},function(t,e,r){(function(t,n){var i;(function(){var s,a="Expected a function",o="__lodash_hash_undefined__",l="__lodash_placeholder__",c=16,u=32,h=64,d=128,f=256,p=1/0,g=9007199254740991,m=NaN,y=4294967295,v=[["ary",d],["bind",1],["bindKey",2],["curry",8],["curryRight",c],["flip",512],["partial",u],["partialRight",h],["rearg",f]],E="[object Arguments]",b="[object Array]",T="[object Boolean]",S="[object Date]",A="[object Error]",_="[object Function]",k="[object GeneratorFunction]",L="[object Map]",w="[object Number]",R="[object Object]",C="[object Promise]",D="[object RegExp]",I="[object Set]",x="[object String]",P="[object Symbol]",O="[object WeakMap]",M="[object ArrayBuffer]",F="[object DataView]",B="[object Float32Array]",N="[object Float64Array]",U="[object Int8Array]",$="[object Int16Array]",j="[object Int32Array]",G="[object Uint8Array]",K="[object Uint8ClampedArray]",H="[object Uint16Array]",V="[object Uint32Array]",W=/\b__p \+= '';/g,Y=/\b(__p \+=) '' \+/g,q=/(__e\(.*?\)|\b__t\)) \+\n'';/g,z=/&(?:amp|lt|gt|quot|#39);/g,X=/[&<>"']/g,Q=RegExp(z.source),J=RegExp(X.source),Z=/<%-([\s\S]+?)%>/g,tt=/<%([\s\S]+?)%>/g,et=/<%=([\s\S]+?)%>/g,rt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nt=/^\w*$/,it=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,st=/[\\^$.*+?()[\]{}|]/g,at=RegExp(st.source),ot=/^\s+/,lt=/\s/,ct=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ut=/\{\n\/\* \[wrapped with (.+)\] \*/,ht=/,? & /,dt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ft=/[()=,{}\[\]\/\s]/,pt=/\\(\\)?/g,gt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,mt=/\w*$/,yt=/^[-+]0x[0-9a-f]+$/i,vt=/^0b[01]+$/i,Et=/^\[object .+?Constructor\]$/,bt=/^0o[0-7]+$/i,Tt=/^(?:0|[1-9]\d*)$/,St=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,At=/($^)/,_t=/['\n\r\u2028\u2029\\]/g,kt="\\ud800-\\udfff",Lt="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",wt="\\u2700-\\u27bf",Rt="a-z\\xdf-\\xf6\\xf8-\\xff",Ct="A-Z\\xc0-\\xd6\\xd8-\\xde",Dt="\\ufe0e\\ufe0f",It="\\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",xt="['’]",Pt="["+kt+"]",Ot="["+It+"]",Mt="["+Lt+"]",Ft="\\d+",Bt="["+wt+"]",Nt="["+Rt+"]",Ut="[^"+kt+It+Ft+wt+Rt+Ct+"]",$t="\\ud83c[\\udffb-\\udfff]",jt="[^"+kt+"]",Gt="(?:\\ud83c[\\udde6-\\uddff]){2}",Kt="[\\ud800-\\udbff][\\udc00-\\udfff]",Ht="["+Ct+"]",Vt="\\u200d",Wt="(?:"+Nt+"|"+Ut+")",Yt="(?:"+Ht+"|"+Ut+")",qt="(?:['’](?:d|ll|m|re|s|t|ve))?",zt="(?:['’](?:D|LL|M|RE|S|T|VE))?",Xt="(?:"+Mt+"|"+$t+")"+"?",Qt="["+Dt+"]?",Jt=Qt+Xt+("(?:"+Vt+"(?:"+[jt,Gt,Kt].join("|")+")"+Qt+Xt+")*"),Zt="(?:"+[Bt,Gt,Kt].join("|")+")"+Jt,te="(?:"+[jt+Mt+"?",Mt,Gt,Kt,Pt].join("|")+")",ee=RegExp(xt,"g"),re=RegExp(Mt,"g"),ne=RegExp($t+"(?="+$t+")|"+te+Jt,"g"),ie=RegExp([Ht+"?"+Nt+"+"+qt+"(?="+[Ot,Ht,"$"].join("|")+")",Yt+"+"+zt+"(?="+[Ot,Ht+Wt,"$"].join("|")+")",Ht+"?"+Wt+"+"+qt,Ht+"+"+zt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Ft,Zt].join("|"),"g"),se=RegExp("["+Vt+kt+Lt+Dt+"]"),ae=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,oe=["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"],le=-1,ce={};ce[B]=ce[N]=ce[U]=ce[$]=ce[j]=ce[G]=ce[K]=ce[H]=ce[V]=!0,ce[E]=ce[b]=ce[M]=ce[T]=ce[F]=ce[S]=ce[A]=ce[_]=ce[L]=ce[w]=ce[R]=ce[D]=ce[I]=ce[x]=ce[O]=!1;var ue={};ue[E]=ue[b]=ue[M]=ue[F]=ue[T]=ue[S]=ue[B]=ue[N]=ue[U]=ue[$]=ue[j]=ue[L]=ue[w]=ue[R]=ue[D]=ue[I]=ue[x]=ue[P]=ue[G]=ue[K]=ue[H]=ue[V]=!0,ue[A]=ue[_]=ue[O]=!1;var he={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},de=parseFloat,fe=parseInt,pe="object"==typeof t&&t&&t.Object===Object&&t,ge="object"==typeof self&&self&&self.Object===Object&&self,me=pe||ge||Function("return this")(),ye=e&&!e.nodeType&&e,ve=ye&&"object"==typeof n&&n&&!n.nodeType&&n,Ee=ve&&ve.exports===ye,be=Ee&&pe.process,Te=function(){try{var t=ve&&ve.require&&ve.require("util").types;return t||be&&be.binding&&be.binding("util")}catch(t){}}(),Se=Te&&Te.isArrayBuffer,Ae=Te&&Te.isDate,_e=Te&&Te.isMap,ke=Te&&Te.isRegExp,Le=Te&&Te.isSet,we=Te&&Te.isTypedArray;function Re(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 Ce(t,e,r,n){for(var i=-1,s=null==t?0:t.length;++i-1}function Me(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function ir(t,e){for(var r=t.length;r--&&He(e,t[r],0)>-1;);return r}var sr=ze({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),ar=ze({"&":"&","<":"<",">":">",'"':""","'":"'"});function or(t){return"\\"+he[t]}function lr(t){return se.test(t)}function cr(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function ur(t,e){return function(r){return t(e(r))}}function hr(t,e){for(var r=-1,n=t.length,i=0,s=[];++r",""":'"',"'":"'"});var vr=function t(e){var r,n=(e=null==e?me:vr.defaults(me.Object(),e,vr.pick(me,oe))).Array,i=e.Date,lt=e.Error,kt=e.Function,Lt=e.Math,wt=e.Object,Rt=e.RegExp,Ct=e.String,Dt=e.TypeError,It=n.prototype,xt=kt.prototype,Pt=wt.prototype,Ot=e["__core-js_shared__"],Mt=xt.toString,Ft=Pt.hasOwnProperty,Bt=0,Nt=(r=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",Ut=Pt.toString,$t=Mt.call(wt),jt=me._,Gt=Rt("^"+Mt.call(Ft).replace(st,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Kt=Ee?e.Buffer:s,Ht=e.Symbol,Vt=e.Uint8Array,Wt=Kt?Kt.allocUnsafe:s,Yt=ur(wt.getPrototypeOf,wt),qt=wt.create,zt=Pt.propertyIsEnumerable,Xt=It.splice,Qt=Ht?Ht.isConcatSpreadable:s,Jt=Ht?Ht.iterator:s,Zt=Ht?Ht.toStringTag:s,te=function(){try{var t=ds(wt,"defineProperty");return t({},"",{}),t}catch(t){}}(),ne=e.clearTimeout!==me.clearTimeout&&e.clearTimeout,se=i&&i.now!==me.Date.now&&i.now,he=e.setTimeout!==me.setTimeout&&e.setTimeout,pe=Lt.ceil,ge=Lt.floor,ye=wt.getOwnPropertySymbols,ve=Kt?Kt.isBuffer:s,be=e.isFinite,Te=It.join,je=ur(wt.keys,wt),ze=Lt.max,Er=Lt.min,br=i.now,Tr=e.parseInt,Sr=Lt.random,Ar=It.reverse,_r=ds(e,"DataView"),kr=ds(e,"Map"),Lr=ds(e,"Promise"),wr=ds(e,"Set"),Rr=ds(e,"WeakMap"),Cr=ds(wt,"create"),Dr=Rr&&new Rr,Ir={},xr=Ns(_r),Pr=Ns(kr),Or=Ns(Lr),Mr=Ns(wr),Fr=Ns(Rr),Br=Ht?Ht.prototype:s,Nr=Br?Br.valueOf:s,Ur=Br?Br.toString:s;function $r(t){if(eo(t)&&!Ha(t)&&!(t instanceof Hr)){if(t instanceof Kr)return t;if(Ft.call(t,"__wrapped__"))return Us(t)}return new Kr(t)}var jr=function(){function t(){}return function(e){if(!to(e))return{};if(qt)return qt(e);t.prototype=e;var r=new t;return t.prototype=s,r}}();function Gr(){}function Kr(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=s}function Hr(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=y,this.__views__=[]}function Vr(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function cn(t,e,r,n,i,a){var o,l=1&e,c=2&e,u=4&e;if(r&&(o=i?r(t,n,i,a):r(t)),o!==s)return o;if(!to(t))return t;var h=Ha(t);if(h){if(o=function(t){var e=t.length,r=new t.constructor(e);e&&"string"==typeof t[0]&&Ft.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!l)return Di(t,o)}else{var d=gs(t),f=d==_||d==k;if(qa(t))return _i(t,l);if(d==R||d==E||f&&!i){if(o=c||f?{}:ys(t),!l)return c?function(t,e){return Ii(t,ps(t),e)}(t,function(t,e){return t&&Ii(e,Po(e),t)}(o,t)):function(t,e){return Ii(t,fs(t),e)}(t,sn(o,t))}else{if(!ue[d])return i?t:{};o=function(t,e,r){var n=t.constructor;switch(e){case M:return ki(t);case T:case S:return new n(+t);case F:return function(t,e){var r=e?ki(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case B:case N:case U:case $:case j:case G:case K:case H:case V:return Li(t,r);case L:return new n;case w:case x:return new n(t);case D:return function(t){var e=new t.constructor(t.source,mt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case I:return new n;case P:return i=t,Nr?wt(Nr.call(i)):{}}var i}(t,d,l)}}a||(a=new zr);var p=a.get(t);if(p)return p;a.set(t,o),ao(t)?t.forEach((function(n){o.add(cn(n,e,r,n,t,a))})):ro(t)&&t.forEach((function(n,i){o.set(i,cn(n,e,r,i,t,a))}));var g=h?s:(u?c?ss:is:c?Po:xo)(t);return De(g||t,(function(n,i){g&&(n=t[i=n]),en(o,i,cn(n,e,r,i,t,a))})),o}function un(t,e,r){var n=r.length;if(null==t)return!n;for(t=wt(t);n--;){var i=r[n],a=e[i],o=t[i];if(o===s&&!(i in t)||!a(o))return!1}return!0}function hn(t,e,r){if("function"!=typeof t)throw new Dt(a);return Is((function(){t.apply(s,r)}),e)}function dn(t,e,r,n){var i=-1,s=Oe,a=!0,o=t.length,l=[],c=e.length;if(!o)return l;r&&(e=Fe(e,tr(r))),n?(s=Me,a=!1):e.length>=200&&(s=rr,a=!1,e=new qr(e));t:for(;++i-1},Wr.prototype.set=function(t,e){var r=this.__data__,n=rn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},Yr.prototype.clear=function(){this.size=0,this.__data__={hash:new Vr,map:new(kr||Wr),string:new Vr}},Yr.prototype.delete=function(t){var e=us(this,t).delete(t);return this.size-=e?1:0,e},Yr.prototype.get=function(t){return us(this,t).get(t)},Yr.prototype.has=function(t){return us(this,t).has(t)},Yr.prototype.set=function(t,e){var r=us(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},qr.prototype.add=qr.prototype.push=function(t){return this.__data__.set(t,o),this},qr.prototype.has=function(t){return this.__data__.has(t)},zr.prototype.clear=function(){this.__data__=new Wr,this.size=0},zr.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},zr.prototype.get=function(t){return this.__data__.get(t)},zr.prototype.has=function(t){return this.__data__.has(t)},zr.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Wr){var n=r.__data__;if(!kr||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Yr(n)}return r.set(t,e),this.size=r.size,this};var fn=Oi(Tn),pn=Oi(Sn,!0);function gn(t,e){var r=!0;return fn(t,(function(t,n,i){return r=!!e(t,n,i)})),r}function mn(t,e,r){for(var n=-1,i=t.length;++n0&&r(o)?e>1?vn(o,e-1,r,n,i):Be(i,o):n||(i[i.length]=o)}return i}var En=Mi(),bn=Mi(!0);function Tn(t,e){return t&&En(t,e,xo)}function Sn(t,e){return t&&bn(t,e,xo)}function An(t,e){return Pe(e,(function(e){return Qa(t[e])}))}function _n(t,e){for(var r=0,n=(e=bi(e,t)).length;null!=t&&re}function Rn(t,e){return null!=t&&Ft.call(t,e)}function Cn(t,e){return null!=t&&e in wt(t)}function Dn(t,e,r){for(var i=r?Me:Oe,a=t[0].length,o=t.length,l=o,c=n(o),u=1/0,h=[];l--;){var d=t[l];l&&e&&(d=Fe(d,tr(e))),u=Er(d.length,u),c[l]=!r&&(e||a>=120&&d.length>=120)?new qr(l&&d):s}d=t[0];var f=-1,p=c[0];t:for(;++f=o?l:l*("desc"==r[n]?-1:1)}return t.index-e.index}(t,e,r)}))}function Wn(t,e,r){for(var n=-1,i=e.length,s={};++n-1;)o!==t&&Xt.call(o,l,1),Xt.call(t,l,1);return t}function qn(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==s){var s=i;Es(i)?Xt.call(t,i,1):di(t,i)}}return t}function zn(t,e){return t+ge(Sr()*(e-t+1))}function Xn(t,e){var r="";if(!t||e<1||e>g)return r;do{e%2&&(r+=t),(e=ge(e/2))&&(t+=t)}while(e);return r}function Qn(t,e){return xs(ws(t,e,il),t+"")}function Jn(t){return Qr(jo(t))}function Zn(t,e){var r=jo(t);return Ms(r,ln(e,0,r.length))}function ti(t,e,r,n){if(!to(t))return t;for(var i=-1,a=(e=bi(e,t)).length,o=a-1,l=t;null!=l&&++is?0:s+e),(r=r>s?s:r)<0&&(r+=s),s=e>r?0:r-e>>>0,e>>>=0;for(var a=n(s);++i>>1,a=t[s];null!==a&&!lo(a)&&(r?a<=e:a=200){var c=e?null:Xi(t);if(c)return dr(c);a=!1,i=rr,l=new qr}else l=e?[]:o;t:for(;++n=n?t:ii(t,e,r)}var Ai=ne||function(t){return me.clearTimeout(t)};function _i(t,e){if(e)return t.slice();var r=t.length,n=Wt?Wt(r):new t.constructor(r);return t.copy(n),n}function ki(t){var e=new t.constructor(t.byteLength);return new Vt(e).set(new Vt(t)),e}function Li(t,e){var r=e?ki(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function wi(t,e){if(t!==e){var r=t!==s,n=null===t,i=t==t,a=lo(t),o=e!==s,l=null===e,c=e==e,u=lo(e);if(!l&&!u&&!a&&t>e||a&&o&&c&&!l&&!u||n&&o&&c||!r&&c||!i)return 1;if(!n&&!a&&!u&&t1?r[i-1]:s,o=i>2?r[2]:s;for(a=t.length>3&&"function"==typeof a?(i--,a):s,o&&bs(r[0],r[1],o)&&(a=i<3?s:a,i=1),e=wt(e);++n-1?i[a?e[o]:o]:s}}function $i(t){return ns((function(e){var r=e.length,n=r,i=Kr.prototype.thru;for(t&&e.reverse();n--;){var o=e[n];if("function"!=typeof o)throw new Dt(a);if(i&&!l&&"wrapper"==os(o))var l=new Kr([],!0)}for(n=l?n:r;++n1&&b.reverse(),f&&ul))return!1;var u=a.get(t),h=a.get(e);if(u&&h)return u==e&&h==t;var d=-1,f=!0,p=2&r?new qr:s;for(a.set(t,e),a.set(e,t);++d-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(ct,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return De(v,(function(r){var n="_."+r[0];e&r[1]&&!Oe(t,n)&&t.push(n)})),t.sort()}(function(t){var e=t.match(ut);return e?e[1].split(ht):[]}(n),r)))}function Os(t){var e=0,r=0;return function(){var n=br(),i=16-(n-r);if(r=n,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(s,arguments)}}function Ms(t,e){var r=-1,n=t.length,i=n-1;for(e=e===s?n:e;++r1?t[e-1]:s;return r="function"==typeof r?(t.pop(),r):s,sa(t,r)}));function da(t){var e=$r(t);return e.__chain__=!0,e}function fa(t,e){return e(t)}var pa=ns((function(t){var e=t.length,r=e?t[0]:0,n=this.__wrapped__,i=function(e){return on(e,t)};return!(e>1||this.__actions__.length)&&n instanceof Hr&&Es(r)?((n=n.slice(r,+r+(e?1:0))).__actions__.push({func:fa,args:[i],thisArg:s}),new Kr(n,this.__chain__).thru((function(t){return e&&!t.length&&t.push(s),t}))):this.thru(i)}));var ga=xi((function(t,e,r){Ft.call(t,r)?++t[r]:an(t,r,1)}));var ma=Ui(Ks),ya=Ui(Hs);function va(t,e){return(Ha(t)?De:fn)(t,cs(e,3))}function Ea(t,e){return(Ha(t)?Ie:pn)(t,cs(e,3))}var ba=xi((function(t,e,r){Ft.call(t,r)?t[r].push(e):an(t,r,[e])}));var Ta=Qn((function(t,e,r){var i=-1,s="function"==typeof e,a=Wa(t)?n(t.length):[];return fn(t,(function(t){a[++i]=s?Re(e,t,r):In(t,e,r)})),a})),Sa=xi((function(t,e,r){an(t,r,e)}));function Aa(t,e){return(Ha(t)?Fe:$n)(t,cs(e,3))}var _a=xi((function(t,e,r){t[r?0:1].push(e)}),(function(){return[[],[]]}));var ka=Qn((function(t,e){if(null==t)return[];var r=e.length;return r>1&&bs(t,e[0],e[1])?e=[]:r>2&&bs(e[0],e[1],e[2])&&(e=[e[0]]),Vn(t,vn(e,1),[])})),La=se||function(){return me.Date.now()};function wa(t,e,r){return e=r?s:e,e=t&&null==e?t.length:e,Ji(t,d,s,s,s,s,e)}function Ra(t,e){var r;if("function"!=typeof e)throw new Dt(a);return t=go(t),function(){return--t>0&&(r=e.apply(this,arguments)),t<=1&&(e=s),r}}var Ca=Qn((function(t,e,r){var n=1;if(r.length){var i=hr(r,ls(Ca));n|=u}return Ji(t,n,e,r,i)})),Da=Qn((function(t,e,r){var n=3;if(r.length){var i=hr(r,ls(Da));n|=u}return Ji(e,n,t,r,i)}));function Ia(t,e,r){var n,i,o,l,c,u,h=0,d=!1,f=!1,p=!0;if("function"!=typeof t)throw new Dt(a);function g(e){var r=n,a=i;return n=i=s,h=e,l=t.apply(a,r)}function m(t){var r=t-u;return u===s||r>=e||r<0||f&&t-h>=o}function y(){var t=La();if(m(t))return v(t);c=Is(y,function(t){var r=e-(t-u);return f?Er(r,o-(t-h)):r}(t))}function v(t){return c=s,p&&n?g(t):(n=i=s,l)}function E(){var t=La(),r=m(t);if(n=arguments,i=this,u=t,r){if(c===s)return function(t){return h=t,c=Is(y,e),d?g(t):l}(u);if(f)return Ai(c),c=Is(y,e),g(u)}return c===s&&(c=Is(y,e)),l}return e=yo(e)||0,to(r)&&(d=!!r.leading,o=(f="maxWait"in r)?ze(yo(r.maxWait)||0,e):o,p="trailing"in r?!!r.trailing:p),E.cancel=function(){c!==s&&Ai(c),h=0,n=u=i=c=s},E.flush=function(){return c===s?l:v(La())},E}var xa=Qn((function(t,e){return hn(t,1,e)})),Pa=Qn((function(t,e,r){return hn(t,yo(e)||0,r)}));function Oa(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new Dt(a);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var a=t.apply(this,n);return r.cache=s.set(i,a)||s,a};return r.cache=new(Oa.Cache||Yr),r}function Ma(t){if("function"!=typeof t)throw new Dt(a);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}Oa.Cache=Yr;var Fa=Ti((function(t,e){var r=(e=1==e.length&&Ha(e[0])?Fe(e[0],tr(cs())):Fe(vn(e,1),tr(cs()))).length;return Qn((function(n){for(var i=-1,s=Er(n.length,r);++i=e})),Ka=xn(function(){return arguments}())?xn:function(t){return eo(t)&&Ft.call(t,"callee")&&!zt.call(t,"callee")},Ha=n.isArray,Va=Se?tr(Se):function(t){return eo(t)&&Ln(t)==M};function Wa(t){return null!=t&&Za(t.length)&&!Qa(t)}function Ya(t){return eo(t)&&Wa(t)}var qa=ve||yl,za=Ae?tr(Ae):function(t){return eo(t)&&Ln(t)==S};function Xa(t){if(!eo(t))return!1;var e=Ln(t);return e==A||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!io(t)}function Qa(t){if(!to(t))return!1;var e=Ln(t);return e==_||e==k||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Ja(t){return"number"==typeof t&&t==go(t)}function Za(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=g}function to(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function eo(t){return null!=t&&"object"==typeof t}var ro=_e?tr(_e):function(t){return eo(t)&&gs(t)==L};function no(t){return"number"==typeof t||eo(t)&&Ln(t)==w}function io(t){if(!eo(t)||Ln(t)!=R)return!1;var e=Yt(t);if(null===e)return!0;var r=Ft.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&Mt.call(r)==$t}var so=ke?tr(ke):function(t){return eo(t)&&Ln(t)==D};var ao=Le?tr(Le):function(t){return eo(t)&&gs(t)==I};function oo(t){return"string"==typeof t||!Ha(t)&&eo(t)&&Ln(t)==x}function lo(t){return"symbol"==typeof t||eo(t)&&Ln(t)==P}var co=we?tr(we):function(t){return eo(t)&&Za(t.length)&&!!ce[Ln(t)]};var uo=Yi(Un),ho=Yi((function(t,e){return t<=e}));function fo(t){if(!t)return[];if(Wa(t))return oo(t)?gr(t):Di(t);if(Jt&&t[Jt])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[Jt]());var e=gs(t);return(e==L?cr:e==I?dr:jo)(t)}function po(t){return t?(t=yo(t))===p||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function go(t){var e=po(t),r=e%1;return e==e?r?e-r:e:0}function mo(t){return t?ln(go(t),0,y):0}function yo(t){if("number"==typeof t)return t;if(lo(t))return m;if(to(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=to(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Ze(t);var r=vt.test(t);return r||bt.test(t)?fe(t.slice(2),r?2:8):yt.test(t)?m:+t}function vo(t){return Ii(t,Po(t))}function Eo(t){return null==t?"":ui(t)}var bo=Pi((function(t,e){if(_s(e)||Wa(e))Ii(e,xo(e),t);else for(var r in e)Ft.call(e,r)&&en(t,r,e[r])})),To=Pi((function(t,e){Ii(e,Po(e),t)})),So=Pi((function(t,e,r,n){Ii(e,Po(e),t,n)})),Ao=Pi((function(t,e,r,n){Ii(e,xo(e),t,n)})),_o=ns(on);var ko=Qn((function(t,e){t=wt(t);var r=-1,n=e.length,i=n>2?e[2]:s;for(i&&bs(e[0],e[1],i)&&(n=1);++r1),e})),Ii(t,ss(t),r),n&&(r=cn(r,7,es));for(var i=e.length;i--;)di(r,e[i]);return r}));var Bo=ns((function(t,e){return null==t?{}:function(t,e){return Wn(t,e,(function(e,r){return Ro(t,r)}))}(t,e)}));function No(t,e){if(null==t)return{};var r=Fe(ss(t),(function(t){return[t]}));return e=cs(e),Wn(t,r,(function(t,r){return e(t,r[0])}))}var Uo=Qi(xo),$o=Qi(Po);function jo(t){return null==t?[]:er(t,xo(t))}var Go=Bi((function(t,e,r){return e=e.toLowerCase(),t+(r?Ko(e):e)}));function Ko(t){return Qo(Eo(t).toLowerCase())}function Ho(t){return(t=Eo(t))&&t.replace(St,sr).replace(re,"")}var Vo=Bi((function(t,e,r){return t+(r?"-":"")+e.toLowerCase()})),Wo=Bi((function(t,e,r){return t+(r?" ":"")+e.toLowerCase()})),Yo=Fi("toLowerCase");var qo=Bi((function(t,e,r){return t+(r?"_":"")+e.toLowerCase()}));var zo=Bi((function(t,e,r){return t+(r?" ":"")+Qo(e)}));var Xo=Bi((function(t,e,r){return t+(r?" ":"")+e.toUpperCase()})),Qo=Fi("toUpperCase");function Jo(t,e,r){return t=Eo(t),(e=r?s:e)===s?function(t){return ae.test(t)}(t)?function(t){return t.match(ie)||[]}(t):function(t){return t.match(dt)||[]}(t):t.match(e)||[]}var Zo=Qn((function(t,e){try{return Re(t,s,e)}catch(t){return Xa(t)?t:new lt(t)}})),tl=ns((function(t,e){return De(e,(function(e){e=Bs(e),an(t,e,Ca(t[e],t))})),t}));function el(t){return function(){return t}}var rl=$i(),nl=$i(!0);function il(t){return t}function sl(t){return Fn("function"==typeof t?t:cn(t,1))}var al=Qn((function(t,e){return function(r){return In(r,t,e)}})),ol=Qn((function(t,e){return function(r){return In(t,r,e)}}));function ll(t,e,r){var n=xo(e),i=An(e,n);null!=r||to(e)&&(i.length||!n.length)||(r=e,e=t,t=this,i=An(e,xo(e)));var s=!(to(r)&&"chain"in r&&!r.chain),a=Qa(t);return De(i,(function(r){var n=e[r];t[r]=n,a&&(t.prototype[r]=function(){var e=this.__chain__;if(s||e){var r=t(this.__wrapped__);return(r.__actions__=Di(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,Be([this.value()],arguments))})})),t}function cl(){}var ul=Hi(Fe),hl=Hi(xe),dl=Hi($e);function fl(t){return Ts(t)?qe(Bs(t)):function(t){return function(e){return _n(e,t)}}(t)}var pl=Wi(),gl=Wi(!0);function ml(){return[]}function yl(){return!1}var vl=Ki((function(t,e){return t+e}),0),El=zi("ceil"),bl=Ki((function(t,e){return t/e}),1),Tl=zi("floor");var Sl,Al=Ki((function(t,e){return t*e}),1),_l=zi("round"),kl=Ki((function(t,e){return t-e}),0);return $r.after=function(t,e){if("function"!=typeof e)throw new Dt(a);return t=go(t),function(){if(--t<1)return e.apply(this,arguments)}},$r.ary=wa,$r.assign=bo,$r.assignIn=To,$r.assignInWith=So,$r.assignWith=Ao,$r.at=_o,$r.before=Ra,$r.bind=Ca,$r.bindAll=tl,$r.bindKey=Da,$r.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Ha(t)?t:[t]},$r.chain=da,$r.chunk=function(t,e,r){e=(r?bs(t,e,r):e===s)?1:ze(go(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var a=0,o=0,l=n(pe(i/e));ai?0:i+r),(n=n===s||n>i?i:go(n))<0&&(n+=i),n=r>n?0:mo(n);r>>0)?(t=Eo(t))&&("string"==typeof e||null!=e&&!so(e))&&!(e=ui(e))&&lr(t)?Si(gr(t),0,r):t.split(e,r):[]},$r.spread=function(t,e){if("function"!=typeof t)throw new Dt(a);return e=null==e?0:ze(go(e),0),Qn((function(r){var n=r[e],i=Si(r,0,e);return n&&Be(i,n),Re(t,this,i)}))},$r.tail=function(t){var e=null==t?0:t.length;return e?ii(t,1,e):[]},$r.take=function(t,e,r){return t&&t.length?ii(t,0,(e=r||e===s?1:go(e))<0?0:e):[]},$r.takeRight=function(t,e,r){var n=null==t?0:t.length;return n?ii(t,(e=n-(e=r||e===s?1:go(e)))<0?0:e,n):[]},$r.takeRightWhile=function(t,e){return t&&t.length?pi(t,cs(e,3),!1,!0):[]},$r.takeWhile=function(t,e){return t&&t.length?pi(t,cs(e,3)):[]},$r.tap=function(t,e){return e(t),t},$r.throttle=function(t,e,r){var n=!0,i=!0;if("function"!=typeof t)throw new Dt(a);return to(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),Ia(t,e,{leading:n,maxWait:e,trailing:i})},$r.thru=fa,$r.toArray=fo,$r.toPairs=Uo,$r.toPairsIn=$o,$r.toPath=function(t){return Ha(t)?Fe(t,Bs):lo(t)?[t]:Di(Fs(Eo(t)))},$r.toPlainObject=vo,$r.transform=function(t,e,r){var n=Ha(t),i=n||qa(t)||co(t);if(e=cs(e,4),null==r){var s=t&&t.constructor;r=i?n?new s:[]:to(t)&&Qa(s)?jr(Yt(t)):{}}return(i?De:Tn)(t,(function(t,n,i){return e(r,t,n,i)})),r},$r.unary=function(t){return wa(t,1)},$r.union=ea,$r.unionBy=ra,$r.unionWith=na,$r.uniq=function(t){return t&&t.length?hi(t):[]},$r.uniqBy=function(t,e){return t&&t.length?hi(t,cs(e,2)):[]},$r.uniqWith=function(t,e){return e="function"==typeof e?e:s,t&&t.length?hi(t,s,e):[]},$r.unset=function(t,e){return null==t||di(t,e)},$r.unzip=ia,$r.unzipWith=sa,$r.update=function(t,e,r){return null==t?t:fi(t,e,Ei(r))},$r.updateWith=function(t,e,r,n){return n="function"==typeof n?n:s,null==t?t:fi(t,e,Ei(r),n)},$r.values=jo,$r.valuesIn=function(t){return null==t?[]:er(t,Po(t))},$r.without=aa,$r.words=Jo,$r.wrap=function(t,e){return Ba(Ei(e),t)},$r.xor=oa,$r.xorBy=la,$r.xorWith=ca,$r.zip=ua,$r.zipObject=function(t,e){return yi(t||[],e||[],en)},$r.zipObjectDeep=function(t,e){return yi(t||[],e||[],ti)},$r.zipWith=ha,$r.entries=Uo,$r.entriesIn=$o,$r.extend=To,$r.extendWith=So,ll($r,$r),$r.add=vl,$r.attempt=Zo,$r.camelCase=Go,$r.capitalize=Ko,$r.ceil=El,$r.clamp=function(t,e,r){return r===s&&(r=e,e=s),r!==s&&(r=(r=yo(r))==r?r:0),e!==s&&(e=(e=yo(e))==e?e:0),ln(yo(t),e,r)},$r.clone=function(t){return cn(t,4)},$r.cloneDeep=function(t){return cn(t,5)},$r.cloneDeepWith=function(t,e){return cn(t,5,e="function"==typeof e?e:s)},$r.cloneWith=function(t,e){return cn(t,4,e="function"==typeof e?e:s)},$r.conformsTo=function(t,e){return null==e||un(t,e,xo(e))},$r.deburr=Ho,$r.defaultTo=function(t,e){return null==t||t!=t?e:t},$r.divide=bl,$r.endsWith=function(t,e,r){t=Eo(t),e=ui(e);var n=t.length,i=r=r===s?n:ln(go(r),0,n);return(r-=e.length)>=0&&t.slice(r,i)==e},$r.eq=$a,$r.escape=function(t){return(t=Eo(t))&&J.test(t)?t.replace(X,ar):t},$r.escapeRegExp=function(t){return(t=Eo(t))&&at.test(t)?t.replace(st,"\\$&"):t},$r.every=function(t,e,r){var n=Ha(t)?xe:gn;return r&&bs(t,e,r)&&(e=s),n(t,cs(e,3))},$r.find=ma,$r.findIndex=Ks,$r.findKey=function(t,e){return Ge(t,cs(e,3),Tn)},$r.findLast=ya,$r.findLastIndex=Hs,$r.findLastKey=function(t,e){return Ge(t,cs(e,3),Sn)},$r.floor=Tl,$r.forEach=va,$r.forEachRight=Ea,$r.forIn=function(t,e){return null==t?t:En(t,cs(e,3),Po)},$r.forInRight=function(t,e){return null==t?t:bn(t,cs(e,3),Po)},$r.forOwn=function(t,e){return t&&Tn(t,cs(e,3))},$r.forOwnRight=function(t,e){return t&&Sn(t,cs(e,3))},$r.get=wo,$r.gt=ja,$r.gte=Ga,$r.has=function(t,e){return null!=t&&ms(t,e,Rn)},$r.hasIn=Ro,$r.head=Ws,$r.identity=il,$r.includes=function(t,e,r,n){t=Wa(t)?t:jo(t),r=r&&!n?go(r):0;var i=t.length;return r<0&&(r=ze(i+r,0)),oo(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&He(t,e,r)>-1},$r.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:go(r);return i<0&&(i=ze(n+i,0)),He(t,e,i)},$r.inRange=function(t,e,r){return e=po(e),r===s?(r=e,e=0):r=po(r),function(t,e,r){return t>=Er(e,r)&&t=-9007199254740991&&t<=g},$r.isSet=ao,$r.isString=oo,$r.isSymbol=lo,$r.isTypedArray=co,$r.isUndefined=function(t){return t===s},$r.isWeakMap=function(t){return eo(t)&&gs(t)==O},$r.isWeakSet=function(t){return eo(t)&&"[object WeakSet]"==Ln(t)},$r.join=function(t,e){return null==t?"":Te.call(t,e)},$r.kebabCase=Vo,$r.last=Xs,$r.lastIndexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=n;return r!==s&&(i=(i=go(r))<0?ze(n+i,0):Er(i,n-1)),e==e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,i):Ke(t,We,i,!0)},$r.lowerCase=Wo,$r.lowerFirst=Yo,$r.lt=uo,$r.lte=ho,$r.max=function(t){return t&&t.length?mn(t,il,wn):s},$r.maxBy=function(t,e){return t&&t.length?mn(t,cs(e,2),wn):s},$r.mean=function(t){return Ye(t,il)},$r.meanBy=function(t,e){return Ye(t,cs(e,2))},$r.min=function(t){return t&&t.length?mn(t,il,Un):s},$r.minBy=function(t,e){return t&&t.length?mn(t,cs(e,2),Un):s},$r.stubArray=ml,$r.stubFalse=yl,$r.stubObject=function(){return{}},$r.stubString=function(){return""},$r.stubTrue=function(){return!0},$r.multiply=Al,$r.nth=function(t,e){return t&&t.length?Hn(t,go(e)):s},$r.noConflict=function(){return me._===this&&(me._=jt),this},$r.noop=cl,$r.now=La,$r.pad=function(t,e,r){t=Eo(t);var n=(e=go(e))?pr(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return Vi(ge(i),r)+t+Vi(pe(i),r)},$r.padEnd=function(t,e,r){t=Eo(t);var n=(e=go(e))?pr(t):0;return e&&ne){var n=t;t=e,e=n}if(r||t%1||e%1){var i=Sr();return Er(t+i*(e-t+de("1e-"+((i+"").length-1))),e)}return zn(t,e)},$r.reduce=function(t,e,r){var n=Ha(t)?Ne:Xe,i=arguments.length<3;return n(t,cs(e,4),r,i,fn)},$r.reduceRight=function(t,e,r){var n=Ha(t)?Ue:Xe,i=arguments.length<3;return n(t,cs(e,4),r,i,pn)},$r.repeat=function(t,e,r){return e=(r?bs(t,e,r):e===s)?1:go(e),Xn(Eo(t),e)},$r.replace=function(){var t=arguments,e=Eo(t[0]);return t.length<3?e:e.replace(t[1],t[2])},$r.result=function(t,e,r){var n=-1,i=(e=bi(e,t)).length;for(i||(i=1,t=s);++ng)return[];var r=y,n=Er(t,y);e=cs(e),t-=y;for(var i=Je(n,e);++r=a)return t;var l=r-pr(n);if(l<1)return n;var c=o?Si(o,0,l).join(""):t.slice(0,l);if(i===s)return c+n;if(o&&(l+=c.length-l),so(i)){if(t.slice(l).search(i)){var u,h=c;for(i.global||(i=Rt(i.source,Eo(mt.exec(i))+"g")),i.lastIndex=0;u=i.exec(h);)var d=u.index;c=c.slice(0,d===s?l:d)}}else if(t.indexOf(ui(i),l)!=l){var f=c.lastIndexOf(i);f>-1&&(c=c.slice(0,f))}return c+n},$r.unescape=function(t){return(t=Eo(t))&&Q.test(t)?t.replace(z,yr):t},$r.uniqueId=function(t){var e=++Bt;return Eo(t)+e},$r.upperCase=Xo,$r.upperFirst=Qo,$r.each=va,$r.eachRight=Ea,$r.first=Ws,ll($r,(Sl={},Tn($r,(function(t,e){Ft.call($r.prototype,e)||(Sl[e]=t)})),Sl),{chain:!1}),$r.VERSION="4.17.21",De(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){$r[t].placeholder=$r})),De(["drop","take"],(function(t,e){Hr.prototype[t]=function(r){r=r===s?1:ze(go(r),0);var n=this.__filtered__&&!e?new Hr(this):this.clone();return n.__filtered__?n.__takeCount__=Er(r,n.__takeCount__):n.__views__.push({size:Er(r,y),type:t+(n.__dir__<0?"Right":"")}),n},Hr.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),De(["filter","map","takeWhile"],(function(t,e){var r=e+1,n=1==r||3==r;Hr.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:cs(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}})),De(["head","last"],(function(t,e){var r="take"+(e?"Right":"");Hr.prototype[t]=function(){return this[r](1).value()[0]}})),De(["initial","tail"],(function(t,e){var r="drop"+(e?"":"Right");Hr.prototype[t]=function(){return this.__filtered__?new Hr(this):this[r](1)}})),Hr.prototype.compact=function(){return this.filter(il)},Hr.prototype.find=function(t){return this.filter(t).head()},Hr.prototype.findLast=function(t){return this.reverse().find(t)},Hr.prototype.invokeMap=Qn((function(t,e){return"function"==typeof t?new Hr(this):this.map((function(r){return In(r,t,e)}))})),Hr.prototype.reject=function(t){return this.filter(Ma(cs(t)))},Hr.prototype.slice=function(t,e){t=go(t);var r=this;return r.__filtered__&&(t>0||e<0)?new Hr(r):(t<0?r=r.takeRight(-t):t&&(r=r.drop(t)),e!==s&&(r=(e=go(e))<0?r.dropRight(-e):r.take(e-t)),r)},Hr.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Hr.prototype.toArray=function(){return this.take(y)},Tn(Hr.prototype,(function(t,e){var r=/^(?:filter|find|map|reject)|While$/.test(e),n=/^(?:head|last)$/.test(e),i=$r[n?"take"+("last"==e?"Right":""):e],a=n||/^find/.test(e);i&&($r.prototype[e]=function(){var e=this.__wrapped__,o=n?[1]:arguments,l=e instanceof Hr,c=o[0],u=l||Ha(e),h=function(t){var e=i.apply($r,Be([t],o));return n&&d?e[0]:e};u&&r&&"function"==typeof c&&1!=c.length&&(l=u=!1);var d=this.__chain__,f=!!this.__actions__.length,p=a&&!d,g=l&&!f;if(!a&&u){e=g?e:new Hr(this);var m=t.apply(e,o);return m.__actions__.push({func:fa,args:[h],thisArg:s}),new Kr(m,d)}return p&&g?t.apply(this,o):(m=this.thru(h),p?n?m.value()[0]:m.value():m)})})),De(["pop","push","shift","sort","splice","unshift"],(function(t){var e=It[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);$r.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Ha(i)?i:[],t)}return this[r]((function(r){return e.apply(Ha(r)?r:[],t)}))}})),Tn(Hr.prototype,(function(t,e){var r=$r[e];if(r){var n=r.name+"";Ft.call(Ir,n)||(Ir[n]=[]),Ir[n].push({name:e,func:r})}})),Ir[ji(s,2).name]=[{name:"wrapper",func:s}],Hr.prototype.clone=function(){var t=new Hr(this.__wrapped__);return t.__actions__=Di(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Di(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Di(this.__views__),t},Hr.prototype.reverse=function(){if(this.__filtered__){var t=new Hr(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Hr.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=Ha(t),n=e<0,i=r?t.length:0,s=function(t,e,r){var n=-1,i=r.length;for(;++n=this.__values__.length;return{done:t,value:t?s:this.__values__[this.__index__++]}},$r.prototype.plant=function(t){for(var e,r=this;r instanceof Gr;){var n=Us(r);n.__index__=0,n.__values__=s,e?i.__wrapped__=n:e=n;var i=n;r=r.__wrapped__}return i.__wrapped__=t,e},$r.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Hr){var e=t;return this.__actions__.length&&(e=new Hr(this)),(e=e.reverse()).__actions__.push({func:fa,args:[ta],thisArg:s}),new Kr(e,this.__chain__)}return this.thru(ta)},$r.prototype.toJSON=$r.prototype.valueOf=$r.prototype.value=function(){return gi(this.__wrapped__,this.__actions__)},$r.prototype.first=$r.prototype.head,Jt&&($r.prototype[Jt]=function(){return this}),$r}();me._=vr,(i=function(){return vr}.call(e,r,e,n))===s||(n.exports=i)}).call(this)}).call(this,r(31),r(156)(t))},function(t,e,r){var n=r(366),i=r(367),s=r(155),a=r(368);t.exports=function(t,e){return n(t)||i(t,e)||s(t,e)||a()},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){"use strict";(function(t){r.d(e,"a",(function(){return E}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(8),d=r.n(h),f=r(1),p=r(167),g=r.n(p),m=r(168),y=r.n(m);function v(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(v=function(){return!!t})()}var E=function(e){function r(){return i()(this,r),t=this,e=r,n=arguments,e=u()(e),l()(t,v()?Reflect.construct(e,n||[],u()(t).constructor):e.apply(t,n));var t,e,n}return d()(r,e),a()(r,[{key:"name",get:function(){return"level_selector"}},{key:"template",get:function(){return Object(f.template)(g.a)}},{key:"supportedVersion",get:function(){return{min:f.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.activeContainer:this.core.mediaControl.container}},{key:"playback",get:function(){return this.core.activePlayback?this.core.activePlayback:this.core.getCurrentPlayback()}},{key:"bindEvents",value:function(){this.listenTo(this.core,f.Events.CORE_READY,this.bindPlaybackEvents),f.Events.CORE_ACTIVE_CONTAINER_CHANGED?this.listenTo(this.core,f.Events.CORE_ACTIVE_CONTAINER_CHANGED,this.reload):this.listenTo(this.core.mediaControl,f.Events.MEDIACONTROL_CONTAINERCHANGED,this.reload),this.listenTo(this.core.mediaControl,f.Events.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,f.Events.MEDIACONTROL_HIDE,this.hideSelectLevelMenu)}},{key:"bindPlaybackEvents",value:function(){this.playback&&(this.listenTo(this.playback,f.Events.PLAYBACK_LEVELS_AVAILABLE,this.fillLevels),this.listenTo(this.playback,f.Events.PLAYBACK_LEVEL_SWITCH_START,this.startLevelSwitch),this.listenTo(this.playback,f.Events.PLAYBACK_LEVEL_SWITCH_END,this.stopLevelSwitch),this.listenTo(this.playback,f.Events.PLAYBACK_BITRATE,this.updateCurrentLevel),this.playback.levels&&this.playback.levels.length>0&&this.fillLevels(this.playback.levels))}},{key:"reload",value:function(){var e=this;this.stopListening(),t.nextTick((function(){e.bindEvents(),e.bindPlaybackEvents()}))}},{key:"shouldRender",value:function(){if(!this.container||!this.playback)return!1;var t=void 0!==this.playback.currentLevel,e=!!(this.levels&&this.levels.length>1);return t&&e}},{key:"render",value:function(){if(this.shouldRender()){var t=f.Styler.getStyleFor(y.a,{baseUrl:this.core.options.baseUrl});this.$el.html(this.template({levels:this.levels,title:this.getTitle()})),this.$el.append(t),this.core.mediaControl.$(".media-control-right-panel").append(this.el),this.$(".level_selector ul").css("max-height",.8*this.core.el.offsetHeight),this.highlightCurrentLevel()}return this}},{key:"fillLevels",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;void 0===this.selectedLevelId&&(this.selectedLevelId=e);var r=this.core.options&&this.core.options.levelSelectorConfig&&this.core.options.levelSelectorConfig.onLevelsAvailable;if(r){if("function"!=typeof r)throw new TypeError("onLevelsAvailable must be a function");t=r(t.slice())}t.forEach((function(t){var e=t.level;if(Object.keys(e).length){var r=e.height;t.resolution="".concat(r,"p")}})),this.levels=t,this.configureLevelsLabels(),this.render()}},{key:"configureLevelsLabels",value:function(){if(void 0!==this.core.options.levelSelectorConfig){var t=this.core.options.levelSelectorConfig.labelCallback;if(t&&"function"!=typeof t)throw new TypeError("labelCallback must be a function");var e,r,n=this.core.options.levelSelectorConfig.labels,i=n?this.core.options.levelSelectorConfig.labels:{};if(t||n)for(var s in this.levels)r=i[(e=this.levels[s]).id],t?e.label=t(e,r):r&&(e.label=r)}}},{key:"findLevelBy",value:function(t){var e;return this.levels.forEach((function(r){r.id===t&&(e=r)})),e}},{key:"onLevelSelect",value:function(t){return this.selectedLevelId=parseInt(t.target.dataset.levelSelectorSelect,10),this.playback.currentLevel==this.selectedLevelId||(this.playback.currentLevel=this.selectedLevelId,this.toggleContextMenu(),t.stopPropagation()),!1}},{key:"onShowLevelSelectMenu",value:function(){this.toggleContextMenu()}},{key:"hideSelectLevelMenu",value:function(){this.$(".level_selector ul").hide()}},{key:"toggleContextMenu",value:function(){this.$(".level_selector ul").toggle()}},{key:"buttonElement",value:function(){return this.$(".level_selector button")}},{key:"levelElement",value:function(t){return this.$(".level_selector ul a".concat(isNaN(t)?"":'[data-level-selector-select="'.concat(t,'"]'))).parent()}},{key:"getTitle",value:function(){return(this.core.options.levelSelectorConfig||{}).title}},{key:"startLevelSwitch",value:function(){this.buttonElement().addClass("changing")}},{key:"stopLevelSwitch",value:function(){this.buttonElement().removeClass("changing")}},{key:"updateText",value:function(t){-1===t?this.buttonElement().text(this.currentLevel?"AUTO (".concat(this.currentLevel.resolution,")"):"AUTO"):this.buttonElement().text(this.findLevelBy(t).resolution)}},{key:"updateCurrentLevel",value:function(t){var e=this.findLevelBy(t.level);this.currentLevel=e||null,this.highlightCurrentLevel()}},{key:"highlightCurrentLevel",value:function(){this.levelElement().removeClass("current"),this.currentLevel&&this.levelElement(this.currentLevel.id).addClass("current"),this.updateText(this.selectedLevelId)}}],[{key:"version",get:function(){return"24.6.1"}}])}(f.UICorePlugin)}).call(this,r(76))},function(t,e){t.exports='\n'},function(t,e,r){var n=r(392);"string"==typeof n&&(n=[[t.i,n,""]]);var i={hmr:!0,transform:undefined,insertInto:void 0};r(161)(n,i);n.locals&&(t.exports=n.locals)},function(t,e,r){"use strict";r.d(e,"a",(function(){return L}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(15),d=r.n(h),f=r(8),p=r.n(f),g=r(1),m=r(90),y=r.n(m),v=r(170),E=r.n(v),b=r(171),T=r.n(b),S=r(91);function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(A=function(){return!!t})()}function _(t,e,r,n){var i=d()(u()(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}var k="blinkPoster",L=function(t){function e(t){var r,n,s,a;return i()(this,e),n=this,s=e,a=[t],s=u()(s),(r=l()(n,A()?Reflect.construct(s,a||[],u()(n).constructor):s.apply(n,a))).startBlinkPoster(),r.container=t,r}return p()(e,t),a()(e,[{key:"name",get:function(){return"poster"}},{key:"bindEvents",value:function(){_(e,"bindEvents",this,3)([]),this.listenTo(this.container,g.Events.CONTAINER_OPTIONS_CHANGE,this.changeOptsRuntime)}},{key:"destroy",value:function(){_(e,"destroy",this,3)([]),this.stopBlinkPoster()}},{key:"changeOptsRuntime",value:function(){this.options[k]?this.startBlinkPoster():this.stopBlinkPoster()}},{key:"startBlinkPoster",value:function(){if(this.options[k]&&!this.hasStartedPlaying){var 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(){_(e,"onStop",this,3)([]),this.startBlinkPoster()}},{key:"onPlay",value:function(){_(e,"onPlay",this,3)([]),this.stopBlinkPoster()}},{key:"posterChangeSource",value:function(){var t=this,e=this.options.authToken?"&":"?",r=this.getPosterSource({postfix:"".concat(e,"_t=").concat(Number(new Date))});this.setPosterSource(r).then((function(){t.posterTimer=setTimeout(t.posterChangeSource,5e3)}))}},{key:"templateVideo",get:function(){return Object(g.template)(T.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(t){var e=this;return Object(S.b)(this.$el[0])?new Promise((function(r){var n=e._videoPoster,i=e.$el.find(".poster-video:not(.visible)");i.one("loadeddata",(function(){n.removeClass("visible"),i.addClass("visible"),e._videoPoster=i,r()})),i.attr({src:t})})):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(g.template)(E.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(y.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=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).postfix,e=this.options.poster.url||this.options.poster;return t?"".concat(e).concat(t):e}},{key:"render",value:function(){if(this.shouldRender)return this.renderVideoPoster(),this.renderPlayButton(),this.update(),this}}])}(g.Poster)},function(t,e,r){},function(t,e){t.exports='
\n
\n'},function(t,e,r){"use strict";r.d(e,"a",(function(){return E}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(8),d=r.n(h),f=r(1),p=r(90),g=r.n(p),m=r(173),y=r.n(m);function v(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(v=function(){return!!t})()}var E=function(t){function e(t){var r,n,s,a;return i()(this,e),n=this,s=e,a=[t],s=u()(s),(r=l()(n,v()?Reflect.construct(s,a||[],u()(n).constructor):s.apply(n,a))).container=t,r}return d()(e,t),a()(e,[{key:"setPosterStyles",value:function(){this.$el.append(''),this.$el.find(".clappr-style").html(Object(f.template)(y.a.toString()))}},{key:"render",value:function(){var t=this;if(this.shouldRender){if(this.$el[0].addEventListener("touchstart",(function(){t.container.play()})),this.$el.html(this.template()),this.setPosterStyles(),this.options.poster&&null==this.options.poster.custom){var e=this.options.poster.url||this.options.poster;this.$el.css({"background-image":"url(".concat(e,")")})}else 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(g.a),this.$playButton=this.$playWrapper.find("svg"),this.$playButton.addClass("poster-icon"),this.$playButton.attr("data-poster","");var r=this.options.mediacontrol&&this.options.mediacontrol.buttons;return r&&this.$el.find("svg path").css("fill",r),this.options.mediacontrol&&this.options.mediacontrol.buttons&&(r=this.options.mediacontrol.buttons,this.$playButton.css("color",r)),this.update(),this}}}])}(f.Poster)},function(t,e,r){},function(t,e,r){"use strict";r.d(e,"a",(function(){return S}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(8),u=r.n(c),h=r(3),d=r.n(h),f=r(15),p=r.n(f),g=r(1),m=r(91),y=r(175),v=r.n(y),E=r(176),b=r.n(E);function T(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(T=function(){return!!t})()}var S=function(t){function e(t){var r,n,s,a;return i()(this,e),n=this,s=e,a=[t],s=d()(s),(r=l()(n,T()?Reflect.construct(s,a||[],d()(n).constructor):s.apply(n,a))).hasStartedPlaying=!1,r.playRequested=!1,r.render(),r}return u()(e,t),a()(e,[{key:"name",get:function(){return"logo"}},{key:"template",get:function(){return Object(g.template)(v.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),(g.Browser.isSafari||g.Browser.isIE)&&this.container.playback.el.addEventListener("loadeddata",this.setPositionBinded),this.listenTo(this.container,g.Events.CONTAINER_STOP,this.onStop),this.listenTo(this.container,g.Events.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,g.Events.CONTAINER_LOADEDMETADATA,this.setPositionBinded)}},{key:"stopListening",value:function(){var t,r,n,i,s;window.removeEventListener("resize",this.setPositionBinded),(g.Browser.isSafari||g.Browser.isIE)&&window.removeEventListener("loadeddata",this.setPositionBinded),(t=e,r="stopListening",n=this,i=3,s=p()(d()(1&i?t.prototype:t),r,n),2&i&&"function"==typeof s?function(t){return s.apply(n,t)}:s)([])}},{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,i=void 0===n?60:n,s=e.height,a=void 0===s?60:s,o=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(o?"?".concat(o):""),style:"width: ".concat(i,"px;height: ").concat(a,"px;")})}},{key:"setPosition",value:function(){if(this.shouldRender){var t=this.container,e=t.$el,r=t.currentSize,n=e.find("video[data-html5-video]").get(0),i=n.videoWidth,s=n.videoHeight,a=Object(m.a)({dom:{width:r.width,height:r.height},media:{width:i,height:s}}),o=this.options.logo,l=a.letterboxing,c=l.vertical,u=l.horizontal,h=this.$logoContainer.get(0);this.setStyles(o,["top","bottom"],h,c),this.setStyles(o,["left","right"],h,u),this.update()}}},{key:"setStyles",value:function(t,e,r,n){var i=this;e.forEach((function(e){return i.setStyle(t,e,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(g.template)(b.a.toString()))}}])}(g.UIContainerPlugin)},function(t,e){t.exports='\n'},function(t,e,r){},function(t,e,r){"use strict";r.d(e,"a",(function(){return g}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(8),d=r.n(h),f=r(1);function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}var g=function(t){function e(){return i()(this,e),t=this,r=e,n=arguments,r=u()(r),l()(t,p()?Reflect.construct(r,n||[],u()(t).constructor):r.apply(t,n));var t,r,n}return d()(e,t),a()(e,[{key:"name",get:function(){return"volumePlugin"}},{key:"bindEvents",value:function(){this.container.options.volume>0?this.listenToOnce(this.container,f.Events.CONTAINER_MEDIACONTROL_ENABLE,this.setInitialVolume):this.enabled=!1}},{key:"setInitialVolume",value:function(){this.container.setVolume(this.container.options.volume)}}])}(f.ContainerPlugin)},function(t,e,r){"use strict";r.d(e,"a",(function(){return E}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(15),d=r.n(h),f=r(8),p=r.n(f),g=r(1),m=r(26);function y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(y=function(){return!!t})()}function v(t,e,r,n){var i=d()(u()(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}var E=function(t){function e(){return i()(this,e),t=this,r=e,n=arguments,r=u()(r),l()(t,y()?Reflect.construct(r,n||[],u()(t).constructor):r.apply(t,n));var t,r,n}return p()(e,t),a()(e,[{key:"name",get:function(){return"StreamStatusPlugin"}},{key:"bindEvents",value:function(){var t=this;if("mseld"===this.container.playback.name)return this.listenTo(this.container.playback,g.Events.PLAYBACK_BUFFERING,this.waitForTime(5e3)),void this.listenTo(this.container.playback,g.Events.PLAYBACK_BUFFERFULL,(function(){return t._buffering=!1}));this.listenTo(this.container.playback,g.Events.PLAYBACK_ERROR,this.startListenStatus)}},{key:"startListenStatus",value:function(t){"mseld"!==this.container.playback.name&&(!t||t&&t.data&&"networkError"!==t.data.type)||(this._statusUrl=Object(m.a)(this.container.options,"info.json"),this.checkStatus=this.checkStatus.bind(this),clearInterval(this.timerStatus),this.timerStatus=setInterval(this.checkStatus,1e3))}},{key:"waitForTime",value:function(t){var e=this;return function(){e._buffering=!0,setTimeout((function(){e._buffering&&e.startListenStatus()}),t)}}},{key:"checkStatus",value:function(){var t=this;fetch(this._statusUrl).then((function(e){404===e.status&&(t.container.playback.setWaitStatus&&t.container.playback.setWaitStatus(!0),t.container.playback.stop()),200===e.status&&(clearInterval(t.timerStatus),t.container.playback.setWaitStatus&&t.container.playback.setWaitStatus(!1))}))}},{key:"disable",value:function(){clearInterval(this.timerStatus),v(e,"disable",this,3)([])}},{key:"destroy",value:function(){clearInterval(this.timerStatus),v(e,"destroy",this,3)([])}}])}(g.UIContainerPlugin)},function(t,e,r){"use strict";r.d(e,"a",(function(){return g}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(8),d=r.n(h),f=r(1);function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}var g=function(t){function e(){return i()(this,e),t=this,r=e,n=arguments,r=u()(r),l()(t,p()?Reflect.construct(r,n||[],u()(t).constructor):r.apply(t,n));var t,r,n}return d()(e,t),a()(e,[{key:"name",get:function(){return"DebugPlugin"}},{key:"bindEvents",value:function(){for(var t in f.Events)"register"!==t&&"listAvailableCustomEvents"!==t&&this.listenTo(this.container.playback,f.Events[t],this.fireEvent.bind(this,t))}},{key:"fireEvent",value:function(t){console.log(t)}}])}(f.UIContainerPlugin)},function(t,e,r){"use strict";var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(15),d=r.n(h),f=r(8),p=r.n(f),g=r(1),m=r(55),y=r.n(m);function v(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(v=function(){return!!t})()}function E(t,e,r,n){var i=d()(u()(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}var b=function(t){function e(){var t,r,n,s;i()(this,e);for(var a=arguments.length,o=new Array(a),c=0;c=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(g.Events.PLAYBACK_DVR,t),this.trigger(g.Events.PLAYBACK_STATS_ADD,{dvr:t})}},{key:"seek",value:function(t){t<0&&(g.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(t=720,this.trigger(g.Events.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(g.Events.PLAYBACK_BITRATE,{bandwidth:t.bandwidth,width:t.width,height:t.height,level:t.id,bitrate:t.videoBandwidth})}},{key:"_updateSettings",value:function(){"vod"===this.getPlaybackType()?this.settings.left=["playpause","position","duration"]:this.dvrEnabled?this.settings.left=["playpause"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(g.Events.PLAYBACK_SETTINGSUPDATE)}},{key:"checkIfCritical",value:function(){var t=this;this._options.mediaInfo.then((function(e){var r=e.criticalError,n=e.errorCodec;r&&(t._isShakaReadyState=!1,t.criticalError=!0,t.stop(),t.trigger(g.Events.PLAYBACK_ERROR,{UI:{title:"Playback error",message:"Could not play ".concat(n||"this"," codec")},raw:{response:{critical:!0}}}))}))}},{key:"_destroy",value:function(){this._isShakaReadyState=!1,g.Log.debug("shaka was destroyed")}}],[{key:"Events",get:function(){return{SHAKA_READY:"shaka:ready"}}},{key:"shakaPlayer",get:function(){return y.a}},{key:"canPlay",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";y.a.polyfill.installAll();var r=y.a.Player.isBrowserSupported(),n=t.split("?")[0].match(/.*\.(.*)$/)||[];return r&&("mpd"===n[1]||e.indexOf("application/dash+xml")>-1)}}])}(g.HTML5Video);e.a=b},function(t,e,r){"use strict";r.d(e,"a",(function(){return E}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(15),d=r.n(h),f=r(8),p=r.n(f),g=r(1),m=r(182),y=r.n(m);function v(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(v=function(){return!!t})()}var E=function(t){function e(t){var r,n,s,a;return i()(this,e),n=this,s=e,a=[t],s=u()(s),(r=l()(n,v()?Reflect.construct(s,a||[],u()(n).constructor):s.apply(n,a))).listenTo(r.container,g.Events.MEDIACONTROL_CONTAINERCHANGED,r.calculatePos),r.listenToOnce(r.container,g.Events.CONTAINER_LOADEDMETADATA,(function(t){r.render(t)})),r}return p()(e,t),a()(e,[{key:"name",get:function(){return"Flussonic paning/zooming plugin"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"destroy",value:function(){var t,r,n,i,s;(t=e,r="destroy",n=this,i=3,s=d()(u()(1&i?t.prototype:t),r,n),2&i&&"function"==typeof s?function(t){return s.apply(n,t)}:s)([])}},{key:"render",value:function(t){var e=this,r=t.data;this._video=r.target,this.zoomElement=y()(this._video,{maxZoom:10,minZoom:1,smoothScroll:!1,zoomDoubleClickSpeed:1,filterKey:function(){return!0},onDoubleClick:function(t){return!1}}),this.zoomElement.on("transform",(function(t){e.calculatePos(t)}))}},{key:"calculatePos",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;if(e)t=e.getTransform();else{if(!this.zoomElement)return;t=this.zoomElement.getTransform()}var r=function(t){return Math.floor(100*t)/100};if(t){var n=t,i=n.x,s=n.y,a=i,o=s,l=!1,c=this.container.el.getBoundingClientRect(),u=this._video.getBoundingClientRect();if(!c)return;if(u.left>c.left&&(a=c.left,l=!0),u.top>c.top&&(o=c.top,l=!0),u.right\n<% } else { %>\n\n<% }; %>\n'},function(t,e,r){"use strict";r.d(e,"a",(function(){return v}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(8),d=r.n(h),f=r(1),p=r(186),g=r(187),m=r.n(g);function y(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(y=function(){return!!t})()}var v=function(t){function e(t){var r,n,s,a;return i()(this,e),n=this,s=e,a=[t],s=u()(s),(r=l()(n,y()?Reflect.construct(s,a||[],u()(n).constructor):s.apply(n,a))).$el.addClass("media-control-button media-control-icon").css({float:"right",height:"100%"}).append(m.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);var n=e.toDataURL("image/jpeg");r.core.mediaControl.trigger("capture:base64",n)})),r}return d()(e,t),a()(e,[{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,f.Events.CORE_ACTIVE_CONTAINER_CHANGED,(function(){this.listenTo(this.core.mediaControl,f.Events.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,"capture:base64",(function(t){Object(p.saveAs)(t,"screenshot_".concat(Date.now(),".jpg"))}))}))}},{key:"unBindEvents",value:function(){this.stopListening(this.core.mediaControl,f.Events.MEDIACONTROL_RENDERED)}},{key:"render",value:function(){return this.core.mediaControl.$el.find(".media-control-right-panel").append(this.el),this}}])}(f.UICorePlugin)},function(t,e,r){(function(r){var n,i,s;i=[],void 0===(s="function"==typeof(n=function(){"use strict";function e(t,e){return void 0===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 n(t,e,r){var n=new XMLHttpRequest;n.open("GET",t),n.responseType="blob",n.onload=function(){l(n.response,e,r)},n.onerror=function(){console.error("could not download file")},n.send()}function i(t){var e=new XMLHttpRequest;e.open("HEAD",t,!1);try{e.send()}catch(t){}return 200<=e.status&&299>=e.status}function s(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(r){var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}}var a="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof r&&r.global===r?r:void 0,o=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=a.saveAs||("object"!=typeof window||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!o?function(t,e,r){var o=a.URL||a.webkitURL,l=document.createElement("a");e=e||t.name||"download",l.download=e,l.rel="noopener","string"==typeof t?(l.href=t,l.origin===location.origin?s(l):i(l.href)?n(t,e,r):s(l,l.target="_blank")):(l.href=o.createObjectURL(t),setTimeout((function(){o.revokeObjectURL(l.href)}),4e4),setTimeout((function(){s(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(t,r,a){if(r=r||t.name||"download","string"!=typeof t)navigator.msSaveOrOpenBlob(e(t,a),r);else if(i(t))n(t,r,a);else{var o=document.createElement("a");o.href=t,o.target="_blank",setTimeout((function(){s(o)}))}}:function(t,e,r,i){if((i=i||open("","_blank"))&&(i.document.title=i.document.body.innerText="downloading..."),"string"==typeof t)return n(t,e,r);var s="application/octet-stream"===t.type,l=/constructor/i.test(a.HTMLElement)||a.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||s&&l||o)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var t=u.result;t=c?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=t:location=t,i=null},u.readAsDataURL(t)}else{var h=a.URL||a.webkitURL,d=h.createObjectURL(t);i?i.location=d:location.href=d,i=null,setTimeout((function(){h.revokeObjectURL(d)}),4e4)}});a.saveAs=l.saveAs=l,t.exports=l})?n.apply(e,i):n)||(t.exports=s)}).call(this,r(31))},function(t,e){t.exports=''},function(t,e,r){"use strict";r.d(e,"a",(function(){return E}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(15),d=r.n(h),f=r(8),p=r.n(f),g=r(17),m=r.n(g),y=r(1);r(405);function v(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(v=function(){return!!t})()}var E=function(t){function e(t){var r,n,s,a;return i()(this,e),n=this,s=e,a=[t],s=u()(s),r=l()(n,v()?Reflect.construct(s,a||[],u()(n).constructor):s.apply(n,a)),m()(r,"frameLooper",(function(){if(r.audioConnected){var t=new Uint8Array(r.analyser.frequencyBinCount);r.analyser.getByteFrequencyData(t);for(var e=0,n=0;ne&&(e=i)}var s=Math.round(r.canvas.offsetHeight/(256/e))||0;r.eqBarBack.style.height="".concat(r.canvas.offsetHeight,"px"),r.eqBar.style.height="".concat(s,"px")}})),r.container=t,r.audioConnected=!1,r.render(),r}return p()(e,t),a()(e,[{key:"name",get:function(){return"EqualizerPlugin"}},{key:"bindEvents",value:function(){this.listenTo(this.container,y.Events.CONTAINER_VOLUME,this.connectToAudio)}},{key:"destroy",value:function(){var t,r,n,i,s;clearInterval(this.timerStatus),(t=e,r="destroy",n=this,i=3,s=d()(u()(1&i?t.prototype:t),r,n),2&i&&"function"==typeof s?function(t){return s.apply(n,t)}:s)([])}},{key:"connectToAudio",value:function(t){100===t&&(this.context=new(window.AudioContext||window.webkitAudioContext),this.analyser=this.context.createAnalyser(),this.source=this.context.createMediaElementSource(this.container.$el.find("video")[0]),this.source.connect(this.analyser),this.analyser.connect(this.context.destination),this.audioConnected=!0,this.frameLooper=this.frameLooper.bind(this),clearInterval(this.timerStatus),this.timerStatus=setInterval(this.frameLooper,25),this.stopListening(this.container,y.Events.CONTAINER_VOLUME,this.connectToAudio))}},{key:"render",value:function(){return this.container.$el.append('
'),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}}])}(y.ContainerPlugin)},function(t,e,r){"use strict";r.d(e,"a",(function(){return y}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(15),d=r.n(h),f=r(8),p=r.n(f),g=r(1);function m(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(m=function(){return!!t})()}var y=function(t){function e(t){var r,n,s,a;return i()(this,e),n=this,s=e,a=[t],s=u()(s),(r=l()(n,m()?Reflect.construct(s,a||[],u()(n).constructor):s.apply(n,a))).background="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAFoBAMAAAA1HFdiAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAG1BMVEX5+fn//wAA//8A/wD/AP//AAAAAP8XFxf///8H5gWfAAAAAWJLR0QIht6VegAAAAd0SU1FB98IBRIsAXmGk48AAAI5SURBVHja7dJBDYBADADBs4AFLGABC1iohbOPhv1BMvu+NLlp10odqTN1pe7Uk5pQ8wMIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECBAgAABAgQIECDA/wKWxzM71T7ZZrfltNnppgACBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAAECBAgQIECAAL8B+ALjSfYzPnmdzgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNS0wOC0wNVQxODo0NDowMSswMTowMCL95a4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTUtMDgtMDVUMTg6NDQ6MDErMDE6MDBToF0SAAAAAElFTkSuQmCC","boolean"==typeof r.options.calmError&&r.options.calmError&&(r.background=""),r.options.dontShowError&&(r.dontShowError=parseInt(r.options.dontShowError,10),1==r.options.dontShowError&&(r.dontShowError=1)),r.listenTo(r.container,g.Events.CONTAINER_ERROR,r.onError),r}return p()(e,t),a()(e,[{key:"name",get:function(){return"Flussonic error plugin"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"destroy",value:function(){var t,r,n,i,s;this.t="stop",(t=e,r="destroy",n=this,i=3,s=d()(u()(1&i?t.prototype:t),r,n),2&i&&"function"==typeof s?function(t){return s.apply(n,t)}:s)([])}},{key:"hide",value:function(){this._err&&this._err.remove()}},{key:"show",value:function(t,e){var r=t.title,n=t.message;this.hide();var i=t&&r?r:"",s=t&&n?n:"A fatal error occured.",a="";if(e){var o=e.code,l=void 0===o?"":o,c=e.text,u=void 0===c?"":c;a=l||u?"Code:".concat(l||""," - ").concat(u||""):""}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(i).css({"font-size":"200%"})).append($("

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

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

').html('Retrying in 10 seconds ...').css({"font-size":"120%",margin:"15px"})),this.dontShowError&&this.dontShowError>0?this.dontShowError-=1:this.container&&this.container.$el.prepend(this._err)}},{key:"onError",value:function(t){if(t){var e=t.UI,r=t.raw;if(r){var n=r.response;if(!this.container)return;if(this.show(e,n),n&&"critical"in n&&n.critical)return $(".retrying_text").text(""),this.t,void this.container.getPlugin("click_to_pause").disable()}}var i;this.container.getPlugin("click_to_pause").disable();var s=10,a=function(){if(clearTimeout(i),"stop"!==this.t){if(0===s)return this.container.getPlugin("click_to_pause").enable(),this.options.errorPlugin&&this.options.errorPlugin.onRetry?void this.options.errorPlugin.onRetry(t):(this.container.stop(),this.container.play(),void this.hide());$(".retry-counter").text(s),s--,this.t=s,i=setTimeout(a,1e3)}}.bind(this);a()}}])}(g.ContainerPlugin)},function(t,e,r){"use strict";r.d(e,"a",(function(){return E}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(8),d=r.n(h),f=r(1),p=r(191),g=r.n(p),m=r(192),y=r.n(m);r(406);function v(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(v=function(){return!!t})()}var E=function(t){function e(t){var r,n,s,a;i()(this,e),n=this,s=e,a=[t],s=u()(s),(r=l()(n,v()?Reflect.construct(s,a||[],u()(n).constructor):s.apply(n,a))).core=t;var o=t.options.closedCaptionsConfig;return r._title=o&&o.title?o.title:null,r._ariaLabel=o&&o.ariaLabel?o.ariaLabel:"cc-button",r._labelCb=o&&o.labelCallback&&"function"==typeof o.labelCallback?o.labelCallback:function(t){return t.name},r.hideCCOnStart=t.options.hideCCOnStart,r.tracksAdded=!1,r.firstTime=!0,r.onSubtitleAvailable(),r}return d()(e,t),a()(e,[{key:"name",get:function(){return"Flussonic closed captions"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"template",get:function(){return Object(f.template)(y.a)}},{key:"events",get:function(){return{"click [data-cc-button]":"toggleContextMenu","click [data-cc-select]":"onTrackSelect"}}},{key:"attributes",get:function(){return{class:"cc-controls","data-cc-controls":""}}},{key:"bindEvents",value:function(){this.listenTo(this.core,f.Events.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged),this.listenTo(this.core.mediaControl,f.Events.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,f.Events.MEDIACONTROL_HIDE,this.hideContextMenu),this.bindContainerEvents()}},{key:"bindContainerEvents",value:function(){this.container=this.core.activeContainer,this.container&&(this.listenTo(this.container,f.Events.CONTAINER_SUBTITLE_CHANGED,this.onSubtitleChanged),this.listenTo(this.container,f.Events.CONTAINER_STOP,this.onContainerStop))}},{key:"onContainerStop",value:function(){this.ccAvailable(!1)}},{key:"containerChanged",value:function(){var t=this.core.plugins;t.length>0&&t.forEach((function(t){"ClosedCaptions"===t.constructor.name&&(t.$el[0].style.display="none");"closed_captions"===t.name&&(t.$el[0].style.display="none",t.disable())})),this.stopListening(),this.bindEvents()}},{key:"onSubtitleAvailable",value:function(){this.renderCcButton(),this.ccAvailable(!0)}},{key:"onSubtitleChanged",value:function(t){if(this.setCurrentContextMenuElement(t.id),this.firstTime){var e=this.container.$el.find("video")[0].textTracks,r=e.length;e&&r&&(this.setCurrentContextMenuElement(r-1),this.$el.addClass("available")),this.firstTime=!1}}},{key:"onTrackSelect",value:function(t){var e=parseInt(t.target.dataset.ccSelect,10);return this.container.closedCaptionsTrackId=e,this.hideContextMenu(),t.noProp||t.stopPropagation(),!1}},{key:"ccAvailable",value:function(t){var e=t?"addClass":"removeClass";this.$el[e]("available")}},{key:"toggleContextMenu",value:function(){this.$el.find("ul").toggle()}},{key:"hideContextMenu",value:function(){this.$el.find("ul").hide()}},{key:"contextMenuElement",value:function(t){return this.$el.find("ul a".concat(Number.isNaN(t)?"":'[data-cc-select="'.concat(t,'"]'))).parent()}},{key:"mainButtonElement",value:function(){return this.$el.find("button.cc-button[data-cc-button]")}},{key:"setCurrentContextMenuElement",value:function(t){if(void 0===this._trackId&&void 0!==this.startingSubs)return this.contextMenuElement().removeClass("current"),this.contextMenuElement(this.startingSubs).addClass("current"),this.$el.find("button.cc-button[data-cc-button]").addClass("enabled"),this._trackId=this.startingSubs,void(this.startingSubs=void 0);if(this._trackId!==t){this.contextMenuElement(this._trackId).removeClass("current"),this.contextMenuElement(t).addClass("current");var e=t>-1?"addClass":"removeClass";this.$ccButton[e]("enabled"),this._trackId=t}}},{key:"renderCcButton",value:function(){for(var t=this.container?this.container.closedCaptionsTracks:[],e=0;ecurrent<% }; %>">\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 A}));var n=r(62),i=r.n(n),s=r(5),a=r.n(s),o=r(6),l=r.n(o),c=r(7),u=r.n(c),h=r(3),d=r.n(h),f=r(15),p=r.n(f),g=r(8),m=r.n(g),y=r(17),v=r.n(y),E=r(1);function b(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function T(t){for(var e=1;e1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=this.playerStatsObject.application;n&&(r?n[t]=r:e&&n[t]++,this.playerStatsObject.application=n)}},{key:"getStats",value:function(){return T(T({},this.playerStatsObject),{},{id:this.uuid})}},{key:"generateUUID",value:function(){var t=(new Date).getTime(),e="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:3&n|8).toString(16)}))}},{key:"destroy",value:function(){var t,r,n,i,s;(t=e,r="destroy",n=this,i=3,s=p()(d()(1&i?t.prototype:t),r,n),2&i&&"function"==typeof s?function(t){return s.apply(n,t)}:s)([])}}])}(E.UIContainerPlugin)},function(t,e,r){"use strict";r.d(e,"a",(function(){return y}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(15),d=r.n(h),f=r(8),p=r.n(f),g=r(1);function m(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(m=function(){return!!t})()}var y=function(t){function e(){return i()(this,e),t=this,r=e,n=arguments,r=u()(r),l()(t,m()?Reflect.construct(r,n||[],u()(t).constructor):r.apply(t,n));var t,r,n}return p()(e,t),a()(e,[{key:"name",get:function(){return"Flussonic timeline check plugin"}},{key:"supportedVersion",get:function(){return{min:"0.4.18"}}},{key:"bindEvents",value:function(){var t=this;this.listenTo(this.core,g.Events.CORE_ACTIVE_CONTAINER_CHANGED,this.checkForLive),this.checkingLive||(this.checkingLive=setInterval((function(){t.checkForLive()}),1e3))}},{key:"destroy",value:function(){var t,r,n,i,s;clearInterval(this.checkingLive),(t=e,r="destroy",n=this,i=3,s=d()(u()(1&i?t.prototype:t),r,n),2&i&&"function"==typeof s?function(t){return s.apply(n,t)}:s)([])}},{key:"checkForLive",value:function(){this.stopListening(),this.bindEvents(),this.mediaControl=this.core.mediaControl;var t=this.mediaControl.$el;"live"===this.core.getPlaybackType()&&t.addClass("live")}},{key:"render",value:function(){this.checkForLive()}}])}(g.UICorePlugin)},function(t,e,r){"use strict";r.d(e,"a",(function(){return y}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(15),d=r.n(h),f=r(8),p=r.n(f),g=r(1);function m(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(m=function(){return!!t})()}var y=function(t){function e(t){var r,n,s,a;i()(this,e),n=this,s=e,a=[t],s=u()(s);var o=(r=l()(n,m()?Reflect.construct(s,a||[],u()(n).constructor):s.apply(n,a)))._options.playbackDuration;return r.playbackDuration=o,r}return p()(e,t),a()(e,[{key:"name",get:function(){return"SegmentPlayPlugin"}},{key:"bindEvents",value:function(){var t=this;this.listenTo(this.container.playback,g.Events.PLAYBACK_PLAY,(function(){t.stopTimer()}))}},{key:"stopTimer",value:function(){var t=this;this.playbackDuration&&(this.stopTimeout=setTimeout((function(){t.container.pause(),setTimeout((function(){t.container.stop()}),0)}),1e3*this.playbackDuration))}},{key:"destroy",value:function(){var t,r,n,i,s;clearTimeout(this.stopTimeout),(t=e,r="destroy",n=this,i=3,s=d()(u()(1&i?t.prototype:t),r,n),2&i&&"function"==typeof s?function(t){return s.apply(n,t)}:s)([])}}])}(g.UIContainerPlugin)},function(t,e,r){"use strict";(function(t){r.d(e,"a",(function(){return E}));var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(8),d=r.n(h),f=r(1),p=r(197),g=r.n(p),m=r(198),y=r.n(m);function v(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(v=function(){return!!t})()}var E=function(e){function r(){return i()(this,r),t=this,e=r,n=arguments,e=u()(e),l()(t,v()?Reflect.construct(e,n||[],u()(t).constructor):e.apply(t,n));var t,e,n}return d()(r,e),a()(r,[{key:"name",get:function(){return"audioTrackSelector"}},{key:"template",get:function(){return Object(f.template)(g.a)}},{key:"supportedVersion",get:function(){return{min:f.version}}},{key:"attributes",get:function(){return{class:this.name,"data-audioTrackSelector":""}}},{key:"events",get:function(){return{"click [data-audioTrackSelector-select]":"onLevelSelect","click [data-audioTrackSelector-button]":"onShowLevelSelectMenu"}}},{key:"container",get:function(){return this.core.activeContainer?this.core.activeContainer:this.core.mediaControl.container}},{key:"playback",get:function(){return this.core.activePlayback?this.core.activePlayback:this.core.getCurrentPlayback()}},{key:"bindEvents",value:function(){this.listenTo(this.core,f.Events.CORE_READY,this.bindPlaybackEvents),f.Events.CORE_ACTIVE_CONTAINER_CHANGED?this.listenTo(this.core,f.Events.CORE_ACTIVE_CONTAINER_CHANGED,this.reload):this.listenTo(this.core.mediaControl,f.Events.MEDIACONTROL_CONTAINERCHANGED,this.reload),this.listenTo(this.core.mediaControl,f.Events.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,f.Events.MEDIACONTROL_HIDE,this.hideSelectLevelMenu)}},{key:"bindPlaybackEvents",value:function(){this.playback&&(this.listenTo(this.playback,f.Events.PLAYBACK_LEVELS_AVAILABLE,this.fillLevels),this.listenTo(this.playback,f.Events.PLAYBACK_LEVEL_SWITCH_START,this.startLevelSwitch),this.listenTo(this.playback,f.Events.PLAYBACK_LEVEL_SWITCH_END,this.stopLevelSwitch),this.listenTo(this.playback,f.Events.PLAYBACK_BITRATE,this.updateCurrentLevel),this.playback.levels&&this.playback.levels.length>0&&this.fillLevels(this.playback.levels))}},{key:"reload",value:function(){var e=this;this.stopListening(),t.nextTick((function(){e.bindEvents(),e.bindPlaybackEvents()}))}},{key:"shouldRender",value:function(){if(!this.container||!this.playback)return!1;var t=void 0!==this.playback.currentLevel,e=!!(this.audioLevels&&this.audioLevels.length>1);return t&&e}},{key:"render",value:function(){if(this.shouldRender()){var t=f.Styler.getStyleFor(y.a,{baseUrl:this.core.options.baseUrl});this.$el.html(this.template({audioLevels:this.audioLevels,title:this.getTitle()})),this.$el.append(t),this.core.mediaControl.$(".media-control-right-panel").append(this.el),this.$(".audioTrackSelector ul").css("max-height",.8*this.core.el.offsetHeight),this.highlightCurrentLevel()}return this}},{key:"fillLevels",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;void 0===this.selectedLevelId&&(this.selectedLevelId=e);var r=this.core.getCurrentPlayback()._hls.audioTrackController.tracks,n=this.core.options&&this.core.options.levelSelectorConfig&&this.core.options.levelSelectorConfig.onLevelsAvailable;if(n){if("function"!=typeof n)throw new TypeError("onLevelsAvailable must be a function");t=n(t.slice())}this.audioLevels=r,this.configureLevelsLabels(),this.render()}},{key:"configureLevelsLabels",value:function(){if(void 0!==this.core.options.levelSelectorConfig){var t=this.core.options.levelSelectorConfig.labelCallback;if(t&&"function"!=typeof t)throw new TypeError("labelCallback must be a function");var e,r,n=this.core.options.levelSelectorConfig.labels,i=n?this.core.options.levelSelectorConfig.labels:{};if(t||n)for(var s in this.audioLevels)r=i[(e=this.audioLevels[s]).id],t?e.label=t(e,r):r&&(e.label=r)}}},{key:"findLevelBy",value:function(t){var e;return this.audioLevels.forEach((function(r){r.id===t&&(e=r)})),e}},{key:"onLevelSelect",value:function(t){return this.selectedLevelId=parseInt(t.target.dataset.audiotrackselectorSelect,10),this.core.getCurrentPlayback()._hls.audioTrackController.trackId===this.selectedLevelId||(this.core.getCurrentPlayback()._hls.audioTrack=this.selectedLevelId,this.updateCurrentLevel(),this.highlightCurrentLevel(),this.toggleContextMenu(),t.stopPropagation()),!1}},{key:"onShowLevelSelectMenu",value:function(){this.toggleContextMenu()}},{key:"hideSelectLevelMenu",value:function(){this.$(".audioTrackSelector ul").hide()}},{key:"toggleContextMenu",value:function(){this.$(".audioTrackSelector ul").toggle()}},{key:"buttonElement",value:function(){return this.$(".audioTrackSelector button")}},{key:"levelElement",value:function(t){return this.$(".audioTrackSelector ul a".concat(isNaN(t)?"":'[data-audioTrackSelector-select="'.concat(t,'"]'))).parent()}},{key:"getTitle",value:function(){return(this.core.options.levelSelectorConfig||{}).title}},{key:"startLevelSwitch",value:function(){this.buttonElement().addClass("changing")}},{key:"stopLevelSwitch",value:function(){this.buttonElement().removeClass("changing")}},{key:"updateText",value:function(){var t=this.findLevelBy(this.core.getCurrentPlayback()._hls.audioTrackController.trackId).lang||"audio track ".concat(this.findLevelBy(this.core.getCurrentPlayback()._hls.audioTrackController.trackId).id+1);this.buttonElement().text(t)}},{key:"updateCurrentLevel",value:function(){var t=this.findLevelBy(this.core.getCurrentPlayback()._hls.audioTrackController.trackId);this.currentAudioLevel=t||null,this.highlightCurrentLevel()}},{key:"highlightCurrentLevel",value:function(){this.levelElement().removeClass("current"),this.currentAudioLevel&&this.levelElement(this.currentAudioLevel.id).addClass("current"),this.updateText()}}],[{key:"version",get:function(){return"24.6.1"}}])}(f.UICorePlugin)}).call(this,r(76))},function(t,e){t.exports='\n

\n'},function(t,e,r){var n=r(407);"string"==typeof n&&(n=[[t.i,n,""]]);var i={hmr:!0,transform:undefined,insertInto:void 0};r(161)(n,i);n.locals&&(t.exports=n.locals)},,,,,,,function(t,e,r){"use strict";r.r(e),function(t){var n=r(5),i=r.n(n),s=r(6),a=r.n(s),o=r(7),l=r.n(o),c=r(3),u=r.n(c),h=r(8),d=r.n(h),f=r(17),p=r.n(f),g=(r(209),r(358),r(359),r(360),r(1)),m=r(408),y=r(22),v=r(95),E=r(163),b=r(166),T=r(169),S=r(172),A=r(174),_=r(177),k=r(178),L=r(179),w=r(180),R=r(123),C=r(181),D=r(183),I=r(26),x=r(185),P=r(188),O=r(189),M=r(190),F=r(193),B=r(194),N=r(195),U=r(196);function $(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return($=function(){return!!t})()}function j(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function G(t){for(var e=1;e1?e-1:0),n=1;n-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function u(t){return"string"!=typeof t&&(t=String(t)),t}function h(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function g(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function m(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:s&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():a&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=m(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(t)||l(t))?this._bodyArrayBuffer=m(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=f(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(i)return this.blob().then(g);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,n,i,s=f(this);if(s)return s;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=p(e),n=/charset=([A-Za-z0-9_-]+)/.exec(t.type),i=n?n[1]:"utf-8",e.readAsText(t,i),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?i:n),this.mode=r.mode||this.mode||null,this.signal=r.signal||this.signal||function(){if("AbortController"in e)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==r.cache&&"no-cache"!==r.cache)){var a=/([?&])_=[^&]*/;if(a.test(this.url))this.url=this.url.replace(a,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function b(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function T(t,e){if(!(this instanceof T))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}E.prototype.clone=function(){return new E(this,{body:this._bodyInit})},y.call(E.prototype),y.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},T.error=function(){var t=new T(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var S=[301,302,303,307,308];T.redirect=function(t,e){if(-1===S.indexOf(e))throw new RangeError("Invalid status code");return new T(null,{status:e,headers:{location:t}})};var A=e.DOMException;try{new A}catch(t){(A=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),A.prototype.constructor=A}function _(t,r){return new Promise((function(n,s){var o=new E(t,r);if(o.signal&&o.signal.aborted)return s(new A("Aborted","AbortError"));var l=new XMLHttpRequest;function h(){l.abort()}if(l.onload=function(){var t,e,r={statusText:l.statusText,headers:(t=l.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();try{e.append(n,i)}catch(t){console.warn("Response "+t.message)}}})),e)};0===o.url.indexOf("file://")&&(l.status<200||l.status>599)?r.status=200:r.status=l.status,r.url="responseURL"in l?l.responseURL:r.headers.get("X-Request-URL");var i="response"in l?l.response:l.responseText;setTimeout((function(){n(new T(i,r))}),0)},l.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},l.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request timed out"))}),0)},l.onabort=function(){setTimeout((function(){s(new A("Aborted","AbortError"))}),0)},l.open(o.method,function(t){try{return""===t&&e.location.href?e.location.href:t}catch(e){return t}}(o.url),!0),"include"===o.credentials?l.withCredentials=!0:"omit"===o.credentials&&(l.withCredentials=!1),"responseType"in l&&(i?l.responseType="blob":a&&(l.responseType="arraybuffer")),r&&"object"==typeof r.headers&&!(r.headers instanceof d||e.Headers&&r.headers instanceof e.Headers)){var f=[];Object.getOwnPropertyNames(r.headers).forEach((function(t){f.push(c(t)),l.setRequestHeader(t,u(r.headers[t]))})),o.headers.forEach((function(t,e){-1===f.indexOf(e)&&l.setRequestHeader(e,t)}))}else o.headers.forEach((function(t,e){l.setRequestHeader(e,t)}));o.signal&&(o.signal.addEventListener("abort",h),l.onreadystatechange=function(){4===l.readyState&&o.signal.removeEventListener("abort",h)}),l.send(void 0===o._bodyInit?null:o._bodyInit)}))}_.polyfill=!0,e.fetch||(e.fetch=_,e.Headers=d,e.Request=E,e.Response=T)}).call(this,r(31))},function(t,e,r){(function(t){!function(t){var e=function(){try{return!!Symbol.iterator}catch(t){return!1}}(),r=function(t){var r={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e&&(r[Symbol.iterator]=function(){return r}),r},n=function(t){return encodeURIComponent(t).replace(/%20/g,"+")},i=function(t){return decodeURIComponent(String(t).replace(/\+/g," "))};(function(){try{var e=t.URLSearchParams;return"a=1"===new e("?a=1").toString()&&"function"==typeof e.prototype.set&&"function"==typeof e.prototype.entries}catch(t){return!1}})()||function(){var i=function(t){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var e=typeof t;if("undefined"===e);else if("string"===e)""!==t&&this._fromString(t);else if(t instanceof i){var r=this;t.forEach((function(t,e){r.append(e,t)}))}else{if(null===t||"object"!==e)throw new TypeError("Unsupported input's type for URLSearchParams");if("[object Array]"===Object.prototype.toString.call(t))for(var n=0;ne[0]?1:0})),t._entries&&(t._entries={});for(var r=0;r1?i(n[1]):"")}})}(void 0!==t?t:"undefined"!=typeof window?window:"undefined"!=typeof self?self:this),function(t){if(function(){try{var e=new t.URL("b","http://a");return e.pathname="c d","http://a/c%20d"===e.href&&e.searchParams}catch(t){return!1}}()||function(){var e=t.URL,r=function(e,r){"string"!=typeof e&&(e=String(e)),r&&"string"!=typeof r&&(r=String(r));var n,i=document;if(r&&(void 0===t.location||r!==t.location.href)){r=r.toLowerCase(),(n=(i=document.implementation.createHTMLDocument("")).createElement("base")).href=r,i.head.appendChild(n);try{if(0!==n.href.indexOf(r))throw new Error(n.href)}catch(t){throw new Error("URL unable to set base "+r+" due to "+t)}}var s=i.createElement("a");s.href=e,n&&(i.body.appendChild(s),s.href=s.href);var a=i.createElement("input");if(a.type="url",a.value=e,":"===s.protocol||!/:/.test(s.href)||!a.checkValidity()&&!r)throw new TypeError("Invalid URL");Object.defineProperty(this,"_anchorElement",{value:s});var o=new t.URLSearchParams(this.search),l=!0,c=!0,u=this;["append","delete","set"].forEach((function(t){var e=o[t];o[t]=function(){e.apply(o,arguments),l&&(c=!1,u.search=o.toString(),c=!0)}})),Object.defineProperty(this,"searchParams",{value:o,enumerable:!0});var h=void 0;Object.defineProperty(this,"_updateSearchParams",{enumerable:!1,configurable:!1,writable:!1,value:function(){this.search!==h&&(h=this.search,c&&(l=!1,this.searchParams._fromString(this.search),l=!0))}})},n=r.prototype;["hash","host","hostname","port","protocol"].forEach((function(t){!function(t){Object.defineProperty(n,t,{get:function(){return this._anchorElement[t]},set:function(e){this._anchorElement[t]=e},enumerable:!0})}(t)})),Object.defineProperty(n,"search",{get:function(){return this._anchorElement.search},set:function(t){this._anchorElement.search=t,this._updateSearchParams()},enumerable:!0}),Object.defineProperties(n,{toString:{get:function(){var t=this;return function(){return t.href}}},href:{get:function(){return this._anchorElement.href.replace(/\?$/,"")},set:function(t){this._anchorElement.href=t,this._updateSearchParams()},enumerable:!0},pathname:{get:function(){return this._anchorElement.pathname.replace(/(^\/?)/,"/")},set:function(t){this._anchorElement.pathname=t},enumerable:!0},origin:{get:function(){var t={"http:":80,"https:":443,"ftp:":21}[this._anchorElement.protocol],e=this._anchorElement.port!=t&&""!==this._anchorElement.port;return this._anchorElement.protocol+"//"+this._anchorElement.hostname+(e?":"+this._anchorElement.port:"")},enumerable:!0},password:{get:function(){return""},set:function(t){},enumerable:!0},username:{get:function(){return""},set:function(t){},enumerable:!0}}),r.createObjectURL=function(t){return e.createObjectURL.apply(e,arguments)},r.revokeObjectURL=function(t){return e.revokeObjectURL.apply(e,arguments)},t.URL=r}(),void 0!==t.location&&!("origin"in t.location)){var e=function(){return t.location.protocol+"//"+t.location.hostname+(t.location.port?":"+t.location.port:"")};try{Object.defineProperty(t.location,"origin",{get:e,enumerable:!0})}catch(r){setInterval((function(){t.location.origin=e()}),100)}}}(void 0!==t?t:"undefined"!=typeof window?window:"undefined"!=typeof self?self:this)}).call(this,r(31))},function(t,e,r){},function(t,e,r){var n=r(154);t.exports=function(t){if(Array.isArray(t))return n(t)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(3);t.exports=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=n(t)););return t},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){var n=r(61).default;function i(){"use strict";t.exports=i=function(){return r},t.exports.__esModule=!0,t.exports.default=t.exports;var e,r={},s=Object.prototype,a=s.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},l="function"==typeof Symbol?Symbol:{},c=l.iterator||"@@iterator",u=l.asyncIterator||"@@asyncIterator",h=l.toStringTag||"@@toStringTag";function d(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},"")}catch(e){d=function(t,e,r){return t[e]=r}}function f(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,s=Object.create(i.prototype),a=new P(n||[]);return o(s,"_invoke",{value:C(t,r,a)}),s}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}r.wrap=f;var g="suspendedStart",m="suspendedYield",y="executing",v="completed",E={};function b(){}function T(){}function S(){}var A={};d(A,c,(function(){return this}));var _=Object.getPrototypeOf,k=_&&_(_(O([])));k&&k!==s&&a.call(k,c)&&(A=k);var L=S.prototype=b.prototype=Object.create(A);function w(t){["next","throw","return"].forEach((function(e){d(t,e,(function(t){return this._invoke(e,t)}))}))}function R(t,e){function r(i,s,o,l){var c=p(t[i],t,s);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==n(h)&&a.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,o,l)}),(function(t){r("throw",t,o,l)})):e.resolve(h).then((function(t){u.value=t,o(u)}),(function(t){return r("throw",t,o,l)}))}l(c.arg)}var i;o(this,"_invoke",{value:function(t,n){function s(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(s,s):s()}})}function C(t,r,n){var i=g;return function(s,a){if(i===y)throw Error("Generator is already running");if(i===v){if("throw"===s)throw a;return{value:e,done:!0}}for(n.method=s,n.arg=a;;){var o=n.delegate;if(o){var l=D(o,n);if(l){if(l===E)continue;return l}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===g)throw i=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=y;var c=p(t,r,n);if("normal"===c.type){if(i=n.done?v:m,c.arg===E)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=v,n.method="throw",n.arg=c.arg)}}}function D(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,D(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),E;var s=p(i,t.iterator,r.arg);if("throw"===s.type)return r.method="throw",r.arg=s.arg,r.delegate=null,E;var a=s.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,E):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,E)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function x(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function O(t){if(t||""===t){var r=t[c];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,s=function r(){for(;++i=0;--i){var s=this.tryEntries[i],o=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var l=a.call(s,"catchLoc"),c=a.call(s,"finallyLoc");if(l&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),x(r),E}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;x(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:O(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),E}},r}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t){if(Array.isArray(t))return t},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,s,a,o=[],l=!0,c=!1;try{if(s=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=s.call(r)).done)&&(o.push(n.value),o.length!==e);l=!0);}catch(t){c=!0,i=t}finally{try{if(!l&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return o}},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e,r){"use strict";var n=r(370);function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,o=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,l=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),c=["'"].concat(l),u=["%","/","?",";","#"].concat(c),h=["/","?","#"],d=/^[+a-z0-9A-Z_-]{0,63}$/,f=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,p={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=r(371);function v(t,e,r){if(t&&"object"==typeof t&&t instanceof i)return t;var n=new i;return n.parse(t,e,r),n}i.prototype.parse=function(t,e,r){if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),a=-1!==i&&i127?x+="x":x+=I[P];if(!x.match(d)){var M=C.slice(0,L),F=C.slice(L+1),B=I.match(f);B&&(M.push(B[1]),F.unshift(B[2])),F.length&&(v="/"+F.join(".")+v),this.hostname=M.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),R||(this.hostname=n.toASCII(this.hostname));var N=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+N,this.href+=this.host,R&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!p[T])for(L=0,D=c.length;L0)&&r.host.split("@"))&&(r.auth=R.shift(),r.hostname=R.shift(),r.host=r.hostname);return r.search=t.search,r.query=t.query,null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!S.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var _=S.slice(-1)[0],k=(r.host||t.host||S.length>1)&&("."===_||".."===_)||""===_,L=0,w=S.length;w>=0;w--)"."===(_=S[w])?S.splice(w,1):".."===_?(S.splice(w,1),L++):L&&(S.splice(w,1),L--);if(!b&&!T)for(;L--;L)S.unshift("..");!b||""===S[0]||S[0]&&"/"===S[0].charAt(0)||S.unshift(""),k&&"/"!==S.join("/").substr(-1)&&S.push("");var R,C=""===S[0]||S[0]&&"/"===S[0].charAt(0);A&&(r.hostname=C?"":S.length?S.shift():"",r.host=r.hostname,(R=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=R.shift(),r.hostname=R.shift(),r.host=r.hostname));return(b=b||r.host&&S.length)&&!C&&S.unshift(""),S.length>0?r.pathname=S.join("/"):(r.pathname=null,r.path=null),null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},i.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)},e.parse=v,e.resolve=function(t,e){return v(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?v(t,!1,!0).resolveObject(e):e},e.format=function(t){return"string"==typeof t&&(t=v(t)),t instanceof i?t.format():i.prototype.format.call(t)},e.Url=i},function(t,e,r){(function(t,n){var i;!function(){e&&e.nodeType,t&&t.nodeType;var s="object"==typeof n&&n;s.global!==s&&s.window!==s&&s.self;var a,o=2147483647,l=36,c=/^xn--/,u=/[^\x20-\x7E]/,h=/[\x2E\u3002\uFF0E\uFF61]/g,d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},f=Math.floor,p=String.fromCharCode;function g(t){throw new RangeError(d[t])}function m(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function y(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+m((t=t.replace(h,".")).split("."),e).join(".")}function v(t){for(var e,r,n=[],i=0,s=t.length;i=55296&&e<=56319&&i65535&&(e+=p((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+=p(t)})).join("")}function b(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function T(t,e,r){var n=0;for(t=r?f(t/700):t>>1,t+=f(t/e);t>455;n+=l)t=f(t/35);return f(n+36*t/(t+38))}function S(t){var e,r,n,i,s,a,c,u,h,d,p,m=[],y=t.length,v=0,b=128,S=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n=128&&g("not-basic"),m.push(t.charCodeAt(n));for(i=r>0?r+1:0;i=y&&g("invalid-input"),((u=(p=t.charCodeAt(i++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:l)>=l||u>f((o-v)/a))&&g("overflow"),v+=u*a,!(u<(h=c<=S?1:c>=S+26?26:c-S));c+=l)a>f(o/(d=l-h))&&g("overflow"),a*=d;S=T(v-s,e=m.length+1,0==s),f(v/e)>o-b&&g("overflow"),b+=f(v/e),v%=e,m.splice(v++,0,b)}return E(m)}function A(t){var e,r,n,i,s,a,c,u,h,d,m,y,E,S,A,_=[];for(y=(t=v(t)).length,e=128,r=0,s=72,a=0;a=e&&mf((o-r)/(E=n+1))&&g("overflow"),r+=(c-e)*E,e=c,a=0;ao&&g("overflow"),m==e){for(u=r,h=l;!(u<(d=h<=s?1:h>=s+26?26:h-s));h+=l)A=u-d,S=l-d,_.push(p(b(d+A%S,0))),u=f(A/S);_.push(p(b(u,0))),s=T(r,E,n==i),r=0,++n}++r,++e}return _.join("")}a={version:"1.4.1",ucs2:{decode:v,encode:E},decode:S,encode:A,toASCII:function(t){return y(t,(function(t){return u.test(t)?"xn--"+A(t):t}))},toUnicode:function(t){return y(t,(function(t){return c.test(t)?S(t.slice(4).toLowerCase()):t}))}},void 0===(i=function(){return a}.call(e,r,e,t))||(t.exports=i)}()}).call(this,r(156)(t),r(31))},function(t,e,r){"use strict";var n=r(372),i=r(391),s=r(120);t.exports={formats:s,parse:i,stringify:n}},function(t,e,r){"use strict";var n=r(373),i=r(159),s=r(120),a=Object.prototype.hasOwnProperty,o={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},l=Array.isArray,c=Array.prototype.push,u=function(t,e){c.apply(t,l(e)?e:[e])},h=Date.prototype.toISOString,d=s.default,f={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,commaRoundTrip:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:i.encode,encodeValuesOnly:!1,filter:void 0,format:d,formatter:s.formatters[d],indices:!1,serializeDate:function(t){return h.call(t)},skipNulls:!1,strictNullHandling:!1},p={},g=function t(e,r,s,a,o,c,h,d,g,m,y,v,E,b,T,S,A,_){for(var k,L=e,w=_,R=0,C=!1;void 0!==(w=w.get(p))&&!C;){var D=w.get(e);if(R+=1,void 0!==D){if(D===R)throw new RangeError("Cyclic object value");C=!0}void 0===w.get(p)&&(R=0)}if("function"==typeof m?L=m(r,L):L instanceof Date?L=E(L):"comma"===s&&l(L)&&(L=i.maybeMap(L,(function(t){return t instanceof Date?E(t):t}))),null===L){if(c)return g&&!S?g(r,f.encoder,A,"key",b):r;L=""}if("string"==typeof(k=L)||"number"==typeof k||"boolean"==typeof k||"symbol"==typeof k||"bigint"==typeof k||i.isBuffer(L))return g?[T(S?r:g(r,f.encoder,A,"key",b))+"="+T(g(L,f.encoder,A,"value",b))]:[T(r)+"="+T(String(L))];var I,x=[];if(void 0===L)return x;if("comma"===s&&l(L))S&&g&&(L=i.maybeMap(L,g)),I=[{value:L.length>0?L.join(",")||null:void 0}];else if(l(m))I=m;else{var P=Object.keys(L);I=y?P.sort(y):P}var O=d?String(r).replace(/\./g,"%2E"):String(r),M=a&&l(L)&&1===L.length?O+"[]":O;if(o&&l(L)&&0===L.length)return M+"[]";for(var F=0;F0?T+b:""}},function(t,e,r){"use strict";var n=r(60),i=r(384),s=r(389),a=r(70),o=n("%WeakMap%",!0),l=n("%Map%",!0),c=i("WeakMap.prototype.get",!0),u=i("WeakMap.prototype.set",!0),h=i("WeakMap.prototype.has",!0),d=i("Map.prototype.get",!0),f=i("Map.prototype.set",!0),p=i("Map.prototype.has",!0),g=function(t,e){for(var r,n=t;null!==(r=n.next);n=r)if(r.key===e)return n.next=r.next,r.next=t.next,t.next=r,r};t.exports=function(){var t,e,r,n={assert:function(t){if(!n.has(t))throw new a("Side channel does not contain "+s(t))},get:function(n){if(o&&n&&("object"==typeof n||"function"==typeof n)){if(t)return c(t,n)}else if(l){if(e)return d(e,n)}else if(r)return function(t,e){var r=g(t,e);return r&&r.value}(r,n)},has:function(n){if(o&&n&&("object"==typeof n||"function"==typeof n)){if(t)return h(t,n)}else if(l){if(e)return p(e,n)}else if(r)return function(t,e){return!!g(t,e)}(r,n);return!1},set:function(n,i){o&&n&&("object"==typeof n||"function"==typeof n)?(t||(t=new o),u(t,n,i)):l?(e||(e=new l),f(e,n,i)):(r||(r={key:{},next:null}),function(t,e,r){var n=g(t,e);n?n.value=r:t.next={key:e,next:t.next,value:r}}(r,n,i))}};return n}},function(t,e,r){"use strict";t.exports=Error},function(t,e,r){"use strict";t.exports=EvalError},function(t,e,r){"use strict";t.exports=RangeError},function(t,e,r){"use strict";t.exports=ReferenceError},function(t,e,r){"use strict";t.exports=URIError},function(t,e,r){"use strict";var n="undefined"!=typeof Symbol&&Symbol,i=r(380);t.exports=function(){return"function"==typeof n&&("function"==typeof Symbol&&("symbol"==typeof n("foo")&&("symbol"==typeof Symbol("bar")&&i())))}},function(t,e,r){"use strict";t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var n=Object.getOwnPropertySymbols(t);if(1!==n.length||n[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},function(t,e,r){"use strict";var n={__proto__:null,foo:{}},i=Object;t.exports=function(){return{__proto__:n}.foo===n.foo&&!(n instanceof i)}},function(t,e,r){"use strict";var n=Object.prototype.toString,i=Math.max,s=function(t,e){for(var r=[],n=0;n-1?i(r):r}},function(t,e,r){"use strict";var n=r(118),i=r(60),s=r(386),a=r(70),o=i("%Function.prototype.apply%"),l=i("%Function.prototype.call%"),c=i("%Reflect.apply%",!0)||n.call(l,o),u=r(119),h=i("%Math.max%");t.exports=function(t){if("function"!=typeof t)throw new a("a function is required");var e=c(n,l,arguments);return s(e,1+h(0,t.length-(arguments.length-1)),!0)};var d=function(){return c(n,o,arguments)};u?u(t.exports,"apply",{value:d}):t.exports.apply=d},function(t,e,r){"use strict";var n=r(60),i=r(387),s=r(388)(),a=r(158),o=r(70),l=n("%Math.floor%");t.exports=function(t,e){if("function"!=typeof t)throw new o("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||l(e)!==e)throw new o("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,c=!0;if("length"in t&&a){var u=a(t,"length");u&&!u.configurable&&(n=!1),u&&!u.writable&&(c=!1)}return(n||c||!r)&&(s?i(t,"length",e,!0,!0):i(t,"length",e)),t}},function(t,e,r){"use strict";var n=r(119),i=r(157),s=r(70),a=r(158);t.exports=function(t,e,r){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new s("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new s("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new s("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new s("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new s("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new s("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,l=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,u=arguments.length>6&&arguments[6],h=!!a&&a(t,e);if(n)n(t,e,{configurable:null===c&&h?h.configurable:!c,enumerable:null===o&&h?h.enumerable:!o,value:r,writable:null===l&&h?h.writable:!l});else{if(!u&&(o||l||c))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=r}}},function(t,e,r){"use strict";var n=r(119),i=function(){return!!n};i.hasArrayLengthDefineBug=function(){if(!n)return null;try{return 1!==n([],"length",{value:1}).length}catch(t){return!0}},t.exports=i},function(t,e,r){(function(e){var n="function"==typeof Map&&Map.prototype,i=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,s=n&&i&&"function"==typeof i.get?i.get:null,a=n&&Map.prototype.forEach,o="function"==typeof Set&&Set.prototype,l=Object.getOwnPropertyDescriptor&&o?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,c=o&&l&&"function"==typeof l.get?l.get:null,u=o&&Set.prototype.forEach,h="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,d="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,f="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,p=Boolean.prototype.valueOf,g=Object.prototype.toString,m=Function.prototype.toString,y=String.prototype.match,v=String.prototype.slice,E=String.prototype.replace,b=String.prototype.toUpperCase,T=String.prototype.toLowerCase,S=RegExp.prototype.test,A=Array.prototype.concat,_=Array.prototype.join,k=Array.prototype.slice,L=Math.floor,w="function"==typeof BigInt?BigInt.prototype.valueOf:null,R=Object.getOwnPropertySymbols,C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,D="function"==typeof Symbol&&"object"==typeof Symbol.iterator,I="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===D||"symbol")?Symbol.toStringTag:null,x=Object.prototype.propertyIsEnumerable,P=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function O(t,e){if(t===1/0||t===-1/0||t!=t||t&&t>-1e3&&t<1e3||S.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof t){var n=t<0?-L(-t):L(t);if(n!==t){var i=String(n),s=v.call(e,i.length+1);return E.call(i,r,"$&_")+"."+E.call(E.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return E.call(e,r,"$&_")}var M=r(390),F=M.custom,B=H(F)?F:null,N={__proto__:null,double:'"',single:"'"},U={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};function $(t,e,r){var n=r.quoteStyle||e,i=N[n];return i+t+i}function j(t){return E.call(String(t),/"/g,""")}function G(t){return!("[object Array]"!==Y(t)||I&&"object"==typeof t&&I in t)}function K(t){return!("[object RegExp]"!==Y(t)||I&&"object"==typeof t&&I in t)}function H(t){if(D)return t&&"object"==typeof t&&t instanceof Symbol;if("symbol"==typeof t)return!0;if(!t||"object"!=typeof t||!C)return!1;try{return C.call(t),!0}catch(t){}return!1}t.exports=function t(r,n,i,o){var l=n||{};if(W(l,"quoteStyle")&&!W(N,l.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(W(l,"maxStringLength")&&("number"==typeof l.maxStringLength?l.maxStringLength<0&&l.maxStringLength!==1/0:null!==l.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var g=!W(l,"customInspect")||l.customInspect;if("boolean"!=typeof g&&"symbol"!==g)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(W(l,"indent")&&null!==l.indent&&"\t"!==l.indent&&!(parseInt(l.indent,10)===l.indent&&l.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(W(l,"numericSeparator")&&"boolean"!=typeof l.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var b=l.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 z(r,l);if("number"==typeof r){if(0===r)return 1/0/r>0?"0":"-0";var S=String(r);return b?O(r,S):S}if("bigint"==typeof r){var L=String(r)+"n";return b?O(r,L):L}var R=void 0===l.depth?5:l.depth;if(void 0===i&&(i=0),i>=R&&R>0&&"object"==typeof r)return G(r)?"[Array]":"[Object]";var F=function(t,e){var r;if("\t"===t.indent)r="\t";else{if(!("number"==typeof t.indent&&t.indent>0))return null;r=_.call(Array(t.indent+1)," ")}return{base:r,prev:_.call(Array(e+1),r)}}(l,i);if(void 0===o)o=[];else if(q(o,r)>=0)return"[Circular]";function U(e,r,n){if(r&&(o=k.call(o)).push(r),n){var s={depth:l.depth};return W(l,"quoteStyle")&&(s.quoteStyle=l.quoteStyle),t(e,s,i+1,o)}return t(e,l,i+1,o)}if("function"==typeof r&&!K(r)){var V=function(t){if(t.name)return t.name;var e=y.call(m.call(t),/^function\s*([\w$]+)/);if(e)return e[1];return null}(r),X=et(r,U);return"[Function"+(V?": "+V:" (anonymous)")+"]"+(X.length>0?" { "+_.call(X,", ")+" }":"")}if(H(r)){var rt=D?E.call(String(r),/^(Symbol\(.*\))_[^)]*$/,"$1"):C.call(r);return"object"!=typeof r||D?rt:Q(rt)}if(function(t){if(!t||"object"!=typeof t)return!1;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return!0;return"string"==typeof t.nodeName&&"function"==typeof t.getAttribute}(r)){for(var nt="<"+T.call(String(r.nodeName)),it=r.attributes||[],st=0;st"}if(G(r)){if(0===r.length)return"[]";var at=et(r,U);return F&&!function(t){for(var e=0;e=0)return!1;return!0}(at)?"["+tt(at,F)+"]":"[ "+_.call(at,", ")+" ]"}if(function(t){return!("[object Error]"!==Y(t)||I&&"object"==typeof t&&I in t)}(r)){var ot=et(r,U);return"cause"in Error.prototype||!("cause"in r)||x.call(r,"cause")?0===ot.length?"["+String(r)+"]":"{ ["+String(r)+"] "+_.call(ot,", ")+" }":"{ ["+String(r)+"] "+_.call(A.call("[cause]: "+U(r.cause),ot),", ")+" }"}if("object"==typeof r&&g){if(B&&"function"==typeof r[B]&&M)return M(r,{depth:R-i});if("symbol"!==g&&"function"==typeof r.inspect)return r.inspect()}if(function(t){if(!s||!t||"object"!=typeof t)return!1;try{s.call(t);try{c.call(t)}catch(t){return!0}return t instanceof Map}catch(t){}return!1}(r)){var lt=[];return a&&a.call(r,(function(t,e){lt.push(U(e,r,!0)+" => "+U(t,r))})),Z("Map",s.call(r),lt,F)}if(function(t){if(!c||!t||"object"!=typeof t)return!1;try{c.call(t);try{s.call(t)}catch(t){return!0}return t instanceof Set}catch(t){}return!1}(r)){var ct=[];return u&&u.call(r,(function(t){ct.push(U(t,r))})),Z("Set",c.call(r),ct,F)}if(function(t){if(!h||!t||"object"!=typeof t)return!1;try{h.call(t,h);try{d.call(t,d)}catch(t){return!0}return t instanceof WeakMap}catch(t){}return!1}(r))return J("WeakMap");if(function(t){if(!d||!t||"object"!=typeof t)return!1;try{d.call(t,d);try{h.call(t,h)}catch(t){return!0}return t instanceof WeakSet}catch(t){}return!1}(r))return J("WeakSet");if(function(t){if(!f||!t||"object"!=typeof t)return!1;try{return f.call(t),!0}catch(t){}return!1}(r))return J("WeakRef");if(function(t){return!("[object Number]"!==Y(t)||I&&"object"==typeof t&&I in t)}(r))return Q(U(Number(r)));if(function(t){if(!t||"object"!=typeof t||!w)return!1;try{return w.call(t),!0}catch(t){}return!1}(r))return Q(U(w.call(r)));if(function(t){return!("[object Boolean]"!==Y(t)||I&&"object"==typeof t&&I in t)}(r))return Q(p.call(r));if(function(t){return!("[object String]"!==Y(t)||I&&"object"==typeof t&&I in t)}(r))return Q(U(String(r)));if("undefined"!=typeof window&&r===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&r===globalThis||void 0!==e&&r===e)return"{ [object globalThis] }";if(!function(t){return!("[object Date]"!==Y(t)||I&&"object"==typeof t&&I in t)}(r)&&!K(r)){var ut=et(r,U),ht=P?P(r)===Object.prototype:r instanceof Object||r.constructor===Object,dt=r instanceof Object?"":"null prototype",ft=!ht&&I&&Object(r)===r&&I in r?v.call(Y(r),8,-1):dt?"Object":"",pt=(ht||"function"!=typeof r.constructor?"":r.constructor.name?r.constructor.name+" ":"")+(ft||dt?"["+_.call(A.call([],ft||[],dt||[]),": ")+"] ":"");return 0===ut.length?pt+"{}":F?pt+"{"+tt(ut,F)+"}":pt+"{ "+_.call(ut,", ")+" }"}return String(r)};var V=Object.prototype.hasOwnProperty||function(t){return t in this};function W(t,e){return V.call(t,e)}function Y(t){return g.call(t)}function q(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,n=t.length;re.maxStringLength){var r=t.length-e.maxStringLength,n="... "+r+" more character"+(r>1?"s":"");return z(v.call(t,0,e.maxStringLength),e)+n}var i=U[e.quoteStyle||"single"];return i.lastIndex=0,$(E.call(E.call(t,i,"\\$1"),/[\x00-\x1f]/g,X),"single",e)}function X(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+b.call(e.toString(16))}function Q(t){return"Object("+t+")"}function J(t){return t+" { ? }"}function Z(t,e,r,n){return t+" ("+e+") {"+(n?tt(r,n):_.call(r,", "))+"}"}function tt(t,e){if(0===t.length)return"";var r="\n"+e.prev+e.base;return r+_.call(t,","+r)+"\n"+e.prev}function et(t,e){var r=G(t),n=[];if(r){n.length=t.length;for(var i=0;i-1?t.split(","):t},c=function(t,e,r,n){if(t){var s=r.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,a=/(\[[^[\]]*])/g,o=r.depth>0&&/(\[[^[\]]*])/.exec(s),c=o?s.slice(0,o.index):s,u=[];if(c){if(!r.plainObjects&&i.call(Object.prototype,c)&&!r.allowPrototypes)return;u.push(c)}for(var h=0;r.depth>0&&null!==(o=a.exec(s))&&h=0;--s){var a,o=t[s];if("[]"===o&&r.parseArrays)a=r.allowEmptyArrays&&(""===i||r.strictNullHandling&&null===i)?[]:[].concat(i);else{a=r.plainObjects?{__proto__:null}:{};var c="["===o.charAt(0)&&"]"===o.charAt(o.length-1)?o.slice(1,-1):o,u=r.decodeDotInKeys?c.replace(/%2E/g,"."):c,h=parseInt(u,10);r.parseArrays||""!==u?!isNaN(h)&&o!==u&&String(h)===u&&h>=0&&r.parseArrays&&h<=r.arrayLimit?(a=[])[h]=i:"__proto__"!==u&&(a[u]=i):a={0:i}}i=a}return i}(u,e,r,n)}};t.exports=function(t,e){var r=function(t){if(!t)return a;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.decodeDotInKeys&&"boolean"!=typeof t.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.decoder&&void 0!==t.decoder&&"function"!=typeof t.decoder)throw new TypeError("Decoder has to be a function.");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 e=void 0===t.charset?a.charset:t.charset,r=void 0===t.duplicates?a.duplicates:t.duplicates;if("combine"!==r&&"first"!==r&&"last"!==r)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===t.allowDots?!0===t.decodeDotInKeys||a.allowDots:!!t.allowDots,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:a.allowEmptyArrays,allowPrototypes:"boolean"==typeof t.allowPrototypes?t.allowPrototypes:a.allowPrototypes,allowSparse:"boolean"==typeof t.allowSparse?t.allowSparse:a.allowSparse,arrayLimit:"number"==typeof t.arrayLimit?t.arrayLimit:a.arrayLimit,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:a.charsetSentinel,comma:"boolean"==typeof t.comma?t.comma:a.comma,decodeDotInKeys:"boolean"==typeof t.decodeDotInKeys?t.decodeDotInKeys:a.decodeDotInKeys,decoder:"function"==typeof t.decoder?t.decoder:a.decoder,delimiter:"string"==typeof t.delimiter||n.isRegExp(t.delimiter)?t.delimiter:a.delimiter,depth:"number"==typeof t.depth||!1===t.depth?+t.depth:a.depth,duplicates:r,ignoreQueryPrefix:!0===t.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof t.interpretNumericEntities?t.interpretNumericEntities:a.interpretNumericEntities,parameterLimit:"number"==typeof t.parameterLimit?t.parameterLimit:a.parameterLimit,parseArrays:!1!==t.parseArrays,plainObjects:"boolean"==typeof t.plainObjects?t.plainObjects:a.plainObjects,strictDepth:"boolean"==typeof t.strictDepth?!!t.strictDepth:a.strictDepth,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:a.strictNullHandling}}(e);if(""===t||null==t)return r.plainObjects?{__proto__:null}:{};for(var u="string"==typeof t?function(t,e){var r={__proto__:null},c=e.ignoreQueryPrefix?t.replace(/^\?/,""):t;c=c.replace(/%5B/gi,"[").replace(/%5D/gi,"]");var u,h=e.parameterLimit===1/0?void 0:e.parameterLimit,d=c.split(e.delimiter,h),f=-1,p=e.charset;if(e.charsetSentinel)for(u=0;u-1&&(m=s(m)?[m]:m);var b=i.call(r,g);b&&"combine"===e.duplicates?r[g]=n.combine(r[g],m):b&&"last"!==e.duplicates||(r[g]=m)}return r}(t,r):t,h=r.plainObjects?{__proto__:null}:{},d=Object.keys(u),f=0;ful{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(t){var e="undefined"!=typeof window&&window.location;if(!e)throw new Error("fixUrls requires window.location");if(!t||"string"!=typeof t)return t;var r=e.protocol+"//"+e.host,n=r+e.pathname.replace(/\/[^\/]*$/,"/");return t.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,(function(t,e){var i,s=e.trim().replace(/^"(.*)"$/,(function(t,e){return e})).replace(/^'(.*)'$/,(function(t,e){return e}));return/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(s)?t:(i=0===s.indexOf("//")?s:0===s.indexOf("/")?r+s:n+s.replace(/^\.\//,""),"url("+JSON.stringify(i)+")")}))}},function(t,e){t.exports=function(t){throw new TypeError('"'+t+'" is read-only')},t.exports.__esModule=!0,t.exports.default=t.exports},function(t,e){function r(t,e,r){t.addEventListener("wheel",e,r)}t.exports=r,t.exports.addWheelListener=r,t.exports.removeWheelListener=function(t,e,r){t.removeEventListener("wheel",e,r)}},function(t,e,r){var n=r(397),i={ease:n(.25,.1,.25,1),easeIn:n(.42,0,1,1),easeOut:n(0,0,.58,1),easeInOut:n(.42,0,.58,1),linear:n(0,0,1,1)};function s(){}function a(){var t=new Set,e=new Set,r=0;return{next:n,cancel:n,clearAll:function(){t.clear(),e.clear(),cancelAnimationFrame(r),r=0}};function n(t){e.add(t),r||(r=requestAnimationFrame(i))}function i(){r=0;var n=e;e=t,(t=n).forEach((function(t){t()})),t.clear()}}t.exports=function(t,e,r){var n=Object.create(null),a=Object.create(null),o="function"==typeof(r=r||{}).easing?r.easing:i[r.easing];o||(r.easing&&console.warn("Unknown easing function in amator: "+r.easing),o=i.ease);var l="function"==typeof r.step?r.step:s,c="function"==typeof r.done?r.done:s,u=function(t){if(!t){return"undefined"!=typeof window&&window.requestAnimationFrame?{next:window.requestAnimationFrame.bind(window),cancel:window.cancelAnimationFrame.bind(window)}:{next:function(t){return setTimeout(t,1e3/60)},cancel:function(t){return clearTimeout(t)}}}if("function"!=typeof t.next)throw new Error("Scheduler is supposed to have next(cb) function");if("function"!=typeof t.cancel)throw new Error("Scheduler is supposed to have cancel(handle) function");return t}(r.scheduler),h=Object.keys(e);h.forEach((function(r){n[r]=t[r],a[r]=e[r]-t[r]}));var d,f="number"==typeof r.duration?r.duration:400,p=Math.max(1,.06*f),g=0;return d=u.next((function e(){var r=o(g/p);g+=1,m(r),g<=p?(d=u.next(e),l(t)):(d=0,setTimeout((function(){c(t)}),0))})),{cancel:function(){u.cancel(d),d=0}};function m(e){h.forEach((function(r){t[r]=a[r]*e+n[r]}))}},t.exports.makeAggregateRaf=a,t.exports.sharedScheduler=a()},function(t,e){var r=.1,n="function"==typeof Float32Array;function i(t,e){return 1-3*e+3*t}function s(t,e){return 3*e-6*t}function a(t){return 3*t}function o(t,e,r){return((i(e,r)*t+s(e,r))*t+a(e))*t}function l(t,e,r){return 3*i(e,r)*t*t+2*s(e,r)*t+a(e)}function c(t){return t}t.exports=function(t,e,i,s){if(!(0<=t&&t<=1&&0<=i&&i<=1))throw new Error("bezier x values must be in [0, 1] range");if(t===e&&i===s)return c;for(var a=n?new Float32Array(11):new Array(11),u=0;u<11;++u)a[u]=o(u*r,t,i);function h(e){for(var n=0,s=1;10!==s&&a[s]<=e;++s)n+=r;--s;var c=n+(e-a[s])/(a[s+1]-a[s])*r,u=l(c,t,i);return u>=.001?function(t,e,r,n){for(var i=0;i<4;++i){var s=l(e,r,n);if(0===s)return e;e-=(o(e,r,n)-t)/s}return e}(e,c,t,i):0===u?c:function(t,e,r,n,i){var s,a,l=0;do{(s=o(a=e+(r-e)/2,n,i)-t)>0?r=a:e=a}while(Math.abs(s)>1e-7&&++l<10);return a}(e,n,n+r,t,i)}return function(t){return 0===t?0:1===t?1:o(h(t),e,s)}}},function(t,e){t.exports=function(t){!function(t){if(!t)throw new Error("Eventify cannot use falsy object as events subject");for(var e=["on","fire","off"],r=0;r1&&(n=Array.prototype.splice.call(arguments,1));for(var s=0;sul{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}.audioTrackSelector[data-audioTrackSelector] li{font-size:12px;color:#eee}.audioTrackSelector[data-audioTrackSelector] li[data-title]{background-color:#333;padding:8px 25px}.audioTrackSelector[data-audioTrackSelector] li a{color:#eee;padding:5px 18px;display:block;text-decoration:none}.audioTrackSelector[data-audioTrackSelector] li a:hover{background-color:rgba(255,255,255,.1);color:#fff}.audioTrackSelector[data-audioTrackSelector] li a:hover a{color:#fff;text-decoration:none}.audioTrackSelector[data-audioTrackSelector] li.current a{color:#2ecc71}@-webkit-keyframes pulse{0%{color:#fff}50%{color:#ff0101}100%{color:#b80000}}',""])}]).default;