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

// InputStoryAreaTypeLocation represents TL type `inputStoryAreaTypeLocation#aa8b3f39`.
type InputStoryAreaTypeLocation struct {
	// The location
	Location Location
	// Address of the location; pass null if unknown
	Address LocationAddress
}

// InputStoryAreaTypeLocationTypeID is TL type id of InputStoryAreaTypeLocation.
const InputStoryAreaTypeLocationTypeID = 0xaa8b3f39

// construct implements constructor of InputStoryAreaTypeClass.
func (i InputStoryAreaTypeLocation) construct() InputStoryAreaTypeClass { return &i }

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

	_ InputStoryAreaTypeClass = &InputStoryAreaTypeLocation{}
)

func (i *InputStoryAreaTypeLocation) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.Location.Zero()) {
		return false
	}
	if !(i.Address.Zero()) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InputStoryAreaTypeLocation) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputStoryAreaTypeLocation",
		ID:   InputStoryAreaTypeLocationTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Location",
			SchemaName: "location",
		},
		{
			Name:       "Address",
			SchemaName: "address",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputStoryAreaTypeLocation) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeLocation#aa8b3f39 as nil")
	}
	b.PutID(InputStoryAreaTypeLocationTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputStoryAreaTypeLocation) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeLocation#aa8b3f39 as nil")
	}
	if err := i.Location.Encode(b); err != nil {
		return fmt.Errorf("unable to encode inputStoryAreaTypeLocation#aa8b3f39: field location: %w", err)
	}
	if err := i.Address.Encode(b); err != nil {
		return fmt.Errorf("unable to encode inputStoryAreaTypeLocation#aa8b3f39: field address: %w", err)
	}
	return nil
}

// Decode implements bin.Decoder.
func (i *InputStoryAreaTypeLocation) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeLocation#aa8b3f39 to nil")
	}
	if err := b.ConsumeID(InputStoryAreaTypeLocationTypeID); err != nil {
		return fmt.Errorf("unable to decode inputStoryAreaTypeLocation#aa8b3f39: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputStoryAreaTypeLocation) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeLocation#aa8b3f39 to nil")
	}
	{
		if err := i.Location.Decode(b); err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeLocation#aa8b3f39: field location: %w", err)
		}
	}
	{
		if err := i.Address.Decode(b); err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeLocation#aa8b3f39: field address: %w", err)
		}
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InputStoryAreaTypeLocation) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeLocation#aa8b3f39 as nil")
	}
	b.ObjStart()
	b.PutID("inputStoryAreaTypeLocation")
	b.Comma()
	b.FieldStart("location")
	if err := i.Location.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode inputStoryAreaTypeLocation#aa8b3f39: field location: %w", err)
	}
	b.Comma()
	b.FieldStart("address")
	if err := i.Address.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode inputStoryAreaTypeLocation#aa8b3f39: field address: %w", err)
	}
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InputStoryAreaTypeLocation) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeLocation#aa8b3f39 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inputStoryAreaTypeLocation"); err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeLocation#aa8b3f39: %w", err)
			}
		case "location":
			if err := i.Location.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeLocation#aa8b3f39: field location: %w", err)
			}
		case "address":
			if err := i.Address.DecodeTDLibJSON(b); err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeLocation#aa8b3f39: field address: %w", err)
			}
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetLocation returns value of Location field.
func (i *InputStoryAreaTypeLocation) GetLocation() (value Location) {
	if i == nil {
		return
	}
	return i.Location
}

// GetAddress returns value of Address field.
func (i *InputStoryAreaTypeLocation) GetAddress() (value LocationAddress) {
	if i == nil {
		return
	}
	return i.Address
}

// InputStoryAreaTypeFoundVenue represents TL type `inputStoryAreaTypeFoundVenue#accda496`.
type InputStoryAreaTypeFoundVenue struct {
	// Identifier of the inline query, used to found the venue
	QueryID int64
	// Identifier of the inline query result
	ResultID string
}

// InputStoryAreaTypeFoundVenueTypeID is TL type id of InputStoryAreaTypeFoundVenue.
const InputStoryAreaTypeFoundVenueTypeID = 0xaccda496

// construct implements constructor of InputStoryAreaTypeClass.
func (i InputStoryAreaTypeFoundVenue) construct() InputStoryAreaTypeClass { return &i }

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

	_ InputStoryAreaTypeClass = &InputStoryAreaTypeFoundVenue{}
)

