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

// ReportResultChooseOption represents TL type `reportResultChooseOption#f0e4e0b6`.
// The user must choose one of the following options, and then messages.report¹ must be
// re-invoked, passing the option's option identifier to messages.report².option.
//
// Links:
//  1. https://core.telegram.org/method/messages.report
//  2. https://core.telegram.org/method/messages.report
//
// See https://core.telegram.org/constructor/reportResultChooseOption for reference.
type ReportResultChooseOption struct {
	// Title of the option popup
	Title string
	// Available options, rendered as menu entries.
	Options []MessageReportOption
}

// ReportResultChooseOptionTypeID is TL type id of ReportResultChooseOption.
const ReportResultChooseOptionTypeID = 0xf0e4e0b6

// construct implements constructor of ReportResultClass.
func ( ReportResultChooseOption) () ReportResultClass { return & }

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

	_ ReportResultClass = &ReportResultChooseOption{}
)

func ( *ReportResultChooseOption) () bool {
	if  == nil {
		return true
	}
	if !(.Title == "") {
		return false
	}
	if !(.Options == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ReportResultChooseOption from given interface.
func ( *ReportResultChooseOption) ( interface {
	() ( string)
	() ( []MessageReportOption)
}) {
	.Title = .()
	.Options = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ReportResultChooseOption) () tdp.Type {
	 := tdp.Type{
		Name: "reportResultChooseOption",
		ID:   ReportResultChooseOptionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Options",
			SchemaName: "options",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ReportResultChooseOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reportResultChooseOption#f0e4e0b6 as nil")
	}
	.PutID(ReportResultChooseOptionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ReportResultChooseOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reportResultChooseOption#f0e4e0b6 as nil")
	}
	.PutString(.Title)
	.PutVectorHeader(len(.Options))
	for ,  := range .Options {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode reportResultChooseOption#f0e4e0b6: field options element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ReportResultChooseOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reportResultChooseOption#f0e4e0b6 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode reportResultChooseOption#f0e4e0b6: field title: %w", )
		}
		.Title = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode reportResultChooseOption#f0e4e0b6: field options: %w", )
		}

		if  > 0 {
			.Options = make([]MessageReportOption, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  MessageReportOption
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode reportResultChooseOption#f0e4e0b6: field options: %w", )
			}
			.Options = append(.Options, )
		}
	}
	return nil
}

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

// GetOptions returns value of Options field.
func ( *ReportResultChooseOption) () ( []MessageReportOption) {
	if  == nil {
		return
	}
	return .Options
}

// ReportResultAddComment represents TL type `reportResultAddComment#6f09ac31`.
// The user should enter an additional comment for the moderators, and then messages
// report¹ must be re-invoked, passing the comment to messages.report².message.
//
// Links:
//  1. https://core.telegram.org/method/messages.report
//  2. https://core.telegram.org/method/messages.report
//
// See https://core.telegram.org/constructor/reportResultAddComment for reference.
type ReportResultAddComment struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this step can be skipped by the user, passing an empty message to messages
	// report¹, or if a non-empty message is mandatory.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.report
	Optional bool
	// The messages.report¹ method must be re-invoked, passing this option to option
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.report
	Option []byte
}

// ReportResultAddCommentTypeID is TL type id of ReportResultAddComment.
const ReportResultAddCommentTypeID = 0x6f09ac31

// construct implements constructor of ReportResultClass.
func ( ReportResultAddComment) () ReportResultClass { return & }

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

	_ ReportResultClass = &ReportResultAddComment{}
)

