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 BubbleLayer_exports = {};
__export(BubbleLayer_exports, {
  BubbleLayer: () => BubbleLayer
});
module.exports = __toCommonJS(BubbleLayer_exports);
var import_react = __toESM(require("react"));
var import_maplibre = require("react-map-gl/maplibre");
var import_BubbleCircleLayer = require("./BubbleCircleLayer.js");
var import_BubbleLayerTooltip = require("./BubbleLayerTooltip.js");
var import_BubbleOutlineLayer = require("./BubbleOutlineLayer.js");
var import_size_interpolation_context = require("./contexts/size-interpolation.context.js");
var import_build_radius_scale = require("./functions/build-radius-scale.js");
var import_parse_bubble_data_to_geo_json = require("./functions/parse-bubble-data-to-geo-json.js");
var import_constants = require("../../constants.js");
var import_tooltip_type_guards = require("../../functions/tooltip-type-guards.js");
var import_use_layer_coloring_strategy = require("../../hooks/use-layer-coloring-strategy.js");
var import_use_legend_interaction_highlighting = require("../../hooks/use-legend-interaction-highlighting.js");
var import_use_legend_interaction_visibility = require("../../hooks/use-legend-interaction-visibility.js");
var import_use_resolve_color = require("../../hooks/use-resolve-color.js");
var import_use_tooltip_template = require("../../hooks/use-tooltip-template.js");
var import_BubbleLayerTooltip2 = require("../../slots/BubbleLayerTooltip.js");
var import_bubble_layer = require("../../types/bubble-layer.js");
const BubbleLayer = (props) => {
  const {
    data,
    layerId,
    radius = import_constants.DEFAULT_RADIUS,
    children,
    sizeInterpolation = "fixed"
  } = props;
  const colorParser = (0, import_use_layer_coloring_strategy.useLayerColoringStrategy)();
  const bubbleColor = (0, import_use_resolve_color.useResolveColor)(import_constants.DEFAULT_BUBBLE_COLOR, props, colorParser);
  const sourceId = `source-${layerId}`;
  (0, import_use_legend_interaction_highlighting.useLegendInteractionHighlighting)(props, sourceId);
  (0, import_use_legend_interaction_visibility.useLegendInteractionVisibility)(props, layerId);
  let radiusScale = (value) => value;
  if ((0, import_bubble_layer.isScaleRadius)(props)) {
    const { radiusRange = [10, 100], radius: radius2, scale = "linear" } = props;
    radiusScale = (0, import_build_radius_scale.buildRadiusScale)(data, radius2, scale, radiusRange);
  }
  const dataGeoJson = (0, import_parse_bubble_data_to_geo_json.parseBubbleDataToGeoJSON)(
    data,
    bubbleColor,
    radius,
    radiusScale
  );
  const tooltipTemplate = (0, import_use_tooltip_template.useTooltipTemplate)(children, import_BubbleLayerTooltip2.BubbleLayerTooltip);
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_size_interpolation_context.SizeInterpolationContext.Provider, { value: sizeInterpolation }, /* @__PURE__ */ import_react.default.createElement(import_maplibre.Source, { id: sourceId, type: "geojson", data: dataGeoJson, generateId: true }, /* @__PURE__ */ import_react.default.createElement(import_BubbleCircleLayer.BubbleCircleLayer, { id: layerId, source: sourceId }), /* @__PURE__ */ import_react.default.createElement(import_BubbleOutlineLayer.BubbleOutlineLayer, { beforeId: layerId, source: sourceId }))), /* @__PURE__ */ import_react.default.createElement(
    import_BubbleLayerTooltip.BubbleLayerTooltip,
    {
      layerId,
      tooltipTemplate: (0, import_tooltip_type_guards.isBubbleTooltipTemplate)(tooltipTemplate) ? tooltipTemplate : void 0
    }
  ));
};
BubbleLayer["displayName"] = "BubbleLayer";
