// 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{}
)

// MessageReactions represents TL type `messageReactions#4f2b9479`.
// Message reactions »¹
//
// Links:
//  1. https://core.telegram.org/api/reactions
//
// See https://core.telegram.org/constructor/messageReactions for reference.
type MessageReactions struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Similar to min¹ objects, used for message reaction »² constructors that are the
	// same for all users so they don't have the reactions sent by the current user (you can
	// use messages.getMessagesReactions³ to get the full reaction info).
	//
	// Links:
	//  1) https://core.telegram.org/api/min
	//  2) https://core.telegram.org/api/reactions
	//  3) https://core.telegram.org/method/messages.getMessagesReactions
	Min bool
	// Whether messages.getMessageReactionsList¹ can be used to see how each specific peer
	// reacted to the message
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.getMessageReactionsList
	CanSeeList bool
	// Reactions
	Results []ReactionCount
	// List of recent peers and their reactions
	//
	// Use SetRecentReactions and GetRecentReactions helpers.
	RecentReactions []MessagePeerReaction
}

// MessageReactionsTypeID is TL type id of MessageReactions.
const MessageReactionsTypeID = 0x4f2b9479

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

func ( *MessageReactions) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Min == false) {
		return false
	}
	if !(.CanSeeList == false) {
		return false
	}
	if !(.Results == nil) {
		return false
	}
	if !(.RecentReactions == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessageReactions from given interface.
func ( *MessageReactions) ( interface {
	() ( bool)
	() ( bool)
	() ( []ReactionCount)
	() ( []MessagePeerReaction,  bool)
}) {
	.Min = .()
	.CanSeeList = .()
	.Results = .()
	if ,  := .();  {
		.RecentReactions = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessageReactions) () tdp.Type {
	 := tdp.Type{
		Name: "messageReactions",
		ID:   MessageReactionsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Min",
			SchemaName: "min",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "CanSeeList",
			SchemaName: "can_see_list",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Results",
			SchemaName: "results",
		},
		{
			Name:       "RecentReactions",
			SchemaName: "recent_reactions",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessageReactions) () {
	if !(.Min == false) {
		.Flags.Set(0)
	}
	if !(.CanSeeList == false) {
		.Flags.Set(2)
	}
	if !(.RecentReactions == nil) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *MessageReactions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messageReactions#4f2b9479 as nil")
	}
	.PutID(MessageReactionsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessageReactions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messageReactions#4f2b9479 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messageReactions#4f2b9479: field flags: %w", )
	}
	.PutVectorHeader(len(.Results))
	for ,  := range .Results {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messageReactions#4f2b9479: field results element with index %d: %w", , )
		}
	}
	if .Flags.Has(1) {
		.PutVectorHeader(len(.RecentReactions))
		for ,  := range .RecentReactions {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode messageReactions#4f2b9479: field recent_reactions element with index %d: %w", , )
			}
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessageReactions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messageReactions#4f2b9479 to nil")
	}
	if  := .ConsumeID(MessageReactionsTypeID);  != nil {
		return fmt.Errorf("unable to decode messageReactions#4f2b9479: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessageReactions) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messageReactions#4f2b9479 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messageReactions#4f2b9479: field flags: %w", )
		}
	}
	.Min = .Flags.Has(0)
	.CanSeeList = .Flags.Has(2)
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messageReactions#4f2b9479: field results: %w", )
		}

		if  > 0 {
			.Results = make([]ReactionCount, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  ReactionCount
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode messageReactions#4f2b9479: field results: %w", )
			}
			.Results = append(.Results, )
		}
	}
	if .Flags.Has(1) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messageReactions#4f2b9479: field recent_reactions: %w", )
		}

		if  > 0 {
			.RecentReactions = make([]MessagePeerReaction, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  MessagePeerReaction
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode messageReactions#4f2b9479: field recent_reactions: %w", )
			}
			.RecentReactions = append(.RecentReactions, )
		}
	}
	return nil
}

// SetMin sets value of Min conditional field.
func ( *MessageReactions) ( bool) {
	if  {
		.Flags.Set(0)
		.Min = true
	} else {
		.Flags.Unset(0)
		.Min = false
	}
}

// GetMin returns value of Min conditional field.
func ( *MessageReactions) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetCanSeeList sets value of CanSeeList conditional field.
func ( *MessageReactions) ( bool) {
	if  {
		.Flags.Set(2)
		.CanSeeList = true
	} else {
		.Flags.Unset(2)
		.CanSeeList = false
	}
}

// GetCanSeeList returns value of CanSeeList conditional field.
func ( *MessageReactions) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetResults returns value of Results field.
func ( *MessageReactions) () ( []ReactionCount) {
	if  == nil {
		return
	}
	return .Results
}

// SetRecentReactions sets value of RecentReactions conditional field.
func ( *MessageReactions) ( []MessagePeerReaction) {
	.Flags.Set(1)
	.RecentReactions = 
}

// GetRecentReactions returns value of RecentReactions conditional field and
// boolean which is true if field was set.
func ( *MessageReactions) () ( []MessagePeerReaction,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .RecentReactions, true
}