import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _asyncToGenerator } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
import React, { useState } from "react";
import { Button, Form, Input } from "antd";
import { locales } from "@pisell/utils";
import "../index.less";
//#region src/plus/saasRegister/components/EntryInfo.tsx
const EntryInfo = (props) => {
	const { passwordLabel = locales.getText("pisell-saas-register-password-label"), passwordPlaceholder = locales.getText("pisell-saas-register-password-placeholder"), showDivider = true, dividerText = locales.getText("pisell-saas-register-divider-text"), showFirstName = true, showLastName = true, form } = props;
	const [loading, setLoading] = useState(false);
	const _handleEntryInfo = function() {
		var _ref = _asyncToGenerator(function* () {
			if (loading) return;
			setLoading(true);
			try {
				var _props$onEntryInfo;
				const values = (yield form.validateFields()) || {};
				yield props === null || props === void 0 || (_props$onEntryInfo = props.onEntryInfo) === null || _props$onEntryInfo === void 0 ? void 0 : _props$onEntryInfo.call(props, _objectSpread2(_objectSpread2({}, values), {}, { token: props.emailToken }));
			} catch (error) {
				console.error("handleEntryInfo_failed:", error);
			} finally {
				setLoading(false);
			}
		});
		return function _handleEntryInfo() {
			return _ref.apply(this, arguments);
		};
	}();
	return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
		className: "pisell-saas-register-form-email",
		style: { marginTop: "12px" }
	}, form.getFieldValue("email")), /* @__PURE__ */ React.createElement("div", { className: "pisell-saas-register-form" }, /* @__PURE__ */ React.createElement("div", { className: "form-item-label" }, passwordLabel), /* @__PURE__ */ React.createElement(Form.Item, {
		name: "password",
		rules: [{
			required: true,
			message: locales.getText("pisell-saas-register-password-required")
		}]
	}, /* @__PURE__ */ React.createElement(Input.Password, {
		placeholder: passwordPlaceholder,
		size: "large",
		className: "pisell-saas-register-input"
	})), showDivider && /* @__PURE__ */ React.createElement("div", { className: "pisell-saas-register-divider" }, /* @__PURE__ */ React.createElement("div", { className: "pisell-saas-register-divider-text" }, dividerText)), /* @__PURE__ */ React.createElement("div", null, showFirstName && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "form-item-label" }, locales.getText("pisell-saas-register-first-name-label")), /* @__PURE__ */ React.createElement(Form.Item, {
		name: "firstName",
		rules: [{ required: false }]
	}, /* @__PURE__ */ React.createElement(Input, {
		placeholder: locales.getText("pisell-saas-register-first-name-placeholder"),
		size: "large",
		className: "pisell-saas-register-input",
		maxLength: 50
	}))), showLastName && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "form-item-label" }, locales.getText("pisell-saas-register-last-name-label")), /* @__PURE__ */ React.createElement(Form.Item, {
		name: "lastName",
		rules: [{ required: false }]
	}, /* @__PURE__ */ React.createElement(Input, {
		placeholder: locales.getText("pisell-saas-register-last-name-placeholder"),
		size: "large",
		className: "pisell-saas-register-input",
		maxLength: 50
	}))), /* @__PURE__ */ React.createElement(Button, {
		type: "primary",
		block: true,
		size: "large",
		className: "pisell-saas-register-button",
		loading,
		onClick: _handleEntryInfo
	}, locales.getText("pisell-saas-register-button")))));
};
//#endregion
export { EntryInfo as default };
