import { init_session_key, parseSessionKey } from "../../../src/routing/session-key.js";
//#region extensions/telegram/src/delivery-chat-id.ts
init_session_key();
/**
* Resolves Telegram Bot API `chat_id` from config/UI `to` / `targetChatId`.
* Accepts numeric ids, full session keys (`agent:main:telegram:...`), or
* routing suffixes (`account:dm:peerId` / `account:group:peerId`).
*/
function normalizeTelegramDeliveryChatId(to) {
	const trimmed = to.trim();
	if (!trimmed) return trimmed;
	const parsed = parseSessionKey(trimmed);
	if (parsed?.source === "telegram") return parsed.peerId;
	const parts = trimmed.split(":");
	if (parts.length === 3 && (parts[1] === "dm" || parts[1] === "group") && parts[2] !== "") return parts[2];
	return trimmed;
}
//#endregion
export { normalizeTelegramDeliveryChatId };

//# sourceMappingURL=delivery-chat-id.js.map