// Code generated by gotdgen, DO NOT EDIT.

package tdapi

import (
	"context"
	"errors"
	"fmt"
	"sort"
	"strings"

	"go.uber.org/multierr"

	"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
	"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)

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

// SupergroupMembersFilterRecent represents TL type `supergroupMembersFilterRecent#4639e5d5`.
type SupergroupMembersFilterRecent struct {
}

// SupergroupMembersFilterRecentTypeID is TL type id of SupergroupMembersFilterRecent.
const SupergroupMembersFilterRecentTypeID = 0x4639e5d5

// construct implements constructor of SupergroupMembersFilterClass.
func (s SupergroupMembersFilterRecent) construct() SupergroupMembersFilterClass { return &s }

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

	_ SupergroupMembersFilterClass = &SupergroupMembersFilterRecent{}
)

func (s *SupergroupMembersFilterRecent) Zero() bool {
	if s == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *SupergroupMembersFilterRecent) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "supergroupMembersFilterRecent",
		ID:   SupergroupMembersFilterRecentTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (s *SupergroupMembersFilterRecent) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterRecent#4639e5d5 as nil")
	}
	b.PutID(SupergroupMembersFilterRecentTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *SupergroupMembersFilterRecent) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterRecent#4639e5d5 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *SupergroupMembersFilterRecent) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterRecent#4639e5d5 to nil")
	}
	if err := b.ConsumeID(SupergroupMembersFilterRecentTypeID); err != nil {
		return fmt.Errorf("unable to decode supergroupMembersFilterRecent#4639e5d5: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *SupergroupMembersFilterRecent) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterRecent#4639e5d5 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SupergroupMembersFilterRecent) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterRecent#4639e5d5 as nil")
	}
	b.ObjStart()
	b.PutID("supergroupMembersFilterRecent")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SupergroupMembersFilterRecent) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterRecent#4639e5d5 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("supergroupMembersFilterRecent"); err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterRecent#4639e5d5: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// SupergroupMembersFilterContacts represents TL type `supergroupMembersFilterContacts#b3885578`.
type SupergroupMembersFilterContacts struct {
	// Query to search for
	Query string
}

// SupergroupMembersFilterContactsTypeID is TL type id of SupergroupMembersFilterContacts.
const SupergroupMembersFilterContactsTypeID = 0xb3885578

// construct implements constructor of SupergroupMembersFilterClass.
func (s SupergroupMembersFilterContacts) construct() SupergroupMembersFilterClass { return &s }

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

	_ SupergroupMembersFilterClass = &SupergroupMembersFilterContacts{}
)

func (s *SupergroupMembersFilterContacts) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.Query == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *SupergroupMembersFilterContacts) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "supergroupMembersFilterContacts",
		ID:   SupergroupMembersFilterContactsTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Query",
			SchemaName: "query",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *SupergroupMembersFilterContacts) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterContacts#b3885578 as nil")
	}
	b.PutID(SupergroupMembersFilterContactsTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *SupergroupMembersFilterContacts) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterContacts#b3885578 as nil")
	}
	b.PutString(s.Query)
	return nil
}

// Decode implements bin.Decoder.
func (s *SupergroupMembersFilterContacts) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterContacts#b3885578 to nil")
	}
	if err := b.ConsumeID(SupergroupMembersFilterContactsTypeID); err != nil {
		return fmt.Errorf("unable to decode supergroupMembersFilterContacts#b3885578: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *SupergroupMembersFilterContacts) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterContacts#b3885578 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode supergroupMembersFilterContacts#b3885578: field query: %w", err)
		}
		s.Query = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SupergroupMembersFilterContacts) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterContacts#b3885578 as nil")
	}
	b.ObjStart()
	b.PutID("supergroupMembersFilterContacts")
	b.Comma()
	b.FieldStart("query")
	b.PutString(s.Query)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SupergroupMembersFilterContacts) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterContacts#b3885578 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("supergroupMembersFilterContacts"); err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterContacts#b3885578: %w", err)
			}
		case "query":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterContacts#b3885578: field query: %w", err)
			}
			s.Query = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetQuery returns value of Query field.
func (s *SupergroupMembersFilterContacts) GetQuery() (value string) {
	if s == nil {
		return
	}
	return s.Query
}

