package constant

const (
	// MaxTDLibChatID is maximum chat TDLib ID.
	MaxTDLibChatID = 999999999999
	// MaxTDLibChannelID is maximum channel TDLib ID.
	MaxTDLibChannelID = 1000000000000 - int64(1<<31)
	// ZeroTDLibChannelID is minimum channel TDLib ID.
	ZeroTDLibChannelID = -1000000000000
	// ZeroTDLibSecretChatID is minimum secret chat TDLib ID.
	ZeroTDLibSecretChatID = -2000000000000
	// MaxTDLibUserID is maximum user TDLib ID.
	MaxTDLibUserID = (1 << 40) - 1
)

// TDLibPeerID is TDLib's peer ID.
type TDLibPeerID int64

// User sets TDLibPeerID value as user.
func ( *TDLibPeerID) ( int64) {
	* = TDLibPeerID()
}

// Chat sets TDLibPeerID value as chat.
func ( *TDLibPeerID) ( int64) {
	* = TDLibPeerID(-)
}

// Channel sets TDLibPeerID value as channel.
func ( *TDLibPeerID) ( int64) {
	* = TDLibPeerID(ZeroTDLibChannelID + ( * -1))
}

// ToPlain converts TDLib ID to plain ID.
func ( TDLibPeerID) () ( int64) {
	switch {
	case .IsUser():
		 = int64()
	case .IsChat():
		 = int64(-)
	case .IsChannel():
		 = int64() - ZeroTDLibChannelID
		 = -
	}
	return 
}

// IsUser whether that given ID is user ID.
func ( TDLibPeerID) () bool {
	return  > 0 &&  <= MaxTDLibUserID
}

// IsChat whether that given ID is chat ID.
func ( TDLibPeerID) () bool {
	return  < 0 && -MaxTDLibChatID <= 
}

// IsChannel whether that given ID is channel ID.
func ( TDLibPeerID) () bool {
	return  < 0 &&
		 != ZeroTDLibChannelID &&
		!.IsChat() &&
		ZeroTDLibChannelID-TDLibPeerID(MaxTDLibChannelID) <= 
}