import { c as createCommonjsModule, u as unwrapExports } from './_commonjsHelpers-0c4b6f40.js';
import React__default from 'react';
import PropTypes from 'prop-types';

var domain;

// This constructor is used to store event handlers. Instantiating this is
// faster than explicitly calling `Object.create(null)` to get a "clean" empty
// object (tested with v8 v4.9).
function EventHandlers() {}
EventHandlers.prototype = Object.create(null);

function EventEmitter() {
  EventEmitter.init.call(this);
}

// nodejs oddity
// require('events') === require('events').EventEmitter
EventEmitter.EventEmitter = EventEmitter;

EventEmitter.usingDomains = false;

EventEmitter.prototype.domain = undefined;
EventEmitter.prototype._events = undefined;
EventEmitter.prototype._maxListeners = undefined;

// By default EventEmitters will print a warning if more than 10 listeners are
// added to it. This is a useful default which helps finding memory leaks.
EventEmitter.defaultMaxListeners = 10;

EventEmitter.init = function() {
  this.domain = null;
  if (EventEmitter.usingDomains) {
    // if there is an active domain, then attach to it.
    if (domain.active ) ;
  }

  if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
    this._events = new EventHandlers();
    this._eventsCount = 0;
  }

  this._maxListeners = this._maxListeners || undefined;
};

// Obviously not all Emitters should be limited to 10. This function allows
// that to be increased. Set to zero for unlimited.
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  if (typeof n !== 'number' || n < 0 || isNaN(n))
    throw new TypeError('"n" argument must be a positive number');
  this._maxListeners = n;
  return this;
};

function $getMaxListeners(that) {
  if (that._maxListeners === undefined)
    return EventEmitter.defaultMaxListeners;
  return that._maxListeners;
}

EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  return $getMaxListeners(this);
};

// These standalone emit* functions are used to optimize calling of event
// handlers for fast cases because emit() itself often has a variable number of
// arguments and can be deoptimized because of that. These functions always have
// the same number of arguments and thus do not get deoptimized, so the code
// inside them can execute faster.
function emitNone(handler, isFn, self) {
  if (isFn)
    handler.call(self);
  else {
    var len = handler.length;
    var listeners = arrayClone(handler, len);
    for (var i = 0; i < len; ++i)
      listeners[i].call(self);
  }
}
function emitOne(handler, isFn, self, arg1) {
  if (isFn)
    handler.call(self, arg1);
  else {
    var len = handler.length;
    var listeners = arrayClone(handler, len);
    for (var i = 0; i < len; ++i)
      listeners[i].call(self, arg1);
  }
}
function emitTwo(handler, isFn, self, arg1, arg2) {
  if (isFn)
    handler.call(self, arg1, arg2);
  else {
    var len = handler.length;
    var listeners = arrayClone(handler, len);
    for (var i = 0; i < len; ++i)
      listeners[i].call(self, arg1, arg2);
  }
}
function emitThree(handler, isFn, self, arg1, arg2, arg3) {
  if (isFn)
    handler.call(self, arg1, arg2, arg3);
  else {
    var len = handler.length;
    var listeners = arrayClone(handler, len);
    for (var i = 0; i < len; ++i)
      listeners[i].call(self, arg1, arg2, arg3);
  }
}

function emitMany(handler, isFn, self, args) {
  if (isFn)
    handler.apply(self, args);
  else {
    var len = handler.length;
    var listeners = arrayClone(handler, len);
    for (var i = 0; i < len; ++i)
      listeners[i].apply(self, args);
  }
}

EventEmitter.prototype.emit = function emit(type) {
  var er, handler, len, args, i, events, domain;
  var doError = (type === 'error');

  events = this._events;
  if (events)
    doError = (doError && events.error == null);
  else if (!doError)
    return false;

  domain = this.domain;

  // If there is no 'error' event listener then throw.
  if (doError) {
    er = arguments[1];
    if (domain) {
      if (!er)
        er = new Error('Uncaught, unspecified "error" event');
      er.domainEmitter = this;
      er.domain = domain;
      er.domainThrown = false;
      domain.emit('error', er);
    } else if (er instanceof Error) {
      throw er; // Unhandled 'error' event
    } else {
      // At least give some kind of context to the user
      var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
      err.context = er;
      throw err;
    }
    return false;
  }

  handler = events[type];

  if (!handler)
    return false;

  var isFn = typeof handler === 'function';
  len = arguments.length;
  switch (len) {
    // fast cases
    case 1:
      emitNone(handler, isFn, this);
      break;
    case 2:
      emitOne(handler, isFn, this, arguments[1]);
      break;
    case 3:
      emitTwo(handler, isFn, this, arguments[1], arguments[2]);
      break;
    case 4:
      emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
      break;
    // slower
    default:
      args = new Array(len - 1);
      for (i = 1; i < len; i++)
        args[i - 1] = arguments[i];
      emitMany(handler, isFn, this, args);
  }

  return true;
};

function _addListener(target, type, listener, prepend) {
  var m;
  var events;
  var existing;

  if (typeof listener !== 'function')
    throw new TypeError('"listener" argument must be a function');

  events = target._events;
  if (!events) {
    events = target._events = new EventHandlers();
    target._eventsCount = 0;
  } else {
    // To avoid recursion in the case that type === "newListener"! Before
    // adding it to the listeners, first emit "newListener".
    if (events.newListener) {
      target.emit('newListener', type,
                  listener.listener ? listener.listener : listener);

      // Re-assign `events` because a newListener handler could have caused the
      // this._events to be assigned to a new object
      events = target._events;
    }
    existing = events[type];
  }

  if (!existing) {
    // Optimize the case of one listener. Don't need the extra array object.
    existing = events[type] = listener;
    ++target._eventsCount;
  } else {
    if (typeof existing === 'function') {
      // Adding the second element, need to change to array.
      existing = events[type] = prepend ? [listener, existing] :
                                          [existing, listener];
    } else {
      // If we've already got an array, just append.
      if (prepend) {
        existing.unshift(listener);
      } else {
        existing.push(listener);
      }
    }

    // Check for listener leak
    if (!existing.warned) {
      m = $getMaxListeners(target);
      if (m && m > 0 && existing.length > m) {
        existing.warned = true;
        var w = new Error('Possible EventEmitter memory leak detected. ' +
                            existing.length + ' ' + type + ' listeners added. ' +
                            'Use emitter.setMaxListeners() to increase limit');
        w.name = 'MaxListenersExceededWarning';
        w.emitter = target;
        w.type = type;
        w.count = existing.length;
        emitWarning(w);
      }
    }
  }

  return target;
}
function emitWarning(e) {
  typeof console.warn === 'function' ? console.warn(e) : console.log(e);
}
EventEmitter.prototype.addListener = function addListener(type, listener) {
  return _addListener(this, type, listener, false);
};

