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/authentication/admin/AuthMethods/components/EmailSettingsContent.tsx
var EmailSettingsContent_exports = {};
__export(EmailSettingsContent_exports, {
  default: () => EmailSettingsContent_default
});
module.exports = __toCommonJS(EmailSettingsContent_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_icons = require("@ant-design/icons");
var import_utils = require("@pisell/utils");
var import_LoginMethodsList = __toESM(require("./LoginMethodsList"));
var import_locales = __toESM(require("../locales"));
import_utils.locales.init(import_locales.default, localStorage.getItem("umi_locale") || "en");
var getDefaultLoginMethods = () => [
  {
    id: "password",
    title: import_utils.locales.getText("auth.email.login.password"),
    description: import_utils.locales.getText("auth.email.login.password.description"),
    enabled: true
  }
  //   {
  //     id: 'magic-link',
  //     title: locales.getText('auth.email.login.magic-link'),
  //     description: locales.getText('auth.email.login.magic-link.description'),
  //     enabled: true,  
  //   },
  //   {
  //     id: 'verification-code',
  //     title: locales.getText('auth.email.login.verification-code'),
  //     description: locales.getText('auth.email.login.verification-code.description'),
  //     enabled: false,
  //   },
];
var EmailSettingsContent = ({ onSettingsChange, initialSettings }) => {
  const [enableRegistration, setEnableRegistration] = (0, import_react.useState)((initialSettings == null ? void 0 : initialSettings.enableRegistration) ?? true);
  const [verificationType, setVerificationType] = (0, import_react.useState)((initialSettings == null ? void 0 : initialSettings.verificationType) ?? "link");
  const [loginMethods, setLoginMethods] = (0, import_react.useState)((initialSettings == null ? void 0 : initialSettings.loginMethods) ?? getDefaultLoginMethods());
  const handleSettingsChange = (newSettings) => {
    const settings = {
      enableRegistration,
      verificationType,
      loginMethods,
      ...newSettings
    };
    onSettingsChange == null ? void 0 : onSettingsChange(settings);
  };
  const handleEnableRegistrationChange = (checked) => {
    setEnableRegistration(checked);
    handleSettingsChange({ enableRegistration: checked });
  };
  const handleVerificationTypeChange = (value) => {
    setVerificationType(value);
    handleSettingsChange({ verificationType: value });
  };
  const handleLoginMethodsChange = (methods) => {
    setLoginMethods(methods);
    handleSettingsChange({ loginMethods: methods });
  };
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-section" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-section-title" }, import_utils.locales.getText("auth.email.registration.title")), /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-item" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-item-main" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Switch, { checked: enableRegistration, onChange: handleEnableRegistrationChange }), /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-item-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-item-title" }, import_utils.locales.getText("auth.email.registration.enable")), /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-item-description" }, import_utils.locales.getText("auth.email.registration.enable.description")))))), /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-section" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-section-title" }, import_utils.locales.getText("auth.email.verification.title")), /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-section-description" }, import_utils.locales.getText("auth.email.verification.description")), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Radio.Group,
    {
      value: verificationType,
      onChange: (e) => handleVerificationTypeChange(e.target.value),
      className: "verification-radio-group"
    },
    /* @__PURE__ */ import_react.default.createElement("div", { className: "verification-option" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Radio, { value: "link" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "verification-option-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "verification-option-title" }, import_utils.locales.getText("auth.email.verification.link")), /* @__PURE__ */ import_react.default.createElement("div", { className: "verification-option-description" }, import_utils.locales.getText("auth.email.verification.link.description"))))),
    /* @__PURE__ */ import_react.default.createElement("div", { className: "verification-option" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Radio, { value: "code" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "verification-option-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "verification-option-title" }, import_utils.locales.getText("auth.email.verification.code")), /* @__PURE__ */ import_react.default.createElement("div", { className: "verification-option-description" }, import_utils.locales.getText("auth.email.verification.code.description")))))
  ), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Alert,
    {
      message: import_utils.locales.getText("auth.email.verification.note"),
      description: import_utils.locales.getText("auth.email.verification.note.description"),
      type: "info",
      icon: /* @__PURE__ */ import_react.default.createElement(import_icons.InfoCircleOutlined, null),
      showIcon: true,
      className: "verification-note"
    }
  )), /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-section" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-section-title" }, import_utils.locales.getText("auth.email.login.title")), /* @__PURE__ */ import_react.default.createElement("div", { className: "settings-section-description" }, import_utils.locales.getText("auth.email.login.description")), /* @__PURE__ */ import_react.default.createElement(import_LoginMethodsList.default, { methods: loginMethods, onMethodsChange: handleLoginMethodsChange })));
};
var EmailSettingsContent_default = EmailSettingsContent;
