import _extends from "@babel/runtime/helpers/esm/extends";
import { generate } from '@ant-design/colors';
import genColorMapToken from './genColorMapToken';
import defaultAlgorithm from '../default';
import { getAlphaColor, getSolidColor } from '../default/colorAlgorithm';
export var generateColorPalettes = function generateColorPalettes(baseColor) {
  var colors = generate(baseColor);
  return {
    1: colors[0],
    2: colors[1],
    3: colors[2],
    4: colors[3],
    5: colors[4],
    6: colors[5],
    7: colors[6],
    8: colors[4],
    9: colors[5],
    10: colors[6]
  };
};

var generateNeutralColorPalettes = function generateNeutralColorPalettes(bgBaseColor, textBaseColor) {
  var colorBgBase = bgBaseColor || '#fff';
  var colorTextBase = textBaseColor || '#000';
  return {
    colorBgBase: colorBgBase,
    colorTextBase: colorTextBase,
    colorText: getAlphaColor(colorTextBase, 0.85),
    colorTextSecondary: getAlphaColor(colorTextBase, 0.45),
    colorTextTertiary: getAlphaColor(colorTextBase, 0.45),
    colorTextQuaternary: getAlphaColor(colorTextBase, 0.25),
    colorFill: getAlphaColor(colorTextBase, 0.06),
    colorFillSecondary: getAlphaColor(colorTextBase, 0.04),
    colorFillTertiary: getAlphaColor(colorTextBase, 0.03),
    colorFillQuaternary: getAlphaColor(colorTextBase, 0.02),
    colorBgLayout: getSolidColor(colorBgBase, 4),
    colorBgContainer: getSolidColor(colorBgBase, 0),
    colorBgElevated: getSolidColor(colorBgBase, 0),
    colorBgSpotlight: getAlphaColor(colorTextBase, 0.85),
    colorBorder: getSolidColor(colorBgBase, 15),
    colorBorderSecondary: getSolidColor(colorBgBase, 6),
    colorSplit: getAlphaColor(colorTextBase, 0.06)
  };
};

var derivative = function derivative(token, mapToken) {
  var mergedMapToken = mapToken !== null && mapToken !== void 0 ? mapToken : defaultAlgorithm(token);
  return _extends(_extends({}, mergedMapToken), genColorMapToken(token, {
    generateColorPalettes: generateColorPalettes,
    generateNeutralColorPalettes: generateNeutralColorPalettes
  }));
};

export default derivative;