import { Field } from "../../utilities/form/Field.mjs";
import { useForm } from "../../utilities/form/formHooks.mjs";
import { useTenantStore } from "../../stores/tenantStore.mjs";
import { useUser } from "../../utilities/auth/useUser.mjs";
import { LayoutUnit } from "../../layout/LayoutUnit.mjs";
import { AmbientTextField } from "../inputs/textField/AmbientTextField.mjs";
import { CkRichEditor } from "../inputs/richEditors/CkRichEditor.mjs";
import { AmbientAutoComplete } from "../inputs/textField/AmbientAutoComplete.mjs";
import { c } from "react-compiler-runtime";
import React, { useEffect } from "react";
import { useTranslation } from "react-i18next";
//#region src/UI/forms/UdpTransactionEmailForm.jsx
const UdpTransactionEmailForm = (t0) => {
	const $ = c(73);
	const { existingTransactionAttachments, toOptions, ccOptions, toLabelFunction, toGroupBy, toFilterOptions, ccLabelFunction, ccGroupBy, ccFilterOptions, attachmentsLabelFunction, toInitialValue: t1, ccInitialValue: t2, existingTransactionAttachmentsInitialValue: t3, subjectInitialValue: t4, body: t5, udpTransactionId } = t0;
	let t6;
	if ($[0] !== t1) {
		t6 = t1 === void 0 ? [] : t1;
		$[0] = t1;
		$[1] = t6;
	} else t6 = $[1];
	const toInitialValue = t6;
	let t7;
	if ($[2] !== t2) {
		t7 = t2 === void 0 ? [] : t2;
		$[2] = t2;
		$[3] = t7;
	} else t7 = $[3];
	const ccInitialValue = t7;
	let t8;
	if ($[4] !== t3) {
		t8 = t3 === void 0 ? [] : t3;
		$[4] = t3;
		$[5] = t8;
	} else t8 = $[5];
	const existingTransactionAttachmentsInitialValue = t8;
	const subjectInitialValue = t4 === void 0 ? "" : t4;
	const body = t5 === void 0 ? "" : t5;
	const i18n = useTranslation().t;
	const form = useForm();
	const user = useUser();
	const currentTenant = useTenantStore(_temp);
	let t9;
	if ($[6] !== form) {
		t9 = (value) => {
			form.change("body", value);
		};
		$[6] = form;
		$[7] = t9;
	} else t9 = $[7];
	const handleOnBodyChange = t9;
	let t10;
	let t11;
	if ($[8] !== body || $[9] !== form) {
		t10 = () => {
			form.change("body", body);
		};
		t11 = [body, form];
		$[8] = body;
		$[9] = form;
		$[10] = t10;
		$[11] = t11;
	} else {
		t10 = $[10];
		t11 = $[11];
	}
	useEffect(t10, t11);
	let t12;
	if ($[12] !== i18n) {
		t12 = i18n("To");
		$[12] = i18n;
		$[13] = t12;
	} else t12 = $[13];
	let t13;
	if ($[14] !== t12 || $[15] !== toFilterOptions || $[16] !== toGroupBy || $[17] !== toInitialValue || $[18] !== toLabelFunction || $[19] !== toOptions) {
		t13 = /* @__PURE__ */ React.createElement(Field, {
			component: AmbientAutoComplete,
			name: "to",
			margin: "normal",
			variant: "outlined",
			isMultiple: true,
			options: toOptions,
			getOptionLabelFunction: toLabelFunction,
			groupBy: toGroupBy,
			filterOptions: toFilterOptions,
			label: t12,
			required: true,
			initialValue: toInitialValue
		});
		$[14] = t12;
		$[15] = toFilterOptions;
		$[16] = toGroupBy;
		$[17] = toInitialValue;
		$[18] = toLabelFunction;
		$[19] = toOptions;
		$[20] = t13;
	} else t13 = $[20];
	let t14;
	if ($[21] !== i18n) {
		t14 = i18n("Cc");
		$[21] = i18n;
		$[22] = t14;
	} else t14 = $[22];
	let t15;
	if ($[23] !== ccFilterOptions || $[24] !== ccGroupBy || $[25] !== ccInitialValue || $[26] !== ccLabelFunction || $[27] !== ccOptions || $[28] !== t14) {
		t15 = /* @__PURE__ */ React.createElement(Field, {
			component: AmbientAutoComplete,
			name: "cc",
			margin: "normal",
			variant: "outlined",
			isMultiple: true,
			options: ccOptions,
			getOptionLabelFunction: ccLabelFunction,
			groupBy: ccGroupBy,
			filterOptions: ccFilterOptions,
			label: t14,
			initialValue: ccInitialValue
		});
		$[23] = ccFilterOptions;
		$[24] = ccGroupBy;
		$[25] = ccInitialValue;
		$[26] = ccLabelFunction;
		$[27] = ccOptions;
		$[28] = t14;
		$[29] = t15;
	} else t15 = $[29];
	let t16;
	if ($[30] !== i18n) {
		t16 = i18n("Attachments");
		$[30] = i18n;
		$[31] = t16;
	} else t16 = $[31];
	let t17;
	if ($[32] !== attachmentsLabelFunction || $[33] !== existingTransactionAttachments || $[34] !== existingTransactionAttachmentsInitialValue || $[35] !== t16) {
		t17 = /* @__PURE__ */ React.createElement(Field, {
			component: AmbientAutoComplete,
			name: "attachments",
			margin: "normal",
			variant: "outlined",
			isMultiple: true,
			options: existingTransactionAttachments,
			getOptionLabelFunction: attachmentsLabelFunction,
			label: t16,
			initialValue: existingTransactionAttachmentsInitialValue
		});
		$[32] = attachmentsLabelFunction;
		$[33] = existingTransactionAttachments;
		$[34] = existingTransactionAttachmentsInitialValue;
		$[35] = t16;
		$[36] = t17;
	} else t17 = $[36];
	let t18;
	if ($[37] !== i18n) {
		t18 = i18n("Subject");
		$[37] = i18n;
		$[38] = t18;
	} else t18 = $[38];
	let t19;
	if ($[39] !== subjectInitialValue || $[40] !== t18) {
		t19 = /* @__PURE__ */ React.createElement(Field, {
			component: AmbientTextField,
			name: "subject",
			margin: "normal",
			variant: "outlined",
			label: t18,
			required: true,
			initialValue: subjectInitialValue
		});
		$[39] = subjectInitialValue;
		$[40] = t18;
		$[41] = t19;
	} else t19 = $[41];
	let t20;
	if ($[42] === Symbol.for("react.memo_cache_sentinel")) {
		t20 = /* @__PURE__ */ React.createElement(LayoutUnit, { unit: "nudge" });
		$[42] = t20;
	} else t20 = $[42];
	let t21;
	if ($[43] !== body || $[44] !== handleOnBodyChange) {
		t21 = /* @__PURE__ */ React.createElement(CkRichEditor, {
			name: "body",
			handleChange: handleOnBodyChange,
			data: body
		});
		$[43] = body;
		$[44] = handleOnBodyChange;
		$[45] = t21;
	} else t21 = $[45];
	let t22;
	if ($[46] !== i18n) {
		t22 = i18n("Sender Name");
		$[46] = i18n;
		$[47] = t22;
	} else t22 = $[47];
	const t23 = user?.name || "";
	let t24;
	if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
		t24 = { display: "none" };
		$[48] = t24;
	} else t24 = $[48];
	let t25;
	if ($[49] !== t22 || $[50] !== t23) {
		t25 = /* @__PURE__ */ React.createElement(Field, {
			component: AmbientTextField,
			name: "senderName",
			margin: "normal",
			variant: "outlined",
			label: t22,
			required: true,
			initialValue: t23,
			style: t24
		});
		$[49] = t22;
		$[50] = t23;
		$[51] = t25;
	} else t25 = $[51];
	let t26;
	if ($[52] !== i18n) {
		t26 = i18n("Current Tenant Name");
		$[52] = i18n;
		$[53] = t26;
	} else t26 = $[53];
	const t27 = currentTenant?.name || "";
	let t28;
	if ($[54] === Symbol.for("react.memo_cache_sentinel")) {
		t28 = { display: "none" };
		$[54] = t28;
	} else t28 = $[54];
	let t29;
	if ($[55] !== t26 || $[56] !== t27) {
		t29 = /* @__PURE__ */ React.createElement(Field, {
			component: AmbientTextField,
			name: "currentTenantName",
			margin: "normal",
			variant: "outlined",
			label: t26,
			required: true,
			initialValue: t27,
			style: t28
		});
		$[55] = t26;
		$[56] = t27;
		$[57] = t29;
	} else t29 = $[57];
	let t30;
	if ($[58] !== i18n) {
		t30 = i18n("UDP Transaction ID");
		$[58] = i18n;
		$[59] = t30;
	} else t30 = $[59];
	const t31 = udpTransactionId || "";
	let t32;
	if ($[60] === Symbol.for("react.memo_cache_sentinel")) {
		t32 = { display: "none" };
		$[60] = t32;
	} else t32 = $[60];
	let t33;
	if ($[61] !== t30 || $[62] !== t31) {
		t33 = /* @__PURE__ */ React.createElement(Field, {
			component: AmbientTextField,
			name: "udpTransactionId",
			margin: "normal",
			variant: "outlined",
			label: t30,
			required: true,
			initialValue: t31,
			style: t32
		});
		$[61] = t30;
		$[62] = t31;
		$[63] = t33;
	} else t33 = $[63];
	let t34;
	if ($[64] !== t13 || $[65] !== t15 || $[66] !== t17 || $[67] !== t19 || $[68] !== t21 || $[69] !== t25 || $[70] !== t29 || $[71] !== t33) {
		t34 = /* @__PURE__ */ React.createElement(React.Fragment, null, t13, t15, t17, t19, t20, t21, t25, t29, t33);
		$[64] = t13;
		$[65] = t15;
		$[66] = t17;
		$[67] = t19;
		$[68] = t21;
		$[69] = t25;
		$[70] = t29;
		$[71] = t33;
		$[72] = t34;
	} else t34 = $[72];
	return t34;
};
function _temp(state) {
	return state.currentTenant;
}
//#endregion
export { UdpTransactionEmailForm };

//# sourceMappingURL=UdpTransactionEmailForm.mjs.map