package email

import (
	_ "embed"
	"fmt"
	"intent-system/pkg/dal/models"
)

const (
	SubscriptionWelcomeSubject = "Unlock the Future — Welcome to Jelly AI"
)

//go:embed welcome_email.html
var SubscriptionWelcomeTemplate string

//go:embed welcome_email_cn.html
var SubscriptionWelcomeTemplateCn string

func SubscriptionMessage(strSubject, strTitle, strSubTitle, strSummary, strLink string) string {
	return fmt.Sprintf(`<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>%s</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      line-height: 1.6;
      margin: 0;
      padding: 0;
    }
    .container {
      max-width: 600px;
      margin: auto;
      padding: 20px;
    }
    h2 {
      color: #333;
      margin-bottom: 10px;
    }
    p {
      color: #666;
      margin-top: 0;
    }
    a {
      text-decoration: none;
      color: #007bff;
    }
  </style>
</head>
<body>
  <div class="container">
    <div>
      <h2>%s</h2>
      <p>%s</p>
    </div>
    <div>
      <p style="max-height: 3em; overflow: hidden; text-overflow: ellipsis;">%s</p>
    </div>
    <div>
      <a href="%s">Read more</a>
    </div>
  </div>
</body>
</html>
`, strSubject, strTitle, strSummary, strSubTitle, strLink)
}

func RegisterVerificationCodeMessage(strLang, strUserName, strVerificationCode string) (strMsg string) {
	switch strLang {
	case models.Language_EN:
		strMsg = registerVerificationCodeMessageEn(strUserName, strVerificationCode)
	case models.Language_CN:
		strMsg = registerVerificationCodeMessageCN(strUserName, strVerificationCode)
	default:
		strMsg = registerVerificationCodeMessageEn(strUserName, strVerificationCode)
	}
	return strMsg
}

func registerVerificationCodeMessageCN(strUserName, strVerificationCode string) string {
	return fmt.Sprintf(`
<!DOCTYPE html>
<html>
<head>
    <title>欢迎加入Jelly AI!</title>
</head>
<body>
    <p>亲爱的 %s,</p>
    <p>感谢您加入Jelly AI！我们很高兴能为您指引接下来的旅程。首先，请使用以下验证码完成您的注册：</p>
    <p><strong>验证码: %s</strong></p>
    <p><strong>注意:</strong> 此验证码将在60分钟后失效。为了您的安全，请不要与任何人分享此验证码。</p>
    <p>在您踏上这段激动人心的旅程之际，我们想向您介绍我们设计的创新产品，旨在改变您的业务：</p>
    <p>如果您没有请求此验证码，可能是有人误输入了您的电子邮件。请忽略此电子邮件，或者如果您有任何疑虑，请随时联系我们：<a href="mailto:it@jellydropsllc.com">it@jellydropsllc.com</a>.</p>
    <p>我们期待帮助您充分利用AI的潜力。感谢您选择Jelly AI.</p>
    <p>祝好,<br>
    <strong>Jelly AI业务部门</strong></p>
</body>
</html>`, strUserName, strVerificationCode)
}

func registerVerificationCodeMessageEn(strUserName, strVerificationCode string) string {

	return fmt.Sprintf(`<!DOCTYPE html>
<html>
<head>
    <title>Welcome to Jelly AI!</title>
</head>
<body>
    <p>Hi %s,</p>
    <p>Thank you for choosing Jelly AI! We are excited to guide you through the next steps of your journey with us. To begin, please use the verification code below to complete your registration:</p>
    <p><strong>Verification Code: %s</strong></p>
    <p><strong>Note:</strong> This code will expire in 60 minutes. For your security, please do not share this code with anyone.</p>
    <p>As you embark on this exciting journey, we would like to introduce you to our innovative products designed to transform your business:</p>
    <p>If you did not request this code, it's possible that someone entered your email by mistake. Please disregard this email, or if you have any concerns, feel free to reach out to us at <a href="mailto:it@jellydropsllc.com">it@jellydropsllc.com</a>.</p>
    <p>We look forward to helping you leverage the full potential of AI. Thank you for choosing Jelly AI.</p>
    <p>Warm regards,<br>
    <strong>The Jelly AI Service Team</strong></p>
</body>
</html>
`, strUserName, strVerificationCode)
}
