UNPKG

flowplayer-vpaid

Version:

VPAID 2.0 (Flash/JS) support within Flowplayer 6 HTML

6 lines 32.2 kB
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.fpvpaid = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ (function (global){ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.fpvpaid=e()}}(function(){return function e(t,i,n){function r(a,s){if(!i[a]){if(!t[a]){var l="function"==typeof require&&require;if(!s&&l)return l(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var d=i[a]={exports:{}};t[a][0].call(d.exports,function(e){var i=t[a][1][e];return r(i?i:e)},d,d.exports,e,t,i,n)}return i[a].exports}for(var o="function"==typeof require&&require,a=0;a<n.length;a++)r(n[a]);return r}({1:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),o=i.IVPAIDAdUnit=function(){function e(){n(this,e)}return r(e,[{key:"handshakeVersion",value:function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:"2.0",arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0}},{key:"initAd",value:function(e,t,i,n){arguments.length>4&&void 0!==arguments[4]?arguments[4]:{AdParameters:""},arguments.length>5&&void 0!==arguments[5]?arguments[5]:{flashVars:""},arguments.length>6&&void 0!==arguments[6]?arguments[6]:void 0}},{key:"resizeAd",value:function(e,t,i){arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0}},{key:"startAd",value:function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0}},{key:"stopAd",value:function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0}},{key:"pauseAd",value:function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0}},{key:"resumeAd",value:function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0}},{key:"expandAd",value:function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0}},{key:"collapseAd",value:function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0}},{key:"skipAd",value:function(){arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0}},{key:"getAdLinear",value:function(e){}},{key:"getAdWidth",value:function(e){}},{key:"getAdHeight",value:function(e){}},{key:"getAdExpanded",value:function(e){}},{key:"getAdSkippableState",value:function(e){}},{key:"getAdRemainingTime",value:function(e){}},{key:"getAdDuration",value:function(e){}},{key:"setAdVolume",value:function(e){arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0}},{key:"getAdVolume",value:function(e){}},{key:"getAdCompanions",value:function(e){}},{key:"getAdIcons",value:function(e){}}]),e}();Object.defineProperty(o,"EVENTS",{writable:!1,configurable:!1,value:["AdLoaded","AdStarted","AdStopped","AdSkipped","AdSkippableStateChange","AdSizeChange","AdLinearChange","AdDurationChange","AdExpandedChange","AdRemainingTimeChange","AdVolumeChange","AdImpression","AdVideoStart","AdVideoFirstQuartile","AdVideoMidpoint","AdVideoThirdQuartile","AdVideoComplete","AdClickThru","AdInteraction","AdUserAcceptInvitation","AdUserMinimize","AdUserClose","AdPaused","AdPlaying","AdLog","AdError"]})},{}],2:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(i,"__esModule",{value:!0});var a=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),s=e("./IVPAIDAdUnit").IVPAIDAdUnit,l=Object.getOwnPropertyNames(s.prototype).filter(function(e){return["constructor"].indexOf(e)===-1});i.VPAIDAdUnit=function(e){function t(e){n(this,t);var i=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return i._destroyed=!1,i._flash=e,i}return o(t,e),a(t,[{key:"_destroy",value:function(){var e=this;this._destroyed=!0,l.forEach(function(t){e._flash.removeCallbackByMethodName(t)}),s.EVENTS.forEach(function(t){e._flash.offEvent(t)}),this._flash=null}},{key:"isDestroyed",value:function(){return this._destroyed}},{key:"on",value:function(e,t){this._flash.on(e,t)}},{key:"off",value:function(e,t){this._flash.off(e,t)}},{key:"handshakeVersion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"2.0",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;this._flash.callFlashMethod("handshakeVersion",[e],t)}},{key:"initAd",value:function(e,t,i,n){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{AdParameters:""},o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{flashVars:""},a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:void 0;this._flash.setSize(e,t),r=r||{AdParameters:""},o=o||{flashVars:""},this._flash.callFlashMethod("initAd",[this._flash.getWidth(),this._flash.getHeight(),i,n,r.AdParameters||"",o.flashVars||""],a)}},{key:"resizeAd",value:function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0;this._flash.setSize(e,t),this._flash.callFlashMethod("resizeAd",[this._flash.getWidth(),this._flash.getHeight(),i],n)}},{key:"startAd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;this._flash.callFlashMethod("startAd",[],e)}},{key:"stopAd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;this._flash.callFlashMethod("stopAd",[],e)}},{key:"pauseAd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;this._flash.callFlashMethod("pauseAd",[],e)}},{key:"resumeAd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;this._flash.callFlashMethod("resumeAd",[],e)}},{key:"expandAd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;this._flash.callFlashMethod("expandAd",[],e)}},{key:"collapseAd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;this._flash.callFlashMethod("collapseAd",[],e)}},{key:"skipAd",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;this._flash.callFlashMethod("skipAd",[],e)}},{key:"getAdLinear",value:function(e){this._flash.callFlashMethod("getAdLinear",[],e)}},{key:"getAdWidth",value:function(e){this._flash.callFlashMethod("getAdWidth",[],e)}},{key:"getAdHeight",value:function(e){this._flash.callFlashMethod("getAdHeight",[],e)}},{key:"getAdExpanded",value:function(e){this._flash.callFlashMethod("getAdExpanded",[],e)}},{key:"getAdSkippableState",value:function(e){this._flash.callFlashMethod("getAdSkippableState",[],e)}},{key:"getAdRemainingTime",value:function(e){this._flash.callFlashMethod("getAdRemainingTime",[],e)}},{key:"getAdDuration",value:function(e){this._flash.callFlashMethod("getAdDuration",[],e)}},{key:"setAdVolume",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;this._flash.callFlashMethod("setAdVolume",[e],t)}},{key:"getAdVolume",value:function(e){this._flash.callFlashMethod("getAdVolume",[],e)}},{key:"getAdCompanions",value:function(e){this._flash.callFlashMethod("getAdCompanions",[],e)}},{key:"getAdIcons",value:function(e){this._flash.callFlashMethod("getAdIcons",[],e)}}]),t}(s)},{"./IVPAIDAdUnit":1}],3:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(){if(this._destroyed)throw new error("VPAIDFlashToJS is destroyed!")}function o(){this._loadLater&&(this.loadAdUnit(this._loadLater.url,this._loadLater.callback),delete this._loadLater)}function a(e,t){Object.defineProperty(y,e,{writable:!1,configurable:!1,value:t})}var s=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),l=e("./jsFlashBridge").JSFlashBridge,u=e("./VPAIDAdUnit").VPAIDAdUnit,d=e("./utils").noop,c=e("./utils").callbackTimeout,h=e("./utils").isPositiveInt,f=e("./utils").createElementWithID,p=e("./utils").unique("vpaid"),v="10.1.0",y=function(){function e(t,i){function r(e){return setTimeout(function(){i(new Error(e))},0),this}var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{data:"VPAIDFlash.swf",width:800,height:400},s=this,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{wmode:"transparent",salign:"tl",align:"left",allowScriptAccess:"always",scale:"noScale",allowFullScreen:"true",quality:"high"},y=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{debug:!1,timeout:1e4};if(n(this,e),!e.hasExternalDependencies())return r("no swfobject in global scope. check: https://github.com/swfobject/swfobject or https://code.google.com/p/swfobject/");if(this._vpaidParentEl=t,this._flashID=p(),this._destroyed=!1,i=i||d,a.width=h(a.width,800),a.height=h(a.height,400),f(t,this._flashID),u.movie=a.data,u.FlashVars="flashid="+this._flashID+"&handler="+l.VPAID_FLASH_HANDLER+"&debug="+y.debug+"&salign="+u.salign,!e.isSupported())return r("user don't support flash or doesn't have the minimum required version of flash "+v);if(this.el=swfobject.createSWF(a,u,this._flashID),!this.el)return r("swfobject failed to create object in element");var g=c(y.timeout,function(e,t){o.call(s),i(e,t)},function(){i("vpaid flash load timeout "+y.timeout)});this._flash=new l(this.el,a.data,this._flashID,a.width,a.height,g)}return s(e,[{key:"destroy",value:function(){this._destroyAdUnit(),this._flash&&(this._flash.destroy(),this._flash=null),this.el=null,this._destroyed=!0}},{key:"isDestroyed",value:function(){return this._destroyed}},{key:"_destroyAdUnit",value:function(){delete this._loadLater,this._adUnitLoad&&(this._adUnitLoad=null,this._flash.removeCallback(this._adUnitLoad)),this._adUnit&&(this._adUnit._destroy(),this._adUnit=null)}},{key:"loadAdUnit",value:function(e,t){var i=this;r.call(this),this._adUnit&&this._destroyAdUnit(),this._flash.isReady()?(this._adUnitLoad=function(e,n){e||(i._adUnit=new u(i._flash)),i._adUnitLoad=null,t(e,i._adUnit)},this._flash.callFlashMethod("loadAdUnit",[e],this._adUnitLoad)):this._loadLater={url:e,callback:t}}},{key:"unloadAdUnit",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0;r.call(this),this._destroyAdUnit(),this._flash.callFlashMethod("unloadAdUnit",[],e)}},{key:"getFlashID",value:function(){return r.call(this),this._flash.getFlashID()}},{key:"getFlashURL",value:function(){return r.call(this),this._flash.getFlashURL()}}]),e}();a("isSupported",function(){return y.hasExternalDependencies()&&swfobject.hasFlashPlayerVersion(v)}),a("hasExternalDependencies",function(){return!!window.swfobject}),window.VPAIDFLASHClient=y,t.exports=y},{"./VPAIDAdUnit":2,"./jsFlashBridge":4,"./utils":7}],4:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t,i){var n=this;setTimeout(function(){var r=n._callbacks.get(e);r&&(n._callbacks.remove(e),r(t,i))},0)}Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),a=e("./utils").unique,s=e("./utils").isPositiveInt,l=e("./utils").stringEndsWith,u=e("./registry").SingleValueRegistry,d=e("./registry").MultipleValuesRegistry,c=e("./jsFlashBridgeRegistry"),h="vpaid_video_flash_handler",f="AdError",p=i.JSFlashBridge=function(){function e(t,i,r,o,s,l){n(this,e),this._el=t,this._flashID=r,this._flashURL=i,this._width=o,this._height=s,this._handlers=new d,this._callbacks=new u,this._uniqueMethodIdentifier=a(this._flashID),this._ready=!1,this._handShakeHandler=l,c.addInstance(this._flashID,this)}return o(e,[{key:"on",value:function(e,t){this._handlers.add(e,t)}},{key:"off",value:function(e,t){return this._handlers.remove(e,t)}},{key:"offEvent",value:function(e){return this._handlers.removeByKey(e)}},{key:"offAll",value:function(){return this._handlers.removeAll()}},{key:"callFlashMethod",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n="";i&&(n=this._uniqueMethodIdentifier()+"_"+e,this._callbacks.add(n,i));try{this._el[e]([n].concat(t))}catch(e){i?r.call(this,n,e):this._trigger(f,e)}}},{key:"removeCallback",value:function(e){return this._callbacks.removeByValue(e)}},{key:"removeCallbackByMethodName",value:function(e){var t=this;this._callbacks.filterKeys(function(t){return l(t,e)}).forEach(function(e){t._callbacks.remove(e)})}},{key:"removeAllCallbacks",value:function(){return this._callbacks.removeAll()}},{key:"_trigger",value:function(e,t){var i=this;this._handlers.get(e).forEach(function(n){"AdClickThru"===e?n(t):setTimeout(function(){i._handlers.get(e).length>0&&n(t)},0)})}},{key:"_callCallback",value:function(e,t,i,n){var o=this._callbacks.get(t);return o?void r.call(this,t,i,n):void(i&&""===t&&this.trigger(f,i))}},{key:"_handShake",value:function(e,t){this._ready=!0,this._handShakeHandler&&(this._handShakeHandler(e,t),delete this._handShakeHandler)}},{key:"getSize",value:function(){return{width:this._width,height:this._height}}},{key:"setSize",value:function(e,t){this._width=s(e,this._width),this._height=s(t,this._height),this._el.setAttribute("width",this._width),this._el.setAttribute("height",this._height)}},{key:"getWidth",value:function(){return this._width}},{key:"setWidth",value:function(e){this.setSize(e,this._height)}},{key:"getHeight",value:function(){return this._height}},{key:"setHeight",value:function(e){this.setSize(this._width,e)}},{key:"getFlashID",value:function(){return this._flashID}},{key:"getFlashURL",value:function(){return this._flashURL}},{key:"isReady",value:function(){return this._ready}},{key:"destroy",value:function(){this.offAll(),this.removeAllCallbacks(),c.removeInstanceByID(this._flashID),this._el.parentElement&&this._el.parentElement.removeChild(this._el)}}]),e}();Object.defineProperty(p,"VPAID_FLASH_HANDLER",{writable:!1,configurable:!1,value:h}),window[h]=function(e,t,i,n,r,o){var a=c.getInstanceByID(e);a&&("handShake"===i?a._handShake(r,o):"event"!==t?a._callCallback(i,n,r,o):a._trigger(i,o))}},{"./jsFlashBridgeRegistry":5,"./registry":6,"./utils":7}],5:[function(e,t,i){"use strict";var n=e("./registry").SingleValueRegistry,r=new n,o={};Object.defineProperty(o,"addInstance",{writable:!1,configurable:!1,value:function(e,t){r.add(e,t)}}),Object.defineProperty(o,"getInstanceByID",{writable:!1,configurable:!1,value:function(e){return r.get(e)}}),Object.defineProperty(o,"removeInstanceByID",{writable:!1,configurable:!1,value:function(e){return r.remove(e)}}),t.exports=o},{"./registry":6}],6:[function(e,t,i){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}();i.MultipleValuesRegistry=function(){function e(){n(this,e),this._registries={}}return r(e,[{key:"add",value:function(e,t){this._registries[e]||(this._registries[e]=[]),this._registries[e].indexOf(t)===-1&&this._registries[e].push(t)}},{key:"get",value:function(e){return this._registries[e]||[]}},{key:"filterKeys",value:function(e){return Object.keys(this._registries).filter(e)}},{key:"findByValue",value:function(e){var t=this,i=Object.keys(this._registries).filter(function(i){return t._registries[i].indexOf(e)!==-1});return i}},{key:"remove",value:function(e,t){if(this._registries[e]){var i=this._registries[e].indexOf(t);if(!(i<0))return this._registries[e].splice(i,1)}}},{key:"removeByKey",value:function(e){var t=this._registries[e];return delete this._registries[e],t}},{key:"removeByValue",value:function(e){var t=this,i=this.findByValue(e);return i.map(function(i){return t.remove(i,e)})}},{key:"removeAll",value:function(){var e=this._registries;return this._registries={},e}},{key:"size",value:function(){return Object.keys(this._registries).length}}]),e}(),i.SingleValueRegistry=function(){function e(){n(this,e),this._registries={}}return r(e,[{key:"add",value:function(e,t){this._registries[e]=t}},{key:"get",value:function(e){return this._registries[e]}},{key:"filterKeys",value:function(e){return Object.keys(this._registries).filter(e)}},{key:"findByValue",value:function(e){var t=this,i=Object.keys(this._registries).filter(function(i){return t._registries[i]===e});return i}},{key:"remove",value:function(e){var t=this._registries[e];return delete this._registries[e],t}},{key:"removeByValue",value:function(e){var t=this,i=this.findByValue(e);return i.map(function(e){return t.remove(e)})}},{key:"removeAll",value:function(){var e=this._registries;return this._registries={},e}},{key:"size",value:function(){return Object.keys(this._registries).length}}]),e}()},{}],7:[function(e,t,i){"use strict";function n(e){var t=-1;return function(i){return e+"_"+ ++t}}function r(){}function o(e,t,i){var n=setTimeout(function(){t=r,i()},e);return function(){clearTimeout(n),t.apply(this,arguments)}}function a(e,t){var i=document.createElement("div");return i.id=t,e.innerHTML="",e.appendChild(i),i}function s(e,t){return!isNaN(parseFloat(e))&&isFinite(e)&&e>0?e:t}function l(e,t){return u.call(e,t)}Object.defineProperty(i,"__esModule",{value:!0}),i.unique=n,i.noop=r,i.callbackTimeout=o,i.createElementWithID=a,i.isPositiveInt=s,i.stringEndsWith=l;var u=function(){return String.prototype.endsWith?String.prototype.endsWith:function(e,t){var i=this.toString();(void 0===t||t>i.length)&&(t=i.length),t-=e.length;var n=i.indexOf(e,t);return n!==-1&&n===t}}()},{}],8:[function(e,t,i){"use strict";function n(e,t,i){}function r(e,t,i){Object.defineProperty(e,t,{writable:!1,configurable:!1,value:i})}var o=["handshakeVersion","initAd","startAd","stopAd","skipAd","resizeAd","pauseAd","resumeAd","expandAd","collapseAd","subscribe","unsubscribe"],a=["AdLoaded","AdStarted","AdStopped","AdSkipped","AdSkippableStateChange","AdSizeChange","AdLinearChange","AdDurationChange","AdExpandedChange","AdRemainingTimeChange","AdVolumeChange","AdImpression","AdVideoStart","AdVideoFirstQuartile","AdVideoMidpoint","AdVideoThirdQuartile","AdVideoComplete","AdClickThru","AdInteraction","AdUserAcceptInvitation","AdUserMinimize","AdUserClose","AdPaused","AdPlaying","AdLog","AdError"],s=["getAdLinear","getAdWidth","getAdHeight","getAdExpanded","getAdSkippableState","getAdRemainingTime","getAdDuration","getAdVolume","getAdCompanions","getAdIcons"],l=["setAdVolume"];n.prototype.handshakeVersion=function(e,t){},n.prototype.initAd=function(e,t,i,n,r,o,a){},n.prototype.startAd=function(e){},n.prototype.stopAd=function(e){},n.prototype.skipAd=function(e){},n.prototype.resizeAd=function(e,t,i,n){},n.prototype.pauseAd=function(e){},n.prototype.resumeAd=function(e){},n.prototype.expandAd=function(e){},n.prototype.collapseAd=function(e){},n.prototype.subscribe=function(e,t,i){},n.prototype.unsubscribe=function(e,t){},n.prototype.getAdLinear=function(e){},n.prototype.getAdWidth=function(e){},n.prototype.getAdHeight=function(e){},n.prototype.getAdExpanded=function(e){},n.prototype.getAdSkippableState=function(e){},n.prototype.getAdRemainingTime=function(e){},n.prototype.getAdDuration=function(e){},n.prototype.getAdVolume=function(e){},n.prototype.getAdCompanions=function(e){},n.prototype.getAdIcons=function(e){},n.prototype.setAdVolume=function(e,t){},r(n,"METHODS",o),r(n,"GETTERS",s),r(n,"SETTERS",l),r(n,"EVENTS",a);var u=o.filter(function(e){return["skipAd"].indexOf(e)===-1});r(n,"checkVPAIDInterface",function(e){var t=u.every(function(t){return"function"==typeof e[t]});return t}),t.exports=n},{}],9:[function(e,t,i){"use strict";function n(e,t,i,n){this._isValid=d(e),this._isValid&&(this._creative=e,this._el=t,this._videoEl=i,this._iframe=n,this._subscribers=new u,r.call(this))}function r(){if(p.forEach(function(e){this._creative.subscribe(a.bind(this,e),e)}.bind(this)),this._creative.subscribe(o.bind(this),f),this._videoEl){var e=this._iframe.contentDocument.documentElement,t=this._videoEl;e.addEventListener("click",function(i){i.target===e&&t.click()})}}function o(e,t,i){this._subscribers.triggerSync(f,{url:e,id:t,playerHandles:i})}function a(e){this._subscribers.trigger(e,Array.prototype.slice(arguments,1))}function s(e,t,i,n){e?e(i,n):i&&t.trigger(h,i)}var l=e("./IVPAIDAdUnit"),u=e("./subscriber"),d=l.checkVPAIDInterface,c=e("./utils"),h=(l.METHODS,"AdError"),f="AdClickThru",p=l.EVENTS.filter(function(e){return e!=f});n.prototype=Object.create(l.prototype),n.prototype.isValidVPAIDAd=function(){return this._isValid},l.METHODS.forEach(function(e){var t=["subscribe","unsubscribe","initAd"];t.indexOf(e)===-1&&(n.prototype[e]=function(){var t=l.prototype[e].length,i=Array.prototype.slice.call(arguments),n=t===i.length?i.pop():void 0;setTimeout(function(){var t,r=null;try{t=this._creative[e].apply(this._creative,i)}catch(e){r=e}s(n,this._subscribers,r,t)}.bind(this),0)})}),n.prototype.initAd=function(e,t,i,n,r,o,a){r=r||{},o=c.extend({slot:this._el,videoSlot:this._videoEl},o||{}),setTimeout(function(){var l;try{this._creative.initAd(e,t,i,n,r,o)}catch(e){l=e}s(a,this._subscribers,l)}.bind(this),0)},n.prototype.subscribe=function(e,t,i){this._subscribers.subscribe(t,e,i)},n.prototype.unsubscribe=function(e,t){this._subscribers.unsubscribe(t,e)},n.prototype.on=n.prototype.subscribe,n.prototype.off=n.prototype.unsubscribe,l.GETTERS.forEach(function(e){n.prototype[e]=function(t){setTimeout(function(){var i,n=null;try{i=this._creative[e]()}catch(e){n=e}s(t,this._subscribers,n,i)}.bind(this),0)}}),n.prototype.setAdVolume=function(e,t){setTimeout(function(){var i,n=null;try{this._creative.setAdVolume(e),i=this._creative.getAdVolume()}catch(e){n=e}n||(n=c.validate(i===e,"failed to apply volume: "+e)),s(t,this._subscribers,n,i)}.bind(this),0)},n.prototype._destroy=function(){this.stopAd(),this._subscribers.unsubscribeAll()},t.exports=n},{"./IVPAIDAdUnit":8,"./subscriber":11,"./utils":12}],10:[function(e,t,i){"use strict";function n(e,t,i,n){i=i||{},this._id=h(),this._destroyed=!1,this._frameContainer=c.createElementInEl(e,"div"),this._videoEl=t,this._vpaidOptions=n||{timeout:1e4},this._templateConfig={template:i.template||p,extraOptions:i.extraOptions||{}}}function r(e){var t=this[e];t&&(t.remove(),delete this[e])}function o(){s.call(this),delete this._adUnit}function a(){s.call(this),u.call(this)}function s(){r.call(this,"_frame"),l.call(this)}function l(){this._onLoad&&(window.removeEventListener("message",this._onLoad),c.clearCallbackTimeout(this._onLoad),delete this._onLoad)}function u(){this._adUnit&&(this._adUnit.stopAd(),delete this._adUnit)}function d(){if(this._destroyed)throw new Error("VPAIDHTML5Client already destroyed!")}var c=e("./utils"),h=c.unique("vpaidIframe"),f=e("./VPAIDAdUnit"),p='<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"></head><body style="margin:0;padding:0">';p+='<script type="text/javascript" src="{{iframeURL_JS}}"></script><script>',p+='parent.postMessage(\'{"event": "ready", "id": "{{iframeID}}"}\', window.location.origin);',p+='</script><div class="ad-element"></div></body></html>';var v="AdStopped";n.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,a.call(this))},n.prototype.isDestroyed=function(){return this._destroyed},n.prototype.loadAdUnit=function(e,t){function i(e){if(e.origin===window.location.origin){var i=JSON.parse(e.data);if(i.id===this.getID()){var n,r,a;if(this._frame.contentWindow?(a=this._frame.contentWindow.getVPAIDAd,r=c.validate("function"==typeof a,"the ad didn't return a function to create an ad")):r="the iframe is not anymore in the DOM tree",!r){var s=this._frame.contentWindow.document.querySelector(".ad-element");n=new f(a(),s,this._videoEl,this._frame),n.subscribe(v,o.bind(this)),r=c.validate(n.isValidVPAIDAd(),"the add is not fully complaint with VPAID specification")}return this._adUnit=n,l.call(this),t(r,r?null:n),!0}}}function n(){t("timeout",null)}d.call(this),a.call(this);var r=c.createIframeWithContent(this._frameContainer,this._templateConfig.template,c.extend({iframeURL_JS:e,iframeID:this.getID()},this._templateConfig.extraOptions));this._frame=r,this._onLoad=c.callbackTimeout(this._vpaidOptions.timeout,i.bind(this),n.bind(this)),window.addEventListener("message",this._onLoad)},n.prototype.unloadAdUnit=function(){a.call(this)},n.prototype.getID=function(){return this._id},t.exports=n,window.VPAIDHTML5Client=n},{"./VPAIDAdUnit":9,"./utils":12}],11:[function(e,t,i){"use strict";function n(){this._subscribers={}}n.prototype.subscribe=function(e,t,i){this.get(t).push({handler:e,context:i})},n.prototype.unsubscribe=function(e,t){this._subscribers[t]=this.get(t).filter(function(t){return e===t.handler})},n.prototype.unsubscribeAll=function(){this._subscribers={}},n.prototype.trigger=function(e,t){var i=this;i.get(e).forEach(function(n){setTimeout(function(){i.get(e)&&n.handler.call(n.context,t)},0)})},n.prototype.triggerSync=function(e,t){this.get(e).forEach(function(e){e.handler.call(e.context,t)})},n.prototype.get=function(e){return this._subscribers[e]||(this._subscribers[e]=[]),this._subscribers[e]},t.exports=n},{}],12:[function(e,t,i){"use strict";function n(){}function r(e,t){return e?null:new Error(t)}function o(e){var t=p[e];t&&(clearTimeout(t),delete p[e])}function a(e,t,i){var r,a;return a=setTimeout(function(){t=n,delete a[r],i()},e),r=function(){t.apply(this,arguments)&&o(r)},p[r]=a,r}function s(e,t,i){var n=document.createElement(t);return i&&(n.id=i),e.appendChild(n),n}function l(e,t,i){var n=u(e,null,i.zIndex);if(c(n,d(t,i)))return n}function u(e,t,i){var n=document.createElement("iframe");return n.src=t||"about:blank",n.marginWidth="0",n.marginHeight="0",n.frameBorder="0",n.width="100%",n.height="100%",n.style.position="absolute",n.style.left="0",n.style.top="0",n.style.margin="0px",n.style.padding="0px",n.style.border="none",i&&(n.style.zIndex=i),n.setAttribute("SCROLLING","NO"),e.innerHTML="",e.appendChild(n),n}function d(e,t){return Object.keys(t).forEach(function(i){var n="object"==typeof n?JSON.stringify(t[i]):t[i];e=e.replace(new RegExp("{{"+i+"}}","g"),n)}),e}function c(e,t){var i=e.contentWindow&&e.contentWindow.document;return!!i&&(i.write(t),!0)}function h(e,t){return Object.keys(t).forEach(function(i){e[i]=t[i]}),e}function f(e){var t=-1;return function(){return e+"_"+ ++t}}var p={};t.exports={noop:n,validate:r,clearCallbackTimeout:o,callbackTimeout:a,createElementInEl:s,createIframeWithContent:l,createIframe:u,simpleTemplate:d,setIframeContent:c,extend:h,unique:f}},{}],13:[function(e,t,i){var n=e("vpaid-html5-client/js/VPAIDHTML5Client.js"),r=e("vpaid-flash-client/js/VPAIDFLASHClient.js");t.exports={attach:function(e){var t=!1,i=e.timeout||5e3,o=void 0,a=!1,s=!1,l=!1,u=!1,d=!1,c=document.createElement("div");c.className="vpaid",c.style.cssText="position:absolute;top:0;left:0;width:100%;height:0;visibility:none;overflow:hidden;z-index:4999;display:flex;align-items:center;justify-content:center;",c.innerHTML='<span style="color:white;">Loading, please wait..</span>',e.container.appendChild(c);var h=function(e){return console&&console.error&&e&&console.error(e),v()},f=function(){c.style.visibility="none",c.style.height="100%"},p=function(){c.style.visibility="visible",c.style.height="100%",c.style.background="black"},v=function(){if(!d){d=!0;try{e.container.removeChild(c)}catch(e){}e.player.trigger("vpaid_end"),e.player.play()}},y=function(t,n,r){return function(s,l){if(s)return h(s);o=l;var d=null,c=!1,y={AdVideoStart:"start",AdVideoFirstQuartile:"firstQuartile",AdVideoMidpoint:"midpoint",AdVideoThirdQuartile:"thirdQuartile",AdVideoComplete:"complete",AdUserAcceptInvitation:"acceptInvitation",AdUserMinimize:"collapse",AdUserClose:"close",AdPaused:"pause",AdPlaying:"resume",AdStopped:function(){c=!0,v()},AdLoaded:function(){a=!0,e.player.trigger("vpaid_loaded"),r?g():f()},AdStarted:function(){u=!0,t.tracker.load(),e.player.trigger("vpaid_start"),l.getAdVolume(function(e,t){d=t})},AdVideoComplete:function(){t.tracker.complete(),v()},AdSkipped:function(){t.tracker.skip(),v()},AdImpression:function(){},AdVolumeChange:function(){l.getAdVolume(function(e,i){0==i&&d>0?t.tracker.setMuted(!0):i>0&&0==d&&t.tracker.setMuted(!1)})},AdClickThru:function(){},AdError:function(){c=!0,t.tracker.errorWithCode(901),v()}};Object.keys(y).forEach(function(e){return l[n](e,function(){if(!c){var i=y[e];return"string"==typeof i?t.tracker.track(i):void i(arguments)}})}),l.handshakeVersion("2.0",function(n){return n?h(n):(e.player.trigger("vpaid_init"),p(),l.initAd(t.width,t.height,"normal",-1,{AdParameters:t.parameters},{}),void setTimeout(function(){a||(c=!0,h("Timed out waiting for VPAID ad to load."))},i))})}};e.player.on("vpaid_js",function(e,t,i){l=!0;var r=new n(c,null,{extraOptions:{zIndex:4999}});r.loadAdUnit(t.src,y(t,"subscribe",i))}),e.player.on("vpaid_swf",function(t,i,n){if(!e.swfVpaid)throw new Error("You must define a url for config.swfVpaid");l=!0;var o=function(){var t=new r(c,function(e){return e?h(e):void t.loadAdUnit(i.src,y(i,"on",n))},{data:e.swfVpaid,width:i.width||c.offsetWidth,height:i.height||c.offsetHeight})};if(window.swfobject)return o();if(!e.swfObject)throw new Error("You must define config.swfObject or include it on the page");var a=document.getElementsByTagName("head")[0],s=document.createElement("script");s.type="text/javascript",s.async=!0,s.src=e.swfObject;var u=!1;s.onload=s.onreadystatechange=function(){u||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(u=!0,o(),s.onload=s.onreadystatechange=null,a.removeChild(s))},a.appendChild(s)});var g=function(){if(l&&!t&&!s){p(),t=!0,e.player.stop();var n=function(e){if(o&&a)return e(o);var t=setInterval(function(){if(o&&a)return e(o)},100);setTimeout(function(){o&&a||(clearInterval(t),e())},i)};n(function(e){return e?(e.startAd(),void setTimeout(function(){u||v()},i)):v()})}};e.player.on("resume",g)}}},{"vpaid-flash-client/js/VPAIDFLASHClient.js":3,"vpaid-html5-client/js/VPAIDHTML5Client.js":10}]},{},[13])(13)}); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}]},{},[1])(1) });