'use strict';

var stringify = require('./stringify-f7a37a8d.js');
var toConsumableArray = require('./toConsumableArray-d7797c2b.js');
var asyncToGenerator = require('./asyncToGenerator-77821af0.js');
var _extends = require('./extends-7c86182f.js');
var inherits = require('./inherits-de66ea16.js');
var React = require('react');
var index = require('./index-fc2f1ca2.js');
var Container = require('react-bootstrap/Container');
var Row = require('react-bootstrap/Row');
var Col = require('react-bootstrap/Col');
var Card = require('react-bootstrap/Card');
var moment = require('./moment-aca40de1.js');
var Router = require('next/router');
var index$1 = require('./index-eadd5035.js');
var entities = require('./entities-df1aed86.js');
var ADInfeed = require('./ADInfeed-81006615.js');
var lodash = require('./lodash-f0783643.js');
var ADlgInfeed = require('./ADlgInfeed-0db07099.js');
var getContentCategory = require('./getContentCategory-f38a4c00.js');
var get = require('./get-5839e5b5.js');
var urlFor = require('./urlFor.js');
var main = require('./main-f1c77adb.js');
var AuthorComponent = require('./AuthorComponent-39b37d84.js');
var PublicationFeature = require('./PublicationFeature-5ccf9b13.js');
var Pagination = require('./Pagination-1e0d5f1d.js');
var Spinner = require('react-bootstrap/Spinner');
require('./_commonjsHelpers-06173234.js');
require('./core.get-iterator-method-5643aa10.js');
require('./_iter-detect-b1df62f0.js');
require('./web.dom.iterable-d98303e0.js');
require('./_library-dd23b178.js');
require('./_object-pie-083f2dd6.js');
require('./_object-sap-d1978572.js');
require('./define-property-e8404b64.js');
require('./typeof-567e31ff.js');
require('./_is-array-54228b29.js');
require('./events-1b438fe7.js');
require('prop-types');
require('react-dom');
require('./slicedToArray-067dd3bc.js');
require('./AdSlot.js');
require('./debounce-d4a2369b.js');
require('./isSymbol-03abbdf0.js');
require('./toNumber-5e1fac58.js');
require('./Beam.js');
require('./Segment.js');
require('./eq-5fc26c07.js');
require('./index-d48b231c.js');
require('react-bootstrap/Button');
require('react-paginate');
require('./index.esm-d51c9ac6.js');
require('./iconBase-be4097c0.js');

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

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
var Row__default = /*#__PURE__*/_interopDefaultLegacy(Row);
var Col__default = /*#__PURE__*/_interopDefaultLegacy(Col);
var Card__default = /*#__PURE__*/_interopDefaultLegacy(Card);
var Spinner__default = /*#__PURE__*/_interopDefaultLegacy(Spinner);

