!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Clappr=t()}(this,(function(){"use strict";function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function n(n){for(var i=1;ie.length)&&(t=e.length);for(var n=0,i=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)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),n=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var i=arguments[1],r=0;r>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var i=arguments[1],r=0;r]*>/,p=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,g=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,v=/^(?:body|html)$/i,m=/([A-Z])/g,y=["val","css","html","text","data","width","height","offset"],A=u.createElement("table"),b=u.createElement("tr"),E={tr:u.createElement("tbody"),tbody:A,thead:A,tfoot:A,td:b,th:b,"*":u.createElement("div")},T=/complete|loaded|interactive/,k=/^[\w-]*$/,_={},S=_.toString,C={},R=u.createElement("div"),w={tabindex:"tabIndex",readonly:"readOnly",for:"htmlFor",class:"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},O=Array.isArray||function(e){return e instanceof Array};function L(e){return null==e?String(e):_[S.call(e)]||"object"}function D(e){return"function"==L(e)}function I(e){return null!=e&&e==e.window}function P(e){return null!=e&&e.nodeType==e.DOCUMENT_NODE}function x(e){return"object"==L(e)}function N(e){return x(e)&&!I(e)&&Object.getPrototypeOf(e)==Object.prototype}function M(e){var n=!!e&&"length"in e&&e.length,i=t.type(e);return"function"!=i&&!I(e)&&("array"==i||0===n||"number"==typeof n&&n>0&&n-1 in e)}function F(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 B(e){return e in d?d[e]:d[e]=new RegExp("(^|\\s)"+e+"(\\s|$)")}function U(e,t){return"number"!=typeof t||h[F(e)]?t:t+"px"}function j(e){return"children"in e?l.call(e.children):t.map(e.childNodes,(function(e){if(1==e.nodeType)return e}))}function V(e,t){var n,i=e?e.length:0;for(n=0;n")),void 0===n&&(n=f.test(e)&&RegExp.$1),n in E||(n="*"),(o=E[n]).innerHTML=""+e,r=t.each(l.call(o.childNodes),(function(){o.removeChild(this)}))),N(i)&&(a=t(r),t.each(i,(function(e,t){y.indexOf(e)>-1?a[e](t):a.attr(e,t)}))),r},C.Z=function(e,t){return new V(e,t)},C.isZ=function(e){return e instanceof C.Z},C.init=function(e,n){var i,r;if(!e)return C.Z();if("string"==typeof e)if("<"==(e=e.trim())[0]&&f.test(e))i=C.fragment(e,RegExp.$1,n),e=null;else{if(void 0!==n)return t(n).find(e);i=C.qsa(u,e)}else{if(D(e))return t(u).ready(e);if(C.isZ(e))return e;if(O(e))r=e,i=s.call(r,(function(e){return null!=e}));else if(x(e))i=[e],e=null;else if(f.test(e))i=C.fragment(e.trim(),RegExp.$1,n),e=null;else{if(void 0!==n)return t(n).find(e);i=C.qsa(u,e)}}return C.Z(i,e)},(t=function(e,t){return C.init(e,t)}).extend=function(e){var t,n=l.call(arguments,1);return"boolean"==typeof e&&(t=e,e=n.shift()),n.forEach((function(n){K(e,n,t)})),e},C.qsa=function(e,t){var n,i="#"==t[0],r=!i&&"."==t[0],a=i||r?t.slice(1):t,o=k.test(a);return e.getElementById&&o&&i?(n=e.getElementById(a))?[n]:[]:1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType?[]:l.call(o&&!i&&e.getElementsByClassName?r?e.getElementsByClassName(a):e.getElementsByTagName(t):e.querySelectorAll(t))},t.contains=u.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},t.type=L,t.isFunction=D,t.isWindow=I,t.isArray=O,t.isPlainObject=N,t.isEmptyObject=function(e){var t;for(t in e)return!1;return!0},t.isNumeric=function(e){var t=Number(e),n=typeof e;return null!=e&&"boolean"!=n&&("string"!=n||e.length)&&!isNaN(t)&&isFinite(t)||!1},t.inArray=function(e,t,n){return a.indexOf.call(t,e,n)},t.camelCase=i,t.trim=function(e){return null==e?"":String.prototype.trim.call(e)},t.uuid=0,t.support={},t.expr={},t.noop=function(){},t.map=function(e,n){var i,r,a,o,s=[];if(M(e))for(r=0;r0?t.fn.concat.apply([],o):o},t.each=function(e,t){var n,i;if(M(e)){for(n=0;n=0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each((function(){null!=this.parentNode&&this.parentNode.removeChild(this)}))},each:function(e){return a.every.call(this,(function(t,n){return!1!==e.call(t,n,t)})),this},filter:function(e){return D(e)?this.not(this.not(e)):t(s.call(this,(function(t){return C.matches(t,e)})))},add:function(e,n){return t(r(this.concat(t(e,n))))},is:function(e){return this.length>0&&C.matches(this[0],e)},not:function(e){var n=[];if(D(e)&&void 0!==e.call)this.each((function(t){e.call(this,t)||n.push(this)}));else{var i="string"==typeof e?this.filter(e):M(e)&&D(e.item)?l.call(e):t(e);this.forEach((function(e){i.indexOf(e)<0&&n.push(e)}))}return t(n)},has:function(e){return this.filter((function(){return x(e)?t.contains(this,e):t(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&&!x(e)?e:t(e)},last:function(){var e=this[this.length-1];return e&&!x(e)?e:t(e)},find:function(e){var n=this;return e?"object"==typeof e?t(e).filter((function(){var e=this;return a.some.call(n,(function(n){return t.contains(n,e)}))})):1==this.length?t(C.qsa(this[0],e)):this.map((function(){return C.qsa(this,e)})):t()},closest:function(e,n){var i=[],r="object"==typeof e&&t(e);return this.each((function(t,a){for(;a&&!(r?r.indexOf(a)>=0:C.matches(a,e));)a=a!==n&&!P(a)&&a.parentNode;a&&i.indexOf(a)<0&&i.push(a)})),t(i)},parents:function(e){for(var n=[],i=this;i.length>0;)i=t.map(i,(function(e){if((e=e.parentNode)&&!P(e)&&n.indexOf(e)<0)return n.push(e),e}));return G(n,e)},parent:function(e){return G(r(this.pluck("parentNode")),e)},children:function(e){return G(this.map((function(){return j(this)})),e)},contents:function(){return this.map((function(){return this.contentDocument||l.call(this.childNodes)}))},siblings:function(e){return G(this.map((function(e,t){return s.call(j(t.parentNode),(function(e){return e!==t}))})),e)},empty:function(){return this.each((function(){this.innerHTML=""}))},pluck:function(e){return t.map(this,(function(t){return t[e]}))},show:function(){return this.each((function(){var e,t,n;"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=(e=this.nodeName,c[e]||(t=u.createElement(e),u.body.appendChild(t),n=getComputedStyle(t,"").getPropertyValue("display"),t.parentNode.removeChild(t),"none"==n&&(n="block"),c[e]=n),c[e]))}))},replaceWith:function(e){return this.before(e).remove()},wrap:function(e){var n=D(e);if(this[0]&&!n)var i=t(e).get(0),r=i.parentNode||this.length>1;return this.each((function(a){t(this).wrapAll(n?e.call(this,a):r?i.cloneNode(!0):i)}))},wrapAll:function(e){if(this[0]){var n;for(t(this[0]).before(e=t(e));(n=e.children()).length;)e=n.first();t(e).append(this)}return this},wrapInner:function(e){var n=D(e);return this.each((function(i){var r=t(this),a=r.contents(),o=n?e.call(this,i):e;a.length?a.wrapAll(o):r.append(o)}))},unwrap:function(){return this.parent().each((function(){t(this).replaceWith(t(this).children())})),this},clone:function(){return this.map((function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(e){return this.each((function(){var n=t(this);(void 0===e?"none"==n.css("display"):e)?n.show():n.hide()}))},prev:function(e){return t(this.pluck("previousElementSibling")).filter(e||"*")},next:function(e){return t(this.pluck("nextElementSibling")).filter(e||"*")},html:function(e){return 0 in arguments?this.each((function(n){var i=this.innerHTML;t(this).empty().append(Y(this,e,n,i))})):0 in this?this[0].innerHTML:null},text:function(e){return 0 in arguments?this.each((function(t){var n=Y(this,e,t,this.textContent);this.textContent=null==n?"":""+n})):0 in this?this.pluck("textContent").join(""):null},attr:function(t,n){var i;return"string"!=typeof t||1 in arguments?this.each((function(i){if(1===this.nodeType)if(x(t))for(e in t)H(this,e,t[e]);else H(this,t,Y(this,n,i,this.getAttribute(t)))})):0 in this&&1==this[0].nodeType&&null!=(i=this[0].getAttribute(t))?i:void 0},removeAttr:function(e){return this.each((function(){1===this.nodeType&&e.split(" ").forEach((function(e){H(this,e)}),this)}))},prop:function(e,t){return e=w[e]||e,1 in arguments?this.each((function(n){this[e]=Y(this,t,n,this[e])})):this[0]&&this[0][e]},removeProp:function(e){return e=w[e]||e,this.each((function(){delete this[e]}))},data:function(e,t){var n="data-"+e.replace(m,"-$1").toLowerCase(),i=1 in arguments?this.attr(n,t):this.attr(n);return null!==i?z(i):void 0},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?t(this[0]).find("option").filter((function(){return this.selected})).pluck("value"):this[0].value)},offset:function(e){if(e)return this.each((function(n){var i=t(this),r=Y(this,e,n,i.offset()),a=i.offsetParent().offset(),o={top:r.top-a.top,left:r.left-a.left};"static"==i.css("position")&&(o.position="relative"),i.css(o)}));if(!this.length)return null;if(u.documentElement!==this[0]&&!t.contains(u.documentElement,this[0]))return{top:0,left:0};var n=this[0].getBoundingClientRect();return{left:n.left+window.pageXOffset,top:n.top+window.pageYOffset,width:Math.round(n.width),height:Math.round(n.height)}},css:function(n,r){if(arguments.length<2){var a=this[0];if("string"==typeof n){if(!a)return;return a.style[i(n)]||getComputedStyle(a,"").getPropertyValue(n)}if(O(n)){if(!a)return;var o={},s=getComputedStyle(a,"");return t.each(n,(function(e,t){o[t]=a.style[i(t)]||s.getPropertyValue(t)})),o}}var l="";if("string"==L(n))r||0===r?l=F(n)+":"+U(n,r):this.each((function(){this.style.removeProperty(F(n))}));else for(e in n)n[e]||0===n[e]?l+=F(e)+":"+U(e,n[e])+";":this.each((function(){this.style.removeProperty(F(e))}));return this.each((function(){this.style.cssText+=";"+l}))},index:function(e){return e?this.indexOf(t(e)[0]):this.parent().children().indexOf(this[0])},hasClass:function(e){return!!e&&a.some.call(this,(function(e){return this.test($(e))}),B(e))},addClass:function(e){return e?this.each((function(i){if("className"in this){n=[];var r=$(this);Y(this,e,i,r).split(/\s+/g).forEach((function(e){t(this).hasClass(e)||n.push(e)}),this),n.length&&$(this,r+(r?" ":"")+n.join(" "))}})):this},removeClass:function(e){return this.each((function(t){if("className"in this){if(void 0===e)return $(this,"");n=$(this),Y(this,e,t,n).split(/\s+/g).forEach((function(e){n=n.replace(B(e)," ")})),$(this,n.trim())}}))},toggleClass:function(e,n){return e?this.each((function(i){var r=t(this);Y(this,e,i,$(this)).split(/\s+/g).forEach((function(e){(void 0===n?!r.hasClass(e):n)?r.addClass(e):r.removeClass(e)}))})):this},scrollTop:function(e){if(this.length){var t="scrollTop"in this[0];return void 0===e?t?this[0].scrollTop:this[0].pageYOffset:this.each(t?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var t="scrollLeft"in this[0];return void 0===e?t?this[0].scrollLeft:this[0].pageXOffset:this.each(t?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var e=this[0],n=this.offsetParent(),i=this.offset(),r=v.test(n[0].nodeName)?{top:0,left:0}:n.offset();return i.top-=parseFloat(t(e).css("margin-top"))||0,i.left-=parseFloat(t(e).css("margin-left"))||0,r.top+=parseFloat(t(n[0]).css("border-top-width"))||0,r.left+=parseFloat(t(n[0]).css("border-left-width"))||0,{top:i.top-r.top,left:i.left-r.left}}},offsetParent:function(){return this.map((function(){for(var e=this.offsetParent||u.body;e&&!v.test(e.nodeName)&&"static"==t(e).css("position");)e=e.offsetParent;return e}))}},t.fn.detach=t.fn.remove,["width","height"].forEach((function(e){var n=e.replace(/./,(function(e){return e[0].toUpperCase()}));t.fn[e]=function(i){var r,a=this[0];return void 0===i?I(a)?a["inner"+n]:P(a)?a.documentElement["scroll"+n]:(r=this.offset())&&r[e]:this.each((function(n){(a=t(this)).css(e,Y(this,i,n,a[e]()))}))}})),["after","prepend","before","append"].forEach((function(e,n){var i=n%2;t.fn[e]=function(){var e,r,a=t.map(arguments,(function(n){var i=[];return"array"==(e=L(n))?(n.forEach((function(e){return void 0!==e.nodeType?i.push(e):t.zepto.isZ(e)?i=i.concat(e.get()):void(i=i.concat(C.fragment(e)))})),i):"object"==e||null==n?n:C.fragment(n)})),o=this.length>1;return a.length<1?this:this.each((function(e,s){r=i?s:s.parentNode,s=0==n?s.nextSibling:1==n?s.firstChild:2==n?s:null;var l=t.contains(u.documentElement,r);a.forEach((function(e){if(o)e=e.cloneNode(!0);else if(!r)return t(e).remove();r.insertBefore(e,s),l&&W(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)}}))}))}))},t.fn[i?e+"To":"insert"+(n?"Before":"After")]=function(n){return t(n)[e](this),this}})),C.Z.prototype=V.prototype=t.fn,C.uniq=r,C.deserializeValue=z,t.zepto=C,t}();window.Zepto=_,void 0===window.$&&(window.$=_),function(e){var t,n,i=+new Date,r=window.document,a=/)<[^<]*)*<\/script>/gi,o=/^(?:text|application)\/javascript/i,s=/^(?:text|application)\/xml/i,l=/^\s*$/,u=r.createElement("a");function c(t,n,i,a){if(t.global)return function(t,n,i){var r=e.Event(n);return e(t).trigger(r,i),!r.isDefaultPrevented()}(n||r,i,a)}function d(e,t){var n=t.context;if(!1===t.beforeSend.call(n,e,t)||!1===c(t,n,"ajaxBeforeSend",[e,t]))return!1;c(t,n,"ajaxSend",[e,t])}function h(e,t,n,i){var r=n.context;n.success.call(r,e,"success",t),i&&i.resolveWith(r,[e,"success",t]),c(n,r,"ajaxSuccess",[t,n,e]),p("success",t,n)}function f(e,t,n,i,r){var a=i.context;i.error.call(a,n,t,e),r&&r.rejectWith(a,[n,t,e]),c(i,a,"ajaxError",[n,i,e||t]),p(t,n,i)}function p(t,n,i){var r=i.context;i.complete.call(r,n,t),c(i,r,"ajaxComplete",[n,i]),function(t){t.global&&!--e.active&&c(t,null,"ajaxStop")}(i)}function g(){}function v(e,t){return""==t?e:(e+"&"+t).replace(/[&?]{1,2}/,"?")}function m(t,n,i,r){return e.isFunction(n)&&(r=i,i=n,n=void 0),e.isFunction(i)||(r=i,i=void 0),{url:t,data:n,success:i,dataType:r}}u.href=window.location.href,e.active=0,e.ajaxJSONP=function(t,n){if(!("type"in t))return e.ajax(t);var a,o,s=t.jsonpCallback,l=(e.isFunction(s)?s():s)||"Zepto"+i++,u=r.createElement("script"),c=window[l],p=function(t){e(u).triggerHandler("error",t||"abort")},g={abort:p};return n&&n.promise(g),e(u).on("load error",(function(i,r){clearTimeout(o),e(u).off().remove(),"error"!=i.type&&a?h(a[0],g,t,n):f(null,r||"error",g,t,n),window[l]=c,a&&e.isFunction(c)&&c(a[0]),c=a=void 0})),!1===d(g,t)?(p("abort"),g):(window[l]=function(){a=arguments},u.src=t.url.replace(/\?(.+)=\?/,"?$1="+l),r.head.appendChild(u),t.timeout>0&&(o=setTimeout((function(){p("timeout")}),t.timeout)),g)},e.ajaxSettings={type:"GET",beforeSend:g,success:g,error:g,complete:g,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:"application/json",xml:"application/xml, text/xml",html:"text/html",text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:g},e.ajax=function(i){var a,p,m=e.extend({},i||{}),y=e.Deferred&&e.Deferred();for(t in e.ajaxSettings)void 0===m[t]&&(m[t]=e.ajaxSettings[t]);!function(t){t.global&&0==e.active++&&c(t,null,"ajaxStart")}(m),m.crossDomain||((a=r.createElement("a")).href=m.url,a.href=a.href,m.crossDomain=u.protocol+"//"+u.host!=a.protocol+"//"+a.host),m.url||(m.url=window.location.toString()),(p=m.url.indexOf("#"))>-1&&(m.url=m.url.slice(0,p)),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=v(t.url,t.data),t.data=void 0)}(m);var A=m.dataType,b=/\?.+=\?/.test(m.url);if(b&&(A="jsonp"),!1!==m.cache&&(i&&!0===i.cache||"script"!=A&&"jsonp"!=A)||(m.url=v(m.url,"_="+Date.now())),"jsonp"==A)return b||(m.url=v(m.url,m.jsonp?m.jsonp+"=?":!1===m.jsonp?"":"callback=?")),e.ajaxJSONP(m,y);var E,T=m.accepts[A],k={},_=function(e,t){k[e.toLowerCase()]=[e,t]},S=/^([\w-]+:)\/\//.test(m.url)?RegExp.$1:window.location.protocol,C=m.xhr(),R=C.setRequestHeader;if(y&&y.promise(C),m.crossDomain||_("X-Requested-With","XMLHttpRequest"),_("Accept",T||"*/*"),(T=m.mimeType||T)&&(T.indexOf(",")>-1&&(T=T.split(",",2)[0]),C.overrideMimeType&&C.overrideMimeType(T)),(m.contentType||!1!==m.contentType&&m.data&&"GET"!=m.type.toUpperCase())&&_("Content-Type",m.contentType||"application/x-www-form-urlencoded"),m.headers)for(n in m.headers)_(n,m.headers[n]);if(C.setRequestHeader=_,C.onreadystatechange=function(){if(4==C.readyState){C.onreadystatechange=g,clearTimeout(E);var t,n=!1;if(C.status>=200&&C.status<300||304==C.status||0==C.status&&"file:"==S){if(A=A||function(e){return e&&(e=e.split(";",2)[0]),e&&("text/html"==e?"html":"application/json"==e?"json":o.test(e)?"script":s.test(e)&&"xml")||"text"}(m.mimeType||C.getResponseHeader("content-type")),"arraybuffer"==C.responseType||"blob"==C.responseType)t=C.response;else{t=C.responseText;try{t=function(e,t,n){if(n.dataFilter==g)return e;var i=n.context;return n.dataFilter.call(i,e,t)}(t,A,m),"script"==A?(0,eval)(t):"xml"==A?t=C.responseXML:"json"==A&&(t=l.test(t)?null:e.parseJSON(t))}catch(e){n=e}if(n)return f(n,"parsererror",C,m,y)}h(t,C,m,y)}else f(C.statusText||null,C.status?"error":"abort",C,m,y)}},!1===d(C,m))return C.abort(),f(null,"abort",C,m,y),C;var w=!("async"in m)||m.async;if(C.open(m.type,m.url,w,m.username,m.password),m.xhrFields)for(n in m.xhrFields)C[n]=m.xhrFields[n];for(n in k)R.apply(C,k[n]);return m.timeout>0&&(E=setTimeout((function(){C.onreadystatechange=g,C.abort(),f(null,"timeout",C,m,y)}),m.timeout)),C.send(m.data?m.data:null),C},e.get=function(){return e.ajax(m.apply(null,arguments))},e.post=function(){var t=m.apply(null,arguments);return t.type="POST",e.ajax(t)},e.getJSON=function(){var t=m.apply(null,arguments);return t.dataType="json",e.ajax(t)},e.fn.load=function(t,n,i){if(!this.length)return this;var r,o=this,s=t.split(/\s/),l=m(t,n,i),u=l.success;return s.length>1&&(l.url=s[0],r=s[1]),l.success=function(t){o.html(r?e("
").html(t.replace(a,"")).find(r):t),u&&u.apply(o,arguments)},e.ajax(l),this};var y=encodeURIComponent;e.param=function(t,n){var i=[];return i.add=function(t,n){e.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(y(t)+"="+y(n))},function t(n,i,r,a){var o,s=e.isArray(i),l=e.isPlainObject(i);e.each(i,(function(i,u){o=e.type(u),a&&(i=r?a:a+"["+(l||"object"==o||"array"==o?i:"")+"]"),!a&&s?n.add(u.name,u.value):"array"==o||!r&&"object"==o?t(n,u,r,i):n.add(i,u)}))}(i,t,n),i.join("&").replace(/%20/g,"+")}}(_),(T=_).Callbacks=function(e){e=T.extend({},e);var t,n,i,r,a,o,s=[],l=!e.once&&[],u=function(d){for(t=e.memory&&d,n=!0,o=r||0,r=0,a=s.length,i=!0;s&&o-1;)s.splice(n,1),i&&(n<=a&&--a,n<=o&&--o)})),this},has:function(e){return!(!s||!(e?T.inArray(e,s)>-1:s.length))},empty:function(){return a=s.length=0,this},disable:function(){return s=l=t=void 0,this},disabled:function(){return!s},lock:function(){return l=void 0,t||c.disable(),this},locked:function(){return!l},fireWith:function(e,t){return!s||n&&!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!!n}};return c},function(e){var t=Array.prototype.slice;function n(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})]],r="pending",a={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},then:function(){var t=arguments;return n((function(n){e.each(i,(function(i,r){var s=e.isFunction(t[i])&&t[i];o[r[1]]((function(){var t=s&&s.apply(this,arguments);if(t&&e.isFunction(t.promise))t.promise().done(n.resolve).fail(n.reject).progress(n.notify);else{var i=this===a?n.promise():this,o=s?[t]:arguments;n[r[0]+"With"](i,o)}}))})),t=null})).promise()},promise:function(t){return null!=t?e.extend(t,a):a}},o={};return e.each(i,(function(e,t){var n=t[2],s=t[3];a[t[1]]=n.add,s&&n.add((function(){r=s}),i[1^e][2].disable,i[2][2].lock),o[t[0]]=function(){return o[t[0]+"With"](this===o?a:this,arguments),this},o[t[0]+"With"]=n.fireWith})),a.promise(o),t&&t.call(o,o),o}e.when=function(i){var r,a,o,s=t.call(arguments),l=s.length,u=0,c=1!==l||i&&e.isFunction(i.promise)?l:0,d=1===c?i:n(),h=function(e,n,i){return function(a){n[e]=this,i[e]=arguments.length>1?t.call(arguments):a,i===r?d.notifyWith(n,i):--c||d.resolveWith(n,i)}};if(l>1)for(r=new Array(l),a=new Array(l),o=new Array(l);u-1)return this},has:function(e,n,i){if(t.qsa(this,i).length)return this}},o=new RegExp("(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*"),s=/^\s*>/,l="Zepto"+ +new Date;function u(e,t){e=e.replace(/=#\]/g,'="#"]');var n,i,r=o.exec(e);if(r&&r[2]in a&&(n=a[r[2]],i=r[3],e=r[1],i)){var s=Number(i);i=isNaN(s)?i.replace(/^["']|["']$/g,""):s}return t(e,n,i)}t.qsa=function(i,r){return u(r,(function(a,o,u){try{var c;!a&&o?a="*":s.test(a)&&(c=e(i).addClass(l),a="."+l+" "+a);var d=n(i,a)}catch(e){throw console.error("error performing selector: %o",r),e}finally{c&&c.removeClass(l)}return o?t.uniq(e.map(d,(function(e,t){return o.call(e,t,d,u)}))):d}))},t.matches=function(e,t){return u(t,(function(t,n,r){return(!t||i(e,t))&&(!n||n.call(e,null,r)===e)}))}}(_);var S,C,R,w=_,O=[{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.]*)"}],L=[{name:"Windows 2000",group:"Windows",identifier:"Windows NT 5.0",version:"5.0"},{name:"Windows XP",group:"Windows",identifier:"Windows NT 5.1",version:"5.1"},{name:"Windows Vista",group:"Windows",identifier:"Windows NT 6.0",version:"6.0"},{name:"Windows 7",group:"Windows",identifier:"Windows NT 6.1",version:"7.0"},{name:"Windows 8",group:"Windows",identifier:"Windows NT 6.2",version:"8.0"},{name:"Windows 8.1",group:"Windows",identifier:"Windows NT 6.3",version:"8.1"},{name:"Windows 10",group:"Windows",identifier:"Windows NT 10.0",version:"10.0"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone ([0-9.]*)"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone OS ([0-9.]*)"},{name:"Windows",group:"Windows",identifier:"Windows"},{name:"Chrome OS",group:"Chrome OS",identifier:"CrOS"},{name:"Android",group:"Android",identifier:"Android",versionIdentifier:"Android ([a-zA-Z0-9.-]*)"},{name:"iPad",group:"iOS",identifier:"iPad",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPod",group:"iOS",identifier:"iPod",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPhone",group:"iOS",identifier:"iPhone OS",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"Mac OS X High Sierra",group:"Mac OS",identifier:"Mac OS X (10([_|.])13([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Sierra",group:"Mac OS",identifier:"Mac OS X (10([_|.])12([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X El Capitan",group:"Mac OS",identifier:"Mac OS X (10([_|.])11([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Yosemite",group:"Mac OS",identifier:"Mac OS X (10([_|.])10([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mavericks",group:"Mac OS",identifier:"Mac OS X (10([_|.])9([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mountain Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])8([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])7([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Snow Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])6([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])5([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Tiger",group:"Mac OS",identifier:"Mac OS X (10([_|.])4([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Panther",group:"Mac OS",identifier:"Mac OS X (10([_|.])3([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Jaguar",group:"Mac OS",identifier:"Mac OS X (10([_|.])2([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Puma",group:"Mac OS",identifier:"Mac OS X (10([_|.])1([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Cheetah",group:"Mac OS",identifier:"Mac OS X (10([_|.])0([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS",group:"Mac OS",identifier:"Mac OS"},{name:"Ubuntu",group:"Linux",identifier:"Ubuntu",versionIdentifier:"Ubuntu/([0-9.]*)"},{name:"Debian",group:"Linux",identifier:"Debian"},{name:"Gentoo",group:"Linux",identifier:"Gentoo"},{name:"Linux",group:"Linux",identifier:"Linux"},{name:"BlackBerry",group:"BlackBerry",identifier:"BlackBerry"}],D={},I=function(e,t){var n=e.split(".",2);t.fullVersion=e,n[0]&&(t.majorVersion=parseInt(n[0])),n[1]&&(t.minorVersion=parseInt(n[1]))},P=function(e,t,n){var i="["==t.substr(0,1)?new RegExp(t,"g"):t,r=e.split(i,2);"."!=t&&(e=e.replace(new RegExp(t,"g"),".")),n.fullVersion=e,r&&r[0]&&(n.majorVersion=parseInt(r[0])),r&&r[1]&&(n.minorVersion=parseInt(r[1]))},x=function(e){var t,n=e.match(/\b(playstation 4|nx|opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(n[1]))return t=/\brv[ :]+(\d+)/g.exec(e)||[],{name:"IE",version:parseInt(t[1]||"")};if("Chrome"===n[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))&&(n.splice(1,1,"Android WebView"),n.splice(2,1,t[1]));return{name:(n=n[2]?[n[1],n[2]]:[navigator.appName,navigator.appVersion,"-?"])[0],version:parseInt(n[1])}}(navigator.userAgent);D.isEdge=/edge/i.test(navigator.userAgent),D.isChrome=/chrome|CriOS/i.test(navigator.userAgent)&&!D.isEdge,D.isSafari=/safari/i.test(navigator.userAgent)&&!D.isChrome&&!D.isEdge,D.isFirefox=/firefox/i.test(navigator.userAgent),D.isLegacyIE=!!window.ActiveXObject,D.isIE=D.isLegacyIE||/trident.*rv:1\d/i.test(navigator.userAgent),D.isIE11=/trident.*rv:11/i.test(navigator.userAgent),D.isChromecast=D.isChrome&&/CrKey/i.test(navigator.userAgent),D.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone|IEMobile|Mobile Safari|Opera Mini/i.test(navigator.userAgent),D.isiOS=/iPad|iPhone|iPod/i.test(navigator.userAgent),D.isAndroid=/Android/i.test(navigator.userAgent),D.isWindowsPhone=/Windows Phone/i.test(navigator.userAgent),D.isWin8App=/MSAppHost/i.test(navigator.userAgent),D.isWiiU=/WiiU/i.test(navigator.userAgent),D.isPS4=/PlayStation 4/i.test(navigator.userAgent),D.hasLocalstorage=function(){try{return localStorage.setItem("clappr","clappr"),localStorage.removeItem("clappr"),!0}catch(e){return!1}}(),D.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)}}(),D.name=x.name,D.version=x.version,D.userAgent=navigator.userAgent,D.data=function(){var e,t={},n=D.userAgent.toLowerCase(),i=E(O);try{for(i.s();!(e=i.n()).done;){var r=e.value,a=new RegExp(r.identifier.toLowerCase()).exec(n);if(null!=a&&a[1]){if(t.name=r.name,t.group=r.group,r.versionIdentifier){var o=new RegExp(r.versionIdentifier.toLowerCase()).exec(n);null!=o&&o[1]&&I(o[1],t)}else I(a[1],t);break}}}catch(e){i.e(e)}finally{i.f()}return t}(),D.os=function(){var e,t={},n=D.userAgent.toLowerCase(),i=E(L);try{for(i.s();!(e=i.n()).done;){var r=e.value,a=new RegExp(r.identifier.toLowerCase()).exec(n);if(null!=a){if(t.name=r.name,t.group=r.group,r.version)P(r.version,r.versionSeparator?r.versionSeparator:".",t);else if(a[1])P(a[1],r.versionSeparator?r.versionSeparator:".",t);else if(r.versionIdentifier){var o=new RegExp(r.versionIdentifier.toLowerCase()).exec(n);null!=o&&o[1]&&P(o[1],r.versionSeparator?r.versionSeparator:".",t)}break}}}catch(e){i.e(e)}finally{i.f()}return t}(),D.viewport=((S={}).width=w(window).width(),S.height=w(window).height(),S),D.device=(C=D.userAgent,(R=/\((iP(?:hone|ad|od))?(?:[^;]*; ){0,2}([^)]+(?=\)))/.exec(C))&&(R[1]||R[2])||""),void 0!==window.orientation&&function(){switch(window.orientation){case-90:case 90:D.viewport.orientation="landscape";break;default:D.viewport.orientation="portrait"}}();var N={},M=[],F=(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){window.setTimeout(e,1e3/60)}).bind(window),B=(window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.clearTimeout).bind(window);function U(e,t){if(t)for(var n in t){var i=Object.getOwnPropertyDescriptor(t,n);i?Object.defineProperty(e,n,i):e[n]=t[n]}return e}function j(e,t){var n=function(e){c(i,e);var n=g(i);function i(){var e;r(this,i);for(var a=arguments.length,o=new Array(a),s=0;s0&&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)}},K=function(){function e(){r(this,e)}return o(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 D.hasLocalstorage&&localStorage[this._createKeyspace(e)]?this._defaultConfig()[e].parse(localStorage[this._createKeyspace(e)]):this._defaultValueFor(e)}},{key:"persist",value:function(e,t){if(D.hasLocalstorage)try{return localStorage[this._createKeyspace(e)]=t,!0}catch(e){return!1}}}]),e}(),G=function(){function e(){r(this,e)}return o(e,null,[{key:"parse",value:function(e){for(var t,n=/\+/g,i=/([^&=]+)=?([^&]*)/g,r=function(e){return decodeURIComponent(e.replace(n," "))},a={};t=i.exec(e);)a[r(t[1]).toLowerCase()]=r(t[2]);return a}},{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}}]),e}();function Y(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"t",t=0,n=G.params[e]||G.hashParams[e]||"",i=n.match(/[0-9]+[hms]+/g)||[];if(i.length>0){var r={h:3600,m:60,s:1};i.forEach((function(e){if(e){var n=e[e.length-1],i=parseInt(e.slice(0,e.length-1),10);t+=i*r[n]}}))}else n&&(t=parseInt(n,10));return t}function H(e){return N[e]||(N[e]=0),e+ ++N[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 W(){return window.navigator&&window.navigator.language}function q(e,t){var n=(t=Object.assign({inline:!1,muted:!1,timeout:250,type:"video",source:k.mp4,element:null},t)).element?t.element:document.createElement(t.type);n.muted=t.muted,!0===t.muted&&n.setAttribute("muted","muted"),!0===t.inline&&n.setAttribute("playsinline","playsinline"),n.src=t.source;var i=n.play(),r=setTimeout((function(){a(!1,new Error("Timeout ".concat(t.timeout," ms has been reached")))}),t.timeout),a=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;clearTimeout(r),e(t,n)};void 0!==i?i.then((function(){return a(!0)})).catch((function(e){return a(!1,e)})):a(!0)}var X=function(){function e(){r(this,e)}return o(e,null,[{key:"configure",value:function(e){this.options=w.extend(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()&&(w(e).children().remove(),Object.values(e.attributes).forEach((function(t){return e.removeAttribute(t.name)})),M.push(e))}}]),e}();X.options={recycleVideo:!1};var Z=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:500;r(this,e),this.delay=t,this.lastTime=0}return o(e,[{key:"handle",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=(new Date).getTime(),r=i-this.lastTime;r0&&(t(),n&&e.preventDefault()),this.lastTime=i}}]),e}(),Q={Config:K,Fullscreen:V,QueryString:G,DomRecycler:X,assign:U,extend:j,formatTime:function(e,t){if(!isFinite(e))return"--:--";e*=1e3;var n=(e=parseInt(e/1e3))%60,i=(e=parseInt(e/60))%60,r=(e=parseInt(e/60))%24,a=parseInt(e/24),o="";return a&&a>0&&(o+=a+":",r<1&&(o+="00:")),(r&&r>0||t)&&(o+=("0"+r).slice(-2)+":"),o+=("0"+i).slice(-2)+":",(o+=("0"+n).slice(-2)).trim()},seekStringToSeconds:Y,uniqueId:H,currentScriptUrl:z,isNumber:$,requestAnimationFrame:F,cancelAnimationFrame:B,getBrowserLanguage:W,now:function(){return window.performance&&window.performance.now?performance.now():Date.now()},removeArrayItem:function(e,t){var n=e.indexOf(t);n>=0&&e.splice(n,1)},listContainsIgnoreCase:function(e,t){return void 0!==e&&void 0!==t&&void 0!==t.find((function(t){return e.toLowerCase()===t.toLowerCase()}))},canAutoPlayMedia:q,Media:k,DoubleEventHandler:Z},J="font-weight: bold; font-size: 13px;",ee="color: #ff8000;"+J,te="color: #ff0000;"+J,ne=["color: #0000ff;font-weight: bold; font-size: 13px;","color: #006600;font-weight: bold; font-size: 13px;",ee,te,te],ie=["debug","info","warn","error","disabled"],re=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;r(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=n}return o(e,[{key:"level",get:function(){return this._level},set:function(e){this._level=e}}]),o(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 "+ie[this.level],ee)}},{key:"log",value:function(e,t,n){if(!(this.EXCLUDE_LIST.indexOf(n[0])>=0||t0&&void 0!==arguments[0]?arguments[0]:{};return r(this,n),(e=t.call(this,i))._options=i,e.uniqueId=H("o"),e}return o(n,[{key:"options",get:function(){return this._options}}]),n}(ue),he=/^(\S+)\s*(.*)$/,fe=function(e){c(n,e);var t=g(n);function n(e){var i;return r(this,n),(i=t.call(this,e)).cid=H("c"),i._ensureElement(),i.delegateEvents(),i}return o(n,[{key:"tagName",get:function(){return"div"}},{key:"events",get:function(){return{}}},{key:"attributes",get:function(){return{}}}]),o(n,[{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=w.zepto.isZ(e)?e:w(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 n=e[t];if(n&&n.constructor!==Function&&(n=this[e[t]]),n){var i=t.match(he),r=i[1],a=i[2];r+=".delegateEvents"+this.cid,""===a?this.$el.on(r,n.bind(this)):this.$el.on(r,a,n.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=w.extend({},this.attributes);this.id&&(e.id=this.id),this.className&&(e.class=this.className);var t=w(X.create(this.tagName)).attr(e);this.setElement(t,!1)}}}]),n}(de),pe=function(e){c(n,e);var t=g(n);function n(){var e,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=arguments.length>1?arguments[1]:void 0;return r(this,n),(e=t.call(this,i)).core=a,e}return o(n,[{key:"name",get:function(){return"error"}}],[{key:"Levels",get:function(){return{FATAL:"FATAL",WARN:"WARN",INFO:"INFO"}}}]),o(n,[{key:"createError",value:function(e){this.core?this.core.trigger(ue.ERROR,e):re.warn(this.name,"Core is not set. Error: ",e)}}]),n}(de),ge={createError:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{useCodePrefix:!0},n=this.constructor&&this.constructor.type||"",i=this.name||n,r=this.i18n||this.core&&this.core.i18n||this.container&&this.container.i18n,a="".concat(i,":").concat(e&&e.code||"unknown"),o={description:"",level:pe.Levels.FATAL,origin:i,scope:n,raw:{}},s=Object.assign({},o,e,{code:t.useCodePrefix?a:e.code});if(r&&s.level==pe.Levels.FATAL&&!s.UI){var l={title:r.t("default_error_title"),message:r.t("default_error_message")};s.UI=l}return this.playerError?this.playerError.createError(s):re.warn(i,"PlayerError is not defined. Error: ",s),s}},ve=function(e){c(n,e);var t=g(n);function n(e){var i;return r(this,n),(i=t.call(this,e.options)).core=e,i.enabled=!0,i.bindEvents(),i.render(),i}return o(n,[{key:"playerError",get:function(){return this.core.playerError}}]),o(n,[{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}}]),n}(fe);function me(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}Object.assign(ve.prototype,ge),ve.extend=function(e){return j(ve,e)},ve.type="core";me(".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");var ye=function(e){c(n,e);var t=g(n);function n(e,i,a){var o;return r(this,n),(o=t.call(this,e))._i18n=i,o.currentTime=0,o.volume=100,o.playback=e.playback,o.playerError=a,o.settings=w.extend({},o.playback.settings),o.isReady=!1,o.mediaControlDisabled=!1,o.plugins=[o.playback],o.dblTapHandler=new Z(500),o.clickTimer=null,o.clickDelay=200,o.bindEvents(),o}return o(n,[{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"}}},{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}}]),o(n,[{key:"bindEvents",value:function(){this.listenTo(this.playback,ue.PLAYBACK_PROGRESS,this.onProgress),this.listenTo(this.playback,ue.PLAYBACK_TIMEUPDATE,this.timeUpdated),this.listenTo(this.playback,ue.PLAYBACK_READY,this.ready),this.listenTo(this.playback,ue.PLAYBACK_BUFFERING,this.onBuffering),this.listenTo(this.playback,ue.PLAYBACK_BUFFERFULL,this.bufferfull),this.listenTo(this.playback,ue.PLAYBACK_SETTINGSUPDATE,this.settingsUpdate),this.listenTo(this.playback,ue.PLAYBACK_LOADEDMETADATA,this.loadedMetadata),this.listenTo(this.playback,ue.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinitionUpdate),this.listenTo(this.playback,ue.PLAYBACK_BITRATE,this.updateBitrate),this.listenTo(this.playback,ue.PLAYBACK_PLAYBACKSTATE,this.playbackStateChanged),this.listenTo(this.playback,ue.PLAYBACK_DVR,this.playbackDvrStateChanged),this.listenTo(this.playback,ue.PLAYBACK_MEDIACONTROL_DISABLE,this.disableMediaControl),this.listenTo(this.playback,ue.PLAYBACK_MEDIACONTROL_ENABLE,this.enableMediaControl),this.listenTo(this.playback,ue.PLAYBACK_SEEKED,this.onSeeked),this.listenTo(this.playback,ue.PLAYBACK_ENDED,this.onEnded),this.listenTo(this.playback,ue.PLAYBACK_PLAY,this.playing),this.listenTo(this.playback,ue.PLAYBACK_PAUSE,this.paused),this.listenTo(this.playback,ue.PLAYBACK_STOP,this.stopped),this.listenTo(this.playback,ue.PLAYBACK_ERROR,this.error),this.listenTo(this.playback,ue.PLAYBACK_SUBTITLE_AVAILABLE,this.subtitleAvailable),this.listenTo(this.playback,ue.PLAYBACK_SUBTITLE_CHANGED,this.subtitleChanged)}},{key:"subtitleAvailable",value:function(){this.trigger(ue.CONTAINER_SUBTITLE_AVAILABLE)}},{key:"subtitleChanged",value:function(e){this.trigger(ue.CONTAINER_SUBTITLE_CHANGED,e)}},{key:"playbackStateChanged",value:function(e){this.trigger(ue.CONTAINER_PLAYBACKSTATE,e)}},{key:"playbackDvrStateChanged",value:function(e){this.settings=this.playback.settings,this.dvrInUse=e,this.trigger(ue.CONTAINER_PLAYBACKDVRSTATECHANGED,e)}},{key:"updateBitrate",value:function(e){this.trigger(ue.CONTAINER_BITRATE,e)}},{key:"statsReport",value:function(e){this.trigger(ue.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(ue.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(ue.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(ue.CONTAINER_ERROR,e,this.name)}},{key:"loadedMetadata",value:function(e){this.trigger(ue.CONTAINER_LOADEDMETADATA,e)}},{key:"timeUpdated",value:function(e){this.currentTime=e.current,this.trigger(ue.CONTAINER_TIMEUPDATE,e,this.name)}},{key:"onProgress",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n=0&&e<=100){var n=t*(e/100);this.seek(n)}}},{key:"setVolume",value:function(e){this.volume=parseFloat(e),this.trigger(ue.CONTAINER_VOLUME,this.volume,this.name),this.playback.volume(this.volume)}},{key:"fullscreen",value:function(){this.trigger(ue.CONTAINER_FULLSCREEN,this.name)}},{key:"onBuffering",value:function(){this.trigger(ue.CONTAINER_STATE_BUFFERING,this.name)}},{key:"bufferfull",value:function(){this.trigger(ue.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(ue.CONTAINER_MOUSE_ENTER)}},{key:"mouseLeave",value:function(){this.options.chromeless&&!this.options.allowUserInteraction||this.trigger(ue.CONTAINER_MOUSE_LEAVE)}},{key:"settingsUpdate",value:function(){this.settings=this.playback.settings,this.trigger(ue.CONTAINER_SETTINGSUPDATE)}},{key:"highDefinitionUpdate",value:function(e){this.trigger(ue.CONTAINER_HIGHDEFINITIONUPDATE,e)}},{key:"isHighDefinitionInUse",value:function(){return this.playback.isHighDefinitionInUse()}},{key:"disableMediaControl",value:function(){this.mediaControlDisabled||(this.mediaControlDisabled=!0,this.trigger(ue.CONTAINER_MEDIACONTROL_DISABLE))}},{key:"enableMediaControl",value:function(){this.mediaControlDisabled&&(this.mediaControlDisabled=!1,this.trigger(ue.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||{},n=t.width;(t.height!==e.height||n!==e.width)&&(this.currentSize=e,this.trigger(ue.CONTAINER_RESIZE,e))}},{key:"configure",value:function(e){this._options=w.extend(this._options,e),this.updateStyle(),this.playback.configure(this.options),this.trigger(ue.CONTAINER_OPTIONS_CHANGE)}},{key:"render",value:function(){return this.$el.append(this.playback.render().el),this.updateStyle(),this.checkResize(),this.enableResizeObserver(),this}}]),n}(fe);Object.assign(ye.prototype,ge);var Ae=function(e){c(n,e);var t=g(n);function n(e,i,a){var o;return r(this,n),(o=t.call(this,e)).settings={},o._i18n=i,o.playerError=a,o._consented=!1,o}return o(n,[{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}}]),o(n,[{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:"getPlaybackType",value:function(){return n.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=w.extend(this._options,e)}},{key:"attemptAutoPlay",value:function(){var e=this;this.canAutoPlay((function(t,n){t&&e.play()}))}},{key:"canAutoPlay",value:function(e){e(!0,null)}},{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){}}]),n}(fe);Object.assign(Ae.prototype,ge),Ae.extend=function(e){return j(Ae,e)},Ae.canPlay=function(e,t){return!1},Ae.VOD="vod",Ae.AOD="aod",Ae.LIVE="live",Ae.NO_OP="no_op",Ae.type="playback";var be=function(e){c(n,e);var t=g(n);function n(e,i,a,o){var s;return r(this,n),(s=t.call(this,e))._i18n=a,s.loader=i,s.playerError=o,s}return o(n,[{key:"options",get:function(){return this._options},set:function(e){this._options=e}}]),o(n,[{key:"createContainers",value:function(){var e=this;return w.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(n){return n.canPlay(e,t)}))[0]}},{key:"createContainer",value:function(e){var t=null,n=this.options.mimeType;"object"===i(e)?(t=e.source.toString(),e.mimeType&&(n=e.mimeType)):t=e.toString(),t.match(/^\/\//)&&(t=window.location.protocol+t);var r=u(u({},this.options),{},{src:t,mimeType:n}),a=this.findPlaybackPlugin(t,n),o=a?new a(r,this._i18n,this.playerError):new Ae;r=u(u({},r),{},{playback:o});var s=new ye(r,this._i18n,this.playerError),l=w.Deferred();return l.promise(s),this.addContainerPlugins(s),this.listenToOnce(s,ue.CONTAINER_READY,(function(){return l.resolve(s)})),s}},{key:"addContainerPlugins",value:function(e){this.loader.containerPlugins.forEach((function(t){e.addPlugin(new t(e))}))}}]),n}(de);me('[data-player] {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-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] 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 [data-player] table {\n border-collapse: collapse;\n border-spacing: 0; }\n [data-player] caption, [data-player] th, [data-player] td {\n text-align: left;\n font-weight: normal;\n vertical-align: middle; }\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 [data-player] a img {\n border: none; }\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');var Ee=function(e){c(n,e);var t=g(n);function n(e){var i;return r(this,n),(i=t.call(this,e)).playerError=new pe(e,f(i)),i.configureDomRecycler(),i.firstResize=!0,i.plugins=[],i.containers=[],i._boundFullscreenHandler=function(){return i.handleFullscreenChange()},w(document).bind("fullscreenchange",i._boundFullscreenHandler),w(document).bind("MSFullscreenChange",i._boundFullscreenHandler),w(document).bind("mozfullscreenchange",i._boundFullscreenHandler),D.isMobile&&w(window).bind("resize",(function(e){i.handleWindowResize(e)})),i}return o(n,[{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 ve(this)),this._dummyMediaControl}},{key:"activeContainer",get:function(){return this._activeContainer},set:function(e){this._activeContainer=e,this.trigger(ue.CORE_ACTIVE_CONTAINER_CHANGED,this._activeContainer)}},{key:"activePlayback",get:function(){return this.activeContainer&&this.activeContainer.playback}}]),o(n,[{key:"configureDomRecycler",value:function(){var e=this.options&&this.options.playback&&this.options.playback.recycleVideo;X.configure({recycleVideo:e})}},{key:"createContainers",value:function(e){this.defer=w.Deferred(),this.defer.promise(this),this.containerFactory=new be(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(){D.isiOS||(this.$el.addClass("fullscreen"),this.$el.removeAttr("style"),this.previousSize={width:this.options.width,height:this.options.height},this.currentSize={width:w(window).width(),height:w(window).height()})}},{key:"setPlayerSize",value:function(){this.$el.removeClass("fullscreen"),this.currentSize=this.previousSize,this.previousSize={width:w(window).width(),height:w(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(ue.CORE_RESIZE,e))}},{key:"disableResizeObserver",value:function(){this.resizeObserverInterval&&clearInterval(this.resizeObserverInterval),this.resizeObserverInterval=null}},{key:"resolveOnContainersReady",value:function(e){var t=this;w.when.apply(w,e).done((function(){t.defer.resolve(t),t.ready=!0,t.trigger(ue.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=w.extend(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(),w(document).unbind("fullscreenchange",this._boundFullscreenHandler),w(document).unbind("MSFullscreenChange",this._boundFullscreenHandler),w(document).unbind("mozfullscreenchange",this._boundFullscreenHandler),this.stopListening()}},{key:"handleFullscreenChange",value:function(){this.trigger(ue.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(ue.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,ue.CONTAINER_DESTROYED,this.removeContainer),this.containers.push(e)}},{key:"setupContainers",value:function(e){return e.forEach(this.setupContainer.bind(this)),this.trigger(ue.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 n=this.containerFactory.createContainer(e,t);return this.setupContainer(n),this.el.appendChild(n.render().el),n}},{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=V.fullscreenElement();if(!e)return!1;var t=this.activePlayback&&this.activePlayback.el;return e===this.el||e===t}},{key:"toggleFullscreen",value:function(){var e=this;if(this.isFullscreen())V.cancelFullscreen(),!D.isiOS&&this.$el.removeClass("fullscreen nocursor");else{var t=D.isiOS?this.activePlayback&&this.activePlayback.el:this.el;if(!t)return;D.isSafari||D.isiOS?V.requestFullscreen(t):V.requestFullscreen(t).then((function(e){return e}),(function(t){return setTimeout((function(){if(!e.isFullscreen())throw new ReferenceError(t)}),600)})),!D.isiOS&&this.$el.addClass("fullscreen")}}},{key:"onMouseMove",value:function(e){this.trigger(ue.CORE_MOUSE_MOVE,e)}},{key:"onMouseLeave",value:function(e){this.trigger(ue.CORE_MOUSE_LEAVE,e)}},{key:"configure",value:function(e){var t=this;this._options=w.extend(this._options,e),this.configureDomRecycler();var n=e.source||e.sources;n&&this.load(n,e.mimeType||this.options.mimeType),this.trigger(ue.CORE_OPTIONS_CHANGE,e),this.containers.forEach((function(e){return e.configure(t.options)}))}},{key:"appendToParent",value:function(){!(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}}]),n}(fe);Object.assign(Ee.prototype,ge);var Te,ke=function(e){c(n,e);var t=g(n);function n(e){var i;return r(this,n),(i=t.call(this)).player=e,i._options=e.options,i}return o(n,[{key:"loader",get:function(){return this.player.loader}}]),o(n,[{key:"create",value:function(){return this.options.loader=this.loader,this.core=new Ee(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 n=new t(e.core);e.core.addPlugin(n),e.setupExternalInterface(n)})),this.core}},{key:"setupExternalInterface",value:function(e){var t=e.getExternalInterface();for(var n in t)this.player[n]=t[n].bind(e)}}]),n}(de),_e=/(\d+)(?:\.(\d+))?(?:\.(\d+))?/,Se=function(){function e(t,n,i){r(this,e),this.major=parseInt(t||0,10),this.minor=parseInt(n||0,10),this.patch=parseInt(i||0,10)}return o(e,null,[{key:"parse",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=t.match(_e)||[],i=m(n,4),r=i[1],a=i[2],o=i[3];return void 0===r?null:new e(r,a,o)}}]),o(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)}}]),e}(),Ce=function(e,t){return e&&t?Object.entries(e).filter((function(e){return m(e,2)[1].type===t})).reduce((function(e,t){var n=m(t,2),i=n[0],r=n[1];return e[i]=r,e}),{}):{}},Re=(Te={plugins:{},playbacks:[]},function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;r(this,e),this.playerId=n,this.playbackPlugins=y(Te.playbacks);var i=e.registeredPlugins,a=i.core,o=i.container;this.containerPlugins=Object.values(o),this.corePlugins=Object.values(a),Array.isArray(t)||this.validateExternalPluginsType(t),this.addExternalPlugins(t)}return o(e,null,[{key:"checkVersionSupport",value:function(e){var t=e.prototype,n=t.supportedVersion,i=t.name;if(!n||!n.min)return re.warn("Loader","missing version information for ".concat(i)),!1;var r=n.max?Se.parse(n.max):Se.parse(n.min).inc("minor"),a=Se.parse(n.min);return!!Se.parse("0.4.14").satisfies(a,r)||(re.warn("Loader","unsupported plugin ".concat(i,": Clappr version ").concat("0.4.14"," does not match required range [").concat(a,",").concat(r,")")),!1)}},{key:"registerPlugin",value:function(t){if(!t||!t.prototype.name)return re.warn("Loader","missing information to register plugin: ".concat(t)),!1;e.checkVersionSupport(t);var n=Te.plugins;if(!n)return!1;var i=n[t.prototype.name];return i&&re.warn("Loader","overriding plugin entry: ".concat(t.prototype.name," - ").concat(i)),n[t.prototype.name]=t,!0}},{key:"registerPlayback",value:function(t){if(!t||!t.prototype.name)return!1;e.checkVersionSupport(t);var n=Te.playbacks,i=n.findIndex((function(e){return e.prototype.name===t.prototype.name}));if(i>=0){var r=n[i];n.splice(i,1),re.warn("Loader","overriding playback entry: ".concat(r.name," - ").concat(r))}return Te.playbacks=[t].concat(y(n)),!0}},{key:"unregisterPlugin",value:function(e){if(!e)return!1;var t=Te.plugins;return!!t[e]&&(delete t[e],!0)}},{key:"unregisterPlayback",value:function(e){if(!e)return!1;var t=Te.playbacks,n=t.findIndex((function(t){return t.prototype.name===e}));return!(n<0||(t.splice(n,1),Te.playbacks=t,0))}},{key:"clearPlugins",value:function(){Te.plugins={}}},{key:"clearPlaybacks",value:function(){Te.playbacks=[]}},{key:"registeredPlaybacks",get:function(){return y(Te.playbacks)}},{key:"registeredPlugins",get:function(){var e=Te.plugins;return{core:Ce(e,"core"),container:Ce(e,"container")}}}]),o(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],n=function(e,n){return e[n.prototype.name]&&t||(e[n.prototype.name]&&delete e[n.prototype.name],e[n.prototype.name]=n),e},i=e.reduceRight(n,Object.create(null)),r=[];for(var a in i)r.unshift(i[a]);return r}},{key:"addExternalPlugins",value:function(t){var n="boolean"!=typeof t.loadExternalPluginsFirst||t.loadExternalPluginsFirst,i="boolean"!=typeof t.loadExternalPlaybacksFirst||t.loadExternalPlaybacksFirst;if((t=this.groupPluginsByType(t)).playback){var r=t.playback.filter((function(t){return e.checkVersionSupport(t),!0}));this.playbackPlugins=i?this.removeDups(r.concat(this.playbackPlugins)):this.removeDups(this.playbackPlugins.concat(r),!0)}if(t.container){var a=t.container.filter((function(t){return e.checkVersionSupport(t),!0}));this.containerPlugins=n?this.removeDups(a.concat(this.containerPlugins)):this.removeDups(this.containerPlugins.concat(a),!0)}if(t.core){var o=t.core.filter((function(t){return e.checkVersionSupport(t),!0}));this.corePlugins=n?this.removeDups(o.concat(this.corePlugins)):this.removeDups(this.corePlugins.concat(o),!0)}}},{key:"validateExternalPluginsType",value:function(e){["playback","container","core"].forEach((function(t){(e[t]||[]).forEach((function(e){var n="external "+e.type+" plugin on "+t+" array";if(e.type!==t)throw new ReferenceError(n)}))}))}}]),e}()),we=z().replace(/\/[^/]+$/,""),Oe=function(e){c(n,e);var t=g(n);function n(e){var i;r(this,n),i=t.call(this,e);var a={playerId:H(""),persistConfig:!0,width:640,height:360,baseUrl:we,allowUserInteraction:D.isMobile,playback:{recycleVideo:!0}};return i._options=w.extend(a,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 ke(f(i)),i.options.parentId?i.setParentId(i.options.parentId):i.options.parent&&i.attachTo(i.options.parent),i}return o(n,[{key:"loader",set:function(e){this._loader=e},get:function(){return this._loader||(this._loader=new Re(this.options.plugins||{},this.options.playerId)),this._loader}},{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:ue.PLAYER_READY,onResize:ue.PLAYER_RESIZE,onPlay:ue.PLAYER_PLAY,onPause:ue.PLAYER_PAUSE,onStop:ue.PLAYER_STOP,onEnded:ue.PLAYER_ENDED,onSeek:ue.PLAYER_SEEK,onError:ue.PLAYER_ERROR,onTimeUpdate:ue.PLAYER_TIMEUPDATE,onVolumeUpdate:ue.PLAYER_VOLUMEUPDATE,onSubtitleAvailable:ue.PLAYER_SUBTITLE_AVAILABLE}}}]),o(n,[{key:"setParentId",value:function(e){var t=document.querySelector(e);return t&&this.attachTo(t),this}},{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,ue.CORE_READY,this._onReady),this.listenTo(this.core,ue.CORE_ACTIVE_CONTAINER_CHANGED,this._containerChanged),this.listenTo(this.core,ue.CORE_FULLSCREEN,this._onFullscreenChange),this.listenTo(this.core,ue.CORE_RESIZE,this._onResize),this}},{key:"_addContainerEventListeners",value:function(){var e=this.core.activeContainer;return e&&(this.listenTo(e,ue.CONTAINER_PLAY,this._onPlay),this.listenTo(e,ue.CONTAINER_PAUSE,this._onPause),this.listenTo(e,ue.CONTAINER_STOP,this._onStop),this.listenTo(e,ue.CONTAINER_ENDED,this._onEnded),this.listenTo(e,ue.CONTAINER_SEEK,this._onSeek),this.listenTo(e,ue.CONTAINER_ERROR,this._onError),this.listenTo(e,ue.CONTAINER_TIMEUPDATE,this._onTimeUpdate),this.listenTo(e,ue.CONTAINER_VOLUME,this._onVolumeUpdate),this.listenTo(e,ue.CONTAINER_SUBTITLE_AVAILABLE,this._onSubtitleAvailable)),this}},{key:"_registerOptionEventListeners",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=Object.keys(t).length>0;return i&&Object.keys(n).forEach((function(t){var i=e.eventsMapping[t];i&&e.off(i,n[t])})),Object.keys(t).forEach((function(n){var i=e.eventsMapping[n];if(i){var r=t[n];(r="function"==typeof r&&r)&&e.on(i,r)}})),this}},{key:"_containerChanged",value:function(){this.stopListening(),this._addEventListeners()}},{key:"_onReady",value:function(){this._ready=!0,this._addContainerEventListeners(),this.trigger(ue.PLAYER_READY)}},{key:"_onFullscreenChange",value:function(e){this.trigger(ue.PLAYER_FULLSCREEN,e)}},{key:"_onVolumeUpdate",value:function(e){this.trigger(ue.PLAYER_VOLUMEUPDATE,e)}},{key:"_onSubtitleAvailable",value:function(){this.trigger(ue.PLAYER_SUBTITLE_AVAILABLE)}},{key:"_onResize",value:function(e){this.trigger(ue.PLAYER_RESIZE,e)}},{key:"_onPlay",value:function(){this.trigger(ue.PLAYER_PLAY)}},{key:"_onPause",value:function(){this.trigger(ue.PLAYER_PAUSE)}},{key:"_onStop",value:function(){this.trigger(ue.PLAYER_STOP,this.getCurrentTime())}},{key:"_onEnded",value:function(){this.trigger(ue.PLAYER_ENDED)}},{key:"_onSeek",value:function(e){this.trigger(ue.PLAYER_SEEK,e)}},{key:"_onTimeUpdate",value:function(e){this.trigger(ue.PLAYER_TIMEUPDATE,e)}},{key:"_onError",value:function(e){this.trigger(ue.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,n){return void 0!==n&&this.configure({autoPlay:!!n}),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(){return this.core.activeContainer.play(),this}},{key:"pause",value:function(){return this.core.activeContainer.pause(),this}},{key:"stop",value:function(){return this.core.activeContainer.stop(),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()}}]),n}(de);Object.assign(Oe.prototype,ge);var Le=function(e){c(n,e);var t=g(n);function n(e){var i;return r(this,n),(i=t.call(this,e.options)).container=e,i.enabled=!0,i.bindEvents(),i}return o(n,[{key:"playerError",get:function(){return this.container.playerError}}]),o(n,[{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()}}]),n}(de);Object.assign(Le.prototype,ge),Le.extend=function(e){return j(Le,e)},Le.type="container";var De=function(e){c(n,e);var t=g(n);function n(e){var i;return r(this,n),(i=t.call(this,e.options)).core=e,i.enabled=!0,i.bindEvents(),i}return o(n,[{key:"playerError",get:function(){return this.core.playerError}}]),o(n,[{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()}}]),n}(de);Object.assign(De.prototype,ge),De.extend=function(e){return j(De,e)},De.type="core";var Ie=function(e){c(n,e);var t=g(n);function n(e){var i;return r(this,n),(i=t.call(this,e.options)).container=e,i.enabled=!0,i.bindEvents(),i}return o(n,[{key:"playerError",get:function(){return this.container.playerError}}]),o(n,[{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(){}}]),n}(fe);Object.assign(Ie.prototype,ge),Ie.extend=function(e){return j(Ie,e)},Ie.type="container";var Pe={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},xe=/(.)^/,Ne={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},Me=/\\|'|\r|\n|\t|\u2028|\u2029/g,Fe={"&":"&","<":"<",">":">",'"':""","'":"'"},Be=new RegExp("[&<>\"']","g"),Ue=function(e){return null===e?"":(""+e).replace(Be,(function(e){return Fe[e]}))},je=0,Ve=function(e,t){var n,i=new RegExp([(Pe.escape||xe).source,(Pe.interpolate||xe).source,(Pe.evaluate||xe).source].join("|")+"|$","g"),r=0,a="__p+='";e.replace(i,(function(t,n,i,o,s){return a+=e.slice(r,s).replace(Me,(function(e){return"\\"+Ne[e]})),n&&(a+="'+\n((__t=("+n+"))==null?'':escapeExpr(__t))+\n'"),i&&(a+="'+\n((__t=("+i+"))==null?'':__t)+\n'"),o&&(a+="';\n"+o+"\n__p+='"),r=s+t.length,t})),a+="';\n",Pe.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["+je+++"]";try{n=new Function(Pe.variable||"obj","escapeExpr",a)}catch(e){throw e.source=a,e}if(t)return n(t,Ue);var o=function(e){return n.call(this,e,Ue)};return o.source="function("+(Pe.variable||"obj")+"){\n"+a+"}",o};Ve.settings=Pe;me("[data-html5-video] {\n position: absolute;\n height: 100%;\n width: 100%;\n display: block; }\n");var Ke={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"]};Ke.ogv=Ke.ogg,Ke["3gp"]=Ke["3gpp"];var Ge={wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},Ye=Object.keys(Ge).reduce((function(e,t){return[].concat(y(e),y(Ge[t]))}),[]),He={code:"unknown",message:"unknown"},$e=function(e){c(n,e);var t=g(n);function n(){var e;r(this,n);for(var i=arguments.length,a=new Array(i),o=0;o=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()===Ae.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}}]),o(n,[{key:"configure",value:function(e){v(d(n.prototype),"configure",this).call(this,e),this.el.loop=!!e.loop}},{key:"attemptAutoPlay",value:function(){var e=this;this.canAutoPlay((function(t,n){n&&re.warn(e.name,"autoplay error.",{result:t,error:n}),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};D.isMobile&&X.options.recycleVideo&&(t.element=this.el),q(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(ue.PLAYBACK_LOADEDMETADATA,{duration:e.target.duration,data:e}),this._updateSettings();var t=void 0===this._options.autoSeekFromUrl||this._options.autoSeekFromUrl;this.getPlaybackType()!==Ae.LIVE&&t&&this._checkInitialSeek()}},{key:"_onDurationChange",value:function(){this._updateSettings(),this._onTimeUpdate(),this._onProgress()}},{key:"_updateSettings",value:function(){this.getPlaybackType()===Ae.VOD||this.getPlaybackType()===Ae.AOD?this.settings.left=["playpause","position","duration"]:this.settings.left=["playstop"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(ue.PLAYBACK_SETTINGSUPDATE)}},{key:"isSeekEnabled",value:function(){return isFinite(this.getDuration())}},{key:"getPlaybackType",value:function(){var e="audio"===this.tagName?Ae.AOD:Ae.VOD;return[0,void 0,1/0].indexOf(this.el.duration)>=0?Ae.LIVE:e}},{key:"isHighDefinitionInUse",value:function(){return!1}},{key:"consent",value:function(e){var t=this;if(this.isPlaying())v(d(n.prototype),"consent",this).call(this,e);else{var i=function i(){t.el.removeEventListener("loadedmetadata",i,!1),t.el.removeEventListener("error",i,!1),v(d(n.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(ue.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(ue.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:"_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(ue.PLAYBACK_PLAY)}},{key:"_onPause",value:function(){this._stopPlayheadMovingChecks(),this._handleBufferingEvents(),this.trigger(ue.PLAYBACK_PAUSE)}},{key:"_onSeeking",value:function(){this._handleBufferingEvents(),this.trigger(ue.PLAYBACK_SEEK)}},{key:"_onSeeked",value:function(){this._handleBufferingEvents(),this.trigger(ue.PLAYBACK_SEEKED)}},{key:"_onEnded",value:function(){this._handleBufferingEvents(),this.trigger(ue.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=e[n].start&&this.el.currentTime<=e[n].end&&(t=n);var i={start:e[t].start,current:e[t].end,total:this.el.duration};this.trigger(ue.PLAYBACK_PROGRESS,i,e)}}},{key:"_typeFor",value:function(e){var t=n._mimeTypesForUrl(e,Ke,this.options.mimeType);return 0===t.length&&(t=n._mimeTypesForUrl(e,Ge,this.options.mimeType)),(t[0]||"").split(";")[0]}},{key:"_ready",value:function(){this._isReadyState||(this._isReadyState=!0,this.trigger(ue.PLAYBACK_READY,this.name))}},{key:"_checkForClosedCaptions",value:function(){if(this.isHTML5Video&&!this._ccIsSetup){if(this.hasClosedCaptionsTracks){this.trigger(ue.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(ue.PLAYBACK_SUBTITLE_CHANGED,{id:e.id}))}},{key:"render",value:function(){return 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(),this}},{key:"isReady",get:function(){return this._isReadyState}},{key:"isHTML5Video",get:function(){return this.name===n.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,n=this.closedCaptionsTracks;if(-1!==e){if(!(t=n.find((function(t){return t.id===e}))))return;if("showing"===t.track.mode)return}n.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(ue.PLAYBACK_SUBTITLE_CHANGED,{id:e})}}},{key:"template",get:function(){return Ve('<% for (var i = 0; i < tracks.length; i++) { %>\n \n<% }; %>\n')}}]),n}(Ae);$e._mimeTypesForUrl=function(e,t,n){var i=(e.split("?")[0].match(/.*\.(.*)$/)||[])[1],r=n||i&&t[i.toLowerCase()]||[];return r.constructor===Array?r:[r]},$e._canPlay=function(e,t,n,i){var r=$e._mimeTypesForUrl(n,t,i),a=document.createElement(e);return!!r.filter((function(e){return!!a.canPlayType(e).replace(/no/,"")}))[0]},$e.canPlay=function(e,t){return $e._canPlay("audio",Ge,e,t)||$e._canPlay("video",Ke,e,t)};var ze=function(e){c(n,e);var t=g(n);function n(){return r(this,n),t.apply(this,arguments)}return o(n,[{key:"updateSettings",value:function(){this.settings.left=["playpause","position","duration"],this.settings.seekEnabled=this.isSeekEnabled(),this.trigger(ue.PLAYBACK_SETTINGSUPDATE)}},{key:"getPlaybackType",value:function(){return Ae.AOD}},{key:"name",get:function(){return"html5_audio"}},{key:"supportedVersion",get:function(){return{min:"0.4.14"}}},{key:"tagName",get:function(){return"audio"}},{key:"isAudioOnly",get:function(){return!0}}]),n}($e);ze.canPlay=function(e,t){return $e._canPlay("audio",{wav:["audio/wav"],mp3:["audio/mp3",'audio/mpeg;codecs="mp3"'],aac:['audio/mp4;codecs="mp4a.40.5"'],oga:["audio/ogg"]},e,t)};me("[data-html-img] {\n max-width: 100%;\n max-height: 100%; }\n");var We=function(e){c(n,e);var t=g(n);function n(e){var i;return r(this,n),(i=t.call(this,e)).el.src=e.src,i}return o(n,[{key:"getPlaybackType",value:function(){return Ae.NO_OP}},{key:"name",get:function(){return"html_img"}},{key:"supportedVersion",get:function(){return{min:"0.4.14"}}},{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"}}}]),o(n,[{key:"render",value:function(){return this.trigger(ue.PLAYBACK_READY,this.name),this}},{key:"_onLoad",value:function(){this.trigger(ue.PLAYBACK_ENDED,this.name)}},{key:"_onError",value:function(e){var t="error"===e.type?"load error":"loading aborted";this.trigger(ue.PLAYBACK_ERROR,{message:t},this.name)}}]),n}(Ae);We.canPlay=function(e){return/\.(png|jpg|jpeg|gif|bmp|tiff|pgm|pnm|webp)(|\?.*)$/i.test(e)};me("[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");var qe=function(e){c(n,e);var t=g(n);function n(){var e;r(this,n);for(var i=arguments.length,a=new Array(i),o=0;o\n

<%=message%>

\n

")}},{key:"attributes",get:function(){return{"data-no-op":""}}}]),o(n,[{key:"render",value:function(){var e=this.options.playbackNotSupportedMessage||this.i18n.t("playback_not_supported");this.$el.html(this.template({message:e})),this.trigger(ue.PLAYBACK_READY,this.name);var t=!(!this.options.poster||!this.options.poster.showForNoOp);return!this.options.autoPlay&&t||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(r){e=new Uint32Array(this.context.canvas.width*this.context.canvas.height*4);for(var n=t.data,i=0;i1&&void 0!==arguments[1]?arguments[1]:{baseUrl:""};return w('').html(Ve(e.toString())(t))}},Ze=function(e){c(n,e);var t=g(n);function n(e){var i;return r(this,n),(i=t.call(this,e))._initializeMessages(),i}return o(n,[{key:"name",get:function(){return"strings"}},{key:"supportedVersion",get:function(){return{min:"0.4.14"}}}]),o(n,[{key:"t",value:function(e){var t=this._language(),n=this._messages.en;return(t&&this._messages[t]||n)[e]||n[e]||e}},{key:"_language",value:function(){return this.core.options.language||W()}},{key:"_initializeMessages",value:function(){this._messages=w.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."},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:{live:"vivo",back_to_live:"volver en vivo",disabled:"Discapacitado",playback_not_supported:"Su navegador no soporta la reproducción de un video. Por favor, trate de usar un navegador diferente."},ru:{live:"прямой эфир",back_to_live:"к прямому эфиру",disabled:"Отключено",playback_not_supported:"Ваш браузер не поддерживает воспроизведение этого видео. Пожалуйста, попробуйте другой браузер."},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:"حدثت مشكلة أثناء تحميل الفيديو."}},this.core.options.strings||{}),this._messages["pt-BR"]=this._messages.pt,this._messages["en-US"]=this._messages.en,this._messages["es-419"]=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}}]),n}(De),Qe=function(e){c(n,e);var t=g(n);function n(){return r(this,n),t.apply(this,arguments)}return o(n,[{key:"bindEvents",value:function(){this.listenTo(this.core,ue.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()}))}},{key:"name",get:function(){return"sources"}},{key:"supportedVersion",get:function(){return{min:"0.4.14"}}}]),n}(De);Re.registerPlugin(Ze),Re.registerPlugin(Qe),Re.registerPlayback(qe),Re.registerPlayback(We),Re.registerPlayback(ze),Re.registerPlayback($e);var Je={Player:Oe,Events:ue,Browser:D,ContainerPlugin:Le,UIContainerPlugin:Ie,CorePlugin:De,UICorePlugin:ve,Playback:Ae,Container:ye,Core:Ee,PlayerError:pe,Loader:Re,BaseObject:de,UIObject:fe,Utils:Q,HTML5Audio:ze,HTML5Video:$e,HTMLImg:We,Log:re,Styler:Xe,version:"0.4.14",template:Ve,$:w};function et(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function tt(e,t){for(var n=0;n 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");var ct=function(e){function t(e){var n;et(this,t),n=ot(this,rt(t).call(this,e));var i=e.options.closedCaptionsConfig;return n._title=i&&i.title?i.title:null,n._ariaLabel=i&&i.ariaLabel?i.ariaLabel:"cc-button",n._labelCb=i&&i.labelCallback&&"function"==typeof i.labelCallback?i.labelCallback:function(e){return e.name},n}return it(t,e),nt(t,[{key:"name",get:function(){return"closed_captions"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}},{key:"template",get:function(){return Ve('\n\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":""}}}]),nt(t,[{key:"bindEvents",value:function(){this.bindCoreEvents(),this.bindContainerEvents()}},{key:"bindCoreEvents",value:function(){var e=this;this.core.mediaControl.settings?(this.listenTo(this.core,ue.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged),this.listenTo(this.core.mediaControl,ue.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.core.mediaControl,ue.MEDIACONTROL_HIDE,this.hideContextMenu)):setTimeout((function(){return e.bindCoreEvents()}),100)}},{key:"bindContainerEvents",value:function(){this.container=this.core.activeContainer,this.container&&(this.listenTo(this.container,ue.CONTAINER_SUBTITLE_AVAILABLE,this.onSubtitleAvailable),this.listenTo(this.container,ue.CONTAINER_SUBTITLE_CHANGED,this.onSubtitleChanged),this.listenTo(this.container,ue.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\n\n'),this.$el.append(this.style)}},{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}}]),t}(ve);ut('.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');var dt=function(e){function t(e){var n;return et(this,t),(n=ot(this,rt(t).call(this,e))).settingsUpdate(),n}return it(t,e),nt(t,[{key:"template",get:function(){return Ve('
<%= live %>
\n\n')}},{key:"name",get:function(){return"dvr_controls"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}},{key:"events",get:function(){return{"click .live-button":"click"}}},{key:"attributes",get:function(){return{class:"dvr-controls","data-dvr-controls":""}}}]),nt(t,[{key:"bindEvents",value:function(){this.bindCoreEvents(),this.bindContainerEvents()}},{key:"bindCoreEvents",value:function(){var e=this;this.core.mediaControl.settings?(this.listenTo(this.core.mediaControl,ue.MEDIACONTROL_CONTAINERCHANGED,this.containerChanged),this.listenTo(this.core.mediaControl,ue.MEDIACONTROL_RENDERED,this.settingsUpdate),this.listenTo(this.core,ue.CORE_OPTIONS_CHANGE,this.render)):setTimeout((function(){return e.bindCoreEvents()}),100)}},{key:"bindContainerEvents",value:function(){this.core.activeContainer&&(this.listenToOnce(this.core.activeContainer,ue.CONTAINER_TIMEUPDATE,this.render),this.listenTo(this.core.activeContainer,ue.CONTAINER_PLAYBACKDVRSTATECHANGED,this.dvrChanged))}},{key:"containerChanged",value:function(){this.stopListening(),this.bindEvents()}},{key:"dvrChanged",value:function(e){this.core.getPlaybackType()===Ae.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()===Ae.LIVE}},{key:"render",value:function(){return this.$el.html(this.template({live:this.core.i18n.t("live"),backToLive:this.core.i18n.t("back_to_live")})),this.shouldRender()&&(this.core.mediaControl.$el.addClass("live"),this.core.mediaControl.$(".media-control-left-panel[data-media-control]").append(this.$el)),this}}]),t}(ve),ht=function(e){function t(){return et(this,t),ot(this,rt(t).apply(this,arguments))}return it(t,e),nt(t,[{key:"bindEvents",value:function(){this.listenTo(this.core,ue.CORE_ACTIVE_CONTAINER_CHANGED,this.containerChanged);var e=this.core.activeContainer;e&&(this.listenTo(e,ue.CONTAINER_ENDED,this.ended),this.listenTo(e,ue.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()}},{key:"name",get:function(){return"end_video"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}}]),t}(De);ut("div.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 div.player-error-screen__content[data-error-screen] {\n font-size: 14px;\n color: #CCCACA;\n margin-top: 45px; }\n div.player-error-screen__title[data-error-screen] {\n font-weight: bold;\n line-height: 30px;\n font-size: 18px; }\n div.player-error-screen__message[data-error-screen] {\n width: 90%;\n margin: 0 auto; }\n div.player-error-screen__code[data-error-screen] {\n font-size: 13px;\n margin-top: 15px; }\n div.player-error-screen__reload {\n cursor: pointer;\n width: 30px;\n margin: 15px auto 0; }\n");var ft=function(e){function t(e){var n;return et(this,t),(n=ot(this,rt(t).call(this,e))).options.disableErrorScreen?ot(n,n.disable()):n}return it(t,e),nt(t,[{key:"name",get:function(){return"error_screen"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}},{key:"template",get:function(){return Ve('
\n <% if (icon) { %>\n
<%= icon %>
\n <% } %>\n
<%= title %>
\n
<%= message %>
\n
Error code: <%= code %>
\n
<%= reloadIcon %>
\n
\n')}},{key:"container",get:function(){return this.core.getCurrentContainer()}},{key:"attributes",get:function(){return{class:"player-error-screen","data-error-screen":""}}}]),nt(t,[{key:"bindEvents",value:function(){this.listenTo(this.core,ue.ERROR,this.onError),this.listenTo(this.core,ue.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,ue.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===pe.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)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:'\n \n \n'})),this.core.$el.append(this.el),this.bindReload(),this}}]),t}(ve),pt='\n \n',gt='\n \n',vt=w('link[rel="shortcut icon"]'),mt=function(e){function t(e){var n;return et(this,t),(n=ot(this,rt(t).call(this,e)))._container=null,n.configure(),n}return it(t,e),nt(t,[{key:"name",get:function(){return"favicon"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}},{key:"oldIcon",get:function(){return vt}}]),nt(t,[{key:"configure",value:function(){this.core.options.changeFavicon?this.enabled||(this.stopListening(this.core,ue.CORE_OPTIONS_CHANGE),this.enable()):this.enabled&&(this.disable(),this.listenTo(this.core,ue.CORE_OPTIONS_CHANGE,this.configure))}},{key:"bindEvents",value:function(){this.listenTo(this.core,ue.CORE_OPTIONS_CHANGE,this.configure),this.listenTo(this.core,ue.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,ue.CONTAINER_PLAY,this.setPlayIcon),this.listenTo(this._container,ue.CONTAINER_PAUSE,this.setPauseIcon),this.listenTo(this._container,ue.CONTAINER_STOP,this.resetIcon),this.listenTo(this._container,ue.CONTAINER_ENDED,this.resetIcon),this.listenTo(this._container,ue.CONTAINER_ERROR,this.resetIcon),this.resetIcon()}},{key:"disable",value:function(){st(rt(t.prototype),"disable",this).call(this),this.resetIcon()}},{key:"destroy",value:function(){st(rt(t.prototype),"destroy",this).call(this),this.resetIcon()}},{key:"createIcon",value:function(e){var t=w("");t[0].width=16,t[0].height=16;var n=t[0].getContext("2d");n.fillStyle="#000";var i=w(e).find("path").attr("d"),r=new Path2D(i);n.fill(r);var a=w('');return a.attr("href",t[0].toDataURL("image/png")),a}},{key:"setPlayIcon",value:function(){this.playIcon||(this.playIcon=this.createIcon(pt)),this.changeIcon(this.playIcon)}},{key:"setPauseIcon",value:function(){this.pauseIcon||(this.pauseIcon=this.createIcon(gt)),this.changeIcon(this.pauseIcon)}},{key:"resetIcon",value:function(){w('link[rel="shortcut icon"]').remove(),w("head").append(this.oldIcon)}},{key:"changeIcon",value:function(e){e&&(w('link[rel="shortcut icon"]').remove(),w("head").append(e))}}]),t}(De),yt=function(e){function t(e){var n;return et(this,t),(n=ot(this,rt(t).call(this,e))).container.options.gaAccount&&(n.account=n.container.options.gaAccount,n.trackerName=n.container.options.gaTrackerName?n.container.options.gaTrackerName+".":"Clappr.",n.domainName=n.container.options.gaDomainName,n.currentHDState=void 0,n.embedScript()),n}return it(t,e),nt(t,[{key:"name",get:function(){return"google_analytics"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}}]),nt(t,[{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,ue.CONTAINER_READY,this.onReady),this.listenTo(this.container,ue.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ue.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ue.CONTAINER_PAUSE,this.onPause),this.listenTo(this.container,ue.CONTAINER_ENDED,this.onEnded),this.listenTo(this.container,ue.CONTAINER_STATE_BUFFERING,this.onBuffering),this.listenTo(this.container,ue.CONTAINER_STATE_BUFFERFULL,this.onBufferFull),this.listenTo(this.container,ue.CONTAINER_ERROR,this.onError),this.listenTo(this.container,ue.CONTAINER_PLAYBACKSTATE,this.onPlaybackChanged),this.listenTo(this.container,ue.CONTAINER_VOLUME,(function(t){return e.onVolumeChanged(t)})),this.listenTo(this.container,ue.CONTAINER_SEEK,(function(t){return e.onSeek(t)})),this.listenTo(this.container,ue.CONTAINER_FULL_SCREEN,this.onFullscreen),this.listenTo(this.container,ue.CONTAINER_HIGHDEFINITIONUPDATE,this.onHD),this.listenTo(this.container,ue.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)}}]),t}(Le),At="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function bt(){throw new Error("setTimeout has not been defined")}function Et(){throw new Error("clearTimeout has not been defined")}var Tt=bt,kt=Et;function _t(e){if(Tt===setTimeout)return setTimeout(e,0);if((Tt===bt||!Tt)&&setTimeout)return Tt=setTimeout,setTimeout(e,0);try{return Tt(e,0)}catch(t){try{return Tt.call(null,e,0)}catch(t){return Tt.call(this,e,0)}}}"function"==typeof At.setTimeout&&(Tt=setTimeout),"function"==typeof At.clearTimeout&&(kt=clearTimeout);var St,Ct=[],Rt=!1,wt=-1;function Ot(){Rt&&St&&(Rt=!1,St.length?Ct=St.concat(Ct):wt=-1,Ct.length&&Lt())}function Lt(){if(!Rt){var e=_t(Ot);Rt=!0;for(var t=Ct.length;t;){for(St=Ct,Ct=[];++wt1)for(var n=1;n
\n
\n <% var renderBar = function(name) { %>\n
>\n
>\n
>
\n
>
\n
>
\n
\n
>\n
>
\n
\n
\n <% }; %>\n <% var renderSegmentedBar = function(name, segments) {\n segments = segments || 10; %>\n
>\n <% for (var i = 0; i < segments; i++) { %>\n
>
\n <% } %>\n
\n <% }; %>\n <% var renderDrawer = function(name, renderContent) { %>\n
>\n
>\n
>
\n >\n
\n <% renderContent(name); %>\n
\n <% }; %>\n <% var renderIndicator = function(name) { %>\n
>
\n <% }; %>\n <% var renderButton = function(name) { %>\n \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
\n <% render(settings.default); %>\n
\n <% } %>\n <% if (settings.left && settings.left.length) { %>\n
\n <% render(settings.left); %>\n
\n <% } %>\n <% if (settings.right && settings.right.length) { %>\n
\n <% render(settings.right); %>\n
\n <% } %>\n
\n')}},{key:"volume",get:function(){return this.container&&this.container.isReady?this.container.volume:this.intendedVolume}},{key:"muted",get:function(){return 0===this.volume}}]),nt(t,[{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,ue.CORE_ACTIVE_CONTAINER_CHANGED,this.onActiveContainerChanged),this.listenTo(this.core,ue.CORE_MOUSE_MOVE,this.show),this.listenTo(this.core,ue.CORE_MOUSE_LEAVE,(function(){return e.hide(e.options.hideMediaControlDelay)})),this.listenTo(this.core,ue.CORE_FULLSCREEN,this.show),this.listenTo(this.core,ue.CORE_OPTIONS_CHANGE,this.configure),this.listenTo(this.core,ue.CORE_RESIZE,this.playerResize),this.bindContainerEvents()}},{key:"bindContainerEvents",value:function(){this.container&&(this.listenTo(this.container,ue.CONTAINER_PLAY,this.changeTogglePlay),this.listenTo(this.container,ue.CONTAINER_PAUSE,this.changeTogglePlay),this.listenTo(this.container,ue.CONTAINER_STOP,this.changeTogglePlay),this.listenTo(this.container,ue.CONTAINER_DBLCLICK,this.toggleFullscreen),this.listenTo(this.container,ue.CONTAINER_TIMEUPDATE,this.onTimeUpdate),this.listenTo(this.container,ue.CONTAINER_PROGRESS,this.updateProgressBar),this.listenTo(this.container,ue.CONTAINER_SETTINGSUPDATE,this.settingsUpdate),this.listenTo(this.container,ue.CONTAINER_PLAYBACKDVRSTATECHANGED,this.settingsUpdate),this.listenTo(this.container,ue.CONTAINER_HIGHDEFINITIONUPDATE,this.highDefinitionUpdate),this.listenTo(this.container,ue.CONTAINER_MEDIACONTROL_DISABLE,this.disable),this.listenTo(this.container,ue.CONTAINER_MEDIACONTROL_ENABLE,this.enable),this.listenTo(this.container,ue.CONTAINER_ENDED,this.ended),this.listenTo(this.container,ue.CONTAINER_VOLUME,this.onVolumeChanged),this.listenTo(this.container,ue.CONTAINER_OPTIONS_CHANGE,this.setInitialVolume),"video"===this.container.playback.el.nodeName.toLowerCase()&&this.listenToOnce(this.container,ue.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?Ut.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;!jt.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(),n=(e-t)/2,i=t*this.volume/100+n;this.$volumeBarFill.css({width:"".concat(this.volume,"%")}),this.$volumeBarScrubber.css({left:i}),this.$volumeBarContainer.find(".segmented-bar-element").removeClass("fill");var r=Math.ceil(this.volume/10);this.$volumeBarContainer.find(".segmented-bar-element").slice(0,r).addClass("fill"),this.$volumeIcon.html(""),this.$volumeIcon.removeClass("muted"),this.muted?(this.$volumeIcon.append('\n \n'),this.$volumeIcon.addClass("muted")):this.$volumeIcon.append(Ft),this.applyButtonStyle(this.$volumeIcon)}}},{key:"changeTogglePlay",value:function(){this.$playPauseToggle.html(""),this.$playStopToggle.html(""),this.container&&this.container.isPlaying()?(this.$playPauseToggle.append(gt),this.$playStopToggle.append(Mt),this.trigger(ue.MEDIACONTROL_PLAYING)):(this.$playPauseToggle.append(pt),this.$playStopToggle.append(pt),this.trigger(ue.MEDIACONTROL_NOTPLAYING),D.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(ue.MEDIACONTROL_MOUSEMOVE_SEEKBAR,e)}},{key:"mouseleaveOnSeekBar",value:function(e){this.trigger(ue.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()?'\n \n':Bt;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,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e=Math.min(100,Math.max(e,0)),this.intendedVolume=e,this.persistConfig&&!n&&Ut.persist("volume",e);var i=function(){t.container&&t.container.isReady?t.container.setVolume(e):t.listenToOnce(t.container,ue.CONTAINER_READY,(function(){t.container.setVolume(e)}))};this.container?i():this.listenToOnce(this,ue.MEDIACONTROL_CONTAINERCHANGED,(function(){return i()}))}},{key:"toggleFullscreen",value:function(){this.trigger(ue.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(ue.CONTAINER_PLAYBACKDVRSTATECHANGED,this.container.isDvrInUse()),this.container&&this.container.mediaControlDisabled&&this.disable(),this.trigger(ue.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,n=e.current/e.total*100;this.$seekBarLoaded.css({left:"".concat(t,"%"),width:"".concat(n-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()!==Ae.LIVE||this.container.isDvrInUse())&&(this.currentSeekBarPercentage=this.currentPositionValue/this.currentDurationValue*100),this.setSeekPercentage(this.currentSeekBarPercentage);var e=Vt(this.currentPositionValue),t=Vt(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 n=e&&e.clientX!==this.lastMouseX&&e.clientY!==this.lastMouseY;(!e||n||navigator.userAgent.match(/firefox/i))&&(clearTimeout(this.hideId),this.$el.show(),this.trigger(ue.MEDIACONTROL_SHOW,this.name),this.container&&this.container.trigger(ue.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 n=t||2e3;if(clearTimeout(this.hideId),this.disabled||!1!==this.options.hideMediaControl){var i=this.userKeepVisible||this.keepVisible,r=this.draggingSeekBar||this.draggingVolumeBar;if(!this.disabled&&(t||i||r))this.hideId=setTimeout((function(){return e.hide()}),n);else{this.trigger(ue.MEDIACONTROL_HIDE,this.name),this.container&&this.container.trigger(ue.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||jt.fullscreenEnabled()||(e.default&&Gt(e.default,"fullscreen"),e.left&&Gt(e.left,"fullscreen"),e.right&&Gt(e.right,"fullscreen")),JSON.stringify(this.settings)!==JSON.stringify(e)&&(this.settings=e,this.render())}},{key:"getSettings",value:function(){return w.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(pt),e.find("button.media-control-button[data-pause]").append(gt),e.find("button.media-control-button[data-stop]").append(Mt),this.$playPauseToggle.append(pt),this.$playStopToggle.append(pt),this.$volumeIcon.append(Ft),this.$fullscreenToggle.append(Bt),this.$hdIndicator.append('\n \n')}},{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(),n=this.container.getDuration(),i=Math.min(Math.max(t+e,0),n);i=Math.min(100*i/n,100),this.container.seekPercentage(i)}}},{key:"bindKeyAndShow",value:function(e,t){var n=this;this.kibo.down(e,(function(){return n.show(),t()}))}},{key:"bindKeyEvents",value:function(){var e=this;if(!D.isMobile&&!this.options.disableKeyboardShortcuts){this.unbindKeyEvents(),this.kibo=new xt(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&&w(e).find("svg path").css("fill",this.buttonsColor)}},{key:"destroy",value:function(){w(document).unbind("mouseup",this.stopDragHandler),w(document).unbind("mousemove",this.updateDragHandler),this.unbindKeyEvents(),this.stopListening(),st(rt(t.prototype),"destroy",this).call(this)}},{key:"configure",value:function(e){this.options.chromeless||e.source||e.sources?this.disable():this.enable(),this.trigger(ue.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})),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()),D.isSafari&&D.isMobile&&(D.version<10?this.$volumeContainer.css("display","none"):this.$volumeBarContainer.css("display","none")),this.$seekBarPosition.addClass("media-control-notransition"),this.$seekBarScrubber.addClass("media-control-notransition");var n=0;return this.displayedSeekBarPercentage&&(n=this.displayedSeekBarPercentage),this.displayedSeekBarPercentage=null,this.setSeekPercentage(n),Dt((function(){!e.settings.seekEnabled&&e.$seekBarContainer.addClass("seek-disabled"),!D.isMobile&&!e.options.disableKeyboardShortcuts&&e.bindKeyEvents(),e.playerResize({width:e.options.width,height:e.options.height}),e.hideVolumeBar(0)})),this.parseColors(),this.highDefinitionUpdate(this.isHD),this.core.$el.append(this.el),this.rendered=!0,this.updateVolumeUI(),this.trigger(ue.MEDIACONTROL_RENDERED),this}}]),t}(ve);Yt.extend=function(e){return Kt(Yt,e)};ut(".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");var Ht=function(e){function t(e){var n;return et(this,t),(n=ot(this,rt(t).call(this,e))).hasStartedPlaying=!1,n.playRequested=!1,n.render(),Dt((function(){return n.update()})),n}return it(t,e),nt(t,[{key:"name",get:function(){return"poster"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}},{key:"template",get:function(){return Ve('
\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()!==Ae.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}}]),nt(t,[{key:"bindEvents",value:function(){this.listenTo(this.container,ue.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ue.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ue.CONTAINER_STATE_BUFFERING,this.update),this.listenTo(this.container,ue.CONTAINER_STATE_BUFFERFULL,this.update),this.listenTo(this.container,ue.CONTAINER_OPTIONS_CHANGE,this.render),this.listenTo(this.container,ue.CONTAINER_ERROR,this.onError),this.showOnVideoEnd&&this.listenTo(this.container,ue.CONTAINER_ENDED,this.onStop)}},{key:"onError",value:function(e){this.hasFatalError=e.level===pe.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.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){if(this.$el.html(this.template()),this.options.poster&&void 0===this.options.poster.custom){var e=this.options.poster.url||this.options.poster;this.$el.css({"background-image":"url("+e+")"})}else this.options.poster&&this.$el.css({background:this.options.poster.custom});this.container.$el.append(this.el),this.$playWrapper=this.$el.find(".play-wrapper"),this.$playWrapper.append(pt),this.$playButton=this.$playWrapper.find("svg"),this.$playButton.addClass("poster-icon"),this.$playButton.attr("data-poster","");var t=this.options.mediacontrol&&this.options.mediacontrol.buttons;return t&&this.$el.find("svg path").css("fill",t),this.options.mediacontrol&&this.options.mediacontrol.buttons&&(t=this.options.mediacontrol.buttons,this.$playButton.css("color",t)),this.update(),this}}}]),t}(Ie);ut('.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');var $t=Q.formatTime,zt=function(e){function t(e){var n;return et(this,t),(n=ot(this,rt(t).call(this,e))).hoveringOverSeekBar=!1,n.hoverPosition=null,n.duration=null,n.firstFragDateTime=null,n.actualLiveTime=!!n.mediaControl.options.actualLiveTime,n.actualLiveTime&&(n.mediaControl.options.actualLiveServerTime?n.actualLiveServerTimeDiff=(new Date).getTime()-new Date(n.mediaControl.options.actualLiveServerTime).getTime():n.actualLiveServerTimeDiff=0),n}return it(t,e),nt(t,[{key:"name",get:function(){return"seek_time"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}},{key:"template",get:function(){return Ve("\n\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()===Ae.LIVE&&this.mediaControlContainer.isDvrEnabled()}},{key:"durationShown",get:function(){return this.isLiveStreamWithDvr&&!this.actualLiveTime}},{key:"useActualLiveTime",get:function(){return this.actualLiveTime&&this.isLiveStreamWithDvr}}]),nt(t,[{key:"bindEvents",value:function(){this.listenTo(this.mediaControl,ue.MEDIACONTROL_RENDERED,this.render),this.listenTo(this.mediaControl,ue.MEDIACONTROL_MOUSEMOVE_SEEKBAR,this.showTime),this.listenTo(this.mediaControl,ue.MEDIACONTROL_MOUSELEAVE_SEEKBAR,this.hideTime),this.listenTo(this.mediaControl,ue.MEDIACONTROL_CONTAINERCHANGED,this.onContainerChanged),this.mediaControlContainer&&(this.listenTo(this.mediaControlContainer,ue.CONTAINER_PLAYBACKDVRSTATECHANGED,this.update),this.listenTo(this.mediaControlContainer,ue.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,n,i;return this.useActualLiveTime?(this.firstFragDateTime?(i=new Date(this.firstFragDateTime),(n=new Date(this.firstFragDateTime)).setHours(0,0,0,0),t=(i.getTime()-n.getTime())/1e3+this.duration):(n=new Date((new Date).getTime()-this.actualLiveServerTimeDiff),t=((i=new Date(n))-n.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=$t(e.seekTime,this.useActualLiveTime);if(t!==this.displayedSeekTime&&(this.$seekTimeEl.text(t),this.displayedSeekTime=t),this.durationShown){this.$durationEl.show();var n=$t(this.actualLiveTime?e.secondsSinceMidnight:this.duration,this.actualLiveTime);n!==this.displayedDuration&&(this.$durationEl.text(n),this.displayedDuration=n)}else this.$durationEl.hide();this.$el.show();var i=this.mediaControl.$seekBarContainer.width(),r=this.$el.width(),a=this.hoverPosition*i;a-=r/2,a=Math.max(0,Math.min(a,i-r)),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(){this.rendered=!0,this.displayedDuration=null,this.displayedSeekTime=null,this.$el.html(this.template()),this.$el.hide(),this.mediaControl.$el.append(this.el),this.$seekTimeEl=this.$el.find("[data-seek-time]"),this.$durationEl=this.$el.find("[data-duration]"),this.$durationEl.hide(),this.update()}}]),t}(ve);ut(".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 -webkit-animation: bouncedelay 1.4s infinite ease-in-out;\n animation: bouncedelay 1.4s infinite ease-in-out;\n /* Prevent first frame from flickering when animation starts */\n -webkit-animation-fill-mode: both;\n animation-fill-mode: both; }\n .spinner-three-bounce[data-spinner] [data-bounce1] {\n -webkit-animation-delay: -0.32s;\n animation-delay: -0.32s; }\n .spinner-three-bounce[data-spinner] [data-bounce2] {\n -webkit-animation-delay: -0.16s;\n animation-delay: -0.16s; }\n\n@-webkit-keyframes bouncedelay {\n 0%, 80%, 100% {\n transform: scale(0); }\n 40% {\n transform: scale(1); } }\n\n@keyframes bouncedelay {\n 0%, 80%, 100% {\n transform: scale(0); }\n 40% {\n transform: scale(1); } }\n");var Wt=function(e){function t(e){var n;return et(this,t),(n=ot(this,rt(t).call(this,e))).template=Ve("
\n"),n.showTimeout=null,n.listenTo(n.container,ue.CONTAINER_STATE_BUFFERING,n.onBuffering),n.listenTo(n.container,ue.CONTAINER_STATE_BUFFERFULL,n.onBufferFull),n.listenTo(n.container,ue.CONTAINER_STOP,n.onStop),n.listenTo(n.container,ue.CONTAINER_ENDED,n.onStop),n.listenTo(n.container,ue.CONTAINER_ERROR,n.onStop),n.render(),n}return it(t,e),nt(t,[{key:"name",get:function(){return"spinner"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}},{key:"attributes",get:function(){return{"data-spinner":"",class:"spinner-three-bounce"}}}]),nt(t,[{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(){return this.$el.html(this.template()),this.container.$el.append(this.$el),this.$el.hide(),this.container.buffering&&this.onBuffering(),this}}]),t}(Ie),qt=function(e){function t(e){var n;return et(this,t),(n=ot(this,rt(t).call(this,e))).setInitialAttrs(),n.reportInterval=n.options.reportInterval||5e3,n.state="IDLE",n}return it(t,e),nt(t,[{key:"name",get:function(){return"stats"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}}]),nt(t,[{key:"bindEvents",value:function(){this.listenTo(this.container.playback,ue.PLAYBACK_PLAY,this.onPlay),this.listenTo(this.container,ue.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ue.CONTAINER_ENDED,this.onStop),this.listenTo(this.container,ue.CONTAINER_DESTROYED,this.onStop),this.listenTo(this.container,ue.CONTAINER_STATE_BUFFERING,this.onBuffering),this.listenTo(this.container,ue.CONTAINER_STATE_BUFFERFULL,this.onBufferFull),this.listenTo(this.container,ue.CONTAINER_STATS_ADD,this.onStatsAdd),this.listenTo(this.container,ue.CONTAINER_BITRATE,this.onStatsAdd),this.listenTo(this.container.playback,ue.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){w.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 w.extend(e,this.externalMetrics),e}},{key:"report",value:function(){this.container.statsReport(this.getStats())}}]),t}(Le);ut(".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");for(var Xt={ClickToPause:lt,ClosedCaptions:ct,DVRControls:dt,EndVideo:ht,ErrorScreen:ft,Favicon:mt,GoogleAnalytics:yt,MediaControl:Yt,Poster:Ht,SeekTime:zt,SpinnerThreeBounce:Wt,Stats:qt,WaterMark:function(e){function t(e){var n;return et(this,t),(n=ot(this,rt(t).call(this,e))).configure(),n}return it(t,e),nt(t,[{key:"name",get:function(){return"watermark"}},{key:"supportedVersion",get:function(){return{min:"0.4.9"}}},{key:"template",get:function(){return Ve('
>\n<% if(typeof imageLink !== \'undefined\') { %>\n\n<% } %>\n\n<% if(typeof imageLink !== \'undefined\') { %>\n\n<% } %>\n
\n')}}]),nt(t,[{key:"bindEvents",value:function(){this.listenTo(this.container,ue.CONTAINER_PLAY,this.onPlay),this.listenTo(this.container,ue.CONTAINER_STOP,this.onStop),this.listenTo(this.container,ue.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={position:this.position,imageUrl:this.imageUrl,imageLink:this.imageLink};return this.$el.html(this.template(e)),this.container.$el.append(this.$el),this}}]),t}(Ie)},Zt=0,Qt=Object.values(Xt);Zte.length)&&(t=e.length);for(var n=0,i=new Array(t);n0}),!1)}e.exports=function(e,t){t=t||{};var r={main:n.m},a=t.all?{main:Object.keys(r.main)}:function(e,t){for(var n={main:[t]},i={main:[]},r={main:{}};s(n);)for(var a=Object.keys(n),l=0;l>>8^255&v^99,e[f]=v,t[v]=f;var m=h[f],y=h[m],A=h[y],b=257*h[v]^16843008*v;i[f]=b<<24|b>>>8,r[f]=b<<16|b>>>16,a[f]=b<<8|b>>>24,o[f]=b,b=16843009*A^65537*y^257*m^16843008*f,l[v]=b<<24|b>>>8,u[v]=b<<16|b>>>16,c[v]=b<<8|b>>>24,d[v]=b,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),n=!0,i=0;i>>5}function h(e,t){return!!(t+1>>6),!((l=(60&t[n+2])>>>2)>p.length-1))return c=(1&t[n+2])<<2,c|=(192&t[n+3])>>>6,s.logger.log("manifest codec:"+a+",ADTS data:type:"+o+",sampleingIndex:"+l+"["+p[l]+"Hz],channelConfig:"+c),/firefox/i.test(h)?l>=6?(o=5,d=new Array(4),u=l-3):(o=2,d=new Array(2),u=l):-1!==h.indexOf("android")?(o=2,d=new Array(2),u=l):(o=5,d=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&l>=6?u=l-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(l>=6&&1===c||/vivaldi/i.test(h))||!a&&1===c)&&(o=2,d=new Array(2)),u=l)),d[0]=o<<3,d[0]|=(14&l)>>1,d[1]|=(1&l)<<7,d[1]|=c<<3,5===o&&(d[1]|=(14&u)>>1,d[2]=(1&u)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:p[l],channelCount:c,codec:"mp4a.40."+o,manifestCodec:f};e.trigger(i.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+l})}(t,n,a,o);e.config=l.config,e.samplerate=l.samplerate,e.channelCount=l.channelCount,e.codec=l.codec,e.manifestCodec=l.manifestCodec,s.logger.log("parsed codec:"+e.codec+",rate:"+l.samplerate+",nb channel:"+l.channelCount)}}function g(e){return 9216e4/e}function v(e,t,n,i,r){var a=function(e,t,n,i,r){var a,o,s=e.length;if(a=c(e,t),o=d(e,t),(o-=a)>0&&t+a+o<=s)return{headerLength:a,frameLength:o,stamp:n+i*r}}(t,n,i,r,g(e.samplerate));if(a){var o=a.stamp,s=a.headerLength,l=a.frameLength,u={unit:t.subarray(n+s,n+s+l),pts:o,dts:o};return e.samples.push(u),{sample:u,length:l+s}}}var m=n("./src/demux/id3.js"),y=function(){function e(e,t,n){this.observer=e,this.config=n,this.remuxer=t}var t=e.prototype;return t.resetInitSegment=function(e,t,n,i){this._audioTrack={container:"audio/adts",type:"audio",id:0,sequenceNumber:0,isAAC:!0,samples:[],len:0,manifestCodec:t,duration:i,inputTimeScale:9e4}},t.resetTimeStamp=function(){},e.probe=function(e){if(!e)return!1;for(var t=(m.default.getID3Data(e,0)||[]).length,n=e.length;tt.length)){var a=this.parseHeader(t,n);if(a&&n+a.frameLength<=t.length){var o=i+r*(9e4*a.samplesPerFrame/a.sampleRate),s={unit:t.subarray(n,n+a.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(s),{sample:s,length:a.frameLength}}}},parseHeader:function(e,t){var n=e[t+1]>>3&3,i=e[t+1]>>1&3,r=e[t+2]>>4&15,a=e[t+2]>>2&3,o=e[t+2]>>1&1;if(1!==n&&0!==r&&15!==r&&3!==a){var s=3===n?3-i:3===i?3:4,l=1e3*b.BitratesMap[14*s+r-1],u=3===n?0:2===n?1:2,c=b.SamplingRateMap[3*u+a],d=e[t+3]>>6==3?1:2,h=b.SamplesCoefficients[n][i],f=b.BytesInSlot[i],p=8*h*f;return{sampleRate:c,channelCount:d,frameLength:parseInt(h*l/c+o,10)*f,samplesPerFrame:p}}},isHeaderPattern:function(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])},isHeader:function(e,t){return!!(t+1e?(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),n=this.word>>>32-t;return e>32&&s.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?n<>>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){var t,n=8,i=8;for(t=0;t=e.length)return void n();if(!(e[t].unit.length<32)){var i=this.decrypter.isSync();if(this.decryptAacSample(e,t,n,i),!i)return}}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,n=new Int8Array(t),i=0,r=32;r<=e.length-16;r+=160,i+=16)n.set(e.subarray(r,r+16),i);return n},t.getAvcDecryptedUnit=function(e,t){t=new Uint8Array(t);for(var n=0,i=32;i<=e.length-16;i+=160,n+=16)e.set(t.subarray(n,n+16),i);return e},t.decryptAvcSample=function(e,t,n,i,r,a){var o=this.discardEPB(r.data),s=this.getAvcEncryptedData(o),l=this;this.decryptBuffer(s.buffer,(function(s){r.data=l.getAvcDecryptedUnit(o,s),a||l.decryptAvcSamples(e,t,n+1,i)}))},t.decryptAvcSamples=function(e,t,n,i){for(;;t++,n=0){if(t>=e.length)return void i();for(var r=e[t].units;!(n>=r.length);n++){var a=r[n];if(!(a.length<=48||1!==a.type&&5!==a.type)){var o=this.decrypter.isSync();if(this.decryptAvcSample(e,t,n,i,a,o),!o)return}}}},e}(),_={video:1,audio:2,id3:3,text:4},S=function(){function e(e,t,n,i){this.observer=e,this.config=n,this.typeSupported=i,this.remuxer=t,this.sampleAes=null}var t=e.prototype;return t.setDecryptData=function(e){null!=e&&null!=e.key&&"SAMPLE-AES"===e.method?this.sampleAes=new k(this.observer,this.config,e,this.discardEPB):this.sampleAes=null},e.probe=function(t){var n=e._syncOffset(t);return!(n<0||(n&&s.logger.warn("MPEG2-TS detected but first sync word found @ offset "+n+", junk ahead ?"),0))},e._syncOffset=function(e){for(var t=Math.min(1e3,e.length-564),n=0;n>4>1){if((d=l+5+t[l+4])===l+188)continue}else d=l+4;switch(c){case A:u&&(k&&(h=w(k))&&O(h,!1),k={data:[],size:0}),k&&(k.data.push(t.subarray(d,l+188)),k.size+=l+188-d);break;case b:u&&(_&&(h=w(_))&&(m.isAAC?L(h):D(h)),_={data:[],size:0}),_&&(_.data.push(t.subarray(d,l+188)),_.size+=l+188-d);break;case E:u&&(S&&(h=w(S))&&I(h),S={data:[],size:0}),S&&(S.data.push(t.subarray(d,l+188)),S.size+=l+188-d);break;case 0:u&&(d+=t[d]+1),T=this._pmtId=C(t,d);break;case T:u&&(d+=t[d]+1);var x=R(t,d,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,null!=this.sampleAes);(A=x.avc)>0&&(v.pid=A),(b=x.audio)>0&&(m.pid=b,m.isAAC=x.isAAC),(E=x.id3)>0&&(y.pid=E),p&&!g&&(s.logger.log("reparse from beginning"),p=!1,l=P-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=!0}}else this.observer.trigger(i.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"TS packet did not start with 0x47"});k&&(h=w(k))?(O(h,!0),v.pesData=null):v.pesData=k,_&&(h=w(_))?(m.isAAC?L(h):D(h),m.pesData=null):(_&&_.size&&s.logger.log("last AAC PES packet truncated,might overlap between fragments"),m.pesData=_),S&&(h=w(S))?(I(h),y.pesData=null):y.pesData=S,null==this.sampleAes?this.remuxer.remux(m,v,y,this._txtTrack,n,a,o):this.decryptAndRemux(m,v,y,this._txtTrack,n,a,o)},t.decryptAndRemux=function(e,t,n,i,r,a,o){if(e.samples&&e.isAAC){var s=this;this.sampleAes.decryptAacSamples(e.samples,0,(function(){s.decryptAndRemuxAvc(e,t,n,i,r,a,o)}))}else this.decryptAndRemuxAvc(e,t,n,i,r,a,o)},t.decryptAndRemuxAvc=function(e,t,n,i,r,a,o){if(t.samples){var s=this;this.sampleAes.decryptAvcSamples(t.samples,0,0,(function(){s.remuxer.remux(e,t,n,i,r,a,o)}))}else this.remuxer.remux(e,t,n,i,r,a,o)},t.destroy=function(){this._initPTS=this._initDTS=void 0,this._duration=0},t._parsePAT=function(e,t){return(31&e[t+10])<<8|e[t+11]},t._parsePMT=function(e,t,n,i){var r,a,o={audio:-1,avc:-1,id3:-1,isAAC:!0};for(r=t+3+((15&e[t+1])<<8|e[t+2])-4,t+=12+((15&e[t+10])<<8|e[t+11]);t1;){var h=new Uint8Array(d[0].length+d[1].length);h.set(d[0]),h.set(d[1],d[0].length),d[0]=h,d.splice(1,1)}if(1===((t=d[0])[0]<<16)+(t[1]<<8)+t[2]){if((i=(t[4]<<8)+t[5])&&i>e.size-6)return null;if(192&(n=t[7])&&((o=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2)>4294967295&&(o-=8589934592),64&n?((l=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2)>4294967295&&(l-=8589934592),o-l>54e5&&(s.logger.warn(Math.round((o-l)/9e4)+"s delta between PTS and DTS, align them"),o=l)):l=o),u=(r=t[8])+9,e.size<=u)return null;e.size-=u,a=new Uint8Array(e.size);for(var f=0,p=d.length;fg){u-=g;continue}t=t.subarray(u),g-=u,u=0}a.set(t,c),c+=g}return i&&(i-=r+3),{data:a,pts:o,dts:l,len:i}}return null},t.pushAccesUnit=function(e,t){if(e.units.length&&e.frame){var n=t.samples,i=n.length;if(isNaN(e.pts)){if(!i)return void t.dropped++;var r=n[i-1];e.pts=r.pts,e.dts=r.dts}!this.config.forceKeyFrameOnDiscontinuity||!0===e.key||t.sps&&(i||this.contiguous)?(e.id=i,n.push(e)):t.dropped++}e.debug.length&&s.logger.log(e.pts+"/"+e.dts+":"+e.debug)},t._parseAVCPES=function(e,t){var n,i,r,a=this,o=this._avcTrack,s=this._parseAVCNALu(e.data),l=this.avcSample,u=!1,c=this.pushAccesUnit.bind(this),d=function(e,t,n,i){return{key:e,pts:t,dts:n,units:[],debug:i}};e.data=null,l&&s.length&&!o.audFound&&(c(l,o),l=this.avcSample=d(!1,e.pts,e.dts,"")),s.forEach((function(t){switch(t.type){case 1:i=!0,l||(l=a.avcSample=d(!0,e.pts,e.dts,"")),l.frame=!0;var s=t.data;if(u&&s.length>4){var h=new T(s).readSliceType();2!==h&&4!==h&&7!==h&&9!==h||(l.key=!0)}break;case 5:i=!0,l||(l=a.avcSample=d(!0,e.pts,e.dts,"")),l.key=!0,l.frame=!0;break;case 6:i=!0,(n=new T(a.discardEPB(t.data))).readUByte();for(var f=0,p=0,g=!1,v=0;!g&&n.bytesAvailable>1;){f=0;do{f+=v=n.readUByte()}while(255===v);p=0;do{p+=v=n.readUByte()}while(255===v);if(4===f&&0!==n.bytesAvailable){if(g=!0,181===n.readUByte()&&49===n.readUShort()&&1195456820===n.readUInt()&&3===n.readUByte()){var y=n.readUByte(),A=31&y,b=[y,n.readUByte()];for(r=0;r16){var E=[];for(r=0;r<16;r++)E.push(n.readUByte().toString(16)),3!==r&&5!==r&&7!==r&&9!==r||E.push("-");var k=p-16,_=new Uint8Array(k);for(r=0;r0){if(t.pts>=e[n-1].pts)e.push(t);else for(var i=n-1;i>=0;i--)if(t.pts=0)i={data:e.subarray(d,a-l-1),type:r},c.push(i);else{var h=this._getLastNalUnit();if(h&&(u&&a<=4-u&&h.state&&(h.data=h.data.subarray(0,h.data.byteLength-u)),(n=a-l-1)>0)){var f=new Uint8Array(h.data.byteLength+n);f.set(h.data,0),f.set(e.subarray(0,n),h.data.byteLength),h.data=f}}a=0&&l>=0&&(i={data:e.subarray(d,o),type:r,state:l},c.push(i)),0===c.length){var p=this._getLastNalUnit();if(p){var g=new Uint8Array(p.data.byteLength+e.byteLength);g.set(p.data,0),g.set(e,p.data.byteLength),p.data=g}}return s.naluState=l,c},t.discardEPB=function(e){for(var t,n,i=e.byteLength,r=[],a=1;a1&&(s.logger.log("AAC: align PTS for overlapping frames by "+Math.round((E-m)/90)),m=E)}for(;a>24&255,t[1]=i>>16&255,t[2]=i>>8&255,t[3]=255&i,t.set(e,4),r=0,i=8;r>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,r>>24,r>>16&255,r>>8&255,255&r,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,n,i){return e.box(e.types.moof,e.mfhd(t),e.traf(i,n))},e.moov=function(t){for(var n=t.length,i=[];n--;)i[n]=e.trak(t[n]);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 n=t.length,i=[];n--;)i[n]=e.trex(t[n]);return e.box.apply(null,[e.types.mvex].concat(i))},e.mvhd=function(t,n){n*=t;var i=Math.floor(n/(w+1)),r=Math.floor(n%(w+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,r>>24,r>>16&255,r>>8&255,255&r,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(e.types.mvhd,a)},e.sdtp=function(t){var n,i,r=t.samples||[],a=new Uint8Array(4+r.length);for(i=0;i>>8&255),a.push(255&r),a=a.concat(Array.prototype.slice.call(i));for(n=0;n>>8&255),o.push(255&r),o=o.concat(Array.prototype.slice.call(i));var s=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(o))),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]),s,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 n=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,n>>8&255,255&n,0,0]),e.box(e.types.esds,e.esds(t)))},e.mp3=function(t){var n=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,n>>8&255,255&n,0,0]))},e.stsd=function(t){return"audio"===t.type?t.isAAC||"mp3"!==t.codec?e.box(e.types.stsd,e.STSD,e.mp4a(t)):e.box(e.types.stsd,e.STSD,e.mp3(t)):e.box(e.types.stsd,e.STSD,e.avc1(t))},e.tkhd=function(t){var n=t.id,i=t.duration*t.timescale,r=t.width,a=t.height,o=Math.floor(i/(w+1)),s=Math.floor(i%(w+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,n>>24&255,n>>16&255,n>>8&255,255&n,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,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,r>>8&255,255&r,0,0,a>>8&255,255&a,0,0]))},e.traf=function(t,n){var i=e.sdtp(t),r=t.id,a=Math.floor(n/(w+1)),o=Math.floor(n%(w+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,i.length+16+20+8+16+8+8),i)},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 n=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,n){var i,r,a,o,s,l,u=t.samples||[],c=u.length,d=12+16*c,h=new Uint8Array(d);for(n+=8+d,h.set([0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,n>>>24&255,n>>>16&255,n>>>8&255,255&n],0),i=0;i>>24&255,a>>>16&255,a>>>8&255,255&a,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.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 n,i=e.moov(t);return(n=new Uint8Array(e.FTYP.byteLength+i.byteLength)).set(e.FTYP),n.set(i,e.FTYP.byteLength),n},e}();function L(e,t,n,i){void 0===n&&(n=1),void 0===i&&(i=!1);var r=e*t*n;return i?Math.round(r):r}function D(e,t){return void 0===t&&(t=!1),L(e,1e3,1/9e4,t)}function I(e,t){return void 0===t&&(t=1),L(e,9e4,1/t)}var P,x=I(10),N=I(.2),M=function(){function e(e,t,n,i){this.observer=e,this.config=t,this.typeSupported=n;var r=navigator.userAgent;this.isSafari=i&&i.indexOf("Apple")>-1&&r&&!r.match("CriOS"),this.ISGenerated=!1}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(e){this._initPTS=this._initDTS=e},t.resetInitSegment=function(){this.ISGenerated=!1},t.remux=function(e,t,n,r,a,o,l){if(this.ISGenerated||this.generateIS(e,t,a),this.ISGenerated){var u=e.samples.length,c=t.samples.length,d=a,h=a;if(u&&c){var f=(e.samples[0].pts-t.samples[0].pts)/t.inputTimeScale;d+=Math.max(0,f),h+=Math.max(0,-f)}if(u){e.timescale||(s.logger.warn("regenerate InitSegment as audio detected"),this.generateIS(e,t,a));var p,g=this.remuxAudio(e,d,o,l);c&&(g&&(p=g.endPTS-g.startPTS),t.timescale||(s.logger.warn("regenerate InitSegment as video detected"),this.generateIS(e,t,a)),this.remuxVideo(t,h,o,p,l))}else if(c){var v=this.remuxVideo(t,h,o,0,l);v&&e.codec&&this.remuxEmptyAudio(e,d,o,v)}}n.samples.length&&this.remuxID3(n,a),r.samples.length&&this.remuxText(r,a),this.observer.trigger(i.default.FRAG_PARSED)},t.generateIS=function(e,t,n){var a,o,l=this.observer,u=e.samples,c=t.samples,d=this.typeSupported,h="audio/mp4",f={},p={tracks:f},g=void 0===this._initPTS;if(g&&(a=o=1/0),e.config&&u.length&&(e.timescale=e.samplerate,s.logger.log("audio sampling rate : "+e.samplerate),e.isAAC||(d.mpeg?(h="audio/mpeg",e.codec=""):d.mp3&&(e.codec="mp3")),f.audio={container:h,codec:e.codec,initSegment:!e.isAAC&&d.mpeg?new Uint8Array:O.initSegment([e]),metadata:{channelCount:e.channelCount}},g&&(a=o=u[0].pts-e.inputTimeScale*n)),t.sps&&t.pps&&c.length){var v=t.inputTimeScale;t.timescale=v,f.video={container:"video/mp4",codec:t.codec,initSegment:O.initSegment([t]),metadata:{width:t.width,height:t.height}},g&&(a=Math.min(a,c[0].pts-v*n),o=Math.min(o,c[0].dts-v*n),this.observer.trigger(i.default.INIT_PTS_FOUND,{initPTS:a}))}Object.keys(f).length?(l.trigger(i.default.FRAG_PARSING_INIT_SEGMENT,p),this.ISGenerated=!0,g&&(this._initPTS=a,this._initDTS=o)):l.trigger(i.default.ERROR,{type:r.ErrorTypes.MEDIA_ERROR,details:r.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"no audio/video samples found"})},t.remuxVideo=function(e,t,n,a,o){var l,u,c,d,h,f,p,g=8,v=e.timescale,m=e.samples,y=[],A=m.length,b=this._PTSNormalize,E=this._initPTS,T=this.nextAvcDts,k=this.isSafari;if(0!==A){k&&(n|=m.length&&T&&(o&&Math.abs(t-T/v)<.1||Math.abs(m[0].pts-T-E)1?s.logger.log("AVC: "+D(R,!0)+" ms hole between fragments detected,filling it"):R<-1&&s.logger.log("AVC: "+D(-R,!0)+" ms overlapping between fragments detected"),h=T,m[0].dts=h,d=Math.max(d-R,T),m[0].pts=d,s.logger.log("Video: PTS/DTS adjusted: "+D(d,!0)+"/"+D(h,!0)+", delta: "+D(R,!0)+" ms")),C=m[m.length-1],p=Math.max(C.dts,0),f=Math.max(C.pts,0,p),k&&(l=Math.round((p-h)/(m.length-1)));for(var w=0,L=0,I=0;I0?V-1:V].dts;if(Z.stretchShortVideoTrack){var J=Z.maxBufferHole,ee=Math.floor(J*v),te=(a?d+a*v:this.nextAudioPts)-K.pts;te>ee?((l=te-Q)<0&&(l=Q),s.logger.log("It is approximately "+D(te,!1)+" ms to the next segment; using duration "+D(l,!1)+" ms for the last video frame.")):l=Q}else l=Q}H=Math.round(K.pts-K.dts)}y.push({size:Y,duration:l,cts:H,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:K.key?2:1,isNonSync:K.key?0:1}})}this.nextAvcDts=p+l;var ne=e.dropped;if(e.nbNalu=0,e.dropped=0,y.length&&navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var ie=y[0].flags;ie.dependsOn=2,ie.isNonSync=0}e.samples=y,c=O.moof(e.sequenceNumber++,h,e),e.samples=[];var re={data1:c,data2:u,startPTS:d/v,endPTS:(f+l)/v,startDTS:h/v,endDTS:this.nextAvcDts/v,type:"video",hasAudio:!1,hasVideo:!0,nb:y.length,dropped:ne};return this.observer.trigger(i.default.FRAG_PARSING_DATA,re),re}},t.remuxAudio=function(e,t,n,a){var o,l,u,c,d,h,f=e.inputTimeScale,p=e.timescale,g=f/p,v=(e.isAAC?1024:1152)*g,m=this._PTSNormalize,y=this._initPTS,A=!e.isAAC&&this.typeSupported.mpeg,b=A?0:8,E=e.samples,T=[],k=this.nextAudioPts;if(n|=E.length&&k&&(a&&Math.abs(t-k/f)<.1||Math.abs(E[0].pts-k-y)<20*v),E.forEach((function(e){e.pts=e.dts=m(e.pts-y,t*f)})),0!==(E=E.filter((function(e){return e.pts>=0}))).length){if(n||(k=a?t*f:E[0].pts),e.isAAC)for(var _=this.config.maxAudioFramesDrift,S=0,C=k;S=_*v&&w0&&G0&&((l=R.getSilentFrame(e.manifestCodec||e.codec,e.channelCount))||(l=V.subarray()),F+=Y*l.length);else if(G<-12){s.logger.log("drop overlapping AAC sample, expected/parsed/delta: "+D(k,!0)+" ms / "+D(K,!0)+" ms / "+D(-G,!0)+" ms"),F-=V.byteLength;continue}K=k}if(d=K,!(F>0))return;F+=b;try{u=new Uint8Array(F)}catch(e){return void this.observer.trigger(i.default.ERROR,{type:r.ErrorTypes.MUX_ERROR,details:r.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:F,reason:"fail allocating audio mdat "+F})}A||(new DataView(u.buffer).setUint32(0,F),u.set(O.types.mdat,4));for(var H=0;H=2&&(z=T[M-2].duration,o.duration=z),M){this.nextAudioPts=k=h+g*z,e.samples=T,c=A?new Uint8Array:O.moof(e.sequenceNumber++,d/g,e),e.samples=[];var W=d/f,q=k/f,X={data1:c,data2:u,startPTS:W,endPTS:q,startDTS:W,endDTS:q,type:"audio",hasAudio:!0,hasVideo:!1,nb:M};return this.observer.trigger(i.default.FRAG_PARSING_DATA,X),X}return null}},t.remuxEmptyAudio=function(e,t,n,i){var r=e.inputTimeScale,a=r/(e.samplerate?e.samplerate:r),o=this.nextAudioPts,l=(void 0!==o?o:i.startDTS*r)+this._initDTS,u=i.endDTS*r+this._initDTS,c=1024*a,d=Math.ceil((u-l)/c),h=R.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(s.logger.warn("remux empty Audio"),h){for(var f=[],p=0;p4294967296;)e+=n;return e},e}(),F=function(){function e(e){this.observer=e}var t=e.prototype;return t.destroy=function(){},t.resetTimeStamp=function(){},t.resetInitSegment=function(){},t.remux=function(e,t,n,r,a,o,s,l){var u=this.observer,c="";e&&(c+="audio"),t&&(c+="video"),u.trigger(i.default.FRAG_PARSING_DATA,{data1:l,startPTS:a,startDTS:a,type:c,hasAudio:!!e,hasVideo:!!t,nb:1,dropped:0}),u.trigger(i.default.FRAG_PARSED)},e}(),B=Object(l.getSelfScope)();try{P=B.performance.now.bind(B.performance)}catch(e){s.logger.debug("Unable to use Performance API on this environment"),P=B.Date.now}var U=function(){function e(e,t,n,i){this.observer=e,this.typeSupported=t,this.config=n,this.vendor=i}var t=e.prototype;return t.destroy=function(){var e=this.demuxer;e&&e.destroy()},t.push=function(e,t,n,r,o,s,l,u,c,d,h,f){var p=this;if(e.byteLength>0&&null!=t&&null!=t.key&&"AES-128"===t.method){var g=this.decrypter;null==g&&(g=this.decrypter=new a.default(this.observer,this.config));var v=P();g.decrypt(e,t.key.buffer,t.iv.buffer,(function(e){var a=P();p.observer.trigger(i.default.FRAG_DECRYPTED,{stats:{tstart:v,tdecrypt:a}}),p.pushDecrypted(new Uint8Array(e),t,new Uint8Array(n),r,o,s,l,u,c,d,h,f)}))}else this.pushDecrypted(new Uint8Array(e),t,new Uint8Array(n),r,o,s,l,u,c,d,h,f)},t.pushDecrypted=function(e,t,n,a,o,s,l,u,c,d,h,f){var p=this.demuxer;if(!p||(l||u)&&!this.probe(e)){for(var g=this.observer,v=this.typeSupported,m=this.config,b=[{demux:S,remux:M},{demux:A.default,remux:F},{demux:y,remux:M},{demux:C,remux:M}],E=0,T=b.length;E1?n-1:0),r=1;r1?n-1:0),r=1;r0)return t.subarray(i,i+r)},e._readSize=function(e,t){var n=0;return n=(127&e[t])<<21,n|=(127&e[t+1])<<14,n|=(127&e[t+2])<<7,n|=127&e[t+3]},e.getTimeStamp=function(t){for(var n=e.getID3Frames(t),i=0;i>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:c+=String.fromCharCode(a);break;case 12:case 13:s=e[d++],c+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=e[d++],l=e[d++],c+=String.fromCharCode((15&a)<<12|(63&s)<<6|(63&l)<<0)}}return c},e}();function o(){var e=Object(r.getSelfScope)();return i||void 0===e.TextDecoder||(i=new e.TextDecoder("utf-8")),i}var s=a._utf8ArrayToStr;t.default=a},"./src/demux/mp4demuxer.js": /*!*********************************!*\ !*** ./src/demux/mp4demuxer.js ***! \*********************************/ /*! exports provided: default */function(e,t,n){n.r(t);var i=n(/*! ../utils/logger */"./src/utils/logger.js"),r=n(/*! ../events */"./src/events.js"),a=Math.pow(2,32)-1,o=function(){function e(e,t){this.observer=e,this.remuxer=t}var t=e.prototype;return t.resetTimeStamp=function(e){this.initPTS=e},t.resetInitSegment=function(t,n,i,a){if(t&&t.byteLength){var o=this.initData=e.parseInitSegment(t);null==n&&(n="mp4a.40.5"),null==i&&(i="avc1.42e01e");var s={};o.audio&&o.video?s.audiovideo={container:"video/mp4",codec:n+","+i,initSegment:a?t:null}:(o.audio&&(s.audio={container:"audio/mp4",codec:n,initSegment:a?t:null}),o.video&&(s.video={container:"video/mp4",codec:i,initSegment:a?t:null})),this.observer.trigger(r.default.FRAG_PARSING_INIT_SEGMENT,{tracks:s})}else n&&(this.audioCodec=n),i&&(this.videoCodec=i)},e.probe=function(t){return e.findBox({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},e.bin2str=function(e){return String.fromCharCode.apply(null,e)},e.readUint16=function(e,t){e.data&&(t+=e.start,e=e.data);var n=e[t]<<8|e[t+1];return n<0?65536+n:n},e.readUint32=function(e,t){e.data&&(t+=e.start,e=e.data);var n=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3];return n<0?4294967296+n:n},e.writeUint32=function(e,t,n){e.data&&(t+=e.start,e=e.data),e[t]=n>>24,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n},e.findBox=function(t,n){var i,r,a,o,s,l,u=[];if(t.data?(s=t.start,a=t.end,t=t.data):(s=0,a=t.byteLength),!n.length)return null;for(i=s;i1?i+r:a,e.bin2str(t.subarray(i+4,i+8))===n[0]&&(1===n.length?u.push({data:t,start:i+8,end:l}):(o=e.findBox({data:t,start:i+8,end:l},n.slice(1))).length&&(u=u.concat(o))),i=l;return u},e.parseSegmentIndex=function(t){var n,i=e.findBox(t,["moov"])[0],r=i?i.end:null,a=0,o=e.findBox(t,["sidx"]);if(!o||!o[0])return null;n=[];var s=(o=o[0]).data[0];a=0===s?8:16;var l=e.readUint32(o,a);a+=4,a+=0===s?8:16,a+=2;var u=o.end+0,c=e.readUint16(o,a);a+=2;for(var d=0;d>>31)return void console.warn("SIDX has hierarchical references (not supported)");var g=e.readUint32(o,h);h+=4,n.push({referenceSize:p,subsegmentDuration:g,info:{duration:g/l,start:u,end:u+p-1}}),u+=p,a=h+=4}return{earliestPresentationTime:0,timescale:l,version:s,referencesCount:c,references:n,moovEndOffset:r}},e.parseInitSegment=function(t){var n=[];return e.findBox(t,["moov","trak"]).forEach((function(t){var r=e.findBox(t,["tkhd"])[0];if(r){var a=r.data[r.start],o=0===a?12:20,s=e.readUint32(r,o),l=e.findBox(t,["mdia","mdhd"])[0];if(l){o=0===(a=l.data[l.start])?12:20;var u=e.readUint32(l,o),c=e.findBox(t,["mdia","hdlr"])[0];if(c){var d={soun:"audio",vide:"video"}[e.bin2str(c.data.subarray(c.start+8,c.start+12))];if(d){var h=e.findBox(t,["mdia","minf","stbl","stsd"]);if(h.length){h=h[0];var f=e.bin2str(h.data.subarray(h.start+12,h.start+16));i.logger.log("MP4Demuxer:"+d+":"+f+" found")}n[s]={timescale:u,type:d},n[d]={timescale:u,id:s}}}}}})),n},e.getStartDTS=function(t,n){var i,r,a;return i=e.findBox(n,["moof","traf"]),r=[].concat.apply([],i.map((function(n){return e.findBox(n,["tfhd"]).map((function(i){var r,a;return r=e.readUint32(i,4),a=t[r].timescale||9e4,e.findBox(n,["tfdt"]).map((function(t){var n,i;return n=t.data[t.start],i=e.readUint32(t,4),1===n&&(i*=Math.pow(2,32),i+=e.readUint32(t,8)),i}))[0]/a}))}))),a=Math.min.apply(null,r),isFinite(a)?a:0},e.offsetStartDTS=function(t,n,i){e.findBox(n,["moof","traf"]).map((function(n){return e.findBox(n,["tfhd"]).map((function(r){var o=e.readUint32(r,4),s=t[o].timescale||9e4;e.findBox(n,["tfdt"]).map((function(t){var n=t.data[t.start],r=e.readUint32(t,4);if(0===n)e.writeUint32(t,4,r-i*s);else{r*=Math.pow(2,32),r+=e.readUint32(t,8),r-=i*s,r=Math.max(r,0);var o=Math.floor(r/(a+1)),l=Math.floor(r%(a+1));e.writeUint32(t,4,o),e.writeUint32(t,8,l)}}))}))}))},t.append=function(t,n,i,a){var o=this.initData;o||(this.resetInitSegment(t,this.audioCodec,this.videoCodec,!1),o=this.initData);var s,l=this.initPTS;if(void 0===l){var u=e.getStartDTS(o,t);this.initPTS=l=u-n,this.observer.trigger(r.default.INIT_PTS_FOUND,{initPTS:l})}e.offsetStartDTS(o,t,l),s=e.getStartDTS(o,t),this.remuxer.remux(o.audio,o.video,null,null,s,i,a,t)},t.destroy=function(){},e}();t.default=o},"./src/errors.ts": /*!***********************!*\ !*** ./src/errors.ts ***! \***********************/ /*! exports provided: ErrorTypes, ErrorDetails */function(e,t,n){var i,r;n.r(t),n.d(t,"ErrorTypes",(function(){return i})),n.d(t,"ErrorDetails",(function(){return r})),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_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.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_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"}(r||(r={}))},"./src/events.js": /*!***********************!*\ !*** ./src/events.js ***! \***********************/ /*! exports provided: default */function(e,t,n){n.r(t),t.default={MEDIA_ATTACHING:"hlsMediaAttaching",MEDIA_ATTACHED:"hlsMediaAttached",MEDIA_DETACHING:"hlsMediaDetaching",MEDIA_DETACHED:"hlsMediaDetached",BUFFER_RESET:"hlsBufferReset",BUFFER_CODECS:"hlsBufferCodecs",BUFFER_CREATED:"hlsBufferCreated",BUFFER_APPENDING:"hlsBufferAppending",BUFFER_APPENDED:"hlsBufferAppended",BUFFER_EOS:"hlsBufferEos",BUFFER_FLUSHING:"hlsBufferFlushing",BUFFER_FLUSHED:"hlsBufferFlushed",MANIFEST_LOADING:"hlsManifestLoading",MANIFEST_LOADED:"hlsManifestLoaded",MANIFEST_PARSED:"hlsManifestParsed",LEVEL_SWITCHING:"hlsLevelSwitching",LEVEL_SWITCHED:"hlsLevelSwitched",LEVEL_LOADING:"hlsLevelLoading",LEVEL_LOADED:"hlsLevelLoaded",LEVEL_UPDATED:"hlsLevelUpdated",LEVEL_PTS_UPDATED:"hlsLevelPtsUpdated",AUDIO_TRACKS_UPDATED:"hlsAudioTracksUpdated",AUDIO_TRACK_SWITCHING:"hlsAudioTrackSwitching",AUDIO_TRACK_SWITCHED:"hlsAudioTrackSwitched",AUDIO_TRACK_LOADING:"hlsAudioTrackLoading",AUDIO_TRACK_LOADED:"hlsAudioTrackLoaded",SUBTITLE_TRACKS_UPDATED:"hlsSubtitleTracksUpdated",SUBTITLE_TRACK_SWITCH:"hlsSubtitleTrackSwitch",SUBTITLE_TRACK_LOADING:"hlsSubtitleTrackLoading",SUBTITLE_TRACK_LOADED:"hlsSubtitleTrackLoaded",SUBTITLE_FRAG_PROCESSED:"hlsSubtitleFragProcessed",INIT_PTS_FOUND:"hlsInitPtsFound",FRAG_LOADING:"hlsFragLoading",FRAG_LOAD_PROGRESS:"hlsFragLoadProgress",FRAG_LOAD_EMERGENCY_ABORTED:"hlsFragLoadEmergencyAborted",FRAG_LOADED:"hlsFragLoaded",FRAG_DECRYPTED:"hlsFragDecrypted",FRAG_PARSING_INIT_SEGMENT:"hlsFragParsingInitSegment",FRAG_PARSING_USERDATA:"hlsFragParsingUserdata",FRAG_PARSING_METADATA:"hlsFragParsingMetadata",FRAG_PARSING_DATA:"hlsFragParsingData",FRAG_PARSED:"hlsFragParsed",FRAG_BUFFERED:"hlsFragBuffered",FRAG_CHANGED:"hlsFragChanged",FPS_DROP:"hlsFpsDrop",FPS_DROP_LEVEL_CAPPING:"hlsFpsDropLevelCapping",ERROR:"hlsError",DESTROYING:"hlsDestroying",KEY_LOADING:"hlsKeyLoading",KEY_LOADED:"hlsKeyLoaded",STREAM_STATE_TRANSITION:"hlsStreamStateTransition",LIVE_BACK_BUFFER_REACHED:"hlsLiveBackBufferReached"}},"./src/hls.ts": /*!*********************************!*\ !*** ./src/hls.ts + 50 modules ***! \*********************************/ /*! exports provided: default */ /*! ModuleConcatenation bailout: Cannot concat with ./src/crypt/decrypter.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/demux/demuxer-inline.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/demux/id3.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/demux/mp4demuxer.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/errors.ts because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/events.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/polyfills/number-isFinite.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/utils/get-self-scope.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./src/utils/logger.js because of ./src/demux/demuxer-worker.js */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/eventemitter3/index.js (<- Module is not an ECMAScript module) */ /*! ModuleConcatenation bailout: Cannot concat with ./node_modules/url-toolkit/src/url-toolkit.js (<- Module is not an ECMAScript module) */function(e,t,n){n.r(t);var i={};n.r(i),n.d(i,"newCue",(function(){return vt}));var r,a,o=n("./node_modules/url-toolkit/src/url-toolkit.js"),s=n("./src/errors.ts"),l=n("./src/polyfills/number-isFinite.js"),u=n("./src/events.js"),c=n("./src/utils/logger.js"),d={hlsEventGeneric:!0,hlsHandlerDestroying:!0,hlsHandlerDestroyed:!0},h=function(){function e(e){this.hls=void 0,this.handledEvents=void 0,this.useGenericHandler=void 0,this.hls=e,this.onEvent=this.onEvent.bind(this);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i>8*(15-n)&255;return t},r.setDecryptDataFromLevelKey=function(e,t){var n=e;return e&&e.method&&e.uri&&!e.iv&&((n=new v(e.baseuri,e.reluri)).method=e.method,n.iv=this.createInitializationVector(t)),n},t=e,(n=[{key:"url",get:function(){return!this._url&&this.relurl&&(this._url=Object(o.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url},set:function(e){this._url=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:"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&&c.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:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(l.isFiniteNumber)(this.programDateTime))return null;var e=Object(l.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){return!(!this.decryptdata||null===this.decryptdata.uri||null!==this.decryptdata.key)}}])&&m(t.prototype,n),i&&m(t,i),e}();function A(e,t){for(var n=0;nNumber.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 n=new Uint8Array(t.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.enumeratedString=function(e){return this[e]},t.decimalResolution=function(e){var t=E.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e){var t,n={};for(T.lastIndex=0;null!==(t=T.exec(e));){var i=t[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),n[t[1]]=i}return n},e}(),_={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,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,drac:!0,dvav:!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}};function S(e,t){return MediaSource.isTypeSupported((t||"video")+'/mp4;codecs="'+e+'"')}var C=/#EXT-X-STREAM-INF:([^\n\r]*)[\r\n]+([^\r\n]+)/g,R=/#EXT-X-MEDIA:(.*)/g,w=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/|(?!#)([\S+ ?]+)/.source,/|#EXT-X-BYTERANGE:*(.+)/.source,/|#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/|#.*/.source].join(""),"g"),O=/(?:(?:#(EXTM3U))|(?:#EXT-X-(PLAYLIST-TYPE):(.+))|(?:#EXT-X-(MEDIA-SEQUENCE): *(\d+))|(?:#EXT-X-(TARGETDURATION): *(\d+))|(?:#EXT-X-(KEY):(.+))|(?:#EXT-X-(START):(.+))|(?:#EXT-X-(ENDLIST))|(?:#EXT-X-(DISCONTINUITY-SEQ)UENCE:(\d+))|(?:#EXT-X-(DIS)CONTINUITY))|(?:#EXT-X-("0.4.1"):(\d+))|(?:#EXT-X-(MAP):(.+))|(?:(#)([^:]*):(.*))|(?:(#)(.*))(?:.*)\r?\n?/,L=/\.(mp4|m4s|m4v|m4a)$/i,D=function(){function e(){}return e.findGroup=function(e,t){for(var n=0;n2?(t=n.shift()+".",t+=parseInt(n.shift()).toString(16),t+=("000"+parseInt(n.shift()).toString(16)).substr(-4)):t=e,t},e.resolve=function(e,t){return o.buildAbsoluteURL(t,e,{alwaysNormalize:!0})},e.parseMasterPlaylist=function(t,n){var i,r=[];function a(e,t){["video","audio"].forEach((function(n){var i=e.filter((function(e){return function(e,t){var n=_[t];return!!n&&!0===n[e.slice(0,4)]}(e,n)}));if(i.length){var r=i.filter((function(e){return 0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)}));t[n+"Codec"]=r.length>0?r[0]:i[0],e=e.filter((function(e){return-1===i.indexOf(e)}))}})),t.unknownCodecs=e}for(C.lastIndex=0;null!=(i=C.exec(t));){var o={},s=o.attrs=new k(i[1]);o.url=e.resolve(i[2],n);var l=s.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),o.bitrate=s.decimalInteger("AVERAGE-BANDWIDTH")||s.decimalInteger("BANDWIDTH"),o.name=s.NAME,a([].concat((s.CODECS||"").split(/[ ,]+/)),o),o.videoCodec&&-1!==o.videoCodec.indexOf("avc1")&&(o.videoCodec=e.convertAVC1ToAVCOTI(o.videoCodec)),r.push(o)}return r},e.parseMasterPlaylistMedia=function(t,n,i,r){var a;void 0===r&&(r=[]);var o=[],s=0;for(R.lastIndex=0;null!==(a=R.exec(t));){var l=new k(a[1]);if(l.TYPE===i){var u={id:s++,groupId:l["GROUP-ID"],name:l.NAME||l.LANGUAGE,type:i,default:"YES"===l.DEFAULT,autoselect:"YES"===l.AUTOSELECT,forced:"YES"===l.FORCED,lang:l.LANGUAGE};if(l.URI&&(u.url=e.resolve(l.URI,n)),r.length){var c=e.findGroup(r,u.groupId);u.audioCodec=c?c.codec:r[0].codec}o.push(u)}}return o},e.parseLevelPlaylist=function(e,t,n,i,r){var a,o,s,u=0,d=0,h=new b(t),f=0,p=null,g=new y,m=null;for(w.lastIndex=0;null!==(a=w.exec(e));){var A=a[1];if(A){g.duration=parseFloat(A);var E=(" "+a[2]).slice(1);g.title=E||null,g.tagList.push(E?["INF",A,E]:["INF",A])}else if(a[3]){if(Object(l.isFiniteNumber)(g.duration)){var T=u++;g.type=i,g.start=d,s&&(g.levelkey=s),g.sn=T,g.level=n,g.cc=f,g.urlId=r,g.baseurl=t,g.relurl=(" "+a[3]).slice(1),I(g,p),h.fragments.push(g),p=g,d+=g.duration,g=new y}}else if(a[4]){var _=(" "+a[4]).slice(1);p?g.setByteRange(_,p):g.setByteRange(_)}else if(a[5])g.rawProgramDateTime=(" "+a[5]).slice(1),g.tagList.push(["PROGRAM-DATE-TIME",g.rawProgramDateTime]),null===m&&(m=h.fragments.length);else{if(!(a=a[0].match(O))){c.logger.warn("No matches on slow regex match for level playlist!");continue}for(o=1;o=0&&(s.method=D,s.key=null,s.iv=x));break;case"START":var N=new k(S).decimalFloatingPoint("TIME-OFFSET");Object(l.isFiniteNumber)(N)&&(h.startTimeOffset=N);break;case"MAP":var M=new k(S);g.relurl=M.URI,M.BYTERANGE&&g.setByteRange(M.BYTERANGE),g.baseurl=t,g.level=n,g.type=i,g.sn="initSegment",h.initSegment=g,(g=new y).rawProgramDateTime=h.initSegment.rawProgramDateTime;break;default:c.logger.warn("line parsed but not handled: "+a)}}}return(g=p)&&!g.relurl&&(h.fragments.pop(),d-=g.duration),h.totalduration=d,h.averagetargetduration=d/h.fragments.length,h.endSN=u-1,h.startCC=h.fragments[0]?h.fragments[0].cc:0,h.endCC=f,!h.initSegment&&h.fragments.length&&h.fragments.every((function(e){return L.test(e.relurl)}))&&(c.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(g=new y).relurl=h.fragments[0].relurl,g.baseurl=t,g.level=n,g.type=i,g.sn="initSegment",h.initSegment=g,h.needSidxRanges=!0),m&&function(e,t){for(var n=e[t],i=t-1;i>=0;i--){var r=e[i];r.programDateTime=n.programDateTime-1e3*r.duration,n=r}}(h.fragments,m),h},e}();function I(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),Object(l.isFiniteNumber)(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}var P=window.performance,x=function(e){var t,n;function i(t){var n;return(n=e.call(this,t,u.default.MANIFEST_LOADING,u.default.LEVEL_LOADING,u.default.AUDIO_TRACK_LOADING,u.default.SUBTITLE_TRACK_LOADING)||this).loaders={},n}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,i.canHaveQualityLevels=function(e){return e!==r.AUDIO_TRACK&&e!==r.SUBTITLE_TRACK},i.mapContextToLevelType=function(e){switch(e.type){case r.AUDIO_TRACK:return a.AUDIO;case r.SUBTITLE_TRACK:return a.SUBTITLE;default:return a.MAIN}},i.getResponseUrl=function(e,t){var n=e.url;return void 0!==n&&0!==n.indexOf("data:")||(n=t.url),n};var o=i.prototype;return o.createInternalLoader=function(e){var t=this.hls.config,n=t.pLoader,i=t.loader,r=new(n||i)(t);return e.loader=r,this.loaders[e.type]=r,r},o.getInternalLoader=function(e){return this.loaders[e.type]},o.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},o.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},o.destroy=function(){this.destroyInternalLoaders(),e.prototype.destroy.call(this)},o.onManifestLoading=function(e){this.load({url:e.url,type:r.MANIFEST,level:0,id:null,responseType:"text"})},o.onLevelLoading=function(e){this.load({url:e.url,type:r.LEVEL,level:e.level,id:e.id,responseType:"text"})},o.onAudioTrackLoading=function(e){this.load({url:e.url,type:r.AUDIO_TRACK,level:null,id:e.id,responseType:"text"})},o.onSubtitleTrackLoading=function(e){this.load({url:e.url,type:r.SUBTITLE_TRACK,level:null,id:e.id,responseType:"text"})},o.load=function(e){var t=this.hls.config;c.logger.debug("Loading playlist of type "+e.type+", level: "+e.level+", id: "+e.id);var n,i,a,o,s=this.getInternalLoader(e);if(s){var l=s.context;if(l&&l.url===e.url)return c.logger.trace("playlist request ongoing"),!1;c.logger.warn("aborting previous loader for type: "+e.type),s.abort()}switch(e.type){case r.MANIFEST:n=t.manifestLoadingMaxRetry,i=t.manifestLoadingTimeOut,a=t.manifestLoadingRetryDelay,o=t.manifestLoadingMaxRetryTimeout;break;case r.LEVEL:n=0,o=0,a=0,i=t.levelLoadingTimeOut;break;default:n=t.levelLoadingMaxRetry,i=t.levelLoadingTimeOut,a=t.levelLoadingRetryDelay,o=t.levelLoadingMaxRetryTimeout}s=this.createInternalLoader(e);var u={timeout:i,maxRetry:n,retryDelay:a,maxRetryDelay:o},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};return c.logger.debug("Calling internal loader delegate for URL: "+e.url),s.load(e,u,d),!0},o.loadsuccess=function(e,t,n,i){if(void 0===i&&(i=null),n.isSidxRequest)return this._handleSidxRequest(e,n),void this._handlePlaylistLoaded(e,t,n,i);if(this.resetInternalLoader(n.type),"string"!=typeof e.data)throw new Error('expected responseType of "text" for PlaylistLoader');var r=e.data;t.tload=P.now(),0===r.indexOf("#EXTM3U")?r.indexOf("#EXTINF:")>0||r.indexOf("#EXT-X-TARGETDURATION:")>0?this._handleTrackOrLevelPlaylist(e,t,n,i):this._handleMasterPlaylist(e,t,n,i):this._handleManifestParsingError(e,n,"no EXTM3U delimiter",i)},o.loaderror=function(e,t,n){void 0===n&&(n=null),this._handleNetworkError(t,n,!1,e)},o.loadtimeout=function(e,t,n){void 0===n&&(n=null),this._handleNetworkError(t,n,!0)},o._handleMasterPlaylist=function(e,t,n,r){var a=this.hls,o=e.data,s=i.getResponseUrl(e,n),l=D.parseMasterPlaylist(o,s);if(l.length){var d=l.map((function(e){return{id:e.attrs.AUDIO,codec:e.audioCodec}})),h=D.parseMasterPlaylistMedia(o,s,"AUDIO",d),f=D.parseMasterPlaylistMedia(o,s,"SUBTITLES");if(h.length){var p=!1;h.forEach((function(e){e.url||(p=!0)})),!1===p&&l[0].audioCodec&&!l[0].attrs.AUDIO&&(c.logger.log("audio codec signaled in quality level, but no embedded audio track signaled, create one"),h.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1}))}a.trigger(u.default.MANIFEST_LOADED,{levels:l,audioTracks:h,subtitles:f,url:s,stats:t,networkDetails:r})}else this._handleManifestParsingError(e,n,"no level found in manifest",r)},o._handleTrackOrLevelPlaylist=function(e,t,n,a){var o=this.hls,s=n.id,c=n.level,d=n.type,h=i.getResponseUrl(e,n),f=Object(l.isFiniteNumber)(s)?s:0,p=Object(l.isFiniteNumber)(c)?c:f,g=i.mapContextToLevelType(n),v=D.parseLevelPlaylist(e.data,h,p,g,f);if(v.tload=t.tload,d===r.MANIFEST){var m={url:h,details:v};o.trigger(u.default.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:h,stats:t,networkDetails:a})}if(t.tparsed=P.now(),v.needSidxRanges){var y=v.initSegment.url;this.load({url:y,isSidxRequest:!0,type:d,level:c,levelDetails:v,id:s,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer"})}else n.levelDetails=v,this._handlePlaylistLoaded(e,t,n,a)},o._handleSidxRequest=function(e,t){if("string"==typeof e.data)throw new Error("sidx request must be made with responseType of array buffer");var n=f.default.parseSegmentIndex(new Uint8Array(e.data));if(n){var i=n.references,r=t.levelDetails;i.forEach((function(e,t){var n=e.info;if(r){var i=r.fragments[t];0===i.byteRange.length&&i.setByteRange(String(1+n.end-n.start)+"@"+String(n.start))}})),r&&r.initSegment.setByteRange(String(n.moovEndOffset)+"@0")}},o._handleManifestParsingError=function(e,t,n,i){this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:!0,url:e.url,reason:n,networkDetails:i})},o._handleNetworkError=function(e,t,n,i){var a,o;void 0===n&&(n=!1),void 0===i&&(i=null),c.logger.info("A network error occured while loading a "+e.type+"-type playlist");var l=this.getInternalLoader(e);switch(e.type){case r.MANIFEST:a=n?s.ErrorDetails.MANIFEST_LOAD_TIMEOUT:s.ErrorDetails.MANIFEST_LOAD_ERROR,o=!0;break;case r.LEVEL:a=n?s.ErrorDetails.LEVEL_LOAD_TIMEOUT:s.ErrorDetails.LEVEL_LOAD_ERROR,o=!1;break;case r.AUDIO_TRACK:a=n?s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,o=!1;break;default:o=!1}l&&(l.abort(),this.resetInternalLoader(e.type));var d={type:s.ErrorTypes.NETWORK_ERROR,details:a,fatal:o,url:e.url,loader:l,context:e,networkDetails:t};i&&(d.response=i),this.hls.trigger(u.default.ERROR,d)},o._handlePlaylistLoaded=function(e,t,n,a){var o=n.type,s=n.level,l=n.id,c=n.levelDetails;if(c&&c.targetduration)if(i.canHaveQualityLevels(n.type))this.hls.trigger(u.default.LEVEL_LOADED,{details:c,level:s||0,id:l||0,stats:t,networkDetails:a});else switch(o){case r.AUDIO_TRACK:this.hls.trigger(u.default.AUDIO_TRACK_LOADED,{details:c,id:l,stats:t,networkDetails:a});break;case r.SUBTITLE_TRACK:this.hls.trigger(u.default.SUBTITLE_TRACK_LOADED,{details:c,id:l,stats:t,networkDetails:a})}else this._handleManifestParsingError(e,n,"invalid target duration",a)},i}(h),N=function(e){var t,n;function i(t){var n;return(n=e.call(this,t,u.default.FRAG_LOADING)||this).loaders={},n}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var r=i.prototype;return r.destroy=function(){var t=this.loaders;for(var n in t){var i=t[n];i&&i.destroy()}this.loaders={},e.prototype.destroy.call(this)},r.onFragLoading=function(e){var t=e.frag,n=t.type,i=this.loaders,r=this.hls.config,a=r.fLoader,o=r.loader;t.loaded=0;var s,u,d,h=i[n];h&&(c.logger.warn("abort previous fragment loader for type: "+n),h.abort()),h=i[n]=t.loader=r.fLoader?new a(r):new o(r),s={url:t.url,frag:t,responseType:"arraybuffer",progressData:!1};var f=t.byteRangeStartOffset,p=t.byteRangeEndOffset;Object(l.isFiniteNumber)(f)&&Object(l.isFiniteNumber)(p)&&(s.rangeStart=f,s.rangeEnd=p),u={timeout:r.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:r.fragLoadingMaxRetryTimeout},d={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this),onProgress:this.loadprogress.bind(this)},h.load(s,u,d)},r.loadsuccess=function(e,t,n,i){void 0===i&&(i=null);var r=e.data,a=n.frag;a.loader=void 0,this.loaders[a.type]=void 0,this.hls.trigger(u.default.FRAG_LOADED,{payload:r,frag:a,stats:t,networkDetails:i})},r.loaderror=function(e,t,n){void 0===n&&(n=null);var i=t.frag,r=i.loader;r&&r.abort(),this.loaders[i.type]=void 0,this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t.frag,response:e,networkDetails:n})},r.loadtimeout=function(e,t,n){void 0===n&&(n=null);var i=t.frag,r=i.loader;r&&r.abort(),this.loaders[i.type]=void 0,this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t.frag,networkDetails:n})},r.loadprogress=function(e,t,n,i){void 0===i&&(i=null);var r=t.frag;r.loaded=e.loaded,this.hls.trigger(u.default.FRAG_LOAD_PROGRESS,{frag:r,stats:e,networkDetails:i})},i}(h),M=function(e){var t,n;function i(t){var n;return(n=e.call(this,t,u.default.KEY_LOADING)||this).loaders={},n.decryptkey=null,n.decrypturl=null,n}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var r=i.prototype;return r.destroy=function(){for(var t in this.loaders){var n=this.loaders[t];n&&n.destroy()}this.loaders={},e.prototype.destroy.call(this)},r.onKeyLoading=function(e){var t=e.frag,n=t.type,i=this.loaders[n];if(t.decryptdata){var r=t.decryptdata.uri;if(r!==this.decrypturl||null===this.decryptkey){var a=this.hls.config;if(i&&(c.logger.warn("abort previous key loader for type:"+n),i.abort()),!r)return void c.logger.warn("key uri is falsy");t.loader=this.loaders[n]=new a.loader(a),this.decrypturl=r,this.decryptkey=null;var o={url:r,frag:t,responseType:"arraybuffer"},s={timeout:a.fragLoadingTimeOut,maxRetry:0,retryDelay:a.fragLoadingRetryDelay,maxRetryDelay:a.fragLoadingMaxRetryTimeout},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};t.loader.load(o,s,l)}else this.decryptkey&&(t.decryptdata.key=this.decryptkey,this.hls.trigger(u.default.KEY_LOADED,{frag:t}))}else c.logger.warn("Missing decryption data on fragment in onKeyLoading")},r.loadsuccess=function(e,t,n){var i=n.frag;i.decryptdata?(this.decryptkey=i.decryptdata.key=new Uint8Array(e.data),i.loader=void 0,delete this.loaders[i.type],this.hls.trigger(u.default.KEY_LOADED,{frag:i})):c.logger.error("after key load, decryptdata unset")},r.loaderror=function(e,t){var n=t.frag,i=n.loader;i&&i.abort(),delete this.loaders[n.type],this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:n,response:e})},r.loadtimeout=function(e,t){var n=t.frag,i=n.loader;i&&i.abort(),delete this.loaders[n.type],this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:n})},i}(h),F="NOT_LOADED",B="APPENDING",U="PARTIAL",j="OK",V=function(e){var t,n;function i(t){var n;return(n=e.call(this,t,u.default.BUFFER_APPENDED,u.default.FRAG_BUFFERED,u.default.FRAG_LOADED)||this).bufferPadding=.2,n.fragments=Object.create(null),n.timeRanges=Object.create(null),n.config=t.config,n}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var r=i.prototype;return r.destroy=function(){this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.config=null,h.prototype.destroy.call(this),e.prototype.destroy.call(this)},r.getBufferedFrag=function(e,t){var n=this.fragments,i=Object.keys(n).filter((function(i){var r=n[i];if(r.body.type!==t)return!1;if(!r.buffered)return!1;var a=r.body;return a.startPTS<=e&&e<=a.endPTS}));if(0===i.length)return null;var r=i.pop();return n[r].body},r.detectEvictedFragments=function(e,t){var n,i,r=this;Object.keys(this.fragments).forEach((function(a){var o=r.fragments[a];if(!0===o.buffered){var s=o.range[e];if(s){n=s.time;for(var l=0;l=i&&t<=r){a.push({startPTS:Math.max(e,n.start(s)),endPTS:Math.min(t,n.end(s))});break}if(ei)a.push({startPTS:Math.max(e,n.start(s)),endPTS:Math.min(t,n.end(s))}),o=!0;else if(t<=i)break}return{time:a,partial:o}},r.getFragmentKey=function(e){return e.type+"_"+e.level+"_"+e.urlId+"_"+e.sn},r.getPartialFragment=function(e){var t,n,i,r=this,a=null,o=0;return Object.keys(this.fragments).forEach((function(s){var l=r.fragments[s];r.isPartial(l)&&(n=l.body.startPTS-r.bufferPadding,i=l.body.endPTS+r.bufferPadding,e>=n&&e<=i&&(t=Math.min(e-n,i-e),o<=t&&(a=l.body,o=t)))})),a},r.getState=function(e){var t=this.getFragmentKey(e),n=this.fragments[t],i=F;return void 0!==n&&(i=n.buffered?!0===this.isPartial(n)?U:j:B),i},r.isPartial=function(e){return!0===e.buffered&&(void 0!==e.range.video&&!0===e.range.video.partial||void 0!==e.range.audio&&!0===e.range.audio.partial)},r.isTimeBuffered=function(e,t,n){for(var i,r,a=0;a=i&&t<=r)return!0;if(t<=i)return!1}return!1},r.onFragLoaded=function(e){var t=e.frag;Object(l.isFiniteNumber)(t.sn)&&!t.bitrateTest&&(this.fragments[this.getFragmentKey(t)]={body:t,range:Object.create(null),buffered:!1})},r.onBufferAppended=function(e){var t=this;this.timeRanges=e.timeRanges,Object.keys(this.timeRanges).forEach((function(e){var n=t.timeRanges[e];t.detectEvictedFragments(e,n)}))},r.onFragBuffered=function(e){this.detectPartialFragments(e.frag)},r.hasFragment=function(e){var t=this.getFragmentKey(e);return void 0!==this.fragments[t]},r.removeFragment=function(e){var t=this.getFragmentKey(e);delete this.fragments[t]},r.removeAllFragments=function(){this.fragments=Object.create(null)},i}(h),K={search:function(e,t){for(var n=0,i=e.length-1,r=null,a=null;n<=i;){var o=t(a=e[r=(n+i)/2|0]);if(o>0)n=r+1;else{if(!(o<0))return a;i=r-1}}return null}},G=function(){function e(){}return e.isBuffered=function(e,t){try{if(e)for(var n=e.buffered,i=0;i=n.start(i)&&t<=n.end(i))return!0}catch(e){}return!1},e.bufferInfo=function(e,t,n){try{if(e){var i,r=e.buffered,a=[];for(i=0;io&&(i[a-1].end=e[r].end):i.push(e[r])}else i.push(e[r])}else i=e;for(var s,l=0,u=t,c=t,d=0;d=h&&t1?t-1:0),i=1;it?(i.duration=a-i.start,i.duration<0&&c.logger.warn("negative duration computed for frag "+i.sn+",level "+i.level+", there should be some duration drift between playlist and fragment!")):(r.duration=i.start-a,r.duration<0&&c.logger.warn("negative duration computed for frag "+r.sn+",level "+r.level+", there should be some duration drift between playlist and fragment!")):r.start=n>t?i.start+i.duration:Math.max(i.start-r.duration,0)}function te(e,t,n,i,r,a){var o=n;if(Object(l.isFiniteNumber)(t.startPTS)){var s=Math.abs(t.startPTS-n);Object(l.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(s,t.deltaPTS):t.deltaPTS=s,o=Math.max(n,t.startPTS),n=Math.min(n,t.startPTS),i=Math.max(i,t.endPTS),r=Math.min(r,t.startDTS),a=Math.max(a,t.endDTS)}var u=n-t.start;t.start=t.startPTS=n,t.maxStartPTS=o,t.endPTS=i,t.startDTS=r,t.endDTS=a,t.duration=i-n;var c,d,h,f=t.sn;if(!e||fe.endSN)return 0;for(c=f-e.startSN,(d=e.fragments)[c]=t,h=c;h>0;h--)ee(d,h,h-1);for(h=c;hi.length))for(var a=0;an.startCC||e&&e.cc=(e[e.length-1].endProgramDateTime||0))return null;n=n||0;for(var i=0;ie&&n.start?-1:0}function de(e,t,n){var i=1e3*Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0));return(n.endProgramDateTime||0)-i>e}var he=function(){function e(e,t,n,i){this.config=e,this.media=t,this.fragmentTracker=n,this.hls=i,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1}var t=e.prototype;return t.poll=function(e){var t=this.config,n=this.media,i=this.stalled,r=n.currentTime,a=n.seeking,o=this.seeking&&!a,s=!this.seeking&&a;if(this.seeking=a,r===e){if((s||o)&&(this.stalled=null),!n.paused&&!n.ended&&0!==n.playbackRate&&n.buffered.length){var l=G.bufferInfo(n,r,0),u=l.len>0,d=l.nextStart||0;if(u||d){if(a){if(l.len>2||!d||d-r>2)return;this.moved=!1}if(!this.moved&&this.stalled){var h=Math.max(d,l.start||0)-r;if(h>0&&h<=2)return void this._trySkipBufferHole(null)}var f=self.performance.now();if(null!==i){var p=f-i;!a&&p>=250&&this._reportStall(l.len);var g=G.bufferInfo(n,r,t.maxBufferHole);this._tryFixBufferStall(g,p)}else this.stalled=f}}}else if(this.moved=!0,null!==i){if(this.stallReported){var v=self.performance.now()-i;c.logger.warn("playback not stuck anymore @"+r+", after "+Math.round(v)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},t._tryFixBufferStall=function(e,t){var n=this.config,i=this.fragmentTracker,r=this.media.currentTime,a=i.getPartialFragment(r);a&&this._trySkipBufferHole(a)||e.len>n.maxBufferHole&&t>1e3*n.highBufferWatchdogPeriod&&(c.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},t._reportStall=function(e){var t=this.hls,n=this.media;this.stallReported||(this.stallReported=!0,c.logger.warn("Playback stalling at @"+n.currentTime+" due to low buffer"),t.trigger(u.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:e}))},t._trySkipBufferHole=function(e){for(var t=this.config,n=this.hls,i=this.media,r=i.currentTime,a=0,o=0;o=a&&r1?i-1:0),a=1;a1&&(this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)),this._tickCallCount=0)},r.doTick=function(){},i}(h),ge="STOPPED",ve="STARTING",me="IDLE",ye="PAUSED",Ae="KEY_LOADING",be="FRAG_LOADING",Ee="FRAG_LOADING_WAITING_RETRY",Te="WAITING_TRACK",ke="PARSING",_e="PARSED",Se="BUFFER_FLUSHING",Ce="ENDED",Re="ERROR",we="WAITING_INIT_PTS",Oe="WAITING_LEVEL",Le=function(e){var t,n;function i(){return e.apply(this,arguments)||this}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var r=i.prototype;return r.doTick=function(){},r.startLoad=function(){},r.stopLoad=function(){var e=this.fragCurrent;e&&(e.loader&&e.loader.abort(),this.fragmentTracker.removeFragment(e)),this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ge},r._streamEnded=function(e,t){var n=this.fragCurrent,i=this.fragmentTracker;if(!t.live&&n&&!n.backtracked&&n.sn===t.endSN&&!e.nextStart){var r=i.getState(n);return r===U||r===j}return!1},r.onMediaSeeking=function(){var e=this.config,t=this.media,n=this.mediaBuffer,i=this.state,r=t?t.currentTime:null,a=G.bufferInfo(n||t,r,this.config.maxBufferHole);if(Object(l.isFiniteNumber)(r)&&c.logger.log("media seeking to "+r.toFixed(3)),i===be){var o=this.fragCurrent;if(0===a.len&&o){var s=e.maxFragLookUpTolerance,u=o.start-s,d=o.start+o.duration+s;rd?(o.loader&&(c.logger.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),o.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.state=me):c.logger.log("seeking outside of buffer but within currently loaded fragment range")}}else i===Ce&&(0===a.len&&(this.fragPrevious=null,this.fragCurrent=null),this.state=me);t&&(this.lastCurrentTime=r),this.loadedmetadata||(this.nextLoadPosition=this.startPosition=r),this.tick()},r.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},r.onHandlerDestroying=function(){this.stopLoad(),e.prototype.onHandlerDestroying.call(this)},r.onHandlerDestroyed=function(){this.state=ge,this.fragmentTracker=null},r.computeLivePosition=function(e,t){var n=void 0!==this.config.liveSyncDuration?this.config.liveSyncDuration:this.config.liveSyncDurationCount*t.targetduration;return e+Math.max(0,t.totalduration-n)},i}(pe);function De(e,t){for(var n=0;n0&&-1===e&&(c.logger.log("override startPosition with lastCurrentTime @"+t.toFixed(3)),e=t),this.state=me,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this.forceStartLoad=!0,this.state=ge},h.stopLoad=function(){this.forceStartLoad=!1,e.prototype.stopLoad.call(this)},h.doTick=function(){switch(this.state){case Se:this.fragLoadError=0;break;case me:this._doTickIdle();break;case Oe:var e=this.levels[this.level];e&&e.details&&(this.state=me);break;case Ee:var t=window.performance.now(),n=this.retryDate;(!n||t>=n||this.media&&this.media.seeking)&&(c.logger.log("mediaController: retryDate reached, switch back to IDLE state"),this.state=me)}this._checkBuffer(),this._checkFragmentChanged()},h._doTickIdle=function(){var e=this.hls,t=e.config,n=this.media;if(void 0!==this.levelLastLoaded&&(n||!this.startFragRequested&&t.startFragPrefetch)){var i;i=this.loadedmetadata?n.currentTime:this.nextLoadPosition;var r=e.nextLoadLevel,a=this.levels[r];if(a){var o,s=a.bitrate;o=s?Math.max(8*t.maxBufferSize/s,t.maxBufferLength):t.maxBufferLength,o=Math.min(o,t.maxMaxBufferLength);var l=G.bufferInfo(this.mediaBuffer?this.mediaBuffer:n,i,t.maxBufferHole),d=l.len;if(!(d>=o)){c.logger.trace("buffer length of "+d.toFixed(3)+" is below max of "+o.toFixed(3)+". checking for more payload ..."),this.level=e.nextLoadLevel=r;var h=a.details;if(!h||h.live&&this.levelLastLoaded!==r)this.state=Oe;else{if(this._streamEnded(l,h)){var f={};return this.altAudio&&(f.type="video"),this.hls.trigger(u.default.BUFFER_EOS,f),void(this.state=Ce)}this._fetchPayloadOrEos(i,l,h)}}}}},h._fetchPayloadOrEos=function(e,t,n){var i=this.fragPrevious,r=this.level,a=n.fragments,o=a.length;if(0!==o){var s,l=a[0].start,u=a[o-1].start+a[o-1].duration,d=t.end;if(n.initSegment&&!n.initSegment.data)s=n.initSegment;else if(n.live){var h=this.config.initialLiveManifestSize;if(oh&&h>u.currentTime&&(c.logger.log("buffer end: "+t.toFixed(3)+" is located too far from the end of live sliding playlist, reset currentTime to : "+h.toFixed(3)),u.currentTime=h),this.nextLoadPosition=h}if(e.PTSKnown&&t>i&&u&&u.readyState)return null;if(this.startFragRequested&&!e.PTSKnown){if(r)if(e.hasProgramDateTime)c.logger.log("live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),s=le(a,r.endProgramDateTime,l.maxFragLookUpTolerance);else{var f=r.sn+1;if(f>=e.startSN&&f<=e.endSN){var p=a[f-e.startSN];r.cc===p.cc&&(s=p,c.logger.log("live playlist, switching playlist, load frag with next SN: "+s.sn))}s||(s=K.search(a,(function(e){return r.cc-e.cc})))&&c.logger.log("live playlist, switching playlist, load frag with same CC: "+s.sn)}s||(s=a[Math.min(o-1,Math.round(o/2))],c.logger.log("live playlist, switching playlist, unknown, load middle frag : "+s.sn))}return s},h._findFragment=function(e,t,n,i,r,a,o){var s,l=this.hls.config;if(s=ra-l.maxFragLookUpTolerance?0:l.maxFragLookUpTolerance):i[n-1]){var u=s.sn-o.startSN,d=t&&s.level===t.level,h=i[u-1],f=i[u+1];if(t&&s.sn===t.sn)if(d&&!s.backtracked)if(s.snl.maxBufferHole&&t.dropped&&u?(s=h,c.logger.warn("Previous fragment was dropped with large PTS gap between audio and video. Maybe fragment is not starting with a keyframe? Loading previous one to try to overcome this")):(s=f,c.logger.log("Re-loading fragment with SN: "+s.sn))}else s=null;else s.backtracked&&(f&&f.backtracked?(c.logger.warn("Already backtracked from fragment "+f.sn+", will not backtrack to fragment "+s.sn+". Loading fragment "+f.sn),s=f):(c.logger.warn("Loaded fragment with dropped frames, backtracking 1 segment to find a keyframe"),s.dropped=0,h?(s=h).backtracked=!0:u&&(s=null)))}return s},h._loadKey=function(e){this.state=Ae,this.hls.trigger(u.default.KEY_LOADING,{frag:e})},h._loadFragment=function(e){var t=this.fragmentTracker.getState(e);this.fragCurrent=e,"initSegment"!==e.sn&&(this.startFragRequested=!0),Object(l.isFiniteNumber)(e.sn)&&!e.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),e.backtracked||t===F||t===U?(e.autoLevel=this.hls.autoLevelEnabled,e.bitrateTest=this.bitrateTest,this.hls.trigger(u.default.FRAG_LOADING,{frag:e}),this.demuxer||(this.demuxer=new Q(this.hls,"main")),this.state=be):t===B&&this._reduceMaxBufferLength(e.duration)&&this.fragmentTracker.removeFragment(e)},h.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,a.MAIN)},h.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.endPTS+.5):null},h._checkFragmentChanged=function(){var e,t,n=this.media;if(n&&n.readyState&&!1===n.seeking&&((t=n.currentTime)>this.lastCurrentTime&&(this.lastCurrentTime=t),G.isBuffered(n,t)?e=this.getBufferedFrag(t):G.isBuffered(n,t+.1)&&(e=this.getBufferedFrag(t+.1)),e)){var i=e;if(i!==this.fragPlaying){this.hls.trigger(u.default.FRAG_CHANGED,{frag:i});var r=i.level;this.fragPlaying&&this.fragPlaying.level===r||this.hls.trigger(u.default.LEVEL_SWITCHED,{level:r}),this.fragPlaying=i}}},h.immediateLevelSwitch=function(){if(c.logger.log("immediateLevelSwitch"),!this.immediateSwitch){this.immediateSwitch=!0;var e,t=this.media;t?(e=t.paused,t.pause()):e=!0,this.previouslyPaused=e}var n=this.fragCurrent;n&&n.loader&&n.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},h.immediateLevelSwitchEnd=function(){var e=this.media;e&&e.buffered.length&&(this.immediateSwitch=!1,G.isBuffered(e,e.currentTime)&&(e.currentTime-=1e-4),this.previouslyPaused||e.play())},h.nextLevelSwitch=function(){var e=this.media;if(e&&e.readyState){var t,n,i;if((n=this.getBufferedFrag(e.currentTime))&&n.startPTS>1&&this.flushMainBuffer(0,n.startPTS-1),e.paused)t=0;else{var r=this.hls.nextLoadLevel,a=this.levels[r],o=this.fragLastKbps;t=o&&this.fragCurrent?this.fragCurrent.duration*a.bitrate/(1e3*o)+1:0}if((i=this.getBufferedFrag(e.currentTime+t))&&(i=this.followingBufferedFrag(i))){var s=this.fragCurrent;s&&s.loader&&s.loader.abort(),this.fragCurrent=null,this.flushMainBuffer(i.maxStartPTS,Number.POSITIVE_INFINITY)}}},h.flushMainBuffer=function(e,t){this.state=Se;var n={startOffset:e,endOffset:t};this.altAudio&&(n.type="video"),this.hls.trigger(u.default.BUFFER_FLUSHING,n)},h.onMediaAttached=function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("seeked",this.onvseeked),t.addEventListener("ended",this.onvended);var n=this.config;this.levels&&n.autoStartLoad&&this.hls.startLoad(n.startPosition),this.gapController=new he(n,t,this.fragmentTracker,this.hls)},h.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(c.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0);var t=this.levels;t&&t.forEach((function(e){e.details&&e.details.fragments.forEach((function(e){e.backtracked=void 0}))})),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("seeked",this.onvseeked),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.fragmentTracker.removeAllFragments(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.stopLoad()},h.onMediaSeeked=function(){var e=this.media,t=e?e.currentTime:void 0;Object(l.isFiniteNumber)(t)&&c.logger.log("media seeked to "+t.toFixed(3)),this.tick()},h.onManifestLoading=function(){c.logger.log("trigger BUFFER_RESET"),this.hls.trigger(u.default.BUFFER_RESET),this.fragmentTracker.removeAllFragments(),this.stalled=!1,this.startPosition=this.lastCurrentTime=0},h.onManifestParsed=function(e){var t,n=!1,i=!1;e.levels.forEach((function(e){(t=e.audioCodec)&&(-1!==t.indexOf("mp4a.40.2")&&(n=!0),-1!==t.indexOf("mp4a.40.5")&&(i=!0))})),this.audioCodecSwitch=n&&i,this.audioCodecSwitch&&c.logger.log("both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.altAudio=e.altAudio,this.levels=e.levels,this.startFragRequested=!1;var r=this.config;(r.autoStartLoad||this.forceStartLoad)&&this.hls.startLoad(r.startPosition)},h.onLevelLoaded=function(e){var t=e.details,n=e.level,i=this.levels[this.levelLastLoaded],r=this.levels[n],a=t.totalduration,o=0;if(c.logger.log("level "+n+" loaded ["+t.startSN+","+t.endSN+"],duration:"+a),t.live){var s=r.details;s&&t.fragments.length>0?(ne(s,t),o=t.fragments[0].start,this.liveSyncPosition=this.computeLivePosition(o,s),t.PTSKnown&&Object(l.isFiniteNumber)(o)?c.logger.log("live playlist sliding:"+o.toFixed(3)):(c.logger.log("live playlist - outdated PTS, unknown sliding"),se(this.fragPrevious,i,t))):(c.logger.log("live playlist - first load, unknown sliding"),t.PTSKnown=!1,se(this.fragPrevious,i,t))}else t.PTSKnown=!1;if(r.details=t,this.levelLastLoaded=n,this.hls.trigger(u.default.LEVEL_UPDATED,{details:t,level:n}),!1===this.startFragRequested){if(-1===this.startPosition||-1===this.lastCurrentTime){var d=t.startTimeOffset;Object(l.isFiniteNumber)(d)?(d<0&&(c.logger.log("negative start time offset "+d+", count from end of last fragment"),d=o+a+d),c.logger.log("start time offset found in playlist, adjust startPosition to "+d),this.startPosition=d):t.live?(this.startPosition=this.computeLivePosition(o,t),c.logger.log("configure startPosition to "+this.startPosition)):this.startPosition=0,this.lastCurrentTime=this.startPosition}this.nextLoadPosition=this.startPosition}this.state===Oe&&(this.state=me),this.tick()},h.onKeyLoaded=function(){this.state===Ae&&(this.state=me,this.tick())},h.onFragLoaded=function(e){var t=this.fragCurrent,n=this.hls,i=this.levels,r=this.media,a=e.frag;if(this.state===be&&t&&"main"===a.type&&a.level===t.level&&a.sn===t.sn){var o=e.stats,s=i[t.level],l=s.details;if(this.bitrateTest=!1,this.stats=o,c.logger.log("Loaded "+t.sn+" of ["+l.startSN+" ,"+l.endSN+"],level "+t.level),a.bitrateTest&&n.nextLoadLevel)this.state=me,this.startFragRequested=!1,o.tparsed=o.tbuffered=window.performance.now(),n.trigger(u.default.FRAG_BUFFERED,{stats:o,frag:t,id:"main"}),this.tick();else if("initSegment"===a.sn)this.state=me,o.tparsed=o.tbuffered=window.performance.now(),l.initSegment.data=e.payload,n.trigger(u.default.FRAG_BUFFERED,{stats:o,frag:t,id:"main"}),this.tick();else{c.logger.log("Parsing "+t.sn+" of ["+l.startSN+" ,"+l.endSN+"],level "+t.level+", cc "+t.cc),this.state=ke,this.pendingBuffering=!0,this.appended=!1,a.bitrateTest&&(a.bitrateTest=!1,this.fragmentTracker.onFragLoaded({frag:a}));var d=!(r&&r.seeking)&&(l.PTSKnown||!l.live),h=l.initSegment?l.initSegment.data:[],f=this._getAudioCodec(s);(this.demuxer=this.demuxer||new Q(this.hls,"main")).push(e.payload,h,f,s.videoCodec,t,l.totalduration,d)}}this.fragLoadError=0},h.onFragParsingInitSegment=function(e){var t=this.fragCurrent,n=e.frag;if(t&&"main"===e.id&&n.sn===t.sn&&n.level===t.level&&this.state===ke){var i,r,a=e.tracks;if(a.audio&&this.altAudio&&delete a.audio,r=a.audio){var o=this.levels[this.level].audioCodec,s=navigator.userAgent.toLowerCase();o&&this.audioCodecSwap&&(c.logger.log("swapping playlist audio codec"),o=-1!==o.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),this.audioCodecSwitch&&1!==r.metadata.channelCount&&-1===s.indexOf("firefox")&&(o="mp4a.40.5"),-1!==s.indexOf("android")&&"audio/mpeg"!==r.container&&(o="mp4a.40.2",c.logger.log("Android: force audio codec to "+o)),r.levelCodec=o,r.id=e.id}for(i in(r=a.video)&&(r.levelCodec=this.levels[this.level].videoCodec,r.id=e.id),this.hls.trigger(u.default.BUFFER_CODECS,a),a){r=a[i],c.logger.log("main track:"+i+",container:"+r.container+",codecs[level/parsed]=["+r.levelCodec+"/"+r.codec+"]");var l=r.initSegment;l&&(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(u.default.BUFFER_APPENDING,{type:i,data:l,parent:"main",content:"initSegment"}))}this.tick()}},h.onFragParsingData=function(e){var t=this,n=this.fragCurrent,i=e.frag;if(n&&"main"===e.id&&i.sn===n.sn&&i.level===n.level&&("audio"!==e.type||!this.altAudio)&&this.state===ke){var r=this.levels[this.level],a=n;if(Object(l.isFiniteNumber)(e.endPTS)||(e.endPTS=e.startPTS+n.duration,e.endDTS=e.startDTS+n.duration),!0===e.hasAudio&&a.addElementaryStream(g.AUDIO),!0===e.hasVideo&&a.addElementaryStream(g.VIDEO),c.logger.log("Parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb+",dropped:"+(e.dropped||0)),"video"===e.type)if(a.dropped=e.dropped,a.dropped)if(a.backtracked)c.logger.warn("Already backtracked on this fragment, appending with the gap",a.sn);else{var o=r.details;if(!o||a.sn!==o.startSN)return c.logger.warn("missing video frame(s), backtracking fragment",a.sn),this.fragmentTracker.removeFragment(a),a.backtracked=!0,this.nextLoadPosition=e.startPTS,this.state=me,this.fragPrevious=a,void this.tick();c.logger.warn("missing video frame(s) on first frag, appending with gap",a.sn)}else a.backtracked=!1;var s=te(r.details,a,e.startPTS,e.endPTS,e.startDTS,e.endDTS),d=this.hls;d.trigger(u.default.LEVEL_PTS_UPDATED,{details:r.details,level:this.level,drift:s,type:e.type,start:e.startPTS,end:e.endPTS}),[e.data1,e.data2].forEach((function(n){n&&n.length&&t.state===ke&&(t.appended=!0,t.pendingBuffering=!0,d.trigger(u.default.BUFFER_APPENDING,{type:e.type,data:n,parent:"main",content:"data"}))})),this.tick()}},h.onFragParsed=function(e){var t=this.fragCurrent,n=e.frag;t&&"main"===e.id&&n.sn===t.sn&&n.level===t.level&&this.state===ke&&(this.stats.tparsed=window.performance.now(),this.state=_e,this._checkAppendedParsed())},h.onAudioTrackSwitching=function(e){var t=!!e.url,n=e.id;if(!t){if(this.mediaBuffer!==this.media){c.logger.log("switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i.loader&&(c.logger.log("switching to main audio track, cancel main fragment load"),i.loader.abort()),this.fragCurrent=null,this.fragPrevious=null,this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),this.state=me}var r=this.hls;r.trigger(u.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),r.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:n}),this.altAudio=!1}},h.onAudioTrackSwitched=function(e){var t=e.id,n=!!this.hls.audioTracks[t].url;if(n){var i=this.videoBuffer;i&&this.mediaBuffer!==i&&(c.logger.log("switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i)}this.altAudio=n,this.tick()},h.onBufferCreated=function(e){var t,n,i=e.tracks,r=!1;for(var a in i){var o=i[a];"main"===o.id?(n=a,t=o,"video"===a&&(this.videoBuffer=i[a].buffer)):r=!0}r&&t?(c.logger.log("alternate track found, use "+n+".buffered to schedule main fragment loading"),this.mediaBuffer=t.buffer):this.mediaBuffer=this.media},h.onBufferAppended=function(e){if("main"===e.parent){var t=this.state;t!==ke&&t!==_e||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},h._checkAppendedParsed=function(){if(!(this.state!==_e||this.appended&&this.pendingBuffering)){var e=this.fragCurrent;if(e){var t=this.mediaBuffer?this.mediaBuffer:this.media;c.logger.log("main buffered : "+ae.toString(t.buffered)),this.fragPrevious=e;var n=this.stats;n.tbuffered=window.performance.now(),this.fragLastKbps=Math.round(8*n.total/(n.tbuffered-n.tfirst)),this.hls.trigger(u.default.FRAG_BUFFERED,{stats:n,frag:e,id:"main"}),this.state=me}this.tick()}},h.onError=function(e){var t=e.frag||this.fragCurrent;if(!t||"main"===t.type){var n=!!this.media&&G.isBuffered(this.media,this.media.currentTime)&&G.isBuffered(this.media,this.media.currentTime+.5);switch(e.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:if(!e.fatal)if(this.fragLoadError+1<=this.config.fragLoadingMaxRetry){var i=Math.min(Math.pow(2,this.fragLoadError)*this.config.fragLoadingRetryDelay,this.config.fragLoadingMaxRetryTimeout);c.logger.warn("mediaController: frag loading failed, retry in "+i+" ms"),this.retryDate=window.performance.now()+i,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.fragLoadError++,this.state=Ee}else c.logger.error("mediaController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=Re;break;case s.ErrorDetails.LEVEL_LOAD_ERROR:case s.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==Re&&(e.fatal?(this.state=Re,c.logger.warn("streamController: "+e.details+",switch to "+this.state+" state ...")):e.levelRetry||this.state!==Oe||(this.state=me));break;case s.ErrorDetails.BUFFER_FULL_ERROR:"main"!==e.parent||this.state!==ke&&this.state!==_e||(n?(this._reduceMaxBufferLength(this.config.maxBufferLength),this.state=me):(c.logger.warn("buffer full error also media.currentTime is not buffered, flush everything"),this.fragCurrent=null,this.flushMainBuffer(0,Number.POSITIVE_INFINITY)))}}},h._reduceMaxBufferLength=function(e){var t=this.config;return t.maxMaxBufferLength>=e&&(t.maxMaxBufferLength/=2,c.logger.warn("main:reduce max buffer length to "+t.maxMaxBufferLength+"s"),!0)},h._checkBuffer=function(){var e=this.media;if(e&&0!==e.readyState){var t=(this.mediaBuffer?this.mediaBuffer:e).buffered;!this.loadedmetadata&&t.length?(this.loadedmetadata=!0,this._seekToStartPos()):this.immediateSwitch?this.immediateLevelSwitchEnd():this.gapController.poll(this.lastCurrentTime,t)}},h.onFragLoadEmergencyAborted=function(){this.state=me,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tick()},h.onBufferFlushed=function(){var e=this.mediaBuffer?this.mediaBuffer:this.media;e&&this.fragmentTracker.detectEvictedFragments(g.VIDEO,e.buffered),this.state=me,this.fragPrevious=null},h.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},h._seekToStartPos=function(){var e=this.media,t=e.currentTime,n=e.seeking?t:this.startPosition;t!==n&&n>=0&&(c.logger.log("target start position not buffered, seek to buffered.start(0) "+n+" from current time "+t+" "),e.currentTime=n)},h._getAudioCodec=function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&(c.logger.log("swapping playlist audio codec"),t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5")),t},r=i,(o=[{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,c.logger.log("main stream-controller: "+t+"->"+e),this.hls.trigger(u.default.STREAM_STATE_TRANSITION,{previousState:t,nextState:e})}},get:function(){return this._state}},{key:"currentLevel",get:function(){var e=this.media;if(e){var t=this.getBufferedFrag(e.currentTime);if(t)return t.level}return-1}},{key:"nextBufferedFrag",get:function(){var e=this.media;return e?this.followingBufferedFrag(this.getBufferedFrag(e.currentTime)):null}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"liveSyncPosition",get:function(){return this._liveSyncPosition},set:function(e){this._liveSyncPosition=e}}])&&De(r.prototype,o),d&&De(r,d),i}(Le);function xe(e,t){for(var n=0;n0){t=n[0].bitrate,n.sort((function(e,t){return e.bitrate-t.bitrate})),this._levels=n;for(var d=0;d=0&&e1&&d.loadError0){var t=this.currentLevelIndex,n=e.urlId,i=e.url[n];c.logger.log("Attempt loading level index "+t+" with URL-id "+n),this.hls.trigger(u.default.LEVEL_LOADING,{url:i,level:t,id:n})}}},r=i,(a=[{key:"levels",get:function(){return this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;t&&(e=Math.min(e,t.length-1),this.currentLevelIndex===e&&t[e].details||this.setLevelInternal(e))}},{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)}}])&&xe(r.prototype,a),o&&xe(r,o),i}(h),Me=n("./src/demux/id3.js");function Fe(e,t){var n;try{n=new Event("addtrack")}catch(e){(n=document.createEvent("Event")).initEvent("addtrack",!1,!1)}n.track=e,t.dispatchEvent(n)}function Be(e){if(e&&e.cues)for(;e.cues.length>0;)e.removeCue(e.cues[0])}var Ue=function(e){var t,n;function i(t){var n;return(n=e.call(this,t,u.default.MEDIA_ATTACHED,u.default.MEDIA_DETACHING,u.default.FRAG_PARSING_METADATA,u.default.LIVE_BACK_BUFFER_REACHED)||this).id3Track=void 0,n.media=void 0,n}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var r=i.prototype;return r.destroy=function(){h.prototype.destroy.call(this)},r.onMediaAttached=function(e){this.media=e.media,this.media},r.onMediaDetaching=function(){Be(this.id3Track),this.id3Track=void 0,this.media=void 0},r.getID3Track=function(e){for(var t=0;ts&&(c.logger.warn("detected an id3 sample with endTime < startTime, adjusting endTime to (startTime + 0.25)"),s=o+.25);for(var l=0;le[e.length-1].endTime)return e[e.length-1];for(var n=0,i=e.length-1;n<=i;){var r=Math.floor((i+n)/2);if(te[r].endTime))return e[r];n=r+1}}return e[n].endTime-t=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.destroy=function(){},e}();function Ke(e,t){for(var n=0;n500*n.duration/s){var l=e.levels,d=Math.max(1,a.bw?a.bw/8:1e3*a.loaded/o),h=l[n.level],f=h.realBitrate?Math.max(h.realBitrate,h.bitrate):h.bitrate,p=a.total?a.total:Math.max(a.loaded,Math.round(n.duration*f/8)),g=t.currentTime,v=(p-a.loaded)/d,m=(G.bufferInfo(t,g,e.config.maxBufferHole).end-g)/s;if(m<2*n.duration/s&&v>m){var y;for(y=n.level-1;y>r;y--){var A=l[y].realBitrate?Math.max(l[y].realBitrate,l[y].bitrate):l[y].bitrate;if(n.duration*A/(6.4*d)=i;u--){var d=l[u];if(d){var h=d.details,f=h?h.totalduration/h.fragments.length:t,p=!!h&&h.live,g=void 0;g=u<=e?o*n:s*n;var v=l[u].realBitrate?Math.max(l[u].realBitrate,l[u].bitrate):l[u].bitrate,m=v*f/g;if(c.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+u+"/"+Math.round(g)+"/"+v+"/"+f+"/"+a+"/"+m),g>v&&(!m||p&&!this.bitrateTestDelay||m=0)return f;c.logger.trace("rebuffering expected to happen, lets try to find a quality level minimizing the rebuffering");var p=s?Math.min(s,i.maxStarvationDelay):i.maxStarvationDelay,g=i.abrBandWidthFactor,v=i.abrBandWidthUpFactor;if(0===h){var m=this.bitrateTestDelay;m&&(p=(s?Math.min(s,i.maxLoadingDelay):i.maxLoadingDelay)-m,c.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(o,s,d,r,t,h+p,g,v,n),Math.max(f,0)}}])&&Ke(r.prototype,a),o&&Ke(r,o),i}(h),He=z(),$e=function(e){var t,n;function i(t){var n;return(n=e.call(this,t,u.default.MEDIA_ATTACHING,u.default.MEDIA_DETACHING,u.default.MANIFEST_PARSED,u.default.BUFFER_RESET,u.default.BUFFER_APPENDING,u.default.BUFFER_CODECS,u.default.BUFFER_EOS,u.default.BUFFER_FLUSHING,u.default.LEVEL_PTS_UPDATED,u.default.LEVEL_UPDATED)||this)._msDuration=null,n._levelDuration=null,n._levelTargetDuration=10,n._live=null,n._objectUrl=null,n._needsFlush=!1,n._needsEos=!1,n.config=void 0,n.audioTimestampOffset=void 0,n.bufferCodecEventsExpected=0,n._bufferCodecEventsTotal=0,n.media=null,n.mediaSource=null,n.segments=[],n.parent=void 0,n.appending=!1,n.appended=0,n.appendError=0,n.flushBufferCounter=0,n.tracks={},n.pendingTracks={},n.sourceBuffer={},n.flushRange=[],n._onMediaSourceOpen=function(){c.logger.log("media source opened"),n.hls.trigger(u.default.MEDIA_ATTACHED,{media:n.media});var e=n.mediaSource;e&&e.removeEventListener("sourceopen",n._onMediaSourceOpen),n.checkPendingTracks()},n._onMediaSourceClose=function(){c.logger.log("media source closed")},n._onMediaSourceEnded=function(){c.logger.log("media source ended")},n._onSBUpdateEnd=function(){if(n.audioTimestampOffset&&n.sourceBuffer.audio){var e=n.sourceBuffer.audio;c.logger.warn("change mpeg audio timestamp offset from "+e.timestampOffset+" to "+n.audioTimestampOffset),e.timestampOffset=n.audioTimestampOffset,delete n.audioTimestampOffset}n._needsFlush&&n.doFlush(),n._needsEos&&n.checkEos(),n.appending=!1;var t=n.parent,i=n.segments.reduce((function(e,n){return n.parent===t?e+1:e}),0),r={},a=n.sourceBuffer;for(var o in a){var s=a[o];if(!s)throw Error("handling source buffer update end error: source buffer for "+o+" uninitilized and unable to update buffered TimeRanges.");r[o]=s.buffered}n.hls.trigger(u.default.BUFFER_APPENDED,{parent:t,pending:i,timeRanges:r}),n._needsFlush||n.doAppending(),n.updateMediaElementDuration(),0===i&&n.flushLiveBackBuffer()},n._onSBUpdateError=function(e){c.logger.error("sourceBuffer error:",e),n.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1})},n.config=t.config,n}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var r=i.prototype;return r.destroy=function(){h.prototype.destroy.call(this)},r.onLevelPtsUpdated=function(e){var t=e.type,n=this.tracks.audio;if("audio"===t&&n&&"audio/mpeg"===n.container){var i=this.sourceBuffer.audio;if(!i)throw Error("Level PTS Updated and source buffer for audio uninitalized");if(Math.abs(i.timestampOffset-e.start)>.1){var r=i.updating;try{i.abort()}catch(e){c.logger.warn("can not abort audio buffer: "+e)}r?this.audioTimestampOffset=e.start:(c.logger.warn("change mpeg audio timestamp offset from "+i.timestampOffset+" to "+e.start),i.timestampOffset=e.start)}}},r.onManifestParsed=function(e){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=e.altAudio?2:1,c.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},r.onMediaAttaching=function(e){var t=this.media=e.media;if(t&&He){var n=this.mediaSource=new He;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),t.src=window.URL.createObjectURL(n),this._objectUrl=t.src}},r.onMediaDetaching=function(){c.logger.log("media source detaching");var e=this.mediaSource;if(e){if("open"===e.readyState)try{e.endOfStream()}catch(e){c.logger.warn("onMediaDetaching:"+e.message+" while calling endOfStream")}e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),this.media&&(this._objectUrl&&window.URL.revokeObjectURL(this._objectUrl),this.media.src===this._objectUrl?(this.media.removeAttribute("src"),this.media.load()):c.logger.warn("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.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0}this.hls.trigger(u.default.MEDIA_DETACHED)},r.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,t=this.pendingTracks,n=Object.keys(t).length;(n&&!e||2===n)&&(this.createSourceBuffers(t),this.pendingTracks={},this.doAppending())},r.onBufferReset=function(){var e=this.sourceBuffer;for(var t in e){var n=e[t];try{n&&(this.mediaSource&&this.mediaSource.removeSourceBuffer(n),n.removeEventListener("updateend",this._onSBUpdateEnd),n.removeEventListener("error",this._onSBUpdateError))}catch(e){}}this.sourceBuffer={},this.flushRange=[],this.segments=[],this.appended=0},r.onBufferCodecs=function(e){var t=this;Object.keys(this.sourceBuffer).length||(Object.keys(e).forEach((function(n){t.pendingTracks[n]=e[n]})),this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},r.createSourceBuffers=function(e){var t=this.sourceBuffer,n=this.mediaSource;if(!n)throw Error("createSourceBuffers called when mediaSource was null");for(var i in e)if(!t[i]){var r=e[i];if(!r)throw Error("source buffer exists for track "+i+", however track does not");var a=r.levelCodec||r.codec,o=r.container+";codecs="+a;c.logger.log("creating sourceBuffer("+o+")");try{var l=t[i]=n.addSourceBuffer(o);l.addEventListener("updateend",this._onSBUpdateEnd),l.addEventListener("error",this._onSBUpdateError),this.tracks[i]={buffer:l,codec:a,id:r.id,container:r.container,levelCodec:r.levelCodec}}catch(e){c.logger.error("error while trying to add sourceBuffer:"+e.message),this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,err:e,mimeType:o})}}this.hls.trigger(u.default.BUFFER_CREATED,{tracks:this.tracks})},r.onBufferAppending=function(e){this._needsFlush||(this.segments?this.segments.push(e):this.segments=[e],this.doAppending())},r.onBufferEos=function(e){for(var t in this.sourceBuffer)if(!e.type||e.type===t){var n=this.sourceBuffer[t];n&&!n.ended&&(n.ended=!0,c.logger.log(t+" sourceBuffer now EOS"))}this.checkEos()},r.checkEos=function(){var e=this.sourceBuffer,t=this.mediaSource;if(t&&"open"===t.readyState){for(var n in e){var i=e[n];if(i){if(!i.ended)return;if(i.updating)return void(this._needsEos=!0)}}c.logger.log("all media data are available, signal endOfStream() to MediaSource and stop loading fragment");try{t.endOfStream()}catch(e){c.logger.warn("exception while calling mediaSource.endOfStream()")}this._needsEos=!1}else this._needsEos=!1},r.onBufferFlushing=function(e){e.type?this.flushRange.push({start:e.startOffset,end:e.endOffset,type:e.type}):(this.flushRange.push({start:e.startOffset,end:e.endOffset,type:"video"}),this.flushRange.push({start:e.startOffset,end:e.endOffset,type:"audio"})),this.flushBufferCounter=0,this.doFlush()},r.flushLiveBackBuffer=function(){if(this._live){var e=this.config.liveBackBufferLength;if(isFinite(e)&&!(e<0))if(this.media)for(var t=this.media.currentTime,n=this.sourceBuffer,i=Object.keys(n),r=t-Math.max(e,this._levelTargetDuration),a=i.length-1;a>=0;a--){var o=i[a],s=n[o];if(s){var l=s.buffered;l.length>0&&r>l.start(0)&&this.removeBufferRange(o,s,0,r)&&this.hls.trigger(u.default.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r})}}else c.logger.error("flushLiveBackBuffer called without attaching media")}},r.onLevelUpdated=function(e){var t=e.details;t.fragments.length>0&&(this._levelDuration=t.totalduration+t.fragments[0].start,this._levelTargetDuration=t.averagetargetduration||t.targetduration||10,this._live=t.live,this.updateMediaElementDuration())},r.updateMediaElementDuration=function(){var e,t=this.config;if(null!==this._levelDuration&&this.media&&this.mediaSource&&this.sourceBuffer&&0!==this.media.readyState&&"open"===this.mediaSource.readyState){for(var n in this.sourceBuffer){var i=this.sourceBuffer[n];if(i&&!0===i.updating)return}e=this.media.duration,null===this._msDuration&&(this._msDuration=this.mediaSource.duration),!0===this._live&&!0===t.liveDurationInfinity?(c.logger.log("Media Source duration is set to Infinity"),this._msDuration=this.mediaSource.duration=1/0):(this._levelDuration>this._msDuration&&this._levelDuration>e||!Object(l.isFiniteNumber)(e))&&(c.logger.log("Updating Media Source duration to "+this._levelDuration.toFixed(3)),this._msDuration=this.mediaSource.duration=this._levelDuration)}},r.doFlush=function(){for(;this.flushRange.length;){var e=this.flushRange[0];if(!this.flushBuffer(e.start,e.end,e.type))return void(this._needsFlush=!0);this.flushRange.shift(),this.flushBufferCounter=0}if(0===this.flushRange.length){this._needsFlush=!1;var t=0,n=this.sourceBuffer;try{for(var i in n){var r=n[i];r&&(t+=r.buffered.length)}}catch(e){c.logger.error("error while accessing sourceBuffer.buffered")}this.appended=t,this.hls.trigger(u.default.BUFFER_FLUSHED)}},r.doAppending=function(){var e=this.config,t=this.hls,n=this.segments,i=this.sourceBuffer;if(Object.keys(i).length){if(!this.media||this.media.error)return this.segments=[],void c.logger.error("trying to append although a media error occured, flush segment and abort");if(!this.appending){var r=n.shift();if(r)try{var a=i[r.type];if(!a)return void this._onSBUpdateEnd();if(a.updating)return void n.unshift(r);a.ended=!1,this.parent=r.parent,a.appendBuffer(r.data),this.appendError=0,this.appended++,this.appending=!0}catch(i){c.logger.error("error while trying to append buffer:"+i.message),n.unshift(r);var o={type:s.ErrorTypes.MEDIA_ERROR,parent:r.parent,details:"",fatal:!1};22===i.code?(this.segments=[],o.details=s.ErrorDetails.BUFFER_FULL_ERROR):(this.appendError++,o.details=s.ErrorDetails.BUFFER_APPEND_ERROR,this.appendError>e.appendErrorMaxRetry&&(c.logger.log("fail "+e.appendErrorMaxRetry+" times to append segment in sourceBuffer"),this.segments=[],o.fatal=!0)),t.trigger(u.default.ERROR,o)}}}},r.flushBuffer=function(e,t,n){var i=this.sourceBuffer;if(!Object.keys(i).length)return!0;var r="null";if(this.media&&(r=this.media.currentTime.toFixed(3)),c.logger.log("flushBuffer,pos/start/end: "+r+"/"+e+"/"+t),this.flushBufferCounter>=this.appended)return c.logger.warn("abort flushing too many retries"),!0;var a=i[n];if(a){if(a.ended=!1,a.updating)return c.logger.warn("cannot flush, sb updating in progress"),!1;if(this.removeBufferRange(n,a,e,t))return this.flushBufferCounter++,!1}return c.logger.log("buffer flushed"),!0},r.removeBufferRange=function(e,t,n,i){try{for(var r=0;r.5){var u="null";return this.media&&(u=this.media.currentTime.toString()),c.logger.log("sb remove "+e+" ["+s+","+l+"], of ["+a+","+o+"], pos:"+u),t.remove(s,l),!0}}}catch(e){c.logger.warn("removeBufferRange failed",e)}return!1},i}(h);function ze(e,t){for(var n=0;nthis.autoLevelCapping&&t.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}},s.getMaxLevel=function(e){var t=this;if(!this.levels)return-1;var n=this.levels.filter((function(n,r){return i.isLevelAllowed(r,t.restrictedLevels)&&r<=e}));return i.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},s.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),clearInterval(this.timer),this.timer=setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},s.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=null,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(this.timer=clearInterval(this.timer),this.timer=null)},i.isLevelAllowed=function(e,t){return void 0===t&&(t=[]),-1===t.indexOf(e)},i.getMaxLevelByMediaSize=function(e,t,n){if(!e||e&&!e.length)return-1;for(var i,r,a=e.length-1,o=0;o=t||s.height>=n)&&(i=s,!(r=e[o+1])||i.width!==r.width||i.height!==r.height)){a=o;break}}return a},r=i,o=[{key:"contentScaleFactor",get:function(){var e=1;try{e=window.devicePixelRatio}catch(e){}return e}}],(a=[{key:"mediaWidth",get:function(){var e,t=this.media;return t&&(e=t.width||t.clientWidth||t.offsetWidth,e*=i.contentScaleFactor),e}},{key:"mediaHeight",get:function(){var e,t=this.media;return t&&(e=t.height||t.clientHeight||t.offsetHeight,e*=i.contentScaleFactor),e}}])&&ze(r.prototype,a),o&&ze(r,o),i}(h),qe=window.performance,Xe=function(e){var t,n;function i(t){return e.call(this,t,u.default.MEDIA_ATTACHING)||this}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var r=i.prototype;return r.destroy=function(){this.timer&&clearInterval(this.timer),this.isVideoPlaybackQualityAvailable=!1},r.onMediaAttaching=function(e){var t=this.hls.config;t.capLevelOnFPSDrop&&("function"==typeof(this.video=e.media instanceof window.HTMLVideoElement?e.media:null).getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),clearInterval(this.timer),this.timer=setInterval(this.checkFPSInterval.bind(this),t.fpsDroppedMonitoringPeriod))},r.checkFPS=function(e,t,n){var i=qe.now();if(t){if(this.lastTime){var r=i-this.lastTime,a=n-this.lastDroppedFrames,o=t-this.lastDecodedFrames,s=1e3*a/r,l=this.hls;if(l.trigger(u.default.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:n}),s>0&&a>l.config.fpsDroppedMonitoringThreshold*o){var d=l.currentLevel;c.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+d),d>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=d)&&(d-=1,l.trigger(u.default.FPS_DROP_LEVEL_CAPPING,{level:d,droppedLevel:l.currentLevel}),l.autoLevelCapping=d,l.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=n,this.lastDecodedFrames=t}},r.checkFPSInterval=function(){var e=this.video;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},i}(h),Ze=window,Qe=Ze.performance,Je=Ze.XMLHttpRequest,et=function(){function e(e){e&&e.xhrSetup&&(this.xhrSetup=e.xhrSetup)}var t=e.prototype;return t.destroy=function(){this.abort(),this.loader=null},t.abort=function(){var e=this.loader;e&&4!==e.readyState&&(this.stats.aborted=!0,e.abort()),window.clearTimeout(this.requestTimeout),this.requestTimeout=null,window.clearTimeout(this.retryTimeout),this.retryTimeout=null},t.load=function(e,t,n){this.context=e,this.config=t,this.callbacks=n,this.stats={trequest:Qe.now(),retry:0},this.retryDelay=t.retryDelay,this.loadInternal()},t.loadInternal=function(){var e,t=this.context;e=this.loader=new Je;var n=this.stats;n.tfirst=0,n.loaded=0;var i=this.xhrSetup;try{if(i)try{i(e,t.url)}catch(n){e.open("GET",t.url,!0),i(e,t.url)}e.readyState||e.open("GET",t.url,!0)}catch(n){return void this.callbacks.onError({code:e.status,text:n.message},t,e)}t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),this.config.timeout),e.send()},t.readystatechange=function(e){var t=e.currentTarget,n=t.readyState,i=this.stats,r=this.context,a=this.config;if(!i.aborted&&n>=2)if(window.clearTimeout(this.requestTimeout),0===i.tfirst&&(i.tfirst=Math.max(Qe.now(),i.trequest)),4===n){var o=t.status;if(o>=200&&o<300){var s,l;i.tload=Math.max(i.tfirst,Qe.now()),l="arraybuffer"===r.responseType?(s=t.response).byteLength:(s=t.responseText).length,i.loaded=i.total=l;var u={url:t.responseURL,data:s};this.callbacks.onSuccess(u,i,r,t)}else i.retry>=a.maxRetry||o>=400&&o<499?(c.logger.error(o+" while loading "+r.url),this.callbacks.onError({code:o,text:t.statusText},r,t)):(c.logger.warn(o+" while loading "+r.url+", retrying in "+this.retryDelay+"..."),this.destroy(),this.retryTimeout=window.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,a.maxRetryDelay),i.retry++)}else this.requestTimeout=window.setTimeout(this.loadtimeout.bind(this),a.timeout)},t.loadtimeout=function(){c.logger.warn("timeout while loading "+this.context.url),this.callbacks.onTimeout(this.stats,this.context,null)},t.loadprogress=function(e){var t=e.currentTarget,n=this.stats;n.loaded=e.loaded,e.lengthComputable&&(n.total=e.total);var i=this.callbacks.onProgress;i&&i(n,this.context,null,t)},e}();function tt(e,t){for(var n=0;n=this.tracks.length)c.logger.warn("Invalid audio track id:",e.id);else{if(c.logger.log("audioTrack "+e.id+" loaded"),this.tracks[e.id].details=e.details,e.details.live&&!this.hasInterval()){var t=1e3*e.details.targetduration;this.setInterval(t)}!e.details.live&&this.hasInterval()&&this.clearInterval()}},l.onAudioTrackSwitched=function(e){var t=this.tracks[e.id].groupId;t&&this.audioGroupId!==t&&(this.audioGroupId=t)},l.onLevelLoaded=function(e){this._selectAudioGroup(e.level)},l.onError=function(e){e.type===s.ErrorTypes.NETWORK_ERROR&&(e.fatal&&this.clearInterval(),e.details===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR&&(c.logger.warn("Network failure on audio-track id:",e.context.id),this._handleLoadError()))},l._setAudioTrack=function(e){if(this._trackId===e&&this.tracks[this._trackId].details)c.logger.debug("Same id as current audio-track passed, and track details available -> no-op");else if(e<0||e>=this.tracks.length)c.logger.warn("Invalid id passed to audio-track controller");else{var t=this.tracks[e];c.logger.log("Now switching to audio-track index "+e),this.clearInterval(),this._trackId=e;var n=t.url,i=t.type,r=t.id;this.hls.trigger(u.default.AUDIO_TRACK_SWITCHING,{id:r,type:i,url:n}),this._loadTrackDetailsIfNeeded(t)}},l.doTick=function(){this._updateTrack(this._trackId)},l._selectAudioGroup=function(e){var t=this.hls.levels[e];if(t&&t.audioGroupIds){var n=t.audioGroupIds[t.urlId];this.audioGroupId!==n&&(this.audioGroupId=n,this._selectInitialAudioTrack())}},l._selectInitialAudioTrack=function(){var e=this,t=this.tracks;if(t.length){var n=this.tracks[this._trackId],i=null;if(n&&(i=n.name),this._selectDefaultTrack){var r=t.filter((function(e){return e.default}));r.length?t=r:c.logger.warn("No default audio tracks defined")}var a=!1,o=function(){t.forEach((function(t){a||e.audioGroupId&&t.groupId!==e.audioGroupId||i&&i!==t.name||(e._setAudioTrack(t.id),a=!0)}))};o(),a||(i=null,o()),a||(c.logger.error("No track found for running audio group-ID: "+this.audioGroupId),this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))}},l._needsTrackLoading=function(e){var t=e.details,n=e.url;return!(t&&!t.live||!n)},l._loadTrackDetailsIfNeeded=function(e){if(this._needsTrackLoading(e)){var t=e.url,n=e.id;c.logger.log("loading audio-track playlist for id: "+n),this.hls.trigger(u.default.AUDIO_TRACK_LOADING,{url:t,id:n})}},l._updateTrack=function(e){if(!(e<0||e>=this.tracks.length)){this.clearInterval(),this._trackId=e,c.logger.log("trying to update audio-track "+e);var t=this.tracks[e];this._loadTrackDetailsIfNeeded(t)}},l._handleLoadError=function(){this.trackIdBlacklist[this._trackId]=!0;var e=this._trackId,t=this.tracks[e],n=t.name,i=t.language,r=t.groupId;c.logger.warn("Loading failed on audio track id: "+e+", group-id: "+r+', name/language: "'+n+'" / "'+i+'"');for(var a=e,o=0;o0&&-1===e?(c.logger.log("audio:override startPosition with lastCurrentTime @"+t.toFixed(3)),this.state=me):(this.lastCurrentTime=this.startPosition?this.startPosition:e,this.state=ve),this.nextLoadPosition=this.startPosition=this.lastCurrentTime,this.tick()}else this.startPosition=e,this.state=ge},d.doTick=function(){var e,t,n,i=this.hls,r=i.config;switch(this.state){case Re:case ye:case Se:break;case ve:this.state=Te,this.loadedmetadata=!1;break;case me:var a=this.tracks;if(!a)break;if(!this.media&&(this.startFragRequested||!r.startFragPrefetch))break;if(this.loadedmetadata)e=this.media.currentTime;else if(void 0===(e=this.nextLoadPosition))break;var o=this.mediaBuffer?this.mediaBuffer:this.media,s=this.videoBuffer?this.videoBuffer:this.media,d=G.bufferInfo(o,e,r.maxBufferHole),h=G.bufferInfo(s,e,r.maxBufferHole),f=d.len,p=d.end,g=this.fragPrevious,v=Math.min(r.maxBufferLength,r.maxMaxBufferLength),m=Math.max(v,h.len),y=this.audioSwitch,A=this.trackId;if((fk||d.nextStart))return;c.logger.log("alt audio track ahead of main track, seek to start of alt audio track"),this.media.currentTime=k+.05}if(n.initSegment&&!n.initSegment.data)b=n.initSegment;else if(p<=k){if(b=E[0],null!==this.videoTrackCC&&b.cc!==this.videoTrackCC&&(b=function(e,t){return K.search(e,(function(e){return e.cct?-1:0}))}(E,this.videoTrackCC)),n.live&&b.loadIdx&&b.loadIdx===this.fragLoadIdx){var S=d.nextStart?d.nextStart:k;return c.logger.log("no alt audio available @currentTime:"+this.media.currentTime+", seeking @"+(S+.05)),void(this.media.currentTime=S+.05)}}else{var C,R=r.maxFragLookUpTolerance,w=g?E[g.sn-E[0].sn+1]:void 0,O=function(e){var t=Math.min(R,e.duration);return e.start+e.duration-t<=p?1:e.start-t>p&&e.start?-1:0};p<_?(p>_-R&&(R=0),C=w&&!O(w)?w:K.search(E,O)):C=E[T-1],C&&(b=C,k=C.start,g&&b.level===g.level&&b.sn===g.sn&&(b.sn=D||I)&&(c.logger.log("audioStreamController: retryDate reached, switch back to IDLE state"),this.state=me);break;case we:var P=this.videoTrackCC;if(void 0===this.initPTS[P])break;var x=this.waitingFragment;if(x){var N=x.frag.cc;P!==N?(t=this.tracks[this.trackId]).details&&t.details.live&&(c.logger.warn("Waiting fragment CC ("+N+") does not match video track CC ("+P+")"),this.waitingFragment=null,this.state=me):(this.state=be,this.onFragLoaded(this.waitingFragment),this.waitingFragment=null)}else this.state=me}},d.onMediaAttached=function(e){var t=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),t.addEventListener("seeking",this.onvseeking),t.addEventListener("ended",this.onvended);var n=this.config;this.tracks&&n.autoStartLoad&&this.startLoad(n.startPosition)},d.onMediaDetaching=function(){var e=this.media;e&&e.ended&&(c.logger.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvseeked=this.onvended=null),this.media=this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},d.onAudioTracksUpdated=function(e){c.logger.log("audio tracks updated"),this.tracks=e.audioTracks},d.onAudioTrackSwitching=function(e){var t=!!e.url;this.trackId=e.id,this.fragCurrent=null,this.state=ye,this.waitingFragment=null,t?this.setInterval(100):this.demuxer&&(this.demuxer.destroy(),this.demuxer=null),t&&(this.audioSwitch=!0,this.state=me),this.tick()},d.onAudioTrackLoaded=function(e){var t=e.details,n=e.id,i=this.tracks[n],r=t.totalduration,a=0;if(c.logger.log("track "+n+" loaded ["+t.startSN+","+t.endSN+"],duration:"+r),t.live){var o=i.details;o&&t.fragments.length>0?(ne(o,t),a=t.fragments[0].start,t.PTSKnown?c.logger.log("live audio playlist sliding:"+a.toFixed(3)):c.logger.log("live audio playlist - outdated PTS, unknown sliding")):(t.PTSKnown=!1,c.logger.log("live audio playlist - first load, unknown sliding"))}else t.PTSKnown=!1;if(i.details=t,!this.startFragRequested){if(-1===this.startPosition){var s=t.startTimeOffset;Object(l.isFiniteNumber)(s)?(c.logger.log("start time offset found in playlist, adjust startPosition to "+s),this.startPosition=s):t.live?(this.startPosition=this.computeLivePosition(a,t),c.logger.log("compute startPosition for audio-track to "+this.startPosition)):this.startPosition=0}this.nextLoadPosition=this.startPosition}this.state===Te&&(this.state=me),this.tick()},d.onKeyLoaded=function(){this.state===Ae&&(this.state=me,this.tick())},d.onFragLoaded=function(e){var t=this.fragCurrent,n=e.frag;if(this.state===be&&t&&"audio"===n.type&&n.level===t.level&&n.sn===t.sn){var i=this.tracks[this.trackId],r=i.details,a=r.totalduration,o=t.level,s=t.sn,l=t.cc,d=this.config.defaultAudioCodec||i.audioCodec||"mp4a.40.2",h=this.stats=e.stats;if("initSegment"===s)this.state=me,h.tparsed=h.tbuffered=rt.now(),r.initSegment.data=e.payload,this.hls.trigger(u.default.FRAG_BUFFERED,{stats:h,frag:t,id:"audio"}),this.tick();else{this.state=ke,this.appended=!1,this.demuxer||(this.demuxer=new Q(this.hls,"audio"));var f=this.initPTS[l],p=r.initSegment?r.initSegment.data:[];r.initSegment||void 0!==f?(this.pendingBuffering=!0,c.logger.log("Demuxing "+s+" of ["+r.startSN+" ,"+r.endSN+"],track "+o),this.demuxer.push(e.payload,p,d,null,t,a,!1,f)):(c.logger.log("unknown video PTS for continuity counter "+l+", waiting for video PTS before demuxing audio frag "+s+" of ["+r.startSN+" ,"+r.endSN+"],track "+o),this.waitingFragment=e,this.state=we)}}this.fragLoadError=0},d.onFragParsingInitSegment=function(e){var t=this.fragCurrent,n=e.frag;if(t&&"audio"===e.id&&n.sn===t.sn&&n.level===t.level&&this.state===ke){var i,r=e.tracks;if(r.video&&delete r.video,i=r.audio){i.levelCodec=i.codec,i.id=e.id,this.hls.trigger(u.default.BUFFER_CODECS,r),c.logger.log("audio track:audio,container:"+i.container+",codecs[level/parsed]=["+i.levelCodec+"/"+i.codec+"]");var a=i.initSegment;if(a){var o={type:"audio",data:a,parent:"audio",content:"initSegment"};this.audioSwitch?this.pendingData=[o]:(this.appended=!0,this.pendingBuffering=!0,this.hls.trigger(u.default.BUFFER_APPENDING,o))}this.tick()}}},d.onFragParsingData=function(e){var t=this,n=this.fragCurrent,i=e.frag;if(n&&"audio"===e.id&&"audio"===e.type&&i.sn===n.sn&&i.level===n.level&&this.state===ke){var r=this.trackId,a=this.tracks[r],o=this.hls;Object(l.isFiniteNumber)(e.endPTS)||(e.endPTS=e.startPTS+n.duration,e.endDTS=e.startDTS+n.duration),n.addElementaryStream(g.AUDIO),c.logger.log("parsed "+e.type+",PTS:["+e.startPTS.toFixed(3)+","+e.endPTS.toFixed(3)+"],DTS:["+e.startDTS.toFixed(3)+"/"+e.endDTS.toFixed(3)+"],nb:"+e.nb),te(a.details,n,e.startPTS,e.endPTS);var d=this.audioSwitch,h=this.media,f=!1;if(d)if(h&&h.readyState){var p=h.currentTime;c.logger.log("switching audio track : currentTime:"+p),p>=e.startPTS&&(c.logger.log("switching audio track : flushing all audio"),this.state=Se,o.trigger(u.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),f=!0,this.audioSwitch=!1,o.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:r}))}else this.audioSwitch=!1,o.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:r});var v=this.pendingData;if(!v)return c.logger.warn("Apparently attempt to enqueue media payload without codec initialization data upfront"),void o.trigger(u.default.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:null,fatal:!0});this.audioSwitch||([e.data1,e.data2].forEach((function(t){t&&t.length&&v.push({type:e.type,data:t,parent:"audio",content:"data"})})),!f&&v.length&&(v.forEach((function(e){t.state===ke&&(t.pendingBuffering=!0,t.hls.trigger(u.default.BUFFER_APPENDING,e))})),this.pendingData=[],this.appended=!0)),this.tick()}},d.onFragParsed=function(e){var t=this.fragCurrent,n=e.frag;t&&"audio"===e.id&&n.sn===t.sn&&n.level===t.level&&this.state===ke&&(this.stats.tparsed=rt.now(),this.state=_e,this._checkAppendedParsed())},d.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},d.onBufferCreated=function(e){var t=e.tracks.audio;t&&(this.mediaBuffer=t.buffer,this.loadedmetadata=!0),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer)},d.onBufferAppended=function(e){if("audio"===e.parent){var t=this.state;t!==ke&&t!==_e||(this.pendingBuffering=e.pending>0,this._checkAppendedParsed())}},d._checkAppendedParsed=function(){if(!(this.state!==_e||this.appended&&this.pendingBuffering)){var e=this.fragCurrent,t=this.stats,n=this.hls;if(e){this.fragPrevious=e,t.tbuffered=rt.now(),n.trigger(u.default.FRAG_BUFFERED,{stats:t,frag:e,id:"audio"});var i=this.mediaBuffer?this.mediaBuffer:this.media;i&&c.logger.log("audio buffered : "+ae.toString(i.buffered)),this.audioSwitch&&this.appended&&(this.audioSwitch=!1,n.trigger(u.default.AUDIO_TRACK_SWITCHED,{id:this.trackId})),this.state=me}this.tick()}},d.onError=function(e){var t=e.frag;if(!t||"audio"===t.type)switch(e.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:var n=e.frag;if(n&&"audio"!==n.type)break;if(!e.fatal){var i=this.fragLoadError;i?i++:i=1;var r=this.config;if(i<=r.fragLoadingMaxRetry){this.fragLoadError=i;var a=Math.min(Math.pow(2,i-1)*r.fragLoadingRetryDelay,r.fragLoadingMaxRetryTimeout);c.logger.warn("AudioStreamController: frag loading failed, retry in "+a+" ms"),this.retryDate=rt.now()+a,this.state=Ee}else c.logger.error("AudioStreamController: "+e.details+" reaches max retry, redispatch as fatal ..."),e.fatal=!0,this.state=Re}break;case s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:this.state!==Re&&(this.state=e.fatal?Re:me,c.logger.warn("AudioStreamController: "+e.details+" while loading frag, now switching to "+this.state+" state ..."));break;case s.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===e.parent&&(this.state===ke||this.state===_e)){var o=this.mediaBuffer,l=this.media.currentTime;if(o&&G.isBuffered(o,l)&&G.isBuffered(o,l+.5)){var d=this.config;d.maxMaxBufferLength>=d.maxBufferLength&&(d.maxMaxBufferLength/=2,c.logger.warn("AudioStreamController: reduce max buffer length to "+d.maxMaxBufferLength+"s")),this.state=me}else c.logger.warn("AudioStreamController: buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,this.state=Se,this.hls.trigger(u.default.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"})}}},d.onBufferFlushed=function(){var e=this,t=this.pendingData;t&&t.length?(c.logger.log("AudioStreamController: appending pending audio data after buffer flushed"),t.forEach((function(t){e.hls.trigger(u.default.BUFFER_APPENDING,t)})),this.appended=!0,this.pendingData=[],this.state=_e):(this.state=me,this.fragPrevious=null,this.tick())},r=i,(a=[{key:"state",set:function(e){if(this.state!==e){var t=this.state;this._state=e,c.logger.log("audio stream:"+t+"->"+e)}},get:function(){return this._state}}])&&it(r.prototype,a),o&&it(r,o),i}(Le),ot=function(){if("undefined"!=typeof window&&window.VTTCue)return window.VTTCue;var e={"":!0,lr:!0,rl:!0},t={start:!0,middle:!0,end:!0,left:!0,right:!0};function n(e){return"string"==typeof e&&!!t[e.toLowerCase()]&&e.toLowerCase()}function i(e){for(var t=1;t100)throw new Error("Position must be between 0 and 100.");y=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",i({},s,{get:function(){return A},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");A=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",i({},s,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",i({},s,{get:function(){return E},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),o.displayState=void 0}return r.prototype.getCueAsHTML=function(){return window.WebVTT.convertCueToDOMTree(window,this.text)},r}(),st=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}};function lt(){this.window=window,this.state="INITIAL",this.buffer="",this.decoder=new st,this.regionList=[]}function ut(){this.values=Object.create(null)}function ct(e,t,n,i){var r=i?e.split(i):[e];for(var a in r)if("string"==typeof r[a]){var o=r[a].split(n);2===o.length&&t(o[0],o[1])}}ut.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,n){return n?this.has(e)?this.values[e]:t[n]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,n){for(var i=0;i=0&&t<=100)&&(this.set(e,t),!0)}};var dt=new ot(0,0,0),ht="middle"===dt.align?"middle":"center";function ft(e,t,n){var i=e;function r(){var t=function(e){function t(e,t,n,i){return 3600*(0|e)+60*(0|t)+(0|n)+(0|i)/1e3}var n=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return n?n[3]?t(n[1],n[2],n[3].replace(":",""),n[4]):n[1]>59?t(n[1],n[2],0,n[4]):t(0,n[1],n[2],n[4]):null}(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function a(){e=e.replace(/^\s+/,"")}if(a(),t.startTime=r(),a(),"--\x3e"!==e.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.substr(3),a(),t.endTime=r(),a(),function(e,t){var i=new ut;ct(e,(function(e,t){switch(e){case"region":for(var r=n.length-1;r>=0;r--)if(n[r].id===t){i.set(e,n[r].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":var a=t.split(","),o=a[0];i.integer(e,o),i.percent(e,o)&&i.set("snapToLines",!1),i.alt(e,o,["auto"]),2===a.length&&i.alt("lineAlign",a[1],["start",ht,"end"]);break;case"position":a=t.split(","),i.percent(e,a[0]),2===a.length&&i.alt("positionAlign",a[1],["start",ht,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",ht,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");var r=i.get("line","auto");"auto"===r&&-1===dt.line&&(r=-1),t.line=r,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",ht);var a=i.get("position","auto");"auto"===a&&50===dt.position&&(a="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=a}(e,t)}function pt(e){return e.replace(//gi,"\n")}lt.prototype={parse:function(e){var t=this;function n(){var e=t.buffer,n=0;for(e=pt(e);n=16?s--:s++,navigator.userAgent.match(/Firefox\//)?a.line=c+1:a.line=c>7?c-2:c+1,a.align="left",a.position=Math.max(0,Math.min(100,s/32*100)),e.addCue(a)}}var mt,yt={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},At=function(e){var t=e;return yt.hasOwnProperty(e)&&(t=yt[e]),String.fromCharCode(t)},bt={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Et={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Tt={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},kt={25:2,26:4,29:6,30:8,31:10,27:13,28:15},_t=["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"}(mt||(mt={}));var St={verboseFilter:{DATA:3,DEBUG:3,INFO:2,WARNING:2,TEXT:1,ERROR:0},time:null,verboseLevel:0,setTime:function(e){this.time=e},log:function(e,t){this.verboseFilter[e],this.verboseLevel}},Ct=function(e){for(var t=[],n=0;n100&&(St.log("ERROR","Too large cursor position "+this.pos),this.pos=100)},t.moveCursor=function(e){var t=this.pos+e;if(e>1)for(var n=this.pos+1;n=144&&this.backSpace();var t=At(e);this.pos>=100?St.log("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<100;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,n=0;n<100;n++){var i=this.chars[n].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}(),Lt=function(){function e(){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.rows=[];for(var e=0;e<15;e++)this.rows.push(new Ot);this.currRow=14,this.nrRollUpRows=null,this.reset()}var t=e.prototype;return t.reset=function(){for(var e=0;e<15;e++)this.rows[e].clear();this.currRow=14},t.equals=function(e){for(var t=!0,n=0;n<15;n++)if(!this.rows[n].equals(e.rows[n])){t=!1;break}return t},t.copy=function(e){for(var t=0;t<15;t++)this.rows[t].copy(e.rows[t])},t.isEmpty=function(){for(var e=!0,t=0;t<15;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){St.log("INFO","setCursor: "+e),this.rows[this.currRow].setCursor(e)},t.setPAC=function(e){St.log("INFO","pacData = "+JSON.stringify(e));var t=e.row-1;if(this.nrRollUpRows&&t0&&(n=e?"["+t.join(" | ")+"]":t.join("\n")),n},t.getTextAndFormat=function(){return this.rows},e}(),Dt=function(){function e(e,t){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.lastCueEndTime=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Lt,this.nonDisplayedMemory=new Lt,this.lastOutputScreen=new Lt,this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}var t=e.prototype;return t.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.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,St.log("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=46,t.italics)t.foreground="white";else{var n=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][n]}St.log("INFO","MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)},t.outputDataUpdate=function(e){void 0===e&&(e=!1);var t=St.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}(),It=function(){function e(e,t,n){this.field=void 0,this.outputs=void 0,this.channels=void 0,this.currChNr=void 0,this.lastCmdA=void 0,this.lastCmdB=void 0,this.lastTime=void 0,this.dataCounters=void 0,this.field=e||1,this.outputs=[t,n],this.channels=[new Dt(1,t),new Dt(2,n)],this.currChNr=-1,this.lastCmdA=null,this.lastCmdB=null,this.lastTime=null,this.dataCounters={padding:0,char:0,cmd:0,other:0}}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 n,i,r,a=!1;this.lastTime=e,St.setTime(e);for(var o=0;o ("+Ct([i,r])+")"),(n=this.parseCmd(i,r))||(n=this.parseMidrow(i,r)),n||(n=this.parsePAC(i,r)),n||(n=this.parseBackgroundAttributes(i,r)),n||(a=this.parseChars(i,r))&&(this.currChNr&&this.currChNr>=0?this.channels[this.currChNr-1].insertChars(a):St.log("WARNING","No channel found yet. TEXT-MODE?")),n?this.dataCounters.cmd+=2:a?this.dataCounters.char+=2:(this.dataCounters.other+=2,St.log("WARNING","Couldn't parse cleaned data "+Ct([i,r])+" orig: "+Ct([t[o],t[o+1]])))):this.dataCounters.padding+=2},t.parseCmd=function(e,t){var n=null;if(!((20===e||28===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,St.log("DEBUG","Repeated command ("+Ct([e,t])+") is dropped"),!0;n=20===e||23===e?1:2;var i=this.channels[n-1];return 20===e||28===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=n,!0},t.parseMidrow=function(e,t){var n=null;return(17===e||25===e)&&t>=32&&t<=47&&((n=17===e?1:2)!==this.currChNr?(St.log("ERROR","Mismatch channel in midrow parsing"),!1):(this.channels[n-1].ccMIDROW(t),St.log("DEBUG","MIDROW ("+Ct([e,t])+")"),!0))},t.parsePAC=function(e,t){var n,i=null;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;if(e===this.lastCmdA&&t===this.lastCmdB)return this.lastCmdA=null,this.lastCmdB=null,!0;n=e<=23?1:2,i=t>=64&&t<=95?1===n?bt[e]:Tt[e]:1===n?Et[e]:kt[e];var r=this.interpretPAC(i,t);return this.channels[n-1].setPAC(r),this.lastCmdA=e,this.lastCmdB=t,this.currChNr=n,!0},t.interpretPAC=function(e,t){var n=t,i={color:null,italics:!1,indent:null,underline:!1,row:e};return n=t>95?t-96:t-64,i.underline=1==(1&n),n<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(n/2)]:n<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((n-16)/2),i},t.parseChars=function(e,t){var n=null,i=null,r=null;if(e>=25?(n=2,r=e-8):(n=1,r=e),r>=17&&r<=19){var a=t;a=17===r?t+80:18===r?t+112:t+144,St.log("INFO","Special char '"+At(a)+"' in channel "+n),i=[a]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);if(i){var o=Ct(i);St.log("DEBUG","Char codes = "+o.join(",")),this.lastCmdA=null,this.lastCmdB=null}return i},t.parseBackgroundAttributes=function(e,t){var n,i,r;return((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47)&&(n={},16===e||24===e?(i=Math.floor((t-32)/2),n.background=_t[i],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0)),r=e<24?1:2,this.channels[r-1].setBkgData(n),this.lastCmdA=null,this.lastCmdB=null,!0)},t.reset=function(){for(var e=0;ee)&&(this.startTime=e),this.endTime=t,this.screen=n,this.timelineController.createCaptionsTrack(this.trackName)},e}(),xt=function(e,t,n){return e.substr(n||0,t.length)===t},Nt=function(e){for(var t=5381,n=e.length;n;)t=33*t^e.charCodeAt(--n);return(t>>>0).toString()},Mt={parse:function(e,t,n,i,r,a){var o,s=Object(Me.utf8ArrayToStr)(new Uint8Array(e)).trim().replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),u="00:00.000",c=0,d=0,h=0,f=[],p=!0,g=!1,v=new gt;v.oncue=function(e){var t=n[i],r=n.ccOffset;t&&t.new&&(void 0!==d?r=n.ccOffset=t.start:function(e,t,n){var i=e[t],r=e[i.prevCC];if(!r||!r.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;r&&r.new;)e.ccOffset+=i.start-r.start,i.new=!1,r=e[(i=r).prevCC];e.presentationOffset=n}(n,i,h)),h&&(r=h-n.presentationOffset),g&&(e.startTime+=r-d,e.endTime+=r-d),e.id=Nt(e.startTime.toString())+Nt(e.endTime.toString())+Nt(e.text),e.text=decodeURIComponent(encodeURIComponent(e.text)),e.endTime>0&&f.push(e)},v.onparsingerror=function(e){o=e},v.onflush=function(){o&&a?a(o):r(f)},s.forEach((function(e){if(p){if(xt(e,"X-TIMESTAMP-MAP=")){p=!1,g=!0,e.substr(16).split(",").forEach((function(e){xt(e,"LOCAL:")?u=e.substr(6):xt(e,"MPEGTS:")&&(c=parseInt(e.substr(7)))}));try{t+(9e4*n[i].start||0)<0&&(t+=8589934592),c-=t,d=function(e){var t=parseInt(e.substr(-3)),n=parseInt(e.substr(-6,2)),i=parseInt(e.substr(-9,2)),r=e.length>9?parseInt(e.substr(0,e.indexOf(":"))):0;if(!(Object(l.isFiniteNumber)(t)&&Object(l.isFiniteNumber)(n)&&Object(l.isFiniteNumber)(i)&&Object(l.isFiniteNumber)(r)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+e);return t+=1e3*n,t+=6e4*i,t+=36e5*r}(u)/1e3,h=c/9e4}catch(e){g=!1,o=e}return}""===e&&(p=!1)}v.parse(e+"\n")})),v.flush()}};function Ft(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Bt(e,t){return e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}var Ut=function(e){var t,n;function i(t){var n;if((n=e.call(this,t,u.default.MEDIA_ATTACHING,u.default.MEDIA_DETACHING,u.default.FRAG_PARSING_USERDATA,u.default.FRAG_DECRYPTED,u.default.MANIFEST_LOADING,u.default.MANIFEST_LOADED,u.default.FRAG_LOADED,u.default.INIT_PTS_FOUND)||this).media=null,n.config=void 0,n.enabled=!0,n.Cues=void 0,n.textTracks=[],n.tracks=[],n.initPTS=[],n.unparsedVttFrags=[],n.cueRanges=[],n.captionsTracks={},n.captionsProperties=void 0,n.cea608Parser=void 0,n.lastSn=-1,n.prevCC=-1,n.vttCCs=null,n.hls=t,n.config=t.config,n.Cues=t.config.cueHandler,n.captionsProperties={textTrack1:{label:n.config.captionsTextTrack1Label,languageCode:n.config.captionsTextTrack1LanguageCode},textTrack2:{label:n.config.captionsTextTrack2Label,languageCode:n.config.captionsTextTrack2LanguageCode}},n.config.enableCEA708Captions){var i=new Pt(Ft(n),"textTrack1"),r=new Pt(Ft(n),"textTrack2");n.cea608Parser=new It(0,i,r)}return n}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var r=i.prototype;return r.addCues=function(e,t,n,i){for(var r,a,o,s,l=this.cueRanges,u=!1,c=l.length;c--;){var d=l[c],h=(r=d[0],a=d[1],o=t,s=n,Math.min(a,s)-Math.max(r,o));if(h>=0&&(d[0]=Math.min(d[0],t),d[1]=Math.max(d[1],n),u=!0,h/(n-t)>.5))return}u||l.push([t,n]),this.Cues.newCue(this.captionsTracks[e],t,n,i)},r.onInitPtsFound=function(e){var t=this,n=e.frag,i=e.id,r=e.initPTS,a=this.unparsedVttFrags;"main"===i&&(this.initPTS[n.cc]=r),a.length&&(this.unparsedVttFrags=[],a.forEach((function(e){t.onFragLoaded(e)})))},r.getExistingTrack=function(e){var t=this.media;if(t)for(var n=0;n=a.length||n!==r||!o||this.stopped)this._clearReloadTimer();else if(c.logger.log("subtitle track "+n+" loaded"),i.live){var s=re(o.details,i,e.stats.trequest);c.logger.log("Reloading live subtitle playlist in "+s+"ms"),this.timer=setTimeout((function(){t._loadCurrentTrack()}),s)}else this._clearReloadTimer()},s.startLoad=function(){this.stopped=!1,this._loadCurrentTrack()},s.stopLoad=function(){this.stopped=!0,this._clearReloadTimer()},s._clearReloadTimer=function(){this.timer&&(clearTimeout(this.timer),this.timer=null)},s._loadCurrentTrack=function(){var e=this.trackId,t=this.tracks,n=this.hls,i=t[e];e<0||!i||i.details&&!i.details.live||(c.logger.log("Loading subtitle track "+e),n.trigger(u.default.SUBTITLE_TRACK_LOADING,{url:i.url,id:e}))},s._toggleTrackModes=function(e){var t=this.media,n=this.subtitleDisplay,i=this.trackId;if(t){var r=Vt(t.textTracks);if(-1===e)[].slice.call(r).forEach((function(e){e.mode="disabled"}));else{var a=r[i];a&&(a.mode="disabled")}var o=r[e];o&&(o.mode=n?"showing":"hidden")}},s._setSubtitleTrackInternal=function(e){var t=this.hls,n=this.tracks;!Object(l.isFiniteNumber)(e)||e<-1||e>=n.length||(this.trackId=e,c.logger.log("Switching to subtitle track "+e),t.trigger(u.default.SUBTITLE_TRACK_SWITCH,{id:e}),this._loadCurrentTrack())},s._onTextTracksChanged=function(){if(this.media){for(var e=-1,t=Vt(this.media.textTracks),n=0;n=i[o].start&&a<=i[o].end){r=i[o];break}var s=t.start+t.duration;r?r.end=s:(r={start:a,end:s},i.push(r))}}},r.onMediaAttached=function(e){var t=e.media;this.media=t,t.addEventListener("seeking",this._onMediaSeeking),this.state=me},r.onMediaDetaching=function(){var e=this;this.media&&(this.media.removeEventListener("seeking",this._onMediaSeeking),this.fragmentTracker.removeAllFragments(),this.currentTrackId=-1,this.tracks.forEach((function(t){e.tracksBuffered[t.id]=[]})),this.media=null,this.state=ge)},r.onError=function(e){var t=e.frag;t&&"subtitle"===t.type&&(this.state=me)},r.onSubtitleTracksUpdated=function(e){var t=this;c.logger.log("subtitle tracks updated"),this.tracksBuffered=[],this.tracks=e.subtitleTracks,this.tracks.forEach((function(e){t.tracksBuffered[e.id]=[]}))},r.onSubtitleTrackSwitch=function(e){if(this.currentTrackId=e.id,this.tracks&&this.tracks.length&&-1!==this.currentTrackId){var t=this.tracks[this.currentTrackId];t&&t.details&&this.setInterval(500)}else this.clearInterval()},r.onSubtitleTrackLoaded=function(e){var t=e.id,n=e.details,i=this.currentTrackId,r=this.tracks,a=r[i];t>=r.length||t!==i||!a||(n.live&&function(e,t,n){void 0===n&&(n=0);var i=-1;ie(e,t,(function(e,t,n){t.start=e.start,i=n}));var r=t.fragments;if(i<0)r.forEach((function(e){e.start+=n}));else for(var a=i+1;a0&&n&&n.key&&"AES-128"===n.method){var a=Ht.now();this.decrypter.decrypt(e.payload,n.key.buffer,n.iv.buffer,(function(e){var t=Ht.now();r.trigger(u.default.FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:a,tdecrypt:t}})}))}},r.onLevelUpdated=function(e){var t=e.details.fragments;this.lastAVStart=t.length?t[0].start:0},r.doTick=function(){if(this.media)switch(this.state){case me:var e=this.config,t=this.currentTrackId,n=this.fragmentTracker,i=this.media,r=this.tracks;if(!r||!r[t]||!r[t].details)break;var a,o=e.maxBufferHole,s=e.maxFragLookUpTolerance,l=Math.min(e.maxBufferLength,e.maxMaxBufferLength),d=G.bufferedInfo(this._getBuffered(),i.currentTime,o),h=d.end,f=d.len,p=r[t].details,g=p.fragments,v=g.length,m=g[v-1].start+g[v-1].duration;if(f>l)return;var y=this.fragPrevious;h3)return void this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});var r=3-this._requestLicenseFailureCount+1;c.logger.warn("Retrying license request, "+r+" attempts left"),this._requestLicense(n,i)}}},l._generateLicenseRequestChallenge=function(e,t){switch(e.mediaKeySystemDomain){case Kt.WIDEVINE:return t}throw new Error("unsupported key-system: "+e.mediaKeySystemDomain)},l._requestLicense=function(e,t){c.logger.log("Requesting content license for key-system");var n=this._mediaKeysList[0];if(!n)return c.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var i=this.getLicenseServerUrl(n.mediaKeySystemDomain),r=this._createLicenseXhr(i,e,t);c.logger.log("Sending license request to URL: "+i);var a=this._generateLicenseRequestChallenge(n,e);r.send(a)}catch(e){c.logger.error("Failure requesting DRM license: "+e),this.hls.trigger(u.default.ERROR,{type:s.ErrorTypes.KEY_SYSTEM_ERROR,details:s.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},l.onMediaAttached=function(e){if(this._emeEnabled){var t=e.media;this._media=t,t.addEventListener("encrypted",this._onMediaEncrypted)}},l.onMediaDetached=function(){this._media&&(this._media.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null)},l.onManifestParsed=function(e){if(this._emeEnabled){var t=e.levels.map((function(e){return e.audioCodec})),n=e.levels.map((function(e){return e.videoCodec}));this._attemptKeySystemAccess(Kt.WIDEVINE,t,n)}},r=i,(a=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&Wt(r.prototype,a),o&&Wt(r,o),i}(h)});function Zt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qt(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Jt(e,t){for(var n=0;nt)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:"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:"liveSyncPosition",get:function(){return this.streamController.liveSyncPosition}},{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:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}}]),i}(q);tn.defaultConfig=void 0},"./src/polyfills/number-isFinite.js": /*!******************************************!*\ !*** ./src/polyfills/number-isFinite.js ***! \******************************************/ /*! exports provided: isFiniteNumber */function(e,t,n){n.r(t),n.d(t,"isFiniteNumber",(function(){return i}));var i=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)}},"./src/utils/get-self-scope.js": /*!*************************************!*\ !*** ./src/utils/get-self-scope.js ***! \*************************************/ /*! exports provided: getSelfScope */function(e,t,n){function i(){return"undefined"==typeof window?self:window}n.r(t),n.d(t,"getSelfScope",(function(){return i}))},"./src/utils/logger.js": /*!*****************************!*\ !*** ./src/utils/logger.js ***! \*****************************/ /*! exports provided: enableLogs, logger */function(e,t,n){n.r(t),n.d(t,"enableLogs",(function(){return c})),n.d(t,"logger",(function(){return d}));var i=n(/*! ./get-self-scope */"./src/utils/get-self-scope.js");function r(){}var a={trace:r,debug:r,log:r,warn:r,info:r,error:r},o=a;function s(e,t){return t="["+e+"] > "+t}var l=Object(i.getSelfScope)();function u(e){var t=l.console[e];return t?function(){for(var n=arguments.length,i=new Array(n),r=0;r1?t-1:0),i=1;i0&&(t=this._duration*(e/100)),this.seek(t)}},{key:"seek",value:function(e){e<0&&(re.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(e0)switch(this._recoverAttemptsRemaining-=1,t.type){case vn.ErrorTypes.NETWORK_ERROR:switch(t.details){case vn.ErrorDetails.MANIFEST_LOAD_ERROR:case vn.ErrorDetails.MANIFEST_LOAD_TIMEOUT:case vn.ErrorDetails.MANIFEST_PARSING_ERROR:case vn.ErrorDetails.LEVEL_LOAD_ERROR:case vn.ErrorDetails.LEVEL_LOAD_TIMEOUT:re.error("hlsjs: unrecoverable network fatal error.",{evt:e,data:t}),n=this.createError(i),this.trigger(ue.PLAYBACK_ERROR,n),this.stop();break;default:re.warn("hlsjs: trying to recover from network error.",{evt:e,data:t}),i.level=pe.Levels.WARN,this._hls.startLoad()}break;case vn.ErrorTypes.MEDIA_ERROR:re.warn("hlsjs: trying to recover from media error.",{evt:e,data:t}),i.level=pe.Levels.WARN,this._recover(e,t,i);break;default:re.error("hlsjs: could not recover from error.",{evt:e,data:t}),n=this.createError(i),this.trigger(ue.PLAYBACK_ERROR,n),this.stop()}else re.error("hlsjs: could not recover from error after maximum number of attempts.",{evt:e,data:t}),n=this.createError(i),this.trigger(ue.PLAYBACK_ERROR,n),this.stop();else{if(this.options.playback.triggerFatalErrorOnResourceDenied&&this._keyIsDenied(t))return re.error("hlsjs: could not load decrypt key.",{evt:e,data:t}),n=this.createError(i),this.trigger(ue.PLAYBACK_ERROR,n),void this.stop();i.level=pe.Levels.WARN,re.warn("hlsjs: non-fatal error occurred",{evt:e,data:t})}}},{key:"_keyIsDenied",value:function(e){return e.type===vn.ErrorTypes.NETWORK_ERROR&&e.details===vn.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(ue.PLAYBACK_TIMEUPDATE,e,this.name))}},{key:"_onDurationChange",value:function(){var e=this.getDuration();this._lastDuration!==e&&(this._lastDuration=e,hn(ln(n.prototype),"_onDurationChange",this).call(this))}},{key:"_onProgress",value:function(){if(this.el.buffered.length){for(var e=[],t=0,n=0;n=e[n].start&&this.el.currentTime<=e[n].end&&(t=n);var i={start:e[t].start,current:e[t].end,total:this.getDuration()};this.trigger(ue.PLAYBACK_PROGRESS,i,e)}}},{key:"play",value:function(){this._hls||this._setup(),hn(ln(n.prototype),"play",this).call(this),this._startTimeUpdateTimer()}},{key:"pause",value:function(){this._hls&&(hn(ln(n.prototype),"pause",this).call(this),this.dvrEnabled&&this._updateDvr(!0))}},{key:"stop",value:function(){this._stopTimeUpdateTimer(),this._hls&&(hn(ln(n.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),hn(ln(n.prototype),"destroy",this).call(this)}},{key:"_updatePlaybackType",value:function(e,t){this._playbackType=t.details.live?Ae.LIVE:Ae.VOD,this._onLevelUpdated(e,t),this._ccTracksUpdated&&this._playbackType===Ae.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(ue.PLAYBACK_LEVELS_AVAILABLE,this._levels)}},{key:"_onLevelUpdated",value:function(e,t){this._segmentTargetDuration=t.details.targetduration,this._playlistType=t.details.type||null;var n=!1,i=!1,r=t.details.fragments,a=this._playableRegionStartTime,o=this._playableRegionDuration;if(0!==r.length){if(r[0].rawProgramDateTime&&(this._programDateTime=r[0].rawProgramDateTime),this._playableRegionStartTime!==r[0].start&&(n=!0,this._playableRegionStartTime=r[0].start),n)if(this._localStartTimeCorrelation){var s=this._localStartTimeCorrelation,l=this._now-s.local,u=(s.remote+l)/1e3;ua+this._extrapolatedWindowDuration&&(this._localStartTimeCorrelation={local:this._now,remote:1e3*Math.max(r[0].start,a+this._extrapolatedWindowDuration)})}else this._localStartTimeCorrelation={local:this._now,remote:1e3*(r[0].start+this._extrapolatedWindowDuration/2)};var c=t.details.totalduration;if(this._playbackType===Ae.LIVE){var d=t.details.targetduration*((this.options.playback.hlsjsConfig||{}).liveSyncDurationCount||vn.DefaultConfig.liveSyncDurationCount);d<=c?(c-=d,this._durationExcludesAfterLiveSyncPoint=!0):this._durationExcludesAfterLiveSyncPoint=!1}c!==this._playableRegionDuration&&(i=!0,this._playableRegionDuration=c);var h=r[0].start+c,f=a+o;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}:vf&&(this._localEndTimeCorrelation={local:this._now,remote:1e3*f})}else this._localEndTimeCorrelation={local:this._now,remote:1e3*h};i&&this._onDurationChange(),n&&this._onProgress()}}},{key:"_onFragmentLoaded",value:function(e,t){this.trigger(ue.PLAYBACK_FRAGMENT_LOADED,t)}},{key:"_onSubtitleLoaded",value:function(){if(!this._ccIsSetup){this.trigger(ue.PLAYBACK_SUBTITLE_AVAILABLE);var e=this._playbackType===Ae.LIVE?-1:this.closedCaptionsTrackId;this.closedCaptionsTrackId=e,this._ccIsSetup=!0}}},{key:"_onLevelSwitch",value:function(e,t){this.levels.length||this._fillLevels(),this.trigger(ue.PLAYBACK_LEVEL_SWITCH_END),this.trigger(ue.PLAYBACK_LEVEL_SWITCH,t);var n=this._hls.levels[t.level];n&&(this.highDefinition=n.height>=720||n.bitrate/1e3>=2e3,this.trigger(ue.PLAYBACK_HIGHDEFINITIONUPDATE,this.highDefinition),this.trigger(ue.PLAYBACK_BITRATE,{height:n.height,width:n.width,bandwidth:n.bitrate,bitrate:n.bitrate,level:t.level}))}},{key:"getPlaybackType",value:function(){return this._playbackType}},{key:"isSeekEnabled",value:function(){return this._playbackType===Ae.VOD||this.dvrEnabled}},{key:"dvrEnabled",get:function(){return this._durationExcludesAfterLiveSyncPoint&&this._duration>=this._minDvrSize&&this.getPlaybackType()===Ae.LIVE}}]),n}($e);return bn.canPlay=function(e,t){var n=e.split("?")[0].match(/.*\.(.*)$/)||[],i=n.length>1&&"m3u8"===n[1].toLowerCase()||An(t,["application/vnd.apple.mpegurl","application/x-mpegURL"]);return!(!vn.isSupported()||!i)},en.Loader.registerPlayback(bn),n({},en,{HLS:bn})})); //# sourceMappingURL=clappr.min.js.map