import { toTitleCase } from "../../utilities/input/StringUtilities.mjs";
import { mapDotNetTypeToAgGridType } from "./crudHelper.mjs";
//#region src/maintenanceEngine/crudBrowser/CrudTableColumnDefs.js
const CrudTableColumnDefs = (entityAttributes, actionList) => {
	let columnDefs = entityAttributes?.reduce((defs, element) => {
		if (element?.extendedProperties?.udpFieldProperties?.maintenanceConfig?.hidden === true) return defs;
		if (element?.name === "businessObjectKey" || element?.name === "ignoreLoggingTransactions") return defs;
		if (!element?.extendedProperties?.childEntity) {
			const columnHeaderName = toTitleCase(element?.extendedProperties?.udpFieldProperties?.displayName || element?.name);
			const lookupId = element?.extendedProperties?.lookup || element?.extendedProperties?.udpFieldProperties?.maintainenceConfig?.lookup;
			let def = {
				headerName: columnHeaderName,
				field: element?.name.charAt(0).toLowerCase() + element?.name.slice(1),
				cellDataType: lookupId ? "text" : mapDotNetTypeToAgGridType(element?.type),
				filter: element?.extendedProperties?.searchable,
				sortable: element?.extendedProperties?.orderable,
				hide: element?.extendedProperties?.udpFieldProperties?.maintainenceConfig?.hidden,
				tooltipField: element?.name.charAt(0).toLowerCase() + element?.name.slice(1),
				context: {
					lookupId,
					...element
				}
			};
			defs.push(def);
		}
		return defs;
	}, []) || [];
	columnDefs.push({
		headerName: "Actions",
		field: "actions",
		cellRenderer: "actionsRenderer",
		cellRendererParams: { actionList }
	});
	return columnDefs;
};
//#endregion
export { CrudTableColumnDefs };

//# sourceMappingURL=CrudTableColumnDefs.mjs.map