var GridContent = function (_React$Component) {
  inherits._inherits(GridContent, _React$Component);

  function GridContent() {
    var _ref,
        _this2 = this;

    var _temp, _this, _ret;

    inherits._classCallCheck(this, GridContent);

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

    return _ret = (_temp = (_this = inherits._possibleConstructorReturn(this, (_ref = GridContent.__proto__ || inherits._Object$getPrototypeOf(GridContent)).call.apply(_ref, [this].concat(args))), _this), _this.page = _this.props.page, _this.mapping = _this.props.mapping, _this.data = _this.props.dataRecord, _this.query = _this.props.query, _this.params = _this.props.params, _this.client = _this.props.client, _this.seoPaginate = _this.props.seoPaginate, _this.pointer = _this.props.pointer ? _this.props.pointer : false, _this.pointerArray = _this.props.pointerArray ? _this.props.pointerArray : false, _this.defaultImage = _this.props.defaultImage ? _this.props.defaultImage : '/placeholder.jpg', _this.state = {
      isDataLoading: false,
      data: _this.data,
      prevData: _this.data,
      itemsPerPage: _this.params ? _this.params.itemsPerPage : _this.params.from && _this.params.to ? _this.params.to - _this.params.from : 30,
      currentPage: _this.props.currentPage || 1,
      lgInfeedAd: _this.props.lgInfeedAd ? _this.props.lgInfeedAd : false,
      showCategory: _this.props.showCategory ? _this.props.showCategory : false,
      contentCategoryMapping: _this.props.contentCategoryMapping ? contentCategoryMapping : [],
      totalDataCount: _this.props.totalDataCount
    }, _this.componentDidUpdate = function (prevProps, prevState) {
      var _this$props = _this.props,
          pageview = _this$props.pageview,
          currentPath = _this$props.router.asPath;
      var prevPath = prevProps.router.asPath;

      if (pageview && currentPath !== prevPath) {
        pageview(currentPath);
      }
    }, _this.renderCardImage = function (row, page) {
      if (row.thumbnail && row.thumbnail.asset) {
        var url = urlFor({
          client: _this.client,
          source: row.thumbnail,
          imageHeight: _this.props.imageHeight || null,
          imageWidth: _this.props.imageWidth || null,
          imageFit: _this.props.imageFit || null
        });
        return url;
      } else {
        return _this.defaultImage;
      }
    }, _this.seoPagination = function (pageNumber) {
      var router = _this.props.router;

      var path = router.asPath;
      var qrIndex = path.indexOf('?');
      var pathname = router.pathname;
      var queryString = '';
      if (qrIndex > 0) {
        path = path.substring(1, qrIndex);
        var partialQS = router.asPath.substring(qrIndex + 1);
        var partialQSArr = partialQS.split('&');
        // exclude page=xxx from query string
        partialQSArr.map(function (item) {
          var itemArr = item.split('=');
          var key = itemArr[0];
          var val = itemArr[1];
          if (key !== 'page') queryString += (queryString.length === 0 ? '' : '&') + key + '=' + val;
        });
      }
      if (queryString.length > 0) path += '?' + queryString;
      pageNumber = parseInt(pageNumber);
      if (_this.state.page !== pageNumber) {
        if (path[0] !== '/') path = '/' + path;
        var newPath = pageNumber === 1 ? '' + path : '' + path + (queryString.length > 0 ? '&' : '?') + 'page=' + pageNumber;
        router.push(pathname, newPath, {
          shallow: true
        });
      }
    }, _this.handlePageChange = function () {
      var _ref2 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(selectedPage) {
        var start, newParams, newData;
        return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                console.log('selectedPage', selectedPage);
                _this.setState({
                  isDataLoading: true,
                  currentPage: selectedPage
                });
                _this.seoPaginate && _this.seoPagination(selectedPage);
                index.lib_3.refresh();
                document.body.scrollTop = 0;
                document.documentElement.scrollTop = 0;
                start = (selectedPage - 1) * _this.state.itemsPerPage;
                newParams = _extends._extends({}, _this.params, {
                  from: start,
                  to: start + _this.state.itemsPerPage
                });
                _context.prev = 8;
                _context.next = 11;
                return _this.client.fetch(_this.query, newParams);

              case 11:
                newData = _context.sent;

                if (_this.pointer && _this.pointerArray) newData = newData[pointerArray][pointer];
                if (newData && newData.length > 0) {
                  _this.setState({
                    isDataLoading: false,
                    data: newData,
                    page: selectedPage
                  });
                }
                _context.next = 19;
                break;

              case 16:
                _context.prev = 16;
                _context.t0 = _context['catch'](8);

                console.error(_context.t0);

              case 19:
              case 'end':
                return _context.stop();
            }
          }
        }, _callee, _this2, [[8, 16]]);
      }));

      return function (_x) {
        return _ref2.apply(this, arguments);
      };
    }(), _this.checkExternalUrl = function (url) {
      return new RegExp(['http', 'https'].join('|')).test(url);
    }, _this.renderMobileAd = function (index, numberOfItemsBeforeAd) {
      var rightItems = _this.props.rightItems;

      var i = ((index + 1) / numberOfItemsBeforeAd - 1) % rightItems.length;
      return React__default['default'].createElement(
        'div',
        { style: { display: 'flex', flex: '1 0 auto' } },
        rightItems[i].component
      );
    }, _temp), inherits._possibleConstructorReturn(_this, _ret);
  }

  inherits._createClass(GridContent, [{
    key: 'cardLoader',
    value: function cardLoader(page, columns, variant, showVideo, VideoPlayer, showBI, brandInsight, lgInfeedAd, contentCategoryMapping) {
      var _this3 = this;

      var lgVar = Math.floor(12 / columns);
      var itemCounter = 0;
      var numberOfItemsBeforeAd = 6;
      var numberOfItemsBeforeVideo = 3;
      if (variant === 'stack') {
        return React__default['default'].createElement(
          Row__default['default'],
          null,
          this.state.data && this.state.data.length > 0 ? this.state.data.map(function (row, index) {
            // const thumbnailURL = get(row, 'thumbnail.asset.url', this.props.defaultImage)
            return React__default['default'].createElement(
              Col__default['default'],
              { key: index, md: 12, lg: lgVar, style: { display: 'flex', flex: '1 0 auto' } },
              React__default['default'].createElement(
                Card__default['default'],
                { className: 'queue-card', style: { borderTop: '1px solid #EEE' } },
                React__default['default'].createElement(
                  Row__default['default'],
                  { style: { flexDirection: 'row' } },
                  React__default['default'].createElement(
                    Col__default['default'],
                    { md: 12, lg: 4 },
                    React__default['default'].createElement(
                      'a',
                      { href: _this3.page + '/' + get.get_1(row, 'url.current') },
                      React__default['default'].createElement(
                        index$1.LazyLoad,
                        { height: _this3.props.imageHeight },
                        React__default['default'].createElement(Card__default['default'].Img, { variant: 'top', src: _this3.renderCardImage(row, page), alt: row.thumbnail && row.thumbnail.asset ? row.thumbnail.asset.originalFilename : '' })
                      )
                    )
                  ),
                  React__default['default'].createElement(
                    Col__default['default'],
                    null,
                    React__default['default'].createElement(
                      Card__default['default'].Body,
                      { style: { padding: '20px' } },
                      React__default['default'].createElement(
                        Card__default['default'].Title,
                        null,
                        React__default['default'].createElement(
                          'a',
                          { href: _this3.page + '/' + get.get_1(row, 'url.current') },
                          row.title
                        )
                      ),
                      _this3.props.showPublished && row.published && React__default['default'].createElement(
                        Card__default['default'].Subtitle,
                        { style: { marginTop: 0 } },
                        moment.moment(row.published).format('MMMM DD, YYYY')
                      ),
                      _this3.props.showAuthor && row.authorMapping && row.authorMapping.length > 0 && React__default['default'].createElement(
                        index$1.LazyLoad,
                        { height: 50 },
                        React__default['default'].createElement(AuthorComponent.AuthorComponent, { key: index.toString(), index: index, authors: row.authorMapping })
                      ),
                      _this3.props.showCategory && row.contentCategory && React__default['default'].createElement(
                        index$1.LazyLoad,
                        { height: 50 },
                        React__default['default'].createElement(
                          'p',
                          {
                            className: 'article-category',
                            style: {
                              background: '#3FB618',
                              color: '#ffffff',
                              marginBottom: '.25rem',
                              display: 'inline-block',
                              padding: '0 .25rem',
                              fontSize: '.8rem'
                            } },
                          getContentCategory.getContentCategory(row.contentCategory.name, contentCategoryMapping)
                        )
                      ),
                      React__default['default'].createElement(
                        Card__default['default'].Text,
                        null,
                        entities.clean_html_1(row.summary)
                      )
                    )
                  )
                )
              )
            );
          }) : React__default['default'].createElement(
            'div',
            null,
            React__default['default'].createElement(
              'h5',
              null,
              React__default['default'].createElement(
                'em',
                null,
                'New content coming soon, please check back later.'
              )
            )
          )
        );
      }

      var insert = function insert(arr, index, newElement) {
        return [].concat(toConsumableArray._toConsumableArray(arr.slice(0, index)), [newElement], toConsumableArray._toConsumableArray(arr.slice(index)));
      };
      var posts = [];
      if (brandInsight && (lgInfeedAd || showBI)) {
        var firstThree = this.state.data.slice(0, 3);
        var data = this.state.data.slice(3);

        //  Need to pass flag "lgInfeedAd={true}" along with brandInsight from site level for large infeed-ad to render
        //  Checking lgInfeedAd flag in desktop view ( window >= 1400px ).
        if (lgInfeedAd && typeof window !== 'undefined' && window.innerWidth >= 1400) {
          var lgInFeedAd = {
            _type: 'lg-infeed',
            adUnit: brandInsight.adUnit,
            className: 'lg-infeed',
            networkID: brandInsight.networkID,
            sizes: [728, 90],
            //  Adding sizeMapping for showing ad above 1400px
            sizeMapping: [{
              viewport: [1400, 0],
              sizes: [[728, 90]]
            }, { viewport: [0, 0], sizes: [] }],
            targeting: {
              content_placement: brandInsight.targeting.content_placement,
              document_url: brandInsight.targeting.document_url,
              document_group: brandInsight.targeting.document_group,
              rootDocumentGroup: brandInsight.targeting.rootDocumentGroup
            },
            /* Passing refresh flag */
            refreshFlag: brandInsight.refreshFlag ? brandInsight.refreshFlag : false
          };
          var chunks = lodash.lodash.chunk(data, 6).map(function (chunk) {
            var set = lodash.lodash.chunk(chunk, 2);
            for (var i = 0; i < set.length; i++) {
              if (i !== set.length - 1) {
                set[i].push(lgInFeedAd);
              }
            }
            return lodash.lodash.flattenDeep(set);
          });

          posts = lodash.lodash.flatten(chunks);
        }

        if (showBI) {
          //  Checking lgInfeedAd flag in desktop view ( window >= 1400px ).
          if (lgInfeedAd && typeof window !== 'undefined' && window.innerWidth >= 1400) {
            brandInsight.interval = 8;
          } else if (typeof window !== 'undefined' && window.innerWidth < 1400) {
            brandInsight.interval = 5;
            posts = data;
          }

          var pos = 0;
          for (var i = 1; pos < posts.length; i++) {
            var inFeedAd = {
              adUnit: brandInsight.adUnit,
              className: brandInsight.className,
              networkID: brandInsight.networkID,
              sizes: brandInsight.sizes,
              slotId: brandInsight.slotId + '_' + i,
              targeting: {
                pos: 'infeed',
                content_placement: brandInsight.targeting.content_placement,
                document_url: brandInsight.targeting.document_url,
                document_group: brandInsight.targeting.document_group,
                rootDocumentGroup: brandInsight.targeting.rootDocumentGroup
              },
              _type: 'brandInsightAd',
              /* Passing refresh flag */
              refreshFlag: brandInsight.refreshFlag ? brandInsight.refreshFlag : false
            };

            posts = insert(posts, pos, inFeedAd);
            pos += brandInsight.interval + 1;
          }
        }
        posts = firstThree.concat(posts);
      } else {
        posts = this.state.data;
      }

      // 'articleCount' is New parameter to use instead of 'index' while passing to 'changePageNumber()'
      // 'index' was including the indexes for infeed ads along with article count making the page number change before it reaches last article.
      // 'articleCount' will be the indexes of only the articles in the deck.
      var articleCount = -1;
      posts = posts.map(function (ele, i) {
        if (ele._type === 'lg-infeed') {
          //  Setting pos as top2 for the first occurence of large infeed ad
          // const pos = posts.indexOf(posts.find((d) => d._type === 'lg-infeed')) === i ? 'top2' : `lg-infeed_${i}`
          return _extends._extends({}, ele, { slotId: 'lg-infeed_' + i, targeting: _extends._extends({}, ele.targeting, { pos: 'lg-infeed' }) });
        } else if (ele._type === 'article') {
          // incrementing 'articleCount' for each article.
          ++articleCount;
          return _extends._extends({}, ele, { articleCount: articleCount });
        } else {
          return ele;
        }
      });

      var publicationFeature = this.props.publicationFeature;

      if (publicationFeature) posts = insert(posts, 3, publicationFeature);

      this.props.params && this.props.params.itemsPerPage ? this.props.params.itemsPerPage : 10;
      var heroContent = this.props.heroContent ? this.props.heroContent : 0;
      var featureCount = 0;
      return React__default['default'].createElement(
        'div',
        { className: 'grid-container' },
        posts && posts.length > 0 ? posts.map(function (row, index) {
          var contentCategoryName = row.contentCategory && row.contentCategory.name && _this3.mapping[row.contentCategory.name] ? row.contentCategory.name : 'Articles';
          var linkHref = row.url && row.url.current ? _this3.mapping[contentCategoryName] + '/' + row.url.current : '';
          if (row._type === 'feature') {
            featureCount++;
            if (row.blank || _this3.checkExternalUrl(row.url.current)) {
              return React__default['default'].createElement(
                React__default['default'].Fragment,
                { key: itemCounter },
                React__default['default'].createElement(
                  'div',
                  { counter: itemCounter++, style: { display: 'flex', flex: '1 0 auto' } },
                  React__default['default'].createElement(
                    Card__default['default'],
                    { className: 'content-card', style: { flexDirection: index === 0 || index % 4 === 0 ? 'top' : 'row' } },
                    (row.thumbnail && row.thumbnail.asset || _this3.props.defaultImage) && React__default['default'].createElement(
                      'a',
                      { rel: 'noopener', href: row.url.current, target: '_blank', className: index === 0 || index % 4 === 0 ? '' : 'card-image' },
                      React__default['default'].createElement(
                        index$1.LazyLoad,
                        { height: _this3.props.imageHeight },
                        React__default['default'].createElement(Card__default['default'].Img, {
                          variant: 'top',
                          src: _this3.renderCardImage(row, page),
                          alt: row.thumbnail && row.thumbnail.asset ? row.thumbnail.asset.originalFilename : ''
                        })
                      )
                    ),
                    React__default['default'].createElement(
                      Card__default['default'].Body,
                      null,
                      React__default['default'].createElement(
                        'a',
                        { rel: 'noopener', href: row.url.current, target: '_blank' },
                        React__default['default'].createElement(
                          Card__default['default'].Title,
                          null,
                          row.title
                        )
                      ),
                      _this3.props.showPublished && row.published && React__default['default'].createElement(
                        Card__default['default'].Subtitle,
                        { style: { marginTop: 0 } },
                        moment.moment(row.published).format('MMMM DD, YYYY')
                      ),
                      _this3.props.showAuthor && row.authorMapping && row.authorMapping.length > 0 && React__default['default'].createElement(
                        index$1.LazyLoad,
                        { height: 50 },
                        React__default['default'].createElement(AuthorComponent.AuthorComponent, { key: index.toString(), index: index, authors: row.authorMapping })
                      ),
                      React__default['default'].createElement(
                        Card__default['default'].Text,
                        { className: index === 0 || index % 4 === 0 ? '' : 'card-subtext' },
                        entities.clean_html_1(row.summary)
                      )
                    )
                  )
                ),
                showVideo && (posts.length < numberOfItemsBeforeVideo || index + 1 === numberOfItemsBeforeVideo) && React__default['default'].createElement(VideoPlayer, null),
                main.main_43 && _this3.props.rightItems && (index + 1) % numberOfItemsBeforeAd === 0 && _this3.renderMobileAd(index, numberOfItemsBeforeAd)
              );
            } else {
              return React__default['default'].createElement(
                React__default['default'].Fragment,
                { key: itemCounter },
                React__default['default'].createElement(
                  'div',
                  { counter: itemCounter++, style: { display: 'flex', flex: '1 0 auto' } },
                  React__default['default'].createElement(
                    Card__default['default'],
                    { className: 'content-card', style: { flexDirection: index === 0 || index % 4 === 0 ? 'top' : 'row' } },
                    (row.thumbnail && row.thumbnail.asset || _this3.props.defaultImage) && React__default['default'].createElement(
                      'a',
                      { href: row.url.current, className: index === 0 || index % 4 === 0 ? '' : 'card-image' },
                      React__default['default'].createElement(
                        index$1.LazyLoad,
                        { height: _this3.props.imageHeight },
                        React__default['default'].createElement(Card__default['default'].Img, {
                          variant: 'top',
                          src: _this3.renderCardImage(row, page),
                          alt: row.thumbnail && row.thumbnail.asset ? row.thumbnail.asset.originalFilename : ''
                        })
                      )
                    ),
                    React__default['default'].createElement(
                      Card__default['default'].Body,
                      null,
                      React__default['default'].createElement(
                        'a',
                        { href: row.url.current },
                        React__default['default'].createElement(
                          Card__default['default'].Title,
                          null,
                          row.title
                        )
                      ),
                      _this3.props.showPublished && row.published && React__default['default'].createElement(
                        Card__default['default'].Subtitle,
                        { style: { marginTop: 0 } },
                        moment.moment(row.published).format('MMMM DD, YYYY')
                      ),
                      _this3.props.showAuthor && row.authorMapping && row.authorMapping.length > 0 && React__default['default'].createElement(
                        index$1.LazyLoad,
                        { height: 50 },
                        React__default['default'].createElement(AuthorComponent.AuthorComponent, { key: index.toString(), index: index, authors: row.authorMapping })
                      ),
                      React__default['default'].createElement(
                        Card__default['default'].Text,
                        { className: index === 0 || index % 4 === 0 ? '' : 'card-subtext' },
                        entities.clean_html_1(row.summary)
                      )
                    )
                  )
                ),
                showVideo && (posts.length < numberOfItemsBeforeVideo || index + 1 === numberOfItemsBeforeVideo) && React__default['default'].createElement(VideoPlayer, null),
                main.main_43 && _this3.props.rightItems && (index + 1) % numberOfItemsBeforeAd === 0 && _this3.renderMobileAd(index, numberOfItemsBeforeAd)
              );
            }
          } else if (row._type === 'lg-infeed' && row.adUnit) {
            return React__default['default'].createElement(ADlgInfeed.ADlgInfeed, _extends._extends({ index: index }, row));
          } else if (row._type === 'brandInsightAd' && row.adUnit) {
            return React__default['default'].createElement(ADInfeed.ADInfeed, { index: index, infeedAd: row });
          } else if (row._type === 'publication') return React__default['default'].createElement(PublicationFeature.PublicationFeature, { data: row, defaultImage: _this3.defaultImage, issueMapping: _this3.props.issueMapping, client: _this3.client });
          if (index + 1 > heroContent + featureCount && (!row._type || !['lg-infeed', 'brandInsightAd'].includes(row._type))) {
            return React__default['default'].createElement(
              React__default['default'].Fragment,
              { key: itemCounter },
              React__default['default'].createElement(
                'div',
                { counter: itemCounter++, style: { display: 'flex', flex: '1 0 auto' } },
                React__default['default'].createElement(
                  Card__default['default'],
                  { className: 'content-card', style: { flexDirection: index === 0 || index % 4 === 0 ? 'top' : 'row' } },
                  (row.thumbnail && row.thumbnail.asset || _this3.props.defaultImage) && React__default['default'].createElement(
                    'a',
                    { href: linkHref, className: index === 0 || index % 4 === 0 ? '' : 'card-image' },
                    React__default['default'].createElement(
                      index$1.LazyLoad,
                      { height: _this3.props.imageHeight },
                      React__default['default'].createElement(Card__default['default'].Img, { variant: 'top', src: _this3.renderCardImage(row, page), alt: row.thumbnail && row.thumbnail.asset ? row.thumbnail.asset.originalFilename : '' })
                    )
                  ),
                  React__default['default'].createElement(
                    Card__default['default'].Body,
                    null,
                    React__default['default'].createElement(
                      'a',
                      { href: linkHref },
                      React__default['default'].createElement(
                        Card__default['default'].Title,
                        null,
                        row.title
                      )
                    ),
                    _this3.props.showPublished && row.published && React__default['default'].createElement(
                      Card__default['default'].Subtitle,
                      { style: { marginTop: 0 } },
                      moment.moment(row.published).format('MMMM DD, YYYY')
                    ),
                    _this3.props.showAuthor && row.authorMapping && row.authorMapping.length > 0 && React__default['default'].createElement(
                      index$1.LazyLoad,
                      { height: 50 },
                      React__default['default'].createElement(AuthorComponent.AuthorComponent, { key: index.toString(), index: index, authors: row.authorMapping })
                    ),
                    _this3.props.showCategory && row.contentCategory && React__default['default'].createElement(
                      index$1.LazyLoad,
                      { height: 50 },
                      React__default['default'].createElement(
                        'p',
                        {
                          className: 'article-category',
                          style: {
                            background: '#3FB618',
                            color: '#ffffff',
                            marginBottom: '.25rem',
                            display: 'inline-block',
                            padding: '0 .25rem',
                            fontSize: '.8rem'
                          } },
                        getContentCategory.getContentCategory(row.contentCategory.name, contentCategoryMapping)
                      )
                    ),
                    React__default['default'].createElement(
                      Card__default['default'].Text,
                      { className: index === 0 || index % 4 === 0 ? '' : 'card-subtext' },
                      entities.clean_html_1(row.summary)
                    )
                  )
                )
              ),
              showVideo && (posts.length < numberOfItemsBeforeVideo || index + 1 === numberOfItemsBeforeVideo) && React__default['default'].createElement(VideoPlayer, null),
              main.main_43 && _this3.props.rightItems && (index + 1) % numberOfItemsBeforeAd === 0 && _this3.renderMobileAd(index, numberOfItemsBeforeAd)
            );
          } else return null;
        }) : React__default['default'].createElement(
          'div',
          null,
          React__default['default'].createElement(
            'h5',
            null,
            React__default['default'].createElement(
              'em',
              null,
              'New content coming soon, please check back later.'
            )
          )
        )
      );
    }
  }, {
    key: 'render',
    value: function render() {
      var _props = this.props,
          columns = _props.columns,
          variant = _props.variant,
          page = _props.page,
          showVideo = _props.showVideo,
          VideoPlayer = _props.VideoPlayer,
          showBI = _props.showBI,
          brandInsight = _props.brandInsight;


      return React__default['default'].createElement(
        'div',
        { className: 'contentDeck' },
        this.state.isDataLoading ? React__default['default'].createElement(
          'div',
          { className: 'd-flex justify-content-center', style: { marginTop: '100px' } },
          React__default['default'].createElement(
            Spinner__default['default'],
            { animation: 'border', role: 'status' },
            React__default['default'].createElement(
              'span',
              { className: 'sr-only' },
              'Loading...'
            )
          )
        ) : React__default['default'].createElement(
          Container__default['default'],
          null,
          this.cardLoader(page, columns, variant, showVideo, VideoPlayer, showBI, brandInsight, this.state.lgInfeedAd, this.state.contentCategoryMapping),
          React__default['default'].createElement(
            'div',
            { className: 'pagination-wrapper' },
            React__default['default'].createElement(Pagination.Pagination, {
              pageCount: Math.ceil(this.state.totalDataCount / this.state.itemsPerPage),
              pageRangeDisplayed: main.main_43 ? 3 : 9,
              currentPage: this.state.currentPage,
              onPageChange: this.handlePageChange,
              needLargePaginateButtons: this.props.needLargePaginateButtons
            }),
            React__default['default'].createElement(
              'style',
              { jsx: 'true' },
              '\n                .pagination-wrapper {\n                  margin: 3rem 0 100px 0;\n                }\n              '
            )
          )
        )
      );
    }
  }], [{
    key: 'getDerivedStateFromProps',
    value: function getDerivedStateFromProps(props, state) {
      if (stringify._JSON$stringify(props.dataRecord) !== stringify._JSON$stringify(state.prevData)) {
        return {
          data: props.dataRecord,
          prevData: props.dataRecord,
          currentPage: props.currentPage
        };
      }
      return null;
    }
  }]);

  return GridContent;
}(React__default['default'].Component);

var GridContentPaginated = React__default['default'].memo(Router.withRouter(GridContent));

module.exports = GridContentPaginated;
