import PhoneField from "../../../pisellSelectCustomerModal/RightPanel/Add/PhoneField/index.js";
import { parseMaxStatus } from "./utils.js";
import React from "react";
import { Checkbox, Form, Input } from "antd";
import { locales } from "@pisell/utils";
import { PisellModal } from "@pisell/materials";
import "./index.less";
//#region src/components/booking/forms/sendModal/index.tsx
const SendModal = ({ open, refreshKey, onCancel, onOk, defaultValues = {}, onValuesChange }) => {
	const [form] = Form.useForm();
	const sendSms = Form.useWatch("sendSms", form);
	const sendEmail = Form.useWatch("sendEmail", form);
	const handleOk = () => {
		form.validateFields().then((values) => {
			onOk(values);
		});
	};
	return /* @__PURE__ */ React.createElement(PisellModal, {
		open,
		title: locales.getText("pisell2.text.send-form-reminder"),
		onCancel,
		onOk: handleOk,
		okText: locales.getText("pisell2.text.send-form-ok")
	}, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode-send-form-wrap" }, /* @__PURE__ */ React.createElement(Form, {
		form,
		key: refreshKey,
		onValuesChange,
		layout: "vertical",
		initialValues: defaultValues
	}, /* @__PURE__ */ React.createElement(Form.Item, {
		name: "sendSms",
		valuePropName: "checked",
		style: { marginBottom: 12 }
	}, /* @__PURE__ */ React.createElement(Checkbox, null, locales.getText("pisell2.text.send-sms-reminder"))), /* @__PURE__ */ React.createElement(Form.Item, {
		name: "phone",
		style: { marginLeft: 16 },
		rules: [{
			required: sendSms,
			message: locales.getText("pisell2.text.phone-required-error-message")
		}, { validator: (_, value) => {
			if (!value || !value.phone) return Promise.reject(locales.getText("pisell2.text.phone-required-error-message"));
			try {
				if (!parseMaxStatus(value)) return Promise.reject(locales.getText("pisell2.text.phone-format-error-message"));
				return Promise.resolve();
			} catch (error) {
				return Promise.reject(locales.getText("pisell2.text.phone-format-error-message"));
			}
		} }]
	}, /* @__PURE__ */ React.createElement(PhoneField, null)), /* @__PURE__ */ React.createElement(Form.Item, {
		name: "sendEmail",
		valuePropName: "checked",
		style: { marginBottom: 12 }
	}, /* @__PURE__ */ React.createElement(Checkbox, null, locales.getText("pisell2.text.send-email-reminder"))), /* @__PURE__ */ React.createElement(Form.Item, {
		name: "email",
		style: { marginLeft: 16 },
		rules: [{
			required: sendEmail,
			message: locales.getText("pisell2.text.email-required-error-message")
		}, {
			pattern: /^([a-zA-Z0-9_\-\.+])+@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,63})+$/,
			message: locales.getText("pisell2.text.send-email-email-error-message")
		}]
	}, /* @__PURE__ */ React.createElement(Input, { size: "large" })))));
};
//#endregion
export { SendModal as default };