EventEmitter.prototype.on = EventEmitter.prototype.addListener;

EventEmitter.prototype.prependListener =
    function prependListener(type, listener) {
      return _addListener(this, type, listener, true);
    };

function _onceWrap(target, type, listener) {
  var fired = false;
  function g() {
    target.removeListener(type, g);
    if (!fired) {
      fired = true;
      listener.apply(target, arguments);
    }
  }
  g.listener = listener;
  return g;
}

EventEmitter.prototype.once = function once(type, listener) {
  if (typeof listener !== 'function')
    throw new TypeError('"listener" argument must be a function');
  this.on(type, _onceWrap(this, type, listener));
  return this;
};

EventEmitter.prototype.prependOnceListener =
    function prependOnceListener(type, listener) {
      if (typeof listener !== 'function')
        throw new TypeError('"listener" argument must be a function');
      this.prependListener(type, _onceWrap(this, type, listener));
      return this;
    };

// emits a 'removeListener' event iff the listener was removed
EventEmitter.prototype.removeListener =
    function removeListener(type, listener) {
      var list, events, position, i, originalListener;

      if (typeof listener !== 'function')
        throw new TypeError('"listener" argument must be a function');

      events = this._events;
      if (!events)
        return this;

      list = events[type];
      if (!list)
        return this;

      if (list === listener || (list.listener && list.listener === listener)) {
        if (--this._eventsCount === 0)
          this._events = new EventHandlers();
        else {
          delete events[type];
          if (events.removeListener)
            this.emit('removeListener', type, list.listener || listener);
        }
      } else if (typeof list !== 'function') {
        position = -1;

        for (i = list.length; i-- > 0;) {
          if (list[i] === listener ||
              (list[i].listener && list[i].listener === listener)) {
            originalListener = list[i].listener;
            position = i;
            break;
          }
        }

        if (position < 0)
          return this;

        if (list.length === 1) {
          list[0] = undefined;
          if (--this._eventsCount === 0) {
            this._events = new EventHandlers();
            return this;
          } else {
            delete events[type];
          }
        } else {
          spliceOne(list, position);
        }

        if (events.removeListener)
          this.emit('removeListener', type, originalListener || listener);
      }

      return this;
    };

EventEmitter.prototype.removeAllListeners =
    function removeAllListeners(type) {
      var listeners, events;

      events = this._events;
      if (!events)
        return this;

      // not listening for removeListener, no need to emit
      if (!events.removeListener) {
        if (arguments.length === 0) {
          this._events = new EventHandlers();
          this._eventsCount = 0;
        } else if (events[type]) {
          if (--this._eventsCount === 0)
            this._events = new EventHandlers();
          else
            delete events[type];
        }
        return this;
      }

      // emit removeListener for all listeners on all events
      if (arguments.length === 0) {
        var keys = Object.keys(events);
        for (var i = 0, key; i < keys.length; ++i) {
          key = keys[i];
          if (key === 'removeListener') continue;
          this.removeAllListeners(key);
        }
        this.removeAllListeners('removeListener');
        this._events = new EventHandlers();
        this._eventsCount = 0;
        return this;
      }

      listeners = events[type];

      if (typeof listeners === 'function') {
        this.removeListener(type, listeners);
      } else if (listeners) {
        // LIFO order
        do {
          this.removeListener(type, listeners[listeners.length - 1]);
        } while (listeners[0]);
      }

      return this;
    };

EventEmitter.prototype.listeners = function listeners(type) {
  var evlistener;
  var ret;
  var events = this._events;

  if (!events)
    ret = [];
  else {
    evlistener = events[type];
    if (!evlistener)
      ret = [];
    else if (typeof evlistener === 'function')
      ret = [evlistener.listener || evlistener];
    else
      ret = unwrapListeners(evlistener);
  }

  return ret;
};

EventEmitter.listenerCount = function(emitter, type) {
  if (typeof emitter.listenerCount === 'function') {
    return emitter.listenerCount(type);
  } else {
    return listenerCount.call(emitter, type);
  }
};

EventEmitter.prototype.listenerCount = listenerCount;
function listenerCount(type) {
  var events = this._events;

  if (events) {
    var evlistener = events[type];

    if (typeof evlistener === 'function') {
      return 1;
    } else if (evlistener) {
      return evlistener.length;
    }
  }

  return 0;
}

EventEmitter.prototype.eventNames = function eventNames() {
  return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
};

// About 1.5x faster than the two-arg version of Array#splice().
function spliceOne(list, index) {
  for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
    list[i] = list[k];
  list.pop();
}

function arrayClone(arr, i) {
  var copy = new Array(i);
  while (i--)
    copy[i] = arr[i];
  return copy;
}

function unwrapListeners(arr) {
  var ret = new Array(arr.length);
  for (var i = 0; i < ret.length; ++i) {
    ret[i] = arr[i].listener || arr[i];
  }
  return ret;
}

