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

// HelpDeepLinkInfoEmpty represents TL type `help.deepLinkInfoEmpty#66afa166`.
// Deep link info empty
//
// See https://core.telegram.org/constructor/help.deepLinkInfoEmpty for reference.
type HelpDeepLinkInfoEmpty struct {
}

// HelpDeepLinkInfoEmptyTypeID is TL type id of HelpDeepLinkInfoEmpty.
const HelpDeepLinkInfoEmptyTypeID = 0x66afa166

// construct implements constructor of HelpDeepLinkInfoClass.
func ( HelpDeepLinkInfoEmpty) () HelpDeepLinkInfoClass { return & }

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

	_ HelpDeepLinkInfoClass = &HelpDeepLinkInfoEmpty{}
)

func ( *HelpDeepLinkInfoEmpty) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*HelpDeepLinkInfoEmpty) () string {
	return "help.deepLinkInfoEmpty"
}

// TypeInfo returns info about TL type.
func ( *HelpDeepLinkInfoEmpty) () tdp.Type {
	 := tdp.Type{
		Name: "help.deepLinkInfoEmpty",
		ID:   HelpDeepLinkInfoEmptyTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *HelpDeepLinkInfoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.deepLinkInfoEmpty#66afa166 as nil")
	}
	.PutID(HelpDeepLinkInfoEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpDeepLinkInfoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.deepLinkInfoEmpty#66afa166 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *HelpDeepLinkInfoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.deepLinkInfoEmpty#66afa166 to nil")
	}
	if  := .ConsumeID(HelpDeepLinkInfoEmptyTypeID);  != nil {
		return fmt.Errorf("unable to decode help.deepLinkInfoEmpty#66afa166: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *HelpDeepLinkInfoEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.deepLinkInfoEmpty#66afa166 to nil")
	}
	return nil
}

// HelpDeepLinkInfo represents TL type `help.deepLinkInfo#6a4ee832`.
// Deep link info, see the here for more details¹
//
// Links:
//  1. https://core.telegram.org/api/links#unsupported-links
//
// See https://core.telegram.org/constructor/help.deepLinkInfo for reference.
type HelpDeepLinkInfo struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// An update of the app is required to parse this link
	UpdateApp bool
	// Message to show to the user
	Message string
	// Message entities for styled text¹
	//
	// Links:
	//  1) https://core.telegram.org/api/entities
	//
	// Use SetEntities and GetEntities helpers.
	Entities []MessageEntityClass
}

// HelpDeepLinkInfoTypeID is TL type id of HelpDeepLinkInfo.
const HelpDeepLinkInfoTypeID = 0x6a4ee832

// construct implements constructor of HelpDeepLinkInfoClass.
func ( HelpDeepLinkInfo) () HelpDeepLinkInfoClass { return & }

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

	_ HelpDeepLinkInfoClass = &HelpDeepLinkInfo{}
)

func ( *HelpDeepLinkInfo) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.UpdateApp == false) {
		return false
	}
	if !(.Message == "") {
		return false
	}
	if !(.Entities == nil) {
		return false
	}

	return true
}

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

// FillFrom fills HelpDeepLinkInfo from given interface.
func ( *HelpDeepLinkInfo) ( interface {
	() ( bool)
	() ( string)
	() ( []MessageEntityClass,  bool)
}) {
	.UpdateApp = .()
	.Message = .()
	if ,  := .();  {
		.Entities = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*HelpDeepLinkInfo) () string {
	return "help.deepLinkInfo"
}

// TypeInfo returns info about TL type.
func ( *HelpDeepLinkInfo) () tdp.Type {
	 := tdp.Type{
		Name: "help.deepLinkInfo",
		ID:   HelpDeepLinkInfoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UpdateApp",
			SchemaName: "update_app",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Message",
			SchemaName: "message",
		},
		{
			Name:       "Entities",
			SchemaName: "entities",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *HelpDeepLinkInfo) () {
	if !(.UpdateApp == false) {
		.Flags.Set(0)
	}
	if !(.Entities == nil) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *HelpDeepLinkInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.deepLinkInfo#6a4ee832 as nil")
	}
	.PutID(HelpDeepLinkInfoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpDeepLinkInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.deepLinkInfo#6a4ee832 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode help.deepLinkInfo#6a4ee832: field flags: %w", )
	}
	.PutString(.Message)
	if .Flags.Has(1) {
		.PutVectorHeader(len(.Entities))
		for ,  := range .Entities {
			if  == nil {
				return fmt.Errorf("unable to encode help.deepLinkInfo#6a4ee832: field entities element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode help.deepLinkInfo#6a4ee832: field entities element with index %d: %w", , )
			}
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *HelpDeepLinkInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.deepLinkInfo#6a4ee832 to nil")
	}
	if  := .ConsumeID(HelpDeepLinkInfoTypeID);  != nil {
		return fmt.Errorf("unable to decode help.deepLinkInfo#6a4ee832: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *HelpDeepLinkInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.deepLinkInfo#6a4ee832 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode help.deepLinkInfo#6a4ee832: field flags: %w", )
		}
	}
	.UpdateApp = .Flags.Has(0)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode help.deepLinkInfo#6a4ee832: field message: %w", )
		}
		.Message = 
	}
	if .Flags.Has(1) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode help.deepLinkInfo#6a4ee832: field entities: %w", )
		}

		if  > 0 {
			.Entities = make([]MessageEntityClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessageEntity()
			if  != nil {
				return fmt.Errorf("unable to decode help.deepLinkInfo#6a4ee832: field entities: %w", )
			}
			.Entities = append(.Entities, )
		}
	}
	return nil
}

