import './_commonjsHelpers-0c4b6f40.js';
import './_to-object-ded78eb9.js';
import './es6.string.iterator-9b2af4a5.js';
import './_library-528f1934.js';
import './_iter-detect-59409a32.js';
import './core.get-iterator-method-54d2e411.js';
import './define-property-de3fc946.js';
import './web.dom.iterable-8956f9a5.js';
import React__default, { useState, useEffect } from 'react';
import './index-0e45a0b2.js';
import 'prop-types';
import Container from 'react-bootstrap/Container';
import 'react-bootstrap/Row';
import 'react-bootstrap/Col';
import { useRouter } from 'next/router';
import './isSymbol-807e927e.js';
import './debounce-1a993acf.js';
import './main-5d1e4bd3.js';
import './stringify-008c8802.js';
import { _ as _slicedToArray } from './slicedToArray-7021e5df.js';
import './asyncToGenerator-7c654f36.js';
import './_set-species-cede29f8.js';
import './beam-681a9749.js';
import './AdSlot.js';
import './get-5ee14cda.js';
import './react-social-icons-a7d5c5c7.js';
import 'react-bootstrap';
import './iconBase-602d52fe.js';
import './index.esm-85cb09e6.js';
import 'react-bootstrap/Button';
import './defineProperty-b798470d.js';
import 'react-bootstrap/Form';
import 'next/head';
import { Column1 } from './Column1.js';
import './SideFooter.js';
import './ConferenceBanner-8792ebd2.js';
import { Column2 } from './Column2.js';
import './ADSponsoredResources.js';
import 'react-bootstrap/ListGroup';
import './ADWebcast.js';
import './LeftNav.js';
import './PageFilter.js';
import { Column3 } from './Column3.js';
import Header from './Header.js';
import 'react-bootstrap/Nav';
import 'react-bootstrap/Navbar';
import 'react-bootstrap/NavDropdown';
import './index.esm-b08f4b04.js';
import './NavFooter-e27bd93b.js';
import './index.esm-73e847d2.js';
import './SocialIcons.js';
import 'react-bootstrap/FormControl';
import './SocialSearchComponent-55960ec4.js';
import MagazineNav from './NavMagazine.js';
import { NavNative } from './NavNative.js';
import './Search.js';
import { NavNormal } from './NavNormal.js';
import { NavDvm } from './NavDvm.js';
import { HamMagazine } from './HamMagazine.js';
import ADGutter from './ADGutter.js';
import AD728x90 from './AD728x90.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 'normal':
        return React__default.createElement(NavNormal, { logo: website.logo, dataObject: config.navItems });
      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 default TemplateNormal;
