//#region extensions/telegram/src/telegram-draft-errors.ts
/**
* Error classification for Telegram draft streaming.
*/
function extractTelegramErrorText(err) {
	return typeof err === "string" ? err : err instanceof Error ? err.message : typeof err === "object" && err && "description" in err ? typeof err.description === "string" ? err.description : "" : "";
}
function shouldFallbackFromDraftTransport(err) {
	const text = extractTelegramErrorText(err);
	if (!/sendMessageDraft/i.test(text)) return false;
	return /(unknown method|method .*not (found|available|supported)|unsupported)/i.test(text) || /(can't be used|can be used only)/i.test(text);
}
const THREAD_NOT_FOUND_RE = /400:\s*Bad Request:\s*message thread not found/i;
function isTelegramThreadNotFoundError(err) {
	return THREAD_NOT_FOUND_RE.test(extractTelegramErrorText(err));
}
function isSafeToRetrySendError(err) {
	const text = extractTelegramErrorText(err);
	return /ECONNRESET|ETIMEDOUT|ENOTFOUND|ENETUNREACH|EAI_AGAIN|socket hang up/i.test(text);
}
function isTelegramClientRejection(err) {
	const text = extractTelegramErrorText(err);
	return /400:\s*Bad Request|403:|404:/i.test(text);
}
//#endregion
export { extractTelegramErrorText, isSafeToRetrySendError, isTelegramClientRejection, isTelegramThreadNotFoundError, shouldFallbackFromDraftTransport };

//# sourceMappingURL=telegram-draft-errors.js.map