// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// Dialog represents TL type `dialog#d58a08c6`.
// Chat
//
// See https://core.telegram.org/constructor/dialog for reference.
type Dialog struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Is the dialog pinned
	Pinned bool
	// Whether the chat was manually marked as unread
	UnreadMark bool
	// Users may also choose to display messages from all topics of a forum¹ as if they were
	// sent to a normal group, using a "View as messages" setting in the local client.  This
	// setting only affects the current account, and is synced to other logged in sessions
	// using the channels.toggleViewForumAsMessages² method; invoking this method will
	// update the value of this flag.
	//
	// Links:
	//  1) https://core.telegram.org/api/forum
	//  2) https://core.telegram.org/method/channels.toggleViewForumAsMessages
	ViewForumAsMessages bool
	// The chat
	Peer PeerClass
	// The latest message ID
	TopMessage int
	// Position up to which all incoming messages are read.
	ReadInboxMaxID int
	// Position up to which all outgoing messages are read.
	ReadOutboxMaxID int
	// Number of unread messages
	UnreadCount int
	// Number of unread mentions¹
	//
	// Links:
	//  1) https://core.telegram.org/api/mentions
	UnreadMentionsCount int
	// Number of unread reactions to messages you sent
	UnreadReactionsCount int
	// Notification settings
	NotifySettings PeerNotifySettings
	// PTS¹
	//
	// Links:
	//  1) https://core.telegram.org/api/updates
	//
	// Use SetPts and GetPts helpers.
	Pts int
	// Message draft¹
	//
	// Links:
	//  1) https://core.telegram.org/api/drafts
	//
	// Use SetDraft and GetDraft helpers.
	Draft DraftMessageClass
	// Peer folder ID, for more info click here¹
	//
	// Links:
	//  1) https://core.telegram.org/api/folders#peer-folders
	//
	// Use SetFolderID and GetFolderID helpers.
	FolderID int
	// Time-to-live of all messages sent in this dialog
	//
	// Use SetTTLPeriod and GetTTLPeriod helpers.
	TTLPeriod int
}

// DialogTypeID is TL type id of Dialog.
const DialogTypeID = 0xd58a08c6

// construct implements constructor of DialogClass.
func ( Dialog) () DialogClass { return & }

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

	_ DialogClass = &Dialog{}
)

func ( *Dialog) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Pinned == false) {
		return false
	}
	if !(.UnreadMark == false) {
		return false
	}
	if !(.ViewForumAsMessages == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.TopMessage == 0) {
		return false
	}
	if !(.ReadInboxMaxID == 0) {
		return false
	}
	if !(.ReadOutboxMaxID == 0) {
		return false
	}
	if !(.UnreadCount == 0) {
		return false
	}
	if !(.UnreadMentionsCount == 0) {
		return false
	}
	if !(.UnreadReactionsCount == 0) {
		return false
	}
	if !(.NotifySettings.Zero()) {
		return false
	}
	if !(.Pts == 0) {
		return false
	}
	if !(.Draft == nil) {
		return false
	}
	if !(.FolderID == 0) {
		return false
	}
	if !(.TTLPeriod == 0) {
		return false
	}

	return true
}

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

