"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.VerifyCodeBody = VerifyCodeBody;
const jsx_runtime_1 = require("react/jsx-runtime");
const components_1 = require("@react-email/components");
// @ts-ignore
const constant_1 = require("@abtnode/constant");
const actions_1 = __importDefault(require("../_components/actions"));
// HACK: 只是短暂为了兼容现有 launcher 转发逻辑
function VerifyCodeBody({ appName, locale = 'en', code, magicLink, children, }) {
    const translations = {
        en: {
            title: `Login to ${appName}`,
            followConfirmation: `Thank you for login to ${appName}. To confirm your account, please click the button below.`,
            confirmButton: 'Confirm account',
            useConfirmLink: 'If Confirm Button does not work, please use the link below.',
            orEnterCode: `Or enter the following code in the application: `,
            followEnterCode: `Thank you for login to ${appName}. To confirm your account, please enter the following code in the application`,
            codeExpiresIn: `This code expires in ${constant_1.VERIFY_CODE_TTL / 60 / 1000} minutes.`,
            doNotShareCodeTitle: 'Do NOT share this code with anyone.',
            doNotShareCode: "Only enter this code on the official application's website. If someone asks for this code, it could be a scam.",
        },
        zh: {
            title: `登录 ${appName}`,
            followConfirmation: `感谢您登录 ${appName}，请点击以下按钮确认您的账户。`,
            confirmButton: '确认账户',
            useConfirmLink: '如果确认按钮无法工作，请使用以下链接。',
            orEnterCode: `或者在应用中输入以下代码：`,
            followEnterCode: `感谢您登录 ${appName}，请在应用中输入以下代码确认您的账户。`,
            codeExpiresIn: `此代码将在${constant_1.VERIFY_CODE_TTL / 60 / 1000}分钟内过期。`,
            doNotShareCodeTitle: '请勿将此代码分享给任何人。',
            doNotShareCode: '请仅在官方应用的网站上输入此代码。如果有人要求提供此代码，这可能是一个骗局。',
        },
    };
    const translation = translations[locale] || translations.en;
    if (children) {
        return children;
    }
    if (code && magicLink) {
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.followConfirmation }), (0, jsx_runtime_1.jsx)(actions_1.default, { actions: [{ title: translation.confirmButton, link: magicLink }] }), (0, jsx_runtime_1.jsx)(components_1.Hr, {}), (0, jsx_runtime_1.jsxs)(components_1.Text, { children: [translation.orEnterCode, (0, jsx_runtime_1.jsx)("strong", { children: code })] }), (0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.codeExpiresIn }), (0, jsx_runtime_1.jsxs)(components_1.Text, { children: [(0, jsx_runtime_1.jsx)("strong", { children: translation.doNotShareCodeTitle }), " ", translation.doNotShareCode] })] }));
    }
    if (magicLink) {
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.followConfirmation }), (0, jsx_runtime_1.jsx)(actions_1.default, { actions: [{ title: translation.confirmButton, link: magicLink }] }), (0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.useConfirmLink }), (0, jsx_runtime_1.jsx)(components_1.Link, { href: magicLink, children: magicLink })] }));
    }
    if (code) {
        return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.followEnterCode }), (0, jsx_runtime_1.jsx)(components_1.Heading, { style: { textAlign: 'center' }, children: code }), (0, jsx_runtime_1.jsx)(components_1.Text, { children: translation.codeExpiresIn }), (0, jsx_runtime_1.jsxs)(components_1.Text, { children: [(0, jsx_runtime_1.jsx)("strong", { children: translation.doNotShareCodeTitle }), " ", translation.doNotShareCode] })] }));
    }
}
exports.default = VerifyCodeBody;
