live

Run Settings
LanguageJavaScript
Language Version
Run Command
var Clappr=function(){"use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function t(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?e(Object(n),!0).forEach((function(e){r(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function n(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){u(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function l(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&h(e,t)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return f(e)}function g(e){var t=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(e){return!1}}();return function(){var r,i=d(e);if(t){var n=d(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return p(this,r)}}function v(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=d(e)););return e}function m(){return m="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var i=v(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},m.apply(this,arguments)}function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var i,n,a=[],s=!0,o=!1;try{for(r=r.call(e);!(s=(i=r.next()).done)&&(a.push(i.value),!t||a.length!==t);s=!0);}catch(e){o=!0,n=e}finally{try{s||null==r.return||r.return()}finally{if(o)throw n}}return a}(e,t)||E(e,t)||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 A(e){return function(e){if(Array.isArray(e))return T(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||E(e)||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 E(e,t){if(e){if("string"==typeof e)return T(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?T(e,t):void 0}}function T(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function b(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=E(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}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 a,s=!0,o=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==r.return||r.return()}finally{if(o)throw a}}}}Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var i=arguments[1],n=0;n<r;){var a=t[n];if(e.call(i,a,n,t))return a;n++}}}),Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),r=t.length,i=new Array(r);r--;)i[r]=[t[r],e[t[r]]];return i}),Object.values||(Object.values=function(e){for(var t=Object.keys(e),r=t.length,i=new Array(r);r--;)i[r]=e[t[r]];return i}),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var r=Object(e),i=1;i<arguments.length;i++){var n=arguments[i];if(null!=n)for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(r[a]=n[a])}return r},writable:!0,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),r=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var i=arguments[1],n=0;n<r;){var a=t[n];if(e.call(i,a,n,t))return n;n++}return-1},configurable:!0,writable:!0});var k,S={mp4:"data:video/mp4;base64,AAAAHGZ0eXBpc29tAAACAGlzb21pc28ybXA0MQAAAAhmcmVlAAAC721kYXQhEAUgpBv/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3pwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcCEQBSCkG//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADengAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAsJtb292AAAAbG12aGQAAAAAAAAAAAAAAAAAAAPoAAAALwABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAB7HRyYWsAAABcdGtoZAAAAAMAAAAAAAAAAAAAAAIAAAAAAAAALwAAAAAAAAAAAAAAAQEAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAAC8AAAAAAAEAAAAAAWRtZGlhAAAAIG1kaGQAAAAAAAAAAAAAAAAAAKxEAAAIAFXEAAAAAAAtaGRscgAAAAAAAAAAc291bgAAAAAAAAAAAAAAAFNvdW5kSGFuZGxlcgAAAAEPbWluZgAAABBzbWhkAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAADTc3RibAAAAGdzdHNkAAAAAAAAAAEAAABXbXA0YQAAAAAAAAABAAAAAAAAAAAAAgAQAAAAAKxEAAAAAAAzZXNkcwAAAAADgICAIgACAASAgIAUQBUAAAAAAfQAAAHz+QWAgIACEhAGgICAAQIAAAAYc3R0cwAAAAAAAAABAAAAAgAABAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAIAAAABAAAAHHN0c3oAAAAAAAAAAAAAAAIAAAFzAAABdAAAABRzdGNvAAAAAAAAAAEAAAAsAAAAYnVkdGEAAABabWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAtaWxzdAAAACWpdG9vAAAAHWRhdGEAAAABAAAAAExhdmY1Ni40MC4xMDE="},_=function(){var e,t,r,i,n,a,s=[],o=s.concat,l=s.filter,u=s.slice,c=window.document,d={},h={},f={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},p=/^\s*<(\w+|!)[^>]*>/,g=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,m=/^(?:body|html)$/i,y=/([A-Z])/g,A=["val","css","html","text","data","width","height","offset"],E=c.createElement("table"),T=c.createElement("tr"),b={tr:c.createElement("tbody"),tbody:E,thead:E,tfoot:E,td:T,th:T,"*":c.createElement("div")},k=/complete|loaded|interactive/,S=/^[\w-]*$/,_={},C=_.toString,L={},D=c.createElement("div"),R={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(e){return e instanceof Array};function O(e){return null==e?String(e):_[C.call(e)]||"object"}function w(e){return"function"==O(e)}function P(e){return null!=e&&e==e.window}function x(e){return null!=e&&e.nodeType==e.DOCUMENT_NODE}function N(e){return"object"==O(e)}function F(e){return N(e)&&!P(e)&&Object.getPrototypeOf(e)==Object.prototype}function M(e){var t=!!e&&"length"in e&&e.length,i=r.type(e);return"function"!=i&&!P(e)&&("array"==i||0===t||"number"==typeof t&&t>0&&t-1 in e)}function B(e){return e.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(e){return e in h?h[e]:h[e]=new RegExp("(^|\\s)"+e+"(\\s|$)")}function G(e,t){return"number"!=typeof t||f[B(e)]?t:t+"px"}function V(e){return"children"in e?u.call(e.children):r.map(e.childNodes,(function(e){if(1==e.nodeType)return e}))}function K(e,t){var r,i=e?e.length:0;for(r=0;r<i;r++)this[r]=e[r];this.length=i,this.selector=t||""}function j(r,i,n){for(t in i)n&&(F(i[t])||I(i[t]))?(F(i[t])&&!F(r[t])&&(r[t]={}),I(i[t])&&!I(r[t])&&(r[t]=[]),j(r[t],i[t],n)):i[t]!==e&&(r[t]=i[t])}function H(e,t){return null==t?r(e):r(e).filter(t)}function Y(e,t,r,i){return w(t)?t.call(e,r,i):t}function W(e,t,r){null==r?e.removeAttribute(t):e.setAttribute(t,r)}function $(t,r){var i=t.className||"",n=i&&i.baseVal!==e;if(r===e)return n?i.baseVal:i;n?i.baseVal=r:t.className=r}function z(e){try{return e?"true"==e||"false"!=e&&("null"==e?null:+e+""==e?+e:/^[\[\{]/.test(e)?r.parseJSON(e):e):e}catch(t){return e}}function q(e,t){t(e);for(var r=0,i=e.childNodes.length;r<i;r++)q(e.childNodes[r],t)}return L.matches=function(e,t){if(!t||!e||1!==e.nodeType)return!1;var r=e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.oMatchesSelector||e.matchesSelector;if(r)return r.call(e,t);var i,n=e.parentNode,a=!n;return a&&(n=D).appendChild(e),i=~L.qsa(n,t).indexOf(e),a&&D.removeChild(e),i},n=function(e){return e.replace(/-+(.)?/g,(function(e,t){return t?t.toUpperCase():""}))},a=function(e){return l.call(e,(function(t,r){return e.indexOf(t)==r}))},L.fragment=function(t,i,n){var a,s,o;return g.test(t)&&(a=r(c.createElement(RegExp.$1))),a||(t.replace&&(t=t.replace(v,"<$1></$2>")),i===e&&(i=p.test(t)&&RegExp.$1),i in b||(i="*"),(o=b[i]).innerHTML=""+t,a=r.each(u.call(o.childNodes),(function(){o.removeChild(this)}))),F(n)&&(s=r(a),r.each(n,(function(e,t){A.indexOf(e)>-1?s[e](t):s.attr(e,t)}))),a},L.Z=function(e,t){return new K(e,t)},L.isZ=function(e){return e instanceof L.Z},L.init=function(t,i){var n,a;if(!t)return L.Z();if("string"==typeof t)if("<"==(t=t.trim())[0]&&p.test(t))n=L.fragment(t,RegExp.$1,i),t=null;else{if(i!==e)return r(i).find(t);n=L.qsa(c,t)}else{if(w(t))return r(c).ready(t);if(L.isZ(t))return t;if(I(t))a=t,n=l.call(a,(function(e){return null!=e}));else if(N(t))n=[t],t=null;else if(p.test(t))n=L.fragment(t.trim(),RegExp.$1,i),t=null;else{if(i!==e)return r(i).find(t);n=L.qsa(c,t)}}return L.Z(n,t)},(r=function(e,t){return L.init(e,t)}).extend=function(e){var t,r=u.call(arguments,1);return"boolean"==typeof e&&(t=e,e=r.shift()),r.forEach((function(r){j(e,r,t)})),e},L.qsa=function(e,t){var r,i="#"==t[0],n=!i&&"."==t[0],a=i||n?t.slice(1):t,s=S.test(a);return e.getElementById&&s&&i?(r=e.getElementById(a))?[r]:[]:1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType?[]:u.call(s&&!i&&e.getElementsByClassName?n?e.getElementsByClassName(a):e.getElementsByTagName(t):e.querySelectorAll(t))},r.contains=c.documentElement.contains?function(e,t){return e!==t&&e.contains(t)}:function(e,t){for(;t&&(t=t.parentNode);)if(t===e)return!0;return!1},r.type=O,r.isFunction=w,r.isWindow=P,r.isArray=I,r.isPlainObject=F,r.isEmptyObject=function(e){var t;for(t in e)return!1;return!0},r.isNumeric=function(e){var t=Number(e),r=typeof e;return null!=e&&"boolean"!=r&&("string"!=r||e.length)&&!isNaN(t)&&isFinite(t)||!1},r.inArray=function(e,t,r){return s.indexOf.call(t,e,r)},r.camelCase=n,r.trim=function(e){return null==e?"":String.prototype.trim.call(e)},r.uuid=0,r.support={},r.expr={},r.noop=function(){},r.map=function(e,t){var i,n,a,s,o=[];if(M(e))for(n=0;n<e.length;n++)null!=(i=t(e[n],n))&&o.push(i);else for(a in e)null!=(i=t(e[a],a))&&o.push(i);return(s=o).length>0?r.fn.concat.apply([],s):s},r.each=function(e,t){var r,i;if(M(e)){for(r=0;r<e.length;r++)if(!1===t.call(e[r],r,e[r]))return e}else for(i in e)if(!1===t.call(e[i],i,e[i]))return e;return e},r.grep=function(e,t){return l.call(e,t)},window.JSON&&(r.parseJSON=JSON.parse),r.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),(function(e,t){_["[object "+t+"]"]=t.toLowerCase()})),r.fn={constructor:L.Z,length:0,forEach:s.forEach,reduce:s.reduce,push:s.push,sort:s.sort,splice:s.splice,indexOf:s.indexOf,concat:function(){var e,t,r=[];for(e=0;e<arguments.length;e++)t=arguments[e],r[e]=L.isZ(t)?t.toArray():t;return o.apply(L.isZ(this)?this.toArray():this,r)},map:function(e){return r(r.map(this,(function(t,r){return e.call(t,r,t)})))},slice:function(){return r(u.apply(this,arguments))},ready:function(e){return k.test(c.readyState)&&c.body?e(r):c.addEventListener("DOMContentLoaded",(function(){e(r)}),!1),this},get:function(t){return t===e?u.call(this):this[t>=0?t:t+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(e){return s.every.call(this,(function(t,r){return!1!==e.call(t,r,t)})),this},filter:function(e){return w(e)?this.not(this.not(e)):r(l.call(this,(function(t){return L.matches(t,e)})))},add:function(e,t){return r(a(this.concat(r(e,t))))},is:function(e){return this.length>0&&L.matches(this[0],e)},not:function(t){var i=[];if(w(t)&&t.call!==e)this.each((function(e){t.call(this,e)||i.push(this)}));else{var n="string"==typeof t?this.filter(t):M(t)&&w(t.item)?u.call(t):r(t);this.forEach((function(e){n.indexOf(e)<0&&i.push(e)}))}return r(i)},has:function(e){return this.filter((function(){return N(e)?r.contains(this,e):r(this).find(e).size()}))},eq:function(e){return-1===e?this.slice(e):this.slice(e,+e+1)},first:function(){var e=this[0];return e&&!N(e)?e:r(e)},last:function(){var e=this[this.length-1];return e&&!N(e)?e:r(e)},find:function(e){var t=this;return e?"object"==typeof e?r(e).filter((function(){var e=this;return s.some.call(t,(function(t){return r.contains(t,e)}))})):1==this.length?r(L.qsa(this[0],e)):this.map((function(){return L.qsa(this,e)})):r()},closest:function(e,t){var i=[],n="object"==typeof e&&r(e);return this.each((function(r,a){for(;a&&!(n?n.indexOf(a)>=0:L.matches(a,e));)a=a!==t&&!x(a)&&a.parentNode;a&&i.indexOf(a)<0&&i.push(a)})),r(i)},parents:function(e){for(var t=[],i=this;i.length>0;)i=r.map(i,(function(e){if((e=e.parentNode)&&!x(e)&&t.indexOf(e)<0)return t.push(e),e}));return H(t,e)},parent:function(e){return H(a(this.pluck("parentNode")),e)},children:function(e){return H(this.map((function(){return V(this)})),e)},contents:function(){return this.map((function(){return this.contentDocument||u.call(this.childNodes)}))},siblings:function(e){return H(this.map((function(e,t){return l.call(V(t.parentNode),(function(e){return e!==t}))})),e)},empty:function(){return this.each((function(){this.innerHTML=""}))},pluck:function(e){return r.map(this,(function(t){return t[e]}))},show:function(){return this.each((function(){var e,t,r;"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=(e=this.nodeName,d[e]||(t=c.createElement(e),c.body.appendChild(t),r=getComputedStyle(t,"").getPropertyValue("display"),t.parentNode.removeChild(t),"none"==r&&(r="block"),d[e]=r),d[e]))}))},replaceWith:function(e){return this.before(e).remove()},wrap:function(e){var t=w(e);if(this[0]&&!t)var i=r(e).get(0),n=i.parentNode||this.length>1;return this.each((function(a){r(this).wrapAll(t?e.call(this,a):n?i.cloneNode(!0):i)}))},wrapAll:function(e){if(this[0]){var t;for(r(this[0]).before(e=r(e));(t=e.children()).length;)e=t.first();r(e).append(this)}return this},wrapInner:function(e){var t=w(e);return this.each((function(i){var n=r(this),a=n.contents(),s=t?e.call(this,i):e;a.length?a.wrapAll(s):n.append(s)}))},unwrap:function(){return this.parent().each((function(){r(this).replaceWith(r(this).children())})),this},clone:function(){return this.map((function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(t){return this.each((function(){var i=r(this);(t===e?"none"==i.css("display"):t)?i.show():i.hide()}))},prev:function(e){return r(this.pluck("previousElementSibling")).filter(e||"*")},next:function(e){return r(this.pluck("nextElementSibling")).filter(e||"*")},html:function(e){return 0 in arguments?this.each((function(t){var i=this.innerHTML;r(this).empty().append(Y(this,e,t,i))})):0 in this?this[0].innerHTML:null},text:function(e){return 0 in arguments?this.each((function(t){var r=Y(this,e,t,this.textContent);this.textContent=null==r?"":""+r})):0 in this?this.pluck("textContent").join(""):null},attr:function(r,i){var n;return"string"!=typeof r||1 in arguments?this.each((function(e){if(1===this.nodeType)if(N(r))for(t in r)W(this,t,r[t]);else W(this,r,Y(this,i,e,this.getAttribute(r)))})):0 in this&&1==this[0].nodeType&&null!=(n=this[0].getAttribute(r))?n:e},removeAttr:function(e){return this.each((function(){1===this.nodeType&&e.split(" ").forEach((function(e){W(this,e)}),this)}))},prop:function(e,t){return e=R[e]||e,1 in arguments?this.each((function(r){this[e]=Y(this,t,r,this[e])})):this[0]&&this[0][e]},removeProp:function(e){return e=R[e]||e,this.each((function(){delete this[e]}))},data:function(t,r){var i="data-"+t.replace(y,"-$1").toLowerCase(),n=1 in arguments?this.attr(i,r):this.attr(i);return null!==n?z(n):e},val:function(e){return 0 in arguments?(null==e&&(e=""),this.each((function(t){this.value=Y(this,e,t,this.value)}))):this[0]&&(this[0].multiple?r(this[0]).find("option").filter((function(){return this.selected})).pluck("value"):this[0].value)},offset:function(e){if(e)return this.each((function(t){var i=r(this),n=Y(this,e,t,i.offset()),a=i.offsetParent().offset(),s={top:n.top-a.top,left:n.left-a.left};"static"==i.css("position")&&(s.position="relative"),i.css(s)}));if(!this.length)return null;if(c.documentElement!==this[0]&&!r.contains(c.documentElement,this[0]))return{top:0,left:0};var t=this[0].getBoundingClientRect();return{left:t.left+window.pageXOffset,top:t.top+window.pageYOffset,width:Math.round(t.width),height:Math.round(t.height)}},css:function(e,i){if(arguments.length<2){var a=this[0];if("string"==typeof e){if(!a)return;return a.style[n(e)]||getComputedStyle(a,"").getPropertyValue(e)}if(I(e)){if(!a)return;var s={},o=getComputedStyle(a,"");return r.each(e,(function(e,t){s[t]=a.style[n(t)]||o.getPropertyValue(t)})),s}}var l="";if("string"==O(e))i||0===i?l=B(e)+":"+G(e,i):this.each((function(){this.style.removeProperty(B(e))}));else for(t in e)e[t]||0===e[t]?l+=B(t)+":"+G(t,e[t])+";":this.each((function(){this.style.removeProperty(B(t))}));return this.each((function(){this.style.cssText+=";"+l}))},index:function(e){return e?this.indexOf(r(e)[0]):this.parent().children().indexOf(this[0])},hasClass:function(e){return!!e&&s.some.call(this,(function(e){return this.test($(e))}),U(e))},addClass:function(e){return e?this.each((function(t){if("className"in this){i=[];var n=$(this);Y(this,e,t,n).split(/\s+/g).forEach((function(e){r(this).hasClass(e)||i.push(e)}),this),i.length&&$(this,n+(n?" ":"")+i.join(" "))}})):this},removeClass:function(t){return this.each((function(r){if("className"in this){if(t===e)return $(this,"");i=$(this),Y(this,t,r,i).split(/\s+/g).forEach((function(e){i=i.replace(U(e)," ")})),$(this,i.trim())}}))},toggleClass:function(t,i){return t?this.each((function(n){var a=r(this);Y(this,t,n,$(this)).split(/\s+/g).forEach((function(t){(i===e?!a.hasClass(t):i)?a.addClass(t):a.removeClass(t)}))})):this},scrollTop:function(t){if(this.length){var r="scrollTop"in this[0];return t===e?r?this[0].scrollTop:this[0].pageYOffset:this.each(r?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var r="scrollLeft"in this[0];return t===e?r?this[0].scrollLeft:this[0].pageXOffset:this.each(r?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var e=this[0],t=this.offsetParent(),i=this.offset(),n=m.test(t[0].nodeName)?{top:0,left:0}:t.offset();return i.top-=parseFloat(r(e).css("margin-top"))||0,i.left-=parseFloat(r(e).css("margin-left"))||0,n.top+=parseFloat(r(t[0]).css("border-top-width"))||0,n.left+=parseFloat(r(t[0]).css("border-left-width"))||0,{top:i.top-n.top,left:i.left-n.left}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent||c.body;e&&!m.test(e.nodeName)&&"static"==r(e).css("position");)e=e.offsetParent;return e}))}},r.fn.detach=r.fn.remove,["width","height"].forEach((function(t){var i=t.replace(/./,(function(e){return e[0].toUpperCase()}));r.fn[t]=function(n){var a,s=this[0];return n===e?P(s)?s["inner"+i]:x(s)?s.documentElement["scroll"+i]:(a=this.offset())&&a[t]:this.each((function(e){(s=r(this)).css(t,Y(this,n,e,s[t]()))}))}})),["after","prepend","before","append"].forEach((function(t,i){var n=i%2;r.fn[t]=function(){var t,a,s=r.map(arguments,(function(i){var n=[];return"array"==(t=O(i))?(i.forEach((function(t){return t.nodeType!==e?n.push(t):r.zepto.isZ(t)?n=n.concat(t.get()):void(n=n.concat(L.fragment(t)))})),n):"object"==t||null==i?i:L.fragment(i)})),o=this.length>1;return s.length<1?this:this.each((function(e,t){a=n?t:t.parentNode,t=0==i?t.nextSibling:1==i?t.firstChild:2==i?t:null;var l=r.contains(c.documentElement,a);s.forEach((function(e){if(o)e=e.cloneNode(!0);else if(!a)return r(e).remove();a.insertBefore(e,t),l&&q(e,(function(e){if(!(null==e.nodeName||"SCRIPT"!==e.nodeName.toUpperCase()||e.type&&"text/javascript"!==e.type||e.src)){var t=e.ownerDocument?e.ownerDocument.defaultView:window;t.eval.call(t,e.innerHTML)}}))}))}))},r.fn[n?t+"To":"insert"+(i?"Before":"After")]=function(e){return r(e)[t](this),this}})),L.Z.prototype=K.prototype=r.fn,L.uniq=a,L.deserializeValue=z,r.zepto=L,r}();window.Zepto=_,void 0===window.$&&(window.$=_),function(e){var t,r,i=+new Date,n=window.document,a=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,s=/^(?:text|application)\/javascript/i,o=/^(?:text|application)\/xml/i,l="application/json",u="text/html",c=/^\s*$/,d=n.createElement("a");function h(t,r,i,a){if(t.global)return function(t,r,i){var n=e.Event(r);return e(t).trigger(n,i),!n.isDefaultPrevented()}(r||n,i,a)}function f(e,t){var r=t.context;if(!1===t.beforeSend.call(r,e,t)||!1===h(t,r,"ajaxBeforeSend",[e,t]))return!1;h(t,r,"ajaxSend",[e,t])}function p(e,t,r,i){var n=r.context,a="success";r.success.call(n,e,a,t),i&&i.resolveWith(n,[e,a,t]),h(r,n,"ajaxSuccess",[t,r,e]),v(a,t,r)}function g(e,t,r,i,n){var a=i.context;i.error.call(a,r,t,e),n&&n.rejectWith(a,[r,t,e]),h(i,a,"ajaxError",[r,i,e||t]),v(t,r,i)}function v(t,r,i){var n=i.context;i.complete.call(n,r,t),h(i,n,"ajaxComplete",[r,i]),function(t){t.global&&!--e.active&&h(t,null,"ajaxStop")}(i)}function m(){}function y(e,t){return""==t?e:(e+"&"+t).replace(/[&?]{1,2}/,"?")}function A(t,r,i,n){return e.isFunction(r)&&(n=i,i=r,r=void 0),e.isFunction(i)||(n=i,i=void 0),{url:t,data:r,success:i,dataType:n}}d.href=window.location.href,e.active=0,e.ajaxJSONP=function(t,r){if(!("type"in t))return e.ajax(t);var a,s,o=t.jsonpCallback,l=(e.isFunction(o)?o():o)||"Zepto"+i++,u=n.createElement("script"),c=window[l],d=function(t){e(u).triggerHandler("error",t||"abort")},h={abort:d};return r&&r.promise(h),e(u).on("load error",(function(i,n){clearTimeout(s),e(u).off().remove(),"error"!=i.type&&a?p(a[0],h,t,r):g(null,n||"error",h,t,r),window[l]=c,a&&e.isFunction(c)&&c(a[0]),c=a=void 0})),!1===f(h,t)?(d("abort"),h):(window[l]=function(){a=arguments},u.src=t.url.replace(/\?(.+)=\?/,"?$1="+l),n.head.appendChild(u),t.timeout>0&&(s=setTimeout((function(){d("timeout")}),t.timeout)),h)},e.ajaxSettings={type:"GET",beforeSend:m,success:m,error:m,complete:m,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:u,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:m},e.ajax=function(i){var a,v,A=e.extend({},i||{}),E=e.Deferred&&e.Deferred();for(t in e.ajaxSettings)void 0===A[t]&&(A[t]=e.ajaxSettings[t]);!function(t){t.global&&0==e.active++&&h(t,null,"ajaxStart")}(A),A.crossDomain||((a=n.createElement("a")).href=A.url,a.href=a.href,A.crossDomain=d.protocol+"//"+d.host!=a.protocol+"//"+a.host),A.url||(A.url=window.location.toString()),(v=A.url.indexOf("#"))>-1&&(A.url=A.url.slice(0,v)),function(t){t.processData&&t.data&&"string"!=e.type(t.data)&&(t.data=e.param(t.data,t.traditional)),!t.data||t.type&&"GET"!=t.type.toUpperCase()&&"jsonp"!=t.dataType||(t.url=y(t.url,t.data),t.data=void 0)}(A);var T=A.dataType,b=/\?.+=\?/.test(A.url);if(b&&(T="jsonp"),!1!==A.cache&&(i&&!0===i.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=?")),e.ajaxJSONP(A,E);var k,S=A.accepts[T],_={},C=function(e,t){_[e.toLowerCase()]=[e,t]},L=/^([\w-]+:)\/\//.test(A.url)?RegExp.$1:window.location.protocol,D=A.xhr(),R=D.setRequestHeader;if(E&&E.promise(D),A.crossDomain||C("X-Requested-With","XMLHttpRequest"),C("Accept",S||"*/*"),(S=A.mimeType||S)&&(S.indexOf(",")>-1&&(S=S.split(",",2)[0]),D.overrideMimeType&&D.overrideMimeType(S)),(A.contentType||!1!==A.contentType&&A.data&&"GET"!=A.type.toUpperCase())&&C("Content-Type",A.contentType||"application/x-www-form-urlencoded"),A.headers)for(r in A.headers)C(r,A.headers[r]);if(D.setRequestHeader=C,D.onreadystatechange=function(){if(4==D.readyState){D.onreadystatechange=m,clearTimeout(k);var t,r=!1;if(D.status>=200&&D.status<300||304==D.status||0==D.status&&"file:"==L){if(T=T||function(e){return e&&(e=e.split(";",2)[0]),e&&(e==u?"html":e==l?"json":s.test(e)?"script":o.test(e)&&"xml")||"text"}(A.mimeType||D.getResponseHeader("content-type")),"arraybuffer"==D.responseType||"blob"==D.responseType)t=D.response;else{t=D.responseText;try{t=function(e,t,r){if(r.dataFilter==m)return e;var i=r.context;return r.dataFilter.call(i,e,t)}(t,T,A),"script"==T?(0,eval)(t):"xml"==T?t=D.responseXML:"json"==T&&(t=c.test(t)?null:e.parseJSON(t))}catch(e){r=e}if(r)return g(r,"parsererror",D,A,E)}p(t,D,A,E)}else g(D.statusText||null,D.status?"error":"abort",D,A,E)}},!1===f(D,A))return D.abort(),g(null,"abort",D,A,E),D;var I=!("async"in A)||A.async;if(D.open(A.type,A.url,I,A.username,A.password),A.xhrFields)for(r in A.xhrFields)D[r]=A.xhrFields[r];for(r in _)R.apply(D,_[r]);return A.timeout>0&&(k=setTimeout((function(){D.onreadystatechange=m,D.abort(),g(null,"timeout",D,A,E)}),A.timeout)),D.send(A.data?A.data:null),D},e.get=function(){return e.ajax(A.apply(null,arguments))},e.post=function(){var t=A.apply(null,arguments);return t.type="POST",e.ajax(t)},e.getJSON=function(){var t=A.apply(null,arguments);return t.dataType="json",e.ajax(t)},e.fn.load=function(t,r,i){if(!this.length)return this;var n,s=this,o=t.split(/\s/),l=A(t,r,i),u=l.success;return o.length>1&&(l.url=o[0],n=o[1]),l.success=function(t){s.html(n?e("<div>").html(t.replace(a,"")).find(n):t),u&&u.apply(s,arguments)},e.ajax(l),this};var E=encodeURIComponent;function T(t,r,i,n){var a,s=e.isArray(r),o=e.isPlainObject(r);e.each(r,(function(r,l){a=e.type(l),n&&(r=i?n:n+"["+(o||"object"==a||"array"==a?r:"")+"]"),!n&&s?t.add(l.name,l.value):"array"==a||!i&&"object"==a?T(t,l,i,r):t.add(r,l)}))}e.param=function(t,r){var i=[];return i.add=function(t,r){e.isFunction(r)&&(r=r()),null==r&&(r=""),this.push(E(t)+"="+E(r))},T(i,t,r),i.join("&").replace(/%20/g,"+")}}(_),(k=_).Callbacks=function(e){e=k.extend({},e);var t,r,i,n,a,s,o=[],l=!e.once&&[],u=function(d){for(t=e.memory&&d,r=!0,s=n||0,n=0,a=o.length,i=!0;o&&s<a;++s)if(!1===o[s].apply(d[0],d[1])&&e.stopOnFalse){t=!1;break}i=!1,o&&(l?l.length&&u(l.shift()):t?o.length=0:c.disable())},c={add:function(){if(o){var r=o.length,s=function(t){k.each(t,(function(t,r){"function"==typeof r?e.unique&&c.has(r)||o.push(r):r&&r.length&&"string"!=typeof r&&s(r)}))};s(arguments),i?a=o.length:t&&(n=r,u(t))}return this},remove:function(){return o&&k.each(arguments,(function(e,t){for(var r;(r=k.inArray(t,o,r))>-1;)o.splice(r,1),i&&(r<=a&&--a,r<=s&&--s)})),this},has:function(e){return!(!o||!(e?k.inArray(e,o)>-1:o.length))},empty:function(){return a=o.length=0,this},disable:function(){return o=l=t=void 0,this},disabled:function(){return!o},lock:function(){return l=void 0,t||c.disable(),this},locked:function(){return!l},fireWith:function(e,t){return!o||r&&!l||(t=[e,(t=t||[]).slice?t.slice():t],i?l.push(t):u(t)),this},fire:function(){return c.fireWith(this,arguments)},fired:function(){return!!r}};return c},function(e){var t=Array.prototype.slice;function r(t){var i=[["resolve","done",e.Callbacks({once:1,memory:1}),"resolved"],["reject","fail",e.Callbacks({once:1,memory:1}),"rejected"],["notify","progress",e.Callbacks({memory:1})]],n="pending",a={state:function(){return n},always:function(){return s.done(arguments).fail(arguments),this},then:function(){var t=arguments;return r((function(r){e.each(i,(function(i,n){var o=e.isFunction(t[i])&&t[i];s[n[1]]((function(){var t=o&&o.apply(this,arguments);if(t&&e.isFunction(t.promise))t.promise().done(r.resolve).fail(r.reject).progress(r.notify);else{var i=this===a?r.promise():this,s=o?[t]:arguments;r[n[0]+"With"](i,s)}}))})),t=null})).promise()},promise:function(t){return null!=t?e.extend(t,a):a}},s={};return e.each(i,(function(e,t){var r=t[2],o=t[3];a[t[1]]=r.add,o&&r.add((function(){n=o}),i[1^e][2].disable,i[2][2].lock),s[t[0]]=function(){return s[t[0]+"With"](this===s?a:this,arguments),this},s[t[0]+"With"]=r.fireWith})),a.promise(s),t&&t.call(s,s),s}e.when=function(i){var n,a,s,o=t.call(arguments),l=o.length,u=0,c=1!==l||i&&e.isFunction(i.promise)?l:0,d=1===c?i:r(),h=function(e,r,i){return function(a){r[e]=this,i[e]=arguments.length>1?t.call(arguments):a,i===n?d.notifyWith(r,i):--c||d.resolveWith(r,i)}};if(l>1)for(n=new Array(l),a=new Array(l),s=new Array(l);u<l;++u)o[u]&&e.isFunction(o[u].promise)?o[u].promise().done(h(u,s,o)).fail(d.reject).progress(h(u,a,n)):--c;return c||d.resolveWith(s,o),d.promise()},e.Deferred=r}(_),function(e){var t,r=1,i=Array.prototype.slice,n=e.isFunction,a=function(e){return"string"==typeof e},s={},o={},l="onfocusin"in window,u={focus:"focusin",blur:"focusout"},c={mouseenter:"mouseover",mouseleave:"mouseout"};function d(e){return e._zid||(e._zid=r++)}function h(e,t,r,i){if((t=f(t)).ns)var n=(a=t.ns,new RegExp("(?:^| )"+a.replace(" "," .* ?")+"(?: |$)"));var a;return(s[d(e)]||[]).filter((function(e){return e&&(!t.e||e.e==t.e)&&(!t.ns||n.test(e.ns))&&(!r||d(e.fn)===d(r))&&(!i||e.sel==i)}))}function f(e){var t=(""+e).split(".");return{e:t[0],ns:t.slice(1).sort().join(" ")}}function p(e,t){return e.del&&!l&&e.e in u||!!t}function g(e){return c[e]||l&&u[e]||e}function v(r,i,n,a,o,l,u){var h=d(r),v=s[h]||(s[h]=[]);i.split(/\s/).forEach((function(i){if("ready"==i)return e(document).ready(n);var s=f(i);s.fn=n,s.sel=o,s.e in c&&(n=function(t){var r=t.relatedTarget;if(!r||r!==this&&!e.contains(this,r))return s.fn.apply(this,arguments)}),s.del=l;var d=l||n;s.proxy=function(e){if(!(e=b(e)).isImmediatePropagationStopped()){e.data=a;var i=d.apply(r,e._args==t?[e]:[e].concat(e._args));return!1===i&&(e.preventDefault(),e.stopPropagation()),i}},s.i=v.length,v.push(s),"addEventListener"in r&&r.addEventListener(g(s.e),s.proxy,p(s,u))}))}function m(e,t,r,i,n){var a=d(e);(t||"").split(/\s/).forEach((function(t){h(e,t,r,i).forEach((function(t){delete s[a][t.i],"removeEventListener"in e&&e.removeEventListener(g(t.e),t.proxy,p(t,n))}))}))}o.click=o.mousedown=o.mouseup=o.mousemove="MouseEvents",e.event={add:v,remove:m},e.proxy=function(t,r){var s=2 in arguments&&i.call(arguments,2);if(n(t)){var o=function(){return t.apply(r,s?s.concat(i.call(arguments)):arguments)};return o._zid=d(t),o}if(a(r))return s?(s.unshift(t[r],t),e.proxy.apply(null,s)):e.proxy(t[r],t);throw new TypeError("expected function")},e.fn.bind=function(e,t,r){return this.on(e,t,r)},e.fn.unbind=function(e,t){return this.off(e,t)},e.fn.one=function(e,t,r,i){return this.on(e,t,r,i,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(r,i){return!i&&r.isDefaultPrevented||(i||(i=r),e.each(T,(function(e,t){var n=i[e];r[e]=function(){return this[t]=y,n&&n.apply(i,arguments)},r[t]=A})),r.timeStamp||(r.timeStamp=Date.now()),(i.defaultPrevented!==t?i.defaultPrevented:"returnValue"in i?!1===i.returnValue:i.getPreventDefault&&i.getPreventDefault())&&(r.isDefaultPrevented=y)),r}function k(e){var r,i={originalEvent:e};for(r in e)E.test(r)||e[r]===t||(i[r]=e[r]);return b(i,e)}e.fn.delegate=function(e,t,r){return this.on(t,e,r)},e.fn.undelegate=function(e,t,r){return this.off(t,e,r)},e.fn.live=function(t,r){return e(document.body).delegate(this.selector,t,r),this},e.fn.die=function(t,r){return e(document.body).undelegate(this.selector,t,r),this},e.fn.on=function(r,s,o,l,u){var c,d,h=this;return r&&!a(r)?(e.each(r,(function(e,t){h.on(e,s,o,t,u)})),h):(a(s)||n(l)||!1===l||(l=o,o=s,s=t),l!==t&&!1!==o||(l=o,o=t),!1===l&&(l=A),h.each((function(t,n){u&&(c=function(e){return m(n,e.type,l),l.apply(this,arguments)}),s&&(d=function(t){var r,a=e(t.target).closest(s,n).get(0);if(a&&a!==n)return r=e.extend(k(t),{currentTarget:a,liveFired:n}),(c||l).apply(a,[r].concat(i.call(arguments,1)))}),v(n,r,l,o,s,d||c)})))},e.fn.off=function(r,i,s){var o=this;return r&&!a(r)?(e.each(r,(function(e,t){o.off(e,i,t)})),o):(a(i)||n(s)||!1===s||(s=i,i=t),!1===s&&(s=A),o.each((function(){m(this,r,s,i)})))},e.fn.trigger=function(t,r){return(t=a(t)||e.isPlainObject(t)?e.Event(t):b(t))._args=r,this.each((function(){t.type in u&&"function"==typeof this[t.type]?this[t.type]():"dispatchEvent"in this?this.dispatchEvent(t):e(this).triggerHandler(t,r)}))},e.fn.triggerHandler=function(t,r){var i,n;return this.each((function(s,o){(i=k(a(t)?e.Event(t):t))._args=r,i.target=o,e.each(h(o,t.type||t),(function(e,t){if(n=t.proxy(i),i.isImmediatePropagationStopped())return!1}))})),n},"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(t){e.fn[t]=function(e){return 0 in arguments?this.bind(t,e):this.trigger(t)}})),e.Event=function(e,t){a(e)||(e=(t=e).type);var r=document.createEvent(o[e]||"Events"),i=!0;if(t)for(var n in t)"bubbles"==n?i=!!t[n]:r[n]=t[n];return r.initEvent(e,i,!0),b(r)}}(_),function(){try{getComputedStyle(void 0)}catch(t){var e=getComputedStyle;window.getComputedStyle=function(t,r){try{return e(t,r)}catch(e){return null}}}}(),function(e){var t=e.zepto,r=t.qsa,i=t.matches;function n(t){return!(!(t=e(t)).width()&&!t.height())&&"none"!==t.css("display")}var a=e.expr[":"]={visible:function(){if(n(this))return this},hidden:function(){if(!n(this))return this},selected:function(){if(this.selected)return this},checked:function(){if(this.checked)return this},parent:function(){return this.parentNode},first:function(e){if(0===e)return this},last:function(e,t){if(e===t.length-1)return this},eq:function(e,t,r){if(e===r)return this},contains:function(t,r,i){if(e(this).text().indexOf(i)>-1)return this},has:function(e,r,i){if(t.qsa(this,i).length)return this}},s=new RegExp("(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*"),o=/^\s*>/,l="Zepto"+ +new Date;function u(e,t){e=e.replace(/=#\]/g,'="#"]');var r,i,n=s.exec(e);if(n&&n[2]in a&&(r=a[n[2]],i=n[3],e=n[1],i)){var o=Number(i);i=isNaN(o)?i.replace(/^["']|["']$/g,""):o}return t(e,r,i)}t.qsa=function(i,n){return u(n,(function(a,s,u){try{var c;!a&&s?a="*":o.test(a)&&(c=e(i).addClass(l),a="."+l+" "+a);var d=r(i,a)}catch(e){throw console.error("error performing selector: %o",n),e}finally{c&&c.removeClass(l)}return s?t.uniq(e.map(d,(function(e,t){return s.call(e,t,d,u)}))):d}))},t.matches=function(e,t){return u(t,(function(t,r,n){return(!t||i(e,t))&&(!r||r.call(e,null,n)===e)}))}}(_);var C,L,D,R=_,I=[{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.]*)"}],O=[{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"}],w={},P=function(e,t){var r=e.split(".",2);t.fullVersion=e,r[0]&&(t.majorVersion=parseInt(r[0])),r[1]&&(t.minorVersion=parseInt(r[1]))},x=function(e,t,r){var i="["==t.substr(0,1)?new RegExp(t,"g"):t,n=e.split(i,2);"."!=t&&(e=e.replace(new RegExp(t,"g"),".")),r.fullVersion=e,n&&n[0]&&(r.majorVersion=parseInt(n[0])),n&&n[1]&&(r.minorVersion=parseInt(n[1]))},N=function(e){var t,r=e.match(/\b(playstation 4|nx|opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(r[1]))return t=/\brv[ :]+(\d+)/g.exec(e)||[],{name:"IE",version:parseInt(t[1]||"")};if("Chrome"===r[1]){if(null!=(t=e.match(/\bOPR\/(\d+)/)))return{name:"Opera",version:parseInt(t[1])};if(null!=(t=e.match(/\bEdge\/(\d+)/)))return{name:"Edge",version:parseInt(t[1])}}else/android/i.test(e)&&(t=e.match(/version\/(\d+)/i))&&(r.splice(1,1,"Android WebView"),r.splice(2,1,t[1]));return{name:(r=r[2]?[r[1],r[2]]:[navigator.appName,navigator.appVersion,"-?"])[0],version:parseInt(r[1])}}(navigator.userAgent);w.isEdge=/Edg|EdgiOS|EdgA/i.test(navigator.userAgent),w.isChrome=/Chrome|CriOS/i.test(navigator.userAgent)&&!w.isEdge,w.isSafari=/Safari/i.test(navigator.userAgent)&&!w.isChrome&&!w.isEdge,w.isFirefox=/Firefox/i.test(navigator.userAgent),w.isLegacyIE=!!window.ActiveXObject,w.isIE=w.isLegacyIE||/trident.*rv:1\d/i.test(navigator.userAgent),w.isIE11=/trident.*rv:11/i.test(navigator.userAgent),w.isChromecast=w.isChrome&&/CrKey/i.test(navigator.userAgent),w.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone|IEMobile|Mobile Safari|Opera Mini/i.test(navigator.userAgent),w.isiOS=/iPad|iPhone|iPod/i.test(navigator.userAgent),w.isAndroid=/Android/i.test(navigator.userAgent),w.isWindowsPhone=/Windows Phone/i.test(navigator.userAgent),w.isWin8App=/MSAppHost/i.test(navigator.userAgent),w.isWiiU=/WiiU/i.test(navigator.userAgent),w.isPS4=/PlayStation 4/i.test(navigator.userAgent),w.hasLocalstorage=function(){try{return localStorage.setItem("clappr","clappr"),localStorage.removeItem("clappr"),!0}catch(e){return!1}}(),w.hasFlash=function(){try{return!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(e){return!(!navigator.mimeTypes||void 0===navigator.mimeTypes["application/x-shockwave-flash"]||!navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)}}(),w.name=N.name,w.version=N.version,w.userAgent=navigator.userAgent,w.data=function(){var e,t={},r=w.userAgent.toLowerCase(),i=b(I);try{for(i.s();!(e=i.n()).done;){var n=e.value,a=new RegExp(n.identifier.toLowerCase()).exec(r);if(null!=a&&a[1]){if(t.name=n.name,t.group=n.group,n.versionIdentifier){var s=new RegExp(n.versionIdentifier.toLowerCase()).exec(r);null!=s&&s[1]&&P(s[1],t)}else P(a[1],t);break}}}catch(e){i.e(e)}finally{i.f()}return t}(),w.os=function(){var e,t={},r=w.userAgent.toLowerCase(),i=b(O);try{for(i.s();!(e=i.n()).done;){var n=e.value,a=new RegExp(n.identifier.toLowerCase()).exec(r);if(null!=a){if(t.name=n.name,t.group=n.group,n.version)x(n.version,n.versionSeparator?n.versionSeparator:".",t);else if(a[1])x(a[1],n.versionSeparator?n.versionSeparator:".",t);else if(n.versionIdentifier){var s=new RegExp(n.versionIdentifier.toLowerCase()).exec(r);null!=s&&s[1]&&x(s[1],n.versionSeparator?n.versionSeparator:".",t)}break}}}catch(e){i.e(e)}finally{i.f()}return t}(),w.isWindows=/^Windows$/i.test(w.os.group),w.isMacOS=/^Mac OS$/i.test(w.os.group),w.isLinux=/^Linux$/i.test(w.os.group),w.viewport=((C={}).width=R(window).width(),C.height=R(window).height(),C),w.device=(L=w.userAgent,(D=/\((iP(?:hone|ad|od))?(?:[^;]*; ){0,2}([^)]+(?=\)))/.exec(L))&&(D[1]||D[2])||""),void 0!==window.orientation&&function(){switch(window.orientation){case-90:case 90:w.viewport.orientation="landscape";break;default:w.viewport.orientation="portrait"}}();var F={},M=[],B=(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}).bind(window),U=(window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.clearTimeout).bind(window);function G(e,t){if(t)for(var r in t){var i=Object.getOwnPropertyDescriptor(t,r);i?Object.defineProperty(e,r,i):e[r]=t[r]}return e}function V(e,t){var r=function(e){c(i,e);var r=g(i);function i(){var e;s(this,i);for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return e=r.call.apply(r,[this].concat(a)),t.initialize&&t.initialize.apply(f(e),a),e}return l(i)}(e);return G(r.prototype,t),r}var K={fullscreenElement:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},requestFullscreen:function(e){if(e.requestFullscreen)return e.requestFullscreen();if(e.webkitRequestFullscreen){if("function"==typeof e.then)return e.webkitRequestFullscreen();e.webkitRequestFullscreen()}else{if(e.mozRequestFullScreen)return e.mozRequestFullScreen();if(e.msRequestFullscreen)return e.msRequestFullscreen();e.querySelector&&e.querySelector("video")&&e.querySelector("video").webkitEnterFullScreen?e.querySelector("video").webkitEnterFullScreen():e.webkitEnterFullScreen&&e.webkitEnterFullScreen()}},cancelFullscreen:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document;e.exitFullscreen?e.exitFullscreen():e.webkitCancelFullScreen?e.webkitCancelFullScreen():e.webkitExitFullscreen?e.webkitExitFullscreen():e.mozCancelFullScreen?e.mozCancelFullScreen():e.msExitFullscreen&&e.msExitFullscreen()},fullscreenEnabled:function(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}},j=function(){function e(){s(this,e)}return l(e,null,[{key:"_defaultConfig",value:function(){return{volume:{value:100,parse:parseInt}}}},{key:"_defaultValueFor",value:function(e){try{return this._defaultConfig()[e].parse(this._defaultConfig()[e].value)}catch(e){return}}},{key:"_createKeyspace",value:function(e){return"clappr.".concat(document.domain,".").concat(e)}},{key:"restore",value:function(e){return w.hasLocalstorage&&localStorage[this._createKeyspace(e)]?this._defaultConfig()[e].parse(localStorage[this._createKeyspace(e)]):this._defaultValueFor(e)}},{key:"persist",value:function(e,t){if(w.hasLocalstorage)try{return localStorage[this._createKeyspace(e)]=t,!0}catch(e){return!1}}}]),e}(),H=function(){function e(){s(this,e)}return l(e,null,[{key:"params",get:function(){var e=window.location.search.substring(1);return e!==this.query&&(this._urlParams=this.parse(e),this.query=e),this._urlParams}},{key:"hashParams",get:function(){var e=window.location.hash.substring(1);return e!==this.hash&&(this._hashParams=this.parse(e),this.hash=e),this._hashParams}},{key:"parse",value:function(e){for(var t,r=/\+/g,i=/([^&=]+)=?([^&]*)/g,n=function(e){return decodeURIComponent(e.replace(r," "))},a={};t=i.exec(e);)a[n(t[1]).toLowerCase()]=n(t[2]);return a}}]),e}();function Y(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"t",t=0,r=H.params[e]||H.hashParams[e]||"",i=r.match(/[0-9]+[hms]+/g)||[];if(i.length>0){var n={h:3600,m:60,s:1};i.forEach((function(e){if(e){var r=e[e.length-1],i=parseInt(e.slice(0,e.length-1),10);t+=i*n[r]}}))}else r&&(t=parseInt(r,10));return t}function W(e){return F[e]||(F[e]=0),e+ ++F[e]}function $(e){return e-parseFloat(e)+1>=0}function z(){var e=document.getElementsByTagName("script");return e.length?e[e.length-1].src:""}function q(){return window.navigator&&window.navigator.language}function X(e,t){var r=(t=Object.assign({inline:!1,muted:!1,timeout:250,type:"video",source:S.mp4,element:null},t)).element?t.element:document.createElement(t.type);r.muted=t.muted,!0===t.muted&&r.setAttribute("muted","muted"),!0===t.inline&&r.setAttribute("playsinline","playsinline"),r.src=t.source;var i=r.play(),n=setTimeout((function(){a(!1,new Error("Timeout ".concat(t.timeout," ms has been reached")))}),t.timeout),a=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;clearTimeout(n),e(t,r)};void 0!==i?i.then((function(){return a(!0)})).catch((function(e){return a(!1,e)})):a(!0)}var Z=function(){function e(){s(this,e)}return l(e,null,[{key:"configure",value:function(e){this.options=R.extend(!0,this.options,e)}},{key:"create",value:function(e){return this.options.recycleVideo&&"video"===e&&M.length>0?M.shift():document.createElement(e)}},{key:"garbage",value:function(e){this.options.recycleVideo&&"VIDEO"===e.tagName.toUpperCase()&&(R(e).children().remove(),Object.values(e.attributes).forEach((function(t){return e.removeAttribute(t.name)})),M.push(e))}}]),e}();Z.options={recycleVideo:!1};var Q=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500;s(this,e),this.delay=t,this.lastTime=0}return l(e,[{key:"handle",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(new Date).getTime(),n=i-this.lastTime;n<this.delay&&n>0&&(t(),r&&e.preventDefault()),this.lastTime=i}}]),e}(),J={Config:j,Fullscreen:K,QueryString:H,DomRecycler:Z,assign:G,extend:V,formatTime:function(e,t){if(!isFinite(e))return"--:--";e*=1e3;var r=(e=parseInt(e/1e3))%60,i=(e=parseInt(e/60))%60,n=(e=parseInt(e/60))%24,a=parseInt(e/24),s="";return a&&a>0&&(s+=a+":",n<1&&(s+="00:")),(n&&n>0||t)&&(s+=("0"+n).slice(-2)+":"),s+=("0"+i).slice(-2)+":",(s+=("0"+r).slice(-2)).trim()},seekStringToSeconds:Y,uniqueId:W,currentScriptUrl:z,isNumber:$,requestAnimationFrame:B,cancelAnimationFrame:U,getBrowserLanguage:q,now:function(){return window.performance&&window.performance.now?performance.now():Date.now()},removeArrayItem:function(e,t){var r=e.indexOf(t);r>=0&&e.splice(r,1)},listContainsIgnoreCase:function(e,t){return void 0!==e&&void 0!==t&&void 0!==t.find((function(t){return e.toLowerCase()===t.toLowerCase()}))},canAutoPlayMedia:X,Media:S,DoubleEventHandler:Q},ee="font-weight: bold; font-size: 13px;",te="color: #ff8000;"+ee,re="color: #ff0000;"+ee,ie=["color: #0000ff;"+ee,"color: #006600;"+ee,te,re,re],ne=["debug","info","warn","error","disabled"],ae=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;s(this,e),this.EXCLUDE_LIST=["timeupdate","playback:timeupdate","playback:progress","container:hover","container:timeupdate","container:progress"],this.level=t,this.previousLevel=this.level,this.offLevel=r}return l(e,[{key:"level",get:function(){return this._level},set:function(e){this._level=e}},{key:"debug",value:function(e){this.log(e,0,Array.prototype.slice.call(arguments,1))}},{key:"info",value:function(e){this.log(e,1,Array.prototype.slice.call(arguments,1))}},{key:"warn",value:function(e){this.log(e,2,Array.prototype.slice.call(arguments,1))}},{key:"error",value:function(e){this.log(e,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 "+ne[this.level],te)}},{key:"log",value:function(e,t,r){if(!(this.EXCLUDE_LIST.indexOf(r[0])>=0||t<this.level)){r||(r=e,e=null);var i=ie[t],n="";e&&(n="["+e+"]"),window.console&&window.console.log&&window.console.log.apply(console,["%c["+ne[t]+"]"+n,i].concat(r))}}}]),e}();ae.LEVEL_DEBUG=0,ae.LEVEL_INFO=1,ae.LEVEL_WARN=2,ae.LEVEL_ERROR=3,ae.getInstance=function(){return void 0===this._instance&&(this._instance=new this),this._instance},ae.setLevel=function(e){this.getInstance().level=e},ae.debug=function(){this.getInstance().debug.apply(this.getInstance(),arguments)},ae.info=function(){this.getInstance().info.apply(this.getInstance(),arguments)},ae.warn=function(){this.getInstance().warn.apply(this.getInstance(),arguments)},ae.error=function(){this.getInstance().error.apply(this.getInstance(),arguments)};var se=Array.prototype.slice,oe=/\s+/,le=function(e,t,r,i){if(!r)return!0;if("object"===a(r)){for(var n in r)e[t].apply(e,[n,r[n]].concat(i));return!1}if(oe.test(r)){for(var s=r.split(oe),o=0,l=s.length;o<l;o++)e[t].apply(e,[s[o]].concat(i));return!1}return!0},ue=function(e,t,r,i){var n,a=-1,s=e.length,o=t[0],l=t[1],u=t[2];!function c(){try{switch(t.length){case 0:for(;++a<s;)(n=e[a]).callback.call(n.ctx);return;case 1:for(;++a<s;)(n=e[a]).callback.call(n.ctx,o);return;case 2:for(;++a<s;)(n=e[a]).callback.call(n.ctx,o,l);return;case 3:for(;++a<s;)(n=e[a]).callback.call(n.ctx,o,l,u);return;default:for(;++a<s;)(n=e[a]).callback.apply(n.ctx,t);return}}catch(e){ae.error.apply(ae,[r,"error on event",i,"trigger","-",e]),c()}}()},ce=function(){function e(){s(this,e)}return l(e,[{key:"on",value:function(e,t,r){return le(this,"on",e,[t,r])&&t?(this._events||(this._events={}),(this._events[e]||(this._events[e]=[])).push({callback:t,context:r,ctx:r||this}),this):this}},{key:"once",value:function(e,t,r){var i,n=this;if(!le(this,"once",e,[t,r])||!t)return this;var a=function(){return n.off(e,i)};return i=function(){a(),t.apply(this,arguments)},this.on(e,i,r)}},{key:"off",value:function(e,t,r){var i,n,a,s,o,l,u,c;if(!this._events||!le(this,"off",e,[t,r]))return this;if(!e&&!t&&!r)return this._events=void 0,this;for(o=0,l=(s=e?[e]:Object.keys(this._events)).length;o<l;o++)if(e=s[o],a=this._events[e]){if(this._events[e]=i=[],t||r)for(u=0,c=a.length;u<c;u++)n=a[u],(t&&t!==n.callback&&t!==n.callback._callback||r&&r!==n.context)&&i.push(n);i.length||delete this._events[e]}return this}},{key:"trigger",value:function(e){var t=this.name||this.constructor.name;if(ae.debug.apply(ae,[t].concat(Array.prototype.slice.call(arguments))),!this._events)return this;var r=se.call(arguments,1);if(!le(this,"trigger",e,r))return this;var i=this._events[e],n=this._events.all;return i&&ue(i,r,t,e),n&&ue(n,arguments,t,e),this}},{key:"stopListening",value:function(e,t,r){var i=this._listeningTo;if(!i)return this;var n=!t&&!r;for(var s in r||"object"!==a(t)||(r=this),e&&((i={})[e._listenId]=e),i)(e=i[s]).off(t,r,this),(n||0===Object.keys(e._events).length)&&delete this._listeningTo[s];return this}}],[{key:"register",value:function(t){e.Custom||(e.Custom={});var r="string"==typeof t&&t.toUpperCase().trim();r&&!e.Custom[r]?e.Custom[r]=r.toLowerCase().split("_").map((function(e,t){return 0===t?e:e=e[0].toUpperCase()+e.slice(1)})).join(""):ae.error("Events","Error when register event: "+t)}},{key:"listAvailableCustomEvents",value:function(){return e.Custom||(e.Custom={}),Object.keys(e.Custom).filter((function(t){return"string"==typeof e.Custom[t]}))}}]),e}(),de={listenTo:"on",listenToOnce:"once"};Object.keys(de).forEach((function(e){ce.prototype[e]=function(t,r,i){return(this._listeningTo||(this._listeningTo={}))[t._listenId||(t._listenId=W("l"))]=t,i||"object"!==a(r)||(i=this),t[de[e]](r,i,this),this}})),ce.PLAYER_READY="ready",ce.PLAYER_RESIZE="resize",ce.PLAYER_FULLSCREEN="fullscreen",ce.PLAYER_PLAY="play",ce.PLAYER_PAUSE="pause",ce.PLAYER_STOP="stop",ce.PLAYER_ENDED="ended",ce.PLAYER_SEEK="seek",ce.PLAYER_ERROR="playererror",ce.ERROR="error",ce.PLAYER_TIMEUPDATE="timeupdate",ce.PLAYER_VOLUMEUPDATE="volumeupdate",ce.PLAYER_SUBTITLE_AVAILABLE="subtitleavailable",ce.PLAYBACK_PROGRESS="playback:progress",ce.PLAYBACK_TIMEUPDATE="playback:timeupdate",ce.PLAYBACK_READY="playback:ready",ce.PLAYBACK_BUFFERING="playback:buffering",ce.PLAYBACK_BUFFERFULL="playback:bufferfull",ce.PLAYBACK_SETTINGSUPDATE="playback:settingsupdate",ce.PLAYBACK_LOADEDMETADATA="playback:loadedmetadata",ce.PLAYBACK_HIGHDEFINITIONUPDATE="playback:highdefinitionupdate",ce.PLAYBACK_BITRATE="playback:bitrate",ce.PLAYBACK_LEVELS_AVAILABLE="playback:levels:available",ce.PLAYBACK_LEVEL_SWITCH_START="playback:levels:switch:start",ce.PLAYBACK_LEVEL_SWITCH_END="playback:levels:switch:end",ce.PLAYBACK_PLAYBACKSTATE="playback:playbackstate",ce.PLAYBACK_DVR="playback:dvr",ce.PLAYBACK_MEDIACONTROL_DISABLE="playback:mediacontrol:disable",ce.PLAYBACK_MEDIACONTROL_ENABLE="playback:mediacontrol:enable",ce.PLAYBACK_ENDED="playback:ended",ce.PLAYBACK_PLAY_INTENT="playback:play:intent",ce.PLAYBACK_PLAY="playback:play",ce.PLAYBACK_PAUSE="playback:pause",ce.PLAYBACK_SEEK="playback:seek",ce.PLAYBACK_SEEKED="playback:seeked",ce.PLAYBACK_STOP="playback:stop",ce.PLAYBACK_ERROR="playback:error",ce.PLAYBACK_STATS_ADD="playback:stats:add",ce.PLAYBACK_FRAGMENT_LOADED="playback:fragment:loaded",ce.PLAYBACK_LEVEL_SWITCH="playback:level:switch",ce.PLAYBACK_SUBTITLE_AVAILABLE="playback:subtitle:available",ce.PLAYBACK_SUBTITLE_CHANGED="playback:subtitle:changed",ce.PLAYBACK_AUDIO_AVAILABLE="playback:audio:available",ce.PLAYBACK_AUDIO_CHANGED="playback:audio:changed",ce.CORE_CONTAINERS_CREATED="core:containers:created",ce.CORE_ACTIVE_CONTAINER_CHANGED="core:active:container:changed",ce.CORE_OPTIONS_CHANGE="core:options:change",ce.CORE_READY="core:ready",ce.CORE_FULLSCREEN="core:fullscreen",ce.CORE_RESIZE="core:resize",ce.CORE_SCREEN_ORIENTATION_CHANGED="core:screen:orientation:changed",ce.CORE_MOUSE_MOVE="core:mousemove",ce.CORE_MOUSE_LEAVE="core:mouseleave",ce.CONTAINER_PLAYBACKSTATE="container:playbackstate",ce.CONTAINER_PLAYBACKDVRSTATECHANGED="container:dvr",ce.CONTAINER_BITRATE="container:bitrate",ce.CONTAINER_STATS_REPORT="container:stats:report",ce.CONTAINER_DESTROYED="container:destroyed",ce.CONTAINER_READY="container:ready",ce.CONTAINER_RESIZE="container:resize",ce.CONTAINER_ERROR="container:error",ce.CONTAINER_LOADEDMETADATA="container:loadedmetadata",ce.CONTAINER_SUBTITLE_AVAILABLE="container:subtitle:available",ce.CONTAINER_SUBTITLE_CHANGED="container:subtitle:changed",ce.CONTAINER_AUDIO_AVAILABLE="container:audio:available",ce.CONTAINER_AUDIO_CHANGED="container:audio:changed",ce.CONTAINER_TIMEUPDATE="container:timeupdate",ce.CONTAINER_PROGRESS="container:progress",ce.CONTAINER_PLAY="container:play",ce.CONTAINER_STOP="container:stop",ce.CONTAINER_PAUSE="container:pause",ce.CONTAINER_ENDED="container:ended",ce.CONTAINER_CLICK="container:click",ce.CONTAINER_DBLCLICK="container:dblclick",ce.CONTAINER_CONTEXTMENU="container:contextmenu",ce.CONTAINER_MOUSE_ENTER="container:mouseenter",ce.CONTAINER_MOUSE_LEAVE="container:mouseleave",ce.CONTAINER_MOUSE_UP="container:mouseup",ce.CONTAINER_MOUSE_DOWN="container:mousedown",ce.CONTAINER_SEEK="container:seek",ce.CONTAINER_SEEKED="container:seeked",ce.CONTAINER_VOLUME="container:volume",ce.CONTAINER_FULLSCREEN="container:fullscreen",ce.CONTAINER_STATE_BUFFERING="container:state:buffering",ce.CONTAINER_STATE_BUFFERFULL="container:state:bufferfull",ce.CONTAINER_SETTINGSUPDATE="container:settingsupdate",ce.CONTAINER_HIGHDEFINITIONUPDATE="container:highdefinitionupdate",ce.CONTAINER_MEDIACONTROL_SHOW="container:mediacontrol:show",ce.CONTAINER_MEDIACONTROL_HIDE="container:mediacontrol:hide",ce.CONTAINER_MEDIACONTROL_DISABLE="container:mediacontrol:disable",ce.CONTAINER_MEDIACONTROL_ENABLE="container:mediacontrol:enable",ce.CONTAINER_STATS_ADD="container:stats:add",ce.CONTAINER_OPTIONS_CHANGE="container:options:change",ce.MEDIACONTROL_RENDERED="mediacontrol:rendered",ce.MEDIACONTROL_FULLSCREEN="mediacontrol:fullscreen",ce.MEDIACONTROL_SHOW="mediacontrol:show",ce.MEDIACONTROL_HIDE="mediacontrol:hide",ce.MEDIACONTROL_MOUSEMOVE_SEEKBAR="mediacontrol:mousemove:seekbar",ce.MEDIACONTROL_MOUSELEAVE_SEEKBAR="mediacontrol:mouseleave:seekbar",ce.MEDIACONTROL_PLAYING="mediacontrol:playing",ce.MEDIACONTROL_NOTPLAYING="mediacontrol:notplaying",ce.MEDIACONTROL_CONTAINERCHANGED="mediacontrol:containerchanged",ce.MEDIACONTROL_OPTIONS_CHANGE="mediacontrol:options:change";var he=function(e){c(r,e);var t=g(r);function r(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return s(this,r),(e=t.call(this,i))._options=i,e.uniqueId=W("o"),e}return l(r,[{key:"options",get:function(){return this._options}}]),r}(ce),fe={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},pe=/(.)^/,ge={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},ve=/\\|'|\r|\n|\t|\u2028|\u2029/g,me={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},ye=new RegExp("[&<>\"']","g"),Ae=function(e){return null===e?"":(""+e).replace(ye,(function(e){return me[e]}))},Ee=0,Te=function(e,t){var r,i=new RegExp([(fe.escape||pe).source,(fe.interpolate||pe).source,(fe.evaluate||pe).source].join("|")+"|$","g"),n=0,a="__p+='";e.replace(i,(function(t,r,i,s,o){return a+=e.slice(n,o).replace(ve,(function(e){return"\\"+ge[e]})),r&&(a+="'+\n((__t=("+r+"))==null?'':escapeExpr(__t))+\n'"),i&&(a+="'+\n((__t=("+i+"))==null?'':__t)+\n'"),s&&(a+="';\n"+s+"\n__p+='"),n=o+t.length,t})),a+="';\n",fe.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n//# sourceURL=/microtemplates/source["+Ee+++"]";try{r=new Function(fe.variable||"obj","escapeExpr",a)}catch(e){throw e.source=a,e}if(t)return r(t,Ae);var s=function(e){return r.call(this,e,Ae)};return s.source="function("+(fe.variable||"obj")+"){\n"+a+"}",s};Te.settings=fe;var be={getStyleFor:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{baseUrl:""};return R('<style class="clappr-style"></style>').html(Te(e.toString())(t))}},ke=/^(\S+)\s*(.*)$/,Se=function(e){c(r,e);var t=g(r);function r(e){var i;return s(this,r),(i=t.call(this,e)).cid=W("c"),i._ensureElement(),i.delegateEvents(),i}return l(r,[{key:"tagName",get:function(){return"div"}},{key:"events",get:function(){return{}}},{key:"attributes",get:function(){return{}}},{key:"$",value:function(e){return this.$el.find(e)}},{key:"render",value:function(){return this}},{key:"destroy",value:function(){return this.$el.remove(),this.stopListening(),this.undelegateEvents(),this}},{key:"setElement",value:function(e,t){return this.$el&&this.undelegateEvents(),this.$el=R.zepto.isZ(e)?e:R(e),this.el=this.$el[0],!1!==t&&this.delegateEvents(),this}},{key:"delegateEvents",value:function(e){for(var t in e||(e=this.events),this.undelegateEvents(),e){var r=e[t];if(r&&r.constructor!==Function&&(r=this[e[t]]),r){var i=t.match(ke),n=i[1],a=i[2];n+=".delegateEvents"+this.cid,""===a?this.$el.on(n,r.bind(this)):this.$el.on(n,a,r.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 e=R.extend(!0,{},this.attributes);this.id&&(e.id=this.id),this.className&&(e.class=this.className);var t=R(Z.create(this.tagName)).attr(e);this.setElement(t,!1)}}}]),r}(he),_e=function(e){c(r,e);var t=g(r);function r(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return s(this,r),(e=t.call(this,i)).core=n,e}return l(r,[{key:"name",get:function(){return"error"}},{key:"createError",value:function(e){this.core?this.core.trigger(ce.ERROR,e):ae.warn(this.name,"Core is not set. Error: ",e)}}],[{key:"Levels",get:function(){return{FATAL:"FATAL",WARN:"WARN",INFO:"INFO"}}}]),r}(he),Ce={createError:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{useCodePrefix:!0},r=this.constructor&&this.constructor.type||"",i=this.name||r,n=this.i18n||this.core&&this.core.i18n||this.container&&this.container.i18n,a="".concat(i,":").concat(e&&e.code||"unknown"),s={description:"",level:_e.Levels.FATAL,origin:i,scope:r,raw:{}},o=Object.assign({},s,e,{code:t.useCodePrefix?a:e.code});if(n&&o.level==_e.Levels.FATAL&&!o.UI){var l={title:n.t("default_error_title"),message:n.t("default_error_message")};o.UI=l}return this.playerError?this.playerError.createError(o):ae.warn(i,"PlayerError is not defined. Error: ",o),o}},Le=function(e){c(r,e);var t=g(r);function r(e){var i;return s(this,r),(i=t.call(this,e.options)).core=e,i.enabled=!0,i.bindEvents(),i.render(),i}return l(r,[{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}}]),r}(Se);Object.assign(Le.prototype,Ce),Le.extend=function(e){return V(Le,e)},Le.type="core";var De=function(e){c(r,e);var t=g(r);function r(e,i,n){var a;return s(this,r),(a=t.call(this,e))._i18n=i,a.currentTime=0,a.volume=100,a.playback=e.playback,a.playerError=n,a.settings=R.extend(!0,{},a.playback.settings),a.isReady=!1,a.mediaControlDisabled=!1,a.plugins=[a.playback],a.dblTapHandler=new Q(500),a.clickTimer=null,a.clickDelay=200,a.actionsMetadata={},a.bindEvents(),a}return l(r,[{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(e){this.playback.closedCaptionsTrackId=e}},{key:"audioTracks",get:function(){return this.playback.audioTracks}},{key:"currentAudioTrack",get:function(){return this.playback.currentAudioTrack}},{key:"bindEvents",value:function(){this.listenTo(this.playback,ce.PLAYBACK_PROGRESS,this.onProgress),this.listenTo(this.playback,ce.PLAYBACK_TIMEUPDATE,this.timeUpdated),this.listenTo(this.playback,ce.PLAYBACK_READY,this.ready),this.listenTo(this.playback,ce.PLAYBACK_BUFFERING,this.onBuffering),this.listenTo(this.playback,ce.PLAYBACK_BUFFERFULL,this.bufferfull),this.listenTo(this.playback,ce.PLAYBACK_SETTINGSUPDATE,this.settingsUpdate),this.listenTo(this.playback,ce.PLAYBACK_LOADEDMETADATA,this.loadedMetadata),this.listenTo(this.playback,ce.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinitionUpdate),this.listenTo(this.playback,ce.PLAYBACK_BITRATE,this.updateBitrate),this.listenTo(this.playback,ce.PLAYBACK_PLAYBACKSTATE,this.playbackStateChanged),this.listenTo(this.playback,ce.PLAYBACK_DVR,this.playbackDvrStateChanged),this.listenTo(this.playback,ce.PLAYBACK_MEDIACONTROL_DISABLE,this.disableMediaControl),this.listenTo(this.playback,ce.PLAYBACK_MEDIACONTROL_ENABLE,this.enableMediaControl),this.listenTo(this.playback,ce.PLAYBACK_SEEK,this.onSeek),this.listenTo(this.playback,ce.PLAYBACK_SEEKED,this.onSeeked),this.listenTo(this.playback,ce.PLAYBACK_ENDED,this.onEnded),this.listenTo(this.playback,ce.PLAYBACK_PLAY,this.playing),this.listenTo(this.playback,ce.PLAYBACK_PAUSE,this.paused),this.listenTo(this.playback,ce.PLAYBACK_STOP,this.stopped),this.listenTo(this.playback,ce.PLAYBACK_ERROR,this.error),this.listenTo(this.playback,ce.PLAYBACK_SUBTITLE_AVAILABLE,this.subtitleAvailable),this.listenTo(this.playback,ce.PLAYBACK_SUBTITLE_CHANGED,this.subtitleChanged),this.listenTo(this.playback,ce.PLAYBACK_AUDIO_AVAILABLE,this.audioAvailable),this.listenTo(this.playback,ce.PLAYBACK_AUDIO_CHANGED,this.audioChanged)}},{key:"subtitleAvailable",value:function(){this.trigger(ce.CONTAINER_SUBTITLE_AVAILABLE)}},{key:"subtitleChanged",value:function(e){this.trigger(ce.CONTAINER_SUBTITLE_CHANGED,e)}},{key:"audioAvailable",value:function(e){this.trigger(ce.CONTAINER_AUDIO_AVAILABLE,e)}},{key:"audioChanged",value:function(e){this.trigger(ce.CONTAINER_AUDIO_CHANGED,e)}},{key:"playbackStateChanged",value:function(e){this.trigger(ce.CONTAINER_PLAYBACKSTATE,e)}},{key:"playbackDvrStateChanged",value:function(e){this.settings=this.playback.settings,this.dvrInUse=e,this.trigger(ce.CONTAINER_PLAYBACKDVRSTATECHANGED,e)}},{key:"updateBitrate",value:function(e){this.trigger(ce.CONTAINER_BITRATE,e)}},{key:"statsReport",value:function(e){this.trigger(ce.CONTAINER_STATS_REPORT,e)}},{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(ce.CONTAINER_DESTROYED,this,this.name),this.stopListening(),this.plugins.forEach((function(e){return e.destroy()})),this.$el.remove()}},{key:"setStyle",value:function(e){this.$el.css(e)}},{key:"animate",value:function(e,t){return this.$el.animate(e,t).promise()}},{key:"ready",value:function(){this.isReady=!0,this.trigger(ce.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(e){this.isReady||this.ready(),this.trigger(ce.CONTAINER_ERROR,e,this.name)}},{key:"loadedMetadata",value:function(e){this.trigger(ce.CONTAINER_LOADEDMETADATA,e)}},{key:"timeUpdated",value:function(e){this.currentTime=e.current,this.trigger(ce.CONTAINER_TIMEUPDATE,e,this.name)}},{key:"onProgress",value:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.trigger.apply(this,[ce.CONTAINER_PROGRESS].concat(t,[this.name]))}},{key:"playing",value:function(){this.trigger(ce.CONTAINER_PLAY,this.name,this.actionsMetadata.playEvent||{}),this.actionsMetadata.playEvent={}}},{key:"paused",value:function(){this.trigger(ce.CONTAINER_PAUSE,this.name,this.actionsMetadata.pauseEvent||{}),this.actionsMetadata.pauseEvent={}}},{key:"stopped",value:function(){this.trigger(ce.CONTAINER_STOP,this.actionsMetadata.stopEvent||{}),this.actionsMetadata.stopEvent={}}},{key:"play",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.playEvent=e,this.playback.play(e)}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.stopEvent=e,this.playback.stop(e),this.currentTime=0}},{key:"switchAudioTrack",value:function(e){this.playback.switchAudioTrack(e)}},{key:"pause",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.actionsMetadata.pauseEvent=e,this.playback.pause(e)}},{key:"onEnded",value:function(){this.trigger(ce.CONTAINER_ENDED,this,this.name),this.currentTime=0}},{key:"clicked",value:function(){var e=this;this.options.chromeless&&!this.options.allowUserInteraction||(this.clickTimer=setTimeout((function(){e.clickTimer&&e.trigger(ce.CONTAINER_CLICK,e,e.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(ce.CONTAINER_DBLCLICK,this,this.name))}},{key:"dblTap",value:function(e){var t=this;this.options.chromeless&&!this.options.allowUserInteraction||this.dblTapHandler.handle(e,(function(){t.cancelClicked(),t.trigger(ce.CONTAINER_DBLCLICK,t,t.name)}))}},{key:"onContextMenu",value:function(e){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ce.CONTAINER_CONTEXTMENU,e,this.name)}},{key:"seek",value:function(e){this.playback.seek(e)}},{key:"onSeek",value:function(e){this.trigger(ce.CONTAINER_SEEK,e,this.name)}},{key:"onSeeked",value:function(){this.trigger(ce.CONTAINER_SEEKED,this.name)}},{key:"seekPercentage",value:function(e){var t=this.getDuration();if(e>=0&&e<=100){var r=t*(e/100);this.seek(r)}}},{key:"setVolume",value:function(e){this.volume=parseFloat(e),this.trigger(ce.CONTAINER_VOLUME,this.volume,this.name),this.playback.volume(this.volume)}},{key:"fullscreen",value:function(){this.trigger(ce.CONTAINER_FULLSCREEN,this.name)}},{key:"onBuffering",value:function(){this.trigger(ce.CONTAINER_STATE_BUFFERING,this.name)}},{key:"bufferfull",value:function(){this.trigger(ce.CONTAINER_STATE_BUFFERFULL,this.name)}},{key:"addPlugin",value:function(e){this.plugins.push(e)}},{key:"hasPlugin",value:function(e){return!!this.getPlugin(e)}},{key:"getPlugin",value:function(e){return this.plugins.filter((function(t){return t.name===e}))[0]}},{key:"mouseEnter",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ce.CONTAINER_MOUSE_ENTER)}},{key:"mouseLeave",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ce.CONTAINER_MOUSE_LEAVE)}},{key:"mouseUp",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ce.CONTAINER_MOUSE_UP)}},{key:"mouseDown",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ce.CONTAINER_MOUSE_DOWN)}},{key:"settingsUpdate",value:function(){this.settings=this.playback.settings,this.trigger(ce.CONTAINER_SETTINGSUPDATE)}},{key:"highDefinitionUpdate",value:function(e){this.trigger(ce.CONTAINER_HIGHDEFINITIONUPDATE,e)}},{key:"isHighDefinitionInUse",value:function(){return this.playback.isHighDefinitionInUse()}},{key:"disableMediaControl",value:function(){this.mediaControlDisabled||(this.mediaControlDisabled=!0,this.trigger(ce.CONTAINER_MEDIACONTROL_DISABLE))}},{key:"enableMediaControl",value:function(){this.mediaControlDisabled&&(this.mediaControlDisabled=!1,this.trigger(ce.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 e=this;this.disableResizeObserver(),this.resizeObserverInterval=setInterval((function(){return e.checkResize()}),500)}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval)}},{key:"checkResize",value:function(){var e={width:this.el.clientWidth,height:this.el.clientHeight},t=this.currentSize||{},r=t.width;(t.height!==e.height||r!==e.width)&&(this.currentSize=e,this.trigger(ce.CONTAINER_RESIZE,e))}},{key:"configure",value:function(e){this._options=R.extend(!0,this._options,e),this.updateStyle(),this.playback.configure(this.options),this.trigger(ce.CONTAINER_OPTIONS_CHANGE)}},{key:"render",value:function(){var e=be.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(e[0]),this.$el.append(this.playback.render().el),this.updateStyle(),this.checkResize(),this.enableResizeObserver(),this}}]),r}(Se);Object.assign(De.prototype,Ce);var Re=function(e){c(r,e);var t=g(r);function r(e,i,n){var a;return s(this,r),(a=t.call(this,e)).settings={},a._i18n=i,a.playerError=n,a._consented=!1,a}return l(r,[{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:"consent",value:function(e){"function"==typeof e&&e()}},{key:"play",value:function(){}},{key:"pause",value:function(){}},{key:"stop",value:function(){}},{key:"seek",value:function(e){}},{key:"seekPercentage",value:function(e){}},{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(e){}},{key:"audioTracks",get:function(){return[]}},{key:"currentAudioTrack",get:function(){return null}},{key:"switchAudioTrack",value:function(e){}},{key:"getPlaybackType",value:function(){return r.NO_OP}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"mute",value:function(){}},{key:"unmute",value:function(){}},{key:"volume",value:function(e){}},{key:"configure",value:function(e){this._options=R.extend(!0,this._options,e)}},{key:"attemptAutoPlay",value:function(){var e=this;this.canAutoPlay((function(t,r){t&&e.play()}))}},{key:"canAutoPlay",value:function(e){e(!0,null)}}]),r}(Se);Object.assign(Re.prototype,Ce),Re.extend=function(e){return V(Re,e)},Re.canPlay=function(e,t){return!1},Re.VOD="vod",Re.AOD="aod",Re.LIVE="live",Re.NO_OP="no_op",Re.type="playback";var Ie=function(e){c(r,e);var t=g(r);function r(e,i,n,a){var o;return s(this,r),(o=t.call(this,e))._i18n=n,o.loader=i,o.playerError=a,o}return l(r,[{key:"options",get:function(){return this._options},set:function(e){this._options=e}},{key:"createContainers",value:function(){var e=this;return R.Deferred((function(t){t.resolve(e.options.sources.map((function(t){return e.createContainer(t)})))}))}},{key:"findPlaybackPlugin",value:function(e,t){return this.loader.playbackPlugins.filter((function(r){return r.canPlay(e,t)}))[0]}},{key:"createContainer",value:function(e){var t=null,r=this.options.mimeType;"object"===a(e)?(t=e.source.toString(),e.mimeType&&(r=e.mimeType)):t=e.toString(),t.match(/^\/\//)&&(t=window.location.protocol+t);var i=n(n({},this.options),{},{src:t,mimeType:r}),s=this.findPlaybackPlugin(t,r),o=s?new s(i,this._i18n,this.playerError):new Re;i=n(n({},i),{},{playback:o});var l=new De(i,this._i18n,this.playerError),u=R.Deferred();return u.promise(l),this.addContainerPlugins(l),this.listenToOnce(l,ce.CONTAINER_READY,(function(){return u.resolve(l)})),l}},{key:"addContainerPlugins",value:function(e){this.loader.containerPlugins.forEach((function(t){e.addPlugin(new t(e))}))}}]),r}(he),Oe=function(e){c(r,e);var t=g(r);function r(e){var i;return s(this,r),(i=t.call(this,e)).playerError=new _e(e,f(i)),i.configureDomRecycler(),i.firstResize=!0,i.plugins=[],i.containers=[],i._boundFullscreenHandler=function(){return i.handleFullscreenChange()},R(document).bind("fullscreenchange",i._boundFullscreenHandler),R(document).bind("MSFullscreenChange",i._boundFullscreenHandler),R(document).bind("mozfullscreenchange",i._boundFullscreenHandler),w.isMobile&&R(window).bind("resize",(function(e){i.handleWindowResize(e)})),i}return l(r,[{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(e){return e}}}},{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 Le(this)),this._dummyMediaControl}},{key:"activeContainer",get:function(){return this._activeContainer},set:function(e){this._activeContainer=e,this.trigger(ce.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 e=this.options&&this.options.playback&&this.options.playback.recycleVideo;Z.configure({recycleVideo:e})}},{key:"createContainers",value:function(e){this.defer=R.Deferred(),this.defer.promise(this),this.containerFactory=new Ie(e,e.loader,this.i18n,this.playerError),this.prepareContainers()}},{key:"prepareContainers",value:function(){var e=this;this.containerFactory.createContainers().then((function(t){return e.setupContainers(t)})).then((function(t){return e.resolveOnContainersReady(t)}))}},{key:"updateSize",value:function(){this.isFullscreen()?this.setFullscreen():this.setPlayerSize()}},{key:"setFullscreen",value:function(){w.isiOS||(this.$el.addClass("fullscreen"),this.$el.removeAttr("style"),this.previousSize={width:this.options.width,height:this.options.height},this.currentSize={width:R(window).width(),height:R(window).height()})}},{key:"setPlayerSize",value:function(){this.$el.removeClass("fullscreen"),this.currentSize=this.previousSize,this.previousSize={width:R(window).width(),height:R(window).height()},this.resize(this.currentSize)}},{key:"resize",value:function(e){$(e.height)||$(e.width)?(this.el.style.height="".concat(e.height,"px"),this.el.style.width="".concat(e.width,"px")):(this.el.style.height="".concat(e.height),this.el.style.width="".concat(e.width)),this.previousSize={width:this.options.width,height:this.options.height},this.options.width=e.width,this.options.height=e.height,this.currentSize=e,this.triggerResize(this.currentSize)}},{key:"enableResizeObserver",value:function(){var e=this;this.disableResizeObserver();this.resizeObserverInterval=setInterval((function(){e.triggerResize({width:e.el.clientWidth,height:e.el.clientHeight})}),500)}},{key:"triggerResize",value:function(e){(this.firstResize||this.oldHeight!==e.height||this.oldWidth!==e.width)&&(this.oldHeight=e.height,this.oldWidth=e.width,this.computedSize=e,this.firstResize=!1,this.trigger(ce.CORE_RESIZE,e))}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval),this.resizeObserverInterval=null}},{key:"resolveOnContainersReady",value:function(e){var t=this;R.when.apply(R,e).done((function(){t.defer.resolve(t),t.ready=!0,t.trigger(ce.CORE_READY)}))}},{key:"addPlugin",value:function(e){this.plugins.push(e)}},{key:"hasPlugin",value:function(e){return!!this.getPlugin(e)}},{key:"getPlugin",value:function(e){return this.plugins.filter((function(t){return t.name===e}))[0]}},{key:"load",value:function(e,t){this.options.mimeType=t,e=e&&e.constructor===Array?e:[e],this.options.sources=e,this.containers.forEach((function(e){return e.destroy()})),this.containerFactory.options=R.extend(!0,this.options,{sources:e}),this.prepareContainers()}},{key:"destroy",value:function(){this.disableResizeObserver(),this.containers.forEach((function(e){return e.destroy()})),this.plugins.forEach((function(e){return e.destroy()})),this.$el.remove(),R(document).unbind("fullscreenchange",this._boundFullscreenHandler),R(document).unbind("MSFullscreenChange",this._boundFullscreenHandler),R(document).unbind("mozfullscreenchange",this._boundFullscreenHandler),this.stopListening()}},{key:"handleFullscreenChange",value:function(){this.trigger(ce.CORE_FULLSCREEN,this.isFullscreen()),this.updateSize()}},{key:"handleWindowResize",value:function(e){var t=window.innerWidth>window.innerHeight?"landscape":"portrait";this._screenOrientation!==t&&(this._screenOrientation=t,this.triggerResize({width:this.el.clientWidth,height:this.el.clientHeight}),this.trigger(ce.CORE_SCREEN_ORIENTATION_CHANGED,{event:e,orientation:this._screenOrientation}))}},{key:"removeContainer",value:function(e){this.stopListening(e),this.containers=this.containers.filter((function(t){return t!==e}))}},{key:"setupContainer",value:function(e){this.listenTo(e,ce.CONTAINER_DESTROYED,this.removeContainer),this.containers.push(e)}},{key:"setupContainers",value:function(e){return e.forEach(this.setupContainer.bind(this)),this.trigger(ce.CORE_CONTAINERS_CREATED),this.renderContainers(),this.activeContainer=e[0],this.render(),this.appendToParent(),this.containers}},{key:"renderContainers",value:function(){var e=this;this.containers.forEach((function(t){return e.el.appendChild(t.render().el)}))}},{key:"createContainer",value:function(e,t){var r=this.containerFactory.createContainer(e,t);return this.setupContainer(r),this.el.appendChild(r.render().el),r}},{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 e=K.fullscreenElement();return e&&e===this.el||e&&e===this.activePlaybackEl||this.activePlaybackEl&&this.activePlaybackEl.webkitDisplayingFullscreen||!1}},{key:"toggleFullscreen",value:function(){var e=this;if(this.isFullscreen()){var t=w.isiOS?this.activePlaybackEl:document;K.cancelFullscreen(t),!w.isiOS&&this.$el.removeClass("fullscreen nocursor")}else{var r=w.isiOS?this.activePlaybackEl:this.el;if(!r)return;w.isSafari||w.isiOS?K.requestFullscreen(r):K.requestFullscreen(r).then((function(e){return e}),(function(t){return setTimeout((function(){if(!e.isFullscreen())throw new ReferenceError(t)}),600)})),!w.isiOS&&this.$el.addClass("fullscreen")}}},{key:"onMouseMove",value:function(e){this.trigger(ce.CORE_MOUSE_MOVE,e)}},{key:"onMouseLeave",value:function(e){this.trigger(ce.CORE_MOUSE_LEAVE,e)}},{key:"configure",value:function(e){var t=this;this._options=R.extend(!0,this._options,e),this.configureDomRecycler();var r=e.source||e.sources;r&&this.load(r,e.mimeType||this.options.mimeType),this.trigger(ce.CORE_OPTIONS_CHANGE,e),this.containers.forEach((function(e){return e.configure(t.options)}))}},{key:"appendToParent",value:function(){var e=be.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}),t=be.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.options.includeResetStyle&&this.$el.append(t[0]),!(this.$el.parent()&&this.$el.parent().length)&&this.$el.appendTo(this.options.parentElement)}},{key:"render",value:function(){this.options.width=this.options.width||this.$el.width(),this.options.height=this.options.height||this.$el.height();var e={width:this.options.width,height:this.options.height};return this.previousSize=this.currentSize=this.computedSize=e,this.updateSize(),this.enableResizeObserver(),this}}]),r}(Se);Object.assign(Oe.prototype,Ce);var we,Pe,xe=function(e){c(r,e);var t=g(r);function r(e){var i;return s(this,r),(i=t.call(this,e.options)).player=e,i}return l(r,[{key:"loader",get:function(){return this.player.loader}},{key:"create",value:function(){return this.options.loader=this.loader,this.core=new Oe(this.options),this.addCorePlugins(),this.core.createContainers(this.options),this.core}},{key:"addCorePlugins",value:function(){var e=this;return this.loader.corePlugins.forEach((function(t){var r=new t(e.core);e.core.addPlugin(r),e.setupExternalInterface(r)})),this.core}},{key:"setupExternalInterface",value:function(e){var t=e.getExternalInterface();for(var r in t)this.player[r]=t[r].bind(e)}}]),r}(he),Ne=/(\d+)(?:\.(\d+))?(?:\.(\d+))?/,Fe=function(){function e(t,r,i){s(this,e),this.major=parseInt(t||0,10),this.minor=parseInt(r||0,10),this.patch=parseInt(i||0,10)}return l(e,[{key:"compare",value:function(e){var t=this.major-e.major;return t=(t=t||this.minor-e.minor)||this.patch-e.patch}},{key:"inc",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"patch";return void 0!==this[e]&&(this[e]+=1),this}},{key:"satisfies",value:function(e,t){return this.compare(e)>=0&&(!t||this.compare(t)<0)}},{key:"toString",value:function(){return"".concat(this.major,".").concat(this.minor,".").concat(this.patch)}}],[{key:"parse",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=t.match(Ne)||[],i=y(r,4),n=i[1],a=i[2],s=i[3];return void 0===n?null:new e(n,a,s)}}]),e}(),Me=function(e,t){return e&&t?Object.entries(e).filter((function(e){return y(e,2)[1].type===t})).reduce((function(e,t){var r=y(t,2),i=r[0],n=r[1];return e[i]=n,e}),{}):{}},Be=(we={plugins:{},playbacks:[]},Pe="0.4.27",function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;s(this,e),this.playerId=r,this.playbackPlugins=A(we.playbacks);var i=e.registeredPlugins,n=i.core,a=i.container;this.containerPlugins=Object.values(a),this.corePlugins=Object.values(n),Array.isArray(t)||this.validateExternalPluginsType(t),this.addExternalPlugins(t)}return l(e,[{key:"groupPluginsByType",value:function(e){return Array.isArray(e)&&(e=e.reduce((function(e,t){return e[t.type]||(e[t.type]=[]),e[t.type].push(t),e}),{})),e}},{key:"removeDups",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=function(e,r){return e[r.prototype.name]&&t||(e[r.prototype.name]&&delete e[r.prototype.name],e[r.prototype.name]=r),e},i=e.reduceRight(r,Object.create(null)),n=[];for(var a in i)n.unshift(i[a]);return n}},{key:"addExternalPlugins",value:function(t){var r="boolean"!=typeof t.loadExternalPluginsFirst||t.loadExternalPluginsFirst,i="boolean"!=typeof t.loadExternalPlaybacksFirst||t.loadExternalPlaybacksFirst;if((t=this.groupPluginsByType(t)).playback){var n=t.playback.filter((function(t){return e.checkVersionSupport(t),!0}));this.playbackPlugins=i?this.removeDups(n.concat(this.playbackPlugins)):this.removeDups(this.playbackPlugins.concat(n),!0)}if(t.container){var a=t.container.filter((function(t){return e.checkVersionSupport(t),!0}));this.containerPlugins=r?this.removeDups(a.concat(this.containerPlugins)):this.removeDups(this.containerPlugins.concat(a),!0)}if(t.core){var s=t.core.filter((function(t){return e.checkVersionSupport(t),!0}));this.corePlugins=r?this.removeDups(s.concat(this.corePlugins)):this.removeDups(this.corePlugins.concat(s),!0)}}},{key:"validateExternalPluginsType",value:function(e){["playback","container","core"].forEach((function(t){(e[t]||[]).forEach((function(e){var r="external "+e.type+" plugin on "+t+" array";if(e.type!==t)throw new ReferenceError(r)}))}))}}],[{key:"registeredPlaybacks",get:function(){return A(we.playbacks)}},{key:"registeredPlugins",get:function(){var e=we.plugins;return{core:Me(e,"core"),container:Me(e,"container")}}},{key:"checkVersionSupport",value:function(e){var t=e.prototype,r=t.supportedVersion,i=t.name;if(!r||!r.min)return ae.warn("Loader","missing version information for ".concat(i)),!1;var n=r.max?Fe.parse(r.max):Fe.parse(r.min).inc("minor"),a=Fe.parse(r.min);return!!Fe.parse(Pe).satisfies(a,n)||(ae.warn("Loader","unsupported plugin ".concat(i,": Clappr version ").concat(Pe," does not match required range [").concat(a,",").concat(n,")")),!1)}},{key:"registerPlugin",value:function(t){if(!t||!t.prototype.name)return ae.warn("Loader","missing information to register plugin: ".concat(t)),!1;e.checkVersionSupport(t);var r=we.plugins;if(!r)return!1;var i=r[t.prototype.name];return i&&ae.warn("Loader","overriding plugin entry: ".concat(t.prototype.name," - ").concat(i)),r[t.prototype.name]=t,!0}},{key:"registerPlayback",value:function(t){if(!t||!t.prototype.name)return!1;e.checkVersionSupport(t);var r=we.playbacks,i=r.findIndex((function(e){return e.prototype.name===t.prototype.name}));if(i>=0){var n=r[i];r.splice(i,1),ae.warn("Loader","overriding playback entry: ".concat(n.name," - ").concat(n))}return we.playbacks=[t].concat(A(r)),!0}},{key:"unregisterPlugin",value:function(e){if(!e)return!1;var t=we.plugins;return!!t[e]&&(delete t[e],!0)}},{key:"unregisterPlayback",value:function(e){if(!e)return!1;var t=we.playbacks,r=t.findIndex((function(t){return t.prototype.name===e}));return!(r<0||(t.splice(r,1),we.playbacks=t,0))}},{key:"clearPlugins",value:function(){we.plugins={}}},{key:"clearPlaybacks",value:function(){we.playbacks=[]}}]),e}()),Ue=z().replace(/\/[^/]+$/,""),Ge=function(e){c(r,e);var t=g(r);function r(e){var i;s(this,r),i=t.call(this,e);var n={playerId:W(""),persistConfig:!0,width:640,height:360,baseUrl:Ue,allowUserInteraction:w.isMobile,includeResetStyle:!0,playback:{recycleVideo:!0}};i._options=R.extend(!0,n,e),i.options.sources=i._normalizeSources(e),i.options.chromeless||(i.options.allowUserInteraction=!0),i.options.allowUserInteraction||(i.options.disableKeyboardShortcuts=!0),i._registerOptionEventListeners(i.options.events),i._coreFactory=new xe(f(i));var a=i._getParentElement(i.options);return a&&i.attachTo(a),i}return l(r,[{key:"loader",get:function(){return this._loader||(this._loader=new Be(this.options.plugins||{},this.options.playerId)),this._loader},set:function(e){this._loader=e}},{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:ce.PLAYER_READY,onResize:ce.PLAYER_RESIZE,onPlay:ce.PLAYER_PLAY,onPause:ce.PLAYER_PAUSE,onStop:ce.PLAYER_STOP,onEnded:ce.PLAYER_ENDED,onSeek:ce.PLAYER_SEEK,onError:ce.PLAYER_ERROR,onTimeUpdate:ce.PLAYER_TIMEUPDATE,onVolumeUpdate:ce.PLAYER_VOLUMEUPDATE,onSubtitleAvailable:ce.PLAYER_SUBTITLE_AVAILABLE}}},{key:"_getParentElement",value:function(e){var t=e.parentId,r=e.parent;return t?document.querySelector(t):r}},{key:"attachTo",value:function(e){return this.options.parentElement=e,this.core=this._coreFactory.create(),this._addEventListeners(),this}},{key:"_addEventListeners",value:function(){return this.core.isReady?this._onReady():this.listenToOnce(this.core,ce.CORE_READY,this._onReady),this.listenTo(this.core,ce.CORE_ACTIVE_CONTAINER_CHANGED,this._containerChanged),this.listenTo(this.core,ce.CORE_FULLSCREEN,this._onFullscreenChange),this.listenTo(this.core,ce.CORE_RESIZE,this._onResize),this}},{key:"_addContainerEventListeners",value:function(){var e=this.core.activeContainer;return e&&(this.listenTo(e,ce.CONTAINER_PLAY,this._onPlay),this.listenTo(e,ce.CONTAINER_PAUSE,this._onPause),this.listenTo(e,ce.CONTAINER_STOP,this._onStop),this.listenTo(e,ce.CONTAINER_ENDED,this._onEnded),this.listenTo(e,ce.CONTAINER_SEEK,this._onSeek),this.listenTo(e,ce.CONTAINER_ERROR,this._onError),this.listenTo(e,ce.CONTAINER_TIMEUPDATE,this._onTimeUpdate),this.listenTo(e,ce.CONTAINER_VOLUME,this._onVolumeUpdate),this.listenTo(e,ce.CONTAINER_SUBTITLE_AVAILABLE,this._onSubtitleAvailable)),this}},{key:"_registerOptionEventListeners",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Object.keys(t).length>0;return i&&Object.keys(r).forEach((function(t){var i=e.eventsMapping[t];i&&e.off(i,r[t])})),Object.keys(t).forEach((function(r){var i=e.eventsMapping[r];if(i){var n=t[r];(n="function"==typeof n&&n)&&e.on(i,n)}})),this}},{key:"_containerChanged",value:function(){this.stopListening(),this._addEventListeners()}},{key:"_onReady",value:function(){this._ready=!0,this._addContainerEventListeners(),this.trigger(ce.PLAYER_READY)}},{key:"_onFullscreenChange",value:function(e){this.trigger(ce.PLAYER_FULLSCREEN,e)}},{key:"_onVolumeUpdate",value:function(e){this.trigger(ce.PLAYER_VOLUMEUPDATE,e)}},{key:"_onSubtitleAvailable",value:function(){this.trigger(ce.PLAYER_SUBTITLE_AVAILABLE)}},{key:"_onResize",value:function(e){this.trigger(ce.PLAYER_RESIZE,e)}},{key:"_onPlay",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.trigger(ce.PLAYER_PLAY,t)}},{key:"_onPause",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.trigger(ce.PLAYER_PAUSE,t)}},{key:"_onStop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.trigger(ce.PLAYER_STOP,this.getCurrentTime(),e)}},{key:"_onEnded",value:function(){this.trigger(ce.PLAYER_ENDED)}},{key:"_onSeek",value:function(e){this.trigger(ce.PLAYER_SEEK,e)}},{key:"_onTimeUpdate",value:function(e){this.trigger(ce.PLAYER_TIMEUPDATE,e)}},{key:"_onError",value:function(e){this.trigger(ce.PLAYER_ERROR,e)}},{key:"_normalizeSources",value:function(e){var t=e.sources||(void 0!==e.source?[e.source]:[]);return 0===t.length?[{source:"",mimeType:""}]:t}},{key:"resize",value:function(e){return this.core.resize(e),this}},{key:"load",value:function(e,t,r){return void 0!==r&&this.configure({autoPlay:!!r}),this.core.load(e,t),this}},{key:"destroy",value:function(){return this.stopListening(),this.core.destroy(),this}},{key:"consent",value:function(e){this.core.getCurrentPlayback().consent(e)}},{key:"play",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.play(e),this}},{key:"pause",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.pause(e),this}},{key:"stop",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.core.activeContainer.stop(e),this}},{key:"seek",value:function(e){return this.core.activeContainer.seek(e),this}},{key:"seekPercentage",value:function(e){return this.core.activeContainer.seekPercentage(e),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 e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._registerOptionEventListeners(e.events,this.options.events),this.core.configure(e),this}},{key:"getPlugin",value:function(e){return this.core.plugins.concat(this.core.activeContainer.plugins).filter((function(t){return t.name===e}))[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()}}]),r}(he);Object.assign(Ge.prototype,Ce);var Ve=function(e){c(r,e);var t=g(r);function r(e){var i;return s(this,r),(i=t.call(this,e.options)).container=e,i.enabled=!0,i.bindEvents(),i}return l(r,[{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()}}]),r}(he);Object.assign(Ve.prototype,Ce),Ve.extend=function(e){return V(Ve,e)},Ve.type="container";var Ke=function(e){c(r,e);var t=g(r);function r(e){var i;return s(this,r),(i=t.call(this,e.options)).core=e,i.enabled=!0,i.bindEvents(),i}return l(r,[{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()}}]),r}(he);Object.assign(Ke.prototype,Ce),Ke.extend=function(e){return V(Ke,e)},Ke.type="core";var je=function(e){c(r,e);var t=g(r);function r(e){var i;return s(this,r),(i=t.call(this,e.options)).container=e,i.enabled=!0,i.bindEvents(),i}return l(r,[{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(){}}]),r}(Se);Object.assign(je.prototype,Ce),je.extend=function(e){return V(je,e)},je.type="container";var He={mp4:["avc1.42E01E","avc1.58A01E","avc1.4D401E","avc1.64001E","mp4v.20.8","mp4v.20.240","mp4a.40.2"].map((function(e){return'video/mp4; codecs="'+e+', 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"]};He.ogv=He.ogg,He["3gp"]=He["3gpp"];var Ye={wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},We=Object.keys(Ye).reduce((function(e,t){return[].concat(A(e),A(Ye[t]))}),[]),$e={code:"unknown",message:"unknown"},ze=function(e){c(r,e);var t=g(r);function r(){var e;s(this,r);for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];(e=t.call.apply(t,[this].concat(n)))._destroyed=!1,e._loadStarted=!1,e._isBuffering=!1,e._playheadMoving=!1,e._playheadMovingTimer=null,e._stopped=!1,e._ccTrackId=-1,e._setupSrc(e.options.src),e.options.playback||(e.options.playback=e.options||{}),e.options.playback.disableContextMenu=e.options.playback.disableContextMenu||e.options.disableVideoTagContextMenu,e._minDvrSize=e.isValidMinimumDVRSizeConfig?e.minimumDVRSizeConfig:60;var o,l=e.options.playback,u=l.preload||(w.isSafari?"auto":e.options.preload);return e.options.poster&&("string"==typeof e.options.poster?o=e.options.poster:"string"==typeof e.options.poster.url&&(o=e.options.poster.url)),R.extend(!0,e.el,{muted:e.options.mute,defaultMuted:e.options.mute,loop:e.options.loop,poster:o,preload:u||"metadata",crossOrigin:l.crossOrigin,"x-webkit-playsinline":l.playInline}),(l.controls||e.options.useVideoTagDefaultControls)&&e.$el.attr("controls",""),l.playInline&&e.$el.attr({playsinline:"playsinline"}),l.crossOrigin&&e.$el.attr({crossorigin:l.crossOrigin}),e.settings={default:["seekbar"]},e.settings.left=["playpause","position","duration"],e.settings.right=["fullscreen","volume","hd-indicator"],l.externalTracks&&e._setupExternalTracks(l.externalTracks),e.options.autoPlay&&e.attemptAutoPlay(),e}return l(r,[{key:"name",get:function(){return"html5_video"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"tagName",get:function(){return this.isAudioOnly?"audio":"video"}},{key:"isAudioOnly",get:function(){var e=this.options.src,t=r._mimeTypesForUrl(e,Ye,this.options.mimeType);return this.options.playback&&this.options.playback.audioOnly||this.options.audioOnly||We.indexOf(t[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"}}},{key:"ended",get:function(){return this.el.ended}},{key:"buffering",get:function(){return this._isBuffering}},{key:"isLive",get:function(){return this.getPlaybackType()===Re.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:"configure",value:function(e){m(d(r.prototype),"configure",this).call(this,e),this.el.loop=!!e.loop}},{key:"attemptAutoPlay",value:function(){var e=this;this.canAutoPlay((function(t,r){r&&ae.warn(e.name,"autoplay error.",{result:t,error:r}),t&&setTimeout((function(){return!e._destroyed&&e.play()}),0)}))}},{key:"canAutoPlay",value:function(e){if(this.options.disableCanAutoPlay)e(!0,null);else{var t={timeout:this.options.autoPlayTimeout||500,inline:this.options.playback.playInline||!1,muted:this.options.mute||!1};w.isMobile&&Z.options.recycleVideo&&(t.element=this.el),X(e,t)}}},{key:"_setupExternalTracks",value:function(e){this._externalTracks=e.map((function(e){return{kind:e.kind||"subtitles",label:e.label,lang:e.lang,src:e.src}}))}},{key:"_setupSrc",value:function(e){this.el.src!==e&&(this._ccIsSetup=!1,this.el.src=e,this._src=this.el.src)}},{key:"_onLoadedMetadata",value:function(e){this._handleBufferingEvents(),this.trigger(ce.PLAYBACK_LOADEDMETADATA,{duration:e.target.duration,data:e}),this._updateSettings();var t=void 0===this._options.autoSeekFromUrl||this._options.autoSeekFromUrl;this.getPlaybackType()!==Re.LIVE&&t&&this._checkInitialSeek()}},{key:"_onDurationChange",value:function(){this._updateSettings(),this._onTimeUpdate(),this._onProgress()}},{key:"_updateSettings",value:function(){this.getPlaybackType()===Re.VOD||this.getPlaybackType()===Re.AOD?this.settings.left=["playpause","position","duration"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(ce.PLAYBACK_SETTINGSUPDATE)}},{key:"isSeekEnabled",value:function(){return isFinite(this.getDuration())}},{key:"getPlaybackType",value:function(){var e="audio"===this.tagName?Re.AOD:Re.VOD;return[0,void 0,1/0].indexOf(this.el.duration)>=0?Re.LIVE:e}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"consent",value:function(e){var t=this;if(this.isPlaying()||this.el._consented)m(d(r.prototype),"consent",this).call(this,e);else{var i=function i(){t.el.removeEventListener("loadedmetadata",i,!1),t.el.removeEventListener("error",i,!1),t.el._consented=!0,m(d(r.prototype),"consent",t).call(t,e)};this.el.addEventListener("loadedmetadata",i,!1),this.el.addEventListener("error",i,!1),this.el.load()}}},{key:"play",value:function(){this.trigger(ce.PLAYBACK_PLAY_INTENT),this._stopped=!1,this._setupSrc(this._src),this._handleBufferingEvents();var e=this.el.play();e&&e.catch&&e.catch((function(){}))}},{key:"pause",value:function(){this.el.pause(),this.dvrEnabled&&this._updateDvr(!0)}},{key:"stop",value:function(){this.pause(),this._stopped=!0,this.el.removeAttribute("src"),this.el.load(),this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(ce.PLAYBACK_STOP)}},{key:"volume",value:function(e){0===e?(this.$el.attr({muted:"true"}),this.el.muted=!0):(this.$el.attr({muted:null}),this.el.muted=!1,this.el.volume=e/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._playheadMovingTimeOnCheck=null,this._determineIfPlayheadMoving(),this._playheadMovingTimer=setInterval(this._determineIfPlayheadMoving.bind(this),500))}},{key:"_stopPlayheadMovingChecks",value:function(){null!==this._playheadMovingTimer&&(clearInterval(this._playheadMovingTimer),this._playheadMovingTimer=null,this._playheadMoving=!1)}},{key:"_determineIfPlayheadMoving",value:function(){var e=this._playheadMovingTimeOnCheck,t=this.el.currentTime;this._playheadMoving=e!==t,this._playheadMovingTimeOnCheck=t,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(ce.PLAYBACK_PLAY)}},{key:"_onPause",value:function(){this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(ce.PLAYBACK_PAUSE)}},{key:"_onSeeking",value:function(){this.trigger(ce.PLAYBACK_SEEK,this.getCurrentTime()),this._handleBufferingEvents()}},{key:"_onSeeked",value:function(){this._handleBufferingEvents(),this.trigger(ce.PLAYBACK_SEEKED)}},{key:"_onEnded",value:function(){this._handleBufferingEvents(),this.trigger(ce.PLAYBACK_ENDED,this.name)}},{key:"_handleBufferingEvents",value:function(){var e=!this.el.ended&&!this.el.paused,t=this._loadStarted&&!this.el.ended&&!this._stopped&&(e&&!this._playheadMoving||this.el.readyState<this.el.HAVE_FUTURE_DATA);this._isBuffering!==t&&(this._isBuffering=t,t?this.trigger(ce.PLAYBACK_BUFFERING,this.name):this.trigger(ce.PLAYBACK_BUFFERFULL,this.name))}},{key:"_onError",value:function(){var e=this.el.error||$e,t=e.code,r=e.message,i=t===$e.code,n=this.createError({code:t,description:r,raw:this.el.error,level:i?_e.Levels.WARN:_e.Levels.FATAL});i?ae.warn(this.name,"HTML5 unknown error: ",n):this.trigger(ce.PLAYBACK_ERROR,n)}},{key:"destroy",value:function(){this._destroyed=!0,this.handleTextTrackChange&&this.el.textTracks.removeEventListener("change",this.handleTextTrackChange),m(d(r.prototype),"destroy",this).call(this),this.el.removeAttribute("src"),this.el.load(),this._src=null,Z.garbage(this.el)}},{key:"_updateDvr",value:function(e){this.trigger(ce.PLAYBACK_DVR,e),this.trigger(ce.PLAYBACK_STATS_ADD,{dvr:e})}},{key:"seek",value:function(e){e<0&&(ae.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),e=this.getDuration()),this.dvrEnabled&&this._updateDvr(e<this.getDuration()-3),e+=this.el.seekable.start(0),this.el.currentTime=e}},{key:"seekPercentage",value:function(e){var t=this.el.duration*(e/100);this.seek(t)}},{key:"_checkInitialSeek",value:function(){var e=Y();0!==e&&this.seek(e)}},{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 e=this;this._updateSettingsCheckInFlight||(this._updateSettingsCheckInFlight=setTimeout((function(){e._updateSettings(),e._updateSettingsCheckInFlight=null}),1e3))}},{key:"_onTimeUpdate",value:function(){var e=this.isLive?this.getDuration():this.el.duration;this.trigger(ce.PLAYBACK_TIMEUPDATE,{current:this.el.currentTime,total:e},this.name)}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var e=[],t=0,r=0;r<this.el.buffered.length;r++)e=[].concat(A(e),[{start:this.el.buffered.start(r),end:this.el.buffered.end(r)}]),this.el.currentTime>=e[r].start&&this.el.currentTime<=e[r].end&&(t=r);var i={start:e[t].start,current:e[t].end,total:this.el.duration};this.trigger(ce.PLAYBACK_PROGRESS,i,e)}}},{key:"_typeFor",value:function(e){var t=r._mimeTypesForUrl(e,He,this.options.mimeType);return 0===t.length&&(t=r._mimeTypesForUrl(e,Ye,this.options.mimeType)),(t[0]||"").split(";")[0]}},{key:"_ready",value:function(){this._isReadyState||(this._isReadyState=!0,this.trigger(ce.PLAYBACK_READY,this.name))}},{key:"_checkForClosedCaptions",value:function(){if(this.isHTML5Video&&!this._ccIsSetup){if(this.hasClosedCaptionsTracks){this.trigger(ce.PLAYBACK_SUBTITLE_AVAILABLE);var e=this.closedCaptionsTrackId;this.closedCaptionsTrackId=e,this.handleTextTrackChange=this._handleTextTrackChange.bind(this),this.el.textTracks.addEventListener("change",this.handleTextTrackChange)}this._ccIsSetup=!0}}},{key:"_handleTextTrackChange",value:function(){var e=this.closedCaptionsTracks.find((function(e){return"showing"===e.track.mode}))||{id:-1};this._ccTrackId!==e.id&&(this._ccTrackId=e.id,this.trigger(ce.PLAYBACK_SUBTITLE_CHANGED,{id:e.id}))}},{key:"isHTML5Video",get:function(){return this.name===r.prototype.name}},{key:"closedCaptionsTracks",get:function(){var e=0;return(this.el.textTracks?Array.from(this.el.textTracks):[]).filter((function(e){return"subtitles"===e.kind||"captions"===e.kind})).map((function(t){return{id:e++,name:t.label,track:t}}))}},{key:"closedCaptionsTrackId",get:function(){return this._ccTrackId},set:function(e){if($(e)){var t,r=this.closedCaptionsTracks;if(-1!==e){if(!(t=r.find((function(t){return t.id===e}))))return;if("showing"===t.track.mode)return}r.filter((function(e){return"hidden"!==e.track.mode})).forEach((function(e){return e.track.mode="hidden"})),t&&(t.track.mode="showing"),this._ccTrackId=e,this.trigger(ce.PLAYBACK_SUBTITLE_CHANGED,{id:e})}}},{key:"template",get:function(){return Te('<% 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 e=be.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(e[0]),this}}]),r}(Re);ze._mimeTypesForUrl=function(e,t,r){var i=(e.split("?")[0].match(/.*\.(.*)$/)||[])[1],n=r||i&&t[i.toLowerCase()]||[];return n.constructor===Array?n:[n]},ze._canPlay=function(e,t,r,i){var n=ze._mimeTypesForUrl(r,t,i),a=document.createElement(e);return!!n.filter((function(e){return!!a.canPlayType(e).replace(/no/,"")}))[0]},ze.canPlay=function(e,t){return ze._canPlay("audio",Ye,e,t)||ze._canPlay("video",He,e,t)};var qe=function(e){c(r,e);var t=g(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"name",get:function(){return"html5_audio"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{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(ce.PLAYBACK_SETTINGSUPDATE)}},{key:"getPlaybackType",value:function(){return Re.AOD}}]),r}(ze);qe.canPlay=function(e,t){return ze._canPlay("audio",{wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},e,t)};var Xe=function(e){c(r,e);var t=g(r);function r(e){var i;return s(this,r),(i=t.call(this,e)).el.src=e.src,i}return l(r,[{key:"name",get:function(){return"html_img"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{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 Re.NO_OP}},{key:"render",value:function(){var e=be.getStyleFor("[data-html-img] {\n max-width: 100%;\n max-height: 100%; }\n".toString(),{baseUrl:this.options.baseUrl});return this.$el.append(e[0]),this.trigger(ce.PLAYBACK_READY,this.name),this}},{key:"_onLoad",value:function(){this.trigger(ce.PLAYBACK_ENDED,this.name)}},{key:"_onError",value:function(e){var t="error"===e.type?"load error":"loading aborted";this.trigger(ce.PLAYBACK_ERROR,{message:t},this.name)}}]),r}(Re);Xe.canPlay=function(e){return/\.(png|jpg|jpeg|gif|bmp|tiff|pgm|pnm|webp)(|\?.*)$/i.test(e)};var Ze=function(e){c(r,e);var t=g(r);function r(){var e;s(this,r);for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];return(e=t.call.apply(t,[this].concat(n)))._noiseFrameNum=-1,e}return l(r,[{key:"name",get:function(){return"no_op"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"template",get:function(){return Te("<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 e=this.options.playbackNotSupportedMessage||this.i18n.t("playback_not_supported"),t=be.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(t[0]),this.$el.html(this.template({message:e})),this.trigger(ce.PLAYBACK_READY,this.name);var r=!(!this.options.poster||!this.options.poster.showForNoOp);return!this.options.autoPlay&&r||this._animate(),this}},{key:"_noise",value:function(){if(this._noiseFrameNum=(this._noiseFrameNum+1)%5,!this._noiseFrameNum){var e,t=this.context.createImageData(this.context.canvas.width,this.context.canvas.height);try{e=new Uint32Array(t.data.buffer)}catch(n){e=new Uint32Array(this.context.canvas.width*this.context.canvas.height*4);for(var r=t.data,i=0;i<r.length;i++)e[i]=r[i]}for(var n=e.length,a=6*Math.random()+4,s=0,o=0,l=0;l<n;){if(s<0)s=a*Math.random(),o=255*Math.pow(Math.random(),.4)<<24;s-=1,e[l++]=o}this.context.putImageData(t,0,0)}}},{key:"_loop",value:function(){var e=this;this._stop||(this._noise(),this._animationHandle=B((function(){return e._loop()})))}},{key:"destroy",value:function(){this._animationHandle&&(U(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()}}]),r}(Re);Ze.canPlay=function(e){return!0};var Qe=function(e){c(r,e);var t=g(r);function r(e){var i;return s(this,r),(i=t.call(this,e))._initializeMessages(),i}return l(r,[{key:"name",get:function(){return"strings"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"t",value:function(e){var t=this._language(),r=this._messages.en;return(t&&this._messages[t]||r)[e]||r[e]||e}},{key:"_language",value:function(){return this.core.options.language||q()}},{key:"_initializeMessages",value:function(){this._messages=R.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 supporta 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}}]),r}(Ke),Je=function(e){c(r,e);var t=g(r);function r(){return s(this,r),t.apply(this,arguments)}return l(r,[{key:"name",get:function(){return"sources"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"bindEvents",value:function(){this.listenTo(this.core,ce.CORE_CONTAINERS_CREATED,this.onContainersCreated)}},{key:"onContainersCreated",value:function(){var e=this.core.containers.filter((function(e){return"no_op"!==e.playback.name}))[0]||this.core.containers[0];e&&this.core.containers.forEach((function(t){t!==e&&t.destroy()}))}}]),r}(Ke);Be.registerPlugin(Qe),Be.registerPlugin(Je),Be.registerPlayback(Ze),Be.registerPlayback(Xe),Be.registerPlayback(qe),Be.registerPlayback(ze);var et={Player:Ge,Events:ce,Browser:w,ContainerPlugin:Ve,UIContainerPlugin:je,CorePlugin:Ke,UICorePlugin:Le,Playback:Re,Container:De,Core:Oe,PlayerError:_e,Loader:Be,BaseObject:he,UIObject:Se,Utils:J,HTML5Audio:qe,HTML5Video:ze,HTMLImg:Xe,Log:ae,Styler:be,version:"0.4.27",template:Te,$:R};function tt(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function rt(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,(n=i.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(n,"string"))?a:String(a)),i)}var n,a}function it(e,t,r){return t&&rt(e.prototype,t),r&&rt(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function nt(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&st(e,t)}function at(e){return at=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},at(e)}function st(e,t){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},st(e,t)}function ot(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function lt(e){var t=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(e){return!1}}();return function(){var r,i=at(e);if(t){var n=at(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return ot(this,r)}}function ut(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=at(e)););return e}function ct(){return ct="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var i=ut(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},ct.apply(this,arguments)}var dt=function(e){nt(r,e);var t=lt(r);function r(e){return tt(this,r),t.call(this,e)}return it(r,[{key:"name",get:function(){return"click_to_pause"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"config",get:function(){return this.container.options.clickToPauseConfig||{}}},{key:"bindEvents",value:function(){this.listenTo(this.container,ce.CONTAINER_CLICK,this.click),this.listenTo(this.container,ce.CONTAINER_SETTINGSUPDATE,this.settingsUpdate)}},{key:"click",value:function(){var e=this.config.onClickPayload;(this.container.getPlaybackType()!==Re.LIVE||this.container.isDvrEnabled())&&(this.container.isPlaying()?this.container.pause(e):this.container.play(e))}},{key:"settingsUpdate",value:function(){var e=this.container.getPlaybackType()!==Re.LIVE||this.container.isDvrEnabled();if(e!==this.pointerEnabled){var t=e?"addClass":"removeClass";this.container.$el[t]("pointer-enabled"),this.pointerEnabled=e}}}]),r}(Ve),ht=function(e){nt(r,e);var t=lt(r);function r(e){var i;tt(this,r),i=t.call(this,e);var n=e.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(e){return e.name},i}return it(r,[{key:"name",get:function(){return"closed_captions"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"template",get:function(){return Te('<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,ce.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged),this.listenTo(this.core.mediaControl,ce.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,ce.MEDIACONTROL_HIDE,this.hideContextMenu),this.bindContainerEvents()}},{key:"bindContainerEvents",value:function(){this.container=this.core.activeContainer,this.container&&(this.listenTo(this.container,ce.CONTAINER_SUBTITLE_AVAILABLE,this.onSubtitleAvailable),this.listenTo(this.container,ce.CONTAINER_SUBTITLE_CHANGED,this.onSubtitleChanged),this.listenTo(this.container,ce.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(e){this.setCurrentContextMenuElement(e.id)}},{key:"onTrackSelect",value:function(e){var t=parseInt(e.target.dataset.ccSelect,10);return this.container.closedCaptionsTrackId=t,this.hideContextMenu(),e.stopPropagation(),!1}},{key:"ccAvailable",value:function(e){var t=e?"addClass":"removeClass";this.$el[t]("available")}},{key:"toggleContextMenu",value:function(){this.$el.find("ul").toggle()}},{key:"hideContextMenu",value:function(){this.$el.find("ul").hide()}},{key:"contextMenuElement",value:function(e){return this.$el.find("ul a"+(isNaN(e)?"":'[data-cc-select="'+e+'"]')).parent()}},{key:"setCurrentContextMenuElement",value:function(e){if(this._trackId!==e){this.contextMenuElement().removeClass("current"),this.contextMenuElement(e).addClass("current");var t=e>-1?"addClass":"removeClass";this.$ccButton[t]("enabled"),this._trackId=e}}},{key:"renderCcButton",value:function(){for(var e=this.container?this.container.closedCaptionsTracks:[],t=0;t<e.length;t++)e[t].label=this._labelCb(e[t]);var r=be.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:e})),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(r[0])}},{key:"render",value:function(){this.renderCcButton();var e=this.core.mediaControl.$el.find("button[data-fullscreen]");return e[0]?this.$el.insertAfter(e):this.core.mediaControl.$el.find(".media-control-right-panel[data-media-control]").prepend(this.$el),this}}]),r}(Le),ft=function(e){nt(r,e);var t=lt(r);function r(e){var i;return tt(this,r),(i=t.call(this,e)).settingsUpdate(),i}return it(r,[{key:"template",get:function(){return Te('<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.4.27"}}},{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 e=this;this.core.mediaControl.settings?(this.listenTo(this.core.mediaControl,ce.MEDIACONTROL_CONTAINERCHANGED,this.containerChanged),this.listenTo(this.core.mediaControl,ce.MEDIACONTROL_RENDERED,this.settingsUpdate),this.listenTo(this.core,ce.CORE_OPTIONS_CHANGE,this.render)):setTimeout((function(){return e.bindCoreEvents()}),100)}},{key:"bindContainerEvents",value:function(){this.core.activeContainer&&(this.listenToOnce(this.core.activeContainer,ce.CONTAINER_TIMEUPDATE,this.render),this.listenTo(this.core.activeContainer,ce.CONTAINER_PLAYBACKDVRSTATECHANGED,this.dvrChanged))}},{key:"containerChanged",value:function(){this.stopListening(),this.bindEvents()}},{key:"dvrChanged",value:function(e){this.core.getPlaybackType()===Re.LIVE&&(this.settingsUpdate(),this.core.mediaControl.$el.addClass("live"),e?(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 e=this.core.mediaControl,t=e.container;t.isPlaying()||t.play(),e.$el.hasClass("dvr")&&t.seek(t.getDuration())}},{key:"settingsUpdate",value:function(){var e=this;this.stopListening(),this.core.mediaControl.$el.removeClass("live"),this.shouldRender()&&(this.render(),this.$el.click((function(){return e.click()}))),this.bindEvents()}},{key:"shouldRender",value:function(){return(void 0===this.core.options.useDvrControls||!!this.core.options.useDvrControls)&&this.core.getPlaybackType()===Re.LIVE}},{key:"render",value:function(){var e=be.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(e[0]),this.shouldRender()&&(this.core.mediaControl.$el.addClass("live"),this.core.mediaControl.$(".media-control-left-panel[data-media-control]").append(this.$el)),this}}]),r}(Le),pt=function(e){nt(r,e);var t=lt(r);function r(){return tt(this,r),t.apply(this,arguments)}return it(r,[{key:"name",get:function(){return"end_video"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"bindEvents",value:function(){this.listenTo(this.core,ce.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged);var e=this.core.activeContainer;e&&(this.listenTo(e,ce.CONTAINER_ENDED,this.ended),this.listenTo(e,ce.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()}}]),r}(Ke),gt=function(e){nt(r,e);var t=lt(r);function r(e){var i;return tt(this,r),(i=t.call(this,e)).options.disableErrorScreen?ot(i,i.disable()):i}return it(r,[{key:"name",get:function(){return"error_screen"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"template",get:function(){return Te('<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,ce.ERROR,this.onError),this.listenTo(this.core,ce.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 e=this;this.listenToOnce(this.core,ce.CORE_READY,(function(){return e.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 e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.level===_e.Levels.FATAL&&(this.err=e,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 e=be.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(e[0]),this.core.$el.append(this.el),this.bindReload(),this}}}]),r}(Le),vt='<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>',mt='<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>',yt=R('link[rel="shortcut icon"]'),At=function(e){nt(r,e);var t=lt(r);function r(e){var i;return tt(this,r),(i=t.call(this,e))._container=null,i.configure(),i}return it(r,[{key:"name",get:function(){return"favicon"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"oldIcon",get:function(){return yt}},{key:"configure",value:function(){this.core.options.changeFavicon?this.enabled||(this.stopListening(this.core,ce.CORE_OPTIONS_CHANGE),this.enable()):this.enabled&&(this.disable(),this.listenTo(this.core,ce.CORE_OPTIONS_CHANGE,this.configure))}},{key:"bindEvents",value:function(){this.listenTo(this.core,ce.CORE_OPTIONS_CHANGE,this.configure),this.listenTo(this.core,ce.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,ce.CONTAINER_PLAY,this.setPlayIcon),this.listenTo(this._container,ce.CONTAINER_PAUSE,this.setPauseIcon),this.listenTo(this._container,ce.CONTAINER_STOP,this.resetIcon),this.listenTo(this._container,ce.CONTAINER_ENDED,this.resetIcon),this.listenTo(this._container,ce.CONTAINER_ERROR,this.resetIcon),this.resetIcon()}},{key:"disable",value:function(){ct(at(r.prototype),"disable",this).call(this),this.resetIcon()}},{key:"destroy",value:function(){ct(at(r.prototype),"destroy",this).call(this),this.resetIcon()}},{key:"createIcon",value:function(e){var t=R("<canvas/>");t[0].width=16,t[0].height=16;var r=t[0].getContext("2d");r.fillStyle="#000";var i=R(e).find("path").attr("d"),n=new Path2D(i);r.fill(n);var a=R('<link rel="shortcut icon" type="image/png"/>');return a.attr("href",t[0].toDataURL("image/png")),a}},{key:"setPlayIcon",value:function(){this.playIcon||(this.playIcon=this.createIcon(vt)),this.changeIcon(this.playIcon)}},{key:"setPauseIcon",value:function(){this.pauseIcon||(this.pauseIcon=this.createIcon(mt)),this.changeIcon(this.pauseIcon)}},{key:"resetIcon",value:function(){R('link[rel="shortcut icon"]').remove(),R("head").append(this.oldIcon)}},{key:"changeIcon",value:function(e){e&&(R('link[rel="shortcut icon"]').remove(),R("head").append(e))}}]),r}(Ke),Et=function(e){nt(r,e);var t=lt(r);function r(e){var i;return tt(this,r),(i=t.call(this,e)).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 it(r,[{key:"name",get:function(){return"google_analytics"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"embedScript",value:function(){var e=this;if(window._gat)this.addEventListeners();else{var t=document.createElement("script");t.setAttribute("type","text/javascript"),t.setAttribute("async","async"),t.setAttribute("src","//www.google-analytics.com/ga.js"),t.onload=function(){return e.addEventListeners()},document.body.appendChild(t)}}},{key:"addEventListeners",value:function(){var e=this;this.container&&(this.listenTo(this.container,ce.CONTAINER_READY,this.onReady),this.listenTo(this.container,ce.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ce.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ce.CONTAINER_PAUSE,this.onPause),this.listenTo(this.container,ce.CONTAINER_ENDED,this.onEnded),this.listenTo(this.container,ce.CONTAINER_STATE_BUFFERING,this.onBuffering),this.listenTo(this.container,ce.CONTAINER_STATE_BUFFERFULL,this.onBufferFull),this.listenTo(this.container,ce.CONTAINER_ERROR,this.onError),this.listenTo(this.container,ce.CONTAINER_PLAYBACKSTATE,this.onPlaybackChanged),this.listenTo(this.container,ce.CONTAINER_VOLUME,(function(t){return e.onVolumeChanged(t)})),this.listenTo(this.container,ce.CONTAINER_SEEK,(function(t){return e.onSeek(t)})),this.listenTo(this.container,ce.CONTAINER_FULL_SCREEN,this.onFullscreen),this.listenTo(this.container,ce.CONTAINER_HIGHDEFINITIONUPDATE,this.onHD),this.listenTo(this.container,ce.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(e){var t=e?"ON":"OFF";t!==this.currentHDState&&(this.currentHDState=t,this.push(["Video","HD - "+t,this.container.playback.src]))}},{key:"onPlaybackChanged",value:function(e){null!==e.type&&this.push(["Video","Playback Type - "+e.type,this.container.playback.src])}},{key:"onDVR",value:function(e){var t=e?"ON":"OFF";this.push(["Interaction","DVR - "+t,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(e){var t=[this.trackerName+"_trackEvent"].concat(e);_gaq.push(t)}}]),r}(Ve),Tt=function(e){this.element=e||window.document,this.initialize()};Tt.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"},Tt.KEY_CODES_BY_NAME={},function(){for(var e in Tt.KEY_NAMES_BY_CODE)Object.prototype.hasOwnProperty.call(Tt.KEY_NAMES_BY_CODE,e)&&(Tt.KEY_CODES_BY_NAME[Tt.KEY_NAMES_BY_CODE[e]]=+e)}(),Tt.MODIFIERS=["shift","ctrl","alt"],Tt.registerEvent=document.addEventListener?function(e,t,r){e.addEventListener(t,r,!1)}:document.attachEvent?function(e,t,r){e.attachEvent("on"+t,r)}:void 0,Tt.unregisterEvent=document.removeEventListener?function(e,t,r){e.removeEventListener(t,r,!1)}:document.detachEvent?function(e,t,r){e.detachEvent("on"+t,r)}:void 0,Tt.stringContains=function(e,t){return-1!==e.indexOf(t)},Tt.neatString=function(e){return e.replace(/^\s+|\s+$/g,"").replace(/\s+/g," ")},Tt.capitalize=function(e){return e.toLowerCase().replace(/^./,(function(e){return e.toUpperCase()}))},Tt.isString=function(e){return Tt.stringContains(Object.prototype.toString.call(e),"String")},Tt.arrayIncludes=Array.prototype.indexOf?function(e,t){return-1!==e.indexOf(t)}:function(e,t){for(var r=0;r<e.length;r++)if(e[r]===t)return!0;return!1},Tt.extractModifiers=function(e){var t,r;for(t=[],r=0;r<Tt.MODIFIERS.length;r++)Tt.stringContains(e,Tt.MODIFIERS[r])&&t.push(Tt.MODIFIERS[r]);return t},Tt.extractKey=function(e){var t,r;for(t=Tt.neatString(e).split(" "),r=0;r<t.length;r++)if(!Tt.arrayIncludes(Tt.MODIFIERS,t[r]))return t[r]},Tt.modifiersAndKey=function(e){var t,r;return Tt.stringContains(e,"any")?Tt.neatString(e).split(" ").slice(0,2).join(" "):(t=Tt.extractModifiers(e),(r=Tt.extractKey(e))&&!Tt.arrayIncludes(Tt.MODIFIERS,r)&&t.push(r),t.join(" "))},Tt.keyName=function(e){return Tt.KEY_NAMES_BY_CODE[e+""]},Tt.keyCode=function(e){return+Tt.KEY_CODES_BY_NAME[e]},Tt.prototype.initialize=function(){var e,t=this;for(this.lastKeyCode=-1,this.lastModifiers={},e=0;e<Tt.MODIFIERS.length;e++)this.lastModifiers[Tt.MODIFIERS[e]]=!1;this.keysDown={any:[]},this.keysUp={any:[]},this.downHandler=this.handler("down"),this.upHandler=this.handler("up"),Tt.registerEvent(this.element,"keydown",this.downHandler),Tt.registerEvent(this.element,"keyup",this.upHandler),Tt.registerEvent(window,"unload",(function e(){Tt.unregisterEvent(t.element,"keydown",t.downHandler),Tt.unregisterEvent(t.element,"keyup",t.upHandler),Tt.unregisterEvent(window,"unload",e)}))},Tt.prototype.handler=function(e){var t=this;return function(r){var i,n,a;for(r=r||window.event,t.lastKeyCode=r.keyCode,i=0;i<Tt.MODIFIERS.length;i++)t.lastModifiers[Tt.MODIFIERS[i]]=r[Tt.MODIFIERS[i]+"Key"];for(Tt.arrayIncludes(Tt.MODIFIERS,Tt.keyName(t.lastKeyCode))&&(t.lastModifiers[Tt.keyName(t.lastKeyCode)]=!0),n=t["keys"+Tt.capitalize(e)],i=0;i<n.any.length;i++)!1===n.any[i](r)&&r.preventDefault&&r.preventDefault();if(n[a=t.lastModifiersAndKey()])for(i=0;i<n[a].length;i++)!1===n[a][i](r)&&r.preventDefault&&r.preventDefault()}},Tt.prototype.registerKeys=function(e,t,r){var i,n,a=this["keys"+Tt.capitalize(e)];for(Tt.isString(t)&&(t=[t]),i=0;i<t.length;i++)n=t[i],a[n=Tt.modifiersAndKey(n+"")]?a[n].push(r):a[n]=[r];return this},Tt.prototype.unregisterKeys=function(e,t,r){var i,n,a,s=this["keys"+Tt.capitalize(e)];for(Tt.isString(t)&&(t=[t]),i=0;i<t.length;i++)if(a=t[i],a=Tt.modifiersAndKey(a+""),null===r)delete s[a];else if(s[a])for(n=0;n<s[a].length;n++)if(String(s[a][n])===String(r)){s[a].splice(n,1);break}return this},Tt.prototype.off=function(e){return this.unregisterKeys("down",e,null)},Tt.prototype.delegate=function(e,t,r){return null!==r||void 0!==r?this.registerKeys(e,t,r):this.unregisterKeys(e,t,r)},Tt.prototype.down=function(e,t){return this.delegate("down",e,t)},Tt.prototype.up=function(e,t){return this.delegate("up",e,t)},Tt.prototype.lastKey=function(e){return e?this.lastModifiers[e]:Tt.keyName(this.lastKeyCode)},Tt.prototype.lastModifiersAndKey=function(){var e,t;for(e=[],t=0;t<Tt.MODIFIERS.length;t++)this.lastKey(Tt.MODIFIERS[t])&&e.push(Tt.MODIFIERS[t]);return Tt.arrayIncludes(e,this.lastKey())||e.push(this.lastKey()),e.join(" ")};var bt={Kibo:Tt},kt='<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>',St='<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>',_t='<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>',Ct=J.Config,Lt=J.Fullscreen,Dt=J.formatTime,Rt=J.extend,It=J.removeArrayItem,Ot=function(e){nt(r,e);var t=lt(r);function r(e){var i;return tt(this,r),(i=t.call(this,e)).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 Tt(i.options.focusElement),i.bindKeyEvents(),i.container?R.isEmptyObject(i.container.settings)||(i.settings=R.extend({},i.container.settings)):i.settings={},i.userDisabled=!1,(i.container&&i.container.mediaControlDisabled||i.options.chromeless)&&i.disable(),i.stopDragHandler=function(e){return i.stopDrag(e)},i.updateDragHandler=function(e){return i.updateDrag(e)},R(document).bind("mouseup",i.stopDragHandler),R(document).bind("mousemove",i.updateDragHandler),i}return it(r,[{key:"name",get:function(){return"media_control"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"disabled",get:function(){var e=this.container&&this.container.getPlaybackType()===Re.NO_OP;return this.userDisabled||e}},{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 Te('<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 e=this;return{setVolume:this.setVolume,getVolume:function(){return e.volume}}}},{key:"bindEvents",value:function(){var e=this;this.stopListening(),this.listenTo(this.core,ce.CORE_ACTIVE_CONTAINER_CHANGED,this.onActiveContainerChanged),this.listenTo(this.core,ce.CORE_MOUSE_MOVE,this.show),this.listenTo(this.core,ce.CORE_MOUSE_LEAVE,(function(){return e.hide(e.options.hideMediaControlDelay)})),this.listenTo(this.core,ce.CORE_FULLSCREEN,this.show),this.listenTo(this.core,ce.CORE_OPTIONS_CHANGE,this.configure),this.listenTo(this.core,ce.CORE_RESIZE,this.playerResize),this.bindContainerEvents()}},{key:"bindContainerEvents",value:function(){this.container&&(this.listenTo(this.container,ce.CONTAINER_PLAY,this.changeTogglePlay),this.listenTo(this.container,ce.CONTAINER_PAUSE,this.changeTogglePlay),this.listenTo(this.container,ce.CONTAINER_STOP,this.changeTogglePlay),this.listenTo(this.container,ce.CONTAINER_DBLCLICK,this.toggleFullscreen),this.listenTo(this.container,ce.CONTAINER_TIMEUPDATE,this.onTimeUpdate),this.listenTo(this.container,ce.CONTAINER_PROGRESS,this.updateProgressBar),this.listenTo(this.container,ce.CONTAINER_SETTINGSUPDATE,this.settingsUpdate),this.listenTo(this.container,ce.CONTAINER_PLAYBACKDVRSTATECHANGED,this.settingsUpdate),this.listenTo(this.container,ce.CONTAINER_HIGHDEFINITIONUPDATE,this.highDefinitionUpdate),this.listenTo(this.container,ce.CONTAINER_MEDIACONTROL_DISABLE,this.disable),this.listenTo(this.container,ce.CONTAINER_MEDIACONTROL_ENABLE,this.enable),this.listenTo(this.container,ce.CONTAINER_ENDED,this.ended),this.listenTo(this.container,ce.CONTAINER_VOLUME,this.onVolumeChanged),this.listenTo(this.container,ce.CONTAINER_OPTIONS_CHANGE,this.setInitialVolume),"video"===this.container.playback.el.nodeName.toLowerCase()&&this.listenToOnce(this.container,ce.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 e=this.persistConfig?Ct.restore("volume"):100,t=this.container&&this.container.options||this.options;this.setVolume(t.mute?0:e,!0)}},{key:"onVolumeChanged",value:function(){this.updateVolumeUI()}},{key:"onLoadedMetadataOnVideoTag",value:function(){var e=this.playback&&this.playback.el;!Lt.fullscreenEnabled()&&e.webkitSupportsFullscreen&&(this.fullScreenOnVideoTagSupported=!0,this.settingsUpdate())}},{key:"updateVolumeUI",value:function(){if(this.rendered){this.$volumeBarContainer.find(".bar-fill-2").css({});var e=this.$volumeBarContainer.width(),t=this.$volumeBarBackground.width(),r=(e-t)/2,i=t*this.volume/100+r;this.$volumeBarFill.css({width:"".concat(this.volume,"%")}),this.$volumeBarScrubber.css({left:i}),this.$volumeBarContainer.find(".segmented-bar-element").removeClass("fill");var n=Math.ceil(this.volume/10);this.$volumeBarContainer.find(".segmented-bar-element").slice(0,n).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(St),this.applyButtonStyle(this.$volumeIcon)}}},{key:"changeTogglePlay",value:function(){this.$playPauseToggle.html(""),this.$playStopToggle.html(""),this.container&&this.container.isPlaying()?(this.$playPauseToggle.append(mt),this.$playStopToggle.append(kt),this.trigger(ce.MEDIACONTROL_PLAYING)):(this.$playPauseToggle.append(vt),this.$playStopToggle.append(vt),this.trigger(ce.MEDIACONTROL_NOTPLAYING),w.isMobile&&this.show()),this.applyButtonStyle(this.$playPauseToggle),this.applyButtonStyle(this.$playStopToggle)}},{key:"mousemoveOnSeekBar",value:function(e){if(this.settings.seekEnabled){var t=e.pageX-this.$seekBarContainer.offset().left-this.$seekBarHover.width()/2;this.$seekBarHover.css({left:t})}this.trigger(ce.MEDIACONTROL_MOUSEMOVE_SEEKBAR,e)}},{key:"mouseleaveOnSeekBar",value:function(e){this.trigger(ce.MEDIACONTROL_MOUSELEAVE_SEEKBAR,e)}},{key:"onVolumeClick",value:function(e){this.setVolume(this.getVolumeFromUIEvent(e))}},{key:"mousemoveOnVolumeBar",value:function(e){this.draggingVolumeBar&&this.setVolume(this.getVolumeFromUIEvent(e))}},{key:"playerResize",value:function(e){this.$fullscreenToggle.html("");var t=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>':_t;this.$fullscreenToggle.append(t),this.applyButtonStyle(this.$fullscreenToggle),0!==this.$el.find(".media-control").length&&this.$el.removeClass("w320"),(e.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(e){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"),e&&e.preventDefault())}},{key:"startVolumeDrag",value:function(e){this.draggingVolumeBar=!0,this.$el.addClass("dragging"),e&&e.preventDefault()}},{key:"stopDrag",value:function(e){this.draggingSeekBar&&this.seek(e),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(e){if(this.draggingSeekBar){e.preventDefault();var t=(e.pageX-this.$seekBarContainer.offset().left)/this.$seekBarContainer.width()*100;t=Math.min(100,Math.max(t,0)),this.setSeekPercentage(t)}else this.draggingVolumeBar&&(e.preventDefault(),this.setVolume(this.getVolumeFromUIEvent(e)))}},{key:"getVolumeFromUIEvent",value:function(e){return(e.pageX-this.$volumeBarContainer.offset().left)/this.$volumeBarContainer.width()*100}},{key:"toggleMute",value:function(){this.setVolume(this.muted?100:0)}},{key:"setVolume",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e=Math.min(100,Math.max(e,0)),this.intendedVolume=e,this.persistConfig&&!r&&Ct.persist("volume",e);var i=function(){t.container&&t.container.isReady?t.container.setVolume(e):t.listenToOnce(t.container,ce.CONTAINER_READY,(function(){t.container.setVolume(e)}))};this.container?i():this.listenToOnce(this,ce.MEDIACONTROL_CONTAINERCHANGED,(function(){return i()}))}},{key:"toggleFullscreen",value:function(){this.trigger(ce.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(ce.CONTAINER_PLAYBACKDVRSTATECHANGED,this.container.isDvrInUse()),this.container&&this.container.mediaControlDisabled&&this.disable(),this.trigger(ce.MEDIACONTROL_CONTAINERCHANGED)}},{key:"showVolumeBar",value:function(){this.hideVolumeId&&clearTimeout(this.hideVolumeId),this.$volumeBarContainer.removeClass("volume-bar-hide")}},{key:"hideVolumeBar",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:400;this.$volumeBarContainer&&(this.draggingVolumeBar?this.hideVolumeId=setTimeout((function(){return e.hideVolumeBar()}),t):(this.hideVolumeId&&clearTimeout(this.hideVolumeId),this.hideVolumeId=setTimeout((function(){return e.$volumeBarContainer.addClass("volume-bar-hide")}),t)))}},{key:"ended",value:function(){this.changeTogglePlay()}},{key:"updateProgressBar",value:function(e){var t=e.start/e.total*100,r=e.current/e.total*100;this.$seekBarLoaded.css({left:"".concat(t,"%"),width:"".concat(r-t,"%")})}},{key:"onTimeUpdate",value:function(e){if(!this.draggingSeekBar){var t=e.current<0?e.total:e.current;this.currentPositionValue=t,this.currentDurationValue=e.total,this.renderSeekBar()}}},{key:"renderSeekBar",value:function(){if(null!==this.currentPositionValue&&null!==this.currentDurationValue){this.currentSeekBarPercentage=100,this.container&&(this.container.getPlaybackType()!==Re.LIVE||this.container.isDvrInUse())&&(this.currentSeekBarPercentage=this.currentPositionValue/this.currentDurationValue*100),this.setSeekPercentage(this.currentSeekBarPercentage);var e=Dt(this.currentPositionValue),t=Dt(this.currentDurationValue);e!==this.displayedPosition&&(this.$position.text(e),this.displayedPosition=e),t!==this.displayedDuration&&(this.$duration.text(t),this.displayedDuration=t)}}},{key:"seek",value:function(e){if(this.settings.seekEnabled){var t=(e.pageX-this.$seekBarContainer.offset().left)/this.$seekBarContainer.width()*100;return t=Math.min(100,Math.max(t,0)),this.container&&this.container.seekPercentage(t),this.setSeekPercentage(t),!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(e){var t=this;if(!this.disabled){var r=e&&e.clientX!==this.lastMouseX&&e.clientY!==this.lastMouseY;(!e||r||navigator.userAgent.match(/firefox/i))&&(clearTimeout(this.hideId),this.$el.show(),this.trigger(ce.MEDIACONTROL_SHOW,this.name),this.container&&this.container.trigger(ce.CONTAINER_MEDIACONTROL_SHOW,this.name),this.$el.removeClass("media-control-hide"),this.hideId=setTimeout((function(){return t.hide()}),2e3),e&&(this.lastMouseX=e.clientX,this.lastMouseY=e.clientY));this.updateCursorStyle(!0)}}},{key:"hide",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(this.isVisible()){var r=t||2e3;if(clearTimeout(this.hideId),this.disabled||!1!==this.options.hideMediaControl){var i=this.userKeepVisible||this.keepVisible,n=this.draggingSeekBar||this.draggingVolumeBar;if(!this.disabled&&(t||i||n))this.hideId=setTimeout((function(){return e.hide()}),r);else{this.trigger(ce.MEDIACONTROL_HIDE,this.name),this.container&&this.container.trigger(ce.CONTAINER_MEDIACONTROL_HIDE,this.name),this.$el.addClass("media-control-hide"),this.hideVolumeBar(0);var a=!1;this.updateCursorStyle(a)}}}}},{key:"updateCursorStyle",value:function(e){e?this.core.$el.removeClass("nocursor"):this.core.isFullscreen()&&this.core.$el.addClass("nocursor")}},{key:"settingsUpdate",value:function(){var e=this.getSettings();!e||this.fullScreenOnVideoTagSupported||Lt.fullscreenEnabled()||(e.default&&It(e.default,"fullscreen"),e.left&&It(e.left,"fullscreen"),e.right&&It(e.right,"fullscreen")),JSON.stringify(this.settings)!==JSON.stringify(e)&&(this.settings=e,this.render())}},{key:"getSettings",value:function(){return R.extend(!0,{},this.container&&this.container.settings)}},{key:"highDefinitionUpdate",value:function(e){this.isHD=e;var t=e?"addClass":"removeClass";this.$hdIndicator[t]("enabled")}},{key:"createCachedElements",value:function(){var e=this.$el.find(".media-control-layer");this.$duration=e.find(".media-control-indicator[data-duration]"),this.$fullscreenToggle=e.find("button.media-control-button[data-fullscreen]"),this.$playPauseToggle=e.find("button.media-control-button[data-playpause]"),this.$playStopToggle=e.find("button.media-control-button[data-playstop]"),this.$position=e.find(".media-control-indicator[data-position]"),this.$seekBarContainer=e.find(".bar-container[data-seekbar]"),this.$seekBarHover=e.find(".bar-hover[data-seekbar]"),this.$seekBarLoaded=e.find(".bar-fill-1[data-seekbar]"),this.$seekBarPosition=e.find(".bar-fill-2[data-seekbar]"),this.$seekBarScrubber=e.find(".bar-scrubber[data-seekbar]"),this.$volumeBarContainer=e.find(".bar-container[data-volume]"),this.$volumeContainer=e.find(".drawer-container[data-volume]"),this.$volumeIcon=e.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 e=this.$el.find(".media-control-layer");e.find("button.media-control-button[data-play]").append(vt),e.find("button.media-control-button[data-pause]").append(mt),e.find("button.media-control-button[data-stop]").append(kt),this.$playPauseToggle.append(vt),this.$playStopToggle.append(vt),this.$volumeIcon.append(St),this.$fullscreenToggle.append(_t),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(e){e=Math.max(Math.min(e,100),0),this.displayedSeekBarPercentage!==e&&(this.displayedSeekBarPercentage=e,this.$seekBarPosition.removeClass("media-control-notransition"),this.$seekBarScrubber.removeClass("media-control-notransition"),this.$seekBarPosition.css({width:"".concat(e,"%")}),this.$seekBarScrubber.css({left:"".concat(e,"%")}))}},{key:"seekRelative",value:function(e){if(this.settings.seekEnabled){var t=this.container.getCurrentTime(),r=this.container.getDuration(),i=Math.min(Math.max(t+e,0),r);i=Math.min(100*i/r,100),this.container.seekPercentage(i)}}},{key:"bindKeyAndShow",value:function(e,t){var r=this;this.kibo.down(e,(function(){return r.show(),t()}))}},{key:"bindKeyEvents",value:function(){var e=this;if(!w.isMobile&&!this.options.disableKeyboardShortcuts){this.unbindKeyEvents(),this.kibo=new Tt(this.options.focusElement||this.options.parentElement),this.bindKeyAndShow("space",(function(){return e.togglePlayPause()})),this.bindKeyAndShow("left",(function(){return e.seekRelative(-5)})),this.bindKeyAndShow("right",(function(){return e.seekRelative(5)})),this.bindKeyAndShow("shift left",(function(){return e.seekRelative(-10)})),this.bindKeyAndShow("shift right",(function(){return e.seekRelative(10)})),this.bindKeyAndShow("shift ctrl left",(function(){return e.seekRelative(-15)})),this.bindKeyAndShow("shift ctrl right",(function(){return e.seekRelative(15)}));["1","2","3","4","5","6","7","8","9","0"].forEach((function(t){e.bindKeyAndShow(t,(function(){e.settings.seekEnabled&&e.container&&e.container.seekPercentage(10*t)}))}))}}},{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 e=this.options.mediacontrol.seekbar;this.$el.find(".bar-fill-2[data-seekbar]").css("background-color",e),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(e){this.buttonsColor&&e&&R(e).find("svg path").css("fill",this.buttonsColor)}},{key:"destroy",value:function(){R(document).unbind("mouseup",this.stopDragHandler),R(document).unbind("mousemove",this.updateDragHandler),this.unbindKeyEvents(),this.stopListening(),ct(at(r.prototype),"destroy",this).call(this)}},{key:"configure",value:function(e){this.options.chromeless||e.source||e.sources?this.disable():this.enable(),this.trigger(ce.MEDIACONTROL_OPTIONS_CHANGE)}},{key:"render",value:function(){var e=this,t=this.options.hideMediaControlDelay||2e3;this.settings&&this.$el.html(this.template({settings:this.settings}));var r=be.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(r[0]),this.createCachedElements(),this.$playPauseToggle.addClass("paused"),this.$playStopToggle.addClass("stopped"),this.changeTogglePlay(),this.container&&(this.hideId=setTimeout((function(){return e.hide()}),t),this.disabled&&this.hide()),w.isSafari&&w.isMobile&&(w.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 i=0;return this.displayedSeekBarPercentage&&(i=this.displayedSeekBarPercentage),this.displayedSeekBarPercentage=null,this.setSeekPercentage(i),setTimeout((function(){!e.settings.seekEnabled&&e.$seekBarContainer.addClass("seek-disabled"),!w.isMobile&&!e.options.disableKeyboardShortcuts&&e.bindKeyEvents(),e.playerResize({width:e.options.width,height:e.options.height}),e.hideVolumeBar(0)}),0),this.parseColors(),this.highDefinitionUpdate(this.isHD),this.core.$el.append(this.el),this.rendered=!0,this.updateVolumeUI(),this.trigger(ce.MEDIACONTROL_RENDERED),this}}]),r}(Le);Ot.extend=function(e){return Rt(Ot,e)};for(var wt=function(e){nt(r,e);var t=lt(r);function r(e){var i;return tt(this,r),(i=t.call(this,e)).hasStartedPlaying=!1,i.playRequested=!1,i.render(),setTimeout((function(){return i.update()}),0),i}return it(r,[{key:"name",get:function(){return"poster"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"template",get:function(){return Te('<div class="play-wrapper" data-poster></div>\n')}},{key:"shouldRender",get:function(){var e=!(!this.options.poster||!this.options.poster.showForNoOp);return"html_img"!==this.container.playback.name&&(this.container.playback.getPlaybackType()!==Re.NO_OP||e)}},{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,ce.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ce.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ce.CONTAINER_STATE_BUFFERING,this.update),this.listenTo(this.container,ce.CONTAINER_STATE_BUFFERFULL,this.update),this.listenTo(this.container,ce.CONTAINER_OPTIONS_CHANGE,this.render),this.listenTo(this.container,ce.CONTAINER_ERROR,this.onError),this.showOnVideoEnd&&this.listenTo(this.container,ce.CONTAINER_ENDED,this.onStop)}},{key:"onError",value:function(e){this.hasFatalError=e.level===_e.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(e){!e||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 e=!this.playRequested&&!this.hasStartedPlaying&&!this.container.buffering;this.updatePlayButton(e),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 e=be.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(e[0]),this.options.poster&&void 0===this.options.poster.custom){var t=this.options.poster.url||this.options.poster;this.$el.css({"background-image":"url("+t+")"}),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(vt),this.$playButton=this.$playWrapper.find("svg"),this.$playButton.addClass("poster-icon"),this.$playButton.attr("data-poster","");var r=this.options.mediacontrol&&this.options.mediacontrol.buttons;return r&&this.$el.find("svg path").css("fill",r),this.options.mediacontrol&&this.options.mediacontrol.buttons&&(r=this.options.mediacontrol.buttons,this.$playButton.css("color",r)),this.update(),this}}},{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")}}]),r}(je),Pt=J.formatTime,xt=function(e){nt(r,e);var t=lt(r);function r(e){var i;return tt(this,r),(i=t.call(this,e)).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 it(r,[{key:"name",get:function(){return"seek_time"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"template",get:function(){return Te("<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()===Re.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,ce.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.mediaControl,ce.MEDIACONTROL_MOUSEMOVE_SEEKBAR,this.showTime),this.listenTo(this.mediaControl,ce.MEDIACONTROL_MOUSELEAVE_SEEKBAR,this.hideTime),this.listenTo(this.mediaControl,ce.MEDIACONTROL_CONTAINERCHANGED,this.onContainerChanged),this.mediaControlContainer&&(this.listenTo(this.mediaControlContainer,ce.CONTAINER_PLAYBACKDVRSTATECHANGED,this.update),this.listenTo(this.mediaControlContainer,ce.CONTAINER_TIMEUPDATE,this.updateDuration))}},{key:"onContainerChanged",value:function(){this.stopListening(),this.bindEvents()}},{key:"updateDuration",value:function(e){this.duration=e.total,this.firstFragDateTime=e.firstFragDateTime,this.update()}},{key:"showTime",value:function(e){this.hoveringOverSeekBar=!0,this.calculateHoverPosition(e),this.update()}},{key:"hideTime",value:function(){this.hoveringOverSeekBar=!1,this.update()}},{key:"calculateHoverPosition",value:function(e){var t=e.pageX-this.mediaControl.$seekBarContainer.offset().left;this.hoverPosition=Math.min(1,Math.max(t/this.mediaControl.$seekBarContainer.width(),0))}},{key:"getSeekTime",value:function(){var e,t,r,i;return this.useActualLiveTime?(this.firstFragDateTime?(i=new Date(this.firstFragDateTime),(r=new Date(this.firstFragDateTime)).setHours(0,0,0,0),t=(i.getTime()-r.getTime())/1e3+this.duration):(r=new Date((new Date).getTime()-this.actualLiveServerTimeDiff),t=((i=new Date(r))-r.setHours(0,0,0,0))/1e3),(e=t-this.duration+this.hoverPosition*this.duration)<0&&(e+=86400)):e=this.hoverPosition*this.duration,{seekTime:e,secondsSinceMidnight:t}}},{key:"update",value:function(){if(this.rendered)if(this.shouldBeVisible()){var e=this.getSeekTime(),t=Pt(e.seekTime,this.useActualLiveTime);if(t!==this.displayedSeekTime&&(this.$seekTimeEl.text(t),this.displayedSeekTime=t),this.durationShown){this.$durationEl.show();var r=Pt(this.actualLiveTime?e.secondsSinceMidnight:this.duration,this.actualLiveTime);r!==this.displayedDuration&&(this.$durationEl.text(r),this.displayedDuration=r)}else this.$durationEl.hide();this.$el.show();var i=this.mediaControl.$seekBarContainer.width(),n=this.$el.width(),a=this.hoverPosition*i;a-=n/2,a=Math.max(0,Math.min(a,i-n)),this.$el.css("left",a)}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 e=be.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(e[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()}}]),r}(Le),Nt={ClickToPause:dt,ClosedCaptions:ht,DVRControls:ft,EndVideo:pt,ErrorScreen:gt,Favicon:At,GoogleAnalytics:Et,MediaControl:Ot,Poster:wt,SeekTime:xt,SpinnerThreeBounce:function(e){nt(r,e);var t=lt(r);function r(e){var i;return tt(this,r),(i=t.call(this,e)).template=Te("<div data-bounce1></div><div data-bounce2></div><div data-bounce3></div>\n"),i.showTimeout=null,i.listenTo(i.container,ce.CONTAINER_STATE_BUFFERING,i.onBuffering),i.listenTo(i.container,ce.CONTAINER_STATE_BUFFERFULL,i.onBufferFull),i.listenTo(i.container,ce.CONTAINER_STOP,i.onStop),i.listenTo(i.container,ce.CONTAINER_ENDED,i.onStop),i.listenTo(i.container,ce.CONTAINER_ERROR,i.onStop),i.render(),i}return it(r,[{key:"name",get:function(){return"spinner"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{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 e=this;null===this.showTimeout&&(this.showTimeout=setTimeout((function(){return e.$el.show()}),300))}},{key:"hide",value:function(){null!==this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=null),this.$el.hide()}},{key:"render",value:function(){var e=be.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(e[0]),this.container.$el.append(this.$el),this.$el.hide(),this.container.buffering&&this.onBuffering(),this}}]),r}(je),Stats:function(e){nt(r,e);var t=lt(r);function r(e){var i;return tt(this,r),(i=t.call(this,e)).setInitialAttrs(),i.reportInterval=i.options.reportInterval||5e3,i.state="IDLE",i}return it(r,[{key:"name",get:function(){return"stats"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"bindEvents",value:function(){this.listenTo(this.container.playback,ce.PLAYBACK_PLAY,this.onPlay),this.listenTo(this.container,ce.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ce.CONTAINER_ENDED,this.onStop),this.listenTo(this.container,ce.CONTAINER_DESTROYED,this.onStop),this.listenTo(this.container,ce.CONTAINER_STATE_BUFFERING,this.onBuffering),this.listenTo(this.container,ce.CONTAINER_STATE_BUFFERFULL,this.onBufferFull),this.listenTo(this.container,ce.CONTAINER_STATS_ADD,this.onStatsAdd),this.listenTo(this.container,ce.CONTAINER_BITRATE,this.onStatsAdd),this.listenTo(this.container.playback,ce.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(e){R.extend(this.externalMetrics,e)}},{key:"getStats",value:function(){var e={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 R.extend(e,this.externalMetrics),e}},{key:"report",value:function(){this.container.statsReport(this.getStats())}}]),r}(Ve),WaterMark:function(e){nt(r,e);var t=lt(r);function r(e){var i;return tt(this,r),(i=t.call(this,e)).configure(),i}return it(r,[{key:"name",get:function(){return"watermark"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"template",get:function(){return Te('<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,ce.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ce.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ce.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 e=be.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}),t={position:this.position,imageUrl:this.imageUrl,imageLink:this.imageLink};return this.$el.html(this.template(t)),this.$el.append(e[0]),this.container.$el.append(this.$el),this}}]),r}(je)},Ft=0,Mt=Object.values(Nt);Ft<Mt.length;Ft++){var Bt=Mt[Ft];Be.registerPlugin(Bt)}var Ut=Nt.ClickToPause,Gt=Nt.ClosedCaptions,Vt=Nt.DVRControls,Kt=Nt.EndVideo,jt=Nt.ErrorScreen,Ht=Nt.Favicon,Yt=Nt.GoogleAnalytics,Wt=Nt.MediaControl,$t=Nt.Poster,zt=Nt.SeekTime,qt=Nt.SpinnerThreeBounce,Xt=Nt.Stats,Zt=Nt.WaterMark,Qt=t(t({},et),{},{ClickToPause:Ut,ClosedCaptions:Gt,DVRControls:Vt,EndVideo:Kt,ErrorScreen:jt,Favicon:Ht,GoogleAnalytics:Yt,MediaControl:Wt,Poster:$t,SeekTime:zt,SpinnerThreeBounce:qt,Stats:Xt,WaterMark:Zt,Vendor:bt,Plugins:Nt,version:"0.5.0"});function Jt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function er(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Jt(Object(r),!0).forEach((function(t){ir(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Jt(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function tr(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function rr(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,hr(i.key),i)}}function ir(e,t,r){return(t=hr(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function nr(e){return nr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},nr(e)}function ar(e,t){return ar=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ar(e,t)}function sr(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function or(e){var t=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(e){return!1}}();return function(){var r,i=nr(e);if(t){var n=nr(this).constructor;r=Reflect.construct(i,arguments,n)}else r=i.apply(this,arguments);return sr(this,r)}}function lr(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=nr(e)););return e}function ur(){return ur="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,r){var i=lr(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(arguments.length<3?e:r):n.value}},ur.apply(this,arguments)}function cr(e){return function(e){if(Array.isArray(e))return dr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return dr(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return dr(e,t)}(e)||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 dr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function hr(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function fr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pr,gr,vr={exports:{}};pr=vr,"undefined"!=typeof window&&(gr=()=>(()=>{var e={"./src/config.ts": /*!***********************!*\ !*** ./src/config.ts ***! \***********************/(e,t,r)=>{r.r(t),r.d(t,{enableStreamingMode:()=>_,hlsDefaultConfig:()=>k,mergeConfig:()=>S});var i=r(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),n=r(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),a=r(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),s=r(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),o=r(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),l=r(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),u=r(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),c=r(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),d=r(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),h=r(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),f=r(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),p=r(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),g=r(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),v=r(/*! ./utils/cues */"./src/utils/cues.ts"),m=r(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),y=r(/*! ./utils/logger */"./src/utils/logger.ts");function A(){return A=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},A.apply(this,arguments)}function E(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function T(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?E(Object(r),!0).forEach((function(t){b(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var k=T(T({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:p.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:i.default,bufferController:l.default,capLevelController:c.default,fpsController:d.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:m.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},{cueHandler:v.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:s.SubtitleStreamController,subtitleTrackController:o.default,timelineController:u.TimelineController,audioStreamController:n.default,audioTrackController:a.default,emeController:h.default,cmcdController:f.default});function S(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return A({},e,t)}function _(e){var t=e.loader;t!==g.default&&t!==p.default?(y.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):(0,g.fetchSupported)()&&(e.loader=g.default,e.progressive=!0,e.enableSoftwareAES=!0,y.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts": /*!******************************************!*\ !*** ./src/controller/abr-controller.ts ***! \******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../types/loader */"./src/types/loader.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts");function u(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var c=function(){function e(e){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;var t=e.config;this.bwEstimator=new n.default(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}var t,r,c,d=e.prototype;return d.registerListeners=function(){var e=this.hls;e.on(a.Events.FRAG_LOADING,this.onFragLoading,this),e.on(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(a.Events.ERROR,this.onError,this)},d.unregisterListeners=function(){var e=this.hls;e.off(a.Events.FRAG_LOADING,this.onFragLoading,this),e.off(a.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(a.Events.ERROR,this.onError,this)},d.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},d.onFragLoading=function(e,t){var r,i=t.frag;i.type===o.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null,this.timer=self.setInterval(this.onCheck,100)))},d.onLevelLoaded=function(e,t){var r=this.hls.config;t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},d._abandonRulesCheck=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,n=r.autoLevelEnabled;r.config;var s=r.media;if(e&&s){var o=t?t.stats:e.stats,u=t?t.duration:e.duration;if(o.aborted||o.loaded&&o.loaded===o.total||0===e.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(n&&!s.paused&&s.playbackRate&&s.readyState){var c=r.mainForwardBufferInfo;if(null!==c){var d=performance.now()-o.loading.start,h=Math.abs(s.playbackRate);if(!(d<=500*u/h)){var f=o.loaded&&o.loading.first,p=this.bwEstimator.getEstimate(),g=r.levels,v=r.minAutoLevel,m=g[e.level],y=o.total||Math.max(o.loaded,Math.round(u*m.maxBitrate/8)),A=f?1e3*o.loaded/d:0,E=A?(y-o.loaded)/A:8*y/p,T=c.len/h;if(!(E<=T)){var b,k=Number.POSITIVE_INFINITY;for(b=e.level-1;b>v;b--){var S=g[b].maxBitrate;if((k=A?u*S/(6.4*A):u*S/p)<T)break}k>=E||(l.logger.warn("Fragment "+e.sn+(t?" part "+t.index:"")+" of level "+e.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+b+"\n Current BW estimate: "+((0,i.isFiniteNumber)(p)?(p/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+E.toFixed(3)+" s\n Estimated load time for the next fragment: "+k.toFixed(3)+" s\n Time to underbuffer: "+T.toFixed(3)+" s"),r.nextLoadLevel=b,f&&this.bwEstimator.sample(d,o.loaded),this.clearTimer(),e.loader&&(this.fragCurrent=this.partCurrent=null,e.loader.abort()),r.trigger(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}}}}}},d.onFragLoaded=function(e,t){var r=t.frag,n=t.part;if(r.type===o.PlaylistLevelType.MAIN&&(0,i.isFiniteNumber)(r.sn)){var s=n?n.stats:r.stats,l=n?n.duration:r.duration;if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[r.level],c=(u.loaded?u.loaded.bytes:0)+s.loaded,d=(u.loaded?u.loaded.duration:0)+l;u.loaded={bytes:c,duration:d},u.realBitrate=Math.round(8*c/d)}if(r.bitrateTest){var h={stats:s,frag:r,part:n,id:r.type};this.onFragBuffered(a.Events.FRAG_BUFFERED,h)}}},d.onFragBuffered=function(e,t){var r=t.frag,i=t.part,n=i?i.stats:r.stats;if(!n.aborted&&r.type===o.PlaylistLevelType.MAIN&&"initSegment"!==r.sn){var a=n.parsing.end-n.loading.start;this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},d.onError=function(e,t){switch(t.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},d.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},d.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,a=r.minAutoLevel,s=r.media,o=t?t.duration:e?e.duration:0;s&&s.currentTime;var u=s&&0!==s.playbackRate?Math.abs(s.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,d=r.mainForwardBufferInfo,h=(d?d.len:0)/u,f=this.findBestLevel(c,a,i,h,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(f>=0)return f;l.logger.trace((h?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var p=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay,g=n.abrBandWidthFactor,v=n.abrBandWidthUpFactor;if(!h){var m=this.bitrateTestDelay;m&&(p=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-m,l.logger.trace("bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*p)+" ms"),g=v=1)}return f=this.findBestLevel(c,a,i,h+p,g,v),Math.max(f,0)},d.findBestLevel=function(e,t,r,n,a,s){for(var o,u=this.fragCurrent,c=this.partCurrent,d=this.lastLoadedFragLevel,h=this.hls.levels,f=h[d],p=!(null==f||null===(o=f.details)||void 0===o||!o.live),g=null==f?void 0:f.codecSet,v=c?c.duration:u?u.duration:0,m=r;m>=t;m--){var y=h[m];if(y&&(!g||y.codecSet===g)){var A=y.details,E=(c?null==A?void 0:A.partTarget:null==A?void 0:A.averagetargetduration)||v,T=void 0;T=m<=d?a*e:s*e;var b=h[m].maxBitrate,k=b*E/T;if(l.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+m+"/"+Math.round(T)+"/"+b+"/"+E+"/"+n+"/"+k),T>b&&(0===k||!(0,i.isFiniteNumber)(k)||p&&!this.bitrateTestDelay||k<n))return m}}return-1},t=e,(r=[{key:"nextAutoLevel",get:function(){var e=this._nextAutoLevel,t=this.bwEstimator;if(-1!==e&&!t.canEstimate())return e;var r=this.getNextABRAutoLevel();return-1!==e&&this.hls.levels[r].loadError?e:(-1!==e&&(r=Math.min(e,r)),r)},set:function(e){this._nextAutoLevel=e}}])&&u(t.prototype,r),c&&u(t,c),Object.defineProperty(t,"prototype",{writable:!1}),e}();const d=c},"./src/controller/audio-stream-controller.ts": /*!***************************************************!*\ !*** ./src/controller/audio-stream-controller.ts ***! \***************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>E});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),l=r(/*! ../types/level */"./src/types/level.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),h=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),f=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),p=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),g=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),v=r(/*! ../errors */"./src/errors.ts");function m(){return m=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},m.apply(this,arguments)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}var A=function(e){var t,r;function A(t,r){var i;return(i=e.call(this,t,r,"[audio-stream-controller]")||this).videoBuffer=null,i.videoTrackCC=-1,i.waitingVideoCC=-1,i.audioSwitch=!1,i.trackId=-1,i.waitingData=null,i.mainDetails=null,i.bufferFlushed=!1,i.cachedTrackLoadedData=null,i._registerListeners(),i}r=e,(t=A).prototype=Object.create(r.prototype),t.prototype.constructor=t,y(t,r);var E=A.prototype;return E.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},E._registerListeners=function(){var e=this.hls;e.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(a.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(a.Events.ERROR,this.onError,this),e.on(a.Events.BUFFER_RESET,this.onBufferReset,this),e.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E._unregisterListeners=function(){var e=this.hls;e.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(a.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(a.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(a.Events.ERROR,this.onError,this),e.off(a.Events.BUFFER_RESET,this.onBufferReset,this),e.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(a.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},E.onInitPtsFound=function(e,t){var r=t.frag,i=t.id,a=t.initPTS;if("main"===i){var s=r.cc;this.initPTS[r.cc]=a,this.log("InitPTS for cc: "+s+" found from main: "+a),this.videoTrackCC=s,this.state===n.State.WAITING_INIT_PTS&&this.tick()}},E.startLoad=function(e){if(!this.levels)return this.startPosition=e,void(this.state=n.State.STOPPED);var t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,t>0&&-1===e?(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t,this.state=n.State.IDLE):(this.loadedmetadata=!1,this.state=n.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},E.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_TRACK:var t,r=this.levels,i=this.trackId,a=null==r||null===(t=r[i])||void 0===t?void 0:t.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=n.State.WAITING_INIT_PTS}break;case n.State.FRAG_LOADING_WAITING_RETRY:var o,l=performance.now(),u=this.retryDate;(!u||l>=u||null!==(o=this.media)&&void 0!==o&&o.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=n.State.IDLE);break;case n.State.WAITING_INIT_PTS:var c=this.waitingData;if(c){var d=c.frag,h=c.part,f=c.cache,g=c.complete;if(void 0!==this.initPTS[d.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.FRAG_LOADING;var v={frag:d,part:h,payload:f.flush(),networkDetails:null};this._handleFragmentLoadProgress(v),g&&e.prototype._handleFragmentLoadComplete.call(this,v)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+d.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var m=this.getLoadPosition(),y=s.BufferHelper.bufferInfo(this.mediaBuffer,m,this.config.maxBufferHole);(0,p.fragmentWithinToleranceTest)(y.end,this.config.maxFragLookUpTolerance,d)<0&&(this.log("Waiting fragment cc ("+d.cc+") @ "+d.start+" cancelled because another fragment at "+y.end+" is needed"),this.clearWaitingFragment())}}else this.state=n.State.IDLE}this.onTickEnd()},E.clearWaitingFragment=function(){var e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=n.State.IDLE)},E.resetLoadingState=function(){this.clearWaitingFragment(),e.prototype.resetLoadingState.call(this)},E.onTickEnd=function(){var e=this.media;e&&e.readyState&&(this.lastCurrentTime=e.currentTime)},E.doTickIdle=function(){var e,t,r=this.hls,i=this.levels,s=this.media,o=this.trackId,l=r.config;if(i&&i[o]&&(s||!this.startFragRequested&&l.startFragPrefetch)){var d=i[o].details;if(!d||d.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(d))this.state=n.State.WAITING_TRACK;else{var h=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&h&&(this.bufferFlushed=!1,this.afterBufferFlushed(h,c.ElementaryStreamTypes.AUDIO,u.PlaylistLevelType.AUDIO));var f=this.getFwdBufferInfo(h,u.PlaylistLevelType.AUDIO);if(null!==f){var p=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,u.PlaylistLevelType.MAIN),g=f.len,v=this.getMaxBufferLength(null==p?void 0:p.len),m=this.audioSwitch;if(!(g>=v)||m){if(!m&&this._streamEnded(f,d))return r.trigger(a.Events.BUFFER_EOS,{type:"audio"}),void(this.state=n.State.ENDED);var y=d.fragments[0].start,A=f.end;if(m&&s){var E=this.getLoadPosition();A=E,d.PTSKnown&&E<y&&(f.end>y||f.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=y+.05)}if(!(p&&A>p.end+d.targetduration)&&(p&&p.len||!f.len)){var T=this.getNextFragment(A,d);T?"identity"!==(null===(e=T.decryptdata)||void 0===e?void 0:e.keyFormat)||null!==(t=T.decryptdata)&&void 0!==t&&t.key?this.loadFragment(T,d,A):this.loadKey(T,d):this.bufferFlushed=!0}}}}}},E.getMaxBufferLength=function(t){var r=e.prototype.getMaxBufferLength.call(this);return t?Math.max(r,t):r},E.onMediaDetaching=function(){this.videoBuffer=null,e.prototype.onMediaDetaching.call(this)},E.onAudioTracksUpdated=function(e,t){var r=t.audioTracks;this.resetTransmuxer(),this.levels=r.map((function(e){return new l.Level(e)}))},E.onAudioTrackSwitching=function(e,t){var r=!!t.url;this.trackId=t.id;var i=this.fragCurrent;null!=i&&i.loader&&i.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.audioSwitch=!0,this.state=n.State.IDLE):this.state=n.State.STOPPED,this.tick()},E.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},E.onLevelLoaded=function(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(a.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},E.onAudioTrackLoaded=function(e,t){var r;if(null!=this.mainDetails){var i=this.levels,a=t.details,s=t.id;if(i){this.log("Track "+s+" loaded ["+a.startSN+","+a.endSN+"],duration:"+a.totalduration);var o=i[s],l=0;if(a.live||null!==(r=o.details)&&void 0!==r&&r.live){var u=this.mainDetails;if(a.fragments[0]||(a.deltaUpdateFailed=!0),a.deltaUpdateFailed||!u)return;!o.details&&a.hasProgramDateTime&&u.hasProgramDateTime?((0,g.alignMediaPlaylistByPDT)(a,u),l=a.fragments[0].start):l=this.alignPlaylists(a,o.details)}o.details=a,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(o.details,l),this.state!==n.State.WAITING_TRACK||this.waitForCdnTuneIn(a)||(this.state=n.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+s)}else this.cachedTrackLoadedData=t},E._handleFragmentLoadProgress=function(e){var t,r=e.frag,i=e.part,a=e.payload,s=this.config,o=this.trackId,l=this.levels;if(l){var c=l[o];console.assert(c,"Audio track is defined on fragment load progress");var p=c.details;console.assert(p,"Audio track details are defined on fragment load progress");var g=s.defaultAudioCodec||c.audioCodec||"mp4a.40.2",v=this.transmuxer;v||(v=this.transmuxer=new h.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var m=this.initPTS[r.cc],y=null===(t=r.initSegment)||void 0===t?void 0:t.data;if(void 0!==m){var A=i?i.index:-1,E=-1!==A,T=new f.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,a.byteLength,A,E);v.push(a,y,g,"",r,i,p.totalduration,!1,T,m)}else this.log("Unknown video PTS for cc "+r.cc+", waiting for video PTS before demuxing audio frag "+r.sn+" of ["+p.startSN+" ,"+p.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:r,part:i,cache:new d.default,complete:!1}).cache.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=n.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},E._handleFragmentLoadComplete=function(t){this.waitingData?this.waitingData.complete=!0:e.prototype._handleFragmentLoadComplete.call(this,t)},E.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},E.onBufferCreated=function(e,t){var r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)},E.onFragBuffered=function(e,t){var r,i=t.frag,n=t.part;i.type===u.PlaylistLevelType.AUDIO?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.audioSwitch):("initSegment"!==i.sn&&(this.fragPrevious=i,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(i,n)):this.loadedmetadata||i.type!==u.PlaylistLevelType.MAIN||null!==(r=this.videoBuffer||this.media)&&void 0!==r&&r.buffered.length&&(this.loadedmetadata=!0)},E.onError=function(t,r){switch(r.details){case v.ErrorDetails.FRAG_LOAD_ERROR:case v.ErrorDetails.FRAG_LOAD_TIMEOUT:case v.ErrorDetails.KEY_LOAD_ERROR:case v.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,r);break;case v.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case v.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==n.State.ERROR&&this.state!==n.State.STOPPED&&(this.state=r.fatal?n.State.ERROR:n.State.IDLE,this.warn(r.details+" while loading frag, switching to "+this.state+" state"));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===r.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var i=!0,a=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO);a&&a.len>.5&&(i=!this.reduceMaxBufferLength(a.len)),i&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},E.onBufferFlushed=function(e,t){t.type===c.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},E._handleTransmuxComplete=function(e){var t,r="audio",i=this.hls,s=e.remuxResult,o=e.chunkMeta,l=this.getCurrentContext(o);if(!l)return this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(o.level);var u=l.frag,d=l.part,h=l.level.details,f=s.audio,p=s.text,g=s.id3,v=s.initSegment;if(!this.fragContextChanged(u)&&h){if(this.state=n.State.PARSING,this.audioSwitch&&f&&this.completeAudioSwitch(),null!=v&&v.tracks&&(this._bufferInitSegment(v.tracks,u,o),i.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:r,tracks:v.tracks})),f){var y=f.startPTS,A=f.endPTS,E=f.startDTS,T=f.endDTS;d&&(d.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:y,endPTS:A,startDTS:E,endDTS:T}),u.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,y,A,E,T),this.bufferFragmentData(f,u,d,o)}if(null!=g&&null!==(t=g.samples)&&void 0!==t&&t.length){var b=m({id:r,frag:u,details:h},g);i.trigger(a.Events.FRAG_PARSING_METADATA,b)}if(p){var k=m({id:r,frag:u,details:h},p);i.trigger(a.Events.FRAG_PARSING_USERDATA,k)}}},E._bufferInitSegment=function(e,t,r){if(this.state===n.State.PARSING){e.video&&delete e.video;var i=e.audio;if(i){i.levelCodec=i.codec,i.id="audio",this.log("Init audio buffer, container:"+i.container+", codecs[parsed]=["+i.codec+"]"),this.hls.trigger(a.Events.BUFFER_CODECS,e);var s=i.initSegment;if(null!=s&&s.byteLength){var o={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:s};this.hls.trigger(a.Events.BUFFER_APPENDING,o)}this.tick()}}},E.loadFragment=function(t,r,a){var s=this.fragmentTracker.getState(t);this.fragCurrent=t,(this.audioSwitch||s===o.FragmentState.NOT_LOADED||s===o.FragmentState.PARTIAL)&&("initSegment"===t.sn?this._loadInitSegment(t):r.live&&!(0,i.isFiniteNumber)(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=n.State.WAITING_INIT_PTS):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,a)))},E.completeAudioSwitch=function(){var t=this.hls,r=this.media,i=this.trackId;r&&(this.log("Switching audio track : flushing all audio"),e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,t.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:i})},A}(n.default);const E=A},"./src/controller/audio-track-controller.ts": /*!**************************************************!*\ !*** ./src/controller/audio-track-controller.ts ***! \**************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}var u=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,"[audio-track-controller]")||this).tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.trackName="",r.selectDefaultTrack=!0,r.registerListeners(),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r);var u,c,d,h=a.prototype;return h.registerListeners=function(){var e=this.hls;e.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(i.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(i.Events.ERROR,this.onError,this)},h.unregisterListeners=function(){var e=this.hls;e.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(i.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(i.Events.ERROR,this.onError,this)},h.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,e.prototype.destroy.call(this)},h.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},h.onManifestParsed=function(e,t){this.tracks=t.audioTracks||[]},h.onAudioTrackLoaded=function(e,t){var r=t.id,i=t.details,n=this.tracksInGroup[r];if(n){var a=n.details;n.details=t.details,this.log("audioTrack "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,t,a))}else this.warn("Invalid audio track id "+r)},h.onLevelLoading=function(e,t){this.switchLevel(t.level)},h.onLevelSwitching=function(e,t){this.switchLevel(t.level)},h.switchLevel=function(e){var t=this.hls.levels[e];if(null!=t&&t.audioGroupIds){var r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r;var n=this.tracks.filter((function(e){return!r||e.groupId===r}));this.selectDefaultTrack&&!n.some((function(e){return e.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;var a={audioTracks:n};this.log("Updating audio tracks, "+n.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(i.Events.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}}},h.onError=function(t,r){e.prototype.onError.call(this,t,r),!r.fatal&&r.context&&r.context.type===s.PlaylistContextType.AUDIO_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},h.setAudioTrack=function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var r=t[this.trackId];this.log("Now switching to audio-track index "+e);var n=t[e],a=n.id,s=n.groupId,o=void 0===s?"":s,l=n.name,u=n.type,c=n.url;if(this.trackId=e,this.trackName=l,this.selectDefaultTrack=!1,this.hls.trigger(i.Events.AUDIO_TRACK_SWITCHING,{id:a,groupId:o,name:l,type:u,url:c}),!n.details||n.details.live){var d=this.switchParams(n.url,null==r?void 0:r.details);this.loadPlaylist(d)}}},h.selectInitialTrack=function(){var e=this.tracksInGroup;console.assert(e.length,"Initial audio track should be selected when tracks are known");var t=this.trackName,r=this.findTrackId(t)||this.findTrackId();-1!==r?this.setAudioTrack(r):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},h.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||e===i.name))return i.id}return-1},h.loadPlaylist=function(e){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var r=t.id,n=t.groupId,a=t.url;if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("loading audio-track playlist for id: "+r),this.clearTimer(),this.hls.trigger(i.Events.AUDIO_TRACK_LOADING,{url:a,id:r,groupId:n,deliveryDirectives:e||null})}},u=a,(c=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}}])&&o(u.prototype,c),d&&o(u,d),Object.defineProperty(u,"prototype",{writable:!1}),a}(a.default);const c=u},"./src/controller/base-playlist-controller.ts": /*!****************************************************!*\ !*** ./src/controller/base-playlist-controller.ts ***! \****************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../types/level */"./src/types/level.ts"),a=r(/*! ./level-helper */"./src/controller/level-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=function(){function e(e,t){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=s.logger.log.bind(s.logger,t+":"),this.warn=s.logger.warn.bind(s.logger,t+":"),this.hls=e}var t=e.prototype;return t.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},t.onError=function(e,t){t.fatal&&t.type===o.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},t.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},t.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},t.stopLoad=function(){this.canLoad=!1,this.clearTimer()},t.switchParams=function(e,t){var r=null==t?void 0:t.renditionReports;if(r)for(var a=0;a<r.length;a++){var s=r[a],o=""+s.URI;if(o===e.slice(-o.length)){var l=parseInt(s["LAST-MSN"]),u=parseInt(s["LAST-PART"]);if(t&&this.hls.config.lowLatencyMode){var c=Math.min(t.age-t.partTarget,t.targetduration);void 0!==u&&c>t.partTarget&&(u+=1)}if((0,i.isFiniteNumber)(l))return new n.HlsUrlParameters(l,(0,i.isFiniteNumber)(u)?u:void 0,n.HlsSkip.No)}}},t.loadPlaylist=function(e){},t.shouldLoadTrack=function(e){return this.canLoad&&e&&!!e.url&&(!e.details||e.details.live)},t.playlistLoaded=function(e,t,r){var i=this,n=t.details,s=t.stats,o=s.loading.end?Math.max(0,self.performance.now()-s.loading.end):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+e+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:"MISSED")),r&&n.fragments.length>0&&(0,a.mergeDetails)(r,n),!this.canLoad||!n.live)return;var l,u=void 0,c=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var d=this.hls.config.lowLatencyMode,h=n.lastPartSn,f=n.endSN,p=n.lastPartIndex,g=h===f;-1!==p?(u=g?f+1:h,c=g?d?0:p:p+1):u=f+1;var v=n.age,m=v+n.ageHeader,y=Math.min(m-n.partTarget,1.5*n.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var A=Math.floor(y/n.targetduration);u+=A,void 0!==c&&(c+=Math.round(y%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+y+" skip sn "+A+" to part "+c)}n.tuneInGoal=y}if(l=this.getDeliveryDirectives(n,t.deliveryDirectives,u,c),d||!g)return void this.loadPlaylist(l)}else l=this.getDeliveryDirectives(n,t.deliveryDirectives,u,c);var E=(0,a.computeReloadInterval)(n,s);void 0!==u&&n.canBlockReload&&(E-=n.partTarget||1),this.log("reload live playlist "+e+" in "+Math.round(E)+" ms"),this.timer=self.setTimeout((function(){return i.loadPlaylist(l)}),E)}else this.clearTimer()},t.getDeliveryDirectives=function(e,t,r,i){var a=(0,n.getSkipValue)(e,r);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=n.HlsSkip.No),new n.HlsUrlParameters(r,i,a)},t.retryLoadingOrFail=function(e){var t,r=this,i=this.hls.config,n=this.retryCount<i.levelLoadingMaxRetry;if(n)if(this.retryCount++,e.details.indexOf("LoadTimeOut")>-1&&null!==(t=e.context)&&void 0!==t&&t.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+e.details+'"'),this.loadPlaylist();else{var a=Math.min(Math.pow(2,this.retryCount)*i.levelLoadingRetryDelay,i.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return r.loadPlaylist()}),a),this.warn("retry playlist loading #"+this.retryCount+" in "+a+' ms after "'+e.details+'"')}else this.warn('cannot recover from error "'+e.details+'"'),this.clearTimer(),e.fatal=!0;return n},e}()},"./src/controller/base-stream-controller.ts": /*!**************************************************!*\ !*** ./src/controller/base-stream-controller.ts ***! \**************************************************/(e,t,r)=>{r.r(t),r.d(t,{State:()=>b,default:()=>k});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../task-loop */"./src/task-loop.ts"),a=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),s=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts"),l=r(/*! ../events */"./src/events.ts"),u=r(/*! ../errors */"./src/errors.ts"),c=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),d=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),f=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),p=r(/*! ./level-helper */"./src/controller/level-helper.ts"),g=r(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),v=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),m=r(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),y=r(/*! ../types/loader */"./src/types/loader.ts");function A(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function E(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function T(e,t){return T=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},T(e,t)}var b={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},k=function(e){var t,r;function n(t,r,i){var n;return(n=e.call(this)||this).hls=void 0,n.fragPrevious=null,n.fragCurrent=null,n.fragmentTracker=void 0,n.transmuxer=null,n._state=b.STOPPED,n.media=null,n.mediaBuffer=null,n.config=void 0,n.bitrateTest=!1,n.lastCurrentTime=0,n.nextLoadPosition=0,n.startPosition=0,n.loadedmetadata=!1,n.fragLoadError=0,n.retryDate=0,n.levels=null,n.fragmentLoader=void 0,n.levelLastLoaded=null,n.startFragRequested=!1,n.decrypter=void 0,n.initPTS=[],n.onvseeking=null,n.onvended=null,n.logPrefix="",n.log=void 0,n.warn=void 0,n.logPrefix=i,n.log=o.logger.log.bind(o.logger,i+":"),n.warn=o.logger.warn.bind(o.logger,i+":"),n.hls=t,n.fragmentLoader=new g.default(t.config),n.fragmentTracker=r,n.config=t.config,n.decrypter=new v.default(t,t.config),t.on(l.Events.KEY_LOADED,n.onKeyLoaded,E(n)),t.on(l.Events.LEVEL_SWITCHING,n.onLevelSwitching,E(n)),n}r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,T(t,r);var k,S,_,C=n.prototype;return C.doTick=function(){this.onTickEnd()},C.onTickEnd=function(){},C.startLoad=function(e){},C.stopLoad=function(){this.fragmentLoader.abort();var e=this.fragCurrent;e&&this.fragmentTracker.removeFragment(e),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=b.STOPPED},C._streamEnded=function(e,t){var r=this.fragCurrent,i=this.fragmentTracker;if(!t.live&&r&&this.media&&r.sn>=t.endSN&&!e.nextStart){var n=t.partList;if(null!=n&&n.length){var o=n[n.length-1];return s.BufferHelper.isBuffered(this.media,o.start+o.duration/2)}var l=i.getState(r);return l===a.FragmentState.PARTIAL||l===a.FragmentState.OK}return!1},C.onMediaAttached=function(e,t){var r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);var i=this.config;this.levels&&i.autoStartLoad&&this.state===b.STOPPED&&this.startLoad(i.startPosition)},C.onMediaDetaching=function(){var e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},C.onMediaSeeking=function(){var e=this.config,t=this.fragCurrent,r=this.media,n=this.mediaBuffer,a=this.state,o=r?r.currentTime:0,l=s.BufferHelper.bufferInfo(n||r,o,e.maxBufferHole);if(this.log("media seeking to "+((0,i.isFiniteNumber)(o)?o.toFixed(3):o)+", state: "+a),a===b.ENDED)this.resetLoadingState();else if(t){var u=e.maxFragLookUpTolerance,c=t.start-u,d=t.start+t.duration+u;if(!l.len||d<l.start||c>l.end){var h=o>d;(o<c||h)&&(h&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.loader.abort()),this.resetLoadingState())}}r&&(this.lastCurrentTime=o),this.loadedmetadata||l.len||(this.nextLoadPosition=this.startPosition=o),this.tickImmediate()},C.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},C.onKeyLoaded=function(e,t){if(this.state===b.KEY_LOADING&&t.frag===this.fragCurrent&&this.levels){this.state=b.IDLE;var r=this.levels[t.frag.level].details;r&&this.loadFragment(t.frag,r,t.frag.start)}},C.onLevelSwitching=function(e,t){this.fragLoadError=0},C.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},C.onHandlerDestroyed=function(){this.state=b.STOPPED,this.hls.off(l.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(l.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,e.prototype.onHandlerDestroyed.call(this)},C.loadKey=function(e,t){this.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level),this.state=b.KEY_LOADING,this.fragCurrent=e,this.hls.trigger(l.Events.KEY_LOADING,{frag:e})},C.loadFragment=function(e,t,r){this._loadFragForPlayback(e,t,r)},C._loadFragForPlayback=function(e,t,r){var i=this;this._doFragLoad(e,t,r,(function(t){if(i.fragContextChanged(e))return i.warn("Fragment "+e.sn+(t.part?" p: "+t.part.index:"")+" of level "+e.level+" was dropped during download."),void i.fragmentTracker.removeFragment(e);e.stats.chunkCount++,i._handleFragmentLoadProgress(t)})).then((function(t){if(t){i.fragLoadError=0;var r=i.state;i.fragContextChanged(e)?(r===b.FRAG_LOADING||!i.fragCurrent&&r===b.PARSING)&&(i.fragmentTracker.removeFragment(e),i.state=b.IDLE):("payload"in t&&(i.log("Loaded fragment "+e.sn+" of level "+e.level),i.hls.trigger(l.Events.FRAG_LOADED,t)),i._handleFragmentLoadComplete(t))}})).catch((function(t){i.state!==b.STOPPED&&i.state!==b.ERROR&&(i.warn(t),i.resetFragmentLoading(e))}))},C.flushMainBuffer=function(e,t,r){if(void 0===r&&(r=null),e-t){var i={startOffset:e,endOffset:t,type:r};this.fragLoadError=0,this.hls.trigger(l.Events.BUFFER_FLUSHING,i)}},C._loadInitSegment=function(e){var t=this;this._doFragLoad(e).then((function(r){if(!r||t.fragContextChanged(e)||!t.levels)throw new Error("init load aborted");return r})).then((function(r){var i=t.hls,n=r.payload,a=e.decryptdata;if(n&&n.byteLength>0&&a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return t.decrypter.webCryptoDecrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).then((function(t){var n=self.performance.now();return i.trigger(l.Events.FRAG_DECRYPTED,{frag:e,payload:t,stats:{tstart:s,tdecrypt:n}}),r.payload=t,r}))}return r})).then((function(r){var i=t.fragCurrent,n=t.hls,a=t.levels;if(!a)throw new Error("init load aborted, missing levels");var s=a[e.level].details;console.assert(s,"Level details are defined when init segment is loaded");var o=e.stats;t.state=b.IDLE,t.fragLoadError=0,e.data=new Uint8Array(r.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),r.frag===i&&n.trigger(l.Events.FRAG_BUFFERED,{stats:o,frag:i,part:null,id:e.type}),t.tick()})).catch((function(r){t.state!==b.STOPPED&&t.state!==b.ERROR&&(t.warn(r),t.resetFragmentLoading(e))}))},C.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId},C.fragBufferedComplete=function(e,t){var r,i,n=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+e.level+" "+(n?m.default.toString(s.BufferHelper.getBuffered(n)):"(detached)")),this.state=b.IDLE,n&&(!this.loadedmetadata&&e.type==y.PlaylistLevelType.MAIN&&n.buffered.length&&(null===(r=this.fragCurrent)||void 0===r?void 0:r.sn)===(null===(i=this.fragPrevious)||void 0===i?void 0:i.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},C.seekToStartPos=function(){},C._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,n=e.partsLoaded,a=!n||0===n.length||n.some((function(e){return!e})),s=new c.ChunkMetadata(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);t.flush(s)}},C._handleFragmentLoadProgress=function(e){},C._doFragLoad=function(e,t,r,n){var a=this;if(void 0===r&&(r=null),!this.levels)throw new Error("frag load aborted, missing levels");if(r=Math.max(e.start,r||0),this.config.lowLatencyMode&&t){var s=t.partList;if(s&&n){r>e.end&&t.fragmentHint&&(e=t.fragmentHint);var o=this.getNextPart(s,e,r);if(o>-1){var u=s[o];return this.log("Loading part sn: "+e.sn+" p: "+u.index+" cc: "+e.cc+" of playlist ["+t.startSN+"-"+t.endSN+"] parts [0-"+o+"-"+(s.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=u.start+u.duration,this.state=b.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:e,part:s[o],targetBufferTime:r}),this.doFragPartsLoad(e,s,o,n).catch((function(e){return a.handleFragLoadError(e)}))}if(!e.url||this.loadedEndOfParts(s,r))return Promise.resolve(null)}}return this.log("Loading fragment "+e.sn+" cc: "+e.cc+" "+(t?"of ["+t.startSN+"-"+t.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+e.level+", target: "+parseFloat(r.toFixed(3))),(0,i.isFiniteNumber)(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=b.FRAG_LOADING,this.hls.trigger(l.Events.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragmentLoader.load(e,n).catch((function(e){return a.handleFragLoadError(e)}))},C.doFragPartsLoad=function(e,t,r,i){var n=this;return new Promise((function(a,s){var o=[];!function r(u){var c=t[u];n.fragmentLoader.loadPart(e,c,i).then((function(i){o[c.index]=i;var s=i.part;n.hls.trigger(l.Events.FRAG_LOADED,i);var d=t[u+1];if(!d||d.fragment!==e)return a({frag:e,part:s,partsLoaded:o});r(u+1)})).catch(s)}(r)}))},C.handleFragLoadError=function(e){var t=e.data;return t&&t.details===u.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(l.Events.ERROR,t),null},C._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===b.PARSING){var r=t.frag,i=t.part,n=t.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a),this.updateLevelTiming(r,i,n,e.partial)}else this.fragCurrent||(this.state=b.IDLE)},C.getCurrentContext=function(e){var t=this.levels,r=e.level,i=e.sn,n=e.part;if(!t||!t[r])return this.warn("Levels object was unset while buffering fragment "+i+" of level "+r+". The current chunk will not be buffered."),null;var a=t[r],s=n>-1?(0,p.getPartWith)(a,i,n):null,o=s?s.fragment:(0,p.getFragmentWithSN)(a,i,this.fragCurrent);return o?{frag:o,part:s,level:a}:null},C.bufferFragmentData=function(e,t,r,i){if(e&&this.state===b.PARSING){var n=e.data1,a=e.data2,s=n;if(n&&a&&(s=(0,d.appendUint8Array)(n,a)),s&&s.length){var o={type:e.type,frag:t,part:r,chunkMeta:i,parent:t.type,data:s};this.hls.trigger(l.Events.BUFFER_APPENDING,o),e.dropped&&e.independent&&!r&&this.flushBufferGap(t)}}},C.flushBufferGap=function(e){var t=this.media;if(t)if(s.BufferHelper.isBuffered(t,t.currentTime)){var r=t.currentTime,i=s.BufferHelper.bufferInfo(t,r,0),n=e.duration,a=Math.min(2*this.config.maxFragLookUpTolerance,.25*n),o=Math.max(Math.min(e.start-a,i.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)},C.getFwdBufferInfo=function(e,t){var r=this.config,n=this.getLoadPosition();if(!(0,i.isFiniteNumber)(n))return null;var a=s.BufferHelper.bufferInfo(e,n,r.maxBufferHole);if(0===a.len&&void 0!==a.nextStart){var o=this.fragmentTracker.getBufferedFrag(n,t);if(o&&a.nextStart<o.end)return s.BufferHelper.bufferInfo(e,n,Math.max(a.nextStart,r.maxBufferHole))}return a},C.getMaxBufferLength=function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)},C.reduceMaxBufferLength=function(e){var t=this.config,r=e||t.maxBufferLength;return t.maxMaxBufferLength>=r&&(t.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},C.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var n,a=this.config,s=r[0].start;if(t.live){var o=a.initialLiveManifestSize;if(i<o)return this.warn("Not enough fragments to start playback (have: "+i+", need: "+o+")"),null;t.PTSKnown||this.startFragRequested||-1!==this.startPosition||(n=this.getInitialLiveFragment(t,r),this.startPosition=n?this.hls.liveSyncPosition||n.start:e)}else e<=s&&(n=r[0]);if(!n){var l=a.lowLatencyMode?t.partEnd:t.fragmentEnd;n=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(n)},C.mapToInitFragWhenRequired=function(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment},C.getNextPart=function(e,t,r){for(var i=-1,n=!1,a=!0,s=0,o=e.length;s<o;s++){var l=e[s];if(a=a&&!l.independent,i>-1&&r<l.start)break;var u=l.loaded;!u&&(n||l.independent||a)&&l.fragment===t&&(i=s),n=u}return i},C.loadedEndOfParts=function(e,t){var r=e[e.length-1];return r&&t>r.start&&r.loaded},C.getInitialLiveFragment=function(e,t){var r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=(0,f.findFragmentByPDT)(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){var n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){var a=t[n-e.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=(0,f.findFragWithCC)(t,r.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn)}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i},C.getFragmentAtPosition=function(e,t,r){var i,n=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,c=n.maxFragLookUpTolerance,d=!!(n.lowLatencyMode&&r.partList&&u);if(d&&u&&!this.bitrateTest&&(o=o.concat(u),l=u.sn),e<t){var h=e>t-c?0:c;i=(0,f.findFragmentByPTS)(s,o,e,h)}else i=o[o.length-1];if(i){var p=i.sn-r.startSN;if(this.fragmentTracker.getState(i)===a.FragmentState.OK&&(s=i),s&&i.sn===s.sn&&!d&&s&&i.level===s.level){var g=o[p+1];i.sn<l&&this.fragmentTracker.getState(g)!==a.FragmentState.OK?(this.log("SN "+i.sn+" just loaded, load next one: "+g.sn),i=g):i=null}}return i},C.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,s=e.edge,o=n>=a-t.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n<i||!o)){var l=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!o&&r.readyState<4||n<s-l)&&(this.loadedmetadata||(this.nextLoadPosition=i),r.readyState&&(this.warn("Playback: "+n.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+i.toFixed(3)),r.currentTime=i))}}},C.alignPlaylists=function(e,t){var r=this.levels,n=this.levelLastLoaded,a=this.fragPrevious,s=null!==n?r[n]:null,o=e.fragments.length;if(!o)return this.warn("No fragments in live playlist"),0;var l=e.fragments[0].start,u=!t,c=e.alignedSliding&&(0,i.isFiniteNumber)(l);if(u||!c&&!l){(0,h.alignStream)(a,s,e);var d=e.fragments[0].start;return this.log("Live playlist sliding: "+d.toFixed(2)+" start-sn: "+(t?t.startSN:"na")+"->"+e.startSN+" prev-sn: "+(a?a.sn:"na")+" fragments: "+o),d}return l},C.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},C.setStartPosition=function(e,t){var r=this.startPosition;if(r<t&&(r=-1),-1===r||-1===this.lastCurrentTime){var n=e.startTimeOffset;(0,i.isFiniteNumber)(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log("Start time offset "+n+" found in playlist, adjust startPosition to "+r),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r},C.getLoadPosition=function(){var e=this.media,t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t},C.handleFragLoadAborted=function(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn("Fragment "+e.sn+(t?" part"+t.index:"")+" of level "+e.level+" was aborted"),this.resetFragmentLoading(e))},C.resetFragmentLoading=function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===b.FRAG_LOADING_WAITING_RETRY)||(this.state=b.IDLE)},C.onFragmentOrKeyLoadError=function(e,t){if(!t.fatal){var r=t.frag;if(r&&r.type===e){var i=this.fragCurrent;console.assert(i&&r.sn===i.sn&&r.level===i.level&&r.urlId===i.urlId,"Frag load error must match current frag to retry");var n=this.config;if(this.fragLoadError+1<=n.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var a=Math.min(Math.pow(2,this.fragLoadError)*n.fragLoadingRetryDelay,n.fragLoadingMaxRetryTimeout);this.warn("Fragment "+r.sn+" of "+e+" "+r.level+" failed to load, retrying in "+a+"ms"),this.retryDate=self.performance.now()+a,this.fragLoadError++,this.state=b.FRAG_LOADING_WAITING_RETRY}else t.levelRetry?(e===y.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=b.IDLE):(o.logger.error(t.details+" reaches max retry, redispatch as fatal ..."),t.fatal=!0,this.hls.stopLoad(),this.state=b.ERROR)}}},C.afterBufferFlushed=function(e,t,r){if(e){var i=s.BufferHelper.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===b.ENDED&&this.resetLoadingState()}},C.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=b.IDLE},C.resetStartWhenNotLoaded=function(e){if(!this.loadedmetadata){this.startFragRequested=!1;var t=this.levels?this.levels[e].details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},C.updateLevelTiming=function(e,t,r,i){var n=this,a=r.details;console.assert(!!a,"level.details must be defined"),Object.keys(e.elementaryStreams).reduce((function(t,s){var o=e.elementaryStreams[s];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return n.warn("Could not parse fragment "+e.sn+" "+s+" duration reliably ("+u+")"),t||!1;var c=i?0:(0,p.updateFragPTSDTS)(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return n.hls.trigger(l.Events.LEVEL_PTS_UPDATED,{details:a,level:r,drift:c,type:s,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)||(this.warn("Found no media in fragment "+e.sn+" of level "+r.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=b.PARSED,this.hls.trigger(l.Events.FRAG_PARSED,{frag:e,part:t})},C.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},k=n,(S=[{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}])&&A(k.prototype,S),_&&A(k,_),Object.defineProperty(k,"prototype",{writable:!1}),n}(n.default)},"./src/controller/buffer-controller.ts": /*!*********************************************!*\ !*** ./src/controller/buffer-controller.ts ***! \*********************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../errors */"./src/errors.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=r(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),d=(0,l.getMediaSource)(),h=/([ha]vc.)(?:\.[^.,]+)+/,f=function(){function e(e){var t=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var e=t.hls,r=t.media,i=t.mediaSource;a.logger.log("[buffer-controller]: Media source opened"),r&&(t.updateMediaElementDuration(),e.trigger(n.Events.MEDIA_ATTACHED,{media:r})),i&&i.removeEventListener("sourceopen",t._onMediaSourceOpen),t.checkPendingTracks()},this._onMediaSourceClose=function(){a.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){a.logger.log("[buffer-controller]: Media source ended")},this.hls=e,this._initSourceBuffer(),this.registerListeners()}var t=e.prototype;return t.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},t.destroy=function(){this.unregisterListeners(),this.details=null},t.registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(n.Events.BUFFER_RESET,this.onBufferReset,this),e.on(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(n.Events.BUFFER_EOS,this.onBufferEos,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(n.Events.FRAG_PARSED,this.onFragParsed,this),e.on(n.Events.FRAG_CHANGED,this.onFragChanged,this)},t.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(n.Events.BUFFER_RESET,this.onBufferReset,this),e.off(n.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(n.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(n.Events.BUFFER_EOS,this.onBufferEos,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(n.Events.FRAG_PARSED,this.onFragParsed,this),e.off(n.Events.FRAG_CHANGED,this.onFragChanged,this)},t._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new c.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},t.onManifestParsed=function(e,t){var r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.details=null,a.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},t.onMediaAttaching=function(e,t){var r=this.media=t.media;if(r&&d){var i=this.mediaSource=new d;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src}},t.onMediaDetaching=function(){var e=this.media,t=this.mediaSource,r=this._objectUrl;if(t){if(a.logger.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){a.logger.warn("[buffer-controller]: onMediaDetaching: "+e.message+" while calling endOfStream")}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):a.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(n.Events.MEDIA_DETACHED,void 0)},t.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach((function(t){var r=e.sourceBuffer[t];try{r&&(e.removeBufferListeners(t),e.mediaSource&&e.mediaSource.removeSourceBuffer(r),e.sourceBuffer[t]=void 0)}catch(e){a.logger.warn("[buffer-controller]: Failed to reset the "+t+" buffer",e)}})),this._initSourceBuffer()},t.onBufferCodecs=function(e,t){var r=this,i=this.getSourceBufferTypes().length;Object.keys(t).forEach((function(e){if(i){var n=r.tracks[e];if(n&&"function"==typeof n.buffer.changeType){var s=t[e],o=s.id,l=s.codec,u=s.levelCodec,c=s.container,d=s.metadata,f=(n.levelCodec||n.codec).replace(h,"$1"),p=(u||l).replace(h,"$1");if(f!==p){var g=c+";codecs="+(u||l);r.appendChangeType(e,g),a.logger.log("[buffer-controller]: switching codec "+f+" to "+p),r.tracks[e]={buffer:n.buffer,codec:l,container:c,levelCodec:u,metadata:d,id:o}}}}else r.pendingTracks[e]=t[e]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},t.appendChangeType=function(e,t){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[e];n&&(a.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+t),n.changeType(t)),i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){a.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",t)}};i.append(n,e)},t.onBufferAppending=function(e,t){var r=this,i=this.hls,l=this.operationQueue,u=this.tracks,c=t.data,d=t.type,h=t.frag,f=t.part,p=t.chunkMeta,g=p.buffering[d],v=self.performance.now();g.start=v;var m=h.stats.buffering,y=f?f.stats.buffering:null;0===m.start&&(m.start=v),y&&0===y.start&&(y.start=v);var A=u.audio,E="audio"===d&&1===p.id&&"audio/mpeg"===(null==A?void 0:A.container),T={execute:function(){if(g.executeStart=self.performance.now(),E){var e=r.sourceBuffer[d];if(e){var t=h.start-e.timestampOffset;Math.abs(t)>=.1&&(a.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+h.start+" (delta: "+t+") sn: "+h.sn+")"),e.timestampOffset=h.start)}}r.appendExecutor(c,d)},onStart:function(){},onComplete:function(){var e=self.performance.now();g.executeEnd=g.end=e,0===m.first&&(m.first=e),y&&0===y.first&&(y.first=e);var t=r.sourceBuffer,i={};for(var a in t)i[a]=o.BufferHelper.getBuffered(t[a]);r.appendError=0,r.hls.trigger(n.Events.BUFFER_APPENDED,{type:d,frag:h,part:f,chunkMeta:p,parent:h.type,timeRanges:i})},onError:function(e){a.logger.error("[buffer-controller]: Error encountered while trying to append to the "+d+" SourceBuffer",e);var t={type:s.ErrorTypes.MEDIA_ERROR,parent:h.type,details:s.ErrorDetails.BUFFER_APPEND_ERROR,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=s.ErrorDetails.BUFFER_FULL_ERROR:(r.appendError++,t.details=s.ErrorDetails.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(a.logger.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),t.fatal=!0,i.stopLoad())),i.trigger(n.Events.ERROR,t)}};l.append(T,d)},t.onBufferFlushing=function(e,t){var r=this,i=this.operationQueue,s=function(e){return{execute:r.removeExecutor.bind(r,e,t.startOffset,t.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(n.Events.BUFFER_FLUSHED,{type:e})},onError:function(t){a.logger.warn("[buffer-controller]: Failed to remove from "+e+" SourceBuffer",t)}}};t.type?i.append(s(t.type),t.type):this.getSourceBufferTypes().forEach((function(e){i.append(s(e),e)}))},t.onFragParsed=function(e,t){var r=this,i=t.frag,s=t.part,o=[],l=s?s.elementaryStreams:i.elementaryStreams;l[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(l[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),l[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&a.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,s&&(s.stats.buffering.end=e);var t=s?s.stats:i.stats;r.hls.trigger(n.Events.FRAG_BUFFERED,{frag:i,part:s,stats:t,id:i.type})}),o)},t.onFragChanged=function(e,t){this.flushBackBuffer()},t.onBufferEos=function(e,t){var r=this;this.getSourceBufferTypes().reduce((function(e,i){var n=r.sourceBuffer[i];return t.type&&t.type!==i||n&&!n.ended&&(n.ended=!0,a.logger.log("[buffer-controller]: "+i+" sourceBuffer now EOS")),e&&!(n&&!n.ended)}),!0)&&this.blockBuffers((function(){var e=r.mediaSource;e&&"open"===e.readyState&&e.endOfStream()}))},t.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},t.flushBackBuffer=function(){var e=this.hls,t=this.details,r=this.media,a=this.sourceBuffer;if(r&&null!==t){var s=this.getSourceBufferTypes();if(s.length){var l=t.live&&null!==e.config.liveBackBufferLength?e.config.liveBackBufferLength:e.config.backBufferLength;if((0,i.isFiniteNumber)(l)&&!(l<0)){var u=r.currentTime,c=t.levelTargetDuration,d=Math.max(l,c),h=Math.floor(u/c)*c-d;s.forEach((function(r){var i=a[r];if(i){var s=o.BufferHelper.getBuffered(i);s.length>0&&h>s.start(0)&&(e.trigger(n.Events.BACK_BUFFER_REACHED,{bufferEnd:h}),t.live&&e.trigger(n.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h}),e.trigger(n.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:r}))}}))}}}},t.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var e=this.details,t=this.hls,r=this.media,n=this.mediaSource,s=e.fragments[0].start+e.totalduration,o=r.duration,l=(0,i.isFiniteNumber)(n.duration)?n.duration:0;e.live&&t.config.liveDurationInfinity?(a.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(s>l&&s>o||!(0,i.isFiniteNumber)(o))&&(a.logger.log("[buffer-controller]: Updating Media Source duration to "+s.toFixed(3)),n.duration=s)}},t.updateSeekableRange=function(e){var t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+e.totalduration);t.setLiveSeekableRange(i,n)}},t.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!e||2===i){this.createSourceBuffers(r),this.pendingTracks={};var a=this.getSourceBufferTypes();if(0===a.length)return void this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});a.forEach((function(e){t.executeNext(e)}))}},t.createSourceBuffers=function(e){var t=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");var i=0;for(var o in e)if(!t[o]){var l=e[o];if(!l)throw Error("source buffer exists for track "+o+", however track does not");var u=l.levelCodec||l.codec,c=l.container+";codecs="+u;a.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var d=t[o]=r.addSourceBuffer(c),h=o;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[o]={buffer:d,codec:u,container:l.container,levelCodec:l.levelCodec,metadata:l.metadata,id:l.id},i++}catch(e){a.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:c})}}i&&this.hls.trigger(n.Events.BUFFER_CREATED,{tracks:this.tracks})},t._onSBUpdateStart=function(e){this.operationQueue.current(e).onStart()},t._onSBUpdateEnd=function(e){var t=this.operationQueue;t.current(e).onComplete(),t.shiftAndExecuteNext(e)},t._onSBUpdateError=function(e,t){a.logger.error("[buffer-controller]: "+e+" SourceBuffer error",t),this.hls.trigger(n.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var r=this.operationQueue.current(e);r&&r.onError(t)},t.removeExecutor=function(e,t,r){var n=this.media,s=this.mediaSource,o=this.operationQueue,l=this.sourceBuffer[e];if(!n||!s||!l)return a.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(e);var u=(0,i.isFiniteNumber)(n.duration)?n.duration:1/0,c=(0,i.isFiniteNumber)(s.duration)?s.duration:1/0,d=Math.max(0,t),h=Math.min(r,u,c);h>d?(a.logger.log("[buffer-controller]: Removing ["+d+","+h+"] from the "+e+" SourceBuffer"),console.assert(!l.updating,e+" sourceBuffer must not be updating"),l.remove(d,h)):o.shiftAndExecuteNext(e)},t.appendExecutor=function(e,t){var r=this.operationQueue,i=this.sourceBuffer[t];if(!i)return a.logger.warn("[buffer-controller]: Attempting to append to the "+t+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(t);i.ended=!1,console.assert(!i.updating,t+" sourceBuffer must not be updating"),i.appendBuffer(e)},t.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.getSourceBufferTypes()),!t.length)return a.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);var i=this.operationQueue,n=t.map((function(e){return i.appendBlocker(e)}));Promise.all(n).then((function(){e(),t.forEach((function(e){var t=r.sourceBuffer[e];t&&t.updating||i.shiftAndExecuteNext(e)}))}))},t.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},t.addBufferListener=function(e,t,r){var i=this.sourceBuffer[e];if(i){var n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),i.addEventListener(t,n)}},t.removeBufferListeners=function(e){var t=this.sourceBuffer[e];t&&this.listeners[e].forEach((function(e){t.removeEventListener(e.event,e.listener)}))},e}()},"./src/controller/buffer-operation-queue.ts": /*!**************************************************!*\ !*** ./src/controller/buffer-operation-queue.ts ***! \**************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=function(){function e(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}var t=e.prototype;return t.append=function(e,t){var r=this.queues[t];r.push(e),1===r.length&&this.buffers[t]&&this.executeNext(t)},t.insertAbort=function(e,t){this.queues[t].unshift(e),this.executeNext(t)},t.appendBlocker=function(e){var t,r=new Promise((function(e){t=e})),i={execute:t,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,e),r},t.executeNext=function(e){var t=this.buffers,r=this.queues,n=t[e],a=r[e];if(a.length){var s=a[0];try{s.execute()}catch(t){i.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),s.onError(t),n&&n.updating||(a.shift(),this.executeNext(e))}}},t.shiftAndExecuteNext=function(e){this.queues[e].shift(),this.executeNext(e)},t.current=function(e){return this.queues[e][0]},e}()},"./src/controller/cap-level-controller.ts": /*!************************************************!*\ !*** ./src/controller/cap-level-controller.ts ***! \************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var i=r(/*! ../events */"./src/events.ts");function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a=function(){function e(e){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var t,r,a,s=e.prototype;return s.setStreamController=function(e){this.streamController=e},s.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},s.registerListeners=function(){var e=this.hls;e.on(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.unregisterListener=function(){var e=this.hls;e.off(i.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(i.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},s.onFpsDropLevelCapping=function(t,r){e.isLevelAllowed(r.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(r.droppedLevel)},s.onMediaAttaching=function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null},s.onManifestParsed=function(e,t){var r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onBufferCodecs=function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()},s.onMediaDetaching=function(){this.stopCapping()},s.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var e=this.hls.levels;if(e.length){var t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},s.getMaxLevel=function(t){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=i.filter((function(i,n){return e.isLevelAllowed(n,r.restrictedLevels)&&n<=t}));return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},s.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},e.isLevelAllowed=function(e,t){return void 0===t&&(t=[]),-1===t.indexOf(e)},e.getMaxLevelByMediaSize=function(e,t,r){if(!e||!e.length)return-1;for(var i,n,a=e.length-1,s=0;s<e.length;s+=1){var o=e[s];if((o.width>=t||o.height>=r)&&(i=o,!(n=e[s+1])||i.width!==n.width||i.height!==n.height)){a=s;break}}return a},t=e,(r=[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}}])&&n(t.prototype,r),a&&n(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}();const s=a},"./src/controller/cmcd-controller.ts": /*!*******************************************!*\ !*** ./src/controller/cmcd-controller.ts ***! \*******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>h});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../types/cmcd */"./src/types/cmcd.ts"),a=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts");function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function l(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},d.apply(this,arguments)}var h=function(){function e(t){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(e){try{r.apply(e,{ot:n.CMCDObjectType.MANIFEST,su:!r.initialized})}catch(e){s.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=function(e){try{var t=e.frag,i=r.hls.levels[t.level],a=r.getObjectType(t),o={d:1e3*t.duration,ot:a};a!==n.CMCDObjectType.VIDEO&&a!==n.CMCDObjectType.AUDIO&&a!=n.CMCDObjectType.MUXED||(o.br=i.bitrate/1e3,o.tb=r.getTopBandwidth(a)/1e3,o.bl=r.getBufferLength(a)),r.apply(e,o)}catch(e){s.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var i=this.config=t.config,a=i.cmcd;null!=a&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=a.sessionId||e.uuid(),this.cid=a.contentId,this.useHeaders=!0===a.useHeaders,this.registerListeners())}var t=e.prototype;return t.registerListeners=function(){var e=this.hls;e.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(i.Events.BUFFER_CREATED,this.onBufferCreated,this)},t.unregisterListeners=function(){var e=this.hls;e.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(i.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},t.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},t.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},t.onBufferCreated=function(e,t){var r,i;this.audioBuffer=null===(r=t.tracks.audio)||void 0===r?void 0:r.buffer,this.videoBuffer=null===(i=t.tracks.video)||void 0===i?void 0:i.buffer},t.createData=function(){var e;return{v:n.CMCDVersion,sf:n.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null===(e=this.media)||void 0===e?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},t.apply=function(t,r){void 0===r&&(r={}),d(r,this.createData());var i=r.ot===n.CMCDObjectType.INIT||r.ot===n.CMCDObjectType.VIDEO||r.ot===n.CMCDObjectType.MUXED;if(this.starved&&i&&(r.bs=!0,r.su=!0,this.starved=!1),null==r.su&&(r.su=this.buffering),this.useHeaders){var a=e.toHeaders(r);if(!Object.keys(a).length)return;t.headers||(t.headers={}),d(t.headers,a)}else{var s=e.toQuery(r);if(!s)return;t.url=e.appendQueryToUri(t.url,s)}},t.getObjectType=function(e){var t=e.type;return"subtitle"===t?n.CMCDObjectType.TIMED_TEXT:"initSegment"===e.sn?n.CMCDObjectType.INIT:"audio"===t?n.CMCDObjectType.AUDIO:"main"===t?this.hls.audioTracks.length?n.CMCDObjectType.VIDEO:n.CMCDObjectType.MUXED:void 0},t.getTopBandwidth=function(e){var t,r=0,i=this.hls;if(e===n.CMCDObjectType.AUDIO)t=i.audioTracks;else{var a=i.maxAutoLevel,s=a>-1?a+1:i.levels.length;t=i.levels.slice(0,s)}for(var o,l=u(t);!(o=l()).done;){var c=o.value;c.bitrate>r&&(r=c.bitrate)}return r>0?r:NaN},t.getBufferLength=function(e){var t=this.hls.media,r=e===n.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return r&&t?1e3*a.BufferHelper.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN},t.createPlaylistLoader=function(){var e=this.config.pLoader,t=this.applyPlaylistData,r=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new r(e)}var i=e.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(e,r,i){t(e),this.loader.load(e,r,i)},l(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),e}()},t.createFragmentLoader=function(){var e=this.config.fLoader,t=this.applyFragmentData,r=e||this.config.loader;return function(){function e(e){this.loader=void 0,this.loader=new r(e)}var i=e.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(e,r,i){t(e),this.loader.load(e,r,i)},l(e,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),e}()},e.uuid=function(){var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)},e.serialize=function(e){for(var t,r=[],i=function(e){return!Number.isNaN(e)&&null!=e&&""!==e&&!1!==e},n=function(e){return Math.round(e)},a=function(e){return 100*n(e/100)},s={br:n,d:n,bl:a,dl:a,mtp:a,nor:function(e){return encodeURIComponent(e)},rtp:a,tb:n},o=u(Object.keys(e||{}).sort());!(t=o()).done;){var l=t.value,c=e[l];if(i(c)&&!("v"===l&&1===c||"pr"==l&&1===c)){var d=s[l];d&&(c=d(c));var h=typeof c,f=void 0;f="ot"===l||"sf"===l||"st"===l?l+"="+c:"boolean"===h?l:"number"===h?l+"="+c:l+"="+JSON.stringify(c),r.push(f)}}return r.join(",")},e.toHeaders=function(t){for(var r={},i=["Object","Request","Session","Status"],n=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},s=0,o=Object.keys(t);s<o.length;s++){var l=o[s];n[null!=a[l]?a[l]:1][l]=t[l]}for(var u=0;u<n.length;u++){var c=e.serialize(n[u]);c&&(r["CMCD-"+i[u]]=c)}return r},e.toQuery=function(t){return"CMCD="+encodeURIComponent(e.serialize(t))},e.appendQueryToUri=function(e,t){if(!t)return e;var r=e.includes("?")?"&":"?";return""+e+r+t},e}()},"./src/controller/eme-controller.ts": /*!******************************************!*\ !*** ./src/controller/eme-controller.ts ***! \******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var l=function(){function e(e){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=e,this._config=e.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var t,r,l,u=e.prototype;return u.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},u._registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this)},u._unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(i.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this)},u.getLicenseServerUrl=function(e){switch(e){case s.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+e+'"')},u._attemptKeySystemAccess=function(e,t,r){var i=this,n=function(e,t,r,i){if(e===s.KeySystems.WIDEVINE)return function(e,t,r){var i={audioCapabilities:[],videoCapabilities:[]};return e.forEach((function(e){i.audioCapabilities.push({contentType:'audio/mp4; codecs="'+e+'"',robustness:r.audioRobustness||""})})),t.forEach((function(e){i.videoCapabilities.push({contentType:'video/mp4; codecs="'+e+'"',robustness:r.videoRobustness||""})})),[i]}(t,r,i);throw new Error("Unknown key-system: "+e)}(e,t,r,this._drmSystemOptions);a.logger.log("Requesting encrypted media key-system access");var o=this.requestMediaKeySystemAccess(e,n);this.mediaKeysPromise=o.then((function(t){return i._onMediaKeySystemAccessObtained(e,t)})),o.catch((function(t){a.logger.error('Failed to obtain key-system "'+e+'" access:',t)}))},u._onMediaKeySystemAccessObtained=function(e,t){var r=this;a.logger.log('Access for key-system "'+e+'" obtained');var i={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:t,mediaKeySystemDomain:e};this._mediaKeysList.push(i);var n=Promise.resolve().then((function(){return t.createMediaKeys()})).then((function(t){return i.mediaKeys=t,a.logger.log('Media-keys created for key-system "'+e+'"'),r._onMediaKeysCreated(),t}));return n.catch((function(e){a.logger.error("Failed to create media-keys:",e)})),n},u._onMediaKeysCreated=function(){var e=this;this._mediaKeysList.forEach((function(t){t.mediaKeysSession||(t.mediaKeysSession=t.mediaKeys.createSession(),e._onNewMediaKeySession(t.mediaKeysSession))}))},u._onNewMediaKeySession=function(e){var t=this;a.logger.log("New key-system session "+e.sessionId),e.addEventListener("message",(function(r){t._onKeySessionMessage(e,r.message)}),!1)},u._onKeySessionMessage=function(e,t){a.logger.log("Got EME message event, creating license request"),this._requestLicense(t,(function(t){a.logger.log("Received license data (length: "+(t?t.byteLength:t)+"), updating key-session"),e.update(t).catch((function(e){a.logger.warn("Updating key-session failed: "+e)}))}))},u.onMediaEncrypted=function(e){var t=this;if(a.logger.log('Media is encrypted using "'+e.initDataType+'" init data type'),!this.mediaKeysPromise)return a.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var r=function(r){t._media&&(t._attemptSetMediaKeys(r),t._generateRequestWithPreferredKeySession(e.initDataType,e.initData))};this.mediaKeysPromise.then(r).catch(r)},u._attemptSetMediaKeys=function(e){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var t=this._mediaKeysList[0];if(!t||!t.mediaKeys)return a.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});a.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(t.mediaKeys),this._hasSetMediaKeys=!0}},u._generateRequestWithPreferredKeySession=function(e,t){var r=this,s=this._mediaKeysList[0];if(!s)return a.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(s.mediaKeysSessionInitialized)a.logger.warn("Key-Session already initialized but requested again");else{var o=s.mediaKeysSession;if(!o)return a.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!t)return a.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});a.logger.log('Generating key-session request for "'+e+'" init data type'),s.mediaKeysSessionInitialized=!0,o.generateRequest(e,t).then((function(){a.logger.debug("Key-session generation succeeded")})).catch((function(e){a.logger.error("Error generating key-session request:",e),r.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},u._createLicenseXhr=function(e,t,r){var i=new XMLHttpRequest;i.responseType="arraybuffer",i.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,i,e,t,r);var n=this._licenseXhrSetup;if(n)try{n.call(this.hls,i,e),n=void 0}catch(e){a.logger.error(e)}try{i.readyState||i.open("POST",e,!0),n&&n.call(this.hls,i,e)}catch(e){throw new Error("issue setting up KeySystem license XHR "+e)}return i},u._onLicenseRequestReadyStageChange=function(e,t,r,s){if(4===e.readyState)if(200===e.status){this._requestLicenseFailureCount=0,a.logger.log("License request succeeded");var o=e.response,l=this._licenseResponseCallback;if(l)try{o=l.call(this.hls,e,t)}catch(e){a.logger.error(e)}s(o)}else{if(a.logger.error("License Request XHR failed ("+t+"). Status: "+e.status+" ("+e.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var u=3-this._requestLicenseFailureCount+1;a.logger.warn("Retrying license request, "+u+" attempts left"),this._requestLicense(r,s)}},u._generateLicenseRequestChallenge=function(e,t){if(e.mediaKeySystemDomain===s.KeySystems.WIDEVINE)return t;throw new Error("unsupported key-system: "+e.mediaKeySystemDomain)},u._requestLicense=function(e,t){a.logger.log("Requesting content license for key-system");var r=this._mediaKeysList[0];if(!r)return a.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var s=this.getLicenseServerUrl(r.mediaKeySystemDomain),o=this._createLicenseXhr(s,e,t);a.logger.log("Sending license request to URL: "+s);var l=this._generateLicenseRequestChallenge(r,e);o.send(l)}catch(e){a.logger.error("Failure requesting DRM license: "+e),this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.KEY_SYSTEM_ERROR,details:n.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},u.onMediaAttached=function(e,t){if(this._emeEnabled){var r=t.media;this._media=r,r.addEventListener("encrypted",this._onMediaEncrypted)}},u.onMediaDetached=function(){var e=this._media,t=this._mediaKeysList;e&&(e.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(t.map((function(e){if(e.mediaKeysSession)return e.mediaKeysSession.close().catch((function(){}))}))).then((function(){return e.setMediaKeys(null)})).catch((function(){})))},u.onManifestParsed=function(e,t){if(this._emeEnabled){var r=t.levels.map((function(e){return e.audioCodec})).filter((function(e){return!!e})),i=t.levels.map((function(e){return e.videoCodec})).filter((function(e){return!!e}));this._attemptKeySystemAccess(s.KeySystems.WIDEVINE,r,i)}},t=e,(r=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&o(t.prototype,r),l&&o(t,l),Object.defineProperty(t,"prototype",{writable:!1}),e}();const u=l},"./src/controller/fps-controller.ts": /*!******************************************!*\ !*** ./src/controller/fps-controller.ts ***! \******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=function(){function e(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.registerListeners=function(){this.hls.on(i.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},t.unregisterListeners=function(){this.hls.off(i.Events.MEDIA_ATTACHING,this.onMediaAttaching)},t.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},t.onMediaAttaching=function(e,t){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},t.checkFPS=function(e,t,r){var a=performance.now();if(t){if(this.lastTime){var s=a-this.lastTime,o=r-this.lastDroppedFrames,l=t-this.lastDecodedFrames,u=1e3*o/s,c=this.hls;if(c.trigger(i.Events.FPS_DROP,{currentDropped:o,currentDecoded:l,totalDroppedFrames:r}),u>0&&o>c.config.fpsDroppedMonitoringThreshold*l){var d=c.currentLevel;n.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(-1===c.autoLevelCapping||c.autoLevelCapping>=d)&&(d-=1,c.trigger(i.Events.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:c.currentLevel}),c.autoLevelCapping=d,this.streamController.nextLevelSwitch())}}this.lastTime=a,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}();const s=a},"./src/controller/fragment-finders.ts": /*!********************************************!*\ !*** ./src/controller/fragment-finders.ts ***! \********************************************/(e,t,r)=>{r.r(t),r.d(t,{findFragWithCC:()=>u,findFragmentByPDT:()=>a,findFragmentByPTS:()=>s,fragmentWithinToleranceTest:()=>o,pdtWithinToleranceTest:()=>l});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function a(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!(0,i.isFiniteNumber)(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(var n=0;n<e.length;++n){var a=e[n];if(l(t,r,a))return a}return null}function s(e,t,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var a=null;if(e?a=t[e.sn-t[0].sn+1]||null:0===r&&0===t[0].start&&(a=t[0]),a&&0===o(r,i,a))return a;var s=n.default.search(t,o.bind(null,r,i));return s||a}function o(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0);var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function l(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function u(e,t){return n.default.search(e,(function(e){return e.cc<t?1:e.cc>t?-1:0}))}},"./src/controller/fragment-tracker.ts": /*!********************************************!*\ !*** ./src/controller/fragment-tracker.ts ***! \********************************************/(e,t,r)=>{r.r(t),r.d(t,{FragmentState:()=>i,FragmentTracker:()=>s});var i,n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../types/loader */"./src/types/loader.ts");!function(e){e.NOT_LOADED="NOT_LOADED",e.APPENDING="APPENDING",e.PARTIAL="PARTIAL",e.OK="OK"}(i||(i={}));var s=function(){function e(e){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e.on(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.on(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.on(n.Events.FRAG_LOADED,this.onFragLoaded,this)},t._unregisterListeners=function(){var e=this.hls;e.off(n.Events.BUFFER_APPENDED,this.onBufferAppended,this),e.off(n.Events.FRAG_BUFFERED,this.onFragBuffered,this),e.off(n.Events.FRAG_LOADED,this.onFragLoaded,this)},t.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){if(t===a.PlaylistLevelType.MAIN){var r=this.activeFragment,i=this.activeParts;if(!r)return null;if(i)for(var n=i.length;n--;){var s=i[n],o=s?s.end:r.appendedPTS;if(s.start<=e&&void 0!==o&&e<=o)return n>9&&(this.activeParts=i.slice(n-9)),s}else if(r.start<=e&&void 0!==r.appendedPTS&&e<=r.appendedPTS)return r}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var a=r[i[n]];if((null==a?void 0:a.body.type)===t&&a.buffered){var s=a.body;if(s.start<=e&&e<=s.end)return s}}return null},t.detectEvictedFragments=function(e,t,r){var i=this;Object.keys(this.fragments).forEach((function(n){var a=i.fragments[n];if(a)if(a.buffered){var s=a.range[e];s&&s.time.some((function(e){var r=!i.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&i.removeFragment(a.body),r}))}else a.body.type===r&&i.removeFragment(a.body)}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,n=e.part;if(r&&"initSegment"!==i.sn){var a=l(i),s=this.fragments[a];s&&(Object.keys(r).forEach((function(e){var a=i.elementaryStreams[e];if(a){var o=r[e],l=null!==n||!0===a.partial;s.range[e]=t.getBufferedTimes(i,n,l,o)}})),s.loaded=null,Object.keys(s.range).length?s.buffered=!0:this.removeFragment(s.body))}},t.fragBuffered=function(e){var t=l(e),r=this.fragments[t];r&&(r.loaded=null,r.buffered=!0)},t.getBufferedTimes=function(e,t,r,i){for(var n={time:[],partial:r},a=t?t.start:e.start,s=t?t.end:e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a,u=0;u<i.length;u++){var c=i.start(u)-this.bufferPadding,d=i.end(u)+this.bufferPadding;if(l>=c&&o<=d){n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(a<d&&s>c)n.partial=!0,n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});else if(s<=c)break}return n},t.getPartialFragment=function(e){var t,r,i,n=null,a=0,s=this.bufferPadding,l=this.fragments;return Object.keys(l).forEach((function(u){var c=l[u];c&&o(c)&&(r=c.body.start-s,i=c.body.end+s,e>=r&&e<=i&&(t=Math.min(e-r,i-e),a<=t&&(n=c.body,a=t)))})),n},t.getState=function(e){var t=l(e),r=this.fragments[t];return r?r.buffered?o(r)?i.PARTIAL:i.OK:i.APPENDING:i.NOT_LOADED},t.isTimeBuffered=function(e,t,r){for(var i,n,a=0;a<r.length;a++){if(i=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=i&&t<=n)return!0;if(t<=i)return!1}return!1},t.onFragLoaded=function(e,t){var r=t.frag,i=t.part;if("initSegment"!==r.sn&&!r.bitrateTest&&!i){var n=l(r);this.fragments[n]={body:r,loaded:t,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=this,i=t.frag,n=t.part,s=t.timeRanges;if(i.type===a.PlaylistLevelType.MAIN)if(this.activeFragment=i,n){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(n)}else this.activeParts=null;this.timeRanges=s,Object.keys(s).forEach((function(e){var t=s[e];if(r.detectEvictedFragments(e,t),!n)for(var a=0;a<t.length;a++)i.appendedPTS=Math.max(t.end(a),i.appendedPTS||0)}))},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=l(e);return!!this.fragments[t]},t.removeFragmentsInRange=function(e,t,r){var i=this;Object.keys(this.fragments).forEach((function(n){var a=i.fragments[n];if(a&&a.buffered){var s=a.body;s.type===r&&s.start<t&&s.end>e&&i.removeFragment(s)}}))},t.removeFragment=function(e){var t=l(e);e.stats.loaded=0,e.clearElementaryStreamInfo(),delete this.fragments[t]},t.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},e}();function o(e){var t,r;return e.buffered&&((null===(t=e.range.video)||void 0===t?void 0:t.partial)||(null===(r=e.range.audio)||void 0===r?void 0:r.partial))}function l(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn}},"./src/controller/gap-controller.ts": /*!******************************************!*\ !*** ./src/controller/gap-controller.ts ***! \******************************************/(e,t,r)=>{r.r(t),r.d(t,{MAX_START_GAP_JUMP:()=>l,SKIP_BUFFER_HOLE_STEP_SECONDS:()=>u,SKIP_BUFFER_RANGE_START:()=>c,STALL_MINIMUM_DURATION_MS:()=>o,default:()=>d});var i=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),n=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../events */"./src/events.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=250,l=2,u=.1,c=.05,d=function(){function e(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}var t=e.prototype;return t.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},t.poll=function(e,t){var r=this.config,n=this.media,a=this.stalled;if(null!==n){var u=n.currentTime,c=n.seeking,d=this.seeking&&!c,h=!this.seeking&&c;if(this.seeking=c,u===e){if((h||d)&&(this.stalled=null),!(n.paused&&!c||n.ended||0===n.playbackRate)&&i.BufferHelper.getBuffered(n).length){var f=i.BufferHelper.bufferInfo(n,u,0),p=f.len>0,g=f.nextStart||0;if(p||g){if(c){var v=f.len>l,m=!g||t&&t.start<=u||g-u>l&&!this.fragmentTracker.getPartialFragment(u);if(v||m)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var y,A=Math.max(g,f.start||0)-u,E=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,T=(null==E||null===(y=E.details)||void 0===y?void 0:y.live)?2*E.details.targetduration:l;if(A>0&&A<=T)return void this._trySkipBufferHole(null)}var b=self.performance.now();if(null!==a){var k=b-a;if(c||!(k>=o)||(this._reportStall(f),this.media)){var S=i.BufferHelper.bufferInfo(n,u,r.maxBufferHole);this._tryFixBufferStall(S,k)}}else this.stalled=b}}}else if(this.moved=!0,null!==a){if(this.stallReported){var _=self.performance.now()-a;s.logger.warn("playback not stuck anymore @"+u+", after "+Math.round(_)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},t._tryFixBufferStall=function(e,t){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,o=i.getPartialFragment(a);if(o&&(this._trySkipBufferHole(o)||!this.media))return;e.len>r.maxBufferHole&&t>1e3*r.highBufferWatchdogPeriod&&(s.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},t._reportStall=function(e){var t=this.hls,r=this.media;!this.stallReported&&r&&(this.stallReported=!0,s.logger.warn("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(e)+")"),t.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e.len}))},t._trySkipBufferHole=function(e){var t=this.config,r=this.hls,o=this.media;if(null===o)return 0;for(var l=o.currentTime,d=0,h=i.BufferHelper.getBuffered(o),f=0;f<h.length;f++){var p=h.start(f);if(l+t.maxBufferHole>=d&&l<p){var g=Math.max(p+c,o.currentTime+u);return s.logger.warn("skipping hole, adjusting currentTime from "+l+" to "+g),this.moved=!0,this.stalled=null,o.currentTime=g,e&&r.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+l+" to "+g,frag:e}),g}d=h.end(f)}return 0},t._tryNudgeBuffer=function(){var e=this.config,t=this.hls,r=this.media,i=this.nudgeRetry;if(null!==r){var o=r.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){var l=o+(i+1)*e.nudgeOffset;s.logger.warn("Nudging 'currentTime' from "+o+" to "+l),r.currentTime=l,t.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else s.logger.error("Playhead still not moving while enough data buffered @"+o+" after "+e.nudgeMaxRetry+" nudges"),t.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},e}()},"./src/controller/id3-track-controller.ts": /*!************************************************!*\ !*** ./src/controller/id3-track-controller.ts ***! \************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ../loader/date-range */"./src/loader/date-range.ts"),l=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function u(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}var c=function(){var e=u();try{new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY}();function d(e,t){return e.getTime()/1e3-t}var h=function(){function e(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}var t=e.prototype;return t.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},t._registerListeners=function(){var e=this.hls;e.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},t._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},t.onMediaAttached=function(e,t){this.media=t.media},t.onMediaDetaching=function(){this.id3Track&&((0,a.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},t.onManifestLoading=function(){this.dateRangeCuesAppended={}},t.createTrack=function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t},t.getID3Track=function(e){if(this.media){for(var t=0;t<e.length;t++){var r=e[t];if("metadata"===r.kind&&"id3"===r.label)return(0,a.sendAddTrackEvent)(r,this.media),r}return this.media.addTextTrack("metadata","id3")}},t.onFragParsingMetadata=function(e,t){if(this.media){var r=this.hls.config,i=r.enableEmsgMetadataCues,n=r.enableID3MetadataCues;if(i||n){t.frag;var a=t.samples;t.details,this.id3Track||(this.id3Track=this.createTrack(this.media));for(var o=u(),d=0;d<a.length;d++){var h=a[d].type;if((h!==l.MetadataSchema.emsg||i)&&n){var f=s.getID3Frames(a[d].data);if(f){var p=a[d].pts,g=p+a[d].duration;g>c&&(g=c),g-p<=0&&(g=p+.25);for(var v=0;v<f.length;v++){var m=f[v];if(!s.isTimeStampFrame(m)){this.updateId3CueEnds(p);var y=new o(p,g,"");y.value=m,h&&(y.type=h),this.id3Track.addCue(y)}}}}}}}},t.updateId3CueEnds=function(e){var t,r=null===(t=this.id3Track)||void 0===t?void 0:t.cues;if(r)for(var i=r.length;i--;){var n=r[i];n.startTime<e&&n.endTime===c&&(n.endTime=e)}},t.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,n=t.type,s=this.id3Track,o=this.hls;if(o){var u,c=o.config,d=c.enableEmsgMetadataCues,h=c.enableID3MetadataCues;s&&(d||h)&&(u="audio"===n?function(e){return e.type===l.MetadataSchema.audioId3&&h}:"video"===n?function(e){return e.type===l.MetadataSchema.emsg&&d}:function(e){return e.type===l.MetadataSchema.audioId3&&h||e.type===l.MetadataSchema.emsg&&d},(0,a.removeCuesInRange)(s,r,i,u))}},t.onLevelUpdated=function(e,t){var r=this,n=t.details;if(this.media&&n.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){var a=this.dateRangeCuesAppended,s=this.id3Track,h=n.dateRanges,f=Object.keys(h);if(s)for(var p=Object.keys(a).filter((function(e){return!f.includes(e)})),g=function(e){var t=p[e];Object.keys(a[t].cues).forEach((function(e){s.removeCue(a[t].cues[e])})),delete a[t]},v=p.length;v--;)g(v);var m=n.fragments[n.fragments.length-1];if(0!==f.length&&(0,i.isFiniteNumber)(null==m?void 0:m.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var y=m.programDateTime/1e3-m.start,A=u(),E=function(e){var t=f[e],i=h[t],n=a[t],s=(null==n?void 0:n.cues)||{},u=(null==n?void 0:n.durationKnown)||!1,p=d(i.startDate,y),g=c,v=i.endDate;if(v)g=d(v,y),u=!0;else if(i.endOnNext&&!u){var m=f.reduce((function(e,t){var r=h[t];return r.class===i.class&&r.id!==t&&r.startDate>i.startDate&&e.push(r),e}),[]).sort((function(e,t){return e.startDate.getTime()-t.startDate.getTime()}))[0];m&&(g=d(m.startDate,y),u=!0)}for(var E,T=Object.keys(i.attr),b=0;b<T.length;b++){var k=T[b];if(k!==o.DateRangeAttribute.ID&&k!==o.DateRangeAttribute.CLASS&&k!==o.DateRangeAttribute.START_DATE&&k!==o.DateRangeAttribute.DURATION&&k!==o.DateRangeAttribute.END_DATE&&k!==o.DateRangeAttribute.END_ON_NEXT){var S=s[k];if(S)u&&!n.durationKnown&&(S.endTime=g);else{var _=i.attr[k];S=new A(p,g,""),k!==o.DateRangeAttribute.SCTE35_OUT&&k!==o.DateRangeAttribute.SCTE35_IN||(E=_,_=Uint8Array.from(E.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer),S.value={key:k,data:_},S.type=l.MetadataSchema.dateRange,r.id3Track.addCue(S),s[k]=S}}}a[t]={cues:s,dateRange:i,durationKnown:u}},T=0;T<f.length;T++)E(T)}}},e}();const f=h},"./src/controller/latency-controller.ts": /*!**********************************************!*\ !*** ./src/controller/latency-controller.ts ***! \**********************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var i=r(/*! ../errors */"./src/errors.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts");function s(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var o=function(){function e(e){var t=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return t.timeupdate()},this.hls=e,this.config=e.config,this.registerListeners()}var t,r,o,l=e.prototype;return l.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},l.registerListeners=function(){this.hls.on(n.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(n.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(n.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){this.hls.off(n.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(n.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(n.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(n.Events.ERROR,this.onError)},l.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},l.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},l.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},l.onLevelUpdated=function(e,t){var r=t.details;this.levelDetails=r,r.advanced&&this.timeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},l.onError=function(e,t){t.details===i.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,a.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},l.timeupdate=function(){var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var r=this.computeLatency();if(null!==r){this._latency=r;var i=this.config,n=i.lowLatencyMode,a=i.maxLiveSyncPlaybackRate;if(n&&1!==a){var s=this.targetLatency;if(null!==s){var o=r-s,l=o<Math.min(this.maxLatency,s+t.targetduration);if(t.live&&l&&o>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,a)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}}}}},l.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},l.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},t=e,(r=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config,t=this.levelDetails;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e)return null;var t=e.holdBack,r=e.partHoldBack,i=e.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*i);var c=i;return u+Math.min(1*this.stallCount,c)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;var i=r.edge,n=e-t-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}])&&s(t.prototype,r),o&&s(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/controller/level-controller.ts": /*!********************************************!*\ !*** ./src/controller/level-controller.ts ***! \********************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>p});var i=r(/*! ../types/level */"./src/types/level.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),l=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts");function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},c.apply(this,arguments)}function d(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function h(e,t){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},h(e,t)}var f=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),p=function(e){var t,r;function l(t){var r;return(r=e.call(this,t,"[level-controller]")||this)._levels=[],r._firstLevel=-1,r._startLevel=void 0,r.currentLevelIndex=-1,r.manualLevelIndex=-1,r.onParsedComplete=void 0,r._registerListeners(),r}r=e,(t=l).prototype=Object.create(r.prototype),t.prototype.constructor=t,h(t,r);var p,g,v,m=l.prototype;return m._registerListeners=function(){var e=this.hls;e.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(n.Events.ERROR,this.onError,this)},m._unregisterListeners=function(){var e=this.hls;e.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(n.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(n.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(n.Events.ERROR,this.onError,this)},m.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},m.startLoad=function(){this._levels.forEach((function(e){e.loadError=0})),e.prototype.startLoad.call(this)},m.onManifestLoaded=function(e,t){var r,l,u=[],c=[],d=[],h={},p=!1,g=!1,v=!1;if(t.levels.forEach((function(e){var t=e.attrs;p=p||!(!e.width||!e.height),g=g||!!e.videoCodec,v=v||!!e.audioCodec,f&&e.audioCodec&&-1!==e.audioCodec.indexOf("mp4a.40.34")&&(e.audioCodec=void 0);var r=e.bitrate+"-"+e.attrs.RESOLUTION+"-"+e.attrs.CODECS;(l=h[r])?l.url.push(e.url):(l=new i.Level(e),h[r]=l,u.push(l)),t&&(t.AUDIO&&(0,o.addGroupId)(l,"audio",t.AUDIO),t.SUBTITLES&&(0,o.addGroupId)(l,"text",t.SUBTITLES))})),(p||g)&&v&&(u=u.filter((function(e){var t=e.videoCodec,r=e.width,i=e.height;return!!t||!(!r||!i)}))),u=u.filter((function(e){var t=e.audioCodec,r=e.videoCodec;return(!t||(0,s.isCodecSupportedInMp4)(t,"audio"))&&(!r||(0,s.isCodecSupportedInMp4)(r,"video"))})),t.audioTracks&&(c=t.audioTracks.filter((function(e){return!e.audioCodec||(0,s.isCodecSupportedInMp4)(e.audioCodec,"audio")})),(0,o.assignTrackIdsByGroup)(c)),t.subtitles&&(d=t.subtitles,(0,o.assignTrackIdsByGroup)(d)),u.length>0){r=u[0].bitrate,u.sort((function(e,t){return e.bitrate-t.bitrate})),this._levels=u;for(var m=0;m<u.length;m++)if(u[m].bitrate===r){this._firstLevel=m,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+r);break}var y=v&&!g,A={levels:u,audioTracks:c,subtitleTracks:d,firstLevel:this._firstLevel,stats:t.stats,audio:v,video:g,altAudio:!y&&c.some((function(e){return!!e.url}))};this.hls.trigger(n.Events.MANIFEST_PARSED,A),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},m.onError=function(t,r){var i;if(e.prototype.onError.call(this,t,r),!r.fatal){var n=r.context,s=this._levels[this.currentLevelIndex];if(n&&(n.type===u.PlaylistContextType.AUDIO_TRACK&&s.audioGroupIds&&n.groupId===s.audioGroupIds[s.urlId]||n.type===u.PlaylistContextType.SUBTITLE_TRACK&&s.textGroupIds&&n.groupId===s.textGroupIds[s.urlId]))this.redundantFailover(this.currentLevelIndex);else{var o,l=!1,c=!0;switch(r.details){case a.ErrorDetails.FRAG_LOAD_ERROR:case a.ErrorDetails.FRAG_LOAD_TIMEOUT:case a.ErrorDetails.KEY_LOAD_ERROR:case a.ErrorDetails.KEY_LOAD_TIMEOUT:if(r.frag){var d=r.frag.type===u.PlaylistLevelType.MAIN?r.frag.level:this.currentLevelIndex,h=this._levels[d];h?(h.fragmentError++,h.fragmentError>this.hls.config.fragLoadingMaxRetry&&(o=d)):o=d}break;case a.ErrorDetails.LEVEL_LOAD_ERROR:case a.ErrorDetails.LEVEL_LOAD_TIMEOUT:n&&(n.deliveryDirectives&&(c=!1),o=n.level),l=!0;break;case a.ErrorDetails.REMUX_ALLOC_ERROR:o=null!=(i=r.level)?i:this.currentLevelIndex,l=!0}void 0!==o&&this.recoverLevel(r,o,l,c)}}},m.recoverLevel=function(e,t,r,i){var n=e.details,a=this._levels[t];if(a.loadError++,r){if(!this.retryLoadingOrFail(e))return void(this.currentLevelIndex=-1);e.levelRetry=!0}if(i){var s=a.url.length;if(s>1&&a.loadError<s)e.levelRetry=!0,this.redundantFailover(t);else if(-1===this.manualLevelIndex){for(var o=-1,l=this._levels,u=l.length;u--;){var c=(u+this.currentLevelIndex)%l.length;if(c!==this.currentLevelIndex&&0===l[c].loadError){o=c;break}}o>-1&&this.currentLevelIndex!==o&&(this.warn(n+": switch to "+o),e.levelRetry=!0,this.hls.nextAutoLevel=o)}}},m.redundantFailover=function(e){var t=this._levels[e],r=t.url.length;if(r>1){var i=(t.urlId+1)%r;this.warn("Switching to redundant URL-id "+i),this._levels.forEach((function(e){e.urlId=i})),this.level=e}},m.onFragLoaded=function(e,t){var r=t.frag;if(void 0!==r&&r.type===u.PlaylistLevelType.MAIN){var i=this._levels[r.level];void 0!==i&&(i.fragmentError=0,i.loadError=0)}},m.onLevelLoaded=function(e,t){var r,i,n=t.level,a=t.details,s=this._levels[n];if(!s)return this.warn("Invalid level index "+n),void(null!==(i=t.deliveryDirectives)&&void 0!==i&&i.skip&&(a.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0,this.retryCount=0),this.playlistLoaded(n,t,s.details)):null!==(r=t.deliveryDirectives)&&void 0!==r&&r.skip&&(a.deltaUpdateFailed=!0)},m.onAudioTrackSwitched=function(e,t){var r=this.hls.levels[this.currentLevelIndex];if(r&&r.audioGroupIds){for(var i=-1,n=this.hls.audioTracks[t.id].groupId,a=0;a<r.audioGroupIds.length;a++)if(r.audioGroupIds[a]===n){i=a;break}i!==r.urlId&&(r.urlId=i,this.startLoad())}},m.loadPlaylist=function(e){var t=this.currentLevelIndex,r=this._levels[t];if(this.canLoad&&r&&r.url.length>0){var i=r.urlId,a=r.url[i];if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Attempt loading level index "+t+(e?" at sn "+e.msn+" part "+e.part:"")+" with URL-id "+i+" "+a),this.clearTimer(),this.hls.trigger(n.Events.LEVEL_LOADING,{url:a,level:t,id:i,deliveryDirectives:e||null})}},m.removeLevel=function(e,t){var r=function(e,r){return r!==t},i=this._levels.filter((function(i,n){return n!==e||i.url.length>1&&void 0!==t&&(i.url=i.url.filter(r),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(r)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(r)),i.urlId=0,!0)})).map((function(e,t){var r=e.details;return null!=r&&r.fragments&&r.fragments.forEach((function(e){e.level=t})),e}));this._levels=i,this.hls.trigger(n.Events.LEVELS_UPDATED,{levels:i})},p=l,(g=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t,r=this._levels;if(0!==r.length&&(this.currentLevelIndex!==e||null===(t=r[e])||void 0===t||!t.details)){if(e<0||e>=r.length){var i=e<0;if(this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.OTHER_ERROR,details:a.ErrorDetails.LEVEL_SWITCH_ERROR,level:e,fatal:i,reason:"invalid level idx"}),i)return;e=Math.min(e,r.length-1)}this.clearTimer();var s=this.currentLevelIndex,o=r[s],l=r[e];this.log("switching to level "+e+" from "+s),this.currentLevelIndex=e;var u=c({},l,{level:e,maxBitrate:l.maxBitrate,uri:l.uri,urlId:l.urlId});delete u._urlId,this.hls.trigger(n.Events.LEVEL_SWITCHING,u);var d=l.details;if(!d||d.live){var h=this.switchParams(l.uri,null==o?void 0:o.details);this.loadPlaylist(h)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])&&d(p.prototype,g),v&&d(p,v),Object.defineProperty(p,"prototype",{writable:!1}),l}(l.default)},"./src/controller/level-helper.ts": /*!****************************************!*\ !*** ./src/controller/level-helper.ts ***! \****************************************/(e,t,r)=>{r.r(t),r.d(t,{addGroupId:()=>o,addSliding:()=>v,adjustSliding:()=>g,assignTrackIdsByGroup:()=>l,computeReloadInterval:()=>m,getFragmentWithSN:()=>y,getPartWith:()=>A,mapFragmentIntersection:()=>p,mapPartIntersection:()=>f,mergeDetails:()=>h,updateFragPTSDTS:()=>d,updatePTS:()=>u});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../utils/logger */"./src/utils/logger.ts"),a=r(/*! ../loader/date-range */"./src/loader/date-range.ts");function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},s.apply(this,arguments)}function o(e,t,r){switch(t){case"audio":e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds.push(r);break;case"text":e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds.push(r)}}function l(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}function u(e,t,r){c(e[t],e[r])}function c(e,t){var r=t.startPTS;if((0,i.isFiniteNumber)(r)){var n,a=0;t.sn>e.sn?(a=r-e.start,n=e):(a=e.start-r,n=t),n.duration!==a&&(n.duration=a)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function d(e,t,r,a,s,o){a-r<=0&&(n.logger.warn("Fragment should have a positive duration",t),a=r+t.duration,o=s+t.duration);var l=r,u=a,d=t.startPTS,h=t.endPTS;if((0,i.isFiniteNumber)(d)){var f=Math.abs(d-r);(0,i.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(f,t.deltaPTS):t.deltaPTS=f,l=Math.max(r,d),r=Math.min(r,d),s=Math.min(s,t.startDTS),u=Math.min(a,h),a=Math.max(a,h),o=Math.max(o,t.endDTS)}t.duration=a-r;var p=r-t.start;t.appendedPTS=a,t.start=t.startPTS=r,t.maxStartPTS=l,t.startDTS=s,t.endPTS=a,t.minEndPTS=u,t.endDTS=o;var g,v=t.sn;if(!e||v<e.startSN||v>e.endSN)return 0;var m=v-e.startSN,y=e.fragments;for(y[m]=t,g=m;g>0;g--)c(y[g],y[g-1]);for(g=m;g<y.length-1;g++)c(y[g],y[g+1]);return e.fragmentHint&&c(y[y.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,p}function h(e,t){for(var r=null,o=e.fragments,l=o.length-1;l>=0;l--){var u=o[l].initSegment;if(u){r=u;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;var c,h,v,m,y,A=0;if(p(e,t,(function(e,n){e.relurl&&(A=e.cc-n.cc),(0,i.isFiniteNumber)(e.startPTS)&&(0,i.isFiniteNumber)(e.endPTS)&&(n.start=n.startPTS=e.startPTS,n.startDTS=e.startDTS,n.appendedPTS=e.appendedPTS,n.maxStartPTS=e.maxStartPTS,n.endPTS=e.endPTS,n.endDTS=e.endDTS,n.minEndPTS=e.minEndPTS,n.duration=e.endPTS-e.startPTS,n.duration&&(c=n),t.PTSKnown=t.alignedSliding=!0),n.elementaryStreams=e.elementaryStreams,n.loader=e.loader,n.stats=e.stats,n.urlId=e.urlId,e.initSegment&&(n.initSegment=e.initSegment,r=e.initSegment)})),r&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((function(e){var t;e.initSegment&&e.initSegment.relurl!==(null===(t=r)||void 0===t?void 0:t.relurl)||(e.initSegment=r)})),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((function(e){return!e})),t.deltaUpdateFailed){n.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var E=t.skippedSegments;E--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=(h=e.dateRanges,v=t.dateRanges,m=t.recentlyRemovedDateranges,y=s({},h),m&&m.forEach((function(e){delete y[e]})),Object.keys(v).forEach((function(e){var t=new a.DateRange(v[e].attr,y[e]);t.isValid?y[e]=t:n.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(v[e].attr)+'"')})),y));var T=t.fragments;if(A){n.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<T.length;b++)T[b].cc+=A}t.skippedSegments&&(t.startCC=t.fragments[0].cc),f(e.partList,t.partList,(function(e,t){t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),c?d(t,c,c.startPTS,c.endPTS,c.startDTS,c.endDTS):g(e,t),T.length&&(t.totalduration=t.edge-T[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var k=t.advancedDateTime;if(t.advanced&&k){var S=t.edge;t.driftStart||(t.driftStartTime=k,t.driftStart=S),t.driftEndTime=k,t.driftEnd=S}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function f(e,t,r){if(e&&t)for(var i=0,n=0,a=e.length;n<=a;n++){var s=e[n],o=t[n+i];s&&o&&s.index===o.index&&s.fragment.sn===o.fragment.sn?r(s,o):i--}}function p(e,t,r){for(var i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,a=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,s=t.startSN-e.startSN,o=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,u=n;u<=a;u++){var c=l[s+u],d=o[u];i&&!d&&u<i&&(d=t.fragments[u]=c),c&&d&&r(c,d)}}function g(e,t){var r=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;r<0||r>=i.length||v(t,i[r].start)}function v(e,t){if(t){for(var r=e.fragments,i=e.skippedSegments;i<r.length;i++)r[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function m(e,t){var r,i=1e3*e.levelTargetDuration,n=i/2,a=e.age,s=a>0&&a<3*i,o=t.loading.end-t.loading.start,l=e.availabilityDelay;if(!1===e.updated)if(s){var u=333*e.misses;r=Math.max(Math.min(n,2*o),u),e.availabilityDelay=(e.availabilityDelay||0)+r}else r=n;else s?(l=Math.min(l||i/2,a),e.availabilityDelay=l,r=l+i-a):r=i-o;return Math.round(r)}function y(e,t,r){if(!e||!e.details)return null;var i=e.details,n=i.fragments[t-i.startSN];return n||((n=i.fragmentHint)&&n.sn===t?n:t<i.startSN&&r&&r.sn===t?r:null)}function A(e,t,r){if(!e||!e.details)return null;var i=e.details.partList;if(i)for(var n=i.length;n--;){var a=i[n];if(a.index===r&&a.fragment.sn===t)return a}return null}},"./src/controller/stream-controller.ts": /*!*********************************************!*\ !*** ./src/controller/stream-controller.ts ***! \*********************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),a=r(/*! ../is-supported */"./src/is-supported.ts"),s=r(/*! ../events */"./src/events.ts"),o=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),l=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),d=r(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),h=r(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),f=r(/*! ./gap-controller */"./src/controller/gap-controller.ts"),p=r(/*! ../errors */"./src/errors.ts");function g(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function v(e,t){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},v(e,t)}var m=function(e){var t,r;function m(t,r){var i;return(i=e.call(this,t,r,"[stream-controller]")||this).audioCodecSwap=!1,i.gapController=null,i.level=-1,i._forceStartLoad=!1,i.altAudio=!1,i.audioOnly=!1,i.fragPlaying=null,i.onvplaying=null,i.onvseeked=null,i.fragLastKbps=0,i.couldBacktrack=!1,i.backtrackFragment=null,i.audioCodecSwitch=!1,i.videoBuffer=null,i._registerListeners(),i}r=e,(t=m).prototype=Object.create(r.prototype),t.prototype.constructor=t,v(t,r);var y,A,E,T=m.prototype;return T._registerListeners=function(){var e=this.hls;e.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(s.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(s.Events.ERROR,this.onError,this),e.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),e.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},T._unregisterListeners=function(){var e=this.hls;e.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(s.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(s.Events.ERROR,this.onError,this),e.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(s.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),e.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(s.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},T.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},T.startLoad=function(e){if(this.levels){var t=this.lastCurrentTime,r=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var i=r.startLevel;-1===i&&(r.config.testBandwidth&&this.levels.length>1?(i=0,this.bitrateTest=!0):i=r.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}t>0&&-1===e&&(this.log("Override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=n.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=n.State.STOPPED},T.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},T.doTick=function(){switch(this.state){case n.State.IDLE:this.doTickIdle();break;case n.State.WAITING_LEVEL:var e,t=this.levels,r=this.level,i=null==t||null===(e=t[r])||void 0===e?void 0:e.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=n.State.IDLE;break}break;case n.State.FRAG_LOADING_WAITING_RETRY:var a,s=self.performance.now(),o=this.retryDate;(!o||s>=o||null!==(a=this.media)&&void 0!==a&&a.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=n.State.IDLE)}this.onTickEnd()},T.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},T.doTickIdle=function(){var e,t,r=this.hls,i=this.levelLastLoaded,a=this.levels,o=this.media,d=r.config,h=r.nextLoadLevel;if(null!==i&&(o||!this.startFragRequested&&d.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&a&&a[h]){var f=a[h];this.level=r.nextLoadLevel=h;var p=f.details;if(!p||this.state===n.State.WAITING_LEVEL||p.live&&this.levelLastLoaded!==h)this.state=n.State.WAITING_LEVEL;else{var g=this.getMainFwdBufferInfo();if(null!==g&&!(g.len>=this.getMaxBufferLength(f.maxBitrate))){if(this._streamEnded(g,p)){var v={};return this.altAudio&&(v.type="video"),this.hls.trigger(s.Events.BUFFER_EOS,v),void(this.state=n.State.ENDED)}this.backtrackFragment&&this.backtrackFragment.start>g.end&&(this.backtrackFragment=null);var m=this.backtrackFragment?this.backtrackFragment.start:g.end,y=this.getNextFragment(m,p);if(this.couldBacktrack&&!this.fragPrevious&&y&&"initSegment"!==y.sn&&this.fragmentTracker.getState(y)!==l.FragmentState.OK){var A,E=(null!=(A=this.backtrackFragment)?A:y).sn-p.startSN,T=p.fragments[E-1];T&&y.cc===T.cc&&(y=T,this.fragmentTracker.removeFragment(T))}else this.backtrackFragment&&g.len&&(this.backtrackFragment=null);if(y&&this.fragmentTracker.getState(y)===l.FragmentState.OK&&this.nextLoadPosition>m){var b=this.audioOnly&&!this.altAudio?c.ElementaryStreamTypes.AUDIO:c.ElementaryStreamTypes.VIDEO;o&&this.afterBufferFlushed(o,b,u.PlaylistLevelType.MAIN),y=this.getNextFragment(this.nextLoadPosition,p)}y&&(!y.initSegment||y.initSegment.data||this.bitrateTest||(y=y.initSegment),"identity"!==(null===(e=y.decryptdata)||void 0===e?void 0:e.keyFormat)||null!==(t=y.decryptdata)&&void 0!==t&&t.key?this.loadFragment(y,p,m):this.loadKey(y,p))}}}},T.loadFragment=function(t,r,i){var n,a=this.fragmentTracker.getState(t);this.fragCurrent=t,a===l.FragmentState.NOT_LOADED?"initSegment"===t.sn?this._loadInitSegment(t):this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t)):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,i)):a===l.FragmentState.APPENDING?this.reduceMaxBufferLength(t.duration)&&this.fragmentTracker.removeFragment(t):0===(null===(n=this.media)||void 0===n?void 0:n.buffered.length)&&this.fragmentTracker.removeAllFragments()},T.getAppendedFrag=function(e){var t=this.fragmentTracker.getAppendedFrag(e,u.PlaylistLevelType.MAIN);return t&&"fragment"in t?t.fragment:t},T.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,u.PlaylistLevelType.MAIN)},T.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},T.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},T.nextLevelSwitch=function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var r,i=this.getAppendedFrag(t.currentTime);if(i&&i.start>1&&this.flushMainBuffer(0,i.start-1),!t.paused&&e){var n=e[this.hls.nextLoadLevel],a=this.fragLastKbps;r=a&&this.fragCurrent?this.fragCurrent.duration*n.maxBitrate/(1e3*a)+1:0}else r=0;var s=this.getBufferedFrag(t.currentTime+r);if(s){var o=this.followingBufferedFrag(s);if(o){this.abortCurrentFrag();var l=o.maxStartPTS?o.maxStartPTS:o.start,u=o.duration,c=Math.max(s.end,l+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,.5*u),.75*u));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},T.abortCurrentFrag=function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,null!=e&&e.loader&&e.loader.abort(),this.state){case n.State.KEY_LOADING:case n.State.FRAG_LOADING:case n.State.FRAG_LOADING_WAITING_RETRY:case n.State.PARSING:case n.State.PARSED:this.state=n.State.IDLE}this.nextLoadPosition=this.getLoadPosition()},T.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.altAudio?"video":null)},T.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var i=r.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 f.default(this.config,i,this.fragmentTracker,this.hls)},T.onMediaDetaching=function(){var t=this.media;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),e.prototype.onMediaDetaching.call(this)},T.onMediaPlaying=function(){this.tick()},T.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:null;(0,i.isFiniteNumber)(t)&&this.log("Media seeked to "+t.toFixed(3)),this.tick()},T.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(s.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},T.onManifestParsed=function(e,t){var r,i=!1,n=!1;t.levels.forEach((function(e){(r=e.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(i=!0),-1!==r.indexOf("mp4a.40.5")&&(n=!0))})),this.audioCodecSwitch=i&&n&&!(0,a.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1},T.onLevelLoading=function(e,t){var r=this.levels;if(r&&this.state===n.State.IDLE){var i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(i.details))&&(this.state=n.State.WAITING_LEVEL)}},T.onLevelLoaded=function(e,t){var r,i=this.levels,a=t.level,o=t.details,l=o.totalduration;if(i){this.log("Level "+a+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.endCC+"] duration:"+l);var u=this.fragCurrent;!u||this.state!==n.State.FRAG_LOADING&&this.state!==n.State.FRAG_LOADING_WAITING_RETRY||u.level!==t.level&&u.loader&&(this.state=n.State.IDLE,this.backtrackFragment=null,u.loader.abort());var c=i[a],d=0;if(o.live||null!==(r=c.details)&&void 0!==r&&r.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,c.details)}if(c.details=o,this.levelLastLoaded=a,this.hls.trigger(s.Events.LEVEL_UPDATED,{details:o,level:a}),this.state===n.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=n.State.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,d),this.tick()}else this.warn("Levels were reset while loading level "+a)},T._handleFragmentLoadProgress=function(e){var t,r=e.frag,i=e.part,n=e.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(o){var l=s.videoCodec,c=o.PTSKnown||!o.live,f=null===(t=r.initSegment)||void 0===t?void 0:t.data,p=this._getAudioCodec(s),g=this.transmuxer=this.transmuxer||new d.default(this.hls,u.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),v=i?i.index:-1,m=-1!==v,y=new h.ChunkMetadata(r.level,r.sn,r.stats.chunkCount,n.byteLength,v,m),A=this.initPTS[r.cc];g.push(n,f,p,l,r,i,o.totalduration,c,y,A)}else this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},T.onAudioTrackSwitching=function(e,t){var r=this.altAudio,i=!!t.url,n=t.id;if(!i){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;null!=a&&a.loader&&(this.log("Switching to main audio track, cancel main fragment load"),a.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var o=this.hls;r&&o.trigger(s.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),o.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:n})}},T.onAudioTrackSwitched=function(e,t){var r=t.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},T.onBufferCreated=function(e,t){var r,i,n=t.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=n[s];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},T.onFragBuffered=function(e,t){var r=t.frag,i=t.part;if(!r||r.type===u.PlaylistLevelType.MAIN){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===n.State.PARSED&&(this.state=n.State.IDLE));var a=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},T.onError=function(e,t){switch(t.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,t);break;case p.ErrorDetails.LEVEL_LOAD_ERROR:case p.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==n.State.ERROR&&(t.fatal?(this.warn(""+t.details),this.state=n.State.ERROR):t.levelRetry||this.state!==n.State.WAITING_LEVEL||(this.state=n.State.IDLE));break;case p.ErrorDetails.BUFFER_FULL_ERROR:if("main"===t.parent&&(this.state===n.State.PARSING||this.state===n.State.PARSED)){var r=!0,i=this.getFwdBufferInfo(this.media,u.PlaylistLevelType.MAIN);i&&i.len>.5&&(r=!this.reduceMaxBufferLength(i.len)),r&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},T.checkBuffer=function(){var e=this.media,t=this.gapController;if(e&&t&&e.readyState){if(this.loadedmetadata||!o.BufferHelper.getBuffered(e).length){var r=this.state!==n.State.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}},T.onFragLoadEmergencyAborted=function(){this.state=n.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},T.onBufferFlushed=function(e,t){var r=t.type;if(r!==c.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var i=(r===c.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,u.PlaylistLevelType.MAIN)}},T.onLevelsUpdated=function(e,t){this.levels=t.levels},T.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},T.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t<r){if(e.seeking)return void this.log("could not seek to "+r+", already seeking at "+t);var i=o.BufferHelper.getBuffered(e),n=(i.length?i.start(0):0)-r;n>0&&(n<this.config.maxBufferHole||n<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+n+" to match buffer start"),r+=n,this.startPosition=r),this.log("seek to target start position "+r+" from current time "+t),e.currentTime=r}}},T._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t},T._loadBitrateTestFrag=function(e){var t=this;e.bitrateTest=!0,this._doFragLoad(e).then((function(r){var i=t.hls;if(r&&!i.nextLoadLevel&&!t.fragContextChanged(e)){t.fragLoadError=0,t.state=n.State.IDLE,t.startFragRequested=!1,t.bitrateTest=!1;var a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(s.Events.FRAG_LOADED,r),e.bitrateTest=!1}}))},T._handleTransmuxComplete=function(e){var t,r="main",a=this.hls,o=e.remuxResult,l=e.chunkMeta,u=this.getCurrentContext(l);if(!u)return this.warn("The loading context changed while buffering fragment "+l.sn+" of level "+l.level+". This chunk will not be buffered."),void this.resetStartWhenNotLoaded(l.level);var d=u.frag,h=u.part,f=u.level,p=o.video,g=o.text,v=o.id3,m=o.initSegment,y=f.details,A=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(d)){if(this.state=n.State.PARSING,m){m.tracks&&(this._bufferInitSegment(f,m.tracks,d,l),a.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:d,id:r,tracks:m.tracks}));var E=m.initPTS,T=m.timescale;(0,i.isFiniteNumber)(E)&&(this.initPTS[d.cc]=E,a.trigger(s.Events.INIT_PTS_FOUND,{frag:d,id:r,initPTS:E,timescale:T}))}if(p&&!1!==o.independent){if(y){var b=p.startPTS,k=p.endPTS,S=p.startDTS,_=p.endDTS;if(h)h.elementaryStreams[p.type]={startPTS:b,endPTS:k,startDTS:S,endDTS:_};else if(p.firstKeyFrame&&p.independent&&(this.couldBacktrack=!0),p.dropped&&p.independent){var C=this.getMainFwdBufferInfo();if((C?C.end:this.getLoadPosition())+this.config.maxBufferHole<(p.firstKeyFramePTS?p.firstKeyFramePTS:b)-this.config.maxBufferHole)return void this.backtrack(d);d.setElementaryStreamInfo(p.type,d.start,k,d.start,_,!0)}d.setElementaryStreamInfo(p.type,b,k,S,_),this.backtrackFragment&&(this.backtrackFragment=d),this.bufferFragmentData(p,d,h,l)}}else if(!1===o.independent)return void this.backtrack(d);if(A){var L=A.startPTS,D=A.endPTS,R=A.startDTS,I=A.endDTS;h&&(h.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:L,endPTS:D,startDTS:R,endDTS:I}),d.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,L,D,R,I),this.bufferFragmentData(A,d,h,l)}if(y&&null!=v&&null!==(t=v.samples)&&void 0!==t&&t.length){var O={id:r,frag:d,details:y,samples:v.samples};a.trigger(s.Events.FRAG_PARSING_METADATA,O)}if(y&&g){var w={id:r,frag:d,details:y,samples:g.samples};a.trigger(s.Events.FRAG_PARSING_USERDATA,w)}}},T._bufferInitSegment=function(e,t,r,i){var a=this;if(this.state===n.State.PARSING){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;var o=t.audio,l=t.video,u=t.audiovideo;if(o){var c=e.audioCodec,d=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(c&&(c=-1!==c.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==o.metadata.channelCount&&-1===d.indexOf("firefox")&&(c="mp4a.40.5")),-1!==d.indexOf("android")&&"audio/mpeg"!==o.container&&(c="mp4a.40.2",this.log("Android: force audio codec to "+c)),e.audioCodec&&e.audioCodec!==c&&this.log('Swapping manifest audio codec "'+e.audioCodec+'" for "'+c+'"'),o.levelCodec=c,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(c||"")+"/"+(e.audioCodec||"")+"/"+o.codec+"]")}l&&(l.levelCodec=e.videoCodec,l.id="main",this.log("Init video buffer, container:"+l.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+l.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(e.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t),Object.keys(t).forEach((function(e){var n=t[e].initSegment;null!=n&&n.byteLength&&a.hls.trigger(s.Events.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tick()}},T.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u.PlaylistLevelType.MAIN)},T.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=n.State.IDLE},T.checkFragmentChanged=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(o.BufferHelper.isBuffered(e,r)?t=this.getAppendedFrag(r):o.BufferHelper.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;var i=this.fragPlaying,n=t.level;i&&t.sn===i.sn&&i.level===n&&t.urlId===i.urlId||(this.hls.trigger(s.Events.FRAG_CHANGED,{frag:t}),i&&i.level===n||this.hls.trigger(s.Events.LEVEL_SWITCHED,{level:n}),this.fragPlaying=t)}}},y=m,(A=[{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}},{key:"currentProgramDateTime",get:function(){var e=this.media;if(e){var t=e.currentTime,r=this.currentFrag;if(r&&(0,i.isFiniteNumber)(t)&&(0,i.isFiniteNumber)(r.programDateTime)){var n=r.programDateTime+1e3*(t-r.start);return new Date(n)}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&g(y.prototype,A),E&&g(y,E),Object.defineProperty(y,"prototype",{writable:!1}),m}(n.default)},"./src/controller/subtitle-stream-controller.ts": /*!******************************************************!*\ !*** ./src/controller/subtitle-stream-controller.ts ***! \******************************************************/(e,t,r)=>{r.r(t),r.d(t,{SubtitleStreamController:()=>p});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=r(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),s=r(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),o=r(/*! ./level-helper */"./src/controller/level-helper.ts"),l=r(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=r(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),c=r(/*! ../types/loader */"./src/types/loader.ts"),d=r(/*! ../types/level */"./src/types/level.ts");function h(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function f(e,t){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},f(e,t)}var p=function(e){var t,r;function p(t,r){var i;return(i=e.call(this,t,r,"[subtitle-stream-controller]")||this).levels=[],i.currentTrackId=-1,i.tracksBuffered=[],i.mainDetails=null,i._registerListeners(),i}r=e,(t=p).prototype=Object.create(r.prototype),t.prototype.constructor=t,f(t,r);var v,m,y,A=p.prototype;return A.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},A._registerListeners=function(){var e=this.hls;e.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.on(i.Events.ERROR,this.onError,this),e.on(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(i.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(i.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(i.Events.FRAG_BUFFERED,this.onFragBuffered,this)},A._unregisterListeners=function(){var e=this.hls;e.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(i.Events.LEVEL_LOADED,this.onLevelLoaded,this),e.off(i.Events.ERROR,this.onError,this),e.off(i.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(i.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(i.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(i.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(i.Events.FRAG_BUFFERED,this.onFragBuffered,this)},A.startLoad=function(e){this.stopLoad(),this.state=u.State.IDLE,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()},A.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},A.onLevelLoaded=function(e,t){this.mainDetails=t.details},A.onSubtitleFragProcessed=function(e,t){var r=t.frag,i=t.success;if(this.fragPrevious=r,this.state=u.State.IDLE,i){var n=this.tracksBuffered[this.currentTrackId];if(n){for(var a,s=r.start,o=0;o<n.length;o++)if(s>=n[o].start&&s<=n[o].end){a=n[o];break}var l=r.start+r.duration;a?a.end=l:(a={start:s,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r)}}},A.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n=this.currentTrackId,a=this.levels;if(!a.length||!a[n]||!a[n].details)return;var s=i-a[n].details.targetduration;if(s<=0)return;t.endOffsetSubtitles=Math.max(0,s),this.tracksBuffered.forEach((function(e){for(var t=0;t<e.length;)if(e[t].end<=s)e.shift();else{if(!(e[t].start<s))break;e[t].start=s,t++}})),this.fragmentTracker.removeFragmentsInRange(r,s,c.PlaylistLevelType.SUBTITLE)}},A.onFragBuffered=function(e,t){var r;this.loadedmetadata||t.frag.type!==c.PlaylistLevelType.MAIN||null!==(r=this.media)&&void 0!==r&&r.buffered.length&&(this.loadedmetadata=!0)},A.onError=function(e,t){var r,i=t.frag;i&&i.type===c.PlaylistLevelType.SUBTITLE&&(null!==(r=this.fragCurrent)&&void 0!==r&&r.loader&&this.fragCurrent.loader.abort(),this.state=u.State.IDLE)},A.onSubtitleTracksUpdated=function(e,t){var r=this,i=t.subtitleTracks;this.tracksBuffered=[],this.levels=i.map((function(e){return new d.Level(e)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(e){r.tracksBuffered[e.id]=[]})),this.mediaBuffer=null},A.onSubtitleTrackSwitch=function(e,t){if(this.currentTrackId=t.id,this.levels.length&&-1!==this.currentTrackId){var r=this.levels[this.currentTrackId];null!=r&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(500)}else this.clearInterval()},A.onSubtitleTrackLoaded=function(e,t){var r,i=t.details,n=t.id,l=this.currentTrackId,c=this.levels;if(c.length){var d=c[l];if(!(n>=c.length||n!==l)&&d){this.mediaBuffer=this.mediaBufferTimeRanges;var h=0;if(i.live||null!==(r=d.details)&&void 0!==r&&r.live){var f=this.mainDetails;if(i.deltaUpdateFailed||!f)return;var p=f.fragments[0];d.details?0===(h=this.alignPlaylists(i,d.details))&&p&&(h=p.start,(0,o.addSliding)(i,h)):i.hasProgramDateTime&&f.hasProgramDateTime?((0,s.alignMediaPlaylistByPDT)(i,f),h=i.fragments[0].start):p&&(h=p.start,(0,o.addSliding)(i,h))}d.details=i,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(d.details,h),this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===u.State.IDLE&&((0,a.findFragmentByPTS)(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),d.details=void 0))}}},A._handleFragmentLoadComplete=function(e){var t=e.frag,r=e.payload,n=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&n&&n.key&&n.iv&&"AES-128"===n.method){var s=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),n.key.buffer,n.iv.buffer).then((function(e){var r=performance.now();a.trigger(i.Events.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:s,tdecrypt:r}})}))}},A.doTick=function(){if(this.media){if(this.state===u.State.IDLE){var e=this.currentTrackId,t=this.levels;if(!t.length||!t[e]||!t[e].details)return;var r=t[e].details,i=r.targetduration,s=this.config,o=this.getLoadPosition(),d=n.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o-i,s.maxBufferHole),h=d.end,f=d.len,p=this.getFwdBufferInfo(this.media,c.PlaylistLevelType.MAIN);if(f>this.getMaxBufferLength(null==p?void 0:p.len)+i)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var g,v=r.fragments,m=v.length,y=r.edge,A=this.fragPrevious;if(h<y){var E=s.maxFragLookUpTolerance;!(g=(0,a.findFragmentByPTS)(A,v,Math.max(v[0].start,h),E))&&A&&A.start<v[0].start&&(g=v[0])}else g=v[m-1];if(!(g=this.mapToInitFragWhenRequired(g)))return;if(this.fragmentTracker.getState(g)!==l.FragmentState.NOT_LOADED)return;g.encrypted?this.loadKey(g,r):this.loadFragment(g,r,h)}}else this.state=u.State.IDLE},A.getMaxBufferLength=function(t){var r=e.prototype.getMaxBufferLength.call(this);return t?Math.max(r,t):r},A.loadFragment=function(t,r,i){this.fragCurrent=t,"initSegment"===t.sn?this._loadInitSegment(t):(this.startFragRequested=!0,e.prototype.loadFragment.call(this,t,r,i))},v=p,(m=[{key:"mediaBufferTimeRanges",get:function(){return new g(this.tracksBuffered[this.currentTrackId]||[])}}])&&h(v.prototype,m),y&&h(v,y),Object.defineProperty(v,"prototype",{writable:!1}),p}(u.default),g=function(e){this.buffered=void 0;var t=function(t,r,i){if((r>>>=0)>i-1)throw new DOMException("Failed to execute '"+t+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+i+")");return e[r][t]};this.buffered={get length(){return e.length},end:function(r){return t("end",r,e.length)},start:function(r){return t("start",r,e.length)}}}},"./src/controller/subtitle-track-controller.ts": /*!*****************************************************!*\ !*** ./src/controller/subtitle-track-controller.ts ***! \*****************************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),a=r(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),s=r(/*! ../types/loader */"./src/types/loader.ts");function o(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}var u=function(e){var t,r;function a(t){var r;return(r=e.call(this,t,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.registerListeners(),r}r=e,(t=a).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r);var u,d,h,f=a.prototype;return f.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,e.prototype.destroy.call(this)},f.registerListeners=function(){var e=this.hls;e.on(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(i.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var e=this.hls;e.off(i.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(i.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(i.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(i.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(i.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(i.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(i.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(i.Events.ERROR,this.onError,this)},f.onMediaAttached=function(e,t){this.media=t.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))},f.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},f.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),c(this.media.textTracks).forEach((function(e){(0,n.clearCurrentCues)(e)})),this.subtitleTrack=-1,this.media=null)},f.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},f.onManifestParsed=function(e,t){this.tracks=t.subtitleTracks},f.onSubtitleTrackLoaded=function(e,t){var r=t.id,i=t.details,n=this.trackId,a=this.tracksInGroup[n];if(a){var s=a.details;a.details=t.details,this.log("subtitle track "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&(this.retryCount=0,this.playlistLoaded(r,t,s))}else this.warn("Invalid subtitle track id "+r)},f.onLevelLoading=function(e,t){this.switchLevel(t.level)},f.onLevelSwitching=function(e,t){this.switchLevel(t.level)},f.switchLevel=function(e){var t=this.hls.levels[e];if(null!=t&&t.textGroupIds){var r=t.textGroupIds[t.urlId];if(this.groupId!==r){var n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,a=this.tracks.filter((function(e){return!r||e.groupId===r}));this.tracksInGroup=a;var s=this.findTrackId(null==n?void 0:n.name)||this.findTrackId();this.groupId=r;var o={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(i.Events.SUBTITLE_TRACKS_UPDATED,o),-1!==s&&this.setSubtitleTrack(s,n)}}},f.findTrackId=function(e){for(var t=this.tracksInGroup,r=0;r<t.length;r++){var i=t[r];if((!this.selectDefaultTrack||i.default)&&(!e||e===i.name))return i.id}return-1},f.onError=function(t,r){e.prototype.onError.call(this,t,r),!r.fatal&&r.context&&r.context.type===s.PlaylistContextType.SUBTITLE_TRACK&&r.context.id===this.trackId&&r.context.groupId===this.groupId&&this.retryLoadingOrFail(r)},f.loadPlaylist=function(e){var t=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(t)){var r=t.id,n=t.groupId,a=t.url;if(e)try{a=e.addDirectives(a)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}this.log("Loading subtitle playlist for id "+r),this.hls.trigger(i.Events.SUBTITLE_TRACK_LOADING,{url:a,id:r,groupId:n,deliveryDirectives:e||null})}},f.toggleTrackModes=function(e){var t=this,r=this.media,i=this.trackId;if(r){var n=c(r.textTracks),a=n.filter((function(e){return e.groupId===t.groupId}));if(-1===e)[].slice.call(n).forEach((function(e){e.mode="disabled"}));else{var s=a[i];s&&(s.mode="disabled")}var o=a[e];o&&(o.mode=this.subtitleDisplay?"showing":"hidden")}},f.setSubtitleTrack=function(e,t){var r,n=this.tracksInGroup;if(this.media){if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(-1===e||null!==(r=n[e])&&void 0!==r&&r.details)||e<-1||e>=n.length)){this.clearTimer();var a=n[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,a){var s=a.id,o=a.groupId,l=void 0===o?"":o,u=a.name,c=a.type,d=a.url;this.hls.trigger(i.Events.SUBTITLE_TRACK_SWITCH,{id:s,groupId:l,name:u,type:c,url:d});var h=this.switchParams(a.url,null==t?void 0:t.details);this.loadPlaylist(h)}else this.hls.trigger(i.Events.SUBTITLE_TRACK_SWITCH,{id:e})}}else this.queuedDefaultTrack=e},f.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var e=-1,t=c(this.media.textTracks),r=0;r<t.length;r++)if("hidden"===t[r].mode)e=r;else if("showing"===t[r].mode){e=r;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},u=a,(d=[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}}])&&o(u.prototype,d),h&&o(u,h),Object.defineProperty(u,"prototype",{writable:!1}),a}(a.default);function c(e){for(var t=[],r=0;r<e.length;r++){var i=e[r];"subtitles"===i.kind&&i.label&&t.push(e[r])}return t}const d=u},"./src/controller/timeline-controller.ts": /*!***********************************************!*\ !*** ./src/controller/timeline-controller.ts ***! \***********************************************/(e,t,r)=>{r.r(t),r.d(t,{TimelineController:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),s=r(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),o=r(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),l=r(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),u=r(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),c=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),d=r(/*! ../types/loader */"./src/types/loader.ts"),h=r(/*! ../utils/logger */"./src/utils/logger.ts"),f=function(){function e(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var t=new s.default(this,"textTrack1"),r=new s.default(this,"textTrack2"),i=new s.default(this,"textTrack3"),o=new s.default(this,"textTrack4");this.cea608Parser1=new a.default(1,t,r),this.cea608Parser2=new a.default(3,i,o)}e.on(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(n.Events.FRAG_LOADING,this.onFragLoading,this),e.on(n.Events.FRAG_LOADED,this.onFragLoaded,this),e.on(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var t=e.prototype;return t.destroy=function(){var e=this.hls;e.off(n.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(n.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(n.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(n.Events.FRAG_LOADING,this.onFragLoading,this),e.off(n.Events.FRAG_LOADED,this.onFragLoaded,this),e.off(n.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(n.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(n.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(n.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(n.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},t.addCues=function(e,t,r,i,a){for(var s,o,l,u,c=!1,d=a.length;d--;){var h=a[d],f=(s=h[0],o=h[1],l=t,u=r,Math.min(o,u)-Math.max(s,l));if(f>=0&&(h[0]=Math.min(h[0],t),h[1]=Math.max(h[1],r),c=!0,f/(r-t)>.5))return}if(c||a.push([t,r]),this.config.renderTextTracksNatively){var p=this.captionsTracks[e];this.Cues.newCue(p,t,r,i)}else{var g=this.Cues.newCue(null,t,r,i);this.hls.trigger(n.Events.CUES_PARSED,{type:"captions",cues:g,track:e})}},t.onInitPtsFound=function(e,t){var r=this,i=t.frag,a=t.id,s=t.initPTS,o=t.timescale,l=this.unparsedVttFrags;"main"===a&&(this.initPTS[i.cc]=s,this.timescale[i.cc]=o),l.length&&(this.unparsedVttFrags=[],l.forEach((function(e){r.onFragLoaded(n.Events.FRAG_LOADED,e)})))},t.getExistingTrack=function(e){var t=this.media;if(t)for(var r=0;r<t.textTracks.length;r++){var i=t.textTracks[r];if(i[e])return i}return null},t.createCaptionsTrack=function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)},t.createNativeTrack=function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,r=this.captionsTracks,i=this.media,n=t[e],a=n.label,s=n.languageCode,o=this.getExistingTrack(e);if(o)r[e]=o,(0,l.clearCurrentCues)(r[e]),(0,l.sendAddTrackEvent)(r[e],i);else{var u=this.createTextTrack("captions",a,s);u&&(u[e]=!0,r[e]=u)}}},t.createNonNativeTrack=function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var r={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}}},t.createTextTrack=function(e,t,r){var i=this.media;if(i)return i.addTextTrack(e,t,r)},t.onMediaAttaching=function(e,t){this.media=t.media,this._cleanTracks()},t.onMediaDetaching=function(){var e=this.captionsTracks;Object.keys(e).forEach((function(t){(0,l.clearCurrentCues)(e[t]),delete e[t]})),this.nonNativeCaptionsTracks={}},t.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},t._cleanTracks=function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var r=0;r<t.length;r++)(0,l.clearCurrentCues)(t[r])}},t.onSubtitleTracksUpdated=function(e,t){var r=this;this.textTracks=[];var i=t.subtitleTracks||[],a=i.some((function(e){return e.textCodec===u.IMSC1_CODEC}));if(this.config.enableWebVTT||a&&this.config.enableIMSC1){var s=this.tracks&&i&&this.tracks.length===i.length;if(this.tracks=i||[],this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach((function(e,t){var i;if(t<o.length){for(var n=null,a=0;a<o.length;a++)if(p(o[a],e)){n=o[a];break}n&&(i=n)}if(i)(0,l.clearCurrentCues)(i);else{var s=r._captionsOrSubtitlesFromCharacteristics(e);(i=r.createTextTrack(s,e.name,e.lang))&&(i.mode="disabled")}i&&(i.groupId=e.groupId,r.textTracks.push(i))}))}else if(!s&&this.tracks&&this.tracks.length){var c=this.tracks.map((function(e){return{label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}}));this.hls.trigger(n.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},t._captionsOrSubtitlesFromCharacteristics=function(e){var t;if(null!==(t=e.attrs)&&void 0!==t&&t.CHARACTERISTICS){var r=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(r&&i)return"captions"}return"subtitles"},t.onManifestLoaded=function(e,t){var r=this;this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((function(e){var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var i="textTrack"+t[1],n=r.captionsProperties[i];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.media=e)}}))},t.closedCaptionsForLevel=function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]},t.onFragLoading=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2,n=this.lastSn,a=this.lastPartIndex;if(this.enabled&&r&&i&&t.frag.type===d.PlaylistLevelType.MAIN){var s,o,l=t.frag.sn,u=null!=(s=null==t||null===(o=t.part)||void 0===o?void 0:o.index)?s:-1;l===n+1||l===n&&u===a+1||(r.reset(),i.reset()),this.lastSn=l,this.lastPartIndex=u}},t.onFragLoaded=function(e,t){var r=t.frag,a=t.payload,s=this.initPTS,o=this.unparsedVttFrags;if(r.type===d.PlaylistLevelType.SUBTITLE)if(a.byteLength){if(!(0,i.isFiniteNumber)(s[r.cc]))return o.push(t),void(s.length&&this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Missing initial subtitle PTS")}));var l=r.decryptdata,c="stats"in t;if(null==l||null==l.key||"AES-128"!==l.method||c){var h=this.tracks[r.level],f=this.vttCCs;f[r.cc]||(f[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),h&&h.textCodec===u.IMSC1_CODEC?this._parseIMSC1(r,a):this._parseVTTs(r,a,f)}}else this.hls.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})},t._parseIMSC1=function(e,t){var r=this,i=this.hls;(0,u.parseIMSC1)(t,this.initPTS[e.cc],this.timescale[e.cc],(function(t){r._appendCues(t,e.level),i.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(t){h.logger.log("Failed to parse IMSC1: "+t),i.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))},t._parseVTTs=function(e,t,r){var i,a=this,s=this.hls,l=null!==(i=e.initSegment)&&void 0!==i&&i.data?(0,c.appendUint8Array)(e.initSegment.data,new Uint8Array(t)):t;(0,o.parseWebVTT)(l,this.initPTS[e.cc],this.timescale[e.cc],r,e.cc,e.start,(function(t){a._appendCues(t,e.level),s.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(function(r){a._fallbackToIMSC1(e,t),h.logger.log("Failed to parse VTT cue: "+r),s.trigger(n.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})}))},t._fallbackToIMSC1=function(e,t){var r=this,i=this.tracks[e.level];i.textCodec||(0,u.parseIMSC1)(t,this.initPTS[e.cc],this.timescale[e.cc],(function(){i.textCodec=u.IMSC1_CODEC,r._parseIMSC1(e,t)}),(function(){i.textCodec="wvtt"}))},t._appendCues=function(e,t){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[t];if(!i||"disabled"===i.mode)return;e.forEach((function(e){return(0,l.addCueToTrack)(i,e)}))}else{var a=this.tracks[t];if(!a)return;var s=a.default?"default":"subtitles"+t;r.trigger(n.Events.CUES_PARSED,{type:"subtitles",cues:e,track:s})}},t.onFragDecrypted=function(e,t){var r=t.frag;if(r.type===d.PlaylistLevelType.SUBTITLE){if(!(0,i.isFiniteNumber)(this.initPTS[r.cc]))return void this.unparsedVttFrags.push(t);this.onFragLoaded(n.Events.FRAG_LOADED,t)}},t.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},t.onFragParsingUserdata=function(e,t){var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i){var n=t.frag,a=t.samples;if(n.type!==d.PlaylistLevelType.MAIN||"NONE"!==this.closedCaptionsForLevel(n))for(var s=0;s<a.length;s++){var o=a[s].bytes;if(o){var l=this.extractCea608Data(o);r.addData(a[s].pts,l[0]),i.addData(a[s].pts,l[1])}}}},t.onBufferFlushing=function(e,t){var r=t.startOffset,i=t.endOffset,n=t.endOffsetSubtitles,a=t.type,s=this.media;if(s&&!(s.currentTime<i)){if(!a||"video"===a){var o=this.captionsTracks;Object.keys(o).forEach((function(e){return(0,l.removeCuesInRange)(o[e],r,i)}))}if(this.config.renderTextTracksNatively&&0===r&&void 0!==n){var u=this.textTracks;Object.keys(u).forEach((function(e){return(0,l.removeCuesInRange)(u[e],r,n)}))}}},t.extractCea608Data=function(e){for(var t=[[],[]],r=31&e[0],i=2,n=0;n<r;n++){var a=e[i++],s=127&e[i++],o=127&e[i++];if((0!==s||0!==o)&&0!=(4&a)){var l=3&a;0!==l&&1!==l||(t[l].push(s),t[l].push(o))}}return t},e}();function p(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}},"./src/crypt/aes-crypto.ts": /*!*********************************!*\ !*** ./src/crypt/aes-crypto.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}return e.prototype.decrypt=function(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)},e}()},"./src/crypt/aes-decryptor.ts": /*!************************************!*\ !*** ./src/crypt/aes-decryptor.ts ***! \************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>a,removePadding:()=>n});var i=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function n(e){var t=e.byteLength,r=t&&new DataView(e.buffer).getUint8(t-1);return r?(0,i.sliceUint8)(e,0,t-r):e}var a=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],n=r[1],a=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],c=o[2],d=o[3],h=new Uint32Array(256),f=0,p=0,g=0;for(g=0;g<256;g++)h[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){var v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^255&v^99,e[f]=v,t[v]=f;var m=h[f],y=h[m],A=h[y],E=257*h[v]^16843008*v;i[f]=E<<24|E>>>8,n[f]=E<<16|E>>>16,a[f]=E<<8|E>>>24,s[f]=E,E=16843009*A^65537*y^257*m^16843008*f,l[v]=E<<24|E>>>8,u[v]=E<<16|E>>>16,c[v]=E<<8|E>>>24,d[v]=E,f?(f=m^h[h[h[A^m]]],p^=h[h[p]]):f=p=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i<t.length&&r;)r=t[i]===this.key[i],i++;if(!r){this.key=t;var n=this.keySize=t.length;if(4!==n&&6!==n&&8!==n)throw new Error("Invalid aes key size="+n);var a,s,o,l,u=this.ksRows=4*(n+6+1),c=this.keySchedule=new Uint32Array(u),d=this.invKeySchedule=new Uint32Array(u),h=this.sBox,f=this.rcon,p=this.invSubMix,g=p[0],v=p[1],m=p[2],y=p[3];for(a=0;a<u;a++)a<n?o=c[a]=t[a]:(l=o,a%n==0?(l=h[(l=l<<8|l>>>24)>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l],l^=f[a/n|0]<<24):n>6&&a%n==4&&(l=h[l>>>24]<<24|h[l>>>16&255]<<16|h[l>>>8&255]<<8|h[255&l]),c[a]=o=(c[a-n]^l)>>>0);for(s=0;s<u;s++)a=u-s,l=3&s?c[a]:c[a-4],d[s]=s<4||a<=4?l:g[h[l>>>24]]^v[h[l>>>16&255]]^m[h[l>>>8&255]]^y[h[255&l]],d[s]=d[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var i,n,a,s,o,l,u,c,d,h,f,p,g,v,m=this.keySize+6,y=this.invKeySchedule,A=this.invSBox,E=this.invSubMix,T=E[0],b=E[1],k=E[2],S=E[3],_=this.uint8ArrayToUint32Array_(r),C=_[0],L=_[1],D=_[2],R=_[3],I=new Int32Array(e),O=new Int32Array(I.length),w=this.networkToHostOrderSwap;t<I.length;){for(d=w(I[t]),h=w(I[t+1]),f=w(I[t+2]),p=w(I[t+3]),o=d^y[0],l=p^y[1],u=f^y[2],c=h^y[3],g=4,v=1;v<m;v++)i=T[o>>>24]^b[l>>16&255]^k[u>>8&255]^S[255&c]^y[g],n=T[l>>>24]^b[u>>16&255]^k[c>>8&255]^S[255&o]^y[g+1],a=T[u>>>24]^b[c>>16&255]^k[o>>8&255]^S[255&l]^y[g+2],s=T[c>>>24]^b[o>>16&255]^k[l>>8&255]^S[255&u]^y[g+3],o=i,l=n,u=a,c=s,g+=4;i=A[o>>>24]<<24^A[l>>16&255]<<16^A[u>>8&255]<<8^A[255&c]^y[g],n=A[l>>>24]<<24^A[u>>16&255]<<16^A[c>>8&255]<<8^A[255&o]^y[g+1],a=A[u>>>24]<<24^A[c>>16&255]<<16^A[o>>8&255]<<8^A[255&l]^y[g+2],s=A[c>>>24]<<24^A[o>>16&255]<<16^A[l>>8&255]<<8^A[255&u]^y[g+3],O[t]=w(i^C),O[t+1]=w(s^L),O[t+2]=w(a^D),O[t+3]=w(n^R),C=d,L=h,D=f,R=p,t+=4}return O.buffer},e}()},"./src/crypt/decrypter.ts": /*!********************************!*\ !*** ./src/crypt/decrypter.ts ***! \********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),n=r(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),a=r(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function e(e,t,r){var i=(void 0===r?{}:r).removePKCS7Padding,n=void 0===i||i;if(this.logEnabled=!0,this.observer=void 0,this.config=void 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.observer=e,this.config=t,this.removePKCS7Padding=n,n)try{var a=self.crypto;a&&(this.subtle=a.subtle||a.webkitSubtle)}catch(e){}null===this.subtle&&(this.config.enableSoftwareAES=!0)}var t=e.prototype;return t.destroy=function(){this.observer=null},t.isSync=function(){return this.config.enableSoftwareAES},t.flush=function(){var e=this.currentResult;if(e){var t=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(0,a.removePadding)(t):t}this.reset()},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r,i){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(e),t,r);var n=this.flush();n&&i(n.buffer)}else this.webCryptoDecrypt(new Uint8Array(e),t,r).then(i)},t.softwareDecrypt=function(e,t,r){var i=this.currentIV,n=this.currentResult,s=this.remainderData;this.logOnce("JS AES decrypt"),s&&(e=(0,o.appendUint8Array)(s,e),this.remainderData=null);var u=this.getValidChunk(e);if(!u.length)return null;i&&(r=i);var c=this.softwareDecrypter;c||(c=this.softwareDecrypter=new a.default),c.expandKey(t);var d=n;return this.currentResult=c.decrypt(u.buffer,0,r),this.currentIV=(0,l.sliceUint8)(u,-16).buffer,d||null},t.webCryptoDecrypt=function(e,t,r){var a=this,s=this.subtle;return this.key===t&&this.fastAesKey||(this.key=t,this.fastAesKey=new n.default(s,t)),this.fastAesKey.expandKey().then((function(t){return s?new i.default(s,r).decrypt(e.buffer,t):Promise.reject(new Error("web crypto not initialized"))})).catch((function(i){return a.onWebCryptoError(i,e,t,r)}))},t.onWebCryptoError=function(e,t,r,i){return s.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",e),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(t,r,i)},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=(0,l.sliceUint8)(e,0,r),this.remainderData=(0,l.sliceUint8)(e,r)),t},t.logOnce=function(e){this.logEnabled&&(s.logger.log("[decrypter.ts]: "+e),this.logEnabled=!1)},e}()},"./src/crypt/fast-aes-key.ts": /*!***********************************!*\ !*** ./src/crypt/fast-aes-key.ts ***! \***********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}return e.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},e}()},"./src/demux/aacdemuxer.ts": /*!*********************************!*\ !*** ./src/demux/aacdemuxer.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var i=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=r(/*! ./adts */"./src/demux/adts.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts");function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}const l=function(e){var t,r;function i(t,r){var i;return(i=e.call(this)||this).observer=void 0,i.config=void 0,i.observer=t,i.config=r,i}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r);var l=i.prototype;return l.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},i.probe=function(e){if(!e)return!1;for(var t=(s.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(n.probe(e,t))return a.logger.log("ADTS sync word found !"),!0;return!1},l.canParse=function(e,t){return n.canParse(e,t)},l.appendFrame=function(e,t,r){n.initTrackConfig(e,this.observer,t,r,e.manifestCodec);var i=n.appendFrame(e,t,r,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i},i}(i.default)},"./src/demux/adts.ts": /*!***************************!*\ !*** ./src/demux/adts.ts ***! \***************************/(e,t,r)=>{r.r(t),r.d(t,{appendFrame:()=>m,canGetFrameLength:()=>c,canParse:()=>h,getAudioConfig:()=>s,getFrameDuration:()=>g,getFullFrameLength:()=>u,getHeaderLength:()=>l,initTrackConfig:()=>p,isHeader:()=>d,isHeaderPattern:()=>o,parseFrameHeader:()=>v,probe:()=>f});var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../events */"./src/events.ts");function s(e,t,r,s){var o,l,u,c,d=navigator.userAgent.toLowerCase(),h=s,f=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=1+((192&t[r+2])>>>6);var p=(60&t[r+2])>>>2;if(!(p>f.length-1))return u=(1&t[r+2])<<2,u|=(192&t[r+3])>>>6,i.logger.log("manifest codec:"+s+", ADTS type:"+o+", samplingIndex:"+p),/firefox/i.test(d)?p>=6?(o=5,c=new Array(4),l=p-3):(o=2,c=new Array(2),l=p):-1!==d.indexOf("android")?(o=2,c=new Array(2),l=p):(o=5,c=new Array(4),s&&(-1!==s.indexOf("mp4a.40.29")||-1!==s.indexOf("mp4a.40.5"))||!s&&p>=6?l=p-3:((s&&-1!==s.indexOf("mp4a.40.2")&&(p>=6&&1===u||/vivaldi/i.test(d))||!s&&1===u)&&(o=2,c=new Array(2)),l=p)),c[0]=o<<3,c[0]|=(14&p)>>1,c[1]|=(1&p)<<7,c[1]|=u<<3,5===o&&(c[1]|=(14&l)>>1,c[2]=(1&l)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:f[p],channelCount:u,codec:"mp4a.40."+o,manifestCodec:h};e.trigger(a.Events.ERROR,{type:n.ErrorTypes.MEDIA_ERROR,details:n.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+p})}function o(e,t){return 255===e[t]&&240==(246&e[t+1])}function l(e,t){return 1&e[t+1]?7:9}function u(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function c(e,t){return t+5<e.length}function d(e,t){return t+1<e.length&&o(e,t)}function h(e,t){return c(e,t)&&o(e,t)&&u(e,t)<=e.length-t}function f(e,t){if(d(e,t)){var r=l(e,t);if(t+r>=e.length)return!1;var i=u(e,t);if(i<=r)return!1;var n=t+i;return n===e.length||d(e,n)}return!1}function p(e,t,r,n,a){if(!e.samplerate){var o=s(t,r,n,a);if(!o)return;e.config=o.config,e.samplerate=o.samplerate,e.channelCount=o.channelCount,e.codec=o.codec,e.manifestCodec=o.manifestCodec,i.logger.log("parsed codec:"+e.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function g(e){return 9216e4/e}function v(e,t){var r=l(e,t);if(t+r<=e.length){var i=u(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}function m(e,t,r,i,n){var a,s=i+n*g(e.samplerate),o=v(t,r);if(o){var l=o.frameLength,u=o.headerLength,c=u+l,d=Math.max(0,r+c-t.length);d?(a=new Uint8Array(c-u)).set(t.subarray(r+u,t.length),0):a=t.subarray(r+u,r+c);var h={unit:a,pts:s};return d||e.samples.push(h),{sample:h,length:c,missing:d}}var f=t.length-r;return(a=new Uint8Array(f)).set(t.subarray(r,t.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}},"./src/demux/base-audio-demuxer.ts": /*!*****************************************!*\ !*** ./src/demux/base-audio-demuxer.ts ***! \*****************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>d,initPTSFn:()=>c});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ../types/demuxer */"./src/types/demuxer.ts"),s=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=(0,o.appendUint8Array)(this.cachedData,e),this.cachedData=null);var r,u=n.getID3Data(e,0),d=u?u.length:0,h=this._audioTrack,f=this._id3Track,p=u?n.getTimeStamp(u):void 0,g=e.length;for((null===this.basePTS||0===this.frameIndex&&(0,i.isFiniteNumber)(p))&&(this.basePTS=c(p,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),u&&u.length>0&&f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:a.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});d<g;){if(this.canParse(e,d)){var v=this.appendFrame(h,e,d);v?(this.frameIndex++,this.lastPTS=v.sample.pts,r=d+=v.length):d=g}else n.canParse(e,d)?(u=n.getID3Data(e,d),f.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:u,type:a.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY}),r=d+=u.length):d++;if(d===g&&r!==g){var m=(0,l.sliceUint8)(e,r);this.cachedData?this.cachedData=(0,o.appendUint8Array)(this.cachedData,m):this.cachedData=m}}return{audioTrack:h,videoTrack:(0,s.dummyTrack)(),id3Track:f,textTrack:(0,s.dummyTrack)()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:(0,s.dummyTrack)(),id3Track:this._id3Track,textTrack:(0,s.dummyTrack)()}},t.destroy=function(){},e}(),c=function(e,t,r){return(0,i.isFiniteNumber)(e)?90*e:9e4*t+(r||0)};const d=u},"./src/demux/chunk-cache.ts": /*!**********************************!*\ !*** ./src/demux/chunk-cache.ts ***! \**********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,n=0;n<e.length;n++){var a=e[n];r.set(a,i),i+=a.length}return r}(t,r),this.reset(),e):new Uint8Array(0)},t.reset=function(){this.chunks.length=0,this.dataLength=0},e}()},"./src/demux/dummy-demuxed-track.ts": /*!******************************************!*\ !*** ./src/demux/dummy-demuxed-track.ts ***! \******************************************/(e,t,r)=>{function i(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}r.r(t),r.d(t,{dummyTrack:()=>i})},"./src/demux/exp-golomb.ts": /*!*********************************!*\ !*** ./src/demux/exp-golomb.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var i=r(/*! ../utils/logger */"./src/utils/logger.ts");const n=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),n=Math.min(4,t);if(0===n)throw new Error("no bytes available");i.set(e.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},t.skipBits=function(e){var t;this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)>>3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;return e>32&&i.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0?this.word<<=t:this.bytesAvailable>0&&this.loadWord(),(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},t.skipScalingList=function(e){for(var t=8,r=8,i=0;i<e;i++)0!==r&&(r=(t+this.readEG()+256)%256),t=0===r?t:r},t.readSPS=function(){var e,t,r,i=0,n=0,a=0,s=0,o=this.readUByte.bind(this),l=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),d=this.skipBits.bind(this),h=this.skipEG.bind(this),f=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);o();var g=o();if(l(5),d(3),o(),f(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var v=u();if(3===v&&d(1),f(),f(),d(1),c())for(t=3!==v?8:12,r=0;r<t;r++)c()&&p(r<6?16:64)}f();var m=u();if(0===m)u();else if(1===m)for(d(1),h(),h(),e=u(),r=0;r<e;r++)h();f(),d(1);var y=u(),A=u(),E=l(1);0===E&&d(1),d(1),c()&&(i=u(),n=u(),a=u(),s=u());var T=[1,1];if(c()&&c())switch(o()){case 1:T=[1,1];break;case 2:T=[12,11];break;case 3:T=[10,11];break;case 4:T=[16,11];break;case 5:T=[40,33];break;case 6:T=[24,11];break;case 7:T=[20,11];break;case 8:T=[32,11];break;case 9:T=[80,33];break;case 10:T=[18,11];break;case 11:T=[15,11];break;case 12:T=[64,33];break;case 13:T=[160,99];break;case 14:T=[4,3];break;case 15:T=[3,2];break;case 16:T=[2,1];break;case 255:T=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(y+1)-2*i-2*n),height:(2-E)*(A+1)*16-(E?2:4)*(a+s),pixelRatio:T}},t.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},e}()},"./src/demux/id3.ts": /*!**************************!*\ !*** ./src/demux/id3.ts ***! \**************************/(e,t,r)=>{r.r(t),r.d(t,{canParse:()=>l,decodeFrame:()=>f,getID3Data:()=>s,getID3Frames:()=>h,getTimeStamp:()=>u,isFooter:()=>a,isHeader:()=>n,isTimeStampFrame:()=>c,testables:()=>A,utf8ArrayToStr:()=>y});var i,n=function(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},a=function(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128},s=function(e,t){for(var r=t,i=0;n(e,t);)i+=10,i+=o(e,t+6),a(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},o=function(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]},l=function(e,t){return n(e,t)&&o(e,t+6)+10<=e.length-t},u=function(e){for(var t=h(e),r=0;r<t.length;r++){var i=t[r];if(c(i))return m(i)}},c=function(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info},d=function(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=o(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},h=function(e){for(var t=0,r=[];n(e,t);){for(var i=o(e,t+6),s=(t+=10)+i;t+8<s;){var l=d(e.subarray(t)),u=f(l);u&&r.push(u),t+=l.size+10}a(e,t)&&(t+=10)}return r},f=function(e){return"PRIV"===e.type?p(e):"W"===e.type[0]?v(e):g(e)},p=function(e){if(!(e.size<2)){var t=y(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}},g=function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=y(e.data.subarray(t),!0);t+=r.length+1;var i=y(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=y(e.data.subarray(1));return{key:e.type,data:n}}},v=function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=y(e.data.subarray(t),!0);t+=r.length+1;var i=y(e.data.subarray(t));return{key:e.type,info:r,data:i}}var n=y(e.data);return{key:e.type,data:n}},m=function(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},y=function(e,t){void 0===t&&(t=!1);var r=E();if(r){var i=r.decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,s,o,l=e.length,u="",c=0;c<l;){if(0===(a=e[c++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:s=e[c++],u+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=e[c++],o=e[c++],u+=String.fromCharCode((15&a)<<12|(63&s)<<6|(63&o)<<0)}}return u},A={decodeTextFrame:g};function E(){return i||void 0===self.TextDecoder||(i=new self.TextDecoder("utf-8")),i}},"./src/demux/mp3demuxer.ts": /*!*********************************!*\ !*** ./src/demux/mp3demuxer.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),n=r(/*! ../demux/id3 */"./src/demux/id3.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}var l=function(e){var t,r;function i(){return e.apply(this,arguments)||this}r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,o(t,r);var l=i.prototype;return l.resetInitSegment=function(t,r,i,n){e.prototype.resetInitSegment.call(this,t,r,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},i.probe=function(e){if(!e)return!1;for(var t=(n.getID3Data(e,0)||[]).length,r=e.length;t<r;t++)if(s.probe(e,t))return a.logger.log("MPEG Audio sync word found !"),!0;return!1},l.canParse=function(e,t){return s.canParse(e,t)},l.appendFrame=function(e,t,r){if(null!==this.basePTS)return s.appendFrame(e,t,r,this.basePTS,this.frameIndex)},i}(i.default);const u=l},"./src/demux/mp4demuxer.ts": /*!*********************************!*\ !*** ./src/demux/mp4demuxer.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../types/demuxer */"./src/types/demuxer.ts"),a=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),s=r(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),o=/\/emsg[-/]ID3/i;const l=function(){function e(e,t){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=t}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,r,i){var n=(0,a.parseInitSegment)(e),o=this.videoTrack=(0,s.dummyTrack)("video",1),l=this.audioTrack=(0,s.dummyTrack)("audio",1),u=this.txtTrack=(0,s.dummyTrack)("text",1);if(this.id3Track=(0,s.dummyTrack)("id3",1),this.timeOffset=0,n.video){var c=n.video,d=c.id,h=c.timescale,f=c.codec;o.id=d,o.timescale=u.timescale=h,o.codec=f}if(n.audio){var p=n.audio,g=p.id,v=p.timescale,m=p.codec;l.id=g,l.timescale=v,l.codec=m}u.id=a.RemuxerTrackIdConfig.text,o.sampleDuration=0,o.duration=l.duration=i},t.resetContiguity=function(){},e.probe=function(e){return e=e.length>16384?e.subarray(0,16384):e,(0,a.findBox)(e,["moof"]).length>0},t.demux=function(e,t){this.timeOffset=t;var r=e,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=(0,a.appendUint8Array)(this.remainderData,e));var s=(0,a.segmentValidRange)(r);this.remainderData=s.remainder,i.samples=s.valid||new Uint8Array}else i.samples=r;var o=this.extractID3Track(i,t);return n.samples=(0,a.parseSamples)(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(t,this.timeOffset);return r.samples=(0,a.parseSamples)(e,t),{videoTrack:t,audioTrack:(0,s.dummyTrack)(),id3Track:i,textTrack:(0,s.dummyTrack)()}},t.extractID3Track=function(e,t){var r=this.id3Track;if(e.samples.length){var s=(0,a.findBox)(e.samples,["emsg"]);s&&s.forEach((function(e){var s=(0,a.parseEmsg)(e);if(o.test(s.schemeIdUri)){var l=(0,i.isFiniteNumber)(s.presentationTime)?s.presentationTime/s.timeScale:t+s.presentationTimeDelta/s.timeScale,u=4294967295===s.eventDuration?Number.POSITIVE_INFINITY:s.eventDuration/s.timeScale;u<=.001&&(u=Number.POSITIVE_INFINITY);var c=s.payload;r.samples.push({data:c,len:c.byteLength,dts:l,pts:l,type:n.MetadataSchema.emsg,duration:u})}}))}return r},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){},e}()},"./src/demux/mpegaudio.ts": /*!********************************!*\ !*** ./src/demux/mpegaudio.ts ***! \********************************/(e,t,r)=>{r.r(t),r.d(t,{appendFrame:()=>l,canParse:()=>h,isHeader:()=>d,isHeaderPattern:()=>c,parseHeader:()=>u,probe:()=>f});var i=null,n=[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],a=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],s=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function l(e,t,r,i,n){if(!(r+24>t.length)){var a=u(t,r);if(a&&r+a.frameLength<=t.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:t.subarray(r,r+a.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function u(e,t){var r=e[t+1]>>3&3,l=e[t+1]>>1&3,u=e[t+2]>>4&15,c=e[t+2]>>2&3;if(1!==r&&0!==u&&15!==u&&3!==c){var d=e[t+2]>>1&1,h=e[t+3]>>6,f=1e3*n[14*(3===r?3-l:3===l?3:4)+u-1],p=a[3*(3===r?0:2===r?1:2)+c],g=3===h?1:2,v=s[r][l],m=o[l],y=8*v*m,A=Math.floor(v*f/p+d)*m;if(null===i){var E=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);i=E?parseInt(E[1]):0}return!!i&&i<=87&&2===l&&f>=224e3&&0===h&&(e[t+3]=128|e[t+3]),{sampleRate:p,channelCount:g,frameLength:A,samplesPerFrame:y}}}function c(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function d(e,t){return t+1<e.length&&c(e,t)}function h(e,t){return c(e,t)&&4<=e.length-t}function f(e,t){if(t+1<e.length&&c(e,t)){var r=u(e,t),i=4;null!=r&&r.frameLength&&(i=r.frameLength);var n=t+i;return n===e.length||d(e,n)}return!1}},"./src/demux/sample-aes.ts": /*!*********************************!*\ !*** ./src/demux/sample-aes.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var i=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),n=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts");const a=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new i.default(e,t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e,t){this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,t)},t.decryptAacSample=function(e,t,r,i){var n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length),o=this;this.decryptBuffer(s,(function(a){var s=new Uint8Array(a);n.set(s,16),i||o.decryptAacSamples(e,t+1,r)}))}},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,r,i),!i)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)r.set(e.subarray(n,n+16),i);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),i=0,n=32;n<e.length-16;n+=160,i+=16)e.set(r.subarray(i,i+16),n);return e},t.decryptAvcSample=function(e,t,r,i,a,s){var o=(0,n.discardEPB)(a.data),l=this.getAvcEncryptedData(o),u=this;this.decryptBuffer(l.buffer,(function(n){a.data=u.getAvcDecryptedUnit(o,n),s||u.decryptAvcSamples(e,t,r+1,i)}))},t.decryptAvcSamples=function(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();for(var n=e[t].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type)){var s=this.decrypter.isSync();if(this.decryptAvcSample(e,t,r,i,a,s),!s)return}}}},e}()},"./src/demux/transmuxer-interface.ts": /*!*******************************************!*\ !*** ./src/demux/transmuxer-interface.ts ***! \*******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var i=r(/*! ./webworkify-webpack */"./src/demux/webworkify-webpack.js"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),c=(0,l.getMediaSource)()||{isTypeSupported:function(){return!1}},d=function(){function e(e,t,r,l){var d=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;var h=e.config;this.hls=e,this.id=t,this.useWorker=!!h.enableWorker,this.onTransmuxComplete=r,this.onFlush=l;var f=function(e,t){(t=t||{}).frag=d.frag,t.id=d.id,d.hls.trigger(e,t)};this.observer=new u.EventEmitter,this.observer.on(n.Events.FRAG_DECRYPTED,f),this.observer.on(n.Events.ERROR,f);var p={mp4:c.isTypeSupported("video/mp4"),mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"')},g=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker){var v;s.logger.log("demuxing in webworker");try{v=this.worker=(0,i.default)(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),v.addEventListener("message",this.onwmsg),v.onerror=function(e){d.useWorker=!1,s.logger.warn("Exception in webworker, fallback to inline"),d.hls.trigger(n.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:new Error(e.message+" ("+e.filename+":"+e.lineno+")")})},v.postMessage({cmd:"init",typeSupported:p,vendor:g,id:t,config:JSON.stringify(h)})}catch(e){s.logger.warn("Error in worker:",e),s.logger.error("Error while initializing DemuxerWorker, fallback to inline"),v&&self.URL.revokeObjectURL(v.objectURL),this.transmuxer=new a.default(this.observer,p,h,g,t),this.worker=null}}else this.transmuxer=new a.default(this.observer,p,h,g,t)}var t=e.prototype;return t.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}var r=this.observer;r&&r.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},t.push=function(e,t,r,i,n,o,l,u,c,d){var h,f,p=this;c.transmuxing.start=self.performance.now();var g=this.transmuxer,v=this.worker,m=o?o.start:n.start,y=n.decryptdata,A=this.frag,E=!(A&&n.cc===A.cc),T=!(A&&c.level===A.level),b=A?c.sn-A.sn:-1,k=this.part?c.part-this.part.index:-1,S=0===b&&c.id>1&&c.id===(null==A?void 0:A.stats.chunkCount),_=!T&&(1===b||0===b&&(1===k||S&&k<=0)),C=self.performance.now();(T||b||0===n.stats.parsing.start)&&(n.stats.parsing.start=C),!o||!k&&_||(o.stats.parsing.start=C);var L=!(A&&(null===(h=n.initSegment)||void 0===h?void 0:h.url)===(null===(f=A.initSegment)||void 0===f?void 0:f.url)),D=new a.TransmuxState(E,_,u,T,m,L);if(!_||E||L){s.logger.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+c.sn+" p: "+c.part+" level: "+c.level+" id: "+c.id+"\n discontinuity: "+E+"\n trackSwitch: "+T+"\n contiguous: "+_+"\n accurateTimeOffset: "+u+"\n timeOffset: "+m+"\n initSegmentChange: "+L);var R=new a.TransmuxConfig(r,i,t,l,d);this.configureTransmuxer(R)}if(this.frag=n,this.part=o,v)v.postMessage({cmd:"demux",data:e,decryptdata:y,chunkMeta:c,state:D},e instanceof ArrayBuffer?[e]:[]);else if(g){var I=g.push(e,y,c,D);(0,a.isPromise)(I)?I.then((function(e){p.handleTransmuxComplete(e)})):this.handleTransmuxComplete(I)}},t.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.transmuxer,i=this.worker;if(i)i.postMessage({cmd:"flush",chunkMeta:e});else if(r){var n=r.flush(e);(0,a.isPromise)(n)?n.then((function(r){t.handleFlushResult(r,e)})):this.handleFlushResult(n,e)}},t.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},t.onWorkerMessage=function(e){var t=e.data,r=this.hls;switch(t.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":s.logger[t.data.logType]&&s.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}},t.configureTransmuxer=function(e){var t=this.worker,r=this.transmuxer;t?t.postMessage({cmd:"configure",config:e}):r&&r.configure(e)},t.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},e}()},"./src/demux/transmuxer-worker.ts": /*!****************************************!*\ !*** ./src/demux/transmuxer-worker.ts ***! \****************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var i=r(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function o(e){var t=new s.EventEmitter,r=function(t,r){e.postMessage({event:t,data:r})};t.on(n.Events.FRAG_DECRYPTED,r),t.on(n.Events.ERROR,r),e.addEventListener("message",(function(n){var s=n.data;switch(s.cmd){case"init":var o=JSON.parse(s.config);e.transmuxer=new i.default(t,s.typeSupported,o,s.vendor,s.id),(0,a.enableLogs)(o.debug,s.id),function(){var e=function(e){a.logger[e]=function(t){r("workerLog",{logType:e,message:t})}};for(var t in a.logger)e(t)}(),r("init",null);break;case"configure":e.transmuxer.configure(s.config);break;case"demux":var u=e.transmuxer.push(s.data,s.decryptdata,s.chunkMeta,s.state);(0,i.isPromise)(u)?u.then((function(t){l(e,t)})):l(e,u);break;case"flush":var d=s.chunkMeta,h=e.transmuxer.flush(d);(0,i.isPromise)(h)?h.then((function(t){c(e,t,d)})):c(e,h,d)}}))}function l(e,t){if(!((r=t.remuxResult).audio||r.video||r.text||r.id3||r.initSegment))return!1;var r,i=[],n=t.remuxResult,a=n.audio,s=n.video;return a&&u(i,a),s&&u(i,s),e.postMessage({event:"transmuxComplete",data:t},i),!0}function u(e,t){t.data1&&e.push(t.data1.buffer),t.data2&&e.push(t.data2.buffer)}function c(e,t,r){t.reduce((function(t,r){return l(e,r)||t}),!1)||e.postMessage({event:"transmuxComplete",data:t[0]}),e.postMessage({event:"flush",data:r})}},"./src/demux/transmuxer.ts": /*!*********************************!*\ !*** ./src/demux/transmuxer.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{TransmuxConfig:()=>y,TransmuxState:()=>A,default:()=>g,isPromise:()=>m});var i,n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),o=r(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),l=r(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),u=r(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),c=r(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),d=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),h=r(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),f=r(/*! ../utils/logger */"./src/utils/logger.ts");try{i=self.performance.now.bind(self.performance)}catch(e){f.logger.debug("Unable to use Performance API on this environment"),i=self.Date.now}var p=[{demux:u.default,remux:d.default},{demux:l.default,remux:h.default},{demux:o.default,remux:d.default},{demux:c.default,remux:d.default}],g=function(){function e(e,t,r,i,n){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=e,this.typeSupported=t,this.config=r,this.vendor=i,this.id=n}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,n){var a=this,s=r.transmuxing;s.executeStart=i();var o=new Uint8Array(e),l=this.config,u=this.currentTransmuxState,c=this.transmuxConfig;n&&(this.currentTransmuxState=n);var d=n||u,h=d.contiguous,f=d.discontinuity,p=d.trackSwitch,g=d.accurateTimeOffset,m=d.timeOffset,y=d.initSegmentChange,A=c.audioCodec,E=c.videoCodec,T=c.defaultInitPts,b=c.duration,k=c.initSegmentData;(f||p||y)&&this.resetInitSegment(k,A,E,b),(f||y)&&this.resetInitialTimestamp(T),h||this.resetContiguity();var S=function(e,t){var r=null;return e.byteLength>0&&null!=t&&null!=t.key&&null!==t.iv&&null!=t.method&&(r=t),r}(o,t);if(S&&"AES-128"===S.method){var _=this.getDecrypter();if(!l.enableSoftwareAES)return this.decryptionPromise=_.webCryptoDecrypt(o,S.key.buffer,S.iv.buffer).then((function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t})),this.decryptionPromise;var C=_.softwareDecrypt(o,S.key.buffer,S.iv.buffer);if(!C)return s.executeEnd=i(),v(r);o=new Uint8Array(C)}this.needsProbing(o,f,p)&&this.configureTransmuxer(o,c);var L=this.transmux(o,S,m,g,r),D=this.currentTransmuxState;return D.contiguous=!0,D.discontinuity=!1,D.trackSwitch=!1,s.executeEnd=i(),L},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=i();var s=this.decrypter,o=this.currentTransmuxState,l=this.decryptionPromise;if(l)return l.then((function(){return t.flush(e)}));var u=[],c=o.timeOffset;if(s){var d=s.flush();d&&u.push(this.push(d,null,e))}var h=this.demuxer,f=this.remuxer;if(!h||!f)return this.observer.emit(n.Events.ERROR,n.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),r.executeEnd=i(),[v(e)];var p=h.flush(c);return m(p)?p.then((function(r){return t.flushRemux(u,r,e),u})):(this.flushRemux(u,p,e),u)},t.flushRemux=function(e,t,r){var n=t.audioTrack,a=t.videoTrack,s=t.id3Track,o=t.textTrack,l=this.currentTransmuxState,u=l.accurateTimeOffset,c=l.timeOffset;f.logger.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var d=this.remuxer.remux(n,a,s,o,c,u,!0,this.id);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=i()},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,i){var n=this.demuxer,a=this.remuxer;n&&a&&(n.resetInitSegment(e,t,r,i),a.resetInitSegment(e,t,r))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(e,t,r,i,n){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n)},t.transmuxUnencrypted=function(e,t,r,i){var n=this.demuxer.demux(e,t,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,t,r,!1,this.id),chunkMeta:i}},t.transmuxSampleAes=function(e,t,r,i,n){var a=this;return this.demuxer.demuxSampleAes(e,t,r).then((function(e){return{remuxResult:a.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,a.id),chunkMeta:n}}))},t.configureTransmuxer=function(e,t){for(var r,i=this.config,n=this.observer,a=this.typeSupported,s=this.vendor,o=t.audioCodec,u=t.defaultInitPts,c=t.duration,d=t.initSegmentData,g=t.videoCodec,v=0,m=p.length;v<m;v++)if(p[v].demux.probe(e)){r=p[v];break}r||(f.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),r={demux:l.default,remux:h.default});var y=this.demuxer,A=this.remuxer,E=r.remux,T=r.demux;A&&A instanceof E||(this.remuxer=new E(n,i,a,s)),y&&y instanceof T||(this.demuxer=new T(n,i,a),this.probe=T.probe),this.resetInitSegment(d,o,g,c),this.resetInitialTimestamp(u)},t.needsProbing=function(e,t,r){return!this.demuxer||!this.remuxer||t||r},t.getDecrypter=function(){var e=this.decrypter;return e||(e=this.decrypter=new s.default(this.observer,this.config)),e},e}(),v=function(e){return{remuxResult:{},chunkMeta:e}};function m(e){return"then"in e&&e.then instanceof Function}var y=function(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n},A=function(e,t,r,i,n,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=a}},"./src/demux/tsdemuxer.ts": /*!********************************!*\ !*** ./src/demux/tsdemuxer.ts ***! \********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>A});var i=r(/*! ./adts */"./src/demux/adts.ts"),n=r(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),a=r(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),s=r(/*! ./sample-aes */"./src/demux/sample-aes.ts"),o=r(/*! ../events */"./src/events.ts"),l=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),u=r(/*! ../utils/logger */"./src/utils/logger.ts"),c=r(/*! ../errors */"./src/errors.ts"),d=r(/*! ../types/demuxer */"./src/types/demuxer.ts");function h(){return h=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},h.apply(this,arguments)}var f=188;function p(e,t,r,i){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:i,length:0}}function g(e,t){return(31&e[t+10])<<8|e[t+11]}function v(e,t,r,i){var n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<a;){var s=(31&e[t+1])<<8|e[t+2];switch(e[t]){case 207:if(!i){u.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===n.audio&&(n.audio=s);break;case 21:-1===n.id3&&(n.id3=s);break;case 219:if(!i){u.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===n.avc&&(n.avc=s);break;case 3:case 4:!0!==r.mpeg&&!0!==r.mp3?u.logger.log("MPEG audio found, not supported in this browser"):-1===n.audio&&(n.audio=s,n.segmentCodec="mp3");break;case 36:u.logger.warn("Unsupported HEVC stream type found")}t+=5+((15&e[t+3])<<8|e[t+4])}return n}function m(e){var t,r,i,n,a,s=0,o=e.data;if(!e||0===e.size)return null;for(;o[0].length<19&&o.length>1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((t=o[0])[0]<<16)+(t[1]<<8)+t[2]){if((r=(t[4]<<8)+t[5])&&r>e.size-6)return null;var c=t[7];192&c&&(n=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&c?n-(a=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>54e5&&(u.logger.warn(Math.round((n-a)/9e4)+"s delta between PTS and DTS, align them"),n=a):a=n);var d=(i=t[8])+9;if(e.size<=d)return null;e.size-=d;for(var h=new Uint8Array(e.size),f=0,p=o.length;f<p;f++){var g=(t=o[f]).byteLength;if(d){if(d>g){d-=g;continue}t=t.subarray(d),g-=d,d=0}h.set(t,s),s+=g}return r&&(r-=i+3),{data:h,pts:n,dts:a,len:r}}return null}function y(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,i=r.length;if(!i)return void t.dropped++;var n=r[i-1];e.pts=n.pts,e.dts=n.dts}t.samples.push(e)}e.debug.length&&u.logger.log(e.pts+"/"+e.dts+":"+e.debug)}const A=function(){function e(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}e.probe=function(t){var r=e.syncOffset(t);return r>0&&u.logger.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},e.syncOffset=function(e){for(var t=Math.min(940,e.length-376)+1,r=0;r<t;){if(71===e[r]&&71===e[r+f])return r;r++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:l.RemuxerTrackIdConfig[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=e.createTrack("video"),this._audioTrack=e.createTrack("audio",n),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._avcTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},t.demux=function(t,r,i,n){var a;void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var s=this._avcTrack,d=this._audioTrack,h=this._id3Track,p=this._txtTrack,y=s.pid,A=s.pesData,E=d.pid,T=h.pid,b=d.pesData,k=h.pesData,S=null,_=this.pmtParsed,C=this._pmtId,L=t.length;if(this.remainderData&&(L=(t=(0,l.appendUint8Array)(this.remainderData,t)).length,this.remainderData=null),L<f&&!n)return this.remainderData=t,{audioTrack:d,videoTrack:s,id3Track:h,textTrack:p};var D=Math.max(0,e.syncOffset(t));(L-=(L-D)%f)<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,L,t.buffer.byteLength-L));for(var R=0,I=D;I<L;I+=f)if(71===t[I]){var O=!!(64&t[I+1]),w=((31&t[I+1])<<8)+t[I+2],P=void 0;if((48&t[I+3])>>4>1){if((P=I+5+t[I+4])===I+f)continue}else P=I+4;switch(w){case y:O&&(A&&(a=m(A))&&this.parseAVCPES(s,p,a,!1),A={data:[],size:0}),A&&(A.data.push(t.subarray(P,I+f)),A.size+=I+f-P);break;case E:if(O){if(b&&(a=m(b)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,a);break;case"mp3":this.parseMPEGPES(d,a)}b={data:[],size:0}}b&&(b.data.push(t.subarray(P,I+f)),b.size+=I+f-P);break;case T:O&&(k&&(a=m(k))&&this.parseID3PES(h,a),k={data:[],size:0}),k&&(k.data.push(t.subarray(P,I+f)),k.size+=I+f-P);break;case 0:O&&(P+=t[P]+1),C=this._pmtId=g(t,P);break;case C:O&&(P+=t[P]+1);var x=v(t,P,this.typeSupported,i);(y=x.avc)>0&&(s.pid=y),(E=x.audio)>0&&(d.pid=E,d.segmentCodec=x.segmentCodec),(T=x.id3)>0&&(h.pid=T),null===S||_||(u.logger.log("unknown PID '"+S+"' in TS found"),S=null,I=D-188),_=this.pmtParsed=!0;break;case 17:case 8191:break;default:S=w}}else R++;R>0&&this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+R+" TS packet/s that do not start with 0x47"}),s.pesData=A,d.pesData=b,h.pesData=k;var N={audioTrack:d,videoTrack:s,id3Track:h,textTrack:p};return n&&this.extractRemainingSamples(N),N},t.flush=function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e},t.extractRemainingSamples=function(e){var t,r=e.audioTrack,i=e.videoTrack,n=e.id3Track,a=e.textTrack,s=i.pesData,o=r.pesData,l=n.pesData;if(s&&(t=m(s))?(this.parseAVCPES(i,a,t,!0),i.pesData=null):i.pesData=s,o&&(t=m(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,t);break;case"mp3":this.parseMPEGPES(r,t)}r.pesData=null}else null!=o&&o.size&&u.logger.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(t=m(l))?(this.parseID3PES(n,t),n.pesData=null):n.pesData=l},t.demuxSampleAes=function(e,t,r){var i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new s.default(this.observer,this.config,t);return this.decrypt(i,n)},t.decrypt=function(e,t){return new Promise((function(r){var i=e.audioTrack,n=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){n.samples?t.decryptAvcSamples(n.samples,0,0,(function(){r(e)})):r(e)})):n.samples&&t.decryptAvcSamples(n.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this._duration=0},t.parseAVCPES=function(e,t,r,i){var n,s=this,o=this.parseAVCNALu(e,r.data),u=this.avcSample,c=!1;r.data=null,u&&o.length&&!e.audFound&&(y(u,e),u=this.avcSample=p(!1,r.pts,r.dts,"")),o.forEach((function(i){switch(i.type){case 1:n=!0,u||(u=s.avcSample=p(!0,r.pts,r.dts,"")),u.frame=!0;var o=i.data;if(c&&o.length>4){var d=new a.default(o).readSliceType();2!==d&&4!==d&&7!==d&&9!==d||(u.key=!0)}break;case 5:n=!0,u||(u=s.avcSample=p(!0,r.pts,r.dts,"")),u.key=!0,u.frame=!0;break;case 6:n=!0,(0,l.parseSEIMessageFromNALu)(i.data,1,r.pts,t.samples);break;case 7:if(n=!0,c=!0,!e.sps){var h=new a.default(i.data).readSPS();e.width=h.width,e.height=h.height,e.pixelRatio=h.pixelRatio,e.sps=[i.data],e.duration=s._duration;for(var f=i.data.subarray(1,4),g="avc1.",v=0;v<3;v++){var m=f[v].toString(16);m.length<2&&(m="0"+m),g+=m}e.codec=g}break;case 8:n=!0,e.pps||(e.pps=[i.data]);break;case 9:n=!1,e.audFound=!0,u&&y(u,e),u=s.avcSample=p(!1,r.pts,r.dts,"");break;case 12:n=!0;break;default:n=!1,u&&(u.debug+="unknown NAL "+i.type+" ")}u&&n&&u.units.push(i)})),i&&u&&(y(u,e),this.avcSample=null)},t.getLastNalUnit=function(e){var t,r,i=this.avcSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!==(t=i)&&void 0!==t&&t.units){var n=i.units;r=n[n.length-1]}return r},t.parseAVCNALu=function(e,t){var r,i,n=t.byteLength,a=e.naluState||0,s=a,o=[],l=0,u=-1,c=0;for(-1===a&&(u=0,c=31&t[0],a=0,l=1);l<n;)if(r=t[l++],a)if(1!==a)if(r)if(1===r){if(u>=0){var d={data:t.subarray(u,l-a-1),type:c};o.push(d)}else{var h=this.getLastNalUnit(e.samples);if(h&&(s&&l<=4-s&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-s)),(i=l-a-1)>0)){var f=new Uint8Array(h.data.byteLength+i);f.set(h.data,0),f.set(t.subarray(0,i),h.data.byteLength),h.data=f,h.state=0}}l<n?(u=l,c=31&t[l],a=0):a=-1}else a=0;else a=3;else a=r?0:2;else a=r?0:1;if(u>=0&&a>=0){var p={data:t.subarray(u,n),type:c,state:a};o.push(p)}if(0===o.length){var g=this.getLastNalUnit(e.samples);if(g){var v=new Uint8Array(g.data.byteLength+t.byteLength);v.set(g.data,0),v.set(t,g.data.byteLength),g.data=v}}return e.naluState=a,o},t.parseAACPES=function(e,t){var r,n,a,s,l,d=0,h=this.aacOverFlow,f=t.data;if(h){this.aacOverFlow=null;var p=h.missing,g=h.sample.unit.byteLength;if(-1===p){var v=new Uint8Array(g+f.byteLength);v.set(h.sample.unit,0),v.set(f,g),f=v}else{var m=g-p;h.sample.unit.set(f.subarray(0,p),m),e.samples.push(h.sample),d=h.missing}}for(r=d,n=f.length;r<n-1&&!i.isHeader(f,r);r++);if(r===d||(r<n-1?(a="AAC PES did not start with ADTS header,offset:"+r,s=!1):(a="no ADTS header found in AAC PES",s=!0),u.logger.warn("parsing error:"+a),this.observer.emit(o.Events.ERROR,o.Events.ERROR,{type:c.ErrorTypes.MEDIA_ERROR,details:c.ErrorDetails.FRAG_PARSING_ERROR,fatal:s,reason:a}),!s)){if(i.initTrackConfig(e,this.observer,f,r,this.audioCodec),void 0!==t.pts)l=t.pts;else{if(!h)return void u.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var y=i.getFrameDuration(e.samplerate);l=h.sample.pts+y}for(var A,E=0;r<n;){if(r+=(A=i.appendFrame(e,f,r,l,E)).length,A.missing){this.aacOverFlow=A;break}for(E++;r<n-1&&!i.isHeader(f,r);r++);}}},t.parseMPEGPES=function(e,t){var r=t.data,i=r.length,a=0,s=0,o=t.pts;if(void 0!==o)for(;s<i;)if(n.isHeader(r,s)){var l=n.appendFrame(e,r,s,o,a);if(!l)break;s+=l.length,a++}else s++;else u.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},t.parseID3PES=function(e,t){if(void 0!==t.pts){var r=h({},t,{type:this._avcTrack?d.MetadataSchema.emsg:d.MetadataSchema.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}else u.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},e}()},"./src/demux/webworkify-webpack.js": /*!*****************************************!*\ !*** ./src/demux/webworkify-webpack.js ***! \*****************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var i=function(){var e=ENTRY_MODULE,t={},r=function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i].call(a.exports,a,a.exports,r),a.exports};r.m=e,r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i=r(ENTRY_MODULE);return i.default||i}.toString().split("ENTRY_MODULE"),n="[\\.|\\-|\\+|\\w|/|@]+",a="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+n+").*?\\)";function s(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(e,t,i){var o={};o[i]=[];var l=t.toString().replace(/^"[^"]+"/,"function"),u=l.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/)||l.match(/^\(\w+,\s*\w+,\s*(\w+)\)\s?\=\s?\>/);if(!u)return o;for(var c,d=u[1],h=new RegExp("(\\\\n|\\W)"+s(d)+a,"g");c=h.exec(l);)"dll-reference"!==c[3]&&o[i].push(c[3]);for(h=new RegExp("\\("+s(d)+'\\("(dll-reference\\s('+n+'))"\\)\\)'+a,"g");c=h.exec(l);)e[c[2]]||(o[i].push(c[1]),e[c[2]]=r(c[1]).m),o[c[2]]=o[c[2]]||[],o[c[2]].push(c[4]);for(var f,p=Object.keys(o),g=0;g<p.length;g++)for(var v=0;v<o[p[g]].length;v++)f=o[p[g]][v],isNaN(1*f)||(o[p[g]][v]=1*o[p[g]][v]);return o}function l(e){return Object.keys(e).reduce((function(t,r){return t||e[r].length>0}),!1)}function u(e,t,r,n){var a=e[n].map((function(e){return'"'+e+'": '+t[n][e].toString().replace(/^"[^"]+"/,"function")})).join(",");return i[0]+"{"+a+"}"+i[1]+'"'+r+'"'+i[2]}function c(e,t){t=t||{};var i={main:r.m},n=t.all?{main:Object.keys(i.main)}:function(e,t){for(var r={main:[t]},i={main:[]},n={main:{}};l(r);)for(var a=Object.keys(r),s=0;s<a.length;s++){var u=a[s],c=r[u].pop();if(n[u]=n[u]||{},!n[u][c]&&e[u][c]){n[u][c]=!0,i[u]=i[u]||[],i[u].push(c);for(var d=o(e,e[u][c],u),h=Object.keys(d),f=0;f<h.length;f++)r[h[f]]=r[h[f]]||[],r[h[f]]=r[h[f]].concat(d[h[f]])}}return i}(i,e),a="";Object.keys(n).filter((function(e){return"main"!==e})).forEach((function(e){for(var t=0;n[e][t];)t++;n[e].push(t),i[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+e+" = ("+u(n,i,t,modules)+")();\n"})),a=a+"new (("+u(n,i,e,"main")+")())(self);";var s=new window.Blob([a],{type:"text/javascript"}),c=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(s),d=new window.Worker(c);return d.objectURL=c,d}},"./src/errors.ts": /*!***********************!*\ !*** ./src/errors.ts ***! \***********************/(e,t,r)=>{var i,n;r.r(t),r.d(t,{ErrorDetails:()=>n,ErrorTypes:()=>i}),function(e){e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError"}(i||(i={})),function(e){e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown"}(n||(n={}))},"./src/events.ts": /*!***********************!*\ !*** ./src/events.ts ***! \***********************/(e,t,r)=>{var i;r.r(t),r.d(t,{Events:()=>i}),function(e){e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached"}(i||(i={}))},"./src/hls.ts": /*!********************!*\ !*** ./src/hls.ts ***! \********************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>y});var i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),n=r(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),a=r(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),s=r(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),o=r(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),l=r(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),u=r(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),c=r(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),d=r(/*! ./is-supported */"./src/is-supported.ts"),h=r(/*! ./utils/logger */"./src/utils/logger.ts"),f=r(/*! ./config */"./src/config.ts"),p=r(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),g=r(/*! ./events */"./src/events.ts"),v=r(/*! ./errors */"./src/errors.ts");function m(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var y=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new p.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=(0,f.mergeConfig)(e.DefaultConfig,t);this.userConfig=t,(0,h.enableLogs)(r.debug,"Hls instance"),this._autoLevelCapping=-1,r.progressive&&(0,f.enableStreamingMode)(r);var i=r.abrController,d=r.bufferController,g=r.capLevelController,v=r.fpsController,m=this.abrController=new i(this),y=this.bufferController=new d(this),A=this.capLevelController=new g(this),E=new v(this),T=new n.default(this),b=new a.default(this),k=new s.default(this),S=this.levelController=new l.default(this),_=new u.FragmentTracker(this),C=this.streamController=new c.default(this,_);A.setStreamController(C),E.setStreamController(C);var L=[T,b,S,C];this.networkControllers=L;var D=[m,y,A,E,k,_];this.audioTrackController=this.createController(r.audioTrackController,null,L),this.createController(r.audioStreamController,_,L),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,L),this.createController(r.subtitleStreamController,_,L),this.createController(r.timelineController,null,D),this.emeController=this.createController(r.emeController,null,D),this.cmcdController=this.createController(r.cmcdController,null,D),this.latencyController=this.createController(o.default,null,D),this.coreComponents=D}e.isSupported=function(){return(0,d.isSupported)()};var t,r,y,A=e.prototype;return A.createController=function(e,t,r){if(e){var i=t?new e(this,t):new e(this);return r&&r.push(i),i}return null},A.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},A.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},A.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},A.off=function(e,t,r,i){void 0===r&&(r=this),this._emitter.off(e,t,r,i)},A.listeners=function(e){return this._emitter.listeners(e)},A.emit=function(e,t,r){return this._emitter.emit(e,t,r)},A.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){h.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(g.Events.ERROR,{type:v.ErrorTypes.OTHER_ERROR,details:v.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1},A.listenerCount=function(e){return this._emitter.listenerCount(e)},A.destroy=function(){h.logger.log("destroy"),this.trigger(g.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0},A.attachMedia=function(e){h.logger.log("attachMedia"),this._media=e,this.trigger(g.Events.MEDIA_ATTACHING,{media:e})},A.detachMedia=function(){h.logger.log("detachMedia"),this.trigger(g.Events.MEDIA_DETACHING,void 0),this._media=null},A.loadSource=function(e){this.stopLoad();var t=this.media,r=this.url,n=this.url=i.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});h.logger.log("loadSource:"+n),t&&r&&r!==n&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(t)),this.trigger(g.Events.MANIFEST_LOADING,{url:e})},A.startLoad=function(e){void 0===e&&(e=-1),h.logger.log("startLoad("+e+")"),this.networkControllers.forEach((function(t){t.startLoad(e)}))},A.stopLoad=function(){h.logger.log("stopLoad"),this.networkControllers.forEach((function(e){e.stopLoad()}))},A.swapAudioCodec=function(){h.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},A.recoverMediaError=function(){h.logger.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)},A.removeLevel=function(e,t){void 0===t&&(t=0),this.levelController.removeLevel(e,t)},t=e,y=[{key:"version",get:function(){return"1.2.9"}},{key:"Events",get:function(){return g.Events}},{key:"ErrorTypes",get:function(){return v.ErrorTypes}},{key:"ErrorDetails",get:function(){return v.ErrorDetails}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:f.hlsDefaultConfig},set:function(t){e.defaultConfig=t}}],(r=[{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){h.logger.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){h.logger.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){h.logger.log("set loadLevel:"+e),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){h.logger.log("set firstLevel:"+e),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(e){h.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(h.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i<r;i++)if(e[i].maxBitrate>=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e=this.levels,t=this.autoLevelCapping;return-1===t&&e&&e.length?e.length-1:t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&m(t.prototype,r),y&&m(t,y),Object.defineProperty(t,"prototype",{writable:!1}),e}();y.defaultConfig=void 0},"./src/is-supported.ts": /*!*****************************!*\ !*** ./src/is-supported.ts ***! \*****************************/(e,t,r)=>{r.r(t),r.d(t,{changeTypeSupported:()=>s,isSupported:()=>a});var i=r(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function n(){return self.SourceBuffer||self.WebKitSourceBuffer}function a(){var e=(0,i.getMediaSource)();if(!e)return!1;var t=n(),r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),a=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!a}function s(){var e,t=n();return"function"==typeof(null==t||null===(e=t.prototype)||void 0===e?void 0:e.changeType)}},"./src/loader/date-range.ts": /*!**********************************!*\ !*** ./src/loader/date-range.ts ***! \**********************************/(e,t,r)=>{r.r(t),r.d(t,{DateRange:()=>u,DateRangeAttribute:()=>i});var i,n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),a=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts");function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},o.apply(this,arguments)}function l(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}!function(e){e.ID="ID",e.CLASS="CLASS",e.START_DATE="START-DATE",e.DURATION="DURATION",e.END_DATE="END-DATE",e.END_ON_NEXT="END-ON-NEXT",e.PLANNED_DURATION="PLANNED-DURATION",e.SCTE35_OUT="SCTE35-OUT",e.SCTE35_IN="SCTE35-IN"}(i||(i={}));var u=function(){function e(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var r=t.attr;for(var l in r)if(Object.prototype.hasOwnProperty.call(e,l)&&e[l]!==r[l]){s.logger.warn('DATERANGE tag attribute: "'+l+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=l;break}e=o(new a.AttrList({}),r,e)}if(this.attr=e,this._startDate=new Date(e[i.START_DATE]),i.END_DATE in this.attr){var u=new Date(this.attr[i.END_DATE]);(0,n.isFiniteNumber)(u.getTime())&&(this._endDate=u)}}var t,r,u;return t=e,(r=[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}},{key:"duration",get:function(){if(i.DURATION in this.attr){var e=this.attr.decimalFloatingPoint(i.DURATION);if((0,n.isFiniteNumber)(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return i.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(i.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(i.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&(0,n.isFiniteNumber)(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}])&&l(t.prototype,r),u&&l(t,u),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/loader/fragment-loader.ts": /*!***************************************!*\ !*** ./src/loader/fragment-loader.ts ***! \***************************************/(e,t,r)=>{r.r(t),r.d(t,{LoadError:()=>f,default:()=>d});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../errors */"./src/errors.ts");function a(e){var t="function"==typeof Map?new Map:void 0;return a=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return s(e,arguments,u(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),l(i,e)},a(e)}function s(e,t,r){return s=o()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&l(n,r.prototype),n},s.apply(null,arguments)}function o(){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(e){return!1}}function l(e,t){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},l(e,t)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}var c=Math.pow(2,17),d=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t){var r=this,i=e.url;if(!i)return Promise.reject(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,networkDetails:null},"Fragment does not have a "+(i?"part list":"url")));this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(i,l){r.loader&&r.loader.destroy();var u=r.loader=e.loader=s?new s(a):new o(a),d=h(e),p={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:"initSegment"===e.sn?1/0:c};e.stats=u.stats,u.load(d,p,{onSuccess:function(t,n,a,s){r.resetLoader(e,u),i({frag:e,part:null,payload:t.data,networkDetails:s})},onError:function(t,i,a){r.resetLoader(e,u),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:t,networkDetails:a}))},onAbort:function(t,i,a){r.resetLoader(e,u),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,networkDetails:a}))},onTimeout:function(t,i,a){r.resetLoader(e,u),l(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,networkDetails:a}))},onProgress:function(r,i,n,a){t&&t({frag:e,part:null,payload:n,networkDetails:a})}})}))},t.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(l,u){i.loader&&i.loader.destroy();var d=i.loader=e.loader=s?new s(a):new o(a),p=h(e,t),g={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:a.fragLoadingMaxRetryTimeout,highWaterMark:c};t.stats=d.stats,d.load(p,g,{onSuccess:function(n,a,s,o){i.resetLoader(e,d),i.updateStatsFromPart(e,t);var u={frag:e,part:t,payload:n.data,networkDetails:o};r(u),l(u)},onError:function(r,a,s){i.resetLoader(e,d),u(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:r,networkDetails:s}))},onAbort:function(r,a,s){e.stats.aborted=t.stats.aborted,i.resetLoader(e,d),u(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,networkDetails:s}))},onTimeout:function(r,a,s){i.resetLoader(e,d),u(new f({type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,networkDetails:s}))}})}))},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){var a=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},t.resetLoader=function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function h(e,t){void 0===t&&(t=null);var r=t||e,n={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,s=r.byteRangeEndOffset;return(0,i.isFiniteNumber)(a)&&(0,i.isFiniteNumber)(s)&&(n.rangeStart=a,n.rangeEnd=s),n}var f=function(e){var t,r;function i(t){for(var r,i=arguments.length,n=new Array(i>1?i-1:0),a=1;a<i;a++)n[a-1]=arguments[a];return(r=e.call.apply(e,[this].concat(n))||this).data=void 0,r.data=t,r}return r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,l(t,r),i}(a(Error))},"./src/loader/fragment.ts": /*!********************************!*\ !*** ./src/loader/fragment.ts ***! \********************************/(e,t,r)=>{r.r(t),r.d(t,{BaseSegment:()=>f,ElementaryStreamTypes:()=>i,Fragment:()=>p,Part:()=>g});var i,n=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),a=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ./level-key */"./src/loader/level-key.ts"),l=r(/*! ./load-stats */"./src/loader/load-stats.ts");function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function d(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function h(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}!function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"}(i||(i={}));var f=function(){function e(e){var t;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((t={})[i.AUDIO]=null,t[i.VIDEO]=null,t[i.AUDIOVIDEO]=null,t),this.baseurl=e}return e.prototype.setByteRange=function(e,t){var r=e.split("@",2),i=[];1===r.length?i[0]=t?t.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},h(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=(0,a.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}}]),e}(),p=function(e){function t(t,r){var i;return(i=e.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkey=void 0,i.type=void 0,i.loader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.appendedPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new l.LoadStats,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.type=t,i}u(t,e);var r=t.prototype;return r.createInitializationVector=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t},r.setDecryptDataFromLevelKey=function(e,t){var r=e;return"AES-128"===(null==e?void 0:e.method)&&e.uri&&!e.iv&&((r=o.LevelKey.fromURI(e.uri)).method=e.method,r.iv=this.createInitializationVector(t),r.keyFormat="identity"),r},r.setElementaryStreamInfo=function(e,t,r,i,n,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[e];o?(o.startPTS=Math.min(o.startPTS,t),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):s[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:a}},r.clearElementaryStreamInfo=function(){var e=this.elementaryStreams;e[i.AUDIO]=null,e[i.VIDEO]=null,e[i.AUDIOVIDEO]=null},h(t,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var e=this.sn;"number"!=typeof e&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&s.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),e=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,e)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!(0,n.isFiniteNumber)(this.programDateTime))return null;var e=(0,n.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;return!(null===(e=this.decryptdata)||void 0===e||!e.keyFormat||!this.decryptdata.uri)}}]),t}(f),g=function(e){function t(t,r,i,n,a){var s;(s=e.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new l.LoadStats,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=n;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return u(t,e),h(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}]),t}(f)},"./src/loader/key-loader.ts": /*!**********************************!*\ !*** ./src/loader/key-loader.ts ***! \**********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var i=r(/*! ../events */"./src/events.ts"),n=r(/*! ../errors */"./src/errors.ts"),a=r(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function e(e){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){this.hls.on(i.Events.KEY_LOADING,this.onKeyLoading,this)},t.unregisterListeners=function(){this.hls.off(i.Events.KEY_LOADING,this.onKeyLoading)},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy()}this.loaders={}},t.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},t.onKeyLoading=function(e,t){var r=t.frag,n=r.type,s=this.loaders[n];if(r.decryptdata){var o=r.decryptdata.uri;if(o!==this.decrypturl||null===this.decryptkey){var l=this.hls.config;if(s&&(a.logger.warn("abort previous key loader for type:"+n),s.abort()),!o)return void a.logger.warn("key uri is falsy");var u=l.loader,c=r.loader=this.loaders[n]=new u(l);this.decrypturl=o,this.decryptkey=null;var d={url:o,frag:r,responseType:"arraybuffer"},h={timeout:l.fragLoadingTimeOut,maxRetry:0,retryDelay:l.fragLoadingRetryDelay,maxRetryDelay:l.fragLoadingMaxRetryTimeout,highWaterMark:0},f={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(d,h,f)}else this.decryptkey&&(r.decryptdata.key=this.decryptkey,this.hls.trigger(i.Events.KEY_LOADED,{frag:r}))}else a.logger.warn("Missing decryption data on fragment in onKeyLoading")},t.loadsuccess=function(e,t,r){var n=r.frag;n.decryptdata?(this.decryptkey=n.decryptdata.key=new Uint8Array(e.data),n.loader=null,delete this.loaders[n.type],this.hls.trigger(i.Events.KEY_LOADED,{frag:n})):a.logger.error("after key load, decryptdata unset")},t.loaderror=function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),delete this.loaders[r.type],this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:r,response:e})},t.loadtimeout=function(e,t){var r=t.frag,a=r.loader;a&&a.abort(),delete this.loaders[r.type],this.hls.trigger(i.Events.ERROR,{type:n.ErrorTypes.NETWORK_ERROR,details:n.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:r})},e}()},"./src/loader/level-details.ts": /*!*************************************!*\ !*** ./src/loader/level-details.ts ***! \*************************************/(e,t,r)=>{r.r(t),r.d(t,{LevelDetails:()=>a});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a=function(){function e(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,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.fragments=[],this.dateRanges={},this.url=e}var t,r,a;return e.prototype.reloaded=function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay},t=e,(r=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&(0,i.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var e;return null!==(e=this.fragments)&&void 0!==e&&e.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var e;return null!==(e=this.partList)&&void 0!==e&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&n(t.prototype,r),a&&n(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/loader/level-key.ts": /*!*********************************!*\ !*** ./src/loader/level-key.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{LevelKey:()=>a});var i=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function n(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var a=function(){function e(e,t){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=t?(0,i.buildAbsoluteURL)(e,t,{alwaysNormalize:!0}):e}var t,r,a;return e.fromURL=function(t,r){return new e(t,r)},e.fromURI=function(t){return new e(t)},t=e,(r=[{key:"uri",get:function(){return this._uri}}])&&n(t.prototype,r),a&&n(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/loader/load-stats.ts": /*!**********************************!*\ !*** ./src/loader/load-stats.ts ***! \**********************************/(e,t,r)=>{r.r(t),r.d(t,{LoadStats:()=>i});var i=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts": /*!***********************************!*\ !*** ./src/loader/m3u8-parser.ts ***! \***********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),a=r(/*! ./date-range */"./src/loader/date-range.ts"),s=r(/*! ./fragment */"./src/loader/fragment.ts"),o=r(/*! ./level-details */"./src/loader/level-details.ts"),l=r(/*! ./level-key */"./src/loader/level-key.ts"),u=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),c=r(/*! ../utils/logger */"./src/utils/logger.ts"),d=r(/*! ../utils/codecs */"./src/utils/codecs.ts"),h=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,f=/#EXT-X-MEDIA:(.*)/g,p=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),g=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|"0.5.0"): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),v=/\.(mp4|m4s|m4v|m4a)$/i,m=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r<e.length;r++){var i=e[r];if(i.id===t)return i}},e.convertAVC1ToAVCOTI=function(e){var t=e.split(".");if(t.length>2){var r=t.shift()+".";return r+=parseInt(t.shift()).toString(16),r+=("000"+parseInt(t.shift()).toString(16)).slice(-4)}return e},e.resolve=function(e,t){return n.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,r){var i,n=[],a=[],s={},o=!1;for(h.lastIndex=0;null!=(i=h.exec(t));)if(i[1]){var l,c=new u.AttrList(i[1]),d={attrs:c,bitrate:c.decimalInteger("AVERAGE-BANDWIDTH")||c.decimalInteger("BANDWIDTH"),name:c.NAME,url:e.resolve(i[2],r)},f=c.decimalResolution("RESOLUTION");f&&(d.width=f.width,d.height=f.height),y((c.CODECS||"").split(/[ ,]+/).filter((function(e){return e})),d),d.videoCodec&&-1!==d.videoCodec.indexOf("avc1")&&(d.videoCodec=e.convertAVC1ToAVCOTI(d.videoCodec)),null!==(l=d.unknownCodecs)&&void 0!==l&&l.length||a.push(d),n.push(d)}else if(i[3]){var p=new u.AttrList(i[3]);p["DATA-ID"]&&(o=!0,s[p["DATA-ID"]]=p)}return{levels:a.length>0&&a.length<n.length?a:n,sessionData:o?s:null}},e.parseMasterPlaylistMedia=function(t,r,i,n){var a;void 0===n&&(n=[]);var s=[],o=0;for(f.lastIndex=0;null!==(a=f.exec(t));){var l=new u.AttrList(a[1]);if(l.TYPE===i){var c={attrs:l,bitrate:0,id:o++,groupId:l["GROUP-ID"],instreamId:l["INSTREAM-ID"],name:l.NAME||l.LANGUAGE||"",type:i,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:l.LANGUAGE,url:l.URI?e.resolve(l.URI,r):""};if(n.length){var d=e.findGroup(n,c.groupId)||n[0];A(c,d,"audioCodec"),A(c,d,"textCodec")}s.push(c)}}return s},e.parseLevelPlaylist=function(e,t,r,d,h){var f,m,y,A=new o.LevelDetails(t),b=A.fragments,k=null,S=0,_=0,C=0,L=0,D=null,R=new s.Fragment(d,t),I=-1,O=!1;for(p.lastIndex=0,A.m3u8=e;null!==(f=p.exec(e));){O&&(O=!1,(R=new s.Fragment(d,t)).start=C,R.sn=S,R.cc=L,R.level=r,k&&(R.initSegment=k,R.rawProgramDateTime=k.rawProgramDateTime,k.rawProgramDateTime=null));var w=f[1];if(w){R.duration=parseFloat(w);var P=(" "+f[2]).slice(1);R.title=P||null,R.tagList.push(P?["INF",w,P]:["INF",w])}else if(f[3])(0,i.isFiniteNumber)(R.duration)&&(R.start=C,y&&(R.levelkey=y),R.sn=S,R.level=r,R.cc=L,R.urlId=h,b.push(R),R.relurl=(" "+f[3]).slice(1),E(R,D),D=R,C+=R.duration,S++,_=0,O=!0);else if(f[4]){var x=(" "+f[4]).slice(1);D?R.setByteRange(x,D):R.setByteRange(x)}else if(f[5])R.rawProgramDateTime=(" "+f[5]).slice(1),R.tagList.push(["PROGRAM-DATE-TIME",R.rawProgramDateTime]),-1===I&&(I=b.length);else{if(!(f=f[0].match(g))){c.logger.warn("No matches on slow regex match for level playlist!");continue}for(m=1;m<f.length&&void 0===f[m];m++);var N=(" "+f[m]).slice(1),F=(" "+f[m+1]).slice(1),M=f[m+2]?(" "+f[m+2]).slice(1):"";switch(N){case"PLAYLIST-TYPE":A.type=F.toUpperCase();break;case"MEDIA-SEQUENCE":S=A.startSN=parseInt(F);break;case"SKIP":var B=new u.AttrList(F),U=B.decimalInteger("SKIPPED-SEGMENTS");if((0,i.isFiniteNumber)(U)){A.skippedSegments=U;for(var G=U;G--;)b.unshift(null);S+=U}var V=B.enumeratedString("RECENTLY-REMOVED-DATERANGES");V&&(A.recentlyRemovedDateranges=V.split("\t"));break;case"TARGETDURATION":A.targetduration=parseFloat(F);break;case'"0.5.0"':A.version=parseInt(F);break;case"EXTM3U":break;case"ENDLIST":A.live=!1;break;case"#":(F||M)&&R.tagList.push(M?[F,M]:[F]);break;case"DISCONTINUITY":L++,R.tagList.push(["DIS"]);break;case"GAP":R.tagList.push([N]);break;case"BITRATE":R.tagList.push([N,F]);break;case"DATERANGE":var K=new u.AttrList(F),j=new a.DateRange(K,A.dateRanges[K.ID]);j.isValid||A.skippedSegments?A.dateRanges[j.id]=j:c.logger.warn('Ignoring invalid DATERANGE tag: "'+F+'"'),R.tagList.push(["EXT-X-DATERANGE",F]);break;case"DISCONTINUITY-SEQUENCE":L=parseInt(F);break;case"KEY":var H,Y=new u.AttrList(F),W=Y.enumeratedString("METHOD"),$=Y.URI,z=Y.hexadecimalInteger("IV"),q=Y.enumeratedString("KEYFORMATVERSIONS"),X=Y.enumeratedString("KEYID"),Z=null!=(H=Y.enumeratedString("KEYFORMAT"))?H:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(Z)>-1){c.logger.warn("Keyformat "+Z+" is not supported from the manifest");continue}if("identity"!==Z)continue;W&&(y=l.LevelKey.fromURL(t,$),$&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(W)>=0&&(y.method=W,y.keyFormat=Z,X&&(y.keyID=X),q&&(y.keyFormatVersions=q),y.iv=z));break;case"START":var Q=new u.AttrList(F).decimalFloatingPoint("TIME-OFFSET");(0,i.isFiniteNumber)(Q)&&(A.startTimeOffset=Q);break;case"MAP":var J=new u.AttrList(F);if(R.duration){var ee=new s.Fragment(d,t);T(ee,J,r,y),k=ee,R.initSegment=k,k.rawProgramDateTime&&!R.rawProgramDateTime&&(R.rawProgramDateTime=k.rawProgramDateTime)}else T(R,J,r,y),k=R,O=!0;break;case"SERVER-CONTROL":var te=new u.AttrList(F);A.canBlockReload=te.bool("CAN-BLOCK-RELOAD"),A.canSkipUntil=te.optionalFloat("CAN-SKIP-UNTIL",0),A.canSkipDateRanges=A.canSkipUntil>0&&te.bool("CAN-SKIP-DATERANGES"),A.partHoldBack=te.optionalFloat("PART-HOLD-BACK",0),A.holdBack=te.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var re=new u.AttrList(F);A.partTarget=re.decimalFloatingPoint("PART-TARGET");break;case"PART":var ie=A.partList;ie||(ie=A.partList=[]);var ne=_>0?ie[ie.length-1]:void 0,ae=_++,se=new s.Part(new u.AttrList(F),R,t,ae,ne);ie.push(se),R.duration+=se.duration;break;case"PRELOAD-HINT":var oe=new u.AttrList(F);A.preloadHint=oe;break;case"RENDITION-REPORT":var le=new u.AttrList(F);A.renditionReports=A.renditionReports||[],A.renditionReports.push(le);break;default:c.logger.warn("line parsed but not handled: "+f)}}}D&&!D.relurl?(b.pop(),C-=D.duration,A.partList&&(A.fragmentHint=D)):A.partList&&(E(R,D),R.cc=L,A.fragmentHint=R);var ue=b.length,ce=b[0],de=b[ue-1];if((C+=A.skippedSegments*A.targetduration)>0&&ue&&de){A.averagetargetduration=C/ue;var he=de.sn;A.endSN="initSegment"!==he?he:0,ce&&(A.startCC=ce.cc,ce.initSegment||A.fragments.every((function(e){return e.relurl&&(t=e.relurl,v.test(null!=(r=null===(i=n.parseURL(t))||void 0===i?void 0:i.path)?r:""));var t,r,i}))&&(c.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(R=new s.Fragment(d,t)).relurl=de.relurl,R.level=r,R.sn="initSegment",ce.initSegment=R,A.needSidxRanges=!0))}else A.endSN=0,A.startCC=0;return A.fragmentHint&&(C+=A.fragmentHint.duration),A.totalduration=C,A.endCC=L,I>0&&function(e,t){for(var r=e[t],i=t;i--;){var n=e[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(b,I),A},e}();function y(e,t){["video","audio","text"].forEach((function(r){var i=e.filter((function(e){return(0,d.isCodecType)(e,r)}));if(i.length){var n=i.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[r+"Codec"]=n.length>0?n[0]:i[0],e=e.filter((function(e){return-1===i.indexOf(e)}))}})),t.unknownCodecs=e}function A(e,t,r){var i=t[r];i&&(e[r]=i)}function E(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),(0,i.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function T(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkey=i),e.initSegment=null}},"./src/loader/playlist-loader.ts": /*!***************************************!*\ !*** ./src/loader/playlist-loader.ts ***! \***************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>f});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../events */"./src/events.ts"),a=r(/*! ../errors */"./src/errors.ts"),s=r(/*! ../utils/logger */"./src/utils/logger.ts"),o=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=r(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function d(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var h=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.unregisterListeners=function(){var e=this.hls;e.off(n.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(n.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(n.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(n.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return e.loader=n,this.loaders[e.type]=n,n},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:u.PlaylistContextType.MANIFEST,url:r,deliveryDirectives:null})},t.onLevelLoading=function(e,t){var r=t.id,i=t.level,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:null,level:i,responseType:"text",type:u.PlaylistContextType.LEVEL,url:n,deliveryDirectives:a})},t.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:u.PlaylistContextType.AUDIO_TRACK,url:n,deliveryDirectives:a})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,n=t.url,a=t.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:u.PlaylistContextType.SUBTITLE_TRACK,url:n,deliveryDirectives:a})},t.load=function(e){var t,r,i,n,a,o,l=this.hls.config,c=this.getInternalLoader(e);if(c){var d=c.context;if(d&&d.url===e.url)return void s.logger.trace("[playlist-loader]: playlist request ongoing");s.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),c.abort()}switch(e.type){case u.PlaylistContextType.MANIFEST:r=l.manifestLoadingMaxRetry,i=l.manifestLoadingTimeOut,n=l.manifestLoadingRetryDelay,a=l.manifestLoadingMaxRetryTimeout;break;case u.PlaylistContextType.LEVEL:case u.PlaylistContextType.AUDIO_TRACK:case u.PlaylistContextType.SUBTITLE_TRACK:r=0,i=l.levelLoadingTimeOut;break;default:r=l.levelLoadingMaxRetry,i=l.levelLoadingTimeOut,n=l.levelLoadingRetryDelay,a=l.levelLoadingMaxRetryTimeout}if(c=this.createInternalLoader(e),null!==(t=e.deliveryDirectives)&&void 0!==t&&t.part&&(e.type===u.PlaylistContextType.LEVEL&&null!==e.level?o=this.hls.levels[e.level].details:e.type===u.PlaylistContextType.AUDIO_TRACK&&null!==e.id?o=this.hls.audioTracks[e.id].details:e.type===u.PlaylistContextType.SUBTITLE_TRACK&&null!==e.id&&(o=this.hls.subtitleTracks[e.id].details),o)){var h=o.partTarget,f=o.targetduration;h&&f&&(i=Math.min(1e3*Math.max(3*h,.8*f),i))}var p={timeout:i,maxRetry:r,retryDelay:n,maxRetryDelay:a,highWaterMark:0},g={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(e,p,g)},t.loadsuccess=function(e,t,r,i){if(void 0===i&&(i=null),r.isSidxRequest)return this.handleSidxRequest(e,r),void this.handlePlaylistLoaded(e,t,r,i);this.resetInternalLoader(r.type);var n=e.data;0===n.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),n.indexOf("#EXTINF:")>0||n.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,t,r,i):this.handleMasterPlaylist(e,t,r,i)):this.handleManifestParsingError(e,r,"no EXTM3U delimiter",i)},t.loaderror=function(e,t,r){void 0===r&&(r=null),this.handleNetworkError(t,r,!1,e)},t.loadtimeout=function(e,t,r){void 0===r&&(r=null),this.handleNetworkError(t,r,!0)},t.handleMasterPlaylist=function(e,t,r,i){var a=this.hls,o=e.data,u=d(e,r),h=l.default.parseMasterPlaylist(o,u),f=h.levels,p=h.sessionData;if(f.length){var g=f.map((function(e){return{id:e.attrs.AUDIO,audioCodec:e.audioCodec}})),v=f.map((function(e){return{id:e.attrs.SUBTITLES,textCodec:e.textCodec}})),m=l.default.parseMasterPlaylistMedia(o,u,"AUDIO",g),y=l.default.parseMasterPlaylistMedia(o,u,"SUBTITLES",v),A=l.default.parseMasterPlaylistMedia(o,u,"CLOSED-CAPTIONS");m.length&&(m.some((function(e){return!e.url}))||!f[0].audioCodec||f[0].attrs.AUDIO||(s.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new c.AttrList({}),bitrate:0,url:""}))),a.trigger(n.Events.MANIFEST_LOADED,{levels:f,audioTracks:m,subtitles:y,captions:A,url:u,stats:t,networkDetails:i,sessionData:p})}else this.handleManifestParsingError(e,r,"no level found in manifest",i)},t.handleTrackOrLevelPlaylist=function(e,t,r,s){var o=this.hls,h=r.id,f=r.level,p=r.type,g=d(e,r),v=(0,i.isFiniteNumber)(h)?h:0,m=(0,i.isFiniteNumber)(f)?f:v,y=function(e){switch(e.type){case u.PlaylistContextType.AUDIO_TRACK:return u.PlaylistLevelType.AUDIO;case u.PlaylistContextType.SUBTITLE_TRACK:return u.PlaylistLevelType.SUBTITLE;default:return u.PlaylistLevelType.MAIN}}(r),A=l.default.parseLevelPlaylist(e.data,g,m,y,v);if(A.fragments.length){if(p===u.PlaylistContextType.MANIFEST){var E={attrs:new c.AttrList({}),bitrate:0,details:A,name:"",url:g};o.trigger(n.Events.MANIFEST_LOADED,{levels:[E],audioTracks:[],url:g,stats:t,networkDetails:s,sessionData:null})}if(t.parsing.end=performance.now(),A.needSidxRanges){var T,b=null===(T=A.fragments[0].initSegment)||void 0===T?void 0:T.url;this.load({url:b,isSidxRequest:!0,type:p,level:f,levelDetails:A,id:h,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else r.levelDetails=A,this.handlePlaylistLoaded(e,t,r,s)}else o.trigger(n.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:g,reason:"no fragments found in level",level:"number"==typeof r.level?r.level:void 0})},t.handleSidxRequest=function(e,t){var r=new Uint8Array(e.data),i=(0,o.findBox)(r,["sidx"])[0];if(i){var n=(0,o.parseSegmentIndex)(i);if(n){var a=n.references,s=t.levelDetails;a.forEach((function(e,t){var i=e.info,n=s.fragments[t];if(0===n.byteRange.length&&n.setByteRange(String(1+i.end-i.start)+"@"+String(i.start)),n.initSegment){var a=(0,o.findBox)(r,["moov"])[0],l=a?a.length:null;n.initSegment.setByteRange(String(l)+"@0")}}))}}},t.handleManifestParsingError=function(e,t,r,i){this.hls.trigger(n.Events.ERROR,{type:a.ErrorTypes.NETWORK_ERROR,details:a.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:t.type===u.PlaylistContextType.MANIFEST,url:e.url,reason:r,response:e,context:t,networkDetails:i})},t.handleNetworkError=function(e,t,r,i){void 0===r&&(r=!1),s.logger.warn("[playlist-loader]: A network "+(r?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var o=a.ErrorDetails.UNKNOWN,l=!1,c=this.getInternalLoader(e);switch(e.type){case u.PlaylistContextType.MANIFEST:o=r?a.ErrorDetails.MANIFEST_LOAD_TIMEOUT:a.ErrorDetails.MANIFEST_LOAD_ERROR,l=!0;break;case u.PlaylistContextType.LEVEL:o=r?a.ErrorDetails.LEVEL_LOAD_TIMEOUT:a.ErrorDetails.LEVEL_LOAD_ERROR,l=!1;break;case u.PlaylistContextType.AUDIO_TRACK:o=r?a.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:a.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case u.PlaylistContextType.SUBTITLE_TRACK:o=r?a.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:a.ErrorDetails.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(e.type);var d={type:a.ErrorTypes.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:c,context:e,networkDetails:t};i&&(d.response=i),this.hls.trigger(n.Events.ERROR,d)},t.handlePlaylistLoaded=function(e,t,r,i){var a=r.type,s=r.level,o=r.id,l=r.groupId,c=r.loader,d=r.levelDetails,h=r.deliveryDirectives;if(null!=d&&d.targetduration){if(c)switch(d.live&&(c.getCacheAge&&(d.ageHeader=c.getCacheAge()||0),c.getCacheAge&&!isNaN(d.ageHeader)||(d.ageHeader=0)),a){case u.PlaylistContextType.MANIFEST:case u.PlaylistContextType.LEVEL:this.hls.trigger(n.Events.LEVEL_LOADED,{details:d,level:s||0,id:o||0,stats:t,networkDetails:i,deliveryDirectives:h});break;case u.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(n.Events.AUDIO_TRACK_LOADED,{details:d,id:o||0,groupId:l||"",stats:t,networkDetails:i,deliveryDirectives:h});break;case u.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(n.Events.SUBTITLE_TRACK_LOADED,{details:d,id:o||0,groupId:l||"",stats:t,networkDetails:i,deliveryDirectives:h})}}else this.handleManifestParsingError(e,r,"invalid target duration",i)},e}();const f=h},"./src/polyfills/number.ts": /*!*********************************!*\ !*** ./src/polyfills/number.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{MAX_SAFE_INTEGER:()=>n,isFiniteNumber:()=>i});var i=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},n=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts": /*!*********************************!*\ !*** ./src/remux/aac-helper.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},e}()},"./src/remux/mp4-generator.ts": /*!************************************!*\ !*** ./src/remux/mp4-generator.ts ***! \************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var i=Math.pow(2,32)-1,n=function(){function e(){}return e.init=function(){var t;for(t in e.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var r=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]);e.HDLR_TYPES={video:r,audio:i};var n=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=a,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,s,l,s,o),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,n))},e.box=function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),n=1;n<r;n++)i[n-1]=arguments[n];for(var a=i.length,s=a;a--;)t+=i[a].byteLength;var o=new Uint8Array(t);for(o[0]=t>>24&255,o[1]=t>>16&255,o[2]=t>>8&255,o[3]=255&t,o.set(e,4),a=0,t=8;a<s;a++)o.set(i[a],t),t+=i[a].byteLength;return o},e.hdlr=function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])},e.mdat=function(t){return e.box(e.types.mdat,t)},e.mdhd=function(t,r){r*=t;var n=Math.floor(r/(i+1)),a=Math.floor(r%(i+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},e.mdia=function(t){return e.box(e.types.mdia,e.mdhd(t.timescale,t.duration),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))},e.moof=function(t,r,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var n=Math.floor(r/(i+1)),a=Math.floor(r%(i+1)),s=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,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,s)},e.sdtp=function(t){var r,i,n=t.samples||[],a=new Uint8Array(4+n.length);for(r=0;r<n.length;r++)i=n[r].flags,a[r+4]=i.dependsOn<<4|i.isDependedOn<<2|i.hasRedundancy;return e.box(e.types.sdtp,a)},e.stbl=function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))},e.avc1=function(t){var r,i,n,a=[],s=[];for(r=0;r<t.sps.length;r++)n=(i=t.sps[r]).byteLength,a.push(n>>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));for(r=0;r<t.pps.length;r++)n=(i=t.pps[r]).byteLength,s.push(n>>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));var o=e.box(e.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|t.sps.length].concat(a).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,c=t.pixelRatio[0],d=t.pixelRatio[1];return e.box(e.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))},e.esds=function(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))},e.mp4a=function(t){var r=t.samplerate;return e.box(e.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var r=t.samplerate;return e.box(e.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},e.stsd=function(t){return"audio"===t.type?"mp3"===t.segmentCodec&&"mp3"===t.codec?e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var r=t.id,n=t.duration*t.timescale,a=t.width,s=t.height,o=Math.floor(n/(i+1)),l=Math.floor(n%(i+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,l>>24,l>>16&255,l>>8&255,255&l,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,a>>8&255,255&a,0,0,s>>8&255,255&s,0,0]))},e.traf=function(t,r){var n=e.sdtp(t),a=t.id,s=Math.floor(r/(i+1)),o=Math.floor(r%(i+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,n.length+16+20+8+16+8+8),n)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var i,n,a,s,o,l,u=t.samples||[],c=u.length,d=12+16*c,h=new Uint8Array(d);for(r+=8+d,h.set(["video"===t.type?1:0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i<c;i++)a=(n=u[i]).duration,s=n.size,o=n.flags,l=n.cts,h.set([a>>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return e.box(e.types.trun,h)},e.initSegment=function(t){e.types||e.init();var r=e.moov(t),i=new Uint8Array(e.FTYP.byteLength+r.byteLength);return i.set(e.FTYP),i.set(r,e.FTYP.byteLength),i},e}();n.types=void 0,n.HDLR_TYPES=void 0,n.STTS=void 0,n.STSC=void 0,n.STCO=void 0,n.STSZ=void 0,n.VMHD=void 0,n.SMHD=void 0,n.STSD=void 0,n.FTYP=void 0,n.DINF=void 0;const a=n},"./src/remux/mp4-remuxer.ts": /*!**********************************!*\ !*** ./src/remux/mp4-remuxer.ts ***! \**********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>p,flushTextTrackMetadataCueSamples:()=>v,flushTextTrackUserdataCueSamples:()=>m,normalizePts:()=>g});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./aac-helper */"./src/remux/aac-helper.ts"),a=r(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),s=r(/*! ../events */"./src/events.ts"),o=r(/*! ../errors */"./src/errors.ts"),l=r(/*! ../utils/logger */"./src/utils/logger.ts"),u=r(/*! ../types/loader */"./src/types/loader.ts"),c=r(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},d.apply(this,arguments)}var h=null,f=null,p=function(){function e(e,t,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===h){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);h=n?parseInt(n[1]):0}if(null===f){var a=navigator.userAgent.match(/Safari\/(\d+)/i);f=a?parseInt(a[1]):0}}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){l.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e},t.resetNextTimestamp=function(){l.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},t.resetInitSegment=function(){l.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},t.getVideoStartPts=function(e){var t=!1,r=e.reduce((function(e,r){var i=r.pts-e;return i<-4294967296?(t=!0,g(e,r.pts)):i>0?e:r.pts}),e[0].pts);return t&&l.logger.debug("PTS rollover detected"),r},t.remux=function(e,t,r,i,n,a,s,o){var c,d,h,f,p,y,A=n,E=n,T=e.pid>-1,b=t.pid>-1,k=t.samples.length,S=e.samples.length>0,_=s&&k>0||k>1;if((!T||S)&&(!b||_)||this.ISGenerated||s){this.ISGenerated||(h=this.generateIS(e,t,n));var C,L=this.isVideoContiguous,D=-1;if(_&&(D=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!L&&this.config.forceKeyFrameOnDiscontinuity))if(y=!0,D>0){l.logger.warn("[mp4-remuxer]: Dropped "+D+" out of "+k+" video samples due to a missing keyframe");var R=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(D),t.dropped+=D,C=E+=(t.samples[0].pts-R)/t.inputTimeScale}else-1===D&&(l.logger.warn("[mp4-remuxer]: No keyframe found out of "+k+" video samples"),y=!1);if(this.ISGenerated){if(S&&_){var I=this.getVideoStartPts(t.samples),O=(g(e.samples[0].pts,I)-I)/t.inputTimeScale;A+=Math.max(0,O),E+=Math.max(0,-O)}if(S){if(e.samplerate||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(e,t,n)),d=this.remuxAudio(e,A,this.isAudioContiguous,a,b||_||o===u.PlaylistLevelType.AUDIO?E:void 0),_){var w=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(l.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(e,t,n)),c=this.remuxVideo(t,E,L,w)}}else _&&(c=this.remuxVideo(t,E,L,0));c&&(c.firstKeyFrame=D,c.independent=-1!==D,c.firstKeyFramePTS=C)}}return this.ISGenerated&&(r.samples.length&&(p=v(r,n,this._initPTS,this._initDTS)),i.samples.length&&(f=m(i,n,this._initPTS))),{audio:d,video:c,initSegment:h,independent:y,text:f,id3:p}},t.generateIS=function(e,t,r){var n,s,o,l=e.samples,u=t.samples,c=this.typeSupported,d={},h=!(0,i.isFiniteNumber)(this._initPTS),f="audio/mp4";if(h&&(n=s=1/0),e.config&&l.length&&(e.timescale=e.samplerate,"mp3"===e.segmentCodec&&(c.mpeg?(f="audio/mpeg",e.codec=""):c.mp3&&(e.codec="mp3")),d.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&c.mpeg?new Uint8Array(0):a.default.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(o=e.inputTimeScale,n=s=l[0].pts-Math.round(o*r))),t.sps&&t.pps&&u.length&&(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:a.default.initSegment([t]),metadata:{width:t.width,height:t.height}},h)){o=t.inputTimeScale;var p=this.getVideoStartPts(u),v=Math.round(o*r);s=Math.min(s,g(u[0].dts,p)-v),n=Math.min(n,p-v)}if(Object.keys(d).length)return this.ISGenerated=!0,h&&(this._initPTS=n,this._initDTS=s),{tracks:d,initPTS:n,timescale:o}},t.remuxVideo=function(e,t,r,i){var n,u,p=e.inputTimeScale,v=e.samples,m=[],A=v.length,E=this._initPTS,T=this.nextAvcDts,b=8,k=this.videoSampleDuration,S=Number.POSITIVE_INFINITY,_=Number.NEGATIVE_INFINITY,C=!1;r&&null!==T||(T=t*p-(v[0].pts-g(v[0].dts,v[0].pts)));for(var L=0;L<A;L++){var D=v[L];D.pts=g(D.pts-E,T),D.dts=g(D.dts-E,T),D.dts<v[L>0?L-1:L].dts&&(C=!0)}C&&v.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=v[0].dts;var R=(u=v[v.length-1].dts)-n,I=R?Math.round(R/(A-1)):k||e.inputTimeScale/30;if(r){var O=n-T,w=O>I,P=O<-1;if((w||P)&&(w?l.logger.warn("AVC: "+(0,c.toMsFromMpegTsClock)(O,!0)+" ms ("+O+"dts) hole between fragments detected, filling it"):l.logger.warn("AVC: "+(0,c.toMsFromMpegTsClock)(-O,!0)+" ms ("+O+"dts) overlapping between fragments detected"),!P||T>v[0].pts)){n=T;var x=v[0].pts-O;v[0].dts=n,v[0].pts=x,l.logger.log("Video: First PTS/DTS adjusted: "+(0,c.toMsFromMpegTsClock)(x,!0)+"/"+(0,c.toMsFromMpegTsClock)(n,!0)+", delta: "+(0,c.toMsFromMpegTsClock)(O,!0)+" ms")}}n=Math.max(0,n);for(var N=0,F=0,M=0;M<A;M++){for(var B=v[M],U=B.units,G=U.length,V=0,K=0;K<G;K++)V+=U[K].data.length;F+=V,N+=G,B.length=V,B.dts=Math.max(B.dts,n),S=Math.min(B.pts,S),_=Math.max(B.pts,_)}u=v[A-1].dts;var j,H=F+4*N+8;try{j=new Uint8Array(H)}catch(e){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:H,reason:"fail allocating video mdat "+H})}var Y=new DataView(j.buffer);Y.setUint32(0,H),j.set(a.default.types.mdat,4);for(var W=!1,$=Number.POSITIVE_INFINITY,z=Number.POSITIVE_INFINITY,q=Number.NEGATIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Z=0;Z<A;Z++){for(var Q=v[Z],J=Q.units,ee=0,te=0,re=J.length;te<re;te++){var ie=J[te],ne=ie.data,ae=ie.data.byteLength;Y.setUint32(b,ae),b+=4,j.set(ne,b),b+=ae,ee+=4+ae}var se=void 0;if(Z<A-1)k=v[Z+1].dts-Q.dts,se=v[Z+1].pts-Q.pts;else{var oe=this.config,le=Z>0?Q.dts-v[Z-1].dts:I;if(se=Z>0?Q.pts-v[Z-1].pts:I,oe.stretchShortVideoTrack&&null!==this.nextAudioPts){var ue=Math.floor(oe.maxBufferHole*p),ce=(i?S+i*p:this.nextAudioPts)-Q.pts;ce>ue?((k=ce-le)<0?k=le:W=!0,l.logger.log("[mp4-remuxer]: It is approximately "+ce/90+" ms to the next segment; using duration "+k/90+" ms for the last video frame.")):k=le}else k=le}var de=Math.round(Q.pts-Q.dts);$=Math.min($,k),q=Math.max(q,k),z=Math.min(z,se),X=Math.max(X,se),m.push(new y(Q.key,k,ee,de))}if(m.length)if(h){if(h<70){var he=m[0].flags;he.dependsOn=2,he.isNonSync=0}}else if(f&&X-z<q-$&&I/q<.025&&0===m[0].cts){l.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var fe=n,pe=0,ge=m.length;pe<ge;pe++){var ve=fe+m[pe].duration,me=fe+m[pe].cts;if(pe<ge-1){var ye=ve+m[pe+1].cts;m[pe].duration=ye-me}else m[pe].duration=pe?m[pe-1].duration:I;m[pe].cts=0,fe=ve}}console.assert(null!==k,"mp4SampleDuration must be computed"),k=W||!k?I:k,this.nextAvcDts=T=u+k,this.videoSampleDuration=k,this.isVideoContiguous=!0;var Ae={data1:a.default.moof(e.sequenceNumber++,n,d({},e,{samples:m})),data2:j,startPTS:S/p,endPTS:(_+k)/p,startDTS:n/p,endDTS:T/p,type:"video",hasAudio:!1,hasVideo:!0,nb:m.length,dropped:e.dropped};return e.samples=[],e.dropped=0,console.assert(j.length,"MDAT length must not be zero"),Ae},t.remuxAudio=function(e,t,r,i,u){var c=e.inputTimeScale,h=c/(e.samplerate?e.samplerate:c),f="aac"===e.segmentCodec?1024:1152,p=f*h,v=this._initPTS,m="mp3"===e.segmentCodec&&this.typeSupported.mpeg,A=[],E=void 0!==u,T=e.samples,b=m?0:8,k=this.nextAudioPts||-1,S=t*c;if(this.isAudioContiguous=r=r||T.length&&k>0&&(i&&Math.abs(S-k)<9e3||Math.abs(g(T[0].pts-v,S)-k)<20*p),T.forEach((function(e){e.pts=g(e.pts-v,S)})),!r||k<0){if(T=T.filter((function(e){return e.pts>=0})),!T.length)return;k=0===u?0:i&&!E?Math.max(0,S):T[0].pts}if("aac"===e.segmentCodec)for(var _=this.config.maxAudioFramesDrift,C=0,L=k;C<T.length;C++){var D=T[C],R=D.pts,I=R-L,O=Math.abs(1e3*I/c);if(I<=-_*p&&E)0===C&&(l.logger.warn("Audio frame @ "+(R/c).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*I/c)+" ms."),this.nextAudioPts=k=L=R);else if(I>=_*p&&O<1e4&&E){var w=Math.round(I/p);(L=R-w*p)<0&&(w--,L+=p),0===C&&(this.nextAudioPts=k=L),l.logger.warn("[mp4-remuxer]: Injecting "+w+" audio frame @ "+(L/c).toFixed(3)+"s due to "+Math.round(1e3*I/c)+" ms gap.");for(var P=0;P<w;P++){var x=Math.max(L,0),N=n.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);N||(l.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),N=D.unit.subarray()),T.splice(C,0,{unit:N,pts:x}),L+=p,C++}}D.pts=L,L+=p}for(var F,M=null,B=null,U=0,G=T.length;G--;)U+=T[G].unit.byteLength;for(var V=0,K=T.length;V<K;V++){var j=T[V],H=j.unit,Y=j.pts;if(null!==B)A[V-1].duration=Math.round((Y-B)/h);else{if(r&&"aac"===e.segmentCodec&&(Y=k),M=Y,!(U>0))return;U+=b;try{F=new Uint8Array(U)}catch(e){return void this.observer.emit(s.Events.ERROR,s.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:U,reason:"fail allocating audio mdat "+U})}m||(new DataView(F.buffer).setUint32(0,U),F.set(a.default.types.mdat,4))}F.set(H,b);var W=H.byteLength;b+=W,A.push(new y(!0,f,W,0)),B=Y}var $=A.length;if($){var z=A[A.length-1];this.nextAudioPts=k=B+h*z.duration;var q=m?new Uint8Array(0):a.default.moof(e.sequenceNumber++,M/h,d({},e,{samples:A}));e.samples=[];var X=M/c,Z=k/c,Q={data1:q,data2:F,startPTS:X,endPTS:Z,startDTS:X,endDTS:Z,type:"audio",hasAudio:!0,hasVideo:!1,nb:$};return this.isAudioContiguous=!0,console.assert(F.length,"MDAT length must not be zero"),Q}},t.remuxEmptyAudio=function(e,t,r,i){var a=e.inputTimeScale,s=a/(e.samplerate?e.samplerate:a),o=this.nextAudioPts,u=(null!==o?o:i.startDTS*a)+this._initDTS,c=i.endDTS*a+this._initDTS,d=1024*s,h=Math.ceil((c-u)/d),f=n.default.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(l.logger.warn("[mp4-remuxer]: remux empty Audio"),f){for(var p=[],g=0;g<h;g++){var v=u+g*d;p.push({unit:f,pts:v,dts:v})}return e.samples=p,this.remuxAudio(e,t,r,!1)}l.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},e}();function g(e,t){var r;if(null===t)return e;for(r=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=r;return e}function v(e,t,r,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,s=0;s<n;s++){var o=e.samples[s];o.pts=g(o.pts-r,t*a)/a,o.dts=g(o.dts-i,t*a)/a}var l=e.samples;return e.samples=[],{samples:l}}}function m(e,t,r){var i=e.samples.length;if(i){for(var n=e.inputTimeScale,a=0;a<i;a++){var s=e.samples[a];s.pts=g(s.pts-r,t*n)/n}e.samples.sort((function(e,t){return e.pts-t.pts}));var o=e.samples;return e.samples=[],{samples:o}}}var y=function(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags=new A(e)},A=function(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}},"./src/remux/passthrough-remuxer.ts": /*!******************************************!*\ !*** ./src/remux/passthrough-remuxer.ts ***! \******************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>u});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./mp4-remuxer */"./src/remux/mp4-remuxer.ts"),a=r(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),s=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),o=r(/*! ../utils/logger */"./src/utils/logger.ts");function l(e,t){var r=null==e?void 0:e.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.c.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||t===s.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}const u=function(){function e(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this.initPTS=e,this.lastEndTime=null},t.resetNextTimestamp=function(){this.lastEndTime=null},t.resetInitSegment=function(e,t,r){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(e),this.emitInitSegment=!0},t.generateInitSegment=function(e){var t=this.audioCodec,r=this.videoCodec;if(!e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=(0,a.parseInitSegment)(e);t||(t=l(i.audio,s.ElementaryStreamTypes.AUDIO)),r||(r=l(i.video,s.ElementaryStreamTypes.VIDEO));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:o.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},t.remux=function(e,t,r,s,l){var u,c=this.initPTS,d=this.lastEndTime,h={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};(0,i.isFiniteNumber)(d)||(d=this.lastEndTime=l||0);var f=t.samples;if(!f||!f.length)return h;var p={initPTS:void 0,timescale:1},g=this.initData;if(g&&g.length||(this.generateInitSegment(f),g=this.initData),!g||!g.length)return o.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1);var v=(0,a.getStartDTS)(g,f);(0,i.isFiniteNumber)(c)||(this.initPTS=p.initPTS=c=v-l);var m=(0,a.getDuration)(f,g),y=e?v-c:d,A=y+m;(0,a.offsetStartDTS)(g,f,c),m>0?this.lastEndTime=A:(o.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var E=!!g.audio,T=!!g.video,b="";E&&(b+="audio"),T&&(b+="video");var k={data1:f,startPTS:y,startDTS:y,endPTS:A,endDTS:A,type:b,hasAudio:E,hasVideo:T,nb:1,dropped:0};h.audio="audio"===k.type?k:void 0,h.video="audio"!==k.type?k:void 0,h.initSegment=p;var S=null!=(u=this.initPTS)?u:0;return h.id3=(0,n.flushTextTrackMetadataCueSamples)(r,l,S,S),s.samples.length&&(h.text=(0,n.flushTextTrackUserdataCueSamples)(s,l,S)),h},e}()},"./src/task-loop.ts": /*!**************************!*\ !*** ./src/task-loop.ts ***! \**************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var t=e.prototype;return t.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},t.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},t.onHandlerDestroyed=function(){},t.hasInterval=function(){return!!this._tickInterval},t.hasNextTick=function(){return!!this._tickTimer},t.setInterval=function(e){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,e),!0)},t.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},t.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},t.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},t.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},t.doTick=function(){},e}()},"./src/types/cmcd.ts": /*!***************************!*\ !*** ./src/types/cmcd.ts ***! \***************************/(e,t,r)=>{r.r(t),r.d(t,{CMCDObjectType:()=>i,CMCDStreamType:()=>a,CMCDStreamingFormat:()=>n,CMCDVersion:()=>s});var i,n,a,s=1;!function(e){e.MANIFEST="m",e.AUDIO="a",e.VIDEO="v",e.MUXED="av",e.INIT="i",e.CAPTION="c",e.TIMED_TEXT="tt",e.KEY="k",e.OTHER="o"}(i||(i={})),function(e){e.DASH="d",e.HLS="h",e.SMOOTH="s",e.OTHER="o"}(n||(n={})),function(e){e.VOD="v",e.LIVE="l"}(a||(a={}))},"./src/types/demuxer.ts": /*!******************************!*\ !*** ./src/types/demuxer.ts ***! \******************************/(e,t,r)=>{var i;r.r(t),r.d(t,{MetadataSchema:()=>i}),function(e){e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3"}(i||(i={}))},"./src/types/level.ts": /*!****************************!*\ !*** ./src/types/level.ts ***! \****************************/(e,t,r)=>{function i(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var n;function a(e,t){var r=e.canSkipUntil,i=e.canSkipDateRanges,a=e.endSN;return r&&(void 0!==t?t-a:0)<r?i?n.v2:n.Yes:n.No}r.r(t),r.d(t,{HlsSkip:()=>n,HlsUrlParameters:()=>s,Level:()=>o,getSkipValue:()=>a}),function(e){e.No="",e.Yes="YES",e.v2="v2"}(n||(n={}));var s=function(){function e(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}return e.prototype.addDirectives=function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.toString()},e}(),o=function(){function e(e){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this.attrs=e.attrs,this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter((function(e){return e})).join(",").replace(/\.[^.,]+/g,"")}var t,r,n;return t=e,(r=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(e){var t=e%this.url.length;this._urlId!==t&&(this.details=void 0,this._urlId=t)}}])&&i(t.prototype,r),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),e}()},"./src/types/loader.ts": /*!*****************************!*\ !*** ./src/types/loader.ts ***! \*****************************/(e,t,r)=>{var i,n;r.r(t),r.d(t,{PlaylistContextType:()=>i,PlaylistLevelType:()=>n}),function(e){e.MANIFEST="manifest",e.LEVEL="level",e.AUDIO_TRACK="audioTrack",e.SUBTITLE_TRACK="subtitleTrack"}(i||(i={})),function(e){e.MAIN="main",e.AUDIO="audio",e.SUBTITLE="subtitle"}(n||(n={}))},"./src/types/transmuxer.ts": /*!*********************************!*\ !*** ./src/types/transmuxer.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{ChunkMetadata:()=>i});var i=function(e,t,r,i,n,a){void 0===i&&(i=0),void 0===n&&(n=-1),void 0===a&&(a=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=n,this.partial=a}},"./src/utils/attr-list.ts": /*!********************************!*\ !*** ./src/utils/attr-list.ts ***! \********************************/(e,t,r)=>{r.r(t),r.d(t,{AttrList:()=>a});var i=/^(\d+)x(\d+)$/,n=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,a=function(){function e(t){for(var r in"string"==typeof t&&(t=e.parseAttrList(t)),t)t.hasOwnProperty(r)&&(this[r]=t[r])}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;i<t.length/2;i++)r[i]=parseInt(t.slice(2*i,2*i+2),16);return r}return null},t.hexadecimalIntegerAsNumber=function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=i.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,r={};for(n.lastIndex=0;null!==(t=n.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[t[1]]=i}return r},e}()},"./src/utils/binary-search.ts": /*!************************************!*\ !*** ./src/utils/binary-search.ts ***! \************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i={search:function(e,t){for(var r=0,i=e.length-1,n=null,a=null;r<=i;){var s=t(a=e[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null}}},"./src/utils/buffer-helper.ts": /*!************************************!*\ !*** ./src/utils/buffer-helper.ts ***! \************************************/(e,t,r)=>{r.r(t),r.d(t,{BufferHelper:()=>a});var i=r(/*! ./logger */"./src/utils/logger.ts"),n={length:0,start:function(){return 0},end:function(){return 0}},a=function(){function e(){}return e.isBuffered=function(t,r){try{if(t)for(var i=e.getBuffered(t),n=0;n<i.length;n++)if(r>=i.start(n)&&r<=i.end(n))return!0}catch(e){}return!1},e.bufferInfo=function(t,r,i){try{if(t){var n,a=e.getBuffered(t),s=[];for(n=0;n<a.length;n++)s.push({start:a.start(n),end:a.end(n)});return this.bufferedInfo(s,r,i)}}catch(e){}return{len:0,start:r,end:r,nextStart:void 0}},e.bufferedInfo=function(e,t,r){t=Math.max(0,t),e.sort((function(e,t){var r=e.start-t.start;return r||t.end-e.end}));var i=[];if(r)for(var n=0;n<e.length;n++){var a=i.length;if(a){var s=i[a-1].end;e[n].start-s<r?e[n].end>s&&(i[a-1].end=e[n].end):i.push(e[n])}else i.push(e[n])}else i=e;for(var o,l=0,u=t,c=t,d=0;d<i.length;d++){var h=i[d].start,f=i[d].end;if(t+r>=h&&t<f)u=h,l=(c=f)-t;else if(t+r<h){o=h;break}}return{len:l,start:u||0,end:c||0,nextStart:o}},e.getBuffered=function(e){try{return e.buffered}catch(e){return i.logger.log("failed to get media.buffered",e),n}},e}()},"./src/utils/cea-608-parser.ts": /*!*************************************!*\ !*** ./src/utils/cea-608-parser.ts ***! \*************************************/(e,t,r)=>{r.r(t),r.d(t,{CaptionScreen:()=>A,Row:()=>y,default:()=>S});var i,n=r(/*! ../utils/logger */"./src/utils/logger.ts"),a={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},s=function(e){var t=e;return a.hasOwnProperty(e)&&(t=a[e]),String.fromCharCode(t)},o=15,l=100,u={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},c={17:2,18:4,21:6,22:8,23:10,19:13,20:15},d={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},h={25:2,26:4,29:6,30:8,31:10,27:13,28:15},f=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(e){e[e.ERROR=0]="ERROR",e[e.TEXT=1]="TEXT",e[e.WARNING=2]="WARNING",e[e.INFO=2]="INFO",e[e.DEBUG=3]="DEBUG",e[e.DATA=3]="DATA"}(i||(i={}));var p=function(){function e(){this.time=null,this.verboseLevel=i.ERROR}return e.prototype.log=function(e,t){this.verboseLevel>=e&&n.logger.log(this.time+" ["+e+"] "+t)},e}(),g=function(e){for(var t=[],r=0;r<e.length;r++)t.push(e[r].toString(16));return t},v=function(){function e(e,t,r,i,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=r||!1,this.background=i||"black",this.flash=n||!1}var t=e.prototype;return t.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},t.setStyles=function(e){for(var t=["foreground","underline","italics","background","flash"],r=0;r<t.length;r++){var i=t[r];e.hasOwnProperty(i)&&(this[i]=e[i])}},t.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},t.equals=function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash},t.copy=function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash},t.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},e}(),m=function(){function e(e,t,r,i,n,a){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new v(t,r,i,n,a)}var t=e.prototype;return t.reset=function(){this.uchar=" ",this.penState.reset()},t.setChar=function(e,t){this.uchar=e,this.penState.copy(t)},t.setPenState=function(e){this.penState.copy(e)},t.equals=function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)},t.copy=function(e){this.uchar=e.uchar,this.penState.copy(e.penState)},t.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},e}(),y=function(){function e(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var t=0;t<l;t++)this.chars.push(new m);this.logger=e,this.pos=0,this.currPenState=new v}var t=e.prototype;return t.equals=function(e){for(var t=!0,r=0;r<l;r++)if(!this.chars[r].equals(e.chars[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<l;t++)this.chars[t].copy(e.chars[t])},t.isEmpty=function(){for(var e=!0,t=0;t<l;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e},t.setCursor=function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(i.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>l&&(this.logger.log(i.DEBUG,"Too large cursor position "+this.pos),this.pos=l)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)},t.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},t.insertChar=function(e){e>=144&&this.backSpace();var t=s(e);this.pos>=l?this.logger.log(i.ERROR,"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))},t.clearFromPos=function(e){var t;for(t=e;t<l;t++)this.chars[t].reset()},t.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},t.clearToEndOfRow=function(){this.clearFromPos(this.pos)},t.getTextString=function(){for(var e=[],t=!0,r=0;r<l;r++){var i=this.chars[r].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")},t.setPenStyles=function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)},e}(),A=function(){function e(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var t=0;t<o;t++)this.rows.push(new y(e));this.logger=e,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var t=e.prototype;return t.reset=function(){for(var e=0;e<o;e++)this.rows[e].clear();this.currRow=14},t.equals=function(e){for(var t=!0,r=0;r<o;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<o;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<o;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e},t.backSpace=function(){this.rows[this.currRow].backSpace()},t.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},t.insertChar=function(e){this.rows[this.currRow].insertChar(e)},t.setPen=function(e){this.rows[this.currRow].setPenStyles(e)},t.moveCursor=function(e){this.rows[this.currRow].moveCursor(e)},t.setCursor=function(e){this.logger.log(i.INFO,"setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){this.logger.log(i.INFO,"pacData = "+JSON.stringify(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var r=0;r<o;r++)this.rows[r].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var s=a.rows[n].cueStartTime,l=this.logger.time;if(s&&null!==l&&s<l)for(var u=0;u<this.nrRollUpRows;u++)this.rows[t-this.nrRollUpRows+u+1].copy(a.rows[n+u])}}this.currRow=t;var c=this.rows[this.currRow];if(null!==e.indent){var d=e.indent,h=Math.max(d-1,0);c.setCursor(e.indent),e.color=c.chars[h].penState.foreground}var f={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(f)},t.setBkgData=function(e){this.logger.log(i.INFO,"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)},t.setRollUpRows=function(e){this.nrRollUpRows=e},t.rollUp=function(){if(null!==this.nrRollUpRows){this.logger.log(i.TEXT,this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(i.INFO,"Rolling up")}else this.logger.log(i.DEBUG,"roll_up but nrRollUpRows not set yet")},t.getDisplayText=function(e){e=e||!1;for(var t=[],r="",i=-1,n=0;n<o;n++){var a=this.rows[n].getTextString();a&&(i=n+1,e?t.push("Row "+i+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r},t.getTextAndFormat=function(){return this.rows},e}(),E=function(){function e(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new A(r),this.nonDisplayedMemory=new A(r),this.lastOutputScreen=new A(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},t.getHandler=function(){return this.outputFilter},t.setHandler=function(e){this.outputFilter=e},t.setPAC=function(e){this.writeScreen.setPAC(e)},t.setBkgData=function(e){this.writeScreen.setBkgData(e)},t.setMode=function(e){e!==this.mode&&(this.mode=e,this.logger.log(i.INFO,"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)},t.insertChars=function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var r=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(i.INFO,r+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(i.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},t.ccRCL=function(){this.logger.log(i.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},t.ccBS=function(){this.logger.log(i.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},t.ccAOF=function(){},t.ccAON=function(){},t.ccDER=function(){this.logger.log(i.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},t.ccRU=function(e){this.logger.log(i.INFO,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)},t.ccFON=function(){this.logger.log(i.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},t.ccRDC=function(){this.logger.log(i.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},t.ccTR=function(){this.logger.log(i.INFO,"TR"),this.setMode("MODE_TEXT")},t.ccRTD=function(){this.logger.log(i.INFO,"RTD"),this.setMode("MODE_TEXT")},t.ccEDM=function(){this.logger.log(i.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},t.ccCR=function(){this.logger.log(i.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},t.ccENM=function(){this.logger.log(i.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},t.ccEOC=function(){if(this.logger.log(i.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(i.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},t.ccTO=function(e){this.logger.log(i.INFO,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)},t.ccMIDROW=function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var r=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(i.INFO,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))},t.cueSplitAtTime=function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))},e}(),T=function(){function e(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new p;this.channels=[null,new E(e,t,i),new E(e+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}var t=e.prototype;return t.getHandler=function(e){return this.channels[e].getHandler()},t.setHandler=function(e,t){this.channels[e].setHandler(t)},t.addData=function(e,t){var r,n,a,s=!1;this.logger.time=e;for(var o=0;o<t.length;o+=2)if(n=127&t[o],a=127&t[o+1],0!==n||0!==a){if(this.logger.log(i.DATA,"["+g([t[o],t[o+1]])+"] -> ("+g([n,a])+")"),(r=this.parseCmd(n,a))||(r=this.parseMidrow(n,a)),r||(r=this.parsePAC(n,a)),r||(r=this.parseBackgroundAttributes(n,a)),!r&&(s=this.parseChars(n,a))){var l=this.currentChannel;l&&l>0?this.channels[l].insertChars(s):this.logger.log(i.WARNING,"No channel found yet. TEXT-MODE?")}r||s||this.logger.log(i.WARNING,"Couldn't parse cleaned data "+g([n,a])+" orig: "+g([t[o],t[o+1]]))}},t.parseCmd=function(e,t){var r=this.cmdHistory;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;if(k(e,t,r))return b(null,null,r),this.logger.log(i.DEBUG,"Repeated command ("+g([e,t])+") is dropped"),!0;var n=20===e||21===e||23===e?1:2,a=this.channels[n];return 20===e||21===e||28===e||29===e?32===t?a.ccRCL():33===t?a.ccBS():34===t?a.ccAOF():35===t?a.ccAON():36===t?a.ccDER():37===t?a.ccRU(2):38===t?a.ccRU(3):39===t?a.ccRU(4):40===t?a.ccFON():41===t?a.ccRDC():42===t?a.ccTR():43===t?a.ccRTD():44===t?a.ccEDM():45===t?a.ccCR():46===t?a.ccENM():47===t&&a.ccEOC():a.ccTO(t-32),b(e,t,r),this.currentChannel=n,!0},t.parseMidrow=function(e,t){var r=0;if((17===e||25===e)&&t>=32&&t<=47){if((r=17===e?1:2)!==this.currentChannel)return this.logger.log(i.ERROR,"Mismatch channel in midrow parsing"),!1;var n=this.channels[r];return!!n&&(n.ccMIDROW(t),this.logger.log(i.DEBUG,"MIDROW ("+g([e,t])+")"),!0)}return!1},t.parsePAC=function(e,t){var r,i=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;if(k(e,t,i))return b(null,null,i),!0;var n=e<=23?1:2;r=t>=64&&t<=95?1===n?u[e]:d[e]:1===n?c[e]:h[e];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(r,t)),b(e,t,i),this.currentChannel=n,!0)},t.interpretPAC=function(e,t){var r,i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},t.parseChars=function(e,t){var r,n,a=null,o=null;if(e>=25?(r=2,o=e-8):(r=1,o=e),o>=17&&o<=19?(n=17===o?t+80:18===o?t+112:t+144,this.logger.log(i.INFO,"Special char '"+s(n)+"' in channel "+r),a=[n]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]),a){var l=g(a);this.logger.log(i.DEBUG,"Char codes = "+l.join(",")),b(e,t,this.cmdHistory)}return a},t.parseBackgroundAttributes=function(e,t){var r;if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;var i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=f[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));var n=e<=23?1:2;return this.channels[n].setBkgData(i),b(e,t,this.cmdHistory),!0},t.reset=function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}this.cmdHistory={a:null,b:null}},t.cueSplitAtTime=function(e){for(var t=0;t<this.channels.length;t++){var r=this.channels[t];r&&r.cueSplitAtTime(e)}},e}();function b(e,t,r){r.a=e,r.b=t}function k(e,t,r){return r.a===e&&r.b===t}const S=T},"./src/utils/codecs.ts": /*!*****************************!*\ !*** ./src/utils/codecs.ts ***! \*****************************/(e,t,r)=>{r.r(t),r.d(t,{isCodecSupportedInMp4:()=>a,isCodecType:()=>n});var i={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function n(e,t){var r=i[t];return!!r&&!0===r[e.slice(0,4)]}function a(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}},"./src/utils/cues.ts": /*!***************************!*\ !*** ./src/utils/cues.ts ***! \***************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>o});var i=r(/*! ./vttparser */"./src/utils/vttparser.ts"),n=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),a=r(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),s=/\s/;const o={newCue:function(e,t,r,o){for(var l,u,c,d,h,f=[],p=self.VTTCue||self.TextTrackCue,g=0;g<o.rows.length;g++)if(c=!0,d=0,h="",!(l=o.rows[g]).isEmpty()){for(var v=0;v<l.chars.length;v++)s.test(l.chars[v].uchar)&&c?d++:(h+=l.chars[v].uchar,c=!1);l.cueStartTime=t,t===r&&(r+=1e-4),d>=16?d--:d++;var m=(0,i.fixLineBreaks)(h.trim()),y=(0,n.generateCueId)(t,r,m);e&&e.cues&&e.cues.getCueById(y)||((u=new p(t,r,m)).id=y,u.line=g+1,u.align="left",u.position=10+Math.min(80,10*Math.floor(8*d/32)),f.push(u))}return e&&f.length&&(f.sort((function(e,t){return"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line})),f.forEach((function(t){return(0,a.addCueToTrack)(e,t)}))),f}}},"./src/utils/discontinuities.ts": /*!**************************************!*\ !*** ./src/utils/discontinuities.ts ***! \**************************************/(e,t,r)=>{r.r(t),r.d(t,{adjustSlidingStart:()=>c,alignMediaPlaylistByPDT:()=>f,alignPDT:()=>h,alignStream:()=>d,findDiscontinuousReferenceFrag:()=>l,findFirstFragWithCC:()=>s,shouldAlignOnDiscontinuities:()=>o});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./logger */"./src/utils/logger.ts"),a=r(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function s(e,t){for(var r=null,i=0,n=e.length;i<n;i++){var a=e[i];if(a&&a.cc===t){r=a;break}}return r}function o(e,t,r){return!(!t.details||!(r.endCC>r.startCC||e&&e.cc<r.startCC))}function l(e,t,r){var i=e.fragments,a=t.fragments;if(a.length&&i.length){var o=s(i,a[0].cc);if(o&&(!o||o.startPTS))return o;n.logger.log("No frag in previous level to align on")}else n.logger.log("No fragments to align")}function u(e,t){if(e){var r=e.start+t;e.start=e.startPTS=r,e.endPTS=r+e.duration}}function c(e,t){for(var r=t.fragments,i=0,n=r.length;i<n;i++)u(r[i],e);t.fragmentHint&&u(t.fragmentHint,e),t.alignedSliding=!0}function d(e,t,r){t&&(function(e,t,r){if(o(e,r,t)){var a=l(r.details,t);a&&(0,i.isFiniteNumber)(a.start)&&(n.logger.log("Adjusting PTS using last level due to CC increase within current level "+t.url),c(a.start,t))}}(e,r,t),!r.alignedSliding&&t.details&&h(r,t.details),r.alignedSliding||!t.details||r.skippedSegments||(0,a.adjustSliding)(t.details,r))}function h(e,t){if(t.fragments.length&&e.hasProgramDateTime&&t.hasProgramDateTime){var r=t.fragments[0].programDateTime,a=e.fragments[0].programDateTime,s=(a-r)/1e3+t.fragments[0].start;s&&(0,i.isFiniteNumber)(s)&&(n.logger.log("Adjusting PTS using programDateTime delta "+(a-r)+"ms, sliding:"+s.toFixed(3)+" "+e.url+" "),c(s,e))}}function f(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var r=e.fragments,i=t.fragments;if(r.length&&i.length){var n=i[Math.round(i.length/2)-1],a=s(r,n.cc)||r[Math.round(r.length/2)-1],o=n.programDateTime,l=a.programDateTime;null!==o&&null!==l&&c((l-o)/1e3-(a.start-n.start),e)}}}},"./src/utils/ewma-bandwidth-estimator.ts": /*!***********************************************!*\ !*** ./src/utils/ewma-bandwidth-estimator.ts ***! \***********************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var i=r(/*! ../utils/ewma */"./src/utils/ewma.ts");const n=function(){function e(e,t,r){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new i.default(e),this.fast_=new i.default(t)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,n=this.fast_;this.slow_.halfLife!==e&&(this.slow_=new i.default(e,r.getEstimate(),r.getTotalWeight())),this.fast_.halfLife!==t&&(this.fast_=new i.default(t,n.getEstimate(),n.getTotalWeight()))},t.sample=function(e,t){var r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},t.canEstimate=function(){var e=this.fast_;return e&&e.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}()},"./src/utils/ewma.ts": /*!***************************!*\ !*** ./src/utils/ewma.ts ***! \***************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}()},"./src/utils/fetch-loader.ts": /*!***********************************!*\ !*** ./src/utils/fetch-loader.ts ***! \***********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>v,fetchSupported:()=>h});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),a=r(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function s(e){var t="function"==typeof Map?new Map:void 0;return s=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,i)}function i(){return o(e,arguments,c(this).constructor)}return i.prototype=Object.create(e.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),u(i,e)},s(e)}function o(e,t,r){return o=l()?Reflect.construct.bind():function(e,t,r){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return r&&u(n,r.prototype),n},o.apply(null,arguments)}function l(){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(e){return!1}}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},d.apply(this,arguments)}function h(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}var f=function(){function e(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||p,this.controller=new self.AbortController,this.stats=new n.LoadStats}var t=e.prototype;return t.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},t.abortInternal=function(){var e=this.response;e&&e.ok||(this.stats.aborted=!0,this.controller.abort())},t.abort=function(){var e;this.abortInternal(),null!==(e=this.callbacks)&&void 0!==e&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},t.load=function(e,t,r){var n=this,a=this.stats;if(a.loading.start)throw new Error("Loader can only be used once.");a.loading.start=self.performance.now();var s=function(e,t){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(d({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),o=r.onProgress,l="arraybuffer"===e.responseType,u=l?"byteLength":"length";this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,s),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){n.abortInternal(),r.onTimeout(a,e,n.response)}),t.timeout),self.fetch(this.request).then((function(r){if(n.response=n.loader=r,!r.ok){var s=r.status,u=r.statusText;throw new g(u||"fetch, bad network response",s,r)}return a.loading.first=Math.max(self.performance.now(),a.loading.start),a.total=parseInt(r.headers.get("Content-Length")||"0"),o&&(0,i.isFiniteNumber)(t.highWaterMark)?n.loadProgressively(r,a,e,t.highWaterMark,o):l?r.arrayBuffer():r.text()})).then((function(s){var l=n.response;self.clearTimeout(n.requestTimeout),a.loading.end=Math.max(self.performance.now(),a.loading.first);var c=s[u];c&&(a.loaded=a.total=c);var d={url:l.url,data:s};o&&!(0,i.isFiniteNumber)(t.highWaterMark)&&o(a,e,s,l),r.onSuccess(d,a,e,l)})).catch((function(t){if(self.clearTimeout(n.requestTimeout),!a.aborted){var i=t&&t.code||0,s=t?t.message:null;r.onError({code:i,text:s},e,t?t.details:null)}}))},t.getCacheAge=function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e},t.loadProgressively=function(e,t,r,i,n){void 0===i&&(i=0);var s=new a.default,o=e.body.getReader();return function a(){return o.read().then((function(o){if(o.done)return s.dataLength&&n(t,r,s.flush(),e),Promise.resolve(new ArrayBuffer(0));var l=o.value,u=l.length;return t.loaded+=u,u<i||s.dataLength?(s.push(l),s.dataLength>=i&&n(t,r,s.flush(),e)):n(t,r,l,e),a()})).catch((function(){return Promise.reject()}))}()},e}();function p(e,t){return new self.Request(e.url,t)}var g=function(e){var t,r;function i(t,r,i){var n;return(n=e.call(this,t)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return r=e,(t=i).prototype=Object.create(r.prototype),t.prototype.constructor=t,u(t,r),i}(s(Error));const v=f},"./src/utils/imsc1-ttml-parser.ts": /*!****************************************!*\ !*** ./src/utils/imsc1-ttml-parser.ts ***! \****************************************/(e,t,r)=>{r.r(t),r.d(t,{IMSC1_CODEC:()=>c,parseIMSC1:()=>p});var i=r(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),a=r(/*! ./vttcue */"./src/utils/vttcue.ts"),s=r(/*! ../demux/id3 */"./src/demux/id3.ts"),o=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),l=r(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},u.apply(this,arguments)}var c="stpp.ttml.im1t",d=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,h=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,f={left:"start",center:"center",right:"end",start:"start",end:"end"};function p(e,t,r,n,c){var d=(0,i.findBox)(new Uint8Array(e),["mdat"]);if(0!==d.length){var h=d.map((function(e){return(0,s.utf8ArrayToStr)(e)})),p=(0,o.toTimescaleFromScale)(t,1,r);try{h.forEach((function(e){return n(function(e,t){var r=(new DOMParser).parseFromString(e,"text/xml"),i=r.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");var n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(n).reduce((function(e,t){return e[t]=i.getAttribute("ttp:"+t)||n[t],e}),{}),o="preserve"!==i.getAttribute("xml:space"),c=v(g(i,"styling","style")),d=v(g(i,"layout","region")),h=g(i,"body","[begin]");return[].map.call(h,(function(e){var r=m(e,o);if(!r||!e.hasAttribute("begin"))return null;var i=E(e.getAttribute("begin"),s),n=E(e.getAttribute("dur"),s),h=E(e.getAttribute("end"),s);if(null===i)throw A(e);if(null===h){if(null===n)throw A(e);h=i+n}var p=new a.default(i-t,h-t,r);p.id=(0,l.generateCueId)(p.startTime,p.endTime,p.text);var g=d[e.getAttribute("region")],v=c[e.getAttribute("style")];p.position=10,p.size=80;var T=function(e,t,r){var i="http://www.w3.org/ns/ttml#styling",n=null,a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return s&&r.hasOwnProperty(s)&&(n=r[s]),a.reduce((function(r,a){var s=y(t,i,a)||y(e,i,a)||y(n,i,a);return s&&(r[a]=s),r}),{})}(g,v,c),b=T.textAlign;if(b){var k=f[b];k&&(p.lineAlign=k),p.align=b}return u(p,T),p})).filter((function(e){return null!==e}))}(e,p))}))}catch(e){c(e)}}else c(new Error("Could not parse IMSC1 mdat"))}function g(e,t,r){var i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function v(e){return e.reduce((function(e,t){var r=t.getAttribute("xml:id");return r&&(e[r]=t),e}),{})}function m(e,t){return[].slice.call(e.childNodes).reduce((function(e,r,i){var n;return"br"===r.nodeName&&i?e+"\n":null!==(n=r.childNodes)&&void 0!==n&&n.length?m(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent}),"")}function y(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function A(e){return new Error("Could not parse ttml timestamp "+e)}function E(e,t){if(!e)return null;var r=(0,n.parseTimeStamp)(e);return null===r&&(d.test(e)?r=function(e,t){var r=d.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):h.test(e)&&(r=function(e,t){var r=h.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}},"./src/utils/logger.ts": /*!*****************************!*\ !*** ./src/utils/logger.ts ***! \*****************************/(e,t,r)=>{r.r(t),r.d(t,{enableLogs:()=>o,logger:()=>l});var i=function(){},n={trace:i,debug:i,log:i,warn:i,info:i,error:i},a=n;function s(e){var t=self.console[e];return t?t.bind(self.console,"["+e+"] >"):i}function o(e,t){if(self.console&&!0===e||"object"==typeof e){!function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];r.forEach((function(t){a[t]=e[t]?e[t].bind(e):s(t)}))}(e,"debug","log","info","warn","error");try{a.log('Debug logs enabled for "'+t+'"')}catch(e){a=n}}else a=n}var l=n},"./src/utils/mediakeys-helper.ts": /*!***************************************!*\ !*** ./src/utils/mediakeys-helper.ts ***! \***************************************/(e,t,r)=>{var i;r.r(t),r.d(t,{KeySystems:()=>i,requestMediaKeySystemAccess:()=>n}),function(e){e.WIDEVINE="com.widevine.alpha",e.PLAYREADY="com.microsoft.playready"}(i||(i={}));var n="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts": /*!*****************************************!*\ !*** ./src/utils/mediasource-helper.ts ***! \*****************************************/(e,t,r)=>{function i(){return self.MediaSource||self.WebKitMediaSource}r.r(t),r.d(t,{getMediaSource:()=>i})},"./src/utils/mp4-tools.ts": /*!********************************!*\ !*** ./src/utils/mp4-tools.ts ***! \********************************/(e,t,r)=>{r.r(t),r.d(t,{RemuxerTrackIdConfig:()=>l,appendUint8Array:()=>b,bin2str:()=>u,computeRawDurationFromSamples:()=>A,discardEPB:()=>C,findBox:()=>p,getDuration:()=>y,getStartDTS:()=>m,offsetStartDTS:()=>E,parseEmsg:()=>L,parseInitSegment:()=>v,parseSEIMessageFromNALu:()=>_,parseSamples:()=>k,parseSegmentIndex:()=>g,readSint32:()=>h,readUint16:()=>c,readUint32:()=>d,segmentValidRange:()=>T,writeUint32:()=>f});var i=r(/*! ./typed-array */"./src/utils/typed-array.ts"),n=r(/*! ../loader/fragment */"./src/loader/fragment.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=Math.pow(2,32)-1,o=[].push,l={video:1,audio:2,id3:3,text:4};function u(e){return String.fromCharCode.apply(null,e)}function c(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function d(e,t){var r=h(e,t);return r<0?4294967296+r:r}function h(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function f(e,t,r){e[t]=r>>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function p(e,t){var r=[];if(!t.length)return r;for(var i=e.byteLength,n=0;n<i;){var a=d(e,n),s=a>1?n+a:i;if(u(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,s));else{var l=p(e.subarray(n+8,s),t.slice(1));l.length&&o.apply(r,l)}n=s}return r}function g(e){var t=[],r=e[0],i=8,n=d(e,i);i+=4,i+=0===r?8:16,i+=2;var a=e.length+0,s=c(e,i);i+=2;for(var o=0;o<s;o++){var l=i,u=d(e,l);l+=4;var h=2147483647&u;if(1==(2147483648&u)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var f=d(e,l);l+=4,t.push({referenceSize:h,subsegmentDuration:f,info:{duration:f/n,start:a,end:a+h-1}}),a+=h,i=l+=4}return{earliestPresentationTime:0,timescale:n,version:r,referencesCount:s,references:t}}function v(e){for(var t=[],r=p(e,["moov","trak"]),i=0;i<r.length;i++){var a=r[i],s=p(a,["tkhd"])[0];if(s){var o=s[0],l=0===o?12:20,c=d(s,l),h=p(a,["mdia","mdhd"])[0];if(h){var f=d(h,l=0===(o=h[0])?12:20),g=p(a,["mdia","hdlr"])[0];if(g){var v=u(g.subarray(8,12)),m={soun:n.ElementaryStreamTypes.AUDIO,vide:n.ElementaryStreamTypes.VIDEO}[v];if(m){var y=p(a,["mdia","minf","stbl","stsd"])[0],A=void 0;y&&(A=u(y.subarray(12,16))),t[c]={timescale:f,type:m},t[m]={timescale:f,id:c,codec:A}}}}}}return p(e,["moov","mvex","trex"]).forEach((function(e){var r=d(e,4),i=t[r];i&&(i.default={duration:d(e,12),flags:d(e,20)})})),t}function m(e,t){return p(t,["moof","traf"]).reduce((function(t,r){var i=p(r,["tfdt"])[0],n=i[0],a=p(r,["tfhd"]).reduce((function(t,r){var a=d(r,4),s=e[a];if(s){var o=d(i,4);1===n&&(o*=Math.pow(2,32),o+=d(i,8));var l=o/(s.timescale||9e4);if(isFinite(l)&&(null===t||l<t))return l}return t}),null);return null!==a&&isFinite(a)&&(null===t||a<t)?a:t}),null)||0}function y(e,t){for(var r=0,i=0,a=0,s=p(e,["moof","traf"]),o=0;o<s.length;o++){var l=s[o],u=p(l,["tfhd"])[0],c=t[d(u,4)];if(c){var h=c.default,f=d(u,0)|(null==h?void 0:h.flags),v=null==h?void 0:h.duration;8&f&&(v=d(u,2&f?12:8));for(var m=c.timescale||9e4,y=p(l,["trun"]),E=0;E<y.length;E++)!(r=A(y[E]))&&v&&(r=v*d(y[E],4)),c.type===n.ElementaryStreamTypes.VIDEO?i+=r/m:c.type===n.ElementaryStreamTypes.AUDIO&&(a+=r/m)}}if(0===i&&0===a){for(var T=0,b=p(e,["sidx"]),k=0;k<b.length;k++){var S=g(b[k]);null!=S&&S.references&&(T+=S.references.reduce((function(e,t){return e+t.info.duration||0}),0))}return T}return i||a}function A(e){var t=d(e,0),r=8;1&t&&(r+=4),4&t&&(r+=4);for(var i=0,n=d(e,4),a=0;a<n;a++)256&t&&(i+=d(e,r),r+=4),512&t&&(r+=4),1024&t&&(r+=4),2048&t&&(r+=4);return i}function E(e,t,r){p(t,["moof","traf"]).forEach((function(t){p(t,["tfhd"]).forEach((function(i){var n=d(i,4),a=e[n];if(a){var o=a.timescale||9e4;p(t,["tfdt"]).forEach((function(e){var t=e[0],i=d(e,4);if(0===t)i-=r*o,f(e,4,i=Math.max(i,0));else{i*=Math.pow(2,32),i+=d(e,8),i-=r*o,i=Math.max(i,0);var n=Math.floor(i/(s+1)),a=Math.floor(i%(s+1));f(e,4,n),f(e,8,a)}}))}}))}))}function T(e){var t={valid:null,remainder:null},r=p(e,["moof"]);if(!r)return t;if(r.length<2)return t.remainder=e,t;var n=r[r.length-1];return t.valid=(0,i.sliceUint8)(e,0,n.byteOffset-8),t.remainder=(0,i.sliceUint8)(e,n.byteOffset-8),t}function b(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function k(e,t){var r=[],i=t.samples,a=t.timescale,s=t.id,o=!1;return p(i,["moof"]).map((function(l){var u=l.byteOffset-8;p(l,["traf"]).map((function(l){var c=p(l,["tfdt"]).map((function(e){var t=e[0],r=d(e,4);return 1===t&&(r*=Math.pow(2,32),r+=d(e,8)),r/a}))[0];return void 0!==c&&(e=c),p(l,["tfhd"]).map((function(c){var f=d(c,4),g=16777215&d(c,0),v=0,m=0!=(16&g),y=0,A=0!=(32&g),E=8;f===s&&(0!=(1&g)&&(E+=8),0!=(2&g)&&(E+=4),0!=(8&g)&&(v=d(c,E),E+=4),m&&(y=d(c,E),E+=4),A&&(E+=4),"video"===t.type&&(o=function(e){if(!e)return!1;var t=e.indexOf("."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),p(l,["trun"]).map((function(s){var l=s[0],c=16777215&d(s,0),f=0!=(1&c),p=0,g=0!=(4&c),m=0!=(256&c),A=0,E=0!=(512&c),T=0,b=0!=(1024&c),k=0!=(2048&c),C=0,L=d(s,4),D=8;f&&(p=d(s,D),D+=4),g&&(D+=4);for(var R=p+u,I=0;I<L;I++){if(m?(A=d(s,D),D+=4):A=v,E?(T=d(s,D),D+=4):T=y,b&&(D+=4),k&&(C=0===l?d(s,D):h(s,D),D+=4),t.type===n.ElementaryStreamTypes.VIDEO)for(var O=0;O<T;){var w=d(i,R);S(o,i[R+=4])&&_(i.subarray(R,R+w),o?2:1,e+C/a,r),R+=w,O+=w+4}e+=A/a}})))}))}))})),r}function S(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6==(31&t)}function _(e,t,r,i){var n=C(e),s=0;s+=t;for(var o=0,l=0,u=!1,h=0;s<n.length;){o=0;do{if(s>=n.length)break;o+=h=n[s++]}while(255===h);l=0;do{if(s>=n.length)break;l+=h=n[s++]}while(255===h);var f=n.length-s;if(!u&&4===o&&s<n.length){if(u=!0,181===n[s++]){var p=c(n,s);if(s+=2,49===p){var g=d(n,s);if(s+=4,1195456820===g){var v=n[s++];if(3===v){var m=n[s++],y=64&m,A=y?2+3*(31&m):0,E=new Uint8Array(A);if(y){E[0]=m;for(var T=1;T<A;T++)E[T]=n[s++]}i.push({type:v,payloadType:o,pts:r,bytes:E})}}}}}else if(5===o&&l<f){if(u=!0,l>16){for(var b=[],k=0;k<16;k++){var S=n[s++].toString(16);b.push(1==S.length?"0"+S:S),3!==k&&5!==k&&7!==k&&9!==k||b.push("-")}for(var _=l-16,L=new Uint8Array(_),D=0;D<_;D++)L[D]=n[s++];i.push({payloadType:o,pts:r,uuid:b.join(""),userData:(0,a.utf8ArrayToStr)(L),userDataBytes:L})}}else if(l<f)s+=l;else if(l>f)break}}function C(e){for(var t=e.byteLength,r=[],i=1;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(r.push(i+2),i+=2):i++;if(0===r.length)return e;var n=t-r.length,a=new Uint8Array(n),s=0;for(i=0;i<n;s++,i++)s===r[0]&&(s++,r.shift()),a[i]=e[s];return a}function L(e){var t=e[0],r="",i="",n=0,a=0,s=0,o=0,l=0,c=0;if(0===t){for(;"\0"!==u(e.subarray(c,c+1));)r+=u(e.subarray(c,c+1)),c+=1;for(r+=u(e.subarray(c,c+1)),c+=1;"\0"!==u(e.subarray(c,c+1));)i+=u(e.subarray(c,c+1)),c+=1;i+=u(e.subarray(c,c+1)),c+=1,n=d(e,12),a=d(e,16),o=d(e,20),l=d(e,24),c=28}else if(1===t){n=d(e,c+=4);var h=d(e,c+=4),f=d(e,c+=4);for(c+=4,s=Math.pow(2,32)*h+f,Number.isSafeInteger(s)||(s=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=d(e,c),l=d(e,c+=4),c+=4;"\0"!==u(e.subarray(c,c+1));)r+=u(e.subarray(c,c+1)),c+=1;for(r+=u(e.subarray(c,c+1)),c+=1;"\0"!==u(e.subarray(c,c+1));)i+=u(e.subarray(c,c+1)),c+=1;i+=u(e.subarray(c,c+1)),c+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:e.subarray(c,e.byteLength)}}},"./src/utils/output-filter.ts": /*!************************************!*\ !*** ./src/utils/output-filter.ts ***! \************************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});var i=function(){function e(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}var t=e.prototype;return t.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},t.newCue=function(e,t,r){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},t.reset=function(){this.cueRanges=[],this.startTime=null},e}()},"./src/utils/texttrack-utils.ts": /*!**************************************!*\ !*** ./src/utils/texttrack-utils.ts ***! \**************************************/(e,t,r)=>{r.r(t),r.d(t,{addCueToTrack:()=>a,clearCurrentCues:()=>s,getCuesInRange:()=>l,removeCuesInRange:()=>o,sendAddTrackEvent:()=>n});var i=r(/*! ./logger */"./src/utils/logger.ts");function n(e,t){var r;try{r=new Event("addtrack")}catch(e){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function a(e,t){var r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error("addCue is failed for: "+t)}catch(r){i.logger.debug("[texttrack-utils]: "+r);var n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}"disabled"===r&&(e.mode=r)}function s(e){var t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(var r=e.cues.length;r--;)e.removeCue(e.cues[r]);"disabled"===t&&(e.mode=t)}function o(e,t,r,i){var n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var a=l(e.cues,t,r),s=0;s<a.length;s++)i&&!i(a[s])||e.removeCue(a[s]);"disabled"===n&&(e.mode=n)}function l(e,t,r){var i=[],n=function(e,t){if(t<e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var i=0,n=r;i<=n;){var a=Math.floor((n+i)/2);if(t<e[a].startTime)n=a-1;else{if(!(t>e[a].startTime&&i<r))return a;i=a+1}}return e[i].startTime-t<t-e[n].startTime?i:n}(e,t);if(n>-1)for(var a=n,s=e.length;a<s;a++){var o=e[a];if(o.startTime>=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}},"./src/utils/time-ranges.ts": /*!**********************************!*\ !*** ./src/utils/time-ranges.ts ***! \**********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i={toString:function(e){for(var t="",r=e.length,i=0;i<r;i++)t+="["+e.start(i).toFixed(3)+","+e.end(i).toFixed(3)+"]";return t}}},"./src/utils/timescale-conversion.ts": /*!*******************************************!*\ !*** ./src/utils/timescale-conversion.ts ***! \*******************************************/(e,t,r)=>{function i(e,t,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=e*t*r;return i?Math.round(n):n}function n(e,t,r,n){return void 0===r&&(r=1),void 0===n&&(n=!1),i(e,t,1/r,n)}function a(e,t){return void 0===t&&(t=!1),i(e,1e3,1/9e4,t)}function s(e,t){return void 0===t&&(t=1),i(e,9e4,1/t)}r.r(t),r.d(t,{toMpegTsClockFromTimescale:()=>s,toMsFromMpegTsClock:()=>a,toTimescaleFromBase:()=>i,toTimescaleFromScale:()=>n})},"./src/utils/typed-array.ts": /*!**********************************!*\ !*** ./src/utils/typed-array.ts ***! \**********************************/(e,t,r)=>{function i(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}r.r(t),r.d(t,{sliceUint8:()=>i})},"./src/utils/vttcue.ts": /*!*****************************!*\ !*** ./src/utils/vttcue.ts ***! \*****************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>i});const i=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var r=t.toLowerCase();return!!~e.indexOf(r)&&r}function i(e){return r(t,e)}function n(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var s in a)e[s]=a[s]}return e}function a(t,a,s){var o=this,l={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,d=t,h=a,f=s,p=null,g="",v=!0,m="auto",y="start",A=50,E="middle",T=50,b="middle";Object.defineProperty(o,"id",n({},l,{get:function(){return u},set:function(e){u=""+e}})),Object.defineProperty(o,"pauseOnExit",n({},l,{get:function(){return c},set:function(e){c=!!e}})),Object.defineProperty(o,"startTime",n({},l,{get:function(){return d},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");d=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",n({},l,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",n({},l,{get:function(){return f},set:function(e){f=""+e,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",n({},l,{get:function(){return p},set:function(e){p=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",n({},l,{get:function(){return g},set:function(t){var i=function(t){return r(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",n({},l,{get:function(){return v},set:function(e){v=!!e,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",n({},l,{get:function(){return m},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");m=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",n({},l,{get:function(){return y},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",n({},l,{get:function(){return A},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");A=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return E},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return T},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return b},set:function(e){var t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");b=t,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}()},"./src/utils/vttparser.ts": /*!********************************!*\ !*** ./src/utils/vttparser.ts ***! \********************************/(e,t,r)=>{r.r(t),r.d(t,{VTTParser:()=>h,fixLineBreaks:()=>d,parseTimeStamp:()=>a});var i=r(/*! ./vttcue */"./src/utils/vttcue.ts"),n=function(){function e(){}return e.prototype.decode=function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))},e}();function a(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(i||0)}var r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}var s=function(){function e(){this.values=Object.create(null)}var t=e.prototype;return t.set=function(e,t){this.get(e)||""===t||(this.values[e]=t)},t.get=function(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t},t.has=function(e){return e in this.values},t.alt=function(e,t,r){for(var i=0;i<r.length;++i)if(t===r[i]){this.set(e,t);break}},t.integer=function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))},t.percent=function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1},e}();function o(e,t,r,i){var n=i?e.split(i):[e];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);2===s.length&&t(s[0],s[1])}}var l=new i.default(0,0,""),u="middle"===l.align?"middle":"center";function c(e,t,r){var i=e;function n(){var t=a(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function c(){e=e.replace(/^\s+/,"")}if(c(),t.startTime=n(),c(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),c(),t.endTime=n(),c(),function(e,t){var i=new s;o(e,(function(e,t){var n;switch(e){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===t){i.set(e,r[a].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),i.integer(e,n[0]),i.percent(e,n[0])&&i.set("snapToLines",!1),i.alt(e,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",u,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",u,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",u,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===l.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",u);var a=i.get("position","auto");"auto"===a&&50===l.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function d(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var h=function(){function e(){this.state="INITIAL",this.buffer="",this.decoder=new n,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var t=e.prototype;return t.parse=function(e){var t=this;function r(){var e=t.buffer,r=0;for(e=d(e);r<e.length&&"\r"!==e[r]&&"\n"!==e[r];)++r;var i=e.slice(0,r);return"\r"===e[r]&&++r,"\n"===e[r]&&++r,t.buffer=e.slice(r),i}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var n="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var a=(n=r()).match(/^()?WEBVTT([ \t].*)?$/);if(!a||!a[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var s=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(s?s=!1:n=r(),t.state){case"HEADER":/:/.test(n)?o(n,(function(e,t){}),/:/):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new i.default(0,0,""),t.state="CUE",-1===n.indexOf("--\x3e")){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{c(n,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var l=-1!==n.indexOf("--\x3e");if(!n||l&&(s=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=n;continue;case"BADCUE":n||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this},t.flush=function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this},e}()},"./src/utils/webvtt-parser.ts": /*!************************************!*\ !*** ./src/utils/webvtt-parser.ts ***! \************************************/(e,t,r)=>{r.r(t),r.d(t,{generateCueId:()=>d,parseWebVTT:()=>h});var i=r(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),n=r(/*! ./vttparser */"./src/utils/vttparser.ts"),a=r(/*! ../demux/id3 */"./src/demux/id3.ts"),s=r(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),o=r(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=/\r\n|\n\r|\n|\r/g,u=function(e,t,r){return void 0===r&&(r=0),e.slice(r,r+t.length)===t},c=function(e){for(var t=5381,r=e.length;r;)t=33*t^e.charCodeAt(--r);return(t>>>0).toString()};function d(e,t,r){return c(e.toString())+c(t.toString())+c(r)}function h(e,t,r,c,h,f,p,g){var v,m=new n.VTTParser,y=(0,a.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(l,"\n").split("\n"),A=[],E=(0,s.toMpegTsClockFromTimescale)(t,r),T="00:00.000",b=0,k=0,S=!0;m.oncue=function(e){var t=c[h],r=c.ccOffset,i=(b-E)/9e4;null!=t&&t.new&&(void 0!==k?r=c.ccOffset=t.start:function(e,t,r){var i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!==(a=n)&&void 0!==a&&a.new;){var a;e.ccOffset+=i.start-n.start,i.new=!1,n=e[(i=n).prevCC]}e.presentationOffset=r}(c,h,i)),i&&(r=i-c.presentationOffset);var n=e.endTime-e.startTime,a=(0,o.normalizePts)(9e4*(e.startTime+r-k),9e4*f)/9e4;e.startTime=Math.max(a,0),e.endTime=Math.max(a+n,0);var s=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(s)),e.id||(e.id=d(e.startTime,e.endTime,s)),e.endTime>0&&A.push(e)},m.onparsingerror=function(e){v=e},m.onflush=function(){v?g(v):p(A)},y.forEach((function(e){if(S){if(u(e,"X-TIMESTAMP-MAP=")){S=!1,e.slice(16).split(",").forEach((function(e){u(e,"LOCAL:")?T=e.slice(6):u(e,"MPEGTS:")&&(b=parseInt(e.slice(7)))}));try{k=function(e){var t=parseInt(e.slice(-3)),r=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!((0,i.isFiniteNumber)(t)&&(0,i.isFiniteNumber)(r)&&(0,i.isFiniteNumber)(n)&&(0,i.isFiniteNumber)(a)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*r,(t+=6e4*n)+36e5*a}(T)/1e3}catch(e){v=e}return}""===e&&(S=!1)}m.parse(e+"\n")})),m.flush()}},"./src/utils/xhr-loader.ts": /*!*********************************!*\ !*** ./src/utils/xhr-loader.ts ***! \*********************************/(e,t,r)=>{r.r(t),r.d(t,{default:()=>s});var i=r(/*! ../utils/logger */"./src/utils/logger.ts"),n=r(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),a=/^age:\s*[\d.]+\s*$/m;const s=function(){function e(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e?e.xhrSetup:null,this.stats=new n.LoadStats,this.retryDelay=0}var t=e.prototype;return t.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},t.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},t.abort=function(){var e;this.abortInternal(),null!==(e=this.callbacks)&&void 0!==e&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},t.load=function(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e=this.config,t=this.context;if(e){var r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0;var n=this.xhrSetup;try{if(n)try{n(r,t.url)}catch(e){r.open("GET",t.url,!0),n(r,t.url)}r.readyState||r.open("GET",t.url,!0);var a=this.context.headers;if(a)for(var s in a)r.setRequestHeader(s,a[s])}catch(e){return void this.callbacks.onError({code:r.status,text:e.message},t,r)}t.rangeEnd&&r.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),r.onreadystatechange=this.readystatechange.bind(this),r.onprogress=this.loadprogress.bind(this),r.responseType=t.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.timeout),r.send()}},t.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!r.aborted&&n>=2)if(self.clearTimeout(this.requestTimeout),0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start)),4===n){t.onreadystatechange=null,t.onprogress=null;var s=t.status,o="arraybuffer"===t.responseType;if(s>=200&&s<300&&(o&&t.response||null!==t.responseText)){var l,u;if(r.loading.end=Math.max(self.performance.now(),r.loading.first),u=o?(l=t.response).byteLength:(l=t.responseText).length,r.loaded=r.total=u,!this.callbacks)return;var c=this.callbacks.onProgress;if(c&&c(r,e,l,t),!this.callbacks)return;var d={url:t.responseURL,data:l};this.callbacks.onSuccess(d,r,e,t)}else r.retry>=a.maxRetry||s>=400&&s<499?(i.logger.error(s+" while loading "+e.url),this.callbacks.onError({code:s,text:t.statusText},e,t)):(i.logger.warn(s+" while loading "+e.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),r.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.timeout)}},t.loadtimeout=function(){i.logger.warn("timeout while loading "+this.context.url);var e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))},t.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},t.getCacheAge=function(){var e=null;if(this.loader&&a.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},e}()},"./node_modules/eventemitter3/index.js": /*!*********************************************!*\ !*** ./node_modules/eventemitter3/index.js ***! \*********************************************/e=>{var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,i,a,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new n(i,a||e,s),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],o]:e._events[l].push(o):(e._events[l]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},o.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,a=i.length,s=new Array(a);n<a;n++)s[n]=i[n].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},o.prototype.emit=function(e,t,i,n,a,s){var o=r?r+e:e;if(!this._events[o])return!1;var l,u,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,i),!0;case 4:return c.fn.call(c.context,t,i,n),!0;case 5:return c.fn.call(c.context,t,i,n,a),!0;case 6:return c.fn.call(c.context,t,i,n,a,s),!0}for(u=1,l=new Array(d-1);u<d;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var h,f=c.length;for(u=0;u<f;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),d){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,i);break;case 4:c[u].fn.call(c[u].context,t,i,n);break;default:if(!l)for(h=1,l=new Array(d-1);h<d;h++)l[h-1]=arguments[h];c[u].fn.apply(c[u].context,l)}}return!0},o.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,i,n){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn!==t||n&&!o.once||i&&o.context!==i||s(this,a);else{for(var l=0,u=[],c=o.length;l<c;l++)(o[l].fn!==t||n&&!o[l].once||i&&o[l].context!==i)&&u.push(o[l]);u.length?this._events[a]=1===u.length?u[0]:u:s(this,a)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o},"./node_modules/url-toolkit/src/url-toolkit.js": /*!*****************************************************!*\ !*** ./node_modules/url-toolkit/src/url-toolkit.js ***! \*****************************************************/function(e){var t,r,i,n,a;t=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var n=a.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=a.normalizePath(n.path),a.buildURLFromParts(n)}var s=a.parseURL(t);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=a.normalizePath(s.path),a.buildURLFromParts(s)):t;var o=a.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=r.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(u.netLoc=o.netLoc,"/"!==s.path[0]))if(s.path){var c=o.path,d=c.substring(0,c.lastIndexOf("/")+1)+s.path;u.path=a.normalizePath(d)}else u.path=o.path,s.params||(u.params=o.params,s.query||(u.query=o.query));return null===u.path&&(u.path=i.alwaysNormalize?a.normalizePath(s.path):s.path),a.buildURLFromParts(u)},parseURL:function(e){var r=t.exec(e);return r?{scheme:r[1]||"",netLoc:r[2]||"",path:r[3]||"",params:r[4]||"",query:r[5]||"",fragment:r[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(i,"");e.length!==(e=e.replace(n,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}},e.exports=a}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return e[i].call(a.exports,a,a.exports,r),a.exports}r.m=e,r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i=r("./src/hls.ts");return i=i.default})(),pr.exports=gr());var mr=fr(vr.exports),yr=J.now,Ar=J.assign,Er=J.listContainsIgnoreCase;ce.register("PLAYBACK_FRAGMENT_CHANGED"),ce.register("PLAYBACK_FRAGMENT_PARSING_METADATA");var Tr=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ar(e,t)}(a,e);var t,r,i,n=or(a);function a(){var e;tr(this,a);for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return(e=n.call.apply(n,[this].concat(r))).options.playback=er(er({},e.options),e.options.playback),e.options.hlsPlayback=er(er({},e.defaultOptions),e.options.hlsPlayback),e._minDvrSize=void 0===e.options.hlsMinimumDvrSize?60:e.options.hlsMinimumDvrSize,e._extrapolatedWindowNumSegments=e.options.playback&&void 0!==e.options.playback.extrapolatedWindowNumSegments?e.options.playback.extrapolatedWindowNumSegments:2,e._playbackType=Re.VOD,e._lastTimeUpdate={current:0,total:0},e._lastDuration=null,e._playableRegionStartTime=0,e._localStartTimeCorrelation=null,e._localEndTimeCorrelation=null,e._playableRegionDuration=0,e._programDateTime=0,e._durationExcludesAfterLiveSyncPoint=!1,e._segmentTargetDuration=null,e._playlistType=null,e._recoverAttemptsRemaining=e.options.hlsRecoverAttempts||16,e}return t=a,r=[{key:"name",get:function(){return"hls"}},{key:"supportedVersion",get:function(){return{min:"0.4.27"}}},{key:"levels",get:function(){return this._levels||[]}},{key:"currentLevel",get:function(){return null===this._currentLevel||void 0===this._currentLevel?-1:this._currentLevel},set:function(e){this._currentLevel=e,this.trigger(ce.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:"_startTime",get:function(){return this._playbackType===Re.LIVE&&"EVENT"!==this._playlistType?this._extrapolatedStartTime:this._playableRegionStartTime}},{key:"_now",get:function(){return yr()}},{key:"_extrapolatedStartTime",get:function(){if(!this._localStartTimeCorrelation)return this._playableRegionStartTime;var e=this._localStartTimeCorrelation,t=this._now-e.local,r=(e.remote+t)/1e3;return Math.min(r,this._playableRegionStartTime+this._extrapolatedWindowDuration)}},{key:"_extrapolatedEndTime",get:function(){var e=this._playableRegionStartTime+this._playableRegionDuration;if(!this._localEndTimeCorrelation)return e;var t=this._localEndTimeCorrelation,r=this._now-t.local,i=(t.remote+r)/1e3;return Math.max(e-this._extrapolatedWindowDuration,Math.min(i,e))}},{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:"_setup",value:function(){var e=this;this._manifestParsed=!1,this._ccIsSetup=!1,this._ccTracksUpdated=!1,this._hls&&this._hls.destroy(),this._hls=new mr(Ar({},this.options.playback.hlsjsConfig)),this._hls.once(mr.Events.MEDIA_ATTACHED,(function(){e.options.hlsPlayback.preload&&e._hls.loadSource(e.options.src)})),this._hls.on(mr.Events.MANIFEST_PARSED,(function(){return e._manifestParsed=!0})),this._hls.on(mr.Events.LEVEL_LOADED,(function(t,r){return e._updatePlaybackType(t,r)})),this._hls.on(mr.Events.LEVEL_UPDATED,(function(t,r){return e._onLevelUpdated(t,r)})),this._hls.on(mr.Events.LEVEL_SWITCHING,(function(t,r){return e._onLevelSwitch(t,r)})),this._hls.on(mr.Events.FRAG_CHANGED,(function(t,r){return e._onFragmentChanged(t,r)})),this._hls.on(mr.Events.FRAG_LOADED,(function(t,r){return e._onFragmentLoaded(t,r)})),this._hls.on(mr.Events.FRAG_PARSING_METADATA,(function(t,r){return e._onFragmentParsingMetadata(t,r)})),this._hls.on(mr.Events.ERROR,(function(t,r){return e._onHLSJSError(t,r)})),this._hls.on(mr.Events.SUBTITLE_TRACK_LOADED,(function(t,r){return e._onSubtitleLoaded(t,r)})),this._hls.on(mr.Events.SUBTITLE_TRACKS_UPDATED,(function(){return e._ccTracksUpdated=!0})),this.bindCustomListeners(),this._hls.attachMedia(this.el)}},{key:"bindCustomListeners",value:function(){var e=this;this.customListeners.forEach((function(t){var r=t.eventName,i=t.once?"once":"on";r&&e._hls["".concat(i)](r,t.callback)}))}},{key:"unbindCustomListeners",value:function(){var e=this;this.customListeners.forEach((function(t){var r=t.eventName;r&&e._hls.off(r,t.callback)}))}},{key:"_onFragmentParsingMetadata",value:function(e,t){this.trigger(ce.Custom.PLAYBACK_FRAGMENT_PARSING_METADATA,{evt:e,data:t})}},{key:"render",value:function(){return this._ready(),ur(nr(a.prototype),"render",this).call(this)}},{key:"_ready",value:function(){this._isReadyState||(!this._hls&&this._setup(),this._isReadyState=!0,this.trigger(ce.PLAYBACK_READY,this.name))}},{key:"_recover",value:function(e,t,r){if(this._recoveredDecodingError)if(this._recoveredAudioCodecError){ae.error("hlsjs: failed to recover",{evt:e,data:t}),r.level=_e.Levels.FATAL;var i=this.createError(r);this.trigger(ce.PLAYBACK_ERROR,i),this.stop()}else this._recoveredAudioCodecError=!0,this._hls.swapAudioCodec(),this._hls.recoverMediaError();else this._recoveredDecodingError=!0,this._hls.recoverMediaError()}},{key:"_setupSrc",value:function(e){}},{key:"_startTimeUpdateTimer",value:function(){var e=this;this._timeUpdateTimer||(this._timeUpdateTimer=setInterval((function(){e._onDurationChange(),e._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(e){var t=this._duration;e>0&&(t=this._duration*(e/100)),this.seek(t)}},{key:"seek",value:function(e){e<0&&(ae.warn("Attempt to seek to a negative time. Resetting to live point. Use seekToLivePoint() to seek to the live point."),e=this.getDuration()),this.dvrEnabled&&this._updateDvr(e<this.getDuration()-3),e+=this._startTime,this.el.currentTime=e}},{key:"seekToLivePoint",value:function(){this.seek(this.getDuration())}},{key:"_updateDvr",value:function(e){this.trigger(ce.PLAYBACK_DVR,e),this.trigger(ce.PLAYBACK_STATS_ADD,{dvr:e})}},{key:"_updateSettings",value:function(){this._playbackType===Re.VOD?this.settings.left=["playpause","position","duration"]:this.dvrEnabled?this.settings.left=["playpause"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(ce.PLAYBACK_SETTINGSUPDATE)}},{key:"_onHLSJSError",value:function(e,t){var r,i={code:"".concat(t.type,"_").concat(t.details),description:"".concat(this.name," error: type: ").concat(t.type,", details: ").concat(t.details),raw:t};if(t.response&&(i.description+=", response: ".concat(JSON.stringify(t.response))),t.fatal)if(this._recoverAttemptsRemaining>0)switch(this._recoverAttemptsRemaining-=1,t.type){case mr.ErrorTypes.NETWORK_ERROR:switch(t.details){case mr.ErrorDetails.MANIFEST_LOAD_ERROR:case mr.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case mr.ErrorDetails.MANIFEST_PARSING_ERROR:case mr.ErrorDetails.LEVEL_LOAD_ERROR:case mr.ErrorDetails.LEVEL_LOAD_TIMEOUT:ae.error("hlsjs: unrecoverable network fatal error.",{evt:e,data:t}),r=this.createError(i),this.trigger(ce.PLAYBACK_ERROR,r),this.stop();break;default:ae.warn("hlsjs: trying to recover from network error.",{evt:e,data:t}),i.level=_e.Levels.WARN,this._hls.startLoad()}break;case mr.ErrorTypes.MEDIA_ERROR:ae.warn("hlsjs: trying to recover from media error.",{evt:e,data:t}),i.level=_e.Levels.WARN,this._recover(e,t,i);break;default:ae.error("hlsjs: could not recover from error.",{evt:e,data:t}),r=this.createError(i),this.trigger(ce.PLAYBACK_ERROR,r),this.stop()}else ae.error("hlsjs: could not recover from error after maximum number of attempts.",{evt:e,data:t}),r=this.createError(i),this.trigger(ce.PLAYBACK_ERROR,r),this.stop();else{if(this.options.playback.triggerFatalErrorOnResourceDenied&&this._keyIsDenied(t))return ae.error("hlsjs: could not load decrypt key.",{evt:e,data:t}),r=this.createError(i),this.trigger(ce.PLAYBACK_ERROR,r),void this.stop();i.level=_e.Levels.WARN,ae.warn("hlsjs: non-fatal error occurred",{evt:e,data:t})}}},{key:"_keyIsDenied",value:function(e){return e.type===mr.ErrorTypes.NETWORK_ERROR&&e.details===mr.ErrorDetails.KEY_LOAD_ERROR&&e.response&&e.response.code>=400}},{key:"_onTimeUpdate",value:function(){var e={current:this.getCurrentTime(),total:this.getDuration(),firstFragDateTime:this.getProgramDateTime()};this._lastTimeUpdate&&e.current===this._lastTimeUpdate.current&&e.total===this._lastTimeUpdate.total||(this._lastTimeUpdate=e,this.trigger(ce.PLAYBACK_TIMEUPDATE,e,this.name))}},{key:"_onDurationChange",value:function(){var e=this.getDuration();this._lastDuration!==e&&(this._lastDuration=e,ur(nr(a.prototype),"_onDurationChange",this).call(this))}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var e=[],t=0,r=0;r<this.el.buffered.length;r++)e=[].concat(cr(e),[{start:Math.max(0,this.el.buffered.start(r)-this._playableRegionStartTime),end:Math.max(0,this.el.buffered.end(r)-this._playableRegionStartTime)}]),this.el.currentTime>=e[r].start&&this.el.currentTime<=e[r].end&&(t=r);var i={start:e[t].start,current:e[t].end,total:this.getDuration()};this.trigger(ce.PLAYBACK_PROGRESS,i,e)}}},{key:"play",value:function(){!this._hls&&this._setup(),!this._manifestParsed&&!this.options.hlsPlayback.preload&&this._hls.loadSource(this.options.src),ur(nr(a.prototype),"play",this).call(this),this._startTimeUpdateTimer()}},{key:"pause",value:function(){this._hls&&(this.el.pause(),this.dvrEnabled&&this._updateDvr(!0))}},{key:"stop",value:function(){this._stopTimeUpdateTimer(),this._hls&&(ur(nr(a.prototype),"stop",this).call(this),this._hls.destroy(),delete this._hls)}},{key:"destroy",value:function(){this._stopTimeUpdateTimer(),this._hls&&(this._hls.destroy(),delete this._hls),ur(nr(a.prototype),"destroy",this).call(this)}},{key:"_updatePlaybackType",value:function(e,t){this._playbackType=t.details.live?Re.LIVE:Re.VOD,this._onLevelUpdated(e,t),this._ccTracksUpdated&&this._playbackType===Re.LIVE&&this.hasClosedCaptionsTracks&&this._onSubtitleLoaded()}},{key:"_fillLevels",value:function(){this._levels=this._hls.levels.map((function(e,t){return{id:t,level:e,label:"".concat(e.bitrate/1e3,"Kbps")}})),this.trigger(ce.PLAYBACK_LEVELS_AVAILABLE,this._levels)}},{key:"_onLevelUpdated",value:function(e,t){this._segmentTargetDuration=t.details.targetduration,this._playlistType=t.details.type||null;var r=!1,i=!1,n=t.details.fragments,a=this._playableRegionStartTime,s=this._playableRegionDuration;if(0!==n.length){if(n[0].rawProgramDateTime&&(this._programDateTime=n[0].rawProgramDateTime),this._playableRegionStartTime!==n[0].start&&(r=!0,this._playableRegionStartTime=n[0].start),r)if(this._localStartTimeCorrelation){var o=this._localStartTimeCorrelation,l=this._now-o.local,u=(o.remote+l)/1e3;u<n[0].start?this._localStartTimeCorrelation={local:this._now,remote:1e3*n[0].start}:u>a+this._extrapolatedWindowDuration&&(this._localStartTimeCorrelation={local:this._now,remote:1e3*Math.max(n[0].start,a+this._extrapolatedWindowDuration)})}else this._localStartTimeCorrelation={local:this._now,remote:1e3*(n[0].start+this._extrapolatedWindowDuration/2)};var c=t.details.totalduration;if(this._playbackType===Re.LIVE){var d=t.details.targetduration*((this.options.playback.hlsjsConfig||{}).liveSyncDurationCount||mr.DefaultConfig.liveSyncDurationCount);d<=c?(c-=d,this._durationExcludesAfterLiveSyncPoint=!0):this._durationExcludesAfterLiveSyncPoint=!1}c!==this._playableRegionDuration&&(i=!0,this._playableRegionDuration=c);var h=n[0].start+c,f=a+s;if(h!==f)if(this._localEndTimeCorrelation){var p=this._localEndTimeCorrelation,g=this._now-p.local,v=(p.remote+g)/1e3;v>h?this._localEndTimeCorrelation={local:this._now,remote:1e3*h}:v<h-this._extrapolatedWindowDuration?this._localEndTimeCorrelation={local:this._now,remote:1e3*(h-this._extrapolatedWindowDuration)}:v>f&&(this._localEndTimeCorrelation={local:this._now,remote:1e3*f})}else this._localEndTimeCorrelation={local:this._now,remote:1e3*h};i&&this._onDurationChange(),r&&this._onProgress()}}},{key:"_onFragmentChanged",value:function(e,t){this.trigger(ce.Custom.PLAYBACK_FRAGMENT_CHANGED,t)}},{key:"_onFragmentLoaded",value:function(e,t){this.trigger(ce.PLAYBACK_FRAGMENT_LOADED,t)}},{key:"_onSubtitleLoaded",value:function(){if(!this._ccIsSetup){this.trigger(ce.PLAYBACK_SUBTITLE_AVAILABLE);var e=this._playbackType===Re.LIVE?-1:this.closedCaptionsTrackId;this.closedCaptionsTrackId=e,this._ccIsSetup=!0}}},{key:"_onLevelSwitch",value:function(e,t){this.levels.length||this._fillLevels(),this.trigger(ce.PLAYBACK_LEVEL_SWITCH_END),this.trigger(ce.PLAYBACK_LEVEL_SWITCH,t);var r=this._hls.levels[t.level];r&&(this.highDefinition=r.height>=720||r.bitrate/1e3>=2e3,this.trigger(ce.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(ce.PLAYBACK_BITRATE,{height:r.height,width:r.width,bandwidth:r.bitrate,bitrate:r.bitrate,level:t.level}))}},{key:"dvrEnabled",get:function(){return this._durationExcludesAfterLiveSyncPoint&&this._duration>=this._minDvrSize&&this.getPlaybackType()===Re.LIVE}},{key:"getPlaybackType",value:function(){return this._playbackType}},{key:"isSeekEnabled",value:function(){return this._playbackType===Re.VOD||this.dvrEnabled}}],i=[{key:"HLSJS",get:function(){return mr}}],r&&rr(t.prototype,r),i&&rr(t,i),Object.defineProperty(t,"prototype",{writable:!1}),a}(ze);return Tr.canPlay=function(e,t){var r=e.split("?")[0].match(/.*\.(.*)$/)||[],i=r.length>1&&"m3u8"===r[1].toLowerCase()||Er(t,["application/vnd.apple.mpegurl","application/x-mpegURL"]);return!(!mr.isSupported()||!i)},Qt.Loader.registerPlayback(Tr),t(t({},Qt),{},{HLS:Tr})}(); //# sourceMappingURL=clappr.min.js.map
Editor Settings
Theme
Key bindings
Full width
Lines