// FillFrom fills Dialog from given interface.
func ( *Dialog) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( PeerClass)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
	() ( PeerNotifySettings)
	() ( int,  bool)
	() ( DraftMessageClass,  bool)
	() ( int,  bool)
	() ( int,  bool)
}) {
	.Pinned = .()
	.UnreadMark = .()
	.ViewForumAsMessages = .()
	.Peer = .()
	.TopMessage = .()
	.ReadInboxMaxID = .()
	.ReadOutboxMaxID = .()
	.UnreadCount = .()
	.UnreadMentionsCount = .()
	.UnreadReactionsCount = .()
	.NotifySettings = .()
	if ,  := .();  {
		.Pts = 
	}

	if ,  := .();  {
		.Draft = 
	}

	if ,  := .();  {
		.FolderID = 
	}

	if ,  := .();  {
		.TTLPeriod = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *Dialog) () tdp.Type {
	 := tdp.Type{
		Name: "dialog",
		ID:   DialogTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Pinned",
			SchemaName: "pinned",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "UnreadMark",
			SchemaName: "unread_mark",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "ViewForumAsMessages",
			SchemaName: "view_forum_as_messages",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "TopMessage",
			SchemaName: "top_message",
		},
		{
			Name:       "ReadInboxMaxID",
			SchemaName: "read_inbox_max_id",
		},
		{
			Name:       "ReadOutboxMaxID",
			SchemaName: "read_outbox_max_id",
		},
		{
			Name:       "UnreadCount",
			SchemaName: "unread_count",
		},
		{
			Name:       "UnreadMentionsCount",
			SchemaName: "unread_mentions_count",
		},
		{
			Name:       "UnreadReactionsCount",
			SchemaName: "unread_reactions_count",
		},
		{
			Name:       "NotifySettings",
			SchemaName: "notify_settings",
		},
		{
			Name:       "Pts",
			SchemaName: "pts",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Draft",
			SchemaName: "draft",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "FolderID",
			SchemaName: "folder_id",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "TTLPeriod",
			SchemaName: "ttl_period",
			Null:       !.Flags.Has(5),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *Dialog) () {
	if !(.Pinned == false) {
		.Flags.Set(2)
	}
	if !(.UnreadMark == false) {
		.Flags.Set(3)
	}
	if !(.ViewForumAsMessages == false) {
		.Flags.Set(6)
	}
	if !(.Pts == 0) {
		.Flags.Set(0)
	}
	if !(.Draft == nil) {
		.Flags.Set(1)
	}
	if !(.FolderID == 0) {
		.Flags.Set(4)
	}
	if !(.TTLPeriod == 0) {
		.Flags.Set(5)
	}
}

// Encode implements bin.Encoder.
func ( *Dialog) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dialog#d58a08c6 as nil")
	}
	.PutID(DialogTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *Dialog) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dialog#d58a08c6 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode dialog#d58a08c6: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode dialog#d58a08c6: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode dialog#d58a08c6: field peer: %w", )
	}
	.PutInt(.TopMessage)
	.PutInt(.ReadInboxMaxID)
	.PutInt(.ReadOutboxMaxID)
	.PutInt(.UnreadCount)
	.PutInt(.UnreadMentionsCount)
	.PutInt(.UnreadReactionsCount)
	if  := .NotifySettings.Encode();  != nil {
		return fmt.Errorf("unable to encode dialog#d58a08c6: field notify_settings: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.Pts)
	}
	if .Flags.Has(1) {
		if .Draft == nil {
			return fmt.Errorf("unable to encode dialog#d58a08c6: field draft is nil")
		}
		if  := .Draft.Encode();  != nil {
			return fmt.Errorf("unable to encode dialog#d58a08c6: field draft: %w", )
		}
	}
	if .Flags.Has(4) {
		.PutInt(.FolderID)
	}
	if .Flags.Has(5) {
		.PutInt(.TTLPeriod)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *Dialog) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode dialog#d58a08c6 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field flags: %w", )
		}
	}
	.Pinned = .Flags.Has(2)
	.UnreadMark = .Flags.Has(3)
	.ViewForumAsMessages = .Flags.Has(6)
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field top_message: %w", )
		}
		.TopMessage = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field read_inbox_max_id: %w", )
		}
		.ReadInboxMaxID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field read_outbox_max_id: %w", )
		}
		.ReadOutboxMaxID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field unread_count: %w", )
		}
		.UnreadCount = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field unread_mentions_count: %w", )
		}
		.UnreadMentionsCount = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field unread_reactions_count: %w", )
		}
		.UnreadReactionsCount = 
	}
	{
		if  := .NotifySettings.Decode();  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field notify_settings: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field pts: %w", )
		}
		.Pts = 
	}
	if .Flags.Has(1) {
		,  := DecodeDraftMessage()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field draft: %w", )
		}
		.Draft = 
	}
	if .Flags.Has(4) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field folder_id: %w", )
		}
		.FolderID = 
	}
	if .Flags.Has(5) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialog#d58a08c6: field ttl_period: %w", )
		}
		.TTLPeriod = 
	}
	return nil
}

