import { Form } from "../../../../utilities/form/Form.mjs";
import { Field } from "../../../../utilities/form/Field.mjs";
import { LayoutUnit } from "../../../../layout/LayoutUnit.mjs";
import { FluentTextField } from "../../../../UI/inputs/textField/FluentTextField.mjs";
import { AmbientAutoComplete } from "../../../../UI/inputs/textField/AmbientAutoComplete.mjs";
import { TRANSACTION_TYPE_STATUS_COLORS } from "../../../utilities/transactionConstants.mjs";
import { c } from "react-compiler-runtime";
import React, { forwardRef, useImperativeHandle, useRef } from "react";
import { FormControlLabel, Switch } from "@material-ui/core";
import { useTranslation } from "react-i18next";
//#region src/udp/pages/UdpTransactionTypesPage/forms/UdpTransactionTypeStatusForm.jsx
const UdpTransactionTypeStatusForm = (props, ref) => {
	const $ = c(15);
	const { onSubmit, initialData } = props;
	const handleSubmitRef = useRef();
	const { t } = useTranslation();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = () => ({ submit: () => {
			handleSubmitRef?.current();
		} });
		$[0] = t0;
	} else t0 = $[0];
	useImperativeHandle(ref, t0);
	let t1;
	if ($[1] !== initialData || $[2] !== onSubmit) {
		t1 = (formData) => {
			onSubmit(formData, initialData);
		};
		$[1] = initialData;
		$[2] = onSubmit;
		$[3] = t1;
	} else t1 = $[3];
	const handleSubmit = t1;
	let t2;
	if ($[4] !== initialData?.code || $[5] !== initialData?.color || $[6] !== initialData?.isCancelledStatus || $[7] !== initialData?.isClosedStatus || $[8] !== initialData?.isDefault || $[9] !== initialData?.name || $[10] !== t) {
		t2 = (t3) => {
			const { handleSubmit: handleSubmit_0 } = t3;
			handleSubmitRef.current = handleSubmit_0;
			return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Field, {
				component: FluentTextField,
				label: t("Name"),
				id: "name",
				name: "name",
				fullWidth: true,
				variant: "outlined",
				margin: "normal",
				size: "small",
				required: true,
				initialValue: initialData?.name || ""
			}), /* @__PURE__ */ React.createElement(Field, {
				component: FluentTextField,
				label: t("Code"),
				id: "code",
				name: "code",
				fullWidth: true,
				variant: "outlined",
				margin: "normal",
				size: "small",
				initialValue: initialData?.code || ""
			}), /* @__PURE__ */ React.createElement(Field, {
				component: AmbientAutoComplete,
				label: t("Color"),
				id: "color",
				name: "color",
				variant: "outlined",
				isMultiple: false,
				disableCloseOnSelect: false,
				options: TRANSACTION_TYPE_STATUS_COLORS || [],
				getOptionLabelFunction: _temp,
				initialValue: TRANSACTION_TYPE_STATUS_COLORS?.find((color) => color?.value === initialData?.color) || null
			}), /* @__PURE__ */ React.createElement(LayoutUnit, { unit: "nudge" }), /* @__PURE__ */ React.createElement(FormControlLabel, {
				control: /* @__PURE__ */ React.createElement(Field, {
					component: Switch,
					id: "isDefault",
					name: "isDefault",
					type: "checkbox",
					initialValue: !!initialData?.isDefault
				}),
				label: t("Default")
			}), /* @__PURE__ */ React.createElement(LayoutUnit, { unit: "nudge" }), /* @__PURE__ */ React.createElement(FormControlLabel, {
				control: /* @__PURE__ */ React.createElement(Field, {
					component: Switch,
					id: "isClosedStatus",
					name: "isClosedStatus",
					type: "checkbox",
					initialValue: !!initialData?.isClosedStatus
				}),
				label: t("Closed Status")
			}), /* @__PURE__ */ React.createElement(LayoutUnit, { unit: "nudge" }), /* @__PURE__ */ React.createElement(FormControlLabel, {
				control: /* @__PURE__ */ React.createElement(Field, {
					component: Switch,
					id: "isCancelledStatus",
					name: "isCancelledStatus",
					type: "checkbox",
					initialValue: !!initialData?.isCancelledStatus
				}),
				label: t("Cancelled Status")
			}));
		};
		$[4] = initialData?.code;
		$[5] = initialData?.color;
		$[6] = initialData?.isCancelledStatus;
		$[7] = initialData?.isClosedStatus;
		$[8] = initialData?.isDefault;
		$[9] = initialData?.name;
		$[10] = t;
		$[11] = t2;
	} else t2 = $[11];
	let t3;
	if ($[12] !== handleSubmit || $[13] !== t2) {
		t3 = /* @__PURE__ */ React.createElement(Form, {
			onSubmit: handleSubmit,
			render: t2
		});
		$[12] = handleSubmit;
		$[13] = t2;
		$[14] = t3;
	} else t3 = $[14];
	return t3;
};
var UdpTransactionTypeStatusForm_default = forwardRef(UdpTransactionTypeStatusForm);
function _temp(option) {
	return option.name;
}
//#endregion
export { UdpTransactionTypeStatusForm_default as default };

//# sourceMappingURL=UdpTransactionTypeStatusForm.mjs.map