import { Form } from "../../../../utilities/form/Form.mjs";
import { Field } from "../../../../utilities/form/Field.mjs";
import { AmbientAutoComplete } from "../../../../UI/inputs/textField/AmbientAutoComplete.mjs";
import { c } from "react-compiler-runtime";
import React, { forwardRef, useImperativeHandle, useRef } from "react";
import { useTranslation } from "react-i18next";
//#region src/udp/pages/UdpTransactionTypesPage/forms/UdpTransactionTypeConfigurationTransactionActionForm.jsx
const UdpTransactionTypeConfigurationTransactionActionForm = (props, ref) => {
	const $ = c(12);
	const { onSubmit, initialData, transactionTypeTransactionActionOptions, isEditing } = props;
	const { t } = useTranslation();
	const handleSubmitRef = useRef();
	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?.transactionTypeTransactionActionId || $[5] !== isEditing || $[6] !== t || $[7] !== transactionTypeTransactionActionOptions) {
		t2 = (t3) => {
			const { handleSubmit: handleSubmit_0 } = t3;
			handleSubmitRef.current = handleSubmit_0;
			return /* @__PURE__ */ React.createElement(React.Fragment, null, isEditing && /* @__PURE__ */ React.createElement(Field, {
				component: AmbientAutoComplete,
				label: t("TransactionTypeTransactionActions"),
				id: "transactionTypeTransactionAction",
				name: "transactionTypeTransactionAction",
				variant: "outlined",
				isMultiple: false,
				disableCloseOnSelect: false,
				options: transactionTypeTransactionActionOptions || [],
				getOptionLabelFunction: _temp,
				initialValue: transactionTypeTransactionActionOptions?.find((ttta) => ttta?.transactionTypeTransactionActionId === initialData?.transactionTypeTransactionActionId) || null,
				required: true
			}), !!!isEditing && /* @__PURE__ */ React.createElement(Field, {
				component: AmbientAutoComplete,
				label: t("Actions to Link"),
				id: "transactionTypeTransactionActions",
				name: "transactionTypeTransactionActions",
				variant: "outlined",
				isMultiple: true,
				disableCloseOnSelect: true,
				options: transactionTypeTransactionActionOptions || [],
				getOptionLabelFunction: _temp2,
				required: true
			}));
		};
		$[4] = initialData?.transactionTypeTransactionActionId;
		$[5] = isEditing;
		$[6] = t;
		$[7] = transactionTypeTransactionActionOptions;
		$[8] = t2;
	} else t2 = $[8];
	let t3;
	if ($[9] !== handleSubmit || $[10] !== t2) {
		t3 = /* @__PURE__ */ React.createElement(Form, {
			onSubmit: handleSubmit,
			render: t2
		});
		$[9] = handleSubmit;
		$[10] = t2;
		$[11] = t3;
	} else t3 = $[11];
	return t3;
};
var UdpTransactionTypeConfigurationTransactionActionForm_default = forwardRef(UdpTransactionTypeConfigurationTransactionActionForm);
function _temp(option) {
	return option.name;
}
function _temp2(option_0) {
	return option_0.name;
}
//#endregion
export { UdpTransactionTypeConfigurationTransactionActionForm_default as default };

//# sourceMappingURL=UdpTransactionTypeConfigurationTransactionActionForm.mjs.map