Hamiltonian analysis of electron self-injection and acceleration into an evolving plasma bubble