import './stringify-59c8f690.js';
import { _ as _slicedToArray } from './slicedToArray-be2f7a22.js';
import React, { useState, useEffect } from 'react';
import { m as main_43 } from './main-b5c5aac1.js';
import DFPAdSlot from './AdSlot.js';
import './_commonjsHelpers-0c4b6f40.js';
import './_to-object-b50e61c3.js';
import './web.dom.iterable-4109ff68.js';
import './es6.string.iterator-bc33758b.js';
import './core.get-iterator-method-133dfacd.js';
import './extends-60e0e1c6.js';
import './_object-pie-133f504a.js';
import 'prop-types';
import './index-2446af28.js';
import './events-6c3a7a63.js';
import './debounce-533d9748.js';
import './isSymbol-a7e9aafe.js';
import './toNumber-5aeba6e7.js';
import './Beam.js';
import './asyncToGenerator-7f8f9219.js';
import './_library-528f1934.js';
import './_iter-detect-7e5e5ce2.js';
import './Segment.js';

// removed static slotID ,because defining static slotID is restricting AD to render only once.
var AD300x250 = function AD300x250(_ref) {
  var networkID = _ref.networkID,
      adUnit = _ref.adUnit,
      _ref$slotId = _ref.slotId,
      slotId = _ref$slotId === undefined ? '' : _ref$slotId,
      _ref$targeting = _ref.targeting,
      targeting = _ref$targeting === undefined ? {} : _ref$targeting,
      _ref$pos = _ref.pos,
      pos = _ref$pos === undefined ? 'rec1' : _ref$pos;

  var mobileView = false;
  if (main_43) {
    pos = 'rec1-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 = [[300, 600], [300, 250], [300, 100]];
  var mobileSizes = [[300, 250], [300, 100]];

  return React.createElement(
    'div',
    null,
    React.createElement(DFPAdSlot, {
      networkID: networkID,
      adUnit: adUnit,
      slotId: slotId,
      targeting: adTargeting,
      className: 'AD300x250',
      sizes: mobileView ? mobileSizes : browserSizes
      /* Passing function to check for ad creative only if it is not in preview. */
      // checkIsAdFound={previewAd ? null : checkIsAdFound}
      // style={{ display: 'none' }}
    }),
    React.createElement(
      'style',
      { jsx: 'true' },
      '\n        .AD300x250 .div[id*=\'google_ads_iframe\']:empty {\n          height: 0px !important;\n        }\n      '
    )
  );
};

export default AD300x250;
