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 iterate_config_slots_exports = {};
__export(iterate_config_slots_exports, {
  iterateConfigSlots: () => iterateConfigSlots
});
module.exports = __toCommonJS(iterate_config_slots_exports);
var import_react = __toESM(require("react"));
var import_react_is = require("react-is");
var import_charts = require("@dynatrace/strato-components-preview/charts");
var import_constants = require("../constants.js");
var import_CategoricalLegend = require("../slots/CategoricalLegend.js");
var import_ChartInteractions = require("../slots/ChartInteractions.js");
var import_SequentialLegend = require("../slots/SequentialLegend.js");
var import_ThresholdLegend = require("../slots/ThresholdLegend.js");
const iterateConfigSlots = (children) => {
  let slots = {
    toolbar: void 0,
    interactions: void 0,
    legend: void 0
  };
  import_react.default.Children.forEach(children, (child) => {
    if ((0, import_react_is.isElement)(child)) {
      switch (child.type) {
        case import_ChartInteractions.ChartInteractions: {
          const { children: children2, ...previousInteractions } = child.props;
          const interactions = iterateChartInteractionsSlots(children2);
          slots = {
            ...slots,
            interactions: {
              ...previousInteractions,
              ...interactions
            }
          };
          break;
        }
        case import_charts.ChartToolbar: {
          const { children: children2, ...toolbar } = child.props;
          const childrenToolbar = iterateChartToolbarSlots(children2);
          slots = {
            ...slots,
            toolbar: {
              ...toolbar,
              ...childrenToolbar
            }
          };
          break;
        }
        case import_SequentialLegend.SequentialLegend: {
          const { children: children2, ...legend } = child.props;
          slots = {
            ...slots,
            legend: {
              type: "sequential",
              colorPalette: import_constants.DEFAULT_SEQUENTIAL_LEGEND_COLOR_PALETTE,
              position: import_constants.DEFAULT_MAP_POSITION,
              ratio: import_constants.DEFAULT_MAP_LEGEND_RATIO,
              ...legend
            }
          };
          break;
        }
        case import_CategoricalLegend.CategoricalLegend: {
          const { children: children2, ...legend } = child.props;
          slots = {
            ...slots,
            legend: {
              type: "categorical",
              position: import_constants.DEFAULT_MAP_POSITION,
              ...legend
            }
          };
          break;
        }
        case import_ThresholdLegend.ThresholdLegend: {
          const { children: children2, ...legend } = child.props;
          slots = {
            ...slots,
            legend: {
              type: "threshold",
              position: import_constants.DEFAULT_MAP_POSITION,
              ratio: import_constants.DEFAULT_MAP_LEGEND_RATIO,
              ...legend
            }
          };
          break;
        }
      }
    }
  });
  return slots;
};
const iterateChartInteractionsSlots = (children) => {
  let interactions = {};
  import_react.default.Children.forEach(children, (childInteractions) => {
    if ((0, import_react_is.isElement)(childInteractions)) {
      switch (childInteractions.type) {
        case import_ChartInteractions.ChartInteractions.Zoom:
          interactions = { ...interactions, zoom: { enabled: true } };
          break;
        case import_ChartInteractions.ChartInteractions.ZoomToFit:
          interactions = { ...interactions, zoomToFit: { enabled: true } };
          break;
      }
    }
  });
  return interactions;
};
const iterateChartToolbarSlots = (children) => {
  let toolbar = {};
  import_react.default.Children.forEach(children, (childToolbar) => {
    if ((0, import_react_is.isElement)(childToolbar) && childToolbar.type === import_charts.ChartToolbar.DownloadData) {
      toolbar = {
        ...toolbar,
        downloadData: { enabled: true }
      };
    }
  });
  return toolbar;
};