// SetPinned sets value of Pinned conditional field.
func ( *Dialog) ( bool) {
	if  {
		.Flags.Set(2)
		.Pinned = true
	} else {
		.Flags.Unset(2)
		.Pinned = false
	}
}

// GetPinned returns value of Pinned conditional field.
func ( *Dialog) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetUnreadMark sets value of UnreadMark conditional field.
func ( *Dialog) ( bool) {
	if  {
		.Flags.Set(3)
		.UnreadMark = true
	} else {
		.Flags.Unset(3)
		.UnreadMark = false
	}
}

// GetUnreadMark returns value of UnreadMark conditional field.
func ( *Dialog) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetViewForumAsMessages sets value of ViewForumAsMessages conditional field.
func ( *Dialog) ( bool) {
	if  {
		.Flags.Set(6)
		.ViewForumAsMessages = true
	} else {
		.Flags.Unset(6)
		.ViewForumAsMessages = false
	}
}

// GetViewForumAsMessages returns value of ViewForumAsMessages conditional field.
func ( *Dialog) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// GetPeer returns value of Peer field.
func ( *Dialog) () ( PeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetTopMessage returns value of TopMessage field.
func ( *Dialog) () ( int) {
	if  == nil {
		return
	}
	return .TopMessage
}

// GetReadInboxMaxID returns value of ReadInboxMaxID field.
func ( *Dialog) () ( int) {
	if  == nil {
		return
	}
	return .ReadInboxMaxID
}

// GetReadOutboxMaxID returns value of ReadOutboxMaxID field.
func ( *Dialog) () ( int) {
	if  == nil {
		return
	}
	return .ReadOutboxMaxID
}

// GetUnreadCount returns value of UnreadCount field.
func ( *Dialog) () ( int) {
	if  == nil {
		return
	}
	return .UnreadCount
}

// GetUnreadMentionsCount returns value of UnreadMentionsCount field.
func ( *Dialog) () ( int) {
	if  == nil {
		return
	}
	return .UnreadMentionsCount
}

// GetUnreadReactionsCount returns value of UnreadReactionsCount field.
func ( *Dialog) () ( int) {
	if  == nil {
		return
	}
	return .UnreadReactionsCount
}

// GetNotifySettings returns value of NotifySettings field.
func ( *Dialog) () ( PeerNotifySettings) {
	if  == nil {
		return
	}
	return .NotifySettings
}

// SetPts sets value of Pts conditional field.
func ( *Dialog) ( int) {
	.Flags.Set(0)
	.Pts = 
}

// GetPts returns value of Pts conditional field and
// boolean which is true if field was set.
func ( *Dialog) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Pts, true
}

// SetDraft sets value of Draft conditional field.
func ( *Dialog) ( DraftMessageClass) {
	.Flags.Set(1)
	.Draft = 
}

// GetDraft returns value of Draft conditional field and
// boolean which is true if field was set.
func ( *Dialog) () ( DraftMessageClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Draft, true
}

// SetFolderID sets value of FolderID conditional field.
func ( *Dialog) ( int) {
	.Flags.Set(4)
	.FolderID = 
}

// GetFolderID returns value of FolderID conditional field and
// boolean which is true if field was set.
func ( *Dialog) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .FolderID, true
}

// SetTTLPeriod sets value of TTLPeriod conditional field.
func ( *Dialog) ( int) {
	.Flags.Set(5)
	.TTLPeriod = 
}

