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

// AvailableEffect represents TL type `availableEffect#93c3e27e`.
// Represents a message effect »¹.
// All long IDs except for id are document¹.ids from the containing messages
// availableEffects² constructor.
// See here »¹ for more info on how to use following fields.
//
// Links:
//  1. https://core.telegram.org/api/effects
//  2. https://core.telegram.org/constructor/document
//  3. https://core.telegram.org/constructor/messages.availableEffects
//  4. https://core.telegram.org/api/effects
//
// See https://core.telegram.org/constructor/availableEffect for reference.
type AvailableEffect struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether a Premium¹ subscription is required to use this effect.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	PremiumRequired bool
	// Unique effect ID.
	ID int64
	// Emoji corresponding to the effect, to be used as icon for the effect if static_icon_id
	// is not set.
	Emoticon string
	// ID of the document containing the static icon (WEBP) of the effect.
	//
	// Use SetStaticIconID and GetStaticIconID helpers.
	StaticIconID int64
	// Contains the preview animation (TGS format »)¹, used for the effect selection menu.
	//
	// Links:
	//  1) https://core.telegram.org/api/stickers#animated-stickers
	EffectStickerID int64
	// If set, contains the actual animated effect (TGS format »)¹. If not set, the
	// animated effect must be set equal to the premium animated sticker effect² associated
	// to the animated sticker specified in effect_sticker_id (always different from the
	// preview animation, fetched thanks to the videoSize³ of type f as specified here
	// »⁴).
	//
	// Links:
	//  1) https://core.telegram.org/api/stickers#animated-stickers
	//  2) https://core.telegram.org/api/stickers#premium-animated-sticker-effects
	//  3) https://core.telegram.org/constructor/videoSize
	//  4) https://core.telegram.org/api/stickers#premium-animated-sticker-effects
	//
	// Use SetEffectAnimationID and GetEffectAnimationID helpers.
	EffectAnimationID int64
}

// AvailableEffectTypeID is TL type id of AvailableEffect.
const AvailableEffectTypeID = 0x93c3e27e

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

func ( *AvailableEffect) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.PremiumRequired == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Emoticon == "") {
		return false
	}
	if !(.StaticIconID == 0) {
		return false
	}
	if !(.EffectStickerID == 0) {
		return false
	}
	if !(.EffectAnimationID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AvailableEffect from given interface.
func ( *AvailableEffect) ( interface {
	() ( bool)
	() ( int64)
	() ( string)
	() ( int64,  bool)
	() ( int64)
	() ( int64,  bool)
}) {
	.PremiumRequired = .()
	.ID = .()
	.Emoticon = .()
	if ,  := .();  {
		.StaticIconID = 
	}

	.EffectStickerID = .()
	if ,  := .();  {
		.EffectAnimationID = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *AvailableEffect) () tdp.Type {
	 := tdp.Type{
		Name: "availableEffect",
		ID:   AvailableEffectTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PremiumRequired",
			SchemaName: "premium_required",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Emoticon",
			SchemaName: "emoticon",
		},
		{
			Name:       "StaticIconID",
			SchemaName: "static_icon_id",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "EffectStickerID",
			SchemaName: "effect_sticker_id",
		},
		{
			Name:       "EffectAnimationID",
			SchemaName: "effect_animation_id",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AvailableEffect) () {
	if !(.PremiumRequired == false) {
		.Flags.Set(2)
	}
	if !(.StaticIconID == 0) {
		.Flags.Set(0)
	}
	if !(.EffectAnimationID == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *AvailableEffect) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode availableEffect#93c3e27e as nil")
	}
	.PutID(AvailableEffectTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AvailableEffect) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode availableEffect#93c3e27e as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode availableEffect#93c3e27e: field flags: %w", )
	}
	.PutLong(.ID)
	.PutString(.Emoticon)
	if .Flags.Has(0) {
		.PutLong(.StaticIconID)
	}
	.PutLong(.EffectStickerID)
	if .Flags.Has(1) {
		.PutLong(.EffectAnimationID)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AvailableEffect) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode availableEffect#93c3e27e to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode availableEffect#93c3e27e: field flags: %w", )
		}
	}
	.PremiumRequired = .Flags.Has(2)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode availableEffect#93c3e27e: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode availableEffect#93c3e27e: field emoticon: %w", )
		}
		.Emoticon = 
	}
	if .Flags.Has(0) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode availableEffect#93c3e27e: field static_icon_id: %w", )
		}
		.StaticIconID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode availableEffect#93c3e27e: field effect_sticker_id: %w", )
		}
		.EffectStickerID = 
	}
	if .Flags.Has(1) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode availableEffect#93c3e27e: field effect_animation_id: %w", )
		}
		.EffectAnimationID = 
	}
	return nil
}

// SetPremiumRequired sets value of PremiumRequired conditional field.
func ( *AvailableEffect) ( bool) {
	if  {
		.Flags.Set(2)
		.PremiumRequired = true
	} else {
		.Flags.Unset(2)
		.PremiumRequired = false
	}
}

// GetPremiumRequired returns value of PremiumRequired conditional field.
func ( *AvailableEffect) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetID returns value of ID field.
func ( *AvailableEffect) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetEmoticon returns value of Emoticon field.
func ( *AvailableEffect) () ( string) {
	if  == nil {
		return
	}
	return .Emoticon
}

// SetStaticIconID sets value of StaticIconID conditional field.
func ( *AvailableEffect) ( int64) {
	.Flags.Set(0)
	.StaticIconID = 
}

// GetStaticIconID returns value of StaticIconID conditional field and
// boolean which is true if field was set.
func ( *AvailableEffect) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .StaticIconID, true
}

// GetEffectStickerID returns value of EffectStickerID field.
func ( *AvailableEffect) () ( int64) {
	if  == nil {
		return
	}
	return .EffectStickerID
}

// SetEffectAnimationID sets value of EffectAnimationID conditional field.
func ( *AvailableEffect) ( int64) {
	.Flags.Set(1)
	.EffectAnimationID = 
}

// GetEffectAnimationID returns value of EffectAnimationID conditional field and
// boolean which is true if field was set.
func ( *AvailableEffect) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .EffectAnimationID, true
}