import { ConfigService } from "../../../../configService/index.mjs";
import { SideSheet } from "../../../../UI/surfaces/SideSheet.mjs";
import { SearchMethodUdpGrid } from "../../../../UI/templates/newGrid/SearchMethodUdpGrid.mjs";
import UdpTransactionTypeConfigurationCreateAndEditSidesheet from "./UdpTransactionTypeConfigurationCreateAndEditSidesheet.mjs";
import UdpTransactionTypeConfigurationTransactionActionSidesheet_default from "./UdpTransactionTypeConfigurationTransactionActionSidesheet.mjs";
import { c } from "react-compiler-runtime";
import React, { forwardRef, useImperativeHandle, useRef } from "react";
import { useTranslation } from "react-i18next";
//#region src/udp/pages/UdpTransactionTypesPage/sidesheets/UdpTransactionTypeConfigurationSidesheet.jsx
const UdpTransactionTypeConfigurationSidesheet = (props, ref) => {
	const $ = c(121);
	const { transactionType, transactionTypeConfiguration, isSideSheetOpen, isCreateOrEditTransactionTypeConfigurationSidesheetOpen, handleTransactionTypeConfigurationSidesheet, handleCreateOrEditTransactionTypeConfigurationSidesheet, handleCreateTransactionTypeConfiguration, handleUpdateTransactionTypeConfiguration, handleDeleteTransactionTypeConfiguration, transactionRuleTypes, catalogObjectProperties, ttstatuses, roles, transactionTypeConfigurationTransactionAction, isTransactionTypeConfigurationTransactionActionSidesheetOpen, handleTransactionTypeConfigurationTransactionActionSidesheet, handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet, isCreateOrEditTransactionTypeConfigurationTransactionActionSidesheetOpen, tttactions, handleCreateTransactionTypeConfigurationTransactionAction, handleUpdateTransactionTypeConfigurationTransactionAction, handleDeleteTransactionTypeConfigurationTransactionAction, ttctaList, ttctaGridApiRef } = props;
	const transactionTypeConfigurationGridApiRef = useRef(null);
	const { t } = useTranslation();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = () => ({ refreshServerSide: () => {
			transactionTypeConfigurationGridApiRef?.current?.refreshServerSide();
		} });
		$[0] = t0;
	} else t0 = $[0];
	useImperativeHandle(ref, t0);
	let t1;
	if ($[1] !== transactionRuleTypes) {
		t1 = (transactionRuleTypeId) => {
			if (!transactionRuleTypes) return "";
			return (transactionRuleTypes?.find((transactionRuleType) => transactionRuleType?.transactionRuleTypeId === transactionRuleTypeId))?.name || "";
		};
		$[1] = transactionRuleTypes;
		$[2] = t1;
	} else t1 = $[2];
	const getTransactionRuleTypeName = t1;
	let t2;
	if ($[3] !== t) {
		t2 = t("TransactionTypeConfigurationId");
		$[3] = t;
		$[4] = t2;
	} else t2 = $[4];
	let t3;
	if ($[5] !== t2) {
		t3 = {
			headerName: t2,
			field: "transactionTypeConfigurationId",
			resizable: true,
			sortable: false,
			hide: true
		};
		$[5] = t2;
		$[6] = t3;
	} else t3 = $[6];
	let t4;
	if ($[7] !== t) {
		t4 = t("Name");
		$[7] = t;
		$[8] = t4;
	} else t4 = $[8];
	let t5;
	if ($[9] !== t4) {
		t5 = {
			headerName: t4,
			field: "name",
			resizable: true,
			sortable: false
		};
		$[9] = t4;
		$[10] = t5;
	} else t5 = $[10];
	let t6;
	if ($[11] !== t) {
		t6 = t("Order");
		$[11] = t;
		$[12] = t6;
	} else t6 = $[12];
	let t7;
	if ($[13] !== t6) {
		t7 = {
			headerName: t6,
			field: "order",
			resizable: false,
			sortable: false
		};
		$[13] = t6;
		$[14] = t7;
	} else t7 = $[14];
	let t8;
	if ($[15] !== t) {
		t8 = t("Enabled");
		$[15] = t;
		$[16] = t8;
	} else t8 = $[16];
	let t9;
	if ($[17] !== t8) {
		t9 = {
			headerName: t8,
			field: "enabled",
			resizable: false,
			sortable: false,
			cellDataType: "boolean"
		};
		$[17] = t8;
		$[18] = t9;
	} else t9 = $[18];
	let t10;
	if ($[19] !== t) {
		t10 = t("Rule Type");
		$[19] = t;
		$[20] = t10;
	} else t10 = $[20];
	let t11;
	if ($[21] !== getTransactionRuleTypeName) {
		t11 = (params) => getTransactionRuleTypeName(params?.data?.transactionRuleTypeId);
		$[21] = getTransactionRuleTypeName;
		$[22] = t11;
	} else t11 = $[22];
	let t12;
	if ($[23] !== t10 || $[24] !== t11) {
		t12 = {
			headerName: t10,
			resizable: false,
			sortable: false,
			valueGetter: t11
		};
		$[23] = t10;
		$[24] = t11;
		$[25] = t12;
	} else t12 = $[25];
	let t13;
	if ($[26] !== t) {
		t13 = t("Actions");
		$[26] = t;
		$[27] = t13;
	} else t13 = $[27];
	let t14;
	if ($[28] !== t) {
		t14 = t("Edit");
		$[28] = t;
		$[29] = t14;
	} else t14 = $[29];
	let t15;
	if ($[30] !== handleCreateOrEditTransactionTypeConfigurationSidesheet) {
		t15 = (e, transactionTypeConfiguration_0) => {
			handleCreateOrEditTransactionTypeConfigurationSidesheet(true, transactionTypeConfiguration_0?.data);
		};
		$[30] = handleCreateOrEditTransactionTypeConfigurationSidesheet;
		$[31] = t15;
	} else t15 = $[31];
	let t16;
	if ($[32] !== t14 || $[33] !== t15) {
		t16 = {
			id: 0,
			title: t14,
			iconName: "edit",
			handleOnClick: t15
		};
		$[32] = t14;
		$[33] = t15;
		$[34] = t16;
	} else t16 = $[34];
	let t17;
	if ($[35] !== t) {
		t17 = t("Delete");
		$[35] = t;
		$[36] = t17;
	} else t17 = $[36];
	let t18;
	if ($[37] !== handleDeleteTransactionTypeConfiguration) {
		t18 = (e_0, transactionTypeConfiguration_1) => {
			handleDeleteTransactionTypeConfiguration(transactionTypeConfiguration_1?.data);
		};
		$[37] = handleDeleteTransactionTypeConfiguration;
		$[38] = t18;
	} else t18 = $[38];
	let t19;
	if ($[39] !== t17 || $[40] !== t18) {
		t19 = {
			id: 1,
			title: t17,
			iconName: "trashCan",
			handleOnClick: t18
		};
		$[39] = t17;
		$[40] = t18;
		$[41] = t19;
	} else t19 = $[41];
	let t20;
	if ($[42] !== t) {
		t20 = t("Link");
		$[42] = t;
		$[43] = t20;
	} else t20 = $[43];
	let t21;
	if ($[44] !== handleTransactionTypeConfigurationTransactionActionSidesheet) {
		t21 = (e_1, transactionTypeConfiguration_2) => {
			handleTransactionTypeConfigurationTransactionActionSidesheet(true, transactionTypeConfiguration_2?.data);
		};
		$[44] = handleTransactionTypeConfigurationTransactionActionSidesheet;
		$[45] = t21;
	} else t21 = $[45];
	let t22;
	if ($[46] !== t20 || $[47] !== t21) {
		t22 = {
			id: 2,
			title: t20,
			iconName: "link",
			handleOnClick: t21
		};
		$[46] = t20;
		$[47] = t21;
		$[48] = t22;
	} else t22 = $[48];
	let t23;
	if ($[49] !== t16 || $[50] !== t19 || $[51] !== t22) {
		t23 = { actionList: [
			t16,
			t19,
			t22
		] };
		$[49] = t16;
		$[50] = t19;
		$[51] = t22;
		$[52] = t23;
	} else t23 = $[52];
	let t24;
	if ($[53] !== t13 || $[54] !== t23) {
		t24 = {
			headerName: t13,
			field: "actions",
			cellRenderer: "actionsRenderer",
			cellRendererParams: t23,
			suppressMenu: true,
			sortable: false,
			filter: false,
			valueGetter: _temp
		};
		$[53] = t13;
		$[54] = t23;
		$[55] = t24;
	} else t24 = $[55];
	let t25;
	if ($[56] !== t12 || $[57] !== t24 || $[58] !== t3 || $[59] !== t5 || $[60] !== t7 || $[61] !== t9) {
		t25 = [
			t3,
			t5,
			t7,
			t9,
			t12,
			t24
		];
		$[56] = t12;
		$[57] = t24;
		$[58] = t3;
		$[59] = t5;
		$[60] = t7;
		$[61] = t9;
		$[62] = t25;
	} else t25 = $[62];
	const columnDefs = t25;
	let t26;
	if ($[63] !== t) {
		t26 = t("Rules");
		$[63] = t;
		$[64] = t26;
	} else t26 = $[64];
	let t27;
	if ($[65] !== t) {
		t27 = t("Add");
		$[65] = t;
		$[66] = t27;
	} else t27 = $[66];
	let t28;
	if ($[67] !== handleCreateOrEditTransactionTypeConfigurationSidesheet) {
		t28 = () => handleCreateOrEditTransactionTypeConfigurationSidesheet(true);
		$[67] = handleCreateOrEditTransactionTypeConfigurationSidesheet;
		$[68] = t28;
	} else t28 = $[68];
	let t29;
	if ($[69] !== t27 || $[70] !== t28) {
		t29 = {
			label: t27,
			iconName: "add",
			onClick: t28
		};
		$[69] = t27;
		$[70] = t28;
		$[71] = t29;
	} else t29 = $[71];
	let t30;
	if ($[72] !== t26 || $[73] !== t29) {
		t30 = {
			title: t26,
			primaryActionButton: t29
		};
		$[72] = t26;
		$[73] = t29;
		$[74] = t30;
	} else t30 = $[74];
	const headerConfig = t30;
	let t31;
	if ($[75] === Symbol.for("react.memo_cache_sentinel")) {
		t31 = [
			{ name: "agGridSizeColumnsToFit" },
			{ name: "agGridAutoSizeColumns" },
			{ name: "agGridResetColumns" },
			{ name: "agGridHideShowColumns" }
		];
		$[75] = t31;
	} else t31 = $[75];
	const gridFunctions = t31;
	let t32;
	if ($[76] === Symbol.for("react.memo_cache_sentinel")) {
		t32 = { pagination: true };
		$[76] = t32;
	} else t32 = $[76];
	const gridOptions = t32;
	let t33;
	if ($[77] === Symbol.for("react.memo_cache_sentinel")) {
		t33 = (api) => {
			transactionTypeConfigurationGridApiRef.current = api;
		};
		$[77] = t33;
	} else t33 = $[77];
	const handleGridApiCallback = t33;
	let t34;
	bb0: {
		let filterElements;
		if (transactionType?.transactionTypeId) {
			const t35 = transactionType?.transactionTypeId;
			let t36;
			if ($[78] !== t35) {
				t36 = [{
					searchField: "TransactionTypeId",
					searchOperator: "=",
					searchValue: t35,
					groupId: 1
				}];
				$[78] = t35;
				$[79] = t36;
			} else t36 = $[79];
			filterElements = t36;
			let t37;
			if ($[80] !== filterElements) {
				t37 = {
					requestUrl: `${ConfigService.productV1ApiUrl}/UdpTransactionTypeConfiguration/search`,
					customSearchObject: { filterElements }
				};
				$[80] = filterElements;
				$[81] = t37;
			} else t37 = $[81];
			t34 = t37;
			break bb0;
		}
		let t35;
		if ($[82] === Symbol.for("react.memo_cache_sentinel")) {
			t35 = {};
			$[82] = t35;
		} else t35 = $[82];
		t34 = t35;
	}
	const searchMethodConfig = t34;
	let t35;
	if ($[83] !== t) {
		t35 = t("Manage Rules");
		$[83] = t;
		$[84] = t35;
	} else t35 = $[84];
	let t36;
	if ($[85] !== handleTransactionTypeConfigurationSidesheet) {
		t36 = () => handleTransactionTypeConfigurationSidesheet(false);
		$[85] = handleTransactionTypeConfigurationSidesheet;
		$[86] = t36;
	} else t36 = $[86];
	let t37;
	if ($[87] !== columnDefs || $[88] !== headerConfig || $[89] !== searchMethodConfig) {
		t37 = /* @__PURE__ */ React.createElement(SearchMethodUdpGrid, {
			searchMethodConfig,
			columnDefs,
			gridHeaderConfig: headerConfig,
			gridOptions,
			gridApiCallback: handleGridApiCallback,
			gridFunctions
		});
		$[87] = columnDefs;
		$[88] = headerConfig;
		$[89] = searchMethodConfig;
		$[90] = t37;
	} else t37 = $[90];
	let t38;
	if ($[91] !== catalogObjectProperties || $[92] !== handleCreateOrEditTransactionTypeConfigurationSidesheet || $[93] !== handleCreateTransactionTypeConfiguration || $[94] !== handleUpdateTransactionTypeConfiguration || $[95] !== isCreateOrEditTransactionTypeConfigurationSidesheetOpen || $[96] !== roles || $[97] !== transactionRuleTypes || $[98] !== transactionTypeConfiguration || $[99] !== ttstatuses) {
		t38 = /* @__PURE__ */ React.createElement(UdpTransactionTypeConfigurationCreateAndEditSidesheet, {
			initialTransactionTypeConfiguration: transactionTypeConfiguration,
			isSideSheetOpen: isCreateOrEditTransactionTypeConfigurationSidesheetOpen,
			handleCreateTransactionTypeConfiguration,
			handleUpdateTransactionTypeConfiguration,
			handleSideSheet: handleCreateOrEditTransactionTypeConfigurationSidesheet,
			transactionRuleTypes,
			catalogObjectProperties,
			ttstatuses,
			roles
		});
		$[91] = catalogObjectProperties;
		$[92] = handleCreateOrEditTransactionTypeConfigurationSidesheet;
		$[93] = handleCreateTransactionTypeConfiguration;
		$[94] = handleUpdateTransactionTypeConfiguration;
		$[95] = isCreateOrEditTransactionTypeConfigurationSidesheetOpen;
		$[96] = roles;
		$[97] = transactionRuleTypes;
		$[98] = transactionTypeConfiguration;
		$[99] = ttstatuses;
		$[100] = t38;
	} else t38 = $[100];
	let t39;
	if ($[101] !== handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet || $[102] !== handleCreateTransactionTypeConfigurationTransactionAction || $[103] !== handleDeleteTransactionTypeConfigurationTransactionAction || $[104] !== handleTransactionTypeConfigurationTransactionActionSidesheet || $[105] !== handleUpdateTransactionTypeConfigurationTransactionAction || $[106] !== isCreateOrEditTransactionTypeConfigurationTransactionActionSidesheetOpen || $[107] !== isTransactionTypeConfigurationTransactionActionSidesheetOpen || $[108] !== transactionTypeConfiguration || $[109] !== transactionTypeConfigurationTransactionAction || $[110] !== ttctaGridApiRef || $[111] !== ttctaList || $[112] !== tttactions) {
		t39 = /* @__PURE__ */ React.createElement(UdpTransactionTypeConfigurationTransactionActionSidesheet_default, {
			ref: ttctaGridApiRef,
			transactionTypeConfiguration,
			transactionTypeConfigurationTransactionAction,
			isSideSheetOpen: isTransactionTypeConfigurationTransactionActionSidesheetOpen,
			handleTransactionTypeConfigurationTransactionActionSidesheet,
			handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet,
			isCreateOrEditSidesheetOpen: isCreateOrEditTransactionTypeConfigurationTransactionActionSidesheetOpen,
			tttactions,
			handleCreateTransactionTypeConfigurationTransactionAction,
			handleUpdateTransactionTypeConfigurationTransactionAction,
			handleDeleteTransactionTypeConfigurationTransactionAction,
			ttctaList
		});
		$[101] = handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet;
		$[102] = handleCreateTransactionTypeConfigurationTransactionAction;
		$[103] = handleDeleteTransactionTypeConfigurationTransactionAction;
		$[104] = handleTransactionTypeConfigurationTransactionActionSidesheet;
		$[105] = handleUpdateTransactionTypeConfigurationTransactionAction;
		$[106] = isCreateOrEditTransactionTypeConfigurationTransactionActionSidesheetOpen;
		$[107] = isTransactionTypeConfigurationTransactionActionSidesheetOpen;
		$[108] = transactionTypeConfiguration;
		$[109] = transactionTypeConfigurationTransactionAction;
		$[110] = ttctaGridApiRef;
		$[111] = ttctaList;
		$[112] = tttactions;
		$[113] = t39;
	} else t39 = $[113];
	let t40;
	if ($[114] !== isSideSheetOpen || $[115] !== t35 || $[116] !== t36 || $[117] !== t37 || $[118] !== t38 || $[119] !== t39) {
		t40 = /* @__PURE__ */ React.createElement(SideSheet, {
			open: isSideSheetOpen,
			width: 900,
			title: t35,
			onClose: t36
		}, t37, t38, t39);
		$[114] = isSideSheetOpen;
		$[115] = t35;
		$[116] = t36;
		$[117] = t37;
		$[118] = t38;
		$[119] = t39;
		$[120] = t40;
	} else t40 = $[120];
	return t40;
};
var UdpTransactionTypeConfigurationSidesheet_default = forwardRef(UdpTransactionTypeConfigurationSidesheet);
function _temp(params_0) {
	return params_0.data;
}
//#endregion
export { UdpTransactionTypeConfigurationSidesheet_default as default };

//# sourceMappingURL=UdpTransactionTypeConfigurationSidesheet.mjs.map