( function( window, document ) {
  function seo_enterprise_keepFocusInMenu() {
    document.addEventListener( 'keydown', function( e ) {
      const seo_enterprise_nav = document.querySelector( '.sidenav' );
      if ( ! seo_enterprise_nav || ! seo_enterprise_nav.classList.contains( 'open' ) ) {
        return;
      }
      const elements = [...seo_enterprise_nav.querySelectorAll( 'input, a, button' )],
        seo_enterprise_lastEl = elements[ elements.length - 1 ],
        seo_enterprise_firstEl = elements[0],
        seo_enterprise_activeEl = document.activeElement,
        tabKey = e.keyCode === 9,
        shiftKey = e.shiftKey;
      if ( ! shiftKey && tabKey && seo_enterprise_lastEl === seo_enterprise_activeEl ) {
        e.preventDefault();
        seo_enterprise_firstEl.focus();
      }
      if ( shiftKey && tabKey && seo_enterprise_firstEl === seo_enterprise_activeEl ) {
        e.preventDefault();
        seo_enterprise_lastEl.focus();
      }
    } );
  }
  seo_enterprise_keepFocusInMenu();
} )( window, document );