// GetTTLPeriod returns value of TTLPeriod conditional field and
// boolean which is true if field was set.
func ( *Dialog) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .TTLPeriod, true
}

// DialogFolder represents TL type `dialogFolder#71bd134c`.
// Dialog in folder
//
// See https://core.telegram.org/constructor/dialogFolder for reference.
type DialogFolder struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Is this folder pinned
	Pinned bool
	// The folder
	Folder Folder
	// Peer in folder
	Peer PeerClass
	// Latest message ID of dialog
	TopMessage int
	// Number of unread muted peers in folder
	UnreadMutedPeersCount int
	// Number of unread unmuted peers in folder
	UnreadUnmutedPeersCount int
	// Number of unread messages from muted peers in folder
	UnreadMutedMessagesCount int
	// Number of unread messages from unmuted peers in folder
	UnreadUnmutedMessagesCount int
}

// DialogFolderTypeID is TL type id of DialogFolder.
const DialogFolderTypeID = 0x71bd134c

// construct implements constructor of DialogClass.
func ( DialogFolder) () DialogClass { return & }

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

	_ DialogClass = &DialogFolder{}
)

func ( *DialogFolder) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Pinned == false) {
		return false
	}
	if !(.Folder.Zero()) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.TopMessage == 0) {
		return false
	}
	if !(.UnreadMutedPeersCount == 0) {
		return false
	}
	if !(.UnreadUnmutedPeersCount == 0) {
		return false
	}
	if !(.UnreadMutedMessagesCount == 0) {
		return false
	}
	if !(.UnreadUnmutedMessagesCount == 0) {
		return false
	}

	return true
}

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

// FillFrom fills DialogFolder from given interface.
func ( *DialogFolder) ( interface {
	() ( bool)
	() ( Folder)
	() ( PeerClass)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
}) {
	.Pinned = .()
	.Folder = .()
	.Peer = .()
	.TopMessage = .()
	.UnreadMutedPeersCount = .()
	.UnreadUnmutedPeersCount = .()
	.UnreadMutedMessagesCount = .()
	.UnreadUnmutedMessagesCount = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *DialogFolder) () tdp.Type {
	 := tdp.Type{
		Name: "dialogFolder",
		ID:   DialogFolderTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Pinned",
			SchemaName: "pinned",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Folder",
			SchemaName: "folder",
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "TopMessage",
			SchemaName: "top_message",
		},
		{
			Name:       "UnreadMutedPeersCount",
			SchemaName: "unread_muted_peers_count",
		},
		{
			Name:       "UnreadUnmutedPeersCount",
			SchemaName: "unread_unmuted_peers_count",
		},
		{
			Name:       "UnreadMutedMessagesCount",
			SchemaName: "unread_muted_messages_count",
		},
		{
			Name:       "UnreadUnmutedMessagesCount",
			SchemaName: "unread_unmuted_messages_count",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *DialogFolder) () {
	if !(.Pinned == false) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *DialogFolder) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dialogFolder#71bd134c as nil")
	}
	.PutID(DialogFolderTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DialogFolder) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode dialogFolder#71bd134c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode dialogFolder#71bd134c: field flags: %w", )
	}
	if  := .Folder.Encode();  != nil {
		return fmt.Errorf("unable to encode dialogFolder#71bd134c: field folder: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode dialogFolder#71bd134c: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode dialogFolder#71bd134c: field peer: %w", )
	}
	.PutInt(.TopMessage)
	.PutInt(.UnreadMutedPeersCount)
	.PutInt(.UnreadUnmutedPeersCount)
	.PutInt(.UnreadMutedMessagesCount)
	.PutInt(.UnreadUnmutedMessagesCount)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *DialogFolder) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode dialogFolder#71bd134c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode dialogFolder#71bd134c: field flags: %w", )
		}
	}
	.Pinned = .Flags.Has(2)
	{
		if  := .Folder.Decode();  != nil {
			return fmt.Errorf("unable to decode dialogFolder#71bd134c: field folder: %w", )
		}
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFolder#71bd134c: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFolder#71bd134c: field top_message: %w", )
		}
		.TopMessage = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFolder#71bd134c: field unread_muted_peers_count: %w", )
		}
		.UnreadMutedPeersCount = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFolder#71bd134c: field unread_unmuted_peers_count: %w", )
		}
		.UnreadUnmutedPeersCount = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFolder#71bd134c: field unread_muted_messages_count: %w", )
		}
		.UnreadMutedMessagesCount = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode dialogFolder#71bd134c: field unread_unmuted_messages_count: %w", )
		}
		.UnreadUnmutedMessagesCount = 
	}
	return nil
}

