{"version":3,"file":"nivo-colors.mjs","sources":["../src/schemes/categorical.ts","../src/schemes/diverging.ts","../src/schemes/sequential.ts","../src/schemes/all.ts","../src/schemes/cyclical.ts","../src/schemes/interpolators.ts","../src/inheritedColor.ts","../src/scales/sequentialColorScale.ts","../src/scales/divergingColorScale.ts","../src/scales/quantizeColorScale.ts","../src/scales/continuousColorScale.ts","../src/scales/ordinalColorScale.ts"],"sourcesContent":["import {\n    schemeCategory10,\n    schemeAccent,\n    schemeDark2,\n    schemePaired,\n    schemePastel1,\n    schemePastel2,\n    schemeSet1,\n    schemeSet2,\n    schemeSet3,\n    schemeTableau10,\n} from 'd3-scale-chromatic'\n\nexport const categoricalColorSchemes = {\n    nivo: ['#e8c1a0', '#f47560', '#f1e15b', '#e8a838', '#61cdbb', '#97e3d5'],\n    category10: schemeCategory10,\n    accent: schemeAccent,\n    dark2: schemeDark2,\n    paired: schemePaired,\n    pastel1: schemePastel1,\n    pastel2: schemePastel2,\n    set1: schemeSet1,\n    set2: schemeSet2,\n    set3: schemeSet3,\n    tableau10: schemeTableau10,\n}\n\nexport type CategoricalColorSchemeId = keyof typeof categoricalColorSchemes\n\nexport const categoricalColorSchemeIds = Object.keys(\n    categoricalColorSchemes\n) as CategoricalColorSchemeId[]\n","import {\n    schemeBrBG,\n    interpolateBrBG,\n    schemePRGn,\n    interpolatePRGn,\n    schemePiYG,\n    interpolatePiYG,\n    schemePuOr,\n    interpolatePuOr,\n    schemeRdBu,\n    interpolateRdBu,\n    schemeRdGy,\n    interpolateRdGy,\n    schemeRdYlBu,\n    interpolateRdYlBu,\n    schemeRdYlGn,\n    interpolateRdYlGn,\n    schemeSpectral,\n    interpolateSpectral,\n} from 'd3-scale-chromatic'\n\n// Diverging color schemes support a size k ranging from 3 to 11\nexport const divergingColorSchemes = {\n    brown_blueGreen: schemeBrBG,\n    purpleRed_green: schemePRGn,\n    pink_yellowGreen: schemePiYG,\n    purple_orange: schemePuOr,\n    red_blue: schemeRdBu,\n    red_grey: schemeRdGy,\n    red_yellow_blue: schemeRdYlBu,\n    red_yellow_green: schemeRdYlGn,\n    spectral: schemeSpectral,\n}\n\nexport type DivergingColorSchemeId = keyof typeof divergingColorSchemes\n\nexport const divergingColorSchemeIds = Object.keys(\n    divergingColorSchemes\n) as DivergingColorSchemeId[]\n\nexport const divergingColorInterpolators = {\n    brown_blueGreen: interpolateBrBG,\n    purpleRed_green: interpolatePRGn,\n    pink_yellowGreen: interpolatePiYG,\n    purple_orange: interpolatePuOr,\n    red_blue: interpolateRdBu,\n    red_grey: interpolateRdGy,\n    red_yellow_blue: interpolateRdYlBu,\n    red_yellow_green: interpolateRdYlGn,\n    spectral: interpolateSpectral,\n}\n\nexport type DivergingColorInterpolatorId = keyof typeof divergingColorInterpolators\n","import {\n    // single hue\n    schemeBlues,\n    interpolateBlues,\n    schemeGreens,\n    interpolateGreens,\n    schemeGreys,\n    interpolateGreys,\n    schemeOranges,\n    interpolateOranges,\n    schemePurples,\n    interpolatePurples,\n    schemeReds,\n    interpolateReds,\n    // multi hue\n    schemeBuGn,\n    interpolateBuGn,\n    schemeBuPu,\n    interpolateBuPu,\n    schemeGnBu,\n    interpolateGnBu,\n    schemeOrRd,\n    interpolateOrRd,\n    schemePuBuGn,\n    interpolatePuBuGn,\n    schemePuBu,\n    interpolatePuBu,\n    schemePuRd,\n    interpolatePuRd,\n    schemeRdPu,\n    interpolateRdPu,\n    schemeYlGnBu,\n    interpolateYlGnBu,\n    schemeYlGn,\n    interpolateYlGn,\n    schemeYlOrBr,\n    interpolateYlOrBr,\n    schemeYlOrRd,\n    interpolateYlOrRd,\n    interpolateTurbo,\n    interpolateViridis,\n    interpolateInferno,\n    interpolateMagma,\n    interpolatePlasma,\n    interpolateCividis,\n    interpolateWarm,\n    interpolateCool,\n    interpolateCubehelixDefault,\n} from 'd3-scale-chromatic'\n\n// Sequential, single-hue color schemes support a size k ranging from 3 to 9\n// Sequential, multi-hue color schemes support a size k ranging from 3 to 9\nexport const sequentialColorSchemes = {\n    // single hue\n    blues: schemeBlues,\n    greens: schemeGreens,\n    greys: schemeGreys,\n    oranges: schemeOranges,\n    purples: schemePurples,\n    reds: schemeReds,\n    // multi hue\n    blue_green: schemeBuGn,\n    blue_purple: schemeBuPu,\n    green_blue: schemeGnBu,\n    orange_red: schemeOrRd,\n    purple_blue_green: schemePuBuGn,\n    purple_blue: schemePuBu,\n    purple_red: schemePuRd,\n    red_purple: schemeRdPu,\n    yellow_green_blue: schemeYlGnBu,\n    yellow_green: schemeYlGn,\n    yellow_orange_brown: schemeYlOrBr,\n    yellow_orange_red: schemeYlOrRd,\n}\n\nexport type SequentialColorSchemeId = keyof typeof sequentialColorSchemes\n\nexport const sequentialColorSchemeIds = Object.keys(\n    sequentialColorSchemes\n) as SequentialColorSchemeId[]\n\nexport const sequentialColorInterpolators = {\n    // single hue\n    blues: interpolateBlues,\n    greens: interpolateGreens,\n    greys: interpolateGreys,\n    oranges: interpolateOranges,\n    purples: interpolatePurples,\n    reds: interpolateReds,\n    // multi hue\n    turbo: interpolateTurbo,\n    viridis: interpolateViridis,\n    inferno: interpolateInferno,\n    magma: interpolateMagma,\n    plasma: interpolatePlasma,\n    cividis: interpolateCividis,\n    warm: interpolateWarm,\n    cool: interpolateCool,\n    cubehelixDefault: interpolateCubehelixDefault,\n    blue_green: interpolateBuGn,\n    blue_purple: interpolateBuPu,\n    green_blue: interpolateGnBu,\n    orange_red: interpolateOrRd,\n    purple_blue_green: interpolatePuBuGn,\n    purple_blue: interpolatePuBu,\n    purple_red: interpolatePuRd,\n    red_purple: interpolateRdPu,\n    yellow_green_blue: interpolateYlGnBu,\n    yellow_green: interpolateYlGn,\n    yellow_orange_brown: interpolateYlOrBr,\n    yellow_orange_red: interpolateYlOrRd,\n}\n\nexport type SequentialColorInterpolatorId = keyof typeof sequentialColorInterpolators\n","import {\n    categoricalColorSchemes,\n    categoricalColorSchemeIds,\n    CategoricalColorSchemeId,\n} from './categorical'\nimport { divergingColorSchemes, divergingColorSchemeIds, DivergingColorSchemeId } from './diverging'\nimport {\n    sequentialColorSchemes,\n    sequentialColorSchemeIds,\n    SequentialColorSchemeId,\n} from './sequential'\n\nexport const colorSchemes = {\n    ...categoricalColorSchemes,\n    ...divergingColorSchemes,\n    ...sequentialColorSchemes,\n}\n\nexport type ColorSchemeId =\n    | CategoricalColorSchemeId\n    | DivergingColorSchemeId\n    | SequentialColorSchemeId\n\nexport const colorSchemeIds = Object.keys(colorSchemes) as ColorSchemeId[]\n\nexport const isCategoricalColorScheme = (\n    scheme: ColorSchemeId\n): scheme is CategoricalColorSchemeId =>\n    categoricalColorSchemeIds.includes(scheme as CategoricalColorSchemeId)\n\nexport const isDivergingColorScheme = (scheme: ColorSchemeId): scheme is DivergingColorSchemeId =>\n    divergingColorSchemeIds.includes(scheme as DivergingColorSchemeId)\n\nexport const isSequentialColorScheme = (scheme: ColorSchemeId): scheme is SequentialColorSchemeId =>\n    sequentialColorSchemeIds.includes(scheme as SequentialColorSchemeId)\n","import { interpolateRainbow, interpolateSinebow } from 'd3-scale-chromatic'\n\nexport const cyclicalColorInterpolators = {\n    rainbow: interpolateRainbow,\n    sinebow: interpolateSinebow,\n}\n\nexport type CyclicalColorInterpolatorId = keyof typeof cyclicalColorInterpolators\n","import { divergingColorInterpolators, DivergingColorInterpolatorId } from './diverging'\nimport { sequentialColorInterpolators, SequentialColorInterpolatorId } from './sequential'\nimport { cyclicalColorInterpolators, CyclicalColorInterpolatorId } from './cyclical'\n\nexport const colorInterpolators = {\n    ...divergingColorInterpolators,\n    ...sequentialColorInterpolators,\n    ...cyclicalColorInterpolators,\n}\n\nexport type ColorInterpolatorId =\n    | DivergingColorInterpolatorId\n    | SequentialColorInterpolatorId\n    | CyclicalColorInterpolatorId\n\nexport const colorInterpolatorIds = Object.keys(colorInterpolators) as ColorInterpolatorId[]\n","import { useMemo } from 'react'\nimport get from 'lodash/get.js'\nimport isPlainObject from 'lodash/isPlainObject.js'\nimport { rgb, RGBColor } from 'd3-color'\nimport { Theme } from '@nivo/theming'\n\nexport type ColorModifierBrightness = ['brighter', number]\n\nexport type ColorModifierDarkness = ['darker', number]\n\nexport type ColorModifierOpacity = ['opacity', number]\n\nexport type ColorModifier = ColorModifierBrightness | ColorModifierDarkness | ColorModifierOpacity\n\nexport type ColorModifierFunction = (color: RGBColor) => RGBColor\n\nexport type InheritedColorConfigStaticColor = string\n\nexport type InheritedColorConfigCustomFunction<Datum> = (d: Datum, ...drest: Datum[]) => string\n\nexport interface InheritedColorConfigFromTheme {\n    theme: string\n}\n\nexport interface InheritedColorConfigFromContext {\n    from: string\n    modifiers?: ColorModifier[]\n}\n\nexport type InheritedColorConfig<Datum> =\n    | InheritedColorConfigStaticColor\n    | InheritedColorConfigCustomFunction<Datum>\n    | InheritedColorConfigFromTheme\n    | InheritedColorConfigFromContext\n\nexport const isInheritedColorConfigFromTheme = <Datum>(\n    config: InheritedColorConfig<Datum>\n): config is InheritedColorConfigFromTheme => {\n    return (config as InheritedColorConfigFromTheme).theme !== undefined\n}\n\nexport const isInheritedColorConfigFromContext = <Datum>(\n    config: InheritedColorConfig<Datum>\n): config is InheritedColorConfigFromContext => {\n    return (config as InheritedColorConfigFromContext).from !== undefined\n}\n\n/**\n * Create a color generator for items which\n * might inherit from parent context,\n * for example labels, outlines…\n *\n * Support the following strategies:\n * - custom function\n * - color from theme\n * - color from parent, with optional color modifiers\n * - static color\n */\nexport const getInheritedColorGenerator = <Datum = any>(\n    config: InheritedColorConfig<Datum>,\n    theme?: Theme\n) => {\n    // user provided function\n    if (typeof config === 'function') {\n        return config\n    }\n\n    if (isPlainObject(config)) {\n        // use color from theme\n        if (isInheritedColorConfigFromTheme(config)) {\n            if (theme === undefined) {\n                throw new Error(`Unable to use color from theme as no theme was provided`)\n            }\n\n            const themeColor = get(theme, config.theme)\n            if (themeColor === undefined) {\n                throw new Error(`Color from theme is undefined at path: '${config.theme}'`)\n            }\n\n            return () => themeColor\n        }\n\n        // use color from parent with optional color modifiers\n        if (isInheritedColorConfigFromContext(config)) {\n            const getColor = (d: Datum) => get(d, config.from)\n\n            if (Array.isArray(config.modifiers)) {\n                const modifiers: ColorModifierFunction[] = []\n                for (const modifier of config.modifiers) {\n                    const [modifierType, amount] = modifier\n                    if (modifierType === 'brighter') {\n                        modifiers.push(color => color.brighter(amount))\n                    } else if (modifierType === 'darker') {\n                        modifiers.push(color => color.darker(amount))\n                    } else if (modifierType === 'opacity') {\n                        modifiers.push(color => {\n                            color.opacity = amount\n\n                            return color\n                        })\n                    } else {\n                        throw new Error(\n                            `Invalid color modifier: '${modifierType}', must be one of: 'brighter', 'darker', 'opacity'`\n                        )\n                    }\n                }\n\n                if (modifiers.length === 0) return getColor\n\n                return (datum: Datum) =>\n                    modifiers\n                        .reduce((color, modify) => modify(color), rgb(getColor(datum)))\n                        .toString()\n            }\n\n            // no modifier\n            return getColor\n        }\n\n        throw new Error(\n            `Invalid color spec, you should either specify 'theme' or 'from' when using a config object`\n        )\n    }\n\n    // use provided color statically\n    return () => config as string\n}\n\nexport const useInheritedColor = <Datum = any>(\n    config: InheritedColorConfig<Datum>,\n    theme?: Theme\n) => useMemo(() => getInheritedColorGenerator<Datum>(config, theme), [config, theme])\n","import { useMemo } from 'react'\nimport { scaleSequential } from 'd3-scale'\nimport { colorInterpolators, ColorInterpolatorId } from '../schemes'\n\nexport interface SequentialColorScaleBaseConfig {\n    type: 'sequential'\n    minValue?: number\n    maxValue?: number\n}\n\nexport interface SequentialColorScaleSchemeConfig extends SequentialColorScaleBaseConfig {\n    scheme?: ColorInterpolatorId\n}\n\nexport interface SequentialColorScaleColorsConfig extends SequentialColorScaleBaseConfig {\n    colors: [string, string]\n}\n\nexport interface SequentialColorScaleInterpolatorConfig extends SequentialColorScaleBaseConfig {\n    interpolator: (t: number) => string\n}\n\nexport type SequentialColorScaleConfig =\n    | SequentialColorScaleSchemeConfig\n    | SequentialColorScaleColorsConfig\n    | SequentialColorScaleInterpolatorConfig\n\nexport interface SequentialColorScaleValues {\n    min: number\n    max: number\n}\n\nexport const sequentialColorScaleDefaults: {\n    scheme: ColorInterpolatorId\n} = {\n    scheme: 'turbo',\n}\n\nexport const getSequentialColorScale = (\n    config: SequentialColorScaleConfig,\n    values: SequentialColorScaleValues\n) => {\n    const { minValue, maxValue } = config\n    const min = minValue !== undefined ? minValue : values.min\n    const max = maxValue !== undefined ? maxValue : values.max\n\n    const colorScale = scaleSequential<string>().domain([min, max]).clamp(true)\n    if ('colors' in config) {\n        colorScale.range(config.colors)\n    } else if ('interpolator' in config) {\n        colorScale.interpolator(config.interpolator)\n    } else {\n        const scheme = config.scheme ?? sequentialColorScaleDefaults.scheme\n        colorScale.interpolator(colorInterpolators[scheme])\n    }\n\n    return colorScale\n}\n\nexport const useSequentialColorScale = (\n    config: SequentialColorScaleConfig,\n    values: SequentialColorScaleValues\n) => useMemo(() => getSequentialColorScale(config, values), [config, values])\n","import { useMemo } from 'react'\nimport { scaleDiverging } from 'd3-scale'\nimport { colorInterpolators, ColorInterpolatorId } from '../schemes'\n\ninterface DivergingColorScaleBaseConfig {\n    type: 'diverging'\n    minValue?: number\n    maxValue?: number\n    divergeAt?: number\n}\n\nexport interface DivergingColorScaleSchemeConfig extends DivergingColorScaleBaseConfig {\n    scheme?: ColorInterpolatorId\n}\n\nexport interface DivergingColorScaleColorsConfig extends DivergingColorScaleBaseConfig {\n    colors: [string, string, string]\n}\n\nexport interface DivergingColorScaleInterpolatorConfig extends DivergingColorScaleBaseConfig {\n    interpolator: (t: number) => string\n}\n\nexport type DivergingColorScaleConfig =\n    | DivergingColorScaleSchemeConfig\n    | DivergingColorScaleColorsConfig\n    | DivergingColorScaleInterpolatorConfig\n\nexport interface DivergingColorScaleValues {\n    min: number\n    max: number\n}\n\nexport const divergingColorScaleDefaults: {\n    scheme: ColorInterpolatorId\n    divergeAt: number\n} = {\n    scheme: 'red_yellow_blue',\n    divergeAt: 0.5,\n}\n\nexport const getDivergingColorScale = (\n    config: DivergingColorScaleConfig,\n    values: DivergingColorScaleValues\n) => {\n    const { minValue, maxValue } = config\n    const min = minValue !== undefined ? minValue : values.min\n    const max = maxValue !== undefined ? maxValue : values.max\n    const domain = [min, min + (max - min) / 2, max]\n\n    const divergeAt = config.divergeAt ?? divergingColorScaleDefaults.divergeAt\n    const offset = 0.5 - divergeAt\n\n    const colorScale = scaleDiverging<string>().domain(domain).clamp(true)\n    let interpolator = (t: number) => String(t) as string\n    if ('colors' in config) {\n        interpolator = scaleDiverging<string>()\n            .domain(domain.map(x => x - offset * (max - min)))\n            .range(config.colors)\n            .interpolator()\n    } else if ('interpolator' in config) {\n        interpolator = config.interpolator\n    } else {\n        const scheme = config.scheme ?? divergingColorScaleDefaults.scheme\n        interpolator = colorInterpolators[scheme]\n    }\n    const offsetInterpolator = (t: number) => interpolator(t + offset)\n    return colorScale.interpolator(offsetInterpolator)\n}\n\nexport const useDivergingColorScale = (\n    config: DivergingColorScaleConfig,\n    values: DivergingColorScaleValues\n) => useMemo(() => getDivergingColorScale(config, values), [config, values])\n","import { useMemo } from 'react'\nimport { scaleQuantize } from 'd3-scale'\nimport { colorInterpolators, ColorInterpolatorId } from '../schemes'\n\n// colors from a scheme\nexport interface QuantizeColorScaleSchemeConfig {\n    type: 'quantize'\n    domain?: [number, number]\n    scheme?: ColorInterpolatorId\n    steps?: number\n}\n\n// explicit colors\nexport interface QuantizeColorScaleColorsConfig {\n    type: 'quantize'\n    domain?: [number, number]\n    colors: string[]\n}\n\nexport type QuantizeColorScaleConfig =\n    | QuantizeColorScaleSchemeConfig\n    | QuantizeColorScaleColorsConfig\n\nexport interface QuantizeColorScaleValues {\n    min: number\n    max: number\n}\n\nexport const quantizeColorScaleDefaults: {\n    scheme: ColorInterpolatorId\n    steps: NonNullable<QuantizeColorScaleSchemeConfig['steps']>\n} = {\n    scheme: 'turbo',\n    steps: 7,\n}\n\nexport const getQuantizeColorScale = (\n    config: QuantizeColorScaleConfig,\n    values: QuantizeColorScaleValues\n) => {\n    const colorScale = scaleQuantize<string>()\n        .domain(config.domain || [values.min, values.max])\n        .nice()\n\n    if ('colors' in config) {\n        colorScale.range(config.colors)\n    } else {\n        const scheme = config.scheme || quantizeColorScaleDefaults.scheme\n        const steps = config.steps === undefined ? quantizeColorScaleDefaults.steps : config.steps\n        const interpolator = colorInterpolators[scheme]\n        const colors = Array.from({ length: steps }).map((_, step) =>\n            interpolator(step * (1 / (steps - 1)))\n        )\n\n        colorScale.range(colors)\n    }\n\n    return colorScale\n}\n\nexport const useQuantizeColorScale = (\n    config: QuantizeColorScaleConfig,\n    values: QuantizeColorScaleValues\n) => useMemo(() => getQuantizeColorScale(config, values), [config, values])\n","import { useMemo } from 'react'\nimport isPlainObject from 'lodash/isPlainObject.js'\nimport { ScaleDiverging, ScaleQuantize, ScaleSequential, scaleLinear } from 'd3-scale'\nimport {\n    SequentialColorScaleConfig,\n    SequentialColorScaleValues,\n    getSequentialColorScale,\n} from './sequentialColorScale'\nimport {\n    DivergingColorScaleConfig,\n    DivergingColorScaleValues,\n    getDivergingColorScale,\n} from './divergingColorScale'\nimport {\n    QuantizeColorScaleConfig,\n    QuantizeColorScaleValues,\n    getQuantizeColorScale,\n} from './quantizeColorScale'\n\nexport type ContinuousColorScaleConfig =\n    | SequentialColorScaleConfig\n    | DivergingColorScaleConfig\n    | QuantizeColorScaleConfig\n\nexport type ContinuousColorScaleValues =\n    | SequentialColorScaleValues\n    | DivergingColorScaleValues\n    | QuantizeColorScaleValues\n\nexport const isSequentialColorScaleConfig = (\n    config: ContinuousColorScaleConfig\n): config is SequentialColorScaleConfig => config.type === 'sequential'\n\nexport const isDivergingColorScaleConfig = (\n    config: ContinuousColorScaleConfig\n): config is DivergingColorScaleConfig => config.type === 'diverging'\n\nexport const isQuantizeColorScaleConfig = (\n    config: ContinuousColorScaleConfig\n): config is QuantizeColorScaleConfig => config.type === 'quantize'\n\nexport const isContinuousColorScale = (config: unknown): config is ContinuousColorScaleConfig => {\n    if (!isPlainObject(config)) return false\n\n    const { type } = config as { type: string }\n    return type === 'sequential' || type === 'diverging' || type === 'quantize'\n}\n\nexport const getContinuousColorScale = <Config extends ContinuousColorScaleConfig>(\n    config: Config,\n    values: ContinuousColorScaleValues\n) => {\n    if (isSequentialColorScaleConfig(config)) {\n        return getSequentialColorScale(config, values)\n    }\n\n    if (isDivergingColorScaleConfig(config)) {\n        return getDivergingColorScale(config, values)\n    }\n\n    if (isQuantizeColorScaleConfig(config)) {\n        return getQuantizeColorScale(config, values)\n    }\n\n    throw new Error('Invalid continuous color scale config')\n}\n\nexport const useContinuousColorScale = (\n    config: ContinuousColorScaleConfig,\n    values: ContinuousColorScaleValues\n) => useMemo(() => getContinuousColorScale(config, values), [config, values])\n\nexport const computeContinuousColorScaleColorStops = (\n    scale: ScaleSequential<string> | ScaleDiverging<string> | ScaleQuantize<string>,\n    steps = 16\n) => {\n    const domain = scale.domain()\n\n    // quantize\n    if ('thresholds' in scale) {\n        const stops: {\n            key: string\n            offset: number\n            stopColor: string\n        }[] = []\n\n        const normalizedScale = scaleLinear().domain(domain).range([0, 1])\n        scale.range().forEach((color, index) => {\n            const [start, end] = scale.invertExtent(color)\n\n            stops.push({\n                key: `${index}.0`,\n                offset: normalizedScale(start),\n                stopColor: color,\n            })\n            stops.push({\n                key: `${index}.1`,\n                offset: normalizedScale(end),\n                stopColor: color,\n            })\n        })\n\n        return stops\n    }\n\n    const colorStopsScale = scale.copy()\n    if (domain.length === 2) {\n        // sequential\n        colorStopsScale.domain([0, 1])\n    } else if (domain.length === 3) {\n        // diverging\n        colorStopsScale.domain([0, 0.5, 1])\n    }\n\n    return ((colorStopsScale as any).ticks(steps) as number[]).map((value: number) => ({\n        key: `${value}`,\n        offset: value,\n        stopColor: `${colorStopsScale(value)}`,\n    }))\n}\n","import { useMemo } from 'react'\nimport get from 'lodash/get.js'\nimport isPlainObject from 'lodash/isPlainObject.js'\nimport { scaleOrdinal } from 'd3-scale'\nimport {\n    ColorSchemeId,\n    colorSchemes,\n    isCategoricalColorScheme,\n    isSequentialColorScheme,\n    isDivergingColorScheme,\n} from '../schemes'\n\n/**\n * Static color.\n */\nexport type OrdinalColorScaleConfigStaticColor = string\n\n/**\n * User defined function, receiving the current datum.\n */\nexport type OrdinalColorScaleConfigCustomFunction<Datum> = (d: Datum) => string\n\n/**\n * Pre-defined color scheme.\n */\nexport interface OrdinalColorScaleConfigScheme {\n    scheme: ColorSchemeId\n    // size is useful for diverging & sequential colors,\n    // as they are array of array, whereas categorical colors\n    // are simple arrays, if the size isn't specified,\n    // the bigger array will be selected, this means the 11th\n    // for diverging colors and 9th for sequential ones.\n    size?: number\n}\n\n/**\n * User defined colors.\n */\nexport type OrdinalColorScaleConfigCustomColors = string[]\n\n/**\n * Get color from datum.\n */\nexport interface OrdinalColorScaleConfigDatumProperty {\n    // path to the color property\n    datum: string\n}\n\nexport type OrdinalColorScaleConfig<Datum = any> =\n    | OrdinalColorScaleConfigStaticColor\n    | OrdinalColorScaleConfigCustomFunction<Datum>\n    | OrdinalColorScaleConfigScheme\n    | OrdinalColorScaleConfigCustomColors\n    | OrdinalColorScaleConfigDatumProperty\n\nconst isOrdinalColorScaleConfigScheme = <Datum>(\n    config: OrdinalColorScaleConfig<Datum>\n): config is OrdinalColorScaleConfigScheme => {\n    return (config as OrdinalColorScaleConfigScheme).scheme !== undefined\n}\n\nconst isOrdinalColorScaleConfigDatumProperty = <Datum>(\n    config: OrdinalColorScaleConfig<Datum>\n): config is OrdinalColorScaleConfigDatumProperty => {\n    return (config as OrdinalColorScaleConfigDatumProperty).datum !== undefined\n}\n\nexport type DatumIdentityAccessor<Datum> = (datum: Datum) => string | number\n\nexport type OrdinalColorScale<Datum> = (d: Datum) => string\n\n/**\n * Compute an ordinal color scale\n */\nexport const getOrdinalColorScale = <Datum = any>(\n    config: OrdinalColorScaleConfig<Datum>,\n    identity?: string | DatumIdentityAccessor<Datum>\n): OrdinalColorScale<Datum> => {\n    // user defined function\n    if (typeof config === 'function') {\n        return config\n    }\n\n    // compute accessor to the datum identity\n    const getIdentity =\n        typeof identity === 'function' ? identity : (datum: Datum) => get(datum, identity as string)\n\n    // user defined color array\n    if (Array.isArray(config)) {\n        const scale = scaleOrdinal(config)\n        const generator = (datum: Datum) => scale(getIdentity(datum))\n        generator.scale = scale\n\n        return generator as OrdinalColorScale<Datum>\n    }\n\n    if (isPlainObject(config)) {\n        // use color from current datum\n        if (isOrdinalColorScaleConfigDatumProperty(config)) {\n            return (datum: Datum) => get(datum, config.datum)\n        }\n\n        // ordinal scale from predefined scheme\n        if (isOrdinalColorScaleConfigScheme(config)) {\n            // categorical color scheme\n            if (isCategoricalColorScheme(config.scheme)) {\n                const scale = scaleOrdinal(colorSchemes[config.scheme])\n                const generator = (datum: Datum) => scale(getIdentity(datum))\n                generator.scale = scale\n\n                return generator as OrdinalColorScale<Datum>\n            }\n\n            // Diverging color schemes support a size k ranging from 3 to 11\n            if (isDivergingColorScheme(config.scheme)) {\n                if (config.size !== undefined && (config.size < 3 || config.size > 11)) {\n                    throw new Error(\n                        `Invalid size '${config.size}' for diverging color scheme '${config.scheme}', must be between 3~11`\n                    )\n                }\n\n                const scale = scaleOrdinal(colorSchemes[config.scheme][config.size || 11])\n                const generator = (d: Datum) => scale(getIdentity(d))\n                generator.scale = scale\n\n                return generator as OrdinalColorScale<Datum>\n            }\n\n            // Sequential, single-hue color schemes support a size k ranging from 3 to 9.\n            // Sequential, multi-hue color schemes support a size k ranging from 3 to 9.\n            if (isSequentialColorScheme(config.scheme)) {\n                if (config.size !== undefined && (config.size < 3 || config.size > 9)) {\n                    throw new Error(\n                        `Invalid size '${config.size}' for sequential color scheme '${config.scheme}', must be between 3~9`\n                    )\n                }\n\n                const scale = scaleOrdinal(colorSchemes[config.scheme][config.size || 9])\n                const generator = (d: Datum) => scale(getIdentity(d))\n                generator.scale = scale\n\n                return generator as OrdinalColorScale<Datum>\n            }\n        }\n\n        throw new Error(\n            `Invalid colors, when using an object, you should either pass a 'datum' or a 'scheme' property`\n        )\n    }\n\n    // static color\n    return () => config as string\n}\n\nexport const useOrdinalColorScale = <Datum = any>(\n    config: OrdinalColorScaleConfig<Datum>,\n    identity: string | DatumIdentityAccessor<Datum>\n) => useMemo(() => getOrdinalColorScale<Datum>(config, identity), [config, identity])\n"],"names":["categoricalColorSchemes","nivo","category10","schemeCategory10","accent","schemeAccent","dark2","schemeDark2","paired","schemePaired","pastel1","schemePastel1","pastel2","schemePastel2","set1","schemeSet1","set2","schemeSet2","set3","schemeSet3","tableau10","schemeTableau10","categoricalColorSchemeIds","Object","keys","divergingColorSchemes","brown_blueGreen","schemeBrBG","purpleRed_green","schemePRGn","pink_yellowGreen","schemePiYG","purple_orange","schemePuOr","red_blue","schemeRdBu","red_grey","schemeRdGy","red_yellow_blue","schemeRdYlBu","red_yellow_green","schemeRdYlGn","spectral","schemeSpectral","divergingColorSchemeIds","divergingColorInterpolators","interpolateBrBG","interpolatePRGn","interpolatePiYG","interpolatePuOr","interpolateRdBu","interpolateRdGy","interpolateRdYlBu","interpolateRdYlGn","interpolateSpectral","sequentialColorSchemes","blues","schemeBlues","greens","schemeGreens","greys","schemeGreys","oranges","schemeOranges","purples","schemePurples","reds","schemeReds","blue_green","schemeBuGn","blue_purple","schemeBuPu","green_blue","schemeGnBu","orange_red","schemeOrRd","purple_blue_green","schemePuBuGn","purple_blue","schemePuBu","purple_red","schemePuRd","red_purple","schemeRdPu","yellow_green_blue","schemeYlGnBu","yellow_green","schemeYlGn","yellow_orange_brown","schemeYlOrBr","yellow_orange_red","schemeYlOrRd","sequentialColorSchemeIds","sequentialColorInterpolators","interpolateBlues","interpolateGreens","interpolateGreys","interpolateOranges","interpolatePurples","interpolateReds","turbo","interpolateTurbo","viridis","interpolateViridis","inferno","interpolateInferno","magma","interpolateMagma","plasma","interpolatePlasma","cividis","interpolateCividis","warm","interpolateWarm","cool","interpolateCool","cubehelixDefault","interpolateCubehelixDefault","interpolateBuGn","interpolateBuPu","interpolateGnBu","interpolateOrRd","interpolatePuBuGn","interpolatePuBu","interpolatePuRd","interpolateRdPu","interpolateYlGnBu","interpolateYlGn","interpolateYlOrBr","interpolateYlOrRd","colorSchemes","_extends","colorSchemeIds","isCategoricalColorScheme","scheme","includes","isDivergingColorScheme","isSequentialColorScheme","cyclicalColorInterpolators","rainbow","interpolateRainbow","sinebow","interpolateSinebow","colorInterpolators","colorInterpolatorIds","isInheritedColorConfigFromTheme","config","undefined","theme","isInheritedColorConfigFromContext","from","getInheritedColorGenerator","isPlainObject","Error","themeColor","get","getColor","d","Array","isArray","modifiers","_step","_loop","modifier","value","modifierType","amount","push","color","brighter","darker","opacity","_iterator","_createForOfIteratorHelperLoose","done","length","datum","reduce","modify","rgb","toString","useInheritedColor","useMemo","sequentialColorScaleDefaults","getSequentialColorScale","values","minValue","maxValue","min","max","colorScale","scaleSequential","domain","clamp","range","colors","interpolator","_config$scheme","useSequentialColorScale","divergingColorScaleDefaults","divergeAt","getDivergingColorScale","_config$divergeAt","offset","scaleDiverging","t","String","map","x","useDivergingColorScale","quantizeColorScaleDefaults","steps","getQuantizeColorScale","scaleQuantize","nice","_","step","useQuantizeColorScale","isSequentialColorScaleConfig","type","isDivergingColorScaleConfig","isQuantizeColorScaleConfig","isContinuousColorScale","getContinuousColorScale","useContinuousColorScale","computeContinuousColorScaleColorStops","scale","stops","normalizedScale","scaleLinear","forEach","index","_scale$invertExtent","invertExtent","start","end","key","stopColor","colorStopsScale","copy","ticks","getOrdinalColorScale","identity","getIdentity","scaleOrdinal","generator","isOrdinalColorScaleConfigDatumProperty","isOrdinalColorScaleConfigScheme","size","useOrdinalColorScale"],"mappings":"gxFAaO,IAAMA,GAA0B,CACnCC,KAAM,CAAC,UAAW,UAAW,UAAW,UAAW,UAAW,WAC9DC,WAAYC,EACZC,OAAQC,EACRC,MAAOC,EACPC,OAAQC,EACRC,QAASC,EACTC,QAASC,EACTC,KAAMC,EACNC,KAAMC,EACNC,KAAMC,EACNC,UAAWC,GAKFC,GAA4BC,OAAOC,KAC5CxB,ICRSyB,GAAwB,CACjCC,gBAAiBC,EACjBC,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