// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// ReactionEmpty represents TL type `reactionEmpty#79f5d419`.
// No reaction
//
// See https://core.telegram.org/constructor/reactionEmpty for reference.
type ReactionEmpty struct {
}

// ReactionEmptyTypeID is TL type id of ReactionEmpty.
const ReactionEmptyTypeID = 0x79f5d419

// construct implements constructor of ReactionClass.
func ( ReactionEmpty) () ReactionClass { return & }

// Ensuring interfaces in compile-time for ReactionEmpty.
var (
	_ bin.Encoder     = &ReactionEmpty{}
	_ bin.Decoder     = &ReactionEmpty{}
	_ bin.BareEncoder = &ReactionEmpty{}
	_ bin.BareDecoder = &ReactionEmpty{}

	_ ReactionClass = &ReactionEmpty{}
)

func ( *ReactionEmpty) () bool {
	if  == nil {
		return true
	}

	return true
}

// String implements fmt.Stringer.
func ( *ReactionEmpty) () string {
	if  == nil {
		return "ReactionEmpty(nil)"
	}
	type  ReactionEmpty
	return fmt.Sprintf("ReactionEmpty%+v", (*))
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ReactionEmpty) () uint32 {
	return ReactionEmptyTypeID
}

// TypeName returns name of type in TL schema.
func (*ReactionEmpty) () string {
	return "reactionEmpty"
}

// TypeInfo returns info about TL type.
func ( *ReactionEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "reactionEmpty",
		ID:   ReactionEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *ReactionEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reactionEmpty#79f5d419 as nil")
	}
	.PutID(ReactionEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ReactionEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reactionEmpty#79f5d419 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ReactionEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reactionEmpty#79f5d419 to nil")
	}
	if  := .ConsumeID(ReactionEmptyTypeID);  != nil {
		return fmt.Errorf("unable to decode reactionEmpty#79f5d419: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ReactionEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reactionEmpty#79f5d419 to nil")
	}
	return nil
}

// ReactionEmoji represents TL type `reactionEmoji#1b2286b8`.
// Normal emoji message reaction
//
// See https://core.telegram.org/constructor/reactionEmoji for reference.
type ReactionEmoji struct {
	// Emoji
	Emoticon string
}

// ReactionEmojiTypeID is TL type id of ReactionEmoji.
const ReactionEmojiTypeID = 0x1b2286b8

// construct implements constructor of ReactionClass.
func ( ReactionEmoji) () ReactionClass { return & }

// Ensuring interfaces in compile-time for ReactionEmoji.
var (
	_ bin.Encoder     = &ReactionEmoji{}
	_ bin.Decoder     = &ReactionEmoji{}
	_ bin.BareEncoder = &ReactionEmoji{}
	_ bin.BareDecoder = &ReactionEmoji{}

	_ ReactionClass = &ReactionEmoji{}
)

func ( *ReactionEmoji) () bool {
	if  == nil {
		return true
	}
	if !(.Emoticon == "") {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *ReactionEmoji) () string {
	if  == nil {
		return "ReactionEmoji(nil)"
	}
	type  ReactionEmoji
	return fmt.Sprintf("ReactionEmoji%+v", (*))
}

// FillFrom fills ReactionEmoji from given interface.
func ( *ReactionEmoji) ( interface {
	() ( string)
}) {
	.Emoticon = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ReactionEmoji) () uint32 {
	return ReactionEmojiTypeID
}

// TypeName returns name of type in TL schema.
func (*ReactionEmoji) () string {
	return "reactionEmoji"
}

// TypeInfo returns info about TL type.
func ( *ReactionEmoji) () tdp.Type {
	 := tdp.Type{
		Name: "reactionEmoji",
		ID:   ReactionEmojiTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Emoticon",
			SchemaName: "emoticon",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ReactionEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reactionEmoji#1b2286b8 as nil")
	}
	.PutID(ReactionEmojiTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ReactionEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reactionEmoji#1b2286b8 as nil")
	}
	.PutString(.Emoticon)
	return nil
}

// Decode implements bin.Decoder.
func ( *ReactionEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reactionEmoji#1b2286b8 to nil")
	}
	if  := .ConsumeID(ReactionEmojiTypeID);  != nil {
		return fmt.Errorf("unable to decode reactionEmoji#1b2286b8: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ReactionEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reactionEmoji#1b2286b8 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode reactionEmoji#1b2286b8: field emoticon: %w", )
		}
		.Emoticon = 
	}
	return nil
}

// GetEmoticon returns value of Emoticon field.
func ( *ReactionEmoji) () ( string) {
	if  == nil {
		return
	}
	return .Emoticon
}

