UNPKG

react-gpt-for-prebid

Version:

A react display ad component using Google Publisher Tag & Prebid

6 lines 30.4 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.ReactGPT=t(require("react"),require("react-dom")):e.ReactGPT=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(4);Object.defineProperty(t,"Bling",{enumerable:!0,get:function(){return r(o).default}});var i=n(1);Object.defineProperty(t,"Events",{enumerable:!0,get:function(){return r(i).default}})},function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n={READY:"ready",RENDER:"render",SLOT_RENDER_ENDED:"slotRenderEnded",IMPRESSION_VIEWABLE:"impressionViewable",SLOT_VISIBILITY_CHANGED:"slotVisibilityChanged",SLOT_LOADED:"slotOnload"};t.default=n},function(e,t,n){"use strict";var r=function(e,t,n,r,o,i,a,s){if(!e){var u;if(void 0===t)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[n,r,o,i,a,s],c=0;u=new Error(t.replace(/%s/g,function(){return l[c++]})),u.name="Invariant Violation"}throw u.framesToPop=1,u}};e.exports=r},function(e,t){e.exports=function(e,t,n,r){function o(){function o(){a=Number(new Date),n.apply(u,c)}function s(){i=void 0}var u=this,l=Number(new Date)-a,c=arguments;r&&!i&&o(),i&&clearTimeout(i),void 0===r&&l>e?o():t!==!0&&(i=setTimeout(r?s:o,void 0===r?e-l:e))}var i,a=0;return"boolean"!=typeof t&&(r=n,n=t,t=void 0),o}},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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 s(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(t,"__esModule",{value:!0});var u,l,c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},d="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},f=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),p=n(21),h=r(p),g=n(17),y=r(g),v=n(22),b=r(v),_=n(2),m=r(_),w=n(8),S=r(w),M=n(15),P=r(M),E=n(1),O=r(E),k=n(6),x=r(k),A=n(5),C=(l=u=function(e){function t(){var e,n,r,o;i(this,t);for(var s=arguments.length,u=Array(s),l=0;l<s;l++)u[l]=arguments[l];return n=r=a(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(u))),r.state={scriptLoaded:!1,inViewport:!1,refreshed:!1},o=n,a(r,o)}return s(t,e),f(t,[{key:"componentDidMount",value:function(){t._adManager.addInstance(this),t._adManager.load(t._config.seedFileUrl).then(this.onScriptLoaded.bind(this)).catch(this.onScriptError.bind(this))}},{key:"componentWillReceiveProps",value:function(e){var n=t._config.propsEqual,r=this.props.sizeMapping;!e.sizeMapping&&!r||n(e.sizeMapping,r)||t._adManager.removeMQListener(this,e)}},{key:"shouldComponentUpdate",value:function(e,n){var r=n.scriptLoaded,o=n.inViewport,i=this.notInViewport(e,n),a=this.state.inViewport!==o,s=this.state.scriptLoaded!==r;if(i)return!1;if(a)return!0;var u=t._config,l=u.filterProps,c=u.propsEqual,d=l(t.refreshableProps,this.props,e),f=l(t.reRenderProps,this.props,e),p=!c(f.props,f.nextProps),h=!p&&!c(d.props,d.nextProps);if(h&&this.configureSlot(this._adSlot,e),t._adManager._syncCorrelator)h?t._adManager.refresh():(p||s)&&t._adManager.renderAll();else{if(h)return this.refresh(),!1;if(p||s)return!0}return!1}},{key:"componentDidUpdate",value:function(){this.notInViewport(this.props,this.state)||this._divId&&(t._adManager._initialRender?t._adManager.render():this.renderAd())}},{key:"componentWillUnmount",value:function(){t._adManager.removeInstance(this),this._adSlot&&(t._adManager.googletag.destroySlots([this._adSlot]),this._adSlot=null)}},{key:"componentWillMount",value:function(){}},{key:"onScriptLoaded",value:function e(){var e=this.props.onScriptLoaded;this.getRenderWhenViewable()&&this.foldCheck(),this.setState({scriptLoaded:!0},e)}},{key:"onScriptError",value:function(e){console.warn("Ad: Failed to load gpt for "+t._config.seedFileUrl,e)}},{key:"getRenderWhenViewable",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props;return void 0!==e.renderWhenViewable?e.renderWhenViewable:t._config.renderWhenViewable}},{key:"foldCheck",value:function(){if(!this.state.inViewport){var e=this.getSlotSize();Array.isArray(e)&&Array.isArray(e[0])&&(e=e[0]),("fluid"===e||Array.isArray(e)&&"fluid"===e[0])&&(e=[0,0]);var n=t._adManager.isInViewport(b.default.findDOMNode(this),e,this.viewableThreshold);n&&this.setState({inViewport:!0})}}},{key:"defineSizeMapping",value:function(e,n){if(n){t._adManager.addMQListener(this,this.props);var r=n.reduce(function(e,t){return e.addSize(t.viewport,t.slot)},t._adManager.googletag.sizeMapping()).build();e.defineSizeMapping(r)}}},{key:"setAttributes",value:function(e,t){var n=e.getAttributeKeys();n.forEach(function(t){e.set(t,null)}),t&&Object.keys(t).forEach(function(n){e.set(n,t[n])})}},{key:"setTargeting",value:function(e,t){e.clearTargeting(),t&&Object.keys(t).forEach(function(n){e.setTargeting(n,t[n])})}},{key:"addCompanionAdService",value:function(e,n){var r=t._adManager.googletag.companionAds();n.addService(r),"object"===("undefined"==typeof e?"undefined":d(e))&&(e.hasOwnProperty("enableSyncLoading")&&r.enableSyncLoading(),e.hasOwnProperty("refreshUnfilledSlots")&&r.setRefreshUnfilledSlots(e.refreshUnfilledSlots))}},{key:"getSlotSize",value:function(){var e=this.props,t=e.slotSize,n=e.sizeMapping,r=void 0;if(t)r=t;else if(n){var o=n;r=o[0]&&o[0].slot}return r}},{key:"renderAd",value:function(){this.defineSlot(),this.display()}},{key:"notInViewport",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.props,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.state,n=t.inViewport;return this.getRenderWhenViewable(e)&&!n}},{key:"defineSlot",value:function(){var e=this.props,n=e.adUnitPath,r=e.outOfPage,o=this._divId,i=this.getSlotSize();this._adSlot||(r?this._adSlot=t._adManager.googletag.defineOutOfPageSlot(n,o):this._adSlot=t._adManager.googletag.defineSlot(n,i||[],o)),this.configureSlot(this._adSlot)}},{key:"configureSlot",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.props,r=n.sizeMapping,i=n.attributes,a=n.targeting,s=n.companionAdService,u=n.categoryExclusion,l=n.collapseEmptyDiv,c=n.safeFrameConfig,d=n.content,f=n.clickUrl,p=n.forceSafeFrame;if(this.defineSizeMapping(e,r),void 0!==l)if(Array.isArray(l)){var h;(h=e.setCollapseEmptyDiv).call.apply(h,[e].concat(o(l)))}else e.setCollapseEmptyDiv(l);if(f&&e.setClickUrl(f),u){var g=u;"string"==typeof g&&(g=[g]),e.clearCategoryExclusions(),g.forEach(function(t){e.setCategoryExclusion(t)})}this.setAttributes(e,i),this.setTargeting(e,a),c&&e.setSafeFrameConfig(c),p&&e.setForceSafeFrame(p),s&&this.addCompanionAdService(s,e),d?e.addService(t._adManager.googletag.content()):e.addService(t._adManager.googletag.pubads())}},{key:"display",value:function(){var e=this.props.content,n=this._divId,r=this._adSlot,o=(this.props.bids,this.props.bidsTimeout,{code:n,mediaTypes:{banner:{sizes:this.props.slotSize.filter(function(e){return Array.isArray(e)})}},bids:this.props.bids});if(e)t._adManager.googletag.content().setContent(r,e);else if(t._adManager._disableInitialLoad||t._adManager._syncCorrelator||t._adManager.updateCorrelator(),t._adManager.googletag.display(n),t._adManager._disableInitialLoad)if(o.bids){var i=this;window.pbjs=window.pbjs||{},window.pbjs.que=window.pbjs.que||[],window.pbjs.que.push(function(){var e={buckets:[{"min":0.01,"max":12.99,"increment":0.01,"precision":2},{"min":13,"max":20,"increment":0.1,"precision":2},{"min":20.01,"max":100,"increment":1,"precision":2}]};window.pbjs.addAdUnits(o),window.pbjs.setConfig({priceGranularity:e,improvedigital:{usePrebidSizes:!0},userSync:{filterSettings:{iframe:{bidders:"*",filter:"include"}}},currency:{adServerCurrency:"USD"},consentManagement:{cmpApi:"iab",timeout:2e3,allowAuctionWithoutConsent:!0}}),window.pbjs.requestBids({timeout:i.props.bidTimeout,adUnitCodes:[n],bidsBackHandler:function(){window.pbjs.setTargetingForGPTAsync([n]),i.state.refreshed||(i.refresh({changeCorrelator:!1}),i.setState({refreshed:!0}))}}),setTimeout(function(){i.state.refreshed||(i.refresh({changeCorrelator:!1}),i.setState({refreshed:!0}))},i.props.bidTimeout)})}else this.refresh()}},{key:"requestBids",value:function(e){}},{key:"clear",value:function(){var e=this._adSlot;if(e&&e.hasOwnProperty("getServices")){var n=e.getServices();if(this._divId&&n.some(function(e){return!!e.setContent}))return void(document.getElementById(this._divId).innerHTML="");t._adManager.clear([e])}this.setState({refreshed:!1})}},{key:"refresh",value:function(e){var n=this._adSlot;n&&(this.clear(),t._adManager.refresh([n],e))}},{key:"render",value:function(){var e=this.state.scriptLoaded,n=this.props,r=n.id,o=n.outOfPage,i=n.style,a=this.notInViewport(this.props,this.state);if(!e||a){var s=this.getSlotSize();o||(0,m.default)(s,"Either 'slotSize' or 'sizeMapping' prop needs to be set."),Array.isArray(s)&&Array.isArray(s[0])&&(s=s[0]),("fluid"===s||Array.isArray(s)&&"fluid"===s[0])&&(s=["auto","auto"]);var u=s&&{width:s[0],height:s[1]};return h.default.createElement("div",{style:u})}return this.clear(),this._adSlot&&(t._adManager.googletag.destroySlots([this._adSlot]),this._adSlot=null),this._divId=r||t._adManager.generateDivId(),h.default.createElement("div",{id:this._divId,style:i})}},{key:"adSlot",get:function(){return this._adSlot}},{key:"viewableThreshold",get:function(){return this.props.viewableThreshold?this.props.viewableThreshold:t._config.viewableThreshold}}],[{key:"on",value:function(e,n){t._on("on",e,n)}},{key:"once",value:function(e,n){t._on("once",e,n)}},{key:"removeListener",value:function(){var e;(e=t._adManager).removeListener.apply(e,arguments)}},{key:"removeAllListeners",value:function(){var e;(e=t._adManager).removeAllListeners.apply(e,arguments)}},{key:"_on",value:function(e,n,r){"function"==typeof r&&(n===O.default.READY&&t._adManager.isReady?r.call(t._adManager,t._adManager.googletag):t._adManager[e](n,r))}},{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t._config=c({},t._config,e)}},{key:"getGPTVersion",value:function(){return t._adManager.getGPTVersion()}},{key:"getPubadsVersion",value:function(){return t._adManager.getPubadsVersion()}},{key:"syncCorrelator",value:function(e){t._adManager.syncCorrelator(e)}},{key:"render",value:function(){t._adManager.renderAll()}},{key:"refresh",value:function(e,n){t._adManager.refresh(e,n)}},{key:"clear",value:function(e){t._adManager.clear(e)}},{key:"updateCorrelator",value:function(){t._adManager.updateCorrelator()}},{key:"testManager",set:function(e){(0,m.default)(e,"Pass in createManagerTest to mock GPT"),t._adManager=e}}]),t}(p.Component),u.propTypes={id:y.default.string,adUnitPath:y.default.string.isRequired,targeting:y.default.object,slotSize:y.default.oneOfType([y.default.array,y.default.string]),sizeMapping:y.default.arrayOf(y.default.shape({viewport:y.default.array,slot:y.default.array})),outOfPage:y.default.bool,companionAdService:y.default.oneOfType([y.default.bool,y.default.object]),content:y.default.string,clickUrl:y.default.string,categoryExclusion:y.default.oneOfType([y.default.string,y.default.array]),attributes:y.default.object,collapseEmptyDiv:y.default.oneOfType([y.default.bool,y.default.array]),forceSafeFrame:y.default.bool,safeFrameConfig:y.default.object,onSlotRenderEnded:y.default.func,onImpressionViewable:y.default.func,onSlotVisibilityChanged:y.default.func,onSlotOnload:y.default.func,renderWhenViewable:y.default.bool,viewableThreshold:y.default.number,onScriptLoaded:y.default.func,onMediaQueryChange:y.default.func,style:y.default.object,bids:y.default.array,bidsTimeout:y.default.number,refreshed:y.default.bool},u.refreshableProps=["targeting","sizeMapping","clickUrl","categoryExclusion","attributes","collapseEmptyDiv","companionAdService","forceSafeFrame","safeFrameConfig"],u.reRenderProps=["adUnitPath","slotSize","outOfPage","content"],u._adManager=(0,A.createManager)(),u._config={seedFileUrl:"https://securepubads.g.doubleclick.net/tag/js/gpt.js",renderWhenViewable:!0,viewableThreshold:.5,filterProps:x.default,propsEqual:S.default},l);t.default=(0,P.default)(C,A.pubadsAPI.reduce(function(e,t){return e[t]=function(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];return C._adManager.pubadsProxy({method:t,args:n})},e},{}))},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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 s(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)}function u(e){return new m(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.AdManager=t.APIToCallBeforeServiceEnabled=t.pubadsAPI=void 0;var l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.createManager=u;var c=n(11),d=r(c),f=n(20),p=n(2),h=(r(p),n(12)),g=n(1),y=r(g),v=n(7),b=r(v),_=(t.pubadsAPI=["enableAsyncRendering","enableSingleRequest","enableSyncRendering","disableInitialLoad","collapseEmptyDivs","enableVideoAds","set","get","getAttributeKeys","setTargeting","clearTargeting","setCategoryExclusion","clearCategoryExclusions","setCentering","setCookieOptions","setLocation","setPublisherProvidedId","setTagForChildDirectedTreatment","clearTagForChildDirectedTreatment","setVideoContent","setForceSafeFrame"],t.APIToCallBeforeServiceEnabled=["enableAsyncRendering","enableSingleRequest","enableSyncRendering","disableInitialLoad","collapseEmptyDivs","setCentering"]),m=t.AdManager=function(e){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n._adCnt=0,n._initialRender=!0,n._syncCorrelator=!1,n._testMode=!1,n._foldCheck=(0,f.throttle)(20,function(e){var t=n.getMountedInstances();t.forEach(function(t){t.getRenderWhenViewable()&&t.foldCheck(e)}),n.testMode&&n._getTimer()}),n._handleMediaQueryChange=function(e){if(n._syncCorrelator)return void n.refresh();var t=/min-width:\s?(\d+)px/.exec(e.media),r=t&&t[1];r&&n._mqls[r]&&n._mqls[r].listeners.forEach(function(t){t.refresh(),t.props.onMediaQueryChange&&t.props.onMediaQueryChange(e)})},n.render=(0,f.debounce)(4,function(){if(n._initialRender){var e=function e(t){n.pubadsReady?t():setTimeout(e,50,t)},t=n.getMountedInstances(),r=!1,o=void 0;t.forEach(function(e){if(!e.notInViewport()){e.defineSlot();var t=e.adSlot;if(t&&t.hasOwnProperty("getServices")){var n=t.getServices();r||(r=n.filter(function(e){return!!e.enableAsyncRendering}).length>0)}}}),r||(o=n.googletag.defineSlot("/",[]),o.addService(n.googletag.pubads())),n._processPubadsQueue(),n.googletag.enableServices(),e(function(){o&&n.googletag.destroySlots([o]),n._processPubadsQueue(),n._listen(),n._isReady=!0,n.emit(y.default.READY,n.googletag),t.forEach(function(e){e.notInViewport()||e.display()}),n.emit(y.default.RENDER,n.googletag),n._initialRender=!1})}}),n.renderAll=(0,f.debounce)(4,function(){if(!n.apiReady)return!1;var e=n.getMountedInstances();return e.forEach(function(e,t){0===t&&n.updateCorrelator(),e.forceUpdate()}),!0}),e.test&&(n.testMode=e),n}return s(t,e),l(t,[{key:"_processPubadsQueue",value:function(){var e=this;this._pubadsProxyQueue&&(Object.keys(this._pubadsProxyQueue).forEach(function(t){(e.googletag&&!e.googletag.pubadsReady&&_.indexOf(t)>-1||e.pubadsReady)&&(e._pubadsProxyQueue[t].forEach(function(t){return e.pubadsProxy(t)}),delete e._pubadsProxyQueue[t])}),Object.keys(this._pubadsProxyQueue).length||(this._pubadsProxyQueue=null))}},{key:"_callPubads",value:function(e){var t=e.method,n=e.args,r=e.resolve,i=e.reject;if("function"!=typeof this.googletag.pubads()[t])i(new Error("googletag.pubads does not support "+t+", please update pubadsAPI"));else try{var a,s=(a=this.googletag.pubads())[t].apply(a,o(n));r(s)}catch(e){i(e)}}},{key:"_toggleListener",value:function(e){var t=this;["scroll","resize"].forEach(function(n){window[e?"addEventListener":"removeEventListener"](n,t._foldCheck)})}},{key:"_getTimer",value:function(){return Date.now()}},{key:"_listen",value:function(){var e=this;this._listening||([y.default.SLOT_RENDER_ENDED,y.default.IMPRESSION_VIEWABLE,y.default.SLOT_VISIBILITY_CHANGED,y.default.SLOT_LOADED].forEach(function(t){["pubads","content","companionAds"].forEach(function(n){e.googletag[n]().addEventListener(t,e._onEvent.bind(e,t))})}),this._listening=!0)}},{key:"_onEvent",value:function(e,t){this.listeners(e,!0)&&this.emit(e,t);var n=this.getMountedInstances(),r=t.slot,o="on"+e.charAt(0).toUpperCase()+e.substr(1),i=n.filter(function(e){return r===e.adSlot})[0];i&&i.props[o]&&i.props[o](t)}},{key:"syncCorrelator",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this._syncCorrelator=e}},{key:"generateDivId",value:function(){return"bling-"+ ++this._adCnt}},{key:"getMountedInstances",value:function(){return this.mountedInstances||(this.mountedInstances=[]),this.mountedInstances}},{key:"addInstance",value:function(e){var t=this.getMountedInstances(),n=t.indexOf(e);n===-1&&(0===t.length&&this._toggleListener(!0),this.addMQListener(e,e.props),t.push(e))}},{key:"removeInstance",value:function(e){var t=this.getMountedInstances(),n=t.indexOf(e);n>=0&&(t.splice(n,1),0===t.length&&this._toggleListener(!1),this.removeMQListener(e,e.props))}},{key:"addMQListener",value:function(e,t){var n=this,r=t.sizeMapping;r&&Array.isArray(r)&&r.forEach(function(t){var r=t.viewport&&t.viewport[0];if(void 0!==r){if(n._mqls||(n._mqls={}),!n._mqls[r]){var o=window.matchMedia("(min-width: "+r+"px)");o.addListener(n._handleMediaQueryChange),n._mqls[r]={mql:o,listeners:[]}}n._mqls[r].listeners.indexOf(e)===-1&&n._mqls[r].listeners.push(e)}})}},{key:"removeMQListener",value:function(e){var t=this;this._mqls&&Object.keys(this._mqls).forEach(function(n){var r=t._mqls[n].listeners.indexOf(e);r>-1&&t._mqls[n].listeners.splice(r,1),0===t._mqls[n].listeners.length&&(t._mqls[n].mql.removeListener(t._handleMediaQueryChange),delete t._mqls[n])})}},{key:"isInViewport",value:function(){return b.default.apply(void 0,arguments)}},{key:"refresh",value:function(e,t){return!!this.pubadsReady&&(this.googletag.pubads().refresh(e,t),!0)}},{key:"clear",value:function(e){return!!this.pubadsReady&&(this.googletag.pubads().clear(e),!0)}},{key:"getGPTVersion",value:function(){return!!this.apiReady&&this.googletag.getVersion()}},{key:"getPubadsVersion",value:function(){return!!this.pubadsReady&&this.googletag.pubads().getVersion()}},{key:"updateCorrelator",value:function(){return!!this.pubadsReady&&(this.googletag.pubads().updateCorrelator(),!0)}},{key:"load",value:function(e){var t=this;return this._loadPromise||(this._loadPromise=new Promise(function(n,r){if(t.testMode)return void n(t.googletag);if(!h.canUseDOM)return void r(new Error("DOM not available"));if(!e)return void r(new Error("url is missing"));var o=function(){window.googletag?(t._googletag=window.googletag,t.googletag.cmd.push(function(){t._isLoaded=!0,n(t.googletag)})):r(new Error("window.googletag is not available"))};if(window.googletag&&window.googletag.apiReady)o();else{var i=document.createElement("script");i.async=!0,i.onload=o,i.onerror=function(){r(new Error("failed to load script"))},i.src=e,document.head.appendChild(i)}}))}},{key:"pubadsProxy",value:function(e){var t=this,n=e.method,r=e.args,o=void 0===r?[]:r,i=e.resolve,a=e.reject;return i?(this._callPubads({method:n,args:o,resolve:i,reject:a}),Promise.resolve()):(_.indexOf(n)>-1&&(this["_"+n]=o&&o.length&&o[0]||!0),new Promise(function(e,r){var i={method:n,args:o,resolve:e,reject:r};t.pubadsReady?t._callPubads(i):(t._pubadsProxyQueue||(t._pubadsProxyQueue={}),t._pubadsProxyQueue[n]||(t._pubadsProxyQueue[n]=[]),t._pubadsProxyQueue[n].push(i))}))}},{key:"googletag",get:function(){return this._googletag}},{key:"isLoaded",get:function(){return!!this._isLoaded}},{key:"isReady",get:function(){return!!this._isReady}},{key:"apiReady",get:function(){return this.googletag&&this.googletag.apiReady}},{key:"pubadsReady",get:function(){return this.googletag&&this.googletag.pubadsReady}},{key:"testMode",get:function(){return this._testMode},set:function(e){return}}]),t}(d.default)},function(e,t){function n(e,t,n){return e.reduce(function(e,r){return e.props[r]=t[r],e.nextProps[r]=n[r],e},{props:{},nextProps:{}})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t){function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0],n=r(t,2),o=n[0],i=n[1],a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!e||1!==e.nodeType)return!1;var s=e.getBoundingClientRect(),u={top:s.top,left:s.left,bottom:s.bottom,right:s.right},l={top:0,left:0,bottom:window.innerHeight,right:window.innerWidth},c=u.bottom>=l.top+i*a&&u.right>=l.left+o*a&&u.top<=l.bottom-i*a&&u.left<=l.right-o*a;return c}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(o)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();t.default=n},function(e,t,n){function r(e){return null===e||void 0===e}function o(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length)&&("function"==typeof e.copy&&"function"==typeof e.slice&&!(e.length>0&&"number"!=typeof e[0]))}function i(e,t,n){var i,c;if(r(e)||r(t))return!1;if(e.prototype!==t.prototype)return!1;if(u(e))return!!u(t)&&(e=a.call(e),t=a.call(t),l(e,t,n));if(o(e)){if(!o(t))return!1;if(e.length!==t.length)return!1;for(i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}try{var d=s(e),f=s(t)}catch(e){return!1}if(d.length!=f.length)return!1;for(d.sort(),f.sort(),i=d.length-1;i>=0;i--)if(d[i]!=f[i])return!1;for(i=d.length-1;i>=0;i--)if(c=d[i],!l(e[c],t[c],n))return!1;return typeof e==typeof t}var a=Array.prototype.slice,s=n(10),u=n(9),l=e.exports=function(e,t,n){return n||(n={}),e===t||(e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():!e||!t||"object"!=typeof e&&"object"!=typeof t?n.strict?e===t:e==t:i(e,t,n))}},function(e,t){function n(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function r(e){return e&&"object"==typeof e&&"number"==typeof e.length&&Object.prototype.hasOwnProperty.call(e,"callee")&&!Object.prototype.propertyIsEnumerable.call(e,"callee")||!1}var o="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();t=e.exports=o?n:r,t.supported=n,t.unsupported=r},function(e,t){function n(e){var t=[];for(var n in e)t.push(n);return t}t=e.exports="function"==typeof Object.keys?Object.keys:n,t.shim=n},function(e,t,n){"use strict";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(){this._events=new r,this._eventsCount=0}var a=Object.prototype.hasOwnProperty,s="~";Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(s=!1)),i.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)a.call(e,t)&&n.push(s?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},i.prototype.listeners=function(e,t){var n=s?s+e:e,r=this._events[n];if(t)return!!r;if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,a=new Array(i);o<i;o++)a[o]=r[o].fn;return a},i.prototype.emit=function(e,t,n,r,o,i){var a=s?s+e:e;if(!this._events[a])return!1;var u,l,c=this._events[a],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,o),!0;case 6:return c.fn.call(c.context,t,n,r,o,i),!0}for(l=1,u=new Array(d-1);l<d;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var f,p=c.length;for(l=0;l<p;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),d){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,r);break;default:if(!u)for(f=1,u=new Array(d-1);f<d;f++)u[f-1]=arguments[f];c[l].fn.apply(c[l].context,u)}}return!0},i.prototype.on=function(e,t,n){var r=new o(t,n||this),i=s?s+e:e;return this._events[i]?this._events[i].fn?this._events[i]=[this._events[i],r]:this._events[i].push(r):(this._events[i]=r,this._eventsCount++),this},i.prototype.once=function(e,t,n){var r=new o(t,n||this,!0),i=s?s+e:e;return this._events[i]?this._events[i].fn?this._events[i]=[this._events[i],r]:this._events[i].push(r):(this._events[i]=r,this._eventsCount++),this},i.prototype.removeListener=function(e,t,n,o){var i=s?s+e:e;if(!this._events[i])return this;if(!t)return 0===--this._eventsCount?this._events=new r:delete this._events[i],this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||n&&a.context!==n||(0===--this._eventsCount?this._events=new r:delete this._events[i]);else{for(var u=0,l=[],c=a.length;u<c;u++)(a[u].fn!==t||o&&!a[u].once||n&&a[u].context!==n)&&l.push(a[u]);l.length?this._events[i]=1===l.length?l[0]:l:0===--this._eventsCount?this._events=new r:delete this._events[i]}return this},i.prototype.removeAllListeners=function(e){var t;return e?(t=s?s+e:e,this._events[t]&&(0===--this._eventsCount?this._events=new r:delete this._events[t])):(this._events=new r,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prototype.setMaxListeners=function(){return this},i.prefixed=s,i.EventEmitter=i,e.exports=i},function(e,t,n){var r;/*! Copyright (c) 2015 Jed Watson. Based on code that is Copyright 2013-2015, Facebook, Inc. All rights reserved. */ !function(){"use strict";var o=!("undefined"==typeof window||!window.document||!window.document.createElement),i={canUseDOM:o,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:o&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:o&&!!window.screen};r=function(){return i}.call(t,n,t,e),!(void 0!==r&&(e.exports=r))}()},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";function r(e,t,n,r,i,a,s,u){if(o(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,r,i,a,s,u],d=0;l=new Error(t.replace(/%s/g,function(){return c[d++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var o=function(e){};e.exports=r},function(e,t){"use strict";var n={childContextTypes:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,mixins:!0,propTypes:!0,type:!0},r={name:!0,length:!0,prototype:!0,caller:!0,arguments:!0,arity:!0},o="function"==typeof Object.getOwnPropertySymbols;e.exports=function(e,t,i){if("string"!=typeof t){var a=Object.getOwnPropertyNames(t);o&&(a=a.concat(Object.getOwnPropertySymbols(t)));for(var s=0;s<a.length;++s)if(!(n[a[s]]||r[a[s]]||i&&i[a[s]]))try{e[a[s]]=t[a[s]]}catch(e){}}return e}},function(e,t,n){"use strict";var r=n(13),o=n(14),i=n(18);e.exports=function(){function e(e,t,n,r,a,s){s!==i&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t,n){e.exports=n(16)()},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},function(e,t,n){var r=n(3);e.exports=function(e,t,n){return void 0===n?r(e,t,!1):r(e,n,t!==!1)}},function(e,t,n){var r=n(3),o=n(19);e.exports={throttle:r,debounce:o}},function(t,n){t.exports=e},function(e,n){e.exports=t}])});