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

// AccountCreateThemeRequest represents TL type `account.createTheme#652e4400`.
// Create a theme
//
// See https://core.telegram.org/method/account.createTheme for reference.
type AccountCreateThemeRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Unique theme ID used to generate theme deep linksĀ¹, can be empty to autogenerate a
	// random ID.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#theme-links
	Slug string
	// Theme name
	Title string
	// Theme file
	//
	// Use SetDocument and GetDocument helpers.
	Document InputDocumentClass
	// Theme settings, multiple values can be provided for the different base themes
	// (day/night mode, etc).
	//
	// Use SetSettings and GetSettings helpers.
	Settings []InputThemeSettings
}

// AccountCreateThemeRequestTypeID is TL type id of AccountCreateThemeRequest.
const AccountCreateThemeRequestTypeID = 0x652e4400

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

func ( *AccountCreateThemeRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Slug == "") {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Document == nil) {
		return false
	}
	if !(.Settings == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountCreateThemeRequest from given interface.
func ( *AccountCreateThemeRequest) ( interface {
	() ( string)
	() ( string)
	() ( InputDocumentClass,  bool)
	() ( []InputThemeSettings,  bool)
}) {
	.Slug = .()
	.Title = .()
	if ,  := .();  {
		.Document = 
	}

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

}

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

// TypeName returns name of type in TL schema.
func (*AccountCreateThemeRequest) () string {
	return "account.createTheme"
}

// TypeInfo returns info about TL type.
func ( *AccountCreateThemeRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.createTheme",
		ID:   AccountCreateThemeRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Slug",
			SchemaName: "slug",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Document",
			SchemaName: "document",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Settings",
			SchemaName: "settings",
			Null:       !.Flags.Has(3),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountCreateThemeRequest) () {
	if !(.Document == nil) {
		.Flags.Set(2)
	}
	if !(.Settings == nil) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *AccountCreateThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.createTheme#652e4400 as nil")
	}
	.PutID(AccountCreateThemeRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountCreateThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.createTheme#652e4400 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.createTheme#652e4400: field flags: %w", )
	}
	.PutString(.Slug)
	.PutString(.Title)
	if .Flags.Has(2) {
		if .Document == nil {
			return fmt.Errorf("unable to encode account.createTheme#652e4400: field document is nil")
		}
		if  := .Document.Encode();  != nil {
			return fmt.Errorf("unable to encode account.createTheme#652e4400: field document: %w", )
		}
	}
	if .Flags.Has(3) {
		.PutVectorHeader(len(.Settings))
		for ,  := range .Settings {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode account.createTheme#652e4400: field settings element with index %d: %w", , )
			}
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountCreateThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.createTheme#652e4400 to nil")
	}
	if  := .ConsumeID(AccountCreateThemeRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode account.createTheme#652e4400: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountCreateThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.createTheme#652e4400 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.createTheme#652e4400: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.createTheme#652e4400: field slug: %w", )
		}
		.Slug = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.createTheme#652e4400: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(2) {
		,  := DecodeInputDocument()
		if  != nil {
			return fmt.Errorf("unable to decode account.createTheme#652e4400: field document: %w", )
		}
		.Document = 
	}
	if .Flags.Has(3) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.createTheme#652e4400: field settings: %w", )
		}

		if  > 0 {
			.Settings = make([]InputThemeSettings, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  InputThemeSettings
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode account.createTheme#652e4400: field settings: %w", )
			}
			.Settings = append(.Settings, )
		}
	}
	return nil
}

// GetSlug returns value of Slug field.
func ( *AccountCreateThemeRequest) () ( string) {
	if  == nil {
		return
	}
	return .Slug
}

// GetTitle returns value of Title field.
func ( *AccountCreateThemeRequest) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

// SetDocument sets value of Document conditional field.
func ( *AccountCreateThemeRequest) ( InputDocumentClass) {
	.Flags.Set(2)
	.Document = 
}

// GetDocument returns value of Document conditional field and
// boolean which is true if field was set.
func ( *AccountCreateThemeRequest) () ( InputDocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Document, true
}

// SetSettings sets value of Settings conditional field.
func ( *AccountCreateThemeRequest) ( []InputThemeSettings) {
	.Flags.Set(3)
	.Settings = 
}

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

// GetDocumentAsNotEmpty returns mapped value of Document conditional field and
// boolean which is true if field was set.
func ( *AccountCreateThemeRequest) () (*InputDocument, bool) {
	if ,  := .GetDocument();  {
		return .AsNotEmpty()
	}
	return nil, false
}

// AccountCreateTheme invokes method account.createTheme#652e4400 returning error if any.
// Create a theme
//
// Possible errors:
//
//	400 THEME_MIME_INVALID: The theme's MIME type is invalid.
//	400 THEME_TITLE_INVALID: The specified theme title is invalid.
//
// See https://core.telegram.org/method/account.createTheme for reference.
func ( *Client) ( context.Context,  *AccountCreateThemeRequest) (*Theme, error) {
	var  Theme

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}