package telegram

import (
	
	

	

	
	
)

type downloadClient struct {
	client *Client
}

func ( downloadClient) () *tg.Client {
	return .client.API()
}

func ( downloadClient) (
	 context.Context,
	 *tg.UploadGetFileRequest,
) (tg.UploadFileClass, error) {
	,  := .api().UploadGetFile(, )

	return , 
}

func ( downloadClient) (
	 context.Context,
	 *tg.UploadGetFileHashesRequest,
) ([]tg.FileHash, error) {
	,  := .api().UploadGetFileHashes(, )

	return , 
}

func ( downloadClient) (
	 context.Context,
	 *tg.UploadReuploadCDNFileRequest,
) ([]tg.FileHash, error) {
	,  := .api().UploadReuploadCDNFile(, )

	return , 
}

func ( downloadClient) (
	 context.Context,
	 *tg.UploadGetCDNFileHashesRequest,
) ([]tg.FileHash, error) {
	,  := .api().UploadGetCDNFileHashes(, )

	return , 
}

func ( downloadClient) (
	 context.Context,
	 *tg.UploadGetWebFileRequest,
) (*tg.UploadWebFile, error) {
	return .api().UploadGetWebFile(, )
}

func ( downloadClient) ( context.Context,  int,  int64) (downloader.CDN, io.Closer, error) {
	,  := .client.CDN(, , )
	if  != nil {
		return nil, nil, 
	}
	if  == nil {
		return nil, nil, errors.New("telegram CDN pool returned nil invoker")
	}

	// CDN pools are cached on client level; downloader should not close them
	// by itself; lifecycle is controlled by caller via returned closer.
	 := tg.NewClient()

	return , , nil
}

// Downloader returns file downloader configured for current client.
func ( *Client) () *downloader.Downloader {
	// Propagate explicit client-level CDN policy into downloader.
	return downloader.NewDownloader().WithAllowCDN(.allowCDN)
}

// Download creates Builder for plain file downloads.
func ( *Client) ( tg.InputFileLocationClass) *downloader.Builder {
	return .Downloader().Download(downloadClient{client: }, )
}

// DownloadWeb creates Builder for web file downloads.
func ( *Client) ( tg.InputWebFileLocationClass) *downloader.Builder {
	return .Downloader().Web(downloadClient{client: }, )
}