func ( *ReportResultAddComment) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Optional == false) {
		return false
	}
	if !(.Option == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ReportResultAddComment from given interface.
func ( *ReportResultAddComment) ( interface {
	() ( bool)
	() ( []byte)
}) {
	.Optional = .()
	.Option = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ReportResultAddComment) () tdp.Type {
	 := tdp.Type{
		Name: "reportResultAddComment",
		ID:   ReportResultAddCommentTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Optional",
			SchemaName: "optional",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Option",
			SchemaName: "option",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ReportResultAddComment) () {
	if !(.Optional == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *ReportResultAddComment) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reportResultAddComment#6f09ac31 as nil")
	}
	.PutID(ReportResultAddCommentTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ReportResultAddComment) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reportResultAddComment#6f09ac31 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode reportResultAddComment#6f09ac31: field flags: %w", )
	}
	.PutBytes(.Option)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ReportResultAddComment) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reportResultAddComment#6f09ac31 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode reportResultAddComment#6f09ac31: field flags: %w", )
		}
	}
	.Optional = .Flags.Has(0)
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode reportResultAddComment#6f09ac31: field option: %w", )
		}
		.Option = 
	}
	return nil
}

// SetOptional sets value of Optional conditional field.
func ( *ReportResultAddComment) ( bool) {
	if  {
		.Flags.Set(0)
		.Optional = true
	} else {
		.Flags.Unset(0)
		.Optional = false
	}
}

// GetOptional returns value of Optional conditional field.
func ( *ReportResultAddComment) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetOption returns value of Option field.
func ( *ReportResultAddComment) () ( []byte) {
	if  == nil {
		return
	}
	return .Option
}

// ReportResultReported represents TL type `reportResultReported#8db33c4b`.
// The report was sent successfully, no further actions are required.
//
// See https://core.telegram.org/constructor/reportResultReported for reference.
type ReportResultReported struct {
}

// ReportResultReportedTypeID is TL type id of ReportResultReported.
const ReportResultReportedTypeID = 0x8db33c4b

// construct implements constructor of ReportResultClass.
func ( ReportResultReported) () ReportResultClass { return & }

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

	_ ReportResultClass = &ReportResultReported{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *ReportResultReported) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reportResultReported#8db33c4b as nil")
	}
	.PutID(ReportResultReportedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ReportResultReported) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode reportResultReported#8db33c4b as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ReportResultReported) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reportResultReported#8db33c4b to nil")
	}
	if  := .ConsumeID(ReportResultReportedTypeID);  != nil {
		return fmt.Errorf("unable to decode reportResultReported#8db33c4b: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ReportResultReported) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode reportResultReported#8db33c4b to nil")
	}
	return nil
}

// ReportResultClassName is schema name of ReportResultClass.
const ReportResultClassName = "ReportResult"

// ReportResultClass represents ReportResult generic type.
//
// See https://core.telegram.org/type/ReportResult for reference.
//
// Constructors:
//   - [ReportResultChooseOption]
//   - [ReportResultAddComment]
//   - [ReportResultReported]
//
// Example:
//
//	g, err := tg.DecodeReportResult(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.ReportResultChooseOption: // reportResultChooseOption#f0e4e0b6
//	case *tg.ReportResultAddComment: // reportResultAddComment#6f09ac31
//	case *tg.ReportResultReported: // reportResultReported#8db33c4b
//	default: panic(v)
//	}
type ReportResultClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() ReportResultClass

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

// DecodeReportResult implements binary de-serialization for ReportResultClass.
func ( *bin.Buffer) (ReportResultClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case ReportResultChooseOptionTypeID:
		// Decoding reportResultChooseOption#f0e4e0b6.
		 := ReportResultChooseOption{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ReportResultClass: %w", )
		}
		return &, nil
	case ReportResultAddCommentTypeID:
		// Decoding reportResultAddComment#6f09ac31.
		 := ReportResultAddComment{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ReportResultClass: %w", )
		}
		return &, nil
	case ReportResultReportedTypeID:
		// Decoding reportResultReported#8db33c4b.
		 := ReportResultReported{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode ReportResultClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode ReportResultClass: %w", bin.NewUnexpectedID())
	}
}

// ReportResult boxes the ReportResultClass providing a helper.
type ReportResultBox struct {
	ReportResult ReportResultClass
}

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

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