export const BOTFATHER_BOT_USERNAME = 'BotFather_bot';
export const BOTFATHER_USER_USERNAME = 'BotFather';
export const BOTFATHER_DISPLAY_NAME = 'BotFather';
export const BOTFATHER_SETTING_USER_ID = 'BOTFATHER_USER_ID';
export const BOTFATHER_SETTING_BOT_ID = 'BOTFATHER_BOT_ID';
export const GET_MY_ID_BOT_USERNAME = 'GetMyIdBot_bot';
export const GET_MY_ID_USER_USERNAME = 'GetMyIdBot';
export const GET_MY_ID_DISPLAY_NAME = 'GetMyIdBot';
export const GET_MY_ID_SETTING_USER_ID = 'GET_MY_ID_BOT_USER_ID';
export const GET_MY_ID_SETTING_BOT_ID = 'GET_MY_ID_BOT_ID';
export const SYSTEM_BOT_OWNER_EMAIL = 'system-bot-owner@internal.lendry.id';

export function resolvePublicFrontendUrl() {
  return (process.env.PUBLIC_FRONTEND_URL ?? 'http://localhost:3002').replace(/\/$/, '');
}

export function buildBotFatherWebAppUrl() {
  return `${resolvePublicFrontendUrl()}/mini-apps/bot-father`;
}

export function buildBotManageWebAppUrl(botId: string) {
  return `${resolvePublicFrontendUrl()}/mini-apps/bot-father?botId=${encodeURIComponent(botId)}`;
}

export function buildBotCreateWebAppUrl() {
  return `${buildBotFatherWebAppUrl()}?mode=create`;
}

export function isBotManageWebAppUrl(url: string | null | undefined) {
  if (!url?.trim()) return false;
  return url.includes('/mini-apps/bot-manage') || url.includes('/mini-apps/bot-father');
}
