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

// AccountPasswordInputSettings represents TL type `account.passwordInputSettings#c23727c9`.
// Settings for setting up a new password
//
// See https://core.telegram.org/constructor/account.passwordInputSettings for reference.
type AccountPasswordInputSettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The SRP algorithm¹ to use
	//
	// Links:
	//  1) https://core.telegram.org/api/srp
	//
	// Use SetNewAlgo and GetNewAlgo helpers.
	NewAlgo PasswordKdfAlgoClass
	// The computed password hash¹
	//
	// Links:
	//  1) https://core.telegram.org/api/srp
	//
	// Use SetNewPasswordHash and GetNewPasswordHash helpers.
	NewPasswordHash []byte
	// Text hint for the password
	//
	// Use SetHint and GetHint helpers.
	Hint string
	// Password recovery email
	//
	// Use SetEmail and GetEmail helpers.
	Email string
	// Telegram passport¹ settings
	//
	// Links:
	//  1) https://core.telegram.org/passport
	//
	// Use SetNewSecureSettings and GetNewSecureSettings helpers.
	NewSecureSettings SecureSecretSettings
}

// AccountPasswordInputSettingsTypeID is TL type id of AccountPasswordInputSettings.
const AccountPasswordInputSettingsTypeID = 0xc23727c9

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

func ( *AccountPasswordInputSettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.NewAlgo == nil) {
		return false
	}
	if !(.NewPasswordHash == nil) {
		return false
	}
	if !(.Hint == "") {
		return false
	}
	if !(.Email == "") {
		return false
	}
	if !(.NewSecureSettings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AccountPasswordInputSettings from given interface.
func ( *AccountPasswordInputSettings) ( interface {
	() ( PasswordKdfAlgoClass,  bool)
	() ( []byte,  bool)
	() ( string,  bool)
	() ( string,  bool)
	() ( SecureSecretSettings,  bool)
}) {
	if ,  := .();  {
		.NewAlgo = 
	}

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

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *AccountPasswordInputSettings) () tdp.Type {
	 := tdp.Type{
		Name: "account.passwordInputSettings",
		ID:   AccountPasswordInputSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "NewAlgo",
			SchemaName: "new_algo",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "NewPasswordHash",
			SchemaName: "new_password_hash",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Hint",
			SchemaName: "hint",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Email",
			SchemaName: "email",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "NewSecureSettings",
			SchemaName: "new_secure_settings",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountPasswordInputSettings) () {
	if !(.NewAlgo == nil) {
		.Flags.Set(0)
	}
	if !(.NewPasswordHash == nil) {
		.Flags.Set(0)
	}
	if !(.Hint == "") {
		.Flags.Set(0)
	}
	if !(.Email == "") {
		.Flags.Set(1)
	}
	if !(.NewSecureSettings.Zero()) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *AccountPasswordInputSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.passwordInputSettings#c23727c9 as nil")
	}
	.PutID(AccountPasswordInputSettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountPasswordInputSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.passwordInputSettings#c23727c9 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.passwordInputSettings#c23727c9: field flags: %w", )
	}
	if .Flags.Has(0) {
		if .NewAlgo == nil {
			return fmt.Errorf("unable to encode account.passwordInputSettings#c23727c9: field new_algo is nil")
		}
		if  := .NewAlgo.Encode();  != nil {
			return fmt.Errorf("unable to encode account.passwordInputSettings#c23727c9: field new_algo: %w", )
		}
	}
	if .Flags.Has(0) {
		.PutBytes(.NewPasswordHash)
	}
	if .Flags.Has(0) {
		.PutString(.Hint)
	}
	if .Flags.Has(1) {
		.PutString(.Email)
	}
	if .Flags.Has(2) {
		if  := .NewSecureSettings.Encode();  != nil {
			return fmt.Errorf("unable to encode account.passwordInputSettings#c23727c9: field new_secure_settings: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountPasswordInputSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.passwordInputSettings#c23727c9 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.passwordInputSettings#c23727c9: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := DecodePasswordKdfAlgo()
		if  != nil {
			return fmt.Errorf("unable to decode account.passwordInputSettings#c23727c9: field new_algo: %w", )
		}
		.NewAlgo = 
	}
	if .Flags.Has(0) {
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode account.passwordInputSettings#c23727c9: field new_password_hash: %w", )
		}
		.NewPasswordHash = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.passwordInputSettings#c23727c9: field hint: %w", )
		}
		.Hint = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.passwordInputSettings#c23727c9: field email: %w", )
		}
		.Email = 
	}
	if .Flags.Has(2) {
		if  := .NewSecureSettings.Decode();  != nil {
			return fmt.Errorf("unable to decode account.passwordInputSettings#c23727c9: field new_secure_settings: %w", )
		}
	}
	return nil
}

// SetNewAlgo sets value of NewAlgo conditional field.
func ( *AccountPasswordInputSettings) ( PasswordKdfAlgoClass) {
	.Flags.Set(0)
	.NewAlgo = 
}

// GetNewAlgo returns value of NewAlgo conditional field and
// boolean which is true if field was set.
func ( *AccountPasswordInputSettings) () ( PasswordKdfAlgoClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .NewAlgo, true
}

// SetNewPasswordHash sets value of NewPasswordHash conditional field.
func ( *AccountPasswordInputSettings) ( []byte) {
	.Flags.Set(0)
	.NewPasswordHash = 
}

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

// SetHint sets value of Hint conditional field.
func ( *AccountPasswordInputSettings) ( string) {
	.Flags.Set(0)
	.Hint = 
}

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

// SetEmail sets value of Email conditional field.
func ( *AccountPasswordInputSettings) ( string) {
	.Flags.Set(1)
	.Email = 
}

// GetEmail returns value of Email conditional field and
// boolean which is true if field was set.
func ( *AccountPasswordInputSettings) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Email, true
}

// SetNewSecureSettings sets value of NewSecureSettings conditional field.
func ( *AccountPasswordInputSettings) ( SecureSecretSettings) {
	.Flags.Set(2)
	.NewSecureSettings = 
}

// GetNewSecureSettings returns value of NewSecureSettings conditional field and
// boolean which is true if field was set.
func ( *AccountPasswordInputSettings) () ( SecureSecretSettings,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .NewSecureSettings, true
}