var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/login-and-register/index.tsx
var login_and_register_exports = {};
__export(login_and_register_exports, {
  default: () => login_and_register_default
});
module.exports = __toCommonJS(login_and_register_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_icons = require("@ant-design/icons");
var import_index = require("./index.less");
var loginAndRegister = ({
  showLogo = true,
  logo,
  logoPosition = "center",
  logoSize = { width: 48, height: 48 },
  title = "Log in to your account",
  showTitle = false,
  titleAlign = "center",
  subtitle = "Welcome back! Please enter your details.",
  showSubtitle = false,
  subtitleAlign = "center",
  loginMethods = ["email", "google", "facebook", "apple"],
  defaultLoginMethod = "email",
  emailLabel = "Email",
  passwordLabel = "Password",
  emailPlaceholder = "Enter your email",
  passwordPlaceholder = "Enter your password",
  emailRules = [
    { required: true, message: "Please input your email!" },
    { type: "email", message: "Please enter a valid email!" }
  ],
  buttonText = "Log in",
  socialLoginTexts = {
    google: "Continue with Google",
    facebook: "Continue with Facebook",
    apple: "Continue with Apple"
  },
  showFooter = true,
  showSignUp = true,
  signUpText = "Don't have an account? Sign up",
  signUpLink = "",
  signUpPosition = "center",
  otherLinks = [],
  otherLinksPosition = "center",
  showTabs = true,
  loginTabText = "Login",
  registerTabText = "Register",
  registerEmailPlaceholder = "Enter your email",
  registerPasswordPlaceholder = "Create a password",
  registerButtonText = "Create account",
  rememberMeText = "Remember me",
  forgotPasswordText = "Forgot password?",
  showRememberMe = false,
  showForgotPassword = false,
  onLogin,
  onSocialLogin,
  onSignUp,
  onRegister,
  backgroundImage = "/login-illustration.png"
}) => {
  const [form] = import_antd.Form.useForm();
  const [loading, setLoading] = (0, import_react.useState)(false);
  const [activeTab, setActiveTab] = (0, import_react.useState)("login");
  (0, import_react.useEffect)(() => {
    document.body.id = "body";
  }, []);
  const handleEmailLogin = async () => {
    try {
      setLoading(true);
      const values = await form.validateFields();
      onLogin == null ? void 0 : onLogin({ ...values, loginMethod: "email" });
    } catch (error) {
      console.error("Validation failed:", error);
    } finally {
      setLoading(false);
    }
  };
  const handleSocialLogin = (type) => {
    onSocialLogin == null ? void 0 : onSocialLogin(type);
  };
  const handleRegister = async () => {
    try {
      setLoading(true);
      const values = await form.validateFields();
      onRegister == null ? void 0 : onRegister(values);
    } catch (error) {
      console.error("Validation failed:", error);
    } finally {
      setLoading(false);
    }
  };
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-main" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-container" }, showLogo && /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `saas-login-logo ${logoPosition}`
    },
    logo && /* @__PURE__ */ import_react.default.createElement("img", { src: logo, alt: "logo" })
  ), showTitle && /* @__PURE__ */ import_react.default.createElement("h1", { className: "saas-login-title", style: { textAlign: titleAlign } }, title), showSubtitle && /* @__PURE__ */ import_react.default.createElement("p", { className: "saas-login-subtitle", style: { textAlign: subtitleAlign } }, subtitle), showTabs && /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-tabs" }, /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `tab ${activeTab === "login" ? "active" : ""}`,
      onClick: () => setActiveTab("login")
    },
    loginTabText
  ), /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `tab ${activeTab === "register" ? "active" : ""}`,
      onClick: () => setActiveTab("register")
    },
    registerTabText
  )), /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-form" }, activeTab === "login" ? /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { form }, /* @__PURE__ */ import_react.default.createElement("div", { className: "form-item-label" }, emailLabel), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form.Item,
    {
      name: "email",
      rules: emailRules
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.Input,
      {
        placeholder: emailPlaceholder,
        size: "large",
        className: "saas-login-input"
      }
    )
  ), /* @__PURE__ */ import_react.default.createElement("div", { className: "form-item-label" }, passwordLabel), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form.Item,
    {
      name: "password",
      rules: [
        { required: true, message: "Please input your password!" }
      ]
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.Input.Password,
      {
        placeholder: passwordPlaceholder,
        size: "large",
        className: "saas-login-input"
      }
    )
  ), (showRememberMe || showForgotPassword) && /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-options" }, showRememberMe && /* @__PURE__ */ import_react.default.createElement(import_antd.Checkbox, null, rememberMeText), showForgotPassword && /* @__PURE__ */ import_react.default.createElement("a", { className: "forgot-password" }, forgotPasswordText)), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      type: "primary",
      block: true,
      size: "large",
      loading,
      onClick: handleEmailLogin,
      className: "saas-login-button"
    },
    "Log in"
  )) : /* @__PURE__ */ import_react.default.createElement(import_antd.Form, { form }, /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form.Item,
    {
      name: "email",
      rules: emailRules
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.Input,
      {
        placeholder: registerEmailPlaceholder,
        size: "large",
        className: "saas-login-input"
      }
    )
  ), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form.Item,
    {
      name: "password",
      rules: [
        { required: true, message: "Please input your password!" },
        { min: 6, message: "Password must be at least 6 characters!" }
      ]
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_antd.Input.Password,
      {
        placeholder: registerPasswordPlaceholder,
        size: "large",
        className: "saas-login-input"
      }
    )
  ), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      type: "primary",
      block: true,
      size: "large",
      loading,
      onClick: handleRegister,
      className: "saas-login-button"
    },
    registerButtonText
  )), /* @__PURE__ */ import_react.default.createElement(import_antd.Space, { direction: "vertical", className: "saas-login-social" }, loginMethods.includes("google") && /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      block: true,
      icon: /* @__PURE__ */ import_react.default.createElement(import_icons.GoogleOutlined, null),
      className: "saas-login-social-button google",
      onClick: () => handleSocialLogin("google")
    },
    socialLoginTexts.google
  ), loginMethods.includes("facebook") && /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      block: true,
      icon: /* @__PURE__ */ import_react.default.createElement(import_icons.FacebookOutlined, null),
      className: "saas-login-social-button facebook",
      onClick: () => handleSocialLogin("facebook")
    },
    socialLoginTexts.facebook
  ), loginMethods.includes("apple") && /* @__PURE__ */ import_react.default.createElement(
    import_antd.Button,
    {
      block: true,
      icon: /* @__PURE__ */ import_react.default.createElement(import_icons.AppleOutlined, null),
      className: "saas-login-social-button apple",
      onClick: () => handleSocialLogin("apple")
    },
    socialLoginTexts.apple
  ))), showFooter && /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-footer" }, showSignUp && /* @__PURE__ */ import_react.default.createElement("p", { className: "saas-login-signup" }, signUpText, signUpLink ? /* @__PURE__ */ import_react.default.createElement("a", { href: signUpLink }, "Sign up") : /* @__PURE__ */ import_react.default.createElement("a", { onClick: onSignUp }, "Sign up")), otherLinks.length > 0 && /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-login-links" }, otherLinks.map((link, index) => /* @__PURE__ */ import_react.default.createElement(
    "a",
    {
      key: index,
      href: link.url,
      target: "_blank",
      rel: "noopener noreferrer"
    },
    link.text
  ))))));
};
var login_and_register_default = loginAndRegister;
