import { ConfigService } from "../../../../configService/index.mjs";
import { apiMutate } from "../../../../utilities/useAxiosMutate.mjs";
import { useActions } from "../../../../hooks/useActions.mjs";
import { useAxiosGet } from "../../../../utilities/useAxiosGet.mjs";
import { GridGroupingSidebar } from "../../ui/GridGroupingSidebar.mjs";
import { AgTable, useAgGridApi } from "../../../../utilities/aggrid/AgTable.mjs";
import { GridActionBar } from "../../../utilityDisplay/deprecated/grid/GridActionBar.mjs";
import { GridPrimaryBar } from "../../../utilityDisplay/deprecated/grid/GridPrimaryBar.mjs";
import { onFirstDataRendered } from "../../../../utilities/aggrid/GridFunctions.mjs";
import { SaveViewFormDialog } from "../../../utilityDisplay/SaveViewFormDialog.mjs";
import { ChipSection } from "../../../utilityDisplay/ChipSection.mjs";
import { BulkActionsGridButton } from "../../../utilityDisplay/BulkActionsGridButton.mjs";
import { FilterOperators } from "../../../../models/SearchOperator.mjs";
import { c } from "react-compiler-runtime";
import React, { useEffect, useState } from "react";
import { Grow, LinearProgress, makeStyles } from "@material-ui/core";
import PropTypes from "prop-types";
import "../../../../style.css";
import { ServerSideRowModelModule } from "@ag-grid-enterprise/server-side-row-model";
import invariant from "invariant";
//#region src/UI/templates/deprecated/AmbientGridTemplate/AmbientGridTemplate.jsx
const useStyles = makeStyles((theme) => ({
	root: {},
	pab: {
		display: "flex",
		[theme.breakpoints.between("xs", "sm")]: {
			position: "fixed",
			bottom: theme.spacing(2),
			right: theme.spacing(2),
			zIndex: theme.zIndex.appBar
		}
	},
	groupSideBar: { width: 225 },
	gridApi: { display: "flex" }
}));
const AmbientGridTemplate = (props) => {
	const $ = c(297);
	let additionalFilters;
	let api;
	let apiMethod;
	let applicationName;
	let clearGridConfig;
	let columnApi;
	let columnDefs;
	let data;
	let defaultAutoSize;
	let deleteGridConfig;
	let disableDynamicSizing;
	let disablePagination;
	let disableRowSelection;
	let filters;
	let frameworkComponents;
	let gridId;
	let gridReady;
	let groupingData;
	let headerBackgroundColor;
	let height;
	let hiddenLabels;
	let hideColumnTab;
	let hideExpandGrid;
	let hideExportGrid;
	let hideFilterTab;
	let hideFitGrid;
	let hideGroupTab;
	let hideHeader;
	let hideRemoveFilters;
	let hideSearchBar;
	let insightsClick;
	let onPrimaryActionClick;
	let onRowSelected;
	let onSearch;
	let onSearchKeyDown;
	let otherGridProps;
	let primaryActionButton;
	let primaryActionDisabled;
	let primaryActionIcon;
	let primaryActionLabel;
	let saveGridConfig;
	let scrollToTopOnStateChange;
	let secondaryActionButtons;
	let t0;
	let t1;
	let t2;
	let t3;
	let t4;
	let t5;
	let t6;
	let tenantName;
	let title;
	let useNewHeader;
	let user;
	if ($[0] !== props) {
		const { additionalFilters: t7, api: t8, apiMethod: t9, applicationName: t10, bulkActionFunctions, clearGridConfig: t11, columnApi: t12, columnDefs: t13, data: t14, defaultAutoSize: t15, deleteGridConfig: t16, disablePagination: t17, disableDynamicSizing: t18, disableRowSelection: t19, entityName, filterChips: t20, filters: t21, frameworkComponents: t22, gridReady: t23, gridId: t24, groupingData: t25, height: t26, hideFitGrid: t27, hideExpandGrid: t28, hideExportGrid: t29, hideRemoveFilters: t30, hideFilterTab: t31, hideGroupTab: t32, hideColumnTab: t33, hideSearchBar: t34, hiddenLabels: t35, hiddenActionButtons: t36, kpiValues: t37, loading: t38, onRowSelected: t39, onSearch: t40, onPrimaryActionClick: t41, paginationPageSize: t42, primaryActionButton: t43, primaryActionDisabled: t44, primaryActionLabel: t45, primaryActionIcon: t46, rowModelType: t47, rowNodeIdName, saveGridConfig: t48, scrollToTopOnStateChange: t49, secondaryActionButtons: t50, title: t51, tenantName: t52, hideHeader: t53, useNewHeader: t54, insightsClick: t55, user: t56, id, udprecordid, additionalGridOptions: t57, headerBackgroundColor: t58, onSearchKeyDown: t59, ...t60 } = props;
		additionalFilters = t7;
		api = t8;
		apiMethod = t9;
		applicationName = t10;
		clearGridConfig = t11;
		columnApi = t12;
		columnDefs = t13;
		data = t14;
		defaultAutoSize = t15;
		deleteGridConfig = t16;
		disablePagination = t17;
		disableDynamicSizing = t18;
		disableRowSelection = t19;
		t0 = t20;
		filters = t21;
		frameworkComponents = t22;
		gridReady = t23;
		gridId = t24;
		groupingData = t25;
		height = t26;
		hideFitGrid = t27;
		hideExpandGrid = t28;
		hideExportGrid = t29;
		hideRemoveFilters = t30;
		hideFilterTab = t31;
		hideGroupTab = t32;
		hideColumnTab = t33;
		hideSearchBar = t34;
		hiddenLabels = t35;
		t1 = t36;
		t2 = t37;
		t3 = t38;
		onRowSelected = t39;
		onSearch = t40;
		onPrimaryActionClick = t41;
		t4 = t42;
		primaryActionButton = t43;
		primaryActionDisabled = t44;
		primaryActionLabel = t45;
		primaryActionIcon = t46;
		t5 = t47;
		saveGridConfig = t48;
		scrollToTopOnStateChange = t49;
		secondaryActionButtons = t50;
		title = t51;
		tenantName = t52;
		hideHeader = t53;
		useNewHeader = t54;
		insightsClick = t55;
		user = t56;
		t6 = t57;
		headerBackgroundColor = t58;
		onSearchKeyDown = t59;
		otherGridProps = t60;
		$[0] = props;
		$[1] = additionalFilters;
		$[2] = api;
		$[3] = apiMethod;
		$[4] = applicationName;
		$[5] = clearGridConfig;
		$[6] = columnApi;
		$[7] = columnDefs;
		$[8] = data;
		$[9] = defaultAutoSize;
		$[10] = deleteGridConfig;
		$[11] = disableDynamicSizing;
		$[12] = disablePagination;
		$[13] = disableRowSelection;
		$[14] = filters;
		$[15] = frameworkComponents;
		$[16] = gridId;
		$[17] = gridReady;
		$[18] = groupingData;
		$[19] = headerBackgroundColor;
		$[20] = height;
		$[21] = hiddenLabels;
		$[22] = hideColumnTab;
		$[23] = hideExpandGrid;
		$[24] = hideExportGrid;
		$[25] = hideFilterTab;
		$[26] = hideFitGrid;
		$[27] = hideGroupTab;
		$[28] = hideHeader;
		$[29] = hideRemoveFilters;
		$[30] = hideSearchBar;
		$[31] = insightsClick;
		$[32] = onPrimaryActionClick;
		$[33] = onRowSelected;
		$[34] = onSearch;
		$[35] = onSearchKeyDown;
		$[36] = otherGridProps;
		$[37] = primaryActionButton;
		$[38] = primaryActionDisabled;
		$[39] = primaryActionIcon;
		$[40] = primaryActionLabel;
		$[41] = saveGridConfig;
		$[42] = scrollToTopOnStateChange;
		$[43] = secondaryActionButtons;
		$[44] = t0;
		$[45] = t1;
		$[46] = t2;
		$[47] = t3;
		$[48] = t4;
		$[49] = t5;
		$[50] = t6;
		$[51] = tenantName;
		$[52] = title;
		$[53] = useNewHeader;
		$[54] = user;
	} else {
		additionalFilters = $[1];
		api = $[2];
		apiMethod = $[3];
		applicationName = $[4];
		clearGridConfig = $[5];
		columnApi = $[6];
		columnDefs = $[7];
		data = $[8];
		defaultAutoSize = $[9];
		deleteGridConfig = $[10];
		disableDynamicSizing = $[11];
		disablePagination = $[12];
		disableRowSelection = $[13];
		filters = $[14];
		frameworkComponents = $[15];
		gridId = $[16];
		gridReady = $[17];
		groupingData = $[18];
		headerBackgroundColor = $[19];
		height = $[20];
		hiddenLabels = $[21];
		hideColumnTab = $[22];
		hideExpandGrid = $[23];
		hideExportGrid = $[24];
		hideFilterTab = $[25];
		hideFitGrid = $[26];
		hideGroupTab = $[27];
		hideHeader = $[28];
		hideRemoveFilters = $[29];
		hideSearchBar = $[30];
		insightsClick = $[31];
		onPrimaryActionClick = $[32];
		onRowSelected = $[33];
		onSearch = $[34];
		onSearchKeyDown = $[35];
		otherGridProps = $[36];
		primaryActionButton = $[37];
		primaryActionDisabled = $[38];
		primaryActionIcon = $[39];
		primaryActionLabel = $[40];
		saveGridConfig = $[41];
		scrollToTopOnStateChange = $[42];
		secondaryActionButtons = $[43];
		t0 = $[44];
		t1 = $[45];
		t2 = $[46];
		t3 = $[47];
		t4 = $[48];
		t5 = $[49];
		t6 = $[50];
		tenantName = $[51];
		title = $[52];
		useNewHeader = $[53];
		user = $[54];
	}
	let t7;
	if ($[55] !== t0) {
		t7 = t0 === void 0 ? [] : t0;
		$[55] = t0;
		$[56] = t7;
	} else t7 = $[56];
	const filterChips = t7;
	let t8;
	if ($[57] !== t1) {
		t8 = t1 === void 0 ? [] : t1;
		$[57] = t1;
		$[58] = t8;
	} else t8 = $[58];
	const hiddenActionButtons = t8;
	let t9;
	if ($[59] !== t2) {
		t9 = t2 === void 0 ? [] : t2;
		$[59] = t2;
		$[60] = t9;
	} else t9 = $[60];
	const kpiValues = t9;
	const loading = t3 === void 0 ? false : t3;
	const paginationPageSize = t4 === void 0 ? 20 : t4;
	const rowModelType = t5 === void 0 ? "clientSide" : t5;
	let t10;
	if ($[61] !== t6) {
		t10 = t6 === void 0 ? {} : t6;
		$[61] = t6;
		$[62] = t10;
	} else t10 = $[62];
	const additionalGridOptions = t10;
	const classes = useStyles();
	const { gridApi, gridColumnApi, onGridReady } = useAgGridApi();
	const [isVisible, setIsVisible] = useState();
	const [sidebarIsVisible, setSidebarIsVisible] = useState(false);
	const [showGroupOptions, setShowGroupOptions] = useState(false);
	const [selectedRow, setSelectedRow] = useState(null);
	const [value, setValue] = useState(0);
	const [saveViewOpen, setSaveViewOpen] = useState(false);
	let t11;
	if ($[63] === Symbol.for("react.memo_cache_sentinel")) {
		t11 = [];
		$[63] = t11;
	} else t11 = $[63];
	const [, setDefaultViews] = useState(t11);
	const [, setViewsOpen] = useState(false);
	const t12 = !scrollToTopOnStateChange;
	let t13;
	if ($[64] !== additionalGridOptions || $[65] !== frameworkComponents || $[66] !== t12) {
		t13 = {
			frameworkComponents,
			suppressScrollOnNewData: t12,
			...additionalGridOptions
		};
		$[64] = additionalGridOptions;
		$[65] = frameworkComponents;
		$[66] = t12;
		$[67] = t13;
	} else t13 = $[67];
	const [agGridOptions] = useState(t13);
	const gApi = api || gridApi;
	const gcApi = columnApi || gridColumnApi;
	let t14;
	if ($[68] === Symbol.for("react.memo_cache_sentinel")) {
		t14 = [];
		$[68] = t14;
	} else t14 = $[68];
	const [viewChips, setViewChips] = useState(t14);
	const [additionalFilterChips, setAdditionalFilterChips] = useState(additionalFilters);
	const [columnDefsValues, setColumnDefsValues] = useState(null);
	const [selectedView, setSelectedView] = useState(null);
	const [viewsRowData, setViewsRowData] = useState(null);
	const [, setNonDefaultViewsRowData] = useState();
	const [numSelectedRows, setNumSelectedRows] = useState(0);
	const [domain, setDomain] = useState(null);
	const [apiCatalogId, setApiCatalogId] = useState(null);
	const { triggerAction } = useActions();
	let t15;
	let t16;
	if ($[69] !== apiMethod) {
		t15 = () => {
			if (apiMethod) {
				setDomain(apiMethod.entityName);
				setApiCatalogId(apiMethod.apiCatalogId);
			}
		};
		t16 = [
			apiMethod,
			setDomain,
			setApiCatalogId
		];
		$[69] = apiMethod;
		$[70] = t15;
		$[71] = t16;
	} else {
		t15 = $[70];
		t16 = $[71];
	}
	useEffect(t15, t16);
	let t17;
	if ($[72] !== rowModelType) {
		t17 = rowModelType === "serverSide" ? Object.keys(FilterOperators) : void 0;
		$[72] = rowModelType;
		$[73] = t17;
	} else t17 = $[73];
	let t18;
	if ($[74] !== t17) {
		t18 = {
			resizable: true,
			editable: false,
			sortable: true,
			filter: true,
			floatingFilter: false,
			enableRowGroup: true,
			filterParams: { filterOptions: t17 }
		};
		$[74] = t17;
		$[75] = t18;
	} else t18 = $[75];
	const defaultColActionsDef = t18;
	let emptyArr;
	let groupGridItems;
	let handleChange;
	let handleFilterChange;
	let handleRowSelected;
	let onColumnsClick;
	let onFilterClick;
	let restoreGridDefault;
	let setSideBarInvisible;
	let showGrouping;
	if ($[76] !== gApi || $[77] !== gcApi || $[78] !== onRowSelected || $[79] !== showGroupOptions || $[80] !== sidebarIsVisible) {
		handleChange = (event, newValue) => {
			event.preventDefault();
			setValue((preValue) => {
				if (newValue === preValue && newValue !== 1) gApi.setSideBarVisible(!gApi.isSideBarVisible());
				else if (newValue === 0) {
					gApi.setSideBarVisible(true);
					gApi.openToolPanel("filters");
					setShowGroupOptions(false);
				} else if (newValue === 1) {
					showGrouping();
					gApi.setSideBarVisible(false);
				} else {
					gApi.setSideBarVisible(true);
					gApi.openToolPanel("columns");
					setShowGroupOptions(false);
				}
				return newValue;
			});
		};
		let t19;
		if ($[91] !== gApi || $[92] !== sidebarIsVisible) {
			t19 = (event_0) => {
				event_0.preventDefault();
				gApi.setSideBarVisible(!gApi.isSideBarVisible());
				gApi.openToolPanel("filters");
				setShowGroupOptions(false);
				setValue(0);
				setSidebarIsVisible(!sidebarIsVisible);
			};
			$[91] = gApi;
			$[92] = sidebarIsVisible;
			$[93] = t19;
		} else t19 = $[93];
		onFilterClick = t19;
		let t20;
		if ($[94] !== gApi || $[95] !== sidebarIsVisible) {
			t20 = (event_2) => {
				event_2.preventDefault();
				gApi.setSideBarVisible(!gApi.isSideBarVisible());
				gApi.openToolPanel("columns");
				setShowGroupOptions(false);
				setValue(2);
				setSidebarIsVisible(!sidebarIsVisible);
			};
			$[94] = gApi;
			$[95] = sidebarIsVisible;
			$[96] = t20;
		} else t20 = $[96];
		onColumnsClick = t20;
		let t21;
		if ($[97] === Symbol.for("react.memo_cache_sentinel")) {
			t21 = [];
			$[97] = t21;
		} else t21 = $[97];
		emptyArr = t21;
		let t22;
		if ($[98] !== gApi || $[99] !== onRowSelected) {
			t22 = (event_3) => {
				if (!gApi) return;
				const selectedRows = gApi.getSelectedRows();
				setNumSelectedRows(selectedRows.length);
				const row = selectedRows.length && selectedRows[0];
				setSelectedRow(row);
				if (onRowSelected) onRowSelected(event_3, row);
			};
			$[98] = gApi;
			$[99] = onRowSelected;
			$[100] = t22;
		} else t22 = $[100];
		handleRowSelected = t22;
		let t23;
		if ($[101] !== gApi) {
			t23 = () => {
				if (gApi.isSideBarVisible()) {
					gApi.setSideBarVisible(false);
					setIsVisible(false);
				} else {
					gApi.setSideBarVisible(true);
					gApi.openToolPanel("filters");
					setShowGroupOptions(false);
					setIsVisible(true);
				}
			};
			$[101] = gApi;
			$[102] = t23;
		} else t23 = $[102];
		setSideBarInvisible = t23;
		let t24;
		if ($[103] !== gApi) {
			t24 = (event_4) => {
				gApi.setQuickFilter(event_4.target.value);
			};
			$[103] = gApi;
			$[104] = t24;
		} else t24 = $[104];
		handleFilterChange = t24;
		let t25;
		if ($[105] !== gApi || $[106] !== gcApi) {
			t25 = (groupItem) => {
				gcApi.setRowGroupColumns([groupItem]);
				gApi.expandAll();
			};
			$[105] = gApi;
			$[106] = gcApi;
			$[107] = t25;
		} else t25 = $[107];
		groupGridItems = t25;
		let t26;
		if ($[108] !== gApi || $[109] !== gcApi) {
			t26 = () => {
				gApi.setQuickFilter("");
				gcApi.setRowGroupColumns([]);
				gApi.setFilterModel(null);
				gApi.setQuickFilter("");
				gcApi.resetColumnState();
			};
			$[108] = gApi;
			$[109] = gcApi;
			$[110] = t26;
		} else t26 = $[110];
		restoreGridDefault = t26;
		showGrouping = () => {
			setShowGroupOptions(!showGroupOptions);
			gApi.setSideBarVisible(false);
		};
		$[76] = gApi;
		$[77] = gcApi;
		$[78] = onRowSelected;
		$[79] = showGroupOptions;
		$[80] = sidebarIsVisible;
		$[81] = emptyArr;
		$[82] = groupGridItems;
		$[83] = handleChange;
		$[84] = handleFilterChange;
		$[85] = handleRowSelected;
		$[86] = onColumnsClick;
		$[87] = onFilterClick;
		$[88] = restoreGridDefault;
		$[89] = setSideBarInvisible;
		$[90] = showGrouping;
	} else {
		emptyArr = $[81];
		groupGridItems = $[82];
		handleChange = $[83];
		handleFilterChange = $[84];
		handleRowSelected = $[85];
		onColumnsClick = $[86];
		onFilterClick = $[87];
		restoreGridDefault = $[88];
		setSideBarInvisible = $[89];
		showGrouping = $[90];
	}
	let t19;
	if ($[111] !== gApi) {
		t19 = () => {
			gApi.expandAll();
		};
		$[111] = gApi;
		$[112] = t19;
	} else t19 = $[112];
	const expandGroupedGrid = t19;
	let t20;
	if ($[113] !== gApi) {
		t20 = () => {
			gApi.collapseAll();
		};
		$[113] = gApi;
		$[114] = t20;
	} else t20 = $[114];
	const collapseGroupedGrid = t20;
	let t21;
	if ($[115] !== gApi) {
		t21 = () => {
			gApi.sizeColumnsToFit();
		};
		$[115] = gApi;
		$[116] = t21;
	} else t21 = $[116];
	const fitToSpace = t21;
	let t22;
	if ($[117] !== gApi) {
		t22 = () => {
			gApi.exportDataAsCsv({
				allColumns: true,
				fileName: "export"
			});
		};
		$[117] = gApi;
		$[118] = t22;
	} else t22 = $[118];
	const exportGrid = t22;
	let t23;
	if ($[119] !== gcApi) {
		t23 = () => {
			setColumnDefsValues(JSON.stringify(gcApi.getColumnState()));
			setSaveViewOpen(true);
		};
		$[119] = gcApi;
		$[120] = t23;
	} else t23 = $[120];
	const openSaveView = t23;
	let t24;
	if ($[121] === Symbol.for("react.memo_cache_sentinel")) {
		t24 = () => {
			setSaveViewOpen(false);
		};
		$[121] = t24;
	} else t24 = $[121];
	const closeSaveView = t24;
	let t25;
	if ($[122] === Symbol.for("react.memo_cache_sentinel")) {
		t25 = () => {
			setViewsOpen(true);
		};
		$[122] = t25;
	} else t25 = $[122];
	const openViews = t25;
	let t26;
	if ($[123] !== gApi || $[124] !== triggerAction) {
		t26 = (actionId) => {
			if (triggerAction && gApi) triggerAction(actionId, gApi.getSelectedRows());
		};
		$[123] = gApi;
		$[124] = triggerAction;
		$[125] = t26;
	} else t26 = $[125];
	const handleTriggerAction = t26;
	let t27;
	if ($[126] !== gcApi) {
		t27 = (skipHeader) => {
			invariant(gcApi, "gridColumnApi not ready");
			const allColumnIds = [];
			gcApi.getAllColumns().forEach((column) => {
				allColumnIds.push(column.getColId());
			});
			gcApi.autoSizeColumns(allColumnIds, skipHeader);
		};
		$[126] = gcApi;
		$[127] = t27;
	} else t27 = $[127];
	const autoSizeAll = t27;
	let t28;
	if ($[128] !== autoSizeAll) {
		t28 = () => autoSizeAll(false);
		$[128] = autoSizeAll;
		$[129] = t28;
	} else t28 = $[129];
	const autoSizeAllWithoutHeader = t28;
	let t29;
	if ($[130] !== autoSizeAllWithoutHeader || $[131] !== defaultAutoSize) {
		t29 = (params) => {
			!defaultAutoSize && params?.api.sizeColumnsToFit();
			defaultAutoSize && autoSizeAllWithoutHeader();
		};
		$[130] = autoSizeAllWithoutHeader;
		$[131] = defaultAutoSize;
		$[132] = t29;
	} else t29 = $[132];
	const firstDataRendered = t29;
	let t30;
	let t31;
	if ($[133] !== gApi || $[134] !== selectedRow) {
		t30 = () => {
			if (!gApi) return;
			setSelectedRow(gApi.getSelectedRows()?.length && gApi.getSelectedRows()[0]);
			selectedRow && gApi.ensureNodeVisible(selectedRow);
		};
		t31 = [gApi, selectedRow];
		$[133] = gApi;
		$[134] = selectedRow;
		$[135] = t30;
		$[136] = t31;
	} else {
		t30 = $[135];
		t31 = $[136];
	}
	useEffect(t30, t31);
	let t32;
	if ($[137] !== gApi || $[138] !== gcApi) {
		t32 = (chipType, chipIndex) => {
			bb136: switch (chipType) {
				case "view":
					setViewChips((prevChips_0) => prevChips_0.filter((__0, index_0) => index_0 !== chipIndex));
					setSelectedView(null);
					gcApi.resetColumnState();
					gApi.sizeColumnsToFit();
					break bb136;
				case "additionalFilter":
					setAdditionalFilterChips((prevChips) => {
						if (prevChips[chipIndex]?.onUntoggle) prevChips[chipIndex]?.onUntoggle();
						return prevChips.filter((_, index) => index !== chipIndex);
					});
					break bb136;
				default:
			}
		};
		$[137] = gApi;
		$[138] = gcApi;
		$[139] = t32;
	} else t32 = $[139];
	const handleChipDelete = t32;
	let t33;
	let t34;
	if ($[140] !== viewsRowData) {
		t33 = () => {
			if (viewsRowData?.length > 0) {
				const DefaultViews = viewsRowData.reduce(_temp, []);
				const nonDefaultViews = viewsRowData.reduce(_temp2, []);
				setDefaultViews(DefaultViews);
				setNonDefaultViewsRowData(nonDefaultViews);
			}
		};
		t34 = [viewsRowData];
		$[140] = viewsRowData;
		$[141] = t33;
		$[142] = t34;
	} else {
		t33 = $[141];
		t34 = $[142];
	}
	useEffect(t33, t34);
	let t35;
	if ($[143] !== gApi || $[144] !== gcApi) {
		t35 = (value_0) => {
			const columnState = value_0?.gridViewGridViewGridConfiguration.map(_temp3);
			setViewChips((prevChips_1) => [{ label: value_0?.name }]);
			onFirstDataRendered(gApi, gcApi, columnState);
		};
		$[143] = gApi;
		$[144] = gcApi;
		$[145] = t35;
	} else t35 = $[145];
	const setView = t35;
	const setFilter = _temp4;
	let t36;
	if ($[146] !== apiCatalogId || $[147] !== domain) {
		t36 = { params: {
			domainName: domain,
			apiCatalogId
		} };
		$[146] = apiCatalogId;
		$[147] = domain;
		$[148] = t36;
	} else t36 = $[148];
	const [t37, refetch] = useAxiosGet(ConfigService.tenantV2ApiUrl, `GridView/getFromUser/${user?.id}/${gridId}`, t36, !!!ConfigService.tenantV2ApiUrl || !!!gridId || !!!user);
	const { data: views } = t37;
	let t38;
	if ($[149] === Symbol.for("react.memo_cache_sentinel")) {
		t38 = {};
		$[149] = t38;
	} else t38 = $[149];
	const [t39] = useAxiosGet(ConfigService.integrationV2ApiUrl, `action/grid/${gridId}`, t38, !!!ConfigService.integrationV2ApiUrl || !!!gridId);
	const { data: bulkActions } = t39;
	let t40;
	let t41;
	if ($[150] !== views) {
		t40 = () => {
			setViewsRowData(views);
		};
		t41 = [openViews, views];
		$[150] = views;
		$[151] = t40;
		$[152] = t41;
	} else {
		t40 = $[151];
		t41 = $[152];
	}
	useEffect(t40, t41);
	let t42;
	if ($[153] !== selectedView?.gridViewId || $[154] !== setView) {
		t42 = async () => {
			await apiMutate(ConfigService.tenantV2ApiUrl, `GridView/${selectedView?.gridViewId}/PartiallyFull`, { method: "get" }).then((response) => {
				setView(response.data);
			}).catch(_temp5);
		};
		$[153] = selectedView?.gridViewId;
		$[154] = setView;
		$[155] = t42;
	} else t42 = $[155];
	const getView = t42;
	let t43;
	if ($[156] !== gApi || $[157] !== gcApi || $[158] !== getView || $[159] !== selectedView?.gridViewId) {
		t43 = () => {
			if (!selectedView?.gridViewId) {
				gcApi?.resetColumnState();
				gApi?.sizeColumnsToFit();
				return;
			}
			getView();
		};
		$[156] = gApi;
		$[157] = gcApi;
		$[158] = getView;
		$[159] = selectedView?.gridViewId;
		$[160] = t43;
	} else t43 = $[160];
	let t44;
	if ($[161] !== gApi || $[162] !== gcApi || $[163] !== getView || $[164] !== selectedView) {
		t44 = [
			setSelectedView,
			selectedView,
			gcApi,
			gApi,
			getView
		];
		$[161] = gApi;
		$[162] = gcApi;
		$[163] = getView;
		$[164] = selectedView;
		$[165] = t44;
	} else t44 = $[165];
	useEffect(t43, t44);
	let t45;
	let t46;
	if ($[166] !== additionalFilters) {
		t45 = () => {
			if (additionalFilters) setAdditionalFilterChips(additionalFilters);
		};
		t46 = [additionalFilters];
		$[166] = additionalFilters;
		$[167] = t45;
		$[168] = t46;
	} else {
		t45 = $[167];
		t46 = $[168];
	}
	useEffect(t45, t46);
	let t47;
	if ($[169] !== autoSizeAllWithoutHeader || $[170] !== exportGrid || $[171] !== fitToSpace || $[172] !== gApi || $[173] !== handleChange || $[174] !== handleFilterChange || $[175] !== headerBackgroundColor || $[176] !== hiddenActionButtons || $[177] !== hiddenLabels || $[178] !== hideHeader || $[179] !== hideSearchBar || $[180] !== insightsClick || $[181] !== isVisible || $[182] !== onColumnsClick || $[183] !== onFilterClick || $[184] !== onPrimaryActionClick || $[185] !== onSearch || $[186] !== onSearchKeyDown || $[187] !== openSaveView || $[188] !== primaryActionDisabled || $[189] !== primaryActionIcon || $[190] !== primaryActionLabel || $[191] !== restoreGridDefault || $[192] !== secondaryActionButtons || $[193] !== setSideBarInvisible || $[194] !== showGrouping || $[195] !== title || $[196] !== useNewHeader || $[197] !== value) {
		t47 = !hideHeader && useNewHeader && gApi && /* @__PURE__ */ React.createElement(GridPrimaryBar, {
			title,
			showFilter: setSideBarInvisible,
			selected: isVisible,
			onChange: onSearch || handleFilterChange,
			showGroup: showGrouping,
			value,
			saveViewClick: openSaveView,
			viewsClick: openViews,
			handleChange,
			fitClick: fitToSpace,
			expandClick: autoSizeAllWithoutHeader,
			exportClick: exportGrid,
			insightsClick,
			clearClick: restoreGridDefault,
			filterClick: onFilterClick,
			columnsClick: onColumnsClick,
			hideSearchBar,
			secondaryActionButtons: secondaryActionButtons || [],
			onPrimaryActionClick,
			primaryActionDisabled,
			primaryActionLabel,
			primaryActionIcon,
			hiddenActionButtons: hiddenActionButtons || [],
			hiddenLabels: hiddenLabels || [],
			background: headerBackgroundColor,
			onSearchKeyDown
		});
		$[169] = autoSizeAllWithoutHeader;
		$[170] = exportGrid;
		$[171] = fitToSpace;
		$[172] = gApi;
		$[173] = handleChange;
		$[174] = handleFilterChange;
		$[175] = headerBackgroundColor;
		$[176] = hiddenActionButtons;
		$[177] = hiddenLabels;
		$[178] = hideHeader;
		$[179] = hideSearchBar;
		$[180] = insightsClick;
		$[181] = isVisible;
		$[182] = onColumnsClick;
		$[183] = onFilterClick;
		$[184] = onPrimaryActionClick;
		$[185] = onSearch;
		$[186] = onSearchKeyDown;
		$[187] = openSaveView;
		$[188] = primaryActionDisabled;
		$[189] = primaryActionIcon;
		$[190] = primaryActionLabel;
		$[191] = restoreGridDefault;
		$[192] = secondaryActionButtons;
		$[193] = setSideBarInvisible;
		$[194] = showGrouping;
		$[195] = title;
		$[196] = useNewHeader;
		$[197] = value;
		$[198] = t47;
	} else t47 = $[198];
	let t48;
	if ($[199] !== additionalFilterChips || $[200] !== bulkActions || $[201] !== domain || $[202] !== filterChips || $[203] !== filters?.length || $[204] !== handleChipDelete || $[205] !== handleTriggerAction || $[206] !== kpiValues || $[207] !== numSelectedRows || $[208] !== useNewHeader || $[209] !== viewChips) {
		t48 = useNewHeader && (kpiValues?.length > 0 || filterChips?.length > 0 || filters?.length > 0 || viewChips?.length > 0 || additionalFilterChips?.length > 0) && /* @__PURE__ */ React.createElement("div", { style: {
			display: "flex",
			flexDirection: "row",
			height: 40
		} }, /* @__PURE__ */ React.createElement(Grow, {
			in: bulkActions && numSelectedRows > 0,
			unmountOnExit: true
		}, /* @__PURE__ */ React.createElement(BulkActionsGridButton, {
			bulkActions,
			numSelectedRows,
			triggerAction: handleTriggerAction,
			domain
		})), /* @__PURE__ */ React.createElement(ChipSection, {
			filterChips,
			viewChips,
			additionalFilterChips,
			kpiValues,
			handleDelete: handleChipDelete,
			setAdditionalFilterChips,
			setViewChips,
			setFilter
		}));
		$[199] = additionalFilterChips;
		$[200] = bulkActions;
		$[201] = domain;
		$[202] = filterChips;
		$[203] = filters?.length;
		$[204] = handleChipDelete;
		$[205] = handleTriggerAction;
		$[206] = kpiValues;
		$[207] = numSelectedRows;
		$[208] = useNewHeader;
		$[209] = viewChips;
		$[210] = t48;
	} else t48 = $[210];
	let t49;
	if ($[211] !== autoSizeAllWithoutHeader || $[212] !== classes || $[213] !== clearGridConfig || $[214] !== deleteGridConfig || $[215] !== exportGrid || $[216] !== fitToSpace || $[217] !== handleChange || $[218] !== handleFilterChange || $[219] !== hideColumnTab || $[220] !== hideExpandGrid || $[221] !== hideExportGrid || $[222] !== hideFilterTab || $[223] !== hideFitGrid || $[224] !== hideGroupTab || $[225] !== hideHeader || $[226] !== hideRemoveFilters || $[227] !== hideSearchBar || $[228] !== isVisible || $[229] !== onSearch || $[230] !== primaryActionButton || $[231] !== restoreGridDefault || $[232] !== saveGridConfig || $[233] !== setSideBarInvisible || $[234] !== showGrouping || $[235] !== title || $[236] !== useNewHeader || $[237] !== value) {
		t49 = !hideHeader && !useNewHeader && /* @__PURE__ */ React.createElement(GridActionBar, {
			title,
			showFilter: setSideBarInvisible,
			selected: isVisible,
			onChange: onSearch || handleFilterChange,
			showGroup: showGrouping,
			value,
			handleChange,
			fitClick: fitToSpace,
			expandClick: autoSizeAllWithoutHeader,
			exportClick: exportGrid,
			clearClick: restoreGridDefault,
			saveGridConfig,
			deleteGridConfig,
			clearGridConfig,
			hideFitGrid,
			hideExpandGrid,
			hideExportGrid,
			hideRemoveFilters,
			hideFilterTab,
			hideGroupTab,
			hideColumnTab,
			hideSearchBar
		}, primaryActionButton && /* @__PURE__ */ React.createElement("div", { className: classes.pab }, primaryActionButton));
		$[211] = autoSizeAllWithoutHeader;
		$[212] = classes;
		$[213] = clearGridConfig;
		$[214] = deleteGridConfig;
		$[215] = exportGrid;
		$[216] = fitToSpace;
		$[217] = handleChange;
		$[218] = handleFilterChange;
		$[219] = hideColumnTab;
		$[220] = hideExpandGrid;
		$[221] = hideExportGrid;
		$[222] = hideFilterTab;
		$[223] = hideFitGrid;
		$[224] = hideGroupTab;
		$[225] = hideHeader;
		$[226] = hideRemoveFilters;
		$[227] = hideSearchBar;
		$[228] = isVisible;
		$[229] = onSearch;
		$[230] = primaryActionButton;
		$[231] = restoreGridDefault;
		$[232] = saveGridConfig;
		$[233] = setSideBarInvisible;
		$[234] = showGrouping;
		$[235] = title;
		$[236] = useNewHeader;
		$[237] = value;
		$[238] = t49;
	} else t49 = $[238];
	let t50;
	if ($[239] !== loading) {
		t50 = loading && /* @__PURE__ */ React.createElement(LinearProgress, null);
		$[239] = loading;
		$[240] = t50;
	} else t50 = $[240];
	let t51;
	let t52;
	if ($[241] === Symbol.for("react.memo_cache_sentinel")) {
		t51 = { display: "flex" };
		t52 = { width: "100%" };
		$[241] = t51;
		$[242] = t52;
	} else {
		t51 = $[241];
		t52 = $[242];
	}
	const t53 = !disableDynamicSizing;
	const t54 = data || emptyArr;
	const t55 = gridReady || onGridReady;
	const t56 = !disablePagination;
	let t57;
	if ($[243] !== rowModelType) {
		t57 = rowModelType === "serverSide" ? [ServerSideRowModelModule] : [];
		$[243] = rowModelType;
		$[244] = t57;
	} else t57 = $[244];
	let t58;
	if ($[245] === Symbol.for("react.memo_cache_sentinel")) {
		t58 = { "first-row-in-group": _temp6 };
		$[245] = t58;
	} else t58 = $[245];
	const t59 = !disableRowSelection && (bulkActions ? "multiple" : "single");
	let t60;
	if ($[246] !== agGridOptions || $[247] !== columnDefs || $[248] !== defaultColActionsDef || $[249] !== firstDataRendered || $[250] !== gApi || $[251] !== handleRowSelected || $[252] !== height || $[253] !== hideHeader || $[254] !== otherGridProps || $[255] !== paginationPageSize || $[256] !== rowModelType || $[257] !== sidebarIsVisible || $[258] !== t53 || $[259] !== t54 || $[260] !== t55 || $[261] !== t56 || $[262] !== t57 || $[263] !== t59) {
		t60 = /* @__PURE__ */ React.createElement("div", { style: t52 }, /* @__PURE__ */ React.createElement(AgTable, {
			...agGridOptions,
			columnDefs,
			dynamicSizing: t53,
			rowData: t54,
			onGridReady: t55,
			onRowSelected: handleRowSelected,
			suppressCellSelection: true,
			suppressRowClickSelection: false,
			defaultColDef: defaultColActionsDef,
			enableRangeSelection: true,
			enableColResize: true,
			sideBar: sidebarIsVisible,
			pivotMode: false,
			pivotPanelShow: "never",
			groupSelectsChildren: true,
			animateRows: false,
			pagination: t56,
			showOpenedGroup: true,
			paginateChildRows: true,
			paginationPageSize,
			modules: t57,
			onFirstDataRendered: firstDataRendered,
			rowModelType,
			rowClassRules: t58,
			height,
			api: gApi,
			rowSelection: t59,
			hideHeader,
			...otherGridProps
		}));
		$[246] = agGridOptions;
		$[247] = columnDefs;
		$[248] = defaultColActionsDef;
		$[249] = firstDataRendered;
		$[250] = gApi;
		$[251] = handleRowSelected;
		$[252] = height;
		$[253] = hideHeader;
		$[254] = otherGridProps;
		$[255] = paginationPageSize;
		$[256] = rowModelType;
		$[257] = sidebarIsVisible;
		$[258] = t53;
		$[259] = t54;
		$[260] = t55;
		$[261] = t56;
		$[262] = t57;
		$[263] = t59;
		$[264] = t60;
	} else t60 = $[264];
	let t61;
	if ($[265] !== classes || $[266] !== collapseGroupedGrid || $[267] !== expandGroupedGrid || $[268] !== groupGridItems || $[269] !== groupingData || $[270] !== height || $[271] !== showGroupOptions) {
		t61 = showGroupOptions && /* @__PURE__ */ React.createElement("div", { className: classes.groupSideBar }, /* @__PURE__ */ React.createElement(GridGroupingSidebar, {
			groupItem: (item) => groupGridItems(item),
			closeClick: () => groupGridItems(""),
			expandClick: expandGroupedGrid,
			collapseClick: collapseGroupedGrid,
			groupingData,
			height
		}));
		$[265] = classes;
		$[266] = collapseGroupedGrid;
		$[267] = expandGroupedGrid;
		$[268] = groupGridItems;
		$[269] = groupingData;
		$[270] = height;
		$[271] = showGroupOptions;
		$[272] = t61;
	} else t61 = $[272];
	let t62;
	if ($[273] !== apiCatalogId || $[274] !== applicationName || $[275] !== columnDefsValues || $[276] !== domain || $[277] !== gApi || $[278] !== gcApi || $[279] !== gridId || $[280] !== hiddenActionButtons || $[281] !== refetch || $[282] !== saveViewOpen || $[283] !== setView || $[284] !== tenantName || $[285] !== user) {
		t62 = !hiddenActionButtons?.includes("saveView") && /* @__PURE__ */ React.createElement(SaveViewFormDialog, {
			open: saveViewOpen,
			handleClose: closeSaveView,
			application: applicationName,
			tenant: tenantName,
			user,
			columnDefsValues,
			refetchViews: refetch,
			gApi,
			gcApi,
			setSelectedView: setView,
			gridId,
			domain,
			apiCatalogId
		});
		$[273] = apiCatalogId;
		$[274] = applicationName;
		$[275] = columnDefsValues;
		$[276] = domain;
		$[277] = gApi;
		$[278] = gcApi;
		$[279] = gridId;
		$[280] = hiddenActionButtons;
		$[281] = refetch;
		$[282] = saveViewOpen;
		$[283] = setView;
		$[284] = tenantName;
		$[285] = user;
		$[286] = t62;
	} else t62 = $[286];
	let t63;
	if ($[287] !== t60 || $[288] !== t61 || $[289] !== t62) {
		t63 = /* @__PURE__ */ React.createElement("div", { style: t51 }, t60, t61, t62);
		$[287] = t60;
		$[288] = t61;
		$[289] = t62;
		$[290] = t63;
	} else t63 = $[290];
	let t64;
	if ($[291] !== t47 || $[292] !== t48 || $[293] !== t49 || $[294] !== t50 || $[295] !== t63) {
		t64 = /* @__PURE__ */ React.createElement(React.Fragment, null, t47, t48, t49, t50, t63);
		$[291] = t47;
		$[292] = t48;
		$[293] = t49;
		$[294] = t50;
		$[295] = t63;
		$[296] = t64;
	} else t64 = $[296];
	return t64;
};
AmbientGridTemplate.propTypes = {
	columnDefs: PropTypes.array,
	handleRowSelected: PropTypes.func,
	data: PropTypes.array,
	title: PropTypes.string,
	groupingData: PropTypes.array,
	frameworkComponents: PropTypes.object,
	loading: PropTypes.bool,
	primaryActionButton: PropTypes.object,
	rowNodeIdName: PropTypes.string,
	defaultAutoSize: PropTypes.bool,
	scrollToTopOnStateChange: PropTypes.bool,
	disableDynamicSizing: PropTypes.bool,
	filters: PropTypes.arrayOf(PropTypes.shape({
		label: PropTypes.string.isRequired,
		value: PropTypes.string.isRequired
	})),
	views: PropTypes.arrayOf(PropTypes.shape({ label: PropTypes.string.isRequired })),
	additionalFilters: PropTypes.arrayOf(PropTypes.shape({ label: PropTypes.string.isRequired })),
	kpis: PropTypes.arrayOf(PropTypes.shape({
		label: PropTypes.string.isRequired,
		value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired
	})),
	useNewHeader: PropTypes.bool,
	insightsClick: PropTypes.func,
	hiddenActionButtons: PropTypes.arrayOf(PropTypes.oneOf([
		"saveView",
		"views",
		"insights",
		"importExport",
		"group",
		"filter",
		"columns",
		"fitGrid",
		"expandGrid",
		"clearFilters"
	])),
	hiddenLabels: PropTypes.arrayOf(PropTypes.oneOf([
		"saveView",
		"views",
		"insights",
		"importExport",
		"group",
		"filter",
		"columns",
		"fitGrid",
		"expandGrid",
		"clearFilters"
	])),
	onPrimaryActionClick: PropTypes.func,
	primaryActionLabel: PropTypes.string,
	primaryActionIcon: PropTypes.elementType,
	secondaryActionButtons: PropTypes.array,
	applicationName: PropTypes.string,
	entityName: PropTypes.string,
	tenantName: PropTypes.string,
	user: PropTypes.object,
	kpiValues: PropTypes.array
};
function _temp(acc, row_0) {
	if (row_0.isDefault) return [...acc, row_0];
	return acc;
}
function _temp2(acc_0, row_1) {
	if (!row_1.isDefault) return [...acc_0, row_1];
	return acc_0;
}
function _temp3(ele) {
	return ele.gridViewGridConfigurationGridConfiguration;
}
function _temp4(value_1) {}
function _temp5(error) {
	console.log(error);
}
function _temp6(params_0) {
	return params_0.node.rowIndex !== 0 && params_0.node.firstChild;
}
//#endregion
export { AmbientGridTemplate };

//# sourceMappingURL=AmbientGridTemplate.mjs.map