// ReactionCustomEmoji represents TL type `reactionCustomEmoji#8935fc73`.
// Custom emojiĀ¹ message reaction
//
// Links:
//  1. https://core.telegram.org/api/custom-emoji
//
// See https://core.telegram.org/constructor/reactionCustomEmoji for reference.
type ReactionCustomEmoji struct {
	// Custom emoji document IDĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/custom-emoji
	DocumentID int64
}

// ReactionCustomEmojiTypeID is TL type id of ReactionCustomEmoji.
const ReactionCustomEmojiTypeID = 0x8935fc73

// construct implements constructor of ReactionClass.
func ( ReactionCustomEmoji) () ReactionClass { return & }

// Ensuring interfaces in compile-time for ReactionCustomEmoji.
var (
	_ bin.Encoder     = &ReactionCustomEmoji{}
	_ bin.Decoder     = &ReactionCustomEmoji{}
	_ bin.BareEncoder = &ReactionCustomEmoji{}
	_ bin.BareDecoder = &ReactionCustomEmoji{}

	_ ReactionClass = &ReactionCustomEmoji{}
)

func ( *ReactionCustomEmoji) () bool {
	if  == nil {
		return true
	}
	if !(.DocumentID == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *ReactionCustomEmoji) () string {
	if  == nil {
		return "ReactionCustomEmoji(nil)"
	}
	type  ReactionCustomEmoji
	return fmt.Sprintf("ReactionCustomEmoji%+v", (*))
}

// FillFrom fills ReactionCustomEmoji from given interface.
func ( *ReactionCustomEmoji) ( interface {
	() ( int64)
}) {
	.DocumentID = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ReactionCustomEmoji) () uint32 {
	return ReactionCustomEmojiTypeID
}

// TypeName returns name of type in TL schema.
func (*ReactionCustomEmoji) () string {
	return "reactionCustomEmoji"
}

// TypeInfo returns info about TL type.
func ( *ReactionCustomEmoji) () tdp.Type {
	 := tdp.Type{
		Name: "reactionCustomEmoji",
		ID:   ReactionCustomEmojiTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "DocumentID",
			SchemaName: "document_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ReactionCustomEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reactionCustomEmoji#8935fc73 as nil")
	}
	.PutID(ReactionCustomEmojiTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ReactionCustomEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reactionCustomEmoji#8935fc73 as nil")
	}
	.PutLong(.DocumentID)
	return nil
}

// Decode implements bin.Decoder.
func ( *ReactionCustomEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reactionCustomEmoji#8935fc73 to nil")
	}
	if  := .ConsumeID(ReactionCustomEmojiTypeID);  != nil {
		return fmt.Errorf("unable to decode reactionCustomEmoji#8935fc73: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ReactionCustomEmoji) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reactionCustomEmoji#8935fc73 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode reactionCustomEmoji#8935fc73: field document_id: %w", )
		}
		.DocumentID = 
	}
	return nil
}

// GetDocumentID returns value of DocumentID field.
func ( *ReactionCustomEmoji) () ( int64) {
	if  == nil {
		return
	}
	return .DocumentID
}

// ReactionClassName is schema name of ReactionClass.
const ReactionClassName = "Reaction"

// ReactionClass represents Reaction generic type.
//
// See https://core.telegram.org/type/Reaction for reference.
//
// Example:
//
//	g, err := tg.DecodeReaction(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.ReactionEmpty: // reactionEmpty#79f5d419
//	case *tg.ReactionEmoji: // reactionEmoji#1b2286b8
//	case *tg.ReactionCustomEmoji: // reactionCustomEmoji#8935fc73
//	default: panic(v)
//	}
type ReactionClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ReactionClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodeReaction implements binary de-serialization for ReactionClass.
func ( *bin.Buffer) (ReactionClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case ReactionEmptyTypeID:
		// Decoding reactionEmpty#79f5d419.
		 := ReactionEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ReactionClass: %w", )
		}
		return &, nil
	case ReactionEmojiTypeID:
		// Decoding reactionEmoji#1b2286b8.
		 := ReactionEmoji{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ReactionClass: %w", )
		}
		return &, nil
	case ReactionCustomEmojiTypeID:
		// Decoding reactionCustomEmoji#8935fc73.
		 := ReactionCustomEmoji{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ReactionClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode ReactionClass: %w", bin.NewUnexpectedID())
	}
}

// Reaction boxes the ReactionClass providing a helper.
type ReactionBox struct {
	Reaction ReactionClass
}

// Decode implements bin.Decoder for ReactionBox.
func ( *ReactionBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode ReactionBox to nil")
	}
	,  := DecodeReaction()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.Reaction = 
	return nil
}

// Encode implements bin.Encode for ReactionBox.
func ( *ReactionBox) ( *bin.Buffer) error {
	if  == nil || .Reaction == nil {
		return fmt.Errorf("unable to encode ReactionClass as nil")
	}
	return .Reaction.Encode()
}