var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var extract_layers_data_exports = {};
__export(extract_layers_data_exports, {
  extractLayersData: () => extractLayersData
});
module.exports = __toCommonJS(extract_layers_data_exports);
var import_lodash_es = require("lodash");
var import_react = __toESM(require("react"));
var import_react_is = require("react-is");
var import_BubbleLayer = require("../components/BubbleLayer/BubbleLayer.js");
var import_ChoroplethLayer = require("../components/ChoroplethLayer/ChoroplethLayer.js");
var import_ConnectionLayer = require("../components/ConnectionLayer/ConnectionLayer.js");
var import_DotLayer = require("../components/DotLayer/DotLayer.js");
const extractLayersData = (children) => {
  let flattenData = [];
  import_react.default.Children.forEach(children, (child) => {
    if ((0, import_react_is.isElement)(child)) {
      const layerId = child.props.layerId;
      switch (child.type) {
        case import_BubbleLayer.BubbleLayer:
        case import_DotLayer.DotLayer: {
          const data = child.props.data;
          data.forEach((dataPoint) => {
            const extendedDataPoint = {
              ...dataPoint,
              "layer-name": layerId
            };
            flattenData = flattenData.concat(extendedDataPoint);
          });
          break;
        }
        case import_ConnectionLayer.ConnectionLayer: {
          const data = child.props.data;
          data.forEach((connection, connectionIndex) => {
            connection.path.forEach((path, pathIndex) => {
              const parsedPath = {
                ...path,
                "connection-name": `connection-${connectionIndex + 1}`,
                "connection-item-index": pathIndex,
                "layer-name": layerId
              };
              flattenData.push(parsedPath);
            });
          });
          break;
        }
        case import_ChoroplethLayer.ChoroplethLayer: {
          const { data, regionAccessor } = child.props;
          data.forEach((dataEntry) => {
            const region = (0, import_lodash_es.isString)(regionAccessor) ? dataEntry[regionAccessor] : regionAccessor(dataEntry);
            const choroplethLayerData = {
              ...dataEntry,
              region,
              "layer-name": layerId
            };
            flattenData.push(choroplethLayerData);
          });
          break;
        }
      }
    }
  });
  return flattenData;
};
