<commit_before>import titleCase from 'title-case'
import primerColors from 'primer-colors'
import colorSystemSCSS from '!!raw-loader?modules!../src/support/variables/color-system.scss'
import colorVariablesSCSS from '!!raw-loader?modules!../src/support/variables/colors.scss'

export const variables = {}

parseSCSSVariables(colorSystemSCSS, variables)
parseSCSSVariables(colorVariablesSCSS, variables)

// XXX we don't necessarily define them in this order in primer-colors,
// so we define an array here just to be safe
export const gradientHues = ['gray', 'blue', 'green', 'purple', 'yellow', 'orange', 'red', 'pink']

export const colors = {
  pink: Object.keys(variables)
    .filter(key => key.startsWith('pink-'))
    .sort()
    .map(key => variables[key]),
  ...primerColors
}

export const gradientPalettes = gradientHues.map(name => ({
  name,
  title: titleCase(name),
  values: colors[name].map((value, index) => ({
    value,
    index,
    variable: `${name}-${index}00`,
    slug: `${name}-${index}`
  }))
}))

export const backgroundPalettes = gradientPalettes.map(({name, values, ...paletteRest}) => ({
  name,
  ...paletteRest,
  value: variables[`bg-${name}`] || '',
  values: values.map(value => ({...value, className: `bg-${value.slug}`}))
}))

export const foregroundPalettes = gradientPalettes.map(({name, values, ...paletteRest}) => ({
  name,
  ...paletteRest,
  value: variables[`text-${name}`] || '',
  values: values.map(value => ({...value, className: `color-${value.slug}`}))
}))

export function getBackgroundPalette(name) {
  return backgroundPalettes.find(palette => palette.name === name)
}

export function getForegroundPalette(name) {<commit_msg>fix raw-loader SCSS imports, rework palette objects<commit_after>import titleCase from 'title-case'
import primerColors from 'primer-colors'

export const variables = {}

import colorSystemSCSS from '!!raw-loader?module!../src/support/variables/color-system.scss'
import colorVariablesSCSS from '!!raw-loader?module!../src/support/variables/colors.scss'

parseSCSSVariables(colorSystemSCSS, variables)
parseSCSSVariables(colorVariablesSCSS, variables)

// XXX we don't necessarily define them in this order in primer-colors,
// so we define an array here just to be safe
export const gradientHues = ['gray', 'blue', 'green', 'purple', 'yellow', 'orange', 'red', 'pink']

export const colors = {
  ...primerColors,
  pink: Object.keys(variables)
    .filter(key => key.startsWith('pink-'))
    .sort()
    .map(key => variables[key])
}

export const gradientPalettes = gradientHues.map(name => {
  const bgClass = `bg-${name}`
  const textClass = `text-${name}`
  return {
    name,
    title: titleCase(name),
    bg: variables[bgClass] ? {className: bgClass, value: variables[bgClass]} : null,
    fg: variables[textClass] ? {className: textClass, value: variables[textClass]} : null,
    values: colors[name].map((value, index) => ({
      value,
      index,
      variable: `${name}-${index}00`,
      slug: `${name}-${index}`
    }))
  }
})

export const backgroundPalettes = gradientPalettes
  .filter(palette => palette.bg)
  .map(({name, values, bg, ...paletteRest}) => ({
    name,
    ...paletteRest,
    className: bg.className,
    value: bg.value,
    values: values.map(value => ({...value, className: `bg-${value.slug}`}))
  }))

export const foregroundPalettes = gradientPalettes
  .filter(palette => palette.fg)
  .map(({name, values, fg, ...paletteRest}) => ({
    name,
    ...paletteRest,
    className: fg.className,
    value: fg.value,
    values: values.map(value => ({...value, className: `color-${value.slug}`}))
  }))

export function getBackgroundPalette(name) {
  return backgroundPalettes.find(palette => palette.name === name)
}

export function getForegroundPalette(name) {
{'fraction_non_alphanumeric': 0.16948257655755017, 'fraction_numerical': 0.0010559662090813093, 'mean_word_length': 4.3668555240793205, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '319855', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1201, 'n_words': 283}