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