import React, { useRef, useEffect } from 'react';
import Container from 'react-bootstrap/Container';
import Nav from 'react-bootstrap/Nav';
import Navbar from 'react-bootstrap/Navbar';
import NavDropdown from 'react-bootstrap/NavDropdown';
import { M as MdEmail, a as MdMouse } from './index.esm-d6f88d94.js';
import Search from './Search.js';
import Segment from './Segment.js';
import './iconBase-602d52fe.js';
import './slicedToArray-be2f7a22.js';
import './_commonjsHelpers-0c4b6f40.js';
import './web.dom.iterable-4109ff68.js';
import './es6.string.iterator-bc33758b.js';
import './_to-object-b50e61c3.js';
import './core.get-iterator-method-133dfacd.js';
import 'react-bootstrap/Form';
import 'react-bootstrap/FormControl';
import 'react-bootstrap/Button';
import './asyncToGenerator-7f8f9219.js';
import './_library-528f1934.js';
import './_iter-detect-7e5e5ce2.js';

var NavNormal = function NavNormal(props) {
  var logo = props.logo,
      dataObject = props.dataObject,
      _props$website = props.website,
      website = _props$website === undefined ? {} : _props$website;


  var ref = useRef(null);

  useEffect(function () {

    setTimeout(function () {
      var segmentLinks = ref.current.querySelectorAll('a[needsegmentsupport="true"]');
      for (var i = 0; i < segmentLinks.length; i++) {
        var link = segmentLinks[i];
        var href = link.getAttribute('href');
        var newHref = Segment.getURL(href, { needSegmentSupport: true });
        link.setAttribute('href', newHref);
      }
    }, 1000);
  }, []);

  return React.createElement(
    'section',
    { ref: ref },
    React.createElement(
      Navbar,
      { expand: 'lg' },
      React.createElement(
        Container,
        null,
        React.createElement('img', { src: logo, style: { height: '50px' }, alt: website.title ? website.title : website.name ? website.name : 'Website Logo' }),
        React.createElement(
          'div',
          null,
          React.createElement(MdEmail, null),
          ' Subscribe',
          React.createElement('br', null),
          React.createElement(MdMouse, null),
          ' Login'
        )
      )
    ),
    React.createElement(
      Navbar,
      { variant: 'dark', expand: 'lg', bg: 'primary' },
      React.createElement(
        Container,
        null,
        React.createElement(Navbar.Toggle, { 'aria-controls': 'basic-navbar-nav' }),
        React.createElement(
          Navbar.Collapse,
          { id: 'basic-navbar-nav' },
          React.createElement(
            Nav,
            { className: 'mr-auto' },
            dataObject && dataObject.map(function (row) {
              if (row.type === 'dropdown') {
                return React.createElement(
                  NavDropdown,
                  { title: row.name, id: 'basic-nav-dropdown', renderMenuOnMount: true },
                  row.dropdown && row.dropdown.map(function (ddRow, ddItems) {
                    if (ddRow.type === 'divider') {
                      return React.createElement(NavDropdown.Divider, null);
                    } else {
                      return React.createElement(
                        NavDropdown.Item,
                        { href: ddRow.url, needsegmentsupport: ddRow.needSegmentSupport ? 'true' : '', target: ddRow.blank ? '_blank' : '_self' },
                        ddRow.name
                      );
                    }
                  })
                );
              } else {
                // Link default
                return React.createElement(
                  Nav.Link,
                  { href: row.url, needsegmentsupport: row.needSegmentSupport ? 'true' : '', target: row.blank ? '_blank' : '_self' },
                  row.name
                );
              }
            })
          )
        ),
        React.createElement(Search, null)
      )
    ),
    React.createElement(
      'style',
      { jsx: 'true' },
      '\n        @media screen and (max-width: 991px) {\n          .dropdown-menu {\n            max-height: 315px;\n            overflow: auto;\n          }\n          ::-webkit-scrollbar {\n            width: 10px;\n          }\n          ::-webkit-scrollbar-thumb {\n            border-radius: 4px;\n            background-color: rgba(214, 214, 214, 0.8);\n            box-shadow: 0 0 1px rgba(255, 255, 255, 0.5);\n            -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, 0.5);\n          }\n        }\n      '
    )
  );
};

export default NavNormal;
export { NavNormal };
