{
  "version": 3,
  "sources": ["../../src/theme/color-algorithms.ts"],
  "sourcesContent": ["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport a11yPlugin from 'colord/plugins/a11y';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\n\nimport { COLORS } from '../utils';\nextend([namesPlugin, a11yPlugin]);\nexport function generateThemeVariables(inputs) {\n  validateInputs(inputs);\n  const generatedColors = {\n    ...generateAccentDependentColors(inputs.accent),\n    ...generateBackgroundDependentColors(inputs.background)\n  };\n  warnContrastIssues(checkContrasts(inputs, generatedColors));\n  return {\n    colors: generatedColors\n  };\n}\nfunction validateInputs(inputs) {\n  for (const [key, value] of Object.entries(inputs)) {\n    if (typeof value !== 'undefined' && !colord(value).isValid()) {\n      globalThis.SCRIPT_DEBUG === true ? warning(`wp.components.Theme: \"${value}\" is not a valid color value for the '${key}' prop.`) : void 0;\n    }\n  }\n}\nexport function checkContrasts(inputs, outputs) {\n  const background = inputs.background || COLORS.white;\n  const accent = inputs.accent || '#3858e9';\n  const foreground = outputs.foreground || COLORS.gray[900];\n  const gray = outputs.gray || COLORS.gray;\n  return {\n    accent: colord(background).isReadable(accent) ? undefined : `The background color (\"${background}\") does not have sufficient contrast against the accent color (\"${accent}\").`,\n    foreground: colord(background).isReadable(foreground) ? undefined : `The background color provided (\"${background}\") does not have sufficient contrast against the standard foreground colors.`,\n    grays: colord(background).contrast(gray[600]) >= 3 && colord(background).contrast(gray[700]) >= 4.5 ? undefined : `The background color provided (\"${background}\") cannot generate a set of grayscale foreground colors with sufficient contrast. Try adjusting the color to be lighter or darker.`\n  };\n}\nfunction warnContrastIssues(issues) {\n  for (const error of Object.values(issues)) {\n    if (error) {\n      globalThis.SCRIPT_DEBUG === true ? warning('wp.components.Theme: ' + error) : void 0;\n    }\n  }\n}\nfunction generateAccentDependentColors(accent) {\n  if (!accent) {\n    return {};\n  }\n  return {\n    accent,\n    accentDarker10: colord(accent).darken(0.1).toHex(),\n    accentDarker20: colord(accent).darken(0.2).toHex(),\n    accentInverted: getForegroundForColor(accent)\n  };\n}\nfunction generateBackgroundDependentColors(background) {\n  if (!background) {\n    return {};\n  }\n  const foreground = getForegroundForColor(background);\n  return {\n    background,\n    foreground,\n    foregroundInverted: getForegroundForColor(foreground),\n    gray: generateShades(background, foreground)\n  };\n}\nfunction getForegroundForColor(color) {\n  return colord(color).isDark() ? COLORS.white : COLORS.gray[900];\n}\nexport function generateShades(background, foreground) {\n  // How much darkness you need to add to #fff to get the COLORS.gray[n] color\n  const SHADES = {\n    100: 0.06,\n    200: 0.121,\n    300: 0.132,\n    400: 0.2,\n    600: 0.42,\n    700: 0.543,\n    800: 0.821\n  };\n\n  // Darkness of COLORS.gray[ 900 ], relative to #fff\n  const limit = 0.884;\n  const direction = colord(background).isDark() ? 'lighten' : 'darken';\n\n  // Lightness delta between the background and foreground colors\n  const range = Math.abs(colord(background).toHsl().l - colord(foreground).toHsl().l) / 100;\n  const result = {};\n  Object.entries(SHADES).forEach(([key, value]) => {\n    result[parseInt(key)] = colord(background)[direction](value / limit * range).toHex();\n  });\n  return result;\n}"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA+B;AAC/B,kBAAuB;AACvB,mBAAwB;AAKxB,qBAAoB;AAMpB,mBAAuB;AAAA,IACvB,sBAAO,CAAC,aAAAA,SAAa,YAAAC,OAAU,CAAC;AACzB,SAAS,uBAAuB,QAAQ;AAC7C,iBAAe,MAAM;AACrB,QAAM,kBAAkB;AAAA,IACtB,GAAG,8BAA8B,OAAO,MAAM;AAAA,IAC9C,GAAG,kCAAkC,OAAO,UAAU;AAAA,EACxD;AACA,qBAAmB,eAAe,QAAQ,eAAe,CAAC;AAC1D,SAAO;AAAA,IACL,QAAQ;AAAA,EACV;AACF;AACA,SAAS,eAAe,QAAQ;AAC9B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