@clappr/player 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clappr.js +23 -23
- package/dist/clappr.js.map +1 -1
- package/dist/clappr.min.js +1 -1
- package/dist/clappr.min.js.map +1 -1
- package/dist/clappr.plainhtml5.js +22 -22
- package/dist/clappr.plainhtml5.js.map +1 -1
- package/dist/clappr.plainhtml5.min.js +1 -1
- package/dist/clappr.plainhtml5.min.js.map +1 -1
- package/package.json +5 -5
package/dist/clappr.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Clappr=function(){"use strict";function t(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function e(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function i(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function n(t,e,i){return e=g(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,r()?Reflect.construct(e,i||[],g(t).constructor):e.apply(t,i))}function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(r=function(){return!!t})()}function s(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function a(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?s(Object(i),!0).forEach((function(e){d(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function o(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function l(t){return l="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},l(t)}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,o(n.key),n)}}function u(t,e,i){return e&&h(t.prototype,e),i&&h(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function d(t,e,i){return(e=o(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}function g(t){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},g(t)}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function m(){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=g(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},m.apply(this,arguments)}function v(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var n,r,s,a,o=[],l=!0,c=!1;try{if(s=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;l=!1}else for(;!(l=(n=s.call(i)).done)&&(o.push(n.value),o.length!==e);l=!0);}catch(t){c=!0,r=t}finally{try{if(!l&&null!=i.return&&(a=i.return(),Object(a)!==a))return}finally{if(c)throw r}}return o}}(t,e)||A(t,e)||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.")}()}function y(t){return function(t){if(Array.isArray(t))return E(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||A(t)||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.")}()}function A(t,e){if(t){if("string"==typeof t)return E(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?E(t,e):void 0}}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function T(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=A(t))||e){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return a=t.done,t},e:function(t){o=!0,s=t},f:function(){try{a||null==i.return||i.return()}finally{if(o)throw s}}}}function b(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var k=function(){var t,e,i,n,r,s,a=[],o=a.concat,l=a.filter,c=a.slice,h=window.document,u={},d={},f={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},g=/^\s*<(\w+|!)[^>]*>/,p=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,m=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,v=/^(?:body|html)$/i,y=/([A-Z])/g,A=["val","css","html","text","data","width","height","offset"],E=h.createElement("table"),T=h.createElement("tr"),b={tr:h.createElement("tbody"),tbody:E,thead:E,tfoot:E,td:T,th:T,"*":h.createElement("div")},k=/complete|loaded|interactive/,S=/^[\w-]*$/,_={},L=_.toString,R={},C=h.createElement("div"),w={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},I=Array.isArray||function(t){return t instanceof Array};function D(t){return null==t?String(t):_[L.call(t)]||"object"}function P(t){return"function"==D(t)}function O(t){return null!=t&&t==t.window}function x(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function N(t){return"object"==D(t)}function M(t){return N(t)&&!O(t)&&Object.getPrototypeOf(t)==Object.prototype}function F(t){var e=!!t&&"length"in t&&t.length,n=i.type(t);return"function"!=n&&!O(t)&&("array"==n||0===e||"number"==typeof e&&e>0&&e-1 in t)}function B(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function U(t){return t in d?d[t]:d[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function $(t,e){return"number"!=typeof e||f[B(t)]?e:e+"px"}function G(t){return"children"in t?c.call(t.children):i.map(t.childNodes,(function(t){if(1==t.nodeType)return t}))}function V(t,e){var i,n=t?t.length:0;for(i=0;i<n;i++)this[i]=t[i];this.length=n,this.selector=e||""}function K(i,n,r){for(e in n)r&&(M(n[e])||I(n[e]))?(M(n[e])&&!M(i[e])&&(i[e]={}),I(n[e])&&!I(i[e])&&(i[e]=[]),K(i[e],n[e],r)):n[e]!==t&&(i[e]=n[e])}function H(t,e){return null==e?i(t):i(t).filter(e)}function Y(t,e,i,n){return P(e)?e.call(t,i,n):e}function j(t,e,i){null==i?t.removeAttribute(e):t.setAttribute(e,i)}function W(e,i){var n=e.className||"",r=n&&n.baseVal!==t;if(i===t)return r?n.baseVal:n;r?n.baseVal=i:e.className=i}function z(t){try{return t?"true"==t||"false"!=t&&("null"==t?null:+t+""==t?+t:/^[\[\{]/.test(t)?i.parseJSON(t):t):t}catch(e){return t}}function q(t,e){e(t);for(var i=0,n=t.childNodes.length;i<n;i++)q(t.childNodes[i],e)}return R.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var i=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(i)return i.call(t,e);var n,r=t.parentNode,s=!r;return s&&(r=C).appendChild(t),n=~R.qsa(r,e).indexOf(t),s&&C.removeChild(t),n},r=function(t){return t.replace(/-+(.)?/g,(function(t,e){return e?e.toUpperCase():""}))},s=function(t){return l.call(t,(function(e,i){return t.indexOf(e)==i}))},R.fragment=function(e,n,r){var s,a,o;return p.test(e)&&(s=i(h.createElement(RegExp.$1))),s||(e.replace&&(e=e.replace(m,"<$1></$2>")),n===t&&(n=g.test(e)&&RegExp.$1),n in b||(n="*"),(o=b[n]).innerHTML=""+e,s=i.each(c.call(o.childNodes),(function(){o.removeChild(this)}))),M(r)&&(a=i(s),i.each(r,(function(t,e){A.indexOf(t)>-1?a[t](e):a.attr(t,e)}))),s},R.Z=function(t,e){return new V(t,e)},R.isZ=function(t){return t instanceof R.Z},R.init=function(e,n){var r,s;if(!e)return R.Z();if("string"==typeof e)if("<"==(e=e.trim())[0]&&g.test(e))r=R.fragment(e,RegExp.$1,n),e=null;else{if(n!==t)return i(n).find(e);r=R.qsa(h,e)}else{if(P(e))return i(h).ready(e);if(R.isZ(e))return e;if(I(e))s=e,r=l.call(s,(function(t){return null!=t}));else if(N(e))r=[e],e=null;else if(g.test(e))r=R.fragment(e.trim(),RegExp.$1,n),e=null;else{if(n!==t)return i(n).find(e);r=R.qsa(h,e)}}return R.Z(r,e)},(i=function(t,e){return R.init(t,e)}).extend=function(t){var e,i=c.call(arguments,1);return"boolean"==typeof t&&(e=t,t=i.shift()),i.forEach((function(i){K(t,i,e)})),t},R.qsa=function(t,e){var i,n="#"==e[0],r=!n&&"."==e[0],s=n||r?e.slice(1):e,a=S.test(s);return t.getElementById&&a&&n?(i=t.getElementById(s))?[i]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:c.call(a&&!n&&t.getElementsByClassName?r?t.getElementsByClassName(s):t.getElementsByTagName(e):t.querySelectorAll(e))},i.contains=h.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},i.type=D,i.isFunction=P,i.isWindow=O,i.isArray=I,i.isPlainObject=M,i.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},i.isNumeric=function(t){var e=Number(t),i=typeof t;return null!=t&&"boolean"!=i&&("string"!=i||t.length)&&!isNaN(e)&&isFinite(e)||!1},i.inArray=function(t,e,i){return a.indexOf.call(e,t,i)},i.camelCase=r,i.trim=function(t){return null==t?"":String.prototype.trim.call(t)},i.uuid=0,i.support={},i.expr={},i.noop=function(){},i.map=function(t,e){var n,r,s,a,o=[];if(F(t))for(r=0;r<t.length;r++)null!=(n=e(t[r],r))&&o.push(n);else for(s in t)null!=(n=e(t[s],s))&&o.push(n);return(a=o).length>0?i.fn.concat.apply([],a):a},i.each=function(t,e){var i,n;if(F(t)){for(i=0;i<t.length;i++)if(!1===e.call(t[i],i,t[i]))return t}else for(n in t)if(!1===e.call(t[n],n,t[n]))return t;return t},i.grep=function(t,e){return l.call(t,e)},window.JSON&&(i.parseJSON=JSON.parse),i.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),(function(t,e){_["[object "+e+"]"]=e.toLowerCase()})),i.fn={constructor:R.Z,length:0,forEach:a.forEach,reduce:a.reduce,push:a.push,sort:a.sort,splice:a.splice,indexOf:a.indexOf,concat:function(){var t,e,i=[];for(t=0;t<arguments.length;t++)e=arguments[t],i[t]=R.isZ(e)?e.toArray():e;return o.apply(R.isZ(this)?this.toArray():this,i)},map:function(t){return i(i.map(this,(function(e,i){return t.call(e,i,e)})))},slice:function(){return i(c.apply(this,arguments))},ready:function(t){return k.test(h.readyState)&&h.body?t(i):h.addEventListener("DOMContentLoaded",(function(){t(i)}),!1),this},get:function(e){return e===t?c.call(this):this[e>=0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each((function(){null!=this.parentNode&&this.parentNode.removeChild(this)}))},each:function(t){return a.every.call(this,(function(e,i){return!1!==t.call(e,i,e)})),this},filter:function(t){return P(t)?this.not(this.not(t)):i(l.call(this,(function(e){return R.matches(e,t)})))},add:function(t,e){return i(s(this.concat(i(t,e))))},is:function(t){return this.length>0&&R.matches(this[0],t)},not:function(e){var n=[];if(P(e)&&e.call!==t)this.each((function(t){e.call(this,t)||n.push(this)}));else{var r="string"==typeof e?this.filter(e):F(e)&&P(e.item)?c.call(e):i(e);this.forEach((function(t){r.indexOf(t)<0&&n.push(t)}))}return i(n)},has:function(t){return this.filter((function(){return N(t)?i.contains(this,t):i(this).find(t).size()}))},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!N(t)?t:i(t)},last:function(){var t=this[this.length-1];return t&&!N(t)?t:i(t)},find:function(t){var e=this;return t?"object"==typeof t?i(t).filter((function(){var t=this;return a.some.call(e,(function(e){return i.contains(e,t)}))})):1==this.length?i(R.qsa(this[0],t)):this.map((function(){return R.qsa(this,t)})):i()},closest:function(t,e){var n=[],r="object"==typeof t&&i(t);return this.each((function(i,s){for(;s&&!(r?r.indexOf(s)>=0:R.matches(s,t));)s=s!==e&&!x(s)&&s.parentNode;s&&n.indexOf(s)<0&&n.push(s)})),i(n)},parents:function(t){for(var e=[],n=this;n.length>0;)n=i.map(n,(function(t){if((t=t.parentNode)&&!x(t)&&e.indexOf(t)<0)return e.push(t),t}));return H(e,t)},parent:function(t){return H(s(this.pluck("parentNode")),t)},children:function(t){return H(this.map((function(){return G(this)})),t)},contents:function(){return this.map((function(){return this.contentDocument||c.call(this.childNodes)}))},siblings:function(t){return H(this.map((function(t,e){return l.call(G(e.parentNode),(function(t){return t!==e}))})),t)},empty:function(){return this.each((function(){this.innerHTML=""}))},pluck:function(t){return i.map(this,(function(e){return e[t]}))},show:function(){return this.each((function(){var t,e,i;"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=(t=this.nodeName,u[t]||(e=h.createElement(t),h.body.appendChild(e),i=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==i&&(i="block"),u[t]=i),u[t]))}))},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=P(t);if(this[0]&&!e)var n=i(t).get(0),r=n.parentNode||this.length>1;return this.each((function(s){i(this).wrapAll(e?t.call(this,s):r?n.cloneNode(!0):n)}))},wrapAll:function(t){if(this[0]){var e;for(i(this[0]).before(t=i(t));(e=t.children()).length;)t=e.first();i(t).append(this)}return this},wrapInner:function(t){var e=P(t);return this.each((function(n){var r=i(this),s=r.contents(),a=e?t.call(this,n):t;s.length?s.wrapAll(a):r.append(a)}))},unwrap:function(){return this.parent().each((function(){i(this).replaceWith(i(this).children())})),this},clone:function(){return this.map((function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(e){return this.each((function(){var n=i(this);(e===t?"none"==n.css("display"):e)?n.show():n.hide()}))},prev:function(t){return i(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return i(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each((function(e){var n=this.innerHTML;i(this).empty().append(Y(this,t,e,n))})):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each((function(e){var i=Y(this,t,e,this.textContent);this.textContent=null==i?"":""+i})):0 in this?this.pluck("textContent").join(""):null},attr:function(i,n){var r;return"string"!=typeof i||1 in arguments?this.each((function(t){if(1===this.nodeType)if(N(i))for(e in i)j(this,e,i[e]);else j(this,i,Y(this,n,t,this.getAttribute(i)))})):0 in this&&1==this[0].nodeType&&null!=(r=this[0].getAttribute(i))?r:t},removeAttr:function(t){return this.each((function(){1===this.nodeType&&t.split(" ").forEach((function(t){j(this,t)}),this)}))},prop:function(t,e){return t=w[t]||t,1 in arguments?this.each((function(i){this[t]=Y(this,e,i,this[t])})):this[0]&&this[0][t]},removeProp:function(t){return t=w[t]||t,this.each((function(){delete this[t]}))},data:function(e,i){var n="data-"+e.replace(y,"-$1").toLowerCase(),r=1 in arguments?this.attr(n,i):this.attr(n);return null!==r?z(r):t},val:function(t){return 0 in arguments?(null==t&&(t=""),this.each((function(e){this.value=Y(this,t,e,this.value)}))):this[0]&&(this[0].multiple?i(this[0]).find("option").filter((function(){return this.selected})).pluck("value"):this[0].value)},offset:function(t){if(t)return this.each((function(e){var n=i(this),r=Y(this,t,e,n.offset()),s=n.offsetParent().offset(),a={top:r.top-s.top,left:r.left-s.left};"static"==n.css("position")&&(a.position="relative"),n.css(a)}));if(!this.length)return null;if(h.documentElement!==this[0]&&!i.contains(h.documentElement,this[0]))return{top:0,left:0};var e=this[0].getBoundingClientRect();return{left:e.left+window.pageXOffset,top:e.top+window.pageYOffset,width:Math.round(e.width),height:Math.round(e.height)}},css:function(t,n){if(arguments.length<2){var s=this[0];if("string"==typeof t){if(!s)return;return s.style[r(t)]||getComputedStyle(s,"").getPropertyValue(t)}if(I(t)){if(!s)return;var a={},o=getComputedStyle(s,"");return i.each(t,(function(t,e){a[e]=s.style[r(e)]||o.getPropertyValue(e)})),a}}var l="";if("string"==D(t))n||0===n?l=B(t)+":"+$(t,n):this.each((function(){this.style.removeProperty(B(t))}));else for(e in t)t[e]||0===t[e]?l+=B(e)+":"+$(e,t[e])+";":this.each((function(){this.style.removeProperty(B(e))}));return this.each((function(){this.style.cssText+=";"+l}))},index:function(t){return t?this.indexOf(i(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return!!t&&a.some.call(this,(function(t){return this.test(W(t))}),U(t))},addClass:function(t){return t?this.each((function(e){if("className"in this){n=[];var r=W(this);Y(this,t,e,r).split(/\s+/g).forEach((function(t){i(this).hasClass(t)||n.push(t)}),this),n.length&&W(this,r+(r?" ":"")+n.join(" "))}})):this},removeClass:function(e){return this.each((function(i){if("className"in this){if(e===t)return W(this,"");n=W(this),Y(this,e,i,n).split(/\s+/g).forEach((function(t){n=n.replace(U(t)," ")})),W(this,n.trim())}}))},toggleClass:function(e,n){return e?this.each((function(r){var s=i(this);Y(this,e,r,W(this)).split(/\s+/g).forEach((function(e){(n===t?!s.hasClass(e):n)?s.addClass(e):s.removeClass(e)}))})):this},scrollTop:function(e){if(this.length){var i="scrollTop"in this[0];return e===t?i?this[0].scrollTop:this[0].pageYOffset:this.each(i?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var i="scrollLeft"in this[0];return e===t?i?this[0].scrollLeft:this[0].pageXOffset:this.each(i?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),r=v.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(i(t).css("margin-top"))||0,n.left-=parseFloat(i(t).css("margin-left"))||0,r.top+=parseFloat(i(e[0]).css("border-top-width"))||0,r.left+=parseFloat(i(e[0]).css("border-left-width"))||0,{top:n.top-r.top,left:n.left-r.left}}},offsetParent:function(){return this.map((function(){for(var t=this.offsetParent||h.body;t&&!v.test(t.nodeName)&&"static"==i(t).css("position");)t=t.offsetParent;return t}))}},i.fn.detach=i.fn.remove,["width","height"].forEach((function(e){var n=e.replace(/./,(function(t){return t[0].toUpperCase()}));i.fn[e]=function(r){var s,a=this[0];return r===t?O(a)?a["inner"+n]:x(a)?a.documentElement["scroll"+n]:(s=this.offset())&&s[e]:this.each((function(t){(a=i(this)).css(e,Y(this,r,t,a[e]()))}))}})),["after","prepend","before","append"].forEach((function(e,n){var r=n%2;i.fn[e]=function(){var e,s,a=i.map(arguments,(function(n){var r=[];return"array"==(e=D(n))?(n.forEach((function(e){return e.nodeType!==t?r.push(e):i.zepto.isZ(e)?r=r.concat(e.get()):void(r=r.concat(R.fragment(e)))})),r):"object"==e||null==n?n:R.fragment(n)})),o=this.length>1;return a.length<1?this:this.each((function(t,e){s=r?e:e.parentNode,e=0==n?e.nextSibling:1==n?e.firstChild:2==n?e:null;var l=i.contains(h.documentElement,s);a.forEach((function(t){if(o)t=t.cloneNode(!0);else if(!s)return i(t).remove();s.insertBefore(t,e),l&&q(t,(function(t){if(!(null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src)){var e=t.ownerDocument?t.ownerDocument.defaultView:window;e.eval.call(e,t.innerHTML)}}))}))}))},i.fn[r?e+"To":"insert"+(n?"Before":"After")]=function(t){return i(t)[e](this),this}})),R.Z.prototype=V.prototype=i.fn,R.uniq=s,R.deserializeValue=z,i.zepto=R,i}();window.Zepto=k,void 0===window.$&&(window.$=k),function(t){var e,i,n=+new Date,r=window.document,s=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,a=/^(?:text|application)\/javascript/i,o=/^(?:text|application)\/xml/i,l="application/json",c="text/html",h=/^\s*$/,u=r.createElement("a");function d(e,i,n,s){if(e.global)return function(e,i,n){var r=t.Event(i);return t(e).trigger(r,n),!r.isDefaultPrevented()}(i||r,n,s)}function f(t,e){var i=e.context;if(!1===e.beforeSend.call(i,t,e)||!1===d(e,i,"ajaxBeforeSend",[t,e]))return!1;d(e,i,"ajaxSend",[t,e])}function g(t,e,i,n){var r=i.context,s="success";i.success.call(r,t,s,e),n&&n.resolveWith(r,[t,s,e]),d(i,r,"ajaxSuccess",[e,i,t]),m(s,e,i)}function p(t,e,i,n,r){var s=n.context;n.error.call(s,i,e,t),r&&r.rejectWith(s,[i,e,t]),d(n,s,"ajaxError",[i,n,t||e]),m(e,i,n)}function m(e,i,n){var r=n.context;n.complete.call(r,i,e),d(n,r,"ajaxComplete",[i,n]),function(e){e.global&&! --t.active&&d(e,null,"ajaxStop")}(n)}function v(){}function y(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function A(e,i,n,r){return t.isFunction(i)&&(r=n,n=i,i=void 0),t.isFunction(n)||(r=n,n=void 0),{url:e,data:i,success:n,dataType:r}}u.href=window.location.href,t.active=0,t.ajaxJSONP=function(e,i){if(!("type"in e))return t.ajax(e);var s,a,o=e.jsonpCallback,l=(t.isFunction(o)?o():o)||"Zepto"+n++,c=r.createElement("script"),h=window[l],u=function(e){t(c).triggerHandler("error",e||"abort")},d={abort:u};return i&&i.promise(d),t(c).on("load error",(function(n,r){clearTimeout(a),t(c).off().remove(),"error"!=n.type&&s?g(s[0],d,e,i):p(null,r||"error",d,e,i),window[l]=h,s&&t.isFunction(h)&&h(s[0]),h=s=void 0})),!1===f(d,e)?(u("abort"),d):(window[l]=function(){s=arguments},c.src=e.url.replace(/\?(.+)=\?/,"?$1="+l),r.head.appendChild(c),e.timeout>0&&(a=setTimeout((function(){u("timeout")}),e.timeout)),d)},t.ajaxSettings={type:"GET",beforeSend:v,success:v,error:v,complete:v,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:l,xml:"application/xml, text/xml",html:c,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:v},t.ajax=function(n){var s,m,A=t.extend({},n||{}),E=t.Deferred&&t.Deferred();for(e in t.ajaxSettings)void 0===A[e]&&(A[e]=t.ajaxSettings[e]);!function(e){e.global&&0==t.active++&&d(e,null,"ajaxStart")}(A),A.crossDomain||((s=r.createElement("a")).href=A.url,s.href=s.href,A.crossDomain=u.protocol+"//"+u.host!=s.protocol+"//"+s.host),A.url||(A.url=window.location.toString()),(m=A.url.indexOf("#"))>-1&&(A.url=A.url.slice(0,m)),function(e){e.processData&&e.data&&"string"!=t.type(e.data)&&(e.data=t.param(e.data,e.traditional)),!e.data||e.type&&"GET"!=e.type.toUpperCase()&&"jsonp"!=e.dataType||(e.url=y(e.url,e.data),e.data=void 0)}(A);var T=A.dataType,b=/\?.+=\?/.test(A.url);if(b&&(T="jsonp"),!1!==A.cache&&(n&&!0===n.cache||"script"!=T&&"jsonp"!=T)||(A.url=y(A.url,"_="+Date.now())),"jsonp"==T)return b||(A.url=y(A.url,A.jsonp?A.jsonp+"=?":!1===A.jsonp?"":"callback=?")),t.ajaxJSONP(A,E);var k,S=A.accepts[T],_={},L=function(t,e){_[t.toLowerCase()]=[t,e]},R=/^([\w-]+:)\/\//.test(A.url)?RegExp.$1:window.location.protocol,C=A.xhr(),w=C.setRequestHeader;if(E&&E.promise(C),A.crossDomain||L("X-Requested-With","XMLHttpRequest"),L("Accept",S||"*/*"),(S=A.mimeType||S)&&(S.indexOf(",")>-1&&(S=S.split(",",2)[0]),C.overrideMimeType&&C.overrideMimeType(S)),(A.contentType||!1!==A.contentType&&A.data&&"GET"!=A.type.toUpperCase())&&L("Content-Type",A.contentType||"application/x-www-form-urlencoded"),A.headers)for(i in A.headers)L(i,A.headers[i]);if(C.setRequestHeader=L,C.onreadystatechange=function(){if(4==C.readyState){C.onreadystatechange=v,clearTimeout(k);var e,i=!1;if(C.status>=200&&C.status<300||304==C.status||0==C.status&&"file:"==R){if(T=T||function(t){return t&&(t=t.split(";",2)[0]),t&&(t==c?"html":t==l?"json":a.test(t)?"script":o.test(t)&&"xml")||"text"}(A.mimeType||C.getResponseHeader("content-type")),"arraybuffer"==C.responseType||"blob"==C.responseType)e=C.response;else{e=C.responseText;try{e=function(t,e,i){if(i.dataFilter==v)return t;var n=i.context;return i.dataFilter.call(n,t,e)}(e,T,A),"script"==T?(0,eval)(e):"xml"==T?e=C.responseXML:"json"==T&&(e=h.test(e)?null:t.parseJSON(e))}catch(t){i=t}if(i)return p(i,"parsererror",C,A,E)}g(e,C,A,E)}else p(C.statusText||null,C.status?"error":"abort",C,A,E)}},!1===f(C,A))return C.abort(),p(null,"abort",C,A,E),C;var I=!("async"in A)||A.async;if(C.open(A.type,A.url,I,A.username,A.password),A.xhrFields)for(i in A.xhrFields)C[i]=A.xhrFields[i];for(i in _)w.apply(C,_[i]);return A.timeout>0&&(k=setTimeout((function(){C.onreadystatechange=v,C.abort(),p(null,"timeout",C,A,E)}),A.timeout)),C.send(A.data?A.data:null),C},t.get=function(){return t.ajax(A.apply(null,arguments))},t.post=function(){var e=A.apply(null,arguments);return e.type="POST",t.ajax(e)},t.getJSON=function(){var e=A.apply(null,arguments);return e.dataType="json",t.ajax(e)},t.fn.load=function(e,i,n){if(!this.length)return this;var r,a=this,o=e.split(/\s/),l=A(e,i,n),c=l.success;return o.length>1&&(l.url=o[0],r=o[1]),l.success=function(e){a.html(r?t("<div>").html(e.replace(s,"")).find(r):e),c&&c.apply(a,arguments)},t.ajax(l),this};var E=encodeURIComponent;function T(e,i,n,r){var s,a=t.isArray(i),o=t.isPlainObject(i);t.each(i,(function(i,l){s=t.type(l),r&&(i=n?r:r+"["+(o||"object"==s||"array"==s?i:"")+"]"),!r&&a?e.add(l.name,l.value):"array"==s||!n&&"object"==s?T(e,l,n,i):e.add(i,l)}))}t.param=function(e,i){var n=[];return n.add=function(e,i){t.isFunction(i)&&(i=i()),null==i&&(i=""),this.push(E(e)+"="+E(i))},T(n,e,i),n.join("&").replace(/%20/g,"+")}}(k),function(t){t.Callbacks=function(e){e=t.extend({},e);var i,n,r,s,a,o,l=[],c=!e.once&&[],h=function(t){for(i=e.memory&&t,n=!0,o=s||0,s=0,a=l.length,r=!0;l&&o<a;++o)if(!1===l[o].apply(t[0],t[1])&&e.stopOnFalse){i=!1;break}r=!1,l&&(c?c.length&&h(c.shift()):i?l.length=0:u.disable())},u={add:function(){if(l){var n=l.length,o=function(i){t.each(i,(function(t,i){"function"==typeof i?e.unique&&u.has(i)||l.push(i):i&&i.length&&"string"!=typeof i&&o(i)}))};o(arguments),r?a=l.length:i&&(s=n,h(i))}return this},remove:function(){return l&&t.each(arguments,(function(e,i){for(var n;(n=t.inArray(i,l,n))>-1;)l.splice(n,1),r&&(n<=a&&--a,n<=o&&--o)})),this},has:function(e){return!(!l||!(e?t.inArray(e,l)>-1:l.length))},empty:function(){return a=l.length=0,this},disable:function(){return l=c=i=void 0,this},disabled:function(){return!l},lock:function(){return c=void 0,i||u.disable(),this},locked:function(){return!c},fireWith:function(t,e){return!l||n&&!c||(e=[t,(e=e||[]).slice?e.slice():e],r?c.push(e):h(e)),this},fire:function(){return u.fireWith(this,arguments)},fired:function(){return!!n}};return u}}(k),function(t){var e=Array.prototype.slice;function i(e){var n=[["resolve","done",t.Callbacks({once:1,memory:1}),"resolved"],["reject","fail",t.Callbacks({once:1,memory:1}),"rejected"],["notify","progress",t.Callbacks({memory:1})]],r="pending",s={state:function(){return r},always:function(){return a.done(arguments).fail(arguments),this},then:function(){var e=arguments;return i((function(i){t.each(n,(function(n,r){var o=t.isFunction(e[n])&&e[n];a[r[1]]((function(){var e=o&&o.apply(this,arguments);if(e&&t.isFunction(e.promise))e.promise().done(i.resolve).fail(i.reject).progress(i.notify);else{var n=this===s?i.promise():this,a=o?[e]:arguments;i[r[0]+"With"](n,a)}}))})),e=null})).promise()},promise:function(e){return null!=e?t.extend(e,s):s}},a={};return t.each(n,(function(t,e){var i=e[2],o=e[3];s[e[1]]=i.add,o&&i.add((function(){r=o}),n[1^t][2].disable,n[2][2].lock),a[e[0]]=function(){return a[e[0]+"With"](this===a?s:this,arguments),this},a[e[0]+"With"]=i.fireWith})),s.promise(a),e&&e.call(a,a),a}t.when=function(n){var r,s,a,o=e.call(arguments),l=o.length,c=0,h=1!==l||n&&t.isFunction(n.promise)?l:0,u=1===h?n:i(),d=function(t,i,n){return function(s){i[t]=this,n[t]=arguments.length>1?e.call(arguments):s,n===r?u.notifyWith(i,n):--h||u.resolveWith(i,n)}};if(l>1)for(r=new Array(l),s=new Array(l),a=new Array(l);c<l;++c)o[c]&&t.isFunction(o[c].promise)?o[c].promise().done(d(c,a,o)).fail(u.reject).progress(d(c,s,r)):--h;return h||u.resolveWith(a,o),u.promise()},t.Deferred=i}(k),function(t){var e,i=1,n=Array.prototype.slice,r=t.isFunction,s=function(t){return"string"==typeof t},a={},o={},l="onfocusin"in window,c={focus:"focusin",blur:"focusout"},h={mouseenter:"mouseover",mouseleave:"mouseout"};function u(t){return t._zid||(t._zid=i++)}function d(t,e,i,n){if((e=f(e)).ns)var r=(s=e.ns,new RegExp("(?:^| )"+s.replace(" "," .* ?")+"(?: |$)"));var s;return(a[u(t)]||[]).filter((function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||r.test(t.ns))&&(!i||u(t.fn)===u(i))&&(!n||t.sel==n)}))}function f(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function g(t,e){return t.del&&!l&&t.e in c||!!e}function p(t){return h[t]||l&&c[t]||t}function m(i,n,r,s,o,l,c){var d=u(i),m=a[d]||(a[d]=[]);n.split(/\s/).forEach((function(n){if("ready"==n)return t(document).ready(r);var a=f(n);a.fn=r,a.sel=o,a.e in h&&(r=function(e){var i=e.relatedTarget;if(!i||i!==this&&!t.contains(this,i))return a.fn.apply(this,arguments)}),a.del=l;var u=l||r;a.proxy=function(t){if(!(t=b(t)).isImmediatePropagationStopped()){t.data=s;var n=u.apply(i,t._args==e?[t]:[t].concat(t._args));return!1===n&&(t.preventDefault(),t.stopPropagation()),n}},a.i=m.length,m.push(a),"addEventListener"in i&&i.addEventListener(p(a.e),a.proxy,g(a,c))}))}function v(t,e,i,n,r){var s=u(t);(e||"").split(/\s/).forEach((function(e){d(t,e,i,n).forEach((function(e){delete a[s][e.i],"removeEventListener"in t&&t.removeEventListener(p(e.e),e.proxy,g(e,r))}))}))}o.click=o.mousedown=o.mouseup=o.mousemove="MouseEvents",t.event={add:m,remove:v},t.proxy=function(e,i){var a=2 in arguments&&n.call(arguments,2);if(r(e)){var o=function(){return e.apply(i,a?a.concat(n.call(arguments)):arguments)};return o._zid=u(e),o}if(s(i))return a?(a.unshift(e[i],e),t.proxy.apply(null,a)):t.proxy(e[i],e);throw new TypeError("expected function")},t.fn.bind=function(t,e,i){return this.on(t,e,i)},t.fn.unbind=function(t,e){return this.off(t,e)},t.fn.one=function(t,e,i,n){return this.on(t,e,i,n,1)};var y=function(){return!0},A=function(){return!1},E=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,T={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};function b(i,n){return!n&&i.isDefaultPrevented||(n||(n=i),t.each(T,(function(t,e){var r=n[t];i[t]=function(){return this[e]=y,r&&r.apply(n,arguments)},i[e]=A})),i.timeStamp||(i.timeStamp=Date.now()),(n.defaultPrevented!==e?n.defaultPrevented:"returnValue"in n?!1===n.returnValue:n.getPreventDefault&&n.getPreventDefault())&&(i.isDefaultPrevented=y)),i}function k(t){var i,n={originalEvent:t};for(i in t)E.test(i)||t[i]===e||(n[i]=t[i]);return b(n,t)}t.fn.delegate=function(t,e,i){return this.on(e,t,i)},t.fn.undelegate=function(t,e,i){return this.off(e,t,i)},t.fn.live=function(e,i){return t(document.body).delegate(this.selector,e,i),this},t.fn.die=function(e,i){return t(document.body).undelegate(this.selector,e,i),this},t.fn.on=function(i,a,o,l,c){var h,u,d=this;return i&&!s(i)?(t.each(i,(function(t,e){d.on(t,a,o,e,c)})),d):(s(a)||r(l)||!1===l||(l=o,o=a,a=e),l!==e&&!1!==o||(l=o,o=e),!1===l&&(l=A),d.each((function(e,r){c&&(h=function(t){return v(r,t.type,l),l.apply(this,arguments)}),a&&(u=function(e){var i,s=t(e.target).closest(a,r).get(0);if(s&&s!==r)return i=t.extend(k(e),{currentTarget:s,liveFired:r}),(h||l).apply(s,[i].concat(n.call(arguments,1)))}),m(r,i,l,o,a,u||h)})))},t.fn.off=function(i,n,a){var o=this;return i&&!s(i)?(t.each(i,(function(t,e){o.off(t,n,e)})),o):(s(n)||r(a)||!1===a||(a=n,n=e),!1===a&&(a=A),o.each((function(){v(this,i,a,n)})))},t.fn.trigger=function(e,i){return(e=s(e)||t.isPlainObject(e)?t.Event(e):b(e))._args=i,this.each((function(){e.type in c&&"function"==typeof this[e.type]?this[e.type]():"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,i)}))},t.fn.triggerHandler=function(e,i){var n,r;return this.each((function(a,o){(n=k(s(e)?t.Event(e):e))._args=i,n.target=o,t.each(d(o,e.type||e),(function(t,e){if(r=e.proxy(n),n.isImmediatePropagationStopped())return!1}))})),r},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach((function(e){t.fn[e]=function(t){return 0 in arguments?this.bind(e,t):this.trigger(e)}})),t.Event=function(t,e){s(t)||(t=(e=t).type);var i=document.createEvent(o[t]||"Events"),n=!0;if(e)for(var r in e)"bubbles"==r?n=!!e[r]:i[r]=e[r];return i.initEvent(t,n,!0),b(i)}}(k),function(){try{getComputedStyle(void 0)}catch(e){var t=getComputedStyle;window.getComputedStyle=function(e,i){try{return t(e,i)}catch(t){return null}}}}(),function(t){var e=t.zepto,i=e.qsa,n=e.matches;function r(e){return!(!(e=t(e)).width()&&!e.height())&&"none"!==e.css("display")}var s=t.expr[":"]={visible:function(){if(r(this))return this},hidden:function(){if(!r(this))return this},selected:function(){if(this.selected)return this},checked:function(){if(this.checked)return this},parent:function(){return this.parentNode},first:function(t){if(0===t)return this},last:function(t,e){if(t===e.length-1)return this},eq:function(t,e,i){if(t===i)return this},contains:function(e,i,n){if(t(this).text().indexOf(n)>-1)return this},has:function(t,i,n){if(e.qsa(this,n).length)return this}},a=new RegExp("(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*"),o=/^\s*>/,l="Zepto"+ +new Date;function c(t,e){t=t.replace(/=#\]/g,'="#"]');var i,n,r=a.exec(t);if(r&&r[2]in s&&(i=s[r[2]],n=r[3],t=r[1],n)){var o=Number(n);n=isNaN(o)?n.replace(/^["']|["']$/g,""):o}return e(t,i,n)}e.qsa=function(n,r){return c(r,(function(s,a,c){try{var h;!s&&a?s="*":o.test(s)&&(h=t(n).addClass(l),s="."+l+" "+s);var u=i(n,s)}catch(t){throw console.error("error performing selector: %o",r),t}finally{h&&h.removeClass(l)}return a?e.uniq(t.map(u,(function(t,e){return a.call(t,e,u,c)}))):u}))},e.matches=function(t,e){return c(e,(function(e,i,r){return(!e||n(t,e))&&(!i||i.call(t,null,r)===t)}))}}(k);var S=b(k);Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var s=e[r];if(t.call(n,s,r,e))return s;r++}}}),Object.entries||(Object.entries=function(t){for(var e=Object.keys(t),i=e.length,n=new Array(i);i--;)n[i]=[e[i],t[e[i]]];return n}),Object.values||(Object.values=function(t){for(var e=Object.keys(t),i=e.length,n=new Array(i);i--;)n[i]=t[e[i]];return n}),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])}return i},writable:!0,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var s=e[r];if(t.call(n,s,r,e))return r;r++}return-1},configurable:!0,writable:!0});var _,L,R,C={mp4:"data:video/mp4;base64,AAAAHGZ0eXBpc29tAAACAGlzb21pc28ybXA0MQAAAAhmcmVlAAAC721kYXQhEAUgpBv/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3pwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcCEQBSCkG//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADengAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAsJtb292AAAAbG12aGQAAAAAAAAAAAAAAAAAAAPoAAAALwABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAB7HRyYWsAAABcdGtoZAAAAAMAAAAAAAAAAAAAAAIAAAAAAAAALwAAAAAAAAAAAAAAAQEAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAAC8AAAAAAAEAAAAAAWRtZGlhAAAAIG1kaGQAAAAAAAAAAAAAAAAAAKxEAAAIAFXEAAAAAAAtaGRscgAAAAAAAAAAc291bgAAAAAAAAAAAAAAAFNvdW5kSGFuZGxlcgAAAAEPbWluZgAAABBzbWhkAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAADTc3RibAAAAGdzdHNkAAAAAAAAAAEAAABXbXA0YQAAAAAAAAABAAAAAAAAAAAAAgAQAAAAAKxEAAAAAAAzZXNkcwAAAAADgICAIgACAASAgIAUQBUAAAAAAfQAAAHz+QWAgIACEhAGgICAAQIAAAAYc3R0cwAAAAAAAAABAAAAAgAABAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAIAAAABAAAAHHN0c3oAAAAAAAAAAAAAAAIAAAFzAAABdAAAABRzdGNvAAAAAAAAAAEAAAAsAAAAYnVkdGEAAABabWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAtaWxzdAAAACWpdG9vAAAAHWRhdGEAAAABAAAAAExhdmY1Ni40MC4xMDE="},w=[{name:"Chromium",group:"Chrome",identifier:"Chromium/([0-9.]*)"},{name:"Chrome Mobile",group:"Chrome",identifier:"Chrome/([0-9.]*) Mobile",versionIdentifier:"Chrome/([0-9.]*)"},{name:"Chrome",group:"Chrome",identifier:"Chrome/([0-9.]*)"},{name:"Chrome for iOS",group:"Chrome",identifier:"CriOS/([0-9.]*)"},{name:"Android Browser",group:"Chrome",identifier:"CrMo/([0-9.]*)"},{name:"Firefox",group:"Firefox",identifier:"Firefox/([0-9.]*)"},{name:"Opera Mini",group:"Opera",identifier:"Opera Mini/([0-9.]*)"},{name:"Opera",group:"Opera",identifier:"Opera ([0-9.]*)"},{name:"Opera",group:"Opera",identifier:"Opera/([0-9.]*)",versionIdentifier:"Version/([0-9.]*)"},{name:"IEMobile",group:"Explorer",identifier:"IEMobile/([0-9.]*)"},{name:"Internet Explorer",group:"Explorer",identifier:"MSIE ([a-zA-Z0-9.]*)"},{name:"Internet Explorer",group:"Explorer",identifier:"Trident/([0-9.]*)",versionIdentifier:"rv:([0-9.]*)"},{name:"Spartan",group:"Spartan",identifier:"Edge/([0-9.]*)",versionIdentifier:"Edge/([0-9.]*)"},{name:"Safari",group:"Safari",identifier:"Safari/([0-9.]*)",versionIdentifier:"Version/([0-9.]*)"}],I=[{name:"Windows 2000",group:"Windows",identifier:"Windows NT 5.0",version:"5.0"},{name:"Windows XP",group:"Windows",identifier:"Windows NT 5.1",version:"5.1"},{name:"Windows Vista",group:"Windows",identifier:"Windows NT 6.0",version:"6.0"},{name:"Windows 7",group:"Windows",identifier:"Windows NT 6.1",version:"7.0"},{name:"Windows 8",group:"Windows",identifier:"Windows NT 6.2",version:"8.0"},{name:"Windows 8.1",group:"Windows",identifier:"Windows NT 6.3",version:"8.1"},{name:"Windows 10",group:"Windows",identifier:"Windows NT 10.0",version:"10.0"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone ([0-9.]*)"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone OS ([0-9.]*)"},{name:"Windows",group:"Windows",identifier:"Windows"},{name:"Chrome OS",group:"Chrome OS",identifier:"CrOS"},{name:"Android",group:"Android",identifier:"Android",versionIdentifier:"Android ([a-zA-Z0-9.-]*)"},{name:"iPad",group:"iOS",identifier:"iPad",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPod",group:"iOS",identifier:"iPod",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPhone",group:"iOS",identifier:"iPhone OS",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"Mac OS X High Sierra",group:"Mac OS",identifier:"Mac OS X (10([_|.])13([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Sierra",group:"Mac OS",identifier:"Mac OS X (10([_|.])12([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X El Capitan",group:"Mac OS",identifier:"Mac OS X (10([_|.])11([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Yosemite",group:"Mac OS",identifier:"Mac OS X (10([_|.])10([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mavericks",group:"Mac OS",identifier:"Mac OS X (10([_|.])9([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mountain Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])8([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])7([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Snow Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])6([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])5([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Tiger",group:"Mac OS",identifier:"Mac OS X (10([_|.])4([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Panther",group:"Mac OS",identifier:"Mac OS X (10([_|.])3([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Jaguar",group:"Mac OS",identifier:"Mac OS X (10([_|.])2([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Puma",group:"Mac OS",identifier:"Mac OS X (10([_|.])1([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Cheetah",group:"Mac OS",identifier:"Mac OS X (10([_|.])0([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS",group:"Mac OS",identifier:"Mac OS"},{name:"Ubuntu",group:"Linux",identifier:"Ubuntu",versionIdentifier:"Ubuntu/([0-9.]*)"},{name:"Debian",group:"Linux",identifier:"Debian"},{name:"Gentoo",group:"Linux",identifier:"Gentoo"},{name:"Linux",group:"Linux",identifier:"Linux"},{name:"BlackBerry",group:"BlackBerry",identifier:"BlackBerry"}],D={},P=function(t,e){var i=t.split(".",2);e.fullVersion=t,i[0]&&(e.majorVersion=parseInt(i[0])),i[1]&&(e.minorVersion=parseInt(i[1]))},O=function(t,e,i){var n="["==e.substr(0,1)?new RegExp(e,"g"):e,r=t.split(n,2);"."!=e&&(t=t.replace(new RegExp(e,"g"),".")),i.fullVersion=t,r&&r[0]&&(i.majorVersion=parseInt(r[0])),r&&r[1]&&(i.minorVersion=parseInt(r[1]))},x=function(t){var e,i=t.match(/\b(playstation 4|nx|opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(i[1]))return e=/\brv[ :]+(\d+)/g.exec(t)||[],{name:"IE",version:parseInt(e[1]||"")};if("Chrome"===i[1]){if(null!=(e=t.match(/\bOPR\/(\d+)/)))return{name:"Opera",version:parseInt(e[1])};if(null!=(e=t.match(/\bEdge\/(\d+)/)))return{name:"Edge",version:parseInt(e[1])}}else/android/i.test(t)&&(e=t.match(/version\/(\d+)/i))&&(i.splice(1,1,"Android WebView"),i.splice(2,1,e[1]));return{name:(i=i[2]?[i[1],i[2]]:[navigator.appName,navigator.appVersion,"-?"])[0],version:parseInt(i[1])}}(navigator.userAgent);D.isEdge=/Edg|EdgiOS|EdgA/i.test(navigator.userAgent),D.isChrome=/Chrome|CriOS/i.test(navigator.userAgent)&&!D.isEdge,D.isSafari=/Safari/i.test(navigator.userAgent)&&!D.isChrome&&!D.isEdge,D.isFirefox=/Firefox/i.test(navigator.userAgent),D.isLegacyIE=!!window.ActiveXObject,D.isIE=D.isLegacyIE||/trident.*rv:1\d/i.test(navigator.userAgent),D.isIE11=/trident.*rv:11/i.test(navigator.userAgent),D.isChromecast=D.isChrome&&/CrKey/i.test(navigator.userAgent),D.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone|IEMobile|Mobile Safari|Opera Mini/i.test(navigator.userAgent),D.isiOS=/iPad|iPhone|iPod/i.test(navigator.userAgent),D.isAndroid=/Android/i.test(navigator.userAgent),D.isWindowsPhone=/Windows Phone/i.test(navigator.userAgent),D.isWin8App=/MSAppHost/i.test(navigator.userAgent),D.isWiiU=/WiiU/i.test(navigator.userAgent),D.isPS4=/PlayStation 4/i.test(navigator.userAgent),D.hasLocalstorage=function(){try{return localStorage.setItem("clappr","clappr"),localStorage.removeItem("clappr"),!0}catch(t){return!1}}(),D.hasFlash=function(){try{return!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(t){return!(!navigator.mimeTypes||void 0===navigator.mimeTypes["application/x-shockwave-flash"]||!navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)}}(),D.name=x.name,D.version=x.version,D.userAgent=navigator.userAgent,D.data=function(){var t,e={},i=D.userAgent.toLowerCase(),n=T(w);try{for(n.s();!(t=n.n()).done;){var r=t.value,s=new RegExp(r.identifier.toLowerCase()).exec(i);if(null!=s&&s[1]){if(e.name=r.name,e.group=r.group,r.versionIdentifier){var a=new RegExp(r.versionIdentifier.toLowerCase()).exec(i);null!=a&&a[1]&&P(a[1],e)}else P(s[1],e);break}}}catch(t){n.e(t)}finally{n.f()}return e}(),D.os=function(){var t,e={},i=D.userAgent.toLowerCase(),n=T(I);try{for(n.s();!(t=n.n()).done;){var r=t.value,s=new RegExp(r.identifier.toLowerCase()).exec(i);if(null!=s){if(e.name=r.name,e.group=r.group,r.version)O(r.version,r.versionSeparator?r.versionSeparator:".",e);else if(s[1])O(s[1],r.versionSeparator?r.versionSeparator:".",e);else if(r.versionIdentifier){var a=new RegExp(r.versionIdentifier.toLowerCase()).exec(i);null!=a&&a[1]&&O(a[1],r.versionSeparator?r.versionSeparator:".",e)}break}}}catch(t){n.e(t)}finally{n.f()}return e}(),D.isWindows=/^Windows$/i.test(D.os.group),D.isMacOS=/^Mac OS$/i.test(D.os.group),D.isLinux=/^Linux$/i.test(D.os.group),D.viewport=((_={}).width=S(window).width(),_.height=S(window).height(),_),D.device=(L=D.userAgent,(R=/\((iP(?:hone|ad|od))?(?:[^;]*; ){0,2}([^)]+(?=\)))/.exec(L))&&(R[1]||R[2])||""),void 0!==window.orientation&&function(){switch(window.orientation){case-90:case 90:D.viewport.orientation="landscape";break;default:D.viewport.orientation="portrait"}}();var N={},M=[],F=(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}).bind(window),B=(window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.clearTimeout).bind(window);function U(t,e){if(e)for(var i in e){var n=Object.getOwnPropertyDescriptor(e,i);n?Object.defineProperty(t,i,n):t[i]=e[i]}return t}function $(t,e){var i=function(t){function i(){var t;c(this,i);for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];return t=n(this,i,[].concat(s)),e.initialize&&e.initialize.apply(t,s),t}return f(i,t),u(i)}(t);return U(i.prototype,e),i}var G={fullscreenElement:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},requestFullscreen:function(t){if(t.requestFullscreen)return t.requestFullscreen();if(t.webkitRequestFullscreen){if("function"==typeof t.then)return t.webkitRequestFullscreen();t.webkitRequestFullscreen()}else{if(t.mozRequestFullScreen)return t.mozRequestFullScreen();if(t.msRequestFullscreen)return t.msRequestFullscreen();t.querySelector&&t.querySelector("video")&&t.querySelector("video").webkitEnterFullScreen?t.querySelector("video").webkitEnterFullScreen():t.webkitEnterFullScreen&&t.webkitEnterFullScreen()}},cancelFullscreen:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;t.exitFullscreen?t.exitFullscreen():t.webkitCancelFullScreen?t.webkitCancelFullScreen():t.webkitExitFullscreen?t.webkitExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.msExitFullscreen&&t.msExitFullscreen()},fullscreenEnabled:function(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}},V=function(){return u((function t(){c(this,t)}),null,[{key:"_defaultConfig",value:function(){return{volume:{value:100,parse:parseInt}}}},{key:"_defaultValueFor",value:function(t){try{return this._defaultConfig()[t].parse(this._defaultConfig()[t].value)}catch(t){return}}},{key:"_createKeyspace",value:function(t){return"clappr.".concat(document.domain,".").concat(t)}},{key:"restore",value:function(t){return D.hasLocalstorage&&localStorage[this._createKeyspace(t)]?this._defaultConfig()[t].parse(localStorage[this._createKeyspace(t)]):this._defaultValueFor(t)}},{key:"persist",value:function(t,e){if(D.hasLocalstorage)try{return localStorage[this._createKeyspace(t)]=e,!0}catch(t){return!1}}}])}(),K=function(){return u((function t(){c(this,t)}),null,[{key:"params",get:function(){var t=window.location.search.substring(1);return t!==this.query&&(this._urlParams=this.parse(t),this.query=t),this._urlParams}},{key:"hashParams",get:function(){var t=window.location.hash.substring(1);return t!==this.hash&&(this._hashParams=this.parse(t),this.hash=t),this._hashParams}},{key:"parse",value:function(t){for(var e,i=/\+/g,n=/([^&=]+)=?([^&]*)/g,r=function(t){return decodeURIComponent(t.replace(i," "))},s={};e=n.exec(t);)s[r(e[1]).toLowerCase()]=r(e[2]);return s}}])}();function H(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"t",e=0,i=K.params[t]||K.hashParams[t]||"",n=i.match(/[0-9]+[hms]+/g)||[];if(n.length>0){var r={h:3600,m:60,s:1};n.forEach((function(t){if(t){var i=t[t.length-1],n=parseInt(t.slice(0,t.length-1),10);e+=n*r[i]}}))}else i&&(e=parseInt(i,10));return e}function Y(t){return N[t]||(N[t]=0),t+ ++N[t]}function j(t){return t-parseFloat(t)+1>=0}function W(){var t=document.getElementsByTagName("script");return t.length?t[t.length-1].src:""}function z(){return window.navigator&&window.navigator.language}function q(t,e){var i=(e=Object.assign({inline:!1,muted:!1,timeout:250,type:"video",source:C.mp4,element:null},e)).element?e.element:document.createElement(e.type);i.muted=e.muted,!0===e.muted&&i.setAttribute("muted","muted"),!0===e.inline&&i.setAttribute("playsinline","playsinline"),i.src=e.source;var n=i.play(),r=setTimeout((function(){s(!1,new Error("Timeout ".concat(e.timeout," ms has been reached")))}),e.timeout),s=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;clearTimeout(r),t(e,i)};void 0!==n?n.then((function(){return s(!0)})).catch((function(t){return s(!1,t)})):s(!0)}var X=function(){return u((function t(){c(this,t)}),null,[{key:"configure",value:function(t){this.options=S.extend(!0,this.options,t)}},{key:"create",value:function(t){return this.options.recycleVideo&&"video"===t&&M.length>0?M.shift():document.createElement(t)}},{key:"garbage",value:function(t){this.options.recycleVideo&&"VIDEO"===t.tagName.toUpperCase()&&(S(t).children().remove(),Object.values(t.attributes).forEach((function(e){return t.removeAttribute(e.name)})),M.push(t))}}])}();X.options={recycleVideo:!1};var Q=function(){return u((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500;c(this,t),this.delay=e,this.lastTime=0}),[{key:"handle",value:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=(new Date).getTime(),r=n-this.lastTime;r<this.delay&&r>0&&(e(),i&&t.preventDefault()),this.lastTime=n}}])}(),Z={Config:V,Fullscreen:G,QueryString:K,DomRecycler:X,assign:U,extend:$,formatTime:function(t,e){if(!isFinite(t))return"--:--";t*=1e3;var i=(t=parseInt(t/1e3))%60,n=(t=parseInt(t/60))%60,r=(t=parseInt(t/60))%24,s=parseInt(t/24),a="";return s&&s>0&&(a+=s+":",r<1&&(a+="00:")),(r&&r>0||e)&&(a+=("0"+r).slice(-2)+":"),a+=("0"+n).slice(-2)+":",(a+=("0"+i).slice(-2)).trim()},seekStringToSeconds:H,uniqueId:Y,currentScriptUrl:W,isNumber:j,requestAnimationFrame:F,cancelAnimationFrame:B,getBrowserLanguage:z,now:function(){return window.performance&&window.performance.now?performance.now():Date.now()},removeArrayItem:function(t,e){var i=t.indexOf(e);i>=0&&t.splice(i,1)},listContainsIgnoreCase:function(t,e){return void 0!==t&&void 0!==e&&void 0!==e.find((function(e){return t.toLowerCase()===e.toLowerCase()}))},canAutoPlayMedia:q,Media:C,DoubleEventHandler:Q},J="font-weight: bold; font-size: 13px;",tt="color: #ff8000;"+J,et="color: #ff0000;"+J,it=["color: #0000ff;"+J,"color: #006600;"+J,tt,et,et],nt=["debug","info","warn","error","disabled"],rt=function(){return u((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;c(this,t),this.EXCLUDE_LIST=["timeupdate","playback:timeupdate","playback:progress","container:hover","container:timeupdate","container:progress","core:mousemove"],this.level=e,this.previousLevel=this.level,this.offLevel=i}),[{key:"level",get:function(){return this._level},set:function(t){this._level=t}},{key:"debug",value:function(t){this.log(t,0,Array.prototype.slice.call(arguments,1))}},{key:"info",value:function(t){this.log(t,1,Array.prototype.slice.call(arguments,1))}},{key:"warn",value:function(t){this.log(t,2,Array.prototype.slice.call(arguments,1))}},{key:"error",value:function(t){this.log(t,3,Array.prototype.slice.call(arguments,1))}},{key:"onOff",value:function(){this.level===this.offLevel?this.level=this.previousLevel:(this.previousLevel=this.level,this.level=this.offLevel),window.console&&window.console.log&&window.console.log("%c[Clappr.Log] set log level to "+nt[this.level],tt)}},{key:"log",value:function(t,e,i){if(!(e<this.level||this.EXCLUDE_LIST.indexOf(i[0])>=0)){i||(i=t,t=null);var n=it[e],r="";t&&(r="["+t+"]"),window.console&&window.console.log&&window.console.log.apply(console,["%c["+nt[e]+"]"+r,n].concat(i))}}}])}();rt.LEVEL_DEBUG=0,rt.LEVEL_INFO=1,rt.LEVEL_WARN=2,rt.LEVEL_ERROR=3,rt.getInstance=function(){return void 0===this._instance&&(this._instance=new this),this._instance},rt.setLevel=function(t){this.getInstance().level=t},rt.debug=function(){this.getInstance().debug.apply(this.getInstance(),arguments)},rt.info=function(){this.getInstance().info.apply(this.getInstance(),arguments)},rt.warn=function(){this.getInstance().warn.apply(this.getInstance(),arguments)},rt.error=function(){this.getInstance().error.apply(this.getInstance(),arguments)};var st=Array.prototype.slice,at=/\s+/,ot=function(t,e,i,n){if(!i)return!0;if("object"===l(i)){for(var r in i)t[e].apply(t,[r,i[r]].concat(n));return!1}if(at.test(i)){for(var s=i.split(at),a=0,o=s.length;a<o;a++)t[e].apply(t,[s[a]].concat(n));return!1}return!0},lt=function(t,e,i,n){var r,s=-1,a=t.length,o=e[0],l=e[1],c=e[2];!function h(){try{switch(e.length){case 0:for(;++s<a;)(r=t[s]).callback.call(r.ctx);return;case 1:for(;++s<a;)(r=t[s]).callback.call(r.ctx,o);return;case 2:for(;++s<a;)(r=t[s]).callback.call(r.ctx,o,l);return;case 3:for(;++s<a;)(r=t[s]).callback.call(r.ctx,o,l,c);return;default:for(;++s<a;)(r=t[s]).callback.apply(r.ctx,e);return}}catch(t){rt.error.apply(rt,[i,"error on event",n,"trigger","-",t]),h()}}()},ct=function(){function t(){c(this,t)}return u(t,[{key:"on",value:function(t,e,i){return ot(this,"on",t,[e,i])&&e?(this._events||(this._events={}),(this._events[t]||(this._events[t]=[])).push({callback:e,context:i,ctx:i||this}),this):this}},{key:"once",value:function(t,e,i){var n,r=this;if(!ot(this,"once",t,[e,i])||!e)return this;return n=function(){r.off(t,n),e.apply(this,arguments)},n._callback=e,this.on(t,n,i)}},{key:"off",value:function(t,e,i){var n,r,s,a,o,l,c,h;if(!this._events||!ot(this,"off",t,[e,i]))return this;if(!t&&!e&&!i)return this._events=void 0,this;for(o=0,l=(a=t?[t]:Object.keys(this._events)).length;o<l;o++)if(t=a[o],s=this._events[t]){if(this._events[t]=n=[],e||i)for(c=0,h=s.length;c<h;c++)r=s[c],(e&&e!==r.callback&&e!==r.callback._callback||i&&i!==r.context)&&n.push(r);n.length||delete this._events[t]}return this}},{key:"trigger",value:function(t){var e=this.name||this.constructor.name;if(rt.debug.apply(rt,[e].concat(Array.prototype.slice.call(arguments))),!this._events)return this;var i=st.call(arguments,1);if(!ot(this,"trigger",t,i))return this;var n=this._events[t],r=this._events.all;return n&<(n,i,e,t),r&<(r,arguments,e,t),this}},{key:"stopListening",value:function(t,e,i){var n=this._listeningTo;if(!n)return this;var r=!e&&!i;for(var s in i||"object"!==l(e)||(i=this),t&&((n={})[t._listenId]=t),n)(t=n[s]).off(e,i,this),(r||0===Object.keys(t._events).length)&&delete this._listeningTo[s];return this}}],[{key:"register",value:function(e){t.Custom||(t.Custom={});var i="string"==typeof e&&e.toUpperCase().trim();i&&!t.Custom[i]?t.Custom[i]=i.toLowerCase().split("_").map((function(t,e){return 0===e?t:t=t[0].toUpperCase()+t.slice(1)})).join(""):rt.error("Events","Error when register event: "+e)}},{key:"listAvailableCustomEvents",value:function(){return t.Custom||(t.Custom={}),Object.keys(t.Custom).filter((function(e){return"string"==typeof t.Custom[e]}))}}])}();ct.prototype.listenTo=function(t,e,i){return(this._listeningTo||(this._listeningTo={}))[t._listenId||(t._listenId=Y("l"))]=t,i||"object"!==l(e)||(i=this),t.on(e,i,this),this},ct.prototype.listenToOnce=function(t,e,i){return(this._listeningTo||(this._listeningTo={}))[t._listenId||(t._listenId=Y("l"))]=t,i||"object"!==l(e)||(i=this),t.once(e,i,this),this},ct.PLAYER_READY="ready",ct.PLAYER_RESIZE="resize",ct.PLAYER_FULLSCREEN="fullscreen",ct.PLAYER_PLAY="play",ct.PLAYER_PAUSE="pause",ct.PLAYER_STOP="stop",ct.PLAYER_ENDED="ended",ct.PLAYER_SEEK="seek",ct.PLAYER_ERROR="playererror",ct.ERROR="error",ct.PLAYER_TIMEUPDATE="timeupdate",ct.PLAYER_VOLUMEUPDATE="volumeupdate",ct.PLAYER_SUBTITLE_AVAILABLE="subtitleavailable",ct.PLAYBACK_PIP_ENTER="playback:picture-in-picture:enter",ct.PLAYBACK_PIP_EXIT="playback:picture-in-picture:exit",ct.PLAYBACK_PROGRESS="playback:progress",ct.PLAYBACK_TIMEUPDATE="playback:timeupdate",ct.PLAYBACK_READY="playback:ready",ct.PLAYBACK_BUFFERING="playback:buffering",ct.PLAYBACK_BUFFERFULL="playback:bufferfull",ct.PLAYBACK_SETTINGSUPDATE="playback:settingsupdate",ct.PLAYBACK_LOADEDMETADATA="playback:loadedmetadata",ct.PLAYBACK_HIGHDEFINITIONUPDATE="playback:highdefinitionupdate",ct.PLAYBACK_BITRATE="playback:bitrate",ct.PLAYBACK_LEVELS_AVAILABLE="playback:levels:available",ct.PLAYBACK_LEVEL_SWITCH_START="playback:levels:switch:start",ct.PLAYBACK_LEVEL_SWITCH_END="playback:levels:switch:end",ct.PLAYBACK_PLAYBACKSTATE="playback:playbackstate",ct.PLAYBACK_DVR="playback:dvr",ct.PLAYBACK_MEDIACONTROL_DISABLE="playback:mediacontrol:disable",ct.PLAYBACK_MEDIACONTROL_ENABLE="playback:mediacontrol:enable",ct.PLAYBACK_ENDED="playback:ended",ct.PLAYBACK_PLAY_INTENT="playback:play:intent",ct.PLAYBACK_PLAY="playback:play",ct.PLAYBACK_PAUSE="playback:pause",ct.PLAYBACK_SEEK="playback:seek",ct.PLAYBACK_SEEKED="playback:seeked",ct.PLAYBACK_STOP="playback:stop",ct.PLAYBACK_ERROR="playback:error",ct.PLAYBACK_STATS_ADD="playback:stats:add",ct.PLAYBACK_FRAGMENT_LOADED="playback:fragment:loaded",ct.PLAYBACK_FRAGMENT_BUFFERED="playback:fragment:buffered",ct.PLAYBACK_LEVEL_SWITCH="playback:level:switch",ct.PLAYBACK_SUBTITLE_AVAILABLE="playback:subtitle:available",ct.PLAYBACK_SUBTITLE_CHANGED="playback:subtitle:changed",ct.PLAYBACK_AUDIO_AVAILABLE="playback:audio:available",ct.PLAYBACK_AUDIO_CHANGED="playback:audio:changed",ct.PLAYBACK_RESIZE="playback:resize",ct.CORE_CONTAINERS_CREATED="core:containers:created",ct.CORE_ACTIVE_CONTAINER_CHANGED="core:active:container:changed",ct.CORE_OPTIONS_CHANGE="core:options:change",ct.CORE_READY="core:ready",ct.CORE_FULLSCREEN="core:fullscreen",ct.CORE_RESIZE="core:resize",ct.CORE_SCREEN_ORIENTATION_CHANGED="core:screen:orientation:changed",ct.CORE_MOUSE_MOVE="core:mousemove",ct.CORE_MOUSE_LEAVE="core:mouseleave",ct.CONTAINER_PLAYBACKSTATE="container:playbackstate",ct.CONTAINER_PLAYBACKDVRSTATECHANGED="container:dvr",ct.CONTAINER_BITRATE="container:bitrate",ct.CONTAINER_STATS_REPORT="container:stats:report",ct.CONTAINER_DESTROYED="container:destroyed",ct.CONTAINER_READY="container:ready",ct.CONTAINER_RESIZE="container:resize",ct.CONTAINER_ERROR="container:error",ct.CONTAINER_LOADEDMETADATA="container:loadedmetadata",ct.CONTAINER_SUBTITLE_AVAILABLE="container:subtitle:available",ct.CONTAINER_SUBTITLE_CHANGED="container:subtitle:changed",ct.CONTAINER_AUDIO_AVAILABLE="container:audio:available",ct.CONTAINER_AUDIO_CHANGED="container:audio:changed",ct.CONTAINER_TIMEUPDATE="container:timeupdate",ct.CONTAINER_PROGRESS="container:progress",ct.CONTAINER_PLAY="container:play",ct.CONTAINER_STOP="container:stop",ct.CONTAINER_PAUSE="container:pause",ct.CONTAINER_ENDED="container:ended",ct.CONTAINER_CLICK="container:click",ct.CONTAINER_DBLCLICK="container:dblclick",ct.CONTAINER_CONTEXTMENU="container:contextmenu",ct.CONTAINER_MOUSE_ENTER="container:mouseenter",ct.CONTAINER_MOUSE_LEAVE="container:mouseleave",ct.CONTAINER_MOUSE_UP="container:mouseup",ct.CONTAINER_MOUSE_DOWN="container:mousedown",ct.CONTAINER_PIP_ENTER="container:picture-in-picture:enter",ct.CONTAINER_PIP_EXIT="container:picture-in-picture:exit",ct.CONTAINER_SEEK="container:seek",ct.CONTAINER_SEEKED="container:seeked",ct.CONTAINER_VOLUME="container:volume",ct.CONTAINER_FULLSCREEN="container:fullscreen",ct.CONTAINER_STATE_BUFFERING="container:state:buffering",ct.CONTAINER_STATE_BUFFERFULL="container:state:bufferfull",ct.CONTAINER_SETTINGSUPDATE="container:settingsupdate",ct.CONTAINER_HIGHDEFINITIONUPDATE="container:highdefinitionupdate",ct.CONTAINER_MEDIACONTROL_SHOW="container:mediacontrol:show",ct.CONTAINER_MEDIACONTROL_HIDE="container:mediacontrol:hide",ct.CONTAINER_MEDIACONTROL_DISABLE="container:mediacontrol:disable",ct.CONTAINER_MEDIACONTROL_ENABLE="container:mediacontrol:enable",ct.CONTAINER_STATS_ADD="container:stats:add",ct.CONTAINER_OPTIONS_CHANGE="container:options:change",ct.MEDIACONTROL_RENDERED="mediacontrol:rendered",ct.MEDIACONTROL_FULLSCREEN="mediacontrol:fullscreen",ct.MEDIACONTROL_SHOW="mediacontrol:show",ct.MEDIACONTROL_HIDE="mediacontrol:hide",ct.MEDIACONTROL_MOUSEMOVE_SEEKBAR="mediacontrol:mousemove:seekbar",ct.MEDIACONTROL_MOUSELEAVE_SEEKBAR="mediacontrol:mouseleave:seekbar",ct.MEDIACONTROL_PLAYING="mediacontrol:playing",ct.MEDIACONTROL_NOTPLAYING="mediacontrol:notplaying",ct.MEDIACONTROL_CONTAINERCHANGED="mediacontrol:containerchanged",ct.MEDIACONTROL_OPTIONS_CHANGE="mediacontrol:options:change";var ht=function(t){function e(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return c(this,e),(t=n(this,e,[i]))._options=i,t.uniqueId=Y("o"),t}return f(e,t),u(e,[{key:"options",get:function(){return this._options}}])}(ct),ut={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},dt=/(.)^/,ft={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},gt=/\\|'|\r|\n|\t|\u2028|\u2029/g,pt={"&":"&","<":"<",">":">",'"':""","'":"'"},mt=new RegExp("[&<>\"']","g"),vt=function(t){return null===t?"":(""+t).replace(mt,(function(t){return pt[t]}))},yt=0,At=function(t,e){var i,n=new RegExp([(ut.escape||dt).source,(ut.interpolate||dt).source,(ut.evaluate||dt).source].join("|")+"|$","g"),r=0,s="__p+='";t.replace(n,(function(e,i,n,a,o){return s+=t.slice(r,o).replace(gt,(function(t){return"\\"+ft[t]})),i&&(s+="'+\n((__t=("+i+"))==null?'':escapeExpr(__t))+\n'"),n&&(s+="'+\n((__t=("+n+"))==null?'':__t)+\n'"),a&&(s+="';\n"+a+"\n__p+='"),r=o+e.length,e})),s+="';\n",ut.variable||(s="with(obj||{}){\n"+s+"}\n"),s="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+s+"return __p;\n//# sourceURL=/microtemplates/source["+yt+++"]";try{i=new Function(ut.variable||"obj","escapeExpr",s)}catch(t){throw t.source=s,t}if(e)return i(e,vt);var a=function(t){return i.call(this,t,vt)};return a.source="function("+(ut.variable||"obj")+"){\n"+s+"}",a};At.settings=ut;var Et={getStyleFor:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:""};return S('<style class="clappr-style"></style>').html(At(t.toString())(e))}},Tt=/^(\S+)\s*(.*)$/,bt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t])).cid=Y("c"),i._ensureElement(),i.delegateEvents(),i}return f(e,t),u(e,[{key:"tagName",get:function(){return"div"}},{key:"events",get:function(){return{}}},{key:"attributes",get:function(){return{}}},{key:"$",value:function(t){return this.$el.find(t)}},{key:"render",value:function(){return this}},{key:"destroy",value:function(){return this.$el.remove(),this.stopListening(),this.undelegateEvents(),this}},{key:"setElement",value:function(t,e){return this.$el&&this.undelegateEvents(),this.$el=S.zepto.isZ(t)?t:S(t),this.el=this.$el[0],!1!==e&&this.delegateEvents(),this}},{key:"delegateEvents",value:function(t){for(var e in t||(t=this.events),this.undelegateEvents(),t){var i=t[e];if(i&&i.constructor!==Function&&(i=this[t[e]]),i){var n=e.match(Tt),r=n[1],s=n[2];r+=".delegateEvents"+this.cid,""===s?this.$el.on(r,i.bind(this)):this.$el.on(r,s,i.bind(this))}}return this}},{key:"undelegateEvents",value:function(){return this.$el.off(".delegateEvents"+this.cid),this}},{key:"_ensureElement",value:function(){if(this.el)this.setElement(this.el,!1);else{var t=S.extend(!0,{},this.attributes);this.id&&(t.id=this.id),this.className&&(t.class=this.className);var e=S(X.create(this.tagName)).attr(t);this.setElement(e,!1)}}},{key:"onResize",value:function(){return this}},{key:"resize",value:function(t){var e=j(t.width)?"".concat(t.width,"px"):"".concat(t.width),i=j(t.height)?"".concat(t.height,"px"):"".concat(t.height);return this.el.style.width=e,this.el.style.height=i,this.onResize(t),this}}])}(ht),kt=function(t){function e(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return c(this,e),(t=n(this,e,[i])).core=r,t}return f(e,t),u(e,[{key:"name",get:function(){return"error"}},{key:"createError",value:function(t){this.core?this.core.trigger(ct.ERROR,t):rt.warn(this.name,"Core is not set. Error: ",t)}}],[{key:"Levels",get:function(){return{FATAL:"FATAL",WARN:"WARN",INFO:"INFO"}}}])}(ht),St={createError:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{useCodePrefix:!0},i=this.constructor&&this.constructor.type||"",n=this.name||i,r=this.i18n||this.core&&this.core.i18n||this.container&&this.container.i18n,s="".concat(n,":").concat(t&&t.code||"unknown"),a={description:"",level:kt.Levels.FATAL,origin:n,scope:i,raw:{}},o=Object.assign({},a,t,{code:e.useCodePrefix?s:t.code});if(r&&o.level==kt.Levels.FATAL&&!o.UI){var l={title:r.t("default_error_title"),message:r.t("default_error_message")};o.UI=l}return this.playerError?this.playerError.createError(o):rt.warn(n,"PlayerError is not defined. Error: ",o),o}},_t=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t.options])).core=t,i.enabled=!0,i.bindEvents(),i.render(),i}return f(e,t),u(e,[{key:"playerError",get:function(){return this.core.playerError}},{key:"bindEvents",value:function(){}},{key:"getExternalInterface",value:function(){return{}}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.$el.show(),this.enabled=!0)}},{key:"disable",value:function(){this.stopListening(),this.$el.hide(),this.enabled=!1}},{key:"render",value:function(){return this}}])}(bt);Object.assign(_t.prototype,St),_t.extend=function(t){return $(_t,t)},_t.type="core";var Lt=function(t){function e(t,i,r){var s;return c(this,e),(s=n(this,e,[t]))._i18n=i,s.currentTime=0,s.volume=100,s.playback=t.playback,s.playerError=r,s.settings=S.extend(!0,{},s.playback.settings),s.isReady=!1,s.mediaControlDisabled=!1,s.plugins=[s.playback],s.dblTapHandler=new Q(500),s.clickTimer=null,s.clickDelay=200,s.actionsMetadata={},s.bindEvents(),s}return f(e,t),u(e,[{key:"name",get:function(){return"Container"}},{key:"attributes",get:function(){return{class:"container","data-container":""}}},{key:"events",get:function(){return{click:"clicked",dblclick:"dblClicked",touchend:"dblTap",contextmenu:"onContextMenu",mouseenter:"mouseEnter",mouseleave:"mouseLeave",mouseup:"onMouseUp",mousedown:"onMouseDown"}}},{key:"ended",get:function(){return this.playback.ended}},{key:"buffering",get:function(){return this.playback.buffering}},{key:"i18n",get:function(){return this._i18n}},{key:"hasClosedCaptionsTracks",get:function(){return this.playback.hasClosedCaptionsTracks}},{key:"closedCaptionsTracks",get:function(){return this.playback.closedCaptionsTracks}},{key:"closedCaptionsTrackId",get:function(){return this.playback.closedCaptionsTrackId},set:function(t){this.playback.closedCaptionsTrackId=t}},{key:"audioTracks",get:function(){return this.playback.audioTracks}},{key:"currentAudioTrack",get:function(){return this.playback.currentAudioTrack}},{key:"isPiPActive",get:function(){return this.playback.isPiPActive}},{key:"bindEvents",value:function(){this.listenTo(this.playback,ct.PLAYBACK_PROGRESS,this.onProgress),this.listenTo(this.playback,ct.PLAYBACK_TIMEUPDATE,this.timeUpdated),this.listenTo(this.playback,ct.PLAYBACK_READY,this.ready),this.listenTo(this.playback,ct.PLAYBACK_BUFFERING,this.onBuffering),this.listenTo(this.playback,ct.PLAYBACK_BUFFERFULL,this.bufferfull),this.listenTo(this.playback,ct.PLAYBACK_SETTINGSUPDATE,this.settingsUpdate),this.listenTo(this.playback,ct.PLAYBACK_LOADEDMETADATA,this.loadedMetadata),this.listenTo(this.playback,ct.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinitionUpdate),this.listenTo(this.playback,ct.PLAYBACK_BITRATE,this.updateBitrate),this.listenTo(this.playback,ct.PLAYBACK_PLAYBACKSTATE,this.playbackStateChanged),this.listenTo(this.playback,ct.PLAYBACK_DVR,this.playbackDvrStateChanged),this.listenTo(this.playback,ct.PLAYBACK_MEDIACONTROL_DISABLE,this.disableMediaControl),this.listenTo(this.playback,ct.PLAYBACK_MEDIACONTROL_ENABLE,this.enableMediaControl),this.listenTo(this.playback,ct.PLAYBACK_SEEK,this.onSeek),this.listenTo(this.playback,ct.PLAYBACK_SEEKED,this.onSeeked),this.listenTo(this.playback,ct.PLAYBACK_ENDED,this.onEnded),this.listenTo(this.playback,ct.PLAYBACK_PLAY,this.playing),this.listenTo(this.playback,ct.PLAYBACK_PAUSE,this.paused),this.listenTo(this.playback,ct.PLAYBACK_STOP,this.stopped),this.listenTo(this.playback,ct.PLAYBACK_ERROR,this.error),this.listenTo(this.playback,ct.PLAYBACK_SUBTITLE_AVAILABLE,this.subtitleAvailable),this.listenTo(this.playback,ct.PLAYBACK_SUBTITLE_CHANGED,this.subtitleChanged),this.listenTo(this.playback,ct.PLAYBACK_AUDIO_AVAILABLE,this.audioAvailable),this.listenTo(this.playback,ct.PLAYBACK_AUDIO_CHANGED,this.audioChanged),this.listenTo(this.playback,ct.PLAYBACK_PIP_ENTER,this.onEnterPiP),this.listenTo(this.playback,ct.PLAYBACK_PIP_EXIT,this.onExitPiP)}},{key:"subtitleAvailable",value:function(){this.trigger(ct.CONTAINER_SUBTITLE_AVAILABLE)}},{key:"subtitleChanged",value:function(t){this.trigger(ct.CONTAINER_SUBTITLE_CHANGED,t)}},{key:"audioAvailable",value:function(t){this.trigger(ct.CONTAINER_AUDIO_AVAILABLE,t)}},{key:"audioChanged",value:function(t){this.trigger(ct.CONTAINER_AUDIO_CHANGED,t)}},{key:"playbackStateChanged",value:function(t){this.trigger(ct.CONTAINER_PLAYBACKSTATE,t)}},{key:"playbackDvrStateChanged",value:function(t){this.settings=this.playback.settings,this.dvrInUse=t,this.trigger(ct.CONTAINER_PLAYBACKDVRSTATECHANGED,t)}},{key:"updateBitrate",value:function(t){this.trigger(ct.CONTAINER_BITRATE,t)}},{key:"statsReport",value:function(t){this.trigger(ct.CONTAINER_STATS_REPORT,t)}},{key:"getPlaybackType",value:function(){return this.playback.getPlaybackType()}},{key:"isDvrEnabled",value:function(){return!!this.playback.dvrEnabled}},{key:"isDvrInUse",value:function(){return!!this.dvrInUse}},{key:"destroy",value:function(){this.disableResizeObserver(),this.trigger(ct.CONTAINER_DESTROYED,this,this.name),this.stopListening(),this.plugins.forEach((function(t){return t.destroy()})),this.$el.remove(),this.undelegateEvents()}},{key:"setStyle",value:function(t){this.$el.css(t)}},{key:"ready",value:function(){this.isReady=!0,this.trigger(ct.CONTAINER_READY,this.name)}},{key:"isPlaying",value:function(){return this.playback.isPlaying()}},{key:"getStartTimeOffset",value:function(){return this.playback.getStartTimeOffset()}},{key:"getCurrentTime",value:function(){return this.currentTime}},{key:"getDuration",value:function(){return this.playback.getDuration()}},{key:"error",value:function(t){this.isReady||this.ready(),this.trigger(ct.CONTAINER_ERROR,t,this.name)}},{key:"loadedMetadata",value:function(t){this.trigger(ct.CONTAINER_LOADEDMETADATA,t)}},{key:"timeUpdated",value:function(t){this.currentTime=t.current,this.trigger(ct.CONTAINER_TIMEUPDATE,t,this.name)}},{key:"onProgress",value:function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.trigger.apply(this,[ct.CONTAINER_PROGRESS].concat(e,[this.name]))}},{key:"playing",value:function(){this.trigger(ct.CONTAINER_PLAY,this.name,this.actionsMetadata.playEvent||{}),this.actionsMetadata.playEvent={}}},{key:"paused",value:function(){this.trigger(ct.CONTAINER_PAUSE,this.name,this.actionsMetadata.pauseEvent||{}),this.actionsMetadata.pauseEvent={}}},{key:"stopped",value:function(){this.trigger(ct.CONTAINER_STOP,this.actionsMetadata.stopEvent||{}),this.actionsMetadata.stopEvent={}}},{key:"play",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.playEvent=t,this.playback.play(t)}},{key:"stop",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.stopEvent=t,this.playback.stop(t),this.currentTime=0}},{key:"switchAudioTrack",value:function(t){this.playback.switchAudioTrack(t)}},{key:"pause",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.pauseEvent=t,this.playback.pause(t)}},{key:"onEnded",value:function(){this.trigger(ct.CONTAINER_ENDED,this,this.name),this.currentTime=0}},{key:"clicked",value:function(){var t=this;this.options.chromeless&&!this.options.allowUserInteraction||(this.clickTimer=setTimeout((function(){t.clickTimer&&t.trigger(ct.CONTAINER_CLICK,t,t.name)}),this.clickDelay))}},{key:"cancelClicked",value:function(){clearTimeout(this.clickTimer),this.clickTimer=null}},{key:"dblClicked",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||(this.cancelClicked(),this.trigger(ct.CONTAINER_DBLCLICK,this,this.name))}},{key:"dblTap",value:function(t){var e=this;this.options.chromeless&&!this.options.allowUserInteraction||this.dblTapHandler.handle(t,(function(){e.cancelClicked(),e.trigger(ct.CONTAINER_DBLCLICK,e,e.name)}))}},{key:"onContextMenu",value:function(t){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ct.CONTAINER_CONTEXTMENU,t,this.name)}},{key:"seek",value:function(t){this.playback.seek(t)}},{key:"onSeek",value:function(t){this.trigger(ct.CONTAINER_SEEK,t,this.name)}},{key:"onSeeked",value:function(){this.trigger(ct.CONTAINER_SEEKED,this.name)}},{key:"seekPercentage",value:function(t){var e=this.getDuration();if(t>=0&&t<=100){var i=e*(t/100);this.seek(i)}}},{key:"setVolume",value:function(t){this.volume=parseFloat(t),this.trigger(ct.CONTAINER_VOLUME,this.volume,this.name),this.playback.volume(this.volume)}},{key:"fullscreen",value:function(){this.trigger(ct.CONTAINER_FULLSCREEN,this.name)}},{key:"onBuffering",value:function(){this.trigger(ct.CONTAINER_STATE_BUFFERING,this.name)}},{key:"bufferfull",value:function(){this.trigger(ct.CONTAINER_STATE_BUFFERFULL,this.name)}},{key:"onEnterPiP",value:function(){this.trigger(ct.CONTAINER_PIP_ENTER,this.name)}},{key:"onExitPiP",value:function(){this.trigger(ct.CONTAINER_PIP_EXIT,this.name)}},{key:"addPlugin",value:function(t){this.plugins.push(t)}},{key:"hasPlugin",value:function(t){return!!this.getPlugin(t)}},{key:"getPlugin",value:function(t){return this.plugins.filter((function(e){return e.name===t}))[0]}},{key:"mouseEnter",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ct.CONTAINER_MOUSE_ENTER)}},{key:"mouseLeave",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ct.CONTAINER_MOUSE_LEAVE)}},{key:"mouseUp",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ct.CONTAINER_MOUSE_UP)}},{key:"mouseDown",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ct.CONTAINER_MOUSE_DOWN)}},{key:"enterPiP",value:function(){this.playback.enterPiP()}},{key:"exitPiP",value:function(){this.playback.exitPiP()}},{key:"settingsUpdate",value:function(){this.settings=this.playback.settings,this.trigger(ct.CONTAINER_SETTINGSUPDATE)}},{key:"highDefinitionUpdate",value:function(t){this.trigger(ct.CONTAINER_HIGHDEFINITIONUPDATE,t)}},{key:"isHighDefinitionInUse",value:function(){return this.playback.isHighDefinitionInUse()}},{key:"disableMediaControl",value:function(){this.mediaControlDisabled||(this.mediaControlDisabled=!0,this.trigger(ct.CONTAINER_MEDIACONTROL_DISABLE))}},{key:"enableMediaControl",value:function(){this.mediaControlDisabled&&(this.mediaControlDisabled=!1,this.trigger(ct.CONTAINER_MEDIACONTROL_ENABLE))}},{key:"updateStyle",value:function(){!this.options.chromeless||this.options.allowUserInteraction?this.$el.removeClass("chromeless"):this.$el.addClass("chromeless")}},{key:"enableResizeObserver",value:function(){var t=this;this.disableResizeObserver(),this.resizeObserverInterval=setInterval((function(){return t.checkResize()}),500)}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval)}},{key:"checkResize",value:function(){var t={width:this.el.clientWidth,height:this.el.clientHeight},e=this.currentSize||{},i=e.width;(e.height!==t.height||i!==t.width)&&(this.currentSize=t,this.trigger(ct.CONTAINER_RESIZE,t))}},{key:"onResize",value:function(t){return this.playback.resize(t),this}},{key:"configure",value:function(t){this._options=S.extend(!0,this._options,t),this.updateStyle(),this.playback.configure(this.options),this.trigger(ct.CONTAINER_OPTIONS_CHANGE)}},{key:"render",value:function(){var t=Et.getStyleFor(".container[data-container] {\n position: absolute;\n background-color: black;\n height: 100%;\n width: 100%;\n max-width: 100%; }\n .container[data-container] .chromeless {\n cursor: default; }\n\n[data-player]:not(.nocursor) .container[data-container]:not(.chromeless).pointer-enabled {\n cursor: pointer; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(t[0]),this.$el.append(this.playback.render().el),this.updateStyle(),this.checkResize(),this.enableResizeObserver(),this}}])}(bt);Object.assign(Lt.prototype,St);var Rt=function(t){function e(t,i,r){var s;return c(this,e),(s=n(this,e,[t])).settings={},s._i18n=i,s.playerError=r,s._consented=!1,s}return f(e,t),u(e,[{key:"isAudioOnly",get:function(){return!1}},{key:"isAdaptive",get:function(){return!1}},{key:"ended",get:function(){return!1}},{key:"i18n",get:function(){return this._i18n}},{key:"buffering",get:function(){return!1}},{key:"latency",get:function(){return null}},{key:"currentProgramDateTime",get:function(){return null}},{key:"isPiPActive",get:function(){return!1}},{key:"consent",value:function(t){"function"==typeof t&&t()}},{key:"play",value:function(){}},{key:"pause",value:function(){}},{key:"stop",value:function(){}},{key:"enterPiP",value:function(){}},{key:"exitPiP",value:function(){}},{key:"seek",value:function(t){}},{key:"seekPercentage",value:function(t){}},{key:"getStartTimeOffset",value:function(){return 0}},{key:"getDuration",value:function(){return 0}},{key:"isPlaying",value:function(){return!1}},{key:"isReady",get:function(){return!1}},{key:"hasClosedCaptionsTracks",get:function(){return this.closedCaptionsTracks.length>0}},{key:"closedCaptionsTracks",get:function(){return[]}},{key:"closedCaptionsTrackId",get:function(){return-1},set:function(t){}},{key:"audioTracks",get:function(){return[]}},{key:"currentAudioTrack",get:function(){return null}},{key:"switchAudioTrack",value:function(t){}},{key:"getPlaybackType",value:function(){return e.NO_OP}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"mute",value:function(){}},{key:"unmute",value:function(){}},{key:"volume",value:function(t){}},{key:"configure",value:function(t){this._options=S.extend(!0,this._options,t)}},{key:"attemptAutoPlay",value:function(){var t=this;this.canAutoPlay((function(e,i){e&&t.play()}))}},{key:"canAutoPlay",value:function(t){t(!0,null)}},{key:"onResize",value:function(t){return this.trigger(ct.PLAYBACK_RESIZE,t),this}}])}(bt);Object.assign(Rt.prototype,St),Rt.extend=function(t){return $(Rt,t)},Rt.canPlay=function(t,e){return!1},Rt.VOD="vod",Rt.AOD="aod",Rt.LIVE="live",Rt.NO_OP="no_op",Rt.type="playback";var Ct=function(t){function e(t,i,r,s){var a;return c(this,e),(a=n(this,e,[t]))._i18n=r,a.loader=i,a.playerError=s,a}return f(e,t),u(e,[{key:"options",get:function(){return this._options},set:function(t){this._options=t}},{key:"createContainers",value:function(){var t=this;return S.Deferred((function(e){e.resolve(t.options.sources.map((function(e){return t.createContainer(e)})))}))}},{key:"findPlaybackPlugin",value:function(t,e){return this.loader.playbackPlugins.filter((function(i){return i.canPlay(t,e)}))[0]}},{key:"createContainer",value:function(t){var e=null,i=this.options.mimeType;"object"===l(t)?(e=t.source.toString(),t.mimeType&&(i=t.mimeType)):e=t.toString(),e.match(/^\/\//)&&(e=window.location.protocol+e);var n=a(a({},this.options),{},{src:e,mimeType:i}),r=this.findPlaybackPlugin(e,i),s=r?new r(n,this._i18n,this.playerError):new Rt;n=a(a({},n),{},{playback:s});var o=new Lt(n,this._i18n,this.playerError),c=S.Deferred();return c.promise(o),this.addContainerPlugins(o),this.listenToOnce(o,ct.CONTAINER_READY,(function(){return c.resolve(o)})),o}},{key:"addContainerPlugins",value:function(t){this.loader.containerPlugins.forEach((function(e){t.addPlugin(new e(t))}))}}])}(ht),wt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t])).playerError=new kt(t,i),i.configureDomRecycler(),i.firstResize=!0,i.styleRendered=!1,i.plugins=[],i.containers=[],i._boundFullscreenHandler=function(){return i.handleFullscreenChange()},i._boundHandleWindowResize=function(t){return i.handleWindowResize(t)},S(document).bind("fullscreenchange",i._boundFullscreenHandler),S(document).bind("MSFullscreenChange",i._boundFullscreenHandler),S(document).bind("mozfullscreenchange",i._boundFullscreenHandler),D.isMobile&&S(window).bind("resize",i._boundHandleWindowResize),i}return f(e,t),u(e,[{key:"events",get:function(){return{webkitfullscreenchange:"handleFullscreenChange",mousemove:"onMouseMove",mouseleave:"onMouseLeave"}}},{key:"attributes",get:function(){return{"data-player":"",tabindex:9999}}},{key:"isReady",get:function(){return!!this.ready}},{key:"i18n",get:function(){return this.getPlugin("strings")||{t:function(t){return t}}}},{key:"mediaControl",get:function(){return this._mediaControl||(this._mediaControl=this.getPlugin("media_control"))||this.dummyMediaControl}},{key:"dummyMediaControl",get:function(){return this._dummyMediaControl||(this._dummyMediaControl=new _t(this)),this._dummyMediaControl}},{key:"activeContainer",get:function(){return this._activeContainer},set:function(t){this._activeContainer=t,this.trigger(ct.CORE_ACTIVE_CONTAINER_CHANGED,this._activeContainer)}},{key:"activePlayback",get:function(){return this.activeContainer&&this.activeContainer.playback}},{key:"activePlaybackEl",get:function(){if(this.activePlayback)return this.activePlayback.$el?this.activePlayback.$el.find("video")[0]:this.activePlayback.el}},{key:"configureDomRecycler",value:function(){var t=this.options&&this.options.playback&&this.options.playback.recycleVideo;X.configure({recycleVideo:t})}},{key:"createContainers",value:function(t){this.defer=S.Deferred(),this.defer.promise(this),this.containerFactory=new Ct(t,t.loader,this.i18n,this.playerError),this.prepareContainers()}},{key:"prepareContainers",value:function(){var t=this;this.containerFactory.createContainers().then((function(e){return t.setupContainers(e)})).then((function(e){return t.resolveOnContainersReady(e)}))}},{key:"updateSize",value:function(){this.isFullscreen()?this.setFullscreen():this.setPlayerSize()}},{key:"setFullscreen",value:function(){D.isiOS||(this.$el.addClass("fullscreen"),this.$el.removeAttr("style"),this.previousSize={width:this.options.width,height:this.options.height},this.currentSize={width:S(window).width(),height:S(window).height()})}},{key:"setPlayerSize",value:function(){this.$el.removeClass("fullscreen"),this.currentSize=this.previousSize,this.previousSize={width:S(window).width(),height:S(window).height()},this.resize(this.currentSize)}},{key:"onResize",value:function(t){return this.previousSize={width:this.options.width,height:this.options.height},this.options.width=t.width,this.options.height=t.height,this.currentSize=t,this.triggerResize(this.currentSize),this}},{key:"enableResizeObserver",value:function(){var t=this;this.disableResizeObserver();this.resizeObserverInterval=setInterval((function(){t.triggerResize({width:t.el.clientWidth,height:t.el.clientHeight})}),500)}},{key:"triggerResize",value:function(t){(this.firstResize||this.oldHeight!==t.height||this.oldWidth!==t.width)&&(this.oldHeight=t.height,this.oldWidth=t.width,this.computedSize=t,this.firstResize=!1,this.trigger(ct.CORE_RESIZE,t))}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval),this.resizeObserverInterval=null}},{key:"resolveOnContainersReady",value:function(t){var e=this;S.when.apply(S,t).done((function(){e.defer.resolve(e),e.ready=!0,e.trigger(ct.CORE_READY)}))}},{key:"addPlugin",value:function(t){this.plugins.push(t)}},{key:"hasPlugin",value:function(t){return!!this.getPlugin(t)}},{key:"getPlugin",value:function(t){return this.plugins.filter((function(e){return e.name===t}))[0]}},{key:"load",value:function(t,e){this.options.mimeType=e,t=t&&t.constructor===Array?t:[t],this.options.sources=t,this.containers.forEach((function(t){return t.destroy()})),this.containerFactory.options=S.extend(!0,this.options,{sources:t}),this.prepareContainers()}},{key:"destroy",value:function(){this.disableResizeObserver(),this.containers.forEach((function(t){return t.destroy()})),this.plugins.forEach((function(t){return t.destroy()})),this.$el.remove(),S(document).unbind("fullscreenchange",this._boundFullscreenHandler),S(document).unbind("MSFullscreenChange",this._boundFullscreenHandler),S(document).unbind("mozfullscreenchange",this._boundFullscreenHandler),D.isMobile&&S(window).unbind("resize",this._boundHandleWindowResize),this.stopListening(),this.undelegateEvents()}},{key:"handleFullscreenChange",value:function(){this.trigger(ct.CORE_FULLSCREEN,this.isFullscreen()),this.updateSize()}},{key:"handleWindowResize",value:function(t){var e=window.innerWidth>window.innerHeight?"landscape":"portrait";this._screenOrientation!==e&&(this._screenOrientation=e,this.triggerResize({width:this.el.clientWidth,height:this.el.clientHeight}),this.trigger(ct.CORE_SCREEN_ORIENTATION_CHANGED,{event:t,orientation:this._screenOrientation}))}},{key:"removeContainer",value:function(t){this.stopListening(t),this.containerFactory.stopListening(t),this.containers=this.containers.filter((function(e){return e!==t}))}},{key:"setupContainer",value:function(t){this.listenTo(t,ct.CONTAINER_DESTROYED,this.removeContainer),this.containers.push(t)}},{key:"setupContainers",value:function(t){return t.forEach(this.setupContainer.bind(this)),this.trigger(ct.CORE_CONTAINERS_CREATED),this.renderContainers(),this.activeContainer=t[0],this.render(),this.appendToParent(),this.containers}},{key:"renderContainers",value:function(){var t=this;this.containers.forEach((function(e){return t.el.appendChild(e.render().el)}))}},{key:"createContainer",value:function(t,e){var i=this.containerFactory.createContainer(t,e);return this.setupContainer(i),this.el.appendChild(i.render().el),i}},{key:"getCurrentContainer",value:function(){return this.activeContainer}},{key:"getCurrentPlayback",value:function(){return this.activePlayback}},{key:"getPlaybackType",value:function(){return this.activeContainer&&this.activeContainer.getPlaybackType()}},{key:"isFullscreen",value:function(){var t=G.fullscreenElement();return t&&t===this.el||t&&t===this.activePlaybackEl||this.activePlaybackEl&&this.activePlaybackEl.webkitDisplayingFullscreen||!1}},{key:"toggleFullscreen",value:function(){var t=this;if(this.isFullscreen()){var e=D.isiOS?this.activePlaybackEl:document;G.cancelFullscreen(e),!D.isiOS&&this.$el.removeClass("fullscreen nocursor")}else{var i=D.isiOS?this.activePlaybackEl:this.el;if(!i)return;D.isSafari||D.isiOS?G.requestFullscreen(i):G.requestFullscreen(i).then((function(t){return t}),(function(e){return setTimeout((function(){if(!t.isFullscreen())throw new ReferenceError(e)}),600)})),!D.isiOS&&this.$el.addClass("fullscreen")}}},{key:"onMouseMove",value:function(t){this.trigger(ct.CORE_MOUSE_MOVE,t)}},{key:"onMouseLeave",value:function(t){this.trigger(ct.CORE_MOUSE_LEAVE,t)}},{key:"configure",value:function(t){var e=this;this._options=S.extend(!0,this._options,t),this.configureDomRecycler();var i=t.source||t.sources;i&&this.load(i,t.mimeType||this.options.mimeType),this.trigger(ct.CORE_OPTIONS_CHANGE,t),this.containers.forEach((function(t){return t.configure(e.options)}))}},{key:"appendToParent",value:function(){!(this.$el.parent()&&this.$el.parent().length)&&this.$el.appendTo(this.options.parentElement)}},{key:"appendStyles",value:function(){if(!this.styleRendered){var t=Et.getStyleFor('[data-player] {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -o-user-select: none;\n user-select: none;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n transform: translate3d(0, 0, 0);\n position: relative;\n margin: 0;\n padding: 0;\n border: 0;\n font-style: normal;\n font-weight: normal;\n text-align: center;\n overflow: hidden;\n font-size: 100%;\n font-family: "Roboto", "Open Sans", Arial, sans-serif;\n text-shadow: 0 0 0;\n box-sizing: border-box; }\n [data-player]:focus {\n outline: 0; }\n [data-player] * {\n box-sizing: inherit; }\n [data-player] > * {\n float: none;\n max-width: none; }\n [data-player] > div {\n display: block; }\n [data-player].fullscreen {\n width: 100% !important;\n height: 100% !important;\n top: 0;\n left: 0; }\n [data-player].nocursor {\n cursor: none; }\n\n.clappr-style {\n display: none !important; }\n'.toString(),{baseUrl:this.options.baseUrl});if(this.$el.append(t[0]),this.options.includeResetStyle){var e=Et.getStyleFor('[data-player] div, [data-player] span, [data-player] applet, [data-player] object, [data-player] iframe,\n[data-player] h1, [data-player] h2, [data-player] h3, [data-player] h4, [data-player] h5, [data-player] h6, [data-player] p, [data-player] blockquote, [data-player] pre,\n[data-player] a, [data-player] abbr, [data-player] acronym, [data-player] address, [data-player] big, [data-player] cite, [data-player] code,\n[data-player] del, [data-player] dfn, [data-player] em, [data-player] img, [data-player] ins, [data-player] kbd, [data-player] q, [data-player] s, [data-player] samp,\n[data-player] small, [data-player] strike, [data-player] strong, [data-player] sub, [data-player] sup, [data-player] tt, [data-player] var,\n[data-player] b, [data-player] u, [data-player] i, [data-player] center,\n[data-player] dl, [data-player] dt, [data-player] dd, [data-player] ol, [data-player] ul, [data-player] li,\n[data-player] fieldset, [data-player] form, [data-player] label, [data-player] legend,\n[data-player] table, [data-player] caption, [data-player] tbody, [data-player] tfoot, [data-player] thead, [data-player] tr, [data-player] th, [data-player] td,\n[data-player] article, [data-player] aside, [data-player] canvas, [data-player] details, [data-player] embed,\n[data-player] figure, [data-player] figcaption, [data-player] footer, [data-player] header, [data-player] hgroup,\n[data-player] menu, [data-player] nav, [data-player] output, [data-player] ruby, [data-player] section, [data-player] summary,\n[data-player] time, [data-player] mark, [data-player] audio, [data-player] video {\n margin: 0;\n padding: 0;\n border: 0;\n font: inherit;\n font-size: 100%;\n vertical-align: baseline; }\n\n[data-player] table {\n border-collapse: collapse;\n border-spacing: 0; }\n\n[data-player] caption, [data-player] th, [data-player] td {\n text-align: left;\n font-weight: normal;\n vertical-align: middle; }\n\n[data-player] q, [data-player] blockquote {\n quotes: none; }\n [data-player] q:before, [data-player] q:after, [data-player] blockquote:before, [data-player] blockquote:after {\n content: "";\n content: none; }\n\n[data-player] a img {\n border: none; }\n'.toString(),{baseUrl:this.options.baseUrl});this.$el.append(e[0])}this.styleRendered=!0}}},{key:"render",value:function(){this.appendStyles(),this.options.width=this.options.width||this.$el.width(),this.options.height=this.options.height||this.$el.height();var t={width:this.options.width,height:this.options.height};return this.previousSize=this.currentSize=this.computedSize=t,this.updateSize(),this.enableResizeObserver(),this}}])}(bt);Object.assign(wt.prototype,St);var It,Dt,Pt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t.options])).player=t,i}return f(e,t),u(e,[{key:"loader",get:function(){return this.player.loader}},{key:"create",value:function(){return this.options.loader=this.loader,this.core=new wt(this.options),this.addCorePlugins(),this.core.createContainers(this.options),this.core}},{key:"addCorePlugins",value:function(){var t=this;return this.loader.corePlugins.forEach((function(e){var i=new e(t.core);t.core.addPlugin(i),t.setupExternalInterface(i)})),this.core}},{key:"setupExternalInterface",value:function(t){var e=t.getExternalInterface();for(var i in e)this.player[i]=e[i].bind(t)}}])}(ht),Ot=/(\d+)(?:\.(\d+))?(?:\.(\d+))?/,xt=function(){function t(e,i,n){c(this,t),this.major=parseInt(e||0,10),this.minor=parseInt(i||0,10),this.patch=parseInt(n||0,10)}return u(t,[{key:"compare",value:function(t){var e=this.major-t.major;return e=(e=e||this.minor-t.minor)||this.patch-t.patch}},{key:"inc",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"patch";return void 0!==this[t]&&(this[t]+=1),this}},{key:"satisfies",value:function(t,e){return this.compare(t)>=0&&(!e||this.compare(e)<0)}},{key:"toString",value:function(){return"".concat(this.major,".").concat(this.minor,".").concat(this.patch)}}],[{key:"parse",value:function(){var e=v((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").match(Ot)||[],4),i=e[1],n=e[2],r=e[3];return void 0===i?null:new t(i,n,r)}}])}(),Nt=function(t,e){return t&&e?Object.entries(t).filter((function(t){return v(t,2)[1].type===e})).reduce((function(t,e){var i=v(e,2),n=i[0],r=i[1];return t[n]=r,t}),{}):{}},Mt=(It={plugins:{},playbacks:[]},Dt="0.11.1",function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;c(this,t),this.playerId=i,this.playbackPlugins=y(It.playbacks);var n=t.registeredPlugins,r=n.core,s=n.container;this.containerPlugins=Object.values(s),this.corePlugins=Object.values(r),Array.isArray(e)||this.validateExternalPluginsType(e),this.addExternalPlugins(e)}return u(t,[{key:"groupPluginsByType",value:function(t){return Array.isArray(t)&&(t=t.reduce((function(t,e){return t[e.type]||(t[e.type]=[]),t[e.type].push(e),t}),{})),t}},{key:"removeDups",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=t.reduceRight((function(t,i){return t[i.prototype.name]&&e||(t[i.prototype.name]&&delete t[i.prototype.name],t[i.prototype.name]=i),t}),Object.create(null)),n=[];for(var r in i)n.unshift(i[r]);return n}},{key:"addExternalPlugins",value:function(e){var i="boolean"!=typeof e.loadExternalPluginsFirst||e.loadExternalPluginsFirst,n="boolean"!=typeof e.loadExternalPlaybacksFirst||e.loadExternalPlaybacksFirst;if((e=this.groupPluginsByType(e)).playback){var r=e.playback.filter((function(e){return t.checkVersionSupport(e),!0}));this.playbackPlugins=n?this.removeDups(r.concat(this.playbackPlugins)):this.removeDups(this.playbackPlugins.concat(r),!0)}if(e.container){var s=e.container.filter((function(e){return t.checkVersionSupport(e),!0}));this.containerPlugins=i?this.removeDups(s.concat(this.containerPlugins)):this.removeDups(this.containerPlugins.concat(s),!0)}if(e.core){var a=e.core.filter((function(e){return t.checkVersionSupport(e),!0}));this.corePlugins=i?this.removeDups(a.concat(this.corePlugins)):this.removeDups(this.corePlugins.concat(a),!0)}}},{key:"validateExternalPluginsType",value:function(t){["playback","container","core"].forEach((function(e){(t[e]||[]).forEach((function(t){var i="external "+t.type+" plugin on "+e+" array";if(t.type!==e)throw new ReferenceError(i)}))}))}}],[{key:"registeredPlaybacks",get:function(){return y(It.playbacks)}},{key:"registeredPlugins",get:function(){var t=It.plugins;return{core:Nt(t,"core"),container:Nt(t,"container")}}},{key:"checkVersionSupport",value:function(t){var e=t.prototype,i=e.supportedVersion,n=e.name;if(!i||!i.min)return rt.warn("Loader","missing version information for ".concat(n)),!1;var r=i.max?xt.parse(i.max):xt.parse(i.min).inc("minor"),s=xt.parse(i.min);return!!xt.parse(Dt).satisfies(s,r)||(rt.warn("Loader","unsupported plugin ".concat(n,": Clappr version ").concat(Dt," does not match required range [").concat(s,",").concat(r,")")),!1)}},{key:"registerPlugin",value:function(e){if(!e||!e.prototype.name)return rt.warn("Loader","missing information to register plugin: ".concat(e)),!1;t.checkVersionSupport(e);var i=It.plugins;if(!i)return!1;var n=i[e.prototype.name];return n&&rt.warn("Loader","overriding plugin entry: ".concat(e.prototype.name," - ").concat(n)),i[e.prototype.name]=e,!0}},{key:"registerPlayback",value:function(e){if(!e||!e.prototype.name)return!1;t.checkVersionSupport(e);var i=It.playbacks,n=i.findIndex((function(t){return t.prototype.name===e.prototype.name}));if(n>=0){var r=i[n];i.splice(n,1),rt.warn("Loader","overriding playback entry: ".concat(r.name," - ").concat(r))}return It.playbacks=[e].concat(y(i)),!0}},{key:"unregisterPlugin",value:function(t){if(!t)return!1;var e=It.plugins;return!!e[t]&&(delete e[t],!0)}},{key:"unregisterPlayback",value:function(t){if(!t)return!1;var e=It.playbacks,i=e.findIndex((function(e){return e.prototype.name===t}));return!(i<0||(e.splice(i,1),It.playbacks=e,0))}},{key:"clearPlugins",value:function(){It.plugins={}}},{key:"clearPlaybacks",value:function(){It.playbacks=[]}}])}()),Ft=W().replace(/\/[^/]+$/,""),Bt=function(t){function e(t){var i;c(this,e),i=n(this,e,[t]);var r={playerId:Y(""),persistConfig:!0,width:640,height:360,baseUrl:Ft,allowUserInteraction:D.isMobile,includeResetStyle:!0,playback:{recycleVideo:!0}};i._options=S.extend(!0,r,t),i.options.sources=i._normalizeSources(t),i.options.chromeless||(i.options.allowUserInteraction=!0),i.options.allowUserInteraction||(i.options.disableKeyboardShortcuts=!0),i._registerOptionEventListeners(i.options.events),i._coreFactory=new Pt(i);var s=i._getParentElement(i.options);return s&&i.attachTo(s),i}return f(e,t),u(e,[{key:"loader",get:function(){return this._loader||(this._loader=new Mt(this.options.plugins||{},this.options.playerId)),this._loader},set:function(t){this._loader=t}},{key:"ended",get:function(){return this.core.activeContainer.ended}},{key:"buffering",get:function(){return this.core.activeContainer.buffering}},{key:"isReady",get:function(){return!!this._ready}},{key:"eventsMapping",get:function(){return{onReady:ct.PLAYER_READY,onResize:ct.PLAYER_RESIZE,onPlay:ct.PLAYER_PLAY,onPause:ct.PLAYER_PAUSE,onStop:ct.PLAYER_STOP,onEnded:ct.PLAYER_ENDED,onSeek:ct.PLAYER_SEEK,onError:ct.PLAYER_ERROR,onTimeUpdate:ct.PLAYER_TIMEUPDATE,onVolumeUpdate:ct.PLAYER_VOLUMEUPDATE,onSubtitleAvailable:ct.PLAYER_SUBTITLE_AVAILABLE}}},{key:"_getParentElement",value:function(t){var e=t.parentId,i=t.parent;return e?document.querySelector(e):i}},{key:"attachTo",value:function(t){return this.options.parentElement=t,this.core=this._coreFactory.create(),this._addEventListeners(),this}},{key:"_addEventListeners",value:function(){return this.core.isReady?this._onReady():this.listenToOnce(this.core,ct.CORE_READY,this._onReady),this.listenTo(this.core,ct.CORE_ACTIVE_CONTAINER_CHANGED,this._containerChanged),this.listenTo(this.core,ct.CORE_FULLSCREEN,this._onFullscreenChange),this.listenTo(this.core,ct.CORE_RESIZE,this._onResize),this}},{key:"_addContainerEventListeners",value:function(){var t=this.core.activeContainer;return t&&(this.listenTo(t,ct.CONTAINER_PLAY,this._onPlay),this.listenTo(t,ct.CONTAINER_PAUSE,this._onPause),this.listenTo(t,ct.CONTAINER_STOP,this._onStop),this.listenTo(t,ct.CONTAINER_ENDED,this._onEnded),this.listenTo(t,ct.CONTAINER_SEEK,this._onSeek),this.listenTo(t,ct.CONTAINER_ERROR,this._onError),this.listenTo(t,ct.CONTAINER_TIMEUPDATE,this._onTimeUpdate),this.listenTo(t,ct.CONTAINER_VOLUME,this._onVolumeUpdate),this.listenTo(t,ct.CONTAINER_SUBTITLE_AVAILABLE,this._onSubtitleAvailable)),this}},{key:"_registerOptionEventListeners",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).length>0&&Object.keys(i).forEach((function(e){var n=t.eventsMapping[e];n&&t.off(n,i[e])})),Object.keys(e).forEach((function(i){var n=t.eventsMapping[i];if(n){var r=e[i];(r="function"==typeof r&&r)&&t.on(n,r)}})),this}},{key:"_containerChanged",value:function(){this.stopListening(),this._addEventListeners()}},{key:"_onReady",value:function(){this._ready=!0,this._addContainerEventListeners(),this.trigger(ct.PLAYER_READY)}},{key:"_onFullscreenChange",value:function(t){this.trigger(ct.PLAYER_FULLSCREEN,t)}},{key:"_onVolumeUpdate",value:function(t){this.trigger(ct.PLAYER_VOLUMEUPDATE,t)}},{key:"_onSubtitleAvailable",value:function(){this.trigger(ct.PLAYER_SUBTITLE_AVAILABLE)}},{key:"_onResize",value:function(t){this.trigger(ct.PLAYER_RESIZE,t)}},{key:"_onPlay",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.trigger(ct.PLAYER_PLAY,e)}},{key:"_onPause",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.trigger(ct.PLAYER_PAUSE,e)}},{key:"_onStop",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.trigger(ct.PLAYER_STOP,this.getCurrentTime(),t)}},{key:"_onEnded",value:function(){this.trigger(ct.PLAYER_ENDED)}},{key:"_onSeek",value:function(t){this.trigger(ct.PLAYER_SEEK,t)}},{key:"_onTimeUpdate",value:function(t){this.trigger(ct.PLAYER_TIMEUPDATE,t)}},{key:"_onError",value:function(t){this.trigger(ct.PLAYER_ERROR,t)}},{key:"_normalizeSources",value:function(t){var e=t.sources||(void 0!==t.source?[t.source]:[]);return 0===e.length?[{source:"",mimeType:""}]:e}},{key:"resize",value:function(t){return this.core.resize(t),this}},{key:"load",value:function(t,e,i){return void 0!==i&&this.configure({autoPlay:!!i}),this.core.load(t,e),this}},{key:"destroy",value:function(){return this.stopListening(),this.core.destroy(),this}},{key:"consent",value:function(t){this.core.getCurrentPlayback().consent(t)}},{key:"play",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.play(t),this}},{key:"pause",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.pause(t),this}},{key:"stop",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.stop(t),this}},{key:"seek",value:function(t){return this.core.activeContainer.seek(t),this}},{key:"seekPercentage",value:function(t){return this.core.activeContainer.seekPercentage(t),this}},{key:"mute",value:function(){return this.core.activePlayback.mute(),this}},{key:"unmute",value:function(){return this.core.activePlayback.unmute(),this}},{key:"isPlaying",value:function(){return this.core.activeContainer.isPlaying()}},{key:"isDvrEnabled",value:function(){return this.core.activeContainer.isDvrEnabled()}},{key:"isDvrInUse",value:function(){return this.core.activeContainer.isDvrInUse()}},{key:"configure",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._registerOptionEventListeners(t.events,this.options.events),this.core.configure(t),this}},{key:"getPlugin",value:function(t){return this.core.plugins.concat(this.core.activeContainer.plugins).filter((function(e){return e.name===t}))[0]}},{key:"getCurrentTime",value:function(){return this.core.activeContainer.getCurrentTime()}},{key:"getStartTimeOffset",value:function(){return this.core.activeContainer.getStartTimeOffset()}},{key:"getDuration",value:function(){return this.core.activeContainer.getDuration()}}])}(ht);Object.assign(Bt.prototype,St);var Ut=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t.options])).container=t,i.enabled=!0,i.bindEvents(),i}return f(e,t),u(e,[{key:"playerError",get:function(){return this.container.playerError}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.stopListening(),this.enabled=!1)}},{key:"bindEvents",value:function(){}},{key:"destroy",value:function(){this.stopListening()}}])}(ht);Object.assign(Ut.prototype,St),Ut.extend=function(t){return $(Ut,t)},Ut.type="container";var $t=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t.options])).core=t,i.enabled=!0,i.bindEvents(),i}return f(e,t),u(e,[{key:"playerError",get:function(){return this.core.playerError}},{key:"bindEvents",value:function(){}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.stopListening(),this.enabled=!1)}},{key:"getExternalInterface",value:function(){return{}}},{key:"destroy",value:function(){this.stopListening()}}])}(ht);Object.assign($t.prototype,St),$t.extend=function(t){return $($t,t)},$t.type="core";var Gt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t.options])).container=t,i.enabled=!0,i.bindEvents(),i}return f(e,t),u(e,[{key:"playerError",get:function(){return this.container.playerError}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.$el.show(),this.enabled=!0)}},{key:"disable",value:function(){this.stopListening(),this.$el.hide(),this.enabled=!1}},{key:"bindEvents",value:function(){}}])}(bt);Object.assign(Gt.prototype,St),Gt.extend=function(t){return $(Gt,t)},Gt.type="container";var Vt={mp4:["avc1.42E01E","avc1.58A01E","avc1.4D401E","avc1.64001E","mp4v.20.8","mp4v.20.240","mp4a.40.2"].map((function(t){return'video/mp4; codecs="'+t+', mp4a.40.2"'})),ogg:['video/ogg; codecs="theora, vorbis"','video/ogg; codecs="dirac"','video/ogg; codecs="theora, speex"'],"3gpp":['video/3gpp; codecs="mp4v.20.8, samr"'],webm:['video/webm; codecs="vp8, vorbis"'],mkv:['video/x-matroska; codecs="theora, vorbis"'],m3u8:["application/x-mpegurl"]};Vt.ogv=Vt.ogg,Vt["3gp"]=Vt["3gpp"];var Kt={wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},Ht=Object.keys(Kt).reduce((function(t,e){return[].concat(y(t),y(Kt[e]))}),[]),Yt={code:"unknown",message:"unknown"},jt=function(t){function e(){var t;c(this,e);for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];(t=n(this,e,[].concat(r)))._destroyed=!1,t._loadStarted=!1,t._isBuffering=!1,t._playheadMoving=!1,t._playheadMovingTimer=null,t._stopped=!1,t._ccTrackId=-1,t._playheadMovingCheckEnabled=!t.options.disablePlayheadMovingCheck,t._setupSrc(t.options.src),t._playheadMovingCheckInterval=t.options.playheadMovingCheckInterval||500,t.options.playback||(t.options.playback=t.options||{}),t.options.playback.disableContextMenu=t.options.playback.disableContextMenu||t.options.disableVideoTagContextMenu,t._minDvrSize=t.isValidMinimumDVRSizeConfig?t.minimumDVRSizeConfig:60;var a,o=t.options.playback,l=o.preload||(D.isSafari?"auto":t.options.preload);return t.options.poster&&("string"==typeof t.options.poster?a=t.options.poster:"string"==typeof t.options.poster.url&&(a=t.options.poster.url)),S.extend(!0,t.el,{muted:t.options.mute,defaultMuted:t.options.mute,loop:t.options.loop,poster:a,preload:l||"metadata",crossOrigin:o.crossOrigin,"x-webkit-playsinline":o.playInline}),(o.controls||t.options.useVideoTagDefaultControls)&&t.$el.attr("controls",""),o.playInline&&t.$el.attr({playsinline:"playsinline"}),o.crossOrigin&&t.$el.attr({crossorigin:o.crossOrigin}),t.settings={default:["seekbar"]},t.settings.left=["playpause","position","duration"],t.settings.right=["fullscreen","volume","hd-indicator"],o.externalTracks&&t._setupExternalTracks(o.externalTracks),t.options.autoPlay&&t.attemptAutoPlay(),t}return f(e,t),u(e,[{key:"name",get:function(){return"html5_video"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"tagName",get:function(){return this.isAudioOnly?"audio":"video"}},{key:"isAudioOnly",get:function(){var t=this.options.src,i=e._mimeTypesForUrl(t,Kt,this.options.mimeType);return this.options.playback&&this.options.playback.audioOnly||this.options.audioOnly||Ht.indexOf(i[0])>=0}},{key:"attributes",get:function(){return{"data-html5-video":""}}},{key:"events",get:function(){return{canplay:"_onCanPlay",canplaythrough:"_handleBufferingEvents",durationchange:"_onDurationChange",ended:"_onEnded",error:"_onError",loadeddata:"_onLoadedData",loadedmetadata:"_onLoadedMetadata",pause:"_onPause",playing:"_onPlaying",progress:"_onProgress",seeking:"_onSeeking",seeked:"_onSeeked",stalled:"_handleBufferingEvents",timeupdate:"_onTimeUpdate",waiting:"_onWaiting",enterpictureinpicture:"_onEnterPiP",leavepictureinpicture:"_onExitPiP"}}},{key:"ended",get:function(){return this.el.ended}},{key:"buffering",get:function(){return this._isBuffering}},{key:"isPiPActive",get:function(){return this.el===document.pictureInPictureElement}},{key:"isLive",get:function(){return this.getPlaybackType()===Rt.LIVE}},{key:"dvrEnabled",get:function(){return this.getDuration()>=this._minDvrSize&&this.isLive}},{key:"minimumDVRSizeConfig",get:function(){return this.options.playback&&this.options.playback.minimumDvrSize}},{key:"isValidMinimumDVRSizeConfig",get:function(){return void 0!==this.minimumDVRSizeConfig&&"number"==typeof this.minimumDVRSizeConfig}},{key:"sourceMedia",get:function(){return this._src}},{key:"configure",value:function(t){m(g(e.prototype),"configure",this).call(this,t),this.el.loop=!!t.loop}},{key:"attemptAutoPlay",value:function(){var t=this;this.canAutoPlay((function(e,i){i&&rt.warn(t.name,"autoplay error.",{result:e,error:i}),e&&setTimeout((function(){return!t._destroyed&&t.play()}),0)}))}},{key:"canAutoPlay",value:function(t){if(this.options.disableCanAutoPlay)t(!0,null);else{var e={timeout:this.options.autoPlayTimeout||500,inline:this.options.playback.playInline||!1,muted:this.options.mute||!1};D.isMobile&&X.options.recycleVideo&&(e.element=this.el),q(t,e)}}},{key:"_setupExternalTracks",value:function(t){this._externalTracks=t.map((function(t){return{kind:t.kind||"subtitles",label:t.label,lang:t.lang,src:t.src}}))}},{key:"load",value:function(t){this._setupSrc(t)}},{key:"_setupSrc",value:function(t){this.el.src!==t&&(this._ccIsSetup=!1,this.el.src=t,this._src=this.el.src)}},{key:"_onLoadedMetadata",value:function(t){this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_LOADEDMETADATA,{duration:t.target.duration,data:t}),this._updateSettings();var e=void 0===this._options.autoSeekFromUrl||this._options.autoSeekFromUrl;this.getPlaybackType()!==Rt.LIVE&&e&&this._checkInitialSeek()}},{key:"_onDurationChange",value:function(){this._updateSettings(),this._onTimeUpdate(),this._onProgress()}},{key:"_updateSettings",value:function(){this.getPlaybackType()===Rt.VOD||this.getPlaybackType()===Rt.AOD?this.settings.left=["playpause","position","duration"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(ct.PLAYBACK_SETTINGSUPDATE)}},{key:"isSeekEnabled",value:function(){return isFinite(this.getDuration())}},{key:"getPlaybackType",value:function(){var t="audio"===this.tagName?Rt.AOD:Rt.VOD;return[0,void 0,1/0].indexOf(this.el.duration)>=0?Rt.LIVE:t}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"consent",value:function(t){var i=this;if(this.isPlaying()||this.el._consented)m(g(e.prototype),"consent",this).call(this,t);else{var n=function n(){i.el.removeEventListener("loadedmetadata",n,!1),i.el.removeEventListener("error",n,!1),i.el._consented=!0,m(g(e.prototype),"consent",i).call(i,t)};this.el.addEventListener("loadedmetadata",n,!1),this.el.addEventListener("error",n,!1),this.el.load()}}},{key:"play",value:function(){var t=this;this.trigger(ct.PLAYBACK_PLAY_INTENT),this._stopped=!1,this._setupSrc(this._src),this._handleBufferingEvents();var e=this.el.play();return e&&e.catch&&e.catch((function(e){return rt.warn(t.name,"HTML5 play failed",e)})),e}},{key:"pause",value:function(){this.el.pause()}},{key:"stop",value:function(){this.pause(),this._stopped=!0,this.el.removeAttribute("src"),this.el.load(),this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_STOP)}},{key:"volume",value:function(t){0===t?(this.$el.attr({muted:"true"}),this.el.muted=!0):(this.$el.attr({muted:null}),this.el.muted=!1,this.el.volume=t/100)}},{key:"mute",value:function(){this.el.muted=!0}},{key:"unmute",value:function(){this.el.muted=!1}},{key:"isMuted",value:function(){return!0===this.el.muted||0===this.el.volume}},{key:"isPlaying",value:function(){return!this.el.paused&&!this.el.ended}},{key:"isReady",get:function(){return this._isReadyState}},{key:"_startPlayheadMovingChecks",value:function(){null===this._playheadMovingTimer&&this._playheadMovingCheckEnabled&&(this._playheadMovingTimeOnCheck=null,this._determineIfPlayheadMoving(),this._playheadMovingTimer=setInterval(this._determineIfPlayheadMoving.bind(this),this._playheadMovingCheckInterval))}},{key:"_stopPlayheadMovingChecks",value:function(){null!==this._playheadMovingTimer&&(clearInterval(this._playheadMovingTimer),this._playheadMovingTimer=null,this._playheadMoving=!1)}},{key:"_determineIfPlayheadMoving",value:function(){var t=this._playheadMovingTimeOnCheck,e=this.el.currentTime;this._playheadMoving=t!==e,this._playheadMovingTimeOnCheck=e,this._handleBufferingEvents()}},{key:"_onWaiting",value:function(){this._loadStarted=!0,this._handleBufferingEvents()}},{key:"_onLoadedData",value:function(){this._loadStarted=!0,this._handleBufferingEvents()}},{key:"_onCanPlay",value:function(){this._handleBufferingEvents()}},{key:"_onPlaying",value:function(){this._checkForClosedCaptions(),this._startPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_PLAY)}},{key:"_onPause",value:function(){this.dvrEnabled&&this._updateDvr(!0),this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_PAUSE)}},{key:"_onSeeking",value:function(){var t=this.getCurrentTime();this.dvrEnabled&&this._updateDvr(t<this.getDuration()-3),this.trigger(ct.PLAYBACK_SEEK,t),this._handleBufferingEvents()}},{key:"_onSeeked",value:function(){this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_SEEKED)}},{key:"_onEnded",value:function(){this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_ENDED,this.name)}},{key:"_onEnterPiP",value:function(){this.trigger(ct.PLAYBACK_PIP_ENTER,this.name)}},{key:"_onExitPiP",value:function(){this.trigger(ct.PLAYBACK_PIP_EXIT,this.name)}},{key:"enterPiP",value:function(){var t=this;this.el.requestPictureInPicture().then((function(){rt.info(t.name,"enter PIP success")})).catch((function(e){rt.warn(t.name,"enter PIP failed",e)}))}},{key:"exitPiP",value:function(){var t=this;document.exitPictureInPicture().then((function(){rt.info(t.name,"exit PIP success")})).catch((function(e){rt.warn(t.name,"exit PIP failed",e)}))}},{key:"_handleBufferingEvents",value:function(){var t=this._loadStarted&&!this.el.ended&&!this._stopped,e=this.el.readyState<this.el.HAVE_FUTURE_DATA,i=!this.el.ended&&!this.el.paused&&!this._playheadMoving,n=t&&e;this._playheadMovingCheckEnabled&&(n=n||t&&i),this._isBuffering!==n&&(this._isBuffering=n,n?this.trigger(ct.PLAYBACK_BUFFERING,this.name):this.trigger(ct.PLAYBACK_BUFFERFULL,this.name))}},{key:"_onError",value:function(){var t=this.el.error||Yt,e=t.code,i=t.message,n=e===Yt.code,r=this.createError({code:e,description:i,raw:this.el.error,level:n?kt.Levels.WARN:kt.Levels.FATAL});n?rt.warn(this.name,"HTML5 unknown error: ",r):this.trigger(ct.PLAYBACK_ERROR,r)}},{key:"destroy",value:function(){this._destroyed=!0,this._stopPlayheadMovingChecks(),this.handleTextTrackChange&&this.el.textTracks.removeEventListener("change",this.handleTextTrackChange),this.$el.off("contextmenu"),m(g(e.prototype),"destroy",this).call(this),this.el.removeAttribute("src"),this.el.load(),this._src=null,X.garbage(this.el)}},{key:"_updateDvr",value:function(t){this.trigger(ct.PLAYBACK_DVR,t),this.trigger(ct.PLAYBACK_STATS_ADD,{dvr:t})}},{key:"seek",value:function(t){t<0&&(rt.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),t=this.getDuration()),t+=this.el.seekable.start(0),this.el.currentTime=t}},{key:"seekPercentage",value:function(t){var e=this.el.duration*(t/100);this.seek(e)}},{key:"_checkInitialSeek",value:function(){var t=H();0!==t&&this.seek(t)}},{key:"getCurrentTime",value:function(){return this.el.currentTime}},{key:"getDuration",value:function(){if(this.isLive){if(this.el.seekable.length>0)return this.el.seekable.end(0)-this.el.seekable.start(0);this._scheduleUpdateSettingsCheck()}return this.el.duration}},{key:"_scheduleUpdateSettingsCheck",value:function(){var t=this;this._updateSettingsCheckInFlight||(this._updateSettingsCheckInFlight=setTimeout((function(){t._updateSettings(),t._updateSettingsCheckInFlight=null}),1e3))}},{key:"_onTimeUpdate",value:function(){var t=this.isLive?this.getDuration():this.el.duration;this.trigger(ct.PLAYBACK_TIMEUPDATE,{current:this.el.currentTime,total:t},this.name)}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var t=[],e=0,i=0;i<this.el.buffered.length;i++)t=[].concat(y(t),[{start:this.el.buffered.start(i),end:this.el.buffered.end(i)}]),this.el.currentTime>=t[i].start&&this.el.currentTime<=t[i].end&&(e=i);var n={start:t[e].start,current:t[e].end,total:this.el.duration};this.trigger(ct.PLAYBACK_PROGRESS,n,t)}}},{key:"_typeFor",value:function(t){var i=e._mimeTypesForUrl(t,Vt,this.options.mimeType);return 0===i.length&&(i=e._mimeTypesForUrl(t,Kt,this.options.mimeType)),(i[0]||"").split(";")[0]}},{key:"_ready",value:function(){this._isReadyState||(this._isReadyState=!0,this.trigger(ct.PLAYBACK_READY,this.name))}},{key:"_checkForClosedCaptions",value:function(){if(this.isHTML5Video&&!this._ccIsSetup){if(this.hasClosedCaptionsTracks){this.trigger(ct.PLAYBACK_SUBTITLE_AVAILABLE);var t=this.closedCaptionsTrackId;this.closedCaptionsTrackId=t,this.handleTextTrackChange=this._handleTextTrackChange.bind(this),this.el.textTracks.addEventListener("change",this.handleTextTrackChange)}this._ccIsSetup=!0}}},{key:"_handleTextTrackChange",value:function(){var t=this.closedCaptionsTracks.find((function(t){return"showing"===t.track.mode}))||{id:-1};this._ccTrackId!==t.id&&(this._ccTrackId=t.id,this.trigger(ct.PLAYBACK_SUBTITLE_CHANGED,{id:t.id}))}},{key:"isHTML5Video",get:function(){return this.name===e.prototype.name}},{key:"closedCaptionsTracks",get:function(){var t=0;return(this.el.textTracks?Array.from(this.el.textTracks):[]).filter((function(t){return"subtitles"===t.kind||"captions"===t.kind})).map((function(e){return{id:t++,name:e.label,track:e}}))}},{key:"closedCaptionsTrackId",get:function(){return this._ccTrackId},set:function(t){if(j(t)){var e,i=this.closedCaptionsTracks;if(-1!==t){if(!(e=i.find((function(e){return e.id===t}))))return;if("showing"===e.track.mode)return}i.filter((function(t){return"hidden"!==t.track.mode})).forEach((function(t){return t.track.mode="hidden"})),e&&(e.track.mode="showing"),this._ccTrackId=t,this.trigger(ct.PLAYBACK_SUBTITLE_CHANGED,{id:t})}}},{key:"template",get:function(){return At('<% for (var i = 0; i < tracks.length; i++) { %>\n <track data-html5-video-track="<%= i %>" kind="<%= tracks[i].kind %>" label="<%= tracks[i].label %>" srclang="<%= tracks[i].lang %>" src="<%= tracks[i].src %>">\n<% }; %>\n')}},{key:"render",value:function(){this.options.playback.disableContextMenu&&this.$el.on("contextmenu",(function(){return!1})),this._externalTracks&&this._externalTracks.length>0&&this.$el.html(this.template({tracks:this._externalTracks})),this._ready();var t=Et.getStyleFor("[data-html5-video] {\n position: absolute;\n height: 100%;\n width: 100%;\n display: block; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(t[0]),this}}])}(Rt);jt._mimeTypesForUrl=function(){var t=arguments.length>1?arguments[1]:void 0,e=arguments.length>2?arguments[2]:void 0,i=((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split("?")[0].match(/.*\.(.*)$/)||[])[1],n=e||i&&t[i.toLowerCase()]||[];return n.constructor===Array?n:[n]},jt._canPlay=function(t,e,i,n){var r=jt._mimeTypesForUrl(i,e,n),s=document.createElement(t);return!!r.filter((function(t){return!!s.canPlayType(t).replace(/no/,"")}))[0]},jt.canPlay=function(t,e){return jt._canPlay("audio",Kt,t,e)||jt._canPlay("video",Vt,t,e)};var Wt=function(t){function e(){return c(this,e),n(this,e,arguments)}return f(e,t),u(e,[{key:"name",get:function(){return"html5_audio"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"tagName",get:function(){return"audio"}},{key:"isAudioOnly",get:function(){return!0}},{key:"updateSettings",value:function(){this.settings.left=["playpause","position","duration"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(ct.PLAYBACK_SETTINGSUPDATE)}},{key:"getPlaybackType",value:function(){return Rt.AOD}}])}(jt);Wt.canPlay=function(t,e){return jt._canPlay("audio",{wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},t,e)};var zt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t])).el.src=t.src,i}return f(e,t),u(e,[{key:"name",get:function(){return"html_img"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"tagName",get:function(){return"img"}},{key:"attributes",get:function(){return{"data-html-img":""}}},{key:"events",get:function(){return{load:"_onLoad",abort:"_onError",error:"_onError"}}},{key:"getPlaybackType",value:function(){return Rt.NO_OP}},{key:"render",value:function(){var t=Et.getStyleFor("[data-html-img] {\n max-width: 100%;\n max-height: 100%; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(t[0]),this.trigger(ct.PLAYBACK_READY,this.name),this}},{key:"_onLoad",value:function(){this.trigger(ct.PLAYBACK_ENDED,this.name)}},{key:"_onError",value:function(t){var e="error"===t.type?"load error":"loading aborted";this.trigger(ct.PLAYBACK_ERROR,{message:e},this.name)}}])}(Rt);zt.canPlay=function(t){return/\.(png|jpg|jpeg|gif|bmp|tiff|pgm|pnm|webp)(|\?.*)$/i.test(t)};var qt=function(t){function e(){var t;c(this,e);for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return(t=n(this,e,[].concat(r)))._noiseFrameNum=-1,t}return f(e,t),u(e,[{key:"name",get:function(){return"no_op"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"template",get:function(){return At("<canvas data-no-op-canvas></canvas>\n<p data-no-op-msg><%=message%></p><p>\n</p>")}},{key:"attributes",get:function(){return{"data-no-op":""}}},{key:"render",value:function(){var t=this.options.playbackNotSupportedMessage||this.i18n.t("playback_not_supported"),e=Et.getStyleFor("[data-no-op] {\n position: absolute;\n height: 100%;\n width: 100%;\n text-align: center; }\n\n[data-no-op] p[data-no-op-msg] {\n position: absolute;\n text-align: center;\n font-size: 25px;\n left: 0;\n right: 0;\n color: white;\n padding: 10px;\n /* center vertically */\n top: 50%;\n transform: translateY(-50%);\n max-height: 100%;\n overflow: auto; }\n\n[data-no-op] canvas[data-no-op-canvas] {\n background-color: #777;\n height: 100%;\n width: 100%; }\n".toString(),{baseUrl:this.options.baseUrl});this.$el.append(e[0]),this.$el.html(this.template({message:t})),this.trigger(ct.PLAYBACK_READY,this.name);var i=!(!this.options.poster||!this.options.poster.showForNoOp);return!this.options.autoPlay&&i||this._animate(),this}},{key:"_noise",value:function(){if(this._noiseFrameNum=(this._noiseFrameNum+1)%5,!this._noiseFrameNum){var t,e=this.context.createImageData(this.context.canvas.width,this.context.canvas.height);try{t=new Uint32Array(e.data.buffer)}catch(r){t=new Uint32Array(this.context.canvas.width*this.context.canvas.height*4);for(var i=e.data,n=0;n<i.length;n++)t[n]=i[n]}for(var r=t.length,s=6*Math.random()+4,a=0,o=0,l=0;l<r;){if(a<0)a=s*Math.random(),o=255*Math.pow(Math.random(),.4)<<24;a-=1,t[l++]=o}this.context.putImageData(e,0,0)}}},{key:"_loop",value:function(){var t=this;this._stop||(this._noise(),this._animationHandle=F((function(){return t._loop()})))}},{key:"destroy",value:function(){this._animationHandle&&(B(this._animationHandle),this._stop=!0)}},{key:"_animate",value:function(){this.canvas=this.$el.find("canvas[data-no-op-canvas]")[0],this.context=this.canvas.getContext("2d"),this._loop()}}])}(Rt);qt.canPlay=function(t){return!0};var Xt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t]))._initializeMessages(),i}return f(e,t),u(e,[{key:"name",get:function(){return"strings"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"t",value:function(t){var e=this._language(),i=this._messages.en;return(e&&this._messages[e]||i)[t]||i[t]||t}},{key:"_language",value:function(){return this.core.options.language||z()}},{key:"_initializeMessages",value:function(){this._messages=S.extend(!0,{en:{live:"live",back_to_live:"back to live",disabled:"Disabled",playback_not_supported:"Your browser does not support the playback of this video. Please try using a different browser.",default_error_title:"Could not play video.",default_error_message:"There was a problem trying to load the video."},de:{live:"Live",back_to_live:"Zurück zum Live-Video",disabled:"Deaktiviert",playback_not_supported:"Ihr Browser unterstützt das Playback Verfahren nicht. Bitte vesuchen Sie es mit einem anderen Browser.",default_error_title:"Video kann nicht abgespielt werden",default_error_message:"Es gab ein Problem beim Laden des Videos"},pt:{live:"ao vivo",back_to_live:"voltar para o ao vivo",disabled:"Desativado",playback_not_supported:"Seu navegador não suporta a reprodução deste video. Por favor, tente usar um navegador diferente.",default_error_title:"Não foi possível reproduzir o vídeo.",default_error_message:"Ocorreu um problema ao tentar carregar o vídeo."},es_am:{live:"vivo",back_to_live:"volver en vivo",disabled:"No disponible",playback_not_supported:"Su navegador no soporta la reproducción de este video. Por favor, utilice un navegador diferente.",default_error_title:"No se puede reproducir el video.",default_error_message:"Se ha producido un error al cargar el video."},es:{live:"en directo",back_to_live:"volver al directo",disabled:"No disponible",playback_not_supported:"Este navegador no es compatible para reproducir este vídeo. Utilice un navegador diferente.",default_error_title:"No se puede reproducir el vídeo.",default_error_message:"Se ha producido un problema al cargar el vídeo."},ru:{live:"прямой эфир",back_to_live:"к прямому эфиру",disabled:"Отключено",playback_not_supported:"Ваш браузер не поддерживает воспроизведение этого видео. Пожалуйста, попробуйте другой браузер."},bg:{live:"на живо",back_to_live:"Върни на живо",disabled:"Изключено",playback_not_supported:"Вашият браузър не поддържа възпроизвеждането на това видео. Моля, пробвайте с друг браузър.",default_error_title:"Видеото не може да се възпроизведе.",default_error_message:"Възникна проблем при зареждането на видеото."},fr:{live:"en direct",back_to_live:"retour au direct",disabled:"Désactivé",playback_not_supported:"Votre navigateur ne supporte pas la lecture de cette vidéo. Merci de tenter sur un autre navigateur.",default_error_title:"Impossible de lire la vidéo.",default_error_message:"Un problème est survenu lors du chargement de la vidéo."},tr:{live:"canlı",back_to_live:"canlı yayına dön",disabled:"Engelli",playback_not_supported:"Tarayıcınız bu videoyu oynatma desteğine sahip değil. Lütfen farklı bir tarayıcı ile deneyin."},et:{live:"Otseülekanne",back_to_live:"Tagasi otseülekande juurde",disabled:"Keelatud",playback_not_supported:"Teie brauser ei toeta selle video taasesitust. Proovige kasutada muud brauserit."},ar:{live:"مباشر",back_to_live:"الرجوع إلى المباشر",disabled:"معطّل",playback_not_supported:"المتصفح الذي تستخدمه لا يدعم تشغيل هذا الفيديو. الرجاء إستخدام متصفح آخر.",default_error_title:"غير قادر الى التشغيل.",default_error_message:"حدثت مشكلة أثناء تحميل الفيديو."},zh:{live:"直播",back_to_live:"返回直播",disabled:"已禁用",playback_not_supported:"您的浏览器不支持该视频的播放。请尝试使用另一个浏览器。",default_error_title:"无法播放视频。",default_error_message:"在尝试加载视频时出现了问题。"}},this.core.options.strings||{}),this._messages["de-DE"]=this._messages.de,this._messages["pt-BR"]=this._messages.pt,this._messages["en-US"]=this._messages.en,this._messages["bg-BG"]=this._messages.bg,this._messages["es-419"]=this._messages.es_am,this._messages["es-ES"]=this._messages.es,this._messages["fr-FR"]=this._messages.fr,this._messages["tr-TR"]=this._messages.tr,this._messages["et-EE"]=this._messages.et,this._messages["ar-IQ"]=this._messages.ar,this._messages["zh-CN"]=this._messages.zh}}])}($t),Qt=function(t){function e(){return c(this,e),n(this,e,arguments)}return f(e,t),u(e,[{key:"name",get:function(){return"sources"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"bindEvents",value:function(){this.listenTo(this.core,ct.CORE_CONTAINERS_CREATED,this.onContainersCreated)}},{key:"onContainersCreated",value:function(){var t=this.core.containers.filter((function(t){return"no_op"!==t.playback.name}))[0]||this.core.containers[0];t&&this.core.containers.forEach((function(e){e!==t&&e.destroy()}))}}])}($t);Mt.registerPlugin(Xt),Mt.registerPlugin(Qt),Mt.registerPlayback(qt),Mt.registerPlayback(zt),Mt.registerPlayback(Wt),Mt.registerPlayback(jt);var Zt={Player:Bt,Events:ct,Browser:D,ContainerPlugin:Ut,UIContainerPlugin:Gt,CorePlugin:$t,UICorePlugin:_t,Playback:Rt,Container:Lt,Core:wt,PlayerError:kt,Loader:Mt,BaseObject:ht,UIObject:bt,Utils:Z,HTML5Audio:Wt,HTML5Video:jt,HTMLImg:zt,Log:rt,Styler:Et,version:"0.11.1",template:At,$:S};function Jt(t,e,i){return e=ae(e),le(t,te()?Reflect.construct(e,i||[],ae(t).constructor):e.apply(t,i))}function te(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(te=function(){return!!t})()}function ee(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function ie(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ne(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ee(n.key),n)}}function re(t,e,i){return e&&ne(t.prototype,e),i&&ne(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function se(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&oe(t,e)}function ae(t){return ae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ae(t)}function oe(t,e){return oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},oe(t,e)}function le(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ce(){return ce="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=ae(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},ce.apply(this,arguments)}var he=function(t){function e(t){return ie(this,e),Jt(this,e,[t])}return se(e,t),re(e,[{key:"name",get:function(){return"click_to_pause"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"config",get:function(){return this.container.options.clickToPauseConfig||{}}},{key:"bindEvents",value:function(){this.listenTo(this.container,ct.CONTAINER_CLICK,this.click),this.listenTo(this.container,ct.CONTAINER_SETTINGSUPDATE,this.settingsUpdate)}},{key:"click",value:function(){var t=this.config.onClickPayload;(this.container.getPlaybackType()!==Rt.LIVE||this.container.isDvrEnabled())&&(this.container.isPlaying()?this.container.pause(t):this.container.play(t))}},{key:"settingsUpdate",value:function(){var t=this.container.getPlaybackType()!==Rt.LIVE||this.container.isDvrEnabled();if(t!==this.pointerEnabled){var e=t?"addClass":"removeClass";this.container.$el[e]("pointer-enabled"),this.pointerEnabled=t}}}])}(Ut),ue=function(t){function e(t){var i;ie(this,e),i=Jt(this,e,[t]);var n=t.options.closedCaptionsConfig;return i._title=n&&n.title?n.title:null,i._ariaLabel=n&&n.ariaLabel?n.ariaLabel:"cc-button",i._labelCb=n&&n.labelCallback&&"function"==typeof n.labelCallback?n.labelCallback:function(t){return t.name},i}return se(e,t),re(e,[{key:"name",get:function(){return"closed_captions"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"template",get:function(){return At('<button type="button" class="cc-button media-control-button media-control-icon" data-cc-button aria-label="<%= ariaLabel %>"></button>\n<ul>\n <% if (title) { %>\n <li data-title><%= title %></li>\n <% }; %>\n <li><a href="#" data-cc-select="-1"><%= disabledLabel %></a></li>\n <% for (var i = 0; i < tracks.length; i++) { %>\n <li><a href="#" data-cc-select="<%= tracks[i].id %>"><%= tracks[i].label %></a></li>\n <% }; %>\n</ul>\n')}},{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,ct.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged),this.listenTo(this.core.mediaControl,ct.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,ct.MEDIACONTROL_HIDE,this.hideContextMenu),this.bindContainerEvents()}},{key:"bindContainerEvents",value:function(){this.container=this.core.activeContainer,this.container&&(this.listenTo(this.container,ct.CONTAINER_SUBTITLE_AVAILABLE,this.onSubtitleAvailable),this.listenTo(this.container,ct.CONTAINER_SUBTITLE_CHANGED,this.onSubtitleChanged),this.listenTo(this.container,ct.CONTAINER_STOP,this.onContainerStop))}},{key:"onContainerStop",value:function(){this.ccAvailable(!1)}},{key:"containerChanged",value:function(){this.ccAvailable(!1),this.stopListening(),this.bindEvents()}},{key:"onSubtitleAvailable",value:function(){this.renderCcButton(),this.ccAvailable(!0)}},{key:"onSubtitleChanged",value:function(t){this.setCurrentContextMenuElement(t.id)}},{key:"onTrackSelect",value:function(t){var e=parseInt(t.target.dataset.ccSelect,10);return this.container.closedCaptionsTrackId=e,this.hideContextMenu(),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"+(isNaN(t)?"":'[data-cc-select="'+t+'"]')).parent()}},{key:"setCurrentContextMenuElement",value:function(t){if(this._trackId!==t){this.contextMenuElement().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;e<t.length;e++)t[e].label=this._labelCb(t[e]);var i=Et.getStyleFor(".cc-controls[data-cc-controls] {\n float: right;\n position: relative;\n display: none; }\n .cc-controls[data-cc-controls].available {\n display: block; }\n .cc-controls[data-cc-controls] .cc-button {\n padding: 6px !important; }\n .cc-controls[data-cc-controls] .cc-button.enabled {\n display: block;\n opacity: 1.0; }\n .cc-controls[data-cc-controls] .cc-button.enabled:hover {\n opacity: 1.0;\n text-shadow: none; }\n .cc-controls[data-cc-controls] > ul {\n list-style-type: none;\n position: absolute;\n bottom: 25px;\n border: 1px solid black;\n display: none;\n background-color: #e6e6e6; }\n .cc-controls[data-cc-controls] li {\n font-size: 10px; }\n .cc-controls[data-cc-controls] li[data-title] {\n background-color: #c3c2c2;\n padding: 5px; }\n .cc-controls[data-cc-controls] li a {\n color: #444;\n padding: 2px 10px;\n display: block;\n text-decoration: none; }\n .cc-controls[data-cc-controls] li a:hover {\n background-color: #555;\n color: white; }\n .cc-controls[data-cc-controls] li a:hover a {\n color: white;\n text-decoration: none; }\n .cc-controls[data-cc-controls] li.current a {\n color: #f00; }\n",{baseUrl:this.options.baseUrl});this.$el.html(this.template({ariaLabel:this._ariaLabel,disabledLabel:this.core.i18n.t("disabled"),title:this._title,tracks:t})),this.$ccButton=this.$el.find("button.cc-button[data-cc-button]"),this.$ccButton.append('<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t viewBox="0 0 49 41.8" style="enable-background:new 0 0 49 41.8;" xml:space="preserve">\n<path d="M47.1,0H3.2C1.6,0,0,1.2,0,2.8v31.5C0,35.9,1.6,37,3.2,37h11.9l3.2,1.9l4.7,2.7c0.9,0.5,2-0.1,2-1.1V37h22.1\n\tc1.6,0,1.9-1.1,1.9-2.7V2.8C49,1.2,48.7,0,47.1,0z M7.2,18.6c0-4.8,3.5-9.3,9.9-9.3c4.8,0,7.1,2.7,7.1,2.7l-2.5,4\n\tc0,0-1.7-1.7-4.2-1.7c-2.8,0-4.3,2.1-4.3,4.3c0,2.1,1.5,4.4,4.5,4.4c2.5,0,4.9-2.1,4.9-2.1l2.2,4.2c0,0-2.7,2.9-7.6,2.9\n\tC10.8,27.9,7.2,23.5,7.2,18.6z M36.9,27.9c-6.4,0-9.9-4.4-9.9-9.3c0-4.8,3.5-9.3,9.9-9.3C41.7,9.3,44,12,44,12l-2.5,4\n\tc0,0-1.7-1.7-4.2-1.7c-2.8,0-4.3,2.1-4.3,4.3c0,2.1,1.5,4.4,4.5,4.4c2.5,0,4.9-2.1,4.9-2.1l2.2,4.2C44.5,25,41.9,27.9,36.9,27.9z"/>\n</svg>'),this.$el.append(i[0])}},{key:"render",value:function(){this.renderCcButton();var t=this.core.mediaControl.$el.find("button[data-fullscreen]");return t[0]?this.$el.insertAfter(t):this.core.mediaControl.$el.find(".media-control-right-panel[data-media-control]").prepend(this.$el),this}}])}(_t),de=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).settingsUpdate(),i}return se(e,t),re(e,[{key:"template",get:function(){return At('<div class="live-info"><%= live %></div>\n<button type="button" class="live-button" aria-label="<%= backToLive %>"><%= backToLive %></button>\n')}},{key:"name",get:function(){return"dvr_controls"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"events",get:function(){return{"click .live-button":"click"}}},{key:"attributes",get:function(){return{class:"dvr-controls","data-dvr-controls":""}}},{key:"bindEvents",value:function(){this.bindCoreEvents(),this.bindContainerEvents()}},{key:"bindCoreEvents",value:function(){var t=this;this.core.mediaControl.settings?(this.listenTo(this.core.mediaControl,ct.MEDIACONTROL_CONTAINERCHANGED,this.containerChanged),this.listenTo(this.core.mediaControl,ct.MEDIACONTROL_RENDERED,this.settingsUpdate),this.listenTo(this.core,ct.CORE_OPTIONS_CHANGE,this.render)):setTimeout((function(){return t.bindCoreEvents()}),100)}},{key:"bindContainerEvents",value:function(){this.core.activeContainer&&(this.listenToOnce(this.core.activeContainer,ct.CONTAINER_TIMEUPDATE,this.render),this.listenTo(this.core.activeContainer,ct.CONTAINER_PLAYBACKDVRSTATECHANGED,this.dvrChanged))}},{key:"containerChanged",value:function(){this.stopListening(),this.bindEvents()}},{key:"dvrChanged",value:function(t){this.core.getPlaybackType()===Rt.LIVE&&(this.settingsUpdate(),this.core.mediaControl.$el.addClass("live"),t?(this.core.mediaControl.$el.addClass("dvr"),this.core.mediaControl.$el.find(".media-control-indicator[data-position], .media-control-indicator[data-duration]").hide()):this.core.mediaControl.$el.removeClass("dvr"))}},{key:"click",value:function(){var t=this.core.mediaControl,e=t.container;e.isPlaying()||e.play(),t.$el.hasClass("dvr")&&e.seek(e.getDuration())}},{key:"settingsUpdate",value:function(){var t=this;this.stopListening(),this.core.mediaControl.$el.removeClass("live"),this.shouldRender()&&(this.render(),this.$el.click((function(){return t.click()}))),this.bindEvents()}},{key:"shouldRender",value:function(){return(void 0===this.core.options.useDvrControls||!!this.core.options.useDvrControls)&&this.core.getPlaybackType()===Rt.LIVE}},{key:"render",value:function(){var t=Et.getStyleFor('.dvr-controls[data-dvr-controls] {\n display: inline-block;\n float: left;\n color: #fff;\n line-height: 32px;\n font-size: 10px;\n font-weight: bold;\n margin-left: 6px; }\n .dvr-controls[data-dvr-controls] .live-info {\n cursor: default;\n font-family: "Roboto", "Open Sans", Arial, sans-serif;\n text-transform: uppercase; }\n .dvr-controls[data-dvr-controls] .live-info:before {\n content: "";\n display: inline-block;\n position: relative;\n width: 7px;\n height: 7px;\n border-radius: 3.5px;\n margin-right: 3.5px;\n background-color: #ff0101; }\n .dvr-controls[data-dvr-controls] .live-info.disabled {\n opacity: 0.3; }\n .dvr-controls[data-dvr-controls] .live-info.disabled:before {\n background-color: #fff; }\n .dvr-controls[data-dvr-controls] .live-button {\n cursor: pointer;\n outline: none;\n display: none;\n border: 0;\n color: #fff;\n background-color: transparent;\n height: 32px;\n padding: 0;\n opacity: 0.7;\n font-family: "Roboto", "Open Sans", Arial, sans-serif;\n text-transform: uppercase;\n transition: all 0.1s ease; }\n .dvr-controls[data-dvr-controls] .live-button:before {\n content: "";\n display: inline-block;\n position: relative;\n width: 7px;\n height: 7px;\n border-radius: 3.5px;\n margin-right: 3.5px;\n background-color: #fff; }\n .dvr-controls[data-dvr-controls] .live-button:hover {\n opacity: 1;\n text-shadow: rgba(255, 255, 255, 0.75) 0 0 5px; }\n\n.dvr .dvr-controls[data-dvr-controls] .live-info {\n display: none; }\n\n.dvr .dvr-controls[data-dvr-controls] .live-button {\n display: block; }\n\n.dvr.media-control.live[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] .bar-fill-2[data-seekbar] {\n background-color: #005aff; }\n\n.media-control.live[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] .bar-fill-2[data-seekbar] {\n background-color: #ff0101; }\n',{baseUrl:this.options.baseUrl});return this.$el.html(this.template({live:this.core.i18n.t("live"),backToLive:this.core.i18n.t("back_to_live")})),this.$el.append(t[0]),this.shouldRender()&&(this.core.mediaControl.$el.addClass("live"),this.core.mediaControl.$(".media-control-left-panel[data-media-control]").append(this.$el)),this}}])}(_t),fe=function(t){function e(){return ie(this,e),Jt(this,e,arguments)}return se(e,t),re(e,[{key:"name",get:function(){return"end_video"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"bindEvents",value:function(){this.listenTo(this.core,ct.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged);var t=this.core.activeContainer;t&&(this.listenTo(t,ct.CONTAINER_ENDED,this.ended),this.listenTo(t,ct.CONTAINER_STOP,this.ended))}},{key:"containerChanged",value:function(){this.stopListening(),this.bindEvents()}},{key:"ended",value:function(){(void 0===this.core.options.exitFullscreenOnEnd||this.core.options.exitFullscreenOnEnd)&&this.core.isFullscreen()&&this.core.toggleFullscreen()}}])}($t),ge=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).options.disableErrorScreen?le(i,i.disable()):i}return se(e,t),re(e,[{key:"name",get:function(){return"error_screen"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"template",get:function(){return At('<div class="player-error-screen__content" data-error-screen>\n <% if (icon) { %>\n <div class="player-error-screen__icon" data-error-screen><%= icon %></div>\n <% } %>\n <div class="player-error-screen__title" data-error-screen><%= title %></div>\n <div class="player-error-screen__message" data-error-screen><%= message %></div>\n <div class="player-error-screen__code" data-error-screen>Error code: <%= code %></div>\n <div class="player-error-screen__reload" data-error-screen><%= reloadIcon %></div>\n</div>\n')}},{key:"container",get:function(){return this.core.getCurrentContainer()}},{key:"attributes",get:function(){return{class:"player-error-screen","data-error-screen":""}}},{key:"bindEvents",value:function(){this.listenTo(this.core,ct.ERROR,this.onError),this.listenTo(this.core,ct.CORE_ACTIVE_CONTAINER_CHANGED,this.onContainerChanged)}},{key:"bindReload",value:function(){this.reloadButton=this.$el.find(".player-error-screen__reload"),this.reloadButton&&this.reloadButton.on("click",this.reload.bind(this))}},{key:"reload",value:function(){var t=this;this.listenToOnce(this.core,ct.CORE_READY,(function(){return t.container.play()})),this.core.load(this.options.sources,this.options.mimeType),this.unbindReload()}},{key:"unbindReload",value:function(){this.reloadButton&&this.reloadButton.off("click")}},{key:"onContainerChanged",value:function(){this.err=null,this.unbindReload(),this.hide()}},{key:"onError",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.level===kt.Levels.FATAL&&(this.err=t,this.container.disableMediaControl(),this.container.stop(),this.show())}},{key:"show",value:function(){this.render(),this.$el.show()}},{key:"hide",value:function(){this.$el.hide()}},{key:"render",value:function(){if(this.err){var t=Et.getStyleFor("[data-player] .player-error-screen {\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n color: #CCCACA;\n position: absolute;\n top: 0;\n height: 100%;\n width: 100%;\n background-color: rgba(0, 0, 0, 0.7);\n z-index: 2000;\n display: flex;\n flex-direction: column;\n justify-content: center; }\n [data-player] .player-error-screen__content[data-error-screen] {\n font-size: 14px;\n color: #CCCACA;\n margin-top: 45px; }\n [data-player] .player-error-screen__title[data-error-screen] {\n font-weight: bold;\n line-height: 30px;\n font-size: 18px; }\n [data-player] .player-error-screen__message[data-error-screen] {\n width: 90%;\n margin: 0 auto; }\n [data-player] .player-error-screen__code[data-error-screen] {\n font-size: 13px;\n margin-top: 15px; }\n [data-player] .player-error-screen__reload {\n cursor: pointer;\n width: 30px;\n margin: 15px auto 0 !important; }\n",{baseUrl:this.options.baseUrl});return this.$el.html(this.template({title:this.err.UI.title,message:this.err.UI.message,code:this.err.code,icon:this.err.UI.icon||"",reloadIcon:'<svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">\n <path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/>\n <path d="M0 0h24v24H0z" fill="none"/>\n</svg>'})),this.$el.append(t[0]),this.core.$el.append(this.el),this.bindReload(),this}}}])}(_t),pe='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill="#010101" d="M1.425.35L14.575 8l-13.15 7.65V.35z"/>\n</svg>',me='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill-rule="evenodd" clip-rule="evenodd" fill="#010101" d="M1.712 14.76H6.43V1.24H1.71v13.52zm7.86-13.52v13.52h4.716V1.24H9.573z"/>\n</svg>',ve=S('link[rel="shortcut icon"]'),ye=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t]))._container=null,i.configure(),i}return se(e,t),re(e,[{key:"name",get:function(){return"favicon"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"oldIcon",get:function(){return ve}},{key:"configure",value:function(){this.core.options.changeFavicon?this.enabled||(this.stopListening(this.core,ct.CORE_OPTIONS_CHANGE),this.enable()):this.enabled&&(this.disable(),this.listenTo(this.core,ct.CORE_OPTIONS_CHANGE,this.configure))}},{key:"bindEvents",value:function(){this.listenTo(this.core,ct.CORE_OPTIONS_CHANGE,this.configure),this.listenTo(this.core,ct.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged),this.core.activeContainer&&this.containerChanged()}},{key:"containerChanged",value:function(){this._container&&this.stopListening(this._container),this._container=this.core.activeContainer,this.listenTo(this._container,ct.CONTAINER_PLAY,this.setPlayIcon),this.listenTo(this._container,ct.CONTAINER_PAUSE,this.setPauseIcon),this.listenTo(this._container,ct.CONTAINER_STOP,this.resetIcon),this.listenTo(this._container,ct.CONTAINER_ENDED,this.resetIcon),this.listenTo(this._container,ct.CONTAINER_ERROR,this.resetIcon),this.resetIcon()}},{key:"disable",value:function(){ce(ae(e.prototype),"disable",this).call(this),this.resetIcon()}},{key:"destroy",value:function(){ce(ae(e.prototype),"destroy",this).call(this),this.resetIcon()}},{key:"createIcon",value:function(t){var e=S("<canvas/>");e[0].width=16,e[0].height=16;var i=e[0].getContext("2d");i.fillStyle="#000";var n=S(t).find("path").attr("d"),r=new Path2D(n);i.fill(r);var s=S('<link rel="shortcut icon" type="image/png"/>');return s.attr("href",e[0].toDataURL("image/png")),s}},{key:"setPlayIcon",value:function(){this.playIcon||(this.playIcon=this.createIcon(pe)),this.changeIcon(this.playIcon)}},{key:"setPauseIcon",value:function(){this.pauseIcon||(this.pauseIcon=this.createIcon(me)),this.changeIcon(this.pauseIcon)}},{key:"resetIcon",value:function(){S('link[rel="shortcut icon"]').remove(),S("head").append(this.oldIcon)}},{key:"changeIcon",value:function(t){t&&(S('link[rel="shortcut icon"]').remove(),S("head").append(t))}}])}($t),Ae=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).container.options.gaAccount&&(i.account=i.container.options.gaAccount,i.trackerName=i.container.options.gaTrackerName?i.container.options.gaTrackerName+".":"Clappr.",i.domainName=i.container.options.gaDomainName,i.currentHDState=void 0,i.embedScript()),i}return se(e,t),re(e,[{key:"name",get:function(){return"google_analytics"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"embedScript",value:function(){var t=this;if(window._gat)this.addEventListeners();else{var e=document.createElement("script");e.setAttribute("type","text/javascript"),e.setAttribute("async","async"),e.setAttribute("src","//www.google-analytics.com/ga.js"),e.onload=function(){return t.addEventListeners()},document.body.appendChild(e)}}},{key:"addEventListeners",value:function(){var t=this;this.container&&(this.listenTo(this.container,ct.CONTAINER_READY,this.onReady),this.listenTo(this.container,ct.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ct.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ct.CONTAINER_PAUSE,this.onPause),this.listenTo(this.container,ct.CONTAINER_ENDED,this.onEnded),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERING,this.onBuffering),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERFULL,this.onBufferFull),this.listenTo(this.container,ct.CONTAINER_ERROR,this.onError),this.listenTo(this.container,ct.CONTAINER_PLAYBACKSTATE,this.onPlaybackChanged),this.listenTo(this.container,ct.CONTAINER_VOLUME,(function(e){return t.onVolumeChanged(e)})),this.listenTo(this.container,ct.CONTAINER_SEEK,(function(e){return t.onSeek(e)})),this.listenTo(this.container,ct.CONTAINER_FULL_SCREEN,this.onFullscreen),this.listenTo(this.container,ct.CONTAINER_HIGHDEFINITIONUPDATE,this.onHD),this.listenTo(this.container,ct.CONTAINER_PLAYBACKDVRSTATECHANGED,this.onDVR)),_gaq.push([this.trackerName+"_setAccount",this.account]),this.domainName&&_gaq.push([this.trackerName+"_setDomainName",this.domainName])}},{key:"onReady",value:function(){this.push(["Video","Playback",this.container.playback.name])}},{key:"onPlay",value:function(){this.push(["Video","Play",this.container.playback.src])}},{key:"onStop",value:function(){this.push(["Video","Stop",this.container.playback.src])}},{key:"onEnded",value:function(){this.push(["Video","Ended",this.container.playback.src])}},{key:"onBuffering",value:function(){this.push(["Video","Buffering",this.container.playback.src])}},{key:"onBufferFull",value:function(){this.push(["Video","Bufferfull",this.container.playback.src])}},{key:"onError",value:function(){this.push(["Video","Error",this.container.playback.src])}},{key:"onHD",value:function(t){var e=t?"ON":"OFF";e!==this.currentHDState&&(this.currentHDState=e,this.push(["Video","HD - "+e,this.container.playback.src]))}},{key:"onPlaybackChanged",value:function(t){null!==t.type&&this.push(["Video","Playback Type - "+t.type,this.container.playback.src])}},{key:"onDVR",value:function(t){var e=t?"ON":"OFF";this.push(["Interaction","DVR - "+e,this.container.playback.src])}},{key:"onPause",value:function(){this.push(["Video","Pause",this.container.playback.src])}},{key:"onSeek",value:function(){this.push(["Video","Seek",this.container.playback.src])}},{key:"onVolumeChanged",value:function(){this.push(["Interaction","Volume",this.container.playback.src])}},{key:"onFullscreen",value:function(){this.push(["Interaction","Fullscreen",this.container.playback.src])}},{key:"push",value:function(t){var e=[this.trackerName+"_trackEvent"].concat(t);_gaq.push(e)}}])}(Ut),Ee=function(t){this.element=t||window.document,this.initialize()};Ee.KEY_NAMES_BY_CODE={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"caps_lock",27:"esc",32:"space",37:"left",38:"up",39:"right",40:"down",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"},Ee.KEY_CODES_BY_NAME={},function(){for(var t in Ee.KEY_NAMES_BY_CODE)Object.prototype.hasOwnProperty.call(Ee.KEY_NAMES_BY_CODE,t)&&(Ee.KEY_CODES_BY_NAME[Ee.KEY_NAMES_BY_CODE[t]]=+t)}(),Ee.MODIFIERS=["shift","ctrl","alt"],Ee.registerEvent=document.addEventListener?function(t,e,i){t.addEventListener(e,i,!1)}:document.attachEvent?function(t,e,i){t.attachEvent("on"+e,i)}:void 0,Ee.unregisterEvent=document.removeEventListener?function(t,e,i){t.removeEventListener(e,i,!1)}:document.detachEvent?function(t,e,i){t.detachEvent("on"+e,i)}:void 0,Ee.stringContains=function(t,e){return-1!==t.indexOf(e)},Ee.neatString=function(t){return t.replace(/^\s+|\s+$/g,"").replace(/\s+/g," ")},Ee.capitalize=function(t){return t.toLowerCase().replace(/^./,(function(t){return t.toUpperCase()}))},Ee.isString=function(t){return Ee.stringContains(Object.prototype.toString.call(t),"String")},Ee.arrayIncludes=Array.prototype.indexOf?function(t,e){return-1!==t.indexOf(e)}:function(t,e){for(var i=0;i<t.length;i++)if(t[i]===e)return!0;return!1},Ee.extractModifiers=function(t){var e,i;for(e=[],i=0;i<Ee.MODIFIERS.length;i++)Ee.stringContains(t,Ee.MODIFIERS[i])&&e.push(Ee.MODIFIERS[i]);return e},Ee.extractKey=function(t){var e,i;for(e=Ee.neatString(t).split(" "),i=0;i<e.length;i++)if(!Ee.arrayIncludes(Ee.MODIFIERS,e[i]))return e[i]},Ee.modifiersAndKey=function(t){var e,i;return Ee.stringContains(t,"any")?Ee.neatString(t).split(" ").slice(0,2).join(" "):(e=Ee.extractModifiers(t),(i=Ee.extractKey(t))&&!Ee.arrayIncludes(Ee.MODIFIERS,i)&&e.push(i),e.join(" "))},Ee.keyName=function(t){return Ee.KEY_NAMES_BY_CODE[t+""]},Ee.keyCode=function(t){return+Ee.KEY_CODES_BY_NAME[t]},Ee.prototype.initialize=function(){var t,e=this;for(this.lastKeyCode=-1,this.lastModifiers={},t=0;t<Ee.MODIFIERS.length;t++)this.lastModifiers[Ee.MODIFIERS[t]]=!1;this.keysDown={any:[]},this.keysUp={any:[]},this.downHandler=this.handler("down"),this.upHandler=this.handler("up"),Ee.registerEvent(this.element,"keydown",this.downHandler),Ee.registerEvent(this.element,"keyup",this.upHandler),Ee.registerEvent(window,"unload",(function t(){Ee.unregisterEvent(e.element,"keydown",e.downHandler),Ee.unregisterEvent(e.element,"keyup",e.upHandler),Ee.unregisterEvent(window,"unload",t)}))},Ee.prototype.handler=function(t){var e=this;return function(i){var n,r,s;for(i=i||window.event,e.lastKeyCode=i.keyCode,n=0;n<Ee.MODIFIERS.length;n++)e.lastModifiers[Ee.MODIFIERS[n]]=i[Ee.MODIFIERS[n]+"Key"];for(Ee.arrayIncludes(Ee.MODIFIERS,Ee.keyName(e.lastKeyCode))&&(e.lastModifiers[Ee.keyName(e.lastKeyCode)]=!0),r=e["keys"+Ee.capitalize(t)],n=0;n<r.any.length;n++)!1===r.any[n](i)&&i.preventDefault&&i.preventDefault();if(r[s=e.lastModifiersAndKey()])for(n=0;n<r[s].length;n++)!1===r[s][n](i)&&i.preventDefault&&i.preventDefault()}},Ee.prototype.registerKeys=function(t,e,i){var n,r,s=this["keys"+Ee.capitalize(t)];for(Ee.isString(e)&&(e=[e]),n=0;n<e.length;n++)r=e[n],s[r=Ee.modifiersAndKey(r+"")]?s[r].push(i):s[r]=[i];return this},Ee.prototype.unregisterKeys=function(t,e,i){var n,r,s,a=this["keys"+Ee.capitalize(t)];for(Ee.isString(e)&&(e=[e]),n=0;n<e.length;n++)if(s=e[n],s=Ee.modifiersAndKey(s+""),null===i)delete a[s];else if(a[s])for(r=0;r<a[s].length;r++)if(String(a[s][r])===String(i)){a[s].splice(r,1);break}return this},Ee.prototype.off=function(t){return this.unregisterKeys("down",t,null)},Ee.prototype.delegate=function(t,e,i){return null!==i||void 0!==i?this.registerKeys(t,e,i):this.unregisterKeys(t,e,i)},Ee.prototype.down=function(t,e){return this.delegate("down",t,e)},Ee.prototype.up=function(t,e){return this.delegate("up",t,e)},Ee.prototype.lastKey=function(t){return t?this.lastModifiers[t]:Ee.keyName(this.lastKeyCode)},Ee.prototype.lastModifiersAndKey=function(){var t,e;for(t=[],e=0;e<Ee.MODIFIERS.length;e++)this.lastKey(Ee.MODIFIERS[e])&&t.push(Ee.MODIFIERS[e]);return Ee.arrayIncludes(t,this.lastKey())||t.push(this.lastKey()),t.join(" ")};var Te={Kibo:Ee},be='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill-rule="evenodd" clip-rule="evenodd" fill="#010101" d="M1.712 1.24h12.6v13.52h-12.6z"/>\n</svg>',ke='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill-rule="evenodd" clip-rule="evenodd" fill="#010101" d="M11.5 11h-.002v1.502L7.798 10H4.5V6h3.297l3.7-2.502V4.5h.003V11zM11 4.49L7.953 6.5H5v3h2.953L11 11.51V4.49z"/>\n</svg>',Se='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill="#010101" d="M7.156 8L4 11.156V8.5H3V13h4.5v-1H4.844L8 8.844 7.156 8zM8.5 3v1h2.657L8 7.157 8.846 8 12 4.844V7.5h1V3H8.5z"/>\n</svg>',_e=Z.Config,Le=Z.Fullscreen,Re=Z.formatTime,Ce=Z.extend,we=Z.removeArrayItem,Ie=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).persistConfig=i.options.persistConfig,i.currentPositionValue=null,i.currentDurationValue=null,i.keepVisible=!1,i.fullScreenOnVideoTagSupported=null,i.setInitialVolume(),i.settings={left:["play","stop","pause"],right:["volume"],default:["position","seekbar","duration"]},i.kibo=new Ee(i.options.focusElement),i.bindKeyEvents(),i.container?S.isEmptyObject(i.container.settings)||(i.settings=S.extend({},i.container.settings)):i.settings={},i.userDisabled=!1,(i.container&&i.container.mediaControlDisabled||i.options.chromeless)&&i.disable(),i.stopDragHandler=function(t){return i.stopDrag(t)},i.updateDragHandler=function(t){return i.updateDrag(t)},S(document).bind("mouseup",i.stopDragHandler),S(document).bind("mousemove",i.updateDragHandler),i}return se(e,t),re(e,[{key:"name",get:function(){return"media_control"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"disabled",get:function(){var t=this.container&&this.container.getPlaybackType()===Rt.NO_OP;return this.userDisabled||t}},{key:"container",get:function(){return this.core&&this.core.activeContainer}},{key:"playback",get:function(){return this.core&&this.core.activePlayback}},{key:"attributes",get:function(){return{class:"media-control","data-media-control":""}}},{key:"events",get:function(){return{"click [data-play]":"play","click [data-pause]":"pause","click [data-playpause]":"togglePlayPause","click [data-stop]":"stop","click [data-playstop]":"togglePlayStop","click [data-fullscreen]":"toggleFullscreen","click .bar-container[data-seekbar]":"seek","click .bar-container[data-volume]":"onVolumeClick","click .drawer-icon[data-volume]":"toggleMute","mouseenter .drawer-container[data-volume]":"showVolumeBar","mouseleave .drawer-container[data-volume]":"hideVolumeBar","mousedown .bar-container[data-volume]":"startVolumeDrag","mousemove .bar-container[data-volume]":"mousemoveOnVolumeBar","mousedown .bar-scrubber[data-seekbar]":"startSeekDrag","mousemove .bar-container[data-seekbar]":"mousemoveOnSeekBar","mouseleave .bar-container[data-seekbar]":"mouseleaveOnSeekBar","mouseenter .media-control-layer[data-controls]":"setUserKeepVisible","mouseleave .media-control-layer[data-controls]":"resetUserKeepVisible"}}},{key:"template",get:function(){return At('<div class="media-control-background" data-background></div>\n<div class="media-control-layer" data-controls>\n <% var renderBar = function(name) { %>\n <div class="bar-container" data-<%= name %>>\n <div class="bar-background" data-<%= name %>>\n <div class="bar-fill-1" data-<%= name %>></div>\n <div class="bar-fill-2" data-<%= name %>></div>\n <div class="bar-hover" data-<%= name %>></div>\n </div>\n <div class="bar-scrubber" data-<%= name %>>\n <div class="bar-scrubber-icon" data-<%= name %>></div>\n </div>\n </div>\n <% }; %>\n <% var renderSegmentedBar = function(name, segments) {\n segments = segments || 10; %>\n <div class="bar-container" data-<%= name %>>\n <% for (var i = 0; i < segments; i++) { %>\n <div class="segmented-bar-element" data-<%= name %>></div>\n <% } %>\n </div>\n <% }; %>\n <% var renderDrawer = function(name, renderContent) { %>\n <div class="drawer-container" data-<%= name %>>\n <div class="drawer-icon-container" data-<%= name %>>\n <div class="drawer-icon media-control-icon" data-<%= name %>></div>\n <span class="drawer-text" data-<%= name %>></span>\n </div>\n <% renderContent(name); %>\n </div>\n <% }; %>\n <% var renderIndicator = function(name) { %>\n <div class="media-control-indicator" data-<%= name %>></div>\n <% }; %>\n <% var renderButton = function(name) { %>\n <button type="button" class="media-control-button media-control-icon" data-<%= name %> aria-label="<%= name %>"></button>\n <% }; %>\n <% var templates = {\n bar: renderBar,\n segmentedBar: renderSegmentedBar,\n };\n var render = function(settingsList) {\n settingsList.forEach(function(setting) {\n if(setting === "seekbar") {\n renderBar(setting);\n } else if (setting === "volume") {\n renderDrawer(setting, settings.volumeBarTemplate ? templates[settings.volumeBarTemplate] : function(name) { return renderSegmentedBar(name); });\n } else if (setting === "duration" || setting === "position") {\n renderIndicator(setting);\n } else {\n renderButton(setting);\n }\n });\n }; %>\n <% if (settings.default && settings.default.length) { %>\n <div class="media-control-center-panel" data-media-control>\n <% render(settings.default); %>\n </div>\n <% } %>\n <% if (settings.left && settings.left.length) { %>\n <div class="media-control-left-panel" data-media-control>\n <% render(settings.left); %>\n </div>\n <% } %>\n <% if (settings.right && settings.right.length) { %>\n <div class="media-control-right-panel" data-media-control>\n <% render(settings.right); %>\n </div>\n <% } %>\n</div>\n')}},{key:"volume",get:function(){return this.container&&this.container.isReady?this.container.volume:this.intendedVolume}},{key:"muted",get:function(){return 0===this.volume}},{key:"getExternalInterface",value:function(){var t=this;return{setVolume:this.setVolume,getVolume:function(){return t.volume}}}},{key:"bindEvents",value:function(){var t=this;this.stopListening(),this.listenTo(this.core,ct.CORE_ACTIVE_CONTAINER_CHANGED,this.onActiveContainerChanged),this.listenTo(this.core,ct.CORE_MOUSE_MOVE,this.show),this.listenTo(this.core,ct.CORE_MOUSE_LEAVE,(function(){return t.hide(t.options.hideMediaControlDelay)})),this.listenTo(this.core,ct.CORE_FULLSCREEN,this.show),this.listenTo(this.core,ct.CORE_OPTIONS_CHANGE,this.configure),this.listenTo(this.core,ct.CORE_RESIZE,this.playerResize),this.bindContainerEvents()}},{key:"bindContainerEvents",value:function(){this.container&&(this.listenTo(this.container,ct.CONTAINER_PLAY,this.changeTogglePlay),this.listenTo(this.container,ct.CONTAINER_PAUSE,this.changeTogglePlay),this.listenTo(this.container,ct.CONTAINER_STOP,this.changeTogglePlay),this.listenTo(this.container,ct.CONTAINER_DBLCLICK,this.toggleFullscreen),this.listenTo(this.container,ct.CONTAINER_TIMEUPDATE,this.onTimeUpdate),this.listenTo(this.container,ct.CONTAINER_PROGRESS,this.updateProgressBar),this.listenTo(this.container,ct.CONTAINER_SETTINGSUPDATE,this.settingsUpdate),this.listenTo(this.container,ct.CONTAINER_PLAYBACKDVRSTATECHANGED,this.settingsUpdate),this.listenTo(this.container,ct.CONTAINER_HIGHDEFINITIONUPDATE,this.highDefinitionUpdate),this.listenTo(this.container,ct.CONTAINER_MEDIACONTROL_DISABLE,this.disable),this.listenTo(this.container,ct.CONTAINER_MEDIACONTROL_ENABLE,this.enable),this.listenTo(this.container,ct.CONTAINER_ENDED,this.ended),this.listenTo(this.container,ct.CONTAINER_VOLUME,this.onVolumeChanged),this.listenTo(this.container,ct.CONTAINER_OPTIONS_CHANGE,this.setInitialVolume),"video"===this.container.playback.el.nodeName.toLowerCase()&&this.listenToOnce(this.container,ct.CONTAINER_LOADEDMETADATA,this.onLoadedMetadataOnVideoTag))}},{key:"disable",value:function(){this.userDisabled=!0,this.hide(),this.unbindKeyEvents(),this.$el.hide()}},{key:"enable",value:function(){this.options.chromeless||(this.userDisabled=!1,this.bindKeyEvents(),this.show())}},{key:"play",value:function(){this.container&&this.container.play()}},{key:"pause",value:function(){this.container&&this.container.pause()}},{key:"stop",value:function(){this.container&&this.container.stop()}},{key:"setInitialVolume",value:function(){var t=this.persistConfig?_e.restore("volume"):100,e=this.container&&this.container.options||this.options;this.setVolume(e.mute?0:t,!0)}},{key:"onVolumeChanged",value:function(){this.updateVolumeUI()}},{key:"onLoadedMetadataOnVideoTag",value:function(){var t=this.playback&&this.playback.el;!Le.fullscreenEnabled()&&t.webkitSupportsFullscreen&&(this.fullScreenOnVideoTagSupported=!0,this.settingsUpdate())}},{key:"updateVolumeUI",value:function(){if(this.rendered){this.$volumeBarContainer.find(".bar-fill-2").css({});var t=this.$volumeBarContainer.width(),e=this.$volumeBarBackground.width(),i=(t-e)/2,n=e*this.volume/100+i;this.$volumeBarFill.css({width:"".concat(this.volume,"%")}),this.$volumeBarScrubber.css({left:n}),this.$volumeBarContainer.find(".segmented-bar-element").removeClass("fill");var r=Math.ceil(this.volume/10);this.$volumeBarContainer.find(".segmented-bar-element").slice(0,r).addClass("fill"),this.$volumeIcon.html(""),this.$volumeIcon.removeClass("muted"),this.muted?(this.$volumeIcon.append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill-rule="evenodd" clip-rule="evenodd" fill="#010101" d="M9.75 11.51L6.7 9.5H3.75v-3H6.7L9.75 4.49v.664l.497.498V3.498L6.547 6H3.248v4h3.296l3.7 2.502v-2.154l-.497.5v.662zm3-5.165L12.404 6l-1.655 1.653L9.093 6l-.346.345L10.402 8 8.747 9.654l.346.347 1.655-1.653L12.403 10l.348-.346L11.097 8l1.655-1.655z"/>\n</svg>'),this.$volumeIcon.addClass("muted")):this.$volumeIcon.append(ke),this.applyButtonStyle(this.$volumeIcon)}}},{key:"changeTogglePlay",value:function(){this.$playPauseToggle.html(""),this.$playStopToggle.html(""),this.container&&this.container.isPlaying()?(this.$playPauseToggle.append(me),this.$playStopToggle.append(be),this.trigger(ct.MEDIACONTROL_PLAYING)):(this.$playPauseToggle.append(pe),this.$playStopToggle.append(pe),this.trigger(ct.MEDIACONTROL_NOTPLAYING),D.isMobile&&this.show()),this.applyButtonStyle(this.$playPauseToggle),this.applyButtonStyle(this.$playStopToggle)}},{key:"mousemoveOnSeekBar",value:function(t){if(this.settings.seekEnabled){var e=t.pageX-this.$seekBarContainer.offset().left-this.$seekBarHover.width()/2;this.$seekBarHover.css({left:e})}this.trigger(ct.MEDIACONTROL_MOUSEMOVE_SEEKBAR,t)}},{key:"mouseleaveOnSeekBar",value:function(t){this.trigger(ct.MEDIACONTROL_MOUSELEAVE_SEEKBAR,t)}},{key:"onVolumeClick",value:function(t){this.setVolume(this.getVolumeFromUIEvent(t))}},{key:"mousemoveOnVolumeBar",value:function(t){this.draggingVolumeBar&&this.setVolume(this.getVolumeFromUIEvent(t))}},{key:"playerResize",value:function(t){this.$fullscreenToggle.html("");var e=this.core.isFullscreen()?'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill="#010101" d="M13.5 3.344l-.844-.844L9.5 5.656V3h-1v4.5H13v-1h-2.656L13.5 3.344zM3 9.5h2.656L2.5 12.656l.844.844L6.5 10.344V13h1V8.5H3v1z"/>\n</svg>':Se;this.$fullscreenToggle.append(e),this.applyButtonStyle(this.$fullscreenToggle),0!==this.$el.find(".media-control").length&&this.$el.removeClass("w320"),(t.width<=320||this.options.hideVolumeBar)&&this.$el.addClass("w320")}},{key:"togglePlayPause",value:function(){return this.container.isPlaying()?this.container.pause():this.container.play(),!1}},{key:"togglePlayStop",value:function(){this.container.isPlaying()?this.container.stop():this.container.play()}},{key:"startSeekDrag",value:function(t){this.settings.seekEnabled&&(this.draggingSeekBar=!0,this.$el.addClass("dragging"),this.$seekBarLoaded.addClass("media-control-notransition"),this.$seekBarPosition.addClass("media-control-notransition"),this.$seekBarScrubber.addClass("media-control-notransition"),t&&t.preventDefault())}},{key:"startVolumeDrag",value:function(t){this.draggingVolumeBar=!0,this.$el.addClass("dragging"),t&&t.preventDefault()}},{key:"stopDrag",value:function(t){this.draggingSeekBar&&this.seek(t),this.$el.removeClass("dragging"),this.$seekBarLoaded.removeClass("media-control-notransition"),this.$seekBarPosition.removeClass("media-control-notransition"),this.$seekBarScrubber.removeClass("media-control-notransition dragging"),this.draggingSeekBar=!1,this.draggingVolumeBar=!1}},{key:"updateDrag",value:function(t){if(this.draggingSeekBar){t.preventDefault();var e=(t.pageX-this.$seekBarContainer.offset().left)/this.$seekBarContainer.width()*100;e=Math.min(100,Math.max(e,0)),this.setSeekPercentage(e)}else this.draggingVolumeBar&&(t.preventDefault(),this.setVolume(this.getVolumeFromUIEvent(t)))}},{key:"getVolumeFromUIEvent",value:function(t){return(t.pageX-this.$volumeBarContainer.offset().left)/this.$volumeBarContainer.width()*100}},{key:"toggleMute",value:function(){this.setVolume(this.muted?100:0)}},{key:"setVolume",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t=Math.min(100,Math.max(t,0)),this.intendedVolume=t,this.persistConfig&&!i&&_e.persist("volume",t);var n=function(){e.container&&e.container.isReady?e.container.setVolume(t):e.listenToOnce(e.container,ct.CONTAINER_READY,(function(){e.container.setVolume(t)}))};this.container?n():this.listenToOnce(this,ct.MEDIACONTROL_CONTAINERCHANGED,(function(){return n()}))}},{key:"toggleFullscreen",value:function(){this.trigger(ct.MEDIACONTROL_FULLSCREEN,this.name),this.container.fullscreen(),this.core.toggleFullscreen(),this.resetUserKeepVisible()}},{key:"onActiveContainerChanged",value:function(){this.fullScreenOnVideoTagSupported=null,this.bindEvents(),this.setInitialVolume(),this.changeTogglePlay(),this.bindContainerEvents(),this.settingsUpdate(),this.container&&this.container.trigger(ct.CONTAINER_PLAYBACKDVRSTATECHANGED,this.container.isDvrInUse()),this.container&&this.container.mediaControlDisabled&&this.disable(),this.trigger(ct.MEDIACONTROL_CONTAINERCHANGED)}},{key:"showVolumeBar",value:function(){this.hideVolumeId&&clearTimeout(this.hideVolumeId),this.$volumeBarContainer.removeClass("volume-bar-hide")}},{key:"hideVolumeBar",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:400;this.$volumeBarContainer&&(this.draggingVolumeBar?this.hideVolumeId=setTimeout((function(){return t.hideVolumeBar()}),e):(this.hideVolumeId&&clearTimeout(this.hideVolumeId),this.hideVolumeId=setTimeout((function(){return t.$volumeBarContainer.addClass("volume-bar-hide")}),e)))}},{key:"ended",value:function(){this.changeTogglePlay()}},{key:"updateProgressBar",value:function(t){var e=t.start/t.total*100,i=t.current/t.total*100;this.$seekBarLoaded.css({left:"".concat(e,"%"),width:"".concat(i-e,"%")})}},{key:"onTimeUpdate",value:function(t){if(!this.draggingSeekBar){var e=t.current<0?t.total:t.current;this.currentPositionValue=e,this.currentDurationValue=t.total,this.renderSeekBar()}}},{key:"renderSeekBar",value:function(){if(null!==this.currentPositionValue&&null!==this.currentDurationValue){this.currentSeekBarPercentage=100,this.container&&(this.container.getPlaybackType()!==Rt.LIVE||this.container.isDvrInUse())&&(this.currentSeekBarPercentage=this.currentPositionValue/this.currentDurationValue*100),this.setSeekPercentage(this.currentSeekBarPercentage);var t=Re(this.currentPositionValue),e=Re(this.currentDurationValue);t!==this.displayedPosition&&(this.$position.text(t),this.displayedPosition=t),e!==this.displayedDuration&&(this.$duration.text(e),this.displayedDuration=e)}}},{key:"seek",value:function(t){if(this.settings.seekEnabled){var e=(t.pageX-this.$seekBarContainer.offset().left)/this.$seekBarContainer.width()*100;return e=Math.min(100,Math.max(e,0)),this.container&&this.container.seekPercentage(e),this.setSeekPercentage(e),!1}}},{key:"setKeepVisible",value:function(){this.keepVisible=!0}},{key:"resetKeepVisible",value:function(){this.keepVisible=!1}},{key:"setUserKeepVisible",value:function(){this.userKeepVisible=!0}},{key:"resetUserKeepVisible",value:function(){this.userKeepVisible=!1}},{key:"isVisible",value:function(){return!this.$el.hasClass("media-control-hide")}},{key:"show",value:function(t){var e=this;if(!this.disabled){var i=t&&t.clientX!==this.lastMouseX&&t.clientY!==this.lastMouseY;(!t||i||navigator.userAgent.match(/firefox/i))&&(clearTimeout(this.hideId),this.$el.show(),this.trigger(ct.MEDIACONTROL_SHOW,this.name),this.container&&this.container.trigger(ct.CONTAINER_MEDIACONTROL_SHOW,this.name),this.$el.removeClass("media-control-hide"),this.hideId=setTimeout((function(){return e.hide()}),2e3),t&&(this.lastMouseX=t.clientX,this.lastMouseY=t.clientY));this.updateCursorStyle(!0)}}},{key:"hide",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this.isVisible()){var i=e||2e3;if(clearTimeout(this.hideId),this.disabled||!1!==this.options.hideMediaControl){var n=this.userKeepVisible||this.keepVisible,r=this.draggingSeekBar||this.draggingVolumeBar;if(!this.disabled&&(e||n||r))this.hideId=setTimeout((function(){return t.hide()}),i);else{this.trigger(ct.MEDIACONTROL_HIDE,this.name),this.container&&this.container.trigger(ct.CONTAINER_MEDIACONTROL_HIDE,this.name),this.$el.addClass("media-control-hide"),this.hideVolumeBar(0);this.updateCursorStyle(!1)}}}}},{key:"updateCursorStyle",value:function(t){t?this.core.$el.removeClass("nocursor"):this.core.isFullscreen()&&this.core.$el.addClass("nocursor")}},{key:"settingsUpdate",value:function(){var t=this.getSettings();!t||this.fullScreenOnVideoTagSupported||Le.fullscreenEnabled()||(t.default&&we(t.default,"fullscreen"),t.left&&we(t.left,"fullscreen"),t.right&&we(t.right,"fullscreen")),JSON.stringify(this.settings)!==JSON.stringify(t)&&(this.settings=t,this.render())}},{key:"getSettings",value:function(){return S.extend(!0,{},this.container&&this.container.settings)}},{key:"highDefinitionUpdate",value:function(t){this.isHD=t;var e=t?"addClass":"removeClass";this.$hdIndicator[e]("enabled")}},{key:"createCachedElements",value:function(){var t=this.$el.find(".media-control-layer");this.$duration=t.find(".media-control-indicator[data-duration]"),this.$fullscreenToggle=t.find("button.media-control-button[data-fullscreen]"),this.$playPauseToggle=t.find("button.media-control-button[data-playpause]"),this.$playStopToggle=t.find("button.media-control-button[data-playstop]"),this.$position=t.find(".media-control-indicator[data-position]"),this.$seekBarContainer=t.find(".bar-container[data-seekbar]"),this.$seekBarHover=t.find(".bar-hover[data-seekbar]"),this.$seekBarLoaded=t.find(".bar-fill-1[data-seekbar]"),this.$seekBarPosition=t.find(".bar-fill-2[data-seekbar]"),this.$seekBarScrubber=t.find(".bar-scrubber[data-seekbar]"),this.$volumeBarContainer=t.find(".bar-container[data-volume]"),this.$volumeContainer=t.find(".drawer-container[data-volume]"),this.$volumeIcon=t.find(".drawer-icon[data-volume]"),this.$volumeBarBackground=this.$el.find(".bar-background[data-volume]"),this.$volumeBarFill=this.$el.find(".bar-fill-1[data-volume]"),this.$volumeBarScrubber=this.$el.find(".bar-scrubber[data-volume]"),this.$hdIndicator=this.$el.find("button.media-control-button[data-hd-indicator]"),this.resetIndicators(),this.initializeIcons()}},{key:"resetIndicators",value:function(){this.displayedPosition=this.$position.text(),this.displayedDuration=this.$duration.text()}},{key:"initializeIcons",value:function(){var t=this.$el.find(".media-control-layer");t.find("button.media-control-button[data-play]").append(pe),t.find("button.media-control-button[data-pause]").append(me),t.find("button.media-control-button[data-stop]").append(be),this.$playPauseToggle.append(pe),this.$playStopToggle.append(pe),this.$volumeIcon.append(ke),this.$fullscreenToggle.append(Se),this.$hdIndicator.append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill="#010101" d="M5.375 7.062H2.637V4.26H.502v7.488h2.135V8.9h2.738v2.848h2.133V4.26H5.375v2.802zm5.97-2.81h-2.84v7.496h2.798c2.65 0 4.195-1.607 4.195-3.77v-.022c0-2.162-1.523-3.704-4.154-3.704zm2.06 3.758c0 1.21-.81 1.896-2.03 1.896h-.83V6.093h.83c1.22 0 2.03.696 2.03 1.896v.02z"/>\n</svg>')}},{key:"setSeekPercentage",value:function(t){t=Math.max(Math.min(t,100),0),this.displayedSeekBarPercentage!==t&&(this.displayedSeekBarPercentage=t,this.$seekBarPosition.removeClass("media-control-notransition"),this.$seekBarScrubber.removeClass("media-control-notransition"),this.$seekBarPosition.css({width:"".concat(t,"%")}),this.$seekBarScrubber.css({left:"".concat(t,"%")}))}},{key:"seekRelative",value:function(t){if(this.settings.seekEnabled){var e=this.container.getCurrentTime(),i=this.container.getDuration(),n=Math.min(Math.max(e+t,0),i);n=Math.min(100*n/i,100),this.container.seekPercentage(n)}}},{key:"bindKeyAndShow",value:function(t,e){var i=this;this.kibo.down(t,(function(){return i.show(),e()}))}},{key:"bindKeyEvents",value:function(){var t=this;if(!D.isMobile&&!this.options.disableKeyboardShortcuts){this.unbindKeyEvents(),this.kibo=new Ee(this.options.focusElement||this.options.parentElement),this.bindKeyAndShow("space",(function(){return t.togglePlayPause()})),this.bindKeyAndShow("left",(function(){return t.seekRelative(-5)})),this.bindKeyAndShow("right",(function(){return t.seekRelative(5)})),this.bindKeyAndShow("shift left",(function(){return t.seekRelative(-10)})),this.bindKeyAndShow("shift right",(function(){return t.seekRelative(10)})),this.bindKeyAndShow("shift ctrl left",(function(){return t.seekRelative(-15)})),this.bindKeyAndShow("shift ctrl right",(function(){return t.seekRelative(15)}));["1","2","3","4","5","6","7","8","9","0"].forEach((function(e){t.bindKeyAndShow(e,(function(){t.settings.seekEnabled&&t.container&&t.container.seekPercentage(10*e)}))}))}}},{key:"unbindKeyEvents",value:function(){this.kibo&&(this.kibo.off("space"),this.kibo.off("left"),this.kibo.off("right"),this.kibo.off("shift left"),this.kibo.off("shift right"),this.kibo.off("shift ctrl left"),this.kibo.off("shift ctrl right"),this.kibo.off(["1","2","3","4","5","6","7","8","9","0"]))}},{key:"parseColors",value:function(){if(this.options.mediacontrol){this.buttonsColor=this.options.mediacontrol.buttons;var t=this.options.mediacontrol.seekbar;this.$el.find(".bar-fill-2[data-seekbar]").css("background-color",t),this.$el.find(".media-control-icon svg path").css("fill",this.buttonsColor),this.$el.find(".segmented-bar-element[data-volume]").css("boxShadow","inset 2px 0 0 "+this.buttonsColor)}}},{key:"applyButtonStyle",value:function(t){this.buttonsColor&&t&&S(t).find("svg path").css("fill",this.buttonsColor)}},{key:"destroy",value:function(){S(document).unbind("mouseup",this.stopDragHandler),S(document).unbind("mousemove",this.updateDragHandler),this.unbindKeyEvents(),this.stopListening(),ce(ae(e.prototype),"destroy",this).call(this)}},{key:"configure",value:function(t){this.options.chromeless||t.source||t.sources?this.disable():this.enable(),this.trigger(ct.MEDIACONTROL_OPTIONS_CHANGE)}},{key:"render",value:function(){var t=this,e=this.options.hideMediaControlDelay||2e3;this.settings&&this.$el.html(this.template({settings:this.settings}));var i=Et.getStyleFor('.media-control-notransition {\n transition: none !important; }\n\n.media-control[data-media-control] {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 9999;\n pointer-events: none; }\n .media-control[data-media-control].dragging {\n pointer-events: auto;\n cursor: grabbing !important;\n cursor: url("closed-hand.cur"), move; }\n .media-control[data-media-control].dragging * {\n cursor: grabbing !important;\n cursor: url("closed-hand.cur"), move; }\n .media-control[data-media-control] .media-control-background[data-background] {\n position: absolute;\n height: 40%;\n width: 100%;\n bottom: 0;\n background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));\n will-change: transform, opacity;\n transition: opacity 0.6s ease-out; }\n .media-control[data-media-control] .media-control-icon {\n line-height: 0;\n letter-spacing: 0;\n speak: none;\n color: #fff;\n opacity: 0.5;\n vertical-align: middle;\n text-align: left;\n transition: all 0.1s ease; }\n .media-control[data-media-control] .media-control-icon:hover {\n color: white;\n opacity: 0.75;\n text-shadow: rgba(255, 255, 255, 0.8) 0 0 5px; }\n .media-control[data-media-control].media-control-hide .media-control-background[data-background] {\n opacity: 0; }\n .media-control[data-media-control].media-control-hide .media-control-layer[data-controls] {\n transform: translateY(50px); }\n .media-control[data-media-control].media-control-hide .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-scrubber[data-seekbar] {\n opacity: 0; }\n .media-control[data-media-control] .media-control-layer[data-controls] {\n position: absolute;\n transform: translateY(-7px);\n bottom: 0;\n width: 100%;\n height: 32px;\n font-size: 0;\n vertical-align: middle;\n pointer-events: auto;\n transition: bottom 0.4s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-left-panel[data-media-control] {\n position: absolute;\n top: 0;\n left: 4px;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-center-panel[data-media-control] {\n height: 100%;\n text-align: center;\n line-height: 32px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-right-panel[data-media-control] {\n position: absolute;\n top: 0;\n right: 4px;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button {\n background-color: transparent;\n border: 0;\n margin: 0 6px;\n padding: 0;\n cursor: pointer;\n display: inline-block;\n width: 32px;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button svg {\n width: 100%;\n height: 22px; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button svg path {\n fill: white; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button:focus {\n outline: none; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-play] {\n float: left;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-pause] {\n float: left;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-stop] {\n float: left;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-fullscreen] {\n float: right;\n background-color: transparent;\n border: 0;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-hd-indicator] {\n background-color: transparent;\n border: 0;\n cursor: default;\n display: none;\n float: right;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-hd-indicator].enabled {\n display: block;\n opacity: 1.0; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-hd-indicator].enabled:hover {\n opacity: 1.0;\n text-shadow: none; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-playpause] {\n float: left; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-playstop] {\n float: left; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-indicator[data-position], .media-control[data-media-control] .media-control-layer[data-controls] .media-control-indicator[data-duration] {\n display: inline-block;\n font-size: 10px;\n color: white;\n cursor: default;\n line-height: 32px;\n position: relative; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-indicator[data-position] {\n margin: 0 6px 0 7px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-indicator[data-duration] {\n color: rgba(255, 255, 255, 0.5);\n margin-right: 6px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-indicator[data-duration]:before {\n content: "|";\n margin-right: 7px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] {\n position: absolute;\n top: -20px;\n left: 0;\n display: inline-block;\n vertical-align: middle;\n width: 100%;\n height: 25px;\n cursor: pointer; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] {\n width: 100%;\n height: 1px;\n position: relative;\n top: 12px;\n background-color: #666666; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] .bar-fill-1[data-seekbar] {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n background-color: #c2c2c2;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] .bar-fill-2[data-seekbar] {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n background-color: #005aff;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] .bar-hover[data-seekbar] {\n opacity: 0;\n position: absolute;\n top: -3px;\n width: 5px;\n height: 7px;\n background-color: rgba(255, 255, 255, 0.5);\n transition: opacity 0.1s ease; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar]:hover .bar-background[data-seekbar] .bar-hover[data-seekbar] {\n opacity: 1; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar].seek-disabled {\n cursor: default; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar].seek-disabled:hover .bar-background[data-seekbar] .bar-hover[data-seekbar] {\n opacity: 0; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-scrubber[data-seekbar] {\n position: absolute;\n transform: translateX(-50%);\n top: 2px;\n left: 0;\n width: 20px;\n height: 20px;\n opacity: 1;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-scrubber[data-seekbar] .bar-scrubber-icon[data-seekbar] {\n position: absolute;\n left: 6px;\n top: 6px;\n width: 8px;\n height: 8px;\n border-radius: 10px;\n box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.2);\n background-color: white; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] {\n float: right;\n display: inline-block;\n height: 32px;\n cursor: pointer;\n margin: 0 6px;\n box-sizing: border-box; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] {\n float: left;\n bottom: 0; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] .drawer-icon[data-volume] {\n background-color: transparent;\n border: 0;\n box-sizing: content-box;\n width: 32px;\n height: 32px;\n opacity: 0.5; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] .drawer-icon[data-volume]:hover {\n opacity: 0.75; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] .drawer-icon[data-volume] svg {\n height: 24px;\n position: relative;\n top: 3px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] .drawer-icon[data-volume] svg path {\n fill: white; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] .drawer-icon[data-volume].muted svg {\n margin-left: 2px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] {\n float: left;\n position: relative;\n overflow: hidden;\n top: 6px;\n width: 42px;\n height: 18px;\n padding: 3px 0;\n transition: width .2s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-background[data-volume] {\n height: 1px;\n position: relative;\n top: 7px;\n margin: 0 3px;\n background-color: #666666; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-background[data-volume] .bar-fill-1[data-volume] {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n background-color: #c2c2c2;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-background[data-volume] .bar-fill-2[data-volume] {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n background-color: #005aff;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-background[data-volume] .bar-hover[data-volume] {\n opacity: 0;\n position: absolute;\n top: -3px;\n width: 5px;\n height: 7px;\n background-color: rgba(255, 255, 255, 0.5);\n transition: opacity 0.1s ease; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-scrubber[data-volume] {\n position: absolute;\n transform: translateX(-50%);\n top: 0px;\n left: 0;\n width: 20px;\n height: 20px;\n opacity: 1;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-scrubber[data-volume] .bar-scrubber-icon[data-volume] {\n position: absolute;\n left: 6px;\n top: 6px;\n width: 8px;\n height: 8px;\n border-radius: 10px;\n box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.2);\n background-color: white; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .segmented-bar-element[data-volume] {\n float: left;\n width: 4px;\n padding-left: 2px;\n height: 12px;\n opacity: 0.5;\n box-shadow: inset 2px 0 0 white;\n transition: transform .2s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .segmented-bar-element[data-volume].fill {\n box-shadow: inset 2px 0 0 #fff;\n opacity: 1; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .segmented-bar-element[data-volume]:nth-of-type(1) {\n padding-left: 0; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .segmented-bar-element[data-volume]:hover {\n transform: scaleY(1.5); }\n .media-control[data-media-control].w320 .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume].volume-bar-hide {\n width: 0;\n height: 12px;\n top: 9px;\n padding: 0; }\n',{baseUrl:this.options.baseUrl});this.$el.append(i[0]),this.createCachedElements(),this.$playPauseToggle.addClass("paused"),this.$playStopToggle.addClass("stopped"),this.changeTogglePlay(),this.container&&(this.hideId=setTimeout((function(){return t.hide()}),e),this.disabled&&this.hide()),D.isSafari&&D.isMobile&&(D.version<10?this.$volumeContainer.css("display","none"):this.$volumeBarContainer.css("display","none")),this.$seekBarPosition.addClass("media-control-notransition"),this.$seekBarScrubber.addClass("media-control-notransition");var n=0;return this.displayedSeekBarPercentage&&(n=this.displayedSeekBarPercentage),this.displayedSeekBarPercentage=null,this.setSeekPercentage(n),setTimeout((function(){!t.settings.seekEnabled&&t.$seekBarContainer.addClass("seek-disabled"),!D.isMobile&&!t.options.disableKeyboardShortcuts&&t.bindKeyEvents(),t.playerResize({width:t.options.width,height:t.options.height}),t.hideVolumeBar(0)}),0),this.parseColors(),this.highDefinitionUpdate(this.isHD),this.core.$el.append(this.el),this.rendered=!0,this.updateVolumeUI(),this.trigger(ct.MEDIACONTROL_RENDERED),this}}])}(_t);Ie.extend=function(t){return Ce(Ie,t)};for(var De=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).hasStartedPlaying=!1,i.playRequested=!1,i.render(),setTimeout((function(){return i.update()}),0),i}return se(e,t),re(e,[{key:"name",get:function(){return"poster"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"template",get:function(){return At('<div class="play-wrapper" data-poster></div>\n')}},{key:"shouldRender",get:function(){var t=!(!this.options.poster||!this.options.poster.showForNoOp);return"html_img"!==this.container.playback.name&&(this.container.playback.getPlaybackType()!==Rt.NO_OP||t)}},{key:"attributes",get:function(){return{class:"player-poster","data-poster":""}}},{key:"events",get:function(){return{click:"clicked"}}},{key:"showOnVideoEnd",get:function(){return!this.options.poster||this.options.poster.showOnVideoEnd||void 0===this.options.poster.showOnVideoEnd}},{key:"bindEvents",value:function(){this.listenTo(this.container,ct.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ct.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERING,this.update),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERFULL,this.update),this.listenTo(this.container,ct.CONTAINER_OPTIONS_CHANGE,this.render),this.listenTo(this.container,ct.CONTAINER_ERROR,this.onError),this.showOnVideoEnd&&this.listenTo(this.container,ct.CONTAINER_ENDED,this.onStop)}},{key:"onError",value:function(t){this.hasFatalError=t.level===kt.Levels.FATAL,this.hasFatalError&&(this.hasStartedPlaying=!1,this.playRequested=!1,this.showPlayButton())}},{key:"onPlay",value:function(){this.hasStartedPlaying=!0,this.update()}},{key:"onStop",value:function(){this.hasStartedPlaying=!1,this.playRequested=!1,this.update()}},{key:"updatePlayButton",value:function(t){!t||this.options.chromeless&&!this.options.allowUserInteraction?this.hidePlayButton():this.showPlayButton()}},{key:"showPlayButton",value:function(){this.hasFatalError&&!this.options.disableErrorScreen||(this.$playButton.show(),this.$el.addClass("clickable"))}},{key:"hidePlayButton",value:function(){this.$playButton.hide(),this.$el.removeClass("clickable")}},{key:"clicked",value:function(){if(!this.hasStartedPlaying)return this.options.chromeless&&!this.options.allowUserInteraction||(this.playRequested=!0,this.update(),this.container.playback&&(this.container.playback._consented=!0),this.container.play()),!1}},{key:"shouldHideOnPlay",value:function(){return!this.container.playback.isAudioOnly}},{key:"update",value:function(){if(this.shouldRender){var t=!this.playRequested&&!this.hasStartedPlaying&&!this.container.buffering;this.updatePlayButton(t),this.updatePoster()}}},{key:"updatePoster",value:function(){this.hasStartedPlaying?this.hidePoster():this.showPoster()}},{key:"showPoster",value:function(){this.container.disableMediaControl(),this.$el.show()}},{key:"hidePoster",value:function(){this.container.enableMediaControl(),this.shouldHideOnPlay()&&this.$el.hide()}},{key:"render",value:function(){if(this.shouldRender){var t=Et.getStyleFor(".player-poster[data-poster] {\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute;\n height: 100%;\n width: 100%;\n z-index: 998;\n top: 0;\n left: 0;\n background-color: transparent;\n background-size: cover;\n background-repeat: no-repeat;\n background-position: 50% 50%; }\n .player-poster[data-poster].clickable {\n cursor: pointer; }\n .player-poster[data-poster]:hover .play-wrapper[data-poster] {\n opacity: 1; }\n .player-poster[data-poster] .play-wrapper[data-poster] {\n width: 100%;\n height: 25%;\n margin: 0 auto;\n opacity: 0.75;\n transition: opacity 0.1s ease; }\n .player-poster[data-poster] .play-wrapper[data-poster] svg {\n height: 100%; }\n .player-poster[data-poster] .play-wrapper[data-poster] svg path {\n fill: #fff; }\n",{baseUrl:this.options.baseUrl});if(this.$el.html(this.template()),this.$el.append(t[0]),this.options.poster&&void 0===this.options.poster.custom){var e=this.options.poster.url||this.options.poster;this.$el.css({"background-image":"url("+e+")"}),this.removeVideoElementPoster()}else this.options.poster&&(this.$el.css({background:this.options.poster.custom}),this.removeVideoElementPoster());this.container.$el.append(this.el),this.$playWrapper=this.$el.find(".play-wrapper"),this.$playWrapper.append(pe),this.$playButton=this.$playWrapper.find("svg"),this.$playButton.addClass("poster-icon"),this.$playButton.attr("data-poster","");var i=this.options.mediacontrol&&this.options.mediacontrol.buttons;return i&&this.$el.find("svg path").css("fill",i),this.options.mediacontrol&&this.options.mediacontrol.buttons&&(i=this.options.mediacontrol.buttons,this.$playButton.css("color",i)),this.update(),this}}},{key:"removeVideoElementPoster",value:function(){this.container.playback&&this.container.playback.$el&&this.container.playback.$el[0]&&this.container.playback.$el[0].removeAttribute&&this.container.playback.$el[0].removeAttribute("poster")}}])}(Gt),Pe=Z.formatTime,Oe=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).hoveringOverSeekBar=!1,i.hoverPosition=null,i.duration=null,i.firstFragDateTime=null,i.actualLiveTime=!!i.mediaControl.options.actualLiveTime,i.actualLiveTime&&(i.mediaControl.options.actualLiveServerTime?i.actualLiveServerTimeDiff=(new Date).getTime()-new Date(i.mediaControl.options.actualLiveServerTime).getTime():i.actualLiveServerTimeDiff=0),i}return se(e,t),re(e,[{key:"name",get:function(){return"seek_time"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"template",get:function(){return At("<span data-seek-time></span>\n<span data-duration></span>\n")}},{key:"attributes",get:function(){return{class:"seek-time","data-seek-time":""}}},{key:"mediaControl",get:function(){return this.core.mediaControl}},{key:"mediaControlContainer",get:function(){return this.mediaControl.container}},{key:"isLiveStreamWithDvr",get:function(){return this.mediaControlContainer&&this.mediaControlContainer.getPlaybackType()===Rt.LIVE&&this.mediaControlContainer.isDvrEnabled()}},{key:"durationShown",get:function(){return this.isLiveStreamWithDvr&&!this.actualLiveTime}},{key:"useActualLiveTime",get:function(){return this.actualLiveTime&&this.isLiveStreamWithDvr}},{key:"bindEvents",value:function(){this.listenTo(this.mediaControl,ct.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.mediaControl,ct.MEDIACONTROL_MOUSEMOVE_SEEKBAR,this.showTime),this.listenTo(this.mediaControl,ct.MEDIACONTROL_MOUSELEAVE_SEEKBAR,this.hideTime),this.listenTo(this.mediaControl,ct.MEDIACONTROL_CONTAINERCHANGED,this.onContainerChanged),this.mediaControlContainer&&(this.listenTo(this.mediaControlContainer,ct.CONTAINER_PLAYBACKDVRSTATECHANGED,this.update),this.listenTo(this.mediaControlContainer,ct.CONTAINER_TIMEUPDATE,this.updateDuration))}},{key:"onContainerChanged",value:function(){this.stopListening(),this.bindEvents()}},{key:"updateDuration",value:function(t){this.duration=t.total,this.firstFragDateTime=t.firstFragDateTime,this.update()}},{key:"showTime",value:function(t){this.hoveringOverSeekBar=!0,this.calculateHoverPosition(t),this.update()}},{key:"hideTime",value:function(){this.hoveringOverSeekBar=!1,this.update()}},{key:"calculateHoverPosition",value:function(t){var e=t.pageX-this.mediaControl.$seekBarContainer.offset().left;this.hoverPosition=Math.min(1,Math.max(e/this.mediaControl.$seekBarContainer.width(),0))}},{key:"getSeekTime",value:function(){var t,e,i,n;return this.useActualLiveTime?(this.firstFragDateTime?(n=new Date(this.firstFragDateTime),(i=new Date(this.firstFragDateTime)).setHours(0,0,0,0),e=(n.getTime()-i.getTime())/1e3+this.duration):(i=new Date((new Date).getTime()-this.actualLiveServerTimeDiff),e=((n=new Date(i))-i.setHours(0,0,0,0))/1e3),(t=e-this.duration+this.hoverPosition*this.duration)<0&&(t+=86400)):t=this.hoverPosition*this.duration,{seekTime:t,secondsSinceMidnight:e}}},{key:"update",value:function(){if(this.rendered)if(this.shouldBeVisible()){var t=this.getSeekTime(),e=Pe(t.seekTime,this.useActualLiveTime);if(e!==this.displayedSeekTime&&(this.$seekTimeEl.text(e),this.displayedSeekTime=e),this.durationShown){this.$durationEl.show();var i=Pe(this.actualLiveTime?t.secondsSinceMidnight:this.duration,this.actualLiveTime);i!==this.displayedDuration&&(this.$durationEl.text(i),this.displayedDuration=i)}else this.$durationEl.hide();this.$el.show();var n=this.mediaControl.$seekBarContainer.width(),r=this.$el.width(),s=this.hoverPosition*n;s-=r/2,s=Math.max(0,Math.min(s,n-r)),this.$el.css("left",s)}else this.$el.hide(),this.$el.css("left","-100%")}},{key:"shouldBeVisible",value:function(){return this.mediaControlContainer&&this.mediaControlContainer.settings.seekEnabled&&this.hoveringOverSeekBar&&null!==this.hoverPosition&&null!==this.duration}},{key:"render",value:function(){var t=Et.getStyleFor('.seek-time[data-seek-time] {\n position: absolute;\n white-space: nowrap;\n height: 20px;\n line-height: 20px;\n font-size: 0;\n left: -100%;\n bottom: 55px;\n background-color: rgba(2, 2, 2, 0.5);\n z-index: 9999;\n transition: opacity 0.1s ease; }\n .seek-time[data-seek-time].hidden[data-seek-time] {\n opacity: 0; }\n .seek-time[data-seek-time] [data-seek-time] {\n display: inline-block;\n color: white;\n font-size: 10px;\n padding-left: 7px;\n padding-right: 7px;\n vertical-align: top; }\n .seek-time[data-seek-time] [data-duration] {\n display: inline-block;\n color: rgba(255, 255, 255, 0.5);\n font-size: 10px;\n padding-right: 7px;\n vertical-align: top; }\n .seek-time[data-seek-time] [data-duration]:before {\n content: "|";\n margin-right: 7px; }\n',{baseUrl:this.options.baseUrl});this.rendered=!0,this.displayedDuration=null,this.displayedSeekTime=null,this.$el.html(this.template()),this.$el.append(t[0]),this.$el.hide(),this.mediaControl.$el.append(this.el),this.$seekTimeEl=this.$el.find("[data-seek-time]"),this.$durationEl=this.$el.find("[data-duration]"),this.$durationEl.hide(),this.update()}}])}(_t),xe={ClickToPause:he,ClosedCaptions:ue,DVRControls:de,EndVideo:fe,ErrorScreen:ge,Favicon:ye,GoogleAnalytics:Ae,MediaControl:Ie,Poster:De,SeekTime:Oe,SpinnerThreeBounce:function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).template=At("<div data-bounce1></div><div data-bounce2></div><div data-bounce3></div>\n"),i.showTimeout=null,i.listenTo(i.container,ct.CONTAINER_STATE_BUFFERING,i.onBuffering),i.listenTo(i.container,ct.CONTAINER_STATE_BUFFERFULL,i.onBufferFull),i.listenTo(i.container,ct.CONTAINER_STOP,i.onStop),i.listenTo(i.container,ct.CONTAINER_ENDED,i.onStop),i.listenTo(i.container,ct.CONTAINER_ERROR,i.onStop),i.render(),i}return se(e,t),re(e,[{key:"name",get:function(){return"spinner"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"attributes",get:function(){return{"data-spinner":"",class:"spinner-three-bounce"}}},{key:"onBuffering",value:function(){this.show()}},{key:"onBufferFull",value:function(){this.hide()}},{key:"onStop",value:function(){this.hide()}},{key:"show",value:function(){var t=this;null===this.showTimeout&&(this.showTimeout=setTimeout((function(){return t.$el.show()}),300))}},{key:"hide",value:function(){null!==this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),this.$el.hide()}},{key:"render",value:function(){var t=Et.getStyleFor(".spinner-three-bounce[data-spinner] {\n position: absolute;\n margin: 0 auto;\n width: 70px;\n text-align: center;\n z-index: 999;\n left: 0;\n right: 0;\n margin-left: auto;\n margin-right: auto;\n /* center vertically */\n top: 50%;\n transform: translateY(-50%); }\n .spinner-three-bounce[data-spinner] > div {\n width: 18px;\n height: 18px;\n background-color: #FFFFFF;\n border-radius: 100%;\n display: inline-block;\n animation: bouncedelay 1.4s infinite ease-in-out;\n /* Prevent first frame from flickering when animation starts */\n animation-fill-mode: both; }\n .spinner-three-bounce[data-spinner] [data-bounce1] {\n animation-delay: -0.32s; }\n .spinner-three-bounce[data-spinner] [data-bounce2] {\n animation-delay: -0.16s; }\n\n@keyframes bouncedelay {\n 0%, 80%, 100% {\n transform: scale(0); }\n 40% {\n transform: scale(1); } }\n",{baseUrl:this.options.baseUrl});return this.$el.html(this.template()),this.$el.append(t[0]),this.container.$el.append(this.$el),this.$el.hide(),this.container.buffering&&this.onBuffering(),this}}])}(Gt),Stats:function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).setInitialAttrs(),i.reportInterval=i.options.reportInterval||5e3,i.state="IDLE",i}return se(e,t),re(e,[{key:"name",get:function(){return"stats"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"bindEvents",value:function(){this.listenTo(this.container.playback,ct.PLAYBACK_PLAY,this.onPlay),this.listenTo(this.container,ct.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ct.CONTAINER_ENDED,this.onStop),this.listenTo(this.container,ct.CONTAINER_DESTROYED,this.onStop),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERING,this.onBuffering),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERFULL,this.onBufferFull),this.listenTo(this.container,ct.CONTAINER_STATS_ADD,this.onStatsAdd),this.listenTo(this.container,ct.CONTAINER_BITRATE,this.onStatsAdd),this.listenTo(this.container.playback,ct.PLAYBACK_STATS_ADD,this.onStatsAdd)}},{key:"setInitialAttrs",value:function(){this.firstPlay=!0,this.startupTime=0,this.rebufferingTime=0,this.watchingTime=0,this.rebuffers=0,this.externalMetrics={}}},{key:"onPlay",value:function(){this.state="PLAYING",this.watchingTimeInit=Date.now(),this.intervalId||(this.intervalId=setInterval(this.report.bind(this),this.reportInterval))}},{key:"onStop",value:function(){clearInterval(this.intervalId),this.report(),this.intervalId=void 0,this.state="STOPPED"}},{key:"onBuffering",value:function(){this.firstPlay?this.startupTimeInit=Date.now():this.rebufferingTimeInit=Date.now(),this.state="BUFFERING",this.rebuffers++}},{key:"onBufferFull",value:function(){this.firstPlay&&this.startupTimeInit?(this.firstPlay=!1,this.startupTime=Date.now()-this.startupTimeInit,this.watchingTimeInit=Date.now()):this.rebufferingTimeInit&&(this.rebufferingTime+=this.getRebufferingTime()),this.rebufferingTimeInit=void 0,this.state="PLAYING"}},{key:"getRebufferingTime",value:function(){return Date.now()-this.rebufferingTimeInit}},{key:"getWatchingTime",value:function(){return Date.now()-this.watchingTimeInit-this.rebufferingTime}},{key:"isRebuffering",value:function(){return!!this.rebufferingTimeInit}},{key:"onStatsAdd",value:function(t){S.extend(this.externalMetrics,t)}},{key:"getStats",value:function(){var t={startupTime:this.startupTime,rebuffers:this.rebuffers,rebufferingTime:this.isRebuffering()?this.rebufferingTime+this.getRebufferingTime():this.rebufferingTime,watchingTime:this.isRebuffering()?this.getWatchingTime()-this.getRebufferingTime():this.getWatchingTime()};return S.extend(t,this.externalMetrics),t}},{key:"report",value:function(){this.container.statsReport(this.getStats())}}])}(Ut),WaterMark:function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).configure(),i}return se(e,t),re(e,[{key:"name",get:function(){return"watermark"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"template",get:function(){return At('<div class="clappr-watermark" data-watermark data-watermark-<%=position %>>\n<% if(typeof imageLink !== \'undefined\') { %>\n<a target="_blank" href="<%= imageLink %>">\n<% } %>\n<img src="<%= imageUrl %>">\n<% if(typeof imageLink !== \'undefined\') { %>\n</a>\n<% } %>\n</div>\n')}},{key:"bindEvents",value:function(){this.listenTo(this.container,ct.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ct.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ct.CONTAINER_OPTIONS_CHANGE,this.configure)}},{key:"configure",value:function(){this.position=this.options.position||"bottom-right",this.options.watermark?(this.imageUrl=this.options.watermark,this.imageLink=this.options.watermarkLink,this.render()):this.$el.remove()}},{key:"onPlay",value:function(){this.hidden||this.$el.show()}},{key:"onStop",value:function(){this.$el.hide()}},{key:"render",value:function(){this.$el.hide();var t=Et.getStyleFor(".clappr-watermark[data-watermark] {\n position: absolute;\n min-width: 70px;\n max-width: 200px;\n width: 12%;\n text-align: center;\n z-index: 10; }\n\n.clappr-watermark[data-watermark] a {\n outline: none;\n cursor: pointer; }\n\n.clappr-watermark[data-watermark] img {\n max-width: 100%; }\n\n.clappr-watermark[data-watermark-bottom-left] {\n bottom: 10px;\n left: 10px; }\n\n.clappr-watermark[data-watermark-bottom-right] {\n bottom: 10px;\n right: 42px; }\n\n.clappr-watermark[data-watermark-top-left] {\n top: 10px;\n left: 10px; }\n\n.clappr-watermark[data-watermark-top-right] {\n top: 10px;\n right: 37px; }\n",{baseUrl:this.options.baseUrl}),e={position:this.position,imageUrl:this.imageUrl,imageLink:this.imageLink};return this.$el.html(this.template(e)),this.$el.append(t[0]),this.container.$el.append(this.$el),this}}])}(Gt)},Ne=0,Me=Object.values(xe);Ne<Me.length;Ne++){var Fe=Me[Ne];Mt.registerPlugin(Fe)}var Be=xe.ClickToPause,Ue=xe.ClosedCaptions,$e=xe.DVRControls,Ge=xe.EndVideo,Ve=xe.ErrorScreen,Ke=xe.Favicon,He=xe.GoogleAnalytics,Ye=xe.MediaControl,je=xe.Poster,We=xe.SeekTime,ze=xe.SpinnerThreeBounce,qe=xe.Stats,Xe=xe.WaterMark,Qe=e(e({},Zt),{},{ClickToPause:Be,ClosedCaptions:Ue,DVRControls:$e,EndVideo:Ge,ErrorScreen:Ve,Favicon:Ke,GoogleAnalytics:He,MediaControl:Ye,Poster:je,SeekTime:We,SpinnerThreeBounce:ze,Stats:qe,WaterMark:Xe,Vendor:Te,Plugins:xe,version:"0.11.1"});function Ze(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function Je(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Ze(Object(i),!0).forEach((function(e){ei(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Ze(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function ti(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ci(n.key),n)}}function ei(t,e,i){return(e=ci(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ii(t){return ii=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ii(t)}function ni(t,e){return ni=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ni(t,e)}function ri(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function si(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=ii(t);if(e){var r=ii(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return ri(this,i)}}function ai(){return ai="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=ii(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},ai.apply(this,arguments)}function oi(t){return function(t){if(Array.isArray(t))return li(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return li(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return li(t,e)}(t)||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.")}()}function li(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function ci(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function hi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ui,di,fi,gi,pi,mi={exports:{}};ui=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,di=/^(?=([^\/?#]*))\1([^]*)$/,fi=/(?:\/|^)\.(?=\/)/g,gi=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,mi.exports=pi={buildAbsoluteURL:function(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;var n=pi.parseURL(t);if(!n)throw new Error("Error trying to parse base URL.");return n.path=pi.normalizePath(n.path),pi.buildURLFromParts(n)}var r=pi.parseURL(e);if(!r)throw new Error("Error trying to parse relative URL.");if(r.scheme)return i.alwaysNormalize?(r.path=pi.normalizePath(r.path),pi.buildURLFromParts(r)):e;var s=pi.parseURL(t);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var a=di.exec(s.path);s.netLoc=a[1],s.path=a[2]}s.netLoc&&!s.path&&(s.path="/");var o={scheme:s.scheme,netLoc:r.netLoc,path:null,params:r.params,query:r.query,fragment:r.fragment};if(!r.netLoc&&(o.netLoc=s.netLoc,"/"!==r.path[0]))if(r.path){var l=s.path,c=l.substring(0,l.lastIndexOf("/")+1)+r.path;o.path=pi.normalizePath(c)}else o.path=s.path,r.params||(o.params=s.params,r.query||(o.query=s.query));return null===o.path&&(o.path=i.alwaysNormalize?pi.normalizePath(r.path):r.path),pi.buildURLFromParts(o)},parseURL:function(t){var e=ui.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(fi,"");t.length!==(t=t.replace(gi,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};var vi=mi.exports;function yi(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function Ai(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?yi(Object(i),!0).forEach((function(e){Ti(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):yi(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function Ei(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function Ti(t,e,i){return(e=Ei(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function bi(){return bi=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},bi.apply(this,arguments)}const ki=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},Si=Number.isSafeInteger||function(t){return"number"==typeof t&&Math.abs(t)<=_i},_i=Number.MAX_SAFE_INTEGER||9007199254740991;let Li=function(t){return t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached",t.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",t}({}),Ri=function(t){return t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t}({}),Ci=function(t){return t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown",t}({});const wi=function(){},Ii={trace:wi,debug:wi,log:wi,warn:wi,info:wi,error:wi};let Di=Ii;function Pi(t,...e){e.forEach((function(e){Di[e]=t[e]?t[e].bind(t):function(t){const e=self.console[t];return e?e.bind(self.console,`[${t}] >`):wi}(e)}))}const Oi=Di,xi=/^(\d+)x(\d+)$/,Ni=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Mi{constructor(t){"string"==typeof t&&(t=Mi.parseAttrList(t)),bi(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 i=new Uint8Array(e.length/2);for(let t=0;t<e.length/2;t++)i[t]=parseInt(e.slice(2*t,2*t+2),16);return i}return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const i=this[t];return i?parseFloat(i):e}enumeratedString(t){return this[t]}bool(t){return"YES"===this[t]}decimalResolution(t){const e=xi.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={};for(Ni.lastIndex=0;null!==(e=Ni.exec(t));){let t=e[2];0===t.indexOf('"')&&t.lastIndexOf('"')===t.length-1&&(t=t.slice(1,-1));i[e[1].trim()]=t}return i}}function Fi(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}class Bi{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const i=e.attr;for(const e in i)if(Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==i[e]){Oi.warn(`DATERANGE tag attribute: "${e}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=e;break}t=bi(new Mi({}),i,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"]);ki(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(ki(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&&ki(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Ui{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 $i="audio",Gi="video",Vi="audiovideo";class Ki{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[$i]:null,[Gi]:null,[Vi]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2);let n;n=1===i.length?(null==e?void 0:e.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[n,parseInt(i[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=vi.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class Hi extends Ki{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 Ui,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(!ki(this.programDateTime))return null;const t=ki(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,i,n,r,s=!1){const{elementaryStreams:a}=this,o=a[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,i),o.startDTS=Math.min(o.startDTS,n),o.endDTS=Math.max(o.endDTS,r)):a[t]={startPTS:e,endPTS:i,startDTS:n,endDTS:r,partial:s}}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[$i]=null,t[Gi]=null,t[Vi]=null}}class Yi extends Ki{constructor(t,e,i,n,r){super(i),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 Ui,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,r),r&&(this.fragOffset=r.fragOffset+r.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 ji{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,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&i>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&&ki(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 Wi(t){return Uint8Array.from(atob(t),(t=>t.charCodeAt(0)))}function zi(t){const e=t.split(":");let i=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],r=n[1];e?(t.splice(-1,1),i=Wi(r)):i=function(t){const e=qi(t).subarray(0,16),i=new Uint8Array(16);return i.set(e,16-e.length),i}(r)}}return i}function qi(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(t=>t.charCodeAt(0)))}const Xi="undefined"!=typeof self?self:void 0;var Qi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Zi="org.w3.clearkey",Ji="com.apple.streamingkeydelivery",tn="com.microsoft.playready",en="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function nn(t){switch(t){case Ji:return Qi.FAIRPLAY;case tn:return Qi.PLAYREADY;case en:return Qi.WIDEVINE;case Zi:return Qi.CLEARKEY}}var rn="edef8ba979d64acea3c827dcd51d21ed";function sn(t){switch(t){case Qi.FAIRPLAY:return Ji;case Qi.PLAYREADY:return tn;case Qi.WIDEVINE:return en;case Qi.CLEARKEY:return Zi}}function an(t){const{drmSystems:e,widevineLicenseUrl:i}=t,n=e?[Qi.FAIRPLAY,Qi.WIDEVINE,Qi.PLAYREADY,Qi.CLEARKEY].filter((t=>!!e[t])):[];return!n[Qi.WIDEVINE]&&i&&n.push(Qi.WIDEVINE),n}const on=null!=Xi&&null!=(ln=Xi.navigator)&&ln.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var ln;function cn(t,e,i){return Uint8Array.prototype.slice?t.slice(e,i):new Uint8Array(Array.prototype.slice.call(t,e,i))}const hn=(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,un=(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,dn=(t,e)=>{const i=e;let n=0;for(;hn(t,e);){n+=10;n+=fn(t,e+6),un(t,e+10)&&(n+=10),e+=n}if(n>0)return t.subarray(i,i+n)},fn=(t,e)=>{let i=0;return i=(127&t[e])<<21,i|=(127&t[e+1])<<14,i|=(127&t[e+2])<<7,i|=127&t[e+3],i},gn=(t,e)=>hn(t,e)&&fn(t,e+6)+10<=t.length-e,pn=t=>{const e=yn(t);for(let t=0;t<e.length;t++){const i=e[t];if(mn(i))return kn(i)}},mn=t=>t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info,vn=t=>{const e=String.fromCharCode(t[0],t[1],t[2],t[3]),i=fn(t,4);return{type:e,size:i,data:t.subarray(10,10+i)}},yn=t=>{let e=0;const i=[];for(;hn(t,e);){const n=fn(t,e+6);e+=10;const r=e+n;for(;e+8<r;){const n=vn(t.subarray(e)),r=An(n);r&&i.push(r),e+=n.size+10}un(t,e)&&(e+=10)}return i},An=t=>"PRIV"===t.type?En(t):"W"===t.type[0]?bn(t):Tn(t),En=t=>{if(t.size<2)return;const e=Sn(t.data,!0),i=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:i.buffer}},Tn=t=>{if(t.size<2)return;if("TXXX"===t.type){let e=1;const i=Sn(t.data.subarray(e),!0);e+=i.length+1;const n=Sn(t.data.subarray(e));return{key:t.type,info:i,data:n}}const e=Sn(t.data.subarray(1));return{key:t.type,data:e}},bn=t=>{if("WXXX"===t.type){if(t.size<2)return;let e=1;const i=Sn(t.data.subarray(e),!0);e+=i.length+1;const n=Sn(t.data.subarray(e));return{key:t.type,info:i,data:n}}const e=Sn(t.data);return{key:t.type,data:e}},kn=t=>{if(8===t.data.byteLength){const e=new Uint8Array(t.data),i=1&e[3];let n=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return n/=45,i&&(n+=47721858.84),Math.round(n)}},Sn=(t,e=!1)=>{const i=Ln();if(i){const n=i.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 r,s,a,o="",l=0;for(;l<n;){if(r=t[l++],0===r&&e)return o;if(0!==r&&3!==r)switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:s=t[l++],o+=String.fromCharCode((31&r)<<6|63&s);break;case 14:s=t[l++],a=t[l++],o+=String.fromCharCode((15&r)<<12|(63&s)<<6|(63&a)<<0)}}return o};let _n;function Ln(){if(!navigator.userAgent.includes("PlayStation 4"))return _n||void 0===self.TextDecoder||(_n=new self.TextDecoder("utf-8")),_n}const Rn=function(t){let e="";for(let i=0;i<t.length;i++){let n=t[i].toString(16);n.length<2&&(n="0"+n),e+=n}return e},Cn=Math.pow(2,32)-1,wn=[].push,In={video:1,audio:2,id3:3,text:4};function Dn(t){return String.fromCharCode.apply(null,t)}function Pn(t,e){const i=t[e]<<8|t[e+1];return i<0?65536+i:i}function On(t,e){const i=Nn(t,e);return i<0?4294967296+i:i}function xn(t,e){let i=On(t,e);return i*=Math.pow(2,32),i+=On(t,e+4),i}function Nn(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function Mn(t,e,i){t[e]=i>>24,t[e+1]=i>>16&255,t[e+2]=i>>8&255,t[e+3]=255&i}function Fn(t,e){const i=[];if(!e.length)return i;const n=t.byteLength;for(let r=0;r<n;){const s=On(t,r),a=s>1?r+s:n;if(Dn(t.subarray(r+4,r+8))===e[0])if(1===e.length)i.push(t.subarray(r+8,a));else{const n=Fn(t.subarray(r+8,a),e.slice(1));n.length&&wn.apply(i,n)}r=a}return i}function Bn(t){const e=[],i=t[0];let n=8;const r=On(t,n);n+=4;let s=0,a=0;0===i?(s=On(t,n),a=On(t,n+4),n+=8):(s=xn(t,n),a=xn(t,n+8),n+=16),n+=2;let o=t.length+a;const l=Pn(t,n);n+=2;for(let i=0;i<l;i++){let i=n;const s=On(t,i);i+=4;const a=2147483647&s;if(1===(2147483648&s)>>>31)return Oi.warn("SIDX has hierarchical references (not supported)"),null;const l=On(t,i);i+=4,e.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/r,start:o,end:o+a-1}}),o+=a,i+=4,n=i}return{earliestPresentationTime:s,timescale:r,version:i,referencesCount:l,references:e}}function Un(t){const e=[],i=Fn(t,["moov","trak"]);for(let t=0;t<i.length;t++){const n=i[t],r=Fn(n,["tkhd"])[0];if(r){let t=r[0];const i=On(r,0===t?12:20),s=Fn(n,["mdia","mdhd"])[0];if(s){t=s[0];const r=On(s,0===t?12:20),a=Fn(n,["mdia","hdlr"])[0];if(a){const t=Dn(a.subarray(8,12)),s={soun:$i,vide:Gi}[t];if(s){const t=$n(Fn(n,["mdia","minf","stbl","stsd"])[0]);e[i]={timescale:r,type:s},e[s]=Ai({timescale:r,id:i},t)}}}}}return Fn(t,["moov","mvex","trex"]).forEach((t=>{const i=On(t,4),n=e[i];n&&(n.default={duration:On(t,12),flags:On(t,20)})})),e}function $n(t){const e=t.subarray(8),i=e.subarray(86),n=Dn(e.subarray(4,8));let r=n;const s="enca"===n||"encv"===n;if(s){const t=Fn(e,[n])[0];Fn(t.subarray("enca"===n?28:78),["sinf"]).forEach((t=>{const e=Fn(t,["schm"])[0];if(e){const i=Dn(e.subarray(4,8));if("cbcs"===i||"cenc"===i){const e=Fn(t,["frma"])[0];e&&(r=Dn(e))}}}))}switch(r){case"avc1":case"avc2":case"avc3":case"avc4":{const t=Fn(i,["avcC"])[0];r+="."+Vn(t[1])+Vn(t[2])+Vn(t[3]);break}case"mp4a":{const t=Fn(e,[n])[0],i=Fn(t.subarray(28),["esds"])[0];if(i&&i.length>12){let t=4;if(3!==i[t++])break;t=Gn(i,t),t+=2;const e=i[t++];if(128&e&&(t+=2),64&e&&(t+=i[t++]),4!==i[t++])break;t=Gn(i,t);const n=i[t++];if(64!==n)break;if(r+="."+Vn(n),t+=12,5!==i[t++])break;t=Gn(i,t);const s=i[t++];let a=(248&s)>>3;31===a&&(a+=1+((7&s)<<3)+((224&i[t])>>5)),r+="."+a}break}case"hvc1":case"hev1":{const t=Fn(i,["hvcC"])[0],e=t[1],n=["","A","B","C"][e>>6],s=31&e,a=On(t,2),o=(32&e)>>5?"H":"L",l=t[12],c=t.subarray(6,12);r+="."+n+s,r+="."+a.toString(16).toUpperCase(),r+="."+o+l;let h="";for(let t=c.length;t--;){const e=c[t];if(e||h){h="."+e.toString(16).toUpperCase()+h}}r+=h;break}case"dvh1":case"dvhe":{const t=Fn(i,["dvcC"])[0],e=t[2]>>1&127,n=t[2]<<5&32|t[3]>>3&31;r+="."+Kn(e)+"."+Kn(n);break}case"vp09":{const t=Fn(i,["vpcC"])[0],e=t[4],n=t[5],s=t[6]>>4&15;r+="."+Kn(e)+"."+Kn(n)+"."+Kn(s);break}case"av01":{const t=Fn(i,["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,h=(8&t[2])>>3,u=(4&t[2])>>2,d=3&t[2],f=1,g=1,p=1,m=0;r+="."+e+"."+Kn(n)+s+"."+Kn(l)+"."+c+"."+h+u+d+"."+Kn(f)+"."+Kn(g)+"."+Kn(p)+"."+m;break}}return{codec:r,encrypted:s}}function Gn(t,e){const i=e+5;for(;128&t[e++]&&e<i;);return e}function Vn(t){return("0"+t.toString(16).toUpperCase()).slice(-2)}function Kn(t){return(t<10?"0":"")+t}function Hn(t){const e=Fn(t,["schm"])[0];if(e){const i=Dn(e.subarray(4,8));if("cbcs"===i||"cenc"===i)return Fn(t,["schi","tenc"])[0]}return Oi.error("[eme] missing 'schm' box"),null}function Yn(t){const e=On(t,0);let i=8;1&e&&(i+=4),4&e&&(i+=4);let n=0;const r=On(t,4);for(let s=0;s<r;s++){if(256&e){n+=On(t,i),i+=4}512&e&&(i+=4),1024&e&&(i+=4),2048&e&&(i+=4)}return n}function jn(t,e){const i=new Uint8Array(t.length+e.length);return i.set(t),i.set(e,t.length),i}function Wn(t,e){const i=[],n=e.samples,r=e.timescale,s=e.id;let a=!1;return Fn(n,["moof"]).map((o=>{const l=o.byteOffset-8;Fn(o,["traf"]).map((o=>{const c=Fn(o,["tfdt"]).map((t=>{const e=t[0];let i=On(t,4);return 1===e&&(i*=Math.pow(2,32),i+=On(t,8)),i/r}))[0];return void 0!==c&&(t=c),Fn(o,["tfhd"]).map((c=>{const h=On(c,4),u=16777215&On(c,0);let d=0;const f=0!=(16&u);let g=0;const p=0!=(32&u);let m=8;h===s&&(0!=(1&u)&&(m+=8),0!=(2&u)&&(m+=4),0!=(8&u)&&(d=On(c,m),m+=4),f&&(g=On(c,m),m+=4),p&&(m+=4),"video"===e.type&&(a=function(t){if(!t)return!1;const e=t.indexOf("."),i=e<0?t:t.substring(0,e);return"hvc1"===i||"hev1"===i||"dvh1"===i||"dvhe"===i}(e.codec)),Fn(o,["trun"]).map((s=>{const o=s[0],c=16777215&On(s,0),h=0!=(1&c);let u=0;const f=0!=(4&c),p=0!=(256&c);let m=0;const v=0!=(512&c);let y=0;const A=0!=(1024&c),E=0!=(2048&c);let T=0;const b=On(s,4);let k=8;h&&(u=On(s,k),k+=4),f&&(k+=4);let S=u+l;for(let l=0;l<b;l++){if(p?(m=On(s,k),k+=4):m=d,v?(y=On(s,k),k+=4):y=g,A&&(k+=4),E&&(T=0===o?On(s,k):Nn(s,k),k+=4),e.type===Gi){let e=0;for(;e<y;){const s=On(n,S);if(S+=4,zn(a,n[S])){qn(n.subarray(S,S+s),a?2:1,t+T/r,i)}S+=s,e+=s+4}}t+=m/r}})))}))}))})),i}function zn(t,e){if(t){const t=e>>1&63;return 39===t||40===t}return 6===(31&e)}function qn(t,e,i,n){const r=Xn(t);let s=0;s+=e;let a=0,o=0,l=0;for(;s<r.length;){a=0;do{if(s>=r.length)break;l=r[s++],a+=l}while(255===l);o=0;do{if(s>=r.length)break;l=r[s++],o+=l}while(255===l);const t=r.length-s;let e=s;if(o<t)s+=o;else if(o>t){Oi.error(`Malformed SEI payload. ${o} is too small, only ${t} bytes left to parse.`);break}if(4===a){if(181===r[e++]){const t=Pn(r,e);if(e+=2,49===t){const t=On(r,e);if(e+=4,1195456820===t){const t=r[e++];if(3===t){const s=r[e++],o=64&s,l=o?2+3*(31&s):0,c=new Uint8Array(l);if(o){c[0]=s;for(let t=1;t<l;t++)c[t]=r[e++]}n.push({type:t,payloadType:a,pts:i,bytes:c})}}}}}else if(5===a&&o>16){const t=[];for(let i=0;i<16;i++){const n=r[e++].toString(16);t.push(1==n.length?"0"+n:n),3!==i&&5!==i&&7!==i&&9!==i||t.push("-")}const s=o-16,l=new Uint8Array(s);for(let t=0;t<s;t++)l[t]=r[e++];n.push({payloadType:a,pts:i,uuid:t.join(""),userData:Sn(l),userDataBytes:l})}}}function Xn(t){const e=t.byteLength,i=[];let n=1;for(;n<e-2;)0===t[n]&&0===t[n+1]&&3===t[n+2]?(i.push(n+2),n+=2):n++;if(0===i.length)return t;const r=e-i.length,s=new Uint8Array(r);let a=0;for(n=0;n<r;a++,n++)a===i[0]&&(a++,i.shift()),s[n]=t[a];return s}function Qn(t,e,i){if(16!==t.byteLength)throw new RangeError("Invalid system id");let n,r,s;if(e){n=1,r=new Uint8Array(16*e.length);for(let t=0;t<e.length;t++){const i=e[t];if(16!==i.byteLength)throw new RangeError("Invalid key");r.set(i,16*t)}}else n=0,r=new Uint8Array;n>0?(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 i&&i.byteLength>0&&new DataView(a.buffer).setUint32(0,i.byteLength,!1),function(t,...e){const i=e.length;let n=8,r=i;for(;r--;)n+=e[r].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),r=0,n=8;r<i;r++)s.set(e[r],n),n+=e[r].byteLength;return s}([112,115,115,104],new Uint8Array([n,0,0,0]),t,s,r,a,i||new Uint8Array)}let Zn={};class Jn{static clearKeyUriToKeyIdMap(){Zn={}}constructor(t,e,i,n=[1],r=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=i,this.keyFormatVersions=n,this.iv=r,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Ji:case en:case tn:case Zi:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof t&&("AES-128"!==this.method||this.iv||Oi.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const e=function(t){const e=new Uint8Array(16);for(let i=12;i<16;i++)e[i]=t>>8*(15-i)&255;return e}(t);return new Jn(this.method,this.uri,"identity",this.keyFormatVersions,e)}const e=zi(this.uri);if(e)switch(this.keyFormat){case en:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case tn:{const t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Qn(t,null,e);const i=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=String.fromCharCode.apply(null,Array.from(i)),r=n.substring(n.indexOf("<"),n.length),s=(new DOMParser).parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(s){const t=s.childNodes[0]?s.childNodes[0].nodeValue:s.getAttribute("VALUE");if(t){const e=Wi(t).subarray(0,16);!function(t){const e=function(t,e,i){const n=t[e];t[e]=t[i],t[i]=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=Zn[this.uri];if(!t){const e=Object.keys(Zn).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16);new DataView(t.buffer,12,4).setUint32(0,e),Zn[this.uri]=t}this.keyId=t}return this}}const tr=/\{\$([a-zA-Z0-9-_]+)\}/g;function er(t){return tr.test(t)}function ir(t,e,i){if(null!==t.variableList||t.hasVariableRefs)for(let n=i.length;n--;){const r=i[n],s=e[r];s&&(e[r]=nr(t,s))}}function nr(t,e){if(null!==t.variableList||t.hasVariableRefs){const i=t.variableList;return e.replace(tr,(e=>{const n=e.substring(2,e.length-1),r=null==i?void 0:i[n];return void 0===r?(t.playlistParsingError||(t.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),e):r}))}return e}function rr(t,e,i){let n,r,s=t.variableList;if(s||(t.variableList=s={}),"QUERYPARAM"in e){n=e.QUERYPARAM;try{const t=new self.URL(i).searchParams;if(!t.has(n))throw new Error(`"${n}" does not match any query parameter in URI: "${i}"`);r=t.get(n)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${e.message}`))}}else n=e.NAME,r=e.VALUE;n in s?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):s[n]=r||""}function sr(t,e,i){const n=e.IMPORT;if(i&&n in i){let e=t.variableList;e||(t.variableList=e={}),e[n]=i[n]}else t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${n}"`))}function ar(t=!0){if("undefined"==typeof self)return;return(t||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}const or={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 lr(t,e,i=!0){return!t.split(",").some((t=>!cr(t,e,i)))}function cr(t,e,i=!0){var n;const r=ar(i);return null!=(n=null==r?void 0:r.isTypeSupported(hr(t,e)))&&n}function hr(t,e){return`${e}/mp4;codecs="${t}"`}function ur(t){if(t){const e=t.substring(0,4);return or.video[e]}return 2}function dr(t){return t.split(",").reduce(((t,e)=>{const i=or.video[e];return i?(2*i+t)/(t?3:2):(or.audio[e]+t)/(t?2:1)}),0)}const fr={};const gr=/flac|opus/i;function pr(t,e=!0){return t.replace(gr,(t=>function(t,e=!0){if(fr[t])return fr[t];const i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[t];for(let n=0;n<i.length;n++)if(cr(i[n],"audio",e))return fr[t]=i[n],i[n];return t}(t.toLowerCase(),e)))}function mr(t,e){return t&&"mp4a"!==t?t:e?e.split(",")[0]:e}const vr=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,yr=/#EXT-X-MEDIA:(.*)/g,Ar=/^#EXT(?:INF|-X-TARGETDURATION):/m,Er=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Tr=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class br{static findGroup(t,e){for(let i=0;i<t.length;i++){const n=t[i];if(n.id===e)return n}}static resolve(t,e){return vi.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Ar.test(t)}static parseMasterPlaylist(t,e){const i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:er(t)},n=[];let r;for(vr.lastIndex=0;null!=(r=vr.exec(t));)if(r[1]){var s;const t=new Mi(r[1]);ir(i,t,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const a=nr(i,r[2]),o={attrs:t,bitrate:t.decimalInteger("BANDWIDTH")||t.decimalInteger("AVERAGE-BANDWIDTH"),name:t.NAME,url:br.resolve(a,e)},l=t.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),_r(t.CODECS,o),null!=(s=o.unknownCodecs)&&s.length||n.push(o),i.levels.push(o)}else if(r[3]){const t=r[3],n=r[4];switch(t){case"SESSION-DATA":{const t=new Mi(n);ir(i,t,["DATA-ID","LANGUAGE","VALUE","URI"]);const e=t["DATA-ID"];e&&(null===i.sessionData&&(i.sessionData={}),i.sessionData[e]=t);break}case"SESSION-KEY":{const t=kr(n,e,i);t.encrypted&&t.isSupported()?(null===i.sessionKeys&&(i.sessionKeys=[]),i.sessionKeys.push(t)):Oi.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${n}"`);break}case"DEFINE":{const t=new Mi(n);ir(i,t,["NAME","VALUE","QUERYPARAM"]),rr(i,t,e)}break;case"CONTENT-STEERING":{const t=new Mi(n);ir(i,t,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:br.resolve(t["SERVER-URI"],e),pathwayId:t["PATHWAY-ID"]||"."};break}case"START":i.startTimeOffset=Sr(n)}}const a=n.length>0&&n.length<i.levels.length;return i.levels=a?n:i.levels,0===i.levels.length&&(i.playlistParsingError=new Error("no levels found in manifest")),i}static parseMasterPlaylistMedia(t,e,i){let n;const r={},s=i.levels,a={AUDIO:s.map((t=>({id:t.attrs.AUDIO,audioCodec:t.audioCodec}))),SUBTITLES:s.map((t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec}))),"CLOSED-CAPTIONS":[]};let o=0;for(yr.lastIndex=0;null!==(n=yr.exec(t));){const t=new Mi(n[1]),s=t.TYPE;if(s){const n=a[s],l=r[s]||[];r[s]=l,ir(i,t,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const c=t.LANGUAGE,h=t["ASSOC-LANGUAGE"],u=t.CHANNELS,d=t.CHARACTERISTICS,f=t["INSTREAM-ID"],g={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?br.resolve(t.URI,e):""};if(h&&(g.assocLang=h),u&&(g.channels=u),d&&(g.characteristics=d),f&&(g.instreamId=f),null!=n&&n.length){const t=br.findGroup(n,g.groupId)||n[0];Lr(g,t,"audioCodec"),Lr(g,t,"textCodec")}l.push(g)}}return r}static parseLevelPlaylist(t,e,i,n,r,s){const a=new ji(e),o=a.fragments;let l,c,h,u=null,d=0,f=0,g=0,p=0,m=null,v=new Hi(n,e),y=-1,A=!1,E=null;for(Er.lastIndex=0,a.m3u8=t,a.hasVariableRefs=er(t);null!==(l=Er.exec(t));){A&&(A=!1,v=new Hi(n,e),v.start=g,v.sn=d,v.cc=p,v.level=i,u&&(v.initSegment=u,v.rawProgramDateTime=u.rawProgramDateTime,u.rawProgramDateTime=null,E&&(v.setByteRange(E),E=null)));const t=l[1];if(t){v.duration=parseFloat(t);const e=(" "+l[2]).slice(1);v.title=e||null,v.tagList.push(e?["INF",t,e]:["INF",t])}else if(l[3]){if(ki(v.duration)){v.start=g,h&&wr(v,h,a),v.sn=d,v.level=i,v.cc=p,o.push(v);const t=(" "+l[3]).slice(1);v.relurl=nr(a,t),Rr(v,m),m=v,g+=v.duration,d++,f=0,A=!0}}else if(l[4]){const t=(" "+l[4]).slice(1);m?v.setByteRange(t,m):v.setByteRange(t)}else if(l[5])v.rawProgramDateTime=(" "+l[5]).slice(1),v.tagList.push(["PROGRAM-DATE-TIME",v.rawProgramDateTime]),-1===y&&(y=o.length);else{if(l=l[0].match(Tr),!l){Oi.warn("No matches on slow regex match for level playlist!");continue}for(c=1;c<l.length&&void 0===l[c];c++);const t=(" "+l[c]).slice(1),r=(" "+l[c+1]).slice(1),g=l[c+2]?(" "+l[c+2]).slice(1):"";switch(t){case"PLAYLIST-TYPE":a.type=r.toUpperCase();break;case"MEDIA-SEQUENCE":d=a.startSN=parseInt(r);break;case"SKIP":{const t=new Mi(r);ir(a,t,["RECENTLY-REMOVED-DATERANGES"]);const e=t.decimalInteger("SKIPPED-SEGMENTS");if(ki(e)){a.skippedSegments=e;for(let t=e;t--;)o.unshift(null);d+=e}const i=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");i&&(a.recentlyRemovedDateranges=i.split("\t"));break}case"TARGETDURATION":a.targetduration=Math.max(parseInt(r),1);break;case"VERSION":a.version=parseInt(r);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"#":(r||g)&&v.tagList.push(g?[r,g]:[r]);break;case"DISCONTINUITY":p++,v.tagList.push(["DIS"]);break;case"GAP":v.gap=!0,v.tagList.push([t]);break;case"BITRATE":v.tagList.push([t,r]);break;case"DATERANGE":{const t=new Mi(r);ir(a,t,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ir(a,t,t.clientAttrs);const e=new Bi(t,a.dateRanges[t.ID]);e.isValid||a.skippedSegments?a.dateRanges[e.id]=e:Oi.warn(`Ignoring invalid DATERANGE tag: "${r}"`),v.tagList.push(["EXT-X-DATERANGE",r]);break}case"DEFINE":{const t=new Mi(r);ir(a,t,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in t?sr(a,t,s):rr(a,t,e)}break;case"DISCONTINUITY-SEQUENCE":p=parseInt(r);break;case"KEY":{const t=kr(r,e,a);if(t.isSupported()){if("NONE"===t.method){h=void 0;break}h||(h={}),h[t.keyFormat]&&(h=bi({},h)),h[t.keyFormat]=t}else Oi.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${r}"`);break}case"START":a.startTimeOffset=Sr(r);break;case"MAP":{const t=new Mi(r);if(ir(a,t,["BYTERANGE","URI"]),v.duration){const r=new Hi(n,e);Cr(r,t,i,h),u=r,v.initSegment=u,u.rawProgramDateTime&&!v.rawProgramDateTime&&(v.rawProgramDateTime=u.rawProgramDateTime)}else{const e=v.byteRangeEndOffset;if(e){const t=v.byteRangeStartOffset;E=`${e-t}@${t}`}else E=null;Cr(v,t,i,h),u=v,A=!0}break}case"SERVER-CONTROL":{const t=new Mi(r);a.canBlockReload=t.bool("CAN-BLOCK-RELOAD"),a.canSkipUntil=t.optionalFloat("CAN-SKIP-UNTIL",0),a.canSkipDateRanges=a.canSkipUntil>0&&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 Mi(r);a.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let t=a.partList;t||(t=a.partList=[]);const i=f>0?t[t.length-1]:void 0,n=f++,s=new Mi(r);ir(a,s,["BYTERANGE","URI"]);const o=new Yi(s,v,e,n,i);t.push(o),v.duration+=o.duration;break}case"PRELOAD-HINT":{const t=new Mi(r);ir(a,t,["URI"]),a.preloadHint=t;break}case"RENDITION-REPORT":{const t=new Mi(r);ir(a,t,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(t);break}default:Oi.warn(`line parsed but not handled: ${l}`)}}}m&&!m.relurl?(o.pop(),g-=m.duration,a.partList&&(a.fragmentHint=m)):a.partList&&(Rr(v,m),v.cc=p,a.fragmentHint=v,h&&wr(v,h,a));const T=o.length,b=o[0],k=o[T-1];if(g+=a.skippedSegments*a.targetduration,g>0&&T&&k){a.averagetargetduration=g/T;const t=k.sn;a.endSN="initSegment"!==t?t:0,a.live||(k.endList=!0),b&&(a.startCC=b.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(g+=a.fragmentHint.duration),a.totalduration=g,a.endCC=p,y>0&&function(t,e){let i=t[e];for(let n=e;n--;){const e=t[n];if(!e)return;e.programDateTime=i.programDateTime-1e3*e.duration,i=e}}(o,y),a}}function kr(t,e,i){var n,r;const s=new Mi(t);ir(i,s,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=null!=(n=s.METHOD)?n:"",o=s.URI,l=s.hexadecimalInteger("IV"),c=s.KEYFORMATVERSIONS,h=null!=(r=s.KEYFORMAT)?r:"identity";o&&s.IV&&!l&&Oi.error(`Invalid IV: ${s.IV}`);const u=o?br.resolve(o,e):"",d=(c||"1").split("/").map(Number).filter(Number.isFinite);return new Jn(a,u,h,d,l)}function Sr(t){const e=new Mi(t).decimalFloatingPoint("TIME-OFFSET");return ki(e)?e:null}function _r(t,e){let i=(t||"").split(/[ ,]+/).filter((t=>t));["video","audio","text"].forEach((t=>{const n=i.filter((e=>function(t,e){const i=or[e];return!!i&&!!i[t.slice(0,4)]}(e,t)));n.length&&(e[`${t}Codec`]=n.join(","),i=i.filter((t=>-1===n.indexOf(t))))})),e.unknownCodecs=i}function Lr(t,e,i){const n=e[i];n&&(t[i]=n)}function Rr(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),ki(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function Cr(t,e,i,n){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=i,t.sn="initSegment",n&&(t.levelkeys=n),t.initSegment=null}function wr(t,e,i){t.levelkeys=e;const{encryptedFragments:n}=i;n.length&&n[n.length-1].levelkeys===e||!Object.keys(e).some((t=>e[t].isCommonEncryption))||n.push(t)}var Ir="manifest",Dr="level",Pr="audioTrack",Or="subtitleTrack",xr="main",Nr="audio",Mr="subtitle";function Fr(t){const{type:e}=t;switch(e){case Pr:return Nr;case Or:return Mr;default:return xr}}function Br(t,e){let i=t.url;return void 0!==i&&0!==i.indexOf("data:")||(i=e.url),i}class Ur{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(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.LEVEL_LOADING,this.onLevelLoading,this),t.on(Li.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(Li.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.LEVEL_LOADING,this.onLevelLoading,this),t.off(Li.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(Li.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,i=e.pLoader,n=e.loader,r=new(i||n)(e);return this.loaders[t.type]=r,r}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:i}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ir,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:n,pathwayId:r,url:s,deliveryDirectives:a}=e;this.load({id:i,level:n,pathwayId:r,responseType:"text",type:Dr,url:s,deliveryDirectives:a})}onAudioTrackLoading(t,e){const{id:i,groupId:n,url:r,deliveryDirectives:s}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:Pr,url:r,deliveryDirectives:s})}onSubtitleTrackLoading(t,e){const{id:i,groupId:n,url:r,deliveryDirectives:s}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:Or,url:r,deliveryDirectives:s})}load(t){var e;const i=this.hls.config;let n,r=this.getInternalLoader(t);if(r){const e=r.context;if(e&&e.url===t.url&&e.level===t.level)return void Oi.trace("[playlist-loader]: playlist request ongoing");Oi.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),r.abort()}if(n=t.type===Ir?i.manifestLoadPolicy.default:bi({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(t),ki(null==(e=t.deliveryDirectives)?void 0:e.part)){let e;if(t.type===Dr&&null!==t.level?e=this.hls.levels[t.level].details:t.type===Pr&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===Or&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e){const t=e.partTarget,i=e.targetduration;if(t&&i){const e=1e3*Math.max(3*t,.8*i);n=bi({},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,i,n)=>{const r=this.getInternalLoader(i);this.resetInternalLoader(i.type);const s=t.data;0===s.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),br.isMediaPlaylist(s)?this.handleTrackOrLevelPlaylist(t,e,i,n||null,r):this.handleMasterPlaylist(t,e,i,n)):this.handleManifestParsingError(t,i,new Error("no EXTM3U delimiter"),n||null,e)},onError:(t,e,i,n)=>{this.handleNetworkError(e,i,!1,t,n)},onTimeout:(t,e,i)=>{this.handleNetworkError(e,i,!0,void 0,t)}};r.load(t,a,o)}handleMasterPlaylist(t,e,i,n){const r=this.hls,s=t.data,a=Br(t,i),o=br.parseMasterPlaylist(s,a);if(o.playlistParsingError)return void this.handleManifestParsingError(t,i,o.playlistParsingError,n,e);const{contentSteering:l,levels:c,sessionData:h,sessionKeys:u,startTimeOffset:d,variableList:f}=o;this.variableList=f;const{AUDIO:g=[],SUBTITLES:p,"CLOSED-CAPTIONS":m}=br.parseMasterPlaylistMedia(s,a,o);if(g.length){g.some((t=>!t.url))||!c[0].audioCodec||c[0].attrs.AUDIO||(Oi.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Mi({}),bitrate:0,url:""}))}r.trigger(Li.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:p,captions:m,contentSteering:l,url:a,stats:e,networkDetails:n,sessionData:h,sessionKeys:u,startTimeOffset:d,variableList:f})}handleTrackOrLevelPlaylist(t,e,i,n,r){const s=this.hls,{id:a,level:o,type:l}=i,c=Br(t,i),h=ki(o)?o:ki(a)?a:0,u=Fr(i),d=br.parseLevelPlaylist(t.data,c,h,u,0,this.variableList);if(l===Ir){const t={attrs:new Mi({}),bitrate:0,details:d,name:"",url:c};s.trigger(Li.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(),i.levelDetails=d,this.handlePlaylistLoaded(d,t,e,i,n,r)}handleManifestParsingError(t,e,i,n,r){this.hls.trigger(Li.ERROR,{type:Ri.NETWORK_ERROR,details:Ci.MANIFEST_PARSING_ERROR,fatal:e.type===Ir,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:n,stats:r})}handleNetworkError(t,e,i=!1,n,r){let s=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${t.type}`;t.type===Dr?s+=`: ${t.level} id: ${t.id}`:t.type!==Pr&&t.type!==Or||(s+=` id: ${t.id} group-id: "${t.groupId}"`);const a=new Error(s);Oi.warn(`[playlist-loader]: ${s}`);let o=Ci.UNKNOWN,l=!1;const c=this.getInternalLoader(t);switch(t.type){case Ir:o=i?Ci.MANIFEST_LOAD_TIMEOUT:Ci.MANIFEST_LOAD_ERROR,l=!0;break;case Dr:o=i?Ci.LEVEL_LOAD_TIMEOUT:Ci.LEVEL_LOAD_ERROR,l=!1;break;case Pr:o=i?Ci.AUDIO_TRACK_LOAD_TIMEOUT:Ci.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Or:o=i?Ci.SUBTITLE_TRACK_LOAD_TIMEOUT:Ci.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(t.type);const h={type:Ri.NETWORK_ERROR,details:o,fatal:l,url:t.url,loader:c,context:t,error:a,networkDetails:e,stats:r};if(n){const i=(null==e?void 0:e.url)||t.url;h.response=Ai({url:i,data:void 0},n)}this.hls.trigger(Li.ERROR,h)}handlePlaylistLoaded(t,e,i,n,r,s){const a=this.hls,{type:o,level:l,id:c,groupId:h,deliveryDirectives:u}=n,d=Br(e,n),f=Fr(n),g="number"==typeof n.level&&f===xr?l:void 0;if(!t.fragments.length){const t=new Error("No Segments found in Playlist");return void a.trigger(Li.ERROR,{type:Ri.NETWORK_ERROR,details:Ci.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:t,reason:t.message,response:e,context:n,level:g,parent:f,networkDetails:r,stats:i})}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const p=t.playlistParsingError;if(p)a.trigger(Li.ERROR,{type:Ri.NETWORK_ERROR,details:Ci.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:p,reason:p.message,response:e,context:n,level:g,parent:f,networkDetails:r,stats:i});else switch(t.live&&s&&(s.getCacheAge&&(t.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case Ir:case Dr:a.trigger(Li.LEVEL_LOADED,{details:t,level:g||0,id:c||0,stats:i,networkDetails:r,deliveryDirectives:u});break;case Pr:a.trigger(Li.AUDIO_TRACK_LOADED,{details:t,id:c||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:u});break;case Or:a.trigger(Li.SUBTITLE_TRACK_LOADED,{details:t,id:c||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:u})}}}function $r(t,e){let i;try{i=new Event("addtrack")}catch(t){i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=t,e.dispatchEvent(i)}function Gr(t,e){const i=t.mode;if("disabled"===i&&(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(i){Oi.debug(`[texttrack-utils]: ${i}`);try{const i=new self.TextTrackCue(e.startTime,e.endTime,e.text);i.id=e.id,t.addCue(i)}catch(t){Oi.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${t}`)}}"disabled"===i&&(t.mode=i)}function Vr(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 Kr(t,e,i,n){const r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&t.cues.length>0){const r=function(t,e,i){const n=[],r=function(t,e){if(e<t[0].startTime)return 0;const i=t.length-1;if(e>t[i].endTime)return-1;let n=0,r=i;for(;n<=r;){const s=Math.floor((r+n)/2);if(e<t[s].startTime)r=s-1;else{if(!(e>t[s].startTime&&n<i))return s;n=s+1}}return t[n].startTime-e<e-t[r].startTime?n:r}(t,e);if(r>-1)for(let s=r,a=t.length;s<a;s++){const r=t[s];if(r.startTime>=e&&r.endTime<=i)n.push(r);else if(r.startTime>i)return n}return n}(t.cues,e,i);for(let e=0;e<r.length;e++)n&&!n(r[e])||t.removeCue(r[e])}"disabled"===r&&(t.mode=r)}function Hr(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i];"subtitles"!==n.kind&&"captions"!==n.kind||!n.label||e.push(t[i])}return e}var Yr="org.id3",jr="com.apple.quicktime.HLS",Wr="https://aomedia.org/emsg/ID3";function zr(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function qr(t,e,i,n,r){let s=new t(e,i,"");try{s.value=n,r&&(s.type=r)}catch(a){s=new t(e,i,JSON.stringify(r?Ai({type:r},n):n))}return s}const Xr=(()=>{const t=zr();try{t&&new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Qr(t,e){return t.getTime()/1e3-e}class Zr{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(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Li.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Li.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Vr(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;e<t.length;e++){const i=t[e];if("metadata"===i.kind&&"id3"===i.label)return $r(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:n}}}=this;if(!i&&!n)return;const{samples:r}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const s=zr();if(s)for(let t=0;t<r.length;t++){const e=r[t].type;if(e===Wr&&!i||!n)continue;const a=yn(r[t].data);if(a){const i=r[t].pts;let n=i+r[t].duration;n>Xr&&(n=Xr);n-i<=0&&(n=i+.25);for(let t=0;t<a.length;t++){const r=a[t];if(!mn(r)){this.updateId3CueEnds(i,e);const t=qr(s,i,n,r,e);t&&this.id3Track.addCue(t)}}}}}updateId3CueEnds(t,e){var i;const n=null==(i=this.id3Track)?void 0:i.cues;if(n)for(let i=n.length;i--;){const r=n[i];r.type===e&&r.startTime<t&&r.endTime===Xr&&(r.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:n}){const{id3Track:r,hls:s}=this;if(!s)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=s;if(r&&(a||o)){let t;t="audio"===n?t=>t.type===Yr&&o:"video"===n?t=>t.type===Wr&&a:t=>t.type===Yr&&o||t.type===Wr&&a,Kr(r,e,i,t)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:n}=this,{dateRanges:r}=e,s=Object.keys(r);if(n){const t=Object.keys(i).filter((t=>!s.includes(t)));for(let e=t.length;e--;){const r=t[e];Object.keys(i[r].cues).forEach((t=>{n.removeCue(i[r].cues[t])})),delete i[r]}}const a=e.fragments[e.fragments.length-1];if(0===s.length||!ki(null==a?void 0:a.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const o=a.programDateTime/1e3-a.start,l=zr();for(let t=0;t<s.length;t++){const e=s[t],n=r[e],a=Qr(n.startDate,o),u=i[e],d=(null==u?void 0:u.cues)||{};let f=(null==u?void 0:u.durationKnown)||!1,g=Xr;const p=n.endDate;if(p)g=Qr(p,o),f=!0;else if(n.endOnNext&&!f){const t=s.reduce(((t,e)=>{if(e!==n.id){const i=r[e];if(i.class===n.class&&i.startDate>n.startDate&&(!t||n.startDate<t.startDate))return i}return t}),null);t&&(g=Qr(t.startDate,o),f=!0)}const m=Object.keys(n.attr);for(let t=0;t<m.length;t++){const i=m[t];if("ID"===(h=i)||"CLASS"===h||"START-DATE"===h||"DURATION"===h||"END-DATE"===h||"END-ON-NEXT"===h)continue;const r=d[i];if(r)f&&!u.durationKnown&&(r.endTime=g);else if(l){let t=n.attr[i];Fi(i)&&(c=t,t=Uint8Array.from(c.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);const r=qr(l,a,g,{key:i,data:t},jr);r&&(r.id=e,this.id3Track.addCue(r),d[i]=r)}}i[e]={cues:d,dateRange:n,durationKnown:f}}var c,h}}class Jr{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.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:i,targetduration:n}=t,{liveSyncDuration:r,liveSyncDurationCount:s,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&i||e;(o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:s*n);const c=n;return l+Math.min(1*this.stallCount,c)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,i=this.levelDetails;if(null===t||null===e||null===i)return null;const n=i.edge,r=t-e-this.edgeStalled,s=n-i.totalduration,a=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(s,r),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 i=t.buffered.length;return(i?t.buffered.end(i-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(Li.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Li.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(Li.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Li.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(Li.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 i;e.details===Ci.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(i=this.levelDetails)&&i.live&&Oi.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 i=this.computeLatency();if(null===i)return;this._latency=i;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:r}=this.config;if(!n||1===r||!e.live)return;const s=this.targetLatency;if(null===s)return;const a=i-s;if(a<Math.min(this.maxLatency,s+e.targetduration)&&a>.05&&this.forwardBufferLength>1){const e=Math.min(2,Math.max(1,r)),i=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;t.playbackRate=Math.min(e,Math.max(1,i))}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 ts=["NONE","TYPE-0","TYPE-1",null];const es=["SDR","PQ","HLG"];var is="",ns="YES",rs="v2";function ss(t){const{canSkipUntil:e,canSkipDateRanges:i,age:n}=t;return e&&n<e/2?i?rs:ns:is}class as{constructor(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}addDirectives(t){const e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class os{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter((t=>!!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 ls(this._audioGroups,t)}hasSubtitleGroup(t){return ls(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 ls(t,e){return!(!e||!t)&&-1!==t.indexOf(e)}function cs(t,e){const i=e.startPTS;if(ki(i)){let n,r=0;e.sn>t.sn?(r=i-t.start,n=t):(r=t.start-i,n=e),n.duration!==r&&(n.duration=r)}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 hs(t,e,i,n,r,s){n-i<=0&&(Oi.warn("Fragment should have a positive duration",e),n=i+e.duration,s=r+e.duration);let a=i,o=n;const l=e.startPTS,c=e.endPTS;if(ki(l)){const t=Math.abs(l-i);ki(e.deltaPTS)?e.deltaPTS=Math.max(t,e.deltaPTS):e.deltaPTS=t,a=Math.max(i,l),i=Math.min(i,l),r=Math.min(r,e.startDTS),o=Math.min(n,c),n=Math.max(n,c),s=Math.max(s,e.endDTS)}const h=i-e.start;0!==e.start&&(e.start=i),e.duration=n-e.start,e.startPTS=i,e.maxStartPTS=a,e.startDTS=r,e.endPTS=n,e.minEndPTS=o,e.endDTS=s;const u=e.sn;if(!t||u<t.startSN||u>t.endSN)return 0;let d;const f=u-t.startSN,g=t.fragments;for(g[f]=e,d=f;d>0;d--)cs(g[d],g[d-1]);for(d=f;d<g.length-1;d++)cs(g[d],g[d+1]);return t.fragmentHint&&cs(g[g.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,h}function us(t,e){let i=null;const n=t.fragments;for(let t=n.length-1;t>=0;t--){const e=n[t].initSegment;if(e){i=e;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;let r,s=0;if(function(t,e,i){const n=e.skippedSegments,r=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=r;t<=s;t++){const r=l[a+t];let s=o[t];n&&!s&&t<n&&(s=e.fragments[t]=r),r&&s&&i(r,s)}}(t,e,((t,n)=>{t.relurl&&(s=t.cc-n.cc),ki(t.startPTS)&&ki(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&&(r=n),e.PTSKnown=e.alignedSliding=!0),n.elementaryStreams=t.elementaryStreams,n.loader=t.loader,n.stats=t.stats,t.initSegment&&(n.initSegment=t.initSegment,i=t.initSegment)})),i){(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((t=>{var e;!t||t.initSegment&&t.initSegment.relurl!==(null==(e=i)?void 0:e.relurl)||(t.initSegment=i)}))}if(e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some((t=>!t)),e.deltaUpdateFailed){Oi.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,i){const n=bi({},t);i&&i.forEach((t=>{delete n[t]}));return Object.keys(e).forEach((t=>{const i=new Bi(e[t].attr,n[t]);i.isValid?n[t]=i:Oi.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){Oi.warn("discontinuity sliding from playlist, take drift into account");for(let t=0;t<a.length;t++)a[t].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),function(t,e,i){if(t&&e){let n=0;for(let r=0,s=t.length;r<=s;r++){const s=t[r],a=e[r+n];s&&a&&s.index===a.index&&s.fragment.sn===a.fragment.sn?i(s,a):n--}}}(t.partList,e.partList,((t,e)=>{e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),r?hs(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):ds(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 ds(t,e){const i=e.startSN+e.skippedSegments-t.startSN,n=t.fragments;i<0||i>=n.length||fs(e,n[i].start)}function fs(t,e){if(e){const i=t.fragments;for(let n=t.skippedSegments;n<i.length;n++)i[n].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function gs(t,e,i){var n;return null!=t&&t.details?ps(null==(n=t.details)?void 0:n.partList,e,i):null}function ps(t,e,i){if(t)for(let n=t.length;n--;){const r=t[n];if(r.index===i&&r.fragment.sn===e)return r}return null}function ms(t){t.forEach(((t,e)=>{const{details:i}=t;null!=i&&i.fragments&&i.fragments.forEach((t=>{t.level=e}))}))}function vs(t){switch(t.details){case Ci.FRAG_LOAD_TIMEOUT:case Ci.KEY_LOAD_TIMEOUT:case Ci.LEVEL_LOAD_TIMEOUT:case Ci.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ys(t,e){const i=vs(e);return t.default[(i?"timeout":"error")+"Retry"]}function As(t,e){const i="linear"===t.backoff?1:Math.pow(2,e);return Math.min(i*t.retryDelayMs,t.maxRetryDelayMs)}function Es(t){return Ai(Ai({},t),{errorRetry:null,timeoutRetry:null})}function Ts(t,e,i,n){if(!t)return!1;const r=null==n?void 0:n.code,s=e<t.maxNumRetry&&(function(t){return 0===t&&!1===navigator.onLine||!!t&&(t<400||t>499)}(r)||!!i);return t.shouldRetry?t.shouldRetry(t,e,i,n,s):s}const bs=function(t,e){let i=0,n=t.length-1,r=null,s=null;for(;i<=n;){r=(i+n)/2|0,s=t[r];const a=e(s);if(a>0)i=r+1;else{if(!(a<0))return s;n=r-1}}return null};function ks(t,e,i=0,n=0,r=.005){let s=null;if(t){s=e[t.sn-e[0].sn+1]||null;const n=t.endDTS-i;n>0&&n<15e-7&&(i+=15e-7)}else 0===i&&0===e[0].start&&(s=e[0]);if(s&&((!t||t.level===s.level)&&0===Ss(i,n,s)||function(t,e,i){if(e&&0===e.start&&e.level<t.level&&(e.endPTS||0)>0){const n=e.tagList.reduce(((t,e)=>("INF"===e[0]&&(t+=parseFloat(e[1])),t)),i);return t.start<=n}return!1}(s,t,Math.min(r,n))))return s;const a=bs(e,Ss.bind(null,i,n));return!a||a===t&&s?s:a}function Ss(t=0,e=0,i){if(i.start<=t&&i.start+i.duration>t)return 0;const n=Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-n<=t?1:i.start-n>t&&i.start?-1:0}function _s(t,e,i){const n=1e3*Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-n>t}var Ls=0,Rs=2,Cs=3,ws=5,Is=0,Ds=1,Ps=2;class Os{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=Oi.log.bind(Oi,`${e}:`),this.warn=Oi.warn.bind(Oi,`${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,i){const n=null==e?void 0:e.renditionReports;if(n){let r=-1;for(let i=0;i<n.length;i++){const s=n[i];let a;try{a=new self.URL(s.URI,e.url).href}catch(t){Oi.warn(`Could not construct new URL for Rendition Report: ${t}`),a=s.URI||""}if(a===t){r=i;break}a===t.substring(0,a.length)&&(r=i)}if(-1!==r){const t=n[r],s=parseInt(t["LAST-MSN"])||(null==e?void 0:e.lastPartSn);let a=parseInt(t["LAST-PART"])||(null==e?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const t=Math.min(e.age-e.partTarget,e.targetduration);a>=0&&t>e.partTarget&&(a+=1)}const o=i&&ss(i);return new as(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,i){const{details:n,stats:r}=e,s=self.performance.now(),a=r.loading.first?Math.max(0,s-r.loading.first):0;if(n.advancedDateTime=Date.now()-a,n.live||null!=i&&i.live){if(n.reloaded(i),i&&this.log(`live playlist ${t} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),i&&n.fragments.length>0&&us(i,n),!this.canLoad||!n.live)return;let a,o,l;if(n.canBlockReload&&n.endSN&&n.advanced){const t=this.hls.config.lowLatencyMode,r=n.lastPartSn,s=n.endSN,c=n.lastPartIndex,h=r===s;-1!==c?(o=h?s+1:r,l=h?t?0:c:c+1):o=s+1;const u=n.age,d=u+n.ageHeader;let f=Math.min(d-n.partTarget,1.5*n.targetduration);if(f>0){if(i&&f>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.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 ${u.toFixed(2)}s goal: ${f} skip sn ${t} to part ${l}`)}n.tuneInGoal=f}if(a=this.getDeliveryDirectives(n,e.deliveryDirectives,o,l),t||!h)return void this.loadPlaylist(a)}else(n.canBlockReload||n.canSkipUntil)&&(a=this.getDeliveryDirectives(n,e.deliveryDirectives,o,l));const c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,u=function(t,e=1/0){let i=1e3*t.targetduration;if(t.updated){const n=t.fragments,r=4;if(n.length&&i*r>e){const t=1e3*n[n.length-1].duration;t<i&&(i=t)}}else i/=2;return Math.round(i)}(n,1e3*(n.edge-h));n.updated&&s>this.requestScheduled+u&&(this.requestScheduled=r.loading.start),void 0!==o&&n.canBlockReload?this.requestScheduled=r.loading.first+u-(1e3*n.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+u<s?this.requestScheduled=s:this.requestScheduled-s<=0&&(this.requestScheduled+=u);let d=this.requestScheduled-s;d=Math.max(0,d),this.log(`reload live playlist ${t} in ${Math.round(d)} ms`),this.timer=self.setTimeout((()=>this.loadPlaylist(a)),d)}else this.clearTimer()}getDeliveryDirectives(t,e,i,n){let r=ss(t);return null!=e&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,n=e.part,r=is),new as(i,n,r)}checkRetry(t){const e=t.details,i=vs(t),n=t.errorAction,{action:r,retryCount:s=0,retryConfig:a}=n||{},o=!!n&&!!a&&(r===ws||!n.resolved&&r===Rs);if(o){var l;if(this.requestScheduled=-1,s>=a.maxNumRetry)return!1;if(i&&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=As(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 xs{constructor(t,e=0,i=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_=i}sample(t,e){const i=Math.pow(this.alpha_,t);this.estimate_=e*(1-i)+i*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 Ns{constructor(t,e,i,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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new xs(t),this.fast_=new xs(e),this.defaultTTFB_=n,this.ttfb_=new xs(t)}update(t,e){const{slow_:i,fast_:n,ttfb_:r}=this;i.halfLife!==t&&(this.slow_=new xs(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.fast_=new xs(e,n.getEstimate(),n.getTotalWeight())),r.halfLife!==t&&(this.ttfb_=new xs(t,r.getEstimate(),r.getTotalWeight()))}sample(t,e){const i=(t=Math.max(t,this.minDelayMs_))/1e3,n=8*e/i;this.fast_.sample(i,n),this.slow_.sample(i,n)}sampleTTFB(t){const e=t/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(i,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 Ms={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},Fs={};function Bs(t,e,i,n,r,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 h=null;if(null!=a&&a.length)try{h=1===a.length&&a[0]?e.groups[a[0]].channels:a.reduce(((t,i)=>{if(i){const n=e.groups[i];if(!n)throw new Error(`Audio track group ${i} 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!==i||t.bitrate>Math.max(r,8e6))||!!h&&ki(c)&&Object.keys(h).some((t=>parseInt(t)>c))}function Us(t,e,i){const n=t.videoCodec,r=t.audioCodec;if(!n||!r||!i)return Promise.resolve(Ms);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:Ai(Ai({},s),{},{contentType:hr(t,"video")})})));return r&&t.audioGroups&&t.audioGroups.forEach((t=>{var i;t&&(null==(i=e.groups[t])||i.tracks.forEach((e=>{if(e.groupId===t){const t=e.channels||"",i=parseFloat(t);ki(i)&&i>2&&o.push.apply(o,r.split(",").map((t=>({type:"media-source",audio:{contentType:hr(t,"audio"),channels:""+i}}))))}})))})),Promise.all(o.map((t=>{const e=function(t){const{audio:e,video:i}=t,n=i||e;if(n){const t=n.contentType.split('"')[1];if(i)return`r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${t}_${Math.ceil(i.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${t}`}return""}(t);return Fs[e]||(Fs[e]=i.decodingInfo(t))}))).then((t=>({supported:!t.some((t=>!t.supported)),configurations:o,decodingInfoResults:t}))).catch((t=>({supported:!1,configurations:o,decodingInfoResults:[],error:t})))}function $s(t,e){let i=!1,n=[];return t&&(i="SDR"!==t,n=[t]),e&&(n=e.allowedVideoRanges||es.slice(0),i=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=i?n.filter((t=>"SDR"!==t)):["SDR"]),{preferHDR:i,allowedVideoRanges:n}}function Gs(t,e){Oi.log(`[abr] start candidates with "${t}" ignored because ${e}`)}function Vs(t,e,i){if("attrs"in t){const i=e.indexOf(t);if(-1!==i)return i}for(let n=0;n<e.length;n++){if(Ks(t,e[n],i))return n}return-1}function Ks(t,e,i){const{groupId:n,name:r,lang:s,assocLang:a,characteristics:o,default:l}=t,c=t.forced;return(void 0===n||e.groupId===n)&&(void 0===r||e.name===r)&&(void 0===s||e.lang===s)&&(void 0===s||e.assocLang===a)&&(void 0===l||e.default===l)&&(void 0===c||e.forced===c)&&(void 0===o||function(t,e=""){const i=t.split(","),n=e.split(",");return i.length===n.length&&!i.some((t=>-1===n.indexOf(t)))}(o,e.characteristics))&&(void 0===i||i(t,e))}function Hs(t,e){const{audioCodec:i,channels:n}=t;return!(void 0!==i&&(e.audioCodec||"").substring(0,4)!==i.substring(0,4)||void 0!==n&&n!==(e.channels||"2"))}function Ys(t,e,i){for(let n=e;n;n--)if(i(t[n]))return n;for(let n=e+1;n<t.length;n++)if(i(t[n]))return n;return-1}class js{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var Ws="NOT_LOADED",zs="APPENDING",qs="PARTIAL",Xs="OK";class Qs{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(Li.BUFFER_APPENDED,this.onBufferAppended,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.on(Li.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.BUFFER_APPENDED,this.onBufferAppended,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.off(Li.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const i=this.activePartLists[e];if(i)for(let e=i.length;e--;){const n=i[e];if(!n)break;const r=n.end;if(n.start<=t&&null!==r&&t<=r)return n}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,n=Object.keys(i);for(let r=n.length;r--;){const s=i[n[r]];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,i,n){this.timeRanges&&(this.timeRanges[t]=e);const r=(null==n?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach((n=>{const s=this.fragments[n];if(!s)return;if(r>=s.body.sn)return;if(!s.buffered&&!s.loaded)return void(s.body.type===i&&this.removeFragment(s.body));const a=s.range[t];a&&a.time.some((t=>{const i=!this.isTimeBuffered(t.startPTS,t.endPTS,e);return i&&this.removeFragment(s.body),i}))}))}detectPartialFragments(t){const e=this.timeRanges,{frag:i,part:n}=t;if(!e||"initSegment"===i.sn)return;const r=Js(i),s=this.fragments[r];if(!s||s.buffered&&i.gap)return;const a=!i.relurl;if(Object.keys(e).forEach((t=>{const r=i.elementaryStreams[t];if(!r)return;const o=e[t],l=a||!0===r.partial;s.range[t]=this.getBufferedTimes(i,n,l,o)})),s.loaded=null,Object.keys(s.range).length){s.buffered=!0;(s.body.endList=i.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),Zs(s)||this.removeParts(i.sn-1,i.type)}else this.removeFragment(s.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter((e=>e.fragment.sn>=t)))}fragBuffered(t,e){const i=Js(t);let n=this.fragments[i];!n&&e&&(n=this.fragments[i]={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,i,n){const r={time:[],partial:i},s=t.start,a=t.end,o=t.minEndPTS||a,l=t.maxStartPTS||s;for(let t=0;t<n.length;t++){const e=n.start(t)-this.bufferPadding,i=n.end(t)+this.bufferPadding;if(l>=e&&o<=i){r.time.push({startPTS:Math.max(s,n.start(t)),endPTS:Math.min(a,n.end(t))});break}if(s<i&&a>e){const e=Math.max(s,n.start(t)),i=Math.min(a,n.end(t));i>e&&(r.partial=!0,r.time.push({startPTS:e,endPTS:i}))}else if(a<=e)break}return r}getPartialFragment(t){let e,i,n,r=null,s=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach((l=>{const c=o[l];c&&Zs(c)&&(i=c.body.start-a,n=c.body.end+a,t>=i&&t<=n&&(e=Math.min(t-i,n-t),s<=e&&(r=c.body,s=e)))})),r}isEndListAppended(t){const e=this.endListFragments[t];return void 0!==e&&(e.buffered||Zs(e))}getState(t){const e=Js(t),i=this.fragments[e];return i?i.buffered?Zs(i)?qs:Xs:zs:Ws}isTimeBuffered(t,e,i){let n,r;for(let s=0;s<i.length;s++){if(n=i.start(s)-this.bufferPadding,r=i.end(s)+this.bufferPadding,t>=n&&e<=r)return!0;if(e<=n)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:n}=e;if("initSegment"===i.sn||i.bitrateTest)return;const r=n?null:e,s=Js(i);this.fragments[s]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:n,timeRanges:r}=e;if("initSegment"===i.sn)return;const s=i.type;if(n){let t=this.activePartLists[s];t||(this.activePartLists[s]=t=[]),t.push(n)}this.timeRanges=r,Object.keys(r).forEach((t=>{const e=r[t];this.detectEvictedFragments(t,e,s,n)}))}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Js(t);return!!this.fragments[e]}hasParts(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)}removeFragmentsInRange(t,e,i,n,r){n&&!this.hasGaps||Object.keys(this.fragments).forEach((s=>{const a=this.fragments[s];if(!a)return;const o=a.body;o.type!==i||n&&!o.gap||o.start<e&&o.end>t&&(a.buffered||r)&&this.removeFragment(o)}))}removeFragment(t){const e=Js(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const e=t.sn;this.activePartLists[t.type]=i.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 Zs(t){var e,i,n;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(i=t.range.audio)?void 0:i.partial)||(null==(n=t.range.audiovideo)?void 0:n.partial))}function Js(t){return`${t.type}_${t.level}_${t.sn}`}const ta={length:0,start:()=>0,end:()=>0};class ea{static isBuffered(t,e){try{if(t){const i=ea.getBuffered(t);for(let t=0;t<i.length;t++)if(e>=i.start(t)&&e<=i.end(t))return!0}}catch(t){}return!1}static bufferInfo(t,e,i){try{if(t){const n=ea.getBuffered(t),r=[];let s;for(s=0;s<n.length;s++)r.push({start:n.start(s),end:n.end(s)});return this.bufferedInfo(r,e,i)}}catch(t){}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,i){e=Math.max(0,e),t.sort((function(t,e){const i=t.start-e.start;return i||e.end-t.end}));let n=[];if(i)for(let e=0;e<t.length;e++){const r=n.length;if(r){const s=n[r-1].end;t[e].start-s<i?t[e].end>s&&(n[r-1].end=t[e].end):n.push(t[e])}else n.push(t[e])}else n=t;let r,s=0,a=e,o=e;for(let t=0;t<n.length;t++){const l=n[t].start,c=n[t].end;if(e+i>=l&&e<c)a=l,o=c,s=o-e;else if(e+i<l){r=l;break}}return{len:s,start:a||0,end:o||0,nextStart:r}}static getBuffered(t){try{return t.buffered}catch(t){return Oi.log("failed to get media.buffered",t),ta}}}class ia{constructor(t,e,i,n=0,r=-1,s=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=i,this.size=n,this.part=r,this.partial=s}}function na(t,e){for(let n=0,r=t.length;n<r;n++){var i;if((null==(i=t[n])?void 0:i.cc)===e)return t[n]}return null}function ra(t,e){if(t){const i=t.start+e;t.start=t.startPTS=i,t.endPTS=i+t.duration}}function sa(t,e){const i=e.fragments;for(let e=0,n=i.length;e<n;e++)ra(i[e],t);e.fragmentHint&&ra(e.fragmentHint,t),e.alignedSliding=!0}function aa(t,e,i){e&&(!function(t,e,i){if(function(t,e,i){return!(!e||!(i.endCC>i.startCC||t&&t.cc<i.startCC))}(t,i,e)){const t=function(t,e){const i=t.fragments,n=e.fragments;if(!n.length||!i.length)return void Oi.log("No fragments to align");const r=na(i,n[0].cc);if(r&&(!r||r.startPTS))return r;Oi.log("No frag in previous level to align on")}(i,e);t&&ki(t.start)&&(Oi.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),sa(t.start,e))}}(t,i,e),!i.alignedSliding&&e&&oa(i,e),i.alignedSliding||!e||i.skippedSegments||ds(e,i))}function oa(t,e){if(!t.hasProgramDateTime||!e.hasProgramDateTime)return;const i=t.fragments,n=e.fragments;if(!i.length||!n.length)return;let r,s;const a=Math.min(e.endCC,t.endCC);e.startCC<a&&t.startCC<a&&(r=na(n,a),s=na(i,a)),r&&s||(r=n[Math.floor(n.length/2)],s=na(i,r.cc)||i[Math.floor(i.length/2)]);const o=r.programDateTime,l=s.programDateTime;if(!o||!l)return;sa((l-o)/1e3-(s.start-r.start),t)}const la=Math.pow(2,17);class ca{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const i=t.url;if(!i)return Promise.reject(new da({type:Ri.NETWORK_ERROR,details:Ci.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();const n=this.config,r=n.fLoader,s=n.loader;return new Promise(((a,o)=>{if(this.loader&&this.loader.destroy(),t.gap){if(t.tagList.some((t=>"GAP"===t[0])))return void o(ua(t));t.gap=!1}const l=this.loader=t.loader=r?new r(n):new s(n),c=ha(t),h=Es(n.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:la};t.stats=l.stats,l.load(c,u,{onSuccess:(e,i,n,r)=>{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:r})},onError:(e,n,r,s)=>{this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Ai({url:i,data:void 0},e),error:new Error(`HTTP Error ${e.code} ${e.text}`),networkDetails:r,stats:s}))},onAbort:(e,i,n)=>{this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:n,stats:e}))},onTimeout:(e,i,n)=>{this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:n,stats:e}))},onProgress:(i,n,r,s)=>{e&&e({frag:t,part:null,payload:r,networkDetails:s})}})}))}loadPart(t,e,i){this.abort();const n=this.config,r=n.fLoader,s=n.loader;return new Promise(((a,o)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap)return void o(ua(t,e));const l=this.loader=t.loader=r?new r(n):new s(n),c=ha(t,e),h=Es(n.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:la};e.stats=l.stats,l.load(c,u,{onSuccess:(n,r,s,o)=>{this.resetLoader(t,l),this.updateStatsFromPart(t,e);const c={frag:t,part:e,payload:n.data,networkDetails:o};i(c),a(c)},onError:(i,n,r,s)=>{this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Ai({url:c.url,data:void 0},i),error:new Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:r,stats:s}))},onAbort:(i,n,r)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:r,stats:i}))},onTimeout:(i,n,r)=>{this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:r,stats:i}))}})}))}updateStatsFromPart(t,e){const i=t.stats,n=e.stats,r=n.total;if(i.loaded+=n.loaded,r){const n=Math.round(t.duration/e.duration),s=Math.min(Math.round(i.loaded/r),n),a=(n-s)*Math.round(i.loaded/s);i.total=i.loaded+a}else i.total=Math.max(i.loaded,i.total);const s=i.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 ha(t,e=null){const i=e||t,n={frag:t,part:e,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},r=i.byteRangeStartOffset,s=i.byteRangeEndOffset;if(ki(r)&&ki(s)){var a;let e=r,i=s;if("initSegment"===t.sn&&"AES-128"===(null==(a=t.decryptdata)?void 0:a.method)){const t=s-r;t%16&&(i=s+(16-t%16)),0!==r&&(n.resetIV=!0,e=r-16)}n.rangeStart=e,n.rangeEnd=i}return n}function ua(t,e){const i=new Error(`GAP ${t.gap?"tag":"attribute"} found`),n={type:Ri.MEDIA_ERROR,details:Ci.FRAG_GAP,fatal:!1,frag:t,error:i,networkDetails:null};return e&&(n.part=e),(e||t).stats.aborted=!0,new da(n)}class da extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class fa{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 ga{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 pa{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),i=new Uint32Array(4);for(let t=0;t<4;t++)i[t]=e.getUint32(4*t);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,n=i[0],r=i[1],s=i[2],a=i[3],o=this.invSubMix,l=o[0],c=o[1],h=o[2],u=o[3],d=new Uint32Array(256);let f=0,g=0,p=0;for(p=0;p<256;p++)d[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){let i=g^g<<1^g<<2^g<<3^g<<4;i=i>>>8^255&i^99,t[f]=i,e[i]=f;const o=d[f],p=d[o],m=d[p];let v=257*d[i]^16843008*i;n[f]=v<<24|v>>>8,r[f]=v<<16|v>>>16,s[f]=v<<8|v>>>24,a[f]=v,v=16843009*m^65537*p^257*o^16843008*f,l[i]=v<<24|v>>>8,c[i]=v<<16|v>>>16,h[i]=v<<8|v>>>24,u[i]=v,f?(f=o^d[d[d[m^o]]],g^=d[d[g]]):f=g=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,n=0;for(;n<e.length&&i;)i=e[n]===this.key[n],n++;if(i)return;this.key=e;const r=this.keySize=e.length;if(4!==r&&6!==r&&8!==r)throw new Error("Invalid aes key size="+r);const s=this.ksRows=4*(r+6+1);let a,o;const l=this.keySchedule=new Uint32Array(s),c=this.invKeySchedule=new Uint32Array(s),h=this.sBox,u=this.rcon,d=this.invSubMix,f=d[0],g=d[1],p=d[2],m=d[3];let v,y;for(a=0;a<s;a++)a<r?v=l[a]=e[a]:(y=v,a%r==0?(y=y<<8|y>>>24,y=h[y>>>24]<<24|h[y>>>16&255]<<16|h[y>>>8&255]<<8|h[255&y],y^=u[a/r|0]<<24):r>6&&a%r==4&&(y=h[y>>>24]<<24|h[y>>>16&255]<<16|h[y>>>8&255]<<8|h[255&y]),l[a]=v=(l[a-r]^y)>>>0);for(o=0;o<s;o++)a=s-o,y=3&o?l[a]:l[a-4],c[o]=o<4||a<=4?y:f[h[y>>>24]]^g[h[y>>>16&255]]^p[h[y>>>8&255]]^m[h[255&y]],c[o]=c[o]>>>0}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}decrypt(t,e,i){const n=this.keySize+6,r=this.invKeySchedule,s=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],c=a[2],h=a[3],u=this.uint8ArrayToUint32Array_(i);let d=u[0],f=u[1],g=u[2],p=u[3];const m=new Int32Array(t),v=new Int32Array(m.length);let y,A,E,T,b,k,S,_,L,R,C,w,I,D;const P=this.networkToHostOrderSwap;for(;e<m.length;){for(L=P(m[e]),R=P(m[e+1]),C=P(m[e+2]),w=P(m[e+3]),b=L^r[0],k=w^r[1],S=C^r[2],_=R^r[3],I=4,D=1;D<n;D++)y=o[b>>>24]^l[k>>16&255]^c[S>>8&255]^h[255&_]^r[I],A=o[k>>>24]^l[S>>16&255]^c[_>>8&255]^h[255&b]^r[I+1],E=o[S>>>24]^l[_>>16&255]^c[b>>8&255]^h[255&k]^r[I+2],T=o[_>>>24]^l[b>>16&255]^c[k>>8&255]^h[255&S]^r[I+3],b=y,k=A,S=E,_=T,I+=4;y=s[b>>>24]<<24^s[k>>16&255]<<16^s[S>>8&255]<<8^s[255&_]^r[I],A=s[k>>>24]<<24^s[S>>16&255]<<16^s[_>>8&255]<<8^s[255&b]^r[I+1],E=s[S>>>24]<<24^s[_>>16&255]<<16^s[b>>8&255]<<8^s[255&k]^r[I+2],T=s[_>>>24]<<24^s[b>>16&255]<<16^s[k>>8&255]<<8^s[255&S]^r[I+3],v[e]=P(y^d),v[e+1]=P(T^f),v[e+2]=P(E^g),v[e+3]=P(A^p),d=L,f=R,g=C,p=w,e+=4}return v.buffer}}class ma{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const t=self.crypto;t&&(this.subtle=t.subtle||t.webkitSubtle)}catch(t){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?function(t){const e=t.byteLength,i=e&&new DataView(t.buffer).getUint8(e-1);return i?cn(t,0,e-i):t}(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,i){return this.useSoftware?new Promise(((n,r)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const s=this.flush();s?n(s.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:n,currentResult:r,remainderData:s}=this;this.logOnce("JS AES decrypt"),s&&(t=jn(s,t),this.remainderData=null);const a=this.getValidChunk(t);if(!a.length)return null;n&&(i=n);let o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new pa),o.expandKey(e);const l=r;return this.currentResult=o.decrypt(a.buffer,0,i),this.currentIV=cn(a,-16).buffer,l||null}webCryptoDecrypt(t,e,i){if(this.key!==e||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(t,e,i));this.key=e,this.fastAesKey=new ga(this.subtle,e)}return this.fastAesKey.expandKey().then((e=>{if(!this.subtle)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new fa(this.subtle,new Uint8Array(i)).decrypt(t.buffer,e)})).catch((n=>(Oi.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(t,e,i))))}onWebCryptoError(t,e,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,i);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 i=t.length-t.length%16;return i!==t.length&&(e=cn(t,0,i),this.remainderData=cn(t,i)),e}logOnce(t){this.logEnabled&&(Oi.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const va=function(t){let e="";const i=t.length;for(let n=0;n<i;n++)e+=`[${t.start(n).toFixed(3)}-${t.end(n).toFixed(3)}]`;return e},ya="STOPPED",Aa="IDLE",Ea="KEY_LOADING",Ta="FRAG_LOADING",ba="FRAG_LOADING_WAITING_RETRY",ka="WAITING_TRACK",Sa="PARSING",_a="PARSED",La="ENDED",Ra="ERROR",Ca="WAITING_INIT_PTS",wa="WAITING_LEVEL";class Ia extends js{constructor(t,e,i,n,r){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=ya,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=r,this.logPrefix=n,this.log=Oi.log.bind(Oi,`${n}:`),this.warn=Oi.warn.bind(Oi,`${n}:`),this.hls=t,this.fragmentLoader=new ca(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new ma(t.config),t.on(Li.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ya}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const i=e.partList;if(null!=i&&i.length){const t=i[i.length-1];return ea.isBuffered(this.media,t.start+t.duration/2)}const n=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}getLevelDetails(){var t;if(this.levels&&null!==this.levelLastLoaded)return null==(t=this.levelLastLoaded)?void 0:t.details}onMediaAttached(t,e){const i=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const n=this.config;this.levels&&n.autoStartLoad&&this.state===ya&&this.startLoad(n.startPosition)}onMediaDetaching(){const t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:i,mediaBuffer:n,state:r}=this,s=i?i.currentTime:0,a=ea.bufferInfo(n||i,s,t.maxBufferHole);if(this.log(`media seeking to ${ki(s)?s.toFixed(3):s}, state: ${r}`),this.state===La)this.resetLoadingState();else if(e){const i=t.maxFragLookUpTolerance,n=e.start-i,r=e.start+e.duration+i;if(!a.len||r<a.start||n>a.end){const t=s>r;(s<n||t)&&(t&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(s,1/0,this.playlistType,!0),this.lastCurrentTime=s),this.loadedmetadata||a.len||(this.nextLoadPosition=this.startPosition=s),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(Li.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=ya,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,e,i){this._loadFragForPlayback(t,e,i)}_loadFragForPlayback(t,e,i){this._doFragLoad(t,e,i,(e=>{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 i=this.state;this.fragContextChanged(t)?(i===Ta||!this.fragCurrent&&i===Sa)&&(this.fragmentTracker.removeFragment(t),this.state=Aa):("payload"in e&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(Li.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))})).catch((e=>{this.state!==ya&&this.state!==Ra&&(this.warn(`Frag error: ${(null==e?void 0:e.message)||e}`),this.resetFragmentLoading(t))}))}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===zs){const e=t.type,n=this.getFwdBufferInfo(this.mediaBuffer,e),r=Math.max(t.duration,n?n.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?t.sn-s.sn:0)||this.reduceMaxBufferLength(r,t.duration))&&i.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===qs&&i.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,i=null){if(!(t-e))return;const n={startOffset:t,endOffset:e,type:i};this.hls.trigger(Li.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:i}=this,{payload:n}=e,r=t.decryptdata;if(n&&n.byteLength>0&&null!=r&&r.key&&r.iv&&"AES-128"===r.method){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),r.key.buffer,r.iv.buffer).catch((e=>{throw i.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((n=>{const r=self.performance.now();return i.trigger(Li.FRAG_DECRYPTED,{frag:t,payload:n,stats:{tstart:s,tdecrypt:r}}),e.payload=n,this.completeInitSegmentLoad(e)}))}return this.completeInitSegmentLoad(e)})).catch((e=>{this.state!==ya&&this.state!==Ra&&(this.warn(e),this.resetFragmentLoading(t))}))}completeInitSegmentLoad(t){const{levels:e}=this;if(!e)throw new Error("init load aborted, missing levels");const i=t.frag.stats;this.state=Aa,t.frag.data=new Uint8Array(t.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.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 i,n,r,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===xr?"level":"track"} ${t.level} (frag:[${(null!=(i=t.startPTS)?i:NaN).toFixed(3)}-${(null!=(n=t.endPTS)?n:NaN).toFixed(3)}] > buffer:${a?va(ea.getBuffered(a)):"(detached)"})`),"initSegment"!==t.sn){var o;if(t.type!==Mr){const e=t.elementaryStreams;if(!Object.keys(e).some((t=>!!e[t])))return void(this.state=Aa)}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=Aa,a&&(!this.loadedmetadata&&t.type==xr&&a.buffered.length&&(null==(r=this.fragCurrent)?void 0:r.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:i,part:n,partsLoaded:r}=t,s=!r||0===r.length||r.some((t=>!t)),a=new ia(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!s);e.flush(a)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,n){var r;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!=(r=t.decryptdata)&&r.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=Ea,this.fragCurrent=t,a=this.keyLoader.load(t).then((t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger(Li.KEY_LOADED,t),this.state===Ea&&(this.state=Aa),t})),this.hls.trigger(Li.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(a=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){const r=s.partList;if(r&&n){i>t.end&&s.fragmentHint&&(t=s.fragmentHint);const o=this.getNextPart(r,t,i);if(o>-1){const l=r[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}-${r.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=Ta,c=a?a.then((i=>!i||this.fragContextChanged(i.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(Li.FRAG_LOADING,{frag:t,part:l,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!t.url||this.loadedEndOfParts(r,i))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(i.toFixed(3))}`),ki(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Ta;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(Li.FRAG_LOADING,{frag:t,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):l}doFragPartsLoad(t,e,i,n){return new Promise(((r,s)=>{var a;const o=[],l=null==(a=i.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(Li.FRAG_LOADED,n);const a=gs(i,t.sn,e.index+1)||ps(l,t.sn,e.index+1);if(!a)return r({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===Ci.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(Li.ERROR,e)}else this.hls.trigger(Li.ERROR,{type:Ri.OTHER_ERROR,details:Ci.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Sa)return void(this.fragCurrent||this.state===ya||this.state===Ra||(this.state=Aa));const{frag:i,part:n,level:r}=e,s=self.performance.now();i.stats.parsing.end=s,n&&(n.stats.parsing.end=s),this.updateLevelTiming(i,n,r,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:n,sn:r,part:s}=t;if(null==e||!e[n])return this.warn(`Levels object was unset while buffering fragment ${r} of level ${n}. The current chunk will not be buffered.`),null;const a=e[n],o=s>-1?gs(a,r,s):null,l=o?o.fragment:function(t,e,i){if(null==t||!t.details)return null;const n=t.details;let r=n.fragments[e-n.startSN];return r||(r=n.fragmentHint,r&&r.sn===e?r:e<n.startSN&&i&&i.sn===e?i:null)}(a,r,i);return l?(i&&i!==l&&(l.stats=i.stats),{frag:l,part:o,level:a}):null}bufferFragmentData(t,e,i,n,r){var s;if(!t||this.state!==Sa)return;const{data1:a,data2:o}=t;let l=a;if(a&&o&&(l=jn(a,o)),null==(s=l)||!s.length)return;const c={type:t.type,frag:e,part:i,chunkMeta:n,parent:e.type,data:l};if(this.hls.trigger(Li.BUFFER_APPENDING,c),t.dropped&&t.independent&&!i){if(r)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!ea.isBuffered(e,e.currentTime))return void this.flushMainBuffer(0,t.start);const i=e.currentTime,n=ea.bufferInfo(e,i,0),r=t.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),a=Math.max(Math.min(t.start-s,n.end-s),i+s);t.start-a>s&&this.flushMainBuffer(a,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return ki(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:n}}=this,r=ea.bufferInfo(t,e,n);if(0===r.len&&void 0!==r.nextStart){const s=this.fragmentTracker.getBufferedFrag(e,i);if(s&&r.nextStart<s.end)return ea.bufferInfo(t,e,Math.max(r.nextStart,n))}return r}getMaxBufferLength(t){const{config:e}=this;let i;return i=t?Math.max(8*e.maxBufferSize/t,e.maxBufferLength):e.maxBufferLength,Math.min(i,e.maxMaxBufferLength)}reduceMaxBufferLength(t,e){const i=this.config,n=Math.max(Math.min(t-e,i.maxBufferLength),e),r=Math.max(t-3*e,i.maxMaxBufferLength/2,n);return r>=n&&(i.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0)}getAppendedFrag(t,e=xr){const i=this.fragmentTracker.getAppendedFrag(t,xr);return i&&"fragment"in i?i.fragment:i}getNextFragment(t,e){const i=e.fragments,n=i.length;if(!n)return null;const{config:r}=this,s=i[0].start;let a;if(e.live){const o=r.initialLiveManifestSize;if(n<o)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${o})`),null;(!e.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||t<s)&&(a=this.getInitialLiveFragment(e,i),this.startPosition=this.nextLoadPosition=a?this.hls.liveSyncPosition||a.start:t)}else t<=s&&(a=i[0]);if(!a){const i=r.lowLatencyMode?e.partEnd:e.fragmentEnd;a=this.getFragmentAtPosition(t,i,e)}return this.mapToInitFragWhenRequired(a)}isLoopLoading(t,e){const i=this.fragmentTracker.getState(t);return(i===Xs||i===qs&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,n,r){const s=t.gap,a=this.getNextFragment(this.nextLoadPosition,e);if(null===a)return a;if(t=a,s&&t&&!t.gap&&i.nextStart){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n);if(null!==e&&i.len+e.len>=r)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,i){let n=-1,r=!1,s=!0;for(let a=0,o=t.length;a<o;a++){const o=t[a];if(s=s&&!o.independent,n>-1&&i<o.start)break;const l=o.loaded;l?n=-1:(r||o.independent||s)&&o.fragment===e&&(n=a),r=l}return n}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let n=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=function(t,e,i){if(null===e||!Array.isArray(t)||!t.length||!ki(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;i=i||0;for(let n=0;n<t.length;++n){const r=t[n];if(_s(e,i,r))return r}return null}(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const r=i.sn+1;if(r>=t.startSN&&r<=t.endSN){const s=e[r-t.startSN];i.cc===s.cc&&(n=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=function(t,e){return bs(t,(t=>t.cc<e?1:t.cc>e?-1:0))}(e,i.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,i){const{config:n}=this;let{fragPrevious:r}=this,{fragments:s,endSN:a}=i;const{fragmentHint:o}=i,{maxFragLookUpTolerance:l}=n,c=i.partList,h=!!(n.lowLatencyMode&&null!=c&&c.length&&o);let u;if(h&&o&&!this.bitrateTest&&(s=s.concat(o),a=o.sn),t<e){u=ks(r,s,t,t>e-l?0:l)}else u=s[s.length-1];if(u){const t=u.sn-i.startSN,e=this.fragmentTracker.getState(u);if((e===Xs||e===qs&&u.gap)&&(r=u),r&&u.sn===r.sn&&(!h||c[0].fragment.sn>u.sn)){if(r&&u.level===r.level){const e=s[t+1];u=u.sn<a&&this.fragmentTracker.getState(e)!==Xs?e:null}}}return u}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,r=i.currentTime,s=t.fragments[0].start,a=t.edge,o=r>=s-e.maxFragLookUpTolerance&&r<=a;if(null!==n&&i.duration>n&&(r<n||!o)){const s=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!o&&i.readyState<4||r<a-s)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${n.toFixed(3)}`),i.currentTime=n))}}alignPlaylists(t,e,i){const n=t.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;const r=t.fragments[0].start,s=!e,a=t.alignedSliding&&ki(r);if(s||!a&&!r){const{fragPrevious:r}=this;aa(r,i,t);const s=t.fragments[0].start;return this.log(`Live playlist sliding: ${s.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${r?r.sn:"na"} fragments: ${n}`),s}return r}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)}setStartPosition(t,e){let i=this.startPosition;if(i<e&&(i=-1),-1===i||-1===this.lastCurrentTime){const n=null!==this.startTimeOffset,r=n?this.startTimeOffset:t.startTimeOffset;null!==r&&ki(r)?(i=e+r,r<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log(`Start time offset ${r} found in ${n?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||e:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===ba)||(this.state=Aa)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const t=this.getCurrentContext(e.chunkMeta);t&&(e.frag=t.frag)}const i=e.frag;if(!i||i.type!==t||!this.levels)return;var n;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(n=this.fragCurrent)?void 0:n.url}`);const r=e.details===Ci.FRAG_GAP;r&&this.fragmentTracker.fragBuffered(i,!0);const s=e.errorAction,{action:a,retryCount:o=0,retryConfig:l}=s||{};if(s&&a===ws&&l){this.resetStartWhenNotLoaded(this.levelLastLoaded);const n=As(l,o);this.warn(`Fragment ${i.sn} of ${t} ${i.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=ba}else if(l&&s){if(this.resetFragmentErrors(t),!(o<l.maxNumRetry))return void Oi.warn(`${e.details} reached or exceeded max retry (${o})`);r||a===Cs||(s.resolved=!0)}else(null==s?void 0:s.action)===Rs?this.state=wa:this.state=Ra;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===Sa||this.state===_a){const e=t.frag,i=t.parent,n=this.getFwdBufferInfo(this.mediaBuffer,i),r=n&&n.len>.5;r&&this.reduceMaxBufferLength(n.len,(null==e?void 0:e.duration)||10);const s=!r;return s&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${i} buffer`),e&&(this.fragmentTracker.removeFragment(e),this.nextLoadPosition=e.start),this.resetLoadingState(),s}return!1}resetFragmentErrors(t){t===Nr&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ya&&(this.state=Aa)}afterBufferFlushed(t,e,i){if(!t)return;const n=ea.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,n,i),this.state===La&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Aa}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,i,n){var r;const s=i.details;if(!s)return void this.warn("level.details undefined");if(!Object.keys(t.elementaryStreams).reduce(((e,r)=>{const a=t.elementaryStreams[r];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${t.sn} ${r} duration reliably (${o})`),e||!1;const l=n?0:hs(s,t,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return this.hls.trigger(Li.LEVEL_PTS_UPDATED,{details:s,level:i,drift:l,type:r,frag:t,start:a.startPTS,end:a.endPTS}),!0}return e}),!1)&&null===(null==(r=this.transmuxer)?void 0:r.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===i.fragmentError&&(i.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(e.message),this.hls.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:t,reason:`Found no media in msn ${t.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=_a,this.hls.trigger(Li.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 Da{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let i;return t.length?(i=1===t.length?t[0]:function(t,e){const i=new Uint8Array(e);let n=0;for(let e=0;e<t.length;e++){const r=t[e];i.set(r,n),n+=r.length}return i}(t,e),this.reset(),i):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}function Pa(t="",e=9e4){return{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Oa{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,i){}demux(t,e){this.cachedData&&(t=jn(this.cachedData,t),this.cachedData=null);let i,n=dn(t,0),r=n?n.length:0;const s=this._audioTrack,a=this._id3Track,o=n?pn(n):void 0,l=t.length;for((null===this.basePTS||0===this.frameIndex&&ki(o))&&(this.basePTS=xa(o,e,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),n&&n.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:Yr,duration:Number.POSITIVE_INFINITY});r<l;){if(this.canParse(t,r)){const e=this.appendFrame(s,t,r);e?(this.frameIndex++,this.lastPTS=e.sample.pts,r+=e.length,i=r):r=l}else gn(t,r)?(n=dn(t,r),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:Yr,duration:Number.POSITIVE_INFINITY}),r+=n.length,i=r):r++;if(r===l&&i!==l){const e=cn(t,i);this.cachedData?this.cachedData=jn(this.cachedData,e):this.cachedData=e}}return{audioTrack:s,videoTrack:Pa(),id3Track:a,textTrack:Pa()}}demuxSampleAes(t,e,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Pa(),id3Track:this._id3Track,textTrack:Pa()}}destroy(){}}const xa=(t,e,i)=>{if(ki(t))return 90*t;return 9e4*e+(i?9e4*i.baseTime/i.timescale:0)};function Na(t,e){return 255===t[e]&&240==(246&t[e+1])}function Ma(t,e){return 1&t[e+1]?7:9}function Fa(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function Ba(t,e){return e+1<t.length&&Na(t,e)}function Ua(t,e){if(Ba(t,e)){const i=Ma(t,e);if(e+i>=t.length)return!1;const n=Fa(t,e);if(n<=i)return!1;const r=e+n;return r===t.length||Ba(t,r)}return!1}function $a(t,e,i,n,r){if(!t.samplerate){const s=function(t,e,i,n){let r,s,a,o;const l=navigator.userAgent.toLowerCase(),c=n,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=1+((192&e[i+2])>>>6);const u=(60&e[i+2])>>>2;if(!(u>h.length-1))return a=(1&e[i+2])<<2,a|=(192&e[i+3])>>>6,Oi.log(`manifest codec:${n}, ADTS type:${r}, samplingIndex:${u}`),/firefox/i.test(l)?u>=6?(r=5,o=new Array(4),s=u-3):(r=2,o=new Array(2),s=u):-1!==l.indexOf("android")?(r=2,o=new Array(2),s=u):(r=5,o=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&u>=6?s=u-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(u>=6&&1===a||/vivaldi/i.test(l))||!n&&1===a)&&(r=2,o=new Array(2)),s=u)),o[0]=r<<3,o[0]|=(14&u)>>1,o[1]|=(1&u)<<7,o[1]|=a<<3,5===r&&(o[1]|=(14&s)>>1,o[2]=(1&s)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[u],channelCount:a,codec:"mp4a.40."+r,manifestCodec:c};{const e=new Error(`invalid ADTS sampling index:${u}`);t.emit(Li.ERROR,Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_PARSING_ERROR,fatal:!0,error:e,reason:e.message})}}(e,i,n,r);if(!s)return;t.config=s.config,t.samplerate=s.samplerate,t.channelCount=s.channelCount,t.codec=s.codec,t.manifestCodec=s.manifestCodec,Oi.log(`parsed codec:${t.codec}, rate:${s.samplerate}, channels:${s.channelCount}`)}}function Ga(t){return 9216e4/t}function Va(t,e,i,n,r){const s=n+r*Ga(t.samplerate),a=function(t,e){const i=Ma(t,e);if(e+i<=t.length){const n=Fa(t,e)-i;if(n>0)return{headerLength:i,frameLength:n}}}(e,i);let o;if(a){const{frameLength:n,headerLength:r}=a,l=r+n,c=Math.max(0,i+l-e.length);c?(o=new Uint8Array(l-r),o.set(e.subarray(i+r,e.length),0)):o=e.subarray(i+r,i+l);const h={unit:o,pts:s};return c||t.samples.push(h),{sample:h,length:l,missing:c}}const l=e.length-i;o=new Uint8Array(l),o.set(e.subarray(i,e.length),0);return{sample:{unit:o,pts:s},length:l,missing:-1}}let Ka=null;const Ha=[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],Ya=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ja=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Wa=[0,1,1,4];function za(t,e,i,n,r){if(i+24>e.length)return;const s=qa(e,i);if(s&&i+s.frameLength<=e.length){const a=n+r*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:e.subarray(i,i+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 qa(t,e){const i=t[e+1]>>3&3,n=t[e+1]>>1&3,r=t[e+2]>>4&15,s=t[e+2]>>2&3;if(1!==i&&0!==r&&15!==r&&3!==s){const a=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*Ha[14*(3===i?3-n:3===n?3:4)+r-1],c=Ya[3*(3===i?0:2===i?1:2)+s],h=3===o?1:2,u=ja[i][n],d=Wa[n],f=8*u*d,g=Math.floor(u*l/c+a)*d;if(null===Ka){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ka=t?parseInt(t[1]):0}return!!Ka&&Ka<=87&&2===n&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:f}}}function Xa(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function Qa(t,e){return e+1<t.length&&Xa(t,e)}function Za(t,e){if(e+1<t.length&&Xa(t,e)){const i=4,n=qa(t,e);let r=i;null!=n&&n.frameLength&&(r=n.frameLength);const s=e+r;return s===t.length||Qa(t,s)}return!1}const Ja=/\/emsg[-/]ID3/i;const to=(t,e)=>{let i=0,n=5;e+=n;const r=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[0]=(a[0]&s[0])>>l,i=i?i<<o|r[0]:r[0],e+=1,n-=o}return i};class eo extends Oa{constructor(t){super(),this.observer=void 0,this.observer=t}resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}canParse(t,e){return e+64<t.length}appendFrame(t,e,i){const n=io(t,e,i,this.basePTS,this.frameIndex);if(-1!==n){return{sample:t.samples[t.samples.length-1],length:n,missing:0}}}static probe(t){if(!t)return!1;const e=dn(t,0);if(!e)return!1;const i=e.length;return 11===t[i]&&119===t[i+1]&&void 0!==pn(e)&&to(t,i)<16}}function io(t,e,i,n,r){if(i+8>e.length)return-1;if(11!==e[i]||119!==e[i+1])return-1;const s=e[i+4]>>6;if(s>=3)return-1;const a=[48e3,44100,32e3][s],o=63&e[i+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+s];if(i+l>e.length)return-1;const c=e[i+6]>>5;let h=0;2===c?h+=2:(1&c&&1!==c&&(h+=2),4&c&&(h+=2));const u=(e[i+6]<<8|e[i+7])>>12-h&1,d=[2,1,2,3,3,4,4,5][c]+u,f=e[i+5]>>3,g=7&e[i+5],p=new Uint8Array([s<<6|f<<1|g>>2,(3&g)<<6|c<<3|u<<2|o>>4,o<<4&224]),m=n+r*(1536/a*9e4),v=e.subarray(i,i+l);return t.config=p,t.channelCount=d,t.samplerate=a,t.samples.push({unit:v,pts:m}),l}class no{constructor(){this.VideoSample=null}createVideoSample(t,e,i,n){return{key:t,frame:!1,pts:e,dts:i,units:[],debug:n,length:0}}getLastNalUnit(t){var e;let i,n=this.VideoSample;if(n&&0!==n.units.length||(n=t[t.length-1]),null!=(e=n)&&e.units){const t=n.units;i=t[t.length-1]}return i}pushAccessUnit(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){const i=e.samples,n=i.length;if(!n)return void e.dropped++;{const e=i[n-1];t.pts=e.pts,t.dts=e.dts}}e.samples.push(t)}t.debug.length&&Oi.log(t.pts+"/"+t.dts+":"+t.debug)}}class ro{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,i=t.byteLength-e,n=new Uint8Array(4),r=Math.min(4,e);if(0===r)throw new Error("no bytes available");n.set(t.subarray(i,i+r)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*r,this.bytesAvailable-=r}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 i=this.word>>>32-e;if(t>32&&Oi.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?i<<e|this.readBits(e):i}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>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,i=8,n=8;for(let r=0;r<t;r++)0!==n&&(e=this.readEG(),n=(i+e+256)%256),i=0===n?i:n}readSPS(){let t,e,i,n=0,r=0,s=0,a=0;const o=this.readUByte.bind(this),l=this.readBits.bind(this),c=this.readUEG.bind(this),h=this.readBoolean.bind(this),u=this.skipBits.bind(this),d=this.skipEG.bind(this),f=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);o();const p=o();if(l(5),u(3),o(),f(),100===p||110===p||122===p||244===p||44===p||83===p||86===p||118===p||128===p){const t=c();if(3===t&&u(1),f(),f(),u(1),h())for(e=3!==t?8:12,i=0;i<e;i++)h()&&g(i<6?16:64)}f();const m=c();if(0===m)c();else if(1===m)for(u(1),d(),d(),t=c(),i=0;i<t;i++)d();f(),u(1);const v=c(),y=c(),A=l(1);0===A&&u(1),u(1),h()&&(n=c(),r=c(),s=c(),a=c());let E=[1,1];if(h()&&h()){switch(o()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[o()<<8|o(),o()<<8|o()]}}return{width:Math.ceil(16*(v+1)-2*n-2*r),height:(2-A)*(y+1)*16-(A?2:4)*(s+a),pixelRatio:E}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class so extends no{parseAVCPES(t,e,i,n,r){const s=this.parseAVCNALu(t,i.data);let a,o=this.VideoSample,l=!1;i.data=null,o&&s.length&&!t.audFound&&(this.pushAccessUnit(o,t),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts,"")),s.forEach((n=>{var s;switch(n.type){case 1:{let e=!1;a=!0;const r=n.data;if(l&&r.length>4){const t=new ro(r).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,i.pts,i.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,i.pts,i.dts,"")),o.key=!0,o.frame=!0;break;case 6:a=!0,qn(n.data,1,i.pts,e.samples);break;case 7:{var h,u;a=!0,l=!0;const e=n.data,i=new ro(e).readSPS();if(!t.sps||t.width!==i.width||t.height!==i.height||(null==(h=t.pixelRatio)?void 0:h[0])!==i.pixelRatio[0]||(null==(u=t.pixelRatio)?void 0:u[1])!==i.pixelRatio[1]){t.width=i.width,t.height=i.height,t.pixelRatio=i.pixelRatio,t.sps=[e],t.duration=r;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,i.pts,i.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 i=e.byteLength;let n=t.naluState||0;const r=n,s=[];let a,o,l,c=0,h=-1,u=0;for(-1===n&&(h=0,u=31&e[0],n=0,c=1);c<i;)if(a=e[c++],n)if(1!==n)if(a)if(1===a){if(o=c-n-1,h>=0){const t={data:e.subarray(h,o),type:u};s.push(t)}else{const i=this.getLastNalUnit(t.samples);i&&(r&&c<=4-r&&i.state&&(i.data=i.data.subarray(0,i.data.byteLength-r)),o>0&&(i.data=jn(i.data,e.subarray(0,o)),i.state=0))}c<i?(l=31&e[c],h=c,u=l,n=0):n=-1}else n=0;else n=3;else n=a?0:2;else n=a?0:1;if(h>=0&&n>=0){const t={data:e.subarray(h,i),type:u,state:n};s.push(t)}if(0===s.length){const i=this.getLastNalUnit(t.samples);i&&(i.data=jn(i.data,e))}return t.naluState=n,s}}class ao{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new ma(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const n=t[e].unit;if(n.length<=16)return;const r=n.subarray(16,n.length-n.length%16),s=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(s).then((r=>{const s=new Uint8Array(r);n.set(s,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,i)}))}decryptAacSamples(t,e,i){for(;;e++){if(e>=t.length)return void i();if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=16*Math.floor((t.length-48)/160)+16,i=new Int8Array(e);let n=0;for(let e=32;e<t.length-16;e+=160,n+=16)i.set(t.subarray(e,e+16),n);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let n=0;for(let e=32;e<t.length-16;e+=160,n+=16)t.set(i.subarray(n,n+16),e);return t}decryptAvcSample(t,e,i,n,r){const s=Xn(r.data),a=this.getAvcEncryptedData(s);this.decryptBuffer(a.buffer).then((a=>{r.data=this.getAvcDecryptedUnit(s,a),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,n)}))}decryptAvcSamples(t,e,i,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length)return void n();const r=t[e].units;for(;!(i>=r.length);i++){const s=r[i];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(t,e,i,n,s),this.decrypter.isSync())))return}}}}const oo=188;class lo{constructor(t,e,i){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=i,this.videoParser=new so}static probe(t){const e=lo.syncOffset(t);return e>0&&Oi.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),-1!==e}static syncOffset(t){const e=t.length;let i=Math.min(940,e-oo)+1,n=0;for(;n<i;){let r=!1,s=-1,a=0;for(let o=n;o<e;o+=oo){if(71!==t[o]||e-o!==oo&&71!==t[o+oo]){if(a)return-1;break}if(a++,-1===s&&(s=o,0!==s&&(i=Math.min(s+18612,t.length-oo)+1)),r||(r=0===co(t,o)),r&&a>1&&(0===s&&a>2||o+oo>i))return s}n++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:In[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}}resetInitSegment(t,e,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=lo.createTrack("video"),this._audioTrack=lo.createTrack("audio",n),this._id3Track=lo.createTrack("id3"),this._txtTrack=lo.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=n}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_videoTrack:e,_id3Track:i}=this;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(t,e,i=!1,n=!1){let r;i||(this.sampleAes=null);const s=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let c=s.pid,h=s.pesData,u=a.pid,d=o.pid,f=a.pesData,g=o.pesData,p=null,m=this.pmtParsed,v=this._pmtId,y=t.length;if(this.remainderData&&(y=(t=jn(this.remainderData,t)).length,this.remainderData=null),y<oo&&!n)return this.remainderData=t,{audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};const A=Math.max(0,lo.syncOffset(t));y-=(y-A)%oo,y<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,y,t.buffer.byteLength-y));let E=0;for(let e=A;e<y;e+=oo)if(71===t[e]){const n=!!(64&t[e+1]),y=co(t,e);let E;if((48&t[e+3])>>4>1){if(E=e+5+t[e+4],E===e+oo)continue}else E=e+4;switch(y){case c:n&&(h&&(r=po(h))&&this.videoParser.parseAVCPES(s,l,r,!1,this._duration),h={data:[],size:0}),h&&(h.data.push(t.subarray(E,e+oo)),h.size+=e+oo-E);break;case u:if(n){if(f&&(r=po(f)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,r);break;case"mp3":this.parseMPEGPES(a,r);break;case"ac3":this.parseAC3PES(a,r)}f={data:[],size:0}}f&&(f.data.push(t.subarray(E,e+oo)),f.size+=e+oo-E);break;case d:n&&(g&&(r=po(g))&&this.parseID3PES(o,r),g={data:[],size:0}),g&&(g.data.push(t.subarray(E,e+oo)),g.size+=e+oo-E);break;case 0:n&&(E+=t[E]+1),v=this._pmtId=ho(t,E);break;case v:{n&&(E+=t[E]+1);const r=uo(t,E,this.typeSupported,i,this.observer);c=r.videoPid,c>0&&(s.pid=c,s.segmentCodec=r.segmentVideoCodec),u=r.audioPid,u>0&&(a.pid=u,a.segmentCodec=r.segmentAudioCodec),d=r.id3Pid,d>0&&(o.pid=d),null===p||m||(Oi.warn(`MPEG-TS PMT found at ${e} after unknown PID '${p}'. Backtracking to sync byte @${A} to parse all TS packets.`),p=null,e=A-188),m=this.pmtParsed=!0;break}case 17:case 8191:break;default:p=y}}else E++;E>0&&fo(this.observer,new Error(`Found ${E} TS packet/s that do not start with 0x47`)),s.pesData=h,a.pesData=f,o.pesData=g;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:i,id3Track:n,textTrack:r}=t,s=i.pesData,a=e.pesData,o=n.pesData;let l;if(s&&(l=po(s))?(this.videoParser.parseAVCPES(i,r,l,!0,this._duration),i.pesData=null):i.pesData=s,a&&(l=po(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&&Oi.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=a;o&&(l=po(o))?(this.parseID3PES(n,l),n.pesData=null):n.pesData=o}demuxSampleAes(t,e,i){const n=this.demux(t,i,!0,!this.config.progressive),r=this.sampleAes=new ao(this.observer,this.config,e);return this.decrypt(n,r)}decrypt(t,e){return new Promise((i=>{const{audioTrack:n,videoTrack:r}=t;n.samples&&"aac"===n.segmentCodec?e.decryptAacSamples(n.samples,0,(()=>{r.samples?e.decryptAvcSamples(r.samples,0,0,(()=>{i(t)})):i(t)})):r.samples&&e.decryptAvcSamples(r.samples,0,0,(()=>{i(t)}))}))}destroy(){this._duration=0}parseAACPES(t,e){let i=0;const n=this.aacOverFlow;let r,s,a,o=e.data;if(n){this.aacOverFlow=null;const e=n.missing,r=n.sample.unit.byteLength;if(-1===e)o=jn(n.sample.unit,o);else{const s=r-e;n.sample.unit.set(o.subarray(0,e),s),t.samples.push(n.sample),i=n.missing}}for(r=i,s=o.length;r<s-1&&!Ba(o,r);r++);if(r!==i){let t;const e=r<s-1;if(t=e?`AAC PES did not start with ADTS header,offset:${r}`:"No ADTS header found in AAC PES",fo(this.observer,new Error(t),e),!e)return}if($a(t,this.observer,o,r,this.audioCodec),void 0!==e.pts)a=e.pts;else{if(!n)return void Oi.warn("[tsdemuxer]: AAC PES unknown PTS");{const e=Ga(t.samplerate);a=n.sample.pts+e}}let l,c=0;for(;r<s;){if(l=Va(t,o,r,a,c),r+=l.length,l.missing){this.aacOverFlow=l;break}for(c++;r<s-1&&!Ba(o,r);r++);}}parseMPEGPES(t,e){const i=e.data,n=i.length;let r=0,s=0;const a=e.pts;if(void 0!==a)for(;s<n;)if(Qa(i,s)){const e=za(t,i,s,a,r);if(!e)break;s+=e.length,r++}else s++;else Oi.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(t,e){{const i=e.data,n=e.pts;if(void 0===n)return void Oi.warn("[tsdemuxer]: AC3 PES unknown PTS");const r=i.length;let s,a=0,o=0;for(;o<r&&(s=io(t,i,o,n,a++))>0;)o+=s}}parseID3PES(t,e){if(void 0===e.pts)return void Oi.warn("[tsdemuxer]: ID3 PES unknown PTS");const i=bi({},e,{type:this._videoTrack?Wr:Yr,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function co(t,e){return((31&t[e+1])<<8)+t[e+2]}function ho(t,e){return(31&t[e+10])<<8|t[e+11]}function uo(t,e,i,n,r){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]);e<a;){const a=co(t,e),o=(15&t[e+3])<<8|t[e+4];switch(t[e]){case 207:if(!n){go("ADTS AAC");break}case 15:-1===s.audioPid&&(s.audioPid=a);break;case 21:-1===s.id3Pid&&(s.id3Pid=a);break;case 219:if(!n){go("H.264");break}case 27:-1===s.videoPid&&(s.videoPid=a,s.segmentVideoCodec="avc");break;case 3:case 4:i.mpeg||i.mp3?-1===s.audioPid&&(s.audioPid=a,s.segmentAudioCodec="mp3"):Oi.log("MPEG audio found, not supported in this browser");break;case 193:if(!n){go("AC-3");break}case 129:i.ac3?-1===s.audioPid&&(s.audioPid=a,s.segmentAudioCodec="ac3"):Oi.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&o>0){let n=e+5,r=o;for(;r>2;){if(106===t[n])!0!==i.ac3?Oi.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,r-=e}}break;case 194:case 135:return fo(r,new Error("Unsupported EC-3 in M2TS found")),s;case 36:return fo(r,new Error("Unsupported HEVC in M2TS found")),s}e+=o+5}return s}function fo(t,e,i){Oi.warn(`parsing error: ${e.message}`),t.emit(Li.ERROR,Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:e,reason:e.message})}function go(t){Oi.log(`${t} with AES-128-CBC encryption found in unencrypted stream`)}function po(t){let e,i,n,r,s,a=0;const o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=jn(o[0],o[1]),o.splice(1,1);e=o[0];if(1===(e[0]<<16)+(e[1]<<8)+e[2]){if(i=(e[4]<<8)+e[5],i&&i>t.size-6)return null;const l=e[7];192&l&&(r=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,r-s>54e5&&(Oi.warn(`${Math.round((r-s)/9e4)}s delta between PTS and DTS, align them`),r=s)):s=r),n=e[8];let c=n+9;if(t.size<=c)return null;t.size-=c;const h=new Uint8Array(t.size);for(let t=0,i=o.length;t<i;t++){e=o[t];let i=e.byteLength;if(c){if(c>i){c-=i;continue}e=e.subarray(c),i-=c,c=0}h.set(e,a),a+=i}return i&&(i-=n+3),{data:h,pts:r,dts:s,len:i}}return null}class mo{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 vo=Math.pow(2,32)-1;class yo{static init(){let t;for(t in yo.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:[]},yo.types)yo.types.hasOwnProperty(t)&&(yo.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]),i=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]);yo.HDLR_TYPES={video:e,audio:i};const n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);yo.STTS=yo.STSC=yo.STCO=r,yo.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),yo.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),yo.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),yo.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]);yo.FTYP=yo.box(yo.types.ftyp,s,o,s,a),yo.DINF=yo.box(yo.types.dinf,yo.box(yo.types.dref,n))}static box(t,...e){let i=8,n=e.length;const r=n;for(;n--;)i+=e[n].byteLength;const s=new Uint8Array(i);for(s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(t,4),n=0,i=8;n<r;n++)s.set(e[n],i),i+=e[n].byteLength;return s}static hdlr(t){return yo.box(yo.types.hdlr,yo.HDLR_TYPES[t])}static mdat(t){return yo.box(yo.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(vo+1)),n=Math.floor(e%(vo+1));return yo.box(yo.types.mdhd,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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))}static mdia(t){return yo.box(yo.types.mdia,yo.mdhd(t.timescale,t.duration),yo.hdlr(t.type),yo.minf(t))}static mfhd(t){return yo.box(yo.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?yo.box(yo.types.minf,yo.box(yo.types.smhd,yo.SMHD),yo.DINF,yo.stbl(t)):yo.box(yo.types.minf,yo.box(yo.types.vmhd,yo.VMHD),yo.DINF,yo.stbl(t))}static moof(t,e,i){return yo.box(yo.types.moof,yo.mfhd(t),yo.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=yo.trak(t[e]);return yo.box.apply(null,[yo.types.moov,yo.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(yo.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=yo.trex(t[e]);return yo.box.apply(null,[yo.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(vo+1)),n=Math.floor(e%(vo+1)),r=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,i>>24,i>>16&255,i>>8&255,255&i,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 yo.box(yo.types.mvhd,r)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let n,r;for(n=0;n<e.length;n++)r=e[n].flags,i[n+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return yo.box(yo.types.sdtp,i)}static stbl(t){return yo.box(yo.types.stbl,yo.stsd(t),yo.box(yo.types.stts,yo.STTS),yo.box(yo.types.stsc,yo.STSC),yo.box(yo.types.stsz,yo.STSZ),yo.box(yo.types.stco,yo.STCO))}static avc1(t){let e,i,n,r=[],s=[];for(e=0;e<t.sps.length;e++)i=t.sps[e],n=i.byteLength,r.push(n>>>8&255),r.push(255&n),r=r.concat(Array.prototype.slice.call(i));for(e=0;e<t.pps.length;e++)i=t.pps[e],n=i.byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));const a=yo.box(yo.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(s))),o=t.width,l=t.height,c=t.pixelRatio[0],h=t.pixelRatio[1];return yo.box(yo.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,yo.box(yo.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),yo.box(yo.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,h>>24,h>>16&255,h>>8&255,255&h])))}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 yo.box(yo.types.mp4a,yo.audioStsd(t),yo.box(yo.types.esds,yo.esds(t)))}static mp3(t){return yo.box(yo.types[".mp3"],yo.audioStsd(t))}static ac3(t){return yo.box(yo.types["ac-3"],yo.audioStsd(t),yo.box(yo.types.dac3,t.config))}static stsd(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?yo.box(yo.types.stsd,yo.STSD,yo.mp3(t)):"ac3"===t.segmentCodec?yo.box(yo.types.stsd,yo.STSD,yo.ac3(t)):yo.box(yo.types.stsd,yo.STSD,yo.mp4a(t)):yo.box(yo.types.stsd,yo.STSD,yo.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,n=t.width,r=t.height,s=Math.floor(i/(vo+1)),a=Math.floor(i%(vo+1));return yo.box(yo.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,r>>8&255,255&r,0,0]))}static traf(t,e){const i=yo.sdtp(t),n=t.id,r=Math.floor(e/(vo+1)),s=Math.floor(e%(vo+1));return yo.box(yo.types.traf,yo.box(yo.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),yo.box(yo.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,s>>24,s>>16&255,s>>8&255,255&s])),yo.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,yo.box(yo.types.trak,yo.tkhd(t),yo.mdia(t))}static trex(t){const e=t.id;return yo.box(yo.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 i=t.samples||[],n=i.length,r=12+16*n,s=new Uint8Array(r);let a,o,l,c,h,u;for(e+=8+r,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<n;a++)o=i[a],l=o.duration,c=o.size,h=o.flags,u=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*a);return yo.box(yo.types.trun,s)}static initSegment(t){yo.types||yo.init();const e=yo.moov(t);return jn(yo.FTYP,e)}}yo.types=void 0,yo.HDLR_TYPES=void 0,yo.STTS=void 0,yo.STSC=void 0,yo.STCO=void 0,yo.STSZ=void 0,yo.VMHD=void 0,yo.SMHD=void 0,yo.STSD=void 0,yo.FTYP=void 0,yo.DINF=void 0;const Ao=9e4;function Eo(t,e,i=1,n=!1){const r=t*e*i;return n?Math.round(r):r}function To(t,e=!1){return Eo(t,1e3,1/Ao,e)}let bo,ko=null,So=null;class _o{constructor(t,e,i,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=i,this.ISGenerated=!1,null===ko){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ko=t?parseInt(t[1]):0}if(null===So){const t=navigator.userAgent.match(/Safari\/(\d+)/i);So=t?parseInt(t[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(t){Oi.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){Oi.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){Oi.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(t){let e=!1;const i=t.reduce(((t,i)=>{const n=i.pts-t;return n<-4294967296?(e=!0,Lo(t,i.pts)):n>0?t:i.pts}),t[0].pts);return e&&Oi.debug("PTS rollover detected"),i}remux(t,e,i,n,r,s,a,o){let l,c,h,u,d,f,g=r,p=r;const m=t.pid>-1,v=e.pid>-1,y=e.samples.length,A=t.samples.length>0,E=a&&y>0||y>1;if((!m||A)&&(!v||E)||this.ISGenerated||a){if(this.ISGenerated){var T,b,k,S;const t=this.videoTrackConfig;!t||e.width===t.width&&e.height===t.height&&(null==(T=e.pixelRatio)?void 0:T[0])===(null==(b=t.pixelRatio)?void 0:b[0])&&(null==(k=e.pixelRatio)?void 0:k[1])===(null==(S=t.pixelRatio)?void 0:S[1])||this.resetInitSegment()}else h=this.generateIS(t,e,r,s);const i=this.isVideoContiguous;let n,a=-1;if(E&&(a=function(t){for(let e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples),!i&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,a>0){Oi.warn(`[mp4-remuxer]: Dropped ${a} out of ${y} video samples due to a missing keyframe`);const t=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(a),e.dropped+=a,p+=(e.samples[0].pts-t)/e.inputTimeScale,n=p}else-1===a&&(Oi.warn(`[mp4-remuxer]: No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(A&&E){const i=this.getVideoStartPts(e.samples),n=(Lo(t.samples[0].pts,i)-i)/e.inputTimeScale;g+=Math.max(0,n),p+=Math.max(0,-n)}if(A){if(t.samplerate||(Oi.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(t,e,r,s)),c=this.remuxAudio(t,g,this.isAudioContiguous,s,v||E||o===Nr?p:void 0),E){const n=c?c.endPTS-c.startPTS:0;e.inputTimeScale||(Oi.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(t,e,r,s)),l=this.remuxVideo(e,p,i,n)}}else E&&(l=this.remuxVideo(e,p,i,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=n)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(d=Ro(i,r,this._initPTS,this._initDTS)),n.samples.length&&(u=Co(n,r,this._initPTS))),{audio:c,video:l,initSegment:h,independent:f,text:u,id3:d}}generateIS(t,e,i,n){const r=t.samples,s=e.samples,a=this.typeSupported,o={},l=this._initPTS;let c,h,u,d=!l||n,f="audio/mp4";if(d&&(c=h=1/0),t.config&&r.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):yo.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(u=t.inputTimeScale,l&&u===l.timescale?d=!1:c=h=r[0].pts-Math.round(u*i))}if(e.sps&&e.pps&&s.length){if(e.timescale=e.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:yo.initSegment([e]),metadata:{width:e.width,height:e.height}},d)if(u=e.inputTimeScale,l&&u===l.timescale)d=!1;else{const t=this.getVideoStartPts(s),e=Math.round(u*i);h=Math.min(h,Lo(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:u},this._initDTS={baseTime:h,timescale:u}):c=u=void 0,{tracks:o,initPTS:c,timescale:u}}remuxVideo(t,e,i,n){const r=t.inputTimeScale,s=t.samples,a=[],o=s.length,l=this._initPTS;let c,h,u=this.nextAvcDts,d=8,f=this.videoSampleDuration,g=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,m=!1;if(!i||null===u){const t=e*r,n=s[0].pts-Lo(s[0].dts,s[0].pts);ko&&null!==u&&Math.abs(t-n-u)<15e3?i=!0:u=t-n}const v=l.baseTime*r/l.timescale;for(let t=0;t<o;t++){const e=s[t];e.pts=Lo(e.pts-v,u),e.dts=Lo(e.dts-v,u),e.dts<s[t>0?t-1:t].dts&&(m=!0)}m&&s.sort((function(t,e){const i=t.dts-e.dts,n=t.pts-e.pts;return i||n})),c=s[0].dts,h=s[s.length-1].dts;const y=h-c,A=y?Math.round(y/(o-1)):f||t.inputTimeScale/30;if(i){const t=c-u,i=t>A,n=t<-1;if((i||n)&&(i?Oi.warn(`AVC: ${To(t,!0)} ms (${t}dts) hole between fragments detected at ${e.toFixed(3)}`):Oi.warn(`AVC: ${To(-t,!0)} ms (${t}dts) overlapping between fragments detected at ${e.toFixed(3)}`),!n||u>=s[0].pts||ko)){c=u;const e=s[0].pts-t;if(i)s[0].dts=c,s[0].pts=e;else for(let i=0;i<s.length&&!(s[i].dts>e);i++)s[i].dts-=t,s[i].pts-=t;Oi.log(`Video: Initial PTS/DTS adjusted: ${To(e,!0)}/${To(c,!0)}, delta: ${To(t,!0)} ms`)}}c=Math.max(0,c);let E=0,T=0,b=c;for(let t=0;t<o;t++){const e=s[t],i=e.units,n=i.length;let r=0;for(let t=0;t<n;t++)r+=i[t].data.length;T+=r,E+=n,e.length=r,e.dts<b?(e.dts=b,b+=A/4|0||1):b=e.dts,g=Math.min(e.pts,g),p=Math.max(e.pts,p)}h=s[o-1].dts;const k=T+4*E+8;let S;try{S=new Uint8Array(k)}catch(t){return void this.observer.emit(Li.ERROR,Li.ERROR,{type:Ri.MUX_ERROR,details:Ci.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:k,reason:`fail allocating video mdat ${k}`})}const _=new DataView(S.buffer);_.setUint32(0,k),S.set(yo.types.mdat,4);let L=!1,R=Number.POSITIVE_INFINITY,C=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,I=Number.NEGATIVE_INFINITY;for(let t=0;t<o;t++){const e=s[t],i=e.units;let l,c=0;for(let t=0,e=i.length;t<e;t++){const e=i[t],n=e.data,r=e.data.byteLength;_.setUint32(d,r),d+=4,S.set(n,d),d+=r,c+=4+r}if(t<o-1)f=s[t+1].dts-e.dts,l=s[t+1].pts-e.pts;else{const i=this.config,a=t>0?e.dts-s[t-1].dts:A;if(l=t>0?e.pts-s[t-1].pts:A,i.stretchShortVideoTrack&&null!==this.nextAudioPts){const t=Math.floor(i.maxBufferHole*r),s=(n?g+n*r:this.nextAudioPts)-e.pts;s>t?(f=s-a,f<0?f=a:L=!0,Oi.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 h=Math.round(e.pts-e.dts);R=Math.min(R,f),w=Math.max(w,f),C=Math.min(C,l),I=Math.max(I,l),a.push(new wo(e.key,f,c,h))}if(a.length)if(ko){if(ko<70){const t=a[0].flags;t.dependsOn=2,t.isNonSync=0}}else if(So&&I-C<w-R&&A/w<.025&&0===a[0].cts){Oi.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let t=c;for(let e=0,i=a.length;e<i;e++){const n=t+a[e].duration,r=t+a[e].cts;if(e<i-1){const t=n+a[e+1].cts;a[e].duration=t-r}else a[e].duration=e?a[e-1].duration:A;a[e].cts=0,t=n}}f=L||!f?A:f,this.nextAvcDts=u=h+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;const D={data1:yo.moof(t.sequenceNumber++,c,bi({},t,{samples:a})),data2:S,startPTS:g/r,endPTS:(p+f)/r,startDTS:c/r,endDTS:u/r,type:"video",hasAudio:!1,hasVideo:!0,nb:a.length,dropped:t.dropped};return t.samples=[],t.dropped=0,D}getSamplesPerFrame(t){switch(t.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(t,e,i,n,r){const s=t.inputTimeScale,a=s/(t.samplerate?t.samplerate:s),o=this.getSamplesPerFrame(t),l=o*a,c=this._initPTS,h="mp3"===t.segmentCodec&&this.typeSupported.mpeg,u=[],d=void 0!==r;let f=t.samples,g=h?0:8,p=this.nextAudioPts||-1;const m=e*s,v=c.baseTime*s/c.timescale;if(this.isAudioContiguous=i=i||f.length&&p>0&&(n&&Math.abs(m-p)<9e3||Math.abs(Lo(f[0].pts-v,m)-p)<20*l),f.forEach((function(t){t.pts=Lo(t.pts-v,m)})),!i||p<0){if(f=f.filter((t=>t.pts>=0)),!f.length)return;p=0===r?0:n&&!d?Math.max(0,m):f[0].pts}if("aac"===t.segmentCodec){const e=this.config.maxAudioFramesDrift;for(let i=0,n=p;i<f.length;i++){const r=f[i],a=r.pts,o=a-n,c=Math.abs(1e3*o/s);if(o<=-e*l&&d)0===i&&(Oi.warn(`Audio frame @ ${(a/s).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*o/s)} ms.`),this.nextAudioPts=p=n=a);else if(o>=e*l&&c<1e4&&d){let e=Math.round(o/l);n=a-e*l,n<0&&(e--,n+=l),0===i&&(this.nextAudioPts=p=n),Oi.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;s<e;s++){const e=Math.max(n,0);let s=mo.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);s||(Oi.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),s=r.unit.subarray()),f.splice(i,0,{unit:s,pts:e}),n+=l,i++}}r.pts=n,n+=l}}let y,A=null,E=null,T=0,b=f.length;for(;b--;)T+=f[b].unit.byteLength;for(let e=0,n=f.length;e<n;e++){const n=f[e],r=n.unit;let s=n.pts;if(null!==E){u[e-1].duration=Math.round((s-E)/a)}else{if(i&&"aac"===t.segmentCodec&&(s=p),A=s,!(T>0))return;T+=g;try{y=new Uint8Array(T)}catch(t){return void this.observer.emit(Li.ERROR,Li.ERROR,{type:Ri.MUX_ERROR,details:Ci.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:T,reason:`fail allocating audio mdat ${T}`})}if(!h){new DataView(y.buffer).setUint32(0,T),y.set(yo.types.mdat,4)}}y.set(r,g);const l=r.byteLength;g+=l,u.push(new wo(!0,o,l,0)),E=s}const k=u.length;if(!k)return;const S=u[u.length-1];this.nextAudioPts=p=E+a*S.duration;const _=h?new Uint8Array(0):yo.moof(t.sequenceNumber++,A/a,bi({},t,{samples:u}));t.samples=[];const L=A/s,R=p/s,C={data1:_,data2:y,startPTS:L,endPTS:R,startDTS:L,endDTS:R,type:"audio",hasAudio:!0,hasVideo:!1,nb:k};return this.isAudioContiguous=!0,C}remuxEmptyAudio(t,e,i,n){const r=t.inputTimeScale,s=r/(t.samplerate?t.samplerate:r),a=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,c=(null!==a?a:n.startDTS*r)+l,h=n.endDTS*r+l,u=1024*s,d=Math.ceil((h-c)/u),f=mo.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(Oi.warn("[mp4-remuxer]: remux empty Audio"),!f)return void Oi.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const g=[];for(let t=0;t<d;t++){const e=c+t*u;g.push({unit:f,pts:e,dts:e})}return t.samples=g,this.remuxAudio(t,e,i,!1)}}function Lo(t,e){let i;if(null===e)return t;for(i=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=i;return t}function Ro(t,e,i,n){const r=t.samples.length;if(!r)return;const s=t.inputTimeScale;for(let a=0;a<r;a++){const r=t.samples[a];r.pts=Lo(r.pts-i.baseTime*s/i.timescale,e*s)/s,r.dts=Lo(r.dts-n.baseTime*s/n.timescale,e*s)/s}const a=t.samples;return t.samples=[],{samples:a}}function Co(t,e,i){const n=t.samples.length;if(!n)return;const r=t.inputTimeScale;for(let s=0;s<n;s++){const n=t.samples[s];n.pts=Lo(n.pts-i.baseTime*r/i.timescale,e*r)/r}t.samples.sort(((t,e)=>t.pts-e.pts));const s=t.samples;return t.samples=[],{samples:s}}class wo{constructor(t,e,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=n,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:t?2:1,isNonSync:t?0:1}}}function Io(t,e){const i=null==t?void 0:t.codec;if(i&&i.length>4)return i;if(e===$i){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return pr(i,!1)}const t="mp4a.40.5";return Oi.info(`Parsed audio codec "${i}" or audio object type not handled. Using "${t}"`),t}return Oi.warn(`Unhandled video codec "${i}"`),"hvc1"===i||"hev1"===i?"hvc1.1.6.L120.90":"av01"===i?"av01.0.04M.08":"avc1.42e01e"}try{bo=self.performance.now.bind(self.performance)}catch(t){Oi.debug("Unable to use Performance API on this environment"),bo=null==Xi?void 0:Xi.Date.now}const Do=[{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,i,n){const r=this.videoTrack=Pa("video",1),s=this.audioTrack=Pa("audio",1),a=this.txtTrack=Pa("text",1);if(this.id3Track=Pa("id3",1),this.timeOffset=0,null==t||!t.byteLength)return;const o=Un(t);if(o.video){const{id:t,timescale:e,codec:i}=o.video;r.id=t,r.timescale=a.timescale=e,r.codec=i}if(o.audio){const{id:t,timescale:e,codec:i}=o.audio;s.id=t,s.timescale=e,s.codec=i}a.id=In.text,r.sampleDuration=0,r.duration=s.duration=n}resetContiguity(){this.remainderData=null}static probe(t){return function(t){const e=t.byteLength;for(let i=0;i<e;){const n=On(t,i);if(n>8&&109===t[i+4]&&111===t[i+5]&&111===t[i+6]&&102===t[i+7])return!0;i=n>1?i+n:e}return!1}(t)}demux(t,e){this.timeOffset=e;let i=t;const n=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=jn(this.remainderData,t));const e=function(t){const e={valid:null,remainder:null},i=Fn(t,["moof"]);if(i.length<2)return e.remainder=t,e;const n=i[i.length-1];return e.valid=cn(t,0,n.byteOffset-8),e.remainder=cn(t,n.byteOffset-8),e}(i);this.remainderData=e.remainder,n.samples=e.valid||new Uint8Array}else n.samples=i;const s=this.extractID3Track(n,e);return r.samples=Wn(e,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(e,this.timeOffset);return i.samples=Wn(t,e),{videoTrack:e,audioTrack:Pa(),id3Track:n,textTrack:Pa()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const n=Fn(t.samples,["emsg"]);n&&n.forEach((t=>{const n=function(t){const e=t[0];let i="",n="",r=0,s=0,a=0,o=0,l=0,c=0;if(0===e){for(;"\0"!==Dn(t.subarray(c,c+1));)i+=Dn(t.subarray(c,c+1)),c+=1;for(i+=Dn(t.subarray(c,c+1)),c+=1;"\0"!==Dn(t.subarray(c,c+1));)n+=Dn(t.subarray(c,c+1)),c+=1;n+=Dn(t.subarray(c,c+1)),c+=1,r=On(t,12),s=On(t,16),o=On(t,20),l=On(t,24),c=28}else if(1===e){c+=4,r=On(t,c),c+=4;const e=On(t,c);c+=4;const s=On(t,c);for(c+=4,a=2**32*e+s,Si(a)||(a=Number.MAX_SAFE_INTEGER,Oi.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=On(t,c),c+=4,l=On(t,c),c+=4;"\0"!==Dn(t.subarray(c,c+1));)i+=Dn(t.subarray(c,c+1)),c+=1;for(i+=Dn(t.subarray(c,c+1)),c+=1;"\0"!==Dn(t.subarray(c,c+1));)n+=Dn(t.subarray(c,c+1)),c+=1;n+=Dn(t.subarray(c,c+1)),c+=1}return{schemeIdUri:i,value:n,timeScale:r,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:t.subarray(c,t.byteLength)}}(t);if(Ja.test(n.schemeIdUri)){const t=ki(n.presentationTime)?n.presentationTime/n.timeScale:e+n.presentationTimeDelta/n.timeScale;let r=4294967295===n.eventDuration?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);const s=n.payload;i.samples.push({data:s,len:s.byteLength,dts:t,pts:t,type:Wr,duration:r})}}))}return i}demuxSampleAes(t,e,i){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,i,n){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(function(t,e){if(!t||!e)return t;const i=e.keyId;i&&e.isCommonEncryption&&Fn(t,["moov","trak"]).forEach((t=>{const e=Fn(t,["mdia","minf","stbl","stsd"])[0].subarray(8);let n=Fn(e,["enca"]);const r=n.length>0;r||(n=Fn(e,["encv"])),n.forEach((t=>{Fn(r?t.subarray(28):t.subarray(78),["sinf"]).forEach((t=>{const e=Hn(t);if(e){const t=e.subarray(8,24);t.some((t=>0!==t))||(Oi.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${Rn(t)} -> ${Rn(i)}`),e.set(i,8))}}))}))}));return t}(t,n)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:i}=this;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const n=this.initData=Un(t);n.audio&&(e=Io(n.audio,$i)),n.video&&(i=Io(n.video,Gi));const r={};n.audio&&n.video?r.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:n.audio?r.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:n.video?r.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:Oi.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r}remux(t,e,i,n,r,s){var a,o;let{initPTS:l,lastEndTime:c}=this;const h={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};ki(c)||(c=this.lastEndTime=r||0);const u=e.samples;if(null==u||!u.length)return h;const d={initPTS:void 0,timescale:1};let f=this.initData;if(null!=(a=f)&&a.length||(this.generateInitSegment(u),f=this.initData),null==(o=f)||!o.length)return Oi.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);const g=function(t,e){let i=0,n=0,r=0;const s=Fn(t,["moof","traf"]);for(let t=0;t<s.length;t++){const a=s[t],o=Fn(a,["tfhd"])[0],l=e[On(o,4)];if(!l)continue;const c=l.default,h=On(o,0)|(null==c?void 0:c.flags);let u=null==c?void 0:c.duration;8&h&&(u=On(o,2&h?12:8));const d=l.timescale||9e4,f=Fn(a,["trun"]);for(let t=0;t<f.length;t++)i=Yn(f[t]),!i&&u&&(i=u*On(f[t],4)),l.type===Gi?n+=i/d:l.type===$i&&(r+=i/d)}if(0===n&&0===r){let e=1/0,i=0,n=0;const r=Fn(t,["sidx"]);for(let t=0;t<r.length;t++){const s=Bn(r[t]);if(null!=s&&s.references){e=Math.min(e,s.earliestPresentationTime/s.timescale);const t=s.references.reduce(((t,e)=>t+e.info.duration||0),0);i=Math.max(i,t+s.earliestPresentationTime/s.timescale),n=i-e}}if(n&&ki(n))return n}return n||r}(u,f),p=function(t,e){return Fn(e,["moof","traf"]).reduce(((e,i)=>{const n=Fn(i,["tfdt"])[0],r=n[0],s=Fn(i,["tfhd"]).reduce(((e,i)=>{const s=On(i,4),a=t[s];if(a){let t=On(n,4);if(1===r){if(t===Cn)return Oi.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t*=Cn+1,t+=On(n,8)}const i=t/(a.timescale||9e4);if(ki(i)&&(null===e||i<e))return i}return e}),null);return null!==s&&ki(s)&&(null===e||s<e)?s:e}),null)}(f,u),m=null===p?r:p;(function(t,e,i,n){if(null===t)return!0;const r=Math.max(n,1),s=e-t.baseTime/t.timescale;return Math.abs(s-i)>r}(l,m,r,g)||d.timescale!==l.timescale&&s)&&(d.initPTS=m-r,l&&1===l.timescale&&Oi.warn("Adjusting initPTS by "+(d.initPTS-l.baseTime)),this.initPTS=l={baseTime:d.initPTS,timescale:1});const v=t?m-l.baseTime/l.timescale:c,y=v+g;!function(t,e,i){Fn(e,["moof","traf"]).forEach((e=>{Fn(e,["tfhd"]).forEach((n=>{const r=On(n,4),s=t[r];if(!s)return;const a=s.timescale||9e4;Fn(e,["tfdt"]).forEach((t=>{const e=t[0],n=i*a;if(n){let i=On(t,4);if(0===e)i-=n,i=Math.max(i,0),Mn(t,4,i);else{i*=Math.pow(2,32),i+=On(t,8),i-=n,i=Math.max(i,0);const e=Math.floor(i/(Cn+1)),r=Math.floor(i%(Cn+1));Mn(t,4,e),Mn(t,8,r)}}}))}))}))}(f,u,l.baseTime/l.timescale),g>0?this.lastEndTime=y:(Oi.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const A=!!f.audio,E=!!f.video;let T="";A&&(T+="audio"),E&&(T+="video");const b={data1:u,startPTS:v,startDTS:v,endPTS:y,endDTS:y,type:T,hasAudio:A,hasVideo:E,nb:1,dropped:0};return h.audio="audio"===b.type?b:void 0,h.video="audio"!==b.type?b:void 0,h.initSegment=d,h.id3=Ro(i,r,l,l),n.samples.length&&(h.text=Co(n,r,l)),h}}},{demux:lo,remux:_o},{demux:class extends Oa{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,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=dn(t,0);let i=(null==e?void 0:e.length)||0;if(Za(t,i))return!1;for(let e=t.length;i<e;i++)if(Ua(t,i))return Oi.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return function(t,e){return function(t,e){return e+5<t.length}(t,e)&&Na(t,e)&&Fa(t,e)<=t.length-e}(t,e)}appendFrame(t,e,i){$a(t,this.observer,e,i,t.manifestCodec);const n=Va(t,e,i,this.basePTS,this.frameIndex);if(n&&0===n.missing)return n}},remux:_o},{demux:class extends Oa{resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;const e=dn(t,0);let i=(null==e?void 0:e.length)||0;if(e&&11===t[i]&&119===t[i+1]&&void 0!==pn(e)&&to(t,i)<=16)return!1;for(let e=t.length;i<e;i++)if(Za(t,i))return Oi.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return function(t,e){return Xa(t,e)&&4<=t.length-e}(t,e)}appendFrame(t,e,i){if(null!==this.basePTS)return za(t,e,i,this.basePTS,this.frameIndex)}},remux:_o}];Do.splice(2,0,{demux:eo,remux:_o});class Po{constructor(t,e,i,n,r){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=i,this.vendor=n,this.id=r}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,n){const r=i.transmuxing;r.executeStart=bo();let s=new Uint8Array(t);const{currentTransmuxState:a,transmuxConfig:o}=this;n&&(this.currentTransmuxState=n);const{contiguous:l,discontinuity:c,trackSwitch:h,accurateTimeOffset:u,timeOffset:d,initSegmentChange:f}=n||a,{audioCodec:g,videoCodec:p,defaultInitPts:m,duration:v,initSegmentData:y}=o,A=function(t,e){let i=null;t.byteLength>0&&null!=(null==e?void 0:e.key)&&null!==e.iv&&null!=e.method&&(i=e);return i}(s,e);if(A&&"AES-128"===A.method){const t=this.getDecrypter();if(!t.isSync())return this.decryptionPromise=t.webCryptoDecrypt(s,A.key.buffer,A.iv.buffer).then((t=>{const e=this.push(t,null,i);return this.decryptionPromise=null,e})),this.decryptionPromise;{let e=t.softwareDecrypt(s,A.key.buffer,A.iv.buffer);if(i.part>-1&&(e=t.flush()),!e)return r.executeEnd=bo(),Oo(i);s=new Uint8Array(e)}}const E=this.needsProbing(c,h);if(E){const t=this.configureTransmuxer(s);if(t)return Oi.warn(`[transmuxer] ${t.message}`),this.observer.emit(Li.ERROR,Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),r.executeEnd=bo(),Oo(i)}(c||h||f||E)&&this.resetInitSegment(y,g,p,v,e),(c||f||E)&&this.resetInitialTimestamp(m),l||this.resetContiguity();const T=this.transmux(s,A,d,u,i),b=this.currentTransmuxState;return b.contiguous=!0,b.discontinuity=!1,b.trackSwitch=!1,r.executeEnd=bo(),T}flush(t){const e=t.transmuxing;e.executeStart=bo();const{decrypter:i,currentTransmuxState:n,decryptionPromise:r}=this;if(r)return r.then((()=>this.flush(t)));const s=[],{timeOffset:a}=n;if(i){const e=i.flush();e&&s.push(this.push(e,null,t))}const{demuxer:o,remuxer:l}=this;if(!o||!l)return e.executeEnd=bo(),[Oo(t)];const c=o.flush(a);return xo(c)?c.then((e=>(this.flushRemux(s,e,t),s))):(this.flushRemux(s,c,t),s)}flushRemux(t,e,i){const{audioTrack:n,videoTrack:r,id3Track:s,textTrack:a}=e,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;Oi.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const c=this.remuxer.remux(n,r,s,a,l,o,!0,this.id);t.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=bo()}resetInitialTimestamp(t){const{demuxer:e,remuxer:i}=this;e&&i&&(e.resetTimeStamp(t),i.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,i,n,r){const{demuxer:s,remuxer:a}=this;s&&a&&(s.resetInitSegment(t,e,i,n),a.resetInitSegment(t,e,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,i,n,r){let s;return s=e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,i,n,r):this.transmuxUnencrypted(t,i,n,r),s}transmuxUnencrypted(t,e,i,n){const{audioTrack:r,videoTrack:s,id3Track:a,textTrack:o}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,s,a,o,e,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(t,e,i,n,r){return this.demuxer.demuxSampleAes(t,e,i).then((t=>({remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,i,n,!1,this.id),chunkMeta:r})))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:n,vendor:r}=this;let s;for(let e=0,i=Do.length;e<i;e++){var a;if(null!=(a=Do[e].demux)&&a.probe(t)){s=Do[e];break}}if(!s)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,l=this.remuxer,c=s.remux,h=s.demux;l&&l instanceof c||(this.remuxer=new c(i,e,n,r)),o&&o instanceof h||(this.demuxer=new h(i,e,n),this.probe=h.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new ma(this.config)),t}}const Oo=t=>({remuxResult:{},chunkMeta:t});function xo(t){return"then"in t&&t.then instanceof Function}class No{constructor(t,e,i,n,r){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=i,this.duration=n,this.defaultInitPts=r||null}}class Mo{constructor(t,e,i,n,r,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=i,this.trackSwitch=n,this.timeOffset=r,this.initSegmentChange=s}}var Fo={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function n(){}function r(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function s(t,e,n,s,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new r(n,s||t,a),l=i?i+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__||(i=!1)),o.prototype.eventNames=function(){var t,n,r=[];if(0===this._eventsCount)return r;for(n in t=this._events)e.call(t,n)&&r.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},o.prototype.listeners=function(t){var e=i?i+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,s=n.length,a=new Array(s);r<s;r++)a[r]=n[r].fn;return a},o.prototype.listenerCount=function(t){var e=i?i+t:t,n=this._events[e];return n?n.fn?1:n.length:0},o.prototype.emit=function(t,e,n,r,s,a){var o=i?i+t:t;if(!this._events[o])return!1;var l,c,h=this._events[o],u=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),u){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,r),!0;case 5:return h.fn.call(h.context,e,n,r,s),!0;case 6:return h.fn.call(h.context,e,n,r,s,a),!0}for(c=1,l=new Array(u-1);c<u;c++)l[c-1]=arguments[c];h.fn.apply(h.context,l)}else{var d,f=h.length;for(c=0;c<f;c++)switch(h[c].once&&this.removeListener(t,h[c].fn,void 0,!0),u){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,e);break;case 3:h[c].fn.call(h[c].context,e,n);break;case 4:h[c].fn.call(h[c].context,e,n,r);break;default:if(!l)for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];h[c].fn.apply(h[c].context,l)}}return!0},o.prototype.on=function(t,e,i){return s(this,t,e,i,!1)},o.prototype.once=function(t,e,i){return s(this,t,e,i,!0)},o.prototype.removeListener=function(t,e,n,r){var s=i?i+t:t;if(!this._events[s])return this;if(!e)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==e||r&&!o.once||n&&o.context!==n||a(this,s);else{for(var l=0,c=[],h=o.length;l<h;l++)(o[l].fn!==e||r&&!o[l].once||n&&o[l].context!==n)&&c.push(o[l]);c.length?this._events[s]=1===c.length?c[0]:c:a(this,s)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&a(this,e)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,t.exports=o}(Fo);var Bo=hi(Fo.exports);class Uo{constructor(t,e,i,n){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const r=t.config;this.hls=t,this.id=e,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;const s=(t,e)=>{(e=e||{}).frag=this.frag,e.id=this.id,t===Li.ERROR&&(this.error=e.error),this.hls.trigger(t,e)};this.observer=new Bo,this.observer.on(Li.FRAG_DECRYPTED,s),this.observer.on(Li.ERROR,s);const a=ar(r.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(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(Oi.log(`loading Web Worker ${r.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}}(r.workerPath)):(Oi.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 i=new Error(`${t.message} (${t.filename}:${t.lineno})`);r.enableWorker=!1,Oi.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(Li.ERROR,{type:Ri.OTHER_ERROR,details:Ci.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:i})},t.postMessage({cmd:"init",typeSupported:o,vendor:"",id:e,config:JSON.stringify(r)})}catch(t){Oi.warn(`Error setting up "${e}" Web Worker, fallback to inline`,t),this.resetWorker(),this.error=null,this.transmuxer=new Po(this.observer,o,r,"",e)}return}}this.transmuxer=new Po(this.observer,o,r,"",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,i,n,r,s,a,o,l,c){var h,u;l.transmuxing.start=self.performance.now();const{transmuxer:d}=this,f=s?s.start:r.start,g=r.decryptdata,p=this.frag,m=!(p&&r.cc===p.cc),v=!(p&&l.level===p.level),y=p?l.sn-p.sn:-1,A=this.part?l.part-this.part.index:-1,E=0===y&&l.id>1&&l.id===(null==p?void 0:p.stats.chunkCount),T=!v&&(1===y||0===y&&(1===A||E&&A<=0)),b=self.performance.now();(v||y||0===r.stats.parsing.start)&&(r.stats.parsing.start=b),!s||!A&&T||(s.stats.parsing.start=b);const k=!(p&&(null==(h=r.initSegment)?void 0:h.url)===(null==(u=p.initSegment)?void 0:u.url)),S=new Mo(m,T,o,v,f,k);if(!T||m||k){Oi.log(`[transmuxer-interface, ${r.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${m}\n trackSwitch: ${v}\n contiguous: ${T}\n accurateTimeOffset: ${o}\n timeOffset: ${f}\n initSegmentChange: ${k}`);const t=new No(i,n,e,a,c);this.configureTransmuxer(t)}if(this.frag=r,this.part=s,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:l,state:S},t instanceof ArrayBuffer?[t]:[]);else if(d){const e=d.push(t,g,l,S);xo(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 i=e.flush(t);xo(i)||e.async?(xo(i)||(i=Promise.resolve(i)),i.then((e=>{this.handleFlushResult(e,t)})).catch((e=>{this.transmuxerError(e,t,"transmuxer-interface flush error")}))):this.handleFlushResult(i,t)}}transmuxerError(t,e,i){this.hls&&(this.error=t,this.hls.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_PARSING_ERROR,chunkMeta:e,frag:this.frag||void 0,fatal:!1,error:t,err:t,reason:i}))}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 Oi.warn("worker message received with no "+(e?"event name":"data"));const i=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":Oi[e.data.logType]&&Oi[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,i.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 $o(t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Go(t[i].attrs,e[i].attrs))return!1;return!0}function Go(t,e,i){const n=t["STABLE-RENDITION-ID"];return n&&!i?n===e["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some((i=>t[i]!==e[i]))}function Vo(t,e){return e.label.toLowerCase()===t.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(t.lang||"").toLowerCase())}class Ko{constructor(t){this.buffered=void 0;const e=(e,i,n)=>{if((i>>>=0)>n-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${n})`);return t[i][e]};this.buffered={get length(){return t.length},end:i=>e("end",i,t.length),start:i=>e("start",i,t.length)}}}class Ho{constructor(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}append(t,e,i){const n=this.queues[e];n.push(t),1!==n.length||i||this.executeNext(e)}insertAbort(t,e){this.queues[e].unshift(t),this.executeNext(e)}appendBlocker(t){let e;const i=new Promise((t=>{e=t})),n={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,t),i}executeNext(t){const e=this.queues[t];if(e.length){const i=e[0];try{i.execute()}catch(e){Oi.warn(`[buffer-operation-queue]: Exception executing "${t}" SourceBuffer operation: ${e}`),i.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 Yo=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;function jo(t){const e=t.querySelectorAll("source");[].slice.call(e).forEach((e=>{t.removeChild(e)}))}const Wo={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},zo=t=>String.fromCharCode(Wo[t]||t),qo=15,Xo=100,Qo={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Zo={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Jo={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},tl={25:2,26:4,29:6,30:8,31:10,27:13,28:15},el=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class il{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i="function"==typeof e?e():e;Oi.log(`${this.time} [${t}] ${i}`)}}}const nl=function(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].toString(16));return e};class rl{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const e=["foreground","underline","italics","background","flash"];for(let i=0;i<e.length;i++){const n=e[i];t.hasOwnProperty(n)&&(this[n]=t[n])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class sl{constructor(){this.uchar=" ",this.penState=new rl}reset(){this.uchar=" ",this.penState.reset()}setChar(t,e){this.uchar=t,this.penState.copy(e)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class al{constructor(t){this.chars=[],this.pos=0,this.currPenState=new rl,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Xo;t++)this.chars.push(new sl);this.logger=t}equals(t){for(let e=0;e<Xo;e++)if(!this.chars[e].equals(t.chars[e]))return!1;return!0}copy(t){for(let e=0;e<Xo;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<Xo;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Xo&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Xo)}moveCursor(t){const e=this.pos+t;if(t>1)for(let t=this.pos+1;t<e+1;t++)this.chars[t].setPenState(this.currPenState);this.setCursor(e)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const e=zo(t);this.pos>=Xo?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<Xo;e++)this.chars[e].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let e=!0;for(let i=0;i<Xo;i++){const n=this.chars[i].uchar;" "!==n&&(e=!1),t.push(n)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t);this.chars[this.pos].setPenState(this.currPenState)}}class ol{constructor(t){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let e=0;e<qo;e++)this.rows.push(new al(t));this.logger=t}reset(){for(let t=0;t<qo;t++)this.rows[t].clear();this.currRow=14}equals(t){let e=!0;for(let i=0;i<qo;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<qo;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<qo;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t);this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,(()=>"pacData = "+JSON.stringify(t)));let e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(let t=0;t<qo;t++)this.rows[t].clear();const t=this.currRow+1-this.nrRollUpRows,i=this.lastOutputScreen;if(i){const n=i.rows[t].cueStartTime,r=this.logger.time;if(null!==n&&null!==r&&n<r)for(let n=0;n<this.nrRollUpRows;n++)this.rows[e-this.nrRollUpRows+n+1].copy(i.rows[t+n])}}this.currRow=e;const i=this.rows[this.currRow];if(null!==t.indent){const e=t.indent,n=Math.max(e-1,0);i.setCursor(t.indent),t.color=i.chars[n].penState.foreground}const n={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(n)}setBkgData(t){this.logger.log(2,(()=>"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 i="",n=-1;for(let i=0;i<qo;i++){const r=this.rows[i].getTextString();r&&(n=i+1,t?e.push("Row "+n+": '"+r+"'"):e.push(r.trim()))}return e.length>0&&(i=t?"["+e.join(" | ")+"]":e.join("\n")),i}getTextAndFormat(){return this.rows}}class ll{constructor(t,e,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new ol(i),this.nonDisplayedMemory=new ol(i),this.lastOutputScreen=new ol(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}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;e<t.length;e++)this.writeScreen.insertChar(t[e]);const e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(()=>e+": "+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 i=Math.floor(t/2)-16,n=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=n[i]}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 cl{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const n=this.logger=new il;this.channels=[null,new ll(t,e,n),new ll(t+1,i,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<e.length;t+=2){const i=127&e[t],n=127&e[t+1];let r=!1,s=null;if(0===i&&0===n)continue;this.logger.log(3,(()=>"["+nl([e[t],e[t+1]])+"] -> ("+nl([i,n])+")"));const a=this.cmdHistory;if(i>=16&&i<=31){if(ul(i,n,a)){hl(null,null,a),this.logger.log(3,(()=>"Repeated command ("+nl([i,n])+") is dropped"));continue}hl(i,n,this.cmdHistory),r=this.parseCmd(i,n),r||(r=this.parseMidrow(i,n)),r||(r=this.parsePAC(i,n)),r||(r=this.parseBackgroundAttributes(i,n))}else hl(null,null,a);if(!r&&(s=this.parseChars(i,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?")}r||s||this.logger.log(2,(()=>"Couldn't parse cleaned data "+nl([i,n])+" orig: "+nl([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 i=20===t||21===t||23===t?1:2,n=this.channels[i];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=i,!0}parseMidrow(t,e){let i=0;if((17===t||25===t)&&e>=32&&e<=47){if(i=17===t?1:2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const n=this.channels[i];return!!n&&(n.ccMIDROW(e),this.logger.log(3,(()=>"MIDROW ("+nl([t,e])+")")),!0)}return!1}parsePAC(t,e){let i;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;i=e>=64&&e<=95?1===n?Qo[t]:Jo[t]:1===n?Zo[t]:tl[t];const r=this.channels[n];return!!r&&(r.setPAC(this.interpretPAC(i,e)),this.currentChannel=n,!0)}interpretPAC(t,e){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:t};return i=e>95?e-96:e-64,n.underline=1==(1&i),i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n}parseChars(t,e){let i,n=null,r=null;if(t>=25?(i=2,r=t-8):(i=1,r=t),r>=17&&r<=19){let t;t=17===r?e+80:18===r?e+112:e+144,this.logger.log(2,(()=>"Special char '"+zo(t)+"' in channel "+i)),n=[t]}else t>=32&&t<=127&&(n=0===e?[t]:[t,e]);return n&&this.logger.log(3,(()=>"Char codes = "+nl(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 i;const n={};16===t||24===t?(i=Math.floor((e-32)/2),n.background=el[i],e%2==1&&(n.background=n.background+"_semi")):45===e?n.background="transparent":(n.foreground="black",47===e&&(n.underline=!0));const r=t<=23?1:2;return this.channels[r].setBkgData(n),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const e=this.channels[t];e&&e.reset()}hl(null,null,this.cmdHistory)}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function hl(t,e,i){i.a=t,i.b=e}function ul(t,e,i){return i.a===t&&i.b===e}class dl{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,i){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var fl=function(){if(null!=Xi&&Xi.VTTCue)return self.VTTCue;const t=["","lr","rl"],e=["start","middle","end","left","right"];function i(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;const i=e.toLowerCase();return!!~t.indexOf(i)&&i}function n(t){return i(e,t)}function r(t,...e){let i=1;for(;i<arguments.length;i++){const e=arguments[i];for(const i in e)t[i]=e[i]}return t}function s(e,s,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let c="",h=!1,u=e,d=s,f=a,g=null,p="",m=!0,v="auto",y="start",A=50,E="middle",T=50,b="middle";Object.defineProperty(o,"id",r({},l,{get:function(){return c},set:function(t){c=""+t}})),Object.defineProperty(o,"pauseOnExit",r({},l,{get:function(){return h},set:function(t){h=!!t}})),Object.defineProperty(o,"startTime",r({},l,{get:function(){return u},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");u=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",r({},l,{get:function(){return d},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");d=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",r({},l,{get:function(){return f},set:function(t){f=""+t,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",r({},l,{get:function(){return g},set:function(t){g=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",r({},l,{get:function(){return p},set:function(e){const n=function(e){return i(t,e)}(e);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");p=n,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",r({},l,{get:function(){return m},set:function(t){m=!!t,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",r({},l,{get:function(){return v},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");v=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",r({},l,{get:function(){return y},set:function(t){const e=n(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",r({},l,{get:function(){return A},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");A=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",r({},l,{get:function(){return E},set:function(t){const e=n(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",r({},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",r({},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}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class gl{decode(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function pl(t){function e(t,e,i,n){return 3600*(0|t)+60*(0|e)+(0|i)+parseFloat(n||0)}const i=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?e(i[2],i[3],0,i[4]):e(i[1],i[2],i[3],i[4]):null}class ml{constructor(){this.values=Object.create(null)}set(t,e){this.get(t)||""===e||(this.values[t]=e)}get(t,e,i){return i?this.has(t)?this.values[t]:e[i]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,i){for(let n=0;n<i.length;++n)if(e===i[n]){this.set(t,e);break}}integer(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))}percent(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){const i=parseFloat(e);if(i>=0&&i<=100)return this.set(t,i),!0}return!1}}function vl(t,e,i,n){const r=n?t.split(n):[t];for(const t in r){if("string"!=typeof r[t])continue;const n=r[t].split(i);if(2!==n.length)continue;e(n[0],n[1])}}const yl=new fl(0,0,""),Al="middle"===yl.align?"middle":"center";function El(t,e,i){const n=t;function r(){const e=pl(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=r(),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=r(),s(),function(t,e){const n=new ml;vl(t,(function(t,e){let r;switch(t){case"region":for(let r=i.length-1;r>=0;r--)if(i[r].id===e){n.set(t,i[r].region);break}break;case"vertical":n.alt(t,e,["rl","lr"]);break;case"line":r=e.split(","),n.integer(t,r[0]),n.percent(t,r[0])&&n.set("snapToLines",!1),n.alt(t,r[0],["auto"]),2===r.length&&n.alt("lineAlign",r[1],["start",Al,"end"]);break;case"position":r=e.split(","),n.percent(t,r[0]),2===r.length&&n.alt("positionAlign",r[1],["start",Al,"end","line-left","line-right","auto"]);break;case"size":n.percent(t,e);break;case"align":n.alt(t,e,["start",Al,"end","left","right"])}}),/:/,/\s/),e.region=n.get("region",null),e.vertical=n.get("vertical","");let r=n.get("line","auto");"auto"===r&&-1===yl.line&&(r=-1),e.line=r,e.lineAlign=n.get("lineAlign","start"),e.snapToLines=n.get("snapToLines",!0),e.size=n.get("size",100),e.align=n.get("align",Al);let s=n.get("position","auto");"auto"===s&&50===yl.position&&(s="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=s}(t,e)}function Tl(t){return t.replace(/<br(?: \/)?>/gi,"\n")}class bl{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new gl,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;function i(){let t=e.buffer,i=0;for(t=Tl(t);i<t.length&&"\r"!==t[i]&&"\n"!==t[i];)++i;const n=t.slice(0,i);return"\r"===t[i]&&++i,"\n"===t[i]&&++i,e.buffer=t.slice(i),n}t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));try{let t="";if("INITIAL"===e.state){if(!/\r\n|\n/.test(e.buffer))return this;t=i();const n=t.match(/^()?WEBVTT([ \t].*)?$/);if(null==n||!n[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let n=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(n?n=!1:t=i(),e.state){case"HEADER":/:/.test(t)?vl(t,(function(t,e){}),/:/):t||(e.state="ID");continue;case"NOTE":t||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(t)){e.state="NOTE";break}if(!t)continue;if(e.cue=new fl(0,0,""),e.state="CUE",-1===t.indexOf("--\x3e")){e.cue.id=t;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{El(t,e.cue,e.regionList)}catch(t){e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const i=-1!==t.indexOf("--\x3e");if(!t||i&&(n=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(null===e.cue)continue;e.cue.text&&(e.cue.text+="\n"),e.cue.text+=t}continue;case"BADCUE":t||(e.state="ID")}}}catch(t){"CUETEXT"===e.state&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state="INITIAL"===e.state?"BADWEBVTT":"BADCUE"}return this}flush(){const t=this;try{if((t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state||"BADWEBVTT"===t.state)throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this}}const kl=/\r\n|\n\r|\n|\r/g,Sl=function(t,e,i=0){return t.slice(i,i+e.length)===e},_l=function(t){let e=5381,i=t.length;for(;i;)e=33*e^t.charCodeAt(--i);return(e>>>0).toString()};function Ll(t,e,i){return _l(t.toString())+_l(e.toString())+_l(i)}function Rl(t,e,i,n,r,s,a){const o=new bl,l=Sn(new Uint8Array(t)).trim().replace(kl,"\n").split("\n"),c=[],h=e?function(t,e=1){return Eo(t,Ao,1/e)}(e.baseTime,e.timescale):0;let u,d="00:00.000",f=0,g=0,p=!0;o.oncue=function(t){const s=i[n];let a=i.ccOffset;const o=(f-h)/9e4;if(null!=s&&s.new&&(void 0!==g?a=i.ccOffset=s.start:function(t,e,i){let n=t[e],r=t[n.prevCC];if(!r||!r.new&&n.new)return t.ccOffset=t.presentationOffset=n.start,void(n.new=!1);for(;null!=(s=r)&&s.new;){var s;t.ccOffset+=n.start-r.start,n.new=!1,n=r,r=t[n.prevCC]}t.presentationOffset=i}(i,n,o)),o){if(!e)return void(u=new Error("Missing initPTS for VTT MPEGTS"));a=o-i.presentationOffset}const l=t.endTime-t.startTime,d=Lo(9e4*(t.startTime+a-g),9e4*r)/9e4;t.startTime=Math.max(d,0),t.endTime=Math.max(d+l,0);const p=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(p)),t.id||(t.id=Ll(t.startTime,t.endTime,p)),t.endTime>0&&c.push(t)},o.onparsingerror=function(t){u=t},o.onflush=function(){u?a(u):s(c)},l.forEach((t=>{if(p){if(Sl(t,"X-TIMESTAMP-MAP=")){p=!1,t.slice(16).split(",").forEach((t=>{Sl(t,"LOCAL:")?d=t.slice(6):Sl(t,"MPEGTS:")&&(f=parseInt(t.slice(7)))}));try{g=function(t){let e=parseInt(t.slice(-3));const i=parseInt(t.slice(-6,-4)),n=parseInt(t.slice(-9,-7)),r=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(ki(e)&&ki(i)&&ki(n)&&ki(r)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${t}`);return e+=1e3*i,e+=6e4*n,e+=36e5*r,e}(d)/1e3}catch(t){u=t}return}""===t&&(p=!1)}o.parse(t+"\n")})),o.flush()}const Cl="stpp.ttml.im1t",wl=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Il=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Dl={left:"start",center:"center",right:"end",start:"start",end:"end"};function Pl(t,e,i,n){const r=Fn(new Uint8Array(t),["mdat"]);if(0===r.length)return void n(new Error("Could not parse IMSC1 mdat"));const s=r.map((t=>Sn(t))),a=function(t,e,i=1,n=!1){return Eo(t,e,1/i,n)}(e.baseTime,1,e.timescale);try{s.forEach((t=>i(function(t,e){const i=(new DOMParser).parseFromString(t,"text/xml"),n=i.getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(r).reduce(((t,e)=>(t[e]=n.getAttribute(`ttp:${e}`)||r[e],t)),{}),a="preserve"!==n.getAttribute("xml:space"),o=xl(Ol(n,"styling","style")),l=xl(Ol(n,"layout","region")),c=Ol(n,"body","[begin]");return[].map.call(c,(t=>{const i=Nl(t,a);if(!i||!t.hasAttribute("begin"))return null;const n=Bl(t.getAttribute("begin"),s),r=Bl(t.getAttribute("dur"),s);let c=Bl(t.getAttribute("end"),s);if(null===n)throw Fl(t);if(null===c){if(null===r)throw Fl(t);c=n+r}const h=new fl(n-e,c-e,i);h.id=Ll(h.startTime,h.endTime,h.text);const u=function(t,e,i){const n="http://www.w3.org/ns/ttml#styling";let r=null;const s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;a&&i.hasOwnProperty(a)&&(r=i[a]);return s.reduce(((i,s)=>{const a=Ml(e,n,s)||Ml(t,n,s)||Ml(r,n,s);return a&&(i[s]=a),i}),{})}(l[t.getAttribute("region")],o[t.getAttribute("style")],o),{textAlign:d}=u;if(d){const t=Dl[d];t&&(h.lineAlign=t),h.align=d}return bi(h,u),h})).filter((t=>null!==t))}(t,a))))}catch(t){n(t)}}function Ol(t,e,i){const n=t.getElementsByTagName(e)[0];return n?[].slice.call(n.querySelectorAll(i)):[]}function xl(t){return t.reduce(((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t}),{})}function Nl(t,e){return[].slice.call(t.childNodes).reduce(((t,i,n)=>{var r;return"br"===i.nodeName&&n?t+"\n":null!=(r=i.childNodes)&&r.length?Nl(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent}),"")}function Ml(t,e,i){return t&&t.hasAttributeNS(e,i)?t.getAttributeNS(e,i):null}function Fl(t){return new Error(`Could not parse ttml timestamp ${t}`)}function Bl(t,e){if(!t)return null;let i=pl(t);return null===i&&(wl.test(t)?i=function(t,e){const i=wl.exec(t),n=(0|i[4])+(0|i[5])/e.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+n/e.frameRate}(t,e):Il.test(t)&&(i=function(t,e){const i=Il.exec(t),n=Number(i[1]);switch(i[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))),i}function Ul(t){return t.characteristics&&/transcribes-spoken-dialog/gi.test(t.characteristics)&&/describes-music-and-sound/gi.test(t.characteristics)?"captions":"subtitles"}function $l(t,e){return!!t&&t.kind===Ul(e)&&Vo(e,t)}class Gl{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(Li.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(Li.BUFFER_CODECS,this.onBufferCodecs,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(Li.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(Li.BUFFER_CODECS,this.onBufferCodecs,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const i=this.hls.levels[e.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.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 i=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,i.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onLevelsUpdated(t,e){this.timer&&ki(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,i=this.getMaxLevel(t.length-1);i!==this.autoLevelCapping&&Oi.log(`Setting autoLevelCapping to ${i}: ${t[i].height}p@${t[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),e.autoLevelCapping=i,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 i=e.filter(((e,i)=>this.isLevelAllowed(e)&&i<=t));return this.clientRect=null,Gl.getMaxLevelByMediaSize(i,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 i=t.getBoundingClientRect();e.width=i.width,e.height=i.height,e.width||e.height||(e.width=i.right-i.left||t.width||0,e.height=i.bottom-i.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,i){if(null==t||!t.length)return-1;let n=t.length-1;const r=Math.max(e,i);for(let e=0;e<t.length;e+=1){const i=t[e];if((i.width>=r||i.height>=r)&&(s=i,!(a=t[e+1])||s.width!==a.width||s.height!==a.height)){n=e;break}}var s,a;return n}}const Vl="[eme]";class Kl{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=Kl.CDMCleanupPromise?[Kl.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=Oi.debug.bind(Oi,Vl),this.log=Oi.log.bind(Oi,Vl),this.warn=Oi.warn.bind(Oi,Vl),this.error=Oi.error.bind(Oi,Vl),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(Li.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Li.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Li.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Li.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Li.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:i}=this.config,n=e[t];if(n)return n.licenseUrl;if(t===Qi.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,i=e[t];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,i=(t,e,i)=>!!t&&i.indexOf(t)===e,n=e.map((t=>t.audioCodec)).filter(i),r=e.map((t=>t.videoCodec)).filter(i);return n.length+r.length===0&&r.push("avc1.42e01e"),new Promise(((e,i)=>{const s=t=>{const a=t.shift();this.getMediaKeysPromise(a,n,r).then((t=>e({keySystem:a,mediaKeys:t}))).catch((e=>{t.length?s(t):i(e instanceof Hl?e:new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))}))};s(t)}))}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:i}=this.config;if("function"!=typeof i){let t=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===on&&"http:"===self.location.protocol&&(t=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(t))}return i(t,e)}getMediaKeysPromise(t,e,i){const n=function(t,e,i,n){let r;switch(t){case Qi.FAIRPLAY:r=["cenc","sinf"];break;case Qi.WIDEVINE:case Qi.PLAYREADY:r=["cenc"];break;case Qi.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${t}`)}return function(t,e,i,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:i.map((t=>({contentType:`video/mp4; codecs="${t}"`,robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null})))}]}(r,e,i,n)}(t,e,i,this.config.drmSystemOptions),r=this.keySystemAccessPromises[t];let s=null==r?void 0:r.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((i=>{this.log(`Access for key-system "${i.keySystem}" obtained`);const n=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),e.mediaKeys=i.createMediaKeys().then((e=>(this.log(`Media-keys created for "${t}"`),n.then((i=>i?this.setMediaKeysServerCertificate(e,t,i):e))))),e.mediaKeys.catch((e=>{this.error(`Failed to create media-keys for "${t}"}: ${e}`)})),e.mediaKeys}))}return s.then((()=>r.mediaKeys))}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${Rn(t.keyId||[])}`);const n=i.createSession(),r={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),n=this.getKeyIdString(e),r="cenc";this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,r,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 Rn(t.keyId)}updateKeySession(t,e){var i;const n=t.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Rn((null==(i=t.decryptdata)?void 0:i.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,i)=>{const n=an(this.config),r=t.map(nn).filter((t=>!!t&&-1!==n.indexOf(t)));return this.getKeySystemSelectionPromise(r).then((({keySystem:t})=>{const n=sn(t);n?e(n):i(new Error(`Unable to find format for key-system "${t}"`))})).catch(i)}))}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),n=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${n}`);let r=this.keyIdToKeySessionPromise[i];return r||(r=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then((({keySystem:i,mediaKeys:r})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${n}`),this.attemptSetMediaKeys(i,r).then((()=>{this.throwIfDestroyed();const t=this.createMediaKeySessionContext({keySystem:i,mediaKeys:r,decryptdata:e});return this.generateRequestWithPreferredKeySession(t,"cenc",e.pssh,"playlist-key")}))))),r.catch((t=>this.handleError(t)))),r}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof Hl?this.hls.trigger(Li.ERROR,t.data):this.hls.trigger(Li.ERROR,{type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const e=nn(t.keyFormat),i=e?[e]:an(this.config);return this.attemptKeySystemAccess(i)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=an(this.config)),0===t.length)throw new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.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:i}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),null===i)return;let n,r;if("sinf"===e&&this.config.drmSystems[Qi.FAIRPLAY]){const t=Dn(new Uint8Array(i));try{const e=Wi(JSON.parse(t).sinf),i=Hn(new Uint8Array(e));if(!i)return;n=i.subarray(8,24),r=Qi.FAIRPLAY}catch(t){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{const t=function(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},i=new DataView(t),n=i.getUint32(0);if(t.byteLength!==n&&n>44)return null;if(1886614376!==i.getUint32(4))return null;if(e.version=i.getUint32(8)>>>24,e.version>1)return null;e.systemId=Rn(new Uint8Array(t,12,16));const r=i.getUint32(28);if(0===e.version){if(n-32<r)return null;e.data=new Uint8Array(t,32,r)}else if(1===e.version){e.kids=[];for(let i=0;i<r;i++)e.kids.push(new Uint8Array(t,32+16*i,16))}return e}(i);if(null===t)return;0===t.version&&t.systemId===rn&&t.data&&(n=t.data.subarray(8,24)),r=function(t){if(t===rn)return Qi.WIDEVINE}(t.systemId)}if(!r||!n)return;const s=Rn(n),{keyIdToKeySessionPromise:a,mediaKeySessions:o}=this;let l=a[s];for(let t=0;t<o.length;t++){const r=o[t],c=r.decryptdata;if(c.pssh||!c.keyId)continue;const h=Rn(c.keyId);if(s===h||-1!==c.uri.replace(/-/g,"").indexOf(s)){l=a[h],delete a[h],c.pssh=new Uint8Array(i),c.keyId=n,l=a[s]=l.then((()=>this.generateRequestWithPreferredKeySession(r,e,i,"encrypted-event-key-match")));break}}l||(l=a[s]=this.getKeySystemSelectionPromise([r]).then((({keySystem:t,mediaKeys:r})=>{var a;this.throwIfDestroyed();const o=new Jn("ISO-23001-7",s,null!=(a=sn(t))?a:"");return o.pssh=new Uint8Array(i),o.keyId=n,this.attemptSetMediaKeys(t,r).then((()=>{this.throwIfDestroyed();const n=this.createMediaKeySessionContext({decryptdata:o,keySystem:t,mediaKeys:r});return this.generateRequestWithPreferredKeySession(n,e,i,"encrypted-event-no-match")}))}))),l.catch((t=>this.handleError(t)))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const n=Promise.all(i).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}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter((t=>-1===i.indexOf(t)))}))}generateRequestWithPreferredKeySession(t,e,i,n){var r,s;const a=null==(r=this.config.drmSystems)||null==(s=r[t.keySystem])?void 0:s.generateRequest;if(a)try{const n=a.call(this.hls,e,i,t);if(!n)throw new Error("Invalid response from configured generateRequest filter");e=n.initDataType,i=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===i)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: ${i?i.byteLength:null})`);const c=new Bo,h=t._onmessage=e=>{const i=t.mediaKeysSession;if(!i)return void c.emit("error",new Error("invalid state"));const{messageType:n,message:r}=e;this.log(`"${n}" message event for session "${i.sessionId}" message size: ${r.byteLength}`),"license-request"===n||"license-renewal"===n?this.renewLicense(t,r).catch((t=>{this.handleError(t),c.emit("error",t)})):"license-release"===n?t.keySystem===Qi.FAIRPLAY&&(this.updateKeySession(t,qi("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${n}"`)},u=t._onkeystatuseschange=e=>{if(!t.mediaKeysSession)return void c.emit("error",new Error("invalid state"));this.onKeyStatusChange(t);const i=t.keyStatus;c.emit("keyStatus",i),"expired"===i&&(this.warn(`${t.keySystem} expired for key ${l}`),this.renewKeySession(t))};t.mediaKeysSession.addEventListener("message",h),t.mediaKeysSession.addEventListener("keystatuseschange",u);const d=new Promise(((t,e)=>{c.on("error",e),c.on("keyStatus",(i=>{i.startsWith("usable")?t():"output-restricted"===i?e(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===i?e(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${i}"`)):"expired"===i?e(new Error("key expired while generating request")):this.warn(`unhandled key status change "${i}"`)}))}));return t.mediaKeysSession.generateRequest(e,i).then((()=>{var e;this.log(`Request generated for key-session "${null==(e=t.mediaKeysSession)?void 0:e.sessionId}" keyId: ${l}`)})).catch((t=>{throw new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.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,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Rn("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Rn(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e}))}fetchServerCertificate(t){const e=this.config,i=new(0,e.loader)(e),n=this.getServerCertificateUrl(t);return n?(this.log(`Fetching server certificate for "${t}"`),new Promise(((r,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,i,n)=>{r(t.data)},onError:(e,i,r,o)=>{s(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:Ai({url:a.url,data:void 0},e)},`"${t}" certificate request failed (${n}). Status: ${e.code} (${e.text})`))},onTimeout:(e,i,r)=>{s(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:a.url,data:void 0}},`"${t}" certificate request timed out (${n})`))},onAbort:(t,e,i)=>{s(new Error("aborted"))}};i.load(a,l,c)}))):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise(((n,r)=>{t.setServerCertificate(i).then((r=>{this.log(`setServerCertificate ${r?"success":"not supported by CDM"} (${null==i?void 0:i.byteLength}) on "${e}"`),n(t)})).catch((t=>{r(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.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 Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)}))))}unpackPlayReadyKeyMessage(t,e){const i=String.fromCharCode.apply(null,new Uint16Array(e.buffer));if(!i.includes("PlayReadyKeyMessage"))return t.setRequestHeader("Content-Type","text/xml; charset=utf-8"),e;const n=(new DOMParser).parseFromString(i,"application/xml"),r=n.querySelectorAll("HttpHeader");if(r.length>0){let e;for(let i=0,n=r.length;i<n;i++){var s,a;e=r[i];const n=null==(s=e.querySelector("name"))?void 0:s.textContent,o=null==(a=e.querySelector("value"))?void 0:a.textContent;n&&o&&t.setRequestHeader(n,o)}}const o=n.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return qi(atob(l))}setupLicenseXHR(t,e,i,n){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then((()=>{if(!i.decryptdata)throw new Error("Key removed");return r.call(this.hls,t,e,i,n)})).catch((s=>{if(!i.decryptdata)throw s;return t.open("POST",e,!0),r.call(this.hls,t,e,i,n)})).then((i=>{t.readyState||t.open("POST",e,!0);return{xhr:t,licenseChallenge:i||n}})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:n}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise(((n,r)=>{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 r(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 i=this.config.licenseResponseCallback;if(i)try{e=i.call(this.hls,a,s,t)}catch(t){this.error(t)}n(e)}else{const o=i.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||a.status>=400&&a.status<500)r(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.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 i=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${i} attempts left`),this.requestLicense(t,e).then(n,r)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=a,this.setupLicenseXHR(a,s,t,e).then((({xhr:e,licenseChallenge:i})=>{t.keySystem==Qi.PLAYREADY&&(i=this.unpackPlayReadyKeyMessage(e,i)),e.send(i)}))}))}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const i=e.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.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={},Jn.clearKeyUriToKeyIdMap();const i=e.length;Kl.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((()=>{i&&(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:i}=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),i&&i.readyState!==XMLHttpRequest.DONE&&i.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}`)}))}}}Kl.CDMCleanupPromise=void 0;class Hl 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 Yl,jl,Wl;!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"}(Yl||(Yl={})),function(t){t.DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o"}(jl||(jl={})),function(t){t.OBJECT="CMCD-Object",t.REQUEST="CMCD-Request",t.SESSION="CMCD-Session",t.STATUS="CMCD-Status"}(Wl||(Wl={}));const zl={[Wl.OBJECT]:["br","d","ot","tb"],[Wl.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[Wl.SESSION]:["cid","pr","sf","sid","st","v"],[Wl.STATUS]:["bs","rtp"]};class ql{constructor(t,e){this.value=void 0,this.params=void 0,Array.isArray(t)&&(t=t.map((t=>t instanceof ql?t:new ql(t)))),this.value=t,this.params=e}}class Xl{constructor(t){this.description=void 0,this.description=t}}const Ql="Dict";function Zl(t,e,i,n){return new Error(`failed to ${t} "${r=e,Array.isArray(r)?JSON.stringify(r):r instanceof Map?"Map{}":r instanceof Set?"Set{}":"object"==typeof r?JSON.stringify(r):String(r)}" as ${i}`,{cause:n});var r}const Jl="Bare Item",tc="Boolean",ec="Byte Sequence",ic="Decimal",nc="Integer";const rc=/[\x00-\x1f\x7f]+/,sc="Token",ac="Key";function oc(t,e,i){return Zl("serialize",t,e,i)}function lc(t){if(!1===ArrayBuffer.isView(t))throw oc(t,ec);return`:${e=t,btoa(String.fromCharCode(...e))}:`;var e}function cc(t){if(function(t){return t<-999999999999999||999999999999999<t}(t))throw oc(t,nc);return t.toString()}function hc(t,e){if(t<0)return-hc(-t,e);const i=Math.pow(10,e);if(Math.abs(t*i%1-.5)<Number.EPSILON){const e=Math.floor(t*i);return(e%2==0?e:e+1)/i}return Math.round(t*i)/i}function uc(t){const e=hc(t,3);if(Math.floor(Math.abs(e)).toString().length>12)throw oc(t,ic);const i=e.toString();return i.includes(".")?i:`${i}.0`}const dc="String";function fc(t){const e=(i=t).description||i.toString().slice(7,-1);var i;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e))throw oc(e,sc);return e}function gc(t){switch(typeof t){case"number":if(!ki(t))throw oc(t,Jl);return Number.isInteger(t)?cc(t):uc(t);case"string":return function(t){if(rc.test(t))throw oc(t,dc);return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(t);case"symbol":return fc(t);case"boolean":return function(t){if("boolean"!=typeof t)throw oc(t,tc);return t?"?1":"?0"}(t);case"object":if(t instanceof Date)return function(t){return`@${cc(t.getTime()/1e3)}`}(t);if(t instanceof Uint8Array)return lc(t);if(t instanceof Xl)return fc(t);default:throw oc(t,Jl)}}function pc(t){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(t))throw oc(t,ac);return t}function mc(t){return null==t?"":Object.entries(t).map((([t,e])=>!0===e?`;${pc(t)}`:`;${pc(t)}=${gc(e)}`)).join("")}function vc(t){return t instanceof ql?`${gc(t.value)}${mc(t.params)}`:gc(t)}function yc(t,e={whitespace:!0}){if("object"!=typeof t)throw oc(t,Ql);const i=t instanceof Map?t.entries():Object.entries(t),n=null!=e&&e.whitespace?" ":"";return Array.from(i).map((([t,e])=>{e instanceof ql==!1&&(e=new ql(e));let i=pc(t);var n;return!0===e.value?i+=mc(e.params):(i+="=",Array.isArray(e.value)?i+=`(${(n=e).value.map(vc).join(" ")})${mc(n.params)}`:i+=vc(e)),i})).join(`,${n}`)}const Ac=t=>"ot"===t||"sf"===t||"st"===t,Ec=t=>"number"==typeof t?ki(t):null!=t&&""!==t&&!1!==t;const Tc=t=>Math.round(t),bc=t=>100*Tc(t/100),kc={br:Tc,d:Tc,bl:bc,dl:bc,mtp:bc,nor:(t,e)=>(null!=e&&e.baseUrl&&(t=function(t,e){const i=new URL(t),n=new URL(e);if(i.origin!==n.origin)return t;const r=i.pathname.split("/").slice(1),s=n.pathname.split("/").slice(1,-1);for(;r[0]===s[0];)r.shift(),s.shift();for(;s.length;)s.shift(),r.unshift("..");return r.join("/")}(t,e.baseUrl)),encodeURIComponent(t)),rtp:bc,tb:Tc};function Sc(t,e={}){return t?function(t,e){return yc(t,e)}(function(t,e){const i={};if(null==t||"object"!=typeof t)return i;const n=Object.keys(t).sort(),r=bi({},kc,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=r[n];o&&(a=o(a,e)),"v"===n&&1===a||"pr"==n&&1===a||Ec(a)&&(Ac(n)&&"string"==typeof a&&(a=new Xl(a)),i[n]=a)})),i}(t,e),bi({whitespace:!1},e)):""}function _c(t,e,i){return bi(t,function(t,e={}){if(!t)return{};const i=Object.entries(t),n=Object.entries(zl).concat(Object.entries((null==e?void 0:e.customHeaderMap)||{})),r=i.reduce(((t,e)=>{var i;const[r,s]=e,a=(null==(i=n.find((t=>t[1].includes(r))))?void 0:i[0])||Wl.REQUEST;return null!=t[a]||(t[a]={}),t[a][r]=s,t}),{});return Object.entries(r).reduce(((t,[i,n])=>(t[i]=Sc(n,e),t)),{})}(e,i))}const Lc="CMCD";const Rc=/CMCD=[^&#]+/;function Cc(t,e,i){const n=function(t,e={}){if(!t)return"";const i=Sc(t,e);return`${Lc}=${encodeURIComponent(i)}`}(e,i);if(!n)return t;if(Rc.test(t))return t.replace(Rc,n);const r=t.includes("?")?"&":"?";return`${t}${r}${n}`}function wc(t,e,i,n){t&&Object.keys(e).forEach((r=>{const s=t.filter((t=>t.groupId===r)).map((t=>{const s=bi({},t);return s.details=void 0,s.attrs=new Mi(s.attrs),s.url=s.attrs.URI=Ic(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),s.groupId=s.attrs["GROUP-ID"]=e[r],s.attrs["PATHWAY-ID"]=n,s}));t.push(...s)}))}function Ic(t,e,i,n){const{HOST:r,PARAMS:s,[i]:a}=n;let o;e&&(o=null==a?void 0:a[e],o&&(t=o));const l=new self.URL(t);return r&&!o&&(l.host=r),s&&Object.keys(s).sort().forEach((t=>{t&&l.searchParams.set(t,s[t])})),l.href}const Dc=/^age:\s*[\d.]+\s*$/im;class Pc{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 Ui,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,i){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=i,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t||!e)return;const i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then((()=>{if(this.loader===i&&!this.stats.aborted)return r(i,e.url)})).catch((t=>{if(this.loader===i&&!this.stats.aborted)return i.open("GET",e.url,!0),r(i,e.url)})).then((()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,e,t)})).catch((t=>{this.callbacks.onError({code:i.status,text:t.message},e,i,n)})):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const n=e.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:s}=i.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),i.timeout=r&&ki(r)?r:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:i}=this;if(!t||!e)return;const n=e.readyState,r=this.config;if(!i.aborted&&n>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(i.loading.first-i.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)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const r=s?e.response:e.responseText,a="arraybuffer"===e.responseType?r.byteLength:r.length;if(i.loaded=i.total=a,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first),!this.callbacks)return;const o=this.callbacks.onProgress;if(o&&o(i,t,r,e),!this.callbacks)return;const l={url:e.responseURL,data:r,code:n};this.callbacks.onSuccess(l,i,t,e)}else{const s=r.loadPolicy.errorRetry;Ts(s,i.retry,!1,{url:t.url,data:void 0,code:n})?this.retry(s):(Oi.error(`${n} while loading ${t.url}`),this.callbacks.onError({code:n,text:e.statusText},t,e,i))}}}loadtimeout(){if(!this.config)return;const t=this.config.loadPolicy.timeoutRetry;if(Ts(t,this.stats.retry,!0))this.retry(t);else{var e;Oi.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:i}=this;this.retryDelay=As(t,i.retry),i.retry++,Oi.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==e?void 0:e.url}, retrying ${i.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&&Dc.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 Oc=/(\d+)-(\d+)\/(\d+)/;class xc{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||Nc,this.controller=new self.AbortController,this.stats=new Ui}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,i){const n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const r=function(t,e){const i={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(bi({},t.headers))};t.rangeEnd&&i.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1));return i}(t,this.controller.signal),s=i.onProgress,a="arraybuffer"===t.responseType,o=a?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:c}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,r),self.clearTimeout(this.requestTimeout),e.timeout=l&&ki(l)?l:c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),i.onTimeout(n,t,this.response)}),e.timeout),self.fetch(this.request).then((r=>{this.response=this.loader=r;const o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),i.onTimeout(n,t,this.response)}),c-(o-n.loading.start)),!r.ok){const{status:t,statusText:e}=r;throw new Mc(e||"fetch, bad network response",t,r)}return n.loading.first=o,n.total=function(t){const e=t.get("Content-Range");if(e){const t=function(t){const e=Oc.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(ki(t))return t}const i=t.get("Content-Length");if(i)return parseInt(i)}(r.headers)||n.total,s&&ki(e.highWaterMark)?this.loadProgressively(r,n,t,e.highWaterMark,s):a?r.arrayBuffer():"json"===t.responseType?r.json():r.text()})).then((r=>{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=r[o];l&&(n.loaded=n.total=l);const c={url:a.url,data:r,code:a.status};s&&!ki(e.highWaterMark)&&s(n,t,r,a),i.onSuccess(c,n,t,a)})).catch((e=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const r=e&&e.code||0,s=e?e.message:null;i.onError({code:r,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,i,n=0,r){const s=new Da,a=t.body.getReader(),o=()=>a.read().then((a=>{if(a.done)return s.dataLength&&r(e,i,s.flush(),t),Promise.resolve(new ArrayBuffer(0));const l=a.value,c=l.length;return e.loaded+=c,c<n||s.dataLength?(s.push(l),s.dataLength>=n&&r(e,i,s.flush(),t)):r(e,i,l,t),o()})).catch((()=>Promise.reject()));return o()}}function Nc(t,e){return new self.Request(t.url,e)}class Mc extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const Fc=/\s/,Bc={newCue(t,e,i,n){const r=[];let s,a,o,l,c;const h=self.VTTCue||self.TextTrackCue;for(let d=0;d<n.rows.length;d++)if(s=n.rows[d],o=!0,l=0,c="",!s.isEmpty()){var u;for(let t=0;t<s.chars.length;t++)Fc.test(s.chars[t].uchar)&&o?l++:(c+=s.chars[t].uchar,o=!1);s.cueStartTime=e,e===i&&(i+=1e-4),l>=16?l--:l++;const n=Tl(c.trim()),f=Ll(e,i,n);null!=t&&null!=(u=t.cues)&&u.getCueById(f)||(a=new h(e,i,n),a.id=f,a.line=d+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),r.push(a))}return t&&r.length&&(r.sort(((t,e)=>"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line)),r.forEach((e=>Gr(t,e)))),r}},Uc=Ai(Ai({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:Pc,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:i}=this,{autoLevelEnabled:n,media:r}=i;if(!t||!r)return;const s=performance.now(),a=e?e.stats:t.stats,o=e?e.duration:t.duration,l=s-a.loading.start,c=i.minAutoLevel;if(a.aborted||a.loaded&&a.loaded===a.total||t.level<=c)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!n||r.paused||!r.playbackRate||!r.readyState)return;const h=i.mainForwardBufferInfo;if(null===h)return;const u=this.bwEstimator.getEstimateTTFB(),d=Math.abs(r.playbackRate);if(l<=Math.max(u,o/(2*d)*1e3))return;const f=h.len/d,g=a.loading.first?a.loading.first-a.loading.start:-1,p=a.loaded&&g>-1,m=this.getBwEstimate(),v=i.levels,y=v[t.level],A=a.total||Math.max(a.loaded,Math.round(o*y.averageBitrate/8));let E=p?l-g:l;E<1&&p&&(E=Math.min(l,8*a.loaded/m));const T=p?1e3*a.loaded/E:0,b=T?(A-a.loaded)/T:8*A/m+u/1e3;if(b<=f)return;const k=T?8*T:m;let S,_=Number.POSITIVE_INFINITY;for(S=t.level-1;S>c;S--){const t=v[S].maxBitrate;if(_=this.getTimeToLoadFrag(u/1e3,k,o*t,!v[S].details),_<f)break}if(_>=b)return;if(_>10*o)return;i.nextLoadLevel=i.nextAutoLevel=S,p?this.bwEstimator.sample(l-Math.min(u,g),a.loaded):this.bwEstimator.sampleTTFB(l);const L=v[S].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>L&&this.resetEstimator(L),this.clearTimer(),Oi.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: ${b.toFixed(3)} s\n Estimated load time for down switch fragment: ${_.toFixed(3)} s\n TTFB estimate: ${0|g} ms\n Current BW estimate: ${ki(m)?0|m:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${S} @ ${0|L} bps`),i.trigger(Li.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:a})},this.hls=t,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(t){t&&(Oi.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 Ns(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate)}registerListeners(){const{hls:t}=this;t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.FRAG_LOADING,this.onFragLoading,this),t.on(Li.FRAG_LOADED,this.onFragLoaded,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.on(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(Li.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.on(Li.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t&&(t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.FRAG_LOADING,this.onFragLoading,this),t.off(Li.FRAG_LOADED,this.onFragLoaded,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.off(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(Li.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.off(Li.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 i=e.frag;if(!this.ignoreFragment(i)){var n;if(!i.bitrateTest)this.fragCurrent=i,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 Ci.BUFFER_ADD_CODEC_ERROR:case Ci.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case Ci.FRAG_LOAD_TIMEOUT:{const t=e.frag,{fragCurrent:i,partCurrent:n}=this;if(t&&i&&t.sn===i.sn&&t.level===i.level){const e=performance.now(),i=n?n.stats:t.stats,r=e-i.loading.start,s=i.loading.first?i.loading.first-i.loading.start:-1;if(i.loaded&&s>-1){const t=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(r-Math.min(t,s),i.loaded)}else this.bwEstimator.sampleTTFB(r)}break}}}getTimeToLoadFrag(t,e,i,n){return t+i/e+(n?this.lastLevelLoadSec:0)}onLevelLoaded(t,e){const i=this.hls.config,{loading:n}=e.stats,r=n.end-n.start;ki(r)&&(this.lastLevelLoadSec=r/1e3),e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}onFragLoaded(t,{frag:e,part:i}){const n=i?i.stats:e.stats;if(e.type===xr&&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=i?i.duration:e.duration,r=this.hls.levels[e.level],s=(r.loaded?r.loaded.bytes:0)+n.loaded,a=(r.loaded?r.loaded.duration:0)+t;r.loaded={bytes:s,duration:a},r.realBitrate=Math.round(8*s/a)}if(e.bitrateTest){const t={stats:n,frag:e,part:i,id:e.type};this.onFragBuffered(Li.FRAG_BUFFERED,t),e.bitrateTest=!1}else this.lastLoadedFragLevel=e.level}}onFragBuffered(t,e){const{frag:i,part:n}=e,r=null!=n&&n.stats.loaded?n.stats:i.stats;if(r.aborted)return;if(this.ignoreFragment(i))return;const s=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(s,r.loaded),r.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==xr||"initSegment"===t.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:t,minAutoLevel:e}=this.hls,i=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,r=this.findBestLevel(i,e,t,0,n,1,1);if(r>-1)return r;const s=this.hls.firstLevel,a=Math.min(Math.max(s,e),t);return Oi.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(),i=this.lastLoadedFragLevel>-1;if(!(-1===t||e&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return t;const n=e&&i?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:i}=this,{maxAutoLevel:n,config:r,minAutoLevel:s}=i,a=e?e.duration:t?t.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let c=r.abrBandWidthFactor,h=r.abrBandWidthUpFactor;if(l){const t=this.findBestLevel(o,s,n,l,0,c,h);if(t>=0)return t}let u=a?Math.min(a,r.maxStarvationDelay):r.maxStarvationDelay;if(!l){const t=this.bitrateTestDelay;if(t){u=(a?Math.min(a,r.maxLoadingDelay):r.maxLoadingDelay)-t,Oi.info(`[abr] bitrate test took ${Math.round(1e3*t)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),c=h=1}}const d=this.findBestLevel(o,s,n,l,u,c,h);if(Oi.info(`[abr] ${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${d}`),d>-1)return d;const f=i.levels[s],g=i.levels[i.loadLevel];return(null==f?void 0:f.bitrate)<(null==g?void 0:g.bitrate)?s:i.loadLevel}getStarvationDelay(){const t=this.hls,e=t.media;if(!e)return 1/0;const i=e&&0!==e.playbackRate?Math.abs(e.playbackRate):1,n=t.mainForwardBufferInfo;return(n?n.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(t,e,i,n,r,s,a){var o;const l=n+r,c=this.lastLoadedFragLevel,h=-1===c?this.hls.firstLevel:c,{fragCurrent:u,partCurrent:d}=this,{levels:f,allAudioTracks:g,loadLevel:p,config:m}=this.hls;if(1===f.length)return 0;const v=f[h],y=!(null==v||null==(o=v.details)||!o.live),A=-1===p||-1===c;let E,T="SDR",b=(null==v?void 0:v.frameRate)||0;const{audioPreference:k,videoPreference:S}=m,_=this.audioTracksByGroup||(this.audioTracksByGroup=function(t){return t.reduce(((t,e)=>{let i=t.groups[e.groupId];i||(i=t.groups[e.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(e);const n=e.channels||"2";return i.channels[n]=(i.channels[n]||0)+1,i.hasDefault=i.hasDefault||e.default,i.hasAutoSelect=i.hasAutoSelect||e.autoselect,i.hasDefault&&(t.hasDefaultAudio=!0),i.hasAutoSelect&&(t.hasAutoSelectAudio=!0),t}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(g));if(A){if(-1!==this.firstSelection)return this.firstSelection;const n=this.codecTiers||(this.codecTiers=function(t,e,i,n){return t.slice(i,n+1).reduce(((t,i)=>{if(!i.codecSet)return t;const n=i.audioGroups;let r=t[i.codecSet];r||(t[i.codecSet]=r={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),r.minBitrate=Math.min(r.minBitrate,i.bitrate);const s=Math.min(i.height,i.width);return r.minHeight=Math.min(r.minHeight,s),r.minFramerate=Math.min(r.minFramerate,i.frameRate),r.maxScore=Math.max(r.maxScore,i.score),r.fragmentError+=i.fragmentError,r.videoRanges[i.videoRange]=(r.videoRanges[i.videoRange]||0)+1,n&&n.forEach((t=>{if(!t)return;const i=e.groups[t];i&&(r.hasDefaultAudio=r.hasDefaultAudio||e.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(i.channels).forEach((t=>{r.channels[t]=(r.channels[t]||0)+i.channels[t]})))})),t}),{})}(f,_,e,i)),r=function(t,e,i,n,r){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,h=!1,u=1/0,d=1/0,f=1/0,g=0,p=[];const{preferHDR:m,allowedVideoRanges:v}=$s(e,r);for(let e=s.length;e--;){const i=t[s[e]];c=i.channels[2]>0,u=Math.min(u,i.minHeight),d=Math.min(d,i.minFramerate),f=Math.min(f,i.minBitrate);const n=v.filter((t=>i.videoRanges[t]>0));n.length>0&&(h=!0,p=n)}u=ki(u)?u:0,d=ki(d)?d:0;const y=Math.max(1080,u),A=Math.max(30,d);return f=ki(f)?f:i,i=Math.max(f,i),h||(e=void 0,p=[]),{codecSet:s.reduce(((e,n)=>{const r=t[n];if(n===e)return e;if(r.minBitrate>i)return Gs(n,`min bitrate of ${r.minBitrate} > current estimate of ${i}`),e;if(!r.hasDefaultAudio)return Gs(n,"no renditions with default or auto-select sound found"),e;if(o&&n.indexOf(o.substring(0,4))%5!=0)return Gs(n,`audio codec preference "${o}" not found`),e;if(a&&!l){if(!r.channels[a])return Gs(n,`no renditions with ${a} channel sound found (channels options: ${Object.keys(r.channels)})`),e}else if((!o||l)&&c&&0===r.channels[2])return Gs(n,"no renditions with stereo sound found"),e;return r.minHeight>y?(Gs(n,`min resolution of ${r.minHeight} > maximum of ${y}`),e):r.minFramerate>A?(Gs(n,`min framerate of ${r.minFramerate} > maximum of ${A}`),e):p.some((t=>r.videoRanges[t]>0))?r.maxScore<g?(Gs(n,`max score of ${r.maxScore} < selected max of ${g}`),e):e&&(dr(n)>=dr(e)||r.fragmentError>t[e].fragmentError)?e:(g=r.maxScore,n):(Gs(n,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),e)}),void 0),videoRanges:p,preferHDR:m,minFramerate:d,minBitrate:f}}(n,T,t,k,S),{codecSet:s,videoRanges:a,minFramerate:o,minBitrate:l,preferHDR:c}=r;E=s,T=c?a[a.length-1]:a[0],b=o,t=Math.max(t,l),Oi.log(`[abr] picked start tier ${JSON.stringify(r)}`)}else E=null==v?void 0:v.codecSet,T=null==v?void 0:v.videoRange;const L=d?d.duration:u?u.duration:0,R=this.bwEstimator.getEstimateTTFB()/1e3,C=[];for(let o=i;o>=e;o--){var w;const e=f[o],u=o>h;if(!e)continue;if(m.useMediaCapabilities&&!e.supportedResult&&!e.supportedPromise){const i=navigator.mediaCapabilities;"function"==typeof(null==i?void 0:i.decodingInfo)&&Bs(e,_,T,b,t,k)?(e.supportedPromise=Us(e,_,i),e.supportedPromise.then((t=>{if(!this.hls)return;e.supportedResult=t;const i=this.hls.levels,n=i.indexOf(e);t.error?Oi.warn(`[abr] MediaCapabilities decodingInfo error: "${t.error}" for level ${n} ${JSON.stringify(t)}`):t.supported||(Oi.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${n} ${JSON.stringify(t)}`),n>-1&&i.length>1&&(Oi.log(`[abr] Removing unsupported level ${n}`),this.hls.removeLevel(n)))}))):e.supportedResult=Ms}if(E&&e.codecSet!==E||T&&e.videoRange!==T||u&&b>e.frameRate||!u&&b>0&&b<e.frameRate||e.supportedResult&&(null==(w=e.supportedResult.decodingInfoResults)||!w[0].smooth)){C.push(o);continue}const g=e.details,S=(d?null==g?void 0:g.partTarget:null==g?void 0:g.averagetargetduration)||L;let I;I=u?a*t:s*t;const D=L&&n>=2*L&&0===r?f[o].averageBitrate:f[o].maxBitrate,P=this.getTimeToLoadFrag(R,I,D*S,void 0===g);if(I>=D&&(o===c||0===e.loadError&&0===e.fragmentError)&&(P<=R||!ki(P)||y&&!this.bitrateTestDelay||P<l)){const t=this.forcedAutoLevel;return o===p||-1!==t&&t===p||(C.length&&Oi.trace(`[abr] Skipped level(s) ${C.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${f[C[0]].codecs}" ${f[C[0]].videoRange}; not compatible with "${v.codecs}" ${T}`),Oi.info(`[abr] switch candidate:${h}->${o} adjustedbw(${Math.round(I)})-bitrate=${Math.round(I-D)} ttfb:${R.toFixed(1)} avgDuration:${S.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${P.toFixed(1)} firstSelection:${A} codecSet:${E} videoRange:${T} hls.loadLevel:${p}`)),A&&(this.firstSelection=o),o}}return-1}set nextAutoLevel(t){const{maxAutoLevel:e,minAutoLevel:i}=this.hls,n=Math.min(Math.max(t,i),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(Li.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&&Oi.error(`Media element src was set while attaching MediaSource (${e} > ${t})`)},this.hls=t;const e="[buffer-controller]";var i;this.appendSource=(i=ar(t.config.preferManagedMediaSource),"undefined"!=typeof self&&i===self.ManagedMediaSource),this.log=Oi.log.bind(Oi,e),this.warn=Oi.warn.bind(Oi,e),this.error=Oi.error.bind(Oi,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(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.BUFFER_RESET,this.onBufferReset,this),t.on(Li.BUFFER_APPENDING,this.onBufferAppending,this),t.on(Li.BUFFER_CODECS,this.onBufferCodecs,this),t.on(Li.BUFFER_EOS,this.onBufferEos,this),t.on(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Li.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(Li.FRAG_PARSED,this.onFragParsed,this),t.on(Li.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.BUFFER_RESET,this.onBufferReset,this),t.off(Li.BUFFER_APPENDING,this.onBufferAppending,this),t.off(Li.BUFFER_CODECS,this.onBufferCodecs,this),t.off(Li.BUFFER_EOS,this.onBufferEos,this),t.off(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Li.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(Li.FRAG_PARSED,this.onFragParsed,this),t.off(Li.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Ho(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 i=2;(e.audio&&!e.video||!e.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media,n=ar(this.appendSource);if(i&&n){var r;const t=this.mediaSource=new n;this.log(`created media source: ${null==(r=t.constructor)?void 0:r.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{i.removeAttribute("src");const n=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||n&&t instanceof n,jo(i),function(t,e){const i=self.document.createElement("source");i.type="video/mp4",i.src=e,t.appendChild(i)}(i,e),i.load()}catch(t){i.src=e}else i.src=e;i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:i}=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),i&&self.URL.revokeObjectURL(i),this.mediaSrc===i?(t.removeAttribute("src"),this.appendSource&&jo(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(Li.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach((t=>{this.resetBuffer(t)})),this._initSourceBuffer()}resetBuffer(t){const e=this.sourceBuffer[t];try{var i;if(e)this.removeBufferListeners(t),this.sourceBuffer[t]=void 0,null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(e)}catch(e){this.warn(`onBufferReset ${t}`,e)}}onBufferCodecs(t,e){const i=this.getSourceBufferTypes().length,n=Object.keys(e);if(n.forEach((t=>{if(i){const i=this.tracks[t];if(i&&"function"==typeof i.buffer.changeType){var n;const{id:r,codec:s,levelCodec:a,container:o,metadata:l}=e[t],c=mr(i.codec,i.levelCodec),h=null==c?void 0:c.replace(Yo,"$1");let u=mr(s,a);const d=null==(n=u)?void 0:n.replace(Yo,"$1");if(u&&h!==d){"audio"===t.slice(0,5)&&(u=pr(u,this.appendSource));const e=`${o};codecs=${u}`;this.appendChangeType(t,e),this.log(`switching codec ${c} to ${u}`),this.tracks[t]={buffer:i.buffer,codec:s,container:o,levelCodec:a,metadata:l,id:r}}}}else this.pendingTracks[t]=e[t]})),i)return;const r=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==r&&(this.log(`${r} bufferCodec event(s) expected ${n.join(",")}`),this.bufferCodecEventsExpected=r),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}appendChangeType(t,e){const{operationQueue:i}=this,n={execute:()=>{const n=this.sourceBuffer[t];n&&(this.log(`changing ${t} sourceBuffer type to ${e}`),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn(`Failed to change ${t} SourceBuffer type`,e)}};i.append(n,t,!!this.pendingTracks[t])}onBufferAppending(t,e){const{hls:i,operationQueue:n,tracks:r}=this,{data:s,type:a,frag:o,part:l,chunkMeta:c}=e,h=c.buffering[a],u=self.performance.now();h.start=u;const d=o.stats.buffering,f=l?l.stats.buffering:null;0===d.start&&(d.start=u),f&&0===f.start&&(f.start=u);const g=r.audio;let p=!1;"audio"===a&&"audio/mpeg"===(null==g?void 0:g.container)&&(p=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);const m=o.start,v={execute:()=>{if(h.executeStart=self.performance.now(),p){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();h.executeEnd=h.end=t,0===d.first&&(d.first=t),f&&0===f.first&&(f.first=t);const{sourceBuffer:e}=this,i={};for(const t in e)i[t]=ea.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(Li.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:c,parent:o.type,timeRanges:i})},onError:t=>{const e={type:Ri.MEDIA_ERROR,parent:o.type,details:Ci.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=Ci.BUFFER_FULL_ERROR;else{const t=++this.appendErrors[a];e.details=Ci.BUFFER_APPEND_ERROR,this.warn(`Failed ${t}/${i.config.appendErrorMaxRetry} times to append segment in "${a}" sourceBuffer`),t>=i.config.appendErrorMaxRetry&&(e.fatal=!0)}i.trigger(Li.ERROR,e)}};n.append(v,a,!!this.pendingTracks[a])}onBufferFlushing(t,e){const{operationQueue:i}=this,n=t=>({execute:this.removeExecutor.bind(this,t,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(Li.BUFFER_FLUSHED,{type:t})},onError:e=>{this.warn(`Failed to remove from ${t} SourceBuffer`,e)}});e.type?i.append(n(e.type),e.type):this.getSourceBufferTypes().forEach((t=>{i.append(n(t),t)}))}onFragParsed(t,e){const{frag:i,part:n}=e,r=[],s=n?n.elementaryStreams:i.elementaryStreams;s[Vi]?r.push("audiovideo"):(s[$i]&&r.push("audio"),s[Gi]&&r.push("video"));0===r.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers((()=>{const t=self.performance.now();i.stats.buffering.end=t,n&&(n.stats.buffering.end=t);const e=n?n.stats:i.stats;this.hls.trigger(Li.FRAG_BUFFERED,{frag:i,part:n,stats:e,id:i.type})}),r)}onFragChanged(t,e){this.trimBuffers()}onBufferEos(t,e){this.getSourceBufferTypes().reduce(((t,i)=>{const n=this.sourceBuffer[i];return!n||e.type&&e.type!==i||(n.ending=!0,n.ended||(n.ended=!0,this.log(`${i} 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:i}=this;if(!i||null===e)return;if(!this.getSourceBufferTypes().length)return;const n=t.config,r=i.currentTime,s=e.levelTargetDuration,a=e.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(ki(a)&&a>0){const t=Math.max(a,s),e=Math.floor(r/s)*s-t;this.flushBackBuffer(r,s,e)}if(ki(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){const t=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),e=Math.max(t,s),i=Math.floor(r/s)*s+e;this.flushFrontBuffer(r,s,i)}}flushBackBuffer(t,e,i){const{details:n,sourceBuffer:r}=this;this.getSourceBufferTypes().forEach((s=>{const a=r[s];if(a){const r=ea.getBuffered(a);if(r.length>0&&i>r.start(0)){if(this.hls.trigger(Li.BACK_BUFFER_REACHED,{bufferEnd:i}),null!=n&&n.live)this.hls.trigger(Li.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(a.ended&&r.end(r.length-1)-t<2*e)return void this.log(`Cannot flush ${s} back buffer while SourceBuffer is in ended state`);this.hls.trigger(Li.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:s})}}}))}flushFrontBuffer(t,e,i){const{sourceBuffer:n}=this;this.getSourceBufferTypes().forEach((r=>{const s=n[r];if(s){const n=ea.getBuffered(s),a=n.length;if(a<2)return;const o=n.start(a-1),l=n.end(a-1);if(i>o||t>=o&&t<=l)return;if(s.ended&&t-l<2*e)return void this.log(`Cannot flush ${r} front buffer while SourceBuffer is in ended state`);this.hls.trigger(Li.BUFFER_FLUSHING,{startOffset:o,endOffset:1/0,type:r})}}))}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:t,hls:e,media:i,mediaSource:n}=this,r=t.fragments[0].start+t.totalduration,s=i.duration,a=ki(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(n.duration=1/0,this.updateSeekableRange(t)):(r>a&&r>s||!ki(s))&&(this.log(`Updating Media Source duration to ${r.toFixed(3)}`),n.duration=r)}updateSeekableRange(t){const e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&null!=e&&e.setLiveSeekableRange){const n=Math.max(0,i[0].start),r=Math.max(n,n+t.totalduration);this.log(`Media Source duration is set to ${e.duration}. Setting seekable range to ${n}-${r}.`),e.setLiveSeekableRange(n,r)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:i}=this,n=Object.keys(i).length;if(n&&(!t||2===n||"audiovideo"in i)){this.createSourceBuffers(i),this.pendingTracks={};const t=this.getSourceBufferTypes();if(t.length)this.hls.trigger(Li.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(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const r in t)if(!e[r]){var n;const s=t[r];if(!s)throw Error(`source buffer exists for track ${r}, however track does not`);let a=-1===(null==(n=s.levelCodec)?void 0:n.indexOf(","))?s.levelCodec:s.codec;a&&"audio"===r.slice(0,5)&&(a=pr(a,this.appendSource));const o=`${s.container};codecs=${a}`;this.log(`creating sourceBuffer(${o})`);try{const t=e[r]=i.addSourceBuffer(o),n=r;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 i=e.removedRanges;null!=i&&i.length&&this.hls.trigger(Li.BUFFER_FLUSHED,{type:r})})),this.tracks[r]={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(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,sourceBufferName:r,mimeType:o})}}}get mediaSrc(){var t,e;const i=(null==(t=this.media)||null==(e=t.querySelector)?void 0:e.call(t,"source"))||this.media;return null==i?void 0:i.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:i}=this;i.current(t).onComplete(),i.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){var i;const n=new Error(`${t} SourceBuffer error. MediaSource readyState: ${null==(i=this.mediaSource)?void 0:i.readyState}`);this.error(`${n}`,e),this.hls.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_APPENDING_ERROR,sourceBufferName:t,error:n,fatal:!1});const r=this.operationQueue.current(t);r&&r.onError(n)}removeExecutor(t,e,i){const{media:n,mediaSource:r,operationQueue:s,sourceBuffer:a}=this,o=a[t];if(!n||!r||!o)return this.warn(`Attempting to remove from the ${t} SourceBuffer, but it does not exist`),void s.shiftAndExecuteNext(t);const l=ki(n.duration)?n.duration:1/0,c=ki(r.duration)?r.duration:1/0,h=Math.max(0,e),u=Math.min(i,l,c);u>h&&(!o.ending||o.ended)?(o.ended=!1,this.log(`Removing [${h},${u}] from the ${t} SourceBuffer`),o.remove(h,u)):s.shiftAndExecuteNext(t)}appendExecutor(t,e){const i=this.sourceBuffer[e];if(i)i.ended=!1,i.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:i}=this,n=e.map((t=>i.appendBlocker(t)));Promise.all(n).then((()=>{t(),e.forEach((t=>{const e=this.sourceBuffer[t];null!=e&&e.updating||i.shiftAndExecuteNext(t)}))}))}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,i){const n=this.sourceBuffer[t];if(!n)return;const r=i.bind(this,t);this.listeners[t].push({event:e,listener:r}),n.addEventListener(e,r)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach((t=>{e.removeEventListener(t.event,t.listener)}))}},capLevelController:Gl,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=Oi.log.bind(Oi,"[info]:"),this.warn=Oi.warn.bind(Oi,"[warning]:"),this.error=Oi.error.bind(Oi,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(Li.ERROR,this.onError,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(Li.ERROR,this.onError,this),t.off(Li.ERROR,this.onErrorOut,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.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)===xr?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i,n;if(e.fatal)return;const r=this.hls,s=e.context;switch(e.details){case Ci.FRAG_LOAD_ERROR:case Ci.FRAG_LOAD_TIMEOUT:case Ci.KEY_LOAD_ERROR:case Ci.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case Ci.FRAG_PARSING_ERROR:if(null!=(i=e.frag)&&i.gap)return void(e.errorAction={action:Ls,flags:Is});case Ci.FRAG_GAP:case Ci.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=Rs);case Ci.LEVEL_EMPTY_ERROR:case Ci.LEVEL_PARSING_ERROR:{var a,o;const t=e.parent===xr?e.level:r.loadLevel;e.details===Ci.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 Ci.LEVEL_LOAD_ERROR:case Ci.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==s?void 0:s.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,s.level)));case Ci.AUDIO_TRACK_LOAD_ERROR:case Ci.AUDIO_TRACK_LOAD_TIMEOUT:case Ci.SUBTITLE_LOAD_ERROR:case Ci.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){const t=r.levels[r.loadLevel];if(t&&(s.type===Pr&&t.hasAudioGroup(s.groupId)||s.type===Or&&t.hasSubtitleGroup(s.groupId)))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,r.loadLevel),e.errorAction.action=Rs,void(e.errorAction.flags=Ds)}return;case Ci.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const t=r.levels[r.loadLevel],i=null==t?void 0:t.attrs["HDCP-LEVEL"];i?e.errorAction={action:Rs,flags:Ps,hdcpLevel:i}:this.keySystemError(e)}return;case Ci.BUFFER_ADD_CODEC_ERROR:case Ci.REMUX_ALLOC_ERROR:case Ci.BUFFER_APPEND_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(n=e.level)?n:r.loadLevel));case Ci.INTERNAL_EXCEPTION:case Ci.BUFFER_APPENDING_ERROR:case Ci.BUFFER_FULL_ERROR:case Ci.LEVEL_SWITCH_ERROR:case Ci.BUFFER_STALLED_ERROR:case Ci.BUFFER_SEEK_OVER_HOLE:case Ci.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:Ls,flags:Is})}e.type===Ri.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 i=ys(this.hls.config.playlistLoadPolicy,t),n=this.playlistError++;if(Ts(i,n,vs(t),t.response))return{action:ws,flags:Is,retryConfig:i,retryCount:n};const r=this.getLevelSwitchAction(t,e);return i&&(r.retryConfig=i,r.retryCount=n),r}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),n=e.levels[i],{fragLoadPolicy:r,keyLoadPolicy:s}=e.config,a=ys(t.details.startsWith("key")?s:r,t),o=e.levels.reduce(((t,e)=>t+e.fragmentError),0);if(n){t.details!==Ci.FRAG_GAP&&n.fragmentError++;if(Ts(a,o,vs(t),t.response))return{action:ws,flags:Is,retryConfig:a,retryCount:o}}const l=this.getLevelSwitchAction(t,i);return a&&(l.retryConfig=a,l.retryCount=o),l}getLevelSwitchAction(t,e){const i=this.hls;null==e&&(e=i.loadLevel);const n=this.hls.levels[e];if(n){var r,s;const e=t.details;n.loadError++,e===Ci.BUFFER_APPEND_ERROR&&n.fragmentError++;let l=-1;const{levels:c,loadLevel:h,minAutoLevel:u,maxAutoLevel:d}=i;i.autoLevelEnabled||(i.loadLevel=-1);const f=null==(r=t.frag)?void 0:r.type,g=(f===Nr&&e===Ci.FRAG_PARSING_ERROR||"audio"===t.sourceBufferName&&(e===Ci.BUFFER_ADD_CODEC_ERROR||e===Ci.BUFFER_APPEND_ERROR))&&c.some((({audioCodec:t})=>n.audioCodec!==t)),p="video"===t.sourceBufferName&&(e===Ci.BUFFER_ADD_CODEC_ERROR||e===Ci.BUFFER_APPEND_ERROR)&&c.some((({codecSet:t,audioCodec:e})=>n.codecSet!==t&&n.audioCodec===e)),{type:m,groupId:v}=null!=(s=t.context)?s:{};for(let i=c.length;i--;){const r=(i+h)%c.length;if(r!==h&&r>=u&&r<=d&&0===c[r].loadError){var a,o;const i=c[r];if(e===Ci.FRAG_GAP&&f===xr&&t.frag){const e=c[r].details;if(e){const i=ks(t.frag,e.fragments,t.frag.start);if(null!=i&&i.gap)continue}}else{if(m===Pr&&i.hasAudioGroup(v)||m===Or&&i.hasSubtitleGroup(v))continue;if(f===Nr&&null!=(a=n.audioGroups)&&a.some((t=>i.hasAudioGroup(t)))||f===Mr&&null!=(o=n.subtitleGroups)&&o.some((t=>i.hasSubtitleGroup(t)))||g&&n.audioCodec===i.audioCodec||!g&&n.audioCodec!==i.audioCodec||p&&n.codecSet===i.codecSet)continue}l=r;break}}if(l>-1&&i.loadLevel!==l)return t.levelRetry=!0,this.playlistError=0,{action:Rs,flags:Is,nextAutoLevel:l}}return{action:Rs,flags:Ds}}onErrorOut(t,e){var i;switch(null==(i=e.errorAction)?void 0:i.action){case Ls:break;case Rs:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===Ci.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,i=t.errorAction;if(!i)return;const{flags:n,hdcpLevel:r,nextAutoLevel:s}=i;switch(n){case Is:this.switchLevel(t,s);break;case Ps:r&&(e.maxHdcpLevel=ts[ts.indexOf(r)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`)}i.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(Li.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(Li.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const i=this.hls.config;if(i.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),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const n=performance.now();if(e){if(this.lastTime){const t=n-this.lastTime,r=i-this.lastDroppedFrames,s=e-this.lastDecodedFrames,a=1e3*r/t,o=this.hls;if(o.trigger(Li.FPS_DROP,{currentDropped:r,currentDecoded:s,totalDroppedFrames:i}),a>0&&r>o.config.fpsDroppedMonitoringThreshold*s){let t=o.currentLevel;Oi.warn("drop FPS ratio greater than max allowed value for currentLevel: "+t),t>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=t)&&(t-=1,o.trigger(Li.FPS_DROP_LEVEL_CAPPING,{level:t,droppedLevel:o.currentLevel}),o.autoLevelCapping=t,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,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:on,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:Bc,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 Ia{constructor(t,e,i){super(t,e,i,"[subtitle-stream-controller]",Mr),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(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Li.ERROR,this.onError,this),t.on(Li.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(Li.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(Li.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(Li.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Li.ERROR,this.onError,this),t.off(Li.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(Li.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(Li.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(Li.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=Aa,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:i,success:n}=e;if(this.fragPrevious=i,this.state=Aa,!n)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let s;const a=i.start;for(let t=0;t<r.length;t++)if(a>=r[t].start&&a<=r[t].end){s=r[t];break}const o=i.start+i.duration;s?s.end=o:(s={start:a,end:o},r.push(s)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null)}onBufferFlushing(t,e){const{startOffset:i,endOffset:n}=e;if(0===i&&n!==Number.POSITIVE_INFINITY){const t=n-1;if(t<=0)return;e.endOffsetSubtitles=Math.max(0,t),this.tracksBuffered.forEach((e=>{for(let i=0;i<e.length;)if(e[i].end<=t)e.shift();else{if(!(e[i].start<t))break;e[i].start=t,i++}})),this.fragmentTracker.removeFragmentsInRange(i,t,Mr)}}onFragBuffered(t,e){var i;this.loadedmetadata||e.frag.type!==xr||null!=(i=this.media)&&i.buffered.length&&(this.loadedmetadata=!0)}onError(t,e){const i=e.frag;(null==i?void 0:i.type)===Mr&&(e.details===Ci.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==ya&&(this.state=Aa))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){this.levels&&$o(this.levels,e)?this.levels=e.map((t=>new os(t))):(this.tracksBuffered=[],this.levels=e.map((t=>{const e=new os(t);return this.tracksBuffered[e.id]=[],e})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Mr),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){var i;if(this.currentTrackId=e.id,null==(i=this.levels)||!i.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 i;const{currentTrackId:n,levels:r}=this,{details:s,id:a}=e;if(!r)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=r[a];if(a>=r.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!=(i=o.details)&&i.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,fs(s,l));else s.hasProgramDateTime&&t.hasProgramDateTime?(oa(s,t),l=s.fragments[0].start):e&&(l=e.start,fs(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===Aa)){ks(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:i}=t,n=e.decryptdata,r=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&"AES-128"===n.method){const t=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch((t=>{throw r.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((i=>{const n=performance.now();r.trigger(Li.FRAG_DECRYPTED,{frag:e,payload:i,stats:{tstart:t,tdecrypt:n}})})).catch((t=>{this.warn(`${t.name}: ${t.message}`),this.state=Aa}))}}doTick(){if(this.media){if(this.state===Aa){const{currentTrackId:t,levels:e}=this,i=null==e?void 0:e[t];if(!i||!e.length||!i.details)return;const{config:n}=this,r=this.getLoadPosition(),s=ea.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,n.maxBufferHole),{end:a,len:o}=s,l=this.getFwdBufferInfo(this.media,xr),c=i.details;if(o>this.getMaxBufferLength(null==l?void 0:l.len)+c.levelTargetDuration)return;const h=c.fragments,u=h.length,d=c.edge;let f=null;const g=this.fragPrevious;if(a<d){const t=n.maxFragLookUpTolerance,e=a>d-t?0:t;f=ks(g,h,Math.max(h[0].start,a),e),!f&&g&&g.start<h[0].start&&(f=h[0])}else f=h[u-1];if(!f)return;if(f=this.mapToInitFragWhenRequired(f),"initSegment"!==f.sn){const t=h[f.sn-c.startSN-1];t&&t.cc===f.cc&&this.fragmentTracker.getState(t)===Ws&&(f=t)}this.fragmentTracker.getState(f)===Ws&&this.loadFragment(f,i,a)}}else this.state=Aa}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,i){this.fragCurrent=t,"initSegment"===t.sn?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,i))}get mediaBufferTimeRanges(){return new Ko(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Os{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.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=Hr(this.media.textTracks);for(let i=0;i<e.length;i++)if("hidden"===e[i].mode)t=e[i];else if("showing"===e[i].mode){t=e[i];break}const i=this.findTrackForTextTrack(t);this.subtitleTrack!==i&&this.setSubtitleTrack(i)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:t}=this;t.on(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.LEVEL_LOADING,this.onLevelLoading,this),t.on(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Li.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(Li.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.LEVEL_LOADING,this.onLevelLoading,this),t.off(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Li.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(Li.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);Hr(this.media.textTracks).forEach((t=>{Vr(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:i,groupId:n,details:r}=e,s=this.tracksInGroup[i];if(!s||s.groupId!==n)return void this.warn(`Subtitle track with id:${i} 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 ${i} "${s.name}" lang:${s.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,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 i=e.subtitleGroups||null,n=this.groupIds;let r=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some((t=>-1===(null==n?void 0:n.indexOf(t))))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const t=this.tracks.filter((t=>!i||-1!==i.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(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=t;const e=this.hls.config.subtitlePreference;if(!r&&e){this.selectDefaultTrack=!1;const i=Vs(e,t);if(i>-1)r=t[i];else{const t=Vs(e,this.tracks);r=this.tracks[t]}}let n=this.findTrackId(r);-1===n&&r&&(n=this.findTrackId(null));const s={subtitleTracks:t};this.log(`Updating subtitle tracks, ${t.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(Li.SUBTITLE_TRACKS_UPDATED,s),-1!==n&&-1===this.trackId&&this.setSubtitleTrack(n)}else this.shouldReloadPlaylist(r)&&this.setSubtitleTrack(this.trackId)}findTrackId(t){const e=this.tracksInGroup,i=this.selectDefaultTrack;for(let n=0;n<e.length;n++){const r=e[n];if((!i||r.default)&&(i||t)&&(!t||Ks(r,t)))return n}if(t){for(let i=0;i<e.length;i++){const n=e[i];if(Go(t.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<e.length;i++){const n=e[i];if(Go(t.attrs,n.attrs,["LANGUAGE"]))return i}}return-1}findTrackForTextTrack(t){if(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){if(Vo(e[i],t))return i}}return-1}onError(t,e){!e.fatal&&e.context&&(e.context.type!==Or||e.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(e.context.groupId)||this.checkRetry(e))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1,this.setSubtitleTrack(t)}setSubtitleOption(t){if(this.hls.config.subtitlePreference=t,t){const e=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,e.length){const i=this.currentTrack;if(i&&Ks(t,i))return i;const n=Vs(t,this.tracksInGroup);if(n>-1){const t=this.tracksInGroup[n];return this.setSubtitleTrack(n),t}if(i)return null;{const i=Vs(t,e);if(i>-1)return e[i]}}}return null}loadPlaylist(t){super.loadPlaylist();const e=this.currentTrack;if(this.shouldLoadPlaylist(e)&&e){const i=e.id,n=e.groupId;let r=e.url;if(t)try{r=t.addDirectives(r)}catch(t){this.warn(`Could not construct new URL with HLS Delivery Directives: ${t}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(Li.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null})}}toggleTrackModes(){const{media:t}=this;if(!t)return;const e=Hr(t.textTracks),i=this.currentTrack;let n;if(i&&(n=e.filter((t=>Vo(i,t)))[0],n||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.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||!ki(t))return void this.warn(`Invalid subtitle track id: ${t}`);this.clearTimer(),this.selectDefaultTrack=!1;const i=this.currentTrack,n=e[t]||null;if(this.trackId=t,this.currentTrack=n,this.toggleTrackModes(),!n)return void this.hls.trigger(Li.SUBTITLE_TRACK_SWITCH,{id:t});const r=!!n.details&&!n.details.live;if(t===this.trackId&&n===i&&r)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(Li.SUBTITLE_TRACK_SWITCH,{id:s,groupId:a,name:o,type:l,url:c});const h=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(h)}},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(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(Li.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(Li.FRAG_LOADING,this.onFragLoading,this),t.on(Li.FRAG_LOADED,this.onFragLoaded,this),t.on(Li.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(Li.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(Li.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(Li.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(Li.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(Li.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(Li.FRAG_LOADING,this.onFragLoading,this),t.off(Li.FRAG_LOADED,this.onFragLoaded,this),t.off(Li.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(Li.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(Li.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(Li.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(Li.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 dl(this,"textTrack1"),e=new dl(this,"textTrack2"),i=new dl(this,"textTrack3"),n=new dl(this,"textTrack4");this.cea608Parser1=new cl(1,t,e),this.cea608Parser2=new cl(3,i,n)}}addCues(t,e,i,n,r){let s=!1;for(let t=r.length;t--;){const n=r[t],h=(a=n[0],o=n[1],l=e,c=i,Math.min(o,c)-Math.max(a,l));if(h>=0&&(n[0]=Math.min(n[0],e),n[1]=Math.max(n[1],i),s=!0,h/(i-e)>.5))return}var a,o,l,c;if(s||r.push([e,i]),this.config.renderTextTracksNatively){const r=this.captionsTracks[t];this.Cues.newCue(r,e,i,n)}else{const r=this.Cues.newCue(null,e,i,n);this.hls.trigger(Li.CUES_PARSED,{type:"captions",cues:r,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:n,timescale:r}){const{unparsedVttFrags:s}=this;"main"===i&&(this.initPTS[e.cc]={baseTime:n,timescale:r}),s.length&&(this.unparsedVttFrags=[],s.forEach((t=>{this.onFragLoaded(Li.FRAG_LOADED,t)})))}getExistingTrack(t,e){const{media:i}=this;if(i)for(let n=0;n<i.textTracks.length;n++){const r=i.textTracks[n];if($l(r,{name:t,lang:e,attrs:{}}))return r}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:i,media:n}=this,{label:r,languageCode:s}=e[t],a=this.getExistingTrack(r,s);if(a)i[t]=a,Vr(i[t]),$r(i[t],n);else{const e=this.createTextTrack("captions",r,s);e&&(e[t]=!0,i[t]=e)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const i={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=i,this.hls.trigger(Li.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}createTextTrack(t,e,i){const n=this.media;if(n)return n.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach((e=>{Vr(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;t<e.length;t++)Vr(e[t])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],n=i.some((t=>t.textCodec===Cl));if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if($o(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const t=this.media,e=t?Hr(t.textTracks):null;if(this.tracks.forEach(((t,i)=>{let n;if(e){let i=null;for(let n=0;n<e.length;n++)if(e[n]&&$l(e[n],t)){i=e[n],e[n]=null;break}i&&(n=i)}if(n)Vr(n);else{const e=Ul(t);n=this.createTextTrack(e,t.name,t.lang),n&&(n.mode="disabled")}n&&this.textTracks.push(n)})),null!=e&&e.length){const t=e.filter((t=>null!==t)).map((t=>t.label));t.length&&Oi.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(Li.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 i=`textTrack${e[1]}`,n=this.captionsProperties[i];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===xr){var i,n;const{cea608Parser1:t,cea608Parser2:r,lastSn:s}=this,{cc:a,sn:o}=e.frag,l=null!=(i=null==(n=e.part)?void 0:n.index)?i:-1;t&&r&&(o!==s+1||o===s&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(t.reset(),r.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(t,e){const{frag:i,payload:n}=e;if(i.type===Mr)if(n.byteLength){const t=i.decryptdata,r="stats"in e;if(null==t||!t.encrypted||r){const t=this.tracks[i.level],r=this.vttCCs;r[i.cc]||(r[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),t&&t.textCodec===Cl?this._parseIMSC1(i,n):this._parseVTTs(e)}}else this.hls.trigger(Li.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const i=this.hls;Pl(e,this.initPTS[t.cc],(e=>{this._appendCues(e,t.level),i.trigger(Li.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(e=>{Oi.log(`Failed to parse IMSC1: ${e}`),i.trigger(Li.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))}_parseVTTs(t){var e;const{frag:i,payload:n}=t,{initPTS:r,unparsedVttFrags:s}=this,a=r.length-1;if(!r[i.cc]&&-1===a)return void s.push(t);const o=this.hls;Rl(null!=(e=i.initSegment)&&e.data?jn(i.initSegment.data,new Uint8Array(n)):n,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,(t=>{this._appendCues(t,i.level),o.trigger(Li.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})}),(e=>{const r="Missing initPTS for VTT MPEGTS"===e.message;r?s.push(t):this._fallbackToIMSC1(i,n),Oi.log(`Failed to parse VTT cue: ${e}`),r&&a>i.cc||o.trigger(Li.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:e})}))}_fallbackToIMSC1(t,e){const i=this.tracks[t.level];i.textCodec||Pl(e,this.initPTS[t.cc],(()=>{i.textCodec=Cl,this._parseIMSC1(t,e)}),(()=>{i.textCodec="wvtt"}))}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const i=this.textTracks[e];if(!i||"disabled"===i.mode)return;t.forEach((t=>Gr(i,t)))}else{const n=this.tracks[e];if(!n)return;const r=n.default?"default":"subtitles"+e;i.trigger(Li.CUES_PARSED,{type:"subtitles",cues:t,track:r})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===Mr&&this.onFragLoaded(Li.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){this.initCea608Parsers();const{cea608Parser1:i,cea608Parser2:n}=this;if(!this.enabled||!i||!n)return;const{frag:r,samples:s}=e;if(r.type!==xr||"NONE"!==this.closedCaptionsForLevel(r))for(let t=0;t<s.length;t++){const e=s[t].bytes;if(e){const r=this.extractCea608Data(e);i.addData(s[t].pts,r[0]),n.addData(s[t].pts,r[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:n,type:r}){const{media:s}=this;if(s&&!(s.currentTime<i)){if(!r||"video"===r){const{captionsTracks:t}=this;Object.keys(t).forEach((n=>Kr(t[n],e,i)))}if(this.config.renderTextTracksNatively&&0===e&&void 0!==n){const{textTracks:t}=this;Object.keys(t).forEach((i=>Kr(t[i],e,n)))}}}extractCea608Data(t){const e=[[],[]],i=31&t[0];let n=2;for(let r=0;r<i;r++){const i=t[n++],r=127&t[n++],s=127&t[n++];if(0===r&&0===s)continue;if(0!=(4&i)){const t=3&i;0!==t&&1!==t||(e[t].push(r),e[t].push(s))}}return e}},audioStreamController:class extends Ia{constructor(t,e,i){super(t,e,i,"[audio-stream-controller]",Nr),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:t}=this;t.on(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Li.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(Li.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(Li.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(Li.ERROR,this.onError,this),t.on(Li.BUFFER_RESET,this.onBufferReset,this),t.on(Li.BUFFER_CREATED,this.onBufferCreated,this),t.on(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Li.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(Li.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Li.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(Li.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(Li.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(Li.ERROR,this.onError,this),t.off(Li.BUFFER_RESET,this.onBufferReset,this),t.off(Li.BUFFER_CREATED,this.onBufferCreated,this),t.off(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Li.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(Li.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:i,initPTS:n,timescale:r}){if("main"===i){const t=e.cc;this.initPTS[e.cc]={baseTime:n,timescale:r},this.log(`InitPTS for cc: ${t} found from main: ${n}`),this.videoTrackCC=t,this.state===Ca&&this.tick()}}startLoad(t){if(!this.levels)return this.startPosition=t,void(this.state=ya);const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),e>0&&-1===t?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=Aa):(this.loadedmetadata=!1,this.state=ka),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case Aa:this.doTickIdle();break;case ka:{var t;const{levels:e,trackId:i}=this,n=null==e||null==(t=e[i])?void 0:t.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=Ca}break}case ba:{var e;const t=performance.now(),i=this.retryDate;if(!i||t>=i||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=Aa}break}case Ca:{const t=this.waitingData;if(t){const{frag:e,part:i,cache:n,complete:r}=t;if(void 0!==this.initPTS[e.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=Ta;const t={frag:e,part:i,payload:n.flush(),networkDetails:null};this._handleFragmentLoadProgress(t),r&&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(),i=ea.bufferInfo(this.mediaBuffer,t,this.config.maxBufferHole);Ss(i.end,this.config.maxFragLookUpTolerance,e)<0&&(this.log(`Waiting fragment cc (${e.cc}) @ ${e.start} cancelled because another fragment at ${i.end} is needed`),this.clearWaitingFragment())}}else this.state=Aa}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Aa)}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:i,trackId:n}=this,r=t.config;if(!i&&(this.startFragRequested||!r.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=ka);const o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,$i,Nr));const l=this.getFwdBufferInfo(o,Nr);if(null===l)return;const{bufferedTrack:c,switchingTrack:h}=this;if(!h&&this._streamEnded(l,a))return t.trigger(Li.BUFFER_EOS,{type:"audio"}),void(this.state=La);const u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,xr),d=l.len,f=this.getMaxBufferLength(null==u?void 0:u.len),g=a.fragments,p=g[0].start;let m=this.flushing?this.getLoadPosition():l.end;if(h&&i){const t=this.getLoadPosition();c&&!Go(h.attrs,c.attrs)&&(m=t),a.PTSKnown&&t<p&&(l.end>p||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=p+.05)}if(d>=f&&!h&&m<g[g.length-1].start)return;let v=this.getNextFragment(m,a),y=!1;if(v&&this.isLoopLoading(v,m)&&(y=!!v.gap,v=this.getNextFragmentLoopLoading(v,a,l,xr,f)),!v)return void(this.bufferFlushed=!0);const A=u&&v.start>u.end+a.targetduration;if(A||(null==u||!u.len)&&l.len){const t=this.getAppendedFrag(v.start,xr);if(null===t)return;if(y||(y=!!t.gap||!!A&&0===u.len),A&&!y||y&&l.nextStart&&l.nextStart<t.end)return}this.loadFragment(v,s,m)}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map((t=>new os(t)))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=Aa,this.flushAudioIfNeeded(e)):(this.switchingTrack=null,this.bufferedTrack=e,this.state=ya),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(Li.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var i;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=e);const{levels:n}=this,{details:r,id:s}=e;if(!n)return void this.warn(`Audio tracks were reset while loading level ${s}`);this.log(`Audio track ${s} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const a=n[s];let o=0;if(r.live||null!=(i=a.details)&&i.live){this.checkLiveUpdate(r);const t=this.mainDetails;if(r.deltaUpdateFailed||!t)return;var l;if(!a.details&&r.hasProgramDateTime&&t.hasProgramDateTime)oa(r,t),o=r.fragments[0].start;else o=this.alignPlaylists(r,a.details,null==(l=this.levelLastLoaded)?void 0:l.details)}a.details=r,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(this.mainDetails||r,o),this.state!==ka||this.waitForCdnTuneIn(r)||(this.state=Aa),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,payload:r}=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 ${i.sn} of level ${i.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(i.start);const h=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new Uo(this.hls,Nr,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const d=this.initPTS[i.cc],f=null==(e=i.initSegment)?void 0:e.data;if(void 0!==d){const t=!1,e=n?n.index:-1,s=-1!==e,a=new ia(i.level,i.sn,i.stats.chunkCount,r.byteLength,e,s);u.push(r,f,h,"",i,n,c.totalduration,t,a,d)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${a}`);const{cache:t}=this.waitingData=this.waitingData||{frag:i,part:n,cache:new Da,complete:!1};t.push(new Uint8Array(r)),this.waitingVideoCC=this.videoTrackCC,this.state=Ca}}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const i=e.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:i,part:n}=e;if(i.type===Nr)if(this.fragContextChanged(i))this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if("initSegment"!==i.sn){this.fragPrevious=i;const t=this.switchingTrack;t&&(this.bufferedTrack=t,this.switchingTrack=null,this.hls.trigger(Li.AUDIO_TRACK_SWITCHED,Ai({},t)))}this.fragBufferedComplete(i,n)}else if(!this.loadedmetadata&&i.type===xr){const t=this.videoBuffer||this.media;if(t){ea.getBuffered(t).length&&(this.loadedmetadata=!0)}}}onError(t,e){var i;if(e.fatal)this.state=Ra;else switch(e.details){case Ci.FRAG_GAP:case Ci.FRAG_PARSING_ERROR:case Ci.FRAG_DECRYPT_ERROR:case Ci.FRAG_LOAD_ERROR:case Ci.FRAG_LOAD_TIMEOUT:case Ci.KEY_LOAD_ERROR:case Ci.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Nr,e);break;case Ci.AUDIO_TRACK_LOAD_ERROR:case Ci.AUDIO_TRACK_LOAD_TIMEOUT:case Ci.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==ka||(null==(i=e.context)?void 0:i.type)!==Pr||(this.state=Aa);break;case Ci.BUFFER_APPEND_ERROR:case Ci.BUFFER_FULL_ERROR:if(!e.parent||"audio"!==e.parent)return;if(e.details===Ci.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Ci.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushing(t,{type:e}){e!==Gi&&(this.flushing=!0)}onBufferFlushed(t,{type:e}){if(e!==Gi){this.flushing=!1,this.bufferFlushed=!0,this.state===La&&(this.state=Aa);const t=this.mediaBuffer||this.media;t&&(this.afterBufferFlushed(t,e,Nr),this.tick())}}_handleTransmuxComplete(t){var e;const i="audio",{hls:n}=this,{remuxResult:r,chunkMeta:s}=t,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:l,level:c}=a,{details:h}=c,{audio:u,text:d,id3:f,initSegment:g}=r;if(!this.fragContextChanged(o)&&h){if(this.state=Sa,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=g&&g.tracks){const t=o.initSegment||o;this._bufferInitSegment(c,g.tracks,t,s),n.trigger(Li.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:i,tracks:g.tracks})}if(u){const{startPTS:t,endPTS:e,startDTS:i,endDTS:n}=u;l&&(l.elementaryStreams[$i]={startPTS:t,endPTS:e,startDTS:i,endDTS:n}),o.setElementaryStreamInfo($i,t,e,i,n),this.bufferFragmentData(u,o,l,s)}if(null!=f&&null!=(e=f.samples)&&e.length){const t=bi({id:i,frag:o,details:h},f);n.trigger(Li.FRAG_PARSING_METADATA,t)}if(d){const t=bi({id:i,frag:o,details:h},d);n.trigger(Li.FRAG_PARSING_USERDATA,t)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(t,e,i,n){if(this.state!==Sa)return;e.video&&delete e.video;const r=e.audio;if(!r)return;r.id="audio";const s=t.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${s}/${r.codec}]`),s&&1===s.split(",").length&&(r.levelCodec=s),this.hls.trigger(Li.BUFFER_CODECS,e);const a=r.initSegment;if(null!=a&&a.byteLength){const t={type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:a};this.hls.trigger(Li.BUFFER_APPENDING,t)}this.tickImmediate()}loadFragment(t,e,i){const n=this.fragmentTracker.getState(t);var r;if(this.fragCurrent=t,this.switchingTrack||n===Ws||n===qs)if("initSegment"===t.sn)this._loadInitSegment(t,e);else if(null!=(r=e.details)&&r.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=Ca;const i=this.mainDetails;i&&i.fragments[0].start!==e.details.fragments[0].start&&oa(e.details,i)}else this.startFragRequested=!0,super.loadFragment(t,e,i);else this.clearTrackerIfNeeded(t)}flushAudioIfNeeded(t){const{media:e,bufferedTrack:i}=this,n=null==i?void 0:i.attrs,r=t.attrs;e&&n&&(n.CHANNELS!==r.CHANNELS||i.name!==t.name||i.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(Li.AUDIO_TRACK_SWITCHED,Ai({},t))}},audioTrackController:class extends Os{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(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.LEVEL_LOADING,this.onLevelLoading,this),t.on(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Li.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(Li.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.LEVEL_LOADING,this.onLevelLoading,this),t.off(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Li.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(Li.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:i,groupId:n,details:r}=e,s=this.tracksInGroup[i];if(!s||s.groupId!==n)return void this.warn(`Audio track with id:${i} 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 ${i} "${s.name}" lang:${s.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,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 i=e.audioGroups||null,n=this.groupIds;let r=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some((t=>-1===(null==n?void 0:n.indexOf(t))))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const t=this.tracks.filter((t=>!i||-1!==i.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(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=t;const e=this.hls.config.audioPreference;if(!r&&e){const i=Vs(e,t,Hs);if(i>-1)r=t[i];else{const t=Vs(e,this.tracks);r=this.tracks[t]}}let n=this.findTrackId(r);-1===n&&r&&(n=this.findTrackId(null));const a={audioTracks:t};this.log(`Updating audio tracks, ${t.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(Li.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(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e})}}else this.shouldReloadPlaylist(r)&&this.setAudioTrack(this.trackId)}onError(t,e){!e.fatal&&e.context&&(e.context.type!==Pr||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 i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const n=this.currentTrack;if(n&&Ks(t,n,Hs))return n;const r=Vs(t,this.tracksInGroup,Hs);if(r>-1){const t=this.tracksInGroup[r];return this.setAudioTrack(r),t}if(n){let n=e.loadLevel;-1===n&&(n=e.firstAutoLevel);const r=function(t,e,i,n,r){const s=e[n],a=e.reduce(((t,e,i)=>{const n=e.uri;return(t[n]||(t[n]=[])).push(i),t}),{}),o=a[s.uri];o.length>1&&(n=Math.max.apply(Math,o));const l=s.videoRange,c=s.frameRate,h=s.codecSet.substring(0,4),u=Ys(e,n,(e=>{if(e.videoRange!==l||e.frameRate!==c||e.codecSet.substring(0,4)!==h)return!1;const n=e.audioGroups,s=i.filter((t=>!n||-1!==n.indexOf(t.groupId)));return Vs(t,s,r)>-1}));return u>-1?u:Ys(e,n,(e=>{const n=e.audioGroups,s=i.filter((t=>!n||-1!==n.indexOf(t.groupId)));return Vs(t,s,r)>-1}))}(t,e.levels,i,n,Hs);if(-1===r)return null;e.nextLoadLevel=r}if(t.channels||t.audioCodec){const e=Vs(t,i);if(e>-1)return i[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 i=this.currentTrack,n=e[t],r=n.details&&!n.details.live;if(t===this.trackId&&n===i&&r)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(Li.AUDIO_TRACK_SWITCHING,Ai({},n)),r)return;const s=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(s)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||Ks(t,n,Hs)))return i}if(t){const{name:i,lang:n,assocLang:r,characteristics:s,audioCodec:a,channels:o}=t;for(let t=0;t<e.length;t++){if(Ks({name:i,lang:n,assocLang:r,characteristics:s,audioCodec:a,channels:o},e[t],Hs))return t}for(let i=0;i<e.length;i++){const n=e[i];if(Go(t.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<e.length;i++){const n=e[i];if(Go(t.attrs,n.attrs,["LANGUAGE"]))return i}}return-1}loadPlaylist(t){const e=this.currentTrack;if(this.shouldLoadPlaylist(e)&&e){super.loadPlaylist();const i=e.id,n=e.groupId;let r=e.url;if(t)try{r=t.addDirectives(r)}catch(t){this.warn(`Could not construct new URL with HLS Delivery Directives: ${t}`)}this.log(`loading audio-track playlist ${i} "${e.name}" lang:${e.lang} group:${n}`),this.clearTimer(),this.hls.trigger(Li.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null})}}},emeController:Kl,cmcdController:class{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=t=>{try{this.apply(t,{ot:Yl.MANIFEST,su:!this.initialized})}catch(t){Oi.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=t=>{try{const e=t.frag,i=this.hls.levels[e.level],n=this.getObjectType(e),r={d:1e3*e.duration,ot:n};n!==Yl.VIDEO&&n!==Yl.AUDIO&&n!=Yl.MUXED||(r.br=i.bitrate/1e3,r.tb=this.getTopBandwidth(n)/1e3,r.bl=this.getBufferLength(n)),this.apply(t,r)}catch(t){Oi.warn("Could not generate segment CMCD data.",t)}},this.hls=t;const e=this.config=t.config,{cmcd:i}=e;null!=i&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.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 i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)}))}}}(),this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const t=this.hls;t.on(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHED,this.onMediaDetached,this),t.on(Li.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHED,this.onMediaDetached,this),t.off(Li.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 i,n;this.audioBuffer=null==(i=e.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(n=e.tracks.video)?void 0:n.buffer}createData(){var t;return{v:1,sf:jl.HLS,sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){bi(e,this.createData());const i=e.ot===Yl.INIT||e.ot===Yl.VIDEO||e.ot===Yl.MUXED;this.starved&&i&&(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,i)=>(n.includes(i)&&(t[i]=e[i]),t)),{})),this.useHeaders?(t.headers||(t.headers={}),_c(t.headers,e)):t.url=Cc(t.url,e)}getObjectType(t){const{type:e}=t;return"subtitle"===e?Yl.TIMED_TEXT:"initSegment"===t.sn?Yl.INIT:"audio"===e?Yl.AUDIO:"main"===e?this.hls.audioTracks.length?Yl.VIDEO:Yl.MUXED:void 0}getTopBandwidth(t){let e,i=0;const n=this.hls;if(t===Yl.AUDIO)e=n.audioTracks;else{const t=n.maxAutoLevel,i=t>-1?t+1:n.levels.length;e=n.levels.slice(0,i)}for(const t of e)t.bitrate>i&&(i=t.bitrate);return i>0?i:NaN}getBufferLength(t){const e=this.hls.media,i=t===Yl.AUDIO?this.audioBuffer:this.videoBuffer;if(!i||!e)return NaN;return 1e3*ea.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,i=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new i(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,i,n){e(t),this.loader.load(t,i,n)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new i(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,i,n){e(t),this.loader.load(t,i,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=Oi.log.bind(Oi,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.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:i}=e;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:i}=e;if((null==i?void 0:i.action)===Rs&&i.flags===Ds){const t=this.levels;let n=this.pathwayPriority,r=this.pathwayId;if(e.context){const{groupId:i,pathwayId:n,type:s}=e.context;i&&t?r=this.getPathwayForGroupId(i,s,r):n&&(r=n)}r in this.penalizedPathways||(this.penalizedPathways[r]=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),i.resolved=this.pathwayId!==r),i.resolved||Oi.warn(`Could not resolve ${e.details} ("${e.error.message}") with content-steering for Pathway: ${r} 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 i=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),e=this.getLevelsForPathway(i),this.pathwayId=i}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return null===this.levels?[]:this.levels.filter((e=>t===e.pathwayId))}updatePathwayPriority(t){let e;this.pathwayPriority=t;const i=this.penalizedPathways,n=performance.now();Object.keys(i).forEach((t=>{n-i[t]>3e5&&delete i[t]}));for(let n=0;n<t.length;n++){const r=t[n];if(r in i)continue;if(r===this.pathwayId)return;const s=this.hls.nextLoadLevel,a=this.hls.levels[s];if(e=this.getLevelsForPathway(r),e.length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,ms(e),this.hls.trigger(Li.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,i){const n=this.getLevelsForPathway(i).concat(this.levels||[]);for(let i=0;i<n.length;i++)if(e===Pr&&n[i].hasAudioGroup(t)||e===Or&&n[i].hasSubtitleGroup(t))return n[i].pathwayId;return i}clonePathways(t){const e=this.levels;if(!e)return;const i={},n={};t.forEach((t=>{const{ID:r,"BASE-ID":s,"URI-REPLACEMENT":a}=t;if(e.some((t=>t.pathwayId===r)))return;const o=this.getLevelsForPathway(s).map((t=>{const e=new Mi(t.attrs);e["PATHWAY-ID"]=r;const s=e.AUDIO&&`${e.AUDIO}_clone_${r}`,o=e.SUBTITLES&&`${e.SUBTITLES}_clone_${r}`;s&&(i[e.AUDIO]=s,e.AUDIO=s),o&&(n[e.SUBTITLES]=o,e.SUBTITLES=o);const l=Ic(t.uri,e["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),c=new os({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<t.audioGroups.length;e++)c.addGroupId("audio",`${t.audioGroups[e]}_clone_${r}`);if(t.subtitleGroups)for(let e=1;e<t.subtitleGroups.length;e++)c.addGroupId("text",`${t.subtitleGroups[e]}_clone_${r}`);return c}));e.push(...o),wc(this.audioTracks,i,a,r),wc(this.subtitleTracks,n,a,r)}))}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;let n;this.loader&&this.loader.destroy(),this.loader=new i(e);try{n=new self.URL(t)}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${t}`)}if("data:"!==n.protocol){const t=0|(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate);n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+t)}const r={responseType:"json",url:n.href},s=e.steeringManifestLoadPolicy.default,a=s.errorRetry||s.timeoutRetry||{},o={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(t,e,i,r)=>{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||i.url),o&&this.clonePathways(o);const c={steeringManifest:s,url:n.toString()};this.hls.trigger(Li.STEERING_MANIFEST_LOADED,c),l&&this.updatePathwayPriority(l)},onError:(t,e,i,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 r=1e3*this.timeToLoad;if(429!==t.code)this.scheduleRefresh(this.uri||e.url,r);else{const t=this.loader;if("function"==typeof(null==t?void 0:t.getResponseHeader)){const e=t.getResponseHeader("Retry-After");e&&(r=1e3*parseFloat(e))}this.log(`Steering manifest ${e.url} rate limited`)}},onTimeout:(t,e,i)=>{this.log(`Timeout loading steering manifest (${e.url})`),this.scheduleRefresh(this.uri||e.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(r,o,l)}scheduleRefresh(t,e=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout((()=>{var e;const i=null==(e=this.hls)?void 0:e.media;!i||i.ended?this.scheduleRefresh(t,1e3*this.timeToLoad):this.loadSteeringManifest(t)}),e)}}});function $c(t){return t&&"object"==typeof t?Array.isArray(t)?t.map($c):Object.keys(t).reduce(((e,i)=>(e[i]=$c(t[i]),e)),{}):t}function Gc(t){const e=t.loader;if(e!==xc&&e!==Pc)Oi.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=xc,t.progressive=!0,t.enableSoftwareAES=!0,Oi.log("[config]: Progressive streaming enabled, using FetchLoader"))}}let Vc;class Kc extends Os{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(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.on(Li.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.off(Li.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 i=this.hls.config.preferManagedMediaSource,n=[],r={},s={};let a=!1,o=!1,l=!1;e.levels.forEach((t=>{var e,c;const h=t.attrs;let{audioCodec:u,videoCodec:d}=t;-1!==(null==(e=u)?void 0:e.indexOf("mp4a.40.34"))&&(Vc||(Vc=/chrome|firefox/i.test(navigator.userAgent)),Vc&&(t.audioCodec=u=void 0)),u&&(t.audioCodec=u=pr(u,i)),0===(null==(c=d)?void 0:c.indexOf("avc1"))&&(d=t.videoCodec=function(t){const e=t.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");if(i.length>2){let n=i.shift()+".";n+=parseInt(i.shift()).toString(16),n+=("000"+parseInt(i.shift()).toString(16)).slice(-4),e[t]=n}}return e.join(",")}(d));const{width:f,height:g,unknownCodecs:p}=t;if(a||(a=!(!f||!g)),o||(o=!!d),l||(l=!!u),null!=p&&p.length||u&&!lr(u,"audio",i)||d&&!lr(d,"video",i))return;const{CODECS:m,"FRAME-RATE":v,"HDCP-LEVEL":y,"PATHWAY-ID":A,RESOLUTION:E,"VIDEO-RANGE":T}=h,b=`${`${A||"."}-`}${t.bitrate}-${E}-${v}-${m}-${T}-${y}`;if(r[b])if(r[b].uri===t.url||t.attrs["PATHWAY-ID"])r[b].addGroupId("audio",h.AUDIO),r[b].addGroupId("text",h.SUBTITLES);else{const e=s[b]+=1;t.attrs["PATHWAY-ID"]=new Array(e+1).join(".");const i=new os(t);r[b]=i,n.push(i)}else{const e=new os(t);r[b]=e,s[b]=1,n.push(e)}})),this.filterAndSortMediaOptions(n,e,a,o,l)}filterAndSortMediaOptions(t,e,i,n,r){let s=[],a=[],o=t;if((i||n)&&r&&(o=o.filter((({videoCodec:t,videoRange:e,width:i,height:n})=>{return(!!t||!(!i||!n))&&(!!(r=e)&&es.indexOf(r)>-1);var r}))),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(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.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||lr(e.audioCodec,"audio",t))),Hc(s)}e.subtitles&&(a=e.subtitles,Hc(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(i&&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 es.indexOf(t.videoRange)-es.indexOf(e.videoRange);if(t.videoCodec!==e.videoCodec){const i=ur(t.videoCodec),n=ur(e.videoCodec);if(i!==n)return n-i}if(t.uri===e.uri&&t.codecSet!==e.codecSet){const i=dr(t.codecSet),n=dr(e.codecSet);if(i!==n)return n-i}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;t<l.length;t++)if(l[t].pathwayId===o[0].pathwayId){c=l[t];break}this._levels=o;for(let t=0;t<o.length;t++)if(o[t]===c){var h;this._firstLevel=t;const e=c.bitrate,i=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${o.length} level(s) found, first bitrate: ${e}`),void 0===(null==(h=this.hls.userConfig)?void 0:h.abrEwmaDefaultEstimate)){const t=Math.min(e,this.hls.config.abrEwmaDefaultEstimateMax);t>i&&i===Uc.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=t)}break}const u=r&&!n,d={levels:o,audioTracks:s,subtitleTracks:a,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:r,video:n,altAudio:!u&&s.some((t=>!!t.url))};this.hls.trigger(Li.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 i=new Error("invalid level idx"),n=t<0;if(this.hls.trigger(Li.ERROR,{type:Ri.OTHER_ERROR,details:Ci.LEVEL_SWITCH_ERROR,level:t,fatal:n,error:i,reason:i.message}),n)return;t=Math.min(t,e.length-1)}const i=this.currentLevelIndex,n=this.currentLevel,r=n?n.attrs["PATHWAY-ID"]:void 0,s=e[t],a=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=s,i===t&&s.details&&n&&r===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 ${i}${r?" with Pathway "+r:""}`);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(Li.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===Dr&&e.context.level===this.level&&this.checkRetry(e)}onFragBuffered(t,{frag:e}){if(void 0!==e&&e.type===xr){const t=e.elementaryStreams;if(!Object.keys(t).some((e=>!!t[e])))return;const i=this._levels[e.level];null!=i&&i.loadError&&(this.log(`Resetting level error count of ${i.loadError} on frag buffered`),i.loadError=0)}}onLevelLoaded(t,e){var i;const{level:n,details:r}=e,s=this._levels[n];var a;if(!s)return this.warn(`Invalid level index ${n}`),void(null!=(a=e.deliveryDirectives)&&a.skip&&(r.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(n,e,s.details)):null!=(i=e.deliveryDirectives)&&i.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){let n=i.uri;if(t)try{n=t.addDirectives(n)}catch(t){this.warn(`Could not construct new URL with HLS Delivery Directives: ${t}`)}const r=i.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${r?" Pathway "+r:""} ${n}`),this.clearTimer(),this.hls.trigger(Li.LEVEL_LOADING,{url:n,level:e,pathwayId:i.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 i=this._levels.filter(((e,i)=>i!==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)));ms(i),this._levels=i,this.currentLevelIndex>-1&&null!=(e=this.currentLevel)&&e.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(Li.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(t,{levels:e}){this._levels=e}checkMaxAutoUpdated(){const{autoLevelCapping:t,maxAutoLevel:e,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==e&&(this._maxAutoLevel=e,this.hls.trigger(Li.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:e,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function Hc(t){const e={};t.forEach((t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++}))}class Yc{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const i in this.keyUriToKeyInfo){const n=this.keyUriToKeyInfo[i].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=Ci.KEY_LOAD_ERROR,i,n,r){return new da({type:Ri.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:r,error:i,networkDetails:n})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:n}=t;for(let t=0;t<e.length;t++){const r=e[t];if(n<=r.cc&&("initSegment"===i||"initSegment"===r.sn||i<r.sn)){this.emeController.selectKeySystemFormat(r).then((t=>{r.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 i,n;e&&t.setKeyFormat(e);const r=t.decryptdata;if(!r){const i=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,Ci.KEY_LOAD_ERROR,i))}const s=r.uri;if(!s)return Promise.reject(this.createKeyLoadError(t,Ci.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));let a=this.keyUriToKeyInfo[s];if(null!=(i=a)&&i.decryptdata.key)return r.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=>(r.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:a})))}switch(a=this.keyUriToKeyInfo[s]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(a,t):this.loadKeyEME(a,t);case"AES-128":return this.loadKeyHTTP(a,t);default:return Promise.reject(this.createKeyLoadError(t,Ci.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(t,e){const i={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const e=this.emeController.loadKey(i);if(e)return(t.keyLoadPromise=e.then((e=>(t.mediaKeySessionContext=e,i)))).catch((e=>{throw t.keyLoadPromise=null,e}))}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,n=new(0,i.loader)(i);return e.keyLoader=t.loader=n,t.keyLoadPromise=new Promise(((r,s)=>{const a={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},o=i.keyLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,e,i,n)=>{const{frag:a,keyInfo:o,url:l}=i;if(!a.decryptdata||o!==this.keyUriToKeyInfo[l])return s(this.createKeyLoadError(a,Ci.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,r({frag:a,keyInfo:o})},onError:(t,i,n,r)=>{this.resetLoader(i),s(this.createKeyLoadError(e,Ci.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key ${t.text}`),n,Ai({url:a.url,data:void 0},t)))},onTimeout:(t,i,n)=>{this.resetLoader(i),s(this.createKeyLoadError(e,Ci.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:(t,i,n)=>{this.resetLoader(i),s(this.createKeyLoadError(e,Ci.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};n.load(a,l,c)}))}resetLoader(t){const{frag:e,keyInfo:i,url:n}=t,r=i.loader;e.keyLoader===r&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],r&&r.destroy()}}function jc(){return self.SourceBuffer||self.WebKitSourceBuffer}function Wc(){if(!ar())return!1;const t=jc();return!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove}class zc{constructor(t,e,i,n){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=i,this.hls=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:i,media:n,stalled:r}=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!==r){if(this.stallReported){const t=self.performance.now()-r;Oi.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||!ea.getBuffered(n).length)return void(this.nudgeRetry=0);const c=ea.bufferInfo(n,s,0),h=c.nextStart||0;if(a){const t=c.len>2,i=!h||e&&e.start<=s||h-s>2&&!this.fragmentTracker.getPartialFragment(s);if(t||i)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var u;if(!(c.len>0)&&!h)return;const t=Math.max(h,c.start||0)-s,e=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,i=(null==e||null==(u=e.details)?void 0:u.live)?2*e.details.targetduration:2,r=this.fragmentTracker.getPartialFragment(s);if(t>0&&(t<=i||r))return void(n.paused||this._trySkipBufferHole(r))}const d=self.performance.now();if(null===r)return void(this.stalled=d);const f=d-r;if(!a&&f>=250&&(this._reportStall(c),!this.media))return;const g=ea.bufferInfo(n,s,i.maxBufferHole);this._tryFixBufferStall(g,f)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:n,media:r}=this;if(null===r)return;const s=r.currentTime,a=n.getPartialFragment(s);if(a){if(this._trySkipBufferHole(a)||!this.media)return}(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-s<i.maxBufferHole)&&e>1e3*i.highBufferWatchdogPeriod&&(Oi.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:i,stallReported:n}=this;if(!n&&i){this.stallReported=!0;const n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);Oi.warn(n.message),e.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:n}=this;if(null===n)return 0;const r=n.currentTime,s=ea.bufferInfo(n,r,0),a=r<s.start?s.start:s.nextStart;if(a){const o=s.len<=e.maxBufferHole,l=s.len>0&&s.len<1&&n.readyState<3,c=a-r;if(c>0&&(o||l)){if(c>e.maxBufferHole){const{fragmentTracker:e}=this;let i=!1;if(0===r){const t=e.getAppendedFrag(0,xr);t&&a<t.end&&(i=!0)}if(!i){const i=t||e.getAppendedFrag(r,xr);if(i){let t=!1,n=i.end;for(;n<a;){const i=e.getPartialFragment(n);if(!i){t=!0;break}n+=i.duration}if(t)return 0}}}const s=Math.max(a+.05,r+.1);if(Oi.warn(`skipping hole, adjusting currentTime from ${r} to ${s}`),this.moved=!0,this.stalled=null,n.currentTime=s,t&&!t.gap){const e=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${s}`);i.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:e,reason:e.message,frag:t})}return s}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:i,nudgeRetry:n}=this;if(null===i)return;const r=i.currentTime;if(this.nudgeRetry++,n<t.nudgeMaxRetry){const s=r+(n+1)*t.nudgeOffset,a=new Error(`Nudging 'currentTime' from ${r} to ${s}`);Oi.warn(a.message),i.currentTime=s,e.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_NUDGE_ON_STALL,error:a,fatal:!1})}else{const i=new Error(`Playhead still not moving while enough data buffered @${r} after ${t.nudgeMaxRetry} nudges`);Oi.error(i.message),e.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_STALLED_ERROR,error:i,fatal:!0})}}}class qc extends Ia{constructor(t,e,i){super(t,e,i,"[stream-controller]",xr),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.LEVEL_LOADING,this.onLevelLoading,this),t.on(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Li.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(Li.ERROR,this.onError,this),t.on(Li.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(Li.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(Li.BUFFER_CREATED,this.onBufferCreated,this),t.on(Li.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Li.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(Li.ERROR,this.onError,this),t.off(Li.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(Li.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(Li.BUFFER_CREATED,this.onBufferCreated,this),t.off(Li.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(t){if(this.levels){const{lastCurrentTime:e,hls:i}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let t=i.startLevel;-1===t&&(i.config.testBandwidth&&this.levels.length>1?(t=0,this.bitrateTest=!0):t=i.firstAutoLevel),i.nextLoadLevel=t,this.level=i.loadLevel,this.loadedmetadata=!1}e>0&&-1===t&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=Aa,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=ya}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case wa:{const{levels:t,level:e}=this,i=null==t?void 0:t[e],n=null==i?void 0:i.details;if(n&&(!n.live||this.levelLastLoaded===i)){if(this.waitForCdnTuneIn(n))break;this.state=Aa;break}if(this.hls.nextLoadLevel!==this.level){this.state=Aa;break}break}case ba:{var t;const e=self.performance.now(),i=this.retryDate;if(!i||e>=i||null!=(t=this.media)&&t.seeking){const{levels:t,level:e}=this,i=null==t?void 0:t[e];this.resetStartWhenNotLoaded(i||null),this.state=Aa}}}this.state===Aa&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:n}=this;if(null===e||!n&&(this.startFragRequested||!t.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const r=t.nextLoadLevel;if(null==i||!i[r])return;const s=i[r],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(Li.BUFFER_EOS,t),void(this.state=La)}t.loadLevel!==r&&-1===t.manualLevel&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=t.nextLoadLevel=r;const l=s.details;if(!l||this.state===wa||l.live&&this.levelLastLoaded!==s)return this.level=r,void(this.state=wa);const c=a.len,h=this.getMaxBufferLength(s.maxBitrate);if(c>=h)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const u=this.backtrackFragment?this.backtrackFragment.start:a.end;let d=this.getNextFragment(u,l);if(this.couldBacktrack&&!this.fragPrevious&&d&&"initSegment"!==d.sn&&this.fragmentTracker.getState(d)!==Xs){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,u)){if(!d.gap){const t=this.audioOnly&&!this.altAudio?$i:Gi,e=(t===Gi?this.videoBuffer:this.mediaBuffer)||this.media;e&&this.afterBufferFlushed(e,t,xr)}d=this.getNextFragmentLoopLoading(d,l,a,xr,h)}d&&(!d.initSegment||d.initSegment.data||this.bitrateTest||(d=d.initSegment),this.loadFragment(d,s,u))}loadFragment(t,e,i){const n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===Ws||n===qs?"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,i)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,xr)}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 i;const n=this.getAppendedFrag(e.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);const r=this.getLevelDetails();if(null!=r&&r.live){const t=this.getMainFwdBufferInfo();if(!t||t.len<2*r.targetduration)return}if(!e.paused&&t){const e=t[this.hls.nextLoadLevel],n=this.fragLastKbps;i=n&&this.fragCurrent?this.fragCurrent.duration*e.maxBitrate/(1e3*n)+1:0}else i=0;const s=this.getBufferedFrag(e.currentTime+i);if(s){const t=this.followingBufferedFrag(s);if(t){this.abortCurrentFrag();const e=t.maxStartPTS?t.maxStartPTS:t.start,i=t.duration,n=Math.max(s.end,e+Math.min(Math.max(i-this.config.maxFragLookUpTolerance,i*(this.couldBacktrack?.5:.125)),i*(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 Ea:case Ta:case ba:case Sa:case _a:this.state=Aa}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const i=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new zc(this.config,i,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;ki(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const i=this.getMainFwdBufferInfo();null!==i&&0!==i.len?this.tick():this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`)}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(Li.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 i=!1,n=!1;e.levels.forEach((t=>{const e=t.audioCodec;e&&(i=i||-1!==e.indexOf("mp4a.40.2"),n=n||-1!==e.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=i&&n&&!function(){var t;const e=jc();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:i}=this;if(!i||this.state!==Aa)return;const n=i[e.level];(!n.details||n.details.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(n.details))&&(this.state=wa)}onLevelLoaded(t,e){var i;const{levels:n}=this,r=e.level,s=e.details,a=s.totalduration;if(!n)return void this.warn(`Levels were reset while loading level ${r}`);this.log(`Level ${r} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""}, cc [${s.startCC}, ${s.endCC}] duration:${a}`);const o=n[r],l=this.fragCurrent;!l||this.state!==Ta&&this.state!==ba||l.level!==e.level&&l.loader&&this.abortCurrentFrag();let c=0;if(s.live||null!=(i=o.details)&&i.live){var h;if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;c=this.alignPlaylists(s,o.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(o.details=s,this.levelLastLoaded=o,this.hls.trigger(Li.LEVEL_UPDATED,{details:s,level:r}),this.state===wa){if(this.waitForCdnTuneIn(s))return;this.state=Aa}this.startFragRequested?s.live&&this.synchronizeToLiveEdge(s):this.setStartPosition(s,c),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,payload:r}=t,{levels:s}=this;if(!s)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);const a=s[i.level],o=a.details;if(!o)return this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),void this.fragmentTracker.removeFragment(i);const l=a.videoCodec,c=o.PTSKnown||!o.live,h=null==(e=i.initSegment)?void 0:e.data,u=this._getAudioCodec(a),d=this.transmuxer=this.transmuxer||new Uo(this.hls,xr,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=n?n.index:-1,g=-1!==f,p=new ia(i.level,i.sn,i.stats.chunkCount,r.byteLength,f,g),m=this.initPTS[i.cc];d.push(r,h,u,l,i,n,o.totalduration,c,p,m)}onAudioTrackSwitching(t,e){const i=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;i&&(t.trigger(Li.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),t.trigger(Li.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,n=!!this.hls.audioTracks[i].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 i=e.tracks;let n,r,s=!1;for(const t in i){const e=i[t];if("main"===e.id){if(r=t,n=e,"video"===t){const e=i[t];e&&(this.videoBuffer=e.buffer)}}else s=!0}s&&n?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:n}=e;if(i&&i.type!==xr)return;if(this.fragContextChanged(i))return this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===_a&&(this.state=Aa));const r=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),"initSegment"!==i.sn&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}onError(t,e){var i;if(e.fatal)this.state=Ra;else switch(e.details){case Ci.FRAG_GAP:case Ci.FRAG_PARSING_ERROR:case Ci.FRAG_DECRYPT_ERROR:case Ci.FRAG_LOAD_ERROR:case Ci.FRAG_LOAD_TIMEOUT:case Ci.KEY_LOAD_ERROR:case Ci.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(xr,e);break;case Ci.LEVEL_LOAD_ERROR:case Ci.LEVEL_LOAD_TIMEOUT:case Ci.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==wa||(null==(i=e.context)?void 0:i.type)!==Dr||(this.state=Aa);break;case Ci.BUFFER_APPEND_ERROR:case Ci.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;if(e.details===Ci.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case Ci.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}checkBuffer(){const{media:t,gapController:e}=this;if(t&&e&&t.readyState){if(this.loadedmetadata||!ea.getBuffered(t).length){const t=this.state!==Aa?this.fragCurrent:null;e.poll(this.lastCurrentTime,t)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=Aa,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==$i||this.audioOnly&&!this.altAudio){const t=(e===Gi?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(t,e,xr),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 i=this.startPosition;if(i>=0&&e<i){if(t.seeking)return void this.log(`could not seek to ${i}, already seeking at ${e}`);const n=ea.getBuffered(t),r=(n.length?n.start(0):0)-i;r>0&&(r<this.config.maxBufferHole||r<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${r} to match buffer start`),i+=r,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${e}`),t.currentTime=i}}_getAudioCodec(t){let e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e}_loadBitrateTestFrag(t,e){t.bitrateTest=!0,this._doFragLoad(t,e).then((i=>{const{hls:n}=this;if(!i||this.fragContextChanged(t))return;e.fragmentError=0,this.state=Aa,this.startFragRequested=!1,this.bitrateTest=!1;const r=t.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),n.trigger(Li.FRAG_LOADED,i),t.bitrateTest=!1}))}_handleTransmuxComplete(t){var e;const i="main",{hls:n}=this,{remuxResult:r,chunkMeta:s}=t,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:l,level:c}=a,{video:h,text:u,id3:d,initSegment:f}=r,{details:g}=c,p=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=Sa,f){if(null!=f&&f.tracks){const t=o.initSegment||o;this._bufferInitSegment(c,f.tracks,t,s),n.trigger(Li.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:i,tracks:f.tracks})}const t=f.initPTS,e=f.timescale;ki(t)&&(this.initPTS[o.cc]={baseTime:t,timescale:e},n.trigger(Li.INIT_PTS_FOUND,{frag:o,id:i,initPTS:t,timescale:e}))}if(h&&g&&"initSegment"!==o.sn){const t=g.fragments[o.sn-1-g.startSN],e=o.sn===g.startSN,i=!t||o.cc>t.cc;if(!1!==r.independent){const{startPTS:t,endPTS:n,startDTS:r,endDTS:a}=h;if(l)l.elementaryStreams[h.type]={startPTS:t,endPTS:n,startDTS:r,endDTS:a};else if(h.firstKeyFrame&&h.independent&&1===s.id&&!i&&(this.couldBacktrack=!0),h.dropped&&h.independent){const r=this.getMainFwdBufferInfo(),s=(r?r.end:this.getLoadPosition())+this.config.maxBufferHole,l=h.firstKeyFramePTS?h.firstKeyFramePTS:t;if(!e&&s<l-this.config.maxBufferHole&&!i)return void this.backtrack(o);i&&(o.gap=!0),o.setElementaryStreamInfo(h.type,o.start,n,o.start,a,!0)}else e&&t>2&&(o.gap=!0);o.setElementaryStreamInfo(h.type,t,n,r,a),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,l,s,e||i)}else{if(!e&&!i)return void this.backtrack(o);o.gap=!0}}if(p){const{startPTS:t,endPTS:e,startDTS:i,endDTS:n}=p;l&&(l.elementaryStreams[$i]={startPTS:t,endPTS:e,startDTS:i,endDTS:n}),o.setElementaryStreamInfo($i,t,e,i,n),this.bufferFragmentData(p,o,l,s)}if(g&&null!=d&&null!=(e=d.samples)&&e.length){const t={id:i,frag:o,details:g,samples:d.samples};n.trigger(Li.FRAG_PARSING_METADATA,t)}if(g&&u){const t={id:i,frag:o,details:g,samples:u.samples};n.trigger(Li.FRAG_PARSING_USERDATA,t)}}}_bufferInitSegment(t,e,i,n){if(this.state!==Sa)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:r,video:s,audiovideo:a}=e;if(r){let e=t.audioCodec;const i=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){e&&(e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const t=r.metadata;t&&"channelCount"in t&&1!==(t.channelCount||1)&&-1===i.indexOf("firefox")&&(e="mp4a.40.5")}e&&-1!==e.indexOf("mp4a.40.5")&&-1!==i.indexOf("android")&&"audio/mpeg"!==r.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}"`),r.levelCodec=e,r.id="main",this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${e||""}/${t.audioCodec||""}/${r.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(Li.BUFFER_CODECS,e),Object.keys(e).forEach((t=>{const r=e[t].initSegment;null!=r&&r.byteLength&&this.hls.trigger(Li.BUFFER_APPENDING,{type:t,data:r,frag:i,part:null,chunkMeta:n,parent:i.type})})),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,xr)}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=Aa}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&!1===t.seeking){const i=t.currentTime;if(ea.isBuffered(t,i)?e=this.getAppendedFrag(i):ea.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const t=this.fragPlaying,i=e.level;t&&e.sn===t.sn&&t.level===i||(this.fragPlaying=e,this.hls.trigger(Li.FRAG_CHANGED,{frag:e}),t&&t.level===i||this.hls.trigger(Li.LEVEL_SWITCHED,{level:i}))}}}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,i=this.currentFrag;if(i&&ki(e)&&ki(i.programDateTime)){const t=i.programDateTime+1e3*(e-i.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 Xc{static get version(){return"1.5.14"}static isMSESupported(){return Wc()}static isSupported(){return function(){if(!Wc())return!1;const t=ar();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(hr(e,"video"))))||["mp4a.40.2","fLaC"].some((e=>t.isTypeSupported(hr(e,"audio")))))}()}static getMediaSource(){return ar()}static get Events(){return Li}static get ErrorTypes(){return Ri}static get ErrorDetails(){return Ci}static get DefaultConfig(){return Xc.defaultConfig?Xc.defaultConfig:Uc}static set DefaultConfig(t){Xc.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 Bo,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){Pi(t,"debug","log","info","warn","error");try{Di.log(`Debug logs enabled for "${e}" in hls.js version 1.5.14`)}catch(t){Di=Ii}}else Di=Ii}(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 i=$c(t),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((t=>{const r=`${"level"===t?"playlist":t}LoadPolicy`,s=void 0===e[r],a=[];n.forEach((n=>{const o=`${t}Loading${n}`,l=e[o];if(void 0!==l&&s){a.push(o);const t=i[r].default;switch(e[r]={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&&Oi.warn(`hls.js config: "${a.join('", "')}" setting(s) are deprecated, use "${r}": ${JSON.stringify(e[r])}`)})),Ai(Ai({},i),e)}(Xc.DefaultConfig,t);this.userConfig=t,e.progressive&&Gc(e);const{abrController:i,bufferController:n,capLevelController:r,errorController:s,fpsController:a}=e,o=new s(this),l=this.abrController=new i(this),c=this.bufferController=new n(this),h=this.capLevelController=new r(this),u=new a(this),d=new Ur(this),f=new Zr(this),g=e.contentSteeringController,p=g?new g(this):null,m=this.levelController=new Kc(this,p),v=new Qs(this),y=new Yc(this.config),A=this.streamController=new qc(this,v,y);h.setStreamController(A),u.setStreamController(A);const E=[d,m,A];p&&E.splice(1,0,p),this.networkControllers=E;const T=[l,c,h,u,f,v];this.audioTrackController=this.createController(e.audioTrackController,E);const b=e.audioStreamController;b&&E.push(new b(this,v,y)),this.subtitleTrackController=this.createController(e.subtitleTrackController,E);const k=e.subtitleStreamController;k&&E.push(new k(this,v,y)),this.createController(e.timelineController,T),y.emeController=this.emeController=this.createController(e.emeController,T),this.cmcdController=this.createController(e.cmcdController,T),this.latencyController=this.createController(Jr,T),this.coreComponents=T,E.push(o);const S=o.onErrorOut;"function"==typeof S&&this.on(Li.ERROR,S,o)}createController(t,e){if(t){const i=new t(this);return e&&e.push(i),i}return null}on(t,e,i=this){this._emitter.on(t,e,i)}once(t,e,i=this){this._emitter.once(t,e,i)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,i=this,n){this._emitter.off(t,e,i,n)}listeners(t){return this._emitter.listeners(t)}emit(t,e,i){return this._emitter.emit(t,e,i)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){if(Oi.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),!this.triggeringException){this.triggeringException=!0;const i=t===Li.ERROR;this.trigger(Li.ERROR,{type:Ri.OTHER_ERROR,details:Ci.INTERNAL_EXCEPTION,fatal:i,event:t,error:e}),this.triggeringException=!1}}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){Oi.log("destroy"),this.trigger(Li.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){Oi.log("attachMedia"),this._media=t,this.trigger(Li.MEDIA_ATTACHING,{media:t})}detachMedia(){Oi.log("detachMedia"),this.trigger(Li.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,n=this.url=vi.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,Oi.log(`loadSource:${n}`),e&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(Li.MANIFEST_LOADING,{url:t})}startLoad(t=-1){Oi.log(`startLoad(${t})`),this.started=!0,this.networkControllers.forEach((e=>{e.startLoad(t)}))}stopLoad(){Oi.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(){Oi.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){Oi.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){Oi.log(`set currentLevel:${t}`),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){Oi.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){Oi.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){Oi.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){Oi.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&&(Oi.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){(function(t){return ts.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 i=t.length;for(let n=0;n<i;n++)if(t[n].maxBitrate>=e)return n;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let n;if(n=-1===e&&null!=t&&t.length?t.length-1:e,i)for(let e=n;e--;){const n=t[e].attrs["HDCP-LEVEL"];if(n&&n<=i)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}}Xc.defaultConfig=void 0;var Qc=Z.now,Zc=Z.listContainsIgnoreCase;ct.register("PLAYBACK_FRAGMENT_CHANGED"),ct.register("PLAYBACK_FRAGMENT_PARSING_METADATA");var Jc=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ni(t,e)}(s,t);var e,i,n,r=si(s);function s(){var t;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s);for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return(t=r.call.apply(r,[this].concat(i))).options.hlsPlayback=Je(Je({},t.defaultOptions),t.options.hlsPlayback),t._timeUpdateThrottleDelay=200,t._timeUpdateFiringRate=.2,t._durationChangeMinOffset=.5,t._setInitialState(),t}return e=s,i=[{key:"name",get:function(){return"hls"}},{key:"supportedVersion",get:function(){return{min:"0.11.1"}}},{key:"levels",get:function(){return this._levels||[]}},{key:"currentLevel",get:function(){return null===this._currentLevel||void 0===this._currentLevel?-1:this._currentLevel},set:function(t){this._currentLevel=t,this.trigger(ct.PLAYBACK_LEVEL_SWITCH_START),this.options.playback.hlsUseNextLevel?this._hls.nextLevel=this._currentLevel:this._hls.currentLevel=this._currentLevel}},{key:"isReady",get:function(){return this._isReadyState}},{key:"latency",get:function(){return this._hls.latency}},{key:"currentProgramDateTime",get:function(){return this._hls.playingDate}},{key:"_startTime",get:function(){return this._playbackType===Rt.LIVE&&"EVENT"!==this._playlistType?this._extrapolatedStartTime:this._playableRegionStartTime}},{key:"_now",get:function(){return Qc()}},{key:"_extrapolatedStartTime",get:function(){if(!this._localStartTimeCorrelation)return this._playableRegionStartTime;var t=this._localStartTimeCorrelation,e=this._now-t.local,i=(t.remote+e)/1e3;return Math.min(i,this._playableRegionStartTime+this._extrapolatedWindowDuration)}},{key:"_extrapolatedEndTime",get:function(){var t=this._playableRegionStartTime+this._playableRegionDuration;if(!this._localEndTimeCorrelation)return t;var e=this._localEndTimeCorrelation,i=this._now-e.local,n=(e.remote+i)/1e3;return Math.max(t-this._extrapolatedWindowDuration,Math.min(n,t))}},{key:"_duration",get:function(){return this._extrapolatedEndTime-this._startTime}},{key:"_extrapolatedWindowDuration",get:function(){return null===this._segmentTargetDuration?0:this._extrapolatedWindowNumSegments*this._segmentTargetDuration}},{key:"bandwidthEstimate",get:function(){return this._hls&&this._hls.bandwidthEstimate}},{key:"defaultOptions",get:function(){return{preload:!0}}},{key:"customListeners",get:function(){return this.options.hlsPlayback&&this.options.hlsPlayback.customListeners||[]}},{key:"sourceMedia",get:function(){return this.options.src}},{key:"currentTimestamp",get:function(){return this._currentFragment?(this._currentFragment.programDateTime+1e3*(this.el.currentTime-this._currentFragment.start))/1e3:null}},{key:"_setInitialState",value:function(){this._minDvrSize=void 0===this.options.hlsMinimumDvrSize?60:this.options.hlsMinimumDvrSize,this._extrapolatedWindowNumSegments=this.options.playback&&void 0!==this.options.playback.extrapolatedWindowNumSegments?this.options.playback.extrapolatedWindowNumSegments:2,this._playbackType=Rt.VOD,this._lastTimeUpdate={current:0,total:0,firstFragDateTime:0},this._lastTimeUpdateFiredTime=0,this._lastDuration=null,this._playableRegionStartTime=0,this._localStartTimeCorrelation=null,this._localEndTimeCorrelation=null,this._playableRegionDuration=0,this._programDateTime=0,this._durationExcludesAfterLiveSyncPoint=!1,this._segmentTargetDuration=null,this._playlistType=null,this._recoverAttemptsRemaining=this.options.hlsRecoverAttempts||16}},{key:"_setup",value:function(){this._destroyHLSInstance(),this._createHLSInstance(),this._listenHLSEvents(),this._attachHLSMedia()}},{key:"_destroyHLSInstance",value:function(){this._hls&&(this._manifestLoading=!1,this._ccIsSetup=!1,this._ccTracksUpdated=!1,this._setInitialState(),this._hls.destroy(),this._hls=null)}},{key:"_createHLSInstance",value:function(){var t=Je({},this.options.playback.hlsjsConfig);this._hls=new Xc(t)}},{key:"_attachHLSMedia",value:function(){this._hls&&this._hls.attachMedia(this.el)}},{key:"_listenHLSEvents",value:function(){var t=this;this._hls&&(this._hls.once(Xc.Events.MEDIA_ATTACHED,(function(){t.options.hlsPlayback.preload&&t._hls.loadSource(t.options.src)})),this._hls.on(Xc.Events.MANIFEST_LOADING,(function(){return t._manifestLoading=!0})),this._hls.on(Xc.Events.LEVEL_LOADED,(function(e,i){return t._updatePlaybackType(e,i)})),this._hls.on(Xc.Events.LEVEL_UPDATED,(function(e,i){return t._onLevelUpdated(e,i)})),this._hls.on(Xc.Events.LEVEL_SWITCHED,(function(e,i){return t._onLevelSwitch(e,i)})),this._hls.on(Xc.Events.FRAG_CHANGED,(function(e,i){return t._onFragmentChanged(e,i)})),this._hls.on(Xc.Events.FRAG_LOADED,(function(e,i){return t._onFragmentLoaded(e,i)})),this._hls.on(Xc.Events.FRAG_BUFFERED,(function(e,i){return t._onFragmentBuffered(e,i)})),this._hls.on(Xc.Events.FRAG_PARSING_METADATA,(function(e,i){return t._onFragmentParsingMetadata(e,i)})),this._hls.on(Xc.Events.ERROR,(function(e,i){return t._onHLSJSError(e,i)})),this._hls.on(Xc.Events.SUBTITLE_TRACK_LOADED,(function(e,i){return t._onSubtitleLoaded(e,i)})),this._hls.on(Xc.Events.SUBTITLE_TRACKS_UPDATED,(function(){return t._ccTracksUpdated=!0})),this.bindCustomListeners())}},{key:"bindCustomListeners",value:function(){var t=this;this.customListeners.forEach((function(e){var i=e.eventName,n=e.once?"once":"on";i&&t._hls["".concat(n)](i,e.callback)}))}},{key:"unbindCustomListeners",value:function(){var t=this;this.customListeners.forEach((function(e){var i=e.eventName;i&&t._hls.off(i,e.callback)}))}},{key:"_onFragmentParsingMetadata",value:function(t,e){this.trigger(ct.Custom.PLAYBACK_FRAGMENT_PARSING_METADATA,{evt:t,data:e})}},{key:"render",value:function(){return this._ready(),ai(ii(s.prototype),"render",this).call(this)}},{key:"_ready",value:function(){this._isReadyState||(!this._hls&&this._setup(),this._isReadyState=!0,this.trigger(ct.PLAYBACK_READY,this.name))}},{key:"_recover",value:function(t,e,i){if(this._recoveredDecodingError)if(this._recoveredAudioCodecError){rt.error("hlsjs: failed to recover",{evt:t,data:e}),i.level=kt.Levels.FATAL;var n=this.createError(i);this.trigger(ct.PLAYBACK_ERROR,n),this.stop()}else this._recoveredAudioCodecError=!0,this._hls.swapAudioCodec(),this._hls.recoverMediaError(),this.play();else this._recoveredDecodingError=!0,this._hls.recoverMediaError(),this.play()}},{key:"_setupSrc",value:function(t){}},{key:"_startTimeUpdateTimer",value:function(){var t=this;this._timeUpdateTimer||(this._timeUpdateTimer=setInterval((function(){t._onDurationChange(),t._onTimeUpdate()}),100))}},{key:"_stopTimeUpdateTimer",value:function(){this._timeUpdateTimer&&(clearInterval(this._timeUpdateTimer),this._timeUpdateTimer=null)}},{key:"getProgramDateTime",value:function(){return this._programDateTime}},{key:"getDuration",value:function(){return this._duration}},{key:"getCurrentTime",value:function(){return Math.max(0,this.el.currentTime-this._startTime)}},{key:"getStartTimeOffset",value:function(){return this._startTime}},{key:"seekPercentage",value:function(t){var e=t>0?this._duration*(t/100):this._duration;this.seek(e)}},{key:"seek",value:function(t){t<0&&(rt.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),t=this.getDuration()),t+=this._startTime,this.el.currentTime=t}},{key:"seekToLivePoint",value:function(){this.seek(this.getDuration())}},{key:"_updateSettings",value:function(){this._playbackType===Rt.VOD?this.settings.left=["playpause","position","duration"]:this.dvrEnabled?this.settings.left=["playpause"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(ct.PLAYBACK_SETTINGSUPDATE)}},{key:"_onHLSJSError",value:function(t,e){var i,n={code:"".concat(e.type,"_").concat(e.details),description:"".concat(this.name," error: type: ").concat(e.type,", details: ").concat(e.details),raw:e};if(e.response&&(n.description+=", response: ".concat(JSON.stringify(e.response))),e.fatal)if(this._recoverAttemptsRemaining>0)switch(this._recoverAttemptsRemaining-=1,e.type){case Xc.ErrorTypes.NETWORK_ERROR:switch(e.details){case Xc.ErrorDetails.MANIFEST_LOAD_ERROR:case Xc.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case Xc.ErrorDetails.MANIFEST_PARSING_ERROR:case Xc.ErrorDetails.LEVEL_LOAD_ERROR:case Xc.ErrorDetails.LEVEL_LOAD_TIMEOUT:rt.error("hlsjs: unrecoverable network fatal error.",{evt:t,data:e}),i=this.createError(n),this.trigger(ct.PLAYBACK_ERROR,i),this.stop();break;default:rt.warn("hlsjs: trying to recover from network error.",{evt:t,data:e}),n.level=kt.Levels.WARN,this._hls.startLoad()}break;case Xc.ErrorTypes.MEDIA_ERROR:rt.warn("hlsjs: trying to recover from media error.",{evt:t,data:e}),n.level=kt.Levels.WARN,this._recover(t,e,n);break;default:rt.error("hlsjs: could not recover from error.",{evt:t,data:e}),i=this.createError(n),this.trigger(ct.PLAYBACK_ERROR,i),this.stop()}else rt.error("hlsjs: could not recover from error after maximum number of attempts.",{evt:t,data:e}),i=this.createError(n),this.trigger(ct.PLAYBACK_ERROR,i),this.stop();else{if(this.options.playback.triggerFatalErrorOnResourceDenied&&this._keyIsDenied(e))return rt.error("hlsjs: could not load decrypt key.",{evt:t,data:e}),i=this.createError(n),this.trigger(ct.PLAYBACK_ERROR,i),void this.stop();n.level=kt.Levels.WARN,rt.warn("hlsjs: non-fatal error occurred",{evt:t,data:e})}}},{key:"_keyIsDenied",value:function(t){return t.type===Xc.ErrorTypes.NETWORK_ERROR&&t.details===Xc.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._shouldThrottleTimeUpdate(t)||(this._lastTimeUpdate=t,this._lastTimeUpdateFiredTime=this._now,this.trigger(ct.PLAYBACK_TIMEUPDATE,t,this.name))}},{key:"_shouldThrottleTimeUpdate",value:function(t){var e=Math.abs(t.current-this._lastTimeUpdate.current)<this._timeUpdateFiringRate,i=Math.abs(t.total-this._lastTimeUpdate.total)<this._durationChangeMinOffset,n=t.firstFragDateTime===this._lastTimeUpdate.firstFragDateTime,r=e&&i&&n,s=this._now-this._lastTimeUpdateFiredTime<this._timeUpdateThrottleDelay;return r&&s}},{key:"_onDurationChange",value:function(){var t=this.getDuration();Math.abs(this._lastDuration-t)<this._durationChangeMinOffset||(this._lastDuration=t,ai(ii(s.prototype),"_onDurationChange",this).call(this))}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var t=[],e=0,i=0;i<this.el.buffered.length;i++)t=[].concat(oi(t),[{start:Math.max(0,this.el.buffered.start(i)-this._playableRegionStartTime),end:Math.max(0,this.el.buffered.end(i)-this._playableRegionStartTime)}]),this.el.currentTime>=t[i].start&&this.el.currentTime<=t[i].end&&(e=i);var n={start:t[e].start,current:t[e].end,total:this.getDuration()};this.trigger(ct.PLAYBACK_PROGRESS,n,t)}}},{key:"load",value:function(t){this._stopTimeUpdateTimer(),this.options.src=t,this._setup()}},{key:"play",value:function(){!this._hls&&this._setup(),!this._manifestLoading&&!this.options.hlsPlayback.preload&&this._hls.loadSource(this.options.src),ai(ii(s.prototype),"play",this).call(this),this._startTimeUpdateTimer()}},{key:"pause",value:function(){this._hls&&this.el.pause()}},{key:"stop",value:function(){this._stopTimeUpdateTimer(),this._hls&&ai(ii(s.prototype),"stop",this).call(this),this._destroyHLSInstance()}},{key:"destroy",value:function(){this._stopTimeUpdateTimer(),this._destroyHLSInstance(),ai(ii(s.prototype),"destroy",this).call(this)}},{key:"_updatePlaybackType",value:function(t,e){this._playbackType=e.details.live?Rt.LIVE:Rt.VOD,this._onLevelUpdated(t,e),this._ccTracksUpdated&&this._playbackType===Rt.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(ct.PLAYBACK_LEVELS_AVAILABLE,this._levels)}},{key:"_onLevelUpdated",value:function(t,e){this._segmentTargetDuration=e.details.targetduration,this._playlistType=e.details.type||null;var i=!1,n=!1,r=e.details.fragments,s=this._playableRegionStartTime,a=this._playableRegionDuration;if(0!==r.length){if(r[0].rawProgramDateTime&&(this._programDateTime=r[0].rawProgramDateTime),this._playableRegionStartTime!==r[0].start&&(i=!0,this._playableRegionStartTime=r[0].start),i)if(this._localStartTimeCorrelation){var o=this._localStartTimeCorrelation,l=this._now-o.local,c=(o.remote+l)/1e3;c<r[0].start?this._localStartTimeCorrelation={local:this._now,remote:1e3*r[0].start}:c>s+this._extrapolatedWindowDuration&&(this._localStartTimeCorrelation={local:this._now,remote:1e3*Math.max(r[0].start,s+this._extrapolatedWindowDuration)})}else this._localStartTimeCorrelation={local:this._now,remote:1e3*(r[0].start+this._extrapolatedWindowDuration/2)};var h=e.details.totalduration;if(this._playbackType===Rt.LIVE){var u=e.details.targetduration*((this.options.playback.hlsjsConfig||{}).liveSyncDurationCount||Xc.DefaultConfig.liveSyncDurationCount);u<=h?(h-=u,this._durationExcludesAfterLiveSyncPoint=!0):this._durationExcludesAfterLiveSyncPoint=!1}h!==this._playableRegionDuration&&(n=!0,this._playableRegionDuration=h);var d=r[0].start+h,f=s+a;if(d!==f)if(this._localEndTimeCorrelation){var g=this._localEndTimeCorrelation,p=this._now-g.local,m=(g.remote+p)/1e3;m>d?this._localEndTimeCorrelation={local:this._now,remote:1e3*d}:m<d-this._extrapolatedWindowDuration?this._localEndTimeCorrelation={local:this._now,remote:1e3*(d-this._extrapolatedWindowDuration)}:m>f&&(this._localEndTimeCorrelation={local:this._now,remote:1e3*f})}else this._localEndTimeCorrelation={local:this._now,remote:1e3*d};n&&this._onDurationChange(),i&&this._onProgress()}}},{key:"_onFragmentChanged",value:function(t,e){this._currentFragment=e.frag,this.trigger(ct.Custom.PLAYBACK_FRAGMENT_CHANGED,e)}},{key:"_onFragmentLoaded",value:function(t,e){this.trigger(ct.PLAYBACK_FRAGMENT_LOADED,e)}},{key:"_onFragmentBuffered",value:function(t,e){this.trigger(ct.PLAYBACK_FRAGMENT_BUFFERED,e)}},{key:"_onSubtitleLoaded",value:function(){if(!this._ccIsSetup){this.trigger(ct.PLAYBACK_SUBTITLE_AVAILABLE);var t=this._playbackType===Rt.LIVE?-1:this.closedCaptionsTrackId;this.closedCaptionsTrackId=t,this._ccIsSetup=!0}}},{key:"_onLevelSwitch",value:function(t,e){this.levels.length||this._fillLevels(),this.trigger(ct.PLAYBACK_LEVEL_SWITCH_END),this.trigger(ct.PLAYBACK_LEVEL_SWITCH,e);var i=this._hls.levels[e.level];i&&(this.highDefinition=i.height>=720||i.bitrate/1e3>=2e3,this.trigger(ct.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(ct.PLAYBACK_BITRATE,{height:i.height,width:i.width,bandwidth:i.bitrate,bitrate:i.bitrate,level:e.level}))}},{key:"dvrEnabled",get:function(){return this._durationExcludesAfterLiveSyncPoint&&this._duration>=this._minDvrSize&&this.getPlaybackType()===Rt.LIVE}},{key:"getPlaybackType",value:function(){return this._playbackType}},{key:"isSeekEnabled",value:function(){return this._playbackType===Rt.VOD||this.dvrEnabled}}],n=[{key:"HLSJS",get:function(){return Xc}}],i&&ti(e.prototype,i),n&&ti(e,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(jt);return Jc.canPlay=function(t,e){var i=t.split("?")[0].match(/.*\.(.*)$/)||[],n=i.length>1&&"m3u8"===i[1].toLowerCase()||Zc(e,["application/vnd.apple.mpegurl","application/x-mpegURL"]);return!(!Xc.isSupported()||!n)},Qe.Loader.registerPlayback(Jc),e(e({},Qe),{},{HLS:Jc})}();
|
|
1
|
+
var Clappr=function(){"use strict";function t(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function e(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function i(t,e,i){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function n(t,e,i){return e=g(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,r()?Reflect.construct(e,i||[],g(t).constructor):e.apply(t,i))}function r(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(r=function(){return!!t})()}function s(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function a(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?s(Object(i),!0).forEach((function(e){d(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function o(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function l(t){return l="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},l(t)}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,o(n.key),n)}}function u(t,e,i){return e&&h(t.prototype,e),i&&h(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function d(t,e,i){return(e=o(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&p(t,e)}function g(t){return g=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},g(t)}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function m(){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=g(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},m.apply(this,arguments)}function v(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var n,r,s,a,o=[],l=!0,c=!1;try{if(s=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;l=!1}else for(;!(l=(n=s.call(i)).done)&&(o.push(n.value),o.length!==e);l=!0);}catch(t){c=!0,r=t}finally{try{if(!l&&null!=i.return&&(a=i.return(),Object(a)!==a))return}finally{if(c)throw r}}return o}}(t,e)||A(t,e)||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.")}()}function y(t){return function(t){if(Array.isArray(t))return E(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||A(t)||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.")}()}function A(t,e){if(t){if("string"==typeof t)return E(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?E(t,e):void 0}}function E(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function T(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=A(t))||e){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return a=t.done,t},e:function(t){o=!0,s=t},f:function(){try{a||null==i.return||i.return()}finally{if(o)throw s}}}}function b(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var k=function(){var t,e,i,n,r,s,a=[],o=a.concat,l=a.filter,c=a.slice,h=window.document,u={},d={},f={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},g=/^\s*<(\w+|!)[^>]*>/,p=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,m=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,v=/^(?:body|html)$/i,y=/([A-Z])/g,A=["val","css","html","text","data","width","height","offset"],E=h.createElement("table"),T=h.createElement("tr"),b={tr:h.createElement("tbody"),tbody:E,thead:E,tfoot:E,td:T,th:T,"*":h.createElement("div")},k=/complete|loaded|interactive/,S=/^[\w-]*$/,_={},L=_.toString,R={},C=h.createElement("div"),w={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},I=Array.isArray||function(t){return t instanceof Array};function D(t){return null==t?String(t):_[L.call(t)]||"object"}function P(t){return"function"==D(t)}function O(t){return null!=t&&t==t.window}function x(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function N(t){return"object"==D(t)}function M(t){return N(t)&&!O(t)&&Object.getPrototypeOf(t)==Object.prototype}function F(t){var e=!!t&&"length"in t&&t.length,n=i.type(t);return"function"!=n&&!O(t)&&("array"==n||0===e||"number"==typeof e&&e>0&&e-1 in t)}function B(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function U(t){return t in d?d[t]:d[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function $(t,e){return"number"!=typeof e||f[B(t)]?e:e+"px"}function G(t){return"children"in t?c.call(t.children):i.map(t.childNodes,(function(t){if(1==t.nodeType)return t}))}function V(t,e){var i,n=t?t.length:0;for(i=0;i<n;i++)this[i]=t[i];this.length=n,this.selector=e||""}function K(i,n,r){for(e in n)r&&(M(n[e])||I(n[e]))?(M(n[e])&&!M(i[e])&&(i[e]={}),I(n[e])&&!I(i[e])&&(i[e]=[]),K(i[e],n[e],r)):n[e]!==t&&(i[e]=n[e])}function H(t,e){return null==e?i(t):i(t).filter(e)}function Y(t,e,i,n){return P(e)?e.call(t,i,n):e}function j(t,e,i){null==i?t.removeAttribute(e):t.setAttribute(e,i)}function W(e,i){var n=e.className||"",r=n&&n.baseVal!==t;if(i===t)return r?n.baseVal:n;r?n.baseVal=i:e.className=i}function z(t){try{return t?"true"==t||"false"!=t&&("null"==t?null:+t+""==t?+t:/^[\[\{]/.test(t)?i.parseJSON(t):t):t}catch(e){return t}}function q(t,e){e(t);for(var i=0,n=t.childNodes.length;i<n;i++)q(t.childNodes[i],e)}return R.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var i=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(i)return i.call(t,e);var n,r=t.parentNode,s=!r;return s&&(r=C).appendChild(t),n=~R.qsa(r,e).indexOf(t),s&&C.removeChild(t),n},r=function(t){return t.replace(/-+(.)?/g,(function(t,e){return e?e.toUpperCase():""}))},s=function(t){return l.call(t,(function(e,i){return t.indexOf(e)==i}))},R.fragment=function(e,n,r){var s,a,o;return p.test(e)&&(s=i(h.createElement(RegExp.$1))),s||(e.replace&&(e=e.replace(m,"<$1></$2>")),n===t&&(n=g.test(e)&&RegExp.$1),n in b||(n="*"),(o=b[n]).innerHTML=""+e,s=i.each(c.call(o.childNodes),(function(){o.removeChild(this)}))),M(r)&&(a=i(s),i.each(r,(function(t,e){A.indexOf(t)>-1?a[t](e):a.attr(t,e)}))),s},R.Z=function(t,e){return new V(t,e)},R.isZ=function(t){return t instanceof R.Z},R.init=function(e,n){var r,s;if(!e)return R.Z();if("string"==typeof e)if("<"==(e=e.trim())[0]&&g.test(e))r=R.fragment(e,RegExp.$1,n),e=null;else{if(n!==t)return i(n).find(e);r=R.qsa(h,e)}else{if(P(e))return i(h).ready(e);if(R.isZ(e))return e;if(I(e))s=e,r=l.call(s,(function(t){return null!=t}));else if(N(e))r=[e],e=null;else if(g.test(e))r=R.fragment(e.trim(),RegExp.$1,n),e=null;else{if(n!==t)return i(n).find(e);r=R.qsa(h,e)}}return R.Z(r,e)},(i=function(t,e){return R.init(t,e)}).extend=function(t){var e,i=c.call(arguments,1);return"boolean"==typeof t&&(e=t,t=i.shift()),i.forEach((function(i){K(t,i,e)})),t},R.qsa=function(t,e){var i,n="#"==e[0],r=!n&&"."==e[0],s=n||r?e.slice(1):e,a=S.test(s);return t.getElementById&&a&&n?(i=t.getElementById(s))?[i]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:c.call(a&&!n&&t.getElementsByClassName?r?t.getElementsByClassName(s):t.getElementsByTagName(e):t.querySelectorAll(e))},i.contains=h.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},i.type=D,i.isFunction=P,i.isWindow=O,i.isArray=I,i.isPlainObject=M,i.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},i.isNumeric=function(t){var e=Number(t),i=typeof t;return null!=t&&"boolean"!=i&&("string"!=i||t.length)&&!isNaN(e)&&isFinite(e)||!1},i.inArray=function(t,e,i){return a.indexOf.call(e,t,i)},i.camelCase=r,i.trim=function(t){return null==t?"":String.prototype.trim.call(t)},i.uuid=0,i.support={},i.expr={},i.noop=function(){},i.map=function(t,e){var n,r,s,a,o=[];if(F(t))for(r=0;r<t.length;r++)null!=(n=e(t[r],r))&&o.push(n);else for(s in t)null!=(n=e(t[s],s))&&o.push(n);return(a=o).length>0?i.fn.concat.apply([],a):a},i.each=function(t,e){var i,n;if(F(t)){for(i=0;i<t.length;i++)if(!1===e.call(t[i],i,t[i]))return t}else for(n in t)if(!1===e.call(t[n],n,t[n]))return t;return t},i.grep=function(t,e){return l.call(t,e)},window.JSON&&(i.parseJSON=JSON.parse),i.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),(function(t,e){_["[object "+e+"]"]=e.toLowerCase()})),i.fn={constructor:R.Z,length:0,forEach:a.forEach,reduce:a.reduce,push:a.push,sort:a.sort,splice:a.splice,indexOf:a.indexOf,concat:function(){var t,e,i=[];for(t=0;t<arguments.length;t++)e=arguments[t],i[t]=R.isZ(e)?e.toArray():e;return o.apply(R.isZ(this)?this.toArray():this,i)},map:function(t){return i(i.map(this,(function(e,i){return t.call(e,i,e)})))},slice:function(){return i(c.apply(this,arguments))},ready:function(t){return k.test(h.readyState)&&h.body?t(i):h.addEventListener("DOMContentLoaded",(function(){t(i)}),!1),this},get:function(e){return e===t?c.call(this):this[e>=0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each((function(){null!=this.parentNode&&this.parentNode.removeChild(this)}))},each:function(t){return a.every.call(this,(function(e,i){return!1!==t.call(e,i,e)})),this},filter:function(t){return P(t)?this.not(this.not(t)):i(l.call(this,(function(e){return R.matches(e,t)})))},add:function(t,e){return i(s(this.concat(i(t,e))))},is:function(t){return this.length>0&&R.matches(this[0],t)},not:function(e){var n=[];if(P(e)&&e.call!==t)this.each((function(t){e.call(this,t)||n.push(this)}));else{var r="string"==typeof e?this.filter(e):F(e)&&P(e.item)?c.call(e):i(e);this.forEach((function(t){r.indexOf(t)<0&&n.push(t)}))}return i(n)},has:function(t){return this.filter((function(){return N(t)?i.contains(this,t):i(this).find(t).size()}))},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!N(t)?t:i(t)},last:function(){var t=this[this.length-1];return t&&!N(t)?t:i(t)},find:function(t){var e=this;return t?"object"==typeof t?i(t).filter((function(){var t=this;return a.some.call(e,(function(e){return i.contains(e,t)}))})):1==this.length?i(R.qsa(this[0],t)):this.map((function(){return R.qsa(this,t)})):i()},closest:function(t,e){var n=[],r="object"==typeof t&&i(t);return this.each((function(i,s){for(;s&&!(r?r.indexOf(s)>=0:R.matches(s,t));)s=s!==e&&!x(s)&&s.parentNode;s&&n.indexOf(s)<0&&n.push(s)})),i(n)},parents:function(t){for(var e=[],n=this;n.length>0;)n=i.map(n,(function(t){if((t=t.parentNode)&&!x(t)&&e.indexOf(t)<0)return e.push(t),t}));return H(e,t)},parent:function(t){return H(s(this.pluck("parentNode")),t)},children:function(t){return H(this.map((function(){return G(this)})),t)},contents:function(){return this.map((function(){return this.contentDocument||c.call(this.childNodes)}))},siblings:function(t){return H(this.map((function(t,e){return l.call(G(e.parentNode),(function(t){return t!==e}))})),t)},empty:function(){return this.each((function(){this.innerHTML=""}))},pluck:function(t){return i.map(this,(function(e){return e[t]}))},show:function(){return this.each((function(){var t,e,i;"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=(t=this.nodeName,u[t]||(e=h.createElement(t),h.body.appendChild(e),i=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==i&&(i="block"),u[t]=i),u[t]))}))},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=P(t);if(this[0]&&!e)var n=i(t).get(0),r=n.parentNode||this.length>1;return this.each((function(s){i(this).wrapAll(e?t.call(this,s):r?n.cloneNode(!0):n)}))},wrapAll:function(t){if(this[0]){var e;for(i(this[0]).before(t=i(t));(e=t.children()).length;)t=e.first();i(t).append(this)}return this},wrapInner:function(t){var e=P(t);return this.each((function(n){var r=i(this),s=r.contents(),a=e?t.call(this,n):t;s.length?s.wrapAll(a):r.append(a)}))},unwrap:function(){return this.parent().each((function(){i(this).replaceWith(i(this).children())})),this},clone:function(){return this.map((function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(e){return this.each((function(){var n=i(this);(e===t?"none"==n.css("display"):e)?n.show():n.hide()}))},prev:function(t){return i(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return i(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each((function(e){var n=this.innerHTML;i(this).empty().append(Y(this,t,e,n))})):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each((function(e){var i=Y(this,t,e,this.textContent);this.textContent=null==i?"":""+i})):0 in this?this.pluck("textContent").join(""):null},attr:function(i,n){var r;return"string"!=typeof i||1 in arguments?this.each((function(t){if(1===this.nodeType)if(N(i))for(e in i)j(this,e,i[e]);else j(this,i,Y(this,n,t,this.getAttribute(i)))})):0 in this&&1==this[0].nodeType&&null!=(r=this[0].getAttribute(i))?r:t},removeAttr:function(t){return this.each((function(){1===this.nodeType&&t.split(" ").forEach((function(t){j(this,t)}),this)}))},prop:function(t,e){return t=w[t]||t,1 in arguments?this.each((function(i){this[t]=Y(this,e,i,this[t])})):this[0]&&this[0][t]},removeProp:function(t){return t=w[t]||t,this.each((function(){delete this[t]}))},data:function(e,i){var n="data-"+e.replace(y,"-$1").toLowerCase(),r=1 in arguments?this.attr(n,i):this.attr(n);return null!==r?z(r):t},val:function(t){return 0 in arguments?(null==t&&(t=""),this.each((function(e){this.value=Y(this,t,e,this.value)}))):this[0]&&(this[0].multiple?i(this[0]).find("option").filter((function(){return this.selected})).pluck("value"):this[0].value)},offset:function(t){if(t)return this.each((function(e){var n=i(this),r=Y(this,t,e,n.offset()),s=n.offsetParent().offset(),a={top:r.top-s.top,left:r.left-s.left};"static"==n.css("position")&&(a.position="relative"),n.css(a)}));if(!this.length)return null;if(h.documentElement!==this[0]&&!i.contains(h.documentElement,this[0]))return{top:0,left:0};var e=this[0].getBoundingClientRect();return{left:e.left+window.pageXOffset,top:e.top+window.pageYOffset,width:Math.round(e.width),height:Math.round(e.height)}},css:function(t,n){if(arguments.length<2){var s=this[0];if("string"==typeof t){if(!s)return;return s.style[r(t)]||getComputedStyle(s,"").getPropertyValue(t)}if(I(t)){if(!s)return;var a={},o=getComputedStyle(s,"");return i.each(t,(function(t,e){a[e]=s.style[r(e)]||o.getPropertyValue(e)})),a}}var l="";if("string"==D(t))n||0===n?l=B(t)+":"+$(t,n):this.each((function(){this.style.removeProperty(B(t))}));else for(e in t)t[e]||0===t[e]?l+=B(e)+":"+$(e,t[e])+";":this.each((function(){this.style.removeProperty(B(e))}));return this.each((function(){this.style.cssText+=";"+l}))},index:function(t){return t?this.indexOf(i(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return!!t&&a.some.call(this,(function(t){return this.test(W(t))}),U(t))},addClass:function(t){return t?this.each((function(e){if("className"in this){n=[];var r=W(this);Y(this,t,e,r).split(/\s+/g).forEach((function(t){i(this).hasClass(t)||n.push(t)}),this),n.length&&W(this,r+(r?" ":"")+n.join(" "))}})):this},removeClass:function(e){return this.each((function(i){if("className"in this){if(e===t)return W(this,"");n=W(this),Y(this,e,i,n).split(/\s+/g).forEach((function(t){n=n.replace(U(t)," ")})),W(this,n.trim())}}))},toggleClass:function(e,n){return e?this.each((function(r){var s=i(this);Y(this,e,r,W(this)).split(/\s+/g).forEach((function(e){(n===t?!s.hasClass(e):n)?s.addClass(e):s.removeClass(e)}))})):this},scrollTop:function(e){if(this.length){var i="scrollTop"in this[0];return e===t?i?this[0].scrollTop:this[0].pageYOffset:this.each(i?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var i="scrollLeft"in this[0];return e===t?i?this[0].scrollLeft:this[0].pageXOffset:this.each(i?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),r=v.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(i(t).css("margin-top"))||0,n.left-=parseFloat(i(t).css("margin-left"))||0,r.top+=parseFloat(i(e[0]).css("border-top-width"))||0,r.left+=parseFloat(i(e[0]).css("border-left-width"))||0,{top:n.top-r.top,left:n.left-r.left}}},offsetParent:function(){return this.map((function(){for(var t=this.offsetParent||h.body;t&&!v.test(t.nodeName)&&"static"==i(t).css("position");)t=t.offsetParent;return t}))}},i.fn.detach=i.fn.remove,["width","height"].forEach((function(e){var n=e.replace(/./,(function(t){return t[0].toUpperCase()}));i.fn[e]=function(r){var s,a=this[0];return r===t?O(a)?a["inner"+n]:x(a)?a.documentElement["scroll"+n]:(s=this.offset())&&s[e]:this.each((function(t){(a=i(this)).css(e,Y(this,r,t,a[e]()))}))}})),["after","prepend","before","append"].forEach((function(e,n){var r=n%2;i.fn[e]=function(){var e,s,a=i.map(arguments,(function(n){var r=[];return"array"==(e=D(n))?(n.forEach((function(e){return e.nodeType!==t?r.push(e):i.zepto.isZ(e)?r=r.concat(e.get()):void(r=r.concat(R.fragment(e)))})),r):"object"==e||null==n?n:R.fragment(n)})),o=this.length>1;return a.length<1?this:this.each((function(t,e){s=r?e:e.parentNode,e=0==n?e.nextSibling:1==n?e.firstChild:2==n?e:null;var l=i.contains(h.documentElement,s);a.forEach((function(t){if(o)t=t.cloneNode(!0);else if(!s)return i(t).remove();s.insertBefore(t,e),l&&q(t,(function(t){if(!(null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src)){var e=t.ownerDocument?t.ownerDocument.defaultView:window;e.eval.call(e,t.innerHTML)}}))}))}))},i.fn[r?e+"To":"insert"+(n?"Before":"After")]=function(t){return i(t)[e](this),this}})),R.Z.prototype=V.prototype=i.fn,R.uniq=s,R.deserializeValue=z,i.zepto=R,i}();window.Zepto=k,void 0===window.$&&(window.$=k),function(t){var e,i,n=+new Date,r=window.document,s=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,a=/^(?:text|application)\/javascript/i,o=/^(?:text|application)\/xml/i,l="application/json",c="text/html",h=/^\s*$/,u=r.createElement("a");function d(e,i,n,s){if(e.global)return function(e,i,n){var r=t.Event(i);return t(e).trigger(r,n),!r.isDefaultPrevented()}(i||r,n,s)}function f(t,e){var i=e.context;if(!1===e.beforeSend.call(i,t,e)||!1===d(e,i,"ajaxBeforeSend",[t,e]))return!1;d(e,i,"ajaxSend",[t,e])}function g(t,e,i,n){var r=i.context,s="success";i.success.call(r,t,s,e),n&&n.resolveWith(r,[t,s,e]),d(i,r,"ajaxSuccess",[e,i,t]),m(s,e,i)}function p(t,e,i,n,r){var s=n.context;n.error.call(s,i,e,t),r&&r.rejectWith(s,[i,e,t]),d(n,s,"ajaxError",[i,n,t||e]),m(e,i,n)}function m(e,i,n){var r=n.context;n.complete.call(r,i,e),d(n,r,"ajaxComplete",[i,n]),function(e){e.global&&! --t.active&&d(e,null,"ajaxStop")}(n)}function v(){}function y(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function A(e,i,n,r){return t.isFunction(i)&&(r=n,n=i,i=void 0),t.isFunction(n)||(r=n,n=void 0),{url:e,data:i,success:n,dataType:r}}u.href=window.location.href,t.active=0,t.ajaxJSONP=function(e,i){if(!("type"in e))return t.ajax(e);var s,a,o=e.jsonpCallback,l=(t.isFunction(o)?o():o)||"Zepto"+n++,c=r.createElement("script"),h=window[l],u=function(e){t(c).triggerHandler("error",e||"abort")},d={abort:u};return i&&i.promise(d),t(c).on("load error",(function(n,r){clearTimeout(a),t(c).off().remove(),"error"!=n.type&&s?g(s[0],d,e,i):p(null,r||"error",d,e,i),window[l]=h,s&&t.isFunction(h)&&h(s[0]),h=s=void 0})),!1===f(d,e)?(u("abort"),d):(window[l]=function(){s=arguments},c.src=e.url.replace(/\?(.+)=\?/,"?$1="+l),r.head.appendChild(c),e.timeout>0&&(a=setTimeout((function(){u("timeout")}),e.timeout)),d)},t.ajaxSettings={type:"GET",beforeSend:v,success:v,error:v,complete:v,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:l,xml:"application/xml, text/xml",html:c,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:v},t.ajax=function(n){var s,m,A=t.extend({},n||{}),E=t.Deferred&&t.Deferred();for(e in t.ajaxSettings)void 0===A[e]&&(A[e]=t.ajaxSettings[e]);!function(e){e.global&&0==t.active++&&d(e,null,"ajaxStart")}(A),A.crossDomain||((s=r.createElement("a")).href=A.url,s.href=s.href,A.crossDomain=u.protocol+"//"+u.host!=s.protocol+"//"+s.host),A.url||(A.url=window.location.toString()),(m=A.url.indexOf("#"))>-1&&(A.url=A.url.slice(0,m)),function(e){e.processData&&e.data&&"string"!=t.type(e.data)&&(e.data=t.param(e.data,e.traditional)),!e.data||e.type&&"GET"!=e.type.toUpperCase()&&"jsonp"!=e.dataType||(e.url=y(e.url,e.data),e.data=void 0)}(A);var T=A.dataType,b=/\?.+=\?/.test(A.url);if(b&&(T="jsonp"),!1!==A.cache&&(n&&!0===n.cache||"script"!=T&&"jsonp"!=T)||(A.url=y(A.url,"_="+Date.now())),"jsonp"==T)return b||(A.url=y(A.url,A.jsonp?A.jsonp+"=?":!1===A.jsonp?"":"callback=?")),t.ajaxJSONP(A,E);var k,S=A.accepts[T],_={},L=function(t,e){_[t.toLowerCase()]=[t,e]},R=/^([\w-]+:)\/\//.test(A.url)?RegExp.$1:window.location.protocol,C=A.xhr(),w=C.setRequestHeader;if(E&&E.promise(C),A.crossDomain||L("X-Requested-With","XMLHttpRequest"),L("Accept",S||"*/*"),(S=A.mimeType||S)&&(S.indexOf(",")>-1&&(S=S.split(",",2)[0]),C.overrideMimeType&&C.overrideMimeType(S)),(A.contentType||!1!==A.contentType&&A.data&&"GET"!=A.type.toUpperCase())&&L("Content-Type",A.contentType||"application/x-www-form-urlencoded"),A.headers)for(i in A.headers)L(i,A.headers[i]);if(C.setRequestHeader=L,C.onreadystatechange=function(){if(4==C.readyState){C.onreadystatechange=v,clearTimeout(k);var e,i=!1;if(C.status>=200&&C.status<300||304==C.status||0==C.status&&"file:"==R){if(T=T||function(t){return t&&(t=t.split(";",2)[0]),t&&(t==c?"html":t==l?"json":a.test(t)?"script":o.test(t)&&"xml")||"text"}(A.mimeType||C.getResponseHeader("content-type")),"arraybuffer"==C.responseType||"blob"==C.responseType)e=C.response;else{e=C.responseText;try{e=function(t,e,i){if(i.dataFilter==v)return t;var n=i.context;return i.dataFilter.call(n,t,e)}(e,T,A),"script"==T?(0,eval)(e):"xml"==T?e=C.responseXML:"json"==T&&(e=h.test(e)?null:t.parseJSON(e))}catch(t){i=t}if(i)return p(i,"parsererror",C,A,E)}g(e,C,A,E)}else p(C.statusText||null,C.status?"error":"abort",C,A,E)}},!1===f(C,A))return C.abort(),p(null,"abort",C,A,E),C;var I=!("async"in A)||A.async;if(C.open(A.type,A.url,I,A.username,A.password),A.xhrFields)for(i in A.xhrFields)C[i]=A.xhrFields[i];for(i in _)w.apply(C,_[i]);return A.timeout>0&&(k=setTimeout((function(){C.onreadystatechange=v,C.abort(),p(null,"timeout",C,A,E)}),A.timeout)),C.send(A.data?A.data:null),C},t.get=function(){return t.ajax(A.apply(null,arguments))},t.post=function(){var e=A.apply(null,arguments);return e.type="POST",t.ajax(e)},t.getJSON=function(){var e=A.apply(null,arguments);return e.dataType="json",t.ajax(e)},t.fn.load=function(e,i,n){if(!this.length)return this;var r,a=this,o=e.split(/\s/),l=A(e,i,n),c=l.success;return o.length>1&&(l.url=o[0],r=o[1]),l.success=function(e){a.html(r?t("<div>").html(e.replace(s,"")).find(r):e),c&&c.apply(a,arguments)},t.ajax(l),this};var E=encodeURIComponent;function T(e,i,n,r){var s,a=t.isArray(i),o=t.isPlainObject(i);t.each(i,(function(i,l){s=t.type(l),r&&(i=n?r:r+"["+(o||"object"==s||"array"==s?i:"")+"]"),!r&&a?e.add(l.name,l.value):"array"==s||!n&&"object"==s?T(e,l,n,i):e.add(i,l)}))}t.param=function(e,i){var n=[];return n.add=function(e,i){t.isFunction(i)&&(i=i()),null==i&&(i=""),this.push(E(e)+"="+E(i))},T(n,e,i),n.join("&").replace(/%20/g,"+")}}(k),function(t){t.Callbacks=function(e){e=t.extend({},e);var i,n,r,s,a,o,l=[],c=!e.once&&[],h=function(t){for(i=e.memory&&t,n=!0,o=s||0,s=0,a=l.length,r=!0;l&&o<a;++o)if(!1===l[o].apply(t[0],t[1])&&e.stopOnFalse){i=!1;break}r=!1,l&&(c?c.length&&h(c.shift()):i?l.length=0:u.disable())},u={add:function(){if(l){var n=l.length,o=function(i){t.each(i,(function(t,i){"function"==typeof i?e.unique&&u.has(i)||l.push(i):i&&i.length&&"string"!=typeof i&&o(i)}))};o(arguments),r?a=l.length:i&&(s=n,h(i))}return this},remove:function(){return l&&t.each(arguments,(function(e,i){for(var n;(n=t.inArray(i,l,n))>-1;)l.splice(n,1),r&&(n<=a&&--a,n<=o&&--o)})),this},has:function(e){return!(!l||!(e?t.inArray(e,l)>-1:l.length))},empty:function(){return a=l.length=0,this},disable:function(){return l=c=i=void 0,this},disabled:function(){return!l},lock:function(){return c=void 0,i||u.disable(),this},locked:function(){return!c},fireWith:function(t,e){return!l||n&&!c||(e=[t,(e=e||[]).slice?e.slice():e],r?c.push(e):h(e)),this},fire:function(){return u.fireWith(this,arguments)},fired:function(){return!!n}};return u}}(k),function(t){var e=Array.prototype.slice;function i(e){var n=[["resolve","done",t.Callbacks({once:1,memory:1}),"resolved"],["reject","fail",t.Callbacks({once:1,memory:1}),"rejected"],["notify","progress",t.Callbacks({memory:1})]],r="pending",s={state:function(){return r},always:function(){return a.done(arguments).fail(arguments),this},then:function(){var e=arguments;return i((function(i){t.each(n,(function(n,r){var o=t.isFunction(e[n])&&e[n];a[r[1]]((function(){var e=o&&o.apply(this,arguments);if(e&&t.isFunction(e.promise))e.promise().done(i.resolve).fail(i.reject).progress(i.notify);else{var n=this===s?i.promise():this,a=o?[e]:arguments;i[r[0]+"With"](n,a)}}))})),e=null})).promise()},promise:function(e){return null!=e?t.extend(e,s):s}},a={};return t.each(n,(function(t,e){var i=e[2],o=e[3];s[e[1]]=i.add,o&&i.add((function(){r=o}),n[1^t][2].disable,n[2][2].lock),a[e[0]]=function(){return a[e[0]+"With"](this===a?s:this,arguments),this},a[e[0]+"With"]=i.fireWith})),s.promise(a),e&&e.call(a,a),a}t.when=function(n){var r,s,a,o=e.call(arguments),l=o.length,c=0,h=1!==l||n&&t.isFunction(n.promise)?l:0,u=1===h?n:i(),d=function(t,i,n){return function(s){i[t]=this,n[t]=arguments.length>1?e.call(arguments):s,n===r?u.notifyWith(i,n):--h||u.resolveWith(i,n)}};if(l>1)for(r=new Array(l),s=new Array(l),a=new Array(l);c<l;++c)o[c]&&t.isFunction(o[c].promise)?o[c].promise().done(d(c,a,o)).fail(u.reject).progress(d(c,s,r)):--h;return h||u.resolveWith(a,o),u.promise()},t.Deferred=i}(k),function(t){var e,i=1,n=Array.prototype.slice,r=t.isFunction,s=function(t){return"string"==typeof t},a={},o={},l="onfocusin"in window,c={focus:"focusin",blur:"focusout"},h={mouseenter:"mouseover",mouseleave:"mouseout"};function u(t){return t._zid||(t._zid=i++)}function d(t,e,i,n){if((e=f(e)).ns)var r=(s=e.ns,new RegExp("(?:^| )"+s.replace(" "," .* ?")+"(?: |$)"));var s;return(a[u(t)]||[]).filter((function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||r.test(t.ns))&&(!i||u(t.fn)===u(i))&&(!n||t.sel==n)}))}function f(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function g(t,e){return t.del&&!l&&t.e in c||!!e}function p(t){return h[t]||l&&c[t]||t}function m(i,n,r,s,o,l,c){var d=u(i),m=a[d]||(a[d]=[]);n.split(/\s/).forEach((function(n){if("ready"==n)return t(document).ready(r);var a=f(n);a.fn=r,a.sel=o,a.e in h&&(r=function(e){var i=e.relatedTarget;if(!i||i!==this&&!t.contains(this,i))return a.fn.apply(this,arguments)}),a.del=l;var u=l||r;a.proxy=function(t){if(!(t=b(t)).isImmediatePropagationStopped()){t.data=s;var n=u.apply(i,t._args==e?[t]:[t].concat(t._args));return!1===n&&(t.preventDefault(),t.stopPropagation()),n}},a.i=m.length,m.push(a),"addEventListener"in i&&i.addEventListener(p(a.e),a.proxy,g(a,c))}))}function v(t,e,i,n,r){var s=u(t);(e||"").split(/\s/).forEach((function(e){d(t,e,i,n).forEach((function(e){delete a[s][e.i],"removeEventListener"in t&&t.removeEventListener(p(e.e),e.proxy,g(e,r))}))}))}o.click=o.mousedown=o.mouseup=o.mousemove="MouseEvents",t.event={add:m,remove:v},t.proxy=function(e,i){var a=2 in arguments&&n.call(arguments,2);if(r(e)){var o=function(){return e.apply(i,a?a.concat(n.call(arguments)):arguments)};return o._zid=u(e),o}if(s(i))return a?(a.unshift(e[i],e),t.proxy.apply(null,a)):t.proxy(e[i],e);throw new TypeError("expected function")},t.fn.bind=function(t,e,i){return this.on(t,e,i)},t.fn.unbind=function(t,e){return this.off(t,e)},t.fn.one=function(t,e,i,n){return this.on(t,e,i,n,1)};var y=function(){return!0},A=function(){return!1},E=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,T={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};function b(i,n){return!n&&i.isDefaultPrevented||(n||(n=i),t.each(T,(function(t,e){var r=n[t];i[t]=function(){return this[e]=y,r&&r.apply(n,arguments)},i[e]=A})),i.timeStamp||(i.timeStamp=Date.now()),(n.defaultPrevented!==e?n.defaultPrevented:"returnValue"in n?!1===n.returnValue:n.getPreventDefault&&n.getPreventDefault())&&(i.isDefaultPrevented=y)),i}function k(t){var i,n={originalEvent:t};for(i in t)E.test(i)||t[i]===e||(n[i]=t[i]);return b(n,t)}t.fn.delegate=function(t,e,i){return this.on(e,t,i)},t.fn.undelegate=function(t,e,i){return this.off(e,t,i)},t.fn.live=function(e,i){return t(document.body).delegate(this.selector,e,i),this},t.fn.die=function(e,i){return t(document.body).undelegate(this.selector,e,i),this},t.fn.on=function(i,a,o,l,c){var h,u,d=this;return i&&!s(i)?(t.each(i,(function(t,e){d.on(t,a,o,e,c)})),d):(s(a)||r(l)||!1===l||(l=o,o=a,a=e),l!==e&&!1!==o||(l=o,o=e),!1===l&&(l=A),d.each((function(e,r){c&&(h=function(t){return v(r,t.type,l),l.apply(this,arguments)}),a&&(u=function(e){var i,s=t(e.target).closest(a,r).get(0);if(s&&s!==r)return i=t.extend(k(e),{currentTarget:s,liveFired:r}),(h||l).apply(s,[i].concat(n.call(arguments,1)))}),m(r,i,l,o,a,u||h)})))},t.fn.off=function(i,n,a){var o=this;return i&&!s(i)?(t.each(i,(function(t,e){o.off(t,n,e)})),o):(s(n)||r(a)||!1===a||(a=n,n=e),!1===a&&(a=A),o.each((function(){v(this,i,a,n)})))},t.fn.trigger=function(e,i){return(e=s(e)||t.isPlainObject(e)?t.Event(e):b(e))._args=i,this.each((function(){e.type in c&&"function"==typeof this[e.type]?this[e.type]():"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,i)}))},t.fn.triggerHandler=function(e,i){var n,r;return this.each((function(a,o){(n=k(s(e)?t.Event(e):e))._args=i,n.target=o,t.each(d(o,e.type||e),(function(t,e){if(r=e.proxy(n),n.isImmediatePropagationStopped())return!1}))})),r},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach((function(e){t.fn[e]=function(t){return 0 in arguments?this.bind(e,t):this.trigger(e)}})),t.Event=function(t,e){s(t)||(t=(e=t).type);var i=document.createEvent(o[t]||"Events"),n=!0;if(e)for(var r in e)"bubbles"==r?n=!!e[r]:i[r]=e[r];return i.initEvent(t,n,!0),b(i)}}(k),function(){try{getComputedStyle(void 0)}catch(e){var t=getComputedStyle;window.getComputedStyle=function(e,i){try{return t(e,i)}catch(t){return null}}}}(),function(t){var e=t.zepto,i=e.qsa,n=e.matches;function r(e){return!(!(e=t(e)).width()&&!e.height())&&"none"!==e.css("display")}var s=t.expr[":"]={visible:function(){if(r(this))return this},hidden:function(){if(!r(this))return this},selected:function(){if(this.selected)return this},checked:function(){if(this.checked)return this},parent:function(){return this.parentNode},first:function(t){if(0===t)return this},last:function(t,e){if(t===e.length-1)return this},eq:function(t,e,i){if(t===i)return this},contains:function(e,i,n){if(t(this).text().indexOf(n)>-1)return this},has:function(t,i,n){if(e.qsa(this,n).length)return this}},a=new RegExp("(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*"),o=/^\s*>/,l="Zepto"+ +new Date;function c(t,e){t=t.replace(/=#\]/g,'="#"]');var i,n,r=a.exec(t);if(r&&r[2]in s&&(i=s[r[2]],n=r[3],t=r[1],n)){var o=Number(n);n=isNaN(o)?n.replace(/^["']|["']$/g,""):o}return e(t,i,n)}e.qsa=function(n,r){return c(r,(function(s,a,c){try{var h;!s&&a?s="*":o.test(s)&&(h=t(n).addClass(l),s="."+l+" "+s);var u=i(n,s)}catch(t){throw console.error("error performing selector: %o",r),t}finally{h&&h.removeClass(l)}return a?e.uniq(t.map(u,(function(t,e){return a.call(t,e,u,c)}))):u}))},e.matches=function(t,e){return c(e,(function(e,i,r){return(!e||n(t,e))&&(!i||i.call(t,null,r)===t)}))}}(k);var S=b(k);Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var s=e[r];if(t.call(n,s,r,e))return s;r++}}}),Object.entries||(Object.entries=function(t){for(var e=Object.keys(t),i=e.length,n=new Array(i);i--;)n[i]=[e[i],t[e[i]]];return n}),Object.values||(Object.values=function(t){for(var e=Object.keys(t),i=e.length,n=new Array(i);i--;)n[i]=t[e[i]];return n}),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(t,e){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(t),n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])}return i},writable:!0,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(t){if(null==this)throw new TypeError('"this" is null or not defined');var e=Object(this),i=e.length>>>0;if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var n=arguments[1],r=0;r<i;){var s=e[r];if(t.call(n,s,r,e))return r;r++}return-1},configurable:!0,writable:!0});var _,L,R,C={mp4:"data:video/mp4;base64,AAAAHGZ0eXBpc29tAAACAGlzb21pc28ybXA0MQAAAAhmcmVlAAAC721kYXQhEAUgpBv/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3pwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcCEQBSCkG//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADengAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAsJtb292AAAAbG12aGQAAAAAAAAAAAAAAAAAAAPoAAAALwABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAB7HRyYWsAAABcdGtoZAAAAAMAAAAAAAAAAAAAAAIAAAAAAAAALwAAAAAAAAAAAAAAAQEAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAAC8AAAAAAAEAAAAAAWRtZGlhAAAAIG1kaGQAAAAAAAAAAAAAAAAAAKxEAAAIAFXEAAAAAAAtaGRscgAAAAAAAAAAc291bgAAAAAAAAAAAAAAAFNvdW5kSGFuZGxlcgAAAAEPbWluZgAAABBzbWhkAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAADTc3RibAAAAGdzdHNkAAAAAAAAAAEAAABXbXA0YQAAAAAAAAABAAAAAAAAAAAAAgAQAAAAAKxEAAAAAAAzZXNkcwAAAAADgICAIgACAASAgIAUQBUAAAAAAfQAAAHz+QWAgIACEhAGgICAAQIAAAAYc3R0cwAAAAAAAAABAAAAAgAABAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAIAAAABAAAAHHN0c3oAAAAAAAAAAAAAAAIAAAFzAAABdAAAABRzdGNvAAAAAAAAAAEAAAAsAAAAYnVkdGEAAABabWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAtaWxzdAAAACWpdG9vAAAAHWRhdGEAAAABAAAAAExhdmY1Ni40MC4xMDE="},w=[{name:"Chromium",group:"Chrome",identifier:"Chromium/([0-9.]*)"},{name:"Chrome Mobile",group:"Chrome",identifier:"Chrome/([0-9.]*) Mobile",versionIdentifier:"Chrome/([0-9.]*)"},{name:"Chrome",group:"Chrome",identifier:"Chrome/([0-9.]*)"},{name:"Chrome for iOS",group:"Chrome",identifier:"CriOS/([0-9.]*)"},{name:"Android Browser",group:"Chrome",identifier:"CrMo/([0-9.]*)"},{name:"Firefox",group:"Firefox",identifier:"Firefox/([0-9.]*)"},{name:"Opera Mini",group:"Opera",identifier:"Opera Mini/([0-9.]*)"},{name:"Opera",group:"Opera",identifier:"Opera ([0-9.]*)"},{name:"Opera",group:"Opera",identifier:"Opera/([0-9.]*)",versionIdentifier:"Version/([0-9.]*)"},{name:"IEMobile",group:"Explorer",identifier:"IEMobile/([0-9.]*)"},{name:"Internet Explorer",group:"Explorer",identifier:"MSIE ([a-zA-Z0-9.]*)"},{name:"Internet Explorer",group:"Explorer",identifier:"Trident/([0-9.]*)",versionIdentifier:"rv:([0-9.]*)"},{name:"Spartan",group:"Spartan",identifier:"Edge/([0-9.]*)",versionIdentifier:"Edge/([0-9.]*)"},{name:"Safari",group:"Safari",identifier:"Safari/([0-9.]*)",versionIdentifier:"Version/([0-9.]*)"}],I=[{name:"Windows 2000",group:"Windows",identifier:"Windows NT 5.0",version:"5.0"},{name:"Windows XP",group:"Windows",identifier:"Windows NT 5.1",version:"5.1"},{name:"Windows Vista",group:"Windows",identifier:"Windows NT 6.0",version:"6.0"},{name:"Windows 7",group:"Windows",identifier:"Windows NT 6.1",version:"7.0"},{name:"Windows 8",group:"Windows",identifier:"Windows NT 6.2",version:"8.0"},{name:"Windows 8.1",group:"Windows",identifier:"Windows NT 6.3",version:"8.1"},{name:"Windows 10",group:"Windows",identifier:"Windows NT 10.0",version:"10.0"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone ([0-9.]*)"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone OS ([0-9.]*)"},{name:"Windows",group:"Windows",identifier:"Windows"},{name:"Chrome OS",group:"Chrome OS",identifier:"CrOS"},{name:"Android",group:"Android",identifier:"Android",versionIdentifier:"Android ([a-zA-Z0-9.-]*)"},{name:"iPad",group:"iOS",identifier:"iPad",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPod",group:"iOS",identifier:"iPod",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPhone",group:"iOS",identifier:"iPhone OS",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"Mac OS X High Sierra",group:"Mac OS",identifier:"Mac OS X (10([_|.])13([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Sierra",group:"Mac OS",identifier:"Mac OS X (10([_|.])12([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X El Capitan",group:"Mac OS",identifier:"Mac OS X (10([_|.])11([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Yosemite",group:"Mac OS",identifier:"Mac OS X (10([_|.])10([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mavericks",group:"Mac OS",identifier:"Mac OS X (10([_|.])9([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mountain Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])8([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])7([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Snow Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])6([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])5([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Tiger",group:"Mac OS",identifier:"Mac OS X (10([_|.])4([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Panther",group:"Mac OS",identifier:"Mac OS X (10([_|.])3([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Jaguar",group:"Mac OS",identifier:"Mac OS X (10([_|.])2([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Puma",group:"Mac OS",identifier:"Mac OS X (10([_|.])1([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Cheetah",group:"Mac OS",identifier:"Mac OS X (10([_|.])0([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS",group:"Mac OS",identifier:"Mac OS"},{name:"Ubuntu",group:"Linux",identifier:"Ubuntu",versionIdentifier:"Ubuntu/([0-9.]*)"},{name:"Debian",group:"Linux",identifier:"Debian"},{name:"Gentoo",group:"Linux",identifier:"Gentoo"},{name:"Linux",group:"Linux",identifier:"Linux"},{name:"BlackBerry",group:"BlackBerry",identifier:"BlackBerry"}],D={},P=function(t,e){var i=t.split(".",2);e.fullVersion=t,i[0]&&(e.majorVersion=parseInt(i[0])),i[1]&&(e.minorVersion=parseInt(i[1]))},O=function(t,e,i){var n="["==e.substr(0,1)?new RegExp(e,"g"):e,r=t.split(n,2);"."!=e&&(t=t.replace(new RegExp(e,"g"),".")),i.fullVersion=t,r&&r[0]&&(i.majorVersion=parseInt(r[0])),r&&r[1]&&(i.minorVersion=parseInt(r[1]))},x=function(t){var e,i=t.match(/\b(playstation 4|nx|opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(i[1]))return e=/\brv[ :]+(\d+)/g.exec(t)||[],{name:"IE",version:parseInt(e[1]||"")};if("Chrome"===i[1]){if(null!=(e=t.match(/\bOPR\/(\d+)/)))return{name:"Opera",version:parseInt(e[1])};if(null!=(e=t.match(/\bEdge\/(\d+)/)))return{name:"Edge",version:parseInt(e[1])}}else/android/i.test(t)&&(e=t.match(/version\/(\d+)/i))&&(i.splice(1,1,"Android WebView"),i.splice(2,1,e[1]));return{name:(i=i[2]?[i[1],i[2]]:[navigator.appName,navigator.appVersion,"-?"])[0],version:parseInt(i[1])}}(navigator.userAgent);D.isEdge=/Edg|EdgiOS|EdgA/i.test(navigator.userAgent),D.isChrome=/Chrome|CriOS/i.test(navigator.userAgent)&&!D.isEdge,D.isSafari=/Safari/i.test(navigator.userAgent)&&!D.isChrome&&!D.isEdge,D.isFirefox=/Firefox/i.test(navigator.userAgent),D.isLegacyIE=!!window.ActiveXObject,D.isIE=D.isLegacyIE||/trident.*rv:1\d/i.test(navigator.userAgent),D.isIE11=/trident.*rv:11/i.test(navigator.userAgent),D.isChromecast=D.isChrome&&/CrKey/i.test(navigator.userAgent),D.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone|IEMobile|Mobile Safari|Opera Mini/i.test(navigator.userAgent),D.isiOS=/iPad|iPhone|iPod/i.test(navigator.userAgent),D.isAndroid=/Android/i.test(navigator.userAgent),D.isWindowsPhone=/Windows Phone/i.test(navigator.userAgent),D.isWin8App=/MSAppHost/i.test(navigator.userAgent),D.isWiiU=/WiiU/i.test(navigator.userAgent),D.isPS4=/PlayStation 4/i.test(navigator.userAgent),D.hasLocalstorage=function(){try{return localStorage.setItem("clappr","clappr"),localStorage.removeItem("clappr"),!0}catch(t){return!1}}(),D.hasFlash=function(){try{return!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(t){return!(!navigator.mimeTypes||void 0===navigator.mimeTypes["application/x-shockwave-flash"]||!navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)}}(),D.name=x.name,D.version=x.version,D.userAgent=navigator.userAgent,D.data=function(){var t,e={},i=D.userAgent.toLowerCase(),n=T(w);try{for(n.s();!(t=n.n()).done;){var r=t.value,s=new RegExp(r.identifier.toLowerCase()).exec(i);if(null!=s&&s[1]){if(e.name=r.name,e.group=r.group,r.versionIdentifier){var a=new RegExp(r.versionIdentifier.toLowerCase()).exec(i);null!=a&&a[1]&&P(a[1],e)}else P(s[1],e);break}}}catch(t){n.e(t)}finally{n.f()}return e}(),D.os=function(){var t,e={},i=D.userAgent.toLowerCase(),n=T(I);try{for(n.s();!(t=n.n()).done;){var r=t.value,s=new RegExp(r.identifier.toLowerCase()).exec(i);if(null!=s){if(e.name=r.name,e.group=r.group,r.version)O(r.version,r.versionSeparator?r.versionSeparator:".",e);else if(s[1])O(s[1],r.versionSeparator?r.versionSeparator:".",e);else if(r.versionIdentifier){var a=new RegExp(r.versionIdentifier.toLowerCase()).exec(i);null!=a&&a[1]&&O(a[1],r.versionSeparator?r.versionSeparator:".",e)}break}}}catch(t){n.e(t)}finally{n.f()}return e}(),D.isWindows=/^Windows$/i.test(D.os.group),D.isMacOS=/^Mac OS$/i.test(D.os.group),D.isLinux=/^Linux$/i.test(D.os.group),D.viewport=((_={}).width=S(window).width(),_.height=S(window).height(),_),D.device=(L=D.userAgent,(R=/\((iP(?:hone|ad|od))?(?:[^;]*; ){0,2}([^)]+(?=\)))/.exec(L))&&(R[1]||R[2])||""),void 0!==window.orientation&&function(){switch(window.orientation){case-90:case 90:D.viewport.orientation="landscape";break;default:D.viewport.orientation="portrait"}}();var N={},M=[],F=(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}).bind(window),B=(window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.clearTimeout).bind(window);function U(t,e){if(e)for(var i in e){var n=Object.getOwnPropertyDescriptor(e,i);n?Object.defineProperty(t,i,n):t[i]=e[i]}return t}function $(t,e){var i=function(t){function i(){var t;c(this,i);for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];return t=n(this,i,[].concat(s)),e.initialize&&e.initialize.apply(t,s),t}return f(i,t),u(i)}(t);return U(i.prototype,e),i}var G={fullscreenElement:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},requestFullscreen:function(t){if(t.requestFullscreen)return t.requestFullscreen();if(t.webkitRequestFullscreen){if("function"==typeof t.then)return t.webkitRequestFullscreen();t.webkitRequestFullscreen()}else{if(t.mozRequestFullScreen)return t.mozRequestFullScreen();if(t.msRequestFullscreen)return t.msRequestFullscreen();t.querySelector&&t.querySelector("video")&&t.querySelector("video").webkitEnterFullScreen?t.querySelector("video").webkitEnterFullScreen():t.webkitEnterFullScreen&&t.webkitEnterFullScreen()}},cancelFullscreen:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;t.exitFullscreen?t.exitFullscreen():t.webkitCancelFullScreen?t.webkitCancelFullScreen():t.webkitExitFullscreen?t.webkitExitFullscreen():t.mozCancelFullScreen?t.mozCancelFullScreen():t.msExitFullscreen&&t.msExitFullscreen()},fullscreenEnabled:function(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}},V=function(){return u((function t(){c(this,t)}),null,[{key:"_defaultConfig",value:function(){return{volume:{value:100,parse:parseInt}}}},{key:"_defaultValueFor",value:function(t){try{return this._defaultConfig()[t].parse(this._defaultConfig()[t].value)}catch(t){return}}},{key:"_createKeyspace",value:function(t){return"clappr.".concat(document.domain,".").concat(t)}},{key:"restore",value:function(t){return D.hasLocalstorage&&localStorage[this._createKeyspace(t)]?this._defaultConfig()[t].parse(localStorage[this._createKeyspace(t)]):this._defaultValueFor(t)}},{key:"persist",value:function(t,e){if(D.hasLocalstorage)try{return localStorage[this._createKeyspace(t)]=e,!0}catch(t){return!1}}}])}(),K=function(){return u((function t(){c(this,t)}),null,[{key:"params",get:function(){var t=window.location.search.substring(1);return t!==this.query&&(this._urlParams=this.parse(t),this.query=t),this._urlParams}},{key:"hashParams",get:function(){var t=window.location.hash.substring(1);return t!==this.hash&&(this._hashParams=this.parse(t),this.hash=t),this._hashParams}},{key:"parse",value:function(t){for(var e,i=/\+/g,n=/([^&=]+)=?([^&]*)/g,r=function(t){return decodeURIComponent(t.replace(i," "))},s={};e=n.exec(t);)s[r(e[1]).toLowerCase()]=r(e[2]);return s}}])}();function H(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"t",e=0,i=K.params[t]||K.hashParams[t]||"",n=i.match(/[0-9]+[hms]+/g)||[];if(n.length>0){var r={h:3600,m:60,s:1};n.forEach((function(t){if(t){var i=t[t.length-1],n=parseInt(t.slice(0,t.length-1),10);e+=n*r[i]}}))}else i&&(e=parseInt(i,10));return e}function Y(t){return N[t]||(N[t]=0),t+ ++N[t]}function j(t){return t-parseFloat(t)+1>=0}function W(){var t=document.getElementsByTagName("script");return t.length?t[t.length-1].src:""}function z(){return window.navigator&&window.navigator.language}function q(t,e){var i=(e=Object.assign({inline:!1,muted:!1,timeout:250,type:"video",source:C.mp4,element:null},e)).element?e.element:document.createElement(e.type);i.muted=e.muted,!0===e.muted&&i.setAttribute("muted","muted"),!0===e.inline&&i.setAttribute("playsinline","playsinline"),i.src=e.source;var n=i.play(),r=setTimeout((function(){s(!1,new Error("Timeout ".concat(e.timeout," ms has been reached")))}),e.timeout),s=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;clearTimeout(r),t(e,i)};void 0!==n?n.then((function(){return s(!0)})).catch((function(t){return s(!1,t)})):s(!0)}var X=function(){return u((function t(){c(this,t)}),null,[{key:"configure",value:function(t){this.options=S.extend(!0,this.options,t)}},{key:"create",value:function(t){return this.options.recycleVideo&&"video"===t&&M.length>0?M.shift():document.createElement(t)}},{key:"garbage",value:function(t){this.options.recycleVideo&&"VIDEO"===t.tagName.toUpperCase()&&(S(t).children().remove(),Object.values(t.attributes).forEach((function(e){return t.removeAttribute(e.name)})),M.push(t))}}])}();X.options={recycleVideo:!1};var Q=function(){return u((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500;c(this,t),this.delay=e,this.lastTime=0}),[{key:"handle",value:function(t,e){var i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=(new Date).getTime(),r=n-this.lastTime;r<this.delay&&r>0&&(e(),i&&t.preventDefault()),this.lastTime=n}}])}(),Z={Config:V,Fullscreen:G,QueryString:K,DomRecycler:X,assign:U,extend:$,formatTime:function(t,e){if(!isFinite(t))return"--:--";t*=1e3;var i=(t=parseInt(t/1e3))%60,n=(t=parseInt(t/60))%60,r=(t=parseInt(t/60))%24,s=parseInt(t/24),a="";return s&&s>0&&(a+=s+":",r<1&&(a+="00:")),(r&&r>0||e)&&(a+=("0"+r).slice(-2)+":"),a+=("0"+n).slice(-2)+":",(a+=("0"+i).slice(-2)).trim()},seekStringToSeconds:H,uniqueId:Y,currentScriptUrl:W,isNumber:j,requestAnimationFrame:F,cancelAnimationFrame:B,getBrowserLanguage:z,now:function(){return window.performance&&window.performance.now?performance.now():Date.now()},removeArrayItem:function(t,e){var i=t.indexOf(e);i>=0&&t.splice(i,1)},listContainsIgnoreCase:function(t,e){return void 0!==t&&void 0!==e&&void 0!==e.find((function(e){return t.toLowerCase()===e.toLowerCase()}))},canAutoPlayMedia:q,Media:C,DoubleEventHandler:Q},J="font-weight: bold; font-size: 13px;",tt="color: #ff8000;"+J,et="color: #ff0000;"+J,it=["color: #0000ff;"+J,"color: #006600;"+J,tt,et,et],nt=["debug","info","warn","error","disabled"],rt=function(){return u((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;c(this,t),this.EXCLUDE_LIST=["timeupdate","playback:timeupdate","playback:progress","container:hover","container:timeupdate","container:progress","core:mousemove"],this.level=e,this.previousLevel=this.level,this.offLevel=i}),[{key:"level",get:function(){return this._level},set:function(t){this._level=t}},{key:"debug",value:function(t){this.log(t,0,Array.prototype.slice.call(arguments,1))}},{key:"info",value:function(t){this.log(t,1,Array.prototype.slice.call(arguments,1))}},{key:"warn",value:function(t){this.log(t,2,Array.prototype.slice.call(arguments,1))}},{key:"error",value:function(t){this.log(t,3,Array.prototype.slice.call(arguments,1))}},{key:"onOff",value:function(){this.level===this.offLevel?this.level=this.previousLevel:(this.previousLevel=this.level,this.level=this.offLevel),window.console&&window.console.log&&window.console.log("%c[Clappr.Log] set log level to "+nt[this.level],tt)}},{key:"log",value:function(t,e,i){if(!(e<this.level||this.EXCLUDE_LIST.indexOf(i[0])>=0)){i||(i=t,t=null);var n=it[e],r="";t&&(r="["+t+"]"),window.console&&window.console.log&&window.console.log.apply(console,["%c["+nt[e]+"]"+r,n].concat(i))}}}])}();rt.LEVEL_DEBUG=0,rt.LEVEL_INFO=1,rt.LEVEL_WARN=2,rt.LEVEL_ERROR=3,rt.getInstance=function(){return void 0===this._instance&&(this._instance=new this),this._instance},rt.setLevel=function(t){this.getInstance().level=t},rt.debug=function(){this.getInstance().debug.apply(this.getInstance(),arguments)},rt.info=function(){this.getInstance().info.apply(this.getInstance(),arguments)},rt.warn=function(){this.getInstance().warn.apply(this.getInstance(),arguments)},rt.error=function(){this.getInstance().error.apply(this.getInstance(),arguments)};var st=Array.prototype.slice,at=/\s+/,ot=function(t,e,i,n){if(!i)return!0;if("object"===l(i)){for(var r in i)t[e].apply(t,[r,i[r]].concat(n));return!1}if(at.test(i)){for(var s=i.split(at),a=0,o=s.length;a<o;a++)t[e].apply(t,[s[a]].concat(n));return!1}return!0},lt=function(t,e,i,n){var r,s=-1,a=t.length,o=e[0],l=e[1],c=e[2];!function h(){try{switch(e.length){case 0:for(;++s<a;)(r=t[s]).callback.call(r.ctx);return;case 1:for(;++s<a;)(r=t[s]).callback.call(r.ctx,o);return;case 2:for(;++s<a;)(r=t[s]).callback.call(r.ctx,o,l);return;case 3:for(;++s<a;)(r=t[s]).callback.call(r.ctx,o,l,c);return;default:for(;++s<a;)(r=t[s]).callback.apply(r.ctx,e);return}}catch(t){rt.error.apply(rt,[i,"error on event",n,"trigger","-",t]),h()}}()},ct=function(){function t(){c(this,t)}return u(t,[{key:"on",value:function(t,e,i){return ot(this,"on",t,[e,i])&&e?(this._events||(this._events={}),(this._events[t]||(this._events[t]=[])).push({callback:e,context:i,ctx:i||this}),this):this}},{key:"once",value:function(t,e,i){var n,r=this;if(!ot(this,"once",t,[e,i])||!e)return this;return n=function(){r.off(t,n),e.apply(this,arguments)},n._callback=e,this.on(t,n,i)}},{key:"off",value:function(t,e,i){var n,r,s,a,o,l,c,h;if(!this._events||!ot(this,"off",t,[e,i]))return this;if(!t&&!e&&!i)return this._events=void 0,this;for(o=0,l=(a=t?[t]:Object.keys(this._events)).length;o<l;o++)if(t=a[o],s=this._events[t]){if(this._events[t]=n=[],e||i)for(c=0,h=s.length;c<h;c++)r=s[c],(e&&e!==r.callback&&e!==r.callback._callback||i&&i!==r.context)&&n.push(r);n.length||delete this._events[t]}return this}},{key:"trigger",value:function(t){var e=this.name||this.constructor.name;if(rt.debug.apply(rt,[e].concat(Array.prototype.slice.call(arguments))),!this._events)return this;var i=st.call(arguments,1);if(!ot(this,"trigger",t,i))return this;var n=this._events[t],r=this._events.all;return n&<(n,i,e,t),r&<(r,arguments,e,t),this}},{key:"stopListening",value:function(t,e,i){var n=this._listeningTo;if(!n)return this;var r=!e&&!i;for(var s in i||"object"!==l(e)||(i=this),t&&((n={})[t._listenId]=t),n)(t=n[s]).off(e,i,this),(r||0===Object.keys(t._events).length)&&delete this._listeningTo[s];return this}}],[{key:"register",value:function(e){t.Custom||(t.Custom={});var i="string"==typeof e&&e.toUpperCase().trim();i&&!t.Custom[i]?t.Custom[i]=i.toLowerCase().split("_").map((function(t,e){return 0===e?t:t=t[0].toUpperCase()+t.slice(1)})).join(""):rt.error("Events","Error when register event: "+e)}},{key:"listAvailableCustomEvents",value:function(){return t.Custom||(t.Custom={}),Object.keys(t.Custom).filter((function(e){return"string"==typeof t.Custom[e]}))}}])}();ct.prototype.listenTo=function(t,e,i){return(this._listeningTo||(this._listeningTo={}))[t._listenId||(t._listenId=Y("l"))]=t,i||"object"!==l(e)||(i=this),t.on(e,i,this),this},ct.prototype.listenToOnce=function(t,e,i){return(this._listeningTo||(this._listeningTo={}))[t._listenId||(t._listenId=Y("l"))]=t,i||"object"!==l(e)||(i=this),t.once(e,i,this),this},ct.PLAYER_READY="ready",ct.PLAYER_RESIZE="resize",ct.PLAYER_FULLSCREEN="fullscreen",ct.PLAYER_PLAY="play",ct.PLAYER_PAUSE="pause",ct.PLAYER_STOP="stop",ct.PLAYER_ENDED="ended",ct.PLAYER_SEEK="seek",ct.PLAYER_ERROR="playererror",ct.ERROR="error",ct.PLAYER_TIMEUPDATE="timeupdate",ct.PLAYER_VOLUMEUPDATE="volumeupdate",ct.PLAYER_SUBTITLE_AVAILABLE="subtitleavailable",ct.PLAYBACK_PIP_ENTER="playback:picture-in-picture:enter",ct.PLAYBACK_PIP_EXIT="playback:picture-in-picture:exit",ct.PLAYBACK_PROGRESS="playback:progress",ct.PLAYBACK_TIMEUPDATE="playback:timeupdate",ct.PLAYBACK_READY="playback:ready",ct.PLAYBACK_BUFFERING="playback:buffering",ct.PLAYBACK_BUFFERFULL="playback:bufferfull",ct.PLAYBACK_SETTINGSUPDATE="playback:settingsupdate",ct.PLAYBACK_LOADEDMETADATA="playback:loadedmetadata",ct.PLAYBACK_HIGHDEFINITIONUPDATE="playback:highdefinitionupdate",ct.PLAYBACK_BITRATE="playback:bitrate",ct.PLAYBACK_LEVELS_AVAILABLE="playback:levels:available",ct.PLAYBACK_LEVEL_SWITCH_START="playback:levels:switch:start",ct.PLAYBACK_LEVEL_SWITCH_END="playback:levels:switch:end",ct.PLAYBACK_PLAYBACKSTATE="playback:playbackstate",ct.PLAYBACK_DVR="playback:dvr",ct.PLAYBACK_MEDIACONTROL_DISABLE="playback:mediacontrol:disable",ct.PLAYBACK_MEDIACONTROL_ENABLE="playback:mediacontrol:enable",ct.PLAYBACK_ENDED="playback:ended",ct.PLAYBACK_PLAY_INTENT="playback:play:intent",ct.PLAYBACK_PLAY="playback:play",ct.PLAYBACK_PAUSE="playback:pause",ct.PLAYBACK_SEEK="playback:seek",ct.PLAYBACK_SEEKED="playback:seeked",ct.PLAYBACK_STOP="playback:stop",ct.PLAYBACK_ERROR="playback:error",ct.PLAYBACK_STATS_ADD="playback:stats:add",ct.PLAYBACK_FRAGMENT_LOADED="playback:fragment:loaded",ct.PLAYBACK_FRAGMENT_BUFFERED="playback:fragment:buffered",ct.PLAYBACK_LEVEL_SWITCH="playback:level:switch",ct.PLAYBACK_SUBTITLE_AVAILABLE="playback:subtitle:available",ct.PLAYBACK_SUBTITLE_CHANGED="playback:subtitle:changed",ct.PLAYBACK_AUDIO_AVAILABLE="playback:audio:available",ct.PLAYBACK_AUDIO_CHANGED="playback:audio:changed",ct.PLAYBACK_RESIZE="playback:resize",ct.CORE_CONTAINERS_CREATED="core:containers:created",ct.CORE_ACTIVE_CONTAINER_CHANGED="core:active:container:changed",ct.CORE_OPTIONS_CHANGE="core:options:change",ct.CORE_READY="core:ready",ct.CORE_FULLSCREEN="core:fullscreen",ct.CORE_RESIZE="core:resize",ct.CORE_SCREEN_ORIENTATION_CHANGED="core:screen:orientation:changed",ct.CORE_MOUSE_MOVE="core:mousemove",ct.CORE_MOUSE_LEAVE="core:mouseleave",ct.CONTAINER_PLAYBACKSTATE="container:playbackstate",ct.CONTAINER_PLAYBACKDVRSTATECHANGED="container:dvr",ct.CONTAINER_BITRATE="container:bitrate",ct.CONTAINER_STATS_REPORT="container:stats:report",ct.CONTAINER_DESTROYED="container:destroyed",ct.CONTAINER_READY="container:ready",ct.CONTAINER_RESIZE="container:resize",ct.CONTAINER_ERROR="container:error",ct.CONTAINER_LOADEDMETADATA="container:loadedmetadata",ct.CONTAINER_SUBTITLE_AVAILABLE="container:subtitle:available",ct.CONTAINER_SUBTITLE_CHANGED="container:subtitle:changed",ct.CONTAINER_AUDIO_AVAILABLE="container:audio:available",ct.CONTAINER_AUDIO_CHANGED="container:audio:changed",ct.CONTAINER_TIMEUPDATE="container:timeupdate",ct.CONTAINER_PROGRESS="container:progress",ct.CONTAINER_PLAY="container:play",ct.CONTAINER_STOP="container:stop",ct.CONTAINER_PAUSE="container:pause",ct.CONTAINER_ENDED="container:ended",ct.CONTAINER_CLICK="container:click",ct.CONTAINER_DBLCLICK="container:dblclick",ct.CONTAINER_CONTEXTMENU="container:contextmenu",ct.CONTAINER_MOUSE_ENTER="container:mouseenter",ct.CONTAINER_MOUSE_LEAVE="container:mouseleave",ct.CONTAINER_MOUSE_UP="container:mouseup",ct.CONTAINER_MOUSE_DOWN="container:mousedown",ct.CONTAINER_PIP_ENTER="container:picture-in-picture:enter",ct.CONTAINER_PIP_EXIT="container:picture-in-picture:exit",ct.CONTAINER_SEEK="container:seek",ct.CONTAINER_SEEKED="container:seeked",ct.CONTAINER_VOLUME="container:volume",ct.CONTAINER_FULLSCREEN="container:fullscreen",ct.CONTAINER_STATE_BUFFERING="container:state:buffering",ct.CONTAINER_STATE_BUFFERFULL="container:state:bufferfull",ct.CONTAINER_SETTINGSUPDATE="container:settingsupdate",ct.CONTAINER_HIGHDEFINITIONUPDATE="container:highdefinitionupdate",ct.CONTAINER_MEDIACONTROL_SHOW="container:mediacontrol:show",ct.CONTAINER_MEDIACONTROL_HIDE="container:mediacontrol:hide",ct.CONTAINER_MEDIACONTROL_DISABLE="container:mediacontrol:disable",ct.CONTAINER_MEDIACONTROL_ENABLE="container:mediacontrol:enable",ct.CONTAINER_STATS_ADD="container:stats:add",ct.CONTAINER_OPTIONS_CHANGE="container:options:change",ct.MEDIACONTROL_RENDERED="mediacontrol:rendered",ct.MEDIACONTROL_FULLSCREEN="mediacontrol:fullscreen",ct.MEDIACONTROL_SHOW="mediacontrol:show",ct.MEDIACONTROL_HIDE="mediacontrol:hide",ct.MEDIACONTROL_MOUSEMOVE_SEEKBAR="mediacontrol:mousemove:seekbar",ct.MEDIACONTROL_MOUSELEAVE_SEEKBAR="mediacontrol:mouseleave:seekbar",ct.MEDIACONTROL_PLAYING="mediacontrol:playing",ct.MEDIACONTROL_NOTPLAYING="mediacontrol:notplaying",ct.MEDIACONTROL_CONTAINERCHANGED="mediacontrol:containerchanged",ct.MEDIACONTROL_OPTIONS_CHANGE="mediacontrol:options:change";var ht=function(t){function e(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return c(this,e),(t=n(this,e,[i]))._options=i,t.uniqueId=Y("o"),t}return f(e,t),u(e,[{key:"options",get:function(){return this._options}}])}(ct),ut={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},dt=/(.)^/,ft={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},gt=/\\|'|\r|\n|\t|\u2028|\u2029/g,pt={"&":"&","<":"<",">":">",'"':""","'":"'"},mt=new RegExp("[&<>\"']","g"),vt=function(t){return null===t?"":(""+t).replace(mt,(function(t){return pt[t]}))},yt=0,At=function(t,e){var i,n=new RegExp([(ut.escape||dt).source,(ut.interpolate||dt).source,(ut.evaluate||dt).source].join("|")+"|$","g"),r=0,s="__p+='";t.replace(n,(function(e,i,n,a,o){return s+=t.slice(r,o).replace(gt,(function(t){return"\\"+ft[t]})),i&&(s+="'+\n((__t=("+i+"))==null?'':escapeExpr(__t))+\n'"),n&&(s+="'+\n((__t=("+n+"))==null?'':__t)+\n'"),a&&(s+="';\n"+a+"\n__p+='"),r=o+e.length,e})),s+="';\n",ut.variable||(s="with(obj||{}){\n"+s+"}\n"),s="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+s+"return __p;\n//# sourceURL=/microtemplates/source["+yt+++"]";try{i=new Function(ut.variable||"obj","escapeExpr",s)}catch(t){throw t.source=s,t}if(e)return i(e,vt);var a=function(t){return i.call(this,t,vt)};return a.source="function("+(ut.variable||"obj")+"){\n"+s+"}",a};At.settings=ut;var Et={getStyleFor:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:""};return S('<style class="clappr-style"></style>').html(At(t.toString())(e))}},Tt=/^(\S+)\s*(.*)$/,bt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t])).cid=Y("c"),i._ensureElement(),i.delegateEvents(),i}return f(e,t),u(e,[{key:"tagName",get:function(){return"div"}},{key:"events",get:function(){return{}}},{key:"attributes",get:function(){return{}}},{key:"$",value:function(t){return this.$el.find(t)}},{key:"render",value:function(){return this}},{key:"destroy",value:function(){return this.$el.remove(),this.stopListening(),this.undelegateEvents(),this}},{key:"setElement",value:function(t,e){return this.$el&&this.undelegateEvents(),this.$el=S.zepto.isZ(t)?t:S(t),this.el=this.$el[0],!1!==e&&this.delegateEvents(),this}},{key:"delegateEvents",value:function(t){for(var e in t||(t=this.events),this.undelegateEvents(),t){var i=t[e];if(i&&i.constructor!==Function&&(i=this[t[e]]),i){var n=e.match(Tt),r=n[1],s=n[2];r+=".delegateEvents"+this.cid,""===s?this.$el.on(r,i.bind(this)):this.$el.on(r,s,i.bind(this))}}return this}},{key:"undelegateEvents",value:function(){return this.$el.off(".delegateEvents"+this.cid),this}},{key:"_ensureElement",value:function(){if(this.el)this.setElement(this.el,!1);else{var t=S.extend(!0,{},this.attributes);this.id&&(t.id=this.id),this.className&&(t.class=this.className);var e=S(X.create(this.tagName)).attr(t);this.setElement(e,!1)}}},{key:"onResize",value:function(){return this}},{key:"resize",value:function(t){var e=j(t.width)?"".concat(t.width,"px"):"".concat(t.width),i=j(t.height)?"".concat(t.height,"px"):"".concat(t.height);return this.el.style.width=e,this.el.style.height=i,this.onResize(t),this}}])}(ht),kt=function(t){function e(){var t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return c(this,e),(t=n(this,e,[i])).core=r,t}return f(e,t),u(e,[{key:"name",get:function(){return"error"}},{key:"createError",value:function(t){this.core?this.core.trigger(ct.ERROR,t):rt.warn(this.name,"Core is not set. Error: ",t)}}],[{key:"Levels",get:function(){return{FATAL:"FATAL",WARN:"WARN",INFO:"INFO"}}}])}(ht),St={createError:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{useCodePrefix:!0},i=this.constructor&&this.constructor.type||"",n=this.name||i,r=this.i18n||this.core&&this.core.i18n||this.container&&this.container.i18n,s="".concat(n,":").concat(t&&t.code||"unknown"),a={description:"",level:kt.Levels.FATAL,origin:n,scope:i,raw:{}},o=Object.assign({},a,t,{code:e.useCodePrefix?s:t.code});if(r&&o.level==kt.Levels.FATAL&&!o.UI){var l={title:r.t("default_error_title"),message:r.t("default_error_message")};o.UI=l}return this.playerError?this.playerError.createError(o):rt.warn(n,"PlayerError is not defined. Error: ",o),o}},_t=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t.options])).core=t,i.enabled=!0,i.bindEvents(),i.render(),i}return f(e,t),u(e,[{key:"playerError",get:function(){return this.core.playerError}},{key:"bindEvents",value:function(){}},{key:"getExternalInterface",value:function(){return{}}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.$el.show(),this.enabled=!0)}},{key:"disable",value:function(){this.stopListening(),this.$el.hide(),this.enabled=!1}},{key:"render",value:function(){return this}}])}(bt);Object.assign(_t.prototype,St),_t.extend=function(t){return $(_t,t)},_t.type="core";var Lt=function(t){function e(t,i,r){var s;return c(this,e),(s=n(this,e,[t]))._i18n=i,s.currentTime=0,s.volume=100,s.playback=t.playback,s.playerError=r,s.settings=S.extend(!0,{},s.playback.settings),s.isReady=!1,s.mediaControlDisabled=!1,s.plugins=[s.playback],s.dblTapHandler=new Q(500),s.clickTimer=null,s.clickDelay=200,s.actionsMetadata={},s.bindEvents(),s}return f(e,t),u(e,[{key:"name",get:function(){return"Container"}},{key:"attributes",get:function(){return{class:"container","data-container":""}}},{key:"events",get:function(){return{click:"clicked",dblclick:"dblClicked",touchend:"dblTap",contextmenu:"onContextMenu",mouseenter:"mouseEnter",mouseleave:"mouseLeave",mouseup:"onMouseUp",mousedown:"onMouseDown"}}},{key:"ended",get:function(){return this.playback.ended}},{key:"buffering",get:function(){return this.playback.buffering}},{key:"i18n",get:function(){return this._i18n}},{key:"hasClosedCaptionsTracks",get:function(){return this.playback.hasClosedCaptionsTracks}},{key:"closedCaptionsTracks",get:function(){return this.playback.closedCaptionsTracks}},{key:"closedCaptionsTrackId",get:function(){return this.playback.closedCaptionsTrackId},set:function(t){this.playback.closedCaptionsTrackId=t}},{key:"audioTracks",get:function(){return this.playback.audioTracks}},{key:"currentAudioTrack",get:function(){return this.playback.currentAudioTrack}},{key:"isPiPActive",get:function(){return this.playback.isPiPActive}},{key:"bindEvents",value:function(){this.listenTo(this.playback,ct.PLAYBACK_PROGRESS,this.onProgress),this.listenTo(this.playback,ct.PLAYBACK_TIMEUPDATE,this.timeUpdated),this.listenTo(this.playback,ct.PLAYBACK_READY,this.ready),this.listenTo(this.playback,ct.PLAYBACK_BUFFERING,this.onBuffering),this.listenTo(this.playback,ct.PLAYBACK_BUFFERFULL,this.bufferfull),this.listenTo(this.playback,ct.PLAYBACK_SETTINGSUPDATE,this.settingsUpdate),this.listenTo(this.playback,ct.PLAYBACK_LOADEDMETADATA,this.loadedMetadata),this.listenTo(this.playback,ct.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinitionUpdate),this.listenTo(this.playback,ct.PLAYBACK_BITRATE,this.updateBitrate),this.listenTo(this.playback,ct.PLAYBACK_PLAYBACKSTATE,this.playbackStateChanged),this.listenTo(this.playback,ct.PLAYBACK_DVR,this.playbackDvrStateChanged),this.listenTo(this.playback,ct.PLAYBACK_MEDIACONTROL_DISABLE,this.disableMediaControl),this.listenTo(this.playback,ct.PLAYBACK_MEDIACONTROL_ENABLE,this.enableMediaControl),this.listenTo(this.playback,ct.PLAYBACK_SEEK,this.onSeek),this.listenTo(this.playback,ct.PLAYBACK_SEEKED,this.onSeeked),this.listenTo(this.playback,ct.PLAYBACK_ENDED,this.onEnded),this.listenTo(this.playback,ct.PLAYBACK_PLAY,this.playing),this.listenTo(this.playback,ct.PLAYBACK_PAUSE,this.paused),this.listenTo(this.playback,ct.PLAYBACK_STOP,this.stopped),this.listenTo(this.playback,ct.PLAYBACK_ERROR,this.error),this.listenTo(this.playback,ct.PLAYBACK_SUBTITLE_AVAILABLE,this.subtitleAvailable),this.listenTo(this.playback,ct.PLAYBACK_SUBTITLE_CHANGED,this.subtitleChanged),this.listenTo(this.playback,ct.PLAYBACK_AUDIO_AVAILABLE,this.audioAvailable),this.listenTo(this.playback,ct.PLAYBACK_AUDIO_CHANGED,this.audioChanged),this.listenTo(this.playback,ct.PLAYBACK_PIP_ENTER,this.onEnterPiP),this.listenTo(this.playback,ct.PLAYBACK_PIP_EXIT,this.onExitPiP)}},{key:"subtitleAvailable",value:function(){this.trigger(ct.CONTAINER_SUBTITLE_AVAILABLE)}},{key:"subtitleChanged",value:function(t){this.trigger(ct.CONTAINER_SUBTITLE_CHANGED,t)}},{key:"audioAvailable",value:function(t){this.trigger(ct.CONTAINER_AUDIO_AVAILABLE,t)}},{key:"audioChanged",value:function(t){this.trigger(ct.CONTAINER_AUDIO_CHANGED,t)}},{key:"playbackStateChanged",value:function(t){this.trigger(ct.CONTAINER_PLAYBACKSTATE,t)}},{key:"playbackDvrStateChanged",value:function(t){this.settings=this.playback.settings,this.dvrInUse=t,this.trigger(ct.CONTAINER_PLAYBACKDVRSTATECHANGED,t)}},{key:"updateBitrate",value:function(t){this.trigger(ct.CONTAINER_BITRATE,t)}},{key:"statsReport",value:function(t){this.trigger(ct.CONTAINER_STATS_REPORT,t)}},{key:"getPlaybackType",value:function(){return this.playback.getPlaybackType()}},{key:"isDvrEnabled",value:function(){return!!this.playback.dvrEnabled}},{key:"isDvrInUse",value:function(){return!!this.dvrInUse}},{key:"destroy",value:function(){this.disableResizeObserver(),this.trigger(ct.CONTAINER_DESTROYED,this,this.name),this.stopListening(),this.plugins.forEach((function(t){return t.destroy()})),this.$el.remove(),this.undelegateEvents()}},{key:"setStyle",value:function(t){this.$el.css(t)}},{key:"ready",value:function(){this.isReady=!0,this.trigger(ct.CONTAINER_READY,this.name)}},{key:"isPlaying",value:function(){return this.playback.isPlaying()}},{key:"getStartTimeOffset",value:function(){return this.playback.getStartTimeOffset()}},{key:"getCurrentTime",value:function(){return this.currentTime}},{key:"getDuration",value:function(){return this.playback.getDuration()}},{key:"error",value:function(t){this.isReady||this.ready(),this.trigger(ct.CONTAINER_ERROR,t,this.name)}},{key:"loadedMetadata",value:function(t){this.trigger(ct.CONTAINER_LOADEDMETADATA,t)}},{key:"timeUpdated",value:function(t){this.currentTime=t.current,this.trigger(ct.CONTAINER_TIMEUPDATE,t,this.name)}},{key:"onProgress",value:function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.trigger.apply(this,[ct.CONTAINER_PROGRESS].concat(e,[this.name]))}},{key:"playing",value:function(){this.trigger(ct.CONTAINER_PLAY,this.name,this.actionsMetadata.playEvent||{}),this.actionsMetadata.playEvent={}}},{key:"paused",value:function(){this.trigger(ct.CONTAINER_PAUSE,this.name,this.actionsMetadata.pauseEvent||{}),this.actionsMetadata.pauseEvent={}}},{key:"stopped",value:function(){this.trigger(ct.CONTAINER_STOP,this.actionsMetadata.stopEvent||{}),this.actionsMetadata.stopEvent={}}},{key:"play",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.playEvent=t,this.playback.play(t)}},{key:"stop",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.stopEvent=t,this.playback.stop(t),this.currentTime=0}},{key:"switchAudioTrack",value:function(t){this.playback.switchAudioTrack(t)}},{key:"pause",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.pauseEvent=t,this.playback.pause(t)}},{key:"onEnded",value:function(){this.trigger(ct.CONTAINER_ENDED,this,this.name),this.currentTime=0}},{key:"clicked",value:function(){var t=this;this.options.chromeless&&!this.options.allowUserInteraction||(this.clickTimer=setTimeout((function(){t.clickTimer&&t.trigger(ct.CONTAINER_CLICK,t,t.name)}),this.clickDelay))}},{key:"cancelClicked",value:function(){clearTimeout(this.clickTimer),this.clickTimer=null}},{key:"dblClicked",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||(this.cancelClicked(),this.trigger(ct.CONTAINER_DBLCLICK,this,this.name))}},{key:"dblTap",value:function(t){var e=this;this.options.chromeless&&!this.options.allowUserInteraction||this.dblTapHandler.handle(t,(function(){e.cancelClicked(),e.trigger(ct.CONTAINER_DBLCLICK,e,e.name)}))}},{key:"onContextMenu",value:function(t){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ct.CONTAINER_CONTEXTMENU,t,this.name)}},{key:"seek",value:function(t){this.playback.seek(t)}},{key:"onSeek",value:function(t){this.trigger(ct.CONTAINER_SEEK,t,this.name)}},{key:"onSeeked",value:function(){this.trigger(ct.CONTAINER_SEEKED,this.name)}},{key:"seekPercentage",value:function(t){var e=this.getDuration();if(t>=0&&t<=100){var i=e*(t/100);this.seek(i)}}},{key:"setVolume",value:function(t){this.volume=parseFloat(t),this.trigger(ct.CONTAINER_VOLUME,this.volume,this.name),this.playback.volume(this.volume)}},{key:"fullscreen",value:function(){this.trigger(ct.CONTAINER_FULLSCREEN,this.name)}},{key:"onBuffering",value:function(){this.trigger(ct.CONTAINER_STATE_BUFFERING,this.name)}},{key:"bufferfull",value:function(){this.trigger(ct.CONTAINER_STATE_BUFFERFULL,this.name)}},{key:"onEnterPiP",value:function(){this.trigger(ct.CONTAINER_PIP_ENTER,this.name)}},{key:"onExitPiP",value:function(){this.trigger(ct.CONTAINER_PIP_EXIT,this.name)}},{key:"addPlugin",value:function(t){this.plugins.push(t)}},{key:"hasPlugin",value:function(t){return!!this.getPlugin(t)}},{key:"getPlugin",value:function(t){return this.plugins.filter((function(e){return e.name===t}))[0]}},{key:"mouseEnter",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ct.CONTAINER_MOUSE_ENTER)}},{key:"mouseLeave",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ct.CONTAINER_MOUSE_LEAVE)}},{key:"mouseUp",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ct.CONTAINER_MOUSE_UP)}},{key:"mouseDown",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ct.CONTAINER_MOUSE_DOWN)}},{key:"enterPiP",value:function(){this.playback.enterPiP()}},{key:"exitPiP",value:function(){this.playback.exitPiP()}},{key:"settingsUpdate",value:function(){this.settings=this.playback.settings,this.trigger(ct.CONTAINER_SETTINGSUPDATE)}},{key:"highDefinitionUpdate",value:function(t){this.trigger(ct.CONTAINER_HIGHDEFINITIONUPDATE,t)}},{key:"isHighDefinitionInUse",value:function(){return this.playback.isHighDefinitionInUse()}},{key:"disableMediaControl",value:function(){this.mediaControlDisabled||(this.mediaControlDisabled=!0,this.trigger(ct.CONTAINER_MEDIACONTROL_DISABLE))}},{key:"enableMediaControl",value:function(){this.mediaControlDisabled&&(this.mediaControlDisabled=!1,this.trigger(ct.CONTAINER_MEDIACONTROL_ENABLE))}},{key:"updateStyle",value:function(){!this.options.chromeless||this.options.allowUserInteraction?this.$el.removeClass("chromeless"):this.$el.addClass("chromeless")}},{key:"enableResizeObserver",value:function(){var t=this;this.disableResizeObserver(),this.resizeObserverInterval=setInterval((function(){return t.checkResize()}),500)}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval)}},{key:"checkResize",value:function(){var t={width:this.el.clientWidth,height:this.el.clientHeight},e=this.currentSize||{},i=e.width;(e.height!==t.height||i!==t.width)&&(this.currentSize=t,this.trigger(ct.CONTAINER_RESIZE,t))}},{key:"onResize",value:function(t){return this.playback.resize(t),this}},{key:"configure",value:function(t){this._options=S.extend(!0,this._options,t),this.updateStyle(),this.playback.configure(this.options),this.trigger(ct.CONTAINER_OPTIONS_CHANGE)}},{key:"render",value:function(){var t=Et.getStyleFor(".container[data-container] {\n position: absolute;\n background-color: black;\n height: 100%;\n width: 100%;\n max-width: 100%; }\n .container[data-container] .chromeless {\n cursor: default; }\n\n[data-player]:not(.nocursor) .container[data-container]:not(.chromeless).pointer-enabled {\n cursor: pointer; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(t[0]),this.$el.append(this.playback.render().el),this.updateStyle(),this.checkResize(),this.enableResizeObserver(),this}}])}(bt);Object.assign(Lt.prototype,St);var Rt=function(t){function e(t,i,r){var s;return c(this,e),(s=n(this,e,[t])).settings={},s._i18n=i,s.playerError=r,s._consented=!1,s}return f(e,t),u(e,[{key:"isAudioOnly",get:function(){return!1}},{key:"isAdaptive",get:function(){return!1}},{key:"ended",get:function(){return!1}},{key:"i18n",get:function(){return this._i18n}},{key:"buffering",get:function(){return!1}},{key:"latency",get:function(){return null}},{key:"currentProgramDateTime",get:function(){return null}},{key:"isPiPActive",get:function(){return!1}},{key:"consent",value:function(t){"function"==typeof t&&t()}},{key:"play",value:function(){}},{key:"pause",value:function(){}},{key:"stop",value:function(){}},{key:"enterPiP",value:function(){}},{key:"exitPiP",value:function(){}},{key:"seek",value:function(t){}},{key:"seekPercentage",value:function(t){}},{key:"getStartTimeOffset",value:function(){return 0}},{key:"getDuration",value:function(){return 0}},{key:"isPlaying",value:function(){return!1}},{key:"isReady",get:function(){return!1}},{key:"hasClosedCaptionsTracks",get:function(){return this.closedCaptionsTracks.length>0}},{key:"closedCaptionsTracks",get:function(){return[]}},{key:"closedCaptionsTrackId",get:function(){return-1},set:function(t){}},{key:"audioTracks",get:function(){return[]}},{key:"currentAudioTrack",get:function(){return null}},{key:"switchAudioTrack",value:function(t){}},{key:"getPlaybackType",value:function(){return e.NO_OP}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"mute",value:function(){}},{key:"unmute",value:function(){}},{key:"volume",value:function(t){}},{key:"configure",value:function(t){this._options=S.extend(!0,this._options,t)}},{key:"attemptAutoPlay",value:function(){var t=this;this.canAutoPlay((function(e,i){e&&t.play()}))}},{key:"canAutoPlay",value:function(t){t(!0,null)}},{key:"onResize",value:function(t){return this.trigger(ct.PLAYBACK_RESIZE,t),this}}])}(bt);Object.assign(Rt.prototype,St),Rt.extend=function(t){return $(Rt,t)},Rt.canPlay=function(t,e){return!1},Rt.VOD="vod",Rt.AOD="aod",Rt.LIVE="live",Rt.NO_OP="no_op",Rt.type="playback";var Ct=function(t){function e(t,i,r,s){var a;return c(this,e),(a=n(this,e,[t]))._i18n=r,a.loader=i,a.playerError=s,a}return f(e,t),u(e,[{key:"options",get:function(){return this._options},set:function(t){this._options=t}},{key:"createContainers",value:function(){var t=this;return S.Deferred((function(e){e.resolve(t.options.sources.map((function(e){return t.createContainer(e)})))}))}},{key:"findPlaybackPlugin",value:function(t,e){return this.loader.playbackPlugins.filter((function(i){return i.canPlay(t,e)}))[0]}},{key:"createContainer",value:function(t){var e=null,i=this.options.mimeType;"object"===l(t)?(e=t.source.toString(),t.mimeType&&(i=t.mimeType)):e=t.toString(),e.match(/^\/\//)&&(e=window.location.protocol+e);var n=a(a({},this.options),{},{src:e,mimeType:i}),r=this.findPlaybackPlugin(e,i),s=r?new r(n,this._i18n,this.playerError):new Rt;n=a(a({},n),{},{playback:s});var o=new Lt(n,this._i18n,this.playerError),c=S.Deferred();return c.promise(o),this.addContainerPlugins(o),this.listenToOnce(o,ct.CONTAINER_READY,(function(){return c.resolve(o)})),o}},{key:"addContainerPlugins",value:function(t){this.loader.containerPlugins.forEach((function(e){t.addPlugin(new e(t))}))}}])}(ht),wt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t])).playerError=new kt(t,i),i.configureDomRecycler(),i.firstResize=!0,i.styleRendered=!1,i.plugins=[],i.containers=[],i._boundFullscreenHandler=function(){return i.handleFullscreenChange()},i._boundHandleWindowResize=function(t){return i.handleWindowResize(t)},S(document).bind("fullscreenchange",i._boundFullscreenHandler),S(document).bind("MSFullscreenChange",i._boundFullscreenHandler),S(document).bind("mozfullscreenchange",i._boundFullscreenHandler),D.isMobile&&S(window).bind("resize",i._boundHandleWindowResize),i}return f(e,t),u(e,[{key:"events",get:function(){return{webkitfullscreenchange:"handleFullscreenChange",mousemove:"onMouseMove",mouseleave:"onMouseLeave"}}},{key:"attributes",get:function(){return{"data-player":"",tabindex:9999}}},{key:"isReady",get:function(){return!!this.ready}},{key:"i18n",get:function(){return this.getPlugin("strings")||{t:function(t){return t}}}},{key:"mediaControl",get:function(){return this._mediaControl||(this._mediaControl=this.getPlugin("media_control"))||this.dummyMediaControl}},{key:"dummyMediaControl",get:function(){return this._dummyMediaControl||(this._dummyMediaControl=new _t(this)),this._dummyMediaControl}},{key:"activeContainer",get:function(){return this._activeContainer},set:function(t){this._activeContainer=t,this.trigger(ct.CORE_ACTIVE_CONTAINER_CHANGED,this._activeContainer)}},{key:"activePlayback",get:function(){return this.activeContainer&&this.activeContainer.playback}},{key:"activePlaybackEl",get:function(){if(this.activePlayback)return this.activePlayback.$el?this.activePlayback.$el.find("video")[0]:this.activePlayback.el}},{key:"configureDomRecycler",value:function(){var t=this.options&&this.options.playback&&this.options.playback.recycleVideo;X.configure({recycleVideo:t})}},{key:"createContainers",value:function(t){this.defer=S.Deferred(),this.defer.promise(this),this.containerFactory=new Ct(t,t.loader,this.i18n,this.playerError),this.prepareContainers()}},{key:"prepareContainers",value:function(){var t=this;this.containerFactory.createContainers().then((function(e){return t.setupContainers(e)})).then((function(e){return t.resolveOnContainersReady(e)}))}},{key:"updateSize",value:function(){this.isFullscreen()?this.setFullscreen():this.setPlayerSize()}},{key:"setFullscreen",value:function(){D.isiOS||(this.$el.addClass("fullscreen"),this.$el.removeAttr("style"),this.previousSize={width:this.options.width,height:this.options.height},this.currentSize={width:S(window).width(),height:S(window).height()})}},{key:"setPlayerSize",value:function(){this.$el.removeClass("fullscreen"),this.currentSize=this.previousSize,this.previousSize={width:S(window).width(),height:S(window).height()},this.resize(this.currentSize)}},{key:"onResize",value:function(t){return this.previousSize={width:this.options.width,height:this.options.height},this.options.width=t.width,this.options.height=t.height,this.currentSize=t,this.triggerResize(this.currentSize),this}},{key:"enableResizeObserver",value:function(){var t=this;this.disableResizeObserver();this.resizeObserverInterval=setInterval((function(){t.triggerResize({width:t.el.clientWidth,height:t.el.clientHeight})}),500)}},{key:"triggerResize",value:function(t){(this.firstResize||this.oldHeight!==t.height||this.oldWidth!==t.width)&&(this.oldHeight=t.height,this.oldWidth=t.width,this.computedSize=t,this.firstResize=!1,this.trigger(ct.CORE_RESIZE,t))}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval),this.resizeObserverInterval=null}},{key:"resolveOnContainersReady",value:function(t){var e=this;S.when.apply(S,t).done((function(){e.defer.resolve(e),e.ready=!0,e.trigger(ct.CORE_READY)}))}},{key:"addPlugin",value:function(t){this.plugins.push(t)}},{key:"hasPlugin",value:function(t){return!!this.getPlugin(t)}},{key:"getPlugin",value:function(t){return this.plugins.filter((function(e){return e.name===t}))[0]}},{key:"load",value:function(t,e){this.options.mimeType=e,t=t&&t.constructor===Array?t:[t],this.options.sources=t,this.containers.forEach((function(t){return t.destroy()})),this.containerFactory.options=S.extend(!0,this.options,{sources:t}),this.prepareContainers()}},{key:"destroy",value:function(){this.disableResizeObserver(),this.containers.forEach((function(t){return t.destroy()})),this.plugins.forEach((function(t){return t.destroy()})),this.$el.remove(),S(document).unbind("fullscreenchange",this._boundFullscreenHandler),S(document).unbind("MSFullscreenChange",this._boundFullscreenHandler),S(document).unbind("mozfullscreenchange",this._boundFullscreenHandler),D.isMobile&&S(window).unbind("resize",this._boundHandleWindowResize),this.stopListening(),this.undelegateEvents()}},{key:"handleFullscreenChange",value:function(){this.trigger(ct.CORE_FULLSCREEN,this.isFullscreen()),this.updateSize()}},{key:"handleWindowResize",value:function(t){var e=window.innerWidth>window.innerHeight?"landscape":"portrait";this._screenOrientation!==e&&(this._screenOrientation=e,this.triggerResize({width:this.el.clientWidth,height:this.el.clientHeight}),this.trigger(ct.CORE_SCREEN_ORIENTATION_CHANGED,{event:t,orientation:this._screenOrientation}))}},{key:"removeContainer",value:function(t){this.stopListening(t),this.containerFactory.stopListening(t),this.containers=this.containers.filter((function(e){return e!==t}))}},{key:"setupContainer",value:function(t){this.listenTo(t,ct.CONTAINER_DESTROYED,this.removeContainer),this.containers.push(t)}},{key:"setupContainers",value:function(t){return t.forEach(this.setupContainer.bind(this)),this.trigger(ct.CORE_CONTAINERS_CREATED),this.renderContainers(),this.activeContainer=t[0],this.render(),this.appendToParent(),this.containers}},{key:"renderContainers",value:function(){var t=this;this.containers.forEach((function(e){return t.el.appendChild(e.render().el)}))}},{key:"createContainer",value:function(t,e){var i=this.containerFactory.createContainer(t,e);return this.setupContainer(i),this.el.appendChild(i.render().el),i}},{key:"getCurrentContainer",value:function(){return this.activeContainer}},{key:"getCurrentPlayback",value:function(){return this.activePlayback}},{key:"getPlaybackType",value:function(){return this.activeContainer&&this.activeContainer.getPlaybackType()}},{key:"isFullscreen",value:function(){var t=G.fullscreenElement();return t&&t===this.el||t&&t===this.activePlaybackEl||this.activePlaybackEl&&this.activePlaybackEl.webkitDisplayingFullscreen||!1}},{key:"toggleFullscreen",value:function(){var t=this;if(this.isFullscreen()){var e=D.isiOS?this.activePlaybackEl:document;G.cancelFullscreen(e),!D.isiOS&&this.$el.removeClass("fullscreen nocursor")}else{var i=D.isiOS?this.activePlaybackEl:this.el;if(!i)return;D.isSafari||D.isiOS?G.requestFullscreen(i):G.requestFullscreen(i).then((function(t){return t}),(function(e){return setTimeout((function(){if(!t.isFullscreen())throw new ReferenceError(e)}),600)})),!D.isiOS&&this.$el.addClass("fullscreen")}}},{key:"onMouseMove",value:function(t){this.trigger(ct.CORE_MOUSE_MOVE,t)}},{key:"onMouseLeave",value:function(t){this.trigger(ct.CORE_MOUSE_LEAVE,t)}},{key:"configure",value:function(t){var e=this;this._options=S.extend(!0,this._options,t),this.configureDomRecycler();var i=t.source||t.sources;i&&this.load(i,t.mimeType||this.options.mimeType),this.trigger(ct.CORE_OPTIONS_CHANGE,t),this.containers.forEach((function(t){return t.configure(e.options)}))}},{key:"appendToParent",value:function(){!(this.$el.parent()&&this.$el.parent().length)&&this.$el.appendTo(this.options.parentElement)}},{key:"appendStyles",value:function(){if(!this.styleRendered){var t=Et.getStyleFor('[data-player] {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -o-user-select: none;\n user-select: none;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n transform: translate3d(0, 0, 0);\n position: relative;\n margin: 0;\n padding: 0;\n border: 0;\n font-style: normal;\n font-weight: normal;\n text-align: center;\n overflow: hidden;\n font-size: 100%;\n font-family: "Roboto", "Open Sans", Arial, sans-serif;\n text-shadow: 0 0 0;\n box-sizing: border-box; }\n [data-player]:focus {\n outline: 0; }\n [data-player] * {\n box-sizing: inherit; }\n [data-player] > * {\n float: none;\n max-width: none; }\n [data-player] > div {\n display: block; }\n [data-player].fullscreen {\n width: 100% !important;\n height: 100% !important;\n top: 0;\n left: 0; }\n [data-player].nocursor {\n cursor: none; }\n\n.clappr-style {\n display: none !important; }\n'.toString(),{baseUrl:this.options.baseUrl});if(this.$el.append(t[0]),this.options.includeResetStyle){var e=Et.getStyleFor('[data-player] div, [data-player] span, [data-player] applet, [data-player] object, [data-player] iframe,\n[data-player] h1, [data-player] h2, [data-player] h3, [data-player] h4, [data-player] h5, [data-player] h6, [data-player] p, [data-player] blockquote, [data-player] pre,\n[data-player] a, [data-player] abbr, [data-player] acronym, [data-player] address, [data-player] big, [data-player] cite, [data-player] code,\n[data-player] del, [data-player] dfn, [data-player] em, [data-player] img, [data-player] ins, [data-player] kbd, [data-player] q, [data-player] s, [data-player] samp,\n[data-player] small, [data-player] strike, [data-player] strong, [data-player] sub, [data-player] sup, [data-player] tt, [data-player] var,\n[data-player] b, [data-player] u, [data-player] i, [data-player] center,\n[data-player] dl, [data-player] dt, [data-player] dd, [data-player] ol, [data-player] ul, [data-player] li,\n[data-player] fieldset, [data-player] form, [data-player] label, [data-player] legend,\n[data-player] table, [data-player] caption, [data-player] tbody, [data-player] tfoot, [data-player] thead, [data-player] tr, [data-player] th, [data-player] td,\n[data-player] article, [data-player] aside, [data-player] canvas, [data-player] details, [data-player] embed,\n[data-player] figure, [data-player] figcaption, [data-player] footer, [data-player] header, [data-player] hgroup,\n[data-player] menu, [data-player] nav, [data-player] output, [data-player] ruby, [data-player] section, [data-player] summary,\n[data-player] time, [data-player] mark, [data-player] audio, [data-player] video {\n margin: 0;\n padding: 0;\n border: 0;\n font: inherit;\n font-size: 100%;\n vertical-align: baseline; }\n\n[data-player] table {\n border-collapse: collapse;\n border-spacing: 0; }\n\n[data-player] caption, [data-player] th, [data-player] td {\n text-align: left;\n font-weight: normal;\n vertical-align: middle; }\n\n[data-player] q, [data-player] blockquote {\n quotes: none; }\n [data-player] q:before, [data-player] q:after, [data-player] blockquote:before, [data-player] blockquote:after {\n content: "";\n content: none; }\n\n[data-player] a img {\n border: none; }\n'.toString(),{baseUrl:this.options.baseUrl});this.$el.append(e[0])}this.styleRendered=!0}}},{key:"render",value:function(){this.appendStyles(),this.options.width=this.options.width||this.$el.width(),this.options.height=this.options.height||this.$el.height();var t={width:this.options.width,height:this.options.height};return this.previousSize=this.currentSize=this.computedSize=t,this.updateSize(),this.enableResizeObserver(),this}}])}(bt);Object.assign(wt.prototype,St);var It,Dt,Pt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t.options])).player=t,i}return f(e,t),u(e,[{key:"loader",get:function(){return this.player.loader}},{key:"create",value:function(){return this.options.loader=this.loader,this.core=new wt(this.options),this.addCorePlugins(),this.core.createContainers(this.options),this.core}},{key:"addCorePlugins",value:function(){var t=this;return this.loader.corePlugins.forEach((function(e){var i=new e(t.core);t.core.addPlugin(i),t.setupExternalInterface(i)})),this.core}},{key:"setupExternalInterface",value:function(t){var e=t.getExternalInterface();for(var i in e)this.player[i]=e[i].bind(t)}}])}(ht),Ot=/(\d+)(?:\.(\d+))?(?:\.(\d+))?/,xt=function(){function t(e,i,n){c(this,t),this.major=parseInt(e||0,10),this.minor=parseInt(i||0,10),this.patch=parseInt(n||0,10)}return u(t,[{key:"compare",value:function(t){var e=this.major-t.major;return e=(e=e||this.minor-t.minor)||this.patch-t.patch}},{key:"inc",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"patch";return void 0!==this[t]&&(this[t]+=1),this}},{key:"satisfies",value:function(t,e){return this.compare(t)>=0&&(!e||this.compare(e)<0)}},{key:"toString",value:function(){return"".concat(this.major,".").concat(this.minor,".").concat(this.patch)}}],[{key:"parse",value:function(){var e=v((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").match(Ot)||[],4),i=e[1],n=e[2],r=e[3];return void 0===i?null:new t(i,n,r)}}])}(),Nt=function(t,e){return t&&e?Object.entries(t).filter((function(t){return v(t,2)[1].type===e})).reduce((function(t,e){var i=v(e,2),n=i[0],r=i[1];return t[n]=r,t}),{}):{}},Mt=(It={plugins:{},playbacks:[]},Dt="0.11.2",function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;c(this,t),this.playerId=i,this.playbackPlugins=y(It.playbacks);var n=t.registeredPlugins,r=n.core,s=n.container;this.containerPlugins=Object.values(s),this.corePlugins=Object.values(r),Array.isArray(e)||this.validateExternalPluginsType(e),this.addExternalPlugins(e)}return u(t,[{key:"groupPluginsByType",value:function(t){return Array.isArray(t)&&(t=t.reduce((function(t,e){return t[e.type]||(t[e.type]=[]),t[e.type].push(e),t}),{})),t}},{key:"removeDups",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=t.reduceRight((function(t,i){return t[i.prototype.name]&&e||(t[i.prototype.name]&&delete t[i.prototype.name],t[i.prototype.name]=i),t}),Object.create(null)),n=[];for(var r in i)n.unshift(i[r]);return n}},{key:"addExternalPlugins",value:function(e){var i="boolean"!=typeof e.loadExternalPluginsFirst||e.loadExternalPluginsFirst,n="boolean"!=typeof e.loadExternalPlaybacksFirst||e.loadExternalPlaybacksFirst;if((e=this.groupPluginsByType(e)).playback){var r=e.playback.filter((function(e){return t.checkVersionSupport(e),!0}));this.playbackPlugins=n?this.removeDups(r.concat(this.playbackPlugins)):this.removeDups(this.playbackPlugins.concat(r),!0)}if(e.container){var s=e.container.filter((function(e){return t.checkVersionSupport(e),!0}));this.containerPlugins=i?this.removeDups(s.concat(this.containerPlugins)):this.removeDups(this.containerPlugins.concat(s),!0)}if(e.core){var a=e.core.filter((function(e){return t.checkVersionSupport(e),!0}));this.corePlugins=i?this.removeDups(a.concat(this.corePlugins)):this.removeDups(this.corePlugins.concat(a),!0)}}},{key:"validateExternalPluginsType",value:function(t){["playback","container","core"].forEach((function(e){(t[e]||[]).forEach((function(t){var i="external "+t.type+" plugin on "+e+" array";if(t.type!==e)throw new ReferenceError(i)}))}))}}],[{key:"registeredPlaybacks",get:function(){return y(It.playbacks)}},{key:"registeredPlugins",get:function(){var t=It.plugins;return{core:Nt(t,"core"),container:Nt(t,"container")}}},{key:"checkVersionSupport",value:function(t){var e=t.prototype,i=e.supportedVersion,n=e.name;if(!i||!i.min)return rt.warn("Loader","missing version information for ".concat(n)),!1;var r=i.max?xt.parse(i.max):xt.parse(i.min).inc("minor"),s=xt.parse(i.min);return!!xt.parse(Dt).satisfies(s,r)||(rt.warn("Loader","unsupported plugin ".concat(n,": Clappr version ").concat(Dt," does not match required range [").concat(s,",").concat(r,")")),!1)}},{key:"registerPlugin",value:function(e){if(!e||!e.prototype.name)return rt.warn("Loader","missing information to register plugin: ".concat(e)),!1;t.checkVersionSupport(e);var i=It.plugins;if(!i)return!1;var n=i[e.prototype.name];return n&&rt.warn("Loader","overriding plugin entry: ".concat(e.prototype.name," - ").concat(n)),i[e.prototype.name]=e,!0}},{key:"registerPlayback",value:function(e){if(!e||!e.prototype.name)return!1;t.checkVersionSupport(e);var i=It.playbacks,n=i.findIndex((function(t){return t.prototype.name===e.prototype.name}));if(n>=0){var r=i[n];i.splice(n,1),rt.warn("Loader","overriding playback entry: ".concat(r.name," - ").concat(r))}return It.playbacks=[e].concat(y(i)),!0}},{key:"unregisterPlugin",value:function(t){if(!t)return!1;var e=It.plugins;return!!e[t]&&(delete e[t],!0)}},{key:"unregisterPlayback",value:function(t){if(!t)return!1;var e=It.playbacks,i=e.findIndex((function(e){return e.prototype.name===t}));return!(i<0||(e.splice(i,1),It.playbacks=e,0))}},{key:"clearPlugins",value:function(){It.plugins={}}},{key:"clearPlaybacks",value:function(){It.playbacks=[]}}])}()),Ft=W().replace(/\/[^/]+$/,""),Bt=function(t){function e(t){var i;c(this,e),i=n(this,e,[t]);var r={playerId:Y(""),persistConfig:!0,width:640,height:360,baseUrl:Ft,allowUserInteraction:D.isMobile,includeResetStyle:!0,playback:{recycleVideo:!0}};i._options=S.extend(!0,r,t),i.options.sources=i._normalizeSources(t),i.options.chromeless||(i.options.allowUserInteraction=!0),i.options.allowUserInteraction||(i.options.disableKeyboardShortcuts=!0),i._registerOptionEventListeners(i.options.events),i._coreFactory=new Pt(i);var s=i._getParentElement(i.options);return s&&i.attachTo(s),i}return f(e,t),u(e,[{key:"loader",get:function(){return this._loader||(this._loader=new Mt(this.options.plugins||{},this.options.playerId)),this._loader},set:function(t){this._loader=t}},{key:"ended",get:function(){return this.core.activeContainer.ended}},{key:"buffering",get:function(){return this.core.activeContainer.buffering}},{key:"isReady",get:function(){return!!this._ready}},{key:"eventsMapping",get:function(){return{onReady:ct.PLAYER_READY,onResize:ct.PLAYER_RESIZE,onPlay:ct.PLAYER_PLAY,onPause:ct.PLAYER_PAUSE,onStop:ct.PLAYER_STOP,onEnded:ct.PLAYER_ENDED,onSeek:ct.PLAYER_SEEK,onError:ct.PLAYER_ERROR,onTimeUpdate:ct.PLAYER_TIMEUPDATE,onVolumeUpdate:ct.PLAYER_VOLUMEUPDATE,onSubtitleAvailable:ct.PLAYER_SUBTITLE_AVAILABLE}}},{key:"_getParentElement",value:function(t){var e=t.parentId,i=t.parent;return e?document.querySelector(e):i}},{key:"attachTo",value:function(t){return this.options.parentElement=t,this.core=this._coreFactory.create(),this._addEventListeners(),this}},{key:"_addEventListeners",value:function(){return this.core.isReady?this._onReady():this.listenToOnce(this.core,ct.CORE_READY,this._onReady),this.listenTo(this.core,ct.CORE_ACTIVE_CONTAINER_CHANGED,this._containerChanged),this.listenTo(this.core,ct.CORE_FULLSCREEN,this._onFullscreenChange),this.listenTo(this.core,ct.CORE_RESIZE,this._onResize),this}},{key:"_addContainerEventListeners",value:function(){var t=this.core.activeContainer;return t&&(this.listenTo(t,ct.CONTAINER_PLAY,this._onPlay),this.listenTo(t,ct.CONTAINER_PAUSE,this._onPause),this.listenTo(t,ct.CONTAINER_STOP,this._onStop),this.listenTo(t,ct.CONTAINER_ENDED,this._onEnded),this.listenTo(t,ct.CONTAINER_SEEK,this._onSeek),this.listenTo(t,ct.CONTAINER_ERROR,this._onError),this.listenTo(t,ct.CONTAINER_TIMEUPDATE,this._onTimeUpdate),this.listenTo(t,ct.CONTAINER_VOLUME,this._onVolumeUpdate),this.listenTo(t,ct.CONTAINER_SUBTITLE_AVAILABLE,this._onSubtitleAvailable)),this}},{key:"_registerOptionEventListeners",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object.keys(e).length>0&&Object.keys(i).forEach((function(e){var n=t.eventsMapping[e];n&&t.off(n,i[e])})),Object.keys(e).forEach((function(i){var n=t.eventsMapping[i];if(n){var r=e[i];(r="function"==typeof r&&r)&&t.on(n,r)}})),this}},{key:"_containerChanged",value:function(){this.stopListening(),this._addEventListeners()}},{key:"_onReady",value:function(){this._ready=!0,this._addContainerEventListeners(),this.trigger(ct.PLAYER_READY)}},{key:"_onFullscreenChange",value:function(t){this.trigger(ct.PLAYER_FULLSCREEN,t)}},{key:"_onVolumeUpdate",value:function(t){this.trigger(ct.PLAYER_VOLUMEUPDATE,t)}},{key:"_onSubtitleAvailable",value:function(){this.trigger(ct.PLAYER_SUBTITLE_AVAILABLE)}},{key:"_onResize",value:function(t){this.trigger(ct.PLAYER_RESIZE,t)}},{key:"_onPlay",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.trigger(ct.PLAYER_PLAY,e)}},{key:"_onPause",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.trigger(ct.PLAYER_PAUSE,e)}},{key:"_onStop",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.trigger(ct.PLAYER_STOP,this.getCurrentTime(),t)}},{key:"_onEnded",value:function(){this.trigger(ct.PLAYER_ENDED)}},{key:"_onSeek",value:function(t){this.trigger(ct.PLAYER_SEEK,t)}},{key:"_onTimeUpdate",value:function(t){this.trigger(ct.PLAYER_TIMEUPDATE,t)}},{key:"_onError",value:function(t){this.trigger(ct.PLAYER_ERROR,t)}},{key:"_normalizeSources",value:function(t){var e=t.sources||(void 0!==t.source?[t.source]:[]);return 0===e.length?[{source:"",mimeType:""}]:e}},{key:"resize",value:function(t){return this.core.resize(t),this}},{key:"load",value:function(t,e,i){return void 0!==i&&this.configure({autoPlay:!!i}),this.core.load(t,e),this}},{key:"destroy",value:function(){return this.stopListening(),this.core.destroy(),this}},{key:"consent",value:function(t){this.core.getCurrentPlayback().consent(t)}},{key:"play",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.play(t),this}},{key:"pause",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.pause(t),this}},{key:"stop",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.stop(t),this}},{key:"seek",value:function(t){return this.core.activeContainer.seek(t),this}},{key:"seekPercentage",value:function(t){return this.core.activeContainer.seekPercentage(t),this}},{key:"mute",value:function(){return this.core.activePlayback.mute(),this}},{key:"unmute",value:function(){return this.core.activePlayback.unmute(),this}},{key:"isPlaying",value:function(){return this.core.activeContainer.isPlaying()}},{key:"isDvrEnabled",value:function(){return this.core.activeContainer.isDvrEnabled()}},{key:"isDvrInUse",value:function(){return this.core.activeContainer.isDvrInUse()}},{key:"configure",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._registerOptionEventListeners(t.events,this.options.events),this.core.configure(t),this}},{key:"getPlugin",value:function(t){return this.core.plugins.concat(this.core.activeContainer.plugins).filter((function(e){return e.name===t}))[0]}},{key:"getCurrentTime",value:function(){return this.core.activeContainer.getCurrentTime()}},{key:"getStartTimeOffset",value:function(){return this.core.activeContainer.getStartTimeOffset()}},{key:"getDuration",value:function(){return this.core.activeContainer.getDuration()}}])}(ht);Object.assign(Bt.prototype,St);var Ut=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t.options])).container=t,i.enabled=!0,i.bindEvents(),i}return f(e,t),u(e,[{key:"playerError",get:function(){return this.container.playerError}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.stopListening(),this.enabled=!1)}},{key:"bindEvents",value:function(){}},{key:"destroy",value:function(){this.stopListening()}}])}(ht);Object.assign(Ut.prototype,St),Ut.extend=function(t){return $(Ut,t)},Ut.type="container";var $t=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t.options])).core=t,i.enabled=!0,i.bindEvents(),i}return f(e,t),u(e,[{key:"playerError",get:function(){return this.core.playerError}},{key:"bindEvents",value:function(){}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.enabled=!0)}},{key:"disable",value:function(){this.enabled&&(this.stopListening(),this.enabled=!1)}},{key:"getExternalInterface",value:function(){return{}}},{key:"destroy",value:function(){this.stopListening()}}])}(ht);Object.assign($t.prototype,St),$t.extend=function(t){return $($t,t)},$t.type="core";var Gt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t.options])).container=t,i.enabled=!0,i.bindEvents(),i}return f(e,t),u(e,[{key:"playerError",get:function(){return this.container.playerError}},{key:"enable",value:function(){this.enabled||(this.bindEvents(),this.$el.show(),this.enabled=!0)}},{key:"disable",value:function(){this.stopListening(),this.$el.hide(),this.enabled=!1}},{key:"bindEvents",value:function(){}}])}(bt);Object.assign(Gt.prototype,St),Gt.extend=function(t){return $(Gt,t)},Gt.type="container";var Vt={mp4:["avc1.42E01E","avc1.58A01E","avc1.4D401E","avc1.64001E","mp4v.20.8","mp4v.20.240","mp4a.40.2"].map((function(t){return'video/mp4; codecs="'+t+', mp4a.40.2"'})),ogg:['video/ogg; codecs="theora, vorbis"','video/ogg; codecs="dirac"','video/ogg; codecs="theora, speex"'],"3gpp":['video/3gpp; codecs="mp4v.20.8, samr"'],webm:['video/webm; codecs="vp8, vorbis"'],mkv:['video/x-matroska; codecs="theora, vorbis"'],m3u8:["application/x-mpegurl"]};Vt.ogv=Vt.ogg,Vt["3gp"]=Vt["3gpp"];var Kt={wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},Ht=Object.keys(Kt).reduce((function(t,e){return[].concat(y(t),y(Kt[e]))}),[]),Yt={code:"unknown",message:"unknown"},jt=function(t){function e(){var t;c(this,e);for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];(t=n(this,e,[].concat(r)))._destroyed=!1,t._loadStarted=!1,t._isBuffering=!1,t._playheadMoving=!1,t._playheadMovingTimer=null,t._stopped=!1,t._ccTrackId=-1,t._playheadMovingCheckEnabled=!t.options.disablePlayheadMovingCheck,t._setupSrc(t.options.src),t._playheadMovingCheckInterval=t.options.playheadMovingCheckInterval||500,t.options.playback||(t.options.playback=t.options||{}),t.options.playback.disableContextMenu=t.options.playback.disableContextMenu||t.options.disableVideoTagContextMenu,t._minDvrSize=t.isValidMinimumDVRSizeConfig?t.minimumDVRSizeConfig:60;var a,o=t.options.playback,l=o.preload||(D.isSafari?"auto":t.options.preload);return t.options.poster&&("string"==typeof t.options.poster?a=t.options.poster:"string"==typeof t.options.poster.url&&(a=t.options.poster.url)),S.extend(!0,t.el,{muted:t.options.mute,defaultMuted:t.options.mute,loop:t.options.loop,poster:a,preload:l||"metadata",crossOrigin:o.crossOrigin,"x-webkit-playsinline":o.playInline}),(o.controls||t.options.useVideoTagDefaultControls)&&t.$el.attr("controls",""),o.playInline&&t.$el.attr({playsinline:"playsinline"}),o.crossOrigin&&t.$el.attr({crossorigin:o.crossOrigin}),t.settings={default:["seekbar"]},t.settings.left=["playpause","position","duration"],t.settings.right=["fullscreen","volume","hd-indicator"],o.externalTracks&&t._setupExternalTracks(o.externalTracks),t.options.autoPlay&&t.attemptAutoPlay(),t}return f(e,t),u(e,[{key:"name",get:function(){return"html5_video"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"tagName",get:function(){return this.isAudioOnly?"audio":"video"}},{key:"isAudioOnly",get:function(){var t=this.options.src,i=e._mimeTypesForUrl(t,Kt,this.options.mimeType);return this.options.playback&&this.options.playback.audioOnly||this.options.audioOnly||Ht.indexOf(i[0])>=0}},{key:"attributes",get:function(){return{"data-html5-video":""}}},{key:"events",get:function(){return{canplay:"_onCanPlay",canplaythrough:"_handleBufferingEvents",durationchange:"_onDurationChange",ended:"_onEnded",error:"_onError",loadeddata:"_onLoadedData",loadedmetadata:"_onLoadedMetadata",pause:"_onPause",playing:"_onPlaying",progress:"_onProgress",seeking:"_onSeeking",seeked:"_onSeeked",stalled:"_handleBufferingEvents",timeupdate:"_onTimeUpdate",waiting:"_onWaiting",enterpictureinpicture:"_onEnterPiP",leavepictureinpicture:"_onExitPiP"}}},{key:"ended",get:function(){return this.el.ended}},{key:"buffering",get:function(){return this._isBuffering}},{key:"isPiPActive",get:function(){return this.el===document.pictureInPictureElement}},{key:"isLive",get:function(){return this.getPlaybackType()===Rt.LIVE}},{key:"dvrEnabled",get:function(){return this.getDuration()>=this._minDvrSize&&this.isLive}},{key:"minimumDVRSizeConfig",get:function(){return this.options.playback&&this.options.playback.minimumDvrSize}},{key:"isValidMinimumDVRSizeConfig",get:function(){return void 0!==this.minimumDVRSizeConfig&&"number"==typeof this.minimumDVRSizeConfig}},{key:"sourceMedia",get:function(){return this._src}},{key:"configure",value:function(t){m(g(e.prototype),"configure",this).call(this,t),this.el.loop=!!t.loop}},{key:"attemptAutoPlay",value:function(){var t=this;this.canAutoPlay((function(e,i){i&&rt.warn(t.name,"autoplay error.",{result:e,error:i}),e&&setTimeout((function(){return!t._destroyed&&t.play()}),0)}))}},{key:"canAutoPlay",value:function(t){if(this.options.disableCanAutoPlay)t(!0,null);else{var e={timeout:this.options.autoPlayTimeout||500,inline:this.options.playback.playInline||!1,muted:this.options.mute||!1};D.isMobile&&X.options.recycleVideo&&(e.element=this.el),q(t,e)}}},{key:"_setupExternalTracks",value:function(t){this._externalTracks=t.map((function(t){return{kind:t.kind||"subtitles",label:t.label,lang:t.lang,src:t.src}}))}},{key:"load",value:function(t){this._setupSrc(t)}},{key:"_setupSrc",value:function(t){this.el.src!==t&&(this._ccIsSetup=!1,this.el.src=t,this._src=this.el.src)}},{key:"_onLoadedMetadata",value:function(t){this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_LOADEDMETADATA,{duration:t.target.duration,data:t}),this._updateSettings();var e=void 0===this._options.autoSeekFromUrl||this._options.autoSeekFromUrl;this.getPlaybackType()!==Rt.LIVE&&e&&this._checkInitialSeek()}},{key:"_onDurationChange",value:function(){this._updateSettings(),this._onTimeUpdate(),this._onProgress()}},{key:"_updateSettings",value:function(){this.getPlaybackType()===Rt.VOD||this.getPlaybackType()===Rt.AOD?this.settings.left=["playpause","position","duration"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(ct.PLAYBACK_SETTINGSUPDATE)}},{key:"isSeekEnabled",value:function(){return isFinite(this.getDuration())}},{key:"getPlaybackType",value:function(){var t="audio"===this.tagName?Rt.AOD:Rt.VOD;return[0,void 0,1/0].indexOf(this.el.duration)>=0?Rt.LIVE:t}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"consent",value:function(t){var i=this;if(this.isPlaying()||this.el._consented)m(g(e.prototype),"consent",this).call(this,t);else{var n=function n(){i.el.removeEventListener("loadedmetadata",n,!1),i.el.removeEventListener("error",n,!1),i.el._consented=!0,m(g(e.prototype),"consent",i).call(i,t)};this.el.addEventListener("loadedmetadata",n,!1),this.el.addEventListener("error",n,!1),this.el.load()}}},{key:"play",value:function(){var t=this;this.trigger(ct.PLAYBACK_PLAY_INTENT),this._stopped=!1,this._setupSrc(this._src),this._handleBufferingEvents();var e=this.el.play();return e&&e.catch&&e.catch((function(e){return rt.warn(t.name,"HTML5 play failed",e)})),e}},{key:"pause",value:function(){this.el.pause()}},{key:"stop",value:function(){this.pause(),this._stopped=!0,this.el.removeAttribute("src"),this.el.load(),this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_STOP)}},{key:"volume",value:function(t){0===t?(this.$el.attr({muted:"true"}),this.el.muted=!0):(this.$el.attr({muted:null}),this.el.muted=!1,this.el.volume=t/100)}},{key:"mute",value:function(){this.el.muted=!0}},{key:"unmute",value:function(){this.el.muted=!1}},{key:"isMuted",value:function(){return!0===this.el.muted||0===this.el.volume}},{key:"isPlaying",value:function(){return!this.el.paused&&!this.el.ended}},{key:"isReady",get:function(){return this._isReadyState}},{key:"_startPlayheadMovingChecks",value:function(){null===this._playheadMovingTimer&&this._playheadMovingCheckEnabled&&(this._playheadMovingTimeOnCheck=null,this._determineIfPlayheadMoving(),this._playheadMovingTimer=setInterval(this._determineIfPlayheadMoving.bind(this),this._playheadMovingCheckInterval))}},{key:"_stopPlayheadMovingChecks",value:function(){null!==this._playheadMovingTimer&&(clearInterval(this._playheadMovingTimer),this._playheadMovingTimer=null,this._playheadMoving=!1)}},{key:"_determineIfPlayheadMoving",value:function(){var t=this._playheadMovingTimeOnCheck,e=this.el.currentTime;this._playheadMoving=t!==e,this._playheadMovingTimeOnCheck=e,this._handleBufferingEvents()}},{key:"_onWaiting",value:function(){this._loadStarted=!0,this._handleBufferingEvents()}},{key:"_onLoadedData",value:function(){this._loadStarted=!0,this._handleBufferingEvents()}},{key:"_onCanPlay",value:function(){this._handleBufferingEvents()}},{key:"_onPlaying",value:function(){this._checkForClosedCaptions(),this._startPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_PLAY)}},{key:"_onPause",value:function(){this.dvrEnabled&&this._updateDvr(!0),this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_PAUSE)}},{key:"_onSeeking",value:function(){var t=this.getCurrentTime();this.dvrEnabled&&this._updateDvr(t<this.getDuration()-3),this.trigger(ct.PLAYBACK_SEEK,t),this._handleBufferingEvents()}},{key:"_onSeeked",value:function(){this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_SEEKED)}},{key:"_onEnded",value:function(){this._handleBufferingEvents(),this.trigger(ct.PLAYBACK_ENDED,this.name)}},{key:"_onEnterPiP",value:function(){this.trigger(ct.PLAYBACK_PIP_ENTER,this.name)}},{key:"_onExitPiP",value:function(){this.trigger(ct.PLAYBACK_PIP_EXIT,this.name)}},{key:"enterPiP",value:function(){var t=this;this.el.requestPictureInPicture().then((function(){rt.info(t.name,"enter PIP success")})).catch((function(e){rt.warn(t.name,"enter PIP failed",e)}))}},{key:"exitPiP",value:function(){var t=this;document.exitPictureInPicture().then((function(){rt.info(t.name,"exit PIP success")})).catch((function(e){rt.warn(t.name,"exit PIP failed",e)}))}},{key:"_handleBufferingEvents",value:function(){var t=this._loadStarted&&!this.el.ended&&!this._stopped,e=this.el.readyState<this.el.HAVE_FUTURE_DATA,i=!this.el.ended&&!this.el.paused&&!this._playheadMoving,n=t&&e;this._playheadMovingCheckEnabled&&(n=n||t&&i),this._isBuffering!==n&&(this._isBuffering=n,n?this.trigger(ct.PLAYBACK_BUFFERING,this.name):this.trigger(ct.PLAYBACK_BUFFERFULL,this.name))}},{key:"_onError",value:function(){var t=this.el.error||Yt,e=t.code,i=t.message,n=e===Yt.code,r=this.createError({code:e,description:i,raw:this.el.error,level:n?kt.Levels.WARN:kt.Levels.FATAL});n?rt.warn(this.name,"HTML5 unknown error: ",r):this.trigger(ct.PLAYBACK_ERROR,r)}},{key:"destroy",value:function(){this._destroyed=!0,this._stopPlayheadMovingChecks(),this.handleTextTrackChange&&this.el.textTracks.removeEventListener("change",this.handleTextTrackChange),this.$el.off("contextmenu"),m(g(e.prototype),"destroy",this).call(this),this.el.removeAttribute("src"),this.el.load(),this._src=null,X.garbage(this.el)}},{key:"_updateDvr",value:function(t){this.trigger(ct.PLAYBACK_DVR,t),this.trigger(ct.PLAYBACK_STATS_ADD,{dvr:t})}},{key:"seek",value:function(t){t<0&&(rt.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),t=this.getDuration()),t+=this.el.seekable.start(0),this.el.currentTime=t}},{key:"seekPercentage",value:function(t){var e=this.el.duration*(t/100);this.seek(e)}},{key:"_checkInitialSeek",value:function(){var t=H();0!==t&&this.seek(t)}},{key:"getCurrentTime",value:function(){return this.el.currentTime}},{key:"getDuration",value:function(){if(this.isLive){if(this.el.seekable.length>0)return this.el.seekable.end(0)-this.el.seekable.start(0);this._scheduleUpdateSettingsCheck()}return this.el.duration}},{key:"_scheduleUpdateSettingsCheck",value:function(){var t=this;this._updateSettingsCheckInFlight||(this._updateSettingsCheckInFlight=setTimeout((function(){t._updateSettings(),t._updateSettingsCheckInFlight=null}),1e3))}},{key:"_onTimeUpdate",value:function(){var t=this.isLive?this.getDuration():this.el.duration;this.trigger(ct.PLAYBACK_TIMEUPDATE,{current:this.el.currentTime,total:t},this.name)}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var t=[],e=0,i=0;i<this.el.buffered.length;i++)t=[].concat(y(t),[{start:this.el.buffered.start(i),end:this.el.buffered.end(i)}]),this.el.currentTime>=t[i].start&&this.el.currentTime<=t[i].end&&(e=i);var n={start:t[e].start,current:t[e].end,total:this.el.duration};this.trigger(ct.PLAYBACK_PROGRESS,n,t)}}},{key:"_typeFor",value:function(t){var i=e._mimeTypesForUrl(t,Vt,this.options.mimeType);return 0===i.length&&(i=e._mimeTypesForUrl(t,Kt,this.options.mimeType)),(i[0]||"").split(";")[0]}},{key:"_ready",value:function(){this._isReadyState||(this._isReadyState=!0,this.trigger(ct.PLAYBACK_READY,this.name))}},{key:"_checkForClosedCaptions",value:function(){if(this.isHTML5Video&&!this._ccIsSetup){if(this.hasClosedCaptionsTracks){this.trigger(ct.PLAYBACK_SUBTITLE_AVAILABLE);var t=this.closedCaptionsTrackId;this.closedCaptionsTrackId=t,this.handleTextTrackChange=this._handleTextTrackChange.bind(this),this.el.textTracks.addEventListener("change",this.handleTextTrackChange)}this._ccIsSetup=!0}}},{key:"_handleTextTrackChange",value:function(){var t=this.closedCaptionsTracks.find((function(t){return"showing"===t.track.mode}))||{id:-1};this._ccTrackId!==t.id&&(this._ccTrackId=t.id,this.trigger(ct.PLAYBACK_SUBTITLE_CHANGED,{id:t.id}))}},{key:"isHTML5Video",get:function(){return this.name===e.prototype.name}},{key:"closedCaptionsTracks",get:function(){var t=0;return(this.el.textTracks?Array.from(this.el.textTracks):[]).filter((function(t){return"subtitles"===t.kind||"captions"===t.kind})).map((function(e){return{id:t++,name:e.label,track:e}}))}},{key:"closedCaptionsTrackId",get:function(){return this._ccTrackId},set:function(t){if(j(t)){var e,i=this.closedCaptionsTracks;if(-1!==t){if(!(e=i.find((function(e){return e.id===t}))))return;if("showing"===e.track.mode)return}i.filter((function(t){return"hidden"!==t.track.mode})).forEach((function(t){return t.track.mode="hidden"})),e&&(e.track.mode="showing"),this._ccTrackId=t,this.trigger(ct.PLAYBACK_SUBTITLE_CHANGED,{id:t})}}},{key:"template",get:function(){return At('<% for (var i = 0; i < tracks.length; i++) { %>\n <track data-html5-video-track="<%= i %>" kind="<%= tracks[i].kind %>" label="<%= tracks[i].label %>" srclang="<%= tracks[i].lang %>" src="<%= tracks[i].src %>">\n<% }; %>\n')}},{key:"render",value:function(){this.options.playback.disableContextMenu&&this.$el.on("contextmenu",(function(){return!1})),this._externalTracks&&this._externalTracks.length>0&&this.$el.html(this.template({tracks:this._externalTracks})),this._ready();var t=Et.getStyleFor("[data-html5-video] {\n position: absolute;\n height: 100%;\n width: 100%;\n display: block; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(t[0]),this}}])}(Rt);jt._mimeTypesForUrl=function(){var t=arguments.length>1?arguments[1]:void 0,e=arguments.length>2?arguments[2]:void 0,i=((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").split("?")[0].match(/.*\.(.*)$/)||[])[1],n=e||i&&t[i.toLowerCase()]||[];return n.constructor===Array?n:[n]},jt._canPlay=function(t,e,i,n){var r=jt._mimeTypesForUrl(i,e,n),s=document.createElement(t);return!!r.filter((function(t){return!!s.canPlayType(t).replace(/no/,"")}))[0]},jt.canPlay=function(t,e){return jt._canPlay("audio",Kt,t,e)||jt._canPlay("video",Vt,t,e)};var Wt=function(t){function e(){return c(this,e),n(this,e,arguments)}return f(e,t),u(e,[{key:"name",get:function(){return"html5_audio"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"tagName",get:function(){return"audio"}},{key:"isAudioOnly",get:function(){return!0}},{key:"updateSettings",value:function(){this.settings.left=["playpause","position","duration"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(ct.PLAYBACK_SETTINGSUPDATE)}},{key:"getPlaybackType",value:function(){return Rt.AOD}}])}(jt);Wt.canPlay=function(t,e){return jt._canPlay("audio",{wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},t,e)};var zt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t])).el.src=t.src,i}return f(e,t),u(e,[{key:"name",get:function(){return"html_img"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"tagName",get:function(){return"img"}},{key:"attributes",get:function(){return{"data-html-img":""}}},{key:"events",get:function(){return{load:"_onLoad",abort:"_onError",error:"_onError"}}},{key:"getPlaybackType",value:function(){return Rt.NO_OP}},{key:"render",value:function(){var t=Et.getStyleFor("[data-html-img] {\n max-width: 100%;\n max-height: 100%; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(t[0]),this.trigger(ct.PLAYBACK_READY,this.name),this}},{key:"_onLoad",value:function(){this.trigger(ct.PLAYBACK_ENDED,this.name)}},{key:"_onError",value:function(t){var e="error"===t.type?"load error":"loading aborted";this.trigger(ct.PLAYBACK_ERROR,{message:e},this.name)}}])}(Rt);zt.canPlay=function(t){return/\.(png|jpg|jpeg|gif|bmp|tiff|pgm|pnm|webp)(|\?.*)$/i.test(t)};var qt=function(t){function e(){var t;c(this,e);for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return(t=n(this,e,[].concat(r)))._noiseFrameNum=-1,t}return f(e,t),u(e,[{key:"name",get:function(){return"no_op"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"template",get:function(){return At("<canvas data-no-op-canvas></canvas>\n<p data-no-op-msg><%=message%></p><p>\n</p>")}},{key:"attributes",get:function(){return{"data-no-op":""}}},{key:"render",value:function(){var t=this.options.playbackNotSupportedMessage||this.i18n.t("playback_not_supported"),e=Et.getStyleFor("[data-no-op] {\n position: absolute;\n height: 100%;\n width: 100%;\n text-align: center; }\n\n[data-no-op] p[data-no-op-msg] {\n position: absolute;\n text-align: center;\n font-size: 25px;\n left: 0;\n right: 0;\n color: white;\n padding: 10px;\n /* center vertically */\n top: 50%;\n transform: translateY(-50%);\n max-height: 100%;\n overflow: auto; }\n\n[data-no-op] canvas[data-no-op-canvas] {\n background-color: #777;\n height: 100%;\n width: 100%; }\n".toString(),{baseUrl:this.options.baseUrl});this.$el.append(e[0]),this.$el.html(this.template({message:t})),this.trigger(ct.PLAYBACK_READY,this.name);var i=!(!this.options.poster||!this.options.poster.showForNoOp);return!this.options.autoPlay&&i||this._animate(),this}},{key:"_noise",value:function(){if(this._noiseFrameNum=(this._noiseFrameNum+1)%5,!this._noiseFrameNum){var t,e=this.context.createImageData(this.context.canvas.width,this.context.canvas.height);try{t=new Uint32Array(e.data.buffer)}catch(r){t=new Uint32Array(this.context.canvas.width*this.context.canvas.height*4);for(var i=e.data,n=0;n<i.length;n++)t[n]=i[n]}for(var r=t.length,s=6*Math.random()+4,a=0,o=0,l=0;l<r;){if(a<0)a=s*Math.random(),o=255*Math.pow(Math.random(),.4)<<24;a-=1,t[l++]=o}this.context.putImageData(e,0,0)}}},{key:"_loop",value:function(){var t=this;this._stop||(this._noise(),this._animationHandle=F((function(){return t._loop()})))}},{key:"destroy",value:function(){this._animationHandle&&(B(this._animationHandle),this._stop=!0)}},{key:"_animate",value:function(){this.canvas=this.$el.find("canvas[data-no-op-canvas]")[0],this.context=this.canvas.getContext("2d"),this._loop()}}])}(Rt);qt.canPlay=function(t){return!0};var Xt=function(t){function e(t){var i;return c(this,e),(i=n(this,e,[t]))._initializeMessages(),i}return f(e,t),u(e,[{key:"name",get:function(){return"strings"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"t",value:function(t){var e=this._language(),i=this._messages.en;return(e&&this._messages[e]||i)[t]||i[t]||t}},{key:"_language",value:function(){return this.core.options.language||z()}},{key:"_initializeMessages",value:function(){this._messages=S.extend(!0,{en:{live:"live",back_to_live:"back to live",disabled:"Disabled",playback_not_supported:"Your browser does not support the playback of this video. Please try using a different browser.",default_error_title:"Could not play video.",default_error_message:"There was a problem trying to load the video."},de:{live:"Live",back_to_live:"Zurück zum Live-Video",disabled:"Deaktiviert",playback_not_supported:"Ihr Browser unterstützt das Playback Verfahren nicht. Bitte vesuchen Sie es mit einem anderen Browser.",default_error_title:"Video kann nicht abgespielt werden",default_error_message:"Es gab ein Problem beim Laden des Videos"},pt:{live:"ao vivo",back_to_live:"voltar para o ao vivo",disabled:"Desativado",playback_not_supported:"Seu navegador não suporta a reprodução deste video. Por favor, tente usar um navegador diferente.",default_error_title:"Não foi possível reproduzir o vídeo.",default_error_message:"Ocorreu um problema ao tentar carregar o vídeo."},es_am:{live:"vivo",back_to_live:"volver en vivo",disabled:"No disponible",playback_not_supported:"Su navegador no soporta la reproducción de este video. Por favor, utilice un navegador diferente.",default_error_title:"No se puede reproducir el video.",default_error_message:"Se ha producido un error al cargar el video."},es:{live:"en directo",back_to_live:"volver al directo",disabled:"No disponible",playback_not_supported:"Este navegador no es compatible para reproducir este vídeo. Utilice un navegador diferente.",default_error_title:"No se puede reproducir el vídeo.",default_error_message:"Se ha producido un problema al cargar el vídeo."},ru:{live:"прямой эфир",back_to_live:"к прямому эфиру",disabled:"Отключено",playback_not_supported:"Ваш браузер не поддерживает воспроизведение этого видео. Пожалуйста, попробуйте другой браузер."},bg:{live:"на живо",back_to_live:"Върни на живо",disabled:"Изключено",playback_not_supported:"Вашият браузър не поддържа възпроизвеждането на това видео. Моля, пробвайте с друг браузър.",default_error_title:"Видеото не може да се възпроизведе.",default_error_message:"Възникна проблем при зареждането на видеото."},fr:{live:"en direct",back_to_live:"retour au direct",disabled:"Désactivé",playback_not_supported:"Votre navigateur ne supporte pas la lecture de cette vidéo. Merci de tenter sur un autre navigateur.",default_error_title:"Impossible de lire la vidéo.",default_error_message:"Un problème est survenu lors du chargement de la vidéo."},tr:{live:"canlı",back_to_live:"canlı yayına dön",disabled:"Engelli",playback_not_supported:"Tarayıcınız bu videoyu oynatma desteğine sahip değil. Lütfen farklı bir tarayıcı ile deneyin."},et:{live:"Otseülekanne",back_to_live:"Tagasi otseülekande juurde",disabled:"Keelatud",playback_not_supported:"Teie brauser ei toeta selle video taasesitust. Proovige kasutada muud brauserit."},ar:{live:"مباشر",back_to_live:"الرجوع إلى المباشر",disabled:"معطّل",playback_not_supported:"المتصفح الذي تستخدمه لا يدعم تشغيل هذا الفيديو. الرجاء إستخدام متصفح آخر.",default_error_title:"غير قادر الى التشغيل.",default_error_message:"حدثت مشكلة أثناء تحميل الفيديو."},zh:{live:"直播",back_to_live:"返回直播",disabled:"已禁用",playback_not_supported:"您的浏览器不支持该视频的播放。请尝试使用另一个浏览器。",default_error_title:"无法播放视频。",default_error_message:"在尝试加载视频时出现了问题。"}},this.core.options.strings||{}),this._messages["de-DE"]=this._messages.de,this._messages["pt-BR"]=this._messages.pt,this._messages["en-US"]=this._messages.en,this._messages["bg-BG"]=this._messages.bg,this._messages["es-419"]=this._messages.es_am,this._messages["es-ES"]=this._messages.es,this._messages["fr-FR"]=this._messages.fr,this._messages["tr-TR"]=this._messages.tr,this._messages["et-EE"]=this._messages.et,this._messages["ar-IQ"]=this._messages.ar,this._messages["zh-CN"]=this._messages.zh}}])}($t),Qt=function(t){function e(){return c(this,e),n(this,e,arguments)}return f(e,t),u(e,[{key:"name",get:function(){return"sources"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"bindEvents",value:function(){this.listenTo(this.core,ct.CORE_CONTAINERS_CREATED,this.onContainersCreated)}},{key:"onContainersCreated",value:function(){var t=this.core.containers.filter((function(t){return"no_op"!==t.playback.name}))[0]||this.core.containers[0];t&&this.core.containers.forEach((function(e){e!==t&&e.destroy()}))}}])}($t);Mt.registerPlugin(Xt),Mt.registerPlugin(Qt),Mt.registerPlayback(qt),Mt.registerPlayback(zt),Mt.registerPlayback(Wt),Mt.registerPlayback(jt);var Zt={Player:Bt,Events:ct,Browser:D,ContainerPlugin:Ut,UIContainerPlugin:Gt,CorePlugin:$t,UICorePlugin:_t,Playback:Rt,Container:Lt,Core:wt,PlayerError:kt,Loader:Mt,BaseObject:ht,UIObject:bt,Utils:Z,HTML5Audio:Wt,HTML5Video:jt,HTMLImg:zt,Log:rt,Styler:Et,version:"0.11.2",template:At,$:S};function Jt(t,e,i){return e=ae(e),le(t,te()?Reflect.construct(e,i||[],ae(t).constructor):e.apply(t,i))}function te(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(te=function(){return!!t})()}function ee(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function ie(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ne(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ee(n.key),n)}}function re(t,e,i){return e&&ne(t.prototype,e),i&&ne(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function se(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&oe(t,e)}function ae(t){return ae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ae(t)}function oe(t,e){return oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},oe(t,e)}function le(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function ce(){return ce="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=ae(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},ce.apply(this,arguments)}var he=function(t){function e(t){return ie(this,e),Jt(this,e,[t])}return se(e,t),re(e,[{key:"name",get:function(){return"click_to_pause"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"config",get:function(){return this.container.options.clickToPauseConfig||{}}},{key:"bindEvents",value:function(){this.listenTo(this.container,ct.CONTAINER_CLICK,this.click),this.listenTo(this.container,ct.CONTAINER_SETTINGSUPDATE,this.settingsUpdate)}},{key:"click",value:function(){var t=this.config.onClickPayload;(this.container.getPlaybackType()!==Rt.LIVE||this.container.isDvrEnabled())&&(this.container.isPlaying()?this.container.pause(t):this.container.play(t))}},{key:"settingsUpdate",value:function(){var t=this.container.getPlaybackType()!==Rt.LIVE||this.container.isDvrEnabled();if(t!==this.pointerEnabled){var e=t?"addClass":"removeClass";this.container.$el[e]("pointer-enabled"),this.pointerEnabled=t}}}])}(Ut),ue=function(t){function e(t){var i;ie(this,e),i=Jt(this,e,[t]);var n=t.options.closedCaptionsConfig;return i._title=n&&n.title?n.title:null,i._ariaLabel=n&&n.ariaLabel?n.ariaLabel:"cc-button",i._labelCb=n&&n.labelCallback&&"function"==typeof n.labelCallback?n.labelCallback:function(t){return t.name},i}return se(e,t),re(e,[{key:"name",get:function(){return"closed_captions"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"template",get:function(){return At('<button type="button" class="cc-button media-control-button media-control-icon" data-cc-button aria-label="<%= ariaLabel %>"></button>\n<ul>\n <% if (title) { %>\n <li data-title><%= title %></li>\n <% }; %>\n <li><a href="#" data-cc-select="-1"><%= disabledLabel %></a></li>\n <% for (var i = 0; i < tracks.length; i++) { %>\n <li><a href="#" data-cc-select="<%= tracks[i].id %>"><%= tracks[i].label %></a></li>\n <% }; %>\n</ul>\n')}},{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,ct.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged),this.listenTo(this.core.mediaControl,ct.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,ct.MEDIACONTROL_HIDE,this.hideContextMenu),this.bindContainerEvents()}},{key:"bindContainerEvents",value:function(){this.container=this.core.activeContainer,this.container&&(this.listenTo(this.container,ct.CONTAINER_SUBTITLE_AVAILABLE,this.onSubtitleAvailable),this.listenTo(this.container,ct.CONTAINER_SUBTITLE_CHANGED,this.onSubtitleChanged),this.listenTo(this.container,ct.CONTAINER_STOP,this.onContainerStop))}},{key:"onContainerStop",value:function(){this.ccAvailable(!1)}},{key:"containerChanged",value:function(){this.ccAvailable(!1),this.stopListening(),this.bindEvents()}},{key:"onSubtitleAvailable",value:function(){this.renderCcButton(),this.ccAvailable(!0)}},{key:"onSubtitleChanged",value:function(t){this.setCurrentContextMenuElement(t.id)}},{key:"onTrackSelect",value:function(t){var e=parseInt(t.target.dataset.ccSelect,10);return this.container.closedCaptionsTrackId=e,this.hideContextMenu(),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"+(isNaN(t)?"":'[data-cc-select="'+t+'"]')).parent()}},{key:"setCurrentContextMenuElement",value:function(t){if(this._trackId!==t){this.contextMenuElement().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;e<t.length;e++)t[e].label=this._labelCb(t[e]);var i=Et.getStyleFor(".cc-controls[data-cc-controls] {\n float: right;\n position: relative;\n display: none; }\n .cc-controls[data-cc-controls].available {\n display: block; }\n .cc-controls[data-cc-controls] .cc-button {\n padding: 6px !important; }\n .cc-controls[data-cc-controls] .cc-button.enabled {\n display: block;\n opacity: 1.0; }\n .cc-controls[data-cc-controls] .cc-button.enabled:hover {\n opacity: 1.0;\n text-shadow: none; }\n .cc-controls[data-cc-controls] > ul {\n list-style-type: none;\n position: absolute;\n bottom: 25px;\n border: 1px solid black;\n display: none;\n background-color: #e6e6e6; }\n .cc-controls[data-cc-controls] li {\n font-size: 10px; }\n .cc-controls[data-cc-controls] li[data-title] {\n background-color: #c3c2c2;\n padding: 5px; }\n .cc-controls[data-cc-controls] li a {\n color: #444;\n padding: 2px 10px;\n display: block;\n text-decoration: none; }\n .cc-controls[data-cc-controls] li a:hover {\n background-color: #555;\n color: white; }\n .cc-controls[data-cc-controls] li a:hover a {\n color: white;\n text-decoration: none; }\n .cc-controls[data-cc-controls] li.current a {\n color: #f00; }\n",{baseUrl:this.options.baseUrl});this.$el.html(this.template({ariaLabel:this._ariaLabel,disabledLabel:this.core.i18n.t("disabled"),title:this._title,tracks:t})),this.$ccButton=this.$el.find("button.cc-button[data-cc-button]"),this.$ccButton.append('<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t viewBox="0 0 49 41.8" style="enable-background:new 0 0 49 41.8;" xml:space="preserve">\n<path d="M47.1,0H3.2C1.6,0,0,1.2,0,2.8v31.5C0,35.9,1.6,37,3.2,37h11.9l3.2,1.9l4.7,2.7c0.9,0.5,2-0.1,2-1.1V37h22.1\n\tc1.6,0,1.9-1.1,1.9-2.7V2.8C49,1.2,48.7,0,47.1,0z M7.2,18.6c0-4.8,3.5-9.3,9.9-9.3c4.8,0,7.1,2.7,7.1,2.7l-2.5,4\n\tc0,0-1.7-1.7-4.2-1.7c-2.8,0-4.3,2.1-4.3,4.3c0,2.1,1.5,4.4,4.5,4.4c2.5,0,4.9-2.1,4.9-2.1l2.2,4.2c0,0-2.7,2.9-7.6,2.9\n\tC10.8,27.9,7.2,23.5,7.2,18.6z M36.9,27.9c-6.4,0-9.9-4.4-9.9-9.3c0-4.8,3.5-9.3,9.9-9.3C41.7,9.3,44,12,44,12l-2.5,4\n\tc0,0-1.7-1.7-4.2-1.7c-2.8,0-4.3,2.1-4.3,4.3c0,2.1,1.5,4.4,4.5,4.4c2.5,0,4.9-2.1,4.9-2.1l2.2,4.2C44.5,25,41.9,27.9,36.9,27.9z"/>\n</svg>'),this.$el.append(i[0])}},{key:"render",value:function(){this.renderCcButton();var t=this.core.mediaControl.$el.find("button[data-fullscreen]");return t[0]?this.$el.insertAfter(t):this.core.mediaControl.$el.find(".media-control-right-panel[data-media-control]").prepend(this.$el),this}}])}(_t),de=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).settingsUpdate(),i}return se(e,t),re(e,[{key:"template",get:function(){return At('<div class="live-info"><%= live %></div>\n<button type="button" class="live-button" aria-label="<%= backToLive %>"><%= backToLive %></button>\n')}},{key:"name",get:function(){return"dvr_controls"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"events",get:function(){return{"click .live-button":"click"}}},{key:"attributes",get:function(){return{class:"dvr-controls","data-dvr-controls":""}}},{key:"bindEvents",value:function(){this.bindCoreEvents(),this.bindContainerEvents()}},{key:"bindCoreEvents",value:function(){var t=this;this.core.mediaControl.settings?(this.listenTo(this.core.mediaControl,ct.MEDIACONTROL_CONTAINERCHANGED,this.containerChanged),this.listenTo(this.core.mediaControl,ct.MEDIACONTROL_RENDERED,this.settingsUpdate),this.listenTo(this.core,ct.CORE_OPTIONS_CHANGE,this.render)):setTimeout((function(){return t.bindCoreEvents()}),100)}},{key:"bindContainerEvents",value:function(){this.core.activeContainer&&(this.listenToOnce(this.core.activeContainer,ct.CONTAINER_TIMEUPDATE,this.render),this.listenTo(this.core.activeContainer,ct.CONTAINER_PLAYBACKDVRSTATECHANGED,this.dvrChanged))}},{key:"containerChanged",value:function(){this.stopListening(),this.bindEvents()}},{key:"dvrChanged",value:function(t){this.core.getPlaybackType()===Rt.LIVE&&(this.settingsUpdate(),this.core.mediaControl.$el.addClass("live"),t?(this.core.mediaControl.$el.addClass("dvr"),this.core.mediaControl.$el.find(".media-control-indicator[data-position], .media-control-indicator[data-duration]").hide()):this.core.mediaControl.$el.removeClass("dvr"))}},{key:"click",value:function(){var t=this.core.mediaControl,e=t.container;e.isPlaying()||e.play(),t.$el.hasClass("dvr")&&e.seek(e.getDuration())}},{key:"settingsUpdate",value:function(){var t=this;this.stopListening(),this.core.mediaControl.$el.removeClass("live"),this.shouldRender()&&(this.render(),this.$el.click((function(){return t.click()}))),this.bindEvents()}},{key:"shouldRender",value:function(){return(void 0===this.core.options.useDvrControls||!!this.core.options.useDvrControls)&&this.core.getPlaybackType()===Rt.LIVE}},{key:"render",value:function(){var t=Et.getStyleFor('.dvr-controls[data-dvr-controls] {\n display: inline-block;\n float: left;\n color: #fff;\n line-height: 32px;\n font-size: 10px;\n font-weight: bold;\n margin-left: 6px; }\n .dvr-controls[data-dvr-controls] .live-info {\n cursor: default;\n font-family: "Roboto", "Open Sans", Arial, sans-serif;\n text-transform: uppercase; }\n .dvr-controls[data-dvr-controls] .live-info:before {\n content: "";\n display: inline-block;\n position: relative;\n width: 7px;\n height: 7px;\n border-radius: 3.5px;\n margin-right: 3.5px;\n background-color: #ff0101; }\n .dvr-controls[data-dvr-controls] .live-info.disabled {\n opacity: 0.3; }\n .dvr-controls[data-dvr-controls] .live-info.disabled:before {\n background-color: #fff; }\n .dvr-controls[data-dvr-controls] .live-button {\n cursor: pointer;\n outline: none;\n display: none;\n border: 0;\n color: #fff;\n background-color: transparent;\n height: 32px;\n padding: 0;\n opacity: 0.7;\n font-family: "Roboto", "Open Sans", Arial, sans-serif;\n text-transform: uppercase;\n transition: all 0.1s ease; }\n .dvr-controls[data-dvr-controls] .live-button:before {\n content: "";\n display: inline-block;\n position: relative;\n width: 7px;\n height: 7px;\n border-radius: 3.5px;\n margin-right: 3.5px;\n background-color: #fff; }\n .dvr-controls[data-dvr-controls] .live-button:hover {\n opacity: 1;\n text-shadow: rgba(255, 255, 255, 0.75) 0 0 5px; }\n\n.dvr .dvr-controls[data-dvr-controls] .live-info {\n display: none; }\n\n.dvr .dvr-controls[data-dvr-controls] .live-button {\n display: block; }\n\n.dvr.media-control.live[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] .bar-fill-2[data-seekbar] {\n background-color: #005aff; }\n\n.media-control.live[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] .bar-fill-2[data-seekbar] {\n background-color: #ff0101; }\n',{baseUrl:this.options.baseUrl});return this.$el.html(this.template({live:this.core.i18n.t("live"),backToLive:this.core.i18n.t("back_to_live")})),this.$el.append(t[0]),this.shouldRender()&&(this.core.mediaControl.$el.addClass("live"),this.core.mediaControl.$(".media-control-left-panel[data-media-control]").append(this.$el)),this}}])}(_t),fe=function(t){function e(){return ie(this,e),Jt(this,e,arguments)}return se(e,t),re(e,[{key:"name",get:function(){return"end_video"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"bindEvents",value:function(){this.listenTo(this.core,ct.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged);var t=this.core.activeContainer;t&&(this.listenTo(t,ct.CONTAINER_ENDED,this.ended),this.listenTo(t,ct.CONTAINER_STOP,this.ended))}},{key:"containerChanged",value:function(){this.stopListening(),this.bindEvents()}},{key:"ended",value:function(){(void 0===this.core.options.exitFullscreenOnEnd||this.core.options.exitFullscreenOnEnd)&&this.core.isFullscreen()&&this.core.toggleFullscreen()}}])}($t),ge=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).options.disableErrorScreen?le(i,i.disable()):i}return se(e,t),re(e,[{key:"name",get:function(){return"error_screen"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"template",get:function(){return At('<div class="player-error-screen__content" data-error-screen>\n <% if (icon) { %>\n <div class="player-error-screen__icon" data-error-screen><%= icon %></div>\n <% } %>\n <div class="player-error-screen__title" data-error-screen><%= title %></div>\n <div class="player-error-screen__message" data-error-screen><%= message %></div>\n <div class="player-error-screen__code" data-error-screen>Error code: <%= code %></div>\n <div class="player-error-screen__reload" data-error-screen><%= reloadIcon %></div>\n</div>\n')}},{key:"container",get:function(){return this.core.getCurrentContainer()}},{key:"attributes",get:function(){return{class:"player-error-screen","data-error-screen":""}}},{key:"bindEvents",value:function(){this.listenTo(this.core,ct.ERROR,this.onError),this.listenTo(this.core,ct.CORE_ACTIVE_CONTAINER_CHANGED,this.onContainerChanged)}},{key:"bindReload",value:function(){this.reloadButton=this.$el.find(".player-error-screen__reload"),this.reloadButton&&this.reloadButton.on("click",this.reload.bind(this))}},{key:"reload",value:function(){var t=this;this.listenToOnce(this.core,ct.CORE_READY,(function(){return t.container.play()})),this.core.load(this.options.sources,this.options.mimeType),this.unbindReload()}},{key:"unbindReload",value:function(){this.reloadButton&&this.reloadButton.off("click")}},{key:"onContainerChanged",value:function(){this.err=null,this.unbindReload(),this.hide()}},{key:"onError",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.level===kt.Levels.FATAL&&(this.err=t,this.container.disableMediaControl(),this.container.stop(),this.show())}},{key:"show",value:function(){this.render(),this.$el.show()}},{key:"hide",value:function(){this.$el.hide()}},{key:"render",value:function(){if(this.err){var t=Et.getStyleFor("[data-player] .player-error-screen {\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n color: #CCCACA;\n position: absolute;\n top: 0;\n height: 100%;\n width: 100%;\n background-color: rgba(0, 0, 0, 0.7);\n z-index: 2000;\n display: flex;\n flex-direction: column;\n justify-content: center; }\n [data-player] .player-error-screen__content[data-error-screen] {\n font-size: 14px;\n color: #CCCACA;\n margin-top: 45px; }\n [data-player] .player-error-screen__title[data-error-screen] {\n font-weight: bold;\n line-height: 30px;\n font-size: 18px; }\n [data-player] .player-error-screen__message[data-error-screen] {\n width: 90%;\n margin: 0 auto; }\n [data-player] .player-error-screen__code[data-error-screen] {\n font-size: 13px;\n margin-top: 15px; }\n [data-player] .player-error-screen__reload {\n cursor: pointer;\n width: 30px;\n margin: 15px auto 0 !important; }\n",{baseUrl:this.options.baseUrl});return this.$el.html(this.template({title:this.err.UI.title,message:this.err.UI.message,code:this.err.code,icon:this.err.UI.icon||"",reloadIcon:'<svg fill="#FFFFFF" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">\n <path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/>\n <path d="M0 0h24v24H0z" fill="none"/>\n</svg>'})),this.$el.append(t[0]),this.core.$el.append(this.el),this.bindReload(),this}}}])}(_t),pe='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill="#010101" d="M1.425.35L14.575 8l-13.15 7.65V.35z"/>\n</svg>',me='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill-rule="evenodd" clip-rule="evenodd" fill="#010101" d="M1.712 14.76H6.43V1.24H1.71v13.52zm7.86-13.52v13.52h4.716V1.24H9.573z"/>\n</svg>',ve=S('link[rel="shortcut icon"]'),ye=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t]))._container=null,i.configure(),i}return se(e,t),re(e,[{key:"name",get:function(){return"favicon"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"oldIcon",get:function(){return ve}},{key:"configure",value:function(){this.core.options.changeFavicon?this.enabled||(this.stopListening(this.core,ct.CORE_OPTIONS_CHANGE),this.enable()):this.enabled&&(this.disable(),this.listenTo(this.core,ct.CORE_OPTIONS_CHANGE,this.configure))}},{key:"bindEvents",value:function(){this.listenTo(this.core,ct.CORE_OPTIONS_CHANGE,this.configure),this.listenTo(this.core,ct.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged),this.core.activeContainer&&this.containerChanged()}},{key:"containerChanged",value:function(){this._container&&this.stopListening(this._container),this._container=this.core.activeContainer,this.listenTo(this._container,ct.CONTAINER_PLAY,this.setPlayIcon),this.listenTo(this._container,ct.CONTAINER_PAUSE,this.setPauseIcon),this.listenTo(this._container,ct.CONTAINER_STOP,this.resetIcon),this.listenTo(this._container,ct.CONTAINER_ENDED,this.resetIcon),this.listenTo(this._container,ct.CONTAINER_ERROR,this.resetIcon),this.resetIcon()}},{key:"disable",value:function(){ce(ae(e.prototype),"disable",this).call(this),this.resetIcon()}},{key:"destroy",value:function(){ce(ae(e.prototype),"destroy",this).call(this),this.resetIcon()}},{key:"createIcon",value:function(t){var e=S("<canvas/>");e[0].width=16,e[0].height=16;var i=e[0].getContext("2d");i.fillStyle="#000";var n=S(t).find("path").attr("d"),r=new Path2D(n);i.fill(r);var s=S('<link rel="shortcut icon" type="image/png"/>');return s.attr("href",e[0].toDataURL("image/png")),s}},{key:"setPlayIcon",value:function(){this.playIcon||(this.playIcon=this.createIcon(pe)),this.changeIcon(this.playIcon)}},{key:"setPauseIcon",value:function(){this.pauseIcon||(this.pauseIcon=this.createIcon(me)),this.changeIcon(this.pauseIcon)}},{key:"resetIcon",value:function(){S('link[rel="shortcut icon"]').remove(),S("head").append(this.oldIcon)}},{key:"changeIcon",value:function(t){t&&(S('link[rel="shortcut icon"]').remove(),S("head").append(t))}}])}($t),Ae=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).container.options.gaAccount&&(i.account=i.container.options.gaAccount,i.trackerName=i.container.options.gaTrackerName?i.container.options.gaTrackerName+".":"Clappr.",i.domainName=i.container.options.gaDomainName,i.currentHDState=void 0,i.embedScript()),i}return se(e,t),re(e,[{key:"name",get:function(){return"google_analytics"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"embedScript",value:function(){var t=this;if(window._gat)this.addEventListeners();else{var e=document.createElement("script");e.setAttribute("type","text/javascript"),e.setAttribute("async","async"),e.setAttribute("src","//www.google-analytics.com/ga.js"),e.onload=function(){return t.addEventListeners()},document.body.appendChild(e)}}},{key:"addEventListeners",value:function(){var t=this;this.container&&(this.listenTo(this.container,ct.CONTAINER_READY,this.onReady),this.listenTo(this.container,ct.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ct.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ct.CONTAINER_PAUSE,this.onPause),this.listenTo(this.container,ct.CONTAINER_ENDED,this.onEnded),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERING,this.onBuffering),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERFULL,this.onBufferFull),this.listenTo(this.container,ct.CONTAINER_ERROR,this.onError),this.listenTo(this.container,ct.CONTAINER_PLAYBACKSTATE,this.onPlaybackChanged),this.listenTo(this.container,ct.CONTAINER_VOLUME,(function(e){return t.onVolumeChanged(e)})),this.listenTo(this.container,ct.CONTAINER_SEEK,(function(e){return t.onSeek(e)})),this.listenTo(this.container,ct.CONTAINER_FULL_SCREEN,this.onFullscreen),this.listenTo(this.container,ct.CONTAINER_HIGHDEFINITIONUPDATE,this.onHD),this.listenTo(this.container,ct.CONTAINER_PLAYBACKDVRSTATECHANGED,this.onDVR)),_gaq.push([this.trackerName+"_setAccount",this.account]),this.domainName&&_gaq.push([this.trackerName+"_setDomainName",this.domainName])}},{key:"onReady",value:function(){this.push(["Video","Playback",this.container.playback.name])}},{key:"onPlay",value:function(){this.push(["Video","Play",this.container.playback.src])}},{key:"onStop",value:function(){this.push(["Video","Stop",this.container.playback.src])}},{key:"onEnded",value:function(){this.push(["Video","Ended",this.container.playback.src])}},{key:"onBuffering",value:function(){this.push(["Video","Buffering",this.container.playback.src])}},{key:"onBufferFull",value:function(){this.push(["Video","Bufferfull",this.container.playback.src])}},{key:"onError",value:function(){this.push(["Video","Error",this.container.playback.src])}},{key:"onHD",value:function(t){var e=t?"ON":"OFF";e!==this.currentHDState&&(this.currentHDState=e,this.push(["Video","HD - "+e,this.container.playback.src]))}},{key:"onPlaybackChanged",value:function(t){null!==t.type&&this.push(["Video","Playback Type - "+t.type,this.container.playback.src])}},{key:"onDVR",value:function(t){var e=t?"ON":"OFF";this.push(["Interaction","DVR - "+e,this.container.playback.src])}},{key:"onPause",value:function(){this.push(["Video","Pause",this.container.playback.src])}},{key:"onSeek",value:function(){this.push(["Video","Seek",this.container.playback.src])}},{key:"onVolumeChanged",value:function(){this.push(["Interaction","Volume",this.container.playback.src])}},{key:"onFullscreen",value:function(){this.push(["Interaction","Fullscreen",this.container.playback.src])}},{key:"push",value:function(t){var e=[this.trackerName+"_trackEvent"].concat(t);_gaq.push(e)}}])}(Ut),Ee=function(t){this.element=t||window.document,this.initialize()};Ee.KEY_NAMES_BY_CODE={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",20:"caps_lock",27:"esc",32:"space",37:"left",38:"up",39:"right",40:"down",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"a",66:"b",67:"c",68:"d",69:"e",70:"f",71:"g",72:"h",73:"i",74:"j",75:"k",76:"l",77:"m",78:"n",79:"o",80:"p",81:"q",82:"r",83:"s",84:"t",85:"u",86:"v",87:"w",88:"x",89:"y",90:"z",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"},Ee.KEY_CODES_BY_NAME={},function(){for(var t in Ee.KEY_NAMES_BY_CODE)Object.prototype.hasOwnProperty.call(Ee.KEY_NAMES_BY_CODE,t)&&(Ee.KEY_CODES_BY_NAME[Ee.KEY_NAMES_BY_CODE[t]]=+t)}(),Ee.MODIFIERS=["shift","ctrl","alt"],Ee.registerEvent=document.addEventListener?function(t,e,i){t.addEventListener(e,i,!1)}:document.attachEvent?function(t,e,i){t.attachEvent("on"+e,i)}:void 0,Ee.unregisterEvent=document.removeEventListener?function(t,e,i){t.removeEventListener(e,i,!1)}:document.detachEvent?function(t,e,i){t.detachEvent("on"+e,i)}:void 0,Ee.stringContains=function(t,e){return-1!==t.indexOf(e)},Ee.neatString=function(t){return t.replace(/^\s+|\s+$/g,"").replace(/\s+/g," ")},Ee.capitalize=function(t){return t.toLowerCase().replace(/^./,(function(t){return t.toUpperCase()}))},Ee.isString=function(t){return Ee.stringContains(Object.prototype.toString.call(t),"String")},Ee.arrayIncludes=Array.prototype.indexOf?function(t,e){return-1!==t.indexOf(e)}:function(t,e){for(var i=0;i<t.length;i++)if(t[i]===e)return!0;return!1},Ee.extractModifiers=function(t){var e,i;for(e=[],i=0;i<Ee.MODIFIERS.length;i++)Ee.stringContains(t,Ee.MODIFIERS[i])&&e.push(Ee.MODIFIERS[i]);return e},Ee.extractKey=function(t){var e,i;for(e=Ee.neatString(t).split(" "),i=0;i<e.length;i++)if(!Ee.arrayIncludes(Ee.MODIFIERS,e[i]))return e[i]},Ee.modifiersAndKey=function(t){var e,i;return Ee.stringContains(t,"any")?Ee.neatString(t).split(" ").slice(0,2).join(" "):(e=Ee.extractModifiers(t),(i=Ee.extractKey(t))&&!Ee.arrayIncludes(Ee.MODIFIERS,i)&&e.push(i),e.join(" "))},Ee.keyName=function(t){return Ee.KEY_NAMES_BY_CODE[t+""]},Ee.keyCode=function(t){return+Ee.KEY_CODES_BY_NAME[t]},Ee.prototype.initialize=function(){var t,e=this;for(this.lastKeyCode=-1,this.lastModifiers={},t=0;t<Ee.MODIFIERS.length;t++)this.lastModifiers[Ee.MODIFIERS[t]]=!1;this.keysDown={any:[]},this.keysUp={any:[]},this.downHandler=this.handler("down"),this.upHandler=this.handler("up"),Ee.registerEvent(this.element,"keydown",this.downHandler),Ee.registerEvent(this.element,"keyup",this.upHandler),Ee.registerEvent(window,"unload",(function t(){Ee.unregisterEvent(e.element,"keydown",e.downHandler),Ee.unregisterEvent(e.element,"keyup",e.upHandler),Ee.unregisterEvent(window,"unload",t)}))},Ee.prototype.handler=function(t){var e=this;return function(i){var n,r,s;for(i=i||window.event,e.lastKeyCode=i.keyCode,n=0;n<Ee.MODIFIERS.length;n++)e.lastModifiers[Ee.MODIFIERS[n]]=i[Ee.MODIFIERS[n]+"Key"];for(Ee.arrayIncludes(Ee.MODIFIERS,Ee.keyName(e.lastKeyCode))&&(e.lastModifiers[Ee.keyName(e.lastKeyCode)]=!0),r=e["keys"+Ee.capitalize(t)],n=0;n<r.any.length;n++)!1===r.any[n](i)&&i.preventDefault&&i.preventDefault();if(r[s=e.lastModifiersAndKey()])for(n=0;n<r[s].length;n++)!1===r[s][n](i)&&i.preventDefault&&i.preventDefault()}},Ee.prototype.registerKeys=function(t,e,i){var n,r,s=this["keys"+Ee.capitalize(t)];for(Ee.isString(e)&&(e=[e]),n=0;n<e.length;n++)r=e[n],s[r=Ee.modifiersAndKey(r+"")]?s[r].push(i):s[r]=[i];return this},Ee.prototype.unregisterKeys=function(t,e,i){var n,r,s,a=this["keys"+Ee.capitalize(t)];for(Ee.isString(e)&&(e=[e]),n=0;n<e.length;n++)if(s=e[n],s=Ee.modifiersAndKey(s+""),null===i)delete a[s];else if(a[s])for(r=0;r<a[s].length;r++)if(String(a[s][r])===String(i)){a[s].splice(r,1);break}return this},Ee.prototype.off=function(t){return this.unregisterKeys("down",t,null)},Ee.prototype.delegate=function(t,e,i){return null!==i||void 0!==i?this.registerKeys(t,e,i):this.unregisterKeys(t,e,i)},Ee.prototype.down=function(t,e){return this.delegate("down",t,e)},Ee.prototype.up=function(t,e){return this.delegate("up",t,e)},Ee.prototype.lastKey=function(t){return t?this.lastModifiers[t]:Ee.keyName(this.lastKeyCode)},Ee.prototype.lastModifiersAndKey=function(){var t,e;for(t=[],e=0;e<Ee.MODIFIERS.length;e++)this.lastKey(Ee.MODIFIERS[e])&&t.push(Ee.MODIFIERS[e]);return Ee.arrayIncludes(t,this.lastKey())||t.push(this.lastKey()),t.join(" ")};var Te={Kibo:Ee},be='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill-rule="evenodd" clip-rule="evenodd" fill="#010101" d="M1.712 1.24h12.6v13.52h-12.6z"/>\n</svg>',ke='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill-rule="evenodd" clip-rule="evenodd" fill="#010101" d="M11.5 11h-.002v1.502L7.798 10H4.5V6h3.297l3.7-2.502V4.5h.003V11zM11 4.49L7.953 6.5H5v3h2.953L11 11.51V4.49z"/>\n</svg>',Se='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill="#010101" d="M7.156 8L4 11.156V8.5H3V13h4.5v-1H4.844L8 8.844 7.156 8zM8.5 3v1h2.657L8 7.157 8.846 8 12 4.844V7.5h1V3H8.5z"/>\n</svg>',_e=Z.Config,Le=Z.Fullscreen,Re=Z.formatTime,Ce=Z.extend,we=Z.removeArrayItem,Ie=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).persistConfig=i.options.persistConfig,i.currentPositionValue=null,i.currentDurationValue=null,i.keepVisible=!1,i.fullScreenOnVideoTagSupported=null,i.setInitialVolume(),i.settings={left:["play","stop","pause"],right:["volume"],default:["position","seekbar","duration"]},i.kibo=new Ee(i.options.focusElement),i.bindKeyEvents(),i.container?S.isEmptyObject(i.container.settings)||(i.settings=S.extend({},i.container.settings)):i.settings={},i.userDisabled=!1,(i.container&&i.container.mediaControlDisabled||i.options.chromeless)&&i.disable(),i.stopDragHandler=function(t){return i.stopDrag(t)},i.updateDragHandler=function(t){return i.updateDrag(t)},S(document).bind("mouseup",i.stopDragHandler),S(document).bind("mousemove",i.updateDragHandler),i}return se(e,t),re(e,[{key:"name",get:function(){return"media_control"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"disabled",get:function(){var t=this.container&&this.container.getPlaybackType()===Rt.NO_OP;return this.userDisabled||t}},{key:"container",get:function(){return this.core&&this.core.activeContainer}},{key:"playback",get:function(){return this.core&&this.core.activePlayback}},{key:"attributes",get:function(){return{class:"media-control","data-media-control":""}}},{key:"events",get:function(){return{"click [data-play]":"play","click [data-pause]":"pause","click [data-playpause]":"togglePlayPause","click [data-stop]":"stop","click [data-playstop]":"togglePlayStop","click [data-fullscreen]":"toggleFullscreen","click .bar-container[data-seekbar]":"seek","click .bar-container[data-volume]":"onVolumeClick","click .drawer-icon[data-volume]":"toggleMute","mouseenter .drawer-container[data-volume]":"showVolumeBar","mouseleave .drawer-container[data-volume]":"hideVolumeBar","mousedown .bar-container[data-volume]":"startVolumeDrag","mousemove .bar-container[data-volume]":"mousemoveOnVolumeBar","mousedown .bar-scrubber[data-seekbar]":"startSeekDrag","mousemove .bar-container[data-seekbar]":"mousemoveOnSeekBar","mouseleave .bar-container[data-seekbar]":"mouseleaveOnSeekBar","mouseenter .media-control-layer[data-controls]":"setUserKeepVisible","mouseleave .media-control-layer[data-controls]":"resetUserKeepVisible"}}},{key:"template",get:function(){return At('<div class="media-control-background" data-background></div>\n<div class="media-control-layer" data-controls>\n <% var renderBar = function(name) { %>\n <div class="bar-container" data-<%= name %>>\n <div class="bar-background" data-<%= name %>>\n <div class="bar-fill-1" data-<%= name %>></div>\n <div class="bar-fill-2" data-<%= name %>></div>\n <div class="bar-hover" data-<%= name %>></div>\n </div>\n <div class="bar-scrubber" data-<%= name %>>\n <div class="bar-scrubber-icon" data-<%= name %>></div>\n </div>\n </div>\n <% }; %>\n <% var renderSegmentedBar = function(name, segments) {\n segments = segments || 10; %>\n <div class="bar-container" data-<%= name %>>\n <% for (var i = 0; i < segments; i++) { %>\n <div class="segmented-bar-element" data-<%= name %>></div>\n <% } %>\n </div>\n <% }; %>\n <% var renderDrawer = function(name, renderContent) { %>\n <div class="drawer-container" data-<%= name %>>\n <div class="drawer-icon-container" data-<%= name %>>\n <div class="drawer-icon media-control-icon" data-<%= name %>></div>\n <span class="drawer-text" data-<%= name %>></span>\n </div>\n <% renderContent(name); %>\n </div>\n <% }; %>\n <% var renderIndicator = function(name) { %>\n <div class="media-control-indicator" data-<%= name %>></div>\n <% }; %>\n <% var renderButton = function(name) { %>\n <button type="button" class="media-control-button media-control-icon" data-<%= name %> aria-label="<%= name %>"></button>\n <% }; %>\n <% var templates = {\n bar: renderBar,\n segmentedBar: renderSegmentedBar,\n };\n var render = function(settingsList) {\n settingsList.forEach(function(setting) {\n if(setting === "seekbar") {\n renderBar(setting);\n } else if (setting === "volume") {\n renderDrawer(setting, settings.volumeBarTemplate ? templates[settings.volumeBarTemplate] : function(name) { return renderSegmentedBar(name); });\n } else if (setting === "duration" || setting === "position") {\n renderIndicator(setting);\n } else {\n renderButton(setting);\n }\n });\n }; %>\n <% if (settings.default && settings.default.length) { %>\n <div class="media-control-center-panel" data-media-control>\n <% render(settings.default); %>\n </div>\n <% } %>\n <% if (settings.left && settings.left.length) { %>\n <div class="media-control-left-panel" data-media-control>\n <% render(settings.left); %>\n </div>\n <% } %>\n <% if (settings.right && settings.right.length) { %>\n <div class="media-control-right-panel" data-media-control>\n <% render(settings.right); %>\n </div>\n <% } %>\n</div>\n')}},{key:"volume",get:function(){return this.container&&this.container.isReady?this.container.volume:this.intendedVolume}},{key:"muted",get:function(){return 0===this.volume}},{key:"getExternalInterface",value:function(){var t=this;return{setVolume:this.setVolume,getVolume:function(){return t.volume}}}},{key:"bindEvents",value:function(){var t=this;this.stopListening(),this.listenTo(this.core,ct.CORE_ACTIVE_CONTAINER_CHANGED,this.onActiveContainerChanged),this.listenTo(this.core,ct.CORE_MOUSE_MOVE,this.show),this.listenTo(this.core,ct.CORE_MOUSE_LEAVE,(function(){return t.hide(t.options.hideMediaControlDelay)})),this.listenTo(this.core,ct.CORE_FULLSCREEN,this.show),this.listenTo(this.core,ct.CORE_OPTIONS_CHANGE,this.configure),this.listenTo(this.core,ct.CORE_RESIZE,this.playerResize),this.bindContainerEvents()}},{key:"bindContainerEvents",value:function(){this.container&&(this.listenTo(this.container,ct.CONTAINER_PLAY,this.changeTogglePlay),this.listenTo(this.container,ct.CONTAINER_PAUSE,this.changeTogglePlay),this.listenTo(this.container,ct.CONTAINER_STOP,this.changeTogglePlay),this.listenTo(this.container,ct.CONTAINER_DBLCLICK,this.toggleFullscreen),this.listenTo(this.container,ct.CONTAINER_TIMEUPDATE,this.onTimeUpdate),this.listenTo(this.container,ct.CONTAINER_PROGRESS,this.updateProgressBar),this.listenTo(this.container,ct.CONTAINER_SETTINGSUPDATE,this.settingsUpdate),this.listenTo(this.container,ct.CONTAINER_PLAYBACKDVRSTATECHANGED,this.settingsUpdate),this.listenTo(this.container,ct.CONTAINER_HIGHDEFINITIONUPDATE,this.highDefinitionUpdate),this.listenTo(this.container,ct.CONTAINER_MEDIACONTROL_DISABLE,this.disable),this.listenTo(this.container,ct.CONTAINER_MEDIACONTROL_ENABLE,this.enable),this.listenTo(this.container,ct.CONTAINER_ENDED,this.ended),this.listenTo(this.container,ct.CONTAINER_VOLUME,this.onVolumeChanged),this.listenTo(this.container,ct.CONTAINER_OPTIONS_CHANGE,this.setInitialVolume),"video"===this.container.playback.el.nodeName.toLowerCase()&&this.listenToOnce(this.container,ct.CONTAINER_LOADEDMETADATA,this.onLoadedMetadataOnVideoTag))}},{key:"disable",value:function(){this.userDisabled=!0,this.hide(),this.unbindKeyEvents(),this.$el.hide()}},{key:"enable",value:function(){this.options.chromeless||(this.userDisabled=!1,this.bindKeyEvents(),this.show())}},{key:"play",value:function(){this.container&&this.container.play()}},{key:"pause",value:function(){this.container&&this.container.pause()}},{key:"stop",value:function(){this.container&&this.container.stop()}},{key:"setInitialVolume",value:function(){var t=this.persistConfig?_e.restore("volume"):100,e=this.container&&this.container.options||this.options;this.setVolume(e.mute?0:t,!0)}},{key:"onVolumeChanged",value:function(){this.updateVolumeUI()}},{key:"onLoadedMetadataOnVideoTag",value:function(){var t=this.playback&&this.playback.el;!Le.fullscreenEnabled()&&t.webkitSupportsFullscreen&&(this.fullScreenOnVideoTagSupported=!0,this.settingsUpdate())}},{key:"updateVolumeUI",value:function(){if(this.rendered){this.$volumeBarContainer.find(".bar-fill-2").css({});var t=this.$volumeBarContainer.width(),e=this.$volumeBarBackground.width(),i=(t-e)/2,n=e*this.volume/100+i;this.$volumeBarFill.css({width:"".concat(this.volume,"%")}),this.$volumeBarScrubber.css({left:n}),this.$volumeBarContainer.find(".segmented-bar-element").removeClass("fill");var r=Math.ceil(this.volume/10);this.$volumeBarContainer.find(".segmented-bar-element").slice(0,r).addClass("fill"),this.$volumeIcon.html(""),this.$volumeIcon.removeClass("muted"),this.muted?(this.$volumeIcon.append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill-rule="evenodd" clip-rule="evenodd" fill="#010101" d="M9.75 11.51L6.7 9.5H3.75v-3H6.7L9.75 4.49v.664l.497.498V3.498L6.547 6H3.248v4h3.296l3.7 2.502v-2.154l-.497.5v.662zm3-5.165L12.404 6l-1.655 1.653L9.093 6l-.346.345L10.402 8 8.747 9.654l.346.347 1.655-1.653L12.403 10l.348-.346L11.097 8l1.655-1.655z"/>\n</svg>'),this.$volumeIcon.addClass("muted")):this.$volumeIcon.append(ke),this.applyButtonStyle(this.$volumeIcon)}}},{key:"changeTogglePlay",value:function(){this.$playPauseToggle.html(""),this.$playStopToggle.html(""),this.container&&this.container.isPlaying()?(this.$playPauseToggle.append(me),this.$playStopToggle.append(be),this.trigger(ct.MEDIACONTROL_PLAYING)):(this.$playPauseToggle.append(pe),this.$playStopToggle.append(pe),this.trigger(ct.MEDIACONTROL_NOTPLAYING),D.isMobile&&this.show()),this.applyButtonStyle(this.$playPauseToggle),this.applyButtonStyle(this.$playStopToggle)}},{key:"mousemoveOnSeekBar",value:function(t){if(this.settings.seekEnabled){var e=t.pageX-this.$seekBarContainer.offset().left-this.$seekBarHover.width()/2;this.$seekBarHover.css({left:e})}this.trigger(ct.MEDIACONTROL_MOUSEMOVE_SEEKBAR,t)}},{key:"mouseleaveOnSeekBar",value:function(t){this.trigger(ct.MEDIACONTROL_MOUSELEAVE_SEEKBAR,t)}},{key:"onVolumeClick",value:function(t){this.setVolume(this.getVolumeFromUIEvent(t))}},{key:"mousemoveOnVolumeBar",value:function(t){this.draggingVolumeBar&&this.setVolume(this.getVolumeFromUIEvent(t))}},{key:"playerResize",value:function(t){this.$fullscreenToggle.html("");var e=this.core.isFullscreen()?'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill="#010101" d="M13.5 3.344l-.844-.844L9.5 5.656V3h-1v4.5H13v-1h-2.656L13.5 3.344zM3 9.5h2.656L2.5 12.656l.844.844L6.5 10.344V13h1V8.5H3v1z"/>\n</svg>':Se;this.$fullscreenToggle.append(e),this.applyButtonStyle(this.$fullscreenToggle),0!==this.$el.find(".media-control").length&&this.$el.removeClass("w320"),(t.width<=320||this.options.hideVolumeBar)&&this.$el.addClass("w320")}},{key:"togglePlayPause",value:function(){return this.container.isPlaying()?this.container.pause():this.container.play(),!1}},{key:"togglePlayStop",value:function(){this.container.isPlaying()?this.container.stop():this.container.play()}},{key:"startSeekDrag",value:function(t){this.settings.seekEnabled&&(this.draggingSeekBar=!0,this.$el.addClass("dragging"),this.$seekBarLoaded.addClass("media-control-notransition"),this.$seekBarPosition.addClass("media-control-notransition"),this.$seekBarScrubber.addClass("media-control-notransition"),t&&t.preventDefault())}},{key:"startVolumeDrag",value:function(t){this.draggingVolumeBar=!0,this.$el.addClass("dragging"),t&&t.preventDefault()}},{key:"stopDrag",value:function(t){this.draggingSeekBar&&this.seek(t),this.$el.removeClass("dragging"),this.$seekBarLoaded.removeClass("media-control-notransition"),this.$seekBarPosition.removeClass("media-control-notransition"),this.$seekBarScrubber.removeClass("media-control-notransition dragging"),this.draggingSeekBar=!1,this.draggingVolumeBar=!1}},{key:"updateDrag",value:function(t){if(this.draggingSeekBar){t.preventDefault();var e=(t.pageX-this.$seekBarContainer.offset().left)/this.$seekBarContainer.width()*100;e=Math.min(100,Math.max(e,0)),this.setSeekPercentage(e)}else this.draggingVolumeBar&&(t.preventDefault(),this.setVolume(this.getVolumeFromUIEvent(t)))}},{key:"getVolumeFromUIEvent",value:function(t){return(t.pageX-this.$volumeBarContainer.offset().left)/this.$volumeBarContainer.width()*100}},{key:"toggleMute",value:function(){this.setVolume(this.muted?100:0)}},{key:"setVolume",value:function(t){var e=this,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t=Math.min(100,Math.max(t,0)),this.intendedVolume=t,this.persistConfig&&!i&&_e.persist("volume",t);var n=function(){e.container&&e.container.isReady?e.container.setVolume(t):e.listenToOnce(e.container,ct.CONTAINER_READY,(function(){e.container.setVolume(t)}))};this.container?n():this.listenToOnce(this,ct.MEDIACONTROL_CONTAINERCHANGED,(function(){return n()}))}},{key:"toggleFullscreen",value:function(){this.trigger(ct.MEDIACONTROL_FULLSCREEN,this.name),this.container.fullscreen(),this.core.toggleFullscreen(),this.resetUserKeepVisible()}},{key:"onActiveContainerChanged",value:function(){this.fullScreenOnVideoTagSupported=null,this.bindEvents(),this.setInitialVolume(),this.changeTogglePlay(),this.bindContainerEvents(),this.settingsUpdate(),this.container&&this.container.trigger(ct.CONTAINER_PLAYBACKDVRSTATECHANGED,this.container.isDvrInUse()),this.container&&this.container.mediaControlDisabled&&this.disable(),this.trigger(ct.MEDIACONTROL_CONTAINERCHANGED)}},{key:"showVolumeBar",value:function(){this.hideVolumeId&&clearTimeout(this.hideVolumeId),this.$volumeBarContainer.removeClass("volume-bar-hide")}},{key:"hideVolumeBar",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:400;this.$volumeBarContainer&&(this.draggingVolumeBar?this.hideVolumeId=setTimeout((function(){return t.hideVolumeBar()}),e):(this.hideVolumeId&&clearTimeout(this.hideVolumeId),this.hideVolumeId=setTimeout((function(){return t.$volumeBarContainer.addClass("volume-bar-hide")}),e)))}},{key:"ended",value:function(){this.changeTogglePlay()}},{key:"updateProgressBar",value:function(t){var e=t.start/t.total*100,i=t.current/t.total*100;this.$seekBarLoaded.css({left:"".concat(e,"%"),width:"".concat(i-e,"%")})}},{key:"onTimeUpdate",value:function(t){if(!this.draggingSeekBar){var e=t.current<0?t.total:t.current;this.currentPositionValue=e,this.currentDurationValue=t.total,this.renderSeekBar()}}},{key:"renderSeekBar",value:function(){if(null!==this.currentPositionValue&&null!==this.currentDurationValue){this.currentSeekBarPercentage=100,this.container&&(this.container.getPlaybackType()!==Rt.LIVE||this.container.isDvrInUse())&&(this.currentSeekBarPercentage=this.currentPositionValue/this.currentDurationValue*100),this.setSeekPercentage(this.currentSeekBarPercentage);var t=Re(this.currentPositionValue),e=Re(this.currentDurationValue);t!==this.displayedPosition&&(this.$position.text(t),this.displayedPosition=t),e!==this.displayedDuration&&(this.$duration.text(e),this.displayedDuration=e)}}},{key:"seek",value:function(t){if(this.settings.seekEnabled){var e=(t.pageX-this.$seekBarContainer.offset().left)/this.$seekBarContainer.width()*100;return e=Math.min(100,Math.max(e,0)),this.container&&this.container.seekPercentage(e),this.setSeekPercentage(e),!1}}},{key:"setKeepVisible",value:function(){this.keepVisible=!0}},{key:"resetKeepVisible",value:function(){this.keepVisible=!1}},{key:"setUserKeepVisible",value:function(){this.userKeepVisible=!0}},{key:"resetUserKeepVisible",value:function(){this.userKeepVisible=!1}},{key:"isVisible",value:function(){return!this.$el.hasClass("media-control-hide")}},{key:"show",value:function(t){var e=this;if(!this.disabled){var i=t&&t.clientX!==this.lastMouseX&&t.clientY!==this.lastMouseY;(!t||i||navigator.userAgent.match(/firefox/i))&&(clearTimeout(this.hideId),this.$el.show(),this.trigger(ct.MEDIACONTROL_SHOW,this.name),this.container&&this.container.trigger(ct.CONTAINER_MEDIACONTROL_SHOW,this.name),this.$el.removeClass("media-control-hide"),this.hideId=setTimeout((function(){return e.hide()}),2e3),t&&(this.lastMouseX=t.clientX,this.lastMouseY=t.clientY));this.updateCursorStyle(!0)}}},{key:"hide",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this.isVisible()){var i=e||2e3;if(clearTimeout(this.hideId),this.disabled||!1!==this.options.hideMediaControl){var n=this.userKeepVisible||this.keepVisible,r=this.draggingSeekBar||this.draggingVolumeBar;if(!this.disabled&&(e||n||r))this.hideId=setTimeout((function(){return t.hide()}),i);else{this.trigger(ct.MEDIACONTROL_HIDE,this.name),this.container&&this.container.trigger(ct.CONTAINER_MEDIACONTROL_HIDE,this.name),this.$el.addClass("media-control-hide"),this.hideVolumeBar(0);this.updateCursorStyle(!1)}}}}},{key:"updateCursorStyle",value:function(t){t?this.core.$el.removeClass("nocursor"):this.core.isFullscreen()&&this.core.$el.addClass("nocursor")}},{key:"settingsUpdate",value:function(){var t=this.getSettings();!t||this.fullScreenOnVideoTagSupported||Le.fullscreenEnabled()||(t.default&&we(t.default,"fullscreen"),t.left&&we(t.left,"fullscreen"),t.right&&we(t.right,"fullscreen")),JSON.stringify(this.settings)!==JSON.stringify(t)&&(this.settings=t,this.render())}},{key:"getSettings",value:function(){return S.extend(!0,{},this.container&&this.container.settings)}},{key:"highDefinitionUpdate",value:function(t){this.isHD=t;var e=t?"addClass":"removeClass";this.$hdIndicator[e]("enabled")}},{key:"createCachedElements",value:function(){var t=this.$el.find(".media-control-layer");this.$duration=t.find(".media-control-indicator[data-duration]"),this.$fullscreenToggle=t.find("button.media-control-button[data-fullscreen]"),this.$playPauseToggle=t.find("button.media-control-button[data-playpause]"),this.$playStopToggle=t.find("button.media-control-button[data-playstop]"),this.$position=t.find(".media-control-indicator[data-position]"),this.$seekBarContainer=t.find(".bar-container[data-seekbar]"),this.$seekBarHover=t.find(".bar-hover[data-seekbar]"),this.$seekBarLoaded=t.find(".bar-fill-1[data-seekbar]"),this.$seekBarPosition=t.find(".bar-fill-2[data-seekbar]"),this.$seekBarScrubber=t.find(".bar-scrubber[data-seekbar]"),this.$volumeBarContainer=t.find(".bar-container[data-volume]"),this.$volumeContainer=t.find(".drawer-container[data-volume]"),this.$volumeIcon=t.find(".drawer-icon[data-volume]"),this.$volumeBarBackground=this.$el.find(".bar-background[data-volume]"),this.$volumeBarFill=this.$el.find(".bar-fill-1[data-volume]"),this.$volumeBarScrubber=this.$el.find(".bar-scrubber[data-volume]"),this.$hdIndicator=this.$el.find("button.media-control-button[data-hd-indicator]"),this.resetIndicators(),this.initializeIcons()}},{key:"resetIndicators",value:function(){this.displayedPosition=this.$position.text(),this.displayedDuration=this.$duration.text()}},{key:"initializeIcons",value:function(){var t=this.$el.find(".media-control-layer");t.find("button.media-control-button[data-play]").append(pe),t.find("button.media-control-button[data-pause]").append(me),t.find("button.media-control-button[data-stop]").append(be),this.$playPauseToggle.append(pe),this.$playStopToggle.append(pe),this.$volumeIcon.append(ke),this.$fullscreenToggle.append(Se),this.$hdIndicator.append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">\n <path fill="#010101" d="M5.375 7.062H2.637V4.26H.502v7.488h2.135V8.9h2.738v2.848h2.133V4.26H5.375v2.802zm5.97-2.81h-2.84v7.496h2.798c2.65 0 4.195-1.607 4.195-3.77v-.022c0-2.162-1.523-3.704-4.154-3.704zm2.06 3.758c0 1.21-.81 1.896-2.03 1.896h-.83V6.093h.83c1.22 0 2.03.696 2.03 1.896v.02z"/>\n</svg>')}},{key:"setSeekPercentage",value:function(t){t=Math.max(Math.min(t,100),0),this.displayedSeekBarPercentage!==t&&(this.displayedSeekBarPercentage=t,this.$seekBarPosition.removeClass("media-control-notransition"),this.$seekBarScrubber.removeClass("media-control-notransition"),this.$seekBarPosition.css({width:"".concat(t,"%")}),this.$seekBarScrubber.css({left:"".concat(t,"%")}))}},{key:"seekRelative",value:function(t){if(this.settings.seekEnabled){var e=this.container.getCurrentTime(),i=this.container.getDuration(),n=Math.min(Math.max(e+t,0),i);n=Math.min(100*n/i,100),this.container.seekPercentage(n)}}},{key:"bindKeyAndShow",value:function(t,e){var i=this;this.kibo.down(t,(function(){return i.show(),e()}))}},{key:"bindKeyEvents",value:function(){var t=this;if(!D.isMobile&&!this.options.disableKeyboardShortcuts){this.unbindKeyEvents(),this.kibo=new Ee(this.options.focusElement||this.options.parentElement),this.bindKeyAndShow("space",(function(){return t.togglePlayPause()})),this.bindKeyAndShow("left",(function(){return t.seekRelative(-5)})),this.bindKeyAndShow("right",(function(){return t.seekRelative(5)})),this.bindKeyAndShow("shift left",(function(){return t.seekRelative(-10)})),this.bindKeyAndShow("shift right",(function(){return t.seekRelative(10)})),this.bindKeyAndShow("shift ctrl left",(function(){return t.seekRelative(-15)})),this.bindKeyAndShow("shift ctrl right",(function(){return t.seekRelative(15)}));["1","2","3","4","5","6","7","8","9","0"].forEach((function(e){t.bindKeyAndShow(e,(function(){t.settings.seekEnabled&&t.container&&t.container.seekPercentage(10*e)}))}))}}},{key:"unbindKeyEvents",value:function(){this.kibo&&(this.kibo.off("space"),this.kibo.off("left"),this.kibo.off("right"),this.kibo.off("shift left"),this.kibo.off("shift right"),this.kibo.off("shift ctrl left"),this.kibo.off("shift ctrl right"),this.kibo.off(["1","2","3","4","5","6","7","8","9","0"]))}},{key:"parseColors",value:function(){if(this.options.mediacontrol){this.buttonsColor=this.options.mediacontrol.buttons;var t=this.options.mediacontrol.seekbar;this.$el.find(".bar-fill-2[data-seekbar]").css("background-color",t),this.$el.find(".media-control-icon svg path").css("fill",this.buttonsColor),this.$el.find(".segmented-bar-element[data-volume]").css("boxShadow","inset 2px 0 0 "+this.buttonsColor)}}},{key:"applyButtonStyle",value:function(t){this.buttonsColor&&t&&S(t).find("svg path").css("fill",this.buttonsColor)}},{key:"destroy",value:function(){S(document).unbind("mouseup",this.stopDragHandler),S(document).unbind("mousemove",this.updateDragHandler),this.unbindKeyEvents(),this.stopListening(),ce(ae(e.prototype),"destroy",this).call(this)}},{key:"configure",value:function(t){this.options.chromeless||t.source||t.sources?this.disable():this.enable(),this.trigger(ct.MEDIACONTROL_OPTIONS_CHANGE)}},{key:"render",value:function(){var t=this,e=this.options.hideMediaControlDelay||2e3;this.settings&&this.$el.html(this.template({settings:this.settings}));var i=Et.getStyleFor('.media-control-notransition {\n transition: none !important; }\n\n.media-control[data-media-control] {\n position: absolute;\n width: 100%;\n height: 100%;\n z-index: 9999;\n pointer-events: none; }\n .media-control[data-media-control].dragging {\n pointer-events: auto;\n cursor: grabbing !important;\n cursor: url("closed-hand.cur"), move; }\n .media-control[data-media-control].dragging * {\n cursor: grabbing !important;\n cursor: url("closed-hand.cur"), move; }\n .media-control[data-media-control] .media-control-background[data-background] {\n position: absolute;\n height: 40%;\n width: 100%;\n bottom: 0;\n background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));\n will-change: transform, opacity;\n transition: opacity 0.6s ease-out; }\n .media-control[data-media-control] .media-control-icon {\n line-height: 0;\n letter-spacing: 0;\n speak: none;\n color: #fff;\n opacity: 0.5;\n vertical-align: middle;\n text-align: left;\n transition: all 0.1s ease; }\n .media-control[data-media-control] .media-control-icon:hover {\n color: white;\n opacity: 0.75;\n text-shadow: rgba(255, 255, 255, 0.8) 0 0 5px; }\n .media-control[data-media-control].media-control-hide .media-control-background[data-background] {\n opacity: 0; }\n .media-control[data-media-control].media-control-hide .media-control-layer[data-controls] {\n transform: translateY(50px); }\n .media-control[data-media-control].media-control-hide .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-scrubber[data-seekbar] {\n opacity: 0; }\n .media-control[data-media-control] .media-control-layer[data-controls] {\n position: absolute;\n transform: translateY(-7px);\n bottom: 0;\n width: 100%;\n height: 32px;\n font-size: 0;\n vertical-align: middle;\n pointer-events: auto;\n transition: bottom 0.4s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-left-panel[data-media-control] {\n position: absolute;\n top: 0;\n left: 4px;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-center-panel[data-media-control] {\n height: 100%;\n text-align: center;\n line-height: 32px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-right-panel[data-media-control] {\n position: absolute;\n top: 0;\n right: 4px;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button {\n background-color: transparent;\n border: 0;\n margin: 0 6px;\n padding: 0;\n cursor: pointer;\n display: inline-block;\n width: 32px;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button svg {\n width: 100%;\n height: 22px; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button svg path {\n fill: white; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button:focus {\n outline: none; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-play] {\n float: left;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-pause] {\n float: left;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-stop] {\n float: left;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-fullscreen] {\n float: right;\n background-color: transparent;\n border: 0;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-hd-indicator] {\n background-color: transparent;\n border: 0;\n cursor: default;\n display: none;\n float: right;\n height: 100%; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-hd-indicator].enabled {\n display: block;\n opacity: 1.0; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-hd-indicator].enabled:hover {\n opacity: 1.0;\n text-shadow: none; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-playpause] {\n float: left; }\n .media-control[data-media-control] .media-control-layer[data-controls] button.media-control-button[data-playstop] {\n float: left; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-indicator[data-position], .media-control[data-media-control] .media-control-layer[data-controls] .media-control-indicator[data-duration] {\n display: inline-block;\n font-size: 10px;\n color: white;\n cursor: default;\n line-height: 32px;\n position: relative; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-indicator[data-position] {\n margin: 0 6px 0 7px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-indicator[data-duration] {\n color: rgba(255, 255, 255, 0.5);\n margin-right: 6px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .media-control-indicator[data-duration]:before {\n content: "|";\n margin-right: 7px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] {\n position: absolute;\n top: -20px;\n left: 0;\n display: inline-block;\n vertical-align: middle;\n width: 100%;\n height: 25px;\n cursor: pointer; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] {\n width: 100%;\n height: 1px;\n position: relative;\n top: 12px;\n background-color: #666666; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] .bar-fill-1[data-seekbar] {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n background-color: #c2c2c2;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] .bar-fill-2[data-seekbar] {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n background-color: #005aff;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-background[data-seekbar] .bar-hover[data-seekbar] {\n opacity: 0;\n position: absolute;\n top: -3px;\n width: 5px;\n height: 7px;\n background-color: rgba(255, 255, 255, 0.5);\n transition: opacity 0.1s ease; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar]:hover .bar-background[data-seekbar] .bar-hover[data-seekbar] {\n opacity: 1; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar].seek-disabled {\n cursor: default; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar].seek-disabled:hover .bar-background[data-seekbar] .bar-hover[data-seekbar] {\n opacity: 0; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-scrubber[data-seekbar] {\n position: absolute;\n transform: translateX(-50%);\n top: 2px;\n left: 0;\n width: 20px;\n height: 20px;\n opacity: 1;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .bar-container[data-seekbar] .bar-scrubber[data-seekbar] .bar-scrubber-icon[data-seekbar] {\n position: absolute;\n left: 6px;\n top: 6px;\n width: 8px;\n height: 8px;\n border-radius: 10px;\n box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.2);\n background-color: white; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] {\n float: right;\n display: inline-block;\n height: 32px;\n cursor: pointer;\n margin: 0 6px;\n box-sizing: border-box; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] {\n float: left;\n bottom: 0; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] .drawer-icon[data-volume] {\n background-color: transparent;\n border: 0;\n box-sizing: content-box;\n width: 32px;\n height: 32px;\n opacity: 0.5; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] .drawer-icon[data-volume]:hover {\n opacity: 0.75; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] .drawer-icon[data-volume] svg {\n height: 24px;\n position: relative;\n top: 3px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] .drawer-icon[data-volume] svg path {\n fill: white; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .drawer-icon-container[data-volume] .drawer-icon[data-volume].muted svg {\n margin-left: 2px; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] {\n float: left;\n position: relative;\n overflow: hidden;\n top: 6px;\n width: 42px;\n height: 18px;\n padding: 3px 0;\n transition: width .2s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-background[data-volume] {\n height: 1px;\n position: relative;\n top: 7px;\n margin: 0 3px;\n background-color: #666666; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-background[data-volume] .bar-fill-1[data-volume] {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n background-color: #c2c2c2;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-background[data-volume] .bar-fill-2[data-volume] {\n position: absolute;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n background-color: #005aff;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-background[data-volume] .bar-hover[data-volume] {\n opacity: 0;\n position: absolute;\n top: -3px;\n width: 5px;\n height: 7px;\n background-color: rgba(255, 255, 255, 0.5);\n transition: opacity 0.1s ease; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-scrubber[data-volume] {\n position: absolute;\n transform: translateX(-50%);\n top: 0px;\n left: 0;\n width: 20px;\n height: 20px;\n opacity: 1;\n transition: all 0.1s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .bar-scrubber[data-volume] .bar-scrubber-icon[data-volume] {\n position: absolute;\n left: 6px;\n top: 6px;\n width: 8px;\n height: 8px;\n border-radius: 10px;\n box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.2);\n background-color: white; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .segmented-bar-element[data-volume] {\n float: left;\n width: 4px;\n padding-left: 2px;\n height: 12px;\n opacity: 0.5;\n box-shadow: inset 2px 0 0 white;\n transition: transform .2s ease-out; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .segmented-bar-element[data-volume].fill {\n box-shadow: inset 2px 0 0 #fff;\n opacity: 1; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .segmented-bar-element[data-volume]:nth-of-type(1) {\n padding-left: 0; }\n .media-control[data-media-control] .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume] .segmented-bar-element[data-volume]:hover {\n transform: scaleY(1.5); }\n .media-control[data-media-control].w320 .media-control-layer[data-controls] .drawer-container[data-volume] .bar-container[data-volume].volume-bar-hide {\n width: 0;\n height: 12px;\n top: 9px;\n padding: 0; }\n',{baseUrl:this.options.baseUrl});this.$el.append(i[0]),this.createCachedElements(),this.$playPauseToggle.addClass("paused"),this.$playStopToggle.addClass("stopped"),this.changeTogglePlay(),this.container&&(this.hideId=setTimeout((function(){return t.hide()}),e),this.disabled&&this.hide()),D.isSafari&&D.isMobile&&(D.version<10?this.$volumeContainer.css("display","none"):this.$volumeBarContainer.css("display","none")),this.$seekBarPosition.addClass("media-control-notransition"),this.$seekBarScrubber.addClass("media-control-notransition");var n=0;return this.displayedSeekBarPercentage&&(n=this.displayedSeekBarPercentage),this.displayedSeekBarPercentage=null,this.setSeekPercentage(n),setTimeout((function(){!t.settings.seekEnabled&&t.$seekBarContainer.addClass("seek-disabled"),!D.isMobile&&!t.options.disableKeyboardShortcuts&&t.bindKeyEvents(),t.playerResize({width:t.options.width,height:t.options.height}),t.hideVolumeBar(0)}),0),this.parseColors(),this.highDefinitionUpdate(this.isHD),this.core.$el.append(this.el),this.rendered=!0,this.updateVolumeUI(),this.trigger(ct.MEDIACONTROL_RENDERED),this}}])}(_t);Ie.extend=function(t){return Ce(Ie,t)};for(var De=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).hasStartedPlaying=!1,i.playRequested=!1,i.render(),setTimeout((function(){return i.update()}),0),i}return se(e,t),re(e,[{key:"name",get:function(){return"poster"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"template",get:function(){return At('<div class="play-wrapper" data-poster></div>\n')}},{key:"shouldRender",get:function(){var t=!(!this.options.poster||!this.options.poster.showForNoOp);return"html_img"!==this.container.playback.name&&(this.container.playback.getPlaybackType()!==Rt.NO_OP||t)}},{key:"attributes",get:function(){return{class:"player-poster","data-poster":""}}},{key:"events",get:function(){return{click:"clicked"}}},{key:"showOnVideoEnd",get:function(){return!this.options.poster||this.options.poster.showOnVideoEnd||void 0===this.options.poster.showOnVideoEnd}},{key:"bindEvents",value:function(){this.listenTo(this.container,ct.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ct.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERING,this.update),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERFULL,this.update),this.listenTo(this.container,ct.CONTAINER_OPTIONS_CHANGE,this.render),this.listenTo(this.container,ct.CONTAINER_ERROR,this.onError),this.showOnVideoEnd&&this.listenTo(this.container,ct.CONTAINER_ENDED,this.onStop)}},{key:"onError",value:function(t){this.hasFatalError=t.level===kt.Levels.FATAL,this.hasFatalError&&(this.hasStartedPlaying=!1,this.playRequested=!1,this.showPlayButton())}},{key:"onPlay",value:function(){this.hasStartedPlaying=!0,this.update()}},{key:"onStop",value:function(){this.hasStartedPlaying=!1,this.playRequested=!1,this.update()}},{key:"updatePlayButton",value:function(t){!t||this.options.chromeless&&!this.options.allowUserInteraction?this.hidePlayButton():this.showPlayButton()}},{key:"showPlayButton",value:function(){this.hasFatalError&&!this.options.disableErrorScreen||(this.$playButton.show(),this.$el.addClass("clickable"))}},{key:"hidePlayButton",value:function(){this.$playButton.hide(),this.$el.removeClass("clickable")}},{key:"clicked",value:function(){if(!this.hasStartedPlaying)return this.options.chromeless&&!this.options.allowUserInteraction||(this.playRequested=!0,this.update(),this.container.playback&&(this.container.playback._consented=!0),this.container.play()),!1}},{key:"shouldHideOnPlay",value:function(){return!this.container.playback.isAudioOnly}},{key:"update",value:function(){if(this.shouldRender){var t=!this.playRequested&&!this.hasStartedPlaying&&!this.container.buffering;this.updatePlayButton(t),this.updatePoster()}}},{key:"updatePoster",value:function(){this.hasStartedPlaying?this.hidePoster():this.showPoster()}},{key:"showPoster",value:function(){this.container.disableMediaControl(),this.$el.show()}},{key:"hidePoster",value:function(){this.container.enableMediaControl(),this.shouldHideOnPlay()&&this.$el.hide()}},{key:"render",value:function(){if(this.shouldRender){var t=Et.getStyleFor(".player-poster[data-poster] {\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute;\n height: 100%;\n width: 100%;\n z-index: 998;\n top: 0;\n left: 0;\n background-color: transparent;\n background-size: cover;\n background-repeat: no-repeat;\n background-position: 50% 50%; }\n .player-poster[data-poster].clickable {\n cursor: pointer; }\n .player-poster[data-poster]:hover .play-wrapper[data-poster] {\n opacity: 1; }\n .player-poster[data-poster] .play-wrapper[data-poster] {\n width: 100%;\n height: 25%;\n margin: 0 auto;\n opacity: 0.75;\n transition: opacity 0.1s ease; }\n .player-poster[data-poster] .play-wrapper[data-poster] svg {\n height: 100%; }\n .player-poster[data-poster] .play-wrapper[data-poster] svg path {\n fill: #fff; }\n",{baseUrl:this.options.baseUrl});if(this.$el.html(this.template()),this.$el.append(t[0]),this.options.poster&&void 0===this.options.poster.custom){var e=this.options.poster.url||this.options.poster;this.$el.css({"background-image":"url("+e+")"}),this.removeVideoElementPoster()}else this.options.poster&&(this.$el.css({background:this.options.poster.custom}),this.removeVideoElementPoster());this.container.$el.append(this.el),this.$playWrapper=this.$el.find(".play-wrapper"),this.$playWrapper.append(pe),this.$playButton=this.$playWrapper.find("svg"),this.$playButton.addClass("poster-icon"),this.$playButton.attr("data-poster","");var i=this.options.mediacontrol&&this.options.mediacontrol.buttons;return i&&this.$el.find("svg path").css("fill",i),this.options.mediacontrol&&this.options.mediacontrol.buttons&&(i=this.options.mediacontrol.buttons,this.$playButton.css("color",i)),this.update(),this}}},{key:"removeVideoElementPoster",value:function(){this.container.playback&&this.container.playback.$el&&this.container.playback.$el[0]&&this.container.playback.$el[0].removeAttribute&&this.container.playback.$el[0].removeAttribute("poster")}}])}(Gt),Pe=Z.formatTime,Oe=function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).hoveringOverSeekBar=!1,i.hoverPosition=null,i.duration=null,i.firstFragDateTime=null,i.actualLiveTime=!!i.mediaControl.options.actualLiveTime,i.actualLiveTime&&(i.mediaControl.options.actualLiveServerTime?i.actualLiveServerTimeDiff=(new Date).getTime()-new Date(i.mediaControl.options.actualLiveServerTime).getTime():i.actualLiveServerTimeDiff=0),i}return se(e,t),re(e,[{key:"name",get:function(){return"seek_time"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"template",get:function(){return At("<span data-seek-time></span>\n<span data-duration></span>\n")}},{key:"attributes",get:function(){return{class:"seek-time","data-seek-time":""}}},{key:"mediaControl",get:function(){return this.core.mediaControl}},{key:"mediaControlContainer",get:function(){return this.mediaControl.container}},{key:"isLiveStreamWithDvr",get:function(){return this.mediaControlContainer&&this.mediaControlContainer.getPlaybackType()===Rt.LIVE&&this.mediaControlContainer.isDvrEnabled()}},{key:"durationShown",get:function(){return this.isLiveStreamWithDvr&&!this.actualLiveTime}},{key:"useActualLiveTime",get:function(){return this.actualLiveTime&&this.isLiveStreamWithDvr}},{key:"bindEvents",value:function(){this.listenTo(this.mediaControl,ct.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.mediaControl,ct.MEDIACONTROL_MOUSEMOVE_SEEKBAR,this.showTime),this.listenTo(this.mediaControl,ct.MEDIACONTROL_MOUSELEAVE_SEEKBAR,this.hideTime),this.listenTo(this.mediaControl,ct.MEDIACONTROL_CONTAINERCHANGED,this.onContainerChanged),this.mediaControlContainer&&(this.listenTo(this.mediaControlContainer,ct.CONTAINER_PLAYBACKDVRSTATECHANGED,this.update),this.listenTo(this.mediaControlContainer,ct.CONTAINER_TIMEUPDATE,this.updateDuration))}},{key:"onContainerChanged",value:function(){this.stopListening(),this.bindEvents()}},{key:"updateDuration",value:function(t){this.duration=t.total,this.firstFragDateTime=t.firstFragDateTime,this.update()}},{key:"showTime",value:function(t){this.hoveringOverSeekBar=!0,this.calculateHoverPosition(t),this.update()}},{key:"hideTime",value:function(){this.hoveringOverSeekBar=!1,this.update()}},{key:"calculateHoverPosition",value:function(t){var e=t.pageX-this.mediaControl.$seekBarContainer.offset().left;this.hoverPosition=Math.min(1,Math.max(e/this.mediaControl.$seekBarContainer.width(),0))}},{key:"getSeekTime",value:function(){var t,e,i,n;return this.useActualLiveTime?(this.firstFragDateTime?(n=new Date(this.firstFragDateTime),(i=new Date(this.firstFragDateTime)).setHours(0,0,0,0),e=(n.getTime()-i.getTime())/1e3+this.duration):(i=new Date((new Date).getTime()-this.actualLiveServerTimeDiff),e=((n=new Date(i))-i.setHours(0,0,0,0))/1e3),(t=e-this.duration+this.hoverPosition*this.duration)<0&&(t+=86400)):t=this.hoverPosition*this.duration,{seekTime:t,secondsSinceMidnight:e}}},{key:"update",value:function(){if(this.rendered)if(this.shouldBeVisible()){var t=this.getSeekTime(),e=Pe(t.seekTime,this.useActualLiveTime);if(e!==this.displayedSeekTime&&(this.$seekTimeEl.text(e),this.displayedSeekTime=e),this.durationShown){this.$durationEl.show();var i=Pe(this.actualLiveTime?t.secondsSinceMidnight:this.duration,this.actualLiveTime);i!==this.displayedDuration&&(this.$durationEl.text(i),this.displayedDuration=i)}else this.$durationEl.hide();this.$el.show();var n=this.mediaControl.$seekBarContainer.width(),r=this.$el.width(),s=this.hoverPosition*n;s-=r/2,s=Math.max(0,Math.min(s,n-r)),this.$el.css("left",s)}else this.$el.hide(),this.$el.css("left","-100%")}},{key:"shouldBeVisible",value:function(){return this.mediaControlContainer&&this.mediaControlContainer.settings.seekEnabled&&this.hoveringOverSeekBar&&null!==this.hoverPosition&&null!==this.duration}},{key:"render",value:function(){var t=Et.getStyleFor('.seek-time[data-seek-time] {\n position: absolute;\n white-space: nowrap;\n height: 20px;\n line-height: 20px;\n font-size: 0;\n left: -100%;\n bottom: 55px;\n background-color: rgba(2, 2, 2, 0.5);\n z-index: 9999;\n transition: opacity 0.1s ease; }\n .seek-time[data-seek-time].hidden[data-seek-time] {\n opacity: 0; }\n .seek-time[data-seek-time] [data-seek-time] {\n display: inline-block;\n color: white;\n font-size: 10px;\n padding-left: 7px;\n padding-right: 7px;\n vertical-align: top; }\n .seek-time[data-seek-time] [data-duration] {\n display: inline-block;\n color: rgba(255, 255, 255, 0.5);\n font-size: 10px;\n padding-right: 7px;\n vertical-align: top; }\n .seek-time[data-seek-time] [data-duration]:before {\n content: "|";\n margin-right: 7px; }\n',{baseUrl:this.options.baseUrl});this.rendered=!0,this.displayedDuration=null,this.displayedSeekTime=null,this.$el.html(this.template()),this.$el.append(t[0]),this.$el.hide(),this.mediaControl.$el.append(this.el),this.$seekTimeEl=this.$el.find("[data-seek-time]"),this.$durationEl=this.$el.find("[data-duration]"),this.$durationEl.hide(),this.update()}}])}(_t),xe={ClickToPause:he,ClosedCaptions:ue,DVRControls:de,EndVideo:fe,ErrorScreen:ge,Favicon:ye,GoogleAnalytics:Ae,MediaControl:Ie,Poster:De,SeekTime:Oe,SpinnerThreeBounce:function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).template=At("<div data-bounce1></div><div data-bounce2></div><div data-bounce3></div>\n"),i.showTimeout=null,i.listenTo(i.container,ct.CONTAINER_STATE_BUFFERING,i.onBuffering),i.listenTo(i.container,ct.CONTAINER_STATE_BUFFERFULL,i.onBufferFull),i.listenTo(i.container,ct.CONTAINER_STOP,i.onStop),i.listenTo(i.container,ct.CONTAINER_ENDED,i.onStop),i.listenTo(i.container,ct.CONTAINER_ERROR,i.onStop),i.render(),i}return se(e,t),re(e,[{key:"name",get:function(){return"spinner"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"attributes",get:function(){return{"data-spinner":"",class:"spinner-three-bounce"}}},{key:"onBuffering",value:function(){this.show()}},{key:"onBufferFull",value:function(){this.hide()}},{key:"onStop",value:function(){this.hide()}},{key:"show",value:function(){var t=this;null===this.showTimeout&&(this.showTimeout=setTimeout((function(){return t.$el.show()}),300))}},{key:"hide",value:function(){null!==this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),this.$el.hide()}},{key:"render",value:function(){var t=Et.getStyleFor(".spinner-three-bounce[data-spinner] {\n position: absolute;\n margin: 0 auto;\n width: 70px;\n text-align: center;\n z-index: 999;\n left: 0;\n right: 0;\n margin-left: auto;\n margin-right: auto;\n /* center vertically */\n top: 50%;\n transform: translateY(-50%); }\n .spinner-three-bounce[data-spinner] > div {\n width: 18px;\n height: 18px;\n background-color: #FFFFFF;\n border-radius: 100%;\n display: inline-block;\n animation: bouncedelay 1.4s infinite ease-in-out;\n /* Prevent first frame from flickering when animation starts */\n animation-fill-mode: both; }\n .spinner-three-bounce[data-spinner] [data-bounce1] {\n animation-delay: -0.32s; }\n .spinner-three-bounce[data-spinner] [data-bounce2] {\n animation-delay: -0.16s; }\n\n@keyframes bouncedelay {\n 0%, 80%, 100% {\n transform: scale(0); }\n 40% {\n transform: scale(1); } }\n",{baseUrl:this.options.baseUrl});return this.$el.html(this.template()),this.$el.append(t[0]),this.container.$el.append(this.$el),this.$el.hide(),this.container.buffering&&this.onBuffering(),this}}])}(Gt),Stats:function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).setInitialAttrs(),i.reportInterval=i.options.reportInterval||5e3,i.state="IDLE",i}return se(e,t),re(e,[{key:"name",get:function(){return"stats"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"bindEvents",value:function(){this.listenTo(this.container.playback,ct.PLAYBACK_PLAY,this.onPlay),this.listenTo(this.container,ct.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ct.CONTAINER_ENDED,this.onStop),this.listenTo(this.container,ct.CONTAINER_DESTROYED,this.onStop),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERING,this.onBuffering),this.listenTo(this.container,ct.CONTAINER_STATE_BUFFERFULL,this.onBufferFull),this.listenTo(this.container,ct.CONTAINER_STATS_ADD,this.onStatsAdd),this.listenTo(this.container,ct.CONTAINER_BITRATE,this.onStatsAdd),this.listenTo(this.container.playback,ct.PLAYBACK_STATS_ADD,this.onStatsAdd)}},{key:"setInitialAttrs",value:function(){this.firstPlay=!0,this.startupTime=0,this.rebufferingTime=0,this.watchingTime=0,this.rebuffers=0,this.externalMetrics={}}},{key:"onPlay",value:function(){this.state="PLAYING",this.watchingTimeInit=Date.now(),this.intervalId||(this.intervalId=setInterval(this.report.bind(this),this.reportInterval))}},{key:"onStop",value:function(){clearInterval(this.intervalId),this.report(),this.intervalId=void 0,this.state="STOPPED"}},{key:"onBuffering",value:function(){this.firstPlay?this.startupTimeInit=Date.now():this.rebufferingTimeInit=Date.now(),this.state="BUFFERING",this.rebuffers++}},{key:"onBufferFull",value:function(){this.firstPlay&&this.startupTimeInit?(this.firstPlay=!1,this.startupTime=Date.now()-this.startupTimeInit,this.watchingTimeInit=Date.now()):this.rebufferingTimeInit&&(this.rebufferingTime+=this.getRebufferingTime()),this.rebufferingTimeInit=void 0,this.state="PLAYING"}},{key:"getRebufferingTime",value:function(){return Date.now()-this.rebufferingTimeInit}},{key:"getWatchingTime",value:function(){return Date.now()-this.watchingTimeInit-this.rebufferingTime}},{key:"isRebuffering",value:function(){return!!this.rebufferingTimeInit}},{key:"onStatsAdd",value:function(t){S.extend(this.externalMetrics,t)}},{key:"getStats",value:function(){var t={startupTime:this.startupTime,rebuffers:this.rebuffers,rebufferingTime:this.isRebuffering()?this.rebufferingTime+this.getRebufferingTime():this.rebufferingTime,watchingTime:this.isRebuffering()?this.getWatchingTime()-this.getRebufferingTime():this.getWatchingTime()};return S.extend(t,this.externalMetrics),t}},{key:"report",value:function(){this.container.statsReport(this.getStats())}}])}(Ut),WaterMark:function(t){function e(t){var i;return ie(this,e),(i=Jt(this,e,[t])).configure(),i}return se(e,t),re(e,[{key:"name",get:function(){return"watermark"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"template",get:function(){return At('<div class="clappr-watermark" data-watermark data-watermark-<%=position %>>\n<% if(typeof imageLink !== \'undefined\') { %>\n<a target="_blank" href="<%= imageLink %>">\n<% } %>\n<img src="<%= imageUrl %>">\n<% if(typeof imageLink !== \'undefined\') { %>\n</a>\n<% } %>\n</div>\n')}},{key:"bindEvents",value:function(){this.listenTo(this.container,ct.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ct.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ct.CONTAINER_OPTIONS_CHANGE,this.configure)}},{key:"configure",value:function(){this.position=this.options.position||"bottom-right",this.options.watermark?(this.imageUrl=this.options.watermark,this.imageLink=this.options.watermarkLink,this.render()):this.$el.remove()}},{key:"onPlay",value:function(){this.hidden||this.$el.show()}},{key:"onStop",value:function(){this.$el.hide()}},{key:"render",value:function(){this.$el.hide();var t=Et.getStyleFor(".clappr-watermark[data-watermark] {\n position: absolute;\n min-width: 70px;\n max-width: 200px;\n width: 12%;\n text-align: center;\n z-index: 10; }\n\n.clappr-watermark[data-watermark] a {\n outline: none;\n cursor: pointer; }\n\n.clappr-watermark[data-watermark] img {\n max-width: 100%; }\n\n.clappr-watermark[data-watermark-bottom-left] {\n bottom: 10px;\n left: 10px; }\n\n.clappr-watermark[data-watermark-bottom-right] {\n bottom: 10px;\n right: 42px; }\n\n.clappr-watermark[data-watermark-top-left] {\n top: 10px;\n left: 10px; }\n\n.clappr-watermark[data-watermark-top-right] {\n top: 10px;\n right: 37px; }\n",{baseUrl:this.options.baseUrl}),e={position:this.position,imageUrl:this.imageUrl,imageLink:this.imageLink};return this.$el.html(this.template(e)),this.$el.append(t[0]),this.container.$el.append(this.$el),this}}])}(Gt)},Ne=0,Me=Object.values(xe);Ne<Me.length;Ne++){var Fe=Me[Ne];Mt.registerPlugin(Fe)}var Be=xe.ClickToPause,Ue=xe.ClosedCaptions,$e=xe.DVRControls,Ge=xe.EndVideo,Ve=xe.ErrorScreen,Ke=xe.Favicon,He=xe.GoogleAnalytics,Ye=xe.MediaControl,je=xe.Poster,We=xe.SeekTime,ze=xe.SpinnerThreeBounce,qe=xe.Stats,Xe=xe.WaterMark,Qe=e(e({},Zt),{},{ClickToPause:Be,ClosedCaptions:Ue,DVRControls:$e,EndVideo:Ge,ErrorScreen:Ve,Favicon:Ke,GoogleAnalytics:He,MediaControl:Ye,Poster:je,SeekTime:We,SpinnerThreeBounce:ze,Stats:qe,WaterMark:Xe,Vendor:Te,Plugins:xe,version:"0.11.2"});function Ze(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function Je(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?Ze(Object(i),!0).forEach((function(e){ei(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):Ze(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function ti(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ci(n.key),n)}}function ei(t,e,i){return(e=ci(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ii(t){return ii=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ii(t)}function ni(t,e){return ni=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ni(t,e)}function ri(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function si(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=ii(t);if(e){var r=ii(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return ri(this,i)}}function ai(){return ai="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=ii(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},ai.apply(this,arguments)}function oi(t){return function(t){if(Array.isArray(t))return li(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return li(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return li(t,e)}(t)||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.")}()}function li(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function ci(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function hi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ui,di,fi,gi,pi,mi={exports:{}};ui=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,di=/^(?=([^\/?#]*))\1([^]*)$/,fi=/(?:\/|^)\.(?=\/)/g,gi=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,mi.exports=pi={buildAbsoluteURL:function(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;var n=pi.parseURL(t);if(!n)throw new Error("Error trying to parse base URL.");return n.path=pi.normalizePath(n.path),pi.buildURLFromParts(n)}var r=pi.parseURL(e);if(!r)throw new Error("Error trying to parse relative URL.");if(r.scheme)return i.alwaysNormalize?(r.path=pi.normalizePath(r.path),pi.buildURLFromParts(r)):e;var s=pi.parseURL(t);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){var a=di.exec(s.path);s.netLoc=a[1],s.path=a[2]}s.netLoc&&!s.path&&(s.path="/");var o={scheme:s.scheme,netLoc:r.netLoc,path:null,params:r.params,query:r.query,fragment:r.fragment};if(!r.netLoc&&(o.netLoc=s.netLoc,"/"!==r.path[0]))if(r.path){var l=s.path,c=l.substring(0,l.lastIndexOf("/")+1)+r.path;o.path=pi.normalizePath(c)}else o.path=s.path,r.params||(o.params=s.params,r.query||(o.query=s.query));return null===o.path&&(o.path=i.alwaysNormalize?pi.normalizePath(r.path):r.path),pi.buildURLFromParts(o)},parseURL:function(t){var e=ui.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(fi,"");t.length!==(t=t.replace(gi,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}};var vi=mi.exports;function yi(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function Ai(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?yi(Object(i),!0).forEach((function(e){Ti(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):yi(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function Ei(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function Ti(t,e,i){return(e=Ei(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function bi(){return bi=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},bi.apply(this,arguments)}const ki=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},Si=Number.isSafeInteger||function(t){return"number"==typeof t&&Math.abs(t)<=_i},_i=Number.MAX_SAFE_INTEGER||9007199254740991;let Li=function(t){return t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached",t.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",t}({}),Ri=function(t){return t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t}({}),Ci=function(t){return t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown",t}({});const wi=function(){},Ii={trace:wi,debug:wi,log:wi,warn:wi,info:wi,error:wi};let Di=Ii;function Pi(t,...e){e.forEach((function(e){Di[e]=t[e]?t[e].bind(t):function(t){const e=self.console[t];return e?e.bind(self.console,`[${t}] >`):wi}(e)}))}const Oi=Di,xi=/^(\d+)x(\d+)$/,Ni=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Mi{constructor(t){"string"==typeof t&&(t=Mi.parseAttrList(t)),bi(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 i=new Uint8Array(e.length/2);for(let t=0;t<e.length/2;t++)i[t]=parseInt(e.slice(2*t,2*t+2),16);return i}return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const i=this[t];return i?parseFloat(i):e}enumeratedString(t){return this[t]}bool(t){return"YES"===this[t]}decimalResolution(t){const e=xi.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={};for(Ni.lastIndex=0;null!==(e=Ni.exec(t));){let t=e[2];0===t.indexOf('"')&&t.lastIndexOf('"')===t.length-1&&(t=t.slice(1,-1));i[e[1].trim()]=t}return i}}function Fi(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}class Bi{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const i=e.attr;for(const e in i)if(Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==i[e]){Oi.warn(`DATERANGE tag attribute: "${e}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=e;break}t=bi(new Mi({}),i,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"]);ki(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(ki(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&&ki(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Ui{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 $i="audio",Gi="video",Vi="audiovideo";class Ki{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[$i]:null,[Gi]:null,[Vi]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2);let n;n=1===i.length?(null==e?void 0:e.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[n,parseInt(i[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=vi.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class Hi extends Ki{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 Ui,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(!ki(this.programDateTime))return null;const t=ki(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,i,n,r,s=!1){const{elementaryStreams:a}=this,o=a[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,i),o.startDTS=Math.min(o.startDTS,n),o.endDTS=Math.max(o.endDTS,r)):a[t]={startPTS:e,endPTS:i,startDTS:n,endDTS:r,partial:s}}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[$i]=null,t[Gi]=null,t[Vi]=null}}class Yi extends Ki{constructor(t,e,i,n,r){super(i),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 Ui,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,r),r&&(this.fragOffset=r.fragOffset+r.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 ji{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,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&i>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&&ki(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 Wi(t){return Uint8Array.from(atob(t),(t=>t.charCodeAt(0)))}function zi(t){const e=t.split(":");let i=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],r=n[1];e?(t.splice(-1,1),i=Wi(r)):i=function(t){const e=qi(t).subarray(0,16),i=new Uint8Array(16);return i.set(e,16-e.length),i}(r)}}return i}function qi(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(t=>t.charCodeAt(0)))}const Xi="undefined"!=typeof self?self:void 0;var Qi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Zi="org.w3.clearkey",Ji="com.apple.streamingkeydelivery",tn="com.microsoft.playready",en="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function nn(t){switch(t){case Ji:return Qi.FAIRPLAY;case tn:return Qi.PLAYREADY;case en:return Qi.WIDEVINE;case Zi:return Qi.CLEARKEY}}var rn="edef8ba979d64acea3c827dcd51d21ed";function sn(t){switch(t){case Qi.FAIRPLAY:return Ji;case Qi.PLAYREADY:return tn;case Qi.WIDEVINE:return en;case Qi.CLEARKEY:return Zi}}function an(t){const{drmSystems:e,widevineLicenseUrl:i}=t,n=e?[Qi.FAIRPLAY,Qi.WIDEVINE,Qi.PLAYREADY,Qi.CLEARKEY].filter((t=>!!e[t])):[];return!n[Qi.WIDEVINE]&&i&&n.push(Qi.WIDEVINE),n}const on=null!=Xi&&null!=(ln=Xi.navigator)&&ln.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var ln;function cn(t,e,i){return Uint8Array.prototype.slice?t.slice(e,i):new Uint8Array(Array.prototype.slice.call(t,e,i))}const hn=(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,un=(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,dn=(t,e)=>{const i=e;let n=0;for(;hn(t,e);){n+=10;n+=fn(t,e+6),un(t,e+10)&&(n+=10),e+=n}if(n>0)return t.subarray(i,i+n)},fn=(t,e)=>{let i=0;return i=(127&t[e])<<21,i|=(127&t[e+1])<<14,i|=(127&t[e+2])<<7,i|=127&t[e+3],i},gn=(t,e)=>hn(t,e)&&fn(t,e+6)+10<=t.length-e,pn=t=>{const e=yn(t);for(let t=0;t<e.length;t++){const i=e[t];if(mn(i))return kn(i)}},mn=t=>t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info,vn=t=>{const e=String.fromCharCode(t[0],t[1],t[2],t[3]),i=fn(t,4);return{type:e,size:i,data:t.subarray(10,10+i)}},yn=t=>{let e=0;const i=[];for(;hn(t,e);){const n=fn(t,e+6);e+=10;const r=e+n;for(;e+8<r;){const n=vn(t.subarray(e)),r=An(n);r&&i.push(r),e+=n.size+10}un(t,e)&&(e+=10)}return i},An=t=>"PRIV"===t.type?En(t):"W"===t.type[0]?bn(t):Tn(t),En=t=>{if(t.size<2)return;const e=Sn(t.data,!0),i=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:i.buffer}},Tn=t=>{if(t.size<2)return;if("TXXX"===t.type){let e=1;const i=Sn(t.data.subarray(e),!0);e+=i.length+1;const n=Sn(t.data.subarray(e));return{key:t.type,info:i,data:n}}const e=Sn(t.data.subarray(1));return{key:t.type,data:e}},bn=t=>{if("WXXX"===t.type){if(t.size<2)return;let e=1;const i=Sn(t.data.subarray(e),!0);e+=i.length+1;const n=Sn(t.data.subarray(e));return{key:t.type,info:i,data:n}}const e=Sn(t.data);return{key:t.type,data:e}},kn=t=>{if(8===t.data.byteLength){const e=new Uint8Array(t.data),i=1&e[3];let n=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return n/=45,i&&(n+=47721858.84),Math.round(n)}},Sn=(t,e=!1)=>{const i=Ln();if(i){const n=i.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 r,s,a,o="",l=0;for(;l<n;){if(r=t[l++],0===r&&e)return o;if(0!==r&&3!==r)switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:s=t[l++],o+=String.fromCharCode((31&r)<<6|63&s);break;case 14:s=t[l++],a=t[l++],o+=String.fromCharCode((15&r)<<12|(63&s)<<6|(63&a)<<0)}}return o};let _n;function Ln(){if(!navigator.userAgent.includes("PlayStation 4"))return _n||void 0===self.TextDecoder||(_n=new self.TextDecoder("utf-8")),_n}const Rn=function(t){let e="";for(let i=0;i<t.length;i++){let n=t[i].toString(16);n.length<2&&(n="0"+n),e+=n}return e},Cn=Math.pow(2,32)-1,wn=[].push,In={video:1,audio:2,id3:3,text:4};function Dn(t){return String.fromCharCode.apply(null,t)}function Pn(t,e){const i=t[e]<<8|t[e+1];return i<0?65536+i:i}function On(t,e){const i=Nn(t,e);return i<0?4294967296+i:i}function xn(t,e){let i=On(t,e);return i*=Math.pow(2,32),i+=On(t,e+4),i}function Nn(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function Mn(t,e,i){t[e]=i>>24,t[e+1]=i>>16&255,t[e+2]=i>>8&255,t[e+3]=255&i}function Fn(t,e){const i=[];if(!e.length)return i;const n=t.byteLength;for(let r=0;r<n;){const s=On(t,r),a=s>1?r+s:n;if(Dn(t.subarray(r+4,r+8))===e[0])if(1===e.length)i.push(t.subarray(r+8,a));else{const n=Fn(t.subarray(r+8,a),e.slice(1));n.length&&wn.apply(i,n)}r=a}return i}function Bn(t){const e=[],i=t[0];let n=8;const r=On(t,n);n+=4;let s=0,a=0;0===i?(s=On(t,n),a=On(t,n+4),n+=8):(s=xn(t,n),a=xn(t,n+8),n+=16),n+=2;let o=t.length+a;const l=Pn(t,n);n+=2;for(let i=0;i<l;i++){let i=n;const s=On(t,i);i+=4;const a=2147483647&s;if(1===(2147483648&s)>>>31)return Oi.warn("SIDX has hierarchical references (not supported)"),null;const l=On(t,i);i+=4,e.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/r,start:o,end:o+a-1}}),o+=a,i+=4,n=i}return{earliestPresentationTime:s,timescale:r,version:i,referencesCount:l,references:e}}function Un(t){const e=[],i=Fn(t,["moov","trak"]);for(let t=0;t<i.length;t++){const n=i[t],r=Fn(n,["tkhd"])[0];if(r){let t=r[0];const i=On(r,0===t?12:20),s=Fn(n,["mdia","mdhd"])[0];if(s){t=s[0];const r=On(s,0===t?12:20),a=Fn(n,["mdia","hdlr"])[0];if(a){const t=Dn(a.subarray(8,12)),s={soun:$i,vide:Gi}[t];if(s){const t=$n(Fn(n,["mdia","minf","stbl","stsd"])[0]);e[i]={timescale:r,type:s},e[s]=Ai({timescale:r,id:i},t)}}}}}return Fn(t,["moov","mvex","trex"]).forEach((t=>{const i=On(t,4),n=e[i];n&&(n.default={duration:On(t,12),flags:On(t,20)})})),e}function $n(t){const e=t.subarray(8),i=e.subarray(86),n=Dn(e.subarray(4,8));let r=n;const s="enca"===n||"encv"===n;if(s){const t=Fn(e,[n])[0];Fn(t.subarray("enca"===n?28:78),["sinf"]).forEach((t=>{const e=Fn(t,["schm"])[0];if(e){const i=Dn(e.subarray(4,8));if("cbcs"===i||"cenc"===i){const e=Fn(t,["frma"])[0];e&&(r=Dn(e))}}}))}switch(r){case"avc1":case"avc2":case"avc3":case"avc4":{const t=Fn(i,["avcC"])[0];r+="."+Vn(t[1])+Vn(t[2])+Vn(t[3]);break}case"mp4a":{const t=Fn(e,[n])[0],i=Fn(t.subarray(28),["esds"])[0];if(i&&i.length>12){let t=4;if(3!==i[t++])break;t=Gn(i,t),t+=2;const e=i[t++];if(128&e&&(t+=2),64&e&&(t+=i[t++]),4!==i[t++])break;t=Gn(i,t);const n=i[t++];if(64!==n)break;if(r+="."+Vn(n),t+=12,5!==i[t++])break;t=Gn(i,t);const s=i[t++];let a=(248&s)>>3;31===a&&(a+=1+((7&s)<<3)+((224&i[t])>>5)),r+="."+a}break}case"hvc1":case"hev1":{const t=Fn(i,["hvcC"])[0],e=t[1],n=["","A","B","C"][e>>6],s=31&e,a=On(t,2),o=(32&e)>>5?"H":"L",l=t[12],c=t.subarray(6,12);r+="."+n+s,r+="."+a.toString(16).toUpperCase(),r+="."+o+l;let h="";for(let t=c.length;t--;){const e=c[t];if(e||h){h="."+e.toString(16).toUpperCase()+h}}r+=h;break}case"dvh1":case"dvhe":{const t=Fn(i,["dvcC"])[0],e=t[2]>>1&127,n=t[2]<<5&32|t[3]>>3&31;r+="."+Kn(e)+"."+Kn(n);break}case"vp09":{const t=Fn(i,["vpcC"])[0],e=t[4],n=t[5],s=t[6]>>4&15;r+="."+Kn(e)+"."+Kn(n)+"."+Kn(s);break}case"av01":{const t=Fn(i,["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,h=(8&t[2])>>3,u=(4&t[2])>>2,d=3&t[2],f=1,g=1,p=1,m=0;r+="."+e+"."+Kn(n)+s+"."+Kn(l)+"."+c+"."+h+u+d+"."+Kn(f)+"."+Kn(g)+"."+Kn(p)+"."+m;break}}return{codec:r,encrypted:s}}function Gn(t,e){const i=e+5;for(;128&t[e++]&&e<i;);return e}function Vn(t){return("0"+t.toString(16).toUpperCase()).slice(-2)}function Kn(t){return(t<10?"0":"")+t}function Hn(t){const e=Fn(t,["schm"])[0];if(e){const i=Dn(e.subarray(4,8));if("cbcs"===i||"cenc"===i)return Fn(t,["schi","tenc"])[0]}return Oi.error("[eme] missing 'schm' box"),null}function Yn(t){const e=On(t,0);let i=8;1&e&&(i+=4),4&e&&(i+=4);let n=0;const r=On(t,4);for(let s=0;s<r;s++){if(256&e){n+=On(t,i),i+=4}512&e&&(i+=4),1024&e&&(i+=4),2048&e&&(i+=4)}return n}function jn(t,e){const i=new Uint8Array(t.length+e.length);return i.set(t),i.set(e,t.length),i}function Wn(t,e){const i=[],n=e.samples,r=e.timescale,s=e.id;let a=!1;return Fn(n,["moof"]).map((o=>{const l=o.byteOffset-8;Fn(o,["traf"]).map((o=>{const c=Fn(o,["tfdt"]).map((t=>{const e=t[0];let i=On(t,4);return 1===e&&(i*=Math.pow(2,32),i+=On(t,8)),i/r}))[0];return void 0!==c&&(t=c),Fn(o,["tfhd"]).map((c=>{const h=On(c,4),u=16777215&On(c,0);let d=0;const f=0!=(16&u);let g=0;const p=0!=(32&u);let m=8;h===s&&(0!=(1&u)&&(m+=8),0!=(2&u)&&(m+=4),0!=(8&u)&&(d=On(c,m),m+=4),f&&(g=On(c,m),m+=4),p&&(m+=4),"video"===e.type&&(a=function(t){if(!t)return!1;const e=t.indexOf("."),i=e<0?t:t.substring(0,e);return"hvc1"===i||"hev1"===i||"dvh1"===i||"dvhe"===i}(e.codec)),Fn(o,["trun"]).map((s=>{const o=s[0],c=16777215&On(s,0),h=0!=(1&c);let u=0;const f=0!=(4&c),p=0!=(256&c);let m=0;const v=0!=(512&c);let y=0;const A=0!=(1024&c),E=0!=(2048&c);let T=0;const b=On(s,4);let k=8;h&&(u=On(s,k),k+=4),f&&(k+=4);let S=u+l;for(let l=0;l<b;l++){if(p?(m=On(s,k),k+=4):m=d,v?(y=On(s,k),k+=4):y=g,A&&(k+=4),E&&(T=0===o?On(s,k):Nn(s,k),k+=4),e.type===Gi){let e=0;for(;e<y;){const s=On(n,S);if(S+=4,zn(a,n[S])){qn(n.subarray(S,S+s),a?2:1,t+T/r,i)}S+=s,e+=s+4}}t+=m/r}})))}))}))})),i}function zn(t,e){if(t){const t=e>>1&63;return 39===t||40===t}return 6===(31&e)}function qn(t,e,i,n){const r=Xn(t);let s=0;s+=e;let a=0,o=0,l=0;for(;s<r.length;){a=0;do{if(s>=r.length)break;l=r[s++],a+=l}while(255===l);o=0;do{if(s>=r.length)break;l=r[s++],o+=l}while(255===l);const t=r.length-s;let e=s;if(o<t)s+=o;else if(o>t){Oi.error(`Malformed SEI payload. ${o} is too small, only ${t} bytes left to parse.`);break}if(4===a){if(181===r[e++]){const t=Pn(r,e);if(e+=2,49===t){const t=On(r,e);if(e+=4,1195456820===t){const t=r[e++];if(3===t){const s=r[e++],o=64&s,l=o?2+3*(31&s):0,c=new Uint8Array(l);if(o){c[0]=s;for(let t=1;t<l;t++)c[t]=r[e++]}n.push({type:t,payloadType:a,pts:i,bytes:c})}}}}}else if(5===a&&o>16){const t=[];for(let i=0;i<16;i++){const n=r[e++].toString(16);t.push(1==n.length?"0"+n:n),3!==i&&5!==i&&7!==i&&9!==i||t.push("-")}const s=o-16,l=new Uint8Array(s);for(let t=0;t<s;t++)l[t]=r[e++];n.push({payloadType:a,pts:i,uuid:t.join(""),userData:Sn(l),userDataBytes:l})}}}function Xn(t){const e=t.byteLength,i=[];let n=1;for(;n<e-2;)0===t[n]&&0===t[n+1]&&3===t[n+2]?(i.push(n+2),n+=2):n++;if(0===i.length)return t;const r=e-i.length,s=new Uint8Array(r);let a=0;for(n=0;n<r;a++,n++)a===i[0]&&(a++,i.shift()),s[n]=t[a];return s}function Qn(t,e,i){if(16!==t.byteLength)throw new RangeError("Invalid system id");let n,r,s;if(e){n=1,r=new Uint8Array(16*e.length);for(let t=0;t<e.length;t++){const i=e[t];if(16!==i.byteLength)throw new RangeError("Invalid key");r.set(i,16*t)}}else n=0,r=new Uint8Array;n>0?(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 i&&i.byteLength>0&&new DataView(a.buffer).setUint32(0,i.byteLength,!1),function(t,...e){const i=e.length;let n=8,r=i;for(;r--;)n+=e[r].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),r=0,n=8;r<i;r++)s.set(e[r],n),n+=e[r].byteLength;return s}([112,115,115,104],new Uint8Array([n,0,0,0]),t,s,r,a,i||new Uint8Array)}let Zn={};class Jn{static clearKeyUriToKeyIdMap(){Zn={}}constructor(t,e,i,n=[1],r=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=i,this.keyFormatVersions=n,this.iv=r,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&"AES-128"!==t}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Ji:case en:case tn:case Zi:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof t&&("AES-128"!==this.method||this.iv||Oi.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const e=function(t){const e=new Uint8Array(16);for(let i=12;i<16;i++)e[i]=t>>8*(15-i)&255;return e}(t);return new Jn(this.method,this.uri,"identity",this.keyFormatVersions,e)}const e=zi(this.uri);if(e)switch(this.keyFormat){case en:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case tn:{const t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Qn(t,null,e);const i=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),n=String.fromCharCode.apply(null,Array.from(i)),r=n.substring(n.indexOf("<"),n.length),s=(new DOMParser).parseFromString(r,"text/xml").getElementsByTagName("KID")[0];if(s){const t=s.childNodes[0]?s.childNodes[0].nodeValue:s.getAttribute("VALUE");if(t){const e=Wi(t).subarray(0,16);!function(t){const e=function(t,e,i){const n=t[e];t[e]=t[i],t[i]=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=Zn[this.uri];if(!t){const e=Object.keys(Zn).length%Number.MAX_SAFE_INTEGER;t=new Uint8Array(16);new DataView(t.buffer,12,4).setUint32(0,e),Zn[this.uri]=t}this.keyId=t}return this}}const tr=/\{\$([a-zA-Z0-9-_]+)\}/g;function er(t){return tr.test(t)}function ir(t,e,i){if(null!==t.variableList||t.hasVariableRefs)for(let n=i.length;n--;){const r=i[n],s=e[r];s&&(e[r]=nr(t,s))}}function nr(t,e){if(null!==t.variableList||t.hasVariableRefs){const i=t.variableList;return e.replace(tr,(e=>{const n=e.substring(2,e.length-1),r=null==i?void 0:i[n];return void 0===r?(t.playlistParsingError||(t.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),e):r}))}return e}function rr(t,e,i){let n,r,s=t.variableList;if(s||(t.variableList=s={}),"QUERYPARAM"in e){n=e.QUERYPARAM;try{const t=new self.URL(i).searchParams;if(!t.has(n))throw new Error(`"${n}" does not match any query parameter in URI: "${i}"`);r=t.get(n)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${e.message}`))}}else n=e.NAME,r=e.VALUE;n in s?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):s[n]=r||""}function sr(t,e,i){const n=e.IMPORT;if(i&&n in i){let e=t.variableList;e||(t.variableList=e={}),e[n]=i[n]}else t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${n}"`))}function ar(t=!0){if("undefined"==typeof self)return;return(t||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}const or={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 lr(t,e,i=!0){return!t.split(",").some((t=>!cr(t,e,i)))}function cr(t,e,i=!0){var n;const r=ar(i);return null!=(n=null==r?void 0:r.isTypeSupported(hr(t,e)))&&n}function hr(t,e){return`${e}/mp4;codecs="${t}"`}function ur(t){if(t){const e=t.substring(0,4);return or.video[e]}return 2}function dr(t){return t.split(",").reduce(((t,e)=>{const i=or.video[e];return i?(2*i+t)/(t?3:2):(or.audio[e]+t)/(t?2:1)}),0)}const fr={};const gr=/flac|opus/i;function pr(t,e=!0){return t.replace(gr,(t=>function(t,e=!0){if(fr[t])return fr[t];const i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[t];for(let n=0;n<i.length;n++)if(cr(i[n],"audio",e))return fr[t]=i[n],i[n];return t}(t.toLowerCase(),e)))}function mr(t,e){return t&&"mp4a"!==t?t:e?e.split(",")[0]:e}const vr=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,yr=/#EXT-X-MEDIA:(.*)/g,Ar=/^#EXT(?:INF|-X-TARGETDURATION):/m,Er=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Tr=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class br{static findGroup(t,e){for(let i=0;i<t.length;i++){const n=t[i];if(n.id===e)return n}}static resolve(t,e){return vi.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Ar.test(t)}static parseMasterPlaylist(t,e){const i={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:er(t)},n=[];let r;for(vr.lastIndex=0;null!=(r=vr.exec(t));)if(r[1]){var s;const t=new Mi(r[1]);ir(i,t,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const a=nr(i,r[2]),o={attrs:t,bitrate:t.decimalInteger("BANDWIDTH")||t.decimalInteger("AVERAGE-BANDWIDTH"),name:t.NAME,url:br.resolve(a,e)},l=t.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),_r(t.CODECS,o),null!=(s=o.unknownCodecs)&&s.length||n.push(o),i.levels.push(o)}else if(r[3]){const t=r[3],n=r[4];switch(t){case"SESSION-DATA":{const t=new Mi(n);ir(i,t,["DATA-ID","LANGUAGE","VALUE","URI"]);const e=t["DATA-ID"];e&&(null===i.sessionData&&(i.sessionData={}),i.sessionData[e]=t);break}case"SESSION-KEY":{const t=kr(n,e,i);t.encrypted&&t.isSupported()?(null===i.sessionKeys&&(i.sessionKeys=[]),i.sessionKeys.push(t)):Oi.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${n}"`);break}case"DEFINE":{const t=new Mi(n);ir(i,t,["NAME","VALUE","QUERYPARAM"]),rr(i,t,e)}break;case"CONTENT-STEERING":{const t=new Mi(n);ir(i,t,["SERVER-URI","PATHWAY-ID"]),i.contentSteering={uri:br.resolve(t["SERVER-URI"],e),pathwayId:t["PATHWAY-ID"]||"."};break}case"START":i.startTimeOffset=Sr(n)}}const a=n.length>0&&n.length<i.levels.length;return i.levels=a?n:i.levels,0===i.levels.length&&(i.playlistParsingError=new Error("no levels found in manifest")),i}static parseMasterPlaylistMedia(t,e,i){let n;const r={},s=i.levels,a={AUDIO:s.map((t=>({id:t.attrs.AUDIO,audioCodec:t.audioCodec}))),SUBTITLES:s.map((t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec}))),"CLOSED-CAPTIONS":[]};let o=0;for(yr.lastIndex=0;null!==(n=yr.exec(t));){const t=new Mi(n[1]),s=t.TYPE;if(s){const n=a[s],l=r[s]||[];r[s]=l,ir(i,t,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const c=t.LANGUAGE,h=t["ASSOC-LANGUAGE"],u=t.CHANNELS,d=t.CHARACTERISTICS,f=t["INSTREAM-ID"],g={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?br.resolve(t.URI,e):""};if(h&&(g.assocLang=h),u&&(g.channels=u),d&&(g.characteristics=d),f&&(g.instreamId=f),null!=n&&n.length){const t=br.findGroup(n,g.groupId)||n[0];Lr(g,t,"audioCodec"),Lr(g,t,"textCodec")}l.push(g)}}return r}static parseLevelPlaylist(t,e,i,n,r,s){const a=new ji(e),o=a.fragments;let l,c,h,u=null,d=0,f=0,g=0,p=0,m=null,v=new Hi(n,e),y=-1,A=!1,E=null;for(Er.lastIndex=0,a.m3u8=t,a.hasVariableRefs=er(t);null!==(l=Er.exec(t));){A&&(A=!1,v=new Hi(n,e),v.start=g,v.sn=d,v.cc=p,v.level=i,u&&(v.initSegment=u,v.rawProgramDateTime=u.rawProgramDateTime,u.rawProgramDateTime=null,E&&(v.setByteRange(E),E=null)));const t=l[1];if(t){v.duration=parseFloat(t);const e=(" "+l[2]).slice(1);v.title=e||null,v.tagList.push(e?["INF",t,e]:["INF",t])}else if(l[3]){if(ki(v.duration)){v.start=g,h&&wr(v,h,a),v.sn=d,v.level=i,v.cc=p,o.push(v);const t=(" "+l[3]).slice(1);v.relurl=nr(a,t),Rr(v,m),m=v,g+=v.duration,d++,f=0,A=!0}}else if(l[4]){const t=(" "+l[4]).slice(1);m?v.setByteRange(t,m):v.setByteRange(t)}else if(l[5])v.rawProgramDateTime=(" "+l[5]).slice(1),v.tagList.push(["PROGRAM-DATE-TIME",v.rawProgramDateTime]),-1===y&&(y=o.length);else{if(l=l[0].match(Tr),!l){Oi.warn("No matches on slow regex match for level playlist!");continue}for(c=1;c<l.length&&void 0===l[c];c++);const t=(" "+l[c]).slice(1),r=(" "+l[c+1]).slice(1),g=l[c+2]?(" "+l[c+2]).slice(1):"";switch(t){case"PLAYLIST-TYPE":a.type=r.toUpperCase();break;case"MEDIA-SEQUENCE":d=a.startSN=parseInt(r);break;case"SKIP":{const t=new Mi(r);ir(a,t,["RECENTLY-REMOVED-DATERANGES"]);const e=t.decimalInteger("SKIPPED-SEGMENTS");if(ki(e)){a.skippedSegments=e;for(let t=e;t--;)o.unshift(null);d+=e}const i=t.enumeratedString("RECENTLY-REMOVED-DATERANGES");i&&(a.recentlyRemovedDateranges=i.split("\t"));break}case"TARGETDURATION":a.targetduration=Math.max(parseInt(r),1);break;case"VERSION":a.version=parseInt(r);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"#":(r||g)&&v.tagList.push(g?[r,g]:[r]);break;case"DISCONTINUITY":p++,v.tagList.push(["DIS"]);break;case"GAP":v.gap=!0,v.tagList.push([t]);break;case"BITRATE":v.tagList.push([t,r]);break;case"DATERANGE":{const t=new Mi(r);ir(a,t,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ir(a,t,t.clientAttrs);const e=new Bi(t,a.dateRanges[t.ID]);e.isValid||a.skippedSegments?a.dateRanges[e.id]=e:Oi.warn(`Ignoring invalid DATERANGE tag: "${r}"`),v.tagList.push(["EXT-X-DATERANGE",r]);break}case"DEFINE":{const t=new Mi(r);ir(a,t,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in t?sr(a,t,s):rr(a,t,e)}break;case"DISCONTINUITY-SEQUENCE":p=parseInt(r);break;case"KEY":{const t=kr(r,e,a);if(t.isSupported()){if("NONE"===t.method){h=void 0;break}h||(h={}),h[t.keyFormat]&&(h=bi({},h)),h[t.keyFormat]=t}else Oi.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${r}"`);break}case"START":a.startTimeOffset=Sr(r);break;case"MAP":{const t=new Mi(r);if(ir(a,t,["BYTERANGE","URI"]),v.duration){const r=new Hi(n,e);Cr(r,t,i,h),u=r,v.initSegment=u,u.rawProgramDateTime&&!v.rawProgramDateTime&&(v.rawProgramDateTime=u.rawProgramDateTime)}else{const e=v.byteRangeEndOffset;if(e){const t=v.byteRangeStartOffset;E=`${e-t}@${t}`}else E=null;Cr(v,t,i,h),u=v,A=!0}break}case"SERVER-CONTROL":{const t=new Mi(r);a.canBlockReload=t.bool("CAN-BLOCK-RELOAD"),a.canSkipUntil=t.optionalFloat("CAN-SKIP-UNTIL",0),a.canSkipDateRanges=a.canSkipUntil>0&&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 Mi(r);a.partTarget=t.decimalFloatingPoint("PART-TARGET");break}case"PART":{let t=a.partList;t||(t=a.partList=[]);const i=f>0?t[t.length-1]:void 0,n=f++,s=new Mi(r);ir(a,s,["BYTERANGE","URI"]);const o=new Yi(s,v,e,n,i);t.push(o),v.duration+=o.duration;break}case"PRELOAD-HINT":{const t=new Mi(r);ir(a,t,["URI"]),a.preloadHint=t;break}case"RENDITION-REPORT":{const t=new Mi(r);ir(a,t,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(t);break}default:Oi.warn(`line parsed but not handled: ${l}`)}}}m&&!m.relurl?(o.pop(),g-=m.duration,a.partList&&(a.fragmentHint=m)):a.partList&&(Rr(v,m),v.cc=p,a.fragmentHint=v,h&&wr(v,h,a));const T=o.length,b=o[0],k=o[T-1];if(g+=a.skippedSegments*a.targetduration,g>0&&T&&k){a.averagetargetduration=g/T;const t=k.sn;a.endSN="initSegment"!==t?t:0,a.live||(k.endList=!0),b&&(a.startCC=b.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(g+=a.fragmentHint.duration),a.totalduration=g,a.endCC=p,y>0&&function(t,e){let i=t[e];for(let n=e;n--;){const e=t[n];if(!e)return;e.programDateTime=i.programDateTime-1e3*e.duration,i=e}}(o,y),a}}function kr(t,e,i){var n,r;const s=new Mi(t);ir(i,s,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=null!=(n=s.METHOD)?n:"",o=s.URI,l=s.hexadecimalInteger("IV"),c=s.KEYFORMATVERSIONS,h=null!=(r=s.KEYFORMAT)?r:"identity";o&&s.IV&&!l&&Oi.error(`Invalid IV: ${s.IV}`);const u=o?br.resolve(o,e):"",d=(c||"1").split("/").map(Number).filter(Number.isFinite);return new Jn(a,u,h,d,l)}function Sr(t){const e=new Mi(t).decimalFloatingPoint("TIME-OFFSET");return ki(e)?e:null}function _r(t,e){let i=(t||"").split(/[ ,]+/).filter((t=>t));["video","audio","text"].forEach((t=>{const n=i.filter((e=>function(t,e){const i=or[e];return!!i&&!!i[t.slice(0,4)]}(e,t)));n.length&&(e[`${t}Codec`]=n.join(","),i=i.filter((t=>-1===n.indexOf(t))))})),e.unknownCodecs=i}function Lr(t,e,i){const n=e[i];n&&(t[i]=n)}function Rr(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),ki(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function Cr(t,e,i,n){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=i,t.sn="initSegment",n&&(t.levelkeys=n),t.initSegment=null}function wr(t,e,i){t.levelkeys=e;const{encryptedFragments:n}=i;n.length&&n[n.length-1].levelkeys===e||!Object.keys(e).some((t=>e[t].isCommonEncryption))||n.push(t)}var Ir="manifest",Dr="level",Pr="audioTrack",Or="subtitleTrack",xr="main",Nr="audio",Mr="subtitle";function Fr(t){const{type:e}=t;switch(e){case Pr:return Nr;case Or:return Mr;default:return xr}}function Br(t,e){let i=t.url;return void 0!==i&&0!==i.indexOf("data:")||(i=e.url),i}class Ur{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(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.LEVEL_LOADING,this.onLevelLoading,this),t.on(Li.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(Li.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.LEVEL_LOADING,this.onLevelLoading,this),t.off(Li.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(Li.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,i=e.pLoader,n=e.loader,r=new(i||n)(e);return this.loaders[t.type]=r,r}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:i}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ir,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:n,pathwayId:r,url:s,deliveryDirectives:a}=e;this.load({id:i,level:n,pathwayId:r,responseType:"text",type:Dr,url:s,deliveryDirectives:a})}onAudioTrackLoading(t,e){const{id:i,groupId:n,url:r,deliveryDirectives:s}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:Pr,url:r,deliveryDirectives:s})}onSubtitleTrackLoading(t,e){const{id:i,groupId:n,url:r,deliveryDirectives:s}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:Or,url:r,deliveryDirectives:s})}load(t){var e;const i=this.hls.config;let n,r=this.getInternalLoader(t);if(r){const e=r.context;if(e&&e.url===t.url&&e.level===t.level)return void Oi.trace("[playlist-loader]: playlist request ongoing");Oi.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),r.abort()}if(n=t.type===Ir?i.manifestLoadPolicy.default:bi({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(t),ki(null==(e=t.deliveryDirectives)?void 0:e.part)){let e;if(t.type===Dr&&null!==t.level?e=this.hls.levels[t.level].details:t.type===Pr&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===Or&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e){const t=e.partTarget,i=e.targetduration;if(t&&i){const e=1e3*Math.max(3*t,.8*i);n=bi({},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,i,n)=>{const r=this.getInternalLoader(i);this.resetInternalLoader(i.type);const s=t.data;0===s.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),br.isMediaPlaylist(s)?this.handleTrackOrLevelPlaylist(t,e,i,n||null,r):this.handleMasterPlaylist(t,e,i,n)):this.handleManifestParsingError(t,i,new Error("no EXTM3U delimiter"),n||null,e)},onError:(t,e,i,n)=>{this.handleNetworkError(e,i,!1,t,n)},onTimeout:(t,e,i)=>{this.handleNetworkError(e,i,!0,void 0,t)}};r.load(t,a,o)}handleMasterPlaylist(t,e,i,n){const r=this.hls,s=t.data,a=Br(t,i),o=br.parseMasterPlaylist(s,a);if(o.playlistParsingError)return void this.handleManifestParsingError(t,i,o.playlistParsingError,n,e);const{contentSteering:l,levels:c,sessionData:h,sessionKeys:u,startTimeOffset:d,variableList:f}=o;this.variableList=f;const{AUDIO:g=[],SUBTITLES:p,"CLOSED-CAPTIONS":m}=br.parseMasterPlaylistMedia(s,a,o);if(g.length){g.some((t=>!t.url))||!c[0].audioCodec||c[0].attrs.AUDIO||(Oi.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Mi({}),bitrate:0,url:""}))}r.trigger(Li.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:p,captions:m,contentSteering:l,url:a,stats:e,networkDetails:n,sessionData:h,sessionKeys:u,startTimeOffset:d,variableList:f})}handleTrackOrLevelPlaylist(t,e,i,n,r){const s=this.hls,{id:a,level:o,type:l}=i,c=Br(t,i),h=ki(o)?o:ki(a)?a:0,u=Fr(i),d=br.parseLevelPlaylist(t.data,c,h,u,0,this.variableList);if(l===Ir){const t={attrs:new Mi({}),bitrate:0,details:d,name:"",url:c};s.trigger(Li.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(),i.levelDetails=d,this.handlePlaylistLoaded(d,t,e,i,n,r)}handleManifestParsingError(t,e,i,n,r){this.hls.trigger(Li.ERROR,{type:Ri.NETWORK_ERROR,details:Ci.MANIFEST_PARSING_ERROR,fatal:e.type===Ir,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:n,stats:r})}handleNetworkError(t,e,i=!1,n,r){let s=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${t.type}`;t.type===Dr?s+=`: ${t.level} id: ${t.id}`:t.type!==Pr&&t.type!==Or||(s+=` id: ${t.id} group-id: "${t.groupId}"`);const a=new Error(s);Oi.warn(`[playlist-loader]: ${s}`);let o=Ci.UNKNOWN,l=!1;const c=this.getInternalLoader(t);switch(t.type){case Ir:o=i?Ci.MANIFEST_LOAD_TIMEOUT:Ci.MANIFEST_LOAD_ERROR,l=!0;break;case Dr:o=i?Ci.LEVEL_LOAD_TIMEOUT:Ci.LEVEL_LOAD_ERROR,l=!1;break;case Pr:o=i?Ci.AUDIO_TRACK_LOAD_TIMEOUT:Ci.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Or:o=i?Ci.SUBTITLE_TRACK_LOAD_TIMEOUT:Ci.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(t.type);const h={type:Ri.NETWORK_ERROR,details:o,fatal:l,url:t.url,loader:c,context:t,error:a,networkDetails:e,stats:r};if(n){const i=(null==e?void 0:e.url)||t.url;h.response=Ai({url:i,data:void 0},n)}this.hls.trigger(Li.ERROR,h)}handlePlaylistLoaded(t,e,i,n,r,s){const a=this.hls,{type:o,level:l,id:c,groupId:h,deliveryDirectives:u}=n,d=Br(e,n),f=Fr(n),g="number"==typeof n.level&&f===xr?l:void 0;if(!t.fragments.length){const t=new Error("No Segments found in Playlist");return void a.trigger(Li.ERROR,{type:Ri.NETWORK_ERROR,details:Ci.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:t,reason:t.message,response:e,context:n,level:g,parent:f,networkDetails:r,stats:i})}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const p=t.playlistParsingError;if(p)a.trigger(Li.ERROR,{type:Ri.NETWORK_ERROR,details:Ci.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:p,reason:p.message,response:e,context:n,level:g,parent:f,networkDetails:r,stats:i});else switch(t.live&&s&&(s.getCacheAge&&(t.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case Ir:case Dr:a.trigger(Li.LEVEL_LOADED,{details:t,level:g||0,id:c||0,stats:i,networkDetails:r,deliveryDirectives:u});break;case Pr:a.trigger(Li.AUDIO_TRACK_LOADED,{details:t,id:c||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:u});break;case Or:a.trigger(Li.SUBTITLE_TRACK_LOADED,{details:t,id:c||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:u})}}}function $r(t,e){let i;try{i=new Event("addtrack")}catch(t){i=document.createEvent("Event"),i.initEvent("addtrack",!1,!1)}i.track=t,e.dispatchEvent(i)}function Gr(t,e){const i=t.mode;if("disabled"===i&&(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(i){Oi.debug(`[texttrack-utils]: ${i}`);try{const i=new self.TextTrackCue(e.startTime,e.endTime,e.text);i.id=e.id,t.addCue(i)}catch(t){Oi.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${t}`)}}"disabled"===i&&(t.mode=i)}function Vr(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 Kr(t,e,i,n){const r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&t.cues.length>0){const r=function(t,e,i){const n=[],r=function(t,e){if(e<t[0].startTime)return 0;const i=t.length-1;if(e>t[i].endTime)return-1;let n=0,r=i;for(;n<=r;){const s=Math.floor((r+n)/2);if(e<t[s].startTime)r=s-1;else{if(!(e>t[s].startTime&&n<i))return s;n=s+1}}return t[n].startTime-e<e-t[r].startTime?n:r}(t,e);if(r>-1)for(let s=r,a=t.length;s<a;s++){const r=t[s];if(r.startTime>=e&&r.endTime<=i)n.push(r);else if(r.startTime>i)return n}return n}(t.cues,e,i);for(let e=0;e<r.length;e++)n&&!n(r[e])||t.removeCue(r[e])}"disabled"===r&&(t.mode=r)}function Hr(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i];"subtitles"!==n.kind&&"captions"!==n.kind||!n.label||e.push(t[i])}return e}var Yr="org.id3",jr="com.apple.quicktime.HLS",Wr="https://aomedia.org/emsg/ID3";function zr(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function qr(t,e,i,n,r){let s=new t(e,i,"");try{s.value=n,r&&(s.type=r)}catch(a){s=new t(e,i,JSON.stringify(r?Ai({type:r},n):n))}return s}const Xr=(()=>{const t=zr();try{t&&new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Qr(t,e){return t.getTime()/1e3-e}class Zr{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(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Li.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Li.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Vr(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;e<t.length;e++){const i=t[e];if("metadata"===i.kind&&"id3"===i.label)return $r(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:n}}}=this;if(!i&&!n)return;const{samples:r}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const s=zr();if(s)for(let t=0;t<r.length;t++){const e=r[t].type;if(e===Wr&&!i||!n)continue;const a=yn(r[t].data);if(a){const i=r[t].pts;let n=i+r[t].duration;n>Xr&&(n=Xr);n-i<=0&&(n=i+.25);for(let t=0;t<a.length;t++){const r=a[t];if(!mn(r)){this.updateId3CueEnds(i,e);const t=qr(s,i,n,r,e);t&&this.id3Track.addCue(t)}}}}}updateId3CueEnds(t,e){var i;const n=null==(i=this.id3Track)?void 0:i.cues;if(n)for(let i=n.length;i--;){const r=n[i];r.type===e&&r.startTime<t&&r.endTime===Xr&&(r.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:n}){const{id3Track:r,hls:s}=this;if(!s)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=s;if(r&&(a||o)){let t;t="audio"===n?t=>t.type===Yr&&o:"video"===n?t=>t.type===Wr&&a:t=>t.type===Yr&&o||t.type===Wr&&a,Kr(r,e,i,t)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:n}=this,{dateRanges:r}=e,s=Object.keys(r);if(n){const t=Object.keys(i).filter((t=>!s.includes(t)));for(let e=t.length;e--;){const r=t[e];Object.keys(i[r].cues).forEach((t=>{n.removeCue(i[r].cues[t])})),delete i[r]}}const a=e.fragments[e.fragments.length-1];if(0===s.length||!ki(null==a?void 0:a.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const o=a.programDateTime/1e3-a.start,l=zr();for(let t=0;t<s.length;t++){const e=s[t],n=r[e],a=Qr(n.startDate,o),u=i[e],d=(null==u?void 0:u.cues)||{};let f=(null==u?void 0:u.durationKnown)||!1,g=Xr;const p=n.endDate;if(p)g=Qr(p,o),f=!0;else if(n.endOnNext&&!f){const t=s.reduce(((t,e)=>{if(e!==n.id){const i=r[e];if(i.class===n.class&&i.startDate>n.startDate&&(!t||n.startDate<t.startDate))return i}return t}),null);t&&(g=Qr(t.startDate,o),f=!0)}const m=Object.keys(n.attr);for(let t=0;t<m.length;t++){const i=m[t];if("ID"===(h=i)||"CLASS"===h||"START-DATE"===h||"DURATION"===h||"END-DATE"===h||"END-ON-NEXT"===h)continue;const r=d[i];if(r)f&&!u.durationKnown&&(r.endTime=g);else if(l){let t=n.attr[i];Fi(i)&&(c=t,t=Uint8Array.from(c.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);const r=qr(l,a,g,{key:i,data:t},jr);r&&(r.id=e,this.id3Track.addCue(r),d[i]=r)}}i[e]={cues:d,dateRange:n,durationKnown:f}}var c,h}}class Jr{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.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:i,targetduration:n}=t,{liveSyncDuration:r,liveSyncDurationCount:s,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&i||e;(o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:s*n);const c=n;return l+Math.min(1*this.stallCount,c)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,i=this.levelDetails;if(null===t||null===e||null===i)return null;const n=i.edge,r=t-e-this.edgeStalled,s=n-i.totalduration,a=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(s,r),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 i=t.buffered.length;return(i?t.buffered.end(i-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(Li.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Li.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(Li.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Li.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(Li.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 i;e.details===Ci.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(i=this.levelDetails)&&i.live&&Oi.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 i=this.computeLatency();if(null===i)return;this._latency=i;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:r}=this.config;if(!n||1===r||!e.live)return;const s=this.targetLatency;if(null===s)return;const a=i-s;if(a<Math.min(this.maxLatency,s+e.targetduration)&&a>.05&&this.forwardBufferLength>1){const e=Math.min(2,Math.max(1,r)),i=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;t.playbackRate=Math.min(e,Math.max(1,i))}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 ts=["NONE","TYPE-0","TYPE-1",null];const es=["SDR","PQ","HLG"];var is="",ns="YES",rs="v2";function ss(t){const{canSkipUntil:e,canSkipDateRanges:i,age:n}=t;return e&&n<e/2?i?rs:ns:is}class as{constructor(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}addDirectives(t){const e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class os{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter((t=>!!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 ls(this._audioGroups,t)}hasSubtitleGroup(t){return ls(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 ls(t,e){return!(!e||!t)&&-1!==t.indexOf(e)}function cs(t,e){const i=e.startPTS;if(ki(i)){let n,r=0;e.sn>t.sn?(r=i-t.start,n=t):(r=t.start-i,n=e),n.duration!==r&&(n.duration=r)}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 hs(t,e,i,n,r,s){n-i<=0&&(Oi.warn("Fragment should have a positive duration",e),n=i+e.duration,s=r+e.duration);let a=i,o=n;const l=e.startPTS,c=e.endPTS;if(ki(l)){const t=Math.abs(l-i);ki(e.deltaPTS)?e.deltaPTS=Math.max(t,e.deltaPTS):e.deltaPTS=t,a=Math.max(i,l),i=Math.min(i,l),r=Math.min(r,e.startDTS),o=Math.min(n,c),n=Math.max(n,c),s=Math.max(s,e.endDTS)}const h=i-e.start;0!==e.start&&(e.start=i),e.duration=n-e.start,e.startPTS=i,e.maxStartPTS=a,e.startDTS=r,e.endPTS=n,e.minEndPTS=o,e.endDTS=s;const u=e.sn;if(!t||u<t.startSN||u>t.endSN)return 0;let d;const f=u-t.startSN,g=t.fragments;for(g[f]=e,d=f;d>0;d--)cs(g[d],g[d-1]);for(d=f;d<g.length-1;d++)cs(g[d],g[d+1]);return t.fragmentHint&&cs(g[g.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,h}function us(t,e){let i=null;const n=t.fragments;for(let t=n.length-1;t>=0;t--){const e=n[t].initSegment;if(e){i=e;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;let r,s=0;if(function(t,e,i){const n=e.skippedSegments,r=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=r;t<=s;t++){const r=l[a+t];let s=o[t];n&&!s&&t<n&&(s=e.fragments[t]=r),r&&s&&i(r,s)}}(t,e,((t,n)=>{t.relurl&&(s=t.cc-n.cc),ki(t.startPTS)&&ki(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&&(r=n),e.PTSKnown=e.alignedSliding=!0),n.elementaryStreams=t.elementaryStreams,n.loader=t.loader,n.stats=t.stats,t.initSegment&&(n.initSegment=t.initSegment,i=t.initSegment)})),i){(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach((t=>{var e;!t||t.initSegment&&t.initSegment.relurl!==(null==(e=i)?void 0:e.relurl)||(t.initSegment=i)}))}if(e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some((t=>!t)),e.deltaUpdateFailed){Oi.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,i){const n=bi({},t);i&&i.forEach((t=>{delete n[t]}));return Object.keys(e).forEach((t=>{const i=new Bi(e[t].attr,n[t]);i.isValid?n[t]=i:Oi.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){Oi.warn("discontinuity sliding from playlist, take drift into account");for(let t=0;t<a.length;t++)a[t].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),function(t,e,i){if(t&&e){let n=0;for(let r=0,s=t.length;r<=s;r++){const s=t[r],a=e[r+n];s&&a&&s.index===a.index&&s.fragment.sn===a.fragment.sn?i(s,a):n--}}}(t.partList,e.partList,((t,e)=>{e.elementaryStreams=t.elementaryStreams,e.stats=t.stats})),r?hs(e,r,r.startPTS,r.endPTS,r.startDTS,r.endDTS):ds(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 ds(t,e){const i=e.startSN+e.skippedSegments-t.startSN,n=t.fragments;i<0||i>=n.length||fs(e,n[i].start)}function fs(t,e){if(e){const i=t.fragments;for(let n=t.skippedSegments;n<i.length;n++)i[n].start+=e;t.fragmentHint&&(t.fragmentHint.start+=e)}}function gs(t,e,i){var n;return null!=t&&t.details?ps(null==(n=t.details)?void 0:n.partList,e,i):null}function ps(t,e,i){if(t)for(let n=t.length;n--;){const r=t[n];if(r.index===i&&r.fragment.sn===e)return r}return null}function ms(t){t.forEach(((t,e)=>{const{details:i}=t;null!=i&&i.fragments&&i.fragments.forEach((t=>{t.level=e}))}))}function vs(t){switch(t.details){case Ci.FRAG_LOAD_TIMEOUT:case Ci.KEY_LOAD_TIMEOUT:case Ci.LEVEL_LOAD_TIMEOUT:case Ci.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function ys(t,e){const i=vs(e);return t.default[(i?"timeout":"error")+"Retry"]}function As(t,e){const i="linear"===t.backoff?1:Math.pow(2,e);return Math.min(i*t.retryDelayMs,t.maxRetryDelayMs)}function Es(t){return Ai(Ai({},t),{errorRetry:null,timeoutRetry:null})}function Ts(t,e,i,n){if(!t)return!1;const r=null==n?void 0:n.code,s=e<t.maxNumRetry&&(function(t){return 0===t&&!1===navigator.onLine||!!t&&(t<400||t>499)}(r)||!!i);return t.shouldRetry?t.shouldRetry(t,e,i,n,s):s}const bs=function(t,e){let i=0,n=t.length-1,r=null,s=null;for(;i<=n;){r=(i+n)/2|0,s=t[r];const a=e(s);if(a>0)i=r+1;else{if(!(a<0))return s;n=r-1}}return null};function ks(t,e,i=0,n=0,r=.005){let s=null;if(t){s=e[t.sn-e[0].sn+1]||null;const n=t.endDTS-i;n>0&&n<15e-7&&(i+=15e-7)}else 0===i&&0===e[0].start&&(s=e[0]);if(s&&((!t||t.level===s.level)&&0===Ss(i,n,s)||function(t,e,i){if(e&&0===e.start&&e.level<t.level&&(e.endPTS||0)>0){const n=e.tagList.reduce(((t,e)=>("INF"===e[0]&&(t+=parseFloat(e[1])),t)),i);return t.start<=n}return!1}(s,t,Math.min(r,n))))return s;const a=bs(e,Ss.bind(null,i,n));return!a||a===t&&s?s:a}function Ss(t=0,e=0,i){if(i.start<=t&&i.start+i.duration>t)return 0;const n=Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-n<=t?1:i.start-n>t&&i.start?-1:0}function _s(t,e,i){const n=1e3*Math.min(e,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-n>t}var Ls=0,Rs=2,Cs=3,ws=5,Is=0,Ds=1,Ps=2;class Os{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=Oi.log.bind(Oi,`${e}:`),this.warn=Oi.warn.bind(Oi,`${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,i){const n=null==e?void 0:e.renditionReports;if(n){let r=-1;for(let i=0;i<n.length;i++){const s=n[i];let a;try{a=new self.URL(s.URI,e.url).href}catch(t){Oi.warn(`Could not construct new URL for Rendition Report: ${t}`),a=s.URI||""}if(a===t){r=i;break}a===t.substring(0,a.length)&&(r=i)}if(-1!==r){const t=n[r],s=parseInt(t["LAST-MSN"])||(null==e?void 0:e.lastPartSn);let a=parseInt(t["LAST-PART"])||(null==e?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const t=Math.min(e.age-e.partTarget,e.targetduration);a>=0&&t>e.partTarget&&(a+=1)}const o=i&&ss(i);return new as(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,i){const{details:n,stats:r}=e,s=self.performance.now(),a=r.loading.first?Math.max(0,s-r.loading.first):0;if(n.advancedDateTime=Date.now()-a,n.live||null!=i&&i.live){if(n.reloaded(i),i&&this.log(`live playlist ${t} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),i&&n.fragments.length>0&&us(i,n),!this.canLoad||!n.live)return;let a,o,l;if(n.canBlockReload&&n.endSN&&n.advanced){const t=this.hls.config.lowLatencyMode,r=n.lastPartSn,s=n.endSN,c=n.lastPartIndex,h=r===s;-1!==c?(o=h?s+1:r,l=h?t?0:c:c+1):o=s+1;const u=n.age,d=u+n.ageHeader;let f=Math.min(d-n.partTarget,1.5*n.targetduration);if(f>0){if(i&&f>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.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 ${u.toFixed(2)}s goal: ${f} skip sn ${t} to part ${l}`)}n.tuneInGoal=f}if(a=this.getDeliveryDirectives(n,e.deliveryDirectives,o,l),t||!h)return void this.loadPlaylist(a)}else(n.canBlockReload||n.canSkipUntil)&&(a=this.getDeliveryDirectives(n,e.deliveryDirectives,o,l));const c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,u=function(t,e=1/0){let i=1e3*t.targetduration;if(t.updated){const n=t.fragments,r=4;if(n.length&&i*r>e){const t=1e3*n[n.length-1].duration;t<i&&(i=t)}}else i/=2;return Math.round(i)}(n,1e3*(n.edge-h));n.updated&&s>this.requestScheduled+u&&(this.requestScheduled=r.loading.start),void 0!==o&&n.canBlockReload?this.requestScheduled=r.loading.first+u-(1e3*n.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+u<s?this.requestScheduled=s:this.requestScheduled-s<=0&&(this.requestScheduled+=u);let d=this.requestScheduled-s;d=Math.max(0,d),this.log(`reload live playlist ${t} in ${Math.round(d)} ms`),this.timer=self.setTimeout((()=>this.loadPlaylist(a)),d)}else this.clearTimer()}getDeliveryDirectives(t,e,i,n){let r=ss(t);return null!=e&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,n=e.part,r=is),new as(i,n,r)}checkRetry(t){const e=t.details,i=vs(t),n=t.errorAction,{action:r,retryCount:s=0,retryConfig:a}=n||{},o=!!n&&!!a&&(r===ws||!n.resolved&&r===Rs);if(o){var l;if(this.requestScheduled=-1,s>=a.maxNumRetry)return!1;if(i&&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=As(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 xs{constructor(t,e=0,i=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_=i}sample(t,e){const i=Math.pow(this.alpha_,t);this.estimate_=e*(1-i)+i*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 Ns{constructor(t,e,i,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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new xs(t),this.fast_=new xs(e),this.defaultTTFB_=n,this.ttfb_=new xs(t)}update(t,e){const{slow_:i,fast_:n,ttfb_:r}=this;i.halfLife!==t&&(this.slow_=new xs(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.fast_=new xs(e,n.getEstimate(),n.getTotalWeight())),r.halfLife!==t&&(this.ttfb_=new xs(t,r.getEstimate(),r.getTotalWeight()))}sample(t,e){const i=(t=Math.max(t,this.minDelayMs_))/1e3,n=8*e/i;this.fast_.sample(i,n),this.slow_.sample(i,n)}sampleTTFB(t){const e=t/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(i,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 Ms={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},Fs={};function Bs(t,e,i,n,r,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 h=null;if(null!=a&&a.length)try{h=1===a.length&&a[0]?e.groups[a[0]].channels:a.reduce(((t,i)=>{if(i){const n=e.groups[i];if(!n)throw new Error(`Audio track group ${i} 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!==i||t.bitrate>Math.max(r,8e6))||!!h&&ki(c)&&Object.keys(h).some((t=>parseInt(t)>c))}function Us(t,e,i){const n=t.videoCodec,r=t.audioCodec;if(!n||!r||!i)return Promise.resolve(Ms);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:Ai(Ai({},s),{},{contentType:hr(t,"video")})})));return r&&t.audioGroups&&t.audioGroups.forEach((t=>{var i;t&&(null==(i=e.groups[t])||i.tracks.forEach((e=>{if(e.groupId===t){const t=e.channels||"",i=parseFloat(t);ki(i)&&i>2&&o.push.apply(o,r.split(",").map((t=>({type:"media-source",audio:{contentType:hr(t,"audio"),channels:""+i}}))))}})))})),Promise.all(o.map((t=>{const e=function(t){const{audio:e,video:i}=t,n=i||e;if(n){const t=n.contentType.split('"')[1];if(i)return`r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${t}_${Math.ceil(i.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${t}`}return""}(t);return Fs[e]||(Fs[e]=i.decodingInfo(t))}))).then((t=>({supported:!t.some((t=>!t.supported)),configurations:o,decodingInfoResults:t}))).catch((t=>({supported:!1,configurations:o,decodingInfoResults:[],error:t})))}function $s(t,e){let i=!1,n=[];return t&&(i="SDR"!==t,n=[t]),e&&(n=e.allowedVideoRanges||es.slice(0),i=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=i?n.filter((t=>"SDR"!==t)):["SDR"]),{preferHDR:i,allowedVideoRanges:n}}function Gs(t,e){Oi.log(`[abr] start candidates with "${t}" ignored because ${e}`)}function Vs(t,e,i){if("attrs"in t){const i=e.indexOf(t);if(-1!==i)return i}for(let n=0;n<e.length;n++){if(Ks(t,e[n],i))return n}return-1}function Ks(t,e,i){const{groupId:n,name:r,lang:s,assocLang:a,characteristics:o,default:l}=t,c=t.forced;return(void 0===n||e.groupId===n)&&(void 0===r||e.name===r)&&(void 0===s||e.lang===s)&&(void 0===s||e.assocLang===a)&&(void 0===l||e.default===l)&&(void 0===c||e.forced===c)&&(void 0===o||function(t,e=""){const i=t.split(","),n=e.split(",");return i.length===n.length&&!i.some((t=>-1===n.indexOf(t)))}(o,e.characteristics))&&(void 0===i||i(t,e))}function Hs(t,e){const{audioCodec:i,channels:n}=t;return!(void 0!==i&&(e.audioCodec||"").substring(0,4)!==i.substring(0,4)||void 0!==n&&n!==(e.channels||"2"))}function Ys(t,e,i){for(let n=e;n;n--)if(i(t[n]))return n;for(let n=e+1;n<t.length;n++)if(i(t[n]))return n;return-1}class js{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var Ws="NOT_LOADED",zs="APPENDING",qs="PARTIAL",Xs="OK";class Qs{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(Li.BUFFER_APPENDED,this.onBufferAppended,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.on(Li.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.BUFFER_APPENDED,this.onBufferAppended,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.off(Li.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const i=this.activePartLists[e];if(i)for(let e=i.length;e--;){const n=i[e];if(!n)break;const r=n.end;if(n.start<=t&&null!==r&&t<=r)return n}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,n=Object.keys(i);for(let r=n.length;r--;){const s=i[n[r]];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,i,n){this.timeRanges&&(this.timeRanges[t]=e);const r=(null==n?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach((n=>{const s=this.fragments[n];if(!s)return;if(r>=s.body.sn)return;if(!s.buffered&&!s.loaded)return void(s.body.type===i&&this.removeFragment(s.body));const a=s.range[t];a&&a.time.some((t=>{const i=!this.isTimeBuffered(t.startPTS,t.endPTS,e);return i&&this.removeFragment(s.body),i}))}))}detectPartialFragments(t){const e=this.timeRanges,{frag:i,part:n}=t;if(!e||"initSegment"===i.sn)return;const r=Js(i),s=this.fragments[r];if(!s||s.buffered&&i.gap)return;const a=!i.relurl;if(Object.keys(e).forEach((t=>{const r=i.elementaryStreams[t];if(!r)return;const o=e[t],l=a||!0===r.partial;s.range[t]=this.getBufferedTimes(i,n,l,o)})),s.loaded=null,Object.keys(s.range).length){s.buffered=!0;(s.body.endList=i.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),Zs(s)||this.removeParts(i.sn-1,i.type)}else this.removeFragment(s.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter((e=>e.fragment.sn>=t)))}fragBuffered(t,e){const i=Js(t);let n=this.fragments[i];!n&&e&&(n=this.fragments[i]={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,i,n){const r={time:[],partial:i},s=t.start,a=t.end,o=t.minEndPTS||a,l=t.maxStartPTS||s;for(let t=0;t<n.length;t++){const e=n.start(t)-this.bufferPadding,i=n.end(t)+this.bufferPadding;if(l>=e&&o<=i){r.time.push({startPTS:Math.max(s,n.start(t)),endPTS:Math.min(a,n.end(t))});break}if(s<i&&a>e){const e=Math.max(s,n.start(t)),i=Math.min(a,n.end(t));i>e&&(r.partial=!0,r.time.push({startPTS:e,endPTS:i}))}else if(a<=e)break}return r}getPartialFragment(t){let e,i,n,r=null,s=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach((l=>{const c=o[l];c&&Zs(c)&&(i=c.body.start-a,n=c.body.end+a,t>=i&&t<=n&&(e=Math.min(t-i,n-t),s<=e&&(r=c.body,s=e)))})),r}isEndListAppended(t){const e=this.endListFragments[t];return void 0!==e&&(e.buffered||Zs(e))}getState(t){const e=Js(t),i=this.fragments[e];return i?i.buffered?Zs(i)?qs:Xs:zs:Ws}isTimeBuffered(t,e,i){let n,r;for(let s=0;s<i.length;s++){if(n=i.start(s)-this.bufferPadding,r=i.end(s)+this.bufferPadding,t>=n&&e<=r)return!0;if(e<=n)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:n}=e;if("initSegment"===i.sn||i.bitrateTest)return;const r=n?null:e,s=Js(i);this.fragments[s]={body:i,appendedPTS:null,loaded:r,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:n,timeRanges:r}=e;if("initSegment"===i.sn)return;const s=i.type;if(n){let t=this.activePartLists[s];t||(this.activePartLists[s]=t=[]),t.push(n)}this.timeRanges=r,Object.keys(r).forEach((t=>{const e=r[t];this.detectEvictedFragments(t,e,s,n)}))}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Js(t);return!!this.fragments[e]}hasParts(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)}removeFragmentsInRange(t,e,i,n,r){n&&!this.hasGaps||Object.keys(this.fragments).forEach((s=>{const a=this.fragments[s];if(!a)return;const o=a.body;o.type!==i||n&&!o.gap||o.start<e&&o.end>t&&(a.buffered||r)&&this.removeFragment(o)}))}removeFragment(t){const e=Js(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const e=t.sn;this.activePartLists[t.type]=i.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 Zs(t){var e,i,n;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(i=t.range.audio)?void 0:i.partial)||(null==(n=t.range.audiovideo)?void 0:n.partial))}function Js(t){return`${t.type}_${t.level}_${t.sn}`}const ta={length:0,start:()=>0,end:()=>0};class ea{static isBuffered(t,e){try{if(t){const i=ea.getBuffered(t);for(let t=0;t<i.length;t++)if(e>=i.start(t)&&e<=i.end(t))return!0}}catch(t){}return!1}static bufferInfo(t,e,i){try{if(t){const n=ea.getBuffered(t),r=[];let s;for(s=0;s<n.length;s++)r.push({start:n.start(s),end:n.end(s)});return this.bufferedInfo(r,e,i)}}catch(t){}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,i){e=Math.max(0,e),t.sort((function(t,e){const i=t.start-e.start;return i||e.end-t.end}));let n=[];if(i)for(let e=0;e<t.length;e++){const r=n.length;if(r){const s=n[r-1].end;t[e].start-s<i?t[e].end>s&&(n[r-1].end=t[e].end):n.push(t[e])}else n.push(t[e])}else n=t;let r,s=0,a=e,o=e;for(let t=0;t<n.length;t++){const l=n[t].start,c=n[t].end;if(e+i>=l&&e<c)a=l,o=c,s=o-e;else if(e+i<l){r=l;break}}return{len:s,start:a||0,end:o||0,nextStart:r}}static getBuffered(t){try{return t.buffered}catch(t){return Oi.log("failed to get media.buffered",t),ta}}}class ia{constructor(t,e,i,n=0,r=-1,s=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=i,this.size=n,this.part=r,this.partial=s}}function na(t,e){for(let n=0,r=t.length;n<r;n++){var i;if((null==(i=t[n])?void 0:i.cc)===e)return t[n]}return null}function ra(t,e){if(t){const i=t.start+e;t.start=t.startPTS=i,t.endPTS=i+t.duration}}function sa(t,e){const i=e.fragments;for(let e=0,n=i.length;e<n;e++)ra(i[e],t);e.fragmentHint&&ra(e.fragmentHint,t),e.alignedSliding=!0}function aa(t,e,i){e&&(!function(t,e,i){if(function(t,e,i){return!(!e||!(i.endCC>i.startCC||t&&t.cc<i.startCC))}(t,i,e)){const t=function(t,e){const i=t.fragments,n=e.fragments;if(!n.length||!i.length)return void Oi.log("No fragments to align");const r=na(i,n[0].cc);if(r&&(!r||r.startPTS))return r;Oi.log("No frag in previous level to align on")}(i,e);t&&ki(t.start)&&(Oi.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),sa(t.start,e))}}(t,i,e),!i.alignedSliding&&e&&oa(i,e),i.alignedSliding||!e||i.skippedSegments||ds(e,i))}function oa(t,e){if(!t.hasProgramDateTime||!e.hasProgramDateTime)return;const i=t.fragments,n=e.fragments;if(!i.length||!n.length)return;let r,s;const a=Math.min(e.endCC,t.endCC);e.startCC<a&&t.startCC<a&&(r=na(n,a),s=na(i,a)),r&&s||(r=n[Math.floor(n.length/2)],s=na(i,r.cc)||i[Math.floor(i.length/2)]);const o=r.programDateTime,l=s.programDateTime;if(!o||!l)return;sa((l-o)/1e3-(s.start-r.start),t)}const la=Math.pow(2,17);class ca{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const i=t.url;if(!i)return Promise.reject(new da({type:Ri.NETWORK_ERROR,details:Ci.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();const n=this.config,r=n.fLoader,s=n.loader;return new Promise(((a,o)=>{if(this.loader&&this.loader.destroy(),t.gap){if(t.tagList.some((t=>"GAP"===t[0])))return void o(ua(t));t.gap=!1}const l=this.loader=t.loader=r?new r(n):new s(n),c=ha(t),h=Es(n.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:la};t.stats=l.stats,l.load(c,u,{onSuccess:(e,i,n,r)=>{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:r})},onError:(e,n,r,s)=>{this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Ai({url:i,data:void 0},e),error:new Error(`HTTP Error ${e.code} ${e.text}`),networkDetails:r,stats:s}))},onAbort:(e,i,n)=>{this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:n,stats:e}))},onTimeout:(e,i,n)=>{this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:n,stats:e}))},onProgress:(i,n,r,s)=>{e&&e({frag:t,part:null,payload:r,networkDetails:s})}})}))}loadPart(t,e,i){this.abort();const n=this.config,r=n.fLoader,s=n.loader;return new Promise(((a,o)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap)return void o(ua(t,e));const l=this.loader=t.loader=r?new r(n):new s(n),c=ha(t,e),h=Es(n.fragLoadPolicy.default),u={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:la};e.stats=l.stats,l.load(c,u,{onSuccess:(n,r,s,o)=>{this.resetLoader(t,l),this.updateStatsFromPart(t,e);const c={frag:t,part:e,payload:n.data,networkDetails:o};i(c),a(c)},onError:(i,n,r,s)=>{this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Ai({url:c.url,data:void 0},i),error:new Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:r,stats:s}))},onAbort:(i,n,r)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:r,stats:i}))},onTimeout:(i,n,r)=>{this.resetLoader(t,l),o(new da({type:Ri.NETWORK_ERROR,details:Ci.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${u.timeout}ms`),networkDetails:r,stats:i}))}})}))}updateStatsFromPart(t,e){const i=t.stats,n=e.stats,r=n.total;if(i.loaded+=n.loaded,r){const n=Math.round(t.duration/e.duration),s=Math.min(Math.round(i.loaded/r),n),a=(n-s)*Math.round(i.loaded/s);i.total=i.loaded+a}else i.total=Math.max(i.loaded,i.total);const s=i.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 ha(t,e=null){const i=e||t,n={frag:t,part:e,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},r=i.byteRangeStartOffset,s=i.byteRangeEndOffset;if(ki(r)&&ki(s)){var a;let e=r,i=s;if("initSegment"===t.sn&&"AES-128"===(null==(a=t.decryptdata)?void 0:a.method)){const t=s-r;t%16&&(i=s+(16-t%16)),0!==r&&(n.resetIV=!0,e=r-16)}n.rangeStart=e,n.rangeEnd=i}return n}function ua(t,e){const i=new Error(`GAP ${t.gap?"tag":"attribute"} found`),n={type:Ri.MEDIA_ERROR,details:Ci.FRAG_GAP,fatal:!1,frag:t,error:i,networkDetails:null};return e&&(n.part=e),(e||t).stats.aborted=!0,new da(n)}class da extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class fa{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 ga{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 pa{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),i=new Uint32Array(4);for(let t=0;t<4;t++)i[t]=e.getUint32(4*t);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,n=i[0],r=i[1],s=i[2],a=i[3],o=this.invSubMix,l=o[0],c=o[1],h=o[2],u=o[3],d=new Uint32Array(256);let f=0,g=0,p=0;for(p=0;p<256;p++)d[p]=p<128?p<<1:p<<1^283;for(p=0;p<256;p++){let i=g^g<<1^g<<2^g<<3^g<<4;i=i>>>8^255&i^99,t[f]=i,e[i]=f;const o=d[f],p=d[o],m=d[p];let v=257*d[i]^16843008*i;n[f]=v<<24|v>>>8,r[f]=v<<16|v>>>16,s[f]=v<<8|v>>>24,a[f]=v,v=16843009*m^65537*p^257*o^16843008*f,l[i]=v<<24|v>>>8,c[i]=v<<16|v>>>16,h[i]=v<<8|v>>>24,u[i]=v,f?(f=o^d[d[d[m^o]]],g^=d[d[g]]):f=g=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,n=0;for(;n<e.length&&i;)i=e[n]===this.key[n],n++;if(i)return;this.key=e;const r=this.keySize=e.length;if(4!==r&&6!==r&&8!==r)throw new Error("Invalid aes key size="+r);const s=this.ksRows=4*(r+6+1);let a,o;const l=this.keySchedule=new Uint32Array(s),c=this.invKeySchedule=new Uint32Array(s),h=this.sBox,u=this.rcon,d=this.invSubMix,f=d[0],g=d[1],p=d[2],m=d[3];let v,y;for(a=0;a<s;a++)a<r?v=l[a]=e[a]:(y=v,a%r==0?(y=y<<8|y>>>24,y=h[y>>>24]<<24|h[y>>>16&255]<<16|h[y>>>8&255]<<8|h[255&y],y^=u[a/r|0]<<24):r>6&&a%r==4&&(y=h[y>>>24]<<24|h[y>>>16&255]<<16|h[y>>>8&255]<<8|h[255&y]),l[a]=v=(l[a-r]^y)>>>0);for(o=0;o<s;o++)a=s-o,y=3&o?l[a]:l[a-4],c[o]=o<4||a<=4?y:f[h[y>>>24]]^g[h[y>>>16&255]]^p[h[y>>>8&255]]^m[h[255&y]],c[o]=c[o]>>>0}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}decrypt(t,e,i){const n=this.keySize+6,r=this.invKeySchedule,s=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],c=a[2],h=a[3],u=this.uint8ArrayToUint32Array_(i);let d=u[0],f=u[1],g=u[2],p=u[3];const m=new Int32Array(t),v=new Int32Array(m.length);let y,A,E,T,b,k,S,_,L,R,C,w,I,D;const P=this.networkToHostOrderSwap;for(;e<m.length;){for(L=P(m[e]),R=P(m[e+1]),C=P(m[e+2]),w=P(m[e+3]),b=L^r[0],k=w^r[1],S=C^r[2],_=R^r[3],I=4,D=1;D<n;D++)y=o[b>>>24]^l[k>>16&255]^c[S>>8&255]^h[255&_]^r[I],A=o[k>>>24]^l[S>>16&255]^c[_>>8&255]^h[255&b]^r[I+1],E=o[S>>>24]^l[_>>16&255]^c[b>>8&255]^h[255&k]^r[I+2],T=o[_>>>24]^l[b>>16&255]^c[k>>8&255]^h[255&S]^r[I+3],b=y,k=A,S=E,_=T,I+=4;y=s[b>>>24]<<24^s[k>>16&255]<<16^s[S>>8&255]<<8^s[255&_]^r[I],A=s[k>>>24]<<24^s[S>>16&255]<<16^s[_>>8&255]<<8^s[255&b]^r[I+1],E=s[S>>>24]<<24^s[_>>16&255]<<16^s[b>>8&255]<<8^s[255&k]^r[I+2],T=s[_>>>24]<<24^s[b>>16&255]<<16^s[k>>8&255]<<8^s[255&S]^r[I+3],v[e]=P(y^d),v[e+1]=P(T^f),v[e+2]=P(E^g),v[e+3]=P(A^p),d=L,f=R,g=C,p=w,e+=4}return v.buffer}}class ma{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const t=self.crypto;t&&(this.subtle=t.subtle||t.webkitSubtle)}catch(t){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?function(t){const e=t.byteLength,i=e&&new DataView(t.buffer).getUint8(e-1);return i?cn(t,0,e-i):t}(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,i){return this.useSoftware?new Promise(((n,r)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const s=this.flush();s?n(s.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:n,currentResult:r,remainderData:s}=this;this.logOnce("JS AES decrypt"),s&&(t=jn(s,t),this.remainderData=null);const a=this.getValidChunk(t);if(!a.length)return null;n&&(i=n);let o=this.softwareDecrypter;o||(o=this.softwareDecrypter=new pa),o.expandKey(e);const l=r;return this.currentResult=o.decrypt(a.buffer,0,i),this.currentIV=cn(a,-16).buffer,l||null}webCryptoDecrypt(t,e,i){if(this.key!==e||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(t,e,i));this.key=e,this.fastAesKey=new ga(this.subtle,e)}return this.fastAesKey.expandKey().then((e=>{if(!this.subtle)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new fa(this.subtle,new Uint8Array(i)).decrypt(t.buffer,e)})).catch((n=>(Oi.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(t,e,i))))}onWebCryptoError(t,e,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,i);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 i=t.length-t.length%16;return i!==t.length&&(e=cn(t,0,i),this.remainderData=cn(t,i)),e}logOnce(t){this.logEnabled&&(Oi.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const va=function(t){let e="";const i=t.length;for(let n=0;n<i;n++)e+=`[${t.start(n).toFixed(3)}-${t.end(n).toFixed(3)}]`;return e},ya="STOPPED",Aa="IDLE",Ea="KEY_LOADING",Ta="FRAG_LOADING",ba="FRAG_LOADING_WAITING_RETRY",ka="WAITING_TRACK",Sa="PARSING",_a="PARSED",La="ENDED",Ra="ERROR",Ca="WAITING_INIT_PTS",wa="WAITING_LEVEL";class Ia extends js{constructor(t,e,i,n,r){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=ya,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=r,this.logPrefix=n,this.log=Oi.log.bind(Oi,`${n}:`),this.warn=Oi.warn.bind(Oi,`${n}:`),this.hls=t,this.fragmentLoader=new ca(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new ma(t.config),t.on(Li.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ya}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const i=e.partList;if(null!=i&&i.length){const t=i[i.length-1];return ea.isBuffered(this.media,t.start+t.duration/2)}const n=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}getLevelDetails(){var t;if(this.levels&&null!==this.levelLastLoaded)return null==(t=this.levelLastLoaded)?void 0:t.details}onMediaAttached(t,e){const i=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const n=this.config;this.levels&&n.autoStartLoad&&this.state===ya&&this.startLoad(n.startPosition)}onMediaDetaching(){const t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:i,mediaBuffer:n,state:r}=this,s=i?i.currentTime:0,a=ea.bufferInfo(n||i,s,t.maxBufferHole);if(this.log(`media seeking to ${ki(s)?s.toFixed(3):s}, state: ${r}`),this.state===La)this.resetLoadingState();else if(e){const i=t.maxFragLookUpTolerance,n=e.start-i,r=e.start+e.duration+i;if(!a.len||r<a.start||n>a.end){const t=s>r;(s<n||t)&&(t&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(s,1/0,this.playlistType,!0),this.lastCurrentTime=s),this.loadedmetadata||a.len||(this.nextLoadPosition=this.startPosition=s),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(Li.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=ya,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,e,i){this._loadFragForPlayback(t,e,i)}_loadFragForPlayback(t,e,i){this._doFragLoad(t,e,i,(e=>{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 i=this.state;this.fragContextChanged(t)?(i===Ta||!this.fragCurrent&&i===Sa)&&(this.fragmentTracker.removeFragment(t),this.state=Aa):("payload"in e&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(Li.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))})).catch((e=>{this.state!==ya&&this.state!==Ra&&(this.warn(`Frag error: ${(null==e?void 0:e.message)||e}`),this.resetFragmentLoading(t))}))}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===zs){const e=t.type,n=this.getFwdBufferInfo(this.mediaBuffer,e),r=Math.max(t.duration,n?n.len:this.config.maxBufferLength),s=this.backtrackFragment;(1===(s?t.sn-s.sn:0)||this.reduceMaxBufferLength(r,t.duration))&&i.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===qs&&i.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,i=null){if(!(t-e))return;const n={startOffset:t,endOffset:e,type:i};this.hls.trigger(Li.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:i}=this,{payload:n}=e,r=t.decryptdata;if(n&&n.byteLength>0&&null!=r&&r.key&&r.iv&&"AES-128"===r.method){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),r.key.buffer,r.iv.buffer).catch((e=>{throw i.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((n=>{const r=self.performance.now();return i.trigger(Li.FRAG_DECRYPTED,{frag:t,payload:n,stats:{tstart:s,tdecrypt:r}}),e.payload=n,this.completeInitSegmentLoad(e)}))}return this.completeInitSegmentLoad(e)})).catch((e=>{this.state!==ya&&this.state!==Ra&&(this.warn(e),this.resetFragmentLoading(t))}))}completeInitSegmentLoad(t){const{levels:e}=this;if(!e)throw new Error("init load aborted, missing levels");const i=t.frag.stats;this.state=Aa,t.frag.data=new Uint8Array(t.payload),i.parsing.start=i.buffering.start=self.performance.now(),i.parsing.end=i.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 i,n,r,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===xr?"level":"track"} ${t.level} (frag:[${(null!=(i=t.startPTS)?i:NaN).toFixed(3)}-${(null!=(n=t.endPTS)?n:NaN).toFixed(3)}] > buffer:${a?va(ea.getBuffered(a)):"(detached)"})`),"initSegment"!==t.sn){var o;if(t.type!==Mr){const e=t.elementaryStreams;if(!Object.keys(e).some((t=>!!e[t])))return void(this.state=Aa)}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=Aa,a&&(!this.loadedmetadata&&t.type==xr&&a.buffered.length&&(null==(r=this.fragCurrent)?void 0:r.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:i,part:n,partsLoaded:r}=t,s=!r||0===r.length||r.some((t=>!t)),a=new ia(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!s);e.flush(a)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,n){var r;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!=(r=t.decryptdata)&&r.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=Ea,this.fragCurrent=t,a=this.keyLoader.load(t).then((t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger(Li.KEY_LOADED,t),this.state===Ea&&(this.state=Aa),t})),this.hls.trigger(Li.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(a=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){const r=s.partList;if(r&&n){i>t.end&&s.fragmentHint&&(t=s.fragmentHint);const o=this.getNextPart(r,t,i);if(o>-1){const l=r[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}-${r.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=Ta,c=a?a.then((i=>!i||this.fragContextChanged(i.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(Li.FRAG_LOADING,{frag:t,part:l,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!t.url||this.loadedEndOfParts(r,i))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(i.toFixed(3))}`),ki(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Ta;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(Li.FRAG_LOADING,{frag:t,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):l}doFragPartsLoad(t,e,i,n){return new Promise(((r,s)=>{var a;const o=[],l=null==(a=i.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(Li.FRAG_LOADED,n);const a=gs(i,t.sn,e.index+1)||ps(l,t.sn,e.index+1);if(!a)return r({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===Ci.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(Li.ERROR,e)}else this.hls.trigger(Li.ERROR,{type:Ri.OTHER_ERROR,details:Ci.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Sa)return void(this.fragCurrent||this.state===ya||this.state===Ra||(this.state=Aa));const{frag:i,part:n,level:r}=e,s=self.performance.now();i.stats.parsing.end=s,n&&(n.stats.parsing.end=s),this.updateLevelTiming(i,n,r,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:n,sn:r,part:s}=t;if(null==e||!e[n])return this.warn(`Levels object was unset while buffering fragment ${r} of level ${n}. The current chunk will not be buffered.`),null;const a=e[n],o=s>-1?gs(a,r,s):null,l=o?o.fragment:function(t,e,i){if(null==t||!t.details)return null;const n=t.details;let r=n.fragments[e-n.startSN];return r||(r=n.fragmentHint,r&&r.sn===e?r:e<n.startSN&&i&&i.sn===e?i:null)}(a,r,i);return l?(i&&i!==l&&(l.stats=i.stats),{frag:l,part:o,level:a}):null}bufferFragmentData(t,e,i,n,r){var s;if(!t||this.state!==Sa)return;const{data1:a,data2:o}=t;let l=a;if(a&&o&&(l=jn(a,o)),null==(s=l)||!s.length)return;const c={type:t.type,frag:e,part:i,chunkMeta:n,parent:e.type,data:l};if(this.hls.trigger(Li.BUFFER_APPENDING,c),t.dropped&&t.independent&&!i){if(r)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!ea.isBuffered(e,e.currentTime))return void this.flushMainBuffer(0,t.start);const i=e.currentTime,n=ea.bufferInfo(e,i,0),r=t.duration,s=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),a=Math.max(Math.min(t.start-s,n.end-s),i+s);t.start-a>s&&this.flushMainBuffer(a,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return ki(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:n}}=this,r=ea.bufferInfo(t,e,n);if(0===r.len&&void 0!==r.nextStart){const s=this.fragmentTracker.getBufferedFrag(e,i);if(s&&r.nextStart<s.end)return ea.bufferInfo(t,e,Math.max(r.nextStart,n))}return r}getMaxBufferLength(t){const{config:e}=this;let i;return i=t?Math.max(8*e.maxBufferSize/t,e.maxBufferLength):e.maxBufferLength,Math.min(i,e.maxMaxBufferLength)}reduceMaxBufferLength(t,e){const i=this.config,n=Math.max(Math.min(t-e,i.maxBufferLength),e),r=Math.max(t-3*e,i.maxMaxBufferLength/2,n);return r>=n&&(i.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0)}getAppendedFrag(t,e=xr){const i=this.fragmentTracker.getAppendedFrag(t,xr);return i&&"fragment"in i?i.fragment:i}getNextFragment(t,e){const i=e.fragments,n=i.length;if(!n)return null;const{config:r}=this,s=i[0].start;let a;if(e.live){const o=r.initialLiveManifestSize;if(n<o)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${o})`),null;(!e.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||t<s)&&(a=this.getInitialLiveFragment(e,i),this.startPosition=this.nextLoadPosition=a?this.hls.liveSyncPosition||a.start:t)}else t<=s&&(a=i[0]);if(!a){const i=r.lowLatencyMode?e.partEnd:e.fragmentEnd;a=this.getFragmentAtPosition(t,i,e)}return this.mapToInitFragWhenRequired(a)}isLoopLoading(t,e){const i=this.fragmentTracker.getState(t);return(i===Xs||i===qs&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,n,r){const s=t.gap,a=this.getNextFragment(this.nextLoadPosition,e);if(null===a)return a;if(t=a,s&&t&&!t.gap&&i.nextStart){const e=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n);if(null!==e&&i.len+e.len>=r)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,i){let n=-1,r=!1,s=!0;for(let a=0,o=t.length;a<o;a++){const o=t[a];if(s=s&&!o.independent,n>-1&&i<o.start)break;const l=o.loaded;l?n=-1:(r||o.independent||s)&&o.fragment===e&&(n=a),r=l}return n}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let n=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=function(t,e,i){if(null===e||!Array.isArray(t)||!t.length||!ki(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;i=i||0;for(let n=0;n<t.length;++n){const r=t[n];if(_s(e,i,r))return r}return null}(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const r=i.sn+1;if(r>=t.startSN&&r<=t.endSN){const s=e[r-t.startSN];i.cc===s.cc&&(n=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=function(t,e){return bs(t,(t=>t.cc<e?1:t.cc>e?-1:0))}(e,i.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,i){const{config:n}=this;let{fragPrevious:r}=this,{fragments:s,endSN:a}=i;const{fragmentHint:o}=i,{maxFragLookUpTolerance:l}=n,c=i.partList,h=!!(n.lowLatencyMode&&null!=c&&c.length&&o);let u;if(h&&o&&!this.bitrateTest&&(s=s.concat(o),a=o.sn),t<e){u=ks(r,s,t,t>e-l?0:l)}else u=s[s.length-1];if(u){const t=u.sn-i.startSN,e=this.fragmentTracker.getState(u);if((e===Xs||e===qs&&u.gap)&&(r=u),r&&u.sn===r.sn&&(!h||c[0].fragment.sn>u.sn)){if(r&&u.level===r.level){const e=s[t+1];u=u.sn<a&&this.fragmentTracker.getState(e)!==Xs?e:null}}}return u}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,r=i.currentTime,s=t.fragments[0].start,a=t.edge,o=r>=s-e.maxFragLookUpTolerance&&r<=a;if(null!==n&&i.duration>n&&(r<n||!o)){const s=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!o&&i.readyState<4||r<a-s)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${n.toFixed(3)}`),i.currentTime=n))}}alignPlaylists(t,e,i){const n=t.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;const r=t.fragments[0].start,s=!e,a=t.alignedSliding&&ki(r);if(s||!a&&!r){const{fragPrevious:r}=this;aa(r,i,t);const s=t.fragments[0].start;return this.log(`Live playlist sliding: ${s.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${r?r.sn:"na"} fragments: ${n}`),s}return r}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)}setStartPosition(t,e){let i=this.startPosition;if(i<e&&(i=-1),-1===i||-1===this.lastCurrentTime){const n=null!==this.startTimeOffset,r=n?this.startTimeOffset:t.startTimeOffset;null!==r&&ki(r)?(i=e+r,r<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log(`Start time offset ${r} found in ${n?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||e:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===ba)||(this.state=Aa)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const t=this.getCurrentContext(e.chunkMeta);t&&(e.frag=t.frag)}const i=e.frag;if(!i||i.type!==t||!this.levels)return;var n;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(n=this.fragCurrent)?void 0:n.url}`);const r=e.details===Ci.FRAG_GAP;r&&this.fragmentTracker.fragBuffered(i,!0);const s=e.errorAction,{action:a,retryCount:o=0,retryConfig:l}=s||{};if(s&&a===ws&&l){this.resetStartWhenNotLoaded(this.levelLastLoaded);const n=As(l,o);this.warn(`Fragment ${i.sn} of ${t} ${i.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=ba}else if(l&&s){if(this.resetFragmentErrors(t),!(o<l.maxNumRetry))return void Oi.warn(`${e.details} reached or exceeded max retry (${o})`);r||a===Cs||(s.resolved=!0)}else(null==s?void 0:s.action)===Rs?this.state=wa:this.state=Ra;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===Sa||this.state===_a){const e=t.frag,i=t.parent,n=this.getFwdBufferInfo(this.mediaBuffer,i),r=n&&n.len>.5;r&&this.reduceMaxBufferLength(n.len,(null==e?void 0:e.duration)||10);const s=!r;return s&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${i} buffer`),e&&(this.fragmentTracker.removeFragment(e),this.nextLoadPosition=e.start),this.resetLoadingState(),s}return!1}resetFragmentErrors(t){t===Nr&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==ya&&(this.state=Aa)}afterBufferFlushed(t,e,i){if(!t)return;const n=ea.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,n,i),this.state===La&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Aa}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,i,n){var r;const s=i.details;if(!s)return void this.warn("level.details undefined");if(!Object.keys(t.elementaryStreams).reduce(((e,r)=>{const a=t.elementaryStreams[r];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${t.sn} ${r} duration reliably (${o})`),e||!1;const l=n?0:hs(s,t,a.startPTS,a.endPTS,a.startDTS,a.endDTS);return this.hls.trigger(Li.LEVEL_PTS_UPDATED,{details:s,level:i,drift:l,type:r,frag:t,start:a.startPTS,end:a.endPTS}),!0}return e}),!1)&&null===(null==(r=this.transmuxer)?void 0:r.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===i.fragmentError&&(i.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(e.message),this.hls.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:t,reason:`Found no media in msn ${t.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=_a,this.hls.trigger(Li.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 Da{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let i;return t.length?(i=1===t.length?t[0]:function(t,e){const i=new Uint8Array(e);let n=0;for(let e=0;e<t.length;e++){const r=t[e];i.set(r,n),n+=r.length}return i}(t,e),this.reset(),i):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}function Pa(t="",e=9e4){return{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Oa{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,i){}demux(t,e){this.cachedData&&(t=jn(this.cachedData,t),this.cachedData=null);let i,n=dn(t,0),r=n?n.length:0;const s=this._audioTrack,a=this._id3Track,o=n?pn(n):void 0,l=t.length;for((null===this.basePTS||0===this.frameIndex&&ki(o))&&(this.basePTS=xa(o,e,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),n&&n.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:Yr,duration:Number.POSITIVE_INFINITY});r<l;){if(this.canParse(t,r)){const e=this.appendFrame(s,t,r);e?(this.frameIndex++,this.lastPTS=e.sample.pts,r+=e.length,i=r):r=l}else gn(t,r)?(n=dn(t,r),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:Yr,duration:Number.POSITIVE_INFINITY}),r+=n.length,i=r):r++;if(r===l&&i!==l){const e=cn(t,i);this.cachedData?this.cachedData=jn(this.cachedData,e):this.cachedData=e}}return{audioTrack:s,videoTrack:Pa(),id3Track:a,textTrack:Pa()}}demuxSampleAes(t,e,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Pa(),id3Track:this._id3Track,textTrack:Pa()}}destroy(){}}const xa=(t,e,i)=>{if(ki(t))return 90*t;return 9e4*e+(i?9e4*i.baseTime/i.timescale:0)};function Na(t,e){return 255===t[e]&&240==(246&t[e+1])}function Ma(t,e){return 1&t[e+1]?7:9}function Fa(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function Ba(t,e){return e+1<t.length&&Na(t,e)}function Ua(t,e){if(Ba(t,e)){const i=Ma(t,e);if(e+i>=t.length)return!1;const n=Fa(t,e);if(n<=i)return!1;const r=e+n;return r===t.length||Ba(t,r)}return!1}function $a(t,e,i,n,r){if(!t.samplerate){const s=function(t,e,i,n){let r,s,a,o;const l=navigator.userAgent.toLowerCase(),c=n,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=1+((192&e[i+2])>>>6);const u=(60&e[i+2])>>>2;if(!(u>h.length-1))return a=(1&e[i+2])<<2,a|=(192&e[i+3])>>>6,Oi.log(`manifest codec:${n}, ADTS type:${r}, samplingIndex:${u}`),/firefox/i.test(l)?u>=6?(r=5,o=new Array(4),s=u-3):(r=2,o=new Array(2),s=u):-1!==l.indexOf("android")?(r=2,o=new Array(2),s=u):(r=5,o=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&u>=6?s=u-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(u>=6&&1===a||/vivaldi/i.test(l))||!n&&1===a)&&(r=2,o=new Array(2)),s=u)),o[0]=r<<3,o[0]|=(14&u)>>1,o[1]|=(1&u)<<7,o[1]|=a<<3,5===r&&(o[1]|=(14&s)>>1,o[2]=(1&s)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[u],channelCount:a,codec:"mp4a.40."+r,manifestCodec:c};{const e=new Error(`invalid ADTS sampling index:${u}`);t.emit(Li.ERROR,Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_PARSING_ERROR,fatal:!0,error:e,reason:e.message})}}(e,i,n,r);if(!s)return;t.config=s.config,t.samplerate=s.samplerate,t.channelCount=s.channelCount,t.codec=s.codec,t.manifestCodec=s.manifestCodec,Oi.log(`parsed codec:${t.codec}, rate:${s.samplerate}, channels:${s.channelCount}`)}}function Ga(t){return 9216e4/t}function Va(t,e,i,n,r){const s=n+r*Ga(t.samplerate),a=function(t,e){const i=Ma(t,e);if(e+i<=t.length){const n=Fa(t,e)-i;if(n>0)return{headerLength:i,frameLength:n}}}(e,i);let o;if(a){const{frameLength:n,headerLength:r}=a,l=r+n,c=Math.max(0,i+l-e.length);c?(o=new Uint8Array(l-r),o.set(e.subarray(i+r,e.length),0)):o=e.subarray(i+r,i+l);const h={unit:o,pts:s};return c||t.samples.push(h),{sample:h,length:l,missing:c}}const l=e.length-i;o=new Uint8Array(l),o.set(e.subarray(i,e.length),0);return{sample:{unit:o,pts:s},length:l,missing:-1}}let Ka=null;const Ha=[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],Ya=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ja=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Wa=[0,1,1,4];function za(t,e,i,n,r){if(i+24>e.length)return;const s=qa(e,i);if(s&&i+s.frameLength<=e.length){const a=n+r*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:e.subarray(i,i+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 qa(t,e){const i=t[e+1]>>3&3,n=t[e+1]>>1&3,r=t[e+2]>>4&15,s=t[e+2]>>2&3;if(1!==i&&0!==r&&15!==r&&3!==s){const a=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*Ha[14*(3===i?3-n:3===n?3:4)+r-1],c=Ya[3*(3===i?0:2===i?1:2)+s],h=3===o?1:2,u=ja[i][n],d=Wa[n],f=8*u*d,g=Math.floor(u*l/c+a)*d;if(null===Ka){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ka=t?parseInt(t[1]):0}return!!Ka&&Ka<=87&&2===n&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:f}}}function Xa(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function Qa(t,e){return e+1<t.length&&Xa(t,e)}function Za(t,e){if(e+1<t.length&&Xa(t,e)){const i=4,n=qa(t,e);let r=i;null!=n&&n.frameLength&&(r=n.frameLength);const s=e+r;return s===t.length||Qa(t,s)}return!1}const Ja=/\/emsg[-/]ID3/i;const to=(t,e)=>{let i=0,n=5;e+=n;const r=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[0]=(a[0]&s[0])>>l,i=i?i<<o|r[0]:r[0],e+=1,n-=o}return i};class eo extends Oa{constructor(t){super(),this.observer=void 0,this.observer=t}resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}canParse(t,e){return e+64<t.length}appendFrame(t,e,i){const n=io(t,e,i,this.basePTS,this.frameIndex);if(-1!==n){return{sample:t.samples[t.samples.length-1],length:n,missing:0}}}static probe(t){if(!t)return!1;const e=dn(t,0);if(!e)return!1;const i=e.length;return 11===t[i]&&119===t[i+1]&&void 0!==pn(e)&&to(t,i)<16}}function io(t,e,i,n,r){if(i+8>e.length)return-1;if(11!==e[i]||119!==e[i+1])return-1;const s=e[i+4]>>6;if(s>=3)return-1;const a=[48e3,44100,32e3][s],o=63&e[i+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+s];if(i+l>e.length)return-1;const c=e[i+6]>>5;let h=0;2===c?h+=2:(1&c&&1!==c&&(h+=2),4&c&&(h+=2));const u=(e[i+6]<<8|e[i+7])>>12-h&1,d=[2,1,2,3,3,4,4,5][c]+u,f=e[i+5]>>3,g=7&e[i+5],p=new Uint8Array([s<<6|f<<1|g>>2,(3&g)<<6|c<<3|u<<2|o>>4,o<<4&224]),m=n+r*(1536/a*9e4),v=e.subarray(i,i+l);return t.config=p,t.channelCount=d,t.samplerate=a,t.samples.push({unit:v,pts:m}),l}class no{constructor(){this.VideoSample=null}createVideoSample(t,e,i,n){return{key:t,frame:!1,pts:e,dts:i,units:[],debug:n,length:0}}getLastNalUnit(t){var e;let i,n=this.VideoSample;if(n&&0!==n.units.length||(n=t[t.length-1]),null!=(e=n)&&e.units){const t=n.units;i=t[t.length-1]}return i}pushAccessUnit(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){const i=e.samples,n=i.length;if(!n)return void e.dropped++;{const e=i[n-1];t.pts=e.pts,t.dts=e.dts}}e.samples.push(t)}t.debug.length&&Oi.log(t.pts+"/"+t.dts+":"+t.debug)}}class ro{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,i=t.byteLength-e,n=new Uint8Array(4),r=Math.min(4,e);if(0===r)throw new Error("no bytes available");n.set(t.subarray(i,i+r)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*r,this.bytesAvailable-=r}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 i=this.word>>>32-e;if(t>32&&Oi.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?i<<e|this.readBits(e):i}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>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,i=8,n=8;for(let r=0;r<t;r++)0!==n&&(e=this.readEG(),n=(i+e+256)%256),i=0===n?i:n}readSPS(){let t,e,i,n=0,r=0,s=0,a=0;const o=this.readUByte.bind(this),l=this.readBits.bind(this),c=this.readUEG.bind(this),h=this.readBoolean.bind(this),u=this.skipBits.bind(this),d=this.skipEG.bind(this),f=this.skipUEG.bind(this),g=this.skipScalingList.bind(this);o();const p=o();if(l(5),u(3),o(),f(),100===p||110===p||122===p||244===p||44===p||83===p||86===p||118===p||128===p){const t=c();if(3===t&&u(1),f(),f(),u(1),h())for(e=3!==t?8:12,i=0;i<e;i++)h()&&g(i<6?16:64)}f();const m=c();if(0===m)c();else if(1===m)for(u(1),d(),d(),t=c(),i=0;i<t;i++)d();f(),u(1);const v=c(),y=c(),A=l(1);0===A&&u(1),u(1),h()&&(n=c(),r=c(),s=c(),a=c());let E=[1,1];if(h()&&h()){switch(o()){case 1:E=[1,1];break;case 2:E=[12,11];break;case 3:E=[10,11];break;case 4:E=[16,11];break;case 5:E=[40,33];break;case 6:E=[24,11];break;case 7:E=[20,11];break;case 8:E=[32,11];break;case 9:E=[80,33];break;case 10:E=[18,11];break;case 11:E=[15,11];break;case 12:E=[64,33];break;case 13:E=[160,99];break;case 14:E=[4,3];break;case 15:E=[3,2];break;case 16:E=[2,1];break;case 255:E=[o()<<8|o(),o()<<8|o()]}}return{width:Math.ceil(16*(v+1)-2*n-2*r),height:(2-A)*(y+1)*16-(A?2:4)*(s+a),pixelRatio:E}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class so extends no{parseAVCPES(t,e,i,n,r){const s=this.parseAVCNALu(t,i.data);let a,o=this.VideoSample,l=!1;i.data=null,o&&s.length&&!t.audFound&&(this.pushAccessUnit(o,t),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts,"")),s.forEach((n=>{var s;switch(n.type){case 1:{let e=!1;a=!0;const r=n.data;if(l&&r.length>4){const t=new ro(r).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,i.pts,i.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,i.pts,i.dts,"")),o.key=!0,o.frame=!0;break;case 6:a=!0,qn(n.data,1,i.pts,e.samples);break;case 7:{var h,u;a=!0,l=!0;const e=n.data,i=new ro(e).readSPS();if(!t.sps||t.width!==i.width||t.height!==i.height||(null==(h=t.pixelRatio)?void 0:h[0])!==i.pixelRatio[0]||(null==(u=t.pixelRatio)?void 0:u[1])!==i.pixelRatio[1]){t.width=i.width,t.height=i.height,t.pixelRatio=i.pixelRatio,t.sps=[e],t.duration=r;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,i.pts,i.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 i=e.byteLength;let n=t.naluState||0;const r=n,s=[];let a,o,l,c=0,h=-1,u=0;for(-1===n&&(h=0,u=31&e[0],n=0,c=1);c<i;)if(a=e[c++],n)if(1!==n)if(a)if(1===a){if(o=c-n-1,h>=0){const t={data:e.subarray(h,o),type:u};s.push(t)}else{const i=this.getLastNalUnit(t.samples);i&&(r&&c<=4-r&&i.state&&(i.data=i.data.subarray(0,i.data.byteLength-r)),o>0&&(i.data=jn(i.data,e.subarray(0,o)),i.state=0))}c<i?(l=31&e[c],h=c,u=l,n=0):n=-1}else n=0;else n=3;else n=a?0:2;else n=a?0:1;if(h>=0&&n>=0){const t={data:e.subarray(h,i),type:u,state:n};s.push(t)}if(0===s.length){const i=this.getLastNalUnit(t.samples);i&&(i.data=jn(i.data,e))}return t.naluState=n,s}}class ao{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new ma(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const n=t[e].unit;if(n.length<=16)return;const r=n.subarray(16,n.length-n.length%16),s=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(s).then((r=>{const s=new Uint8Array(r);n.set(s,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,i)}))}decryptAacSamples(t,e,i){for(;;e++){if(e>=t.length)return void i();if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=16*Math.floor((t.length-48)/160)+16,i=new Int8Array(e);let n=0;for(let e=32;e<t.length-16;e+=160,n+=16)i.set(t.subarray(e,e+16),n);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let n=0;for(let e=32;e<t.length-16;e+=160,n+=16)t.set(i.subarray(n,n+16),e);return t}decryptAvcSample(t,e,i,n,r){const s=Xn(r.data),a=this.getAvcEncryptedData(s);this.decryptBuffer(a.buffer).then((a=>{r.data=this.getAvcDecryptedUnit(s,a),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,n)}))}decryptAvcSamples(t,e,i,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length)return void n();const r=t[e].units;for(;!(i>=r.length);i++){const s=r[i];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(t,e,i,n,s),this.decrypter.isSync())))return}}}}const oo=188;class lo{constructor(t,e,i){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=i,this.videoParser=new so}static probe(t){const e=lo.syncOffset(t);return e>0&&Oi.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),-1!==e}static syncOffset(t){const e=t.length;let i=Math.min(940,e-oo)+1,n=0;for(;n<i;){let r=!1,s=-1,a=0;for(let o=n;o<e;o+=oo){if(71!==t[o]||e-o!==oo&&71!==t[o+oo]){if(a)return-1;break}if(a++,-1===s&&(s=o,0!==s&&(i=Math.min(s+18612,t.length-oo)+1)),r||(r=0===co(t,o)),r&&a>1&&(0===s&&a>2||o+oo>i))return s}n++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:In[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}}resetInitSegment(t,e,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=lo.createTrack("video"),this._audioTrack=lo.createTrack("audio",n),this._id3Track=lo.createTrack("id3"),this._txtTrack=lo.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=n}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_videoTrack:e,_id3Track:i}=this;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(t,e,i=!1,n=!1){let r;i||(this.sampleAes=null);const s=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let c=s.pid,h=s.pesData,u=a.pid,d=o.pid,f=a.pesData,g=o.pesData,p=null,m=this.pmtParsed,v=this._pmtId,y=t.length;if(this.remainderData&&(y=(t=jn(this.remainderData,t)).length,this.remainderData=null),y<oo&&!n)return this.remainderData=t,{audioTrack:a,videoTrack:s,id3Track:o,textTrack:l};const A=Math.max(0,lo.syncOffset(t));y-=(y-A)%oo,y<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,y,t.buffer.byteLength-y));let E=0;for(let e=A;e<y;e+=oo)if(71===t[e]){const n=!!(64&t[e+1]),y=co(t,e);let E;if((48&t[e+3])>>4>1){if(E=e+5+t[e+4],E===e+oo)continue}else E=e+4;switch(y){case c:n&&(h&&(r=po(h))&&this.videoParser.parseAVCPES(s,l,r,!1,this._duration),h={data:[],size:0}),h&&(h.data.push(t.subarray(E,e+oo)),h.size+=e+oo-E);break;case u:if(n){if(f&&(r=po(f)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,r);break;case"mp3":this.parseMPEGPES(a,r);break;case"ac3":this.parseAC3PES(a,r)}f={data:[],size:0}}f&&(f.data.push(t.subarray(E,e+oo)),f.size+=e+oo-E);break;case d:n&&(g&&(r=po(g))&&this.parseID3PES(o,r),g={data:[],size:0}),g&&(g.data.push(t.subarray(E,e+oo)),g.size+=e+oo-E);break;case 0:n&&(E+=t[E]+1),v=this._pmtId=ho(t,E);break;case v:{n&&(E+=t[E]+1);const r=uo(t,E,this.typeSupported,i,this.observer);c=r.videoPid,c>0&&(s.pid=c,s.segmentCodec=r.segmentVideoCodec),u=r.audioPid,u>0&&(a.pid=u,a.segmentCodec=r.segmentAudioCodec),d=r.id3Pid,d>0&&(o.pid=d),null===p||m||(Oi.warn(`MPEG-TS PMT found at ${e} after unknown PID '${p}'. Backtracking to sync byte @${A} to parse all TS packets.`),p=null,e=A-188),m=this.pmtParsed=!0;break}case 17:case 8191:break;default:p=y}}else E++;E>0&&fo(this.observer,new Error(`Found ${E} TS packet/s that do not start with 0x47`)),s.pesData=h,a.pesData=f,o.pesData=g;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:i,id3Track:n,textTrack:r}=t,s=i.pesData,a=e.pesData,o=n.pesData;let l;if(s&&(l=po(s))?(this.videoParser.parseAVCPES(i,r,l,!0,this._duration),i.pesData=null):i.pesData=s,a&&(l=po(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&&Oi.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=a;o&&(l=po(o))?(this.parseID3PES(n,l),n.pesData=null):n.pesData=o}demuxSampleAes(t,e,i){const n=this.demux(t,i,!0,!this.config.progressive),r=this.sampleAes=new ao(this.observer,this.config,e);return this.decrypt(n,r)}decrypt(t,e){return new Promise((i=>{const{audioTrack:n,videoTrack:r}=t;n.samples&&"aac"===n.segmentCodec?e.decryptAacSamples(n.samples,0,(()=>{r.samples?e.decryptAvcSamples(r.samples,0,0,(()=>{i(t)})):i(t)})):r.samples&&e.decryptAvcSamples(r.samples,0,0,(()=>{i(t)}))}))}destroy(){this._duration=0}parseAACPES(t,e){let i=0;const n=this.aacOverFlow;let r,s,a,o=e.data;if(n){this.aacOverFlow=null;const e=n.missing,r=n.sample.unit.byteLength;if(-1===e)o=jn(n.sample.unit,o);else{const s=r-e;n.sample.unit.set(o.subarray(0,e),s),t.samples.push(n.sample),i=n.missing}}for(r=i,s=o.length;r<s-1&&!Ba(o,r);r++);if(r!==i){let t;const e=r<s-1;if(t=e?`AAC PES did not start with ADTS header,offset:${r}`:"No ADTS header found in AAC PES",fo(this.observer,new Error(t),e),!e)return}if($a(t,this.observer,o,r,this.audioCodec),void 0!==e.pts)a=e.pts;else{if(!n)return void Oi.warn("[tsdemuxer]: AAC PES unknown PTS");{const e=Ga(t.samplerate);a=n.sample.pts+e}}let l,c=0;for(;r<s;){if(l=Va(t,o,r,a,c),r+=l.length,l.missing){this.aacOverFlow=l;break}for(c++;r<s-1&&!Ba(o,r);r++);}}parseMPEGPES(t,e){const i=e.data,n=i.length;let r=0,s=0;const a=e.pts;if(void 0!==a)for(;s<n;)if(Qa(i,s)){const e=za(t,i,s,a,r);if(!e)break;s+=e.length,r++}else s++;else Oi.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(t,e){{const i=e.data,n=e.pts;if(void 0===n)return void Oi.warn("[tsdemuxer]: AC3 PES unknown PTS");const r=i.length;let s,a=0,o=0;for(;o<r&&(s=io(t,i,o,n,a++))>0;)o+=s}}parseID3PES(t,e){if(void 0===e.pts)return void Oi.warn("[tsdemuxer]: ID3 PES unknown PTS");const i=bi({},e,{type:this._videoTrack?Wr:Yr,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function co(t,e){return((31&t[e+1])<<8)+t[e+2]}function ho(t,e){return(31&t[e+10])<<8|t[e+11]}function uo(t,e,i,n,r){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]);e<a;){const a=co(t,e),o=(15&t[e+3])<<8|t[e+4];switch(t[e]){case 207:if(!n){go("ADTS AAC");break}case 15:-1===s.audioPid&&(s.audioPid=a);break;case 21:-1===s.id3Pid&&(s.id3Pid=a);break;case 219:if(!n){go("H.264");break}case 27:-1===s.videoPid&&(s.videoPid=a,s.segmentVideoCodec="avc");break;case 3:case 4:i.mpeg||i.mp3?-1===s.audioPid&&(s.audioPid=a,s.segmentAudioCodec="mp3"):Oi.log("MPEG audio found, not supported in this browser");break;case 193:if(!n){go("AC-3");break}case 129:i.ac3?-1===s.audioPid&&(s.audioPid=a,s.segmentAudioCodec="ac3"):Oi.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===s.audioPid&&o>0){let n=e+5,r=o;for(;r>2;){if(106===t[n])!0!==i.ac3?Oi.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,r-=e}}break;case 194:case 135:return fo(r,new Error("Unsupported EC-3 in M2TS found")),s;case 36:return fo(r,new Error("Unsupported HEVC in M2TS found")),s}e+=o+5}return s}function fo(t,e,i){Oi.warn(`parsing error: ${e.message}`),t.emit(Li.ERROR,Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:e,reason:e.message})}function go(t){Oi.log(`${t} with AES-128-CBC encryption found in unencrypted stream`)}function po(t){let e,i,n,r,s,a=0;const o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=jn(o[0],o[1]),o.splice(1,1);e=o[0];if(1===(e[0]<<16)+(e[1]<<8)+e[2]){if(i=(e[4]<<8)+e[5],i&&i>t.size-6)return null;const l=e[7];192&l&&(r=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,r-s>54e5&&(Oi.warn(`${Math.round((r-s)/9e4)}s delta between PTS and DTS, align them`),r=s)):s=r),n=e[8];let c=n+9;if(t.size<=c)return null;t.size-=c;const h=new Uint8Array(t.size);for(let t=0,i=o.length;t<i;t++){e=o[t];let i=e.byteLength;if(c){if(c>i){c-=i;continue}e=e.subarray(c),i-=c,c=0}h.set(e,a),a+=i}return i&&(i-=n+3),{data:h,pts:r,dts:s,len:i}}return null}class mo{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 vo=Math.pow(2,32)-1;class yo{static init(){let t;for(t in yo.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:[]},yo.types)yo.types.hasOwnProperty(t)&&(yo.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]),i=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]);yo.HDLR_TYPES={video:e,audio:i};const n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);yo.STTS=yo.STSC=yo.STCO=r,yo.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),yo.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),yo.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),yo.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]);yo.FTYP=yo.box(yo.types.ftyp,s,o,s,a),yo.DINF=yo.box(yo.types.dinf,yo.box(yo.types.dref,n))}static box(t,...e){let i=8,n=e.length;const r=n;for(;n--;)i+=e[n].byteLength;const s=new Uint8Array(i);for(s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(t,4),n=0,i=8;n<r;n++)s.set(e[n],i),i+=e[n].byteLength;return s}static hdlr(t){return yo.box(yo.types.hdlr,yo.HDLR_TYPES[t])}static mdat(t){return yo.box(yo.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(vo+1)),n=Math.floor(e%(vo+1));return yo.box(yo.types.mdhd,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,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))}static mdia(t){return yo.box(yo.types.mdia,yo.mdhd(t.timescale,t.duration),yo.hdlr(t.type),yo.minf(t))}static mfhd(t){return yo.box(yo.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?yo.box(yo.types.minf,yo.box(yo.types.smhd,yo.SMHD),yo.DINF,yo.stbl(t)):yo.box(yo.types.minf,yo.box(yo.types.vmhd,yo.VMHD),yo.DINF,yo.stbl(t))}static moof(t,e,i){return yo.box(yo.types.moof,yo.mfhd(t),yo.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=yo.trak(t[e]);return yo.box.apply(null,[yo.types.moov,yo.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(yo.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=yo.trex(t[e]);return yo.box.apply(null,[yo.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(vo+1)),n=Math.floor(e%(vo+1)),r=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,i>>24,i>>16&255,i>>8&255,255&i,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 yo.box(yo.types.mvhd,r)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let n,r;for(n=0;n<e.length;n++)r=e[n].flags,i[n+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return yo.box(yo.types.sdtp,i)}static stbl(t){return yo.box(yo.types.stbl,yo.stsd(t),yo.box(yo.types.stts,yo.STTS),yo.box(yo.types.stsc,yo.STSC),yo.box(yo.types.stsz,yo.STSZ),yo.box(yo.types.stco,yo.STCO))}static avc1(t){let e,i,n,r=[],s=[];for(e=0;e<t.sps.length;e++)i=t.sps[e],n=i.byteLength,r.push(n>>>8&255),r.push(255&n),r=r.concat(Array.prototype.slice.call(i));for(e=0;e<t.pps.length;e++)i=t.pps[e],n=i.byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));const a=yo.box(yo.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(s))),o=t.width,l=t.height,c=t.pixelRatio[0],h=t.pixelRatio[1];return yo.box(yo.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,yo.box(yo.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),yo.box(yo.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,h>>24,h>>16&255,h>>8&255,255&h])))}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 yo.box(yo.types.mp4a,yo.audioStsd(t),yo.box(yo.types.esds,yo.esds(t)))}static mp3(t){return yo.box(yo.types[".mp3"],yo.audioStsd(t))}static ac3(t){return yo.box(yo.types["ac-3"],yo.audioStsd(t),yo.box(yo.types.dac3,t.config))}static stsd(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?yo.box(yo.types.stsd,yo.STSD,yo.mp3(t)):"ac3"===t.segmentCodec?yo.box(yo.types.stsd,yo.STSD,yo.ac3(t)):yo.box(yo.types.stsd,yo.STSD,yo.mp4a(t)):yo.box(yo.types.stsd,yo.STSD,yo.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,n=t.width,r=t.height,s=Math.floor(i/(vo+1)),a=Math.floor(i%(vo+1));return yo.box(yo.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,r>>8&255,255&r,0,0]))}static traf(t,e){const i=yo.sdtp(t),n=t.id,r=Math.floor(e/(vo+1)),s=Math.floor(e%(vo+1));return yo.box(yo.types.traf,yo.box(yo.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),yo.box(yo.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,s>>24,s>>16&255,s>>8&255,255&s])),yo.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,yo.box(yo.types.trak,yo.tkhd(t),yo.mdia(t))}static trex(t){const e=t.id;return yo.box(yo.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 i=t.samples||[],n=i.length,r=12+16*n,s=new Uint8Array(r);let a,o,l,c,h,u;for(e+=8+r,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<n;a++)o=i[a],l=o.duration,c=o.size,h=o.flags,u=o.cts,s.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,h.isLeading<<2|h.dependsOn,h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|h.isNonSync,61440&h.degradPrio,15&h.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*a);return yo.box(yo.types.trun,s)}static initSegment(t){yo.types||yo.init();const e=yo.moov(t);return jn(yo.FTYP,e)}}yo.types=void 0,yo.HDLR_TYPES=void 0,yo.STTS=void 0,yo.STSC=void 0,yo.STCO=void 0,yo.STSZ=void 0,yo.VMHD=void 0,yo.SMHD=void 0,yo.STSD=void 0,yo.FTYP=void 0,yo.DINF=void 0;const Ao=9e4;function Eo(t,e,i=1,n=!1){const r=t*e*i;return n?Math.round(r):r}function To(t,e=!1){return Eo(t,1e3,1/Ao,e)}let bo,ko=null,So=null;class _o{constructor(t,e,i,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=i,this.ISGenerated=!1,null===ko){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);ko=t?parseInt(t[1]):0}if(null===So){const t=navigator.userAgent.match(/Safari\/(\d+)/i);So=t?parseInt(t[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(t){Oi.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){Oi.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){Oi.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(t){let e=!1;const i=t.reduce(((t,i)=>{const n=i.pts-t;return n<-4294967296?(e=!0,Lo(t,i.pts)):n>0?t:i.pts}),t[0].pts);return e&&Oi.debug("PTS rollover detected"),i}remux(t,e,i,n,r,s,a,o){let l,c,h,u,d,f,g=r,p=r;const m=t.pid>-1,v=e.pid>-1,y=e.samples.length,A=t.samples.length>0,E=a&&y>0||y>1;if((!m||A)&&(!v||E)||this.ISGenerated||a){if(this.ISGenerated){var T,b,k,S;const t=this.videoTrackConfig;!t||e.width===t.width&&e.height===t.height&&(null==(T=e.pixelRatio)?void 0:T[0])===(null==(b=t.pixelRatio)?void 0:b[0])&&(null==(k=e.pixelRatio)?void 0:k[1])===(null==(S=t.pixelRatio)?void 0:S[1])||this.resetInitSegment()}else h=this.generateIS(t,e,r,s);const i=this.isVideoContiguous;let n,a=-1;if(E&&(a=function(t){for(let e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples),!i&&this.config.forceKeyFrameOnDiscontinuity))if(f=!0,a>0){Oi.warn(`[mp4-remuxer]: Dropped ${a} out of ${y} video samples due to a missing keyframe`);const t=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(a),e.dropped+=a,p+=(e.samples[0].pts-t)/e.inputTimeScale,n=p}else-1===a&&(Oi.warn(`[mp4-remuxer]: No keyframe found out of ${y} video samples`),f=!1);if(this.ISGenerated){if(A&&E){const i=this.getVideoStartPts(e.samples),n=(Lo(t.samples[0].pts,i)-i)/e.inputTimeScale;g+=Math.max(0,n),p+=Math.max(0,-n)}if(A){if(t.samplerate||(Oi.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(t,e,r,s)),c=this.remuxAudio(t,g,this.isAudioContiguous,s,v||E||o===Nr?p:void 0),E){const n=c?c.endPTS-c.startPTS:0;e.inputTimeScale||(Oi.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(t,e,r,s)),l=this.remuxVideo(e,p,i,n)}}else E&&(l=this.remuxVideo(e,p,i,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=n)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(d=Ro(i,r,this._initPTS,this._initDTS)),n.samples.length&&(u=Co(n,r,this._initPTS))),{audio:c,video:l,initSegment:h,independent:f,text:u,id3:d}}generateIS(t,e,i,n){const r=t.samples,s=e.samples,a=this.typeSupported,o={},l=this._initPTS;let c,h,u,d=!l||n,f="audio/mp4";if(d&&(c=h=1/0),t.config&&r.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):yo.initSegment([t]),metadata:{channelCount:t.channelCount}},d&&(u=t.inputTimeScale,l&&u===l.timescale?d=!1:c=h=r[0].pts-Math.round(u*i))}if(e.sps&&e.pps&&s.length){if(e.timescale=e.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:yo.initSegment([e]),metadata:{width:e.width,height:e.height}},d)if(u=e.inputTimeScale,l&&u===l.timescale)d=!1;else{const t=this.getVideoStartPts(s),e=Math.round(u*i);h=Math.min(h,Lo(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:u},this._initDTS={baseTime:h,timescale:u}):c=u=void 0,{tracks:o,initPTS:c,timescale:u}}remuxVideo(t,e,i,n){const r=t.inputTimeScale,s=t.samples,a=[],o=s.length,l=this._initPTS;let c,h,u=this.nextAvcDts,d=8,f=this.videoSampleDuration,g=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,m=!1;if(!i||null===u){const t=e*r,n=s[0].pts-Lo(s[0].dts,s[0].pts);ko&&null!==u&&Math.abs(t-n-u)<15e3?i=!0:u=t-n}const v=l.baseTime*r/l.timescale;for(let t=0;t<o;t++){const e=s[t];e.pts=Lo(e.pts-v,u),e.dts=Lo(e.dts-v,u),e.dts<s[t>0?t-1:t].dts&&(m=!0)}m&&s.sort((function(t,e){const i=t.dts-e.dts,n=t.pts-e.pts;return i||n})),c=s[0].dts,h=s[s.length-1].dts;const y=h-c,A=y?Math.round(y/(o-1)):f||t.inputTimeScale/30;if(i){const t=c-u,i=t>A,n=t<-1;if((i||n)&&(i?Oi.warn(`AVC: ${To(t,!0)} ms (${t}dts) hole between fragments detected at ${e.toFixed(3)}`):Oi.warn(`AVC: ${To(-t,!0)} ms (${t}dts) overlapping between fragments detected at ${e.toFixed(3)}`),!n||u>=s[0].pts||ko)){c=u;const e=s[0].pts-t;if(i)s[0].dts=c,s[0].pts=e;else for(let i=0;i<s.length&&!(s[i].dts>e);i++)s[i].dts-=t,s[i].pts-=t;Oi.log(`Video: Initial PTS/DTS adjusted: ${To(e,!0)}/${To(c,!0)}, delta: ${To(t,!0)} ms`)}}c=Math.max(0,c);let E=0,T=0,b=c;for(let t=0;t<o;t++){const e=s[t],i=e.units,n=i.length;let r=0;for(let t=0;t<n;t++)r+=i[t].data.length;T+=r,E+=n,e.length=r,e.dts<b?(e.dts=b,b+=A/4|0||1):b=e.dts,g=Math.min(e.pts,g),p=Math.max(e.pts,p)}h=s[o-1].dts;const k=T+4*E+8;let S;try{S=new Uint8Array(k)}catch(t){return void this.observer.emit(Li.ERROR,Li.ERROR,{type:Ri.MUX_ERROR,details:Ci.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:k,reason:`fail allocating video mdat ${k}`})}const _=new DataView(S.buffer);_.setUint32(0,k),S.set(yo.types.mdat,4);let L=!1,R=Number.POSITIVE_INFINITY,C=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,I=Number.NEGATIVE_INFINITY;for(let t=0;t<o;t++){const e=s[t],i=e.units;let l,c=0;for(let t=0,e=i.length;t<e;t++){const e=i[t],n=e.data,r=e.data.byteLength;_.setUint32(d,r),d+=4,S.set(n,d),d+=r,c+=4+r}if(t<o-1)f=s[t+1].dts-e.dts,l=s[t+1].pts-e.pts;else{const i=this.config,a=t>0?e.dts-s[t-1].dts:A;if(l=t>0?e.pts-s[t-1].pts:A,i.stretchShortVideoTrack&&null!==this.nextAudioPts){const t=Math.floor(i.maxBufferHole*r),s=(n?g+n*r:this.nextAudioPts)-e.pts;s>t?(f=s-a,f<0?f=a:L=!0,Oi.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 h=Math.round(e.pts-e.dts);R=Math.min(R,f),w=Math.max(w,f),C=Math.min(C,l),I=Math.max(I,l),a.push(new wo(e.key,f,c,h))}if(a.length)if(ko){if(ko<70){const t=a[0].flags;t.dependsOn=2,t.isNonSync=0}}else if(So&&I-C<w-R&&A/w<.025&&0===a[0].cts){Oi.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let t=c;for(let e=0,i=a.length;e<i;e++){const n=t+a[e].duration,r=t+a[e].cts;if(e<i-1){const t=n+a[e+1].cts;a[e].duration=t-r}else a[e].duration=e?a[e-1].duration:A;a[e].cts=0,t=n}}f=L||!f?A:f,this.nextAvcDts=u=h+f,this.videoSampleDuration=f,this.isVideoContiguous=!0;const D={data1:yo.moof(t.sequenceNumber++,c,bi({},t,{samples:a})),data2:S,startPTS:g/r,endPTS:(p+f)/r,startDTS:c/r,endDTS:u/r,type:"video",hasAudio:!1,hasVideo:!0,nb:a.length,dropped:t.dropped};return t.samples=[],t.dropped=0,D}getSamplesPerFrame(t){switch(t.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(t,e,i,n,r){const s=t.inputTimeScale,a=s/(t.samplerate?t.samplerate:s),o=this.getSamplesPerFrame(t),l=o*a,c=this._initPTS,h="mp3"===t.segmentCodec&&this.typeSupported.mpeg,u=[],d=void 0!==r;let f=t.samples,g=h?0:8,p=this.nextAudioPts||-1;const m=e*s,v=c.baseTime*s/c.timescale;if(this.isAudioContiguous=i=i||f.length&&p>0&&(n&&Math.abs(m-p)<9e3||Math.abs(Lo(f[0].pts-v,m)-p)<20*l),f.forEach((function(t){t.pts=Lo(t.pts-v,m)})),!i||p<0){if(f=f.filter((t=>t.pts>=0)),!f.length)return;p=0===r?0:n&&!d?Math.max(0,m):f[0].pts}if("aac"===t.segmentCodec){const e=this.config.maxAudioFramesDrift;for(let i=0,n=p;i<f.length;i++){const r=f[i],a=r.pts,o=a-n,c=Math.abs(1e3*o/s);if(o<=-e*l&&d)0===i&&(Oi.warn(`Audio frame @ ${(a/s).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*o/s)} ms.`),this.nextAudioPts=p=n=a);else if(o>=e*l&&c<1e4&&d){let e=Math.round(o/l);n=a-e*l,n<0&&(e--,n+=l),0===i&&(this.nextAudioPts=p=n),Oi.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;s<e;s++){const e=Math.max(n,0);let s=mo.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);s||(Oi.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),s=r.unit.subarray()),f.splice(i,0,{unit:s,pts:e}),n+=l,i++}}r.pts=n,n+=l}}let y,A=null,E=null,T=0,b=f.length;for(;b--;)T+=f[b].unit.byteLength;for(let e=0,n=f.length;e<n;e++){const n=f[e],r=n.unit;let s=n.pts;if(null!==E){u[e-1].duration=Math.round((s-E)/a)}else{if(i&&"aac"===t.segmentCodec&&(s=p),A=s,!(T>0))return;T+=g;try{y=new Uint8Array(T)}catch(t){return void this.observer.emit(Li.ERROR,Li.ERROR,{type:Ri.MUX_ERROR,details:Ci.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:T,reason:`fail allocating audio mdat ${T}`})}if(!h){new DataView(y.buffer).setUint32(0,T),y.set(yo.types.mdat,4)}}y.set(r,g);const l=r.byteLength;g+=l,u.push(new wo(!0,o,l,0)),E=s}const k=u.length;if(!k)return;const S=u[u.length-1];this.nextAudioPts=p=E+a*S.duration;const _=h?new Uint8Array(0):yo.moof(t.sequenceNumber++,A/a,bi({},t,{samples:u}));t.samples=[];const L=A/s,R=p/s,C={data1:_,data2:y,startPTS:L,endPTS:R,startDTS:L,endDTS:R,type:"audio",hasAudio:!0,hasVideo:!1,nb:k};return this.isAudioContiguous=!0,C}remuxEmptyAudio(t,e,i,n){const r=t.inputTimeScale,s=r/(t.samplerate?t.samplerate:r),a=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,c=(null!==a?a:n.startDTS*r)+l,h=n.endDTS*r+l,u=1024*s,d=Math.ceil((h-c)/u),f=mo.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(Oi.warn("[mp4-remuxer]: remux empty Audio"),!f)return void Oi.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const g=[];for(let t=0;t<d;t++){const e=c+t*u;g.push({unit:f,pts:e,dts:e})}return t.samples=g,this.remuxAudio(t,e,i,!1)}}function Lo(t,e){let i;if(null===e)return t;for(i=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=i;return t}function Ro(t,e,i,n){const r=t.samples.length;if(!r)return;const s=t.inputTimeScale;for(let a=0;a<r;a++){const r=t.samples[a];r.pts=Lo(r.pts-i.baseTime*s/i.timescale,e*s)/s,r.dts=Lo(r.dts-n.baseTime*s/n.timescale,e*s)/s}const a=t.samples;return t.samples=[],{samples:a}}function Co(t,e,i){const n=t.samples.length;if(!n)return;const r=t.inputTimeScale;for(let s=0;s<n;s++){const n=t.samples[s];n.pts=Lo(n.pts-i.baseTime*r/i.timescale,e*r)/r}t.samples.sort(((t,e)=>t.pts-e.pts));const s=t.samples;return t.samples=[],{samples:s}}class wo{constructor(t,e,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=n,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:t?2:1,isNonSync:t?0:1}}}function Io(t,e){const i=null==t?void 0:t.codec;if(i&&i.length>4)return i;if(e===$i){if("ec-3"===i||"ac-3"===i||"alac"===i)return i;if("fLaC"===i||"Opus"===i){return pr(i,!1)}const t="mp4a.40.5";return Oi.info(`Parsed audio codec "${i}" or audio object type not handled. Using "${t}"`),t}return Oi.warn(`Unhandled video codec "${i}"`),"hvc1"===i||"hev1"===i?"hvc1.1.6.L120.90":"av01"===i?"av01.0.04M.08":"avc1.42e01e"}try{bo=self.performance.now.bind(self.performance)}catch(t){Oi.debug("Unable to use Performance API on this environment"),bo=null==Xi?void 0:Xi.Date.now}const Do=[{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,i,n){const r=this.videoTrack=Pa("video",1),s=this.audioTrack=Pa("audio",1),a=this.txtTrack=Pa("text",1);if(this.id3Track=Pa("id3",1),this.timeOffset=0,null==t||!t.byteLength)return;const o=Un(t);if(o.video){const{id:t,timescale:e,codec:i}=o.video;r.id=t,r.timescale=a.timescale=e,r.codec=i}if(o.audio){const{id:t,timescale:e,codec:i}=o.audio;s.id=t,s.timescale=e,s.codec=i}a.id=In.text,r.sampleDuration=0,r.duration=s.duration=n}resetContiguity(){this.remainderData=null}static probe(t){return function(t){const e=t.byteLength;for(let i=0;i<e;){const n=On(t,i);if(n>8&&109===t[i+4]&&111===t[i+5]&&111===t[i+6]&&102===t[i+7])return!0;i=n>1?i+n:e}return!1}(t)}demux(t,e){this.timeOffset=e;let i=t;const n=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=jn(this.remainderData,t));const e=function(t){const e={valid:null,remainder:null},i=Fn(t,["moof"]);if(i.length<2)return e.remainder=t,e;const n=i[i.length-1];return e.valid=cn(t,0,n.byteOffset-8),e.remainder=cn(t,n.byteOffset-8),e}(i);this.remainderData=e.remainder,n.samples=e.valid||new Uint8Array}else n.samples=i;const s=this.extractID3Track(n,e);return r.samples=Wn(e,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(e,this.timeOffset);return i.samples=Wn(t,e),{videoTrack:e,audioTrack:Pa(),id3Track:n,textTrack:Pa()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const n=Fn(t.samples,["emsg"]);n&&n.forEach((t=>{const n=function(t){const e=t[0];let i="",n="",r=0,s=0,a=0,o=0,l=0,c=0;if(0===e){for(;"\0"!==Dn(t.subarray(c,c+1));)i+=Dn(t.subarray(c,c+1)),c+=1;for(i+=Dn(t.subarray(c,c+1)),c+=1;"\0"!==Dn(t.subarray(c,c+1));)n+=Dn(t.subarray(c,c+1)),c+=1;n+=Dn(t.subarray(c,c+1)),c+=1,r=On(t,12),s=On(t,16),o=On(t,20),l=On(t,24),c=28}else if(1===e){c+=4,r=On(t,c),c+=4;const e=On(t,c);c+=4;const s=On(t,c);for(c+=4,a=2**32*e+s,Si(a)||(a=Number.MAX_SAFE_INTEGER,Oi.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=On(t,c),c+=4,l=On(t,c),c+=4;"\0"!==Dn(t.subarray(c,c+1));)i+=Dn(t.subarray(c,c+1)),c+=1;for(i+=Dn(t.subarray(c,c+1)),c+=1;"\0"!==Dn(t.subarray(c,c+1));)n+=Dn(t.subarray(c,c+1)),c+=1;n+=Dn(t.subarray(c,c+1)),c+=1}return{schemeIdUri:i,value:n,timeScale:r,presentationTime:a,presentationTimeDelta:s,eventDuration:o,id:l,payload:t.subarray(c,t.byteLength)}}(t);if(Ja.test(n.schemeIdUri)){const t=ki(n.presentationTime)?n.presentationTime/n.timeScale:e+n.presentationTimeDelta/n.timeScale;let r=4294967295===n.eventDuration?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);const s=n.payload;i.samples.push({data:s,len:s.byteLength,dts:t,pts:t,type:Wr,duration:r})}}))}return i}demuxSampleAes(t,e,i){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,i,n){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(function(t,e){if(!t||!e)return t;const i=e.keyId;i&&e.isCommonEncryption&&Fn(t,["moov","trak"]).forEach((t=>{const e=Fn(t,["mdia","minf","stbl","stsd"])[0].subarray(8);let n=Fn(e,["enca"]);const r=n.length>0;r||(n=Fn(e,["encv"])),n.forEach((t=>{Fn(r?t.subarray(28):t.subarray(78),["sinf"]).forEach((t=>{const e=Hn(t);if(e){const t=e.subarray(8,24);t.some((t=>0!==t))||(Oi.log(`[eme] Patching keyId in 'enc${r?"a":"v"}>sinf>>tenc' box: ${Rn(t)} -> ${Rn(i)}`),e.set(i,8))}}))}))}));return t}(t,n)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:i}=this;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const n=this.initData=Un(t);n.audio&&(e=Io(n.audio,$i)),n.video&&(i=Io(n.video,Gi));const r={};n.audio&&n.video?r.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:n.audio?r.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:n.video?r.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:Oi.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r}remux(t,e,i,n,r,s){var a,o;let{initPTS:l,lastEndTime:c}=this;const h={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};ki(c)||(c=this.lastEndTime=r||0);const u=e.samples;if(null==u||!u.length)return h;const d={initPTS:void 0,timescale:1};let f=this.initData;if(null!=(a=f)&&a.length||(this.generateInitSegment(u),f=this.initData),null==(o=f)||!o.length)return Oi.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);const g=function(t,e){let i=0,n=0,r=0;const s=Fn(t,["moof","traf"]);for(let t=0;t<s.length;t++){const a=s[t],o=Fn(a,["tfhd"])[0],l=e[On(o,4)];if(!l)continue;const c=l.default,h=On(o,0)|(null==c?void 0:c.flags);let u=null==c?void 0:c.duration;8&h&&(u=On(o,2&h?12:8));const d=l.timescale||9e4,f=Fn(a,["trun"]);for(let t=0;t<f.length;t++)i=Yn(f[t]),!i&&u&&(i=u*On(f[t],4)),l.type===Gi?n+=i/d:l.type===$i&&(r+=i/d)}if(0===n&&0===r){let e=1/0,i=0,n=0;const r=Fn(t,["sidx"]);for(let t=0;t<r.length;t++){const s=Bn(r[t]);if(null!=s&&s.references){e=Math.min(e,s.earliestPresentationTime/s.timescale);const t=s.references.reduce(((t,e)=>t+e.info.duration||0),0);i=Math.max(i,t+s.earliestPresentationTime/s.timescale),n=i-e}}if(n&&ki(n))return n}return n||r}(u,f),p=function(t,e){return Fn(e,["moof","traf"]).reduce(((e,i)=>{const n=Fn(i,["tfdt"])[0],r=n[0],s=Fn(i,["tfhd"]).reduce(((e,i)=>{const s=On(i,4),a=t[s];if(a){let t=On(n,4);if(1===r){if(t===Cn)return Oi.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),e;t*=Cn+1,t+=On(n,8)}const i=t/(a.timescale||9e4);if(ki(i)&&(null===e||i<e))return i}return e}),null);return null!==s&&ki(s)&&(null===e||s<e)?s:e}),null)}(f,u),m=null===p?r:p;(function(t,e,i,n){if(null===t)return!0;const r=Math.max(n,1),s=e-t.baseTime/t.timescale;return Math.abs(s-i)>r}(l,m,r,g)||d.timescale!==l.timescale&&s)&&(d.initPTS=m-r,l&&1===l.timescale&&Oi.warn("Adjusting initPTS by "+(d.initPTS-l.baseTime)),this.initPTS=l={baseTime:d.initPTS,timescale:1});const v=t?m-l.baseTime/l.timescale:c,y=v+g;!function(t,e,i){Fn(e,["moof","traf"]).forEach((e=>{Fn(e,["tfhd"]).forEach((n=>{const r=On(n,4),s=t[r];if(!s)return;const a=s.timescale||9e4;Fn(e,["tfdt"]).forEach((t=>{const e=t[0],n=i*a;if(n){let i=On(t,4);if(0===e)i-=n,i=Math.max(i,0),Mn(t,4,i);else{i*=Math.pow(2,32),i+=On(t,8),i-=n,i=Math.max(i,0);const e=Math.floor(i/(Cn+1)),r=Math.floor(i%(Cn+1));Mn(t,4,e),Mn(t,8,r)}}}))}))}))}(f,u,l.baseTime/l.timescale),g>0?this.lastEndTime=y:(Oi.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const A=!!f.audio,E=!!f.video;let T="";A&&(T+="audio"),E&&(T+="video");const b={data1:u,startPTS:v,startDTS:v,endPTS:y,endDTS:y,type:T,hasAudio:A,hasVideo:E,nb:1,dropped:0};return h.audio="audio"===b.type?b:void 0,h.video="audio"!==b.type?b:void 0,h.initSegment=d,h.id3=Ro(i,r,l,l),n.samples.length&&(h.text=Co(n,r,l)),h}}},{demux:lo,remux:_o},{demux:class extends Oa{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,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=dn(t,0);let i=(null==e?void 0:e.length)||0;if(Za(t,i))return!1;for(let e=t.length;i<e;i++)if(Ua(t,i))return Oi.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return function(t,e){return function(t,e){return e+5<t.length}(t,e)&&Na(t,e)&&Fa(t,e)<=t.length-e}(t,e)}appendFrame(t,e,i){$a(t,this.observer,e,i,t.manifestCodec);const n=Va(t,e,i,this.basePTS,this.frameIndex);if(n&&0===n.missing)return n}},remux:_o},{demux:class extends Oa{resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;const e=dn(t,0);let i=(null==e?void 0:e.length)||0;if(e&&11===t[i]&&119===t[i+1]&&void 0!==pn(e)&&to(t,i)<=16)return!1;for(let e=t.length;i<e;i++)if(Za(t,i))return Oi.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return function(t,e){return Xa(t,e)&&4<=t.length-e}(t,e)}appendFrame(t,e,i){if(null!==this.basePTS)return za(t,e,i,this.basePTS,this.frameIndex)}},remux:_o}];Do.splice(2,0,{demux:eo,remux:_o});class Po{constructor(t,e,i,n,r){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=i,this.vendor=n,this.id=r}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,n){const r=i.transmuxing;r.executeStart=bo();let s=new Uint8Array(t);const{currentTransmuxState:a,transmuxConfig:o}=this;n&&(this.currentTransmuxState=n);const{contiguous:l,discontinuity:c,trackSwitch:h,accurateTimeOffset:u,timeOffset:d,initSegmentChange:f}=n||a,{audioCodec:g,videoCodec:p,defaultInitPts:m,duration:v,initSegmentData:y}=o,A=function(t,e){let i=null;t.byteLength>0&&null!=(null==e?void 0:e.key)&&null!==e.iv&&null!=e.method&&(i=e);return i}(s,e);if(A&&"AES-128"===A.method){const t=this.getDecrypter();if(!t.isSync())return this.decryptionPromise=t.webCryptoDecrypt(s,A.key.buffer,A.iv.buffer).then((t=>{const e=this.push(t,null,i);return this.decryptionPromise=null,e})),this.decryptionPromise;{let e=t.softwareDecrypt(s,A.key.buffer,A.iv.buffer);if(i.part>-1&&(e=t.flush()),!e)return r.executeEnd=bo(),Oo(i);s=new Uint8Array(e)}}const E=this.needsProbing(c,h);if(E){const t=this.configureTransmuxer(s);if(t)return Oi.warn(`[transmuxer] ${t.message}`),this.observer.emit(Li.ERROR,Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),r.executeEnd=bo(),Oo(i)}(c||h||f||E)&&this.resetInitSegment(y,g,p,v,e),(c||f||E)&&this.resetInitialTimestamp(m),l||this.resetContiguity();const T=this.transmux(s,A,d,u,i),b=this.currentTransmuxState;return b.contiguous=!0,b.discontinuity=!1,b.trackSwitch=!1,r.executeEnd=bo(),T}flush(t){const e=t.transmuxing;e.executeStart=bo();const{decrypter:i,currentTransmuxState:n,decryptionPromise:r}=this;if(r)return r.then((()=>this.flush(t)));const s=[],{timeOffset:a}=n;if(i){const e=i.flush();e&&s.push(this.push(e,null,t))}const{demuxer:o,remuxer:l}=this;if(!o||!l)return e.executeEnd=bo(),[Oo(t)];const c=o.flush(a);return xo(c)?c.then((e=>(this.flushRemux(s,e,t),s))):(this.flushRemux(s,c,t),s)}flushRemux(t,e,i){const{audioTrack:n,videoTrack:r,id3Track:s,textTrack:a}=e,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;Oi.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const c=this.remuxer.remux(n,r,s,a,l,o,!0,this.id);t.push({remuxResult:c,chunkMeta:i}),i.transmuxing.executeEnd=bo()}resetInitialTimestamp(t){const{demuxer:e,remuxer:i}=this;e&&i&&(e.resetTimeStamp(t),i.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,i,n,r){const{demuxer:s,remuxer:a}=this;s&&a&&(s.resetInitSegment(t,e,i,n),a.resetInitSegment(t,e,i,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,i,n,r){let s;return s=e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,i,n,r):this.transmuxUnencrypted(t,i,n,r),s}transmuxUnencrypted(t,e,i,n){const{audioTrack:r,videoTrack:s,id3Track:a,textTrack:o}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,s,a,o,e,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(t,e,i,n,r){return this.demuxer.demuxSampleAes(t,e,i).then((t=>({remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,i,n,!1,this.id),chunkMeta:r})))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:n,vendor:r}=this;let s;for(let e=0,i=Do.length;e<i;e++){var a;if(null!=(a=Do[e].demux)&&a.probe(t)){s=Do[e];break}}if(!s)return new Error("Failed to find demuxer by probing fragment data");const o=this.demuxer,l=this.remuxer,c=s.remux,h=s.demux;l&&l instanceof c||(this.remuxer=new c(i,e,n,r)),o&&o instanceof h||(this.demuxer=new h(i,e,n),this.probe=h.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new ma(this.config)),t}}const Oo=t=>({remuxResult:{},chunkMeta:t});function xo(t){return"then"in t&&t.then instanceof Function}class No{constructor(t,e,i,n,r){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=i,this.duration=n,this.defaultInitPts=r||null}}class Mo{constructor(t,e,i,n,r,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=i,this.trackSwitch=n,this.timeOffset=r,this.initSegmentChange=s}}var Fo={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function n(){}function r(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function s(t,e,n,s,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new r(n,s||t,a),l=i?i+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__||(i=!1)),o.prototype.eventNames=function(){var t,n,r=[];if(0===this._eventsCount)return r;for(n in t=this._events)e.call(t,n)&&r.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},o.prototype.listeners=function(t){var e=i?i+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,s=n.length,a=new Array(s);r<s;r++)a[r]=n[r].fn;return a},o.prototype.listenerCount=function(t){var e=i?i+t:t,n=this._events[e];return n?n.fn?1:n.length:0},o.prototype.emit=function(t,e,n,r,s,a){var o=i?i+t:t;if(!this._events[o])return!1;var l,c,h=this._events[o],u=arguments.length;if(h.fn){switch(h.once&&this.removeListener(t,h.fn,void 0,!0),u){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,e),!0;case 3:return h.fn.call(h.context,e,n),!0;case 4:return h.fn.call(h.context,e,n,r),!0;case 5:return h.fn.call(h.context,e,n,r,s),!0;case 6:return h.fn.call(h.context,e,n,r,s,a),!0}for(c=1,l=new Array(u-1);c<u;c++)l[c-1]=arguments[c];h.fn.apply(h.context,l)}else{var d,f=h.length;for(c=0;c<f;c++)switch(h[c].once&&this.removeListener(t,h[c].fn,void 0,!0),u){case 1:h[c].fn.call(h[c].context);break;case 2:h[c].fn.call(h[c].context,e);break;case 3:h[c].fn.call(h[c].context,e,n);break;case 4:h[c].fn.call(h[c].context,e,n,r);break;default:if(!l)for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];h[c].fn.apply(h[c].context,l)}}return!0},o.prototype.on=function(t,e,i){return s(this,t,e,i,!1)},o.prototype.once=function(t,e,i){return s(this,t,e,i,!0)},o.prototype.removeListener=function(t,e,n,r){var s=i?i+t:t;if(!this._events[s])return this;if(!e)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==e||r&&!o.once||n&&o.context!==n||a(this,s);else{for(var l=0,c=[],h=o.length;l<h;l++)(o[l].fn!==e||r&&!o[l].once||n&&o[l].context!==n)&&c.push(o[l]);c.length?this._events[s]=1===c.length?c[0]:c:a(this,s)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&a(this,e)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,t.exports=o}(Fo);var Bo=hi(Fo.exports);class Uo{constructor(t,e,i,n){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const r=t.config;this.hls=t,this.id=e,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;const s=(t,e)=>{(e=e||{}).frag=this.frag,e.id=this.id,t===Li.ERROR&&(this.error=e.error),this.hls.trigger(t,e)};this.observer=new Bo,this.observer.on(Li.FRAG_DECRYPTED,s),this.observer.on(Li.ERROR,s);const a=ar(r.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(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(Oi.log(`loading Web Worker ${r.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}}(r.workerPath)):(Oi.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 i=new Error(`${t.message} (${t.filename}:${t.lineno})`);r.enableWorker=!1,Oi.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(Li.ERROR,{type:Ri.OTHER_ERROR,details:Ci.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:i})},t.postMessage({cmd:"init",typeSupported:o,vendor:"",id:e,config:JSON.stringify(r)})}catch(t){Oi.warn(`Error setting up "${e}" Web Worker, fallback to inline`,t),this.resetWorker(),this.error=null,this.transmuxer=new Po(this.observer,o,r,"",e)}return}}this.transmuxer=new Po(this.observer,o,r,"",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,i,n,r,s,a,o,l,c){var h,u;l.transmuxing.start=self.performance.now();const{transmuxer:d}=this,f=s?s.start:r.start,g=r.decryptdata,p=this.frag,m=!(p&&r.cc===p.cc),v=!(p&&l.level===p.level),y=p?l.sn-p.sn:-1,A=this.part?l.part-this.part.index:-1,E=0===y&&l.id>1&&l.id===(null==p?void 0:p.stats.chunkCount),T=!v&&(1===y||0===y&&(1===A||E&&A<=0)),b=self.performance.now();(v||y||0===r.stats.parsing.start)&&(r.stats.parsing.start=b),!s||!A&&T||(s.stats.parsing.start=b);const k=!(p&&(null==(h=r.initSegment)?void 0:h.url)===(null==(u=p.initSegment)?void 0:u.url)),S=new Mo(m,T,o,v,f,k);if(!T||m||k){Oi.log(`[transmuxer-interface, ${r.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${m}\n trackSwitch: ${v}\n contiguous: ${T}\n accurateTimeOffset: ${o}\n timeOffset: ${f}\n initSegmentChange: ${k}`);const t=new No(i,n,e,a,c);this.configureTransmuxer(t)}if(this.frag=r,this.part=s,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:g,chunkMeta:l,state:S},t instanceof ArrayBuffer?[t]:[]);else if(d){const e=d.push(t,g,l,S);xo(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 i=e.flush(t);xo(i)||e.async?(xo(i)||(i=Promise.resolve(i)),i.then((e=>{this.handleFlushResult(e,t)})).catch((e=>{this.transmuxerError(e,t,"transmuxer-interface flush error")}))):this.handleFlushResult(i,t)}}transmuxerError(t,e,i){this.hls&&(this.error=t,this.hls.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_PARSING_ERROR,chunkMeta:e,frag:this.frag||void 0,fatal:!1,error:t,err:t,reason:i}))}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 Oi.warn("worker message received with no "+(e?"event name":"data"));const i=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":Oi[e.data.logType]&&Oi[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,i.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 $o(t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Go(t[i].attrs,e[i].attrs))return!1;return!0}function Go(t,e,i){const n=t["STABLE-RENDITION-ID"];return n&&!i?n===e["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some((i=>t[i]!==e[i]))}function Vo(t,e){return e.label.toLowerCase()===t.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(t.lang||"").toLowerCase())}class Ko{constructor(t){this.buffered=void 0;const e=(e,i,n)=>{if((i>>>=0)>n-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${n})`);return t[i][e]};this.buffered={get length(){return t.length},end:i=>e("end",i,t.length),start:i=>e("start",i,t.length)}}}class Ho{constructor(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}append(t,e,i){const n=this.queues[e];n.push(t),1!==n.length||i||this.executeNext(e)}insertAbort(t,e){this.queues[e].unshift(t),this.executeNext(e)}appendBlocker(t){let e;const i=new Promise((t=>{e=t})),n={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,t),i}executeNext(t){const e=this.queues[t];if(e.length){const i=e[0];try{i.execute()}catch(e){Oi.warn(`[buffer-operation-queue]: Exception executing "${t}" SourceBuffer operation: ${e}`),i.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 Yo=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;function jo(t){const e=t.querySelectorAll("source");[].slice.call(e).forEach((e=>{t.removeChild(e)}))}const Wo={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},zo=t=>String.fromCharCode(Wo[t]||t),qo=15,Xo=100,Qo={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Zo={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Jo={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},tl={25:2,26:4,29:6,30:8,31:10,27:13,28:15},el=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class il{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i="function"==typeof e?e():e;Oi.log(`${this.time} [${t}] ${i}`)}}}const nl=function(t){const e=[];for(let i=0;i<t.length;i++)e.push(t[i].toString(16));return e};class rl{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const e=["foreground","underline","italics","background","flash"];for(let i=0;i<e.length;i++){const n=e[i];t.hasOwnProperty(n)&&(this[n]=t[n])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class sl{constructor(){this.uchar=" ",this.penState=new rl}reset(){this.uchar=" ",this.penState.reset()}setChar(t,e){this.uchar=t,this.penState.copy(e)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class al{constructor(t){this.chars=[],this.pos=0,this.currPenState=new rl,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Xo;t++)this.chars.push(new sl);this.logger=t}equals(t){for(let e=0;e<Xo;e++)if(!this.chars[e].equals(t.chars[e]))return!1;return!0}copy(t){for(let e=0;e<Xo;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<Xo;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Xo&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Xo)}moveCursor(t){const e=this.pos+t;if(t>1)for(let t=this.pos+1;t<e+1;t++)this.chars[t].setPenState(this.currPenState);this.setCursor(e)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const e=zo(t);this.pos>=Xo?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<Xo;e++)this.chars[e].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let e=!0;for(let i=0;i<Xo;i++){const n=this.chars[i].uchar;" "!==n&&(e=!1),t.push(n)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t);this.chars[this.pos].setPenState(this.currPenState)}}class ol{constructor(t){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let e=0;e<qo;e++)this.rows.push(new al(t));this.logger=t}reset(){for(let t=0;t<qo;t++)this.rows[t].clear();this.currRow=14}equals(t){let e=!0;for(let i=0;i<qo;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<qo;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<qo;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t);this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,(()=>"pacData = "+JSON.stringify(t)));let e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(let t=0;t<qo;t++)this.rows[t].clear();const t=this.currRow+1-this.nrRollUpRows,i=this.lastOutputScreen;if(i){const n=i.rows[t].cueStartTime,r=this.logger.time;if(null!==n&&null!==r&&n<r)for(let n=0;n<this.nrRollUpRows;n++)this.rows[e-this.nrRollUpRows+n+1].copy(i.rows[t+n])}}this.currRow=e;const i=this.rows[this.currRow];if(null!==t.indent){const e=t.indent,n=Math.max(e-1,0);i.setCursor(t.indent),t.color=i.chars[n].penState.foreground}const n={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(n)}setBkgData(t){this.logger.log(2,(()=>"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 i="",n=-1;for(let i=0;i<qo;i++){const r=this.rows[i].getTextString();r&&(n=i+1,t?e.push("Row "+n+": '"+r+"'"):e.push(r.trim()))}return e.length>0&&(i=t?"["+e.join(" | ")+"]":e.join("\n")),i}getTextAndFormat(){return this.rows}}class ll{constructor(t,e,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new ol(i),this.nonDisplayedMemory=new ol(i),this.lastOutputScreen=new ol(i),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}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;e<t.length;e++)this.writeScreen.insertChar(t[e]);const e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(()=>e+": "+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 i=Math.floor(t/2)-16,n=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=n[i]}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 cl{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const n=this.logger=new il;this.channels=[null,new ll(t,e,n),new ll(t+1,i,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<e.length;t+=2){const i=127&e[t],n=127&e[t+1];let r=!1,s=null;if(0===i&&0===n)continue;this.logger.log(3,(()=>"["+nl([e[t],e[t+1]])+"] -> ("+nl([i,n])+")"));const a=this.cmdHistory;if(i>=16&&i<=31){if(ul(i,n,a)){hl(null,null,a),this.logger.log(3,(()=>"Repeated command ("+nl([i,n])+") is dropped"));continue}hl(i,n,this.cmdHistory),r=this.parseCmd(i,n),r||(r=this.parseMidrow(i,n)),r||(r=this.parsePAC(i,n)),r||(r=this.parseBackgroundAttributes(i,n))}else hl(null,null,a);if(!r&&(s=this.parseChars(i,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?")}r||s||this.logger.log(2,(()=>"Couldn't parse cleaned data "+nl([i,n])+" orig: "+nl([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 i=20===t||21===t||23===t?1:2,n=this.channels[i];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=i,!0}parseMidrow(t,e){let i=0;if((17===t||25===t)&&e>=32&&e<=47){if(i=17===t?1:2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const n=this.channels[i];return!!n&&(n.ccMIDROW(e),this.logger.log(3,(()=>"MIDROW ("+nl([t,e])+")")),!0)}return!1}parsePAC(t,e){let i;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;i=e>=64&&e<=95?1===n?Qo[t]:Jo[t]:1===n?Zo[t]:tl[t];const r=this.channels[n];return!!r&&(r.setPAC(this.interpretPAC(i,e)),this.currentChannel=n,!0)}interpretPAC(t,e){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:t};return i=e>95?e-96:e-64,n.underline=1==(1&i),i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n}parseChars(t,e){let i,n=null,r=null;if(t>=25?(i=2,r=t-8):(i=1,r=t),r>=17&&r<=19){let t;t=17===r?e+80:18===r?e+112:e+144,this.logger.log(2,(()=>"Special char '"+zo(t)+"' in channel "+i)),n=[t]}else t>=32&&t<=127&&(n=0===e?[t]:[t,e]);return n&&this.logger.log(3,(()=>"Char codes = "+nl(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 i;const n={};16===t||24===t?(i=Math.floor((e-32)/2),n.background=el[i],e%2==1&&(n.background=n.background+"_semi")):45===e?n.background="transparent":(n.foreground="black",47===e&&(n.underline=!0));const r=t<=23?1:2;return this.channels[r].setBkgData(n),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const e=this.channels[t];e&&e.reset()}hl(null,null,this.cmdHistory)}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function hl(t,e,i){i.a=t,i.b=e}function ul(t,e,i){return i.a===t&&i.b===e}class dl{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,i){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var fl=function(){if(null!=Xi&&Xi.VTTCue)return self.VTTCue;const t=["","lr","rl"],e=["start","middle","end","left","right"];function i(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;const i=e.toLowerCase();return!!~t.indexOf(i)&&i}function n(t){return i(e,t)}function r(t,...e){let i=1;for(;i<arguments.length;i++){const e=arguments[i];for(const i in e)t[i]=e[i]}return t}function s(e,s,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let c="",h=!1,u=e,d=s,f=a,g=null,p="",m=!0,v="auto",y="start",A=50,E="middle",T=50,b="middle";Object.defineProperty(o,"id",r({},l,{get:function(){return c},set:function(t){c=""+t}})),Object.defineProperty(o,"pauseOnExit",r({},l,{get:function(){return h},set:function(t){h=!!t}})),Object.defineProperty(o,"startTime",r({},l,{get:function(){return u},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");u=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",r({},l,{get:function(){return d},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");d=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",r({},l,{get:function(){return f},set:function(t){f=""+t,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",r({},l,{get:function(){return g},set:function(t){g=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",r({},l,{get:function(){return p},set:function(e){const n=function(e){return i(t,e)}(e);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");p=n,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",r({},l,{get:function(){return m},set:function(t){m=!!t,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",r({},l,{get:function(){return v},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");v=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",r({},l,{get:function(){return y},set:function(t){const e=n(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",r({},l,{get:function(){return A},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");A=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",r({},l,{get:function(){return E},set:function(t){const e=n(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",r({},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",r({},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}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class gl{decode(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function pl(t){function e(t,e,i,n){return 3600*(0|t)+60*(0|e)+(0|i)+parseFloat(n||0)}const i=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?e(i[2],i[3],0,i[4]):e(i[1],i[2],i[3],i[4]):null}class ml{constructor(){this.values=Object.create(null)}set(t,e){this.get(t)||""===e||(this.values[t]=e)}get(t,e,i){return i?this.has(t)?this.values[t]:e[i]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,i){for(let n=0;n<i.length;++n)if(e===i[n]){this.set(t,e);break}}integer(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))}percent(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){const i=parseFloat(e);if(i>=0&&i<=100)return this.set(t,i),!0}return!1}}function vl(t,e,i,n){const r=n?t.split(n):[t];for(const t in r){if("string"!=typeof r[t])continue;const n=r[t].split(i);if(2!==n.length)continue;e(n[0],n[1])}}const yl=new fl(0,0,""),Al="middle"===yl.align?"middle":"center";function El(t,e,i){const n=t;function r(){const e=pl(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=r(),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=r(),s(),function(t,e){const n=new ml;vl(t,(function(t,e){let r;switch(t){case"region":for(let r=i.length-1;r>=0;r--)if(i[r].id===e){n.set(t,i[r].region);break}break;case"vertical":n.alt(t,e,["rl","lr"]);break;case"line":r=e.split(","),n.integer(t,r[0]),n.percent(t,r[0])&&n.set("snapToLines",!1),n.alt(t,r[0],["auto"]),2===r.length&&n.alt("lineAlign",r[1],["start",Al,"end"]);break;case"position":r=e.split(","),n.percent(t,r[0]),2===r.length&&n.alt("positionAlign",r[1],["start",Al,"end","line-left","line-right","auto"]);break;case"size":n.percent(t,e);break;case"align":n.alt(t,e,["start",Al,"end","left","right"])}}),/:/,/\s/),e.region=n.get("region",null),e.vertical=n.get("vertical","");let r=n.get("line","auto");"auto"===r&&-1===yl.line&&(r=-1),e.line=r,e.lineAlign=n.get("lineAlign","start"),e.snapToLines=n.get("snapToLines",!0),e.size=n.get("size",100),e.align=n.get("align",Al);let s=n.get("position","auto");"auto"===s&&50===yl.position&&(s="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=s}(t,e)}function Tl(t){return t.replace(/<br(?: \/)?>/gi,"\n")}class bl{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new gl,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;function i(){let t=e.buffer,i=0;for(t=Tl(t);i<t.length&&"\r"!==t[i]&&"\n"!==t[i];)++i;const n=t.slice(0,i);return"\r"===t[i]&&++i,"\n"===t[i]&&++i,e.buffer=t.slice(i),n}t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));try{let t="";if("INITIAL"===e.state){if(!/\r\n|\n/.test(e.buffer))return this;t=i();const n=t.match(/^()?WEBVTT([ \t].*)?$/);if(null==n||!n[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let n=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(n?n=!1:t=i(),e.state){case"HEADER":/:/.test(t)?vl(t,(function(t,e){}),/:/):t||(e.state="ID");continue;case"NOTE":t||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(t)){e.state="NOTE";break}if(!t)continue;if(e.cue=new fl(0,0,""),e.state="CUE",-1===t.indexOf("--\x3e")){e.cue.id=t;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{El(t,e.cue,e.regionList)}catch(t){e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const i=-1!==t.indexOf("--\x3e");if(!t||i&&(n=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(null===e.cue)continue;e.cue.text&&(e.cue.text+="\n"),e.cue.text+=t}continue;case"BADCUE":t||(e.state="ID")}}}catch(t){"CUETEXT"===e.state&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state="INITIAL"===e.state?"BADWEBVTT":"BADCUE"}return this}flush(){const t=this;try{if((t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state||"BADWEBVTT"===t.state)throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this}}const kl=/\r\n|\n\r|\n|\r/g,Sl=function(t,e,i=0){return t.slice(i,i+e.length)===e},_l=function(t){let e=5381,i=t.length;for(;i;)e=33*e^t.charCodeAt(--i);return(e>>>0).toString()};function Ll(t,e,i){return _l(t.toString())+_l(e.toString())+_l(i)}function Rl(t,e,i,n,r,s,a){const o=new bl,l=Sn(new Uint8Array(t)).trim().replace(kl,"\n").split("\n"),c=[],h=e?function(t,e=1){return Eo(t,Ao,1/e)}(e.baseTime,e.timescale):0;let u,d="00:00.000",f=0,g=0,p=!0;o.oncue=function(t){const s=i[n];let a=i.ccOffset;const o=(f-h)/9e4;if(null!=s&&s.new&&(void 0!==g?a=i.ccOffset=s.start:function(t,e,i){let n=t[e],r=t[n.prevCC];if(!r||!r.new&&n.new)return t.ccOffset=t.presentationOffset=n.start,void(n.new=!1);for(;null!=(s=r)&&s.new;){var s;t.ccOffset+=n.start-r.start,n.new=!1,n=r,r=t[n.prevCC]}t.presentationOffset=i}(i,n,o)),o){if(!e)return void(u=new Error("Missing initPTS for VTT MPEGTS"));a=o-i.presentationOffset}const l=t.endTime-t.startTime,d=Lo(9e4*(t.startTime+a-g),9e4*r)/9e4;t.startTime=Math.max(d,0),t.endTime=Math.max(d+l,0);const p=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(p)),t.id||(t.id=Ll(t.startTime,t.endTime,p)),t.endTime>0&&c.push(t)},o.onparsingerror=function(t){u=t},o.onflush=function(){u?a(u):s(c)},l.forEach((t=>{if(p){if(Sl(t,"X-TIMESTAMP-MAP=")){p=!1,t.slice(16).split(",").forEach((t=>{Sl(t,"LOCAL:")?d=t.slice(6):Sl(t,"MPEGTS:")&&(f=parseInt(t.slice(7)))}));try{g=function(t){let e=parseInt(t.slice(-3));const i=parseInt(t.slice(-6,-4)),n=parseInt(t.slice(-9,-7)),r=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(ki(e)&&ki(i)&&ki(n)&&ki(r)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${t}`);return e+=1e3*i,e+=6e4*n,e+=36e5*r,e}(d)/1e3}catch(t){u=t}return}""===t&&(p=!1)}o.parse(t+"\n")})),o.flush()}const Cl="stpp.ttml.im1t",wl=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Il=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Dl={left:"start",center:"center",right:"end",start:"start",end:"end"};function Pl(t,e,i,n){const r=Fn(new Uint8Array(t),["mdat"]);if(0===r.length)return void n(new Error("Could not parse IMSC1 mdat"));const s=r.map((t=>Sn(t))),a=function(t,e,i=1,n=!1){return Eo(t,e,1/i,n)}(e.baseTime,1,e.timescale);try{s.forEach((t=>i(function(t,e){const i=(new DOMParser).parseFromString(t,"text/xml"),n=i.getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(r).reduce(((t,e)=>(t[e]=n.getAttribute(`ttp:${e}`)||r[e],t)),{}),a="preserve"!==n.getAttribute("xml:space"),o=xl(Ol(n,"styling","style")),l=xl(Ol(n,"layout","region")),c=Ol(n,"body","[begin]");return[].map.call(c,(t=>{const i=Nl(t,a);if(!i||!t.hasAttribute("begin"))return null;const n=Bl(t.getAttribute("begin"),s),r=Bl(t.getAttribute("dur"),s);let c=Bl(t.getAttribute("end"),s);if(null===n)throw Fl(t);if(null===c){if(null===r)throw Fl(t);c=n+r}const h=new fl(n-e,c-e,i);h.id=Ll(h.startTime,h.endTime,h.text);const u=function(t,e,i){const n="http://www.w3.org/ns/ttml#styling";let r=null;const s=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;a&&i.hasOwnProperty(a)&&(r=i[a]);return s.reduce(((i,s)=>{const a=Ml(e,n,s)||Ml(t,n,s)||Ml(r,n,s);return a&&(i[s]=a),i}),{})}(l[t.getAttribute("region")],o[t.getAttribute("style")],o),{textAlign:d}=u;if(d){const t=Dl[d];t&&(h.lineAlign=t),h.align=d}return bi(h,u),h})).filter((t=>null!==t))}(t,a))))}catch(t){n(t)}}function Ol(t,e,i){const n=t.getElementsByTagName(e)[0];return n?[].slice.call(n.querySelectorAll(i)):[]}function xl(t){return t.reduce(((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t}),{})}function Nl(t,e){return[].slice.call(t.childNodes).reduce(((t,i,n)=>{var r;return"br"===i.nodeName&&n?t+"\n":null!=(r=i.childNodes)&&r.length?Nl(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent}),"")}function Ml(t,e,i){return t&&t.hasAttributeNS(e,i)?t.getAttributeNS(e,i):null}function Fl(t){return new Error(`Could not parse ttml timestamp ${t}`)}function Bl(t,e){if(!t)return null;let i=pl(t);return null===i&&(wl.test(t)?i=function(t,e){const i=wl.exec(t),n=(0|i[4])+(0|i[5])/e.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+n/e.frameRate}(t,e):Il.test(t)&&(i=function(t,e){const i=Il.exec(t),n=Number(i[1]);switch(i[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))),i}function Ul(t){return t.characteristics&&/transcribes-spoken-dialog/gi.test(t.characteristics)&&/describes-music-and-sound/gi.test(t.characteristics)?"captions":"subtitles"}function $l(t,e){return!!t&&t.kind===Ul(e)&&Vo(e,t)}class Gl{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(Li.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(Li.BUFFER_CODECS,this.onBufferCodecs,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(Li.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(Li.BUFFER_CODECS,this.onBufferCodecs,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const i=this.hls.levels[e.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.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 i=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,i.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onLevelsUpdated(t,e){this.timer&&ki(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,i=this.getMaxLevel(t.length-1);i!==this.autoLevelCapping&&Oi.log(`Setting autoLevelCapping to ${i}: ${t[i].height}p@${t[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),e.autoLevelCapping=i,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 i=e.filter(((e,i)=>this.isLevelAllowed(e)&&i<=t));return this.clientRect=null,Gl.getMaxLevelByMediaSize(i,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 i=t.getBoundingClientRect();e.width=i.width,e.height=i.height,e.width||e.height||(e.width=i.right-i.left||t.width||0,e.height=i.bottom-i.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,i){if(null==t||!t.length)return-1;let n=t.length-1;const r=Math.max(e,i);for(let e=0;e<t.length;e+=1){const i=t[e];if((i.width>=r||i.height>=r)&&(s=i,!(a=t[e+1])||s.width!==a.width||s.height!==a.height)){n=e;break}}var s,a;return n}}const Vl="[eme]";class Kl{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=Kl.CDMCleanupPromise?[Kl.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=Oi.debug.bind(Oi,Vl),this.log=Oi.log.bind(Oi,Vl),this.warn=Oi.warn.bind(Oi,Vl),this.error=Oi.error.bind(Oi,Vl),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(Li.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Li.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Li.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Li.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Li.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:i}=this.config,n=e[t];if(n)return n.licenseUrl;if(t===Qi.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,i=e[t];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,i=(t,e,i)=>!!t&&i.indexOf(t)===e,n=e.map((t=>t.audioCodec)).filter(i),r=e.map((t=>t.videoCodec)).filter(i);return n.length+r.length===0&&r.push("avc1.42e01e"),new Promise(((e,i)=>{const s=t=>{const a=t.shift();this.getMediaKeysPromise(a,n,r).then((t=>e({keySystem:a,mediaKeys:t}))).catch((e=>{t.length?s(t):i(e instanceof Hl?e:new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))}))};s(t)}))}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:i}=this.config;if("function"!=typeof i){let t=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===on&&"http:"===self.location.protocol&&(t=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(t))}return i(t,e)}getMediaKeysPromise(t,e,i){const n=function(t,e,i,n){let r;switch(t){case Qi.FAIRPLAY:r=["cenc","sinf"];break;case Qi.WIDEVINE:case Qi.PLAYREADY:r=["cenc"];break;case Qi.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${t}`)}return function(t,e,i,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:i.map((t=>({contentType:`video/mp4; codecs="${t}"`,robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null})))}]}(r,e,i,n)}(t,e,i,this.config.drmSystemOptions),r=this.keySystemAccessPromises[t];let s=null==r?void 0:r.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((i=>{this.log(`Access for key-system "${i.keySystem}" obtained`);const n=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),e.mediaKeys=i.createMediaKeys().then((e=>(this.log(`Media-keys created for "${t}"`),n.then((i=>i?this.setMediaKeysServerCertificate(e,t,i):e))))),e.mediaKeys.catch((e=>{this.error(`Failed to create media-keys for "${t}"}: ${e}`)})),e.mediaKeys}))}return s.then((()=>r.mediaKeys))}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${Rn(t.keyId||[])}`);const n=i.createSession(),r={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),n=this.getKeyIdString(e),r="cenc";this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,r,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 Rn(t.keyId)}updateKeySession(t,e){var i;const n=t.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Rn((null==(i=t.decryptdata)?void 0:i.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,i)=>{const n=an(this.config),r=t.map(nn).filter((t=>!!t&&-1!==n.indexOf(t)));return this.getKeySystemSelectionPromise(r).then((({keySystem:t})=>{const n=sn(t);n?e(n):i(new Error(`Unable to find format for key-system "${t}"`))})).catch(i)}))}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),n=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${n}`);let r=this.keyIdToKeySessionPromise[i];return r||(r=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then((({keySystem:i,mediaKeys:r})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${n}`),this.attemptSetMediaKeys(i,r).then((()=>{this.throwIfDestroyed();const t=this.createMediaKeySessionContext({keySystem:i,mediaKeys:r,decryptdata:e});return this.generateRequestWithPreferredKeySession(t,"cenc",e.pssh,"playlist-key")}))))),r.catch((t=>this.handleError(t)))),r}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof Hl?this.hls.trigger(Li.ERROR,t.data):this.hls.trigger(Li.ERROR,{type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const e=nn(t.keyFormat),i=e?[e]:an(this.config);return this.attemptKeySystemAccess(i)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=an(this.config)),0===t.length)throw new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.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:i}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),null===i)return;let n,r;if("sinf"===e&&this.config.drmSystems[Qi.FAIRPLAY]){const t=Dn(new Uint8Array(i));try{const e=Wi(JSON.parse(t).sinf),i=Hn(new Uint8Array(e));if(!i)return;n=i.subarray(8,24),r=Qi.FAIRPLAY}catch(t){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{const t=function(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},i=new DataView(t),n=i.getUint32(0);if(t.byteLength!==n&&n>44)return null;if(1886614376!==i.getUint32(4))return null;if(e.version=i.getUint32(8)>>>24,e.version>1)return null;e.systemId=Rn(new Uint8Array(t,12,16));const r=i.getUint32(28);if(0===e.version){if(n-32<r)return null;e.data=new Uint8Array(t,32,r)}else if(1===e.version){e.kids=[];for(let i=0;i<r;i++)e.kids.push(new Uint8Array(t,32+16*i,16))}return e}(i);if(null===t)return;0===t.version&&t.systemId===rn&&t.data&&(n=t.data.subarray(8,24)),r=function(t){if(t===rn)return Qi.WIDEVINE}(t.systemId)}if(!r||!n)return;const s=Rn(n),{keyIdToKeySessionPromise:a,mediaKeySessions:o}=this;let l=a[s];for(let t=0;t<o.length;t++){const r=o[t],c=r.decryptdata;if(c.pssh||!c.keyId)continue;const h=Rn(c.keyId);if(s===h||-1!==c.uri.replace(/-/g,"").indexOf(s)){l=a[h],delete a[h],c.pssh=new Uint8Array(i),c.keyId=n,l=a[s]=l.then((()=>this.generateRequestWithPreferredKeySession(r,e,i,"encrypted-event-key-match")));break}}l||(l=a[s]=this.getKeySystemSelectionPromise([r]).then((({keySystem:t,mediaKeys:r})=>{var a;this.throwIfDestroyed();const o=new Jn("ISO-23001-7",s,null!=(a=sn(t))?a:"");return o.pssh=new Uint8Array(i),o.keyId=n,this.attemptSetMediaKeys(t,r).then((()=>{this.throwIfDestroyed();const n=this.createMediaKeySessionContext({decryptdata:o,keySystem:t,mediaKeys:r});return this.generateRequestWithPreferredKeySession(n,e,i,"encrypted-event-no-match")}))}))),l.catch((t=>this.handleError(t)))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const n=Promise.all(i).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}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter((t=>-1===i.indexOf(t)))}))}generateRequestWithPreferredKeySession(t,e,i,n){var r,s;const a=null==(r=this.config.drmSystems)||null==(s=r[t.keySystem])?void 0:s.generateRequest;if(a)try{const n=a.call(this.hls,e,i,t);if(!n)throw new Error("Invalid response from configured generateRequest filter");e=n.initDataType,i=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===i)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: ${i?i.byteLength:null})`);const c=new Bo,h=t._onmessage=e=>{const i=t.mediaKeysSession;if(!i)return void c.emit("error",new Error("invalid state"));const{messageType:n,message:r}=e;this.log(`"${n}" message event for session "${i.sessionId}" message size: ${r.byteLength}`),"license-request"===n||"license-renewal"===n?this.renewLicense(t,r).catch((t=>{this.handleError(t),c.emit("error",t)})):"license-release"===n?t.keySystem===Qi.FAIRPLAY&&(this.updateKeySession(t,qi("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${n}"`)},u=t._onkeystatuseschange=e=>{if(!t.mediaKeysSession)return void c.emit("error",new Error("invalid state"));this.onKeyStatusChange(t);const i=t.keyStatus;c.emit("keyStatus",i),"expired"===i&&(this.warn(`${t.keySystem} expired for key ${l}`),this.renewKeySession(t))};t.mediaKeysSession.addEventListener("message",h),t.mediaKeysSession.addEventListener("keystatuseschange",u);const d=new Promise(((t,e)=>{c.on("error",e),c.on("keyStatus",(i=>{i.startsWith("usable")?t():"output-restricted"===i?e(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===i?e(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${i}"`)):"expired"===i?e(new Error("key expired while generating request")):this.warn(`unhandled key status change "${i}"`)}))}));return t.mediaKeysSession.generateRequest(e,i).then((()=>{var e;this.log(`Request generated for key-session "${null==(e=t.mediaKeysSession)?void 0:e.sessionId}" keyId: ${l}`)})).catch((t=>{throw new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.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,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Rn("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Rn(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e}))}fetchServerCertificate(t){const e=this.config,i=new(0,e.loader)(e),n=this.getServerCertificateUrl(t);return n?(this.log(`Fetching server certificate for "${t}"`),new Promise(((r,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,i,n)=>{r(t.data)},onError:(e,i,r,o)=>{s(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:Ai({url:a.url,data:void 0},e)},`"${t}" certificate request failed (${n}). Status: ${e.code} (${e.text})`))},onTimeout:(e,i,r)=>{s(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:a.url,data:void 0}},`"${t}" certificate request timed out (${n})`))},onAbort:(t,e,i)=>{s(new Error("aborted"))}};i.load(a,l,c)}))):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise(((n,r)=>{t.setServerCertificate(i).then((r=>{this.log(`setServerCertificate ${r?"success":"not supported by CDM"} (${null==i?void 0:i.byteLength}) on "${e}"`),n(t)})).catch((t=>{r(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.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 Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:t,fatal:!0},t.message)}))))}unpackPlayReadyKeyMessage(t,e){const i=String.fromCharCode.apply(null,new Uint16Array(e.buffer));if(!i.includes("PlayReadyKeyMessage"))return t.setRequestHeader("Content-Type","text/xml; charset=utf-8"),e;const n=(new DOMParser).parseFromString(i,"application/xml"),r=n.querySelectorAll("HttpHeader");if(r.length>0){let e;for(let i=0,n=r.length;i<n;i++){var s,a;e=r[i];const n=null==(s=e.querySelector("name"))?void 0:s.textContent,o=null==(a=e.querySelector("value"))?void 0:a.textContent;n&&o&&t.setRequestHeader(n,o)}}const o=n.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return qi(atob(l))}setupLicenseXHR(t,e,i,n){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then((()=>{if(!i.decryptdata)throw new Error("Key removed");return r.call(this.hls,t,e,i,n)})).catch((s=>{if(!i.decryptdata)throw s;return t.open("POST",e,!0),r.call(this.hls,t,e,i,n)})).then((i=>{t.readyState||t.open("POST",e,!0);return{xhr:t,licenseChallenge:i||n}})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:n}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise(((n,r)=>{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 r(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 i=this.config.licenseResponseCallback;if(i)try{e=i.call(this.hls,a,s,t)}catch(t){this.error(t)}n(e)}else{const o=i.errorRetry,l=o?o.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||a.status>=400&&a.status<500)r(new Hl({type:Ri.KEY_SYSTEM_ERROR,details:Ci.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 i=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${i} attempts left`),this.requestLicense(t,e).then(n,r)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=a,this.setupLicenseXHR(a,s,t,e).then((({xhr:e,licenseChallenge:i})=>{t.keySystem==Qi.PLAYREADY&&(i=this.unpackPlayReadyKeyMessage(e,i)),e.send(i)}))}))}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const i=e.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.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={},Jn.clearKeyUriToKeyIdMap();const i=e.length;Kl.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((()=>{i&&(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:i}=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),i&&i.readyState!==XMLHttpRequest.DONE&&i.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}`)}))}}}Kl.CDMCleanupPromise=void 0;class Hl 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 Yl,jl,Wl;!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"}(Yl||(Yl={})),function(t){t.DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o"}(jl||(jl={})),function(t){t.OBJECT="CMCD-Object",t.REQUEST="CMCD-Request",t.SESSION="CMCD-Session",t.STATUS="CMCD-Status"}(Wl||(Wl={}));const zl={[Wl.OBJECT]:["br","d","ot","tb"],[Wl.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[Wl.SESSION]:["cid","pr","sf","sid","st","v"],[Wl.STATUS]:["bs","rtp"]};class ql{constructor(t,e){this.value=void 0,this.params=void 0,Array.isArray(t)&&(t=t.map((t=>t instanceof ql?t:new ql(t)))),this.value=t,this.params=e}}class Xl{constructor(t){this.description=void 0,this.description=t}}const Ql="Dict";function Zl(t,e,i,n){return new Error(`failed to ${t} "${r=e,Array.isArray(r)?JSON.stringify(r):r instanceof Map?"Map{}":r instanceof Set?"Set{}":"object"==typeof r?JSON.stringify(r):String(r)}" as ${i}`,{cause:n});var r}const Jl="Bare Item",tc="Boolean",ec="Byte Sequence",ic="Decimal",nc="Integer";const rc=/[\x00-\x1f\x7f]+/,sc="Token",ac="Key";function oc(t,e,i){return Zl("serialize",t,e,i)}function lc(t){if(!1===ArrayBuffer.isView(t))throw oc(t,ec);return`:${e=t,btoa(String.fromCharCode(...e))}:`;var e}function cc(t){if(function(t){return t<-999999999999999||999999999999999<t}(t))throw oc(t,nc);return t.toString()}function hc(t,e){if(t<0)return-hc(-t,e);const i=Math.pow(10,e);if(Math.abs(t*i%1-.5)<Number.EPSILON){const e=Math.floor(t*i);return(e%2==0?e:e+1)/i}return Math.round(t*i)/i}function uc(t){const e=hc(t,3);if(Math.floor(Math.abs(e)).toString().length>12)throw oc(t,ic);const i=e.toString();return i.includes(".")?i:`${i}.0`}const dc="String";function fc(t){const e=(i=t).description||i.toString().slice(7,-1);var i;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e))throw oc(e,sc);return e}function gc(t){switch(typeof t){case"number":if(!ki(t))throw oc(t,Jl);return Number.isInteger(t)?cc(t):uc(t);case"string":return function(t){if(rc.test(t))throw oc(t,dc);return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(t);case"symbol":return fc(t);case"boolean":return function(t){if("boolean"!=typeof t)throw oc(t,tc);return t?"?1":"?0"}(t);case"object":if(t instanceof Date)return function(t){return`@${cc(t.getTime()/1e3)}`}(t);if(t instanceof Uint8Array)return lc(t);if(t instanceof Xl)return fc(t);default:throw oc(t,Jl)}}function pc(t){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(t))throw oc(t,ac);return t}function mc(t){return null==t?"":Object.entries(t).map((([t,e])=>!0===e?`;${pc(t)}`:`;${pc(t)}=${gc(e)}`)).join("")}function vc(t){return t instanceof ql?`${gc(t.value)}${mc(t.params)}`:gc(t)}function yc(t,e={whitespace:!0}){if("object"!=typeof t)throw oc(t,Ql);const i=t instanceof Map?t.entries():Object.entries(t),n=null!=e&&e.whitespace?" ":"";return Array.from(i).map((([t,e])=>{e instanceof ql==!1&&(e=new ql(e));let i=pc(t);var n;return!0===e.value?i+=mc(e.params):(i+="=",Array.isArray(e.value)?i+=`(${(n=e).value.map(vc).join(" ")})${mc(n.params)}`:i+=vc(e)),i})).join(`,${n}`)}const Ac=t=>"ot"===t||"sf"===t||"st"===t,Ec=t=>"number"==typeof t?ki(t):null!=t&&""!==t&&!1!==t;const Tc=t=>Math.round(t),bc=t=>100*Tc(t/100),kc={br:Tc,d:Tc,bl:bc,dl:bc,mtp:bc,nor:(t,e)=>(null!=e&&e.baseUrl&&(t=function(t,e){const i=new URL(t),n=new URL(e);if(i.origin!==n.origin)return t;const r=i.pathname.split("/").slice(1),s=n.pathname.split("/").slice(1,-1);for(;r[0]===s[0];)r.shift(),s.shift();for(;s.length;)s.shift(),r.unshift("..");return r.join("/")}(t,e.baseUrl)),encodeURIComponent(t)),rtp:bc,tb:Tc};function Sc(t,e={}){return t?function(t,e){return yc(t,e)}(function(t,e){const i={};if(null==t||"object"!=typeof t)return i;const n=Object.keys(t).sort(),r=bi({},kc,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=r[n];o&&(a=o(a,e)),"v"===n&&1===a||"pr"==n&&1===a||Ec(a)&&(Ac(n)&&"string"==typeof a&&(a=new Xl(a)),i[n]=a)})),i}(t,e),bi({whitespace:!1},e)):""}function _c(t,e,i){return bi(t,function(t,e={}){if(!t)return{};const i=Object.entries(t),n=Object.entries(zl).concat(Object.entries((null==e?void 0:e.customHeaderMap)||{})),r=i.reduce(((t,e)=>{var i;const[r,s]=e,a=(null==(i=n.find((t=>t[1].includes(r))))?void 0:i[0])||Wl.REQUEST;return null!=t[a]||(t[a]={}),t[a][r]=s,t}),{});return Object.entries(r).reduce(((t,[i,n])=>(t[i]=Sc(n,e),t)),{})}(e,i))}const Lc="CMCD";const Rc=/CMCD=[^&#]+/;function Cc(t,e,i){const n=function(t,e={}){if(!t)return"";const i=Sc(t,e);return`${Lc}=${encodeURIComponent(i)}`}(e,i);if(!n)return t;if(Rc.test(t))return t.replace(Rc,n);const r=t.includes("?")?"&":"?";return`${t}${r}${n}`}function wc(t,e,i,n){t&&Object.keys(e).forEach((r=>{const s=t.filter((t=>t.groupId===r)).map((t=>{const s=bi({},t);return s.details=void 0,s.attrs=new Mi(s.attrs),s.url=s.attrs.URI=Ic(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),s.groupId=s.attrs["GROUP-ID"]=e[r],s.attrs["PATHWAY-ID"]=n,s}));t.push(...s)}))}function Ic(t,e,i,n){const{HOST:r,PARAMS:s,[i]:a}=n;let o;e&&(o=null==a?void 0:a[e],o&&(t=o));const l=new self.URL(t);return r&&!o&&(l.host=r),s&&Object.keys(s).sort().forEach((t=>{t&&l.searchParams.set(t,s[t])})),l.href}const Dc=/^age:\s*[\d.]+\s*$/im;class Pc{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 Ui,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,i){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=i,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t||!e)return;const i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then((()=>{if(this.loader===i&&!this.stats.aborted)return r(i,e.url)})).catch((t=>{if(this.loader===i&&!this.stats.aborted)return i.open("GET",e.url,!0),r(i,e.url)})).then((()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,e,t)})).catch((t=>{this.callbacks.onError({code:i.status,text:t.message},e,i,n)})):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const n=e.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:s}=i.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),i.timeout=r&&ki(r)?r:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:i}=this;if(!t||!e)return;const n=e.readyState,r=this.config;if(!i.aborted&&n>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(i.loading.first-i.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)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const r=s?e.response:e.responseText,a="arraybuffer"===e.responseType?r.byteLength:r.length;if(i.loaded=i.total=a,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first),!this.callbacks)return;const o=this.callbacks.onProgress;if(o&&o(i,t,r,e),!this.callbacks)return;const l={url:e.responseURL,data:r,code:n};this.callbacks.onSuccess(l,i,t,e)}else{const s=r.loadPolicy.errorRetry;Ts(s,i.retry,!1,{url:t.url,data:void 0,code:n})?this.retry(s):(Oi.error(`${n} while loading ${t.url}`),this.callbacks.onError({code:n,text:e.statusText},t,e,i))}}}loadtimeout(){if(!this.config)return;const t=this.config.loadPolicy.timeoutRetry;if(Ts(t,this.stats.retry,!0))this.retry(t);else{var e;Oi.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:i}=this;this.retryDelay=As(t,i.retry),i.retry++,Oi.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==e?void 0:e.url}, retrying ${i.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&&Dc.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 Oc=/(\d+)-(\d+)\/(\d+)/;class xc{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||Nc,this.controller=new self.AbortController,this.stats=new Ui}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,i){const n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const r=function(t,e){const i={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(bi({},t.headers))};t.rangeEnd&&i.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1));return i}(t,this.controller.signal),s=i.onProgress,a="arraybuffer"===t.responseType,o=a?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:c}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,r),self.clearTimeout(this.requestTimeout),e.timeout=l&&ki(l)?l:c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),i.onTimeout(n,t,this.response)}),e.timeout),self.fetch(this.request).then((r=>{this.response=this.loader=r;const o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=c,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),i.onTimeout(n,t,this.response)}),c-(o-n.loading.start)),!r.ok){const{status:t,statusText:e}=r;throw new Mc(e||"fetch, bad network response",t,r)}return n.loading.first=o,n.total=function(t){const e=t.get("Content-Range");if(e){const t=function(t){const e=Oc.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(ki(t))return t}const i=t.get("Content-Length");if(i)return parseInt(i)}(r.headers)||n.total,s&&ki(e.highWaterMark)?this.loadProgressively(r,n,t,e.highWaterMark,s):a?r.arrayBuffer():"json"===t.responseType?r.json():r.text()})).then((r=>{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=r[o];l&&(n.loaded=n.total=l);const c={url:a.url,data:r,code:a.status};s&&!ki(e.highWaterMark)&&s(n,t,r,a),i.onSuccess(c,n,t,a)})).catch((e=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const r=e&&e.code||0,s=e?e.message:null;i.onError({code:r,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,i,n=0,r){const s=new Da,a=t.body.getReader(),o=()=>a.read().then((a=>{if(a.done)return s.dataLength&&r(e,i,s.flush(),t),Promise.resolve(new ArrayBuffer(0));const l=a.value,c=l.length;return e.loaded+=c,c<n||s.dataLength?(s.push(l),s.dataLength>=n&&r(e,i,s.flush(),t)):r(e,i,l,t),o()})).catch((()=>Promise.reject()));return o()}}function Nc(t,e){return new self.Request(t.url,e)}class Mc extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const Fc=/\s/,Bc={newCue(t,e,i,n){const r=[];let s,a,o,l,c;const h=self.VTTCue||self.TextTrackCue;for(let d=0;d<n.rows.length;d++)if(s=n.rows[d],o=!0,l=0,c="",!s.isEmpty()){var u;for(let t=0;t<s.chars.length;t++)Fc.test(s.chars[t].uchar)&&o?l++:(c+=s.chars[t].uchar,o=!1);s.cueStartTime=e,e===i&&(i+=1e-4),l>=16?l--:l++;const n=Tl(c.trim()),f=Ll(e,i,n);null!=t&&null!=(u=t.cues)&&u.getCueById(f)||(a=new h(e,i,n),a.id=f,a.line=d+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),r.push(a))}return t&&r.length&&(r.sort(((t,e)=>"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line)),r.forEach((e=>Gr(t,e)))),r}},Uc=Ai(Ai({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:Pc,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:i}=this,{autoLevelEnabled:n,media:r}=i;if(!t||!r)return;const s=performance.now(),a=e?e.stats:t.stats,o=e?e.duration:t.duration,l=s-a.loading.start,c=i.minAutoLevel;if(a.aborted||a.loaded&&a.loaded===a.total||t.level<=c)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!n||r.paused||!r.playbackRate||!r.readyState)return;const h=i.mainForwardBufferInfo;if(null===h)return;const u=this.bwEstimator.getEstimateTTFB(),d=Math.abs(r.playbackRate);if(l<=Math.max(u,o/(2*d)*1e3))return;const f=h.len/d,g=a.loading.first?a.loading.first-a.loading.start:-1,p=a.loaded&&g>-1,m=this.getBwEstimate(),v=i.levels,y=v[t.level],A=a.total||Math.max(a.loaded,Math.round(o*y.averageBitrate/8));let E=p?l-g:l;E<1&&p&&(E=Math.min(l,8*a.loaded/m));const T=p?1e3*a.loaded/E:0,b=T?(A-a.loaded)/T:8*A/m+u/1e3;if(b<=f)return;const k=T?8*T:m;let S,_=Number.POSITIVE_INFINITY;for(S=t.level-1;S>c;S--){const t=v[S].maxBitrate;if(_=this.getTimeToLoadFrag(u/1e3,k,o*t,!v[S].details),_<f)break}if(_>=b)return;if(_>10*o)return;i.nextLoadLevel=i.nextAutoLevel=S,p?this.bwEstimator.sample(l-Math.min(u,g),a.loaded):this.bwEstimator.sampleTTFB(l);const L=v[S].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>L&&this.resetEstimator(L),this.clearTimer(),Oi.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: ${b.toFixed(3)} s\n Estimated load time for down switch fragment: ${_.toFixed(3)} s\n TTFB estimate: ${0|g} ms\n Current BW estimate: ${ki(m)?0|m:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${S} @ ${0|L} bps`),i.trigger(Li.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:a})},this.hls=t,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(t){t&&(Oi.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 Ns(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate)}registerListeners(){const{hls:t}=this;t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.FRAG_LOADING,this.onFragLoading,this),t.on(Li.FRAG_LOADED,this.onFragLoaded,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.on(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(Li.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.on(Li.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t&&(t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.FRAG_LOADING,this.onFragLoading,this),t.off(Li.FRAG_LOADED,this.onFragLoaded,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.off(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(Li.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.off(Li.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 i=e.frag;if(!this.ignoreFragment(i)){var n;if(!i.bitrateTest)this.fragCurrent=i,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 Ci.BUFFER_ADD_CODEC_ERROR:case Ci.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case Ci.FRAG_LOAD_TIMEOUT:{const t=e.frag,{fragCurrent:i,partCurrent:n}=this;if(t&&i&&t.sn===i.sn&&t.level===i.level){const e=performance.now(),i=n?n.stats:t.stats,r=e-i.loading.start,s=i.loading.first?i.loading.first-i.loading.start:-1;if(i.loaded&&s>-1){const t=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(r-Math.min(t,s),i.loaded)}else this.bwEstimator.sampleTTFB(r)}break}}}getTimeToLoadFrag(t,e,i,n){return t+i/e+(n?this.lastLevelLoadSec:0)}onLevelLoaded(t,e){const i=this.hls.config,{loading:n}=e.stats,r=n.end-n.start;ki(r)&&(this.lastLevelLoadSec=r/1e3),e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}onFragLoaded(t,{frag:e,part:i}){const n=i?i.stats:e.stats;if(e.type===xr&&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=i?i.duration:e.duration,r=this.hls.levels[e.level],s=(r.loaded?r.loaded.bytes:0)+n.loaded,a=(r.loaded?r.loaded.duration:0)+t;r.loaded={bytes:s,duration:a},r.realBitrate=Math.round(8*s/a)}if(e.bitrateTest){const t={stats:n,frag:e,part:i,id:e.type};this.onFragBuffered(Li.FRAG_BUFFERED,t),e.bitrateTest=!1}else this.lastLoadedFragLevel=e.level}}onFragBuffered(t,e){const{frag:i,part:n}=e,r=null!=n&&n.stats.loaded?n.stats:i.stats;if(r.aborted)return;if(this.ignoreFragment(i))return;const s=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(s,r.loaded),r.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==xr||"initSegment"===t.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:t,minAutoLevel:e}=this.hls,i=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,r=this.findBestLevel(i,e,t,0,n,1,1);if(r>-1)return r;const s=this.hls.firstLevel,a=Math.min(Math.max(s,e),t);return Oi.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(),i=this.lastLoadedFragLevel>-1;if(!(-1===t||e&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return t;const n=e&&i?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:i}=this,{maxAutoLevel:n,config:r,minAutoLevel:s}=i,a=e?e.duration:t?t.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let c=r.abrBandWidthFactor,h=r.abrBandWidthUpFactor;if(l){const t=this.findBestLevel(o,s,n,l,0,c,h);if(t>=0)return t}let u=a?Math.min(a,r.maxStarvationDelay):r.maxStarvationDelay;if(!l){const t=this.bitrateTestDelay;if(t){u=(a?Math.min(a,r.maxLoadingDelay):r.maxLoadingDelay)-t,Oi.info(`[abr] bitrate test took ${Math.round(1e3*t)}ms, set first fragment max fetchDuration to ${Math.round(1e3*u)} ms`),c=h=1}}const d=this.findBestLevel(o,s,n,l,u,c,h);if(Oi.info(`[abr] ${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${d}`),d>-1)return d;const f=i.levels[s],g=i.levels[i.loadLevel];return(null==f?void 0:f.bitrate)<(null==g?void 0:g.bitrate)?s:i.loadLevel}getStarvationDelay(){const t=this.hls,e=t.media;if(!e)return 1/0;const i=e&&0!==e.playbackRate?Math.abs(e.playbackRate):1,n=t.mainForwardBufferInfo;return(n?n.len:0)/i}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(t,e,i,n,r,s,a){var o;const l=n+r,c=this.lastLoadedFragLevel,h=-1===c?this.hls.firstLevel:c,{fragCurrent:u,partCurrent:d}=this,{levels:f,allAudioTracks:g,loadLevel:p,config:m}=this.hls;if(1===f.length)return 0;const v=f[h],y=!(null==v||null==(o=v.details)||!o.live),A=-1===p||-1===c;let E,T="SDR",b=(null==v?void 0:v.frameRate)||0;const{audioPreference:k,videoPreference:S}=m,_=this.audioTracksByGroup||(this.audioTracksByGroup=function(t){return t.reduce(((t,e)=>{let i=t.groups[e.groupId];i||(i=t.groups[e.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(e);const n=e.channels||"2";return i.channels[n]=(i.channels[n]||0)+1,i.hasDefault=i.hasDefault||e.default,i.hasAutoSelect=i.hasAutoSelect||e.autoselect,i.hasDefault&&(t.hasDefaultAudio=!0),i.hasAutoSelect&&(t.hasAutoSelectAudio=!0),t}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(g));if(A){if(-1!==this.firstSelection)return this.firstSelection;const n=this.codecTiers||(this.codecTiers=function(t,e,i,n){return t.slice(i,n+1).reduce(((t,i)=>{if(!i.codecSet)return t;const n=i.audioGroups;let r=t[i.codecSet];r||(t[i.codecSet]=r={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!n,fragmentError:0}),r.minBitrate=Math.min(r.minBitrate,i.bitrate);const s=Math.min(i.height,i.width);return r.minHeight=Math.min(r.minHeight,s),r.minFramerate=Math.min(r.minFramerate,i.frameRate),r.maxScore=Math.max(r.maxScore,i.score),r.fragmentError+=i.fragmentError,r.videoRanges[i.videoRange]=(r.videoRanges[i.videoRange]||0)+1,n&&n.forEach((t=>{if(!t)return;const i=e.groups[t];i&&(r.hasDefaultAudio=r.hasDefaultAudio||e.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(i.channels).forEach((t=>{r.channels[t]=(r.channels[t]||0)+i.channels[t]})))})),t}),{})}(f,_,e,i)),r=function(t,e,i,n,r){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,h=!1,u=1/0,d=1/0,f=1/0,g=0,p=[];const{preferHDR:m,allowedVideoRanges:v}=$s(e,r);for(let e=s.length;e--;){const i=t[s[e]];c=i.channels[2]>0,u=Math.min(u,i.minHeight),d=Math.min(d,i.minFramerate),f=Math.min(f,i.minBitrate);const n=v.filter((t=>i.videoRanges[t]>0));n.length>0&&(h=!0,p=n)}u=ki(u)?u:0,d=ki(d)?d:0;const y=Math.max(1080,u),A=Math.max(30,d);return f=ki(f)?f:i,i=Math.max(f,i),h||(e=void 0,p=[]),{codecSet:s.reduce(((e,n)=>{const r=t[n];if(n===e)return e;if(r.minBitrate>i)return Gs(n,`min bitrate of ${r.minBitrate} > current estimate of ${i}`),e;if(!r.hasDefaultAudio)return Gs(n,"no renditions with default or auto-select sound found"),e;if(o&&n.indexOf(o.substring(0,4))%5!=0)return Gs(n,`audio codec preference "${o}" not found`),e;if(a&&!l){if(!r.channels[a])return Gs(n,`no renditions with ${a} channel sound found (channels options: ${Object.keys(r.channels)})`),e}else if((!o||l)&&c&&0===r.channels[2])return Gs(n,"no renditions with stereo sound found"),e;return r.minHeight>y?(Gs(n,`min resolution of ${r.minHeight} > maximum of ${y}`),e):r.minFramerate>A?(Gs(n,`min framerate of ${r.minFramerate} > maximum of ${A}`),e):p.some((t=>r.videoRanges[t]>0))?r.maxScore<g?(Gs(n,`max score of ${r.maxScore} < selected max of ${g}`),e):e&&(dr(n)>=dr(e)||r.fragmentError>t[e].fragmentError)?e:(g=r.maxScore,n):(Gs(n,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),e)}),void 0),videoRanges:p,preferHDR:m,minFramerate:d,minBitrate:f}}(n,T,t,k,S),{codecSet:s,videoRanges:a,minFramerate:o,minBitrate:l,preferHDR:c}=r;E=s,T=c?a[a.length-1]:a[0],b=o,t=Math.max(t,l),Oi.log(`[abr] picked start tier ${JSON.stringify(r)}`)}else E=null==v?void 0:v.codecSet,T=null==v?void 0:v.videoRange;const L=d?d.duration:u?u.duration:0,R=this.bwEstimator.getEstimateTTFB()/1e3,C=[];for(let o=i;o>=e;o--){var w;const e=f[o],u=o>h;if(!e)continue;if(m.useMediaCapabilities&&!e.supportedResult&&!e.supportedPromise){const i=navigator.mediaCapabilities;"function"==typeof(null==i?void 0:i.decodingInfo)&&Bs(e,_,T,b,t,k)?(e.supportedPromise=Us(e,_,i),e.supportedPromise.then((t=>{if(!this.hls)return;e.supportedResult=t;const i=this.hls.levels,n=i.indexOf(e);t.error?Oi.warn(`[abr] MediaCapabilities decodingInfo error: "${t.error}" for level ${n} ${JSON.stringify(t)}`):t.supported||(Oi.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${n} ${JSON.stringify(t)}`),n>-1&&i.length>1&&(Oi.log(`[abr] Removing unsupported level ${n}`),this.hls.removeLevel(n)))}))):e.supportedResult=Ms}if(E&&e.codecSet!==E||T&&e.videoRange!==T||u&&b>e.frameRate||!u&&b>0&&b<e.frameRate||e.supportedResult&&(null==(w=e.supportedResult.decodingInfoResults)||!w[0].smooth)){C.push(o);continue}const g=e.details,S=(d?null==g?void 0:g.partTarget:null==g?void 0:g.averagetargetduration)||L;let I;I=u?a*t:s*t;const D=L&&n>=2*L&&0===r?f[o].averageBitrate:f[o].maxBitrate,P=this.getTimeToLoadFrag(R,I,D*S,void 0===g);if(I>=D&&(o===c||0===e.loadError&&0===e.fragmentError)&&(P<=R||!ki(P)||y&&!this.bitrateTestDelay||P<l)){const t=this.forcedAutoLevel;return o===p||-1!==t&&t===p||(C.length&&Oi.trace(`[abr] Skipped level(s) ${C.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${f[C[0]].codecs}" ${f[C[0]].videoRange}; not compatible with "${v.codecs}" ${T}`),Oi.info(`[abr] switch candidate:${h}->${o} adjustedbw(${Math.round(I)})-bitrate=${Math.round(I-D)} ttfb:${R.toFixed(1)} avgDuration:${S.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${P.toFixed(1)} firstSelection:${A} codecSet:${E} videoRange:${T} hls.loadLevel:${p}`)),A&&(this.firstSelection=o),o}}return-1}set nextAutoLevel(t){const{maxAutoLevel:e,minAutoLevel:i}=this.hls,n=Math.min(Math.max(t,i),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(Li.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&&Oi.error(`Media element src was set while attaching MediaSource (${e} > ${t})`)},this.hls=t;const e="[buffer-controller]";var i;this.appendSource=(i=ar(t.config.preferManagedMediaSource),"undefined"!=typeof self&&i===self.ManagedMediaSource),this.log=Oi.log.bind(Oi,e),this.warn=Oi.warn.bind(Oi,e),this.error=Oi.error.bind(Oi,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(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.BUFFER_RESET,this.onBufferReset,this),t.on(Li.BUFFER_APPENDING,this.onBufferAppending,this),t.on(Li.BUFFER_CODECS,this.onBufferCodecs,this),t.on(Li.BUFFER_EOS,this.onBufferEos,this),t.on(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Li.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(Li.FRAG_PARSED,this.onFragParsed,this),t.on(Li.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.BUFFER_RESET,this.onBufferReset,this),t.off(Li.BUFFER_APPENDING,this.onBufferAppending,this),t.off(Li.BUFFER_CODECS,this.onBufferCodecs,this),t.off(Li.BUFFER_EOS,this.onBufferEos,this),t.off(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Li.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(Li.FRAG_PARSED,this.onFragParsed,this),t.off(Li.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Ho(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 i=2;(e.audio&&!e.video||!e.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media,n=ar(this.appendSource);if(i&&n){var r;const t=this.mediaSource=new n;this.log(`created media source: ${null==(r=t.constructor)?void 0:r.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{i.removeAttribute("src");const n=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||n&&t instanceof n,jo(i),function(t,e){const i=self.document.createElement("source");i.type="video/mp4",i.src=e,t.appendChild(i)}(i,e),i.load()}catch(t){i.src=e}else i.src=e;i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:i}=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),i&&self.URL.revokeObjectURL(i),this.mediaSrc===i?(t.removeAttribute("src"),this.appendSource&&jo(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(Li.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach((t=>{this.resetBuffer(t)})),this._initSourceBuffer()}resetBuffer(t){const e=this.sourceBuffer[t];try{var i;if(e)this.removeBufferListeners(t),this.sourceBuffer[t]=void 0,null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(e)}catch(e){this.warn(`onBufferReset ${t}`,e)}}onBufferCodecs(t,e){const i=this.getSourceBufferTypes().length,n=Object.keys(e);if(n.forEach((t=>{if(i){const i=this.tracks[t];if(i&&"function"==typeof i.buffer.changeType){var n;const{id:r,codec:s,levelCodec:a,container:o,metadata:l}=e[t],c=mr(i.codec,i.levelCodec),h=null==c?void 0:c.replace(Yo,"$1");let u=mr(s,a);const d=null==(n=u)?void 0:n.replace(Yo,"$1");if(u&&h!==d){"audio"===t.slice(0,5)&&(u=pr(u,this.appendSource));const e=`${o};codecs=${u}`;this.appendChangeType(t,e),this.log(`switching codec ${c} to ${u}`),this.tracks[t]={buffer:i.buffer,codec:s,container:o,levelCodec:a,metadata:l,id:r}}}}else this.pendingTracks[t]=e[t]})),i)return;const r=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==r&&(this.log(`${r} bufferCodec event(s) expected ${n.join(",")}`),this.bufferCodecEventsExpected=r),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}appendChangeType(t,e){const{operationQueue:i}=this,n={execute:()=>{const n=this.sourceBuffer[t];n&&(this.log(`changing ${t} sourceBuffer type to ${e}`),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn(`Failed to change ${t} SourceBuffer type`,e)}};i.append(n,t,!!this.pendingTracks[t])}onBufferAppending(t,e){const{hls:i,operationQueue:n,tracks:r}=this,{data:s,type:a,frag:o,part:l,chunkMeta:c}=e,h=c.buffering[a],u=self.performance.now();h.start=u;const d=o.stats.buffering,f=l?l.stats.buffering:null;0===d.start&&(d.start=u),f&&0===f.start&&(f.start=u);const g=r.audio;let p=!1;"audio"===a&&"audio/mpeg"===(null==g?void 0:g.container)&&(p=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);const m=o.start,v={execute:()=>{if(h.executeStart=self.performance.now(),p){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();h.executeEnd=h.end=t,0===d.first&&(d.first=t),f&&0===f.first&&(f.first=t);const{sourceBuffer:e}=this,i={};for(const t in e)i[t]=ea.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(Li.BUFFER_APPENDED,{type:a,frag:o,part:l,chunkMeta:c,parent:o.type,timeRanges:i})},onError:t=>{const e={type:Ri.MEDIA_ERROR,parent:o.type,details:Ci.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=Ci.BUFFER_FULL_ERROR;else{const t=++this.appendErrors[a];e.details=Ci.BUFFER_APPEND_ERROR,this.warn(`Failed ${t}/${i.config.appendErrorMaxRetry} times to append segment in "${a}" sourceBuffer`),t>=i.config.appendErrorMaxRetry&&(e.fatal=!0)}i.trigger(Li.ERROR,e)}};n.append(v,a,!!this.pendingTracks[a])}onBufferFlushing(t,e){const{operationQueue:i}=this,n=t=>({execute:this.removeExecutor.bind(this,t,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(Li.BUFFER_FLUSHED,{type:t})},onError:e=>{this.warn(`Failed to remove from ${t} SourceBuffer`,e)}});e.type?i.append(n(e.type),e.type):this.getSourceBufferTypes().forEach((t=>{i.append(n(t),t)}))}onFragParsed(t,e){const{frag:i,part:n}=e,r=[],s=n?n.elementaryStreams:i.elementaryStreams;s[Vi]?r.push("audiovideo"):(s[$i]&&r.push("audio"),s[Gi]&&r.push("video"));0===r.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers((()=>{const t=self.performance.now();i.stats.buffering.end=t,n&&(n.stats.buffering.end=t);const e=n?n.stats:i.stats;this.hls.trigger(Li.FRAG_BUFFERED,{frag:i,part:n,stats:e,id:i.type})}),r)}onFragChanged(t,e){this.trimBuffers()}onBufferEos(t,e){this.getSourceBufferTypes().reduce(((t,i)=>{const n=this.sourceBuffer[i];return!n||e.type&&e.type!==i||(n.ending=!0,n.ended||(n.ended=!0,this.log(`${i} 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:i}=this;if(!i||null===e)return;if(!this.getSourceBufferTypes().length)return;const n=t.config,r=i.currentTime,s=e.levelTargetDuration,a=e.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(ki(a)&&a>0){const t=Math.max(a,s),e=Math.floor(r/s)*s-t;this.flushBackBuffer(r,s,e)}if(ki(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){const t=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),e=Math.max(t,s),i=Math.floor(r/s)*s+e;this.flushFrontBuffer(r,s,i)}}flushBackBuffer(t,e,i){const{details:n,sourceBuffer:r}=this;this.getSourceBufferTypes().forEach((s=>{const a=r[s];if(a){const r=ea.getBuffered(a);if(r.length>0&&i>r.start(0)){if(this.hls.trigger(Li.BACK_BUFFER_REACHED,{bufferEnd:i}),null!=n&&n.live)this.hls.trigger(Li.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(a.ended&&r.end(r.length-1)-t<2*e)return void this.log(`Cannot flush ${s} back buffer while SourceBuffer is in ended state`);this.hls.trigger(Li.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:s})}}}))}flushFrontBuffer(t,e,i){const{sourceBuffer:n}=this;this.getSourceBufferTypes().forEach((r=>{const s=n[r];if(s){const n=ea.getBuffered(s),a=n.length;if(a<2)return;const o=n.start(a-1),l=n.end(a-1);if(i>o||t>=o&&t<=l)return;if(s.ended&&t-l<2*e)return void this.log(`Cannot flush ${r} front buffer while SourceBuffer is in ended state`);this.hls.trigger(Li.BUFFER_FLUSHING,{startOffset:o,endOffset:1/0,type:r})}}))}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:t,hls:e,media:i,mediaSource:n}=this,r=t.fragments[0].start+t.totalduration,s=i.duration,a=ki(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(n.duration=1/0,this.updateSeekableRange(t)):(r>a&&r>s||!ki(s))&&(this.log(`Updating Media Source duration to ${r.toFixed(3)}`),n.duration=r)}updateSeekableRange(t){const e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&null!=e&&e.setLiveSeekableRange){const n=Math.max(0,i[0].start),r=Math.max(n,n+t.totalduration);this.log(`Media Source duration is set to ${e.duration}. Setting seekable range to ${n}-${r}.`),e.setLiveSeekableRange(n,r)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:i}=this,n=Object.keys(i).length;if(n&&(!t||2===n||"audiovideo"in i)){this.createSourceBuffers(i),this.pendingTracks={};const t=this.getSourceBufferTypes();if(t.length)this.hls.trigger(Li.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(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const r in t)if(!e[r]){var n;const s=t[r];if(!s)throw Error(`source buffer exists for track ${r}, however track does not`);let a=-1===(null==(n=s.levelCodec)?void 0:n.indexOf(","))?s.levelCodec:s.codec;a&&"audio"===r.slice(0,5)&&(a=pr(a,this.appendSource));const o=`${s.container};codecs=${a}`;this.log(`creating sourceBuffer(${o})`);try{const t=e[r]=i.addSourceBuffer(o),n=r;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 i=e.removedRanges;null!=i&&i.length&&this.hls.trigger(Li.BUFFER_FLUSHED,{type:r})})),this.tracks[r]={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(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,sourceBufferName:r,mimeType:o})}}}get mediaSrc(){var t,e;const i=(null==(t=this.media)||null==(e=t.querySelector)?void 0:e.call(t,"source"))||this.media;return null==i?void 0:i.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:i}=this;i.current(t).onComplete(),i.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){var i;const n=new Error(`${t} SourceBuffer error. MediaSource readyState: ${null==(i=this.mediaSource)?void 0:i.readyState}`);this.error(`${n}`,e),this.hls.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_APPENDING_ERROR,sourceBufferName:t,error:n,fatal:!1});const r=this.operationQueue.current(t);r&&r.onError(n)}removeExecutor(t,e,i){const{media:n,mediaSource:r,operationQueue:s,sourceBuffer:a}=this,o=a[t];if(!n||!r||!o)return this.warn(`Attempting to remove from the ${t} SourceBuffer, but it does not exist`),void s.shiftAndExecuteNext(t);const l=ki(n.duration)?n.duration:1/0,c=ki(r.duration)?r.duration:1/0,h=Math.max(0,e),u=Math.min(i,l,c);u>h&&(!o.ending||o.ended)?(o.ended=!1,this.log(`Removing [${h},${u}] from the ${t} SourceBuffer`),o.remove(h,u)):s.shiftAndExecuteNext(t)}appendExecutor(t,e){const i=this.sourceBuffer[e];if(i)i.ended=!1,i.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:i}=this,n=e.map((t=>i.appendBlocker(t)));Promise.all(n).then((()=>{t(),e.forEach((t=>{const e=this.sourceBuffer[t];null!=e&&e.updating||i.shiftAndExecuteNext(t)}))}))}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,i){const n=this.sourceBuffer[t];if(!n)return;const r=i.bind(this,t);this.listeners[t].push({event:e,listener:r}),n.addEventListener(e,r)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach((t=>{e.removeEventListener(t.event,t.listener)}))}},capLevelController:Gl,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=Oi.log.bind(Oi,"[info]:"),this.warn=Oi.warn.bind(Oi,"[warning]:"),this.error=Oi.error.bind(Oi,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(Li.ERROR,this.onError,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(Li.ERROR,this.onError,this),t.off(Li.ERROR,this.onErrorOut,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.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)===xr?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i,n;if(e.fatal)return;const r=this.hls,s=e.context;switch(e.details){case Ci.FRAG_LOAD_ERROR:case Ci.FRAG_LOAD_TIMEOUT:case Ci.KEY_LOAD_ERROR:case Ci.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case Ci.FRAG_PARSING_ERROR:if(null!=(i=e.frag)&&i.gap)return void(e.errorAction={action:Ls,flags:Is});case Ci.FRAG_GAP:case Ci.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=Rs);case Ci.LEVEL_EMPTY_ERROR:case Ci.LEVEL_PARSING_ERROR:{var a,o;const t=e.parent===xr?e.level:r.loadLevel;e.details===Ci.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 Ci.LEVEL_LOAD_ERROR:case Ci.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==s?void 0:s.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,s.level)));case Ci.AUDIO_TRACK_LOAD_ERROR:case Ci.AUDIO_TRACK_LOAD_TIMEOUT:case Ci.SUBTITLE_LOAD_ERROR:case Ci.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){const t=r.levels[r.loadLevel];if(t&&(s.type===Pr&&t.hasAudioGroup(s.groupId)||s.type===Or&&t.hasSubtitleGroup(s.groupId)))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,r.loadLevel),e.errorAction.action=Rs,void(e.errorAction.flags=Ds)}return;case Ci.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const t=r.levels[r.loadLevel],i=null==t?void 0:t.attrs["HDCP-LEVEL"];i?e.errorAction={action:Rs,flags:Ps,hdcpLevel:i}:this.keySystemError(e)}return;case Ci.BUFFER_ADD_CODEC_ERROR:case Ci.REMUX_ALLOC_ERROR:case Ci.BUFFER_APPEND_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(n=e.level)?n:r.loadLevel));case Ci.INTERNAL_EXCEPTION:case Ci.BUFFER_APPENDING_ERROR:case Ci.BUFFER_FULL_ERROR:case Ci.LEVEL_SWITCH_ERROR:case Ci.BUFFER_STALLED_ERROR:case Ci.BUFFER_SEEK_OVER_HOLE:case Ci.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:Ls,flags:Is})}e.type===Ri.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 i=ys(this.hls.config.playlistLoadPolicy,t),n=this.playlistError++;if(Ts(i,n,vs(t),t.response))return{action:ws,flags:Is,retryConfig:i,retryCount:n};const r=this.getLevelSwitchAction(t,e);return i&&(r.retryConfig=i,r.retryCount=n),r}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),n=e.levels[i],{fragLoadPolicy:r,keyLoadPolicy:s}=e.config,a=ys(t.details.startsWith("key")?s:r,t),o=e.levels.reduce(((t,e)=>t+e.fragmentError),0);if(n){t.details!==Ci.FRAG_GAP&&n.fragmentError++;if(Ts(a,o,vs(t),t.response))return{action:ws,flags:Is,retryConfig:a,retryCount:o}}const l=this.getLevelSwitchAction(t,i);return a&&(l.retryConfig=a,l.retryCount=o),l}getLevelSwitchAction(t,e){const i=this.hls;null==e&&(e=i.loadLevel);const n=this.hls.levels[e];if(n){var r,s;const e=t.details;n.loadError++,e===Ci.BUFFER_APPEND_ERROR&&n.fragmentError++;let l=-1;const{levels:c,loadLevel:h,minAutoLevel:u,maxAutoLevel:d}=i;i.autoLevelEnabled||(i.loadLevel=-1);const f=null==(r=t.frag)?void 0:r.type,g=(f===Nr&&e===Ci.FRAG_PARSING_ERROR||"audio"===t.sourceBufferName&&(e===Ci.BUFFER_ADD_CODEC_ERROR||e===Ci.BUFFER_APPEND_ERROR))&&c.some((({audioCodec:t})=>n.audioCodec!==t)),p="video"===t.sourceBufferName&&(e===Ci.BUFFER_ADD_CODEC_ERROR||e===Ci.BUFFER_APPEND_ERROR)&&c.some((({codecSet:t,audioCodec:e})=>n.codecSet!==t&&n.audioCodec===e)),{type:m,groupId:v}=null!=(s=t.context)?s:{};for(let i=c.length;i--;){const r=(i+h)%c.length;if(r!==h&&r>=u&&r<=d&&0===c[r].loadError){var a,o;const i=c[r];if(e===Ci.FRAG_GAP&&f===xr&&t.frag){const e=c[r].details;if(e){const i=ks(t.frag,e.fragments,t.frag.start);if(null!=i&&i.gap)continue}}else{if(m===Pr&&i.hasAudioGroup(v)||m===Or&&i.hasSubtitleGroup(v))continue;if(f===Nr&&null!=(a=n.audioGroups)&&a.some((t=>i.hasAudioGroup(t)))||f===Mr&&null!=(o=n.subtitleGroups)&&o.some((t=>i.hasSubtitleGroup(t)))||g&&n.audioCodec===i.audioCodec||!g&&n.audioCodec!==i.audioCodec||p&&n.codecSet===i.codecSet)continue}l=r;break}}if(l>-1&&i.loadLevel!==l)return t.levelRetry=!0,this.playlistError=0,{action:Rs,flags:Is,nextAutoLevel:l}}return{action:Rs,flags:Ds}}onErrorOut(t,e){var i;switch(null==(i=e.errorAction)?void 0:i.action){case Ls:break;case Rs:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===Ci.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,i=t.errorAction;if(!i)return;const{flags:n,hdcpLevel:r,nextAutoLevel:s}=i;switch(n){case Is:this.switchLevel(t,s);break;case Ps:r&&(e.maxHdcpLevel=ts[ts.indexOf(r)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`)}i.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(Li.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(Li.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const i=this.hls.config;if(i.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),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const n=performance.now();if(e){if(this.lastTime){const t=n-this.lastTime,r=i-this.lastDroppedFrames,s=e-this.lastDecodedFrames,a=1e3*r/t,o=this.hls;if(o.trigger(Li.FPS_DROP,{currentDropped:r,currentDecoded:s,totalDroppedFrames:i}),a>0&&r>o.config.fpsDroppedMonitoringThreshold*s){let t=o.currentLevel;Oi.warn("drop FPS ratio greater than max allowed value for currentLevel: "+t),t>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=t)&&(t-=1,o.trigger(Li.FPS_DROP_LEVEL_CAPPING,{level:t,droppedLevel:o.currentLevel}),o.autoLevelCapping=t,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,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:on,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:Bc,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 Ia{constructor(t,e,i){super(t,e,i,"[subtitle-stream-controller]",Mr),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(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Li.ERROR,this.onError,this),t.on(Li.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(Li.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(Li.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(Li.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Li.ERROR,this.onError,this),t.off(Li.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(Li.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(Li.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(Li.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=Aa,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:i,success:n}=e;if(this.fragPrevious=i,this.state=Aa,!n)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let s;const a=i.start;for(let t=0;t<r.length;t++)if(a>=r[t].start&&a<=r[t].end){s=r[t];break}const o=i.start+i.duration;s?s.end=o:(s={start:a,end:o},r.push(s)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null)}onBufferFlushing(t,e){const{startOffset:i,endOffset:n}=e;if(0===i&&n!==Number.POSITIVE_INFINITY){const t=n-1;if(t<=0)return;e.endOffsetSubtitles=Math.max(0,t),this.tracksBuffered.forEach((e=>{for(let i=0;i<e.length;)if(e[i].end<=t)e.shift();else{if(!(e[i].start<t))break;e[i].start=t,i++}})),this.fragmentTracker.removeFragmentsInRange(i,t,Mr)}}onFragBuffered(t,e){var i;this.loadedmetadata||e.frag.type!==xr||null!=(i=this.media)&&i.buffered.length&&(this.loadedmetadata=!0)}onError(t,e){const i=e.frag;(null==i?void 0:i.type)===Mr&&(e.details===Ci.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==ya&&(this.state=Aa))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){this.levels&&$o(this.levels,e)?this.levels=e.map((t=>new os(t))):(this.tracksBuffered=[],this.levels=e.map((t=>{const e=new os(t);return this.tracksBuffered[e.id]=[],e})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Mr),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){var i;if(this.currentTrackId=e.id,null==(i=this.levels)||!i.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 i;const{currentTrackId:n,levels:r}=this,{details:s,id:a}=e;if(!r)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=r[a];if(a>=r.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!=(i=o.details)&&i.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,fs(s,l));else s.hasProgramDateTime&&t.hasProgramDateTime?(oa(s,t),l=s.fragments[0].start):e&&(l=e.start,fs(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===Aa)){ks(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:i}=t,n=e.decryptdata,r=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&"AES-128"===n.method){const t=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch((t=>{throw r.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((i=>{const n=performance.now();r.trigger(Li.FRAG_DECRYPTED,{frag:e,payload:i,stats:{tstart:t,tdecrypt:n}})})).catch((t=>{this.warn(`${t.name}: ${t.message}`),this.state=Aa}))}}doTick(){if(this.media){if(this.state===Aa){const{currentTrackId:t,levels:e}=this,i=null==e?void 0:e[t];if(!i||!e.length||!i.details)return;const{config:n}=this,r=this.getLoadPosition(),s=ea.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,n.maxBufferHole),{end:a,len:o}=s,l=this.getFwdBufferInfo(this.media,xr),c=i.details;if(o>this.getMaxBufferLength(null==l?void 0:l.len)+c.levelTargetDuration)return;const h=c.fragments,u=h.length,d=c.edge;let f=null;const g=this.fragPrevious;if(a<d){const t=n.maxFragLookUpTolerance,e=a>d-t?0:t;f=ks(g,h,Math.max(h[0].start,a),e),!f&&g&&g.start<h[0].start&&(f=h[0])}else f=h[u-1];if(!f)return;if(f=this.mapToInitFragWhenRequired(f),"initSegment"!==f.sn){const t=h[f.sn-c.startSN-1];t&&t.cc===f.cc&&this.fragmentTracker.getState(t)===Ws&&(f=t)}this.fragmentTracker.getState(f)===Ws&&this.loadFragment(f,i,a)}}else this.state=Aa}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,i){this.fragCurrent=t,"initSegment"===t.sn?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,i))}get mediaBufferTimeRanges(){return new Ko(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Os{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.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=Hr(this.media.textTracks);for(let i=0;i<e.length;i++)if("hidden"===e[i].mode)t=e[i];else if("showing"===e[i].mode){t=e[i];break}const i=this.findTrackForTextTrack(t);this.subtitleTrack!==i&&this.setSubtitleTrack(i)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:t}=this;t.on(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.LEVEL_LOADING,this.onLevelLoading,this),t.on(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Li.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(Li.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.LEVEL_LOADING,this.onLevelLoading,this),t.off(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Li.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(Li.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);Hr(this.media.textTracks).forEach((t=>{Vr(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:i,groupId:n,details:r}=e,s=this.tracksInGroup[i];if(!s||s.groupId!==n)return void this.warn(`Subtitle track with id:${i} 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 ${i} "${s.name}" lang:${s.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,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 i=e.subtitleGroups||null,n=this.groupIds;let r=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some((t=>-1===(null==n?void 0:n.indexOf(t))))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const t=this.tracks.filter((t=>!i||-1!==i.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(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=t;const e=this.hls.config.subtitlePreference;if(!r&&e){this.selectDefaultTrack=!1;const i=Vs(e,t);if(i>-1)r=t[i];else{const t=Vs(e,this.tracks);r=this.tracks[t]}}let n=this.findTrackId(r);-1===n&&r&&(n=this.findTrackId(null));const s={subtitleTracks:t};this.log(`Updating subtitle tracks, ${t.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(Li.SUBTITLE_TRACKS_UPDATED,s),-1!==n&&-1===this.trackId&&this.setSubtitleTrack(n)}else this.shouldReloadPlaylist(r)&&this.setSubtitleTrack(this.trackId)}findTrackId(t){const e=this.tracksInGroup,i=this.selectDefaultTrack;for(let n=0;n<e.length;n++){const r=e[n];if((!i||r.default)&&(i||t)&&(!t||Ks(r,t)))return n}if(t){for(let i=0;i<e.length;i++){const n=e[i];if(Go(t.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<e.length;i++){const n=e[i];if(Go(t.attrs,n.attrs,["LANGUAGE"]))return i}}return-1}findTrackForTextTrack(t){if(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){if(Vo(e[i],t))return i}}return-1}onError(t,e){!e.fatal&&e.context&&(e.context.type!==Or||e.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(e.context.groupId)||this.checkRetry(e))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1,this.setSubtitleTrack(t)}setSubtitleOption(t){if(this.hls.config.subtitlePreference=t,t){const e=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,e.length){const i=this.currentTrack;if(i&&Ks(t,i))return i;const n=Vs(t,this.tracksInGroup);if(n>-1){const t=this.tracksInGroup[n];return this.setSubtitleTrack(n),t}if(i)return null;{const i=Vs(t,e);if(i>-1)return e[i]}}}return null}loadPlaylist(t){super.loadPlaylist();const e=this.currentTrack;if(this.shouldLoadPlaylist(e)&&e){const i=e.id,n=e.groupId;let r=e.url;if(t)try{r=t.addDirectives(r)}catch(t){this.warn(`Could not construct new URL with HLS Delivery Directives: ${t}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(Li.SUBTITLE_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null})}}toggleTrackModes(){const{media:t}=this;if(!t)return;const e=Hr(t.textTracks),i=this.currentTrack;let n;if(i&&(n=e.filter((t=>Vo(i,t)))[0],n||this.warn(`Unable to find subtitle TextTrack with name "${i.name}" and language "${i.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||!ki(t))return void this.warn(`Invalid subtitle track id: ${t}`);this.clearTimer(),this.selectDefaultTrack=!1;const i=this.currentTrack,n=e[t]||null;if(this.trackId=t,this.currentTrack=n,this.toggleTrackModes(),!n)return void this.hls.trigger(Li.SUBTITLE_TRACK_SWITCH,{id:t});const r=!!n.details&&!n.details.live;if(t===this.trackId&&n===i&&r)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(Li.SUBTITLE_TRACK_SWITCH,{id:s,groupId:a,name:o,type:l,url:c});const h=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(h)}},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(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(Li.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(Li.FRAG_LOADING,this.onFragLoading,this),t.on(Li.FRAG_LOADED,this.onFragLoaded,this),t.on(Li.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(Li.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(Li.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(Li.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(Li.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(Li.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(Li.FRAG_LOADING,this.onFragLoading,this),t.off(Li.FRAG_LOADED,this.onFragLoaded,this),t.off(Li.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(Li.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(Li.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(Li.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(Li.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 dl(this,"textTrack1"),e=new dl(this,"textTrack2"),i=new dl(this,"textTrack3"),n=new dl(this,"textTrack4");this.cea608Parser1=new cl(1,t,e),this.cea608Parser2=new cl(3,i,n)}}addCues(t,e,i,n,r){let s=!1;for(let t=r.length;t--;){const n=r[t],h=(a=n[0],o=n[1],l=e,c=i,Math.min(o,c)-Math.max(a,l));if(h>=0&&(n[0]=Math.min(n[0],e),n[1]=Math.max(n[1],i),s=!0,h/(i-e)>.5))return}var a,o,l,c;if(s||r.push([e,i]),this.config.renderTextTracksNatively){const r=this.captionsTracks[t];this.Cues.newCue(r,e,i,n)}else{const r=this.Cues.newCue(null,e,i,n);this.hls.trigger(Li.CUES_PARSED,{type:"captions",cues:r,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:n,timescale:r}){const{unparsedVttFrags:s}=this;"main"===i&&(this.initPTS[e.cc]={baseTime:n,timescale:r}),s.length&&(this.unparsedVttFrags=[],s.forEach((t=>{this.onFragLoaded(Li.FRAG_LOADED,t)})))}getExistingTrack(t,e){const{media:i}=this;if(i)for(let n=0;n<i.textTracks.length;n++){const r=i.textTracks[n];if($l(r,{name:t,lang:e,attrs:{}}))return r}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:i,media:n}=this,{label:r,languageCode:s}=e[t],a=this.getExistingTrack(r,s);if(a)i[t]=a,Vr(i[t]),$r(i[t],n);else{const e=this.createTextTrack("captions",r,s);e&&(e[t]=!0,i[t]=e)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const i={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=i,this.hls.trigger(Li.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}createTextTrack(t,e,i){const n=this.media;if(n)return n.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach((e=>{Vr(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;t<e.length;t++)Vr(e[t])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],n=i.some((t=>t.textCodec===Cl));if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if($o(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const t=this.media,e=t?Hr(t.textTracks):null;if(this.tracks.forEach(((t,i)=>{let n;if(e){let i=null;for(let n=0;n<e.length;n++)if(e[n]&&$l(e[n],t)){i=e[n],e[n]=null;break}i&&(n=i)}if(n)Vr(n);else{const e=Ul(t);n=this.createTextTrack(e,t.name,t.lang),n&&(n.mode="disabled")}n&&this.textTracks.push(n)})),null!=e&&e.length){const t=e.filter((t=>null!==t)).map((t=>t.label));t.length&&Oi.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(Li.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 i=`textTrack${e[1]}`,n=this.captionsProperties[i];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===xr){var i,n;const{cea608Parser1:t,cea608Parser2:r,lastSn:s}=this,{cc:a,sn:o}=e.frag,l=null!=(i=null==(n=e.part)?void 0:n.index)?i:-1;t&&r&&(o!==s+1||o===s&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(t.reset(),r.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(t,e){const{frag:i,payload:n}=e;if(i.type===Mr)if(n.byteLength){const t=i.decryptdata,r="stats"in e;if(null==t||!t.encrypted||r){const t=this.tracks[i.level],r=this.vttCCs;r[i.cc]||(r[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),t&&t.textCodec===Cl?this._parseIMSC1(i,n):this._parseVTTs(e)}}else this.hls.trigger(Li.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const i=this.hls;Pl(e,this.initPTS[t.cc],(e=>{this._appendCues(e,t.level),i.trigger(Li.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(e=>{Oi.log(`Failed to parse IMSC1: ${e}`),i.trigger(Li.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})}))}_parseVTTs(t){var e;const{frag:i,payload:n}=t,{initPTS:r,unparsedVttFrags:s}=this,a=r.length-1;if(!r[i.cc]&&-1===a)return void s.push(t);const o=this.hls;Rl(null!=(e=i.initSegment)&&e.data?jn(i.initSegment.data,new Uint8Array(n)):n,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,(t=>{this._appendCues(t,i.level),o.trigger(Li.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})}),(e=>{const r="Missing initPTS for VTT MPEGTS"===e.message;r?s.push(t):this._fallbackToIMSC1(i,n),Oi.log(`Failed to parse VTT cue: ${e}`),r&&a>i.cc||o.trigger(Li.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:e})}))}_fallbackToIMSC1(t,e){const i=this.tracks[t.level];i.textCodec||Pl(e,this.initPTS[t.cc],(()=>{i.textCodec=Cl,this._parseIMSC1(t,e)}),(()=>{i.textCodec="wvtt"}))}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const i=this.textTracks[e];if(!i||"disabled"===i.mode)return;t.forEach((t=>Gr(i,t)))}else{const n=this.tracks[e];if(!n)return;const r=n.default?"default":"subtitles"+e;i.trigger(Li.CUES_PARSED,{type:"subtitles",cues:t,track:r})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===Mr&&this.onFragLoaded(Li.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){this.initCea608Parsers();const{cea608Parser1:i,cea608Parser2:n}=this;if(!this.enabled||!i||!n)return;const{frag:r,samples:s}=e;if(r.type!==xr||"NONE"!==this.closedCaptionsForLevel(r))for(let t=0;t<s.length;t++){const e=s[t].bytes;if(e){const r=this.extractCea608Data(e);i.addData(s[t].pts,r[0]),n.addData(s[t].pts,r[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:n,type:r}){const{media:s}=this;if(s&&!(s.currentTime<i)){if(!r||"video"===r){const{captionsTracks:t}=this;Object.keys(t).forEach((n=>Kr(t[n],e,i)))}if(this.config.renderTextTracksNatively&&0===e&&void 0!==n){const{textTracks:t}=this;Object.keys(t).forEach((i=>Kr(t[i],e,n)))}}}extractCea608Data(t){const e=[[],[]],i=31&t[0];let n=2;for(let r=0;r<i;r++){const i=t[n++],r=127&t[n++],s=127&t[n++];if(0===r&&0===s)continue;if(0!=(4&i)){const t=3&i;0!==t&&1!==t||(e[t].push(r),e[t].push(s))}}return e}},audioStreamController:class extends Ia{constructor(t,e,i){super(t,e,i,"[audio-stream-controller]",Nr),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:t}=this;t.on(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Li.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(Li.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(Li.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(Li.ERROR,this.onError,this),t.on(Li.BUFFER_RESET,this.onBufferReset,this),t.on(Li.BUFFER_CREATED,this.onBufferCreated,this),t.on(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(Li.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(Li.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Li.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(Li.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(Li.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(Li.ERROR,this.onError,this),t.off(Li.BUFFER_RESET,this.onBufferReset,this),t.off(Li.BUFFER_CREATED,this.onBufferCreated,this),t.off(Li.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(Li.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(Li.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:i,initPTS:n,timescale:r}){if("main"===i){const t=e.cc;this.initPTS[e.cc]={baseTime:n,timescale:r},this.log(`InitPTS for cc: ${t} found from main: ${n}`),this.videoTrackCC=t,this.state===Ca&&this.tick()}}startLoad(t){if(!this.levels)return this.startPosition=t,void(this.state=ya);const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),e>0&&-1===t?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=Aa):(this.loadedmetadata=!1,this.state=ka),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case Aa:this.doTickIdle();break;case ka:{var t;const{levels:e,trackId:i}=this,n=null==e||null==(t=e[i])?void 0:t.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=Ca}break}case ba:{var e;const t=performance.now(),i=this.retryDate;if(!i||t>=i||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=Aa}break}case Ca:{const t=this.waitingData;if(t){const{frag:e,part:i,cache:n,complete:r}=t;if(void 0!==this.initPTS[e.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=Ta;const t={frag:e,part:i,payload:n.flush(),networkDetails:null};this._handleFragmentLoadProgress(t),r&&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(),i=ea.bufferInfo(this.mediaBuffer,t,this.config.maxBufferHole);Ss(i.end,this.config.maxFragLookUpTolerance,e)<0&&(this.log(`Waiting fragment cc (${e.cc}) @ ${e.start} cancelled because another fragment at ${i.end} is needed`),this.clearWaitingFragment())}}else this.state=Aa}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Aa)}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:i,trackId:n}=this,r=t.config;if(!i&&(this.startFragRequested||!r.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=ka);const o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,$i,Nr));const l=this.getFwdBufferInfo(o,Nr);if(null===l)return;const{bufferedTrack:c,switchingTrack:h}=this;if(!h&&this._streamEnded(l,a))return t.trigger(Li.BUFFER_EOS,{type:"audio"}),void(this.state=La);const u=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,xr),d=l.len,f=this.getMaxBufferLength(null==u?void 0:u.len),g=a.fragments,p=g[0].start;let m=this.flushing?this.getLoadPosition():l.end;if(h&&i){const t=this.getLoadPosition();c&&!Go(h.attrs,c.attrs)&&(m=t),a.PTSKnown&&t<p&&(l.end>p||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=p+.05)}if(d>=f&&!h&&m<g[g.length-1].start)return;let v=this.getNextFragment(m,a),y=!1;if(v&&this.isLoopLoading(v,m)&&(y=!!v.gap,v=this.getNextFragmentLoopLoading(v,a,l,xr,f)),!v)return void(this.bufferFlushed=!0);const A=u&&v.start>u.end+a.targetduration;if(A||(null==u||!u.len)&&l.len){const t=this.getAppendedFrag(v.start,xr);if(null===t)return;if(y||(y=!!t.gap||!!A&&0===u.len),A&&!y||y&&l.nextStart&&l.nextStart<t.end)return}this.loadFragment(v,s,m)}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map((t=>new os(t)))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=Aa,this.flushAudioIfNeeded(e)):(this.switchingTrack=null,this.bufferedTrack=e,this.state=ya),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(Li.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var i;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=e);const{levels:n}=this,{details:r,id:s}=e;if(!n)return void this.warn(`Audio tracks were reset while loading level ${s}`);this.log(`Audio track ${s} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const a=n[s];let o=0;if(r.live||null!=(i=a.details)&&i.live){this.checkLiveUpdate(r);const t=this.mainDetails;if(r.deltaUpdateFailed||!t)return;var l;if(!a.details&&r.hasProgramDateTime&&t.hasProgramDateTime)oa(r,t),o=r.fragments[0].start;else o=this.alignPlaylists(r,a.details,null==(l=this.levelLastLoaded)?void 0:l.details)}a.details=r,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(this.mainDetails||r,o),this.state!==ka||this.waitForCdnTuneIn(r)||(this.state=Aa),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,payload:r}=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 ${i.sn} of level ${i.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(i.start);const h=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let u=this.transmuxer;u||(u=this.transmuxer=new Uo(this.hls,Nr,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const d=this.initPTS[i.cc],f=null==(e=i.initSegment)?void 0:e.data;if(void 0!==d){const t=!1,e=n?n.index:-1,s=-1!==e,a=new ia(i.level,i.sn,i.stats.chunkCount,r.byteLength,e,s);u.push(r,f,h,"",i,n,c.totalduration,t,a,d)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${c.startSN} ,${c.endSN}],track ${a}`);const{cache:t}=this.waitingData=this.waitingData||{frag:i,part:n,cache:new Da,complete:!1};t.push(new Uint8Array(r)),this.waitingVideoCC=this.videoTrackCC,this.state=Ca}}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const i=e.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:i,part:n}=e;if(i.type===Nr)if(this.fragContextChanged(i))this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if("initSegment"!==i.sn){this.fragPrevious=i;const t=this.switchingTrack;t&&(this.bufferedTrack=t,this.switchingTrack=null,this.hls.trigger(Li.AUDIO_TRACK_SWITCHED,Ai({},t)))}this.fragBufferedComplete(i,n)}else if(!this.loadedmetadata&&i.type===xr){const t=this.videoBuffer||this.media;if(t){ea.getBuffered(t).length&&(this.loadedmetadata=!0)}}}onError(t,e){var i;if(e.fatal)this.state=Ra;else switch(e.details){case Ci.FRAG_GAP:case Ci.FRAG_PARSING_ERROR:case Ci.FRAG_DECRYPT_ERROR:case Ci.FRAG_LOAD_ERROR:case Ci.FRAG_LOAD_TIMEOUT:case Ci.KEY_LOAD_ERROR:case Ci.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Nr,e);break;case Ci.AUDIO_TRACK_LOAD_ERROR:case Ci.AUDIO_TRACK_LOAD_TIMEOUT:case Ci.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==ka||(null==(i=e.context)?void 0:i.type)!==Pr||(this.state=Aa);break;case Ci.BUFFER_APPEND_ERROR:case Ci.BUFFER_FULL_ERROR:if(!e.parent||"audio"!==e.parent)return;if(e.details===Ci.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Ci.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushing(t,{type:e}){e!==Gi&&(this.flushing=!0)}onBufferFlushed(t,{type:e}){if(e!==Gi){this.flushing=!1,this.bufferFlushed=!0,this.state===La&&(this.state=Aa);const t=this.mediaBuffer||this.media;t&&(this.afterBufferFlushed(t,e,Nr),this.tick())}}_handleTransmuxComplete(t){var e;const i="audio",{hls:n}=this,{remuxResult:r,chunkMeta:s}=t,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:l,level:c}=a,{details:h}=c,{audio:u,text:d,id3:f,initSegment:g}=r;if(!this.fragContextChanged(o)&&h){if(this.state=Sa,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=g&&g.tracks){const t=o.initSegment||o;this._bufferInitSegment(c,g.tracks,t,s),n.trigger(Li.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:i,tracks:g.tracks})}if(u){const{startPTS:t,endPTS:e,startDTS:i,endDTS:n}=u;l&&(l.elementaryStreams[$i]={startPTS:t,endPTS:e,startDTS:i,endDTS:n}),o.setElementaryStreamInfo($i,t,e,i,n),this.bufferFragmentData(u,o,l,s)}if(null!=f&&null!=(e=f.samples)&&e.length){const t=bi({id:i,frag:o,details:h},f);n.trigger(Li.FRAG_PARSING_METADATA,t)}if(d){const t=bi({id:i,frag:o,details:h},d);n.trigger(Li.FRAG_PARSING_USERDATA,t)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(t,e,i,n){if(this.state!==Sa)return;e.video&&delete e.video;const r=e.audio;if(!r)return;r.id="audio";const s=t.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${s}/${r.codec}]`),s&&1===s.split(",").length&&(r.levelCodec=s),this.hls.trigger(Li.BUFFER_CODECS,e);const a=r.initSegment;if(null!=a&&a.byteLength){const t={type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:a};this.hls.trigger(Li.BUFFER_APPENDING,t)}this.tickImmediate()}loadFragment(t,e,i){const n=this.fragmentTracker.getState(t);var r;if(this.fragCurrent=t,this.switchingTrack||n===Ws||n===qs)if("initSegment"===t.sn)this._loadInitSegment(t,e);else if(null!=(r=e.details)&&r.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=Ca;const i=this.mainDetails;i&&i.fragments[0].start!==e.details.fragments[0].start&&oa(e.details,i)}else this.startFragRequested=!0,super.loadFragment(t,e,i);else this.clearTrackerIfNeeded(t)}flushAudioIfNeeded(t){const{media:e,bufferedTrack:i}=this,n=null==i?void 0:i.attrs,r=t.attrs;e&&n&&(n.CHANNELS!==r.CHANNELS||i.name!==t.name||i.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(Li.AUDIO_TRACK_SWITCHED,Ai({},t))}},audioTrackController:class extends Os{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(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.LEVEL_LOADING,this.onLevelLoading,this),t.on(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(Li.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(Li.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.LEVEL_LOADING,this.onLevelLoading,this),t.off(Li.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(Li.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(Li.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:i,groupId:n,details:r}=e,s=this.tracksInGroup[i];if(!s||s.groupId!==n)return void this.warn(`Audio track with id:${i} 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 ${i} "${s.name}" lang:${s.lang} group:${n} loaded [${r.startSN}-${r.endSN}]`),i===this.trackId&&this.playlistLoaded(i,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 i=e.audioGroups||null,n=this.groupIds;let r=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some((t=>-1===(null==n?void 0:n.indexOf(t))))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;const t=this.tracks.filter((t=>!i||-1!==i.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(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=t;const e=this.hls.config.audioPreference;if(!r&&e){const i=Vs(e,t,Hs);if(i>-1)r=t[i];else{const t=Vs(e,this.tracks);r=this.tracks[t]}}let n=this.findTrackId(r);-1===n&&r&&(n=this.findTrackId(null));const a={audioTracks:t};this.log(`Updating audio tracks, ${t.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(Li.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(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e})}}else this.shouldReloadPlaylist(r)&&this.setAudioTrack(this.trackId)}onError(t,e){!e.fatal&&e.context&&(e.context.type!==Pr||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 i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){const n=this.currentTrack;if(n&&Ks(t,n,Hs))return n;const r=Vs(t,this.tracksInGroup,Hs);if(r>-1){const t=this.tracksInGroup[r];return this.setAudioTrack(r),t}if(n){let n=e.loadLevel;-1===n&&(n=e.firstAutoLevel);const r=function(t,e,i,n,r){const s=e[n],a=e.reduce(((t,e,i)=>{const n=e.uri;return(t[n]||(t[n]=[])).push(i),t}),{}),o=a[s.uri];o.length>1&&(n=Math.max.apply(Math,o));const l=s.videoRange,c=s.frameRate,h=s.codecSet.substring(0,4),u=Ys(e,n,(e=>{if(e.videoRange!==l||e.frameRate!==c||e.codecSet.substring(0,4)!==h)return!1;const n=e.audioGroups,s=i.filter((t=>!n||-1!==n.indexOf(t.groupId)));return Vs(t,s,r)>-1}));return u>-1?u:Ys(e,n,(e=>{const n=e.audioGroups,s=i.filter((t=>!n||-1!==n.indexOf(t.groupId)));return Vs(t,s,r)>-1}))}(t,e.levels,i,n,Hs);if(-1===r)return null;e.nextLoadLevel=r}if(t.channels||t.audioCodec){const e=Vs(t,i);if(e>-1)return i[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 i=this.currentTrack,n=e[t],r=n.details&&!n.details.live;if(t===this.trackId&&n===i&&r)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(Li.AUDIO_TRACK_SWITCHING,Ai({},n)),r)return;const s=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(s)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||Ks(t,n,Hs)))return i}if(t){const{name:i,lang:n,assocLang:r,characteristics:s,audioCodec:a,channels:o}=t;for(let t=0;t<e.length;t++){if(Ks({name:i,lang:n,assocLang:r,characteristics:s,audioCodec:a,channels:o},e[t],Hs))return t}for(let i=0;i<e.length;i++){const n=e[i];if(Go(t.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return i}for(let i=0;i<e.length;i++){const n=e[i];if(Go(t.attrs,n.attrs,["LANGUAGE"]))return i}}return-1}loadPlaylist(t){const e=this.currentTrack;if(this.shouldLoadPlaylist(e)&&e){super.loadPlaylist();const i=e.id,n=e.groupId;let r=e.url;if(t)try{r=t.addDirectives(r)}catch(t){this.warn(`Could not construct new URL with HLS Delivery Directives: ${t}`)}this.log(`loading audio-track playlist ${i} "${e.name}" lang:${e.lang} group:${n}`),this.clearTimer(),this.hls.trigger(Li.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:n,deliveryDirectives:t||null})}}},emeController:Kl,cmcdController:class{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=t=>{try{this.apply(t,{ot:Yl.MANIFEST,su:!this.initialized})}catch(t){Oi.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=t=>{try{const e=t.frag,i=this.hls.levels[e.level],n=this.getObjectType(e),r={d:1e3*e.duration,ot:n};n!==Yl.VIDEO&&n!==Yl.AUDIO&&n!=Yl.MUXED||(r.br=i.bitrate/1e3,r.tb=this.getTopBandwidth(n)/1e3,r.bl=this.getBufferLength(n)),this.apply(t,r)}catch(t){Oi.warn("Could not generate segment CMCD data.",t)}},this.hls=t;const e=this.config=t.config,{cmcd:i}=e;null!=i&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.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 i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)}))}}}(),this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.includeKeys=i.includeKeys,this.registerListeners())}registerListeners(){const t=this.hls;t.on(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHED,this.onMediaDetached,this),t.on(Li.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHED,this.onMediaDetached,this),t.off(Li.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 i,n;this.audioBuffer=null==(i=e.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(n=e.tracks.video)?void 0:n.buffer}createData(){var t;return{v:1,sf:jl.HLS,sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){bi(e,this.createData());const i=e.ot===Yl.INIT||e.ot===Yl.VIDEO||e.ot===Yl.MUXED;this.starved&&i&&(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,i)=>(n.includes(i)&&(t[i]=e[i]),t)),{})),this.useHeaders?(t.headers||(t.headers={}),_c(t.headers,e)):t.url=Cc(t.url,e)}getObjectType(t){const{type:e}=t;return"subtitle"===e?Yl.TIMED_TEXT:"initSegment"===t.sn?Yl.INIT:"audio"===e?Yl.AUDIO:"main"===e?this.hls.audioTracks.length?Yl.VIDEO:Yl.MUXED:void 0}getTopBandwidth(t){let e,i=0;const n=this.hls;if(t===Yl.AUDIO)e=n.audioTracks;else{const t=n.maxAutoLevel,i=t>-1?t+1:n.levels.length;e=n.levels.slice(0,i)}for(const t of e)t.bitrate>i&&(i=t.bitrate);return i>0?i:NaN}getBufferLength(t){const e=this.hls.media,i=t===Yl.AUDIO?this.audioBuffer:this.videoBuffer;if(!i||!e)return NaN;return 1e3*ea.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,i=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new i(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,i,n){e(t),this.loader.load(t,i,n)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new i(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,i,n){e(t),this.loader.load(t,i,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=Oi.log.bind(Oi,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.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:i}=e;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:i}=e;if((null==i?void 0:i.action)===Rs&&i.flags===Ds){const t=this.levels;let n=this.pathwayPriority,r=this.pathwayId;if(e.context){const{groupId:i,pathwayId:n,type:s}=e.context;i&&t?r=this.getPathwayForGroupId(i,s,r):n&&(r=n)}r in this.penalizedPathways||(this.penalizedPathways[r]=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),i.resolved=this.pathwayId!==r),i.resolved||Oi.warn(`Could not resolve ${e.details} ("${e.error.message}") with content-steering for Pathway: ${r} 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 i=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),e=this.getLevelsForPathway(i),this.pathwayId=i}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return null===this.levels?[]:this.levels.filter((e=>t===e.pathwayId))}updatePathwayPriority(t){let e;this.pathwayPriority=t;const i=this.penalizedPathways,n=performance.now();Object.keys(i).forEach((t=>{n-i[t]>3e5&&delete i[t]}));for(let n=0;n<t.length;n++){const r=t[n];if(r in i)continue;if(r===this.pathwayId)return;const s=this.hls.nextLoadLevel,a=this.hls.levels[s];if(e=this.getLevelsForPathway(r),e.length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,ms(e),this.hls.trigger(Li.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,i){const n=this.getLevelsForPathway(i).concat(this.levels||[]);for(let i=0;i<n.length;i++)if(e===Pr&&n[i].hasAudioGroup(t)||e===Or&&n[i].hasSubtitleGroup(t))return n[i].pathwayId;return i}clonePathways(t){const e=this.levels;if(!e)return;const i={},n={};t.forEach((t=>{const{ID:r,"BASE-ID":s,"URI-REPLACEMENT":a}=t;if(e.some((t=>t.pathwayId===r)))return;const o=this.getLevelsForPathway(s).map((t=>{const e=new Mi(t.attrs);e["PATHWAY-ID"]=r;const s=e.AUDIO&&`${e.AUDIO}_clone_${r}`,o=e.SUBTITLES&&`${e.SUBTITLES}_clone_${r}`;s&&(i[e.AUDIO]=s,e.AUDIO=s),o&&(n[e.SUBTITLES]=o,e.SUBTITLES=o);const l=Ic(t.uri,e["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),c=new os({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<t.audioGroups.length;e++)c.addGroupId("audio",`${t.audioGroups[e]}_clone_${r}`);if(t.subtitleGroups)for(let e=1;e<t.subtitleGroups.length;e++)c.addGroupId("text",`${t.subtitleGroups[e]}_clone_${r}`);return c}));e.push(...o),wc(this.audioTracks,i,a,r),wc(this.subtitleTracks,n,a,r)}))}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;let n;this.loader&&this.loader.destroy(),this.loader=new i(e);try{n=new self.URL(t)}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${t}`)}if("data:"!==n.protocol){const t=0|(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate);n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+t)}const r={responseType:"json",url:n.href},s=e.steeringManifestLoadPolicy.default,a=s.errorRetry||s.timeoutRetry||{},o={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(t,e,i,r)=>{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||i.url),o&&this.clonePathways(o);const c={steeringManifest:s,url:n.toString()};this.hls.trigger(Li.STEERING_MANIFEST_LOADED,c),l&&this.updatePathwayPriority(l)},onError:(t,e,i,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 r=1e3*this.timeToLoad;if(429!==t.code)this.scheduleRefresh(this.uri||e.url,r);else{const t=this.loader;if("function"==typeof(null==t?void 0:t.getResponseHeader)){const e=t.getResponseHeader("Retry-After");e&&(r=1e3*parseFloat(e))}this.log(`Steering manifest ${e.url} rate limited`)}},onTimeout:(t,e,i)=>{this.log(`Timeout loading steering manifest (${e.url})`),this.scheduleRefresh(this.uri||e.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(r,o,l)}scheduleRefresh(t,e=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout((()=>{var e;const i=null==(e=this.hls)?void 0:e.media;!i||i.ended?this.scheduleRefresh(t,1e3*this.timeToLoad):this.loadSteeringManifest(t)}),e)}}});function $c(t){return t&&"object"==typeof t?Array.isArray(t)?t.map($c):Object.keys(t).reduce(((e,i)=>(e[i]=$c(t[i]),e)),{}):t}function Gc(t){const e=t.loader;if(e!==xc&&e!==Pc)Oi.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=xc,t.progressive=!0,t.enableSoftwareAES=!0,Oi.log("[config]: Progressive streaming enabled, using FetchLoader"))}}let Vc;class Kc extends Os{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(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.on(Li.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this),t.off(Li.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 i=this.hls.config.preferManagedMediaSource,n=[],r={},s={};let a=!1,o=!1,l=!1;e.levels.forEach((t=>{var e,c;const h=t.attrs;let{audioCodec:u,videoCodec:d}=t;-1!==(null==(e=u)?void 0:e.indexOf("mp4a.40.34"))&&(Vc||(Vc=/chrome|firefox/i.test(navigator.userAgent)),Vc&&(t.audioCodec=u=void 0)),u&&(t.audioCodec=u=pr(u,i)),0===(null==(c=d)?void 0:c.indexOf("avc1"))&&(d=t.videoCodec=function(t){const e=t.split(",");for(let t=0;t<e.length;t++){const i=e[t].split(".");if(i.length>2){let n=i.shift()+".";n+=parseInt(i.shift()).toString(16),n+=("000"+parseInt(i.shift()).toString(16)).slice(-4),e[t]=n}}return e.join(",")}(d));const{width:f,height:g,unknownCodecs:p}=t;if(a||(a=!(!f||!g)),o||(o=!!d),l||(l=!!u),null!=p&&p.length||u&&!lr(u,"audio",i)||d&&!lr(d,"video",i))return;const{CODECS:m,"FRAME-RATE":v,"HDCP-LEVEL":y,"PATHWAY-ID":A,RESOLUTION:E,"VIDEO-RANGE":T}=h,b=`${`${A||"."}-`}${t.bitrate}-${E}-${v}-${m}-${T}-${y}`;if(r[b])if(r[b].uri===t.url||t.attrs["PATHWAY-ID"])r[b].addGroupId("audio",h.AUDIO),r[b].addGroupId("text",h.SUBTITLES);else{const e=s[b]+=1;t.attrs["PATHWAY-ID"]=new Array(e+1).join(".");const i=new os(t);r[b]=i,n.push(i)}else{const e=new os(t);r[b]=e,s[b]=1,n.push(e)}})),this.filterAndSortMediaOptions(n,e,a,o,l)}filterAndSortMediaOptions(t,e,i,n,r){let s=[],a=[],o=t;if((i||n)&&r&&(o=o.filter((({videoCodec:t,videoRange:e,width:i,height:n})=>{return(!!t||!(!i||!n))&&(!!(r=e)&&es.indexOf(r)>-1);var r}))),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(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.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||lr(e.audioCodec,"audio",t))),Hc(s)}e.subtitles&&(a=e.subtitles,Hc(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(i&&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 es.indexOf(t.videoRange)-es.indexOf(e.videoRange);if(t.videoCodec!==e.videoCodec){const i=ur(t.videoCodec),n=ur(e.videoCodec);if(i!==n)return n-i}if(t.uri===e.uri&&t.codecSet!==e.codecSet){const i=dr(t.codecSet),n=dr(e.codecSet);if(i!==n)return n-i}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;t<l.length;t++)if(l[t].pathwayId===o[0].pathwayId){c=l[t];break}this._levels=o;for(let t=0;t<o.length;t++)if(o[t]===c){var h;this._firstLevel=t;const e=c.bitrate,i=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${o.length} level(s) found, first bitrate: ${e}`),void 0===(null==(h=this.hls.userConfig)?void 0:h.abrEwmaDefaultEstimate)){const t=Math.min(e,this.hls.config.abrEwmaDefaultEstimateMax);t>i&&i===Uc.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=t)}break}const u=r&&!n,d={levels:o,audioTracks:s,subtitleTracks:a,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:r,video:n,altAudio:!u&&s.some((t=>!!t.url))};this.hls.trigger(Li.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 i=new Error("invalid level idx"),n=t<0;if(this.hls.trigger(Li.ERROR,{type:Ri.OTHER_ERROR,details:Ci.LEVEL_SWITCH_ERROR,level:t,fatal:n,error:i,reason:i.message}),n)return;t=Math.min(t,e.length-1)}const i=this.currentLevelIndex,n=this.currentLevel,r=n?n.attrs["PATHWAY-ID"]:void 0,s=e[t],a=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=s,i===t&&s.details&&n&&r===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 ${i}${r?" with Pathway "+r:""}`);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(Li.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===Dr&&e.context.level===this.level&&this.checkRetry(e)}onFragBuffered(t,{frag:e}){if(void 0!==e&&e.type===xr){const t=e.elementaryStreams;if(!Object.keys(t).some((e=>!!t[e])))return;const i=this._levels[e.level];null!=i&&i.loadError&&(this.log(`Resetting level error count of ${i.loadError} on frag buffered`),i.loadError=0)}}onLevelLoaded(t,e){var i;const{level:n,details:r}=e,s=this._levels[n];var a;if(!s)return this.warn(`Invalid level index ${n}`),void(null!=(a=e.deliveryDirectives)&&a.skip&&(r.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(n,e,s.details)):null!=(i=e.deliveryDirectives)&&i.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){let n=i.uri;if(t)try{n=t.addDirectives(n)}catch(t){this.warn(`Could not construct new URL with HLS Delivery Directives: ${t}`)}const r=i.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${r?" Pathway "+r:""} ${n}`),this.clearTimer(),this.hls.trigger(Li.LEVEL_LOADING,{url:n,level:e,pathwayId:i.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 i=this._levels.filter(((e,i)=>i!==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)));ms(i),this._levels=i,this.currentLevelIndex>-1&&null!=(e=this.currentLevel)&&e.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(Li.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(t,{levels:e}){this._levels=e}checkMaxAutoUpdated(){const{autoLevelCapping:t,maxAutoLevel:e,maxHdcpLevel:i}=this.hls;this._maxAutoLevel!==e&&(this._maxAutoLevel=e,this.hls.trigger(Li.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:e,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))}}function Hc(t){const e={};t.forEach((t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++}))}class Yc{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const i in this.keyUriToKeyInfo){const n=this.keyUriToKeyInfo[i].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=Ci.KEY_LOAD_ERROR,i,n,r){return new da({type:Ri.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:r,error:i,networkDetails:n})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:n}=t;for(let t=0;t<e.length;t++){const r=e[t];if(n<=r.cc&&("initSegment"===i||"initSegment"===r.sn||i<r.sn)){this.emeController.selectKeySystemFormat(r).then((t=>{r.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 i,n;e&&t.setKeyFormat(e);const r=t.decryptdata;if(!r){const i=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,Ci.KEY_LOAD_ERROR,i))}const s=r.uri;if(!s)return Promise.reject(this.createKeyLoadError(t,Ci.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));let a=this.keyUriToKeyInfo[s];if(null!=(i=a)&&i.decryptdata.key)return r.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=>(r.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:a})))}switch(a=this.keyUriToKeyInfo[s]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(a,t):this.loadKeyEME(a,t);case"AES-128":return this.loadKeyHTTP(a,t);default:return Promise.reject(this.createKeyLoadError(t,Ci.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(t,e){const i={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const e=this.emeController.loadKey(i);if(e)return(t.keyLoadPromise=e.then((e=>(t.mediaKeySessionContext=e,i)))).catch((e=>{throw t.keyLoadPromise=null,e}))}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,n=new(0,i.loader)(i);return e.keyLoader=t.loader=n,t.keyLoadPromise=new Promise(((r,s)=>{const a={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},o=i.keyLoadPolicy.default,l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,e,i,n)=>{const{frag:a,keyInfo:o,url:l}=i;if(!a.decryptdata||o!==this.keyUriToKeyInfo[l])return s(this.createKeyLoadError(a,Ci.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,r({frag:a,keyInfo:o})},onError:(t,i,n,r)=>{this.resetLoader(i),s(this.createKeyLoadError(e,Ci.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key ${t.text}`),n,Ai({url:a.url,data:void 0},t)))},onTimeout:(t,i,n)=>{this.resetLoader(i),s(this.createKeyLoadError(e,Ci.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:(t,i,n)=>{this.resetLoader(i),s(this.createKeyLoadError(e,Ci.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};n.load(a,l,c)}))}resetLoader(t){const{frag:e,keyInfo:i,url:n}=t,r=i.loader;e.keyLoader===r&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],r&&r.destroy()}}function jc(){return self.SourceBuffer||self.WebKitSourceBuffer}function Wc(){if(!ar())return!1;const t=jc();return!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove}class zc{constructor(t,e,i,n){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=i,this.hls=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:i,media:n,stalled:r}=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!==r){if(this.stallReported){const t=self.performance.now()-r;Oi.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||!ea.getBuffered(n).length)return void(this.nudgeRetry=0);const c=ea.bufferInfo(n,s,0),h=c.nextStart||0;if(a){const t=c.len>2,i=!h||e&&e.start<=s||h-s>2&&!this.fragmentTracker.getPartialFragment(s);if(t||i)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var u;if(!(c.len>0)&&!h)return;const t=Math.max(h,c.start||0)-s,e=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,i=(null==e||null==(u=e.details)?void 0:u.live)?2*e.details.targetduration:2,r=this.fragmentTracker.getPartialFragment(s);if(t>0&&(t<=i||r))return void(n.paused||this._trySkipBufferHole(r))}const d=self.performance.now();if(null===r)return void(this.stalled=d);const f=d-r;if(!a&&f>=250&&(this._reportStall(c),!this.media))return;const g=ea.bufferInfo(n,s,i.maxBufferHole);this._tryFixBufferStall(g,f)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:n,media:r}=this;if(null===r)return;const s=r.currentTime,a=n.getPartialFragment(s);if(a){if(this._trySkipBufferHole(a)||!this.media)return}(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-s<i.maxBufferHole)&&e>1e3*i.highBufferWatchdogPeriod&&(Oi.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:i,stallReported:n}=this;if(!n&&i){this.stallReported=!0;const n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);Oi.warn(n.message),e.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:n}=this;if(null===n)return 0;const r=n.currentTime,s=ea.bufferInfo(n,r,0),a=r<s.start?s.start:s.nextStart;if(a){const o=s.len<=e.maxBufferHole,l=s.len>0&&s.len<1&&n.readyState<3,c=a-r;if(c>0&&(o||l)){if(c>e.maxBufferHole){const{fragmentTracker:e}=this;let i=!1;if(0===r){const t=e.getAppendedFrag(0,xr);t&&a<t.end&&(i=!0)}if(!i){const i=t||e.getAppendedFrag(r,xr);if(i){let t=!1,n=i.end;for(;n<a;){const i=e.getPartialFragment(n);if(!i){t=!0;break}n+=i.duration}if(t)return 0}}}const s=Math.max(a+.05,r+.1);if(Oi.warn(`skipping hole, adjusting currentTime from ${r} to ${s}`),this.moved=!0,this.stalled=null,n.currentTime=s,t&&!t.gap){const e=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${s}`);i.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:e,reason:e.message,frag:t})}return s}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:i,nudgeRetry:n}=this;if(null===i)return;const r=i.currentTime;if(this.nudgeRetry++,n<t.nudgeMaxRetry){const s=r+(n+1)*t.nudgeOffset,a=new Error(`Nudging 'currentTime' from ${r} to ${s}`);Oi.warn(a.message),i.currentTime=s,e.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_NUDGE_ON_STALL,error:a,fatal:!1})}else{const i=new Error(`Playhead still not moving while enough data buffered @${r} after ${t.nudgeMaxRetry} nudges`);Oi.error(i.message),e.trigger(Li.ERROR,{type:Ri.MEDIA_ERROR,details:Ci.BUFFER_STALLED_ERROR,error:i,fatal:!0})}}}class qc extends Ia{constructor(t,e,i){super(t,e,i,"[stream-controller]",xr),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.on(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.on(Li.LEVEL_LOADING,this.onLevelLoading,this),t.on(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.on(Li.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(Li.ERROR,this.onError,this),t.on(Li.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(Li.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(Li.BUFFER_CREATED,this.onBufferCreated,this),t.on(Li.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(Li.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(Li.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(Li.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(Li.MANIFEST_LOADING,this.onManifestLoading,this),t.off(Li.MANIFEST_PARSED,this.onManifestParsed,this),t.off(Li.LEVEL_LOADED,this.onLevelLoaded,this),t.off(Li.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(Li.ERROR,this.onError,this),t.off(Li.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(Li.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(Li.BUFFER_CREATED,this.onBufferCreated,this),t.off(Li.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(Li.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(Li.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(t){if(this.levels){const{lastCurrentTime:e,hls:i}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let t=i.startLevel;-1===t&&(i.config.testBandwidth&&this.levels.length>1?(t=0,this.bitrateTest=!0):t=i.firstAutoLevel),i.nextLoadLevel=t,this.level=i.loadLevel,this.loadedmetadata=!1}e>0&&-1===t&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=Aa,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=ya}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case wa:{const{levels:t,level:e}=this,i=null==t?void 0:t[e],n=null==i?void 0:i.details;if(n&&(!n.live||this.levelLastLoaded===i)){if(this.waitForCdnTuneIn(n))break;this.state=Aa;break}if(this.hls.nextLoadLevel!==this.level){this.state=Aa;break}break}case ba:{var t;const e=self.performance.now(),i=this.retryDate;if(!i||e>=i||null!=(t=this.media)&&t.seeking){const{levels:t,level:e}=this,i=null==t?void 0:t[e];this.resetStartWhenNotLoaded(i||null),this.state=Aa}}}this.state===Aa&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:n}=this;if(null===e||!n&&(this.startFragRequested||!t.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const r=t.nextLoadLevel;if(null==i||!i[r])return;const s=i[r],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(Li.BUFFER_EOS,t),void(this.state=La)}t.loadLevel!==r&&-1===t.manualLevel&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=t.nextLoadLevel=r;const l=s.details;if(!l||this.state===wa||l.live&&this.levelLastLoaded!==s)return this.level=r,void(this.state=wa);const c=a.len,h=this.getMaxBufferLength(s.maxBitrate);if(c>=h)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const u=this.backtrackFragment?this.backtrackFragment.start:a.end;let d=this.getNextFragment(u,l);if(this.couldBacktrack&&!this.fragPrevious&&d&&"initSegment"!==d.sn&&this.fragmentTracker.getState(d)!==Xs){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,u)){if(!d.gap){const t=this.audioOnly&&!this.altAudio?$i:Gi,e=(t===Gi?this.videoBuffer:this.mediaBuffer)||this.media;e&&this.afterBufferFlushed(e,t,xr)}d=this.getNextFragmentLoopLoading(d,l,a,xr,h)}d&&(!d.initSegment||d.initSegment.data||this.bitrateTest||(d=d.initSegment),this.loadFragment(d,s,u))}loadFragment(t,e,i){const n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===Ws||n===qs?"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,i)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,xr)}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 i;const n=this.getAppendedFrag(e.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);const r=this.getLevelDetails();if(null!=r&&r.live){const t=this.getMainFwdBufferInfo();if(!t||t.len<2*r.targetduration)return}if(!e.paused&&t){const e=t[this.hls.nextLoadLevel],n=this.fragLastKbps;i=n&&this.fragCurrent?this.fragCurrent.duration*e.maxBitrate/(1e3*n)+1:0}else i=0;const s=this.getBufferedFrag(e.currentTime+i);if(s){const t=this.followingBufferedFrag(s);if(t){this.abortCurrentFrag();const e=t.maxStartPTS?t.maxStartPTS:t.start,i=t.duration,n=Math.max(s.end,e+Math.min(Math.max(i-this.config.maxFragLookUpTolerance,i*(this.couldBacktrack?.5:.125)),i*(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 Ea:case Ta:case ba:case Sa:case _a:this.state=Aa}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const i=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new zc(this.config,i,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;ki(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const i=this.getMainFwdBufferInfo();null!==i&&0!==i.len?this.tick():this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`)}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(Li.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 i=!1,n=!1;e.levels.forEach((t=>{const e=t.audioCodec;e&&(i=i||-1!==e.indexOf("mp4a.40.2"),n=n||-1!==e.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=i&&n&&!function(){var t;const e=jc();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:i}=this;if(!i||this.state!==Aa)return;const n=i[e.level];(!n.details||n.details.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(n.details))&&(this.state=wa)}onLevelLoaded(t,e){var i;const{levels:n}=this,r=e.level,s=e.details,a=s.totalduration;if(!n)return void this.warn(`Levels were reset while loading level ${r}`);this.log(`Level ${r} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""}, cc [${s.startCC}, ${s.endCC}] duration:${a}`);const o=n[r],l=this.fragCurrent;!l||this.state!==Ta&&this.state!==ba||l.level!==e.level&&l.loader&&this.abortCurrentFrag();let c=0;if(s.live||null!=(i=o.details)&&i.live){var h;if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;c=this.alignPlaylists(s,o.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(o.details=s,this.levelLastLoaded=o,this.hls.trigger(Li.LEVEL_UPDATED,{details:s,level:r}),this.state===wa){if(this.waitForCdnTuneIn(s))return;this.state=Aa}this.startFragRequested?s.live&&this.synchronizeToLiveEdge(s):this.setStartPosition(s,c),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,payload:r}=t,{levels:s}=this;if(!s)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);const a=s[i.level],o=a.details;if(!o)return this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),void this.fragmentTracker.removeFragment(i);const l=a.videoCodec,c=o.PTSKnown||!o.live,h=null==(e=i.initSegment)?void 0:e.data,u=this._getAudioCodec(a),d=this.transmuxer=this.transmuxer||new Uo(this.hls,xr,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=n?n.index:-1,g=-1!==f,p=new ia(i.level,i.sn,i.stats.chunkCount,r.byteLength,f,g),m=this.initPTS[i.cc];d.push(r,h,u,l,i,n,o.totalduration,c,p,m)}onAudioTrackSwitching(t,e){const i=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;i&&(t.trigger(Li.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),t.trigger(Li.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,n=!!this.hls.audioTracks[i].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 i=e.tracks;let n,r,s=!1;for(const t in i){const e=i[t];if("main"===e.id){if(r=t,n=e,"video"===t){const e=i[t];e&&(this.videoBuffer=e.buffer)}}else s=!0}s&&n?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:n}=e;if(i&&i.type!==xr)return;if(this.fragContextChanged(i))return this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===_a&&(this.state=Aa));const r=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),"initSegment"!==i.sn&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}onError(t,e){var i;if(e.fatal)this.state=Ra;else switch(e.details){case Ci.FRAG_GAP:case Ci.FRAG_PARSING_ERROR:case Ci.FRAG_DECRYPT_ERROR:case Ci.FRAG_LOAD_ERROR:case Ci.FRAG_LOAD_TIMEOUT:case Ci.KEY_LOAD_ERROR:case Ci.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(xr,e);break;case Ci.LEVEL_LOAD_ERROR:case Ci.LEVEL_LOAD_TIMEOUT:case Ci.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==wa||(null==(i=e.context)?void 0:i.type)!==Dr||(this.state=Aa);break;case Ci.BUFFER_APPEND_ERROR:case Ci.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;if(e.details===Ci.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case Ci.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}checkBuffer(){const{media:t,gapController:e}=this;if(t&&e&&t.readyState){if(this.loadedmetadata||!ea.getBuffered(t).length){const t=this.state!==Aa?this.fragCurrent:null;e.poll(this.lastCurrentTime,t)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=Aa,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==$i||this.audioOnly&&!this.altAudio){const t=(e===Gi?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(t,e,xr),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 i=this.startPosition;if(i>=0&&e<i){if(t.seeking)return void this.log(`could not seek to ${i}, already seeking at ${e}`);const n=ea.getBuffered(t),r=(n.length?n.start(0):0)-i;r>0&&(r<this.config.maxBufferHole||r<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${r} to match buffer start`),i+=r,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${e}`),t.currentTime=i}}_getAudioCodec(t){let e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e}_loadBitrateTestFrag(t,e){t.bitrateTest=!0,this._doFragLoad(t,e).then((i=>{const{hls:n}=this;if(!i||this.fragContextChanged(t))return;e.fragmentError=0,this.state=Aa,this.startFragRequested=!1,this.bitrateTest=!1;const r=t.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),n.trigger(Li.FRAG_LOADED,i),t.bitrateTest=!1}))}_handleTransmuxComplete(t){var e;const i="main",{hls:n}=this,{remuxResult:r,chunkMeta:s}=t,a=this.getCurrentContext(s);if(!a)return void this.resetWhenMissingContext(s);const{frag:o,part:l,level:c}=a,{video:h,text:u,id3:d,initSegment:f}=r,{details:g}=c,p=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=Sa,f){if(null!=f&&f.tracks){const t=o.initSegment||o;this._bufferInitSegment(c,f.tracks,t,s),n.trigger(Li.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:i,tracks:f.tracks})}const t=f.initPTS,e=f.timescale;ki(t)&&(this.initPTS[o.cc]={baseTime:t,timescale:e},n.trigger(Li.INIT_PTS_FOUND,{frag:o,id:i,initPTS:t,timescale:e}))}if(h&&g&&"initSegment"!==o.sn){const t=g.fragments[o.sn-1-g.startSN],e=o.sn===g.startSN,i=!t||o.cc>t.cc;if(!1!==r.independent){const{startPTS:t,endPTS:n,startDTS:r,endDTS:a}=h;if(l)l.elementaryStreams[h.type]={startPTS:t,endPTS:n,startDTS:r,endDTS:a};else if(h.firstKeyFrame&&h.independent&&1===s.id&&!i&&(this.couldBacktrack=!0),h.dropped&&h.independent){const r=this.getMainFwdBufferInfo(),s=(r?r.end:this.getLoadPosition())+this.config.maxBufferHole,l=h.firstKeyFramePTS?h.firstKeyFramePTS:t;if(!e&&s<l-this.config.maxBufferHole&&!i)return void this.backtrack(o);i&&(o.gap=!0),o.setElementaryStreamInfo(h.type,o.start,n,o.start,a,!0)}else e&&t>2&&(o.gap=!0);o.setElementaryStreamInfo(h.type,t,n,r,a),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,l,s,e||i)}else{if(!e&&!i)return void this.backtrack(o);o.gap=!0}}if(p){const{startPTS:t,endPTS:e,startDTS:i,endDTS:n}=p;l&&(l.elementaryStreams[$i]={startPTS:t,endPTS:e,startDTS:i,endDTS:n}),o.setElementaryStreamInfo($i,t,e,i,n),this.bufferFragmentData(p,o,l,s)}if(g&&null!=d&&null!=(e=d.samples)&&e.length){const t={id:i,frag:o,details:g,samples:d.samples};n.trigger(Li.FRAG_PARSING_METADATA,t)}if(g&&u){const t={id:i,frag:o,details:g,samples:u.samples};n.trigger(Li.FRAG_PARSING_USERDATA,t)}}}_bufferInitSegment(t,e,i,n){if(this.state!==Sa)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:r,video:s,audiovideo:a}=e;if(r){let e=t.audioCodec;const i=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){e&&(e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const t=r.metadata;t&&"channelCount"in t&&1!==(t.channelCount||1)&&-1===i.indexOf("firefox")&&(e="mp4a.40.5")}e&&-1!==e.indexOf("mp4a.40.5")&&-1!==i.indexOf("android")&&"audio/mpeg"!==r.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}"`),r.levelCodec=e,r.id="main",this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${e||""}/${t.audioCodec||""}/${r.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(Li.BUFFER_CODECS,e),Object.keys(e).forEach((t=>{const r=e[t].initSegment;null!=r&&r.byteLength&&this.hls.trigger(Li.BUFFER_APPENDING,{type:t,data:r,frag:i,part:null,chunkMeta:n,parent:i.type})})),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,xr)}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=Aa}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&!1===t.seeking){const i=t.currentTime;if(ea.isBuffered(t,i)?e=this.getAppendedFrag(i):ea.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const t=this.fragPlaying,i=e.level;t&&e.sn===t.sn&&t.level===i||(this.fragPlaying=e,this.hls.trigger(Li.FRAG_CHANGED,{frag:e}),t&&t.level===i||this.hls.trigger(Li.LEVEL_SWITCHED,{level:i}))}}}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,i=this.currentFrag;if(i&&ki(e)&&ki(i.programDateTime)){const t=i.programDateTime+1e3*(e-i.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 Xc{static get version(){return"1.5.14"}static isMSESupported(){return Wc()}static isSupported(){return function(){if(!Wc())return!1;const t=ar();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(hr(e,"video"))))||["mp4a.40.2","fLaC"].some((e=>t.isTypeSupported(hr(e,"audio")))))}()}static getMediaSource(){return ar()}static get Events(){return Li}static get ErrorTypes(){return Ri}static get ErrorDetails(){return Ci}static get DefaultConfig(){return Xc.defaultConfig?Xc.defaultConfig:Uc}static set DefaultConfig(t){Xc.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 Bo,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){Pi(t,"debug","log","info","warn","error");try{Di.log(`Debug logs enabled for "${e}" in hls.js version 1.5.14`)}catch(t){Di=Ii}}else Di=Ii}(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 i=$c(t),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((t=>{const r=`${"level"===t?"playlist":t}LoadPolicy`,s=void 0===e[r],a=[];n.forEach((n=>{const o=`${t}Loading${n}`,l=e[o];if(void 0!==l&&s){a.push(o);const t=i[r].default;switch(e[r]={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&&Oi.warn(`hls.js config: "${a.join('", "')}" setting(s) are deprecated, use "${r}": ${JSON.stringify(e[r])}`)})),Ai(Ai({},i),e)}(Xc.DefaultConfig,t);this.userConfig=t,e.progressive&&Gc(e);const{abrController:i,bufferController:n,capLevelController:r,errorController:s,fpsController:a}=e,o=new s(this),l=this.abrController=new i(this),c=this.bufferController=new n(this),h=this.capLevelController=new r(this),u=new a(this),d=new Ur(this),f=new Zr(this),g=e.contentSteeringController,p=g?new g(this):null,m=this.levelController=new Kc(this,p),v=new Qs(this),y=new Yc(this.config),A=this.streamController=new qc(this,v,y);h.setStreamController(A),u.setStreamController(A);const E=[d,m,A];p&&E.splice(1,0,p),this.networkControllers=E;const T=[l,c,h,u,f,v];this.audioTrackController=this.createController(e.audioTrackController,E);const b=e.audioStreamController;b&&E.push(new b(this,v,y)),this.subtitleTrackController=this.createController(e.subtitleTrackController,E);const k=e.subtitleStreamController;k&&E.push(new k(this,v,y)),this.createController(e.timelineController,T),y.emeController=this.emeController=this.createController(e.emeController,T),this.cmcdController=this.createController(e.cmcdController,T),this.latencyController=this.createController(Jr,T),this.coreComponents=T,E.push(o);const S=o.onErrorOut;"function"==typeof S&&this.on(Li.ERROR,S,o)}createController(t,e){if(t){const i=new t(this);return e&&e.push(i),i}return null}on(t,e,i=this){this._emitter.on(t,e,i)}once(t,e,i=this){this._emitter.once(t,e,i)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,i=this,n){this._emitter.off(t,e,i,n)}listeners(t){return this._emitter.listeners(t)}emit(t,e,i){return this._emitter.emit(t,e,i)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){if(Oi.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),!this.triggeringException){this.triggeringException=!0;const i=t===Li.ERROR;this.trigger(Li.ERROR,{type:Ri.OTHER_ERROR,details:Ci.INTERNAL_EXCEPTION,fatal:i,event:t,error:e}),this.triggeringException=!1}}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){Oi.log("destroy"),this.trigger(Li.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){Oi.log("attachMedia"),this._media=t,this.trigger(Li.MEDIA_ATTACHING,{media:t})}detachMedia(){Oi.log("detachMedia"),this.trigger(Li.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,n=this.url=vi.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,Oi.log(`loadSource:${n}`),e&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(Li.MANIFEST_LOADING,{url:t})}startLoad(t=-1){Oi.log(`startLoad(${t})`),this.started=!0,this.networkControllers.forEach((e=>{e.startLoad(t)}))}stopLoad(){Oi.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(){Oi.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){Oi.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){Oi.log(`set currentLevel:${t}`),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){Oi.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){Oi.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){Oi.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){Oi.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&&(Oi.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){(function(t){return ts.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 i=t.length;for(let n=0;n<i;n++)if(t[n].maxBitrate>=e)return n;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let n;if(n=-1===e&&null!=t&&t.length?t.length-1:e,i)for(let e=n;e--;){const n=t[e].attrs["HDCP-LEVEL"];if(n&&n<=i)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}}Xc.defaultConfig=void 0;var Qc=Z.now,Zc=Z.listContainsIgnoreCase;ct.register("PLAYBACK_FRAGMENT_CHANGED"),ct.register("PLAYBACK_FRAGMENT_PARSING_METADATA");var Jc=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ni(t,e)}(s,t);var e,i,n,r=si(s);function s(){var t;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s);for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return(t=r.call.apply(r,[this].concat(i))).options.hlsPlayback=Je(Je({},t.defaultOptions),t.options.hlsPlayback),t._timeUpdateThrottleDelay=200,t._timeUpdateFiringRate=.2,t._durationChangeMinOffset=.5,t._setInitialState(),t}return e=s,i=[{key:"name",get:function(){return"hls"}},{key:"supportedVersion",get:function(){return{min:"0.11.2"}}},{key:"levels",get:function(){return this._levels||[]}},{key:"currentLevel",get:function(){return null===this._currentLevel||void 0===this._currentLevel?-1:this._currentLevel},set:function(t){this._currentLevel=t,this.trigger(ct.PLAYBACK_LEVEL_SWITCH_START),this.options.playback.hlsUseNextLevel?this._hls.nextLevel=this._currentLevel:this._hls.currentLevel=this._currentLevel}},{key:"isReady",get:function(){return this._isReadyState}},{key:"latency",get:function(){return this._hls.latency}},{key:"currentProgramDateTime",get:function(){return this._hls.playingDate}},{key:"_startTime",get:function(){return this._playbackType===Rt.LIVE&&"EVENT"!==this._playlistType?this._extrapolatedStartTime:this._playableRegionStartTime}},{key:"_now",get:function(){return Qc()}},{key:"_extrapolatedStartTime",get:function(){if(!this._localStartTimeCorrelation)return this._playableRegionStartTime;var t=this._localStartTimeCorrelation,e=this._now-t.local,i=(t.remote+e)/1e3;return Math.min(i,this._playableRegionStartTime+this._extrapolatedWindowDuration)}},{key:"_extrapolatedEndTime",get:function(){var t=this._playableRegionStartTime+this._playableRegionDuration;if(!this._localEndTimeCorrelation)return t;var e=this._localEndTimeCorrelation,i=this._now-e.local,n=(e.remote+i)/1e3;return Math.max(t-this._extrapolatedWindowDuration,Math.min(n,t))}},{key:"_duration",get:function(){return this._extrapolatedEndTime-this._startTime}},{key:"_extrapolatedWindowDuration",get:function(){return null===this._segmentTargetDuration?0:this._extrapolatedWindowNumSegments*this._segmentTargetDuration}},{key:"bandwidthEstimate",get:function(){return this._hls&&this._hls.bandwidthEstimate}},{key:"defaultOptions",get:function(){return{preload:!0}}},{key:"customListeners",get:function(){return this.options.hlsPlayback&&this.options.hlsPlayback.customListeners||[]}},{key:"sourceMedia",get:function(){return this.options.src}},{key:"currentTimestamp",get:function(){return this._currentFragment?(this._currentFragment.programDateTime+1e3*(this.el.currentTime-this._currentFragment.start))/1e3:null}},{key:"_setInitialState",value:function(){this._minDvrSize=void 0===this.options.hlsMinimumDvrSize?60:this.options.hlsMinimumDvrSize,this._extrapolatedWindowNumSegments=this.options.playback&&void 0!==this.options.playback.extrapolatedWindowNumSegments?this.options.playback.extrapolatedWindowNumSegments:2,this._playbackType=Rt.VOD,this._lastTimeUpdate={current:0,total:0,firstFragDateTime:0},this._lastTimeUpdateFiredTime=0,this._lastDuration=null,this._playableRegionStartTime=0,this._localStartTimeCorrelation=null,this._localEndTimeCorrelation=null,this._playableRegionDuration=0,this._programDateTime=0,this._durationExcludesAfterLiveSyncPoint=!1,this._segmentTargetDuration=null,this._playlistType=null,this._recoverAttemptsRemaining=this.options.hlsRecoverAttempts||16}},{key:"_setup",value:function(){this._destroyHLSInstance(),this._createHLSInstance(),this._listenHLSEvents(),this._attachHLSMedia()}},{key:"_destroyHLSInstance",value:function(){this._hls&&(this._manifestLoading=!1,this._ccIsSetup=!1,this._ccTracksUpdated=!1,this._setInitialState(),this._hls.destroy(),this._hls=null)}},{key:"_createHLSInstance",value:function(){var t=Je({},this.options.playback.hlsjsConfig);this._hls=new Xc(t)}},{key:"_attachHLSMedia",value:function(){this._hls&&this._hls.attachMedia(this.el)}},{key:"_listenHLSEvents",value:function(){var t=this;this._hls&&(this._hls.once(Xc.Events.MEDIA_ATTACHED,(function(){t.options.hlsPlayback.preload&&t._hls.loadSource(t.options.src)})),this._hls.on(Xc.Events.MANIFEST_LOADING,(function(){return t._manifestLoading=!0})),this._hls.on(Xc.Events.LEVEL_LOADED,(function(e,i){return t._updatePlaybackType(e,i)})),this._hls.on(Xc.Events.LEVEL_UPDATED,(function(e,i){return t._onLevelUpdated(e,i)})),this._hls.on(Xc.Events.LEVEL_SWITCHED,(function(e,i){return t._onLevelSwitch(e,i)})),this._hls.on(Xc.Events.FRAG_CHANGED,(function(e,i){return t._onFragmentChanged(e,i)})),this._hls.on(Xc.Events.FRAG_LOADED,(function(e,i){return t._onFragmentLoaded(e,i)})),this._hls.on(Xc.Events.FRAG_BUFFERED,(function(e,i){return t._onFragmentBuffered(e,i)})),this._hls.on(Xc.Events.FRAG_PARSING_METADATA,(function(e,i){return t._onFragmentParsingMetadata(e,i)})),this._hls.on(Xc.Events.ERROR,(function(e,i){return t._onHLSJSError(e,i)})),this._hls.on(Xc.Events.SUBTITLE_TRACK_LOADED,(function(e,i){return t._onSubtitleLoaded(e,i)})),this._hls.on(Xc.Events.SUBTITLE_TRACKS_UPDATED,(function(){return t._ccTracksUpdated=!0})),this.bindCustomListeners())}},{key:"bindCustomListeners",value:function(){var t=this;this.customListeners.forEach((function(e){var i=e.eventName,n=e.once?"once":"on";i&&t._hls["".concat(n)](i,e.callback)}))}},{key:"unbindCustomListeners",value:function(){var t=this;this.customListeners.forEach((function(e){var i=e.eventName;i&&t._hls.off(i,e.callback)}))}},{key:"_onFragmentParsingMetadata",value:function(t,e){this.trigger(ct.Custom.PLAYBACK_FRAGMENT_PARSING_METADATA,{evt:t,data:e})}},{key:"render",value:function(){return this._ready(),ai(ii(s.prototype),"render",this).call(this)}},{key:"_ready",value:function(){this._isReadyState||(!this._hls&&this._setup(),this._isReadyState=!0,this.trigger(ct.PLAYBACK_READY,this.name))}},{key:"_recover",value:function(t,e,i){if(this._recoveredDecodingError)if(this._recoveredAudioCodecError){rt.error("hlsjs: failed to recover",{evt:t,data:e}),i.level=kt.Levels.FATAL;var n=this.createError(i);this.trigger(ct.PLAYBACK_ERROR,n),this.stop()}else this._recoveredAudioCodecError=!0,this._hls.swapAudioCodec(),this._hls.recoverMediaError(),this.play();else this._recoveredDecodingError=!0,this._hls.recoverMediaError(),this.play()}},{key:"_setupSrc",value:function(t){}},{key:"_startTimeUpdateTimer",value:function(){var t=this;this._timeUpdateTimer||(this._timeUpdateTimer=setInterval((function(){t._onDurationChange(),t._onTimeUpdate()}),100))}},{key:"_stopTimeUpdateTimer",value:function(){this._timeUpdateTimer&&(clearInterval(this._timeUpdateTimer),this._timeUpdateTimer=null)}},{key:"getProgramDateTime",value:function(){return this._programDateTime}},{key:"getDuration",value:function(){return this._duration}},{key:"getCurrentTime",value:function(){return Math.max(0,this.el.currentTime-this._startTime)}},{key:"getStartTimeOffset",value:function(){return this._startTime}},{key:"seekPercentage",value:function(t){var e=t>0?this._duration*(t/100):this._duration;this.seek(e)}},{key:"seek",value:function(t){t<0&&(rt.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),t=this.getDuration()),t+=this._startTime,this.el.currentTime=t}},{key:"seekToLivePoint",value:function(){this.seek(this.getDuration())}},{key:"_updateSettings",value:function(){this._playbackType===Rt.VOD?this.settings.left=["playpause","position","duration"]:this.dvrEnabled?this.settings.left=["playpause"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(ct.PLAYBACK_SETTINGSUPDATE)}},{key:"_onHLSJSError",value:function(t,e){var i,n={code:"".concat(e.type,"_").concat(e.details),description:"".concat(this.name," error: type: ").concat(e.type,", details: ").concat(e.details),raw:e};if(e.response&&(n.description+=", response: ".concat(JSON.stringify(e.response))),e.fatal)if(this._recoverAttemptsRemaining>0)switch(this._recoverAttemptsRemaining-=1,e.type){case Xc.ErrorTypes.NETWORK_ERROR:switch(e.details){case Xc.ErrorDetails.MANIFEST_LOAD_ERROR:case Xc.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case Xc.ErrorDetails.MANIFEST_PARSING_ERROR:case Xc.ErrorDetails.LEVEL_LOAD_ERROR:case Xc.ErrorDetails.LEVEL_LOAD_TIMEOUT:rt.error("hlsjs: unrecoverable network fatal error.",{evt:t,data:e}),i=this.createError(n),this.trigger(ct.PLAYBACK_ERROR,i),this.stop();break;default:rt.warn("hlsjs: trying to recover from network error.",{evt:t,data:e}),n.level=kt.Levels.WARN,this._hls.startLoad()}break;case Xc.ErrorTypes.MEDIA_ERROR:rt.warn("hlsjs: trying to recover from media error.",{evt:t,data:e}),n.level=kt.Levels.WARN,this._recover(t,e,n);break;default:rt.error("hlsjs: could not recover from error.",{evt:t,data:e}),i=this.createError(n),this.trigger(ct.PLAYBACK_ERROR,i),this.stop()}else rt.error("hlsjs: could not recover from error after maximum number of attempts.",{evt:t,data:e}),i=this.createError(n),this.trigger(ct.PLAYBACK_ERROR,i),this.stop();else{if(this.options.playback.triggerFatalErrorOnResourceDenied&&this._keyIsDenied(e))return rt.error("hlsjs: could not load decrypt key.",{evt:t,data:e}),i=this.createError(n),this.trigger(ct.PLAYBACK_ERROR,i),void this.stop();n.level=kt.Levels.WARN,rt.warn("hlsjs: non-fatal error occurred",{evt:t,data:e})}}},{key:"_keyIsDenied",value:function(t){return t.type===Xc.ErrorTypes.NETWORK_ERROR&&t.details===Xc.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._shouldThrottleTimeUpdate(t)||(this._lastTimeUpdate=t,this._lastTimeUpdateFiredTime=this._now,this.trigger(ct.PLAYBACK_TIMEUPDATE,t,this.name))}},{key:"_shouldThrottleTimeUpdate",value:function(t){var e=Math.abs(t.current-this._lastTimeUpdate.current)<this._timeUpdateFiringRate,i=Math.abs(t.total-this._lastTimeUpdate.total)<this._durationChangeMinOffset,n=t.firstFragDateTime===this._lastTimeUpdate.firstFragDateTime,r=e&&i&&n,s=this._now-this._lastTimeUpdateFiredTime<this._timeUpdateThrottleDelay;return r&&s}},{key:"_onDurationChange",value:function(){var t=this.getDuration();Math.abs(this._lastDuration-t)<this._durationChangeMinOffset||(this._lastDuration=t,ai(ii(s.prototype),"_onDurationChange",this).call(this))}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var t=[],e=0,i=0;i<this.el.buffered.length;i++)t=[].concat(oi(t),[{start:Math.max(0,this.el.buffered.start(i)-this._playableRegionStartTime),end:Math.max(0,this.el.buffered.end(i)-this._playableRegionStartTime)}]),this.el.currentTime>=t[i].start&&this.el.currentTime<=t[i].end&&(e=i);var n={start:t[e].start,current:t[e].end,total:this.getDuration()};this.trigger(ct.PLAYBACK_PROGRESS,n,t)}}},{key:"load",value:function(t){this._stopTimeUpdateTimer(),this.options.src=t,this._setup()}},{key:"play",value:function(){!this._hls&&this._setup(),!this._manifestLoading&&!this.options.hlsPlayback.preload&&this._hls.loadSource(this.options.src),ai(ii(s.prototype),"play",this).call(this),this._startTimeUpdateTimer()}},{key:"pause",value:function(){this._hls&&this.el.pause()}},{key:"stop",value:function(){this._stopTimeUpdateTimer(),this._hls&&ai(ii(s.prototype),"stop",this).call(this),this._destroyHLSInstance()}},{key:"destroy",value:function(){this._stopTimeUpdateTimer(),this._destroyHLSInstance(),ai(ii(s.prototype),"destroy",this).call(this)}},{key:"_updatePlaybackType",value:function(t,e){this._playbackType=e.details.live?Rt.LIVE:Rt.VOD,this._onLevelUpdated(t,e),this._ccTracksUpdated&&this._playbackType===Rt.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(ct.PLAYBACK_LEVELS_AVAILABLE,this._levels)}},{key:"_onLevelUpdated",value:function(t,e){this._segmentTargetDuration=e.details.targetduration,this._playlistType=e.details.type||null;var i=!1,n=!1,r=e.details.fragments,s=this._playableRegionStartTime,a=this._playableRegionDuration;if(0!==r.length){if(r[0].rawProgramDateTime&&(this._programDateTime=r[0].rawProgramDateTime),this._playableRegionStartTime!==r[0].start&&(i=!0,this._playableRegionStartTime=r[0].start),i)if(this._localStartTimeCorrelation){var o=this._localStartTimeCorrelation,l=this._now-o.local,c=(o.remote+l)/1e3;c<r[0].start?this._localStartTimeCorrelation={local:this._now,remote:1e3*r[0].start}:c>s+this._extrapolatedWindowDuration&&(this._localStartTimeCorrelation={local:this._now,remote:1e3*Math.max(r[0].start,s+this._extrapolatedWindowDuration)})}else this._localStartTimeCorrelation={local:this._now,remote:1e3*(r[0].start+this._extrapolatedWindowDuration/2)};var h=e.details.totalduration;if(this._playbackType===Rt.LIVE){var u=e.details.targetduration*((this.options.playback.hlsjsConfig||{}).liveSyncDurationCount||Xc.DefaultConfig.liveSyncDurationCount);u<=h?(h-=u,this._durationExcludesAfterLiveSyncPoint=!0):this._durationExcludesAfterLiveSyncPoint=!1}h!==this._playableRegionDuration&&(n=!0,this._playableRegionDuration=h);var d=r[0].start+h,f=s+a;if(d!==f)if(this._localEndTimeCorrelation){var g=this._localEndTimeCorrelation,p=this._now-g.local,m=(g.remote+p)/1e3;m>d?this._localEndTimeCorrelation={local:this._now,remote:1e3*d}:m<d-this._extrapolatedWindowDuration?this._localEndTimeCorrelation={local:this._now,remote:1e3*(d-this._extrapolatedWindowDuration)}:m>f&&(this._localEndTimeCorrelation={local:this._now,remote:1e3*f})}else this._localEndTimeCorrelation={local:this._now,remote:1e3*d};n&&this._onDurationChange(),i&&this._onProgress()}}},{key:"_onFragmentChanged",value:function(t,e){this._currentFragment=e.frag,this.trigger(ct.Custom.PLAYBACK_FRAGMENT_CHANGED,e)}},{key:"_onFragmentLoaded",value:function(t,e){this.trigger(ct.PLAYBACK_FRAGMENT_LOADED,e)}},{key:"_onFragmentBuffered",value:function(t,e){this.trigger(ct.PLAYBACK_FRAGMENT_BUFFERED,e)}},{key:"_onSubtitleLoaded",value:function(){if(!this._ccIsSetup){this.trigger(ct.PLAYBACK_SUBTITLE_AVAILABLE);var t=this._playbackType===Rt.LIVE?-1:this.closedCaptionsTrackId;this.closedCaptionsTrackId=t,this._ccIsSetup=!0}}},{key:"_onLevelSwitch",value:function(t,e){this.levels.length||this._fillLevels(),this.trigger(ct.PLAYBACK_LEVEL_SWITCH_END),this.trigger(ct.PLAYBACK_LEVEL_SWITCH,e);var i=this._hls.levels[e.level];i&&(this.highDefinition=i.height>=720||i.bitrate/1e3>=2e3,this.trigger(ct.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(ct.PLAYBACK_BITRATE,{height:i.height,width:i.width,bandwidth:i.bitrate,bitrate:i.bitrate,level:e.level}))}},{key:"dvrEnabled",get:function(){return this._durationExcludesAfterLiveSyncPoint&&this._duration>=this._minDvrSize&&this.getPlaybackType()===Rt.LIVE}},{key:"getPlaybackType",value:function(){return this._playbackType}},{key:"isSeekEnabled",value:function(){return this._playbackType===Rt.VOD||this.dvrEnabled}}],n=[{key:"HLSJS",get:function(){return Xc}}],i&&ti(e.prototype,i),n&&ti(e,n),Object.defineProperty(e,"prototype",{writable:!1}),s}(jt);return Jc.canPlay=function(t,e){var i=t.split("?")[0].match(/.*\.(.*)$/)||[],n=i.length>1&&"m3u8"===i[1].toLowerCase()||Zc(e,["application/vnd.apple.mpegurl","application/x-mpegURL"]);return!(!Xc.isSupported()||!n)},Qe.Loader.registerPlayback(Jc),e(e({},Qe),{},{HLS:Jc})}();
|
|
2
2
|
//# sourceMappingURL=clappr.min.js.map
|