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");
//#region src/components/authentication/admin/AuthMethods/components/PhoneSettingsContent.tsx
_pisell_utils.locales.init(require_locales.default, localStorage.getItem("umi_locale") || "en");
const getDefaultLoginMethods = () => [{
	id: "password",
	title: _pisell_utils.locales.getText("auth.phone.login.password"),
	description: _pisell_utils.locales.getText("auth.phone.login.password.description"),
	enabled: true
}, {
	id: "sms",
	title: _pisell_utils.locales.getText("auth.phone.login.sms"),
	description: _pisell_utils.locales.getText("auth.phone.login.sms.description"),
	enabled: true
}];
const PhoneSettingsContent = ({ onSettingsChange, initialSettings }) => {
	var _initialSettings$enab, _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] = (0, react.useState)("sms");
	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 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.phone.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.phone.registration.enable")), /* @__PURE__ */ react.default.createElement("div", { className: "settings-item-description" }, _pisell_utils.locales.getText("auth.phone.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.phone.verification.title")), /* @__PURE__ */ react.default.createElement("div", { className: "settings-section-description" }, _pisell_utils.locales.getText("auth.phone.verification.description")), /* @__PURE__ */ react.default.createElement(antd.Radio.Group, {
		value: verificationType,
		className: "verification-radio-group"
	}, /* @__PURE__ */ react.default.createElement("div", { className: "verification-option" }, /* @__PURE__ */ react.default.createElement(antd.Radio, { value: "sms" }, /* @__PURE__ */ react.default.createElement("div", { className: "verification-option-content" }, /* @__PURE__ */ react.default.createElement("div", { className: "verification-option-title" }, _pisell_utils.locales.getText("auth.phone.verification.sms")), /* @__PURE__ */ react.default.createElement("div", { className: "verification-option-description" }, _pisell_utils.locales.getText("auth.phone.verification.sms.description"))))))), /* @__PURE__ */ react.default.createElement("div", { className: "settings-section" }, /* @__PURE__ */ react.default.createElement("div", { className: "settings-section-title" }, _pisell_utils.locales.getText("auth.phone.login.title")), /* @__PURE__ */ react.default.createElement("div", { className: "settings-section-description" }, _pisell_utils.locales.getText("auth.phone.login.description")), /* @__PURE__ */ react.default.createElement(require_LoginMethodsList.default, {
		methods: loginMethods,
		onMethodsChange: handleLoginMethodsChange
	})));
};
//#endregion
exports.default = PhoneSettingsContent;
