import { Field as Field$1 } from "../../../../utilities/form/Field.mjs";
import { FluentButton } from "../../../../UI/inputs/buttons/FluentButton.mjs";
import { FluentTextField } from "../../../../UI/inputs/textField/FluentTextField.mjs";
import { AmbientAutoComplete } from "../../../../UI/inputs/textField/AmbientAutoComplete.mjs";
import { c } from "react-compiler-runtime";
import React, { useEffect } from "react";
import { makeStyles } from "@material-ui/core";
import { useForm, useFormState } from "react-final-form";
import { StatusCircleErrorXIcon } from "@fluentui/react-icons";
import { useTranslation } from "react-i18next";
import { FieldArray } from "react-final-form-arrays";
//#region src/udp/pages/UdpTransactionTypesPage/forms/UdpTransactionTypeTransactionActionFormFields.jsx
const useStyles = makeStyles((theme) => ({
	domainFields: {
		display: "flex",
		flexDirection: "row",
		alignItems: "flex-end",
		justifyContent: "flex-start",
		"& > *": { marginRight: theme.spacing(2) }
	},
	addRemoveButtons: {
		display: "flex",
		flexDirection: "row",
		alignItems: "center",
		justifyContent: "flex-start",
		margin: `${theme.spacing(2)}px  0  0 ${-theme.spacing(2)}px`,
		"& > *": { margin: `0 ${theme.spacing(2)}px` }
	},
	removeIcon: {
		fontSize: theme.spacing(3.5),
		marginTop: theme.spacing(1)
	},
	noRemoveIcon: { marginLeft: theme.spacing(3.5) }
}));
const UdpTransactionTypeTransactionActionFormFields = (props) => {
	const $ = c(73);
	const { transactionActionOptions, catalogObjectProperties, actionApiOptions, pageOptions, transactionTypeStatusOptions, showMandatoryFields, showHiddenFields, showToStatusField, showActionApiField, showPageField, showDomainDataToUpdateFields, pushToFieldArray } = props;
	const { t } = useTranslation();
	const classes = useStyles();
	const form = useForm();
	const { values } = useFormState();
	let t0;
	if ($[0] !== form || $[1] !== showActionApiField || $[2] !== showDomainDataToUpdateFields || $[3] !== showHiddenFields || $[4] !== showMandatoryFields || $[5] !== showPageField || $[6] !== showToStatusField) {
		t0 = () => {
			if (!showMandatoryFields) form.change("mandatoryFields", []);
			if (!showHiddenFields) form.change("hiddenFields", []);
			if (!showToStatusField) form.change("toStatus", null);
			if (!showActionApiField) form.change("actionApiId", null);
			if (!showPageField) form.change("pageId", []);
			if (!showDomainDataToUpdateFields) form.change("domainDataToUpdate", [[]]);
		};
		$[0] = form;
		$[1] = showActionApiField;
		$[2] = showDomainDataToUpdateFields;
		$[3] = showHiddenFields;
		$[4] = showMandatoryFields;
		$[5] = showPageField;
		$[6] = showToStatusField;
		$[7] = t0;
	} else t0 = $[7];
	let t1;
	if ($[8] !== form || $[9] !== showActionApiField || $[10] !== showDomainDataToUpdateFields || $[11] !== showHiddenFields || $[12] !== showMandatoryFields || $[13] !== showPageField || $[14] !== showToStatusField || $[15] !== values.transactionAction) {
		t1 = [
			form,
			showMandatoryFields,
			showHiddenFields,
			showToStatusField,
			showActionApiField,
			showPageField,
			showDomainDataToUpdateFields,
			values.transactionAction
		];
		$[8] = form;
		$[9] = showActionApiField;
		$[10] = showDomainDataToUpdateFields;
		$[11] = showHiddenFields;
		$[12] = showMandatoryFields;
		$[13] = showPageField;
		$[14] = showToStatusField;
		$[15] = values.transactionAction;
		$[16] = t1;
	} else t1 = $[16];
	useEffect(t0, t1);
	let t2;
	if ($[17] !== t) {
		t2 = t("Name");
		$[17] = t;
		$[18] = t2;
	} else t2 = $[18];
	let t3;
	if ($[19] !== t2) {
		t3 = /* @__PURE__ */ React.createElement(Field$1, {
			component: FluentTextField,
			label: t2,
			id: "name",
			name: "name",
			fullWidth: true,
			variant: "outlined",
			margin: "normal",
			size: "small",
			required: true
		});
		$[19] = t2;
		$[20] = t3;
	} else t3 = $[20];
	let t4;
	if ($[21] !== t) {
		t4 = t("Description");
		$[21] = t;
		$[22] = t4;
	} else t4 = $[22];
	let t5;
	if ($[23] !== t4) {
		t5 = /* @__PURE__ */ React.createElement(Field$1, {
			component: FluentTextField,
			label: t4,
			id: "description",
			name: "description",
			fullWidth: true,
			variant: "outlined",
			margin: "normal",
			size: "small"
		});
		$[23] = t4;
		$[24] = t5;
	} else t5 = $[24];
	let t6;
	if ($[25] !== t) {
		t6 = t("Icon");
		$[25] = t;
		$[26] = t6;
	} else t6 = $[26];
	let t7;
	if ($[27] !== t6) {
		t7 = /* @__PURE__ */ React.createElement(Field$1, {
			component: FluentTextField,
			label: t6,
			id: "icon",
			name: "icon",
			fullWidth: true,
			variant: "outlined",
			margin: "normal",
			size: "small"
		});
		$[27] = t6;
		$[28] = t7;
	} else t7 = $[28];
	let t8;
	if ($[29] !== t) {
		t8 = t("Transaction Action");
		$[29] = t;
		$[30] = t8;
	} else t8 = $[30];
	let t9;
	if ($[31] !== transactionActionOptions) {
		t9 = transactionActionOptions || [];
		$[31] = transactionActionOptions;
		$[32] = t9;
	} else t9 = $[32];
	let t10;
	if ($[33] !== t8 || $[34] !== t9) {
		t10 = /* @__PURE__ */ React.createElement(Field$1, {
			component: AmbientAutoComplete,
			label: t8,
			id: "transactionAction",
			name: "transactionAction",
			variant: "outlined",
			isMultiple: false,
			disableCloseOnSelect: false,
			options: t9,
			getOptionLabelFunction: _temp,
			valueForChange: _temp2,
			required: true
		});
		$[33] = t8;
		$[34] = t9;
		$[35] = t10;
	} else t10 = $[35];
	let t11;
	if ($[36] !== showToStatusField || $[37] !== t || $[38] !== transactionTypeStatusOptions) {
		t11 = showToStatusField && /* @__PURE__ */ React.createElement(Field$1, {
			component: AmbientAutoComplete,
			label: t("To Status"),
			id: "toStatus",
			name: "toStatus",
			variant: "outlined",
			isMultiple: false,
			disableCloseOnSelect: false,
			options: transactionTypeStatusOptions || [],
			getOptionLabelFunction: _temp3
		});
		$[36] = showToStatusField;
		$[37] = t;
		$[38] = transactionTypeStatusOptions;
		$[39] = t11;
	} else t11 = $[39];
	let t12;
	if ($[40] !== catalogObjectProperties || $[41] !== showMandatoryFields || $[42] !== t) {
		t12 = showMandatoryFields && /* @__PURE__ */ React.createElement(Field$1, {
			component: AmbientAutoComplete,
			label: t("Mandatory Fields"),
			id: "mandatoryFields",
			name: "mandatoryFields",
			variant: "outlined",
			isMultiple: true,
			disableCloseOnSelect: true,
			options: catalogObjectProperties || [],
			getOptionLabelFunction: _temp4
		});
		$[40] = catalogObjectProperties;
		$[41] = showMandatoryFields;
		$[42] = t;
		$[43] = t12;
	} else t12 = $[43];
	let t13;
	if ($[44] !== catalogObjectProperties || $[45] !== showHiddenFields || $[46] !== t) {
		t13 = showHiddenFields && /* @__PURE__ */ React.createElement(Field$1, {
			component: AmbientAutoComplete,
			label: t("Hidden Fields"),
			id: "hiddenFields",
			name: "hiddenFields",
			variant: "outlined",
			isMultiple: true,
			disableCloseOnSelect: true,
			options: catalogObjectProperties || [],
			getOptionLabelFunction: _temp5
		});
		$[44] = catalogObjectProperties;
		$[45] = showHiddenFields;
		$[46] = t;
		$[47] = t13;
	} else t13 = $[47];
	let t14;
	if ($[48] !== actionApiOptions || $[49] !== showActionApiField || $[50] !== t) {
		t14 = showActionApiField && /* @__PURE__ */ React.createElement(Field$1, {
			component: AmbientAutoComplete,
			label: t("Action Api"),
			id: "actionApiId",
			name: "actionApiId",
			variant: "outlined",
			isMultiple: false,
			disableCloseOnSelect: false,
			options: actionApiOptions || [],
			getOptionLabelFunction: _temp6
		});
		$[48] = actionApiOptions;
		$[49] = showActionApiField;
		$[50] = t;
		$[51] = t14;
	} else t14 = $[51];
	let t15;
	if ($[52] !== pageOptions || $[53] !== showPageField || $[54] !== t) {
		t15 = showPageField && /* @__PURE__ */ React.createElement(Field$1, {
			component: AmbientAutoComplete,
			label: t("Page"),
			id: "pageId",
			name: "pageId",
			variant: "outlined",
			isMultiple: false,
			disableCloseOnSelect: false,
			options: pageOptions || [],
			getOptionLabelFunction: _temp7
		});
		$[52] = pageOptions;
		$[53] = showPageField;
		$[54] = t;
		$[55] = t15;
	} else t15 = $[55];
	let t16;
	if ($[56] !== catalogObjectProperties || $[57] !== classes || $[58] !== pushToFieldArray || $[59] !== showDomainDataToUpdateFields || $[60] !== t) {
		t16 = showDomainDataToUpdateFields && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: classes.addRemoveButtons }, /* @__PURE__ */ React.createElement(FluentButton, {
			variant: "contained",
			color: "primary",
			onClick: () => pushToFieldArray("domainDataToUpdate", void 0)
		}, t("Add a Domain Field"))), /* @__PURE__ */ React.createElement(FieldArray, { name: "domainDataToUpdate" }, (t17) => {
			const { fields } = t17;
			return fields.map((name, index) => /* @__PURE__ */ React.createElement("div", {
				key: `${name}${index}`,
				className: classes.domainFields
			}, /* @__PURE__ */ React.createElement(Field$1, {
				component: AmbientAutoComplete,
				label: index === 0 && t("Field"),
				name: `${name}[0]`,
				variant: "outlined",
				isMultiple: false,
				disableCloseOnSelect: false,
				options: catalogObjectProperties || [],
				getOptionLabelFunction: _temp8,
				onChange: _temp9
			}), /* @__PURE__ */ React.createElement(Field$1, {
				component: FluentTextField,
				label: index === 0 && t("Value"),
				name: `${name}[1]`,
				fullWidth: true,
				variant: "outlined",
				margin: "normal",
				size: "small",
				onChange: _temp0
			}), /* @__PURE__ */ React.createElement("span", {
				onClick: () => fields.remove(index),
				style: { cursor: "pointer" },
				className: classes.removeIcon
			}, /* @__PURE__ */ React.createElement(StatusCircleErrorXIcon, null))));
		}));
		$[56] = catalogObjectProperties;
		$[57] = classes;
		$[58] = pushToFieldArray;
		$[59] = showDomainDataToUpdateFields;
		$[60] = t;
		$[61] = t16;
	} else t16 = $[61];
	let t17;
	if ($[62] !== t10 || $[63] !== t11 || $[64] !== t12 || $[65] !== t13 || $[66] !== t14 || $[67] !== t15 || $[68] !== t16 || $[69] !== t3 || $[70] !== t5 || $[71] !== t7) {
		t17 = /* @__PURE__ */ React.createElement(React.Fragment, null, t3, t5, t7, t10, t11, t12, t13, t14, t15, t16);
		$[62] = t10;
		$[63] = t11;
		$[64] = t12;
		$[65] = t13;
		$[66] = t14;
		$[67] = t15;
		$[68] = t16;
		$[69] = t3;
		$[70] = t5;
		$[71] = t7;
		$[72] = t17;
	} else t17 = $[72];
	return t17;
};
function _temp(option) {
	return option.name;
}
function _temp2(value) {
	return value;
}
function _temp3(option_0) {
	return option_0.name;
}
function _temp4(option_1) {
	return option_1;
}
function _temp5(option_2) {
	return option_2;
}
function _temp6(option_3) {
	return option_3.name;
}
function _temp7(option_4) {
	return option_4.name;
}
function _temp8(option_5) {
	return option_5;
}
function _temp9() {}
function _temp0() {}
//#endregion
export { UdpTransactionTypeTransactionActionFormFields as default };

//# sourceMappingURL=UdpTransactionTypeTransactionActionFormFields.mjs.map