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

// AttachMenuBotIcon represents TL type `attachMenuBotIcon#b2a7386b`.
// Represents an attachment menu icon for bot mini apps »¹
//
// Links:
//  1. https://core.telegram.org/api/bots/attach
//
// See https://core.telegram.org/constructor/attachMenuBotIcon for reference.
type AttachMenuBotIcon struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// One of the following values: note that animated icons must be played when the user
	// clicks on the button, activating the bot mini app. default_static - Default attachment
	// menu icon in SVG format placeholder_static - Default placeholder for opened Web Apps
	// in SVG format ios_static - Attachment menu icon in SVG format for the official iOS app
	// ios_animated - Animated attachment menu icon in TGS format for the official iOS app
	// android_animated - Animated attachment menu icon in TGS format for the official
	// Android app macos_animated - Animated attachment menu icon in TGS format for the
	// official native Mac OS app ios_side_menu_static - Side menu icon in PNG format for the
	// official iOS app android_side_menu_static - Side menu icon in SVG format for the
	// official android app macos_side_menu_static - Side menu icon in PNG format for the
	// official native Mac OS app
	Name string
	// The actual icon file.
	Icon DocumentClass
	// Attachment menu icon colors.
	//
	// Use SetColors and GetColors helpers.
	Colors []AttachMenuBotIconColor
}

// AttachMenuBotIconTypeID is TL type id of AttachMenuBotIcon.
const AttachMenuBotIconTypeID = 0xb2a7386b

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

func ( *AttachMenuBotIcon) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Name == "") {
		return false
	}
	if !(.Icon == nil) {
		return false
	}
	if !(.Colors == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AttachMenuBotIcon from given interface.
func ( *AttachMenuBotIcon) ( interface {
	() ( string)
	() ( DocumentClass)
	() ( []AttachMenuBotIconColor,  bool)
}) {
	.Name = .()
	.Icon = .()
	if ,  := .();  {
		.Colors = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *AttachMenuBotIcon) () tdp.Type {
	 := tdp.Type{
		Name: "attachMenuBotIcon",
		ID:   AttachMenuBotIconTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Name",
			SchemaName: "name",
		},
		{
			Name:       "Icon",
			SchemaName: "icon",
		},
		{
			Name:       "Colors",
			SchemaName: "colors",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AttachMenuBotIcon) () {
	if !(.Colors == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AttachMenuBotIcon) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode attachMenuBotIcon#b2a7386b as nil")
	}
	.PutID(AttachMenuBotIconTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AttachMenuBotIcon) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode attachMenuBotIcon#b2a7386b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode attachMenuBotIcon#b2a7386b: field flags: %w", )
	}
	.PutString(.Name)
	if .Icon == nil {
		return fmt.Errorf("unable to encode attachMenuBotIcon#b2a7386b: field icon is nil")
	}
	if  := .Icon.Encode();  != nil {
		return fmt.Errorf("unable to encode attachMenuBotIcon#b2a7386b: field icon: %w", )
	}
	if .Flags.Has(0) {
		.PutVectorHeader(len(.Colors))
		for ,  := range .Colors {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode attachMenuBotIcon#b2a7386b: field colors element with index %d: %w", , )
			}
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AttachMenuBotIcon) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode attachMenuBotIcon#b2a7386b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: field name: %w", )
		}
		.Name = 
	}
	{
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: field icon: %w", )
		}
		.Icon = 
	}
	if .Flags.Has(0) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: field colors: %w", )
		}

		if  > 0 {
			.Colors = make([]AttachMenuBotIconColor, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  AttachMenuBotIconColor
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode attachMenuBotIcon#b2a7386b: field colors: %w", )
			}
			.Colors = append(.Colors, )
		}
	}
	return nil
}

// GetName returns value of Name field.
func ( *AttachMenuBotIcon) () ( string) {
	if  == nil {
		return
	}
	return .Name
}

// GetIcon returns value of Icon field.
func ( *AttachMenuBotIcon) () ( DocumentClass) {
	if  == nil {
		return
	}
	return .Icon
}

// SetColors sets value of Colors conditional field.
func ( *AttachMenuBotIcon) ( []AttachMenuBotIconColor) {
	.Flags.Set(0)
	.Colors = 
}

// GetColors returns value of Colors conditional field and
// boolean which is true if field was set.
func ( *AttachMenuBotIcon) () ( []AttachMenuBotIconColor,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Colors, true
}

// GetIconAsNotEmpty returns mapped value of Icon field.
func ( *AttachMenuBotIcon) () (*Document, bool) {
	return .Icon.AsNotEmpty()
}