var utils = createCommonjsModule(function (module, exports) {

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.loadGPTScript = loadGPTScript;

function doloadGPTScript(resolve, reject) {
  window.googletag = window.googletag || {};
  window.googletag.cmd = window.googletag.cmd || [];
  var scriptTag = document.createElement('script');
  scriptTag.src = "".concat(document.location.protocol, "//securepubads.g.doubleclick.net/tag/js/gpt.js");
  scriptTag.async = true;
  scriptTag.type = 'text/javascript';

  scriptTag.onerror = function scriptTagOnError(errs) {
    reject(errs);
  };

  scriptTag.onload = function scriptTagOnLoad() {
    resolve(window.googletag);
  };

  document.getElementsByTagName('head')[0].appendChild(scriptTag);
}

function loadGPTScript() {
  return new Promise(function (resolve, reject) {
    doloadGPTScript(resolve, reject);
  });
}
});

unwrapExports(utils);
utils.loadGPTScript;

var manager = createCommonjsModule(function (module, exports) {

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;



var Utils = _interopRequireWildcard(utils);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

var loadPromise = null;
var googleGPTScriptLoadPromise = null;
var singleRequestEnabled = true;
var disableInitialLoadEnabled = false;
var lazyLoadEnabled = false;
var lazyLoadConfig = null;
var servePersonalizedAds = true;
var serveCookies = true;
var registeredSlots = {};
var managerAlreadyInitialized = false;
var globalTargetingArguments = {};
var globalAdSenseAttributes = {};
var DFPManager = Object.assign(new EventEmitter.EventEmitter().setMaxListeners(0), {
  singleRequestIsEnabled: function singleRequestIsEnabled() {
    return singleRequestEnabled;
  },
  configureSingleRequest: function configureSingleRequest(value) {
    singleRequestEnabled = !!value;
  },
  disableInitialLoadIsEnabled: function disableInitialLoadIsEnabled() {
    return disableInitialLoadEnabled;
  },
  configureDisableInitialLoad: function configureDisableInitialLoad(value) {
    disableInitialLoadEnabled = !!value;
  },
  configureLazyLoad: function configureLazyLoad() {
    var enable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
    var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
    var conf = null;

    if (config !== null && _typeof(config) === 'object') {
      conf = _objectSpread({}, config);
    }

    lazyLoadEnabled = !!enable;
    lazyLoadConfig = conf;
  },
  lazyLoadIsEnabled: function lazyLoadIsEnabled() {
    return lazyLoadEnabled;
  },
  getLazyLoadConfig: function getLazyLoadConfig() {
    return lazyLoadConfig;
  },
  getAdSenseAttribute: function getAdSenseAttribute(key) {
    return globalAdSenseAttributes[key];
  },
  configurePersonalizedAds: function configurePersonalizedAds(value) {
    servePersonalizedAds = value;
  },
  configureCookieOption: function configureCookieOption(value) {
    serveCookies = value;
  },
  personalizedAdsEnabled: function personalizedAdsEnabled() {
    return servePersonalizedAds;
  },
  cookiesEnabled: function cookiesEnabled() {
    return serveCookies;
  },
  setAdSenseAttribute: function setAdSenseAttribute(key, value) {
    this.setAdSenseAttributes(_defineProperty({}, key, value));
  },
  getAdSenseAttributes: function getAdSenseAttributes() {
    return _objectSpread({}, globalAdSenseAttributes);
  },
  setAdSenseAttributes: function setAdSenseAttributes(attrs) {
    Object.assign(globalAdSenseAttributes, attrs);

    if (managerAlreadyInitialized === true) {
      this.getGoogletag().then(function (googletag) {
        googletag.cmd.push(function () {
          var pubadsService = googletag.pubads();
          Object.keys(globalAdSenseAttributes).forEach(function (key) {
            pubadsService.set(key, globalTargetingArguments[key]);
          });
        });
      });
    }
  },
  setTargetingArguments: function setTargetingArguments(data) {
    Object.assign(globalTargetingArguments, data);

    if (managerAlreadyInitialized === true) {
      this.getGoogletag().then(function (googletag) {
        googletag.cmd.push(function () {
          var pubadsService = googletag.pubads();
          Object.keys(globalTargetingArguments).forEach(function (varName) {
            if (pubadsService) {
              pubadsService.setTargeting(varName, globalTargetingArguments[varName]);
            }
          });
        });
      });
    }
  },
  getTargetingArguments: function getTargetingArguments() {
    return _objectSpread({}, globalTargetingArguments);
  },
  getSlotProperty: function getSlotProperty(slotId, propName) {
    var slot = this.getRegisteredSlots()[slotId];
    var ret = null;

    if (slot !== undefined) {
      ret = slot[propName] || ret;
    }

    return ret;
  },
  getSlotTargetingArguments: function getSlotTargetingArguments(slotId) {
    var propValue = this.getSlotProperty(slotId, 'targetingArguments');
    return propValue ? _objectSpread({}, propValue) : null;
  },
  getSlotAdSenseAttributes: function getSlotAdSenseAttributes(slotId) {
    var propValue = this.getSlotProperty(slotId, 'adSenseAttributes');
    return propValue ? _objectSpread({}, propValue) : null;
  },
  init: function init() {
    var _this = this;

    if (managerAlreadyInitialized === false) {
      managerAlreadyInitialized = true;
      this.getGoogletag().then(function (googletag) {
        googletag.cmd.push(function () {
          var pubadsService = googletag.pubads();
          pubadsService.addEventListener('slotRenderEnded', function (event) {
            var slotId = event.slot.getSlotElementId();

            _this.emit('slotRenderEnded', {
              slotId: slotId,
              event: event
            });
          });
          pubadsService.addEventListener('impressionViewable', function (event) {
            var slotId = event.slot.getSlotElementId();

            _this.emit('impressionViewable', {
              slotId: slotId,
              event: event
            });
          });
          pubadsService.addEventListener('slotVisibilityChanged', function (event) {
            var slotId = event.slot.getSlotElementId();

            _this.emit('slotVisibilityChanged', {
              slotId: slotId,
              event: event
            });
          });
          pubadsService.setRequestNonPersonalizedAds(_this.personalizedAdsEnabled() ? 0 : 1);
          pubadsService.setCookieOptions(_this.cookiesEnabled() ? 0 : 1);
        });
      });
    }
  },
  getGoogletag: function getGoogletag() {
    if (googleGPTScriptLoadPromise === null) {
      googleGPTScriptLoadPromise = Utils.loadGPTScript();
    }

    return googleGPTScriptLoadPromise;
  },
  setCollapseEmptyDivs: function setCollapseEmptyDivs(collapse) {
    this.collapseEmptyDivs = collapse;
  },
  load: function load() {
    var _this2 = this;

    for (var _len = arguments.length, slots = new Array(_len), _key = 0; _key < _len; _key++) {
      slots[_key] = arguments[_key];
    }

    if (loadPromise === null) {
      loadPromise = this.doLoad.apply(this, slots);
    } else {
      loadPromise = loadPromise.then(function () {
        return _this2.doLoad.apply(_this2, slots);
      });
    }
  },
  doLoad: function doLoad() {
    this.init();
    var availableSlots = {};

    for (var _len2 = arguments.length, slots = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
      slots[_key2] = arguments[_key2];
    }

    if (slots.length > 0) {
      availableSlots = slots.filter(function (slotId) {
        return Object.prototype.hasOwnProperty.call(registeredSlots, slotId);
      });
    } else {
      availableSlots = Object.keys(registeredSlots);
    }

    availableSlots = availableSlots.filter(function (id) {
      return !registeredSlots[id].loading && !registeredSlots[id].gptSlot;
    });
    availableSlots.forEach(function (slotId) {
      registeredSlots[slotId].loading = true;
    });
    return this.gptLoadAds(availableSlots);
  },
  gptLoadAds: function gptLoadAds(slotsToInitialize) {
    var _this3 = this;

    return new Promise(function (resolve) {
      _this3.getGoogletag().then(function (googletag) {
        _this3.configureInitialOptions(googletag);

        slotsToInitialize.forEach(function (currentSlotId) {
          registeredSlots[currentSlotId].loading = false;
          googletag.cmd.push(function () {
            var slot = registeredSlots[currentSlotId];
            var gptSlot;
            var adUnit = "".concat(slot.dfpNetworkId, "/").concat(slot.adUnit);

            if (slot.renderOutOfThePage === true) {
              gptSlot = googletag.defineOutOfPageSlot(adUnit, currentSlotId);
            } else {
              gptSlot = googletag.defineSlot(adUnit, slot.sizes, currentSlotId);
            }

            if (gptSlot !== null) {
              slot.gptSlot = gptSlot;

              var slotTargetingArguments = _this3.getSlotTargetingArguments(currentSlotId);

              if (slotTargetingArguments !== null) {
                Object.keys(slotTargetingArguments).forEach(function (varName) {
                  if (slot && slot.gptSlot) {
                    slot.gptSlot.setTargeting(varName, slotTargetingArguments[varName]);
                  }
                });
              }

              var slotAdSenseAttributes = _this3.getSlotAdSenseAttributes(currentSlotId);

              if (slotAdSenseAttributes !== null) {
                Object.keys(slotAdSenseAttributes).forEach(function (varName) {
                  slot.gptSlot.set(varName, slotAdSenseAttributes[varName]);
                });
              }

              slot.gptSlot.addService(googletag.pubads());

              if (slot.sizeMapping) {
                var smbuilder = googletag.sizeMapping();
                slot.sizeMapping.forEach(function (mapping) {
                  smbuilder = smbuilder.addSize(mapping.viewport, mapping.sizes);
                });
                slot.gptSlot.defineSizeMapping(smbuilder.build());
              }
            }
          });
        });

        _this3.configureOptions(googletag);

        googletag.cmd.push(function () {
          googletag.enableServices();
          slotsToInitialize.forEach(function (theSlotId) {
            googletag.display(theSlotId);
          });
          resolve();
        });
      });
    });
  },
  // configure those gpt parameters that need to be set before pubsads service
  // initialization.
  configureInitialOptions: function configureInitialOptions(googletag) {
    var _this4 = this;

    googletag.cmd.push(function () {
      if (_this4.disableInitialLoadIsEnabled()) {
        googletag.pubads().disableInitialLoad();
      }
    });
  },
  configureOptions: function configureOptions(googletag) {
    var _this5 = this;

    googletag.cmd.push(function () {
      var pubadsService = googletag.pubads();
      pubadsService.setRequestNonPersonalizedAds(_this5.personalizedAdsEnabled() ? 0 : 1);
      pubadsService.setCookieOptions(_this5.cookiesEnabled() ? 0 : 1);

      var targetingArguments = _this5.getTargetingArguments(); // set global targetting arguments


      Object.keys(targetingArguments).forEach(function (varName) {
        if (pubadsService) {
          pubadsService.setTargeting(varName, targetingArguments[varName]);
        }
      }); // set global adSense attributes

      var adSenseAttributes = _this5.getAdSenseAttributes();

      Object.keys(adSenseAttributes).forEach(function (key) {
        pubadsService.set(key, adSenseAttributes[key]);
      });

      if (_this5.lazyLoadIsEnabled()) {
        var config = _this5.getLazyLoadConfig();

        if (config) {
          pubadsService.enableLazyLoad(config);
        } else {
          pubadsService.enableLazyLoad();
        }
      }

      if (_this5.singleRequestIsEnabled()) {
        pubadsService.enableSingleRequest();
      }

      if (_this5.collapseEmptyDivs === true || _this5.collapseEmptyDivs === false) {
        pubadsService.collapseEmptyDivs(_this5.collapseEmptyDivs);
      }
    });
  },
  getRefreshableSlots: function getRefreshableSlots() {
    var slots = {};

    for (var _len3 = arguments.length, slotsArray = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
      slotsArray[_key3] = arguments[_key3];
    }

    if (slotsArray.length === 0) {
      var slotsToRefresh = Object.keys(registeredSlots).map(function (k) {
        return registeredSlots[k];
      });
      return slotsToRefresh.reduce(function (last, slot) {
        if (slot.slotShouldRefresh() === true) {
          slots[slot.slotId] = slot;
        }

        return slots;
      }, slots);
    }

    return slotsArray.reduce(function (last, slotId) {
      var slot = registeredSlots[slotId];

      if (typeof slot !== 'undefined') {
        slots[slotId] = slot;
      }

      return slots;
    }, slots);
  },
  refresh: function refresh() {
    var _this6 = this;

    for (var _len4 = arguments.length, slots = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
      slots[_key4] = arguments[_key4];
    }

    if (loadPromise === null) {
      this.load();
    } else {
      loadPromise.then(function () {
        _this6.gptRefreshAds(Object.keys(_this6.getRefreshableSlots.apply(_this6, slots)));
      });
    }
  },
  gptRefreshAds: function gptRefreshAds(slots) {
    var _this7 = this;

    return this.getGoogletag().then(function (googletag) {
      _this7.configureOptions(googletag);

      googletag.cmd.push(function () {
        var pubadsService = googletag.pubads();
        pubadsService.refresh(slots.map(function (slotId) {
          return registeredSlots[slotId].gptSlot;
        }));
      });
    });
  },
  reload: function reload() {
    var _this8 = this;

    return this.destroyGPTSlots.apply(this, arguments).then(function () {
      return _this8.load();
    });
  },
  destroyGPTSlots: function destroyGPTSlots() {
    var _this9 = this;

    for (var _len5 = arguments.length, slotsToDestroy = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
      slotsToDestroy[_key5] = arguments[_key5];
    }

    if (slotsToDestroy.length === 0) {
      // eslint-disable-next-line no-param-reassign
      slotsToDestroy = Object.keys(registeredSlots);
    }

    return new Promise(function (resolve) {
      var slots = []; // eslint-disable-next-line guard-for-in,no-restricted-syntax

      for (var idx in slotsToDestroy) {
        var slotId = slotsToDestroy[idx];
        var slot = registeredSlots[slotId];
        slots.push(slot);
      }

      _this9.getGoogletag().then(function (googletag) {
        googletag.cmd.push(function () {
          if (managerAlreadyInitialized === true) {
            if (slotsToDestroy.length > 0) {
              // eslint-disable-next-line guard-for-in,no-restricted-syntax
              for (var _idx in slots) {
                var _slot = slots[_idx];
                slots.push(_slot.gptSlot);
                delete _slot.gptSlot;
              }

              googletag.destroySlots(slots);
            } else {
              googletag.destroySlots();
            }
          }

          resolve(slotsToDestroy);
        });
      });
    });
  },
  registerSlot: function registerSlot(_ref) {
    var _this10 = this;

    var slotId = _ref.slotId,
        dfpNetworkId = _ref.dfpNetworkId,
        adUnit = _ref.adUnit,
        sizes = _ref.sizes,
        renderOutOfThePage = _ref.renderOutOfThePage,
        sizeMapping = _ref.sizeMapping,
        adSenseAttributes = _ref.adSenseAttributes,
        targetingArguments = _ref.targetingArguments,
        slotShouldRefresh = _ref.slotShouldRefresh;
    var autoLoad = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;

    if (!Object.prototype.hasOwnProperty.call(registeredSlots, slotId)) {
      registeredSlots[slotId] = {
        slotId: slotId,
        sizes: sizes,
        renderOutOfThePage: renderOutOfThePage,
        dfpNetworkId: dfpNetworkId,
        adUnit: adUnit,
        adSenseAttributes: adSenseAttributes,
        targetingArguments: targetingArguments,
        sizeMapping: sizeMapping,
        slotShouldRefresh: slotShouldRefresh,
        loading: false
      };
      this.emit('slotRegistered', {
        slotId: slotId
      });

      if (autoLoad === true && loadPromise !== null) {
        loadPromise = loadPromise.catch().then(function () {
          var slot = registeredSlots[slotId];

          if (typeof slot !== 'undefined') {
            var loading = slot.loading,
                gptSlot = slot.gptSlot;

            if (loading === false && !gptSlot) {
              _this10.load(slotId);
            }
          }
        });
      }
    }
  },
  unregisterSlot: function unregisterSlot(_ref2) {
    var slotId = _ref2.slotId;
    this.destroyGPTSlots(slotId);
    delete registeredSlots[slotId];
  },
  getRegisteredSlots: function getRegisteredSlots() {
    return registeredSlots;
  },
  attachSlotRenderEnded: function attachSlotRenderEnded(cb) {
    this.on('slotRenderEnded', cb);
  },
  detachSlotRenderEnded: function detachSlotRenderEnded(cb) {
    this.removeListener('slotRenderEnded', cb);
  },
  attachSlotVisibilityChanged: function attachSlotVisibilityChanged(cb) {
    this.on('slotVisibilityChanged', cb);
  },
  detachSlotVisibilityChanged: function detachSlotVisibilityChanged(cb) {
    this.removeListener('slotVisibilityChanged', cb);
  },
  attachSlotIsViewable: function attachSlotIsViewable(cb) {
    this.on('impressionViewable', cb);
  },
  detachSlotIsViewable: function detachSlotIsViewable(cb) {
    this.removeListener('impressionViewable', cb);
  }
});
var _default = DFPManager;
exports.default = _default;
});

