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