package telegram

import (
	
	
	

	
	
	

	
	
	
	
	
	
	
)

type (
	// PublicKey is a Telegram server public key.
	PublicKey = exchange.PublicKey
)

// Options of Client.
type Options struct {
	// PublicKeys of telegram.
	//
	// If not provided, embedded public keys will be used.
	PublicKeys []PublicKey

	// DC ID to connect.
	//
	// If not provided, 2 will be used by default.
	DC int

	// DCList is initial list of addresses to connect.
	DCList dcs.List

	// Resolver to use.
	Resolver dcs.Resolver

	// NoUpdates enables no updates mode.
	//
	// Enabled by default if no UpdateHandler is provided.
	NoUpdates bool

	// ReconnectionBackoff configures and returns reconnection backoff object.
	ReconnectionBackoff func() backoff.BackOff
	// MigrationTimeout configures migration timeout.
	MigrationTimeout time.Duration

	// Random is random source. Defaults to crypto.
	Random io.Reader
	// Logger is instance of zap.Logger. No logs by default.
	Logger *zap.Logger
	// SessionStorage will be used to load and save session data.
	// NB: Very sensitive data, save with care.
	SessionStorage SessionStorage
	// UpdateHandler will be called on received update.
	UpdateHandler UpdateHandler
	// Middlewares list allows wrapping tg.Invoker. Can be useful for metrics,
	// tracing, etc. Note that order is important, see ExampleMiddleware.
	//
	// Middlewares are called in order from first to last.
	Middlewares []Middleware

	// AckBatchSize is limit of MTProto ACK buffer size.
	AckBatchSize int
	// AckInterval is maximum time to buffer MTProto ACK.
	AckInterval time.Duration
	// RetryInterval is duration between send retries.
	RetryInterval time.Duration
	// MaxRetries is limit of send retries.
	MaxRetries int
	// ExchangeTimeout is timeout of every key exchange request.
	ExchangeTimeout time.Duration
	// DialTimeout is timeout of creating connection.
	DialTimeout time.Duration

	// CompressThreshold is a threshold in bytes to determine that message
	// is large enough to be compressed using GZIP.
	// If < 0, compression will be disabled.
	// If == 0, default value will be used.
	CompressThreshold int

	// Device is device config.
	// Will be sent with session creation request.
	Device DeviceConfig

	MessageID mtproto.MessageIDSource
	Clock     clock.Clock

	// OpenTelemetry.
	TracerProvider trace.TracerProvider
}

func ( *Options) () {
	if .Resolver == nil {
		.Resolver = dcs.DefaultResolver()
	}
	if .Random == nil {
		.Random = crypto.DefaultRand()
	}
	if .Logger == nil {
		.Logger = zap.NewNop()
	}
	if .DC == 0 {
		.DC = 2
	}
	if .DCList.Zero() {
		.DCList = dcs.Prod()
	}
	// It's okay to use zero value AckBatchSize, mtproto.Options will set defaults.
	// It's okay to use zero value AckInterval, mtproto.Options will set defaults.
	// It's okay to use zero value RetryInterval, mtproto.Options will set defaults.
	// It's okay to use zero value MaxRetries, mtproto.Options will set defaults.
	// It's okay to use zero value CompressThreshold, mtproto.Options will set defaults.
	.Device.SetDefaults()
	if .Clock == nil {
		.Clock = clock.System
	}
	if .ReconnectionBackoff == nil {
		.ReconnectionBackoff = defaultBackoff(.Clock)
	}
	if .MigrationTimeout == 0 {
		.MigrationTimeout = time.Second * 15
	}
	if .MessageID == nil {
		.MessageID = proto.NewMessageIDGen(.Clock.Now)
	}
	if .UpdateHandler == nil {
		// No updates handler passed, so no sense to subscribe for updates.
		// User should explicitly ignore updates using custom UpdateHandler.
		.NoUpdates = true

		// Using no-op handler.
		.UpdateHandler = UpdateHandlerFunc(func( context.Context,  tg.UpdatesClass) error {
			return nil
		})
	}
}

func ( clock.Clock) func() backoff.BackOff {
	return func() backoff.BackOff {
		 := backoff.NewExponentialBackOff()
		.Clock = 
		.MaxElapsedTime = 0
		return 
	}
}