unwrapExports(manager);

var dfpslotsprovider = createCommonjsModule(function (module, exports) {

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.Context = void 0;

var _react = _interopRequireDefault(React__default);

var _propTypes = _interopRequireDefault(PropTypes);

var _manager = _interopRequireDefault(manager);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

// React.createContext is undefined for React < 16.3
var Context = _react.default.createContext ? _react.default.createContext({
  dfpNetworkId: null,
  dfpAdUnit: null,
  dfpSizeMapping: null,
  dfpTargetingArguments: null,
  newSlotCallback: null
}) : null;
exports.Context = Context;

var DFPSlotsProvider =
/*#__PURE__*/
function (_React$Component) {
  _inherits(DFPSlotsProvider, _React$Component);

  function DFPSlotsProvider(props) {
    var _this;

    _classCallCheck(this, DFPSlotsProvider);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(DFPSlotsProvider).call(this, props));
    _this.loadAdsIfPossible = _this.loadAdsIfPossible.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.newSlotCallback = _this.newSlotCallback.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.applyConfigs = _this.applyConfigs.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.shouldReloadConfig = _this.shouldReloadConfig.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.attachLoadCallback = _this.attachLoadCallback.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.getContextValue = _this.getContextValue.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.loadAlreadyCalled = false;
    _this.loadCallbackAttached = false;
    _this.shouldReloadAds = false;
    _this.totalSlots = 0;
    _this.contextValue = {};

    if (Context === null) {
      _this.getChildContext = function () {
        return _this.getContextValue();
      };
    }

    return _this;
  }

  _createClass(DFPSlotsProvider, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.applyConfigs();

      if (this.props.autoLoad && !this.loadAdsIfPossible()) {
        this.attachLoadCallback();
      }
    }
  }, {
    key: "shouldComponentUpdate",
    value: function shouldComponentUpdate(nextProps) {
      this.shouldReloadAds = this.shouldReloadConfig(nextProps);

      if (nextProps.children !== this.props.children) {
        return true;
      }

      if (nextProps.autoLoad && !this.props.autoLoad) {
        return true;
      }

      return this.shouldReloadAds;
    }
  }, {
    key: "componentDidUpdate",
    value: function componentDidUpdate() {
      this.applyConfigs();

      if (this.props.autoLoad) {
        if (this.loadAlreadyCalled) {
          if (this.shouldReloadAds) {
            _manager.default.reload();
          }
        } else if (!this.loadAdsIfPossible()) {
          this.attachLoadCallback();
        }
      }

      this.shouldReloadAds = false;
    }
  }, {
    key: "getContextValue",
    value: function getContextValue() {
      var _this$props = this.props,
          dfpNetworkId = _this$props.dfpNetworkId,
          dfpAdUnit = _this$props.adUnit,
          dfpSizeMapping = _this$props.sizeMapping,
          dfpTargetingArguments = _this$props.targetingArguments,
          _this$contextValue = this.contextValue,
          ctxDfpNetworkId = _this$contextValue.dfpNetworkId,
          ctxDfpAdUnit = _this$contextValue.adUnit,
          ctxDfpSizeMapping = _this$contextValue.sizeMapping,
          ctxDfpTargetingArguments = _this$contextValue.targetingArguments; // performance: update context value object only when any of its
      // props is updated.

      if (dfpNetworkId !== ctxDfpNetworkId || dfpAdUnit !== ctxDfpAdUnit || dfpSizeMapping !== ctxDfpSizeMapping || dfpTargetingArguments !== ctxDfpTargetingArguments) {
        this.contextValue = {
          dfpNetworkId: dfpNetworkId,
          dfpAdUnit: dfpAdUnit,
          dfpSizeMapping: dfpSizeMapping,
          dfpTargetingArguments: dfpTargetingArguments,
          newSlotCallback: this.newSlotCallback
        };
      }

      return this.contextValue;
    }
  }, {
    key: "applyConfigs",
    value: function applyConfigs() {
      _manager.default.configurePersonalizedAds(this.props.personalizedAds);

      _manager.default.configureCookieOption(this.props.cookieOption);

      _manager.default.configureSingleRequest(this.props.singleRequest);

      _manager.default.configureDisableInitialLoad(this.props.disableInitialLoad);

      _manager.default.configureLazyLoad(!!this.props.lazyLoad, typeof this.props.lazyLoad === 'boolean' ? null : this.props.lazyLoad);

      _manager.default.setAdSenseAttributes(this.props.adSenseAttributes);

      _manager.default.setCollapseEmptyDivs(this.props.collapseEmptyDivs);
    }
  }, {
    key: "attachLoadCallback",
    value: function attachLoadCallback() {
      if (this.loadCallbackAttached === false) {
        _manager.default.on('slotRegistered', this.loadAdsIfPossible);

        this.loadCallbackAttached = true;
        return true;
      }

      return false;
    } // pretty strait-forward interface that children ad slots use to register
    // with their DFPSlotProvider parent node.

  }, {
    key: "newSlotCallback",
    value: function newSlotCallback() {
      this.totalSlots++;
    } // Checks all the mounted children ads have been already registered
    // in the DFPManager before trying to call the gpt load scripts.
    // This is helpful when trying to fetch ads with a single request.

  }, {
    key: "loadAdsIfPossible",
    value: function loadAdsIfPossible() {
      var r = false;

      if (Object.keys(_manager.default.getRegisteredSlots()).length >= this.totalSlots) {
        _manager.default.removeListener('slotRegistered', this.loadAdsIfPossible);

        _manager.default.load();

        this.loadAlreadyCalled = true;
        this.loadCallbackAttached = false;
        r = true;
      }

      return r;
    }
  }, {
    key: "shouldReloadConfig",
    value: function shouldReloadConfig(nextProps) {
      var reloadConfig = nextProps.autoReload || this.props.autoReload;

      if (this.props.autoLoad || nextProps.autoLoad) {
        if (_typeof(reloadConfig) === 'object') {
          var attrs = Object.keys(reloadConfig); // eslint-disable-next-line guard-for-in, no-restricted-syntax

          for (var i in attrs) {
            var propName = attrs[i]; // eslint-disable-next-line

            if (reloadConfig[propName] === true && this.props[propName] !== nextProps[propName]) {
              return true;
            }
          }
        }
      }

      return false;
    }
  }, {
    key: "render",
    value: function render() {
      var children = this.props.children;

      if (Context === null) {
        return children;
      }

      return _react.default.createElement(Context.Provider, {
        value: this.getContextValue()
      }, children);
    }
  }]);

  return DFPSlotsProvider;
}(_react.default.Component);

