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

// StoriesStoryReactionsList represents TL type `stories.storyReactionsList#aa5f789c`.
//
// See https://core.telegram.org/constructor/stories.storyReactionsList for reference.
type StoriesStoryReactionsList struct {
	// Flags field of StoriesStoryReactionsList.
	Flags bin.Fields
	// Count field of StoriesStoryReactionsList.
	Count int
	// Reactions field of StoriesStoryReactionsList.
	Reactions []StoryReactionClass
	// Chats field of StoriesStoryReactionsList.
	Chats []ChatClass
	// Users field of StoriesStoryReactionsList.
	Users []UserClass
	// NextOffset field of StoriesStoryReactionsList.
	//
	// Use SetNextOffset and GetNextOffset helpers.
	NextOffset string
}

// StoriesStoryReactionsListTypeID is TL type id of StoriesStoryReactionsList.
const StoriesStoryReactionsListTypeID = 0xaa5f789c

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

func ( *StoriesStoryReactionsList) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Count == 0) {
		return false
	}
	if !(.Reactions == nil) {
		return false
	}
	if !(.Chats == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}
	if !(.NextOffset == "") {
		return false
	}

	return true
}

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

// FillFrom fills StoriesStoryReactionsList from given interface.
func ( *StoriesStoryReactionsList) ( interface {
	() ( int)
	() ( []StoryReactionClass)
	() ( []ChatClass)
	() ( []UserClass)
	() ( string,  bool)
}) {
	.Count = .()
	.Reactions = .()
	.Chats = .()
	.Users = .()
	if ,  := .();  {
		.NextOffset = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*StoriesStoryReactionsList) () string {
	return "stories.storyReactionsList"
}

// TypeInfo returns info about TL type.
func ( *StoriesStoryReactionsList) () tdp.Type {
	 := tdp.Type{
		Name: "stories.storyReactionsList",
		ID:   StoriesStoryReactionsListTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Count",
			SchemaName: "count",
		},
		{
			Name:       "Reactions",
			SchemaName: "reactions",
		},
		{
			Name:       "Chats",
			SchemaName: "chats",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
		{
			Name:       "NextOffset",
			SchemaName: "next_offset",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StoriesStoryReactionsList) () {
	if !(.NextOffset == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *StoriesStoryReactionsList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.storyReactionsList#aa5f789c as nil")
	}
	.PutID(StoriesStoryReactionsListTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StoriesStoryReactionsList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stories.storyReactionsList#aa5f789c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode stories.storyReactionsList#aa5f789c: field flags: %w", )
	}
	.PutInt(.Count)
	.PutVectorHeader(len(.Reactions))
	for ,  := range .Reactions {
		if  == nil {
			return fmt.Errorf("unable to encode stories.storyReactionsList#aa5f789c: field reactions element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stories.storyReactionsList#aa5f789c: field reactions element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Chats))
	for ,  := range .Chats {
		if  == nil {
			return fmt.Errorf("unable to encode stories.storyReactionsList#aa5f789c: field chats element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stories.storyReactionsList#aa5f789c: field chats element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode stories.storyReactionsList#aa5f789c: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode stories.storyReactionsList#aa5f789c: field users element with index %d: %w", , )
		}
	}
	if .Flags.Has(0) {
		.PutString(.NextOffset)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StoriesStoryReactionsList) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stories.storyReactionsList#aa5f789c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode stories.storyReactionsList#aa5f789c: field flags: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stories.storyReactionsList#aa5f789c: field count: %w", )
		}
		.Count = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.storyReactionsList#aa5f789c: field reactions: %w", )
		}

		if  > 0 {
			.Reactions = make([]StoryReactionClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeStoryReaction()
			if  != nil {
				return fmt.Errorf("unable to decode stories.storyReactionsList#aa5f789c: field reactions: %w", )
			}
			.Reactions = append(.Reactions, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.storyReactionsList#aa5f789c: field chats: %w", )
		}

		if  > 0 {
			.Chats = make([]ChatClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeChat()
			if  != nil {
				return fmt.Errorf("unable to decode stories.storyReactionsList#aa5f789c: field chats: %w", )
			}
			.Chats = append(.Chats, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode stories.storyReactionsList#aa5f789c: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode stories.storyReactionsList#aa5f789c: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode stories.storyReactionsList#aa5f789c: field next_offset: %w", )
		}
		.NextOffset = 
	}
	return nil
}

// GetCount returns value of Count field.
func ( *StoriesStoryReactionsList) () ( int) {
	if  == nil {
		return
	}
	return .Count
}

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

// GetChats returns value of Chats field.
func ( *StoriesStoryReactionsList) () ( []ChatClass) {
	if  == nil {
		return
	}
	return .Chats
}

// GetUsers returns value of Users field.
func ( *StoriesStoryReactionsList) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// SetNextOffset sets value of NextOffset conditional field.
func ( *StoriesStoryReactionsList) ( string) {
	.Flags.Set(0)
	.NextOffset = 
}

// GetNextOffset returns value of NextOffset conditional field and
// boolean which is true if field was set.
func ( *StoriesStoryReactionsList) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .NextOffset, true
}

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

// MapChats returns field Chats wrapped in ChatClassArray helper.
func ( *StoriesStoryReactionsList) () ( ChatClassArray) {
	return ChatClassArray(.Chats)
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *StoriesStoryReactionsList) () ( UserClassArray) {
	return UserClassArray(.Users)
}