func (i *InputStoryAreaTypeFoundVenue) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.QueryID == 0) {
		return false
	}
	if !(i.ResultID == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InputStoryAreaTypeFoundVenue) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputStoryAreaTypeFoundVenue",
		ID:   InputStoryAreaTypeFoundVenueTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "QueryID",
			SchemaName: "query_id",
		},
		{
			Name:       "ResultID",
			SchemaName: "result_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputStoryAreaTypeFoundVenue) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeFoundVenue#accda496 as nil")
	}
	b.PutID(InputStoryAreaTypeFoundVenueTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputStoryAreaTypeFoundVenue) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeFoundVenue#accda496 as nil")
	}
	b.PutLong(i.QueryID)
	b.PutString(i.ResultID)
	return nil
}

// Decode implements bin.Decoder.
func (i *InputStoryAreaTypeFoundVenue) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeFoundVenue#accda496 to nil")
	}
	if err := b.ConsumeID(InputStoryAreaTypeFoundVenueTypeID); err != nil {
		return fmt.Errorf("unable to decode inputStoryAreaTypeFoundVenue#accda496: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputStoryAreaTypeFoundVenue) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeFoundVenue#accda496 to nil")
	}
	{
		value, err := b.Long()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeFoundVenue#accda496: field query_id: %w", err)
		}
		i.QueryID = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeFoundVenue#accda496: field result_id: %w", err)
		}
		i.ResultID = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InputStoryAreaTypeFoundVenue) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeFoundVenue#accda496 as nil")
	}
	b.ObjStart()
	b.PutID("inputStoryAreaTypeFoundVenue")
	b.Comma()
	b.FieldStart("query_id")
	b.PutLong(i.QueryID)
	b.Comma()
	b.FieldStart("result_id")
	b.PutString(i.ResultID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InputStoryAreaTypeFoundVenue) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeFoundVenue#accda496 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inputStoryAreaTypeFoundVenue"); err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeFoundVenue#accda496: %w", err)
			}
		case "query_id":
			value, err := b.Long()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeFoundVenue#accda496: field query_id: %w", err)
			}
			i.QueryID = value
		case "result_id":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeFoundVenue#accda496: field result_id: %w", err)
			}
			i.ResultID = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetQueryID returns value of QueryID field.
func (i *InputStoryAreaTypeFoundVenue) GetQueryID() (value int64) {
	if i == nil {
		return
	}
	return i.QueryID
}

// GetResultID returns value of ResultID field.
func (i *InputStoryAreaTypeFoundVenue) GetResultID() (value string) {
	if i == nil {
		return
	}
	return i.ResultID
}

// InputStoryAreaTypePreviousVenue represents TL type `inputStoryAreaTypePreviousVenue#6e124e0c`.
type InputStoryAreaTypePreviousVenue struct {
	// Provider of the venue
	VenueProvider string
	// Identifier of the venue in the provider database
	VenueID string
}

// InputStoryAreaTypePreviousVenueTypeID is TL type id of InputStoryAreaTypePreviousVenue.
const InputStoryAreaTypePreviousVenueTypeID = 0x6e124e0c

// construct implements constructor of InputStoryAreaTypeClass.
func (i InputStoryAreaTypePreviousVenue) construct() InputStoryAreaTypeClass { return &i }

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

	_ InputStoryAreaTypeClass = &InputStoryAreaTypePreviousVenue{}
)

func (i *InputStoryAreaTypePreviousVenue) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.VenueProvider == "") {
		return false
	}
	if !(i.VenueID == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InputStoryAreaTypePreviousVenue) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputStoryAreaTypePreviousVenue",
		ID:   InputStoryAreaTypePreviousVenueTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "VenueProvider",
			SchemaName: "venue_provider",
		},
		{
			Name:       "VenueID",
			SchemaName: "venue_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputStoryAreaTypePreviousVenue) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypePreviousVenue#6e124e0c as nil")
	}
	b.PutID(InputStoryAreaTypePreviousVenueTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputStoryAreaTypePreviousVenue) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypePreviousVenue#6e124e0c as nil")
	}
	b.PutString(i.VenueProvider)
	b.PutString(i.VenueID)
	return nil
}

