import { _ as _slicedToArray } from './slicedToArray-6ebcbfea.js';
import React__default, { useState, useEffect } from 'react';
import { useRouter } from 'next/router';
import Container from 'react-bootstrap/Container';
import ADGutter from './ADGutter.js';
import AD728x90 from './AD728x90.js';
import Header from './Header.js';
import { Column1 } from './Column1.js';
import { Column2 } from './Column2.js';
import { Column3 } from './Column3.js';
import MagazineNav from './NavMagazine.js';
import { NavNative } from './NavNative.js';
import { NavDvm } from './NavDvm.js';
import { HamMagazine } from './HamMagazine.js';
import './_commonjsHelpers-0c4b6f40.js';
import './web.dom.iterable-ab4dea5c.js';
import './core.get-iterator-method-ea258bb1.js';
import './AdSlot.js';
import './extends-6d8e3924.js';
import './_object-pie-133f504a.js';
import 'prop-types';
import './index-f0fc23eb.js';
import './events-6c3a7a63.js';
import './debounce-533d9748.js';
import './isSymbol-a7e9aafe.js';
import './toNumber-5aeba6e7.js';
import './Beam.js';
import './stringify-2b084bee.js';
import './asyncToGenerator-958ef5fc.js';
import './_library-528f1934.js';
import './_iter-detect-98db3b07.js';
import './Segment.js';
import './main-1894c974.js';
import 'next/head';
import 'react-bootstrap/Row';
import 'react-bootstrap/Col';
import './SideFooter.js';
import './react-social-icons-9be47857.js';
import './get-3c308da4.js';
import './eq-bdcbf886.js';
import './checkSisterSite-baa4fb6b.js';
import './ConferenceBanner-8792ebd2.js';
import './ADSponsoredResources.js';
import './LeftNav.js';
import 'react-bootstrap/ListGroup';
import './ADWebcast.js';
import './PageFilter.js';
import 'react-bootstrap';
import 'react-bootstrap/Nav';
import 'react-bootstrap/Navbar';
import 'react-bootstrap/NavDropdown';
import './index.esm-9b042655.js';
import './iconBase-ccc56b97.js';
import './index.esm-eb1e8e80.js';
import './NavFooter-3272e9cd.js';
import './index.esm-07c37a92.js';
import './SocialSearchComponent-165b4ae7.js';
import './SocialIcons.js';
import 'react-bootstrap/Form';
import 'react-bootstrap/FormControl';
import 'react-bootstrap/Button';
import './Search.js';

// Main
var TemplateNormal = function TemplateNormal(props) {
  var config = props.config,
      title = props.title,
      keywords = props.keywords,
      description = props.description,
      website = props.website,
      horizontalAD = props.config.horizontalAD,
      showFilter = props.showFilter,
      filterParams = props.filterParams,
      filters = props.filters,
      defaultFilter = props.defaultFilter,
      showRightAd = props.showRightAd,
      sponsoredFlag = props.sponsoredFlag,
      _props$noTitle = props.noTitle,
      noTitle = _props$noTitle === undefined ? false : _props$noTitle;

  var router = useRouter();

  var _useState = useState(0),
      _useState2 = _slicedToArray(_useState, 2),
      currentPage = _useState2[0],
      setCurrentPage = _useState2[1];

  useEffect(function () {
    router.asPath && router.asPath.split('?').forEach(function (item) {
      if (item.includes('page=')) {
        setCurrentPage(item.split('=')[1]);
      } else {
        setCurrentPage(0);
      }
    });
  }, [router]);
  var navigation = function navigation() {
    switch (config.navComponent) {
      case 'magazine':
        return React__default.createElement(MagazineNav, { logo: website.logo, mobileLogo: website.mobileLogo, dataObject: config.navItems, subNav: config.leftItems, website: website });
      case 'native':
        return React__default.createElement(NavNative, { logo: website.logo, dataObject: config.navItems, subNav: config.leftItems, website: website });
      case 'dvm':
        return React__default.createElement(NavDvm, { logo: website.logo, dataObject: config.navItems, mobileLogo: website.logo, subNav: config.leftItems, website: website });
      case 'hamburgerNav':
        return React__default.createElement(HamMagazine, {
          socialFooterNav: true,
          logo: website.logo,
          dataObject: config.navItems,
          mobileLogo: website.logo,
          subNav: config.leftItems,
          website: website.siteSettingCache,
          showLogin: website.showLogin
        });
      default:
        return React__default.createElement('noNav', null);
    }
  };

  var adTargeting = { desktop: {}, mobile: {} };
  if (horizontalAD.targeting) {
    adTargeting = horizontalAD.targeting;
  }
  if (website.sponsoredAd) {
    website.sponsoredAd['targeting'] = adTargeting;
  }
  if (website.gutterAd) {
    website.gutterAd['targeting'] = adTargeting;
  }
  function layout() {
    switch (config.columns) {
      case '1':
        return React__default.createElement(
          Column1,
          { title: title },
          props.children
        );
      case '2':
        return React__default.createElement(
          Column2,
          { title: title, rightItems: config.rightItems, website: website },
          props.children
        );
      case '3':
        return React__default.createElement(
          Column3,
          {
            title: title,
            leftItems: config.leftItems,
            rightItems: config.rightItems,
            website: website,
            showFilter: showFilter,
            getParams: filterParams,
            filters: filters,
            defaultFilter: defaultFilter,
            showRightAd: showRightAd,
            logo: website.brandLogo },
          props.children
        );
      default:
        return React__default.createElement('noLayout', null);
    }
  }

  return React__default.createElement(
    'section',
    null,
    noTitle ? React__default.createElement(Header, {
      isLiveSite: config.isLiveSite,
      keyword: keywords,
      description: description + ('' + (router && router.query && router.query.page ? '| Page ' + router.query.page : ''))
    }) : React__default.createElement(Header, {
      title: title ? title + ' ' + (currentPage !== 0 ? '| Page ' + currentPage + ' ' : router && router.query && router.query.page ? '| Page ' + router.query.page + ' ' : '') + '| ' + website.title : website.title + ' ' + (currentPage !== 0 ? '| Page ' + currentPage + ' ' : router && router.query && router.query.page ? '| Page ' + router.query.page + ' ' : ''),
      isLiveSite: config.isLiveSite,
      keyword: keywords,
      description: description + ('' + (router && router.query && router.query.page ? '| Page ' + router.query.page : ''))
    }),
    navigation(),
    sponsoredFlag ? React__default.createElement('div', { style: { height: '50px' } }) : React__default.createElement(
      React__default.Fragment,
      null,
      horizontalAD && horizontalAD.networkID && horizontalAD.adUnit && React__default.createElement(
        Container,
        null,
        React__default.createElement(AD728x90, { networkID: horizontalAD.networkID, adUnit: horizontalAD.adUnit, targeting: adTargeting })
      )
    ),
    website.gutterAd && !sponsoredFlag && React__default.createElement(ADGutter, { title: 'gutter-ad', gutterAd: website.gutterAd }),
    React__default.createElement(
      Container,
      null,
      layout()
    )
  );
};

export { TemplateNormal as default };
