import './_commonjsHelpers-0c4b6f40.js';
import './_to-object-cedb5b78.js';
import './es6.string.iterator-1577cb76.js';
import './_library-528f1934.js';
import './_iter-detect-0fa1c752.js';
import './core.get-iterator-method-227107e6.js';
import './_object-pie-33c40e79.js';
import './extends-be71a29a.js';
import './define-property-2f35af22.js';
import './web.dom.iterable-ace8ed30.js';
import React__default, { useState, useEffect } from 'react';
import './events-6c3a7a63.js';
import './index-41a678ea.js';
import 'prop-types';
import Container$1 from 'react-bootstrap/Container';
import 'react-bootstrap/Row';
import 'react-bootstrap/Col';
import { useRouter } from 'next/router';
import './isSymbol-1981418f.js';
import './debounce-89969f66.js';
import './toNumber-e3dcad26.js';
import './main-ae902629.js';
import { _ as _slicedToArray } from './slicedToArray-f0edf3d6.js';
import './stringify-d1b9276a.js';
import './asyncToGenerator-e1a2f43a.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-a7d5c5c7.js';
import 'react-bootstrap';
import './iconBase-602d52fe.js';
import './index.esm-3fdda599.js';
import 'next/head';
import './defineProperty-eb9699c0.js';
import 'react-bootstrap/Form';
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-c6715e80.js';
import './NavFooter-e27bd93b.js';
import './index.esm-ed50151c.js';
import './SocialIcons.js';
import 'react-bootstrap/FormControl';
import './SocialSearchComponent-9cc36413.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__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$1,
        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$1,
      null,
      layout()
    )
  );
};

export default TemplateNormal;