// Decode implements bin.Decoder.
func (i *InputStoryAreaTypePreviousVenue) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypePreviousVenue#6e124e0c to nil")
	}
	if err := b.ConsumeID(InputStoryAreaTypePreviousVenueTypeID); err != nil {
		return fmt.Errorf("unable to decode inputStoryAreaTypePreviousVenue#6e124e0c: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputStoryAreaTypePreviousVenue) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypePreviousVenue#6e124e0c to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypePreviousVenue#6e124e0c: field venue_provider: %w", err)
		}
		i.VenueProvider = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypePreviousVenue#6e124e0c: field venue_id: %w", err)
		}
		i.VenueID = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InputStoryAreaTypePreviousVenue) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypePreviousVenue#6e124e0c as nil")
	}
	b.ObjStart()
	b.PutID("inputStoryAreaTypePreviousVenue")
	b.Comma()
	b.FieldStart("venue_provider")
	b.PutString(i.VenueProvider)
	b.Comma()
	b.FieldStart("venue_id")
	b.PutString(i.VenueID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InputStoryAreaTypePreviousVenue) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypePreviousVenue#6e124e0c to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inputStoryAreaTypePreviousVenue"); err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypePreviousVenue#6e124e0c: %w", err)
			}
		case "venue_provider":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypePreviousVenue#6e124e0c: field venue_provider: %w", err)
			}
			i.VenueProvider = value
		case "venue_id":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypePreviousVenue#6e124e0c: field venue_id: %w", err)
			}
			i.VenueID = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetVenueProvider returns value of VenueProvider field.
func (i *InputStoryAreaTypePreviousVenue) GetVenueProvider() (value string) {
	if i == nil {
		return
	}
	return i.VenueProvider
}

// GetVenueID returns value of VenueID field.
func (i *InputStoryAreaTypePreviousVenue) GetVenueID() (value string) {
	if i == nil {
		return
	}
	return i.VenueID
}

// InputStoryAreaTypeSuggestedReaction represents TL type `inputStoryAreaTypeSuggestedReaction#7d4751d3`.
type InputStoryAreaTypeSuggestedReaction struct {
	// Type of the reaction
	ReactionType ReactionTypeClass
	// True, if reaction has a dark background
	IsDark bool
	// True, if reaction corner is flipped
	IsFlipped bool
}

// InputStoryAreaTypeSuggestedReactionTypeID is TL type id of InputStoryAreaTypeSuggestedReaction.
const InputStoryAreaTypeSuggestedReactionTypeID = 0x7d4751d3

// construct implements constructor of InputStoryAreaTypeClass.
func (i InputStoryAreaTypeSuggestedReaction) construct() InputStoryAreaTypeClass { return &i }

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

	_ InputStoryAreaTypeClass = &InputStoryAreaTypeSuggestedReaction{}
)

func (i *InputStoryAreaTypeSuggestedReaction) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.ReactionType == nil) {
		return false
	}
	if !(i.IsDark == false) {
		return false
	}
	if !(i.IsFlipped == false) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InputStoryAreaTypeSuggestedReaction) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputStoryAreaTypeSuggestedReaction",
		ID:   InputStoryAreaTypeSuggestedReactionTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ReactionType",
			SchemaName: "reaction_type",
		},
		{
			Name:       "IsDark",
			SchemaName: "is_dark",
		},
		{
			Name:       "IsFlipped",
			SchemaName: "is_flipped",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputStoryAreaTypeSuggestedReaction) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeSuggestedReaction#7d4751d3 as nil")
	}
	b.PutID(InputStoryAreaTypeSuggestedReactionTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputStoryAreaTypeSuggestedReaction) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeSuggestedReaction#7d4751d3 as nil")
	}
	if i.ReactionType == nil {
		return fmt.Errorf("unable to encode inputStoryAreaTypeSuggestedReaction#7d4751d3: field reaction_type is nil")
	}
	if err := i.ReactionType.Encode(b); err != nil {
		return fmt.Errorf("unable to encode inputStoryAreaTypeSuggestedReaction#7d4751d3: field reaction_type: %w", err)
	}
	b.PutBool(i.IsDark)
	b.PutBool(i.IsFlipped)
	return nil
}

