diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 73f0d8f..0000000 --- a/.appveyor.yml +++ /dev/null @@ -1,18 +0,0 @@ -# https://www.appveyor.com/docs/appveyor-yml - -environment: - matrix: - - nodejs_version: 6 - -version: "{build}" -build: off -deploy: off - -install: - - ps: Install-Product node $env:nodejs_version - - npm install --ignore-scripts - -test_script: - - node --version - - npm --version - - cmd: "npm test" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a9be21b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + +jobs: + test: + name: test + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18, '*'] + + steps: + - name: checkout + uses: actions/checkout@v2 + - name: setup node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - run: npm install + - run: npm test diff --git a/.gitignore b/.gitignore index 6b0c809..b6d06d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,3 @@ node_modules -index.*.* -package-lock.json -*.log* *.result.css -.* -!.appveyor.yml -!.editorconfig -!.gitignore -!.rollup.js -!.tape.js -!.travis.yml +.eslintcache diff --git a/.rollup.js b/.rollup.js deleted file mode 100644 index 3f28a55..0000000 --- a/.rollup.js +++ /dev/null @@ -1,19 +0,0 @@ -import babel from 'rollup-plugin-babel'; - -export default { - input: 'index.js', - output: [ - { file: 'index.cjs.js', format: 'cjs', sourcemap: true }, - { file: 'index.es.mjs', format: 'es', sourcemap: true } - ], - plugins: [ - babel({ - plugins: [ - '@babel/plugin-syntax-dynamic-import' - ], - presets: [ - ['@babel/env', { modules: false, targets: { node: 6 } }] - ] - }) - ] -}; diff --git a/.rollup.mjs b/.rollup.mjs new file mode 100644 index 0000000..9d4e886 --- /dev/null +++ b/.rollup.mjs @@ -0,0 +1,7 @@ +export default { + input: 'index.js', + output: [ + { file: 'index.cjs.js', format: 'cjs', sourcemap: true, exports: 'auto' }, + { file: 'index.es.mjs', format: 'esm', sourcemap: true, exports: 'auto' } + ], +}; diff --git a/.tape.js b/.tape.js index 011fdb4..1167316 100644 --- a/.tape.js +++ b/.tape.js @@ -1,91 +1,89 @@ module.exports = { - 'postcss-color-mod-function': { - 'basic': { - message: 'supports basic usage' - }, - 'basic:colors': { - message: 'supports { stringifier } usage', - options: { - stringifier: color => color.toString() - } - }, - 'basic:transformvars': { - message: 'supports { transformVars: false } usage', - options: { - transformVars: false - }, - error: { - reason: 'Expected a color' - } - }, - 'warn': { - message: 'supports { unresolved } usage', - options: { - unresolved: 'warn' - }, - warning: 43, - expect: 'warn.css' - }, - 'hex': { - message: 'supports hex usage' + 'basic': { + message: 'supports basic usage' + }, + 'basic:colors': { + message: 'supports { stringifier } usage', + options: { + stringifier: color => color.toString() + } + }, + 'basic:transformvars': { + message: 'supports { transformVars: false } usage', + options: { + transformVars: false }, - 'import': { - message: 'supports { importFrom: "test/import-root.css" } usage', - options: { - importFrom: 'test/import-root.css' - } + error: { + reason: 'Expected a color' + } + }, + 'warn': { + message: 'supports { unresolved } usage', + options: { + unresolved: 'warn' }, - 'import:array': { - message: 'supports { importFrom: ["test/import-root.css"] } usage', - options: { - importFrom: ['test/import-root.css'] - }, - expect: 'import.expect.css', - result: 'import.result.css' + warnings: 43, + expect: 'warn.css' + }, + 'hex': { + message: 'supports hex usage' + }, + 'import': { + message: 'supports { importFrom: "test/import-root.css" } usage', + options: { + importFrom: 'test/import-root.css' + } + }, + 'import:array': { + message: 'supports { importFrom: ["test/import-root.css"] } usage', + options: { + importFrom: ['test/import-root.css'] }, - 'import:array-array': { - message: 'supports { importFrom: [["css", "test/import-root.css" ]] } usage', - options: { - importFrom: { from: 'test/import-root.css', type: 'css' } - }, - expect: 'import.expect.css', - result: 'import.result.css' + expect: 'import.expect.css', + result: 'import.result.css' + }, + 'import:array-array': { + message: 'supports { importFrom: [["css", "test/import-root.css" ]] } usage', + options: { + importFrom: { from: 'test/import-root.css', type: 'css' } }, - 'import:js': { - message: 'supports { importFrom: "test/import-root.js" } usage', - options: { - importFrom: 'test/import-root.js' - }, - expect: 'import.expect.css', - result: 'import.result.css' + expect: 'import.expect.css', + result: 'import.result.css' + }, + 'import:js': { + message: 'supports { importFrom: "test/import-root.js" } usage', + options: { + importFrom: 'test/import-root.js' }, - 'import:json': { - message: 'supports { importFrom: "test/import-root.json" } usage', - options: { - importFrom: 'test/import-root.json' - }, - expect: 'import.expect.css', - result: 'import.result.css' + expect: 'import.expect.css', + result: 'import.result.css' + }, + 'import:json': { + message: 'supports { importFrom: "test/import-root.json" } usage', + options: { + importFrom: 'test/import-root.json' }, - 'import:object': { - message: 'supports { importFrom: { customProperties: {} } } usage', - options: { - importFrom: [ - { - customProperties: { - '--color': 'var(--color-blue)' - } - }, - { - customProperties: { - '--color-blue': 'blue', - '--color-red': 'red' - } + expect: 'import.expect.css', + result: 'import.result.css' + }, + 'import:object': { + message: 'supports { importFrom: { customProperties: {} } } usage', + options: { + importFrom: [ + { + customProperties: { + '--color': 'var(--color-blue)' } - ] - }, - expect: 'import.expect.css', - result: 'import.result.css' - } + }, + { + customProperties: { + '--color-blue': 'blue', + '--color-red': 'red' + } + } + ] + }, + expect: 'import.expect.css', + result: 'import.result.css' } }; diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e1f11a5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -# https://docs.travis-ci.com/user/travis-lint - -language: node_js - -node_js: - - 6 - -install: - - npm install --ignore-scripts diff --git a/CHANGELOG.md b/CHANGELOG.md index c089195..ab9fa81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changes to PostCSS color-mod() Function +### 4.1.0 (October 18, 2024) + +- Drop `postcss-values-parser` in favor of `postcss-value-parser` + +### 4.0.0 (October 18, 2024) + +- PostCSS 8 support + ### 3.0.3 (September 23, 2018) - Fixed an issue with certain colors not being tranformed from variables diff --git a/INSTALL.md b/INSTALL.md index 3db6b03..5ba659a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -10,7 +10,7 @@ Add [PostCSS color-mod() Function] to your project: ```bash -npm install postcss-color-mod-function --save-dev +npm install postcss postcss-color-mod-function --save-dev ``` Use [PostCSS color-mod() Function] to process your CSS: diff --git a/README.md b/README.md index 881c8a9..5254580 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ # PostCSS color-mod() Function [PostCSS Logo][postcss] [![NPM Version][npm-img]][npm-url] -[![CSS Standard Status][css-img]][css-url] -[![Build Status][cli-img]][cli-url] -[![Support Chat][git-img]][git-url] +[![Test](https://github.com/csstools/postcss-color-mod-function/actions/workflows/test.yml/badge.svg)](https://github.com/csstools/postcss-color-mod-function/actions/workflows/test.yml) [PostCSS color-mod() Function] lets you modify colors using the `color-mod()` function in CSS, following the outdated version of [CSS Color Module Level 4] specification (05 July 2016). @@ -67,7 +65,7 @@ Properties are found in a `:root` rule, or if a fallback value is specified. Add [PostCSS color-mod() Function] to your project: ```bash -npm install postcss-color-mod-function --save-dev +npm install postcss postcss-color-mod-function --save-dev ``` Use [PostCSS color-mod() Function] to process your CSS: @@ -190,12 +188,6 @@ Variables may reference other variables, and this plugin will attempt to resolve them. If `transformVars` is set to `false` then `importFrom` will not be used. -[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-color-mod-function.svg -[cli-url]: https://travis-ci.org/jonathantneal/postcss-color-mod-function -[css-img]: https://cssdb.org/badge/color-mod-function.svg -[css-url]: https://preset-env.cssdb.org/features#color-mod-function -[git-img]: https://img.shields.io/badge/support-chat-blue.svg -[git-url]: https://gitter.im/postcss/postcss [npm-img]: https://img.shields.io/npm/v/postcss-color-mod-function.svg [npm-url]: https://www.npmjs.com/package/postcss-color-mod-function @@ -203,4 +195,4 @@ be used. [Gulp PostCSS]: https://github.com/postcss/gulp-postcss [Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss [PostCSS]: https://github.com/postcss/postcss -[PostCSS color-mod() Function]: https://github.com/jonathantneal/postcss-color-mod-function +[PostCSS color-mod() Function]: https://github.com/csstools/postcss-color-mod-function diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..71711c2 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,19 @@ +# Security Policy + +## Supported Versions + +Only the latest version of plugins and packages will receive security patches. +Please reach out if you need extended support for an older version. + +| Version | Supported | +| ------- | ------------------ | +| 5.1.x | :white_check_mark: | +| 5.0.x | :x: | +| 4.0.x | :x: | +| < 4.0 | :x: | + +## Security contact information + +To report a security vulnerability, please use the +[Tidelift security contact](https://tidelift.com/security). +Tidelift will coordinate the fix and disclosure. diff --git a/index.cjs.js b/index.cjs.js new file mode 100644 index 0000000..07ba8b2 --- /dev/null +++ b/index.cjs.js @@ -0,0 +1,1691 @@ +'use strict'; + +var parser = require('postcss-value-parser'); +var fs = require('fs'); +var path = require('path'); +var postcss = require('postcss'); +var convertColors = require('@csstools/convert-colors'); + +// return custom selectors from the css root, conditionally removing them +function getCustomProperties(root, opts) { + // initialize custom selectors + const customPropertiesFromHtmlElement = {}; + const customPropertiesFromRootPsuedo = {}; + + // for each html or :root rule + root.nodes.slice().forEach(rule => { + const customPropertiesObject = isHtmlRule(rule) + ? customPropertiesFromHtmlElement + : isRootRule(rule) + ? customPropertiesFromRootPsuedo + : null; + + // for each custom property + if (customPropertiesObject) { + rule.nodes.slice().forEach(decl => { + if (isCustomDecl(decl)) { + const { prop } = decl; + + // write the parsed value to the custom property + customPropertiesObject[prop] = parser(decl.value); + + // conditionally remove the custom property declaration + if (!opts.preserve) { + decl.remove(); + } + } + }); + + // conditionally remove the empty html or :root rule + if (!opts.preserve && isEmptyParent(rule)) { + rule.remove(); + } + } + }); + + // return all custom properties, preferring :root properties over html properties + return { ...customPropertiesFromHtmlElement, ...customPropertiesFromRootPsuedo }; +} + +// match html and :root rules +const htmlSelectorRegExp = /^html$/i; +const rootSelectorRegExp = /^:root$/i; +const customPropertyRegExp = /^--[A-z][\w-]*$/; + +// whether the node is an html or :root rule +const isHtmlRule = node => node.type === 'rule' && htmlSelectorRegExp.test(node.selector) && Object(node.nodes).length; +const isRootRule = node => node.type === 'rule' && rootSelectorRegExp.test(node.selector) && Object(node.nodes).length; + +// whether the node is an custom property +const isCustomDecl = node => node.type === 'decl' && customPropertyRegExp.test(node.prop); + +// whether the node is a parent without children +const isEmptyParent = node => Object(node.nodes).length === 0; + +/* Import Custom Properties from CSS AST +/* ========================================================================== */ + +function importCustomPropertiesFromCSSAST(root) { + return getCustomProperties(root, { preserve: true }); +} + +/* Import Custom Properties from CSS File +/* ========================================================================== */ + +async function importCustomPropertiesFromCSSFile(from) { + const css = await readFile(from); + const root = postcss.parse(css, { from }); + + return importCustomPropertiesFromCSSAST(root); +} + +/* Import Custom Properties from Object +/* ========================================================================== */ + +function importCustomPropertiesFromObject(object) { + const customProperties = Object.assign( + {}, + Object(object).customProperties || Object(object)['custom-properties'] + ); + + for (const prop in customProperties) { + customProperties[prop] = parser(customProperties[prop]); + } + + return customProperties; +} + +/* Import Custom Properties from JSON file +/* ========================================================================== */ + +async function importCustomPropertiesFromJSONFile(from) { + const object = await readJSON(from); + + return importCustomPropertiesFromObject(object); +} + +/* Import Custom Properties from JS file +/* ========================================================================== */ + +async function importCustomPropertiesFromJSFile(from) { + const object = await import(from); + + return importCustomPropertiesFromObject(('default' in object) ? object.default : object); +} + +/* Import Custom Properties from Sources +/* ========================================================================== */ + +function importCustomPropertiesFromSources(sources) { + return sources.map(source => { + if (source instanceof Promise) { + return source; + } else if (source instanceof Function) { + return source(); + } + + // read the source as an object + const opts = source === Object(source) ? source : { from: String(source) }; + + // skip objects with Custom Properties + if (opts.customProperties || opts['custom-properties']) { + return opts + } + + // source pathname + const from = path.resolve(String(opts.from || '')); + + // type of file being read from + const type = (opts.type || path.extname(from).slice(1)).toLowerCase(); + + return { type, from }; + }).reduce(async (customProperties, source) => { + const { type, from } = await source; + + if (type === 'ast') { + return Object.assign(await customProperties, importCustomPropertiesFromCSSAST(from)); + } + + if (type === 'css') { + return Object.assign(await customProperties, await importCustomPropertiesFromCSSFile(from)); + } + + if (type === 'js') { + return Object.assign(await customProperties, await importCustomPropertiesFromJSFile(from)); + } + + if (type === 'json') { + return Object.assign(await customProperties, await importCustomPropertiesFromJSONFile(from)); + } + + return Object.assign(await customProperties, await importCustomPropertiesFromObject(await source)); + }, {}); +} + +/* Helper utilities +/* ========================================================================== */ + +const readFile = from => new Promise((resolve, reject) => { + fs.readFile(from, 'utf8', (error, result) => { + if (error) { + reject(error); + } else { + resolve(result); + } + }); +}); + +const readJSON = async from => JSON.parse(await readFile(from)); + +/* Convert Degree to Hue Degree +/* ========================================================================== */ + +function convertDtoD(deg) { + return deg % 360; +} + +/* Convert Gradian to Hue Degree +/* ========================================================================== */ + +function convertGtoD(grad) { + return grad * 0.9 % 360; +} + +/* Convert Radian to Hue Degree +/* ========================================================================== */ + +function convertRtoD(rad) { + return rad * 180 / Math.PI % 360; +} + +/* Convert Turn to Hue Degree +/* ========================================================================== */ + +function convertTtoD(turn) { + return turn * 360 % 360; +} + +/* Convert a Name to Red/Green/Blue +/* ========================================================================== */ + +function convertNtoRGB(name) { + const names = { + aliceblue: [240, 248, 255], + antiquewhite: [250, 235, 215], + aqua: [0, 255, 255], + aquamarine: [127, 255, 212], + azure: [240, 255, 255], + beige: [245, 245, 220], + bisque: [255, 228, 196], + black: [0, 0, 0], + blanchedalmond: [255, 235, 205], + blue: [0, 0, 255], + blueviolet: [138, 43, 226], + brown: [165, 42, 42], + burlywood: [222, 184, 135], + cadetblue: [95, 158, 160], + chartreuse: [127, 255, 0], + chocolate: [210, 105, 30], + coral: [255, 127, 80], + cornflowerblue: [100, 149, 237], + cornsilk: [255, 248, 220], + crimson: [220, 20, 60], + cyan: [0, 255, 255], + darkblue: [0, 0, 139], + darkcyan: [0, 139, 139], + darkgoldenrod: [184, 134, 11], + darkgray: [169, 169, 169], + darkgreen: [0, 100, 0], + darkgrey: [169, 169, 169], + darkkhaki: [189, 183, 107], + darkmagenta: [139, 0, 139], + darkolivegreen: [85, 107, 47], + darkorange: [255, 140, 0], + darkorchid: [153, 50, 204], + darkred: [139, 0, 0], + darksalmon: [233, 150, 122], + darkseagreen: [143, 188, 143], + darkslateblue: [72, 61, 139], + darkslategray: [47, 79, 79], + darkslategrey: [47, 79, 79], + darkturquoise: [0, 206, 209], + darkviolet: [148, 0, 211], + deeppink: [255, 20, 147], + deepskyblue: [0, 191, 255], + dimgray: [105, 105, 105], + dimgrey: [105, 105, 105], + dodgerblue: [30, 144, 255], + firebrick: [178, 34, 34], + floralwhite: [255, 250, 240], + forestgreen: [34, 139, 34], + fuchsia: [255, 0, 255], + gainsboro: [220, 220, 220], + ghostwhite: [248, 248, 255], + gold: [255, 215, 0], + goldenrod: [218, 165, 32], + gray: [128, 128, 128], + green: [0, 128, 0], + greenyellow: [173, 255, 47], + grey: [128, 128, 128], + honeydew: [240, 255, 240], + hotpink: [255, 105, 180], + indianred: [205, 92, 92], + indigo: [75, 0, 130], + ivory: [255, 255, 240], + khaki: [240, 230, 140], + lavender: [230, 230, 250], + lavenderblush: [255, 240, 245], + lawngreen: [124, 252, 0], + lemonchiffon: [255, 250, 205], + lightblue: [173, 216, 230], + lightcoral: [240, 128, 128], + lightcyan: [224, 255, 255], + lightgoldenrodyellow: [250, 250, 210], + lightgray: [211, 211, 211], + lightgreen: [144, 238, 144], + lightgrey: [211, 211, 211], + lightpink: [255, 182, 193], + lightsalmon: [255, 160, 122], + lightseagreen: [32, 178, 170], + lightskyblue: [135, 206, 250], + lightslategray: [119, 136, 153], + lightslategrey: [119, 136, 153], + lightsteelblue: [176, 196, 222], + lightyellow: [255, 255, 224], + lime: [0, 255, 0], + limegreen: [50, 205, 50], + linen: [250, 240, 230], + magenta: [255, 0, 255], + maroon: [128, 0, 0], + mediumaquamarine: [102, 205, 170], + mediumblue: [0, 0, 205], + mediumorchid: [186, 85, 211], + mediumpurple: [147, 112, 219], + mediumseagreen: [60, 179, 113], + mediumslateblue: [123, 104, 238], + mediumspringgreen: [0, 250, 154], + mediumturquoise: [72, 209, 204], + mediumvioletred: [199, 21, 133], + midnightblue: [25, 25, 112], + mintcream: [245, 255, 250], + mistyrose: [255, 228, 225], + moccasin: [255, 228, 181], + navajowhite: [255, 222, 173], + navy: [0, 0, 128], + oldlace: [253, 245, 230], + olive: [128, 128, 0], + olivedrab: [107, 142, 35], + orange: [255, 165, 0], + orangered: [255, 69, 0], + orchid: [218, 112, 214], + palegoldenrod: [238, 232, 170], + palegreen: [152, 251, 152], + paleturquoise: [175, 238, 238], + palevioletred: [219, 112, 147], + papayawhip: [255, 239, 213], + peachpuff: [255, 218, 185], + peru: [205, 133, 63], + pink: [255, 192, 203], + plum: [221, 160, 221], + powderblue: [176, 224, 230], + purple: [128, 0, 128], + rebeccapurple: [102, 51, 153], + red: [255, 0, 0], + rosybrown: [188, 143, 143], + royalblue: [65, 105, 225], + saddlebrown: [139, 69, 19], + salmon: [250, 128, 114], + sandybrown: [244, 164, 96], + seagreen: [46, 139, 87], + seashell: [255, 245, 238], + sienna: [160, 82, 45], + silver: [192, 192, 192], + skyblue: [135, 206, 235], + slateblue: [106, 90, 205], + slategray: [112, 128, 144], + slategrey: [112, 128, 144], + snow: [255, 250, 250], + springgreen: [0, 255, 127], + steelblue: [70, 130, 180], + tan: [210, 180, 140], + teal: [0, 128, 128], + thistle: [216, 191, 216], + tomato: [255, 99, 71], + transparent: [0, 0, 0], + turquoise: [64, 224, 208], + violet: [238, 130, 238], + wheat: [245, 222, 179], + white: [255, 255, 255], + whitesmoke: [245, 245, 245], + yellow: [255, 255, 0], + yellowgreen: [154, 205, 50] + }; + + return names[name] && names[name].map(c => c / 2.55); +} + + +/* Convert a Hex to Red/Green/Blue +/* ========================================================================== */ + +function convertHtoRGB(hex) { + // #{3,4,6,8} + const [r, g, b, a, rr, gg, bb, aa] = (hex.match(hexColorMatch$1) || []).slice(1); + + if (rr !== undefined || r !== undefined) { + const red = rr !== undefined ? parseInt(rr, 16) : r !== undefined ? parseInt(r + r, 16) : 0; + const green = gg !== undefined ? parseInt(gg, 16) : g !== undefined ? parseInt(g + g, 16) : 0; + const blue = bb !== undefined ? parseInt(bb, 16) : b !== undefined ? parseInt(b + b, 16) : 0; + const alpha = aa !== undefined ? parseInt(aa, 16) : a !== undefined ? parseInt(a + a, 16) : 255; + + return [red, green, blue, alpha].map(c => c / 2.55); + } + + return undefined; +} + +const hexColorMatch$1 = /^#(?:([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?|([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?)$/i; + +class Color { + constructor(color) { + this.color = Object(Object(color).color || color); + + this.color.colorspace = this.color.colorspace + ? this.color.colorspace + : 'red' in color && 'green' in color && 'blue' in color + ? 'rgb' + : 'hue' in color && 'saturation' in color && 'lightness' in color + ? 'hsl' + : 'hue' in color && 'whiteness' in color && 'blackness' in color + ? 'hwb' + : 'unknown'; + + if (color.colorspace === 'rgb') { + this.color.hue = convertColors.rgb2hue(color.red, color.green, color.blue, color.hue || 0); + } + } + + alpha(alpha) { + const color = this.color; + + return alpha === undefined + ? color.alpha + : new Color(assign(color, { alpha })); + } + + blackness(blackness) { + const hwb = color2hwb(this.color); + + return blackness === undefined + ? hwb.blackness + : new Color(assign(hwb, { blackness })); + } + + blend(color, percentage, colorspace = 'rgb') { + const base = this.color; + + return new Color(blend(base, color, percentage, colorspace)); + } + + blenda(color, percentage, colorspace = 'rgb') { + const base = this.color; + + return new Color(blend(base, color, percentage, colorspace, true)); + } + + blue(blue) { + const rgb = color2rgb(this.color); + + return blue === undefined + ? rgb.blue + : new Color(assign(rgb, { blue })); + } + + contrast(percentage) { + const base = this.color; + + return new Color(contrast(base, percentage)); + } + + green(green) { + const rgb = color2rgb(this.color); + + return green === undefined + ? rgb.green + : new Color(assign(rgb, { green })); + } + + hue(hue) { + const hsl = color2hsl(this.color); + + return hue === undefined + ? hsl.hue + : new Color(assign(hsl, { hue })); + } + + lightness(lightness) { + const hsl = color2hsl(this.color); + + return lightness === undefined + ? hsl.lightness + : new Color(assign(hsl, { lightness })) + } + + red(red) { + const rgb = color2rgb(this.color); + + return red === undefined + ? rgb.red + : new Color(assign(rgb, { red })); + } + + rgb(red, green, blue) { + const rgb = color2rgb(this.color); + + return new Color(assign(rgb, { red, green, blue })); + } + + saturation(saturation) { + const hsl = color2hsl(this.color); + + return saturation === undefined + ? hsl.saturation + : new Color(assign(hsl, { saturation })); + } + + shade(percentage) { + const hwb = color2hwb(this.color); + const shade = { hue: 0, whiteness: 0, blackness: 100, colorspace: 'hwb' }; + const colorspace = 'rgb'; + + return percentage === undefined + ? hwb.blackness + : new Color(blend(hwb, shade, percentage, colorspace)); + } + + tint(percentage) { + const hwb = color2hwb(this.color); + const tint = { hue: 0, whiteness: 100, blackness: 0, colorspace: 'hwb' }; + const colorspace = 'rgb'; + + return percentage === undefined + ? hwb.blackness + : new Color(blend(hwb, tint, percentage, colorspace)); + } + + whiteness(whiteness) { + const hwb = color2hwb(this.color); + + return whiteness === undefined + ? hwb.whiteness + : new Color(assign(hwb, { whiteness })); + } + + toHSL() { + return color2hslString(this.color); + } + + toHWB() { + return color2hwbString(this.color); + } + + toLegacy() { + return color2legacyString(this.color); + } + + toRGB() { + return color2rgbString(this.color); + } + + toRGBLegacy() { + return color2rgbLegacyString(this.color); + } + + toString() { + return color2string(this.color); + } +} + +/* Blending +/* ========================================================================== */ + +function blend(base, color, percentage, colorspace, isBlendingAlpha) { + const addition = percentage / 100; + const subtraction = 1 - addition; + + if (colorspace === 'hsl') { + const { hue: h1, saturation: s1, lightness: l1, alpha: a1 } = color2hsl(base); + const { hue: h2, saturation: s2, lightness: l2, alpha: a2 } = color2hsl(color); + + const [hue, saturation, lightness, alpha] = [ + h1 * subtraction + h2 * addition, + s1 * subtraction + s2 * addition, + l1 * subtraction + l2 * addition, + isBlendingAlpha + ? a1 * subtraction + a2 * addition + : a1 + ]; + + return { hue, saturation, lightness, alpha, colorspace: 'hsl' }; + } else if (colorspace === 'hwb') { + const { hue: h1, whiteness: w1, blackness: b1, alpha: a1 } = color2hwb(base); + const { hue: h2, whiteness: w2, blackness: b2, alpha: a2 } = color2hwb(color); + + const [hue, whiteness, blackness, alpha] = [ + h1 * subtraction + h2 * addition, + w1 * subtraction + w2 * addition, + b1 * subtraction + b2 * addition, + isBlendingAlpha + ? a1 * subtraction + a2 * addition + : a1 + ]; + + return { hue, whiteness, blackness, alpha, colorspace: 'hwb' }; + } else { + const { red: r1, green: g1, blue: b1, alpha: a1 } = color2rgb(base); + const { red: r2, green: g2, blue: b2, alpha: a2 } = color2rgb(color); + + const [red, green, blue, alpha] = [ + r1 * subtraction + r2 * addition, + g1 * subtraction + g2 * addition, + b1 * subtraction + b2 * addition, + isBlendingAlpha + ? a1 * subtraction + a2 * addition + : a1 + ]; + + return { red, green, blue, alpha, colorspace: 'rgb' }; + } +} + +/* Assign channels to a new instance of a base color +/* ========================================================================== */ + +function assign(base, channels) { + const color = Object.assign({}, base); + + Object.keys(channels).forEach( + channel => { + // detect channel + const channelIsHue = channel === 'hue'; + const isRGB = !channelIsHue && blueGreenRedMatch.test(channel); + + // normalized value of the channel + const value = normalize(channels[channel], channel); + + // assign channel to new object + color[channel] = value; + + if (isRGB) { + // conditionally preserve the hue + color.hue = convertColors.rgb2hue(color.red, color.green, color.blue, base.hue || 0); + } + } + ); + + return color; +} + +function normalize(value, channel) { + // detect channel + const channelIsHue = channel === 'hue'; + + // value limitations + const min = 0; + const max = channelIsHue ? 360 : 100; + + const normalizedValue = Math.min(Math.max(channelIsHue + ? value % 360 + : value, min), max); + + return normalizedValue; +} + +/* Convert colors +/* ========================================================================== */ + +function color2rgb(color) { + const [ red, green, blue ] = color.colorspace === 'hsl' + ? convertColors.hsl2rgb(color.hue, color.saturation, color.lightness) + : color.colorspace === 'hwb' + ? convertColors.hwb2rgb(color.hue, color.whiteness, color.blackness) + : [ color.red, color.green, color.blue ]; + + return { red, green, blue, hue: color.hue, alpha: color.alpha, colorspace: 'rgb' }; +} + +function color2hsl(color) { + const [ hue, saturation, lightness ] = color.colorspace === 'rgb' + ? convertColors.rgb2hsl(color.red, color.green, color.blue, color.hue) + : color.colorspace === 'hwb' + ? convertColors.hwb2hsl(color.hue, color.whiteness, color.blackness) + : [ color.hue, color.saturation, color.lightness ]; + + return { hue, saturation, lightness, alpha: color.alpha, colorspace: 'hsl' }; +} + +function color2hwb(color) { + const [ hue, whiteness, blackness ] = color.colorspace === 'rgb' + ? convertColors.rgb2hwb(color.red, color.green, color.blue, color.hue) + : color.colorspace === 'hsl' + ? convertColors.hsl2hwb(color.hue, color.saturation, color.lightness) + : [ color.hue, color.whiteness, color.blackness ]; + + return { hue, whiteness, blackness, alpha: color.alpha, colorspace: 'hwb' }; +} + +/* Contrast functions +/* ========================================================================== */ + +function contrast(color, percentage) { + // https://drafts.csswg.org/css-color/#contrast-adjuster + const hwb = color2hwb(color); + const rgb = color2rgb(color); + + // compute the luminance of the color. + const luminance = rgb2luminance(rgb.red, rgb.green, rgb.blue); + + // the maximum-contrast color, if it is less than .5 + const maxContrastColor = luminance < 0.5 + // hwb(X, 100%, 0%), where X is the hue angle of the color + ? { hue: hwb.hue, whiteness: 100, blackness: 0, alpha: hwb.alpha, colorspace: 'hwb' } + // otherwise, hwb(X, 0%, 100%), where X is the hue angle of the color + : { hue: hwb.hue, whiteness: 0, blackness: 100, alpha: hwb.alpha, colorspace: 'hwb' }; + + // contrast ratio + const contrastRatio = colors2contrast(color, maxContrastColor); + + const minContrastColor = contrastRatio > 4.5 + // the color with the smallest contrast ratio with the base color that is greater than 4.5 + ? colors2contrastRatioColor(hwb, maxContrastColor) + // otherwise, the maximum-contrast color + : maxContrastColor; + + // color(maximum-contrast blend(minimum-contrast hwb))); + return blend(maxContrastColor, minContrastColor, percentage, 'hwb', false); +} + +function colors2contrast(color1, color2) { + // https://drafts.csswg.org/css-color/#contrast-ratio + const rgb1 = color2rgb(color1); + const rgb2 = color2rgb(color2); + const l1 = rgb2luminance(rgb1.red, rgb1.green, rgb1.blue); + const l2 = rgb2luminance(rgb2.red, rgb2.green, rgb2.blue); + + return l1 > l2 + // if l1 is the relative luminance of the lighter of the colors + ? (l1 + 0.05) / (l2 + 0.05) + // otherwise, if l2 is the relative luminance of the lighter of the colors + : (l2 + 0.05) / (l1 + 0.05); +} + +function rgb2luminance(red, green, blue) { + const [ redLuminance, greenLuminance, blueLuminance ] = [ + channel2luminance(red), + channel2luminance(green), + channel2luminance(blue) + ]; + + // https://drafts.csswg.org/css-color/#luminance + const luminance = 0.2126 * redLuminance + 0.7152 * greenLuminance + 0.0722 * blueLuminance; + + return luminance; +} + +function channel2luminance(value) { + // https://drafts.csswg.org/css-color/#luminance + const luminance = value <= 0.03928 ? value / 12.92 : Math.pow((value + 0.055) /1.055, 2.4); + + return luminance; +} + +// return the smallest contrast ratio from a color and a maximum contrast (credit: @thetalecrafter) +function colors2contrastRatioColor(hwb, maxHWB) { + const modifiedHWB = Object.assign({}, hwb); + + // values to be used for linear interpolations in HWB space + let minW = hwb.whiteness; + let minB = hwb.blackness; + let maxW = maxHWB.whiteness; + let maxB = maxHWB.blackness; + + // find the color with the smallest contrast ratio with the base color that is greater than 4.5 + while (Math.abs(minW - maxW) > 100 || Math.abs(minB - maxB) > 100) { + const midW = Math.round((maxW + minW) / 2); + const midB = Math.round((maxB + minB) / 2); + + modifiedHWB.whiteness = midW; + modifiedHWB.blackness = midB; + + if (colors2contrast(modifiedHWB, hwb) > 4.5) { + maxW = midW; + maxB = midB; + } else { + minW = midW; + minB = midB; + } + } + + return modifiedHWB; +} + +/* Match +/* ========================================================================== */ + +const blueGreenRedMatch = /^(blue|green|red)$/i; + +/* Stringifiers +/* ========================================================================== */ + +function color2string(color) { + return color.colorspace === 'hsl' + ? color2hslString(color) + : color.colorspace === 'hwb' + ? color2hwbString(color) + : color2rgbString(color); +} + +function color2hslString(color) { + const hsl = color2hsl(color); + const isOpaque = hsl.alpha === 100; + const hue = hsl.hue; + const saturation = Math.round(hsl.saturation * 10000000000) / 10000000000; + const lightness = Math.round(hsl.lightness * 10000000000) / 10000000000; + const alpha = Math.round(hsl.alpha * 10000000000) / 10000000000; + + return `hsl(${hue} ${saturation}% ${lightness}%${isOpaque + ? '' + : ` / ${alpha}%`})`; +} + +function color2hwbString(color) { + const hwb = color2hwb(color); + const isOpaque = hwb.alpha === 100; + const hue = hwb.hue; + const whiteness = Math.round(hwb.whiteness * 10000000000) / 10000000000; + const blackness = Math.round(hwb.blackness * 10000000000) / 10000000000; + const alpha = Math.round(hwb.alpha * 10000000000) / 10000000000; + + return `hwb(${hue} ${whiteness}% ${blackness}%${isOpaque + ? '' + : ` / ${alpha}%`})`; +} + +function color2rgbString(color) { + const rgb = color2rgb(color); + const isOpaque = rgb.alpha === 100; + const red = Math.round(rgb.red * 10000000000) / 10000000000; + const green = Math.round(rgb.green * 10000000000) / 10000000000; + const blue = Math.round(rgb.blue * 10000000000) / 10000000000; + const alpha = Math.round(rgb.alpha * 10000000000) / 10000000000; + + return `rgb(${red}% ${green}% ${blue}%${isOpaque + ? '' + : ` / ${alpha}%`})`; +} + +function color2legacyString(color) { + return color.colorspace === 'hsl' + ? color2hslLegacyString(color) + : color2rgbLegacyString(color); +} + +function color2rgbLegacyString(color) { + const rgb = color2rgb(color); + const isOpaque = rgb.alpha === 100; + const name = isOpaque ? 'rgb' : 'rgba'; + const red = Math.round(rgb.red * 255 / 100); + const green = Math.round(rgb.green * 255 / 100); + const blue = Math.round(rgb.blue * 255 / 100); + const alpha = Math.round(rgb.alpha / 100 * 10000000000) / 10000000000; + + return `${name}(${red}, ${green}, ${blue}${isOpaque + ? '' + : `, ${alpha}`})`; +} + +function color2hslLegacyString(color) { + const hsl = color2hsl(color); + const isOpaque = hsl.alpha === 100; + const name = isOpaque ? 'hsl' : 'hsla'; + const hue = hsl.hue; + const saturation = Math.round(hsl.saturation * 10000000000) / 10000000000; + const lightness = Math.round(hsl.lightness * 10000000000) / 10000000000; + const alpha = Math.round(hsl.alpha / 100 * 10000000000) / 10000000000; + + return `${name}(${hue}, ${saturation}%, ${lightness}%${isOpaque + ? '' + : `, ${alpha}`})`; +} + +function manageUnresolved(node, opts, word, message) { + if ('warn' === opts.unresolved) { + opts.decl.warn(opts.result, message, { word }); + } else if ('ignore' !== opts.unresolved) { + throw opts.decl.error(message, { word }); + } +} + +// tooling + +/* Transform AST +/* ========================================================================== */ + +function transformAST(node, opts) { + node.nodes.slice(0).forEach((child, index) => { + if (isColorModFunction(child)) { + // transform any variables within the color-mod() function + if (opts.transformVars) { + transformVariables(child, opts); + } + + // transform any color-mod() functions + const color = transformColorModFunction(child, opts); + + if (color) { + // update the color-mod() function with the transformed value + node.nodes.splice(index, 1, { + type: 'word', + value: opts.stringifier(color) + }); + } + } else if (child.nodes && Object(child.nodes).length) { + transformAST(child, opts); + } + }); +} + +/* Transform functions +/* ========================================================================== */ + +function transformVariables(node, opts) { + parser.walk(node.nodes, (child, index, nodes) => { + if (isVariable(child)) { + // get the custom property and fallback value from var() + const [prop, fallbackNode] = transformArgsByParams(child, [ + // , [ ]? + [transformWord, isComma, transformNode] + ]); + + // if the custom property is known + if (prop in opts.customProperties) { + let customPropertyValue = opts.customProperties[prop]; + + // follow custom properties referencing custom properties + if (looseVarMatch.test(parser.stringify(customPropertyValue))) { + const rootChildAST = JSON.parse(JSON.stringify({ nodes: customPropertyValue.nodes })); + + transformVariables(rootChildAST, opts); + + customPropertyValue = rootChildAST; + } + + // replace var() with the custom property value + if (customPropertyValue.nodes.length) { + nodes.splice(index, 0, ...JSON.parse(JSON.stringify(customPropertyValue.nodes))); + } + + nodes.splice(nodes.indexOf(child), 1); + } else if (fallbackNode && fallbackNode.nodes.length === 1 && fallbackNode.nodes[0].nodes.length) { + // otherwise, replace var() with the fallback value + transformVariables(fallbackNode, opts); + + nodes.splice(index, 1, ...fallbackNode.nodes[0].nodes[0]); + } + } + }); +} + +/* Transform functions +/* ========================================================================== */ + +function transformColor(node, opts) { + if (isRGBFunction(node)) { + return transformRGBFunction(node, opts); + } else if (isHSLFunction(node)) { + return transformHSLFunction(node, opts); + } else if (isHWBFunction(node)) { + return transformHWBFunction(node, opts); + } else if (isColorModFunction(node)) { + return transformColorModFunction(node, opts); + } else if (isHexColor(node)) { + return transformHexColor(node, opts); + } else if (isNamedColor(node)) { + return transformNamedColor(node, opts); + } else { + return manageUnresolved(node, opts, node.value, `Expected a color`); + } +} + +// return a transformed rgb/rgba color function +function transformRGBFunction(node, opts) { + const [red, green, blue, alpha = 100] = transformArgsByParams(node, [ + // [ , ]? + [transformPercentage, transformPercentage, transformPercentage, isSlash, transformAlpha], + // [ , ]? + [transformRGBNumber, transformRGBNumber, transformRGBNumber, isSlash, transformAlpha], + // , , [ , ]? + [transformPercentage, isComma, transformPercentage, isComma, transformPercentage, isComma, transformAlpha], + // , , [ , ]? + [transformRGBNumber, isComma, transformRGBNumber, isComma, transformRGBNumber, isComma, transformAlpha] + ]); + + if (red !== undefined) { + const color = new Color({ red, green, blue, alpha, colorspace: 'rgb' }); + + return color; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid rgb() function`); + } +} + +// return a transformed hsl/hsla color function +function transformHSLFunction(node, opts) { + const [hue, saturation, lightness, alpha = 100] = transformArgsByParams(node, [ + // [ / ]? + [transformHue, transformPercentage, transformPercentage, isSlash, transformAlpha], + // , , [ , ]? + [transformHue, isComma, transformPercentage, isComma, transformPercentage, isComma, transformAlpha] + ]); + + if (lightness !== undefined) { + const color = new Color({ hue, saturation, lightness, alpha, colorspace: 'hsl' }); + + return color; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid hsl() function`); + } +} + +// return a transformed hwb color function +function transformHWBFunction(node, opts) { + const [hue, whiteness, blackness, alpha = 100] = transformArgsByParams(node, [ + // [ / ]? + [transformHue, transformPercentage, transformPercentage, isSlash, transformAlpha] + ]); + + if (blackness !== undefined) { + const color = new Color({ hue, whiteness, blackness, alpha, colorspace: 'hwb' }); + + return color; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid hwb() function`); + } +} + +// return a transformed color-mod color function +function transformColorModFunction(node, opts) { + // [ | ] * + const [colorOrHueNode, ...adjusterNodes] = node.nodes || []; + + if (colorOrHueNode !== undefined) { + const color = isHue(colorOrHueNode) + ? new Color({ + hue: transformHue(colorOrHueNode, opts), + saturation: 100, + lightness: 50, + alpha: 100, + colorspace: 'hsl' + }) + : transformColor(colorOrHueNode, opts); + + if (color) { + const adjustedColor = transformColorByAdjusters(color, adjusterNodes, opts); + + return adjustedColor; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid color`); + } + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid color-mod() function`); + } +} + +// return a transformed hex color +function transformHexColor(node, opts) { + if (hexColorMatch.test(node.value)) { + // #{3,4,6,8} + const [red, green, blue, alpha] = convertHtoRGB(node.value); + + const color = new Color({ red, green, blue, alpha }); + + return color; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid hex color`); + } +} + +// return a transformed named-color +function transformNamedColor(node, opts) { + if (isNamedColor(node)) { + // + const [red, green, blue] = convertNtoRGB(node.value); + + const color = new Color({ red, green, blue, alpha: 100, colorspace: 'rgb' }); + + return color; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid named-color`); + } +} + +/* Transform functions +/* ========================================================================== */ + +// return a transformed color using adjustments +function transformColorByAdjusters(color, adjusterNodes, opts) { + const adjustedColor = adjusterNodes.filter((node) => { + return node.type !== 'space' && node.type !== 'comment'; + }).reduce((base, node) => { + if (isAlphaBlueGreenRedAdjuster(node)) { + return transformAlphaBlueGreenRedAdjuster(base, node, opts); + } else if (isRGBAdjuster(node)) { + return transformRGBAdjuster(base, node, opts); + } else if (isHueAdjuster(node)) { + return transformHueAdjuster(base, node, opts); + } else if (isBlacknessLightnessSaturationWhitenessAdjuster(node)) { + return transformBlacknessLightnessSaturationWhitenessAdjuster(base, node, opts); + } else if (isShadeTintAdjuster(node)) { + return transformShadeTintAdjuster(base, node, opts); + } else if (isBlendAdjuster(node)) { + return transformBlendAdjuster(base, node, node.value === 'blenda', opts); + } else if (isContrastAdjuster(node)) { + return transformContrastAdjuster(base, node, opts); + } else { + manageUnresolved(node, opts, node.value, `Expected a valid color adjuster`); + + return base; + } + }, color); + + return adjustedColor; +} + +// return a transformed color using a/alpha/blue/green/red adjustments +function transformAlphaBlueGreenRedAdjuster(base, node, opts) { + const [operatorOrValue, adjustment] = transformArgsByParams(node, alphaMatch.test(node.value) + // a/alpha adjustments + ? [ + // [ + | - ] + [transformMinusPlusOperator, transformAlpha], + // * + [transformTimesOperator, transformPercentage], + // + [transformAlpha] + ] + // blue/green/red adjustments + : [ + // [ + | - ] + [transformMinusPlusOperator, transformPercentage], + // [ + | - ] + [transformMinusPlusOperator, transformRGBNumber], + // * + [transformTimesOperator, transformPercentage], + // + [transformPercentage], + // + [transformRGBNumber] + ] + ); + + if (operatorOrValue !== undefined) { + // normalized channel name + const channel = node.value.toLowerCase().replace(alphaMatch, 'alpha'); + + const existingValue = base[channel](); + + const modifiedValue = adjustment !== undefined + ? operatorOrValue === '+' + ? existingValue + Number(adjustment) + : operatorOrValue === '-' + ? existingValue - Number(adjustment) + : operatorOrValue === '*' + ? existingValue * Number(adjustment) + : Number(adjustment) + : Number(operatorOrValue); + + const modifiedColor = base[channel](modifiedValue); + + return modifiedColor; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid modifier()`); + } +} + +// return a transformed color using an rgb adjustment +function transformRGBAdjuster(base, node, opts) { + const [arg1, arg2, arg3, arg4] = transformArgsByParams(node, [ + // [ + | - ] + [transformMinusPlusOperator, transformPercentage, transformPercentage, transformPercentage], + // [ + | - ] + [transformMinusPlusOperator, transformRGBNumber, transformRGBNumber, transformRGBNumber], + // [ + | - ] + [transformMinusPlusOperator, transformHexColor], + // [ * ] + [transformTimesOperator, transformPercentage] + ] + ); + + if (arg2 !== undefined && arg2.color) { + const modifiedColor = base.rgb( + arg1 === '+' + ? base.red() + arg2.red() + : base.red() - arg2.red(), + arg1 === '+' + ? base.green() + arg2.green() + : base.green() - arg2.green(), + arg1 === '+' + ? base.blue() + arg2.blue() + : base.blue() - arg2.blue() + ); + + return modifiedColor; + } else if (arg1 !== undefined && minusPlusMatch.test(arg1)) { + const modifiedColor = base.rgb( + arg1 === '+' + ? base.red() + arg2 + : base.red() - arg2, + arg1 === '+' + ? base.green() + arg3 + : base.green() - arg3, + arg1 === '+' + ? base.blue() + arg4 + : base.blue() - arg4 + ); + + return modifiedColor; + } else if (arg1 !== undefined && arg2 !== undefined) { + const modifiedColor = base.rgb( + base.red() * arg2, + base.green() * arg2, + base.blue() * arg2 + ); + + return modifiedColor; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid rgb() adjuster`); + } +} + +// return a transformed color using a blend/blenda adjustment +function transformBlendAdjuster(base, node, isAlphaBlend, opts) { + const [color, percentage, colorspace = 'rgb'] = transformArgsByParams(node, [ + [transformColor, transformPercentage, transformColorSpace] + ]); + + if (percentage !== undefined) { + const modifiedColor = isAlphaBlend + ? base.blenda(color.color, percentage, colorspace) + : base.blend(color.color, percentage, colorspace); + + return modifiedColor; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid blend() adjuster)`); + } +} + +// return a transformed color using a contrast adjustment +function transformContrastAdjuster(base, node, opts) { + const [percentage] = transformArgsByParams(node, [ + // + [transformPercentage] + ]); + + if (percentage !== undefined) { + const modifiedColor = base.contrast(percentage); + + return modifiedColor; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid contrast() adjuster)`); + } +} + +// return a transformed color using a hue adjustment +function transformHueAdjuster(base, node, opts) { + const [operatorOrHue, adjustment] = transformArgsByParams(node, [ + // [ + | - | * ] + [transformMinusPlusTimesOperator, transformHue], + // + [transformHue] + ]); + + if (operatorOrHue !== undefined) { + const existingHue = base.hue(); + + const modifiedValue = adjustment !== undefined + ? operatorOrHue === '+' + ? existingHue + Number(adjustment) + : operatorOrHue === '-' + ? existingHue - Number(adjustment) + : operatorOrHue === '*' + ? existingHue * Number(adjustment) + : Number(adjustment) + : Number(operatorOrHue); + + return base.hue(modifiedValue); + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid hue() function)`); + } +} + +// [ b | blackness | l | lightness | s | saturation | w | whiteness ]( [ + | - | * ]? ) +function transformBlacknessLightnessSaturationWhitenessAdjuster(base, node, opts) { + const channel = node.value.toLowerCase().replace(/^b$/, 'blackness').replace(/^l$/, 'lightness').replace(/^s$/, 'saturation').replace(/^w$/, 'whiteness'); + const [operatorOrValue, adjustment] = transformArgsByParams(node, [ + [transformMinusPlusTimesOperator, transformPercentage], + [transformPercentage] + ]); + + if (operatorOrValue !== undefined) { + const existingValue = base[channel](); + + const modifiedValue = adjustment !== undefined + ? operatorOrValue === '+' + ? existingValue + Number(adjustment) + : operatorOrValue === '-' + ? existingValue - Number(adjustment) + : operatorOrValue === '*' + ? existingValue * Number(adjustment) + : Number(adjustment) + : Number(operatorOrValue); + + return base[channel](modifiedValue); + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid ${channel}() function)`); + } +} + +// return a transformed color using shade/tint adjustments +function transformShadeTintAdjuster(base, node, opts) { + const channel = node.value.toLowerCase(); + const [percentage] = transformArgsByParams(node, [ + // [ shade | tint ]( ) + [transformPercentage] + ]); + + if (percentage !== undefined) { + const modifiedValue = Number(percentage); + + return base[channel](modifiedValue); + } else { + return manageUnresolved(node, opts, node.value, `Expected valid ${channel}() arguments`); + } +} + +/* Argument Transforms +/* ========================================================================== */ + +// return a transformed color space +function transformColorSpace(node, opts) { + if (isColorSpace(node)) { + // [ hsl | hwb | rgb ] + return node.value; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid color space)`); + } +} + +// return a transformed alpha value +function transformAlpha(node, opts) { + if (isNumber(node)) { + // + return Number(parser.unit(node.value).number) * 100; + } else if (isPercentage(node)) { + // + return transformPercentage(node, opts); + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid alpha value)`); + } +} + +// return a transformed rgb number +function transformRGBNumber(node, opts) { + if (isNumber(node)) { + // + return node.value / 2.55; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid RGB value)`); + } +} + +// return a transformed hue +function transformHue(node, opts) { + if (isHue(node)) { + // = | + const unit = parser.unit(node.value).unit.toLowerCase(); + + if (unit === 'grad') { + // if = (400 per circle) + return convertGtoD(Number(parser.unit(node.value).number)); + } else if (unit === 'rad') { + // if = (2π per circle) + return convertRtoD(Number(parser.unit(node.value).number)); + } else if (unit === 'turn') { + // if = (1 per circle) + return convertTtoD(Number(parser.unit(node.value).number)); + } else { + // if = [ | ] (360 per circle) + return convertDtoD(Number(parser.unit(node.value).number)); + } + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid hue`); + } +} + +// return a transformed percentage +function transformPercentage(node, opts) { + if (isPercentage(node)) { + // + return Number(parser.unit(node.value).number); + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid percentage`); + } +} + +// return a transformed minus-plus operator +function transformMinusPlusOperator(node, opts) { + if (isMinusPlusOperator(node)) { + // [ - | + ] + return node.value; + } else { + return manageUnresolved(node, opts, node.value, `Expected a plus or minus operator`); + } +} + +// return a transformed times operator +function transformTimesOperator(node, opts) { + if (isTimesOperator(node)) { + // [ * ] + return node.value; + } else { + return manageUnresolved(node, opts, node.value, `Expected a times operator`); + } +} + +// return a transformed minus-plus-times operator +function transformMinusPlusTimesOperator(node, opts) { + if (isMinusPlusTimesOperator(node)) { + // [ - | + | * ] + return node.value; + } else { + return manageUnresolved(node, opts, node.value, `Expected a plus, minus, or times operator`); + } +} + +/* Additional transforms +/* ========================================================================== */ + +function transformWord(node, opts) { + if (isWord(node)) { + return node.value; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid word`); + } +} + +function transformNode(node) { + return Object(node); +} + +/* Transform helper +/* ========================================================================== */ + +// return the first set of transformed arguments allowable by the parameters +function transformArgsByParams(node, params) { + const nodes = (node.nodes || []).filter((node) => { + return node.type !== 'space' && node.type !== 'comment'; + }); + const opts = { unresolved: 'ignore' }; + + return params.map((param) => { + return nodes.map((childNode, index) => { + return typeof param[index] === 'function' ? param[index](childNode, opts) : undefined + }).filter((child) => { + return typeof child !== 'boolean' + }) + }).filter((param) => { + return param.every((result) => { + return result !== undefined + }) + })[0] || []; +} + +/* Variable validators +/* ========================================================================== */ + +// return whether the node is a var function +function isVariable(node) { + // var() + return Object(node).type === 'function' && varMatch.test(node.value); +} + +/* Adjustment validators +/* ========================================================================== */ + +// return whether the node is an a/alpha/blue/green/red adjuster +function isAlphaBlueGreenRedAdjuster(node) { + // [ a(), alpha(), blue(), green(), red() ] + return Object(node).type === 'function' && alphaBlueGreenRedMatch.test(node.value); +} + +// return whether the node is an rgb adjuster +function isRGBAdjuster(node) { + return Object(node).type === 'function' && rgbMatch.test(node.value); +} + +// return whether the node is a hue adjuster +function isHueAdjuster(node) { + // [ h() | hue() ] + return Object(node).type === 'function' && hueMatch.test(node.value); +} + +// return whether the node is a blackness/lightness/saturation/whiteness adjuster +function isBlacknessLightnessSaturationWhitenessAdjuster(node) { + // [ b() | blackness() | l() | lightness() | s() | saturation() | w() | whiteness() ] + return Object(node).type === 'function' && blacknessLightnessSaturationWhitenessMatch.test(node.value); +} + +// return whether the node is a shade/tint adjuster +function isShadeTintAdjuster(node) { + // [ shade() | tint() ] + return Object(node).type === 'function' && shadeTintMatch.test(node.value); +} + +// return whether the node is a blend adjuster +function isBlendAdjuster(node) { + // [ blend(), blenda() ] + return Object(node).type === 'function' && blendMatch.test(node.value); +} + +// return whether the node is a contrast adjuster +function isContrastAdjuster(node) { + // [ contrast() ] + return Object(node).type === 'function' && contrastMatch.test(node.value); +} + +/* Color validators +/* ========================================================================== */ + +// return whether the node is an rgb/rgba color function +function isRGBFunction(node) { + // [ rgb(), rgba() ] + return Object(node).type === 'function' && rgbaMatch.test(node.value); +} + +// return whether the node is an hsl color function +function isHSLFunction(node) { + // [ hsl(), hsla() ] + return Object(node).type === 'function' && hslaMatch.test(node.value); +} + +// return whether the node is an hwb color function +function isHWBFunction(node) { + // hwb() + return Object(node).type === 'function' && hwbMatch.test(node.value); +} + +// return whether the node is a color-mod function +function isColorModFunction(node) { + // color-mod() + return Object(node).type === 'function' && colorModMatch.test(node.value); +} + +// return whether the node is a valid named-color +function isNamedColor(node) { + return Object(node).type === 'word' && Boolean(convertNtoRGB(node.value)); +} + +// return whether the node is a valid hex color +function isHexColor(node) { + // #{3,4,6,8} + return Object(node).type === 'word' && hexColorMatch.test(node.value); +} + +// return whether the node is a valid color space +function isColorSpace(node) { + // [ hsl | hwb | rgb ] + return Object(node).type === 'word' && colorSpaceMatch.test(node.value); +} + +/* Additional validators +/* ========================================================================== */ + +// return whether the hue value is valid +function isHue(node) { + if (Object(node).type !== 'word') { + return false; + } + + const parsedNumber = parser.unit(node.value); + return parsedNumber && hueUnitMatch.test(parsedNumber.unit); +} + +// return whether the comma is valid +function isComma(node) { + return Object(node).type === 'div' && node.value === ','; +} + +// return whether the slash operator is valid +function isSlash(node) { + return Object(node).type === 'div' && node.value === '/'; +} + +// return whether the number is valid +function isNumber(node) { + if (Object(node).type !== 'word') { + return false; + } + + const parsedNumber = parser.unit(node.value); + return parsedNumber && parsedNumber.unit === ''; +} + +// return whether the mind-plus operator is valid +function isMinusPlusOperator(node) { + return Object(node).type === 'word' && minusPlusMatch.test(node.value); +} + +// return whether the minus-plus-times operator is valid +function isMinusPlusTimesOperator(node) { + return Object(node).type === 'word' && minusPlusTimesMatch.test(node.value); +} + +// return whether the times operator is valid +function isTimesOperator(node) { + return Object(node).type === 'word' && timesMatch.test(node.value); +} + +// return whether the percentage is valid +function isPercentage(node) { + if (Object(node).type !== 'word') { + return false; + } + + const parsedNumber = parser.unit(node.value); + return parsedNumber && (parsedNumber.unit === '%' || parseFloat(parsedNumber.number) === 0); +} + +// return whether the node is a word +function isWord(node) { + // + return Object(node).type === 'word'; +} + +/* Matchers +/* ========================================================================== */ + +const alphaMatch = /^a(lpha)?$/i; +const alphaBlueGreenRedMatch = /^(a(lpha)?|blue|green|red)$/i; +const blacknessLightnessSaturationWhitenessMatch = /^(b(lackness)?|l(ightness)?|s(aturation)?|w(hiteness)?)$/i; +const blendMatch = /^blenda?$/i; +const colorModMatch = /^color-mod$/i; +const colorSpaceMatch = /^(hsl|hwb|rgb)$/i; +const contrastMatch = /^contrast$/i; +const hexColorMatch = /^#(?:([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?|([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?)$/i; +const hslaMatch = /^hsla?$/i; +const hueUnitMatch = /^(deg|grad|rad|turn)?$/i; +const hueMatch = /^h(ue)?$/i; +const hwbMatch = /^hwb$/i; +const minusPlusMatch = /^[+-]$/; +const minusPlusTimesMatch = /^[*+-]$/; +const rgbMatch = /^rgb$/i; +const rgbaMatch = /^rgba?$/i; +const shadeTintMatch = /^(shade|tint)$/i; +const varMatch = /^var$/i; +const looseVarMatch = /(^|[^\w-])var\(/i; +const timesMatch = /^[*]$/; + +module.exports = (opts = {}) => { + // how unresolved functions and arguments should be handled (default: "throw") + const unresolvedOpt = String(Object(opts).unresolved || 'throw').toLowerCase(); + + // how transformed colors will be produced in CSS + const stringifierOpt = Object(opts).stringifier || (color => color.toLegacy()); + + // sources to import custom selectors from + const importFrom = [].concat(Object(opts).importFrom || []); + + // whether var() within color-mod() should use Custom Properties or var() fallback + const transformVarsOpt = 'transformVars' in Object(opts) ? opts.transformVars : true; + + // promise any custom selectors are imported + const customPropertiesPromise = importCustomPropertiesFromSources(importFrom); + + return { + postcssPlugin: 'postcss-color-mod-function', + async Once (root, { result }) { + const customProperties = Object.assign( + await customPropertiesPromise, + getCustomProperties(root, { preserve: true }) + ); + + root.walkDecls(decl => { + const originalValue = decl.value; + + if (colorModFunctionMatch.test(originalValue)) { + const ast = parser(originalValue); + + transformAST(ast, { + unresolved: unresolvedOpt, + stringifier: stringifierOpt, + transformVars: transformVarsOpt, + decl, + result, + customProperties + }); + + const modifiedValue = parser.stringify(ast); + + if (originalValue !== modifiedValue) { + decl.value = modifiedValue; + } + } + }); + } + }; +}; + +module.exports.postcss = true; + +const colorModFunctionMatch = /(^|[^\w-])color-mod\(/i; +//# sourceMappingURL=index.cjs.js.map diff --git a/index.cjs.js.map b/index.cjs.js.map new file mode 100644 index 0000000..4c481b3 --- /dev/null +++ b/index.cjs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.cjs.js","sources":["lib/get-custom-properties.js","lib/import-from.js","lib/conversions.js","lib/color.js","lib/manage-unresolved.js","lib/transform.js","index.js"],"sourcesContent":["import valueParser from 'postcss-value-parser';\n\n// return custom selectors from the css root, conditionally removing them\nexport default function getCustomProperties(root, opts) {\n\t// initialize custom selectors\n\tconst customPropertiesFromHtmlElement = {};\n\tconst customPropertiesFromRootPsuedo = {};\n\n\t// for each html or :root rule\n\troot.nodes.slice().forEach(rule => {\n\t\tconst customPropertiesObject = isHtmlRule(rule)\n\t\t\t? customPropertiesFromHtmlElement\n\t\t: isRootRule(rule)\n\t\t\t? customPropertiesFromRootPsuedo\n\t\t: null;\n\n\t\t// for each custom property\n\t\tif (customPropertiesObject) {\n\t\t\trule.nodes.slice().forEach(decl => {\n\t\t\t\tif (isCustomDecl(decl)) {\n\t\t\t\t\tconst { prop } = decl;\n\n\t\t\t\t\t// write the parsed value to the custom property\n\t\t\t\t\tcustomPropertiesObject[prop] = valueParser(decl.value);\n\n\t\t\t\t\t// conditionally remove the custom property declaration\n\t\t\t\t\tif (!opts.preserve) {\n\t\t\t\t\t\tdecl.remove();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// conditionally remove the empty html or :root rule\n\t\t\tif (!opts.preserve && isEmptyParent(rule)) {\n\t\t\t\trule.remove();\n\t\t\t}\n\t\t}\n\t});\n\n\t// return all custom properties, preferring :root properties over html properties\n\treturn { ...customPropertiesFromHtmlElement, ...customPropertiesFromRootPsuedo };\n}\n\n// match html and :root rules\nconst htmlSelectorRegExp = /^html$/i;\nconst rootSelectorRegExp = /^:root$/i;\nconst customPropertyRegExp = /^--[A-z][\\w-]*$/;\n\n// whether the node is an html or :root rule\nconst isHtmlRule = node => node.type === 'rule' && htmlSelectorRegExp.test(node.selector) && Object(node.nodes).length;\nconst isRootRule = node => node.type === 'rule' && rootSelectorRegExp.test(node.selector) && Object(node.nodes).length;\n\n// whether the node is an custom property\nconst isCustomDecl = node => node.type === 'decl' && customPropertyRegExp.test(node.prop);\n\n// whether the node is a parent without children\nconst isEmptyParent = node => Object(node.nodes).length === 0;\n","import fs from 'fs';\nimport path from 'path';\nimport postcss from 'postcss';\nimport getCustomProperties from './get-custom-properties';\nimport valueParser from 'postcss-value-parser';\n\n/* Import Custom Properties from CSS AST\n/* ========================================================================== */\n\nfunction importCustomPropertiesFromCSSAST(root) {\n\treturn getCustomProperties(root, { preserve: true });\n}\n\n/* Import Custom Properties from CSS File\n/* ========================================================================== */\n\nasync function importCustomPropertiesFromCSSFile(from) {\n\tconst css = await readFile(from);\n\tconst root = postcss.parse(css, { from });\n\n\treturn importCustomPropertiesFromCSSAST(root);\n}\n\n/* Import Custom Properties from Object\n/* ========================================================================== */\n\nfunction importCustomPropertiesFromObject(object) {\n\tconst customProperties = Object.assign(\n\t\t{},\n\t\tObject(object).customProperties || Object(object)['custom-properties']\n\t);\n\n\tfor (const prop in customProperties) {\n\t\tcustomProperties[prop] = valueParser(customProperties[prop]);\n\t}\n\n\treturn customProperties;\n}\n\n/* Import Custom Properties from JSON file\n/* ========================================================================== */\n\nasync function importCustomPropertiesFromJSONFile(from) {\n\tconst object = await readJSON(from);\n\n\treturn importCustomPropertiesFromObject(object);\n}\n\n/* Import Custom Properties from JS file\n/* ========================================================================== */\n\nasync function importCustomPropertiesFromJSFile(from) {\n\tconst object = await import(from);\n\n\treturn importCustomPropertiesFromObject(('default' in object) ? object.default : object);\n}\n\n/* Import Custom Properties from Sources\n/* ========================================================================== */\n\nexport default function importCustomPropertiesFromSources(sources) {\n\treturn sources.map(source => {\n\t\tif (source instanceof Promise) {\n\t\t\treturn source;\n\t\t} else if (source instanceof Function) {\n\t\t\treturn source();\n\t\t}\n\n\t\t// read the source as an object\n\t\tconst opts = source === Object(source) ? source : { from: String(source) };\n\n\t\t// skip objects with Custom Properties\n\t\tif (opts.customProperties || opts['custom-properties']) {\n\t\t\treturn opts\n\t\t}\n\n\t\t// source pathname\n\t\tconst from = path.resolve(String(opts.from || ''));\n\n\t\t// type of file being read from\n\t\tconst type = (opts.type || path.extname(from).slice(1)).toLowerCase();\n\n\t\treturn { type, from };\n\t}).reduce(async (customProperties, source) => {\n\t\tconst { type, from } = await source;\n\n\t\tif (type === 'ast') {\n\t\t\treturn Object.assign(await customProperties, importCustomPropertiesFromCSSAST(from));\n\t\t}\n\n\t\tif (type === 'css') {\n\t\t\treturn Object.assign(await customProperties, await importCustomPropertiesFromCSSFile(from));\n\t\t}\n\n\t\tif (type === 'js') {\n\t\t\treturn Object.assign(await customProperties, await importCustomPropertiesFromJSFile(from));\n\t\t}\n\n\t\tif (type === 'json') {\n\t\t\treturn Object.assign(await customProperties, await importCustomPropertiesFromJSONFile(from));\n\t\t}\n\n\t\treturn Object.assign(await customProperties, await importCustomPropertiesFromObject(await source));\n\t}, {});\n}\n\n/* Helper utilities\n/* ========================================================================== */\n\nconst readFile = from => new Promise((resolve, reject) => {\n\tfs.readFile(from, 'utf8', (error, result) => {\n\t\tif (error) {\n\t\t\treject(error);\n\t\t} else {\n\t\t\tresolve(result);\n\t\t}\n\t});\n});\n\nconst readJSON = async from => JSON.parse(await readFile(from));\n","/* Convert Degree to Hue Degree\n/* ========================================================================== */\n\nexport function convertDtoD(deg) {\n\treturn deg % 360;\n}\n\n/* Convert Gradian to Hue Degree\n/* ========================================================================== */\n\nexport function convertGtoD(grad) {\n\treturn grad * 0.9 % 360;\n}\n\n/* Convert Radian to Hue Degree\n/* ========================================================================== */\n\nexport function convertRtoD(rad) {\n\treturn rad * 180 / Math.PI % 360;\n}\n\n/* Convert Turn to Hue Degree\n/* ========================================================================== */\n\nexport function convertTtoD(turn) {\n\treturn turn * 360 % 360;\n}\n\n/* Convert a Name to Red/Green/Blue\n/* ========================================================================== */\n\nexport function convertNtoRGB(name) {\n\tconst names = {\n\t\taliceblue: [240, 248, 255],\n\t\tantiquewhite: [250, 235, 215],\n\t\taqua: [0, 255, 255],\n\t\taquamarine: [127, 255, 212],\n\t\tazure: [240, 255, 255],\n\t\tbeige: [245, 245, 220],\n\t\tbisque: [255, 228, 196],\n\t\tblack: [0, 0, 0],\n\t\tblanchedalmond: [255, 235, 205],\n\t\tblue: [0, 0, 255],\n\t\tblueviolet: [138, 43, 226],\n\t\tbrown: [165, 42, 42],\n\t\tburlywood: [222, 184, 135],\n\t\tcadetblue: [95, 158, 160],\n\t\tchartreuse: [127, 255, 0],\n\t\tchocolate: [210, 105, 30],\n\t\tcoral: [255, 127, 80],\n\t\tcornflowerblue: [100, 149, 237],\n\t\tcornsilk: [255, 248, 220],\n\t\tcrimson: [220, 20, 60],\n\t\tcyan: [0, 255, 255],\n\t\tdarkblue: [0, 0, 139],\n\t\tdarkcyan: [0, 139, 139],\n\t\tdarkgoldenrod: [184, 134, 11],\n\t\tdarkgray: [169, 169, 169],\n\t\tdarkgreen: [0, 100, 0],\n\t\tdarkgrey: [169, 169, 169],\n\t\tdarkkhaki: [189, 183, 107],\n\t\tdarkmagenta: [139, 0, 139],\n\t\tdarkolivegreen: [85, 107, 47],\n\t\tdarkorange: [255, 140, 0],\n\t\tdarkorchid: [153, 50, 204],\n\t\tdarkred: [139, 0, 0],\n\t\tdarksalmon: [233, 150, 122],\n\t\tdarkseagreen: [143, 188, 143],\n\t\tdarkslateblue: [72, 61, 139],\n\t\tdarkslategray: [47, 79, 79],\n\t\tdarkslategrey: [47, 79, 79],\n\t\tdarkturquoise: [0, 206, 209],\n\t\tdarkviolet: [148, 0, 211],\n\t\tdeeppink: [255, 20, 147],\n\t\tdeepskyblue: [0, 191, 255],\n\t\tdimgray: [105, 105, 105],\n\t\tdimgrey: [105, 105, 105],\n\t\tdodgerblue: [30, 144, 255],\n\t\tfirebrick: [178, 34, 34],\n\t\tfloralwhite: [255, 250, 240],\n\t\tforestgreen: [34, 139, 34],\n\t\tfuchsia: [255, 0, 255],\n\t\tgainsboro: [220, 220, 220],\n\t\tghostwhite: [248, 248, 255],\n\t\tgold: [255, 215, 0],\n\t\tgoldenrod: [218, 165, 32],\n\t\tgray: [128, 128, 128],\n\t\tgreen: [0, 128, 0],\n\t\tgreenyellow: [173, 255, 47],\n\t\tgrey: [128, 128, 128],\n\t\thoneydew: [240, 255, 240],\n\t\thotpink: [255, 105, 180],\n\t\tindianred: [205, 92, 92],\n\t\tindigo: [75, 0, 130],\n\t\tivory: [255, 255, 240],\n\t\tkhaki: [240, 230, 140],\n\t\tlavender: [230, 230, 250],\n\t\tlavenderblush: [255, 240, 245],\n\t\tlawngreen: [124, 252, 0],\n\t\tlemonchiffon: [255, 250, 205],\n\t\tlightblue: [173, 216, 230],\n\t\tlightcoral: [240, 128, 128],\n\t\tlightcyan: [224, 255, 255],\n\t\tlightgoldenrodyellow: [250, 250, 210],\n\t\tlightgray: [211, 211, 211],\n\t\tlightgreen: [144, 238, 144],\n\t\tlightgrey: [211, 211, 211],\n\t\tlightpink: [255, 182, 193],\n\t\tlightsalmon: [255, 160, 122],\n\t\tlightseagreen: [32, 178, 170],\n\t\tlightskyblue: [135, 206, 250],\n\t\tlightslategray: [119, 136, 153],\n\t\tlightslategrey: [119, 136, 153],\n\t\tlightsteelblue: [176, 196, 222],\n\t\tlightyellow: [255, 255, 224],\n\t\tlime: [0, 255, 0],\n\t\tlimegreen: [50, 205, 50],\n\t\tlinen: [250, 240, 230],\n\t\tmagenta: [255, 0, 255],\n\t\tmaroon: [128, 0, 0],\n\t\tmediumaquamarine: [102, 205, 170],\n\t\tmediumblue: [0, 0, 205],\n\t\tmediumorchid: [186, 85, 211],\n\t\tmediumpurple: [147, 112, 219],\n\t\tmediumseagreen: [60, 179, 113],\n\t\tmediumslateblue: [123, 104, 238],\n\t\tmediumspringgreen: [0, 250, 154],\n\t\tmediumturquoise: [72, 209, 204],\n\t\tmediumvioletred: [199, 21, 133],\n\t\tmidnightblue: [25, 25, 112],\n\t\tmintcream: [245, 255, 250],\n\t\tmistyrose: [255, 228, 225],\n\t\tmoccasin: [255, 228, 181],\n\t\tnavajowhite: [255, 222, 173],\n\t\tnavy: [0, 0, 128],\n\t\toldlace: [253, 245, 230],\n\t\tolive: [128, 128, 0],\n\t\tolivedrab: [107, 142, 35],\n\t\torange: [255, 165, 0],\n\t\torangered: [255, 69, 0],\n\t\torchid: [218, 112, 214],\n\t\tpalegoldenrod: [238, 232, 170],\n\t\tpalegreen: [152, 251, 152],\n\t\tpaleturquoise: [175, 238, 238],\n\t\tpalevioletred: [219, 112, 147],\n\t\tpapayawhip: [255, 239, 213],\n\t\tpeachpuff: [255, 218, 185],\n\t\tperu: [205, 133, 63],\n\t\tpink: [255, 192, 203],\n\t\tplum: [221, 160, 221],\n\t\tpowderblue: [176, 224, 230],\n\t\tpurple: [128, 0, 128],\n\t\trebeccapurple: [102, 51, 153],\n\t\tred: [255, 0, 0],\n\t\trosybrown: [188, 143, 143],\n\t\troyalblue: [65, 105, 225],\n\t\tsaddlebrown: [139, 69, 19],\n\t\tsalmon: [250, 128, 114],\n\t\tsandybrown: [244, 164, 96],\n\t\tseagreen: [46, 139, 87],\n\t\tseashell: [255, 245, 238],\n\t\tsienna: [160, 82, 45],\n\t\tsilver: [192, 192, 192],\n\t\tskyblue: [135, 206, 235],\n\t\tslateblue: [106, 90, 205],\n\t\tslategray: [112, 128, 144],\n\t\tslategrey: [112, 128, 144],\n\t\tsnow: [255, 250, 250],\n\t\tspringgreen: [0, 255, 127],\n\t\tsteelblue: [70, 130, 180],\n\t\ttan: [210, 180, 140],\n\t\tteal: [0, 128, 128],\n\t\tthistle: [216, 191, 216],\n\t\ttomato: [255, 99, 71],\n\t\ttransparent: [0, 0, 0],\n\t\tturquoise: [64, 224, 208],\n\t\tviolet: [238, 130, 238],\n\t\twheat: [245, 222, 179],\n\t\twhite: [255, 255, 255],\n\t\twhitesmoke: [245, 245, 245],\n\t\tyellow: [255, 255, 0],\n\t\tyellowgreen: [154, 205, 50]\n\t};\n\n\treturn names[name] && names[name].map(c => c / 2.55);\n}\n\n\n/* Convert a Hex to Red/Green/Blue\n/* ========================================================================== */\n\nexport function convertHtoRGB(hex) {\n\t// #{3,4,6,8}\n\tconst [r, g, b, a, rr, gg, bb, aa] = (hex.match(hexColorMatch) || []).slice(1);\n\n\tif (rr !== undefined || r !== undefined) {\n\t\tconst red = rr !== undefined ? parseInt(rr, 16) : r !== undefined ? parseInt(r + r, 16) : 0;\n\t\tconst green = gg !== undefined ? parseInt(gg, 16) : g !== undefined ? parseInt(g + g, 16) : 0;\n\t\tconst blue = bb !== undefined ? parseInt(bb, 16) : b !== undefined ? parseInt(b + b, 16) : 0;\n\t\tconst alpha = aa !== undefined ? parseInt(aa, 16) : a !== undefined ? parseInt(a + a, 16) : 255;\n\n\t\treturn [red, green, blue, alpha].map(c => c / 2.55);\n\t}\n\n\treturn undefined;\n}\n\nconst hexColorMatch = /^#(?:([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?|([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?)$/i;\n","import { rgb2hsl, rgb2hwb, hsl2rgb, hsl2hwb, hwb2rgb, hwb2hsl, rgb2hue } from '@csstools/convert-colors';\n\nexport default class Color {\n\tconstructor(color) {\n\t\tthis.color = Object(Object(color).color || color);\n\n\t\tthis.color.colorspace = this.color.colorspace\n\t\t\t? this.color.colorspace\n\t\t: 'red' in color && 'green' in color && 'blue' in color\n\t\t\t? 'rgb'\n\t\t: 'hue' in color && 'saturation' in color && 'lightness' in color\n\t\t\t? 'hsl'\n\t\t: 'hue' in color && 'whiteness' in color && 'blackness' in color\n\t\t\t? 'hwb'\n\t\t: 'unknown';\n\n\t\tif (color.colorspace === 'rgb') {\n\t\t\tthis.color.hue = rgb2hue(color.red, color.green, color.blue, color.hue || 0);\n\t\t}\n\t}\n\n\talpha(alpha) {\n\t\tconst color = this.color;\n\n\t\treturn alpha === undefined\n\t\t\t? color.alpha\n\t\t: new Color(assign(color, { alpha }));\n\t}\n\n\tblackness(blackness) {\n\t\tconst hwb = color2hwb(this.color);\n\n\t\treturn blackness === undefined\n\t\t\t? hwb.blackness\n\t\t: new Color(assign(hwb, { blackness }));\n\t}\n\n\tblend(color, percentage, colorspace = 'rgb') {\n\t\tconst base = this.color;\n\n\t\treturn new Color(blend(base, color, percentage, colorspace));\n\t}\n\n\tblenda(color, percentage, colorspace = 'rgb') {\n\t\tconst base = this.color;\n\n\t\treturn new Color(blend(base, color, percentage, colorspace, true));\n\t}\n\n\tblue(blue) {\n\t\tconst rgb = color2rgb(this.color);\n\n\t\treturn blue === undefined\n\t\t\t? rgb.blue\n\t\t: new Color(assign(rgb, { blue }));\n\t}\n\n\tcontrast(percentage) {\n\t\tconst base = this.color;\n\n\t\treturn new Color(contrast(base, percentage));\n\t}\n\n\tgreen(green) {\n\t\tconst rgb = color2rgb(this.color);\n\n\t\treturn green === undefined\n\t\t\t? rgb.green\n\t\t: new Color(assign(rgb, { green }));\n\t}\n\n\thue(hue) {\n\t\tconst hsl = color2hsl(this.color);\n\n\t\treturn hue === undefined\n\t\t\t? hsl.hue\n\t\t: new Color(assign(hsl, { hue }));\n\t}\n\n\tlightness(lightness) {\n\t\tconst hsl = color2hsl(this.color);\n\n\t\treturn lightness === undefined\n\t\t\t? hsl.lightness\n\t\t: new Color(assign(hsl, { lightness }))\n\t}\n\n\tred(red) {\n\t\tconst rgb = color2rgb(this.color);\n\n\t\treturn red === undefined\n\t\t\t? rgb.red\n\t\t: new Color(assign(rgb, { red }));\n\t}\n\n\trgb(red, green, blue) {\n\t\tconst rgb = color2rgb(this.color);\n\n\t\treturn new Color(assign(rgb, { red, green, blue }));\n\t}\n\n\tsaturation(saturation) {\n\t\tconst hsl = color2hsl(this.color);\n\n\t\treturn saturation === undefined\n\t\t\t? hsl.saturation\n\t\t: new Color(assign(hsl, { saturation }));\n\t}\n\n\tshade(percentage) {\n\t\tconst hwb = color2hwb(this.color);\n\t\tconst shade = { hue: 0, whiteness: 0, blackness: 100, colorspace: 'hwb' };\n\t\tconst colorspace = 'rgb';\n\n\t\treturn percentage === undefined\n\t\t\t? hwb.blackness\n\t\t: new Color(blend(hwb, shade, percentage, colorspace));\n\t}\n\n\ttint(percentage) {\n\t\tconst hwb = color2hwb(this.color);\n\t\tconst tint = { hue: 0, whiteness: 100, blackness: 0, colorspace: 'hwb' };\n\t\tconst colorspace = 'rgb';\n\n\t\treturn percentage === undefined\n\t\t\t? hwb.blackness\n\t\t: new Color(blend(hwb, tint, percentage, colorspace));\n\t}\n\n\twhiteness(whiteness) {\n\t\tconst hwb = color2hwb(this.color);\n\n\t\treturn whiteness === undefined\n\t\t\t? hwb.whiteness\n\t\t: new Color(assign(hwb, { whiteness }));\n\t}\n\n\ttoHSL() {\n\t\treturn color2hslString(this.color);\n\t}\n\n\ttoHWB() {\n\t\treturn color2hwbString(this.color);\n\t}\n\n\ttoLegacy() {\n\t\treturn color2legacyString(this.color);\n\t}\n\n\ttoRGB() {\n\t\treturn color2rgbString(this.color);\n\t}\n\n\ttoRGBLegacy() {\n\t\treturn color2rgbLegacyString(this.color);\n\t}\n\n\ttoString() {\n\t\treturn color2string(this.color);\n\t}\n}\n\n/* Blending\n/* ========================================================================== */\n\nfunction blend(base, color, percentage, colorspace, isBlendingAlpha) {\n\tconst addition = percentage / 100;\n\tconst subtraction = 1 - addition;\n\n\tif (colorspace === 'hsl') {\n\t\tconst { hue: h1, saturation: s1, lightness: l1, alpha: a1 } = color2hsl(base);\n\t\tconst { hue: h2, saturation: s2, lightness: l2, alpha: a2 } = color2hsl(color);\n\n\t\tconst [hue, saturation, lightness, alpha] = [\n\t\t\th1 * subtraction + h2 * addition,\n\t\t\ts1 * subtraction + s2 * addition,\n\t\t\tl1 * subtraction + l2 * addition,\n\t\t\tisBlendingAlpha\n\t\t\t\t? a1 * subtraction + a2 * addition\n\t\t\t: a1\n\t\t];\n\n\t\treturn { hue, saturation, lightness, alpha, colorspace: 'hsl' };\n\t} else if (colorspace === 'hwb') {\n\t\tconst { hue: h1, whiteness: w1, blackness: b1, alpha: a1 } = color2hwb(base);\n\t\tconst { hue: h2, whiteness: w2, blackness: b2, alpha: a2 } = color2hwb(color);\n\n\t\tconst [hue, whiteness, blackness, alpha] = [\n\t\t\th1 * subtraction + h2 * addition,\n\t\t\tw1 * subtraction + w2 * addition,\n\t\t\tb1 * subtraction + b2 * addition,\n\t\t\tisBlendingAlpha\n\t\t\t\t? a1 * subtraction + a2 * addition\n\t\t\t: a1\n\t\t];\n\n\t\treturn { hue, whiteness, blackness, alpha, colorspace: 'hwb' };\n\t} else {\n\t\tconst { red: r1, green: g1, blue: b1, alpha: a1 } = color2rgb(base);\n\t\tconst { red: r2, green: g2, blue: b2, alpha: a2 } = color2rgb(color);\n\n\t\tconst [red, green, blue, alpha] = [\n\t\t\tr1 * subtraction + r2 * addition,\n\t\t\tg1 * subtraction + g2 * addition,\n\t\t\tb1 * subtraction + b2 * addition,\n\t\t\tisBlendingAlpha\n\t\t\t\t? a1 * subtraction + a2 * addition\n\t\t\t: a1\n\t\t];\n\n\t\treturn { red, green, blue, alpha, colorspace: 'rgb' };\n\t}\n}\n\n/* Assign channels to a new instance of a base color\n/* ========================================================================== */\n\nfunction assign(base, channels) {\n\tconst color = Object.assign({}, base);\n\n\tObject.keys(channels).forEach(\n\t\tchannel => {\n\t\t\t// detect channel\n\t\t\tconst channelIsHue = channel === 'hue';\n\t\t\tconst isRGB = !channelIsHue && blueGreenRedMatch.test(channel);\n\n\t\t\t// normalized value of the channel\n\t\t\tconst value = normalize(channels[channel], channel);\n\n\t\t\t// assign channel to new object\n\t\t\tcolor[channel] = value;\n\n\t\t\tif (isRGB) {\n\t\t\t\t// conditionally preserve the hue\n\t\t\t\tcolor.hue = rgb2hue(color.red, color.green, color.blue, base.hue || 0);\n\t\t\t}\n\t\t}\n\t);\n\n\treturn color;\n}\n\nfunction normalize(value, channel) {\n\t// detect channel\n\tconst channelIsHue = channel === 'hue';\n\n\t// value limitations\n\tconst min = 0;\n\tconst max = channelIsHue ? 360 : 100;\n\n\tconst normalizedValue = Math.min(Math.max(channelIsHue\n\t\t? value % 360\n\t: value, min), max);\n\n\treturn normalizedValue;\n}\n\n/* Convert colors\n/* ========================================================================== */\n\nfunction color2rgb(color) {\n\tconst [ red, green, blue ] = color.colorspace === 'hsl'\n\t\t? hsl2rgb(color.hue, color.saturation, color.lightness)\n\t: color.colorspace === 'hwb'\n\t\t? hwb2rgb(color.hue, color.whiteness, color.blackness)\n\t: [ color.red, color.green, color.blue ];\n\n\treturn { red, green, blue, hue: color.hue, alpha: color.alpha, colorspace: 'rgb' };\n}\n\nfunction color2hsl(color) {\n\tconst [ hue, saturation, lightness ] = color.colorspace === 'rgb'\n\t\t? rgb2hsl(color.red, color.green, color.blue, color.hue)\n\t: color.colorspace === 'hwb'\n\t\t? hwb2hsl(color.hue, color.whiteness, color.blackness)\n\t: [ color.hue, color.saturation, color.lightness ];\n\n\treturn { hue, saturation, lightness, alpha: color.alpha, colorspace: 'hsl' };\n}\n\nfunction color2hwb(color) {\n\tconst [ hue, whiteness, blackness ] = color.colorspace === 'rgb'\n\t\t? rgb2hwb(color.red, color.green, color.blue, color.hue)\n\t: color.colorspace === 'hsl'\n\t\t? hsl2hwb(color.hue, color.saturation, color.lightness)\n\t: [ color.hue, color.whiteness, color.blackness ];\n\n\treturn { hue, whiteness, blackness, alpha: color.alpha, colorspace: 'hwb' };\n}\n\n/* Contrast functions\n/* ========================================================================== */\n\nfunction contrast(color, percentage) {\n\t// https://drafts.csswg.org/css-color/#contrast-adjuster\n\tconst hwb = color2hwb(color);\n\tconst rgb = color2rgb(color);\n\n\t// compute the luminance of the color.\n\tconst luminance = rgb2luminance(rgb.red, rgb.green, rgb.blue);\n\n\t// the maximum-contrast color, if it is less than .5\n\tconst maxContrastColor = luminance < 0.5\n\t\t// hwb(X, 100%, 0%), where X is the hue angle of the color\n\t\t? { hue: hwb.hue, whiteness: 100, blackness: 0, alpha: hwb.alpha, colorspace: 'hwb' }\n\t// otherwise, hwb(X, 0%, 100%), where X is the hue angle of the color\n\t: { hue: hwb.hue, whiteness: 0, blackness: 100, alpha: hwb.alpha, colorspace: 'hwb' };\n\n\t// contrast ratio\n\tconst contrastRatio = colors2contrast(color, maxContrastColor);\n\n\tconst minContrastColor = contrastRatio > 4.5\n\t\t// the color with the smallest contrast ratio with the base color that is greater than 4.5\n\t\t? colors2contrastRatioColor(hwb, maxContrastColor)\n\t// otherwise, the maximum-contrast color\n\t: maxContrastColor;\n\n\t// color(maximum-contrast blend(minimum-contrast hwb)));\n\treturn blend(maxContrastColor, minContrastColor, percentage, 'hwb', false);\n}\n\nfunction colors2contrast(color1, color2) {\n\t// https://drafts.csswg.org/css-color/#contrast-ratio\n\tconst rgb1 = color2rgb(color1);\n\tconst rgb2 = color2rgb(color2);\n\tconst l1 = rgb2luminance(rgb1.red, rgb1.green, rgb1.blue);\n\tconst l2 = rgb2luminance(rgb2.red, rgb2.green, rgb2.blue);\n\n\treturn l1 > l2\n\t\t// if l1 is the relative luminance of the lighter of the colors\n\t\t? (l1 + 0.05) / (l2 + 0.05)\n\t// otherwise, if l2 is the relative luminance of the lighter of the colors\n\t: (l2 + 0.05) / (l1 + 0.05);\n}\n\nfunction rgb2luminance(red, green, blue) {\n\tconst [ redLuminance, greenLuminance, blueLuminance ] = [\n\t\tchannel2luminance(red),\n\t\tchannel2luminance(green),\n\t\tchannel2luminance(blue)\n\t];\n\n\t// https://drafts.csswg.org/css-color/#luminance\n\tconst luminance = 0.2126 * redLuminance + 0.7152 * greenLuminance + 0.0722 * blueLuminance;\n\n\treturn luminance;\n}\n\nfunction channel2luminance(value) {\n\t// https://drafts.csswg.org/css-color/#luminance\n\tconst luminance = value <= 0.03928 ? value / 12.92 : Math.pow((value + 0.055) /1.055, 2.4);\n\n\treturn luminance;\n}\n\n// return the smallest contrast ratio from a color and a maximum contrast (credit: @thetalecrafter)\nfunction colors2contrastRatioColor(hwb, maxHWB) {\n\tconst modifiedHWB = Object.assign({}, hwb);\n\n\t// values to be used for linear interpolations in HWB space\n\tlet minW = hwb.whiteness;\n\tlet minB = hwb.blackness;\n\tlet maxW = maxHWB.whiteness;\n\tlet maxB = maxHWB.blackness;\n\n\t// find the color with the smallest contrast ratio with the base color that is greater than 4.5\n\twhile (Math.abs(minW - maxW) > 100 || Math.abs(minB - maxB) > 100) {\n\t\tconst midW = Math.round((maxW + minW) / 2);\n\t\tconst midB = Math.round((maxB + minB) / 2);\n\n\t\tmodifiedHWB.whiteness = midW;\n\t\tmodifiedHWB.blackness = midB;\n\n\t\tif (colors2contrast(modifiedHWB, hwb) > 4.5) {\n\t\t\tmaxW = midW;\n\t\t\tmaxB = midB;\n\t\t} else {\n\t\t\tminW = midW;\n\t\t\tminB = midB;\n\t\t}\n\t}\n\n\treturn modifiedHWB;\n}\n\n/* Match\n/* ========================================================================== */\n\nconst blueGreenRedMatch = /^(blue|green|red)$/i;\n\n/* Stringifiers\n/* ========================================================================== */\n\nfunction color2string(color) {\n\treturn color.colorspace === 'hsl'\n\t\t? color2hslString(color)\n\t: color.colorspace === 'hwb'\n\t\t? color2hwbString(color)\n\t: color2rgbString(color);\n}\n\nfunction color2hslString(color) {\n\tconst hsl = color2hsl(color);\n\tconst isOpaque = hsl.alpha === 100;\n\tconst hue = hsl.hue;\n\tconst saturation = Math.round(hsl.saturation * 10000000000) / 10000000000;\n\tconst lightness = Math.round(hsl.lightness * 10000000000) / 10000000000;\n\tconst alpha = Math.round(hsl.alpha * 10000000000) / 10000000000;\n\n\treturn `hsl(${hue} ${saturation}% ${lightness}%${isOpaque\n\t\t? ''\n\t: ` / ${alpha}%`})`;\n}\n\nfunction color2hwbString(color) {\n\tconst hwb = color2hwb(color);\n\tconst isOpaque = hwb.alpha === 100;\n\tconst hue = hwb.hue;\n\tconst whiteness = Math.round(hwb.whiteness * 10000000000) / 10000000000;\n\tconst blackness = Math.round(hwb.blackness * 10000000000) / 10000000000;\n\tconst alpha = Math.round(hwb.alpha * 10000000000) / 10000000000;\n\n\treturn `hwb(${hue} ${whiteness}% ${blackness}%${isOpaque\n\t\t? ''\n\t: ` / ${alpha}%`})`;\n}\n\nfunction color2rgbString(color) {\n\tconst rgb = color2rgb(color);\n\tconst isOpaque = rgb.alpha === 100;\n\tconst red = Math.round(rgb.red * 10000000000) / 10000000000;\n\tconst green = Math.round(rgb.green * 10000000000) / 10000000000;\n\tconst blue = Math.round(rgb.blue * 10000000000) / 10000000000;\n\tconst alpha = Math.round(rgb.alpha * 10000000000) / 10000000000;\n\n\treturn `rgb(${red}% ${green}% ${blue}%${isOpaque\n\t\t? ''\n\t: ` / ${alpha}%`})`;\n}\n\nfunction color2legacyString(color) {\n\treturn color.colorspace === 'hsl'\n\t\t? color2hslLegacyString(color)\n\t: color2rgbLegacyString(color);\n}\n\nfunction color2rgbLegacyString(color) {\n\tconst rgb = color2rgb(color);\n\tconst isOpaque = rgb.alpha === 100;\n\tconst name = isOpaque ? 'rgb' : 'rgba';\n\tconst red = Math.round(rgb.red * 255 / 100);\n\tconst green = Math.round(rgb.green * 255 / 100);\n\tconst blue = Math.round(rgb.blue * 255 / 100);\n\tconst alpha = Math.round(rgb.alpha / 100 * 10000000000) / 10000000000;\n\n\treturn `${name}(${red}, ${green}, ${blue}${isOpaque\n\t\t? ''\n\t: `, ${alpha}`})`;\n}\n\nfunction color2hslLegacyString(color) {\n\tconst hsl = color2hsl(color);\n\tconst isOpaque = hsl.alpha === 100;\n\tconst name = isOpaque ? 'hsl' : 'hsla';\n\tconst hue = hsl.hue;\n\tconst saturation = Math.round(hsl.saturation * 10000000000) / 10000000000;\n\tconst lightness = Math.round(hsl.lightness * 10000000000) / 10000000000;\n\tconst alpha = Math.round(hsl.alpha / 100 * 10000000000) / 10000000000;\n\n\treturn `${name}(${hue}, ${saturation}%, ${lightness}%${isOpaque\n\t\t? ''\n\t: `, ${alpha}`})`;\n}\n","export default function manageUnresolved(node, opts, word, message) {\n\tif ('warn' === opts.unresolved) {\n\t\topts.decl.warn(opts.result, message, { word });\n\t} else if ('ignore' !== opts.unresolved) {\n\t\tthrow opts.decl.error(message, { word });\n\t}\n}\n","// tooling\nimport { convertDtoD, convertGtoD, convertRtoD, convertTtoD, convertNtoRGB, convertHtoRGB } from './conversions';\nimport Color from './color';\nimport manageUnresolved from './manage-unresolved';\nimport parser from 'postcss-value-parser';\n\n/* Transform AST\n/* ========================================================================== */\n\nexport default function transformAST(node, opts) {\n\tnode.nodes.slice(0).forEach((child, index) => {\n\t\tif (isColorModFunction(child)) {\n\t\t\t// transform any variables within the color-mod() function\n\t\t\tif (opts.transformVars) {\n\t\t\t\ttransformVariables(child, opts);\n\t\t\t}\n\n\t\t\t// transform any color-mod() functions\n\t\t\tconst color = transformColorModFunction(child, opts);\n\n\t\t\tif (color) {\n\t\t\t\t// update the color-mod() function with the transformed value\n\t\t\t\tnode.nodes.splice(index, 1, {\n\t\t\t\t\ttype: 'word',\n\t\t\t\t\tvalue: opts.stringifier(color)\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (child.nodes && Object(child.nodes).length) {\n\t\t\ttransformAST(child, opts);\n\t\t}\n\t});\n}\n\n/* Transform functions\n/* ========================================================================== */\n\nfunction transformVariables(node, opts) {\n\tparser.walk(node.nodes, (child, index, nodes) => {\n\t\tif (isVariable(child)) {\n\t\t\t// get the custom property and fallback value from var()\n\t\t\tconst [prop, fallbackNode] = transformArgsByParams(child, [\n\t\t\t\t// , [ ]?\n\t\t\t\t[transformWord, isComma, transformNode]\n\t\t\t]);\n\n\t\t\t// if the custom property is known\n\t\t\tif (prop in opts.customProperties) {\n\t\t\t\tlet customPropertyValue = opts.customProperties[prop];\n\n\t\t\t\t// follow custom properties referencing custom properties\n\t\t\t\tif (looseVarMatch.test(parser.stringify(customPropertyValue))) {\n\t\t\t\t\tconst rootChildAST = JSON.parse(JSON.stringify({ nodes: customPropertyValue.nodes }));\n\n\t\t\t\t\ttransformVariables(rootChildAST, opts);\n\n\t\t\t\t\tcustomPropertyValue = rootChildAST;\n\t\t\t\t}\n\n\t\t\t\t// replace var() with the custom property value\n\t\t\t\tif (customPropertyValue.nodes.length) {\n\t\t\t\t\tnodes.splice(index, 0, ...JSON.parse(JSON.stringify(customPropertyValue.nodes)));\n\t\t\t\t}\n\n\t\t\t\tnodes.splice(nodes.indexOf(child), 1);\n\t\t\t} else if (fallbackNode && fallbackNode.nodes.length === 1 && fallbackNode.nodes[0].nodes.length) {\n\t\t\t\t// otherwise, replace var() with the fallback value\n\t\t\t\ttransformVariables(fallbackNode, opts);\n\n\t\t\t\tnodes.splice(index, 1, ...fallbackNode.nodes[0].nodes[0]);\n\t\t\t}\n\t\t}\n\t});\n}\n\n/* Transform functions\n/* ========================================================================== */\n\nfunction transformColor(node, opts) {\n\tif (isRGBFunction(node)) {\n\t\treturn transformRGBFunction(node, opts);\n\t} else if (isHSLFunction(node)) {\n\t\treturn transformHSLFunction(node, opts);\n\t} else if (isHWBFunction(node)) {\n\t\treturn transformHWBFunction(node, opts);\n\t} else if (isColorModFunction(node)) {\n\t\treturn transformColorModFunction(node, opts);\n\t} else if (isHexColor(node)) {\n\t\treturn transformHexColor(node, opts);\n\t} else if (isNamedColor(node)) {\n\t\treturn transformNamedColor(node, opts);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a color`);\n\t}\n}\n\n// return a transformed rgb/rgba color function\nfunction transformRGBFunction(node, opts) {\n\tconst [red, green, blue, alpha = 100] = transformArgsByParams(node, [\n\t\t// [ , ]?\n\t\t[transformPercentage, transformPercentage, transformPercentage, isSlash, transformAlpha],\n\t\t// [ , ]?\n\t\t[transformRGBNumber, transformRGBNumber, transformRGBNumber, isSlash, transformAlpha],\n\t\t// , , [ , ]?\n\t\t[transformPercentage, isComma, transformPercentage, isComma, transformPercentage, isComma, transformAlpha],\n\t\t// , , [ , ]?\n\t\t[transformRGBNumber, isComma, transformRGBNumber, isComma, transformRGBNumber, isComma, transformAlpha]\n\t]);\n\n\tif (red !== undefined) {\n\t\tconst color = new Color({ red, green, blue, alpha, colorspace: 'rgb' });\n\n\t\treturn color;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid rgb() function`);\n\t}\n}\n\n// return a transformed hsl/hsla color function\nfunction transformHSLFunction(node, opts) {\n\tconst [hue, saturation, lightness, alpha = 100] = transformArgsByParams(node, [\n\t\t// [ / ]?\n\t\t[transformHue, transformPercentage, transformPercentage, isSlash, transformAlpha],\n\t\t// , , [ , ]?\n\t\t[transformHue, isComma, transformPercentage, isComma, transformPercentage, isComma, transformAlpha]\n\t]);\n\n\tif (lightness !== undefined) {\n\t\tconst color = new Color({ hue, saturation, lightness, alpha, colorspace: 'hsl' });\n\n\t\treturn color;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid hsl() function`);\n\t}\n}\n\n// return a transformed hwb color function\nfunction transformHWBFunction(node, opts) {\n\tconst [hue, whiteness, blackness, alpha = 100] = transformArgsByParams(node, [\n\t\t// [ / ]?\n\t\t[transformHue, transformPercentage, transformPercentage, isSlash, transformAlpha]\n\t]);\n\n\tif (blackness !== undefined) {\n\t\tconst color = new Color({ hue, whiteness, blackness, alpha, colorspace: 'hwb' });\n\n\t\treturn color;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid hwb() function`);\n\t}\n}\n\n// return a transformed color-mod color function\nfunction transformColorModFunction(node, opts) {\n\t// [ | ] *\n\tconst [colorOrHueNode, ...adjusterNodes] = node.nodes || [];\n\n\tif (colorOrHueNode !== undefined) {\n\t\tconst color = isHue(colorOrHueNode)\n\t\t\t? new Color({\n\t\t\t\thue: transformHue(colorOrHueNode, opts),\n\t\t\t\tsaturation: 100,\n\t\t\t\tlightness: 50,\n\t\t\t\talpha: 100,\n\t\t\t\tcolorspace: 'hsl'\n\t\t\t})\n\t\t: transformColor(colorOrHueNode, opts);\n\n\t\tif (color) {\n\t\t\tconst adjustedColor = transformColorByAdjusters(color, adjusterNodes, opts);\n\n\t\t\treturn adjustedColor;\n\t\t} else {\n\t\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid color`);\n\t\t}\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid color-mod() function`);\n\t}\n}\n\n// return a transformed hex color\nfunction transformHexColor(node, opts) {\n\tif (hexColorMatch.test(node.value)) {\n\t\t// #{3,4,6,8}\n\t\tconst [red, green, blue, alpha] = convertHtoRGB(node.value);\n\n\t\tconst color = new Color({ red, green, blue, alpha });\n\n\t\treturn color;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid hex color`);\n\t}\n}\n\n// return a transformed named-color\nfunction transformNamedColor(node, opts) {\n\tif (isNamedColor(node)) {\n\t\t// \n\t\tconst [red, green, blue] = convertNtoRGB(node.value);\n\n\t\tconst color = new Color({ red, green, blue, alpha: 100, colorspace: 'rgb' });\n\n\t\treturn color;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid named-color`);\n\t}\n}\n\n/* Transform functions\n/* ========================================================================== */\n\n// return a transformed color using adjustments\nfunction transformColorByAdjusters(color, adjusterNodes, opts) {\n\tconst adjustedColor = adjusterNodes.filter((node) => {\n\t\treturn node.type !== 'space' && node.type !== 'comment';\n\t}).reduce((base, node) => {\n\t\tif (isAlphaBlueGreenRedAdjuster(node)) {\n\t\t\treturn transformAlphaBlueGreenRedAdjuster(base, node, opts);\n\t\t} else if (isRGBAdjuster(node)) {\n\t\t\treturn transformRGBAdjuster(base, node, opts);\n\t\t} else if (isHueAdjuster(node)) {\n\t\t\treturn transformHueAdjuster(base, node, opts);\n\t\t} else if (isBlacknessLightnessSaturationWhitenessAdjuster(node)) {\n\t\t\treturn transformBlacknessLightnessSaturationWhitenessAdjuster(base, node, opts);\n\t\t} else if (isShadeTintAdjuster(node)) {\n\t\t\treturn transformShadeTintAdjuster(base, node, opts);\n\t\t} else if (isBlendAdjuster(node)) {\n\t\t\treturn transformBlendAdjuster(base, node, node.value === 'blenda', opts);\n\t\t} else if (isContrastAdjuster(node)) {\n\t\t\treturn transformContrastAdjuster(base, node, opts);\n\t\t} else {\n\t\t\tmanageUnresolved(node, opts, node.value, `Expected a valid color adjuster`);\n\n\t\t\treturn base;\n\t\t}\n\t}, color);\n\n\treturn adjustedColor;\n}\n\n// return a transformed color using a/alpha/blue/green/red adjustments\nfunction transformAlphaBlueGreenRedAdjuster(base, node, opts) {\n\tconst [operatorOrValue, adjustment] = transformArgsByParams(node, alphaMatch.test(node.value)\n\t\t\t// a/alpha adjustments\n\t\t\t? [\n\t\t\t\t// [ + | - ] \n\t\t\t\t[transformMinusPlusOperator, transformAlpha],\n\t\t\t\t// * \n\t\t\t\t[transformTimesOperator, transformPercentage],\n\t\t\t\t// \n\t\t\t\t[transformAlpha]\n\t\t\t]\n\t\t// blue/green/red adjustments\n\t\t: [\n\t\t\t// [ + | - ] \n\t\t\t[transformMinusPlusOperator, transformPercentage],\n\t\t\t// [ + | - ] \n\t\t\t[transformMinusPlusOperator, transformRGBNumber],\n\t\t\t// * \n\t\t\t[transformTimesOperator, transformPercentage],\n\t\t\t// \n\t\t\t[transformPercentage],\n\t\t\t// \n\t\t\t[transformRGBNumber]\n\t\t]\n\t);\n\n\tif (operatorOrValue !== undefined) {\n\t\t// normalized channel name\n\t\tconst channel = node.value.toLowerCase().replace(alphaMatch, 'alpha');\n\n\t\tconst existingValue = base[channel]();\n\n\t\tconst modifiedValue = adjustment !== undefined\n\t\t\t? operatorOrValue === '+'\n\t\t\t\t? existingValue + Number(adjustment)\n\t\t\t: operatorOrValue === '-'\n\t\t\t\t? existingValue - Number(adjustment)\n\t\t\t: operatorOrValue === '*'\n\t\t\t\t? existingValue * Number(adjustment)\n\t\t\t: Number(adjustment)\n\t\t: Number(operatorOrValue);\n\n\t\tconst modifiedColor = base[channel](modifiedValue);\n\n\t\treturn modifiedColor;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid modifier()`);\n\t}\n}\n\n// return a transformed color using an rgb adjustment\nfunction transformRGBAdjuster(base, node, opts) {\n\tconst [arg1, arg2, arg3, arg4] = transformArgsByParams(node, [\n\t\t\t// [ + | - ] \n\t\t\t[transformMinusPlusOperator, transformPercentage, transformPercentage, transformPercentage],\n\t\t\t// [ + | - ] \n\t\t\t[transformMinusPlusOperator, transformRGBNumber, transformRGBNumber, transformRGBNumber],\n\t\t\t// [ + | - ] \n\t\t\t[transformMinusPlusOperator, transformHexColor],\n\t\t\t// [ * ] \n\t\t\t[transformTimesOperator, transformPercentage]\n\t\t]\n\t);\n\n\tif (arg2 !== undefined && arg2.color) {\n\t\tconst modifiedColor = base.rgb(\n\t\t\targ1 === '+'\n\t\t\t\t? base.red() + arg2.red()\n\t\t\t: base.red() - arg2.red(),\n\t\t\targ1 === '+'\n\t\t\t\t? base.green() + arg2.green()\n\t\t\t: base.green() - arg2.green(),\n\t\t\targ1 === '+'\n\t\t\t\t? base.blue() + arg2.blue()\n\t\t\t: base.blue() - arg2.blue()\n\t\t);\n\n\t\treturn modifiedColor;\n\t} else if (arg1 !== undefined && minusPlusMatch.test(arg1)) {\n\t\tconst modifiedColor = base.rgb(\n\t\t\targ1 === '+'\n\t\t\t\t? base.red() + arg2\n\t\t\t: base.red() - arg2,\n\t\t\targ1 === '+'\n\t\t\t\t? base.green() + arg3\n\t\t\t: base.green() - arg3,\n\t\t\targ1 === '+'\n\t\t\t\t? base.blue() + arg4\n\t\t\t: base.blue() - arg4\n\t\t);\n\n\t\treturn modifiedColor;\n\t} else if (arg1 !== undefined && arg2 !== undefined) {\n\t\tconst modifiedColor = base.rgb(\n\t\t\tbase.red() * arg2,\n\t\t\tbase.green() * arg2,\n\t\t\tbase.blue() * arg2\n\t\t);\n\n\t\treturn modifiedColor;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid rgb() adjuster`);\n\t}\n}\n\n// return a transformed color using a blend/blenda adjustment\nfunction transformBlendAdjuster(base, node, isAlphaBlend, opts) {\n\tconst [color, percentage, colorspace = 'rgb'] = transformArgsByParams(node, [\n\t\t[transformColor, transformPercentage, transformColorSpace]\n\t]);\n\n\tif (percentage !== undefined) {\n\t\tconst modifiedColor = isAlphaBlend\n\t\t\t? base.blenda(color.color, percentage, colorspace)\n\t\t: base.blend(color.color, percentage, colorspace);\n\n\t\treturn modifiedColor;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid blend() adjuster)`);\n\t}\n}\n\n// return a transformed color using a contrast adjustment\nfunction transformContrastAdjuster(base, node, opts) {\n\tconst [percentage] = transformArgsByParams(node, [\n\t\t// \n\t\t[transformPercentage]\n\t]);\n\n\tif (percentage !== undefined) {\n\t\tconst modifiedColor = base.contrast(percentage);\n\n\t\treturn modifiedColor;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid contrast() adjuster)`);\n\t}\n}\n\n// return a transformed color using a hue adjustment\nfunction transformHueAdjuster(base, node, opts) {\n\tconst [operatorOrHue, adjustment] = transformArgsByParams(node, [\n\t\t// [ + | - | * ] \n\t\t[transformMinusPlusTimesOperator, transformHue],\n\t\t// \n\t\t[transformHue]\n\t]);\n\n\tif (operatorOrHue !== undefined) {\n\t\tconst existingHue = base.hue();\n\n\t\tconst modifiedValue = adjustment !== undefined\n\t\t\t? operatorOrHue === '+'\n\t\t\t\t? existingHue + Number(adjustment)\n\t\t\t: operatorOrHue === '-'\n\t\t\t\t? existingHue - Number(adjustment)\n\t\t\t: operatorOrHue === '*'\n\t\t\t\t? existingHue * Number(adjustment)\n\t\t\t: Number(adjustment)\n\t\t: Number(operatorOrHue);\n\n\t\treturn base.hue(modifiedValue);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid hue() function)`);\n\t}\n}\n\n// [ b | blackness | l | lightness | s | saturation | w | whiteness ]( [ + | - | * ]? )\nfunction transformBlacknessLightnessSaturationWhitenessAdjuster(base, node, opts) {\n\tconst channel = node.value.toLowerCase().replace(/^b$/, 'blackness').replace(/^l$/, 'lightness').replace(/^s$/, 'saturation').replace(/^w$/, 'whiteness');\n\tconst [operatorOrValue, adjustment] = transformArgsByParams(node, [\n\t\t[transformMinusPlusTimesOperator, transformPercentage],\n\t\t[transformPercentage]\n\t]);\n\n\tif (operatorOrValue !== undefined) {\n\t\tconst existingValue = base[channel]();\n\n\t\tconst modifiedValue = adjustment !== undefined\n\t\t\t? operatorOrValue === '+'\n\t\t\t\t? existingValue + Number(adjustment)\n\t\t\t: operatorOrValue === '-'\n\t\t\t\t? existingValue - Number(adjustment)\n\t\t\t: operatorOrValue === '*'\n\t\t\t\t? existingValue * Number(adjustment)\n\t\t\t: Number(adjustment)\n\t\t: Number(operatorOrValue);\n\n\t\treturn base[channel](modifiedValue);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid ${channel}() function)`);\n\t}\n}\n\n// return a transformed color using shade/tint adjustments\nfunction transformShadeTintAdjuster(base, node, opts) {\n\tconst channel = node.value.toLowerCase();\n\tconst [percentage] = transformArgsByParams(node, [\n\t\t// [ shade | tint ]( )\n\t\t[transformPercentage]\n\t]);\n\n\tif (percentage !== undefined) {\n\t\tconst modifiedValue = Number(percentage);\n\n\t\treturn base[channel](modifiedValue);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected valid ${channel}() arguments`);\n\t}\n}\n\n/* Argument Transforms\n/* ========================================================================== */\n\n// return a transformed color space\nfunction transformColorSpace(node, opts) {\n\tif (isColorSpace(node)) {\n\t\t// [ hsl | hwb | rgb ]\n\t\treturn node.value;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid color space)`);\n\t}\n}\n\n// return a transformed alpha value\nfunction transformAlpha(node, opts) {\n\tif (isNumber(node)) {\n\t\t// \n\t\treturn Number(parser.unit(node.value).number) * 100;\n\t} else if (isPercentage(node)) {\n\t\t// \n\t\treturn transformPercentage(node, opts);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid alpha value)`);\n\t}\n}\n\n// return a transformed rgb number\nfunction transformRGBNumber(node, opts) {\n\tif (isNumber(node)) {\n\t\t// \n\t\treturn node.value / 2.55;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid RGB value)`);\n\t}\n}\n\n// return a transformed hue\nfunction transformHue(node, opts) {\n\tif (isHue(node)) {\n\t\t// = | \n\t\tconst unit = parser.unit(node.value).unit.toLowerCase();\n\n\t\tif (unit === 'grad') {\n\t\t\t// if = (400 per circle)\n\t\t\treturn convertGtoD(Number(parser.unit(node.value).number));\n\t\t} else if (unit === 'rad') {\n\t\t\t// if = (2π per circle)\n\t\t\treturn convertRtoD(Number(parser.unit(node.value).number));\n\t\t} else if (unit === 'turn') {\n\t\t\t// if = (1 per circle)\n\t\t\treturn convertTtoD(Number(parser.unit(node.value).number));\n\t\t} else {\n\t\t\t// if = [ | ] (360 per circle)\n\t\t\treturn convertDtoD(Number(parser.unit(node.value).number));\n\t\t}\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid hue`);\n\t}\n}\n\n// return a transformed percentage\nfunction transformPercentage(node, opts) {\n\tif (isPercentage(node)) {\n\t\t// \n\t\treturn Number(parser.unit(node.value).number);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid percentage`);\n\t}\n}\n\n// return a transformed minus-plus operator\nfunction transformMinusPlusOperator(node, opts) {\n\tif (isMinusPlusOperator(node)) {\n\t\t// [ - | + ]\n\t\treturn node.value;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a plus or minus operator`);\n\t}\n}\n\n// return a transformed times operator\nfunction transformTimesOperator(node, opts) {\n\tif (isTimesOperator(node)) {\n\t\t// [ * ]\n\t\treturn node.value;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a times operator`);\n\t}\n}\n\n// return a transformed minus-plus-times operator\nfunction transformMinusPlusTimesOperator(node, opts) {\n\tif (isMinusPlusTimesOperator(node)) {\n\t\t// [ - | + | * ]\n\t\treturn node.value;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a plus, minus, or times operator`);\n\t}\n}\n\n/* Additional transforms\n/* ========================================================================== */\n\nfunction transformWord(node, opts) {\n\tif (isWord(node)) {\n\t\treturn node.value;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid word`);\n\t}\n}\n\nfunction transformNode(node) {\n\treturn Object(node);\n}\n\n/* Transform helper\n/* ========================================================================== */\n\n// return the first set of transformed arguments allowable by the parameters\nfunction transformArgsByParams(node, params) {\n\tconst nodes = (node.nodes || []).filter((node) => {\n\t\treturn node.type !== 'space' && node.type !== 'comment';\n\t});\n\tconst opts = { unresolved: 'ignore' };\n\n\treturn params.map((param) => {\n\t\treturn nodes.map((childNode, index) => {\n\t\t\treturn typeof param[index] === 'function' ? param[index](childNode, opts) : undefined\n\t\t}).filter((child) => {\n\t\t\treturn typeof child !== 'boolean'\n\t\t})\n\t}).filter((param) => {\n\t\treturn param.every((result) => {\n\t\t\treturn result !== undefined\n\t\t})\n\t})[0] || [];\n}\n\n/* Variable validators\n/* ========================================================================== */\n\n// return whether the node is a var function\nfunction isVariable(node) {\n\t// var()\n\treturn Object(node).type === 'function' && varMatch.test(node.value);\n}\n\n/* Adjustment validators\n/* ========================================================================== */\n\n// return whether the node is an a/alpha/blue/green/red adjuster\nfunction isAlphaBlueGreenRedAdjuster(node) {\n\t// [ a(), alpha(), blue(), green(), red() ]\n\treturn Object(node).type === 'function' && alphaBlueGreenRedMatch.test(node.value);\n}\n\n// return whether the node is an rgb adjuster\nfunction isRGBAdjuster(node) {\n\treturn Object(node).type === 'function' && rgbMatch.test(node.value);\n}\n\n// return whether the node is a hue adjuster\nfunction isHueAdjuster(node) {\n\t// [ h() | hue() ]\n\treturn Object(node).type === 'function' && hueMatch.test(node.value);\n}\n\n// return whether the node is a blackness/lightness/saturation/whiteness adjuster\nfunction isBlacknessLightnessSaturationWhitenessAdjuster(node) {\n\t// [ b() | blackness() | l() | lightness() | s() | saturation() | w() | whiteness() ]\n\treturn Object(node).type === 'function' && blacknessLightnessSaturationWhitenessMatch.test(node.value);\n}\n\n// return whether the node is a shade/tint adjuster\nfunction isShadeTintAdjuster(node) {\n\t// [ shade() | tint() ]\n\treturn Object(node).type === 'function' && shadeTintMatch.test(node.value);\n}\n\n// return whether the node is a blend adjuster\nfunction isBlendAdjuster(node) {\n\t// [ blend(), blenda() ]\n\treturn Object(node).type === 'function' && blendMatch.test(node.value);\n}\n\n// return whether the node is a contrast adjuster\nfunction isContrastAdjuster(node) {\n\t// [ contrast() ]\n\treturn Object(node).type === 'function' && contrastMatch.test(node.value);\n}\n\n/* Color validators\n/* ========================================================================== */\n\n// return whether the node is an rgb/rgba color function\nfunction isRGBFunction(node) {\n\t// [ rgb(), rgba() ]\n\treturn Object(node).type === 'function' && rgbaMatch.test(node.value);\n}\n\n// return whether the node is an hsl color function\nfunction isHSLFunction(node) {\n\t// [ hsl(), hsla() ]\n\treturn Object(node).type === 'function' && hslaMatch.test(node.value);\n}\n\n// return whether the node is an hwb color function\nfunction isHWBFunction(node) {\n\t// hwb()\n\treturn Object(node).type === 'function' && hwbMatch.test(node.value);\n}\n\n// return whether the node is a color-mod function\nfunction isColorModFunction(node) {\n\t// color-mod()\n\treturn Object(node).type === 'function' && colorModMatch.test(node.value);\n}\n\n// return whether the node is a valid named-color\nfunction isNamedColor(node) {\n\treturn Object(node).type === 'word' && Boolean(convertNtoRGB(node.value));\n}\n\n// return whether the node is a valid hex color\nfunction isHexColor(node) {\n\t// #{3,4,6,8}\n\treturn Object(node).type === 'word' && hexColorMatch.test(node.value);\n}\n\n// return whether the node is a valid color space\nfunction isColorSpace(node) {\n\t// [ hsl | hwb | rgb ]\n\treturn Object(node).type === 'word' && colorSpaceMatch.test(node.value);\n}\n\n/* Additional validators\n/* ========================================================================== */\n\n// return whether the hue value is valid\nfunction isHue(node) {\n\tif (Object(node).type !== 'word') {\n\t\treturn false;\n\t}\n\n\tconst parsedNumber = parser.unit(node.value);\n\treturn parsedNumber && hueUnitMatch.test(parsedNumber.unit);\n}\n\n// return whether the comma is valid\nfunction isComma(node) {\n\treturn Object(node).type === 'div' && node.value === ',';\n}\n\n// return whether the slash operator is valid\nfunction isSlash(node) {\n\treturn Object(node).type === 'div' && node.value === '/';\n}\n\n// return whether the number is valid\nfunction isNumber(node) {\n\tif (Object(node).type !== 'word') {\n\t\treturn false;\n\t}\n\n\tconst parsedNumber = parser.unit(node.value);\n\treturn parsedNumber && parsedNumber.unit === '';\n}\n\n// return whether the mind-plus operator is valid\nfunction isMinusPlusOperator(node) {\n\treturn Object(node).type === 'word' && minusPlusMatch.test(node.value);\n}\n\n// return whether the minus-plus-times operator is valid\nfunction isMinusPlusTimesOperator(node) {\n\treturn Object(node).type === 'word' && minusPlusTimesMatch.test(node.value);\n}\n\n// return whether the times operator is valid\nfunction isTimesOperator(node) {\n\treturn Object(node).type === 'word' && timesMatch.test(node.value);\n}\n\n// return whether the percentage is valid\nfunction isPercentage(node) {\n\tif (Object(node).type !== 'word') {\n\t\treturn false;\n\t}\n\n\tconst parsedNumber = parser.unit(node.value);\n\treturn parsedNumber && (parsedNumber.unit === '%' || parseFloat(parsedNumber.number) === 0);\n}\n\n// return whether the node is a word\nfunction isWord(node) {\n\t// \n\treturn Object(node).type === 'word';\n}\n\n/* Matchers\n/* ========================================================================== */\n\nconst alphaMatch = /^a(lpha)?$/i;\nconst alphaBlueGreenRedMatch = /^(a(lpha)?|blue|green|red)$/i;\nconst blacknessLightnessSaturationWhitenessMatch = /^(b(lackness)?|l(ightness)?|s(aturation)?|w(hiteness)?)$/i;\nconst blendMatch = /^blenda?$/i;\nconst colorModMatch = /^color-mod$/i;\nconst colorSpaceMatch = /^(hsl|hwb|rgb)$/i;\nconst contrastMatch = /^contrast$/i;\nconst hexColorMatch = /^#(?:([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?|([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?)$/i;\nconst hslaMatch = /^hsla?$/i;\nconst hueUnitMatch = /^(deg|grad|rad|turn)?$/i;\nconst hueMatch = /^h(ue)?$/i;\nconst hwbMatch = /^hwb$/i;\nconst minusPlusMatch = /^[+-]$/;\nconst minusPlusTimesMatch = /^[*+-]$/;\nconst rgbMatch = /^rgb$/i;\nconst rgbaMatch = /^rgba?$/i;\nconst shadeTintMatch = /^(shade|tint)$/i;\nconst varMatch = /^var$/i;\nconst looseVarMatch = /(^|[^\\w-])var\\(/i;\nconst timesMatch = /^[*]$/;\n","import getCustomProperties from './lib/get-custom-properties';\nimport importCustomPropertiesFromSources from './lib/import-from';\nimport parser from 'postcss-value-parser';\nimport transformAST from './lib/transform';\n\nmodule.exports = (opts = {}) => {\n\t// how unresolved functions and arguments should be handled (default: \"throw\")\n\tconst unresolvedOpt = String(Object(opts).unresolved || 'throw').toLowerCase();\n\n\t// how transformed colors will be produced in CSS\n\tconst stringifierOpt = Object(opts).stringifier || (color => color.toLegacy());\n\n\t// sources to import custom selectors from\n\tconst importFrom = [].concat(Object(opts).importFrom || []);\n\n\t// whether var() within color-mod() should use Custom Properties or var() fallback\n\tconst transformVarsOpt = 'transformVars' in Object(opts) ? opts.transformVars : true;\n\n\t// promise any custom selectors are imported\n\tconst customPropertiesPromise = importCustomPropertiesFromSources(importFrom);\n\n\treturn {\n\t\tpostcssPlugin: 'postcss-color-mod-function',\n\t\tasync Once (root, { result }) {\n\t\t\tconst customProperties = Object.assign(\n\t\t\t\tawait customPropertiesPromise,\n\t\t\t\tgetCustomProperties(root, { preserve: true })\n\t\t\t);\n\n\t\t\troot.walkDecls(decl => {\n\t\t\t\tconst originalValue = decl.value;\n\n\t\t\t\tif (colorModFunctionMatch.test(originalValue)) {\n\t\t\t\t\tconst ast = parser(originalValue);\n\n\t\t\t\t\ttransformAST(ast, {\n\t\t\t\t\t\tunresolved: unresolvedOpt,\n\t\t\t\t\t\tstringifier: stringifierOpt,\n\t\t\t\t\t\ttransformVars: transformVarsOpt,\n\t\t\t\t\t\tdecl,\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tcustomProperties\n\t\t\t\t\t});\n\n\t\t\t\t\tconst modifiedValue = parser.stringify(ast);\n\n\t\t\t\t\tif (originalValue !== modifiedValue) {\n\t\t\t\t\t\tdecl.value = modifiedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n};\n\nmodule.exports.postcss = true;\n\nconst colorModFunctionMatch = /(^|[^\\w-])color-mod\\(/i;\n"],"names":["valueParser","hexColorMatch","rgb2hue","hsl2rgb","hwb2rgb","rgb2hsl","hwb2hsl","rgb2hwb","hsl2hwb"],"mappings":";;;;;;;;AAEA;AACe,SAAS,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE;AACxD;AACA,CAAC,MAAM,+BAA+B,GAAG,EAAE;AAC3C,CAAC,MAAM,8BAA8B,GAAG,EAAE;;AAE1C;AACA,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI;AACpC,EAAE,MAAM,sBAAsB,GAAG,UAAU,CAAC,IAAI;AAChD,KAAK;AACL,IAAI,UAAU,CAAC,IAAI;AACnB,KAAK;AACL,IAAI,IAAI;;AAER;AACA,EAAE,IAAI,sBAAsB,EAAE;AAC9B,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI;AACtC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE;AAC5B,KAAK,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI;;AAE1B;AACA,KAAK,sBAAsB,CAAC,IAAI,CAAC,GAAGA,MAAW,CAAC,IAAI,CAAC,KAAK,CAAC;;AAE3D;AACA,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;AACzB,MAAM,IAAI,CAAC,MAAM,EAAE;AACnB;AACA;AACA,IAAI,CAAC;;AAEL;AACA,GAAG,IAAI,CAAC,IAAI,C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AgB;AACrC,MAAM,IAAI;AACV,MAAM,MAAM;AACZ,MAAM;AACN,MAAM,CAAC;;AAEP,KAAK,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;;AAEhD,KAAK,IAAI,aAAa,KAAK,aAAa,EAAE;AAC1C,MAAM,IAAI,CAAC,KAAK,GAAG,aAAa;AAChC;AACA;AACA,IAAI,CAAC;AACL;AACA,EAAE;AACF,CAAC;;AAED,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI;;AAE7B,MAAM,qBAAqB,GAAG,wBAAwB;;"} \ No newline at end of file diff --git a/index.es.mjs b/index.es.mjs new file mode 100644 index 0000000..00a3ade --- /dev/null +++ b/index.es.mjs @@ -0,0 +1,1689 @@ +import parser from 'postcss-value-parser'; +import fs from 'fs'; +import path from 'path'; +import postcss from 'postcss'; +import { rgb2hue, hsl2rgb, hwb2rgb, rgb2hsl, hwb2hsl, rgb2hwb, hsl2hwb } from '@csstools/convert-colors'; + +// return custom selectors from the css root, conditionally removing them +function getCustomProperties(root, opts) { + // initialize custom selectors + const customPropertiesFromHtmlElement = {}; + const customPropertiesFromRootPsuedo = {}; + + // for each html or :root rule + root.nodes.slice().forEach(rule => { + const customPropertiesObject = isHtmlRule(rule) + ? customPropertiesFromHtmlElement + : isRootRule(rule) + ? customPropertiesFromRootPsuedo + : null; + + // for each custom property + if (customPropertiesObject) { + rule.nodes.slice().forEach(decl => { + if (isCustomDecl(decl)) { + const { prop } = decl; + + // write the parsed value to the custom property + customPropertiesObject[prop] = parser(decl.value); + + // conditionally remove the custom property declaration + if (!opts.preserve) { + decl.remove(); + } + } + }); + + // conditionally remove the empty html or :root rule + if (!opts.preserve && isEmptyParent(rule)) { + rule.remove(); + } + } + }); + + // return all custom properties, preferring :root properties over html properties + return { ...customPropertiesFromHtmlElement, ...customPropertiesFromRootPsuedo }; +} + +// match html and :root rules +const htmlSelectorRegExp = /^html$/i; +const rootSelectorRegExp = /^:root$/i; +const customPropertyRegExp = /^--[A-z][\w-]*$/; + +// whether the node is an html or :root rule +const isHtmlRule = node => node.type === 'rule' && htmlSelectorRegExp.test(node.selector) && Object(node.nodes).length; +const isRootRule = node => node.type === 'rule' && rootSelectorRegExp.test(node.selector) && Object(node.nodes).length; + +// whether the node is an custom property +const isCustomDecl = node => node.type === 'decl' && customPropertyRegExp.test(node.prop); + +// whether the node is a parent without children +const isEmptyParent = node => Object(node.nodes).length === 0; + +/* Import Custom Properties from CSS AST +/* ========================================================================== */ + +function importCustomPropertiesFromCSSAST(root) { + return getCustomProperties(root, { preserve: true }); +} + +/* Import Custom Properties from CSS File +/* ========================================================================== */ + +async function importCustomPropertiesFromCSSFile(from) { + const css = await readFile(from); + const root = postcss.parse(css, { from }); + + return importCustomPropertiesFromCSSAST(root); +} + +/* Import Custom Properties from Object +/* ========================================================================== */ + +function importCustomPropertiesFromObject(object) { + const customProperties = Object.assign( + {}, + Object(object).customProperties || Object(object)['custom-properties'] + ); + + for (const prop in customProperties) { + customProperties[prop] = parser(customProperties[prop]); + } + + return customProperties; +} + +/* Import Custom Properties from JSON file +/* ========================================================================== */ + +async function importCustomPropertiesFromJSONFile(from) { + const object = await readJSON(from); + + return importCustomPropertiesFromObject(object); +} + +/* Import Custom Properties from JS file +/* ========================================================================== */ + +async function importCustomPropertiesFromJSFile(from) { + const object = await import(from); + + return importCustomPropertiesFromObject(('default' in object) ? object.default : object); +} + +/* Import Custom Properties from Sources +/* ========================================================================== */ + +function importCustomPropertiesFromSources(sources) { + return sources.map(source => { + if (source instanceof Promise) { + return source; + } else if (source instanceof Function) { + return source(); + } + + // read the source as an object + const opts = source === Object(source) ? source : { from: String(source) }; + + // skip objects with Custom Properties + if (opts.customProperties || opts['custom-properties']) { + return opts + } + + // source pathname + const from = path.resolve(String(opts.from || '')); + + // type of file being read from + const type = (opts.type || path.extname(from).slice(1)).toLowerCase(); + + return { type, from }; + }).reduce(async (customProperties, source) => { + const { type, from } = await source; + + if (type === 'ast') { + return Object.assign(await customProperties, importCustomPropertiesFromCSSAST(from)); + } + + if (type === 'css') { + return Object.assign(await customProperties, await importCustomPropertiesFromCSSFile(from)); + } + + if (type === 'js') { + return Object.assign(await customProperties, await importCustomPropertiesFromJSFile(from)); + } + + if (type === 'json') { + return Object.assign(await customProperties, await importCustomPropertiesFromJSONFile(from)); + } + + return Object.assign(await customProperties, await importCustomPropertiesFromObject(await source)); + }, {}); +} + +/* Helper utilities +/* ========================================================================== */ + +const readFile = from => new Promise((resolve, reject) => { + fs.readFile(from, 'utf8', (error, result) => { + if (error) { + reject(error); + } else { + resolve(result); + } + }); +}); + +const readJSON = async from => JSON.parse(await readFile(from)); + +/* Convert Degree to Hue Degree +/* ========================================================================== */ + +function convertDtoD(deg) { + return deg % 360; +} + +/* Convert Gradian to Hue Degree +/* ========================================================================== */ + +function convertGtoD(grad) { + return grad * 0.9 % 360; +} + +/* Convert Radian to Hue Degree +/* ========================================================================== */ + +function convertRtoD(rad) { + return rad * 180 / Math.PI % 360; +} + +/* Convert Turn to Hue Degree +/* ========================================================================== */ + +function convertTtoD(turn) { + return turn * 360 % 360; +} + +/* Convert a Name to Red/Green/Blue +/* ========================================================================== */ + +function convertNtoRGB(name) { + const names = { + aliceblue: [240, 248, 255], + antiquewhite: [250, 235, 215], + aqua: [0, 255, 255], + aquamarine: [127, 255, 212], + azure: [240, 255, 255], + beige: [245, 245, 220], + bisque: [255, 228, 196], + black: [0, 0, 0], + blanchedalmond: [255, 235, 205], + blue: [0, 0, 255], + blueviolet: [138, 43, 226], + brown: [165, 42, 42], + burlywood: [222, 184, 135], + cadetblue: [95, 158, 160], + chartreuse: [127, 255, 0], + chocolate: [210, 105, 30], + coral: [255, 127, 80], + cornflowerblue: [100, 149, 237], + cornsilk: [255, 248, 220], + crimson: [220, 20, 60], + cyan: [0, 255, 255], + darkblue: [0, 0, 139], + darkcyan: [0, 139, 139], + darkgoldenrod: [184, 134, 11], + darkgray: [169, 169, 169], + darkgreen: [0, 100, 0], + darkgrey: [169, 169, 169], + darkkhaki: [189, 183, 107], + darkmagenta: [139, 0, 139], + darkolivegreen: [85, 107, 47], + darkorange: [255, 140, 0], + darkorchid: [153, 50, 204], + darkred: [139, 0, 0], + darksalmon: [233, 150, 122], + darkseagreen: [143, 188, 143], + darkslateblue: [72, 61, 139], + darkslategray: [47, 79, 79], + darkslategrey: [47, 79, 79], + darkturquoise: [0, 206, 209], + darkviolet: [148, 0, 211], + deeppink: [255, 20, 147], + deepskyblue: [0, 191, 255], + dimgray: [105, 105, 105], + dimgrey: [105, 105, 105], + dodgerblue: [30, 144, 255], + firebrick: [178, 34, 34], + floralwhite: [255, 250, 240], + forestgreen: [34, 139, 34], + fuchsia: [255, 0, 255], + gainsboro: [220, 220, 220], + ghostwhite: [248, 248, 255], + gold: [255, 215, 0], + goldenrod: [218, 165, 32], + gray: [128, 128, 128], + green: [0, 128, 0], + greenyellow: [173, 255, 47], + grey: [128, 128, 128], + honeydew: [240, 255, 240], + hotpink: [255, 105, 180], + indianred: [205, 92, 92], + indigo: [75, 0, 130], + ivory: [255, 255, 240], + khaki: [240, 230, 140], + lavender: [230, 230, 250], + lavenderblush: [255, 240, 245], + lawngreen: [124, 252, 0], + lemonchiffon: [255, 250, 205], + lightblue: [173, 216, 230], + lightcoral: [240, 128, 128], + lightcyan: [224, 255, 255], + lightgoldenrodyellow: [250, 250, 210], + lightgray: [211, 211, 211], + lightgreen: [144, 238, 144], + lightgrey: [211, 211, 211], + lightpink: [255, 182, 193], + lightsalmon: [255, 160, 122], + lightseagreen: [32, 178, 170], + lightskyblue: [135, 206, 250], + lightslategray: [119, 136, 153], + lightslategrey: [119, 136, 153], + lightsteelblue: [176, 196, 222], + lightyellow: [255, 255, 224], + lime: [0, 255, 0], + limegreen: [50, 205, 50], + linen: [250, 240, 230], + magenta: [255, 0, 255], + maroon: [128, 0, 0], + mediumaquamarine: [102, 205, 170], + mediumblue: [0, 0, 205], + mediumorchid: [186, 85, 211], + mediumpurple: [147, 112, 219], + mediumseagreen: [60, 179, 113], + mediumslateblue: [123, 104, 238], + mediumspringgreen: [0, 250, 154], + mediumturquoise: [72, 209, 204], + mediumvioletred: [199, 21, 133], + midnightblue: [25, 25, 112], + mintcream: [245, 255, 250], + mistyrose: [255, 228, 225], + moccasin: [255, 228, 181], + navajowhite: [255, 222, 173], + navy: [0, 0, 128], + oldlace: [253, 245, 230], + olive: [128, 128, 0], + olivedrab: [107, 142, 35], + orange: [255, 165, 0], + orangered: [255, 69, 0], + orchid: [218, 112, 214], + palegoldenrod: [238, 232, 170], + palegreen: [152, 251, 152], + paleturquoise: [175, 238, 238], + palevioletred: [219, 112, 147], + papayawhip: [255, 239, 213], + peachpuff: [255, 218, 185], + peru: [205, 133, 63], + pink: [255, 192, 203], + plum: [221, 160, 221], + powderblue: [176, 224, 230], + purple: [128, 0, 128], + rebeccapurple: [102, 51, 153], + red: [255, 0, 0], + rosybrown: [188, 143, 143], + royalblue: [65, 105, 225], + saddlebrown: [139, 69, 19], + salmon: [250, 128, 114], + sandybrown: [244, 164, 96], + seagreen: [46, 139, 87], + seashell: [255, 245, 238], + sienna: [160, 82, 45], + silver: [192, 192, 192], + skyblue: [135, 206, 235], + slateblue: [106, 90, 205], + slategray: [112, 128, 144], + slategrey: [112, 128, 144], + snow: [255, 250, 250], + springgreen: [0, 255, 127], + steelblue: [70, 130, 180], + tan: [210, 180, 140], + teal: [0, 128, 128], + thistle: [216, 191, 216], + tomato: [255, 99, 71], + transparent: [0, 0, 0], + turquoise: [64, 224, 208], + violet: [238, 130, 238], + wheat: [245, 222, 179], + white: [255, 255, 255], + whitesmoke: [245, 245, 245], + yellow: [255, 255, 0], + yellowgreen: [154, 205, 50] + }; + + return names[name] && names[name].map(c => c / 2.55); +} + + +/* Convert a Hex to Red/Green/Blue +/* ========================================================================== */ + +function convertHtoRGB(hex) { + // #{3,4,6,8} + const [r, g, b, a, rr, gg, bb, aa] = (hex.match(hexColorMatch$1) || []).slice(1); + + if (rr !== undefined || r !== undefined) { + const red = rr !== undefined ? parseInt(rr, 16) : r !== undefined ? parseInt(r + r, 16) : 0; + const green = gg !== undefined ? parseInt(gg, 16) : g !== undefined ? parseInt(g + g, 16) : 0; + const blue = bb !== undefined ? parseInt(bb, 16) : b !== undefined ? parseInt(b + b, 16) : 0; + const alpha = aa !== undefined ? parseInt(aa, 16) : a !== undefined ? parseInt(a + a, 16) : 255; + + return [red, green, blue, alpha].map(c => c / 2.55); + } + + return undefined; +} + +const hexColorMatch$1 = /^#(?:([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?|([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?)$/i; + +class Color { + constructor(color) { + this.color = Object(Object(color).color || color); + + this.color.colorspace = this.color.colorspace + ? this.color.colorspace + : 'red' in color && 'green' in color && 'blue' in color + ? 'rgb' + : 'hue' in color && 'saturation' in color && 'lightness' in color + ? 'hsl' + : 'hue' in color && 'whiteness' in color && 'blackness' in color + ? 'hwb' + : 'unknown'; + + if (color.colorspace === 'rgb') { + this.color.hue = rgb2hue(color.red, color.green, color.blue, color.hue || 0); + } + } + + alpha(alpha) { + const color = this.color; + + return alpha === undefined + ? color.alpha + : new Color(assign(color, { alpha })); + } + + blackness(blackness) { + const hwb = color2hwb(this.color); + + return blackness === undefined + ? hwb.blackness + : new Color(assign(hwb, { blackness })); + } + + blend(color, percentage, colorspace = 'rgb') { + const base = this.color; + + return new Color(blend(base, color, percentage, colorspace)); + } + + blenda(color, percentage, colorspace = 'rgb') { + const base = this.color; + + return new Color(blend(base, color, percentage, colorspace, true)); + } + + blue(blue) { + const rgb = color2rgb(this.color); + + return blue === undefined + ? rgb.blue + : new Color(assign(rgb, { blue })); + } + + contrast(percentage) { + const base = this.color; + + return new Color(contrast(base, percentage)); + } + + green(green) { + const rgb = color2rgb(this.color); + + return green === undefined + ? rgb.green + : new Color(assign(rgb, { green })); + } + + hue(hue) { + const hsl = color2hsl(this.color); + + return hue === undefined + ? hsl.hue + : new Color(assign(hsl, { hue })); + } + + lightness(lightness) { + const hsl = color2hsl(this.color); + + return lightness === undefined + ? hsl.lightness + : new Color(assign(hsl, { lightness })) + } + + red(red) { + const rgb = color2rgb(this.color); + + return red === undefined + ? rgb.red + : new Color(assign(rgb, { red })); + } + + rgb(red, green, blue) { + const rgb = color2rgb(this.color); + + return new Color(assign(rgb, { red, green, blue })); + } + + saturation(saturation) { + const hsl = color2hsl(this.color); + + return saturation === undefined + ? hsl.saturation + : new Color(assign(hsl, { saturation })); + } + + shade(percentage) { + const hwb = color2hwb(this.color); + const shade = { hue: 0, whiteness: 0, blackness: 100, colorspace: 'hwb' }; + const colorspace = 'rgb'; + + return percentage === undefined + ? hwb.blackness + : new Color(blend(hwb, shade, percentage, colorspace)); + } + + tint(percentage) { + const hwb = color2hwb(this.color); + const tint = { hue: 0, whiteness: 100, blackness: 0, colorspace: 'hwb' }; + const colorspace = 'rgb'; + + return percentage === undefined + ? hwb.blackness + : new Color(blend(hwb, tint, percentage, colorspace)); + } + + whiteness(whiteness) { + const hwb = color2hwb(this.color); + + return whiteness === undefined + ? hwb.whiteness + : new Color(assign(hwb, { whiteness })); + } + + toHSL() { + return color2hslString(this.color); + } + + toHWB() { + return color2hwbString(this.color); + } + + toLegacy() { + return color2legacyString(this.color); + } + + toRGB() { + return color2rgbString(this.color); + } + + toRGBLegacy() { + return color2rgbLegacyString(this.color); + } + + toString() { + return color2string(this.color); + } +} + +/* Blending +/* ========================================================================== */ + +function blend(base, color, percentage, colorspace, isBlendingAlpha) { + const addition = percentage / 100; + const subtraction = 1 - addition; + + if (colorspace === 'hsl') { + const { hue: h1, saturation: s1, lightness: l1, alpha: a1 } = color2hsl(base); + const { hue: h2, saturation: s2, lightness: l2, alpha: a2 } = color2hsl(color); + + const [hue, saturation, lightness, alpha] = [ + h1 * subtraction + h2 * addition, + s1 * subtraction + s2 * addition, + l1 * subtraction + l2 * addition, + isBlendingAlpha + ? a1 * subtraction + a2 * addition + : a1 + ]; + + return { hue, saturation, lightness, alpha, colorspace: 'hsl' }; + } else if (colorspace === 'hwb') { + const { hue: h1, whiteness: w1, blackness: b1, alpha: a1 } = color2hwb(base); + const { hue: h2, whiteness: w2, blackness: b2, alpha: a2 } = color2hwb(color); + + const [hue, whiteness, blackness, alpha] = [ + h1 * subtraction + h2 * addition, + w1 * subtraction + w2 * addition, + b1 * subtraction + b2 * addition, + isBlendingAlpha + ? a1 * subtraction + a2 * addition + : a1 + ]; + + return { hue, whiteness, blackness, alpha, colorspace: 'hwb' }; + } else { + const { red: r1, green: g1, blue: b1, alpha: a1 } = color2rgb(base); + const { red: r2, green: g2, blue: b2, alpha: a2 } = color2rgb(color); + + const [red, green, blue, alpha] = [ + r1 * subtraction + r2 * addition, + g1 * subtraction + g2 * addition, + b1 * subtraction + b2 * addition, + isBlendingAlpha + ? a1 * subtraction + a2 * addition + : a1 + ]; + + return { red, green, blue, alpha, colorspace: 'rgb' }; + } +} + +/* Assign channels to a new instance of a base color +/* ========================================================================== */ + +function assign(base, channels) { + const color = Object.assign({}, base); + + Object.keys(channels).forEach( + channel => { + // detect channel + const channelIsHue = channel === 'hue'; + const isRGB = !channelIsHue && blueGreenRedMatch.test(channel); + + // normalized value of the channel + const value = normalize(channels[channel], channel); + + // assign channel to new object + color[channel] = value; + + if (isRGB) { + // conditionally preserve the hue + color.hue = rgb2hue(color.red, color.green, color.blue, base.hue || 0); + } + } + ); + + return color; +} + +function normalize(value, channel) { + // detect channel + const channelIsHue = channel === 'hue'; + + // value limitations + const min = 0; + const max = channelIsHue ? 360 : 100; + + const normalizedValue = Math.min(Math.max(channelIsHue + ? value % 360 + : value, min), max); + + return normalizedValue; +} + +/* Convert colors +/* ========================================================================== */ + +function color2rgb(color) { + const [ red, green, blue ] = color.colorspace === 'hsl' + ? hsl2rgb(color.hue, color.saturation, color.lightness) + : color.colorspace === 'hwb' + ? hwb2rgb(color.hue, color.whiteness, color.blackness) + : [ color.red, color.green, color.blue ]; + + return { red, green, blue, hue: color.hue, alpha: color.alpha, colorspace: 'rgb' }; +} + +function color2hsl(color) { + const [ hue, saturation, lightness ] = color.colorspace === 'rgb' + ? rgb2hsl(color.red, color.green, color.blue, color.hue) + : color.colorspace === 'hwb' + ? hwb2hsl(color.hue, color.whiteness, color.blackness) + : [ color.hue, color.saturation, color.lightness ]; + + return { hue, saturation, lightness, alpha: color.alpha, colorspace: 'hsl' }; +} + +function color2hwb(color) { + const [ hue, whiteness, blackness ] = color.colorspace === 'rgb' + ? rgb2hwb(color.red, color.green, color.blue, color.hue) + : color.colorspace === 'hsl' + ? hsl2hwb(color.hue, color.saturation, color.lightness) + : [ color.hue, color.whiteness, color.blackness ]; + + return { hue, whiteness, blackness, alpha: color.alpha, colorspace: 'hwb' }; +} + +/* Contrast functions +/* ========================================================================== */ + +function contrast(color, percentage) { + // https://drafts.csswg.org/css-color/#contrast-adjuster + const hwb = color2hwb(color); + const rgb = color2rgb(color); + + // compute the luminance of the color. + const luminance = rgb2luminance(rgb.red, rgb.green, rgb.blue); + + // the maximum-contrast color, if it is less than .5 + const maxContrastColor = luminance < 0.5 + // hwb(X, 100%, 0%), where X is the hue angle of the color + ? { hue: hwb.hue, whiteness: 100, blackness: 0, alpha: hwb.alpha, colorspace: 'hwb' } + // otherwise, hwb(X, 0%, 100%), where X is the hue angle of the color + : { hue: hwb.hue, whiteness: 0, blackness: 100, alpha: hwb.alpha, colorspace: 'hwb' }; + + // contrast ratio + const contrastRatio = colors2contrast(color, maxContrastColor); + + const minContrastColor = contrastRatio > 4.5 + // the color with the smallest contrast ratio with the base color that is greater than 4.5 + ? colors2contrastRatioColor(hwb, maxContrastColor) + // otherwise, the maximum-contrast color + : maxContrastColor; + + // color(maximum-contrast blend(minimum-contrast hwb))); + return blend(maxContrastColor, minContrastColor, percentage, 'hwb', false); +} + +function colors2contrast(color1, color2) { + // https://drafts.csswg.org/css-color/#contrast-ratio + const rgb1 = color2rgb(color1); + const rgb2 = color2rgb(color2); + const l1 = rgb2luminance(rgb1.red, rgb1.green, rgb1.blue); + const l2 = rgb2luminance(rgb2.red, rgb2.green, rgb2.blue); + + return l1 > l2 + // if l1 is the relative luminance of the lighter of the colors + ? (l1 + 0.05) / (l2 + 0.05) + // otherwise, if l2 is the relative luminance of the lighter of the colors + : (l2 + 0.05) / (l1 + 0.05); +} + +function rgb2luminance(red, green, blue) { + const [ redLuminance, greenLuminance, blueLuminance ] = [ + channel2luminance(red), + channel2luminance(green), + channel2luminance(blue) + ]; + + // https://drafts.csswg.org/css-color/#luminance + const luminance = 0.2126 * redLuminance + 0.7152 * greenLuminance + 0.0722 * blueLuminance; + + return luminance; +} + +function channel2luminance(value) { + // https://drafts.csswg.org/css-color/#luminance + const luminance = value <= 0.03928 ? value / 12.92 : Math.pow((value + 0.055) /1.055, 2.4); + + return luminance; +} + +// return the smallest contrast ratio from a color and a maximum contrast (credit: @thetalecrafter) +function colors2contrastRatioColor(hwb, maxHWB) { + const modifiedHWB = Object.assign({}, hwb); + + // values to be used for linear interpolations in HWB space + let minW = hwb.whiteness; + let minB = hwb.blackness; + let maxW = maxHWB.whiteness; + let maxB = maxHWB.blackness; + + // find the color with the smallest contrast ratio with the base color that is greater than 4.5 + while (Math.abs(minW - maxW) > 100 || Math.abs(minB - maxB) > 100) { + const midW = Math.round((maxW + minW) / 2); + const midB = Math.round((maxB + minB) / 2); + + modifiedHWB.whiteness = midW; + modifiedHWB.blackness = midB; + + if (colors2contrast(modifiedHWB, hwb) > 4.5) { + maxW = midW; + maxB = midB; + } else { + minW = midW; + minB = midB; + } + } + + return modifiedHWB; +} + +/* Match +/* ========================================================================== */ + +const blueGreenRedMatch = /^(blue|green|red)$/i; + +/* Stringifiers +/* ========================================================================== */ + +function color2string(color) { + return color.colorspace === 'hsl' + ? color2hslString(color) + : color.colorspace === 'hwb' + ? color2hwbString(color) + : color2rgbString(color); +} + +function color2hslString(color) { + const hsl = color2hsl(color); + const isOpaque = hsl.alpha === 100; + const hue = hsl.hue; + const saturation = Math.round(hsl.saturation * 10000000000) / 10000000000; + const lightness = Math.round(hsl.lightness * 10000000000) / 10000000000; + const alpha = Math.round(hsl.alpha * 10000000000) / 10000000000; + + return `hsl(${hue} ${saturation}% ${lightness}%${isOpaque + ? '' + : ` / ${alpha}%`})`; +} + +function color2hwbString(color) { + const hwb = color2hwb(color); + const isOpaque = hwb.alpha === 100; + const hue = hwb.hue; + const whiteness = Math.round(hwb.whiteness * 10000000000) / 10000000000; + const blackness = Math.round(hwb.blackness * 10000000000) / 10000000000; + const alpha = Math.round(hwb.alpha * 10000000000) / 10000000000; + + return `hwb(${hue} ${whiteness}% ${blackness}%${isOpaque + ? '' + : ` / ${alpha}%`})`; +} + +function color2rgbString(color) { + const rgb = color2rgb(color); + const isOpaque = rgb.alpha === 100; + const red = Math.round(rgb.red * 10000000000) / 10000000000; + const green = Math.round(rgb.green * 10000000000) / 10000000000; + const blue = Math.round(rgb.blue * 10000000000) / 10000000000; + const alpha = Math.round(rgb.alpha * 10000000000) / 10000000000; + + return `rgb(${red}% ${green}% ${blue}%${isOpaque + ? '' + : ` / ${alpha}%`})`; +} + +function color2legacyString(color) { + return color.colorspace === 'hsl' + ? color2hslLegacyString(color) + : color2rgbLegacyString(color); +} + +function color2rgbLegacyString(color) { + const rgb = color2rgb(color); + const isOpaque = rgb.alpha === 100; + const name = isOpaque ? 'rgb' : 'rgba'; + const red = Math.round(rgb.red * 255 / 100); + const green = Math.round(rgb.green * 255 / 100); + const blue = Math.round(rgb.blue * 255 / 100); + const alpha = Math.round(rgb.alpha / 100 * 10000000000) / 10000000000; + + return `${name}(${red}, ${green}, ${blue}${isOpaque + ? '' + : `, ${alpha}`})`; +} + +function color2hslLegacyString(color) { + const hsl = color2hsl(color); + const isOpaque = hsl.alpha === 100; + const name = isOpaque ? 'hsl' : 'hsla'; + const hue = hsl.hue; + const saturation = Math.round(hsl.saturation * 10000000000) / 10000000000; + const lightness = Math.round(hsl.lightness * 10000000000) / 10000000000; + const alpha = Math.round(hsl.alpha / 100 * 10000000000) / 10000000000; + + return `${name}(${hue}, ${saturation}%, ${lightness}%${isOpaque + ? '' + : `, ${alpha}`})`; +} + +function manageUnresolved(node, opts, word, message) { + if ('warn' === opts.unresolved) { + opts.decl.warn(opts.result, message, { word }); + } else if ('ignore' !== opts.unresolved) { + throw opts.decl.error(message, { word }); + } +} + +// tooling + +/* Transform AST +/* ========================================================================== */ + +function transformAST(node, opts) { + node.nodes.slice(0).forEach((child, index) => { + if (isColorModFunction(child)) { + // transform any variables within the color-mod() function + if (opts.transformVars) { + transformVariables(child, opts); + } + + // transform any color-mod() functions + const color = transformColorModFunction(child, opts); + + if (color) { + // update the color-mod() function with the transformed value + node.nodes.splice(index, 1, { + type: 'word', + value: opts.stringifier(color) + }); + } + } else if (child.nodes && Object(child.nodes).length) { + transformAST(child, opts); + } + }); +} + +/* Transform functions +/* ========================================================================== */ + +function transformVariables(node, opts) { + parser.walk(node.nodes, (child, index, nodes) => { + if (isVariable(child)) { + // get the custom property and fallback value from var() + const [prop, fallbackNode] = transformArgsByParams(child, [ + // , [ ]? + [transformWord, isComma, transformNode] + ]); + + // if the custom property is known + if (prop in opts.customProperties) { + let customPropertyValue = opts.customProperties[prop]; + + // follow custom properties referencing custom properties + if (looseVarMatch.test(parser.stringify(customPropertyValue))) { + const rootChildAST = JSON.parse(JSON.stringify({ nodes: customPropertyValue.nodes })); + + transformVariables(rootChildAST, opts); + + customPropertyValue = rootChildAST; + } + + // replace var() with the custom property value + if (customPropertyValue.nodes.length) { + nodes.splice(index, 0, ...JSON.parse(JSON.stringify(customPropertyValue.nodes))); + } + + nodes.splice(nodes.indexOf(child), 1); + } else if (fallbackNode && fallbackNode.nodes.length === 1 && fallbackNode.nodes[0].nodes.length) { + // otherwise, replace var() with the fallback value + transformVariables(fallbackNode, opts); + + nodes.splice(index, 1, ...fallbackNode.nodes[0].nodes[0]); + } + } + }); +} + +/* Transform functions +/* ========================================================================== */ + +function transformColor(node, opts) { + if (isRGBFunction(node)) { + return transformRGBFunction(node, opts); + } else if (isHSLFunction(node)) { + return transformHSLFunction(node, opts); + } else if (isHWBFunction(node)) { + return transformHWBFunction(node, opts); + } else if (isColorModFunction(node)) { + return transformColorModFunction(node, opts); + } else if (isHexColor(node)) { + return transformHexColor(node, opts); + } else if (isNamedColor(node)) { + return transformNamedColor(node, opts); + } else { + return manageUnresolved(node, opts, node.value, `Expected a color`); + } +} + +// return a transformed rgb/rgba color function +function transformRGBFunction(node, opts) { + const [red, green, blue, alpha = 100] = transformArgsByParams(node, [ + // [ , ]? + [transformPercentage, transformPercentage, transformPercentage, isSlash, transformAlpha], + // [ , ]? + [transformRGBNumber, transformRGBNumber, transformRGBNumber, isSlash, transformAlpha], + // , , [ , ]? + [transformPercentage, isComma, transformPercentage, isComma, transformPercentage, isComma, transformAlpha], + // , , [ , ]? + [transformRGBNumber, isComma, transformRGBNumber, isComma, transformRGBNumber, isComma, transformAlpha] + ]); + + if (red !== undefined) { + const color = new Color({ red, green, blue, alpha, colorspace: 'rgb' }); + + return color; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid rgb() function`); + } +} + +// return a transformed hsl/hsla color function +function transformHSLFunction(node, opts) { + const [hue, saturation, lightness, alpha = 100] = transformArgsByParams(node, [ + // [ / ]? + [transformHue, transformPercentage, transformPercentage, isSlash, transformAlpha], + // , , [ , ]? + [transformHue, isComma, transformPercentage, isComma, transformPercentage, isComma, transformAlpha] + ]); + + if (lightness !== undefined) { + const color = new Color({ hue, saturation, lightness, alpha, colorspace: 'hsl' }); + + return color; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid hsl() function`); + } +} + +// return a transformed hwb color function +function transformHWBFunction(node, opts) { + const [hue, whiteness, blackness, alpha = 100] = transformArgsByParams(node, [ + // [ / ]? + [transformHue, transformPercentage, transformPercentage, isSlash, transformAlpha] + ]); + + if (blackness !== undefined) { + const color = new Color({ hue, whiteness, blackness, alpha, colorspace: 'hwb' }); + + return color; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid hwb() function`); + } +} + +// return a transformed color-mod color function +function transformColorModFunction(node, opts) { + // [ | ] * + const [colorOrHueNode, ...adjusterNodes] = node.nodes || []; + + if (colorOrHueNode !== undefined) { + const color = isHue(colorOrHueNode) + ? new Color({ + hue: transformHue(colorOrHueNode, opts), + saturation: 100, + lightness: 50, + alpha: 100, + colorspace: 'hsl' + }) + : transformColor(colorOrHueNode, opts); + + if (color) { + const adjustedColor = transformColorByAdjusters(color, adjusterNodes, opts); + + return adjustedColor; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid color`); + } + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid color-mod() function`); + } +} + +// return a transformed hex color +function transformHexColor(node, opts) { + if (hexColorMatch.test(node.value)) { + // #{3,4,6,8} + const [red, green, blue, alpha] = convertHtoRGB(node.value); + + const color = new Color({ red, green, blue, alpha }); + + return color; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid hex color`); + } +} + +// return a transformed named-color +function transformNamedColor(node, opts) { + if (isNamedColor(node)) { + // + const [red, green, blue] = convertNtoRGB(node.value); + + const color = new Color({ red, green, blue, alpha: 100, colorspace: 'rgb' }); + + return color; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid named-color`); + } +} + +/* Transform functions +/* ========================================================================== */ + +// return a transformed color using adjustments +function transformColorByAdjusters(color, adjusterNodes, opts) { + const adjustedColor = adjusterNodes.filter((node) => { + return node.type !== 'space' && node.type !== 'comment'; + }).reduce((base, node) => { + if (isAlphaBlueGreenRedAdjuster(node)) { + return transformAlphaBlueGreenRedAdjuster(base, node, opts); + } else if (isRGBAdjuster(node)) { + return transformRGBAdjuster(base, node, opts); + } else if (isHueAdjuster(node)) { + return transformHueAdjuster(base, node, opts); + } else if (isBlacknessLightnessSaturationWhitenessAdjuster(node)) { + return transformBlacknessLightnessSaturationWhitenessAdjuster(base, node, opts); + } else if (isShadeTintAdjuster(node)) { + return transformShadeTintAdjuster(base, node, opts); + } else if (isBlendAdjuster(node)) { + return transformBlendAdjuster(base, node, node.value === 'blenda', opts); + } else if (isContrastAdjuster(node)) { + return transformContrastAdjuster(base, node, opts); + } else { + manageUnresolved(node, opts, node.value, `Expected a valid color adjuster`); + + return base; + } + }, color); + + return adjustedColor; +} + +// return a transformed color using a/alpha/blue/green/red adjustments +function transformAlphaBlueGreenRedAdjuster(base, node, opts) { + const [operatorOrValue, adjustment] = transformArgsByParams(node, alphaMatch.test(node.value) + // a/alpha adjustments + ? [ + // [ + | - ] + [transformMinusPlusOperator, transformAlpha], + // * + [transformTimesOperator, transformPercentage], + // + [transformAlpha] + ] + // blue/green/red adjustments + : [ + // [ + | - ] + [transformMinusPlusOperator, transformPercentage], + // [ + | - ] + [transformMinusPlusOperator, transformRGBNumber], + // * + [transformTimesOperator, transformPercentage], + // + [transformPercentage], + // + [transformRGBNumber] + ] + ); + + if (operatorOrValue !== undefined) { + // normalized channel name + const channel = node.value.toLowerCase().replace(alphaMatch, 'alpha'); + + const existingValue = base[channel](); + + const modifiedValue = adjustment !== undefined + ? operatorOrValue === '+' + ? existingValue + Number(adjustment) + : operatorOrValue === '-' + ? existingValue - Number(adjustment) + : operatorOrValue === '*' + ? existingValue * Number(adjustment) + : Number(adjustment) + : Number(operatorOrValue); + + const modifiedColor = base[channel](modifiedValue); + + return modifiedColor; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid modifier()`); + } +} + +// return a transformed color using an rgb adjustment +function transformRGBAdjuster(base, node, opts) { + const [arg1, arg2, arg3, arg4] = transformArgsByParams(node, [ + // [ + | - ] + [transformMinusPlusOperator, transformPercentage, transformPercentage, transformPercentage], + // [ + | - ] + [transformMinusPlusOperator, transformRGBNumber, transformRGBNumber, transformRGBNumber], + // [ + | - ] + [transformMinusPlusOperator, transformHexColor], + // [ * ] + [transformTimesOperator, transformPercentage] + ] + ); + + if (arg2 !== undefined && arg2.color) { + const modifiedColor = base.rgb( + arg1 === '+' + ? base.red() + arg2.red() + : base.red() - arg2.red(), + arg1 === '+' + ? base.green() + arg2.green() + : base.green() - arg2.green(), + arg1 === '+' + ? base.blue() + arg2.blue() + : base.blue() - arg2.blue() + ); + + return modifiedColor; + } else if (arg1 !== undefined && minusPlusMatch.test(arg1)) { + const modifiedColor = base.rgb( + arg1 === '+' + ? base.red() + arg2 + : base.red() - arg2, + arg1 === '+' + ? base.green() + arg3 + : base.green() - arg3, + arg1 === '+' + ? base.blue() + arg4 + : base.blue() - arg4 + ); + + return modifiedColor; + } else if (arg1 !== undefined && arg2 !== undefined) { + const modifiedColor = base.rgb( + base.red() * arg2, + base.green() * arg2, + base.blue() * arg2 + ); + + return modifiedColor; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid rgb() adjuster`); + } +} + +// return a transformed color using a blend/blenda adjustment +function transformBlendAdjuster(base, node, isAlphaBlend, opts) { + const [color, percentage, colorspace = 'rgb'] = transformArgsByParams(node, [ + [transformColor, transformPercentage, transformColorSpace] + ]); + + if (percentage !== undefined) { + const modifiedColor = isAlphaBlend + ? base.blenda(color.color, percentage, colorspace) + : base.blend(color.color, percentage, colorspace); + + return modifiedColor; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid blend() adjuster)`); + } +} + +// return a transformed color using a contrast adjustment +function transformContrastAdjuster(base, node, opts) { + const [percentage] = transformArgsByParams(node, [ + // + [transformPercentage] + ]); + + if (percentage !== undefined) { + const modifiedColor = base.contrast(percentage); + + return modifiedColor; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid contrast() adjuster)`); + } +} + +// return a transformed color using a hue adjustment +function transformHueAdjuster(base, node, opts) { + const [operatorOrHue, adjustment] = transformArgsByParams(node, [ + // [ + | - | * ] + [transformMinusPlusTimesOperator, transformHue], + // + [transformHue] + ]); + + if (operatorOrHue !== undefined) { + const existingHue = base.hue(); + + const modifiedValue = adjustment !== undefined + ? operatorOrHue === '+' + ? existingHue + Number(adjustment) + : operatorOrHue === '-' + ? existingHue - Number(adjustment) + : operatorOrHue === '*' + ? existingHue * Number(adjustment) + : Number(adjustment) + : Number(operatorOrHue); + + return base.hue(modifiedValue); + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid hue() function)`); + } +} + +// [ b | blackness | l | lightness | s | saturation | w | whiteness ]( [ + | - | * ]? ) +function transformBlacknessLightnessSaturationWhitenessAdjuster(base, node, opts) { + const channel = node.value.toLowerCase().replace(/^b$/, 'blackness').replace(/^l$/, 'lightness').replace(/^s$/, 'saturation').replace(/^w$/, 'whiteness'); + const [operatorOrValue, adjustment] = transformArgsByParams(node, [ + [transformMinusPlusTimesOperator, transformPercentage], + [transformPercentage] + ]); + + if (operatorOrValue !== undefined) { + const existingValue = base[channel](); + + const modifiedValue = adjustment !== undefined + ? operatorOrValue === '+' + ? existingValue + Number(adjustment) + : operatorOrValue === '-' + ? existingValue - Number(adjustment) + : operatorOrValue === '*' + ? existingValue * Number(adjustment) + : Number(adjustment) + : Number(operatorOrValue); + + return base[channel](modifiedValue); + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid ${channel}() function)`); + } +} + +// return a transformed color using shade/tint adjustments +function transformShadeTintAdjuster(base, node, opts) { + const channel = node.value.toLowerCase(); + const [percentage] = transformArgsByParams(node, [ + // [ shade | tint ]( ) + [transformPercentage] + ]); + + if (percentage !== undefined) { + const modifiedValue = Number(percentage); + + return base[channel](modifiedValue); + } else { + return manageUnresolved(node, opts, node.value, `Expected valid ${channel}() arguments`); + } +} + +/* Argument Transforms +/* ========================================================================== */ + +// return a transformed color space +function transformColorSpace(node, opts) { + if (isColorSpace(node)) { + // [ hsl | hwb | rgb ] + return node.value; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid color space)`); + } +} + +// return a transformed alpha value +function transformAlpha(node, opts) { + if (isNumber(node)) { + // + return Number(parser.unit(node.value).number) * 100; + } else if (isPercentage(node)) { + // + return transformPercentage(node, opts); + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid alpha value)`); + } +} + +// return a transformed rgb number +function transformRGBNumber(node, opts) { + if (isNumber(node)) { + // + return node.value / 2.55; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid RGB value)`); + } +} + +// return a transformed hue +function transformHue(node, opts) { + if (isHue(node)) { + // = | + const unit = parser.unit(node.value).unit.toLowerCase(); + + if (unit === 'grad') { + // if = (400 per circle) + return convertGtoD(Number(parser.unit(node.value).number)); + } else if (unit === 'rad') { + // if = (2π per circle) + return convertRtoD(Number(parser.unit(node.value).number)); + } else if (unit === 'turn') { + // if = (1 per circle) + return convertTtoD(Number(parser.unit(node.value).number)); + } else { + // if = [ | ] (360 per circle) + return convertDtoD(Number(parser.unit(node.value).number)); + } + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid hue`); + } +} + +// return a transformed percentage +function transformPercentage(node, opts) { + if (isPercentage(node)) { + // + return Number(parser.unit(node.value).number); + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid percentage`); + } +} + +// return a transformed minus-plus operator +function transformMinusPlusOperator(node, opts) { + if (isMinusPlusOperator(node)) { + // [ - | + ] + return node.value; + } else { + return manageUnresolved(node, opts, node.value, `Expected a plus or minus operator`); + } +} + +// return a transformed times operator +function transformTimesOperator(node, opts) { + if (isTimesOperator(node)) { + // [ * ] + return node.value; + } else { + return manageUnresolved(node, opts, node.value, `Expected a times operator`); + } +} + +// return a transformed minus-plus-times operator +function transformMinusPlusTimesOperator(node, opts) { + if (isMinusPlusTimesOperator(node)) { + // [ - | + | * ] + return node.value; + } else { + return manageUnresolved(node, opts, node.value, `Expected a plus, minus, or times operator`); + } +} + +/* Additional transforms +/* ========================================================================== */ + +function transformWord(node, opts) { + if (isWord(node)) { + return node.value; + } else { + return manageUnresolved(node, opts, node.value, `Expected a valid word`); + } +} + +function transformNode(node) { + return Object(node); +} + +/* Transform helper +/* ========================================================================== */ + +// return the first set of transformed arguments allowable by the parameters +function transformArgsByParams(node, params) { + const nodes = (node.nodes || []).filter((node) => { + return node.type !== 'space' && node.type !== 'comment'; + }); + const opts = { unresolved: 'ignore' }; + + return params.map((param) => { + return nodes.map((childNode, index) => { + return typeof param[index] === 'function' ? param[index](childNode, opts) : undefined + }).filter((child) => { + return typeof child !== 'boolean' + }) + }).filter((param) => { + return param.every((result) => { + return result !== undefined + }) + })[0] || []; +} + +/* Variable validators +/* ========================================================================== */ + +// return whether the node is a var function +function isVariable(node) { + // var() + return Object(node).type === 'function' && varMatch.test(node.value); +} + +/* Adjustment validators +/* ========================================================================== */ + +// return whether the node is an a/alpha/blue/green/red adjuster +function isAlphaBlueGreenRedAdjuster(node) { + // [ a(), alpha(), blue(), green(), red() ] + return Object(node).type === 'function' && alphaBlueGreenRedMatch.test(node.value); +} + +// return whether the node is an rgb adjuster +function isRGBAdjuster(node) { + return Object(node).type === 'function' && rgbMatch.test(node.value); +} + +// return whether the node is a hue adjuster +function isHueAdjuster(node) { + // [ h() | hue() ] + return Object(node).type === 'function' && hueMatch.test(node.value); +} + +// return whether the node is a blackness/lightness/saturation/whiteness adjuster +function isBlacknessLightnessSaturationWhitenessAdjuster(node) { + // [ b() | blackness() | l() | lightness() | s() | saturation() | w() | whiteness() ] + return Object(node).type === 'function' && blacknessLightnessSaturationWhitenessMatch.test(node.value); +} + +// return whether the node is a shade/tint adjuster +function isShadeTintAdjuster(node) { + // [ shade() | tint() ] + return Object(node).type === 'function' && shadeTintMatch.test(node.value); +} + +// return whether the node is a blend adjuster +function isBlendAdjuster(node) { + // [ blend(), blenda() ] + return Object(node).type === 'function' && blendMatch.test(node.value); +} + +// return whether the node is a contrast adjuster +function isContrastAdjuster(node) { + // [ contrast() ] + return Object(node).type === 'function' && contrastMatch.test(node.value); +} + +/* Color validators +/* ========================================================================== */ + +// return whether the node is an rgb/rgba color function +function isRGBFunction(node) { + // [ rgb(), rgba() ] + return Object(node).type === 'function' && rgbaMatch.test(node.value); +} + +// return whether the node is an hsl color function +function isHSLFunction(node) { + // [ hsl(), hsla() ] + return Object(node).type === 'function' && hslaMatch.test(node.value); +} + +// return whether the node is an hwb color function +function isHWBFunction(node) { + // hwb() + return Object(node).type === 'function' && hwbMatch.test(node.value); +} + +// return whether the node is a color-mod function +function isColorModFunction(node) { + // color-mod() + return Object(node).type === 'function' && colorModMatch.test(node.value); +} + +// return whether the node is a valid named-color +function isNamedColor(node) { + return Object(node).type === 'word' && Boolean(convertNtoRGB(node.value)); +} + +// return whether the node is a valid hex color +function isHexColor(node) { + // #{3,4,6,8} + return Object(node).type === 'word' && hexColorMatch.test(node.value); +} + +// return whether the node is a valid color space +function isColorSpace(node) { + // [ hsl | hwb | rgb ] + return Object(node).type === 'word' && colorSpaceMatch.test(node.value); +} + +/* Additional validators +/* ========================================================================== */ + +// return whether the hue value is valid +function isHue(node) { + if (Object(node).type !== 'word') { + return false; + } + + const parsedNumber = parser.unit(node.value); + return parsedNumber && hueUnitMatch.test(parsedNumber.unit); +} + +// return whether the comma is valid +function isComma(node) { + return Object(node).type === 'div' && node.value === ','; +} + +// return whether the slash operator is valid +function isSlash(node) { + return Object(node).type === 'div' && node.value === '/'; +} + +// return whether the number is valid +function isNumber(node) { + if (Object(node).type !== 'word') { + return false; + } + + const parsedNumber = parser.unit(node.value); + return parsedNumber && parsedNumber.unit === ''; +} + +// return whether the mind-plus operator is valid +function isMinusPlusOperator(node) { + return Object(node).type === 'word' && minusPlusMatch.test(node.value); +} + +// return whether the minus-plus-times operator is valid +function isMinusPlusTimesOperator(node) { + return Object(node).type === 'word' && minusPlusTimesMatch.test(node.value); +} + +// return whether the times operator is valid +function isTimesOperator(node) { + return Object(node).type === 'word' && timesMatch.test(node.value); +} + +// return whether the percentage is valid +function isPercentage(node) { + if (Object(node).type !== 'word') { + return false; + } + + const parsedNumber = parser.unit(node.value); + return parsedNumber && (parsedNumber.unit === '%' || parseFloat(parsedNumber.number) === 0); +} + +// return whether the node is a word +function isWord(node) { + // + return Object(node).type === 'word'; +} + +/* Matchers +/* ========================================================================== */ + +const alphaMatch = /^a(lpha)?$/i; +const alphaBlueGreenRedMatch = /^(a(lpha)?|blue|green|red)$/i; +const blacknessLightnessSaturationWhitenessMatch = /^(b(lackness)?|l(ightness)?|s(aturation)?|w(hiteness)?)$/i; +const blendMatch = /^blenda?$/i; +const colorModMatch = /^color-mod$/i; +const colorSpaceMatch = /^(hsl|hwb|rgb)$/i; +const contrastMatch = /^contrast$/i; +const hexColorMatch = /^#(?:([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?|([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?)$/i; +const hslaMatch = /^hsla?$/i; +const hueUnitMatch = /^(deg|grad|rad|turn)?$/i; +const hueMatch = /^h(ue)?$/i; +const hwbMatch = /^hwb$/i; +const minusPlusMatch = /^[+-]$/; +const minusPlusTimesMatch = /^[*+-]$/; +const rgbMatch = /^rgb$/i; +const rgbaMatch = /^rgba?$/i; +const shadeTintMatch = /^(shade|tint)$/i; +const varMatch = /^var$/i; +const looseVarMatch = /(^|[^\w-])var\(/i; +const timesMatch = /^[*]$/; + +module.exports = (opts = {}) => { + // how unresolved functions and arguments should be handled (default: "throw") + const unresolvedOpt = String(Object(opts).unresolved || 'throw').toLowerCase(); + + // how transformed colors will be produced in CSS + const stringifierOpt = Object(opts).stringifier || (color => color.toLegacy()); + + // sources to import custom selectors from + const importFrom = [].concat(Object(opts).importFrom || []); + + // whether var() within color-mod() should use Custom Properties or var() fallback + const transformVarsOpt = 'transformVars' in Object(opts) ? opts.transformVars : true; + + // promise any custom selectors are imported + const customPropertiesPromise = importCustomPropertiesFromSources(importFrom); + + return { + postcssPlugin: 'postcss-color-mod-function', + async Once (root, { result }) { + const customProperties = Object.assign( + await customPropertiesPromise, + getCustomProperties(root, { preserve: true }) + ); + + root.walkDecls(decl => { + const originalValue = decl.value; + + if (colorModFunctionMatch.test(originalValue)) { + const ast = parser(originalValue); + + transformAST(ast, { + unresolved: unresolvedOpt, + stringifier: stringifierOpt, + transformVars: transformVarsOpt, + decl, + result, + customProperties + }); + + const modifiedValue = parser.stringify(ast); + + if (originalValue !== modifiedValue) { + decl.value = modifiedValue; + } + } + }); + } + }; +}; + +module.exports.postcss = true; + +const colorModFunctionMatch = /(^|[^\w-])color-mod\(/i; +//# sourceMappingURL=index.es.mjs.map diff --git a/index.es.mjs.map b/index.es.mjs.map new file mode 100644 index 0000000..720ef49 --- /dev/null +++ b/index.es.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.es.mjs","sources":["lib/get-custom-properties.js","lib/import-from.js","lib/conversions.js","lib/color.js","lib/manage-unresolved.js","lib/transform.js","index.js"],"sourcesContent":["import valueParser from 'postcss-value-parser';\n\n// return custom selectors from the css root, conditionally removing them\nexport default function getCustomProperties(root, opts) {\n\t// initialize custom selectors\n\tconst customPropertiesFromHtmlElement = {};\n\tconst customPropertiesFromRootPsuedo = {};\n\n\t// for each html or :root rule\n\troot.nodes.slice().forEach(rule => {\n\t\tconst customPropertiesObject = isHtmlRule(rule)\n\t\t\t? customPropertiesFromHtmlElement\n\t\t: isRootRule(rule)\n\t\t\t? customPropertiesFromRootPsuedo\n\t\t: null;\n\n\t\t// for each custom property\n\t\tif (customPropertiesObject) {\n\t\t\trule.nodes.slice().forEach(decl => {\n\t\t\t\tif (isCustomDecl(decl)) {\n\t\t\t\t\tconst { prop } = decl;\n\n\t\t\t\t\t// write the parsed value to the custom property\n\t\t\t\t\tcustomPropertiesObject[prop] = valueParser(decl.value);\n\n\t\t\t\t\t// conditionally remove the custom property declaration\n\t\t\t\t\tif (!opts.preserve) {\n\t\t\t\t\t\tdecl.remove();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// conditionally remove the empty html or :root rule\n\t\t\tif (!opts.preserve && isEmptyParent(rule)) {\n\t\t\t\trule.remove();\n\t\t\t}\n\t\t}\n\t});\n\n\t// return all custom properties, preferring :root properties over html properties\n\treturn { ...customPropertiesFromHtmlElement, ...customPropertiesFromRootPsuedo };\n}\n\n// match html and :root rules\nconst htmlSelectorRegExp = /^html$/i;\nconst rootSelectorRegExp = /^:root$/i;\nconst customPropertyRegExp = /^--[A-z][\\w-]*$/;\n\n// whether the node is an html or :root rule\nconst isHtmlRule = node => node.type === 'rule' && htmlSelectorRegExp.test(node.selector) && Object(node.nodes).length;\nconst isRootRule = node => node.type === 'rule' && rootSelectorRegExp.test(node.selector) && Object(node.nodes).length;\n\n// whether the node is an custom property\nconst isCustomDecl = node => node.type === 'decl' && customPropertyRegExp.test(node.prop);\n\n// whether the node is a parent without children\nconst isEmptyParent = node => Object(node.nodes).length === 0;\n","import fs from 'fs';\nimport path from 'path';\nimport postcss from 'postcss';\nimport getCustomProperties from './get-custom-properties';\nimport valueParser from 'postcss-value-parser';\n\n/* Import Custom Properties from CSS AST\n/* ========================================================================== */\n\nfunction importCustomPropertiesFromCSSAST(root) {\n\treturn getCustomProperties(root, { preserve: true });\n}\n\n/* Import Custom Properties from CSS File\n/* ========================================================================== */\n\nasync function importCustomPropertiesFromCSSFile(from) {\n\tconst css = await readFile(from);\n\tconst root = postcss.parse(css, { from });\n\n\treturn importCustomPropertiesFromCSSAST(root);\n}\n\n/* Import Custom Properties from Object\n/* ========================================================================== */\n\nfunction importCustomPropertiesFromObject(object) {\n\tconst customProperties = Object.assign(\n\t\t{},\n\t\tObject(object).customProperties || Object(object)['custom-properties']\n\t);\n\n\tfor (const prop in customProperties) {\n\t\tcustomProperties[prop] = valueParser(customProperties[prop]);\n\t}\n\n\treturn customProperties;\n}\n\n/* Import Custom Properties from JSON file\n/* ========================================================================== */\n\nasync function importCustomPropertiesFromJSONFile(from) {\n\tconst object = await readJSON(from);\n\n\treturn importCustomPropertiesFromObject(object);\n}\n\n/* Import Custom Properties from JS file\n/* ========================================================================== */\n\nasync function importCustomPropertiesFromJSFile(from) {\n\tconst object = await import(from);\n\n\treturn importCustomPropertiesFromObject(('default' in object) ? object.default : object);\n}\n\n/* Import Custom Properties from Sources\n/* ========================================================================== */\n\nexport default function importCustomPropertiesFromSources(sources) {\n\treturn sources.map(source => {\n\t\tif (source instanceof Promise) {\n\t\t\treturn source;\n\t\t} else if (source instanceof Function) {\n\t\t\treturn source();\n\t\t}\n\n\t\t// read the source as an object\n\t\tconst opts = source === Object(source) ? source : { from: String(source) };\n\n\t\t// skip objects with Custom Properties\n\t\tif (opts.customProperties || opts['custom-properties']) {\n\t\t\treturn opts\n\t\t}\n\n\t\t// source pathname\n\t\tconst from = path.resolve(String(opts.from || ''));\n\n\t\t// type of file being read from\n\t\tconst type = (opts.type || path.extname(from).slice(1)).toLowerCase();\n\n\t\treturn { type, from };\n\t}).reduce(async (customProperties, source) => {\n\t\tconst { type, from } = await source;\n\n\t\tif (type === 'ast') {\n\t\t\treturn Object.assign(await customProperties, importCustomPropertiesFromCSSAST(from));\n\t\t}\n\n\t\tif (type === 'css') {\n\t\t\treturn Object.assign(await customProperties, await importCustomPropertiesFromCSSFile(from));\n\t\t}\n\n\t\tif (type === 'js') {\n\t\t\treturn Object.assign(await customProperties, await importCustomPropertiesFromJSFile(from));\n\t\t}\n\n\t\tif (type === 'json') {\n\t\t\treturn Object.assign(await customProperties, await importCustomPropertiesFromJSONFile(from));\n\t\t}\n\n\t\treturn Object.assign(await customProperties, await importCustomPropertiesFromObject(await source));\n\t}, {});\n}\n\n/* Helper utilities\n/* ========================================================================== */\n\nconst readFile = from => new Promise((resolve, reject) => {\n\tfs.readFile(from, 'utf8', (error, result) => {\n\t\tif (error) {\n\t\t\treject(error);\n\t\t} else {\n\t\t\tresolve(result);\n\t\t}\n\t});\n});\n\nconst readJSON = async from => JSON.parse(await readFile(from));\n","/* Convert Degree to Hue Degree\n/* ========================================================================== */\n\nexport function convertDtoD(deg) {\n\treturn deg % 360;\n}\n\n/* Convert Gradian to Hue Degree\n/* ========================================================================== */\n\nexport function convertGtoD(grad) {\n\treturn grad * 0.9 % 360;\n}\n\n/* Convert Radian to Hue Degree\n/* ========================================================================== */\n\nexport function convertRtoD(rad) {\n\treturn rad * 180 / Math.PI % 360;\n}\n\n/* Convert Turn to Hue Degree\n/* ========================================================================== */\n\nexport function convertTtoD(turn) {\n\treturn turn * 360 % 360;\n}\n\n/* Convert a Name to Red/Green/Blue\n/* ========================================================================== */\n\nexport function convertNtoRGB(name) {\n\tconst names = {\n\t\taliceblue: [240, 248, 255],\n\t\tantiquewhite: [250, 235, 215],\n\t\taqua: [0, 255, 255],\n\t\taquamarine: [127, 255, 212],\n\t\tazure: [240, 255, 255],\n\t\tbeige: [245, 245, 220],\n\t\tbisque: [255, 228, 196],\n\t\tblack: [0, 0, 0],\n\t\tblanchedalmond: [255, 235, 205],\n\t\tblue: [0, 0, 255],\n\t\tblueviolet: [138, 43, 226],\n\t\tbrown: [165, 42, 42],\n\t\tburlywood: [222, 184, 135],\n\t\tcadetblue: [95, 158, 160],\n\t\tchartreuse: [127, 255, 0],\n\t\tchocolate: [210, 105, 30],\n\t\tcoral: [255, 127, 80],\n\t\tcornflowerblue: [100, 149, 237],\n\t\tcornsilk: [255, 248, 220],\n\t\tcrimson: [220, 20, 60],\n\t\tcyan: [0, 255, 255],\n\t\tdarkblue: [0, 0, 139],\n\t\tdarkcyan: [0, 139, 139],\n\t\tdarkgoldenrod: [184, 134, 11],\n\t\tdarkgray: [169, 169, 169],\n\t\tdarkgreen: [0, 100, 0],\n\t\tdarkgrey: [169, 169, 169],\n\t\tdarkkhaki: [189, 183, 107],\n\t\tdarkmagenta: [139, 0, 139],\n\t\tdarkolivegreen: [85, 107, 47],\n\t\tdarkorange: [255, 140, 0],\n\t\tdarkorchid: [153, 50, 204],\n\t\tdarkred: [139, 0, 0],\n\t\tdarksalmon: [233, 150, 122],\n\t\tdarkseagreen: [143, 188, 143],\n\t\tdarkslateblue: [72, 61, 139],\n\t\tdarkslategray: [47, 79, 79],\n\t\tdarkslategrey: [47, 79, 79],\n\t\tdarkturquoise: [0, 206, 209],\n\t\tdarkviolet: [148, 0, 211],\n\t\tdeeppink: [255, 20, 147],\n\t\tdeepskyblue: [0, 191, 255],\n\t\tdimgray: [105, 105, 105],\n\t\tdimgrey: [105, 105, 105],\n\t\tdodgerblue: [30, 144, 255],\n\t\tfirebrick: [178, 34, 34],\n\t\tfloralwhite: [255, 250, 240],\n\t\tforestgreen: [34, 139, 34],\n\t\tfuchsia: [255, 0, 255],\n\t\tgainsboro: [220, 220, 220],\n\t\tghostwhite: [248, 248, 255],\n\t\tgold: [255, 215, 0],\n\t\tgoldenrod: [218, 165, 32],\n\t\tgray: [128, 128, 128],\n\t\tgreen: [0, 128, 0],\n\t\tgreenyellow: [173, 255, 47],\n\t\tgrey: [128, 128, 128],\n\t\thoneydew: [240, 255, 240],\n\t\thotpink: [255, 105, 180],\n\t\tindianred: [205, 92, 92],\n\t\tindigo: [75, 0, 130],\n\t\tivory: [255, 255, 240],\n\t\tkhaki: [240, 230, 140],\n\t\tlavender: [230, 230, 250],\n\t\tlavenderblush: [255, 240, 245],\n\t\tlawngreen: [124, 252, 0],\n\t\tlemonchiffon: [255, 250, 205],\n\t\tlightblue: [173, 216, 230],\n\t\tlightcoral: [240, 128, 128],\n\t\tlightcyan: [224, 255, 255],\n\t\tlightgoldenrodyellow: [250, 250, 210],\n\t\tlightgray: [211, 211, 211],\n\t\tlightgreen: [144, 238, 144],\n\t\tlightgrey: [211, 211, 211],\n\t\tlightpink: [255, 182, 193],\n\t\tlightsalmon: [255, 160, 122],\n\t\tlightseagreen: [32, 178, 170],\n\t\tlightskyblue: [135, 206, 250],\n\t\tlightslategray: [119, 136, 153],\n\t\tlightslategrey: [119, 136, 153],\n\t\tlightsteelblue: [176, 196, 222],\n\t\tlightyellow: [255, 255, 224],\n\t\tlime: [0, 255, 0],\n\t\tlimegreen: [50, 205, 50],\n\t\tlinen: [250, 240, 230],\n\t\tmagenta: [255, 0, 255],\n\t\tmaroon: [128, 0, 0],\n\t\tmediumaquamarine: [102, 205, 170],\n\t\tmediumblue: [0, 0, 205],\n\t\tmediumorchid: [186, 85, 211],\n\t\tmediumpurple: [147, 112, 219],\n\t\tmediumseagreen: [60, 179, 113],\n\t\tmediumslateblue: [123, 104, 238],\n\t\tmediumspringgreen: [0, 250, 154],\n\t\tmediumturquoise: [72, 209, 204],\n\t\tmediumvioletred: [199, 21, 133],\n\t\tmidnightblue: [25, 25, 112],\n\t\tmintcream: [245, 255, 250],\n\t\tmistyrose: [255, 228, 225],\n\t\tmoccasin: [255, 228, 181],\n\t\tnavajowhite: [255, 222, 173],\n\t\tnavy: [0, 0, 128],\n\t\toldlace: [253, 245, 230],\n\t\tolive: [128, 128, 0],\n\t\tolivedrab: [107, 142, 35],\n\t\torange: [255, 165, 0],\n\t\torangered: [255, 69, 0],\n\t\torchid: [218, 112, 214],\n\t\tpalegoldenrod: [238, 232, 170],\n\t\tpalegreen: [152, 251, 152],\n\t\tpaleturquoise: [175, 238, 238],\n\t\tpalevioletred: [219, 112, 147],\n\t\tpapayawhip: [255, 239, 213],\n\t\tpeachpuff: [255, 218, 185],\n\t\tperu: [205, 133, 63],\n\t\tpink: [255, 192, 203],\n\t\tplum: [221, 160, 221],\n\t\tpowderblue: [176, 224, 230],\n\t\tpurple: [128, 0, 128],\n\t\trebeccapurple: [102, 51, 153],\n\t\tred: [255, 0, 0],\n\t\trosybrown: [188, 143, 143],\n\t\troyalblue: [65, 105, 225],\n\t\tsaddlebrown: [139, 69, 19],\n\t\tsalmon: [250, 128, 114],\n\t\tsandybrown: [244, 164, 96],\n\t\tseagreen: [46, 139, 87],\n\t\tseashell: [255, 245, 238],\n\t\tsienna: [160, 82, 45],\n\t\tsilver: [192, 192, 192],\n\t\tskyblue: [135, 206, 235],\n\t\tslateblue: [106, 90, 205],\n\t\tslategray: [112, 128, 144],\n\t\tslategrey: [112, 128, 144],\n\t\tsnow: [255, 250, 250],\n\t\tspringgreen: [0, 255, 127],\n\t\tsteelblue: [70, 130, 180],\n\t\ttan: [210, 180, 140],\n\t\tteal: [0, 128, 128],\n\t\tthistle: [216, 191, 216],\n\t\ttomato: [255, 99, 71],\n\t\ttransparent: [0, 0, 0],\n\t\tturquoise: [64, 224, 208],\n\t\tviolet: [238, 130, 238],\n\t\twheat: [245, 222, 179],\n\t\twhite: [255, 255, 255],\n\t\twhitesmoke: [245, 245, 245],\n\t\tyellow: [255, 255, 0],\n\t\tyellowgreen: [154, 205, 50]\n\t};\n\n\treturn names[name] && names[name].map(c => c / 2.55);\n}\n\n\n/* Convert a Hex to Red/Green/Blue\n/* ========================================================================== */\n\nexport function convertHtoRGB(hex) {\n\t// #{3,4,6,8}\n\tconst [r, g, b, a, rr, gg, bb, aa] = (hex.match(hexColorMatch) || []).slice(1);\n\n\tif (rr !== undefined || r !== undefined) {\n\t\tconst red = rr !== undefined ? parseInt(rr, 16) : r !== undefined ? parseInt(r + r, 16) : 0;\n\t\tconst green = gg !== undefined ? parseInt(gg, 16) : g !== undefined ? parseInt(g + g, 16) : 0;\n\t\tconst blue = bb !== undefined ? parseInt(bb, 16) : b !== undefined ? parseInt(b + b, 16) : 0;\n\t\tconst alpha = aa !== undefined ? parseInt(aa, 16) : a !== undefined ? parseInt(a + a, 16) : 255;\n\n\t\treturn [red, green, blue, alpha].map(c => c / 2.55);\n\t}\n\n\treturn undefined;\n}\n\nconst hexColorMatch = /^#(?:([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?|([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?)$/i;\n","import { rgb2hsl, rgb2hwb, hsl2rgb, hsl2hwb, hwb2rgb, hwb2hsl, rgb2hue } from '@csstools/convert-colors';\n\nexport default class Color {\n\tconstructor(color) {\n\t\tthis.color = Object(Object(color).color || color);\n\n\t\tthis.color.colorspace = this.color.colorspace\n\t\t\t? this.color.colorspace\n\t\t: 'red' in color && 'green' in color && 'blue' in color\n\t\t\t? 'rgb'\n\t\t: 'hue' in color && 'saturation' in color && 'lightness' in color\n\t\t\t? 'hsl'\n\t\t: 'hue' in color && 'whiteness' in color && 'blackness' in color\n\t\t\t? 'hwb'\n\t\t: 'unknown';\n\n\t\tif (color.colorspace === 'rgb') {\n\t\t\tthis.color.hue = rgb2hue(color.red, color.green, color.blue, color.hue || 0);\n\t\t}\n\t}\n\n\talpha(alpha) {\n\t\tconst color = this.color;\n\n\t\treturn alpha === undefined\n\t\t\t? color.alpha\n\t\t: new Color(assign(color, { alpha }));\n\t}\n\n\tblackness(blackness) {\n\t\tconst hwb = color2hwb(this.color);\n\n\t\treturn blackness === undefined\n\t\t\t? hwb.blackness\n\t\t: new Color(assign(hwb, { blackness }));\n\t}\n\n\tblend(color, percentage, colorspace = 'rgb') {\n\t\tconst base = this.color;\n\n\t\treturn new Color(blend(base, color, percentage, colorspace));\n\t}\n\n\tblenda(color, percentage, colorspace = 'rgb') {\n\t\tconst base = this.color;\n\n\t\treturn new Color(blend(base, color, percentage, colorspace, true));\n\t}\n\n\tblue(blue) {\n\t\tconst rgb = color2rgb(this.color);\n\n\t\treturn blue === undefined\n\t\t\t? rgb.blue\n\t\t: new Color(assign(rgb, { blue }));\n\t}\n\n\tcontrast(percentage) {\n\t\tconst base = this.color;\n\n\t\treturn new Color(contrast(base, percentage));\n\t}\n\n\tgreen(green) {\n\t\tconst rgb = color2rgb(this.color);\n\n\t\treturn green === undefined\n\t\t\t? rgb.green\n\t\t: new Color(assign(rgb, { green }));\n\t}\n\n\thue(hue) {\n\t\tconst hsl = color2hsl(this.color);\n\n\t\treturn hue === undefined\n\t\t\t? hsl.hue\n\t\t: new Color(assign(hsl, { hue }));\n\t}\n\n\tlightness(lightness) {\n\t\tconst hsl = color2hsl(this.color);\n\n\t\treturn lightness === undefined\n\t\t\t? hsl.lightness\n\t\t: new Color(assign(hsl, { lightness }))\n\t}\n\n\tred(red) {\n\t\tconst rgb = color2rgb(this.color);\n\n\t\treturn red === undefined\n\t\t\t? rgb.red\n\t\t: new Color(assign(rgb, { red }));\n\t}\n\n\trgb(red, green, blue) {\n\t\tconst rgb = color2rgb(this.color);\n\n\t\treturn new Color(assign(rgb, { red, green, blue }));\n\t}\n\n\tsaturation(saturation) {\n\t\tconst hsl = color2hsl(this.color);\n\n\t\treturn saturation === undefined\n\t\t\t? hsl.saturation\n\t\t: new Color(assign(hsl, { saturation }));\n\t}\n\n\tshade(percentage) {\n\t\tconst hwb = color2hwb(this.color);\n\t\tconst shade = { hue: 0, whiteness: 0, blackness: 100, colorspace: 'hwb' };\n\t\tconst colorspace = 'rgb';\n\n\t\treturn percentage === undefined\n\t\t\t? hwb.blackness\n\t\t: new Color(blend(hwb, shade, percentage, colorspace));\n\t}\n\n\ttint(percentage) {\n\t\tconst hwb = color2hwb(this.color);\n\t\tconst tint = { hue: 0, whiteness: 100, blackness: 0, colorspace: 'hwb' };\n\t\tconst colorspace = 'rgb';\n\n\t\treturn percentage === undefined\n\t\t\t? hwb.blackness\n\t\t: new Color(blend(hwb, tint, percentage, colorspace));\n\t}\n\n\twhiteness(whiteness) {\n\t\tconst hwb = color2hwb(this.color);\n\n\t\treturn whiteness === undefined\n\t\t\t? hwb.whiteness\n\t\t: new Color(assign(hwb, { whiteness }));\n\t}\n\n\ttoHSL() {\n\t\treturn color2hslString(this.color);\n\t}\n\n\ttoHWB() {\n\t\treturn color2hwbString(this.color);\n\t}\n\n\ttoLegacy() {\n\t\treturn color2legacyString(this.color);\n\t}\n\n\ttoRGB() {\n\t\treturn color2rgbString(this.color);\n\t}\n\n\ttoRGBLegacy() {\n\t\treturn color2rgbLegacyString(this.color);\n\t}\n\n\ttoString() {\n\t\treturn color2string(this.color);\n\t}\n}\n\n/* Blending\n/* ========================================================================== */\n\nfunction blend(base, color, percentage, colorspace, isBlendingAlpha) {\n\tconst addition = percentage / 100;\n\tconst subtraction = 1 - addition;\n\n\tif (colorspace === 'hsl') {\n\t\tconst { hue: h1, saturation: s1, lightness: l1, alpha: a1 } = color2hsl(base);\n\t\tconst { hue: h2, saturation: s2, lightness: l2, alpha: a2 } = color2hsl(color);\n\n\t\tconst [hue, saturation, lightness, alpha] = [\n\t\t\th1 * subtraction + h2 * addition,\n\t\t\ts1 * subtraction + s2 * addition,\n\t\t\tl1 * subtraction + l2 * addition,\n\t\t\tisBlendingAlpha\n\t\t\t\t? a1 * subtraction + a2 * addition\n\t\t\t: a1\n\t\t];\n\n\t\treturn { hue, saturation, lightness, alpha, colorspace: 'hsl' };\n\t} else if (colorspace === 'hwb') {\n\t\tconst { hue: h1, whiteness: w1, blackness: b1, alpha: a1 } = color2hwb(base);\n\t\tconst { hue: h2, whiteness: w2, blackness: b2, alpha: a2 } = color2hwb(color);\n\n\t\tconst [hue, whiteness, blackness, alpha] = [\n\t\t\th1 * subtraction + h2 * addition,\n\t\t\tw1 * subtraction + w2 * addition,\n\t\t\tb1 * subtraction + b2 * addition,\n\t\t\tisBlendingAlpha\n\t\t\t\t? a1 * subtraction + a2 * addition\n\t\t\t: a1\n\t\t];\n\n\t\treturn { hue, whiteness, blackness, alpha, colorspace: 'hwb' };\n\t} else {\n\t\tconst { red: r1, green: g1, blue: b1, alpha: a1 } = color2rgb(base);\n\t\tconst { red: r2, green: g2, blue: b2, alpha: a2 } = color2rgb(color);\n\n\t\tconst [red, green, blue, alpha] = [\n\t\t\tr1 * subtraction + r2 * addition,\n\t\t\tg1 * subtraction + g2 * addition,\n\t\t\tb1 * subtraction + b2 * addition,\n\t\t\tisBlendingAlpha\n\t\t\t\t? a1 * subtraction + a2 * addition\n\t\t\t: a1\n\t\t];\n\n\t\treturn { red, green, blue, alpha, colorspace: 'rgb' };\n\t}\n}\n\n/* Assign channels to a new instance of a base color\n/* ========================================================================== */\n\nfunction assign(base, channels) {\n\tconst color = Object.assign({}, base);\n\n\tObject.keys(channels).forEach(\n\t\tchannel => {\n\t\t\t// detect channel\n\t\t\tconst channelIsHue = channel === 'hue';\n\t\t\tconst isRGB = !channelIsHue && blueGreenRedMatch.test(channel);\n\n\t\t\t// normalized value of the channel\n\t\t\tconst value = normalize(channels[channel], channel);\n\n\t\t\t// assign channel to new object\n\t\t\tcolor[channel] = value;\n\n\t\t\tif (isRGB) {\n\t\t\t\t// conditionally preserve the hue\n\t\t\t\tcolor.hue = rgb2hue(color.red, color.green, color.blue, base.hue || 0);\n\t\t\t}\n\t\t}\n\t);\n\n\treturn color;\n}\n\nfunction normalize(value, channel) {\n\t// detect channel\n\tconst channelIsHue = channel === 'hue';\n\n\t// value limitations\n\tconst min = 0;\n\tconst max = channelIsHue ? 360 : 100;\n\n\tconst normalizedValue = Math.min(Math.max(channelIsHue\n\t\t? value % 360\n\t: value, min), max);\n\n\treturn normalizedValue;\n}\n\n/* Convert colors\n/* ========================================================================== */\n\nfunction color2rgb(color) {\n\tconst [ red, green, blue ] = color.colorspace === 'hsl'\n\t\t? hsl2rgb(color.hue, color.saturation, color.lightness)\n\t: color.colorspace === 'hwb'\n\t\t? hwb2rgb(color.hue, color.whiteness, color.blackness)\n\t: [ color.red, color.green, color.blue ];\n\n\treturn { red, green, blue, hue: color.hue, alpha: color.alpha, colorspace: 'rgb' };\n}\n\nfunction color2hsl(color) {\n\tconst [ hue, saturation, lightness ] = color.colorspace === 'rgb'\n\t\t? rgb2hsl(color.red, color.green, color.blue, color.hue)\n\t: color.colorspace === 'hwb'\n\t\t? hwb2hsl(color.hue, color.whiteness, color.blackness)\n\t: [ color.hue, color.saturation, color.lightness ];\n\n\treturn { hue, saturation, lightness, alpha: color.alpha, colorspace: 'hsl' };\n}\n\nfunction color2hwb(color) {\n\tconst [ hue, whiteness, blackness ] = color.colorspace === 'rgb'\n\t\t? rgb2hwb(color.red, color.green, color.blue, color.hue)\n\t: color.colorspace === 'hsl'\n\t\t? hsl2hwb(color.hue, color.saturation, color.lightness)\n\t: [ color.hue, color.whiteness, color.blackness ];\n\n\treturn { hue, whiteness, blackness, alpha: color.alpha, colorspace: 'hwb' };\n}\n\n/* Contrast functions\n/* ========================================================================== */\n\nfunction contrast(color, percentage) {\n\t// https://drafts.csswg.org/css-color/#contrast-adjuster\n\tconst hwb = color2hwb(color);\n\tconst rgb = color2rgb(color);\n\n\t// compute the luminance of the color.\n\tconst luminance = rgb2luminance(rgb.red, rgb.green, rgb.blue);\n\n\t// the maximum-contrast color, if it is less than .5\n\tconst maxContrastColor = luminance < 0.5\n\t\t// hwb(X, 100%, 0%), where X is the hue angle of the color\n\t\t? { hue: hwb.hue, whiteness: 100, blackness: 0, alpha: hwb.alpha, colorspace: 'hwb' }\n\t// otherwise, hwb(X, 0%, 100%), where X is the hue angle of the color\n\t: { hue: hwb.hue, whiteness: 0, blackness: 100, alpha: hwb.alpha, colorspace: 'hwb' };\n\n\t// contrast ratio\n\tconst contrastRatio = colors2contrast(color, maxContrastColor);\n\n\tconst minContrastColor = contrastRatio > 4.5\n\t\t// the color with the smallest contrast ratio with the base color that is greater than 4.5\n\t\t? colors2contrastRatioColor(hwb, maxContrastColor)\n\t// otherwise, the maximum-contrast color\n\t: maxContrastColor;\n\n\t// color(maximum-contrast blend(minimum-contrast hwb)));\n\treturn blend(maxContrastColor, minContrastColor, percentage, 'hwb', false);\n}\n\nfunction colors2contrast(color1, color2) {\n\t// https://drafts.csswg.org/css-color/#contrast-ratio\n\tconst rgb1 = color2rgb(color1);\n\tconst rgb2 = color2rgb(color2);\n\tconst l1 = rgb2luminance(rgb1.red, rgb1.green, rgb1.blue);\n\tconst l2 = rgb2luminance(rgb2.red, rgb2.green, rgb2.blue);\n\n\treturn l1 > l2\n\t\t// if l1 is the relative luminance of the lighter of the colors\n\t\t? (l1 + 0.05) / (l2 + 0.05)\n\t// otherwise, if l2 is the relative luminance of the lighter of the colors\n\t: (l2 + 0.05) / (l1 + 0.05);\n}\n\nfunction rgb2luminance(red, green, blue) {\n\tconst [ redLuminance, greenLuminance, blueLuminance ] = [\n\t\tchannel2luminance(red),\n\t\tchannel2luminance(green),\n\t\tchannel2luminance(blue)\n\t];\n\n\t// https://drafts.csswg.org/css-color/#luminance\n\tconst luminance = 0.2126 * redLuminance + 0.7152 * greenLuminance + 0.0722 * blueLuminance;\n\n\treturn luminance;\n}\n\nfunction channel2luminance(value) {\n\t// https://drafts.csswg.org/css-color/#luminance\n\tconst luminance = value <= 0.03928 ? value / 12.92 : Math.pow((value + 0.055) /1.055, 2.4);\n\n\treturn luminance;\n}\n\n// return the smallest contrast ratio from a color and a maximum contrast (credit: @thetalecrafter)\nfunction colors2contrastRatioColor(hwb, maxHWB) {\n\tconst modifiedHWB = Object.assign({}, hwb);\n\n\t// values to be used for linear interpolations in HWB space\n\tlet minW = hwb.whiteness;\n\tlet minB = hwb.blackness;\n\tlet maxW = maxHWB.whiteness;\n\tlet maxB = maxHWB.blackness;\n\n\t// find the color with the smallest contrast ratio with the base color that is greater than 4.5\n\twhile (Math.abs(minW - maxW) > 100 || Math.abs(minB - maxB) > 100) {\n\t\tconst midW = Math.round((maxW + minW) / 2);\n\t\tconst midB = Math.round((maxB + minB) / 2);\n\n\t\tmodifiedHWB.whiteness = midW;\n\t\tmodifiedHWB.blackness = midB;\n\n\t\tif (colors2contrast(modifiedHWB, hwb) > 4.5) {\n\t\t\tmaxW = midW;\n\t\t\tmaxB = midB;\n\t\t} else {\n\t\t\tminW = midW;\n\t\t\tminB = midB;\n\t\t}\n\t}\n\n\treturn modifiedHWB;\n}\n\n/* Match\n/* ========================================================================== */\n\nconst blueGreenRedMatch = /^(blue|green|red)$/i;\n\n/* Stringifiers\n/* ========================================================================== */\n\nfunction color2string(color) {\n\treturn color.colorspace === 'hsl'\n\t\t? color2hslString(color)\n\t: color.colorspace === 'hwb'\n\t\t? color2hwbString(color)\n\t: color2rgbString(color);\n}\n\nfunction color2hslString(color) {\n\tconst hsl = color2hsl(color);\n\tconst isOpaque = hsl.alpha === 100;\n\tconst hue = hsl.hue;\n\tconst saturation = Math.round(hsl.saturation * 10000000000) / 10000000000;\n\tconst lightness = Math.round(hsl.lightness * 10000000000) / 10000000000;\n\tconst alpha = Math.round(hsl.alpha * 10000000000) / 10000000000;\n\n\treturn `hsl(${hue} ${saturation}% ${lightness}%${isOpaque\n\t\t? ''\n\t: ` / ${alpha}%`})`;\n}\n\nfunction color2hwbString(color) {\n\tconst hwb = color2hwb(color);\n\tconst isOpaque = hwb.alpha === 100;\n\tconst hue = hwb.hue;\n\tconst whiteness = Math.round(hwb.whiteness * 10000000000) / 10000000000;\n\tconst blackness = Math.round(hwb.blackness * 10000000000) / 10000000000;\n\tconst alpha = Math.round(hwb.alpha * 10000000000) / 10000000000;\n\n\treturn `hwb(${hue} ${whiteness}% ${blackness}%${isOpaque\n\t\t? ''\n\t: ` / ${alpha}%`})`;\n}\n\nfunction color2rgbString(color) {\n\tconst rgb = color2rgb(color);\n\tconst isOpaque = rgb.alpha === 100;\n\tconst red = Math.round(rgb.red * 10000000000) / 10000000000;\n\tconst green = Math.round(rgb.green * 10000000000) / 10000000000;\n\tconst blue = Math.round(rgb.blue * 10000000000) / 10000000000;\n\tconst alpha = Math.round(rgb.alpha * 10000000000) / 10000000000;\n\n\treturn `rgb(${red}% ${green}% ${blue}%${isOpaque\n\t\t? ''\n\t: ` / ${alpha}%`})`;\n}\n\nfunction color2legacyString(color) {\n\treturn color.colorspace === 'hsl'\n\t\t? color2hslLegacyString(color)\n\t: color2rgbLegacyString(color);\n}\n\nfunction color2rgbLegacyString(color) {\n\tconst rgb = color2rgb(color);\n\tconst isOpaque = rgb.alpha === 100;\n\tconst name = isOpaque ? 'rgb' : 'rgba';\n\tconst red = Math.round(rgb.red * 255 / 100);\n\tconst green = Math.round(rgb.green * 255 / 100);\n\tconst blue = Math.round(rgb.blue * 255 / 100);\n\tconst alpha = Math.round(rgb.alpha / 100 * 10000000000) / 10000000000;\n\n\treturn `${name}(${red}, ${green}, ${blue}${isOpaque\n\t\t? ''\n\t: `, ${alpha}`})`;\n}\n\nfunction color2hslLegacyString(color) {\n\tconst hsl = color2hsl(color);\n\tconst isOpaque = hsl.alpha === 100;\n\tconst name = isOpaque ? 'hsl' : 'hsla';\n\tconst hue = hsl.hue;\n\tconst saturation = Math.round(hsl.saturation * 10000000000) / 10000000000;\n\tconst lightness = Math.round(hsl.lightness * 10000000000) / 10000000000;\n\tconst alpha = Math.round(hsl.alpha / 100 * 10000000000) / 10000000000;\n\n\treturn `${name}(${hue}, ${saturation}%, ${lightness}%${isOpaque\n\t\t? ''\n\t: `, ${alpha}`})`;\n}\n","export default function manageUnresolved(node, opts, word, message) {\n\tif ('warn' === opts.unresolved) {\n\t\topts.decl.warn(opts.result, message, { word });\n\t} else if ('ignore' !== opts.unresolved) {\n\t\tthrow opts.decl.error(message, { word });\n\t}\n}\n","// tooling\nimport { convertDtoD, convertGtoD, convertRtoD, convertTtoD, convertNtoRGB, convertHtoRGB } from './conversions';\nimport Color from './color';\nimport manageUnresolved from './manage-unresolved';\nimport parser from 'postcss-value-parser';\n\n/* Transform AST\n/* ========================================================================== */\n\nexport default function transformAST(node, opts) {\n\tnode.nodes.slice(0).forEach((child, index) => {\n\t\tif (isColorModFunction(child)) {\n\t\t\t// transform any variables within the color-mod() function\n\t\t\tif (opts.transformVars) {\n\t\t\t\ttransformVariables(child, opts);\n\t\t\t}\n\n\t\t\t// transform any color-mod() functions\n\t\t\tconst color = transformColorModFunction(child, opts);\n\n\t\t\tif (color) {\n\t\t\t\t// update the color-mod() function with the transformed value\n\t\t\t\tnode.nodes.splice(index, 1, {\n\t\t\t\t\ttype: 'word',\n\t\t\t\t\tvalue: opts.stringifier(color)\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (child.nodes && Object(child.nodes).length) {\n\t\t\ttransformAST(child, opts);\n\t\t}\n\t});\n}\n\n/* Transform functions\n/* ========================================================================== */\n\nfunction transformVariables(node, opts) {\n\tparser.walk(node.nodes, (child, index, nodes) => {\n\t\tif (isVariable(child)) {\n\t\t\t// get the custom property and fallback value from var()\n\t\t\tconst [prop, fallbackNode] = transformArgsByParams(child, [\n\t\t\t\t// , [ ]?\n\t\t\t\t[transformWord, isComma, transformNode]\n\t\t\t]);\n\n\t\t\t// if the custom property is known\n\t\t\tif (prop in opts.customProperties) {\n\t\t\t\tlet customPropertyValue = opts.customProperties[prop];\n\n\t\t\t\t// follow custom properties referencing custom properties\n\t\t\t\tif (looseVarMatch.test(parser.stringify(customPropertyValue))) {\n\t\t\t\t\tconst rootChildAST = JSON.parse(JSON.stringify({ nodes: customPropertyValue.nodes }));\n\n\t\t\t\t\ttransformVariables(rootChildAST, opts);\n\n\t\t\t\t\tcustomPropertyValue = rootChildAST;\n\t\t\t\t}\n\n\t\t\t\t// replace var() with the custom property value\n\t\t\t\tif (customPropertyValue.nodes.length) {\n\t\t\t\t\tnodes.splice(index, 0, ...JSON.parse(JSON.stringify(customPropertyValue.nodes)));\n\t\t\t\t}\n\n\t\t\t\tnodes.splice(nodes.indexOf(child), 1);\n\t\t\t} else if (fallbackNode && fallbackNode.nodes.length === 1 && fallbackNode.nodes[0].nodes.length) {\n\t\t\t\t// otherwise, replace var() with the fallback value\n\t\t\t\ttransformVariables(fallbackNode, opts);\n\n\t\t\t\tnodes.splice(index, 1, ...fallbackNode.nodes[0].nodes[0]);\n\t\t\t}\n\t\t}\n\t});\n}\n\n/* Transform functions\n/* ========================================================================== */\n\nfunction transformColor(node, opts) {\n\tif (isRGBFunction(node)) {\n\t\treturn transformRGBFunction(node, opts);\n\t} else if (isHSLFunction(node)) {\n\t\treturn transformHSLFunction(node, opts);\n\t} else if (isHWBFunction(node)) {\n\t\treturn transformHWBFunction(node, opts);\n\t} else if (isColorModFunction(node)) {\n\t\treturn transformColorModFunction(node, opts);\n\t} else if (isHexColor(node)) {\n\t\treturn transformHexColor(node, opts);\n\t} else if (isNamedColor(node)) {\n\t\treturn transformNamedColor(node, opts);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a color`);\n\t}\n}\n\n// return a transformed rgb/rgba color function\nfunction transformRGBFunction(node, opts) {\n\tconst [red, green, blue, alpha = 100] = transformArgsByParams(node, [\n\t\t// [ , ]?\n\t\t[transformPercentage, transformPercentage, transformPercentage, isSlash, transformAlpha],\n\t\t// [ , ]?\n\t\t[transformRGBNumber, transformRGBNumber, transformRGBNumber, isSlash, transformAlpha],\n\t\t// , , [ , ]?\n\t\t[transformPercentage, isComma, transformPercentage, isComma, transformPercentage, isComma, transformAlpha],\n\t\t// , , [ , ]?\n\t\t[transformRGBNumber, isComma, transformRGBNumber, isComma, transformRGBNumber, isComma, transformAlpha]\n\t]);\n\n\tif (red !== undefined) {\n\t\tconst color = new Color({ red, green, blue, alpha, colorspace: 'rgb' });\n\n\t\treturn color;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid rgb() function`);\n\t}\n}\n\n// return a transformed hsl/hsla color function\nfunction transformHSLFunction(node, opts) {\n\tconst [hue, saturation, lightness, alpha = 100] = transformArgsByParams(node, [\n\t\t// [ / ]?\n\t\t[transformHue, transformPercentage, transformPercentage, isSlash, transformAlpha],\n\t\t// , , [ , ]?\n\t\t[transformHue, isComma, transformPercentage, isComma, transformPercentage, isComma, transformAlpha]\n\t]);\n\n\tif (lightness !== undefined) {\n\t\tconst color = new Color({ hue, saturation, lightness, alpha, colorspace: 'hsl' });\n\n\t\treturn color;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid hsl() function`);\n\t}\n}\n\n// return a transformed hwb color function\nfunction transformHWBFunction(node, opts) {\n\tconst [hue, whiteness, blackness, alpha = 100] = transformArgsByParams(node, [\n\t\t// [ / ]?\n\t\t[transformHue, transformPercentage, transformPercentage, isSlash, transformAlpha]\n\t]);\n\n\tif (blackness !== undefined) {\n\t\tconst color = new Color({ hue, whiteness, blackness, alpha, colorspace: 'hwb' });\n\n\t\treturn color;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid hwb() function`);\n\t}\n}\n\n// return a transformed color-mod color function\nfunction transformColorModFunction(node, opts) {\n\t// [ | ] *\n\tconst [colorOrHueNode, ...adjusterNodes] = node.nodes || [];\n\n\tif (colorOrHueNode !== undefined) {\n\t\tconst color = isHue(colorOrHueNode)\n\t\t\t? new Color({\n\t\t\t\thue: transformHue(colorOrHueNode, opts),\n\t\t\t\tsaturation: 100,\n\t\t\t\tlightness: 50,\n\t\t\t\talpha: 100,\n\t\t\t\tcolorspace: 'hsl'\n\t\t\t})\n\t\t: transformColor(colorOrHueNode, opts);\n\n\t\tif (color) {\n\t\t\tconst adjustedColor = transformColorByAdjusters(color, adjusterNodes, opts);\n\n\t\t\treturn adjustedColor;\n\t\t} else {\n\t\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid color`);\n\t\t}\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid color-mod() function`);\n\t}\n}\n\n// return a transformed hex color\nfunction transformHexColor(node, opts) {\n\tif (hexColorMatch.test(node.value)) {\n\t\t// #{3,4,6,8}\n\t\tconst [red, green, blue, alpha] = convertHtoRGB(node.value);\n\n\t\tconst color = new Color({ red, green, blue, alpha });\n\n\t\treturn color;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid hex color`);\n\t}\n}\n\n// return a transformed named-color\nfunction transformNamedColor(node, opts) {\n\tif (isNamedColor(node)) {\n\t\t// \n\t\tconst [red, green, blue] = convertNtoRGB(node.value);\n\n\t\tconst color = new Color({ red, green, blue, alpha: 100, colorspace: 'rgb' });\n\n\t\treturn color;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid named-color`);\n\t}\n}\n\n/* Transform functions\n/* ========================================================================== */\n\n// return a transformed color using adjustments\nfunction transformColorByAdjusters(color, adjusterNodes, opts) {\n\tconst adjustedColor = adjusterNodes.filter((node) => {\n\t\treturn node.type !== 'space' && node.type !== 'comment';\n\t}).reduce((base, node) => {\n\t\tif (isAlphaBlueGreenRedAdjuster(node)) {\n\t\t\treturn transformAlphaBlueGreenRedAdjuster(base, node, opts);\n\t\t} else if (isRGBAdjuster(node)) {\n\t\t\treturn transformRGBAdjuster(base, node, opts);\n\t\t} else if (isHueAdjuster(node)) {\n\t\t\treturn transformHueAdjuster(base, node, opts);\n\t\t} else if (isBlacknessLightnessSaturationWhitenessAdjuster(node)) {\n\t\t\treturn transformBlacknessLightnessSaturationWhitenessAdjuster(base, node, opts);\n\t\t} else if (isShadeTintAdjuster(node)) {\n\t\t\treturn transformShadeTintAdjuster(base, node, opts);\n\t\t} else if (isBlendAdjuster(node)) {\n\t\t\treturn transformBlendAdjuster(base, node, node.value === 'blenda', opts);\n\t\t} else if (isContrastAdjuster(node)) {\n\t\t\treturn transformContrastAdjuster(base, node, opts);\n\t\t} else {\n\t\t\tmanageUnresolved(node, opts, node.value, `Expected a valid color adjuster`);\n\n\t\t\treturn base;\n\t\t}\n\t}, color);\n\n\treturn adjustedColor;\n}\n\n// return a transformed color using a/alpha/blue/green/red adjustments\nfunction transformAlphaBlueGreenRedAdjuster(base, node, opts) {\n\tconst [operatorOrValue, adjustment] = transformArgsByParams(node, alphaMatch.test(node.value)\n\t\t\t// a/alpha adjustments\n\t\t\t? [\n\t\t\t\t// [ + | - ] \n\t\t\t\t[transformMinusPlusOperator, transformAlpha],\n\t\t\t\t// * \n\t\t\t\t[transformTimesOperator, transformPercentage],\n\t\t\t\t// \n\t\t\t\t[transformAlpha]\n\t\t\t]\n\t\t// blue/green/red adjustments\n\t\t: [\n\t\t\t// [ + | - ] \n\t\t\t[transformMinusPlusOperator, transformPercentage],\n\t\t\t// [ + | - ] \n\t\t\t[transformMinusPlusOperator, transformRGBNumber],\n\t\t\t// * \n\t\t\t[transformTimesOperator, transformPercentage],\n\t\t\t// \n\t\t\t[transformPercentage],\n\t\t\t// \n\t\t\t[transformRGBNumber]\n\t\t]\n\t);\n\n\tif (operatorOrValue !== undefined) {\n\t\t// normalized channel name\n\t\tconst channel = node.value.toLowerCase().replace(alphaMatch, 'alpha');\n\n\t\tconst existingValue = base[channel]();\n\n\t\tconst modifiedValue = adjustment !== undefined\n\t\t\t? operatorOrValue === '+'\n\t\t\t\t? existingValue + Number(adjustment)\n\t\t\t: operatorOrValue === '-'\n\t\t\t\t? existingValue - Number(adjustment)\n\t\t\t: operatorOrValue === '*'\n\t\t\t\t? existingValue * Number(adjustment)\n\t\t\t: Number(adjustment)\n\t\t: Number(operatorOrValue);\n\n\t\tconst modifiedColor = base[channel](modifiedValue);\n\n\t\treturn modifiedColor;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid modifier()`);\n\t}\n}\n\n// return a transformed color using an rgb adjustment\nfunction transformRGBAdjuster(base, node, opts) {\n\tconst [arg1, arg2, arg3, arg4] = transformArgsByParams(node, [\n\t\t\t// [ + | - ] \n\t\t\t[transformMinusPlusOperator, transformPercentage, transformPercentage, transformPercentage],\n\t\t\t// [ + | - ] \n\t\t\t[transformMinusPlusOperator, transformRGBNumber, transformRGBNumber, transformRGBNumber],\n\t\t\t// [ + | - ] \n\t\t\t[transformMinusPlusOperator, transformHexColor],\n\t\t\t// [ * ] \n\t\t\t[transformTimesOperator, transformPercentage]\n\t\t]\n\t);\n\n\tif (arg2 !== undefined && arg2.color) {\n\t\tconst modifiedColor = base.rgb(\n\t\t\targ1 === '+'\n\t\t\t\t? base.red() + arg2.red()\n\t\t\t: base.red() - arg2.red(),\n\t\t\targ1 === '+'\n\t\t\t\t? base.green() + arg2.green()\n\t\t\t: base.green() - arg2.green(),\n\t\t\targ1 === '+'\n\t\t\t\t? base.blue() + arg2.blue()\n\t\t\t: base.blue() - arg2.blue()\n\t\t);\n\n\t\treturn modifiedColor;\n\t} else if (arg1 !== undefined && minusPlusMatch.test(arg1)) {\n\t\tconst modifiedColor = base.rgb(\n\t\t\targ1 === '+'\n\t\t\t\t? base.red() + arg2\n\t\t\t: base.red() - arg2,\n\t\t\targ1 === '+'\n\t\t\t\t? base.green() + arg3\n\t\t\t: base.green() - arg3,\n\t\t\targ1 === '+'\n\t\t\t\t? base.blue() + arg4\n\t\t\t: base.blue() - arg4\n\t\t);\n\n\t\treturn modifiedColor;\n\t} else if (arg1 !== undefined && arg2 !== undefined) {\n\t\tconst modifiedColor = base.rgb(\n\t\t\tbase.red() * arg2,\n\t\t\tbase.green() * arg2,\n\t\t\tbase.blue() * arg2\n\t\t);\n\n\t\treturn modifiedColor;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid rgb() adjuster`);\n\t}\n}\n\n// return a transformed color using a blend/blenda adjustment\nfunction transformBlendAdjuster(base, node, isAlphaBlend, opts) {\n\tconst [color, percentage, colorspace = 'rgb'] = transformArgsByParams(node, [\n\t\t[transformColor, transformPercentage, transformColorSpace]\n\t]);\n\n\tif (percentage !== undefined) {\n\t\tconst modifiedColor = isAlphaBlend\n\t\t\t? base.blenda(color.color, percentage, colorspace)\n\t\t: base.blend(color.color, percentage, colorspace);\n\n\t\treturn modifiedColor;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid blend() adjuster)`);\n\t}\n}\n\n// return a transformed color using a contrast adjustment\nfunction transformContrastAdjuster(base, node, opts) {\n\tconst [percentage] = transformArgsByParams(node, [\n\t\t// \n\t\t[transformPercentage]\n\t]);\n\n\tif (percentage !== undefined) {\n\t\tconst modifiedColor = base.contrast(percentage);\n\n\t\treturn modifiedColor;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid contrast() adjuster)`);\n\t}\n}\n\n// return a transformed color using a hue adjustment\nfunction transformHueAdjuster(base, node, opts) {\n\tconst [operatorOrHue, adjustment] = transformArgsByParams(node, [\n\t\t// [ + | - | * ] \n\t\t[transformMinusPlusTimesOperator, transformHue],\n\t\t// \n\t\t[transformHue]\n\t]);\n\n\tif (operatorOrHue !== undefined) {\n\t\tconst existingHue = base.hue();\n\n\t\tconst modifiedValue = adjustment !== undefined\n\t\t\t? operatorOrHue === '+'\n\t\t\t\t? existingHue + Number(adjustment)\n\t\t\t: operatorOrHue === '-'\n\t\t\t\t? existingHue - Number(adjustment)\n\t\t\t: operatorOrHue === '*'\n\t\t\t\t? existingHue * Number(adjustment)\n\t\t\t: Number(adjustment)\n\t\t: Number(operatorOrHue);\n\n\t\treturn base.hue(modifiedValue);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid hue() function)`);\n\t}\n}\n\n// [ b | blackness | l | lightness | s | saturation | w | whiteness ]( [ + | - | * ]? )\nfunction transformBlacknessLightnessSaturationWhitenessAdjuster(base, node, opts) {\n\tconst channel = node.value.toLowerCase().replace(/^b$/, 'blackness').replace(/^l$/, 'lightness').replace(/^s$/, 'saturation').replace(/^w$/, 'whiteness');\n\tconst [operatorOrValue, adjustment] = transformArgsByParams(node, [\n\t\t[transformMinusPlusTimesOperator, transformPercentage],\n\t\t[transformPercentage]\n\t]);\n\n\tif (operatorOrValue !== undefined) {\n\t\tconst existingValue = base[channel]();\n\n\t\tconst modifiedValue = adjustment !== undefined\n\t\t\t? operatorOrValue === '+'\n\t\t\t\t? existingValue + Number(adjustment)\n\t\t\t: operatorOrValue === '-'\n\t\t\t\t? existingValue - Number(adjustment)\n\t\t\t: operatorOrValue === '*'\n\t\t\t\t? existingValue * Number(adjustment)\n\t\t\t: Number(adjustment)\n\t\t: Number(operatorOrValue);\n\n\t\treturn base[channel](modifiedValue);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid ${channel}() function)`);\n\t}\n}\n\n// return a transformed color using shade/tint adjustments\nfunction transformShadeTintAdjuster(base, node, opts) {\n\tconst channel = node.value.toLowerCase();\n\tconst [percentage] = transformArgsByParams(node, [\n\t\t// [ shade | tint ]( )\n\t\t[transformPercentage]\n\t]);\n\n\tif (percentage !== undefined) {\n\t\tconst modifiedValue = Number(percentage);\n\n\t\treturn base[channel](modifiedValue);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected valid ${channel}() arguments`);\n\t}\n}\n\n/* Argument Transforms\n/* ========================================================================== */\n\n// return a transformed color space\nfunction transformColorSpace(node, opts) {\n\tif (isColorSpace(node)) {\n\t\t// [ hsl | hwb | rgb ]\n\t\treturn node.value;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid color space)`);\n\t}\n}\n\n// return a transformed alpha value\nfunction transformAlpha(node, opts) {\n\tif (isNumber(node)) {\n\t\t// \n\t\treturn Number(parser.unit(node.value).number) * 100;\n\t} else if (isPercentage(node)) {\n\t\t// \n\t\treturn transformPercentage(node, opts);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid alpha value)`);\n\t}\n}\n\n// return a transformed rgb number\nfunction transformRGBNumber(node, opts) {\n\tif (isNumber(node)) {\n\t\t// \n\t\treturn node.value / 2.55;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid RGB value)`);\n\t}\n}\n\n// return a transformed hue\nfunction transformHue(node, opts) {\n\tif (isHue(node)) {\n\t\t// = | \n\t\tconst unit = parser.unit(node.value).unit.toLowerCase();\n\n\t\tif (unit === 'grad') {\n\t\t\t// if = (400 per circle)\n\t\t\treturn convertGtoD(Number(parser.unit(node.value).number));\n\t\t} else if (unit === 'rad') {\n\t\t\t// if = (2π per circle)\n\t\t\treturn convertRtoD(Number(parser.unit(node.value).number));\n\t\t} else if (unit === 'turn') {\n\t\t\t// if = (1 per circle)\n\t\t\treturn convertTtoD(Number(parser.unit(node.value).number));\n\t\t} else {\n\t\t\t// if = [ | ] (360 per circle)\n\t\t\treturn convertDtoD(Number(parser.unit(node.value).number));\n\t\t}\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid hue`);\n\t}\n}\n\n// return a transformed percentage\nfunction transformPercentage(node, opts) {\n\tif (isPercentage(node)) {\n\t\t// \n\t\treturn Number(parser.unit(node.value).number);\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid percentage`);\n\t}\n}\n\n// return a transformed minus-plus operator\nfunction transformMinusPlusOperator(node, opts) {\n\tif (isMinusPlusOperator(node)) {\n\t\t// [ - | + ]\n\t\treturn node.value;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a plus or minus operator`);\n\t}\n}\n\n// return a transformed times operator\nfunction transformTimesOperator(node, opts) {\n\tif (isTimesOperator(node)) {\n\t\t// [ * ]\n\t\treturn node.value;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a times operator`);\n\t}\n}\n\n// return a transformed minus-plus-times operator\nfunction transformMinusPlusTimesOperator(node, opts) {\n\tif (isMinusPlusTimesOperator(node)) {\n\t\t// [ - | + | * ]\n\t\treturn node.value;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a plus, minus, or times operator`);\n\t}\n}\n\n/* Additional transforms\n/* ========================================================================== */\n\nfunction transformWord(node, opts) {\n\tif (isWord(node)) {\n\t\treturn node.value;\n\t} else {\n\t\treturn manageUnresolved(node, opts, node.value, `Expected a valid word`);\n\t}\n}\n\nfunction transformNode(node) {\n\treturn Object(node);\n}\n\n/* Transform helper\n/* ========================================================================== */\n\n// return the first set of transformed arguments allowable by the parameters\nfunction transformArgsByParams(node, params) {\n\tconst nodes = (node.nodes || []).filter((node) => {\n\t\treturn node.type !== 'space' && node.type !== 'comment';\n\t});\n\tconst opts = { unresolved: 'ignore' };\n\n\treturn params.map((param) => {\n\t\treturn nodes.map((childNode, index) => {\n\t\t\treturn typeof param[index] === 'function' ? param[index](childNode, opts) : undefined\n\t\t}).filter((child) => {\n\t\t\treturn typeof child !== 'boolean'\n\t\t})\n\t}).filter((param) => {\n\t\treturn param.every((result) => {\n\t\t\treturn result !== undefined\n\t\t})\n\t})[0] || [];\n}\n\n/* Variable validators\n/* ========================================================================== */\n\n// return whether the node is a var function\nfunction isVariable(node) {\n\t// var()\n\treturn Object(node).type === 'function' && varMatch.test(node.value);\n}\n\n/* Adjustment validators\n/* ========================================================================== */\n\n// return whether the node is an a/alpha/blue/green/red adjuster\nfunction isAlphaBlueGreenRedAdjuster(node) {\n\t// [ a(), alpha(), blue(), green(), red() ]\n\treturn Object(node).type === 'function' && alphaBlueGreenRedMatch.test(node.value);\n}\n\n// return whether the node is an rgb adjuster\nfunction isRGBAdjuster(node) {\n\treturn Object(node).type === 'function' && rgbMatch.test(node.value);\n}\n\n// return whether the node is a hue adjuster\nfunction isHueAdjuster(node) {\n\t// [ h() | hue() ]\n\treturn Object(node).type === 'function' && hueMatch.test(node.value);\n}\n\n// return whether the node is a blackness/lightness/saturation/whiteness adjuster\nfunction isBlacknessLightnessSaturationWhitenessAdjuster(node) {\n\t// [ b() | blackness() | l() | lightness() | s() | saturation() | w() | whiteness() ]\n\treturn Object(node).type === 'function' && blacknessLightnessSaturationWhitenessMatch.test(node.value);\n}\n\n// return whether the node is a shade/tint adjuster\nfunction isShadeTintAdjuster(node) {\n\t// [ shade() | tint() ]\n\treturn Object(node).type === 'function' && shadeTintMatch.test(node.value);\n}\n\n// return whether the node is a blend adjuster\nfunction isBlendAdjuster(node) {\n\t// [ blend(), blenda() ]\n\treturn Object(node).type === 'function' && blendMatch.test(node.value);\n}\n\n// return whether the node is a contrast adjuster\nfunction isContrastAdjuster(node) {\n\t// [ contrast() ]\n\treturn Object(node).type === 'function' && contrastMatch.test(node.value);\n}\n\n/* Color validators\n/* ========================================================================== */\n\n// return whether the node is an rgb/rgba color function\nfunction isRGBFunction(node) {\n\t// [ rgb(), rgba() ]\n\treturn Object(node).type === 'function' && rgbaMatch.test(node.value);\n}\n\n// return whether the node is an hsl color function\nfunction isHSLFunction(node) {\n\t// [ hsl(), hsla() ]\n\treturn Object(node).type === 'function' && hslaMatch.test(node.value);\n}\n\n// return whether the node is an hwb color function\nfunction isHWBFunction(node) {\n\t// hwb()\n\treturn Object(node).type === 'function' && hwbMatch.test(node.value);\n}\n\n// return whether the node is a color-mod function\nfunction isColorModFunction(node) {\n\t// color-mod()\n\treturn Object(node).type === 'function' && colorModMatch.test(node.value);\n}\n\n// return whether the node is a valid named-color\nfunction isNamedColor(node) {\n\treturn Object(node).type === 'word' && Boolean(convertNtoRGB(node.value));\n}\n\n// return whether the node is a valid hex color\nfunction isHexColor(node) {\n\t// #{3,4,6,8}\n\treturn Object(node).type === 'word' && hexColorMatch.test(node.value);\n}\n\n// return whether the node is a valid color space\nfunction isColorSpace(node) {\n\t// [ hsl | hwb | rgb ]\n\treturn Object(node).type === 'word' && colorSpaceMatch.test(node.value);\n}\n\n/* Additional validators\n/* ========================================================================== */\n\n// return whether the hue value is valid\nfunction isHue(node) {\n\tif (Object(node).type !== 'word') {\n\t\treturn false;\n\t}\n\n\tconst parsedNumber = parser.unit(node.value);\n\treturn parsedNumber && hueUnitMatch.test(parsedNumber.unit);\n}\n\n// return whether the comma is valid\nfunction isComma(node) {\n\treturn Object(node).type === 'div' && node.value === ',';\n}\n\n// return whether the slash operator is valid\nfunction isSlash(node) {\n\treturn Object(node).type === 'div' && node.value === '/';\n}\n\n// return whether the number is valid\nfunction isNumber(node) {\n\tif (Object(node).type !== 'word') {\n\t\treturn false;\n\t}\n\n\tconst parsedNumber = parser.unit(node.value);\n\treturn parsedNumber && parsedNumber.unit === '';\n}\n\n// return whether the mind-plus operator is valid\nfunction isMinusPlusOperator(node) {\n\treturn Object(node).type === 'word' && minusPlusMatch.test(node.value);\n}\n\n// return whether the minus-plus-times operator is valid\nfunction isMinusPlusTimesOperator(node) {\n\treturn Object(node).type === 'word' && minusPlusTimesMatch.test(node.value);\n}\n\n// return whether the times operator is valid\nfunction isTimesOperator(node) {\n\treturn Object(node).type === 'word' && timesMatch.test(node.value);\n}\n\n// return whether the percentage is valid\nfunction isPercentage(node) {\n\tif (Object(node).type !== 'word') {\n\t\treturn false;\n\t}\n\n\tconst parsedNumber = parser.unit(node.value);\n\treturn parsedNumber && (parsedNumber.unit === '%' || parseFloat(parsedNumber.number) === 0);\n}\n\n// return whether the node is a word\nfunction isWord(node) {\n\t// \n\treturn Object(node).type === 'word';\n}\n\n/* Matchers\n/* ========================================================================== */\n\nconst alphaMatch = /^a(lpha)?$/i;\nconst alphaBlueGreenRedMatch = /^(a(lpha)?|blue|green|red)$/i;\nconst blacknessLightnessSaturationWhitenessMatch = /^(b(lackness)?|l(ightness)?|s(aturation)?|w(hiteness)?)$/i;\nconst blendMatch = /^blenda?$/i;\nconst colorModMatch = /^color-mod$/i;\nconst colorSpaceMatch = /^(hsl|hwb|rgb)$/i;\nconst contrastMatch = /^contrast$/i;\nconst hexColorMatch = /^#(?:([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?|([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?)$/i;\nconst hslaMatch = /^hsla?$/i;\nconst hueUnitMatch = /^(deg|grad|rad|turn)?$/i;\nconst hueMatch = /^h(ue)?$/i;\nconst hwbMatch = /^hwb$/i;\nconst minusPlusMatch = /^[+-]$/;\nconst minusPlusTimesMatch = /^[*+-]$/;\nconst rgbMatch = /^rgb$/i;\nconst rgbaMatch = /^rgba?$/i;\nconst shadeTintMatch = /^(shade|tint)$/i;\nconst varMatch = /^var$/i;\nconst looseVarMatch = /(^|[^\\w-])var\\(/i;\nconst timesMatch = /^[*]$/;\n","import getCustomProperties from './lib/get-custom-properties';\nimport importCustomPropertiesFromSources from './lib/import-from';\nimport parser from 'postcss-value-parser';\nimport transformAST from './lib/transform';\n\nmodule.exports = (opts = {}) => {\n\t// how unresolved functions and arguments should be handled (default: \"throw\")\n\tconst unresolvedOpt = String(Object(opts).unresolved || 'throw').toLowerCase();\n\n\t// how transformed colors will be produced in CSS\n\tconst stringifierOpt = Object(opts).stringifier || (color => color.toLegacy());\n\n\t// sources to import custom selectors from\n\tconst importFrom = [].concat(Object(opts).importFrom || []);\n\n\t// whether var() within color-mod() should use Custom Properties or var() fallback\n\tconst transformVarsOpt = 'transformVars' in Object(opts) ? opts.transformVars : true;\n\n\t// promise any custom selectors are imported\n\tconst customPropertiesPromise = importCustomPropertiesFromSources(importFrom);\n\n\treturn {\n\t\tpostcssPlugin: 'postcss-color-mod-function',\n\t\tasync Once (root, { result }) {\n\t\t\tconst customProperties = Object.assign(\n\t\t\t\tawait customPropertiesPromise,\n\t\t\t\tgetCustomProperties(root, { preserve: true })\n\t\t\t);\n\n\t\t\troot.walkDecls(decl => {\n\t\t\t\tconst originalValue = decl.value;\n\n\t\t\t\tif (colorModFunctionMatch.test(originalValue)) {\n\t\t\t\t\tconst ast = parser(originalValue);\n\n\t\t\t\t\ttransformAST(ast, {\n\t\t\t\t\t\tunresolved: unresolvedOpt,\n\t\t\t\t\t\tstringifier: stringifierOpt,\n\t\t\t\t\t\ttransformVars: transformVarsOpt,\n\t\t\t\t\t\tdecl,\n\t\t\t\t\t\tresult,\n\t\t\t\t\t\tcustomProperties\n\t\t\t\t\t});\n\n\t\t\t\t\tconst modifiedValue = parser.stringify(ast);\n\n\t\t\t\t\tif (originalValue !== modifiedValue) {\n\t\t\t\t\t\tdecl.value = modifiedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n};\n\nmodule.exports.postcss = true;\n\nconst colorModFunctionMatch = /(^|[^\\w-])color-mod\\(/i;\n"],"names":["valueParser","hexColorMatch"],"mappings":";;;;;;AAEA;AACe,SAAS,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE;AACxD;AACA,CAAC,MAAM,+BAA+B,GAAG,EAAE;AAC3C,CAAC,MAAM,8BAA8B,GAAG,EAAE;;AAE1C;AACA,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI;AACpC,EAAE,MAAM,sBAAsB,GAAG,UAAU,CAAC,IAAI;AAChD,KAAK;AACL,IAAI,UAAU,CAAC,IAAI;AACnB,KAAK;AACL,IAAI,IAAI;;AAER;AACA,EAAE,IAAI,sBAAsB,EAAE;AAC9B,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,IAAI;AACtC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE;AAC5B,KAAK,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI;;AAE1B;AACA,KAAK,sBAAsB,CAAC,IAAI,CAAC,GAAGA,MAAW,CAAC,IAAI,CAAC,KAAK,CAAC;;AAE3D;AACA,KAAK,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;AACzB,MAAM,IAAI,CAAC,MAAM,EAAE;AACnB;AACA;AACA,IAAI,CAAC;;AAEL;AACA,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE;AAC9C,IAAI,IAAI,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,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;;AAEhD,KAAK,IAAI,aAAa,KAAK,aAAa,EAAE;AAC1C,MAAM,IAAI,CAAC,KAAK,GAAG,aAAa;AAChC;AACA;AACA,IAAI,CAAC;AACL;AACA,EAAE;AACF,CAAC;;AAED,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,IAAI;;AAE7B,MAAM,qBAAqB,GAAG,wBAAwB"} \ No newline at end of file diff --git a/index.js b/index.js index a42d053..a5f5ed4 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,9 @@ import getCustomProperties from './lib/get-custom-properties'; import importCustomPropertiesFromSources from './lib/import-from'; -import parser from 'postcss-values-parser'; -import postcss from 'postcss'; +import parser from 'postcss-value-parser'; import transformAST from './lib/transform'; -export default postcss.plugin('postcss-color-mod-function', opts => { +module.exports = (opts = {}) => { // how unresolved functions and arguments should be handled (default: "throw") const unresolvedOpt = String(Object(opts).unresolved || 'throw').toLowerCase(); @@ -14,41 +13,46 @@ export default postcss.plugin('postcss-color-mod-function', opts => { // sources to import custom selectors from const importFrom = [].concat(Object(opts).importFrom || []); - // whether var() within color-mod() should use Custom Properties or var() fallback + // whether var() within color-mod() should use Custom Properties or var() fallback const transformVarsOpt = 'transformVars' in Object(opts) ? opts.transformVars : true; // promise any custom selectors are imported const customPropertiesPromise = importCustomPropertiesFromSources(importFrom); - return async (root, result) => { - const customProperties = Object.assign( - await customPropertiesPromise, - getCustomProperties(root, { preserve: true }) - ); - - root.walkDecls(decl => { - const originalValue = decl.value; - - if (colorModFunctionMatch.test(originalValue)) { - const ast = parser(originalValue, { loose: true }).parse(); - - transformAST(ast, { - unresolved: unresolvedOpt, - stringifier: stringifierOpt, - transformVars: transformVarsOpt, - decl, - result, - customProperties - }); - - const modifiedValue = ast.toString(); - - if (originalValue !== modifiedValue) { - decl.value = modifiedValue; + return { + postcssPlugin: 'postcss-color-mod-function', + async Once (root, { result }) { + const customProperties = Object.assign( + await customPropertiesPromise, + getCustomProperties(root, { preserve: true }) + ); + + root.walkDecls(decl => { + const originalValue = decl.value; + + if (colorModFunctionMatch.test(originalValue)) { + const ast = parser(originalValue); + + transformAST(ast, { + unresolved: unresolvedOpt, + stringifier: stringifierOpt, + transformVars: transformVarsOpt, + decl, + result, + customProperties + }); + + const modifiedValue = parser.stringify(ast); + + if (originalValue !== modifiedValue) { + decl.value = modifiedValue; + } } - } - }); + }); + } }; -}); +}; + +module.exports.postcss = true; const colorModFunctionMatch = /(^|[^\w-])color-mod\(/i; diff --git a/lib/color.js b/lib/color.js index f37ae4b..51228fe 100644 --- a/lib/color.js +++ b/lib/color.js @@ -221,8 +221,8 @@ function assign(base, channels) { Object.keys(channels).forEach( channel => { // detect channel - const isHue = channel === 'hue'; - const isRGB = !isHue && blueGreenRedMatch.test(channel); + const channelIsHue = channel === 'hue'; + const isRGB = !channelIsHue && blueGreenRedMatch.test(channel); // normalized value of the channel const value = normalize(channels[channel], channel); @@ -242,13 +242,13 @@ function assign(base, channels) { function normalize(value, channel) { // detect channel - const isHue = channel === 'hue'; + const channelIsHue = channel === 'hue'; // value limitations const min = 0; - const max = isHue ? 360 : 100; + const max = channelIsHue ? 360 : 100; - const normalizedValue = Math.min(Math.max(isHue + const normalizedValue = Math.min(Math.max(channelIsHue ? value % 360 : value, min), max); diff --git a/lib/get-custom-properties.js b/lib/get-custom-properties.js index 62b25cc..333be3b 100644 --- a/lib/get-custom-properties.js +++ b/lib/get-custom-properties.js @@ -1,4 +1,4 @@ -import valueParser from 'postcss-values-parser'; +import valueParser from 'postcss-value-parser'; // return custom selectors from the css root, conditionally removing them export default function getCustomProperties(root, opts) { @@ -21,7 +21,7 @@ export default function getCustomProperties(root, opts) { const { prop } = decl; // write the parsed value to the custom property - customPropertiesObject[prop] = valueParser(decl.value).parse(); + customPropertiesObject[prop] = valueParser(decl.value); // conditionally remove the custom property declaration if (!opts.preserve) { diff --git a/lib/import-from.js b/lib/import-from.js index c80bc48..323dfb2 100644 --- a/lib/import-from.js +++ b/lib/import-from.js @@ -2,7 +2,7 @@ import fs from 'fs'; import path from 'path'; import postcss from 'postcss'; import getCustomProperties from './get-custom-properties'; -import valueParser from 'postcss-values-parser'; +import valueParser from 'postcss-value-parser'; /* Import Custom Properties from CSS AST /* ========================================================================== */ @@ -31,7 +31,7 @@ function importCustomPropertiesFromObject(object) { ); for (const prop in customProperties) { - customProperties[prop] = valueParser(customProperties[prop]).parse(); + customProperties[prop] = valueParser(customProperties[prop]); } return customProperties; @@ -52,7 +52,7 @@ async function importCustomPropertiesFromJSONFile(from) { async function importCustomPropertiesFromJSFile(from) { const object = await import(from); - return importCustomPropertiesFromObject(object); + return importCustomPropertiesFromObject(('default' in object) ? object.default : object); } /* Import Custom Properties from Sources diff --git a/lib/transform.js b/lib/transform.js index d8c3369..dae81ba 100644 --- a/lib/transform.js +++ b/lib/transform.js @@ -2,13 +2,13 @@ import { convertDtoD, convertGtoD, convertRtoD, convertTtoD, convertNtoRGB, convertHtoRGB } from './conversions'; import Color from './color'; import manageUnresolved from './manage-unresolved'; -import parser from 'postcss-values-parser'; +import parser from 'postcss-value-parser'; /* Transform AST /* ========================================================================== */ export default function transformAST(node, opts) { - node.nodes.slice(0).forEach(child => { + node.nodes.slice(0).forEach((child, index) => { if (isColorModFunction(child)) { // transform any variables within the color-mod() function if (opts.transformVars) { @@ -20,10 +20,10 @@ export default function transformAST(node, opts) { if (color) { // update the color-mod() function with the transformed value - child.replaceWith(parser.word({ - raws: child.raws, + node.nodes.splice(index, 1, { + type: 'word', value: opts.stringifier(color) - })); + }); } } else if (child.nodes && Object(child.nodes).length) { transformAST(child, opts); @@ -35,7 +35,7 @@ export default function transformAST(node, opts) { /* ========================================================================== */ function transformVariables(node, opts) { - walk(node, child => { + parser.walk(node.nodes, (child, index, nodes) => { if (isVariable(child)) { // get the custom property and fallback value from var() const [prop, fallbackNode] = transformArgsByParams(child, [ @@ -48,8 +48,8 @@ function transformVariables(node, opts) { let customPropertyValue = opts.customProperties[prop]; // follow custom properties referencing custom properties - if (looseVarMatch.test(customPropertyValue)) { - const rootChildAST = customPropertyValue.clone(); + if (looseVarMatch.test(parser.stringify(customPropertyValue))) { + const rootChildAST = JSON.parse(JSON.stringify({ nodes: customPropertyValue.nodes })); transformVariables(rootChildAST, opts); @@ -57,18 +57,16 @@ function transformVariables(node, opts) { } // replace var() with the custom property value - if (customPropertyValue.nodes.length === 1 && customPropertyValue.nodes[0].nodes.length) { - customPropertyValue.nodes[0].nodes.forEach(customPropertyChild => { - child.parent.insertBefore(child, customPropertyChild); - }); + if (customPropertyValue.nodes.length) { + nodes.splice(index, 0, ...JSON.parse(JSON.stringify(customPropertyValue.nodes))); } - child.remove(); + nodes.splice(nodes.indexOf(child), 1); } else if (fallbackNode && fallbackNode.nodes.length === 1 && fallbackNode.nodes[0].nodes.length) { // otherwise, replace var() with the fallback value transformVariables(fallbackNode, opts); - child.replaceWith(...fallbackNode.nodes[0].nodes[0]); + nodes.splice(index, 1, ...fallbackNode.nodes[0].nodes[0]); } } }); @@ -154,7 +152,7 @@ function transformHWBFunction(node, opts) { // return a transformed color-mod color function function transformColorModFunction(node, opts) { // [ | ] * - const [colorOrHueNode, ...adjusterNodes] = (node.nodes || []).slice(1, -1) || []; + const [colorOrHueNode, ...adjusterNodes] = node.nodes || []; if (colorOrHueNode !== undefined) { const color = isHue(colorOrHueNode) @@ -212,7 +210,9 @@ function transformNamedColor(node, opts) { // return a transformed color using adjustments function transformColorByAdjusters(color, adjusterNodes, opts) { - const adjustedColor = adjusterNodes.reduce((base, node) => { + const adjustedColor = adjusterNodes.filter((node) => { + return node.type !== 'space' && node.type !== 'comment'; + }).reduce((base, node) => { if (isAlphaBlueGreenRedAdjuster(node)) { return transformAlphaBlueGreenRedAdjuster(base, node, opts); } else if (isRGBAdjuster(node)) { @@ -465,7 +465,7 @@ function transformColorSpace(node, opts) { function transformAlpha(node, opts) { if (isNumber(node)) { // - return node.value * 100; + return Number(parser.unit(node.value).number) * 100; } else if (isPercentage(node)) { // return transformPercentage(node, opts); @@ -488,20 +488,20 @@ function transformRGBNumber(node, opts) { function transformHue(node, opts) { if (isHue(node)) { // = | - const unit = node.unit.toLowerCase(); + const unit = parser.unit(node.value).unit.toLowerCase(); if (unit === 'grad') { // if = (400 per circle) - return convertGtoD(node.value); + return convertGtoD(Number(parser.unit(node.value).number)); } else if (unit === 'rad') { // if = (2π per circle) - return convertRtoD(node.value); + return convertRtoD(Number(parser.unit(node.value).number)); } else if (unit === 'turn') { // if = (1 per circle) - return convertTtoD(node.value); + return convertTtoD(Number(parser.unit(node.value).number)); } else { // if = [ | ] (360 per circle) - return convertDtoD(node.value); + return convertDtoD(Number(parser.unit(node.value).number)); } } else { return manageUnresolved(node, opts, node.value, `Expected a valid hue`); @@ -512,9 +512,9 @@ function transformHue(node, opts) { function transformPercentage(node, opts) { if (isPercentage(node)) { // - return Number(node.value); + return Number(parser.unit(node.value).number); } else { - return manageUnresolved(node, opts, node.value, `Expected a valid hue`); + return manageUnresolved(node, opts, node.value, `Expected a valid percentage`); } } @@ -568,28 +568,22 @@ function transformNode(node) { // return the first set of transformed arguments allowable by the parameters function transformArgsByParams(node, params) { - const nodes = (node.nodes || []).slice(1, -1); + const nodes = (node.nodes || []).filter((node) => { + return node.type !== 'space' && node.type !== 'comment'; + }); const opts = { unresolved: 'ignore' }; - return params.map(param => nodes.map( - (childNode, index) => typeof param[index] === 'function' ? param[index](childNode, opts) : undefined - ).filter(child => typeof child !== 'boolean')).filter(param => param.every( - result => result !== undefined - ))[0] || []; -} - -/* Walk helper (required because the default walker is affected by mutations) -/* ========================================================================== */ - -// run a function over each node and hen walk each child node of that node -function walk(node, fn) { - fn(node); - - if (Object(node.nodes).length) { - node.nodes.slice().forEach(childNode => { - walk(childNode, fn); - }); - } + return params.map((param) => { + return nodes.map((childNode, index) => { + return typeof param[index] === 'function' ? param[index](childNode, opts) : undefined + }).filter((child) => { + return typeof child !== 'boolean' + }) + }).filter((param) => { + return param.every((result) => { + return result !== undefined + }) + })[0] || []; } /* Variable validators @@ -598,7 +592,7 @@ function walk(node, fn) { // return whether the node is a var function function isVariable(node) { // var() - return Object(node).type === 'func' && varMatch.test(node.value); + return Object(node).type === 'function' && varMatch.test(node.value); } /* Adjustment validators @@ -607,42 +601,42 @@ function isVariable(node) { // return whether the node is an a/alpha/blue/green/red adjuster function isAlphaBlueGreenRedAdjuster(node) { // [ a(), alpha(), blue(), green(), red() ] - return Object(node).type === 'func' && alphaBlueGreenRedMatch.test(node.value); + return Object(node).type === 'function' && alphaBlueGreenRedMatch.test(node.value); } // return whether the node is an rgb adjuster function isRGBAdjuster(node) { - return Object(node).type === 'func' && rgbMatch.test(node.value); + return Object(node).type === 'function' && rgbMatch.test(node.value); } // return whether the node is a hue adjuster function isHueAdjuster(node) { // [ h() | hue() ] - return Object(node).type === 'func' && hueMatch.test(node.value); + return Object(node).type === 'function' && hueMatch.test(node.value); } // return whether the node is a blackness/lightness/saturation/whiteness adjuster function isBlacknessLightnessSaturationWhitenessAdjuster(node) { // [ b() | blackness() | l() | lightness() | s() | saturation() | w() | whiteness() ] - return Object(node).type === 'func' && blacknessLightnessSaturationWhitenessMatch.test(node.value); + return Object(node).type === 'function' && blacknessLightnessSaturationWhitenessMatch.test(node.value); } // return whether the node is a shade/tint adjuster function isShadeTintAdjuster(node) { // [ shade() | tint() ] - return Object(node).type === 'func' && shadeTintMatch.test(node.value); + return Object(node).type === 'function' && shadeTintMatch.test(node.value); } // return whether the node is a blend adjuster function isBlendAdjuster(node) { // [ blend(), blenda() ] - return Object(node).type === 'func' && blendMatch.test(node.value); + return Object(node).type === 'function' && blendMatch.test(node.value); } // return whether the node is a contrast adjuster function isContrastAdjuster(node) { // [ contrast() ] - return Object(node).type === 'func' && contrastMatch.test(node.value); + return Object(node).type === 'function' && contrastMatch.test(node.value); } /* Color validators @@ -651,25 +645,25 @@ function isContrastAdjuster(node) { // return whether the node is an rgb/rgba color function function isRGBFunction(node) { // [ rgb(), rgba() ] - return Object(node).type === 'func' && rgbaMatch.test(node.value); + return Object(node).type === 'function' && rgbaMatch.test(node.value); } // return whether the node is an hsl color function function isHSLFunction(node) { // [ hsl(), hsla() ] - return Object(node).type === 'func' && hslaMatch.test(node.value); + return Object(node).type === 'function' && hslaMatch.test(node.value); } // return whether the node is an hwb color function function isHWBFunction(node) { // hwb() - return Object(node).type === 'func' && hwbMatch.test(node.value); + return Object(node).type === 'function' && hwbMatch.test(node.value); } // return whether the node is a color-mod function function isColorModFunction(node) { // color-mod() - return Object(node).type === 'func' && colorModMatch.test(node.value); + return Object(node).type === 'function' && colorModMatch.test(node.value); } // return whether the node is a valid named-color @@ -694,42 +688,57 @@ function isColorSpace(node) { // return whether the hue value is valid function isHue(node) { - return Object(node).type === 'number' && hueUnitMatch.test(node.unit); + if (Object(node).type !== 'word') { + return false; + } + + const parsedNumber = parser.unit(node.value); + return parsedNumber && hueUnitMatch.test(parsedNumber.unit); } // return whether the comma is valid function isComma(node) { - return Object(node).type === 'comma'; + return Object(node).type === 'div' && node.value === ','; } // return whether the slash operator is valid function isSlash(node) { - return Object(node).type === 'operator' && node.value === '/'; + return Object(node).type === 'div' && node.value === '/'; } // return whether the number is valid function isNumber(node) { - return Object(node).type === 'number' && node.unit === ''; + if (Object(node).type !== 'word') { + return false; + } + + const parsedNumber = parser.unit(node.value); + return parsedNumber && parsedNumber.unit === ''; } // return whether the mind-plus operator is valid function isMinusPlusOperator(node) { - return Object(node).type === 'operator' && minusPlusMatch.test(node.value); + return Object(node).type === 'word' && minusPlusMatch.test(node.value); } // return whether the minus-plus-times operator is valid function isMinusPlusTimesOperator(node) { - return Object(node).type === 'operator' && minusPlusTimesMatch.test(node.value); + return Object(node).type === 'word' && minusPlusTimesMatch.test(node.value); } // return whether the times operator is valid function isTimesOperator(node) { - return Object(node).type === 'operator' && timesMatch.test(node.value); + return Object(node).type === 'word' && timesMatch.test(node.value); } // return whether the percentage is valid function isPercentage(node) { - return Object(node).type === 'number' && (node.unit === '%' || node.value === '0'); + if (Object(node).type !== 'word') { + return false; + } + + const parsedNumber = parser.unit(node.value); + return parsedNumber && (parsedNumber.unit === '%' || parseFloat(parsedNumber.number) === 0); } // return whether the node is a word diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..3797084 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,451 @@ +{ + "name": "postcss-color-mod-function", + "version": "4.1.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "postcss-color-mod-function", + "version": "4.1.1", + "license": "CC0-1.0", + "dependencies": { + "@csstools/convert-colors": "^1.4.0", + "postcss-value-parser": "^4.2.0" + }, + "devDependencies": { + "postcss": "^8.2.15", + "postcss-tape": "^6.0.1", + "rollup": "^4.24.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "postcss": "^8.2.15" + } + }, + "node_modules/@csstools/convert-colors": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@csstools/convert-colors/-/convert-colors-1.4.0.tgz", + "integrity": "sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw==", + "license": "CC0-1.0", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.29.1.tgz", + "integrity": "sha512-ssKhA8RNltTZLpG6/QNkCSge+7mBQGUqJRisZ2MDQcEGaK93QESEgWK2iOpIDZ7k9zPVkG5AS3ksvD5ZWxmItw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.29.1.tgz", + "integrity": "sha512-CaRfrV0cd+NIIcVVN/jx+hVLN+VRqnuzLRmfmlzpOzB87ajixsN/+9L5xNmkaUUvEbI5BmIKS+XTwXsHEb65Ew==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.29.1.tgz", + "integrity": "sha512-2ORr7T31Y0Mnk6qNuwtyNmy14MunTAMx06VAPI6/Ju52W10zk1i7i5U3vlDRWjhOI5quBcrvhkCHyF76bI7kEw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.29.1.tgz", + "integrity": "sha512-j/Ej1oanzPjmN0tirRd5K2/nncAhS9W6ICzgxV+9Y5ZsP0hiGhHJXZ2JQ53iSSjj8m6cRY6oB1GMzNn2EUt6Ng==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.29.1.tgz", + "integrity": "sha512-91C//G6Dm/cv724tpt7nTyP+JdN12iqeXGFM1SqnljCmi5yTXriH7B1r8AD9dAZByHpKAumqP1Qy2vVNIdLZqw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.29.1.tgz", + "integrity": "sha512-hEioiEQ9Dec2nIRoeHUP6hr1PSkXzQaCUyqBDQ9I9ik4gCXQZjJMIVzoNLBRGet+hIUb3CISMh9KXuCcWVW/8w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.29.1.tgz", + "integrity": "sha512-Py5vFd5HWYN9zxBv3WMrLAXY3yYJ6Q/aVERoeUFwiDGiMOWsMs7FokXihSOaT/PMWUty/Pj60XDQndK3eAfE6A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.29.1.tgz", + "integrity": "sha512-RiWpGgbayf7LUcuSNIbahr0ys2YnEERD4gYdISA06wa0i8RALrnzflh9Wxii7zQJEB2/Eh74dX4y/sHKLWp5uQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.29.1.tgz", + "integrity": "sha512-Z80O+taYxTQITWMjm/YqNoe9d10OX6kDh8X5/rFCMuPqsKsSyDilvfg+vd3iXIqtfmp+cnfL1UrYirkaF8SBZA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.29.1.tgz", + "integrity": "sha512-fOHRtF9gahwJk3QVp01a/GqS4hBEZCV1oKglVVq13kcK3NeVlS4BwIFzOHDbmKzt3i0OuHG4zfRP0YoG5OF/rA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.29.1.tgz", + "integrity": "sha512-5a7q3tnlbcg0OodyxcAdrrCxFi0DgXJSoOuidFUzHZ2GixZXQs6Tc3CHmlvqKAmOs5eRde+JJxeIf9DonkmYkw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.29.1.tgz", + "integrity": "sha512-9b4Mg5Yfz6mRnlSPIdROcfw1BU22FQxmfjlp/CShWwO3LilKQuMISMTtAu/bxmmrE6A902W2cZJuzx8+gJ8e9w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.29.1.tgz", + "integrity": "sha512-G5pn0NChlbRM8OJWpJFMX4/i8OEU538uiSv0P6roZcbpe/WfhEO+AT8SHVKfp8qhDQzaz7Q+1/ixMy7hBRidnQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.29.1.tgz", + "integrity": "sha512-WM9lIkNdkhVwiArmLxFXpWndFGuOka4oJOZh8EP3Vb8q5lzdSCBuhjavJsw68Q9AKDGeOOIHYzYm4ZFvmWez5g==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.29.1.tgz", + "integrity": "sha512-87xYCwb0cPGZFoGiErT1eDcssByaLX4fc0z2nRM6eMtV9njAfEE6OW3UniAoDhX4Iq5xQVpE6qO9aJbCFumKYQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.29.1.tgz", + "integrity": "sha512-xufkSNppNOdVRCEC4WKvlR1FBDyqCSCpQeMMgv9ZyXqqtKBfkw1yfGMTUTs9Qsl6WQbJnsGboWCp7pJGkeMhKA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.29.1.tgz", + "integrity": "sha512-F2OiJ42m77lSkizZQLuC+jiZ2cgueWQL5YC9tjo3AgaEw+KJmVxHGSyQfDUoYR9cci0lAywv2Clmckzulcq6ig==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.29.1.tgz", + "integrity": "sha512-rYRe5S0FcjlOBZQHgbTKNrqxCBUmgDJem/VQTCcTnA2KCabYSWQDrytOzX7avb79cAAweNmMUb/Zw18RNd4mng==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.29.1.tgz", + "integrity": "sha512-+10CMg9vt1MoHj6x1pxyjPSMjHTIlqs8/tBztXvPAx24SKs9jwVnKqHJumlH/IzhaPUaj3T6T6wfZr8okdXaIg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/estree": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/nanoid": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.4.49", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.49.tgz", + "integrity": "sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.7", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-tape": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/postcss-tape/-/postcss-tape-6.0.1.tgz", + "integrity": "sha512-qw/1YCSoGgmz8DC/8lbUo3OZGN0UWWZdThAvCSOIJrK346Weu8bM+aC5c9q1/Np2YjCJfRqhJO+P94A3sLdWhQ==", + "dev": true, + "license": "CC0-1.0", + "bin": { + "postcss-tape": "dist/index.js" + }, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "postcss": "^7 || ^8" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", + "license": "MIT" + }, + "node_modules/rollup": { + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.29.1.tgz", + "integrity": "sha512-RaJ45M/kmJUzSWDs1Nnd5DdV4eerC98idtUOVr6FfKcgxqvjwHmxc5upLF9qZU9EpsVzzhleFahrT3shLuJzIw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.6" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.29.1", + "@rollup/rollup-android-arm64": "4.29.1", + "@rollup/rollup-darwin-arm64": "4.29.1", + "@rollup/rollup-darwin-x64": "4.29.1", + "@rollup/rollup-freebsd-arm64": "4.29.1", + "@rollup/rollup-freebsd-x64": "4.29.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.29.1", + "@rollup/rollup-linux-arm-musleabihf": "4.29.1", + "@rollup/rollup-linux-arm64-gnu": "4.29.1", + "@rollup/rollup-linux-arm64-musl": "4.29.1", + "@rollup/rollup-linux-loongarch64-gnu": "4.29.1", + "@rollup/rollup-linux-powerpc64le-gnu": "4.29.1", + "@rollup/rollup-linux-riscv64-gnu": "4.29.1", + "@rollup/rollup-linux-s390x-gnu": "4.29.1", + "@rollup/rollup-linux-x64-gnu": "4.29.1", + "@rollup/rollup-linux-x64-musl": "4.29.1", + "@rollup/rollup-win32-arm64-msvc": "4.29.1", + "@rollup/rollup-win32-ia32-msvc": "4.29.1", + "@rollup/rollup-win32-x64-msvc": "4.29.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + } + } +} diff --git a/package.json b/package.json index eceb158..f3f3844 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "postcss-color-mod-function", - "version": "3.0.3", + "version": "4.1.1", "description": "Modify colors using the color-mod() function in CSS", "author": "Jonathan Neal ", "license": "CC0-1.0", "repository": "jonathantneal/postcss-color-mod-function", - "homepage": "https://github.com/jonathantneal/postcss-color-mod-function#readme", - "bugs": "https://github.com/jonathantneal/postcss-color-mod-function/issues", + "homepage": "https://github.com/csstools/postcss-color-mod-function#readme", + "bugs": "https://github.com/csstools/postcss-color-mod-function/issues", "main": "index.cjs.js", "module": "index.es.mjs", "files": [ @@ -17,40 +17,24 @@ ], "scripts": { "prepublishOnly": "npm test", - "pretest": "rollup -c .rollup.js --silent", - "test": "echo 'Running tests...'; npm run test:js && npm run test:tape", - "test:js": "eslint *.js lib/*.js --cache --ignore-path .gitignore --quiet", - "test:tape": "postcss-tape" + "pretest": "npm run build", + "build": "rollup -c .rollup.mjs --silent", + "test": "postcss-tape" }, "engines": { - "node": ">=6.0.0" + "node": ">= 18" }, "dependencies": { "@csstools/convert-colors": "^1.4.0", - "postcss": "^7.0.2", - "postcss-values-parser": "^2.0.0" + "postcss-value-parser": "^4.2.0" }, "devDependencies": { - "@babel/core": "^7.1.0", - "@babel/plugin-syntax-dynamic-import": "^7.0.0", - "@babel/preset-env": "^7.1.0", - "babel-eslint": "^9.0.0", - "eslint": "^5.6.0", - "eslint-config-dev": "^2.0.0", - "postcss-tape": "^2.2.0", - "pre-commit": "^1.2.2", - "rollup": "^0.66.2", - "rollup-plugin-babel": "^4.0.3" + "postcss": "^8.2.15", + "postcss-tape": "^6.0.1", + "rollup": "^4.24.0" }, - "eslintConfig": { - "extends": "dev", - "parser": "babel-eslint", - "rules": { - "max-params": [ - 2, - 5 - ] - } + "peerDependencies": { + "postcss": "^8.2.15" }, "keywords": [ "postcss",