import { ConfigService } from "../../../../configService/index.mjs";
import { SideSheet } from "../../../../UI/surfaces/SideSheet.mjs";
import { SearchMethodUdpGrid } from "../../../../UI/templates/newGrid/SearchMethodUdpGrid.mjs";
import UdpTransactionTypeConfigurationTransactionActionCreateAndEditSidesheet from "./UdpTransactionTypeConfigurationTransactionActionCreateAndEditSidesheet.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/UdpTransactionTypeConfigurationTransactionActionSidesheet.jsx
const UdpTransactionTypeConfigurationTransactionActionSidesheet = (props, ref) => {
	const $ = c(77);
	const { transactionTypeConfiguration, transactionTypeConfigurationTransactionAction, isSideSheetOpen, handleTransactionTypeConfigurationTransactionActionSidesheet, isCreateOrEditSidesheetOpen, handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet, handleCreateTransactionTypeConfigurationTransactionAction, handleUpdateTransactionTypeConfigurationTransactionAction, handleDeleteTransactionTypeConfigurationTransactionAction, tttactions, ttctaList } = props;
	const ttctaGridApiRef = useRef(null);
	const { t } = useTranslation();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = () => ({ refreshServerSide: () => {
			ttctaGridApiRef?.current?.refreshServerSide();
		} });
		$[0] = t0;
	} else t0 = $[0];
	useImperativeHandle(ref, t0);
	let t1;
	if ($[1] !== tttactions) {
		t1 = (transactionTypeTransactionActionId) => {
			if (!tttactions?.length) return "";
			return tttactions.find((ttta) => ttta.transactionTypeTransactionActionId === transactionTypeTransactionActionId)?.name || "";
		};
		$[1] = tttactions;
		$[2] = t1;
	} else t1 = $[2];
	const getTTTActionName = t1;
	let t2;
	if ($[3] !== t) {
		t2 = t("TransactionTypeConfiguration");
		$[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("TransactionTypeTransactionAction");
		$[7] = t;
		$[8] = t4;
	} else t4 = $[8];
	let t5;
	if ($[9] !== t4) {
		t5 = {
			headerName: t4,
			field: "transactionTypeTransactionActionId",
			resizable: false,
			sortable: false,
			hide: true
		};
		$[9] = t4;
		$[10] = t5;
	} else t5 = $[10];
	let t6;
	if ($[11] !== t) {
		t6 = t("Name");
		$[11] = t;
		$[12] = t6;
	} else t6 = $[12];
	let t7;
	if ($[13] !== getTTTActionName) {
		t7 = (params) => getTTTActionName(params?.data?.transactionTypeTransactionActionId);
		$[13] = getTTTActionName;
		$[14] = t7;
	} else t7 = $[14];
	let t8;
	if ($[15] !== t6 || $[16] !== t7) {
		t8 = {
			headerName: t6,
			field: "name",
			resizable: true,
			sortable: false,
			valueGetter: t7
		};
		$[15] = t6;
		$[16] = t7;
		$[17] = t8;
	} else t8 = $[17];
	let t9;
	if ($[18] !== t) {
		t9 = t("Actions");
		$[18] = t;
		$[19] = t9;
	} else t9 = $[19];
	let t10;
	if ($[20] !== t) {
		t10 = t("Delete");
		$[20] = t;
		$[21] = t10;
	} else t10 = $[21];
	let t11;
	if ($[22] !== handleDeleteTransactionTypeConfigurationTransactionAction) {
		t11 = (e, transactionTypeConfigurationTransactionAction_0) => {
			handleDeleteTransactionTypeConfigurationTransactionAction(transactionTypeConfigurationTransactionAction_0?.data);
		};
		$[22] = handleDeleteTransactionTypeConfigurationTransactionAction;
		$[23] = t11;
	} else t11 = $[23];
	let t12;
	if ($[24] !== t10 || $[25] !== t11) {
		t12 = { actionList: [{
			id: 1,
			title: t10,
			iconName: "trashCan",
			handleOnClick: t11
		}] };
		$[24] = t10;
		$[25] = t11;
		$[26] = t12;
	} else t12 = $[26];
	let t13;
	if ($[27] !== t12 || $[28] !== t9) {
		t13 = {
			headerName: t9,
			field: "actions",
			cellRenderer: "actionsRenderer",
			cellRendererParams: t12,
			suppressMenu: true,
			sortable: false,
			filter: false,
			valueGetter: _temp
		};
		$[27] = t12;
		$[28] = t9;
		$[29] = t13;
	} else t13 = $[29];
	let t14;
	if ($[30] !== t13 || $[31] !== t3 || $[32] !== t5 || $[33] !== t8) {
		t14 = [
			t3,
			t5,
			t8,
			t13
		];
		$[30] = t13;
		$[31] = t3;
		$[32] = t5;
		$[33] = t8;
		$[34] = t14;
	} else t14 = $[34];
	const columnDefs = t14;
	let t15;
	if ($[35] !== t) {
		t15 = t("Linked Actions");
		$[35] = t;
		$[36] = t15;
	} else t15 = $[36];
	let t16;
	if ($[37] !== t) {
		t16 = t("Add");
		$[37] = t;
		$[38] = t16;
	} else t16 = $[38];
	let t17;
	if ($[39] !== handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet) {
		t17 = () => handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet(true);
		$[39] = handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet;
		$[40] = t17;
	} else t17 = $[40];
	let t18;
	if ($[41] !== t16 || $[42] !== t17) {
		t18 = {
			label: t16,
			iconName: "add",
			onClick: t17
		};
		$[41] = t16;
		$[42] = t17;
		$[43] = t18;
	} else t18 = $[43];
	let t19;
	if ($[44] !== t15 || $[45] !== t18) {
		t19 = {
			title: t15,
			primaryActionButton: t18
		};
		$[44] = t15;
		$[45] = t18;
		$[46] = t19;
	} else t19 = $[46];
	const headerConfig = t19;
	let t20;
	if ($[47] === Symbol.for("react.memo_cache_sentinel")) {
		t20 = [
			{ name: "agGridSizeColumnsToFit" },
			{ name: "agGridAutoSizeColumns" },
			{ name: "agGridResetColumns" },
			{ name: "agGridHideShowColumns" }
		];
		$[47] = t20;
	} else t20 = $[47];
	const gridFunctions = t20;
	let t21;
	if ($[48] === Symbol.for("react.memo_cache_sentinel")) {
		t21 = { pagination: true };
		$[48] = t21;
	} else t21 = $[48];
	const gridOptions = t21;
	let t22;
	if ($[49] === Symbol.for("react.memo_cache_sentinel")) {
		t22 = (api) => {
			ttctaGridApiRef.current = api;
		};
		$[49] = t22;
	} else t22 = $[49];
	const handleGridApiCallback = t22;
	let t23;
	bb0: {
		let filterElements;
		if (transactionTypeConfiguration?.transactionTypeConfigurationId) {
			const t24 = transactionTypeConfiguration?.transactionTypeConfigurationId;
			let t25;
			if ($[50] !== t24) {
				t25 = [{
					searchField: "TransactionTypeConfigurationId",
					searchOperator: "=",
					searchValue: t24,
					groupId: 1
				}];
				$[50] = t24;
				$[51] = t25;
			} else t25 = $[51];
			filterElements = t25;
			let t26;
			if ($[52] !== filterElements) {
				t26 = {
					requestUrl: `${ConfigService.productV1ApiUrl}/UdpTransactionTypeConfigurationTransactionAction/search`,
					customSearchObject: { filterElements }
				};
				$[52] = filterElements;
				$[53] = t26;
			} else t26 = $[53];
			t23 = t26;
			break bb0;
		}
		let t24;
		if ($[54] === Symbol.for("react.memo_cache_sentinel")) {
			t24 = {};
			$[54] = t24;
		} else t24 = $[54];
		t23 = t24;
	}
	const searchMethodConfig = t23;
	let t24;
	if ($[55] !== t) {
		t24 = t("Manage Linked Actions");
		$[55] = t;
		$[56] = t24;
	} else t24 = $[56];
	let t25;
	if ($[57] !== handleTransactionTypeConfigurationTransactionActionSidesheet) {
		t25 = () => handleTransactionTypeConfigurationTransactionActionSidesheet(false);
		$[57] = handleTransactionTypeConfigurationTransactionActionSidesheet;
		$[58] = t25;
	} else t25 = $[58];
	let t26;
	if ($[59] !== columnDefs || $[60] !== headerConfig || $[61] !== searchMethodConfig) {
		t26 = /* @__PURE__ */ React.createElement(SearchMethodUdpGrid, {
			searchMethodConfig,
			columnDefs,
			gridHeaderConfig: headerConfig,
			gridOptions,
			gridApiCallback: handleGridApiCallback,
			gridFunctions
		});
		$[59] = columnDefs;
		$[60] = headerConfig;
		$[61] = searchMethodConfig;
		$[62] = t26;
	} else t26 = $[62];
	let t27;
	if ($[63] !== handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet || $[64] !== handleCreateTransactionTypeConfigurationTransactionAction || $[65] !== handleUpdateTransactionTypeConfigurationTransactionAction || $[66] !== isCreateOrEditSidesheetOpen || $[67] !== transactionTypeConfigurationTransactionAction || $[68] !== ttctaList || $[69] !== tttactions) {
		t27 = /* @__PURE__ */ React.createElement(UdpTransactionTypeConfigurationTransactionActionCreateAndEditSidesheet, {
			initialTransactionTypeConfigurationTransactionAction: transactionTypeConfigurationTransactionAction,
			isSideSheetOpen: isCreateOrEditSidesheetOpen,
			handleCreateTransactionTypeConfigurationTransactionAction,
			handleUpdateTransactionTypeConfigurationTransactionAction,
			handleSideSheet: handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet,
			transactionTypeTransactionActions: tttactions,
			existingTtctaList: ttctaList
		});
		$[63] = handleCreateOrEditTransactionTypeConfigurationTransactionActionSidesheet;
		$[64] = handleCreateTransactionTypeConfigurationTransactionAction;
		$[65] = handleUpdateTransactionTypeConfigurationTransactionAction;
		$[66] = isCreateOrEditSidesheetOpen;
		$[67] = transactionTypeConfigurationTransactionAction;
		$[68] = ttctaList;
		$[69] = tttactions;
		$[70] = t27;
	} else t27 = $[70];
	let t28;
	if ($[71] !== isSideSheetOpen || $[72] !== t24 || $[73] !== t25 || $[74] !== t26 || $[75] !== t27) {
		t28 = /* @__PURE__ */ React.createElement(SideSheet, {
			open: isSideSheetOpen,
			width: 700,
			title: t24,
			onClose: t25
		}, t26, t27);
		$[71] = isSideSheetOpen;
		$[72] = t24;
		$[73] = t25;
		$[74] = t26;
		$[75] = t27;
		$[76] = t28;
	} else t28 = $[76];
	return t28;
};
var UdpTransactionTypeConfigurationTransactionActionSidesheet_default = forwardRef(UdpTransactionTypeConfigurationTransactionActionSidesheet);
function _temp(params_0) {
	return params_0.data;
}
//#endregion
export { UdpTransactionTypeConfigurationTransactionActionSidesheet_default as default };

//# sourceMappingURL=UdpTransactionTypeConfigurationTransactionActionSidesheet.mjs.map