{"version":3,"file":"colors.mjs","sources":["../../../admin/src/utils/colors.ts"],"sourcesContent":["import { lightTheme } from '@strapi/design-system';\nimport { DefaultTheme } from 'styled-components';\n\nconst STAGE_COLORS: Record<string, string> = {\n  primary600: 'Blue',\n  primary200: 'Lilac',\n  alternative600: 'Violet',\n  alternative200: 'Lavender',\n  success600: 'Green',\n  success200: 'Pale Green',\n  danger500: 'Cherry',\n  danger200: 'Pink',\n  warning600: 'Orange',\n  warning200: 'Yellow',\n  secondary600: 'Teal',\n  secondary200: 'Baby Blue',\n  neutral400: 'Gray',\n  neutral0: 'White',\n};\n\nconst getStageColorByHex = (hex?: string) => {\n  if (!hex) {\n    return null;\n  }\n\n  // there are multiple colors with the same hex code in the design tokens. In order to find\n  // the correct one we have to find all matching colors and then check, which ones are usable\n  // for stages.\n  const themeColors: [string, (keyof typeof STAGE_COLORS)[]][] = Object.entries(\n    lightTheme.colors\n  ).filter(([, value]) => value.toUpperCase() === hex.toUpperCase());\n\n  const themeColorName = themeColors.reduce(\n    (acc, [name]) => {\n      if (STAGE_COLORS?.[name]) {\n        acc = name;\n      }\n\n      return acc;\n    },\n    null as keyof typeof STAGE_COLORS | null\n  );\n\n  if (!themeColorName) {\n    return null;\n  }\n\n  return {\n    themeColorName,\n    name: STAGE_COLORS[themeColorName],\n  };\n};\n\nconst AVAILABLE_COLORS = Object.entries(STAGE_COLORS).map(([themeColorName, name]) => ({\n  hex: lightTheme.colors[themeColorName as keyof DefaultTheme['colors']].toUpperCase(),\n  name,\n}));\n\nexport { AVAILABLE_COLORS, getStageColorByHex };\n"],"names":["STAGE_COLORS","primary600","primary200","alternative600","alternative200","success600","success200","danger500","danger200","warning600","warning200","secondary600","secondary200","neutral400","neutral0","getStageColorByHex","hex","themeColors","Object","entries","lightTheme","colors","filter","value","toUpperCase","themeColorName","reduce","acc","name","AVAILABLE_COLORS","map"],"mappings":";;AAGA,MAAMA,YAAAA,GAAuC;IAC3CC,UAAAA,EAAY,MAAA;IACZC,UAAA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