package telegram

import (
	

	
	
	
	
)

// DeviceConfig is config which send when Telegram connection session created.
type DeviceConfig = manager.DeviceConfig

// Telegram Desktop application version sent in initConnection.
//
// Keep in sync with the bundled tdesktop reference (Telegram/SourceFiles/core/version.h).
const tdesktopAppVersion = "6.9.1"

// TimezoneParams builds the initConnection params value with the tz_offset
// field, matching what the official clients (e.g. Telegram Desktop) send.
//
// The offset is the timezone offset of loc in seconds, rounded to the nearest
// 15 minutes (900 seconds) and clamped to the [-12h, +14h] range, exactly like
// Telegram Desktop's prepareInitParams.
func ( *time.Location) tg.JSONValueClass {
	,  := time.Now().In().Zone()

	for  < -12*3600 {
		 += 24 * 3600
	}
	for  > 14*3600 {
		 -= 24 * 3600
	}

	 := 1
	if  < 0 {
		 = -1
		 = -
	}
	 := (( + 450) / 900) * 900 * 

	return &tg.JSONObject{
		Value: []tg.JSONObjectValue{
			{Key: "tz_offset", Value: &tg.JSONNumber{Value: float64()}},
		},
	}
}

// TDesktopResolver returns a DC resolver that connects the same way as Telegram
// Desktop: every direct connection is wrapped in Obfuscated2 and uses the
// abridged transport codec.
//
// Use it together with DeviceTDesktopWindows to be indistinguishable from
// Telegram Desktop both on the transport layer and in initConnection:
//
//	client := telegram.NewClient(appID, appHash, telegram.Options{
//		Device:   telegram.DeviceTDesktopWindows(),
//		Resolver: telegram.TDesktopResolver(),
//	})
func () dcs.Resolver {
	return dcs.Plain(dcs.PlainOptions{
		Protocol:   transport.Abridged,
		Obfuscated: true,
	})
}

// DeviceTDesktopWindows returns a DeviceConfig that emulates a Telegram Desktop
// (Windows build) installation on initConnection, making the connection
// parameters indistinguishable from Telegram Desktop from the server's
// perspective.
//
// Combine it with TDesktopResolver to also match Telegram Desktop on the
// transport layer.
func () DeviceConfig {
	return DeviceConfig{
		DeviceModel:    "Desktop",
		SystemVersion:  "Windows 10",
		AppVersion:     tdesktopAppVersion + " x64",
		SystemLangCode: "en-US",
		LangPack:       "tdesktop",
		LangCode:       "en",
		Params:         TimezoneParams(time.Local),
	}
}