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

// InputThemeSettings represents TL type `inputThemeSettings#8fde504f`.
// Theme settings
//
// See https://core.telegram.org/constructor/inputThemeSettings for reference.
type InputThemeSettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, the freeform gradient fill needs to be animated on every sent message
	MessageColorsAnimated bool
	// Default theme on which this theme is based
	BaseTheme BaseThemeClass
	// Accent color, ARGB format
	AccentColor int
	// Accent color of outgoing messages in ARGB format
	//
	// Use SetOutboxAccentColor and GetOutboxAccentColor helpers.
	OutboxAccentColor int
	// The fill to be used as a background for outgoing messages, in RGB24 format. If just
	// one or two equal colors are provided, describes a solid fill of a background. If two
	// different colors are provided, describes the top and bottom colors of a 0-degree
	// gradient.If three or four colors are provided, describes a freeform gradient fill of a
	// background.
	//
	// Use SetMessageColors and GetMessageColors helpers.
	MessageColors []int
	// inputWallPaper¹ or inputWallPaperSlug² when passing wallpaper files for image³ or
	// pattern⁴ wallpapers, inputWallPaperNoFile⁵ with id=0 otherwise.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputWallPaper
	//  2) https://core.telegram.org/constructor/inputWallPaper
	//  3) https://core.telegram.org/api/wallpapers#image-wallpapers
	//  4) https://core.telegram.org/api/wallpapers#pattern-wallpapers
	//  5) https://core.telegram.org/constructor/inputWallPaperNoFile
	//
	// Use SetWallpaper and GetWallpaper helpers.
	Wallpaper InputWallPaperClass
	// Wallpaper¹ settings.
	//
	// Links:
	//  1) https://core.telegram.org/api/wallpapers
	//
	// Use SetWallpaperSettings and GetWallpaperSettings helpers.
	WallpaperSettings WallPaperSettings
}

// InputThemeSettingsTypeID is TL type id of InputThemeSettings.
const InputThemeSettingsTypeID = 0x8fde504f

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

func ( *InputThemeSettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.MessageColorsAnimated == false) {
		return false
	}
	if !(.BaseTheme == nil) {
		return false
	}
	if !(.AccentColor == 0) {
		return false
	}
	if !(.OutboxAccentColor == 0) {
		return false
	}
	if !(.MessageColors == nil) {
		return false
	}
	if !(.Wallpaper == nil) {
		return false
	}
	if !(.WallpaperSettings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills InputThemeSettings from given interface.
func ( *InputThemeSettings) ( interface {
	() ( bool)
	() ( BaseThemeClass)
	() ( int)
	() ( int,  bool)
	() ( []int,  bool)
	() ( InputWallPaperClass,  bool)
	() ( WallPaperSettings,  bool)
}) {
	.MessageColorsAnimated = .()
	.BaseTheme = .()
	.AccentColor = .()
	if ,  := .();  {
		.OutboxAccentColor = 
	}

	if ,  := .();  {
		.MessageColors = 
	}

	if ,  := .();  {
		.Wallpaper = 
	}

	if ,  := .();  {
		.WallpaperSettings = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *InputThemeSettings) () tdp.Type {
	 := tdp.Type{
		Name: "inputThemeSettings",
		ID:   InputThemeSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "MessageColorsAnimated",
			SchemaName: "message_colors_animated",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "BaseTheme",
			SchemaName: "base_theme",
		},
		{
			Name:       "AccentColor",
			SchemaName: "accent_color",
		},
		{
			Name:       "OutboxAccentColor",
			SchemaName: "outbox_accent_color",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "MessageColors",
			SchemaName: "message_colors",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Wallpaper",
			SchemaName: "wallpaper",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "WallpaperSettings",
			SchemaName: "wallpaper_settings",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputThemeSettings) () {
	if !(.MessageColorsAnimated == false) {
		.Flags.Set(2)
	}
	if !(.OutboxAccentColor == 0) {
		.Flags.Set(3)
	}
	if !(.MessageColors == nil) {
		.Flags.Set(0)
	}
	if !(.Wallpaper == nil) {
		.Flags.Set(1)
	}
	if !(.WallpaperSettings.Zero()) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *InputThemeSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputThemeSettings#8fde504f as nil")
	}
	.PutID(InputThemeSettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputThemeSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputThemeSettings#8fde504f as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputThemeSettings#8fde504f: field flags: %w", )
	}
	if .BaseTheme == nil {
		return fmt.Errorf("unable to encode inputThemeSettings#8fde504f: field base_theme is nil")
	}
	if  := .BaseTheme.Encode();  != nil {
		return fmt.Errorf("unable to encode inputThemeSettings#8fde504f: field base_theme: %w", )
	}
	.PutInt(.AccentColor)
	if .Flags.Has(3) {
		.PutInt(.OutboxAccentColor)
	}
	if .Flags.Has(0) {
		.PutVectorHeader(len(.MessageColors))
		for ,  := range .MessageColors {
			.PutInt()
		}
	}
	if .Flags.Has(1) {
		if .Wallpaper == nil {
			return fmt.Errorf("unable to encode inputThemeSettings#8fde504f: field wallpaper is nil")
		}
		if  := .Wallpaper.Encode();  != nil {
			return fmt.Errorf("unable to encode inputThemeSettings#8fde504f: field wallpaper: %w", )
		}
	}
	if .Flags.Has(1) {
		if  := .WallpaperSettings.Encode();  != nil {
			return fmt.Errorf("unable to encode inputThemeSettings#8fde504f: field wallpaper_settings: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputThemeSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputThemeSettings#8fde504f to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputThemeSettings#8fde504f: field flags: %w", )
		}
	}
	.MessageColorsAnimated = .Flags.Has(2)
	{
		,  := DecodeBaseTheme()
		if  != nil {
			return fmt.Errorf("unable to decode inputThemeSettings#8fde504f: field base_theme: %w", )
		}
		.BaseTheme = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputThemeSettings#8fde504f: field accent_color: %w", )
		}
		.AccentColor = 
	}
	if .Flags.Has(3) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputThemeSettings#8fde504f: field outbox_accent_color: %w", )
		}
		.OutboxAccentColor = 
	}
	if .Flags.Has(0) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode inputThemeSettings#8fde504f: field message_colors: %w", )
		}

		if  > 0 {
			.MessageColors = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode inputThemeSettings#8fde504f: field message_colors: %w", )
			}
			.MessageColors = append(.MessageColors, )
		}
	}
	if .Flags.Has(1) {
		,  := DecodeInputWallPaper()
		if  != nil {
			return fmt.Errorf("unable to decode inputThemeSettings#8fde504f: field wallpaper: %w", )
		}
		.Wallpaper = 
	}
	if .Flags.Has(1) {
		if  := .WallpaperSettings.Decode();  != nil {
			return fmt.Errorf("unable to decode inputThemeSettings#8fde504f: field wallpaper_settings: %w", )
		}
	}
	return nil
}