// SupergroupMembersFilterAdministrators represents TL type `supergroupMembersFilterAdministrators#82fc8457`.
type SupergroupMembersFilterAdministrators struct {
}

// SupergroupMembersFilterAdministratorsTypeID is TL type id of SupergroupMembersFilterAdministrators.
const SupergroupMembersFilterAdministratorsTypeID = 0x82fc8457

// construct implements constructor of SupergroupMembersFilterClass.
func (s SupergroupMembersFilterAdministrators) construct() SupergroupMembersFilterClass { return &s }

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

	_ SupergroupMembersFilterClass = &SupergroupMembersFilterAdministrators{}
)

func (s *SupergroupMembersFilterAdministrators) Zero() bool {
	if s == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *SupergroupMembersFilterAdministrators) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "supergroupMembersFilterAdministrators",
		ID:   SupergroupMembersFilterAdministratorsTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (s *SupergroupMembersFilterAdministrators) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterAdministrators#82fc8457 as nil")
	}
	b.PutID(SupergroupMembersFilterAdministratorsTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *SupergroupMembersFilterAdministrators) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterAdministrators#82fc8457 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *SupergroupMembersFilterAdministrators) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterAdministrators#82fc8457 to nil")
	}
	if err := b.ConsumeID(SupergroupMembersFilterAdministratorsTypeID); err != nil {
		return fmt.Errorf("unable to decode supergroupMembersFilterAdministrators#82fc8457: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *SupergroupMembersFilterAdministrators) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterAdministrators#82fc8457 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SupergroupMembersFilterAdministrators) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterAdministrators#82fc8457 as nil")
	}
	b.ObjStart()
	b.PutID("supergroupMembersFilterAdministrators")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SupergroupMembersFilterAdministrators) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterAdministrators#82fc8457 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("supergroupMembersFilterAdministrators"); err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterAdministrators#82fc8457: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// SupergroupMembersFilterSearch represents TL type `supergroupMembersFilterSearch#9ae39fbb`.
type SupergroupMembersFilterSearch struct {
	// Query to search for
	Query string
}

// SupergroupMembersFilterSearchTypeID is TL type id of SupergroupMembersFilterSearch.
const SupergroupMembersFilterSearchTypeID = 0x9ae39fbb

// construct implements constructor of SupergroupMembersFilterClass.
func (s SupergroupMembersFilterSearch) construct() SupergroupMembersFilterClass { return &s }

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

	_ SupergroupMembersFilterClass = &SupergroupMembersFilterSearch{}
)

func (s *SupergroupMembersFilterSearch) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.Query == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *SupergroupMembersFilterSearch) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "supergroupMembersFilterSearch",
		ID:   SupergroupMembersFilterSearchTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Query",
			SchemaName: "query",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *SupergroupMembersFilterSearch) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterSearch#9ae39fbb as nil")
	}
	b.PutID(SupergroupMembersFilterSearchTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *SupergroupMembersFilterSearch) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterSearch#9ae39fbb as nil")
	}
	b.PutString(s.Query)
	return nil
}

// Decode implements bin.Decoder.
func (s *SupergroupMembersFilterSearch) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterSearch#9ae39fbb to nil")
	}
	if err := b.ConsumeID(SupergroupMembersFilterSearchTypeID); err != nil {
		return fmt.Errorf("unable to decode supergroupMembersFilterSearch#9ae39fbb: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *SupergroupMembersFilterSearch) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterSearch#9ae39fbb to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode supergroupMembersFilterSearch#9ae39fbb: field query: %w", err)
		}
		s.Query = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SupergroupMembersFilterSearch) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterSearch#9ae39fbb as nil")
	}
	b.ObjStart()
	b.PutID("supergroupMembersFilterSearch")
	b.Comma()
	b.FieldStart("query")
	b.PutString(s.Query)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SupergroupMembersFilterSearch) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterSearch#9ae39fbb to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("supergroupMembersFilterSearch"); err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterSearch#9ae39fbb: %w", err)
			}
		case "query":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterSearch#9ae39fbb: field query: %w", err)
			}
			s.Query = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetQuery returns value of Query field.
func (s *SupergroupMembersFilterSearch) GetQuery() (value string) {
	if s == nil {
		return
	}
	return s.Query
}

