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