// SetMessageColorsAnimated sets value of MessageColorsAnimated conditional field.
func ( *InputThemeSettings) ( bool) {
	if  {
		.Flags.Set(2)
		.MessageColorsAnimated = true
	} else {
		.Flags.Unset(2)
		.MessageColorsAnimated = false
	}
}

// GetMessageColorsAnimated returns value of MessageColorsAnimated conditional field.
func ( *InputThemeSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetBaseTheme returns value of BaseTheme field.
func ( *InputThemeSettings) () ( BaseThemeClass) {
	if  == nil {
		return
	}
	return .BaseTheme
}

// GetAccentColor returns value of AccentColor field.
func ( *InputThemeSettings) () ( int) {
	if  == nil {
		return
	}
	return .AccentColor
}

// SetOutboxAccentColor sets value of OutboxAccentColor conditional field.
func ( *InputThemeSettings) ( int) {
	.Flags.Set(3)
	.OutboxAccentColor = 
}

// GetOutboxAccentColor returns value of OutboxAccentColor conditional field and
// boolean which is true if field was set.
func ( *InputThemeSettings) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .OutboxAccentColor, true
}

// SetMessageColors sets value of MessageColors conditional field.
func ( *InputThemeSettings) ( []int) {
	.Flags.Set(0)
	.MessageColors = 
}

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

// SetWallpaper sets value of Wallpaper conditional field.
func ( *InputThemeSettings) ( InputWallPaperClass) {
	.Flags.Set(1)
	.Wallpaper = 
}

// GetWallpaper returns value of Wallpaper conditional field and
// boolean which is true if field was set.
func ( *InputThemeSettings) () ( InputWallPaperClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Wallpaper, true
}

// SetWallpaperSettings sets value of WallpaperSettings conditional field.
func ( *InputThemeSettings) ( WallPaperSettings) {
	.Flags.Set(1)
	.WallpaperSettings = 
}

// GetWallpaperSettings returns value of WallpaperSettings conditional field and
// boolean which is true if field was set.
func ( *InputThemeSettings) () ( WallPaperSettings,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .WallpaperSettings, true
}