import { _objectSpread2 } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import locales_default from "../locales.js";
import LoginMethodsList from "./LoginMethodsList.js";
import React, { useState } from "react";
import { Radio, Switch } from "antd";
import { locales } from "@pisell/utils";
//#region src/components/authentication/admin/AuthMethods/components/PhoneSettingsContent.tsx
locales.init(locales_default, localStorage.getItem("umi_locale") || "en");
const getDefaultLoginMethods = () => [{
	id: "password",
	title: locales.getText("auth.phone.login.password"),
	description: locales.getText("auth.phone.login.password.description"),
	enabled: true
}, {
	id: "sms",
	title: locales.getText("auth.phone.login.sms"),
	description: locales.getText("auth.phone.login.sms.description"),
	enabled: true
}];
const PhoneSettingsContent = ({ onSettingsChange, initialSettings }) => {
	var _initialSettings$enab, _initialSettings$logi;
	const [enableRegistration, setEnableRegistration] = useState((_initialSettings$enab = initialSettings === null || initialSettings === void 0 ? void 0 : initialSettings.enableRegistration) !== null && _initialSettings$enab !== void 0 ? _initialSettings$enab : true);
	const [verificationType] = useState("sms");
	const [loginMethods, setLoginMethods] = 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 = _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.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "settings-section" }, /* @__PURE__ */ React.createElement("div", { className: "settings-section-title" }, locales.getText("auth.phone.registration.title")), /* @__PURE__ */ React.createElement("div", { className: "settings-item" }, /* @__PURE__ */ React.createElement("div", { className: "settings-item-main" }, /* @__PURE__ */ React.createElement(Switch, {
		checked: enableRegistration,
		onChange: handleEnableRegistrationChange
	}), /* @__PURE__ */ React.createElement("div", { className: "settings-item-content" }, /* @__PURE__ */ React.createElement("div", { className: "settings-item-title" }, locales.getText("auth.phone.registration.enable")), /* @__PURE__ */ React.createElement("div", { className: "settings-item-description" }, locales.getText("auth.phone.registration.enable.description")))))), /* @__PURE__ */ React.createElement("div", { className: "settings-section" }, /* @__PURE__ */ React.createElement("div", { className: "settings-section-title" }, locales.getText("auth.phone.verification.title")), /* @__PURE__ */ React.createElement("div", { className: "settings-section-description" }, locales.getText("auth.phone.verification.description")), /* @__PURE__ */ React.createElement(Radio.Group, {
		value: verificationType,
		className: "verification-radio-group"
	}, /* @__PURE__ */ React.createElement("div", { className: "verification-option" }, /* @__PURE__ */ React.createElement(Radio, { value: "sms" }, /* @__PURE__ */ React.createElement("div", { className: "verification-option-content" }, /* @__PURE__ */ React.createElement("div", { className: "verification-option-title" }, locales.getText("auth.phone.verification.sms")), /* @__PURE__ */ React.createElement("div", { className: "verification-option-description" }, locales.getText("auth.phone.verification.sms.description"))))))), /* @__PURE__ */ React.createElement("div", { className: "settings-section" }, /* @__PURE__ */ React.createElement("div", { className: "settings-section-title" }, locales.getText("auth.phone.login.title")), /* @__PURE__ */ React.createElement("div", { className: "settings-section-description" }, locales.getText("auth.phone.login.description")), /* @__PURE__ */ React.createElement(LoginMethodsList, {
		methods: loginMethods,
		onMethodsChange: handleLoginMethodsChange
	})));
};
//#endregion
export { PhoneSettingsContent as default };
