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

// EmojiCategoryTypeDefault represents TL type `emojiCategoryTypeDefault#46db626b`.
type EmojiCategoryTypeDefault struct {
}

// EmojiCategoryTypeDefaultTypeID is TL type id of EmojiCategoryTypeDefault.
const EmojiCategoryTypeDefaultTypeID = 0x46db626b

// construct implements constructor of EmojiCategoryTypeClass.
func (e EmojiCategoryTypeDefault) construct() EmojiCategoryTypeClass { return &e }

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

	_ EmojiCategoryTypeClass = &EmojiCategoryTypeDefault{}
)

func (e *EmojiCategoryTypeDefault) Zero() bool {
	if e == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (e *EmojiCategoryTypeDefault) Encode(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeDefault#46db626b as nil")
	}
	b.PutID(EmojiCategoryTypeDefaultTypeID)
	return e.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (e *EmojiCategoryTypeDefault) EncodeBare(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeDefault#46db626b as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (e *EmojiCategoryTypeDefault) Decode(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeDefault#46db626b to nil")
	}
	if err := b.ConsumeID(EmojiCategoryTypeDefaultTypeID); err != nil {
		return fmt.Errorf("unable to decode emojiCategoryTypeDefault#46db626b: %w", err)
	}
	return e.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (e *EmojiCategoryTypeDefault) DecodeBare(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeDefault#46db626b to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (e *EmojiCategoryTypeDefault) EncodeTDLibJSON(b tdjson.Encoder) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeDefault#46db626b as nil")
	}
	b.ObjStart()
	b.PutID("emojiCategoryTypeDefault")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (e *EmojiCategoryTypeDefault) DecodeTDLibJSON(b tdjson.Decoder) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeDefault#46db626b to nil")
	}

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

// EmojiCategoryTypeRegularStickers represents TL type `emojiCategoryTypeRegularStickers#b04799d2`.
type EmojiCategoryTypeRegularStickers struct {
}

// EmojiCategoryTypeRegularStickersTypeID is TL type id of EmojiCategoryTypeRegularStickers.
const EmojiCategoryTypeRegularStickersTypeID = 0xb04799d2

// construct implements constructor of EmojiCategoryTypeClass.
func (e EmojiCategoryTypeRegularStickers) construct() EmojiCategoryTypeClass { return &e }

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

	_ EmojiCategoryTypeClass = &EmojiCategoryTypeRegularStickers{}
)

func (e *EmojiCategoryTypeRegularStickers) Zero() bool {
	if e == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (e *EmojiCategoryTypeRegularStickers) Encode(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeRegularStickers#b04799d2 as nil")
	}
	b.PutID(EmojiCategoryTypeRegularStickersTypeID)
	return e.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (e *EmojiCategoryTypeRegularStickers) EncodeBare(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeRegularStickers#b04799d2 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (e *EmojiCategoryTypeRegularStickers) Decode(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeRegularStickers#b04799d2 to nil")
	}
	if err := b.ConsumeID(EmojiCategoryTypeRegularStickersTypeID); err != nil {
		return fmt.Errorf("unable to decode emojiCategoryTypeRegularStickers#b04799d2: %w", err)
	}
	return e.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (e *EmojiCategoryTypeRegularStickers) DecodeBare(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeRegularStickers#b04799d2 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (e *EmojiCategoryTypeRegularStickers) EncodeTDLibJSON(b tdjson.Encoder) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeRegularStickers#b04799d2 as nil")
	}
	b.ObjStart()
	b.PutID("emojiCategoryTypeRegularStickers")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (e *EmojiCategoryTypeRegularStickers) DecodeTDLibJSON(b tdjson.Decoder) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeRegularStickers#b04799d2 to nil")
	}

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

// EmojiCategoryTypeEmojiStatus represents TL type `emojiCategoryTypeEmojiStatus#5254b347`.
type EmojiCategoryTypeEmojiStatus struct {
}

// EmojiCategoryTypeEmojiStatusTypeID is TL type id of EmojiCategoryTypeEmojiStatus.
const EmojiCategoryTypeEmojiStatusTypeID = 0x5254b347

// construct implements constructor of EmojiCategoryTypeClass.
func (e EmojiCategoryTypeEmojiStatus) construct() EmojiCategoryTypeClass { return &e }

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

	_ EmojiCategoryTypeClass = &EmojiCategoryTypeEmojiStatus{}
)

func (e *EmojiCategoryTypeEmojiStatus) Zero() bool {
	if e == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (e *EmojiCategoryTypeEmojiStatus) Encode(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeEmojiStatus#5254b347 as nil")
	}
	b.PutID(EmojiCategoryTypeEmojiStatusTypeID)
	return e.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (e *EmojiCategoryTypeEmojiStatus) EncodeBare(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeEmojiStatus#5254b347 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (e *EmojiCategoryTypeEmojiStatus) Decode(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeEmojiStatus#5254b347 to nil")
	}
	if err := b.ConsumeID(EmojiCategoryTypeEmojiStatusTypeID); err != nil {
		return fmt.Errorf("unable to decode emojiCategoryTypeEmojiStatus#5254b347: %w", err)
	}
	return e.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (e *EmojiCategoryTypeEmojiStatus) DecodeBare(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeEmojiStatus#5254b347 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (e *EmojiCategoryTypeEmojiStatus) EncodeTDLibJSON(b tdjson.Encoder) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeEmojiStatus#5254b347 as nil")
	}
	b.ObjStart()
	b.PutID("emojiCategoryTypeEmojiStatus")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (e *EmojiCategoryTypeEmojiStatus) DecodeTDLibJSON(b tdjson.Decoder) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeEmojiStatus#5254b347 to nil")
	}

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