// Decode implements bin.Decoder.
func (i *InputStoryAreaTypeSuggestedReaction) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeSuggestedReaction#7d4751d3 to nil")
	}
	if err := b.ConsumeID(InputStoryAreaTypeSuggestedReactionTypeID); err != nil {
		return fmt.Errorf("unable to decode inputStoryAreaTypeSuggestedReaction#7d4751d3: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputStoryAreaTypeSuggestedReaction) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeSuggestedReaction#7d4751d3 to nil")
	}
	{
		value, err := DecodeReactionType(b)
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeSuggestedReaction#7d4751d3: field reaction_type: %w", err)
		}
		i.ReactionType = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeSuggestedReaction#7d4751d3: field is_dark: %w", err)
		}
		i.IsDark = value
	}
	{
		value, err := b.Bool()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeSuggestedReaction#7d4751d3: field is_flipped: %w", err)
		}
		i.IsFlipped = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InputStoryAreaTypeSuggestedReaction) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeSuggestedReaction#7d4751d3 as nil")
	}
	b.ObjStart()
	b.PutID("inputStoryAreaTypeSuggestedReaction")
	b.Comma()
	b.FieldStart("reaction_type")
	if i.ReactionType == nil {
		return fmt.Errorf("unable to encode inputStoryAreaTypeSuggestedReaction#7d4751d3: field reaction_type is nil")
	}
	if err := i.ReactionType.EncodeTDLibJSON(b); err != nil {
		return fmt.Errorf("unable to encode inputStoryAreaTypeSuggestedReaction#7d4751d3: field reaction_type: %w", err)
	}
	b.Comma()
	b.FieldStart("is_dark")
	b.PutBool(i.IsDark)
	b.Comma()
	b.FieldStart("is_flipped")
	b.PutBool(i.IsFlipped)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InputStoryAreaTypeSuggestedReaction) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeSuggestedReaction#7d4751d3 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inputStoryAreaTypeSuggestedReaction"); err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeSuggestedReaction#7d4751d3: %w", err)
			}
		case "reaction_type":
			value, err := DecodeTDLibJSONReactionType(b)
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeSuggestedReaction#7d4751d3: field reaction_type: %w", err)
			}
			i.ReactionType = value
		case "is_dark":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeSuggestedReaction#7d4751d3: field is_dark: %w", err)
			}
			i.IsDark = value
		case "is_flipped":
			value, err := b.Bool()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeSuggestedReaction#7d4751d3: field is_flipped: %w", err)
			}
			i.IsFlipped = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetReactionType returns value of ReactionType field.
func (i *InputStoryAreaTypeSuggestedReaction) GetReactionType() (value ReactionTypeClass) {
	if i == nil {
		return
	}
	return i.ReactionType
}

// GetIsDark returns value of IsDark field.
func (i *InputStoryAreaTypeSuggestedReaction) GetIsDark() (value bool) {
	if i == nil {
		return
	}
	return i.IsDark
}

// GetIsFlipped returns value of IsFlipped field.
func (i *InputStoryAreaTypeSuggestedReaction) GetIsFlipped() (value bool) {
	if i == nil {
		return
	}
	return i.IsFlipped
}

// InputStoryAreaTypeMessage represents TL type `inputStoryAreaTypeMessage#f01be457`.
type InputStoryAreaTypeMessage struct {
	// Identifier of the chat with the message. Currently, the chat must be a supergroup or a
	// channel chat
	ChatID int64
	// Identifier of the message. Use messageProperties.can_be_shared_in_story to check
	// whether the message is suitable
	MessageID int64
}

// InputStoryAreaTypeMessageTypeID is TL type id of InputStoryAreaTypeMessage.
const InputStoryAreaTypeMessageTypeID = 0xf01be457

// construct implements constructor of InputStoryAreaTypeClass.
func (i InputStoryAreaTypeMessage) construct() InputStoryAreaTypeClass { return &i }

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

	_ InputStoryAreaTypeClass = &InputStoryAreaTypeMessage{}
)

func (i *InputStoryAreaTypeMessage) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.ChatID == 0) {
		return false
	}
	if !(i.MessageID == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InputStoryAreaTypeMessage) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputStoryAreaTypeMessage",
		ID:   InputStoryAreaTypeMessageTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "MessageID",
			SchemaName: "message_id",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputStoryAreaTypeMessage) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeMessage#f01be457 as nil")
	}
	b.PutID(InputStoryAreaTypeMessageTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputStoryAreaTypeMessage) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeMessage#f01be457 as nil")
	}
	b.PutInt53(i.ChatID)
	b.PutInt53(i.MessageID)
	return nil
}

