What republics did the Spanish kingdom come before?