// EmojiCategoryTypeChatPhoto represents TL type `emojiCategoryTypeChatPhoto#3f200529`.
type EmojiCategoryTypeChatPhoto struct {
}

// EmojiCategoryTypeChatPhotoTypeID is TL type id of EmojiCategoryTypeChatPhoto.
const EmojiCategoryTypeChatPhotoTypeID = 0x3f200529

// construct implements constructor of EmojiCategoryTypeClass.
func (e EmojiCategoryTypeChatPhoto) construct() EmojiCategoryTypeClass { return &e }

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

	_ EmojiCategoryTypeClass = &EmojiCategoryTypeChatPhoto{}
)

func (e *EmojiCategoryTypeChatPhoto) Zero() bool {
	if e == nil {
		return true
	}

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func (e *EmojiCategoryTypeChatPhoto) Encode(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeChatPhoto#3f200529 as nil")
	}
	b.PutID(EmojiCategoryTypeChatPhotoTypeID)
	return e.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (e *EmojiCategoryTypeChatPhoto) EncodeBare(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeChatPhoto#3f200529 as nil")
	}
	return nil
}

// Decode implements bin.Decoder.
func (e *EmojiCategoryTypeChatPhoto) Decode(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeChatPhoto#3f200529 to nil")
	}
	if err := b.ConsumeID(EmojiCategoryTypeChatPhotoTypeID); err != nil {
		return fmt.Errorf("unable to decode emojiCategoryTypeChatPhoto#3f200529: %w", err)
	}
	return e.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (e *EmojiCategoryTypeChatPhoto) DecodeBare(b *bin.Buffer) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeChatPhoto#3f200529 to nil")
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (e *EmojiCategoryTypeChatPhoto) EncodeTDLibJSON(b tdjson.Encoder) error {
	if e == nil {
		return fmt.Errorf("can't encode emojiCategoryTypeChatPhoto#3f200529 as nil")
	}
	b.ObjStart()
	b.PutID("emojiCategoryTypeChatPhoto")
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (e *EmojiCategoryTypeChatPhoto) DecodeTDLibJSON(b tdjson.Decoder) error {
	if e == nil {
		return fmt.Errorf("can't decode emojiCategoryTypeChatPhoto#3f200529 to nil")
	}

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

// EmojiCategoryTypeClassName is schema name of EmojiCategoryTypeClass.
const EmojiCategoryTypeClassName = "EmojiCategoryType"

// EmojiCategoryTypeClass represents EmojiCategoryType generic type.
//
// Example:
//
//	g, err := tdapi.DecodeEmojiCategoryType(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.EmojiCategoryTypeDefault: // emojiCategoryTypeDefault#46db626b
//	case *tdapi.EmojiCategoryTypeRegularStickers: // emojiCategoryTypeRegularStickers#b04799d2
//	case *tdapi.EmojiCategoryTypeEmojiStatus: // emojiCategoryTypeEmojiStatus#5254b347
//	case *tdapi.EmojiCategoryTypeChatPhoto: // emojiCategoryTypeChatPhoto#3f200529
//	default: panic(v)
//	}
type EmojiCategoryTypeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() EmojiCategoryTypeClass

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

// DecodeEmojiCategoryType implements binary de-serialization for EmojiCategoryTypeClass.
func DecodeEmojiCategoryType(buf *bin.Buffer) (EmojiCategoryTypeClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case EmojiCategoryTypeDefaultTypeID:
		// Decoding emojiCategoryTypeDefault#46db626b.
		v := EmojiCategoryTypeDefault{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode EmojiCategoryTypeClass: %w", err)
		}
		return &v, nil
	case EmojiCategoryTypeRegularStickersTypeID:
		// Decoding emojiCategoryTypeRegularStickers#b04799d2.
		v := EmojiCategoryTypeRegularStickers{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode EmojiCategoryTypeClass: %w", err)
		}
		return &v, nil
	case EmojiCategoryTypeEmojiStatusTypeID:
		// Decoding emojiCategoryTypeEmojiStatus#5254b347.
		v := EmojiCategoryTypeEmojiStatus{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode EmojiCategoryTypeClass: %w", err)
		}
		return &v, nil
	case EmojiCategoryTypeChatPhotoTypeID:
		// Decoding emojiCategoryTypeChatPhoto#3f200529.
		v := EmojiCategoryTypeChatPhoto{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode EmojiCategoryTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode EmojiCategoryTypeClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONEmojiCategoryType implements binary de-serialization for EmojiCategoryTypeClass.
func DecodeTDLibJSONEmojiCategoryType(buf tdjson.Decoder) (EmojiCategoryTypeClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "emojiCategoryTypeDefault":
		// Decoding emojiCategoryTypeDefault#46db626b.
		v := EmojiCategoryTypeDefault{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode EmojiCategoryTypeClass: %w", err)
		}
		return &v, nil
	case "emojiCategoryTypeRegularStickers":
		// Decoding emojiCategoryTypeRegularStickers#b04799d2.
		v := EmojiCategoryTypeRegularStickers{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode EmojiCategoryTypeClass: %w", err)
		}
		return &v, nil
	case "emojiCategoryTypeEmojiStatus":
		// Decoding emojiCategoryTypeEmojiStatus#5254b347.
		v := EmojiCategoryTypeEmojiStatus{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode EmojiCategoryTypeClass: %w", err)
		}
		return &v, nil
	case "emojiCategoryTypeChatPhoto":
		// Decoding emojiCategoryTypeChatPhoto#3f200529.
		v := EmojiCategoryTypeChatPhoto{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode EmojiCategoryTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode EmojiCategoryTypeClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// EmojiCategoryType boxes the EmojiCategoryTypeClass providing a helper.
type EmojiCategoryTypeBox struct {
	EmojiCategoryType EmojiCategoryTypeClass
}

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

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

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

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