// Decode implements bin.Decoder.
func (i *InputStoryAreaTypeMessage) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeMessage#f01be457 to nil")
	}
	if err := b.ConsumeID(InputStoryAreaTypeMessageTypeID); err != nil {
		return fmt.Errorf("unable to decode inputStoryAreaTypeMessage#f01be457: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputStoryAreaTypeMessage) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeMessage#f01be457 to nil")
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeMessage#f01be457: field chat_id: %w", err)
		}
		i.ChatID = value
	}
	{
		value, err := b.Int53()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeMessage#f01be457: field message_id: %w", err)
		}
		i.MessageID = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InputStoryAreaTypeMessage) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeMessage#f01be457 as nil")
	}
	b.ObjStart()
	b.PutID("inputStoryAreaTypeMessage")
	b.Comma()
	b.FieldStart("chat_id")
	b.PutInt53(i.ChatID)
	b.Comma()
	b.FieldStart("message_id")
	b.PutInt53(i.MessageID)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InputStoryAreaTypeMessage) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeMessage#f01be457 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inputStoryAreaTypeMessage"); err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeMessage#f01be457: %w", err)
			}
		case "chat_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeMessage#f01be457: field chat_id: %w", err)
			}
			i.ChatID = value
		case "message_id":
			value, err := b.Int53()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeMessage#f01be457: field message_id: %w", err)
			}
			i.MessageID = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetChatID returns value of ChatID field.
func (i *InputStoryAreaTypeMessage) GetChatID() (value int64) {
	if i == nil {
		return
	}
	return i.ChatID
}

// GetMessageID returns value of MessageID field.
func (i *InputStoryAreaTypeMessage) GetMessageID() (value int64) {
	if i == nil {
		return
	}
	return i.MessageID
}

// InputStoryAreaTypeLink represents TL type `inputStoryAreaTypeLink#53f31b48`.
type InputStoryAreaTypeLink struct {
	// HTTP or tg:// URL to be opened when the area is clicked
	URL string
}

// InputStoryAreaTypeLinkTypeID is TL type id of InputStoryAreaTypeLink.
const InputStoryAreaTypeLinkTypeID = 0x53f31b48

// construct implements constructor of InputStoryAreaTypeClass.
func (i InputStoryAreaTypeLink) construct() InputStoryAreaTypeClass { return &i }

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

	_ InputStoryAreaTypeClass = &InputStoryAreaTypeLink{}
)

func (i *InputStoryAreaTypeLink) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.URL == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InputStoryAreaTypeLink) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputStoryAreaTypeLink",
		ID:   InputStoryAreaTypeLinkTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "URL",
			SchemaName: "url",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputStoryAreaTypeLink) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeLink#53f31b48 as nil")
	}
	b.PutID(InputStoryAreaTypeLinkTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputStoryAreaTypeLink) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeLink#53f31b48 as nil")
	}
	b.PutString(i.URL)
	return nil
}

// Decode implements bin.Decoder.
func (i *InputStoryAreaTypeLink) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeLink#53f31b48 to nil")
	}
	if err := b.ConsumeID(InputStoryAreaTypeLinkTypeID); err != nil {
		return fmt.Errorf("unable to decode inputStoryAreaTypeLink#53f31b48: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputStoryAreaTypeLink) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeLink#53f31b48 to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeLink#53f31b48: field url: %w", err)
		}
		i.URL = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InputStoryAreaTypeLink) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeLink#53f31b48 as nil")
	}
	b.ObjStart()
	b.PutID("inputStoryAreaTypeLink")
	b.Comma()
	b.FieldStart("url")
	b.PutString(i.URL)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InputStoryAreaTypeLink) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeLink#53f31b48 to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inputStoryAreaTypeLink"); err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeLink#53f31b48: %w", err)
			}
		case "url":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeLink#53f31b48: field url: %w", err)
			}
			i.URL = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetURL returns value of URL field.
func (i *InputStoryAreaTypeLink) GetURL() (value string) {
	if i == nil {
		return
	}
	return i.URL
}

// InputStoryAreaTypeWeather represents TL type `inputStoryAreaTypeWeather#b7b7de9d`.
type InputStoryAreaTypeWeather struct {
	// Temperature, in degree Celsius
	Temperature float64
	// Emoji representing the weather
	Emoji string
	// A color of the area background in the ARGB format
	BackgroundColor int32
}

// InputStoryAreaTypeWeatherTypeID is TL type id of InputStoryAreaTypeWeather.
const InputStoryAreaTypeWeatherTypeID = 0xb7b7de9d

// construct implements constructor of InputStoryAreaTypeClass.
func (i InputStoryAreaTypeWeather) construct() InputStoryAreaTypeClass { return &i }

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

	_ InputStoryAreaTypeClass = &InputStoryAreaTypeWeather{}
)

