const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_asyncToGenerator = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_types = require("../../types.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_materials = require("@pisell/materials");
//#region src/plus/saasDevice/devicePlanning/components/WorkAreaModal/index.tsx
const WorkAreaModal = ({ open, mode, record, submitting, getText, onCancel, onSubmit }) => {
	const [form] = antd.Form.useForm();
	(0, react.useEffect)(() => {
		if (!open) return;
		form.setFieldsValue({
			name: mode === "edit" ? require_types.toLangDict(record === null || record === void 0 ? void 0 : record.name) : require_objectSpread2._objectSpread2({}, require_types.EMPTY_I18N),
			description: mode === "edit" ? require_types.toLangDict(record === null || record === void 0 ? void 0 : record.description) : require_objectSpread2._objectSpread2({}, require_types.EMPTY_I18N)
		});
	}, [
		form,
		mode,
		open,
		record
	]);
	const handleOk = function() {
		var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
			onSubmit(yield form.validateFields());
		});
		return function handleOk() {
			return _ref.apply(this, arguments);
		};
	}();
	return /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal, {
		open,
		title: getText(mode === "create" ? "pisell2.saas.device-planning.modal.create-title" : "pisell2.saas.device-planning.modal.edit-title"),
		headerDivider: false,
		onCancel,
		okText: getText(mode === "create" ? "pisell2.saas.device-planning.modal.create" : "pisell2.saas.device-planning.modal.save"),
		cancelText: getText("pisell2.saas.device-planning.modal.cancel"),
		okButtonProps: {
			loading: submitting,
			onClick: handleOk
		},
		cancelButtonProps: { disabled: submitting },
		destroyOnClose: true,
		maskClosable: false,
		width: 520,
		className: "saas-device-planning-workarea-modal"
	}, /* @__PURE__ */ react.default.createElement(antd.Form, {
		form,
		layout: "vertical",
		preserve: false
	}, /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: "name",
		label: getText("pisell2.saas.device-planning.modal.name"),
		required: true,
		rules: [{ validator: require_types.validateI18nRequired(getText("pisell2.saas.device-planning.modal.name-required")) }]
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.BaseTranslation, { renderMode: "edit" })), /* @__PURE__ */ react.default.createElement(antd.Form.Item, {
		name: "description",
		label: getText("pisell2.saas.device-planning.modal.description")
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.BaseTranslation, {
		renderMode: "edit",
		type: "textarea"
	}))));
};
//#endregion
exports.default = WorkAreaModal;
