State TV reports Egypt's first democratically elected president fainted during court session and died afterwards.