PageSourceSearch

https://www.wkyc.com/assets/js-libs/akamai/amp/core/amp.js?apikey=tegna&version=9.1.22

js wkyc.com collected 2026-09-24 08:29:56 UTC 619,492 bytes, 19,044 lines download raw bytes

1var REACT_ELEMENT_TYPE,babelHelpers={};function _typeof(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?babelHelpers.typeof=_typeof=function(e){return typeof e}:babelHelpers.typeof=_typeof=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _createRawReactElement(e,r,t,n){REACT_ELEMENT_TYPE=REACT_ELEMENT_TYPE||("function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103);var o=e&&e.defaultProps,a=arguments.length-3;if(r||0==a||(r={children:void 0}),1==a)r.children=n;else if(1<a){for(var l=new Array(a),i=0;i<a;i++)l[i]=arguments[i+3];r.children=l}if(r&&o)for(var s in o)void 0===r[s]&&(r[s]=o[s]);else r=r||(o||{});return{$$typeof:REACT_ELEMENT_TYPE,type:e,key:void 0===t?null:""+t,ref:null,props:r,_owner:null}}function _asyncIterator(e){var r;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(r=e[Symbol.asyncIterator]))return r.call(e);if(Symbol.iterator&&null!=(r=e[Symbol.iterator]))return r.call(e)}throw new TypeError("Object is not async iterable")}function AsyncGenerator(a){var o,l;function i(r,e){try{var t=a[r](e),n=t.value,o=n instanceof babelHelpers.AwaitValue;Promise.resolve(o?n.wrapped:n).then(function(e){o?i("return"===r?"return":"next",e):s(t.done?"return":"normal",e)},function(e){i("throw",e)})}catch(e){s("throw",e)}}function s(e,r){switch(e){case"return":o.resolve({value:r,done:!0});break;case"throw":o.reject(r);break;default:o.resolve({value:r,done:!1})}(o=o.next)?i(o.key,o.arg):l=null}this._invoke=function(t,n){return new Promise(function(e,r){r={key:t,arg:n,resolve:e,reject:r,next:null};l?l=l.next=r:(o=l=r,i(t,n))})},"function"!=typeof a.return&&(this.return=void 0)}function _asyncGeneratorDelegate(n,e){var r={},o=!1;function t(r,t){return o=!0,t=new Promise(function(e){e(n[r](t))}),{done:!1,value:e(t)}}return"function"==typeof Symbol&&Symbol.iterator&&(r[Symbol.iterator]=function(){return this}),r.next=function(e){return o?(o=!1,e):t("next",e)},"function"==typeof n.throw&&(r.throw=function(e){if(o)throw o=!1,e;return t("throw",e)}
1),"function"==typeof n.return&&(r.return=function(e){return o?(o=!1,e):t("return",e)}),r}function asyncGeneratorStep(e,r,t,n,o,a,l){try{var i=e[a](l),s=i.value}catch(e){return void t(e)}i.done?r(s):Promise.resolve(s).then(n,o)}function _asyncToGenerator(i){return function(){var e=this,l=arguments;return new Promise(function(r,t){var n=i.apply(e,l);function o(e){asyncGeneratorStep(n,r,t,o,a,"next",e)}function a(e){asyncGeneratorStep(n,r,t,o,a,"throw",e)}o(void 0)})}}function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),e}function _defineEnumerableProperties(e,r){for(var t in r)(a=r[t]).configurable=a.enumerable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,t,a);if(Object.getOwnPropertySymbols)for(var n=Object.getOwnPropertySymbols(r),o=0;o<n.length;o++){var a,l=n[o];(a=r[l]).configurable=a.enumerable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,l,a)}return e}function _defaults(e,r){for(var t=Object.getOwnPropertyNames(r),n=0;n<t.length;n++){var o=t[n],a=Object.getOwnPropertyDescriptor(r,o);a&&a.configurable&&void 0===e[o]&&Object.defineProperty(e,o,a)}return e}function _defineProperty(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _extends(){return babelHelpers.extends=_extends=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t,n=arguments[r];for(t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},_extends.apply(this,arguments)}function _inherits(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&babelHelpers.setPrototypeOf(e,r)}function _getPrototypeOf(e){return babelHelpers.getPrototypeOf=_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _setPrototypeOf(e,r){return babelHelpers.setPrototypeOf=_setPrototypeOf=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e},_setPrototypeOf(e,r)}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function _construct(e,r,t){return babelHelpers.isNativeReflectConstruct()?babelHelpers.construct=_construct=Reflect.construct:babelHelpers.construct=_construct=function(e,r,t){var n=[null];n.push.apply(n,r);n=new(Function.bind.apply(e,n));return t&&babelHelpers.setPrototypeOf(n,t.prototype),n},_construct.apply(null,arguments)}function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}function _wrapNativeSuper(e){var t="function"==typeof Map?new Map:void 0;return babelHelpers.wrapNativeSuper=_wrapNativeSuper=function(e){if(null===e||!babelHelpers.isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return babelHelpers.construct(e,arguments,babelHelpers.getPrototypeOf(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),babelHelpers.setPrototypeOf(r,e)},_wrapNativeSuper(e)}function _instanceof(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function(){return e},e}
1function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=_getRequireWildcardCache();if(r&&r.has(e))return r.get(e);var t,n,o={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&((n=a?Object.getOwnPropertyDescriptor(e,t):null)&&(n.get||n.set)?Object.defineProperty(o,t,n):o[t]=e[t]);return o.default=e,r&&r.set(e,o),o}function _newArrowCheck(e,r){if(e!==r)throw new TypeError("Cannot instantiate an arrow function")}function _objectDestructuringEmpty(e){if(null==e)throw new TypeError("Cannot destructure undefined")}function _objectWithoutPropertiesLoose(e,r){if(null==e)return{};for(var t,n={},o=Object.keys(e),a=0;a<o.length;a++)t=o[a],0<=r.indexOf(t)||(n[t]=e[t]);return n}function _objectWithoutProperties(e,r){if(null==e)return{};var t,n=babelHelpers.objectWithoutPropertiesLoose(e,r);if(Object.getOwnPropertySymbols)for(var o=Object.getOwnPropertySymbols(e),a=0;a<o.length;a++)t=o[a],0<=r.indexOf(t)||Object.prototype.propertyIsEnumerable.call(e,t)&&(n[t]=e[t]);return n}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,r){return!r||"object"!=typeof r&&"function"!=typeof r?babelHelpers.assertThisInitialized(e):r}function _superPropBase(e,r){for(;!Object.prototype.hasOwnProperty.call(e,r)&&null!==(e=babelHelpers.getPrototypeOf(e)););return e}function _get(e,r,t){return"undefined"!=typeof Reflect&&Reflect.get?babelHelpers.get=_get=Reflect.get:babelHelpers.get=_get=function(e,r,t){e=babelHelpers.superPropBase(e,r);if(e){r=Object.getOwnPropertyDescriptor(e,r);return r.get?r.get.call(t):r.value}},_get(e,r,t||e)}function set(e,r,t,n){return(set="undefined"!=typeof Reflect&&Reflect.set?Reflect.set:function(e,r,t,n){var o,e=babelHelpers.superPropBase(e,r);if(e){if((o=Object.getOwnPropertyDescriptor(e,r)).set)return o.set.call(n,t),!0;if(!o.writable)return!1}if(o=Object.getOwnPropertyDescriptor(n,r)){if(!o.writable)return!1;o.value=t,Object.defineProperty(n,r,o)}else babelHelpers.defineProperty(n,r,t);return!0})(e,r,t,n)}function _set(e,r,t,n,o){if(!set(e,r,t,n||e)&&o)throw new Error("failed to set property");return t}function _taggedTemplateLiteral(e,r){return r=r||e.slice(0),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(r)}}))}function _taggedTemplateLiteralLoose(e,r){return r=r||e.slice(0),e.raw=r,e}function _temporalUndefined(){}function _temporalRef(e,r){return e===babelHelpers.temporalUndefined?babelHelpers.tdz(r):e}function _slicedToArray(e,r){return babelHelpers.arrayWithHoles(e)||babelHelpers.iterableToArrayLimit(e,r)||babelHelpers.unsupportedIterableToArray(e,r)||babelHelpers.nonIterableRest()}function _slicedToArrayLoose(e,r){return babelHelpers.arrayWithHoles(e)||babelHelpers.iterableToArrayLimitLoose(e,r)||babelHelpers.unsupportedIterableToArray(e,r)||babelHelpers.nonIterableRest()}function _toArray(e){return babelHelpers.arrayWithHoles(e)||babelHelpers.iterableToArray(e)||babelHelpers.unsupportedIterableToArray(e)||babelHelpers.nonIterableRest()}function _toConsumableArray(e){return babelHelpers.arrayWithoutHoles(e)||babelHelpers.iterableToArray(e)||babelHelpers.unsupportedIterableToArray(e)||babelHelpers.nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return babelHelpers.arrayLikeToArray(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}babelHelpers.typeof=_typeof,babelHelpers.jsx=_createRawReactElement,babelHelpers.asyncIterator=_asyncIterator,"function"==typeof Symbol&&Symbol.asyncIterator&&(AsyncGenerator.prototype[Symbol.asyncIterator]=function(){return this}),AsyncGenerator.prototype.next=function(e){return this._invoke("next",e)},AsyncGenerator.prototype.throw=function(e){return this._invoke("throw",e)},AsyncGenerator.prototype.return=function(e){return this._invoke("return",e)},babelHelpers.AsyncGenerator=AsyncGenerator,babelHelpers.asyncGeneratorDelegate=_asyncGeneratorDelegate,babelHelpers.asyncToGenerator=_asyncToGenerator,babelHelpers.classCallCheck=_classCallCheck,babelHelpers.createClass=_createClass,babelHelpers.defineEnumerableProperties=_defineEnumerableProperties,babelHelpers.defaults=_defaults,babelHelpers.defineProperty=_defineProperty,babelHelpers.extends=_extends,babelHelpers.inherits=_inherits,babelHelpers.getPrototypeOf=_getPrototypeOf,babelHelpers.setPrototypeOf=_setPrototypeOf,babelHelpers.isNativeReflectConstruct=_isNativeReflectConstruct,babelHelpers.construct=_construct,babelHelpers.isNativeFunction=_isNativeFunction,babelHelpers.wrapNativeSuper=_wrapNativeSuper,babelHelpers.instanceof=_instanceof,babelHelpers.interopRequireDefault=_interopRequireDefault,babelHelpers.interopRequireWildcard=_interopRequireWildcard,babelHelpers.newArrowCheck=_newArrowCheck,babelHelpers.objectDestructuringEmpty=_objectDestructuringEmpty,babelHelpers.objectWithoutPropertiesLoose=_objectWithoutPropertiesLoose,babelHelpers.objectWithoutProperties=_objectWithoutProperties,babelHelpers.assertThisInitialized=_assertThisInitialized,babelHelpers.possibleConstructorReturn=_possibleConstructorReturn,babelHelpers.superPropBase=_superPropBase,babelHelpers.get=_get,babelHelpers.set=_set,babelHelpers.taggedTemplateLiteral=_taggedTemplateLiteral,babelHelpers.taggedTemplateLiteralLoose=_taggedTemplateLiteralLoose,babelHelpers.temporalUndefined=_temporalUndefined,babelHelpers.temporalRef=_temporalRef,babelHelpers.slicedToArray=_slicedToArray,babelHelpers.slicedToArrayLoose=_slicedToArrayLoose,babelHelpers.toArray=_toArray,babelHelpers.toConsumableArray=_toConsumableArray,babelHelpers.arrayWithoutHoles=_arrayWithoutHoles,babelHelpers.arrayWithHoles=_arrayWithHoles,babelHelpers.iterableToArray=_iterableToArray,babelHelpers.arrayLikeToArray=_arrayLikeToArray;
2try{var ce=new window.CustomEvent("test");ce.preventDefault();if(!0!==ce.defaultPrevented)throw Error("Could not prevent default");}
2catch(e){var CustomEvent=function(d,a){var b,c;a=a||{bubbles:!1,cancelable:!1,detail:void 0};b=document.createEvent("CustomEvent");b.initCustomEvent(d,a.bubbles,a.cancelable,a.detail);c=b.preventDefault;b.preventDefault=function(){c.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(f){this.defaultPrevented=!0}};return b};CustomEvent.prototype=
3window.Event.prototype;window.CustomEvent=CustomEvent};
4!function(t,e){if(!t.ES6Promise){t.ES6Promise=e();t.ES6Promise.polyfill()}}(this,function(){"use strict";function t(t){return"function"==typeof t||"object"==typeof t&&null!==t}function e(t){return"function"==typeof t}function n(t){I=t}function r(t){J=t}function o(){return function(){return process.nextTick(a)}}function i(){return"undefined"!=typeof H?function(){H(a)}:c()}function s(){var t=0,e=new V(a),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function u(){var t=new MessageChannel;return t.port1.onmessage=a,function(){return t.port2.postMessage(0)}}function c(){var t=setTimeout;return function(){return t(a,1)}}function a(){for(var t=0;t<G;t+=2){var e=$[t],n=$[t+1];e(n),$[t]=void 0,$[t+1]=void 0}G=0}function f(){try{var t=require,e=t("vertx");return H=e.runOnLoop||e.runOnContext,i()}catch(n){return c()}}function l(t,e){var n=arguments,r=this,o=new this.constructor(p);void 0===o[et]&&k(o);var i=r._state;return i?!function(){var t=n[i-1];J(function(){return x(i,o,t,r._result)})}():E(r,o,t,e),o}function h(t){var e=this;if(t&&"object"==typeof t&&t.constructor===e)return t;var n=new e(p);return g(n,t),n}function p(){}function v(){return new TypeError("You cannot resolve a promise with itself")}function d(){return new TypeError("A promises callback cannot return that same promise.")}function _(t){try{return t.then}catch(e){return it.error=e,it}}function y(t,e,n,r){try{t.call(e,n,r)}catch(o){return o}}function m(t,e,n){J(function(t){var r=!1,o=y(n,e,function(n){r||(r=!0,e!==n?g(t,n):S(t,n))},function(e){r||(r=!0,j(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&o&&(r=!0,j(t,o))},t)}function b(t,e){e._state===rt?S(t,e._result):e._state===ot?j(t,e._result):E(e,void 0,function(e){return g(t,e)},function(e){return j(t,e)})}function w(t,n,r){n.constructor===t.constructor&&r===l&&n.constructor.resolve===h?b(t,n):r===it?j(t,it.error):void 0===r?S(t,n):e(r)?m(t,n,r):S(t,n)}function g(e,n){e===n?j(e,v()):t(n)?w(e,n,_(n)):S(e,n)}function A(t){t._onerror&&t._onerror(t._result),P(t)}function S(t,e){t._state===nt&&(t._result=e,t._state=rt,0!==t._subscribers.length&&J(P,t))}function j(t,e){t._state===nt&&(t._state=ot,t._result=e,J(A,t))}function E(t,e,n,r){var o=t._subscribers,i=o.length;t._onerror=null,o[i]=e,o[i+rt]=n,o[i+ot]=r,0===i&&t._state&&J(P,t)}function P(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r=void 0,o=void 0,i=t._result,s=0;s<e.length;s+=3)r=e[s],o=e[s+n],r?x(n,r,o,i):o(i);t._subscribers.length=0}}function T(){this.error=null}function M(t,e){try{return t(e)}catch(n){return st.error=n,st}}function x(t,n,r,o){var i=e(r),s=void 0,u=void 0,c=void 0,a=void 0;if(i){if(s=M(r,o),s===st?(a=!0,u=s.error,s=null):c=!0,n===s)return void j(n,d())}else s=o,c=!0;n._state!==nt||(i&&c?g(n,s):a?j(n,u):t===rt?S(n,s):t===ot&&j(n,s))}function C(t,e){try{e(function(e){g(t,e)},function(e){j(t,e)})}catch(n){j(t,n)}}function O(){return ut++}function k(t){t[et]=ut++,t._state=void 0,t._result=void 0,t._subscribers=[]}function Y(t,e){this._instanceConstructor=t,this.promise=new t(p),this.promise[et]||k(this.promise),B(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._result=new Array(this.length),0===this.length?S(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&S(this.promise,this._result))):j(this.promise,q())}function q(){return new Error("Array Methods must be provided an Array")}function F(t){return new Y(this,t).promise}function D(t){var e=this;return new e(B(t)?function(n,r){for(var o=t.length,i=0;i<o;i++)e.resolve(t[i]).then(n,r)}:function(t,e){return e(new TypeError("You must pass an array to race."))})}function K(t){var e=this,n=new e(p);return j(n,t),n}function L(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function N(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object c
4onstructor cannot be called as a function.")}function U(t){this[et]=O(),this._result=this._state=void 0,this._subscribers=[],p!==t&&("function"!=typeof t&&L(),this instanceof U?C(this,t):N())}function W(){var t=void 0;if("undefined"!=typeof global)t=global;else if("undefined"!=typeof self)t=self;else try{t=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var n=t.Promise;if(n){var r=null;try{r=Object.prototype.toString.call(n.resolve())}catch(e){}if("[object Promise]"===r&&!n.cast)return}t.Promise=U}var z=void 0;z=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var B=z,G=0,H=void 0,I=void 0,J=function(t,e){$[G]=t,$[G+1]=e,G+=2,2===G&&(I?I(a):tt())},Q="undefined"!=typeof window?window:void 0,R=Q||{},V=R.MutationObserver||R.WebKitMutationObserver,X="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),Z="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,$=new Array(1e3),tt=void 0;tt=X?o():V?s():Z?u():void 0===Q&&"function"==typeof require?f():c();var et=Math.random().toString(36).substring(16),nt=void 0,rt=1,ot=2,it=new T,st=new T,ut=0;return Y.prototype._enumerate=function(){for(var t=this.length,e=this._input,n=0;this._state===nt&&n<t;n++)this._eachEntry(e[n],n)},Y.prototype._eachEntry=function(t,e){var n=this._instanceConstructor,r=n.resolve;if(r===h){var o=_(t);if(o===l&&t._state!==nt)this._settledAt(t._state,e,t._result);else if("function"!=typeof o)this._remaining--,this._result[e]=t;else if(n===U){var i=new n(p);w(i,t,o),this._willSettleAt(i,e)}else this._willSettleAt(new n(function(e){return e(t)}),e)}else this._willSettleAt(r(t),e)},Y.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===nt&&(this._remaining--,t===ot?j(r,n):this._result[e]=n),0===this._remaining&&S(r,this._result)},Y.prototype._willSettleAt=function(t,e){var n=this;E(t,void 0,function(t){return n._settledAt(rt,e,t)},function(t){return n._settledAt(ot,e,t)})},U.all=F,U.race=D,U.resolve=h,U.reject=K,U._setScheduler=n,U._setAsap=r,U._asap=J,U.prototype={constructor:U,then:l,"catch":function(t){return this.then(null,t)}},U.polyfill=W,U.Promise=U,U});
5"function"!=typeof Object.values&&(Object.values=function(c){return Object.keys(c).map(function(d){return c[d]})});
6"function"!=typeof Object.entries&&(Object.entries=function(c){return Object.keys(c).map(function(d){return [d,c[d]]})});
7"function"!=typeof Object.assign&&(Object.assign=function(c){if(null==c)throw new TypeError("Cannot convert undefined or null to object");c=Object(c);for(var e=1;e<arguments.length;e++){var b=arguments[e];if(null!=b)for(var d in b)Object.prototype.hasOwnProperty.call(b,d)&&(c[d]=b[d])}return c});
8Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(c,e){if(null==this)throw new TypeError('"this" is null or not defined');var b=Object(this),f=b.length>>>0;if("function"!==typeof c)throw new TypeError("predicate must be a function");for(var a=0;a<f;){var d=b[a];if(c.call(e,d,a,b))return d;a++}},configurable:!0,writable:!0});
9Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(c,e){if(null==this)throw new TypeError('"this" is null or not defined');var b=Object(this),d=b.length>>>0;if("function"!==typeof c)throw new TypeError("predicate must be a function");for(var a=0;a<d;){if(c.call(e,b[a],a,b))return a;a++}return-1}});
10Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(c,e){if(null==this)throw new TypeError('"this" is null or not defined');var b=Object(this),d=b.length>>>0;if(0===d)return!1;var a=e|0;for(a=Math.max(0<=a?a:d-Math.abs(a),0);a<d;){var f=b[a],g=c;if(f===g||"number"===typeof f&&"number"===typeof g&&isNaN(f)&&isNaN(g))return!0;a++}return!1}});
11Array.from||(Array.from=function(){var l=Object.prototype.toString,h=function(c){return"function"===typeof c||"[object Function]"===l.call(c)},m=Math.pow(2,53)-1;return function(c){var k=Object(c);if(null==c)throw new TypeError("Array.from requires an array-like object - not null or undefined");var d=1<arguments.length?arguments[1]:void 0,f;if("undefined"!==typeof d){if(!h(d))throw new TypeError("Array.from: when provided, the second argument must be a function");2<arguments.length&&(f=arguments[2])}var a=Number(k.length);a=isNaN(a)?0:0!==a&&isFinite(a)?(0<a?1:-1)*Math.floor(Math.abs(a)
11):a;a=Math.min(Math.max(a,0),m);for(var g=h(this)?Object(new this(a)):Array(a),b=0,e;b<a;)e=k[b],g[b]=d?"undefined"===typeof f?d(e,b):d.call(f,e,b):e,b+=1;g.length=a;return g}}());
12String.prototype.padStart||Object.defineProperty(String.prototype,"padStart",{value:function(b,a){b>>=0;a=String("undefined"!==typeof a?a:" ");if(this.length>b)return String(this);b-=this.length;b>a.length&&(a+=a.repeat(b/a.length));return a.slice(0,b)+String(this)}});
13String.prototype.includes||Object.defineProperty(String.prototype,"includes",{value:function(b,a){"number"!==typeof a&&(a=0);return a+b.length>this.length?!1:-1!==this.indexOf(b,a)}});
14
15(function(n){function i(a,d){this.setNotifyMethod(a);this.setNotifyContext(d)}function j(a,d,b){this.name=a;this.body=d;this.type=b}function k(){}function m(){}function l(){this.subCommands=[];this.initializeMacroCommand()}function g(a,d){this.mediatorName=a||this.constructor.NAME;this.viewComponent=d}function h(a,d){this.proxyName=a||this.constructor.NAME;null!=d&&this.setData(d)}function b(a){if(null!=b.instanceMap[a])throw Error(b.MULTITON_MSG);this.initializeNotifier(a);b.instanceMap[a]=this;
16this.initializeFacade()}function c(a){if(null!=c.instanceMap[a])throw Error(c.MULTITON_MSG);this.multitonKey=a;c.instanceMap[this.multitonKey]=this;this.mediatorMap=[];this.observerMap=[];this.initializeView()}function e(a){if(e.instanceMap[a])throw Error(e.MULTITON_MSG);this.multitonKey=a;e.instanceMap[a]=this;this.proxyMap=[];this.initializeModel()}function f(a){if(null!=f.instanceMap[a])throw Error(f.MULTITON_MSG);this.multitonKey=a;f.instanceMap[this.multitonKey]=this;this.commandMap=[];this.initializeController()}
17function p(a,d,b){for(var a=a.split("."),b=b||o.global,c,e,f=0,g=a.length;f<g;f++)c=b,e=a[f],b=null==b[e]?b[e]={}:b[e];return null==d?b:c[e]=d}null==n&&(n=window);if(!n.puremvc){i.prototype.setNotifyMethod=function(a){this.notify=a};i.prototype.setNotifyContext=function(a){this.context=a};i.prototype.getNotifyMethod=function(){return this.notify};i.prototype.getNotifyContext=function(){return this.context};i.prototype.notifyObserver=function(a){this.getNotifyMethod().call(this.getNotifyContext(),
18a)};i.prototype.compareNotifyContext=function(a){return a===this.context};i.prototype.notify=null;i.prototype.context=null;j.prototype.getName=function(){return this.name};j.prototype.setBody=function(a){this.body=a};j.prototype.getBody=function(){return this.body};j.prototype.setType=function(a){this.type=a};j.prototype.getType=function(){return this.type};j.prototype.toString=function(){var a="Notification Name: "+this.getName(),a=a+("\nBody:"+(null==this.body?"null":this.body.toString()));return a+=
19"\nType:"+(null==this.type?"null":this.type)};j.prototype.name=null;j.prototype.type=null;j.prototype.body=null;k.prototype.sendNotification=function(a,d,b){var c=this.getFacade();c&&c.sendNotification(a,d,b)};k.prototype.initializeNotifier=function(a){this.multitonKey=""+a;this.facade=this.getFacade()};k.prototype.getFacade=function(){if(null==this.multitonKey)throw Error(k.MULTITON_MSG);return b.getInstance(this.multitonKey)};k.prototype.multitonKey=null;k.MULTITON_MSG="multitonKey for this Notifier not yet initialized!";
20m.prototype=new k;m.prototype.constructor=m;m.prototype.execute=function(){};l.prototype=new k;l.prototype.constructor=l;l.prototype.subCommands=null;l.prototype.initializeMacroCommand=function(){};l.prototype.addSubCommand=function(a){this.subCommands.push(a)};l.prototype.execute=function(a){for(;0<this.subCommands.length;){var d=new (this.subCommands.shift());d.initializeNotifier(this.multitonKey);d.execute(a)}};g.NAME="Mediator";g.prototype=new k;g.prototype.constructor=g;g.prototype.getMediatorName=
21function(){return this.mediatorName};g.prototype.setViewComponent=function(a){this.viewComponent=a};g.prototype.getViewComponent=function(){return this.viewComponent};g.prototype.listNotificationInterests=function(){return[]};g.prototype.handleNotification=function(){};g.prototype.onRegister=function(){};g.prototype.onRemove=function(){};g.prototype.mediatorName=null;g.prototype.viewComponent=null;h.NAME="Proxy";h.prototype=new k;h.prototype.constructor=h;h.prototype.getProxyName=function(){return this.proxyName};
22h.prototype.setData=function(a){this.data=a};h.prototype.getData=function(){return this.data};
22h.prototype.onRegister=function(){};h.prototype.onRemove=function(){};h.prototype.proxyName=null;h.prototype.data=null;b.prototype.initializeFacade=function(){this.initializeModel();this.initializeController();this.initializeView()};b.getInstance=function(a){if(null==a)return null;null==b.instanceMap[a]&&(b.instanceMap[a]=new b(a));return b.instanceMap[a]};b.prototype.initializeController=function(){if(null==
23this.controller)this.controller=f.getInstance(this.multitonKey)};b.prototype.initializeModel=function(){if(null==this.model)this.model=e.getInstance(this.multitonKey)};b.prototype.initializeView=function(){if(null==this.view)this.view=c.getInstance(this.multitonKey)};b.prototype.registerCommand=function(a,d){this.controller.registerCommand(a,d)};b.prototype.removeCommand=function(a){this.controller.removeCommand(a)};b.prototype.hasCommand=function(a){return this.controller.hasCommand(a)};b.prototype.registerProxy=
24function(a){this.model.registerProxy(a)};b.prototype.retrieveProxy=function(a){return this.model.retrieveProxy(a)};b.prototype.removeProxy=function(a){var d=null;null!=this.model&&(d=this.model.removeProxy(a));return d};b.prototype.hasProxy=function(a){return this.model.hasProxy(a)};b.prototype.registerMediator=function(a){null!=this.view&&this.view.registerMediator(a)};b.prototype.retrieveMediator=function(a){return this.view.retrieveMediator(a)};b.prototype.removeMediator=function(a){var d=null;
25null!=this.view&&(d=this.view.removeMediator(a));return d};b.prototype.hasMediator=function(a){return this.view.hasMediator(a)};b.prototype.sendNotification=function(a,d,b){this.notifyObservers(new j(a,d,b))};b.prototype.notifyObservers=function(a){null!=this.view&&this.view.notifyObservers(a)};b.prototype.initializeNotifier=function(a){this.multitonKey=a};b.hasCore=function(a){return null!=b.instanceMap[a]};b.removeCore=function(a){null!=b.instanceMap[a]&&(e.removeModel(a),c.removeView(a),f.removeController(a),
26delete b.instanceMap[a])};b.prototype.controller=null;b.prototype.model=null;b.prototype.view=null;b.prototype.multitonKey=null;b.instanceMap=[];b.MULTITON_MSG="Facade instance for this Multiton key already constructed!";c.prototype.initializeView=function(){};c.getInstance=function(a){if(null==a)return null;null==c.instanceMap[a]&&(c.instanceMap[a]=new c(a));return c.instanceMap[a]};c.prototype.registerObserver=function(a,d){null!=this.observerMap[a]?this.observerMap[a].push(d):this.observerMap[a]=
27[d]};c.prototype.notifyObservers=function(a){if(null!=this.observerMap[a.getName()]){for(var d=this.observerMap[a.getName()],b=[],c,e=0;e<d.length;e++)c=d[e],b.push(c);for(e=0;e<b.length;e++)c=b[e],c.notifyObserver(a)}};c.prototype.removeObserver=function(a,d){for(var b=this.observerMap[a],c=0;c<b.length;c++)if(!0==b[c].compareNotifyContext(d)){b.splice(c,1);break}0==b.length&&delete this.observerMap[a]};c.prototype.registerMediator=function(a){if(null==this.mediatorMap[a.getMediatorName()]){a.initializeNotifier(this.multitonKey);
28this.mediatorMap[a.getMediatorName()]=a;var d=a.listNotificationInterests();if(0<d.length)for(var b=new i(a.handleNotification,a),c=0;c<d.length;c++)this.registerObserver(d[c],b);a.onRegister()}};c.prototype.retrieveMediator=function(a){return this.mediatorMap[a]};c.prototype.removeMediator=function(a){var d=this.mediatorMap[a];if(d){for(var b=d.listNotificationInterests(),c=0;c<b.length;c++)this.removeObserver(b[c],d);delete this.mediatorMap[a];d.onRemove()}return d};c.prototype.hasMediator=function(a){return null!=
29this.mediatorMap[a]};c.removeView=function(a){delete c.instanceMap[a]};c.prototype.mediatorMap=null;c.prototype.observerMap=null;c.instanceMap=[];c.prototype.multitonKey=null;c.MULTITON_MSG="View instance for this Multiton key already constructed!";e.prototype.initializeModel=function(){};e.getInstance=function(a){if(null==a)return null;null==e.instanceMap[a]&&(e.instanceMap[a]=new e(a));return e.instanceMap[a]};e.prototype.registerProxy=function(a){a.initializeNotifier(this.multitonKey);this.proxyMap[a.getProxyName()]=
30a;a.onRegister()};e.prototype.retrieveProxy=function(a){return this.proxyMap[a]};e.prototype.hasProxy=function(a){return null!=this.proxyMap[a]};e.prototype.removeProxy=function(a){var b=this.proxyMap[a];b&&(this.proxyMap[a]=null,b.onRemove());return b};e.removeModel=function(a){delete e.instanceMap[a]};e.prototype.proxyMap=null;e.instanceMap=[];e.MULTITON_MSG="Model instance for this Multiton key already constructed!";f.prototype.initializeController=function(){this.view=c.getInstance(this.multitonKey)};
31f.getInstance=function(a){if(null==a)return null;null==this.instanceMap[a]&&(this.instanceMap[a]=new this(a));return this.instanceMap[a]};f.prototype.executeCommand=function(a){var b=this.commandMap[a.getName()];null!=b&&(b=new b,b.initializeNotifier(this.multitonKey),b.execute(a))};f.prototype.registerCommand=function(a,b){null==this.commandMap[a]&&this.view.registerObserver(a,new i(this.executeCommand,this));this.commandMap[a]=b};f.prototype.hasCommand=function(a){return null!=this.commandMap[a]};
32f.prototype.removeCommand=function(a){this.hasCommand(a)&&(this.view.removeObserver(a,this),this.commandMap[a]=null)};f.removeController=function(a){delete this.instanceMap[a]};f.prototype.view=null;f.prototype.commandMap=null;f.prototype.multitonKey=null;f.instanceMap=[];f.MULTITON_MSG="controller key for this Multiton key already constructed";var o={global:function(){return this}(),extend:function(a,b){if("function"!==typeof a)throw new TypeError("#extend- child should be Function");if("function"!==
33typeof b)throw new TypeError("#extend- parent should be Function");if(b!==a){var c=new Function;c.prototype=b.prototype;a.prototype=new c;return a.prototype.constructor=a}},decorate:function(a,b){for(var c in b)a[c]=b[c];return a}};n.puremvc={View:c,Model:e,Controller:f,SimpleCommand:m,MacroCommand:l,Facade:b,Mediator:g,Observer:i,Notification:j,Notifier:k,Proxy:h,define:function(a,b,c){a||(a={});var e=a.name,f=a.parent,g="function"===typeof f,h=a.scope||null;if("parent"in a&&!g)throw new TypeError("Class parent must be Function");
34if(a.hasOwnProperty("constructor")){if(a=a.constructor,"function"!==typeof a)throw new TypeError("Class constructor must be Function");}else a=g?function(){f.apply(this,arguments)}:new Function;g&&o.extend(a,f);if(b)g=a.prototype,o.decorate(g,b),g.constructor=a;c&&o.decorate(a,c);if(e){if("string"!==typeof e)throw new TypeError("Class name must be primitive string");p(e,a,h)}return a},declare:p}}})(this);
35/*!
36 * Bowser - a browser detector
37 * https://github.com/ded/bowser
38 * MIT License | (c) Dustin Diaz 2015
39 */
40!function(e,t,n){typeof module!="undefined"&&module.exports?module.exports=n():typeof define=="function"&&define.amd?define(t,n):e[t]=n()}(this,"bowser",function(){function t(t){function n(e){var n=t.match(e);return n&&n.length>1&&n[1]||""}function r(e){var n=t.match(e);return n&&n.length>1&&n[2]||""}function N(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return undefined}}var i=n(/(ipod|iphone|ipad)/i).toLowerCase(),s=/like android/i.test(t),o=!s&&/android/i.test(t),u=/nexus\s*[0-6]\s*/i.test(t),a=!u&&/nexus\s*[0-9]+/i.test(t),f=/CrOS/.test(t),l=/silk/i.test(t),c=/sailfish/i.test(t),h=/tizen/i.test(t),p=/(web|hpw)os/i.test(t),d=/windows phone/i.test(t),v=/SamsungBrowser/i.test(t),m=!d&&/windows/i.test(t),g=!i&&!l&&/macintosh/i.test(t),y=!o&&!c&&!h&&!p&&/linux/i.test(t),b=r(/edg([ea]|ios)\/(\d+(\.\d+)?)/i),w=n(/version\/(\d+(\.\d+)?)/i),E=/tablet/i.test(t)&&!/tablet pc/i.test(t),S=!E&&/[^-]mobi/i.test(t),x=/xbox/i.test(t),T;/opera/i.test(t)?T={name:"Opera",opera:e,version:w||n(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)}:/opr\/|opios/i.test(t)?T={name:"Opera",opera:e,version:n(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i)||w}:/SamsungBrowser/i.test(t)?T={name:"Samsung Internet for Android",samsungBrowser:e,version:w||n(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)}:/coast/i.test(t)?T={name:"Opera Coast",coast:e,version:w||n(/(?:coast)[\s\/](\d+(\.\d+)?)/i)}:/yabrowser/i.test(t)?T={name:"Yandex Browser",yandexbrowser:e,version:w||n(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:/ucbrowser/i.test(t)?T={name:"UC Browser",ucbrowser:e,version:n(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/mxios/i.test(t)?T={name:"Maxthon",maxthon:e,version:n(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)}:/epiphany/i.test(t)?T={name:"Epiphany",epiphany:e,version:n(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)}:/puffin/i.test(t)?T={name:"Puffin",puffin:e,version:n(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)}:/sleipnir/i.test(t)?T={name:"Sleipnir",sleipnir:e,version:n(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)}:/k-meleon/i.test(t)?T={name:"K-Meleon",kMeleon:e,version:n(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)}:d?(T={name:"Windows Phone",osname:"Windows Phone",windowsphone:e},b?(T.msedge=e,T.version=b):(T.msie=e,T.version=n(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?T={name:"Internet Explorer",msie:e,version:n(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:f?T={name:"Chrome",osname:"Chrome OS",chromeos:e,chromeBook:e,chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/edg([ea]|ios)/i.test(t)?T={name:"Microsoft Edge",msedge:e,version:b}:/vivaldi/i.test(t)?T={name:"Vivaldi",vivaldi:e,version:n(/vivaldi\/(\d+(\.\d+)?)/i)||w}:c?T={name:"Sailfish",osname:"Sailfish OS",sailfish:e,version:n(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?T={name:"SeaMonkey",seamonkey:e,version:n(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel|fxios/i.test(t)?(T={name:"Firefox",firefox:e,version:n(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(T.firefoxos=e,T.osname="Firefox OS")):l?T={name:"Amazon Silk",silk:e,version:n(/silk\/(\d+(\.\d+)?)/i)}:/phantom/i.test(t)?T={name:"PhantomJS",phantom:e,version:n(/phantomjs\/(\d+(\.\d+)?)/i)}:/slimerjs/i.test(t)?T={name:"SlimerJS",slimer:e,version:n(/slimerjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?T={name:"BlackBerry",osname:"BlackBerry OS",blackberry:e,version:w||n(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:p?(T={name:"WebOS",osname:"WebOS",webos:e,version:w||n(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(T.touchpad=e)):/bada/i.test(t)?T={name:"Bada",osname:"Bada",bada:e,version:n(/dolfin\/(\d+(\.\d+)?)/i)}:h?T={name:"Tizen",osname:"Tizen",tizen:e,version:n(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||w}:/qupzilla/i.test(t)?T={name:"QupZilla",qupzilla:e,version:n(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i)||w}:/chromium/i.test(t)?T={name:"Chromium",chromium:e,version:n(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i)||w}:/chrome|crios|crmo/i.test(t)?T={name:"Chrome",chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:o?T={name:"Android",version:w}:/safari|applewebkit/i.test(t)?(T={name:"Safari",safari:e},w&&(T.version=w)):i?(T={name:i=="iphone"?"iPhone":i=="ipad"?"iPad":"iPod"},w&&(T.version=w)):/googlebot/i.test(t)?T={name:"Googlebot",googlebot:e,version:n(/googlebot\/(\d+(\.\d+))/i)||w}:T={name:n(/^(.*)\/(.*) /),version:r(/^(.*)\/(.*) /)},!T.msedge&&/(apple)?webkit/i.test(t)?(/(apple)?webkit\/537\.36/i.test(t)?(T.name=T.name||"Blink",T.blink=e):(T.name=T.name||"Webkit",T.webkit=e),!T.version&&w&&(T.version=w)):!T.opera&&/gecko\//i.test(t)&&(T.name=T.name||"Gecko",T.gecko=e,T.version=T.version||n(/gecko\/(\d+(\.\d+)?)/i)),!T.windowsphone&&(o||T.silk)?(T.android=e,T.osname="Android"):!T.windowsphone&&i?(T[i]=e,T.ios=e,T.osname="iOS"):g?(T.mac=e,T.osname="macOS"):x?(T.xbox=e,T.osname="Xbox"):m?(T.windows=e,T.osname="Windows"):y&&(T.linux=e,T.osname="Linux");var C="";T.windows?C=N(n(/Windows ((NT|XP)( \d\d?.\d)?)/i)):T.windowsphone?C=n(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):T.mac?(C=n(/Mac OS X (\d+([_\.\s]\d+)*)/i),C=C.replace(/[_\s]/g,".")):i?(C=n(/os (\d+([_\s]\d+)*) like mac os x/i),C=C.replace(/[_\s]/g,".")):o?C=n(/android[ \/-](\d+(\.\d+)*)/i):T.webos?C=n(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):T.blackberry?C=n(/rim\stablet\sos\s(\d+(\.\d+)*)/i):T.bada?C=n(/bada\/(\d+(\.\d+)*)/i):T.tizen&&(C=n(/tizen[\/\s](\d+(\.\d+)*)/i)),C&&(T.osversion=C);var k=!T.windows&&C.split(".")[0];if(E||a||i=="ipad"||o&&(k==3||k>=4&&!S)||T.silk)T.tablet=e;else if(S||i=="iphone"||i=="ipod"||o||u||T.blackberry||T.webos||T.bada)T.mobile=e;return T.msedge||T.msie&&T.version>=10||T.yandexbrowser&&T.version>
40=15||T.vivaldi&&T.version>=1||T.chrome&&T.version>=20||T.samsungBrowser&&T.version>=4||T.firefox&&T.version>=20||T.safari&&T.version>=6||T.opera&&T.version>=10||T.ios&&T.osversion&&T.osversion.split(".")[0]>=6||T.blackberry&&T.version>=10.1||T.chromium&&T.version>=20?T.a=e:T.msie&&T.version<10||T.chrome&&T.version<20||T.firefox&&T.version<20||T.safari&&T.version<6||T.opera&&T.version<10||T.ios&&T.osversion&&T.osversion.split(".")[0]<6||T.chromium&&T.version<20?T.c=e:T.x=e,T}function r(e){return e.split(".").length}function i(e,t){var n=[],r;if(Array.prototype.map)return Array.prototype.map.call(e,t);for(r=0;r<e.length;r++)n.push(t(e[r]));return n}function s(e){var t=Math.max(r(e[0]),r(e[1])),n=i(e,function(e){var n=t-r(e);return e+=(new Array(n+1)).join(".0"),i(e.split("."),function(e){return(new Array(20-e.length)).join("0")+e}).reverse()});while(--t>=0){if(n[0][t]>n[1][t])return 1;if(n[0][t]!==n[1][t])return-1;if(t===0)return 0}}function o(e,r,i){var o=n;typeof r=="string"&&(i=r,r=void 0),r===void 0&&(r=!1),i&&(o=t(i));var u=""+o.version;for(var a in e)if(e.hasOwnProperty(a)&&o[a]){if(typeof e[a]!="string")throw new Error("Browser version in the minVersion map should be a string: "+a+": "+String(e));return s([u,e[a]])<0}return r}function u(e,t,n){return!o(e,t,n)}var e=!0,n=t(typeof navigator!="undefined"?navigator.userAgent||"":"");return n.test=function(e){for(var t=0;t<e.length;++t){var r=e[t];if(typeof r=="string"&&r in n)return!0}return!1},n.isUnsupportedBrowser=o,n.compareVersions=s,n.check=u,n._detect=t,n.detect=t,n});
41
42var akamai = (function () {
43  'use strict';
44
45  var AMPError = /*#__PURE__*/function (_Error) {
46    babelHelpers.inherits(AMPError, _Error);
47    function AMPError(message) {
48      var _this;
49      var code = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
50      var metadata = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
51      babelHelpers.classCallCheck(this, AMPError);
52      _this = _Error.call(this) || this;
53      _this.code = code;
54      _this.metadata = metadata;
55      if (message instanceof AMPError) {
56        return babelHelpers.possibleConstructorReturn(_this, message);
57      }
58      if (babelHelpers["typeof"](message) === "object") {
59        _this.metadata = message.metadata || message;
60        _this.message = message.message || (typeof message.toString === "function" ? message.toString() : void 0);
61        if (message.code) {
62          _this.code = message.code;
63        }
64      } else {
65        _this.message = message;
66      }
67      return _this;
68    }
69    babelHelpers.createClass(AMPError, null, [{
70      key: "create",
71      value: function create(message, code, metadata) {
72        return new AMPError(message, code, metadata);
73      }
74    }]);
75    return AMPError;
76  }( /*#__PURE__*/babelHelpers.wrapNativeSuper(Error));
77
78  // fp utils
79  var _pipe = function _pipe(f, g) {
80    return function () {
81      return f(g.apply(void 0, arguments));
82    };
83  };
84  var pipe = function pipe() {
85    for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
86      fns[_key] = arguments[_key];
87    }
88    return fns.reduce(_pipe);
89  };
90  var DONE = "__DONE__"; //Symbol("DONE")
91
92  var each = function each(obj, func) {
93    if (obj == null || typeof func != "function") return;
94    if (obj.length != undefined) {
95      for (var i = 0, len = obj.length; i < len; i++) {
96        if (func(obj[i], i, obj) === DONE) return;
97      }
98    } else {
99      for (var key in obj) {
100        if (func(obj[key], key, obj) === DONE) return;
101      }
102    }
103  };
104
105  // reduction utils
106  var concat = function concat() {
107    return function (acc, value) {
108      return acc.push(value), acc;
109    };
110  };
111  var nop = function nop() {
112    return function (acc, value) {
113      return value;
114    };
115  };
116
117  // reducers
118  var map = function map(fn) {
119    return function (reducing) {
120      return function (result, input, done) {
121        return reducing(result, fn(input, done), done);
122      };
123    };
124  };
125  var filter = function filter(fn) {
126    return function (reducing) {
127      return function (result, input, done) {
128        return fn(input, done) ? reducing(result, input, done) : result;
129      };
130    };
131  };
132  var tap = function tap(fn) {
133    return function (reducing) {
134      return function (result, input, done) {
135        return fn(input, done), reducing(result, input, done);
136      };
137    };
138  };
139  var until = function until(fn) {
140    return function (reducing) {
141      return function (result, input, done) {
142        return fn(input, done) ? reducing(result, input, done) : (done(), result);
143      };
144    };
145  };
146  var take = function take(num) {
147    var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : num;
148    return function (reducing) {
149      return function (result, input, done) {
150        return --i > 0 ? reducing(result, input, done) : (i = num, done(), reducing(result, input, done));
151      };
152    };
153  };
154
155  // transduce
156  var transduce = function transduce(xform, reducing, acc, input) {
157    var reducer = xform(reducing);
158    var done = function done() {
159      return _done = true;
160    };
161    var _done = false;
162    each(input, function (item) {
163      if (_done) return DONE;
164      acc = reducer(acc, item, done);
165    });
166    return acc;
167  };
168  var into = function into(to, xform, from) {
169    return transduce(xform, concat(), to, from);
170  };
171  var seq = function seq(xform, input) {
172    return into([], xform, input);
173  };
174  var transform = function transform(input) {
175    for (var _len2 = arguments.length, xfs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
176      xfs[_key2 - 1] = arguments[_key2];
177    }
178    return seq(pipe.apply(void 0, xfs), input);
179  };
180  var find = function find(input) {
181    var result = null;
182    for (var _len3 = arguments.length, xfs = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
183      xfs[_key3 - 1] = arguments[_key3];
184    }
185    var reducer = pipe.apply(void 0, xfs)(nop());
186    each(input, function (item) {
187      result = reducer(null, item);
188      if (result) return DONE;
189    });
190    return result;
191  };
192  var fp = {
193    pipe: pipe,
194    map: map,
195    filter: filter,
196    tap: tap,
197    take: take,
198    until: until,
199    each: each,
200    DONE: DONE,
201    transform: transform,
202    find: find
203  };
204
205  var Event = /*#__PURE__*/function () {
206    /**
207     * Event constructor.
208     *
209     * @param {!string}  type  A string representing the event's type.
210     * @param {Object=} detail  Data to pass along with the event.
211     * @constructor
212     * @private
213     */
214    function Event(type) {
215      var detail = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
216      babelHelpers.classCallCheck(this, Event);
217      this.type = type;
218      this.detail = this.data = detail;
219      this.target = null;
220    }
221
222    /**
223     * Create an event
224     *
225     * @param {!string}  type  A string representing the event's type.
226     * @param {Object=} detail  Data to pass along with the event.
227     * @return {Event}
228     */
229    babelHelpers.createClass(Event, null, [{
230      key: "create",
231      value: function create(type, detail) {
232        return new Event(type, detail);
233      }
234    }]);
235    return Event;
236  }();
237
238  var EventDispatcher = /*#__PURE__*/function () {
239    /**
240     * Creates a new EventDispatcher
241     *
242     * @constructor
243     * @private
244     * @implements {IEventDispatcher}
245     */
246    function EventDispatcher() {
247      var _target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this;
248      babelHelpers.classCallCheck(this, EventDispatcher);
249      this._target = _target;
250      this._listenerMap = {};
251      this._regex = [];
252      this.emit = this.dispatch.bind(this);
253      this.on = this.addListener = this.addEventListener.bind(this);
254      this.off = this.removeListener = this.removeEventListener.bind(this);
255    }
256
257    /**
258     * Creates a new EventDispatcher
259     *
260     * @param {Object} target
261     *  The event dispatcher target
262     *
263     * @return {EventDispatcher}
264     */
265    babelHelpers.createClass(EventDispatcher, [{
266      key: "addEventListener",
267      value:
268      /**
269       * Adds a listener for a given event type.
270       *
271       * @param {!string}  type  A string representing the event's type.
272       * @param {!Function} func  A function to call when the event is triggered.
273       */
274      function addEventListener(type, func) {
275        if (func == null || type == null) {
276          return;
277        }
278        if (type instanceof RegExp) {
279          func.__regex = type;
280          this._regex.push(func);
281        } else {
282          if (this._listenerMap[type] == null) {
283            this._listenerMap[type] = [];
284          }
285          if (this._listenerMap[type].indexOf(func) !== -1) {
286            return;
287          }
288          this._listenerMap[type].push(func);
289        }
290      }
291
292      /**
293       * Adds a listener for a given event type and removes it after it has been triggered once.
294       */
295    }, {
296      key: "once",
297      value: function once(type, func) {
298        func.__once = true;
299        this.addEventListener(type, func);
300      }
301
302      /**
303       * Dispathes an event, triggering all event listener of the event's type.
304       *
305       * @param {!IEvent} event The event to dispatch.
306       */
307    }, {
308      key: "dispatchEvent",
309      value: function dispatchEvent(event) {
310        if (this._target == null && this._listenerMap == null) return;
311        if (event.target == null && babelHelpers["typeof"](event) === 'object') event.target = this._target;
312        var type = event.type;
313        var target = this._target;
314        var listener = target["on" + type];
315        if (listener != null) {
316          listener.apply(target, [event]);
317        }
318        var listeners = this._listenerMap[type];
319        if (listeners && listeners.length > 0) {
320          var copy = listeners.slice();
321          fp.each(copy, function (listener) {
322            listener.call(target, event);
323            if (listener.__once === true) {
324              var index = listeners.indexOf(listener);
325              if (index === -1) return;
326              listeners.splice(index, 1);
327            }
328          });
329        }
330        listeners = this._regex;
331        if (listeners.length > 0) {
332          var _copy = listeners.slice();
333          for (var i = 0, len = _copy.length; i < len; ++i) {
334            listener = _copy[i];
335            if (listener.__regex.test(type) == false) {
336              continue;
337            }
338            listener.call(target, event);
339            if (listener.__once === true) {
340              listeners.splice(i, 1);
341            }
342          }
343        }
344      }
345
346      /**
347       * Dispathes an event, triggering all event listener of the event's type.
348       *
349       * @param {!String} type    The type of event to dispatch.
350       * @param {Object=} detail  Data to pass along with the event.
351       */
352    }, {
353      key: "dispatch",
354      value: function dispatch(type, detail) {
355        this.dispatchEvent(Event.create(type, detail));
356      }
357
358      /**
359       * Removes a listener for a given event type.
360       *
361       * @param {!string}  type  A string representing the event's type.
362       * @param {!Function} func  A function to call when the event is triggered.
363       * @return {?Function} the handler that was removed if any
364       */
365    }, {
366      key: "removeEventListener",
367      value: function removeEventListener(type, func) {
368        if (func == null || type == null) {
369          return;
370        }
371        var regexp = type instanceof RegExp;
372        var listeners = regexp ? this._regex : this._listenerMap[type];
373        if (listeners == null) {
374          return;
375        }
376        var index = listeners.indexOf(func);
377        if (index === -1) {
378          return;
379        }
380        if (regexp && type.toString() !== listeners[index].__regex.toString()) {
381          return;
382        }
383        return listeners.splice(index, 1);
384      }
385
386      /**
387       * Destroys the EventDispatcher
388       */
389    }, {
390      key: "destroy",
391      value: function destroy() {
392        this._listenerMap = null;
393        this._target = null;
394      }
395    }], [{
396      key: "create",
397      value: function create(target) {
398        return new EventDispatcher(target);
399      }
400    }]);
401    return EventDispatcher;
402  }();
403
404  var Timer = /*#__PURE__*/function (_EventDispatcher) {
405    babelHelpers.inherits(Timer, _EventDispatcher);
406    /**
407     * Constructs a new Timer object with the specified delay and repeatCount states.
408     */
409    function Timer(delay) {
410      var _this;
411      var repeatCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
412      var timeoutSet = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : setTimeout;
413      var timeoutClear = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : clearTimeout;
414      babelHelpers.classCallCheck(this, Timer);
415      _this = _EventDispatcher.call(this) || this;
416      _this.delay = delay;
417      _this.repeatCount = repeatCount;
418      _this.timerGroup = timerGroup;
419      _this._running = false;
420      _this._currentCount = 0;
421      _this._timeout = null;
422      _this._startTime = null;
423      _this._currentTime = 0;
424      _this.setTimeout = timeoutSet;
425      _this.clearTimeout = timeoutClear;
426      _this.next = function () {
427        var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.delay;
428        return _this.setTimeout(function () {
429          return _this.tick();
430        }, delay);
431      };
432      _this.clear = function () {
433        return _this.clearTimeout(_this._timeout);
434      };
435      return _this;
436    }
437
438    /**
439     * The timer event. Called on every iteration of the timer.
440     *
441     * @static
442     * @type {string}
443     */
444    babelHelpers.createClass(Timer, [{
445      key: "currentCount",
446      get:
447      /**
448       *
449       */
450      function get() {
451        return this._currentCount;
452      }
453
454      /**
455       *
456       */
457    }, {
458      key: "running",
459      get: function get() {
460        return this._running;
461      }
462
463      /**
464       *
465       */
466    }, {
467      key: "time",
468      get: function get() {
469        return this._currentTime + (Date.now() - this._startTime);
470      }
471
472      /**
473       * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch.
474       */
475    }, {
476      key: "reset",
477      value: function reset() {
478        this.stop();
479        this._currentCount = 0;
480        this._currentTime = 0;
481        this._startTime = null;
482      }
483
484      /**
485       * Starts the timer, if it is not already running.
486       */
487    }, {
488      key: "start",
489      value: function start() {
490        if (this._running === true) {
491          return;
492        }
493        var delay = this.delay - (this._currentTime - this.delay * this._currentCount);
494        this._running = true;
495        this._timeout = this.next(delay);
496      }
497
498      /**
499       * Stops the timer.
500       */
501    }, {
502      key: "stop",
503      value: function stop() {
504        if (this._running === false) {
505          return;
506        }
507        this.clear();
508        this._currentTime += Date.now() - this._startTime;
509        this._timeout = null;
510        this._running = false;
511      }
512
513      /**
514       *
515       */
516    }, {
517      key: "tick",
518      value: function tick() {
519        this.clear();
520        var complete = this.repeatCount !== 0 && this._currentCount >= this.repeatCount;
521        this._currentCount++;
522        this._currentTime += this.delay;
523        this._startTime = Date.now();
524        if (complete === false) {
525          this._timeout = this.next(this.delay);
526        }
527        this.dispatch(Timer.TIMER, this);
528        if (complete === true) {
529          this.stop();
530          this.dispatch(Timer.COMPLETE, this);
531        }
532      }
533
534      /**
535       *
536       */
537    }, {
538      key: "destroy",
539      value: function destroy() {
540        this.clear();
541        babelHelpers.get(babelHelpers.getPrototypeOf(Timer.prototype), "destroy", this).call(this);
542        this.next = null;
543      }
544    }], [{
545      key: "TIMER",
546      get: function get() {
547        return "timer";
548      }
549
550      /**
551       * The complete event. Called when timer reaches repeat count.
552       *
553       * @static
554       * @type {string}
555       */
556    }, {
557      key: "COMPLETE",
558      get: function get() {
559        return "complete";
560      }
561
562      /**
563       * Create a new Timer instance
564       *
565       * @param {number} delay
566       * @param {number} repeatCount
567       * @return {Timer}
568       */
569    }, {
570      key: "create",
571      value: function create(delay, repeatCount, timeoutSet, timeoutClear) {
572        return new Timer(delay, repeatCount, timeoutSet, timeoutClear);
573      }
574    }]);
575    return Timer;
576  }(EventDispatcher);
577
578  var TimerGroup = /*#__PURE__*/function () {
579    /**
580     *
581     */
582    function TimerGroup(id) {
583      babelHelpers.classCallCheck(this, TimerGroup);
584      this.id = id;
585      this.intervals = [];
586      this.timeouts = [];
587      this.timers = [];
588      this.groups = [];
589    }
590
591    /**
592     *
593     */
594    babelHelpers.createClass(TimerGroup, [{
595      key: "setTimeout",
596      value: function (_setTimeout) {
597        function setTimeout(_x, _x2) {
598          return _setTimeout.apply(this, arguments);
599        }
600        setTimeout.toString = function () {
601          return _setTimeout.toString();
602        };
603        return setTimeout;
604      }(
605      /**
606       *
607       */
608      function (func, interval) {
609        var _this = this;
610        for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
611          args[_key - 2] = arguments[_key];
612        }
613        var id = setTimeout(function () {
614          func.apply(null, args);
615          _this.clearTimeout(id);
616        }, interval);
617        this.timeouts.push(id);
618        return id;
619      }
620
621      /**
622       *
623       */)
624    }, {
625      key: "clearTimeout",
626      value: function (_clearTimeout) {
627        function clearTimeout(_x3) {
628          return _clearTimeout.apply(this, arguments);
629        }
630        clearTimeout.toString = function () {
631          return _clearTimeout.toString();
632        };
633        return clearTimeout;
634      }(function (id) {
635        var index = this.timeouts.indexOf(id);
636        if (index !== -1) {
637          this.timeouts.splice(index, 1);
638        }
639        return clearTimeout(id);
640      }
641
642      /**
643       *
644       */)
645    }, {
646      key: "setInterval",
647      value: function (_setInterval) {
648        function setInterval() {
649          return _setInterval.apply(this, arguments);
650        }
651        setInterval.toString = function () {
652          return _setInterval.toString();
653        };
654        return setInterval;
655      }(function () {
656        for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
657          args[_key2] = arguments[_key2];
658        }
659        var id = setInterval.apply(null, args);
660        this.intervals.push(id);
661        return id;
662      }
663
664      /**
665       *
666       */)
667    }, {
668      key: "clearInterval",
669      value: function (_clearInterval) {
670        function clearInterval(_x4) {
671          return _clearInterval.apply(this, arguments);
672        }
673        clearInterval.toString = function () {
674          return _clearInterval.toString();
675        };
676        return clearInterval;
677      }(function (id) {
678        var index = this.intervals.indexOf(id);
679        if (index !== -1) {
680          this.intervals.splice(index, 1);
681        }
682        return clearInterval(id);
683      }
684
685      /**
686       *
687       */)
688    }, {
689      key: "setImmediate",
690      value: function setImmediate(func) {
691        var _this2 = this;
692        for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
693          args[_key3 - 1] = arguments[_key3];
694        }
695        var id = setTimeout(function () {
696          func.apply(null, args);
697          _this2.clearImmediate(id);
698        }, 0);
699        this.timeouts.push(id);
700        return id;
701      }
702
703      /**
704       *
705       */
706    }, {
707      key: "clearImmediate",
708      value: function clearImmediate(id) {
709        var index = this.timeouts.indexOf(id);
710        if (index !== -1) {
711          this.timeouts.splice(index, 1);
712        }
713        return clearTimeout(id);
714      }
715
716      /**
717       *
718       */
719    }, {
720      key: "setTimer",
721      value: function setTimer(delay, repeatCount) {
722        var timer = Timer.create(delay, repeatCount, this.setTimeout.bind(this), this.clearTimeout.bind(this));
723        this.timers.push(timer);
724        return timer;
725      }
726
727      /**
728       *
729       */
730    }, {
731      key: "clearTimer",
732      value: function clearTimer(timer) {
733        var index = this.timers.indexOf(timer);
734        if (index !== -1) {
735          timer = this.timers.splice(index, 1);
736          timer.destroy();
737        }
738      }
739
740      /**
741       *
742       */
743    }, {
744      key: "setGroup",
745      value: function setGroup(id) {
746        var group = TimerGroup.create(id);
747        this.groups.push(group);
748        return group;
749      }
750
751      /**
752       *
753       */
754    }, {
755      key: "clearGroup",
756      value: function clearGroup(id) {
757        var index = this.groups.indexOf(timer);
758        if (index !== -1) {
759          var group = this.groups.splice(index, 1);
760          group.destroy();
761        }
762      }
763
764      /**
765       * @override
766       */
767    }, {
768      key: "destroy",
769      value: function destroy() {
770        this.intervals.forEach(function (id) {
771          return clearInterval(id);
772        });
773        this.timeouts.forEach(function (id) {
774          return clearTimeout(id);
775        });
776        this.timers.forEach(function (id) {
777          return id.destroy();
778        });
779        this.groups.forEach(function (id) {
780          return id.destroy();
781        });
782        this.id = null;
783        this.intervals = null;
784        this.timeouts = null;
785        this.timers = null;
786        this.groups = null;
787      }
788    }], [{
789      key: "create",
790      value: function create(id) {
791        return new TimerGroup(id);
792      }
793    }]);
794    return TimerGroup;
795  }();
796
797  var QueryString = /*#__PURE__*/function () {
798    function QueryString() {
799      babelHelpers.classCallCheck(this, QueryString);
800    }
801    babelHelpers.createClass(QueryString, null, [{
802      key: "construct",
803      value: function construct() {
804        var _this = this;
805        var search = window.location.search;
806        var vars = this.decode(search);
807        QueryString.typed = {};
808        QueryString.amp = {};
809        var amp = /^amp(_|-)/;
810        fp.each(vars, function (value, key) {
811          QueryString[key] = value;
812          var parsed = _this.parse(value);
813          QueryString.typed[key] = parsed;
814          if (amp.test(key)) {
815            QueryString.amp[Utils.toCamelCase(key.replace(amp, ""))] = parsed;
816          }
817        });
818        return true;
819      }
820    }, {
821      key: "encode",
822      value: function encode(obj, prefix) {
823        var _this2 = this;
824        var str = [];
825        fp.each(obj, function (v, p) {
826          if (v == null) {
827            return;
828          }
829          var k = prefix ? prefix + "[" + p + "]" : p;
830          str.push(babelHelpers["typeof"](v) === "object" ? _this2.encode(v, k) : k + "=" + encodeURIComponent(v));
831        });
832        return str.join("&");
833      }
834    }, {
835      key: "decode",
836      value: function decode(uri) {
837        var _this3 = this;
838        var results;
839        if (/__proto__|prototype|constructor/.test(uri)) return;
840        if (uri != null) {
841          results = {};
842          uri = uri.replace(/^[^?]*\?/, "");
843          uri.replace(new RegExp("([^?=&]+)(\=([^&]+))", "g"), function ($0, $1, $2, $3) {
844            var key = decodeURIComponent($1);
845            var value = decodeURIComponent($3);
846            if (/~/.test(value)) {
847              value = _this3.decodeObject(value);
848            }
849            if (/\[/.test(key)) {
850              var obj = key.match(/[^\[]+/)[0];
851              key = key.match(/\[([A-Za-z]+)\]/)[1];
852              if (results[obj] == null) {
853                results[obj] = {};
854              }
855              results[obj][key] = value;
856              return;
857            }
858            results[key] = value;
859          });
860        }
861        return results;
862      }
863    }, {
864      key: "decodeObject",
865      value: function decodeObject(uri) {
866        var _this4 = this;
867        var results;
868        if (uri != null) {
869          results = {};
870          uri.replace(/([^:~]+)(:([^~]*))?/g, function ($0, $1, $2, $3) {
871            results[decodeURIComponent($1)] = _this4.parse(decodeURIComponent($3));
872          });
873        }
874        return results;
875      }
876    }, {
877      key: "parse",
878      value: function parse(value) {
879        if (babelHelpers["typeof"](value) === "object") {
880          return value;
881        }
882        if (value === "undefined") {
883          return true;
884        }
885        var temp = value.toLowerCase();
886        if (temp === "true" || temp === "false") {
887          return temp === "true";
888        }
889        if (temp === "null") {
890          return null;
891        }
892        temp = parseFloat(value);
893        if (!isNaN(temp)) {
894          return temp;
895        }
896        try {
897          temp = JSON.parse(value);
898          return temp;
899        } catch (error) {
900          return value;
901        }
902      }
903    }]);
904    return QueryString;
905  }();
906
907  var URL = /*#__PURE__*/function () {
908    /**
909     *
910     */
911    function URL(obj) {
912      babelHelpers.classCallCheck(this, URL);
913      this._url = typeof obj === "string" ? obj : obj.url;
914      this._method = obj.method || "GET";
915      this._withCredentials = obj.withCredentials || false;
916      this._headers = obj.headers || {};
917      this._data = obj.data || obj.body || {};
918      this._responseType = obj.responseType;
919      this._query = obj.query;
920      if (obj.query != null) {
921        var sep = /\?/.test(this._url) ? "&" : "?";
922        this._url += sep + QueryString.encode(obj.query);
923      }
924    }
925
926    /**
927     * The URL to send the request to.
928     *
929     * @type {String}
930     */
931    babelHelpers.createClass(URL, [{
932      key: "url",
933      get: function get() {
934        return this._url;
935      }
936
937      /**
938       * The HTTP method to use, such as "GET", "POST", "PUT", "DELETE", etc.
939       * Ignored for non-HTTP(S) URLs.
940       *
941       * @type {String}
942       */
943    }, {
944      key: "method",
945      get: function get() {
946        return this._method;
947      }
948
949      /**
950       * A Boolean that indicates whether or not cross-site Access-Control
951       * requests should be made using credentials such as cookies or authorization
952       * headers.
953       *
954       * @type {Boolean}
955       */
956    }, {
957      key: "withCredentials",
958      get: function get() {
959        return this._withCredentials;
960      }
961
962      /**
963       * A key value map of http headers to include in the reques
964       *
965       * @type {Object}
966       */
967    }, {
968      key: "headers",
969      get: function get() {
970        return this._headers;
971      }
972
973      /*
974       *
975       */
976    }, {
977      key: "query",
978      get: function get() {
979        return this._query;
980      }
981
982      /*
983       *
984       */
985    }, {
986      key: "responseType",
987      get: function get() {
988        return this._responseType;
989      }
990
991      /**
992       * Data to send with a POST request
993       *
994       * @type {String|Object}
995       */
996    }, {
997      key: "data",
998      get: function get() {
999        return this._data;
1000      }
1001    }, {
1002      key: "body",
1003      get: function get() {
1004        return this._data;
1005      }
1006
1007      /**
1008       *
1009       */
1010    }], [{
1011      key: "create",
1012      value: function create(obj) {
1013        return new URL(obj);
1014      }
1015    }]);
1016    return URL;
1017  }();
1018
1019  var KeySystem = /*#__PURE__*/function () {
1020    function KeySystem() {
1021      babelHelpers.classCallCheck(this, KeySystem);
1022    }
1023    babelHelpers.createClass(KeySystem, null, [{
1024      key: "WIDEVINE",
1025      get:
1026      /**
1027       *
1028       */
1029      function get() {
1030        return "com.widevine.alpha";
1031      }
1032
1033      /**
1034       *
1035       */
1036    }, {
1037      key: "PLAYREADY",
1038      get: function get() {
1039        return "com.microsoft.playready";
1040      }
1041
1042      /**
1043       *
1044       */
1045    }, {
1046      key: "FAIRPLAY",
1047      get: function get() {
1048        return "com.apple.fps.1_0";
1049      }
1050
1051      /**
1052       *
1053       */
1054    }, {
1055      key: "CLEARKEY",
1056      get: function get() {
1057        return "org.w3.clearkey";
1058      }
1059
1060      /**
1061       *
1062       */
1063    }, {
1064      key: "UNKNOWN",
1065      get: function get() {
1066        return "unknown";
1067      }
1068      /**
1069      *
1070      */
1071    }, {
1072      key: "key",
1073      get: function get() {
1074        return key;
1075      },
1076      set: function set(value) {
1077        key = value;
1078      }
1079    }, {
1080      key: "robustnessLevel",
1081      get: function get() {
1082        return robustnessLevel;
1083      },
1084      set: function set(value) {
1085        robustnessLevel = value;
1086      }
1087    }, {
1088      key: "init",
1089      value: function init(config) {
1090        if (this.isEMEBrowser() !== true) return Promise.resolve(KeySystem.UNKNOWN);
1091        if ('robustnessLevel' in config) robustnessLevel = config['robustnessLevel'];
1092        return this.detect();
1093      }
1094    }, {
1095      key: "isEMEBrowser",
1096      value: function isEMEBrowser() {
1097        return "MediaKeys" in window || "WebKitMediaKeys" in window || "MSMediaKeys" in window;
1098      }
1099    }, {
1100      key: "detect",
1101      value: function detect() {
1102        var _this = this;
1103        var widevine = this.requestMediaKeyAccess(KeySystem.WIDEVINE);
1104        var playready = this.requestMediaKeyAccess(KeySystem.PLAYREADY);
1105        var fairplay = new Promise(function (resolve) {
1106          if ("WebKitMediaKeys" in window && WebKitMediaKeys.isTypeSupported(KeySystem.FAIRPLAY, "video/mp4")) resolve(KeySystem.FAIRPLAY);else resolve(KeySystem.UNKNOWN);
1107        });
1108        var clearkey = this.requestMediaKeyAccess(KeySystem.CLEARKEY);
1109        return Promise.all([widevine, playready, fairplay, clearkey]).then(function (values) {
1110          _this.key = values.filter(function (val) {
1111            return val !== KeySystem.UNKNOWN;
1112          });
1113        });
1114      }
1115    }, {
1116      key: "requestMediaKeyAccess",
1117      value: function requestMediaKeyAccess(key) {
1118        return new Promise(function (resolve, reject) {
1119          var config = [{
1120            initDataTypes: ['cenc'],
1121            videoCapabilities: [{
1122              contentType: 'video/mp4;codecs="avc1.42E01E"',
1123              robustness: robustnessLevel
1124            }, {
1125              contentType: 'video/webm; codecs="vp9"',
1126              robustness: robustnessLevel
1127            }]
1128          }];
1129          var complete = function complete(key) {
1130            return resolve(key);
1131          };
1132          var error = function error() {
1133            complete(KeySystem.UNKNOWN);
1134          };
1135          try {
1136            navigator.requestMediaKeySystemAccess(key, config).then(function () {
1137              return complete(key);
1138            })["catch"](error);
1139          } catch (error) {
1140            complete(KeySystem.UNKNOWN);
1141          }
1142        });
1143      }
1144    }]);
1145    return KeySystem;
1146  }();
1147  var key = [KeySystem.UNKNOWN];
1148  var robustnessLevel = '';
1149
1150  var _navigator = navigator,
1151    ua = _navigator.userAgent,
1152    appName = _navigator.appName,
1153    platform = _navigator.platform,
1154    appVersion = _navigator.appVersion;
1155  var _semver = /((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?/;
1156  var Utils = /*#__PURE__*/function () {
1157    function Utils() {
1158      babelHelpers.classCallCheck(this, Utils);
1159    }
1160    babelHelpers.createClass(Utils, null, [{
1161      key: "mimeTypes",
1162      get: function get() {
1163        return {
1164          mp4: "video/mp4",
1165          m3u8: "application/x-mpegURL",
1166          mp3: "audio/mpeg",
1167          json: "application/json",
1168          txt: "text/plain",
1169          xml: "application/xml",
1170          ogv: "video/ogg",
1171          webm: "video/webm",
1172          mpd: "application/dash+xml",
1173          ism: "application/vnd.ms-sstr+xml",
1174          js: "text/javascript",
1175          css: "text/css",
1176          vtt: "text/vtt",
1177          ttml: "application/ttml+xml",
1178          srt: "application/x-subrip",
1179          cea608: "text/cea-608",
1180          cea708: "text/cea-708"
1181        };
1182      }
1183    }, {
1184      key: "semver",
1185      value: function semver() {
1186        var str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
1187        var match = str.match(_semver) || [];
1188        return {
1189          major: parseInt(match[2]),
1190          minor: parseInt(match[3]),
1191          patch: parseInt(match[4]),
1192          pre: match[5],
1193          build: match[6],
1194          version: match[1],
1195          raw: match[0],
1196          toString: function toString() {
1197            return this.raw;
1198          }
1199        };
1200      }
1201
1202      // https://github.com/mathiasbynens/small
1203    }, {
1204      key: "blankVideo",
1205      value: function blankVideo() {
1206        return "data:video/mp4;base64,AAAAHGZ0eXBpc29tAAACAGlzb21pc28ybXA0MQAAAAhmcmVlAAAC721kYXQhEAUgpBv/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA3pwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcCEQBSCkG//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADengAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAsJtb292AAAAbG12aGQAAAAAAAAAAAAAAAAAAAPoAAAALwABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAB7HRyYWsAAABcdGtoZAAAAAMAAAAAAAAAAAAAAAIAAAAAAAAALwAAAAAAAAAAAAAAAQEAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAAC8AAAAAAAEAAAAAAWRtZGlhAAAAIG1kaGQAAAAAAAAAAAAAAAAAAKxEAAAIAFXEAAAAAAAtaGRscgAAAAAAAAAAc291bgAAAAAAAAAAAAAAAFNvdW5kSGFuZGxlcgAAAAEPbWluZgAAABBzbWhkAAAAAAAAAAAAAAAkZGluZgAAABxkcmVmAAAAAAAAAAEAAAAMdXJsIAAAAAEAAADTc3RibAAAAGdzdHNkAAAAAAAAAAEAAABXbXA0YQAAAAAAAAABAAAAAAAAAAAAAgAQAAAAAKxEAAAAAAAzZXNkcwAAAAADgICAIgACAASAgIAUQBUAAAAAAfQAAAHz+QWAgIACEhAGgICAAQIAAAAYc3R0cwAAAAAAAAABAAAAAgAABAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAIAAAABAAAAHHN0c3oAAAAAAAAAAAAAAAIAAAFzAAABdAAAABRzdGNvAAAAAAAAAAEAAAAsAAAAYnVkdGEAAABabWV0YQAAAAAAAAAhaGRscgAAAAAAAAAAbWRpcmFwcGwAAAAAAAAAAAAAAAAtaWxzdAAAACWpdG9vAAAAHWRhdGEAAAABAAAAAExhdmY1Ni40MC4xMDE=";
1207      }
1208    }, {
1209      key: "getIEVersion",
1210      value: function getIEVersion() {
1211        var re,
1212          rv = -1;
1213        if (appName === "Microsoft Internet Explorer") {
1214          re = /MSIE ([0-9]{1,}[\.0-9]{0,})/;
1215        } else if (appName === "Netscape") {
1216          re = /Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/;
1217        } else if (/Edge\/[0-9\.]+$/.test(ua)) {
1218          re = /Edge\/([0-9\.]+)/;
1219        }
1220        if ((re != null ? re.exec(ua) : void 0) != null) {
1221          rv = parseFloat(RegExp.$1);
1222        }
1223        return rv;
1224      }
1225    }, {
1226      key: "getEdgeVersion",
1227      value: function getEdgeVersion() {
1228        var rv = -1;
1229        if (/Edge\/([\d]+)/.exec(ua)) {
1230          rv = parseFloat(RegExp.$1);
1231        }
1232        return rv;
1233      }
1234    }, {
1235      key: "getFFVersion",
1236      value: function getFFVersion() {
1237        var rv = -1;
1238        if (/Firefox\/([0-9\.]+)$/.exec(ua)) {
1239          rv = parseFloat(RegExp.$1);
1240        }
1241        return rv;
1242      }
1243    }, {
1244      key: "getSafariVersion",
1245      value: function getSafariVersion() {
1246        var rv = -1;
1247        if (/Safari\/[0-9\.]+$/.test(ua) && /Version\/([0-9]+\.[0-9]+)/.exec(ua) != null) {
1248          rv = parseFloat(RegExp.$1);
1249        }
1250        return rv;
1251      }
1252    }, {
1253      key: "isChrome",
1254      value: function isChrome() {
1255        return /Chrom(e|ium)/.test(ua);
1256      }
1257    }, {
1258      key: "getChromeVersion",
1259      value: function getChromeVersion() {
1260        var rv = -1;
1261        if (/Chrome( Mobile)?\/([0-9\.]+)/.test(ua)) {
1262          rv = parseFloat(ua.match(/Chrome( Mobile)?\/([0-9\.]+)/)[2].split(".").slice(0, 2).join("."));
1263        }
1264        return rv;
1265      }
1266    }, {
1267      key: "selectSource",
1268      value: function selectSource(media, canPlay) {
1269        // find the first playable item
1270        return fp.find(media.source, fp.map(function (source) {
1271          return Object.assign({
1272            type: Utils.getMimeType(media.src || source.src)
1273          }, media, source);
1274        }), fp.filter(function (item) {
1275          return canPlay(item);
1276        }));
1277      }
1278    }, {
1279      key: "getSourceByType",
1280      value: function getSourceByType(media, type) {
1281        var sources = media.source != null ? media.source.slice() : [];
1282        if (media.type == null) media.type = Utils.getMimeType(media.src);
1283        sources.push(media);
1284        return sources.find(function (source) {
1285          return source.type === type;
1286        });
1287      }
1288    }, {
1289      key: "getMimeType",
1290      value: function getMimeType(file) {
1291        return Utils.mimeTypes[Utils.getFileExtension(file)];
1292      }
1293    }, {
1294      key: "selectTrack",
1295      value: function selectTrack(tracks, kind) {
1296        return tracks.find(function (track) {
1297          return track.kind === kind;
1298        });
1299      }
1300    }, {
1301      key: "isIPhone",
1302      value: function isIPhone() {
1303        return /iPhone/.test(platform) || /iPhone/.test(ua);
1304      }
1305    }, {
1306      key: "isIPad",
1307      value: function isIPad() {
1308        return /iPad/.test(platform) || /iPad/.test(ua);
1309      }
1310    }, {
1311      key: "isAndroid",
1312      value: function isAndroid() {
1313        return /Android [4-9]/.test(ua);
1314      }
1315    }, {
1316      key: "isKindleFireHD",
1317      value: function isKindleFireHD() {
1318        return /Silk\/2/.test(ua);
1319      }
1320    }, {
1321      key: "isKindleFire",
1322      value: function isKindleFire() {
1323        return /Silk\/1/.test(ua);
1324      }
1325    }, {
1326      key: "isBlackBerry",
1327      value: function isBlackBerry() {
1328        return /BlackBerry;|PlayBook|BB10/.test(ua);
1329      }
1330    }, {
1331      key: "isFirefoxOS",
1332      value: function isFirefoxOS() {
1333        return /\(Mobile;.*Firefox\//.test(ua);
1334      }
1335    }, {
1336      key: "isHTML5",
1337      value: function isHTML5() {
1338        return Utils.isIOS() || Utils.isAndroid() || Utils.isKindleFireHD() || Utils.isBlackBerry() || Utils.isFirefoxOS();
1339      }
1340    }, {
1341      key: "isIOS",
1342      value: function isIOS() {
1343        var iOSRegEx = /iP(hone|od|ad)/i;
1344        return iOSRegEx.test(platform) || iOSRegEx.test(ua);
1345      }
1346    }, {
1347      key: "getIOSversion",
1348      value: function getIOSversion() {
1349        if (Utils.isIOS()) {
1350          var ver = appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);
1351          if (ver == null) {
1352            ver = appVersion.match(/Version\/(\d+)\.(\d+)/);
1353          }
1354          if (ver != null) {
1355            return [parseInt(ver[1], 10), parseInt(ver[2], 10), parseInt(ver[3] || 0, 10)];
1356          }
1357        }
1358      }
1359    }, {
1360      key: "isFullscreenDevice",
1361      value: function isFullscreenDevice() {
1362        return Utils.isKindleFireHD() || Utils.isIPhone();
1363      }
1364    }, {
1365      key: "getDevice",
1366      value: function getDevice() {
1367        var device = "desktop";
1368        if (Utils.isIPhone()) {
1369          device = "iphone";
1370        } else if (Utils.isIPad()) {
1371          device = "ipad";
1372        } else if (/Android/.test(ua)) {
1373          device = "android";
1374        } else if (Utils.isKindleFireHD()) {
1375          device = "kindlefirehd";
1376        } else if (Utils.isKindleFire()) {
1377          device = "kindlefire";
1378        }
1379        return device;
1380      }
1381
1382      // Changes XML to JSON
1383    }, {
1384      key: "xmlToJson",
1385      value: function xmlToJson(xml) {
1386        // Create the return object
1387        var obj = {};
1388
1389        // document
1390        if (xml.nodeType === 9) {
1391          xml = xml.firstChild;
1392        }
1393
1394        // element
1395        if (xml.nodeType === 1) {
1396          // do attributes
1397          if (xml.attributes.length > 0) {
1398            obj["@attributes"] = {};
1399            fp.each(xml.attributes, function (attribute) {
1400              obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
1401            });
1402          }
1403          // text or cdata
1404        } else if (xml.nodeType === 3 || xml.nodeType === 4) {
1405          obj = xml.nodeValue;
1406        }
1407
1408        // do children
1409        if (xml.hasChildNodes()) {
1410          fp.each(xml.childNodes, function (child) {
1411            // check for blank text nodes
1412            if (child.nodeType === 3 && !/\S/.test(child.nodeValue)) {
1413              return;
1414            }
1415
1416            // convert namespaces
1417            var nodeName = child.nodeName.replace(/:/, "-");
1418
1419            // // convert the element
1420            var element = Utils.xmlToJson(child);
1421
1422            // hoist text only nodes
1423            if (element["@attributes"] == null && element["#text"] != null) {
1424              element = element["#text"];
1425            }
1426            if (obj[nodeName] == null) {
1427              obj[nodeName] = element;
1428            } else {
1429              if (!(obj[nodeName] instanceof Array)) {
1430                obj[nodeName] = [obj[nodeName]];
1431              }
1432              obj[nodeName].push(element);
1433            }
1434          });
1435        }
1436        return obj;
1437      }
1438
1439      /**
1440       * Returns a platform specific XHR object.
1441       *
1442       * @static
1443       */
1444    }, {
1445      key: "getXHR",
1446      value: function getXHR() {
1447        return new XMLHttpRequest();
1448      }
1449
1450      /**
1451       * Retrieves a remote text file
1452       *
1453       * @static
1454       */
1455    }, {
1456      key: "getUTC",
1457      value: function getUTC() {
1458        return Utils.request("//time.akamai.com").then(function (xhr) {
1459          return parseFloat(xhr.responseText) * 1000;
1460        });
1461      }
1462
1463      /**
1464       * Request an http resource
1465       *
1466       * @static
1467       */
1468    }, {
1469      key: "request",
1470      value: function request() {
1471        var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1472        return new Promise(function (resolve, reject) {
1473          options = URL.create(options);
1474          var xhr = Utils.getXHR();
1475          xhr.open(options.method, options.url);
1476          xhr.onload = function () {
1477            if (options.checkStatus !== false) {
1478              if (xhr.status > 399) {
1479                reject(xhr);
1480              }
1481            }
1482            resolve(xhr);
1483          };
1484          xhr.onerror = function (event) {
1485            return reject(xhr);
1486          };
1487          xhr.withCredentials = options.withCredentials;
1488          if (options.responseType != null) {
1489            try {
1490              xhr.responseType = options.responseType;
1491            } catch (error) {}
1492          }
1493          if (options.headers != null) {
1494            var headers = options.headers;
1495            fp.each(headers, function (value, key) {
1496              if (key != null && value != null) {
1497                xhr.setRequestHeader(key, value);
1498              }
1499            });
1500          }
1501          return xhr.send(options.data);
1502        });
1503      }
1504
1505      /**
1506       * Request an http resource
1507       *
1508       * @static
1509       */
1510    }, {
1511      key: "requestText",
1512      value: function requestText() {
1513        var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1514        return Utils.request(options).then(function (xhr) {
1515          return xhr.responseText;
1516        });
1517      }
1518
1519      /**
1520       * Request an http resource
1521       *
1522       * @static
1523       */
1524    }, {
1525      key: "requestJson",
1526      value: function requestJson() {
1527        var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1528        return Utils.requestText(options).then(function (text) {
1529          return JSON.parse(text);
1530        });
1531      }
1532
1533      /**
1534       * Attaches a CSS file to the head of the document.
1535       *
1536       * @static
1537       */
1538    }, {
1539      key: "jsonp",
1540      value: function jsonp(url, responseField) {
1541        return new Promise(function (resolve, reject) {
1542          window[responseField] = resolve;
1543          return Utils.loadScript(url).then(function (script) {
1544            script.parentNode.removeChild(script);
1545            window[responseField] = null;
1546            try {
1547              delete window[responseField];
1548            } catch (error) {}
1549          })["catch"](reject);
1550        });
1551      }
1552
1553      /**
1554       * Attaches a JavaScript file to the head of the document.
1555       *
1556       * @static
1557       */
1558    }, {
1559      key: "loadScript",
1560      value: function loadScript(src, parent) {
1561        return new Promise(function (resolve, reject) {
1562          var head = parent || document.getElementsByTagName("head")[0];
1563          var script = document.createElement("script");
1564          script.type = "text/javascript";
1565          if (script.addEventListener) {
1566            script.onload = function () {
1567              resolve(script);
1568            };
1569            script.onerror = function (event) {
1570              reject(event);
1571            };
1572          } else if (script.readyState) {
1573            script.onreadystatechange = function (event) {
1574              if (this.readyState === "loaded" || this.readyState === "complete") {
1575                this.onreadystatechange = null;
1576                resolve(script);
1577              }
1578            };
1579          }
1580          script.src = src;
1581          head.appendChild(script);
1582        });
1583      }
1584
1585      /**
1586       * Attaches a CSS file to the head of the document.
1587       *
1588       * @static
1589       */
1590    }, {
1591      key: "loadStyleSheet",
1592      value: function loadStyleSheet(href) {
1593        var head = document.getElementsByTagName("head")[0];
1594        var link = document.createElement("link");
1595        link.rel = "stylesheet";
1596        link.type = "text/css";
1597        link.href = href;
1598        return head.appendChild(link);
1599      }
1600
1601      /**
1602       * Load an image.
1603       *
1604       * @static
1605       */
1606    }, {
1607      key: "loadImage",
1608      value: function loadImage(src) {
1609        return new Promise(function (resolve, reject) {
1610          try {
1611            var img = document.createElement("img");
1612            img.onload = function (event) {
1613              return resolve(img);
1614            };
1615            img.onerror = function (event) {
1616              return reject(event);
1617            };
1618            return img.src = src;
1619          } catch (error) {
1620            return reject(error);
1621          }
1622        });
1623      }
1624    }, {
1625      key: "getFileExtension",
1626      value: function getFileExtension() {
1627        var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
1628        return url.replace(/\?.*/, "").replace(/\#.*/, "").split(".").pop();
1629      }
1630
1631      /**
1632       * Determines if the device supports touch events
1633       *
1634       * @static
1635       */
1636    }, {
1637      key: "isTouchDevice",
1638      value: function isTouchDevice() {
1639        if (Utils.isTouch == null) {
1640          try {
1641            document.createEvent("TouchEvent");
1642            Utils.isTouch = true;
1643          } catch (error) {
1644            Utils.isTouch = false;
1645          }
1646        }
1647        return Utils.isTouch;
1648      }
1649
1650      /**
1651       * Forces a number between a min and a max
1652       *
1653       * @static
1654       */
1655    }, {
1656      key: "clamp",
1657      value: function clamp(value, min, max) {
1658        if (value < min) {
1659          value = min;
1660        }
1661        if (value > max) {
1662          value = max;
1663        }
1664        return value;
1665      }
1666
1667      /**
1668       * Override the properties of a base object with the values
1669       * of an override object.
1670       *
1671       * @param {Object} base     The base object.
1672       * @param {Object} overrides  key/value overrides
1673       * @return {Object}
1674       * @static
1675       */
1676    }, {
1677      key: "override",
1678      value: function override(base, overrides) {
1679        var clone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1680        if (base == null) return overrides;
1681        if (overrides == null) return base;
1682        if (clone === true) {
1683          base = Utils.clone(base);
1684          overrides = Utils.clone(overrides);
1685        }
1686        Object.getOwnPropertyNames(overrides).forEach(function (key) {
1687          var value = overrides[key];
1688          var baseValue = base[key];
1689          var type = babelHelpers["typeof"](value);
1690          if (type === "undefined") return;
1691          if (baseValue == null || babelHelpers["typeof"](baseValue) !== "object" || value instanceof Array) {
1692            base[key] = value;
1693          } else if (type === "object") {
1694            base[key] = Utils.override(baseValue, value, false);
1695          }
1696        });
1697        return base;
1698      }
1699
1700      /**
1701       * Merge the properties of a list of object. Similar to
1702       * Object.assign, but undefined values will not override
1703       * defined values.
1704       *
1705       * @param {Array.<Object>} objs The list of objects
1706       * @return {Object}
1707       * @static
1708       */
1709    }, {
1710      key: "merge",
1711      value: function merge() {
1712        for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1713          args[_key] = arguments[_key];
1714        }
1715        var objs = args[0] instanceof Array ? args[0] : args;
1716        return objs.reduce(function (acc, obj) {
1717          return obj != null ? Utils.override(acc, obj, false) : acc;
1718        }, {});
1719      }
1720
1721      /**
1722       * Mixin the properties of a list of objects. Similar to
1723       * Object.assign, but takes into account class methods.
1724       *
1725       * @param {Object} base The base object
1726       * @param {Array.<Object>} objs The list of objects
1727       * @return {Object}
1728       * @static
1729       */
1730    }, {
1731      key: "mixin",
1732      value: function mixin(base) {
1733        for (var _len2 = arguments.length, objs = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1734          objs[_key2 - 1] = arguments[_key2];
1735        }
1736        if (base == null || objs.length < 1) return base;
1737        var names = Object.getOwnPropertyNames;
1738        var proto = Object.getPrototypeOf;
1739        objs.forEach(function (obj) {
1740          var props = names(obj).concat(names(proto(obj)));
1741          props.forEach(function (prop) {
1742            return base[prop] = obj[prop];
1743          });
1744        });
1745        return base;
1746      }
1747
1748      /**
1749       * Diffs two objects.
1750       *
1751       * @param {Object} oldObj The old object.
1752       * @param {Object} newObj The new object.
1753       * @return {Object?}
1754       * @static
1755       */
1756    }, {
1757      key: "diff",
1758      value: function diff(oldObj, newObj) {
1759        if (newObj == null) {
1760          return null;
1761        }
1762        if (oldObj == null && newObj != null) {
1763          return newObj;
1764        }
1765        var changes = {};
1766        for (var key in newObj) {
1767          var value = newObj[key];
1768          var old = oldObj[key];
1769          if (old !== value) {
1770            if (old == null) {
1771              changes[key] = value;
1772            } else {
1773              switch (babelHelpers["typeof"](value)) {
1774                case "string":
1775                case "number":
1776                case "boolean":
1777                case "function":
1778                  // Functions can only be strictly diffed so they go here
1779                  changes[key] = value;
1780                  break;
1781                case "object":
1782                  if (value instanceof Array) {
1783                    if (old.length !== value.length) {
1784                      changes[key] = value;
1785                    }
1786                  } else {
1787                    var diff = Utils.diff(old, value);
1788                    if (diff != null) {
1789                      changes[key] = diff;
1790                    }
1791                  }
1792              }
1793            }
1794          }
1795        }
1796        if (Object.keys(changes).length === 0) {
1797          return null;
1798        }
1799        return changes;
1800      }
1801
1802      /**
1803       * Clones an object.
1804       *
1805       * @param {Object} obj The object to be cloned.
1806       * @return {Object}
1807       * @static
1808       */
1809    }, {
1810      key: "clone",
1811      value: function clone(obj) {
1812        var deepCopy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1813        if (obj == null) {
1814          return obj;
1815        }
1816        var clone = obj;
1817        if (babelHelpers["typeof"](obj) === "object") {
1818          clone = obj instanceof Array ? [] : {};
1819          var _loop = function _loop(key) {
1820            var value = obj[key];
1821            if (babelHelpers["typeof"](value) === "object" && value !== null && deepCopy === true) {
1822              if (value instanceof Array) {
1823                clone[key] = [];
1824                value.forEach(function (item) {
1825                  return clone[key].push(Utils.clone(item));
1826                });
1827              } else {
1828                clone[key] = {};
1829                for (var k in value) {
1830                  clone[key][k] = Utils.clone(value[k]);
1831                }
1832              }
1833            } else {
1834              clone[key] = value;
1835            }
1836          };
1837          for (var key in obj) {
1838            _loop(key);
1839          }
1840        }
1841        return clone;
1842      }
1843
1844      /**
1845       * Safely gets a value from an obj's sub path
1846       */
1847    }, {
1848      key: "get",
1849      value: function get(obj, paths) {
1850        if (obj == null || paths == null || paths.length < 1) return;
1851        if (typeof paths == "string") paths = paths.split(".");
1852        for (var i = 0, len = paths.length; i < len; ++i) {
1853          var path = paths[i];
1854          if (obj[path] != null) {
1855            obj = obj[path];
1856          } else {
1857            return;
1858          }
1859        }
1860        return obj;
1861      }
1862
1863      /**
1864       * Applies a value to an obj creating sub objects where needed.
1865       */
1866    }, {
1867      key: "set",
1868      value: function set(obj, paths, value) {
1869        if (obj == null || paths == null || paths.length < 1) {
1870          return;
1871        }
1872        var last = paths.length - 1;
1873        paths.forEach(function (path, i) {
1874          if (i === last) {
1875            return obj[path] = value;
1876          }
1877          if (obj[path] == null) {
1878            obj[path] = {};
1879          }
1880          obj = obj[path];
1881        });
1882      }
1883
1884      /**
1885       * Takes a time in seconds and converts it to timecode.
1886       *
1887       * @param   {Number}  time  The time in seconds to be formatted.
1888       * @return  {String}  A SMTP formatted string.
1889       */
1890    }, {
1891      key: "formatTimecode",
1892      value: function formatTimecode(time, duration) {
1893        time = parseInt(time);
1894        if (isNaN(time)) {
1895          return "00:00";
1896        }
1897        var strTime = Utils.formatZeroFill(time % 60);
1898        time = parseInt(time / 60);
1899        strTime = Utils.formatZeroFill(time % 60) + ":" + strTime;
1900        time = parseInt(time / 60);
1901        if (time > 0) {
1902          strTime = Utils.formatZeroFill(time) + ":" + strTime;
1903        }
1904        if (duration >= 3600 && strTime.length === 5) {
1905          strTime = "00:" + strTime;
1906        }
1907        return strTime;
1908      }
1909
1910      /**
1911       * Converts a time in seconds to a string and adds a zero in front of any number lower than 10.
1912       *
1913       * @param Number time The number to be zero filled.
1914       */
1915    }, {
1916      key: "formatZeroFill",
1917      value: function formatZeroFill(time) {
1918        var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
1919        return time.toString().padStart(length, "0");
1920      }
1921
1922      /** */
1923    }, {
1924      key: "toDate",
1925      value: function toDate(value) {
1926        if (!(value instanceof Date)) {
1927          return new Date(value);
1928        } else {
1929          return value;
1930        }
1931      }
1932
1933      /**
1934       * Converts a date into a time strimg based on a ISO 8601 formatted time string.
1935       *
1936       * @param   {number|Date}  date
1937       *    The date
1938       *
1939       * @param   {string}  [format="h:mm:ss A"]
1940       *    The ISO 8601 format string
1941       *
1942       * @param   {string}  [timezone=""]
1943       *    The timezone string
1944       *
1945       * @return  {string}
1946       *    The formattted time string
1947       */
1948    }, {
1949      key: "formatTime",
1950      value: function formatTime(date) {
1951        var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "h:mm:ss A";
1952        var tz = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
1953          timezone: "",
1954          offset: -(new Date().getTimezoneOffset() / 60)
1955        };
1956        date = Utils.toDate(date);
1957        if (tz.offset != null && tz.offset !== 0) {
1958          date = new Date(date.getTime() + Math.round(tz.offset * 60 * 60 * 1000));
1959        }
1960        if (isNaN(date.getTime())) {
1961          return;
1962        }
1963        var hours = date.getUTCHours();
1964        var minutes = date.getUTCMinutes();
1965        var seconds = date.getUTCSeconds();
1966        var milliseconds = date.getUTCMilliseconds();
1967        var twelve = hours % 12 || 12;
1968        var a = hours < 12 ? "am" : "pm";
1969        var replace = {
1970          hh: Utils.formatZeroFill(twelve),
1971          h: twelve,
1972          HH: Utils.formatZeroFill(hours),
1973          H: hours,
1974          mm: Utils.formatZeroFill(minutes),
1975          m: minutes,
1976          sss: Utils.formatZeroFill(milliseconds, 3),
1977          ss: Utils.formatZeroFill(seconds),
1978          s: seconds,
1979          a: a,
1980          A: a.toUpperCase(),
1981          z: tz.timezone
1982        };
1983        for (var key in replace) {
1984          format = format.replace(key, replace[key]);
1985        }
1986        return format;
1987      }
1988
1989      /**
1990       * Converts timecode to seconds.
1991       *
1992       * @param   {string}  timeCode        A SMTP formatted string.
1993       * @param   {number}  [framerate=30]  The frame rate. Used to calculate milliseconds.
1994       * @return  {number}                  The number of seconds represented by the time code
1995       */
1996    }, {
1997      key: "flattenTimecode",
1998      value: function flattenTimecode(timeCode) {
1999        var framerate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 30;
2000        if (!timeCode) {
2001          return NaN;
2002        }
2003        var pieces = timeCode.split(":");
2004        var ms = 0;
2005        if (pieces.length === 4) {
2006          ms = parseInt(pieces.pop()) / framerate;
2007        } else if (pieces.length === 3) {
2008          // sometimes ms separator is a comma
2009          pieces[2] = pieces[2].replace(",", ".");
2010          if (pieces[2].indexOf(".") !== -1) {
2011            var parts = pieces[2].split(".");
2012            if ((parts != null ? parts.length : void 0) > 1) {
2013              pieces[2] = parts[0];
2014              ms = parseInt(parts[1]) / 1000;
2015            }
2016          }
2017        }
2018        var time = parseInt(pieces.pop());
2019        while (pieces.length > 0) {
2020          time += Math.pow(60, pieces.length) * parseInt(pieces.shift());
2021        }
2022        return time + ms;
2023      }
2024
2025      /**
2026       * Adds a cache busting query string parameter to a url.
2027       *
2028       * @param String url The url.
2029       * @param String key The name of the query string variable
2030       * @param Object value The value of the query string variable
2031       */
2032    }, {
2033      key: "cacheBust",
2034      value: function cacheBust(url) {
2035        var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "cacheBust";
2036        var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Date.now();
2037        var op = url.indexOf("?") === -1 ? "?" : "&";
2038        return url + op + key + "=" + value;
2039      }
2040
2041      /** */
2042    }, {
2043      key: "getFeed",
2044      value: function getFeed(url) {
2045        return Utils.request(url).then(function (xhr) {
2046          if (xhr.responseType === "document" || /^</.test(xhr.responseText)) {
2047            return Utils.xmlToJson(xhr.responseXML);
2048          } else {
2049            return JSON.parse(xhr.responseText);
2050          }
2051        });
2052      }
2053
2054      /** */
2055    }, {
2056      key: "trackMouse",
2057      value: function trackMouse() {
2058        try {
2059          document.addEventListener("mousemove", Utils.mouseTracker);
2060          document.documentElement.addEventListener("mouseleave", function (event) {
2061            if (event.relatedTarget === null) {
2062              return Utils.doc = false;
2063            }
2064          });
2065          document.documentElement.addEventListener("mouseenter", function (event) {
2066            if (event.relatedTarget === null) {
2067              return Utils.doc = true;
2068            }
2069          });
2070        } catch (error) {}
2071      }
2072
2073      /** */
2074    }, {
2075      key: "mouseTracker",
2076      value: function mouseTracker(event) {
2077        Utils.clientX = event.clientX;
2078        Utils.clientY = event.clientY;
2079        Utils.pageX = event.pageX;
2080        Utils.pageY = event.pageY;
2081      }
2082
2083      /** */
2084    }, {
2085      key: "isMouseOverElement",
2086      value: function isMouseOverElement(element) {
2087        var isOver = false;
2088        if (element == null) {
2089          return isOver;
2090        }
2091        try {
2092          isOver = element.contains(document.elementFromPoint(Utils.clientX, Utils.clientY));
2093        } catch (error) {
2094          isOver = false;
2095        }
2096        return isOver;
2097      }
2098
2099      /** */
2100    }, {
2101      key: "isMouseOverDocument",
2102      value: function isMouseOverDocument() {
2103        return Utils.doc;
2104      }
2105
2106      /** Function to get Outer Dimensions*/
2107    }, {
2108      key: "getActualSize",
2109      value: function getActualSize(element) {
2110        var margin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2111        var width = element.offsetWidth;
2112        var height = element.offsetHeight;
2113        if (margin === true) {
2114          var style = getComputedStyle(element);
2115          width += parseInt(style.marginLeft) + parseInt(style.marginRight);
2116          height += parseInt(style.marginTop) + parseInt(style.marginBottom);
2117        }
2118        return {
2119          width: width,
2120          height: height
2121        };
2122      }
2123    }, {
2124      key: "isVolumeSettable",
2125      value: function isVolumeSettable() {
2126        var noVolume = /ipad|iphone|ipod|android|blackberry|windows ce|windows phone|webos|playbook/.exec(ua.toLowerCase());
2127        if (noVolume != null) {
2128          // Firefox on android DOES support changing the volume
2129          return noVolume[0] === "android" && /Firefox/.test(ua);
2130        }
2131        return true;
2132      }
2133
2134      /**
2135       * Creates a unique id.
2136       *
2137       * @param   {number=}   len
2138       *    The number of characters in the uid
2139       *
2140       * @param   {number=}   base
2141       *    The base to use for representing a numeric value.
2142       *
2143       * @return  {string}
2144       *    The unique id.
2145       */
2146    }, {
2147      key: "createUID",
2148      value: function createUID() {
2149        var len = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
2150        var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 32;
2151        var randomRangeInt = function randomRangeInt(min, max) {
2152          return Math.floor(Math.random() * (max - min + 1)) + min;
2153        };
2154        var uid = "",
2155          l = len - 1;
2156        for (var i = 0; i < l; i++) {
2157          uid += randomRangeInt(0, base - 1).toString(base).toUpperCase();
2158        }
2159        if (Utils.uids[uid] === true) {
2160          return Utils.createUID(len, base);
2161        }
2162        Utils.uids[uid] = true;
2163        return uid;
2164      }
2165
2166      /**
2167       * Chains an array of promises sequentially
2168       *
2169       * @param   {Array}   promises
2170       *    The list of promises
2171       *
2172       * @param   {Object}   data
2173       *    Data to be passes from promise to promise
2174       *
2175       * @return  {Promise}
2176       *    The promise chain
2177       */
2178    }, {
2179      key: "chain",
2180      value: function chain(promises, data) {
2181        var chain = Promise.resolve(data);
2182        promises.forEach(function (promise) {
2183          return chain = chain.then(promise);
2184        });
2185        return chain;
2186      }
2187
2188      /**
2189       * Traverse an array of promises until one resolves without error
2190       *
2191       * @param   {Array}   promises
2192       *    The list of promises
2193       *
2194       * @param   {Object}   data
2195       *    Data to be passes from promise to promise
2196       *
2197       * @return  {Promise}
2198       *    The promise chain
2199       */
2200    }, {
2201      key: "first",
2202      value: function first(promises, data) {
2203        return Promise.resolve(data).then(promises.shift()).then(function (result) {
2204          return result;
2205        })["catch"](function (error) {
2206          if (promises.length > 0) {
2207            return Utils.first(promises, data);
2208          } else {
2209            return null;
2210          }
2211        });
2212      }
2213
2214      /**
2215       * Asynchronously transform an object using an array of functions
2216       *
2217       * @param   {Object}   value
2218       *    Data to be passes from promise to promise
2219       *
2220       * @param   {Array.<Function|Transform>}   transforms
2221       *    The list of transforms
2222       *
2223       * @return  {Promise.<Object>}
2224       *    The transformed object
2225       */
2226    }, {
2227      key: "transform",
2228      value: function transform(value, transforms) {
2229        // if no transforms were provided, return the value as is
2230        if (transforms == null || transforms.length === 0) {
2231          return Promise.resolve(value);
2232        }
2233
2234        // Some transforms are encapsulated objects, so first make a flat list of only transform functions
2235        transforms = transforms.map(function (t) {
2236          return typeof t.transform === "function" ? t.transform : t;
2237        });
2238
2239        // establish enclosure variables to keep track of where we are in the transform chain
2240        var index = 0;
2241        var len = transforms.length - 1;
2242
2243        // the next function is passed to every transform, allowing each transform to be applied on both the upstream and downstream
2244        var next = function next(value) {
2245          index++;
2246          return exec(value);
2247        };
2248
2249        // execute an individual transform function
2250        var exec = function exec(value) {
2251          var transform = transforms[index];
2252          if (typeof transform !== "function") {
2253            throw new Error("Transform must be a valid function");
2254          }
2255          // wrap each transform in a Promise, allowing for either sync and async functions to be used
2256          return Promise.resolve(transform(value, next)).then(function (result) {
2257            return index < len ? next(result) : result;
2258          });
2259        };
2260
2261        // execute the first transform to start off the chain
2262        return exec(value);
2263      }
2264
2265      /**
2266       * Converts an array buffer to UTF-8 string.
2267       *
2268       * @param   {ArrayBuffer}   arrayBuffer
2269       *    The ArrayBuffer
2270       *
2271       * @return  {String}
2272       *    The UTF-8 string
2273       */
2274    }, {
2275      key: "arrayBufferToString",
2276      value: function arrayBufferToString(arrayBuffer) {
2277        return String.fromCharCode.apply(null, new Uint8Array(arrayBuffer));
2278      }
2279
2280      /**
2281       * Parses a JSON Web Token
2282       *
2283       * @param {String} jwt
2284       *
2285       * @return {Object}
2286       *    The parsed JSON Web Token as an object
2287       */
2288    }, {
2289      key: "parseJWT",
2290      value: function parseJWT(jwt) {
2291        var parts = jwt.split(".");
2292        return {
2293          header: JSON.parse(atob(parts[0])),
2294          payload: JSON.parse(atob(parts[1])),
2295          signature: parts[2]
2296        };
2297      }
2298
2299      /**
2300       *
2301       */
2302    }, {
2303      key: "getFullScreenApi",
2304      value: function getFullScreenApi(container, video) {
2305        var fullscreen = {};
2306        if (container.webkitRequestFullScreen != null) {
2307          fullscreen.enter = container.webkitRequestFullScreen.bind(container);
2308          fullscreen.exit = document.webkitExitFullscreen != null ? document.webkitExitFullscreen.bind(document) : document.webkitCancelFullScreen.bind(document);
2309          fullscreen.event = "onwebkitfullscreenchange";
2310          fullscreen.element = "webkitFullscreenElement";
2311          fullscreen.error = "webkitfullscreenerror";
2312        } else if (container.requestFullscreen != null) {
2313          fullscreen.enter = container.requestFullscreen.bind(container);
2314          fullscreen.exit = document.exitFullscreen != null ? document.exitFullscreen.bind(document) : document.cancelFullscreen.bind(document);
2315          fullscreen.event = "onfullscreenchange";
2316          fullscreen.element = "fullscreenElement";
2317          fullscreen.error = "fullscreenerror";
2318        } else if (container.mozRequestFullScreen != null) {
2319          fullscreen.enter = container.mozRequestFullScreen.bind(container);
2320          fullscreen.exit = document.mozCancelFullScreen.bind(document);
2321          fullscreen.event = "onmozfullscreenchange";
2322          fullscreen.element = "mozFullscreenElement";
2323          fullscreen.error = "mozfullscreenerror";
2324        } else if (container.msRequestFullscreen != null) {
2325          fullscreen.enter = container.msRequestFullscreen.bind(container);
2326          fullscreen.exit = document.msExitFullscreen.bind(document);
2327          fullscreen.event = "onmsfullscreenchange";
2328          fullscreen.element = "msFullscreenElement";
2329          fullscreen.error = "MSFullscreenError";
2330        } else if (video.webkitEnterFullscreen != null) {
2331          fullscreen.enter = video.webkitEnterFullscreen.bind(video);
2332          fullscreen.exit = video.webkitExitFullscreen.bind(video);
2333          fullscreen.event = null;
2334          fullscreen.error = null;
2335        }
2336        return fullscreen;
2337      }
2338
2339      /** 
2340       * Picture in Picture API variants
2341       */
2342    }, {
2343      key: "getPictureInPictureApi",
2344      value: function getPictureInPictureApi(video) {
2345        var pip = {};
2346        if (video.requestPictureInPicture != null) {
2347          pip.enter = video.requestPictureInPicture.bind(video);
2348          pip.exit = document.exitPictureInPicture.bind(document);
2349          pip.event = "onleavepictureinpicture";
2350          pip.eventName = "leavepictureinpicture";
2351          pip.element = "pictureInPictureElement";
2352        } else if (video.webkitSetPresentationMode != null) {
2353          pip.enter = video.webkitSetPresentationMode.bind(video, "picture-in-picture");
2354          pip.exit = video.webkitSetPresentationMode.bind(video, "inline");
2355          pip.event = "onwebkitpresentationmodechanged";
2356          pip.eventName = "webkitpresentationmodechanged";
2357          pip.element = "pictureInPictureElement";
2358        }
2359        return pip;
2360      }
2361
2362      /** Helper to determine whether the browser allows PiP or not */
2363    }, {
2364      key: "isPictureInPictureSupported",
2365      value: function isPictureInPictureSupported(video) {
2366        return video.disablePictureInPicture != true && document.pictureInPictureEnabled != false && (typeof video.webkitSupportsPresentationMode == "function" || typeof video.requestPictureInPicture == "function");
2367      }
2368
2369      /** */
2370    }, {
2371      key: "stringToArray",
2372      value: function stringToArray(string) {
2373        var buffer = new ArrayBuffer(string.length * 2); // 2 bytes for each char
2374        var array = new Uint16Array(buffer);
2375        for (var i = 0, l = string.length; i < l; i++) {
2376          array[i] = string.charCodeAt(i);
2377        }
2378        return array;
2379      }
2380
2381      /** */
2382    }, {
2383      key: "arrayToString",
2384      value: function arrayToString(array) {
2385        return String.fromCharCode.apply(null, new Uint16Array(array.buffer));
2386      }
2387
2388      /** */
2389    }, {
2390      key: "base64DecodeUint8Array",
2391      value: function base64DecodeUint8Array(input) {
2392        var raw = window.atob(input);
2393        var rawLength = raw.length;
2394        var array = new Uint8Array(new ArrayBuffer(rawLength));
2395        for (var i = 0, j = 0, l = rawLength - 1; 0 <= l ? j <= l : j >= l; i = 0 <= l ? ++j : --j) {
2396          array[i] = raw.charCodeAt(i);
2397        }
2398        return array;
2399      }
2400
2401      /** */
2402    }, {
2403      key: "base64EncodeUint8Array",
2404      value: function base64EncodeUint8Array(input) {
2405        var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
2406        var len = input.length;
2407        var output = "";
2408        var i = 0;
2409        while (i < len) {
2410          var chr1 = input[i++];
2411          var chr2 = i < len ? input[i++] : Number.NaN; // Not sure if the index
2412          var chr3 = i < len ? input[i++] : Number.NaN; // checks are needed here
2413
2414          var enc1 = chr1 >> 2;
2415          var enc2 = (chr1 & 3) << 4 | chr2 >> 4;
2416          var enc3 = (chr2 & 15) << 2 | chr3 >> 6;
2417          var enc4 = chr3 & 63;
2418          if (isNaN(chr2)) {
2419            enc3 = enc4 = 64;
2420          } else if (isNaN(chr3)) {
2421            enc4 = 64;
2422          }
2423          output += keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
2424        }
2425        return output;
2426      }
2427
2428      /** */
2429    }, {
2430      key: "getKeySystem",
2431      value: function getKeySystem() {
2432        var key = KeySystem.key;
2433        if (key.length === 0 || key.indexOf(KeySystem.UNKNOWN) !== -1) return Utils.getKeySystemByUserAgent();
2434        return key;
2435      }
2436    }, {
2437      key: "getKeySystemByUserAgent",
2438      value: function getKeySystemByUserAgent() {
2439        if (/Edge/.test(ua) || /Trident/.test(ua) || /Tizen/.test(ua)) {
2440          return [KeySystem.PLAYREADY, KeySystem.CLEARKEY];
2441        } else if (/Chrome/.test(ua) || /Firefox/.test(ua)) {
2442          return [KeySystem.WIDEVINE, KeySystem.CLEARKEY];
2443        } else if (/Safari/.test(ua)) {
2444          return [KeySystem.FAIRPLAY];
2445        } else {
2446          return [KeySystem.UNKNOWN];
2447        }
2448      }
2449
2450      /** */
2451    }, {
2452      key: "isAutoplaySupported",
2453      value: function isAutoplaySupported() {
2454        var supported = true;
2455        if (Utils.isIOS()) {
2456          if (Utils.getSafariVersion() !== -1) {
2457            var ver = Utils.getIOSversion() || [];
2458            supported = ver[0] >= 10;
2459          } else if (Utils.isChrome()) {
2460            supported = Utils.getChromeVersion() >= 53;
2461          }
2462        }
2463        if (Utils.isChrome() && Utils.isAndroid()) {
2464          supported = Utils.getChromeVersion() >= 53;
2465        }
2466        return supported;
2467      }
2468
2469      /** */
2470    }, {
2471      key: "fieldIsUnique",
2472      value: function fieldIsUnique(items, field, compare) {
2473        compare = compare.toString().toLowerCase();
2474        return !items.some(function () {
2475          var item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2476          var value = item.hasOwnProperty(field) ? item[field] : "";
2477          return value.toString().toLowerCase() === compare;
2478        });
2479      }
2480
2481      /** */
2482    }, {
2483      key: "toCamelCase",
2484      value: function toCamelCase(str) {
2485        return str.replace(/-|_([a-z])/g, function (g) {
2486          return g[1].toUpperCase();
2487        });
2488      }
2489
2490      /** */
2491    }, {
2492      key: "toHyphenated",
2493      value: function toHyphenated(str) {
2494        var sep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "-";
2495        return str.replace(/([A-Z])/g, function (g) {
2496          return sep + g[0].toLowerCase();
2497        });
2498      }
2499
2500      /** */
2501    }, {
2502      key: "toSnakeCase",
2503      value: function toSnakeCase(str) {
2504        var upper = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2505        str = Utils.toHyphenated(str, "_");
2506        return upper === true ? str.toUpperCase() : str;
2507      }
2508
2509      /**
2510       * Creates an HTML element.
2511       *
2512       * @param   {?(string|Array.<string>)}  classes
2513       * @param   {?DOMElement}  parent
2514       * @param   {?string} text
2515       * @param   {?string|DOMElement}  element
2516       * @return  {DOMElement}
2517       */
2518    }, {
2519      key: "createElement",
2520      value: function createElement(classes, parent, text) {
2521        var element = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "div";
2522        if (typeof element === "string") {
2523          element = document.createElement(element);
2524        }
2525        if (classes != null) {
2526          if (typeof classes === "string") {
2527            classes = [classes];
2528          }
2529          classes.forEach(function (item) {
2530            return element.classList.add(item);
2531          });
2532        }
2533        if (text != null) {
2534          element.textContent = text;
2535        }
2536        if (parent != null) {
2537          parent.appendChild(element);
2538        }
2539        return element;
2540      }
2541
2542      /** */
2543    }, {
2544      key: "select",
2545      value: function select(el) {
2546        if (typeof el === "string") {
2547          var result = document.getElementById(el);
2548          if (result == null) {
2549            result = document.querySelector(el);
2550          }
2551          el = result;
2552        }
2553        return el;
2554      }
2555
2556      /** */
2557    }, {
2558      key: "getViewability",
2559      value: function getViewability(el) {
2560        el = Utils.select(el);
2561        var rect = el.getBoundingClientRect();
2562        var width = window.innerWidth || document.documentElement.clientWidth;
2563        var height = window.innerHeight || document.documentElement.clientHeight;
2564        var top = rect.top >= 0;
2565        var left = rect.left >= 0;
2566        var bottom = rect.bottom <= height;
2567        var right = rect.right <= width;
2568        switch (true) {
2569          case top && left && bottom && right:
2570            return "full";
2571          case !top && rect.bottom <= 0 || !left && rect.right <= 0 || !right && rect.left >= width || !bottom && rect.top >= height:
2572            return "none";
2573          case top || left || bottom || right:
2574            return "partial";
2575        }
2576      }
2577
2578      /** */
2579    }, {
2580      key: "isViewable",
2581      value: function isViewable(el) {
2582        return Utils.getViewability(el) === "full";
2583      }
2584
2585      /** */
2586    }, {
2587      key: "timerGroup",
2588      value: function timerGroup(id) {
2589        var destroy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2590        if (Utils.timerGroups == null) {
2591          Utils.timerGroups = {};
2592        }
2593        if (destroy === true) {
2594          var group = Utils.timerGroups[id];
2595          if (group != null) {
2596            group.destroy();
2597          }
2598          delete Utils.timerGroups[id];
2599          return;
2600        }
2601        if (Utils.timerGroups[id] == null) {
2602          Utils.timerGroups[id] = TimerGroup.create(id);
2603        }
2604        return Utils.timerGroups[id];
2605      }
2606
2607      /** */
2608    }, {
2609      key: "startsWith",
2610      value: function startsWith(value, search) {
2611        var pos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2612        return value.substring(pos, pos + search.length) === search;
2613      }
2614
2615      /** compares ISO 639-1 and ISO 639-2/T language codes*/
2616    }, {
2617      key: "compareLanguageTags",
2618      value: function compareLanguageTags(a, b) {
2619        return this.startsWith(a, b) || this.startsWith(b, a);
2620      }
2621
2622      /**
2623       * Returns the multipliers for the transfer rate unit type
2624       */
2625    }, {
2626      key: "transferRates",
2627      get: function get() {
2628        return {
2629          'Kbps': 1E+3,
2630          'Mbps': 1E+6,
2631          'Gbps': 1E+9
2632        };
2633      }
2634    }]);
2635    return Utils;
2636  }();
2637  Utils.isTouch = null;
2638  Utils.clientX = 0;
2639  Utils.clientY = 0;
2640  Utils.pageX = 0;
2641  Utils.pageY = 0;
2642  Utils.doc = true;
2643  Utils.trackMouse();
2644  Utils.uids = {};
2645
2646  var CSS = /*#__PURE__*/function () {
2647    function CSS() {
2648      babelHelpers.classCallCheck(this, CSS);
2649    }
2650    babelHelpers.createClass(CSS, null, [{
2651      key: "toColor",
2652      value: function toColor(str) {
2653        var parts;
2654        if (/$#/.test(str)) {
2655          parts = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
2656            return '#' + r + r + g + g + b + b;
2657          }).substring(1).match(/.{2}/g).map(x(function () {
2658            return parseInt(x, 16);
2659          }));
2660        } else {
2661          parts = str.match(/[0-9\.]+/g);
2662        }
2663        var r = parseInt(parts[0]);
2664        var g = parseInt(parts[1]);
2665        var b = parseInt(parts[2]);
2666        var a = parts[3] !== null ? parseFloat(parts[3]) : 1;
2667        return {
2668          r: r,
2669          g: g,
2670          b: b,
2671          a: a
2672        };
2673      }
2674    }, {
2675      key: "fromColor",
2676      value: function fromColor(color) {
2677        if (color.a == null) {
2678          color.a = 1;
2679        }
2680        return "rgba(".concat(color.r, ",").concat(color.g, ",").concat(color.b, ",").concat(color.a, ")");
2681      }
2682    }, {
2683      key: "toPercent",
2684      value: function toPercent(num) {
2685        if (typeof num === "string") {
2686          return num;
2687        }
2688        return "".concat(Math.round(num * 100), "%");
2689      }
2690    }, {
2691      key: "fromPercent",
2692      value: function fromPercent(str) {
2693        if (typeof str === "number") {
2694          return str;
2695        }
2696        return parseFloat(str) / 100;
2697      }
2698    }, {
2699      key: "toSize",
2700      value: function toSize(size) {
2701        if (/^[0-9]+$/.test(size)) {
2702          return size + "px";
2703        } else {
2704          return size;
2705        }
2706      }
2707    }, {
2708      key: "toCSS",
2709      value: function toCSS(obj) {
2710        var important = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
2711        var css = "";
2712        important = important === true ? " !important" : "";
2713        fp.each(obj, function (value, key) {
2714          return css += "".concat(Utils.toHyphenated(key), ":").concat(value).concat(important, ";");
2715        });
2716        return css;
2717      }
2718    }]);
2719    return CSS;
2720  }();
2721
2722  var Logger = /*#__PURE__*/function () {
2723    function Logger(enabled) {
2724      babelHelpers.classCallCheck(this, Logger);
2725      this.enabled = enabled;
2726      if (!this.enabled) {
2727        this.log = this.trace = this.debug = this.info = this.warn = this.error = this.fatal = function () {};
2728      }
2729    }
2730    babelHelpers.createClass(Logger, [{
2731      key: "log",
2732      value: function log() {
2733        try {
2734          if (arguments.length > 1 && arguments[1] != null) {
2735            console.log.apply(console, arguments);
2736          } else {
2737            console.log(arguments[0]);
2738          }
2739        } catch (error) {}
2740      }
2741    }, {
2742      key: "trace",
2743      value: function trace() {
2744        try {
2745          console.trace.apply(console, arguments);
2746        } catch (error) {}
2747      }
2748    }, {
2749      key: "debug",
2750      value: function debug() {
2751        try {
2752          console.log.apply(console, arguments);
2753        } catch (error) {
2754          this.log.apply(this, arguments);
2755        }
2756      }
2757    }, {
2758      key: "info",
2759      value: function info() {
2760        try {
2761          console.info.apply(console, arguments);
2762        } catch (error) {}
2763      }
2764    }, {
2765      key: "warn",
2766      value: function warn() {
2767        try {
2768          console.warn.apply(console, arguments);
2769        } catch (error) {}
2770      }
2771    }, {
2772      key: "error",
2773      value: function error() {
2774        try {
2775          console.error.apply(console, arguments);
2776        } catch (error) {
2777          this.log.apply(this, arguments);
2778        }
2779      }
2780    }, {
2781      key: "fatal",
2782      value: function fatal() {
2783        try {
2784          console.fatal.apply(console, arguments);
2785        } catch (error) {}
2786      }
2787    }]);
2788    return Logger;
2789  }();
2790
2791  var Events = {
2792    LOADED_METADATA: "loadedmetadata",
2793    READY: "ready",
2794    ERROR: "error",
2795    ENDED: "ended",
2796    STARTED: "started",
2797    DURATION_CHANGE: "durationchange",
2798    SEEKING: "seeking",
2799    SEEKED: "seeked",
2800    TIME_UPDATE: "timeupdate",
2801    LOAD_START: "loadstart",
2802    LOADED_DATA: "loadeddata",
2803    CAN_PLAY: "canplay",
2804    CAN_PLAY_THROUGH: "canplaythrough",
2805    PROGRESS: "progress",
2806    MEDIA_CHANGE: "mediachange",
2807    WAITING: "waiting",
2808    BUFFERING_CHANGE: "bufferingchange",
2809    STALLED: "stalled",
2810    PLAY: "play",
2811    PLAYING: "playing",
2812    PAUSE: "pause",
2813    PAUSED: "paused",
2814    PLAY_REQUEST: "playrequest",
2815    MEDIUM_CHANGE: "mediumchange",
2816    TEMPORAL_TYPE_CHANGE: "temporaltypechange",
2817    VOLUME_CHANGE: "volumechange",
2818    FAIL_OVER_ATTEMPT: "failoverattempt",
2819    PLAYBACK_TARGET_CHANGE: "playbacktargetchange",
2820    PLAYBACK_TARGET_AVAILABILITY_CHANGE: "playbacktargetavailabilitychange",
2821    RECORD_CONTENT_CHANGE: "recordcontentchange",
2822    IS_LIVE: "islive",
2823    CONTENT_CHANGED: "contentchanged",
2824    PLAYBACK_RATE_CHANGE: "playbackratechange",
2825    SETTINGS_CHANGE: "settingschange",
2826    TRACK_ERROR: "trackerror",
2827    QUALITY_CHANGE: "qualitychange",
2828    QUALITY_CHANGING: "qualitychanging",
2829    QUALITY_SWITCHED: "qualityswitched",
2830    QUALITY_MODE_CHANGE: "qualitymodechange",
2831    QUALITY_LEVELS_LOADED: "qualitylevelsloaded",
2832    MEDIA_SEQUENCE_INITIALIZED: "mediasequenceinitialized",
2833    MEDIA_SEQUENCE_STARTED: "mediasequencestarted",
2834    MEDIA_SEQUENCE_ENDED: "mediasequenceended",
2835    MEDIA_SEQUENCE_ABORTED: "mediasequenceaborted",
2836    AUTOPLAY_BLOCKED: "autoplayblocked",
2837    LANGUAGE_CHANGE: "languagechange",
2838    TIMED_METADATA: "timedmetadata",
2839    CUES_CHANGE: "cueschange",
2840    VIEW_CREATED: "viewcreated",
2841    MUTE_CHANGE: "mutechange",
2842    RESUME: "resume",
2843    PLAY_STATE_CHANGE: "playstatechange",
2844    FULL_SCREEN_CHANGE: "fullscreenchange",
2845    DISPLAY_STATE_CHANGE: "displaystatechange",
2846    BUSY: "busy",
2847    CREATE: "create",
2848    DESTROY: "destroy",
2849    GO_LIVE: "golive"
2850  };
2851
2852  /**
2853   * @enum {string}
2854   * @const
2855   */
2856  var AutoplayPolicy = {
2857    /**
2858     *
2859     */
2860    NONE: "none",
2861    /**
2862     *
2863     */
2864    DEFAULT: "default",
2865    /**
2866     *
2867     */
2868    MUTED: "muted"
2869  };
2870
2871  var AutoplayThreshold = /*#__PURE__*/function () {
2872    function AutoplayThreshold() {
2873      babelHelpers.classCallCheck(this, AutoplayThreshold);
2874    }
2875    babelHelpers.createClass(AutoplayThreshold, null, [{
2876      key: "UNKNOWN",
2877      get:
2878      /**
2879       *
2880       */
2881      function get() {
2882        return "unknown";
2883      }
2884
2885      /**
2886       *
2887       */
2888    }, {
2889      key: "ALLOWED",
2890      get: function get() {
2891        return "allowed";
2892      }
2893
2894      /**
2895       *
2896       */
2897    }, {
2898      key: "MUTED",
2899      get: function get() {
2900        return "muted";
2901      }
2902
2903      /**
2904       *
2905       */
2906    }, {
2907      key: "MUTED_INLINE",
2908      get: function get() {
2909        return "mutedinline";
2910      }
2911
2912      /**
2913       *
2914       */
2915    }, {
2916      key: "BLOCKED",
2917      get: function get() {
2918        return "blocked";
2919      }
2920
2921      /**
2922       *
2923       */
2924    }, {
2925      key: "threshold",
2926      get: function get() {
2927        return threshold;
2928      },
2929      set: function set(value) {
2930        threshold = value;
2931      }
2932
2933      /**
2934       * Detects the browser's autoplay threshold
2935       *
2936       * @param  {string=}  url  The url to use in the dectection process
2937       */
2938    }, {
2939      key: "detect",
2940      value: function detect() {
2941        var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Utils.blankVideo();
2942        return new Promise(function (resolve, reject) {
2943          var complete = function complete(threshold) {
2944            try {
2945              video.removeEventListener("error", error);
2946              video.pause();
2947            } catch (error) {}
2948            resolve(threshold);
2949          };
2950          var error = function error() {
2951            complete(AutoplayThreshold.UNKNOWN);
2952          };
2953          var muted = function muted() {
2954            video.muted = true;
2955            video.play().then(function () {
2956              return complete(AutoplayThreshold.MUTED);
2957            })["catch"](inline);
2958          };
2959          var inline = function inline() {
2960            video.playsInline = true;
2961            video.play().then(function () {
2962              return complete(AutoplayThreshold.MUTED_INLINE);
2963            })["catch"](function () {
2964              return complete(AutoplayThreshold.BLOCKED);
2965            });
2966          };
2967          try {
2968            if (!Utils.isAutoplaySupported()) {
2969              return resolve(AutoplayThreshold.BLOCKED);
2970            }
2971            var video = document.createElement("video");
2972            video.addEventListener("error", error);
2973            video.volume = 0.01;
2974            video.src = url;
2975            Promise.resolve(video.play()).then(function () {
2976              return complete(AutoplayThreshold.ALLOWED);
2977            })["catch"](muted);
2978          } catch (err) {
2979            error();
2980          }
2981        });
2982      }
2983
2984      /*
2985       *
2986       */
2987    }, {
2988      key: "init",
2989      value: function init(config) {
2990        // don't run the detection if the customer opts out
2991        if (config.autoplayPolicy === AutoplayPolicy.NONE) {
2992          return Promise.resolve(threshold = AutoplayThreshold.UNKNOWN);
2993        }
2994        if (Utils.isHTML5() === true) {
2995          if (Utils.isAutoplaySupported()) {
2996            threshold = Utils.isIOS() ? AutoplayThreshold.MUTED_INLINE : AutoplayThreshold.MUTED;
2997          } else {
2998            threshold = AutoplayThreshold.BLOCKED;
2999          }
3000          return Promise.resolve(threshold);
3001        }
3002        return this.value(threshold === AutoplayThreshold.UNKNOWN);
3003      }
3004
3005      /*
3006       *
3007       */
3008    }, {
3009      key: "value",
3010      value: function value() {
3011        var refresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
3012        if (refresh === true) {
3013          threshold = null;
3014          detecting = null;
3015        }
3016        if (threshold != null) {
3017          return Promise.resolve(threshold);
3018        } else {
3019          if (detecting == null) {
3020            detecting = this.detect().then(function (value) {
3021              threshold = value;
3022              detecting = null;
3023              return value;
3024            });
3025          }
3026          return detecting;
3027        }
3028      }
3029    }]);
3030    return AutoplayThreshold;
3031  }();
3032  var threshold = AutoplayThreshold.UNKNOWN;
3033  var detecting = null;
3034
3035  /**
3036   * @enum {string}
3037   * @const
3038   * @private
3039   */
3040  var Preload = {
3041    /**
3042     * Constant representing the "none" preload mode
3043     */
3044    NONE: "none",
3045    /**
3046     * Constant representing the "metadata" preload mode
3047     */
3048    METADATA: "metadata",
3049    /**
3050     * Constant representing the "auto" preload mode
3051     */
3052    AUTO: "auto"
3053  };
3054
3055  var Env = {
3056    VERSION: "9.1.22",
3057    PRODUCT: "premier",
3058    PLATFORM: "web",
3059    PLAYER_ID: "",
3060    CREATE: "http://localhost:2672/beacon/create/",
3061    TRACK: "http://localhost:2672/beacon/track/"
3062  };
3063
3064  var Config = /*#__PURE__*/function () {
3065    /**
3066     * The Config class
3067     *
3068     * @param Object} overrides
3069     *    Config overrides
3070     *
3071     * @constructor
3072     */
3073    function Config() {
3074      var overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3075      babelHelpers.classCallCheck(this, Config);
3076      // apply overrides
3077      var config = Utils.override(Config.defaults, overrides);
3078      var debug = QueryString.amp.debug;
3079      if (debug != null) {
3080        config.debug = debug;
3081      }
3082      if (config.defaults == null) {
3083        config.defaults = {};
3084      }
3085      if (config.controls === true) {
3086        config.plugins.react = null;
3087      }
3088      Object.assign(this, config);
3089
3090      // autoplay/autoplayPolicy shortcut
3091      if (/muted/i.test(this.autoplay)) {
3092        this.autoplayPolicy = AutoplayPolicy.MUTED;
3093        this.autoplay = true;
3094      }
3095    }
3096    babelHelpers.createClass(Config, null, [{
3097      key: "create",
3098      value: function create(overrides) {
3099        return new Config(overrides);
3100      }
3101    }]);
3102    return Config;
3103  }();
3104  Config.defaults = {
3105    id: null,
3106    paths: {
3107      base: "../",
3108      player: "${paths.base}akamai/amp/core/",
3109      plugins: "${paths.base}akamai/amp/",
3110      libs: "${paths.player}libs/",
3111      resources: "${paths.base}resources/"
3112    },
3113    resources: [{
3114      debug: "${paths.player}amp.css",
3115      src: "${paths.player}amp.min.css",
3116      type: "text/css",
3117      async: true
3118    }],
3119    plugins: {
3120      react: {
3121        resources: [{
3122          src: "${paths.plugins}react/libs/react.min.js",
3123          debug: "${paths.plugins}react/libs/react.js",
3124          type: "text/javascript"
3125        }, {
3126          src: "${paths.plugins}react/React.min.css",
3127          debug: "${paths.plugins}react/React.css",
3128          type: "text/css"
3129        }, {
3130          src: "${paths.plugins}react/React.min.js",
3131          debug: "${paths.plugins}react/React.js",
3132          type: "text/javascript"
3133        }],
3134        autoHide: 3,
3135        hint: {
3136          enabled: true
3137        }
3138      }
3139    },
3140    pid: Env.PLAYER_ID,
3141    dataset: {},
3142    settings: {},
3143    preload: Preload.NONE,
3144    language: navigator.language || navigator.browserLanguage,
3145    autoplay: false,
3146    autoplayPolicy: AutoplayPolicy.DEFAULT,
3147    loop: false,
3148    controls: false,
3149    playsinline: null,
3150    withCredentials: false,
3151    muted: null,
3152    fullscreen: {},
3153    captioning: {},
3154    hls: {
3155      resources: [{
3156        type: "text/javascript",
3157        src: "${paths.libs}hls.min.js",
3158        debug: "${paths.libs}hls.js",
3159        defer: true
3160      }],
3161      quality: {
3162        startLevel: -1
3163      },
3164      data: {
3165        enableWorker: true
3166      }
3167    },
3168    dash: {
3169      resources: [{
3170        type: "text/javascript",
3171        src: "//cdn.dashjs.org/v4.1.0/dash.all.min.js",
3172        debug: "//cdn.dashjs.org/v4.1.0/dash.all.debug.js",
3173        defer: true
3174      }],
3175      buffer: 1
3176    },
3177    locales: {},
3178    defaults: {
3179      language: "en"
3180    }
3181  };
3182  Config.locales = {
3183    en: {
3184      MONOSPACED_SERIF: "Monospaced Serif",
3185      PROPORTIONAL_SERIF: "Proportional Serif",
3186      MONOSPACED_SANS_SERIF: "Monospaced Sans-Serif",
3187      PROPORTIONAL_SANS_SERIF: "Proportional Sans-Serif",
3188      CASUAL: "Casual",
3189      CURSIVE: "Cursive",
3190      SMALL_CAPS: "Small Capitals",
3191      ERROR: "Error",
3192      ERROR_ABORTED: "Media Aborted",
3193      ERROR_DECODE: "Decode Error",
3194      ERROR_NETWORK: "Network Error",
3195      ERROR_SRC: "Source not supported",
3196      ERROR_DEFAULT: "An unknown error has occurred",
3197      STREAM_NOT_FOUND: "Stream not found",
3198      EN: "English",
3199      ENG: "English",
3200      ES: "Spanish",
3201      SPA: "Spanish",
3202      DE: "German",
3203      DEU: "German",
3204      GER: "German",
3205      FR: "French",
3206      FRE: "French",
3207      FRA: "French",
3208      IT: "Italian",
3209      ITA: "Italian",
3210      RU: "Russian",
3211      RUS: "Russian",
3212      ZH: "Chinese",
3213      ZHO: "Chinese",
3214      CHI: "Chinese",
3215      JA: "Japanese",
3216      JPN: "Japanese",
3217      KO: "Korean",
3218      KOR: "Korean",
3219      SV: "Swedish",
3220      SWE: "Swedish",
3221      PHI: "Philippine",
3222      PT: "Portuguese",
3223      POR: "Portuguese",
3224      UNKNOWN: "Unknown"
3225    },
3226    es: '#{paths.player}es.json',
3227    fr: '#{paths.player}fr.json'
3228  };
3229
3230  var SINGLE = /^\s*[#\$]{([^\$#{}]+)}\s*$/;
3231  var TOKEN = /[#\$]{([^\$#}]*)}/g;
3232  var DataBinding = /*#__PURE__*/function () {
3233    /**
3234     * @constructor
3235     */
3236    function DataBinding() {
3237      babelHelpers.classCallCheck(this, DataBinding);
3238    }
3239
3240    /**
3241     * @private
3242     * @type {RegExp}
3243     * @const
3244     */
3245    babelHelpers.createClass(DataBinding, null, [{
3246      key: "SINGLE",
3247      get: function get() {
3248        return SINGLE;
3249      }
3250
3251      /**
3252       * @private
3253       * @type {RegExp}
3254       * @const
3255       */
3256    }, {
3257      key: "TOKEN",
3258      get: function get() {
3259        return TOKEN;
3260      }
3261
3262      /**
3263       * Evaluate a data bound string.
3264       *
3265       * @param {string} binding
3266       *   The data bound string.
3267       *
3268       * @param {?Object} context
3269       *   The context object used as "global" when evaluating the binding.
3270       *
3271       * @return {string}
3272       *   The evaluated result
3273       */
3274    }, {
3275      key: "eval",
3276      value: function _eval(binding, context) {
3277        var _this = this;
3278        if (binding == null) {
3279          return binding;
3280        }
3281        // if the binding is a single value, such as ${media}, execute it by itself so that the full object can be returned instead of "[object Object]"
3282        if (SINGLE.test(binding)) {
3283          try {
3284            return this.exec(binding.replace(SINGLE, "$1"), context);
3285          } catch (error) {
3286            return binding;
3287          }
3288        }
3289        return binding.replace(TOKEN, function (match, token, offset, string) {
3290          try {
3291            return _this.exec(token, context);
3292          } catch (error) {
3293            return match;
3294          }
3295        });
3296      }
3297
3298      /**
3299       * Execute a data bound string.
3300       *
3301       * @param {string} binding
3302       *   The data bound string.
3303       *
3304       * @param {?Object} context
3305       *   The context object used as "global" when evaluating the binding.
3306       *
3307       * @return {string}
3308       *   The evaluated result
3309       */
3310    }, {
3311      key: "exec",
3312      value: function exec(binding, context) {
3313        var _Utils$get;
3314        return (_Utils$get = Utils.get(context, binding)) !== null && _Utils$get !== void 0 ? _Utils$get : new Function("with (this) { return ".concat(binding, " }")).bind(context)();
3315      }
3316
3317      /**
3318       * Evaluate a data bound object.
3319       *
3320       * @param {Object} value
3321       *   The data bound object.
3322       *
3323       * @param {Object} context
3324       *   The context object used as "global" when evaluating the binding.
3325       *
3326       * @return {Object}
3327       *   The evaluated result
3328       */
3329    }, {
3330      key: "evaluateBindings",
3331      value: function evaluateBindings(value, context) {
3332        var _this2 = this;
3333        var clone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
3334        if (value == null) {
3335          return;
3336        }
3337        if (babelHelpers["typeof"](value) === "object") {
3338          var obj = clone === true ? JSON.parse(JSON.stringify(value)) : value;
3339          if (value instanceof Array) {
3340            return obj.map(function (item) {
3341              return _this2.evaluateBindings(item, context, false);
3342            });
3343          } else {
3344            value = {};
3345            for (var key in obj) {
3346              value[key] = this.evaluateBindings(obj[key], context, false);
3347            }
3348            return value;
3349          }
3350        } else if (typeof value === "string") {
3351          var result = this.eval(value, context);
3352          // allow recursive binding in strings only
3353          if (result !== value && TOKEN.test(result) === true) {
3354            return this.evaluateBindings(result, context, clone);
3355          } else {
3356            return result;
3357          }
3358        } else {
3359          return value;
3360        }
3361      }
3362    }]);
3363    return DataBinding;
3364  }();
3365
3366  var ModuleProxy = /*#__PURE__*/function (_puremvc$Proxy) {
3367    babelHelpers.inherits(ModuleProxy, _puremvc$Proxy);
3368    /**
3369     * Creates a new instance of MediaProxy. Used to track player configuration settings.
3370     *
3371     * @param {Object} data The config object.
3372     * @constructor
3373     * @private
3374     * @extends {puremvc.Proxy}
3375     */
3376    function ModuleProxy(data, name) {
3377      var _this;
3378      babelHelpers.classCallCheck(this, ModuleProxy);
3379      _this = _puremvc$Proxy.call(this, name) || this;
3380      _this.config = data;
3381      return _this;
3382    }
3383
3384    /**
3385     * The name of the this Proxy.
3386     *
3387     * @static
3388     * @type {string}
3389     */
3390    babelHelpers.createClass(ModuleProxy, [{
3391      key: "initializeNotifier",
3392      value: /** @override */
3393      function initializeNotifier(key) {
3394        babelHelpers.get(babelHelpers.getPrototypeOf(ModuleProxy.prototype), "initializeNotifier", this).call(this, key);
3395        this.createData();
3396      }
3397
3398      /** */
3399    }, {
3400      key: "createData",
3401      value: function createData() {
3402        this.setData(this.config);
3403      }
3404
3405      /** */
3406    }, {
3407      key: "getDefaults",
3408      value: function getDefaults() {
3409        return this.defaults || {};
3410      }
3411
3412      /**
3413       * Sets the data for this proxy.
3414       *
3415       * @param {Object} value
3416       *    The new data for this proxy
3417       * @override
3418       */
3419    }, {
3420      key: "setData",
3421      value: function setData() {
3422        var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3423        var obj = {};
3424        this.getDefaults();
3425        fp.each(this.getDefaults(), function (value, key) {
3426          return obj[key] = key in data ? data[key] : value;
3427        });
3428        babelHelpers.get(babelHelpers.getPrototypeOf(ModuleProxy.prototype), "setData", this).call(this, obj);
3429        return data;
3430      }
3431
3432      /** */
3433    }, {
3434      key: "destroy",
3435      value: function destroy() {}
3436    }], [{
3437      key: "NAME",
3438      get: function get() {
3439        return "ModuleProxy";
3440      }
3441    }]);
3442    return ModuleProxy;
3443  }(puremvc.Proxy);
3444
3445  var ModuleAdapter = /*#__PURE__*/function (_puremvc$Mediator) {
3446    babelHelpers.inherits(ModuleAdapter, _puremvc$Mediator);
3447    /**
3448     * The ModuleAdapter class.
3449     *
3450     * @param {Module} module
3451     * @constructor
3452     * @private
3453     * @extends {puremvc.Mediator}
3454     */
3455    function ModuleAdapter(module) {
3456      var _this;
3457      babelHelpers.classCallCheck(this, ModuleAdapter);
3458      _this = _puremvc$Mediator.call(this, module.getModuleName()) || this;
3459      _this.module = module;
3460      _this.mediator = null;
3461      return _this;
3462    }
3463    babelHelpers.createClass(ModuleAdapter, [{
3464      key: "initializeNotifier",
3465      value: function initializeNotifier(key) {
3466        var _this2 = this;
3467        babelHelpers.get(babelHelpers.getPrototypeOf(ModuleAdapter.prototype), "initializeNotifier", this).call(this, key);
3468        var publications = this.module.listNotificationPublications();
3469        if (publications != null) {
3470          this.mediator = new puremvc.Mediator(this.facade.getModuleName());
3471          this.mediator.listNotificationInterests = function () {
3472            return publications;
3473          };
3474          this.mediator.handleNotification = function (notification) {
3475            _this2.facade.sendNotification(notification.getName(), notification.getBody(), notification.getType());
3476          };
3477        }
3478      }
3479    }, {
3480      key: "onRegister",
3481      value: function onRegister() {
3482        if (this.mediator != null) {
3483          this.module.registerMediator(this.mediator);
3484        }
3485      }
3486    }, {
3487      key: "onRemove",
3488      value: function onRemove() {
3489        if (this.mediator != null) {
3490          this.module.removeMediator(this.mediator);
3491        }
3492      }
3493
3494      /**
3495       * Overridden so this class may subscribe to all notifications
3496       * @return An Array
3497       *
3498       */
3499    }, {
3500      key: "listNotificationInterests",
3501      value: function listNotificationInterests() {
3502        return this.module.listNotificationInterests();
3503      }
3504
3505      /**
3506       * Handles notifications of interest to this mediator. Note that
3507       * the default declaration is to allow the super to handle the
3508       * note. This leaves the base JunctionMediator to handle things
3509       * like ACCEPT_INPUT_PIPE and ACCEPT_OUTPUT_PIPE
3510       * @param note An INotification
3511       *
3512       */
3513    }, {
3514      key: "handleNotification",
3515      value: function handleNotification(notification) {
3516        this.module.sendNotification(notification.getName(), notification.getBody(), notification.getType());
3517      }
3518    }]);
3519    return ModuleAdapter;
3520  }(puremvc.Mediator);
3521
3522  var DispatchEventCommand = /*#__PURE__*/function (_puremvc$SimpleComman) {
3523    babelHelpers.inherits(DispatchEventCommand, _puremvc$SimpleComman);
3524    /**
3525     * The EndCommand class.
3526     *
3527     * @constructor
3528     * @private
3529     * @extends {puremvc.SimpleCommand}
3530     */
3531    function DispatchEventCommand() {
3532      babelHelpers.classCallCheck(this, DispatchEventCommand);
3533      return _puremvc$SimpleComman.call(this) || this;
3534    }
3535
3536    /**
3537     * Executes the command.
3538     *
3539     * @param {puremvc.Notification} notification
3540     *    The notification.
3541     *
3542     * @override
3543     */
3544    babelHelpers.createClass(DispatchEventCommand, [{
3545      key: "execute",
3546      value: function execute(notification) {
3547        var event = notification.getBody();
3548        event.player = this.facade.player || this.facade;
3549        this.facade.dispatchEvent(event);
3550      }
3551    }]);
3552    return DispatchEventCommand;
3553  }(puremvc.SimpleCommand);
3554
3555  var Transformer = /*#__PURE__*/function () {
3556    /**
3557     * Creates a new Transformer
3558     *
3559     * @constructor
3560     * @private
3561     */
3562    function Transformer() {
3563      babelHelpers.classCallCheck(this, Transformer);
3564      this._transformMap = {};
3565    }
3566
3567    /**
3568     * Creates a new Transformer
3569     *
3570     * @param {Object} target
3571     *  The Transformer target
3572     *
3573     * @return {Transformer}
3574     */
3575    babelHelpers.createClass(Transformer, [{
3576      key: "addTransform",
3577      value:
3578      /**
3579       * Adds a transform for a given type.
3580       *
3581       * @param {!string}  type  A string representing the event's type.
3582       * @param {!Function} transform  A function to call when the event is triggered.
3583       */
3584      function addTransform(type, transform) {
3585        if (transform == null || type == null) {
3586          return;
3587        }
3588        if (this._transformMap[type] == null) {
3589          this._transformMap[type] = [];
3590        } else if (this._transformMap[type].indexOf(transform) !== -1) {
3591          return;
3592        }
3593        this._transformMap[type].push(transform);
3594        this.sortTransforms(type);
3595      }
3596
3597      /**
3598       * Sorts the transform list by priority. Higher priority Transforms
3599       * are executed first.
3600       *
3601       * @param {!String} type The transform type
3602       * @param {Function=} func An optional sort function
3603       * @returns {Array.<Function|akamai.amp.Transform>} The sorted list
3604       */
3605    }, {
3606      key: "sortTransforms",
3607      value: function sortTransforms(type, func) {
3608        if (func == null) {
3609          func = function func(a, b) {
3610            var aP = a.priority || 0;
3611            var bP = b.priority || 0;
3612            return bP - aP;
3613          };
3614        }
3615        return this._transformMap[type].sort(func);
3616      }
3617
3618      /**
3619       * Performs a transform for a given type
3620       *
3621       * @param {!String} type The transform type
3622       * @param {!Object} value The value to be transformed
3623       */
3624    }, {
3625      key: "transform",
3626      value: function transform(type, value) {
3627        var transforms = this._transformMap[type];
3628        if (transforms == null) {
3629          return Promise.resolve(value);
3630        }
3631        return Utils.transform(value, transforms);
3632      }
3633
3634      /**
3635       * Removes a transform for a given type.
3636       *
3637       * @param {!string}  type  A string representing the transform's type.
3638       * @param {!Function} transform  A function or Transform object to call when the type is triggered.
3639       * @return {?Function} the transform that was removed if any
3640       */
3641    }, {
3642      key: "removeTransform",
3643      value: function removeTransform(type, transform) {
3644        if (transform == null || type == null) {
3645          return;
3646        }
3647        var transforms = this._transformMap[type];
3648        if (transforms == null) {
3649          return;
3650        }
3651        var index = transforms.indexOf(transform);
3652        if (index === -1) {
3653          return;
3654        }
3655        return transforms.splice(index, 1);
3656      }
3657    }], [{
3658      key: "create",
3659      value: function create() {
3660        return new Transformer();
3661      }
3662    }]);
3663    return Transformer;
3664  }();
3665
3666  /**
3667   * @enum {string}
3668   * @const
3669   */
3670  var TransformType = {
3671    /**
3672     *
3673     */
3674    TIME: "time",
3675    /**
3676     *
3677     */
3678    SEEK: "seek",
3679    /**
3680     *
3681     */
3682    MEDIA: "media",
3683    /**
3684     *
3685     */
3686    AD_REQUEST: "adrequest",
3687    /**
3688     *
3689     */
3690    AD_BREAK: "adbreak",
3691    /**
3692     *
3693     */
3694    PLAY_STATE: "playstate",
3695    /**
3696     *
3697     */
3698    EVENT: "event",
3699    /**
3700     *
3701     */
3702    ERROR: "error",
3703    /**
3704     *
3705     */
3706    CUE_CHANGE: "cuechange"
3707  };
3708
3709  /**
3710   * @enum {string}
3711   * @const
3712   * @private
3713   */
3714  var Notifications = {
3715    INTERNAL: "internal",
3716    STARTUP: "startup",
3717    LOAD: "load",
3718    REQUEST_PLAY: "requestplay",
3719    PAUSE_REQUEST: "pauserequest",
3720    TOGGLE_PLAY_PAUSE: "toggleplaypause",
3721    CHANGE_PLAY_STATE: "changeplaystate",
3722    MEDIA_ELEMENT_CHANGE: "mediaelementchange",
3723    HIDDEN_CHANGE: "hiddenchange",
3724    TOGGLE_FULL_SCREEN: "togglefullscreen",
3725    CHANGE_DISPLAY_STATE: "changedisplaystate",
3726    DISABLE_FULL_SCREEN: "disablefullscreen",
3727    ENABLE_FULL_SCREEN: "enablefullscreen",
3728    CHANGE_ACTIVE_STATE: "changeactivestate",
3729    ACTIVE_STATE_CHANGE: "activestatechange",
3730    CHANGE_MEDIA: "changemedia",
3731    SET_MEDIA: "setmedia",
3732    MEDIA_VALIDATED: "mediavalidated",
3733    CHANGE_SETTINGS: "changesettings",
3734    CHANGE_VOLUME: "changevolume",
3735    CHANGE_MUTED: "changemuted",
3736    TOGGLE_MUTED: "togglemuted",
3737    CHANGE_TIME: "changetime",
3738    TIME_CHANGE: "timechange",
3739    SEEK: "seek",
3740    SEEK_COMPLETE: "seekcomplete",
3741    CHANGE_DURATION: "changeduration",
3742    CHANGE_AUTOPLAY: "changeautoplay",
3743    AUTOPLAY_CHANGE: "autoplaychange",
3744    CHANGE_LOOP: "changeloop",
3745    CHANGE_PRELOAD: "changepreload",
3746    CHANGE_CONTROLS: "changecontrols",
3747    PLAYBACK_CORE_CHANGE: "playbackcorechange",
3748    START: "start",
3749    END: "end",
3750    REPLAY: "replay",
3751    ADD_LAYER: "addlayer",
3752    REMOVE_LAYER: "removelayer",
3753    ADD_OVERLAY: "addoverlay",
3754    REMOVE_OVERLAY: "removeoverlay",
3755    ADD_CONTROL: "addcontrol",
3756    REMOVE_CONTROL: "removecontrol",
3757    ADD_CONTROL_STATE: "addcontrolstate",
3758    REMOVE_CONTROL_STATE: "removecontrolstate",
3759    ADD_APPLICATION_STATE: "addapplicationstate",
3760    REMOVE_APPLICATION_STATE: "removeapplicationstate",
3761    DISPATCH_EVENT: "dispatchevent",
3762    INITIALIZED: "initialized",
3763    REGISTER_PLAYBACK_CORE: "registerplaybackcore",
3764    REMOVE_PLAYBACK_CORE: "removeplaybackcore",
3765    CHANGE_PLAYBACK_TARGET: "changeplaybacktarget",
3766    LOCK: "lock",
3767    FRAGMENT_LOAD_START: "fragmentloadstart",
3768    FRAGMENT_LOADED: "fragmentloaded",
3769    CHANGE_CONTENT: "changecontent",
3770    ENABLE_VIDEO_EVENTS: "enablevideoevents",
3771    DISABLE_VIDEO_EVENTS: "disablevideoevents",
3772    HAS_POST_CONTENT: "haspostcontent",
3773    AUDIO_TRACK_SWITCH: "audiotrackswitch",
3774    TRACK: "track",
3775    TEXT_TRACK_ADDED: "texttrackadded",
3776    init: function init() {
3777      var _this = this;
3778      fp.each(Events, function (value, key) {
3779        if (key !== "values" && key !== "init") {
3780          _this[key] = value;
3781        }
3782      });
3783    }
3784  };
3785
3786  var Module = /*#__PURE__*/function (_puremvc$Facade) {
3787    babelHelpers.inherits(Module, _puremvc$Facade);
3788    /**
3789     * The Module class.
3790     *
3791     * @param {Object}  config        The configuration object
3792     * @param {Object}  viewComponent The player's container element
3793     * @constructor
3794     * @private
3795     * @extends {puremvc.Facade}
3796     */
3797    function Module(viewComponent) {
3798      var _this;
3799      babelHelpers.classCallCheck(this, Module);
3800      _this = _puremvc$Facade.call(this, Utils.createUID()) || this;
3801      _this.viewComponent = viewComponent;
3802      _this.performance = {
3803        init: Date.now(),
3804        record: function record(label) {
3805          var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
3806          return this[label] = time;
3807        },
3808        elapsed: function elapsed(label) {
3809          var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "init";
3810          return this[label] - this[start];
3811        }
3812      };
3813      _this.dispatcher = EventDispatcher.create(babelHelpers.assertThisInitialized(_this));
3814      _this.transformer = Transformer.create();
3815      _this.logger = Logger.instance;
3816      _this.moduleMap = {};
3817      _this.emit = _this.dispatch.bind(babelHelpers.assertThisInitialized(_this));
3818      _this.on = _this.addListener = _this.addEventListener.bind(babelHelpers.assertThisInitialized(_this));
3819      _this.off = _this.removeListener = _this.removeEventListener.bind(babelHelpers.assertThisInitialized(_this));
3820      _this.config = null;
3821      _this.oninitialized = null;
3822      _this.onerror = null;
3823      _this.parentModule = null;
3824      _this.ignoreEvents = /(timeupdate|progress|fragmentloaded|fragmentloadstart|timeremaining|adtimeremaining)/;
3825      return _this;
3826    }
3827
3828    /**
3829     * Initialization function.
3830     *
3831     * @param {Object}  config  The plugin's configuration object.
3832     */
3833    babelHelpers.createClass(Module, [{
3834      key: "initialize",
3835      value: function initialize(config, parentModule) {
3836        this.config = config;
3837        this.parentModule = parentModule;
3838        this._id = this.config.id || this.multitonKey;
3839        this.loadModuleResources().then(this.resourcesLoaded.bind(this))["catch"](this.resourcesError.bind(this));
3840      }
3841
3842      /** */
3843    }, {
3844      key: "loadModuleResources",
3845      value: function loadModuleResources() {
3846        var resources = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.config.resources;
3847        if (!(resources != null ? resources.length : void 0) > 0) {
3848          return Promise.resolve();
3849        }
3850        return AMP.addResources(this.evaluatePaths(resources));
3851      }
3852
3853      /** */
3854    }, {
3855      key: "evaluatePaths",
3856      value: function evaluatePaths(path) {
3857        var ref, ref1;
3858        if (path == null) {
3859          return;
3860        }
3861        var paths = this.config.paths || ((ref = this.parentModule) != null ? (ref1 = ref.config) != null ? ref1.paths : void 0 : void 0);
3862        if (paths != null) {
3863          path = DataBinding.evaluateBindings(path, {
3864            paths: paths
3865          });
3866        }
3867        return path;
3868      }
3869
3870      /**
3871       * The resources failed to load.
3872       *
3873       * @private
3874       */
3875    }, {
3876      key: "resourcesError",
3877      value: function resourcesError(error) {
3878        if (this.onerror != null) {
3879          this.onerror(this);
3880        } else {
3881          throw AMPError.create(error);
3882        }
3883      }
3884
3885      /**
3886       * The resources have finished loaded, load the extensions.
3887       *
3888       * @private
3889       */
3890    }, {
3891      key: "resourcesLoaded",
3892      value: function resourcesLoaded() {
3893        this.createFramework();
3894        if (typeof this.oninitialized === "function") {
3895          this.oninitialized(this);
3896        }
3897      }
3898
3899      /**
3900       * Framework based initialization function for defining default
3901       * mvc classes. Meant to be overwritten by base classes.
3902       */
3903    }, {
3904      key: "createFramework",
3905      value: function createFramework() {
3906        this.createModel();
3907        this.createController();
3908        this.createView();
3909      }
3910
3911      /** */
3912    }, {
3913      key: "createModel",
3914      value: function createModel() {
3915        this.registerProxy(new ModuleProxy(this.config));
3916      }
3917
3918      /** */
3919    }, {
3920      key: "createView",
3921      value: function createView() {}
3922
3923      /** */
3924    }, {
3925      key: "createController",
3926      value: function createController() {
3927        this.registerCommand(Notifications.DISPATCH_EVENT, DispatchEventCommand);
3928      }
3929
3930      /** */
3931    }, {
3932      key: "getModuleName",
3933      value: function getModuleName() {
3934        return this.moduleName;
3935      }
3936
3937      /** */
3938    }, {
3939      key: "getId",
3940      value: function getId() {
3941        return this._id;
3942      }
3943    }, {
3944      key: "id",
3945      get: function get() {
3946        return this.getId();
3947      }
3948
3949      /**
3950       * @return {Object} The configuration object.
3951       * @expose
3952       */
3953    }, {
3954      key: "getConfig",
3955      value: function getConfig() {
3956        return this.config;
3957      }
3958
3959      /** */
3960    }, {
3961      key: "hasModule",
3962      value: function hasModule(moduleName) {
3963        return this.moduleMap[moduleName] != null;
3964      }
3965
3966      /** */
3967    }, {
3968      key: "getModules",
3969      value: function getModules() {
3970        var modules = {};
3971        fp.each(this.moduleMap, function (value, key) {
3972          return modules[key] = value.module;
3973        });
3974        return modules;
3975      }
3976
3977      /** */
3978    }, {
3979      key: "registerModule",
3980      value: function registerModule(module) {
3981        var moduleName = module.getModuleName();
3982        if (module == null || this.moduleMap[moduleName] != null) {
3983          return;
3984        }
3985        var adaptor = new ModuleAdapter(module);
3986        this.moduleMap[moduleName] = adaptor;
3987        this.registerMediator(adaptor);
3988        module.onRegister();
3989      }
3990
3991      /** */
3992    }, {
3993      key: "retrieveModule",
3994      value: function retrieveModule(moduleName) {
3995        return this.moduleMap[moduleName].module;
3996      }
3997
3998      /** */
3999    }, {
4000      key: "removeModule",
4001      value: function removeModule(moduleName) {
4002        var adaptor = this.moduleMap[moduleName];
4003        if (adaptor == null) {
4004          return;
4005        }
4006        delete this.moduleMap[moduleName];
4007        this.removeMediator(moduleName);
4008        var module = adaptor.module;
4009        module.onRemove.call(module);
4010        return module;
4011      }
4012
4013      /** List INotification interests. */
4014    }, {
4015      key: "listNotificationInterests",
4016      value: function listNotificationInterests() {
4017        return [];
4018      }
4019
4020      /** List Notification publications */
4021    }, {
4022      key: "listNotificationPublications",
4023      value: function listNotificationPublications() {
4024        return [];
4025      }
4026
4027      /** Get the IMediator's view component. */
4028      // Override this function in sub classes that need to publish additional Notificaions.
4029    }, {
4030      key: "getViewComponent",
4031      value: function getViewComponent() {
4032        return this.viewComponent;
4033      }
4034
4035      /** Set the IMediator's view component. */
4036    }, {
4037      key: "setViewComponent",
4038      value: function setViewComponent(viewComponent) {
4039        this.viewComponent = viewComponent;
4040        return viewComponent;
4041      }
4042
4043      /** Called by the parent module when the Module is registered */
4044    }, {
4045      key: "onRegister",
4046      value: function onRegister() {}
4047
4048      /** Called by the parent module when the Module is removed */
4049    }, {
4050      key: "onRemove",
4051      value: function onRemove() {}
4052
4053      /** Destroys the module */
4054    }, {
4055      key: "destroy",
4056      value: function destroy() {
4057        var proxy = this.retrieveProxy(ModuleProxy.NAME);
4058        if (proxy != null) {
4059          if (typeof proxy.destroy === "function") {
4060            proxy.destroy();
4061          }
4062        }
4063        puremvc.Facade.removeCore(this.multitonKey);
4064        this.dispatcher.destroy();
4065        if (this.viewComponent != null) {
4066          this.viewComponent.innerHTML = "";
4067          this.viewComponent.className = "";
4068        }
4069      }
4070
4071      /**
4072       * Adds a listener for a given event type.
4073       *
4074       * @param {!string}  type  A string representing the event's type.
4075       * @param {!Function} func  A function to call when the event is triggered.
4076       * @expose
4077       */
4078    }, {
4079      key: "addEventListener",
4080      value: function addEventListener(type, func) {
4081        this.dispatcher.addEventListener(type, func);
4082      }
4083
4084      /**
4085       * Adds a listener for a given event type and removes it after it has been triggered once.
4086       */
4087    }, {
4088      key: "once",
4089      value: function once(type, func) {
4090        this.dispatcher.once(type, func);
4091      }
4092
4093      /** */
4094    }, {
4095      key: "logEvent",
4096      value: function logEvent(event) {
4097        if (this.ignoreEvents.test(event.type) === true) {
4098          return;
4099        }
4100        var prefix = this.getModuleName().toUpperCase();
4101        if (event.dispatcher) {
4102          prefix += " " + event.dispatcher;
4103        }
4104        this.logger.log("[".concat(prefix, " EVENT] ").concat(event.type), event);
4105      }
4106
4107      /**
4108       * Dispathes and event, triggering all event listener of the event's type.
4109       *
4110       * @param {!IEvent} event The event to dispatch.
4111       * @expose
4112       */
4113    }, {
4114      key: "dispatchEvent",
4115      value: function dispatchEvent(event) {
4116        var _this2 = this;
4117        this.transform(TransformType.EVENT, event).then(function (result) {
4118          if (result == null) {
4119            return;
4120          }
4121          _this2.logEvent(event);
4122          return _this2.dispatcher.dispatchEvent(event);
4123        });
4124      }
4125
4126      /**
4127       * Dispathes an event, triggering all event listener of the event's type.
4128       *
4129       * @param {!String} type    The type of event to dispatch.
4130       * @param {Object=} detail  Data to pass along with the event.
4131       */
4132    }, {
4133      key: "dispatch",
4134      value: function dispatch(type, detail) {
4135        this.dispatchEvent(Event.create(type, detail));
4136      }
4137
4138      /**
4139       * Removes a listener for a given event type.
4140       *
4141       * @param {!string}  type  A string representing the event's type.
4142       * @param {!Function} func  A function to call when the event is triggered.
4143       * @return {?Function} the handler that was removed if any
4144       * @expose
4145       */
4146    }, {
4147      key: "removeEventListener",
4148      value: function removeEventListener(type, func) {
4149        this.dispatcher.removeEventListener(type, func);
4150      }
4151
4152      /**
4153       * Adds a transform for a given type.
4154       *
4155       * @param {!string}  type  A string representing the event's type.
4156       * @param {!Function} func  A function to call when the event is triggered.
4157       */
4158    }, {
4159      key: "addTransform",
4160      value: function addTransform(type, transform) {
4161        return this.transformer.addTransform(type, transform);
4162      }
4163
4164      /**
4165       * Sorts the transform list by priority. Higher priority Transforms
4166       * are executed first.
4167       *
4168       * @param {!String} type The transform type
4169       * @param {Function=} sort An optional sort function
4170       * @returns {Array.<Function|akamai.amp.Transform>} The sorted list of transforms
4171       */
4172    }, {
4173      key: "sortTransforms",
4174      value: function sortTransforms(type, sort) {
4175        return this.transformer.sortTransforms(type, sort);
4176      }
4177
4178      /**
4179       * Performs a transform for a given type
4180       *
4181       * @param {!String} type The transform type
4182       * @param {!Object} value The value to be transformed
4183       */
4184    }, {
4185      key: "transform",
4186      value: function transform(type, value) {
4187        return this.transformer.transform(type, value);
4188      }
4189
4190      /**
4191       * Removes a transform for a given type.
4192       *
4193       * @param {!string}  type  A string representing the transform's type.
4194       * @param {!Function} transform  A function or Transform object to call when the type is triggered.
4195       * @return {?Function} the transform that was removed if any
4196       */
4197    }, {
4198      key: "removeTransform",
4199      value: function removeTransform(type, transform) {
4200        return this.transformer.removeTransform(type, transform);
4201      }
4202    }]);
4203    return Module;
4204  }(puremvc.Facade);
4205
4206  /**
4207   * @enum {string}
4208   * @const
4209   * @private
4210   */
4211  var PluginNotifications = {
4212    REGISTER_PLUGINS: "registerPlugins",
4213    PLUGIN_REGISTERED: "pluginRegistered",
4214    PLUGINS_INITIALIZED: "pluginsinitialized"
4215  };
4216
4217  var FPS = /*#__PURE__*/function () {
4218    function FPS() {
4219      babelHelpers.classCallCheck(this, FPS);
4220    }
4221    babelHelpers.createClass(FPS, null, [{
4222      key: "extractContentId",
4223      value: function extractContentId(initData, keys) {
4224        var link = document.createElement('a');
4225        link.href = Utils.arrayToString(initData);
4226        return link.hostname;
4227      }
4228    }, {
4229      key: "extractServerUrl",
4230      value: function extractServerUrl(initData, keys) {
4231        return keys.serverURL || keys.serverUrl;
4232      }
4233    }, {
4234      key: "requestCertificate",
4235      value: function requestCertificate(keys) {
4236        var request = {
4237          url: keys.cert,
4238          responseType: "arraybuffer",
4239          headers: {
4240            "Pragma": "Cache-Control: no-cache",
4241            "Cache-Control": "max-age=0"
4242          }
4243        };
4244        return Utils.request(request).then(function (xhr) {
4245          return new Uint8Array(xhr.response);
4246        });
4247      }
4248    }, {
4249      key: "concatInitDataIdAndCertificate",
4250      value: function concatInitDataIdAndCertificate(initData, id, cert) {
4251        if (typeof id === "string") {
4252          id = Utils.stringToArray(id);
4253        }
4254        // layout is [initData][4 byte: idLength][idLength byte: id][4 byte:certLength][certLength byte: cert]
4255        var offset = 0;
4256        var buffer = new ArrayBuffer(initData.byteLength + 4 + id.byteLength + 4 + cert.byteLength);
4257        var dataView = new DataView(buffer);
4258        var initDataArray = new Uint8Array(buffer, offset, initData.byteLength);
4259        initDataArray.set(initData);
4260        offset += initData.byteLength;
4261        dataView.setUint32(offset, id.byteLength, true);
4262        offset += 4;
4263        var idArray = new Uint16Array(buffer, offset, id.length);
4264        idArray.set(id);
4265        offset += idArray.byteLength;
4266        dataView.setUint32(offset, cert.byteLength, true);
4267        offset += 4;
4268        var certArray = new Uint8Array(buffer, offset, cert.byteLength);
4269        certArray.set(cert);
4270        return new Uint8Array(buffer, 0, buffer.byteLength);
4271      }
4272    }, {
4273      key: "requestLicense",
4274      value: function requestLicense(message, contentId, serverUrl, keys) {
4275        var request = {
4276          url: serverUrl,
4277          method: "POST",
4278          responseType: "text",
4279          headers: {
4280            "Content-type": "application/x-www-form-urlencoded"
4281          },
4282          data: "spc=".concat(Utils.base64EncodeUint8Array(message), "&assetId=").concat(encodeURIComponent(contentId))
4283        };
4284        fp.each(keys.httpRequestHeaders, function (value, key) {
4285          return request.headers[key] = value;
4286        });
4287        if (typeof keys.withCredentials === "boolean") {
4288          request.withCredentials = keys.withCredentials;
4289        }
4290        return Utils.request(request).then(function (xhr) {
4291          // response can be of the form: '\n<ckc>base64encoded</ckc>\n'
4292          // so trim the excess:
4293          var keyText = xhr.responseText.trim();
4294          if (keyText.substr(0, 5) === "<ckc>" && keyText.substr(-6) === "</ckc>") {
4295            keyText = keyText.slice(5, -6);
4296          }
4297          return Utils.base64DecodeUint8Array(keyText);
4298        })["catch"](function (error) {
4299          throw "The license request failed.";
4300        });
4301      }
4302    }]);
4303    return FPS;
4304  }();
4305
4306  /**
4307   * @enum {string}
4308   * @const
4309   * @private
4310   */
4311  var DisplayState = {
4312    /**
4313     * Constant representing the normal display state
4314     */
4315    NORMAL: "normal",
4316    /**
4317     * Constant representing the full screen display state
4318     */
4319    FULL_SCREEN: "full-screen",
4320    /**
4321     * Constant representing the full screen display state
4322     */
4323    FULLSCREEN: "full-screen",
4324    /**
4325     * Constant representing the picture in picture display state
4326     */
4327    PICTURE_IN_PICTURE: "picture-in-picture"
4328  };
4329
4330  /**
4331   * @enum {string}
4332   * @const
4333   * @private
4334   */
4335  var PlayState = {
4336    /**
4337     * Constant representing the playing play state
4338     */
4339    READY: "ready",
4340    /**
4341     * Constant representing the playing play state
4342     */
4343    PLAYING: "playing",
4344    /**
4345     * Constant representing the paused play state
4346     */
4347    PAUSED: "paused",
4348    /**
4349     * Constant representing the ended play state
4350     */
4351    ENDED: "ended",
4352    /**
4353     * Constant representing the waiting play state
4354     */
4355    LOADING: "loading",
4356    /**
4357     * Constant representing the waiting play state
4358     */
4359    WAITING: "waiting",
4360    /**
4361     * Constant representing the waiting play state
4362     */
4363    ERROR: "error"
4364  };
4365
4366  /**
4367   * @enum {string}
4368   * @const
4369   * @private
4370   */
4371  var ActiveState = {
4372    /**
4373     * Constant representing the active state (controls on).
4374     */
4375    ACTIVE: "active",
4376    /**
4377     * Constant representing the inactive state (controls off).
4378     */
4379    INACTIVE: "inactive"
4380  };
4381
4382  var ApplicationStateProxy = /*#__PURE__*/function (_puremvc$Proxy) {
4383    babelHelpers.inherits(ApplicationStateProxy, _puremvc$Proxy);
4384    /**
4385     * Used to track the various states of the player like full screen mode and active state (controls visible).
4386     *
4387     * @constructor
4388     * @private
4389     * @extends {puremvc.Proxy}
4390     */
4391    function ApplicationStateProxy() {
4392      var _this;
4393      babelHelpers.classCallCheck(this, ApplicationStateProxy);
4394      _this = _puremvc$Proxy.call(this) || this;
4395      _this.device = Utils.getDevice();
4396      _this.time = {
4397        currentTime: 0,
4398        duration: 0
4399      };
4400      _this.displayState = DisplayState.NORMAL;
4401      _this.playState = null;
4402      _this.activeState = null;
4403      _this.seeking = false;
4404      _this.seekrequested = false;
4405      _this.waiting = false;
4406      _this.busy = false;
4407      _this.volume = 1;
4408      _this.playbackTarget = "amp";
4409      _this.hasPostContent = false;
4410      _this.locked = true; // Lock out the user until media has been assigned
4411      _this.mediaElement = null;
4412      _this.hidden = false;
4413      _this.ended = false;
4414      _this.buffering = false;
4415      _this.playbackRate = 1;
4416      return _this;
4417    }
4418
4419    /** @static */
4420    babelHelpers.createClass(ApplicationStateProxy, [{
4421      key: "getHasPostContent",
4422      value:
4423      /**
4424       * Flag indicating whether or not the media will have additional
4425       * content playback after the media playback is complete
4426       *
4427       * @param {Boolean} value
4428       *    The post content flag
4429       * @returns {Boolean}
4430       *    The post content flag
4431       * @type {Boolean}
4432       */
4433      function getHasPostContent() {
4434        return this.hasPostContent;
4435      }
4436    }, {
4437      key: "setHasPostContent",
4438      value: function setHasPostContent(value) {
4439        this.hasPostContent = value;
4440      }
4441
4442      /**
4443       * Flag indicating whether or not the media playback is complete
4444       *
4445       * @param {Boolean} value
4446       *    The ended flag
4447       * @returns {Boolean}
4448       *    The ended flag
4449       * @type {Boolean}
4450       */
4451    }, {
4452      key: "getEnded",
4453      value: function getEnded() {
4454        return this.ended;
4455      }
4456    }, {
4457      key: "setEnded",
4458      value: function setEnded(value) {
4459        this.ended = value;
4460        if (this.ended === true && this.seeking === true) {
4461          this.seeking = false;
4462        }
4463      }
4464
4465      /**
4466       * The player's display state. Valid options are:
4467       *
4468       * ApplicationStateProxy.FULL_SCREEN
4469       * ApplicationStateProxy.NORMAL
4470       *
4471       * @param {String} value
4472       *    The new display state of the player
4473       * @returns {String}
4474       *    The display state of the player
4475       * @type {String}
4476       */
4477    }, {
4478      key: "getDisplayState",
4479      value: function getDisplayState() {
4480        return this.displayState;
4481      }
4482    }, {
4483      key: "setDisplayState",
4484      value: function setDisplayState(value) {
4485        if (value === this.displayState) {
4486          return;
4487        }
4488        var previous = this.displayState;
4489        this.displayState = value;
4490        this.sendNotification(Notifications.DISPLAY_STATE_CHANGE, {
4491          previous: previous,
4492          value: this.displayState
4493        });
4494      }
4495
4496      /**
4497       * The player's display state. Valid options are:
4498       *
4499       * ApplicationStateProxy.FULL_SCREEN
4500       * ApplicationStateProxy.NORMAL
4501       *
4502       * @param {String} value
4503       *    The new display state of the player
4504       * @returns {String}
4505       *    The display state of the player
4506       * @type {String}
4507       */
4508    }, {
4509      key: "getPlayState",
4510      value: function getPlayState() {
4511        return this.playState;
4512      }
4513    }, {
4514      key: "setPlayState",
4515      value: function setPlayState(value) {
4516        var _this2 = this;
4517        if (this.getWaiting() === true) {
4518          this.setWaiting(false);
4519        }
4520        if (value === this.playState) {
4521          return;
4522        }
4523        var previous = this.playState;
4524        this.playState = value;
4525        this.facade.transform(TransformType.PLAY_STATE, this.playState).then(function (result) {
4526          if (result == null || result === previous) {
4527            return;
4528          }
4529          _this2.sendNotification(Notifications.PLAY_STATE_CHANGE, {
4530            previous: previous,
4531            value: _this2.playState
4532          });
4533          switch (value) {
4534            case PlayState.PLAYING:
4535              return _this2.sendNotification(Notifications.DISPATCH_EVENT, Event.create("playing"));
4536          }
4537        })["catch"](function (error) {
4538          return _this2.sendNotification(Notifications.ERROR, error);
4539        });
4540      }
4541
4542      /**
4543       * The player's device.
4544       *
4545       *
4546       * @returns {String}
4547       *    The display state of the player
4548       * @type {String}
4549       */
4550    }, {
4551      key: "getDevice",
4552      value: function getDevice() {
4553        return this.device;
4554      }
4555
4556      /**
4557       * Indicates whether or not the player is seeking
4558       *
4559       * @param {Boolean} value
4560       *    The seeking flag
4561       * @returns {Boolean}
4562       *    The seeking flag
4563       * @type {Boolean}
4564       */
4565    }, {
4566      key: "getSeeking",
4567      value: function getSeeking() {
4568        return this.seeking;
4569      }
4570    }, {
4571      key: "setSeeking",
4572      value: function setSeeking(value) {
4573        if (value === this.seeking) {
4574          return;
4575        }
4576        this.seeking = value;
4577        if (this.seeking === false && this.playState === PlayState.PAUSED) {
4578          this.setWaiting(false);
4579        }
4580      }
4581
4582      /**
4583       * Indicates whether or not a seek has been requested.
4584       * This is only set when a seek is requested while
4585       * a previously requested seek is in progress
4586       *
4587       * @param {Boolean} value
4588       *    The seekrequested flag
4589       * @returns {Boolean}
4590       *    The seekrequested flag
4591       * @type {Boolean}
4592       */
4593    }, {
4594      key: "getSeekRequested",
4595      value: function getSeekRequested() {
4596        return this.seekrequested;
4597      }
4598    }, {
4599      key: "setSeekRequested",
4600      value: function setSeekRequested(value) {
4601        if (value === this.seekrequested) {
4602          return;
4603        }
4604        this.seekrequested = value;
4605      }
4606
4607      /**
4608       * Indicates whether or not the player is waiting
4609       *
4610       * @param {Boolean} value
4611       *    The waiting flag
4612       * @returns {Boolean}
4613       *    The waiting flag
4614       * @type {Boolean}
4615       */
4616    }, {
4617      key: "getWaiting",
4618      value: function getWaiting() {
4619        return this.waiting;
4620      }
4621    }, {
4622      key: "setWaiting",
4623      value: function setWaiting(value) {
4624        var _this3 = this;
4625        if (value === this.waiting) {
4626          return;
4627        }
4628        this.waiting = value;
4629        var note = this.waiting === true ? Notifications.ADD_APPLICATION_STATE : Notifications.REMOVE_APPLICATION_STATE;
4630        this.sendNotification(note, PlayState.WAITING);
4631        if (this.waiting === true) {
4632          var clear = function clear() {
4633            _this3.facade.removeEventListener("timeupdate", update);
4634            _this3.facade.removeEventListener("playing", handler);
4635            _this3.facade.removeEventListener("canplaythrough", handler);
4636            _this3.facade.removeEventListener("ended", handler);
4637          };
4638          var handler = function handler() {
4639            clear();
4640            _this3.setWaiting(false);
4641          };
4642          var update = function update(event) {
4643            if (_this3.facade.seeking === false) {
4644              handler();
4645            }
4646          };
4647          this.facade.addEventListener("timeupdate", update);
4648          this.facade.addEventListener("playing", handler);
4649          this.facade.addEventListener("canplaythrough", handler);
4650          this.facade.addEventListener("ended", handler);
4651        }
4652      }
4653
4654      /**
4655       * Indicates whether or not the player is busy
4656       *
4657       * @param {Boolean} value
4658       *    The busy flag
4659       * @returns {Boolean}
4660       *    The busy flag
4661       * @type {Boolean}
4662       */
4663    }, {
4664      key: "getBusy",
4665      value: function getBusy() {
4666        return this.busy;
4667      }
4668    }, {
4669      key: "setBusy",
4670      value: function setBusy(value) {
4671        if (value === this.busy) {
4672          return;
4673        }
4674        this.busy = value;
4675        this.sendNotification(Notifications.DISPATCH_EVENT, Event.create("busy", value));
4676      }
4677
4678      /**
4679       * Indicates whether or not the player is locked.
4680       * A lock player will not autoplay even if configured
4681       * to do so.
4682       *
4683       * @param {Boolean} value
4684       *    The locked flag
4685       * @returns {Boolean}
4686       *    The locked flag
4687       * @type {Boolean}
4688       */
4689    }, {
4690      key: "getLocked",
4691      value: function getLocked() {
4692        return this.locked;
4693      }
4694    }, {
4695      key: "setLocked",
4696      value: function setLocked(value) {
4697        this.locked = value;
4698      }
4699
4700      /**
4701       * Indicates whether or not the player is buffering.
4702       *
4703       * @param {Boolean} value
4704       *    The buffering flag
4705       * @returns {Boolean}
4706       *    The buffering flag
4707       * @type {Boolean}
4708       */
4709    }, {
4710      key: "getBuffering",
4711      value: function getBuffering() {
4712        return this.buffering;
4713      }
4714    }, {
4715      key: "setBuffering",
4716      value: function setBuffering(value) {
4717        this.buffering = value;
4718      }
4719
4720      /**
4721       * The medium the player is currently playing. Valid options are:
4722       *
4723       * "audio"
4724       * "video"
4725       *
4726       * @param {String} value
4727       *    The new medium
4728       *
4729       * @returns {String}
4730       *    The current medium
4731       *
4732       * @type {String}
4733       */
4734    }, {
4735      key: "getMedium",
4736      value: function getMedium() {
4737        return this.medium;
4738      }
4739    }, {
4740      key: "setMedium",
4741      value: function setMedium(value) {
4742        if (value === this.medium) {
4743          return;
4744        }
4745        var previous = this.medium != null ? "medium-" + this.medium : this.medium;
4746        this.medium = value;
4747        this.sendNotification(Notifications.MEDIUM_CHANGE, {
4748          previous: previous,
4749          value: "medium-".concat(this.medium)
4750        });
4751      }
4752
4753      /**
4754       * The player's volume as a value between 0 and 1.
4755       *
4756       * @param {Number} value
4757       *    The new volume
4758       *
4759       * @returns {Number}
4760       *    The current volume
4761       *
4762       * @type {Number}
4763       */
4764    }, {
4765      key: "getVolume",
4766      value: function getVolume() {
4767        return this.volume;
4768      }
4769    }, {
4770      key: "setVolume",
4771      value: function setVolume(value) {
4772        if (value === this.volume) {
4773          return;
4774        }
4775        return this.volume = value;
4776      }
4777
4778      /**
4779       * The playback target. i.e. "amp", "chromecast", "airplay"
4780       *
4781       * @param {Number} value
4782       *    The new volume
4783       *
4784       * @returns {Number}
4785       *    The current volume
4786       *
4787       * @type {Number}
4788       */
4789    }, {
4790      key: "getPlaybackTarget",
4791      value: function getPlaybackTarget() {
4792        return this.playbackTarget;
4793      }
4794    }, {
4795      key: "setPlaybackTarget",
4796      value: function setPlaybackTarget(value) {
4797        if (value === this.playbackTarget) {
4798          return;
4799        }
4800        var previous = this.playbackTarget;
4801        this.playbackTarget = value;
4802        if (value !== "amp") {
4803          if (this.getPlayState() !== PlayState.PAUSED) {
4804            this.facade.pause();
4805          }
4806        } else {
4807          if (this.getPlayState() === PlayState.PLAYING) {
4808            this.facade.play();
4809          }
4810        }
4811        this.sendNotification(Notifications.PLAYBACK_TARGET_CHANGE, {
4812          previous: previous,
4813          value: this.playbackTarget
4814        });
4815      }
4816
4817      /**
4818       * The active state of the player. Used to display controls.
4819       *
4820       * @param {Boolean} value
4821       *    The new active state of the video
4822       * @returns {Boolean}
4823       *    The active state of the video
4824       * @type {Boolean}
4825       */
4826    }, {
4827      key: "getActiveState",
4828      value: function getActiveState() {
4829        return this.activeState;
4830      }
4831    }, {
4832      key: "setActiveState",
4833      value: function setActiveState(value) {
4834        if (value === this.activeState) {
4835          return;
4836        }
4837        var previous = this.activeState;
4838        this.activeState = value;
4839        this.sendNotification(Notifications.ACTIVE_STATE_CHANGE, {
4840          previous: previous,
4841          value: this.activeState
4842        });
4843      }
4844
4845      /**
4846       * The player's media element
4847       *
4848       * @param {HTMLElement} value
4849       *    The new media element
4850       * @returns {HTMLElement}
4851       *    The media element
4852       * @type {HTMLElement}
4853       */
4854    }, {
4855      key: "getMediaElement",
4856      value: function getMediaElement() {
4857        return this.mediaElement;
4858      }
4859    }, {
4860      key: "setMediaElement",
4861      value: function setMediaElement(value) {
4862        if (value === this.mediaElement) {
4863          return;
4864        }
4865        var previous = this.mediaElement;
4866        if (previous != null) {
4867          value.volume = previous.volume;
4868          value.muted = previous.muted;
4869        }
4870        this.mediaElement = value;
4871        this.sendNotification(Notifications.MEDIA_ELEMENT_CHANGE, {
4872          previous: previous,
4873          value: this.mediaElement
4874        });
4875      }
4876
4877      /**
4878       * The player's hidden state
4879       *
4880       * @param {Boolean} value
4881       *    The new hidden state
4882       * @returns {Boolean}
4883       *    The hidden state
4884       * @type {Boolean}
4885       */
4886    }, {
4887      key: "getHidden",
4888      value: function getHidden() {
4889        return this.hidden;
4890      }
4891    }, {
4892      key: "setHidden",
4893      value: function setHidden(value) {
4894        if (value === this.hidden) {
4895          return;
4896        }
4897        var previous = this.hidden;
4898        this.hidden = value;
4899        this.sendNotification(Notifications.HIDDEN_CHANGE, {
4900          previous: previous,
4901          value: this.hidden
4902        });
4903      }
4904
4905      /**
4906       * The media's current time
4907       *
4908       * @param {Number} value
4909       *    The new current time
4910       * @returns {Number}
4911       *    The current time
4912       * @type {Number}
4913       */
4914    }, {
4915      key: "getCurrentTime",
4916      value: function getCurrentTime() {
4917        return this.time.currentTime;
4918      }
4919    }, {
4920      key: "setCurrentTime",
4921      value: function setCurrentTime(value) {
4922        if (value === this.time.currentTime || value < 0) {
4923          return;
4924        }
4925        this.time.currentTime = value;
4926        this.sendNotification(Notifications.TIME_UPDATE, value);
4927      }
4928
4929      /**
4930       * The media's duration
4931       *
4932       * @param {Number} value
4933       *    The new duration
4934       * @returns {Number}
4935       *    The duration
4936       * @type {Number}
4937       */
4938    }, {
4939      key: "getDuration",
4940      value: function getDuration() {
4941        return this.time.duration;
4942      }
4943    }, {
4944      key: "setDuration",
4945      value: function setDuration(value) {
4946        if (value === this.time.duration) {
4947          return;
4948        }
4949        this.time.duration = value;
4950        this.sendNotification(Notifications.DURATION_CHANGE, value);
4951      }
4952
4953      /**
4954       * The playback rate
4955       *
4956       * @param {Number} value
4957       *     The new playback rate
4958       * @returns {Number}
4959       *     The playback rate
4960       * @type {Number}
4961       */
4962    }, {
4963      key: "getPlaybackRate",
4964      value: function getPlaybackRate() {
4965        return this.playbackRate;
4966      }
4967    }, {
4968      key: "setPlaybackRate",
4969      value: function setPlaybackRate(value) {
4970        if (value === this.playbackRate) {
4971          return;
4972        }
4973        this.playbackRate = value;
4974        this.sendNotification(Notifications.PLAYBACK_RATE_CHANGE, value);
4975      }
4976    }], [{
4977      key: "NAME",
4978      get: function get() {
4979        return "ApplicationStateProxy";
4980      }
4981    }]);
4982    return ApplicationStateProxy;
4983  }(puremvc.Proxy);
4984
4985  /**
4986   * @enum {string}
4987   * @const
4988   * @private
4989   */
4990  var AuthEvents = {
4991    AUTHENTICATE: "authenticate",
4992    AUTHENTICATED: "authenticated",
4993    AUTHENTICATION_FAILED: "authenticationfailed",
4994    AUTHORIZE: "authorize",
4995    AUTHORIZED: "authorized",
4996    AUTHORIZATION_FAILED: "authorizationfailed",
4997    AUTHORIZATION_EXPIRED: "authorizationexpired",
4998    CHOOSE_PROVIDER: "chooseprovider",
4999    ASSET_AUTHORIZED: "assetauthorized",
5000    ASSET_AUTHORIZATION_FAILED: "assetauthorizationfailed"
5001  };
5002
5003  var SecurityProxy = /*#__PURE__*/function (_puremvc$Proxy) {
5004    babelHelpers.inherits(SecurityProxy, _puremvc$Proxy);
5005    /**
5006     * Creates a new instance of SecurityProxy.
5007     *
5008     * @constructor
5009     * @private
5010     * @extends {puremvc.Proxy}
5011     */
5012    function SecurityProxy() {
5013      var _this;
5014      babelHelpers.classCallCheck(this, SecurityProxy);
5015      _this = _puremvc$Proxy.call(this, SecurityProxy.NAME, {}) || this;
5016      _this._authorized = true;
5017      _this._session = null;
5018      _this.data = null;
5019      _this.timeout = null;
5020      return _this;
5021    }
5022
5023    /**
5024     * @static
5025     * @type {string}
5026     */
5027    babelHelpers.createClass(SecurityProxy, [{
5028      key: "setMedia",
5029      value: /** */
5030      function setMedia(media) {
5031        this.setSession(null);
5032        var authorized = media.status.state !== "blocked" && media.restriction.length === 0;
5033        this.setAuthorized(authorized);
5034        this.setAuthorization(media.authorization);
5035      }
5036
5037      /** */
5038    }, {
5039      key: "authorize",
5040      value: function authorize(authorization) {
5041        this.setAuthorization(authorization);
5042        this.sendNotification(AuthEvents.AUTHORIZED, authorization);
5043      }
5044
5045      /** */
5046    }, {
5047      key: "getAuthorization",
5048      value: function getAuthorization() {
5049        return this.data;
5050      }
5051    }, {
5052      key: "setAuthorization",
5053      value: function setAuthorization(value) {
5054        if ((value != null ? value.token : void 0) != null) {
5055          this.setAuthorized(true);
5056        }
5057        this.data = value || {};
5058        if (this.data.expiration != null) {
5059          this.setExpiration(this.data.expiration);
5060        }
5061        return value;
5062      }
5063
5064      /** */
5065    }, {
5066      key: "getKey",
5067      value: function getKey() {
5068        return this.data.key;
5069      }
5070    }, {
5071      key: "setKey",
5072      value: function setKey(value) {
5073        this.data.key = value;
5074        return value;
5075      }
5076
5077      /** */
5078    }, {
5079      key: "getToken",
5080      value: function getToken() {
5081        return this.data.token;
5082      }
5083    }, {
5084      key: "setToken",
5085      value: function setToken(value) {
5086        this.data.token = value;
5087        return value;
5088      }
5089
5090      /** */
5091    }, {
5092      key: "getExpiration",
5093      value: function getExpiration() {
5094        return this.data.expiration;
5095      }
5096    }, {
5097      key: "setExpiration",
5098      value: function setExpiration(value) {
5099        this.data.expiration = value;
5100        if (this.data.expiration > Date.now()) {
5101          this.startTimeout();
5102        }
5103        return value;
5104      }
5105
5106      /** */
5107    }, {
5108      key: "startTimeout",
5109      value: function startTimeout() {
5110        var _this2 = this;
5111        Utils.getUTC().then(function (time) {
5112          var timeout = function timeout() {
5113            _this2.sendNotification(AuthEvents.AUTHORIZATION_EXPIRED);
5114            _this2.sendNotification(AuthEvents.AUTHORIZE, {
5115              media: _this2.facade.getMedia()
5116            });
5117          };
5118          return _this2.timeout = _this2.facade.timers.setTimeout(timeout, _this2.getExpiration() - time);
5119        });
5120      }
5121
5122      /** */
5123    }, {
5124      key: "stopTimeout",
5125      value: function stopTimeout() {
5126        clearTimeout(this.timeout);
5127      }
5128
5129      /** */
5130    }, {
5131      key: "getSecret",
5132      value: function getSecret() {
5133        if (this.data == null || this.data.token == null) {
5134          return null;
5135        }
5136        var secret = "";
5137        if (this.data.token != null) {
5138          secret = "".concat(this.data.token);
5139        }
5140        if (this.data.key != null) {
5141          secret = "".concat(this.data.key, "=").concat(secret);
5142        }
5143        return secret;
5144      }
5145
5146      /** */
5147    }, {
5148      key: "createURL",
5149      value: function createURL(url) {
5150        var secret = this.getSecret();
5151        if (secret != null) {
5152          url += !/\?/.test(url) ? "?" : "&";
5153          url += secret;
5154        }
5155        return url;
5156      }
5157
5158      /** */
5159    }, {
5160      key: "getAuthorized",
5161      value: function getAuthorized() {
5162        return this._authorized;
5163      }
5164    }, {
5165      key: "setAuthorized",
5166      value: function setAuthorized(value) {
5167        this.stopTimeout();
5168        this._authorized = value;
5169        return value;
5170      }
5171
5172      /** */
5173    }, {
5174      key: "authorized",
5175      get: function get() {
5176        return this.getAuthorized();
5177      }
5178
5179      /** */
5180    }, {
5181      key: "getSession",
5182      value: function getSession() {
5183        return this._session;
5184      }
5185    }, {
5186      key: "setSession",
5187      value: function setSession(value) {
5188        this._session = value;
5189        return value;
5190      }
5191    }], [{
5192      key: "NAME",
5193      get: function get() {
5194        return "SecurityProxy";
5195      }
5196    }]);
5197    return SecurityProxy;
5198  }(puremvc.Proxy);
5199
5200  var ConfigurationProxy = /*#__PURE__*/function (_ModuleProxy) {
5201    babelHelpers.inherits(ConfigurationProxy, _ModuleProxy);
5202    /**
5203     * Creates a new instance of MediaProxy.
5204     *
5205     * @constructor
5206     * @private
5207     */
5208    function ConfigurationProxy(config) {
5209      var _this;
5210      babelHelpers.classCallCheck(this, ConfigurationProxy);
5211      _this = _ModuleProxy.call(this, config) || this;
5212      _this.defaults = Config.defaults;
5213      return _this;
5214    }
5215
5216    /**
5217     * @static
5218     * @type {string}
5219     */
5220    babelHelpers.createClass(ConfigurationProxy, [{
5221      key: "getValueOf",
5222      value:
5223      /**
5224       *
5225       */
5226      function getValueOf(name) {
5227        var _this2 = this;
5228        var overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5229        var media = this.facade.getMedia() || {};
5230        var metadata = media.metadata || {};
5231        var config = metadata.config || {};
5232        var retrieve = function retrieve() {
5233          // The old approach was to put overrides directly on the media object
5234          var value = media[name];
5235          if (value != null) {
5236            return value;
5237          }
5238          // Then we created the media.metadata property to stop polluting the media object
5239          value = metadata[name];
5240          if (value != null) {
5241            return value;
5242          }
5243          // Then media metadata became an mess, so we defined a specific property for config overrides
5244          value = config[name];
5245          if (value != null) {
5246            return value;
5247          }
5248          // Additionally, plugins have their own configs which can override certain properties
5249          value = overrides[name];
5250          if (value != null) {
5251            return value;
5252          }
5253          // Now check the actual config data which is set by the ConfigurationProxy API
5254          value = _this2.data[name];
5255          if (value != null) {
5256            return value;
5257          }
5258          // Finally check the original data that was passed in at player creation
5259          value = _this2.config[name];
5260          if (value != null) {
5261            return value;
5262          }
5263        };
5264        try {
5265          return this.facade.evaluateBindings(retrieve());
5266        } catch (error) {
5267          return null;
5268        }
5269      }
5270
5271      /**
5272       * Player ID
5273       */
5274    }, {
5275      key: "getPID",
5276      value: function getPID() {
5277        return this.data.pid;
5278      }
5279
5280      /**
5281       * Plays iniline
5282       */
5283    }, {
5284      key: "getPlaysInline",
5285      value: function getPlaysInline() {
5286        return this.data.playsinline;
5287      }
5288
5289      /**
5290       * Plays iniline
5291       */
5292    }, {
5293      key: "getMuted",
5294      value: function getMuted() {
5295        return this.getValueOf("muted");
5296      }
5297    }, {
5298      key: "setMuted",
5299      value: function setMuted(value) {
5300        this.data.muted = value;
5301        return value;
5302      }
5303
5304      /**
5305       * With credentials
5306       */
5307    }, {
5308      key: "getWithCredentials",
5309      value: function getWithCredentials() {
5310        return this.getValueOf("withCredentials");
5311      }
5312    }, {
5313      key: "setWithCredentials",
5314      value: function setWithCredentials(value) {
5315        this.data.withCredentials = value;
5316        return value;
5317      }
5318
5319      /**
5320       * Autoplay.
5321       */
5322    }, {
5323      key: "getAutoplay",
5324      value: function getAutoplay() {
5325        return this.getValueOf("autoplay");
5326      }
5327    }, {
5328      key: "setAutoplay",
5329      value: function setAutoplay(value) {
5330        this.data.autoplay = value;
5331        return value;
5332      }
5333
5334      /**
5335       * Autoplay Policy.
5336       */
5337    }, {
5338      key: "getAutoplayPolicy",
5339      value: function getAutoplayPolicy() {
5340        return this.getValueOf("autoplayPolicy");
5341      }
5342    }, {
5343      key: "setAutoplayPolicy",
5344      value: function setAutoplayPolicy(value) {
5345        this.data.autoplayPolicy = value;
5346        return value;
5347      }
5348
5349      /**
5350       * Loop.
5351       */
5352    }, {
5353      key: "getLoop",
5354      value: function getLoop() {
5355        return this.getValueOf("loop");
5356      }
5357    }, {
5358      key: "setLoop",
5359      value: function setLoop(value) {
5360        this.data.loop = value;
5361        return value;
5362      }
5363
5364      /**
5365       * Settings.
5366       */
5367    }, {
5368      key: "getSettings",
5369      value: function getSettings() {
5370        return this.data.settings;
5371      }
5372    }, {
5373      key: "setSettings",
5374      value: function setSettings(value) {
5375        this.data.settings = value;
5376        return value;
5377      }
5378
5379      /**
5380       * The player paths.
5381       */
5382    }, {
5383      key: "getPaths",
5384      value: function getPaths() {
5385        return this.data.paths;
5386      }
5387    }, {
5388      key: "setPaths",
5389      value: function setPaths(value) {
5390        this.data.paths = value;
5391        return value;
5392      }
5393
5394      /**
5395       * The player version.
5396       */
5397    }, {
5398      key: "getVersion",
5399      value: function getVersion() {
5400        return this.data.version;
5401      }
5402
5403      /**
5404       * Controls
5405       */
5406    }, {
5407      key: "getControls",
5408      value: function getControls() {
5409        return this.getValueOf("controls") === true;
5410      }
5411    }, {
5412      key: "setControls",
5413      value: function setControls(value) {
5414        this.data.controls = value;
5415        return value;
5416      }
5417
5418      /**
5419       * Fullscreen configuration
5420       */
5421    }, {
5422      key: "getFullscreen",
5423      value: function getFullscreen() {
5424        return this.data.fullscreen || {};
5425      }
5426    }, {
5427      key: "setFullscreen",
5428      value: function setFullscreen(value) {
5429        this.data.fullscreen = value;
5430        return value;
5431      }
5432
5433      /**
5434       * Language configuration
5435       */
5436    }, {
5437      key: "getLanguage",
5438      value: function getLanguage() {
5439        return this.data.language;
5440      }
5441
5442      /**
5443       * Preload.
5444       */
5445    }, {
5446      key: "getPreload",
5447      value: function getPreload() {
5448        return this.getValueOf("preload");
5449      }
5450    }, {
5451      key: "setPreload",
5452      value: function setPreload(value) {
5453        this.data.preload = value;
5454        return value;
5455      }
5456    }], [{
5457      key: "NAME",
5458      get: function get() {
5459        return ModuleProxy.NAME;
5460      }
5461    }]);
5462    return ConfigurationProxy;
5463  }(ModuleProxy);
5464
5465  var Track = /*#__PURE__*/function (_EventDispatcher) {
5466    babelHelpers.inherits(Track, _EventDispatcher);
5467    function Track() {
5468      var _this;
5469      var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5470      babelHelpers.classCallCheck(this, Track);
5471      _this = _EventDispatcher.call(this) || this;
5472      _this.data = data;
5473      Object.defineProperties(babelHelpers.assertThisInitialized(_this), {
5474        kind: {
5475          get: _this.getKind,
5476          enumerable: true,
5477          configurable: false
5478        },
5479        label: {
5480          get: _this.getLabel,
5481          enumerable: true,
5482          configurable: false
5483        },
5484        language: {
5485          get: _this.getLanguage,
5486          enumerable: true,
5487          configurable: false
5488        },
5489        id: {
5490          get: _this.getId,
5491          enumerable: true,
5492          configurable: false
5493        },
5494        enabled: {
5495          get: _this.getEnabled,
5496          set: _this.setEnabled,
5497          enumerable: true,
5498          configurable: false
5499        }
5500      });
5501      return _this;
5502    }
5503
5504    // readonly attribute DOMString kind;
5505    babelHelpers.createClass(Track, [{
5506      key: "getKind",
5507      value: function getKind() {
5508        return this.data.kind;
5509      }
5510
5511      // readonly attribute DOMString label;
5512    }, {
5513      key: "getLabel",
5514      value: function getLabel() {
5515        return this.data.label;
5516      }
5517
5518      // readonly attribute DOMString language;
5519    }, {
5520      key: "getLanguage",
5521      value: function getLanguage() {
5522        return this.data.language;
5523      }
5524
5525      // readonly attribute DOMString id;
5526    }, {
5527      key: "getId",
5528      value: function getId() {
5529        return this.data.id;
5530      }
5531    }, {
5532      key: "setEnabled",
5533      value: function setEnabled(value) {
5534        if (value === this.data.enabled) {
5535          return;
5536        }
5537        this.data.enabled = value;
5538        this.changeEnabled(value);
5539        this.dispatchEvent("change");
5540      }
5541    }, {
5542      key: "changeEnabled",
5543      value: function changeEnabled(value) {}
5544    }, {
5545      key: "getEnabled",
5546      value: function getEnabled() {
5547        return this.data.enabled;
5548      }
5549    }, {
5550      key: "flatten",
5551      value: function flatten() {
5552        return {
5553          kind: this.getKind(),
5554          label: this.getLabel(),
5555          language: this.getLanguage(),
5556          id: this.getId(),
5557          enabled: this.getEnabled()
5558        };
5559      }
5560    }]);
5561    return Track;
5562  }(EventDispatcher);
5563
5564  var TrackMode = {
5565    SHOWING: "showing",
5566    HIDDEN: "hidden",
5567    DISABLED: "disabled"
5568  };
5569
5570  /**
5571   * @enum {string}
5572   * @const
5573   * @private
5574   */
5575  var CaptioningNotifications = {
5576    VISIBILITY_CHANGE: "captioningvisibilitychange",
5577    ENABLED: "captioningenabled",
5578    TRACKS_LOADED: "captioningtracksloaded",
5579    TRACK_SELECTED: "captioningtrackselected",
5580    CHANGE_CUE: "captioningchangecue",
5581    CUE_CHANGE: "captioningcuechange",
5582    SETTINGS_VISIBILITY_CHANGE: "captioningsettingsvisibility",
5583    SETTINGS_CHANGE: "captioningsettingschange",
5584    TTML_CUE_CHANGE: "captioningttmlcuechange"
5585  };
5586
5587  var Cue = /*#__PURE__*/function () {
5588    /**
5589     * The Cue class.
5590     *
5591     * @constructor
5592     * @private
5593     * @param {number} startTime  The start time of the cue in seconds
5594     * @param {number} endTime    The end time of the cue in seconds
5595     * @param {number} data       The cue data
5596     */
5597    function Cue(startTime) {
5598      var endTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.startTime;
5599      var data = arguments.length > 2 ? arguments[2] : undefined;
5600      var id = arguments.length > 3 ? arguments[3] : undefined;
5601      var style = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
5602      babelHelpers.classCallCheck(this, Cue);
5603      this.startTime = startTime;
5604      this.endTime = endTime;
5605      this.data = data;
5606      this.id = id;
5607      this.style = style;
5608    }
5609
5610    /** */
5611    babelHelpers.createClass(Cue, null, [{
5612      key: "create",
5613      value: function create(startTime, endTime, data, id, style) {
5614        return new Cue(startTime, endTime, data, id, style);
5615      }
5616    }]);
5617    return Cue;
5618  }();
5619
5620  var CaptionCue = /*#__PURE__*/function (_Cue) {
5621    babelHelpers.inherits(CaptionCue, _Cue);
5622    function CaptionCue() {
5623      babelHelpers.classCallCheck(this, CaptionCue);
5624      return _Cue.apply(this, arguments) || this;
5625    }
5626    babelHelpers.createClass(CaptionCue, [{
5627      key: "text",
5628      get: function get() {
5629        return this.data.text;
5630      },
5631      set: function set(value) {
5632        this.data.text = value;
5633      }
5634    }, {
5635      key: "html",
5636      get: function get() {
5637        return this.data.html;
5638      },
5639      set: function set(value) {
5640        this.data.html = value;
5641      }
5642    }, {
5643      key: "raw",
5644      get: function get() {
5645        return this.data.raw;
5646      }
5647
5648      /** */
5649    }], [{
5650      key: "create",
5651      value: function create(startTime, endTime, data, id, style) {
5652        return new CaptionCue(startTime, endTime, data, id, style);
5653      }
5654    }]);
5655    return CaptionCue;
5656  }(Cue);
5657
5658  var XMLUtils = /*#__PURE__*/function () {
5659    function XMLUtils() {
5660      babelHelpers.classCallCheck(this, XMLUtils);
5661    }
5662    babelHelpers.createClass(XMLUtils, null, [{
5663      key: "createTextContent",
5664      value: function createTextContent(xml, text) {
5665        var node = /[\&<>]/.test(text) ? xml.createCDATASection(text) : xml.createTextNode(text);
5666        return node;
5667      }
5668    }, {
5669      key: "updateTextContent",
5670      value: function updateTextContent(node, str) {
5671        var text = XMLUtils.createTextContent(node.ownerDocument, str);
5672        node.removeChild(node.childNodes[0]);
5673        node.appendChild(text);
5674        return node;
5675      }
5676    }, {
5677      key: "serialize",
5678      value: function serialize(xml) {
5679        if (xml == null) {
5680          return;
5681        }
5682        if (typeof xml === "string") {
5683          return xml;
5684        }
5685        try {
5686          var serializer = new XMLSerializer();
5687          return serializer.serializeToString(xml);
5688        } catch (error) {}
5689      }
5690    }, {
5691      key: "parse",
5692      value: function parse(text) {
5693        var parser = new DOMParser();
5694        return parser.parseFromString(text, "application/xml");
5695      }
5696    }]);
5697    return XMLUtils;
5698  }();
5699
5700  var SMPTETTParser = /*#__PURE__*/function () {
5701    function SMPTETTParser() {
5702      babelHelpers.classCallCheck(this, SMPTETTParser);
5703    }
5704    babelHelpers.createClass(SMPTETTParser, [{
5705      key: "parse",
5706      value:
5707      /**
5708       * Parses a SMPTETT file into CaptionCue objects and attaches them to a given track.
5709       *
5710       * @param   {XMLDocument}   xml   The SMPTETT xml document
5711       * @param   {CaptionTrack}  track The caption track to populate
5712       * @return  {CaptionTrack}        The populated caption track
5713       */
5714      function parse(xml) {
5715        var track = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CaptionTrack.create({
5716          kind: "captions",
5717          type: Utils.mimeTypes.ttml
5718        });
5719        var captions, styledElements, styles;
5720        if (typeof xml === "string") {
5721          // Styles
5722          xml = XMLUtils.parse(xml);
5723        }
5724        styles = Array.prototype.slice.call(xml.querySelectorAll("styling style"));
5725        styles.forEach(function (item, index, list) {
5726          var attributes, id, style;
5727          style = "";
5728          id = item.getAttribute("id") || item.getAttribute("xml:id");
5729          attributes = Array.prototype.slice.call(item.attributes);
5730          attributes.forEach(function (item, index, array) {
5731            if (item.prefix === "tts") {
5732              return style += Utils.toHyphenated(item.localName) + ":" + item.nodeValue + ";";
5733            }
5734          });
5735          track.styles[id] = style;
5736        });
5737        styledElements = Array.prototype.slice.call(xml.querySelectorAll("body [style]"));
5738        styledElements.forEach(function (item, index, array) {
5739          var id;
5740          id = item.getAttribute("style");
5741          item.setAttribute("style", track.styles[id]);
5742        });
5743        captions = Array.prototype.slice.call(xml.querySelectorAll("body p[begin]"));
5744        captions.forEach(function (item, index, array) {
5745          var align, cue, end, html, start, style, text;
5746          // get start time
5747          start = item.getAttribute("begin");
5748          item.removeAttribute("begin");
5749          // get end time
5750          if (item.getAttribute("end") != null) {
5751            end = item.getAttribute("end");
5752            item.removeAttribute("end");
5753          } else if (captions[index + 1] != null) {
5754            end = captions[index + 1].getAttribute("begin");
5755          }
5756          // get alignment
5757          align = item.getAttributeNS("http://www.w3.org/ns/ttml#styling", "textAlign");
5758          if (align != null) {
5759            style = {
5760              align: align === "center" ? "middle" : align
5761            };
5762            item.removeAttributeNS("http://www.w3.org/ns/ttml#styling", "textAlign");
5763          }
5764          // get raw text
5765          text = XMLUtils.serialize(item);
5766          // get html for non-native implementations
5767          text = text.replace(/\s*xmlns="[^"]*"/, "");
5768          html = text;
5769          // get text for native implementations
5770          text = text.replace(/^<p[^>]*>/, "");
5771          text = text.replace(/<\/p>$/, "");
5772          text = text.replace(/<br\/>/, "\n");
5773          text = text.replace(/<span style="([^"]*)"/, "<c.$1");
5774          text = text.replace(/<\/span>/, "</c>");
5775          // create generic cue
5776          cue = CaptionCue.create(Utils.flattenTimecode(start), Utils.flattenTimecode(end), {
5777            text: text,
5778            html: html
5779          }, "".concat(index), style);
5780          // add the cue to the track
5781          track.cues.push(cue);
5782        });
5783        return track;
5784      }
5785    }]);
5786    return SMPTETTParser;
5787  }();
5788
5789  var SRTParser = /*#__PURE__*/function () {
5790    function SRTParser() {
5791      babelHelpers.classCallCheck(this, SRTParser);
5792    }
5793    babelHelpers.createClass(SRTParser, [{
5794      key: "parse",
5795      value:
5796      /**
5797       * Parses a SRT (subrip) file into CaptionCue objects and attaches them to a given track.
5798       *
5799       * @param   {String}        txt   The text of the srt file
5800       * @param   {CaptionTrack}  track The caption track to populate
5801       * @return  {CaptionTrack}        The populated caption track
5802       */
5803      function parse(txt) {
5804        var track = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CaptionTrack.create({
5805          kind: "captions",
5806          type: Utils.mimeTypes.srt
5807        });
5808        // replace windows line breaks
5809        txt = txt.replace(/\r/g, '');
5810
5811        // split up the caption chunks
5812        var captions = txt.split("\n\n");
5813        fp.each(captions, function (caption) {
5814          // split up the caption parts
5815          var parts = caption.split("\n");
5816          try {
5817            var index = parts[0];
5818            var times = parts[1].match(/([0-9:\,]+)\s*-->\s*([0-9:\,]+)/).slice(1);
5819            var start = Utils.flattenTimecode(times[0]);
5820            var end = Utils.flattenTimecode(times[1]);
5821            var text = parts.slice(2);
5822
5823            // create generic cue
5824            var cue = CaptionCue.create(start, end, {
5825              text: text.join("\n"),
5826              html: "<p>" + text.join("<br />") + "</p>"
5827            });
5828
5829            // // add the cue to the track
5830            track.cues.push(cue);
5831          } catch (error) {
5832            Logger.instance.warn("SRT Parsing Warning");
5833          }
5834        });
5835        return track;
5836      }
5837    }]);
5838    return SRTParser;
5839  }();
5840
5841  var WebVTTParser = /*#__PURE__*/function () {
5842    function WebVTTParser() {
5843      babelHelpers.classCallCheck(this, WebVTTParser);
5844    }
5845    babelHelpers.createClass(WebVTTParser, [{
5846      key: "parseCaption",
5847      value:
5848      /**
5849       * Parses a single WebVTT caption into a CaptionCue.
5850       *
5851       * @param   {String}        txt   The text of the caption
5852       * @return  {CaptionCue}          The CaptionCue
5853       */
5854      function parseCaption(caption) {
5855        var id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
5856        var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5857        // split up the caption parts
5858        var parts = caption.trim().split("\n");
5859        var timecode = /([0-9:\.]+)\s*-->\s*([0-9:\.]+)([^\n]*)/;
5860        var setting = /\s*([A-Za-z]+)\s*:\s*([\w\-\%]+)/g;
5861        try {
5862          if (!timecode.test(parts[0])) {
5863            id = parts.shift();
5864          }
5865          var times = parts[0].match(timecode).slice(1);
5866          var settings = times[2];
5867          var start = Utils.flattenTimecode(times[0]);
5868          var end = Utils.flattenTimecode(times[1]);
5869          var lines = parts.slice(1);
5870
5871          // parse the settings if they exists, and apply them to the cue
5872          if (settings != null) {
5873            settings.replace(setting, function (match, $1, $2) {
5874              style[$1] = $2;
5875              return "";
5876            });
5877          }
5878
5879          // create generic cue
5880          var html = WebVTTParser.createHTML(lines);
5881          var text = lines.join("\n");
5882          var cue = CaptionCue.create(start, end, {
5883            text: text,
5884            html: html,
5885            raw: caption
5886          }, "".concat(id), style);
5887          Object.assign(cue, style);
5888          return cue;
5889        } catch (error) {
5890          Logger.instance.error("WebVTT Parse Error", error);
5891        }
5892      }
5893
5894      /**
5895       * Parses a WebVTT file into CaptionCue objects and attaches them to a given track.
5896       *
5897       * @param   {String}        txt   The text of the webvtt file
5898       * @param   {CaptionTrack}  track The caption track to populate
5899       * @return  {CaptionTrack}        The populated caption track
5900       */
5901    }, {
5902      key: "parse",
5903      value: function parse(txt) {
5904        var _this = this;
5905        var track = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : CaptionTrack.create({
5906          kind: "captions",
5907          type: Utils.mimeTypes.vtt
5908        });
5909        // replace windows line breaks
5910        txt = txt.replace(/\r/g, '');
5911
5912        // split up the caption chunks
5913        var captions = txt.split("\n\n");
5914        var index = 0;
5915        captions.forEach(function (caption) {
5916          // skip the document declaration line
5917          if (/^WEBVTT/.test(caption)) return;
5918
5919          // skip blank lines
5920          if (caption == "") return;
5921
5922          // skip note sections
5923          if (/^NOTE/.test(caption)) return;
5924
5925          // handle inline styles
5926          if (/^STYLE/.test(caption)) {
5927            // TODO: properly parse style data and populate track and caption styles
5928            return;
5929          }
5930          var cue = _this.parseCaption(caption, ++index);
5931          // add the cue to the track
5932          track.cues.push(cue);
5933        });
5934        return track;
5935      }
5936    }], [{
5937      key: "createHTML",
5938      value:
5939      /**
5940       * Converts plain text with line breaks to HTML with <br /> tags.
5941       *
5942       * @param   {String|Array.<String>} txt The plain text, or array of plain text lines.
5943       * @return  {String}                    The HTML text
5944       */
5945      function createHTML(text) {
5946        if (typeof text === "string") text = text.split(/\n|\r/);
5947        return "<p>".concat(text.join("<br />"), "</p>");
5948      }
5949    }]);
5950    return WebVTTParser;
5951  }();
5952
5953  var CaptionParsers = {
5954    "application/ttml+xml": new SMPTETTParser(),
5955    "application/x-subrip": new SRTParser(),
5956    "text/vtt": new WebVTTParser(),
5957    undefined: new SMPTETTParser()
5958  };
5959
5960  var CueTrack = /*#__PURE__*/function (_Track) {
5961    babelHelpers.inherits(CueTrack, _Track);
5962    /**
5963     * The CaptionTrack class.
5964     *
5965     * @constructor
5966     * @private
5967     * @param {?Object} track A generic track object.
5968     */
5969    function CueTrack(data) {
5970      var _this;
5971      var cues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
5972      babelHelpers.classCallCheck(this, CueTrack);
5973      _this = _Track.call(this, data) || this;
5974      _this.cues = cues;
5975      Object.defineProperties(babelHelpers.assertThisInitialized(_this), {
5976        "default": {
5977          get: _this.getDefault,
5978          set: _this.setDefault,
5979          enumerable: true,
5980          configurable: false
5981        }
5982      });
5983      return _this;
5984    }
5985    babelHelpers.createClass(CueTrack, [{
5986      key: "getDefault",
5987      value: function getDefault() {
5988        return !!this.data["default"];
5989      }
5990    }, {
5991      key: "setDefault",
5992      value: function setDefault(value) {
5993        if (value === this.data["default"]) {
5994          return;
5995        }
5996        this.data["default"] = !!value;
5997      }
5998    }, {
5999      key: "flatten",
6000      value: function flatten() {
6001        var track = babelHelpers.get(babelHelpers.getPrototypeOf(CueTrack.prototype), "flatten", this).call(this);
6002        return Object.assign({}, track, {
6003          "default": this.getDefault()
6004        });
6005      }
6006    }, {
6007      key: "getCueAt",
6008      value: function getCueAt(time) {
6009        return this.cues.find(function (cue) {
6010          return cue.startTime <= time && cue.endTime >= time;
6011        });
6012      }
6013
6014      /** @static */
6015    }], [{
6016      key: "create",
6017      value: function create(track) {
6018        return new CueTrack(track);
6019      }
6020    }]);
6021    return CueTrack;
6022  }(Track);
6023
6024  var CaptionTrack = /*#__PURE__*/function (_CueTrack) {
6025    babelHelpers.inherits(CaptionTrack, _CueTrack);
6026    /**
6027     * The CaptionTrack class.
6028     *
6029     * @constructor
6030     * @private
6031     * @param {?Object} track A generic track object.
6032     */
6033    function CaptionTrack(track, onload) {
6034      var _this;
6035      babelHelpers.classCallCheck(this, CaptionTrack);
6036      _this = _CueTrack.call(this, {
6037        kind: track.kind,
6038        label: track.label,
6039        language: track.srclang,
6040        "default": track["default"]
6041      }) || this;
6042      _this.src = track.src;
6043      _this.type = track.type;
6044      _this.cues = track.cues || [];
6045      _this.styles = track.styles || {};
6046      _this.activeCues = [];
6047      _this.isLive = /^live/.test(_this.type);
6048      var load = onload;
6049      if (_this.src && !_this.isLive) {
6050        load = function load() {
6051          return Utils.request(_this.src).then(function (xhr) {
6052            try {
6053              CaptionParsers[_this.type].parse(xhr.response, babelHelpers.assertThisInitialized(_this));
6054            } catch (error) {
6055              _this.dispatch("error", "Could not parse caption track: ".concat(_this.src));
6056              Logger.instance.error("Could not parse caption track: ".concat(_this.src));
6057              return;
6058            }
6059            if (typeof onload === "function") {
6060              onload(babelHelpers.assertThisInitialized(_this));
6061            }
6062          })["catch"](function (error) {
6063            _this.dispatch("error", "Could not load caption track: ".concat(error, ", ").concat(_this.src));
6064            Logger.instance.error("Could not load caption track: ".concat(error, ", ").concat(_this.src
6064));
6065          });
6066        };
6067      }
6068      if (load != null) {
6069        Promise.resolve(babelHelpers.assertThisInitialized(_this)).then(load);
6070      }
6071      return _this;
6072    }
6073
6074    /** @static */
6075    babelHelpers.createClass(CaptionTrack, null, [{
6076      key: "create",
6077      value: function create(track, onload) {
6078        return new CaptionTrack(track, onload);
6079      }
6080    }]);
6081    return CaptionTrack;
6082  }(CueTrack);
6083
6084  var PluginProxy = /*#__PURE__*/function (_ModuleProxy) {
6085    babelHelpers.inherits(PluginProxy, _ModuleProxy);
6086    /**
6087     * The PluginProxy class.
6088     *
6089     * @param {Object} config
6090     * @constructor
6091     * @private
6092     * @extends {ModuleProxy}
6093     */
6094    function PluginProxy(config) {
6095      var _this;
6096      babelHelpers.classCallCheck(this, PluginProxy);
6097      _this = _ModuleProxy.call(this, config) || this;
6098      _this.enabled = true;
6099      _this.plugin = null;
6100      _this.appState = null;
6101      return _this;
6102    }
6103
6104    /**
6105     * The name of the this Proxy.
6106     *
6107     * @static
6108     * @type {string}
6109     */
6110    babelHelpers.createClass(PluginProxy, [{
6111      key: "value",
6112      get: /** */
6113      function get() {
6114        return this.getValue();
6115      }
6116
6117      /** */
6118    }, {
6119      key: "getDefaults",
6120      value: function getDefaults() {
6121        var defaults = babelHelpers.get(babelHelpers.getPrototypeOf(PluginProxy.prototype), "getDefaults", this).call(this);
6122        if (defaults.debug == null) {
6123          defaults.debug = null;
6124        }
6125        return defaults;
6126      }
6127
6128      /** */
6129    }, {
6130      key: "getValue",
6131      value: function getValue(prop) {
6132        var value = this.facade.player.evaluateBindings(this.config);
6133        if (prop != null) {
6134          return value[prop];
6135        } else {
6136          return value;
6137        }
6138      }
6139
6140      /** @override */
6141    }, {
6142      key: "initializeNotifier",
6143      value: function initializeNotifier(key) {
6144        babelHelpers.get(babelHelpers.getPrototypeOf(PluginProxy.prototype), "initializeNotifier", this).call(this, key);
6145        this.appState = this.facade.player.appState;
6146      }
6147
6148      /** */
6149    }, {
6150      key: "getMediaElement",
6151      value: function getMediaElement() {
6152        return this.facade.player.getMediaElement();
6153      }
6154
6155      /** */
6156    }, {
6157      key: "setEnabled",
6158      value: function setEnabled(value) {
6159        this.enabled = value;
6160        return value;
6161      }
6162    }, {
6163      key: "getEnabled",
6164      value: function getEnabled() {
6165        return this.enabled;
6166      }
6167
6168      /** */
6169    }, {
6170      key: "getDebug",
6171      value: function getDebug() {
6172        if (this.value.debug != null) {
6173          return this.value.debug;
6174        } else {
6175          return this.facade.player.getConfig().debug === true;
6176        }
6177      }
6178
6179      /** */
6180    }, {
6181      key: "createPlugin",
6182      value: function createPlugin() {}
6183
6184      /** */
6185    }, {
6186      key: "initialize",
6187      value: function initialize() {
6188        this.plugin = this.createPlugin();
6189      }
6190
6191      /** */
6192    }, {
6193      key: "error",
6194      value: function error(err) {
6195        this.facade.logger.error("[AMP ".concat(this.facade.getModuleName().toUpperCase(), " Error]"), err);
6196      }
6197    }], [{
6198      key: "NAME",
6199      get: function get() {
6200        return ModuleProxy.NAME;
6201      }
6202    }]);
6203    return PluginProxy;
6204  }(ModuleProxy);
6205
6206  var LocalizationProxy = /*#__PURE__*/function (_puremvc$Proxy) {
6207    babelHelpers.inherits(LocalizationProxy, _puremvc$Proxy);
6208    /**
6209     * The LocalizationProxy class. Used to track player localization settings.
6210     *
6211     * @constructor
6212     * @private
6213     * @extends {puremvc.Proxy}
6214     * @param {Object}  init  The configuration object.
6215     */
6216    function LocalizationProxy(init) {
6217      var _this;
6218      babelHelpers.classCallCheck(this, LocalizationProxy);
6219      _this = _puremvc$Proxy.call(this) || this;
6220      _this.data = {
6221        "default": init.defaults.language,
6222        language: init.language,
6223        locales: [Config.locales]
6224      };
6225      _this.defaults = {};
6226      _this.locale = null;
6227      _this.localeId = null;
6228      return _this;
6229    }
6230
6231    /**
6232     * The name of the this Proxy.
6233     *
6234     * @static
6235     * @type {string}
6236     */
6237    babelHelpers.createClass(LocalizationProxy, [{
6238      key: "initialize",
6239      value: /** */
6240      function initialize(plugins) {
6241        var _this2 = this;
6242        if (this.facade.config.locales != null) {
6243          this.addLocales(this.facade.config.locales, false);
6244        }
6245        plugins.forEach(function (key) {
6246          if (_this2.facade[key].locales != null) {
6247            _this2.addLocales(_this2.facade[key].locales, false);
6248          }
6249        });
6250        return this.compileLocale(this.data["default"]).then(function (defaults) {
6251          _this2.defaults = defaults;
6252          return _this2.setLanguage(_this2.data.language);
6253        });
6254      }
6255
6256      /**
6257       *
6258       */
6259    }, {
6260      key: "getLanguage",
6261      value: function getLanguage() {
6262        return this.data.language;
6263      }
6264    }, {
6265      key: "setLanguage",
6266      value: function setLanguage(value) {
6267        var _this3 = this;
6268        return this.compileLocale(value).then(function (locale) {
6269          _this3.data.language = value;
6270          _this3.localeId = value.toLowerCase();
6271          _this3.locale = _this3.facade.l10n = locale;
6272          _this3.sendNotification(Notifications.LANGUAGE_CHANGE, value);
6273        });
6274      }
6275
6276      /**
6277       *
6278       */
6279    }, {
6280      key: "compileLocale",
6281      value: function compileLocale(key) {
6282        var _this4 = this;
6283        return new Promise(function (resolve, reject) {
6284          if (!key) {
6285            return resolve({});
6286          }
6287          var localeId = key.toLowerCase();
6288          var localeIdShort = _this4.getLocaleIdShort(localeId);
6289          var find = function find(locale) {
6290            return locale[localeId] || locale[localeIdShort];
6291          };
6292          var exists = function exists(locale) {
6293            return locale != null;
6294          };
6295          var load = function load(locale) {
6296            if (typeof locale !== "string") {
6297              return locale;
6298            }
6299            return AMP.addResource({
6300              src: _this4.facade.evaluatePaths(locale),
6301              type: Utils.mimeTypes.json
6302            }).then(function (resource) {
6303              return resource.data;
6304            })["catch"](function (error) {
6305              return {};
6306            });
6307          };
6308          var locales = fp.transform(_this4.data.locales, fp.filter(exists), fp.map(find), fp.filter(exists), fp.map(load));
6309          Promise.all(locales).then(function (locales) {
6310            return resolve(Object.assign.apply(Object, [{}].concat(babelHelpers.toConsumableArray(locales))));
6311          });
6312        });
6313      }
6314
6315      /**
6316       *
6317       */
6318    }, {
6319      key: "getLocaleId",
6320      value: function getLocaleId() {
6321        return this.localeId;
6322      }
6323
6324      /**
6325       *
6326       */
6327    }, {
6328      key: "getLocaleIdShort",
6329      value: function getLocaleIdShort() {
6330        var localeId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.localeId;
6331        return (localeId || "").split("-").shift();
6332      }
6333
6334      /**
6335       *
6336       */
6337    }, {
6338      key: "getLocales",
6339      value: function getLocales() {
6340        return this.data.locales;
6341      }
6342    }, {
6343      key: "setLocales",
6344      value: function setLocales(value) {
6345        this.data.locales = value;
6346        return value;
6347      }
6348
6349      /**
6350       *
6351       */
6352    }, {
6353      key: "addLocales",
6354      value: function addLocales(value) {
6355        var _this5 = this;
6356        var refresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
6357        if (value == null) {
6358          return Promise.resolve();
6359        }
6360        if (!(value instanceof Array)) {
6361          value = [value];
6362        }
6363        value.forEach(function (locale) {
6364          if (!(babelHelpers["typeof"](locale) === "object")) {
6365            return;
6366          }
6367          var obj = {};
6368          fp.each(locale, function (value, key) {
6369            return obj[key.toLowerCase()] = value;
6370          });
6371          _this5.data.locales.push(obj);
6372        });
6373        if (refresh === false) {
6374          return Promise.resolve();
6375        }
6376        return this.setLanguage(this.getLanguage());
6377      }
6378
6379      /**
6380       *
6381       */
6382    }, {
6383      key: "getString",
6384      value: function getString(id, context) {
6385        if (id == null) {
6386          return;
6387        }
6388        if (!this.data.language) {
6389          return id;
6390        }
6391        try {
6392          var key = id.replace(/^MSG_/, "");
6393          var msg = "MSG_".concat(key);
6394          var dflt = this.defaults;
6395          var locale = this.locale || dflt;
6396          if (locale == null) {
6397            return id;
6398          }
6399          var str = locale[msg] || locale[key] || dflt[msg] || dflt[key] || id;
6400          str = this.facade.evaluateBindings(str, context);
6401          return str;
6402        } catch (error) {
6403          return id;
6404        }
6405      }
6406
6407      /**
6408       * Retrieves the full language name in the player's current language setting.
6409       *
6410       * @param   {string}  lang  The language code.
6411       * @return  {string}        The full name of the language according to the player's current language setting.
6412       */
6413    }, {
6414      key: "getLanguageString",
6415      value: function getLanguageString(lang) {
6416        // bail if nothing useful was provided
6417        if (typeof lang !== "string" || lang == null || lang === "") {
6418          return "";
6419        }
6420        // try the full language code, which may have a regional sub code
6421        var key = "MSG_".concat(lang.toUpperCase());
6422        var str = this.getString(key);
6423
6424        // try the just the language
6425        if (str === key) {
6426          lang = this.getLocaleIdShort(lang);
6427          key = "MSG_".concat(lang.toUpperCase());
6428          str = this.getString(key);
6429        }
6430        return str;
6431      }
6432    }], [{
6433      key: "NAME",
6434      get: function get() {
6435        return "LocalizationProxy";
6436      }
6437    }]);
6438    return LocalizationProxy;
6439  }(puremvc.Proxy);
6440
6441  var CaptionRenderer = {
6442    AUTO: "auto",
6443    HTML: "html",
6444    NATIVE: "native"
6445  };
6446
6447  var CaptionMapper = {
6448    AUTO: "auto",
6449    MANUAL: "manual"
6450  };
6451
6452  var regex = /subtitles|captions|descriptions/i;
6453  var CaptioningProxy = /*#__PURE__*/function (_PluginProxy) {
6454    babelHelpers.inherits(CaptioningProxy, _PluginProxy);
6455    /**
6456     * The CaptioningProxy class
6457     *
6458     * @constructor
6459     * @private
6460     * @extends {PluginProxy}
6461     * @param   {Object}  config  The configuration object.
6462     */
6463    function CaptioningProxy(config) {
6464      var _this;
6465      babelHelpers.classCallCheck(this, CaptioningProxy);
6466      _this = _PluginProxy.call(this, config) || this;
6467      _this.providers = {};
6468      _this.tracks = [];
6469      _this.rendererMap = [];
6470      _this.track = {};
6471      _this.defaults = {
6472        renderer: CaptionRenderer.AUTO,
6473        crossorigin: null
6474      };
6475      _this.enabled = false;
6476      _this.hidden = true;
6477      _this.captions = null;
6478      _this.loaded = true;
6479      _this.mapper = CaptionMapper.AUTO;
6480      return _this;
6481    }
6482    babelHelpers.createClass(CaptioningProxy, [{
6483      key: "onRegister",
6484      value: function onRegister() {
6485        this.renderer = this.getValue("renderer") || CaptionRenderer.AUTO;
6486      }
6487
6488      /** @static */
6489    }, {
6490      key: "getCrossOrigin",
6491      value:
6492      /**
6493       *
6494       */
6495      function getCrossOrigin() {
6496        return this.getValue("crossorigin");
6497      }
6498
6499      /**
6500       *
6501       */
6502    }, {
6503      key: "getTracks",
6504      value: function getTracks() {
6505        return this.tracks;
6506      }
6507    }, {
6508      key: "setTracks",
6509      value: function setTracks(value) {
6510        var _this2 = this;
6511        // reset the proxy members
6512        this.tracks = [];
6513        this.track = null;
6514        value = this.facade.player.evaluateBindings(value);
6515        if (value == null) {
6516          return;
6517        }
6518
6519        // set up the loading helpers
6520        var getTracks = function getTracks() {
6521          return _this2.tracks;
6522        };
6523        var loaded = 0;
6524        var trackLoaded = function trackLoaded() {
6525          var tracks = getTracks();
6526          loaded++;
6527          if (loaded === tracks.length) {
6528            _this2.sendNotification(CaptioningNotifications.TRACKS_LOADED, tracks);
6529            _this2.autoSelectTrack();
6530          }
6531        };
6532
6533        // load the tracks
6534        var dflt;
6535        value.forEach(function (item) {
6536          if (!regex.test(item.kind) || !item.srclang) return;
6537          var track = CaptionTrack.create(item, trackLoaded);
6538          track.once("error", function (event) {
6539            return _this2.facade.dispatch(Events.TRACK_ERROR, event.data);
6540          });
6541          _this2.tracks.push(track);
6542          if (track["default"]) dflt = track;
6543        });
6544        if (dflt == null && this.tracks.length) this.tracks[0]["default"] = true;
6545        return value;
6546      }
6547
6548      /** */
6549    }, {
6550      key: "registerRenderer",
6551      value: function registerRenderer(value) {
6552        if (value == null) {
6553          return;
6554        }
6555        value.proxy = this;
6556        this.rendererMap.push(value);
6557      }
6558
6559      /** */
6560    }, {
6561      key: "retrieveRenderer",
6562      value: function retrieveRenderer(name) {
6563        return this.rendererMap.find(function (r) {
6564          return r.getRendererName() === name;
6565        });
6566      }
6567
6568      /** */
6569    }, {
6570      key: "removeRenderer",
6571      value: function removeRenderer(name) {
6572        var value = this.retrieveRenderer(name);
6573        value.proxy = null;
6574        if (value == null) {
6575          return null;
6576        }
6577        var index = this.rendererMap.indexOf(value);
6578        this.rendererMap.splice(index, 1);
6579        return value;
6580      }
6581
6582      /**
6583       *
6584       */
6585    }, {
6586      key: "getRenderer",
6587      value: function getRenderer() {
6588        return this.renderer;
6589      }
6590    }, {
6591      key: "setRenderer",
6592      value: function setRenderer(value) {
6593        if (value === this.renderer) {
6594          return value;
6595        }
6596        this.renderer = value;
6597        this.selectRenderer(this.facade.player.media);
6598        return value;
6599      }
6600    }, {
6601      key: "getCurrentRenderer",
6602      value: function getCurrentRenderer() {
6603        var mediator = this.facade.retrieveMediator(CaptioningProxy.TEXT_TRACK_RENDERER);
6604        return mediator && mediator.getRendererName();
6605      }
6606
6607      /**
6608       *
6609       */
6610    }, {
6611      key: "selectRenderer",
6612      value: function selectRenderer() {
6613        var media = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6614        var tracks = media.track || this.tracks;
6615        if (tracks == null) return;
6616
6617        // get the customer defined renderer or default to auto detect
6618        var renderer = this.renderer;
6619        if (!this.rendererMap.map(function (r) {
6620          return r.getRendererName();
6621        }).includes(renderer)) renderer = CaptionRenderer.AUTO;
6622
6623        // auto detect
6624        if (renderer === CaptionRenderer.AUTO) {
6625          renderer = fp.find(this.rendererMap, fp.filter(function (r) {
6626            return tracks.some(function (t) {
6627              return r.canUseResource(t);
6628            });
6629          }),
6630          // if the renderer can display one of the tracks
6631          fp.map(function (r) {
6632            return r.getRendererName();
6633          }) // get the name
6634          );
6635        }
6636
6637        // check if the renderer is already loaded
6638        if (this.getCurrentRenderer() === renderer) {
6639          return;
6640        }
6641
6642        // unload the current renderer
6643        this.facade.removeMediator(CaptioningProxy.TEXT_TRACK_RENDERER);
6644
6645        // load the new renderer
6646        var mediator = this.retrieveRenderer(renderer);
6647        if (mediator != null) {
6648          this.facade.registerMediator(mediator);
6649        }
6650      }
6651    }, {
6652      key: "setMapper",
6653      value: function setMapper(mode) {
6654        this.mapper = mode;
6655      }
6656    }, {
6657      key: "getMapper",
6658      value: function getMapper() {
6659        return this.mapper;
6660      }
6661
6662      /**
6663       *
6664       */
6665    }, {
6666      key: "getTrack",
6667      value: function getTrack() {
6668        return this.track;
6669      }
6670    }, {
6671      key: "setTrack",
6672      value: function setTrack(value) {
6673        this.track = value;
6674        this.captions = this.track.cues;
6675        this.track.enabled = true;
6676        this.sendNotification(Notifications.CHANGE_SETTINGS, {
6677          captions: {
6678            track: this.track.flatten()
6679          }
6680        });
6681
6682        // TODO: Remove this in favor of Notifications.SETTINGS_CHANGE
6683        this.sendNotification(CaptioningNotifications.TRACK_SELECTED, this.track);
6684        return value;
6685      }
6686
6687      /**
6688       *
6689       */
6690    }, {
6691      key: "selectTrackByIndex",
6692      value: function selectTrackByIndex(index) {
6693        var track = null;
6694        if (index >= 0 && index < this.tracks.length) {
6695          track = this.tracks[index];
6696          this.setTrack(track);
6697        }
6698        return track;
6699      }
6700
6701      /**
6702       *
6703       */
6704    }, {
6705      key: "selectTrackByLanguage",
6706      value: function selectTrackByLanguage(lang) {
6707        var track = this.tracks.find(function (t) {
6708          return t.language === lang;
6709        });
6710        if (track != null) this.setTrack(track);
6711        return track;
6712      }
6713
6714      /**
6715       *
6716       */
6717    }, {
6718      key: "getHidden",
6719      value: function getHidden() {
6720        return this.hidden;
6721      }
6722    }, {
6723      key: "setHidden",
6724      value: function setHidden(value) {
6725        this.hidden = value;
6726        return value;
6727      }
6728
6729      /**
6730       *
6731       */
6732    }, {
6733      key: "getEnabled",
6734      value: function getEnabled() {
6735        return this.enabled;
6736      }
6737    }, {
6738      key: "setEnabled",
6739      value: function setEnabled(value) {
6740        this.enabled = value;
6741        return value;
6742      }
6743
6744      /**
6745       *
6746       */
6747    }, {
6748      key: "autoSelectTrack",
6749      value: function autoSelectTrack() {
6750        // TODO: Should we auto select, or force the user to choose?
6751        var track = null;
6752        var lang = this.facade.player.retrieveProxy(LocalizationProxy.NAME).getLanguage();
6753        if (lang != null) {
6754          lang = lang.split("-").shift();
6755          track = this.selectTrackByLanguage(lang);
6756        }
6757        if (track == null) {
6758          track = this.tracks[0];
6759          this.setTrack(track);
6760        }
6761        return track;
6762      }
6763
6764      /**
6765       *
6766       */
6767    }, {
6768      key: "getTextTracks",
6769      value: function getTextTracks() {
6770        return Array.from(this.facade.player.getMediaElement().textTracks);
6771      }
6772
6773      /**
6774       *
6775       */
6776    }, {
6777      key: "getTextTrack",
6778      value: function getTextTrack() {
6779        var selected = this.getTrack();
6780        if (!selected) {
6781          return;
6782        }
6783        var kind = selected.kind;
6784        var exists = function exists(t) {
6785          return regex.test(t.kind) && (Utils.compareLanguageTags(t.language, lang) || !t.language.length);
6786        }; //Dash streams may not include languge
6787        var compare = function compare(a, b) {
6788          var weight = 0;
6789          if (a.kind === kind && b.kind !== kind) {
6790            weight++;
6791          }
6792          if (a.kind !== kind && b.kind === kind) {
6793            weight--;
6794          }
6795          if (Utils.compareLanguageTags(a.language, lang) && !Utils.compareLanguageTags(b.language, lang)) {
6796            weight++;
6797          }
6798          if (!Utils.compareLanguageTags(a.language, lang) && Utils.compareLanguageTags(b.language, lang)) {
6799            weight--;
6800          }
6801          if (a.mode !== TrackMode.SHOWING) {
6802            weight--;
6803          }
6804          return weight;
6805        };
6806        var lang = selected.language;
6807        if (lang != null) lang = lang.split("-").shift();
6808        var tracks = this.getTextTracks().filter(exists).sort(compare);
6809        return tracks[tracks.length - 1];
6810      }
6811    }], [{
6812      key: "NAME",
6813      get: function get() {
6814        return ModuleProxy.NAME;
6815      }
6816
6817      /** @static */
6818    }, {
6819      key: "TEXT_TRACK_RENDERER",
6820      get: function get() {
6821        return "caption-text";
6822      }
6823    }]);
6824    return CaptioningProxy;
6825  }(PluginProxy);
6826
6827  var PlaybackProxy = /*#__PURE__*/function (_puremvc$Proxy) {
6828    babelHelpers.inherits(PlaybackProxy, _puremvc$Proxy);
6829    /**
6830     * PlaybackProxy constructor.
6831     *
6832     * @constructor
6833     * @private
6834     * @extends {puremvc.Proxy}
6835     */
6836    function PlaybackProxy() {
6837      var _this;
6838      babelHelpers.classCallCheck(this, PlaybackProxy);
6839      _this = _puremvc$Proxy.call(this, PlaybackProxy.NAME) || this;
6840      _this.data = {
6841        core: null,
6842        muted: false,
6843        started: false,
6844        volume: 1,
6845        currentTime: 0,
6846        duration: 0,
6847        src: null,
6848        ended: false,
6849        paused: true,
6850        seeking: false,
6851        loading: false,
6852        waiting: false,
6853        keyErrored: false
6854      };
6855      _this.initialized = false;
6856      if (Utils.getDevice() === "desktop") {
6857        _this.initialized = true;
6858      }
6859      _this.handlers = {
6860        "timeupdate": _this.ontimeupdate.bind(babelHelpers.assertThisInitialized(_this)),
6861        "durationchange": _this.ondurationchange.bind(babelHelpers.assertThisInitialized(_this)),
6862        "play": _this.onplay.bind(babelHelpers.assertThisInitialized(_this)),
6863        "playing": _this.onplaying.bind(babelHelpers.assertThisInitialized(_this)),
6864        "pause": _this.onpause.bind(babelHelpers.assertThisInitialized(_this)),
6865        "loadeddata": _this.onloadeddata.bind(babelHelpers.assertThisInitialized(_this)),
6866        "waiting": _this.onwaiting.bind(babelHelpers.assertThisInitialized(_this)),
6867        "seeking": _this.onseeking.bind(babelHelpers.assertThisInitialized(_this)),
6868        "seeked": _this.onseeked.bind(babelHelpers.assertThisInitialized(_this)),
6869        "ended": _this.onended.bind(babelHelpers.assertThisInitialized(_this)),
6870        "progress": _this.onprogress.bind(babelHelpers.assertThisInitialized(_this)),
6871        "error": _this.onerror.bind(babelHelpers.assertThisInitialized(_this)),
6872        "loadstart": _this.onloadstart.bind(babelHelpers.assertThisInitialized(_this)),
6873        "canplay": _this.oncanplay.bind(babelHelpers.assertThisInitialized(_this)),
6874        "canplaythrough": _this.oncanplaythrough.bind(babelHelpers.assertThisInitialized(_this)),
6875        "loadedmetadata": _this.onloadedmetadata.bind(babelHelpers.assertThisInitialized(_this)),
6876        "stalled": _this.onstalled.bind(babelHelpers.assertThisInitialized(_this))
6877      };
6878      _this.resume = {
6879        event: Utils.getIEVersion() === -1 || Utils.getIEVersion() === 11 ? "loadedmetadata" : "canplaythrough",
6880        listener: _this.resumestart.bind(babelHelpers.assertThisInitialized(_this))
6881      };
6882      _this.textTrackHandlers = {
6883        "addtrack": _this.onaddtrack.bind(babelHelpers.assertThisInitialized(_this))
6884      };
6885      _this.onneedkey = _this.onneedkey.bind(babelHelpers.assertThisInitialized(_this));
6886      _this.enabled = null;
6887      _this.playWhenLoaded = false;
6888      _this.metadataloaded = false;
6889      _this.activeCuesIndex = 0;
6890      _this.id3CueType = null;
6891      return _this;
6892    }
6893
6894    /**
6895     * The name of the this Proxy.
6896     *
6897     * @static
6898     * @type {string}
6899     */
6900    babelHelpers.createClass(PlaybackProxy, [{
6901      key: "getEnabled",
6902      value:
6903      /**
6904       * The current time of the video in seconds. Value must be between currentTime and duration.
6905       *
6906       * @param {Number} value
6907       *    The new currentTime value in seconds
6908       * @returns {Number}
6909       *    The currentTime value in seconds
6910       * @type {Number}
6911       */
6912      function getEnabled() {
6913        return this.enabled;
6914      }
6915    }, {
6916      key: "setEnabled",
6917      value: function setEnabled(value) {
6918        if (value === this.enabled) {
6919          return;
6920        }
6921        this.enabled = value;
6922        if (this.enabled === true) {
6923          this.init();
6924        } else {
6925          this.applyHandlers(false);
6926        }
6927        return value;
6928      }
6929
6930      /** @private */
6931    }, {
6932      key: "applyHandlers",
6933      value: function applyHandlers() {
6934        var enabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
6935        var video = this.getMediaElement();
6936        var action = enabled ? "addEventListener" : "removeEventListener";
6937        fp.each(this.handlers, function (value, key) {
6938          video[action](key, value);
6939        });
6940      }
6941
6942      /** @private */
6943    }, {
6944      key: "resumestart",
6945      value: function resumestart(event) {
6946        var _this2 = this;
6947        this.getMediaElement();
6948        this.handlers.durationchange(event);
6949        if (this.data.currentTime > 0 && this.data.ended !== true) {
6950          this.facade.timers.setTimeout(function () {
6951            _this2.seek(_this2.data.currentTime).then(_this2.resumecomplete.bind(_this2));
6952          }, 50);
6953        } else {
6954          this.resumecomplete();
6955        }
6956      }
6957
6958      /** @private */
6959    }, {
6960      key: "resumecomplete",
6961      value: function resumecomplete() {
6962        this.data.loading = false;
6963        this.applyHandlers(true);
6964        if (this.playWhenLoaded === true) {
6965          this.facade.timers.setTimeout(this.play.bind(this), 1);
6966        }
6967      }
6968
6969      /** @private */
6970    }, {
6971      key: "onaddtrack",
6972      value: function onaddtrack(event) {
6973        var _this3 = this;
6974        var track = event.track;
6975        this.sendNotification(Notifications.TEXT_TRACK_ADDED, {
6976          track: track
6977        });
6978        if (this.facade.captioning == null && regex.test(track.kind)) {
6979          track.mode = TrackMode.HIDDEN;
6980        }
6981        if (track.kind !== "metadata") {
6982          return;
6983        }
6984        track.mode = TrackMode.HIDDEN;
6985        track.addEventListener("cuechange", function (event) {
6986          fp.each(event.target.activeCues, function (cue, i, cues) {
6987            if (cues[i - 1] === cue) {
6988              return;
6989            }
6990            _this3.sendNotification(Notifications.TIMED_METADATA, cue);
6991          });
6992        });
6993      }
6994    }, {
6995      key: "ontimeupdate",
6996      value: function ontimeupdate(event) {
6997        var currentTime = event.target.currentTime;
6998        // TODO: This should not be here.
6999        if (this.facade.ads.inProgress === true) {
7000          return;
7001        }
7002        this.data.currentTime = currentTime;
7003        this.sendNotification(Notifications.TIME_CHANGE, {
7004          currentTime: currentTime
7005        });
7006      }
7007    }, {
7008      key: "ondurationchange",
7009      value: function ondurationchange(event) {
7010        var duration = event.target.duration;
7011        if (!duration) {
7012          return;
7013        }
7014        this.data.duration = duration;
7015
7016        //TODO: HACK! Android 4-7 returns the wrong duration for m3u8s
7017        if (/Android [4-7]/.test(navigator.userAgent) && this.getMediaElement().src.indexOf(".m3u8") !== -1 && duration === 2e308) {
7018          return;
7019        }
7020        this.sendNotification(Notifications.CHANGE_DURATION, duration);
7021      }
7022    }, {
7023      key: "onplay",
7024      value: function onplay(event) {
7025        this.data.paused = false;
7026      }
7027    }, {
7028      key: "onplaying",
7029      value: function onplaying(event) {
7030        this.data.paused = false;
7031        this.data.seeking = false;
7032        this.data.waiting = false;
7033        this.sendNotification(Notifications.PLAYING);
7034      }
7035    }, {
7036      key: "onpause",
7037      value: function onpause(event) {
7038        if (this.getMediaElement().ended === true || this.facade.playState === PlayState.READY) {
7039          return;
7040        }
7041        // HACK: HTML-1150 - To prevent bubbling pause notification on waiting.
7042        if (this.data.waiting === true && this.playbackCoreName === "hls") {
7043          return;
7044        }
7045        this.data.paused = true;
7046        if (event.target.readyState > 0) {
7047          this.sendNotification(Notifications.PAUSED);
7048          this.sendNotification(Notifications.CHANGE_PLAY_STATE, PlayState.PAUSED);
7049        }
7050      }
7051    }, {
7052      key: "onloadeddata",
7053      value: function onloadeddata(event) {
7054        this.sendNotification(Notifications.LOADED_DATA);
7055      }
7056    }, {
7057      key: "onwaiting",
7058      value: function onwaiting(event) {
7059        this.data.waiting = true;
7060        this.sendNotification(Notifications.WAITING);
7061        var video = this.getMediaElement();
7062        if (video.seeking === false && video.readyState === 2 && video.networkState === 2) {
7063          video.once("playing", this.sendNotification.bind(this, Notifications.BUFFERING_CHANGE, false));
7064          this.sendNotification(Notifications.BUFFERING_CHANGE, true);
7065        }
7066      }
7067    }, {
7068      key: "onstalled",
7069      value: function onstalled(event) {
7070        this.sendNotification(Notifications.STALLED);
7071      }
7072    }, {
7073      key: "onseeking",
7074      value: function onseeking(event) {
7075        this.getMediaElement().removeEventListener("timeupdate", this.handlers.timeupdate);
7076        // AMPWEB-866: This is the best available solution to.
7077        // See final ticket comment from @jgirard for details.
7078        var currentTime = event.target.currentTime;
7079        this.sendNotification(Notifications.TIME_CHANGE, {
7080          currentTime: currentTime
7081        });
7082        this.data.seeking = true;
7083        this.sendNotification(Notifications.SEEKING);
7084      }
7085    }, {
7086      key: "onseeked",
7087      value: function onseeked(event) {
7088        this.data.seeking = false;
7089        this.sendNotification(Notifications.SEEK_COMPLETE, event.target.currentTime);
7090        this.getMediaElement().addEventListener("timeupdate", this.handlers.timeupdate);
7091      }
7092    }, {
7093      key: "onended",
7094      value: function onended(event) {
7095        this.data.ended = true;
7096        this.sendNotification(Notifications.ENDED);
7097      }
7098    }, {
7099      key: "onprogress",
7100      value: function onprogress(event) {
7101        try {
7102          var video = this.getMediaElement();
7103          var buffered = video.buffered;
7104          this.sendNotification(Notifications.PROGRESS, buffered.end(buffered.length - 1) / video.duration);
7105        } catch (error) {}
7106      }
7107    }, {
7108      key: "onerror",
7109      value: function onerror(event) {
7110        var error = this.getMediaElement().error;
7111        this.sendNotification(Notifications.ERROR, this.facade.createMediaError(error.code, error));
7112      }
7113    }, {
7114      key: "onloadstart",
7115      value: function onloadstart(event) {
7116        this.sendNotification(Notifications.LOAD_START);
7117      }
7118    }, {
7119      key: "oncanplay",
7120      value: function oncanplay(event) {
7121        this.sendNotification(Notifications.CAN_PLAY);
7122      }
7123    }, {
7124      key: "oncanplaythrough",
7125      value: function oncanplaythrough(event) {
7126        this.createTracks();
7127        this.sendNotification(Notifications.CAN_PLAY_THROUGH);
7128        this.sendNotification(Notifications.PROGRESS, this.getDuration());
7129      }
7130    }, {
7131      key: "onloadedmetadata",
7132      value: function onloadedmetadata(event) {
7133        this.metadataloaded = true;
7134        this.sendNotification(Notifications.ENABLE_FULL_SCREEN);
7135        this.sendNotification(Notifications.LOADED_METADATA);
7136      }
7137    }, {
7138      key: "applyTextTrackHandlers",
7139      value: function applyTextTrackHandlers(data) {
7140        var action = data === true ? "addEventListener" : "removeEventListener";
7141        var tracks = this.getMediaElement().textTracks;
7142        if (tracks != null) {
7143          tracks[action]("addtrack", this.textTrackHandlers.addtrack);
7144        }
7145      }
7146
7147      /** @override */
7148    }, {
7149      key: "createTracks",
7150      value: function createTracks() {
7151        var _this4 = this;
7152        var audio = this.getMediaElement().audioTracks;
7153        var tracks = this.facade.tracks.getAudioTracks();
7154        function changeEnabled(track) {
7155          var tracks = this.facade.tracks.getAudioTracks();
7156          tracks.some(function (item) {
7157            item.data.enabled = item.id == track.id;
7158          });
7159        }
7160        if (audio != null) {
7161          var count = audio.length || 0;
7162          fp.each(audio, function (item, index) {
7163            if (Utils.fieldIsUnique(tracks, 'id', item.id) === false) {
7164              return;
7165            }
7166            var track = new Track(item);
7167            track.changeEnabled = changeEnabled.bind(_this4, track);
7168            tracks.add(track, index + 1 === count);
7169          });
7170        }
7171      }
7172
7173      /** @private */
7174    }, {
7175      key: "reset",
7176      value: function reset() {
7177        this.data.currentTime = 0;
7178        this.data.duration = 0;
7179        this.data.src = null;
7180        this.data.ended = false;
7181        this.data.paused = false;
7182        this.data.seeking = false;
7183        this.data.started = false;
7184        this.data.loading = false;
7185        this.applyTextTrackHandlers(false);
7186      }
7187
7188      /**
7189       * @return {boolean}
7190       */
7191    }, {
7192      key: "getStarted",
7193      value: function getStarted() {
7194        return this.data.started;
7195      }
7196
7197      /**
7198       * The playback core
7199       *
7200       * @param {HTMLVideoElement} value
7201       *    The new playback core
7202       * @returns {HTMLVideoElement}
7203       *    The playback core
7204       * @type {HTMLVideoElement}
7205       *
7206       * @private
7207       */
7208    }, {
7209      key: "getMediaElement",
7210      value: function getMediaElement() {
7211        return this.facade.getMediaElement();
7212      }
7213
7214      /**
7215       *
7216       */
7217    }, {
7218      key: "canPlayMedium",
7219      value: function canPlayMedium(medium) {
7220        return medium === "video";
7221      }
7222
7223      /**
7224       *
7225       */
7226    }, {
7227      key: "canPlayTemporalType",
7228      value: function canPlayTemporalType(temporalType) {
7229        return temporalType !== "dvr";
7230      }
7231
7232      /**
7233       * Determines if the core can play a given mimeType.
7234       *
7235       * @return {String} "" if the core can't play the mimeType
7236       */
7237    }, {
7238      key: "canPlayType",
7239      value: function canPlayType(mimeType) {
7240        var canPlay = document.createElement("video").canPlayType(mimeType) || "";
7241
7242        //TODO: HACK. Fix for andrioid 4.1.2+ not returning "maybe"
7243        if ((/Android (4\.[1-9]|[5-6])/.test(navigator.userAgent) || /Silk\/3/.test(navigator.userAgent)) && mimeType === Utils.mimeTypes.m3u8) {
7244          canPlay = "maybe";
7245        }
7246
7247        //TODO: HACK. Fix for UCBrowser+ returning "probably" for Flash Sources
7248        if (canPlay === "probably" && /video\/f4m|x-flv/.test(mimeType) && /UCBrowser/.test(navigator.userAgent)) {
7249          canPlay = "";
7250        }
7251        return canPlay;
7252      }
7253
7254      /**
7255       * Indicates whether or not the video is playing.
7256       *
7257       * @returns {Boolean}
7258       *    The playing value
7259       * @type {Boolean}
7260       */
7261    }, {
7262      key: "getPaused",
7263      value: function getPaused() {
7264        return this.data.paused;
7265      }
7266
7267      /**
7268       * Indicates whether or not the video is playing.
7269       *
7270       * @returns {Boolean}
7271       *    The playing value
7272       * @type {Boolean}
7273       */
7274    }, {
7275      key: "getSeeking",
7276      value: function getSeeking() {
7277        return this.data.seeking;
7278      }
7279
7280      /**
7281       * The current time of the video in seconds. Value must be between currentTime and duration.
7282       *
7283       * @param {Number} value
7284       *    The new currentTime value in seconds
7285       * @returns {Number}
7286       *    The currentTime value in seconds
7287       * @type {Number}
7288       */
7289    }, {
7290      key: "getCurrentTime",
7291      value: function getCurrentTime() {
7292        return this.data.currentTime;
7293      }
7294    }, {
7295      key: "setCurrentTime",
7296      value: function setCurrentTime(value) {
7297        if (value === this.data.currentTime) {
7298          return;
7299        }
7300        this.data.currentTime = value;
7301        if (this.getStarted()) {
7302          this.seek(value);
7303        }
7304        return value;
7305      }
7306
7307      /** */
7308    }, {
7309      key: "getCurrentTimeUTC",
7310      value: function getCurrentTimeUTC() {
7311        var startDate = this.getStartDate();
7312        if (startDate == null || isNaN(startDate)) return 0;
7313        return Math.round(startDate + this.facade.getMediaElement().currentTime * 1000);
7314      }
7315    }, {
7316      key: "getStartDate",
7317      value: function getStartDate() {
7318        var config = this.facade.retrieveProxy(ConfigurationProxy.NAME);
7319        var mediaElement = this.facade.getMediaElement();
7320        if (mediaElement.getStartDate == null) {
7321          return config.getValueOf("startDate");
7322        }
7323        return mediaElement.getStartDate().getTime();
7324      }
7325      /** */
7326    }, {
7327      key: "toUTC",
7328      value: function toUTC(value) {
7329        if (!isFinite(value)) {
7330          return value;
7331        }
7332        var utc = this.getCurrentTimeUTC();
7333        if (utc === 0) {
7334          return value;
7335        }
7336        var time = this.getCurrentTime();
7337        var offset = Math.round((value - time) * 1000);
7338        return utc + offset;
7339      }
7340
7341      /** */
7342    }, {
7343      key: "fromUTC",
7344      value: function fromUTC(value) {
7345        if (!isFinite(value)) {
7346          return value;
7347        }
7348        var utc = this.getCurrentTimeUTC();
7349        if (utc === 0) {
7350          return value;
7351        }
7352        var time = this.getCurrentTime();
7353        var offset = (value - utc) / 1000;
7354        return time + offset;
7355      }
7356
7357      /** @private */
7358    }, {
7359      key: "seek",
7360      value: function seek() {
7361        var _this5 = this;
7362        var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.data.currentTime;
7363        return new Promise(function (resolve, reject) {
7364          try {
7365            var video = _this5.getMediaElement();
7366            var seeked = function seeked() {
7367              // NOTE: Call resolve after the seeked event has fired at the player level.
7368              _this5.facade.timers.setTimeout(resolve, 10, time);
7369            };
7370            video.once("seeked", seeked);
7371            video.currentTime = time;
7372            // HACK Android Chrome seeked event not firing
7373            var ua = navigator.userAgent;
7374            if (/Android.*Chrome/.test(ua)) {
7375              var interval = _this5.facade.timers.setInterval(function () {
7376                if (Math.round(video.currentTime) === Math.round(time)) {
7377                  _this5.facade.timers.clearInterval(interval);
7378                  video.dispatchEvent(new CustomEvent("seeked"));
7379                }
7380              }, 10);
7381            }
7382          } catch (error) {
7383            reject(error);
7384          }
7385        });
7386      }
7387
7388      /** */
7389    }, {
7390      key: "goLive",
7391      value: function goLive() {
7392        var mediaElement = this.getMediaElement();
7393        var time = mediaElement.duration === 2e308 ? mediaElement.seekable.end(0) : mediaElement.duration;
7394        mediaElement.currentTime = time;
7395      }
7396
7397      /**
7398       * The current time of the video in seconds. Value must be between currentTime and duration.
7399       *
7400       * @param {Number} value
7401       *    The new currentTime value in seconds
7402       * @returns {Number}
7403       *    The currentTime value in seconds
7404       * @type {Number}
7405       */
7406    }, {
7407      key: "getVolume",
7408      value: function getVolume() {
7409        var mediaElement = this.getMediaElement();
7410        if (mediaElement.muted === true) {
7411          return 0;
7412        } else {
7413          return mediaElement.volume;
7414        }
7415      }
7416    }, {
7417      key: "setVolume",
7418      value: function setVolume(value, type) {
7419        if (this.getMuted() && value > 0) {
7420          this.setMuted(false, false);
7421        } else if (!this.getMuted() && value === 0) {
7422          this.setMuted(true, false);
7423        }
7424        this.sendNotification(Notifications.VOLUME_CHANGE, this.getMediaElement().volume = value, type);
7425        return value;
7426      }
7427
7428      /** */
7429    }, {
7430      key: "getMuted",
7431      value: function getMuted() {
7432        return this.data.muted;
7433      }
7434    }, {
7435      key: "setMuted",
7436      value: function setMuted(value) {
7437        var changeVolume = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
7438        var type = arguments.length > 2 ? arguments[2] : undefined;
7439        if (this.data.muted === value) {
7440          return;
7441        }
7442        this.data.muted = value;
7443        var volume = this.data.volume;
7444        if (this.data.muted === true) {
7445          this.data.volume = this.getVolume();
7446          volume = 0;
7447        }
7448        this.getMediaElement().muted = value;
7449        if (changeVolume === true) {
7450          this.sendNotification(Notifications.CHANGE_VOLUME, volume);
7451          this.sendNotification(Notifications.VOLUME_CHANGE, volume, type);
7452        }
7453        this.sendNotification(Notifications.MUTE_CHANGE, this.data.muted);
7454        return value;
7455      }
7456
7457      /**
7458       * The duration of the video in seconds.
7459       *
7460       * @returns {Number}
7461       *    The duration of the video
7462       * @type {Number}
7463       */
7464    }, {
7465      key: "getDuration",
7466      value: function getDuration() {
7467        return this.data.duration;
7468      }
7469
7470      /**
7471       * Instructs the core to play.
7472       */
7473    }, {
7474      key: "play",
7475      value: function play() {
7476        var _this6 = this;
7477        this.sendNotification(Notifications.WAITING);
7478        if (this.data.started !== true) {
7479          this.data.started = true;
7480          this.setEnabled(true);
7481          this.playWhenLoaded = true;
7482          if (this.metadataloaded === false) {
7483            return;
7484          }
7485        } else if (this.data.loading === true) {
7486          this.playWhenLoaded = true;
7487          return;
7488        }
7489        if (this.getPaused()) {
7490          this.sendNotification(Notifications.RESUME);
7491        }
7492        Promise.resolve(this.getMediaElement().play())["catch"](function (error) {
7493          return AutoplayThreshold.value(true).then(function (threshold) {
7494            _this6.sendNotification(Notifications.REMOVE_APPLICATION_STATE, PlayState.WAITING);
7495            return _this6.sendNotification(Notifications.AUTOPLAY_BLOCKED, {
7496              threshold: threshold,
7497              policy: _this6.facade.autoplayPolicy
7498            });
7499          });
7500        });
7501      }
7502
7503      /**
7504       * Instructs the core to pause.
7505       */
7506    }, {
7507      key: "pause",
7508      value: function pause() {
7509        this.data.paused = true;
7510        this.getMediaElement().pause();
7511      }
7512    }, {
7513      key: "getSrc",
7514      value: function getSrc() {
7515        return this.facade.mediaProxy.getSrc();
7516      }
7517
7518      /**
7519       * Instructs the core to initailize.
7520       */
7521    }, {
7522      key: "init",
7523      value: function init() {
7524        this.data.loading = true;
7525        this.playWhenLoaded = false;
7526        this.metadataloaded = false;
7527        var element = this.getMediaElement();
7528        this.resume.id = element.once(this.resume.event, this.resume.listener);
7529        element.addEventListener("loadedmetadata", this.handlers.loadedmetadata);
7530        element.addEventListener("durationchange", this.handlers.durationchange);
7531        element.addEventListener("canplaythrough", this.handlers.canplaythrough);
7532        element.addEventListener("webkitneedkey", this.onneedkey);
7533        element.addEventListener("error", this.handlers.error);
7534        this.applyTextTrackHandlers(true);
7535        this.applySrc();
7536      }
7537
7538      /**
7539       * Preload
7540       */
7541    }, {
7542      key: "preload",
7543      value: function preload() {
7544        var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.facade.getPreload();
7545        if (value === Preload.NONE) {
7546          return;
7547        }
7548        var element = this.getMediaElement();
7549        element.preload = value;
7550        this.setEnabled(true);
7551      }
7552
7553      /**
7554       * Instructs the core to load.
7555       */
7556    }, {
7557      key: "load",
7558      value: function load() {
7559        var element = this.getMediaElement();
7560
7561        //HACK: Delay the load for IPAD IOS 7.1 and lower ver
7562        var ver = Utils.getIOSversion() || [];
7563        if (Utils.isIPad() && ver[0] < 8) {
7564          this.facade.timers.setTimeout(element.load.bind(element), 100);
7565        } else {
7566          element.load();
7567        }
7568      }
7569    }, {
7570      key: "unload",
7571      value: function unload() {}
7572    }, {
7573      key: "applySrc",
7574      value: function applySrc() {
7575        var src = this.getSrc();
7576        if (src == null || src === "") {
7577          this.sendNotification(Notifications.ERROR, "The value of src is not supported: " + value);
7578          return;
7579        }
7580        var element = this.getMediaElement();
7581        element.src = src;
7582        var muted = element.muted;
7583        if (muted === true) {
7584          this.data.muted = true;
7585        }
7586        this.load();
7587      }
7588    }, {
7589      key: "setMaxBitrate",
7590      value: function setMaxBitrate(value) {}
7591    }, {
7592      key: "getMaxBitrate",
7593      value: function getMaxBitrate() {}
7594    }, {
7595      key: "setQuality",
7596      value: function setQuality(value) {}
7597    }, {
7598      key: "getQuality",
7599      value: function getQuality() {}
7600    }, {
7601      key: "getQualityLevels",
7602      value: function getQualityLevels() {
7603        return [];
7604      }
7605    }, {
7606      key: "getQualityMode",
7607      value: function getQualityMode() {}
7608    }, {
7609      key: "setQualityMode",
7610      value: function setQualityMode(value) {}
7611    }, {
7612      key: "setMaxQualityLevel",
7613      value: function setMaxQualityLevel(value) {}
7614    }, {
7615      key: "getMaxQualityLevel",
7616      value: function getMaxQualityLevel() {}
7617    }, {
7618      key: "destroy",
7619      value: function destroy() {
7620        this.applyHandlers(false);
7621        var element = this.getMediaElement();
7622        element.removeEventListener(this.resume.event, element[this.resume.id]);
7623        element.removeEventListener("webkitneedkey", this.onneedkey);
7624        if (element.textTracks != null) {
7625          element.textTracks.removeEventListener("addtrack", this.textTrackHandlers.addtrack);
7626        }
7627      }
7628
7629      /**
7630      The EME specification (https://dvcs.w3.org/hg/html-media/raw-file/tip/encrypted-media/encrypted-media.html)
7631      is supported starting OSX 10.10 and greater.
7632      */
7633    }, {
7634      key: "onneedkey",
7635      value: function onneedkey(event) {
7636        var _this7 = this;
7637        var video = event.target;
7638        var keySystem = Utils.getKeySystem();
7639        var keys = this.facade.mediaProxy.getKeys()[KeySystem.FAIRPLAY];
7640        var fps = this.facade.fps;
7641        var disallowRetries = fps.allowKeyErrorRetries === false;
7642        if (keys == null || keySystem.indexOf(KeySystem.FAIRPLAY) === -1) {
7643          return;
7644        }
7645        if (this.keyErrored && disallowRetries) {
7646          this.getMediaElement().removeEventListener("webkitneedkey", this.onneedkey);
7647          return;
7648        }
7649        var initData = event.initData;
7650        // contentId is passed up as a URI, from which the host must be extracted:
7651        var contentId = fps.extractContentId(initData, keys);
7652        var serverUrl = fps.extractServerUrl(initData, keys);
7653        fps.requestCertificate(keys).then(function (cert) {
7654          return fps.concatInitDataIdAndCertificate(initData, contentId, cert);
7655        }).then(function (initData) {
7656          if (!WebKitMediaKeys.isTypeSupported(KeySystem.FAIRPLAY, "video/mp4")) {
7657            throw "Key System not supported";
7658          }
7659          if (video.webkitKeys == null) {
7660            video.webkitSetMediaKeys(new WebKitMediaKeys(KeySystem.FAIRPLAY));
7661          }
7662          if (video.webkitKeys == null) {
7663            throw "Could not create MediaKeys";
7664          }
7665          var session = video.webkitKeys.createSession("video/mp4", initData);
7666          if (session == null) {
7667            throw "Could not create key session";
7668          }
7669          session.addEventListener("webkitkeymessage", function (event) {
7670            fps.requestLicense(event.message, contentId, serverUrl, keys).then(function (key) {
7671              session.update(key);
7672            })["catch"](function (error) {
7673              session.close();
7674              _this7.keyErrored = true;
7675              _this7.facade.logger.error("[AMP DRM] A key request error was encountered.", error);
7676            });
7677          });
7678          session.addEventListener("webkitkeyadded", function (event) {
7679            _this7.facade.logger.log("[AMP DRM] Decryption key was added to session.");
7680          });
7681          session.addEventListener("webkitkeyerror", function (event) {
7682            _this7.sendNotification(Notifications.ERROR, {
7683              message: "A decryption key error was encountered for key system " + babelHelpers.toConsumableArray(keySystem),
7684              detail: event
7685            });
7686            session.close();
7687            _this7.keyErrored = true;
7688            _this7.facade.logger.log("[AMP DRM] A decryption key error was encountered.", event);
7689          });
7690        })["catch"](function (error) {
7691          _this7.facade.logger.error(error);
7692        });
7693      }
7694    }], [{
7695      key: "NAME",
7696      get: function get() {
7697        return "PlaybackProxy";
7698      }
7699    }]);
7700    return PlaybackProxy;
7701  }(puremvc.Proxy);
7702
7703  var PlaybackCoreProxy = /*#__PURE__*/function (_PlaybackProxy) {
7704    babelHelpers.inherits(PlaybackCoreProxy, _PlaybackProxy);
7705    /**
7706     * PlaybackCoreProxy constructor.
7707     *
7708     * @constructor
7709     * @private
7710     * @extends {PlaybackProxy}
7711     */
7712
7713    function PlaybackCoreProxy() {
7714      var _this;
7715      var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7716      var plugin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7717      babelHelpers.classCallCheck(this, PlaybackCoreProxy);
7718      _this = _PlaybackProxy.call(this) || this;
7719      _this.playbackCoreName = "default";
7720      _this.config = config;
7721      _this.plugin = plugin;
7722      _this.supportedTypes = null;
7723      if (_this.config.types != null) {
7724        _this.supportedTypes = _this.config.types;
7725      }
7726      _this.temporalTypes = ["vod", "live", "ondemand"];
7727      _this.decryptionTypes = [KeySystem.FAIRPLAY, KeySystem.CLEARKEY];
7728
7729      // keep loaders avail if before playback cores get fully avail 
7730      if (PlaybackCoreProxy._customLoaders == null) PlaybackCoreProxy._customLoaders = [];
7731      return _this;
7732    }
7733    babelHelpers.createClass(PlaybackCoreProxy, [{
7734      key: "customLoaders",
7735      get: function get() {
7736        return PlaybackCoreProxy.getCustomLoaders();
7737      }
7738
7739      /** */
7740    }, {
7741      key: "renderer",
7742      value: function renderer() {
7743        var _this2 = this;
7744        var id = this.playbackCoreName;
7745        var canPlay = function canPlay(media) {
7746          return _this2.canPlayMedium(media.medium) === true && _this2.canPlayTemporalType(media.temporalType) === true && _this2.canPlayType(media.type) !== "" && _this2.canPlayDRM(media.keys) !== "";
7747        };
7748        var factory = function factory(player) {
7749          return Promise.resolve(_this2);
7750        };
7751        return {
7752          id: id,
7753          canPlay: canPlay,
7754          factory: factory
7755        };
7756      }
7757
7758      /** */
7759    }, {
7760      key: "onRegister",
7761      value: function onRegister() {
7762        this.mediaProxy = this.facade.retrieveProxy(MediaProxy.NAME);
7763      }
7764
7765      /** */
7766    }, {
7767      key: "getPlaybackCoreName",
7768      value: function getPlaybackCoreName() {
7769        return this.playbackCoreName;
7770      }
7771
7772      /** */
7773    }, {
7774      key: "getSupportedTypes",
7775      value: function getSupportedTypes() {
7776        return this.supportedTypes || [];
7777      }
7778
7779      /** */
7780    }, {
7781      key: "setSupportedTypes",
7782      value: function setSupportedTypes(types) {
7783        this.supportedTypes = types;
7784        return types;
7785      }
7786
7787      /** */
7788    }, {
7789      key: "getTemporalTypes",
7790      value: function getTemporalTypes() {
7791        return this.temporalTypes || [];
7792      }
7793    }, {
7794      key: "getDecryptionTypes",
7795      value: function getDecryptionTypes() {
7796        return this.decryptionTypes || [];
7797      }
7798
7799      /** */
7800    }, {
7801      key: "setTemporalTypes",
7802      value: function setTemporalTypes(types) {
7803        this.temporalTypes = types;
7804        return types;
7805      }
7806
7807      /** @override */
7808    }, {
7809      key: "canPlayTemporalType",
7810      value: function canPlayTemporalType(temporalType) {
7811        return this.getTemporalTypes().indexOf(temporalType) !== -1;
7812      }
7813
7814      /** @override */
7815    }, {
7816      key: "canPlayType",
7817      value: function canPlayType(mimeType) {
7818        if (this.supportedTypes != null) {
7819          if (this.getSupportedTypes().indexOf(mimeType) !== -1) {
7820            return "maybe";
7821          } else {
7822            return "";
7823          }
7824        } else {
7825          return babelHelpers.get(babelHelpers.getPrototypeOf(PlaybackCoreProxy.prototype), "canPlayType", this).call(this, mimeType);
7826        }
7827      }
7828    }, {
7829      key: "canPlayDRM",
7830      value: function canPlayDRM(keys) {
7831        var decryptionTypes = this.getDecryptionTypes();
7832        var availableKeySystem = Utils.getKeySystem() || [];
7833        var isEmpty = function isEmpty(obj) {
7834          return fp.transform(Object.keys(obj), fp.filter(function (key) {
7835            return obj.hasOwnProperty(key);
7836          })).length === 0;
7837        };
7838        if (keys == null || isEmpty(keys)) return 'maybe';
7839        return fp.find(Object.keys(keys), fp.filter(function (key) {
7840          return decryptionTypes.indexOf(key) !== -1;
7841        }), fp.filter(function (key) {
7842          return availableKeySystem.indexOf(key) !== -1;
7843        }), fp.map(function (r) {
7844          return r ? "maybe" : "";
7845        })) || "";
7846      }
7847
7848      /**
7849       * XMLHttpRequest loader
7850       * @name customLoader
7851       * @function
7852       */
7853
7854      /** 
7855       * 
7856       * @override 
7857       * @param {customLoader} loader - callback function
7858       * @param {string} name - Playback core name of the loader 
7859       * @param {string} type - optional config core type 
7860       */
7861    }, {
7862      key: "registerCustomLoader",
7863      value: function registerCustomLoader(loader) {
7864        var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.playbackCoreName;
7865        var type = arguments.length > 2 ? arguments[2] : undefined;
7866        return this.customLoaders.push({
7867          loader: loader,
7868          name: name,
7869          type: type
7870        });
7871      }
7872    }, {
7873      key: "getActiveLoaders",
7874      value: function getActiveLoaders() {
7875        var _this3 = this;
7876        return fp.transform(this.customLoaders, fp.filter(function (loader) {
7877          return loader.name === _this3.playbackCoreName;
7878        }));
7879      }
7880    }, {
7881      key: "removeCustomLoader",
7882      value: function removeCustomLoader(index) {
7883        if (index > -1) return this.customLoaders.splice(index, 1);
7884      }
7885    }], [{
7886      key: "getCustomLoaders",
7887      value: function getCustomLoaders() {
7888        return PlaybackCoreProxy._customLoaders;
7889      }
7890    }]);
7891    return PlaybackCoreProxy;
7892  }(PlaybackProxy);
7893
7894  var DVRPlaybackProxy = /*#__PURE__*/function (_PlaybackCoreProxy) {
7895    babelHelpers.inherits(DVRPlaybackProxy, _PlaybackCoreProxy);
7896    /**
7897     * DVRPlaybackProxy constructor.
7898     *
7899     * @constructor
7900     * @private
7901     * @extends {PlaybackCoreProxy}
7902     */
7903    function DVRPlaybackProxy() {
7904      var _this;
7905      babelHelpers.classCallCheck(this, DVRPlaybackProxy);
7906      _this = _PlaybackCoreProxy.call(this) || this;
7907      _this.playbackCoreName = "dvr";
7908      _this.interval = null;
7909      return _this;
7910    }
7911
7912    /** @override */
7913    babelHelpers.createClass(DVRPlaybackProxy, [{
7914      key: "ondurationchange",
7915      value: function ondurationchange(event) {
7916        this.updateDuration();
7917      }
7918
7919      /** @override */
7920    }, {
7921      key: "ontimeupdate",
7922      value: function ontimeupdate(event) {
7923        this.updateCurrentTime();
7924      }
7925
7926      /** @override */
7927    }, {
7928      key: "onplay",
7929      value: function onplay(event) {
7930        this.stopTimer();
7931        babelHelpers.get(babelHelpers.getPrototypeOf(DVRPlaybackProxy.prototype), "onplay", this).call(this, event);
7932      }
7933
7934      /** @override */
7935    }, {
7936      key: "onplaying",
7937      value: function onplaying(event) {
7938        this.stopTimer();
7939        babelHelpers.get(babelHelpers.getPrototypeOf(DVRPlaybackProxy.prototype), "onplaying", this).call(this, event);
7940      }
7941
7942      /** @override */
7943    }, {
7944      key: "onpause",
7945      value: function onpause(event) {
7946        this.startTimer();
7947        babelHelpers.get(babelHelpers.getPrototypeOf(DVRPlaybackProxy.prototype), "onpause", this).call(this, event);
7948      }
7949
7950      /** @override */
7951    }, {
7952      key: "canPlayTemporalType",
7953      value: function canPlayTemporalType(temporalType) {
7954        return temporalType === "dvr";
7955      }
7956
7957      /** */
7958    }, {
7959      key: "getDuration",
7960      value: function getDuration() {
7961        var mediaElement = this.getMediaElement();
7962        if (mediaElement.duration === 2e308) {
7963          this.updateDuration();
7964        }
7965        return this.data.duration;
7966      }
7967
7968      /** */
7969    }, {
7970      key: "getStartTime",
7971      value: function getStartTime() {
7972        return this.getMediaElement().seekable.start(0);
7973      }
7974
7975      /** */
7976    }, {
7977      key: "getFragmentDuration",
7978      value: function getFragmentDuration() {
7979        var config = this.facade.retrieveProxy(ConfigurationProxy.NAME);
7980        var fragmentDuration = config.getValueOf("fragmentDuration");
7981        return fragmentDuration || 10;
7982      }
7983
7984      /** */
7985    }, {
7986      key: "getLiveTime",
7987      value: function getLiveTime() {
7988        return this.getDuration() - this.getFragmentDuration();
7989      }
7990
7991      /** */
7992    }, {
7993      key: "isLive",
7994      value: function isLive() {
7995        return this.getStartTime() + this.getCurrentTime() >= this.getLiveTime();
7996      }
7997
7998      /** @override */
7999    }, {
8000      key: "seek",
8001      value: function seek(value) {
8002        var _this2 = this;
8003        return babelHelpers.get(babelHelpers.getPrototypeOf(DVRPlaybackProxy.prototype), "seek", this).call(this, value + this.getStartTime()).then(function (time) {
8004          _this2.sendNotification(Notifications.IS_LIVE, _this2.isLive());
8005        });
8006      }
8007
8008      /** */
8009    }, {
8010      key: "updateCurrentTime",
8011      value: function updateCurrentTime() {
8012        var seekable = this.getMediaElement().seekable;
8013        if (seekable.length === 0) {
8014          return;
8015        }
8016        var currentTime = this.getMediaElement().currentTime;
8017        this.data.currentTime = currentTime - seekable.start(0);
8018        // don't let playback go out of the DVR window
8019        if (this.data.currentTime < 0) {
8020          return this.goLive();
8021        }
8022        this.sendNotification(Notifications.TIME_CHANGE, {
8023          currentTime: this.data.currentTime
8024        });
8025        this.mediaProxy.setIsLive(this.isLive());
8026      }
8027
8028      /** */
8029    }, {
8030      key: "updateDuration",
8031      value: function updateDuration() {
8032        var seekable = this.getMediaElement().seekable;
8033        if (seekable.length === 0) {
8034          return;
8035        }
8036        this.data.duration = seekable.end(0) - seekable.start(0);
8037        this.sendNotification(Notifications.CHANGE_DURATION, this.data.duration);
8038      }
8039
8040      /** */
8041    }, {
8042      key: "startTimer",
8043      value: function startTimer() {
8044        this.interval = this.facade.timers.setInterval(this.updateCurrentTime.bind(this), 1000);
8045      }
8046
8047      /** */
8048    }, {
8049      key: "stopTimer",
8050      value: function stopTimer() {
8051        if (this.interval != null) {
8052          this.facade.timers.clearInterval(this.interval);
8053          this.interval = null;
8054          this.updateCurrentTime();
8055        }
8056      }
8057    }]);
8058    return DVRPlaybackProxy;
8059  }(PlaybackCoreProxy);
8060
8061  var ClassList = /*#__PURE__*/function () {
8062    /**
8063     * The ClassList class.
8064     *
8065     * @param {!DOMElement}  element
8066     *    The DOM Element
8067     *
8068     * @constructor
8069     */
8070    function ClassList(element) {
8071      babelHelpers.classCallCheck(this, ClassList);
8072      this.element = element;
8073      this.prefix = "amp-";
8074    }
8075
8076    /** */
8077    babelHelpers.createClass(ClassList, [{
8078      key: "contains",
8079      value: function contains(className) {
8080        return this.constructor.contains(className, this.element, this.prefix);
8081      }
8082
8083      /** */
8084    }, {
8085      key: "add",
8086      value: function add(className) {
8087        this.constructor.add(className, this.element, this.prefix);
8088      }
8089
8090      /** */
8091    }, {
8092      key: "remove",
8093      value: function remove(className) {
8094        this.constructor.remove(className, this.element, this.prefix);
8095      }
8096
8097      /** */
8098    }, {
8099      key: "toggle",
8100      value: function toggle(className) {
8101        return this.constructor.contains(className, this.element, this.prefix);
8102      }
8103
8104      /** */
8105    }], [{
8106      key: "contains",
8107      value: function contains(className, element) {
8108        var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
8109        return element.classList.contains(prefix + className);
8110      }
8111
8112      /** */
8113    }, {
8114      key: "add",
8115      value: function add(className, element) {
8116        var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
8117        element.classList.add(prefix + className);
8118      }
8119
8120      /** */
8121    }, {
8122      key: "remove",
8123      value: function remove(className, element) {
8124        var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
8125        element.classList.remove(prefix + className);
8126      }
8127
8128      /** */
8129    }, {
8130      key: "toggle",
8131      value: function toggle(className, element) {
8132        var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
8133        element.classList.toggle(prefix + className);
8134      }
8135    }]);
8136    return ClassList;
8137  }();
8138
8139  var UI = /*#__PURE__*/function () {
8140    function UI() {
8141      babelHelpers.classCallCheck(this, UI);
8142    }
8143    babelHelpers.createClass(UI, null, [{
8144      key: "create",
8145      value:
8146      /**
8147       * Creates an HTML element.
8148       *
8149       * @param   {?(string|Array.<string>)}  type
8150       * @param   {?DOMElement}  parent
8151       * @param   {?string|DOMElement}  element
8152       * @param   {?string} text
8153       * @return  {DOMElement}
8154       */
8155      function create(type, parent) {
8156        var element = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "div";
8157        var text = arguments.length > 3 ? arguments[3] : undefined;
8158        if (typeof element === "string") {
8159          element = document.createElement(element);
8160        }
8161        var classList = new ClassList(element);
8162        if (type != null) {
8163          if (typeof type === "string") {
8164            type = [type];
8165          }
8166          type.forEach(function (item) {
8167            return classList.add(item);
8168          });
8169        }
8170        element._classList = classList;
8171        if (text != null) {
8172          element.textContent = text;
8173        }
8174        if (parent != null) {
8175          var viewComponent;
8176          if (parent.getViewComponent != null) {
8177            viewComponent = parent.getViewComponent();
8178          }
8179          if (viewComponent != null) {
8180            parent = viewComponent;
8181          }
8182          parent.appendChild(element);
8183        }
8184        return element;
8185      }
8186
8187      /**
8188       * Creates a DOM element.
8189       *
8190       * @param   {?string}  type
8191       * @param   {?Object}  props
8192       * @param   {?Array.<string|Object>}  children
8193       * @return  {DOMElement}
8194       */
8195    }, {
8196      key: "createElement",
8197      value: function createElement(type, props, children) {
8198        if (type && babelHelpers["typeof"](type) == "object") {
8199          props = type;
8200          children = type.children;
8201          type = type.type;
8202        }
8203        if (!type) type = "div";
8204        if (!props) props = {};
8205        if (!children) children = [];
8206        var element = document.createElement(type);
8207        var propList = ["innerHTML", "className"];
8208        var ignore = ["type", "children"];
8209        fp.each(props, function (value, key) {
8210          if (ignore.includes(key)) return;
8211          if (propList.includes(key)) return element[key] = value;
8212          if (key === "style" && value && babelHelpers["typeof"](value) === "object") value = CSS.toCSS(value);
8213          element.setAttribute(key, value);
8214        });
8215        children.forEach(function (child) {
8216          var type = babelHelpers["typeof"](child);
8217          if (child == null) {
8218            return;
8219          }
8220          if (type === "string") {
8221            child = document.createTextNode(child);
8222          } else if (type === "object") {
8223            if (child instanceof Array) return;
8224            child = UI.createElement(child);
8225          } else {
8226            return;
8227          }
8228          element.appendChild(child);
8229        });
8230        return element;
8231      }
8232
8233      /**
8234       * Binds a mediators event handlers to an element.
8235       *
8236       * @param {!DOMElement} element
8237       * @param {!mediator} mediator
8238       */
8239    }, {
8240      key: "bindEvents",
8241      value: function bindEvents(element, handlers) {
8242        var exceptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ["onRemove", "onRegister"];
8243        fp.each(handlers, function (value, key) {
8244          if (!exceptions.includes(key) && /^on/.test(key) && value && value.bind) {
8245            element[key] = value.bind(handlers);
8246          }
8247        });
8248      }
8249    }]);
8250    return UI;
8251  }();
8252
8253  var ModuleMediator = /*#__PURE__*/function (_puremvc$Mediator) {
8254    babelHelpers.inherits(ModuleMediator, _puremvc$Mediator);
8255    /**
8256     * The ModuleMediator class.
8257     *
8258     * @param {string} name
8259     * @param {Object} viewComponent
8260     * @constructor
8261     * @private
8262     * @extends {puremvc.Mediator}
8263     */
8264    function ModuleMediator(name, viewComponent) {
8265      var _this;
8266      babelHelpers.classCallCheck(this, ModuleMediator);
8267      _this = _puremvc$Mediator.call(this, name, viewComponent) || this;
8268      _this.mediatorName = name;
8269      _this.config = null;
8270      _this.classList = null;
8271      return _this;
8272    }
8273
8274    /** @override */
8275    babelHelpers.createClass(ModuleMediator, [{
8276      key: "initializeNotifier",
8277      value: function initializeNotifier(key) {
8278        babelHelpers.get(babelHelpers.getPrototypeOf(ModuleMediator.prototype), "initializeNotifier", this).call(this, key);
8279        var base = this.facade.player || this.facade;
8280        this.config = base.retrieveProxy(ModuleProxy.NAME);
8281        this.classList = new ClassList(this.viewComponent);
8282      }
8283    }]);
8284    return ModuleMediator;
8285  }(puremvc.Mediator);
8286
8287  var LocalizedMediator = /*#__PURE__*/function (_ModuleMediator) {
8288    babelHelpers.inherits(LocalizedMediator, _ModuleMediator);
8289    /**
8290     * @constructor
8291     * @private
8292     */
8293    function LocalizedMediator(name, viewComponent) {
8294      var _this;
8295      babelHelpers.classCallCheck(this, LocalizedMediator);
8296      _this = _ModuleMediator.call(this, name, viewComponent) || this;
8297      _this.localizationManager = null;
8298      return _this;
8299    }
8300
8301    /** @override */
8302    babelHelpers.createClass(LocalizedMediator, [{
8303      key: "initializeNotifier",
8304      value: function initializeNotifier(key) {
8305        babelHelpers.get(babelHelpers.getPrototypeOf(LocalizedMediator.prototype), "initializeNotifier", this).call(this, key);
8306        var target = this.facade.player || this.facade;
8307        this.localizationManager = target.retrieveProxy(LocalizationProxy.NAME);
8308      }
8309    }]);
8310    return LocalizedMediator;
8311  }(ModuleMediator);
8312
8313  var ComponentMediator = /*#__PURE__*/function (_LocalizedMediator) {
8314    babelHelpers.inherits(ComponentMediator, _LocalizedMediator);
8315    /**
8316     * @constructor
8317     * @extends {LocalizedMediator}
8318     * @private
8319     */
8320    function ComponentMediator(componentName, componentType, parent, element) {
8321      var _this;
8322      babelHelpers.classCallCheck(this, ComponentMediator);
8323      _this = _LocalizedMediator.call(this, componentName || Utils.createUID()) || this;
8324      _this.componentType = componentType;
8325      _this.parent = parent;
8326      _this.element = element;
8327      _this.componentName = null;
8328      if (componentName != null) {
8329        _this.componentName = componentName;
8330      }
8331      if (_this.mediatorName == null) {
8332        _this.mediatorName = _this.createMediatorName();
8333      }
8334      _this.classList = null;
8335      _this.state = null;
8336      _this.disabled = false;
8337      return _this;
8338    }
8339
8340    /** */
8341    babelHelpers.createClass(ComponentMediator, [{
8342      key: "onRegister",
8343      value: function onRegister() {
8344        if (this.viewComponent != null) return;
8345        this.viewComponent = this.createViewComponent(this.parent, this.element);
8346        this.classList = this.viewComponent._classList;
8347        UI.bindEvents(this.viewComponent, this);
8348      }
8349
8350      /** */
8351    }, {
8352      key: "createViewComponent",
8353      value: function createViewComponent(parent, element) {
8354        var type = this.getTypeList();
8355        return UI.create(type, parent, element);
8356      }
8357
8358      /** */
8359    }, {
8360      key: "createMediatorName",
8361      value: function createMediatorName() {
8362        var type = this.getTypeList();
8363        type.push("mediator");
8364        type.push(Utils.createUID());
8365        return type.join("-");
8366      }
8367
8368      /** */
8369    }, {
8370      key: "getTypeList",
8371      value: function getTypeList() {
8372        var type = [];
8373        if (this.componentName != null) {
8374          type.push(this.componentName);
8375        }
8376        if (this.componentType != null) {
8377          type = type.concat(this.componentType);
8378        }
8379        return type;
8380      }
8381
8382      /** */
8383    }, {
8384      key: "create",
8385      value: function create(type) {
8386        var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
8387        var element = arguments.length > 2 ? arguments[2] : undefined;
8388        var text = arguments.length > 3 ? arguments[3] : undefined;
8389        if (parent === false) {
8390          parent = null;
8391        }
8392        return UI.create(type, parent, element, text);
8393      }
8394
8395      /** */
8396    }, {
8397      key: "createText",
8398      value: function createText(type, text) {
8399        var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this;
8400        var element = arguments.length > 3 ? arguments[3] : undefined;
8401        return UI.create(type, parent, element, text);
8402      }
8403
8404      /** */
8405    }, {
8406      key: "setState",
8407      value: function setState(value) {
8408        if (value === this.state) {
8409          return;
8410        }
8411        if (this.state != null) {
8412          this.classList.remove(this.state);
8413        }
8414        this.state = value;
8415        if (this.state != null) {
8416          this.classList.add(this.state);
8417        }
8418        return value;
8419      }
8420
8421      /** */
8422    }, {
8423      key: "getState",
8424      value: function getState() {
8425        return this.state;
8426      }
8427
8428      /** */
8429    }, {
8430      key: "setDisabled",
8431      value: function setDisabled(value) {
8432        if (value === this.disabled) {
8433          return;
8434        }
8435        this.disabled = value;
8436        if (this.disabled) {
8437          this.classList.add("disabled");
8438        } else {
8439          this.classList.remove("disabled");
8440        }
8441        return value;
8442      }
8443
8444      /** */
8445    }, {
8446      key: "getDisabled",
8447      value: function getDisabled() {
8448        return this.disabled;
8449      }
8450    }]);
8451    return ComponentMediator;
8452  }(LocalizedMediator);
8453
8454  var MediaElementMediator = /*#__PURE__*/function (_ComponentMediator) {
8455    babelHelpers.inherits(MediaElementMediator, _ComponentMediator);
8456    /**
8457     * @constructor
8458     * @private
8459     * @extends {ComponentMediator}
8460     */
8461    function MediaElementMediator(componentName, viewComponent) {
8462      var _this;
8463      babelHelpers.classCallCheck(this, MediaElementMediator);
8464      _this = _ComponentMediator.call(this, componentName, "media-element", null, viewComponent) || this;
8465      _this.mediatorName = "".concat(_this.componentType, "-mediator");
8466      _this.created = false;
8467      return _this;
8468    }
8469    babelHelpers.createClass(MediaElementMediator, [{
8470      key: "onRegister",
8471      value: function onRegister() {
8472        if (this.created !== true) {
8473          this.created = true;
8474          babelHelpers.get(babelHelpers.getPrototypeOf(MediaElementMediator.prototype), "onRegister", this).call(this);
8475        }
8476      }
8477    }]);
8478    return MediaElementMediator;
8479  }(ComponentMediator);
8480
8481  var AudioPlaybackProxy = /*#__PURE__*/function (_PlaybackCoreProxy) {
8482    babelHelpers.inherits(AudioPlaybackProxy, _PlaybackCoreProxy);
8483    /**
8484     * AudioPlaybackProxy constructor.
8485     *
8486     * @constructor
8487     * @private
8488     * @extends {PlaybackCoreProxy}
8489     */
8490    function AudioPlaybackProxy() {
8491      var _this;
8492      babelHelpers.classCallCheck(this, AudioPlaybackProxy);
8493      _this = _PlaybackCoreProxy.call(this) || this;
8494      _this.playbackCoreName = "audio";
8495      return _this;
8496    }
8497
8498    /** @override */
8499    babelHelpers.createClass(AudioPlaybackProxy, [{
8500      key: "onRegister",
8501      value: function onRegister() {
8502        var mediaElement = new MediaElementMediator("html5", "audio");
8503        this.sendNotification(Notifications.PLAYBACK_CORE_CHANGE, mediaElement);
8504        babelHelpers.get(babelHelpers.getPrototypeOf(AudioPlaybackProxy.prototype), "onRegister", this).call(this);
8505      }
8506
8507      /** @override */
8508    }, {
8509      key: "onRemove",
8510      value: function onRemove() {
8511        this.facade.createMediaElement();
8512      }
8513
8514      /**
8515       *
8516       */
8517    }, {
8518      key: "canPlayMedium",
8519      value: function canPlayMedium(medium) {
8520        return medium === "audio";
8521      }
8522
8523      /** @override */
8524    }, {
8525      key: "canPlayType",
8526      value: function canPlayType(mimeType) {
8527        if (/audio/.test(mimeType)) {
8528          return "maybe";
8529        } else if (/mpegURL/.test(mimeType) && (Utils.isIOS() || Utils.getSafariVersion() !== -1)) {
8530          return "maybe";
8531        }
8532        return "";
8533      }
8534    }]);
8535    return AudioPlaybackProxy;
8536  }(PlaybackCoreProxy);
8537
8538  var PlayerProxy = /*#__PURE__*/function (_puremvc$Proxy) {
8539    babelHelpers.inherits(PlayerProxy, _puremvc$Proxy);
8540    /**
8541     * Creates a new instance of PlayerProxy.
8542     *
8543     * @constructor
8544     * @private
8545     * @extends {puremvc.Proxy}
8546     */
8547    function PlayerProxy(defaultPlaybackCore, config) {
8548      var _this;
8549      babelHelpers.classCallCheck(this, PlayerProxy);
8550      _this = _puremvc$Proxy.call(this) || this;
8551      _this.defaultPlaybackCore = defaultPlaybackCore;
8552      _this.activePlaybackCore = null;
8553      _this.renderers = [];
8554      if (_this.getPlaybackOrder == null) {
8555        var defaultPlaybackOrder = function defaultPlaybackOrder(order) {
8556          var playbackOrder = config.playbackOrder || [];
8557          if (playbackOrder.length > 0) {
8558            return playbackOrder;
8559          } else if (/Edge|Android/.test(navigator.userAgent)) {
8560            return ["audio", "hls", "dash", "dvr", "default"];
8561          }
8562        };
8563        _this.getPlaybackOrder = config.getPlaybackOrder || defaultPlaybackOrder;
8564      }
8565      _this.canPlay = _this.canPlay.bind(babelHelpers.assertThisInitialized(_this));
8566      return _this;
8567    }
8568
8569    /**
8570     * The name of the this Proxy.
8571     *
8572     * @static
8573     * @type {string}
8574     */
8575    babelHelpers.createClass(PlayerProxy, [{
8576      key: "onRegister",
8577      value: /** */
8578      function onRegister() {
8579        babelHelpers.get(babelHelpers.getPrototypeOf(PlayerProxy.prototype), "onRegister", this).call(this);
8580        this.registerPlaybackCore(new DVRPlaybackProxy());
8581        this.registerPlaybackCore(this.defaultPlaybackCore);
8582        this.registerPlaybackCore(new AudioPlaybackProxy());
8583        this.activePlaybackCore = this.defaultPlaybackCore;
8584      }
8585
8586      // sort core map after plugins have registered
8587    }, {
8588      key: "ready",
8589      value: function ready() {
8590        if (typeof this.getPlaybackOrder !== "function") {
8591          return;
8592        }
8593        var order = this.getPlaybackOrder(this.renderers.map(function (r) {
8594          return r.id;
8595        }));
8596        if (order == null) {
8597          return;
8598        }
8599        this.renderers = this.renderers.sort(function (a, b) {
8600          a = order.indexOf(a.id);
8601          b = order.indexOf(b.id);
8602          if (a === b) {
8603            return 0;
8604          }
8605          if (a === -1 && b !== -1) {
8606            return 1;
8607          }
8608          if (a !== -1 && b === -1) {
8609            return -1;
8610          }
8611          return a - b;
8612        });
8613      }
8614
8615      /** */
8616    }, {
8617      key: "getActivePlaybackCore",
8618      value: function getActivePlaybackCore() {
8619        return this.activePlaybackCore;
8620      }
8621
8622      /** */
8623    }, {
8624      key: "registerPlaybackCore",
8625      value: function registerPlaybackCore(core) {
8626        this.registerRenderer(core.renderer());
8627      }
8628
8629      /** */
8630    }, {
8631      key: "registerRenderer",
8632      value: function registerRenderer(renderer) {
8633        var id = renderer.id;
8634        if (this.renderers[id] != null) {
8635          return;
8636        }
8637        this.renderers.push(renderer);
8638        this.renderers[id] = renderer;
8639      }
8640
8641      /** */
8642    }, {
8643      key: "retrieveRenderer",
8644      value: function retrieveRenderer(name) {
8645        return this.renderers[name];
8646      }
8647
8648      /** */
8649    }, {
8650      key: "retrieveRendererFor",
8651      value: function retrieveRendererFor(media) {
8652        var _this2 = this;
8653        var factories = fp.transform(this.renderers, fp.filter(function (r) {
8654          return r.canPlay(media);
8655        }),
8656        // filter out renderers that can't play the media
8657        fp.map(function (r) {
8658          return r.factory;
8659        }) // return just the renderer's factory function
8660        );
8661
8662        return Utils.first(factories, this.facade).then(function (renderer) {
8663          return renderer === _this2.facade ? null : renderer;
8664        });
8665      }
8666
8667      /** */
8668    }, {
8669      key: "removeRenderer",
8670      value: function removeRenderer(name) {
8671        if (this.renderers[name] == null) {
8672          return;
8673        }
8674        var item = this.renderers[name];
8675        var index = this.renderers.indexOf(item);
8676        this.renderers.splice(index, 1);
8677        delete this.renderers[name];
8678        return item;
8679      }
8680
8681      /** */
8682    }, {
8683      key: "setPlaybackCore",
8684      value: function setPlaybackCore(media) {
8685        var _this3 = this;
8686        return this.retrieveRendererFor(media).then(function (core) {
8687          if (core == null) {
8688            throw _this3.facade.createMediaError(MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED);
8689          }
8690          var playbackProxy = _this3.facade.retrieveProxy(PlaybackProxy.NAME);
8691          if (playbackProxy !== core) {
8692            if (typeof playbackProxy.destroy === "function") {
8693              playbackProxy.destroy();
8694            }
8695            _this3.facade.removeProxy(PlaybackProxy.NAME);
8696            _this3.facade.registerProxy(core);
8697            core.setData(playbackProxy.getData());
8698          } else {
8699            if (typeof playbackProxy.unload === "function") {
8700              playbackProxy.unload();
8701            }
8702          }
8703          _this3.activePlaybackCore = core;
8704          return core;
8705        });
8706      }
8707
8708      /** */
8709    }, {
8710      key: "canPlay",
8711      value: function canPlay(media) {
8712        return this.renderers.some(function (r) {
8713          return r.canPlay(media);
8714        });
8715      }
8716    }], [{
8717      key: "NAME",
8718      get: function get() {
8719        return "PlayerProxy";
8720      }
8721    }]);
8722    return PlayerProxy;
8723  }(puremvc.Proxy);
8724
8725  var MediaProxy = /*#__PURE__*/function (_puremvc$Proxy) {
8726    babelHelpers.inherits(MediaProxy, _puremvc$Proxy);
8727    /**
8728     * Creates a new instance of MediaProxy. Used to track metadata associated with the video such as src, title and duration.
8729     *
8730     * @constructor
8731     * @private
8732     * @extends {puremvc.Proxy}
8733     */
8734    function MediaProxy(config) {
8735      var _this;
8736      babelHelpers.classCallCheck(this, MediaProxy);
8737      _this = _puremvc$Proxy.call(this) || this;
8738      _this.data = {
8739        metadata: {}
8740      };
8741      _this.applyDefaults = _this.applyDefaults.bind(babelHelpers.assertThisInitialized(_this));
8742      _this.started = false;
8743      return _this;
8744    }
8745
8746    /**
8747     * The name of the this Proxy.
8748     *
8749     * @static
8750     * @type {string}
8751     */
8752    babelHelpers.createClass(MediaProxy, [{
8753      key: "getData",
8754      value:
8755      /**
8756       * Sets the data for this proxy.
8757       *
8758       * @param {Object} value
8759       *    The new data for this proxy
8760       * @override
8761       */
8762      function getData() {
8763        var data = Utils.clone(babelHelpers.get(babelHelpers.getPrototypeOf(MediaProxy.prototype), "getData", this).call(this));
8764        if (data.authorization == null) {
8765          data.authorization = Utils.clone(this.facade.security.data);
8766        }
8767        return data;
8768      }
8769
8770      /**
8771       * Sets the data for this proxy.
8772       *
8773       * @param {Object} value
8774       *    The new data for this proxy
8775       * @override
8776       */
8777    }, {
8778      key: "setData",
8779      value: function setData(value) {
8780        if (this.data != null && this.facade.getCurrentTime() < this.facade.getDuration()) {
8781          this.sendNotification(Notifications.MEDIA_SEQUENCE_ABORTED);
8782        }
8783        this.started = false;
8784        this.setAutoplay(value.autoplay);
8785        this.setType(value.type);
8786        this.setIsLive(value.isLive);
8787        this.setTemporalType(value.temporalType);
8788        if (value.source != null) {
8789          this.setSource(value.source);
8790        }
8791        if (value.src != null) {
8792          this.setSrc(value.src);
8793        }
8794        this.setTitle(value.title);
8795        this.setDuration(value.duration);
8796        this.setPoster(value.poster);
8797        this.setGUID(value.guid);
8798        this.setLink(value.link);
8799        this.setEmbed(value.embed);
8800        this.setWidth(value.width);
8801        this.setHeight(value.height);
8802        this.setCategory(value.category);
8803        this.setStartTime(value.startTime);
8804        this.setDescription(value.description);
8805        this.setStatus(value.status);
8806        this.setCategory(value.category);
8807        this.setMetadata(value.metadata);
8808        this.setAuthorization(value.authorization);
8809        this.setMedium(value.medium);
8810        this.setPubDate(value.pubDate);
8811        this.setTrack(value.track);
8812        this.setScenes(value.scenes);
8813        this.setKeys(value.keys);
8814        this.setCues(value.cues);
8815        this.setRestriction(value.restriction);
8816        return this.data;
8817      }
8818
8819      /**
8820       *
8821       */
8822    }, {
8823      key: "applyDefaults",
8824      value: function applyDefaults(media) {
8825        if (media.medium == null) {
8826          media.medium = /audio/.test(media.type) ? "audio" : "video";
8827        }
8828        if (media.temporalType == null) {
8829          media.temporalType = "vod";
8830        }
8831        media.isLive = media.temporalType === "live" || media.temporalType === "dvr";
8832        var source = media.source;
8833        if (media.src == null && source) {
8834          var playerProxy = this.facade.retrieveProxy(PlayerProxy.NAME);
8835          if (playerProxy != null) {
8836            var item = Utils.selectSource(media, playerProxy.canPlay);
8837            if (item && item.src) {
8838              media.src = item.src;
8839              media.type = item.type;
8840            }
8841          }
8842        }
8843        if (media.type == null) {
8844          media.type = Utils.getMimeType(media.src);
8845        }
8846        var scenes = media.scenes;
8847        if (scenes != null) {
8848          scenes.forEach(function (scene, index) {
8849            var time;
8850            scene.start = isNaN(time = Utils.flattenTimecode(scene.sceneStartTime)) ? 0 : time;
8851            scene.end = isNaN(time = Utils.flattenTimecode(scene.sceneEndTime)) ? 0 : time;
8852            scene.title = scene.sceneTitle || "";
8853            scene.description = scene.sceneDescription || "";
8854            scene.position = index + 1;
8855          });
8856        }
8857        if (media.startTime == null) {
8858          media.startTime = 0;
8859        }
8860        if (media.status == null) {
8861          media.status = {};
8862        }
8863        if (media.restriction == null) {
8864          media.restriction = [];
8865        }
8866        if (media.track == null) {
8867          media.track = [];
8868        }
8869        if (media.metadata == null) {
8870          media.metadata = {};
8871        }
8872        media.originalSrc = media.src;
8873        return media;
8874      }
8875
8876      /**
8877       *
8878       */
8879    }, {
8880      key: "updateData",
8881      value: function updateData(data) {
8882        var _this2 = this;
8883        fp.each(data, function (value, key) {
8884          if (key in _this2.data) {
8885            _this2.data[key] = value;
8886          }
8887        });
8888      }
8889
8890      /**
8891       * The global unique identifier for this to the video.
8892       *
8893       * @param {String} value
8894       *    The new guid of the video
8895       * @returns {String}
8896       *    The guid of the video
8897       * @type {String}
8898       */
8899    }, {
8900      key: "getGUID",
8901      value: function getGUID() {
8902        return this.data.guid;
8903      }
8904    }, {
8905      key: "setGUID",
8906      value: function setGUID(value) {
8907        return this.data.guid = value;
8908      }
8909    }, {
8910      key: "getLink",
8911      value: function getLink() {
8912        return this.data.link;
8913      }
8914    }, {
8915      key: "setLink",
8916      value: function setLink(value) {
8917        return this.data.link = value;
8918      }
8919    }, {
8920      key: "getStartTime",
8921      value: function getStartTime() {
8922        return this.data.startTime;
8923      }
8924    }, {
8925      key: "setStartTime",
8926      value: function setStartTime(value) {
8927        return this.data.startTime = value;
8928      }
8929    }, {
8930      key: "getEmbed",
8931      value: function getEmbed() {
8932        return this.data.embed;
8933      }
8934    }, {
8935      key: "setEmbed",
8936      value: function setEmbed(value) {
8937        return this.data.embed = value;
8938      }
8939    }, {
8940      key: "getAutoplay",
8941      value: function getAutoplay() {
8942        return this.data.autoplay;
8943      }
8944    }, {
8945      key: "setAutoplay",
8946      value: function setAutoplay(value) {
8947        return this.data.autoplay = value;
8948      }
8949    }, {
8950      key: "getPubDate",
8951      value: function getPubDate() {
8952        return this.data.pubDate;
8953      }
8954    }, {
8955      key: "setPubDate",
8956      value: function setPubDate(value) {
8957        return this.data.pubDate = value;
8958      }
8959    }, {
8960      key: "getCategory",
8961      value:
8962      /**
8963       *
8964       */
8965      function getCategory() {
8966        return this.data.category;
8967      }
8968    }, {
8969      key: "setCategory",
8970      value: function setCategory(value) {
8971        return this.data.category = value;
8972      }
8973
8974      /**
8975       * The duration of the video. This property is used in situations where the
8976       * duration cannot be determined from the video (i.e. before metadata is loaded)
8977       *
8978       * @param {Number} value
8979       *    The new duration of the video
8980       * @returns {Number}
8981       *    The duration of the video
8982       * @type {Number}
8983       */
8984    }, {
8985      key: "getStatus",
8986      value: function getStatus() {
8987        return this.data.status;
8988      }
8989    }, {
8990      key: "setStatus",
8991      value: function setStatus() {
8992        var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8993        return this.data.status = value;
8994      }
8995
8996      /**
8997       * The url to the video.
8998       *
8999       * @param {String} value
9000       *    The new title of the video
9001       * @returns {Boolean}
9002       *    The title of the video
9003       * @type {String}
9004       */
9005    }, {
9006      key: "getSrc",
9007      value: function getSrc() {
9008        return this.facade.security.createURL(this.data.src);
9009      }
9010    }, {
9011      key: "setSrc",
9012      value: function setSrc(value) {
9013        return this.data.src = value;
9014      }
9015
9016      /**
9017       * The mimeType of the video.
9018       */
9019    }, {
9020      key: "getType",
9021      value: function getType() {
9022        return this.data.type;
9023      }
9024    }, {
9025      key: "setType",
9026      value: function setType(value) {
9027        return this.data.type = value;
9028      }
9029
9030      /**
9031       * The medium the video. ie audio, video, executable
9032       */
9033    }, {
9034      key: "getMedium",
9035      value: function getMedium() {
9036        return this.data.medium;
9037      }
9038    }, {
9039      key: "setMedium",
9040      value: function setMedium(value) {
9041        if (value === this.data.medium) {
9042          return;
9043        }
9044        this.data.medium = value;
9045        return this.facade.retrieveProxy(ApplicationStateProxy.NAME).setMedium(value);
9046      }
9047
9048      /**
9049       * Additional information about the vieo
9050       */
9051    }, {
9052      key: "getMetadata",
9053      value: function getMetadata() {
9054        return this.data.metadata;
9055      }
9056    }, {
9057      key: "setMetadata",
9058      value: function setMetadata(value) {
9059        return this.data.metadata = value;
9060      }
9061
9062      /**
9063       * The source object of the video.
9064       */
9065    }, {
9066      key: "getSource",
9067      value: function getSource() {
9068        return this.data.source;
9069      }
9070    }, {
9071      key: "setSource",
9072      value: function setSource(value) {
9073        return this.data.source = value;
9074      }
9075
9076      /**
9077       * The source object of the video.
9078       */
9079    }, {
9080      key: "getTrack",
9081      value: function getTrack() {
9082        return this.data.track;
9083      }
9084    }, {
9085      key: "setTrack",
9086      value: function setTrack(value) {
9087        return this.data.track = value;
9088      }
9089
9090      /**
9091       * The title of the video.
9092       *
9093       * @param {String} value
9094       *    The new title of the video
9095       * @returns {Boolean}
9096       *    The title of the video
9097       * @type {String}
9098       */
9099    }, {
9100      key: "getTitle",
9101      value: function getTitle() {
9102        return this.data.title;
9103      }
9104    }, {
9105      key: "setTitle",
9106      value: function setTitle(value) {
9107        return this.data.title = value;
9108      }
9109
9110      /**
9111       * The native width of the video.
9112       */
9113    }, {
9114      key: "getWidth",
9115      value: function getWidth() {
9116        return this.data.width;
9117      }
9118    }, {
9119      key: "setWidth",
9120      value: function setWidth(value) {
9121        return this.data.width = value;
9122      }
9123
9124      /**
9125       * The native width of the video.
9126       */
9127    }, {
9128      key: "getHeight",
9129      value: function getHeight() {
9130        return this.data.height;
9131      }
9132    }, {
9133      key: "setHeight",
9134      value: function setHeight(value) {
9135        return this.data.height = value;
9136      }
9137
9138      /**
9139       * The description of the video.
9140       *
9141       * @param {String} value
9142       *    The new description of the video
9143       * @returns {Boolean}
9144       *    The description of the video
9145       * @type {String}
9146       */
9147    }, {
9148      key: "getDescription",
9149      value: function getDescription() {
9150        return this.data.description;
9151      }
9152    }, {
9153      key: "setDescription",
9154      value: function setDescription(value) {
9155        return this.data.description = value;
9156      }
9157    }, {
9158      key: "getDuration",
9159      value: function getDuration(value) {
9160        return this.data.duration;
9161      }
9162    }, {
9163      key: "setDuration",
9164      value: function setDuration(value) {
9165        if (!value || this.data.temporalType === "live") {
9166          return;
9167        }
9168        //HACK: Android's native browser sometimes returns a duration of 1 before playback begins
9169        var ua = navigator.userAgent;
9170        if (value === 1 && /Android/.test(ua) && !/Android.*Chrome/.test(ua)) {
9171          return;
9172        }
9173        if (value !== this.data.duration) {
9174          this.data.duration = value;
9175          this.sendNotification(Notifications.TIME_CHANGE, {
9176            duration: value
9177          });
9178        }
9179        if (value === 2e308 && this.data.temporalType !== "dvr") {
9180          this.setTemporalType("live");
9181        }
9182        return value;
9183      }
9184
9185      /**
9186       * The poster image for the video.
9187       *
9188       * @param {String} value
9189       *    The url of the new poster image
9190       * @returns {String}
9191       *    The url of the poster image
9192       * @type {String}
9193       */
9194    }, {
9195      key: "getPoster",
9196      value: function getPoster(value) {
9197        return this.data.poster;
9198      }
9199    }, {
9200      key: "setPoster",
9201      value: function setPoster(value) {
9202        this.data.poster = value;
9203      }
9204
9205      /**
9206       *
9207       */
9208    }, {
9209      key: "getIsLive",
9210      value: function getIsLive() {
9211        return this.data.isLive;
9212      }
9213    }, {
9214      key: "setIsLive",
9215      value: function setIsLive(value) {
9216        if (value === this.data.isLive) {
9217          return;
9218        }
9219        this.data.isLive = value;
9220        this.sendNotification(Notifications.IS_LIVE, value);
9221        return value;
9222      }
9223
9224      /**
9225       *
9226       */
9227    }, {
9228      key: "getTemporalType",
9229      value: function getTemporalType() {
9230        return this.data.temporalType || "vod";
9231      }
9232    }, {
9233      key: "setTemporalType",
9234      value: function setTemporalType(value) {
9235        if (value === this.data.temporalType) {
9236          return;
9237        }
9238        var previous = this.data.temporalType;
9239        this.data.temporalType = value;
9240        this.sendNotification(Notifications.TEMPORAL_TYPE_CHANGE, {
9241          previous: previous,
9242          value: value
9243        });
9244      }
9245
9246      /**
9247       *
9248       */
9249    }, {
9250      key: "getScenes",
9251      value: function getScenes() {
9252        return this.data.scenes;
9253      }
9254    }, {
9255      key: "setScenes",
9256      value: function setScenes(value) {
9257        return this.data.scenes = value;
9258      }
9259
9260      /**
9261       *
9262       */
9263    }, {
9264      key: "getCues",
9265      value: function getCues() {
9266        return this.data.cues;
9267      }
9268    }, {
9269      key: "setCues",
9270      value: function setCues() {
9271        var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
9272        if (this.data.cues === value) {
9273          return;
9274        }
9275        this.data.cues = value;
9276        this.sendNotification(Notifications.CUES_CHANGE, value);
9277        return value;
9278      }
9279
9280      /**
9281       *
9282       */
9283    }, {
9284      key: "getScene",
9285      value: function getScene(currentTime) {
9286        var scenes = this.data.scenes;
9287        if (scenes == null) {
9288          return;
9289        }
9290        return scenes.find(function (scene) {
9291          return scene.start <= currentTime && currentTime < scene.end;
9292        });
9293      }
9294
9295      /**
9296       *
9297       */
9298    }, {
9299      key: "getKeys",
9300      value: function getKeys() {
9301        return this.data.keys;
9302      }
9303    }, {
9304      key: "setKeys",
9305      value: function setKeys(value) {
9306        this.data.keys = value;
9307      }
9308
9309      /**
9310       *
9311       */
9312    }, {
9313      key: "getAuthorization",
9314      value: function getAuthorization() {
9315        return this.data.authorization;
9316      }
9317    }, {
9318      key: "setAuthorization",
9319      value: function setAuthorization(value) {
9320        this.data.authorization = value;
9321      }
9322
9323      /**
9324       *
9325       */
9326    }, {
9327      key: "getRestriction",
9328      value: function getRestriction() {
9329        return this.data.restriction;
9330      }
9331    }, {
9332      key: "setRestriction",
9333      value: function setRestriction() {
9334        var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
9335        this.data.restriction = value;
9336      }
9337    }], [{
9338      key: "NAME",
9339      get: function get() {
9340        return "MediaProxy";
9341      }
9342    }]);
9343    return MediaProxy;
9344  }(puremvc.Proxy);
9345
9346  var TrackList = /*#__PURE__*/function (_EventDispatcher) {
9347    babelHelpers.inherits(TrackList, _EventDispatcher);
9348    /**
9349     * @constructor
9350     * @private
9351     */
9352    function TrackList() {
9353      var _this;
9354      var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
9355      babelHelpers.classCallCheck(this, TrackList);
9356      _this = _EventDispatcher.call(this) || this;
9357      _this.list = list;
9358      _this.onchange = null;
9359      _this.handlers = {
9360        change: _this.changeHandler.bind(babelHelpers.assertThisInitialized(_this))
9361      };
9362      return _this;
9363    }
9364
9365    /** */
9366    babelHelpers.createClass(TrackList, [{
9367      key: "changeHandler",
9368      value: function changeHandler(event) {
9369        this.dispatchEvent(event);
9370      }
9371
9372      /**
9373       * @param {string} key
9374       *     The key
9375       *
9376       * @param {Object} value
9377       *     The value
9378       */
9379    }, {
9380      key: "add",
9381      value: function add(track) {
9382        var dispatch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
9383        this.list.push(track);
9384        track.addEventListener("change", this.handlers.change);
9385        if (dispatch === true) {
9386          this.dispatch("addtrack", track);
9387        }
9388      }
9389
9390      /**
9391       * @param {string} key
9392       *     The module's key
9393       *
9394       * @return {Object}
9395       *     The item.
9396       */
9397    }, {
9398      key: "remove",
9399      value: function remove(track) {
9400        var dispatch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
9401        var index = this.list.indexOf(track);
9402        if (index === -1) {
9403          return;
9404        }
9405        this.list.splice(index, 1);
9406        track.removeEventListener("change", this.handlers.change);
9407        if (dispatch === true) {
9408          this.dispatch("removetrack", track);
9409        }
9410        return track;
9411      }
9412    }, {
9413      key: "clear",
9414      value: function clear() {
9415        var _this2 = this;
9416        if (this.list.length === 0) {
9417          return;
9418        }
9419        fp.each(this.list, function () {
9420          _this2.remove(_this2.list[_this2.list.length - 1], false);
9421        });
9422        this.dispatch("removetrack");
9423      }
9424    }, {
9425      key: "getTrackById",
9426      value: function getTrackById(id) {
9427        return this.list.find(function (track) {
9428          return track.id === id;
9429        });
9430      }
9431    }, {
9432      key: "some",
9433      value: function some(func) {
9434        return this.list.some(func);
9435      }
9436    }]);
9437    return TrackList;
9438  }(EventDispatcher);
9439
9440  var AudioTrackList = /*#__PURE__*/function (_TrackList) {
9441    babelHelpers.inherits(AudioTrackList, _TrackList);
9442    /**
9443     * @constructor
9444     * @private
9445     */
9446    function AudioTrackList(list) {
9447      babelHelpers.classCallCheck(this, AudioTrackList);
9448      return _TrackList.call(this, list) || this;
9449    }
9450    babelHelpers.createClass(AudioTrackList, [{
9451      key: "selectTrackByIndex",
9452      value: function selectTrackByIndex(index) {
9453        if (index >= 0 && index < this.list.length) {
9454          for (var i = 0; i < this.list.length; i++) {
9455            this.list[i].enabled = i == index;
9456          }
9457        }
9458      }
9459    }, {
9460      key: "selectTrackByLanguage",
9461      value: function selectTrackByLanguage() {
9462        var lang = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
9463        var track = this.list.filter(function (track) {
9464          return track.language.toLowerCase() === lang.toLowerCase();
9465        })[0];
9466        var index = this.list.indexOf(track);
9467        this.selectTrackByIndex(index);
9468      }
9469    }]);
9470    return AudioTrackList;
9471  }(TrackList);
9472
9473  var PreviewTrack = /*#__PURE__*/function (_CaptionTrack) {
9474    babelHelpers.inherits(PreviewTrack, _CaptionTrack);
9475    /**
9476     * The PreviewTrack class.
9477     *
9478     * @constructor
9479     * @private
9480     * @param {?Object} track A generic track object.
9481     */
9482    function PreviewTrack(track, onload) {
9483      var _this;
9484      babelHelpers.classCallCheck(this, PreviewTrack);
9485      var resourceManager = AMP.getResourceManager();
9486      var parse = function parse() {
9487        var a = document.createElement("a");
9488        a.href = _this.src;
9489        var absolute = a.protocol + "//" + a.hostname;
9490        var relative = absolute + a.pathname.split("/").slice(0, -1).join("/") + "/";
9491        _this.cues.forEach(function (cue) {
9492          var _cue$text$split = cue.text.split("#"),
9493            _cue$text$split2 = babelHelpers.slicedToArray(_cue$text$split, 2),
9494            file = _cue$text$split2[0],
9495            params = _cue$text$split2[1];
9496          var src = file;
9497          if (!/^(https?:)?\/\//.test(src)) {
9498            if (/^\//.test(src)) {
9499              src = absolute + src;
9500            } else {
9501              src = relative + src;
9502            }
9503          }
9504          var kv = params.split("=");
9505          var keys = kv[0];
9506          var values = kv[1].split(",");
9507          var style = {
9508            background: "url(" + src + ") 0px 0px no-repeat"
9509          };
9510          fp.each(keys, function (key, i) {
9511            var value = values[i];
9512            switch (key) {
9513              case "w":
9514                style.width = value + "px";
9515                break;
9516              case "h":
9517                style.height = value + "px";
9518                break;
9519              case "x":
9520                style.background = style.background.replace(") 0px", ") -" + value + "px");
9521                break;
9522              case "y":
9523                style.background = style.background.replace("0px n", "-" + value + "px n");
9524            }
9525          });
9526          cue.style = style;
9527          // preload
9528          return resourceManager.add({
9529            src: src,
9530            type: "image"
9531          });
9532        });
9533        if (typeof onload === "function") {
9534          onload(babelHelpers.assertThisInitialized(_this));
9535        }
9536      };
9537      return _this = _CaptionTrack.call(this, track, parse) || this;
9538    }
9539
9540    /** @static */
9541    babelHelpers.createClass(PreviewTrack, null, [{
9542      key: "create",
9543      value: function create(track) {
9544        return new Promise(function (resolve, reject) {
9545          var error;
9546          try {
9547            return new PreviewTrack(track, function (captionTrack) {
9548              return resolve(captionTrack);
9549            });
9550          } catch (error1) {
9551            error = error1;
9552            return reject(error);
9553          }
9554        });
9555      }
9556    }]);
9557    return PreviewTrack;
9558  }(CaptionTrack);
9559
9560  var ChapterTrack = /*#__PURE__*/function (_CaptionTrack) {
9561    babelHelpers.inherits(ChapterTrack, _CaptionTrack);
9562    /**
9563     * The ChapterTrack class.
9564     *
9565     * @constructor
9566     * @private
9567     * @param {?Object} track A generic track object.
9568     */
9569    function ChapterTrack(track, onload) {
9570      babelHelpers.classCallCheck(this, ChapterTrack);
9571      return _CaptionTrack.call(this, track, onload) || this;
9572    }
9573    return babelHelpers.createClass(ChapterTrack);
9574  }(CaptionTrack);
9575
9576  var TracksProxy = /*#__PURE__*/function (_puremvc$Proxy) {
9577    babelHelpers.inherits(TracksProxy, _puremvc$Proxy);
9578    /**
9579     * Creates a new instance of TracksProxy.
9580     *
9581     * @constructor
9582     * @private
9583     */
9584    function TracksProxy() {
9585      var _this;
9586      babelHelpers.classCallCheck(this, TracksProxy);
9587      _this = _puremvc$Proxy.call(this, null, {}) || this;
9588      _this.data.audioTracks = new AudioTrackList();
9589      _this.data.videoTracks = new TrackList();
9590      _this.data.textTracks = new TrackList();
9591      _this.data.previewTracks = new TrackList();
9592      _this.data.chapterTracks = new TrackList();
9593      return _this;
9594    }
9595
9596    /**
9597     * @static
9598     * @type {string}
9599     */
9600    babelHelpers.createClass(TracksProxy, [{
9601      key: "clear",
9602      value: function clear() {
9603        this.data.audioTracks.clear();
9604        this.data.videoTracks.clear();
9605        this.data.textTracks.clear();
9606        this.data.previewTracks.clear();
9607        this.data.chapterTracks.clear();
9608      }
9609    }, {
9610      key: "setMedia",
9611      value: function setMedia(media) {
9612        var _this2 = this;
9613        var tracks = media.track || [];
9614        tracks.forEach(function (track) {
9615          if (track.kind === "preview" || track.kind === "thumbnail") {
9616            _this2.getPreviewTracks().add(new PreviewTrack(track));
9617          }
9618          if (track.kind === "chapters" || track.kind === "chapter") {
9619            _this2.getChapterTracks().add(new ChapterTrack(track));
9620          }
9621        });
9622      }
9623    }, {
9624      key: "getAudioTracks",
9625      value: function getAudioTracks() {
9626        return this.data.audioTracks;
9627      }
9628    }, {
9629      key: "getVideoTracks",
9630      value: function getVideoTracks() {
9631        return this.data.videoTracks;
9632      }
9633    }, {
9634      key: "getTextTracks",
9635      value: function getTextTracks() {
9636        return this.data.textTracks;
9637      }
9638    }, {
9639      key: "getPreviewTracks",
9640      value: function getPreviewTracks() {
9641        return this.data.previewTracks;
9642      }
9643    }, {
9644      key: "getChapterTracks",
9645      value: function getChapterTracks() {
9646        return this.data.chapterTracks;
9647      }
9648    }], [{
9649      key: "NAME",
9650      get: function get() {
9651        return "TracksProxy";
9652      }
9653    }]);
9654    return TracksProxy;
9655  }(puremvc.Proxy);
9656
9657  var PlayerMediator = /*#__PURE__*/function (_ComponentMediator) {
9658    babelHelpers.inherits(PlayerMediator, _ComponentMediator);
9659    /**
9660     * @constructor
9661     * @private
9662     * @extends {ComponentMediator}
9663     */
9664    function PlayerMediator(componentName, viewComponent) {
9665      var _this;
9666      babelHelpers.classCallCheck(this, PlayerMediator);
9667      _this = _ComponentMediator.call(this, componentName, "player", null, viewComponent) || this;
9668      _this.layers = [];
9669      _this.core = null;
9670      _this.medium = null;
9671      _this.ready = false;
9672      return _this;
9673    }
9674
9675    /** @override */
9676    babelHelpers.createClass(PlayerMediator, [{
9677      key: "onRegister",
9678      value: function onRegister() {
9679        babelHelpers.get(babelHelpers.getPrototypeOf(PlayerMediator.prototype), "onRegister", this).call(this);
9680        //Add device flag in case device specific styles are needed
9681        var device = Utils.getDevice();
9682        if (device != null) {
9683          this.classList.add(device);
9684        }
9685        if (Utils.isTouchDevice()) {
9686          this.classList.add("touch");
9687        }
9688      }
9689
9690      /** @override */
9691    }, {
9692      key: "listNotificationInterests",
9693      value: function listNotificationInterests() {
9694        return [Notifications.DISPLAY_STATE_CHANGE, Notifications.ACTIVE_STATE_CHANGE, Notifications.PLAY_STATE_CHANGE, Notifications.ADD_APPLICATION_STATE, Notifications.REMOVE_APPLICATION_STATE, Notifications.MEDIUM_CHANGE, Notifications.DURATION_CHANGE, Notifications.TEMPORAL_TYPE_CHANGE, Notifications.IS_LIVE, Notifications.ADD_LAYER, Notifications.REMOVE_LAYER, Notifications.STARTUP];
9695      }
9696
9697      /** @override */
9698    }, {
9699      key: "handleNotification",
9700      value: function handleNotification(notification) {
9701        var name = notification.getName();
9702        var body = notification.getBody();
9703        switch (name) {
9704          case Notifications.ACTIVE_STATE_CHANGE:
9705          case Notifications.PLAY_STATE_CHANGE:
9706          case Notifications.DISPLAY_STATE_CHANGE:
9707          case Notifications.MEDIUM_CHANGE:
9708            var states = body;
9709            var value = states.value;
9710            var previous = states.previous;
9711            if (previous != null && this.classList.contains(previous)) {
9712              this.classList.remove(previous);
9713            }
9714            if (value != null) {
9715              this.classList.add(value);
9716            }
9717            break;
9718          case Notifications.ADD_APPLICATION_STATE:
9719            if (body == null) {
9720              return;
9721            }
9722            this.classList.add(body);
9723            break;
9724          case Notifications.REMOVE_APPLICATION_STATE:
9725            this.classList.remove(body);
9726            break;
9727          case Notifications.TEMPORAL_TYPE_CHANGE:
9728            if (body.previous) {
9729              this.sendNotification(Notifications.REMOVE_APPLICATION_STATE, body.previous);
9730            }
9731            if (body.value) {
9732              this.sendNotification(Notifications.ADD_APPLICATION_STATE, body.value);
9733            }
9734            break;
9735          case Notifications.IS_LIVE:
9736            if (body === true) {
9737              this.sendNotification(Notifications.ADD_APPLICATION_STATE, "is-live");
9738            } else {
9739              this.sendNotification(Notifications.REMOVE_APPLICATION_STATE, "is-live");
9740            }
9741            break;
9742          case Notifications.DURATION_CHANGE:
9743            // add style flag if this is long form content
9744            if (body > 3600) {
9745              this.sendNotification(Notifications.ADD_APPLICATION_STATE, "long-form");
9746            } else {
9747              this.sendNotification(Notifications.REMOVE_APPLICATION_STATE, "long-form");
9748            }
9749            break;
9750          case Notifications.ADD_LAYER:
9751            this.addLayer(body);
9752            break;
9753          case Notifications.REMOVE_LAYER:
9754            this.removeLayer(body);
9755            break;
9756          case Notifications.STARTUP:
9757            this.initialize();
9758            this.viewCreated();
9759        }
9760      }
9761
9762      /** */
9763    }, {
9764      key: "initialize",
9765      value: function initialize() {
9766        var _this2 = this;
9767        this.ready = true;
9768        this.layers.forEach(function (layer) {
9769          if (!_this2.viewComponent.contains(layer)) {
9770            _this2.viewComponent.appendChild(layer);
9771          }
9772        });
9773      }
9774    }, {
9775      key: "viewCreated",
9776      value: function viewCreated() {
9777        this.sendNotification(Notifications.VIEW_CREATED);
9778      }
9779
9780      /** */
9781    }, {
9782      key: "addLayer",
9783      value: function addLayer(layer) {
9784        this.layers.push(layer);
9785        if (this.ready) {
9786          this.viewComponent.appendChild(layer);
9787        }
9788      }
9789
9790      /** */
9791    }, {
9792      key: "removeLayer",
9793      value: function removeLayer(layer) {
9794        if (this.viewComponent.contains(layer)) {
9795          this.viewComponent.removeChild(layer);
9796        }
9797        var index = this.layers.indexOf(layer);
9798        if (index >= 0) {
9799          this.layers.splice(index, 1);
9800        }
9801      }
9802    }]);
9803    return PlayerMediator;
9804  }(ComponentMediator);
9805
9806  var LayerMediator = /*#__PURE__*/function (_ComponentMediator) {
9807    babelHelpers.inherits(LayerMediator, _ComponentMediator);
9808    /**
9809     * @constructor
9810     * @private
9811     */
9812    function LayerMediator(name) {
9813      babelHelpers.classCallCheck(this, LayerMediator);
9814      return _ComponentMediator.call(this, name, "layer") || this;
9815    }
9816
9817    /**
9818     * Registers the layer
9819     *
9820     * @override
9821     */
9822    babelHelpers.createClass(LayerMediator, [{
9823      key: "onRegister",
9824      value: function onRegister() {
9825        babelHelpers.get(babelHelpers.getPrototypeOf(LayerMediator.prototype), "onRegister", this).call(this);
9826        this.registerLayer();
9827      }
9828
9829      /**
9830       * Removes the layer
9831       *
9832       * @override
9833       */
9834    }, {
9835      key: "onRemove",
9836      value: function onRemove() {
9837        babelHelpers.get(babelHelpers.getPrototypeOf(LayerMediator.prototype), "onRemove", this).call(this);
9838        this.removeLayer();
9839      }
9840
9841      /**
9842       *
9843       */
9844    }, {
9845      key: "registerLayer",
9846      value: function registerLayer() {
9847        this.sendNotification(Notifications.ADD_LAYER, this.viewComponent);
9848      }
9849
9850      /**
9851       *
9852       */
9853    }, {
9854      key: "removeLayer",
9855      value: function removeLayer() {
9856        this.sendNotification(Notifications.REMOVE_LAYER, this.viewComponent);
9857      }
9858    }]);
9859    return LayerMediator;
9860  }(ComponentMediator);
9861
9862  var OverlayLayerMediator = /*#__PURE__*/function (_LayerMediator) {
9863    babelHelpers.inherits(OverlayLayerMediator, _LayerMediator);
9864    /**
9865     * The OverlayLayerMediator class.
9866     *
9867     * @constructor
9868     * @private
9869     * @extends {LayerMediator}
9870     */
9871    function OverlayLayerMediator() {
9872      babelHelpers.classCallCheck(this, OverlayLayerMediator);
9873      return _LayerMediator.call(this, "overlays") || this;
9874    }
9875
9876    /**
9877     * Overridden so this class may subscribe to all notifications
9878     * @return An Array
9879     *
9880     * @override
9881     */
9882    babelHelpers.createClass(OverlayLayerMediator, [{
9883      key: "listNotificationInterests",
9884      value: function listNotificationInterests() {
9885        return [Notifications.ADD_OVERLAY, Notifications.REMOVE_OVERLAY];
9886      }
9887
9888      /**
9889       * Handles notifications of interest to this mediator. Note that
9890       * the default declaration is to allow the super to handle the
9891       * note. This leaves the base JunctionMediator to handle things
9892       * like ACCEPT_INPUT_PIPE and ACCEPT_OUTPUT_PIPE
9893       *
9894       * @param note An INotification
9895       * @override
9896       */
9897    }, {
9898      key: "handleNotification",
9899      value: function handleNotification(notification) {
9900        var name = notification.getName();
9901        var overlay = notification.getBody();
9902        switch (name) {
9903          case Notifications.ADD_OVERLAY:
9904            this.viewComponent.appendChild(overlay);
9905            break;
9906          case Notifications.REMOVE_OVERLAY:
9907            this.viewComponent.removeChild(overlay);
9908        }
9909      }
9910    }]);
9911    return OverlayLayerMediator;
9912  }(LayerMediator);
9913
9914  var VideoLayerMediator = /*#__PURE__*/function (_LayerMediator) {
9915    babelHelpers.inherits(VideoLayerMediator, _LayerMediator);
9916    /**
9917     * @constructor
9918     * @extends {LayerMediator}
9919     * @private
9920     */
9921    function VideoLayerMediator() {
9922      var _this;
9923      babelHelpers.classCallCheck(this, VideoLayerMediator);
9924      _this = _LayerMediator.call(this, "video") || this;
9925      _this.mediator = null;
9926      _this.mediaElement = null;
9927      return _this;
9928    }
9929
9930    /** @override */
9931    babelHelpers.createClass(VideoLayerMediator, [{
9932      key: "listNotificationInterests",
9933      value: function listNotificationInterests() {
9934        return [Notifications.PLAYBACK_CORE_CHANGE];
9935      }
9936
9937      /** @override */
9938    }, {
9939      key: "handleNotification",
9940      value: function handleNotification(notification) {
9941        var name = notification.getName();
9942        var body = notification.getBody();
9943        switch (name) {
9944          case Notifications.PLAYBACK_CORE_CHANGE:
9945            // remove the old video object if it exists
9946            if (this.mediaElement != null) {
9947              this.viewComponent.removeChild(this.mediaElement);
9948            }
9949
9950            // remove the old mediator if it exists
9951            if (this.mediator != null) {
9952              this.facade.removeMediator(this.mediator.getMediatorName());
9953            }
9954
9955            // retrive new media element
9956            var isMediator = body && body.getViewComponent;
9957            if (isMediator) {
9958              this.facade.registerMediator(body);
9959              this.mediator = body;
9960              this.mediaElement = this.mediator.getViewComponent();
9961            } else {
9962              this.mediator = null;
9963              this.mediaElement = body;
9964            }
9965            // add the new video object if it exists
9966            if (this.mediaElement != null) {
9967              this.facade.setMediaElement(this.mediaElement);
9968              this.viewComponent.appendChild(this.mediaElement);
9969            }
9970        }
9971      }
9972    }]);
9973    return VideoLayerMediator;
9974  }(LayerMediator);
9975
9976  /**
9977   * @enum {string}
9978   * @const
9979   * @private
9980   */
9981  var AdNotifications = {
9982    BREAK_START: "adsbreakstart",
9983    BREAK_END: "adsbreakend",
9984    BREAK_SKIPPED: "adsbreakskipped",
9985    AD_CONTAINER_CREATED: "adscontainercreated",
9986    AD_LOADED: "adsloaded",
9987    AD_MANAGER_LOADED: "adsmanagerloaded",
9988    AD_STARTED: "adsstarted",
9989    AD_TIME_UPDATE: "adstimeupdate",
9990    AD_TIME_REMAINING: "adstimeremaining",
9991    AD_DURATION_CHANGE: "adsdurationchange",
9992    AD_ENDED: "adsended",
9993    AD_ERROR: "adserror",
9994    AD_PLAY: "adsplay",
9995    AD_PLAYING: "adsplaying",
9996    AD_PAUSE: "adspause",
9997    AD_PAUSED: "adspaused",
9998    AD_RESUME: "adsresume",
9999    AD_CLICKED: "adclicked",
10000    AD_COMPANION: "adscompanion",
10001    FIRST_QUARTILE: "adsfirstquartile",
10002    MIDPOINT: "adsmidpoint",
10003    THIRD_QUARTILE: "adsthirdquartile",
10004    COMPLETE: "adscomplete",
10005    CONCRETE: "adsconcrete",
10006    LOG: "adslog",
10007    REQUEST: "adsrequest",
10008    REQUEST_START: "adsrequeststart",
10009    REQUEST_COMPLETE: "adsrequestcomplete",
10010    RESPONSE: "adsresponse",
10011    SKIPPED: "adsskipped",
10012    IMPRESSION: "adsimpression"
10013  };
10014
10015  var OverlayMediator = /*#__PURE__*/function (_ComponentMediator) {
10016    babelHelpers.inherits(OverlayMediator, _ComponentMediator);
10017    /**
10018     * @constructor
10019     * @private
10020     */
10021    function OverlayMediator(name) {
10022      babelHelpers.classCallCheck(this, OverlayMediator);
10023      return _ComponentMediator.call(this, name, "overlay") || this;
10024    }
10025
10026    /**
10027     * Registers the overlay.
10028     *
10029     * @override
10030     */
10031    babelHelpers.createClass(OverlayMediator, [{
10032      key: "onRegister",
10033      value: function onRegister() {
10034        babelHelpers.get(babelHelpers.getPrototypeOf(OverlayMediator.prototype), "onRegister", this).call(this);
10035        this.registerOverlay();
10036      }
10037
10038      /**
10039       * Removes the overlay.
10040       *
10041       * @override
10042       */
10043    }, {
10044      key: "onRemove",
10045      value: function onRemove() {
10046        babelHelpers.get(babelHelpers.getPrototypeOf(OverlayMediator.prototype), "onRemove", this).call(this);
10047        this.removeOverlay();
10048      }
10049
10050      /**
10051       *
10052       */
10053    }, {
10054      key: "registerOverlay",
10055      value: function registerOverlay() {
10056        this.sendNotification(Notifications.ADD_OVERLAY, this.viewComponent);
10057      }
10058
10059      /**
10060       *
10061       */
10062    }, {
10063      key: "removeOverlay",
10064      value: function removeOverlay() {
10065        this.sendNotification(Notifications.REMOVE_OVERLAY, this.viewComponent);
10066      }
10067    }]);
10068    return OverlayMediator;
10069  }(ComponentMediator);
10070
10071  var AdContainerMediator = /*#__PURE__*/function (_OverlayMediator) {
10072    babelHelpers.inherits(AdContainerMediator, _OverlayMediator);
10073    /**
10074     * @constructor
10075     * @private
10076     * @extends {OverlayMediator}
10077     */
10078    function AdContainerMediator() {
10079      var _this;
10080      babelHelpers.classCallCheck(this, AdContainerMediator);
10081      _this = _OverlayMediator.call(this, "ads") || this;
10082      _this._hidden = true;
10083      _this._container = null;
10084      return _this;
10085    }
10086
10087    /**
10088     * @override
10089     */
10090    babelHelpers.createClass(AdContainerMediator, [{
10091      key: "onRegister",
10092      value: function onRegister() {
10093        babelHelpers.get(babelHelpers.getPrototypeOf(AdContainerMediator.prototype), "onRegister", this).call(this);
10094        this.setContainer(this.viewComponent);
10095        this.sendNotification(AdNotifications.AD_CONTAINER_CREATED, this.viewComponent);
10096      }
10097
10098      /**
10099       * @override
10100       */
10101    }, {
10102      key: "listNotificationInterests",
10103      value: function listNotificationInterests() {
10104        return [AdNotifications.BREAK_START, AdNotifications.BREAK_END];
10105      }
10106    }, {
10107      key: "getHidden",
10108      value: function getHidden() {
10109        return this._hidden;
10110      }
10111    }, {
10112      key: "setHidden",
10113      value: function setHidden(value) {
10114        this._hidden = value;
10115        if (this._container) this._container.hidden = value;
10116        return value;
10117      }
10118    }, {
10119      key: "getContainer",
10120      value: function getContainer() {
10121        return this._container;
10122      }
10123    }, {
10124      key: "setContainer",
10125      value: function setContainer(value) {
10126        this._container = value;
10127        if (this._container) this._container.hidden = this._hidden;
10128        return value;
10129      }
10130
10131      /**
10132       * @override
10133       */
10134    }, {
10135      key: "handleNotification",
10136      value: function handleNotification(notification) {
10137        var body = notification.body || {};
10138        switch (notification.getName()) {
10139          case AdNotifications.BREAK_START:
10140            this.setHidden(false);
10141            break;
10142          case AdNotifications.BREAK_END:
10143            this.setHidden(body.type !== "overlay");
10144        }
10145      }
10146    }]);
10147    return AdContainerMediator;
10148  }(OverlayMediator);
10149
10150  var Controller = /*#__PURE__*/function (_puremvc$Mediator) {
10151    babelHelpers.inherits(Controller, _puremvc$Mediator);
10152    /**
10153     * The Controller class.
10154     *
10155     * @param {string} name
10156     * @param {Object} viewComponent
10157     * @constructor
10158     * @private
10159     * @extends {puremvc.Mediator}
10160     */
10161    function Controller(name, viewComponent) {
10162      babelHelpers.classCallCheck(this, Controller);
10163      return _puremvc$Mediator.call(this, name, viewComponent) || this;
10164    }
10165    babelHelpers.createClass(Controller, [{
10166      key: "playback",
10167      get: function get() {
10168        return this.playerCore.getActivePlaybackCore();
10169      }
10170
10171      /** */
10172    }, {
10173      key: "doAfter",
10174      value: function doAfter(func) {
10175        var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
10176        var facade = this.facade.player || this.facade;
10177        return new Promise(function (resolve, reject) {
10178          var callback = function callback() {
10179            try {
10180              func();
10181              resolve();
10182            } catch (error) {
10183              facade.logger.error(error);
10184              reject(error);
10185            }
10186          };
10187          return facade.timers.setTimeout(callback, timeout);
10188        });
10189      }
10190
10191      /** @override */
10192    }, {
10193      key: "initializeNotifier",
10194      value: function initializeNotifier(key) {
10195        babelHelpers.get(babelHelpers.getPrototypeOf(Controller.prototype), "initializeNotifier", this).call(this, key);
10196        var facade = this.facade.player || this.facade;
10197        this.applicationState = facade.appState;
10198        this.media = facade.mediaProxy;
10199        this.config = facade.configuration;
10200        this.logger = facade.logger;
10201        this.bindings = facade.bindings;
10202        this.params = facade.params;
10203        this.playerCore = facade.playerCore;
10204        this.security = facade.security;
10205        this.tracks = facade.tracks;
10206        this.localization = facade.localization;
10207        this.player = facade;
10208      }
10209
10210      /**
10211       * Handles notifications of interest to this mediator.
10212       *
10213       * @param note An INotification
10214       * @override
10215       */
10216    }, {
10217      key: "handleNotification",
10218      value: function handleNotification(notification) {
10219        var name = notification.getName();
10220        if (typeof this[name] === "function") {
10221          this[name](notification.getBody(), notification);
10222        }
10223      }
10224    }]);
10225    return Controller;
10226  }(puremvc.Mediator);
10227
10228  var CoreController = /*#__PURE__*/function (_Controller) {
10229    babelHelpers.inherits(CoreController, _Controller);
10230    /**
10231     * The CoreController class.
10232     *
10233     * @param {string} name
10234     * @param {Object} viewComponent
10235     * @constructor
10236     * @private
10237     * @extends {amp.player.Controller}
10238     */
10239    function CoreController() {
10240      babelHelpers.classCallCheck(this, CoreController);
10241      return _Controller.call(this, CoreController.NAME) || this;
10242    }
10243
10244    /**
10245     * @static
10246     * @type {string}
10247     */
10248    babelHelpers.createClass(CoreController, [{
10249      key: "listNotificationInterests",
10250      value: /** @override */
10251      function listNotificationInterests() {
10252        return [Notifications.START, Notifications.PLAY, Notifications.PAUSE, Notifications.ENDED, Notifications.TOGGLE_PLAY_PAUSE, Notifications.CHANGE_DURATION];
10253      }
10254
10255      /** */
10256    }, {
10257      key: "play",
10258      value: function play(userInitiated) {
10259        if (this.applicationState.getLocked() === true) {
10260          return;
10261        }
10262        if (userInitiated && this.playback.initialized !== true) {
10263          this.sendNotification(Notifications.INITIALIZED);
10264        }
10265        if (this.playback.initialized !== true || !this.media.getSrc() && !this.media.getSource()) {
10266          return;
10267        }
10268        if (!this.playback.getStarted()) {
10269          this.sendNotification(Notifications.START);
10270        }
10271        this.playback.play();
10272      }
10273
10274      /** */
10275    }, {
10276      key: "pause",
10277      value: function pause() {
10278        //update the model
10279        this.playback.pause();
10280        this.sendNotification(Notifications.CHANGE_ACTIVE_STATE, ActiveState.ACTIVE);
10281      }
10282
10283      /** */
10284    }, {
10285      key: "ended",
10286      value: function ended() {
10287        var _this = this;
10288        if (this.applicationState.getEnded()) {
10289          return;
10290        }
10291        this.applicationState.setEnded(true);
10292        this.doAfter(function () {
10293          if (_this.config.getLoop() === true) {
10294            _this.sendNotification(Notifications.REPLAY);
10295          } else if (_this.applicationState.getHasPostContent() === false) {
10296            _this.sendNotification(Notifications.MEDIA_SEQUENCE_ENDED);
10297          }
10298        });
10299      }
10300
10301      /** */
10302    }, {
10303      key: "start",
10304      value: function start(value) {
10305        this.sendNotification(Notifications.REQUEST_PLAY);
10306        // start normal video playback
10307        this.sendNotification(Notifications.STARTED, value);
10308      }
10309
10310      /** */
10311    }, {
10312      key: "toggleplaypause",
10313      value: function toggleplaypause() {
10314        var note;
10315        if (this.applicationState.getSeeking()) {
10316          return;
10317        }
10318        switch (this.applicationState.getPlayState()) {
10319          case PlayState.ENDED:
10320            note = Notifications.REPLAY;
10321            break;
10322          case PlayState.PAUSED:
10323          case PlayState.READY:
10324            note = Notifications.PLAY;
10325            break;
10326          case PlayState.PLAYING:
10327            note = Notifications.PAUSE;
10328        }
10329        if (this.applicationState.getWaiting()) {
10330          //HACK: Toggle issue when seeked under paused state
10331          if (this.facade.getMediaElement().paused === true) {
10332            note = Notifications.PLAY;
10333          }
10334        }
10335        this.sendNotification(note, true);
10336      }
10337
10338      /** */
10339    }, {
10340      key: "changeduration",
10341      value: function changeduration(duration) {
10342        if (this.media.getDuration() === duration) {
10343          return;
10344        }
10345        this.media.setDuration(duration);
10346      }
10347    }], [{
10348      key: "NAME",
10349      get: function get() {
10350        return "CoreController";
10351      }
10352    }]);
10353    return CoreController;
10354  }(Controller);
10355
10356  var Utilization = /*#__PURE__*/function () {
10357    function Utilization() {
10358      babelHelpers.classCallCheck(this, Utilization);
10359    }
10360    babelHelpers.createClass(Utilization, null, [{
10361      key: "track",
10362      value: function track(event, data, player) {
10363        var semver = Utils.semver(player.version);
10364        var request = {
10365          url: "//amp.akamaized.net/amp.gif",
10366          query: {
10367            prod: semver.build ? semver.build : "standard",
10368            prodver: semver.version,
10369            platform: "web",
10370            os: bowser.osname,
10371            osver: bowser.osversion,
10372            browser: bowser.name,
10373            browserver: bowser.version,
10374            url: location.href,
10375            event: event,
10376            data: data,
10377            lic: player.pid
10378          }
10379        };
10380        return Utils.request(request)["catch"](function (error) {
10381          return Logger.instance.log(error);
10382        });
10383      }
10384    }]);
10385    return Utilization;
10386  }();
10387
10388  var PlayerController = /*#__PURE__*/function (_Controller) {
10389    babelHelpers.inherits(PlayerController, _Controller);
10390    /**
10391     * The PlayerController class.
10392     *
10393     * @param {string} name
10394     * @param {Object} viewComponent
10395     * @constructor
10396     * @private
10397     * @extends {amp.player.Controller}
10398     */
10399    function PlayerController() {
10400      babelHelpers.classCallCheck(this, PlayerController);
10401      return _Controller.call(this, PlayerController.NAME) || this;
10402    }
10403
10404    /**
10405     * @static
10406     * @type {string}
10407     */
10408    babelHelpers.createClass(PlayerController, [{
10409      key: "listNotificationInterests",
10410      value: /** @override */
10411      function listNotificationInterests() {
10412        return [Notifications.STARTUP, Notifications.ERROR, Notifications.TRACK, Notifications.DESTROY];
10413      }
10414
10415      /** */
10416    }, {
10417      key: "startup",
10418      value: function startup() {
10419        var _this = this;
10420        this.localization.initialize(this.facade.plugins).then(function () {
10421          var volume = _this.facade.config.volume;
10422          if (volume != null) {
10423            _this.sendNotification(Notifications.CHANGE_VOLUME, volume);
10424          }
10425          _this.playerCore.ready();
10426          if (_this.facade.config.autoplay === true) {
10427            _this.sendNotification(Notifications.ADD_APPLICATION_STATE, "autoplay");
10428          }
10429          _this.sendNotification(Notifications.CHANGE_DISPLAY_STATE, DisplayState.NORMAL);
10430          _this.sendNotification(Notifications.CHANGE_PLAY_STATE, PlayState.READY);
10431          _this.sendNotification(Notifications.CHANGE_ACTIVE_STATE, ActiveState.ACTIVE);
10432          AutoplayThreshold.value().then(function () {
10433            _this.facade.performance.ready = Date.now();
10434            _this.sendNotification(Notifications.TRACK, Event.create("create"));
10435            _this.sendNotification(Notifications.READY, _this.facade);
10436            _this.doAfter(function () {
10437              var media = _this.facade.config.media;
10438              if (media != null) {
10439                _this.sendNotification(Notifications.SET_MEDIA, media);
10440              }
10441            }, 2);
10442          });
10443        })["catch"](function (error) {
10444          throw AMPError.create(error);
10445        });
10446      }
10447
10448      /** */
10449    }, {
10450      key: "error",
10451      value: function error(_error) {
10452        var _this2 = this;
10453        var destroy = function destroy(error) {
10454          _this2.facade._error = error;
10455          _this2.playback.destroy();
10456          var core = _this2.playback.getMediaElement();
10457          Promise.resolve(core.pause())["catch"](function (error) {
10458            return error;
10459          });
10460
10461          //update the view
10462          _this2.sendNotification(Notifications.CHANGE_PLAY_STATE, PlayState.ERROR);
10463
10464          // notify listeners
10465          _this2.facade.dispatch(Events.ERROR, error);
10466
10467          //send the error to the console
10468          _this2.logger.error("[AMP ERROR]", error);
10469        };
10470        this.facade.transform(TransformType.ERROR, AMPError.create(_error)).then(function (result) {
10471          if (result == null) {
10472            return;
10473          }
10474          destroy(result);
10475        })["catch"](function (error) {
10476          destroy(error);
10477        });
10478      }
10479
10480      /** */
10481    }, {
10482      key: "track",
10483      value: function track(event) {
10484        Utilization.track(event.type, event.data, this.facade);
10485      }
10486
10487      /** */
10488    }, {
10489      key: "destroy",
10490      value: function destroy() {
10491        var _this3 = this;
10492        var modules = Object.keys(this.facade.getModules());
10493        var plugins = this.facade.plugins;
10494        plugins.forEach(function (plugin) {
10495          if (modules.includes(plugin)) return;
10496          try {
10497            var base = _this3.facade[plugin] || {};
10498            if (typeof base.destroy === "function") {
10499              base.destroy();
10500            }
10501          } catch (error) {
10502            _this3.facade.logger.error(error);
10503          }
10504        });
10505      }
10506    }], [{
10507      key: "NAME",
10508      get: function get() {
10509        return "PlayerController";
10510      }
10511    }]);
10512    return PlayerController;
10513  }(Controller);
10514
10515  var PlaybackController = /*#__PURE__*/function (_Controller) {
10516    babelHelpers.inherits(PlaybackController, _Controller);
10517    /**
10518     * The PlaybackController class.
10519     *
10520     * @param {string} name
10521     * @param {Object} viewComponent
10522     * @constructor
10523     * @private
10524     * @extends {amp.player.Controller}
10525     */
10526    function PlaybackController() {
10527      babelHelpers.classCallCheck(this, PlaybackController);
10528      return _Controller.call(this, PlaybackController.NAME) || this;
10529    }
10530
10531    /**
10532     * @static
10533     * @type {string}
10534     */
10535    babelHelpers.createClass(PlaybackController, [{
10536      key: "listNotificationInterests",
10537      value: /** @override */
10538      function listNotificationInterests() {
10539        return [Notifications.PLAYING, Notifications.REQUEST_PLAY, Notifications.PLAYBACK_TARGET_CHANGE, Notifications.REGISTER_PLAYBACK_CORE, Notifications.REPLAY, Notifications.END, Notifications.HAS_POST_CONTENT, Notifications.LOCK, Notifications.MEDIA_SEQUENCE_ENDED];
10540      }
10541
10542      /** */
10543    }, {
10544      key: "requestplay",
10545      value: function requestplay() {
10546        if (this.media.started === true) {
10547          return;
10548        }
10549        this.media.started = true;
10550        this.sendNotification(Notifications.PLAY_REQUEST);
10551        this.sendNotification(Notifications.WAITING);
10552        this.sendNotification(Notifications.MEDIA_SEQUENCE_STARTED);
10553        this.sendNotification(Notifications.TRACK, Event.create("start"));
10554      }
10555
10556      /** */
10557    }, {
10558      key: "end",
10559      value: function end() {
10560        var _this = this;
10561        if (this.applicationState.getEnded()) {
10562          return;
10563        }
10564        if (this.facade.ads.getInProgress()) {
10565          var _transform = {
10566            player: this.player,
10567            transform: function transform(value) {
10568              if (value > -1) {
10569                _this.player.sendNotification(Notifications.END);
10570                _this.player.removeTransform(_transform);
10571                return value;
10572              }
10573            }
10574          };
10575          this.player.addTransform(TransformType.TIME, _transform);
10576          this.facade.ads.terminateAllAds();
10577          return;
10578        }
10579        this.playback.setEnabled(false);
10580        this.playback.pause();
10581        this.playback.seek(this.playback.getDuration()).then(this.sendNotification.bind(this, Notifications.ENDED));
10582      }
10583
10584      /** */
10585    }, {
10586      key: "replay",
10587      value: function replay() {
10588        if (typeof this.playback.replay === "function") {
10589          this.playback.replay();
10590          return;
10591        }
10592        var media = this.media.getData();
10593        media.metadata = Object.assign({}, media.metadata, {
10594          config: {
10595            autoplay: true
10596          }
10597        });
10598        this.sendNotification(Notifications.SET_MEDIA, media);
10599      }
10600
10601      /** */
10602    }, {
10603      key: "registerplaybackcore",
10604      value: function registerplaybackcore(core) {
10605        this.playerCore.registerPlaybackCore(core);
10606      }
10607
10608      /** */
10609    }, {
10610      key: "playbacktargetchange",
10611      value: function playbacktargetchange(body) {
10612        var target = body.value;
10613        var note = target === "amp" ? Notifications.REMOVE_APPLICATION_STATE : Notifications.ADD_APPLICATION_STATE;
10614        this.sendNotification(note, "remote-playback");
10615      }
10616
10617      /** */
10618    }, {
10619      key: "playing",
10620      value: function playing() {
10621        if (this.facade.getMediaElement().currentTime === 0 && this.media.started === false && this.applicationState.getSeeking() === false) {
10622          this.media.started = true;
10623          this.sendNotification(Notifications.MEDIA_SEQUENCE_STARTED);
10624        }
10625        if (this.applicationState.getPlayState() !== PlayState.PLAYING) {
10626          this.sendNotification(Notifications.CHANGE_PLAY_STATE, PlayState.PLAYING);
10627        }
10628      }
10629
10630      /** */
10631    }, {
10632      key: "haspostcontent",
10633      value: function haspostcontent(value) {
10634        this.applicationState.setHasPostContent(value);
10635      }
10636
10637      /** */
10638    }, {
10639      key: "lock",
10640      value: function lock(locked) {
10641        var note = locked ? Notifications.ADD_APPLICATION_STATE : Notifications.REMOVE_APPLICATION_STATE;
10642        this.sendNotification(note, "locked");
10643        this.applicationState.setLocked(locked);
10644      }
10645
10646      /** */
10647    }, {
10648      key: "mediasequenceended",
10649      value: function mediasequenceended() {
10650        if (this.config.getLoop() === true) {
10651          this.doAfter(this.sendNotification.bind(this, Notifications.REPLAY));
10652        } else {
10653          this.sendNotification(Notifications.CHANGE_PLAY_STATE, PlayState.ENDED);
10654          this.sendNotification(Notifications.CHANGE_ACTIVE_STATE, ActiveState.ACTIVE);
10655        }
10656      }
10657    }], [{
10658      key: "NAME",
10659      get: function get() {
10660        return "PlaybackController";
10661      }
10662    }]);
10663    return PlaybackController;
10664  }(Controller);
10665
10666  /**
10667   * @enum {string}
10668   * @const
10669   * @private
10670   */
10671  var FullscreenMode = {
10672    /**
10673     *
10674     */
10675    EXTERNAL: "external"
10676  };
10677
10678  var StateController = /*#__PURE__*/function (_Controller) {
10679    babelHelpers.inherits(StateController, _Controller);
10680    /**
10681     * The StateController class.
10682     *
10683     * @param {string} name
10684     * @param {Object} viewComponent
10685     * @constructor
10686     * @private
10687     * @extends {amp.player.Controller}
10688     */
10689    function StateController() {
10690      babelHelpers.classCallCheck(this, StateController);
10691      return _Controller.call(this, StateController.NAME) || this;
10692    }
10693
10694    /**
10695     * @static
10696     * @type {string}
10697     */
10698    babelHelpers.createClass(StateController, [{
10699      key: "listNotificationInterests",
10700      value: /** @override */
10701      function listNotificationInterests() {
10702        return [Notifications.BUFFERING_CHANGE, Notifications.WAITING, Notifications.CHANGE_PLAY_STATE, Notifications.TOGGLE_FULL_SCREEN, Notifications.CHANGE_DISPLAY_STATE, Notifications.CHANGE_ACTIVE_STATE, Notifications.INITIALIZED];
10703      }
10704    }, {
10705      key: "core",
10706      get: function get() {
10707        return this.facade.getMediaElement();
10708      }
10709    }, {
10710      key: "view",
10711      get: function get() {
10712        return this.facade.getViewComponent();
10713      }
10714    }, {
10715      key: "fullScreen",
10716      get: function get() {
10717        return this.getFullScreen();
10718      }
10719    }, {
10720      key: "getFullScreen",
10721      value: function getFullScreen() {
10722        return Utils.getFullScreenApi(this.view, this.core);
10723      }
10724    }, {
10725      key: "pictureInPicture",
10726      get: function get() {
10727        return this.getPictureInPicture();
10728      }
10729    }, {
10730      key: "getPictureInPicture",
10731      value: function getPictureInPicture() {
10732        return Utils.getPictureInPictureApi(this.core);
10733      }
10734
10735      /** */
10736    }, {
10737      key: "bufferingchange",
10738      value: function bufferingchange(buffering) {
10739        if (this.applicationState.getBuffering() === buffering) {
10740          return;
10741        }
10742        this.applicationState.setBuffering(buffering);
10743      }
10744
10745      /** */
10746    }, {
10747      key: "waiting",
10748      value: function waiting() {
10749        if (this.applicationState.getWaiting()) {
10750          return;
10751        }
10752        this.applicationState.setWaiting(true);
10753      }
10754
10755      /** */
10756    }, {
10757      key: "changeplaystate",
10758      value: function changeplaystate(value) {
10759        this.applicationState.setPlayState(value);
10760      }
10761
10762      /** */
10763    }, {
10764      key: "changeactivestate",
10765      value: function changeactivestate(value) {
10766        this.applicationState.setActiveState(value);
10767      }
10768
10769      /** */
10770    }, {
10771      key: "initialized",
10772      value: function initialized() {
10773        this.playback.initialized = true;
10774      }
10775
10776      /** */
10777    }, {
10778      key: "changedisplaystate",
10779      value: function changedisplaystate(state) {
10780        var _this = this;
10781        var previousState = this.applicationState.getDisplayState();
10782        if (state === previousState) {
10783          return;
10784        }
10785        var sendNotifications = function sendNotifications(state) {
10786          _this.sendNotification(Notifications.FULL_SCREEN_CHANGE, state === DisplayState.FULL_SCREEN);
10787        };
10788        this.applicationState.setDisplayState(state);
10789        if (this.config.getFullscreen().mode === FullscreenMode.EXTERNAL) {
10790          sendNotifications(state);
10791          return;
10792        }
10793        switch (state) {
10794          case DisplayState.PICTURE_IN_PICTURE:
10795            if (previousState === DisplayState.FULL_SCREEN) this.exitFullScreen();
10796            this.enterPictureInPicture();
10797            break;
10798          case DisplayState.FULL_SCREEN:
10799            if (previousState === DisplayState.PICTURE_IN_PICTURE) this.exitPictureInPicture();
10800            this.enterFullScreen();
10801            break;
10802          case DisplayState.NORMAL:
10803            if (previousState === DisplayState.PICTURE_IN_PICTURE) this.exitPictureInPicture();
10804            if (previousState === DisplayState.FULL_SCREEN) this.exitFullScreen();
10805            break;
10806        }
10807        sendNotifications(state);
10808      }
10809
10810      /** */
10811    }, {
10812      key: "togglefullscreen",
10813      value: function togglefullscreen() {
10814        var state = this.applicationState.getDisplayState() === DisplayState.FULL_SCREEN ? DisplayState.NORMAL : DisplayState.FULL_SCREEN;
10815        return this.sendNotification(Notifications.CHANGE_DISPLAY_STATE, state);
10816      }
10817    }, {
10818      key: "enterFullScreen",
10819      value: function enterFullScreen() {
10820        var _this2 = this;
10821        var core = this.core;
10822        var view = this.view;
10823        var fullScreen = this.fullScreen;
10824        var getDisplayState = function getDisplayState() {
10825          var displayState = _this2.applicationState.getDisplayState();
10826          return displayState !== DisplayState.FULL_SCREEN ? displayState : DisplayState.NORMAL;
10827        };
10828        if (fullScreen.event != null) {
10829          // Hack: added condition to detect firefox fullScreen event and send CHANGE_DISPLAY_STATE notification
10830          if (view.mozRequestfullScreen != null) {
10831            document[fullScreen.event] = function (event) {
10832              if (!document.mozFullScreen) {
10833                return _this2.sendNotification(Notifications.CHANGE_DISPLAY_STATE, getDisplayState());
10834              }
10835            };
10836          } else {
10837            document[fullScreen.event] = function (event) {
10838              if (document[fullScreen.element] == null) {
10839                return _this2.sendNotification(Notifications.CHANGE_DISPLAY_STATE, getDisplayState());
10840              }
10841            };
10842          }
10843        } else {
10844          //HACK: Safari Webkit does not have an AV Player fullscreen event, this code may safely control both enter/exit
10845          var onwebkitenterfullscreen = function onwebkitenterfullscreen() {
10846            if (core.webkitDisplayingFullscreen !== true) return core.readyState !== 0 ? void 0 : _this2.sendNotification(Notifications.CHANGE_DISPLAY_STATE, DisplayState.NORMAL);
10847            _this2.facade.timers.clearInterval(_this2.interval);
10848            _this2.interval = _this2.facade.timers.setInterval(onwebkitexitfullscreen, 100);
10849          };
10850          var onwebkitexitfullscreen = function onwebkitexitfullscreen() {
10851            if (core.webkitDisplayingFullscreen !== true) _this2.sendNotification(Notifications.CHANGE_DISPLAY_STATE, getDisplayState());
10852          };
10853          this.facade.timers.clearInterval(this.interval);
10854          this.interval = this.facade.timers.setInterval(onwebkitenterfullscreen, 100);
10855        }
10856        if (fullScreen.error != null) {
10857          document.addEventListener(fullScreen.error, this.facade.logger.error.bind(this.facade.logger));
10858        }
10859        fullScreen.enter();
10860      }
10861    }, {
10862      key: "exitFullScreen",
10863      value: function exitFullScreen() {
10864        var core = this.core;
10865        var fullScreen = this.fullScreen;
10866        var element = fullScreen.element;
10867        if (fullScreen == null || element != null && document[element] == null) return;
10868        if (typeof fullScreen.exit === "function") {
10869          fullScreen.exit();
10870        }
10871        core[fullScreen.event] = null;
10872        this.facade.timers.clearInterval(this.interval);
10873      }
10874    }, {
10875      key: "enterPictureInPicture",
10876      value: function enterPictureInPicture() {
10877        var _this3 = this;
10878        var core = this.core;
10879        var pip = this.pictureInPicture;
10880        var onleavepictureinpicture = function onleavepictureinpicture() {
10881          if (document[pip.element] != null) return;
10882          var displayState = _this3.applicationState.getDisplayState();
10883          var state = displayState !== DisplayState.PICTURE_IN_PICTURE ? displayState : DisplayState.NORMAL;
10884          return _this3.sendNotification(Notifications.CHANGE_DISPLAY_STATE, state);
10885        };
10886        if (core.readyState === 0 || !Utils.isPictureInPictureSupported(core)) return;
10887        if (core[pip.event] != null) {
10888          core[pip.event] = onleavepictureinpicture;
10889        } else {
10890          core.once(pip.eventName, onleavepictureinpicture);
10891        }
10892        pip.enter();
10893      }
10894    }, {
10895      key: "exitPictureInPicture",
10896      value: function exitPictureInPicture() {
10897        var pip = this.pictureInPicture;
10898        if (document[pip.element] == null) return;
10899        pip.exit();
10900      }
10901    }], [{
10902      key: "NAME",
10903      get: function get() {
10904        return "StateController";
10905      }
10906    }]);
10907    return StateController;
10908  }(Controller);
10909
10910  var Plugin = /*#__PURE__*/function (_Module) {
10911    babelHelpers.inherits(Plugin, _Module);
10912    /**
10913     * The Plugin class. Acts as a base for plugins.
10914     *
10915     * @constructor
10916     * @private
10917     * @extends {Module}
10918     */
10919    function Plugin() {
10920      var _this;
10921      babelHelpers.classCallCheck(this, Plugin);
10922      _this = _Module.call(this) || this;
10923      _this.player = null;
10924      _this.proxy = null;
10925      return _this;
10926    }
10927
10928    /**
10929     * @override
10930     */
10931    babelHelpers.createClass(Plugin, [{
10932      key: "initialize",
10933      value: function initialize(config, player) {
10934        this.player = player;
10935        this.logger = this.player.logger;
10936        babelHelpers.get(babelHelpers.getPrototypeOf(Plugin.prototype), "initialize", this).call(this, config, player);
10937      }
10938
10939      /** */
10940    }, {
10941      key: "isAvailable",
10942      value: function isAvailable() {
10943        return true;
10944      }
10945
10946      /** */
10947    }, {
10948      key: "loadModuleResources",
10949      value: function loadModuleResources() {
10950        if (!this.isAvailable()) {
10951          return Promise.resolve();
10952        }
10953        return babelHelpers.get(babelHelpers.getPrototypeOf(Plugin.prototype), "loadModuleResources", this).call(this);
10954      }
10955
10956      /**
10957       * @override
10958       */
10959    }, {
10960      key: "resourcesLoaded",
10961      value: function resourcesLoaded() {
10962        if (typeof this.oninitialized === "function") {
10963          this.oninitialized(this);
10964        }
10965      }
10966
10967      /** @override */
10968    }, {
10969      key: "onRegister",
10970      value: function onRegister() {
10971        if (this.isAvailable()) {
10972          this.createFramework();
10973          var proxy = this.retrieveProxy(PluginProxy.NAME);
10974          if (proxy && typeof proxy.initialize === "function") {
10975            proxy.initialize();
10976          }
10977        }
10978        this.performance.record("ready");
10979        this.sendNotification(PluginNotifications.PLUGIN_REGISTERED, this);
10980      }
10981
10982      /** @override */
10983    }, {
10984      key: "logEvent",
10985      value: function logEvent(event) {
10986        if (this.ignoreEvents.test(event.type) === true) {
10987          return;
10988        }
10989        var prefix = this.player.getModuleName().toUpperCase() + " " + this.getModuleName().toUpperCase();
10990        if (event.dispatcher != null) {
10991          prefix += " " + event.dispatcher;
10992        }
10993        this.logger.log("[".concat(prefix, " EVENT] ").concat(event.type), event);
10994      }
10995
10996      /** @override */
10997    }, {
10998      key: "listNotificationPublications",
10999      value: function listNotificationPublications() {
11000        var notes = [Notifications.ADD_LAYER, Notifications.REMOVE_LAYER, Notifications.ADD_OVERLAY, Notifications.REMOVE_OVERLAY, Notifications.ADD_APPLICATION_STATE, Notifications.REMOVE_APPLICATION_STATE, Notifications.PLAYBACK_CORE_CHANGE];
11001        return notes.concat(Object.values(PluginNotifications));
11002      }
11003    }]);
11004    return Plugin;
11005  }(Module);
11006
11007  var PluginsController = /*#__PURE__*/function (_puremvc$Mediator) {
11008    babelHelpers.inherits(PluginsController, _puremvc$Mediator);
11009    /**
11010     * @constructor
11011     * @private
11012     */
11013    function PluginsController() {
11014      var _this;
11015      babelHelpers.classCallCheck(this, PluginsController);
11016      _this = _puremvc$Mediator.call(this, PluginsController.NAME) || this;
11017      _this.plugins = [];
11018      _this.registered = 0;
11019      return _this;
11020    }
11021
11022    /**
11023     * @static
11024     * @type {string}
11025     */
11026    babelHelpers.createClass(PluginsController, [{
11027      key: "listNotificationInterests",
11028      value:
11029      /**
11030       * Overridden so this class may subscribe to all notifications
11031       * @return An Array
11032       *
11033       * @override
11034       */
11035      function listNotificationInterests() {
11036        return [PluginNotifications.REGISTER_PLUGINS, PluginNotifications.PLUGIN_REGIST
11036ERED, PluginNotifications.PLUGINS_INITIALIZED, Notifications.DESTROY];
11037      }
11038
11039      /**
11040       * Handles notifications of interest to this mediator. Note that
11041       * the default declaration is to allow the super to handle the
11042       * note. This leaves the base JunctionMediator to handle things
11043       * like ACCEPT_INPUT_PIPE and ACCEPT_OUTPUT_PIPE
11044       *
11045       * @param note An INotification
11046       * @override
11047       */
11048    }, {
11049      key: "handleNotification",
11050      value: function handleNotification(notification) {
11051        var _this2 = this;
11052        var name = notification.getName();
11053        var body = notification.getBody();
11054        switch (name) {
11055          case PluginNotifications.REGISTER_PLUGINS:
11056            var config = body;
11057            this.facade.plugins = [];
11058
11059            // load internal PureMVC based plugins
11060            fp.each(AMP.plugins, function (def, key) {
11061              if (!(key in config)) {
11062                return;
11063              }
11064              var init = config[key];
11065              if (init == null || init.enabled === false) {
11066                return;
11067              }
11068              if (def == null) {
11069                _this2.facade.logger.debug("[AMP] Plugin could not be found: ".concat(key));
11070                return;
11071              }
11072              try {
11073                var plugin = new def();
11074                plugin.oninitialized = _this2.onplugininitialized.bind(_this2, key);
11075                plugin.onerror = _this2.onpluginerror.bind(_this2, key);
11076                _this2.plugins.push(plugin.initialize.bind(plugin, init, _this2.facade));
11077              } catch (error) {
11078                _this2.facade.logger.error("[AMP] Plugin could not be created: ".concat(key, ". ").concat(error));
11079                return;
11080              }
11081            });
11082
11083            // load external promise based plugins
11084            config.plugins || {};
11085            fp.each(config.plugins || {}, function (init, key) {
11086              if (init == null || init.enabled === false) {
11087                return;
11088              }
11089              var initialize = function initialize(player, config, key, resolve, reject) {
11090                return _this2.facade.loadResources(config.resources).then(function () {
11091                  var def = AMP.plugins[key];
11092                  if (def == null) {
11093                    reject("[AMP] Plugin could not be found: ".concat(key));
11094                  }
11095                  return def(player, config, key);
11096                }).then(resolve)["catch"](reject);
11097              };
11098              _this2.plugins.push(initialize.bind(null, _this2.facade, init, key, _this2.onpluginregistered.bind(_this2, key), _this2.onpluginerror.bind(_this2, key)));
11099            });
11100            this.plugins.forEach(function (item) {
11101              return item();
11102            });
11103            break;
11104          case PluginNotifications.PLUGIN_REGISTERED:
11105            this.onpluginregistered(body.getModuleName(), body);
11106            break;
11107          case PluginNotifications.PLUGINS_INITIALIZED:
11108            this.sendNotification(Notifications.STARTUP, this.facade.config);
11109            break;
11110          case Notifications.DESTROY:
11111            fp.each(this.facade.plugins, function (plugin) {
11112              if (plugin.destroy) {
11113                try {
11114                  plugin.destroy();
11115                } catch (error) {
11116                  _this2.facade.logger.error(error);
11117                }
11118              }
11119            });
11120            break;
11121        }
11122      }
11123    }, {
11124      key: "initializedCheck",
11125      value: function initializedCheck() {
11126        if (this.registered === this.plugins.length) {
11127          this.sendNotification(PluginNotifications.PLUGINS_INITIALIZED, this.plugins);
11128        }
11129      }
11130    }, {
11131      key: "onplugininitialized",
11132      value: function onplugininitialized(key, plugin) {
11133        plugin.oninitialized = null;
11134        plugin.onerror = null;
11135        this.facade.registerModule(plugin);
11136      }
11137    }, {
11138      key: "onpluginerror",
11139      value: function onpluginerror(key, error) {
11140        this.registered++;
11141        this.facade.logger.error("[AMP] Plugin could not be registered: ".concat(key));
11142        this.facade.logger.error(error);
11143        this.initializedCheck();
11144      }
11145    }, {
11146      key: "onpluginregistered",
11147      value: function onpluginregistered(key, plugin) {
11148        if (this.facade[key] != null) {
11149          return;
11150        }
11151        this.registered++;
11152        this.facade.logger.debug("[AMP] Plugin registered: ".concat(key));
11153        this.facade[key] = plugin;
11154        this.facade.plugins.push(key);
11155        var feature = plugin.feature;
11156        if (feature != null) {
11157          this.facade[feature] = plugin;
11158        }
11159        this.initializedCheck();
11160      }
11161    }], [{
11162      key: "NAME",
11163      get: function get() {
11164        return "PluginsController";
11165      }
11166    }]);
11167    return PluginsController;
11168  }(puremvc.Mediator);
11169
11170  var MediaController = /*#__PURE__*/function (_Controller) {
11171    babelHelpers.inherits(MediaController, _Controller);
11172    /**
11173     * The MediaController class.
11174     *
11175     * @param {string} name
11176     * @param {Object} viewComponent
11177     * @constructor
11178     * @private
11179     * @extends {amp.player.Controller}
11180     */
11181    function MediaController() {
11182      babelHelpers.classCallCheck(this, MediaController);
11183      return _Controller.call(this, MediaController.NAME) || this;
11184    }
11185
11186    /**
11187     * @static
11188     * @type {string}
11189     */
11190    babelHelpers.createClass(MediaController, [{
11191      key: "listNotificationInterests",
11192      value: /** @override */
11193      function listNotificationInterests() {
11194        return [Notifications.SET_MEDIA, Notifications.CHANGE_MEDIA, Notifications.MEDIA_VALIDATED, AuthEvents.AUTHORIZED, Notifications.RECORD_CONTENT_CHANGE];
11195      }
11196
11197      /** */
11198    }, {
11199      key: "setmedia",
11200      value: function setmedia(media) {
11201        var _this = this;
11202        // Lock applicationState.setLockedout the user until the media has been fully processed
11203        this.sendNotification(Notifications.LOCK, true);
11204        this.facade.busy = true;
11205        this.applicationState.setBuffering(false);
11206        this.applicationState.setEnded(false);
11207        this.playback.setEnabled(false);
11208        this.playback.pause();
11209        if (this.tracks != null) {
11210          this.tracks.clear();
11211        }
11212        this.sendNotification(Notifications.HAS_POST_CONTENT, false);
11213        this.sendNotification(Notifications.CHANGE_PLAY_STATE, PlayState.READY);
11214        this.sendNotification(Notifications.CHANGE_ACTIVE_STATE, ActiveState.ACTIVE);
11215
11216        // apply the defaults before running transforms
11217        media = this.media.applyDefaults(media);
11218        this.security.setMedia(media);
11219        this.facade.transform(TransformType.MEDIA, media).then(function (result) {
11220          if (result == null) {
11221            return;
11222          }
11223
11224          // re-apply the defaults after running transforms
11225          result = _this.media.applyDefaults(result);
11226          _this.sendNotification(Notifications.CHANGE_MEDIA, result);
11227        })["catch"](function (error) {
11228          _this.sendNotification(Notifications.ERROR, error);
11229        });
11230      }
11231
11232      /** */
11233    }, {
11234      key: "changemedia",
11235      value: function changemedia(media) {
11236        try {
11237          //update the metadata
11238          media = this.media.setData(media);
11239        } catch (error) {
11240          this.sendNotification(Notifications.ERROR, error.message);
11241          return;
11242        }
11243        media = this.media.getData();
11244        if (media.authorization != null) {
11245          this.security.setAuthorization(media.authorization);
11246        }
11247        if (this.security.getAuthorized()) {
11248          this.sendNotification(AuthEvents.AUTHORIZED, this.security.getAuthorization());
11249        } else {
11250          this.sendNotification(AuthEvents.AUTHORIZE, {
11251            media: media
11252          });
11253        }
11254      }
11255
11256      /** */
11257    }, {
11258      key: "mediavalidated",
11259      value: function mediavalidated(media) {
11260        var _this2 = this;
11261        var mediaElement = this.facade.getMediaElement();
11262        this.sendNotification(Notifications.MEDIA_CHANGE, media);
11263        this.playerCore.setPlaybackCore(media).then(function (playback) {
11264          _this2.sendNotification(Notifications.LOCK, false);
11265          _this2.facade.busy = false;
11266          if (playback == null) {
11267            playback = _this2.player.playback;
11268          }
11269          playback.reset();
11270          playback.setCurrentTime(media.startTime || 0);
11271          if (_this2.applicationState.getPlaybackTarget() !== "amp") {
11272            _this2.sendNotification(Notifications.MEDIA_SEQUENCE_INITIALIZED, {
11273              media: media
11274            });
11275            return;
11276          }
11277          _this2.tracks.setMedia(media);
11278
11279          // get the value of autoplay, muted and inline
11280          var autoplay = _this2.facade.getAutoplay() && _this2.a
11280pplicationState.getLocked() === false;
11281          var muted = _this2.config.getMuted();
11282          var playsinline = _this2.config.getPlaysInline();
11283
11284          // attempt autoplay calculation on the first playback attempt
11285          if (_this2.applicationState.calculateAutoplay !== false) {
11286            _this2.applicationState.calculateAutoplay = false;
11287
11288            // only calculate autoplay if the customer opts in
11289            if (autoplay === true) {
11290              // get the values for threshold and policy
11291              var threshold = _this2.facade.autoplayThreshold;
11292              var policy = _this2.facade.autoplayPolicy;
11293
11294              // only calculate autoplay if the browser disallows it and the customer hasn't explicitly opted out
11295              if (threshold !== AutoplayThreshold.ALLOWED && policy !== AutoplayPolicy.NONE) {
11296                // customer has explicitly muted playback
11297                var forceMuted = muted === true;
11298
11299                // customer has explicitly inlined playback
11300                var forceInline = playsinline === true;
11301
11302                // only attempt autoplay if the customer opts in
11303                var attemptMuted = policy.includes(AutoplayPolicy.MUTED);
11304
11305                // threshold must be one of the "muted" values
11306                var mutedAllowed = threshold === AutoplayThreshold.MUTED;
11307
11308                // only allow mutedinline if the customer explicitly opts in
11309                var mutedInlineAllowed = threshold === AutoplayThreshold.MUTED_INLINE && forceInline;
11310
11311                // customer has explicitly set muted to false
11312                var notUnmuted = muted !== false;
11313
11314                // have the various requirements for muted playback been fulfilled?
11315                var canplayMuted = mutedAllowed || mutedInlineAllowed;
11316
11317                // autoplay calculation
11318                autoplay = forceMuted && canplayMuted || attemptMuted && canplayMuted && notUnmuted;
11319                if (autoplay === true) {
11320                  // if we've made it this far the player should attempt muted playback
11321                  muted = true;
11322                } else {
11323                  _this2.sendNotification(Notifications.AUTOPLAY_BLOCKED, {
11324                    threshold: threshold,
11325                    policy: policy
11326                  });
11327                }
11328              }
11329            }
11330          }
11331          if (playsinline != null) {
11332            mediaElement.playsInline = playsinline;
11333          }
11334          if (muted != null) {
11335            _this2.playback.setMuted(muted, true, Notifications.INTERNAL);
11336          }
11337          _this2.sendNotification(Notifications.MEDIA_SEQUENCE_INITIALIZED, {
11338            media: media,
11339            autoplay: autoplay,
11340            muted: muted === true,
11341            playsinline: playsinline === true
11342          });
11343          if (autoplay === true) {
11344            _this2.doAfter(_this2.sendNotification.bind(_this2, Notifications.PLAY, true));
11345          } else {
11346            var preload = _this2.facade.getPreload() || Preload.NONE;
11347            if (preload !== Preload.NONE) {
11348              _this2.playback.preload(preload);
11349            }
11350          }
11351        })["catch"](function (error) {
11352          _this2.sendNotification(Notifications.ERROR, error);
11353        });
11354      }
11355
11356      /** */
11357    }, {
11358      key: "authorized",
11359      value: function authorized() {
11360        if (this.security.getSession() != null) {
11361          return;
11362        }
11363        this.security.setSession(Utils.createUID());
11364        this.sendNotification(Notifications.MEDIA_VALIDATED, this.media.getData());
11365      }
11366
11367      /** */
11368    }, {
11369      key: "recordcontentchange",
11370      value: function recordcontentchange(content) {
11371        this.media.updateData(content);
11372      }
11373    }], [{
11374      key: "NAME",
11375      get: function get() {
11376        return "MediaController";
11377      }
11378    }]);
11379    return MediaController;
11380  }(Controller);
11381
11382  var TimeController = /*#__PURE__*/function (_Controller) {
11383    babelHelpers.inherits(TimeController, _Controller);
11384    /**
11385     * The TimeController class.
11386     *
11387     * @param {string} name
11388     * @param {Object} viewComponent
11389     * @constructor
11390     * @private
11391     * @extends {amp.player.Controller}
11392     */
11393    function TimeController() {
11394      babelHelpers.classCallCheck(this, TimeController);
11395      return _Controller.call(this, TimeController.NAME) || this;
11396    }
11397
11398    /**
11399     * @static
11400     * @type {string}
11401     */
11402    babelHelpers.createClass(TimeController, [{
11403      key: "listNotificationInterests",
11404      value: /** @override */
11405      function listNotificationInterests() {
11406        return [Notifications.TIMED_METADATA, Notifications.TIME_CHANGE, Notifications.SEEK, Notifications.SEEKING, Notifications.SEEK_COMPLETE, Notifications.GO_LIVE];
11407      }
11408
11409      /** */
11410    }, {
11411      key: "timedmetadata",
11412      value: function timedmetadata(metadata, notification) {
11413        // properties cannot be added to the value object, so we need to make a shallow copy
11414        var detail = {
11415          startTime: metadata.startTime,
11416          endTime: metadata.endTime,
11417          type: metadata.type,
11418          track: metadata.track,
11419          value: {
11420            key: metadata.value.key,
11421            data: metadata.value.data,
11422            info: metadata.value.info
11423          }
11424        };
11425        var value = detail.value;
11426        try {
11427          if (value.info == null) {
11428            if (typeof value.data === "string") {
11429              value.info = value.data;
11430            } else if (value.data instanceof ArrayBuffer) {
11431              value.info = Utils.arrayBufferToString(value.data);
11432            }
11433          }
11434        } catch (error) {
11435          this.facade.logger.log("[AMP ERROR]: Could not parse timed metadata");
11436        }
11437        notification.body = detail;
11438      }
11439
11440      /** */
11441    }, {
11442      key: "timechange",
11443      value: function timechange(time) {
11444        var _this = this;
11445        if (time.currentTime != null) {
11446          this.facade.transform(TransformType.TIME, time.currentTime).then(function (time) {
11447            return _this.applicationState.setCurrentTime(time);
11448          });
11449        }
11450        if (time.duration != null) {
11451          this.facade.transform(TransformType.TIME, time.duration).then(function (time) {
11452            return _this.applicationState.setDuration(time);
11453          });
11454        }
11455      }
11456
11457      /** */
11458    }, {
11459      key: "seek",
11460      value: function seek(time) {
11461        var _this2 = this;
11462        this.facade.transform(TransformType.SEEK, time).then(function (time) {
11463          if (time == null || time === _this2.playback.getCurrentTime() || _this2.playback.metadataloaded === false) {
11464            return;
11465          }
11466          // HACK: Setting currentTime to 0 on Akamai HLS streams causes playback at double speed.
11467          if (time === 0 && _this2.media.getType() === Utils.mimeTypes.m3u8) {
11468            time = 0.25;
11469          }
11470          if (_this2.playback.getStarted() === true) {
11471            _this2.sendNotification(Notifications.WAITING);
11472          }
11473          _this2.facade.getMediaElement();
11474          _this2.playback.setCurrentTime(time);
11475          if (_this2.playback.getStarted() !== true) {
11476            _this2.sendNotification(Notifications.TIME_CHANGE, time);
11477          }
11478        });
11479      }
11480
11481      /** */
11482    }, {
11483      key: "seeking",
11484      value: function seeking() {
11485        if (this.applicationState.getSeeking() === true) {
11486          this.applicationState.setSeekRequested(true);
11487          return;
11488        }
11489        if (this.applicationState.getEnded()) {
11490          this.applicationState.setEnded(false);
11491        }
11492        if (this.facade.getMediaElement().currentTime === 0) {
11493          this.media.started = false;
11494        }
11495        this.applicationState.setSeeking(true);
11496      }
11497
11498      /** */
11499    }, {
11500      key: "seekcomplete",
11501      value: function seekcomplete(value, notification) {
11502        var _this3 = this;
11503        //TODO: HACK! Safari and HLS will jump back to the original current time, then jump to the seek time
11504        this.facade.timers.setTimeout(function () {
11505          _this3.applicationState.setSeeking(false);
11506          _this3.applicationState.setSeekRequested(false);
11507          _this3.sendNotification(Notifications.SEEKED, value);
11508          if (_this3.applicationState.getPlayState() === PlayState.READY) {
11509            return;
11510          }
11511          //TODO: HACK! Ipad Safari FS mode paused during seek
11512          if (_this3.applicationState.displayState === "full-screen" && _this3.applicationState.device === "ipad" && _this3.facade.retrieveProxy(PlaybackProxy.NAME).getPaused() !== _this3.facade.getMediaElement().paused) {
11513            var state = _this3.facade.getMediaElement().paused === true ? PlayState.PAUSED : PlayState.PLAYING;
11514            _this3.sendNotification(Notifications.CHANGE_PLAY_STATE, state);
11515          }
11516        }, 1);
11517      }
11518
11519      /** */
11520    }, {
11521      key: "golive",
11522      value: function golive() {
11523        if (typeof this.playback.goLive === "function") {
11524          this.playback.goLive();
11525        }
11526      }
11527    }], [{
11528      key: "NAME",
11529      get: function get() {
11530        return "TimeController";
11531      }
11532    }]);
11533    return TimeController;
11534  }(Controller);
11535
11536  var VolumeController = /*#__PURE__*/function (_Controller) {
11537    babelHelpers.inherits(VolumeController, _Controller);
11538    /**
11539     * The VolumeController class.
11540     *
11541     * @param {string} name
11542     * @param {Object} viewComponent
11543     * @constructor
11544     * @private
11545     * @extends {amp.player.Controller}
11546     */
11547    function VolumeController() {
11548      babelHelpers.classCallCheck(this, VolumeController);
11549      return _Controller.call(this, VolumeController.NAME) || this;
11550    }
11551
11552    /**
11553     * @static
11554     * @type {string}
11555     */
11556    babelHelpers.createClass(VolumeController, [{
11557      key: "listNotificationInterests",
11558      value: /** @override */
11559      function listNotificationInterests() {
11560        return [Notifications.VOLUME_CHANGE, Notifications.CHANGE_VOLUME, Notifications.CHANGE_MUTED, Notifications.TOGGLE_MUTED];
11561      }
11562
11563      /** */
11564    }, {
11565      key: "changevolume",
11566      value: function changevolume(volume) {
11567        //update the playback core
11568        volume = Utils.clamp(volume, 0, 1);
11569        if (this.playback.getVolume() === volume) {
11570          return;
11571        }
11572        this.playback.setVolume(volume);
11573        if (volume === 0) {
11574          this.sendNotification(Notifications.ADD_APPLICATION_STATE, "muted");
11575        } else {
11576          this.sendNotification(Notifications.REMOVE_APPLICATION_STATE, "muted");
11577        }
11578      }
11579
11580      /** */
11581    }, {
11582      key: "volumechange",
11583      value: function volumechange(volume) {
11584        this.applicationState.setVolume(volume);
11585      }
11586
11587      /** */
11588    }, {
11589      key: "changemuted",
11590      value: function changemuted(muted) {
11591        this.playback.setMuted(muted);
11592      }
11593
11594      /** */
11595    }, {
11596      key: "togglemuted",
11597      value: function togglemuted() {
11598        this.playback.setMuted(!this.playback.getMuted());
11599      }
11600    }], [{
11601      key: "NAME",
11602      get: function get() {
11603        return "VolumeController";
11604      }
11605    }]);
11606    return VolumeController;
11607  }(Controller);
11608
11609  var Settings = /*#__PURE__*/function () {
11610    /** */
11611    function Settings(overrides) {
11612      babelHelpers.classCallCheck(this, Settings);
11613      var settings = Object.assign({}, Settings.defaults);
11614      settings = Utils.override(settings, overrides, false);
11615      Utils.override(this, settings, false);
11616    }
11617
11618    /** */
11619    babelHelpers.createClass(Settings, null, [{
11620      key: "create",
11621      value: function create(overrides) {
11622        return new Settings(overrides);
11623      }
11624    }]);
11625    return Settings;
11626  }();
11627
11628  /** */
11629  Settings.defaults = {
11630    version: "1.0.1",
11631    // this is the version of the Settings data model. Used to synchronize user settings when the model's structure changes
11632    volume: 1,
11633    captions: {
11634      presets: {
11635        fontFamily: {
11636          monospacedSerif: "'Courier New', Courier, 'Nimbus Mono L', 'Cutive Mono', monospace",
11637          proportionalSerif: "'Times New Roman', Times, Georgia, Cambria, 'PT Serif Caption', serif",
11638          monospacedSansSerif: "'Deja Vu Sans Mono', 'Lucida Console', Monaco, Consolas, 'PT Mono', monospace",
11639          proportionalSansSerif: "Roboto, 'Arial Unicode Ms', Arial, Helvetica, Verdana, 'PT Sans Caption', sans-serif",
11640          casual: "'Comic Sans MS', Impact, Handlee, fantasy",
11641          cursive: "'Monotype Corsiva', 'URW Chancery L', 'Apple Chancery', 'Dancing Script', cursive",
11642          smallCapitals: "'Arial Unicode Ms', Arial, Helvetica, Verdana, 'Marcellus SC', sans-serif; font-variant: small-caps"
11643        },
11644        fontSize: {
11645          smallest: "x-small",
11646          small: "small",
11647          medium: "medium",
11648          large: "large",
11649          largest: "x-large"
11650        },
11651        iosFontSize: {
11652          smallest: "62.5%",
11653          small: "83.333%",
11654          medium: "100%",
11655          large: "112.5%",
11656          largest: "150%"
11657        },
11658        edgeType: {
11659          none: "0px 0px 0px",
11660          depressed: "0px 1px 0px",
11661          leftShadow: "-3px 3px 2px",
11662          raised: "0px 1px 1px",
11663          rightShadow: "3px 3px 2px",
11664          uniform: "0px 0px 4px"
11665        },
11666        color: {
11667          white: "rgb(255, 255, 255)",
11668          yellow: "rgb(255, 255, 0)",
11669          green: "rgb(0, 128, 0)",
11670          cyan: "rgb(0, 255, 255)",
11671          blue: "rgb(0, 0, 255)",
11672          magenta: "rgb(255, 0, 255)",
11673          red: "rgb(255, 0, 0)",
11674          black: "rgb(0, 0, 0)"
11675        }
11676      },
11677      visible: false,
11678      fontFamily: "monospacedSerif",
11679      fontSize: "medium",
11680      scroll: "popout",
11681      fontColor: "white",
11682      fontOpacity: "100%",
11683      edgeType: "rightShadow",
11684      edgeColor: "black",
11685      edgeOpacity: "75%",
11686      backgroundColor: "black",
11687      backgroundOpacity: "0%",
11688      windowColor: "black",
11689      windowOpacity: "50%",
11690      styles: {
11691        window: {
11692          backgroundColor: "rgba(0,0,0,0.5)"
11693        },
11694        text: {
11695          fontFamily: "Courier New, Courier, Nimbus Mono L, Cutive Mono, monospace",
11696          fontSize: "100%",
11697          color: "rgba(255,255,255,1)",
11698          textShadow: "2px 2px 3px rgba(0,0,0,0.75)",
11699          backgroundColor: "rgba(0,0,0,0)"
11700        }
11701      }
11702    }
11703  };
11704
11705  var namespace = "akamai_amp";
11706  var SettingsController = /*#__PURE__*/function (_Controller) {
11707    babelHelpers.inherits(SettingsController, _Controller);
11708    /**
11709     * The SettingsController class.
11710     *
11711     * @param {string} name
11712     * @param {Object} viewComponent
11713     * @constructor
11714     * @private
11715     * @extends {amp.player.Controller}
11716     */
11717    function SettingsController() {
11718      var _this;
11719      babelHelpers.classCallCheck(this, SettingsController);
11720      _this = _Controller.call(this, SettingsController.NAME) || this;
11721      _this.namespace = SettingsController.NAMESPACE;
11722      return _this;
11723    }
11724    babelHelpers.createClass(SettingsController, [{
11725      key: "onRegister",
11726      value: /** @override */
11727      function onRegister() {
11728        // get customer supplied settings configurations
11729        var config = this.config.getSettings() || {};
11730        if (config.namespace != null) {
11731          this.namespace = namespace = config.namespace;
11732        }
11733
11734        // intialize the saved settings with the defaults Object
11735        this.settings = Settings.create(config.defaults);
11736
11737        // overrides
11738        var overrides = Object.assign({}, config);
11739        delete overrides.defaults;
11740        delete overrides.namespace;
11741        try {
11742          // get end user settings
11743          var data = localStorage.getItem(this.namespace);
11744          var settings;
11745          if (data != null) {
11746            settings = Utils.override(JSON.parse(data), overrides);
11747          }
11748
11749          // update the settings object with end user settings
11750          this.save(settings);
11751        } catch (error) {}
11752      }
11753
11754      /** @override */
11755    }, {
11756      key: "listNotificationInterests",
11757      value: function listNotificationInterests() {
11758        return [Notifications.READY, Notifications.VOLUME_CHANGE, Notifications.CHANGE_SETTINGS, Notifications.CHANGE_AUTOPLAY, Notifications.CHANGE_LOOP, Notifications.CHANGE_PRELOAD, Notifications.CHANGE_CONTROLS, Notifications.MEDIA_CHANGE];
11759      }
11760
11761      /** */
11762    }, {
11763      key: "changesettings",
11764      value: function changesettings(settings) {
11765        this.change(settings);
11766      }
11767
11768      /** */
11769    }, {
11770      key: "changeautoplay",
11771      value: function changeautoplay(value) {
11772        this.config.setAutoplay(value);
11773      }
11774
11775      /** */
11776    }, {
11777      key: "changeloop",
11778      value: function changeloop(value) {
11779        this.config.setLoop(value);
11780      }
11781
11782      /** */
11783    }, {
11784      key: "changepreload",
11785      value: function changepreload(value) {
11786        this.config.setPreload(value);
11787      }
11788
11789      /** */
11790    }, {
11791      key: "changecontrols",
11792      value: function changecontrols(value) {
11793        this.config.setControls(value);
11794        this.updateControls();
11795      }
11796
11797      /** */
11798    }, {
11799      key: "updateControls",
11800      value: function updateControls() {
11801        this.player.mediaElement.controls = this.config.getControls();
11802      }
11803
11804      /** */
11805    }, {
11806      key: "mediachange",
11807      value: function mediachange(value) {
11808        this.updateControls();
11809      }
11810
11811      /** */
11812    }, {
11813      key: "ready",
11814      value: function ready() {
11815        var value = this.settings.volume;
11816        if (value != null) {
11817          this.sendNotification(Notifications.CHANGE_VOLUME, value);
11818        }
11819      }
11820
11821      /** */
11822    }, {
11823      key: "volumechange",
11824      value: function volumechange(volume, notification) {
11825        if (this.settings.volume === volume) {
11826          return;
11827        }
11828
11829        // Only record change made the the user, ignore changes initiated internally by the player
11830        if (notification.getType() == "internal") return;
11831        this.change({
11832          volume: volume
11833        });
11834      }
11835
11836      /** */
11837    }, {
11838      key: "computeStyles",
11839      value: function computeStyles(captions, presets) {
11840        captions = Utils.override(this.settings.captions, captions);
11841        if (presets == null) {
11842          presets = captions.presets;
11843        }
11844        function preset(type) {
11845          var dflt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : captions[type];
11846          return presets[type][dflt] || dflt;
11847        }
11848        function toColor(type) {
11849          var color = CSS.toColor(preset("color", captions[type + "Color"]));
11850          var opacity = captions[type + "Opacity"];
11851          if (opacity != null) {
11852            color.a = CSS.fromPercent(opacity);
11853          }
11854          return CSS.fromColor(color);
11855        }
11856        function getFontSize() {
11857          var size = preset("fontSize");
11858
11859          //IOS Fullscreen devices do not support <absolute> font-size type
11860          if (Utils.isIOS()) size = CSS.toPercent(preset("iosFontSize", captions["fontSize"]));
11861          return size;
11862        }
11863        return {
11864          window: {
11865            backgroundColor: toColor("window")
11866          },
11867          text: {
11868            fontFamily: preset("fontFamily"),
11869            fontSize: getFontSize(),
11870            color: toColor("font"),
11871            textShadow: preset("edgeType") + " " + toColor("edge"),
11872            backgroundColor: toColor("background")
11873          }
11874        };
11875      }
11876
11877      /** */
11878    }, {
11879      key: "change",
11880      value: function change(settings) {
11881        if (settings == null || babelHelpers["typeof"](settings) !== "object" || settings instanceof Array) {
11882          return;
11883        }
11884        var changes = Utils.diff(this.settings, settings);
11885        if (changes == null) {
11886          return;
11887        }
11888        var captions = changes.captions;
11889        if (captions != null) {
11890          captions.styles = Utils.override(this.computeStyles(captions), captions.styles);
11891        }
11892        this.save(changes);
11893        this.sendNotification(Notifications.SETTINGS_CHANGE, changes);
11894      }
11895
11896      /** */
11897    }, {
11898      key: "getSettings",
11899      value: function getSettings() {
11900        return Object.freeze(Object.assign({
11901          change: this.change.bind(this)
11902        }, this.settings));
11903      }
11904
11905      /** */
11906    }, {
11907      key: "save",
11908      value: function save(settings) {
11909        this.settings = Utils.override(this.settings, settings);
11910        try {
11911          localStorage.setItem(this.namespace, JSON.stringify(this.settings));
11912        } catch (error) {}
11913      }
11914    }], [{
11915      key: "NAMESPACE",
11916      get: function get() {
11917        return namespace;
11918      }
11919    }, {
11920      key: "GET",
11921      value: function GET() {
11922        var settings = localStorage.getItem(SettingsController.NAMESPACE);
11923        try {
11924          settings = JSON.parse(settings);
11925        } catch (error) {
11926          settings = {};
11927        }
11928        return settings || {};
11929      }
11930
11931      /**
11932       * @static
11933       * @type {string}
11934       */
11935    }, {
11936      key: "NAME",
11937      get: function get() {
11938        return "SettingsController";
11939      }
11940    }]);
11941    return SettingsController;
11942  }(Controller);
11943
11944  var EventController = /*#__PURE__*/function (_Controller) {
11945    babelHelpers.inherits(EventController, _Controller);
11946    /**
11947     * The EventController class.
11948     *
11949     * @param {string} name
11950     * @param {Object} viewComponent
11951     * @constructor
11952     * @private
11953     * @extends {amp.player.controller.Controller}
11954     */
11955    function EventController(name, viewComponent) {
11956      babelHelpers.classCallCheck(this, EventController);
11957      return _Controller.call(this, EventController.NAME, viewComponent) || this;
11958    }
11959
11960    /**
11961     * @static
11962     * @type {string}
11963     */
11964    babelHelpers.createClass(EventController, [{
11965      key: "dispatchEvent",
11966      value:
11967      /**
11968       *
11969       */
11970      function dispatchEvent(type, detail) {
11971        this.facade.dispatch(type, detail);
11972      }
11973
11974      /** @override */
11975    }, {
11976      key: "listNotificationInterests",
11977      value: function listNotificationInterests() {
11978        return Object.values(Events).concat(Object.values(AuthEvents)).concat([Notifications.ENABLE_VIDEO_EVENTS, Notifications.DISABLE_VIDEO_EVENTS]);
11979      }
11980
11981      /**
11982       * Handles notifications of interest to this mediator.
11983       *
11984       * @param note An INotification
11985       * @override
11986       */
11987    }, {
11988      key: "handleNotification",
11989      value: function handleNotification(notification) {
11990        var name = notification.getName();
11991        if (this[name] != null) {
11992          babelHelpers.get(babelHelpers.getPrototypeOf(EventController.prototype), "handleNotification", this).call(this, notification);
11993        } else {
11994          this.dispatchEvent(name, notification.getBody());
11995        }
11996      }
11997
11998      /** */
11999    }, {
12000      key: "error",
12001      value: function error() {}
12002
12003      /** */
12004    }, {
12005      key: "enablevideoevents",
12006      value: function enablevideoevents(events) {
12007        var _this = this;
12008        var video = this.facade.getMediaElement();
12009        events.forEach(function (event) {
12010          return video.addEventListener(event, _this.playback.handlers[event]);
12011        });
12012      }
12013
12014      /** */
12015    }, {
12016      key: "disablevideoevents",
12017      value: function disablevideoevents(events) {
12018        var _this2 = this;
12019        var video = this.facade.getMediaElement();
12020        events.forEach(function (event) {
12021          return video.removeEventListener(event, _this2.playback.handlers[event]);
12022        });
12023      }
12024    }], [{
12025      key: "NAME",
12026      get: function get() {
12027        return "EventController";
12028      }
12029    }]);
12030    return EventController;
12031  }(Controller);
12032
12033  var Player = /*#__PURE__*/function (_Module) {
12034    babelHelpers.inherits(Player, _Module);
12035    /**
12036     * The base player class.
12037     *
12038     * @param {Object} config
12039     * @param {Object} viewComponent
12040     * @constructor
12041     * @private
12042     * @extends {Module}
12043     */
12044    function Player(viewComponent) {
12045      var _this;
12046      babelHelpers.classCallCheck(this, Player);
12047      _this = _Module.call(this, viewComponent) || this;
12048      _this.ads = EventDispatcher.create();
12049      _this.ads.enabled = false;
12050      _this.ads.getEnabled = function () {
12051        return false;
12052      };
12053      _this.ads.inprogress = false;
12054      _this.ads.getInProgress = function () {
12055        return false;
12056      };
12057      _this.loadResources = _this.loadModuleResources.bind(babelHelpers.assertThisInitialized(_this));
12058      _this.presentationModeChanged = _this.presentationModeChanged.bind(babelHelpers.assertThisInitialized(_this));
12059      _this.moduleName = "amp";
12060      _this.l10n = null;
12061      _this.appState = null;
12062      _this.mediaProxy = null;
12063      _this.bindings = null;
12064      _this.configuration = null;
12065      _this.security = null;
12066      _this.playerCore = null;
12067      _this.tracks = null;
12068      _this.mediator = null;
12069      return _this;
12070    }
12071
12072    /** */
12073    babelHelpers.createClass(Player, [{
12074      key: "createModel",
12075      value: function createModel() {
12076        this.appState = new ApplicationStateProxy();
12077        this.registerProxy(this.appState);
12078        this.security = new SecurityProxy();
12079        this.registerProxy(this.security);
12080        this.mediaProxy = new MediaProxy(this.config);
12081        this.registerProxy(this.mediaProxy);
12082        this.configuration = new ConfigurationProxy(this.config);
12083        this.registerProxy(this.configuration);
12084        this.localization = new LocalizationProxy(this.config);
12085        this.registerProxy(this.localization);
12086        var playbackProxy = new PlaybackCoreProxy();
12087        this.registerProxy(playbackProxy);
12088        this.playerCore = new PlayerProxy(playbackProxy, this.config);
12089        this.registerProxy(this.playerCore);
12090        this.tracks = new TracksProxy();
12091        this.registerProxy(this.tracks);
12092        this.fps = Utils.override(FPS, this.config.fps);
12093      }
12094
12095      /** @override */
12096    }, {
12097      key: "createView",
12098      value: function createView() {
12099        // Register the ApplicationMediator passing the Application instance to its constructor.
12100        this.mediator = new PlayerMediator("html5", this.getViewComponent());
12101        this.registerMediator(this.mediator);
12102        this.registerMediator(new VideoLayerMediator());
12103
12104        // Create the overlay container
12105        this.registerMediator(new OverlayLayerMediator());
12106
12107        // // Create the ad container
12108        this.adMediator = new AdContainerMediator();
12109        this.registerMediator(this.adMediator);
12110      }
12111
12112      /** @override */
12113    }, {
12114      key: "createController",
12115      value: function createController() {
12116        babelHelpers.get(babelHelpers.getPrototypeOf(Player.prototype), "createController", this).call(this);
12117        this.registerMediator(new CoreController());
12118        this.registerMediator(new PlayerController());
12119        this.registerMediator(new StateController());
12120        this.registerMediator(new PluginsController());
12121        this.registerMediator(new MediaController());
12122        this.registerMediator(new PlaybackController());
12123        this.registerMediator(new TimeController());
12124        this.registerMediator(new VolumeController());
12125        this.registerMediator(new EventController());
12126        this._settings = new SettingsController();
12127        this.registerMediator(this._settings);
12128      }
12129
12130      /** @override */
12131    }, {
12132      key: "dispatchEvent",
12133      value: function dispatchEvent(event) {
12134        event.player = this;
12135        babelHelpers.get(babelHelpers.getPrototypeOf(Player.prototype), "dispatchEvent", this).call(this, event);
12136      }
12137
12138      /** @override */
12139    }, {
12140      key: "setViewComponent",
12141      value: function setViewComponent(viewComponent) {
12142        viewComponent["amp"] = this;
12143        return babelHelpers.get(babelHelpers.getPrototypeOf(Player.prototype), "setViewComponent", this).call(this, viewComponent);
12144      }
12145
12146      /** */
12147    }, {
12148      key: "getPlayer",
12149      value: function getPlayer() {
12150        return this._player;
12151      }
12152    }, {
12153      key: "setPlayer",
12154      value: function setPlayer(value) {
12155        this._player = value;
12156      }
12157    }, {
12158      key: "player",
12159      get: function get() {
12160        return this.getPlayer();
12161      },
12162      set: function set(value) {
12163        this.setPlayer(value);
12164      }
12165
12166      /** */
12167    }, {
12168      key: "now",
12169      get: function get() {
12170        return Date.now();
12171      }
12172
12173      /** */
12174    }, {
12175      key: "paths",
12176      get: function get() {
12177        return this.configuration.getPaths();
12178      }
12179
12180      /** */
12181    }, {
12182      key: "timers",
12183      get: function get() {
12184        return Utils.timerGroup(this.multitonKey);
12185      }
12186
12187      /** */
12188    }, {
12189      key: "autoplayPolicy",
12190      get: function get() {
12191        return this.configuration.getAutoplayPolicy();
12192      }
12193
12194      /** */
12195    }, {
12196      key: "autoplayThreshold",
12197      get: function get() {
12198        return AutoplayThreshold.threshold;
12199      }
12200
12201      /** */
12202    }, {
12203      key: "temporalType",
12204      get: function get() {
12205        return this.mediaProxy.getTemporalType();
12206      }
12207
12208      /** */
12209    }, {
12210      key: "isLive",
12211      get: function get() {
12212        return this.mediaProxy.getIsLive();
12213      }
12214
12215      /** */
12216    }, {
12217      key: "textTracks",
12218      get: function get() {
12219        return this.getMediaElement().textTracks;
12220      }
12221
12222      /** */
12223    }, {
12224      key: "defaultMediaTransform",
12225      get: function get() {
12226        return this.mediaProxy.applyDefaults;
12227      }
12228
12229      /** */
12230    }, {
12231      key: "getPID",
12232      value: function getPID() {
12233        return AMP.LICENSE || this.config.pid;
12234      }
12235    }, {
12236      key: "pid",
12237      get: function get() {
12238        return this.getPID();
12239      }
12240
12241      /** */
12242    }, {
12243      key: "getVersion",
12244      value: function getVersion() {
12245        return AMP.getVersion();
12246      }
12247    }, {
12248      key: "version",
12249      get: function get() {
12250        return this.getVersion();
12251      }
12252
12253      /** */
12254    }, {
12255      key: "getDebug",
12256      value: function getDebug() {
12257        return this.config.debug;
12258      }
12259    }, {
12260      key: "debug",
12261      get: function get() {
12262        return this.getDebug();
12263      }
12264
12265      /** */
12266    }, {
12267      key: "createPlugins",
12268      value: function createPlugins() {
12269        this.sendNotification(PluginNotifications.REGISTER_PLUGINS, this.config);
12270      }
12271
12272      /** */
12273    }, {
12274      key: "createMediaElement",
12275      value: function createMediaElement() {
12276        var view = this.getViewComponent() || {};
12277        var element = (typeof view.querySelector === "function" ? view.querySelector("video") : null) || "video";
12278        this.mediator = new MediaElementMediator("html5", element);
12279        this.sendNotification(Notifications.PLAYBACK_CORE_CHANGE, this.mediator);
12280        var viewComponent = this.mediator.getViewComponent();
12281        if (viewComponent.dataset == null) {
12282          viewComponent.dataset = {};
12283        }
12284        return viewComponent;
12285      }
12286
12287      /** @override */
12288    }, {
12289      key: "createFramework",
12290      value: function createFramework() {
12291        babelHelpers.get(babelHelpers.getPrototypeOf(Player.prototype), "createFramework", this).call(this);
12292        this.setMediaElement(this.createMediaElement());
12293        this.createPlugins();
12294      }
12295
12296      /**
12297      */
12298    }, {
12299      key: "getLanguage",
12300      value: function getLanguage() {
12301        return this.localization.getLanguage();
12302      }
12303    }, {
12304      key: "language",
12305      get: function get() {
12306        return this.getLanguage();
12307      }
12308
12309      /**
12310      */,
12311      set: function set(value) {
12312        return this.setLanguage(value);
12313      }
12314
12315      /**
12316      */
12317    }, {
12318      key: "setLanguage",
12319      value: function setLanguage(value) {
12320        this.localization.setLanguage(value);
12321        return value;
12322      }
12323    }, {
12324      key: "getLocalizedString",
12325      value: function getLocalizedString(value, context) {
12326        try {
12327          return this.localization.getString(value, context);
12328        } catch (error) {
12329          return value;
12330        }
12331      }
12332
12333      /**
12334       * @return {HTMLObject|HTMLMediaElement} The media playback DOM element.
12335       */
12336    }, {
12337      key: "getMediaElement",
12338      value: function getMediaElement() {
12339        return this.appState.getMediaElement();
12340      }
12341    }, {
12342      key: "mediaElement",
12343      get: function get() {
12344        return this.getMediaElement();
12345      }
12346
12347      /** */
12348    }, {
12349      key: "setMediaElement",
12350      value: function setMediaElement(value) {
12351        var mediaElement = this.getMediaElement();
12352        if (mediaElement != null) {
12353          mediaElement.removeEventListener("webkitpresentationmodechanged", this.presentationModeChanged);
12354        }
12355        value.addEventListener("webkitpresentationmodechanged", this.presentationModeChanged);
12356        this.appState.setMediaElement(value);
12357        if (value.once == null) {
12358          value.once = function (type, listener) {
12359            var id = Utils.createUID();
12360            var handler = function handler(id, type, listener, event) {
12361              this.removeEventListener(type, this[id]);
12362              delete this[id];
12363              listener(event);
12364            };
12365            this[id] = handler.bind(this, id, type, listener);
12366            this.addEventListener(type, this[id]);
12367            return id;
12368          };
12369          value.once = value.once.bind(value);
12370        }
12371        value.amp = this;
12372        return value;
12373      }
12374
12375      /**
12376       * HACK: Fix for iOS 10 manipulating controls property incorrectly after leaving fullscreen
12377       */
12378    }, {
12379      key: "presentationModeChanged",
12380      value: function presentationModeChanged(event) {
12381        if ("inline" === event.target.webkitPresentationMode) {
12382          event.target.controls = this.getControls();
12383        }
12384      }
12385
12386      /**
12387       * @return {boolean}
12388       */
12389    }, {
12390      key: "setControls",
12391      value: function setControls(value) {
12392        return this.sendNotification(Notifications.CHANGE_CONTROLS, value);
12393      }
12394    }, {
12395      key: "controls",
12396      get: function get() {
12397        return this.getControls();
12398      }
12399
12400      /**
12401       * @return {HTMLElement} The container div.
12402       */,
12403      set: function set(value) {
12404        return this.setControls(value);
12405      }
12406
12407      /**
12408       *
12409       */
12410    }, {
12411      key: "getControls",
12412      value: function getControls() {
12413        return this.configuration.getControls();
12414      }
12415    }, {
12416      key: "getContainer",
12417      value: function getContainer() {
12418        return this.getViewComponent();
12419      }
12420    }, {
12421      key: "container",
12422      get: function get() {
12423        return this.getContainer();
12424      }
12425
12426      /**
12427       *
12428       */
12429    }, {
12430      key: "getAdContainer",
12431      value: function getAdContainer() {
12432        return this.adMediator.getContainer();
12433      }
12434    }, {
12435      key: "adContainer",
12436      get: function get() {
12437        return this.getAdContainer();
12438      }
12439
12440      /**
12441       *
12442       */,
12443      set: function set(value) {
12444        return this.setAdContainer(value);
12445      }
12446
12447      /**
12448       * @return {ChapterTrack} The chapter track.
12449       */
12450    }, {
12451      key: "setAdContainer",
12452      value: function setAdContainer(value) {
12453        this.adMediator.setContainer(value);
12454      }
12455    }, {
12456      key: "getChapterTracks",
12457      value: function getChapterTracks() {
12458        return this.tracks.getChapterTracks();
12459      }
12460    }, {
12461      key: "chapterTracks",
12462      get: function get() {
12463        return this.getChapterTracks();
12464      }
12465
12466      /**
12467       * @return {PreviewTrack} The preview track.
12468       */
12469    }, {
12470      key: "getPreviewTracks",
12471      value: function getPreviewTracks() {
12472        return this.tracks.getPreviewTracks();
12473      }
12474    }, {
12475      key: "previewTracks",
12476      get: function get() {
12477        return this.getPreviewTracks();
12478      }
12479
12480      /**
12481       * @return {HTMLElement} The container div.
12482       */
12483    }, {
12484      key: "getAudioTracks",
12485      value: function getAudioTracks() {
12486        return this.tracks.getAudioTracks();
12487      }
12488    }, {
12489      key: "audioTracks",
12490      get: function get() {
12491        return this.getAudioTracks();
12492      }
12493
12494      /**
12495       * @param   {Object}  binding
12496       *    A data bound object to evaluate.
12497       *
12498       * @param   {?Object}  context
12499       *    Context object to pass to the bindings
12500       *
12501       * @return {Object}
12502       *    The evaluated result
12503       */
12504    }, {
12505      key: "evaluateBindings",
12506      value: function evaluateBindings(binding, context) {
12507        if (context != null) {
12508          context = Object.assign({}, this, context);
12509        } else {
12510          context = this;
12511        }
12512        return DataBinding.evaluateBindings(binding, context);
12513      }
12514
12515      /**
12516       * Determines if the core can play a given mimeType.
12517       *
12518       * @param   {string}  type
12519       *    The mimetype to check.
12520       *
12521       * @return  {string}  ""
12522       *    if the core can't play the mimeType
12523       */
12524    }, {
12525      key: "canPlayType",
12526      value: function canPlayType(type) {
12527        return this.retrieveProxy(PlaybackProxy.NAME).canPlayType(type);
12528      }
12529
12530      /**
12531       * Loads the video.
12532       */
12533    }, {
12534      key: "load",
12535      value: function load() {
12536        this.sendNotification(Notifications.LOAD);
12537      }
12538
12539      /**
12540       * Plays the currently loaded video.
12541       */
12542    }, {
12543      key: "play",
12544      value: function play() {
12545        var _this2 = this;
12546        return new Promise(function (resolve, reject) {
12547          var clear = function clear() {
12548            _this2.removeEventListener(Events.PLAYING, res);
12549            _this2.removeEventListener(Events.AUTOPLAY_BLOCKED, rej);
12550            _this2.removeEventListener(Events.ERROR, rej);
12551          };
12552          var res = function res() {
12553            clear();
12554            resolve();
12555          };
12556          var rej = function rej() {
12557            clear();
12558            reject();
12559          };
12560          _this2.addEventListener(Events.PLAYING, res);
12561          _this2.addEventListener(Events.AUTOPLAY_BLOCKED, rej);
12562          _this2.addEventListener(Events.ERROR, rej);
12563          _this2.sendNotification(Notifications.PLAY, true);
12564        });
12565      }
12566
12567      /**
12568       * Plays the currently loaded video from its start time.
12569       */
12570    }, {
12571      key: "replay",
12572      value: function replay() {
12573        this.sendNotification(Notifications.REPLAY);
12574      }
12575
12576      /**
12577       * Pauses the currently loaded video.
12578       */
12579    }, {
12580      key: "pause",
12581      value: function pause() {
12582        var _this3 = this;
12583        return new Promise(function (resolve, reject) {
12584          _this3.once(Events.PAUSED, resolve);
12585          return _this3.sendNotification(Notifications.PAUSE);
12586        });
12587      }
12588
12589      /**
12590       * Sets the current time of the video.
12591       */
12592    }, {
12593      key: "seek",
12594      value: function seek(value) {
12595        var _this4 = this;
12596        return new Promise(function (resolve, reject) {
12597          _this4.once(Events.SEEKED, resolve);
12598          return _this4.setCurrentTime(value);
12599        });
12600      }
12601
12602      /**
12603       * Ends video playback.
12604       */
12605    }, {
12606      key: "end",
12607      value: function end() {
12608        var _this5 = this;
12609        return new Promise(function (resolve) {
12610          _this5.once(Events.ENDED, resolve);
12611          return _this5.sendNotification(Notifications.END);
12612        });
12613      }
12614
12615      /**
12616       * Sets auto play flag.
12617       *
12618       * @param {boolean} value The autoplay flag.
12619       */
12620    }, {
12621      key: "setAutoplay",
12622      value: function setAutoplay(value) {
12623        this.sendNotification(Notifications.CHANGE_AUTOPLAY, value);
12624        return value;
12625      }
12626    }, {
12627      key: "autoplay",
12628      get: function get() {
12629        return this.getAutoplay();
12630      }
12631
12632      /**
12633       * Sets preload value.
12634       *
12635       * @param {string} value The preload value.
12636       */,
12637      set: function set(value) {
12638        return this.setAutoplay(value);
12639      }
12640
12641      /**
12642       * Gets auto play flag.
12643       *
12644       * @return {boolean} The autoplay flag.
12645       */
12646    }, {
12647      key: "getAutoplay",
12648      value: function getAutoplay() {
12649        return this.configuration.getAutoplay();
12650      }
12651    }, {
12652      key: "setPreload",
12653      value: function setPreload(value) {
12654        this.sendNotification(Notifications.CHANGE_PRELOAD, value);
12655        return value;
12656      }
12657    }, {
12658      key: "preload",
12659      get: function get() {
12660        return this.getPreload();
12661      }
12662
12663      /**
12664       * Sets player's loop flag.
12665       *
12666       * @param {boolean} value The loop flag.
12667       */,
12668      set: function set(value) {
12669        return this.setPreload(value);
12670      }
12671
12672      /**
12673       * Gets preload value.
12674       *
12675       * @return {boolean} The preload value.
12676       */
12677    }, {
12678      key: "getPreload",
12679      value: function getPreload() {
12680        return this.configuration.getPreload();
12681      }
12682    }, {
12683      key: "setLoop",
12684      value: function setLoop(value) {
12685        this.sendNotification(Notifications.CHANGE_LOOP, value);
12686        return value;
12687      }
12688    }, {
12689      key: "loop",
12690      get: function get() {
12691        return this.getLoop();
12692      }
12693
12694      /**
12695       * Sets player's muted value.
12696       *
12697       * @param {boolean} value The muted value.
12698       */,
12699      set: function set(value) {
12700        return this.setLoop(value);
12701      }
12702
12703      /**
12704       * Gets player's loop flag.
12705       *
12706       * @return {boolean} The loop flag.
12707       */
12708    }, {
12709      key: "getLoop",
12710      value: function getLoop() {
12711        return this.configuration.getLoop();
12712      }
12713    }, {
12714      key: "setMuted",
12715      value: function setMuted(value) {
12716        this.sendNotification(Notifications.CHANGE_MUTED, value);
12717        return value;
12718      }
12719    }, {
12720      key: "muted",
12721      get: function get() {
12722        return this.getMuted();
12723      }
12724
12725      /**
12726       * Mutes the player.
12727       */,
12728      set: function set(value) {
12729        return this.setMuted(value);
12730      }
12731
12732      /**
12733       * Gets player's muted value.
12734       *
12735       * @return {boolean} The muted value.
12736       */
12737    }, {
12738      key: "getMuted",
12739      value: function getMuted() {
12740        return this.retrieveProxy(PlaybackProxy.NAME).getMuted();
12741      }
12742    }, {
12743      key: "mute",
12744      value: function mute() {
12745        return this.setMuted(true);
12746      }
12747
12748      /**
12749       * Unmutes the player.
12750       */
12751    }, {
12752      key: "unmute",
12753      value: function unmute() {
12754        return this.setMuted(false);
12755      }
12756
12757      /**
12758       * Sets the media object.
12759       *
12760       * @param {Object} value The media object for the video to play.
12761       */
12762    }, {
12763      key: "setMedia",
12764      value: function setMedia(value) {
12765        this.sendNotification(Notifications.SET_MEDIA, value);
12766        return value;
12767      }
12768    }, {
12769      key: "media",
12770      get: function get() {
12771        return this.getMedia();
12772      }
12773
12774      /**
12775       * Sets the current time of the video.
12776       *
12777       * @param {number} value The desired time to seek to.
12778       */,
12779      set: function set(value) {
12780        return this.setMedia(value);
12781      }
12782
12783      /**
12784       * Gets the media object.
12785       *
12786       * @return {Object} The media object for the video to play.
12787       */
12788    }, {
12789      key: "getMedia",
12790      value: function getMedia() {
12791        return this.mediaProxy.getData();
12792      }
12793    }, {
12794      key: "setCurrentTime",
12795      value: function setCurrentTime(value) {
12796        this.sendNotification(Notifications.SEEK, value);
12797        return value;
12798      }
12799    }, {
12800      key: "currentTime",
12801      get: function get() {
12802        return this.getCurrentTime();
12803      }
12804
12805      /**
12806       * Sets the current time of the video.
12807       *
12808       * @param {number} value The desired time to seek to.
12809       */,
12810      set: function set(value) {
12811        return this.setCurrentTime(value);
12812      }
12813
12814      /**
12815       * Gets the current time of the video.
12816       *
12817       * @return {number} The current playhead time.
12818       */
12819    }, {
12820      key: "getCurrentTime",
12821      value: function getCurrentTime() {
12822        return this.appState.getCurrentTime();
12823      }
12824    }, {
12825      key: "setAbsoluteCurrentTime",
12826      value: function setAbsoluteCurrentTime(value) {
12827        this.sendNotification(Notifications.SEEK, value);
12828        return value;
12829      }
12830    }, {
12831      key: "absoluteCurrentTime",
12832      get: function get() {
12833        return this.getAbsoluteCurrentTime();
12834      }
12835
12836      /** */,
12837      set: function set(value) {
12838        return this.setAbsoluteCurrentTime(value);
12839      }
12840
12841      /**
12842       * Gets the current time of the video.
12843       *
12844       * @return {number} The current playhead time.
12845       */
12846    }, {
12847      key: "getAbsoluteCurrentTime",
12848      value: function getAbsoluteCurrentTime() {
12849        return this.retrieveProxy(PlaybackProxy.NAME).getCurrentTime();
12850      }
12851    }, {
12852      key: "toUTC",
12853      value: function toUTC(value) {
12854        return this.retrieveProxy(PlaybackProxy.NAME).toUTC(value);
12855      }
12856
12857      /** */
12858    }, {
12859      key: "fromUTC",
12860      value: function fromUTC(value) {
12861        return this.retrieveProxy(PlaybackProxy.NAME).fromUTC(value);
12862      }
12863
12864      /**
12865       * Gets the current time of the video.
12866       *
12867       * @return {number} The current time of the video.
12868       */
12869    }, {
12870      key: "getDuration",
12871      value: function getDuration() {
12872        return this.appState.getDuration();
12873      }
12874    }, {
12875      key: "duration",
12876      get: function get() {
12877        return this.getDuration();
12878      }
12879
12880      /**
12881       * Gets the current time of the video.
12882       *
12883       * @return {number} The current time of the video.
12884       */
12885    }, {
12886      key: "getAbsoluteDuration",
12887      value: function getAbsoluteDuration() {
12888        return this.mediaProxy.getDuration();
12889      }
12890    }, {
12891      key: "absoluteDuration",
12892      get: function get() {
12893        return this.getAbsoluteDuration();
12894      }
12895
12896      /**
12897       * Sets the source url of video.
12898       *
12899       * @param {string} value The source url of the video to play.
12900       */
12901    }, {
12902      key: "setSrc",
12903      value: function setSrc(value) {
12904        this.sendNotification(Notifications.SET_MEDIA, {
12905          src: value
12906        });
12907        return value;
12908      }
12909    }, {
12910      key: "src",
12911      get: function get() {
12912        return this.getSrc();
12913      }
12914
12915      /**
12916       * Sets the source url of video.
12917       *
12918       * @param {Array.<Object>} value An array of source objects to choose from.
12919       */,
12920      set: function set(value) {
12921        return this.setSrc(value);
12922      }
12923
12924      /**
12925       * Gets the source url of video.
12926       *
12927       * @return {string} The source url of the video to play.
12928       */
12929    }, {
12930      key: "getSrc",
12931      value: function getSrc() {
12932        return this.mediaProxy.getSrc();
12933      }
12934    }, {
12935      key: "setSource",
12936      value: function setSource(value) {
12937        this.sendNotification(Notifications.SET_MEDIA, {
12938          source: value
12939        });
12940        return value;
12941      }
12942
12943      /**
12944       * Gets the source url of video.
12945       *
12946       * @return {Array.<Object>} An array of source objects to choose from.
12947       */
12948    }, {
12949      key: "getSource",
12950      value: function getSource() {
12951        return this.mediaProxy.getSource();
12952      }
12953
12954      /**
12955       * Sets the source url of video.
12956       *
12957       * @param {number} value The source url of the video to play.
12958       */
12959    }, {
12960      key: "setVolume",
12961      value: function setVolume(value) {
12962        this.sendNotification(Notifications.CHANGE_VOLUME, value);
12963        return value;
12964      }
12965    }, {
12966      key: "volume",
12967      get: function get() {
12968        return this.getVolume();
12969      }
12970
12971      /**
12972       * The seeking flag.
12973       *
12974       * @return {boolean} The seeking flag.
12975       */,
12976      set: function set(value) {
12977        return this.setVolume(value);
12978      }
12979
12980      /**
12981       * Gets the source url of video.
12982       *
12983       * @return {number} The volume a number between 0 and 1.
12984       */
12985    }, {
12986      key: "getVolume",
12987      value: function getVolume() {
12988        return this.retrieveProxy(PlaybackProxy.NAME).getVolume();
12989      }
12990    }, {
12991      key: "getSeeking",
12992      value: function getSeeking() {
12993        return this.retrieveProxy(PlaybackProxy.NAME).getSeeking();
12994      }
12995    }, {
12996      key: "seeking",
12997      get: function get() {
12998        return this.getSeeking();
12999      }
13000
13001      /**
13002       * The paused flag.
13003       *
13004       * @return {boolean} The paused flag.
13005       */
13006    }, {
13007      key: "getPaused",
13008      value: function getPaused() {
13009        return this.retrieveProxy(PlaybackProxy.NAME).getPaused();
13010      }
13011    }, {
13012      key: "paused",
13013      get: function get() {
13014        return this.getPaused();
13015      }
13016
13017      /**
13018       * The ended flag.
13019       *
13020       * @return {boolean} The ended flag.
13021       */
13022    }, {
13023      key: "getEnded",
13024      value: function getEnded() {
13025        return this.appState.getEnded();
13026      }
13027    }, {
13028      key: "ended",
13029      get: function get() {
13030        return this.getEnded();
13031      }
13032
13033      /**
13034       * The buffering flag.
13035       *
13036       * @return {boolean} The buffering flag.
13037       */
13038    }, {
13039      key: "getBuffering",
13040      value: function getBuffering() {
13041        return this.appState.getBuffering();
13042      }
13043    }, {
13044      key: "buffering",
13045      get: function get() {
13046        return this.getBuffering();
13047      }
13048
13049      /**
13050       * Sets the player's display state.
13051       *
13052       * @param {DisplayState} value
13053       *    The display state.
13054       */
13055    }, {
13056      key: "setDisplayState",
13057      value: function setDisplayState(value) {
13058        this.sendNotification(Notifications.CHANGE_DISPLAY_STATE, value);
13059      }
13060    }, {
13061      key: "displayState",
13062      get: function get() {
13063        return this.getDisplayState();
13064      }
13065
13066      /**
13067       * Returns the player's waiting state.
13068       *
13069       * @return {boolean}
13070       *    The waiting state.
13071       */,
13072      set: function set(value) {
13073        return this.setDisplayState(value);
13074      }
13075
13076      /**
13077       * Returns the player's display state.
13078       *
13079       * @return {DisplayState}
13080       *    The display state.
13081       */
13082    }, {
13083      key: "getDisplayState",
13084      value: function getDisplayState(value) {
13085        return this.appState.getDisplayState();
13086      }
13087    }, {
13088      key: "getWaiting",
13089      value: function getWaiting() {
13090        return this.appState.getWaiting();
13091      }
13092    }, {
13093      key: "waiting",
13094      get: function get() {
13095        return this.getWaiting();
13096      }
13097
13098      /**
13099       * Sets the player's waiting state.
13100       *
13101       * @param {boolean} value
13102       *    The waiting state.
13103       */,
13104      set: function set(value) {
13105        return this.setWaiting(value);
13106      }
13107
13108      /**
13109       * Returns the player's busy state.
13110       *
13111       * @return {boolean}
13112       *    The busy state.
13113       */
13114    }, {
13115      key: "setWaiting",
13116      value: function setWaiting(value) {
13117        return this.appState.setWaiting(value);
13118      }
13119    }, {
13120      key: "getBusy",
13121      value: function getBusy() {
13122        return this.appState.getBusy();
13123      }
13124    }, {
13125      key: "busy",
13126      get: function get() {
13127        return this.getBusy();
13128      }
13129
13130      /**
13131       * Sets the player's busy state.
13132       *
13133       * @param {boolean} value
13134       *    The busy state.
13135       */,
13136      set: function set(value) {
13137        return this.setBusy(value);
13138      }
13139
13140      /**
13141       * Returns the player error.
13142       *
13143       * @return {Error}
13144       *    The Error
13145       */
13146    }, {
13147      key: "setBusy",
13148      value: function setBusy(value) {
13149        return this.appState.setBusy(value);
13150      }
13151    }, {
13152      key: "getError",
13153      value: function getError() {
13154        return this._error || this.getMediaElement().error;
13155      }
13156    }, {
13157      key: "error",
13158      get: function get() {
13159        return this.getError();
13160      }
13161
13162      /**
13163       * Enters the player into full screen mode.
13164       */
13165    }, {
13166      key: "enterFullScreen",
13167      value: function enterFullScreen() {
13168        this.sendNotification(Notifications.CHANGE_DISPLAY_STATE, DisplayState.FULL_SCREEN);
13169      }
13170
13171      /**
13172       * Exits the player out of full screen mode.
13173       */
13174    }, {
13175      key: "exitFullScreen",
13176      value: function exitFullScreen() {
13177        this.sendNotification(Notifications.CHANGE_DISPLAY_STATE, DisplayState.NORMAL);
13178      }
13179
13180      /**
13181       * Enters the player into picture in picture mode.
13182       */
13183    }, {
13184      key: "enterPictureInPicture",
13185      value: function enterPictureInPicture() {
13186        this.sendNotification(Notifications.CHANGE_DISPLAY_STATE, DisplayState.PICTURE_IN_PICTURE);
13187      }
13188
13189      /**
13190       * Exits the player out of picture in picture mode.
13191       */
13192    }, {
13193      key: "exitPictureInPicture",
13194      value: function exitPictureInPicture() {
13195        this.sendNotification(Notifications.CHANGE_DISPLAY_STATE, DisplayState.NORMAL);
13196      }
13197
13198      /**
13199       * Show the player
13200       */
13201    }, {
13202      key: "setHidden",
13203      value: function setHidden(value) {
13204        if (value === this.appState.getHidden()) {
13205          return;
13206        }
13207        this.appState.setHidden(value);
13208        var style = this.viewComponent.style;
13209        if (value === true) {
13210          this.hiddenData = {
13211            width: style.width,
13212            height: style.height,
13213            paused: this.getPaused()
13214          };
13215          style.width = style.height = "0px";
13216          if (this.hiddenData.paused === false) {
13217            this.pause();
13218          }
13219        } else {
13220          style.width = this.hiddenData.width;
13221          style.height = this.hiddenData.height;
13222          if (this.hiddenData.paused === false) {
13223            this.play();
13224          }
13225          this.hiddenData = null;
13226        }
13227      }
13228    }, {
13229      key: "hidden",
13230      get: function get() {
13231        return this.getHidden();
13232      }
13233
13234      /**
13235       * The player's width
13236       */,
13237      set: function set(value) {
13238        return this.setHidden(value);
13239      }
13240
13241      /**
13242       * Hide the player
13243       */
13244    }, {
13245      key: "getHidden",
13246      value: function getHidden() {
13247        return this.appState.getHidden();
13248      }
13249    }, {
13250      key: "getWidth",
13251      value: function getWidth() {
13252        var view = this.getViewComponent() || {};
13253        return view.offsetWidth;
13254      }
13255    }, {
13256      key: "width",
13257      get: function get() {
13258        return this.getWidth();
13259      }
13260
13261      /**
13262       * The player's height
13263       */
13264    }, {
13265      key: "getHeight",
13266      value: function getHeight() {
13267        var view = this.getViewComponent() || {};
13268        return view.offsetHeight;
13269      }
13270    }, {
13271      key: "height",
13272      get: function get() {
13273        return this.getHeight();
13274      }
13275
13276      /**
13277       * The media's source width
13278       */
13279    }, {
13280      key: "getVideoWidth",
13281      value: function getVideoWidth() {
13282        var element = this.getMediaElement() || {};
13283        return element.videoWidth;
13284      }
13285    }, {
13286      key: "videoWidth",
13287      get: function get() {
13288        return this.getVideoWidth();
13289      }
13290
13291      /**
13292       * The media's source height
13293       */
13294    }, {
13295      key: "getVideoHeight",
13296      value: function getVideoHeight() {
13297        var element = this.getMediaElement() || {};
13298        return element.videoHeight;
13299      }
13300    }, {
13301      key: "videoHeight",
13302      get: function get() {
13303        return this.getVideoHeight();
13304      }
13305
13306      /**
13307       * The player's left position
13308       */
13309    }, {
13310      key: "getLeft",
13311      value: function getLeft() {
13312        var view = this.getViewComponent() || {};
13313        return view.offsetLeft;
13314      }
13315    }, {
13316      key: "left",
13317      get: function get() {
13318        return this.getLeft();
13319      }
13320
13321      /**
13322       * The player's right position
13323       */
13324    }, {
13325      key: "getRight",
13326      value: function getRight() {
13327        return this.getLeft() + this.getWidth();
13328      }
13329    }, {
13330      key: "right",
13331      get: function get() {
13332        return this.getRight();
13333      }
13334
13335      /**
13336       * The player's top position
13337       */
13338    }, {
13339      key: "getTop",
13340      value: function getTop() {
13341        var view = this.getViewComponent() || {};
13342        return view.offsetTop;
13343      }
13344    }, {
13345      key: "top",
13346      get: function get() {
13347        return this.getTop();
13348      }
13349
13350      /**
13351       * The player's bottom position
13352       */
13353    }, {
13354      key: "getBottom",
13355      value: function getBottom() {
13356        return this.getTop() + this.getHeight();
13357      }
13358    }, {
13359      key: "bottom",
13360      get: function get() {
13361        return this.getBottom();
13362      }
13363
13364      /**
13365       * The player's width
13366       */
13367    }, {
13368      key: "getMouseX",
13369      value: function getMouseX() {
13370        return Utils.clientX - this.getLeft();
13371      }
13372    }, {
13373      key: "mouseX",
13374      get: function get() {
13375        return this.getMouseX();
13376      }
13377
13378      /**
13379       * The player's width
13380       */
13381    }, {
13382      key: "getMouseY",
13383      value: function getMouseY() {
13384        return Utils.clientY - this.getTop();
13385      }
13386    }, {
13387      key: "mouseY",
13388      get: function get() {
13389        return this.getMouseY();
13390      }
13391
13392      /**
13393       * The player's width
13394       */
13395    }, {
13396      key: "getMouseOver",
13397      value: function getMouseOver() {
13398        var mouseX = this.getMouseX();
13399        var mouseY = this.getMouseY();
13400        var isMouseInX = mouseX >= 0 && mouseX <= this.right && mouseX >= this.left;
13401        var isMouseInY = mouseY >= 0 && mouseY <= this.top && mouseY >= this.bottom;
13402        return Utils.isMouseOverDocument() && isMouseInX && isMouseInY;
13403      }
13404    }, {
13405      key: "mouseOver",
13406      get: function get() {
13407        return this.getMouseOver();
13408      }
13409
13410      /**
13411       * Records a content change
13412       *
13413       * @param {Object} content
13414       *    An object representing the new content
13415       */
13416    }, {
13417      key: "recordContentChange",
13418      value: function recordContentChange(content) {
13419        this.sendNotification(Notifications.RECORD_CONTENT_CHANGE, content);
13420      }
13421
13422      /**
13423       * Sets the rate of playback.
13424       */
13425    }, {
13426      key: "setPlaybackRate",
13427      value: function setPlaybackRate(value) {
13428        if (this.ads.inProgress === true || value === this.getMediaElement().playbackRate) {
13429          return;
13430        }
13431        this.appState.setPlaybackRate(value);
13432        this.getMediaElement().playbackRate = value;
13433      }
13434    }, {
13435      key: "playbackRate",
13436      get: function get() {
13437        return this.getPlaybackRate();
13438      }
13439
13440      /**
13441       * Sets the list of cues.
13442       */,
13443      set: function set(value) {
13444        return this.setPlaybackRate(value);
13445      }
13446
13447      /**
13448       * Gets the rate of playback.
13449       */
13450    }, {
13451      key: "getPlaybackRate",
13452      value: function getPlaybackRate() {
13453        return this.getMediaElement().playbackRate;
13454      }
13455    }, {
13456      key: "setCues",
13457      value: function setCues(value) {
13458        this.mediaProxy.setCues(value);
13459        return value;
13460      }
13461    }, {
13462      key: "cues",
13463      get: function get() {
13464        return this.getCues();
13465      },
13466      set: function set(value) {
13467        return this.setCues(value);
13468      }
13469
13470      /**
13471       * Gets the list of cues.
13472       */
13473    }, {
13474      key: "getCues",
13475      value: function getCues() {
13476        return this.mediaProxy.getCues();
13477      }
13478    }, {
13479      key: "maxBitrate",
13480      get: function get() {
13481        return this.getMaxBitrate();
13482      }
13483
13484      /**
13485        * The maximum bitrate selectable by the ABR algorithms will choose. Use -1 for no limit. 
13486       */,
13487      set: function set(value) {
13488        return this.setMaxBitrate(value);
13489      }
13490
13491      /**
13492        * The maximum bitrate selectable by the ABR algorithms will choose. Use -1 for no limit. 
13493       */
13494    }, {
13495      key: "setMaxBitrate",
13496      value: function setMaxBitrate(value) {
13497        return this.retrieveProxy(PlaybackProxy.NAME).setMaxBitrate(value);
13498      }
13499    }, {
13500      key: "getMaxBitrate",
13501      value: function getMaxBitrate(value) {
13502        return this.retrieveProxy(PlaybackProxy.NAME).getMaxBitrate(value);
13503      }
13504
13505      /**
13506       *
13507       */
13508    }, {
13509      key: "setQuality",
13510      value: function setQuality(value) {
13511        return this.retrieveProxy(PlaybackProxy.NAME).setQuality(value);
13512      }
13513    }, {
13514      key: "quality",
13515      get: function get() {
13516        return this.getQuality();
13517      }
13518
13519      /**
13520       *
13521       */,
13522      set: function set(value) {
13523        return this.setQuality(value);
13524      }
13525
13526      /**
13527       *
13528       */
13529    }, {
13530      key: "getQuality",
13531      value: function getQuality() {
13532        return this.retrieveProxy(PlaybackProxy.NAME).getQuality();
13533      }
13534    }, {
13535      key: "getQualityLevels",
13536      value: function getQualityLevels() {
13537        return this.retrieveProxy(PlaybackProxy.NAME).getQualityLevels();
13538      }
13539    }, {
13540      key: "qualityLevels",
13541      get: function get() {
13542        return this.getQualityLevels();
13543      }
13544
13545      /**
13546       *
13547       */
13548    }, {
13549      key: "getQualityMode",
13550      value: function getQualityMode() {
13551        return this.retrieveProxy(PlaybackProxy.NAME).getQualityMode();
13552      }
13553    }, {
13554      key: "qualityMode",
13555      get: function get() {
13556        return this.getQualityMode();
13557      }
13558
13559      /**
13560       *
13561       */,
13562      set: function set(value) {
13563        return this.setQualityMode(value);
13564      }
13565
13566      /**
13567       * @deprecated use setMaxBitrate instead
13568       */
13569    }, {
13570      key: "setQualityMode",
13571      value: function setQualityMode(value) {
13572        return this.retrieveProxy(PlaybackProxy.NAME).setQualityMode(value);
13573      }
13574    }, {
13575      key: "setMaxQualityLevel",
13576      value: function setMaxQualityLevel(value) {
13577        this.logger.warn("[AMP] Deprecation warning, setMaxQualityLevel is deprecated; use setMaxBitrate instead.");
13578        return this.retrieveProxy(PlaybackProxy.NAME).setMaxQualityLevel(value);
13579      }
13580    }, {
13581      key: "maxQualityLevel",
13582      get: function get() {
13583        return this.getMaxQualityLevel();
13584      }
13585
13586      /**
13587       * Gets the play state.
13588       */,
13589      set: function set(value) {
13590        return this.setMaxQualityLevel(value);
13591      }
13592
13593      /**
13594       * 
13595       */
13596    }, {
13597      key: "getMaxQualityLevel",
13598      value: function getMaxQualityLevel() {
13599        return this.retrieveProxy(PlaybackProxy.NAME).getMaxQualityLevel();
13600      }
13601    }, {
13602      key: "getPlayState",
13603      value: function getPlayState() {
13604        return this.appState.getPlayState();
13605      }
13606    }, {
13607      key: "playState",
13608      get: function get() {
13609        return this.getPlayState();
13610      }
13611
13612      /**
13613       *
13614       */
13615    }, {
13616      key: "getPlaybackTarget",
13617      value: function getPlaybackTarget() {
13618        return this.appState.getPlaybackTarget();
13619      }
13620    }, {
13621      key: "playbackTarget",
13622      get: function get() {
13623        return this.getPlaybackTarget();
13624      }
13625
13626      /**
13627       *
13628       */,
13629      set: function set(value) {
13630        this.setPlaybackTarget(value);
13631      }
13632
13633      /**
13634       * Gets the list of media transforms
13635       */
13636    }, {
13637      key: "setPlaybackTarget",
13638      value: function setPlaybackTarget(value) {
13639        this.appState.setPlaybackTarget(value);
13640      }
13641    }, {
13642      key: "getMediaTransforms",
13643      value: function getMediaTransforms() {
13644        return this.mediaProxy.getTransforms();
13645      }
13646
13647      /**
13648       * Authorizes a protected stream
13649       */
13650    }, {
13651      key: "authorize",
13652      value: function authorize(authorization) {
13653        this.security.authorize(authorization);
13654      }
13655
13656      /**
13657       * Force the player into live mode during DVR playback
13658       */
13659    }, {
13660      key: "goLive",
13661      value: function goLive() {
13662        return this.retrieveProxy(PlaybackProxy.NAME).goLive();
13663      }
13664
13665      /**
13666       *
13667       */
13668    }, {
13669      key: "appendChild",
13670      value: function appendChild(element) {
13671        this.mediator.addLayer(element);
13672      }
13673
13674      /**
13675       *
13676       */
13677    }, {
13678      key: "removeChild",
13679      value: function removeChild(element) {
13680        this.mediator.removeLayer(element);
13681      }
13682
13683      /**
13684       *
13685       */
13686    }, {
13687      key: "getSettings",
13688      value: function getSettings() {
13689        return this._settings && this._settings.getSettings() || {
13690          change: function change() {}
13691        };
13692      }
13693    }, {
13694      key: "settings",
13695      get: function get() {
13696        return this.getSettings();
13697      }
13698
13699      /**
13700       *
13701       */
13702    }, {
13703      key: "createMediaError",
13704      value: function createMediaError(code, metadata) {
13705        var message = null;
13706        switch (code) {
13707          case MediaError.MEDIA_ERR_ABORTED:
13708            message = this.l10n.MSG_ERROR_ABORTED;
13709            break;
13710          case MediaError.MEDIA_ERR_DECODE:
13711            message = this.l10n.MSG_ERROR_DECODE;
13712            break;
13713          case MediaError.MEDIA_ERR_NETWORK:
13714            message = this.l10n.MSG_ERROR_NETWORK;
13715            break;
13716          case MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED:
13717            message = this.l10n.MSG_ERROR_SRC;
13718            break;
13719          default:
13720            message = this.l10n.MSG_ERROR_DEFAULT;
13721            break;
13722        }
13723        return AMPError.create(message, code, metadata);
13724      }
13725
13726      /**
13727       * @override
13728       */
13729    }, {
13730      key: "destroy",
13731      value: function destroy() {
13732        var _this6 = this;
13733        var proxy = this.retrieveProxy(PlayerProxy.NAME);
13734        return new Promise(function (resolve) {
13735          if (proxy != null) {
13736            var core = proxy.activePlaybackCore;
13737            if (core != null) {
13738              if (typeof core.destroy === "function") {
13739                core.destroy();
13740              }
13741            }
13742          }
13743          _this6.once(Events.DESTROY, function () {
13744            return setTimeout(resolve, 10);
13745          });
13746          _this6.sendNotification(Notifications.DESTROY, _this6);
13747          setTimeout(function () {
13748            babelHelpers.get(babelHelpers.getPrototypeOf(Player.prototype), "destroy", _this6).call(_this6);
13749            Utils.timerGroup(_this6.multitonKey, true);
13750          }, 1);
13751        });
13752      }
13753
13754      /**
13755       * @static
13756       */
13757    }], [{
13758      key: "create",
13759      value: function create(element, config) {
13760        return new Promise(function (resolve, reject) {
13761          try {
13762            var player = new Player(element);
13763            element.amp = player;
13764            player.onready = function (event) {
13765              this.player = event.player;
13766              resolve(event);
13767            };
13768            player.initialize(config);
13769          } catch (error) {
13770            reject(error);
13771          }
13772        });
13773      }
13774    }]);
13775    return Player;
13776  }(Module);
13777
13778  var Manager = /*#__PURE__*/function () {
13779    /**
13780     * @constructor
13781     * @private
13782     */
13783    function Manager() {
13784      babelHelpers.classCallCheck(this, Manager);
13785      this.map = {};
13786    }
13787
13788    /**
13789     * @param {string} key
13790     *     The key
13791     *
13792     * @param {Object} value
13793     *     The value
13794     */
13795    babelHelpers.createClass(Manager, [{
13796      key: "add",
13797      value: function add(key, value) {
13798        this.map[key] = value;
13799      }
13800
13801      /**
13802       * @param {string} key
13803       *     The module's key
13804       *
13805       * @return {Object}
13806       *     The item at the given key.
13807       */
13808    }, {
13809      key: "item",
13810      value: function item(key) {
13811        return this.map[key];
13812      }
13813
13814      /**
13815       * @param {string} key
13816       *     The module's key
13817       *
13818       * @return {Object}
13819       *     The item.
13820       */
13821    }, {
13822      key: "remove",
13823      value: function remove(key) {
13824        var item = this.map[key];
13825        if (item != null) {
13826          this.map[key] = null;
13827          delete this.map[key];
13828        }
13829        return item;
13830      }
13831    }]);
13832    return Manager;
13833  }();
13834
13835  var ResourceManager = /*#__PURE__*/function (_Manager) {
13836    babelHelpers.inherits(ResourceManager, _Manager);
13837    /**
13838     * @constructor
13839     * @extends {Manager}
13840     */
13841    function ResourceManager() {
13842      babelHelpers.classCallCheck(this, ResourceManager);
13843      return _Manager.call(this) || this;
13844    }
13845    babelHelpers.createClass(ResourceManager, [{
13846      key: "js",
13847      value: function js(src, resource) {
13848        return Utils.loadScript(src, document.body);
13849      }
13850    }, {
13851      key: "css",
13852      value: function css(src, resource) {
13853        return new Promise(function (resolve, reject) {
13854          try {
13855            Utils.loadStyleSheet(src);
13856          } catch (error) {
13857            reject();
13858          }
13859          resolve(resource);
13860        });
13861      }
13862    }, {
13863      key: "json",
13864      value: function json(src, resource) {
13865        return Utils.requestJson(resource.src).then(function (data) {
13866          resource.data = data;
13867          return resource;
13868        });
13869      }
13870    }, {
13871      key: "img",
13872      value: function img(src, resource) {
13873        return Utils.loadImage(src);
13874      }
13875
13876      /**
13877       * @override
13878       */
13879    }, {
13880      key: "require",
13881      value: function require(id) {
13882        var item = this.item(id);
13883        if (item == null) {
13884          if (typeof id === "string") {
13885            return this.add({
13886              src: id
13887            });
13888          } else if (id.src != null) {
13889            return this.add(id);
13890          } else {
13891            return Promise.resolve(id);
13892          }
13893        } else if (typeof item === "function") {
13894          Manager.prototype.add.call(this, id, null);
13895          return Promise.resolve().then(function () {
13896            return item();
13897          });
13898        } else if (typeof item.then === "function") {
13899          return item;
13900        } else {
13901          return Promise.resolve(item);
13902        }
13903      }
13904
13905      /**
13906       * @override
13907       */
13908    }, {
13909      key: "add",
13910      value: function add(resource) {
13911        var _this = this;
13912        if (resource.enabled === false) {
13913          return Promise.resolve();
13914        }
13915        var src = Logger.instance.enabled && resource.debug != null ? resource.debug : resource.src;
13916        var id = resource.id || resource.src || src;
13917        if (resource.defer === true) {
13918          resource.defer = false;
13919          babelHelpers.get(babelHelpers.getPrototypeOf(ResourceManager.prototype), "add", this).call(this, id, this.add.bind(this, resource));
13920          return Promise.resolve();
13921        }
13922        var item = this.item(id);
13923        if (item != null) {
13924          if (typeof item.then === "function") {
13925            return item;
13926          } else if (typeof item !== "function") {
13927            return Promise.resolve(item);
13928          }
13929        }
13930        var type = resource.type || Utils.getMimeType(src);
13931        var promise;
13932        if (type === Utils.mimeTypes.js || /javascript/.test(type)) {
13933          promise = this.js(src, resource);
13934        } else if (type === Utils.mimeTypes.css) {
13935          promise = this.css(src, resource);
13936        } else if (type === Utils.mimeTypes.json || /json/.test(type)) {
13937          promise = this.json(src, resource);
13938        } else if (type !== Utils.mimeTypes.swf) {
13939          promise = Utils.request(src);
13940        } else if (/image/.test(type)) {
13941          promise = this.img(src, resource);
13942        }
13943        if (promise == null) {
13944          return Promise.resolve();
13945        }
13946        promise = promise.then(function (resource) {
13947          Manager.prototype.add.call(_this, id, resource);
13948          return resource;
13949        });
13950        babelHelpers.get(babelHelpers.getPrototypeOf(ResourceManager.prototype), "add", this).call(this, id, promise);
13951        return promise;
13952      }
13953
13954      /**
13955       * @param {Array.<akamai.amp.Resource>} resource
13956       *    The resource
13957       *
13958       * @param {Function} callback
13959       */
13960    }, {
13961      key: "addResources",
13962      value: function addResources(resources) {
13963        var _this2 = this;
13964        if (!resources || resources.length == 0) {
13965          return Promise.resolve();
13966        }
13967        var promises = [];
13968        var asyncs = [];
13969        resources.forEach(function (resource) {
13970          if (resource instanceof Array) {
13971            promises.push(_this2.addResources.bind(_this2, resource));
13972          } else if (resource.async === true) {
13973            asyncs.push(_this2.add(resource));
13974          } else {
13975            promises.push(_this2.add.bind(_this2, resource));
13976          }
13977        });
13978        var promise = asyncs.length > 0 ? Promise.all(asyncs) : Promise.resolve();
13979        return promise.then(function () {
13980          return Utils.chain(promises);
13981        });
13982      }
13983    }]);
13984    return ResourceManager;
13985  }(Manager);
13986
13987  var plugins = {};
13988  var resourceManager = new ResourceManager();
13989  var instances = [];
13990  var AMP = /*#__PURE__*/function () {
13991    /**
13992     * @constructor
13993     */
13994    function AMP() {
13995      babelHelpers.classCallCheck(this, AMP);
13996    }
13997
13998    /**
13999     * Create a player based on the configuration object and container.
14000     *
14001     * @param {string|HTMLElement} container
14002     *    The id of the div the player will be attached to.
14003     *
14004     * @param {?(Object|string)} config
14005     *    The configuration override object.
14006     *
14007     * @param {?Function} onready
14008     *    Optional ready handler.
14009     *
14010     * @return {Player}
14011     *
14012     */
14013    babelHelpers.createClass(AMP, null, [{
14014      key: "VERSION",
14015      get:
14016      /**
14017       * The player version string
14018       *
14019       * @type {string}
14020       * @private
14021       * @static
14022       */
14023      function get() {
14024        return "AMP v9.1.22+premier";
14025      }
14026
14027      /**
14028       * @private
14029       */
14030    }, {
14031      key: "plugins",
14032      get: function get() {
14033        return plugins;
14034      }
14035
14036      /**
14037       * @private
14038       */
14039    }, {
14040      key: "instances",
14041      get: function get() {
14042        return instances;
14043      }
14044
14045      /**
14046       * @type {akamai.amp.ResourceManager}
14047       * @private
14048       */
14049    }, {
14050      key: "resourceManager",
14051      get: function get() {
14052        return resourceManager;
14053      }
14054    }, {
14055      key: "create",
14056      value: function create(container, config, onready) {
14057        var _this = this;
14058        var initTime = Date.now();
14059        if (container.container != null) {
14060          config = container;
14061          container = container.container;
14062          delete config.container;
14063        }
14064        var element = Utils.select(container);
14065        if (element == null) {
14066          return Promise.reject(AMPError.create("Invalid container. Could not find DOM element: ".concat(container)));
14067        }
14068        config = config instanceof Config ? config : Config.create(config);
14069        Logger.instance = new Logger(config.debug);
14070        var version = this.getVersion();
14071        if (element.dataset == null) {
14072          element.dataset = {};
14073        }
14074        element.dataset["amp.version"] = version;
14075        Logger.instance.log("[AMP] ".concat(version));
14076        return Promise.all([AutoplayThreshold.init(config), Player.create(element, config), KeySystem.init(config)]).then(function (results) {
14077          var event = results[1];
14078          var player = event.player;
14079          player.initTime = initTime;
14080          player.performance.record("init", initTime);
14081          player.request = _this.request.bind(_this);
14082          player.require = _this.require.bind(_this);
14083          player.once(Events.DESTROY, function (event) {
14084            return dispatcher.dispatchEvent(event);
14085          });
14086          dispatcher.dispatch(Events.CREATE, player);
14087          if (typeof onready === "function") {
14088            onready(event);
14089          }
14090          return player;
14091        })["catch"](function (error) {
14092          throw AMPError.create(error);
14093        });
14094      }
14095
14096      /**
14097       * Returns the version string for this player library.
14098       *
14099       * @return {string} The version string.
14100       */
14101    }, {
14102      key: "getVersion",
14103      value: function getVersion() {
14104        return this.VERSION;
14105      }
14106
14107      /**
14108       * Registers a plugin factory function. This function is
14109       * called when .create is called and the
14110       * config object contains the plugin key.
14111       *
14112       * @param {String} key
14113       *    The plugin key. Used to configure the plugin.
14114       *
14115       * @param {Function} factory
14116       *
14117       * @static
14118       */
14119    }, {
14120      key: "registerPlugin",
14121      value: function registerPlugin(id, mode, plugin) {
14122        if (typeof mode === "function") {
14123          plugin = mode;
14124        }
14125        this.plugins[id] = plugin;
14126      }
14127
14128      /**
14129       * Short cut getter for the global renderer manager
14130       *
14131       * @return {akamai.amp.ResourceManager}
14132       *
14133       * @static
14134       * @private
14135       */
14136    }, {
14137      key: "getResourceManager",
14138      value: function getResourceManager() {
14139        return resourceManager;
14140      }
14141
14142      /**
14143       * @param {akamai.amp.Resource} resource
14144       *    The resource definition
14145       *
14146       * @param {Function} callback
14147       *
14148       * @static
14149       * @private
14150       */
14151    }, {
14152      key: "addResource",
14153      value: function addResource(resource) {
14154        return this.getResourceManager().add(resource);
14155      }
14156
14157      /**
14158       * @param {Array.<akamai.amp.Resource>} resources
14159       *    The list of resources
14160       *
14161       * @param {Function} callback
14162       *
14163       * @static
14164       * @private
14165       */
14166    }, {
14167      key: "addResources",
14168      value: function addResources(resources) {
14169        return this.getResourceManager().addResources(resources);
14170      }
14171
14172      /**
14173       * Request a http resource.
14174       *
14175       * @param {String|Object} options
14176       *    A url string or an object containing the following properties:
14177       *
14178       * @return {Promise.<XHR>}
14179       *     Promise which resolves to a XHR object
14180       *
14181       * @static
14182       */
14183    }, {
14184      key: "request",
14185      value: function request(options) {
14186        return Utils.request(options);
14187      }
14188
14189      /**
14190       * Request a http json resource.
14191       *
14192       * @param {String|Object} options
14193       *    A url string or an object containing the following properties:
14194       *
14195       * @return {Promise.<Object>}
14196       *     Promise which resolves to a js object
14197       *
14198       * @static
14199       */
14200    }, {
14201      key: "requestJson",
14202      value: function requestJson(options) {
14203        return Utils.requestJson(options);
14204      }
14205
14206      /**
14207       * Loads resource from url or cache
14208       *
14209       * @param {String} id
14210       *    A url or id of the resource
14211       *
14212       * @return {Promise.<Object>}
14213       *     Promise which resolves to an object
14214       *
14215       * @static
14216       */
14217    }, {
14218      key: "require",
14219      value: function require(id) {
14220        return this.resourceManager.require(id);
14221      }
14222
14223      /**
14224       * @param {!string} key
14225       *     The resource's key
14226       *
14227       * @return {akamai.amp.Resource}
14228       *     The resource definition
14229       *
14230       * @static
14231       * @private
14232       */
14233    }, {
14234      key: "getResource",
14235      value: function getResource(key) {
14236        return this.getResourceManager().item(key);
14237      }
14238
14239      /**
14240       * @param {!string} key
14241       *     The resource's key
14242       *
14243       * @return {Function}
14244       *     The resource's constructor
14245       *
14246       * @static
14247       * @private
14248       */
14249    }, {
14250      key: "removeResource",
14251      value: function removeResource(key) {
14252        return this.getResourceManager().remove(key);
14253      }
14254
14255      /**
14256       * Evaluate a data bound object.
14257       *
14258       * @param {Object} binding
14259       *   The data bound object.
14260       *
14261       * @param {Object} context
14262       *   The context object used as "global" when evaluating the binding.
14263       *
14264       * @return {string}
14265       *   The evaluated result
14266       */
14267    }, {
14268      key: "evaluateBindings",
14269      value: function evaluateBindings(value, context) {
14270        return DataBinding.evaluateBindings(value, context);
14271      }
14272
14273      /**
14274       * Overrides the Config defaults.
14275       *
14276       * @param {Object} overrides
14277       *  The overrides.
14278       *
14279       * @return {Object}
14280       *  The new defaults object
14281       */
14282    }, {
14283      key: "defaults",
14284      value: function defaults(overrides) {
14285        return Utils.override(Config.defaults, overrides, false);
14286      }
14287
14288      /**
14289       * Embeds an AMP instance using the inline HTML sytax.
14290       *
14291       * @example <script class="amp-inline" data-config='{"media":{"src":"VfE.mp4"}}' src="amp.js"></script>
14292       * @example <script class="amp-inline" data-defaults='{"autoplay":false}' src="amp.js"></script>
14293       * @example <div class="amp-inline" data-autoplay="muted" data-src="VfE.mp4" data-poster="/bunny.jpg" data-time="10" data-width="320" data-hieght="160"></div>
14294       * @example <div class="amp-inline" data-a="muted" data-s="VfE.mp4" data-p="/bunny.jpg" data-t="10" data-w="320" data-h="160"></div>
14295       */
14296    }, {
14297      key: "embed",
14298      value: function embed(element) {
14299        if (element == null) {
14300          return Promise.reject(AMPError.create("Invalid DOM element"));
14301        }
14302        var data = element.dataset;
14303        data.embedded = true;
14304        function get(name, dflt) {
14305          return data[name] || data[name[0]] || dflt;
14306        }
14307
14308        // all amp-inline elements must have an id
14309        var id = get("id", element.id || Utils.createUID());
14310        if (data.id !== id) {
14311          data.id = id;
14312        }
14313
14314        // only create amp instance once
14315        if (AMP.instances[id] != null) {
14316          return Promise.reject(AMPError.create("Player with id \"".concat(id, "\" already exists.")));
14317        } else {
14318          AMP.instances[id] = true;
14319        }
14320
14321        // json data can be inline or remote
14322        function resource(name) {
14323          var value = get(name);
14324          if (value == null) {
14325            return Promise.resolve();
14326          }
14327          return Promise.resolve().then(function () {
14328            // inline json
14329            if (/^\{[\s\S]*\}$/.test(value)) {
14330              return value;
14331            } else {
14332              // remote json
14333              return Utils.requestText(value)["catch"](function (error) {
14334                throw AMPError.create("Could not load resource \"".concat(name, "\" at \"").concat(value, "\""));
14335              });
14336            }
14337          }).then(function (json) {
14338            // parse json
14339            try {
14340              return JSON.parse(json);
14341            } catch (error) {
14342              throw AMPError.create("Could not parse resource \"".concat(name, "\". \"").concat(value, "\""));
14343            }
14344          });
14345        }
14346
14347        // overrides
14348        function options(opts) {
14349          function set(target, path, value, format) {
14350            if (value == null) {
14351              return;
14352            }
14353            return Utils.set(target, path, format != null ? format(value) : value);
14354          }
14355
14356          // get media and playback config options
14357          set(opts, ["media", "src"], get("src"));
14358          set(opts, ["media", "poster"], get("poster"));
14359          set(opts, ["media", "startTime"], get("time"), parseFloat);
14360          set(opts, ["autoplay"], get("autoplay"), function (value) {
14361            return /true|false/.test(value) ? value == "true" : value;
14362          });
14363
14364          // setup the container element
14365          set(opts, ["container"], element.nodeName !== "SCRIPT" ? element : element.parentNode.insertBefore(document.createElement("div"), element.nextSibling));
14366          set(opts, ["container", "style", "width"], get("width"), CSS.toSize);
14367          set(opts, ["container", "style", "height"], get("height"), CSS.toSize);
14368          return opts;
14369        }
14370
14371        // get the config if available
14372        return Promise.all([resource("defaults"), resource("config"), resource("media")]).then(function (results) {
14373          var dflts = results[0];
14374          if (dflts != null) {
14375            AMP.defaults(dflts);
14376            // Do not create a player if only defaults were passed in.
14377            // This allows the script tag to be loaded in the head of
14378            // the document with default overrides, and players to be
14379            // created later in the body.
14380            if (element.nodeName.toLowerCase() == "script" && results.filter(function (x) {
14381              return x != null;
14382            }).length === 1) {
14383              return;
14384            }
14385          }
14386
14387          // populate media config
14388          if (results[2] != null) {
14389            results[2] = {
14390              media: results[2]
14391            };
14392          }
14393
14394          // override the id, and pass in the data-* params for plugins to use
14395          results.push(options({
14396            id: id,
14397            dataset: Utils.clone(data)
14398          }));
14399          var config = Utils.merge(results);
14400          return AMP.create(config);
14401        });
14402      }
14403    }]);
14404    return AMP;
14405  }();
14406  var dispatcher = EventDispatcher.create(AMP);
14407  Utils.mixin(AMP, dispatcher);
14408  AMP.addEventListener(Events.CREATE, function (event) {
14409    var player = event.detail;
14410    instances.push(event.detail);
14411    if (player.id != null) {
14412      instances[player.id] = player;
14413    }
14414  });
14415  AMP.addEventListener(Events.DESTROY, function (event) {
14416    var player = event.detail;
14417    var index = instances.indexOf(player);
14418    instances.splice(index, 1);
14419    if (player.id != null) {
14420      delete instances[player.id];
14421    }
14422  });
14423
14424  var AuthProvider = /*#__PURE__*/function () {
14425    /**
14426     * Creates a new instance of AuthProvider.
14427     *
14428     * @constructor
14429     */
14430    function AuthProvider(id, name, logo, metadata) {
14431      babelHelpers.classCallCheck(this, AuthProvider);
14432      this.id = id;
14433      this.name = name;
14434      this.logo = logo;
14435      this.metadata = metadata;
14436    }
14437
14438    /** @static */
14439    babelHelpers.createClass(AuthProvider, null, [{
14440      key: "create",
14441      value: function create(id, name, logo, metadata) {
14442        return new AuthProvider(id, name, logo, metadata);
14443      }
14444    }]);
14445    return AuthProvider;
14446  }();
14447
14448  var AuthProviderList = /*#__PURE__*/function () {
14449    /**
14450     * Creates a new instance of AuthProviderList.
14451     *
14452     * @constructor
14453     */
14454    function AuthProviderList(items) {
14455      var _this = this;
14456      var featured = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
14457      var footprints = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
14458      var metadata = arguments.length > 3 ? arguments[3] : undefined;
14459      babelHelpers.classCallCheck(this, AuthProviderList);
14460      this.list = [];
14461      this.featured = featured;
14462      this.footprints = footprints;
14463      this.metadata = metadata;
14464      items.forEach(function (item) {
14465        return _this.add(item);
14466      });
14467    }
14468
14469    /** @static */
14470    babelHelpers.createClass(AuthProviderList, [{
14471      key: "length",
14472      get: function get() {
14473        return this.list.length;
14474      }
14475
14476      /**
14477       *
14478       */
14479    }, {
14480      key: "add",
14481      value: function add(item) {
14482        this.list.push(item);
14483        this[item.id] = item;
14484        return item;
14485      }
14486
14487      /**
14488       *
14489       */
14490    }, {
14491      key: "slice",
14492      value: function slice(index, count) {
14493        return this.list.forEach(index, count);
14494      }
14495
14496      /**
14497       *
14498       */
14499    }, {
14500      key: "splice",
14501      value: function splice(index, remove) {
14502        var _this$list;
14503        for (var _len = arguments.length, items = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
14504          items[_key - 2] = arguments[_key];
14505        }
14506        return (_this$list = this.list).splice.apply(_this$list, [index, remove].concat(items));
14507      }
14508
14509      /**
14510       *
14511       */
14512    }, {
14513      key: "forEach",
14514      value: function forEach(func) {
14515        return this.list.forEach(func);
14516      }
14517
14518      /**
14519       *
14520       */
14521    }, {
14522      key: "some",
14523      value: function some(func) {
14524        return this.list.some(func);
14525      }
14526
14527      /**
14528       *
14529       */
14530    }, {
14531      key: "filter",
14532      value: function filter(func) {
14533        return this.list.filter(func);
14534      }
14535
14536      /**
14537       *
14538       */
14539    }, {
14540      key: "map",
14541      value: function map(func) {
14542        return this.list.map(func);
14543      }
14544
14545      /**
14546       *
14547       */
14548    }, {
14549      key: "reduce",
14550      value: function reduce(func, init) {
14551        return this.list.reduce(func, init);
14552      }
14553
14554      /**
14555       *
14556       */
14557    }, {
14558      key: "includes",
14559      value: function includes(item) {
14560        return this.list.includes(item);
14561      }
14562
14563      /**
14564       *
14565       */
14566    }, {
14567      key: "indexOf",
14568      value: function indexOf(item) {
14569        return this.list.indexOf(item);
14570      }
14571
14572      /**
14573       *
14574       */
14575    }, {
14576      key: "item",
14577      value: function item(index) {
14578        return this.list[index];
14579      }
14580    }], [{
14581      key: "create",
14582      value: function create(items, featured, footprints, metadata) {
14583        return new AuthProviderList(items, featured, footprints, metadata);
14584      }
14585    }]);
14586    return AuthProviderList;
14587  }();
14588
14589  /**
14590   * @enum {string}
14591   * @const
14592   * @private
14593   */
14594  var Medium = {
14595    /**
14596     * Constant representing video content
14597     */
14598    VIDEO: "video",
14599    /**
14600     * Constant representing audio content
14601     */
14602    AUDIO: "audio"
14603  };
14604
14605  /**
14606   * @enum {string}
14607   * @const
14608   * @private
14609   */
14610  var QualityMode = {
14611    /**
14612     * Constant representing the auto quality mode. Let the playback engine handle bitrate switching.
14613     */
14614    AUTO: "auto",
14615    /**
14616     * Constant representing the manual quality mode. Let the user handle bitrate switching.
14617     */
14618    MANUAL: "manual"
14619  };
14620
14621  var Authorization = /*#__PURE__*/babelHelpers.createClass(function Authorization(key, token, expiration) {
14622    babelHelpers.classCallCheck(this, Authorization);
14623    this.key = key;
14624    this.token = token;
14625    this.expiration = expiration;
14626  });
14627
14628  var Resource = /*#__PURE__*/babelHelpers.createClass(function Resource() {
14629    babelHelpers.classCallCheck(this, Resource);
14630    this.src = null;
14631    this.debug = null;
14632    this.type = null;
14633    this.metadata = {};
14634  });
14635
14636  var MediaVO = /*#__PURE__*/function (_Resource) {
14637    babelHelpers.inherits(MediaVO, _Resource);
14638    function MediaVO() {
14639      var _this;
14640      babelHelpers.classCallCheck(this, MediaVO);
14641      _this = _Resource.call(this) || this;
14642      _this.source = null;
14643      _this.title = null;
14644      _this.description = null;
14645      _this.link = null;
14646      _this.guid = null;
14647      _this.pubDate = null;
14648      _this.poster = null;
14649      _this.thumbnail = null;
14650      _this.embed = null;
14651      _this.category = null;
14652      _this.medium = null;
14653      _this.duration = null;
14654      _this.track = null;
14655      _this.scenes = null;
14656      _this.startTime = null;
14657      return _this;
14658    }
14659    babelHelpers.createClass(MediaVO, null, [{
14660      key: "DEFAULT",
14661      get: function get() {
14662        return {
14663          src: Utils.blankVideo(),
14664          type: Utils.mimeTypes.mp4,
14665          temporalType: "vod",
14666          medium: "video"
14667        };
14668      }
14669    }]);
14670    return MediaVO;
14671  }(Resource);
14672
14673  var PromisePlugin = /*#__PURE__*/function (_EventDispatcher) {
14674    babelHelpers.inherits(PromisePlugin, _EventDispatcher);
14675    function PromisePlugin(player, config, key) {
14676      var _this;
14677      babelHelpers.classCallCheck(this, PromisePlugin);
14678      _this = _EventDispatcher.call(this) || this;
14679      _this.player = player;
14680      _this.config = config || {};
14681      _this.key = key;
14682      _this.logger = new Logger(_this.debug);
14683      Object.values(Events).forEach(function (event) {
14684        var prop = _this["on".concat(event)];
14685        if (prop == null || typeof prop != "function") return;
14686        prop = _this["on".concat(event)] = prop.bind(babelHelpers.assertThisInitialized(_this));
14687        _this.player.addEventListener(event, prop);
14688      });
14689      return _this;
14690    }
14691    babelHelpers.createClass(PromisePlugin, [{
14692      key: "debug",
14693      get: function get() {
14694        return this.config.debug != null ? this.config.debug : this.player.config.debug;
14695      }
14696    }, {
14697      key: "data",
14698      get: function get() {
14699        return this.player.evaluateBindings(this.config);
14700      }
14701    }, {
14702      key: "destroy",
14703      value: function destroy() {
14704        var _this2 = this;
14705        Object.values(Events).forEach(function (event) {
14706          var prop = _this2["on".concat(event)];
14707          if (prop == null || typeof prop != "function") return;
14708          _this2.player.removeEventListener(event, prop);
14709        });
14710        babelHelpers.get(babelHelpers.getPrototypeOf(PromisePlugin.prototype), "destroy", this).call(this);
14711        this.player = null;
14712        this.config = null;
14713        this.key = null;
14714      }
14715    }, {
14716      key: "bindHandlers",
14717      value: function bindHandlers(handlers) {
14718        var _this3 = this;
14719        if (handlers instanceof Array == false) handlers = [handlers];
14720        handlers.forEach(function (func) {
14721          _this3[func] = _this3[func].bind(_this3);
14722        });
14723      }
14724    }], [{
14725      key: "createFactory",
14726      value: function createFactory(def) {
14727        return function (player, config, key) {
14728          var _this4 = this;
14729          return new Promise(function (resolve, reject) {
14730            try {
14731              var plugin = new _this4(player, config, key);
14732              resolve(plugin);
14733            } catch (error) {
14734              reject(error);
14735            }
14736          });
14737        }.bind(def);
14738      }
14739    }, {
14740      key: "createPureMVCFactory",
14741      value: function createPureMVCFactory(def) {
14742        return function (player, config, key) {
14743          return new Promise(function (resolve, reject) {
14744            try {
14745              var plugin = new def();
14746              plugin.parentModule = player;
14747              plugin.player = player;
14748              plugin.config = config;
14749              player.registerModule(plugin);
14750              resolve(plugin);
14751            } catch (error) {
14752              reject(error);
14753            }
14754          });
14755        };
14756      }
14757    }]);
14758    return PromisePlugin;
14759  }(EventDispatcher);
14760
14761  var AdPromisePlugin = /*#__PURE__*/function (_PromisePlugin) {
14762    babelHelpers.inherits(AdPromisePlugin, _PromisePlugin);
14763    function AdPromisePlugin(player, config) {
14764      var _this;
14765      babelHelpers.classCallCheck(this, AdPromisePlugin);
14766      _this = _PromisePlugin.call(this, player, config) || this;
14767      _this.feature = "ads";
14768      return _this;
14769    }
14770    babelHelpers.createClass(AdPromisePlugin, [{
14771      key: "dispatchEvent",
14772      value: function dispatchEvent(event) {
14773        var type = event.type;
14774        if (type != "timeupdate" && type != "timeremaining") this.player.logger.log("[AMP AD EVENT] ".concat(type), event);
14775        if (typeof this.player.sendNotification === "function") this.player.sendNotification("ads".concat(type), event.detail);
14776        babelHelpers.get(babelHelpers.getPrototypeOf(AdPromisePlugin.prototype), "dispatchEvent", this).call(this, event);
14777        this.player.dispatch("ad".concat(type), event.detail);
14778      }
14779    }]);
14780    return AdPromisePlugin;
14781  }(PromisePlugin);
14782
14783  var AuthPromisePlugin = /*#__PURE__*/function (_PromisePlugin) {
14784    babelHelpers.inherits(AuthPromisePlugin, _PromisePlugin);
14785    function AuthPromisePlugin(player, config) {
14786      var _this;
14787      babelHelpers.classCallCheck(this, AuthPromisePlugin);
14788      _this = _PromisePlugin.call(this, player, config) || this;
14789      _this.feature = "auth";
14790      _this.provider = null;
14791      _this.providers = null;
14792      return _this;
14793    }
14794    babelHelpers.createClass(AuthPromisePlugin, [{
14795      key: "dispatchEvent",
14796      value: function dispatchEvent(event) {
14797        babelHelpers.get(babelHelpers.getPrototypeOf(AuthPromisePlugin.prototype), "dispatchEvent", this).call(this, event);
14798        if (Object.values(AuthEvents).includes(event.type)) {
14799          this.player.dispatchEvent(event);
14800        }
14801      }
14802    }]);
14803    return AuthPromisePlugin;
14804  }(PromisePlugin);
14805
14806  var AdVO = /*#__PURE__*/function () {
14807    /**
14808     * @constructor
14809     */
14810    function AdVO(id1, title1, duration1, position1, type1, partner1, advertiser1, companions1, request1, metadata1, totalAds1, time1, clickThrough1) {
14811      babelHelpers.classCallCheck(this, AdVO);
14812      this.id = id1;
14813      this.title = title1;
14814      this.duration = duration1;
14815      this.position = position1;
14816      this.type = type1;
14817      this.partner = partner1;
14818      this.advertiser = advertiser1;
14819      this.companions = companions1;
14820      this.request = request1;
14821      this.metadata = metadata1;
14822      this.totalAds = totalAds1;
14823      this.time = time1;
14824      this.clickThrough = clickThrough1;
14825    }
14826    babelHelpers.createClass(AdVO, null, [{
14827      key: "create",
14828      value: function create(id, title, duration, position, type, partner, advertiser, companions, request, metadata, totalAds, time, clickThrough) {
14829        return new AdVO(id, title, duration, position, type, partner, advertiser, companions, request, metadata, totalAds, time, clickThrough);
14830      }
14831    }]);
14832    return AdVO;
14833  }();
14834
14835  var PluginController = /*#__PURE__*/function (_Controller) {
14836    babelHelpers.inherits(PluginController, _Controller);
14837    /**
14838     * The PluginController class.
14839     *
14840     * @param {string} name
14841     * @param {Object} viewComponent
14842     * @constructor
14843     * @private
14844     * @extends {amp.plugins.PluginController}
14845     */
14846    function PluginController(name) {
14847      var _this;
14848      babelHelpers.classCallCheck(this, PluginController);
14849      _this = _Controller.call(this, name) || this;
14850      _this.plugin = null;
14851      _this.proxy = null;
14852      return _this;
14853    }
14854
14855    /** @override */
14856    babelHelpers.createClass(PluginController, [{
14857      key: "initializeNotifier",
14858      value: function initializeNotifier(key) {
14859        babelHelpers.get(babelHelpers.getPrototypeOf(PluginController.prototype), "initializeNotifier", this).call(this, key);
14860        this.proxy = this.facade.retrieveProxy(ModuleProxy.NAME);
14861        this.plugin = this.facade;
14862      }
14863
14864      /** */
14865    }, {
14866      key: "dispatchEvent",
14867      value: function dispatchEvent(type, detail) {
14868        if (typeof type !== "string") {
14869          detail = type.getBody();
14870          if (detail == null) {
14871            detail = {};
14872          }
14873          type = type.getName();
14874        }
14875        this.player.sendNotification(Notifications.DISPATCH_EVENT, Event.create(type, detail));
14876        var name = this.plugin.feature;
14877        if (name != null && name !== "auth") {
14878          type = type.replace(new RegExp("^(" + name + ")"), "");
14879        }
14880        name = this.plugin.getModuleName();
14881        type = type.replace(new RegExp("^(" + name + ")"), "");
14882        var event = Event.create(type, detail);
14883        this.sendNotification(Notifications.DISPATCH_EVENT, event);
14884        return event;
14885      }
14886    }]);
14887    return PluginController;
14888  }(Controller);
14889
14890  var AdContentController = /*#__PURE__*/function (_PluginController) {
14891    babelHelpers.inherits(AdContentController, _PluginController);
14892    /**
14893     * The AdContentController class.
14894     *
14895     * @param {string} name
14896     * @param {Object} viewComponent
14897     * @constructor
14898     * @private
14899     * @extends {amp.plugins.ads.AdContentController}
14900     */
14901    function AdContentController() {
14902      babelHelpers.classCallCheck(this, AdContentController);
14903      return _PluginController.call(this, AdContentController.NAME) || this;
14904    }
14905
14906    /**
14907     * @static
14908     * @type {string}
14909     */
14910    babelHelpers.createClass(AdContentController, [{
14911      key: "listNotificationInterests",
14912      value: /** @override */
14913      function listNotificationInterests() {
14914        return [Notifications.STARTED, Notifications.ENDED];
14915      }
14916
14917      /** */
14918    }, {
14919      key: "started",
14920      value: function started() {
14921        this.proxy.contentStarted();
14922      }
14923
14924      /** */
14925    }, {
14926      key: "ended",
14927      value: function ended() {
14928        this.proxy.contentEnded();
14929      }
14930    }], [{
14931      key: "NAME",
14932      get: function get() {
14933        return "AdContentController";
14934      }
14935    }]);
14936    return AdContentController;
14937  }(PluginController);
14938
14939  var AdCoreController = /*#__PURE__*/function (_PluginController) {
14940    babelHelpers.inherits(AdCoreController, _PluginController);
14941    /**
14942     * The AdCoreController class.
14943     *
14944     * @param {string} name
14945     * @param {Object} viewComponent
14946     * @constructor
14947     * @private
14948     * @extends {amp.plugins.ads.AdCoreController}
14949     */
14950    function AdCoreController() {
14951      babelHelpers.classCallCheck(this, AdCoreController);
14952      return _PluginController.call(this, AdCoreController.NAME) || this;
14953    }
14954
14955    /**
14956     * @static
14957     * @type {string}
14958     */
14959    babelHelpers.createClass(AdCoreController, [{
14960      key: "listNotificationInterests",
14961      value: /** @override */
14962      function listNotificationInterests() {
14963        return [Notifications.START, Notifications.PLAY, Notifications.PAUSE, Notifications.TOGGLE_PLAY_PAUSE, Notifications.VOLUME_CHANGE, Notifications.PLAY_STATE_CHANGE];
14964      }
14965
14966      /** */
14967    }, {
14968      key: "start",
14969      value: function start() {
14970        this.sendNotification(Notifications.REQUEST_PLAY);
14971        if (this.playback.initialized === false) {
14972          this.player.sendNotification(Notifications.INITIALIZED);
14973        }
14974        this.proxy.start();
14975      }
14976
14977      /** */
14978    }, {
14979      key: "play",
14980      value: function play() {
14981        if (this.applicationState.getLocked() === true) {
14982          return;
14983        }
14984        this.sendNotification(Notifications.REQUEST_PLAY);
14985        if (this.proxy.getStarted() === false) {
14986          this.sendNotification(Notifications.START, true);
14987          return;
14988        }
14989        this.proxy.play();
14990        this.player.sendNotification(Notifications.CHANGE_PLAY_STATE, PlayState.PLAYING);
14991      }
14992
14993      /** */
14994    }, {
14995      key: "pause",
14996      value: function pause() {
14997        var _this = this;
14998        var time = this.proxy.adVO.time;
14999        var duration = this.proxy.adVO.duration;
15000        // See AMPWEB-268. Resolves issues created by premature pause instructions
15001        if (typeof time === "undefined" || time === duration) {
15002          // See AMPWEB-902
15003          var _transform = {
15004            transform: function transform(state) {
15005              if (state === Notifications.PLAYING) {
15006                // Required in relation to AMPWEB-1013
15007                _this.player.timers.setTimeout(function () {
15008                  _this.player.removeTransform(TransformType.PLAY_STATE, _transform);
15009                  return _this.player.sendNotification(Notifications.PAUSE);
15010                }, 300);
15011                return state;
15012              }
15013            },
15014            priority: 2
15015          };
15016          this.player.addTransform(TransformType.PLAY_STATE, _transform);
15017          return;
15018        }
15019        this.proxy.pause();
15020        this.player.sendNotification(Notifications.CHANGE_PLAY_STATE, PlayState.PAUSED);
15021      }
15022
15023      /** */
15024    }, {
15025      key: "toggleplaypause",
15026      value: function toggleplaypause() {
15027        var note = this.proxy.getPaused() || this.proxy.getStarted() === false ? Notifications.PLAY : Notifications.PAUSE;
15028        this.sendNotification(note, true);
15029      }
15030
15031      /** */
15032    }, {
15033      key: "volumechange",
15034      value: function volumechange(volume) {
15035        this.proxy.setVolume(volume);
15036      }
15037
15038      /** */
15039    }, {
15040      key: "playstatechange",
15041      value: function playstatechange(state) {
15042        if (state.value === "playing") {
15043          this.sendNotification(AdNotifications.AD_PLAYING, this.proxy.adVO);
15044        }
15045      }
15046    }], [{
15047      key: "NAME",
15048      get: function get() {
15049        return "AdCoreController";
15050      }
15051    }]);
15052    return AdCoreController;
15053  }(PluginController);
15054
15055  var AdProxy = /*#__PURE__*/function (_PluginProxy) {
15056    babelHelpers.inherits(AdProxy, _PluginProxy);
15057    /**
15058     * The AdProxy class.
15059     *
15060     * @constructor
15061     * @private
15062     * @extends {PluginProxy}
15063     * @param {Object} config
15064     */
15065    function AdProxy(config) {
15066      var _this;
15067      babelHelpers.classCallCheck(this, AdProxy);
15068      _this = _PluginProxy.call(this, config) || this;
15069      _this.pods = [];
15070      _this.content = new AdContentController();
15071      _this.ads = new AdCoreController();
15072      _this.processAdBreak = _this.processAdBreak.bind(babelHelpers.assertThisInitialized(_this));
15073      _this.processAdRequest = _this.processAdRequest.bind(babelHelpers.assertThisInitialized(_this));
15074      _this.inProgress = false;
15075      _this.paused = false;
15076      _this.started = false;
15077      _this.adVO = null;
15078      _this.contextName = "ad";
15079      _this.container = null;
15080      _this.partner = null;
15081      _this.pods = null;
15082      _this.mediaChanging = false;
15083      return _this;
15084    }
15085
15086    /**
15087     * The name of the this Proxy.
15088     *
15089     * @static
15090     * @type {string}
15091     */
15092    babelHelpers.createClass(AdProxy, [{
15093      key: "createDefaultAdVO",
15094      value: function createDefaultAdVO() {
15095        return new AdVO(null, null, null, null, null, this.partner, null, null, null, null, null);
15096      }
15097
15098      /** */
15099    }, {
15100      key: "getContainer",
15101      value: function getContainer() {
15102        return this.facade.player.adContainer || this.facade.player.container;
15103      }
15104
15105      /** */
15106    }, {
15107      key: "setCompanions",
15108      value: function setCompanions(value) {
15109        this.adVO.companions = value;
15110        this.sendNotification(AdNotifications.AD_COMPANION, this.adVO);
15111        return value;
15112      }
15113    }, {
15114      key: "getCompanions",
15115      value: function getCompanions() {
15116        var ref;
15117        return (ref = this.adVO) != null ? ref.companions : void 0;
15118      }
15119
15120      /** */
15121    }, {
15122      key: "getInProgress",
15123      value: function getInProgress() {
15124        return this.inProgress;
15125      }
15126    }, {
15127      key: "setInProgress",
15128      value: function setInProgress(value) {
15129        this.inProgress = value;
15130        return value;
15131      }
15132
15133      /** */
15134    }, {
15135      key: "getStarted",
15136      value: function getStarted() {
15137        return this.started;
15138      }
15139
15140      /** */
15141    }, {
15142      key: "setStarted",
15143      value: function setStarted(value) {
15144        this.started = value;
15145        return value;
15146      }
15147
15148      /** */
15149    }, {
15150      key: "getPaused",
15151      value: function getPaused() {
15152        return this.paused;
15153      }
15154    }, {
15155      key: "setPaused",
15156      value: function setPaused(value) {
15157        this.paused = value;
15158        return value;
15159      }
15160    }, {
15161      key: "setCues",
15162      value: function setCues(value) {
15163        var cues = fp.transform(value, fp.map(function (cue) {
15164          return {
15165            startTime: cue,
15166            endTime: cue
15167          };
15168        }));
15169        this.facade.player.mediaProxy.setCues(cues);
15170        return value;
15171      }
15172
15173      /** */
15174    }, {
15175      key: "play",
15176      value: function play() {
15177        this.setPaused(false);
15178        this.sendNotification(AdNotifications.AD_PLAY, this.adVO);
15179      }
15180
15181      /** */
15182    }, {
15183      key: "pause",
15184      value: function pause() {
15185        this.setPaused(true);
15186        this.sendNotification(AdNotifications.AD_PAUSE, this.adVO);
15187      }
15188
15189      /** */
15190    }, {
15191      key: "breakStart",
15192      value: function breakStart() {
15193        this.setInProgress(true);
15194      }
15195
15196      /** */
15197    }, {
15198      key: "breakEnd",
15199      value: function breakEnd() {
15200        this.setInProgress(false);
15201        this.reset();
15202      }
15203
15204      /** */
15205    }, {
15206      key: "error",
15207      value: function error(err) {
15208        var breakEnd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
15209        var msg = (typeof err.getMessage === "function" ? err.getMessage() : void 0) || err.message;
15210        this.facade.logger.error("[AMP AD ERROR]", "".concat(msg, " Skipping ad content."), err);
15211        if (this.adVO == null) {
15212          this.adVO = {};
15213        }
15214        this.adVO.error = err;
15215        this.sendNotification(AdNotifications.AD_ERROR, this.adVO);
15216        if (breakEnd === true) {
15217          this.endBreak();
15218        }
15219      }
15220
15221      /** */
15222    }, {
15223      key: "engage",
15224      value: function engage(media) {
15225        if (this.getEnabled() === false) {
15226          return;
15227        }
15228        this.setStarted(false);
15229        if (this.getInProgress()) {
15230          this.reset();
15231          this.facade.player.sendNotification(Notifications.REMOVE_APPLICATION_STATE, "ad-mode");
15232        }
15233        this.engageAds();
15234      }
15235
15236      /** */
15237    }, {
15238      key: "engageAds",
15239      value: function engageAds() {
15240        if (this.engaged === true) return;
15241        this.engaged = true;
15242        this.core = this.facade.player.removeMediator(CoreController.NAME);
15243        this.facade.removeMediator(AdContentController.NAME);
15244        this.facade.registerMediator(this.ads);
15245      }
15246
15247      /** */
15248    }, {
15249      key: "reset",
15250      value: function reset() {
15251        this.engaged = false;
15252        this.facade.removeMediator(AdCoreController.NAME);
15253        this.facade.player.registerMediator(this.core);
15254        this.facade.registerMediator(this.content);
15255      }
15256
15257      /** */
15258    }, {
15259      key: "processAdRequest",
15260      value: function processAdRequest(value) {
15261        var _this2 = this;
15262        return this.facade.player.transform(TransformType.AD_REQUEST, value).then(function (result) {
15263          _this2.sendNotification(AdNotifications.REQUEST, result);
15264          return _this2.facade.transform(TransformType.AD_REQUEST, result);
15265        });
15266      }
15267
15268      /** */
15269    }, {
15270      key: "processAdBreak",
15271      value: function processAdBreak(value) {
15272        var _this3 = this;
15273        return this.facade.player.transform(TransformType.AD_BREAK, value).then(function (result) {
15274          return _this3.facade.transform(TransformType.AD_BREAK, result);
15275        });
15276      }
15277
15278      /** */
15279    }, {
15280      key: "requestAd",
15281      value: function requestAd() {
15282        this.sendNotification(AdNotifications.REQUEST_START, this.adVO);
15283      }
15284
15285      /** */
15286    }, {
15287      key: "getPodById",
15288      value: function getPodById(id) {
15289        return this.pods.find(function (pod) {
15290          return pod.id === id;
15291        });
15292      }
15293
15294      /** */
15295    }, {
15296      key: "setPodLocks",
15297      value: function setPodLocks(pods) {
15298        var _this4 = this;
15299        pods.forEach(function (pod) {
15300          var p = _this4.getPodById(pod.id);
15301          if (p != null) {
15302            p.locked = pod.locked;
15303          }
15304        });
15305      }
15306
15307      /** */
15308    }, {
15309      key: "resize",
15310      value: function resize(state) {}
15311
15312      /** */
15313    }, {
15314      key: "startBreak",
15315      value: function startBreak(adVO) {
15316        if (adVO != null) {
15317          this.adVO = adVO;
15318        }
15319        this.setStarted(true);
15320        this.sendNotification(AdNotifications.BREAK_START, this.adVO);
15321        if (this.getEnabled() === false) {
15322          this.endBreak();
15323          return false;
15324        }
15325        return true;
15326      }
15327
15328      /** */
15329    }, {
15330      key: "endBreak",
15331      value: function endBreak() {
15332        this.sendNotification(AdNotifications.BREAK_END, this.adVO);
15333      }
15334
15335      /** */
15336    }, {
15337      key: "start",
15338      value: function start() {
15339        this.mediaChanging = false;
15340        this.startBreak();
15341      }
15342
15343      /** */
15344    }, {
15345      key: "contentPlay",
15346      value: function contentPlay() {
15347        this.facade.player.sendNotification(Notifications.PLAY, true);
15348      }
15349
15350      /** */
15351    }, {
15352      key: "contentPause",
15353      value: function contentPause() {
15354        var video = this.facade.player.mediaElement;
15355        if (video.seeking === true) {
15356          video.once("seeked", function () {
15357            video.pause();
15358          });
15359        } else {
15360          video.pause();
15361        }
15362    
15362  }
15363
15364      /** */
15365    }, {
15366      key: "contentStarted",
15367      value: function contentStarted() {}
15368
15369      /** */
15370    }, {
15371      key: "contentSeek",
15372      value: function contentSeek(time) {}
15373
15374      /** */
15375    }, {
15376      key: "contentEnded",
15377      value: function contentEnded() {}
15378
15379      /** */
15380    }, {
15381      key: "setVolume",
15382      value: function setVolume(value) {}
15383
15384      /** */
15385    }, {
15386      key: "getVolume",
15387      value: function getVolume() {}
15388
15389      /** */
15390    }, {
15391      key: "terminateAd",
15392      value: function terminateAd() {}
15393
15394      /** */
15395    }, {
15396      key: "terminateAllAds",
15397      value: function terminateAllAds() {}
15398    }], [{
15399      key: "NAME",
15400      get: function get() {
15401        return PluginProxy.NAME;
15402      }
15403    }]);
15404    return AdProxy;
15405  }(PluginProxy);
15406
15407  var AdRequest = /*#__PURE__*/function () {
15408    /**
15409     * Create an AdRequest object.
15410     *
15411     * @constructor
15412     * @param {Object} request The partner specific ad request object
15413     * @param {string} partner The partner identifier. i.e. "ima" or "freewheel"
15414     * @param {Object} config The plugin's configuration object
15415     * @param {Object} params Additional parameters to send with the ad request
15416     */
15417    function AdRequest(request, partner, config, params) {
15418      var _this = this;
15419      babelHelpers.classCallCheck(this, AdRequest);
15420      this.request = request;
15421      this.partner = partner;
15422      this.config = config;
15423      fp.each(params, function (value, key) {
15424        return _this[key] = value;
15425      });
15426    }
15427
15428    /**
15429     * Create an AdRequest object.
15430     *
15431     * @param {Object} request The partner specific ad request object
15432     * @param {string} partner The partner identifier. i.e. "ima" or "freewheel"
15433     * @param {Object} config The plugin's configuration object
15434     * @param {Object} params Additional parameters to send with the ad request
15435     * @returns {AdRequest}
15436     */
15437    babelHelpers.createClass(AdRequest, null, [{
15438      key: "create",
15439      value: function create(request, partner, config, params) {
15440        return new AdRequest(request, partner, config, params);
15441      }
15442    }]);
15443    return AdRequest;
15444  }();
15445
15446  var AdController = /*#__PURE__*/function (_PluginController) {
15447    babelHelpers.inherits(AdController, _PluginController);
15448    /**
15449     * The AdController class.
15450     *
15451     * @param {string} name
15452     * @param {Object} viewComponent
15453     * @constructor
15454     * @private
15455     * @extends {amp.plugins.ads.AdController}
15456     */
15457    function AdController() {
15458      babelHelpers.classCallCheck(this, AdController);
15459      return _PluginController.call(this, AdController.NAME) || this;
15460    }
15461
15462    /**
15463     * @static
15464     * @type {string}
15465     */
15466    babelHelpers.createClass(AdController, [{
15467      key: "listNotificationInterests",
15468      value: /** @override */
15469      function listNotificationInterests() {
15470        return [Notifications.MEDIA_CHANGE, AdNotifications.BREAK_START, AdNotifications.BREAK_END, Notifications.SEEKED, AdNotifications.AD_CONTAINER_CREATED, Notifications.REPLAY, Notifications.DESTROY];
15471      }
15472
15473      /** */
15474    }, {
15475      key: "mediachange",
15476      value: function mediachange(media) {
15477        if (this.proxy.getEnabled() === false) {
15478          return;
15479        }
15480        this.proxy.mediaChanging = true;
15481        this.proxy.engage(media);
15482      }
15483
15484      /** */
15485    }, {
15486      key: "seeked",
15487      value: function seeked(time) {
15488        this.proxy.contentSeek(time);
15489      }
15490
15491      /** */
15492    }, {
15493      key: "replay",
15494      value: function replay() {
15495        if (typeof this.proxy.replay === "function" && this.player.getAutoplay() === false) {
15496          this.proxy.replay();
15497        }
15498      }
15499
15500      /** */
15501    }, {
15502      key: "destroy",
15503      value: function destroy() {
15504        if (typeof this.proxy.destroy === "function") this.proxy.destroy();
15505      }
15506
15507      /** */
15508    }, {
15509      key: "adscontainercreated",
15510      value: function adscontainercreated(container) {
15511        this.proxy.container = container;
15512      }
15513
15514      /** */
15515    }, {
15516      key: "adsbreakstart",
15517      value: function adsbreakstart() {
15518        this.proxy.breakStart();
15519      }
15520
15521      /** */
15522    }, {
15523      key: "adsbreakend",
15524      value: function adsbreakend(adVO) {
15525        var _this = this;
15526        var rate;
15527        this.proxy.breakEnd();
15528        if ((adVO != null ? adVO.partner : void 0) === "ima") {
15529          rate = this.applicationState.getPlaybackRate();
15530          this.facade.player.setPlaybackRate(rate);
15531        }
15532        this.doAfter(function () {
15533          if (_this.applicationState.getEnded() && _this.applicationState.getHasPostContent() === true) {
15534            _this.sendNotification(Notifications.MEDIA_SEQUENCE_ENDED);
15535          }
15536        });
15537      }
15538    }], [{
15539      key: "NAME",
15540      get: function get() {
15541        return "AdController";
15542      }
15543    }]);
15544    return AdController;
15545  }(PluginController);
15546
15547  var AdEventController = /*#__PURE__*/function (_PluginController) {
15548    babelHelpers.inherits(AdEventController, _PluginController);
15549    /**
15550     * The AdEventController class.
15551     *
15552     * @param {string} name
15553     * @param {Object} viewComponent
15554     * @constructor
15555     * @private
15556     * @extends {amp.plugins.ads.AdEventController}
15557     */
15558    function AdEventController() {
15559      babelHelpers.classCallCheck(this, AdEventController);
15560      return _PluginController.call(this, AdEventController.NAME) || this;
15561    }
15562
15563    /**
15564     * @static
15565     * @type {string}
15566     */
15567    babelHelpers.createClass(AdEventController, [{
15568      key: "listNotificationInterests",
15569      value: /** @override */
15570      function listNotificationInterests() {
15571        return Object.values(AdNotifications);
15572      }
15573
15574      /**
15575       * Handles notifications of interest to this mediator.
15576       *
15577       * @param note An INotification
15578       * @override
15579       */
15580    }, {
15581      key: "handleNotification",
15582      value: function handleNotification(notification) {
15583        this.dispatchEvent(notification.getName(), notification.getBody());
15584      }
15585
15586      /** */
15587    }, {
15588      key: "dispatchEvent",
15589      value: function dispatchEvent(type, detail) {
15590        type = type.replace(/^(ads)/, "");
15591        this.sendNotification(Notifications.DISPATCH_EVENT, Event.create(type, detail));
15592        this.facade.player.sendNotification(Notifications.DISPATCH_EVENT, Event.create("ad".concat(type), detail));
15593      }
15594    }], [{
15595      key: "NAME",
15596      get: function get() {
15597        return "AdEventController";
15598      }
15599    }]);
15600    return AdEventController;
15601  }(PluginController);
15602
15603  var AdPlugin = /*#__PURE__*/function (_Plugin) {
15604    babelHelpers.inherits(AdPlugin, _Plugin);
15605    /**
15606     * The AdPlugin class.
15607     *
15608     * @param {Module}  app     The parent module of this plugin.
15609     * @constructor
15610     * @private
15611     * @extends {Plugin}
15612     */
15613    function AdPlugin() {
15614      var _this;
15615      babelHelpers.classCallCheck(this, AdPlugin);
15616      _this = _Plugin.call(this) || this;
15617      _this.feature = "ads";
15618      _this.container = null;
15619      Object.defineProperties(babelHelpers.assertThisInitialized(_this), {
15620        enabled: {
15621          get: _this.getEnabled,
15622          set: _this.setEnabled,
15623          enumerable: true,
15624          configurable: false
15625        },
15626        inProgress: {
15627          get: _this.getInProgress,
15628          enumerable: true,
15629          configurable: false
15630        },
15631        started: {
15632          get: _this.getStarted,
15633          enumerable: true,
15634          configurable: false
15635        },
15636        paused: {
15637          get: _this.getPaused,
15638          enumerable: true,
15639          configurable: false
15640        },
15641        companions: {
15642          get: _this.getCompanions,
15643          enumerable: true,
15644          configurable: false
15645        },
15646        currentAd: {
15647          get: _this.getCurrentAd,
15648          enumerable: true,
15649          configurable: false
15650        }
15651      });
15652      return _this;
15653    }
15654
15655    /**
15656     * @static
15657     * @type {string}
15658     */
15659    babelHelpers.createClass(AdPlugin, [{
15660      key: "createModel",
15661      value: /** @override */
15662      function createModel() {
15663        this.proxy = this.isFullscreenDevice() ? this.createFullscreenProxy() : this.createProxy();
15664        this.registerProxy(this.proxy);
15665      }
15666
15667      /** @override */
15668    }, {
15669      key: "createController",
15670      value: function createController() {
15671        babelHelpers.get(babelHelpers.getPrototypeOf(AdPlugin.prototype), "createController", this).call(this);
15672        this.registerMediator(new AdController());
15673        this.registerMediator(new AdEventController());
15674      }
15675    }, {
15676      key: "isFullscreenDevice",
15677      value: function isFullscreenDevice() {
15678        return Utils.isFullscreenDevice();
15679      }
15680    }, {
15681      key: "createProxy",
15682      value: function createProxy() {}
15683    }, {
15684      key: "createFullscreenProxy",
15685      value: function createFullscreenProxy() {}
15686
15687      /** */
15688    }, {
15689      key: "listNotificationInterests",
15690      value: function listNotificationInterests() {
15691        return [Notifications.MEDIA_CHANGE, Notifications.REPLAY, Notifications.PLAY, Notifications.PAUSE, Notifications.PAUSED, Notifications.START, Notifications.STARTED, Notifications.ENDED, Notifications.READY, Notifications.VOLUME_CHANGE, Notifications.FULL_SCREEN_CHANGE, Notifications.CHANGE_ACTIVE_STATE, Notifications.PLAY_STATE_CHANGE, Notifications.SEEKED, Notifications.TOGGLE_PLAY_PAUSE, Notifications.DESTROY];
15692      }
15693
15694      /** */
15695    }, {
15696      key: "listNotificationPublications",
15697      value: function listNotificationPublications() {
15698        return babelHelpers.get(babelHelpers.getPrototypeOf(AdPlugin.prototype), "listNotificationPublications", this).call(this).concat(Object.values(AdNotifications)).concat([Notifications.REQUEST_PLAY, Notifications.DISPLAY_TIME, Notifications.DISABLE_FULL_SCREEN, Notifications.ENABLE_VIDEO_EVENTS, Notifications.DISABLE_VIDEO_EVENTS, Notifications.HAS_POST_CONTENT, Notifications.MEDIA_SEQUENCE_ENDED, Notifications.CHANGE_PLAY_STATE, Notifications.AUTOPLAY_BLOCKED]);
15699      }
15700
15701      /**
15702       * @param {boolean} value The enabled flag.
15703       * @expose
15704       */
15705    }, {
15706      key: "setEnabled",
15707      value: function setEnabled(value) {
15708        this.proxy.setEnabled(value);
15709      }
15710
15711      /**
15712       * @return {boolean} The enabled flag.
15713       * @expose
15714       */
15715    }, {
15716      key: "getEnabled",
15717      value: function getEnabled() {
15718        return this.proxy.getEnabled();
15719      }
15720
15721      /**
15722       * @return {boolean} The in progress flag.
15723       * @expose
15724       */
15725    }, {
15726      key: "getInProgress",
15727      value: function getInProgress() {
15728        return this.proxy.getInProgress();
15729      }
15730
15731      /**
15732       * @return {boolean} The started flag.
15733       * @expose
15734       */
15735    }, {
15736      key: "getStarted",
15737      value: function getStarted() {
15738        return this.proxy.getStarted();
15739      }
15740
15741      /**
15742       * @return {boolean} The paused flag.
15743       * @expose
15744       */
15745    }, {
15746      key: "getPaused",
15747      value: function getPaused() {
15748        return this.proxy.getPaused();
15749      }
15750
15751      /**
15752       * @return {Array.<Object>} The list of companion ads.
15753       * @expose
15754       */
15755    }, {
15756      key: "getCompanions",
15757      value: function getCompanions() {
15758        return this.proxy.getCompanions();
15759      }
15760
15761      /**
15762       * @return {Array.<Object>} The list of companion ads.
15763       * @expose
15764       */
15765    }, {
15766      key: "getCurrentAd",
15767      value: function getCurrentAd() {
15768        return this.proxy.adVO;
15769      }
15770
15771      /**
15772       * @expose
15773       */
15774    }, {
15775      key: "setPodLocks",
15776      value: function setPodLocks(pods) {
15777        this.proxy.setPodLocks(pods);
15778      }
15779
15780      /**
15781       * @expose
15782       */
15783    }, {
15784      key: "resize",
15785      value: function resize(state) {
15786        this.proxy.resize(state);
15787      }
15788
15789      /**
15790       * @expose
15791       */
15792    }, {
15793      key: "terminateAd",
15794      value: function terminateAd() {
15795        this.proxy.terminateAd();
15796      }
15797
15798      /**
15799       * @expose
15800       */
15801    }, {
15802      key: "terminateAllAds",
15803      value: function terminateAllAds() {
15804        this.proxy.terminateAllAds();
15805      }
15806
15807      /**
15808       * @expose
15809       */
15810    }, {
15811      key: "requestAd",
15812      value: function requestAd() {
15813        this.proxy.start(false);
15814      }
15815    }], [{
15816      key: "NAME",
15817      get: function get() {
15818        return "AdPlugin";
15819      }
15820    }]);
15821    return AdPlugin;
15822  }(Plugin);
15823
15824  var PluginMediator = /*#__PURE__*/function (_OverlayMediator) {
15825    babelHelpers.inherits(PluginMediator, _OverlayMediator);
15826    /**
15827     * PluginMediator class.
15828     *
15829     * @constructor
15830     * @private
15831     * @extends {OverlayMediator}
15832     */
15833    function PluginMediator(name) {
15834      babelHelpers.classCallCheck(this, PluginMediator);
15835      return _OverlayMediator.call(this, name) || this;
15836    }
15837
15838    /** @override */
15839    babelHelpers.createClass(PluginMediator, [{
15840      key: "initializeNotifier",
15841      value: function initializeNotifier(key) {
15842        babelHelpers.get(babelHelpers.getPrototypeOf(PluginMediator.prototype), "initializeNotifier", this).call(this, key);
15843        this.plugin = this.facade.retrieveProxy(ModuleProxy.NAME);
15844        this.media = this.facade.player.retrieveProxy(MediaProxy.NAME);
15845      }
15846
15847      /** @override */
15848    }, {
15849      key: "onRegister",
15850      value: function onRegister() {
15851        babelHelpers.get(babelHelpers.getPrototypeOf(PluginMediator.prototype), "onRegister", this).call(this);
15852        this.facade.viewComponent = this.viewComponent;
15853      }
15854    }]);
15855    return PluginMediator;
15856  }(OverlayMediator);
15857
15858  var CaptioningMediator = /*#__PURE__*/function (_PluginMediator) {
15859    babelHelpers.inherits(CaptioningMediator, _PluginMediator);
15860    /**
15861     * The CaptioningMediator class.
15862     *
15863     * @constructor
15864     * @private
15865     * @extends {PluginMediator}
15866     * @param {Object} viewComponent
15867     */
15868    function CaptioningMediator() {
15869      babelHelpers.classCallCheck(this, CaptioningMediator);
15870      return _PluginMediator.call(this, "captioning") || this;
15871    }
15872
15873    /**
15874     * @override
15875     */
15876    babelHelpers.createClass(CaptioningMediator, [{
15877      key: "onRegister",
15878      value: function onRegister() {
15879        babelHelpers.get(babelHelpers.getPrototypeOf(CaptioningMediator.prototype), "onRegister", this).call(this);
15880        //Creating Dynaic Class Injection to DOM
15881        this.captioningStyle = this.create(null, this.viewComponent, "style");
15882        this.captioningStyle.type = "text/css";
15883        this.applyStyles();
15884      }
15885
15886      /**
15887       * @override
15888       */
15889    }, {
15890      key: "listNotificationInterests",
15891      value: function listNotificationInterests() {
15892        return [CaptioningNotifications.VISIBILITY_CHANGE, CaptioningNotifications.ENABLED, CaptioningNotifications.TRACK_SELECTED, Notifications.SETTINGS_CHANGE];
15893      }
15894
15895      /** @override */
15896    }, {
15897      key: "onRemove",
15898      value: function onRemove() {
15899        if (this.captioningStyle) {
15900          this.viewComponent.removeChild(this.captioningStyle);
15901        }
15902      }
15903
15904      /**
15905       * @override
15906       */
15907    }, {
15908      key: "handleNotification",
15909      value: function handleNotification(notification) {
15910        var body = notification.getBody();
15911        var note = body ? Notifications.ADD_APPLICATION_STATE : Notifications.REMOVE_APPLICATION_STATE;
15912        var state;
15913        switch (notification.getName()) {
15914          case CaptioningNotifications.TRACK_SELECTED:
15915            state = "cc-embedded";
15916            note = body.type === "embedded" ? Notifications.ADD_APPLICATION_STATE : Notifications.REMOVE_APPLICATION_STATE;
15917            break;
15918          case CaptioningNotifications.VISIBILITY_CHANGE:
15919            state = "cc-active";
15920            break;
15921          case CaptioningNotifications.ENABLED:
15922            note = body ? Notifications.ADD_CONTROL_STATE : Notifications.REMOVE_CONTROL_STATE;
15923            state = "cc-enabled";
15924            if (!body) {
15925              this.sendNotification(Notifications.REMOVE_APPLICATION_STATE, "cc-active");
15926            }
15927            break;
15928          case Notifications.SETTINGS_CHANGE:
15929            if (body.captions != null) {
15930              this.applyStyles();
15931            }
15932        }
15933        if (state != null) {
15934          this.sendNotification(note, state);
15935        }
15936      }
15937    }, {
15938      key: "applyStyles",
15939      value: function applyStyles() {
15940        var settings = this.facade.settings;
15941        var styles = this.facade.settings.styles;
15942        var windowStyles = CSS.toCSS(styles.window, true, "\n");
15943        var textStyles = CSS.toCSS(styles.text, true, "\n");
15944        var id = "#" + this.facade.player.viewComponent.id;
15945        if (settings.visible != null) {
15946          this.facade.hidden = !settings.visible;
15947        }
15948
15949        // all of these rules need to be defined individually because if
15950        // one of the selectors is invalid the entire rule will be ignored
15951        var rules = "".concat(id, " .amp-caption {").concat(windowStyles, "}\n") + "".concat(id, " .amp-caption p, ").concat(id, " .amp-caption span {").concat(textStyles, "}\n");
15952
15953        // Chrome does not provide a "window" div, so we merge the two sets of styles
15954        if (Utils.isChrome()) {
15955          rules += "".concat(id, " video::cue {").concat(textStyles).concat(windowStyles, "}\n");
15956        } else {
15957          rules += "".concat(id, " video::-webkit-media-text-track-display-backdrop {").concat(windowStyles, "}\n") + "".concat(id, " video::cue {").concat(textStyles, "}\n") + "".concat(id, " video::-webkit-media-text-track-display span {").concat(textStyles, "}");
15958        }
15959        this.captioningStyle.innerHTML = rules;
15960      }
15961    }]);
15962    return CaptioningMediator;
15963  }(PluginMediator);
15964
15965  var CaptioningHTMLMediator = /*#__PURE__*/function (_ComponentMediator) {
15966    babelHelpers.inherits(CaptioningHTMLMediator, _ComponentMediator);
15967    /**
15968     * The CaptioningHTMLMediator class.
15969     *
15970     * @constructor
15971     * @private
15972     * @extends {LocalizedMediator}
15973     * @param {Object} viewComponent
15974     */
15975    function CaptioningHTMLMediator(viewComponent) {
15976      var _this;
15977      babelHelpers.classCallCheck(this, CaptioningHTMLMediator);
15978      _this = _ComponentMediator.call(this, CaptioningHTMLMediator.NAME, null, viewComponent) || this;
15979      _this.proxy = null;
15980      _this.handleInline = _this.handleInline.bind(babelHelpers.assertThisInitialized(_this));
15981      _this.inlineTypes = [Utils.mimeTypes.vtt, Utils.mimeTypes.cea608, Utils.mimeTypes.cea708, Utils.mimeTypes.ttml];
15982      _this.current = [];
15983      return _this;
15984    }
15985
15986    /** @static */
15987    babelHelpers.createClass(CaptioningHTMLMediator, [{
15988      key: "getRendererName",
15989      value: /** */
15990      function getRendererName() {
15991        return "html";
15992      }
15993
15994      /** @override */
15995    }, {
15996      key: "onRegister",
15997      value: function onRegister() {
15998        babelHelpers.get(babelHelpers.getPrototypeOf(CaptioningHTMLMediator.prototype), "onRegister", this).call(this);
15999        this.proxy = this.facade.retrieveProxy(CaptioningProxy.NAME);
16000        var track = this.proxy.getTrack();
16001        if (track == null) return;
16002        var cues = track.activeCues;
16003        if (cues.length > 0) {
16004          this.render(cues);
16005        }
16006        this.initInline();
16007      }
16008
16009      /** */
16010    }, {
16011      key: "onRemove",
16012      value: function onRemove() {
16013        this.clear();
16014      }
16015
16016      /** */
16017    }, {
16018      key: "canUseResource",
16019      value: function canUseResource(resource) {
16020        if (resource == null) {
16021          return false;
16022        }
16023        var types = [Utils.mimeTypes.srt, Utils.mimeTypes.ttml].concat(this.inlineTypes);
16024        return types.includes(resource.type);
16025      }
16026
16027      /** */
16028    }, {
16029      key: "initInline",
16030      value: function initInline() {
16031        var textTrack = this.proxy.getTextTrack();
16032        var track = this.proxy.track;
16033        var isSidecar = function isSidecar(track) {
16034          return !!track.src;
16035        };
16036        var isTrackInactive = function isTrackInactive(track) {
16037          return textTrack.language !== track.language || textTrack.kind !== track.kind;
16038        };
16039        if (!track || !textTrack || !this.inlineTypes.includes(track.type)) {
16040          return;
16041        }
16042        track.enabled = true;
16043        if (this.proxy.getHidden() || isSidecar(track)) {
16044          this.disableTrack(textTrack);
16045        } else {
16046          this.hideTrack(textTrack);
16047        }
16048        fp.transform(this.proxy.getTextTracks(), fp.filter(function (track) {
16049          return regex.test(track.kind) && isTrackInactive(track);
16050        }), fp.map(this.disableTrack.bind(this)));
16051        this.handleInline({
16052          target: textTrack
16053        });
16054      }
16055    }, {
16056      key: "disableTrack",
16057      value: function disableTrack(track) {
16058        track.removeEventListener("cuechange", this.handleInline, true);
16059        track.mode = TrackMode.DISABLED;
16060      }
16061    }, {
16062      key: "hideTrack",
16063      value: function hideTrack(track) {
16064        var player = this.facade.player;
16065        track.addEventListener("cuechange", this.handleInline, true);
16066        // Show & Hide to propagate the track selection across cores
16067        track.mode = TrackMode.SHOWING;
16068        player.timers.setTimeout(function () {
16069          return track.mode = TrackMode.HIDDEN;
16070        }, 10);
16071      }
16072
16073      /** */
16074    }, {
16075      key: "handleInline",
16076      value: function handleInline(event) {
16077        var target = event.target;
16078        // Fix AMPWEB-2330: IE11 ensure hidden track mode 
16079        target.mode = TrackMode.HIDDEN;
16080        if (target.activeCues == null) return;
16081        var cues = this.convertCues(target.activeCues);
16082        this.sendNotification(CaptioningNotifications.CHANGE_CUE, cues);
16083      }
16084
16085      /**
16086       * Convert VTTCue to Caption Cue
16087       */
16088    }, {
16089      key: "convertCues",
16090      value: function convertCues(activeCues) {
16091        return Array.from(activeCues, function (cue) {
16092          var text = cue.text;
16093          // ignore JSON cue points
16094          if (/^\{\".*}$/.test(text)) return;
16095          cue.html = WebVTTParser.createHTML(text);
16096          return cue;
16097        }).filter(function (cue) {
16098          return !!cue;
16099        });
16100      }
16101
16102      /**
16103       * Computes CSS styles based on VTT settings.
16104       *
16105       * @param {CaptionCue}	cue - The vtt cue point
16106       * @param {Number}	offset - The line number offset
16107       *
16108       * @return {Object}
16109       */
16110    }, {
16111      key: "computeStyles",
16112      value: function computeStyles(cue) {
16113        var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
16114        var length = arguments.length > 2 ? arguments[2] : undefined;
16115        var bounds = arguments.length > 3 ? arguments[3] : undefined;
16116        var parseValue = function parseValue(value) {
16117          var dflt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
16118          value = parseInt(value);
16119          return isNaN(value) ? dflt : value;
16120        };
16121        var toPercent = function toPercent(value) {
16122          return "".concat(value, "%");
16123        };
16124        var styles = {
16125          position: "relative",
16126          overflow: "hidden",
16127          minWidth: "min-content"
16128        };
16129
16130        // values
16131        var align = cue.align || "middle";
16132        var pos = parseValue(cue.position, "auto");
16133        var size = parseValue(cue.size);
16134        var line = parseValue(cue.line, "auto");
16135        var auto = pos == "auto";
16136
16137        // alignment
16138        switch (align) {
16139          case "left":
16140          case "start":
16141            styles.textAlign = "start";
16142            if (auto) pos = 0;
16143            break;
16144          case "middle":
16145          case "center":
16146            styles.textAlign = "center";
16147            if (auto) pos = (100 - size) / 2;
16148            break;
16149          case "right":
16150          case "end":
16151            styles.textAlign = "end";
16152            if (auto) pos = 100;
16153            break;
16154        }
16155
16156        // position
16157        styles.left = toPercent(pos);
16158
16159        // size
16160        if (!auto && size === 100) {
16161          size = size - pos;
16162        }
16163        styles.width = toPercent(size);
16164
16165        // line
16166        if (line < 0 || line > 100) {
16167          line = 100;
16168        } else if (line === "auto") {
16169          line = 100 - offset;
16170        }
16171        if (cue.snapToLines === true) {
16172          styles.top = "".concat(line * (bounds.height + 1), "px");
16173        } else {
16174          // increase the last cue flex-basis to accomodate cues on top of main axis 
16175          var computedLine = 100 - line;
16176          var basis = "auto";
16177          if (computedLine > 1 && offset === length - 1) {
16178            basis = toPercent(computedLine);
16179          }
16180          styles.flex = "0 1 ".concat(basis);
16181        }
16182        if (cue.visible === false) styles.visibility = "hidden";
16183        return styles;
16184      }
16185
16186      /**
16187       * Adjust the caption position to fit inside viewable area
16188       *
16189       * @param {DOMElement}	element - The caption DOM element
16190       * @param {Object}	bounds - The bounding rect
16191       */
16192    }, {
16193      key: "adjustCaption",
16194      value: function adjustCaption(element, bounds) {
16195        // adjust positioning
16196        var rect = element.getBoundingClientRect();
16197        var style = element.style;
16198        if (rect.bottom > bounds.bottom) {
16199          style.top = "0%";
16200          style.bottom = "auto";
16201          style.flex = "";
16202        }
16203        if (rect.right > bounds.right) {
16204          style.left = "auto";
16205          style.right = "0%";
16206          style.marginLeft = 'auto';
16207        }
16208      }
16209
16210      /**
16211       * @override
16212       */
16213    }, {
16214      key: "listNotificationInterests",
16215      value: function listNotificationInterests() {
16216        return [CaptioningNotifications.CUE_CHANGE, CaptioningNotifications.TRACK_SELECTED, CaptioningNotifications.VISIBILITY_CHANGE, Notifications.TEXT_TRACK_ADDED, Notifications.CHANGE_MEDIA, Notifications.LOADED_METADATA, Notifications.CAN_PLAY_THROUGH];
16217      }
16218
16219      /**
16220       * @override
16221       */
16222    }, {
16223      key: "handleNotification",
16224      value: function handleNotification(notification) {
16225        var name = notification.getName();
16226        var body = notification.getBody();
16227        this.viewComponent;
16228        switch (name) {
16229          case Notifications.CHANGE_MEDIA:
16230            this.clear();
16231            break;
16232          case CaptioningNotifications.CUE_CHANGE:
16233            this.render(body);
16234            break;
16235          case CaptioningNotifications.VISIBILITY_CHANGE:
16236          case CaptioningNotifications.TRACK_SELECTED:
16237          case Notifications.LOADED_METADATA:
16238          case Notifications.CAN_PLAY_THROUGH:
16239          case Notifications.TEXT_TRACK_ADDED:
16240            this.initInline();
16241            break;
16242        }
16243      }
16244
16245      /**
16246       * Clear cues.
16247       */
16248    }, {
16249      key: "clear",
16250      value: function clear() {
16251        this.viewComponent.innerHTML = "";
16252        this.elements = null;
16253      }
16254
16255      /**
16256       * createCaption
16257       *
16258       * @param {type}	cue - this is the parameter cue
16259       * @param {type}	offset - this is the parameter offset
16260       *
16261       */
16262    }, {
16263      key: "createCaption",
16264      value: function createCaption(cue, offset) {
16265        var lines = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
16266        var line = arguments.length > 3 ? arguments[3] : undefined;
16267        return this.viewComponent.appendChild(UI.createElement({
16268          "class": "amp-caption-area",
16269          style: this.computeStyles(cue, offset, lines, line),
16270          children: [{
16271            "class": "amp-caption",
16272            innerHTML: cue.html
16273          }]
16274        }));
16275      }
16276
16277      /**
16278       *
16279       */
16280    }, {
16281      key: "getLineBounds",
16282      value: function getLineBounds() {
16283        var element = this.createCaption({
16284          html: "CUE",
16285          visible: false
16286        }, 0);
16287        var rect = element.getBoundingClientRect();
16288        this.viewComponent.removeChild(element);
16289        return rect;
16290      }
16291
16292      /**
16293       * Loop through the cues and pull out the ones that need
16294       * to be auto aligned and return a single multi-line cue.
16295       */
16296    }, {
16297      key: "processCues",
16298      value: function processCues(cues) {
16299        var results = cues.slice();
16300        var len = cues.length;
16301        var i = 0;
16302        var text = "";
16303        while (i < len) {
16304          var cue = results[i];
16305          var line = cue.line;
16306          if (line == "auto" || line >= 100 || line < 0) line = 100;
16307          if (line != 100) {
16308            ++i;
16309            continue;
16310          }
16311          results.splice(i, 1);
16312          len--;
16313          text += cue.text + "\n";
16314        }
16315        if (text.length > 0) results.push({
16316          text: text,
16317          html: WebVTTParser.createHTML(text),
16318          line: 100
16319        });
16320        return results;
16321      }
16322
16323      /**
16324       * Renders cue points.
16325       *
16326       * @param {Array.<CaptionCue>}	cues - this is the parameter cues
16327       *
16328       */
16329    }, {
16330      key: "render",
16331      value: function render(cues) {
16332        var _this2 = this;
16333        var settings = this.facade.player.settings.captions || {};
16334        settings.scroll = settings.scroll.toLowerCase().replace("-", "");
16335        switch (settings.scroll) {
16336          case "rollon":
16337            this.classList.add("captioning-roll");
16338            this.classList.remove("captioning-typed");
16339          case "painton":
16340            var exist = function exist(cue) {
16341              return _this2.current == cue;
16342            };
16343            var active = cues.filter(exist).length > 0;
16344            var length = cues.length - 1;
16345            if (active) return; // no need to update if cue is active
16346            else if (length < 0) return this.clear();
16347            this.current = cues[length];
16348            if (settings.scroll !== "painton") break;
16349            this.classList.add("captioning-typed");
16350            this.classList.remove("captioning-roll");
16351            break;
16352          default:
16353            this.classList.remove("captioning-roll");
16354            this.classList.remove("captioning-typed");
16355            break;
16356        }
16357        this.clear();
16358        var bounds = this.viewComponent.getBoundingClientRect();
16359        var line = this.getLineBounds();
16360        var len = cues.length - 1;
16361        this.elements = fp.transform(this.processCues(cues), fp.map(function (cue) {
16362          return _this2.createCaption(cue, len--, cues.length, line);
16363        }), fp.map(function (caption) {
16364          return _this2.adjustCaption(caption, bounds);
16365        }));
16366      }
16367    }], [{
16368      key: "NAME",
16369      get: function get() {
16370        return CaptioningProxy.TEXT_TRACK_RENDERER;
16371      }
16372    }]);
16373    return CaptioningHTMLMediator;
16374  }(ComponentMediator);
16375
16376  var CaptioningNativeMediator = /*#__PURE__*/function (_LocalizedMediator) {
16377    babelHelpers.inherits(CaptioningNativeMediator, _LocalizedMediator);
16378    /**
16379     * The CaptioningMediator class.
16380     *
16381     * @constructor
16382     * @private
16383     * @extends {PluginMediator}
16384     * @param {Object} viewComponent
16385     */
16386    function CaptioningNativeMediator(viewComponent) {
16387      var _this;
16388      babelHelpers.classCallCheck(this, CaptioningNativeMediator);
16389      _this = _LocalizedMediator.call(this, CaptioningNativeMediator.NAME, viewComponent) || this;
16390      _this.proxy = null;
16391      _this.track = null;
16392      _this.handleInline = _this.handleInline.bind(babelHelpers.assertThisInitialized(_this));
16393      return _this;
16394    }
16395
16396    /** @static */
16397    babelHelpers.createClass(CaptioningNativeMediator, [{
16398      key: "getRendererName",
16399      value: /** */
16400      function getRendererName() {
16401        return "native";
16402      }
16403
16404      /** */
16405    }, {
16406      key: "canUseResource",
16407      value: function canUseResource(resource) {
16408        if (resource == null) {
16409          return false;
16410        }
16411        var hasNative = document.createElement("video").textTracks != null;
16412        if (!hasNative) {
16413          return false;
16414        }
16415        var types = [Utils.mimeTypes.vtt, Utils.mimeTypes.cea608, Utils.mimeTypes.cea708];
16416        var useNative = /iphone|ipad/.test(Utils.getDevice());
16417        if (!useNative) {
16418          return false;
16419        }
16420        return types.indexOf(resource.type) !== -1;
16421      }
16422
16423      /**
16424       * @override
16425       */
16426    }, {
16427      key: "onRegister",
16428      value: function onRegister() {
16429        this.proxy = this.facade.retrieveProxy(CaptioningProxy.NAME);
16430        this.loadTracks();
16431        this.updateTrack();
16432      }
16433
16434      /**
16435        * @override
16436        */
16437    }, {
16438      key: "onRemove",
16439      value: function onRemove() {
16440        this.unloadTracks();
16441      }
16442
16443      /**
16444       * @override
16445       */
16446    }, {
16447      key: "listNotificationInterests",
16448      value: function listNotificationInterests() {
16449        return [CaptioningNotifications.VISIBILITY_CHANGE, CaptioningNotifications.TRACK_SELECTED, Notifications.LOADED_METADATA, Notifications.CAN_PLAY_THROUGH];
16450      }
16451
16452      /**
16453       * @override
16454       */
16455    }, {
16456      key: "handleNotification",
16457      value: function handleNotification(notification) {
16458        notification.getBody();
16459        switch (notification.getName()) {
16460          case CaptioningNotifications.TRACK_SELECTED:
16461          case CaptioningNotifications.VISIBILITY_CHANGE:
16462          case Notifications.CAN_PLAY_THROUGH:
16463            this.updateTrack();
16464            break;
16465          case Notifications.LOADED_METADATA:
16466            this.loadTracks();
16467        }
16468      }
16469    }, {
16470      key: "unloadTracks",
16471      value: function unloadTracks() {
16472        this.proxy.getTextTracks().forEach(function (track) {
16473          return track.mode = TrackMode.HIDDEN;
16474        });
16475        var mediaElement = this.facade.player.getMediaElement();
16476        var tracks = Array.from(mediaElement.children);
16477        tracks.forEach(function (track) {
16478          return mediaElement.removeChild(track);
16479        });
16480      }
16481    }, {
16482      key: "loadTracks",
16483      value: function loadTracks() {
16484        this.unloadTracks();
16485        var tracks = this.proxy.getTracks();
16486        if (tracks == null) {
16487          return;
16488        }
16489        var mediaElement = this.facade.player.getMediaElement();
16490        var crossorigin = this.proxy.getCrossOrigin();
16491        if (crossorigin != null) {
16492          mediaElement.setAttribute("crossorigin", crossorigin);
16493        }
16494        tracks.forEach(function (track) {
16495          if (track.type !== Utils.mimeTypes.vtt) {
16496            return;
16497          }
16498          var element = document.createElement("track");
16499          element.src = track.src;
16500          if (track.kind != null) {
16501            element.kind = track.kind;
16502          }
16503          if (track.language != null) {
16504            element.srclang = track.language;
16505          }
16506          if (track.label != null) {
16507            element.label = track.label;
16508          }
16509          element["default"] = track["default"];
16510          mediaElement.appendChild(element);
16511        });
16512      }
16513    }, {
16514      key: "updateTrack",
16515      value: function updateTrack() {
16516        // hide the previously selected track
16517        if (this.track != null) {
16518          this.track.mode = TrackMode.HIDDEN;
16519        }
16520        // hide all <video> media text tracks avail
16521        this.proxy.getTextTracks().forEach(function (track) {
16522          return track.mode = TrackMode.HIDDEN;
16523        });
16524        var track = this.proxy.getTextTrack();
16525        if (track) {
16526          this.track = track;
16527          if (this.proxy.getHidden()) {
16528            this.track.removeEventListener("cuechange", this.handleInline, true);
16529            this.track.mode = TrackMode.HIDDEN;
16530          } else {
16531            this.track.addEventListener("cuechange", this.handleInline, true);
16532            this.track.mode = TrackMode.SHOWING;
16533          }
16534        }
16535      }
16536
16537      /** */
16538    }, {
16539      key: "handleInline",
16540      value: function handleInline(event) {
16541        this.sendNotification(CaptioningNotifications.CHANGE_CUE, Array.from(event.target.activeCues));
16542      }
16543    }], [{
16544      key: "NAME",
16545      get: function get() {
16546        return CaptioningProxy.TEXT_TRACK_RENDERER;
16547      }
16548    }]);
16549    return CaptioningNativeMediator;
16550  }(LocalizedMediator);
16551
16552  var LiveCaptionProxy = /*#__PURE__*/function (_puremvc$Proxy) {
16553    babelHelpers.inherits(LiveCaptionProxy, _puremvc$Proxy);
16554    /**
16555     * @constructor
16556     * @private
16557     */
16558    function LiveCaptionProxy() {
16559      var _this;
16560      babelHelpers.classCallCheck(this, LiveCaptionProxy);
16561      _this = _puremvc$Proxy.call(this, LiveCaptionProxy.NAME) || this;
16562      _this.captions = [];
16563      _this.head = document.getElementsByTagName("head")[0];
16564      //create JSONP callback
16565      var com = window.com || {};
16566      com.akamai = com.akamai || {};
16567      com.akamai.amp = com.akamai.amp || {};
16568      com.akamai.amp.plugins = com.akamai.amp.plugins || {};
16569      com.akamai.amp.plugins.subply = com.akamai.amp.plugins.subply || {};
16570      com.akamai.amp.plugins.subply.response = function (json) {
16571        _this.parse(json);
16572        _this.poll();
16573      };
16574      if (window.com == null) {
16575        window.com = com;
16576      }
16577      _this.data = {
16578        base: "http://test.plymedia.com.s3.amazonaws.com/online/Akamai_",
16579        interval: 1000
16580      };
16581      _this.caption = null;
16582      _this.head = null;
16583      _this.script = null;
16584      _this.timeout = null;
16585      return _this;
16586    }
16587
16588    /**
16589     *
16590     */
16591    babelHelpers.createClass(LiveCaptionProxy, [{
16592      key: "getURL",
16593      value: function getURL() {
16594        return this.data.url;
16595      }
16596    }, {
16597      key: "setURL",
16598      value: function setURL(value) {
16599        this.data.url = value;
16600        return value;
16601      }
16602    }, {
16603      key: "start",
16604      value: function start() {
16605        this.send();
16606      }
16607    }, {
16608      key: "poll",
16609      value: function poll() {
16610        var _this2 = this;
16611        this.facade.player.timers.setTimeout(function () {
16612          _this2.send();
16613        }, this.data.interval || 1000);
16614      }
16615    }, {
16616      key: "send",
16617      value: function send() {
16618        var _this3 = this;
16619        if (this.script != null) {
16620          this.head.removeChild(this.script);
16621        }
16622        this.script = Utils.loadScript(this.data.base + this.data.url + ".js?nocache=" + Date.now()).then(function (script) {
16623          return _this3.script = script;
16624        })["catch"](function (error) {
16625          return _this3.facade.logger.error("[AMP CAPTIONING ERROR]", error);
16626        });
16627      }
16628    }, {
16629      key: "stop",
16630      value: function stop() {
16631        clearTimeout(timeout);
16632      }
16633
16634      /**
16635       *
16636       */
16637    }, {
16638      key: "parse",
16639      value: function parse(response) {
16640        if (response.Stream !== this.data.url) {
16641          return;
16642        }
16643        if (this.caption != null && this.caption.id >= response.Ticks) {
16644          return;
16645        }
16646        this.caption = new CaptionCue(Utils.flattenTimecode(response.From), Utils.flattenTimecode(response.To), response.Ticks);
16647        this.caption.text = response.Text;
16648        html = "";
16649        fp.each(response.Text.split("\n"), function (text) {
16650          if (html !== "") {
16651            html += "<br />";
16652          }
16653          html += "<span>" + text + "</span>";
16654        });
16655        this.caption.html = "<p>" + html + "</p>";
16656        this.sendNotification(CaptioningNotifications.CUE_CHANGE, [this.caption]);
16657        return this.caption;
16658      }
16659    }]);
16660    return LiveCaptionProxy;
16661  }(puremvc.Proxy);
16662
16663  /** @static */
16664  LiveCaptionProxy.NAME = "LiveCaptionProxy";
16665
16666  var TTMLCaptionProxy = /*#__PURE__*/function (_puremvc$Proxy) {
16667    babelHelpers.inherits(TTMLCaptionProxy, _puremvc$Proxy);
16668    /**
16669     * @constructor
16670     * @private
16671     */
16672    function TTMLCaptionProxy() {
16673      var _this;
16674      babelHelpers.classCallCheck(this, TTMLCaptionProxy);
16675      _this = _puremvc$Proxy.call(this, TTMLCaptionProxy.NAME) || this;
16676      _this.parser = new SMPTETTParser();
16677      return _this;
16678    }
16679    babelHelpers.createClass(TTMLCaptionProxy, [{
16680      key: "create",
16681      value: function create(value, notification) {
16682        var xml = value.data;
16683        var track = this.facade.getTrack();
16684        fp.each(this.parseToCues(xml), function (cue, index) {
16685          this.cues.push(cue);
16686        }.bind(track));
16687      }
16688    }, {
16689      key: "parseToCues",
16690      value: function parseToCues(xml) {
16691        var track,
16692          hasError = false;
16693        try {
16694          track = this.parser.parse(xml);
16695          if (track.cues == null || !track.cues instanceof Array) throw "property 'cues' is undefined";
16696        } catch (error) {
16697          this.dispatch("error", "Could not parse ttml caption track", error);
16698          Logger.instance.error("Could not parse ttml caption track", error);
16699          hasError = true;
16700        }
16701        if (hasError) return new Array();
16702        return track.cues;
16703      }
16704    }]);
16705    return TTMLCaptionProxy;
16706  }(puremvc.Proxy);
16707
16708  /** @static */
16709  TTMLCaptionProxy.NAME = "TTMLCaptionProxy";
16710
16711  var CaptioningController = /*#__PURE__*/function (_PluginController) {
16712    babelHelpers.inherits(CaptioningController, _PluginController);
16713    /**
16714     * The AdContentController class.
16715     *
16716     * @param {string} name
16717     * @param {Object} viewComponent
16718     * @constructor
16719     * @private
16720     * @extends {amp.plugins.ads.AdContentController}
16721     */
16722    function CaptioningController() {
16723      babelHelpers.classCallCheck(this, CaptioningController);
16724      return _PluginController.call(this, CaptioningController.NAME) || this;
16725    }
16726
16727    /**
16728     * @static
16729     * @type {string}
16730     */
16731    babelHelpers.createClass(CaptioningController, [{
16732      key: "listNotificationInterests",
16733      value: /** @override */
16734      function listNotificationInterests() {
16735        return [Notifications.CHANGE_MEDIA, Notifications.STARTED, Notifications.TIME_UPDATE, Notifications.TEXT_TRACK_ADDED, CaptioningNotifications.VISIBILITY_CHANGE, CaptioningNotifications.ENABLED, CaptioningNotifications.CHANGE_CUE, CaptioningNotifications.TRACK_SELECTED, CaptioningNotifications.TRACKS_LOADED, CaptioningNotifications.CUE_CHANGE, CaptioningNotifications.TTML_CUE_CHANGE];
16736      }
16737
16738      /** */
16739    }, {
16740      key: "changemedia",
16741      value: function changemedia(media) {
16742        this.proxy.setMapper(CaptionMapper.AUTO);
16743        if (media.track && media.track.length) {
16744          this.proxy.setMapper(CaptionMapper.MANUAL);
16745        }
16746        this.proxy.setTracks(media.track);
16747        this.proxy.selectRenderer(media);
16748        this.sendNotification(CaptioningNotifications.ENABLED, true);
16749        this.sendNotification(Notifications.TEXT_TRACK_ADDED, {});
16750      }
16751
16752      /** */
16753    }, {
16754      key: "started",
16755      value: function started() {
16756        var _this = this;
16757        var tracks = this.proxy.getTracks();
16758        var proxy = this.proxy;
16759        var track = proxy.getTrack();
16760        if (track == null && tracks.length > 0) {
16761          track = proxy.autoSelectTrack();
16762        }
16763        if (track == null) return;
16764        if (track.isLive === true) {
16765          proxy = this.facade.retrieveProxy(LiveCaptionProxy.NAME);
16766          if (proxy == null) {
16767            proxy = new LiveCaptionProxy();
16768            this.facade.registerProxy(proxy);
16769          }
16770          proxy.setURL(track.src);
16771          proxy.start();
16772        }
16773        fp.find(tracks, fp.filter(function (track) {
16774          return track.type === Utils.mimeTypes.ttml;
16775        }), fp.map(function () {
16776          proxy = _this.facade.retrieveProxy(TTMLCaptionProxy.NAME);
16777          proxy = new TTMLCaptionProxy();
16778          _this.facade.registerProxy(proxy);
16779        }));
16780      }
16781
16782      /** */
16783    }, {
16784      key: "timeupdate",
16785      value: function timeupdate(time) {
16786        var track = this.proxy.getTrack();
16787        if (track == null || track.isLive === true) return;
16788        var active = track.activeCues;
16789        var changed = false;
16790        track.cues.forEach(function (cue) {
16791          if (cue == null) return;
16792          var index = active.indexOf(cue);
16793          changed = true;
16794          if (time >= cue.startTime && time < cue.endTime) {
16795            if (index === -1) active.push(cue);
16796          } else {
16797            if (index !== -1) active.splice(index, 1);
16798          }
16799        });
16800        if (changed === true) {
16801          this.sendNotification(CaptioningNotifications.CHANGE_CUE, active);
16802        }
16803      }
16804    }, {
16805      key: "texttrackadded",
16806      value: function texttrackadded() {
16807        if (this.proxy.getMapper() === CaptionMapper.MANUAL) return;
16808        var textTracks = this.proxy.getTextTracks();
16809        var captionTracks = this.proxy.getTracks();
16810        var tracks = fp.transform(textTracks, fp.filter(function (track) {
16811          return regex.test(track.kind);
16812        }), fp.filter(function (track) {
16813          return !captionTracks.some(function (item) {
16814            return item.language === track.srclang;
16815          });
16816        }), fp.map(function (track) {
16817          return {
16818            srclang: track.language || 'en',
16819            // defaults to 'en' if language is not provided by textTrack API
16820            type: !!track.isEmbedded ? Utils.mimeTypes.cea608 : Utils.mimeTypes.vtt,
16821            kind: track.kind,
16822            label: track.label
16823          };
16824        }));
16825        this.proxy.setTracks(tracks);
16826        this.proxy.selectRenderer();
16827      }
16828
16829      /** */
16830    }, {
16831      key: "captioningvisibilitychange",
16832      value: function captioningvisibilitychange(visible, notification) {
16833        var hidden = !visible;
16834        if (hidden === this.proxy.getHidden()) {
16835          return;
16836        }
16837        this.proxy.setHidden(hidden);
16838        this.dispatchEvent(notification);
16839      }
16840
16841      /** */
16842    }, {
16843      key: "captioningenabled",
16844      value: function captioningenabled(value, notification) {
16845        this.proxy.setEnabled(value);
16846        this.dispatchEvent(notification);
16847      }
16848
16849      /** */
16850    }, {
16851      key: "captioningchangecue",
16852      value: function captioningchangecue(cues) {
16853        var _this2 = this;
16854        this.player.transform(TransformType.CUE_CHANGE, cues).then(function (result) {
16855          if (result == null) return;
16856          _this2.sendNotification(CaptioningNotifications.CUE_CHANGE, result);
16857        })["catch"](function (error) {
16858          _this2.sendNotification(CaptioningNotifications.CUE_CHANGE, cues);
16859        });
16860      }
16861
16862      /** */
16863    }, {
16864      key: "captioningtrackselected",
16865      value: function captioningtrackselected(value, notification) {
16866        this.dispatchEvent(notification);
16867      }
16868
16869      /** */
16870    }, {
16871      key: "captioningtracksloaded",
16872      value: function captioningtracksloaded(value, notification) {
16873        this.dispatchEvent(notification);
16874      }
16875
16876      /** */
16877    }, {
16878      key: "captioningcuechange",
16879      value: function captioningcuechange(value, notification) {
16880        this.dispatchEvent(notification);
16881      }
16882    }, {
16883      key: "captioningttmlcuechange",
16884      value: function captioningttmlcuechange(value, notification) {
16885        var proxy = this.facade.retrieveProxy(TTMLCaptionProxy.NAME);
16886        var track = this.proxy.getTrack();
16887        if (proxy == null || track.type !== Utils.mimeTypes.ttml) return;
16888        proxy.create(value, notification);
16889      }
16890    }], [{
16891      key: "NAME",
16892      get: function get() {
16893        return "CaptioningController";
16894      }
16895    }]);
16896    return CaptioningController;
16897  }(PluginController);
16898
16899  var PluginCommand = /*#__PURE__*/function (_puremvc$SimpleComman) {
16900    babelHelpers.inherits(PluginCommand, _puremvc$SimpleComman);
16901    /**
16902     * @constructor
16903     * @private
16904     * @extends {puremvc.SimpleCommand}
16905     */
16906    function PluginCommand() {
16907      var _this;
16908      babelHelpers.classCallCheck(this, PluginCommand);
16909      _this = _puremvc$SimpleComman.call(this) || this;
16910      _this.applicationState = null;
16911      _this.media = null;
16912      _this.player = null;
16913      _this.playback = null;
16914      _this.config = null;
16915      _this.logger = null;
16916      _this.bindings = null;
16917      _this.params = null;
16918      _this.playerCore = null;
16919      _this.security = null;
16920      _this.tracks = null;
16921      _this.plugin = null;
16922      _this.proxy = null;
16923      return _this;
16924    }
16925
16926    /** @override */
16927    babelHelpers.createClass(PluginCommand, [{
16928      key: "initializeNotifier",
16929      value: function initializeNotifier(key) {
16930        babelHelpers.get(babelHelpers.getPrototypeOf(PluginCommand.prototype), "initializeNotifier", this).call(this, key);
16931        this.player = this.facade.player || this.facade;
16932        this.applicationState = this.player.appState;
16933        this.media = this.player.mediaProxy;
16934        this.config = this.player.configuration;
16935        this.logger = this.player.logger;
16936        this.bindings = this.player.bindings;
16937        this.params = this.player.params;
16938        this.playerCore = this.player.playerCore;
16939        this.security = this.player.security;
16940        this.tracks = this.player.tracks;
16941        this.playback = this.player.playerCore.getActivePlaybackCore() || this.player.playback;
16942        this.localization = this.player.localization;
16943        this.proxy = this.facade.retrieveProxy(ModuleProxy.NAME);
16944        this.plugin = this.facade;
16945      }
16946
16947      // allow mediachange event to fire before auto playing
16948    }, {
16949      key: "doAfter",
16950      value: function doAfter(func) {
16951        var _this2 = this;
16952        return new Promise(function (resolve, reject) {
16953          var callback = function callback() {
16954            try {
16955              func();
16956              resolve();
16957            } catch (error) {
16958              _this2.facade.logger.error(error);
16959              reject(error);
16960            }
16961          };
16962          return _this2.player.timers.setImmediate(callback);
16963        });
16964      }
16965    }]);
16966    return PluginCommand;
16967  }(puremvc.SimpleCommand);
16968
16969  var CaptioningPlugin = /*#__PURE__*/function (_Plugin) {
16970    babelHelpers.inherits(CaptioningPlugin, _Plugin);
16971    /**
16972     * The CaptioningPlugin class.
16973     *
16974     * @param {Module}  app     The parent module of this plugin.
16975     * @constructor
16976     * @private
16977     * @extends {Plugin}
16978     */
16979    function CaptioningPlugin() {
16980      var _this;
16981      babelHelpers.classCallCheck(this, CaptioningPlugin);
16982      _this = _Plugin.call(this) || this;
16983      _this.feature = "captioning";
16984      _this.moduleName = "captioning";
16985      _this.mediatorname = "";
16986      return _this;
16987    }
16988
16989    /** @override */
16990    babelHelpers.createClass(CaptioningPlugin, [{
16991      key: "createController",
16992      value: function createController() {
16993        babelHelpers.get(babelHelpers.getPrototypeOf(CaptioningPlugin.prototype), "createController", this).call(this);
16994        this.registerMediator(new CaptioningController());
16995      }
16996
16997      /** @override */
16998    }, {
16999      key: "createModel",
17000      value: function createModel() {
17001        this.proxy = new CaptioningProxy(this.config);
17002        this.registerProxy(this.proxy);
17003      }
17004
17005      /** @override */
17006    }, {
17007      key: "createView",
17008      value: function createView() {
17009        var mediator = new CaptioningMediator();
17010        this.registerMediator(mediator);
17011        this.mediatorname = mediator.getMediatorName();
17012        var viewComponent = mediator.viewComponent;
17013        this.proxy.registerRenderer(new CaptioningNativeMediator(viewComponent));
17014        this.proxy.registerRenderer(new CaptioningHTMLMediator(viewComponent));
17015      }
17016
17017      /** @override */
17018    }, {
17019      key: "destroy",
17020      value: function destroy() {
17021        while (this.proxy.rendererMap.length >= 1) {
17022          var renderer = this.proxy.rendererMap[0];
17023          var name = renderer.getMediatorName();
17024          this.removeMediator(name);
17025          this.proxy.removeRenderer(renderer.getRendererName());
17026        }
17027        this.removeMediator(this.mediatorname);
17028      }
17029
17030      /** */
17031    }, {
17032      key: "listNotificationInterests",
17033      value: function listNotificationInterests() {
17034        return [Notifications.LOADED_DATA, Notifications.CAN_PLAY_THROUGH, Notifications.CHANGE_MEDIA, Notifications.STARTED, Notifications.TIME_UPDATE, Notifications.SETTINGS_CHANGE, Notifications.TEXT_TRACK_ADDED, CaptioningNotifications.TRACK_SELECTED, CaptioningNotifications.TTML_CUE_CHANGE];
17035      }
17036
17037      /** */
17038    }, {
17039      key: "listNotificationPublications",
17040      value: function listNotificationPublications() {
17041        return babelHelpers.get(babelHelpers.getPrototypeOf(CaptioningPlugin.prototype), "listNotificationPublications", this).call(this).concat([CaptioningNotifications.CUE_CHANGE, Notifications.ADD_CONTROL_STATE, Notifications.REMOVE_CONTROL_STATE, Notifications.CHANGE_SETTINGS, CaptioningNotifications.VISIBILITY_CHANGE, CaptioningNotifications.SETTINGS_CHANGE]);
17042      }
17043
17044      /**
17045       * @return {boolean} The hidden flag.
17046       * @expose
17047       */
17048    }, {
17049      key: "getEnabled",
17050      value: function getEnabled() {
17051        return this.proxy.getEnabled();
17052      }
17053    }, {
17054      key: "enabled",
17055      get: function get() {
17056        return this.getEnabled();
17057      }
17058
17059      /**
17060       * @param {boolean} value The hidden flag.
17061       * @expose
17062       */,
17063      set: function set(value) {
17064        return this.setEnabled(value);
17065      }
17066
17067      /**
17068       * @return {boolean} The hidden flag.
17069       * @expose
17070       */
17071    }, {
17072      key: "setEnabled",
17073      value: function setEnabled(value) {
17074        this.sendNotification(CaptioningNotifications.ENABLED, value);
17075        return value;
17076      }
17077    }, {
17078      key: "getHidden",
17079      value: function getHidden() {
17080        return this.proxy.getHidden();
17081      }
17082    }, {
17083      key: "hidden",
17084      get: function get() {
17085        return this.getHidden();
17086      }
17087
17088      /**
17089       * @param {boolean} value The hidden flag.
17090       * @expose
17091       */,
17092      set: function set(value) {
17093        return this.setHidden(value);
17094      }
17095
17096      /**
17097       * @return {boolean} The hidden flag.
17098       * @expose
17099       */
17100    }, {
17101      key: "setHidden",
17102      value: function setHidden(value) {
17103        this.setVisible(!value);
17104        return value;
17105      }
17106    }, {
17107      key: "getVisible",
17108      value: function getVisible() {
17109        return !this.proxy.getHidden();
17110      }
17111    }, {
17112      key: "visible",
17113      get: function get() {
17114        return this.getVisible();
17115      }
17116
17117      /**
17118       * @param {boolean} value The hidden flag.
17119       * @expose
17120       */,
17121      set: function set(value) {
17122        return this.setVisible(value);
17123      }
17124
17125      /**
17126       * Returns an array of caption tracks
17127       *
17128       * @return {Array.<CaptionTrack>} The list of text tracks.
17129       * @expose
17130       */
17131    }, {
17132      key: "setVisible",
17133      value: function setVisible(value) {
17134        this.sendNotification(Notifications.CHANGE_SETTINGS, {
17135          captions: {
17136            visible: value
17137          }
17138        });
17139        // TODO: Remove this in favor of Notifications.SETTINGS_CHANGE
17140        this.sendNotification(CaptioningNotifications.VISIBILITY_CHANGE, value);
17141        return value;
17142      }
17143    }, {
17144      key: "getTracks",
17145      value: function getTracks() {
17146        return this.proxy.getTracks();
17147      }
17148    }, {
17149      key: "tracks",
17150      get: function get() {
17151        return this.getTracks();
17152      }
17153
17154      /**
17155       * Returns the currently selected track.
17156       *
17157       * @return {CaptionTrack} The currently selected caption track.
17158       * @expose
17159       */
17160    }, {
17161      key: "getTrack",
17162      value: function getTrack() {
17163        return this.proxy.getTrack();
17164      }
17165    }, {
17166      key: "track",
17167      get: function get() {
17168        return this.getTrack();
17169      }
17170
17171      /**
17172       * Selects a caption track
17173       *
17174       * @param {CaptionTrack} value The caption track to select
17175       * @expose
17176       */,
17177      set: function set(value) {
17178        return this.setTrack(value);
17179      }
17180
17181      /**
17182       * Selects a caption track by its index in the getTracks array.
17183       *
17184       * @param {number}        index   The index to select
17185       * @return {CaptionTrack}         The selected caption track.
17186       * @expose
17187       */
17188    }, {
17189      key: "setTrack",
17190      value: function setTrack(value) {
17191        this.proxy.setTrack(value);
17192        return value;
17193      }
17194    }, {
17195      key: "selectTrackByIndex",
17196      value: function selectTrackByIndex(index) {
17197        return this.proxy.selectTrackByIndex(index);
17198      }
17199
17200      /**
17201       * Selects a caption track by it's language property.
17202       *
17203       * @param {string}        lang  The language to select
17204       * @return {CaptionTrack}       The selected caption track.
17205       * @expose
17206       */
17207    }, {
17208      key: "selectTrackByLanguage",
17209      value: function selectTrackByLanguage(lang) {
17210        return this.proxy.selectTrackByLanguage(lang);
17211      }
17212
17213      /**
17214       * Sets a caption Settings Object (styles)
17215       *
17216       * @param {Object}  object  The caption settings object.
17217       * @expose
17218       */
17219    }, {
17220      key: "changeSettings",
17221      value: function changeSettings(object) {
17222        this.sendNotification(Notifications.CHANGE_SETTINGS, {
17223          captions: object
17224        });
17225        // TODO: Remove this in favor of Notifications.SETTINGS_CHANGE
17226        this.sendNotification(CaptioningNotifications.SETTINGS_CHANGE, object);
17227        return object;
17228      }
17229
17230      /**
17231       * Return the captions settings object
17232       *
17233       * @return {Object}       The captions settings object.
17234       * @expose
17235       */
17236    }, {
17237      key: "getSettings",
17238      value: function getSettings() {
17239        return this.player.settings.captions;
17240      }
17241    }, {
17242      key: "settings",
17243      get: function get() {
17244        return this.getSettings();
17245      }
17246
17247      /**
17248       * Returns the caption renderer.
17249       *
17250       * @return {String} The caption renderer.
17251       * @expose
17252       */
17253    }, {
17254      key: "getRenderer",
17255      value: function getRenderer() {
17256        return this.proxy.getRenderer();
17257      }
17258    }, {
17259      key: "renderer",
17260      get: function get() {
17261        return this.getRenderer();
17262      }
17263
17264      /**
17265       * Selects a caption renderer by name
17266       *
17267       * @param {String} value The caption renderer name
17268       * @expose
17269       */,
17270      set: function set(value) {
17271        return this.setRenderer(value);
17272      }
17273
17274      /**
17275       * Returns the name of the currently selected caption renderer.
17276       *
17277       * @return {String} The currently selected caption renderer.
17278       * @expose
17279       */
17280    }, {
17281      key: "setRenderer",
17282      value: function setRenderer(value) {
17283        return this.proxy.setRenderer(value);
17284      }
17285    }, {
17286      key: "getCurrentRenderer",
17287      value: function getCurrentRenderer() {
17288        return this.proxy.getCurrentRenderer();
17289      }
17290    }, {
17291      key: "currentRenderer",
17292      get: function get() {
17293        return this.getCurrentRenderer();
17294      }
17295    }]);
17296    return CaptioningPlugin;
17297  }(Plugin);
17298
17299  var PlaybackPlugin = /*#__PURE__*/function (_Plugin) {
17300    babelHelpers.inherits(PlaybackPlugin, _Plugin);
17301    /**
17302     * The PluginProxy class.
17303     *
17304     * @param {Object} config
17305     * @constructor
17306     * @private
17307     * @extends {Plugin}
17308     */
17309    function PlaybackPlugin(config) {
17310      var _this;
17311      babelHelpers.classCallCheck(this, PlaybackPlugin);
17312      _this = _Plugin.call(this, config) || this;
17313      Object.defineProperties(babelHelpers.assertThisInitialized(_this), {
17314        instance: {
17315          get: _this.getInstance,
17316          enumerable: true,
17317          configurable: false
17318        }
17319      });
17320      return _this;
17321    }
17322
17323    /**
17324     * Returns HLS PlaybackProxy
17325     *
17326     */
17327    babelHelpers.createClass(PlaybackPlugin, [{
17328      key: "getPlaybackProxy",
17329      value: function getPlaybackProxy() {
17330        return this.proxy.playbackProxy;
17331      }
17332
17333      /**
17334       * Returns instance of HLS player
17335       *
17336       */
17337    }, {
17338      key: "getInstance",
17339      value: function getInstance() {
17340        return this.getPlaybackProxy().player;
17341      }
17342    }]);
17343    return PlaybackPlugin;
17344  }(Plugin);
17345
17346  var PlaybackPluginProxy = /*#__PURE__*/function (_PluginProxy) {
17347    babelHelpers.inherits(PlaybackPluginProxy, _PluginProxy);
17348    /**
17349     * @param {Object}  config  The plugin configuration object.
17350     * @constructor
17351     * @private
17352     * @extends {PluginProxy}
17353     */
17354    function PlaybackPluginProxy(config) {
17355      var _this;
17356      babelHelpers.classCallCheck(this, PlaybackPluginProxy);
17357      _this = _PluginProxy.call(this, config) || this;
17358      _this.playbackProxy = null;
17359      return _this;
17360    }
17361
17362    /** @static */
17363    babelHelpers.createClass(PlaybackPluginProxy, [{
17364      key: "createPlaybackProxy",
17365      value: function createPlaybackProxy() {}
17366    }, {
17367      key: "renderer",
17368      value: function renderer() {
17369        var _this2 = this;
17370        var renderer = this.playbackProxy.renderer();
17371        var id = renderer.id;
17372        var canPlay = function canPlay(media) {
17373          return (window.MediaSource || window.WebKitMediaSource) != null && renderer.canPlay(media);
17374        };
17375        var factory = function factory(player) {
17376          var resources = fp.transform(_this2.config.resources, fp.map(function (r) {
17377            return AMP.resourceManager.item(player.evaluatePaths(r.src));
17378          }),
17379          // resolve the path to the resource
17380          fp.filter(function (r) {
17381            return typeof r === "function";
17382          }),
17383          // filter out loaded resources
17384          fp.map(function (r) {
17385            return r();
17386          }) // load the resource
17387          );
17388
17389          return Promise.all(resources).then(function (deferred) {
17390            return renderer.factory(player);
17391          });
17392        };
17393        return {
17394          id: id,
17395          canPlay: canPlay,
17396          factory: factory
17397        };
17398      }
17399    }, {
17400      key: "initialize",
17401      value: function initialize() {
17402        this.playbackProxy = this.createPlaybackProxy();
17403        if (this.playbackProxy != null) {
17404          var player = this.facade.player.retrieveProxy(PlayerProxy.NAME);
17405          player.registerRenderer(this.renderer());
17406        }
17407        this.sendNotification(Notifications.INITIALIZED);
17408      }
17409    }, {
17410      key: "destroy",
17411      value: function destroy() {
17412        if (this.playbackProxy != null) {
17413          this.playbackProxy.destroy();
17414        }
17415      }
17416    }], [{
17417      key: "NAME",
17418      get: function get() {
17419        return ModuleProxy.NAME;
17420      }
17421    }]);
17422    return PlaybackPluginProxy;
17423  }(PluginProxy);
17424
17425  var HLSPlaybackProxy = /*#__PURE__*/function (_PlaybackCoreProxy) {
17426    babelHelpers.inherits(HLSPlaybackProxy, _PlaybackCoreProxy);
17427    /**
17428     * HLSPlaybackProxy constructor.
17429     *
17430     * @constructor
17431     * @private
17432     * @extends {PlaybackCoreProxy}
17433     */
17434    function HLSPlaybackProxy(config, plugin) {
17435      var _this;
17436      babelHelpers.classCallCheck(this, HLSPlaybackProxy);
17437      _this = _PlaybackCoreProxy.call(this, config, plugin) || this;
17438      _this.decryptionTypes = [KeySystem.WIDEVINE];
17439      _this.temporalTypes = ["vod", "live", "dvr"];
17440      _this.playbackCoreName = "hls";
17441      _this.player = null;
17442      _this.hlsConfig = null;
17443      _this.fragErrorTime = 0;
17444      _this.timedMedatadata = null;
17445      _this.currentMedatadata = null;
17446      _this.id3Track = null;
17447      _this.manifestParsed = false;
17448      _this.details = null;
17449      _this.quality = -1;
17450      _this.qualityMode = "auto";
17451      _this.userSwitched = false;
17452      return _this;
17453    }
17454
17455    /**
17456     *
17457     */
17458    babelHelpers.createClass(HLSPlaybackProxy, [{
17459      key: "canPlayMedium",
17460      value: function canPlayMedium(medium) {
17461        return babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlaybackProxy.prototype), "canPlayMedium", this).call(this, medium) || medium === "audio";
17462      }
17463    }, {
17464      key: "getConfig",
17465      value: function getConfig() {
17466        var _this2 = this;
17467        var config = Utils.merge({}, this.config.settings, this.config.data);
17468        var withCredentials = this.facade.configuration.getValueOf("withCredentials", this.config);
17469        if (withCredentials === true) {
17470          var xhrSetup = typeof config.xhrSetup === "function" ? config.xhrSetup : function () {};
17471          config.xhrSetup = function (xhr, url) {
17472            xhr.withCredentials = true;
17473            xhrSetup(xhr, url);
17474          };
17475        }
17476        config.debug = this.plugin.proxy.getDebug();
17477        var preload = this.facade.getPreload();
17478        if (preload !== Preload.NONE && config.autoStartLoad == null) {
17479          config.autoStartLoad = true;
17480        }
17481        if (preload === Preload.AUTO && config.startFragPrefetch == null) {
17482          config.startFragPrefetch = true;
17483        }
17484        var cmcd = this.facade.configuration.getValueOf("cmcd", this.config);
17485        if (cmcd != null && cmcd.enabled !== false) config.cmcd = cmcd;
17486        var keys = this.facade.getMedia().keys;
17487        fp.find(Utils.getKeySystem(), fp.filter(function (key) {
17488          return keys && !!keys[key];
17489        }), fp.filter(function (key) {
17490          return _this2.decryptionTypes.indexOf(key) !== -1;
17491        }), fp.map(function (key) {
17492          config.emeEnabled = true;
17493          config.widevineLicenseUrl = keys[key].serverURL;
17494        }));
17495        var customLoaders = this.getActiveLoaders();
17496        fp.find(customLoaders, fp.filter(function (loader) {
17497          return !!loader['type'];
17498        }), fp.map(function (loader) {
17499          return config[loader.type] = loader['loader'];
17500        }));
17501        return config;
17502      }
17503
17504      /** @override */
17505    }, {
17506      key: "init",
17507      value: function init() {
17508        var _this3 = this;
17509        this.destroy();
17510        this.manifestParsed = false;
17511        this.userSwitched = false;
17512        this.quality = -1;
17513        var config = this.getConfig();
17514        var player = new Hls(config);
17515        player.attachMedia(this.getMediaElement());
17516        player.on(Hls.Events.MANIFEST_PARSED, this.onManifestParsed.bind(this));
17517        player.on(Hls.Events.ERROR, this.onError.bind(this));
17518        player.on(Hls.Events.LEVEL_LOADED, this.onLevelLoaded.bind(this));
17519        player.on(Hls.Events.LEVEL_SWITCHING, this.onLevelSwitching.bind(this));
17520        player.on(Hls.Events.LEVEL_SWITCHED, this.onLevelSwitched.bind(this));
17521        player.on(Hls.Events.AUDIO_TRACK_SWITCHING, this.onAudioTrackSwitch.bind(this));
17522        player.on(Hls.Events.AUDIO_TRACK_SWITCHED, this.onAudioTrackSwitch.bind(this));
17523        player.on(Hls.Events.FRAG_LOADING, this.onFragmentLoadStart.bind(this));
17524        player.on(Hls.Events.FRAG_LOADED, this.onFragmentLoaded.bind(this));
17525        player.on(Hls.Events.FRAG_CHANGED, this.onFragmentChanged.bind(this));
17526        fp.each(Hls.Events, function (value) {
17527          player.on(value, function (event, data) {
17528            _this3.plugin.sendNotification(Notifications.DISPATCH_EVENT, Event.create(event, data));
17529          });
17530        });
17531        try {
17532          fp.each(this.config.quality, function (value, key) {
17533            return player[key] = value;
17534          });
17535        } catch (error) {}
17536        this.player = player;
17537        this.details = null;
17538        babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlaybackProxy.prototype), "init", this).call(this);
17539      }
17540    }, {
17541      key: "unload",
17542      value: function unload() {
17543        this.destroy();
17544      }
17545    }, {
17546      key: "applySrc",
17547      value: function applySrc() {
17548        this.currentMedatadata = null;
17549        this.player.loadSource(this.getSrc());
17550        this.load();
17551      }
17552
17553      /** */
17554    }, {
17555      key: "onManifestParsed",
17556      value: function onManifestParsed(event, data) {
17557        this.manifestParsed = true;
17558        this.sendNotification(Notifications.QUALITY_LEVELS_LOADED, data.levels);
17559        //start bitrate -1 auto 0 low 1 high
17560        this.player.loadLevel = -1;
17561        if (this.config.maxBitrate > -1) {
17562          this.setMaxBitrate(this.config.maxBitrate);
17563        }
17564      }
17565
17566      /** */
17567    }, {
17568      key: "onLevelLoaded",
17569      value: function onLevelLoaded(event, data) {
17570        this.player.levels[data.level].level = data.level;
17571        this.sendNotification(Notifications.QUALITY_CHANGE, this.player.levels[data.level]);
17572        this.details = data.details;
17573        var duration = this.details.totalduration;
17574        if (duration != null) {
17575          this.data.duration = duration;
17576          this.sendNotification(Notifications.CHANGE_DURATION, this.data.duration);
17577        }
17578        if (this.details.live === true && this.facade.mediaProxy.getTemporalType() !== "dvr") {
17579          this.facade.mediaProxy.setTemporalType("live");
17580        }
17581      }
17582
17583      /** */
17584    }, {
17585      key: "onLevelSwitching",
17586      value: function onLevelSwitching(event, data) {
17587        if (this.getQualityMode() === QualityMode.MANUAL) {
17588          this.userSwitched = true;
17589        }
17590        this.sendNotification(Notifications.QUALITY_CHANGING, this.player.levels[data.level]);
17591      }
17592    }, {
17593      key: "onLevelSwitched",
17594      value: function onLevelSwitched(event, data) {
17595        this.sendNotification(Notifications.QUALITY_SWITCHED, this.player.levels[data.level]);
17596      }
17597    }, {
17598      key: "onAudioTrackSwitch",
17599      value: function onAudioTrackSwitch(event, data) {
17600        var hasswitched = event === Hls.Events.AUDIO_TRACK_SWITCHED;
17601        this.sendNotification(Notifications.AUDIO_TRACK_SWITCH, {
17602          switched: hasswitched
17603        });
17604      }
17605
17606      /** */
17607    }, {
17608      key: "onseeking",
17609      value: function onseeking(event) {
17610        if (this.getQualityMode() === QualityMode.MANUAL && this.userSwitched) {
17611          return;
17612        }
17613        babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlaybackProxy.prototype), "onseeking", this).call(this, event);
17614      }
17615
17616      /** */
17617    }, {
17618      key: "onseeked",
17619      value: function onseeked(event) {
17620        if (this.getQualityMode() === QualityMode.MANUAL && this.userSwitched) {
17621          this.userSwitched = false;
17622          return;
17623        }
17624        babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlaybackProxy.prototype), "onseeked", this).call(this, event);
17625      }
17626    }, {
17627      key: "onFragmentLoadStart",
17628      value: function onFragmentLoadStart(event, data) {
17629        try {
17630          var bitrate = this.player.levels[data.frag.level].bitrate;
17631          this.sendNotification(Notifications.FRAGMENT_LOAD_START, bitrate);
17632        } catch (error) {
17633          return;
17634        }
17635      }
17636    }, {
17637      key: "onFragmentLoaded",
17638      value: function onFragmentLoaded(event, data) {
17639        try {
17640          var bitrate = this.player.levels[data.frag.level].bitrate;
17641          this.sendNotification(Notifications.FRAGMENT_LOADED, bitrate);
17642        } catch (error) {
17643          return;
17644        }
17645      }
17646    }, {
17647      key: "onFragmentChanged",
17648      value: function onFragmentChanged(event, data) {
17649        this.fragment = data.frag;
17650      }
17651    }, {
17652      key: "ontimeupdate",
17653      value: function ontimeupdate(event) {
17654        // TODO: This should not be here.
17655        if (this.facade.ads.inProgress === true) {
17656          return;
17657        }
17658        this.data.currentTime = this.getCurrentTime();
17659        // don't let playback go out of the DVR window
17660        // regardless the behind buffer tolerance value 
17661        if (this.data.currentTime < 0) {
17662          return this.goLive();
17663        }
17664        this.sendNotification(Notifications.TIME_CHANGE, {
17665          currentTime: this.data.currentTime
17666        });
17667      }
17668
17669      /** */
17670    }, {
17671      key: "ondurationchange",
17672      value: function ondurationchange(event) {
17673        var duration = this.getDetails().totalduration;
17674        if (duration === this.data.duration || duration === 0 || isNaN(duration)) {
17675          return;
17676        }
17677        this.data.duration = duration;
17678        this.sendNotification(Notifications.CHANGE_DURATION, duration);
17679      }
17680    }, {
17681      key: "oncanplaythrough",
17682      value: function oncanplaythrough(event) {
17683        this.createTracks();
17684        this.sendNotification(Notifications.CAN_PLAY_THROUGH);
17685        this.sendNotification(Notifications.PROGRESS, this.getDuration());
17686        if (this.qualityMode === QualityMode.MANUAL && this.player.nextLevel !== this.quality) {
17687          this.setQuality(this.quality);
17688        }
17689      }
17690    }, {
17691      key: "getStartTime",
17692      value: function getStartTime() {
17693        return this.getMediaElement().duration - this.getDuration();
17694      }
17695    }, {
17696      key: "getCurrentTime",
17697      value: function getCurrentTime() {
17698        return this.getMediaElement().currentTime - this.getStartTime();
17699      }
17700    }, {
17701      key: "getDetails",
17702      value: function getDetails() {
17703        return this.details || {};
17704      }
17705    }, {
17706      key: "getFragmentDuration",
17707      value: function getFragmentDuration() {
17708        return this.getDetails().targetduration || 0;
17709      }
17710
17711      /** @override */
17712    }, {
17713      key: "getCurrentTimeUTC",
17714      value: function getCurrentTimeUTC() {
17715        var offset, utc;
17716        try {
17717          offset = (this.getMediaElement().currentTime - this.fragment.start) * 1000;
17718          utc = this.fragment.programDateTime || this.fragment.sn;
17719        } catch (error) {
17720          utc = 0;
17721          offset = 0;
17722        }
17723        return Math.round(offset + utc);
17724      }
17725
17726      // TODO: These are duplicates of DVRPlaybackProxy funcitons -- start
17727      /** */
17728    }, {
17729      key: "goLive",
17730      value: function goLive() {
17731        this.setCurrentTime(this.getDuration() - this.getFragmentDuration());
17732      }
17733
17734      /** */
17735    }, {
17736      key: "getLiveTime",
17737      value: function getLiveTime() {
17738        return this.getMediaElement().duration - this.getFragmentDuration();
17739      }
17740
17741      /** */
17742    }, {
17743      key: "isLive",
17744      value: function isLive() {
17745        return Math.round(this.getStartTime() + this.getCurrentTime()) >= Math.round(this.getLiveTime());
17746      }
17747    }, {
17748      key: "onplay",
17749      value: function onplay(event) {
17750        babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlaybackProxy.prototype), "onplay", this).call(this, event);
17751        if (this.mediaProxy.getTemporalType() === "dvr" && this.getMediaElement().currentTime > 0) {
17752          this.sendNotification(Notifications.IS_LIVE, this.isLive());
17753        }
17754      }
17755
17756      /** @override */
17757    }, {
17758      key: "seek",
17759      value: function seek(value) {
17760        var _this4 = this;
17761        var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getStartTime();
17762        var seek = function seek(time) {
17763          return new Promise(function (resolve, reject) {
17764            try {
17765              var video = _this4.getMediaElement();
17766
17767              // HACK HLS.js seeked event is not being fired when using streams with missing keyframes
17768              var interval = _this4.facade.timers.setInterval(function () {
17769                if (Math.round(video.currentTime) === Math.round(time)) {
17770                  _this4.facade.timers.clearInterval(interval);
17771                  video.dispatchEvent(new CustomEvent("seeked"));
17772                }
17773              }, 100);
17774            } catch (error) {
17775              reject(error);
17776            }
17777          });
17778        };
17779        return Promise.race([babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlaybackProxy.prototype), "seek", this).call(this, value + offset), seek(value + offset)]).then(function (time) {
17780          if (_this4.mediaProxy.getTemporalType() === "dvr") {
17781            _this4.sendNotification(Notifications.IS_LIVE, _this4.isLive());
17782          }
17783        });
17784      }
17785
17786      // TODO: These are duplicates of DVRPlaybackProxy funcitons -- end
17787      /** override */
17788    }, {
17789      key: "onplaying",
17790      value: function onplaying(event) {
17791        babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlaybackProxy.prototype), "onplaying", this).call(this);
17792        this.retried = false;
17793      }
17794
17795      /** */
17796    }, {
17797      key: "onError",
17798      value: function onError(event, data) {
17799        this.userSwitched = false;
17800        this.plugin.sendNotification(Notifications.DISPATCH_EVENT, Event.create(Events.ERROR, {
17801          event: event,
17802          data: data
17803        }));
17804        if (this.config.ignoreErrors === true) {
17805          return;
17806        }
17807        if (this.config.retryOnError === false || this.retried === true) {
17808          this.retried = false;
17809          this.error(data);
17810          return;
17811        }
17812
17813        //HLS Bug for handling Frag loop error
17814        if (data.fatal && data.type === Hls.ErrorTypes.MEDIA_ERROR && data.details === Hls.ErrorDetails.FRAG_LOOP_LOADING_ERROR) {
17815          data.fatal = false;
17816        }
17817
17818        //Error Handling/Recovery
17819        if (data.fatal) {
17820          switch (data.type) {
17821            case Hls.ErrorTypes.NETWORK_ERROR:
17822              this.retried = true;
17823              if (this.manifestParsed) {
17824                this.player.startLoad();
17825              } else {
17826                this.player.loadSource(this.getSrc());
17827              }
17828              this.facade.logger.error("[AMP HLS] Playback Error trying to recover:", event);
17829              break;
17830            case Hls.ErrorTypes.MEDIA_ERROR:
17831              this.retried = true;
17832              this.player.recoverMediaError();
17833              this.facade.logger.error("[AMP HLS] Playback Error trying to recover:", event);
17834              break;
17835            default:
17836              this.facade.logger.error("[AMP HLS] Playback Error:", event);
17837              this.error(data);
17838          }
17839        } else {
17840          switch (data.details) {
17841            //HACK Frag Loop error handling
17842            case Hls.ErrorDetails.FRAG_LOOP_LOADING_ERROR:
17843              if (this.fragErrorTime === this.getMediaElement().currentTime) {
17844                this.getMediaElement().currentTime++;
17845                this.facade.logger.error("[AMP HLS] Frag Loop Load Error, Seeking to :", this.getMediaElement().currentTime);
17846              } else {
17847                this.fragErrorTime = this.getMediaElement().currentTime;
17848              }
17849              break;
17850            case Hls.ErrorDetails.BUFFER_STALLED_ERROR:
17851            case Hls.ErrorDetails.BUFFER_NUDGE_ON_STALL:
17852              {
17853                var minBufferTime = 0.5;
17854                this.sendNotification(Notifications.STALLED);
17855                // AMPWEB-2452: Prevent hls.js to stall in the end slice if the remaining
17856                // time is less than the minimum buffer data to be loaded
17857                if (this.mediaProxy.getTemporalType() === 'vod' && this.getMediaElement().duration - this.getMediaElement().currentTime < minBufferTime) {
17858                  this.facade.logger.error("[AMP HLS] Abort loading data at end slice, calling end:", this.getMediaElement().currentTime);
17859                  this.sendNotification(Notifications.END);
17860                }
17861                break;
17862              }
17863          }
17864        }
17865      }
17866    }, {
17867      key: "error",
17868      value: function error(data) {
17869        switch (data.type) {
17870          case Hls.ErrorTypes.NETWORK_ERROR:
17871            data.code = MediaError.MEDIA_ERR_NETWORK;
17872            break;
17873          case Hls.ErrorTypes.MEDIA_ERROR:
17874            data.code = MediaError.MEDIA_ERR_DECODE;
17875            break;
17876          default:
17877            data.toString = function () {
17878              return data.message;
17879            };
17880        }
17881        data.message = "".concat(data.type, ": ").concat(data.details);
17882        this.sendNotification(Notifications.ERROR, data);
17883      }
17884
17885      /** @override */
17886    }, {
17887      key: "createTracks",
17888      value: function createTracks() {
17889        var _this5 = this;
17890        var audio = this.player.audioTracks;
17891        var current = this.player.audioTrack;
17892        var tracks = this.facade.tracks.getAudioTracks();
17893        var count = audio.length;
17894        function changeEnabled(track, enabled) {
17895          var tracks = this.facade.tracks.getAudioTracks();
17896          if (enabled !== true) {
17897            return;
17898          }
17899          tracks.some(function (item) {
17900            item.data.enabled = item.id == track.id;
17901          });
17902          this.player.audioTrack = track.id;
17903        }
17904        audio.forEach(function (item, index) {
17905          if (Utils.fieldIsUnique(tracks, 'id', item.id) === false) return;
17906          var track = new Track({
17907            kind: item.type,
17908            label: item.name || item.id,
17909            language: item.lang,
17910            id: item.id,
17911            enabled: item.id === current,
17912            data: item
17913          });
17914          track.changeEnabled = changeEnabled.bind(_this5, item);
17915          tracks.add(track, index + 1 === count);
17916        });
17917      }
17918    }, {
17919      key: "onaddtrack",
17920      value: function onaddtrack(event) {
17921        babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlaybackProxy.prototype), "onaddtrack", this).call(this, event);
17922        var track = event.track;
17923        // ignores text tracks to be shown in <video> when captioning is disabled
17924        // hack HLS.js inner core ignores track mode `hidden` in favor of `disabled`
17925        if (this.facade.captioning == null && regex.test(track.kind)) {
17926          this.facade.timers.setTimeout(function () {
17927            return track.mode = TrackMode.DISABLED;
17928          }, 10);
17929        }
17930      }
17931
17932      /** @override */
17933    }, {
17934      key: "setQuality",
17935      value: function setQuality(value) {
17936        var mode = value === -1 ? QualityMode.AUTO : QualityMode.MANUAL;
17937        this.setQualityMode(mode);
17938        //resets max bitrate ceiling 
17939        if (mode === QualityMode.MANUAL) {
17940          this.setMaxQualityLevel(-1);
17941        } else {
17942          this.setCapLevelToPlayerSize(true);
17943        }
17944        if (value === this.player.nextLevel && mode === QualityMode.MANUAL) {
17945          // If the level is the current level, even if auto
17946          // switching is on, hls.js does not send these events
17947          // No need to manually switch level when using auto (-1)
17948          this.onLevelSwitching("hlsLevelSwitching", this.player.levels[value]);
17949          this.onLevelSwitched("hlsLevelSwitched", {
17950            level: value
17951          });
17952        }
17953        if (this.player != null) {
17954          this.player.nextLevel = this.quality = value;
17955        }
17956        return this.quality;
17957      }
17958
17959      /** @override */
17960    }, {
17961      key: "getQuality",
17962      value: function getQuality() {
17963        var autoLevel = -1;
17964        var player = this.player;
17965        if (player == null) return autoLevel;
17966        if (player.currentLevel > autoLevel) {
17967          return player.currentLevel;
17968        } else if (player.nextLevel > autoLevel) {
17969          return player.nextLevel;
17970        } else {
17971          return player.loadLevel;
17972        }
17973      }
17974
17975      /** @override */
17976    }, {
17977      key: "getQualityLevels",
17978      value: function getQualityLevels() {
17979        var player = this.player;
17980        return player != null ? player.levels : babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlaybackProxy.prototype), "getQualityLevels", this).call(this);
17981      }
17982
17983      /** @override */
17984    }, {
17985      key: "getQualityMode",
17986      value: function getQualityMode() {
17987        return this.qualityMode;
17988      }
17989
17990      /** @override */
17991    }, {
17992      key: "setQualityMode",
17993      value: function setQualityMode(value) {
17994        this.qualityMode = value;
17995        return value;
17996      }
17997
17998      /** @override */
17999    }, {
18000      key: "setMaxQualityLevel",
18001      value: function setMaxQualityLevel(value) {
18002        this.setMaxBitrate(value);
18003      }
18004
18005      /** @override */
18006    }, {
18007      key: "getMaxQualityLevel",
18008      value: function getMaxQualityLevel() {
18009        if (this.player == null) return;
18010        return this.player.autoLevelCapping;
18011      }
18012    }, {
18013      key: "setMaxBitrate",
18014      value: function setMaxBitrate(value) {
18015        if (this.player == null) return;
18016        var levels = this.getQualityLevels();
18017        var level = levels.filter(function (level) {
18018          return level.bitrate <= value;
18019        }).length - 1;
18020        this.setCapLevelToPlayerSize(level === -1);
18021        this.player.autoLevelCapping = level;
18022        return level;
18023      }
18024    }, {
18025      key: "getMaxBitrate",
18026      value: function getMaxBitrate() {
18027        var levels = this.getQualityLevels();
18028        var maxQualityLevel = this.getMaxQualityLevel();
18029        if (maxQualityLevel === -1 || this.player.capLevelToPlayerSize) return -1;
18030        return levels[maxQualityLevel].bitrate;
18031      }
18032    }, {
18033      key: "setCapLevelToPlayerSize",
18034      value: function setCapLevelToPlayerSize() {
18035        var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
18036        var setting = Utils.get(this.config, ['data', 'capLevelToPlayerSize']);
18037        var capLevelToPlayerSize = QualityMode.AUTO === this.qualityMode && setting !== false && value;
18038        this.player.capLevelToPlayerSize = capLevelToPlayerSize;
18039        return this.player.capLevelToPlayerSize;
18040      }
18041
18042      /** @override */
18043    }, {
18044      key: "destroy",
18045      value: function destroy() {
18046        if (this.player == null) {
18047          return;
18048        }
18049        try {
18050          babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlaybackProxy.prototype), "destroy", this).call(this);
18051          this.player.destroy();
18052          this.player = null;
18053        } catch (error) {}
18054      }
18055
18056      /** 
18057       * @override 
18058       * @param {Hls.DefaultConfig.loader} loader - callback function
18059       * @param {string} name - Playback core name of the loader 
18060       * @param {string} type - HLS Loader types i.e fLoader, pLoader and loader 
18061       */
18062    }, {
18063      key: "registerCustomLoader",
18064      value: function registerCustomLoader(loader) {
18065        var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.playbackCoreName;
18066        var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'loader';
18067        if (typeof loader !== 'function') return;
18068        return this.customLoaders.push({
18069          name: name,
18070          loader: loader,
18071          type: type
18072        });
18073      }
18074    }]);
18075    return HLSPlaybackProxy;
18076  }(PlaybackCoreProxy);
18077
18078  var HLSProxy = /*#__PURE__*/function (_PlaybackPluginProxy) {
18079    babelHelpers.inherits(HLSProxy, _PlaybackPluginProxy);
18080    /**
18081     * The HLSProxy class.
18082     *
18083     * @param {Object}  config  The plugin configuration object.
18084     * @constructor
18085     * @private
18086     * @extends {PluginProxy}
18087     */
18088    function HLSProxy(config) {
18089      var _this;
18090      babelHelpers.classCallCheck(this, HLSProxy);
18091      _this = _PlaybackPluginProxy.call(this, config) || this;
18092      _this.defaults = {
18093        types: ["application/x-mpegURL"],
18094        data: {
18095          enableWorker: true,
18096          enableCEA708Captions: true
18097        },
18098        settings: {
18099          enableSoftwareAES: true,
18100          capLevelToPlayerSize: true,
18101          lowLatencyMode: false
18102        },
18103        buffer: null,
18104        quality: null,
18105        withCredentials: null,
18106        retryOnError: true,
18107        ignoreErrors: false,
18108        maxBitrate: -1
18109      };
18110      return _this;
18111    }
18112
18113    /** @static */
18114    babelHelpers.createClass(HLSProxy, [{
18115      key: "createPlaybackProxy",
18116      value: function createPlaybackProxy() {
18117        return new HLSPlaybackProxy(this.getData(), this.facade);
18118      }
18119    }], [{
18120      key: "NAME",
18121      get: function get() {
18122        return ModuleProxy.NAME;
18123      }
18124    }]);
18125    return HLSProxy;
18126  }(PlaybackPluginProxy);
18127
18128  var HLSAdBreakStartCommand = /*#__PURE__*/function (_PluginCommand) {
18129    babelHelpers.inherits(HLSAdBreakStartCommand, _PluginCommand);
18130    /**
18131     * The HLSAdBreakStartCommand class.
18132     *
18133     * @constructor
18134     * @private
18135     * @extends {puremvc.SimpleCommand}
18136     */
18137    function HLSAdBreakStartCommand() {
18138      babelHelpers.classCallCheck(this, HLSAdBreakStartCommand);
18139      return _PluginCommand.call(this) || this;
18140    }
18141
18142    /**
18143     * Executes the command.
18144     *
18145     * @param {puremvc.Notification} notification
18146     *    The notification.
18147     *
18148     * @override
18149     */
18150    babelHelpers.createClass(HLSAdBreakStartCommand, [{
18151      key: "execute",
18152      value: function execute(notification) {
18153        var rate, ref;
18154        if (((ref = notification.getBody()) != null ? ref.partner : void 0) === "freewheel") {
18155          rate = this.facade.player.getPlaybackRate();
18156          this.proxy.destroy();
18157          this.facade.player.setPlaybackRate(rate);
18158        }
18159      }
18160    }]);
18161    return HLSAdBreakStartCommand;
18162  }(PluginCommand);
18163
18164  var HLSPlugin = /*#__PURE__*/function (_PlaybackPlugin) {
18165    babelHelpers.inherits(HLSPlugin, _PlaybackPlugin);
18166    /**
18167     * The HLSPlugin class.
18168     *
18169     * @param {Module}  app     The parent module of this plugin.
18170     * @constructor
18171     * @private
18172     * @extends {Plugin}
18173     */
18174    function HLSPlugin() {
18175      var _this;
18176      babelHelpers.classCallCheck(this, HLSPlugin);
18177      _this = _PlaybackPlugin.call(this) || this;
18178      _this.moduleName = "hls";
18179      return _this;
18180    }
18181
18182    /** @override */
18183    babelHelpers.createClass(HLSPlugin, [{
18184      key: "createModel",
18185      value: function createModel() {
18186        this.proxy = new HLSProxy(this.config);
18187        this.registerProxy(this.proxy);
18188      }
18189    }, {
18190      key: "createController",
18191      value: function createController() {
18192        this.registerCommand(AdNotifications.BREAK_START, HLSAdBreakStartCommand);
18193        babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlugin.prototype), "createController", this).call(this);
18194      }
18195
18196      /** */
18197    }, {
18198      key: "logEvent",
18199      value: function logEvent(event) {
18200        if (/^hls/.test(event.type) === true) {
18201          return;
18202        }
18203        babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlugin.prototype), "logEvent", this).call(this, event);
18204      }
18205
18206      /** */
18207    }, {
18208      key: "listNotificationInterests",
18209      value: function listNotificationInterests() {
18210        return babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlugin.prototype), "listNotificationInterests", this).call(this).concat([AdNotifications.BREAK_START]);
18211      }
18212
18213      /** */
18214    }, {
18215      key: "listNotificationPublications",
18216      value: function listNotificationPublications() {
18217        return babelHelpers.get(babelHelpers.getPrototypeOf(HLSPlugin.prototype), "listNotificationPublications", this).call(this).concat([Notifications.TIMED_METADATA, Notifications.QUALITY_LEVELS_LOADED, Notifications.QUALITY_CHANGE, Notifications.QUALITY_CHANGING, Notifications.FRAGMENT_LOAD_START, Notifications.FRAGMENT_LOADED]);
18218      }
18219    }]);
18220    return HLSPlugin;
18221  }(PlaybackPlugin);
18222
18223  var DataCue = /*#__PURE__*/function (_Cue) {
18224    babelHelpers.inherits(DataCue, _Cue);
18225    function DataCue(startTime, endTime, data) {
18226      babelHelpers.classCallCheck(this, DataCue);
18227      return _Cue.call(this, startTime, endTime, data) || this;
18228    }
18229    babelHelpers.createClass(DataCue, [{
18230      key: "type",
18231      get: function get() {
18232        return 'metadata';
18233      }
18234    }, {
18235      key: "data",
18236      set: function set(value) {
18237        return this.value = value;
18238      }
18239    }]);
18240    return DataCue;
18241  }(Cue);
18242
18243  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
18244  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {};
18244 i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { babelHelpers.defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
18245  var DASHPlaybackProxy = /*#__PURE__*/function (_PlaybackCoreProxy) {
18246    babelHelpers.inherits(DASHPlaybackProxy, _PlaybackCoreProxy);
18247    /**
18248     * DASHPlaybackProxy constructor.
18249     *
18250     * @constructor
18251     * @private
18252     * @extends {PlaybackCoreProxy}
18253     */
18254    function DASHPlaybackProxy(data, plugin) {
18255      var _this;
18256      babelHelpers.classCallCheck(this, DASHPlaybackProxy);
18257      _this = _PlaybackCoreProxy.call(this, data, plugin) || this;
18258      _this.buffer = data.buffer;
18259      _this.decryptionTypes = [KeySystem.WIDEVINE, KeySystem.PLAYREADY, KeySystem.CLEARKEY];
18260      _this.temporalTypes = ["vod", "live", "dvr"];
18261      DASHPlaybackProxy.SCTE = _this.config.schemeIdUri;
18262      DASHPlaybackProxy.FRAGMENT_DURATION = _this.config.fragmentDuration;
18263      _this.playbackCoreName = "dash";
18264      _this.context = null;
18265      _this.player = null;
18266      _this.buffer = null;
18267      return _this;
18268    }
18269
18270    /** @override */
18271    babelHelpers.createClass(DASHPlaybackProxy, [{
18272      key: "resumecomplete",
18273      value: function resumecomplete() {
18274        try {
18275          // IE throws error when accessing index 0 when length is 0
18276          var mediaElement = this.facade.getMediaElement();
18277          var tracks = mediaElement != null ? mediaElement.textTracks : void 0;
18278          if ((tracks != null ? tracks.length : void 0) !== 0) {
18279            var track = tracks[0];
18280            if (track != null) {
18281              track.mode = "hidden";
18282            }
18283          }
18284        } catch (error) {}
18285        babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "resumecomplete", this).call(this);
18286      }
18287    }, {
18288      key: "onerror",
18289      value: function onerror() {}
18290
18291      /** @override */
18292    }, {
18293      key: "ontimeupdate",
18294      value: function ontimeupdate(event) {
18295        babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "ontimeupdate", this).call(this, {
18296          target: {
18297            currentTime: this.getCurrentTime()
18298          }
18299        });
18300      }
18301
18302      /** @override */
18303    }, {
18304      key: "onseeked",
18305      value: function onseeked(event) {
18306        babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "onseeked", this).call(this, {
18307          target: {
18308            currentTime: this.getCurrentTime()
18309          }
18310        });
18311      }
18312
18313      /** @override */
18314    }, {
18315      key: "onseeking",
18316      value: function onseeking(event) {
18317        babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "onseeking", this).call(this, {
18318          target: {
18319            currentTime: this.getCurrentTime()
18320          }
18321        });
18322      }
18323
18324      /** @override */
18325    }, {
18326      key: "ondurationchange",
18327      value: function ondurationchange(event) {
18328        babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "ondurationchange", this).call(this, {
18329          target: {
18330            duration: this.getDuration()
18331          }
18332        });
18333      }
18334
18335      /** @override */
18336    }, {
18337      key: "onloadedmetadata",
18338      value: function onloadedmetadata(event) {
18339        babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "onloadedmetadata", this).call(this, event);
18340        this.sendNotification(Notifications.CHANGE_DURATION, this.getDuration());
18341      }
18342
18343      /** @override */
18344    }, {
18345      key: "oncanplaythrough",
18346      value: function oncanplaythrough(event) {
18347        babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "oncanplaythrough", this).call(this, event);
18348        this.sendNotification(Notifications.CHANGE_DURATION, this.getDuration());
18349      }
18350
18351      /**
18352       *
18353       */
18354    }, {
18355      key: "canPlayMedium",
18356      value: function canPlayMedium(medium) {
18357        return babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "canPlayMedium", this).call(this, medium) || medium === "audio";
18358      }
18359    }, {
18360      key: "getMedium",
18361      value: function getMedium() {
18362        return Utils.get(this.facade, ["media", "medium"]) || "video";
18363      }
18364
18365      /** @override */
18366    }, {
18367      key: "createTracks",
18368      value: function createTracks() {
18369        var _this2 = this;
18370        if (this.player && this.player.getActiveStream() == null) return;
18371        var audio = this.player.getTracksFor("audio");
18372        var current = this.player.getCurrentTrackFor("audio");
18373        var tracks = this.facade.tracks.getAudioTracks();
18374        var count = audio.length;
18375        fp.each(audio, function (item, index) {
18376          var id = item.id || index;
18377          if (id != null && Utils.fieldIsUnique(tracks, 'id', id) === false) {
18378            return;
18379          }
18380          var track = new Track({
18381            kind: item.roles.join(" "),
18382            label: item.id,
18383            language: item.lang,
18384            id: id,
18385            enabled: item === current,
18386            data: item
18387          });
18388          track.changeEnabled = _this2.changeEnabled.bind(_this2, item, track);
18389          tracks.add(track, index + 1 === count);
18390        });
18391      }
18392    }, {
18393      key: "changeEnabled",
18394      value: function changeEnabled(audio, track, enabled) {
18395        var tracks = this.facade.tracks.getAudioTracks();
18396        fp.each(tracks.list, function (item) {
18397          return item.data.enabled = item === track;
18398        });
18399        if (enabled !== true) {
18400          return;
18401        }
18402        this.player.setCurrentTrack(audio);
18403      }
18404    }, {
18405      key: "logLevel",
18406      value: function logLevel() {
18407        var debug = this.plugin.proxy.getDebug();
18408        var type = babelHelpers["typeof"](debug);
18409        switch (type) {
18410          case "number":
18411            return debug;
18412          case "boolean":
18413            return debug === true ? dashjs.Debug.LOG_LEVEL_DEBUG : dashjs.Debug.LOG_LEVEL_NONE;
18414          default:
18415            return dashjs.Debug.LOG_LEVEL_NONE;
18416        }
18417      }
18418
18419      /** @override */
18420    }, {
18421      key: "init",
18422      value: function init() {
18423        var _this3 = this;
18424        try {
18425          var config = this.config;
18426          if (this.player == null) {
18427            var player = dashjs.MediaPlayer().create();
18428            player.on(dashjs.MediaPlayer.events.ERROR, this.onError.bind(this));
18429            player.on(dashjs.MediaPlayer.events.FRAGMENT_LOADING_STARTED, this.onFragmentLoadStart.bind(this));
18430            player.on(dashjs.MediaPlayer.events.FRAGMENT_LOADING_COMPLETED, this.onFragmentLoaded.bind(this));
18431            player.on(dashjs.MediaPlayer.events.QUALITY_CHANGE_REQUESTED, this.onQualityChangeRequested.bind(this));
18432            player.on(dashjs.MediaPlayer.events.QUALITY_CHANGE_RENDERED, this.onQualityChangeRendered.bind(this));
18433            player.on(dashjs.MediaPlayer.events.MANIFEST_LOADED, this.onManifestLoaded.bind(this));
18434            player.on(dashjs.Protection.events.PROTECTION_CREATED, this.onProtectionCreated.bind(this));
18435            player.on(dashjs.MediaPlayer.events.BUFFER_EMPTY, this.onBufferEmpty.bind(this));
18436            player.on(DASHPlaybackProxy.SCTE, this.onEmsg.bind(this));
18437            player.on(dashjs.MediaPlayer.events.TTML_TO_PARSE, this.onTmlToParse.bind(this));
18438            player.on(dashjs.MediaPlayer.events.TEXT_TRACKS_ADDED, this.onTracksAdded.bind(this));
18439            this.player = player;
18440          }
18441          var settings = Utils.merge({
18442            debug: {
18443              logLevel: this.logLevel()
18444            },
18445            streaming: {
18446              fastSwitchEnabled: true
18447            }
18448          }, config.data, config.settings);
18449          if (config.lowLatencyEnabled != null) {
18450            Utils.set(settings, ["streaming", "lowLatencyEnabled"], config.lowLatencyEnabled);
18451          }
18452          if (config.liveDelay != null) {
18453            Utils.set(settings, ["streaming", "liveDelay"], config.liveDelay);
18454          }
18455          if (config.catchUpPlaybackRate != null) {
18456            Utils.set(settings, ["streaming", "liveCatchUpPlaybackRate"], config.catchUpPlaybackRate);
18457          }
18458          if (config.initialBitrate != null) {
18459            Utils.set(settings, ["streaming", "abr", "initialBitrate", this.getMedium()], config.initialBitrate);
18460          }
18461          if (config.maxBitrate > -1) {
18462            // converts to Kbps
18463            Utils.set(settings, ["streaming", "abr", "maxBitrate", this.getMedium()], config.maxBitrate / Utils.transferRates.Kbps);
18464          }
18465          var cmcd = this.facade.configuration.getValueOf("cmcd", config);
18466          if (cmcd != null && cmcd.enabled !== false) {
18467            Utils.set(settings, ["streaming", "cmcd"], this.createCmcdConfig(cmcd));
18468          }
18469          this.player.initialize(this.getMediaElement(), null, false);
18470          this.player.updateSettings(settings);
18471          var withCredentials = this.facade.configuration.getValueOf("withCredentials", config);
18472          if (withCredentials != null) {
18473            if (typeof withCredentials === "boolean") {
18474              withCredentials = {
18475                "default": withCredentials
18476              };
18477            }
18478            fp.each(withCredentials, function (value, key) {
18479              return _this3.player.setXHRWithCredentialsForType(key, value);
18480            });
18481          }
18482          babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "init", this).call(this);
18483        } catch (error) {
18484          this.facade.logger.error(error);
18485        }
18486      }
18487    }, {
18488      key: "isLive",
18489      get: function get() {
18490        return this.getCurrentTime() >= this.getDuration() - DASHPlaybackProxy.FRAGMENT_DURATION;
18491      }
18492    }, {
18493      key: "notifyDVRLiveStatus",
18494      value: function notifyDVRLiveStatus() {
18495        if (this.mediaProxy.getTemporalType() === "dvr") {
18496          this.sendNotification(Notifications.IS_LIVE, this.isLive);
18497        }
18498      }
18499    }, {
18500      key: "onplay",
18501      value: function onplay() {
18502        babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "onplay", this).call(this);
18503        this.notifyDVRLiveStatus();
18504      }
18505
18506      /** @override */
18507    }, {
18508      key: "applySrc",
18509      value: function applySrc() {
18510        var keys = this.facade.getMedia().keys;
18511        if (keys != null) {
18512          this.player.setProtectionData(keys);
18513        }
18514        this.player.attachSource(this.getSrc());
18515        this.load();
18516      }
18517
18518      /** @override */
18519    }, {
18520      key: "preload",
18521      value: function preload() {
18522        arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.facade.getPreload();
18523      }
18524    }, {
18525      key: "goLive",
18526      value: function goLive() {
18527        this.setCurrentTime(this.getDuration());
18528      }
18529
18530      /** @override */
18531    }, {
18532      key: "seek",
18533      value: function seek(value) {
18534        var _this4 = this;
18535        return Promise.resolve(this.player.seek(value)).then(function (time) {
18536          _this4.notifyDVRLiveStatus();
18537        });
18538      }
18539
18540      /** @override */
18541    }, {
18542      key: "getCurrentTime",
18543      value: function getCurrentTime() {
18544        if (!this.player) return 0;
18545        return this.player.time();
18546      }
18547
18548      /** @override */
18549    }, {
18550      key: "getDuration",
18551      value: function getDuration() {
18552        if (!this.player) return 0;
18553        return this.player.duration();
18554      }
18555
18556      /** @override */
18557    }, {
18558      key: "getCurrentTimeUTC",
18559      value: function getCurrentTimeUTC() {
18560        if (!this.player) return 0;
18561        return Math.round(this.player.timeAsUTC() * 1000);
18562      }
18563
18564      /** */
18565    }, {
18566      key: "getStats",
18567      value: function getStats() {
18568        return {};
18569      }
18570
18571      /**
18572       * Transforms to dashjs like cmcd config 
18573       * @param config cmcd config 
18574       * */
18575    }, {
18576      key: "createCmcdConfig",
18577      value: function createCmcdConfig() {
18578        var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
18579        var props = {
18580          deviceId: "did",
18581          contentId: "cid",
18582          sessionId: "sid",
18583          version: "v"
18584        };
18585        return Object.keys(config).filter(function (key) {
18586          return !!props[key];
18587        }).reduce(function (acc, key) {
18588          acc[props[key]] = config[key];
18589          return acc;
18590        }, _objectSpread({
18591          enabled: true
18592        }, config.useHeaders === true && {
18593          mode: "header"
18594        }));
18595      }
18596
18597      /** */
18598    }, {
18599      key: "onFragmentLoadStart",
18600      value: function onFragmentLoadStart(event) {
18601        var bitrate = event.request.mediaInfo.bitrateList[event.request.quality].bandwidth;
18602        this.sendNotification(Notifications.FRAGMENT_LOAD_START, bitrate);
18603      }
18604
18605      /** */
18606    }, {
18607      key: "onFragmentLoaded",
18608      value: function onFragmentLoaded(event) {
18609        var bitrate = event.request.mediaInfo.bitrateList[event.request.quality].bandwidth;
18610        this.sendNotification(Notifications.FRAGMENT_LOADED, bitrate);
18611      }
18612
18613      /** */
18614    }, {
18615      key: "onQualityChangeRequested",
18616      value: function onQualityChangeRequested(event) {
18617        this.sendNotification(Notifications.QUALITY_CHANGING, this.getQualityLevels()[event.newQuality]);
18618
18619        // The QUALITY_CHANGING event is fired as soon as the user manually selects the bitrate. This
18620        // creates a UI bug where the buffering animation plays until the QUALITY_CHANGE_RENDERED
18621        // event fires. This can take a long time as the player needs to drain the remaining
18622        // buffer before performing the switch.
18623        this.sendNotification(Notifications.QUALITY_SWITCHED, this.getQualityLevels()[event.newQuality]);
18624      }
18625
18626      /** */
18627    }, {
18628      key: "onQualityChangeRendered",
18629      value: function onQualityChangeRendered(event) {
18630        this.sendNotification(Notifications.QUALITY_SWITCHED, this.getQualityLevels()[event.newQuality]);
18631      }
18632    }, {
18633      key: "onManifestLoaded",
18634      value: function onManifestLoaded(event) {
18635        this.plugin.sendNotification(Notifications.DISPATCH_EVENT, Event.create(dashjs.MediaPlayer.events.MANIFEST_LOADED, event.data));
18636      }
18637    }, {
18638      key: "onProtectionCreated",
18639      value: function onProtectionCreated(event) {
18640        this.plugin.sendNotification(Notifications.DISPATCH_EVENT, Event.create(dashjs.Protection.events.PROTECTION_CREATED, event.data));
18641      }
18642    }, {
18643      key: "onBufferEmpty",
18644      value: function onBufferEmpty(event) {
18645        if (event.mediaType !== "video") return;
18646        this.sendNotification(Notifications.STALLED);
18647      }
18648    }, {
18649      key: "onEmsg",
18650      value: function onEmsg(event) {
18651        var data = event.event;
18652        this.plugin.sendNotification(Notifications.DISPATCH_EVENT, Event.create(event.type, data));
18653        var start = (data.presentationTime || data.calculatedPresentationTime / data.presentationTimeDelta) * 10000;
18654        var end = start + data.duration / data.presentationTimeDelta * 10000;
18655        var text = String.fromCharCode.apply(null, data.messageData);
18656        var info = XMLUtils.parse(text);
18657        data.text = text;
18658        var cue = new DataCue(start, end, {
18659          key: DASHPlaybackProxy.SCTE,
18660          data: data,
18661          info: info
18662        });
18663        this.sendNotification(Notifications.TIMED_METADATA, cue);
18664      }
18665    }, {
18666      key: "onTracksAdded",
18667      value: function onTracksAdded(event) {
18668        var player = this.player;
18669        // Prevent Dash to parse & handle texttracks if captions is disabled
18670        if (this.facade.captioning == null) {
18671          player.setTextTrack(-1);
18672          return;
18673        }
18674        var tracks = this.facade.captioning.getTracks();
18675        var textTracks = this.facade.textTracks;
18676        var compare = function compare(a, b) {
18677          // sameness criterias  
18678          if (a.isFromCEA608 === true && b.type !== Utils.mimeTypes.cea608) return false;
18679          if (a.isEmbedded === true && b.type !== Utils.mimeTypes.cea708) return false;
18680          if (a.isTTML === true && b.type !== Utils.mimeTypes.ttml) return false;
18681          if (Utils.compareLanguageTags(a.language, b.language) !== true) return false;
18682
18683          // if nothing fails return true
18684          return true;
18685        };
18686        var select = function select(track) {
18687          fp.each(textTracks, function (item, idx) {
18688            if (compare(item, track)) player.setTextTrack(idx);
18689          });
18690        };
18691        var changeEnabled = function changeEnabled(track, enabled) {
18692          if (enabled !== true) return;
18693          player.setTextTrack(-1); // disables dash CC processing for all tracks
18694          select(track);
18695          // resets 'enabled' state to active tracks
18696          fp.each(tracks, function (item) {
18697            return item.data.enabled = item === track;
18698          });
18699        };
18700
18701        // maps tracks that requires DashAPI handling  
18702        fp.each(tracks, function (item, index) {
18703          item.changeEnabled = changeEnabled.bind(this, item);
18704          if (item.enabled === true) select(item);
18705        });
18706      }
18707    }, {
18708      key: "onTmlToParse",
18709      value: function onTmlToParse(event) {
18710        this.sendNotification(CaptioningNotifications.TTML_CUE_CHANGE, event);
18711      }
18712
18713      /** */
18714    }, {
18715      key: "onError",
18716      value: function onError(event) {
18717        var error = event.error;
18718        this.plugin.sendNotification(Notifications.DISPATCH_EVENT, Event.create(Events.ERROR, error));
18719        this.sendNotification(Notifications.ERROR, error);
18720      }
18721
18722      /** @override */
18723    }, {
18724      key: "setQuality",
18725      value: function setQuality(value) {
18726        if (!this.player) return;
18727        var mode = value === -1 ? QualityMode.AUTO : QualityMode.MANUAL;
18728        this.setQualityMode(mode);
18729        // removes the max bitrate ceiling on manual bitrate selection
18730        if (mode === QualityMode.MANUAL) this.setMaxQualityLevel(-1);
18731        this.player.setQualityFor("video", value);
18732        return value;
18733      }
18734
18735      /** @override */
18736    }, {
18737      key: "getQuality",
18738      value: function getQuality() {
18739        if (!this.player) return;
18740        return this.player.getQualityFor("video");
18741      }
18742
18743      /** @override */
18744    }, {
18745      key: "getQualityLevels",
18746      value: function getQualityLevels() {
18747        if (!this.player) return;
18748        return this.player.getBitrateInfoListFor("video") || babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "getQualityLevels", this).call(this);
18749      }
18750
18751      /** @override */
18752    }, {
18753      key: "getQualityMode",
18754      value: function getQualityMode() {
18755        if (!this.player) return;
18756        var settings = this.player.getSettings();
18757        var setting = Utils.get(settings, ["streaming", "abr", "autoSwitchBitrate", this.getMedium()]);
18758        return setting === true ? QualityMode.AUTO : QualityMode.MANUAL;
18759      }
18760
18761      /** @override */
18762    }, {
18763      key: "setQualityMode",
18764      value: function setQualityMode(value) {
18765        if (!this.player || value === this.getQualityMode()) return;
18766        var settings = this.player.getSettings();
18767        Utils.set(settings, ["streaming", "abr", "autoSwitchBitrate", this.getMedium()], value == QualityMode.AUTO);
18768        this.player.updateSettings(this.settings);
18769        return value;
18770      }
18771
18772      /** @override */
18773    }, {
18774      key: "setMaxQualityLevel",
18775      value: function setMaxQualityLevel(value) {
18776        this.setMaxBitrate(value);
18777      }
18778
18779      /** @override */
18780    }, {
18781      key: "getMaxQualityLevel",
18782      value: function getMaxQualityLevel() {
18783        var levels = this.getQualityLevels();
18784        var maxBitrate = this.getMaxBitrateFromSettings();
18785        return levels.filter(function (level) {
18786          return level.bitrate <= maxBitrate;
18787        }).length - 1;
18788      }
18789    }, {
18790      key: "getMaxBitrateFromSettings",
18791      value: function getMaxBitrateFromSettings() {
18792        if (this.player == null) return this.config.maxBitrate;
18793        var settings = this.player.getSettings();
18794        return Utils.get(settings, ["streaming", "abr", "maxBitrate", this.getMedium()]);
18795      }
18796
18797      /** @override */
18798    }, {
18799      key: "setMaxBitrate",
18800      value: function setMaxBitrate(value) {
18801        if (this.player == null || typeof value !== 'number') return;
18802        var levels = this.getQualityLevels();
18803        var settings = this.player.getSettings();
18804        var level = levels.filter(function (level) {
18805          return level.bitrate <= value;
18806        }).length - 1;
18807        var maxBitrate = levels[level] ? levels[level].bitrate / Utils.transferRates.Kbps : level;
18808        Utils.set(settings, ["streaming", "abr", "maxBitrate", this.getMedium()], maxBitrate);
18809        this.player.updateSettings(this.settings);
18810        return level;
18811      }
18812
18813      /** 
18814       * @returns {number} max selectable bitrate in bits per second
18815       */
18816    }, {
18817      key: "getMaxBitrate",
18818      value: function getMaxBitrate() {
18819        var maxBitrate = this.getMaxBitrateFromSettings();
18820        if (maxBitrate === -1 || this.QualityMode === QualityMode.MANUAL) return -1;
18821        // Convert to bps
18822        return maxBitrate * Utils.transferRates.Kbps;
18823      }
18824
18825      /** @override */
18826    }, {
18827      key: "destroy",
18828      value: function destroy() {
18829        if (!this.player) return;
18830        this.player.reset();
18831        babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlaybackProxy.prototype), "destroy", this).call(this);
18832      }
18833    }]);
18834    return DASHPlaybackProxy;
18835  }(PlaybackCoreProxy);
18836
18837  var DASHProxy = /*#__PURE__*/function (_PlaybackPluginProxy) {
18838    babelHelpers.inherits(DASHProxy, _PlaybackPluginProxy);
18839    /**
18840     * The DASHProxy class.
18841     *
18842     * @param {Object}  config  The plugin configuration object.
18843     * @constructor
18844     * @private
18845     * @extends {PluginProxy}
18846     */
18847    function DASHProxy(config) {
18848      var _this;
18849      babelHelpers.classCallCheck(this, DASHProxy);
18850      _this = _PlaybackPluginProxy.call(this, config) || this;
18851      _this.defaults = {
18852        types: ["application/dash+xml"],
18853        buffer: null,
18854        initialBitrate: null,
18855        lowLatencyEnabled: null,
18856        liveDelay: null,
18857        catchUpPlaybackRate: null,
18858        withCredentials: null,
18859        data: null,
18860        settings: null,
18861        schemeIdUri: "urn:scte:scte35:2013:xml",
18862        fragmentDuration: 10,
18863        maxBitrate: -1
18864      };
18865      return _this;
18866    }
18867
18868    /** @static */
18869    babelHelpers.createClass(DASHProxy, [{
18870      key: "createPlaybackProxy",
18871      value: function createPlaybackProxy() {
18872        return new DASHPlaybackProxy(this.getData(), this.facade);
18873      }
18874    }], [{
18875      key: "NAME",
18876      get: function get() {
18877        return ModuleProxy.NAME;
18878      }
18879    }]);
18880    return DASHProxy;
18881  }(PlaybackPluginProxy);
18882
18883  var DASHPlugin = /*#__PURE__*/function (_PlaybackPlugin) {
18884    babelHelpers.inherits(DASHPlugin, _PlaybackPlugin);
18885    /**
18886     * The DASHPlugin class.
18887     *
18888     * @param {Module}  app     The parent module of this plugin.
18889     * @constructor
18890     * @private
18891     * @extends {Plugin}
18892     */
18893    function DASHPlugin() {
18894      var _this;
18895      babelHelpers.classCallCheck(this, DASHPlugin);
18896      _this = _PlaybackPlugin.call(this) || this;
18897      _this.moduleName = "dash";
18898      return _this;
18899    }
18900
18901    /** @override */
18902    babelHelpers.createClass(DASHPlugin, [{
18903      key: "createModel",
18904      value: function createModel() {
18905        this.proxy = new DASHProxy(this.config);
18906        this.registerProxy(this.proxy);
18907      }
18908
18909      /** */
18910    }, {
18911      key: "listNotificationPublications",
18912      value: function listNotificationPublications() {
18913        return babelHelpers.get(babelHelpers.getPrototypeOf(DASHPlugin.prototype), "listNotificationPublications", this).call(this).concat([Notifications.FRAGMENT_LOAD_START, Notifications.FRAGMENT_LOADED]);
18914      }
18915    }]);
18916    return DASHPlugin;
18917  }(PlaybackPlugin);
18918
18919  // init
18920  QueryString.constructed = QueryString.construct();
18921  Notifications.init();
18922  AMP.registerPlugin("hls", "html", HLSPlugin);
18923  AMP.registerPlugin("dash", "html", DASHPlugin);
18924  AMP.registerPlugin("captioning", "html", CaptioningPlugin);
18925
18926  // embed future players
18927  var Observer = MutationObserver || WebKitMutationObserver;
18928  var observer = new Observer(function (mutationsList, observer) {
18929    mutationsList.forEach(function (mutation) {
18930      embed(mutation.addedNodes);
18931    });
18932  });
18933  function observe() {
18934    observer.observe(document.body, {
18935      childList: true,
18936      subtree: true
18937    });
18938  }
18939  function embed(nodes) {
18940    if (!nodes || nodes.length == 0) return;
18941    var promise = Promise.resolve();
18942    fp.each(nodes, function (node) {
18943      if (!node.classList || !node.classList.contains("amp-inline") || !Object.keys(node.dataset) || node.dataset.embedded == "true") return;
18944      promise = promise.then(AMP.embed.bind(null, node));
18945    });
18946  }
18947
18948  // embed all current players
18949  function embedAll() {
18950    embed(document.querySelectorAll(".amp-inline"));
18951  }
18952  if (document.body) {
18953    observe();
18954  } else {
18955    var domContentLoaded = function domContentLoaded() {
18956      document.removeEventListener("DOMContentLoaded", domContentLoaded);
18957      embedAll();
18958      observe();
18959    };
18960    document.addEventListener("DOMContentLoaded", domContentLoaded);
18961  }
18962  embedAll();
18963  var main = {
18964    fp: fp,
18965    amp: {
18966      ActiveState: ActiveState,
18967      Ad: AdVO,
18968      AdEvents: Object.entries(AdNotifications).reduce(function (acc, ent) {
18969        acc[ent[0].replace(/^AD_/, "")] = ent[1].replace(/^ads/, "");
18970        return acc;
18971      }, {}),
18972      AdPlugin: AdPromisePlugin,
18973      ads: {
18974        AdNotifications: AdNotifications,
18975        AdPlugin: AdPlugin,
18976        AdProxy: AdProxy,
18977        AdRequest: AdRequest,
18978        AdVO: AdVO
18979      },
18980      ApplicationStateProxy: ApplicationStateProxy,
18981      AMP: AMP,
18982      AMPError: AMPError,
18983      AmpError: AMPError,
18984      AuthEvents: AuthEvents,
18985      Authorization: Authorization,
18986      AuthPlugin: AuthPromisePlugin,
18987      AuthProvider: AuthProvider,
18988      AuthProviderList: AuthProviderList,
18989      AutoplayPolicy: AutoplayPolicy,
18990      AutoplayThreshold: AutoplayThreshold,
18991      CaptionRenderer: CaptionRenderer,
18992      CaptionCue: CaptionCue,
18993      CaptionTrack: CaptionTrack,
18994      Config: Config,
18995      CSS: CSS,
18996      Cue: Cue,
18997      DataBinding: DataBinding,
18998      DataBoundConfigurationProxy: ModuleProxy,
18999      DisplayState: DisplayState,
19000      Event: Event,
19001      Events: Events,
19002      EventDispatcher: EventDispatcher,
19003      KeySystem: KeySystem,
19004      Logger: Logger,
19005      Media: MediaVO,
19006      MediaProxy: MediaProxy,
19007      Medium: Medium,
19008      ModuleProxy: ModuleProxy,
19009      Notifications: Notifications,
19010      OverlayMediator: OverlayMediator,
19011      PlayerProxy: PlayerProxy,
19012      PlayState: PlayState,
19013      Plugin: PromisePlugin,
19014      Preload: Preload,
19015      PreviewTrack: PreviewTrack,
19016      QualityMode: QualityMode,
19017      QueryString: QueryString,
19018      Resource: Resource,
19019      get Settings() {
19020        return SettingsController.GET();
19021      },
19022      SMPTETTParser: SMPTETTParser,
19023      SRTParser: SRTParser,
19024      Timer: Timer,
19025      Transformer: Transformer,
19026      TransformType: TransformType,
19027      URL: URL,
19028      Utils: Utils,
19029      XMLUtils: XMLUtils,
19030      utils: {
19031        Logger: Logger,
19032        QueryString: QueryString,
19033        Timer: Timer,
19034        Utils: Utils,
19035        XMLUtils: XMLUtils
19036      },
19037      WebVTTParser: WebVTTParser
19038    }
19039  };
19040
19041  return main;
19042
19043})();
19044//# sourceMappingURL=amp.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.