exports.default = DFPSlotsProvider;

_defineProperty(DFPSlotsProvider, "propTypes", {
  children: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.array]).isRequired,
  autoLoad: _propTypes.default.bool,
  autoReload: _propTypes.default.shape({
    dfpNetworkId: _propTypes.default.bool,
    personalizedAds: _propTypes.default.bool,
    cookieOption: _propTypes.default.bool,
    singleRequest: _propTypes.default.bool,
    disableInitialLoad: _propTypes.default.bool,
    adUnit: _propTypes.default.bool,
    sizeMapping: _propTypes.default.bool,
    adSenseAttributes: _propTypes.default.bool,
    targetingArguments: _propTypes.default.bool,
    collapseEmptyDivs: _propTypes.default.bool,
    lazyLoad: _propTypes.default.bool
  }),
  dfpNetworkId: _propTypes.default.string.isRequired,
  personalizedAds: _propTypes.default.bool,
  cookieOption: _propTypes.default.bool,
  singleRequest: _propTypes.default.bool,
  disableInitialLoad: _propTypes.default.bool,
  adUnit: _propTypes.default.string,
  sizeMapping: _propTypes.default.arrayOf(_propTypes.default.object),
  adSenseAttributes: _propTypes.default.object,
  targetingArguments: _propTypes.default.object,
  collapseEmptyDivs: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.object]),
  adSenseAttrs: _propTypes.default.object,
  lazyLoad: _propTypes.default.oneOfType([_propTypes.default.bool, _propTypes.default.shape({
    fetchMarginPercent: _propTypes.default.number,
    renderMarginPercent: _propTypes.default.number,
    mobileScaling: _propTypes.default.number
  })])
});

