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

// InputGeoPointEmpty represents TL type `inputGeoPointEmpty#e4c123d6`.
// Empty GeoPoint constructor.
//
// See https://core.telegram.org/constructor/inputGeoPointEmpty for reference.
type InputGeoPointEmpty struct {
}

// InputGeoPointEmptyTypeID is TL type id of InputGeoPointEmpty.
const InputGeoPointEmptyTypeID = 0xe4c123d6

// construct implements constructor of InputGeoPointClass.
func ( InputGeoPointEmpty) () InputGeoPointClass { return & }

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

	_ InputGeoPointClass = &InputGeoPointEmpty{}
)

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

	return true
}

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

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

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

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

// Encode implements bin.Encoder.
func ( *InputGeoPointEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputGeoPointEmpty#e4c123d6 as nil")
	}
	.PutID(InputGeoPointEmptyTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputGeoPointEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputGeoPointEmpty#e4c123d6 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputGeoPointEmpty) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputGeoPointEmpty#e4c123d6 to nil")
	}
	return nil
}

// InputGeoPoint represents TL type `inputGeoPoint#48222faf`.
// Defines a GeoPoint by its coordinates.
//
// See https://core.telegram.org/constructor/inputGeoPoint for reference.
type InputGeoPoint struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Latitude
	Lat float64
	// Longitude
	Long float64
	// The estimated horizontal accuracy of the location, in meters; as defined by the sender.
	//
	// Use SetAccuracyRadius and GetAccuracyRadius helpers.
	AccuracyRadius int
}

// InputGeoPointTypeID is TL type id of InputGeoPoint.
const InputGeoPointTypeID = 0x48222faf

// construct implements constructor of InputGeoPointClass.
func ( InputGeoPoint) () InputGeoPointClass { return & }

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

	_ InputGeoPointClass = &InputGeoPoint{}
)

func ( *InputGeoPoint) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Lat == 0) {
		return false
	}
	if !(.Long == 0) {
		return false
	}
	if !(.AccuracyRadius == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputGeoPoint from given interface.
func ( *InputGeoPoint) ( interface {
	() ( float64)
	() ( float64)
	() ( int,  bool)
}) {
	.Lat = .()
	.Long = .()
	if ,  := .();  {
		.AccuracyRadius = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *InputGeoPoint) () tdp.Type {
	 := tdp.Type{
		Name: "inputGeoPoint",
		ID:   InputGeoPointTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Lat",
			SchemaName: "lat",
		},
		{
			Name:       "Long",
			SchemaName: "long",
		},
		{
			Name:       "AccuracyRadius",
			SchemaName: "accuracy_radius",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *InputGeoPoint) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputGeoPoint#48222faf as nil")
	}
	.PutID(InputGeoPointTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputGeoPoint) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputGeoPoint#48222faf as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputGeoPoint#48222faf: field flags: %w", )
	}
	.PutDouble(.Lat)
	.PutDouble(.Long)
	if .Flags.Has(0) {
		.PutInt(.AccuracyRadius)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputGeoPoint) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputGeoPoint#48222faf to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputGeoPoint#48222faf: field flags: %w", )
		}
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode inputGeoPoint#48222faf: field lat: %w", )
		}
		.Lat = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode inputGeoPoint#48222faf: field long: %w", )
		}
		.Long = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputGeoPoint#48222faf: field accuracy_radius: %w", )
		}
		.AccuracyRadius = 
	}
	return nil
}

// GetLat returns value of Lat field.
func ( *InputGeoPoint) () ( float64) {
	if  == nil {
		return
	}
	return .Lat
}

// GetLong returns value of Long field.
func ( *InputGeoPoint) () ( float64) {
	if  == nil {
		return
	}
	return .Long
}

// SetAccuracyRadius sets value of AccuracyRadius conditional field.
func ( *InputGeoPoint) ( int) {
	.Flags.Set(0)
	.AccuracyRadius = 
}

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

// InputGeoPointClassName is schema name of InputGeoPointClass.
const InputGeoPointClassName = "InputGeoPoint"

// InputGeoPointClass represents InputGeoPoint generic type.
//
// See https://core.telegram.org/type/InputGeoPoint for reference.
//
// Example:
//
//	g, err := tg.DecodeInputGeoPoint(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputGeoPointEmpty: // inputGeoPointEmpty#e4c123d6
//	case *tg.InputGeoPoint: // inputGeoPoint#48222faf
//	default: panic(v)
//	}
type InputGeoPointClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputGeoPointClass

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

	// AsNotEmpty tries to map InputGeoPointClass to InputGeoPoint.
	AsNotEmpty() (*InputGeoPoint, bool)
}

// AsNotEmpty tries to map InputGeoPointEmpty to InputGeoPoint.
func ( *InputGeoPointEmpty) () (*InputGeoPoint, bool) {
	return nil, false
}

// AsNotEmpty tries to map InputGeoPoint to InputGeoPoint.
func ( *InputGeoPoint) () (*InputGeoPoint, bool) {
	return , true
}

// DecodeInputGeoPoint implements binary de-serialization for InputGeoPointClass.
func ( *bin.Buffer) (InputGeoPointClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputGeoPointEmptyTypeID:
		// Decoding inputGeoPointEmpty#e4c123d6.
		 := InputGeoPointEmpty{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputGeoPointClass: %w", )
		}
		return &, nil
	case InputGeoPointTypeID:
		// Decoding inputGeoPoint#48222faf.
		 := InputGeoPoint{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputGeoPointClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputGeoPointClass: %w", bin.NewUnexpectedID())
	}
}

// InputGeoPoint boxes the InputGeoPointClass providing a helper.
type InputGeoPointBox struct {
	InputGeoPoint InputGeoPointClass
}

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

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