import { ConfigService } from "../../../../configService/index.mjs";
import { SideSheet } from "../../../../UI/surfaces/SideSheet.mjs";
import { SearchMethodUdpGrid } from "../../../../UI/templates/newGrid/SearchMethodUdpGrid.mjs";
import UdpTransactionAttachmentTypeCreateAndEditSidesheet from "./UdpTransactionAttachmentTypeCreateAndEditSidesheet.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/UdpTransactionAttachmentTypeSidesheet.jsx
const UdpTransactionAttachmentTypeSidesheet = (props, ref) => {
	const $ = c(75);
	const { transactionType, transactionAttachmentType, isSideSheetOpen, isTransactionAttachmentTypeCreateOrEditSidesheetOpen, handleTransactionAttachmentTypeSidesheet, handleCreateOrEditTransactionAttachmentTypeSidesheet, handleCreateTransactionAttachmentType, handleUpdateTransactionAttachmentType, handleDeleteTransactionAttachmentType } = props;
	const transactionAttachmentTypeGridApiRef = useRef(null);
	const { t } = useTranslation();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = () => ({ refreshServerSide: () => {
			transactionAttachmentTypeGridApiRef?.current?.refreshServerSide();
		} });
		$[0] = t0;
	} else t0 = $[0];
	useImperativeHandle(ref, t0);
	let t1;
	if ($[1] !== t) {
		t1 = t("Attachment Type Id");
		$[1] = t;
		$[2] = t1;
	} else t1 = $[2];
	let t2;
	if ($[3] !== t1) {
		t2 = {
			headerName: t1,
			field: "transactionAttachmentTypeId",
			resizable: true,
			sortable: false,
			hide: true
		};
		$[3] = t1;
		$[4] = t2;
	} else t2 = $[4];
	let t3;
	if ($[5] !== t) {
		t3 = t("Name");
		$[5] = t;
		$[6] = t3;
	} else t3 = $[6];
	let t4;
	if ($[7] !== t3) {
		t4 = {
			headerName: t3,
			field: "name",
			resizable: true,
			sortable: false
		};
		$[7] = t3;
		$[8] = t4;
	} else t4 = $[8];
	let t5;
	if ($[9] !== t) {
		t5 = t("Actions");
		$[9] = t;
		$[10] = t5;
	} else t5 = $[10];
	let t6;
	if ($[11] !== t) {
		t6 = t("Edit");
		$[11] = t;
		$[12] = t6;
	} else t6 = $[12];
	let t7;
	if ($[13] !== handleCreateOrEditTransactionAttachmentTypeSidesheet) {
		t7 = (e, transactionAttachmentType_0) => {
			handleCreateOrEditTransactionAttachmentTypeSidesheet(true, transactionAttachmentType_0?.data);
		};
		$[13] = handleCreateOrEditTransactionAttachmentTypeSidesheet;
		$[14] = t7;
	} else t7 = $[14];
	let t8;
	if ($[15] !== t6 || $[16] !== t7) {
		t8 = {
			id: 0,
			title: t6,
			iconName: "edit",
			handleOnClick: t7
		};
		$[15] = t6;
		$[16] = t7;
		$[17] = t8;
	} else t8 = $[17];
	let t9;
	if ($[18] !== t) {
		t9 = t("Delete");
		$[18] = t;
		$[19] = t9;
	} else t9 = $[19];
	let t10;
	if ($[20] !== handleDeleteTransactionAttachmentType) {
		t10 = (e_0, transactionAttachmentType_1) => {
			handleDeleteTransactionAttachmentType(transactionAttachmentType_1?.data);
		};
		$[20] = handleDeleteTransactionAttachmentType;
		$[21] = t10;
	} else t10 = $[21];
	let t11;
	if ($[22] !== t10 || $[23] !== t9) {
		t11 = {
			id: 1,
			title: t9,
			iconName: "trashCan",
			handleOnClick: t10
		};
		$[22] = t10;
		$[23] = t9;
		$[24] = t11;
	} else t11 = $[24];
	let t12;
	if ($[25] !== t11 || $[26] !== t8) {
		t12 = { actionList: [t8, t11] };
		$[25] = t11;
		$[26] = t8;
		$[27] = t12;
	} else t12 = $[27];
	let t13;
	if ($[28] !== t12 || $[29] !== t5) {
		t13 = {
			headerName: t5,
			field: "actions",
			cellRenderer: "actionsRenderer",
			cellRendererParams: t12,
			suppressMenu: true,
			sortable: false,
			filter: false,
			valueGetter: _temp
		};
		$[28] = t12;
		$[29] = t5;
		$[30] = t13;
	} else t13 = $[30];
	let t14;
	if ($[31] !== t13 || $[32] !== t2 || $[33] !== t4) {
		t14 = [
			t2,
			t4,
			t13
		];
		$[31] = t13;
		$[32] = t2;
		$[33] = t4;
		$[34] = t14;
	} else t14 = $[34];
	const columnDefs = t14;
	let t15;
	if ($[35] !== t) {
		t15 = t("Attachment Types");
		$[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] !== handleCreateOrEditTransactionAttachmentTypeSidesheet) {
		t17 = () => handleCreateOrEditTransactionAttachmentTypeSidesheet(true);
		$[39] = handleCreateOrEditTransactionAttachmentTypeSidesheet;
		$[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: "agGridExport" },
			{ 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) => {
			transactionAttachmentTypeGridApiRef.current = api;
		};
		$[49] = t22;
	} else t22 = $[49];
	const handleGridApiCallback = t22;
	let t23;
	bb0: {
		let filterElements;
		if (transactionType?.transactionTypeId) {
			const t24 = transactionType?.transactionTypeId;
			let t25;
			if ($[50] !== t24) {
				t25 = [{
					searchField: "TransactionTypeId",
					searchOperator: "=",
					searchValue: t24,
					groupId: 1
				}];
				$[50] = t24;
				$[51] = t25;
			} else t25 = $[51];
			filterElements = t25;
			let t26;
			if ($[52] !== filterElements) {
				t26 = {
					requestUrl: `${ConfigService.productV1ApiUrl}/UdpTransactionAttachmentType/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 Attachment Types");
		$[55] = t;
		$[56] = t24;
	} else t24 = $[56];
	let t25;
	if ($[57] !== handleTransactionAttachmentTypeSidesheet) {
		t25 = () => handleTransactionAttachmentTypeSidesheet(false);
		$[57] = handleTransactionAttachmentTypeSidesheet;
		$[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] !== handleCreateOrEditTransactionAttachmentTypeSidesheet || $[64] !== handleCreateTransactionAttachmentType || $[65] !== handleUpdateTransactionAttachmentType || $[66] !== isTransactionAttachmentTypeCreateOrEditSidesheetOpen || $[67] !== transactionAttachmentType) {
		t27 = /* @__PURE__ */ React.createElement(UdpTransactionAttachmentTypeCreateAndEditSidesheet, {
			initialTransactionAttachmentType: transactionAttachmentType,
			isSideSheetOpen: isTransactionAttachmentTypeCreateOrEditSidesheetOpen,
			handleCreateTransactionAttachmentType,
			handleUpdateTransactionAttachmentType,
			handleSideSheet: handleCreateOrEditTransactionAttachmentTypeSidesheet
		});
		$[63] = handleCreateOrEditTransactionAttachmentTypeSidesheet;
		$[64] = handleCreateTransactionAttachmentType;
		$[65] = handleUpdateTransactionAttachmentType;
		$[66] = isTransactionAttachmentTypeCreateOrEditSidesheetOpen;
		$[67] = transactionAttachmentType;
		$[68] = t27;
	} else t27 = $[68];
	let t28;
	if ($[69] !== isSideSheetOpen || $[70] !== t24 || $[71] !== t25 || $[72] !== t26 || $[73] !== t27) {
		t28 = /* @__PURE__ */ React.createElement(SideSheet, {
			open: isSideSheetOpen,
			width: 800,
			title: t24,
			onClose: t25
		}, t26, t27);
		$[69] = isSideSheetOpen;
		$[70] = t24;
		$[71] = t25;
		$[72] = t26;
		$[73] = t27;
		$[74] = t28;
	} else t28 = $[74];
	return t28;
};
var UdpTransactionAttachmentTypeSidesheet_default = forwardRef(UdpTransactionAttachmentTypeSidesheet);
function _temp(params) {
	return params.data;
}
//#endregion
export { UdpTransactionAttachmentTypeSidesheet_default as default };

//# sourceMappingURL=UdpTransactionAttachmentTypeSidesheet.mjs.map