// SetPinned sets value of Pinned conditional field.
func ( *DialogFolder) ( bool) {
	if  {
		.Flags.Set(2)
		.Pinned = true
	} else {
		.Flags.Unset(2)
		.Pinned = false
	}
}

// GetPinned returns value of Pinned conditional field.
func ( *DialogFolder) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetFolder returns value of Folder field.
func ( *DialogFolder) () ( Folder) {
	if  == nil {
		return
	}
	return .Folder
}

// GetPeer returns value of Peer field.
func ( *DialogFolder) () ( PeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetTopMessage returns value of TopMessage field.
func ( *DialogFolder) () ( int) {
	if  == nil {
		return
	}
	return .TopMessage
}

// GetUnreadMutedPeersCount returns value of UnreadMutedPeersCount field.
func ( *DialogFolder) () ( int) {
	if  == nil {
		return
	}
	return .UnreadMutedPeersCount
}

// GetUnreadUnmutedPeersCount returns value of UnreadUnmutedPeersCount field.
func ( *DialogFolder) () ( int) {
	if  == nil {
		return
	}
	return .UnreadUnmutedPeersCount
}

// GetUnreadMutedMessagesCount returns value of UnreadMutedMessagesCount field.
func ( *DialogFolder) () ( int) {
	if  == nil {
		return
	}
	return .UnreadMutedMessagesCount
}

// GetUnreadUnmutedMessagesCount returns value of UnreadUnmutedMessagesCount field.
func ( *DialogFolder) () ( int) {
	if  == nil {
		return
	}
	return .UnreadUnmutedMessagesCount
}

// DialogClassName is schema name of DialogClass.
const DialogClassName = "Dialog"

// DialogClass represents Dialog generic type.
//
// See https://core.telegram.org/type/Dialog for reference.
//
// Example:
//
//	g, err := tg.DecodeDialog(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.Dialog: // dialog#d58a08c6
//	case *tg.DialogFolder: // dialogFolder#71bd134c
//	default: panic(v)
//	}
type DialogClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() DialogClass

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

	// Is the dialog pinned
	GetPinned() (value bool)

	// The chat
	GetPeer() (value PeerClass)

	// The latest message ID
	GetTopMessage() (value int)
}

// AsInputDialogPeerFolder tries to map Dialog to InputDialogPeerFolder.
func ( *Dialog) () *InputDialogPeerFolder {
	 := new(InputDialogPeerFolder)
	if ,  := .GetFolderID();  {
		.FolderID = 
	}

	return 
}

// DecodeDialog implements binary de-serialization for DialogClass.
func ( *bin.Buffer) (DialogClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case DialogTypeID:
		// Decoding dialog#d58a08c6.
		 := Dialog{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DialogClass: %w", )
		}
		return &, nil
	case DialogFolderTypeID:
		// Decoding dialogFolder#71bd134c.
		 := DialogFolder{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode DialogClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode DialogClass: %w", bin.NewUnexpectedID())
	}
}

// Dialog boxes the DialogClass providing a helper.
type DialogBox struct {
	Dialog DialogClass
}

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

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