// SupergroupMembersFilterRestricted represents TL type `supergroupMembersFilterRestricted#bdf8501e`.
type SupergroupMembersFilterRestricted struct {
	// Query to search for
	Query string
}

// SupergroupMembersFilterRestrictedTypeID is TL type id of SupergroupMembersFilterRestricted.
const SupergroupMembersFilterRestrictedTypeID = 0xbdf8501e

// construct implements constructor of SupergroupMembersFilterClass.
func (s SupergroupMembersFilterRestricted) construct() SupergroupMembersFilterClass { return &s }

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

	_ SupergroupMembersFilterClass = &SupergroupMembersFilterRestricted{}
)

func (s *SupergroupMembersFilterRestricted) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.Query == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *SupergroupMembersFilterRestricted) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "supergroupMembersFilterRestricted",
		ID:   SupergroupMembersFilterRestrictedTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Query",
			SchemaName: "query",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *SupergroupMembersFilterRestricted) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterRestricted#bdf8501e as nil")
	}
	b.PutID(SupergroupMembersFilterRestrictedTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *SupergroupMembersFilterRestricted) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterRestricted#bdf8501e as nil")
	}
	b.PutString(s.Query)
	return nil
}

// Decode implements bin.Decoder.
func (s *SupergroupMembersFilterRestricted) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterRestricted#bdf8501e to nil")
	}
	if err := b.ConsumeID(SupergroupMembersFilterRestrictedTypeID); err != nil {
		return fmt.Errorf("unable to decode supergroupMembersFilterRestricted#bdf8501e: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *SupergroupMembersFilterRestricted) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterRestricted#bdf8501e to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode supergroupMembersFilterRestricted#bdf8501e: field query: %w", err)
		}
		s.Query = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SupergroupMembersFilterRestricted) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterRestricted#bdf8501e as nil")
	}
	b.ObjStart()
	b.PutID("supergroupMembersFilterRestricted")
	b.Comma()
	b.FieldStart("query")
	b.PutString(s.Query)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SupergroupMembersFilterRestricted) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterRestricted#bdf8501e to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("supergroupMembersFilterRestricted"); err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterRestricted#bdf8501e: %w", err)
			}
		case "query":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterRestricted#bdf8501e: field query: %w", err)
			}
			s.Query = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetQuery returns value of Query field.
func (s *SupergroupMembersFilterRestricted) GetQuery() (value string) {
	if s == nil {
		return
	}
	return s.Query
}

// SupergroupMembersFilterBanned represents TL type `supergroupMembersFilterBanned#b7d7610d`.
type SupergroupMembersFilterBanned struct {
	// Query to search for
	Query string
}

// SupergroupMembersFilterBannedTypeID is TL type id of SupergroupMembersFilterBanned.
const SupergroupMembersFilterBannedTypeID = 0xb7d7610d

// construct implements constructor of SupergroupMembersFilterClass.
func (s SupergroupMembersFilterBanned) construct() SupergroupMembersFilterClass { return &s }

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

	_ SupergroupMembersFilterClass = &SupergroupMembersFilterBanned{}
)

func (s *SupergroupMembersFilterBanned) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.Query == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *SupergroupMembersFilterBanned) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "supergroupMembersFilterBanned",
		ID:   SupergroupMembersFilterBannedTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Query",
			SchemaName: "query",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *SupergroupMembersFilterBanned) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterBanned#b7d7610d as nil")
	}
	b.PutID(SupergroupMembersFilterBannedTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *SupergroupMembersFilterBanned) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterBanned#b7d7610d as nil")
	}
	b.PutString(s.Query)
	return nil
}

// Decode implements bin.Decoder.
func (s *SupergroupMembersFilterBanned) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterBanned#b7d7610d to nil")
	}
	if err := b.ConsumeID(SupergroupMembersFilterBannedTypeID); err != nil {
		return fmt.Errorf("unable to decode supergroupMembersFilterBanned#b7d7610d: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *SupergroupMembersFilterBanned) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterBanned#b7d7610d to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode supergroupMembersFilterBanned#b7d7610d: field query: %w", err)
		}
		s.Query = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SupergroupMembersFilterBanned) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterBanned#b7d7610d as nil")
	}
	b.ObjStart()
	b.PutID("supergroupMembersFilterBanned")
	b.Comma()
	b.FieldStart("query")
	b.PutString(s.Query)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SupergroupMembersFilterBanned) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterBanned#b7d7610d to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("supergroupMembersFilterBanned"); err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterBanned#b7d7610d: %w", err)
			}
		case "query":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterBanned#b7d7610d: field query: %w", err)
			}
			s.Query = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetQuery returns value of Query field.
