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 build_radius_scale_exports = {};
__export(build_radius_scale_exports, {
  buildRadiusScale: () => buildRadiusScale
});
module.exports = __toCommonJS(build_radius_scale_exports);
var import_d3_scale = require("d3-scale");
const calculateDomain = (data, radius) => {
  let domain = [Infinity, -Infinity];
  for (let i = 0; i < data.length; i++) {
    const radiusValue = radius(data[i]);
    const [currentMin, currentMax] = domain;
    domain = [
      Math.min(currentMin, radiusValue),
      Math.max(currentMax, radiusValue)
    ];
  }
  return domain;
};
const buildRadiusScale = (data, radius, scale, range) => {
  const [minRadius, maxRadius] = range;
  const domain = calculateDomain(data, radius);
  if (scale === "linear") {
    return (0, import_d3_scale.scaleLinear)(domain, [minRadius, maxRadius]);
  }
  return (0, import_d3_scale.scaleLog)(domain, [minRadius, maxRadius]);
};
