import './_commonjsHelpers-0c4b6f40.js';
import './core.get-iterator-method-86d4db69.js';
import './_library-528f1934.js';
import './_iter-detect-130ee549.js';
import './_object-pie-33c40e79.js';
import './extends-a4230287.js';
import './define-property-6d26cb48.js';
import './web.dom.iterable-f8f967cd.js';
import React, { useState, useEffect } from 'react';
import './index-1819118a.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-1981418f.js';
import './debounce-9207d8ee.js';
import './toNumber-2f7a84cd.js';
import { _ as _slicedToArray } from './slicedToArray-67a08c9c.js';
import './main-43ca42fe.js';
import './stringify-70b72959.js';
import './asyncToGenerator-64812e90.js';
import './Segment.js';
import './Beam.js';
import './AdSlot.js';
import './get-1e515072.js';
import './eq-b470f743.js';
import 'react-bootstrap/Button';
import './react-social-icons-3822f1ce.js';
import 'react-bootstrap';
import './iconBase-602d52fe.js';
import './index.esm-55f22b35.js';
import 'react-bootstrap/Form';
import 'next/head';
import './defineProperty-d7d9b577.js';
import { Column1 } from './Column1.js';
import './SideFooter.js';
import './ConferenceBanner-9162d0ca.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-c6715e80.js';
import './NavFooter-c29526b7.js';
import './index.esm-8ee5ff72.js';
import './SocialIcons.js';
import 'react-bootstrap/FormControl';
import './SocialSearchComponent-32ee0f63.js';
import MagazineNav from './NavMagazine.js';
import { NavNative } from './NavNative.js';
import './Search.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 'magazine':
        return React.createElement(MagazineNav, { logo: website.logo, mobileLogo: website.mobileLogo, dataObject: config.navItems, subNav: config.leftItems, website: website });
      case 'native':
        return React.createElement(NavNative, { logo: website.logo, dataObject: config.navItems, subNav: config.leftItems, website: website });
      case 'dvm':
        return React.createElement(NavDvm, { logo: website.logo, dataObject: config.navItems, mobileLogo: website.logo, subNav: config.leftItems, website: website });
      case 'hamburgerNav':
        return React.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.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.createElement(
          Column1,
          { title: title },
          props.children
        );
      case '2':
        return React.createElement(
          Column2,
          { title: title, rightItems: config.rightItems, website: website },
          props.children
        );
      case '3':
        return React.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.createElement('noLayout', null);
    }
  }

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

export default TemplateNormal;
