UNPKG

@playkit-js/playkit-js-ima

Version:

[![Build Status](https://github.com/kaltura/playkit-js-ima/actions/workflows/run_canary_full_flow.yaml/badge.svg)](https://github.com/kaltura/playkit-js-ima/actions/workflows/run_canary_full_flow.yaml) [![code style: prettier](https://img.shields.io/badge

1 lines 52.4 kB
var KalturaPlayer="object"==typeof KalturaPlayer?KalturaPlayer:{};KalturaPlayer.plugins=KalturaPlayer.plugins||{},KalturaPlayer.plugins.ima=function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t){e.exports=KalturaPlayer},function(e,t,n){var i;i=function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t,n){"use strict";e.exports=function(e,t){var n,i,r;for(n=1;n<arguments.length;n++)for(r in i=arguments[n])i.hasOwnProperty(r)&&(e[r]=i[r]);return e}},function(e,t,n){"use strict";var i=n(0);e.exports={build:function(e,t){var n,r,a,s=t.plugins;for(n=0,r=s.length;n<r;n++)(a=s[n]).methods&&i(e,a.methods),a.properties&&Object.defineProperties(e,a.properties)},hook:function(e,t,n){var i,r,a,s,o=e.config.plugins,d=[e.context];for(n&&(d=d.concat(n)),i=0,r=o.length;i<r;i++)s=o[i],(a=o[i][t])&&a.apply(s,d)}}},function(e,t,n){"use strict";function i(e){if(0===e.length)return e;var t,n,i=e.split(/[_-]/);if(1===i.length&&i[0][0].toLowerCase()===i[0][0])return e;for(n=i[0].toLowerCase(),t=1;t<i.length;t++)n=n+i[t].charAt(0).toUpperCase()+i[t].substring(1).toLowerCase();return n}i.prepended=function(e,t){return e+(t=i(t))[0].toUpperCase()+t.substring(1)},e.exports=i},function(e,t,n){"use strict";var i=n(0),r=n(2);function a(e,t){e=e||{},this.options=e,this.defaults=t.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(e.init),this.data=this.configureData(e.data),this.methods=this.configureMethods(e.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(e.transitions||[]),this.plugins=this.configurePlugins(e.plugins,t.plugin)}i(a.prototype,{addState:function(e){this.map[e]||(this.states.push(e),this.addStateLifecycleNames(e),this.map[e]={})},addStateLifecycleNames:function(e){this.lifecycle.onEnter[e]=r.prepended("onEnter",e),this.lifecycle.onLeave[e]=r.prepended("onLeave",e),this.lifecycle.on[e]=r.prepended("on",e)},addTransition:function(e){this.transitions.indexOf(e)<0&&(this.transitions.push(e),this.addTransitionLifecycleNames(e))},addTransitionLifecycleNames:function(e){this.lifecycle.onBefore[e]=r.prepended("onBefore",e),this.lifecycle.onAfter[e]=r.prepended("onAfter",e),this.lifecycle.on[e]=r.prepended("on",e)},mapTransition:function(e){var t=e.name,n=e.from,i=e.to;return this.addState(n),"function"!=typeof i&&this.addState(i),this.addTransition(t),this.map[n][t]=e,e},configureLifecycle:function(){return{onBefore:{transition:"onBeforeTransition"},onAfter:{transition:"onAfterTransition"},onEnter:{state:"onEnterState"},onLeave:{state:"onLeaveState"},on:{transition:"onTransition"}}},configureInitTransition:function(e){return"string"==typeof e?this.mapTransition(i({},this.defaults.init,{to:e,active:!0})):"object"==typeof e?this.mapTransition(i({},this.defaults.init,e,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(e){return"function"==typeof e?e:"object"==typeof e?function(){return e}:function(){return{}}},configureMethods:function(e){return e||{}},configurePlugins:function(e,t){var n,i,r;for(n=0,i=(e=e||[]).length;n<i;n++)"function"==typeof(r=e[n])&&(e[n]=r=r()),r.configure&&r.configure(this);return e},configureTransitions:function(e){var t,n,i,r,a,s=this.defaults.wildcard;for(n=0;n<e.length;n++)for(i=e[n],r=Array.isArray(i.from)?i.from:[i.from||s],a=i.to||s,t=0;t<r.length;t++)this.mapTransition({name:i.name,from:r[t],to:a})},transitionFor:function(e,t){var n=this.defaults.wildcard;return this.map[e][t]||this.map[n][t]},transitionsFor:function(e){var t=this.defaults.wildcard;return Object.keys(this.map[e]).concat(Object.keys(this.map[t]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),e.exports=a},function(e,t,n){var i=n(0),r=n(6),a=n(1),s=[null,[]];function o(e,t){this.context=e,this.config=t,this.state=t.init.from,this.observers=[e]}i(o.prototype,{init:function(e){if(i(this.context,this.config.data.apply(this.context,e)),a.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(e){return Array.isArray(e)?e.indexOf(this.state)>=0:this.state===e},isPending:function(){return this.pending},can:function(e){return!this.isPending()&&!!this.seek(e)},cannot:function(e){return!this.can(e)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(e,t){var n=this.config.defaults.wildcard,i=this.config.transitionFor(this.state,e),r=i&&i.to;return"function"==typeof r?r.apply(this.context,t):r===n?this.state:r},fire:function(e,t){return this.transit(e,this.state,this.seek(e,t),t)},transit:function(e,t,n,i){var r=this.config.lifecycle,a=this.config.options.observeUnchangedState||t!==n;return n?this.isPending()?this.context.onPendingTransition(e,t,n):(this.config.addState(n),this.beginTransit(),i.unshift({transition:e,from:t,to:n,fsm:this.context}),this.observeEvents([this.observersForEvent(r.onBefore.transition),this.observersForEvent(r.onBefore[e]),a?this.observersForEvent(r.onLeave.state):s,a?this.observersForEvent(r.onLeave[t]):s,this.observersForEvent(r.on.transition),a?["doTransit",[this]]:s,a?this.observersForEvent(r.onEnter.state):s,a?this.observersForEvent(r.onEnter[n]):s,a?this.observersForEvent(r.on[n]):s,this.observersForEvent(r.onAfter.transition),this.observersForEvent(r.onAfter[e]),this.observersForEvent(r.on[e])],i)):this.context.onInvalidTransition(e,t,n)},beginTransit:function(){this.pending=!0},endTransit:function(e){return this.pending=!1,e},failTransit:function(e){throw this.pending=!1,e},doTransit:function(e){this.state=e.to},observe:function(e){if(2===e.length){var t={};t[e[0]]=e[1],this.observers.push(t)}else this.observers.push(e[0])},observersForEvent:function(e){for(var t,n=0,i=this.observers.length,r=[];n<i;n++)(t=this.observers[n])[e]&&r.push(t);return[e,r,!0]},observeEvents:function(e,t,n,i){if(0===e.length)return this.endTransit(void 0===i||i);var r=e[0][0],s=e[0][1],o=e[0][2];if(t[0].event=r,r&&o&&r!==n&&a.hook(this,"lifecycle",t),0===s.length){var d=e.slice(1);return this.observeEvents(d,t,r,i)}var c=s.shift(),l=c[r].apply(c,t);return l&&"function"==typeof l.then?l.then(this.observeEvents.bind(this,e,t,r)).catch(this.failTransit.bind(this)):!1===l?this.endTransit(!1):this.observeEvents(e,t,r,l)},onInvalidTransition:function(e,t,n){throw new r("transition is invalid in current state",e,t,n,this.state)},onPendingTransition:function(e,t,n){throw new r("transition is invalid while previous transition is still in progress",e,t,n,this.state)}}),e.exports=o},function(e,t,n){"use strict";var i=n(0),r=n(2),a=n(1),s=n(3),o=n(4),d={is:function(e){return this._fsm.is(e)},can:function(e){return this._fsm.can(e)},cannot:function(e){return this._fsm.cannot(e)},observe:function(){return this._fsm.observe(arguments)},transitions:function(){return this._fsm.transitions()},allTransitions:function(){return this._fsm.allTransitions()},allStates:function(){return this._fsm.allStates()},onInvalidTransition:function(e,t,n){return this._fsm.onInvalidTransition(e,t,n)},onPendingTransition:function(e,t,n){return this._fsm.onPendingTransition(e,t,n)}},c={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(e){throw Error("use transitions to change state")}}};function l(e){return h(this||{},e)}function h(e,t){return u(e,new s(t,l)),e._fsm(),e}function u(e,t){if("object"!=typeof e||Array.isArray(e))throw Error("StateMachine can only be applied to objects");a.build(e,t),Object.defineProperties(e,c),i(e,d),i(e,t.methods),t.allTransitions().forEach((function(t){e[r(t)]=function(){return this._fsm.fire(t,[].slice.call(arguments))}})),e._fsm=function(){this._fsm=new o(this,t),this._fsm.init(arguments)}}l.version="3.0.1",l.factory=function(){var e,t;"function"==typeof arguments[0]?(e=arguments[0],t=arguments[1]||{}):(e=function(){this._fsm.apply(this,arguments)},t=arguments[0]||{});var n=new s(t,l);return u(e.prototype,n),e.prototype._fsm.config=n,e},l.apply=h,l.defaults={wildcard:"*",init:{name:"init",from:"none"}},e.exports=l},function(e,t,n){"use strict";e.exports=function(e,t,n,i,r){this.message=e,this.transition=t,this.from=n,this.to=i,this.current=r}}])},e.exports=i()},function(e,t,n){var i;i=function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){"use strict";function i(e){if(0===e.length)return e;var t,n,i=e.split(/[_-]/);if(1===i.length&&i[0][0].toLowerCase()===i[0][0])return e;for(n=i[0].toLowerCase(),t=1;t<i.length;t++)n=n+i[t].charAt(0).toUpperCase()+i[t].substring(1).toLowerCase();return n}i.prepended=function(e,t){return e+(t=i(t))[0].toUpperCase()+t.substring(1)},e.exports=i},function(e,t,n){"use strict";var i=n(0);e.exports=function(e){var t=i((e=e||{}).name||e.past||"history"),n=i(e.future||"future"),r=i.prepended("clear",t),a=i.prepended(t,"back"),s=i.prepended(t,"forward"),o=i.prepended("can",a),d=i.prepended("can",s),c=e.max,l={configure:function(e){e.addTransitionLifecycleNames(a),e.addTransitionLifecycleNames(s)},init:function(e){e[t]=[],e[n]=[]},lifecycle:function(e,i){"onEnterState"===i.event&&(e[t].push(i.to),c&&e[t].length>c&&e[t].shift(),i.transition!==a&&i.transition!==s&&(e[n].length=0))},methods:{},properties:{}};return l.methods[r]=function(){this[t].length=0,this[n].length=0},l.properties[o]={get:function(){return this[t].length>1}},l.properties[d]={get:function(){return this[n].length>0}},l.methods[a]=function(){if(!this[o])throw Error("no history");var e=this[t].pop(),i=this[t].pop();this[n].push(e),this._fsm.transit(a,e,i,[])},l.methods[s]=function(){if(!this[d])throw Error("no history");var e=this.state,t=this[n].pop();this._fsm.transit(s,e,t,[])},l}}])},e.exports=i()},function(e,t,n){var i=n(4),r=n(5);"string"==typeof(r=r.__esModule?r.default:r)&&(r=[[e.i,r,""]]);var a={insert:"head",singleton:!1};i(r,a);e.exports=r.locals||{}},function(e,t,n){"use strict";var i,r=function(){return void 0===i&&(i=Boolean(window&&document&&document.all&&!window.atob)),i},a=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),s=[];function o(e){for(var t=-1,n=0;n<s.length;n++)if(s[n].identifier===e){t=n;break}return t}function d(e,t){for(var n={},i=[],r=0;r<e.length;r++){var a=e[r],d=t.base?a[0]+t.base:a[0],c=n[d]||0,l="".concat(d," ").concat(c);n[d]=c+1;var h=o(l),u={css:a[1],media:a[2],sourceMap:a[3]};-1!==h?(s[h].references++,s[h].updater(u)):s.push({identifier:l,updater:_(u,t),references:1}),i.push(l)}return i}function c(e){var t=document.createElement("style"),i=e.attributes||{};if(void 0===i.nonce){var r=n.nc;r&&(i.nonce=r)}if(Object.keys(i).forEach((function(e){t.setAttribute(e,i[e])})),"function"==typeof e.insert)e.insert(t);else{var s=a(e.insert||"head");if(!s)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");s.appendChild(t)}return t}var l,h=(l=[],function(e,t){return l[e]=t,l.filter(Boolean).join("\n")});function u(e,t,n,i){var r=n?"":i.media?"@media ".concat(i.media," {").concat(i.css,"}"):i.css;if(e.styleSheet)e.styleSheet.cssText=h(t,r);else{var a=document.createTextNode(r),s=e.childNodes;s[t]&&e.removeChild(s[t]),s.length?e.insertBefore(a,s[t]):e.appendChild(a)}}function p(e,t,n){var i=n.css,r=n.media,a=n.sourceMap;if(r?e.setAttribute("media",r):e.removeAttribute("media"),a&&"undefined"!=typeof btoa&&(i+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a))))," */")),e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}var f=null,g=0;function _(e,t){var n,i,r;if(t.singleton){var a=g++;n=f||(f=c(t)),i=u.bind(null,n,a,!1),r=u.bind(null,n,a,!0)}else n=c(t),i=p.bind(null,n,t),r=function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(n)};return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else r()}}e.exports=function(e,t){(t=t||{}).singleton||"boolean"==typeof t.singleton||(t.singleton=r());var n=d(e=e||[],t);return function(e){if(e=e||[],"[object Array]"===Object.prototype.toString.call(e)){for(var i=0;i<n.length;i++){var r=o(n[i]);s[r].references--}for(var a=d(e,t),c=0;c<n.length;c++){var l=o(n[c]);0===s[l].references&&(s[l].updater(),s.splice(l,1))}n=a}}}},function(e,t,n){(e.exports=n(6)(!1)).push([e.i,".playkit-ads-cover {\n position: relative;\n cursor: pointer;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0);\n}\n\n.playkit-ads-container {\n opacity: 0;\n pointer-events: none;\n position: absolute;\n}\n",""])},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n=e[1]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var r=(s=i,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(s))))+" */"),a=i.sources.map((function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"}));return[n].concat(a).concat([r]).join("\n")}var s;return[n].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n})).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var i={},r=0;r<this.length;r++){var a=this[r][0];null!=a&&(i[a]=!0)}for(r=0;r<e.length;r++){var s=e[r];null!=s[0]&&i[s[0]]||(n&&!s[2]?s[2]=n:n&&(s[2]="("+s[2]+") and ("+n+")"),t.push(s))}},t}},function(e,t,n){"use strict";n.r(t),n.d(t,"Plugin",(function(){return re})),n.d(t,"VERSION",(function(){return ae})),n.d(t,"NAME",(function(){return se}));var i=n(0),r="loading",a="loaded",s="pending",o="playing",d="paused",c="idle",l="done";function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var u=i.core.BaseMiddleware,p=(i.core.AdBreak,i.core.Ad,function(e){var t,n;function i(t){var n,i,r,a;return n=e.call(this)||this,i=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n),a="ImaMiddleware",(r="id")in i?Object.defineProperty(i,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[r]=a,n._context=t,t.player.addEventListener(t.player.Event.CHANGE_SOURCE_STARTED,(function(){n._isFirstPlay=!0,n._nextLoad=null})),n}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,h(t,n);var r=i.prototype;return r.load=function(e){var t=this;this._nextLoad=e,this._context.loadPromise.catch((function(){return t._callNextLoad()})),this._context.getStateMachine().state!==c&&(this._context.config.adTagUrl||this._context.config.adsResponse)?(this._context.player.addEventListener(this._context.player.Event.AD_BREAK_START,(function(e){return t._adBreak=e.payload.adBreak})),this._context.player.addEventListener(this._context.player.Event.AD_BREAK_END,(function(){t._adBreak=null,t._ad=null})),this._context.player.addEventListener(this._context.player.Event.AD_LOADED,(function(e){t._ad=e.payload.ad,t._ad.linear||t._callNextLoad()})),this._context.player.addEventListener(this._context.player.Event.AD_ERROR,(function(){t._context.logger.debug("Ad error listener on middleware",t._adBreak,t._ad),t._ad&&t._adBreak&&t._ad.position!==t._adBreak.numAds||(t._context.logger.debug("Call next load after ad error on middleware"),t._callNextLoad())})),this._context.player.addEventListener(this._context.player.Event.AD_MANIFEST_LOADED,(function(e){e.payload.adBreaksPosition.includes(0)||t._callNextLoad()}))):this._callNextLoad()},r.play=function(e){var t=this;this._isFirstPlay&&(this._isFirstPlay=!1,this._context.config.disableMediaPreload||this._context.playOnMainVideoTag()?(this._context.player.addEventListener(this._context.player.Event.AD_BREAK_END,(function(){return t._callNextLoad()})),this._context.playOnMainVideoTag()||this._context.player.getVideoElement().src||this._context.player.getVideoElement().load()):this._callNextLoad()),this._context.loadPromise.then((function(){switch(t._context.getStateMachine().state){case o:break;case a:var n=t._context.initialUserAction();if(n)return n.then((function(){t.callNext(e)}));t.callNext(e);break;case d:var i=t._context.resumeAd();if(i)return i.then((function(){t.callNext(e)}));t.callNext(e);break;default:t.callNext(e)}})).catch((function(n){t._context.reset(),t._context.logger.error(n),t.callNext(e)}))},r.pause=function(e){switch(this._context.getStateMachine().state){case d:break;case o:this._context.pauseAd();break;default:this.callNext(e)}},r._callNextLoad=function(){this._nextLoad&&this.callNext(this._nextLoad),this._nextLoad=null},i}(u));function f(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var g=function(){function e(e){var t,n,i,r=this;i=function(e){r._context.playAdNow(e)},(n="playAdNow")in(t=this)?Object.defineProperty(t,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[n]=i,this._context=e}var t,n,i,r=e.prototype;return r.skipAd=function(){this._context.skipAd()},r.onPlaybackEnded=function(){return this._context.onPlaybackEnded()},t=e,(n=[{key:"active",get:function(){return this._context.getStateMachine().state===o||this._context.getStateMachine().state===d}},{key:"done",get:function(){return this._context.getStateMachine().state===l}},{key:"name",get:function(){return this._context.name}}])&&f(t.prototype,n),i&&f(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}(),_=n(1),y=n.n(_),v=n(2),A=n.n(v),m=i.core.AdBreakType,E=i.core.Error,b=i.core.Utils,M=function(e){return new y.a({init:r,transitions:[{name:"loaded",from:[r,a,c,d,o,l],to:a},{name:e.player.Event.AD_STARTED,from:[a,c,d,o,s],to:function(e){return e.getAd().isLinear()?o:c}},{name:e.player.Event.AD_RESUMED,from:[d,o],to:o},{name:e.player.Event.AD_PAUSED,from:o,to:d},{name:e.player.Event.AD_SKIPPED,from:[o,d],to:c},{name:e.player.Event.AD_COMPLETED,from:[o,d]},{name:e.player.Event.ADS_COMPLETED,from:[c,d],to:l},{name:e.player.Event.AD_BREAK_END,from:[c,o,a,d,s],to:c},{name:"adlog",from:[c,a,o,d,r,s],to:c},{name:e.player.Event.AD_ERROR,from:[c,a,o,d,r,s],to:R.bind(e)},{name:e.player.Event.AD_LOADED,from:[c,a,o]},{name:e.player.Event.AD_FIRST_QUARTILE,from:o},{name:e.player.Event.AD_BREAK_START,from:[c,a],to:s},{name:e.player.Event.AD_MIDPOINT,from:o},{name:e.player.Event.AD_THIRD_QUARTILE,from:o},{name:e.player.Event.USER_CLOSED_AD,from:[c,o,d]},{name:e.player.Event.AD_VOLUME_CHANGED,from:[s,o,d,a]},{name:e.player.Event.AD_MUTED,from:[o,d,a]},{name:e.player.Event.AD_CLICKED,from:[o,d,c]},{name:e.player.Event.AD_CAN_SKIP,from:[o,d,a]},{name:e.player.Event.AD_PROGRESS,from:[o,d,s,c]},{name:e.player.Event.AD_BUFFERING,from:"*"},{name:"goto",from:"*",to:function(e){return e}}],methods:{onAdloaded:T.bind(e),onAdstarted:k.bind(e),onAdpaused:U.bind(e),onAdresumed:L.bind(e),onAdclicked:C.bind(e),onAdskipped:w.bind(e),onAdcompleted:S.bind(e),onAdscompleted:D.bind(e),onAdcanskip:I.bind(e),onAdbreakstart:P.bind(e),onAdbreakend:O.bind(e),onAdfirstquartile:U.bind(e),onAdmidpoint:U.bind(e),onAdthirdquartile:U.bind(e),onAdlog:x.bind(e),onUserclosedad:U.bind(e),onAdvolumechanged:U.bind(e),onAdmuted:U.bind(e),onAdprogress:N.bind(e),onAdbuffering:U.bind(e),onEnterState:B.bind(e),onPendingTransition:V.bind(e)},plugins:[new A.a]})};function T(e,t){this.logger.debug(t.type.toUpperCase());var n=H.call(this,t),r=F.call(this,t),a=new i.Ad(t.getAd().getAdId(),r);b.Dom.setAttribute(this._adsContainerDiv,"data-adtype",n),this.logger.warn("adType and extraAdData fields will be deprecated soon from AD_LOADED event payload. See docs for more information"),this.dispatchEvent(e.transition,{ad:a,adType:n,extraAdData:t.getAdData()})}function k(e,t){this.logger.debug(t.type.toUpperCase()),this._currentAd=t.getAd(),this._adVideoTagAlreadyPlayed=!0,this._resizeAd(),this._maybeDisplayCompanionAds(),this._currentAd.isLinear()?this._showAdsContainer():this._nextPromise?this._resolveNextPromise():this.player.play();var n=F.call(this,t),r=new i.Ad(t.getAd().getAdId(),n);this.dispatchEvent(e.transition,{ad:r})}function C(e,t){this.logger.debug(t.type.toUpperCase()),this._currentAd.isLinear()?this._isVideoAd()&&(this._maybeIgnoreClickOnAd(),this._stateMachine.is(o)&&!this.player.isLive()?this._adsManager.pause():this.player.isLive()&&this.resumeAd(),this._setToggleAdsCover(!0)):this.player.paused||this.player.pause(),this.dispatchEvent(e.transition)}function L(e,t){this.logger.debug(t.type.toUpperCase()),this._setToggleAdsCover(!1),this.dispatchEvent(e.transition)}function S(e,t){this.logger.debug(t.type.toUpperCase()),this.dispatchEvent(e.transition)}function D(e,t){this.logger.debug(e.transition.toUpperCase()),this.playOnMainVideoTag()&&this._contentComplete&&!this.player.config.playback.playAdsWithMSE&&(this.player.getVideoElement().src=this._contentSrc),O.call(this,e,t)}function P(e,t){this.logger.debug(t.type.toUpperCase()),this.player.pause();var n=K.call(this,t),r=new i.AdBreak(n);this._maybeSavePlayerSnapshot(),this._maybeForceExitFullScreen(),this._maybeSaveVideoCurrentTime(),this.dispatchEvent(e.transition,{adBreak:r})}function O(e,t){var n=this;this.logger.debug(t.type.toUpperCase()),this._currentAd=null,this._contentComplete||(this.config.forceReloadMediaAfterAds&&(this.eventManager.listenOnce(this.player,this.player.Event.LOADED_DATA,(function(){n._maybeSetVideoCurrentTime(),n.player.play()})),this.player.getVideoElement().load()),this._hideAdsContainer(),this._maybeSetVideoCurrentTime(),this._nextPromise?this._resolveNextPromise():this.config.forceReloadMediaAfterAds||this.player.play()),this._maybeRestorePlayerSnapshot(),this.dispatchEvent(e.transition)}function x(e,t){var n;this.logger.debug(t.type.toUpperCase()),"function"==typeof t.getAdData?n=t.getAdData().adError:"function"==typeof t.getError&&(n=t.getError()),n&&(this.logger.error("Non-fatal error occurred: "+n.getMessage()),this.dispatchEvent(this.player.Event.AD_ERROR,j.call(this,n,!1)))}function R(e){var t=this,n=c;if(this._playAdByConfig()){this.logger.debug(e.type.toUpperCase());var i=e.getError();this._nextPromise?this.playOnMainVideoTag()&&"iOS"!==this.player.env.os.name?setTimeout((function(){t._nextPromise.reject(i)}),0,i):this._nextPromise.reject(i):(this.reset(),n=l),this.dispatchEvent("aderror",j.call(this,i,!0))}return n}function w(e,t){this.logger.debug(t.type.toUpperCase()),this.dispatchEvent(e.transition)}function I(e,t){this.logger.debug(t.type.toUpperCase()),this._adsManager.getAdSkippableState()&&this.dispatchEvent(e.transition)}function N(e,t){this.logger.debug(t.type.toUpperCase());var n=this._adsManager.getRemainingTime(),i=t.getAdData()&&t.getAdData().duration,r=i-n;r=r<0?0:r,b.Number.isNumber(i)&&b.Number.isNumber(r)&&this.dispatchEvent(e.transition,{adProgress:{currentTime:r,duration:i}})}function U(e,t){this.logger.debug(t.type.toUpperCase()),this.dispatchEvent(e.transition)}function B(e){e.from!==e.to&&this.logger.debug("Change state: "+e.from+" => "+e.to)}function V(e,t,n){this.logger.warn("The previous transition is still in progress",{transition:e,from:t,to:n})}function j(e,t){var n,r,a=t?E.Severity.CRITICAL:E.Severity.RECOVERABLE,s=E.Category.ADS;try{n=900!==e.getVastErrorCode()?parseInt(E.Category.ADS+e.getVastErrorCode()):E.Code.AD_UNDEFINED_ERROR}catch(e){n=E.Code.AD_UNDEFINED_ERROR}if(this._adsManager)try{var o=this._adsManager.getCurrentAd(),d={getAd:function(){return o},getAdData:function(){}},c=F.call(this,d);r=new i.Ad(o.getAdId(),c)}catch(e){}return new E(a,s,n,{ad:r,innerError:e})}function F(e){var t={},n=e.getAd(),i=e.getAdData(),r=n.getAdPodInfo();return i&&(this._isVpaid=i.vpaid),t.system=n.getAdSystem(),t.url=n.getMediaUrl(),t.clickThroughUrl=i&&i.clickThroughUrl,t.contentType=n.getContentType(),t.duration=n.getDuration(),t.position=this._adPosition||r.getAdPosition(),t.title=n.getTitle(),t.linear=n.isLinear(),t.skipOffset=n.getSkipTimeOffset(),t.width=n.isLinear()?n.getVastMediaWidth():n.getWidth(),t.height=n.isLinear()?n.getVastMediaHeight():n.getHeight(),t.bitrate=n.getVastMediaBitrate(),t.bumper=r.getIsBumper()||this._isBumper,t.vpaid=this._isVpaid,t.wrapperAdIds=n.getWrapperAdIds(),t.wrapperCreativeIds=n.getWrapperCreativeIds(),t.wrapperAdSystems=n.getWrapperAdSystems(),t}function K(e){var t={};return t.numAds=this._podLength||e.getAd().getAdPodInfo().getTotalAds(),t.position=this.player.ended?-1:this.player.currentTime,t.type=H.call(this,e),t}function H(e){try{if(!e.getAd().isLinear())return m.OVERLAY}catch(e){}return this._playAdByConfig()?function(e){var t=e.getAd(),n=t.getAdPodInfo().getPodIndex();if(!t.isLinear())return m.OVERLAY;switch(n){case 0:return m.PRE;case-1:return m.POST;default:return m.MID}}(e):this._getAdBreakTypeFromPlayer()}n(3);function W(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}i.core.FakeEvent;var G=function(){function e(e,t){this._plugin=t}var t,n,i;return e.prototype.dispatchEvent=function(e){return e.defaultPrevented},t=e,(n=[{key:"active",get:function(){return this._plugin.playOnMainVideoTag()&&this._plugin.isAdPlaying()}},{key:"paused",get:function(){return!0}},{key:"currentTime",get:function(){return this._plugin.getContentTime()},set:function(e){}},{key:"duration",get:function(){return this._plugin.getContentDuration()}},{key:"ended",get:function(){return this._plugin.getContentEnded()}}])&&W(t.prototype,n),i&&W(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();function z(){return(z=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function q(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Q(e,t){return(Q=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function Y(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}i.core.BaseMiddleware;var J=i.core.EngineType,X=i.core.Error,Z=i.core.getCapabilities,$=i.core.Utils,ee=i.core.Env,te=(i.core.AudioTrack,i.core.TextTrack,i.core.EventManager),ne=i.core.AdBreakType,ie=["fullscreenchange","mozfullscreenchange","webkitfullscreenchange"],re=function(e){var t,n;function i(t,n,i){var r;return Y(q(r=e.call(this,t,n,i)||this),"_adVideoTagAlreadyPlayed",!1),Y(q(r),"_adStartedEvent",null),Y(q(r),"_engine",null),r._stateMachine=new M(q(r)),r._initMembers(),r._init(),r}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,Q(t,n),i.isValid=function(){return!0};var r=i.prototype;return r.getEngineDecorator=function(e){return this._engine=e,new G(e,this)},r.getMiddlewareImpl=function(){return new p(this)},r.getAdsController=function(){return new g(this)},r.playAdNow=function(e){!Array.isArray(e)||this.isAdPlaying()||this._playAdByConfig()||this._playAdBreak(e)},r._playAdBreak=function(e){var t=this;this._podLength=e.length,this._adPosition=1,this._firstOfAdPod=!0,this._waterfalled=!1,this.loadPromise.then((function(){t._playAd(e),!t._hasUserAction&&t.player.currentTime>0&&t.initialUserAction()})).catch((function(){}))},r._playAd=function(e){var t=this,n=e[0],i=function(){e.shift(),t._adBreaksEventManager.removeAll(),t._waterfalled=!1,t._podLength=e.length,t._adPosition++,t._playAd(e)},r=function(r){n.url&&n.url.length>1||!n.url&&n.response&&n.response.length>1?function(i){t.dispatchEvent(t.player.Event.AD_WATERFALLING,{adFailed:{url:n.url?n.url[0]:"",response:!n.url&&n.response?n.response[0]:"",data:i,adBreak:t._getAdBreakTypeFromPlayer(),position:t._adPosition}}),t._adBreaksEventManager.removeAll(),t._waterfalled=!0,n.url?n.url.shift():n.response&&n.response.shift(),t._playAd(e)}(r):(t._waterfalled&&t.dispatchEvent(t.player.Event.AD_WATERFALLING_FAILED),t._stateMachine.adlog(r),i())};n&&(this._adBreaksEventManager.listen(this._adsLoader,this._sdk.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,(function(){t._adBreaksEventManager.listen(t._adsManager,t._sdk.AdEvent.Type.COMPLETE,i),t._adBreaksEventManager.listen(t._adsManager,t._sdk.AdEvent.Type.SKIPPED,i),t._adBreaksEventManager.listen(t._adsManager,t._sdk.AdEvent.Type.LOG,r),t._adBreaksEventManager.listen(t._adsManager,t._sdk.AdErrorEvent.Type.AD_ERROR,r)})),this._adBreaksEventManager.listen(this._adsLoader,this._sdk.AdErrorEvent.Type.AD_ERROR,(function(e){r(e),0===t._podLength&&(t.player.ads.isAdBreak()&&t._stateMachine.adbreakend({type:t._sdk.AdEvent.Type.CONTENT_RESUME_REQUESTED}),t._hasUserAction?t._stateMachine.adscompleted({type:t._sdk.AdEvent.Type.ALL_ADS_COMPLETED}):t.eventManager.listen(t.player,t.player.Event.FIRST_PLAY,(function(){t._stateMachine.adscompleted({type:t._sdk.AdEvent.Type.ALL_ADS_COMPLETED})})))})),this._isBumper=!!n.bumper,this._requestAds(n.url&&n.url[0],n.response&&n.response[0]))},r._getAdBreakTypeFromPlayer=function(){return this.player.ended?ne.POST:this.player.currentTime>0?ne.MID:ne.PRE},r.skipAd=function(){this.logger.debug("Skip ad"),this._adsManager&&(this._adsManager.getAdSkippableState()?this._adsManager.skip():this.config.skipSupport&&this._adsManager.stop())},r.resumeAd=function(){return this.logger.debug("Resume ad"),this._nextPromise=$.Object.defer(),this._adsManager.resume(),this._nextPromise},r.pauseAd=function(){this.logger.debug("Pause ad"),this._adsManager.pause()},r.getStateMachine=function(){return this._stateMachine},r.playOnMainVideoTag=function(){return!!this._adsManager&&!!this._adsManager.isCustomPlaybackUsed()},r.isAdPlaying=function(){return this._stateMachine.is(o)||this._stateMachine.is(s)||this._stateMachine.is(d)},r.getContentTime=function(){var e=0;return this._videoLastCurrentTime?e=this._videoLastCurrentTime:this._contentComplete&&(e=this.getContentDuration()),e},r.getContentDuration=function(){return this._contentDuration||this.player.config.sources.duration||0},r.getContentSrc=function(){return this._contentSrc||""},r.getContentEnded=function(){return this._contentComplete},r.loadMedia=function(){var e=this;this._addBindings(),this.loadPromise.then((function(){e._adDisplayContainer||(e._adDisplayContainer=new e._sdk.AdDisplayContainer(e._adsContainerDiv,e.player.getVideoElement())),e._adsLoader||e._initAdsLoader()})),this._playAdByConfig()&&this.loadPromise.then((function(){return e._requestAds()})).catch((function(){}))},r.reset=function(){this.logger.debug("reset"),this.eventManager.removeAll(),this._adBreaksEventManager.removeAll(),this._hideAdsContainer(),this._isImaSDKLibLoaded()&&(this._destroyIMAManagers(),this._stateMachine.goto(l),this._initMembers())},r.destroy=function(){this.logger.debug("destroy"),this.eventManager.destroy(),this._hideAdsContainer(),this._destroyIMAManagers()},r._destroyIMAManagers=function(){this._adsManager&&this._adsManager.destroy(),this._adsLoader&&(this._adsLoader.destroy(),this._adsLoader=null),this._adDisplayContainer&&(this._adDisplayContainer.destroy(),this._adDisplayContainer=null)},r.initialUserAction=function(){try{this.logger.debug("Initial user action"),this._nextPromise=$.Object.defer(),this._adDisplayContainer.initialize(),this._hasUserAction=!0,this._isAdsManagerLoaded&&(this.logger.debug("User action occurred after ads manager loaded"),this._startAdsManager())}catch(e){this.logger.error(e),this.reset()}return this._nextPromise},r._startAdsManager=function(){var e=this;this.logger.debug("Start ads manager"),(this.playOnMainVideoTag()&&!this.config.disableMediaPreload?this.player.ready():Promise.resolve()).then((function(){e._adsManager.init(e.player.dimensions.width,e.player.dimensions.height,e._sdk.ViewMode.NORMAL),e._adsManager.start()}))},r._addBindings=function(){var e=this;ie.forEach((function(t){return e.eventManager.listen(document,t,(function(){return e._resizeAd()}))})),this.eventManager.listen(this.player,"resize",(function(){return e._resizeAd()})),this.eventManager.listen(this.player,this.player.Event.MUTE_CHANGE,(function(){return e._syncPlayerVolume()})),this.eventManager.listen(this.player,this.player.Event.VOLUME_CHANGE,(function(){return e._syncPlayerVolume()})),this.eventManager.listen(this.player,this.player.Event.SOURCE_SELECTED,(function(t){var n=t.payload.selectedSource;n&&n.length>0&&(e._contentSrc=n[0].url)})),this.eventManager.listenOnce(this.player,this.player.Event.DURATION_CHANGE,(function(){e._contentDuration=e.player.duration})),this.eventManager.listen(this.player,this.player.Event.ERROR,(function(t){t.payload&&t.payload.severity===X.Severity.CRITICAL&&e.reset()})),this.eventManager.listen(this.player,this.player.Event.FIRST_PLAY,(function(){e._currentAd&&!e._currentAd.isLinear()&&e._showAdsContainer()})),this.eventManager.listen(this.player,this.player.Event.MEDIA_LOADED,(function(){var t;null==(t=e._adsManager)||t.updateAdsRenderingSettings({restoreCustomPlaybackStateOnAdBreakComplete:!e.player.config.playback.playAdsWithMSE})})),this.eventManager.listen(this.player,this.player.Event.ENDED,(function(){return e._onMediaEnded()})),this.eventManager.listen(this.player,this.player.Event.LOADED_METADATA,(function(){return e._onLoadedMetadata()})),this.eventManager.listen(this.player,this.player.Event.TIME_UPDATE,(function(){return e._onMediaTimeUpdate()})),this.eventManager.listen(this.player,this.player.Event.SEEKING,(function(){return e._onMediaSeeking()})),this.eventManager.listen(this.player,this.player.Event.SEEKED,(function(){return e._onMediaSeeked()})),this._playAdByConfig()||this.eventManager.listenOnce(this.player,this.player.Event.USER_GESTURE,(function(){e._adVideoTagAlreadyPlayed||e._adDisplayContainer.initialize()}))},r._initMembers=function(){this._nextPromise=null,this._currentAd=null,this._adsManager=null,this._contentComplete=!1,this._isAdsManagerLoaded=!1,this._videoLastCurrentTime=null,this._contentPlayheadTracker={currentTime:0,previousTime:0,seeking:!1,duration:0},this._hasUserAction=!1,this._togglePlayPauseOnAdsContainerCallback=null,this._contentDuration=null,this._selectedAudioTrack=null,this._selectedTextTrack=null,this._selectedPlaybackRate=1,this._textTracksHidden=[],this._adBreaksEventManager=new te,this._podLength=0,this._adPosition=0,this._firstOfAdPod=!1,this._waterfalled=!1,this._isBumper=!1,this._isVpaid=!1},r._init=function(){var e=this;this.loadPromise=$.Object.defer(),this._maybeDelayInitUntilSourceSelected().then((function(){return e._loadImaSDKLib()})).then((function(){e._sdk=window.google.ima,e.logger.debug("IMA SDK version: "+e._sdk.VERSION),e._initImaSettings(),e._initAdsContainer(),e._initAdsLoader(),e.loadPromise.resolve()})).catch((function(t){e.loadPromise.reject(t)}))},r._maybeDelayInitUntilSourceSelected=function(){var e=this;return this.config.delayInitUntilSourceSelected?new Promise((function(t,n){e._contentSrc?t():(e.eventManager.listenOnce(e.player,e.player.Event.SOURCE_SELECTED,t),e.eventManager.listenOnce(e.player,e.player.Event.ERROR,(function(e){e.payload.severity===X.Severity.CRITICAL&&n(e)})))})):Promise.resolve()},r._loadImaSDKLib=function(){var e=$.Http.protocol+(this.config.debug?i.IMA_SDK_DEBUG_LIB_URL:i.IMA_SDK_LIB_URL);return this._isImaSDKLibLoaded()?Promise.resolve():$.Dom.loadScriptAsync(e)},r._isImaSDKLibLoaded=function(){return window.google&&window.google.ima&&window.google.ima.VERSION},r._initImaSettings=function(){this._sdk.settings.setPlayerType(this.config.playerName),this._sdk.settings.setPlayerVersion(this.config.playerVersion),this._sdk.settings.setVpaidAllowed(!0),this._sdk.settings.setVpaidMode(this._getVpaidMode()),Object.prototype.hasOwnProperty.call(this.config,"locale")&&this._sdk.settings.setLocale(this.config.locale),"boolean"==typeof this.config.setDisableCustomPlaybackForIOS10Plus?this._sdk.settings.setDisableCustomPlaybackForIOS10Plus(this.config.setDisableCustomPlaybackForIOS10Plus):this._sdk.settings.setDisableCustomPlaybackForIOS10Plus(this.player.config.playback.playsinline),"number"==typeof this.config.numRedirects&&this._sdk.settings.setNumRedirects(this.config.numRedirects),"string"==typeof this.config.sessionId&&this._sdk.settings.setSessionId(this.config.sessionId)},r._getVpaidMode=function(){var e=this._sdk.ImaSdkSettings.VpaidMode[this.config.vpaidMode];return this.config.vpaidMode&&"number"==typeof e?(this.logger.debug("VpaidMode: set to "+this.config.vpaidMode),e):(this.logger.warn("VpaidMode is not set, setting to ENABLED"),this._sdk.ImaSdkSettings.VpaidMode.ENABLED)},r._initAdsContainer=function(){var e=this;this.logger.debug("Init ads container");var t=this.player.getView();this._adsContainerDiv=$.Dom.createElement("div"),this._adsContainerDiv.id="playkit-ads-container"+t.id,this._adsContainerDiv.className="playkit-ads-container",this._adsCoverDiv=$.Dom.createElement("div"),this._adsCoverDiv.id="playkit-ads-cover"+t.id,this._adsCoverDiv.className="playkit-ads-cover",this._adsCoverDiv.onclick=function(){return e._onAdsCoverClicked()},$.Dom.appendChild(t,this._adsContainerDiv),this._adDisplayContainer=new this._sdk.AdDisplayContainer(this._adsContainerDiv,this.player.getVideoElement())},r._initAdsLoader=function(){var e=this;this.logger.debug("Init ads loader"),this._adsLoader=new this._sdk.AdsLoader(this._adDisplayContainer),this._adsLoader.addEventListener(this._sdk.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,(function(t){return e._onAdsManagerLoaded(t)})),this._adsLoader.addEventListener(this._sdk.AdErrorEvent.Type.AD_ERROR,(function(t){return e._stateMachine.aderror(t)}))},r._requestAds=function(e,t){var n=this;if(e||t||this._playAdByConfig()){this.logger.debug("Request ads");var i=new this._sdk.AdsRequest,r=e||this.config.adTagUrl;if(r?i.adTagUrl=r:i.adsResponse=t||this.config.adsResponse,"number"==typeof this.config.vastLoadTimeout&&(i.vastLoadTimeout=this.config.vastLoadTimeout),"object"==typeof this.config.omidAccessModes)for(var a=0,s=Object.entries(this.config.omidAccessModes);a<s.length;a++){var o=s[a],d=o[0],c=o[1];i.omidAccessModeRules[this._sdk.OmidVerificationVendor[d]]=this._sdk.OmidAccessMode[c]}i.linearAdSlotWidth=this.player.dimensions.width,i.linearAdSlotHeight=this.player.dimensions.height,i.nonLinearAdSlotWidth=this.player.dimensions.width,i.nonLinearAdSlotHeight=this.player.dimensions.height/3,i.contentDuration=-3;var h=this.player.muted||0===this.player.volume;i.setAdWillPlayMuted(h);var u=this.config.adWillAutoPlay,p=this.player.config.playback.autoplay,f=this.player.config.playback.allowMutedAutoPlay;"boolean"==typeof u?(i.setAdWillAutoPlay(u),this._adsLoader.requestAds(i)):p?Z(J.HTML5).then((function(e){n._adsLoader&&(e.autoplay?i.setAdWillAutoPlay(!0):f&&e.mutedAutoPlay?(i.setAdWillAutoPlay(!0),i.setAdWillPlayMuted(!0)):i.setAdWillAutoPlay(!1),n._adsLoader.requestAds(i))})):(i.setAdWillAutoPlay(!1),this._adsLoader.requestAds(i)),this._stateMachine.loaded()}else this._stateMachine.goto(l),this.logger.debug("Missing ad tag url: create plugin without requesting ads")},r._resizeAd=function(){if(this._sdk&&this._adsManager&&this._currentAd){var e=this.player.isFullscreen()?this._sdk.ViewMode.FULLSCREEN:this._sdk.ViewMode.NORMAL;if(this._currentAd.isLinear()||this._isVpaid)this._adsManager.resize(this.player.dimensions.width,this.player.dimensions.height,e);else{var t=this._currentAd.getWidth()+8,n=this._currentAd.getHeight()+8;t<=this.player.dimensions.width&&n<=this.player.dimensions.height?(this._alignAdsContainerSizeForOverlayAd(),this._adsManager.resize(t,n,e),this._showAdsContainer()):this._hideAdsContainer()}}},r._alignAdsContainerSizeForOverlayAd=function(){this._adsContainerDiv.style.bottom=this._currentAd.getHeight()+8+"px",this._adsContainerDiv.style.left=(this.player.dimensions.width-this._currentAd.getWidth())/2+"px"},r._onLoadedMetadata=function(){this._contentPlayheadTracker.duration=this.player.duration},r._onMediaTimeUpdate=function(){!this._contentPlayheadTracker.seeking&&this.player.currentTime>0&&(this._contentPlayheadTracker.previousTime=this._contentPlayheadTracker.currentTime,this._contentPlayheadTracker.currentTime=this.player.currentTime)},r._onMediaSeeking=function(){this._contentPlayheadTracker.seeking=!0},r._onMediaSeeked=function(){this._contentPlayheadTracker.seeking=!1},r._maybeSaveVideoCurrentTime=function(){(this.playOnMainVideoTag()||this.config.forceReloadMediaAfterAds)&&this._engine.currentTime>0&&(this.logger.debug("Custom playback used: save current time before ads",this._engine.currentTime),this._videoLastCurrentTime=this._engine.currentTime)},r._maybeSetVideoCurrentTime=function(){this._videoLastCurrentTime&&(this.logger.debug("Custom playback used: set current time after ads",this._videoLastCurrentTime),this.player.currentTime=this._videoLastCurrentTime,this._videoLastCurrentTime=null)},r._hasPostRoll=function(){return this._adsManager&&this._adsManager.getCuePoints().includes(-1)},r._onMediaEnded=function(){this.logger.debug("Media ended"),this._contentComplete=!0,this._currentAd&&!this._currentAd.isLinear()?this.reset():this._hasPostRoll()||this._stateMachine.goto(l)},r.onPlaybackEnded=function(){var e=this;return this.logger.debug("Playback ended"),this._adsLoader&&this._adsLoader.contentComplete(),this._hasPostRoll()?new Promise((function(t){e.eventManager.listenOnce(e._adsManager,e._sdk.AdEvent.Type.ALL_ADS_COMPLETED,(function(){t()}))})):Promise.resolve()},r._showAdsContainer=function(){this._adsContainerDiv&&(this._adsContainerDiv.style.opacity=1,this._adsContainerDiv.style.pointerEvents="auto")},r._hideAdsContainer=function(){this._adsContainerDiv&&(this._adsContainerDiv.style.opacity=0,this._adsContainerDiv.style.pointerEvents="none")},r._onAdsManagerLoaded=function(e){var t=this;this.logger.debug("Ads manager loaded");var n=this._getAdsRenderingSetting();this._adsManager=e.getAdsManager(this._contentPlayheadTracker,n),this.config.forceReloadMediaAfterAds=!this.playOnMainVideoTag()&&this.config.forceReloadMediaAfterAds;var i=[].concat(this._adsManager.getCuePoints());i.length||i.push(0),this._playAdByConfig()&&(this.dispatchEvent(this.player.Event.AD_MANIFEST_LOADED,{adBreaksPosition:i}),this.player.hasService("timeline")&&this.config.showAdBreakCuePoint&&i.forEach((function(e){t.player.getService("timeline").addCuePoint(z({time:-1!==e?e:1/0},t.config.adBreakCuePointStyle))}))),this._isAdsManagerLoaded=!0,this._attachAdsManagerListeners(),this._syncPlayerVolume(),this._hasUserAction&&(this.logger.debug("User action occurred before ads manager loaded"),this._startAdsManager())},r._getAdsRenderingSetting=function(){var e=this,t=new this._sdk.AdsRenderingSettings;return Object.keys(this.config.adsRenderingSettings).forEach((function(n){void 0!==t[n]?t[n]=e.config.adsRenderingSettings[n]:e.logger.warn("unsupported adsRenderingSettings was set:",n)})),t.restoreCustomPlaybackStateOnAdBreakComplete=!1,"number"!=typeof this.config.adsRenderingSettings.playAdsAfterTime&&(t.playAdsAfterTime=this.player.config.sources.startTime),t},r._attachAdsManagerListeners=function(){var e=this;this._adsManager.addEventListener(this._sdk.AdEvent.Type.CONTENT_PAUSE_REQUESTED,(function(t){(e._playAdByConfig()||e._firstOfAdPod)&&(e._firstOfAdPod=!1,e._stateMachine.adbreakstart(t),e._adStartedEvent&&(e._stateMachine.adstarted(e._adStartedEvent),e._adStartedEvent=null))})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.CONTENT_RESUME_REQUESTED,(function(t){(e._playAdByConfig()||0===e._podLength)&&e._stateMachine.adbreakend(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.ALL_ADS_COMPLETED,(function(t){(e._playAdByConfig()||0===e._podLength)&&e._stateMachine.adscompleted(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.LOADED,(function(t){return e._stateMachine.adloaded(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.STARTED,(function(t){t.getAd().isLinear()&&!e.player.ads.isAdBreak()?e._adStartedEvent=t:e._stateMachine.adstarted(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.PAUSED,(function(t){return e._stateMachine.adpaused(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.RESUMED,(function(t){return e._stateMachine.adresumed(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.FIRST_QUARTILE,(function(t){return e._stateMachine.adfirstquartile(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.MIDPOINT,(function(t){return e._stateMachine.admidpoint(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.THIRD_QUARTILE,(function(t){return e._stateMachine.adthirdquartile(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.CLICK,(function(t){return e._stateMachine.adclicked(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.SKIPPED,(function(t){return e._stateMachine.adskipped(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.COMPLETE,(function(t){return e._stateMachine.adcompleted(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.USER_CLOSE,(function(t){return e._stateMachine.userclosedad(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.VOLUME_CHANGED,(function(t){return e._stateMachine.advolumechanged(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.VOLUME_MUTED,(function(t){return e._stateMachine.admuted(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.AD_PROGRESS,(function(t){return e._stateMachine.adprogress(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.AD_BUFFERING,(function(t){return e._stateMachine.adbuffering(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.LOG,(function(t){return e._stateMachine.adlog(t)})),this._adsManager.addEventListener(this._sdk.AdEvent.Type.SKIPPABLE_STATE_CHANGED,(function(t){return e._stateMachine.adcanskip(t)})),this._adsManager.addEventListener(this._sdk.AdErrorEvent.Type.AD_ERROR,(function(t){return e._stateMachine.aderror(t)}))},r._syncPlayerVolume=function(){this._adsManager&&(this.player.muted?this._adsManager.setVolume(0):this._adsManager&&!isNaN(this.player.volume)&&"number"==typeof this.player.volume&&this._adsManager.setVolume(this.player.volume))},r._resolveNextPromise=function(){this._nextPromise&&(this._nextPromise.resolve(),this._nextPromise=null)},r._setToggleAdsCover=function(e){e?this.playOnMainVideoTag()||this._adsContainerDiv.parentNode&&(this._adsContainerDiv.parentNode.insertBefore(this._adsCoverDiv,this._adsContainerDiv.nextSibling),this._isAdsCoverActive=!0):this._isAdsCoverActive&&this._adsContainerDiv.parentNode&&(this._adsContainerDiv.parentNode.removeChild(this._adsCoverDiv),this._isAdsCoverActive=!1)},r._onAdsCoverClicked=function(){if(this._adsManager)switch(this._stateMachine.state){case d:this._adsManager.resume();break;case o:this._adsManager.pause()}},r._maybeDisplayCompanionAds=function(){var e;if(null!=(e=this.config.companions)&&e.ads){var t,n;$.Object.isObject(null==(t=window)||null==(n=t.googletag)?void 0:n.cmd)&&this.logger.warn("googletag exists. Do not display the companions manually");var i=new this._sdk.CompanionAdSelectionSettings;i.resourceType=this._sdk.CompanionAdSelectionSettings.ResourceType.ALL,i.creativeType=this._sdk.CompanionAdSelectionSettings.CreativeType.ALL;var r=this.config.companions.sizeCriteria;i.sizeCriteria=this._sdk.CompanionAdSelectionSettings.SizeCriteria[r]||this._sdk.CompanionAdSelectionSettings.SizeCriteria.SELECT_EXACT_MATCH;for(var a=Object.keys(this.config.companions.ads),s=0;s<a.length;s++){var o=a[s],d=this.config.companions.ads[o],c=d.width,l=d.height;try{var h=this._currentAd.getCompanionAds(c,l,i);if(h.length>0){var u=h[0].getContent(),p=$.Dom.getElementById(o);p&&(p.innerHTML=u)}}catch(e){this.logger.error("Error occurred while extracting companion ad",e)}}}},r._maybeIgnoreClickOnAd=function(){var e=this;"Android"===e.player.env.os.name&&"Chrome"===e.player.env.browser.name&&this.eventManager.listenOnce(this.player.getView(),"click",(function(e){return e.stopPropagation()}))},r._hideActiveTextTracksOnAVPlayer=function(){var e=this;if("iOS"===this.player.env.os.name&&this.playOnMainVideoTag()){var t=this.play