import interpolateRgb from './rgb.mjs';
import { genericArray } from './array.mjs';
import date from './date.mjs';
import interpolateNumber from './number.mjs';
import object from './object.mjs';
import interpolateString from './string.mjs';
import constant from './constant.mjs';
import numberArray, { isNumberArray } from './numberArray.mjs';
import color from '../../../../d3-color@3.1.0/node_modules/d3-color/src/color.mjs';

function interpolate(a, b) {
  var t = typeof b, c;
  return b == null || t === "boolean" ? constant(b)
      : (t === "number" ? interpolateNumber
      : t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString)
      : b instanceof color ? interpolateRgb
      : b instanceof Date ? date
      : isNumberArray(b) ? numberArray
      : Array.isArray(b) ? genericArray
      : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? object
      : interpolateNumber)(a, b);
}

export { interpolate as default };
