import { _ as _slicedToArray } from './slicedToArray-be2f7a22.js';
import React, { useState, useEffect } from 'react';
import 'react-bootstrap/Card';
import DFPAdSlot from './AdSlot.js';

var ADlgInfeed = function ADlgInfeed(props) {
  var className = props.className,
      slotId = props.slotId,
      adUnit = props.adUnit,
      _props$targeting = props.targeting,
      targeting = _props$targeting === undefined ? {} : _props$targeting,
      networkID = props.networkID,
      sizes = props.sizes,
      index = props.index,
      _props$refreshFlag = props.refreshFlag,
      refreshFlag = _props$refreshFlag === undefined ? false : _props$refreshFlag;

  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');
    }));
  }, []);

  return React.createElement(
    'div',
    { id: 'lg-infeed-wrapper-' + (index + 1), className: 'lg-infeed-wrapper', style: { display: 'flex', flex: '1 0 auto' } },
    React.createElement(DFPAdSlot, {
      className: className,
      networkID: networkID,
      adUnit: adUnit,
      slotId: slotId,
      targeting: targeting,
      sizes: sizes
      /* Passing function to check for ad creative only if it is not in preview. */
      // checkIsAdFound={previewAd ? null : checkIsAdFound}
      /* Passing refresh flag */
      , refreshFlag: refreshFlag
    }),
    React.createElement(
      'style',
      { jsx: 'true' },
      '\n        .lg-infeed-wrapper {\n          flex-direction: row;\n          margin-bottom: 1.25rem;\n          padding-bottom: 1.25rem;\n          border-bottom: 1px solid rgb(221, 221, 221);\n        }\n        .lg-infeed-wrapper div[id*=\'google_ads_iframe\']:empty {\n          height: 0px !important;\n        }\n      '
    )
  );
};

export { ADlgInfeed as A };