func (s *SupergroupMembersFilterBanned) GetQuery() (value string) {
	if s == nil {
		return
	}
	return s.Query
}

// SupergroupMembersFilterMention represents TL type `supergroupMembersFilterMention#3880091c`.
type SupergroupMembersFilterMention struct {
	// Query to search for
	Query string
	// If non-zero, the identifier of the current message thread
	MessageThreadID int64
}

// SupergroupMembersFilterMentionTypeID is TL type id of SupergroupMembersFilterMention.
const SupergroupMembersFilterMentionTypeID = 0x3880091c

// construct implements constructor of SupergroupMembersFilterClass.
func (s SupergroupMembersFilterMention) construct() SupergroupMembersFilterClass { return &s }

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

	_ SupergroupMembersFilterClass = &SupergroupMembersFilterMention{}
)

func (s *SupergroupMembersFilterMention) Zero() bool {
	if s == nil {
		return true
	}
	if !(s.Query == "") {
		return false
	}
	if !(s.MessageThreadID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *SupergroupMembersFilterMention) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "supergroupMembersFilterMention",
		ID:   SupergroupMembersFilterMentionTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Query",
			SchemaName: "query",
		},
		{
			Name:       "MessageThreadID",
			SchemaName: "message_thread_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (s *SupergroupMembersFilterMention) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterMention#3880091c as nil")
	}
	b.PutID(SupergroupMembersFilterMentionTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *SupergroupMembersFilterMention) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterMention#3880091c as nil")
	}
	b.PutString(s.Query)
	b.PutInt53(s.MessageThreadID)
	return nil
}

// Decode implements bin.Decoder.
func (s *SupergroupMembersFilterMention) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterMention#3880091c to nil")
	}
	if err := b.ConsumeID(SupergroupMembersFilterMentionTypeID); err != nil {
		return fmt.Errorf("unable to decode supergroupMembersFilterMention#3880091c: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *SupergroupMembersFilterMention) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterMention#3880091c to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode supergroupMembersFilterMention#3880091c: field query: %w", err)
		}
		s.Query = value
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode supergroupMembersFilterMention#3880091c: field message_thread_id: %w", err)
		}
		s.MessageThreadID = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SupergroupMembersFilterMention) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterMention#3880091c as nil")
	}
	b.ObjStart()
	b.PutID("supergroupMembersFilterMention")
	b.Comma()
	b.FieldStart("query")
	b.PutString(s.Query)
	b.Comma()
	b.FieldStart("message_thread_id")
	b.PutInt53(s.MessageThreadID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SupergroupMembersFilterMention) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterMention#3880091c to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("supergroupMembersFilterMention"); err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterMention#3880091c: %w", err)
			}
		case "query":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterMention#3880091c: field query: %w", err)
			}
			s.Query = value
		case "message_thread_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterMention#3880091c: field message_thread_id: %w", err)
			}
			s.MessageThreadID = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetQuery returns value of Query field.
func (s *SupergroupMembersFilterMention) GetQuery() (value string) {
	if s == nil {
		return
	}
	return s.Query
}

// GetMessageThreadID returns value of MessageThreadID field.
func (s *SupergroupMembersFilterMention) GetMessageThreadID() (value int64) {
	if s == nil {
		return
	}
	return s.MessageThreadID
}

// SupergroupMembersFilterBots represents TL type `supergroupMembersFilterBots#1d5571a6`.
type SupergroupMembersFilterBots struct {
}

// SupergroupMembersFilterBotsTypeID is TL type id of SupergroupMembersFilterBots.
const SupergroupMembersFilterBotsTypeID = 0x1d5571a6

