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