'use strict';

require('./_commonjsHelpers-06173234.js');
require('./_to-object-329a650b.js');
require('./es6.string.iterator-cc0bbaa4.js');
require('./_library-dd23b178.js');
require('./_iter-detect-60b2f026.js');
require('./core.get-iterator-method-f62321d4.js');
require('./_object-pie-68c5bcbc.js');
require('./extends-0a918631.js');
require('./web.dom.iterable-a0e279c1.js');
var React = require('react');
require('./index-e08f00ce.js');
require('prop-types');
require('./isSymbol-04666465.js');
require('./debounce-529c8d06.js');
require('./toNumber-36d1e7e5.js');
var main = require('./main-7b5e57b0.js');
var slicedToArray = require('./slicedToArray-8f385299.js');
require('./stringify-7c5aff47.js');
require('./asyncToGenerator-140e5f89.js');
require('./Segment.js');
require('./Beam.js');
var AdSlot = require('./AdSlot.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var AD728x90 = function AD728x90(_ref) {
  var networkID = _ref.networkID,
      adUnit = _ref.adUnit,
      _ref$slotId = _ref.slotId,
      slotId = _ref$slotId === undefined ? 'leaderboard-ad' : _ref$slotId,
      _ref$targeting = _ref.targeting,
      targeting = _ref$targeting === undefined ? {} : _ref$targeting,
      _ref$pos = _ref.pos,
      pos = _ref$pos === undefined ? 'top' : _ref$pos,
      _ref$fixedPos = _ref.fixedPos;

  var mobileView = false;
  if (main.main_40) {
    pos = 'top-mobile';
    mobileView = true;
  }

  var _useState = React.useState(true),
      _useState2 = slicedToArray._slicedToArray(_useState, 2),
      previewAd = _useState2[0],
      setPreviewAd = _useState2[1];

  React.useEffect(function () {
    var path = window && window.location && window.location.search;
    // Setting flag for Ad-preview URLs
    setPreviewAd(path.split('&').some(function (param) {
      return param.includes('creativeId');
    }));
  }, []);

  var adTargeting = {
    content_placement: targeting.content_placement,
    tags: targeting.tags,
    document_group: targeting.document_group,
    document_url: targeting.document_url,
    rootDocumentGroup: targeting.rootDocumentGroup,
    pos: pos,
    campaign_id: targeting.campaign_id,
    issue_url: targeting.issue_url,
    publication_url: targeting.publication_url
  };

  var browserSizes = [[728, 90], [970, 90], [320, 50], [300, 50]];
  var mobileSizes = [[320, 50], [300, 50]];

  return React__default['default'].createElement(
    'div',
    { className: 'leaderboard-ad-wrapper' },
    React__default['default'].createElement(AdSlot, {
      slotId: slotId,
      networkID: networkID,
      adUnit: adUnit,
      targeting: adTargeting,
      className: 'AD728x90',
      sizes: mobileView ? mobileSizes : browserSizes,
      sizeMapping: [{
        viewport: [1000, 1],
        sizes: [[728, 90], [970, 90]]
      }, {
        viewport: [768, 1],
        sizes: [[728, 90]]
      }, {
        viewport: [1, 1],
        sizes: [[320, 50], [300, 50]]
      }]
      /* Passing function to check for ad creative only if it is not in preview. */
      // checkIsAdFound={previewAd ? null : checkIsAdFound}
    }),
    React__default['default'].createElement(
      'style',
      { jsx: 'true' },
      '\n        .leaderboard-ad-wrapper {\n          height: auto !important;\n          background: #fff;\n        }\n        .leaderboard-ad-wrapper .AD728x90 {\n          height: auto !important;\n        }\n        /* setting height to 0px when the ad slot is empty. */\n        .leaderboard-ad-wrapper .AD728x90 div[id*=\'google_ads_iframe\']:empty {\n          height: 0px !important;\n        }\n      '
    ),
    main.main_40 && React__default['default'].createElement(
      'style',
      { jsx: 'true' },
      '\n          @media screen and (max-width: 768px) {\n            .leaderboard-ad-wrapper {\n              min-height: 0px;\n              position: fixed;\n              background: transparent;\n              background-color: transparent;\n              bottom: 0px;\n              left: 50%;\n              transform: translateX(-50%);\n              z-index: 9999;\n            }\n          }\n        '
    )
  );
};

module.exports = AD728x90;
