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