import { ConfigService } from "../../../../configService/index.mjs";
import { SideSheet } from "../../../../UI/surfaces/SideSheet.mjs";
import { SearchMethodUdpGrid } from "../../../../UI/templates/newGrid/SearchMethodUdpGrid.mjs";
import { TRANSACTION_TYPE_STATUS_COLORS } from "../../../utilities/transactionConstants.mjs";
import UdpTransactionTypeStatusCreateAndEditSidesheet from "./UdpTransactionTypeStatusCreateAndEditSidesheet.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/UdpTransactionTypeStatusSidesheet.jsx
const UdpTransactionTypeStatusSidesheet = (props, ref) => {
	const $ = c(97);
	const { transactionType, transactionTypeStatus, isSideSheetOpen, isTransactionTypeStatusCreateOrEditSidesheetOpen, handleTransactionTypeStatusSideSheet, handleCreateOrEditTransactionTypeStatusSideSheet, handleCreateTransactionTypeStatus, handleUpdateTransactionTypeStatus, handleDeleteTransactionTypeStatus } = props;
	const transactionTypeStatusGridApiRef = useRef(null);
	const { t } = useTranslation();
	let t0;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t0 = () => ({ refreshServerSide: () => {
			transactionTypeStatusGridApiRef?.current?.refreshServerSide();
		} });
		$[0] = t0;
	} else t0 = $[0];
	useImperativeHandle(ref, t0);
	const getStatusLabel = _temp;
	let t1;
	if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = {
			Default: "gray",
			Warning: "warning",
			Info: "info",
			Success: "success",
			Error: "error"
		};
		$[1] = t1;
	} else t1 = $[1];
	const getStatusColor = t1;
	let t2;
	if ($[2] !== t) {
		t2 = t("Name");
		$[2] = t;
		$[3] = t2;
	} else t2 = $[3];
	let t3;
	if ($[4] !== t2) {
		t3 = {
			headerName: t2,
			field: "name",
			resizable: true,
			sortable: false
		};
		$[4] = t2;
		$[5] = t3;
	} else t3 = $[5];
	let t4;
	if ($[6] !== t) {
		t4 = t("Code");
		$[6] = t;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== t4) {
		t5 = {
			headerName: t4,
			field: "code",
			resizable: true,
			sortable: false
		};
		$[8] = t4;
		$[9] = t5;
	} else t5 = $[9];
	let t6;
	if ($[10] !== t) {
		t6 = t("Color");
		$[10] = t;
		$[11] = t6;
	} else t6 = $[11];
	let t7;
	if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = {
			statusMappingConfig: getStatusColor,
			getStatusValue: getStatusLabel
		};
		$[12] = t7;
	} else t7 = $[12];
	let t8;
	if ($[13] !== t6) {
		t8 = {
			headerName: t6,
			field: "color",
			resizable: true,
			sortable: false,
			cellRenderer: "statusRenderer",
			cellRendererParams: t7
		};
		$[13] = t6;
		$[14] = t8;
	} else t8 = $[14];
	let t9;
	if ($[15] !== t) {
		t9 = t("Default");
		$[15] = t;
		$[16] = t9;
	} else t9 = $[16];
	let t10;
	if ($[17] !== t9) {
		t10 = {
			headerName: t9,
			field: "isDefault",
			resizable: true,
			sortable: false,
			cellDataType: "boolean"
		};
		$[17] = t9;
		$[18] = t10;
	} else t10 = $[18];
	let t11;
	if ($[19] !== t) {
		t11 = t("Closed Status");
		$[19] = t;
		$[20] = t11;
	} else t11 = $[20];
	let t12;
	if ($[21] !== t11) {
		t12 = {
			headerName: t11,
			field: "isClosedStatus",
			resizable: true,
			sortable: false,
			cellDataType: "boolean"
		};
		$[21] = t11;
		$[22] = t12;
	} else t12 = $[22];
	let t13;
	if ($[23] !== t) {
		t13 = t("Cancelled Status");
		$[23] = t;
		$[24] = t13;
	} else t13 = $[24];
	let t14;
	if ($[25] !== t13) {
		t14 = {
			headerName: t13,
			field: "isCancelledStatus",
			resizable: true,
			sortable: false,
			cellDataType: "boolean"
		};
		$[25] = t13;
		$[26] = t14;
	} else t14 = $[26];
	let t15;
	if ($[27] !== t) {
		t15 = t("Actions");
		$[27] = t;
		$[28] = t15;
	} else t15 = $[28];
	let t16;
	if ($[29] !== t) {
		t16 = t("Edit");
		$[29] = t;
		$[30] = t16;
	} else t16 = $[30];
	let t17;
	if ($[31] !== handleCreateOrEditTransactionTypeStatusSideSheet) {
		t17 = (e, transactionTypeStatus_0) => {
			handleCreateOrEditTransactionTypeStatusSideSheet(true, transactionTypeStatus_0?.data);
		};
		$[31] = handleCreateOrEditTransactionTypeStatusSideSheet;
		$[32] = t17;
	} else t17 = $[32];
	let t18;
	if ($[33] !== t16 || $[34] !== t17) {
		t18 = {
			id: 0,
			title: t16,
			iconName: "edit",
			handleOnClick: t17
		};
		$[33] = t16;
		$[34] = t17;
		$[35] = t18;
	} else t18 = $[35];
	let t19;
	if ($[36] !== t) {
		t19 = t("Delete");
		$[36] = t;
		$[37] = t19;
	} else t19 = $[37];
	let t20;
	if ($[38] !== handleDeleteTransactionTypeStatus) {
		t20 = (e_0, transactionTypeStatus_1) => {
			handleDeleteTransactionTypeStatus(transactionTypeStatus_1?.data);
		};
		$[38] = handleDeleteTransactionTypeStatus;
		$[39] = t20;
	} else t20 = $[39];
	let t21;
	if ($[40] !== t19 || $[41] !== t20) {
		t21 = {
			id: 1,
			title: t19,
			iconName: "trashCan",
			handleOnClick: t20
		};
		$[40] = t19;
		$[41] = t20;
		$[42] = t21;
	} else t21 = $[42];
	let t22;
	if ($[43] !== t18 || $[44] !== t21) {
		t22 = { actionList: [t18, t21] };
		$[43] = t18;
		$[44] = t21;
		$[45] = t22;
	} else t22 = $[45];
	let t23;
	if ($[46] !== t15 || $[47] !== t22) {
		t23 = {
			headerName: t15,
			field: "actions",
			cellRenderer: "actionsRenderer",
			cellRendererParams: t22,
			suppressMenu: true,
			sortable: false,
			filter: false,
			valueGetter: _temp2
		};
		$[46] = t15;
		$[47] = t22;
		$[48] = t23;
	} else t23 = $[48];
	let t24;
	if ($[49] !== t10 || $[50] !== t12 || $[51] !== t14 || $[52] !== t23 || $[53] !== t3 || $[54] !== t5 || $[55] !== t8) {
		t24 = [
			t3,
			t5,
			t8,
			t10,
			t12,
			t14,
			t23
		];
		$[49] = t10;
		$[50] = t12;
		$[51] = t14;
		$[52] = t23;
		$[53] = t3;
		$[54] = t5;
		$[55] = t8;
		$[56] = t24;
	} else t24 = $[56];
	const columnDefs = t24;
	let t25;
	if ($[57] !== t) {
		t25 = t("Statuses");
		$[57] = t;
		$[58] = t25;
	} else t25 = $[58];
	let t26;
	if ($[59] !== t) {
		t26 = t("Add");
		$[59] = t;
		$[60] = t26;
	} else t26 = $[60];
	let t27;
	if ($[61] !== handleCreateOrEditTransactionTypeStatusSideSheet) {
		t27 = () => handleCreateOrEditTransactionTypeStatusSideSheet(true);
		$[61] = handleCreateOrEditTransactionTypeStatusSideSheet;
		$[62] = t27;
	} else t27 = $[62];
	let t28;
	if ($[63] !== t26 || $[64] !== t27) {
		t28 = {
			label: t26,
			iconName: "add",
			onClick: t27
		};
		$[63] = t26;
		$[64] = t27;
		$[65] = t28;
	} else t28 = $[65];
	let t29;
	if ($[66] !== t25 || $[67] !== t28) {
		t29 = {
			title: t25,
			primaryActionButton: t28
		};
		$[66] = t25;
		$[67] = t28;
		$[68] = t29;
	} else t29 = $[68];
	const headerConfig = t29;
	let t30;
	if ($[69] === Symbol.for("react.memo_cache_sentinel")) {
		t30 = [
			{ name: "agGridExport" },
			{ name: "agGridSizeColumnsToFit" },
			{ name: "agGridAutoSizeColumns" },
			{ name: "agGridResetColumns" },
			{ name: "agGridHideShowColumns" }
		];
		$[69] = t30;
	} else t30 = $[69];
	const gridFunctions = t30;
	let t31;
	if ($[70] === Symbol.for("react.memo_cache_sentinel")) {
		t31 = { pagination: true };
		$[70] = t31;
	} else t31 = $[70];
	const gridOptions = t31;
	let t32;
	if ($[71] === Symbol.for("react.memo_cache_sentinel")) {
		t32 = (api) => {
			transactionTypeStatusGridApiRef.current = api;
		};
		$[71] = t32;
	} else t32 = $[71];
	const handleGridApiCallback = t32;
	let t33;
	bb0: {
		let filterElements;
		if (transactionType?.transactionTypeId) {
			const t34 = transactionType?.transactionTypeId;
			let t35;
			if ($[72] !== t34) {
				t35 = [{
					searchField: "TransactionTypeId",
					searchOperator: "=",
					searchValue: t34,
					groupId: 1
				}];
				$[72] = t34;
				$[73] = t35;
			} else t35 = $[73];
			filterElements = t35;
			let t36;
			if ($[74] !== filterElements) {
				t36 = {
					requestUrl: `${ConfigService.productV1ApiUrl}/UdpTransactionTypeStatus/search`,
					customSearchObject: { filterElements }
				};
				$[74] = filterElements;
				$[75] = t36;
			} else t36 = $[75];
			t33 = t36;
			break bb0;
		}
		let t34;
		if ($[76] === Symbol.for("react.memo_cache_sentinel")) {
			t34 = {};
			$[76] = t34;
		} else t34 = $[76];
		t33 = t34;
	}
	const searchMethodConfig = t33;
	let t34;
	if ($[77] !== t) {
		t34 = t("Manage Statuses");
		$[77] = t;
		$[78] = t34;
	} else t34 = $[78];
	let t35;
	if ($[79] !== handleTransactionTypeStatusSideSheet) {
		t35 = () => handleTransactionTypeStatusSideSheet(false);
		$[79] = handleTransactionTypeStatusSideSheet;
		$[80] = t35;
	} else t35 = $[80];
	let t36;
	if ($[81] !== columnDefs || $[82] !== headerConfig || $[83] !== searchMethodConfig) {
		t36 = /* @__PURE__ */ React.createElement(SearchMethodUdpGrid, {
			searchMethodConfig,
			columnDefs,
			gridHeaderConfig: headerConfig,
			gridOptions,
			gridApiCallback: handleGridApiCallback,
			gridFunctions
		});
		$[81] = columnDefs;
		$[82] = headerConfig;
		$[83] = searchMethodConfig;
		$[84] = t36;
	} else t36 = $[84];
	let t37;
	if ($[85] !== handleCreateOrEditTransactionTypeStatusSideSheet || $[86] !== handleCreateTransactionTypeStatus || $[87] !== handleUpdateTransactionTypeStatus || $[88] !== isTransactionTypeStatusCreateOrEditSidesheetOpen || $[89] !== transactionTypeStatus) {
		t37 = /* @__PURE__ */ React.createElement(UdpTransactionTypeStatusCreateAndEditSidesheet, {
			initialTransactionTypeStatus: transactionTypeStatus,
			isSideSheetOpen: isTransactionTypeStatusCreateOrEditSidesheetOpen,
			handleCreateTransactionTypeStatus,
			handleUpdateTransactionTypeStatus,
			handleSideSheet: handleCreateOrEditTransactionTypeStatusSideSheet
		});
		$[85] = handleCreateOrEditTransactionTypeStatusSideSheet;
		$[86] = handleCreateTransactionTypeStatus;
		$[87] = handleUpdateTransactionTypeStatus;
		$[88] = isTransactionTypeStatusCreateOrEditSidesheetOpen;
		$[89] = transactionTypeStatus;
		$[90] = t37;
	} else t37 = $[90];
	let t38;
	if ($[91] !== isSideSheetOpen || $[92] !== t34 || $[93] !== t35 || $[94] !== t36 || $[95] !== t37) {
		t38 = /* @__PURE__ */ React.createElement(SideSheet, {
			open: isSideSheetOpen,
			width: 900,
			title: t34,
			onClose: t35
		}, t36, t37);
		$[91] = isSideSheetOpen;
		$[92] = t34;
		$[93] = t35;
		$[94] = t36;
		$[95] = t37;
		$[96] = t38;
	} else t38 = $[96];
	return t38;
};
var UdpTransactionTypeStatusSidesheet_default = forwardRef(UdpTransactionTypeStatusSidesheet);
function _temp(node) {
	let label;
	label = TRANSACTION_TYPE_STATUS_COLORS.find((color) => color.value === node.data.color)?.name;
	return label || "";
}
function _temp2(params) {
	return params.data;
}
//#endregion
export { UdpTransactionTypeStatusSidesheet_default as default };

//# sourceMappingURL=UdpTransactionTypeStatusSidesheet.mjs.map