func (i *InputStoryAreaTypeWeather) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.Temperature == 0) {
		return false
	}
	if !(i.Emoji == "") {
		return false
	}
	if !(i.BackgroundColor == 0) {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InputStoryAreaTypeWeather) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputStoryAreaTypeWeather",
		ID:   InputStoryAreaTypeWeatherTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "Temperature",
			SchemaName: "temperature",
		},
		{
			Name:       "Emoji",
			SchemaName: "emoji",
		},
		{
			Name:       "BackgroundColor",
			SchemaName: "background_color",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputStoryAreaTypeWeather) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeWeather#b7b7de9d as nil")
	}
	b.PutID(InputStoryAreaTypeWeatherTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputStoryAreaTypeWeather) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeWeather#b7b7de9d as nil")
	}
	b.PutDouble(i.Temperature)
	b.PutString(i.Emoji)
	b.PutInt32(i.BackgroundColor)
	return nil
}

// Decode implements bin.Decoder.
func (i *InputStoryAreaTypeWeather) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeWeather#b7b7de9d to nil")
	}
	if err := b.ConsumeID(InputStoryAreaTypeWeatherTypeID); err != nil {
		return fmt.Errorf("unable to decode inputStoryAreaTypeWeather#b7b7de9d: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputStoryAreaTypeWeather) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeWeather#b7b7de9d to nil")
	}
	{
		value, err := b.Double()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeWeather#b7b7de9d: field temperature: %w", err)
		}
		i.Temperature = value
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeWeather#b7b7de9d: field emoji: %w", err)
		}
		i.Emoji = value
	}
	{
		value, err := b.Int32()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeWeather#b7b7de9d: field background_color: %w", err)
		}
		i.BackgroundColor = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InputStoryAreaTypeWeather) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeWeather#b7b7de9d as nil")
	}
	b.ObjStart()
	b.PutID("inputStoryAreaTypeWeather")
	b.Comma()
	b.FieldStart("temperature")
	b.PutDouble(i.Temperature)
	b.Comma()
	b.FieldStart("emoji")
	b.PutString(i.Emoji)
	b.Comma()
	b.FieldStart("background_color")
	b.PutInt32(i.BackgroundColor)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InputStoryAreaTypeWeather) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeWeather#b7b7de9d to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inputStoryAreaTypeWeather"); err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeWeather#b7b7de9d: %w", err)
			}
		case "temperature":
			value, err := b.Double()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeWeather#b7b7de9d: field temperature: %w", err)
			}
			i.Temperature = value
		case "emoji":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeWeather#b7b7de9d: field emoji: %w", err)
			}
			i.Emoji = value
		case "background_color":
			value, err := b.Int32()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeWeather#b7b7de9d: field background_color: %w", err)
			}
			i.BackgroundColor = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetTemperature returns value of Temperature field.
func (i *InputStoryAreaTypeWeather) GetTemperature() (value float64) {
	if i == nil {
		return
	}
	return i.Temperature
}

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

// GetBackgroundColor returns value of BackgroundColor field.
func (i *InputStoryAreaTypeWeather) GetBackgroundColor() (value int32) {
	if i == nil {
		return
	}
	return i.BackgroundColor
}

// InputStoryAreaTypeUpgradedGift represents TL type `inputStoryAreaTypeUpgradedGift#2f45216e`.
type InputStoryAreaTypeUpgradedGift struct {
	// Unique name of the upgraded gift
	GiftName string
}

// InputStoryAreaTypeUpgradedGiftTypeID is TL type id of InputStoryAreaTypeUpgradedGift.
const InputStoryAreaTypeUpgradedGiftTypeID = 0x2f45216e

// construct implements constructor of InputStoryAreaTypeClass.
func (i InputStoryAreaTypeUpgradedGift) construct() InputStoryAreaTypeClass { return &i }

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

	_ InputStoryAreaTypeClass = &InputStoryAreaTypeUpgradedGift{}
)

func (i *InputStoryAreaTypeUpgradedGift) Zero() bool {
	if i == nil {
		return true
	}
	if !(i.GiftName == "") {
		return false
	}

	return true
}

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

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

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

// TypeInfo returns info about TL type.
func (i *InputStoryAreaTypeUpgradedGift) TypeInfo() tdp.Type {
	typ := tdp.Type{
		Name: "inputStoryAreaTypeUpgradedGift",
		ID:   InputStoryAreaTypeUpgradedGiftTypeID,
	}
	if i == nil {
		typ.Null = true
		return typ
	}
	typ.Fields = []tdp.Field{
		{
			Name:       "GiftName",
			SchemaName: "gift_name",
		},
	}
	return typ
}

