const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_locales = require("../locales.js");
const require_LoginMethodsList = require("./LoginMethodsList.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let _ant_design_icons = require("@ant-design/icons");
//#region src/components/authentication/admin/AuthMethods/components/EmailSettingsContent.tsx
_pisell_utils.locales.init(require_locales.default, localStorage.getItem("umi_locale") || "en");
const getDefaultLoginMethods = () => [{
	id: "password",
	title: _pisell_utils.locales.getText("auth.email.login.password"),
	description: _pisell_utils.locales.getText("auth.email.login.password.description"),
	enabled: true
}];
const EmailSettingsContent = ({ onSettingsChange, initialSettings }) => {
	var _initialSettings$enab, _initialSettings$veri, _initialSettings$logi;
	const [enableRegistration, setEnableRegistration] = (0, react.useState)((_initialSettings$enab = initialSettings === null || initialSettings === void 0 ? void 0 : initialSettings.enableRegistration) !== null && _initialSettings$enab !== void 0 ? _initialSettings$enab : true);
	const [verificationType, setVerificationType] = (0, react.useState)((_initialSettings$veri = initialSettings === null || initialSettings === void 0 ? void 0 : initialSettings.verificationType) !== null && _initialSettings$veri !== void 0 ? _initialSettings$veri : "link");
	const [loginMethods, setLoginMethods] = (0, react.useState)((_initialSettings$logi = initialSettings === null || initialSettings === void 0 ? void 0 : initialSettings.loginMethods) !== null && _initialSettings$logi !== void 0 ? _initialSettings$logi : getDefaultLoginMethods());
	const handleSettingsChange = (newSettings) => {
		const settings = require_objectSpread2._objectSpread2({
			enableRegistration,
			verificationType,
			loginMethods
		}, newSettings);
		onSettingsChange === null || onSettingsChange === 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__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: "settings-section" }, /* @__PURE__ */ react.default.createElement("div", { className: "settings-section-title" }, _pisell_utils.locales.getText("auth.email.registration.title")), /* @__PURE__ */ react.default.createElement("div", { className: "settings-item" }, /* @__PURE__ */ react.default.createElement("div", { className: "settings-item-main" }, /* @__PURE__ */ react.default.createElement(antd.Switch, {
		checked: enableRegistration,
		onChange: handleEnableRegistrationChange
	}), /* @__PURE__ */ react.default.createElement("div", { className: "settings-item-content" }, /* @__PURE__ */ react.default.createElement("div", { className: "settings-item-title" }, _pisell_utils.locales.getText("auth.email.registration.enable")), /* @__PURE__ */ react.default.createElement("div", { className: "settings-item-description" }, _pisell_utils.locales.getText("auth.email.registration.enable.description")))))), /* @__PURE__ */ react.default.createElement("div", { className: "settings-section" }, /* @__PURE__ */ react.default.createElement("div", { className: "settings-section-title" }, _pisell_utils.locales.getText("auth.email.verification.title")), /* @__PURE__ */ react.default.createElement("div", { className: "settings-section-description" }, _pisell_utils.locales.getText("auth.email.verification.description")), /* @__PURE__ */ react.default.createElement(antd.Radio.Group, {
		value: verificationType,
		onChange: (e) => handleVerificationTypeChange(e.target.value),
		className: "verification-radio-group"
	}, /* @__PURE__ */ react.default.createElement("div", { className: "verification-option" }, /* @__PURE__ */ react.default.createElement(antd.Radio, { value: "link" }, /* @__PURE__ */ react.default.createElement("div", { className: "verification-option-content" }, /* @__PURE__ */ react.default.createElement("div", { className: "verification-option-title" }, _pisell_utils.locales.getText("auth.email.verification.link")), /* @__PURE__ */ react.default.createElement("div", { className: "verification-option-description" }, _pisell_utils.locales.getText("auth.email.verification.link.description"))))), /* @__PURE__ */ react.default.createElement("div", { className: "verification-option" }, /* @__PURE__ */ react.default.createElement(antd.Radio, { value: "code" }, /* @__PURE__ */ react.default.createElement("div", { className: "verification-option-content" }, /* @__PURE__ */ react.default.createElement("div", { className: "verification-option-title" }, _pisell_utils.locales.getText("auth.email.verification.code")), /* @__PURE__ */ react.default.createElement("div", { className: "verification-option-description" }, _pisell_utils.locales.getText("auth.email.verification.code.description")))))), /* @__PURE__ */ react.default.createElement(antd.Alert, {
		message: _pisell_utils.locales.getText("auth.email.verification.note"),
		description: _pisell_utils.locales.getText("auth.email.verification.note.description"),
		type: "info",
		icon: /* @__PURE__ */ react.default.createElement(_ant_design_icons.InfoCircleOutlined, null),
		showIcon: true,
		className: "verification-note"
	})), /* @__PURE__ */ react.default.createElement("div", { className: "settings-section" }, /* @__PURE__ */ react.default.createElement("div", { className: "settings-section-title" }, _pisell_utils.locales.getText("auth.email.login.title")), /* @__PURE__ */ react.default.createElement("div", { className: "settings-section-description" }, _pisell_utils.locales.getText("auth.email.login.description")), /* @__PURE__ */ react.default.createElement(require_LoginMethodsList.default, {
		methods: loginMethods,
		onMethodsChange: handleLoginMethodsChange
	})));
};
//#endregion
exports.default = EmailSettingsContent;
