var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var parse_region_data_to_geo_json_exports = {};
__export(parse_region_data_to_geo_json_exports, {
  parseRegionDataToGeoJSON: () => parseRegionDataToGeoJSON
});
module.exports = __toCommonJS(parse_region_data_to_geo_json_exports);
var import_charts = require("@dynatrace/strato-components-preview/charts");
var import_core = require("@dynatrace/strato-components-preview/core");
var import_calculate_hovered_color = require("../../../functions/calculate-hovered-color.js");
var import_define_color = require("../../../functions/define-color.js");
const parseRegionDataToGeoJSON = (mapSource, data, regionAccessor, color) => {
  const features = data.reduce((features2, item) => {
    let id = "";
    if (typeof regionAccessor === "function") {
      id = regionAccessor(item);
    } else {
      id = (0, import_core._accessValue)(item, regionAccessor);
    }
    const feature = mapSource.features.find((region) => region.id === id);
    if (feature !== void 0) {
      const regionColor = (0, import_define_color.defineColor)(color, item);
      const canvasColor = (0, import_charts._getCanvasColor)(regionColor);
      const hoveredColor = (0, import_calculate_hovered_color.calculateHoveredColor)(canvasColor);
      const { n: name } = feature.properties;
      const feat = {
        ...feature,
        properties: {
          name,
          data: item,
          ...item,
          __color: canvasColor,
          __hoveredColor: hoveredColor
        }
      };
      features2.push(feat);
    }
    return features2;
  }, []);
  return {
    type: "FeatureCollection",
    features
  };
};
