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

// InputStickerSetItem represents TL type `inputStickerSetItem#32da9e9c`.
// Sticker in a stickerset
//
// See https://core.telegram.org/constructor/inputStickerSetItem for reference.
type InputStickerSetItem struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The sticker
	Document InputDocumentClass
	// Associated emoji
	Emoji string
	// Coordinates for mask sticker
	//
	// Use SetMaskCoords and GetMaskCoords helpers.
	MaskCoords MaskCoords
	// Set of keywords, separated by commas (can't be provided for mask stickers)
	//
	// Use SetKeywords and GetKeywords helpers.
	Keywords string
}

// InputStickerSetItemTypeID is TL type id of InputStickerSetItem.
const InputStickerSetItemTypeID = 0x32da9e9c

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

func ( *InputStickerSetItem) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Document == nil) {
		return false
	}
	if !(.Emoji == "") {
		return false
	}
	if !(.MaskCoords.Zero()) {
		return false
	}
	if !(.Keywords == "") {
		return false
	}

	return true
}

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

// FillFrom fills InputStickerSetItem from given interface.
func ( *InputStickerSetItem) ( interface {
	() ( InputDocumentClass)
	() ( string)
	() ( MaskCoords,  bool)
	() ( string,  bool)
}) {
	.Document = .()
	.Emoji = .()
	if ,  := .();  {
		.MaskCoords = 
	}

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

}

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

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

// TypeInfo returns info about TL type.
func ( *InputStickerSetItem) () tdp.Type {
	 := tdp.Type{
		Name: "inputStickerSetItem",
		ID:   InputStickerSetItemTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Document",
			SchemaName: "document",
		},
		{
			Name:       "Emoji",
			SchemaName: "emoji",
		},
		{
			Name:       "MaskCoords",
			SchemaName: "mask_coords",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Keywords",
			SchemaName: "keywords",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputStickerSetItem) () {
	if !(.MaskCoords.Zero()) {
		.Flags.Set(0)
	}
	if !(.Keywords == "") {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *InputStickerSetItem) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStickerSetItem#32da9e9c as nil")
	}
	.PutID(InputStickerSetItemTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputStickerSetItem) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputStickerSetItem#32da9e9c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStickerSetItem#32da9e9c: field flags: %w", )
	}
	if .Document == nil {
		return fmt.Errorf("unable to encode inputStickerSetItem#32da9e9c: field document is nil")
	}
	if  := .Document.Encode();  != nil {
		return fmt.Errorf("unable to encode inputStickerSetItem#32da9e9c: field document: %w", )
	}
	.PutString(.Emoji)
	if .Flags.Has(0) {
		if  := .MaskCoords.Encode();  != nil {
			return fmt.Errorf("unable to encode inputStickerSetItem#32da9e9c: field mask_coords: %w", )
		}
	}
	if .Flags.Has(1) {
		.PutString(.Keywords)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputStickerSetItem) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputStickerSetItem#32da9e9c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputStickerSetItem#32da9e9c: field flags: %w", )
		}
	}
	{
		,  := DecodeInputDocument()
		if  != nil {
			return fmt.Errorf("unable to decode inputStickerSetItem#32da9e9c: field document: %w", )
		}
		.Document = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStickerSetItem#32da9e9c: field emoji: %w", )
		}
		.Emoji = 
	}
	if .Flags.Has(0) {
		if  := .MaskCoords.Decode();  != nil {
			return fmt.Errorf("unable to decode inputStickerSetItem#32da9e9c: field mask_coords: %w", )
		}
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputStickerSetItem#32da9e9c: field keywords: %w", )
		}
		.Keywords = 
	}
	return nil
}

// GetDocument returns value of Document field.
func ( *InputStickerSetItem) () ( InputDocumentClass) {
	if  == nil {
		return
	}
	return .Document
}

// GetEmoji returns value of Emoji field.
func ( *InputStickerSetItem) () ( string) {
	if  == nil {
		return
	}
	return .Emoji
}

// SetMaskCoords sets value of MaskCoords conditional field.
func ( *InputStickerSetItem) ( MaskCoords) {
	.Flags.Set(0)
	.MaskCoords = 
}

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

// SetKeywords sets value of Keywords conditional field.
func ( *InputStickerSetItem) ( string) {
	.Flags.Set(1)
	.Keywords = 
}

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

// GetDocumentAsNotEmpty returns mapped value of Document field.
func ( *InputStickerSetItem) () (*InputDocument, bool) {
	return .Document.AsNotEmpty()
}