From af0c40009d185d1b1c0115a0148752c0de5984bd Mon Sep 17 00:00:00 2001 From: Sara Nordmyr da Cunha Date: Mon, 27 May 2019 10:14:12 +0200 Subject: [PATCH] Bundle release 3.0.0-alpha.2 --- dist/vast-client-browser.min.js | 2 +- dist/vast-client-node.js | 77 +++++++++++++++++++++++++-------- dist/vast-client-node.min.js | 2 +- dist/vast-client.js | 77 +++++++++++++++++++++++++-------- dist/vast-client.min.js | 2 +- 5 files changed, 119 insertions(+), 41 deletions(-) diff --git a/dist/vast-client-browser.min.js b/dist/vast-client-browser.min.js index c719a62c..d4f1ed92 100644 --- a/dist/vast-client-browser.min.js +++ b/dist/vast-client-browser.min.js @@ -1 +1 @@ -var VAST=function(e){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r=s.maxWrapperDepth||-1!==s.parentURLs.indexOf(i.nextWrapperURL))return i.errorCode=302,delete i.nextWrapperURL,t(i);i.nextWrapperURL=k.resolveVastAdTagURI(i.nextWrapperURL,a);var r=i.sequence;a=i.nextWrapperURL,s.fetchVAST(i.nextWrapperURL,n,a).then(function(e){return s.parse(e,{originalUrl:a,wrapperSequence:r,wrapperDepth:n}).then(function(e){if(delete i.nextWrapperURL,0===e.length)return i.creatives=[],t(i);e.forEach(function(e){e&&k.mergeWrapperAdData(e,i)}),t(e)})}).catch(function(e){i.errorCode=301,i.errorMessage=e.message,t(i)})})}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;0<=t;t--){var r=e.ads[t];(r.errorCode||0===r.creatives.length)&&(this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:r.errorCode||303},{ERRORMESSAGE:r.errorMessage||""},{extensions:r.extensions},{system:r.system}),e.ads.splice(t,1))}}}]),t}(),W=null,q={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete this.data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},_=function(){function e(){l(this,e),this.storage=this.initStorage()}return n(e,[{key:"initStorage",value:function(){if(W)return W;try{W="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){W=null}return W&&!this.isStorageDisabled(W)||(W=q).clear(),W}},{key:"isStorageDisabled",value:function(e){var t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),j=function(){function i(e,t,r){l(this,i),this.cappingFreeLunch=e||0,this.cappingMinimumTimeInterval=t||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new H,this.storage=r||new _,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return n(i,[{key:"getParser",value:function(){return this.vastParser}},{key:"hasRemainingAds",value:function(){return 0=n.totalCalls)return r(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(n.totalCalls,"/").concat(n.cappingFreeLunch)));var e=s-n.lastSuccessfulAd;if(e<0)n.lastSuccessfulAd=0;else if(e=s.maxWrapperDepth||-1!==s.parentURLs.indexOf(i.nextWrapperURL))return i.errorCode=302,delete i.nextWrapperURL,t(i);i.nextWrapperURL=k.resolveVastAdTagURI(i.nextWrapperURL,a);var r=i.sequence;a=i.nextWrapperURL,s.fetchVAST(i.nextWrapperURL,n,a).then(function(e){return s.parse(e,{originalUrl:a,wrapperSequence:r,wrapperDepth:n}).then(function(e){if(delete i.nextWrapperURL,0===e.length)return i.creatives=[],t(i);e.forEach(function(e){e&&k.mergeWrapperAdData(e,i)}),t(e)})}).catch(function(e){i.errorCode=301,i.errorMessage=e.message,t(i)})})}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;0<=t;t--){var r=e.ads[t];(r.errorCode||0===r.creatives.length)&&(this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:r.errorCode||303},{ERRORMESSAGE:r.errorMessage||""},{extensions:r.extensions},{system:r.system}),e.ads.splice(t,1))}}}]),t}(),q=null,W={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete this.data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},_=function(){function e(){l(this,e),this.storage=this.initStorage()}return n(e,[{key:"initStorage",value:function(){if(q)return q;try{q="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){q=null}return q&&!this.isStorageDisabled(q)||(q=W).clear(),q}},{key:"isStorageDisabled",value:function(e){var t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),j=function(){function i(e,t,r){l(this,i),this.cappingFreeLunch=e||0,this.cappingMinimumTimeInterval=t||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new H,this.storage=r||new _,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return n(i,[{key:"getParser",value:function(){return this.vastParser}},{key:"hasRemainingAds",value:function(){return 0=n.totalCalls)return r(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(n.totalCalls,"/").concat(n.cappingFreeLunch)));var e=s-n.lastSuccessfulAd;if(e<0)n.lastSuccessfulAd=0;else if(e 0 && arguments[0] !== undefined ? arguments[0] : []; + var arr2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + var firstArr = Array.isArray(arr1) ? arr1 : []; + var secondArr = Array.isArray(arr2) ? arr2 : []; + var arr = firstArr.concat(secondArr); + return arr.reduce(function (res, val) { + if (res.indexOf(val) === -1) { + res.push(val); + } + + return res; + }, []); +} var util = { track: track, @@ -291,7 +313,8 @@ var util = { leftpad: leftpad, range: range, isNumeric: isNumeric, - flatten: flatten + flatten: flatten, + joinArrayUnique: joinArrayUnique }; /** @@ -504,7 +527,24 @@ function mergeWrapperAdData(unwrappedAd, wrapper) { unwrappedAd.errorURLTemplates = wrapper.errorURLTemplates.concat(unwrappedAd.errorURLTemplates); unwrappedAd.impressionURLTemplates = wrapper.impressionURLTemplates.concat(unwrappedAd.impressionURLTemplates); unwrappedAd.extensions = wrapper.extensions.concat(unwrappedAd.extensions); + var wrapperCompanions = (wrapper.creatives || []).filter(function (creative) { + return creative && creative.type === 'companion'; + }); + var wrapperCompanionClickTracking = wrapperCompanions.reduce(function (result, creative) { + (creative.variations || []).forEach(function (variation) { + (variation.companionClickTrackingURLTemplates || []).forEach(function (url) { + if (result.indexOf(url) === -1) { + result.push(url); + } + }); + }); + return result; + }, []); + unwrappedAd.creatives = wrapperCompanions.concat(unwrappedAd.creatives); + var wrapperHasVideoClickTracking = wrapper.videoClickTrackingURLTemplates && wrapper.videoClickTrackingURLTemplates.length; + var wrapperHasVideoCustomClick = wrapper.videoCustomClickURLTemplates && wrapper.videoCustomClickURLTemplates.length; unwrappedAd.creatives.forEach(function (creative) { + // merge tracking events if (wrapper.trackingEvents && wrapper.trackingEvents[creative.type]) { for (var eventName in wrapper.trackingEvents[creative.type]) { var urls = wrapper.trackingEvents[creative.type][eventName]; @@ -516,32 +556,31 @@ function mergeWrapperAdData(unwrappedAd, wrapper) { creative.trackingEvents[eventName] = creative.trackingEvents[eventName].concat(urls); } } - }); - if (wrapper.videoClickTrackingURLTemplates && wrapper.videoClickTrackingURLTemplates.length) { - unwrappedAd.creatives.forEach(function (creative) { - if (creative.type === 'linear') { + if (creative.type === 'linear') { + // merge video click tracking url + if (wrapperHasVideoClickTracking) { creative.videoClickTrackingURLTemplates = creative.videoClickTrackingURLTemplates.concat(wrapper.videoClickTrackingURLTemplates); - } - }); - } + } // merge video custom click url - if (wrapper.videoCustomClickURLTemplates && wrapper.videoCustomClickURLTemplates.length) { - unwrappedAd.creatives.forEach(function (creative) { - if (creative.type === 'linear') { + + if (wrapperHasVideoCustomClick) { creative.videoCustomClickURLTemplates = creative.videoCustomClickURLTemplates.concat(wrapper.videoCustomClickURLTemplates); - } - }); - } // VAST 2.0 support - Use Wrapper/linear/clickThrough when Inline/Linear/clickThrough is null + } // VAST 2.0 support - Use Wrapper/linear/clickThrough when Inline/Linear/clickThrough is null - if (wrapper.videoClickThroughURLTemplate) { - unwrappedAd.creatives.forEach(function (creative) { - if (creative.type === 'linear' && (creative.videoClickThroughURLTemplate === null || typeof creative.videoClickThroughURLTemplate === 'undefined')) { + if (wrapper.videoClickThroughURLTemplate && (creative.videoClickThroughURLTemplate === null || typeof creative.videoClickThroughURLTemplate === 'undefined')) { creative.videoClickThroughURLTemplate = wrapper.videoClickThroughURLTemplate; } - }); - } + } // pass wrapper companion trackers to all companions + + + if (creative.type === 'companion' && wrapperCompanionClickTracking.length) { + (creative.variations || []).forEach(function (variation) { + variation.companionClickTrackingURLTemplates = util.joinArrayUnique(variation.companionClickTrackingURLTemplates, wrapperCompanionClickTracking); + }); + } + }); } var parserUtils = { diff --git a/dist/vast-client-node.min.js b/dist/vast-client-node.min.js index e7704d36..88edfbac 100644 --- a/dist/vast-client-node.min.js +++ b/dist/vast-client-node.min.js @@ -1 +1 @@ -"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r=s.maxWrapperDepth||-1!==s.parentURLs.indexOf(i.nextWrapperURL))return i.errorCode=302,delete i.nextWrapperURL,t(i);i.nextWrapperURL=parserUtils.resolveVastAdTagURI(i.nextWrapperURL,a);var r=i.sequence;a=i.nextWrapperURL,s.fetchVAST(i.nextWrapperURL,n,a).then(function(e){return s.parse(e,{originalUrl:a,wrapperSequence:r,wrapperDepth:n}).then(function(e){if(delete i.nextWrapperURL,0===e.length)return i.creatives=[],t(i);e.forEach(function(e){e&&parserUtils.mergeWrapperAdData(e,i)}),t(e)})}).catch(function(e){i.errorCode=301,i.errorMessage=e.message,t(i)})})}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;0<=t;t--){var r=e.ads[t];(r.errorCode||0===r.creatives.length)&&(this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:r.errorCode||303},{ERRORMESSAGE:r.errorMessage||""},{extensions:r.extensions},{system:r.system}),e.ads.splice(t,1))}}}]),t}(),storage=null,DEFAULT_STORAGE={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete this.data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},Storage=function(){function e(){_classCallCheck(this,e),this.storage=this.initStorage()}return _createClass(e,[{key:"initStorage",value:function(){if(storage)return storage;try{storage="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){storage=null}return storage&&!this.isStorageDisabled(storage)||(storage=DEFAULT_STORAGE).clear(),storage}},{key:"isStorageDisabled",value:function(e){var t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),VASTClient=function(){function i(e,t,r){_classCallCheck(this,i),this.cappingFreeLunch=e||0,this.cappingMinimumTimeInterval=t||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new VASTParser,this.storage=r||new Storage,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return _createClass(i,[{key:"getParser",value:function(){return this.vastParser}},{key:"hasRemainingAds",value:function(){return 0=n.totalCalls)return r(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(n.totalCalls,"/").concat(n.cappingFreeLunch)));var e=s-n.lastSuccessfulAd;if(e<0)n.lastSuccessfulAd=0;else if(e=s.maxWrapperDepth||-1!==s.parentURLs.indexOf(i.nextWrapperURL))return i.errorCode=302,delete i.nextWrapperURL,t(i);i.nextWrapperURL=parserUtils.resolveVastAdTagURI(i.nextWrapperURL,a);var r=i.sequence;a=i.nextWrapperURL,s.fetchVAST(i.nextWrapperURL,n,a).then(function(e){return s.parse(e,{originalUrl:a,wrapperSequence:r,wrapperDepth:n}).then(function(e){if(delete i.nextWrapperURL,0===e.length)return i.creatives=[],t(i);e.forEach(function(e){e&&parserUtils.mergeWrapperAdData(e,i)}),t(e)})}).catch(function(e){i.errorCode=301,i.errorMessage=e.message,t(i)})})}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;0<=t;t--){var r=e.ads[t];(r.errorCode||0===r.creatives.length)&&(this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:r.errorCode||303},{ERRORMESSAGE:r.errorMessage||""},{extensions:r.extensions},{system:r.system}),e.ads.splice(t,1))}}}]),t}(),storage=null,DEFAULT_STORAGE={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete this.data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},Storage=function(){function e(){_classCallCheck(this,e),this.storage=this.initStorage()}return _createClass(e,[{key:"initStorage",value:function(){if(storage)return storage;try{storage="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){storage=null}return storage&&!this.isStorageDisabled(storage)||(storage=DEFAULT_STORAGE).clear(),storage}},{key:"isStorageDisabled",value:function(e){var t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),VASTClient=function(){function i(e,t,r){_classCallCheck(this,i),this.cappingFreeLunch=e||0,this.cappingMinimumTimeInterval=t||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new VASTParser,this.storage=r||new Storage,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return _createClass(i,[{key:"getParser",value:function(){return this.vastParser}},{key:"hasRemainingAds",value:function(){return 0=n.totalCalls)return r(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(n.totalCalls,"/").concat(n.cappingFreeLunch)));var e=s-n.lastSuccessfulAd;if(e<0)n.lastSuccessfulAd=0;else if(e 0 && arguments[0] !== undefined ? arguments[0] : []; + var arr2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; + var firstArr = Array.isArray(arr1) ? arr1 : []; + var secondArr = Array.isArray(arr2) ? arr2 : []; + var arr = firstArr.concat(secondArr); + return arr.reduce(function (res, val) { + if (res.indexOf(val) === -1) { + res.push(val); + } + + return res; + }, []); + } var util = { track: track, @@ -293,7 +315,8 @@ leftpad: leftpad, range: range, isNumeric: isNumeric, - flatten: flatten + flatten: flatten, + joinArrayUnique: joinArrayUnique }; /** @@ -506,7 +529,24 @@ unwrappedAd.errorURLTemplates = wrapper.errorURLTemplates.concat(unwrappedAd.errorURLTemplates); unwrappedAd.impressionURLTemplates = wrapper.impressionURLTemplates.concat(unwrappedAd.impressionURLTemplates); unwrappedAd.extensions = wrapper.extensions.concat(unwrappedAd.extensions); + var wrapperCompanions = (wrapper.creatives || []).filter(function (creative) { + return creative && creative.type === 'companion'; + }); + var wrapperCompanionClickTracking = wrapperCompanions.reduce(function (result, creative) { + (creative.variations || []).forEach(function (variation) { + (variation.companionClickTrackingURLTemplates || []).forEach(function (url) { + if (result.indexOf(url) === -1) { + result.push(url); + } + }); + }); + return result; + }, []); + unwrappedAd.creatives = wrapperCompanions.concat(unwrappedAd.creatives); + var wrapperHasVideoClickTracking = wrapper.videoClickTrackingURLTemplates && wrapper.videoClickTrackingURLTemplates.length; + var wrapperHasVideoCustomClick = wrapper.videoCustomClickURLTemplates && wrapper.videoCustomClickURLTemplates.length; unwrappedAd.creatives.forEach(function (creative) { + // merge tracking events if (wrapper.trackingEvents && wrapper.trackingEvents[creative.type]) { for (var eventName in wrapper.trackingEvents[creative.type]) { var urls = wrapper.trackingEvents[creative.type][eventName]; @@ -518,32 +558,31 @@ creative.trackingEvents[eventName] = creative.trackingEvents[eventName].concat(urls); } } - }); - if (wrapper.videoClickTrackingURLTemplates && wrapper.videoClickTrackingURLTemplates.length) { - unwrappedAd.creatives.forEach(function (creative) { - if (creative.type === 'linear') { + if (creative.type === 'linear') { + // merge video click tracking url + if (wrapperHasVideoClickTracking) { creative.videoClickTrackingURLTemplates = creative.videoClickTrackingURLTemplates.concat(wrapper.videoClickTrackingURLTemplates); - } - }); - } + } // merge video custom click url - if (wrapper.videoCustomClickURLTemplates && wrapper.videoCustomClickURLTemplates.length) { - unwrappedAd.creatives.forEach(function (creative) { - if (creative.type === 'linear') { + + if (wrapperHasVideoCustomClick) { creative.videoCustomClickURLTemplates = creative.videoCustomClickURLTemplates.concat(wrapper.videoCustomClickURLTemplates); - } - }); - } // VAST 2.0 support - Use Wrapper/linear/clickThrough when Inline/Linear/clickThrough is null + } // VAST 2.0 support - Use Wrapper/linear/clickThrough when Inline/Linear/clickThrough is null - if (wrapper.videoClickThroughURLTemplate) { - unwrappedAd.creatives.forEach(function (creative) { - if (creative.type === 'linear' && (creative.videoClickThroughURLTemplate === null || typeof creative.videoClickThroughURLTemplate === 'undefined')) { + if (wrapper.videoClickThroughURLTemplate && (creative.videoClickThroughURLTemplate === null || typeof creative.videoClickThroughURLTemplate === 'undefined')) { creative.videoClickThroughURLTemplate = wrapper.videoClickThroughURLTemplate; } - }); - } + } // pass wrapper companion trackers to all companions + + + if (creative.type === 'companion' && wrapperCompanionClickTracking.length) { + (creative.variations || []).forEach(function (variation) { + variation.companionClickTrackingURLTemplates = util.joinArrayUnique(variation.companionClickTrackingURLTemplates, wrapperCompanionClickTracking); + }); + } + }); } var parserUtils = { diff --git a/dist/vast-client.min.js b/dist/vast-client.min.js index 89ff8d94..9f4e6f68 100644 --- a/dist/vast-client.min.js +++ b/dist/vast-client.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).VAST={})}(this,function(e){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function l(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r=s.maxWrapperDepth||-1!==s.parentURLs.indexOf(i.nextWrapperURL))return i.errorCode=302,delete i.nextWrapperURL,t(i);i.nextWrapperURL=k.resolveVastAdTagURI(i.nextWrapperURL,a);var r=i.sequence;a=i.nextWrapperURL,s.fetchVAST(i.nextWrapperURL,n,a).then(function(e){return s.parse(e,{originalUrl:a,wrapperSequence:r,wrapperDepth:n}).then(function(e){if(delete i.nextWrapperURL,0===e.length)return i.creatives=[],t(i);e.forEach(function(e){e&&k.mergeWrapperAdData(e,i)}),t(e)})}).catch(function(e){i.errorCode=301,i.errorMessage=e.message,t(i)})})}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;0<=t;t--){var r=e.ads[t];(r.errorCode||0===r.creatives.length)&&(this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:r.errorCode||303},{ERRORMESSAGE:r.errorMessage||""},{extensions:r.extensions},{system:r.system}),e.ads.splice(t,1))}}}]),t}(),W=null,_={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete this.data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},q=function(){function e(){l(this,e),this.storage=this.initStorage()}return n(e,[{key:"initStorage",value:function(){if(W)return W;try{W="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){W=null}return W&&!this.isStorageDisabled(W)||(W=_).clear(),W}},{key:"isStorageDisabled",value:function(e){var t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),j=function(){function i(e,t,r){l(this,i),this.cappingFreeLunch=e||0,this.cappingMinimumTimeInterval=t||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new H,this.storage=r||new q,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return n(i,[{key:"getParser",value:function(){return this.vastParser}},{key:"hasRemainingAds",value:function(){return 0=n.totalCalls)return r(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(n.totalCalls,"/").concat(n.cappingFreeLunch)));var e=s-n.lastSuccessfulAd;if(e<0)n.lastSuccessfulAd=0;else if(e=s.maxWrapperDepth||-1!==s.parentURLs.indexOf(i.nextWrapperURL))return i.errorCode=302,delete i.nextWrapperURL,t(i);i.nextWrapperURL=k.resolveVastAdTagURI(i.nextWrapperURL,a);var r=i.sequence;a=i.nextWrapperURL,s.fetchVAST(i.nextWrapperURL,n,a).then(function(e){return s.parse(e,{originalUrl:a,wrapperSequence:r,wrapperDepth:n}).then(function(e){if(delete i.nextWrapperURL,0===e.length)return i.creatives=[],t(i);e.forEach(function(e){e&&k.mergeWrapperAdData(e,i)}),t(e)})}).catch(function(e){i.errorCode=301,i.errorMessage=e.message,t(i)})})}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;0<=t;t--){var r=e.ads[t];(r.errorCode||0===r.creatives.length)&&(this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:r.errorCode||303},{ERRORMESSAGE:r.errorMessage||""},{extensions:r.extensions},{system:r.system}),e.ads.splice(t,1))}}}]),t}(),q=null,W={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete this.data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},_=function(){function e(){l(this,e),this.storage=this.initStorage()}return n(e,[{key:"initStorage",value:function(){if(q)return q;try{q="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){q=null}return q&&!this.isStorageDisabled(q)||(q=W).clear(),q}},{key:"isStorageDisabled",value:function(e){var t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),j=function(){function i(e,t,r){l(this,i),this.cappingFreeLunch=e||0,this.cappingMinimumTimeInterval=t||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new H,this.storage=r||new _,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return n(i,[{key:"getParser",value:function(){return this.vastParser}},{key:"hasRemainingAds",value:function(){return 0=n.totalCalls)return r(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(n.totalCalls,"/").concat(n.cappingFreeLunch)));var e=s-n.lastSuccessfulAd;if(e<0)n.lastSuccessfulAd=0;else if(e