// Encode implements bin.Encoder.
func (i *InputStoryAreaTypeUpgradedGift) Encode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeUpgradedGift#2f45216e as nil")
	}
	b.PutID(InputStoryAreaTypeUpgradedGiftTypeID)
	return i.EncodeBare(b)
}

// EncodeBare implements bin.BareEncoder.
func (i *InputStoryAreaTypeUpgradedGift) EncodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeUpgradedGift#2f45216e as nil")
	}
	b.PutString(i.GiftName)
	return nil
}

// Decode implements bin.Decoder.
func (i *InputStoryAreaTypeUpgradedGift) Decode(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeUpgradedGift#2f45216e to nil")
	}
	if err := b.ConsumeID(InputStoryAreaTypeUpgradedGiftTypeID); err != nil {
		return fmt.Errorf("unable to decode inputStoryAreaTypeUpgradedGift#2f45216e: %w", err)
	}
	return i.DecodeBare(b)
}

// DecodeBare implements bin.BareDecoder.
func (i *InputStoryAreaTypeUpgradedGift) DecodeBare(b *bin.Buffer) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeUpgradedGift#2f45216e to nil")
	}
	{
		value, err := b.String()
		if err != nil {
			return fmt.Errorf("unable to decode inputStoryAreaTypeUpgradedGift#2f45216e: field gift_name: %w", err)
		}
		i.GiftName = value
	}
	return nil
}

// EncodeTDLibJSON implements tdjson.TDLibEncoder.
func (i *InputStoryAreaTypeUpgradedGift) EncodeTDLibJSON(b tdjson.Encoder) error {
	if i == nil {
		return fmt.Errorf("can't encode inputStoryAreaTypeUpgradedGift#2f45216e as nil")
	}
	b.ObjStart()
	b.PutID("inputStoryAreaTypeUpgradedGift")
	b.Comma()
	b.FieldStart("gift_name")
	b.PutString(i.GiftName)
	b.Comma()
	b.StripComma()
	b.ObjEnd()
	return nil
}

// DecodeTDLibJSON implements tdjson.TDLibDecoder.
func (i *InputStoryAreaTypeUpgradedGift) DecodeTDLibJSON(b tdjson.Decoder) error {
	if i == nil {
		return fmt.Errorf("can't decode inputStoryAreaTypeUpgradedGift#2f45216e to nil")
	}

	return b.Obj(func(b tdjson.Decoder, key []byte) error {
		switch string(key) {
		case tdjson.TypeField:
			if err := b.ConsumeID("inputStoryAreaTypeUpgradedGift"); err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeUpgradedGift#2f45216e: %w", err)
			}
		case "gift_name":
			value, err := b.String()
			if err != nil {
				return fmt.Errorf("unable to decode inputStoryAreaTypeUpgradedGift#2f45216e: field gift_name: %w", err)
			}
			i.GiftName = value
		default:
			return b.Skip()
		}
		return nil
	})
}

// GetGiftName returns value of GiftName field.
func (i *InputStoryAreaTypeUpgradedGift) GetGiftName() (value string) {
	if i == nil {
		return
	}
	return i.GiftName
}

// InputStoryAreaTypeClassName is schema name of InputStoryAreaTypeClass.
const InputStoryAreaTypeClassName = "InputStoryAreaType"

// InputStoryAreaTypeClass represents InputStoryAreaType generic type.
//
// Example:
//
//	g, err := tdapi.DecodeInputStoryAreaType(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tdapi.InputStoryAreaTypeLocation: // inputStoryAreaTypeLocation#aa8b3f39
//	case *tdapi.InputStoryAreaTypeFoundVenue: // inputStoryAreaTypeFoundVenue#accda496
//	case *tdapi.InputStoryAreaTypePreviousVenue: // inputStoryAreaTypePreviousVenue#6e124e0c
//	case *tdapi.InputStoryAreaTypeSuggestedReaction: // inputStoryAreaTypeSuggestedReaction#7d4751d3
//	case *tdapi.InputStoryAreaTypeMessage: // inputStoryAreaTypeMessage#f01be457
//	case *tdapi.InputStoryAreaTypeLink: // inputStoryAreaTypeLink#53f31b48
//	case *tdapi.InputStoryAreaTypeWeather: // inputStoryAreaTypeWeather#b7b7de9d
//	case *tdapi.InputStoryAreaTypeUpgradedGift: // inputStoryAreaTypeUpgradedGift#2f45216e
//	default: panic(v)
//	}
type InputStoryAreaTypeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputStoryAreaTypeClass

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

