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

// ChatReactionsNone represents TL type `chatReactionsNone#eafc32bc`.
// No reactions are allowed
//
// See https://core.telegram.org/constructor/chatReactionsNone for reference.
type ChatReactionsNone struct {
}

// ChatReactionsNoneTypeID is TL type id of ChatReactionsNone.
const ChatReactionsNoneTypeID = 0xeafc32bc

// construct implements constructor of ChatReactionsClass.
func ( ChatReactionsNone) () ChatReactionsClass { return & }

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

	_ ChatReactionsClass = &ChatReactionsNone{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *ChatReactionsNone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatReactionsNone#eafc32bc as nil")
	}
	.PutID(ChatReactionsNoneTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatReactionsNone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatReactionsNone#eafc32bc as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChatReactionsNone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatReactionsNone#eafc32bc to nil")
	}
	return nil
}

// ChatReactionsAll represents TL type `chatReactionsAll#52928bca`.
// All reactions or all non-custom reactions are allowed
//
// See https://core.telegram.org/constructor/chatReactionsAll for reference.
type ChatReactionsAll struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to allow custom reactions
	AllowCustom bool
}

// ChatReactionsAllTypeID is TL type id of ChatReactionsAll.
const ChatReactionsAllTypeID = 0x52928bca

// construct implements constructor of ChatReactionsClass.
func ( ChatReactionsAll) () ChatReactionsClass { return & }

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

	_ ChatReactionsClass = &ChatReactionsAll{}
)

func ( *ChatReactionsAll) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.AllowCustom == false) {
		return false
	}

	return true
}

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

// FillFrom fills ChatReactionsAll from given interface.
func ( *ChatReactionsAll) ( interface {
	() ( bool)
}) {
	.AllowCustom = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatReactionsAll) () tdp.Type {
	 := tdp.Type{
		Name: "chatReactionsAll",
		ID:   ChatReactionsAllTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "AllowCustom",
			SchemaName: "allow_custom",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChatReactionsAll) () {
	if !(.AllowCustom == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *ChatReactionsAll) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatReactionsAll#52928bca as nil")
	}
	.PutID(ChatReactionsAllTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatReactionsAll) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatReactionsAll#52928bca as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode chatReactionsAll#52928bca: field flags: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ChatReactionsAll) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatReactionsAll#52928bca to nil")
	}
	if  := .ConsumeID(ChatReactionsAllTypeID);  != nil {
		return fmt.Errorf("unable to decode chatReactionsAll#52928bca: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChatReactionsAll) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatReactionsAll#52928bca to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode chatReactionsAll#52928bca: field flags: %w", )
		}
	}
	.AllowCustom = .Flags.Has(0)
	return nil
}

// SetAllowCustom sets value of AllowCustom conditional field.
func ( *ChatReactionsAll) ( bool) {
	if  {
		.Flags.Set(0)
		.AllowCustom = true
	} else {
		.Flags.Unset(0)
		.AllowCustom = false
	}
}

// GetAllowCustom returns value of AllowCustom conditional field.
func ( *ChatReactionsAll) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// ChatReactionsSome represents TL type `chatReactionsSome#661d4037`.
// Some reactions are allowed
//
// See https://core.telegram.org/constructor/chatReactionsSome for reference.
type ChatReactionsSome struct {
	// Allowed set of reactions: the reactions_in_chat_max¹ configuration field indicates
	// the maximum number of reactions that can be specified in this field.
	//
	// Links:
	//  1) https://core.telegram.org/api/config#reactions-in-chat-max
	Reactions []ReactionClass
}

// ChatReactionsSomeTypeID is TL type id of ChatReactionsSome.
const ChatReactionsSomeTypeID = 0x661d4037

// construct implements constructor of ChatReactionsClass.
func ( ChatReactionsSome) () ChatReactionsClass { return & }

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

	_ ChatReactionsClass = &ChatReactionsSome{}
)

func ( *ChatReactionsSome) () bool {
	if  == nil {
		return true
	}
	if !(.Reactions == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ChatReactionsSome from given interface.
func ( *ChatReactionsSome) ( interface {
	() ( []ReactionClass)
}) {
	.Reactions = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChatReactionsSome) () tdp.Type {
	 := tdp.Type{
		Name: "chatReactionsSome",
		ID:   ChatReactionsSomeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Reactions",
			SchemaName: "reactions",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChatReactionsSome) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatReactionsSome#661d4037 as nil")
	}
	.PutID(ChatReactionsSomeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatReactionsSome) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatReactionsSome#661d4037 as nil")
	}
	.PutVectorHeader(len(.Reactions))
	for ,  := range .Reactions {
		if  == nil {
			return fmt.Errorf("unable to encode chatReactionsSome#661d4037: field reactions element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode chatReactionsSome#661d4037: field reactions element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ChatReactionsSome) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatReactionsSome#661d4037 to nil")
	}
	if  := .ConsumeID(ChatReactionsSomeTypeID);  != nil {
		return fmt.Errorf("unable to decode chatReactionsSome#661d4037: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChatReactionsSome) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatReactionsSome#661d4037 to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode chatReactionsSome#661d4037: field reactions: %w", )
		}

		if  > 0 {
			.Reactions = make([]ReactionClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeReaction()
			if  != nil {
				return fmt.Errorf("unable to decode chatReactionsSome#661d4037: field reactions: %w", )
			}
			.Reactions = append(.Reactions, )
		}
	}
	return nil
}

// GetReactions returns value of Reactions field.
func ( *ChatReactionsSome) () ( []ReactionClass) {
	if  == nil {
		return
	}
	return .Reactions
}

// MapReactions returns field Reactions wrapped in ReactionClassArray helper.
func ( *ChatReactionsSome) () ( ReactionClassArray) {
	return ReactionClassArray(.Reactions)
}

// ChatReactionsClassName is schema name of ChatReactionsClass.
const ChatReactionsClassName = "ChatReactions"

// ChatReactionsClass represents ChatReactions generic type.
//
// See https://core.telegram.org/type/ChatReactions for reference.
//
// Example:
//
//	g, err := tg.DecodeChatReactions(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.ChatReactionsNone: // chatReactionsNone#eafc32bc
//	case *tg.ChatReactionsAll: // chatReactionsAll#52928bca
//	case *tg.ChatReactionsSome: // chatReactionsSome#661d4037
//	default: panic(v)
//	}
type ChatReactionsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ChatReactionsClass

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

// DecodeChatReactions implements binary de-serialization for ChatReactionsClass.
func ( *bin.Buffer) (ChatReactionsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case ChatReactionsNoneTypeID:
		// Decoding chatReactionsNone#eafc32bc.
		 := ChatReactionsNone{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatReactionsClass: %w", )
		}
		return &, nil
	case ChatReactionsAllTypeID:
		// Decoding chatReactionsAll#52928bca.
		 := ChatReactionsAll{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatReactionsClass: %w", )
		}
		return &, nil
	case ChatReactionsSomeTypeID:
		// Decoding chatReactionsSome#661d4037.
		 := ChatReactionsSome{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ChatReactionsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode ChatReactionsClass: %w", bin.NewUnexpectedID())
	}
}

// ChatReactions boxes the ChatReactionsClass providing a helper.
type ChatReactionsBox struct {
	ChatReactions ChatReactionsClass
}

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

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