_defineProperty(DFPSlotsProvider, "defaultProps", {
  autoLoad: true,
  autoReload: {
    dfpNetworkId: false,
    personalizedAds: false,
    cookieOption: false,
    singleRequest: false,
    disableInitialLoad: false,
    adUnit: false,
    sizeMapping: false,
    adSenseAttributes: false,
    targetingArguments: false,
    collapseEmptyDivs: false,
    lazyLoad: false
  },
  personalizedAds: true,
  cookieOption: true,
  singleRequest: true,
  disableInitialLoad: false,
  collapseEmptyDivs: null,
  lazyLoad: false
});

if (Context === null) {
  // React < 16.3
  DFPSlotsProvider.childContextTypes = {
    dfpNetworkId: _propTypes.default.string,
    dfpAdUnit: _propTypes.default.string,
    dfpSizeMapping: _propTypes.default.arrayOf(_propTypes.default.object),
    dfpTargetingArguments: _propTypes.default.object,
    newSlotCallback: _propTypes.default.func
  };
}
});

unwrapExports(dfpslotsprovider);
dfpslotsprovider.Context;

var adslot = createCommonjsModule(function (module, exports) {

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.AdSlot = void 0;

var _react = _interopRequireDefault(React__default);

var _propTypes = _interopRequireDefault(PropTypes);

var _manager = _interopRequireDefault(manager);



function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var dynamicAdCount = 0;

var AdSlot =
/*#__PURE__*/
function (_React$Component) {
  _inherits(AdSlot, _React$Component);

  function AdSlot(props) {
    var _this;

    _classCallCheck(this, AdSlot);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(AdSlot).call(this, props));
    _this.doRegisterSlot = _this.doRegisterSlot.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.generateSlotId = _this.generateSlotId.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.getSlotId = _this.getSlotId.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.mapContextToAdSlotProps = _this.mapContextToAdSlotProps.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.slotShouldRefresh = _this.slotShouldRefresh.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.slotRenderEnded = _this.slotRenderEnded.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.slotRegisterCallback = _this.slotRegisterCallback.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.slotIsViewable = _this.slotIsViewable.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.slotVisibilityChanged = _this.slotVisibilityChanged.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.getClasses = _this.getClasses.bind(_assertThisInitialized(_assertThisInitialized(_this)));
    _this.state = {
      slotId: _this.props.slotId || null,
      className: _this.props.className || ''
    };
    _this.adElementRef = _react.default.createRef ? _react.default.createRef() : function (element) {
      _this.adElementRef = element;
    };
    return _this;
  }

  _createClass(AdSlot, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      // register this ad-unit in the <DFPSlotProvider>, when available.
      if (this.context !== undefined && this.context.newSlotCallback) {
        this.context.newSlotCallback();
      }

      this.registerSlot();
    }
  }, {
    key: "componentWillUnmount",
    value: function componentWillUnmount() {
      this.unregisterSlot();
    }
  }, {
    key: "getSlotId",
    value: function getSlotId() {
      return this.props.slotId || this.state.slotId;
    }
  }, {
    key: "getClasses",
    value: function getClasses() {
      var baseClass = 'adunitContainer';
      var extraClasses = this.state.className.split(' ');
      extraClasses.push(baseClass);
      return extraClasses;
    }
  }, {
    key: "generateSlotId",
    value: function generateSlotId() {
      return "adSlot-".concat(dynamicAdCount++);
    }
  }, {
    key: "mapContextToAdSlotProps",
    value: function mapContextToAdSlotProps() {
      var context = this.context;
      var mappedProps = {};

      if (context.dfpNetworkId !== undefined) {
        mappedProps.dfpNetworkId = context.dfpNetworkId;
      }

      if (context.dfpAdUnit !== undefined) {
        mappedProps.adUnit = context.dfpAdUnit;
      }

      if (context.dfpSizeMapping !== undefined) {
        mappedProps.sizeMapping = context.dfpSizeMapping;
      }

      if (context.dfpTargetingArguments !== undefined) {
        mappedProps.targetingArguments = context.dfpTargetingArguments;
      }

      return mappedProps;
    }
  }, {
    key: "doRegisterSlot",
    value: function doRegisterSlot() {
      _manager.default.registerSlot(_objectSpread({}, this.mapContextToAdSlotProps(), this.props, this.state, {
        slotShouldRefresh: this.slotShouldRefresh
      }));

      if (this.props.fetchNow === true) {
        _manager.default.load(this.getSlotId());
      }

      _manager.default.attachSlotRenderEnded(this.slotRenderEnded);

      _manager.default.attachSlotIsViewable(this.slotIsViewable);

      _manager.default.attachSlotVisibilityChanged(this.slotVisibilityChanged);

      this.slotRegisterCallback();
    }
  }, {
    key: "registerSlot",
    value: function registerSlot() {
      if (this.state.slotId === null) {
        this.setState({
          slotId: this.generateSlotId()
        }, this.doRegisterSlot);
      } else {
        this.doRegisterSlot();
      }
    }
  }, {
    key: "unregisterSlot",
    value: function unregisterSlot() {
      _manager.default.unregisterSlot(_objectSpread({}, this.mapContextToAdSlotProps(), this.props, this.state));

      _manager.default.detachSlotRenderEnded(this.slotRenderEnded);

      _manager.default.detachSlotIsViewable(this.slotIsViewable);

      _manager.default.detachSlotVisibilityChanged(this.slotVisibilityChanged);
    }
  }, {
    key: "slotRenderEnded",
    value: function slotRenderEnded(eventData) {
      if (eventData.slotId === this.getSlotId()) {
        if (this.props.onSlotRender !== undefined) {
          // now that slot has rendered we have access to the ref
          var params = _objectSpread({}, eventData, {
            adElementRef: this.adElementRef
          });

          this.props.onSlotRender(params);
        }
      }
    }
  }, {
    key: "slotRegisterCallback",
    value: function slotRegisterCallback() {
      if (typeof this.props.onSlotRegister === 'function') {
        this.props.onSlotRegister({
          slotId: this.getSlotId(),
          sizes: this.props.sizes,
          slotCount: dynamicAdCount,
          adElementRef: this.adElementRef
        });
      }
    }
  }, {
    key: "slotIsViewable",
    value: function slotIsViewable(eventData) {
      if (eventData.slotId === this.getSlotId()) {
        if (this.props.onSlotIsViewable !== undefined) {
          this.props.onSlotIsViewable(eventData);
        }
      }
    }
  }, {
    key: "slotVisibilityChanged",
    value: function slotVisibilityChanged(eventData) {
      if (eventData.slotId === this.getSlotId()) {
        if (this.props.onSlotVisibilityChanged !== undefined) {
          this.props.onSlotVisibilityChanged(eventData);
        }
      }
    }
  }, {
    key: "slotShouldRefresh",
    value: function slotShouldRefresh() {
      var r = true;

      if (this.props.shouldRefresh !== undefined) {
        r = this.props.shouldRefresh(_objectSpread({}, this.mapContextToAdSlotProps(), this.props, {
          slotId: this.getSlotId()
        }));
      }

      return r;
    }
  }, {
    key: "render",
    value: function render() {
      var slotId = this.state.slotId;
      var props = {
        className: 'adBox'
      };

      if (slotId !== null) {
        props.id = slotId;
      }

      return _react.default.createElement("div", {
        className: this.getClasses().join(' ').trim()
      }, _react.default.createElement("div", _extends({
        ref: this.adElementRef
      }, props)));
    }
  }]);

  return AdSlot;
}(_react.default.Component);