// SetUpdateApp sets value of UpdateApp conditional field.
func ( *HelpDeepLinkInfo) ( bool) {
	if  {
		.Flags.Set(0)
		.UpdateApp = true
	} else {
		.Flags.Unset(0)
		.UpdateApp = false
	}
}

// GetUpdateApp returns value of UpdateApp conditional field.
func ( *HelpDeepLinkInfo) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetMessage returns value of Message field.
func ( *HelpDeepLinkInfo) () ( string) {
	if  == nil {
		return
	}
	return .Message
}

// SetEntities sets value of Entities conditional field.
func ( *HelpDeepLinkInfo) ( []MessageEntityClass) {
	.Flags.Set(1)
	.Entities = 
}

// GetEntities returns value of Entities conditional field and
// boolean which is true if field was set.
func ( *HelpDeepLinkInfo) () ( []MessageEntityClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Entities, true
}

// MapEntities returns field Entities wrapped in MessageEntityClassArray helper.
func ( *HelpDeepLinkInfo) () ( MessageEntityClassArray,  bool) {
	if !.Flags.Has(1) {
		return , false
	}
	return MessageEntityClassArray(.Entities), true
}

// HelpDeepLinkInfoClassName is schema name of HelpDeepLinkInfoClass.
const HelpDeepLinkInfoClassName = "help.DeepLinkInfo"

// HelpDeepLinkInfoClass represents help.DeepLinkInfo generic type.
//
// See https://core.telegram.org/type/help.DeepLinkInfo for reference.
//
// Example:
//
//	g, err := tg.DecodeHelpDeepLinkInfo(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.HelpDeepLinkInfoEmpty: // help.deepLinkInfoEmpty#66afa166
//	case *tg.HelpDeepLinkInfo: // help.deepLinkInfo#6a4ee832
//	default: panic(v)
//	}
type HelpDeepLinkInfoClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() HelpDeepLinkInfoClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool

	// AsNotEmpty tries to map HelpDeepLinkInfoClass to HelpDeepLinkInfo.
	AsNotEmpty() (*HelpDeepLinkInfo, bool)
}

// AsNotEmpty tries to map HelpDeepLinkInfoEmpty to HelpDeepLinkInfo.
func ( *HelpDeepLinkInfoEmpty) () (*HelpDeepLinkInfo, bool) {
	return nil, false
}

// AsNotEmpty tries to map HelpDeepLinkInfo to HelpDeepLinkInfo.
func ( *HelpDeepLinkInfo) () (*HelpDeepLinkInfo, bool) {
	return , true
}

// DecodeHelpDeepLinkInfo implements binary de-serialization for HelpDeepLinkInfoClass.
func ( *bin.Buffer) (HelpDeepLinkInfoClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case HelpDeepLinkInfoEmptyTypeID:
		// Decoding help.deepLinkInfoEmpty#66afa166.
		 := HelpDeepLinkInfoEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode HelpDeepLinkInfoClass: %w", )
		}
		return &, nil
	case HelpDeepLinkInfoTypeID:
		// Decoding help.deepLinkInfo#6a4ee832.
		 := HelpDeepLinkInfo{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode HelpDeepLinkInfoClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode HelpDeepLinkInfoClass: %w", bin.NewUnexpectedID())
	}
}

// HelpDeepLinkInfo boxes the HelpDeepLinkInfoClass providing a helper.
type HelpDeepLinkInfoBox struct {
	DeepLinkInfo HelpDeepLinkInfoClass
}

// Decode implements bin.Decoder for HelpDeepLinkInfoBox.
func ( *HelpDeepLinkInfoBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode HelpDeepLinkInfoBox to nil")
	}
	,  := DecodeHelpDeepLinkInfo()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.DeepLinkInfo = 
	return nil
}

// Encode implements bin.Encode for HelpDeepLinkInfoBox.
func ( *HelpDeepLinkInfoBox) ( *bin.Buffer) error {
	if  == nil || .DeepLinkInfo == nil {
		return fmt.Errorf("unable to encode HelpDeepLinkInfoClass as nil")
	}
	return .DeepLinkInfo.Encode()
}