/**
 * User invitation email — a one-click link to accept the invite and set a
 * password. The link points at the same `/reset-password` page the password
 * reset flow uses (the invitee is "resetting" from an unusable random password
 * to one they choose), so no separate accept page is required.
 */
function escapeHtml(value) {
    return value
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;')
        .replace(/"/g, '&quot;')
        .replace(/'/g, '&#39;');
}
/** Human-friendly role label for the email body. */
function roleLabel(role) {
    const lower = role.toLowerCase();
    return lower.charAt(0).toUpperCase() + lower.slice(1);
}
export function userInvitationEmailTemplate(args) {
    const site = args.siteName?.trim() || 'Actuate CMS';
    const inviter = args.invitedByName?.trim();
    const role = roleLabel(args.role);
    const safeSite = escapeHtml(site);
    const safeName = escapeHtml(args.userName);
    const safeRole = escapeHtml(role);
    const invitedLine = inviter
        ? `${escapeHtml(inviter)} invited you to join ${safeSite}`
        : `You've been invited to join ${safeSite}`;
    return {
        subject: `You're invited to ${site}`,
        html: `<!DOCTYPE html>
<html>
<head><meta charset="utf-8"></head>
<body style="margin:0;padding:0;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;background:#f9fafb;">
  <table width="100%" cellpadding="0" cellspacing="0" style="max-width:560px;margin:40px auto;background:#fff;border-radius:8px;border:1px solid #e5e7eb;">
    <tr>
      <td style="padding:32px;">
        <h1 style="margin:0 0 16px;font-size:20px;color:#111827;">${invitedLine}</h1>
        <p style="margin:0 0 24px;font-size:15px;line-height:1.6;color:#374151;">
          Hi ${safeName}, you've been added as a <strong>${safeRole}</strong>. Click the button below to set your password and sign in.
        </p>
        <a href="${args.inviteUrl}" style="display:inline-block;padding:12px 24px;background:#3b82f6;color:#fff;text-decoration:none;border-radius:6px;font-weight:600;font-size:14px;">
          Accept invitation
        </a>
        <p style="margin:24px 0 0;font-size:13px;color:#9ca3af;">
          If you weren't expecting this, you can safely ignore this email. This invitation link expires in 7 days.
        </p>
      </td>
    </tr>
  </table>
</body>
</html>`,
        text: `${inviter ? `${inviter} invited you` : "You've been invited"} to join ${site} as a ${role}.\n\nHi ${args.userName}, set your password and sign in using the link below:\n\n${args.inviteUrl}\n\nIf you weren't expecting this, you can safely ignore this email. This invitation link expires in 7 days.`,
    };
}
//# sourceMappingURL=invite-email.js.map