// construct implements constructor of SupergroupMembersFilterClass.
func (s SupergroupMembersFilterBots) construct() SupergroupMembersFilterClass { return &s }

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

	_ SupergroupMembersFilterClass = &SupergroupMembersFilterBots{}
)

func (s *SupergroupMembersFilterBots) Zero() bool {
	if s == nil {
		return true
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (s *SupergroupMembersFilterBots) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "supergroupMembersFilterBots",
		ID:   SupergroupMembersFilterBotsTypeID,
	}
	if s == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{}
	return typ
}

// Encode implements bin.Encoder.
func (s *SupergroupMembersFilterBots) Encode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterBots#1d5571a6 as nil")
	}
	b.PutID(SupergroupMembersFilterBotsTypeID)
	return s.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (s *SupergroupMembersFilterBots) EncodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterBots#1d5571a6 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (s *SupergroupMembersFilterBots) Decode(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterBots#1d5571a6 to nil")
	}
	if err := b.ConsumeID(SupergroupMembersFilterBotsTypeID); err != nil {
		return fmt.Errorf("unable to decode supergroupMembersFilterBots#1d5571a6: %w", err)
	}
	return s.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (s *SupergroupMembersFilterBots) DecodeBare(b *bin.Buffer) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterBots#1d5571a6 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (s *SupergroupMembersFilterBots) EncodeTDLibJSON(b tdjson.Encoder) error {
	if s == nil {
		return fmt.Errorf("can't encode supergroupMembersFilterBots#1d5571a6 as nil")
	}
	b.ObjStart()
	b.PutID("supergroupMembersFilterBots")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (s *SupergroupMembersFilterBots) DecodeTDLibJSON(b tdjson.Decoder) error {
	if s == nil {
		return fmt.Errorf("can't decode supergroupMembersFilterBots#1d5571a6 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("supergroupMembersFilterBots"); err != nil {
				return fmt.Errorf("unable to decode supergroupMembersFilterBots#1d5571a6: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// SupergroupMembersFilterClassName is schema name of SupergroupMembersFilterClass.
const SupergroupMembersFilterClassName = "SupergroupMembersFilter"

// SupergroupMembersFilterClass represents SupergroupMembersFilter generic type.
//
// Example:
//
//	g, err := tdapi.DecodeSupergroupMembersFilter(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.SupergroupMembersFilterRecent: // supergroupMembersFilterRecent#4639e5d5
//	case *tdapi.SupergroupMembersFilterContacts: // supergroupMembersFilterContacts#b3885578
//	case *tdapi.SupergroupMembersFilterAdministrators: // supergroupMembersFilterAdministrators#82fc8457
//	case *tdapi.SupergroupMembersFilterSearch: // supergroupMembersFilterSearch#9ae39fbb
//	case *tdapi.SupergroupMembersFilterRestricted: // supergroupMembersFilterRestricted#bdf8501e
//	case *tdapi.SupergroupMembersFilterBanned: // supergroupMembersFilterBanned#b7d7610d
//	case *tdapi.SupergroupMembersFilterMention: // supergroupMembersFilterMention#3880091c
//	case *tdapi.SupergroupMembersFilterBots: // supergroupMembersFilterBots#1d5571a6
//	default: panic(v)
//	}
type SupergroupMembersFilterClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() SupergroupMembersFilterClass

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

	EncodeTDLibJSON(b tdjson.Encoder) error
	DecodeTDLibJSON(b tdjson.Decoder) error
}

// DecodeSupergroupMembersFilter implements binary de-serialization for SupergroupMembersFilterClass.
func DecodeSupergroupMembersFilter(buf *bin.Buffer) (SupergroupMembersFilterClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case SupergroupMembersFilterRecentTypeID:
		// Decoding supergroupMembersFilterRecent#4639e5d5.
		v := SupergroupMembersFilterRecent{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case SupergroupMembersFilterContactsTypeID:
		// Decoding supergroupMembersFilterContacts#b3885578.
		v := SupergroupMembersFilterContacts{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case SupergroupMembersFilterAdministratorsTypeID:
		// Decoding supergroupMembersFilterAdministrators#82fc8457.
		v := SupergroupMembersFilterAdministrators{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case SupergroupMembersFilterSearchTypeID:
		// Decoding supergroupMembersFilterSearch#9ae39fbb.
		v := SupergroupMembersFilterSearch{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case SupergroupMembersFilterRestrictedTypeID:
		// Decoding supergroupMembersFilterRestricted#bdf8501e.
		v := SupergroupMembersFilterRestricted{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case SupergroupMembersFilterBannedTypeID:
		// Decoding supergroupMembersFilterBanned#b7d7610d.
		v := SupergroupMembersFilterBanned{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case SupergroupMembersFilterMentionTypeID:
		// Decoding supergroupMembersFilterMention#3880091c.
		v := SupergroupMembersFilterMention{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case SupergroupMembersFilterBotsTypeID:
		// Decoding supergroupMembersFilterBots#1d5571a6.
		v := SupergroupMembersFilterBots{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONSupergroupMembersFilter implements binary de-serialization for SupergroupMembersFilterClass.
func DecodeTDLibJSONSupergroupMembersFilter(buf tdjson.Decoder) (SupergroupMembersFilterClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "supergroupMembersFilterRecent":
		// Decoding supergroupMembersFilterRecent#4639e5d5.
		v := SupergroupMembersFilterRecent{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case "supergroupMembersFilterContacts":
		// Decoding supergroupMembersFilterContacts#b3885578.
		v := SupergroupMembersFilterContacts{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case "supergroupMembersFilterAdministrators":
		// Decoding supergroupMembersFilterAdministrators#82fc8457.
		v := SupergroupMembersFilterAdministrators{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case "supergroupMembersFilterSearch":
		// Decoding supergroupMembersFilterSearch#9ae39fbb.
		v := SupergroupMembersFilterSearch{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case "supergroupMembersFilterRestricted":
		// Decoding supergroupMembersFilterRestricted#bdf8501e.
		v := SupergroupMembersFilterRestricted{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case "supergroupMembersFilterBanned":
		// Decoding supergroupMembersFilterBanned#b7d7610d.
		v := SupergroupMembersFilterBanned{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case "supergroupMembersFilterMention":
		// Decoding supergroupMembersFilterMention#3880091c.
		v := SupergroupMembersFilterMention{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	case "supergroupMembersFilterBots":
		// Decoding supergroupMembersFilterBots#1d5571a6.
		v := SupergroupMembersFilterBots{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode SupergroupMembersFilterClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// SupergroupMembersFilter boxes the SupergroupMembersFilterClass providing a helper.
type SupergroupMembersFilterBox struct {
	SupergroupMembersFilter SupergroupMembersFilterClass
}

// Decode implements bin.Decoder for SupergroupMembersFilterBox.
func (b *SupergroupMembersFilterBox) Decode(buf *bin.Buffer) error {
	if b == nil {
		return fmt.Errorf("unable to decode SupergroupMembersFilterBox to nil")
	}
	v, err := DecodeSupergroupMembersFilter(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.SupergroupMembersFilter = v
	return nil
}

// Encode implements bin.Encode for SupergroupMembersFilterBox.
func (b *SupergroupMembersFilterBox) Encode(buf *bin.Buffer) error {
	if b == nil || b.SupergroupMembersFilter == nil {
		return fmt.Errorf("unable to encode SupergroupMembersFilterClass as nil")
	}
	return b.SupergroupMembersFilter.Encode(buf)
}

// DecodeTDLibJSON implements bin.Decoder for SupergroupMembersFilterBox.
func (b *SupergroupMembersFilterBox) DecodeTDLibJSON(buf tdjson.Decoder) error {
	if b == nil {
		return fmt.Errorf("unable to decode SupergroupMembersFilterBox to nil")
	}
	v, err := DecodeTDLibJSONSupergroupMembersFilter(buf)
	if err != nil {
		return fmt.Errorf("unable to decode boxed value: %w", err)
	}
	b.SupergroupMembersFilter = v
	return nil
}

// EncodeTDLibJSON implements bin.Encode for SupergroupMembersFilterBox.
func (b *SupergroupMembersFilterBox) EncodeTDLibJSON(buf tdjson.Encoder) error {
	if b == nil || b.SupergroupMembersFilter == nil {
		return fmt.Errorf("unable to encode SupergroupMembersFilterClass as nil")
	}
	return b.SupergroupMembersFilter.EncodeTDLibJSON(buf)
}
