function decode($0, $1, $2) {
  if ($1) {
    // Escape.
    return $1
  }

  // Reference.
  const head = $2.charCodeAt(0)

  if (head === codes.numberSign) {
    const head = $2.charCodeAt(1)
    const hex = head === codes.lowercaseX || head === codes.uppercaseX
    return decodeNumericCharacterReference(
      $2.slice(hex ? 2 : 1),
      hex ? constants.numericBaseHexadecimal : constants.numericBaseDecimal
    )
  }

  return decodeNamedCharacterReference($2) || $0
}
@param {string} $0
  Match.
@param {string} $1
  Character escape.
@param {string} $2
  Character reference.
@returns {string}
  Decoded value