import './_commonjsHelpers-0c4b6f40.js';
import './_to-object-a4107da3.js';
import './es6.string.iterator-c990c18c.js';
import './_library-528f1934.js';
import './_iter-detect-5d49a330.js';
import './core.get-iterator-method-e1de7503.js';
import './_object-pie-33c40e79.js';
import './extends-eb69e8ac.js';
import './define-property-8af5f002.js';
import './web.dom.iterable-4439f05a.js';
import React__default, { useState, useEffect } from 'react';
import './index-a9e53f80.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-e4a934b2.js';
import { _ as _slicedToArray } from './slicedToArray-641f241f.js';
import './stringify-4330ccdc.js';
import './asyncToGenerator-502f13b4.js';
import './_set-species-3f8319f5.js';
import './Segment.js';
import './Beam.js';
import './AdSlot.js';
import './get-5ee14cda.js';
import './react-social-icons-a7d5c5c7.js';
import 'react-bootstrap';
import './iconBase-602d52fe.js';
import './index.esm-29e48d38.js';
import 'next/head';
import 'react-bootstrap/Button';
import './defineProperty-94fd8bfc.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-b08f4b04.js';
import './NavFooter-e27bd93b.js';
import './index.esm-fd746768.js';
import './SocialIcons.js';
import 'react-bootstrap/FormControl';
import './SocialSearchComponent-a2ae84d1.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;
