import { isEqualWith } from "lodash-es";
//#region src/UI/mapLayout/utilities/MapUtilities.js
const getChildrenObjectsWithNoChildren = (arr, valueKey) => {
	if (!!!arr) return [];
	return arr.reduce((result, obj) => {
		const children = obj?.options ?? [];
		const childrenWithNoChildren = getChildrenObjectsWithNoChildren(children, valueKey);
		if (childrenWithNoChildren.length > 0) result.push(...childrenWithNoChildren);
		else if (children.length === 0) result.push(obj[valueKey]);
		return result;
	}, []);
};
const getLayer = (layerKeys, layerKeySeparator, obj) => {
	let stringValue = "";
	layerKeys?.forEach((key, index) => {
		stringValue += obj[key] + (index !== layerKeys?.length - 1 ? layerKeySeparator : "");
	});
	return stringValue;
};
const generateGeoJsonList = (data, mappingConfig) => {
	if (data?.length > 0 && mappingConfig) return data?.map((item) => {
		return {
			type: "Feature",
			id: item[mappingConfig.featureId],
			geometry: {
				type: item[mappingConfig.geometryType],
				coordinates: item[mappingConfig.coordinates]
			},
			properties: mappingConfig.propertiesObj && !!item[mappingConfig.propertiesObj] ? {
				...item[mappingConfig.propertiesObj],
				id: item[mappingConfig.featureId]
			} : {
				...item,
				id: item[mappingConfig.featureId]
			}
		};
	});
	return [];
};
const isEqualIgnoreFunctions = (a, b) => isEqualWith(a, b, (val1, val2) => {
	if (typeof val1 === "function" && typeof val2 === "function") return true;
});
//#endregion
export { generateGeoJsonList, getChildrenObjectsWithNoChildren, getLayer, isEqualIgnoreFunctions };

//# sourceMappingURL=MapUtilities.mjs.map