Panama has established diplomatic ties with China and broken with Taiwan in a major victory for Beijing.