HEX
Server: nginx/1.28.1
System: Linux VM-0-12-opencloudos 6.6.117-45.oc9.x86_64 #1 SMP Thu Dec 4 10:26:39 CST 2025 x86_64
User: www (1000)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.waciwang.com/wp-content/plugins/gutenberg/build/scripts/theme/index.js.map
{
  "version": 3,
  "sources": ["package-external:@wordpress/private-apis", "package-external:@wordpress/element", "vendor-external:react/jsx-runtime", "../../../packages/theme/src/lock-unlock.ts", "../../../packages/theme/src/theme-provider.tsx", "../../../packages/theme/src/style.module.css", "../../../packages/theme/src/context.ts", "../../../packages/theme/node_modules/colorjs.io/src/multiply-matrices.js", "../../../packages/theme/node_modules/colorjs.io/src/util.js", "../../../packages/theme/node_modules/colorjs.io/src/Type.js", "../../../packages/theme/node_modules/colorjs.io/src/Format.js", "../../../packages/theme/node_modules/colorjs.io/src/hooks.js", "../../../packages/theme/node_modules/colorjs.io/src/adapt.js", "../../../packages/theme/node_modules/colorjs.io/src/defaults.js", "../../../packages/theme/node_modules/colorjs.io/src/parse.js", "../../../packages/theme/node_modules/colorjs.io/src/getColor.js", "../../../packages/theme/node_modules/colorjs.io/src/ColorSpace.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/xyz-d65.js", "../../../packages/theme/node_modules/colorjs.io/src/RGBColorSpace.js", "../../../packages/theme/node_modules/colorjs.io/src/getAll.js", "../../../packages/theme/node_modules/colorjs.io/src/get.js", "../../../packages/theme/node_modules/colorjs.io/src/setAll.js", "../../../packages/theme/node_modules/colorjs.io/src/set.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/xyz-d50.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/lab.js", "../../../packages/theme/node_modules/colorjs.io/src/angles.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/lch.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaE2000.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/oklab.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaEOK.js", "../../../packages/theme/node_modules/colorjs.io/src/inGamut.js", "../../../packages/theme/node_modules/colorjs.io/src/clone.js", "../../../packages/theme/node_modules/colorjs.io/src/distance.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaE76.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaECMC.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/xyz-abs-d65.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/jzazbz.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/jzczhz.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaEJz.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/ictcp.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaEITP.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaEOK2.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/cam16.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/hct.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/deltaEHCT.js", "../../../packages/theme/node_modules/colorjs.io/src/deltaE/index.js", "../../../packages/theme/node_modules/colorjs.io/src/toGamut.js", "../../../packages/theme/node_modules/colorjs.io/src/to.js", "../../../packages/theme/node_modules/colorjs.io/src/serialize.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/p3-linear.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/srgb-linear.js", "../../../packages/theme/node_modules/colorjs.io/src/keywords.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/srgb.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/p3.js", "../../../packages/theme/node_modules/colorjs.io/src/luminance.js", "../../../packages/theme/node_modules/colorjs.io/src/contrast/WCAG21.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/hsl.js", "../../../packages/theme/node_modules/colorjs.io/src/spaces/oklch.js", "../../../node_modules/memize/dist/index.js", "../../../packages/theme/src/use-theme-provider-styles.ts", "../../../packages/theme/src/color-ramps/lib/register-color-spaces.ts", "../../../packages/theme/src/prebuilt/ts/color-tokens.ts", "../../../packages/theme/src/color-ramps/lib/color-utils.ts", "../../../packages/theme/src/color-ramps/lib/constants.ts", "../../../packages/theme/src/color-ramps/lib/utils.ts", "../../../packages/theme/src/color-ramps/lib/taper-chroma.ts", "../../../packages/theme/src/color-ramps/lib/find-color-with-constraints.ts", "../../../packages/theme/src/color-ramps/lib/index.ts", "../../../packages/theme/src/color-ramps/lib/ramp-configs.ts", "../../../packages/theme/src/color-ramps/index.ts", "../../../packages/theme/src/private-apis.ts"],
  "sourcesContent": ["module.exports = window.wp.privateApis;", "module.exports = window.wp.element;", "module.exports = window.ReactJSXRuntime;", "/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/theme'\n\t);\n", "/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useId } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { ThemeContext } from './context';\nimport { useThemeProviderStyles } from './use-theme-provider-styles';\nimport { type ThemeProviderProps } from './types';\nimport styles from './style.module.css';\n\nfunction cssObjectToText( values: CSSProperties ) {\n\treturn Object.entries( values )\n\t\t.map( ( [ key, value ] ) => `${ key }: ${ value };` )\n\t\t.join( '' );\n}\n\nfunction generateCSSSelector( {\n\tinstanceId,\n\tisRoot,\n}: {\n\tinstanceId: string;\n\tisRoot: boolean;\n} ) {\n\tconst rootSel = `[data-wpds-root-provider=\"true\"]`;\n\tconst instanceIdSel = `[data-wpds-theme-provider-id=\"${ instanceId }\"]`;\n\n\tconst selectors = [];\n\n\tif ( isRoot ) {\n\t\tselectors.push(\n\t\t\t`:root:has(.${ styles.root }${ rootSel }${ instanceIdSel })`\n\t\t);\n\t}\n\n\tselectors.push( `.${ styles.root }.${ styles.root }${ instanceIdSel }` );\n\n\treturn selectors.join( ',' );\n}\n\nexport const ThemeProvider = ( {\n\tchildren,\n\tcolor = {},\n\tisRoot = false,\n\tdensity,\n}: ThemeProviderProps ) => {\n\tconst instanceId = useId();\n\n\tconst { themeProviderStyles, resolvedSettings } = useThemeProviderStyles( {\n\t\tcolor,\n\t} );\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tresolvedSettings,\n\t\t} ),\n\t\t[ resolvedSettings ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ themeProviderStyles ? (\n\t\t\t\t<style>\n\t\t\t\t\t{ `${ generateCSSSelector( {\n\t\t\t\t\t\tinstanceId,\n\t\t\t\t\t\tisRoot,\n\t\t\t\t\t} ) } {${ cssObjectToText( themeProviderStyles ) }}` }\n\t\t\t\t</style>\n\t\t\t) : null }\n\t\t\t<div\n\t\t\t\tdata-wpds-theme-provider-id={ instanceId }\n\t\t\t\tdata-wpds-root-provider={ isRoot }\n\t\t\t\tdata-wpds-density={ density }\n\t\t\t\tclassName={ styles.root }\n\t\t\t>\n\t\t\t\t<ThemeContext.Provider value={ contextValue }>\n\t\t\t\t\t{ children }\n\t\t\t\t</ThemeContext.Provider>\n\t\t\t</div>\n\t\t</>\n\t);\n};\n", "const css = `.style-module__root__26kw6 {\n\tdisplay: contents;\n}\n`;\ndocument.head\n    .appendChild(document.createElement(\"style\"))\n    .appendChild(document.createTextNode(css));\nexport {css};\nexport default {\n  \"root\": \"style-module__root__26kw6\"\n};", "/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { ThemeProviderSettings } from './types';\n\ninterface ThemeContextType {\n\tresolvedSettings: ThemeProviderSettings;\n}\n\nexport const ThemeContext = createContext< ThemeContextType >( {\n\tresolvedSettings: {\n\t\tcolor: {},\n\t},\n} );\n", "/** @import { Matrix3x3, Vector3 } from \"./types.js\" */\n\n/**\n * A is m x n. B is n x p. product is m x p.\n *\n * Array arguments are treated like vectors:\n * - A becomes 1 x n\n * - B becomes n x 1\n *\n * Returns Matrix m x p or equivalent array or number\n *\n * @overload\n * @param {number[]} A Vector 1 x n\n * @param {number[]} B Vector n x 1\n * @returns {number} Scalar number\n *\n * @overload\n * @param {number[][]} A Matrix m x n\n * @param {number[]} B Vector n x 1\n * @returns {number[]} Array with length m\n *\n * @overload\n * @param {number[]} A Vector 1 x n\n * @param {number[][]} B Matrix n x p\n * @returns {number[]} Array with length p\n *\n * @overload\n * @param {number[][]} A Matrix m x n\n * @param {number[][]} B Matrix n x p\n * @returns {number[][]} Matrix m x p\n *\n * @param {number[] | number[][]} A Matrix m x n or a vector\n * @param {number[] | number[][]} B Matrix n x p or a vector\n * @returns {number | number[] | number[][]} Matrix m x p or equivalent array or number\n */\nexport default function multiplyMatrices (A, B) {\n\tlet m = A.length;\n\t/** @type {number[][]} */\n\tlet AM;\n\t/** @type {number[][]} */\n\tlet BM;\n\tlet aVec = false;\n\tlet bVec = false;\n\n\tif (!Array.isArray(A[0])) {\n\t\t// A is vector, convert to [[a, b, c, ...]]\n\t\tAM = [/** @type {number[]} */ (A)];\n\t\tm = AM.length;\n\t\taVec = true;\n\t}\n\telse {\n\t\tAM = /** @type {number[][]} */ (A);\n\t}\n\n\tif (!Array.isArray(B[0])) {\n\t\t// B is vector, convert to [[a], [b], [c], ...]]\n\t\tBM = B.length > 0 ? B.map(x => [x]) : [[]]; // Avoid mapping empty array\n\t\tbVec = true;\n\t}\n\telse {\n\t\tBM = /** @type {number[][]} */ (B);\n\t}\n\n\tlet p = BM[0].length;\n\tlet BM_cols = BM[0].map((_, i) => BM.map(x => x[i])); // transpose B\n\t/** @type {number[] | number[][]} */\n\tlet product = AM.map(row =>\n\t\tBM_cols.map(col => {\n\t\t\tlet ret = 0;\n\n\t\t\tif (!Array.isArray(row)) {\n\t\t\t\tfor (let c of col) {\n\t\t\t\t\tret += row * c;\n\t\t\t\t}\n\n\t\t\t\treturn ret;\n\t\t\t}\n\n\t\t\tfor (let i = 0; i < row.length; i++) {\n\t\t\t\tret += row[i] * (col[i] || 0);\n\t\t\t}\n\n\t\t\treturn ret;\n\t\t}));\n\n\tif (m === 1 && aVec) {\n\t\tproduct = product[0]; // Avoid [[a, b, c, ...]]\n\t}\n\tif (p === 1 && bVec) {\n\t\tif (m === 1 && aVec) {\n\t\t\treturn product[0]; // Avoid [[a]], return a number\n\t\t}\n\t\telse {\n\t\t\treturn product.map(x => x[0]); // Avoid [[a], [b], [c], ...]]\n\t\t}\n\t}\n\n\treturn product;\n}\n\n// dot3 and transform functions adapted from https://github.com/texel-org/color/blob/9793c7d4d02b51f068e0f3fd37131129a4270396/src/core.js\n//\n// The MIT License (MIT)\n// Copyright (c) 2024 Matt DesLauriers\n\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE\n// OR OTHER DEALINGS IN THE SOFTWARE.\n\n/**\n * Returns the dot product of two vectors each with a length of 3.\n *\n * @param {Vector3} a\n * @param {Vector3} b\n * @returns {number}\n */\nfunction dot3 (a, b) {\n\treturn a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n}\n\n/**\n * Transforms a vector of length 3 by a 3x3 matrix. Specify the same input and output\n * vector to transform in place.\n *\n * @param {Vector3} input\n * @param {Matrix3x3} matrix\n * @param {Vector3} [out]\n * @returns {Vector3}\n */\nexport function multiply_v3_m3x3 (input, matrix, out = [0, 0, 0]) {\n\tconst x = dot3(input, matrix[0]);\n\tconst y = dot3(input, matrix[1]);\n\tconst z = dot3(input, matrix[2]);\n\tout[0] = x;\n\tout[1] = y;\n\tout[2] = z;\n\treturn out;\n}\n", "/**\n * Various utility functions\n */\n\nexport { default as multiplyMatrices, multiply_v3_m3x3 } from \"./multiply-matrices.js\";\n\n/**\n * Check if a value is a string (including a String object)\n * @param {any} str - Value to check\n * @returns {str is string}\n */\nexport function isString (str) {\n\treturn type(str) === \"string\";\n}\n\n/**\n * Determine the internal JavaScript [[Class]] of an object.\n * @param {any} o - Value to check\n * @returns {string}\n */\nexport function type (o) {\n\tlet str = Object.prototype.toString.call(o);\n\n\treturn (str.match(/^\\[object\\s+(.*?)\\]$/)[1] || \"\").toLowerCase();\n}\n\n/**\n * @param {number} n\n * @param {{ precision?: number | undefined, unit?: string | undefined }} options\n * @returns {string}\n */\nexport function serializeNumber (n, { precision = 16, unit }) {\n\tif (isNone(n)) {\n\t\treturn \"none\";\n\t}\n\n\tn = +toPrecision(n, precision);\n\n\treturn n + (unit ?? \"\");\n}\n\n/**\n * Check if a value corresponds to a none argument\n * @param {any} n - Value to check\n * @returns {n is null}\n */\nexport function isNone (n) {\n\treturn n === null;\n}\n\n/**\n * Replace none values with 0\n * @param {number | null} n\n * @returns {number}\n */\nexport function skipNone (n) {\n\treturn isNone(n) ? 0 : n;\n}\n\n/**\n * Round a number to a certain number of significant digits\n * @param {number} n - The number to round\n * @param {number} precision - Number of significant digits\n */\nexport function toPrecision (n, precision) {\n\tif (n === 0) {\n\t\treturn 0;\n\t}\n\tlet integer = ~~n;\n\tlet digits = 0;\n\tif (integer && precision) {\n\t\tdigits = ~~Math.log10(Math.abs(integer)) + 1;\n\t}\n\tconst multiplier = 10.0 ** (precision - digits);\n\treturn Math.floor(n * multiplier + 0.5) / multiplier;\n}\n\n/**\n * @param {number} start\n * @param {number} end\n * @param {number} p\n */\nexport function interpolate (start, end, p) {\n\tif (isNaN(start)) {\n\t\treturn end;\n\t}\n\n\tif (isNaN(end)) {\n\t\treturn start;\n\t}\n\n\treturn start + (end - start) * p;\n}\n\n/**\n * @param {number} start\n * @param {number} end\n * @param {number} value\n */\nexport function interpolateInv (start, end, value) {\n\treturn (value - start) / (end - start);\n}\n\n/**\n * @param {[number, number]} from\n * @param {[number, number]} to\n * @param {number} value\n */\nexport function mapRange (from, to, value) {\n\tif (\n\t\t!from ||\n\t\t!to ||\n\t\tfrom === to ||\n\t\t(from[0] === to[0] && from[1] === to[1]) ||\n\t\tisNaN(value) ||\n\t\tvalue === null\n\t) {\n\t\t// Ranges missing or the same\n\t\treturn value;\n\t}\n\n\treturn interpolate(to[0], to[1], interpolateInv(from[0], from[1], value));\n}\n\n/**\n * Clamp value between the minimum and maximum\n * @param {number} min minimum value to return\n * @param {number} val the value to return if it is between min and max\n * @param {number} max maximum value to return\n */\nexport function clamp (min, val, max) {\n\treturn Math.max(Math.min(max, val), min);\n}\n\n/**\n * Copy sign of one value to another.\n * @param {number} to - Number to copy sign to\n * @param {number} from - Number to copy sign from\n */\nexport function copySign (to, from) {\n\treturn Math.sign(to) === Math.sign(from) ? to : -to;\n}\n\n/**\n * Perform pow on a signed number and copy sign to result\n * @param {number} base The base number\n * @param {number} exp The exponent\n */\nexport function spow (base, exp) {\n\treturn copySign(Math.abs(base) ** exp, base);\n}\n\n/**\n * Perform a divide, but return zero if the denominator is zero\n * @param {number} n The numerator\n * @param {number} d The denominator\n */\nexport function zdiv (n, d) {\n\treturn d === 0 ? 0 : n / d;\n}\n\n/**\n * Perform a bisect on a sorted list and locate the insertion point for\n * a value in arr to maintain sorted order.\n * @param {number[]} arr - array of sorted numbers\n * @param {number} value - value to find insertion point for\n * @param {number} lo - used to specify a the low end of a subset of the list\n * @param {number} hi - used to specify a the high end of a subset of the list\n */\nexport function bisectLeft (arr, value, lo = 0, hi = arr.length) {\n\twhile (lo < hi) {\n\t\tconst mid = (lo + hi) >> 1;\n\t\tif (arr[mid] < value) {\n\t\t\tlo = mid + 1;\n\t\t}\n\t\telse {\n\t\t\thi = mid;\n\t\t}\n\t}\n\treturn lo;\n}\n\n/**\n * Determines whether an argument is an instance of a constructor, including subclasses.\n * This is done by first just checking `instanceof`,\n * and then comparing the string names of the constructors if that fails.\n * @param {any} arg\n * @param {C} constructor\n * @template {new (...args: any) => any} C\n * @returns {arg is InstanceType<C>}\n */\nexport function isInstance (arg, constructor) {\n\tif (arg instanceof constructor) {\n\t\treturn true;\n\t}\n\n\tconst targetName = constructor.name;\n\n\twhile (arg) {\n\t\tconst proto = Object.getPrototypeOf(arg);\n\t\tconst constructorName = proto?.constructor?.name;\n\t\tif (constructorName === targetName) {\n\t\t\treturn true;\n\t\t}\n\t\tif (!constructorName || constructorName === \"Object\") {\n\t\t\treturn false;\n\t\t}\n\t\targ = proto;\n\t}\n\n\treturn false;\n}\n", "import { serializeNumber, mapRange, isInstance } from \"./util.js\";\n\nexport default class Type {\n\t// Class properties - declared here so that type inference works\n\ttype;\n\tcoordMeta;\n\tcoordRange;\n\t/** @type {[number, number]} */\n\trange;\n\n\t/**\n\t * @param {any} type\n\t * @param {import(\"./types.js\").CoordMeta} coordMeta\n\t */\n\tconstructor (type, coordMeta) {\n\t\tif (typeof type === \"object\") {\n\t\t\tthis.coordMeta = type;\n\t\t}\n\n\t\tif (coordMeta) {\n\t\t\tthis.coordMeta = coordMeta;\n\t\t\tthis.coordRange = coordMeta.range ?? coordMeta.refRange;\n\t\t}\n\n\t\tif (typeof type === \"string\") {\n\t\t\tlet params = type\n\t\t\t\t.trim()\n\t\t\t\t.match(/^(?<type><[a-z]+>)(\\[(?<min>-?[.\\d]+),\\s*(?<max>-?[.\\d]+)\\])?$/);\n\n\t\t\tif (!params) {\n\t\t\t\tthrow new TypeError(`Cannot parse ${type} as a type definition.`);\n\t\t\t}\n\n\t\t\tthis.type = params.groups.type;\n\t\t\tlet { min, max } = params.groups;\n\n\t\t\tif (min || max) {\n\t\t\t\tthis.range = [+min, +max];\n\t\t\t}\n\t\t}\n\t}\n\n\t/** @returns {[number, number]} */\n\tget computedRange () {\n\t\tif (this.range) {\n\t\t\treturn this.range;\n\t\t}\n\t\tif (this.type === \"<percentage>\") {\n\t\t\treturn this.percentageRange();\n\t\t}\n\t\telse if (this.type === \"<angle>\") {\n\t\t\treturn [0, 360];\n\t\t}\n\t\treturn null;\n\t}\n\n\tget unit () {\n\t\tif (this.type === \"<percentage>\") {\n\t\t\treturn \"%\";\n\t\t}\n\t\telse if (this.type === \"<angle>\") {\n\t\t\treturn \"deg\";\n\t\t}\n\n\t\treturn \"\";\n\t}\n\n\t/**\n\t * Map a number to the internal representation\n\t * @param {number} number\n\t */\n\tresolve (number) {\n\t\tif (this.type === \"<angle>\") {\n\t\t\treturn number;\n\t\t}\n\n\t\tlet fromRange = this.computedRange;\n\t\tlet toRange = this.coordRange;\n\n\t\tif (this.type === \"<percentage>\") {\n\t\t\ttoRange ??= this.percentageRange();\n\t\t}\n\n\t\treturn mapRange(fromRange, toRange, number);\n\t}\n\n\t/**\n\t * Serialize a number from the internal representation to a string\n\t * @param {number} number\n\t * @param {number} [precision]\n\t */\n\tserialize (number, precision) {\n\t\tlet toRange = this.type === \"<percentage>\" ? this.percentageRange(100) : this.computedRange;\n\n\t\tlet unit = this.unit;\n\n\t\tnumber = mapRange(this.coordRange, toRange, number);\n\t\treturn serializeNumber(number, { unit, precision });\n\t}\n\n\ttoString () {\n\t\tlet ret = this.type;\n\n\t\tif (this.range) {\n\t\t\tlet [min = \"\", max = \"\"] = this.range;\n\t\t\tret += `[${min},${max}]`;\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\t/**\n\t * Returns a percentage range for values of this type\n\t * @param {number} scale\n\t * @returns {[number, number]}\n\t */\n\tpercentageRange (scale = 1) {\n\t\tlet range;\n\t\tif (\n\t\t\t(this.coordMeta && this.coordMeta.range) ||\n\t\t\t(this.coordRange && this.coordRange[0] >= 0)\n\t\t) {\n\t\t\trange = [0, 1];\n\t\t}\n\t\telse {\n\t\t\trange = [-1, 1];\n\t\t}\n\t\treturn [range[0] * scale, range[1] * scale];\n\t}\n\n\tstatic get (type, coordMeta) {\n\t\tif (isInstance(type, this)) {\n\t\t\treturn type;\n\t\t}\n\n\t\treturn new this(type, coordMeta);\n\t}\n}\n", "import { isInstance, isNone } from \"./util.js\";\nimport Type from \"./Type.js\";\n\n/** @import { ColorSpace, Coords } from \"./types.js\" */\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").Format} FormatInterface */\n\n/**\n * @internal\n * Used to index {@link FormatInterface Format} objects and store an instance.\n * Not meant for external use\n */\nexport const instance = Symbol(\"instance\");\n\n/**\n * Remove the first element of an array type\n * @template {any[]} T\n * @typedef {T extends [any, ...infer R] ? R : T[number][]} RemoveFirstElement\n */\n\n/**\n * @class Format\n * @implements {Omit<FormatInterface, \"coords\" | \"serializeCoords\">}\n * Class to hold a color serialization format\n */\nexport default class Format {\n\t// Class properties - declared here so that type inference works\n\ttype;\n\tname;\n\tspaceCoords;\n\t/** @type {Type[][]} */\n\tcoords;\n\t/** @type {string | undefined} */\n\tid;\n\t/** @type {boolean | undefined} */\n\talpha;\n\n\t/**\n\t * @param {FormatInterface} format\n\t * @param {ColorSpace} space\n\t */\n\tconstructor (format, space = format.space) {\n\t\tformat[instance] = this;\n\t\tthis.type = \"function\";\n\t\tthis.name = \"color\";\n\n\t\tObject.assign(this, format);\n\n\t\tthis.space = space;\n\n\t\tif (this.type === \"custom\") {\n\t\t\t// Nothing else to do here\n\t\t\treturn;\n\t\t}\n\n\t\tthis.spaceCoords = Object.values(space.coords);\n\n\t\tif (!this.coords) {\n\t\t\t// @ts-expect-error Strings are converted to the correct type later\n\t\t\tthis.coords = this.spaceCoords.map(coordMeta => {\n\t\t\t\tlet ret = [\"<number>\", \"<percentage>\"];\n\n\t\t\t\tif (coordMeta.type === \"angle\") {\n\t\t\t\t\tret.push(\"<angle>\");\n\t\t\t\t}\n\n\t\t\t\treturn ret;\n\t\t\t});\n\t\t}\n\n\t\tthis.coords = this.coords.map(\n\t\t\t/** @param {string | string[] | Type[]} types */ (types, i) => {\n\t\t\t\tlet coordMeta = this.spaceCoords[i];\n\n\t\t\t\tif (typeof types === \"string\") {\n\t\t\t\t\ttypes = types.trim().split(/\\s*\\|\\s*/);\n\t\t\t\t}\n\n\t\t\t\treturn types.map(type => Type.get(type, coordMeta));\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * @param {Coords} coords\n\t * @param {number} precision\n\t * @param {Type[]} types\n\t */\n\tserializeCoords (coords, precision, types) {\n\t\ttypes = coords.map((_, i) =>\n\t\t\tType.get(types?.[i] ?? this.coords[i][0], this.spaceCoords[i]));\n\t\treturn coords.map((c, i) => types[i].serialize(c, precision));\n\t}\n\n\t/**\n\t * Validates the coordinates of a color against a format's coord grammar and\n\t * maps the coordinates to the range or refRange of the coordinates.\n\t * @param {Coords} coords\n\t * @param {[string, string, string]} types\n\t */\n\tcoerceCoords (coords, types) {\n\t\treturn Object.entries(this.space.coords).map(([id, coordMeta], i) => {\n\t\t\tlet arg = coords[i];\n\n\t\t\tif (isNone(arg) || isNaN(arg)) {\n\t\t\t\t// Nothing to do here\n\t\t\t\treturn arg;\n\t\t\t}\n\n\t\t\t// Find grammar alternative that matches the provided type\n\t\t\t// Non-strict equals is intentional because we are comparing w/ string objects\n\t\t\tlet providedType = types[i];\n\t\t\tlet type = this.coords[i].find(c => c.type == providedType);\n\n\t\t\t// Check that each coord conforms to its grammar\n\t\t\tif (!type) {\n\t\t\t\t// Type does not exist in the grammar, throw\n\t\t\t\tlet coordName = coordMeta.name || id;\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`${providedType ?? /** @type {any} */ (arg)?.raw ?? arg} not allowed for ${coordName} in ${this.name}()`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\targ = type.resolve(arg);\n\n\t\t\tif (type.range) {\n\t\t\t\t// Adjust type to include range\n\t\t\t\ttypes[i] = type.toString();\n\t\t\t}\n\n\t\t\treturn arg;\n\t\t});\n\t}\n\n\t/**\n\t * @returns {boolean | Required<FormatInterface>[\"serialize\"]}\n\t */\n\tcanSerialize () {\n\t\treturn this.type === \"function\" || /** @type {any} */ (this).serialize;\n\t}\n\n\t/**\n\t * @param {string} str\n\t * @returns {(import(\"./types.js\").ColorConstructor) | undefined | null}\n\t */\n\tparse (str) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * @param {Format | FormatInterface} format\n\t * @param {RemoveFirstElement<ConstructorParameters<typeof Format>>} args\n\t * @returns {Format}\n\t */\n\tstatic get (format, ...args) {\n\t\tif (!format || isInstance(format, this)) {\n\t\t\treturn /** @type {Format} */ (format);\n\t\t}\n\n\t\tif (format[instance]) {\n\t\t\treturn format[instance];\n\t\t}\n\n\t\treturn new Format(format, ...args);\n\t}\n}\n", "/**\n * A class for adding deep extensibility to any piece of JS code\n */\nexport class Hooks {\n\tadd (name, callback, first) {\n\t\tif (typeof arguments[0] != \"string\") {\n\t\t\t// Multiple hooks\n\t\t\tfor (var name in arguments[0]) {\n\t\t\t\tthis.add(name, arguments[0][name], arguments[1]);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\t(Array.isArray(name) ? name : [name]).forEach(function (name) {\n\t\t\tthis[name] = this[name] || [];\n\n\t\t\tif (callback) {\n\t\t\t\tthis[name][first ? \"unshift\" : \"push\"](callback);\n\t\t\t}\n\t\t}, this);\n\t}\n\n\trun (name, env) {\n\t\tthis[name] = this[name] || [];\n\t\tthis[name].forEach(function (callback) {\n\t\t\tcallback.call(env && env.context ? env.context : env, env);\n\t\t});\n\t}\n}\n\n/**\n * The instance of {@link Hooks} used throughout Color.js\n */\nconst hooks = new Hooks();\n\nexport default hooks;\n", "import hooks from \"./hooks.js\";\nimport { multiply_v3_m3x3 } from \"./util.js\";\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").White} White */\n\n/** @type {Record<string, White>} */\n// prettier-ignore\nexport const WHITES = {\n\t// for compatibility, the four-digit chromaticity-derived ones everyone else uses\n\tD50: [0.3457 / 0.3585, 1.00000, (1.0 - 0.3457 - 0.3585) / 0.3585],\n\tD65: [0.3127 / 0.3290, 1.00000, (1.0 - 0.3127 - 0.3290) / 0.3290],\n};\n\n/**\n *\n * @param {string | White} name\n * @returns {White}\n */\nexport function getWhite (name) {\n\tif (Array.isArray(name)) {\n\t\treturn name;\n\t}\n\n\treturn WHITES[name];\n}\n\n/**\n * Adapt XYZ from white point W1 to W2\n * @param {White | string} W1\n * @param {White | string} W2\n * @param {[number, number, number]} XYZ\n * @param {{ method?: string | undefined }} options\n * @returns {[number, number, number]}\n */\nexport default function adapt (W1, W2, XYZ, options = {}) {\n\tW1 = getWhite(W1);\n\tW2 = getWhite(W2);\n\n\tif (!W1 || !W2) {\n\t\tthrow new TypeError(\n\t\t\t`Missing white point to convert ${!W1 ? \"from\" : \"\"}${!W1 && !W2 ? \"/\" : \"\"}${!W2 ? \"to\" : \"\"}`,\n\t\t);\n\t}\n\n\tif (W1 === W2) {\n\t\t// Same whitepoints, no conversion needed\n\t\treturn XYZ;\n\t}\n\n\tlet env = { W1, W2, XYZ, options };\n\n\thooks.run(\"chromatic-adaptation-start\", env);\n\n\tif (!env.M) {\n\t\tif (env.W1 === WHITES.D65 && env.W2 === WHITES.D50) {\n\t\t\t// prettier-ignore\n\t\t\tenv.M = [\n\t\t\t\t[  1.0479297925449969,   0.022946870601609652, -0.05019226628920524  ],\n\t\t\t\t[  0.02962780877005599,  0.9904344267538799,   -0.017073799063418826 ],\n\t\t\t\t[ -0.009243040646204504, 0.015055191490298152,  0.7518742814281371   ],\n\t\t\t];\n\t\t}\n\t\telse if (env.W1 === WHITES.D50 && env.W2 === WHITES.D65) {\n\t\t\t// prettier-ignore\n\t\t\tenv.M = [\n\t\t\t\t[  0.955473421488075,    -0.02309845494876471,  0.06325924320057072  ],\n\t\t\t\t[ -0.0283697093338637,    1.0099953980813041,   0.021041441191917323 ],\n\t\t\t\t[  0.012314014864481998, -0.020507649298898964, 1.330365926242124    ],\n\t\t\t];\n\t\t}\n\t}\n\n\thooks.run(\"chromatic-adaptation-end\", env);\n\n\tif (env.M) {\n\t\treturn multiply_v3_m3x3(env.XYZ, env.M);\n\t}\n\telse {\n\t\tthrow new TypeError(\"Only Bradford CAT with white points D50 and D65 supported for now.\");\n\t}\n}\n", "// Global defaults one may want to configure\nexport default {\n\tgamut_mapping: \"css\",\n\tprecision: 5,\n\tdeltaE: \"76\", // Default deltaE method\n\tverbose: globalThis?.process?.env?.NODE_ENV?.toLowerCase() !== \"test\",\n\twarn: function warn (msg) {\n\t\tif (this.verbose) {\n\t\t\tglobalThis?.console?.warn?.(msg);\n\t\t}\n\t},\n};\n", "import { isNone, clamp } from \"./util.js\";\nimport hooks from \"./hooks.js\";\nimport ColorSpace from \"./ColorSpace.js\";\nimport defaults from \"./defaults.js\";\n\n/** @import { ColorConstructor } from \"./types.js\" */\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").ArgumentMeta} ArgumentMeta */\n/** @typedef {import(\"./types.js\").ParseFunctionReturn} ParseFunctionReturn */\n/** @typedef {import(\"./types.js\").ParseOptions} ParseOptions */\n\n/**\n * Convert a CSS Color string to a color object\n * @param {string} str\n * @param {ParseOptions} [options]\n * @returns {ColorConstructor}\n */\nexport default function parse (str, options) {\n\tlet env = {\n\t\tstr: String(str)?.trim(),\n\t\toptions,\n\t};\n\n\thooks.run(\"parse-start\", env);\n\n\tif (env.color) {\n\t\treturn env.color;\n\t}\n\n\tenv.parsed = parseFunction(env.str);\n\tlet ret;\n\tlet meta = env.options ? (env.options.parseMeta ?? env.options.meta) : null;\n\n\tif (env.parsed) {\n\t\t// Is a functional syntax\n\t\tlet name = env.parsed.name;\n\t\tlet format;\n\t\tlet space;\n\t\tlet coords = env.parsed.args;\n\t\tlet types = coords.map((c, i) => env.parsed.argMeta[i]?.type);\n\n\t\tif (name === \"color\") {\n\t\t\t// color() function\n\t\t\tlet id = coords.shift();\n\t\t\ttypes.shift();\n\t\t\t// Check against both <dashed-ident> and <ident> versions\n\t\t\tlet alternateId = id.startsWith(\"--\") ? id.substring(2) : `--${id}`;\n\t\t\tlet ids = [id, alternateId];\n\t\t\tformat = ColorSpace.findFormat({ name, id: ids, type: \"function\" });\n\n\t\t\tif (!format) {\n\t\t\t\t// Not found\n\t\t\t\tlet didYouMean;\n\n\t\t\t\tlet registryId = id in ColorSpace.registry ? id : alternateId;\n\t\t\t\tif (registryId in ColorSpace.registry) {\n\t\t\t\t\t// Used color space id instead of color() id, these are often different\n\t\t\t\t\tlet cssId = ColorSpace.registry[registryId].formats?.color?.id;\n\n\t\t\t\t\tif (cssId) {\n\t\t\t\t\t\tlet altColor = str.replace(\"color(\" + id, \"color(\" + cssId);\n\t\t\t\t\t\tdidYouMean = `Did you mean ${altColor}?`;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t`Cannot parse ${env.str}. ` + (didYouMean ?? \"Missing a plugin?\"),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tspace = format.space;\n\n\t\t\tif (format.id.startsWith(\"--\") && !id.startsWith(\"--\")) {\n\t\t\t\tdefaults.warn(\n\t\t\t\t\t`${space.name} is a non-standard space and not currently supported in the CSS spec. ` +\n\t\t\t\t\t\t`Use prefixed color(${format.id}) instead of color(${id}).`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (id.startsWith(\"--\") && !format.id.startsWith(\"--\")) {\n\t\t\t\tdefaults.warn(\n\t\t\t\t\t`${space.name} is a standard space and supported in the CSS spec. ` +\n\t\t\t\t\t\t`Use color(${format.id}) instead of prefixed color(${id}).`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tformat = ColorSpace.findFormat({ name, type: \"function\" });\n\t\t\tspace = format.space;\n\t\t}\n\n\t\tif (meta) {\n\t\t\tObject.assign(meta, {\n\t\t\t\tformat,\n\t\t\t\tformatId: format.name,\n\t\t\t\ttypes,\n\t\t\t\tcommas: env.parsed.commas,\n\t\t\t});\n\t\t}\n\n\t\tlet alpha = 1;\n\n\t\tif (env.parsed.lastAlpha) {\n\t\t\talpha = env.parsed.args.pop();\n\n\t\t\tif (meta) {\n\t\t\t\tmeta.alphaType = types.pop();\n\t\t\t}\n\t\t}\n\n\t\tlet coordCount = format.coords.length;\n\n\t\tif (coords.length !== coordCount) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Expected ${coordCount} coordinates for ${space.id} in ${env.str}), got ${coords.length}`,\n\t\t\t);\n\t\t}\n\n\t\tcoords = format.coerceCoords(coords, types);\n\n\t\tret = { spaceId: space.id, coords, alpha };\n\t}\n\telse {\n\t\t// Custom, colorspace-specific format\n\t\tspaceloop: for (let space of ColorSpace.all) {\n\t\t\tfor (let formatId in space.formats) {\n\t\t\t\tlet format = space.formats[formatId];\n\n\t\t\t\tif (format.type !== \"custom\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (format.test && !format.test(env.str)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// Convert to Format object\n\t\t\t\tlet formatObject = space.getFormat(format);\n\n\t\t\t\tlet color = formatObject.parse(env.str);\n\n\t\t\t\tif (color) {\n\t\t\t\t\tif (meta) {\n\t\t\t\t\t\tObject.assign(meta, { format: formatObject, formatId });\n\t\t\t\t\t}\n\n\t\t\t\t\tret = color;\n\t\t\t\t\tbreak spaceloop;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!ret) {\n\t\t// If we're here, we couldn't parse\n\t\tthrow new TypeError(`Could not parse ${str} as a color. Missing a plugin?`);\n\t}\n\n\t// Clamp alpha to [0, 1]\n\tret.alpha = isNone(ret.alpha)\n\t\t? ret.alpha\n\t\t: ret.alpha === undefined\n\t\t\t? 1\n\t\t\t: clamp(0, ret.alpha, 1);\n\n\treturn ret;\n}\n\n/**\n * Units and multiplication factors for the internally stored numbers\n */\nexport const units = {\n\t\"%\": 0.01,\n\tdeg: 1,\n\tgrad: 0.9,\n\trad: 180 / Math.PI,\n\tturn: 360,\n};\n\nexport const regex = {\n\t// Need to list calc(NaN) explicitly as otherwise its ending paren would terminate the function call\n\tfunction: /^([a-z]+)\\(((?:calc\\(NaN\\)|.)+?)\\)$/i,\n\tnumber: /^([-+]?(?:[0-9]*\\.)?[0-9]+(e[-+]?[0-9]+)?)$/i,\n\tunitValue: RegExp(`(${Object.keys(units).join(\"|\")})$`),\n\n\t// NOTE The -+ are not just for prefix, but also for idents, and e+N notation!\n\tsingleArgument: /\\/?\\s*(none|NaN|calc\\(NaN\\)|[-+\\w.]+(?:%|deg|g?rad|turn)?)/g,\n};\n\n/**\n * Parse a single function argument\n * @param {string} rawArg\n * @returns {{value: number, meta: ArgumentMeta}}\n */\nexport function parseArgument (rawArg) {\n\t/** @type {Partial<ArgumentMeta>} */\n\tlet meta = {};\n\tlet unit = rawArg.match(regex.unitValue)?.[0];\n\t/** @type {string | number} */\n\tlet value = (meta.raw = rawArg);\n\n\tif (unit) {\n\t\t// It\u2019s a dimension token\n\t\tmeta.type = unit === \"%\" ? \"<percentage>\" : \"<angle>\";\n\t\tmeta.unit = unit;\n\t\tmeta.unitless = Number(value.slice(0, -unit.length)); // unitless number\n\n\t\tvalue = meta.unitless * units[unit];\n\t}\n\telse if (regex.number.test(value)) {\n\t\t// It's a number\n\t\t// Convert numerical args to numbers\n\t\tvalue = Number(value);\n\t\tmeta.type = \"<number>\";\n\t}\n\telse if (value === \"none\") {\n\t\tvalue = null;\n\t}\n\telse if (value === \"NaN\" || value === \"calc(NaN)\") {\n\t\tvalue = NaN;\n\t\tmeta.type = \"<number>\";\n\t}\n\telse {\n\t\tmeta.type = \"<ident>\";\n\t}\n\n\treturn { value: /** @type {number} */ (value), meta: /** @type {ArgumentMeta} */ (meta) };\n}\n\n/**\n * Parse a CSS function, regardless of its name and arguments\n * @param {string} str String to parse\n * @return {ParseFunctionReturn | void}\n */\nexport function parseFunction (str) {\n\tif (!str) {\n\t\treturn;\n\t}\n\n\tstr = str.trim();\n\n\tlet parts = str.match(regex.function);\n\n\tif (parts) {\n\t\t// It is a function, parse args\n\t\tlet args = [];\n\t\tlet argMeta = [];\n\t\tlet lastAlpha = false;\n\t\tlet name = parts[1].toLowerCase();\n\n\t\tlet separators = parts[2].replace(regex.singleArgument, ($0, rawArg) => {\n\t\t\tlet { value, meta } = parseArgument(rawArg);\n\n\t\t\tif (\n\t\t\t\t// If there's a slash here, it's modern syntax\n\t\t\t\t$0.startsWith(\"/\") ||\n\t\t\t\t// If there's still elements to process after there's already 3 in `args` (and the we're not dealing with \"color()\"), it's likely to be a legacy color like \"hsl(0, 0%, 0%, 0.5)\"\n\t\t\t\t(name !== \"color\" && args.length === 3)\n\t\t\t) {\n\t\t\t\t// It's alpha\n\t\t\t\tlastAlpha = true;\n\t\t\t}\n\n\t\t\targs.push(value);\n\t\t\targMeta.push(meta);\n\t\t\treturn \"\";\n\t\t});\n\n\t\treturn {\n\t\t\tname,\n\t\t\targs,\n\t\t\targMeta,\n\t\t\tlastAlpha,\n\t\t\tcommas: separators.includes(\",\"),\n\t\t\trawName: parts[1],\n\t\t\trawArgs: parts[2],\n\t\t};\n\t}\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport { isString, isInstance } from \"./util.js\";\nimport parse from \"./parse.js\";\n\n/** @import { ColorTypes, ParseOptions as GetColorOptions, PlainColorObject } from \"./types.js\" */\n\n/**\n * Resolves a color reference (object or string) to a plain color object\n * @overload\n * @param {ColorTypes} color\n * @param {GetColorOptions} [options]\n * @returns {PlainColorObject}\n */\n/**\n * @overload\n * @param {ColorTypes[]} color\n * @param {GetColorOptions} [options]\n * @returns {PlainColorObject[]}\n */\nexport default function getColor (color, options) {\n\tif (Array.isArray(color)) {\n\t\treturn color.map(c => getColor(c, options));\n\t}\n\n\tif (!color) {\n\t\tthrow new TypeError(\"Empty color reference\");\n\t}\n\n\tif (isString(color)) {\n\t\tcolor = parse(color, options);\n\t}\n\n\t// Object fixup\n\tlet space = color.space || color.spaceId;\n\n\tif (typeof space === \"string\") {\n\t\t// Convert string id to color space object\n\t\tcolor.space = ColorSpace.get(space);\n\t}\n\n\tif (color.alpha === undefined) {\n\t\tcolor.alpha = 1;\n\t}\n\n\treturn color;\n}\n", "/**\n * @packageDocumentation\n * Defines the class and other types related to creating color spaces.\n * For the builtin color spaces, see the `spaces` module.\n */\nimport { type, isNone, isInstance } from \"./util.js\";\nimport Format from \"./Format.js\";\nimport { getWhite } from \"./adapt.js\";\nimport hooks from \"./hooks.js\";\nimport getColor from \"./getColor.js\";\n\nconst \u03B5 = 0.000075;\n\n/**\n * Class to represent a color space\n */\nexport default class ColorSpace {\n\tconstructor (options) {\n\t\tthis.id = options.id;\n\t\tthis.name = options.name;\n\t\tthis.base = options.base ? ColorSpace.get(options.base) : null;\n\t\tthis.aliases = options.aliases;\n\n\t\tif (this.base) {\n\t\t\tthis.fromBase = options.fromBase;\n\t\t\tthis.toBase = options.toBase;\n\t\t}\n\n\t\t// Coordinate metadata\n\n\t\tlet coords = options.coords ?? this.base.coords;\n\n\t\tfor (let name in coords) {\n\t\t\tif (!(\"name\" in coords[name])) {\n\t\t\t\tcoords[name].name = name;\n\t\t\t}\n\t\t}\n\t\tthis.coords = coords;\n\n\t\t// White point\n\n\t\tlet white = options.white ?? this.base.white ?? \"D65\";\n\t\tthis.white = getWhite(white);\n\n\t\t// Sort out formats\n\n\t\tthis.formats = options.formats ?? {};\n\n\t\tfor (let name in this.formats) {\n\t\t\tlet format = this.formats[name];\n\t\t\tformat.type ||= \"function\";\n\t\t\tformat.name ||= name;\n\t\t}\n\n\t\tif (!this.formats.color?.id) {\n\t\t\tthis.formats.color = {\n\t\t\t\t...(this.formats.color ?? {}),\n\t\t\t\tid: options.cssId || this.id,\n\t\t\t};\n\t\t}\n\n\t\t// Gamut space\n\n\t\tif (options.gamutSpace) {\n\t\t\t// Gamut space explicitly specified\n\t\t\tthis.gamutSpace =\n\t\t\t\toptions.gamutSpace === \"self\" ? this : ColorSpace.get(options.gamutSpace);\n\t\t}\n\t\telse {\n\t\t\t// No gamut space specified, calculate a sensible default\n\t\t\tif (this.isPolar) {\n\t\t\t\t// Do not check gamut through polar coordinates\n\t\t\t\tthis.gamutSpace = this.base;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.gamutSpace = this;\n\t\t\t}\n\t\t}\n\n\t\t// Optimize inGamut for unbounded spaces\n\t\tif (this.gamutSpace.isUnbounded) {\n\t\t\tthis.inGamut = (coords, options) => {\n\t\t\t\treturn true;\n\t\t\t};\n\t\t}\n\n\t\t// Other stuff\n\t\tthis.referred = options.referred;\n\n\t\t// Compute ancestors and store them, since they will never change\n\t\tObject.defineProperty(this, \"path\", {\n\t\t\tvalue: getPath(this).reverse(),\n\t\t\twritable: false,\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\n\t\thooks.run(\"colorspace-init-end\", this);\n\t}\n\n\tinGamut (coords, { epsilon = \u03B5 } = {}) {\n\t\tif (!this.equals(this.gamutSpace)) {\n\t\t\tcoords = this.to(this.gamutSpace, coords);\n\t\t\treturn this.gamutSpace.inGamut(coords, { epsilon });\n\t\t}\n\n\t\tlet coordMeta = Object.values(this.coords);\n\n\t\treturn coords.every((c, i) => {\n\t\t\tlet meta = coordMeta[i];\n\n\t\t\tif (meta.type !== \"angle\" && meta.range) {\n\t\t\t\tif (isNone(c)) {\n\t\t\t\t\t// NaN is always in gamut\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tlet [min, max] = meta.range;\n\t\t\t\treturn (\n\t\t\t\t\t(min === undefined || c >= min - epsilon) &&\n\t\t\t\t\t(max === undefined || c <= max + epsilon)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t});\n\t}\n\n\tget isUnbounded () {\n\t\treturn Object.values(this.coords).every(coord => !(\"range\" in coord));\n\t}\n\n\tget cssId () {\n\t\treturn this.formats?.color?.id || this.id;\n\t}\n\n\tget isPolar () {\n\t\tfor (let id in this.coords) {\n\t\t\tif (this.coords[id].type === \"angle\") {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t/**\n\t * Lookup a format in this color space\n\t * @param {string | object | Format} format - Format id if string. If object, it's converted to a `Format` object and returned.\n\t * @returns {Format}\n\t */\n\tgetFormat (format) {\n\t\tif (!format) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (format === \"default\") {\n\t\t\tformat = Object.values(this.formats)[0];\n\t\t}\n\t\telse if (typeof format === \"string\") {\n\t\t\tformat = this.formats[format];\n\t\t}\n\n\t\tlet ret = Format.get(format, this);\n\n\t\tif (ret !== format && format.name in this.formats) {\n\t\t\t// Update the format we have on file so we can find it more quickly next time\n\t\t\tthis.formats[format.name] = ret;\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\t/**\n\t * Check if this color space is the same as another color space reference.\n\t * Allows proxying color space objects and comparing color spaces with ids.\n\t * @param {string | ColorSpace} space ColorSpace object or id to compare to\n\t * @returns {boolean}\n\t */\n\tequals (space) {\n\t\tif (!space) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this === space || this.id === space || this.id === space.id;\n\t}\n\n\tto (space, coords) {\n\t\tif (arguments.length === 1) {\n\t\t\tconst color = getColor(space);\n\t\t\t[space, coords] = [color.space, color.coords];\n\t\t}\n\n\t\tspace = ColorSpace.get(space);\n\n\t\tif (this.equals(space)) {\n\t\t\t// Same space, no change needed\n\t\t\treturn coords;\n\t\t}\n\n\t\t// Convert NaN to 0, which seems to be valid in every coordinate of every color space\n\t\tcoords = coords.map(c => (isNone(c) ? 0 : c));\n\n\t\t// Find connection space = lowest common ancestor in the base tree\n\t\tlet myPath = this.path;\n\t\tlet otherPath = space.path;\n\n\t\tlet connectionSpace, connectionSpaceIndex;\n\n\t\tfor (let i = 0; i < myPath.length; i++) {\n\t\t\tif (myPath[i].equals(otherPath[i])) {\n\t\t\t\tconnectionSpace = myPath[i];\n\t\t\t\tconnectionSpaceIndex = i;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!connectionSpace) {\n\t\t\t// This should never happen\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot convert between color spaces ${this} and ${space}: no connection space was found`,\n\t\t\t);\n\t\t}\n\n\t\t// Go up from current space to connection space\n\t\tfor (let i = myPath.length - 1; i > connectionSpaceIndex; i--) {\n\t\t\tcoords = myPath[i].toBase(coords);\n\t\t}\n\n\t\t// Go down from connection space to target space\n\t\tfor (let i = connectionSpaceIndex + 1; i < otherPath.length; i++) {\n\t\t\tcoords = otherPath[i].fromBase(coords);\n\t\t}\n\n\t\treturn coords;\n\t}\n\n\tfrom (space, coords) {\n\t\tif (arguments.length === 1) {\n\t\t\tconst color = getColor(space);\n\t\t\t[space, coords] = [color.space, color.coords];\n\t\t}\n\n\t\tspace = ColorSpace.get(space);\n\n\t\treturn space.to(this, coords);\n\t}\n\n\ttoString () {\n\t\treturn `${this.name} (${this.id})`;\n\t}\n\n\tgetMinCoords () {\n\t\tlet ret = [];\n\n\t\tfor (let id in this.coords) {\n\t\t\tlet meta = this.coords[id];\n\t\t\tlet range = meta.range || meta.refRange;\n\t\t\tret.push(range?.min ?? 0);\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\tstatic registry = {};\n\n\t// Returns array of unique color spaces\n\tstatic get all () {\n\t\treturn [...new Set(Object.values(ColorSpace.registry))];\n\t}\n\n\tstatic register (id, space) {\n\t\tif (arguments.length === 1) {\n\t\t\tspace = arguments[0];\n\t\t\tid = space.id;\n\t\t}\n\n\t\tspace = this.get(space);\n\n\t\tif (this.registry[id] && this.registry[id] !== space) {\n\t\t\tthrow new Error(`Duplicate color space registration: '${id}'`);\n\t\t}\n\t\tthis.registry[id] = space;\n\n\t\t// Register aliases when called without an explicit ID.\n\t\tif (arguments.length === 1 && space.aliases) {\n\t\t\tfor (let alias of space.aliases) {\n\t\t\t\tthis.register(alias, space);\n\t\t\t}\n\t\t}\n\n\t\treturn space;\n\t}\n\n\t/**\n\t * Lookup ColorSpace object by name\n\t * @param {ColorSpace | string} name\n\t */\n\tstatic get (space, ...alternatives) {\n\t\tif (!space || isInstance(space, this)) {\n\t\t\treturn space;\n\t\t}\n\n\t\tlet argType = type(space);\n\n\t\tif (argType === \"string\") {\n\t\t\t// It's a color space id\n\t\t\tlet ret = ColorSpace.registry[space.toLowerCase()];\n\n\t\t\tif (!ret) {\n\t\t\t\tthrow new TypeError(`No color space found with id = \"${space}\"`);\n\t\t\t}\n\n\t\t\treturn ret;\n\t\t}\n\n\t\tif (alternatives.length) {\n\t\t\treturn ColorSpace.get(...alternatives);\n\t\t}\n\n\t\tthrow new TypeError(`${space} is not a valid color space`);\n\t}\n\n\t/**\n\t * Look up all color spaces for a format that matches certain criteria\n\t * @param {object | string} filters\n\t * @param {Array<ColorSpace>} [spaces=ColorSpace.all]\n\t * @returns {Format | null}\n\t */\n\tstatic findFormat (filters, spaces = ColorSpace.all) {\n\t\tif (!filters) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (typeof filters === \"string\") {\n\t\t\tfilters = { name: filters };\n\t\t}\n\n\t\tfor (let space of spaces) {\n\t\t\tfor (let [name, format] of Object.entries(space.formats)) {\n\t\t\t\tformat.name ??= name;\n\t\t\t\tformat.type ??= \"function\";\n\n\t\t\t\tlet matches =\n\t\t\t\t\t(!filters.name || format.name === filters.name) &&\n\t\t\t\t\t(!filters.type || format.type === filters.type);\n\n\t\t\t\tif (filters.id) {\n\t\t\t\t\tlet ids = format.ids || [format.id];\n\t\t\t\t\tlet filterIds = Array.isArray(filters.id) ? filters.id : [filters.id];\n\t\t\t\t\tmatches &&= filterIds.some(id => ids.includes(id));\n\t\t\t\t}\n\n\t\t\t\tif (matches) {\n\t\t\t\t\tlet ret = Format.get(format, space);\n\n\t\t\t\t\tif (ret !== format) {\n\t\t\t\t\t\tspace.formats[format.name] = ret;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Get metadata about a coordinate of a color space\n\t *\n\t * @static\n\t * @param {Array | string} ref\n\t * @param {ColorSpace | string} [workingSpace]\n\t * @return {Object}\n\t */\n\tstatic resolveCoord (ref, workingSpace) {\n\t\tlet coordType = type(ref);\n\t\tlet space, coord;\n\n\t\tif (coordType === \"string\") {\n\t\t\tif (ref.includes(\".\")) {\n\t\t\t\t// Absolute coordinate\n\t\t\t\t[space, coord] = ref.split(\".\");\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// Relative coordinate\n\t\t\t\t[space, coord] = [, ref];\n\t\t\t}\n\t\t}\n\t\telse if (Array.isArray(ref)) {\n\t\t\t[space, coord] = ref;\n\t\t}\n\t\telse {\n\t\t\t// Object\n\t\t\tspace = ref.space;\n\t\t\tcoord = ref.coordId;\n\t\t}\n\n\t\tspace = ColorSpace.get(space);\n\n\t\tif (!space) {\n\t\t\tspace = workingSpace;\n\t\t}\n\n\t\tif (!space) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`Cannot resolve coordinate reference ${ref}: No color space specified and relative references are not allowed here`,\n\t\t\t);\n\t\t}\n\n\t\tcoordType = type(coord);\n\n\t\tif (coordType === \"number\" || (coordType === \"string\" && coord >= 0)) {\n\t\t\t// Resolve numerical coord\n\t\t\tlet meta = Object.entries(space.coords)[coord];\n\n\t\t\tif (meta) {\n\t\t\t\treturn { space, id: meta[0], index: coord, ...meta[1] };\n\t\t\t}\n\t\t}\n\n\t\tspace = ColorSpace.get(space);\n\n\t\tlet normalizedCoord = coord.toLowerCase();\n\n\t\tlet i = 0;\n\t\tfor (let id in space.coords) {\n\t\t\tlet meta = space.coords[id];\n\n\t\t\tif (\n\t\t\t\tid.toLowerCase() === normalizedCoord ||\n\t\t\t\tmeta.name?.toLowerCase() === normalizedCoord\n\t\t\t) {\n\t\t\t\treturn { space, id, index: i, ...meta };\n\t\t\t}\n\n\t\t\ti++;\n\t\t}\n\n\t\tthrow new TypeError(\n\t\t\t`No \"${coord}\" coordinate found in ${space.name}. Its coordinates are: ${Object.keys(space.coords).join(\", \")}`,\n\t\t);\n\t}\n\n\tstatic DEFAULT_FORMAT = {\n\t\ttype: \"functions\",\n\t\tname: \"color\",\n\t};\n}\n\nfunction getPath (space) {\n\tlet ret = [space];\n\n\tfor (let s = space; (s = s.base); ) {\n\t\tret.push(s);\n\t}\n\n\treturn ret;\n}\n", "import ColorSpace from \"../ColorSpace.js\";\n\nexport default new ColorSpace({\n\tid: \"xyz-d65\",\n\tname: \"XYZ D65\",\n\tcoords: {\n\t\tx: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"X\",\n\t\t},\n\t\ty: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Y\",\n\t\t},\n\t\tz: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Z\",\n\t\t},\n\t},\n\twhite: \"D65\",\n\tformats: {\n\t\tcolor: {\n\t\t\tids: [\"xyz-d65\", \"xyz\"],\n\t\t},\n\t},\n\taliases: [\"xyz\"],\n});\n", "import ColorSpace from \"./ColorSpace.js\";\nimport { multiply_v3_m3x3 } from \"./util.js\";\nimport adapt from \"./adapt.js\";\nimport XYZ_D65 from \"./spaces/xyz-d65.js\";\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").RGBOptions} RGBOptions */\n\n/** Convenience class for RGB color spaces */\nexport default class RGBColorSpace extends ColorSpace {\n\t/**\n\t * Creates a new RGB ColorSpace.\n\t * If coords are not specified, they will use the default RGB coords.\n\t * Instead of `fromBase()` and `toBase()` functions,\n\t * you can specify to/from XYZ matrices and have `toBase()` and `fromBase()` automatically generated.\n\t * @param {RGBOptions} options\n\t */\n\tconstructor (options) {\n\t\tif (!options.coords) {\n\t\t\toptions.coords = {\n\t\t\t\tr: {\n\t\t\t\t\trange: [0, 1],\n\t\t\t\t\tname: \"Red\",\n\t\t\t\t},\n\t\t\t\tg: {\n\t\t\t\t\trange: [0, 1],\n\t\t\t\t\tname: \"Green\",\n\t\t\t\t},\n\t\t\t\tb: {\n\t\t\t\t\trange: [0, 1],\n\t\t\t\t\tname: \"Blue\",\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (!options.base) {\n\t\t\toptions.base = XYZ_D65;\n\t\t}\n\n\t\tif (options.toXYZ_M && options.fromXYZ_M) {\n\t\t\toptions.toBase ??= rgb => {\n\t\t\t\tlet xyz = multiply_v3_m3x3(rgb, options.toXYZ_M);\n\n\t\t\t\tif (this.white !== this.base.white) {\n\t\t\t\t\t// Perform chromatic adaptation\n\t\t\t\t\txyz = adapt(this.white, this.base.white, xyz);\n\t\t\t\t}\n\n\t\t\t\treturn xyz;\n\t\t\t};\n\n\t\t\toptions.fromBase ??= xyz => {\n\t\t\t\txyz = adapt(this.base.white, this.white, xyz);\n\t\t\t\treturn multiply_v3_m3x3(xyz, options.fromXYZ_M);\n\t\t\t};\n\t\t}\n\n\t\toptions.referred ??= \"display\";\n\n\t\tsuper(options);\n\t}\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport getColor from \"./getColor.js\";\nimport { toPrecision } from \"./util.js\";\n\n/** @import { ColorTypes, Coords } from \"./types.js\" */\n\n/**\n * Options for {@link getAll}\n * @typedef GetAllOptions\n * @property {string | ColorSpace | undefined} [space]\n * The color space to convert to. Defaults to the color's current space\n * @property {number | undefined} [precision]\n * The number of significant digits to round the coordinates to\n */\n\n/**\n * Get the coordinates of a color in any color space\n * @overload\n * @param {ColorTypes} color\n * @param {string | ColorSpace} [options=color.space] The color space to convert to. Defaults to the color's current space\n * @returns {Coords} The color coordinates in the given color space\n */\n/**\n * @overload\n * @param {ColorTypes} color\n * @param {GetAllOptions} [options]\n * @returns {Coords} The color coordinates in the given color space\n */\nexport default function getAll (color, options) {\n\tcolor = getColor(color);\n\n\tlet space = ColorSpace.get(options, options?.space);\n\tlet precision = options?.precision;\n\n\tlet coords;\n\tif (!space || color.space.equals(space)) {\n\t\t// No conversion needed\n\t\tcoords = color.coords.slice();\n\t}\n\telse {\n\t\tcoords = space.from(color);\n\t}\n\n\treturn precision === undefined ? coords : coords.map(coord => toPrecision(coord, precision));\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport getAll from \"./getAll.js\";\nimport getColor from \"./getColor.js\";\n\n/** @import { ColorTypes, Ref } from \"./types.js\" */\n\n/**\n * @param {ColorTypes} color\n * @param {Ref} prop\n * @returns {number}\n */\nexport default function get (color, prop) {\n\tcolor = getColor(color);\n\n\tif (prop === \"alpha\") {\n\t\treturn color.alpha ?? 1;\n\t}\n\n\tlet { space, index } = ColorSpace.resolveCoord(prop, color.space);\n\tlet coords = getAll(color, space);\n\treturn coords[index];\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport getColor from \"./getColor.js\";\n\n/** @import { ColorTypes, Coords, PlainColorObject } from \"./types.js\" */\n\n/**\n * Set all coordinates of a color at once, in its own color space or another.\n * Modifies the color in place.\n * @overload\n * @param {ColorTypes} color\n * @param {Coords} coords Array of coordinates\n * @param {number} [alpha]\n * @returns {PlainColorObject}\n */\n/**\n * @overload\n * @param {ColorTypes} color\n * @param {string | ColorSpace} space The color space of the provided coordinates.\n * @param {Coords} coords Array of coordinates\n * @param {number} [alpha]\n * @returns {PlainColorObject}\n */\nexport default function setAll (color, space, coords, alpha) {\n\tcolor = getColor(color);\n\n\tif (Array.isArray(space)) {\n\t\t// Space is omitted\n\t\t[space, coords, alpha] = [color.space, space, coords];\n\t}\n\n\tspace = ColorSpace.get(space); // Make sure we have a ColorSpace object\n\tcolor.coords = space === color.space ? coords.slice() : space.to(color.space, coords);\n\n\tif (alpha !== undefined) {\n\t\tcolor.alpha = alpha;\n\t}\n\n\treturn color;\n}\n\n/** @type {\"color\"} */\nsetAll.returns = \"color\";\n", "import ColorSpace from \"./ColorSpace.js\";\nimport getColor from \"./getColor.js\";\nimport get from \"./get.js\";\nimport getAll from \"./getAll.js\";\nimport setAll from \"./setAll.js\";\nimport { type } from \"./util.js\";\n\n/** @import { ColorTypes, PlainColorObject, Ref } from \"./types.js\" */\n\n/**\n * Set properties and return current instance\n * @overload\n * @param {ColorTypes} color\n * @param {Ref} prop\n * @param {number | ((coord: number) => number)} value\n * @returns {PlainColorObject}\n */\n/**\n * @overload\n * @param {ColorTypes} color\n * @param {Record<string, number | ((coord: number) => number)>} props\n * @returns {PlainColorObject}\n */\nexport default function set (color, prop, value) {\n\tcolor = getColor(color);\n\n\tif (arguments.length === 2 && type(arguments[1]) === \"object\") {\n\t\t// Argument is an object literal\n\t\tlet object = arguments[1];\n\t\tfor (let p in object) {\n\t\t\tset(color, p, object[p]);\n\t\t}\n\t}\n\telse {\n\t\tif (typeof value === \"function\") {\n\t\t\tvalue = value(get(color, prop));\n\t\t}\n\n\t\tif (prop === \"alpha\") {\n\t\t\tcolor.alpha = value;\n\t\t}\n\t\telse {\n\t\t\tlet { space, index } = ColorSpace.resolveCoord(prop, color.space);\n\t\t\tlet coords = getAll(color, space);\n\t\t\tcoords[index] = value;\n\t\t\tsetAll(color, space, coords);\n\t\t}\n\t}\n\n\treturn color;\n}\n\n/** @type {\"color\"} */\nset.returns = \"color\";\n", "import ColorSpace from \"../ColorSpace.js\";\nimport adapt from \"../adapt.js\";\nimport XYZ_D65 from \"./xyz-d65.js\";\n\nexport default new ColorSpace({\n\tid: \"xyz-d50\",\n\tname: \"XYZ D50\",\n\twhite: \"D50\",\n\tbase: XYZ_D65,\n\tfromBase: coords => adapt(XYZ_D65.white, \"D50\", coords),\n\ttoBase: coords => adapt(\"D50\", XYZ_D65.white, coords),\n});\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { WHITES } from \"../adapt.js\";\nimport xyz_d50 from \"./xyz-d50.js\";\n\n// \u03BA * \u03B5  = 2^3 = 8\nconst \u03B5 = 216 / 24389; // 6^3/29^3 == (24/116)^3\nconst \u03B53 = 24 / 116;\nconst \u03BA = 24389 / 27; // 29^3/3^3\n\nlet white = WHITES.D50;\n\nexport default new ColorSpace({\n\tid: \"lab\",\n\tname: \"Lab\",\n\tcoords: {\n\t\tl: {\n\t\t\trefRange: [0, 100],\n\t\t\tname: \"Lightness\",\n\t\t},\n\t\ta: {\n\t\t\trefRange: [-125, 125],\n\t\t},\n\t\tb: {\n\t\t\trefRange: [-125, 125],\n\t\t},\n\t},\n\n\t// Assuming XYZ is relative to D50, convert to CIE Lab\n\t// from CIE standard, which now defines these as a rational fraction\n\twhite,\n\n\tbase: xyz_d50,\n\t// Convert D50-adapted XYX to Lab\n\t// CIE 15.3:2004 section 8.2.1.1\n\tfromBase (XYZ) {\n\t\t// XYZ scaled relative to reference white\n\t\tlet xyz = XYZ.map((value, i) => value / white[i]);\n\t\tlet f = xyz.map(value => (value > \u03B5 ? Math.cbrt(value) : (\u03BA * value + 16) / 116));\n\n\t\tlet L = 116 * f[1] - 16;\n\t\tlet a = 500 * (f[0] - f[1]);\n\t\tlet b = 200 * (f[1] - f[2]);\n\n\t\treturn [L, a, b];\n\t},\n\t// Convert Lab to D50-adapted XYZ\n\t// Same result as CIE 15.3:2004 Appendix D although the derivation is different\n\t// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html\n\ttoBase (Lab) {\n\t\t// compute f, starting with the luminance-related term\n\t\tlet [L, a, b] = Lab;\n\t\tlet f = [];\n\t\tf[1] = (L + 16) / 116;\n\t\tf[0] = a / 500 + f[1];\n\t\tf[2] = f[1] - b / 200;\n\n\t\t// compute xyz\n\t\t// prettier-ignore\n\t\tlet xyz = [\n\t\t\tf[0]   > \u03B53 ? Math.pow(f[0], 3)                : (116 * f[0] - 16) / \u03BA,\n\t\t\tLab[0] > 8  ? Math.pow((Lab[0] + 16) / 116, 3) : Lab[0] / \u03BA,\n\t\t\tf[2]   > \u03B53 ? Math.pow(f[2], 3)                : (116 * f[2] - 16) / \u03BA,\n\t\t];\n\n\t\t// Compute XYZ by scaling xyz by reference white\n\t\treturn xyz.map((value, i) => value * white[i]);\n\t},\n\n\tformats: {\n\t\tlab: {\n\t\t\tcoords: [\n\t\t\t\t\"<percentage> | <number>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t],\n\t\t},\n\t},\n});\n", "import * as util from \"./util.js\";\n\n/**\n * Constrain an angle to 360 degrees\n * @param {number} angle\n * @returns {number}\n */\nexport function constrain (angle) {\n\tif (typeof angle !== \"number\") {\n\t\treturn angle;\n\t}\n\n\treturn ((angle % 360) + 360) % 360;\n}\n\n/**\n * @param {\"raw\" | \"increasing\" | \"decreasing\" | \"longer\" | \"shorter\"} arc\n * @param {[number, number]} angles\n * @returns {[number, number]}\n */\nexport function adjust (arc, angles) {\n\tlet [a1, a2] = angles;\n\n\tlet none1 = util.isNone(a1);\n\tlet none2 = util.isNone(a2);\n\n\tif (none1 && none2) {\n\t\treturn [a1, a2];\n\t}\n\telse if (none1) {\n\t\ta1 = a2;\n\t}\n\telse if (none2) {\n\t\ta2 = a1;\n\t}\n\n\tif (arc === \"raw\") {\n\t\treturn angles;\n\t}\n\n\ta1 = constrain(a1);\n\ta2 = constrain(a2);\n\n\tlet angleDiff = a2 - a1;\n\n\tif (arc === \"increasing\") {\n\t\tif (angleDiff < 0) {\n\t\t\ta2 += 360;\n\t\t}\n\t}\n\telse if (arc === \"decreasing\") {\n\t\tif (angleDiff > 0) {\n\t\t\ta1 += 360;\n\t\t}\n\t}\n\telse if (arc === \"longer\") {\n\t\tif (-180 < angleDiff && angleDiff < 180) {\n\t\t\tif (angleDiff > 0) {\n\t\t\t\ta1 += 360;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ta2 += 360;\n\t\t\t}\n\t\t}\n\t}\n\telse if (arc === \"shorter\") {\n\t\tif (angleDiff > 180) {\n\t\t\ta1 += 360;\n\t\t}\n\t\telse if (angleDiff < -180) {\n\t\t\ta2 += 360;\n\t\t}\n\t}\n\n\treturn [a1, a2];\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport Lab from \"./lab.js\";\nimport { constrain as constrainAngle } from \"../angles.js\";\nimport { isNone } from \"../util.js\";\n\nexport default new ColorSpace({\n\tid: \"lch\",\n\tname: \"LCH\",\n\tcoords: {\n\t\tl: {\n\t\t\trefRange: [0, 100],\n\t\t\tname: \"Lightness\",\n\t\t},\n\t\tc: {\n\t\t\trefRange: [0, 150],\n\t\t\tname: \"Chroma\",\n\t\t},\n\t\th: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t},\n\n\tbase: Lab,\n\tfromBase (Lab) {\n\t\t// These methods are used for other polar forms as well, so we can't hardcode the \u03B5\n\t\tif (this.\u03B5 === undefined) {\n\t\t\t// @ts-expect-error Property 'coords' does not exist on type 'string | ColorSpace'\n\t\t\tlet range = Object.values(this.base.coords)[1].refRange;\n\t\t\tlet extent = range[1] - range[0];\n\t\t\tthis.\u03B5 = extent / 100000;\n\t\t}\n\n\t\t// Convert to polar form\n\t\tlet [L, a, b] = Lab;\n\t\tlet isAchromatic = Math.abs(a) < this.\u03B5 && Math.abs(b) < this.\u03B5;\n\t\tlet h = isAchromatic ? null : constrainAngle((Math.atan2(b, a) * 180) / Math.PI);\n\t\tlet C = isAchromatic ? 0 : Math.sqrt(a ** 2 + b ** 2);\n\n\t\treturn [L, C, h];\n\t},\n\ttoBase (lch) {\n\t\t// Convert from polar form\n\t\tlet [L, C, h] = lch;\n\t\tlet a = null,\n\t\t\tb = null;\n\n\t\tif (!isNone(h)) {\n\t\t\tC = C < 0 ? 0 : C; // Clamp negative Chroma\n\t\t\ta = C * Math.cos((h * Math.PI) / 180);\n\t\t\tb = C * Math.sin((h * Math.PI) / 180);\n\t\t}\n\n\t\treturn [L, a, b];\n\t},\n\n\tformats: {\n\t\tlch: {\n\t\t\tcoords: [\"<percentage> | <number>\", \"<number> | <percentage>\", \"<number> | <angle>\"],\n\t\t},\n\t},\n});\n", "import defaults from \"../defaults.js\";\nimport lab from \"../spaces/lab.js\";\nimport lch from \"../spaces/lch.js\";\nimport getColor from \"../getColor.js\";\n\n// deltaE2000 is a statistically significant improvement\n// and is recommended by the CIE and Idealliance\n// especially for color differences less than 10 deltaE76\n// but is wicked complicated\n// and many implementations have small errors!\n// DeltaE2000 is also discontinuous; in case this\n// matters to you, use deltaECMC instead.\n\nconst Gfactor = 25 ** 7;\nconst \u03C0 = Math.PI;\nconst r2d = 180 / \u03C0;\nconst d2r = \u03C0 / 180;\n\nfunction pow7 (x) {\n\t// Faster than x ** 7 or Math.pow(x, 7)\n\n\tconst x2 = x * x;\n\tconst x7 = x2 * x2 * x2 * x;\n\n\treturn x7;\n}\n\n/**\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @param {{ kL?: number | undefined; kC?: number | undefined; kH?: number | undefined }} options\n * @returns {number}\n */\nexport default function (color, sample, { kL = 1, kC = 1, kH = 1 } = {}) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and the function parameter as the sample,\n\t// calculate deltaE 2000.\n\n\t// This implementation assumes the parametric\n\t// weighting factors kL, kC and kH\n\t// for the influence of viewing conditions\n\t// are all 1, as sadly seems typical.\n\t// kL should be increased for lightness texture or noise\n\t// and kC increased for chroma noise\n\n\tlet [L1, a1, b1] = lab.from(color);\n\tlet C1 = lch.from(lab, [L1, a1, b1])[1];\n\tlet [L2, a2, b2] = lab.from(sample);\n\tlet C2 = lch.from(lab, [L2, a2, b2])[1];\n\n\t// Check for negative Chroma,\n\t// which might happen through\n\t// direct user input of LCH values\n\n\tif (C1 < 0) {\n\t\tC1 = 0;\n\t}\n\tif (C2 < 0) {\n\t\tC2 = 0;\n\t}\n\n\tlet Cbar = (C1 + C2) / 2; // mean Chroma\n\n\t// calculate a-axis asymmetry factor from mean Chroma\n\t// this turns JND ellipses for near-neutral colors back into circles\n\tlet C7 = pow7(Cbar);\n\n\tlet G = 0.5 * (1 - Math.sqrt(C7 / (C7 + Gfactor)));\n\n\t// scale a axes by asymmetry factor\n\t// this by the way is why there is no Lab2000 colorspace\n\tlet adash1 = (1 + G) * a1;\n\tlet adash2 = (1 + G) * a2;\n\n\t// calculate new Chroma from scaled a and original b axes\n\tlet Cdash1 = Math.sqrt(adash1 ** 2 + b1 ** 2);\n\tlet Cdash2 = Math.sqrt(adash2 ** 2 + b2 ** 2);\n\n\t// calculate new hues, with zero hue for true neutrals\n\t// and in degrees, not radians\n\n\tlet h1 = adash1 === 0 && b1 === 0 ? 0 : Math.atan2(b1, adash1);\n\tlet h2 = adash2 === 0 && b2 === 0 ? 0 : Math.atan2(b2, adash2);\n\n\tif (h1 < 0) {\n\t\th1 += 2 * \u03C0;\n\t}\n\tif (h2 < 0) {\n\t\th2 += 2 * \u03C0;\n\t}\n\n\th1 *= r2d;\n\th2 *= r2d;\n\n\t// Lightness and Chroma differences; sign matters\n\tlet \u0394L = L2 - L1;\n\tlet \u0394C = Cdash2 - Cdash1;\n\n\t// Hue difference, getting the sign correct\n\tlet hdiff = h2 - h1;\n\tlet hsum = h1 + h2;\n\tlet habs = Math.abs(hdiff);\n\tlet \u0394h;\n\n\tif (Cdash1 * Cdash2 === 0) {\n\t\t\u0394h = 0;\n\t}\n\telse if (habs <= 180) {\n\t\t\u0394h = hdiff;\n\t}\n\telse if (hdiff > 180) {\n\t\t\u0394h = hdiff - 360;\n\t}\n\telse if (hdiff < -180) {\n\t\t\u0394h = hdiff + 360;\n\t}\n\telse {\n\t\tdefaults.warn(\"the unthinkable has happened\");\n\t}\n\n\t// weighted Hue difference, more for larger Chroma\n\tlet \u0394H = 2 * Math.sqrt(Cdash2 * Cdash1) * Math.sin((\u0394h * d2r) / 2);\n\n\t// calculate mean Lightness and Chroma\n\tlet Ldash = (L1 + L2) / 2;\n\tlet Cdash = (Cdash1 + Cdash2) / 2;\n\tlet Cdash7 = pow7(Cdash);\n\n\t// Compensate for non-linearity in the blue region of Lab.\n\t// Four possibilities for hue weighting factor,\n\t// depending on the angles, to get the correct sign\n\tlet hdash;\n\tif (Cdash1 * Cdash2 === 0) {\n\t\thdash = hsum; // which should be zero\n\t}\n\telse if (habs <= 180) {\n\t\thdash = hsum / 2;\n\t}\n\telse if (hsum < 360) {\n\t\thdash = (hsum + 360) / 2;\n\t}\n\telse {\n\t\thdash = (hsum - 360) / 2;\n\t}\n\n\t// positional corrections to the lack of uniformity of CIELAB\n\t// These are all trying to make JND ellipsoids more like spheres\n\n\t// SL Lightness crispening factor\n\t// a background with L=50 is assumed\n\tlet lsq = (Ldash - 50) ** 2;\n\tlet SL = 1 + (0.015 * lsq) / Math.sqrt(20 + lsq);\n\n\t// SC Chroma factor, similar to those in CMC and deltaE 94 formulae\n\tlet SC = 1 + 0.045 * Cdash;\n\n\t// Cross term T for blue non-linearity\n\tlet T = 1;\n\tT -= 0.17 * Math.cos((hdash - 30) * d2r);\n\tT += 0.24 * Math.cos(2 * hdash * d2r);\n\tT += 0.32 * Math.cos((3 * hdash + 6) * d2r);\n\tT -= 0.2 * Math.cos((4 * hdash - 63) * d2r);\n\n\t// SH Hue factor depends on Chroma,\n\t// as well as adjusted hue angle like deltaE94.\n\tlet SH = 1 + 0.015 * Cdash * T;\n\n\t// RT Hue rotation term compensates for rotation of JND ellipses\n\t// and Munsell constant hue lines\n\t// in the medium-high Chroma blue region\n\t// (Hue 225 to 315)\n\tlet \u0394\u03B8 = 30 * Math.exp(-1 * ((hdash - 275) / 25) ** 2);\n\tlet RC = 2 * Math.sqrt(Cdash7 / (Cdash7 + Gfactor));\n\tlet RT = -1 * Math.sin(2 * \u0394\u03B8 * d2r) * RC;\n\n\t// Finally calculate the deltaE, term by term as root sume of squares\n\tlet dE = (\u0394L / (kL * SL)) ** 2;\n\tdE += (\u0394C / (kC * SC)) ** 2;\n\tdE += (\u0394H / (kH * SH)) ** 2;\n\tdE += RT * (\u0394C / (kC * SC)) * (\u0394H / (kH * SH));\n\treturn Math.sqrt(dE);\n\t// Yay!!!\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { multiply_v3_m3x3 } from \"../util.js\";\nimport XYZ_D65 from \"./xyz-d65.js\";\n\n/** @import { Matrix3x3 } from \"../types.js\" */\n\n// Recalculated for consistent reference white\n// see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst XYZtoLMS_M = [\n\t[ 0.8190224379967030, 0.3619062600528904, -0.1288737815209879 ],\n\t[ 0.0329836539323885, 0.9292868615863434,  0.0361446663506424 ],\n\t[ 0.0481771893596242, 0.2642395317527308,  0.6335478284694309 ],\n];\n// inverse of XYZtoLMS_M\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst LMStoXYZ_M = [\n\t[  1.2268798758459243, -0.5578149944602171,  0.2813910456659647 ],\n\t[ -0.0405757452148008,  1.1122868032803170, -0.0717110580655164 ],\n\t[ -0.0763729366746601, -0.4214933324022432,  1.5869240198367816 ],\n];\n/** @type {Matrix3x3} */\n// prettier-ignore\nexport const LMStoLab_M = [\n\t[ 0.2104542683093140,  0.7936177747023054, -0.0040720430116193 ],\n\t[ 1.9779985324311684, -2.4285922420485799,  0.4505937096174110 ],\n\t[ 0.0259040424655478,  0.7827717124575296, -0.8086757549230774 ],\n];\n// LMStoIab_M inverted\n/** @type {Matrix3x3} */\n// prettier-ignore\nexport const LabtoLMS_M = [\n\t[ 1.0000000000000000,  0.3963377773761749,  0.2158037573099136 ],\n\t[ 1.0000000000000000, -0.1055613458156586, -0.0638541728258133 ],\n\t[ 1.0000000000000000, -0.0894841775298119, -1.2914855480194092 ],\n];\n\nexport default new ColorSpace({\n\tid: \"oklab\",\n\tname: \"Oklab\",\n\tcoords: {\n\t\tl: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Lightness\",\n\t\t},\n\t\ta: {\n\t\t\trefRange: [-0.4, 0.4],\n\t\t},\n\t\tb: {\n\t\t\trefRange: [-0.4, 0.4],\n\t\t},\n\t},\n\n\t// Note that XYZ is relative to D65\n\twhite: \"D65\",\n\tbase: XYZ_D65,\n\tfromBase (XYZ) {\n\t\t// move to LMS cone domain\n\t\tlet LMS = multiply_v3_m3x3(XYZ, XYZtoLMS_M);\n\n\t\t// non-linearity\n\t\tLMS[0] = Math.cbrt(LMS[0]);\n\t\tLMS[1] = Math.cbrt(LMS[1]);\n\t\tLMS[2] = Math.cbrt(LMS[2]);\n\n\t\treturn multiply_v3_m3x3(LMS, LMStoLab_M, LMS);\n\t},\n\ttoBase (OKLab) {\n\t\t// move to LMS cone domain\n\t\tlet LMSg = multiply_v3_m3x3(OKLab, LabtoLMS_M);\n\n\t\t// restore linearity\n\t\tLMSg[0] = LMSg[0] ** 3;\n\t\tLMSg[1] = LMSg[1] ** 3;\n\t\tLMSg[2] = LMSg[2] ** 3;\n\n\t\treturn multiply_v3_m3x3(LMSg, LMStoXYZ_M, LMSg);\n\t},\n\n\tformats: {\n\t\toklab: {\n\t\t\tcoords: [\n\t\t\t\t\"<percentage> | <number>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t],\n\t\t},\n\t},\n});\n", "import oklab from \"../spaces/oklab.js\";\nimport getColor from \"../getColor.js\";\n\n/**\n * More accurate color-difference formulae\n * than the simple 1976 Euclidean distance in CIE Lab\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function (color, sample) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and a sample,\n\t// calculate deltaEOK, term by term as root sum of squares\n\tlet [L1, a1, b1] = oklab.from(color);\n\tlet [L2, a2, b2] = oklab.from(sample);\n\tlet \u0394L = L1 - L2;\n\tlet \u0394a = a1 - a2;\n\tlet \u0394b = b1 - b2;\n\treturn Math.sqrt(\u0394L ** 2 + \u0394a ** 2 + \u0394b ** 2);\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport getColor from \"./getColor.js\";\n\n/** @import { ColorTypes } from \"./types.js\" */\n\nconst \u03B5 = 0.000075;\n\n/**\n * Check if a color is in gamut of either its own or another color space\n * @param {ColorTypes} color\n * @param {string | ColorSpace} [space]\n * @param {{ epsilon?: number | undefined }} [param2]\n * @returns {boolean}\n */\nexport default function inGamut (color, space, { epsilon = \u03B5 } = {}) {\n\tcolor = getColor(color);\n\n\tif (!space) {\n\t\tspace = color.space;\n\t}\n\n\tspace = ColorSpace.get(space);\n\tlet coords = color.coords;\n\n\tif (space !== color.space) {\n\t\tcoords = space.from(color);\n\t}\n\n\treturn space.inGamut(coords, { epsilon });\n}\n", "/** @import { Coords, PlainColorObject } from \"./types.js\" */\n\n/**\n * @param {PlainColorObject} color\n * @returns {PlainColorObject}\n */\nexport default function clone (color) {\n\treturn {\n\t\tspace: color.space,\n\t\tcoords: /** @type {Coords} */ (color.coords.slice()),\n\t\talpha: color.alpha,\n\t};\n}\n", "import ColorSpace from \"./ColorSpace.js\";\nimport { isNone } from \"./util.js\";\n\n/** @import { ColorTypes } from \"./types.js\" */\n\n/**\n * Euclidean distance of colors in an arbitrary color space\n * @param {ColorTypes} color1\n * @param {ColorTypes} color2\n * @param {string | ColorSpace} space\n * @returns {number}\n */\nexport default function distance (color1, color2, space = \"lab\") {\n\tspace = ColorSpace.get(space);\n\n\t// Assume getColor() is called on color in space.from()\n\tlet coords1 = space.from(color1);\n\tlet coords2 = space.from(color2);\n\n\treturn Math.sqrt(\n\t\tcoords1.reduce((acc, c1, i) => {\n\t\t\tlet c2 = coords2[i];\n\t\t\tif (isNone(c1) || isNone(c2)) {\n\t\t\t\treturn acc;\n\t\t\t}\n\n\t\t\treturn acc + (c2 - c1) ** 2;\n\t\t}, 0),\n\t);\n}\n", "import distance from \"../distance.js\";\nimport getColor from \"../getColor.js\";\n\n/**\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function deltaE76 (color, sample) {\n\t// Assume getColor() is called in the distance function\n\treturn distance(color, sample, \"lab\");\n}\n", "import lab from \"../spaces/lab.js\";\nimport lch from \"../spaces/lch.js\";\nimport getColor from \"../getColor.js\";\nimport { isNone } from \"../util.js\";\n\n// More accurate color-difference formulae\n// than the simple 1976 Euclidean distance in Lab\n\n// CMC by the Color Measurement Committee of the\n// Bradford Society of Dyeists and Colorsts, 1994.\n// Uses LCH rather than Lab,\n// with different weights for L, C and H differences\n// A nice increase in accuracy for modest increase in complexity\nconst \u03C0 = Math.PI;\nconst d2r = \u03C0 / 180;\n\n/**\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @param {{ l?: number | undefined; c?: number | undefined }} options\n * @returns {number}\n */\nexport default function (color, sample, { l = 2, c = 1 } = {}) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and a sample,\n\t// calculate deltaE CMC.\n\n\t// This implementation assumes the parametric\n\t// weighting factors l:c are 2:1\n\t// which is typical for non-textile uses.\n\n\tlet [L1, a1, b1] = lab.from(color);\n\tlet [, C1, H1] = lch.from(lab, [L1, a1, b1]);\n\tlet [L2, a2, b2] = lab.from(sample);\n\tlet C2 = lch.from(lab, [L2, a2, b2])[1];\n\n\t// let [L1, a1, b1] = color.getAll(lab);\n\t// let C1 = color.get(\"lch.c\");\n\t// let H1 = color.get(\"lch.h\");\n\t// let [L2, a2, b2] = sample.getAll(lab);\n\t// let C2 = sample.get(\"lch.c\");\n\n\t// Check for negative Chroma,\n\t// which might happen through\n\t// direct user input of LCH values\n\n\tif (C1 < 0) {\n\t\tC1 = 0;\n\t}\n\tif (C2 < 0) {\n\t\tC2 = 0;\n\t}\n\n\t// we don't need H2 as \u0394H is calculated from \u0394a, \u0394b and \u0394C\n\n\t// Lightness and Chroma differences\n\t// These are (color - sample), unlike deltaE2000\n\tlet \u0394L = L1 - L2;\n\tlet \u0394C = C1 - C2;\n\n\tlet \u0394a = a1 - a2;\n\tlet \u0394b = b1 - b2;\n\n\t// weighted Hue difference, less for larger Chroma difference\n\n\tlet H2 = \u0394a ** 2 + \u0394b ** 2 - \u0394C ** 2;\n\t// due to roundoff error it is possible that, for zero a and b,\n\t// \u0394C > \u0394a + \u0394b is 0, resulting in attempting\n\t// to take the square root of a negative number\n\n\t// trying instead the equation from Industrial Color Physics\n\t// By Georg A. Klein\n\n\t// let \u0394H = ((a1 * b2) - (a2 * b1)) / Math.sqrt(0.5 * ((C2 * C1) + (a2 * a1) + (b2 * b1)));\n\t// console.log({\u0394H});\n\t// This gives the same result to 12 decimal places\n\t// except it sometimes NaNs when trying to root a negative number\n\n\t// let \u0394H = Math.sqrt(H2); we never actually use the root, it gets squared again!!\n\n\t// positional corrections to the lack of uniformity of CIELAB\n\t// These are all trying to make JND ellipsoids more like spheres\n\n\t// SL Lightness crispening factor, depends entirely on L1 not L2\n\tlet SL = 0.511; // linear portion of the Y to L transfer function\n\tif (L1 >= 16) {\n\t\t// cubic portion\n\t\tSL = (0.040975 * L1) / (1 + 0.01765 * L1);\n\t}\n\n\t// SC Chroma factor\n\tlet SC = (0.0638 * C1) / (1 + 0.0131 * C1) + 0.638;\n\n\t// Cross term T for blue non-linearity\n\tlet T;\n\tif (isNone(H1)) {\n\t\tH1 = 0;\n\t}\n\n\tif (H1 >= 164 && H1 <= 345) {\n\t\tT = 0.56 + Math.abs(0.2 * Math.cos((H1 + 168) * d2r));\n\t}\n\telse {\n\t\tT = 0.36 + Math.abs(0.4 * Math.cos((H1 + 35) * d2r));\n\t}\n\t// console.log({T});\n\n\t// SH Hue factor also depends on C1,\n\tlet C4 = Math.pow(C1, 4);\n\tlet F = Math.sqrt(C4 / (C4 + 1900));\n\tlet SH = SC * (F * T + 1 - F);\n\n\t// Finally calculate the deltaE, term by term as root sume of squares\n\tlet dE = (\u0394L / (l * SL)) ** 2;\n\tdE += (\u0394C / (c * SC)) ** 2;\n\tdE += H2 / SH ** 2;\n\t// dE += (\u0394H / SH)  ** 2;\n\treturn Math.sqrt(dE);\n\t// Yay!!!\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport XYZ_D65 from \"./xyz-d65.js\";\n\nconst Yw = 203; // absolute luminance of media white\n\nexport default new ColorSpace({\n\t// Absolute CIE XYZ, with a D65 whitepoint,\n\t// as used in most HDR colorspaces as a starting point.\n\t// SDR spaces are converted per BT.2048\n\t// so that diffuse, media white is 203 cd/m\u00B2\n\tid: \"xyz-abs-d65\",\n\tcssId: \"--xyz-abs-d65\",\n\tname: \"Absolute XYZ D65\",\n\tcoords: {\n\t\tx: {\n\t\t\trefRange: [0, 9504.7],\n\t\t\tname: \"Xa\",\n\t\t},\n\t\ty: {\n\t\t\trefRange: [0, 10000],\n\t\t\tname: \"Ya\",\n\t\t},\n\t\tz: {\n\t\t\trefRange: [0, 10888.3],\n\t\t\tname: \"Za\",\n\t\t},\n\t},\n\n\tbase: XYZ_D65,\n\tfromBase (XYZ) {\n\t\t// Make XYZ absolute, not relative to media white\n\t\t// Maximum luminance in PQ is 10,000 cd/m\u00B2\n\t\t// Relative XYZ has Y=1 for media white\n\t\treturn XYZ.map(v => v * Yw);\n\t},\n\ttoBase (AbsXYZ) {\n\t\t// Convert to media-white relative XYZ\n\t\treturn AbsXYZ.map(v => v / Yw);\n\t},\n});\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { multiply_v3_m3x3 } from \"../util.js\";\nimport XYZ_Abs_D65 from \"./xyz-abs-d65.js\";\nimport { spow } from \"../util.js\";\n\n/** @import { Matrix3x3, Vector3 } from \"../types.js\" */\n\nconst b = 1.15;\nconst g = 0.66;\nconst n = 2610 / 2 ** 14;\nconst ninv = 2 ** 14 / 2610;\nconst c1 = 3424 / 2 ** 12;\nconst c2 = 2413 / 2 ** 7;\nconst c3 = 2392 / 2 ** 7;\nconst p = (1.7 * 2523) / 2 ** 5;\nconst pinv = 2 ** 5 / (1.7 * 2523);\nconst d = -0.56;\nconst d0 = 1.6295499532821566e-11;\n\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst XYZtoCone_M = [\n\t[  0.41478972, 0.579999,  0.0146480 ],\n\t[ -0.2015100,  1.120649,  0.0531008 ],\n\t[ -0.0166008,  0.264800,  0.6684799 ],\n];\n// XYZtoCone_M inverted\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst ConetoXYZ_M = [\n\t[  1.9242264357876067,  -1.0047923125953657,  0.037651404030618   ],\n\t[  0.35031676209499907,  0.7264811939316552, -0.06538442294808501 ],\n\t[ -0.09098281098284752, -0.3127282905230739,  1.5227665613052603  ],\n];\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst ConetoIab_M = [\n\t[  0.5,       0.5,       0        ],\n\t[  3.524000, -4.066708,  0.542708 ],\n\t[  0.199076,  1.096799, -1.295875 ],\n];\n// ConetoIab_M inverted\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst IabtoCone_M = [\n\t[ 1,                   0.13860504327153927,   0.05804731615611883 ],\n\t[ 1,                  -0.1386050432715393,   -0.058047316156118904 ],\n\t[ 1,                  -0.09601924202631895,  -0.81189189605603900  ],\n];\n\nexport default new ColorSpace({\n\tid: \"jzazbz\",\n\tname: \"Jzazbz\",\n\tcoords: {\n\t\tjz: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Jz\",\n\t\t},\n\t\taz: {\n\t\t\trefRange: [-0.21, 0.21],\n\t\t},\n\t\tbz: {\n\t\t\trefRange: [-0.21, 0.21],\n\t\t},\n\t},\n\n\tbase: XYZ_Abs_D65,\n\tfromBase (XYZ) {\n\t\t// First make XYZ absolute, not relative to media white\n\t\t// Maximum luminance in PQ is 10,000 cd/m\u00B2\n\t\t// Relative XYZ has Y=1 for media white\n\t\t// BT.2048 says media white Y=203 at PQ 58\n\n\t\tlet [Xa, Ya, Za] = XYZ;\n\n\t\t// modify X and Y to minimize blue curvature\n\t\tlet Xm = b * Xa - (b - 1) * Za;\n\t\tlet Ym = g * Ya - (g - 1) * Xa;\n\n\t\t// move to LMS cone domain\n\t\tlet LMS = multiply_v3_m3x3([Xm, Ym, Za], XYZtoCone_M);\n\n\t\t// PQ-encode LMS\n\t\tlet PQLMS = /** @type {Vector3} } */ (\n\t\t\tLMS.map(function (val) {\n\t\t\t\tlet num = c1 + c2 * spow(val / 10000, n);\n\t\t\t\tlet denom = 1 + c3 * spow(val / 10000, n);\n\n\t\t\t\treturn spow(num / denom, p);\n\t\t\t})\n\t\t);\n\n\t\t// almost there, calculate Iz az bz\n\t\tlet [Iz, az, bz] = multiply_v3_m3x3(PQLMS, ConetoIab_M);\n\t\t// console.log({Iz, az, bz});\n\n\t\tlet Jz = ((1 + d) * Iz) / (1 + d * Iz) - d0;\n\t\treturn [Jz, az, bz];\n\t},\n\ttoBase (Jzazbz) {\n\t\tlet [Jz, az, bz] = Jzazbz;\n\t\tlet Iz = (Jz + d0) / (1 + d - d * (Jz + d0));\n\n\t\t// bring into LMS cone domain\n\t\tlet PQLMS = multiply_v3_m3x3([Iz, az, bz], IabtoCone_M);\n\n\t\t// convert from PQ-coded to linear-light\n\t\tlet LMS = /** @type {Vector3} } */ (\n\t\t\tPQLMS.map(function (val) {\n\t\t\t\tlet num = c1 - spow(val, pinv);\n\t\t\t\tlet denom = c3 * spow(val, pinv) - c2;\n\t\t\t\tlet x = 10000 * spow(num / denom, ninv);\n\n\t\t\t\treturn x; // luminance relative to diffuse white, [0, 70 or so].\n\t\t\t})\n\t\t);\n\n\t\t// modified abs XYZ\n\t\tlet [Xm, Ym, Za] = multiply_v3_m3x3(LMS, ConetoXYZ_M);\n\n\t\t// un-modify X and Y to get D65 XYZ, relative to media white\n\t\tlet Xa = (Xm + (b - 1) * Za) / b;\n\t\tlet Ya = (Ym + (g - 1) * Xa) / g;\n\t\treturn [Xa, Ya, Za];\n\t},\n\n\tformats: {\n\t\t// https://drafts.csswg.org/css-color-hdr/#Jzazbz\n\t\tjzazbz: {\n\t\t\tcoords: [\n\t\t\t\t\"<percentage> | <number>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t],\n\t\t},\n\t},\n});\n", "import ColorSpace from \"../ColorSpace.js\";\nimport Jzazbz from \"./jzazbz.js\";\nimport lch from \"./lch.js\";\n\nexport default new ColorSpace({\n\tid: \"jzczhz\",\n\tname: \"JzCzHz\",\n\tcoords: {\n\t\tjz: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Jz\",\n\t\t},\n\t\tcz: {\n\t\t\trefRange: [0, 0.26],\n\t\t\tname: \"Chroma\",\n\t\t},\n\t\thz: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t},\n\n\tbase: Jzazbz,\n\tfromBase: lch.fromBase,\n\ttoBase: lch.toBase,\n\n\tformats: {\n\t\t// https://drafts.csswg.org/css-color-hdr/#JzCzhz\n\t\tjzczhz: {\n\t\t\tcoords: [\"<percentage> | <number>\", \"<number> | <percentage>\", \"<number> | <angle>\"],\n\t\t},\n\t},\n});\n", "import jzczhz from \"../spaces/jzczhz.js\";\nimport getColor from \"../getColor.js\";\nimport { isNone } from \"../util.js\";\n\n/**\n * More accurate color-difference formulae\n * than the simple 1976 Euclidean distance in Lab\n *\n * Uses JzCzHz, which has improved perceptual uniformity\n * and thus a simple Euclidean root-sum of \u0394L\u00B2 \u0394C\u00B2 \u0394H\u00B2\n * gives good results.\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function (color, sample) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and a sample,\n\t// calculate deltaE in JzCzHz.\n\tlet [Jz1, Cz1, Hz1] = jzczhz.from(color);\n\tlet [Jz2, Cz2, Hz2] = jzczhz.from(sample);\n\n\t// Lightness and Chroma differences\n\t// sign does not matter as they are squared.\n\tlet \u0394J = Jz1 - Jz2;\n\tlet \u0394C = Cz1 - Cz2;\n\n\t// length of chord for \u0394H\n\tif (isNone(Hz1) && isNone(Hz2)) {\n\t\t// both undefined hues\n\t\tHz1 = 0;\n\t\tHz2 = 0;\n\t}\n\telse if (isNone(Hz1)) {\n\t\t// one undefined, set to the defined hue\n\t\tHz1 = Hz2;\n\t}\n\telse if (isNone(Hz2)) {\n\t\tHz2 = Hz1;\n\t}\n\n\tlet \u0394h = Hz1 - Hz2;\n\tlet \u0394H = 2 * Math.sqrt(Cz1 * Cz2) * Math.sin((\u0394h / 2) * (Math.PI / 180));\n\n\treturn Math.sqrt(\u0394J ** 2 + \u0394C ** 2 + \u0394H ** 2);\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { multiply_v3_m3x3 } from \"../util.js\";\nimport XYZ_Abs_D65 from \"./xyz-abs-d65.js\";\n\n/** @import { Matrix3x3, Vector3 } from \"../types.js\" */\n\nconst c1 = 3424 / 4096;\nconst c2 = 2413 / 128;\nconst c3 = 2392 / 128;\nconst m1 = 2610 / 16384;\nconst m2 = 2523 / 32;\nconst im1 = 16384 / 2610;\nconst im2 = 32 / 2523;\n\n// The matrix below includes the 4% crosstalk components\n// and is from the Dolby \"What is ICtCp\" paper\"\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst XYZtoLMS_M = [\n\t[  0.3592832590121217,  0.6976051147779502, -0.0358915932320290 ],\n\t[ -0.1920808463704993,  1.1004767970374321,  0.0753748658519118 ],\n\t[  0.0070797844607479,  0.0748396662186362,  0.8433265453898765 ],\n];\n// linear-light Rec.2020 to LMS, again with crosstalk\n// rational terms from Jan Fr\u00F6hlich,\n// Encoding High Dynamic Range andWide Color Gamut Imagery, p.97\n// and ITU-R BT.2124-0 p.2\n/*\nconst Rec2020toLMS_M = [\n\t[ 1688 / 4096,  2146 / 4096,   262 / 4096 ],\n\t[  683 / 4096,  2951 / 4096,   462 / 4096 ],\n\t[   99 / 4096,   309 / 4096,  3688 / 4096 ]\n];\n*/\n// this includes the Ebner LMS coefficients,\n// the rotation, and the scaling to [-0.5,0.5] range\n// rational terms from Fr\u00F6hlich p.97\n// and ITU-R BT.2124-0 pp.2-3\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst LMStoIPT_M = [\n\t[  2048 / 4096,   2048 / 4096,       0      ],\n\t[  6610 / 4096, -13613 / 4096,  7003 / 4096 ],\n\t[ 17933 / 4096, -17390 / 4096,  -543 / 4096 ],\n];\n\n// inverted matrices, calculated from the above\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst IPTtoLMS_M = [\n\t[ 0.9999999999999998,  0.0086090370379328,  0.1110296250030260 ],\n\t[ 0.9999999999999998, -0.0086090370379328, -0.1110296250030259 ],\n\t[ 0.9999999999999998,  0.5600313357106791, -0.3206271749873188 ],\n];\n/*\n// prettier-ignore\nconst LMStoRec2020_M = [\n\t[ 3.4375568932814012112,   -2.5072112125095058195,   0.069654319228104608382],\n\t[-0.79142868665644156125,   1.9838372198740089874,  -0.19240853321756742626 ],\n\t[-0.025646662911506476363, -0.099240248643945566751, 1.1248869115554520431  ]\n];\n*/\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst LMStoXYZ_M = [\n\t[  2.0701522183894223, -1.3263473389671563,  0.2066510476294053 ],\n\t[  0.3647385209748072,  0.6805660249472273, -0.0453045459220347 ],\n\t[ -0.0497472075358123, -0.0492609666966131,  1.1880659249923042 ],\n];\n\n// Only the PQ form of ICtCp is implemented here. There is also an HLG form.\n// from Dolby, \"WHAT IS ICTCP?\"\n// https://professional.dolby.com/siteassets/pdfs/ictcp_dolbywhitepaper_v071.pdf\n// and\n// Dolby, \"Perceptual Color Volume\n// Measuring the Distinguishable Colors of HDR and WCG Displays\"\n// https://professional.dolby.com/siteassets/pdfs/dolby-vision-measuring-perceptual-color-volume-v7.1.pdf\nexport default new ColorSpace({\n\tid: \"ictcp\",\n\tname: \"ICTCP\",\n\t// From BT.2100-2 page 7:\n\t// During production, signal values are expected to exceed the\n\t// range E\u2032 = [0.0 : 1.0]. This provides processing headroom and avoids\n\t// signal degradation during cascaded processing. Such values of E\u2032,\n\t// below 0.0 or exceeding 1.0, should not be clipped during production\n\t// and exchange.\n\t// Values below 0.0 should not be clipped in reference displays (even\n\t// though they represent \u201Cnegative\u201D light) to allow the black level of\n\t// the signal (LB) to be properly set using test signals known as \u201CPLUGE\u201D\n\tcoords: {\n\t\ti: {\n\t\t\trefRange: [0, 1], // Constant luminance,\n\t\t\tname: \"I\",\n\t\t},\n\t\tct: {\n\t\t\trefRange: [-0.5, 0.5], // Full BT.2020 gamut in range [-0.5, 0.5]\n\t\t\tname: \"CT\",\n\t\t},\n\t\tcp: {\n\t\t\trefRange: [-0.5, 0.5],\n\t\t\tname: \"CP\",\n\t\t},\n\t},\n\n\tbase: XYZ_Abs_D65,\n\tfromBase (XYZ) {\n\t\t// move to LMS cone domain\n\t\tlet LMS = multiply_v3_m3x3(XYZ, XYZtoLMS_M);\n\n\t\treturn LMStoICtCp(LMS);\n\t},\n\ttoBase (ICtCp) {\n\t\tlet LMS = ICtCptoLMS(ICtCp);\n\n\t\treturn multiply_v3_m3x3(LMS, LMStoXYZ_M);\n\t},\n\n\tformats: {\n\t\tictcp: {\n\t\t\tcoords: [\n\t\t\t\t\"<percentage> | <number>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t\t\"<number> | <percentage>\",\n\t\t\t],\n\t\t},\n\t},\n});\n\n/**\n *\n * @param {Vector3} LMS\n * @returns {Vector3}\n */\nfunction LMStoICtCp (LMS) {\n\t// apply the PQ EOTF\n\t// we can't ever be dividing by zero because of the \"1 +\" in the denominator\n\tlet PQLMS = /** @type {Vector3} */ (\n\t\tLMS.map(function (val) {\n\t\t\tlet num = c1 + c2 * (val / 10000) ** m1;\n\t\t\tlet denom = 1 + c3 * (val / 10000) ** m1;\n\n\t\t\treturn (num / denom) ** m2;\n\t\t})\n\t);\n\n\t// LMS to IPT, with rotation for Y'C'bC'r compatibility\n\treturn multiply_v3_m3x3(PQLMS, LMStoIPT_M);\n}\n\n/**\n *\n * @param {Vector3} ICtCp\n * @returns {Vector3}\n */\nfunction ICtCptoLMS (ICtCp) {\n\tlet PQLMS = multiply_v3_m3x3(ICtCp, IPTtoLMS_M);\n\n\t// From BT.2124-0 Annex 2 Conversion 3\n\tlet LMS = /** @type {Vector3} */ (\n\t\tPQLMS.map(function (val) {\n\t\t\tlet num = Math.max(val ** im2 - c1, 0);\n\t\t\tlet denom = c2 - c3 * val ** im2;\n\t\t\treturn 10000 * (num / denom) ** im1;\n\t\t})\n\t);\n\n\treturn LMS;\n}\n", "import ictcp from \"../spaces/ictcp.js\";\nimport getColor from \"../getColor.js\";\n\n/**\n * Delta E in ICtCp space,\n * which the ITU calls Delta E ITP, which is shorter.\n * Formulae from ITU Rec. ITU-R BT.2124-0\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function (color, sample) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and a sample,\n\t// calculate deltaE in ICtCp\n\t// which is simply the Euclidean distance\n\n\tlet [I1, T1, P1] = ictcp.from(color);\n\tlet [I2, T2, P2] = ictcp.from(sample);\n\n\t// the 0.25 factor is to undo the encoding scaling in Ct\n\t// the 720 is so that 1 deltaE = 1 JND\n\t// per  ITU-R BT.2124-0 p.3\n\n\treturn 720 * Math.sqrt((I1 - I2) ** 2 + 0.25 * (T1 - T2) ** 2 + (P1 - P2) ** 2);\n}\n", "import oklab from \"../spaces/oklab.js\";\nimport getColor from \"../getColor.js\";\n\n/**\n * More accurate color-difference formulae\n * than the simple 1976 Euclidean distance in CIE Lab\n * The Oklab a and b axes are scaled relative to the L axis, for better uniformity\n * Bj\u00F6rn Ottosson said:\n * \"I've recently done some tests with color distance datasets as implemented\n * in Colorio and on both the Combvd dataset and the OSA-UCS dataset a\n * scale factor of slightly more than 2 for a and b would give the best results\n * (2.016 works best for Combvd and 2.045 for the OSA-UCS dataset).\"\n * @see {@link <https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-945714988>}\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function (color, sample) {\n\t[color, sample] = getColor([color, sample]);\n\n\t// Given this color as the reference\n\t// and a sample,\n\t// calculate deltaEOK2, term by term as root sum of squares\n\tlet abscale = 2;\n\tlet [L1, a1, b1] = oklab.from(color);\n\tlet [L2, a2, b2] = oklab.from(sample);\n\tlet \u0394L = L1 - L2;\n\tlet \u0394a = abscale * (a1 - a2);\n\tlet \u0394b = abscale * (b1 - b2);\n\treturn Math.sqrt(\u0394L ** 2 + \u0394a ** 2 + \u0394b ** 2);\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { multiply_v3_m3x3, interpolate, copySign, spow, zdiv, bisectLeft } from \"../util.js\";\nimport { constrain } from \"../angles.js\";\nimport xyz_d65 from \"./xyz-d65.js\";\nimport { WHITES } from \"../adapt.js\";\n\n/** @import { Coords, Matrix3x3, Vector3 } from \"../types.js\" */\n\n// Type re-exports\n/** @typedef {import(\"../types.js\").Cam16Object} Cam16Object */\n/** @typedef {import(\"../types.js\").Cam16Input} Cam16Input */\n/** @typedef {import(\"../types.js\").Cam16Environment} Cam16Environment */\n\nconst white = WHITES.D65;\nconst adaptedCoef = 0.42;\nconst adaptedCoefInv = 1 / adaptedCoef;\nconst tau = 2 * Math.PI;\n\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst cat16 = [\n\t[  0.401288,  0.650173, -0.051461 ],\n\t[ -0.250268,  1.204414,  0.045854 ],\n\t[ -0.002079,  0.048952,  0.953127 ],\n];\n\n/** @type {Matrix3x3} */\nconst cat16Inv = [\n\t[1.8620678550872327, -1.0112546305316843, 0.14918677544445175],\n\t[0.38752654323613717, 0.6214474419314753, -0.008973985167612518],\n\t[-0.015841498849333856, -0.03412293802851557, 1.0499644368778496],\n];\n\n/** @type {Matrix3x3} */\nconst m1 = [\n\t[460.0, 451.0, 288.0],\n\t[460.0, -891.0, -261.0],\n\t[460.0, -220.0, -6300.0],\n];\n\nconst surroundMap = {\n\tdark: [0.8, 0.525, 0.8],\n\tdim: [0.9, 0.59, 0.9],\n\taverage: [1, 0.69, 1],\n};\n\nconst hueQuadMap = {\n\t// Red, Yellow, Green, Blue, Red\n\th: [20.14, 90.0, 164.25, 237.53, 380.14],\n\te: [0.8, 0.7, 1.0, 1.2, 0.8],\n\tH: [0.0, 100.0, 200.0, 300.0, 400.0],\n};\n\nconst rad2deg = 180 / Math.PI;\nconst deg2rad = Math.PI / 180;\n\n/**\n * @param {Coords} coords\n * @param {number} fl\n * @returns {[number, number, number]}\n */\nexport function adapt (coords, fl) {\n\tconst temp = /** @type {[number, number, number]} */ (\n\t\tcoords.map(c => {\n\t\t\tconst x = spow(fl * Math.abs(c) * 0.01, adaptedCoef);\n\t\t\treturn (400 * copySign(x, c)) / (x + 27.13);\n\t\t})\n\t);\n\treturn temp;\n}\n\n/**\n * @param {Coords} adapted\n * @param {number} fl\n * @returns {[number, number, number]}\n */\nexport function unadapt (adapted, fl) {\n\tconst constant = (100 / fl) * 27.13 ** adaptedCoefInv;\n\treturn /** @type {[number, number, number]} */ (\n\t\tadapted.map(c => {\n\t\t\tconst cabs = Math.abs(c);\n\t\t\treturn copySign(constant * spow(cabs / (400 - cabs), adaptedCoefInv), c);\n\t\t})\n\t);\n}\n\n/**\n * @param {number} h\n */\nexport function hueQuadrature (h) {\n\tlet hp = constrain(h);\n\tif (hp <= hueQuadMap.h[0]) {\n\t\thp += 360;\n\t}\n\n\tconst i = bisectLeft(hueQuadMap.h, hp) - 1;\n\tconst [hi, hii] = hueQuadMap.h.slice(i, i + 2);\n\tconst [ei, eii] = hueQuadMap.e.slice(i, i + 2);\n\tconst Hi = hueQuadMap.H[i];\n\n\tconst t = (hp - hi) / ei;\n\treturn Hi + (100 * t) / (t + (hii - hp) / eii);\n}\n\n/**\n * @param {number} H\n */\nexport function invHueQuadrature (H) {\n\tlet Hp = ((H % 400) + 400) % 400;\n\tconst i = Math.floor(0.01 * Hp);\n\tHp = Hp % 100;\n\tconst [hi, hii] = hueQuadMap.h.slice(i, i + 2);\n\tconst [ei, eii] = hueQuadMap.e.slice(i, i + 2);\n\n\treturn constrain((Hp * (eii * hi - ei * hii) - 100 * hi * eii) / (Hp * (eii - ei) - 100 * eii));\n}\n\n/**\n * @param {[number, number, number]} refWhite\n * @param {number} adaptingLuminance\n * @param {number} backgroundLuminance\n * @param {keyof typeof surroundMap} surround\n * @param {boolean} discounting\n * @returns {Cam16Environment}\n */\nexport function environment (\n\trefWhite,\n\tadaptingLuminance,\n\tbackgroundLuminance,\n\tsurround,\n\tdiscounting,\n) {\n\tconst env = {};\n\n\tenv.discounting = discounting;\n\tenv.refWhite = refWhite;\n\tenv.surround = surround;\n\tconst xyzW = /** @type {Vector3} */ (\n\t\trefWhite.map(c => {\n\t\t\treturn c * 100;\n\t\t})\n\t);\n\n\t// The average luminance of the environment in `cd/m^2cd/m` (a.k.a. nits)\n\tenv.la = adaptingLuminance;\n\t// The relative luminance of the nearby background\n\tenv.yb = backgroundLuminance;\n\t// Absolute luminance of the reference white.\n\tconst yw = xyzW[1];\n\n\t// Cone response for reference white\n\tconst rgbW = multiply_v3_m3x3(xyzW, cat16);\n\n\t// Surround: dark, dim, and average\n\tlet values = surroundMap[env.surround];\n\tconst f = values[0];\n\tenv.c = values[1];\n\tenv.nc = values[2];\n\n\tconst k = 1 / (5 * env.la + 1);\n\tconst k4 = k ** 4;\n\n\t// Factor of luminance level adaptation\n\tenv.fl = k4 * env.la + 0.1 * (1 - k4) * (1 - k4) * Math.cbrt(5 * env.la);\n\tenv.flRoot = env.fl ** 0.25;\n\n\tenv.n = env.yb / yw;\n\tenv.z = 1.48 + Math.sqrt(env.n);\n\tenv.nbb = 0.725 * env.n ** -0.2;\n\tenv.ncb = env.nbb;\n\n\t// Degree of adaptation calculating if not discounting\n\t// illuminant (assumed eye is fully adapted)\n\tconst d = discounting\n\t\t? 1\n\t\t: Math.max(Math.min(f * (1 - (1 / 3.6) * Math.exp((-env.la - 42) / 92)), 1), 0);\n\tenv.dRgb = /** @type {[number, number, number]} */ (\n\t\trgbW.map(c => {\n\t\t\treturn interpolate(1, yw / c, d);\n\t\t})\n\t);\n\tenv.dRgbInv = /** @type {[number, number, number]} */ (\n\t\tenv.dRgb.map(c => {\n\t\t\treturn 1 / c;\n\t\t})\n\t);\n\n\t// Achromatic response\n\tconst rgbCW = /** @type {[number, number, number]} */ (\n\t\trgbW.map((c, i) => {\n\t\t\treturn c * env.dRgb[i];\n\t\t})\n\t);\n\tconst rgbAW = adapt(rgbCW, env.fl);\n\tenv.aW = env.nbb * (2 * rgbAW[0] + rgbAW[1] + 0.05 * rgbAW[2]);\n\n\t// console.log(env);\n\n\treturn env;\n}\n\n// Pre-calculate everything we can with the viewing conditions\nconst viewingConditions = environment(white, (64 / Math.PI) * 0.2, 20, \"average\", false);\n\n/**\n * @param {Cam16Input} cam16\n * @param {Cam16Environment} env\n * @returns {[number, number, number]}\n */\nexport function fromCam16 (cam16, env) {\n\t// These check ensure one, and only one attribute for a\n\t// given category is provided.\n\t// @ts-expect-error The '^` operator is not allowed for boolean types\n\tif (!((cam16.J !== undefined) ^ (cam16.Q !== undefined))) {\n\t\tthrow new Error(\"Conversion requires one and only one: 'J' or 'Q'\");\n\t}\n\n\t// @ts-expect-error - The '^` operator is not allowed for boolean types\n\tif (!((cam16.C !== undefined) ^ (cam16.M !== undefined) ^ (cam16.s !== undefined))) {\n\t\tthrow new Error(\"Conversion requires one and only one: 'C', 'M' or 's'\");\n\t}\n\n\t// Hue is absolutely required\n\t// @ts-expect-error - The '^` operator is not allowed for boolean types\n\tif (!((cam16.h !== undefined) ^ (cam16.H !== undefined))) {\n\t\tthrow new Error(\"Conversion requires one and only one: 'h' or 'H'\");\n\t}\n\n\t// Black\n\tif (cam16.J === 0.0 || cam16.Q === 0.0) {\n\t\treturn [0.0, 0.0, 0.0];\n\t}\n\n\t// Break hue into Cartesian components\n\tlet hRad = 0.0;\n\tif (cam16.h !== undefined) {\n\t\thRad = constrain(cam16.h) * deg2rad;\n\t}\n\telse {\n\t\thRad = invHueQuadrature(cam16.H) * deg2rad;\n\t}\n\n\tconst cosh = Math.cos(hRad);\n\tconst sinh = Math.sin(hRad);\n\n\t// Calculate `Jroot` from one of the lightness derived coordinates.\n\tlet Jroot = 0.0;\n\tif (cam16.J !== undefined) {\n\t\tJroot = spow(cam16.J, 1 / 2) * 0.1;\n\t}\n\telse if (cam16.Q !== undefined) {\n\t\tJroot = (0.25 * env.c * cam16.Q) / ((env.aW + 4) * env.flRoot);\n\t}\n\n\t// Calculate the `t` value from one of the chroma derived coordinates\n\tlet alpha = 0.0;\n\tif (cam16.C !== undefined) {\n\t\talpha = cam16.C / Jroot;\n\t}\n\telse if (cam16.M !== undefined) {\n\t\talpha = cam16.M / env.flRoot / Jroot;\n\t}\n\telse if (cam16.s !== undefined) {\n\t\talpha = (0.0004 * cam16.s ** 2 * (env.aW + 4)) / env.c;\n\t}\n\tconst t = spow(alpha * Math.pow(1.64 - Math.pow(0.29, env.n), -0.73), 10 / 9);\n\n\t// Eccentricity\n\tconst et = 0.25 * (Math.cos(hRad + 2) + 3.8);\n\n\t// Achromatic response\n\tconst A = env.aW * spow(Jroot, 2 / env.c / env.z);\n\n\t// Calculate red-green and yellow-blue components\n\tconst p1 = (5e4 / 13) * env.nc * env.ncb * et;\n\tconst p2 = A / env.nbb;\n\tconst r = 23 * (p2 + 0.305) * zdiv(t, 23 * p1 + t * (11 * cosh + 108 * sinh));\n\tconst a = r * cosh;\n\tconst b = r * sinh;\n\n\t// Calculate back from cone response to XYZ\n\tconst rgb_c = unadapt(\n\t\t/** @type {Vector3} */\n\t\t(\n\t\t\tmultiply_v3_m3x3([p2, a, b], m1).map(c => {\n\t\t\t\treturn (c * 1) / 1403;\n\t\t\t})\n\t\t),\n\t\tenv.fl,\n\t);\n\treturn /** @type {Vector3} */ (\n\t\tmultiply_v3_m3x3(\n\t\t\t/** @type {Vector3} */ (\n\t\t\t\trgb_c.map((c, i) => {\n\t\t\t\t\treturn c * env.dRgbInv[i];\n\t\t\t\t})\n\t\t\t),\n\t\t\tcat16Inv,\n\t\t).map(c => {\n\t\t\treturn c / 100;\n\t\t})\n\t);\n}\n\n/**\n * @param {[number, number, number]} xyzd65\n * @param {Cam16Environment} env\n * @returns {Cam16Object}\n */\nexport function toCam16 (xyzd65, env) {\n\t// Cone response\n\tconst xyz100 = /** @type {Vector3} */ (\n\t\txyzd65.map(c => {\n\t\t\treturn c * 100;\n\t\t})\n\t);\n\tconst rgbA = adapt(\n\t\t/** @type {[number, number, number]} */\n\t\t(\n\t\t\tmultiply_v3_m3x3(xyz100, cat16).map((c, i) => {\n\t\t\t\treturn c * env.dRgb[i];\n\t\t\t})\n\t\t),\n\t\tenv.fl,\n\t);\n\n\t// Calculate hue from red-green and yellow-blue components\n\tconst a = rgbA[0] + (-12 * rgbA[1] + rgbA[2]) / 11;\n\tconst b = (rgbA[0] + rgbA[1] - 2 * rgbA[2]) / 9;\n\tconst hRad = ((Math.atan2(b, a) % tau) + tau) % tau;\n\n\t// Eccentricity\n\tconst et = 0.25 * (Math.cos(hRad + 2) + 3.8);\n\n\tconst t =\n\t\t(5e4 / 13) *\n\t\tenv.nc *\n\t\tenv.ncb *\n\t\tzdiv(et * Math.sqrt(a ** 2 + b ** 2), rgbA[0] + rgbA[1] + 1.05 * rgbA[2] + 0.305);\n\tconst alpha = spow(t, 0.9) * Math.pow(1.64 - Math.pow(0.29, env.n), 0.73);\n\n\t// Achromatic response\n\tconst A = env.nbb * (2 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]);\n\n\tconst Jroot = spow(A / env.aW, 0.5 * env.c * env.z);\n\n\t// Lightness\n\tconst J = 100 * spow(Jroot, 2);\n\n\t// Brightness\n\tconst Q = (4 / env.c) * Jroot * (env.aW + 4) * env.flRoot;\n\n\t// Chroma\n\tconst C = alpha * Jroot;\n\n\t// Colorfulness\n\tconst M = C * env.flRoot;\n\n\t// Hue\n\tconst h = constrain(hRad * rad2deg);\n\n\t// Hue quadrature\n\tconst H = hueQuadrature(h);\n\n\t// Saturation\n\tconst s = 50 * spow((env.c * alpha) / (env.aW + 4), 1 / 2);\n\n\t// console.log({J: J, C: C, h: h, s: s, Q: Q, M: M, H: H});\n\n\treturn { J: J, C: C, h: h, s: s, Q: Q, M: M, H: H };\n}\n\n// Provided as a way to directly evaluate the CAM16 model\n// https://observablehq.com/@jrus/cam16: reference implementation\n// https://arxiv.org/pdf/1802.06067.pdf: Nico Schl\u00F6mer\n// https://onlinelibrary.wiley.com/doi/pdf/10.1002/col.22324: hue quadrature\n// https://www.researchgate.net/publication/318152296_Comprehensive_color_solutions_CAM16_CAT16_and_CAM16-UCS\n// Results compared against: https://github.com/colour-science/colour\nexport default new ColorSpace({\n\tid: \"cam16-jmh\",\n\tcssId: \"--cam16-jmh\",\n\tname: \"CAM16-JMh\",\n\tcoords: {\n\t\tj: {\n\t\t\trefRange: [0, 100],\n\t\t\tname: \"J\",\n\t\t},\n\t\tm: {\n\t\t\trefRange: [0, 105.0],\n\t\t\tname: \"Colorfulness\",\n\t\t},\n\t\th: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t},\n\n\tbase: xyz_d65,\n\n\tfromBase (xyz) {\n\t\t// If another derivation is created, \u03B5 could vary, so we can't hardcode\n\t\tif (this.\u03B5 === undefined) {\n\t\t\tthis.\u03B5 = Object.values(this.coords)[1].refRange[1] / 100000;\n\t\t}\n\t\tconst cam16 = toCam16(xyz, viewingConditions);\n\t\tconst isAchromatic = Math.abs(cam16.M) < this.\u03B5;\n\t\treturn [cam16.J, isAchromatic ? 0 : cam16.M, isAchromatic ? null : cam16.h];\n\t},\n\ttoBase (cam16) {\n\t\treturn fromCam16({ J: cam16[0], M: cam16[1], h: cam16[2] }, viewingConditions);\n\t},\n});\n", "import ColorSpace from \"../ColorSpace.js\";\nimport { constrain } from \"../angles.js\";\nimport xyz_d65 from \"./xyz-d65.js\";\nimport { fromCam16, toCam16, environment } from \"./cam16.js\";\nimport { WHITES } from \"../adapt.js\";\n\nconst white = WHITES.D65;\nconst \u03B5 = 216 / 24389; // 6^3/29^3 == (24/116)^3\nconst \u03BA = 24389 / 27; // 29^3/3^3\n\nfunction toLstar (y) {\n\t// Convert XYZ Y to L*\n\n\tconst fy = y > \u03B5 ? Math.cbrt(y) : (\u03BA * y + 16) / 116;\n\treturn 116.0 * fy - 16.0;\n}\n\nfunction fromLstar (lstar) {\n\t// Convert L* back to XYZ Y\n\n\treturn lstar > 8 ? Math.pow((lstar + 16) / 116, 3) : lstar / \u03BA;\n}\n\nfunction fromHct (coords, env) {\n\t// Use Newton's method to try and converge as quick as possible or\n\t// converge as close as we can. While the requested precision is achieved\n\t// most of the time, it may not always be achievable. Especially past the\n\t// visible spectrum, the algorithm will likely struggle to get the same\n\t// precision. If, for whatever reason, we cannot achieve the accuracy we\n\t// seek in the allotted iterations, just return the closest we were able to\n\t// get.\n\n\tlet [h, c, t] = coords;\n\tlet xyz = [];\n\tlet j = 0;\n\n\t// Shortcut out for black\n\tif (t === 0) {\n\t\treturn [0.0, 0.0, 0.0];\n\t}\n\n\t// Calculate the Y we need to target\n\tlet y = fromLstar(t);\n\n\t// A better initial guess yields better results. Polynomials come from\n\t// curve fitting the T vs J response.\n\tif (t > 0) {\n\t\tj = 0.00379058511492914 * t ** 2 + 0.608983189401032 * t + 0.9155088574762233;\n\t}\n\telse {\n\t\tj = 9.514440756550361e-6 * t ** 2 + 0.08693057439788597 * t - 21.928975842194614;\n\t}\n\n\t// Threshold of how close is close enough, and max number of attempts.\n\t// More precision and more attempts means more time spent iterating. Higher\n\t// required precision gives more accuracy but also increases the chance of\n\t// not hitting the goal. 2e-12 allows us to convert round trip with\n\t// reasonable accuracy of six decimal places or more.\n\tconst threshold = 2e-12;\n\tconst max_attempts = 15;\n\n\tlet attempt = 0;\n\tlet last = Infinity;\n\tlet best = j;\n\n\t// Try to find a J such that the returned y matches the returned y of the L*\n\twhile (attempt <= max_attempts) {\n\t\txyz = fromCam16({ J: j, C: c, h: h }, env);\n\n\t\t// If we are within range, return XYZ\n\t\t// If we are closer than last time, save the values\n\t\tconst delta = Math.abs(xyz[1] - y);\n\t\tif (delta < last) {\n\t\t\tif (delta <= threshold) {\n\t\t\t\treturn xyz;\n\t\t\t}\n\t\t\tbest = j;\n\t\t\tlast = delta;\n\t\t}\n\n\t\t// f(j_root) = (j ** (1 / 2)) * 0.1\n\t\t// f(j) = ((f(j_root) * 100) ** 2) / j - 1 = 0\n\t\t// f(j_root) = Y = y / 100\n\t\t// f(j) = (y ** 2) / j - 1\n\t\t// f'(j) = (2 * y) / j\n\t\tj = j - ((xyz[1] - y) * j) / (2 * xyz[1]);\n\n\t\tattempt += 1;\n\t}\n\n\t// We could not acquire the precision we desired,\n\t// return our closest attempt.\n\treturn fromCam16({ J: j, C: c, h: h }, env);\n}\n\nfunction toHct (xyz, env) {\n\t// Calculate HCT by taking the L* of CIE LCh D65 and CAM16 chroma and hue.\n\n\tconst t = toLstar(xyz[1]);\n\tif (t === 0.0) {\n\t\treturn [0.0, 0.0, 0.0];\n\t}\n\tconst cam16 = toCam16(xyz, viewingConditions);\n\treturn [constrain(cam16.h), cam16.C, t];\n}\n\n// Pre-calculate everything we can with the viewing conditions\nexport const viewingConditions = environment(\n\twhite,\n\t(200 / Math.PI) * fromLstar(50.0),\n\tfromLstar(50.0) * 100,\n\t\"average\",\n\tfalse,\n);\n\n// https://material.io/blog/science-of-color-design\n// This is not a port of the material-color-utilities,\n// but instead implements the full color space as described,\n// combining CAM16 JCh and Lab D65. This does not clamp conversion\n// to HCT to specific chroma bands and provides support for wider\n// gamuts than Google currently supports and does so at a greater\n// precision (> 8 bits back to sRGB).\n// This implementation comes from https://github.com/facelessuser/coloraide\n// which is licensed under MIT.\nexport default new ColorSpace({\n\tid: \"hct\",\n\tname: \"HCT\",\n\tcoords: {\n\t\th: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t\tc: {\n\t\t\trefRange: [0, 145],\n\t\t\tname: \"Colorfulness\",\n\t\t},\n\t\tt: {\n\t\t\trefRange: [0, 100],\n\t\t\tname: \"Tone\",\n\t\t},\n\t},\n\n\tbase: xyz_d65,\n\n\tfromBase (xyz) {\n\t\tif (this.\u03B5 === undefined) {\n\t\t\tthis.\u03B5 = Object.values(this.coords)[1].refRange[1] / 100000;\n\t\t}\n\t\tlet hct = toHct(xyz, viewingConditions);\n\t\tif (hct[1] < this.\u03B5) {\n\t\t\thct[1] = 0.0;\n\t\t\thct[0] = null;\n\t\t}\n\t\treturn hct;\n\t},\n\ttoBase (hct) {\n\t\treturn fromHct(hct, viewingConditions);\n\t},\n\tformats: {\n\t\tcolor: {\n\t\t\tid: \"--hct\",\n\t\t\tcoords: [\"<number> | <angle>\", \"<percentage> | <number>\", \"<percentage> | <number>\"],\n\t\t},\n\t},\n});\n", "import hct from \"../spaces/hct.js\";\nimport { viewingConditions } from \"../spaces/hct.js\";\nimport getColor from \"../getColor.js\";\n\n/** @import { Coords } from \"../types.js\" */\n\nconst rad2deg = 180 / Math.PI;\nconst deg2rad = Math.PI / 180;\nconst ucsCoeff = [1.0, 0.007, 0.0228];\n\n/**\n * Convert HCT chroma and hue (CAM16 JMh colorfulness and hue) using UCS logic for a and b.\n * @param {Coords} coords - HCT coordinates.\n * @return {number[]}\n */\nfunction convertUcsAb (coords) {\n\t// We want the distance between the actual color.\n\t// If chroma is negative, it will throw off our calculations.\n\t// Normally, converting back to the base and forward will correct it.\n\t// If we have a negative chroma after this, then we have a color that\n\t// cannot resolve to positive chroma.\n\tif (coords[1] < 0) {\n\t\tcoords = hct.fromBase(hct.toBase(coords));\n\t}\n\n\t// Only in extreme cases (usually outside the visible spectrum)\n\t// can the input value for log become negative.\n\t// Avoid domain error by forcing a zero result via \"max\" if necessary.\n\tconst M =\n\t\tMath.log(Math.max(1 + ucsCoeff[2] * coords[1] * viewingConditions.flRoot, 1.0)) /\n\t\tucsCoeff[2];\n\tconst hrad = coords[0] * deg2rad;\n\tconst a = M * Math.cos(hrad);\n\tconst b = M * Math.sin(hrad);\n\n\treturn [coords[2], a, b];\n}\n\n/**\n * Color distance using HCT.\n * @param {import(\"../types.js\").ColorTypes} color\n * @param {import(\"../types.js\").ColorTypes} sample\n * @returns {number}\n */\nexport default function (color, sample) {\n\t[color, sample] = getColor([color, sample]);\n\n\tlet [t1, a1, b1] = convertUcsAb(hct.from(color));\n\tlet [t2, a2, b2] = convertUcsAb(hct.from(sample));\n\n\t// Use simple euclidean distance with a and b using UCS conversion\n\t// and LCh lightness (HCT tone).\n\treturn Math.sqrt((t1 - t2) ** 2 + (a1 - a2) ** 2 + (b1 - b2) ** 2);\n}\n", "/**\n * @packageDocumentation\n * This module defines all the builtin deltaE methods.\n */\nimport deltaE76 from \"./deltaE76.js\";\nimport deltaECMC from \"./deltaECMC.js\";\nimport deltaE2000 from \"./deltaE2000.js\";\nimport deltaEJz from \"./deltaEJz.js\";\nimport deltaEITP from \"./deltaEITP.js\";\nimport deltaEOK from \"./deltaEOK.js\";\nimport deltaEOK2 from \"./deltaEOK2.js\";\nimport deltaEHCT from \"./deltaEHCT.js\";\n\nexport { deltaE76, deltaECMC, deltaE2000, deltaEJz, deltaEITP, deltaEOK, deltaEOK2, deltaEHCT };\n\nexport default {\n\tdeltaE76,\n\tdeltaECMC,\n\tdeltaE2000,\n\tdeltaEJz,\n\tdeltaEITP,\n\tdeltaEOK,\n\tdeltaEOK2,\n\tdeltaEHCT,\n};\n\n/** @typedef {keyof typeof import(\"./index.js\").default extends `deltaE${infer Method}` ? Method : string} Methods */\n", "import * as util from \"./util.js\";\nimport ColorSpace from \"./ColorSpace.js\";\nimport defaults from \"./defaults.js\";\nimport deltaE2000 from \"./deltaE/deltaE2000.js\";\nimport deltaEOK from \"./deltaE/deltaEOK.js\";\nimport inGamut from \"./inGamut.js\";\nimport to from \"./to.js\";\nimport get from \"./get.js\";\nimport oklab from \"./spaces/oklab.js\";\nimport set from \"./set.js\";\nimport clone from \"./clone.js\";\nimport getColor from \"./getColor.js\";\nimport deltaEMethods from \"./deltaE/index.js\";\nimport { WHITES } from \"./adapt.js\";\n\n/** @import { ColorTypes, PlainColorObject } from \"./types.js\" */\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").ToGamutOptions} ToGamutOptions */\n\n/**\n * Calculate the epsilon to 2 degrees smaller than the specified JND.\n * @param {number} jnd The target \"just noticeable difference\".\n * @returns {number}\n */\nfunction calcEpsilon (jnd) {\n\t// Calculate the epsilon to 2 degrees smaller than the specified JND.\n\n\tconst order = !jnd ? 0 : Math.floor(Math.log10(Math.abs(jnd)));\n\t// Limit to an arbitrary value to ensure value is never too small and causes infinite loops.\n\treturn Math.max(parseFloat(`1e${order - 2}`), 1e-6);\n}\n\nconst GMAPPRESET = {\n\thct: {\n\t\tmethod: \"hct.c\",\n\t\tjnd: 2,\n\t\tdeltaEMethod: \"hct\",\n\t\tblackWhiteClamp: {},\n\t},\n\t\"hct-tonal\": {\n\t\tmethod: \"hct.c\",\n\t\tjnd: 0,\n\t\tdeltaEMethod: \"hct\",\n\t\tblackWhiteClamp: { channel: \"hct.t\", min: 0, max: 100 },\n\t},\n};\n\n/**\n * Force coordinates to be in gamut of a certain color space.\n * Mutates the color it is passed.\n * @overload\n * @param {ColorTypes} color\n * @param {ToGamutOptions} [options]\n * @returns {PlainColorObject}\n */\n/**\n * @overload\n * @param {ColorTypes} color\n * @param {string} [space]\n * @returns {PlainColorObject}\n */\n/**\n * @param {ColorTypes} color\n * @param {string & Partial<ToGamutOptions> | ToGamutOptions} [space]\n * @returns {PlainColorObject}\n */\nexport default function toGamut (\n\tcolor,\n\t{\n\t\tmethod = defaults.gamut_mapping,\n\t\tspace = undefined,\n\t\tdeltaEMethod = \"\",\n\t\tjnd = 2,\n\t\tblackWhiteClamp = undefined,\n\t} = {},\n) {\n\tcolor = getColor(color);\n\n\tif (util.isString(arguments[1])) {\n\t\tspace = arguments[1];\n\t}\n\telse if (!space) {\n\t\tspace = color.space;\n\t}\n\n\tspace = ColorSpace.get(space);\n\n\t// 3 spaces:\n\t// color.space: current color space\n\t// space: space whose gamut we are mapping to\n\t// mapSpace: space with the coord we're reducing\n\n\tif (inGamut(color, space, { epsilon: 0 })) {\n\t\treturn /** @type {PlainColorObject} */ (color);\n\t}\n\n\tlet spaceColor;\n\tif (method === \"css\") {\n\t\tspaceColor = toGamutCSS(color, { space });\n\t}\n\telse {\n\t\tif (method !== \"clip\" && !inGamut(color, space)) {\n\t\t\tif (Object.prototype.hasOwnProperty.call(GMAPPRESET, method)) {\n\t\t\t\t({ method, jnd, deltaEMethod, blackWhiteClamp } = GMAPPRESET[method]);\n\t\t\t}\n\n\t\t\t// Get the correct delta E method\n\t\t\tlet de = deltaE2000;\n\t\t\tif (deltaEMethod !== \"\") {\n\t\t\t\tfor (let m in deltaEMethods) {\n\t\t\t\t\tif (\"deltae\" + deltaEMethod.toLowerCase() === m.toLowerCase()) {\n\t\t\t\t\t\tde = deltaEMethods[m];\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (jnd === 0) {\n\t\t\t\tjnd = 1e-16;\n\t\t\t}\n\n\t\t\tlet clipped = toGamut(to(color, space), { method: \"clip\", space });\n\t\t\tif (de(color, clipped) > jnd) {\n\t\t\t\t// Clamp to SDR white and black if required\n\t\t\t\tif (blackWhiteClamp && Object.keys(blackWhiteClamp).length === 3) {\n\t\t\t\t\tlet channelMeta = ColorSpace.resolveCoord(blackWhiteClamp.channel);\n\t\t\t\t\tlet channel = get(to(color, channelMeta.space), channelMeta.id);\n\t\t\t\t\tif (util.isNone(channel)) {\n\t\t\t\t\t\tchannel = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (channel >= blackWhiteClamp.max) {\n\t\t\t\t\t\treturn to({ space: \"xyz-d65\", coords: WHITES[\"D65\"] }, color.space);\n\t\t\t\t\t}\n\t\t\t\t\telse if (channel <= blackWhiteClamp.min) {\n\t\t\t\t\t\treturn to({ space: \"xyz-d65\", coords: [0, 0, 0] }, color.space);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Reduce a coordinate of a certain color space until the color is in gamut\n\t\t\t\tlet coordMeta = ColorSpace.resolveCoord(method);\n\t\t\t\tlet mapSpace = coordMeta.space;\n\t\t\t\tlet coordId = coordMeta.id;\n\n\t\t\t\tlet mappedColor = to(color, mapSpace);\n\t\t\t\t// If we were already in the mapped color space, we need to resolve undefined channels\n\t\t\t\tmappedColor.coords.forEach((c, i) => {\n\t\t\t\t\tif (util.isNone(c)) {\n\t\t\t\t\t\tmappedColor.coords[i] = 0;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tlet bounds = coordMeta.range || coordMeta.refRange;\n\t\t\t\tlet min = bounds[0];\n\t\t\t\tlet \u03B5 = calcEpsilon(jnd);\n\t\t\t\tlet low = min;\n\t\t\t\tlet high = get(mappedColor, coordId);\n\n\t\t\t\twhile (high - low > \u03B5) {\n\t\t\t\t\tlet clipped = clone(mappedColor);\n\t\t\t\t\tclipped = toGamut(clipped, { space, method: \"clip\" });\n\t\t\t\t\tlet deltaE = de(mappedColor, clipped);\n\n\t\t\t\t\tif (deltaE - jnd < \u03B5) {\n\t\t\t\t\t\tlow = get(mappedColor, coordId);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\thigh = get(mappedColor, coordId);\n\t\t\t\t\t}\n\n\t\t\t\t\tset(mappedColor, coordId, (low + high) / 2);\n\t\t\t\t}\n\n\t\t\t\tspaceColor = to(mappedColor, space);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tspaceColor = clipped;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tspaceColor = to(color, space);\n\t\t}\n\n\t\tif (\n\t\t\tmethod === \"clip\" || // Dumb coord clipping\n\t\t\t// finish off smarter gamut mapping with clip to get rid of \u03B5, see #17\n\t\t\t!inGamut(spaceColor, space, { epsilon: 0 })\n\t\t) {\n\t\t\tlet bounds = Object.values(space.coords).map(c => c.range || []);\n\n\t\t\tspaceColor.coords = /** @type {[number, number, number]} */ (\n\t\t\t\tspaceColor.coords.map((c, i) => {\n\t\t\t\t\tlet [min, max] = bounds[i];\n\n\t\t\t\t\tif (min !== undefined) {\n\t\t\t\t\t\tc = Math.max(min, c);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (max !== undefined) {\n\t\t\t\t\t\tc = Math.min(c, max);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn c;\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\t}\n\n\tif (space !== color.space) {\n\t\tspaceColor = to(spaceColor, color.space);\n\t}\n\n\tcolor.coords = spaceColor.coords;\n\treturn /** @type {PlainColorObject} */ (color);\n}\n\n/** @type {\"color\"} */\ntoGamut.returns = \"color\";\n\n/**\n * The reference colors to be used if lightness is out of the range 0-1 in the\n * `Oklch` space. These are created in the `Oklab` space, as it is used by the\n * DeltaEOK calculation, so it is guaranteed to be imported.\n * @satisfies {Record<string, ColorTypes>}\n */\nconst COLORS = {\n\tWHITE: { space: oklab, coords: [1, 0, 0], alpha: 1 },\n\tBLACK: { space: oklab, coords: [0, 0, 0], alpha: 1 },\n};\n\n/**\n * Given a color `origin`, returns a new color that is in gamut using\n * the CSS Gamut Mapping Algorithm. If `space` is specified, it will be in gamut\n * in `space`, and returned in `space`. Otherwise, it will be in gamut and\n * returned in the color space of `origin`.\n * @param {ColorTypes} origin\n * @param {{ space?: string | ColorSpace | undefined }} param1\n * @returns {PlainColorObject}\n */\nexport function toGamutCSS (origin, { space } = {}) {\n\tconst JND = 0.02;\n\tconst \u03B5 = 0.0001;\n\n\torigin = getColor(origin);\n\n\tif (!space) {\n\t\tspace = origin.space;\n\t}\n\n\tspace = ColorSpace.get(space);\n\tconst oklchSpace = ColorSpace.get(\"oklch\");\n\n\tif (space.isUnbounded) {\n\t\treturn to(origin, space);\n\t}\n\n\tconst origin_OKLCH = to(origin, oklchSpace);\n\tlet L = origin_OKLCH.coords[0];\n\n\t// return media white or black, if lightness is out of range\n\tif (L >= 1) {\n\t\tconst white = to(COLORS.WHITE, space);\n\t\twhite.alpha = origin.alpha;\n\t\treturn to(white, space);\n\t}\n\tif (L <= 0) {\n\t\tconst black = to(COLORS.BLACK, space);\n\t\tblack.alpha = origin.alpha;\n\t\treturn to(black, space);\n\t}\n\n\tif (inGamut(origin_OKLCH, space, { epsilon: 0 })) {\n\t\treturn to(origin_OKLCH, space);\n\t}\n\n\tfunction clip (_color) {\n\t\tconst destColor = to(_color, space);\n\t\tconst spaceCoords = Object.values(/** @type {ColorSpace} */ (space).coords);\n\t\tdestColor.coords = /** @type {[number, number, number]} */ (\n\t\t\tdestColor.coords.map((coord, index) => {\n\t\t\t\tif (\"range\" in spaceCoords[index]) {\n\t\t\t\t\tconst [min, max] = spaceCoords[index].range;\n\t\t\t\t\treturn util.clamp(min, coord, max);\n\t\t\t\t}\n\t\t\t\treturn coord;\n\t\t\t})\n\t\t);\n\t\treturn destColor;\n\t}\n\tlet min = 0;\n\tlet max = origin_OKLCH.coords[1];\n\tlet min_inGamut = true;\n\tlet current = clone(origin_OKLCH);\n\tlet clipped = clip(current);\n\n\tlet E = deltaEOK(clipped, current);\n\tif (E < JND) {\n\t\treturn clipped;\n\t}\n\n\twhile (max - min > \u03B5) {\n\t\tconst chroma = (min + max) / 2;\n\t\tcurrent.coords[1] = chroma;\n\t\tif (min_inGamut && inGamut(current, space, { epsilon: 0 })) {\n\t\t\tmin = chroma;\n\t\t}\n\t\telse {\n\t\t\tclipped = clip(current);\n\t\t\tE = deltaEOK(clipped, current);\n\t\t\tif (E < JND) {\n\t\t\t\tif (JND - E < \u03B5) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tmin_inGamut = false;\n\t\t\t\t\tmin = chroma;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tmax = chroma;\n\t\t\t}\n\t\t}\n\t}\n\treturn clipped;\n}\n", "import getColor from \"./getColor.js\";\nimport ColorSpace from \"./ColorSpace.js\";\nimport toGamut from \"./toGamut.js\";\n\n/** @import { ColorTypes, PlainColorObject, ToGamutOptions } from \"./types.js\" */\n\n/**\n * Convert to color space and return a new color\n * @param {ColorTypes} color\n * @param {string | ColorSpace} space\n * @param {{ inGamut?: boolean | ToGamutOptions | undefined }} options\n * @returns {PlainColorObject}\n */\nexport default function to (color, space, { inGamut } = {}) {\n\tcolor = getColor(color);\n\tspace = ColorSpace.get(space);\n\n\tlet coords = space.from(color);\n\tlet ret = { space, coords, alpha: color.alpha };\n\n\tif (inGamut) {\n\t\tret = toGamut(ret, inGamut === true ? undefined : inGamut);\n\t}\n\n\treturn ret;\n}\n\n/** @type {\"color\"} */\nto.returns = \"color\";\n", "// @ts-nocheck\n\nimport * as util from \"./util.js\";\nimport ColorSpace from \"./ColorSpace.js\";\nimport defaults from \"./defaults.js\";\nimport getColor from \"./getColor.js\";\nimport to from \"./to.js\";\nimport checkInGamut from \"./inGamut.js\";\nimport toGamut from \"./toGamut.js\";\nimport clone from \"./clone.js\";\n\n/** @import { ColorTypes, ParseOptions, PlainColorObject } from \"./types.js\" */\n\n// Type re-exports\n/** @typedef {import(\"./types.js\").SerializeOptions} SerializeOptions */\n\n/**\n * Generic toString() method, outputs a color(spaceId ...coords) function, a functional syntax, or custom formats defined by the color space\n * @param {ColorTypes} color\n * @param {SerializeOptions & Record<string, any>} options\n * @returns {string}\n */\nexport default function serialize (color, options = {}) {\n\tlet {\n\t\tprecision = defaults.precision,\n\t\tformat,\n\t\tinGamut = true,\n\t\tcoords: coordFormat,\n\t\talpha: alphaFormat,\n\t\tcommas,\n\t} = options;\n\tlet ret;\n\n\tlet colorWithMeta = /** @type {PlainColorObject & ParseOptions} */ (getColor(color));\n\n\tlet formatId = format;\n\tlet parseMeta = colorWithMeta.parseMeta;\n\n\tif (parseMeta && !format) {\n\t\tif (parseMeta.format.canSerialize()) {\n\t\t\tformat = parseMeta.format;\n\t\t\tformatId = parseMeta.formatId;\n\t\t}\n\n\t\tcoordFormat ??= parseMeta.types;\n\t\talphaFormat ??= parseMeta.alphaType;\n\t\tcommas ??= parseMeta.commas;\n\t}\n\n\tif (formatId) {\n\t\t// A format is explicitly specified\n\t\tformat = colorWithMeta.space.getFormat(format) ?? ColorSpace.findFormat(formatId);\n\t}\n\n\tif (!format) {\n\t\t// No format specified, or format not found\n\t\tformat = colorWithMeta.space.getFormat(\"default\") ?? ColorSpace.DEFAULT_FORMAT;\n\t\tformatId = format.name;\n\t}\n\n\tif (format && format.space && format.space !== colorWithMeta.space) {\n\t\t// Format specified belongs to a different color space,\n\t\t// need to convert to it first\n\t\tcolorWithMeta = to(colorWithMeta, format.space);\n\t}\n\n\t// The assignment to coords and inGamut needs to stay in the order they are now\n\t// The order of the assignment was changed as a workaround for a bug in Next.js\n\t// See this issue for details: https://github.com/color-js/color.js/issues/260\n\n\tlet coords = colorWithMeta.coords.slice(); // clone so we can manipulate it\n\n\tinGamut ||= format.toGamut;\n\n\tif (inGamut && !checkInGamut(colorWithMeta)) {\n\t\t// FIXME what happens if the color contains none values?\n\t\tcoords = toGamut(clone(colorWithMeta), inGamut === true ? undefined : inGamut).coords;\n\t}\n\n\tif (format.type === \"custom\") {\n\t\tif (format.serialize) {\n\t\t\tret = format.serialize(coords, colorWithMeta.alpha, options);\n\t\t}\n\t\telse {\n\t\t\tthrow new TypeError(\n\t\t\t\t`format ${formatId} can only be used to parse colors, not for serialization`,\n\t\t\t);\n\t\t}\n\t}\n\telse {\n\t\t// Functional syntax\n\t\tlet name = format.name || \"color\";\n\n\t\tlet args = format.serializeCoords(coords, precision, coordFormat);\n\n\t\tif (name === \"color\") {\n\t\t\t// If output is a color() function, add colorspace id as first argument\n\t\t\tlet cssId =\n\t\t\t\tformat.id || format.ids?.[0] || colorWithMeta.space.cssId || colorWithMeta.space.id;\n\t\t\targs.unshift(cssId);\n\t\t}\n\n\t\t// Serialize alpha?\n\t\t/** @type {string | number} */\n\t\tlet alpha = colorWithMeta.alpha;\n\n\t\tif (alphaFormat !== undefined && !(typeof alphaFormat === \"object\")) {\n\t\t\talphaFormat =\n\t\t\t\ttypeof alphaFormat === \"string\" ? { type: alphaFormat } : { include: alphaFormat };\n\t\t}\n\n\t\tlet alphaType = alphaFormat?.type ?? \"<number>\";\n\t\tlet serializeAlpha =\n\t\t\talphaFormat?.include === true ||\n\t\t\tformat.alpha === true ||\n\t\t\t(alphaFormat?.include !== false && format.alpha !== false && alpha < 1);\n\t\tlet strAlpha = \"\";\n\n\t\tcommas ??= format.commas;\n\n\t\tif (serializeAlpha) {\n\t\t\tif (precision !== null) {\n\t\t\t\tlet unit;\n\n\t\t\t\tif (alphaType === \"<percentage>\") {\n\t\t\t\t\tunit = \"%\";\n\t\t\t\t\talpha *= 100;\n\t\t\t\t}\n\n\t\t\t\talpha = util.serializeNumber(alpha, { precision, unit });\n\t\t\t}\n\n\t\t\tstrAlpha = `${commas ? \",\" : \" /\"} ${alpha}`;\n\t\t}\n\n\t\tret = `${name}(${args.join(commas ? \", \" : \" \")}${strAlpha})`;\n\t}\n\n\treturn ret;\n}\n", "import RGBColorSpace from \"../RGBColorSpace.js\";\n\n/** @import { Matrix3x3 } from \"../types.js\" */\n\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst toXYZ_M = [\n\t[0.4865709486482162, 0.26566769316909306, 0.1982172852343625],\n\t[0.2289745640697488, 0.6917385218365064,  0.079286914093745],\n\t[0.0000000000000000, 0.04511338185890264, 1.043944368900976],\n];\n\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst fromXYZ_M = [\n\t[ 2.493496911941425,   -0.9313836179191239, -0.40271078445071684],\n\t[-0.8294889695615747,   1.7626640603183463,  0.023624685841943577],\n\t[ 0.03584583024378447, -0.07617238926804182, 0.9568845240076872],\n];\n\nexport default new RGBColorSpace({\n\tid: \"p3-linear\",\n\tcssId: \"display-p3-linear\",\n\tname: \"Linear P3\",\n\twhite: \"D65\",\n\ttoXYZ_M,\n\tfromXYZ_M,\n});\n", "import RGBColorSpace from \"../RGBColorSpace.js\";\n\n/** @import { Matrix3x3 } from \"../types.js\" */\n\n// This is the linear-light version of sRGB\n// as used for example in SVG filters\n// or in Canvas\n\n// This matrix was calculated directly from the RGB and white chromaticities\n// when rounded to 8 decimal places, it agrees completely with the official matrix\n// see https://github.com/w3c/csswg-drafts/issues/5922\n/** @type {Matrix3x3} */\n// prettier-ignore\nconst toXYZ_M = [\n\t[ 0.41239079926595934, 0.357584339383878,   0.1804807884018343  ],\n\t[ 0.21263900587151027, 0.715168678767756,   0.07219231536073371 ],\n\t[ 0.01933081871559182, 0.11919477979462598, 0.9505321522496607  ],\n];\n\n// This matrix is the inverse of the above;\n// again it agrees with the official definition when rounded to 8 decimal places\n/** @type {Matrix3x3} */\n// prettier-ignore\nexport const fromXYZ_M = [\n\t[  3.2409699419045226,  -1.537383177570094,   -0.4986107602930034  ],\n\t[ -0.9692436362808796,   1.8759675015077202,   0.04155505740717559 ],\n\t[  0.05563007969699366, -0.20397695888897652,  1.0569715142428786  ],\n];\n\nexport default new RGBColorSpace({\n\tid: \"srgb-linear\",\n\tname: \"Linear sRGB\",\n\twhite: \"D65\",\n\ttoXYZ_M,\n\tfromXYZ_M,\n});\n", "// To produce: Visit https://www.w3.org/TR/css-color-4/#named-colors\n// and run in the console:\n// copy($$(\"tr\", $(\".named-color-table tbody\")).map(tr => `\"${tr.cells[2].textContent.trim()}\": [${tr.cells[4].textContent.trim().split(/\\s+/).map(c => c === \"0\"? \"0\" : c === \"255\"? \"1\" : c + \" / 255\").join(\", \")}]`).join(\",\\n\"))\n\n/** List of CSS color keywords\n *  Note that this does not include currentColor, transparent,\n *  or system colors\n *\n *  @type {Record<string, [number, number, number]>}\n */\nexport default {\n\taliceblue: [240 / 255, 248 / 255, 1],\n\tantiquewhite: [250 / 255, 235 / 255, 215 / 255],\n\taqua: [0, 1, 1],\n\taquamarine: [127 / 255, 1, 212 / 255],\n\tazure: [240 / 255, 1, 1],\n\tbeige: [245 / 255, 245 / 255, 220 / 255],\n\tbisque: [1, 228 / 255, 196 / 255],\n\tblack: [0, 0, 0],\n\tblanchedalmond: [1, 235 / 255, 205 / 255],\n\tblue: [0, 0, 1],\n\tblueviolet: [138 / 255, 43 / 255, 226 / 255],\n\tbrown: [165 / 255, 42 / 255, 42 / 255],\n\tburlywood: [222 / 255, 184 / 255, 135 / 255],\n\tcadetblue: [95 / 255, 158 / 255, 160 / 255],\n\tchartreuse: [127 / 255, 1, 0],\n\tchocolate: [210 / 255, 105 / 255, 30 / 255],\n\tcoral: [1, 127 / 255, 80 / 255],\n\tcornflowerblue: [100 / 255, 149 / 255, 237 / 255],\n\tcornsilk: [1, 248 / 255, 220 / 255],\n\tcrimson: [220 / 255, 20 / 255, 60 / 255],\n\tcyan: [0, 1, 1],\n\tdarkblue: [0, 0, 139 / 255],\n\tdarkcyan: [0, 139 / 255, 139 / 255],\n\tdarkgoldenrod: [184 / 255, 134 / 255, 11 / 255],\n\tdarkgray: [169 / 255, 169 / 255, 169 / 255],\n\tdarkgreen: [0, 100 / 255, 0],\n\tdarkgrey: [169 / 255, 169 / 255, 169 / 255],\n\tdarkkhaki: [189 / 255, 183 / 255, 107 / 255],\n\tdarkmagenta: [139 / 255, 0, 139 / 255],\n\tdarkolivegreen: [85 / 255, 107 / 255, 47 / 255],\n\tdarkorange: [1, 140 / 255, 0],\n\tdarkorchid: [153 / 255, 50 / 255, 204 / 255],\n\tdarkred: [139 / 255, 0, 0],\n\tdarksalmon: [233 / 255, 150 / 255, 122 / 255],\n\tdarkseagreen: [143 / 255, 188 / 255, 143 / 255],\n\tdarkslateblue: [72 / 255, 61 / 255, 139 / 255],\n\tdarkslategray: [47 / 255, 79 / 255, 79 / 255],\n\tdarkslategrey: [47 / 255, 79 / 255, 79 / 255],\n\tdarkturquoise: [0, 206 / 255, 209 / 255],\n\tdarkviolet: [148 / 255, 0, 211 / 255],\n\tdeeppink: [1, 20 / 255, 147 / 255],\n\tdeepskyblue: [0, 191 / 255, 1],\n\tdimgray: [105 / 255, 105 / 255, 105 / 255],\n\tdimgrey: [105 / 255, 105 / 255, 105 / 255],\n\tdodgerblue: [30 / 255, 144 / 255, 1],\n\tfirebrick: [178 / 255, 34 / 255, 34 / 255],\n\tfloralwhite: [1, 250 / 255, 240 / 255],\n\tforestgreen: [34 / 255, 139 / 255, 34 / 255],\n\tfuchsia: [1, 0, 1],\n\tgainsboro: [220 / 255, 220 / 255, 220 / 255],\n\tghostwhite: [248 / 255, 248 / 255, 1],\n\tgold: [1, 215 / 255, 0],\n\tgoldenrod: [218 / 255, 165 / 255, 32 / 255],\n\tgray: [128 / 255, 128 / 255, 128 / 255],\n\tgreen: [0, 128 / 255, 0],\n\tgreenyellow: [173 / 255, 1, 47 / 255],\n\tgrey: [128 / 255, 128 / 255, 128 / 255],\n\thoneydew: [240 / 255, 1, 240 / 255],\n\thotpink: [1, 105 / 255, 180 / 255],\n\tindianred: [205 / 255, 92 / 255, 92 / 255],\n\tindigo: [75 / 255, 0, 130 / 255],\n\tivory: [1, 1, 240 / 255],\n\tkhaki: [240 / 255, 230 / 255, 140 / 255],\n\tlavender: [230 / 255, 230 / 255, 250 / 255],\n\tlavenderblush: [1, 240 / 255, 245 / 255],\n\tlawngreen: [124 / 255, 252 / 255, 0],\n\tlemonchiffon: [1, 250 / 255, 205 / 255],\n\tlightblue: [173 / 255, 216 / 255, 230 / 255],\n\tlightcoral: [240 / 255, 128 / 255, 128 / 255],\n\tlightcyan: [224 / 255, 1, 1],\n\tlightgoldenrodyellow: [250 / 255, 250 / 255, 210 / 255],\n\tlightgray: [211 / 255, 211 / 255, 211 / 255],\n\tlightgreen: [144 / 255, 238 / 255, 144 / 255],\n\tlightgrey: [211 / 255, 211 / 255, 211 / 255],\n\tlightpink: [1, 182 / 255, 193 / 255],\n\tlightsalmon: [1, 160 / 255, 122 / 255],\n\tlightseagreen: [32 / 255, 178 / 255, 170 / 255],\n\tlightskyblue: [135 / 255, 206 / 255, 250 / 255],\n\tlightslategray: [119 / 255, 136 / 255, 153 / 255],\n\tlightslategrey: [119 / 255, 136 / 255, 153 / 255],\n\tlightsteelblue: [176 / 255, 196 / 255, 222 / 255],\n\tlightyellow: [1, 1, 224 / 255],\n\tlime: [0, 1, 0],\n\tlimegreen: [50 / 255, 205 / 255, 50 / 255],\n\tlinen: [250 / 255, 240 / 255, 230 / 255],\n\tmagenta: [1, 0, 1],\n\tmaroon: [128 / 255, 0, 0],\n\tmediumaquamarine: [102 / 255, 205 / 255, 170 / 255],\n\tmediumblue: [0, 0, 205 / 255],\n\tmediumorchid: [186 / 255, 85 / 255, 211 / 255],\n\tmediumpurple: [147 / 255, 112 / 255, 219 / 255],\n\tmediumseagreen: [60 / 255, 179 / 255, 113 / 255],\n\tmediumslateblue: [123 / 255, 104 / 255, 238 / 255],\n\tmediumspringgreen: [0, 250 / 255, 154 / 255],\n\tmediumturquoise: [72 / 255, 209 / 255, 204 / 255],\n\tmediumvioletred: [199 / 255, 21 / 255, 133 / 255],\n\tmidnightblue: [25 / 255, 25 / 255, 112 / 255],\n\tmintcream: [245 / 255, 1, 250 / 255],\n\tmistyrose: [1, 228 / 255, 225 / 255],\n\tmoccasin: [1, 228 / 255, 181 / 255],\n\tnavajowhite: [1, 222 / 255, 173 / 255],\n\tnavy: [0, 0, 128 / 255],\n\toldlace: [253 / 255, 245 / 255, 230 / 255],\n\tolive: [128 / 255, 128 / 255, 0],\n\tolivedrab: [107 / 255, 142 / 255, 35 / 255],\n\torange: [1, 165 / 255, 0],\n\torangered: [1, 69 / 255, 0],\n\torchid: [218 / 255, 112 / 255, 214 / 255],\n\tpalegoldenrod: [238 / 255, 232 / 255, 170 / 255],\n\tpalegreen: [152 / 255, 251 / 255, 152 / 255],\n\tpaleturquoise: [175 / 255, 238 / 255, 238 / 255],\n\tpalevioletred: [219 / 255, 112 / 255, 147 / 255],\n\tpapayawhip: [1, 239 / 255, 213 / 255],\n\tpeachpuff: [1, 218 / 255, 185 / 255],\n\tperu: [205 / 255, 133 / 255, 63 / 255],\n\tpink: [1, 192 / 255, 203 / 255],\n\tplum: [221 / 255, 160 / 255, 221 / 255],\n\tpowderblue: [176 / 255, 224 / 255, 230 / 255],\n\tpurple: [128 / 255, 0, 128 / 255],\n\trebeccapurple: [102 / 255, 51 / 255, 153 / 255],\n\tred: [1, 0, 0],\n\trosybrown: [188 / 255, 143 / 255, 143 / 255],\n\troyalblue: [65 / 255, 105 / 255, 225 / 255],\n\tsaddlebrown: [139 / 255, 69 / 255, 19 / 255],\n\tsalmon: [250 / 255, 128 / 255, 114 / 255],\n\tsandybrown: [244 / 255, 164 / 255, 96 / 255],\n\tseagreen: [46 / 255, 139 / 255, 87 / 255],\n\tseashell: [1, 245 / 255, 238 / 255],\n\tsienna: [160 / 255, 82 / 255, 45 / 255],\n\tsilver: [192 / 255, 192 / 255, 192 / 255],\n\tskyblue: [135 / 255, 206 / 255, 235 / 255],\n\tslateblue: [106 / 255, 90 / 255, 205 / 255],\n\tslategray: [112 / 255, 128 / 255, 144 / 255],\n\tslategrey: [112 / 255, 128 / 255, 144 / 255],\n\tsnow: [1, 250 / 255, 250 / 255],\n\tspringgreen: [0, 1, 127 / 255],\n\tsteelblue: [70 / 255, 130 / 255, 180 / 255],\n\ttan: [210 / 255, 180 / 255, 140 / 255],\n\tteal: [0, 128 / 255, 128 / 255],\n\tthistle: [216 / 255, 191 / 255, 216 / 255],\n\ttomato: [1, 99 / 255, 71 / 255],\n\tturquoise: [64 / 255, 224 / 255, 208 / 255],\n\tviolet: [238 / 255, 130 / 255, 238 / 255],\n\twheat: [245 / 255, 222 / 255, 179 / 255],\n\twhite: [1, 1, 1],\n\twhitesmoke: [245 / 255, 245 / 255, 245 / 255],\n\tyellow: [1, 1, 0],\n\tyellowgreen: [154 / 255, 205 / 255, 50 / 255],\n};\n", "import RGBColorSpace from \"../RGBColorSpace.js\";\nimport sRGBLinear from \"./srgb-linear.js\";\nimport KEYWORDS from \"../keywords.js\";\n\n/** @import { Coords } from \"../types.js\" */\n\nlet coordGrammar = Array(3).fill(\"<percentage> | <number>[0, 255]\");\nlet coordGrammarNumber = Array(3).fill(\"<number>[0, 255]\");\n\nexport default new RGBColorSpace({\n\tid: \"srgb\",\n\tname: \"sRGB\",\n\tbase: sRGBLinear,\n\tfromBase: rgb => {\n\t\t// convert an array of linear-light sRGB values in the range 0.0-1.0\n\t\t// to gamma corrected form\n\t\t// https://en.wikipedia.org/wiki/SRGB\n\t\treturn rgb.map(val => {\n\t\t\tlet sign = val < 0 ? -1 : 1;\n\t\t\tlet abs = val * sign;\n\n\t\t\tif (abs > 0.0031308) {\n\t\t\t\treturn sign * (1.055 * abs ** (1 / 2.4) - 0.055);\n\t\t\t}\n\n\t\t\treturn 12.92 * val;\n\t\t});\n\t},\n\ttoBase: rgb => {\n\t\t// convert an array of sRGB values in the range 0.0 - 1.0\n\t\t// to linear light (un-companded) form.\n\t\t// https://en.wikipedia.org/wiki/SRGB\n\t\treturn rgb.map(val => {\n\t\t\tlet sign = val < 0 ? -1 : 1;\n\t\t\tlet abs = val * sign;\n\n\t\t\tif (abs <= 0.04045) {\n\t\t\t\treturn val / 12.92;\n\t\t\t}\n\n\t\t\treturn sign * ((abs + 0.055) / 1.055) ** 2.4;\n\t\t});\n\t},\n\tformats: {\n\t\trgb: {\n\t\t\tcoords: coordGrammar,\n\t\t},\n\t\trgb_number: {\n\t\t\tname: \"rgb\",\n\t\t\tcommas: true,\n\t\t\tcoords: coordGrammarNumber,\n\t\t\talpha: false,\n\t\t},\n\t\tcolor: {\n\t\t\t/* use defaults */\n\t\t},\n\t\trgba: {\n\t\t\tcoords: coordGrammar,\n\t\t\tcommas: true,\n\t\t\talpha: true,\n\t\t},\n\t\trgba_number: {\n\t\t\tname: \"rgba\",\n\t\t\tcommas: true,\n\t\t\tcoords: coordGrammarNumber,\n\t\t},\n\t\thex: {\n\t\t\ttype: \"custom\",\n\t\t\ttoGamut: true,\n\t\t\ttest: str => /^#(([a-f0-9]{2}){3,4}|[a-f0-9]{3,4})$/i.test(str),\n\t\t\tparse (str) {\n\t\t\t\tif (str.length <= 5) {\n\t\t\t\t\t// #rgb or #rgba, duplicate digits\n\t\t\t\t\tstr = str.replace(/[a-f0-9]/gi, \"$&$&\");\n\t\t\t\t}\n\n\t\t\t\t/** @type {number[]} */\n\t\t\t\tlet rgba = [];\n\t\t\t\t// @ts-expect-error Type 'void' is not assignable to type 'string'\n\t\t\t\tstr.replace(/[a-f0-9]{2}/gi, component => {\n\t\t\t\t\trgba.push(parseInt(component, 16) / 255);\n\t\t\t\t});\n\n\t\t\t\treturn {\n\t\t\t\t\tspaceId: \"srgb\",\n\t\t\t\t\tcoords: /** @type {Coords} */ (rgba.slice(0, 3)),\n\t\t\t\t\talpha: /** @type {number} */ (rgba.slice(3)[0]),\n\t\t\t\t};\n\t\t\t},\n\t\t\tserialize: (\n\t\t\t\tcoords,\n\t\t\t\talpha,\n\t\t\t\t{\n\t\t\t\t\tcollapse = true, // collapse to 3-4 digit hex when possible?\n\t\t\t\t\talpha: alphaFormat,\n\t\t\t\t} = {},\n\t\t\t) => {\n\t\t\t\tif ((alphaFormat !== false && alpha < 1) || alphaFormat === true) {\n\t\t\t\t\tcoords.push(alpha);\n\t\t\t\t}\n\n\t\t\t\tcoords = /** @type {[number, number, number]} */ (\n\t\t\t\t\tcoords.map(c => Math.round(c * 255))\n\t\t\t\t);\n\n\t\t\t\tlet collapsible = collapse && coords.every(c => c % 17 === 0);\n\n\t\t\t\tlet hex = coords\n\t\t\t\t\t.map(c => {\n\t\t\t\t\t\tif (collapsible) {\n\t\t\t\t\t\t\treturn (c / 17).toString(16);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn c.toString(16).padStart(2, \"0\");\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\");\n\n\t\t\t\treturn \"#\" + hex;\n\t\t\t},\n\t\t},\n\t\tkeyword: {\n\t\t\ttype: \"custom\",\n\t\t\ttest: str => /^[a-z]+$/i.test(str),\n\t\t\tparse (str) {\n\t\t\t\tstr = str.toLowerCase();\n\t\t\t\tlet ret = { spaceId: \"srgb\", coords: null, alpha: 1 };\n\n\t\t\t\tif (str === \"transparent\") {\n\t\t\t\t\tret.coords = KEYWORDS.black;\n\t\t\t\t\tret.alpha = 0;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tret.coords = KEYWORDS[str];\n\t\t\t\t}\n\n\t\t\t\tif (ret.coords) {\n\t\t\t\t\treturn ret;\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t},\n});\n", "import RGBColorSpace from \"../RGBColorSpace.js\";\nimport P3Linear from \"./p3-linear.js\";\nimport sRGB from \"./srgb.js\";\n\nexport default new RGBColorSpace({\n\tid: \"p3\",\n\tcssId: \"display-p3\",\n\tname: \"P3\",\n\tbase: P3Linear,\n\t// Gamma encoding/decoding is the same as sRGB\n\tfromBase: sRGB.fromBase,\n\ttoBase: sRGB.toBase,\n});\n", "/**\n * Relative luminance\n */\nimport get from \"./get.js\";\nimport set from \"./set.js\";\nimport xyz_d65 from \"./spaces/xyz-d65.js\";\n\n/** @import { ColorTypes } from \"./types.js\" */\n\n/**\n *\n * @param {ColorTypes} color\n * @returns {number}\n */\nexport function getLuminance (color) {\n\t// Assume getColor() is called on color in get()\n\treturn get(color, [xyz_d65, \"y\"]);\n}\n\n/**\n * @param {ColorTypes} color\n * @param {number | ((coord: number) => number)} value\n */\nexport function setLuminance (color, value) {\n\t// Assume getColor() is called on color in set()\n\tset(color, [xyz_d65, \"y\"], value);\n}\n\n/**\n * @param {typeof import(\"./color.js\").default} Color\n */\nexport function register (Color) {\n\tObject.defineProperty(Color.prototype, \"luminance\", {\n\t\tget () {\n\t\t\treturn getLuminance(this);\n\t\t},\n\t\tset (value) {\n\t\t\tsetLuminance(this, value);\n\t\t},\n\t});\n}\n", "// WCAG 2.0 contrast https://www.w3.org/TR/WCAG20-TECHS/G18.html\n// Simple contrast, with fixed 5% viewing flare contribution\n// Symmetric, does not matter which is foreground and which is background\n\nimport getColor from \"../getColor.js\";\nimport { getLuminance } from \"../luminance.js\";\n\n/**\n * @param {import(\"../types.js\").ColorTypes} color1\n * @param {import(\"../types.js\").ColorTypes} color2\n * @returns {number}\n */\nexport default function contrastWCAG21 (color1, color2) {\n\tcolor1 = getColor(color1);\n\tcolor2 = getColor(color2);\n\n\tlet Y1 = Math.max(getLuminance(color1), 0);\n\tlet Y2 = Math.max(getLuminance(color2), 0);\n\n\tif (Y2 > Y1) {\n\t\t[Y1, Y2] = [Y2, Y1];\n\t}\n\n\treturn (Y1 + 0.05) / (Y2 + 0.05);\n}\n", "import ColorSpace from \"../ColorSpace.js\";\nimport sRGB from \"./srgb.js\";\n\nexport default new ColorSpace({\n\tid: \"hsl\",\n\tname: \"HSL\",\n\tcoords: {\n\t\th: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t\ts: {\n\t\t\trange: [0, 100],\n\t\t\tname: \"Saturation\",\n\t\t},\n\t\tl: {\n\t\t\trange: [0, 100],\n\t\t\tname: \"Lightness\",\n\t\t},\n\t},\n\n\tbase: sRGB,\n\n\t// Adapted from https://drafts.csswg.org/css-color-4/better-rgbToHsl.js\n\tfromBase: rgb => {\n\t\tlet max = Math.max(...rgb);\n\t\tlet min = Math.min(...rgb);\n\t\tlet [r, g, b] = rgb;\n\t\tlet [h, s, l] = [null, 0, (min + max) / 2];\n\t\tlet d = max - min;\n\n\t\tif (d !== 0) {\n\t\t\ts = l === 0 || l === 1 ? 0 : (max - l) / Math.min(l, 1 - l);\n\n\t\t\tswitch (max) {\n\t\t\t\tcase r:\n\t\t\t\t\th = (g - b) / d + (g < b ? 6 : 0);\n\t\t\t\t\tbreak;\n\t\t\t\tcase g:\n\t\t\t\t\th = (b - r) / d + 2;\n\t\t\t\t\tbreak;\n\t\t\t\tcase b:\n\t\t\t\t\th = (r - g) / d + 4;\n\t\t\t}\n\n\t\t\th = h * 60;\n\t\t}\n\n\t\t// Very out of gamut colors can produce negative saturation\n\t\t// If so, just rotate the hue by 180 and use a positive saturation\n\t\t// see https://github.com/w3c/csswg-drafts/issues/9222\n\t\tif (s < 0) {\n\t\t\th += 180;\n\t\t\ts = Math.abs(s);\n\t\t}\n\n\t\tif (h >= 360) {\n\t\t\th -= 360;\n\t\t}\n\n\t\treturn [h, s * 100, l * 100];\n\t},\n\n\t// Adapted from https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB_alternative\n\ttoBase: hsl => {\n\t\tlet [h, s, l] = hsl;\n\t\th = h % 360;\n\n\t\tif (h < 0) {\n\t\t\th += 360;\n\t\t}\n\n\t\ts /= 100;\n\t\tl /= 100;\n\n\t\tfunction f (n) {\n\t\t\tlet k = (n + h / 30) % 12;\n\t\t\tlet a = s * Math.min(l, 1 - l);\n\t\t\treturn l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));\n\t\t}\n\n\t\treturn [f(0), f(8), f(4)];\n\t},\n\n\tformats: {\n\t\thsl: {\n\t\t\tcoords: [\"<number> | <angle>\", \"<percentage> | <number>\", \"<percentage> | <number>\"],\n\t\t},\n\t\thsla: {\n\t\t\tcoords: [\"<number> | <angle>\", \"<percentage> | <number>\", \"<percentage> | <number>\"],\n\t\t\tcommas: true,\n\t\t\talpha: true,\n\t\t},\n\t},\n});\n", "import ColorSpace from \"../ColorSpace.js\";\nimport OKLab from \"./oklab.js\";\nimport lch from \"./lch.js\";\n\nexport default new ColorSpace({\n\tid: \"oklch\",\n\tname: \"OkLCh\",\n\tcoords: {\n\t\tl: {\n\t\t\trefRange: [0, 1],\n\t\t\tname: \"Lightness\",\n\t\t},\n\t\tc: {\n\t\t\trefRange: [0, 0.4],\n\t\t\tname: \"Chroma\",\n\t\t},\n\t\th: {\n\t\t\trefRange: [0, 360],\n\t\t\ttype: \"angle\",\n\t\t\tname: \"Hue\",\n\t\t},\n\t},\n\twhite: \"D65\",\n\n\tbase: OKLab,\n\tfromBase: lch.fromBase,\n\ttoBase: lch.toBase,\n\n\tformats: {\n\t\toklch: {\n\t\t\tcoords: [\"<percentage> | <number>\", \"<number> | <percentage>\", \"<number> | <angle>\"],\n\t\t},\n\t},\n});\n", "/**\n * Memize options object.\n *\n * @typedef MemizeOptions\n *\n * @property {number} [maxSize] Maximum size of the cache.\n */\n\n/**\n * Internal cache entry.\n *\n * @typedef MemizeCacheNode\n *\n * @property {?MemizeCacheNode|undefined} [prev] Previous node.\n * @property {?MemizeCacheNode|undefined} [next] Next node.\n * @property {Array<*>}                   args   Function arguments for cache\n *                                               entry.\n * @property {*}                          val    Function result.\n */\n\n/**\n * Properties of the enhanced function for controlling cache.\n *\n * @typedef MemizeMemoizedFunction\n *\n * @property {()=>void} clear Clear the cache.\n */\n\n/**\n * Accepts a function to be memoized, and returns a new memoized function, with\n * optional options.\n *\n * @template {(...args: any[]) => any} F\n *\n * @param {F}             fn        Function to memoize.\n * @param {MemizeOptions} [options] Options object.\n *\n * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.\n */\nfunction memize(fn, options) {\n\tvar size = 0;\n\n\t/** @type {?MemizeCacheNode|undefined} */\n\tvar head;\n\n\t/** @type {?MemizeCacheNode|undefined} */\n\tvar tail;\n\n\toptions = options || {};\n\n\tfunction memoized(/* ...args */) {\n\t\tvar node = head,\n\t\t\tlen = arguments.length,\n\t\t\targs,\n\t\t\ti;\n\n\t\tsearchCache: while (node) {\n\t\t\t// Perform a shallow equality test to confirm that whether the node\n\t\t\t// under test is a candidate for the arguments passed. Two arrays\n\t\t\t// are shallowly equal if their length matches and each entry is\n\t\t\t// strictly equal between the two sets. Avoid abstracting to a\n\t\t\t// function which could incur an arguments leaking deoptimization.\n\n\t\t\t// Check whether node arguments match arguments length\n\t\t\tif (node.args.length !== arguments.length) {\n\t\t\t\tnode = node.next;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Check whether node arguments match arguments values\n\t\t\tfor (i = 0; i < len; i++) {\n\t\t\t\tif (node.args[i] !== arguments[i]) {\n\t\t\t\t\tnode = node.next;\n\t\t\t\t\tcontinue searchCache;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// At this point we can assume we've found a match\n\n\t\t\t// Surface matched node to head if not already\n\t\t\tif (node !== head) {\n\t\t\t\t// As tail, shift to previous. Must only shift if not also\n\t\t\t\t// head, since if both head and tail, there is no previous.\n\t\t\t\tif (node === tail) {\n\t\t\t\t\ttail = node.prev;\n\t\t\t\t}\n\n\t\t\t\t// Adjust siblings to point to each other. If node was tail,\n\t\t\t\t// this also handles new tail's empty `next` assignment.\n\t\t\t\t/** @type {MemizeCacheNode} */ (node.prev).next = node.next;\n\t\t\t\tif (node.next) {\n\t\t\t\t\tnode.next.prev = node.prev;\n\t\t\t\t}\n\n\t\t\t\tnode.next = head;\n\t\t\t\tnode.prev = null;\n\t\t\t\t/** @type {MemizeCacheNode} */ (head).prev = node;\n\t\t\t\thead = node;\n\t\t\t}\n\n\t\t\t// Return immediately\n\t\t\treturn node.val;\n\t\t}\n\n\t\t// No cached value found. Continue to insertion phase:\n\n\t\t// Create a copy of arguments (avoid leaking deoptimization)\n\t\targs = new Array(len);\n\t\tfor (i = 0; i < len; i++) {\n\t\t\targs[i] = arguments[i];\n\t\t}\n\n\t\tnode = {\n\t\t\targs: args,\n\n\t\t\t// Generate the result from original function\n\t\t\tval: fn.apply(null, args),\n\t\t};\n\n\t\t// Don't need to check whether node is already head, since it would\n\t\t// have been returned above already if it was\n\n\t\t// Shift existing head down list\n\t\tif (head) {\n\t\t\thead.prev = node;\n\t\t\tnode.next = head;\n\t\t} else {\n\t\t\t// If no head, follows that there's no tail (at initial or reset)\n\t\t\ttail = node;\n\t\t}\n\n\t\t// Trim tail if we're reached max size and are pending cache insertion\n\t\tif (size === /** @type {MemizeOptions} */ (options).maxSize) {\n\t\t\ttail = /** @type {MemizeCacheNode} */ (tail).prev;\n\t\t\t/** @type {MemizeCacheNode} */ (tail).next = null;\n\t\t} else {\n\t\t\tsize++;\n\t\t}\n\n\t\thead = node;\n\n\t\treturn node.val;\n\t}\n\n\tmemoized.clear = function () {\n\t\thead = null;\n\t\ttail = null;\n\t\tsize = 0;\n\t};\n\n\t// Ignore reason: There's not a clear solution to create an intersection of\n\t// the function with additional properties, where the goal is to retain the\n\t// function signature of the incoming argument and add control properties\n\t// on the return value.\n\n\t// @ts-ignore\n\treturn memoized;\n}\n\nexport { memize as default };\n", "/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\nimport {\n\tclone,\n\tset,\n\tto,\n\tsRGB,\n\tHSL,\n\ttype PlainColorObject,\n} from 'colorjs.io/fn';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport './color-ramps/lib/register-color-spaces';\nimport { ThemeContext } from './context';\nimport colorTokens from './prebuilt/ts/color-tokens';\nimport {\n\tbuildBgRamp,\n\tbuildAccentRamp,\n\tDEFAULT_SEED_COLORS,\n\ttype RampResult,\n} from './color-ramps';\nimport { getColorString } from './color-ramps/lib/color-utils';\nimport type { ThemeProviderProps } from './types';\n\ntype Entry = [ string, string ];\n\nconst getCachedBgRamp = memoize( buildBgRamp, { maxSize: 10 } );\nconst getCachedAccentRamp = memoize( buildAccentRamp, { maxSize: 10 } );\n\nconst legacyWpComponentsOverridesCSS: Entry[] = [\n\t[ '--wp-components-color-accent', 'var(--wp-admin-theme-color)' ],\n\t[\n\t\t'--wp-components-color-accent-darker-10',\n\t\t'var(--wp-admin-theme-color-darker-10)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-darker-20',\n\t\t'var(--wp-admin-theme-color-darker-20)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-inverted',\n\t\t'var(--wpds-color-fg-interactive-brand-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-background',\n\t\t'var(--wpds-color-bg-surface-neutral-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground-inverted',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-100',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-200',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-300',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-400',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-600',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-700',\n\t\t'var(--wpds-color-fg-content-neutral-weak)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-800',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n];\n\nfunction customRgbFormat( color: PlainColorObject ): string {\n\tconst rgb = to( color, sRGB );\n\treturn rgb.coords\n\t\t.map( ( n ) => Math.round( ( n ?? 0 ) * 255 ) )\n\t\t.join( ', ' );\n}\n\nfunction legacyWpAdminThemeOverridesCSS( accent: string ): Entry[] {\n\tconst parsedAccent = to( accent, HSL );\n\tconst parsedL = parsedAccent.coords[ 2 ] ?? 0;\n\n\t// Create darker version of accent \u2014\n\tconst darker10 = set(\n\t\tclone( parsedAccent ),\n\t\t[ HSL, 'l' ],\n\t\tMath.max( 0, parsedL - 5 ) // L reduced by 5%\n\t);\n\tconst darker20 = set(\n\t\tclone( parsedAccent ),\n\t\t[ HSL, 'l' ],\n\t\tMath.max( 0, parsedL - 10 ) // L reduced by 10%\n\t);\n\n\treturn [\n\t\t[ '--wp-admin-theme-color', getColorString( parsedAccent ) ],\n\t\t[ '--wp-admin-theme-color--rgb', customRgbFormat( parsedAccent ) ],\n\t\t[ '--wp-admin-theme-color-darker-10', getColorString( darker10 ) ],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-10--rgb',\n\t\t\tcustomRgbFormat( darker10 ),\n\t\t],\n\t\t[ '--wp-admin-theme-color-darker-20', getColorString( darker20 ) ],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-20--rgb',\n\t\t\tcustomRgbFormat( darker20 ),\n\t\t],\n\t];\n}\n\nfunction colorTokensCSS(\n\tcomputedColorRamps: Map< string, RampResult >\n): Entry[] {\n\tconst entries: Entry[] = [];\n\n\tfor ( const [ rampName, { ramp } ] of computedColorRamps ) {\n\t\tfor ( const [ tokenName, tokenValue ] of Object.entries( ramp ) ) {\n\t\t\tconst key = `${ rampName }-${ tokenName }`;\n\t\t\tconst aliasedBy = colorTokens[ key ] ?? [];\n\t\t\tfor ( const aliasedId of aliasedBy ) {\n\t\t\t\tentries.push( [ `--wpds-color-${ aliasedId }`, tokenValue ] );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\nfunction generateStyles( {\n\tprimary,\n\tcomputedColorRamps,\n}: {\n\tprimary: string;\n\tcomputedColorRamps: Map< string, RampResult >;\n} ): CSSProperties {\n\treturn Object.fromEntries(\n\t\t[\n\t\t\t// Semantic color tokens\n\t\t\tcolorTokensCSS( computedColorRamps ),\n\t\t\t// Legacy overrides\n\t\t\tlegacyWpAdminThemeOverridesCSS( primary ),\n\t\t\tlegacyWpComponentsOverridesCSS,\n\t\t].flat()\n\t);\n}\n\nexport function useThemeProviderStyles( {\n\tcolor = {},\n}: {\n\tcolor?: ThemeProviderProps[ 'color' ];\n} = {} ) {\n\tconst { resolvedSettings: inheritedSettings } = useContext( ThemeContext );\n\n\t// Compute settings:\n\t// - used provided prop value;\n\t// - otherwise, use inherited value from parent instance;\n\t// - otherwise, use fallback value (where applicable).\n\tconst primary =\n\t\tcolor.primary ??\n\t\tinheritedSettings.color?.primary ??\n\t\tDEFAULT_SEED_COLORS.primary;\n\tconst bg =\n\t\tcolor.bg ?? inheritedSettings.color?.bg ?? DEFAULT_SEED_COLORS.bg;\n\n\tconst resolvedSettings = useMemo(\n\t\t() => ( {\n\t\t\tcolor: {\n\t\t\t\tprimary,\n\t\t\t\tbg,\n\t\t\t},\n\t\t} ),\n\t\t[ primary, bg ]\n\t);\n\n\tconst themeProviderStyles = useMemo( () => {\n\t\t// Determine which seeds are needed for generating ramps.\n\t\tconst seeds = {\n\t\t\t...DEFAULT_SEED_COLORS,\n\t\t\tbg,\n\t\t\tprimary,\n\t\t};\n\n\t\t// Generate ramps.\n\t\tconst computedColorRamps = new Map< string, RampResult >();\n\t\tconst bgRamp = getCachedBgRamp( seeds.bg );\n\t\tObject.entries( seeds ).forEach( ( [ rampName, seed ] ) => {\n\t\t\tif ( rampName === 'bg' ) {\n\t\t\t\tcomputedColorRamps.set( rampName, bgRamp );\n\t\t\t} else {\n\t\t\t\tcomputedColorRamps.set(\n\t\t\t\t\trampName,\n\t\t\t\t\tgetCachedAccentRamp( seed, bgRamp )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn generateStyles( {\n\t\t\tprimary: seeds.primary,\n\t\t\tcomputedColorRamps,\n\t\t} );\n\t}, [ primary, bg ] );\n\n\treturn {\n\t\tresolvedSettings,\n\t\tthemeProviderStyles,\n\t};\n}\n", "/**\n * External dependencies\n */\nimport { ColorSpace, OKLCH, P3, sRGB, HSL } from 'colorjs.io/fn';\n\n// Ensures that all color spaces used in color ramps are registered globally, a\n// requirement for using colorjs.io's procedural API.\n//\n// See: https://colorjs.io/docs/procedural\nColorSpace.register( sRGB );\nColorSpace.register( OKLCH );\nColorSpace.register( P3 );\nColorSpace.register( HSL );\n", "/*\n * This file is generated by the @wordpress/terrazzo-plugin-inline-alias-values plugin.\n * Do not edit this file directly.\n */\n\nexport default {\n\t'primary-bgFill1': [ 'bg-interactive-brand-strong' ],\n\t'primary-fgFill': [\n\t\t'fg-interactive-brand-strong',\n\t\t'fg-interactive-brand-strong-active',\n\t],\n\t'primary-bgFill2': [ 'bg-interactive-brand-strong-active' ],\n\t'primary-surface4': [ 'bg-interactive-brand-weak-active' ],\n\t'primary-fgSurface3': [\n\t\t'fg-interactive-brand',\n\t\t'fg-interactive-brand-active',\n\t],\n\t'primary-stroke3': [\n\t\t'bg-thumb-brand',\n\t\t'bg-thumb-brand-active',\n\t\t'stroke-focus-brand',\n\t\t'stroke-interactive-brand',\n\t\t'stroke-surface-brand-strong',\n\t],\n\t'primary-stroke4': [ 'stroke-interactive-brand-active' ],\n\t'primary-stroke1': [ 'stroke-surface-brand' ],\n\t'primary-surface1': [ 'bg-surface-brand' ],\n\t'info-surface2': [ 'bg-surface-info-weak' ],\n\t'info-surface4': [ 'bg-surface-info' ],\n\t'info-fgSurface4': [ 'fg-content-info' ],\n\t'info-fgSurface3': [ 'fg-content-info-weak' ],\n\t'info-stroke3': [ 'stroke-surface-info-strong' ],\n\t'info-stroke1': [ 'stroke-surface-info' ],\n\t'success-surface2': [ 'bg-surface-success-weak' ],\n\t'success-surface4': [ 'bg-surface-success' ],\n\t'success-fgSurface4': [ 'fg-content-success' ],\n\t'success-fgSurface3': [ 'fg-content-success-weak' ],\n\t'success-stroke3': [ 'stroke-surface-success-strong' ],\n\t'success-stroke1': [ 'stroke-surface-success' ],\n\t'warning-surface2': [ 'bg-surface-warning-weak' ],\n\t'warning-surface4': [ 'bg-surface-warning' ],\n\t'warning-fgSurface4': [ 'fg-content-warning' ],\n\t'warning-fgSurface3': [ 'fg-content-warning-weak' ],\n\t'warning-stroke3': [ 'stroke-surface-warning-strong' ],\n\t'warning-stroke1': [ 'stroke-surface-warning' ],\n\t'error-bgFill1': [ 'bg-interactive-error-strong' ],\n\t'error-fgFill': [\n\t\t'fg-interactive-error-strong',\n\t\t'fg-interactive-error-strong-active',\n\t],\n\t'error-bgFill2': [ 'bg-interactive-error-strong-active' ],\n\t'error-surface2': [\n\t\t'bg-interactive-error-active',\n\t\t'bg-surface-error-weak',\n\t],\n\t'error-surface4': [\n\t\t'bg-interactive-error-weak-active',\n\t\t'bg-surface-error',\n\t],\n\t'error-fgSurface4': [ 'fg-content-error' ],\n\t'error-fgSurface3': [\n\t\t'fg-content-error-weak',\n\t\t'fg-interactive-error',\n\t\t'fg-interactive-error-active',\n\t],\n\t'error-stroke3': [\n\t\t'stroke-interactive-error',\n\t\t'stroke-interactive-error-strong',\n\t\t'stroke-surface-error-strong',\n\t],\n\t'error-stroke4': [ 'stroke-interactive-error-active' ],\n\t'error-stroke1': [ 'stroke-surface-error' ],\n\t'bg-surface2': [ 'bg-surface-neutral' ],\n\t'bg-surface5': [ 'bg-interactive-neutral-strong-disabled' ],\n\t'bg-surface4': [ 'bg-interactive-neutral-weak-active' ],\n\t'bg-surface3': [ 'bg-surface-neutral-strong' ],\n\t'bg-fgSurface4': [\n\t\t'fg-content-neutral',\n\t\t'fg-interactive-neutral',\n\t\t'fg-interactive-neutral-active',\n\t],\n\t'bg-fgSurface3': [\n\t\t'fg-content-neutral-weak',\n\t\t'fg-interactive-neutral-weak',\n\t],\n\t'bg-fgSurface2': [\n\t\t'fg-interactive-neutral-disabled',\n\t\t'fg-interactive-neutral-strong-disabled',\n\t\t'fg-interactive-neutral-weak-disabled',\n\t],\n\t'bg-stroke3': [\n\t\t'bg-thumb-neutral-weak',\n\t\t'stroke-interactive-neutral',\n\t\t'stroke-surface-neutral-strong',\n\t],\n\t'bg-stroke4': [\n\t\t'bg-thumb-neutral-weak-active',\n\t\t'stroke-interactive-neutral-active',\n\t\t'stroke-interactive-neutral-strong',\n\t],\n\t'bg-stroke2': [\n\t\t'bg-thumb-neutral-disabled',\n\t\t'bg-track-neutral',\n\t\t'stroke-interactive-neutral-disabled',\n\t\t'stroke-surface-neutral',\n\t],\n\t'bg-stroke1': [ 'bg-track-neutral-weak', 'stroke-surface-neutral-weak' ],\n\t'bg-bgFillInverted2': [ 'bg-interactive-neutral-strong-active' ],\n\t'bg-bgFillInverted1': [ 'bg-interactive-neutral-strong' ],\n\t'bg-fgFillInverted': [\n\t\t'fg-interactive-neutral-strong',\n\t\t'fg-interactive-neutral-strong-active',\n\t],\n\t'bg-surface1': [ 'bg-surface-neutral-weak' ],\n\t'caution-surface2': [ 'bg-surface-caution-weak' ],\n\t'caution-surface4': [ 'bg-surface-caution' ],\n\t'caution-fgSurface4': [ 'fg-content-caution' ],\n\t'caution-fgSurface3': [ 'fg-content-caution-weak' ],\n} as Record< string, string[] >;\n", "/**\n * External dependencies\n */\nimport {\n\tto,\n\ttoGamut,\n\tserialize,\n\tcontrastWCAG21,\n\tsRGB,\n\tOKLCH,\n\ttype ColorTypes,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\n\n/**\n * Get string representation of a color\n * @param color Color object to stringify\n * @return String representation\n */\nexport function getColorString( color: ColorTypes ): string {\n\tconst rgbRounded = serialize( to( color, sRGB ) );\n\treturn serialize( rgbRounded, { format: 'hex' } );\n}\n\n/**\n * Get contrast value between two colors\n * @param colorA First color\n * @param colorB Second color\n * @return WCAG 2.1 contrast ratio\n */\nexport function getContrast( colorA: ColorTypes, colorB: ColorTypes ): number {\n\treturn contrastWCAG21( colorA, colorB );\n}\n\n/**\n * Make sure that a color is valid in the sRGB gamut and convert it to OKLCH.\n * @param c\n */\nexport function clampToGamut( c: ColorTypes ) {\n\t// map into sRGB using CSS OKLCH method\n\treturn to( toGamut( c, { space: sRGB, method: 'css' } ), OKLCH );\n}\n", "/**\n * External dependencies\n */\nimport { to, OKLCH } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport type { Ramp } from './types';\n\nexport const WHITE = to( 'white', OKLCH );\nexport const BLACK = to( 'black', OKLCH );\n\n// Margin added to target contrasts to counter for algorithm approximations and rounding errors.\n// - the `CONTRAST_EPSILON` value is 0.004, so the real contrast can be lower by this amount.\n// - the max contrast between adjacent RGB values is 1.016, so 0.016 is the maximum total rounding error between two values.\n// - the sum is 0.02: the margin we add to ensure that the target contrast is met after all the rounding.\nexport const UNIVERSAL_CONTRAST_TOPUP = 0.02;\n\n// When enabling \"lighter direction\" bias, this is the amount by which\n// black text contrast needs to be greater than white text contrast.\n// The higher the value, the stronger the preference for white text.\n// The current value has been determined empirically as the highest value\n// that won't cause the algo not to be able to correctly solve all contrasts.\nexport const WHITE_TEXT_CONTRAST_MARGIN = 3.1;\n\n// These values are used as thresholds when trying to match the background\n// ramp's lightness while calculating an accent ramp. They prevent the accent\n// scale from being pinned to lightness values in the middle of the range,\n// which would cause the algorithm to struggle to satisfy the accent scale\n// constraints and therefore produce unexpected results.\nexport const ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS = {\n\tlighter: { min: 0.2, max: 0.4 },\n\tdarker: { min: 0.75, max: 0.98 },\n} as const;\n\n// Contrast precision we aim for. Approximately 1/256, resolution of an 8-bit number.\nexport const CONTRAST_EPSILON = 4e-3;\n\nexport const MAX_BISECTION_ITERATIONS = 10;\n\nexport const CONTRAST_COMBINATIONS: {\n\tbgs: ( keyof Ramp )[];\n\tfgs: ( keyof Ramp )[];\n\ttarget: number;\n}[] = [\n\t{\n\t\tbgs: [ 'surface1', 'surface2', 'surface3' ],\n\t\tfgs: [ 'fgSurface3', 'fgSurface4' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'surface4', 'surface5' ],\n\t\tfgs: [ 'fgSurface4' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFill1' ],\n\t\tfgs: [ 'fgFill' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFillInverted1' ],\n\t\tfgs: [ 'fgFillInverted' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFillInverted1' ],\n\t\tfgs: [ 'fgFillInverted' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'surface1', 'surface2', 'surface3' ],\n\t\tfgs: [ 'stroke3' ],\n\t\ttarget: 3,\n\t},\n];\n\n// Used when generating the DTCG tokens and the static color ramps.\nexport const DEFAULT_SEED_COLORS = {\n\tbg: '#f8f8f8',\n\tprimary: '#3858e9',\n\tinfo: '#0090ff',\n\tsuccess: '#4ab866',\n\tcaution: '#f0d149',\n\twarning: '#f0b849',\n\terror: '#cc1818',\n};\n", "/**\n * External dependencies\n */\nimport { type ColorTypes } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport {\n\tWHITE,\n\tBLACK,\n\tUNIVERSAL_CONTRAST_TOPUP,\n\tWHITE_TEXT_CONTRAST_MARGIN,\n\tACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS,\n\tMAX_BISECTION_ITERATIONS,\n\tCONTRAST_EPSILON,\n} from './constants';\nimport type { Ramp, RampConfig, RampDirection } from './types';\nimport { getContrast } from './color-utils';\n\n/**\n * Build a dependency graph from the steps configuration\n * @param config - The steps configuration object\n */\nfunction buildDependencyGraph( config: RampConfig ): {\n\tdependencies: Map< keyof Ramp, ( keyof Ramp | 'seed' )[] >;\n\tdependents: Map< keyof Ramp | 'seed', ( keyof Ramp )[] >;\n} {\n\tconst dependencies = new Map< keyof Ramp, ( keyof Ramp | 'seed' )[] >();\n\tconst dependents = new Map< keyof Ramp | 'seed', ( keyof Ramp )[] >();\n\n\t// Initialize maps\n\tObject.keys( config ).forEach( ( step ) => {\n\t\tdependencies.set( step as keyof Ramp, [] );\n\t} );\n\tdependents.set( 'seed', [] );\n\tObject.keys( config ).forEach( ( step ) => {\n\t\tdependents.set( step as keyof Ramp, [] );\n\t} );\n\n\t// Build the graph\n\tObject.entries( config ).forEach( ( [ stepName, stepConfig ] ) => {\n\t\tconst step = stepName as keyof Ramp;\n\t\tconst reference = stepConfig.contrast.reference;\n\n\t\tdependencies.get( step )!.push( reference );\n\t\tdependents.get( reference )!.push( step );\n\n\t\t// Add dependency for sameAsIfPossible\n\t\tif ( stepConfig.sameAsIfPossible ) {\n\t\t\tdependencies.get( step )!.push( stepConfig.sameAsIfPossible );\n\t\t\tdependents.get( stepConfig.sameAsIfPossible )!.push( step );\n\t\t}\n\t} );\n\n\treturn { dependencies, dependents };\n}\n\n/**\n * Topologically sort steps based on their dependencies\n * @param config - The steps configuration object\n */\nexport function sortByDependency( config: RampConfig ): ( keyof Ramp )[] {\n\tconst { dependents } = buildDependencyGraph( config );\n\tconst result: ( keyof Ramp )[] = [];\n\tconst visited = new Set< keyof Ramp | 'seed' >();\n\tconst visiting = new Set< keyof Ramp | 'seed' >();\n\n\tfunction visit( node: keyof Ramp | 'seed' ): void {\n\t\tif ( visiting.has( node ) ) {\n\t\t\tthrow new Error(\n\t\t\t\t`Circular dependency detected involving step: ${ String(\n\t\t\t\t\tnode\n\t\t\t\t) }`\n\t\t\t);\n\t\t}\n\t\tif ( visited.has( node ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tvisiting.add( node );\n\n\t\t// Visit all dependents (steps that depend on this node)\n\t\tconst nodeDependents = dependents.get( node ) || [];\n\t\tnodeDependents.forEach( ( dependent ) => {\n\t\t\tvisit( dependent );\n\t\t} );\n\n\t\tvisiting.delete( node );\n\t\tvisited.add( node );\n\n\t\t// Add to result only if it's a step (not 'seed')\n\t\tif ( node !== 'seed' ) {\n\t\t\tresult.unshift( node ); // Add to front for correct topological order\n\t\t}\n\t}\n\n\t// Start with seed - this will recursively visit all reachable nodes\n\tvisit( 'seed' );\n\n\treturn result;\n}\n/**\n * Return minimal set of steps that are needed to calculate `stepName` from the seed.\n * @param stepName Name of the step.\n * @param config   Configuration of the ramp.\n * @return Array of steps that `stepName` depends on.\n */\nexport function stepsForStep(\n\tstepName: keyof Ramp,\n\tconfig: RampConfig\n): ( keyof Ramp )[] {\n\tconst result = new Set< keyof Ramp >();\n\tfunction visit( step: keyof Ramp | 'seed' ) {\n\t\tif ( step === 'seed' || result.has( step ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst stepConfig = config[ step ];\n\t\tif ( ! stepConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tvisit( stepConfig.contrast.reference );\n\t\tif ( stepConfig.sameAsIfPossible ) {\n\t\t\tvisit( stepConfig.sameAsIfPossible );\n\t\t}\n\n\t\tresult.add( step );\n\t}\n\tvisit( stepName );\n\treturn Array.from( result );\n}\n\n/**\n * Finds out whether a lighter or a darker foreground color achieves a better\n * contrast against the seed\n * @param seed\n * @param preferLighter Whether the check should favor white foreground color\n * @return An object with \"better\" and \"worse\" properties, each holding a\n * ramp direction value.\n */\nexport function computeBetterFgColorDirection(\n\tseed: ColorTypes,\n\tpreferLighter?: boolean\n): {\n\tbetter: RampDirection;\n\tworse: RampDirection;\n} {\n\tconst contrastAgainstBlack = getContrast( seed, BLACK );\n\tconst contrastAgainstWhite = getContrast( seed, WHITE );\n\n\treturn contrastAgainstBlack >\n\t\tcontrastAgainstWhite +\n\t\t\t( preferLighter ? WHITE_TEXT_CONTRAST_MARGIN : 0 )\n\t\t? { better: 'darker', worse: 'lighter' }\n\t\t: { better: 'lighter', worse: 'darker' };\n}\n\nexport function adjustContrastTarget( target: number ) {\n\tif ( target === 1 ) {\n\t\treturn 1;\n\t}\n\n\t// Add a little top up to take into account any rounding error and algo imprecisions.\n\treturn target + UNIVERSAL_CONTRAST_TOPUP;\n}\n\n/**\n * Prevent the accent scale from referencing a lightness value that\n * would prevent the algorithm from complying with the requirements\n * and cause it to generate unexpected results.\n * @param rawLightness\n * @param direction\n * @return The clamped lightness value\n */\nexport function clampAccentScaleReferenceLightness(\n\trawLightness: number,\n\tdirection: RampDirection\n) {\n\tconst thresholds = ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS[ direction ];\n\treturn Math.max( thresholds.min, Math.min( thresholds.max, rawLightness ) );\n}\n\n/**\n * Find the value of of `L` (luminance) that produces a `C` (color) that has a\n * `value` (contrast delta) equal to zero.\n * @param calculateC     Calculate `C` from a given `L`.\n * @param calculateValue Calculate value (delta) for a given `C`.\n * @param initLowerL     Initial lower value of `L`.\n * @param initLowerValue Initial lower delta (negative).\n * @param initUpperL     Initial upper value of `L`.\n * @param initUpperValue Initial upper delta (positive).\n * @return Resulting value of type `C`.\n */\nexport function solveWithBisect< C >(\n\tcalculateC: ( l: number ) => C,\n\tcalculateValue: ( t: C ) => number,\n\tinitLowerL: number,\n\tinitLowerValue: number,\n\tinitUpperL: number,\n\tinitUpperValue: number\n): C {\n\tlet lowerL = initLowerL;\n\tlet lowerValue = initLowerValue;\n\tlet lowerReplaced = false;\n\n\tlet upperL = initUpperL;\n\tlet upperValue = initUpperValue;\n\tlet upperReplaced = false;\n\n\tlet bestC: C;\n\tlet bestValue: number;\n\tlet iterations = 0;\n\n\twhile ( true ) {\n\t\titerations++;\n\n\t\t// Linear interpolation: find the point where a line would cross the zero axis.\n\t\tconst newL =\n\t\t\t( lowerL * upperValue - upperL * lowerValue ) /\n\t\t\t( upperValue - lowerValue );\n\n\t\tbestC = calculateC( newL );\n\t\tbestValue = calculateValue( bestC );\n\n\t\tif (\n\t\t\tMath.abs( bestValue ) <= CONTRAST_EPSILON ||\n\t\t\titerations >= MAX_BISECTION_ITERATIONS\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// Update the lower/upper bracket values. When only one side is repeatedly updated,\n\t\t// apply so-called \"Illinois trick\" for faster convergence: halve the opposite value.\n\t\tif ( bestValue <= 0 ) {\n\t\t\tlowerL = newL;\n\t\t\tlowerValue = bestValue;\n\t\t\tif ( lowerReplaced ) {\n\t\t\t\tupperValue /= 2;\n\t\t\t}\n\t\t\tlowerReplaced = true;\n\t\t\tupperReplaced = false;\n\t\t} else {\n\t\t\tupperL = newL;\n\t\t\tupperValue = bestValue;\n\t\t\tif ( upperReplaced ) {\n\t\t\t\tlowerValue /= 2;\n\t\t\t}\n\t\t\tupperReplaced = true;\n\t\t\tlowerReplaced = false;\n\t\t}\n\t}\n\n\treturn bestC;\n}\n", "/**\n * External dependencies\n */\nimport {\n\tget,\n\ttoGamut,\n\tOKLCH,\n\tsRGB,\n\ttype PlainColorObject,\n\ttype ColorSpace,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\n\nexport interface TaperChromaOptions {\n\tgamut?: ColorSpace; // target gamut (default `sRGB`)\n\talpha?: number; // base fraction of Cmax at target (default 0.62)\n\tcarry?: number; // seed vividness carry exponent \u03B2 in [0..1] (default 0.5)\n\tcUpperBound?: number; // hard search cap for C (default 0.45)\n\t// Continuous taper around the seed (desaturate both sides slightly)\n\tradiusLight?: number; // distance in L where kLight is reached (default 0.20)\n\tradiusDark?: number; // distance in L where kDark is reached (default 0.20)\n\tkLight?: number; // floor multiplier near lighter side (default 0.85)\n\tkDark?: number; // floor multiplier near darker side (default 0.85)\n\t// Achromatic handling\n\thueFallback?: number; // degrees: if seed is achromatic and you still want color\n\tachromaEpsilon?: number; // \u2264 this chroma \u2192 treat as achromatic (default 0.005)\n}\n\n/**\n * Given the seed and the target lightness, tapers the chroma smoothly.\n * - C_intended = Cmax(Lt,H0) * alpha * (seedRelative^carry)\n * - Continuous taper vs |Lt - Ls| to softly reduce chroma for neighbors\n * - Downward-only clamp on C (preserve L & H)\n * @param seed\n * @param lTarget\n * @param options\n */\nexport function taperChroma(\n\tseed: PlainColorObject, // already OKLCH\n\tlTarget: number, // [0..1]\n\toptions: TaperChromaOptions = {}\n): { l: number; c: number } | PlainColorObject {\n\tconst gamut = options.gamut ?? sRGB;\n\tconst alpha = options.alpha ?? 0.65; // 0.7-0.8 works well for accent surface\n\tconst carry = options.carry ?? 0.5;\n\tconst cUpperBound = options.cUpperBound ?? 0.45;\n\tconst radiusLight = options.radiusLight ?? 0.2;\n\tconst radiusDark = options.radiusDark ?? 0.2;\n\tconst kLight = options.kLight ?? 0.85;\n\tconst kDark = options.kDark ?? 0.85;\n\tconst achromaEpsilon = options.achromaEpsilon ?? 0.005;\n\n\tconst cSeed = Math.max( 0, get( seed, [ OKLCH, 'c' ] ) );\n\tlet hSeed = get( seed, [ OKLCH, 'h' ] );\n\n\tconst chromaIsTiny = cSeed < achromaEpsilon;\n\tconst hueIsInvalid = hSeed === null || ! Number.isFinite( hSeed );\n\n\tif ( chromaIsTiny || hueIsInvalid ) {\n\t\tif ( typeof options.hueFallback === 'number' ) {\n\t\t\thSeed = normalizeHue( options.hueFallback );\n\t\t} else {\n\t\t\t// Respect achromatic intent: grayscale at target L\n\t\t\treturn {\n\t\t\t\tspace: OKLCH,\n\t\t\t\tcoords: [ clamp01( lTarget ), 0, 0 ],\n\t\t\t\talpha: 1,\n\t\t\t};\n\t\t}\n\t}\n\n\t// Capacity at seed and target\n\tconst lSeed = clamp01( get( seed, [ OKLCH, 'l' ] ) );\n\tconst cmaxSeed = getCachedMaxChromaAtLH( lSeed, hSeed, gamut, cUpperBound );\n\tconst cmaxTarget = getCachedMaxChromaAtLH(\n\t\tclamp01( lTarget ),\n\t\thSeed,\n\t\tgamut,\n\t\tcUpperBound\n\t);\n\n\t// Seed vividness ratio (hue-fair normalization)\n\tlet seedRelative = 0;\n\tconst denom = cmaxSeed > 0 ? cmaxSeed : 1e-6;\n\tseedRelative = clamp01( cSeed / denom );\n\n\t// Intended chroma from local capacity, tempered by seed vividness\n\tconst cIntendedBase = alpha * cmaxTarget;\n\tconst cWithCarry =\n\t\tcIntendedBase * Math.pow( seedRelative, clamp01( carry ) );\n\n\t// Gentle, symmetric desaturation vs distance in L\n\tconst t = continuousTaper( lSeed, lTarget, {\n\t\tradiusLight,\n\t\tradiusDark,\n\t\tkLight,\n\t\tkDark,\n\t} );\n\tconst cPlanned = cWithCarry * t;\n\n\t// Downward-only clamp (preserve L & H)\n\tconst lOut = clamp01( lTarget );\n\n\treturn { l: lOut, c: cPlanned };\n}\n\n/* ---------------- helpers & caches ---------------- */\n\nfunction clamp01( x: number ): number {\n\tif ( x < 0 ) {\n\t\treturn 0;\n\t}\n\tif ( x > 1 ) {\n\t\treturn 1;\n\t}\n\treturn x;\n}\nfunction normalizeHue( h: number ): number {\n\tlet hue = h % 360;\n\tif ( hue < 0 ) {\n\t\thue += 360;\n\t}\n\treturn hue;\n}\nfunction raisedCosine( u: number ): number {\n\tconst x = clamp01( u );\n\treturn 0.5 - 0.5 * Math.cos( Math.PI * x );\n}\n\n/**\n * smooth, distance-from-seed chroma taper (raised-cosine per side)\n * @param seedL\n * @param targetL\n * @param opts\n * @param opts.radiusLight\n * @param opts.radiusDark\n * @param opts.kLight\n * @param opts.kDark\n */\nfunction continuousTaper(\n\tseedL: number,\n\ttargetL: number,\n\topts: {\n\t\tradiusLight: number;\n\t\tradiusDark: number;\n\t\tkLight: number;\n\t\tkDark: number;\n\t}\n): number {\n\tconst d = targetL - seedL;\n\tif ( d >= 0 ) {\n\t\tconst u = opts.radiusLight > 0 ? Math.abs( d ) / opts.radiusLight : 1;\n\t\tconst w = raisedCosine( u > 1 ? 1 : u );\n\t\treturn 1 - ( 1 - opts.kLight ) * w;\n\t}\n\tconst u = opts.radiusDark > 0 ? Math.abs( d ) / opts.radiusDark : 1;\n\tconst w = raisedCosine( u > 1 ? 1 : u );\n\treturn 1 - ( 1 - opts.kDark ) * w;\n}\n\n/* ---- chroma-capacity queries with small caches ---- */\n\nconst maxChromaCache = new Map< string, number >();\nfunction keyMax( l: number, h: number, gamut: string, cap: number ): string {\n\t// Quantize to keep cache compact\n\tconst lq = quantize( l, 0.05 );\n\tconst hq = quantize( normalizeHue( h ), 10 );\n\tconst cq = quantize( cap, 0.05 );\n\treturn `${ gamut }|L:${ lq }|H:${ hq }|cap:${ cq }`;\n}\n\nfunction quantize( x: number, step: number ): number {\n\tconst k = Math.round( x / step );\n\treturn k * step;\n}\n\nfunction getCachedMaxChromaAtLH(\n\tl: number,\n\th: number,\n\tgamutSpace: ColorSpace,\n\tcap: number\n): number {\n\tconst gamut = gamutSpace.id;\n\tconst key = keyMax( l, h, gamut, cap );\n\tconst hit = maxChromaCache.get( key );\n\tif ( typeof hit === 'number' ) {\n\t\treturn hit;\n\t}\n\n\tconst computed = maxInGamutChromaAtLH( l, h, gamutSpace, cap );\n\tmaxChromaCache.set( key, computed );\n\treturn computed;\n}\n\n/**\n * Find the max in-gamut chroma at fixed (L,H) in the target gamut\n * @param l\n * @param h\n * @param gamutSpace\n * @param cap\n */\nfunction maxInGamutChromaAtLH(\n\tl: number,\n\th: number,\n\tgamutSpace: ColorSpace,\n\tcap: number\n): number {\n\t// Construct a color with maximum chroma.\n\tconst probe: PlainColorObject = {\n\t\tspace: OKLCH,\n\t\tcoords: [ l, cap, h ],\n\t\talpha: 1,\n\t};\n\n\t// Let `toGamut` reduce the chroma to the gamut maximum.\n\tconst clamped = toGamut( probe, { space: gamutSpace, method: 'css' } );\n\n\treturn get( clamped, [ OKLCH, 'c' ] );\n}\n", "/**\n * External dependencies\n */\nimport { get, OKLCH, type PlainColorObject } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport { solveWithBisect } from './utils';\nimport { WHITE, BLACK, CONTRAST_EPSILON } from './constants';\nimport { clampToGamut, getContrast } from './color-utils';\nimport { type TaperChromaOptions, taperChroma } from './taper-chroma';\n\n/**\n * Difference of contrast values that grows linearly with the Y luminance.\n * We get more precise linear interpolations when we use this.\n * @param c1 First contrast.\n * @param c2 Second contrast.\n * @return Difference of logarithms.\n */\nfunction cdiff( c1: number, c2: number ) {\n\treturn Math.log( c1 / c2 );\n}\n\n/**\n * Solve for L such that:\n *  - the L applied to the seed meets the contrast target against the reference\n *  - the search is performed in one direction (ie lighter / darker)\n *  - more constraints can be applied around lightness\n * @param reference\n * @param seed\n * @param target\n * @param direction\n * @param options\n * @param options.lightnessConstraint\n * @param options.lightnessConstraint.type\n * @param options.lightnessConstraint.value\n * @param options.taperChromaOptions\n */\nexport function findColorMeetingRequirements(\n\treference: PlainColorObject,\n\tseed: PlainColorObject,\n\ttarget: number,\n\tdirection: 'lighter' | 'darker',\n\t{\n\t\tlightnessConstraint,\n\t\ttaperChromaOptions,\n\t}: {\n\t\tlightnessConstraint?: {\n\t\t\ttype: 'force' | 'onlyIfSucceeds';\n\t\t\tvalue: number;\n\t\t};\n\t\ttaperChromaOptions?: TaperChromaOptions;\n\t} = {}\n): {\n\tcolor: PlainColorObject;\n\treached: boolean;\n\tachieved: number;\n\tdeficit?: number;\n} {\n\t// A target of 1 means same color.\n\t// A target lower than 1 doesn't make sense.\n\tif ( target <= 1 ) {\n\t\treturn {\n\t\t\tcolor: reference,\n\t\t\treached: true,\n\t\t\tachieved: 1,\n\t\t};\n\t}\n\n\tfunction getColorForL( l: number ): PlainColorObject {\n\t\tlet newL = l;\n\t\tlet newC = get( seed, [ OKLCH, 'c' ] );\n\n\t\tif ( taperChromaOptions ) {\n\t\t\tconst tapered = taperChroma( seed, newL, taperChromaOptions );\n\t\t\t// taperChroma returns either { l, c } or a ColorObject\n\t\t\tif ( 'l' in tapered && 'c' in tapered ) {\n\t\t\t\tnewL = tapered.l;\n\t\t\t\tnewC = tapered.c;\n\t\t\t} else {\n\t\t\t\t// It's already a ColorObject, return it directly\n\t\t\t\treturn tapered;\n\t\t\t}\n\t\t}\n\n\t\treturn clampToGamut( {\n\t\t\tspaceId: 'oklch',\n\t\t\tcoords: [ newL, newC, get( seed, [ OKLCH, 'h' ] ) ],\n\t\t} );\n\t}\n\n\t// Set the boundary based on the direction.\n\tconst mostContrastingL = direction === 'lighter' ? 1 : 0;\n\tconst mostContrastingColor = direction === 'lighter' ? WHITE : BLACK;\n\tconst highestContrast = getContrast( reference, mostContrastingColor );\n\n\tif ( lightnessConstraint ) {\n\t\t// Apply a specific L value.\n\t\t// Useful when pinning a step to a specific lightness, of to specify\n\t\t// min/max L values.\n\t\tconst colorWithExactL = getColorForL( lightnessConstraint.value );\n\t\tconst exactLContrast = getContrast( reference, colorWithExactL );\n\t\tconst exactLContrastMeetsTarget =\n\t\t\tcdiff( exactLContrast, target ) >= -CONTRAST_EPSILON;\n\n\t\t// If the L constraint is of \"force\" type, apply it even when it doesn't\n\t\t// meet the contrast target.\n\t\tif (\n\t\t\texactLContrastMeetsTarget ||\n\t\t\tlightnessConstraint.type === 'force'\n\t\t) {\n\t\t\treturn {\n\t\t\t\tcolor: colorWithExactL,\n\t\t\t\treached: exactLContrastMeetsTarget,\n\t\t\t\tachieved: exactLContrast,\n\t\t\t\tdeficit: exactLContrastMeetsTarget\n\t\t\t\t\t? cdiff( exactLContrast, highestContrast )\n\t\t\t\t\t: cdiff( target, exactLContrast ),\n\t\t\t};\n\t\t}\n\t}\n\n\t// If even the most contrasting color can't reach the target, the target is unreachable.\n\t// On the other hand, if the contrast is very close to the target, we consider it reached.\n\tif ( cdiff( highestContrast, target ) <= CONTRAST_EPSILON ) {\n\t\treturn {\n\t\t\tcolor: mostContrastingColor,\n\t\t\treached: cdiff( highestContrast, target ) >= -CONTRAST_EPSILON,\n\t\t\tachieved: highestContrast,\n\t\t\tdeficit: cdiff( target, highestContrast ),\n\t\t};\n\t}\n\n\t// Bracket: low fails, high meets.\n\t// Originally this was seed.oklch.l \u2014 although it's an assumption that works\n\t// only when we know for sure the direction of the search.\n\t// TODO: can we bring this back to seed.oklch.l ?\n\tconst lowerL = get( reference, [ OKLCH, 'l' ] );\n\tconst lowerContrast = cdiff( 1, target );\n\tconst upperL = mostContrastingL;\n\tconst upperContrast = cdiff( highestContrast, target );\n\n\tconst bestColor = solveWithBisect(\n\t\tgetColorForL,\n\t\t( c ) => cdiff( getContrast( reference, c ), target ),\n\t\tlowerL,\n\t\tlowerContrast,\n\t\tupperL,\n\t\tupperContrast\n\t);\n\n\treturn {\n\t\tcolor: bestColor,\n\t\treached: true,\n\t\tachieved: target,\n\t\t// Negative number that specifies how much room we have.\n\t\tdeficit: cdiff( target, highestContrast ),\n\t};\n}\n", "/**\n * External dependencies\n */\nimport {\n\tclone,\n\tget,\n\tOKLCH,\n\tset,\n\ttype ColorTypes,\n\ttype PlainColorObject,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport { clampToGamut, getContrast, getColorString } from './color-utils';\nimport { findColorMeetingRequirements } from './find-color-with-constraints';\nimport {\n\tsortByDependency,\n\tcomputeBetterFgColorDirection,\n\tadjustContrastTarget,\n\tstepsForStep,\n\tsolveWithBisect,\n} from './utils';\n\nimport type {\n\tFollowDirection,\n\tRamp,\n\tRampDirection,\n\tRampConfig,\n\tRampResult,\n} from './types';\nimport { CONTRAST_EPSILON } from './constants';\n\n/**\n * Calculate a complete color ramp based on the provided configuration.\n *\n * @param params                       - The calculation parameters\n * @param params.seed                  - The base color to build the ramp from\n * @param params.sortedSteps           - Steps sorted in dependency order\n * @param params.config                - Ramp configuration defining contrast requirements\n * @param params.mainDir               - Primary direction for the ramp (lighter/darker)\n * @param params.oppDir                - Opposite direction from mainDir\n * @param params.pinLightness          - Optional lightness override for a given step\n * @param params.pinLightness.stepName\n * @param params.pinLightness.value\n * @return Object containing ramp results and satisfaction status\n */\nfunction calculateRamp( {\n\tseed,\n\tsortedSteps,\n\tconfig,\n\tmainDir,\n\toppDir,\n\tpinLightness,\n}: {\n\tseed: PlainColorObject;\n\tsortedSteps: ( keyof Ramp )[];\n\tconfig: RampConfig;\n\tmainDir: RampDirection;\n\toppDir: RampDirection;\n\tpinLightness?: {\n\t\tstepName: keyof Ramp;\n\t\tvalue: number;\n\t};\n} ) {\n\tconst rampResults = {} as Record< keyof Ramp, string >;\n\tlet warnings: string[] | undefined;\n\tlet maxDeficit = -Infinity;\n\tlet maxDeficitDirection: RampDirection = 'lighter';\n\tlet maxDeficitStep;\n\n\t// Keep track of the calculated colors, as they are going to be useful\n\t// when other colors reference them.\n\tconst calculatedColors = new Map< keyof Ramp | 'seed', PlainColorObject >();\n\tcalculatedColors.set( 'seed', seed );\n\n\tfor ( const stepName of sortedSteps ) {\n\t\tconst {\n\t\t\tcontrast,\n\t\t\tlightness: stepLightnessConstraint,\n\t\t\ttaperChromaOptions,\n\t\t\tsameAsIfPossible,\n\t\t} = config[ stepName ];\n\n\t\tconst referenceColor = calculatedColors.get( contrast.reference );\n\t\tif ( ! referenceColor ) {\n\t\t\tthrow new Error(\n\t\t\t\t`Reference color for step ${ stepName } not found: ${ contrast.reference }`\n\t\t\t);\n\t\t}\n\n\t\t// Check if we can reuse color from the `sameAsIfPossible` config option\n\t\tif ( sameAsIfPossible ) {\n\t\t\tconst candidateColor = calculatedColors.get( sameAsIfPossible );\n\t\t\tif ( ! candidateColor ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Same-as color for step ${ stepName } not found: ${ sameAsIfPossible }`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst candidateContrast = getContrast(\n\t\t\t\treferenceColor,\n\t\t\t\tcandidateColor\n\t\t\t);\n\t\t\tconst adjustedTarget = adjustContrastTarget( contrast.target );\n\t\t\t// If the candidate meets the contrast requirement, use it\n\t\t\tif ( candidateContrast >= adjustedTarget ) {\n\t\t\t\t// Store the reused color\n\t\t\t\tcalculatedColors.set( stepName, candidateColor );\n\t\t\t\trampResults[ stepName ] = getColorString( candidateColor );\n\n\t\t\t\tcontinue; // Skip to next step\n\t\t\t}\n\t\t}\n\n\t\tfunction computeDirection(\n\t\t\tcolor: ColorTypes,\n\t\t\tfollowDirection: FollowDirection\n\t\t): RampDirection {\n\t\t\tif ( followDirection === 'main' ) {\n\t\t\t\treturn mainDir;\n\t\t\t}\n\n\t\t\tif ( followDirection === 'opposite' ) {\n\t\t\t\treturn oppDir;\n\t\t\t}\n\n\t\t\tif ( followDirection === 'best' ) {\n\t\t\t\treturn computeBetterFgColorDirection(\n\t\t\t\t\tcolor,\n\t\t\t\t\tcontrast.preferLighter\n\t\t\t\t).better;\n\t\t\t}\n\n\t\t\treturn followDirection;\n\t\t}\n\n\t\tconst computedDir = computeDirection(\n\t\t\treferenceColor,\n\t\t\tcontrast.followDirection\n\t\t);\n\n\t\tconst adjustedTarget = adjustContrastTarget( contrast.target );\n\n\t\t// Define the lightness constraint, if needed.\n\t\tlet lightnessConstraint;\n\t\tif ( pinLightness?.stepName === stepName ) {\n\t\t\tlightnessConstraint = {\n\t\t\t\tvalue: pinLightness.value,\n\t\t\t\ttype: 'force',\n\t\t\t} as const;\n\t\t} else if ( stepLightnessConstraint ) {\n\t\t\tlightnessConstraint = {\n\t\t\t\tvalue: stepLightnessConstraint( computedDir ),\n\t\t\t\ttype: 'onlyIfSucceeds',\n\t\t\t} as const;\n\t\t}\n\n\t\t// Calculate the color meeting the requirements\n\t\tconst searchResults = findColorMeetingRequirements(\n\t\t\treferenceColor,\n\t\t\tseed,\n\t\t\tadjustedTarget,\n\t\t\tcomputedDir,\n\t\t\t{\n\t\t\t\tlightnessConstraint,\n\t\t\t\ttaperChromaOptions,\n\t\t\t}\n\t\t);\n\n\t\t// When the target contrast is not met, take note of it and use\n\t\t// that information to guide the ramp calculation bisection.\n\t\tif (\n\t\t\t! contrast.ignoreWhenAdjustingSeed &&\n\t\t\tsearchResults.deficit &&\n\t\t\tsearchResults.deficit > maxDeficit\n\t\t) {\n\t\t\tmaxDeficit = searchResults.deficit;\n\t\t\tmaxDeficitDirection = computedDir;\n\t\t\tmaxDeficitStep = stepName;\n\t\t}\n\n\t\t// Store calculated color for future dependencies\n\t\tcalculatedColors.set( stepName, searchResults.color );\n\n\t\t// Add to results\n\t\trampResults[ stepName ] = getColorString( searchResults.color );\n\n\t\tif ( ! searchResults.reached && ! contrast.ignoreWhenAdjustingSeed ) {\n\t\t\twarnings ??= [];\n\t\t\twarnings.push( stepName );\n\t\t}\n\t}\n\n\treturn {\n\t\trampResults,\n\t\twarnings,\n\t\tmaxDeficit,\n\t\tmaxDeficitDirection,\n\t\tmaxDeficitStep,\n\t};\n}\n\nexport function buildRamp(\n\tseedArg: string,\n\tconfig: RampConfig,\n\t{\n\t\tmainDirection,\n\t\tpinLightness,\n\t\trescaleToFitContrastTargets = true,\n\t}: {\n\t\tmainDirection?: RampDirection;\n\t\tpinLightness?: {\n\t\t\tstepName: keyof Ramp;\n\t\t\tvalue: number;\n\t\t};\n\t\trescaleToFitContrastTargets?: boolean;\n\t} = {}\n): RampResult {\n\tlet seed: PlainColorObject;\n\ttry {\n\t\tseed = clampToGamut( seedArg );\n\t} catch ( error ) {\n\t\tthrow new Error(\n\t\t\t`Invalid seed color \"${ seedArg }\": ${\n\t\t\t\terror instanceof Error ? error.message : 'Unknown error'\n\t\t\t}`\n\t\t);\n\t}\n\n\tlet mainDir: RampDirection = 'lighter';\n\tlet oppDir: RampDirection = 'darker';\n\n\tif ( mainDirection ) {\n\t\tmainDir = mainDirection;\n\t\toppDir = mainDirection === 'darker' ? 'lighter' : 'darker';\n\t} else {\n\t\tconst { better, worse } = computeBetterFgColorDirection( seed );\n\t\tmainDir = better;\n\t\toppDir = worse;\n\t}\n\n\t// Get the correct calculation order based on dependencies\n\tconst sortedSteps = sortByDependency( config );\n\n\t// Calculate the ramp with the initial seed.\n\tconst {\n\t\trampResults,\n\t\twarnings,\n\t\tmaxDeficit,\n\t\tmaxDeficitDirection,\n\t\tmaxDeficitStep,\n\t} = calculateRamp( {\n\t\tseed,\n\t\tsortedSteps,\n\t\tconfig,\n\t\tmainDir,\n\t\toppDir,\n\t\tpinLightness,\n\t} );\n\n\tlet bestRamp = rampResults;\n\n\tif ( maxDeficit > CONTRAST_EPSILON && rescaleToFitContrastTargets ) {\n\t\tconst iterSteps = stepsForStep( maxDeficitStep!, config );\n\n\t\tfunction getSeedForL( l: number ): PlainColorObject {\n\t\t\treturn clampToGamut( set( clone( seed ), [ OKLCH, 'l' ], l ) );\n\t\t}\n\n\t\tfunction getDeficitForSeed( s: PlainColorObject ): number {\n\t\t\tconst iterationResults = calculateRamp( {\n\t\t\t\tseed: s,\n\t\t\t\tsortedSteps: iterSteps,\n\t\t\t\tconfig,\n\t\t\t\tmainDir,\n\t\t\t\toppDir,\n\t\t\t\tpinLightness,\n\t\t\t} );\n\n\t\t\t// If the constraints start failing in the opposite direction to the original\n\t\t\t// iteration's direction, that means we've moved too far away from the target.\n\t\t\t// Don't use the `maxDeficit` value because it's not related to our search,\n\t\t\t// and might even be positive, which would confuse the bisection algorithm.\n\t\t\treturn iterationResults.maxDeficitDirection === maxDeficitDirection\n\t\t\t\t? iterationResults.maxDeficit\n\t\t\t\t: -maxDeficit;\n\t\t}\n\n\t\t// For a scale with the \"lighter\" direction, the contrast can be improved\n\t\t// by darkening the seed. For \"darker\" direction, by lightening the seed.\n\t\tconst lowerSeedL = maxDeficitDirection === 'lighter' ? 0 : 1;\n\t\tconst lowerDeficit = -maxDeficit;\n\t\tconst upperSeedL = get( seed, [ OKLCH, 'l' ] );\n\t\tconst upperDeficit = maxDeficit;\n\n\t\tconst bestSeed = solveWithBisect(\n\t\t\tgetSeedForL,\n\t\t\tgetDeficitForSeed,\n\t\t\tlowerSeedL,\n\t\t\tlowerDeficit,\n\t\t\tupperSeedL,\n\t\t\tupperDeficit\n\t\t);\n\n\t\t// Calculate the final ramp with adjusted seed.\n\t\tbestRamp = calculateRamp( {\n\t\t\tseed: bestSeed,\n\t\t\tsortedSteps,\n\t\t\tconfig,\n\t\t\tmainDir,\n\t\t\toppDir,\n\t\t\tpinLightness,\n\t\t} ).rampResults;\n\t}\n\n\t// Swap surface1 and surface3 for darker ramps to maintain visual elevation hierarchy.\n\t// This ensures surface1 appears \"behind\" surface2, and surface3 appears \"in front\",\n\t// regardless of the ramp's main direction.\n\tif ( mainDir === 'darker' ) {\n\t\tconst tmpSurface1 = bestRamp.surface1;\n\t\tbestRamp.surface1 = bestRamp.surface3;\n\t\tbestRamp.surface3 = tmpSurface1;\n\t}\n\n\treturn {\n\t\tramp: bestRamp,\n\t\twarnings,\n\t\tdirection: mainDir,\n\t};\n}\n", "/**\n * Internal dependencies\n */\nimport type { RampStepConfig, RampConfig, RampDirection } from './types';\nimport type { TaperChromaOptions } from './taper-chroma';\n\nconst lightnessConstraintForegroundHighContrast = (\n\tdirection: RampDirection\n) =>\n\tdirection === 'lighter'\n\t\t? 0.9551 // lightness of #f0f0f0 (ie $gray-100)\n\t\t: 0.235; // lightness of #1e1e1e (ie $gray-900)\nconst lightnessConstraintForegroundMediumContrast = (\n\tdirection: RampDirection\n) =>\n\tdirection === 'lighter'\n\t\t? 0.77 // lightness of #b4b4b4\n\t\t: 0.56; // lightness of #747474\nconst lightnessConstraintBgFill = ( direction: RampDirection ) =>\n\tdirection === 'lighter'\n\t\t? 0.67 // lightness of #969696 (7:1 vs black)\n\t\t: 0.45; // lightness of #555555 (7:1 vs white)\n\nconst BG_SURFACE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.7,\n};\nconst FG_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.6,\n\tkLight: 0.2,\n\tkDark: 0.2,\n};\nconst STROKE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.6,\n\tradiusDark: 0.01,\n\tradiusLight: 0.01,\n\tkLight: 0.8,\n\tkDark: 0.8,\n};\nconst ACCENT_SURFACE_TAPER_CHROMA: TaperChromaOptions = {\n\talpha: 0.75,\n\tradiusDark: 0.01,\n\tradiusLight: 0.01,\n};\n\nconst fgSurface4Config: RampStepConfig = {\n\tcontrast: {\n\t\treference: 'surface3',\n\t\tfollowDirection: 'main',\n\t\ttarget: 7,\n\t\tpreferLighter: true,\n\t},\n\tlightness: lightnessConstraintForegroundHighContrast,\n\ttaperChromaOptions: FG_TAPER_CHROMA,\n};\n\nexport const BG_RAMP_CONFIG: RampConfig = {\n\t// Surface\n\tsurface1: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 1.06,\n\t\t\tignoreWhenAdjustingSeed: true,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface2: {\n\t\tcontrast: {\n\t\t\treference: 'seed',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1,\n\t\t},\n\t},\n\tsurface3: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.06,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface4: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.12,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface5: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.2,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface6: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.4,\n\t\t},\n\t\ttaperChromaOptions: BG_SURFACE_TAPER_CHROMA,\n\t},\n\t// Bg fill\n\tbgFill1: {\n\t\tcontrast: {\n\t\t\treference: 'surface2',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 4,\n\t\t},\n\t\tlightness: lightnessConstraintBgFill,\n\t},\n\tbgFill2: {\n\t\tcontrast: {\n\t\t\treference: 'bgFill1',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.2,\n\t\t},\n\t},\n\tbgFillInverted1: {\n\t\tcontrast: {\n\t\t\treference: 'bgFillInverted2',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 1.2,\n\t\t},\n\t},\n\tbgFillInverted2: fgSurface4Config,\n\tbgFillDark: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'darker', // This is what causes the token to be always dark\n\t\t\ttarget: 7,\n\t\t\tignoreWhenAdjustingSeed: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\t// Stroke\n\tstroke1: {\n\t\tcontrast: {\n\t\t\treference: 'stroke3',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 2.6,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\tstroke2: {\n\t\tcontrast: {\n\t\t\treference: 'stroke3',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: 2.4,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\tstroke3: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 3,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\tstroke4: {\n\t\tcontrast: {\n\t\t\treference: 'stroke3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1.5,\n\t\t},\n\t\ttaperChromaOptions: STROKE_TAPER_CHROMA,\n\t},\n\t// fgSurface\n\tfgSurface1: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 2,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgSurface2: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 3,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgSurface3: {\n\t\tcontrast: {\n\t\t\treference: 'surface3',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundMediumContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgSurface4: fgSurface4Config,\n\t// fgFill\n\tfgFill: {\n\t\tcontrast: {\n\t\t\treference: 'bgFill1',\n\t\t\tfollowDirection: 'best',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgFillInverted: {\n\t\tcontrast: {\n\t\t\treference: 'bgFillInverted1',\n\t\t\tfollowDirection: 'best',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n\tfgFillDark: {\n\t\tcontrast: {\n\t\t\treference: 'bgFillDark',\n\t\t\tfollowDirection: 'best',\n\t\t\ttarget: 4.5,\n\t\t\tpreferLighter: true,\n\t\t},\n\t\tlightness: lightnessConstraintForegroundHighContrast,\n\t\ttaperChromaOptions: FG_TAPER_CHROMA,\n\t},\n};\n\n// BG_RAMP: seed => surface2 => {bgFill, surface3 => all other tokens}\n// ACCENT_RAMP: seed => bgFill1 => surface2 => surface3 => all other tokens\nexport const ACCENT_RAMP_CONFIG: RampConfig = {\n\t...BG_RAMP_CONFIG,\n\tsurface1: {\n\t\t...BG_RAMP_CONFIG.surface1,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface2: {\n\t\tcontrast: {\n\t\t\treference: 'bgFill1',\n\t\t\tfollowDirection: 'opposite',\n\t\t\ttarget: BG_RAMP_CONFIG.bgFill1.contrast.target,\n\t\t\tignoreWhenAdjustingSeed: true,\n\t\t},\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface3: {\n\t\t...BG_RAMP_CONFIG.surface3,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface4: {\n\t\t...BG_RAMP_CONFIG.surface4,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface5: {\n\t\t...BG_RAMP_CONFIG.surface5,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tsurface6: {\n\t\t...BG_RAMP_CONFIG.surface6,\n\t\ttaperChromaOptions: ACCENT_SURFACE_TAPER_CHROMA,\n\t},\n\tbgFill1: {\n\t\tcontrast: {\n\t\t\treference: 'seed',\n\t\t\tfollowDirection: 'main',\n\t\t\ttarget: 1,\n\t\t},\n\t},\n\tstroke1: {\n\t\t...BG_RAMP_CONFIG.stroke1,\n\t},\n\tstroke2: {\n\t\t...BG_RAMP_CONFIG.stroke2,\n\t},\n\tstroke3: {\n\t\t...BG_RAMP_CONFIG.stroke3,\n\t\tsameAsIfPossible: 'fgSurface3',\n\t\ttaperChromaOptions: undefined,\n\t},\n\tstroke4: {\n\t\t...BG_RAMP_CONFIG.stroke4,\n\t\ttaperChromaOptions: undefined,\n\t},\n\t// fgSurface: do not de-saturate\n\tfgSurface1: {\n\t\t...BG_RAMP_CONFIG.fgSurface1,\n\t\ttaperChromaOptions: undefined,\n\t},\n\tfgSurface2: {\n\t\t...BG_RAMP_CONFIG.fgSurface2,\n\t\ttaperChromaOptions: undefined,\n\t},\n\tfgSurface3: {\n\t\t...BG_RAMP_CONFIG.fgSurface3,\n\t\ttaperChromaOptions: undefined,\n\t\tsameAsIfPossible: 'bgFill1',\n\t},\n\tfgSurface4: {\n\t\t...BG_RAMP_CONFIG.fgSurface4,\n\t\ttaperChromaOptions: undefined,\n\t},\n};\n", "/**\n * External dependencies\n */\nimport { get, OKLCH } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './lib/register-color-spaces';\nimport { buildRamp } from './lib/index';\nimport { clampAccentScaleReferenceLightness } from './lib/utils';\nimport { BG_RAMP_CONFIG, ACCENT_RAMP_CONFIG } from './lib/ramp-configs';\nimport type {\n\tRampResult as InternalRampResult,\n\tRampDirection,\n\tRamp,\n} from './lib/types';\nimport { getContrast } from './lib/color-utils';\nimport { CONTRAST_COMBINATIONS } from './lib/constants';\nexport { DEFAULT_SEED_COLORS } from './lib/constants';\n\n/**\n * Creates a background ramp.\n * @param seed The seed color for the background ramp.\n */\nexport function buildBgRamp( seed: string ) {\n\tif ( typeof seed !== 'string' || seed.trim() === '' ) {\n\t\tthrow new Error( 'Seed color must be a non-empty string' );\n\t}\n\n\treturn buildRamp( seed, BG_RAMP_CONFIG );\n}\n\nconst STEP_TO_PIN = 'surface2';\nfunction getBgRampInfo( ramp: InternalRampResult ): {\n\tmainDirection: RampDirection;\n\tpinLightness: {\n\t\tstepName: keyof Ramp;\n\t\tvalue: number;\n\t};\n} {\n\treturn {\n\t\tmainDirection: ramp.direction,\n\t\tpinLightness: {\n\t\t\tstepName: STEP_TO_PIN,\n\t\t\tvalue: clampAccentScaleReferenceLightness(\n\t\t\t\tget( ramp.ramp[ STEP_TO_PIN ], [ OKLCH, 'l' ] ),\n\t\t\t\tramp.direction\n\t\t\t),\n\t\t},\n\t};\n}\n\n/**\n * Creates an accent ramp (ie used by primary, success, info, warning and error\n * ramps).\n * @param seed   The seed color for the accent ramp.\n * @param bgRamp The ramp of the background on which the accent is shown.\n */\nexport function buildAccentRamp(\n\tseed: string,\n\tbgRamp?: InternalRampResult\n): InternalRampResult {\n\tif ( typeof seed !== 'string' || seed.trim() === '' ) {\n\t\tthrow new Error( 'Seed color must be a non-empty string' );\n\t}\n\n\tconst bgRampInfo = bgRamp ? getBgRampInfo( bgRamp ) : undefined;\n\treturn buildRamp( seed, ACCENT_RAMP_CONFIG, bgRampInfo );\n}\n\n/**\n * Checks that all bg/fg combinations generated by the ramps meet contrast\n * targets.\n * @param params\n * @param params.bgRamp\n * @param params.accentRamps\n */\nexport function checkAccessibleCombinations( {\n\tbgRamp,\n\taccentRamps = [],\n}: {\n\tbgRamp: InternalRampResult;\n\taccentRamps?: InternalRampResult[];\n} ) {\n\tconst unmetTargets: {\n\t\tbgName: keyof Ramp;\n\t\tbgColor: string;\n\t\tfgName: keyof Ramp;\n\t\tfgColor: string;\n\t\tunmetContrast: number;\n\t\tachievedContrast: number;\n\t}[] = [];\n\n\t// Assess combinations within each ramp\n\t[ bgRamp, ...accentRamps ].forEach( ( ramp ) => {\n\t\tCONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {\n\t\t\tfor ( const bg of bgs ) {\n\t\t\t\tfor ( const fg of fgs ) {\n\t\t\t\t\tconst bgColor = ramp.ramp[ bg ];\n\t\t\t\t\tconst fgColor = ramp.ramp[ fg ];\n\t\t\t\t\tconst achievedContrast = getContrast( bgColor, fgColor );\n\t\t\t\t\tif ( achievedContrast < target ) {\n\t\t\t\t\t\tunmetTargets.push( {\n\t\t\t\t\t\t\tbgName: bg,\n\t\t\t\t\t\t\tbgColor,\n\t\t\t\t\t\t\tfgName: fg,\n\t\t\t\t\t\t\tfgColor,\n\t\t\t\t\t\t\tunmetContrast: target,\n\t\t\t\t\t\t\tachievedContrast,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n\t// Assess each accent ramp's fg color against bg ramp\n\taccentRamps.forEach( ( ramp ) => {\n\t\tCONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {\n\t\t\tfor ( const bg of bgs ) {\n\t\t\t\tfor ( const fg of fgs ) {\n\t\t\t\t\tconst bgColor = bgRamp.ramp[ bg ];\n\t\t\t\t\tconst fgColor = ramp.ramp[ fg ];\n\t\t\t\t\tconst achievedContrast = getContrast( bgColor, fgColor );\n\t\t\t\t\tif ( achievedContrast < target ) {\n\t\t\t\t\t\tunmetTargets.push( {\n\t\t\t\t\t\t\tbgName: bg,\n\t\t\t\t\t\t\tbgColor,\n\t\t\t\t\t\t\tfgName: fg,\n\t\t\t\t\t\t\tfgColor,\n\t\t\t\t\t\t\tunmetContrast: target,\n\t\t\t\t\t\t\tachievedContrast,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n\n\treturn unmetTargets;\n}\n\nexport type RampResult = InternalRampResult;\n", "/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport { ThemeProvider } from './theme-provider';\nimport { useThemeProviderStyles } from './use-theme-provider-styles';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tThemeProvider,\n\tuseThemeProviderStyles,\n} );\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,aAAO,UAAU,OAAO,GAAG;AAAA;AAAA;;;ACA3B;AAAA;AAAA,aAAO,UAAU,OAAO,GAAG;AAAA;AAAA;;;ACA3B;AAAA;AAAA,aAAO,UAAU,OAAO;AAAA;AAAA;A;;;;;;;;ACGxB,4BAAiE;AAE1D,MAAM,EAAE,MAAM,OAAO,QAC3B;IACC;IACA;EACD;;;ACDD,MAAAA,kBAA+B;;;AEL/B,uBAA8B;AAWvB,MAAM,mBAAe,8BAAmC;IAC9D,kBAAkB;MACjB,OAAO,CAAC;IACT;EACD,CAAE;;;ACgHF,WAAS,KAAM,GAAGC,IAAG;AACpB,WAAO,EAAE,CAAC,IAAIA,GAAE,CAAC,IAAI,EAAE,CAAC,IAAIA,GAAE,CAAC,IAAI,EAAE,CAAC,IAAIA,GAAE,CAAC;AAAA,EAC9C;AAWO,WAAS,iBAAkB,OAAO,QAAQ,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG;AACjE,UAAM,IAAI,KAAK,OAAO,OAAO,CAAC,CAAC;AAC/B,UAAM,IAAI,KAAK,OAAO,OAAO,CAAC,CAAC;AAC/B,UAAM,IAAI,KAAK,OAAO,OAAO,CAAC,CAAC;AAC/B,QAAI,CAAC,IAAI;AACT,QAAI,CAAC,IAAI;AACT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AiB,mBAAoB,CAAE,IAAA,CAClD,IACG;MACJ;QAAC;QAAA;UACA,+BAA8B;UAC9B,2BAA0B;UAC1B,qBAAoB;UACpB,WAAY,cAAO;UAEnB,UAAA,4CAAC,aAAa,UAAb,EAAsB,OAAQ,cAC5B,SAAA,CACH;QAAA;MACD;IAAA,EAAA,CACD;EAEF;;;AkEjFO,MAAM,cAAc,CAAC;AAC5B,OAAM,aAAa;IAClB;IACA;EACD,CAAE;",
  "names": ["import_element", "b", "n", "n", "p", "to", "d", "type", "type", "name", "white", "coords", "options", "p", "\u03B5", "b", "b", "\u03B5", "c1", "c2", "\u03C0", "d2r", "c1", "c2", "c3", "XYZtoLMS_M", "LMStoXYZ_M", "white", "m1", "adapt", "d", "b", "white", "\u03B5", "\u03BA", "viewingConditions", "rad2deg", "deg2rad", "viewingConditions", "b", "\u03B5", "clipped", "white", "min", "max", "inGamut", "inGamut", "toXYZ_M", "fromXYZ_M", "g", "b", "d", "n", "import_element", "d", "u", "w", "c1", "c2", "adjustedTarget", "n"]
}