// DecodeInputStoryAreaType implements binary de-serialization for InputStoryAreaTypeClass.
func DecodeInputStoryAreaType(buf *bin.Buffer) (InputStoryAreaTypeClass, error) {
	id, err := buf.PeekID()
	if err != nil {
		return nil, err
	}
	switch id {
	case InputStoryAreaTypeLocationTypeID:
		// Decoding inputStoryAreaTypeLocation#aa8b3f39.
		v := InputStoryAreaTypeLocation{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case InputStoryAreaTypeFoundVenueTypeID:
		// Decoding inputStoryAreaTypeFoundVenue#accda496.
		v := InputStoryAreaTypeFoundVenue{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case InputStoryAreaTypePreviousVenueTypeID:
		// Decoding inputStoryAreaTypePreviousVenue#6e124e0c.
		v := InputStoryAreaTypePreviousVenue{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case InputStoryAreaTypeSuggestedReactionTypeID:
		// Decoding inputStoryAreaTypeSuggestedReaction#7d4751d3.
		v := InputStoryAreaTypeSuggestedReaction{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case InputStoryAreaTypeMessageTypeID:
		// Decoding inputStoryAreaTypeMessage#f01be457.
		v := InputStoryAreaTypeMessage{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case InputStoryAreaTypeLinkTypeID:
		// Decoding inputStoryAreaTypeLink#53f31b48.
		v := InputStoryAreaTypeLink{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case InputStoryAreaTypeWeatherTypeID:
		// Decoding inputStoryAreaTypeWeather#b7b7de9d.
		v := InputStoryAreaTypeWeather{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case InputStoryAreaTypeUpgradedGiftTypeID:
		// Decoding inputStoryAreaTypeUpgradedGift#2f45216e.
		v := InputStoryAreaTypeUpgradedGift{}
		if err := v.Decode(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", bin.NewUnexpectedID(id))
	}
}

// DecodeTDLibJSONInputStoryAreaType implements binary de-serialization for InputStoryAreaTypeClass.
func DecodeTDLibJSONInputStoryAreaType(buf tdjson.Decoder) (InputStoryAreaTypeClass, error) {
	id, err := buf.FindTypeID()
	if err != nil {
		return nil, err
	}
	switch id {
	case "inputStoryAreaTypeLocation":
		// Decoding inputStoryAreaTypeLocation#aa8b3f39.
		v := InputStoryAreaTypeLocation{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case "inputStoryAreaTypeFoundVenue":
		// Decoding inputStoryAreaTypeFoundVenue#accda496.
		v := InputStoryAreaTypeFoundVenue{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case "inputStoryAreaTypePreviousVenue":
		// Decoding inputStoryAreaTypePreviousVenue#6e124e0c.
		v := InputStoryAreaTypePreviousVenue{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case "inputStoryAreaTypeSuggestedReaction":
		// Decoding inputStoryAreaTypeSuggestedReaction#7d4751d3.
		v := InputStoryAreaTypeSuggestedReaction{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case "inputStoryAreaTypeMessage":
		// Decoding inputStoryAreaTypeMessage#f01be457.
		v := InputStoryAreaTypeMessage{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case "inputStoryAreaTypeLink":
		// Decoding inputStoryAreaTypeLink#53f31b48.
		v := InputStoryAreaTypeLink{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case "inputStoryAreaTypeWeather":
		// Decoding inputStoryAreaTypeWeather#b7b7de9d.
		v := InputStoryAreaTypeWeather{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	case "inputStoryAreaTypeUpgradedGift":
		// Decoding inputStoryAreaTypeUpgradedGift#2f45216e.
		v := InputStoryAreaTypeUpgradedGift{}
		if err := v.DecodeTDLibJSON(buf); err != nil {
			return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", err)
		}
		return &v, nil
	default:
		return nil, fmt.Errorf("unable to decode InputStoryAreaTypeClass: %w", tdjson.NewUnexpectedID(id))
	}
}

// InputStoryAreaType boxes the InputStoryAreaTypeClass providing a helper.
type InputStoryAreaTypeBox struct {
	InputStoryAreaType InputStoryAreaTypeClass
}

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

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

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

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