import './stringify-2b084bee.js';
import { _ as _slicedToArray } from './slicedToArray-6ebcbfea.js';
import React__default, { useState, useEffect } from 'react';
import { m as main_43 } from './main-754d4992.js';
import DFPAdSlot from './AdSlot.js';
import './_commonjsHelpers-0c4b6f40.js';
import './core.get-iterator-method-ea258bb1.js';
import './web.dom.iterable-ab4dea5c.js';
import './extends-6d8e3924.js';
import './_object-pie-133f504a.js';
import 'prop-types';
import './index-5cc7b406.js';
import './debounce-533d9748.js';
import './isSymbol-a7e9aafe.js';
import './toNumber-5aeba6e7.js';
import './Beam.js';
import './asyncToGenerator-64822ccc.js';
import './_library-528f1934.js';
import './_set-species-2cd9340f.js';
import './_iter-detect-98db3b07.js';
import './Segment.js';

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;

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

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

  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.createElement(
    'div',
    { className: 'leaderboard-ad-wrapper' },
    React__default.createElement(DFPAdSlot, {
      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.createElement(
      'style',
      { jsx: 'true' },
      '\n        .leaderboard-ad-wrapper {\n          height: auto !important;\n          min-height: 90px;\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_43 && React__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        '
    )
  );
};

export { AD728x90 as default };
