import { getLocale } from "../../utils/locales.js";
import locales_default from "./locales.js";
import React, { useMemo, useState } from "react";
import { Button, Form, Input } from "antd";
import "./index.less";
import { locales } from "@pisell/utils";
//#region src/components/login/index.tsx
const Login = (props) => {
	const { title, style, onLogin } = props;
	const [loading, setLoading] = useState(false);
	const onFinish = (values) => {
		setLoading(true);
		onLogin && onLogin(values, (data) => {
			setLoading(false);
		});
	};
	useMemo(() => {
		console.log(getLocale(), "getLocale()");
		locales.init(locales_default, getLocale());
	}, []);
	return /* @__PURE__ */ React.createElement("div", {
		className: "pisell-lowcode__login-wrap",
		style
	}, /* @__PURE__ */ React.createElement("div", { style: { width: "100%" } }, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__login-title" }, title || "Login"), /* @__PURE__ */ React.createElement(Form, { onFinish }, /* @__PURE__ */ React.createElement(Form.Item, {
		name: "email",
		rules: [{
			required: true,
			message: locales.getText("pisell2.text.email-placeholder")
		}, {
			pattern: /^\w+((.\w+)|(-\w+))@[A-Za-z0-9]+((.|-)[A-Za-z0-9]+).[A-Za-z0-9]+$/,
			message: locales.getText("pisell2.text.email-error")
		}]
	}, /* @__PURE__ */ React.createElement(Input, {
		placeholder: locales.getText("pisell2.text.email-placeholder"),
		className: "pisell-lowcode__login-input pisell-lowcode__field-style"
	})), /* @__PURE__ */ React.createElement(Form.Item, {
		name: "password",
		rules: [{
			required: true,
			message: locales.getText("pisell2.text.password-placeholder")
		}, {
			pattern: /* @__PURE__ */ new RegExp(/^[^\s]*$/, "g"),
			message: locales.getText("pisell2.text.password-error")
		}]
	}, /* @__PURE__ */ React.createElement(Input, {
		className: "pisell-lowcode__login-input pisell-lowcode__field-style",
		placeholder: locales.getText("pisell2.text.password-placeholder"),
		type: "Password",
		autoComplete: "new-password"
	})), /* @__PURE__ */ React.createElement(Form.Item, { noStyle: true }, /* @__PURE__ */ React.createElement(Button, {
		className: "pisell-lowcode__login-button pisell-lowcode__field-style",
		type: "primary",
		htmlType: "submit",
		size: "large",
		loading
	}, locales.getText("pisell2.text.login"))))));
};
//#endregion
export { Login as default };
