import{logger as e}from"../logger/index.mjs";import{InviteUserEmailEN as t,InviteUserEmailES as n,InviteUserEmailFR as r}from"../emails/InviteUserEmail.mjs";import{MagicLinkEmailEN as i,MagicLinkEmailES as a,MagicLinkEmailFR as o}from"../emails/MagicLinkEmail.mjs";import{OAuthTokenCreatedEmailEN as s,OAuthTokenCreatedEmailES as c,OAuthTokenCreatedEmailFR as l}from"../emails/OAuthTokenCreatedEmail.mjs";import{PasswordChangeConfirmationEmailEN as u,PasswordChangeConfirmationEmailES as d,PasswordChangeConfirmationEmailFR as f}from"../emails/PasswordChangeConfirmation.mjs";import{ResetPasswordEmailEN as p,ResetPasswordEmailES as m,ResetPasswordEmailFR as h}from"../emails/ResetUserPassword.mjs";import{SubscriptionPaymentCancellationEN as g,SubscriptionPaymentCancellationES as _,SubscriptionPaymentCancellationFR as v}from"../emails/SubscriptionPaymentCancellation.mjs";import{SubscriptionPaymentErrorEN as y,SubscriptionPaymentErrorES as b,SubscriptionPaymentErrorFR as x}from"../emails/SubscriptionPaymentError.mjs";import{SubscriptionPaymentSuccessEN as S,SubscriptionPaymentSuccessES as C,SubscriptionPaymentSuccessFR as w}from"../emails/SubscriptionPaymentSuccess.mjs";import{ValidateUserEmailEN as T,ValidateUserEmailES as E,ValidateUserEmailFR as D}from"../emails/ValidateUserEmail.mjs";import{WelcomeEmailEN as O,WelcomeEmailES as k,WelcomeEmailFR as A}from"../emails/Welcome.mjs";import{t as j}from"fastify-intlayer";import{jsx as M}from"react/jsx-runtime";import{Resend as N}from"resend";const P=e=>({invite:{template:j({en:t,fr:r,es:n},e),subject:j({en:`You have been invited to join Intlayer`,fr:`Vous êtes invité à rejoindre Intlayer`,es:`Has sido invitado a unirte a Intlayer`},e)},validate:{template:j({en:T,fr:D,es:E},e),subject:j({en:`Validate your email for Intlayer`,fr:`Validez votre email pour Intlayer`,es:`Valida tu correo electrónico para Intlayer`},e)},resetPassword:{template:j({en:p,fr:h,es:m},e),subject:j({en:`Reset your password for Intlayer`,fr:`Réinitialisez votre mot de passe pour Intlayer`,es:`Restablece tu contraseña para Intlayer`},e)},welcome:{template:j({en:O,fr:A,es:k},e),subject:j({en:`Welcome to Intlayer!`,fr:`Bienvenue chez Intlayer!`,es:`¡Bienvenido a Intlayer!`},e)},magicLink:{template:j({en:i,fr:o,es:a},e),subject:j({en:`Sign in to Intlayer`,fr:`Connectez-vous à Intlayer`,es:`Inicia sesión en Intlayer`},e)},passwordChangeConfirmation:{template:j({en:u,fr:f,es:d},e),subject:j({en:`Your Intlayer password has been changed`,fr:`Votre mot de passe Intlayer a été modifié`,es:`Tu contraseña de Intlayer ha sido cambiada`},e)},subscriptionPaymentSuccess:{template:j({en:S,fr:w,es:C}),subject:j({en:`Your payment for Intlayer subscription is confirmed`,fr:`Votre paiement pour l'abonnement Intlayer est confirmé`,es:`Tu pago por la suscripción de Intlayer ha sido confirmado`})},subscriptionPaymentCancellation:{template:j({en:g,fr:v,es:_}),subject:j({en:`Your Intlayer subscription has been canceled`,fr:`Votre abonnement Intlayer a été annulé`,es:`Tu suscripción de Intlayer ha sido cancelada`})},subscriptionPaymentError:{template:j({en:y,fr:x,es:b}),subject:j({en:`There was an issue with your Intlayer subscription payment`,fr:`Un problème est survenu avec votre paiement pour l'abonnement Intlayer`,es:`Hubo un problema con el pago de tu suscripción de Intlayer`})},oAuthTokenCreated:{template:j({en:s,fr:l,es:c}),subject:j({en:`A third-party OAuth application has been added to your Intlayer account`,fr:`Une application OAuth tierce a été ajoutée à votre compte Intlayer`,es:`Una aplicación OAuth de terceros ha sido añadida a tu cuenta de Intlayer`})}}),F=async({type:t,to:n,subject:r,locale:i,...a})=>{let o=new N(process.env.RESEND_API_KEY),{template:s,subject:c}=P(i)[t],l=M(s,{...a});await o.emails.send({from:`Intlayer <no-reply@intlayer.org>`,to:n,subject:r??c,react:l}).catch(t=>e.error(t)),e.info(`Email sent ${t} to ${n}`)};export{F as sendEmail};
//# sourceMappingURL=email.service.mjs.map