exports.AdSlot = AdSlot;

_defineProperty(AdSlot, "propTypes", {
  dfpNetworkId: _propTypes.default.string,
  adUnit: _propTypes.default.string,
  sizes: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.number), _propTypes.default.string])),
  renderOutOfThePage: _propTypes.default.bool,
  sizeMapping: _propTypes.default.arrayOf(_propTypes.default.object),
  fetchNow: _propTypes.default.bool,
  adSenseAttributes: _propTypes.default.object,
  targetingArguments: _propTypes.default.object,
  onSlotRender: _propTypes.default.func,
  onSlotRegister: _propTypes.default.func,
  onSlotIsViewable: _propTypes.default.func,
  onSlotVisibilityChanged: _propTypes.default.func,
  shouldRefresh: _propTypes.default.func,
  slotId: _propTypes.default.string,
  className: _propTypes.default.string
});

_defineProperty(AdSlot, "defaultProps", {
  fetchNow: false
});

if (dfpslotsprovider.Context === null) {
  // React < 16.3
  AdSlot.contextTypes = {
    dfpNetworkId: _propTypes.default.string,
    dfpAdUnit: _propTypes.default.string,
    dfpSizeMapping: _propTypes.default.arrayOf(_propTypes.default.object),
    dfpTargetingArguments: _propTypes.default.object,
    newSlotCallback: _propTypes.default.func
  };
} else {
  AdSlot.contextType = dfpslotsprovider.Context;
}

var _default = AdSlot;
exports.default = _default;
});

unwrapExports(adslot);
adslot.AdSlot;

var lib = createCommonjsModule(function (module, exports) {

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DFPSlotsProvider = exports.AdSlot = exports.DFPManager = void 0;

var _manager = _interopRequireDefault(manager);

var _adslot = _interopRequireDefault(adslot);

var _dfpslotsprovider = _interopRequireDefault(dfpslotsprovider);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var DFPManager = _manager.default;
exports.DFPManager = DFPManager;
var AdSlot = _adslot.default;
exports.AdSlot = AdSlot;
var DFPSlotsProvider = _dfpslotsprovider.default;
exports.DFPSlotsProvider = DFPSlotsProvider;
});

unwrapExports(lib);
var lib_1 = lib.DFPSlotsProvider;
var lib_2 = lib.AdSlot;
var lib_3 = lib.DFPManager;

export { lib_2 as a, lib_1 as b, lib_3 as l };
