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

// MediaAreaCoordinates represents TL type `mediaAreaCoordinates#cfc9e002`.
// Coordinates and size of a clickable rectangular area on top of a story.
//
// See https://core.telegram.org/constructor/mediaAreaCoordinates for reference.
type MediaAreaCoordinates struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The abscissa of the rectangle's center, as a percentage of the media width (0-100).
	X float64
	// The ordinate of the rectangle's center, as a percentage of the media height (0-100).
	Y float64
	// The width of the rectangle, as a percentage of the media width (0-100).
	W float64
	// The height of the rectangle, as a percentage of the media height (0-100).
	H float64
	// Clockwise rotation angle of the rectangle, in degrees (0-360).
	Rotation float64
	// The radius of the rectangle corner rounding, as a percentage of the media width.
	//
	// Use SetRadius and GetRadius helpers.
	Radius float64
}

// MediaAreaCoordinatesTypeID is TL type id of MediaAreaCoordinates.
const MediaAreaCoordinatesTypeID = 0xcfc9e002

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

func ( *MediaAreaCoordinates) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.X == 0) {
		return false
	}
	if !(.Y == 0) {
		return false
	}
	if !(.W == 0) {
		return false
	}
	if !(.H == 0) {
		return false
	}
	if !(.Rotation == 0) {
		return false
	}
	if !(.Radius == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MediaAreaCoordinates from given interface.
func ( *MediaAreaCoordinates) ( interface {
	() ( float64)
	() ( float64)
	() ( float64)
	() ( float64)
	() ( float64)
	() ( float64,  bool)
}) {
	.X = .()
	.Y = .()
	.W = .()
	.H = .()
	.Rotation = .()
	if ,  := .();  {
		.Radius = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MediaAreaCoordinates) () tdp.Type {
	 := tdp.Type{
		Name: "mediaAreaCoordinates",
		ID:   MediaAreaCoordinatesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "X",
			SchemaName: "x",
		},
		{
			Name:       "Y",
			SchemaName: "y",
		},
		{
			Name:       "W",
			SchemaName: "w",
		},
		{
			Name:       "H",
			SchemaName: "h",
		},
		{
			Name:       "Rotation",
			SchemaName: "rotation",
		},
		{
			Name:       "Radius",
			SchemaName: "radius",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MediaAreaCoordinates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode mediaAreaCoordinates#cfc9e002 as nil")
	}
	.PutID(MediaAreaCoordinatesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MediaAreaCoordinates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode mediaAreaCoordinates#cfc9e002 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode mediaAreaCoordinates#cfc9e002: field flags: %w", )
	}
	.PutDouble(.X)
	.PutDouble(.Y)
	.PutDouble(.W)
	.PutDouble(.H)
	.PutDouble(.Rotation)
	if .Flags.Has(0) {
		.PutDouble(.Radius)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MediaAreaCoordinates) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode mediaAreaCoordinates#cfc9e002 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#cfc9e002: field flags: %w", )
		}
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#cfc9e002: field x: %w", )
		}
		.X = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#cfc9e002: field y: %w", )
		}
		.Y = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#cfc9e002: field w: %w", )
		}
		.W = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#cfc9e002: field h: %w", )
		}
		.H = 
	}
	{
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#cfc9e002: field rotation: %w", )
		}
		.Rotation = 
	}
	if .Flags.Has(0) {
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode mediaAreaCoordinates#cfc9e002: field radius: %w", )
		}
		.Radius = 
	}
	return nil
}

// GetX returns value of X field.
func ( *MediaAreaCoordinates) () ( float64) {
	if  == nil {
		return
	}
	return .X
}

// GetY returns value of Y field.
func ( *MediaAreaCoordinates) () ( float64) {
	if  == nil {
		return
	}
	return .Y
}

// GetW returns value of W field.
func ( *MediaAreaCoordinates) () ( float64) {
	if  == nil {
		return
	}
	return .W
}

// GetH returns value of H field.
func ( *MediaAreaCoordinates) () ( float64) {
	if  == nil {
		return
	}
	return .H
}

// GetRotation returns value of Rotation field.
func ( *MediaAreaCoordinates) () ( float64) {
	if  == nil {
		return
	}
	return .Rotation
}

// SetRadius sets value of Radius conditional field.
func ( *MediaAreaCoordinates) ( float64) {
	.Flags.Set(0)
	.Radius = 
}

// GetRadius returns value of Radius conditional field and
// boolean which is true if field was set.
func ( *MediaAreaCoordinates) () ( float64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Radius, true
}