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