@dilemmagx/palette 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../node_modules/sharp/lib/is.js", "../node_modules/detect-libc/lib/process.js", "../node_modules/detect-libc/lib/filesystem.js", "../node_modules/detect-libc/lib/elf.js", "../node_modules/detect-libc/lib/detect-libc.js", "../node_modules/semver/internal/debug.js", "../node_modules/semver/internal/constants.js", "../node_modules/semver/internal/re.js", "../node_modules/semver/internal/parse-options.js", "../node_modules/semver/internal/identifiers.js", "../node_modules/semver/classes/semver.js", "../node_modules/semver/functions/parse.js", "../node_modules/semver/functions/coerce.js", "../node_modules/semver/functions/compare.js", "../node_modules/semver/functions/gte.js", "../node_modules/semver/internal/lrucache.js", "../node_modules/semver/functions/eq.js", "../node_modules/semver/functions/neq.js", "../node_modules/semver/functions/gt.js", "../node_modules/semver/functions/lt.js", "../node_modules/semver/functions/lte.js", "../node_modules/semver/functions/cmp.js", "../node_modules/semver/classes/comparator.js", "../node_modules/semver/classes/range.js", "../node_modules/semver/functions/satisfies.js", "../node_modules/sharp/package.json", "../node_modules/sharp/lib/libvips.js", "../node_modules/sharp/lib/sharp.js", "../node_modules/sharp/lib/constructor.js", "../node_modules/sharp/lib/input.js", "../node_modules/sharp/lib/resize.js", "../node_modules/sharp/lib/composite.js", "../node_modules/sharp/lib/operation.js", "../node_modules/@img/colour/color.cjs", "../node_modules/@img/colour/index.cjs", "../node_modules/sharp/lib/colour.js", "../node_modules/sharp/lib/channel.js", "../node_modules/sharp/lib/output.js", "../node_modules/sharp/lib/utility.js", "../node_modules/sharp/lib/index.js", "../src/index.ts", "../src/core.ts", "../node_modules/@material/material-color-utilities/utils/math_utils.ts", "../node_modules/@material/material-color-utilities/utils/color_utils.ts", "../node_modules/@material/material-color-utilities/hct/viewing_conditions.ts", "../node_modules/@material/material-color-utilities/hct/cam16.ts", "../node_modules/@material/material-color-utilities/hct/hct_solver.ts", "../node_modules/@material/material-color-utilities/hct/hct.ts", "../node_modules/@material/material-color-utilities/contrast/contrast.ts", "../node_modules/@material/material-color-utilities/dislike/dislike_analyzer.ts", "../node_modules/@material/material-color-utilities/dynamiccolor/dynamic_color.ts", "../node_modules/@material/material-color-utilities/palettes/tonal_palette.ts", "../node_modules/@material/material-color-utilities/dynamiccolor/contrast_curve.ts", "../node_modules/@material/material-color-utilities/dynamiccolor/tone_delta_pair.ts", "../node_modules/@material/material-color-utilities/dynamiccolor/variant.ts", "../node_modules/@material/material-color-utilities/dynamiccolor/material_dynamic_colors.ts", "../node_modules/@material/material-color-utilities/dynamiccolor/dynamic_scheme.ts", "../node_modules/@material/material-color-utilities/quantize/lab_point_provider.ts", "../node_modules/@material/material-color-utilities/quantize/quantizer_wsmeans.ts", "../node_modules/@material/material-color-utilities/quantize/quantizer_map.ts", "../node_modules/@material/material-color-utilities/quantize/quantizer_wu.ts", "../node_modules/@material/material-color-utilities/quantize/quantizer_celebi.ts", "../node_modules/@material/material-color-utilities/scheme/scheme_expressive.ts", "../node_modules/@material/material-color-utilities/scheme/scheme_vibrant.ts", "../node_modules/@material/material-color-utilities/score/score.ts", "../node_modules/@material/material-color-utilities/utils/string_utils.ts", "../src/presets.ts"],
4
- "sourcesContent": ["/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\n/**\n * Is this value defined and not null?\n * @private\n */\nconst defined = (val) => typeof val !== 'undefined' && val !== null;\n\n/**\n * Is this value an object?\n * @private\n */\nconst object = (val) => typeof val === 'object';\n\n/**\n * Is this value a plain object?\n * @private\n */\nconst plainObject = (val) => Object.prototype.toString.call(val) === '[object Object]';\n\n/**\n * Is this value a function?\n * @private\n */\nconst fn = (val) => typeof val === 'function';\n\n/**\n * Is this value a boolean?\n * @private\n */\nconst bool = (val) => typeof val === 'boolean';\n\n/**\n * Is this value a Buffer object?\n * @private\n */\nconst buffer = (val) => val instanceof Buffer;\n\n/**\n * Is this value a typed array object?. E.g. Uint8Array or Uint8ClampedArray?\n * @private\n */\nconst typedArray = (val) => {\n if (defined(val)) {\n switch (val.constructor) {\n case Uint8Array:\n case Uint8ClampedArray:\n case Int8Array:\n case Uint16Array:\n case Int16Array:\n case Uint32Array:\n case Int32Array:\n case Float32Array:\n case Float64Array:\n return true;\n }\n }\n\n return false;\n};\n\n/**\n * Is this value an ArrayBuffer object?\n * @private\n */\nconst arrayBuffer = (val) => val instanceof ArrayBuffer;\n\n/**\n * Is this value a non-empty string?\n * @private\n */\nconst string = (val) => typeof val === 'string' && val.length > 0;\n\n/**\n * Is this value a real number?\n * @private\n */\nconst number = (val) => typeof val === 'number' && !Number.isNaN(val);\n\n/**\n * Is this value an integer?\n * @private\n */\nconst integer = (val) => Number.isInteger(val);\n\n/**\n * Is this value within an inclusive given range?\n * @private\n */\nconst inRange = (val, min, max) => val >= min && val <= max;\n\n/**\n * Is this value within the elements of an array?\n * @private\n */\nconst inArray = (val, list) => list.includes(val);\n\n/**\n * Create an Error with a message relating to an invalid parameter.\n *\n * @param {string} name - parameter name.\n * @param {string} expected - description of the type/value/range expected.\n * @param {*} actual - the value received.\n * @returns {Error} Containing the formatted message.\n * @private\n */\nconst invalidParameterError = (name, expected, actual) => new Error(\n `Expected ${expected} for ${name} but received ${actual} of type ${typeof actual}`\n );\n\n/**\n * Ensures an Error from C++ contains a JS stack.\n *\n * @param {Error} native - Error with message from C++.\n * @param {Error} context - Error with stack from JS.\n * @returns {Error} Error with message and stack.\n * @private\n */\nconst nativeError = (native, context) => {\n context.message = native.message;\n return context;\n};\n\nmodule.exports = {\n defined,\n object,\n plainObject,\n fn,\n bool,\n buffer,\n typedArray,\n arrayBuffer,\n string,\n number,\n integer,\n inRange,\n inArray,\n invalidParameterError,\n nativeError\n};\n", "// Copyright 2017 Lovell Fuller and others.\n// SPDX-License-Identifier: Apache-2.0\n\n'use strict';\n\nconst isLinux = () => process.platform === 'linux';\n\nlet report = null;\nconst getReport = () => {\n if (!report) {\n /* istanbul ignore next */\n if (isLinux() && process.report) {\n const orig = process.report.excludeNetwork;\n process.report.excludeNetwork = true;\n report = process.report.getReport();\n process.report.excludeNetwork = orig;\n } else {\n report = {};\n }\n }\n return report;\n};\n\nmodule.exports = { isLinux, getReport };\n", "// Copyright 2017 Lovell Fuller and others.\n// SPDX-License-Identifier: Apache-2.0\n\n'use strict';\n\nconst fs = require('fs');\n\nconst LDD_PATH = '/usr/bin/ldd';\nconst SELF_PATH = '/proc/self/exe';\nconst MAX_LENGTH = 2048;\n\n/**\n * Read the content of a file synchronous\n *\n * @param {string} path\n * @returns {Buffer}\n */\nconst readFileSync = (path) => {\n const fd = fs.openSync(path, 'r');\n const buffer = Buffer.alloc(MAX_LENGTH);\n const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);\n fs.close(fd, () => {});\n return buffer.subarray(0, bytesRead);\n};\n\n/**\n * Read the content of a file\n *\n * @param {string} path\n * @returns {Promise<Buffer>}\n */\nconst readFile = (path) => new Promise((resolve, reject) => {\n fs.open(path, 'r', (err, fd) => {\n if (err) {\n reject(err);\n } else {\n const buffer = Buffer.alloc(MAX_LENGTH);\n fs.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {\n resolve(buffer.subarray(0, bytesRead));\n fs.close(fd, () => {});\n });\n }\n });\n});\n\nmodule.exports = {\n LDD_PATH,\n SELF_PATH,\n readFileSync,\n readFile\n};\n", "// Copyright 2017 Lovell Fuller and others.\n// SPDX-License-Identifier: Apache-2.0\n\n'use strict';\n\nconst interpreterPath = (elf) => {\n if (elf.length < 64) {\n return null;\n }\n if (elf.readUInt32BE(0) !== 0x7F454C46) {\n // Unexpected magic bytes\n return null;\n }\n if (elf.readUInt8(4) !== 2) {\n // Not a 64-bit ELF\n return null;\n }\n if (elf.readUInt8(5) !== 1) {\n // Not little-endian\n return null;\n }\n const offset = elf.readUInt32LE(32);\n const size = elf.readUInt16LE(54);\n const count = elf.readUInt16LE(56);\n for (let i = 0; i < count; i++) {\n const headerOffset = offset + (i * size);\n const type = elf.readUInt32LE(headerOffset);\n if (type === 3) {\n const fileOffset = elf.readUInt32LE(headerOffset + 8);\n const fileSize = elf.readUInt32LE(headerOffset + 32);\n return elf.subarray(fileOffset, fileOffset + fileSize).toString().replace(/\\0.*$/g, '');\n }\n }\n return null;\n};\n\nmodule.exports = {\n interpreterPath\n};\n", "// Copyright 2017 Lovell Fuller and others.\n// SPDX-License-Identifier: Apache-2.0\n\n'use strict';\n\nconst childProcess = require('child_process');\nconst { isLinux, getReport } = require('./process');\nconst { LDD_PATH, SELF_PATH, readFile, readFileSync } = require('./filesystem');\nconst { interpreterPath } = require('./elf');\n\nlet cachedFamilyInterpreter;\nlet cachedFamilyFilesystem;\nlet cachedVersionFilesystem;\n\nconst command = 'getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true';\nlet commandOut = '';\n\nconst safeCommand = () => {\n if (!commandOut) {\n return new Promise((resolve) => {\n childProcess.exec(command, (err, out) => {\n commandOut = err ? ' ' : out;\n resolve(commandOut);\n });\n });\n }\n return commandOut;\n};\n\nconst safeCommandSync = () => {\n if (!commandOut) {\n try {\n commandOut = childProcess.execSync(command, { encoding: 'utf8' });\n } catch (_err) {\n commandOut = ' ';\n }\n }\n return commandOut;\n};\n\n/**\n * A String constant containing the value `glibc`.\n * @type {string}\n * @public\n */\nconst GLIBC = 'glibc';\n\n/**\n * A Regexp constant to get the GLIBC Version.\n * @type {string}\n */\nconst RE_GLIBC_VERSION = /LIBC[a-z0-9 \\-).]*?(\\d+\\.\\d+)/i;\n\n/**\n * A String constant containing the value `musl`.\n * @type {string}\n * @public\n */\nconst MUSL = 'musl';\n\nconst isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-');\n\nconst familyFromReport = () => {\n const report = getReport();\n if (report.header && report.header.glibcVersionRuntime) {\n return GLIBC;\n }\n if (Array.isArray(report.sharedObjects)) {\n if (report.sharedObjects.some(isFileMusl)) {\n return MUSL;\n }\n }\n return null;\n};\n\nconst familyFromCommand = (out) => {\n const [getconf, ldd1] = out.split(/[\\r\\n]+/);\n if (getconf && getconf.includes(GLIBC)) {\n return GLIBC;\n }\n if (ldd1 && ldd1.includes(MUSL)) {\n return MUSL;\n }\n return null;\n};\n\nconst familyFromInterpreterPath = (path) => {\n if (path) {\n if (path.includes('/ld-musl-')) {\n return MUSL;\n } else if (path.includes('/ld-linux-')) {\n return GLIBC;\n }\n }\n return null;\n};\n\nconst getFamilyFromLddContent = (content) => {\n content = content.toString();\n if (content.includes('musl')) {\n return MUSL;\n }\n if (content.includes('GNU C Library')) {\n return GLIBC;\n }\n return null;\n};\n\nconst familyFromFilesystem = async () => {\n if (cachedFamilyFilesystem !== undefined) {\n return cachedFamilyFilesystem;\n }\n cachedFamilyFilesystem = null;\n try {\n const lddContent = await readFile(LDD_PATH);\n cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);\n } catch (e) {}\n return cachedFamilyFilesystem;\n};\n\nconst familyFromFilesystemSync = () => {\n if (cachedFamilyFilesystem !== undefined) {\n return cachedFamilyFilesystem;\n }\n cachedFamilyFilesystem = null;\n try {\n const lddContent = readFileSync(LDD_PATH);\n cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);\n } catch (e) {}\n return cachedFamilyFilesystem;\n};\n\nconst familyFromInterpreter = async () => {\n if (cachedFamilyInterpreter !== undefined) {\n return cachedFamilyInterpreter;\n }\n cachedFamilyInterpreter = null;\n try {\n const selfContent = await readFile(SELF_PATH);\n const path = interpreterPath(selfContent);\n cachedFamilyInterpreter = familyFromInterpreterPath(path);\n } catch (e) {}\n return cachedFamilyInterpreter;\n};\n\nconst familyFromInterpreterSync = () => {\n if (cachedFamilyInterpreter !== undefined) {\n return cachedFamilyInterpreter;\n }\n cachedFamilyInterpreter = null;\n try {\n const selfContent = readFileSync(SELF_PATH);\n const path = interpreterPath(selfContent);\n cachedFamilyInterpreter = familyFromInterpreterPath(path);\n } catch (e) {}\n return cachedFamilyInterpreter;\n};\n\n/**\n * Resolves with the libc family when it can be determined, `null` otherwise.\n * @returns {Promise<?string>}\n */\nconst family = async () => {\n let family = null;\n if (isLinux()) {\n family = await familyFromInterpreter();\n if (!family) {\n family = await familyFromFilesystem();\n if (!family) {\n family = familyFromReport();\n }\n if (!family) {\n const out = await safeCommand();\n family = familyFromCommand(out);\n }\n }\n }\n return family;\n};\n\n/**\n * Returns the libc family when it can be determined, `null` otherwise.\n * @returns {?string}\n */\nconst familySync = () => {\n let family = null;\n if (isLinux()) {\n family = familyFromInterpreterSync();\n if (!family) {\n family = familyFromFilesystemSync();\n if (!family) {\n family = familyFromReport();\n }\n if (!family) {\n const out = safeCommandSync();\n family = familyFromCommand(out);\n }\n }\n }\n return family;\n};\n\n/**\n * Resolves `true` only when the platform is Linux and the libc family is not `glibc`.\n * @returns {Promise<boolean>}\n */\nconst isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;\n\n/**\n * Returns `true` only when the platform is Linux and the libc family is not `glibc`.\n * @returns {boolean}\n */\nconst isNonGlibcLinuxSync = () => isLinux() && familySync() !== GLIBC;\n\nconst versionFromFilesystem = async () => {\n if (cachedVersionFilesystem !== undefined) {\n return cachedVersionFilesystem;\n }\n cachedVersionFilesystem = null;\n try {\n const lddContent = await readFile(LDD_PATH);\n const versionMatch = lddContent.match(RE_GLIBC_VERSION);\n if (versionMatch) {\n cachedVersionFilesystem = versionMatch[1];\n }\n } catch (e) {}\n return cachedVersionFilesystem;\n};\n\nconst versionFromFilesystemSync = () => {\n if (cachedVersionFilesystem !== undefined) {\n return cachedVersionFilesystem;\n }\n cachedVersionFilesystem = null;\n try {\n const lddContent = readFileSync(LDD_PATH);\n const versionMatch = lddContent.match(RE_GLIBC_VERSION);\n if (versionMatch) {\n cachedVersionFilesystem = versionMatch[1];\n }\n } catch (e) {}\n return cachedVersionFilesystem;\n};\n\nconst versionFromReport = () => {\n const report = getReport();\n if (report.header && report.header.glibcVersionRuntime) {\n return report.header.glibcVersionRuntime;\n }\n return null;\n};\n\nconst versionSuffix = (s) => s.trim().split(/\\s+/)[1];\n\nconst versionFromCommand = (out) => {\n const [getconf, ldd1, ldd2] = out.split(/[\\r\\n]+/);\n if (getconf && getconf.includes(GLIBC)) {\n return versionSuffix(getconf);\n }\n if (ldd1 && ldd2 && ldd1.includes(MUSL)) {\n return versionSuffix(ldd2);\n }\n return null;\n};\n\n/**\n * Resolves with the libc version when it can be determined, `null` otherwise.\n * @returns {Promise<?string>}\n */\nconst version = async () => {\n let version = null;\n if (isLinux()) {\n version = await versionFromFilesystem();\n if (!version) {\n version = versionFromReport();\n }\n if (!version) {\n const out = await safeCommand();\n version = versionFromCommand(out);\n }\n }\n return version;\n};\n\n/**\n * Returns the libc version when it can be determined, `null` otherwise.\n * @returns {?string}\n */\nconst versionSync = () => {\n let version = null;\n if (isLinux()) {\n version = versionFromFilesystemSync();\n if (!version) {\n version = versionFromReport();\n }\n if (!version) {\n const out = safeCommandSync();\n version = versionFromCommand(out);\n }\n }\n return version;\n};\n\nmodule.exports = {\n GLIBC,\n MUSL,\n family,\n familySync,\n isNonGlibcLinux,\n isNonGlibcLinuxSync,\n version,\n versionSync\n};\n", "'use strict'\n\nconst debug = (\n typeof process === 'object' &&\n process.env &&\n process.env.NODE_DEBUG &&\n /\\bsemver\\b/i.test(process.env.NODE_DEBUG)\n) ? (...args) => console.error('SEMVER', ...args)\n : () => {}\n\nmodule.exports = debug\n", "'use strict'\n\n// Note: this is the semver.org version of the spec that it implements\n// Not necessarily the package version of this code.\nconst SEMVER_SPEC_VERSION = '2.0.0'\n\nconst MAX_LENGTH = 256\nconst MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||\n/* istanbul ignore next */ 9007199254740991\n\n// Max safe segment length for coercion.\nconst MAX_SAFE_COMPONENT_LENGTH = 16\n\n// Max safe length for a build identifier. The max length minus 6 characters for\n// the shortest version with a build 0.0.0+BUILD.\nconst MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6\n\nconst RELEASE_TYPES = [\n 'major',\n 'premajor',\n 'minor',\n 'preminor',\n 'patch',\n 'prepatch',\n 'prerelease',\n]\n\nmodule.exports = {\n MAX_LENGTH,\n MAX_SAFE_COMPONENT_LENGTH,\n MAX_SAFE_BUILD_LENGTH,\n MAX_SAFE_INTEGER,\n RELEASE_TYPES,\n SEMVER_SPEC_VERSION,\n FLAG_INCLUDE_PRERELEASE: 0b001,\n FLAG_LOOSE: 0b010,\n}\n", "'use strict'\n\nconst {\n MAX_SAFE_COMPONENT_LENGTH,\n MAX_SAFE_BUILD_LENGTH,\n MAX_LENGTH,\n} = require('./constants')\nconst debug = require('./debug')\nexports = module.exports = {}\n\n// The actual regexps go on exports.re\nconst re = exports.re = []\nconst safeRe = exports.safeRe = []\nconst src = exports.src = []\nconst safeSrc = exports.safeSrc = []\nconst t = exports.t = {}\nlet R = 0\n\nconst LETTERDASHNUMBER = '[a-zA-Z0-9-]'\n\n// Replace some greedy regex tokens to prevent regex dos issues. These regex are\n// used internally via the safeRe object since all inputs in this library get\n// normalized first to trim and collapse all extra whitespace. The original\n// regexes are exported for userland consumption and lower level usage. A\n// future breaking change could export the safer regex only with a note that\n// all input should have extra whitespace removed.\nconst safeRegexReplacements = [\n ['\\\\s', 1],\n ['\\\\d', MAX_LENGTH],\n [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],\n]\n\nconst makeSafeRegex = (value) => {\n for (const [token, max] of safeRegexReplacements) {\n value = value\n .split(`${token}*`).join(`${token}{0,${max}}`)\n .split(`${token}+`).join(`${token}{1,${max}}`)\n }\n return value\n}\n\nconst createToken = (name, value, isGlobal) => {\n const safe = makeSafeRegex(value)\n const index = R++\n debug(name, index, value)\n t[name] = index\n src[index] = value\n safeSrc[index] = safe\n re[index] = new RegExp(value, isGlobal ? 'g' : undefined)\n safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)\n}\n\n// The following Regular Expressions can be used for tokenizing,\n// validating, and parsing SemVer version strings.\n\n// ## Numeric Identifier\n// A single `0`, or a non-zero digit followed by zero or more digits.\n\ncreateToken('NUMERICIDENTIFIER', '0|[1-9]\\\\d*')\ncreateToken('NUMERICIDENTIFIERLOOSE', '\\\\d+')\n\n// ## Non-numeric Identifier\n// Zero or more digits, followed by a letter or hyphen, and then zero or\n// more letters, digits, or hyphens.\n\ncreateToken('NONNUMERICIDENTIFIER', `\\\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`)\n\n// ## Main Version\n// Three dot-separated numeric identifiers.\n\ncreateToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIER]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIER]})`)\n\ncreateToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIERLOOSE]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIERLOOSE]})`)\n\n// ## Pre-release Version Identifier\n// A numeric identifier, or a non-numeric identifier.\n// Non-numeric identifiers include numeric identifiers but can be longer.\n// Therefore non-numeric identifiers must go first.\n\ncreateToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]\n}|${src[t.NUMERICIDENTIFIER]})`)\n\ncreateToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]\n}|${src[t.NUMERICIDENTIFIERLOOSE]})`)\n\n// ## Pre-release Version\n// Hyphen, followed by one or more dot-separated pre-release version\n// identifiers.\n\ncreateToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]\n}(?:\\\\.${src[t.PRERELEASEIDENTIFIER]})*))`)\n\ncreateToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]\n}(?:\\\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`)\n\n// ## Build Metadata Identifier\n// Any combination of digits, letters, or hyphens.\n\ncreateToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`)\n\n// ## Build Metadata\n// Plus sign, followed by one or more period-separated build metadata\n// identifiers.\n\ncreateToken('BUILD', `(?:\\\\+(${src[t.BUILDIDENTIFIER]\n}(?:\\\\.${src[t.BUILDIDENTIFIER]})*))`)\n\n// ## Full Version String\n// A main version, followed optionally by a pre-release version and\n// build metadata.\n\n// Note that the only major, minor, patch, and pre-release sections of\n// the version string are capturing groups. The build metadata is not a\n// capturing group, because it should not ever be used in version\n// comparison.\n\ncreateToken('FULLPLAIN', `v?${src[t.MAINVERSION]\n}${src[t.PRERELEASE]}?${\n src[t.BUILD]}?`)\n\ncreateToken('FULL', `^${src[t.FULLPLAIN]}$`)\n\n// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.\n// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty\n// common in the npm registry.\ncreateToken('LOOSEPLAIN', `[v=\\\\s]*${src[t.MAINVERSIONLOOSE]\n}${src[t.PRERELEASELOOSE]}?${\n src[t.BUILD]}?`)\n\ncreateToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)\n\ncreateToken('GTLT', '((?:<|>)?=?)')\n\n// Something like \"2.*\" or \"1.2.x\".\n// Note that \"x.x\" is a valid xRange identifer, meaning \"any version\"\n// Only the first item is strictly required.\ncreateToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\\\*`)\ncreateToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\\\*`)\n\ncreateToken('XRANGEPLAIN', `[v=\\\\s]*(${src[t.XRANGEIDENTIFIER]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIER]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIER]})` +\n `(?:${src[t.PRERELEASE]})?${\n src[t.BUILD]}?` +\n `)?)?`)\n\ncreateToken('XRANGEPLAINLOOSE', `[v=\\\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:${src[t.PRERELEASELOOSE]})?${\n src[t.BUILD]}?` +\n `)?)?`)\n\ncreateToken('XRANGE', `^${src[t.GTLT]}\\\\s*${src[t.XRANGEPLAIN]}$`)\ncreateToken('XRANGELOOSE', `^${src[t.GTLT]}\\\\s*${src[t.XRANGEPLAINLOOSE]}$`)\n\n// Coercion.\n// Extract anything that could conceivably be a part of a valid semver\ncreateToken('COERCEPLAIN', `${'(^|[^\\\\d])' +\n '(\\\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +\n `(?:\\\\.(\\\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +\n `(?:\\\\.(\\\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`)\ncreateToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\\\d])`)\ncreateToken('COERCEFULL', src[t.COERCEPLAIN] +\n `(?:${src[t.PRERELEASE]})?` +\n `(?:${src[t.BUILD]})?` +\n `(?:$|[^\\\\d])`)\ncreateToken('COERCERTL', src[t.COERCE], true)\ncreateToken('COERCERTLFULL', src[t.COERCEFULL], true)\n\n// Tilde ranges.\n// Meaning is \"reasonably at or greater than\"\ncreateToken('LONETILDE', '(?:~>?)')\n\ncreateToken('TILDETRIM', `(\\\\s*)${src[t.LONETILDE]}\\\\s+`, true)\nexports.tildeTrimReplace = '$1~'\n\ncreateToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`)\ncreateToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`)\n\n// Caret ranges.\n// Meaning is \"at least and backwards compatible with\"\ncreateToken('LONECARET', '(?:\\\\^)')\n\ncreateToken('CARETTRIM', `(\\\\s*)${src[t.LONECARET]}\\\\s+`, true)\nexports.caretTrimReplace = '$1^'\n\ncreateToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`)\ncreateToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`)\n\n// A simple gt/lt/eq thing, or just \"\" to indicate \"any version\"\ncreateToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\\\s*(${src[t.LOOSEPLAIN]})$|^$`)\ncreateToken('COMPARATOR', `^${src[t.GTLT]}\\\\s*(${src[t.FULLPLAIN]})$|^$`)\n\n// An expression to strip any whitespace between the gtlt and the thing\n// it modifies, so that `> 1.2.3` ==> `>1.2.3`\ncreateToken('COMPARATORTRIM', `(\\\\s*)${src[t.GTLT]\n}\\\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true)\nexports.comparatorTrimReplace = '$1$2$3'\n\n// Something like `1.2.3 - 1.2.4`\n// Note that these all use the loose form, because they'll be\n// checked against either the strict or loose comparator form\n// later.\ncreateToken('HYPHENRANGE', `^\\\\s*(${src[t.XRANGEPLAIN]})` +\n `\\\\s+-\\\\s+` +\n `(${src[t.XRANGEPLAIN]})` +\n `\\\\s*$`)\n\ncreateToken('HYPHENRANGELOOSE', `^\\\\s*(${src[t.XRANGEPLAINLOOSE]})` +\n `\\\\s+-\\\\s+` +\n `(${src[t.XRANGEPLAINLOOSE]})` +\n `\\\\s*$`)\n\n// Star ranges basically just allow anything at all.\ncreateToken('STAR', '(<|>)?=?\\\\s*\\\\*')\n// >=0.0.0 is like a star\ncreateToken('GTE0', '^\\\\s*>=\\\\s*0\\\\.0\\\\.0\\\\s*$')\ncreateToken('GTE0PRE', '^\\\\s*>=\\\\s*0\\\\.0\\\\.0-0\\\\s*$')\n", "'use strict'\n\n// parse out just the options we care about\nconst looseOption = Object.freeze({ loose: true })\nconst emptyOpts = Object.freeze({ })\nconst parseOptions = options => {\n if (!options) {\n return emptyOpts\n }\n\n if (typeof options !== 'object') {\n return looseOption\n }\n\n return options\n}\nmodule.exports = parseOptions\n", "'use strict'\n\nconst numeric = /^[0-9]+$/\nconst compareIdentifiers = (a, b) => {\n if (typeof a === 'number' && typeof b === 'number') {\n return a === b ? 0 : a < b ? -1 : 1\n }\n\n const anum = numeric.test(a)\n const bnum = numeric.test(b)\n\n if (anum && bnum) {\n a = +a\n b = +b\n }\n\n return a === b ? 0\n : (anum && !bnum) ? -1\n : (bnum && !anum) ? 1\n : a < b ? -1\n : 1\n}\n\nconst rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)\n\nmodule.exports = {\n compareIdentifiers,\n rcompareIdentifiers,\n}\n", "'use strict'\n\nconst debug = require('../internal/debug')\nconst { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')\nconst { safeRe: re, t } = require('../internal/re')\n\nconst parseOptions = require('../internal/parse-options')\nconst { compareIdentifiers } = require('../internal/identifiers')\nclass SemVer {\n constructor (version, options) {\n options = parseOptions(options)\n\n if (version instanceof SemVer) {\n if (version.loose === !!options.loose &&\n version.includePrerelease === !!options.includePrerelease) {\n return version\n } else {\n version = version.version\n }\n } else if (typeof version !== 'string') {\n throw new TypeError(`Invalid version. Must be a string. Got type \"${typeof version}\".`)\n }\n\n if (version.length > MAX_LENGTH) {\n throw new TypeError(\n `version is longer than ${MAX_LENGTH} characters`\n )\n }\n\n debug('SemVer', version, options)\n this.options = options\n this.loose = !!options.loose\n // this isn't actually relevant for versions, but keep it so that we\n // don't run into trouble passing this.options around.\n this.includePrerelease = !!options.includePrerelease\n\n const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])\n\n if (!m) {\n throw new TypeError(`Invalid Version: ${version}`)\n }\n\n this.raw = version\n\n // these are actually numbers\n this.major = +m[1]\n this.minor = +m[2]\n this.patch = +m[3]\n\n if (this.major > MAX_SAFE_INTEGER || this.major < 0) {\n throw new TypeError('Invalid major version')\n }\n\n if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {\n throw new TypeError('Invalid minor version')\n }\n\n if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {\n throw new TypeError('Invalid patch version')\n }\n\n // numberify any prerelease numeric ids\n if (!m[4]) {\n this.prerelease = []\n } else {\n this.prerelease = m[4].split('.').map((id) => {\n if (/^[0-9]+$/.test(id)) {\n const num = +id\n if (num >= 0 && num < MAX_SAFE_INTEGER) {\n return num\n }\n }\n return id\n })\n }\n\n this.build = m[5] ? m[5].split('.') : []\n this.format()\n }\n\n format () {\n this.version = `${this.major}.${this.minor}.${this.patch}`\n if (this.prerelease.length) {\n this.version += `-${this.prerelease.join('.')}`\n }\n return this.version\n }\n\n toString () {\n return this.version\n }\n\n compare (other) {\n debug('SemVer.compare', this.version, this.options, other)\n if (!(other instanceof SemVer)) {\n if (typeof other === 'string' && other === this.version) {\n return 0\n }\n other = new SemVer(other, this.options)\n }\n\n if (other.version === this.version) {\n return 0\n }\n\n return this.compareMain(other) || this.comparePre(other)\n }\n\n compareMain (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n if (this.major < other.major) {\n return -1\n }\n if (this.major > other.major) {\n return 1\n }\n if (this.minor < other.minor) {\n return -1\n }\n if (this.minor > other.minor) {\n return 1\n }\n if (this.patch < other.patch) {\n return -1\n }\n if (this.patch > other.patch) {\n return 1\n }\n return 0\n }\n\n comparePre (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n // NOT having a prerelease is > having one\n if (this.prerelease.length && !other.prerelease.length) {\n return -1\n } else if (!this.prerelease.length && other.prerelease.length) {\n return 1\n } else if (!this.prerelease.length && !other.prerelease.length) {\n return 0\n }\n\n let i = 0\n do {\n const a = this.prerelease[i]\n const b = other.prerelease[i]\n debug('prerelease compare', i, a, b)\n if (a === undefined && b === undefined) {\n return 0\n } else if (b === undefined) {\n return 1\n } else if (a === undefined) {\n return -1\n } else if (a === b) {\n continue\n } else {\n return compareIdentifiers(a, b)\n }\n } while (++i)\n }\n\n compareBuild (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n let i = 0\n do {\n const a = this.build[i]\n const b = other.build[i]\n debug('build compare', i, a, b)\n if (a === undefined && b === undefined) {\n return 0\n } else if (b === undefined) {\n return 1\n } else if (a === undefined) {\n return -1\n } else if (a === b) {\n continue\n } else {\n return compareIdentifiers(a, b)\n }\n } while (++i)\n }\n\n // preminor will bump the version up to the next minor release, and immediately\n // down to pre-release. premajor and prepatch work the same way.\n inc (release, identifier, identifierBase) {\n if (release.startsWith('pre')) {\n if (!identifier && identifierBase === false) {\n throw new Error('invalid increment argument: identifier is empty')\n }\n // Avoid an invalid semver results\n if (identifier) {\n const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])\n if (!match || match[1] !== identifier) {\n throw new Error(`invalid identifier: ${identifier}`)\n }\n }\n }\n\n switch (release) {\n case 'premajor':\n this.prerelease.length = 0\n this.patch = 0\n this.minor = 0\n this.major++\n this.inc('pre', identifier, identifierBase)\n break\n case 'preminor':\n this.prerelease.length = 0\n this.patch = 0\n this.minor++\n this.inc('pre', identifier, identifierBase)\n break\n case 'prepatch':\n // If this is already a prerelease, it will bump to the next version\n // drop any prereleases that might already exist, since they are not\n // relevant at this point.\n this.prerelease.length = 0\n this.inc('patch', identifier, identifierBase)\n this.inc('pre', identifier, identifierBase)\n break\n // If the input is a non-prerelease version, this acts the same as\n // prepatch.\n case 'prerelease':\n if (this.prerelease.length === 0) {\n this.inc('patch', identifier, identifierBase)\n }\n this.inc('pre', identifier, identifierBase)\n break\n case 'release':\n if (this.prerelease.length === 0) {\n throw new Error(`version ${this.raw} is not a prerelease`)\n }\n this.prerelease.length = 0\n break\n\n case 'major':\n // If this is a pre-major version, bump up to the same major version.\n // Otherwise increment major.\n // 1.0.0-5 bumps to 1.0.0\n // 1.1.0 bumps to 2.0.0\n if (\n this.minor !== 0 ||\n this.patch !== 0 ||\n this.prerelease.length === 0\n ) {\n this.major++\n }\n this.minor = 0\n this.patch = 0\n this.prerelease = []\n break\n case 'minor':\n // If this is a pre-minor version, bump up to the same minor version.\n // Otherwise increment minor.\n // 1.2.0-5 bumps to 1.2.0\n // 1.2.1 bumps to 1.3.0\n if (this.patch !== 0 || this.prerelease.length === 0) {\n this.minor++\n }\n this.patch = 0\n this.prerelease = []\n break\n case 'patch':\n // If this is not a pre-release version, it will increment the patch.\n // If it is a pre-release it will bump up to the same patch version.\n // 1.2.0-5 patches to 1.2.0\n // 1.2.0 patches to 1.2.1\n if (this.prerelease.length === 0) {\n this.patch++\n }\n this.prerelease = []\n break\n // This probably shouldn't be used publicly.\n // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.\n case 'pre': {\n const base = Number(identifierBase) ? 1 : 0\n\n if (this.prerelease.length === 0) {\n this.prerelease = [base]\n } else {\n let i = this.prerelease.length\n while (--i >= 0) {\n if (typeof this.prerelease[i] === 'number') {\n this.prerelease[i]++\n i = -2\n }\n }\n if (i === -1) {\n // didn't increment anything\n if (identifier === this.prerelease.join('.') && identifierBase === false) {\n throw new Error('invalid increment argument: identifier already exists')\n }\n this.prerelease.push(base)\n }\n }\n if (identifier) {\n // 1.2.0-beta.1 bumps to 1.2.0-beta.2,\n // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0\n let prerelease = [identifier, base]\n if (identifierBase === false) {\n prerelease = [identifier]\n }\n if (compareIdentifiers(this.prerelease[0], identifier) === 0) {\n if (isNaN(this.prerelease[1])) {\n this.prerelease = prerelease\n }\n } else {\n this.prerelease = prerelease\n }\n }\n break\n }\n default:\n throw new Error(`invalid increment argument: ${release}`)\n }\n this.raw = this.format()\n if (this.build.length) {\n this.raw += `+${this.build.join('.')}`\n }\n return this\n }\n}\n\nmodule.exports = SemVer\n", "'use strict'\n\nconst SemVer = require('../classes/semver')\nconst parse = (version, options, throwErrors = false) => {\n if (version instanceof SemVer) {\n return version\n }\n try {\n return new SemVer(version, options)\n } catch (er) {\n if (!throwErrors) {\n return null\n }\n throw er\n }\n}\n\nmodule.exports = parse\n", "'use strict'\n\nconst SemVer = require('../classes/semver')\nconst parse = require('./parse')\nconst { safeRe: re, t } = require('../internal/re')\n\nconst coerce = (version, options) => {\n if (version instanceof SemVer) {\n return version\n }\n\n if (typeof version === 'number') {\n version = String(version)\n }\n\n if (typeof version !== 'string') {\n return null\n }\n\n options = options || {}\n\n let match = null\n if (!options.rtl) {\n match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE])\n } else {\n // Find the right-most coercible string that does not share\n // a terminus with a more left-ward coercible string.\n // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'\n // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'\n //\n // Walk through the string checking with a /g regexp\n // Manually set the index so as to pick up overlapping matches.\n // Stop when we get a match that ends at the string end, since no\n // coercible string can be more right-ward without the same terminus.\n const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]\n let next\n while ((next = coerceRtlRegex.exec(version)) &&\n (!match || match.index + match[0].length !== version.length)\n ) {\n if (!match ||\n next.index + next[0].length !== match.index + match[0].length) {\n match = next\n }\n coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length\n }\n // leave it in a clean state\n coerceRtlRegex.lastIndex = -1\n }\n\n if (match === null) {\n return null\n }\n\n const major = match[2]\n const minor = match[3] || '0'\n const patch = match[4] || '0'\n const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ''\n const build = options.includePrerelease && match[6] ? `+${match[6]}` : ''\n\n return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)\n}\nmodule.exports = coerce\n", "'use strict'\n\nconst SemVer = require('../classes/semver')\nconst compare = (a, b, loose) =>\n new SemVer(a, loose).compare(new SemVer(b, loose))\n\nmodule.exports = compare\n", "'use strict'\n\nconst compare = require('./compare')\nconst gte = (a, b, loose) => compare(a, b, loose) >= 0\nmodule.exports = gte\n", "'use strict'\n\nclass LRUCache {\n constructor () {\n this.max = 1000\n this.map = new Map()\n }\n\n get (key) {\n const value = this.map.get(key)\n if (value === undefined) {\n return undefined\n } else {\n // Remove the key from the map and add it to the end\n this.map.delete(key)\n this.map.set(key, value)\n return value\n }\n }\n\n delete (key) {\n return this.map.delete(key)\n }\n\n set (key, value) {\n const deleted = this.delete(key)\n\n if (!deleted && value !== undefined) {\n // If cache is full, delete the least recently used item\n if (this.map.size >= this.max) {\n const firstKey = this.map.keys().next().value\n this.delete(firstKey)\n }\n\n this.map.set(key, value)\n }\n\n return this\n }\n}\n\nmodule.exports = LRUCache\n", "'use strict'\n\nconst compare = require('./compare')\nconst eq = (a, b, loose) => compare(a, b, loose) === 0\nmodule.exports = eq\n", "'use strict'\n\nconst compare = require('./compare')\nconst neq = (a, b, loose) => compare(a, b, loose) !== 0\nmodule.exports = neq\n", "'use strict'\n\nconst compare = require('./compare')\nconst gt = (a, b, loose) => compare(a, b, loose) > 0\nmodule.exports = gt\n", "'use strict'\n\nconst compare = require('./compare')\nconst lt = (a, b, loose) => compare(a, b, loose) < 0\nmodule.exports = lt\n", "'use strict'\n\nconst compare = require('./compare')\nconst lte = (a, b, loose) => compare(a, b, loose) <= 0\nmodule.exports = lte\n", "'use strict'\n\nconst eq = require('./eq')\nconst neq = require('./neq')\nconst gt = require('./gt')\nconst gte = require('./gte')\nconst lt = require('./lt')\nconst lte = require('./lte')\n\nconst cmp = (a, op, b, loose) => {\n switch (op) {\n case '===':\n if (typeof a === 'object') {\n a = a.version\n }\n if (typeof b === 'object') {\n b = b.version\n }\n return a === b\n\n case '!==':\n if (typeof a === 'object') {\n a = a.version\n }\n if (typeof b === 'object') {\n b = b.version\n }\n return a !== b\n\n case '':\n case '=':\n case '==':\n return eq(a, b, loose)\n\n case '!=':\n return neq(a, b, loose)\n\n case '>':\n return gt(a, b, loose)\n\n case '>=':\n return gte(a, b, loose)\n\n case '<':\n return lt(a, b, loose)\n\n case '<=':\n return lte(a, b, loose)\n\n default:\n throw new TypeError(`Invalid operator: ${op}`)\n }\n}\nmodule.exports = cmp\n", "'use strict'\n\nconst ANY = Symbol('SemVer ANY')\n// hoisted class for cyclic dependency\nclass Comparator {\n static get ANY () {\n return ANY\n }\n\n constructor (comp, options) {\n options = parseOptions(options)\n\n if (comp instanceof Comparator) {\n if (comp.loose === !!options.loose) {\n return comp\n } else {\n comp = comp.value\n }\n }\n\n comp = comp.trim().split(/\\s+/).join(' ')\n debug('comparator', comp, options)\n this.options = options\n this.loose = !!options.loose\n this.parse(comp)\n\n if (this.semver === ANY) {\n this.value = ''\n } else {\n this.value = this.operator + this.semver.version\n }\n\n debug('comp', this)\n }\n\n parse (comp) {\n const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]\n const m = comp.match(r)\n\n if (!m) {\n throw new TypeError(`Invalid comparator: ${comp}`)\n }\n\n this.operator = m[1] !== undefined ? m[1] : ''\n if (this.operator === '=') {\n this.operator = ''\n }\n\n // if it literally is just '>' or '' then allow anything.\n if (!m[2]) {\n this.semver = ANY\n } else {\n this.semver = new SemVer(m[2], this.options.loose)\n }\n }\n\n toString () {\n return this.value\n }\n\n test (version) {\n debug('Comparator.test', version, this.options.loose)\n\n if (this.semver === ANY || version === ANY) {\n return true\n }\n\n if (typeof version === 'string') {\n try {\n version = new SemVer(version, this.options)\n } catch (er) {\n return false\n }\n }\n\n return cmp(version, this.operator, this.semver, this.options)\n }\n\n intersects (comp, options) {\n if (!(comp instanceof Comparator)) {\n throw new TypeError('a Comparator is required')\n }\n\n if (this.operator === '') {\n if (this.value === '') {\n return true\n }\n return new Range(comp.value, options).test(this.value)\n } else if (comp.operator === '') {\n if (comp.value === '') {\n return true\n }\n return new Range(this.value, options).test(comp.semver)\n }\n\n options = parseOptions(options)\n\n // Special cases where nothing can possibly be lower\n if (options.includePrerelease &&\n (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {\n return false\n }\n if (!options.includePrerelease &&\n (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {\n return false\n }\n\n // Same direction increasing (> or >=)\n if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {\n return true\n }\n // Same direction decreasing (< or <=)\n if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {\n return true\n }\n // same SemVer and both sides are inclusive (<= or >=)\n if (\n (this.semver.version === comp.semver.version) &&\n this.operator.includes('=') && comp.operator.includes('=')) {\n return true\n }\n // opposite directions less than\n if (cmp(this.semver, '<', comp.semver, options) &&\n this.operator.startsWith('>') && comp.operator.startsWith('<')) {\n return true\n }\n // opposite directions greater than\n if (cmp(this.semver, '>', comp.semver, options) &&\n this.operator.startsWith('<') && comp.operator.startsWith('>')) {\n return true\n }\n return false\n }\n}\n\nmodule.exports = Comparator\n\nconst parseOptions = require('../internal/parse-options')\nconst { safeRe: re, t } = require('../internal/re')\nconst cmp = require('../functions/cmp')\nconst debug = require('../internal/debug')\nconst SemVer = require('./semver')\nconst Range = require('./range')\n", "'use strict'\n\nconst SPACE_CHARACTERS = /\\s+/g\n\n// hoisted class for cyclic dependency\nclass Range {\n constructor (range, options) {\n options = parseOptions(options)\n\n if (range instanceof Range) {\n if (\n range.loose === !!options.loose &&\n range.includePrerelease === !!options.includePrerelease\n ) {\n return range\n } else {\n return new Range(range.raw, options)\n }\n }\n\n if (range instanceof Comparator) {\n // just put it in the set and return\n this.raw = range.value\n this.set = [[range]]\n this.formatted = undefined\n return this\n }\n\n this.options = options\n this.loose = !!options.loose\n this.includePrerelease = !!options.includePrerelease\n\n // First reduce all whitespace as much as possible so we do not have to rely\n // on potentially slow regexes like \\s*. This is then stored and used for\n // future error messages as well.\n this.raw = range.trim().replace(SPACE_CHARACTERS, ' ')\n\n // First, split on ||\n this.set = this.raw\n .split('||')\n // map the range to a 2d array of comparators\n .map(r => this.parseRange(r.trim()))\n // throw out any comparator lists that are empty\n // this generally means that it was not a valid range, which is allowed\n // in loose mode, but will still throw if the WHOLE range is invalid.\n .filter(c => c.length)\n\n if (!this.set.length) {\n throw new TypeError(`Invalid SemVer Range: ${this.raw}`)\n }\n\n // if we have any that are not the null set, throw out null sets.\n if (this.set.length > 1) {\n // keep the first one, in case they're all null sets\n const first = this.set[0]\n this.set = this.set.filter(c => !isNullSet(c[0]))\n if (this.set.length === 0) {\n this.set = [first]\n } else if (this.set.length > 1) {\n // if we have any that are *, then the range is just *\n for (const c of this.set) {\n if (c.length === 1 && isAny(c[0])) {\n this.set = [c]\n break\n }\n }\n }\n }\n\n this.formatted = undefined\n }\n\n get range () {\n if (this.formatted === undefined) {\n this.formatted = ''\n for (let i = 0; i < this.set.length; i++) {\n if (i > 0) {\n this.formatted += '||'\n }\n const comps = this.set[i]\n for (let k = 0; k < comps.length; k++) {\n if (k > 0) {\n this.formatted += ' '\n }\n this.formatted += comps[k].toString().trim()\n }\n }\n }\n return this.formatted\n }\n\n format () {\n return this.range\n }\n\n toString () {\n return this.range\n }\n\n parseRange (range) {\n // memoize range parsing for performance.\n // this is a very hot path, and fully deterministic.\n const memoOpts =\n (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |\n (this.options.loose && FLAG_LOOSE)\n const memoKey = memoOpts + ':' + range\n const cached = cache.get(memoKey)\n if (cached) {\n return cached\n }\n\n const loose = this.options.loose\n // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`\n const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]\n range = range.replace(hr, hyphenReplace(this.options.includePrerelease))\n debug('hyphen replace', range)\n\n // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`\n range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)\n debug('comparator trim', range)\n\n // `~ 1.2.3` => `~1.2.3`\n range = range.replace(re[t.TILDETRIM], tildeTrimReplace)\n debug('tilde trim', range)\n\n // `^ 1.2.3` => `^1.2.3`\n range = range.replace(re[t.CARETTRIM], caretTrimReplace)\n debug('caret trim', range)\n\n // At this point, the range is completely trimmed and\n // ready to be split into comparators.\n\n let rangeList = range\n .split(' ')\n .map(comp => parseComparator(comp, this.options))\n .join(' ')\n .split(/\\s+/)\n // >=0.0.0 is equivalent to *\n .map(comp => replaceGTE0(comp, this.options))\n\n if (loose) {\n // in loose mode, throw out any that are not valid comparators\n rangeList = rangeList.filter(comp => {\n debug('loose invalid filter', comp, this.options)\n return !!comp.match(re[t.COMPARATORLOOSE])\n })\n }\n debug('range list', rangeList)\n\n // if any comparators are the null set, then replace with JUST null set\n // if more than one comparator, remove any * comparators\n // also, don't include the same comparator more than once\n const rangeMap = new Map()\n const comparators = rangeList.map(comp => new Comparator(comp, this.options))\n for (const comp of comparators) {\n if (isNullSet(comp)) {\n return [comp]\n }\n rangeMap.set(comp.value, comp)\n }\n if (rangeMap.size > 1 && rangeMap.has('')) {\n rangeMap.delete('')\n }\n\n const result = [...rangeMap.values()]\n cache.set(memoKey, result)\n return result\n }\n\n intersects (range, options) {\n if (!(range instanceof Range)) {\n throw new TypeError('a Range is required')\n }\n\n return this.set.some((thisComparators) => {\n return (\n isSatisfiable(thisComparators, options) &&\n range.set.some((rangeComparators) => {\n return (\n isSatisfiable(rangeComparators, options) &&\n thisComparators.every((thisComparator) => {\n return rangeComparators.every((rangeComparator) => {\n return thisComparator.intersects(rangeComparator, options)\n })\n })\n )\n })\n )\n })\n }\n\n // if ANY of the sets match ALL of its comparators, then pass\n test (version) {\n if (!version) {\n return false\n }\n\n if (typeof version === 'string') {\n try {\n version = new SemVer(version, this.options)\n } catch (er) {\n return false\n }\n }\n\n for (let i = 0; i < this.set.length; i++) {\n if (testSet(this.set[i], version, this.options)) {\n return true\n }\n }\n return false\n }\n}\n\nmodule.exports = Range\n\nconst LRU = require('../internal/lrucache')\nconst cache = new LRU()\n\nconst parseOptions = require('../internal/parse-options')\nconst Comparator = require('./comparator')\nconst debug = require('../internal/debug')\nconst SemVer = require('./semver')\nconst {\n safeRe: re,\n t,\n comparatorTrimReplace,\n tildeTrimReplace,\n caretTrimReplace,\n} = require('../internal/re')\nconst { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')\n\nconst isNullSet = c => c.value === '<0.0.0-0'\nconst isAny = c => c.value === ''\n\n// take a set of comparators and determine whether there\n// exists a version which can satisfy it\nconst isSatisfiable = (comparators, options) => {\n let result = true\n const remainingComparators = comparators.slice()\n let testComparator = remainingComparators.pop()\n\n while (result && remainingComparators.length) {\n result = remainingComparators.every((otherComparator) => {\n return testComparator.intersects(otherComparator, options)\n })\n\n testComparator = remainingComparators.pop()\n }\n\n return result\n}\n\n// comprised of xranges, tildes, stars, and gtlt's at this point.\n// already replaced the hyphen ranges\n// turn into a set of JUST comparators.\nconst parseComparator = (comp, options) => {\n comp = comp.replace(re[t.BUILD], '')\n debug('comp', comp, options)\n comp = replaceCarets(comp, options)\n debug('caret', comp)\n comp = replaceTildes(comp, options)\n debug('tildes', comp)\n comp = replaceXRanges(comp, options)\n debug('xrange', comp)\n comp = replaceStars(comp, options)\n debug('stars', comp)\n return comp\n}\n\nconst isX = id => !id || id.toLowerCase() === 'x' || id === '*'\n\n// ~, ~> --> * (any, kinda silly)\n// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0\n// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0\n// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0\n// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0\n// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0\n// ~0.0.1 --> >=0.0.1 <0.1.0-0\nconst replaceTildes = (comp, options) => {\n return comp\n .trim()\n .split(/\\s+/)\n .map((c) => replaceTilde(c, options))\n .join(' ')\n}\n\nconst replaceTilde = (comp, options) => {\n const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]\n return comp.replace(r, (_, M, m, p, pr) => {\n debug('tilde', comp, _, M, m, p, pr)\n let ret\n\n if (isX(M)) {\n ret = ''\n } else if (isX(m)) {\n ret = `>=${M}.0.0 <${+M + 1}.0.0-0`\n } else if (isX(p)) {\n // ~1.2 == >=1.2.0 <1.3.0-0\n ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`\n } else if (pr) {\n debug('replaceTilde pr', pr)\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${+m + 1}.0-0`\n } else {\n // ~1.2.3 == >=1.2.3 <1.3.0-0\n ret = `>=${M}.${m}.${p\n } <${M}.${+m + 1}.0-0`\n }\n\n debug('tilde return', ret)\n return ret\n })\n}\n\n// ^ --> * (any, kinda silly)\n// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0\n// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0\n// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0\n// ^1.2.3 --> >=1.2.3 <2.0.0-0\n// ^1.2.0 --> >=1.2.0 <2.0.0-0\n// ^0.0.1 --> >=0.0.1 <0.0.2-0\n// ^0.1.0 --> >=0.1.0 <0.2.0-0\nconst replaceCarets = (comp, options) => {\n return comp\n .trim()\n .split(/\\s+/)\n .map((c) => replaceCaret(c, options))\n .join(' ')\n}\n\nconst replaceCaret = (comp, options) => {\n debug('caret', comp, options)\n const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]\n const z = options.includePrerelease ? '-0' : ''\n return comp.replace(r, (_, M, m, p, pr) => {\n debug('caret', comp, _, M, m, p, pr)\n let ret\n\n if (isX(M)) {\n ret = ''\n } else if (isX(m)) {\n ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`\n } else if (isX(p)) {\n if (M === '0') {\n ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`\n } else {\n ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`\n }\n } else if (pr) {\n debug('replaceCaret pr', pr)\n if (M === '0') {\n if (m === '0') {\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${m}.${+p + 1}-0`\n } else {\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${+m + 1}.0-0`\n }\n } else {\n ret = `>=${M}.${m}.${p}-${pr\n } <${+M + 1}.0.0-0`\n }\n } else {\n debug('no pr')\n if (M === '0') {\n if (m === '0') {\n ret = `>=${M}.${m}.${p\n }${z} <${M}.${m}.${+p + 1}-0`\n } else {\n ret = `>=${M}.${m}.${p\n }${z} <${M}.${+m + 1}.0-0`\n }\n } else {\n ret = `>=${M}.${m}.${p\n } <${+M + 1}.0.0-0`\n }\n }\n\n debug('caret return', ret)\n return ret\n })\n}\n\nconst replaceXRanges = (comp, options) => {\n debug('replaceXRanges', comp, options)\n return comp\n .split(/\\s+/)\n .map((c) => replaceXRange(c, options))\n .join(' ')\n}\n\nconst replaceXRange = (comp, options) => {\n comp = comp.trim()\n const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]\n return comp.replace(r, (ret, gtlt, M, m, p, pr) => {\n debug('xRange', comp, ret, gtlt, M, m, p, pr)\n const xM = isX(M)\n const xm = xM || isX(m)\n const xp = xm || isX(p)\n const anyX = xp\n\n if (gtlt === '=' && anyX) {\n gtlt = ''\n }\n\n // if we're including prereleases in the match, then we need\n // to fix this to -0, the lowest possible prerelease value\n pr = options.includePrerelease ? '-0' : ''\n\n if (xM) {\n if (gtlt === '>' || gtlt === '<') {\n // nothing is allowed\n ret = '<0.0.0-0'\n } else {\n // nothing is forbidden\n ret = '*'\n }\n } else if (gtlt && anyX) {\n // we know patch is an x, because we have any x at all.\n // replace X with 0\n if (xm) {\n m = 0\n }\n p = 0\n\n if (gtlt === '>') {\n // >1 => >=2.0.0\n // >1.2 => >=1.3.0\n gtlt = '>='\n if (xm) {\n M = +M + 1\n m = 0\n p = 0\n } else {\n m = +m + 1\n p = 0\n }\n } else if (gtlt === '<=') {\n // <=0.7.x is actually <0.8.0, since any 0.7.x should\n // pass. Similarly, <=7.x is actually <8.0.0, etc.\n gtlt = '<'\n if (xm) {\n M = +M + 1\n } else {\n m = +m + 1\n }\n }\n\n if (gtlt === '<') {\n pr = '-0'\n }\n\n ret = `${gtlt + M}.${m}.${p}${pr}`\n } else if (xm) {\n ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`\n } else if (xp) {\n ret = `>=${M}.${m}.0${pr\n } <${M}.${+m + 1}.0-0`\n }\n\n debug('xRange return', ret)\n\n return ret\n })\n}\n\n// Because * is AND-ed with everything else in the comparator,\n// and '' means \"any version\", just remove the *s entirely.\nconst replaceStars = (comp, options) => {\n debug('replaceStars', comp, options)\n // Looseness is ignored here. star is always as loose as it gets!\n return comp\n .trim()\n .replace(re[t.STAR], '')\n}\n\nconst replaceGTE0 = (comp, options) => {\n debug('replaceGTE0', comp, options)\n return comp\n .trim()\n .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')\n}\n\n// This function is passed to string.replace(re[t.HYPHENRANGE])\n// M, m, patch, prerelease, build\n// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5\n// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do\n// 1.2 - 3.4 => >=1.2.0 <3.5.0-0\n// TODO build?\nconst hyphenReplace = incPr => ($0,\n from, fM, fm, fp, fpr, fb,\n to, tM, tm, tp, tpr) => {\n if (isX(fM)) {\n from = ''\n } else if (isX(fm)) {\n from = `>=${fM}.0.0${incPr ? '-0' : ''}`\n } else if (isX(fp)) {\n from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`\n } else if (fpr) {\n from = `>=${from}`\n } else {\n from = `>=${from}${incPr ? '-0' : ''}`\n }\n\n if (isX(tM)) {\n to = ''\n } else if (isX(tm)) {\n to = `<${+tM + 1}.0.0-0`\n } else if (isX(tp)) {\n to = `<${tM}.${+tm + 1}.0-0`\n } else if (tpr) {\n to = `<=${tM}.${tm}.${tp}-${tpr}`\n } else if (incPr) {\n to = `<${tM}.${tm}.${+tp + 1}-0`\n } else {\n to = `<=${to}`\n }\n\n return `${from} ${to}`.trim()\n}\n\nconst testSet = (set, version, options) => {\n for (let i = 0; i < set.length; i++) {\n if (!set[i].test(version)) {\n return false\n }\n }\n\n if (version.prerelease.length && !options.includePrerelease) {\n // Find the set of versions that are allowed to have prereleases\n // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0\n // That should allow `1.2.3-pr.2` to pass.\n // However, `1.2.4-alpha.notready` should NOT be allowed,\n // even though it's within the range set by the comparators.\n for (let i = 0; i < set.length; i++) {\n debug(set[i].semver)\n if (set[i].semver === Comparator.ANY) {\n continue\n }\n\n if (set[i].semver.prerelease.length > 0) {\n const allowed = set[i].semver\n if (allowed.major === version.major &&\n allowed.minor === version.minor &&\n allowed.patch === version.patch) {\n return true\n }\n }\n }\n\n // Version has a -pre, but it's not one of the ones we like.\n return false\n }\n\n return true\n}\n", "'use strict'\n\nconst Range = require('../classes/range')\nconst satisfies = (version, range, options) => {\n try {\n range = new Range(range, options)\n } catch (er) {\n return false\n }\n return range.test(version)\n}\nmodule.exports = satisfies\n", "{\n \"name\": \"sharp\",\n \"description\": \"High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images\",\n \"version\": \"0.34.5\",\n \"author\": \"Lovell Fuller <npm@lovell.info>\",\n \"homepage\": \"https://sharp.pixelplumbing.com\",\n \"contributors\": [\n \"Pierre Inglebert <pierre.inglebert@gmail.com>\",\n \"Jonathan Ong <jonathanrichardong@gmail.com>\",\n \"Chanon Sajjamanochai <chanon.s@gmail.com>\",\n \"Juliano Julio <julianojulio@gmail.com>\",\n \"Daniel Gasienica <daniel@gasienica.ch>\",\n \"Julian Walker <julian@fiftythree.com>\",\n \"Amit Pitaru <pitaru.amit@gmail.com>\",\n \"Brandon Aaron <hello.brandon@aaron.sh>\",\n \"Andreas Lind <andreas@one.com>\",\n \"Maurus Cuelenaere <mcuelenaere@gmail.com>\",\n \"Linus Unneb\u00E4ck <linus@folkdatorn.se>\",\n \"Victor Mateevitsi <mvictoras@gmail.com>\",\n \"Alaric Holloway <alaric.holloway@gmail.com>\",\n \"Bernhard K. Weisshuhn <bkw@codingforce.com>\",\n \"Chris Riley <criley@primedia.com>\",\n \"David Carley <dacarley@gmail.com>\",\n \"John Tobin <john@limelightmobileinc.com>\",\n \"Kenton Gray <kentongray@gmail.com>\",\n \"Felix B\u00FCnemann <Felix.Buenemann@gmail.com>\",\n \"Samy Al Zahrani <samyalzahrany@gmail.com>\",\n \"Chintan Thakkar <lemnisk8@gmail.com>\",\n \"F. Orlando Galashan <frulo@gmx.de>\",\n \"Kleis Auke Wolthuizen <info@kleisauke.nl>\",\n \"Matt Hirsch <mhirsch@media.mit.edu>\",\n \"Matthias Thoemmes <thoemmes@gmail.com>\",\n \"Patrick Paskaris <patrick@paskaris.gr>\",\n \"J\u00E9r\u00E9my Lal <kapouer@melix.org>\",\n \"Rahul Nanwani <r.nanwani@gmail.com>\",\n \"Alice Monday <alice0meta@gmail.com>\",\n \"Kristo Jorgenson <kristo.jorgenson@gmail.com>\",\n \"YvesBos <yves_bos@outlook.com>\",\n \"Guy Maliar <guy@tailorbrands.com>\",\n \"Nicolas Coden <nicolas@ncoden.fr>\",\n \"Matt Parrish <matt.r.parrish@gmail.com>\",\n \"Marcel Bretschneider <marcel.bretschneider@gmail.com>\",\n \"Matthew McEachen <matthew+github@mceachen.org>\",\n \"Jarda Kot\u011B\u0161ovec <jarda.kotesovec@gmail.com>\",\n \"Kenric D'Souza <kenric.dsouza@gmail.com>\",\n \"Oleh Aleinyk <oleg.aleynik@gmail.com>\",\n \"Marcel Bretschneider <marcel.bretschneider@gmail.com>\",\n \"Andrea Bianco <andrea.bianco@unibas.ch>\",\n \"Rik Heywood <rik@rik.org>\",\n \"Thomas Parisot <hi@oncletom.io>\",\n \"Nathan Graves <nathanrgraves+github@gmail.com>\",\n \"Tom Lokhorst <tom@lokhorst.eu>\",\n \"Espen Hovlandsdal <espen@hovlandsdal.com>\",\n \"Sylvain Dumont <sylvain.dumont35@gmail.com>\",\n \"Alun Davies <alun.owain.davies@googlemail.com>\",\n \"Aidan Hoolachan <ajhoolachan21@gmail.com>\",\n \"Axel Eirola <axel.eirola@iki.fi>\",\n \"Freezy <freezy@xbmc.org>\",\n \"Daiz <taneli.vatanen@gmail.com>\",\n \"Julian Aubourg <j@ubourg.net>\",\n \"Keith Belovay <keith@picthrive.com>\",\n \"Michael B. Klein <mbklein@gmail.com>\",\n \"Jordan Prudhomme <jordan@raboland.fr>\",\n \"Ilya Ovdin <iovdin@gmail.com>\",\n \"Andargor <andargor@yahoo.com>\",\n \"Paul Neave <paul.neave@gmail.com>\",\n \"Brendan Kennedy <brenwken@gmail.com>\",\n \"Brychan Bennett-Odlum <git@brychan.io>\",\n \"Edward Silverton <e.silverton@gmail.com>\",\n \"Roman Malieiev <aromaleev@gmail.com>\",\n \"Tomas Szabo <tomas.szabo@deftomat.com>\",\n \"Robert O'Rourke <robert@o-rourke.org>\",\n \"Guillermo Alfonso Varela Chouci\u00F1o <guillevch@gmail.com>\",\n \"Christian Flintrup <chr@gigahost.dk>\",\n \"Manan Jadhav <manan@motionden.com>\",\n \"Leon Radley <leon@radley.se>\",\n \"alza54 <alza54@thiocod.in>\",\n \"Jacob Smith <jacob@frende.me>\",\n \"Michael Nutt <michael@nutt.im>\",\n \"Brad Parham <baparham@gmail.com>\",\n \"Taneli Vatanen <taneli.vatanen@gmail.com>\",\n \"Joris Dugu\u00E9 <zaruike10@gmail.com>\",\n \"Chris Banks <christopher.bradley.banks@gmail.com>\",\n \"Ompal Singh <ompal.hitm09@gmail.com>\",\n \"Brodan <christopher.hranj@gmail.com>\",\n \"Ankur Parihar <ankur.github@gmail.com>\",\n \"Brahim Ait elhaj <brahima@gmail.com>\",\n \"Mart Jansink <m.jansink@gmail.com>\",\n \"Lachlan Newman <lachnewman007@gmail.com>\",\n \"Dennis Beatty <dennis@dcbeatty.com>\",\n \"Ingvar Stepanyan <me@rreverser.com>\",\n \"Don Denton <don@happycollision.com>\"\n ],\n \"scripts\": {\n \"build\": \"node install/build.js\",\n \"install\": \"node install/check.js || npm run build\",\n \"clean\": \"rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*\",\n \"test\": \"npm run lint && npm run test-unit\",\n \"lint\": \"npm run lint-cpp && npm run lint-js && npm run lint-types\",\n \"lint-cpp\": \"cpplint --quiet src/*.h src/*.cc\",\n \"lint-js\": \"biome lint\",\n \"lint-types\": \"tsd --files ./test/types/sharp.test-d.ts\",\n \"test-leak\": \"./test/leak/leak.sh\",\n \"test-unit\": \"node --experimental-test-coverage test/unit.mjs\",\n \"package-from-local-build\": \"node npm/from-local-build.js\",\n \"package-release-notes\": \"node npm/release-notes.js\",\n \"docs-build\": \"node docs/build.mjs\",\n \"docs-serve\": \"cd docs && npm start\",\n \"docs-publish\": \"cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp\"\n },\n \"type\": \"commonjs\",\n \"main\": \"lib/index.js\",\n \"types\": \"lib/index.d.ts\",\n \"files\": [\n \"install\",\n \"lib\",\n \"src/*.{cc,h,gyp}\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git://github.com/lovell/sharp.git\"\n },\n \"keywords\": [\n \"jpeg\",\n \"png\",\n \"webp\",\n \"avif\",\n \"tiff\",\n \"gif\",\n \"svg\",\n \"jp2\",\n \"dzi\",\n \"image\",\n \"resize\",\n \"thumbnail\",\n \"crop\",\n \"embed\",\n \"libvips\",\n \"vips\"\n ],\n \"dependencies\": {\n \"@img/colour\": \"^1.0.0\",\n \"detect-libc\": \"^2.1.2\",\n \"semver\": \"^7.7.3\"\n },\n \"optionalDependencies\": {\n \"@img/sharp-darwin-arm64\": \"0.34.5\",\n \"@img/sharp-darwin-x64\": \"0.34.5\",\n \"@img/sharp-libvips-darwin-arm64\": \"1.2.4\",\n \"@img/sharp-libvips-darwin-x64\": \"1.2.4\",\n \"@img/sharp-libvips-linux-arm\": \"1.2.4\",\n \"@img/sharp-libvips-linux-arm64\": \"1.2.4\",\n \"@img/sharp-libvips-linux-ppc64\": \"1.2.4\",\n \"@img/sharp-libvips-linux-riscv64\": \"1.2.4\",\n \"@img/sharp-libvips-linux-s390x\": \"1.2.4\",\n \"@img/sharp-libvips-linux-x64\": \"1.2.4\",\n \"@img/sharp-libvips-linuxmusl-arm64\": \"1.2.4\",\n \"@img/sharp-libvips-linuxmusl-x64\": \"1.2.4\",\n \"@img/sharp-linux-arm\": \"0.34.5\",\n \"@img/sharp-linux-arm64\": \"0.34.5\",\n \"@img/sharp-linux-ppc64\": \"0.34.5\",\n \"@img/sharp-linux-riscv64\": \"0.34.5\",\n \"@img/sharp-linux-s390x\": \"0.34.5\",\n \"@img/sharp-linux-x64\": \"0.34.5\",\n \"@img/sharp-linuxmusl-arm64\": \"0.34.5\",\n \"@img/sharp-linuxmusl-x64\": \"0.34.5\",\n \"@img/sharp-wasm32\": \"0.34.5\",\n \"@img/sharp-win32-arm64\": \"0.34.5\",\n \"@img/sharp-win32-ia32\": \"0.34.5\",\n \"@img/sharp-win32-x64\": \"0.34.5\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^2.3.4\",\n \"@cpplint/cli\": \"^0.1.0\",\n \"@emnapi/runtime\": \"^1.7.0\",\n \"@img/sharp-libvips-dev\": \"1.2.4\",\n \"@img/sharp-libvips-dev-wasm32\": \"1.2.4\",\n \"@img/sharp-libvips-win32-arm64\": \"1.2.4\",\n \"@img/sharp-libvips-win32-ia32\": \"1.2.4\",\n \"@img/sharp-libvips-win32-x64\": \"1.2.4\",\n \"@types/node\": \"*\",\n \"emnapi\": \"^1.7.0\",\n \"exif-reader\": \"^2.0.2\",\n \"extract-zip\": \"^2.0.1\",\n \"icc\": \"^3.0.0\",\n \"jsdoc-to-markdown\": \"^9.1.3\",\n \"node-addon-api\": \"^8.5.0\",\n \"node-gyp\": \"^11.5.0\",\n \"tar-fs\": \"^3.1.1\",\n \"tsd\": \"^0.33.0\"\n },\n \"license\": \"Apache-2.0\",\n \"engines\": {\n \"node\": \"^18.17.0 || ^20.3.0 || >=21.0.0\"\n },\n \"config\": {\n \"libvips\": \">=8.17.3\"\n },\n \"funding\": {\n \"url\": \"https://opencollective.com/libvips\"\n }\n}\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst { spawnSync } = require('node:child_process');\nconst { createHash } = require('node:crypto');\nconst semverCoerce = require('semver/functions/coerce');\nconst semverGreaterThanOrEqualTo = require('semver/functions/gte');\nconst semverSatisfies = require('semver/functions/satisfies');\nconst detectLibc = require('detect-libc');\n\nconst { config, engines, optionalDependencies } = require('../package.json');\n\n/* node:coverage ignore next */\nconst minimumLibvipsVersionLabelled = process.env.npm_package_config_libvips || config.libvips;\nconst minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).version;\n\nconst prebuiltPlatforms = [\n 'darwin-arm64', 'darwin-x64',\n 'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-riscv64', 'linux-s390x', 'linux-x64',\n 'linuxmusl-arm64', 'linuxmusl-x64',\n 'win32-arm64', 'win32-ia32', 'win32-x64'\n];\n\nconst spawnSyncOptions = {\n encoding: 'utf8',\n shell: true\n};\n\nconst log = (item) => {\n if (item instanceof Error) {\n console.error(`sharp: Installation error: ${item.message}`);\n } else {\n console.log(`sharp: ${item}`);\n }\n};\n\n/* node:coverage ignore next */\nconst runtimeLibc = () => detectLibc.isNonGlibcLinuxSync() ? detectLibc.familySync() : '';\n\nconst runtimePlatformArch = () => `${process.platform}${runtimeLibc()}-${process.arch}`;\n\nconst buildPlatformArch = () => {\n /* node:coverage ignore next 3 */\n if (isEmscripten()) {\n return 'wasm32';\n }\n const { npm_config_arch, npm_config_platform, npm_config_libc } = process.env;\n const libc = typeof npm_config_libc === 'string' ? npm_config_libc : runtimeLibc();\n return `${npm_config_platform || process.platform}${libc}-${npm_config_arch || process.arch}`;\n};\n\nconst buildSharpLibvipsIncludeDir = () => {\n try {\n return require(`@img/sharp-libvips-dev-${buildPlatformArch()}/include`);\n } catch {\n /* node:coverage ignore next 5 */\n try {\n return require('@img/sharp-libvips-dev/include');\n } catch {}\n }\n return '';\n};\n\nconst buildSharpLibvipsCPlusPlusDir = () => {\n /* node:coverage ignore next 4 */\n try {\n return require('@img/sharp-libvips-dev/cplusplus');\n } catch {}\n return '';\n};\n\nconst buildSharpLibvipsLibDir = () => {\n try {\n return require(`@img/sharp-libvips-dev-${buildPlatformArch()}/lib`);\n } catch {\n /* node:coverage ignore next 5 */\n try {\n return require(`@img/sharp-libvips-${buildPlatformArch()}/lib`);\n } catch {}\n }\n return '';\n};\n\n/* node:coverage disable */\n\nconst isUnsupportedNodeRuntime = () => {\n if (process.release?.name === 'node' && process.versions) {\n if (!semverSatisfies(process.versions.node, engines.node)) {\n return { found: process.versions.node, expected: engines.node };\n }\n }\n};\n\nconst isEmscripten = () => {\n const { CC } = process.env;\n return Boolean(CC?.endsWith('/emcc'));\n};\n\nconst isRosetta = () => {\n if (process.platform === 'darwin' && process.arch === 'x64') {\n const translated = spawnSync('sysctl sysctl.proc_translated', spawnSyncOptions).stdout;\n return (translated || '').trim() === 'sysctl.proc_translated: 1';\n }\n return false;\n};\n\n/* node:coverage enable */\n\nconst sha512 = (s) => createHash('sha512').update(s).digest('hex');\n\nconst yarnLocator = () => {\n try {\n const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);\n const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`], {\n includePrerelease: true\n }).version;\n return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);\n } catch {}\n return '';\n};\n\n/* node:coverage disable */\n\nconst spawnRebuild = () =>\n spawnSync(`node-gyp rebuild --directory=src ${isEmscripten() ? '--nodedir=emscripten' : ''}`, {\n ...spawnSyncOptions,\n stdio: 'inherit'\n }).status;\n\nconst globalLibvipsVersion = () => {\n if (process.platform !== 'win32') {\n const globalLibvipsVersion = spawnSync('pkg-config --modversion vips-cpp', {\n ...spawnSyncOptions,\n env: {\n ...process.env,\n PKG_CONFIG_PATH: pkgConfigPath()\n }\n }).stdout;\n return (globalLibvipsVersion || '').trim();\n } else {\n return '';\n }\n};\n\n/* node:coverage enable */\n\nconst pkgConfigPath = () => {\n if (process.platform !== 'win32') {\n /* node:coverage ignore next 4 */\n const brewPkgConfigPath = spawnSync(\n 'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d\" \" -f2',\n spawnSyncOptions\n ).stdout || '';\n return [\n brewPkgConfigPath.trim(),\n process.env.PKG_CONFIG_PATH,\n '/usr/local/lib/pkgconfig',\n '/usr/lib/pkgconfig',\n '/usr/local/libdata/pkgconfig',\n '/usr/libdata/pkgconfig'\n ].filter(Boolean).join(':');\n } else {\n return '';\n }\n};\n\nconst skipSearch = (status, reason, logger) => {\n if (logger) {\n logger(`Detected ${reason}, skipping search for globally-installed libvips`);\n }\n return status;\n};\n\nconst useGlobalLibvips = (logger) => {\n if (Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS) === true) {\n return skipSearch(false, 'SHARP_IGNORE_GLOBAL_LIBVIPS', logger);\n }\n if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) {\n return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS', logger);\n }\n /* node:coverage ignore next 3 */\n if (isRosetta()) {\n return skipSearch(false, 'Rosetta', logger);\n }\n const globalVipsVersion = globalLibvipsVersion();\n /* node:coverage ignore next */\n return !!globalVipsVersion && semverGreaterThanOrEqualTo(globalVipsVersion, minimumLibvipsVersion);\n};\n\nmodule.exports = {\n minimumLibvipsVersion,\n prebuiltPlatforms,\n buildPlatformArch,\n buildSharpLibvipsIncludeDir,\n buildSharpLibvipsCPlusPlusDir,\n buildSharpLibvipsLibDir,\n isUnsupportedNodeRuntime,\n runtimePlatformArch,\n log,\n yarnLocator,\n spawnRebuild,\n globalLibvipsVersion,\n pkgConfigPath,\n useGlobalLibvips\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\n// Inspects the runtime environment and exports the relevant sharp.node binary\n\nconst { familySync, versionSync } = require('detect-libc');\n\nconst { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');\nconst runtimePlatform = runtimePlatformArch();\n\nconst paths = [\n `../src/build/Release/sharp-${runtimePlatform}.node`,\n '../src/build/Release/sharp-wasm32.node',\n `@img/sharp-${runtimePlatform}/sharp.node`,\n '@img/sharp-wasm32/sharp.node'\n];\n\n/* node:coverage disable */\n\nlet path, sharp;\nconst errors = [];\nfor (path of paths) {\n try {\n sharp = require(path);\n break;\n } catch (err) {\n errors.push(err);\n }\n}\n\nif (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2()) {\n const err = new Error('Prebuilt binaries for linux-x64 require v2 microarchitecture');\n err.code = 'Unsupported CPU';\n errors.push(err);\n sharp = null;\n}\n\nif (sharp) {\n module.exports = sharp;\n} else {\n const [isLinux, isMacOs, isWindows] = ['linux', 'darwin', 'win32'].map(os => runtimePlatform.startsWith(os));\n\n const help = [`Could not load the \"sharp\" module using the ${runtimePlatform} runtime`];\n errors.forEach(err => {\n if (err.code !== 'MODULE_NOT_FOUND') {\n help.push(`${err.code}: ${err.message}`);\n }\n });\n const messages = errors.map(err => err.message).join(' ');\n help.push('Possible solutions:');\n // Common error messages\n if (isUnsupportedNodeRuntime()) {\n const { found, expected } = isUnsupportedNodeRuntime();\n help.push(\n '- Please upgrade Node.js:',\n ` Found ${found}`,\n ` Requires ${expected}`\n );\n } else if (prebuiltPlatforms.includes(runtimePlatform)) {\n const [os, cpu] = runtimePlatform.split('-');\n const libc = os.endsWith('musl') ? ' --libc=musl' : '';\n help.push(\n '- Ensure optional dependencies can be installed:',\n ' npm install --include=optional sharp',\n '- Ensure your package manager supports multi-platform installation:',\n ' See https://sharp.pixelplumbing.com/install#cross-platform',\n '- Add platform-specific dependencies:',\n ` npm install --os=${os.replace('musl', '')}${libc} --cpu=${cpu} sharp`\n );\n } else {\n help.push(\n `- Manually install libvips >= ${minimumLibvipsVersion}`,\n '- Add experimental WebAssembly-based dependencies:',\n ' npm install --cpu=wasm32 sharp',\n ' npm install @img/sharp-wasm32'\n );\n }\n if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {\n try {\n const { config } = require(`@img/sharp-libvips-${runtimePlatform}/package`);\n const libcFound = `${familySync()} ${versionSync()}`;\n const libcRequires = `${config.musl ? 'musl' : 'glibc'} ${config.musl || config.glibc}`;\n help.push(\n '- Update your OS:',\n ` Found ${libcFound}`,\n ` Requires ${libcRequires}`\n );\n } catch (_errEngines) {}\n }\n if (isLinux && /\\/snap\\/core[0-9]{2}/.test(messages)) {\n help.push(\n '- Remove the Node.js Snap, which does not support native modules',\n ' snap remove node'\n );\n }\n if (isMacOs && /Incompatible library version/.test(messages)) {\n help.push(\n '- Update Homebrew:',\n ' brew update && brew upgrade vips'\n );\n }\n if (errors.some(err => err.code === 'ERR_DLOPEN_DISABLED')) {\n help.push('- Run Node.js without using the --no-addons flag');\n }\n // Link to installation docs\n if (isWindows && /The specified procedure could not be found/.test(messages)) {\n help.push(\n '- Using the canvas package on Windows?',\n ' See https://sharp.pixelplumbing.com/install#canvas-and-windows',\n '- Check for outdated versions of sharp in the dependency tree:',\n ' npm ls sharp'\n );\n }\n help.push(\n '- Consult the installation documentation:',\n ' See https://sharp.pixelplumbing.com/install'\n );\n throw new Error(help.join('\\n'));\n}\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst util = require('node:util');\nconst stream = require('node:stream');\nconst is = require('./is');\n\nrequire('./sharp');\n\n// Use NODE_DEBUG=sharp to enable libvips warnings\nconst debuglog = util.debuglog('sharp');\n\nconst queueListener = (queueLength) => {\n Sharp.queue.emit('change', queueLength);\n};\n\n/**\n * Constructor factory to create an instance of `sharp`, to which further methods are chained.\n *\n * JPEG, PNG, WebP, GIF, AVIF or TIFF format image data can be streamed out from this object.\n * When using Stream based output, derived attributes are available from the `info` event.\n *\n * Non-critical problems encountered during processing are emitted as `warning` events.\n *\n * Implements the [stream.Duplex](http://nodejs.org/api/stream.html#stream_class_stream_duplex) class.\n *\n * When loading more than one page/frame of an animated image,\n * these are combined as a vertically-stacked \"toilet roll\" image\n * where the overall height is the `pageHeight` multiplied by the number of `pages`.\n *\n * @constructs Sharp\n *\n * @emits Sharp#info\n * @emits Sharp#warning\n *\n * @example\n * sharp('input.jpg')\n * .resize(300, 200)\n * .toFile('output.jpg', function(err) {\n * // output.jpg is a 300 pixels wide and 200 pixels high image\n * // containing a scaled and cropped version of input.jpg\n * });\n *\n * @example\n * // Read image data from remote URL,\n * // resize to 300 pixels wide,\n * // emit an 'info' event with calculated dimensions\n * // and finally write image data to writableStream\n * const { body } = fetch('https://...');\n * const readableStream = Readable.fromWeb(body);\n * const transformer = sharp()\n * .resize(300)\n * .on('info', ({ height }) => {\n * console.log(`Image height is ${height}`);\n * });\n * readableStream.pipe(transformer).pipe(writableStream);\n *\n * @example\n * // Create a blank 300x200 PNG image of semi-translucent red pixels\n * sharp({\n * create: {\n * width: 300,\n * height: 200,\n * channels: 4,\n * background: { r: 255, g: 0, b: 0, alpha: 0.5 }\n * }\n * })\n * .png()\n * .toBuffer()\n * .then( ... );\n *\n * @example\n * // Convert an animated GIF to an animated WebP\n * await sharp('in.gif', { animated: true }).toFile('out.webp');\n *\n * @example\n * // Read a raw array of pixels and save it to a png\n * const input = Uint8Array.from([255, 255, 255, 0, 0, 0]); // or Uint8ClampedArray\n * const image = sharp(input, {\n * // because the input does not contain its dimensions or how many channels it has\n * // we need to specify it in the constructor options\n * raw: {\n * width: 2,\n * height: 1,\n * channels: 3\n * }\n * });\n * await image.toFile('my-two-pixels.png');\n *\n * @example\n * // Generate RGB Gaussian noise\n * await sharp({\n * create: {\n * width: 300,\n * height: 200,\n * channels: 3,\n * noise: {\n * type: 'gaussian',\n * mean: 128,\n * sigma: 30\n * }\n * }\n * }).toFile('noise.png');\n *\n * @example\n * // Generate an image from text\n * await sharp({\n * text: {\n * text: 'Hello, world!',\n * width: 400, // max width\n * height: 300 // max height\n * }\n * }).toFile('text_bw.png');\n *\n * @example\n * // Generate an rgba image from text using pango markup and font\n * await sharp({\n * text: {\n * text: '<span foreground=\"red\">Red!</span><span background=\"cyan\">blue</span>',\n * font: 'sans',\n * rgba: true,\n * dpi: 300\n * }\n * }).toFile('text_rgba.png');\n *\n * @example\n * // Join four input images as a 2x2 grid with a 4 pixel gutter\n * const data = await sharp(\n * [image1, image2, image3, image4],\n * { join: { across: 2, shim: 4 } }\n * ).toBuffer();\n *\n * @example\n * // Generate a two-frame animated image from emoji\n * const images = ['\uD83D\uDE00', '\uD83D\uDE1B'].map(text => ({\n * text: { text, width: 64, height: 64, channels: 4, rgba: true }\n * }));\n * await sharp(images, { join: { animated: true } }).toFile('out.gif');\n *\n * @param {(Buffer|ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array|Float32Array|Float64Array|string|Array)} [input] - if present, can be\n * a Buffer / ArrayBuffer / Uint8Array / Uint8ClampedArray containing JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image data, or\n * a TypedArray containing raw pixel image data, or\n * a String containing the filesystem path to an JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image file.\n * An array of inputs can be provided, and these will be joined together.\n * JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.\n * @param {Object} [options] - if present, is an Object with optional attributes.\n * @param {string} [options.failOn='warning'] - When to abort processing of invalid pixel data, one of (in order of sensitivity, least to most): 'none', 'truncated', 'error', 'warning'. Higher levels imply lower levels. Invalid metadata will always abort.\n * @param {number|boolean} [options.limitInputPixels=268402689] - Do not process input images where the number of pixels\n * (width x height) exceeds this limit. Assumes image dimensions contained in the input metadata can be trusted.\n * An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF).\n * @param {boolean} [options.unlimited=false] - Set this to `true` to remove safety features that help prevent memory exhaustion (JPEG, PNG, SVG, HEIF).\n * @param {boolean} [options.autoOrient=false] - Set this to `true` to rotate/flip the image to match EXIF `Orientation`, if any.\n * @param {boolean} [options.sequentialRead=true] - Set this to `false` to use random access rather than sequential read. Some operations will do this automatically.\n * @param {number} [options.density=72] - number representing the DPI for vector images in the range 1 to 100000.\n * @param {number} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.\n * @param {number} [options.pages=1] - Number of pages to extract for multi-page input (GIF, WebP, TIFF), use -1 for all pages.\n * @param {number} [options.page=0] - Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based.\n * @param {boolean} [options.animated=false] - Set to `true` to read all frames/pages of an animated image (GIF, WebP, TIFF), equivalent of setting `pages` to `-1`.\n * @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.\n * @param {number} [options.raw.width] - integral number of pixels wide.\n * @param {number} [options.raw.height] - integral number of pixels high.\n * @param {number} [options.raw.channels] - integral number of channels, between 1 and 4.\n * @param {boolean} [options.raw.premultiplied] - specifies that the raw input has already been premultiplied, set to `true`\n * to avoid sharp premultiplying the image. (optional, default `false`)\n * @param {number} [options.raw.pageHeight] - The pixel height of each page/frame for animated images, must be an integral factor of `raw.height`.\n * @param {Object} [options.create] - describes a new image to be created.\n * @param {number} [options.create.width] - integral number of pixels wide.\n * @param {number} [options.create.height] - integral number of pixels high.\n * @param {number} [options.create.channels] - integral number of channels, either 3 (RGB) or 4 (RGBA).\n * @param {string|Object} [options.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @param {number} [options.create.pageHeight] - The pixel height of each page/frame for animated images, must be an integral factor of `create.height`.\n * @param {Object} [options.create.noise] - describes a noise to be created.\n * @param {string} [options.create.noise.type] - type of generated noise, currently only `gaussian` is supported.\n * @param {number} [options.create.noise.mean=128] - Mean value of pixels in the generated noise.\n * @param {number} [options.create.noise.sigma=30] - Standard deviation of pixel values in the generated noise.\n * @param {Object} [options.text] - describes a new text image to be created.\n * @param {string} [options.text.text] - text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`.\n * @param {string} [options.text.font] - font name to render with.\n * @param {string} [options.text.fontfile] - absolute filesystem path to a font file that can be used by `font`.\n * @param {number} [options.text.width=0] - Integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries.\n * @param {number} [options.text.height=0] - Maximum integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0.\n * @param {string} [options.text.align='left'] - Alignment style for multi-line text (`'left'`, `'centre'`, `'center'`, `'right'`).\n * @param {boolean} [options.text.justify=false] - set this to true to apply justification to the text.\n * @param {number} [options.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.\n * @param {boolean} [options.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for pango markup features like `<span foreground=\"red\">Red!</span>`.\n * @param {number} [options.text.spacing=0] - text line height in points. Will use the font line height if none is specified.\n * @param {string} [options.text.wrap='word'] - word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none'.\n * @param {Object} [options.join] - describes how an array of input images should be joined.\n * @param {number} [options.join.across=1] - number of images to join horizontally.\n * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image.\n * @param {number} [options.join.shim=0] - number of pixels to insert between joined images.\n * @param {string|Object} [options.join.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @param {string} [options.join.halign='left'] - horizontal alignment style for images joined horizontally (`'left'`, `'centre'`, `'center'`, `'right'`).\n * @param {string} [options.join.valign='top'] - vertical alignment style for images joined vertically (`'top'`, `'centre'`, `'center'`, `'bottom'`).\n * @param {Object} [options.tiff] - Describes TIFF specific options.\n * @param {number} [options.tiff.subifd=-1] - Sub Image File Directory to extract for OME-TIFF, defaults to main image.\n * @param {Object} [options.svg] - Describes SVG specific options.\n * @param {string} [options.svg.stylesheet] - Custom CSS for SVG input, applied with a User Origin during the CSS cascade.\n * @param {boolean} [options.svg.highBitdepth=false] - Set to `true` to render SVG input at 32-bits per channel (128-bit) instead of 8-bits per channel (32-bit) RGBA.\n * @param {Object} [options.pdf] - Describes PDF specific options. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick.\n * @param {string|Object} [options.pdf.background] - Background colour to use when PDF is partially transparent. Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @param {Object} [options.openSlide] - Describes OpenSlide specific options. Requires the use of a globally-installed libvips compiled with support for OpenSlide.\n * @param {number} [options.openSlide.level=0] - Level to extract from a multi-level input, zero based.\n * @param {Object} [options.jp2] - Describes JPEG 2000 specific options. Requires the use of a globally-installed libvips compiled with support for OpenJPEG.\n * @param {boolean} [options.jp2.oneshot=false] - Set to `true` to decode tiled JPEG 2000 images in a single operation, improving compatibility.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nconst Sharp = function (input, options) {\n // biome-ignore lint/complexity/noArguments: constructor factory\n if (arguments.length === 1 && !is.defined(input)) {\n throw new Error('Invalid input');\n }\n if (!(this instanceof Sharp)) {\n return new Sharp(input, options);\n }\n stream.Duplex.call(this);\n this.options = {\n // resize options\n topOffsetPre: -1,\n leftOffsetPre: -1,\n widthPre: -1,\n heightPre: -1,\n topOffsetPost: -1,\n leftOffsetPost: -1,\n widthPost: -1,\n heightPost: -1,\n width: -1,\n height: -1,\n canvas: 'crop',\n position: 0,\n resizeBackground: [0, 0, 0, 255],\n angle: 0,\n rotationAngle: 0,\n rotationBackground: [0, 0, 0, 255],\n rotateBefore: false,\n orientBefore: false,\n flip: false,\n flop: false,\n extendTop: 0,\n extendBottom: 0,\n extendLeft: 0,\n extendRight: 0,\n extendBackground: [0, 0, 0, 255],\n extendWith: 'background',\n withoutEnlargement: false,\n withoutReduction: false,\n affineMatrix: [],\n affineBackground: [0, 0, 0, 255],\n affineIdx: 0,\n affineIdy: 0,\n affineOdx: 0,\n affineOdy: 0,\n affineInterpolator: this.constructor.interpolators.bilinear,\n kernel: 'lanczos3',\n fastShrinkOnLoad: true,\n // operations\n tint: [-1, 0, 0, 0],\n flatten: false,\n flattenBackground: [0, 0, 0],\n unflatten: false,\n negate: false,\n negateAlpha: true,\n medianSize: 0,\n blurSigma: 0,\n precision: 'integer',\n minAmpl: 0.2,\n sharpenSigma: 0,\n sharpenM1: 1,\n sharpenM2: 2,\n sharpenX1: 2,\n sharpenY2: 10,\n sharpenY3: 20,\n threshold: 0,\n thresholdGrayscale: true,\n trimBackground: [],\n trimThreshold: -1,\n trimLineArt: false,\n dilateWidth: 0,\n erodeWidth: 0,\n gamma: 0,\n gammaOut: 0,\n greyscale: false,\n normalise: false,\n normaliseLower: 1,\n normaliseUpper: 99,\n claheWidth: 0,\n claheHeight: 0,\n claheMaxSlope: 3,\n brightness: 1,\n saturation: 1,\n hue: 0,\n lightness: 0,\n booleanBufferIn: null,\n booleanFileIn: '',\n joinChannelIn: [],\n extractChannel: -1,\n removeAlpha: false,\n ensureAlpha: -1,\n colourspace: 'srgb',\n colourspacePipeline: 'last',\n composite: [],\n // output\n fileOut: '',\n formatOut: 'input',\n streamOut: false,\n keepMetadata: 0,\n withMetadataOrientation: -1,\n withMetadataDensity: 0,\n withIccProfile: '',\n withExif: {},\n withExifMerge: true,\n withXmp: '',\n resolveWithObject: false,\n loop: -1,\n delay: [],\n // output format\n jpegQuality: 80,\n jpegProgressive: false,\n jpegChromaSubsampling: '4:2:0',\n jpegTrellisQuantisation: false,\n jpegOvershootDeringing: false,\n jpegOptimiseScans: false,\n jpegOptimiseCoding: true,\n jpegQuantisationTable: 0,\n pngProgressive: false,\n pngCompressionLevel: 6,\n pngAdaptiveFiltering: false,\n pngPalette: false,\n pngQuality: 100,\n pngEffort: 7,\n pngBitdepth: 8,\n pngDither: 1,\n jp2Quality: 80,\n jp2TileHeight: 512,\n jp2TileWidth: 512,\n jp2Lossless: false,\n jp2ChromaSubsampling: '4:4:4',\n webpQuality: 80,\n webpAlphaQuality: 100,\n webpLossless: false,\n webpNearLossless: false,\n webpSmartSubsample: false,\n webpSmartDeblock: false,\n webpPreset: 'default',\n webpEffort: 4,\n webpMinSize: false,\n webpMixed: false,\n gifBitdepth: 8,\n gifEffort: 7,\n gifDither: 1,\n gifInterFrameMaxError: 0,\n gifInterPaletteMaxError: 3,\n gifKeepDuplicateFrames: false,\n gifReuse: true,\n gifProgressive: false,\n tiffQuality: 80,\n tiffCompression: 'jpeg',\n tiffBigtiff: false,\n tiffPredictor: 'horizontal',\n tiffPyramid: false,\n tiffMiniswhite: false,\n tiffBitdepth: 8,\n tiffTile: false,\n tiffTileHeight: 256,\n tiffTileWidth: 256,\n tiffXres: 1.0,\n tiffYres: 1.0,\n tiffResolutionUnit: 'inch',\n heifQuality: 50,\n heifLossless: false,\n heifCompression: 'av1',\n heifEffort: 4,\n heifChromaSubsampling: '4:4:4',\n heifBitdepth: 8,\n jxlDistance: 1,\n jxlDecodingTier: 0,\n jxlEffort: 7,\n jxlLossless: false,\n rawDepth: 'uchar',\n tileSize: 256,\n tileOverlap: 0,\n tileContainer: 'fs',\n tileLayout: 'dz',\n tileFormat: 'last',\n tileDepth: 'last',\n tileAngle: 0,\n tileSkipBlanks: -1,\n tileBackground: [255, 255, 255, 255],\n tileCentre: false,\n tileId: 'https://example.com/iiif',\n tileBasename: '',\n timeoutSeconds: 0,\n linearA: [],\n linearB: [],\n pdfBackground: [255, 255, 255, 255],\n // Function to notify of libvips warnings\n debuglog: warning => {\n this.emit('warning', warning);\n debuglog(warning);\n },\n // Function to notify of queue length changes\n queueListener\n };\n this.options.input = this._createInputDescriptor(input, options, { allowStream: true });\n return this;\n};\nObject.setPrototypeOf(Sharp.prototype, stream.Duplex.prototype);\nObject.setPrototypeOf(Sharp, stream.Duplex);\n\n/**\n * Take a \"snapshot\" of the Sharp instance, returning a new instance.\n * Cloned instances inherit the input of their parent instance.\n * This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream.\n *\n * @example\n * const pipeline = sharp().rotate();\n * pipeline.clone().resize(800, 600).pipe(firstWritableStream);\n * pipeline.clone().extract({ left: 20, top: 20, width: 100, height: 100 }).pipe(secondWritableStream);\n * readableStream.pipe(pipeline);\n * // firstWritableStream receives auto-rotated, resized readableStream\n * // secondWritableStream receives auto-rotated, extracted region of readableStream\n *\n * @example\n * // Create a pipeline that will download an image, resize it and format it to different files\n * // Using Promises to know when the pipeline is complete\n * const fs = require(\"fs\");\n * const got = require(\"got\");\n * const sharpStream = sharp({ failOn: 'none' });\n *\n * const promises = [];\n *\n * promises.push(\n * sharpStream\n * .clone()\n * .jpeg({ quality: 100 })\n * .toFile(\"originalFile.jpg\")\n * );\n *\n * promises.push(\n * sharpStream\n * .clone()\n * .resize({ width: 500 })\n * .jpeg({ quality: 80 })\n * .toFile(\"optimized-500.jpg\")\n * );\n *\n * promises.push(\n * sharpStream\n * .clone()\n * .resize({ width: 500 })\n * .webp({ quality: 80 })\n * .toFile(\"optimized-500.webp\")\n * );\n *\n * // https://github.com/sindresorhus/got/blob/main/documentation/3-streams.md\n * got.stream(\"https://www.example.com/some-file.jpg\").pipe(sharpStream);\n *\n * Promise.all(promises)\n * .then(res => { console.log(\"Done!\", res); })\n * .catch(err => {\n * console.error(\"Error processing files, let's clean it up\", err);\n * try {\n * fs.unlinkSync(\"originalFile.jpg\");\n * fs.unlinkSync(\"optimized-500.jpg\");\n * fs.unlinkSync(\"optimized-500.webp\");\n * } catch (e) {}\n * });\n *\n * @returns {Sharp}\n */\nfunction clone () {\n // Clone existing options\n const clone = this.constructor.call();\n const { debuglog, queueListener, ...options } = this.options;\n clone.options = structuredClone(options);\n clone.options.debuglog = debuglog;\n clone.options.queueListener = queueListener;\n // Pass 'finish' event to clone for Stream-based input\n if (this._isStreamInput()) {\n this.on('finish', () => {\n // Clone inherits input data\n this._flattenBufferIn();\n clone.options.input.buffer = this.options.input.buffer;\n clone.emit('finish');\n });\n }\n return clone;\n}\nObject.assign(Sharp.prototype, { clone });\n\n/**\n * Export constructor.\n * @module Sharp\n * @private\n */\nmodule.exports = Sharp;\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst is = require('./is');\nconst sharp = require('./sharp');\n\n/**\n * Justification alignment\n * @member\n * @private\n */\nconst align = {\n left: 'low',\n top: 'low',\n low: 'low',\n center: 'centre',\n centre: 'centre',\n right: 'high',\n bottom: 'high',\n high: 'high'\n};\n\nconst inputStreamParameters = [\n // Limits and error handling\n 'failOn', 'limitInputPixels', 'unlimited',\n // Format-generic\n 'animated', 'autoOrient', 'density', 'ignoreIcc', 'page', 'pages', 'sequentialRead',\n // Format-specific\n 'jp2', 'openSlide', 'pdf', 'raw', 'svg', 'tiff',\n // Deprecated\n 'failOnError', 'openSlideLevel', 'pdfBackground', 'tiffSubifd'\n];\n\n/**\n * Extract input options, if any, from an object.\n * @private\n */\nfunction _inputOptionsFromObject (obj) {\n const params = inputStreamParameters\n .filter(p => is.defined(obj[p]))\n .map(p => ([p, obj[p]]));\n return params.length\n ? Object.fromEntries(params)\n : undefined;\n}\n\n/**\n * Create Object containing input and input-related options.\n * @private\n */\nfunction _createInputDescriptor (input, inputOptions, containerOptions) {\n const inputDescriptor = {\n autoOrient: false,\n failOn: 'warning',\n limitInputPixels: 0x3FFF ** 2,\n ignoreIcc: false,\n unlimited: false,\n sequentialRead: true\n };\n if (is.string(input)) {\n // filesystem\n inputDescriptor.file = input;\n } else if (is.buffer(input)) {\n // Buffer\n if (input.length === 0) {\n throw Error('Input Buffer is empty');\n }\n inputDescriptor.buffer = input;\n } else if (is.arrayBuffer(input)) {\n if (input.byteLength === 0) {\n throw Error('Input bit Array is empty');\n }\n inputDescriptor.buffer = Buffer.from(input, 0, input.byteLength);\n } else if (is.typedArray(input)) {\n if (input.length === 0) {\n throw Error('Input Bit Array is empty');\n }\n inputDescriptor.buffer = Buffer.from(input.buffer, input.byteOffset, input.byteLength);\n } else if (is.plainObject(input) && !is.defined(inputOptions)) {\n // Plain Object descriptor, e.g. create\n inputOptions = input;\n if (_inputOptionsFromObject(inputOptions)) {\n // Stream with options\n inputDescriptor.buffer = [];\n }\n } else if (!is.defined(input) && !is.defined(inputOptions) && is.object(containerOptions) && containerOptions.allowStream) {\n // Stream without options\n inputDescriptor.buffer = [];\n } else if (Array.isArray(input)) {\n if (input.length > 1) {\n // Join images together\n if (!this.options.joining) {\n this.options.joining = true;\n this.options.join = input.map(i => this._createInputDescriptor(i));\n } else {\n throw new Error('Recursive join is unsupported');\n }\n } else {\n throw new Error('Expected at least two images to join');\n }\n } else {\n throw new Error(`Unsupported input '${input}' of type ${typeof input}${\n is.defined(inputOptions) ? ` when also providing options of type ${typeof inputOptions}` : ''\n }`);\n }\n if (is.object(inputOptions)) {\n // Deprecated: failOnError\n if (is.defined(inputOptions.failOnError)) {\n if (is.bool(inputOptions.failOnError)) {\n inputDescriptor.failOn = inputOptions.failOnError ? 'warning' : 'none';\n } else {\n throw is.invalidParameterError('failOnError', 'boolean', inputOptions.failOnError);\n }\n }\n // failOn\n if (is.defined(inputOptions.failOn)) {\n if (is.string(inputOptions.failOn) && is.inArray(inputOptions.failOn, ['none', 'truncated', 'error', 'warning'])) {\n inputDescriptor.failOn = inputOptions.failOn;\n } else {\n throw is.invalidParameterError('failOn', 'one of: none, truncated, error, warning', inputOptions.failOn);\n }\n }\n // autoOrient\n if (is.defined(inputOptions.autoOrient)) {\n if (is.bool(inputOptions.autoOrient)) {\n inputDescriptor.autoOrient = inputOptions.autoOrient;\n } else {\n throw is.invalidParameterError('autoOrient', 'boolean', inputOptions.autoOrient);\n }\n }\n // Density\n if (is.defined(inputOptions.density)) {\n if (is.inRange(inputOptions.density, 1, 100000)) {\n inputDescriptor.density = inputOptions.density;\n } else {\n throw is.invalidParameterError('density', 'number between 1 and 100000', inputOptions.density);\n }\n }\n // Ignore embeddded ICC profile\n if (is.defined(inputOptions.ignoreIcc)) {\n if (is.bool(inputOptions.ignoreIcc)) {\n inputDescriptor.ignoreIcc = inputOptions.ignoreIcc;\n } else {\n throw is.invalidParameterError('ignoreIcc', 'boolean', inputOptions.ignoreIcc);\n }\n }\n // limitInputPixels\n if (is.defined(inputOptions.limitInputPixels)) {\n if (is.bool(inputOptions.limitInputPixels)) {\n inputDescriptor.limitInputPixels = inputOptions.limitInputPixels\n ? 0x3FFF ** 2\n : 0;\n } else if (is.integer(inputOptions.limitInputPixels) && is.inRange(inputOptions.limitInputPixels, 0, Number.MAX_SAFE_INTEGER)) {\n inputDescriptor.limitInputPixels = inputOptions.limitInputPixels;\n } else {\n throw is.invalidParameterError('limitInputPixels', 'positive integer', inputOptions.limitInputPixels);\n }\n }\n // unlimited\n if (is.defined(inputOptions.unlimited)) {\n if (is.bool(inputOptions.unlimited)) {\n inputDescriptor.unlimited = inputOptions.unlimited;\n } else {\n throw is.invalidParameterError('unlimited', 'boolean', inputOptions.unlimited);\n }\n }\n // sequentialRead\n if (is.defined(inputOptions.sequentialRead)) {\n if (is.bool(inputOptions.sequentialRead)) {\n inputDescriptor.sequentialRead = inputOptions.sequentialRead;\n } else {\n throw is.invalidParameterError('sequentialRead', 'boolean', inputOptions.sequentialRead);\n }\n }\n // Raw pixel input\n if (is.defined(inputOptions.raw)) {\n if (\n is.object(inputOptions.raw) &&\n is.integer(inputOptions.raw.width) && inputOptions.raw.width > 0 &&\n is.integer(inputOptions.raw.height) && inputOptions.raw.height > 0 &&\n is.integer(inputOptions.raw.channels) && is.inRange(inputOptions.raw.channels, 1, 4)\n ) {\n inputDescriptor.rawWidth = inputOptions.raw.width;\n inputDescriptor.rawHeight = inputOptions.raw.height;\n inputDescriptor.rawChannels = inputOptions.raw.channels;\n switch (input.constructor) {\n case Uint8Array:\n case Uint8ClampedArray:\n inputDescriptor.rawDepth = 'uchar';\n break;\n case Int8Array:\n inputDescriptor.rawDepth = 'char';\n break;\n case Uint16Array:\n inputDescriptor.rawDepth = 'ushort';\n break;\n case Int16Array:\n inputDescriptor.rawDepth = 'short';\n break;\n case Uint32Array:\n inputDescriptor.rawDepth = 'uint';\n break;\n case Int32Array:\n inputDescriptor.rawDepth = 'int';\n break;\n case Float32Array:\n inputDescriptor.rawDepth = 'float';\n break;\n case Float64Array:\n inputDescriptor.rawDepth = 'double';\n break;\n default:\n inputDescriptor.rawDepth = 'uchar';\n break;\n }\n } else {\n throw new Error('Expected width, height and channels for raw pixel input');\n }\n inputDescriptor.rawPremultiplied = false;\n if (is.defined(inputOptions.raw.premultiplied)) {\n if (is.bool(inputOptions.raw.premultiplied)) {\n inputDescriptor.rawPremultiplied = inputOptions.raw.premultiplied;\n } else {\n throw is.invalidParameterError('raw.premultiplied', 'boolean', inputOptions.raw.premultiplied);\n }\n }\n inputDescriptor.rawPageHeight = 0;\n if (is.defined(inputOptions.raw.pageHeight)) {\n if (is.integer(inputOptions.raw.pageHeight) && inputOptions.raw.pageHeight > 0 && inputOptions.raw.pageHeight <= inputOptions.raw.height) {\n if (inputOptions.raw.height % inputOptions.raw.pageHeight !== 0) {\n throw new Error(`Expected raw.height ${inputOptions.raw.height} to be a multiple of raw.pageHeight ${inputOptions.raw.pageHeight}`);\n }\n inputDescriptor.rawPageHeight = inputOptions.raw.pageHeight;\n } else {\n throw is.invalidParameterError('raw.pageHeight', 'positive integer', inputOptions.raw.pageHeight);\n }\n }\n }\n // Multi-page input (GIF, TIFF, PDF)\n if (is.defined(inputOptions.animated)) {\n if (is.bool(inputOptions.animated)) {\n inputDescriptor.pages = inputOptions.animated ? -1 : 1;\n } else {\n throw is.invalidParameterError('animated', 'boolean', inputOptions.animated);\n }\n }\n if (is.defined(inputOptions.pages)) {\n if (is.integer(inputOptions.pages) && is.inRange(inputOptions.pages, -1, 100000)) {\n inputDescriptor.pages = inputOptions.pages;\n } else {\n throw is.invalidParameterError('pages', 'integer between -1 and 100000', inputOptions.pages);\n }\n }\n if (is.defined(inputOptions.page)) {\n if (is.integer(inputOptions.page) && is.inRange(inputOptions.page, 0, 100000)) {\n inputDescriptor.page = inputOptions.page;\n } else {\n throw is.invalidParameterError('page', 'integer between 0 and 100000', inputOptions.page);\n }\n }\n // OpenSlide specific options\n if (is.object(inputOptions.openSlide) && is.defined(inputOptions.openSlide.level)) {\n if (is.integer(inputOptions.openSlide.level) && is.inRange(inputOptions.openSlide.level, 0, 256)) {\n inputDescriptor.openSlideLevel = inputOptions.openSlide.level;\n } else {\n throw is.invalidParameterError('openSlide.level', 'integer between 0 and 256', inputOptions.openSlide.level);\n }\n } else if (is.defined(inputOptions.level)) {\n // Deprecated\n if (is.integer(inputOptions.level) && is.inRange(inputOptions.level, 0, 256)) {\n inputDescriptor.openSlideLevel = inputOptions.level;\n } else {\n throw is.invalidParameterError('level', 'integer between 0 and 256', inputOptions.level);\n }\n }\n // TIFF specific options\n if (is.object(inputOptions.tiff) && is.defined(inputOptions.tiff.subifd)) {\n if (is.integer(inputOptions.tiff.subifd) && is.inRange(inputOptions.tiff.subifd, -1, 100000)) {\n inputDescriptor.tiffSubifd = inputOptions.tiff.subifd;\n } else {\n throw is.invalidParameterError('tiff.subifd', 'integer between -1 and 100000', inputOptions.tiff.subifd);\n }\n } else if (is.defined(inputOptions.subifd)) {\n // Deprecated\n if (is.integer(inputOptions.subifd) && is.inRange(inputOptions.subifd, -1, 100000)) {\n inputDescriptor.tiffSubifd = inputOptions.subifd;\n } else {\n throw is.invalidParameterError('subifd', 'integer between -1 and 100000', inputOptions.subifd);\n }\n }\n // SVG specific options\n if (is.object(inputOptions.svg)) {\n if (is.defined(inputOptions.svg.stylesheet)) {\n if (is.string(inputOptions.svg.stylesheet)) {\n inputDescriptor.svgStylesheet = inputOptions.svg.stylesheet;\n } else {\n throw is.invalidParameterError('svg.stylesheet', 'string', inputOptions.svg.stylesheet);\n }\n }\n if (is.defined(inputOptions.svg.highBitdepth)) {\n if (is.bool(inputOptions.svg.highBitdepth)) {\n inputDescriptor.svgHighBitdepth = inputOptions.svg.highBitdepth;\n } else {\n throw is.invalidParameterError('svg.highBitdepth', 'boolean', inputOptions.svg.highBitdepth);\n }\n }\n }\n // PDF specific options\n if (is.object(inputOptions.pdf) && is.defined(inputOptions.pdf.background)) {\n inputDescriptor.pdfBackground = this._getBackgroundColourOption(inputOptions.pdf.background);\n } else if (is.defined(inputOptions.pdfBackground)) {\n // Deprecated\n inputDescriptor.pdfBackground = this._getBackgroundColourOption(inputOptions.pdfBackground);\n }\n // JPEG 2000 specific options\n if (is.object(inputOptions.jp2) && is.defined(inputOptions.jp2.oneshot)) {\n if (is.bool(inputOptions.jp2.oneshot)) {\n inputDescriptor.jp2Oneshot = inputOptions.jp2.oneshot;\n } else {\n throw is.invalidParameterError('jp2.oneshot', 'boolean', inputOptions.jp2.oneshot);\n }\n }\n // Create new image\n if (is.defined(inputOptions.create)) {\n if (\n is.object(inputOptions.create) &&\n is.integer(inputOptions.create.width) && inputOptions.create.width > 0 &&\n is.integer(inputOptions.create.height) && inputOptions.create.height > 0 &&\n is.integer(inputOptions.create.channels)\n ) {\n inputDescriptor.createWidth = inputOptions.create.width;\n inputDescriptor.createHeight = inputOptions.create.height;\n inputDescriptor.createChannels = inputOptions.create.channels;\n inputDescriptor.createPageHeight = 0;\n if (is.defined(inputOptions.create.pageHeight)) {\n if (is.integer(inputOptions.create.pageHeight) && inputOptions.create.pageHeight > 0 && inputOptions.create.pageHeight <= inputOptions.create.height) {\n if (inputOptions.create.height % inputOptions.create.pageHeight !== 0) {\n throw new Error(`Expected create.height ${inputOptions.create.height} to be a multiple of create.pageHeight ${inputOptions.create.pageHeight}`);\n }\n inputDescriptor.createPageHeight = inputOptions.create.pageHeight;\n } else {\n throw is.invalidParameterError('create.pageHeight', 'positive integer', inputOptions.create.pageHeight);\n }\n }\n // Noise\n if (is.defined(inputOptions.create.noise)) {\n if (!is.object(inputOptions.create.noise)) {\n throw new Error('Expected noise to be an object');\n }\n if (inputOptions.create.noise.type !== 'gaussian') {\n throw new Error('Only gaussian noise is supported at the moment');\n }\n inputDescriptor.createNoiseType = inputOptions.create.noise.type;\n if (!is.inRange(inputOptions.create.channels, 1, 4)) {\n throw is.invalidParameterError('create.channels', 'number between 1 and 4', inputOptions.create.channels);\n }\n inputDescriptor.createNoiseMean = 128;\n if (is.defined(inputOptions.create.noise.mean)) {\n if (is.number(inputOptions.create.noise.mean) && is.inRange(inputOptions.create.noise.mean, 0, 10000)) {\n inputDescriptor.createNoiseMean = inputOptions.create.noise.mean;\n } else {\n throw is.invalidParameterError('create.noise.mean', 'number between 0 and 10000', inputOptions.create.noise.mean);\n }\n }\n inputDescriptor.createNoiseSigma = 30;\n if (is.defined(inputOptions.create.noise.sigma)) {\n if (is.number(inputOptions.create.noise.sigma) && is.inRange(inputOptions.create.noise.sigma, 0, 10000)) {\n inputDescriptor.createNoiseSigma = inputOptions.create.noise.sigma;\n } else {\n throw is.invalidParameterError('create.noise.sigma', 'number between 0 and 10000', inputOptions.create.noise.sigma);\n }\n }\n } else if (is.defined(inputOptions.create.background)) {\n if (!is.inRange(inputOptions.create.channels, 3, 4)) {\n throw is.invalidParameterError('create.channels', 'number between 3 and 4', inputOptions.create.channels);\n }\n inputDescriptor.createBackground = this._getBackgroundColourOption(inputOptions.create.background);\n } else {\n throw new Error('Expected valid noise or background to create a new input image');\n }\n delete inputDescriptor.buffer;\n } else {\n throw new Error('Expected valid width, height and channels to create a new input image');\n }\n }\n // Create a new image with text\n if (is.defined(inputOptions.text)) {\n if (is.object(inputOptions.text) && is.string(inputOptions.text.text)) {\n inputDescriptor.textValue = inputOptions.text.text;\n if (is.defined(inputOptions.text.height) && is.defined(inputOptions.text.dpi)) {\n throw new Error('Expected only one of dpi or height');\n }\n if (is.defined(inputOptions.text.font)) {\n if (is.string(inputOptions.text.font)) {\n inputDescriptor.textFont = inputOptions.text.font;\n } else {\n throw is.invalidParameterError('text.font', 'string', inputOptions.text.font);\n }\n }\n if (is.defined(inputOptions.text.fontfile)) {\n if (is.string(inputOptions.text.fontfile)) {\n inputDescriptor.textFontfile = inputOptions.text.fontfile;\n } else {\n throw is.invalidParameterError('text.fontfile', 'string', inputOptions.text.fontfile);\n }\n }\n if (is.defined(inputOptions.text.width)) {\n if (is.integer(inputOptions.text.width) && inputOptions.text.width > 0) {\n inputDescriptor.textWidth = inputOptions.text.width;\n } else {\n throw is.invalidParameterError('text.width', 'positive integer', inputOptions.text.width);\n }\n }\n if (is.defined(inputOptions.text.height)) {\n if (is.integer(inputOptions.text.height) && inputOptions.text.height > 0) {\n inputDescriptor.textHeight = inputOptions.text.height;\n } else {\n throw is.invalidParameterError('text.height', 'positive integer', inputOptions.text.height);\n }\n }\n if (is.defined(inputOptions.text.align)) {\n if (is.string(inputOptions.text.align) && is.string(this.constructor.align[inputOptions.text.align])) {\n inputDescriptor.textAlign = this.constructor.align[inputOptions.text.align];\n } else {\n throw is.invalidParameterError('text.align', 'valid alignment', inputOptions.text.align);\n }\n }\n if (is.defined(inputOptions.text.justify)) {\n if (is.bool(inputOptions.text.justify)) {\n inputDescriptor.textJustify = inputOptions.text.justify;\n } else {\n throw is.invalidParameterError('text.justify', 'boolean', inputOptions.text.justify);\n }\n }\n if (is.defined(inputOptions.text.dpi)) {\n if (is.integer(inputOptions.text.dpi) && is.inRange(inputOptions.text.dpi, 1, 1000000)) {\n inputDescriptor.textDpi = inputOptions.text.dpi;\n } else {\n throw is.invalidParameterError('text.dpi', 'integer between 1 and 1000000', inputOptions.text.dpi);\n }\n }\n if (is.defined(inputOptions.text.rgba)) {\n if (is.bool(inputOptions.text.rgba)) {\n inputDescriptor.textRgba = inputOptions.text.rgba;\n } else {\n throw is.invalidParameterError('text.rgba', 'bool', inputOptions.text.rgba);\n }\n }\n if (is.defined(inputOptions.text.spacing)) {\n if (is.integer(inputOptions.text.spacing) && is.inRange(inputOptions.text.spacing, -1000000, 1000000)) {\n inputDescriptor.textSpacing = inputOptions.text.spacing;\n } else {\n throw is.invalidParameterError('text.spacing', 'integer between -1000000 and 1000000', inputOptions.text.spacing);\n }\n }\n if (is.defined(inputOptions.text.wrap)) {\n if (is.string(inputOptions.text.wrap) && is.inArray(inputOptions.text.wrap, ['word', 'char', 'word-char', 'none'])) {\n inputDescriptor.textWrap = inputOptions.text.wrap;\n } else {\n throw is.invalidParameterError('text.wrap', 'one of: word, char, word-char, none', inputOptions.text.wrap);\n }\n }\n delete inputDescriptor.buffer;\n } else {\n throw new Error('Expected a valid string to create an image with text.');\n }\n }\n // Join images together\n if (is.defined(inputOptions.join)) {\n if (is.defined(this.options.join)) {\n if (is.defined(inputOptions.join.animated)) {\n if (is.bool(inputOptions.join.animated)) {\n inputDescriptor.joinAnimated = inputOptions.join.animated;\n } else {\n throw is.invalidParameterError('join.animated', 'boolean', inputOptions.join.animated);\n }\n }\n if (is.defined(inputOptions.join.across)) {\n if (is.integer(inputOptions.join.across) && is.inRange(inputOptions.join.across, 1, 1000000)) {\n inputDescriptor.joinAcross = inputOptions.join.across;\n } else {\n throw is.invalidParameterError('join.across', 'integer between 1 and 100000', inputOptions.join.across);\n }\n }\n if (is.defined(inputOptions.join.shim)) {\n if (is.integer(inputOptions.join.shim) && is.inRange(inputOptions.join.shim, 0, 1000000)) {\n inputDescriptor.joinShim = inputOptions.join.shim;\n } else {\n throw is.invalidParameterError('join.shim', 'integer between 0 and 100000', inputOptions.join.shim);\n }\n }\n if (is.defined(inputOptions.join.background)) {\n inputDescriptor.joinBackground = this._getBackgroundColourOption(inputOptions.join.background);\n }\n if (is.defined(inputOptions.join.halign)) {\n if (is.string(inputOptions.join.halign) && is.string(this.constructor.align[inputOptions.join.halign])) {\n inputDescriptor.joinHalign = this.constructor.align[inputOptions.join.halign];\n } else {\n throw is.invalidParameterError('join.halign', 'valid alignment', inputOptions.join.halign);\n }\n }\n if (is.defined(inputOptions.join.valign)) {\n if (is.string(inputOptions.join.valign) && is.string(this.constructor.align[inputOptions.join.valign])) {\n inputDescriptor.joinValign = this.constructor.align[inputOptions.join.valign];\n } else {\n throw is.invalidParameterError('join.valign', 'valid alignment', inputOptions.join.valign);\n }\n }\n } else {\n throw new Error('Expected input to be an array of images to join');\n }\n }\n } else if (is.defined(inputOptions)) {\n throw new Error(`Invalid input options ${inputOptions}`);\n }\n return inputDescriptor;\n}\n\n/**\n * Handle incoming Buffer chunk on Writable Stream.\n * @private\n * @param {Buffer} chunk\n * @param {string} encoding - unused\n * @param {Function} callback\n */\nfunction _write (chunk, _encoding, callback) {\n if (Array.isArray(this.options.input.buffer)) {\n if (is.buffer(chunk)) {\n if (this.options.input.buffer.length === 0) {\n this.on('finish', () => {\n this.streamInFinished = true;\n });\n }\n this.options.input.buffer.push(chunk);\n callback();\n } else {\n callback(new Error('Non-Buffer data on Writable Stream'));\n }\n } else {\n callback(new Error('Unexpected data on Writable Stream'));\n }\n}\n\n/**\n * Flattens the array of chunks accumulated in input.buffer.\n * @private\n */\nfunction _flattenBufferIn () {\n if (this._isStreamInput()) {\n this.options.input.buffer = Buffer.concat(this.options.input.buffer);\n }\n}\n\n/**\n * Are we expecting Stream-based input?\n * @private\n * @returns {boolean}\n */\nfunction _isStreamInput () {\n return Array.isArray(this.options.input.buffer);\n}\n\n/**\n * Fast access to (uncached) image metadata without decoding any compressed pixel data.\n *\n * This is read from the header of the input image.\n * It does not take into consideration any operations to be applied to the output image,\n * such as resize or rotate.\n *\n * Dimensions in the response will respect the `page` and `pages` properties of the\n * {@link /api-constructor/ constructor parameters}.\n *\n * A `Promise` is returned when `callback` is not provided.\n *\n * - `format`: Name of decoder used to decompress image data e.g. `jpeg`, `png`, `webp`, `gif`, `svg`\n * - `size`: Total size of image in bytes, for Stream and Buffer input only\n * - `width`: Number of pixels wide (EXIF orientation is not taken into consideration, see example below)\n * - `height`: Number of pixels high (EXIF orientation is not taken into consideration, see example below)\n * - `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/enum.Interpretation.html)\n * - `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK\n * - `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...](https://www.libvips.org/API/current/enum.BandFormat.html)\n * - `density`: Number of pixels per inch (DPI), if present\n * - `chromaSubsampling`: String containing JPEG chroma subsampling, `4:2:0` or `4:4:4` for RGB, `4:2:0:4` or `4:4:4:4` for CMYK\n * - `isProgressive`: Boolean indicating whether the image is interlaced using a progressive scan\n * - `isPalette`: Boolean indicating whether the image is palette-based (GIF, PNG).\n * - `bitsPerSample`: Number of bits per sample for each channel (GIF, PNG, HEIF).\n * - `pages`: Number of pages/frames contained within the image, with support for TIFF, HEIF, PDF, animated GIF and animated WebP\n * - `pageHeight`: Number of pixels high each page in a multi-page image will be.\n * - `loop`: Number of times to loop an animated image, zero refers to a continuous loop.\n * - `delay`: Delay in ms between each page in an animated image, provided as an array of integers.\n * - `pagePrimary`: Number of the primary page in a HEIF image\n * - `levels`: Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide\n * - `subifds`: Number of Sub Image File Directories in an OME-TIFF image\n * - `background`: Default background colour, if present, for PNG (bKGD) and GIF images\n * - `compression`: The encoder used to compress an HEIF file, `av1` (AVIF) or `hevc` (HEIC)\n * - `resolutionUnit`: The unit of resolution (density), either `inch` or `cm`, if present\n * - `hasProfile`: Boolean indicating the presence of an embedded ICC profile\n * - `hasAlpha`: Boolean indicating the presence of an alpha transparency channel\n * - `orientation`: Number value of the EXIF Orientation header, if present\n * - `exif`: Buffer containing raw EXIF data, if present\n * - `icc`: Buffer containing raw [ICC](https://www.npmjs.com/package/icc) profile data, if present\n * - `iptc`: Buffer containing raw IPTC data, if present\n * - `xmp`: Buffer containing raw XMP data, if present\n * - `xmpAsString`: String containing XMP data, if valid UTF-8.\n * - `tifftagPhotoshop`: Buffer containing raw TIFFTAG_PHOTOSHOP data, if present\n * - `formatMagick`: String containing format for images loaded via *magick\n * - `comments`: Array of keyword/text pairs representing PNG text blocks, if present.\n *\n * @example\n * const metadata = await sharp(input).metadata();\n *\n * @example\n * const image = sharp(inputJpg);\n * image\n * .metadata()\n * .then(function(metadata) {\n * return image\n * .resize(Math.round(metadata.width / 2))\n * .webp()\n * .toBuffer();\n * })\n * .then(function(data) {\n * // data contains a WebP image half the width and height of the original JPEG\n * });\n *\n * @example\n * // Get dimensions taking EXIF Orientation into account.\n * const { autoOrient } = await sharp(input).metadata();\n * const { width, height } = autoOrient;\n *\n * @param {Function} [callback] - called with the arguments `(err, metadata)`\n * @returns {Promise<Object>|Sharp}\n */\nfunction metadata (callback) {\n const stack = Error();\n if (is.fn(callback)) {\n if (this._isStreamInput()) {\n this.on('finish', () => {\n this._flattenBufferIn();\n sharp.metadata(this.options, (err, metadata) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, metadata);\n }\n });\n });\n } else {\n sharp.metadata(this.options, (err, metadata) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, metadata);\n }\n });\n }\n return this;\n } else {\n if (this._isStreamInput()) {\n return new Promise((resolve, reject) => {\n const finished = () => {\n this._flattenBufferIn();\n sharp.metadata(this.options, (err, metadata) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n resolve(metadata);\n }\n });\n };\n if (this.writableFinished) {\n finished();\n } else {\n this.once('finish', finished);\n }\n });\n } else {\n return new Promise((resolve, reject) => {\n sharp.metadata(this.options, (err, metadata) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n resolve(metadata);\n }\n });\n });\n }\n }\n}\n\n/**\n * Access to pixel-derived image statistics for every channel in the image.\n * A `Promise` is returned when `callback` is not provided.\n *\n * - `channels`: Array of channel statistics for each channel in the image. Each channel statistic contains\n * - `min` (minimum value in the channel)\n * - `max` (maximum value in the channel)\n * - `sum` (sum of all values in a channel)\n * - `squaresSum` (sum of squared values in a channel)\n * - `mean` (mean of the values in a channel)\n * - `stdev` (standard deviation for the values in a channel)\n * - `minX` (x-coordinate of one of the pixel where the minimum lies)\n * - `minY` (y-coordinate of one of the pixel where the minimum lies)\n * - `maxX` (x-coordinate of one of the pixel where the maximum lies)\n * - `maxY` (y-coordinate of one of the pixel where the maximum lies)\n * - `isOpaque`: Is the image fully opaque? Will be `true` if the image has no alpha channel or if every pixel is fully opaque.\n * - `entropy`: Histogram-based estimation of greyscale entropy, discarding alpha channel if any.\n * - `sharpness`: Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any.\n * - `dominant`: Object containing most dominant sRGB colour based on a 4096-bin 3D histogram.\n *\n * **Note**: Statistics are derived from the original input image. Any operations performed on the image must first be\n * written to a buffer in order to run `stats` on the result (see third example).\n *\n * @example\n * const image = sharp(inputJpg);\n * image\n * .stats()\n * .then(function(stats) {\n * // stats contains the channel-wise statistics array and the isOpaque value\n * });\n *\n * @example\n * const { entropy, sharpness, dominant } = await sharp(input).stats();\n * const { r, g, b } = dominant;\n *\n * @example\n * const image = sharp(input);\n * // store intermediate result\n * const part = await image.extract(region).toBuffer();\n * // create new instance to obtain statistics of extracted region\n * const stats = await sharp(part).stats();\n *\n * @param {Function} [callback] - called with the arguments `(err, stats)`\n * @returns {Promise<Object>}\n */\nfunction stats (callback) {\n const stack = Error();\n if (is.fn(callback)) {\n if (this._isStreamInput()) {\n this.on('finish', () => {\n this._flattenBufferIn();\n sharp.stats(this.options, (err, stats) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, stats);\n }\n });\n });\n } else {\n sharp.stats(this.options, (err, stats) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, stats);\n }\n });\n }\n return this;\n } else {\n if (this._isStreamInput()) {\n return new Promise((resolve, reject) => {\n this.on('finish', function () {\n this._flattenBufferIn();\n sharp.stats(this.options, (err, stats) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n resolve(stats);\n }\n });\n });\n });\n } else {\n return new Promise((resolve, reject) => {\n sharp.stats(this.options, (err, stats) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n resolve(stats);\n }\n });\n });\n }\n }\n}\n\n/**\n * Decorate the Sharp prototype with input-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n // Private\n _inputOptionsFromObject,\n _createInputDescriptor,\n _write,\n _flattenBufferIn,\n _isStreamInput,\n // Public\n metadata,\n stats\n });\n // Class attributes\n Sharp.align = align;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst is = require('./is');\n\n/**\n * Weighting to apply when using contain/cover fit.\n * @member\n * @private\n */\nconst gravity = {\n center: 0,\n centre: 0,\n north: 1,\n east: 2,\n south: 3,\n west: 4,\n northeast: 5,\n southeast: 6,\n southwest: 7,\n northwest: 8\n};\n\n/**\n * Position to apply when using contain/cover fit.\n * @member\n * @private\n */\nconst position = {\n top: 1,\n right: 2,\n bottom: 3,\n left: 4,\n 'right top': 5,\n 'right bottom': 6,\n 'left bottom': 7,\n 'left top': 8\n};\n\n/**\n * How to extend the image.\n * @member\n * @private\n */\nconst extendWith = {\n background: 'background',\n copy: 'copy',\n repeat: 'repeat',\n mirror: 'mirror'\n};\n\n/**\n * Strategies for automagic cover behaviour.\n * @member\n * @private\n */\nconst strategy = {\n entropy: 16,\n attention: 17\n};\n\n/**\n * Reduction kernels.\n * @member\n * @private\n */\nconst kernel = {\n nearest: 'nearest',\n linear: 'linear',\n cubic: 'cubic',\n mitchell: 'mitchell',\n lanczos2: 'lanczos2',\n lanczos3: 'lanczos3',\n mks2013: 'mks2013',\n mks2021: 'mks2021'\n};\n\n/**\n * Methods by which an image can be resized to fit the provided dimensions.\n * @member\n * @private\n */\nconst fit = {\n contain: 'contain',\n cover: 'cover',\n fill: 'fill',\n inside: 'inside',\n outside: 'outside'\n};\n\n/**\n * Map external fit property to internal canvas property.\n * @member\n * @private\n */\nconst mapFitToCanvas = {\n contain: 'embed',\n cover: 'crop',\n fill: 'ignore_aspect',\n inside: 'max',\n outside: 'min'\n};\n\n/**\n * @private\n */\nfunction isRotationExpected (options) {\n return (options.angle % 360) !== 0 || options.rotationAngle !== 0;\n}\n\n/**\n * @private\n */\nfunction isResizeExpected (options) {\n return options.width !== -1 || options.height !== -1;\n}\n\n/**\n * Resize image to `width`, `height` or `width x height`.\n *\n * When both a `width` and `height` are provided, the possible methods by which the image should **fit** these are:\n * - `cover`: (default) Preserving aspect ratio, attempt to ensure the image covers both provided dimensions by cropping/clipping to fit.\n * - `contain`: Preserving aspect ratio, contain within both provided dimensions using \"letterboxing\" where necessary.\n * - `fill`: Ignore the aspect ratio of the input and stretch to both provided dimensions.\n * - `inside`: Preserving aspect ratio, resize the image to be as large as possible while ensuring its dimensions are less than or equal to both those specified.\n * - `outside`: Preserving aspect ratio, resize the image to be as small as possible while ensuring its dimensions are greater than or equal to both those specified.\n *\n * Some of these values are based on the [object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) CSS property.\n *\n * <img alt=\"Examples of various values for the fit property when resizing\" width=\"100%\" style=\"aspect-ratio: 998/243\" src=\"/api-resize-fit.svg\">\n *\n * When using a **fit** of `cover` or `contain`, the default **position** is `centre`. Other options are:\n * - `sharp.position`: `top`, `right top`, `right`, `right bottom`, `bottom`, `left bottom`, `left`, `left top`.\n * - `sharp.gravity`: `north`, `northeast`, `east`, `southeast`, `south`, `southwest`, `west`, `northwest`, `center` or `centre`.\n * - `sharp.strategy`: `cover` only, dynamically crop using either the `entropy` or `attention` strategy.\n *\n * Some of these values are based on the [object-position](https://developer.mozilla.org/en-US/docs/Web/CSS/object-position) CSS property.\n *\n * The strategy-based approach initially resizes so one dimension is at its target length\n * then repeatedly ranks edge regions, discarding the edge with the lowest score based on the selected strategy.\n * - `entropy`: focus on the region with the highest [Shannon entropy](https://en.wikipedia.org/wiki/Entropy_%28information_theory%29).\n * - `attention`: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.\n *\n * Possible downsizing kernels are:\n * - `nearest`: Use [nearest neighbour interpolation](http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation).\n * - `linear`: Use a [triangle filter](https://en.wikipedia.org/wiki/Triangular_function).\n * - `cubic`: Use a [Catmull-Rom spline](https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline).\n * - `mitchell`: Use a [Mitchell-Netravali spline](https://www.cs.utexas.edu/~fussell/courses/cs384g-fall2013/lectures/mitchell/Mitchell.pdf).\n * - `lanczos2`: Use a [Lanczos kernel](https://en.wikipedia.org/wiki/Lanczos_resampling#Lanczos_kernel) with `a=2`.\n * - `lanczos3`: Use a Lanczos kernel with `a=3` (the default).\n * - `mks2013`: Use a [Magic Kernel Sharp](https://johncostella.com/magic/mks.pdf) 2013 kernel, as adopted by Facebook.\n * - `mks2021`: Use a Magic Kernel Sharp 2021 kernel, with more accurate (reduced) sharpening than the 2013 version.\n *\n * When upsampling, these kernels map to `nearest`, `linear` and `cubic` interpolators.\n * Downsampling kernels without a matching upsampling interpolator map to `cubic`.\n *\n * Only one resize can occur per pipeline.\n * Previous calls to `resize` in the same pipeline will be ignored.\n *\n * @example\n * sharp(input)\n * .resize({ width: 100 })\n * .toBuffer()\n * .then(data => {\n * // 100 pixels wide, auto-scaled height\n * });\n *\n * @example\n * sharp(input)\n * .resize({ height: 100 })\n * .toBuffer()\n * .then(data => {\n * // 100 pixels high, auto-scaled width\n * });\n *\n * @example\n * sharp(input)\n * .resize(200, 300, {\n * kernel: sharp.kernel.nearest,\n * fit: 'contain',\n * position: 'right top',\n * background: { r: 255, g: 255, b: 255, alpha: 0.5 }\n * })\n * .toFile('output.png')\n * .then(() => {\n * // output.png is a 200 pixels wide and 300 pixels high image\n * // containing a nearest-neighbour scaled version\n * // contained within the north-east corner of a semi-transparent white canvas\n * });\n *\n * @example\n * const transformer = sharp()\n * .resize({\n * width: 200,\n * height: 200,\n * fit: sharp.fit.cover,\n * position: sharp.strategy.entropy\n * });\n * // Read image data from readableStream\n * // Write 200px square auto-cropped image data to writableStream\n * readableStream\n * .pipe(transformer)\n * .pipe(writableStream);\n *\n * @example\n * sharp(input)\n * .resize(200, 200, {\n * fit: sharp.fit.inside,\n * withoutEnlargement: true\n * })\n * .toFormat('jpeg')\n * .toBuffer()\n * .then(function(outputBuffer) {\n * // outputBuffer contains JPEG image data\n * // no wider and no higher than 200 pixels\n * // and no larger than the input image\n * });\n *\n * @example\n * sharp(input)\n * .resize(200, 200, {\n * fit: sharp.fit.outside,\n * withoutReduction: true\n * })\n * .toFormat('jpeg')\n * .toBuffer()\n * .then(function(outputBuffer) {\n * // outputBuffer contains JPEG image data\n * // of at least 200 pixels wide and 200 pixels high while maintaining aspect ratio\n * // and no smaller than the input image\n * });\n *\n * @example\n * const scaleByHalf = await sharp(input)\n * .metadata()\n * .then(({ width }) => sharp(input)\n * .resize(Math.round(width * 0.5))\n * .toBuffer()\n * );\n *\n * @param {number} [width] - How many pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height.\n * @param {number} [height] - How many pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.\n * @param {Object} [options]\n * @param {number} [options.width] - An alternative means of specifying `width`. If both are present this takes priority.\n * @param {number} [options.height] - An alternative means of specifying `height`. If both are present this takes priority.\n * @param {String} [options.fit='cover'] - How the image should be resized/cropped to fit the target dimension(s), one of `cover`, `contain`, `fill`, `inside` or `outside`.\n * @param {String} [options.position='centre'] - A position, gravity or strategy to use when `fit` is `cover` or `contain`.\n * @param {String|Object} [options.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour when `fit` is `contain`, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency.\n * @param {String} [options.kernel='lanczos3'] - The kernel to use for image reduction and the inferred interpolator to use for upsampling. Use the `fastShrinkOnLoad` option to control kernel vs shrink-on-load.\n * @param {Boolean} [options.withoutEnlargement=false] - Do not scale up if the width *or* height are already less than the target dimensions, equivalent to GraphicsMagick's `>` geometry option. This may result in output dimensions smaller than the target dimensions.\n * @param {Boolean} [options.withoutReduction=false] - Do not scale down if the width *or* height are already greater than the target dimensions, equivalent to GraphicsMagick's `<` geometry option. This may still result in a crop to reach the target dimensions.\n * @param {Boolean} [options.fastShrinkOnLoad=true] - Take greater advantage of the JPEG and WebP shrink-on-load feature, which can lead to a slight moir\u00E9 pattern or round-down of an auto-scaled dimension.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction resize (widthOrOptions, height, options) {\n if (isResizeExpected(this.options)) {\n this.options.debuglog('ignoring previous resize options');\n }\n if (this.options.widthPost !== -1) {\n this.options.debuglog('operation order will be: extract, resize, extract');\n }\n if (is.defined(widthOrOptions)) {\n if (is.object(widthOrOptions) && !is.defined(options)) {\n options = widthOrOptions;\n } else if (is.integer(widthOrOptions) && widthOrOptions > 0) {\n this.options.width = widthOrOptions;\n } else {\n throw is.invalidParameterError('width', 'positive integer', widthOrOptions);\n }\n } else {\n this.options.width = -1;\n }\n if (is.defined(height)) {\n if (is.integer(height) && height > 0) {\n this.options.height = height;\n } else {\n throw is.invalidParameterError('height', 'positive integer', height);\n }\n } else {\n this.options.height = -1;\n }\n if (is.object(options)) {\n // Width\n if (is.defined(options.width)) {\n if (is.integer(options.width) && options.width > 0) {\n this.options.width = options.width;\n } else {\n throw is.invalidParameterError('width', 'positive integer', options.width);\n }\n }\n // Height\n if (is.defined(options.height)) {\n if (is.integer(options.height) && options.height > 0) {\n this.options.height = options.height;\n } else {\n throw is.invalidParameterError('height', 'positive integer', options.height);\n }\n }\n // Fit\n if (is.defined(options.fit)) {\n const canvas = mapFitToCanvas[options.fit];\n if (is.string(canvas)) {\n this.options.canvas = canvas;\n } else {\n throw is.invalidParameterError('fit', 'valid fit', options.fit);\n }\n }\n // Position\n if (is.defined(options.position)) {\n const pos = is.integer(options.position)\n ? options.position\n : strategy[options.position] || position[options.position] || gravity[options.position];\n if (is.integer(pos) && (is.inRange(pos, 0, 8) || is.inRange(pos, 16, 17))) {\n this.options.position = pos;\n } else {\n throw is.invalidParameterError('position', 'valid position/gravity/strategy', options.position);\n }\n }\n // Background\n this._setBackgroundColourOption('resizeBackground', options.background);\n // Kernel\n if (is.defined(options.kernel)) {\n if (is.string(kernel[options.kernel])) {\n this.options.kernel = kernel[options.kernel];\n } else {\n throw is.invalidParameterError('kernel', 'valid kernel name', options.kernel);\n }\n }\n // Without enlargement\n if (is.defined(options.withoutEnlargement)) {\n this._setBooleanOption('withoutEnlargement', options.withoutEnlargement);\n }\n // Without reduction\n if (is.defined(options.withoutReduction)) {\n this._setBooleanOption('withoutReduction', options.withoutReduction);\n }\n // Shrink on load\n if (is.defined(options.fastShrinkOnLoad)) {\n this._setBooleanOption('fastShrinkOnLoad', options.fastShrinkOnLoad);\n }\n }\n if (isRotationExpected(this.options) && isResizeExpected(this.options)) {\n this.options.rotateBefore = true;\n }\n return this;\n}\n\n/**\n * Extend / pad / extrude one or more edges of the image with either\n * the provided background colour or pixels derived from the image.\n * This operation will always occur after resizing and extraction, if any.\n *\n * @example\n * // Resize to 140 pixels wide, then add 10 transparent pixels\n * // to the top, left and right edges and 20 to the bottom edge\n * sharp(input)\n * .resize(140)\n * .extend({\n * top: 10,\n * bottom: 20,\n * left: 10,\n * right: 10,\n * background: { r: 0, g: 0, b: 0, alpha: 0 }\n * })\n * ...\n *\n* @example\n * // Add a row of 10 red pixels to the bottom\n * sharp(input)\n * .extend({\n * bottom: 10,\n * background: 'red'\n * })\n * ...\n *\n * @example\n * // Extrude image by 8 pixels to the right, mirroring existing right hand edge\n * sharp(input)\n * .extend({\n * right: 8,\n * background: 'mirror'\n * })\n * ...\n *\n * @param {(number|Object)} extend - single pixel count to add to all edges or an Object with per-edge counts\n * @param {number} [extend.top=0]\n * @param {number} [extend.left=0]\n * @param {number} [extend.bottom=0]\n * @param {number} [extend.right=0]\n * @param {String} [extend.extendWith='background'] - populate new pixels using this method, one of: background, copy, repeat, mirror.\n * @param {String|Object} [extend.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n*/\nfunction extend (extend) {\n if (is.integer(extend) && extend > 0) {\n this.options.extendTop = extend;\n this.options.extendBottom = extend;\n this.options.extendLeft = extend;\n this.options.extendRight = extend;\n } else if (is.object(extend)) {\n if (is.defined(extend.top)) {\n if (is.integer(extend.top) && extend.top >= 0) {\n this.options.extendTop = extend.top;\n } else {\n throw is.invalidParameterError('top', 'positive integer', extend.top);\n }\n }\n if (is.defined(extend.bottom)) {\n if (is.integer(extend.bottom) && extend.bottom >= 0) {\n this.options.extendBottom = extend.bottom;\n } else {\n throw is.invalidParameterError('bottom', 'positive integer', extend.bottom);\n }\n }\n if (is.defined(extend.left)) {\n if (is.integer(extend.left) && extend.left >= 0) {\n this.options.extendLeft = extend.left;\n } else {\n throw is.invalidParameterError('left', 'positive integer', extend.left);\n }\n }\n if (is.defined(extend.right)) {\n if (is.integer(extend.right) && extend.right >= 0) {\n this.options.extendRight = extend.right;\n } else {\n throw is.invalidParameterError('right', 'positive integer', extend.right);\n }\n }\n this._setBackgroundColourOption('extendBackground', extend.background);\n if (is.defined(extend.extendWith)) {\n if (is.string(extendWith[extend.extendWith])) {\n this.options.extendWith = extendWith[extend.extendWith];\n } else {\n throw is.invalidParameterError('extendWith', 'one of: background, copy, repeat, mirror', extend.extendWith);\n }\n }\n } else {\n throw is.invalidParameterError('extend', 'integer or object', extend);\n }\n return this;\n}\n\n/**\n * Extract/crop a region of the image.\n *\n * - Use `extract` before `resize` for pre-resize extraction.\n * - Use `extract` after `resize` for post-resize extraction.\n * - Use `extract` twice and `resize` once for extract-then-resize-then-extract in a fixed operation order.\n *\n * @example\n * sharp(input)\n * .extract({ left: left, top: top, width: width, height: height })\n * .toFile(output, function(err) {\n * // Extract a region of the input image, saving in the same format.\n * });\n * @example\n * sharp(input)\n * .extract({ left: leftOffsetPre, top: topOffsetPre, width: widthPre, height: heightPre })\n * .resize(width, height)\n * .extract({ left: leftOffsetPost, top: topOffsetPost, width: widthPost, height: heightPost })\n * .toFile(output, function(err) {\n * // Extract a region, resize, then extract from the resized image\n * });\n *\n * @param {Object} options - describes the region to extract using integral pixel values\n * @param {number} options.left - zero-indexed offset from left edge\n * @param {number} options.top - zero-indexed offset from top edge\n * @param {number} options.width - width of region to extract\n * @param {number} options.height - height of region to extract\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction extract (options) {\n const suffix = isResizeExpected(this.options) || this.options.widthPre !== -1 ? 'Post' : 'Pre';\n if (this.options[`width${suffix}`] !== -1) {\n this.options.debuglog('ignoring previous extract options');\n }\n ['left', 'top', 'width', 'height'].forEach(function (name) {\n const value = options[name];\n if (is.integer(value) && value >= 0) {\n this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value;\n } else {\n throw is.invalidParameterError(name, 'integer', value);\n }\n }, this);\n // Ensure existing rotation occurs before pre-resize extraction\n if (isRotationExpected(this.options) && !isResizeExpected(this.options)) {\n if (this.options.widthPre === -1 || this.options.widthPost === -1) {\n this.options.rotateBefore = true;\n }\n }\n if (this.options.input.autoOrient) {\n this.options.orientBefore = true;\n }\n return this;\n}\n\n/**\n * Trim pixels from all edges that contain values similar to the given background colour, which defaults to that of the top-left pixel.\n *\n * Images with an alpha channel will use the combined bounding box of alpha and non-alpha channels.\n *\n * If the result of this operation would trim an image to nothing then no change is made.\n *\n * The `info` response Object will contain `trimOffsetLeft` and `trimOffsetTop` properties.\n *\n * @example\n * // Trim pixels with a colour similar to that of the top-left pixel.\n * await sharp(input)\n * .trim()\n * .toFile(output);\n *\n * @example\n * // Trim pixels with the exact same colour as that of the top-left pixel.\n * await sharp(input)\n * .trim({\n * threshold: 0\n * })\n * .toFile(output);\n *\n * @example\n * // Assume input is line art and trim only pixels with a similar colour to red.\n * const output = await sharp(input)\n * .trim({\n * background: \"#FF0000\",\n * lineArt: true\n * })\n * .toBuffer();\n *\n * @example\n * // Trim all \"yellow-ish\" pixels, being more lenient with the higher threshold.\n * const output = await sharp(input)\n * .trim({\n * background: \"yellow\",\n * threshold: 42,\n * })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {string|Object} [options.background='top-left pixel'] - Background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to that of the top-left pixel.\n * @param {number} [options.threshold=10] - Allowed difference from the above colour, a positive number.\n * @param {boolean} [options.lineArt=false] - Does the input more closely resemble line art (e.g. vector) rather than being photographic?\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction trim (options) {\n this.options.trimThreshold = 10;\n if (is.defined(options)) {\n if (is.object(options)) {\n if (is.defined(options.background)) {\n this._setBackgroundColourOption('trimBackground', options.background);\n }\n if (is.defined(options.threshold)) {\n if (is.number(options.threshold) && options.threshold >= 0) {\n this.options.trimThreshold = options.threshold;\n } else {\n throw is.invalidParameterError('threshold', 'positive number', options.threshold);\n }\n }\n if (is.defined(options.lineArt)) {\n this._setBooleanOption('trimLineArt', options.lineArt);\n }\n } else {\n throw is.invalidParameterError('trim', 'object', options);\n }\n }\n if (isRotationExpected(this.options)) {\n this.options.rotateBefore = true;\n }\n return this;\n}\n\n/**\n * Decorate the Sharp prototype with resize-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n resize,\n extend,\n extract,\n trim\n });\n // Class attributes\n Sharp.gravity = gravity;\n Sharp.strategy = strategy;\n Sharp.kernel = kernel;\n Sharp.fit = fit;\n Sharp.position = position;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst is = require('./is');\n\n/**\n * Blend modes.\n * @member\n * @private\n */\nconst blend = {\n clear: 'clear',\n source: 'source',\n over: 'over',\n in: 'in',\n out: 'out',\n atop: 'atop',\n dest: 'dest',\n 'dest-over': 'dest-over',\n 'dest-in': 'dest-in',\n 'dest-out': 'dest-out',\n 'dest-atop': 'dest-atop',\n xor: 'xor',\n add: 'add',\n saturate: 'saturate',\n multiply: 'multiply',\n screen: 'screen',\n overlay: 'overlay',\n darken: 'darken',\n lighten: 'lighten',\n 'colour-dodge': 'colour-dodge',\n 'color-dodge': 'colour-dodge',\n 'colour-burn': 'colour-burn',\n 'color-burn': 'colour-burn',\n 'hard-light': 'hard-light',\n 'soft-light': 'soft-light',\n difference: 'difference',\n exclusion: 'exclusion'\n};\n\n/**\n * Composite image(s) over the processed (resized, extracted etc.) image.\n *\n * The images to composite must be the same size or smaller than the processed image.\n * If both `top` and `left` options are provided, they take precedence over `gravity`.\n *\n * Other operations in the same processing pipeline (e.g. resize, rotate, flip,\n * flop, extract) will always be applied to the input image before composition.\n *\n * The `blend` option can be one of `clear`, `source`, `over`, `in`, `out`, `atop`,\n * `dest`, `dest-over`, `dest-in`, `dest-out`, `dest-atop`,\n * `xor`, `add`, `saturate`, `multiply`, `screen`, `overlay`, `darken`, `lighten`,\n * `colour-dodge`, `color-dodge`, `colour-burn`,`color-burn`,\n * `hard-light`, `soft-light`, `difference`, `exclusion`.\n *\n * More information about blend modes can be found at\n * https://www.libvips.org/API/current/enum.BlendMode.html\n * and https://www.cairographics.org/operators/\n *\n * @since 0.22.0\n *\n * @example\n * await sharp(background)\n * .composite([\n * { input: layer1, gravity: 'northwest' },\n * { input: layer2, gravity: 'southeast' },\n * ])\n * .toFile('combined.png');\n *\n * @example\n * const output = await sharp('input.gif', { animated: true })\n * .composite([\n * { input: 'overlay.png', tile: true, blend: 'saturate' }\n * ])\n * .toBuffer();\n *\n * @example\n * sharp('input.png')\n * .rotate(180)\n * .resize(300)\n * .flatten( { background: '#ff6600' } )\n * .composite([{ input: 'overlay.png', gravity: 'southeast' }])\n * .sharpen()\n * .withMetadata()\n * .webp( { quality: 90 } )\n * .toBuffer()\n * .then(function(outputBuffer) {\n * // outputBuffer contains upside down, 300px wide, alpha channel flattened\n * // onto orange background, composited with overlay.png with SE gravity,\n * // sharpened, with metadata, 90% quality WebP image data. Phew!\n * });\n *\n * @param {Object[]} images - Ordered list of images to composite\n * @param {Buffer|String} [images[].input] - Buffer containing image data, String containing the path to an image file, or Create object (see below)\n * @param {Object} [images[].input.create] - describes a blank overlay to be created.\n * @param {Number} [images[].input.create.width]\n * @param {Number} [images[].input.create.height]\n * @param {Number} [images[].input.create.channels] - 3-4\n * @param {String|Object} [images[].input.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @param {Object} [images[].input.text] - describes a new text image to be created.\n * @param {string} [images[].input.text.text] - text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`.\n * @param {string} [images[].input.text.font] - font name to render with.\n * @param {string} [images[].input.text.fontfile] - absolute filesystem path to a font file that can be used by `font`.\n * @param {number} [images[].input.text.width=0] - integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries.\n * @param {number} [images[].input.text.height=0] - integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0.\n * @param {string} [images[].input.text.align='left'] - text alignment (`'left'`, `'centre'`, `'center'`, `'right'`).\n * @param {boolean} [images[].input.text.justify=false] - set this to true to apply justification to the text.\n * @param {number} [images[].input.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.\n * @param {boolean} [images[].input.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for Pango markup features like `<span foreground=\"red\">Red!</span>`.\n * @param {number} [images[].input.text.spacing=0] - text line height in points. Will use the font line height if none is specified.\n * @param {Boolean} [images[].autoOrient=false] - set to true to use EXIF orientation data, if present, to orient the image.\n * @param {String} [images[].blend='over'] - how to blend this image with the image below.\n * @param {String} [images[].gravity='centre'] - gravity at which to place the overlay.\n * @param {Number} [images[].top] - the pixel offset from the top edge.\n * @param {Number} [images[].left] - the pixel offset from the left edge.\n * @param {Boolean} [images[].tile=false] - set to true to repeat the overlay image across the entire image with the given `gravity`.\n * @param {Boolean} [images[].premultiplied=false] - set to true to avoid premultiplying the image below. Equivalent to the `--premultiplied` vips option.\n * @param {Number} [images[].density=72] - number representing the DPI for vector overlay image.\n * @param {Object} [images[].raw] - describes overlay when using raw pixel data.\n * @param {Number} [images[].raw.width]\n * @param {Number} [images[].raw.height]\n * @param {Number} [images[].raw.channels]\n * @param {boolean} [images[].animated=false] - Set to `true` to read all frames/pages of an animated image.\n * @param {string} [images[].failOn='warning'] - @see {@link /api-constructor/ constructor parameters}\n * @param {number|boolean} [images[].limitInputPixels=268402689] - @see {@link /api-constructor/ constructor parameters}\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction composite (images) {\n if (!Array.isArray(images)) {\n throw is.invalidParameterError('images to composite', 'array', images);\n }\n this.options.composite = images.map(image => {\n if (!is.object(image)) {\n throw is.invalidParameterError('image to composite', 'object', image);\n }\n const inputOptions = this._inputOptionsFromObject(image);\n const composite = {\n input: this._createInputDescriptor(image.input, inputOptions, { allowStream: false }),\n blend: 'over',\n tile: false,\n left: 0,\n top: 0,\n hasOffset: false,\n gravity: 0,\n premultiplied: false\n };\n if (is.defined(image.blend)) {\n if (is.string(blend[image.blend])) {\n composite.blend = blend[image.blend];\n } else {\n throw is.invalidParameterError('blend', 'valid blend name', image.blend);\n }\n }\n if (is.defined(image.tile)) {\n if (is.bool(image.tile)) {\n composite.tile = image.tile;\n } else {\n throw is.invalidParameterError('tile', 'boolean', image.tile);\n }\n }\n if (is.defined(image.left)) {\n if (is.integer(image.left)) {\n composite.left = image.left;\n } else {\n throw is.invalidParameterError('left', 'integer', image.left);\n }\n }\n if (is.defined(image.top)) {\n if (is.integer(image.top)) {\n composite.top = image.top;\n } else {\n throw is.invalidParameterError('top', 'integer', image.top);\n }\n }\n if (is.defined(image.top) !== is.defined(image.left)) {\n throw new Error('Expected both left and top to be set');\n } else {\n composite.hasOffset = is.integer(image.top) && is.integer(image.left);\n }\n if (is.defined(image.gravity)) {\n if (is.integer(image.gravity) && is.inRange(image.gravity, 0, 8)) {\n composite.gravity = image.gravity;\n } else if (is.string(image.gravity) && is.integer(this.constructor.gravity[image.gravity])) {\n composite.gravity = this.constructor.gravity[image.gravity];\n } else {\n throw is.invalidParameterError('gravity', 'valid gravity', image.gravity);\n }\n }\n if (is.defined(image.premultiplied)) {\n if (is.bool(image.premultiplied)) {\n composite.premultiplied = image.premultiplied;\n } else {\n throw is.invalidParameterError('premultiplied', 'boolean', image.premultiplied);\n }\n }\n return composite;\n });\n return this;\n}\n\n/**\n * Decorate the Sharp prototype with composite-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Sharp.prototype.composite = composite;\n Sharp.blend = blend;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst is = require('./is');\n\n/**\n * How accurate an operation should be.\n * @member\n * @private\n */\nconst vipsPrecision = {\n integer: 'integer',\n float: 'float',\n approximate: 'approximate'\n};\n\n/**\n * Rotate the output image.\n *\n * The provided angle is converted to a valid positive degree rotation.\n * For example, `-450` will produce a 270 degree rotation.\n *\n * When rotating by an angle other than a multiple of 90,\n * the background colour can be provided with the `background` option.\n *\n * For backwards compatibility, if no angle is provided, `.autoOrient()` will be called.\n *\n * Only one rotation can occur per pipeline (aside from an initial call without\n * arguments to orient via EXIF data). Previous calls to `rotate` in the same\n * pipeline will be ignored.\n *\n * Multi-page images can only be rotated by 180 degrees.\n *\n * Method order is important when rotating, resizing and/or extracting regions,\n * for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.\n *\n * @example\n * const rotateThenResize = await sharp(input)\n * .rotate(90)\n * .resize({ width: 16, height: 8, fit: 'fill' })\n * .toBuffer();\n * const resizeThenRotate = await sharp(input)\n * .resize({ width: 16, height: 8, fit: 'fill' })\n * .rotate(90)\n * .toBuffer();\n *\n * @param {number} [angle=auto] angle of rotation.\n * @param {Object} [options] - if present, is an Object with optional attributes.\n * @param {string|Object} [options.background=\"#000000\"] parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction rotate (angle, options) {\n if (!is.defined(angle)) {\n return this.autoOrient();\n }\n if (this.options.angle || this.options.rotationAngle) {\n this.options.debuglog('ignoring previous rotate options');\n this.options.angle = 0;\n this.options.rotationAngle = 0;\n }\n if (is.integer(angle) && !(angle % 90)) {\n this.options.angle = angle;\n } else if (is.number(angle)) {\n this.options.rotationAngle = angle;\n if (is.object(options) && options.background) {\n this._setBackgroundColourOption('rotationBackground', options.background);\n }\n } else {\n throw is.invalidParameterError('angle', 'numeric', angle);\n }\n return this;\n}\n\n/**\n * Auto-orient based on the EXIF `Orientation` tag, then remove the tag.\n * Mirroring is supported and may infer the use of a flip operation.\n *\n * Previous or subsequent use of `rotate(angle)` and either `flip()` or `flop()`\n * will logically occur after auto-orientation, regardless of call order.\n *\n * @example\n * const output = await sharp(input).autoOrient().toBuffer();\n *\n * @example\n * const pipeline = sharp()\n * .autoOrient()\n * .resize(null, 200)\n * .toBuffer(function (err, outputBuffer, info) {\n * // outputBuffer contains 200px high JPEG image data,\n * // auto-oriented using EXIF Orientation tag\n * // info.width and info.height contain the dimensions of the resized image\n * });\n * readableStream.pipe(pipeline);\n *\n * @returns {Sharp}\n */\nfunction autoOrient () {\n this.options.input.autoOrient = true;\n return this;\n}\n\n/**\n * Mirror the image vertically (up-down) about the x-axis.\n * This always occurs before rotation, if any.\n *\n * This operation does not work correctly with multi-page images.\n *\n * @example\n * const output = await sharp(input).flip().toBuffer();\n *\n * @param {Boolean} [flip=true]\n * @returns {Sharp}\n */\nfunction flip (flip) {\n this.options.flip = is.bool(flip) ? flip : true;\n return this;\n}\n\n/**\n * Mirror the image horizontally (left-right) about the y-axis.\n * This always occurs before rotation, if any.\n *\n * @example\n * const output = await sharp(input).flop().toBuffer();\n *\n * @param {Boolean} [flop=true]\n * @returns {Sharp}\n */\nfunction flop (flop) {\n this.options.flop = is.bool(flop) ? flop : true;\n return this;\n}\n\n/**\n * Perform an affine transform on an image. This operation will always occur after resizing, extraction and rotation, if any.\n *\n * You must provide an array of length 4 or a 2x2 affine transformation matrix.\n * By default, new pixels are filled with a black background. You can provide a background colour with the `background` option.\n * A particular interpolator may also be specified. Set the `interpolator` option to an attribute of the `sharp.interpolators` Object e.g. `sharp.interpolators.nohalo`.\n *\n * In the case of a 2x2 matrix, the transform is:\n * - X = `matrix[0, 0]` \\* (x + `idx`) + `matrix[0, 1]` \\* (y + `idy`) + `odx`\n * - Y = `matrix[1, 0]` \\* (x + `idx`) + `matrix[1, 1]` \\* (y + `idy`) + `ody`\n *\n * where:\n * - x and y are the coordinates in input image.\n * - X and Y are the coordinates in output image.\n * - (0,0) is the upper left corner.\n *\n * @since 0.27.0\n *\n * @example\n * const pipeline = sharp()\n * .affine([[1, 0.3], [0.1, 0.7]], {\n * background: 'white',\n * interpolator: sharp.interpolators.nohalo\n * })\n * .toBuffer((err, outputBuffer, info) => {\n * // outputBuffer contains the transformed image\n * // info.width and info.height contain the new dimensions\n * });\n *\n * inputStream\n * .pipe(pipeline);\n *\n * @param {Array<Array<number>>|Array<number>} matrix - affine transformation matrix\n * @param {Object} [options] - if present, is an Object with optional attributes.\n * @param {String|Object} [options.background=\"#000000\"] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @param {Number} [options.idx=0] - input horizontal offset\n * @param {Number} [options.idy=0] - input vertical offset\n * @param {Number} [options.odx=0] - output horizontal offset\n * @param {Number} [options.ody=0] - output vertical offset\n * @param {String} [options.interpolator=sharp.interpolators.bicubic] - interpolator\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction affine (matrix, options) {\n const flatMatrix = [].concat(...matrix);\n if (flatMatrix.length === 4 && flatMatrix.every(is.number)) {\n this.options.affineMatrix = flatMatrix;\n } else {\n throw is.invalidParameterError('matrix', '1x4 or 2x2 array', matrix);\n }\n\n if (is.defined(options)) {\n if (is.object(options)) {\n this._setBackgroundColourOption('affineBackground', options.background);\n if (is.defined(options.idx)) {\n if (is.number(options.idx)) {\n this.options.affineIdx = options.idx;\n } else {\n throw is.invalidParameterError('options.idx', 'number', options.idx);\n }\n }\n if (is.defined(options.idy)) {\n if (is.number(options.idy)) {\n this.options.affineIdy = options.idy;\n } else {\n throw is.invalidParameterError('options.idy', 'number', options.idy);\n }\n }\n if (is.defined(options.odx)) {\n if (is.number(options.odx)) {\n this.options.affineOdx = options.odx;\n } else {\n throw is.invalidParameterError('options.odx', 'number', options.odx);\n }\n }\n if (is.defined(options.ody)) {\n if (is.number(options.ody)) {\n this.options.affineOdy = options.ody;\n } else {\n throw is.invalidParameterError('options.ody', 'number', options.ody);\n }\n }\n if (is.defined(options.interpolator)) {\n if (is.inArray(options.interpolator, Object.values(this.constructor.interpolators))) {\n this.options.affineInterpolator = options.interpolator;\n } else {\n throw is.invalidParameterError('options.interpolator', 'valid interpolator name', options.interpolator);\n }\n }\n } else {\n throw is.invalidParameterError('options', 'object', options);\n }\n }\n\n return this;\n}\n\n/**\n * Sharpen the image.\n *\n * When used without parameters, performs a fast, mild sharpen of the output image.\n *\n * When a `sigma` is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.\n * Fine-grained control over the level of sharpening in \"flat\" (m1) and \"jagged\" (m2) areas is available.\n *\n * See {@link https://www.libvips.org/API/current/method.Image.sharpen.html libvips sharpen} operation.\n *\n * @example\n * const data = await sharp(input).sharpen().toBuffer();\n *\n * @example\n * const data = await sharp(input).sharpen({ sigma: 2 }).toBuffer();\n *\n * @example\n * const data = await sharp(input)\n * .sharpen({\n * sigma: 2,\n * m1: 0,\n * m2: 3,\n * x1: 3,\n * y2: 15,\n * y3: 15,\n * })\n * .toBuffer();\n *\n * @param {Object|number} [options] - if present, is an Object with attributes\n * @param {number} [options.sigma] - the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10\n * @param {number} [options.m1=1.0] - the level of sharpening to apply to \"flat\" areas, between 0 and 1000000\n * @param {number} [options.m2=2.0] - the level of sharpening to apply to \"jagged\" areas, between 0 and 1000000\n * @param {number} [options.x1=2.0] - threshold between \"flat\" and \"jagged\", between 0 and 1000000\n * @param {number} [options.y2=10.0] - maximum amount of brightening, between 0 and 1000000\n * @param {number} [options.y3=20.0] - maximum amount of darkening, between 0 and 1000000\n * @param {number} [flat] - (deprecated) see `options.m1`.\n * @param {number} [jagged] - (deprecated) see `options.m2`.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction sharpen (options, flat, jagged) {\n if (!is.defined(options)) {\n // No arguments: default to mild sharpen\n this.options.sharpenSigma = -1;\n } else if (is.bool(options)) {\n // Deprecated boolean argument: apply mild sharpen?\n this.options.sharpenSigma = options ? -1 : 0;\n } else if (is.number(options) && is.inRange(options, 0.01, 10000)) {\n // Deprecated numeric argument: specific sigma\n this.options.sharpenSigma = options;\n // Deprecated control over flat areas\n if (is.defined(flat)) {\n if (is.number(flat) && is.inRange(flat, 0, 10000)) {\n this.options.sharpenM1 = flat;\n } else {\n throw is.invalidParameterError('flat', 'number between 0 and 10000', flat);\n }\n }\n // Deprecated control over jagged areas\n if (is.defined(jagged)) {\n if (is.number(jagged) && is.inRange(jagged, 0, 10000)) {\n this.options.sharpenM2 = jagged;\n } else {\n throw is.invalidParameterError('jagged', 'number between 0 and 10000', jagged);\n }\n }\n } else if (is.plainObject(options)) {\n if (is.number(options.sigma) && is.inRange(options.sigma, 0.000001, 10)) {\n this.options.sharpenSigma = options.sigma;\n } else {\n throw is.invalidParameterError('options.sigma', 'number between 0.000001 and 10', options.sigma);\n }\n if (is.defined(options.m1)) {\n if (is.number(options.m1) && is.inRange(options.m1, 0, 1000000)) {\n this.options.sharpenM1 = options.m1;\n } else {\n throw is.invalidParameterError('options.m1', 'number between 0 and 1000000', options.m1);\n }\n }\n if (is.defined(options.m2)) {\n if (is.number(options.m2) && is.inRange(options.m2, 0, 1000000)) {\n this.options.sharpenM2 = options.m2;\n } else {\n throw is.invalidParameterError('options.m2', 'number between 0 and 1000000', options.m2);\n }\n }\n if (is.defined(options.x1)) {\n if (is.number(options.x1) && is.inRange(options.x1, 0, 1000000)) {\n this.options.sharpenX1 = options.x1;\n } else {\n throw is.invalidParameterError('options.x1', 'number between 0 and 1000000', options.x1);\n }\n }\n if (is.defined(options.y2)) {\n if (is.number(options.y2) && is.inRange(options.y2, 0, 1000000)) {\n this.options.sharpenY2 = options.y2;\n } else {\n throw is.invalidParameterError('options.y2', 'number between 0 and 1000000', options.y2);\n }\n }\n if (is.defined(options.y3)) {\n if (is.number(options.y3) && is.inRange(options.y3, 0, 1000000)) {\n this.options.sharpenY3 = options.y3;\n } else {\n throw is.invalidParameterError('options.y3', 'number between 0 and 1000000', options.y3);\n }\n }\n } else {\n throw is.invalidParameterError('sigma', 'number between 0.01 and 10000', options);\n }\n return this;\n}\n\n/**\n * Apply median filter.\n * When used without parameters the default window is 3x3.\n *\n * @example\n * const output = await sharp(input).median().toBuffer();\n *\n * @example\n * const output = await sharp(input).median(5).toBuffer();\n *\n * @param {number} [size=3] square mask size: size x size\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction median (size) {\n if (!is.defined(size)) {\n // No arguments: default to 3x3\n this.options.medianSize = 3;\n } else if (is.integer(size) && is.inRange(size, 1, 1000)) {\n // Numeric argument: specific sigma\n this.options.medianSize = size;\n } else {\n throw is.invalidParameterError('size', 'integer between 1 and 1000', size);\n }\n return this;\n}\n\n/**\n * Blur the image.\n *\n * When used without parameters, performs a fast 3x3 box blur (equivalent to a box linear filter).\n *\n * When a `sigma` is provided, performs a slower, more accurate Gaussian blur.\n *\n * @example\n * const boxBlurred = await sharp(input)\n * .blur()\n * .toBuffer();\n *\n * @example\n * const gaussianBlurred = await sharp(input)\n * .blur(5)\n * .toBuffer();\n *\n * @param {Object|number|Boolean} [options]\n * @param {number} [options.sigma] a value between 0.3 and 1000 representing the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`.\n * @param {string} [options.precision='integer'] How accurate the operation should be, one of: integer, float, approximate.\n * @param {number} [options.minAmplitude=0.2] A value between 0.001 and 1. A smaller value will generate a larger, more accurate mask.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction blur (options) {\n let sigma;\n if (is.number(options)) {\n sigma = options;\n } else if (is.plainObject(options)) {\n if (!is.number(options.sigma)) {\n throw is.invalidParameterError('options.sigma', 'number between 0.3 and 1000', sigma);\n }\n sigma = options.sigma;\n if ('precision' in options) {\n if (is.string(vipsPrecision[options.precision])) {\n this.options.precision = vipsPrecision[options.precision];\n } else {\n throw is.invalidParameterError('precision', 'one of: integer, float, approximate', options.precision);\n }\n }\n if ('minAmplitude' in options) {\n if (is.number(options.minAmplitude) && is.inRange(options.minAmplitude, 0.001, 1)) {\n this.options.minAmpl = options.minAmplitude;\n } else {\n throw is.invalidParameterError('minAmplitude', 'number between 0.001 and 1', options.minAmplitude);\n }\n }\n }\n\n if (!is.defined(options)) {\n // No arguments: default to mild blur\n this.options.blurSigma = -1;\n } else if (is.bool(options)) {\n // Boolean argument: apply mild blur?\n this.options.blurSigma = options ? -1 : 0;\n } else if (is.number(sigma) && is.inRange(sigma, 0.3, 1000)) {\n // Numeric argument: specific sigma\n this.options.blurSigma = sigma;\n } else {\n throw is.invalidParameterError('sigma', 'number between 0.3 and 1000', sigma);\n }\n\n return this;\n}\n\n/**\n * Expand foreground objects using the dilate morphological operator.\n *\n * @example\n * const output = await sharp(input)\n * .dilate()\n * .toBuffer();\n *\n * @param {Number} [width=1] dilation width in pixels.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction dilate (width) {\n if (!is.defined(width)) {\n this.options.dilateWidth = 1;\n } else if (is.integer(width) && width > 0) {\n this.options.dilateWidth = width;\n } else {\n throw is.invalidParameterError('dilate', 'positive integer', dilate);\n }\n return this;\n}\n\n/**\n * Shrink foreground objects using the erode morphological operator.\n *\n * @example\n * const output = await sharp(input)\n * .erode()\n * .toBuffer();\n *\n * @param {Number} [width=1] erosion width in pixels.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction erode (width) {\n if (!is.defined(width)) {\n this.options.erodeWidth = 1;\n } else if (is.integer(width) && width > 0) {\n this.options.erodeWidth = width;\n } else {\n throw is.invalidParameterError('erode', 'positive integer', erode);\n }\n return this;\n}\n\n/**\n * Merge alpha transparency channel, if any, with a background, then remove the alpha channel.\n *\n * See also {@link /api-channel#removealpha removeAlpha}.\n *\n * @example\n * await sharp(rgbaInput)\n * .flatten({ background: '#F0A703' })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {string|Object} [options.background={r: 0, g: 0, b: 0}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black.\n * @returns {Sharp}\n */\nfunction flatten (options) {\n this.options.flatten = is.bool(options) ? options : true;\n if (is.object(options)) {\n this._setBackgroundColourOption('flattenBackground', options.background);\n }\n return this;\n}\n\n/**\n * Ensure the image has an alpha channel\n * with all white pixel values made fully transparent.\n *\n * Existing alpha channel values for non-white pixels remain unchanged.\n *\n * This feature is experimental and the API may change.\n *\n * @since 0.32.1\n *\n * @example\n * await sharp(rgbInput)\n * .unflatten()\n * .toBuffer();\n *\n * @example\n * await sharp(rgbInput)\n * .threshold(128, { grayscale: false }) // converter bright pixels to white\n * .unflatten()\n * .toBuffer();\n */\nfunction unflatten () {\n this.options.unflatten = true;\n return this;\n}\n\n/**\n * Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of `1/gamma`\n * then increasing the encoding (brighten) post-resize at a factor of `gamma`.\n * This can improve the perceived brightness of a resized image in non-linear colour spaces.\n * JPEG and WebP input images will not take advantage of the shrink-on-load performance optimisation\n * when applying a gamma correction.\n *\n * Supply a second argument to use a different output gamma value, otherwise the first value is used in both cases.\n *\n * @param {number} [gamma=2.2] value between 1.0 and 3.0.\n * @param {number} [gammaOut] value between 1.0 and 3.0. (optional, defaults to same as `gamma`)\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction gamma (gamma, gammaOut) {\n if (!is.defined(gamma)) {\n // Default gamma correction of 2.2 (sRGB)\n this.options.gamma = 2.2;\n } else if (is.number(gamma) && is.inRange(gamma, 1, 3)) {\n this.options.gamma = gamma;\n } else {\n throw is.invalidParameterError('gamma', 'number between 1.0 and 3.0', gamma);\n }\n if (!is.defined(gammaOut)) {\n // Default gamma correction for output is same as input\n this.options.gammaOut = this.options.gamma;\n } else if (is.number(gammaOut) && is.inRange(gammaOut, 1, 3)) {\n this.options.gammaOut = gammaOut;\n } else {\n throw is.invalidParameterError('gammaOut', 'number between 1.0 and 3.0', gammaOut);\n }\n return this;\n}\n\n/**\n * Produce the \"negative\" of the image.\n *\n * @example\n * const output = await sharp(input)\n * .negate()\n * .toBuffer();\n *\n * @example\n * const output = await sharp(input)\n * .negate({ alpha: false })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {Boolean} [options.alpha=true] Whether or not to negate any alpha channel\n * @returns {Sharp}\n */\nfunction negate (options) {\n this.options.negate = is.bool(options) ? options : true;\n if (is.plainObject(options) && 'alpha' in options) {\n if (!is.bool(options.alpha)) {\n throw is.invalidParameterError('alpha', 'should be boolean value', options.alpha);\n } else {\n this.options.negateAlpha = options.alpha;\n }\n }\n return this;\n}\n\n/**\n * Enhance output image contrast by stretching its luminance to cover a full dynamic range.\n *\n * Uses a histogram-based approach, taking a default range of 1% to 99% to reduce sensitivity to noise at the extremes.\n *\n * Luminance values below the `lower` percentile will be underexposed by clipping to zero.\n * Luminance values above the `upper` percentile will be overexposed by clipping to the max pixel value.\n *\n * @example\n * const output = await sharp(input)\n * .normalise()\n * .toBuffer();\n *\n * @example\n * const output = await sharp(input)\n * .normalise({ lower: 0, upper: 100 })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {number} [options.lower=1] - Percentile below which luminance values will be underexposed.\n * @param {number} [options.upper=99] - Percentile above which luminance values will be overexposed.\n * @returns {Sharp}\n */\nfunction normalise (options) {\n if (is.plainObject(options)) {\n if (is.defined(options.lower)) {\n if (is.number(options.lower) && is.inRange(options.lower, 0, 99)) {\n this.options.normaliseLower = options.lower;\n } else {\n throw is.invalidParameterError('lower', 'number between 0 and 99', options.lower);\n }\n }\n if (is.defined(options.upper)) {\n if (is.number(options.upper) && is.inRange(options.upper, 1, 100)) {\n this.options.normaliseUpper = options.upper;\n } else {\n throw is.invalidParameterError('upper', 'number between 1 and 100', options.upper);\n }\n }\n }\n if (this.options.normaliseLower >= this.options.normaliseUpper) {\n throw is.invalidParameterError('range', 'lower to be less than upper',\n `${this.options.normaliseLower} >= ${this.options.normaliseUpper}`);\n }\n this.options.normalise = true;\n return this;\n}\n\n/**\n * Alternative spelling of normalise.\n *\n * @example\n * const output = await sharp(input)\n * .normalize()\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {number} [options.lower=1] - Percentile below which luminance values will be underexposed.\n * @param {number} [options.upper=99] - Percentile above which luminance values will be overexposed.\n * @returns {Sharp}\n */\nfunction normalize (options) {\n return this.normalise(options);\n}\n\n/**\n * Perform contrast limiting adaptive histogram equalization\n * {@link https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE CLAHE}.\n *\n * This will, in general, enhance the clarity of the image by bringing out darker details.\n *\n * @since 0.28.3\n *\n * @example\n * const output = await sharp(input)\n * .clahe({\n * width: 3,\n * height: 3,\n * })\n * .toBuffer();\n *\n * @param {Object} options\n * @param {number} options.width - Integral width of the search window, in pixels.\n * @param {number} options.height - Integral height of the search window, in pixels.\n * @param {number} [options.maxSlope=3] - Integral level of brightening, between 0 and 100, where 0 disables contrast limiting.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction clahe (options) {\n if (is.plainObject(options)) {\n if (is.integer(options.width) && options.width > 0) {\n this.options.claheWidth = options.width;\n } else {\n throw is.invalidParameterError('width', 'integer greater than zero', options.width);\n }\n if (is.integer(options.height) && options.height > 0) {\n this.options.claheHeight = options.height;\n } else {\n throw is.invalidParameterError('height', 'integer greater than zero', options.height);\n }\n if (is.defined(options.maxSlope)) {\n if (is.integer(options.maxSlope) && is.inRange(options.maxSlope, 0, 100)) {\n this.options.claheMaxSlope = options.maxSlope;\n } else {\n throw is.invalidParameterError('maxSlope', 'integer between 0 and 100', options.maxSlope);\n }\n }\n } else {\n throw is.invalidParameterError('options', 'plain object', options);\n }\n return this;\n}\n\n/**\n * Convolve the image with the specified kernel.\n *\n * @example\n * sharp(input)\n * .convolve({\n * width: 3,\n * height: 3,\n * kernel: [-1, 0, 1, -2, 0, 2, -1, 0, 1]\n * })\n * .raw()\n * .toBuffer(function(err, data, info) {\n * // data contains the raw pixel data representing the convolution\n * // of the input image with the horizontal Sobel operator\n * });\n *\n * @param {Object} kernel\n * @param {number} kernel.width - width of the kernel in pixels.\n * @param {number} kernel.height - height of the kernel in pixels.\n * @param {Array<number>} kernel.kernel - Array of length `width*height` containing the kernel values.\n * @param {number} [kernel.scale=sum] - the scale of the kernel in pixels.\n * @param {number} [kernel.offset=0] - the offset of the kernel in pixels.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction convolve (kernel) {\n if (!is.object(kernel) || !Array.isArray(kernel.kernel) ||\n !is.integer(kernel.width) || !is.integer(kernel.height) ||\n !is.inRange(kernel.width, 3, 1001) || !is.inRange(kernel.height, 3, 1001) ||\n kernel.height * kernel.width !== kernel.kernel.length\n ) {\n // must pass in a kernel\n throw new Error('Invalid convolution kernel');\n }\n // Default scale is sum of kernel values\n if (!is.integer(kernel.scale)) {\n kernel.scale = kernel.kernel.reduce((a, b) => a + b, 0);\n }\n // Clip scale to a minimum value of 1\n if (kernel.scale < 1) {\n kernel.scale = 1;\n }\n if (!is.integer(kernel.offset)) {\n kernel.offset = 0;\n }\n this.options.convKernel = kernel;\n return this;\n}\n\n/**\n * Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0.\n * @param {number} [threshold=128] - a value in the range 0-255 representing the level at which the threshold will be applied.\n * @param {Object} [options]\n * @param {Boolean} [options.greyscale=true] - convert to single channel greyscale.\n * @param {Boolean} [options.grayscale=true] - alternative spelling for greyscale.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction threshold (threshold, options) {\n if (!is.defined(threshold)) {\n this.options.threshold = 128;\n } else if (is.bool(threshold)) {\n this.options.threshold = threshold ? 128 : 0;\n } else if (is.integer(threshold) && is.inRange(threshold, 0, 255)) {\n this.options.threshold = threshold;\n } else {\n throw is.invalidParameterError('threshold', 'integer between 0 and 255', threshold);\n }\n if (!is.object(options) || options.greyscale === true || options.grayscale === true) {\n this.options.thresholdGrayscale = true;\n } else {\n this.options.thresholdGrayscale = false;\n }\n return this;\n}\n\n/**\n * Perform a bitwise boolean operation with operand image.\n *\n * This operation creates an output image where each pixel is the result of\n * the selected bitwise boolean `operation` between the corresponding pixels of the input images.\n *\n * @param {Buffer|string} operand - Buffer containing image data or string containing the path to an image file.\n * @param {string} operator - one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.\n * @param {Object} [options]\n * @param {Object} [options.raw] - describes operand when using raw pixel data.\n * @param {number} [options.raw.width]\n * @param {number} [options.raw.height]\n * @param {number} [options.raw.channels]\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction boolean (operand, operator, options) {\n this.options.boolean = this._createInputDescriptor(operand, options);\n if (is.string(operator) && is.inArray(operator, ['and', 'or', 'eor'])) {\n this.options.booleanOp = operator;\n } else {\n throw is.invalidParameterError('operator', 'one of: and, or, eor', operator);\n }\n return this;\n}\n\n/**\n * Apply the linear formula `a` * input + `b` to the image to adjust image levels.\n *\n * When a single number is provided, it will be used for all image channels.\n * When an array of numbers is provided, the array length must match the number of channels.\n *\n * @example\n * await sharp(input)\n * .linear(0.5, 2)\n * .toBuffer();\n *\n * @example\n * await sharp(rgbInput)\n * .linear(\n * [0.25, 0.5, 0.75],\n * [150, 100, 50]\n * )\n * .toBuffer();\n *\n * @param {(number|number[])} [a=[]] multiplier\n * @param {(number|number[])} [b=[]] offset\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction linear (a, b) {\n if (!is.defined(a) && is.number(b)) {\n a = 1.0;\n } else if (is.number(a) && !is.defined(b)) {\n b = 0.0;\n }\n if (!is.defined(a)) {\n this.options.linearA = [];\n } else if (is.number(a)) {\n this.options.linearA = [a];\n } else if (Array.isArray(a) && a.length && a.every(is.number)) {\n this.options.linearA = a;\n } else {\n throw is.invalidParameterError('a', 'number or array of numbers', a);\n }\n if (!is.defined(b)) {\n this.options.linearB = [];\n } else if (is.number(b)) {\n this.options.linearB = [b];\n } else if (Array.isArray(b) && b.length && b.every(is.number)) {\n this.options.linearB = b;\n } else {\n throw is.invalidParameterError('b', 'number or array of numbers', b);\n }\n if (this.options.linearA.length !== this.options.linearB.length) {\n throw new Error('Expected a and b to be arrays of the same length');\n }\n return this;\n}\n\n/**\n * Recombine the image with the specified matrix.\n *\n * @since 0.21.1\n *\n * @example\n * sharp(input)\n * .recomb([\n * [0.3588, 0.7044, 0.1368],\n * [0.2990, 0.5870, 0.1140],\n * [0.2392, 0.4696, 0.0912],\n * ])\n * .raw()\n * .toBuffer(function(err, data, info) {\n * // data contains the raw pixel data after applying the matrix\n * // With this example input, a sepia filter has been applied\n * });\n *\n * @param {Array<Array<number>>} inputMatrix - 3x3 or 4x4 Recombination matrix\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction recomb (inputMatrix) {\n if (!Array.isArray(inputMatrix)) {\n throw is.invalidParameterError('inputMatrix', 'array', inputMatrix);\n }\n if (inputMatrix.length !== 3 && inputMatrix.length !== 4) {\n throw is.invalidParameterError('inputMatrix', '3x3 or 4x4 array', inputMatrix.length);\n }\n const recombMatrix = inputMatrix.flat().map(Number);\n if (recombMatrix.length !== 9 && recombMatrix.length !== 16) {\n throw is.invalidParameterError('inputMatrix', 'cardinality of 9 or 16', recombMatrix.length);\n }\n this.options.recombMatrix = recombMatrix;\n return this;\n}\n\n/**\n * Transforms the image using brightness, saturation, hue rotation, and lightness.\n * Brightness and lightness both operate on luminance, with the difference being that\n * brightness is multiplicative whereas lightness is additive.\n *\n * @since 0.22.1\n *\n * @example\n * // increase brightness by a factor of 2\n * const output = await sharp(input)\n * .modulate({\n * brightness: 2\n * })\n * .toBuffer();\n *\n * @example\n * // hue-rotate by 180 degrees\n * const output = await sharp(input)\n * .modulate({\n * hue: 180\n * })\n * .toBuffer();\n *\n * @example\n * // increase lightness by +50\n * const output = await sharp(input)\n * .modulate({\n * lightness: 50\n * })\n * .toBuffer();\n *\n * @example\n * // decrease brightness and saturation while also hue-rotating by 90 degrees\n * const output = await sharp(input)\n * .modulate({\n * brightness: 0.5,\n * saturation: 0.5,\n * hue: 90,\n * })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {number} [options.brightness] Brightness multiplier\n * @param {number} [options.saturation] Saturation multiplier\n * @param {number} [options.hue] Degrees for hue rotation\n * @param {number} [options.lightness] Lightness addend\n * @returns {Sharp}\n */\nfunction modulate (options) {\n if (!is.plainObject(options)) {\n throw is.invalidParameterError('options', 'plain object', options);\n }\n if ('brightness' in options) {\n if (is.number(options.brightness) && options.brightness >= 0) {\n this.options.brightness = options.brightness;\n } else {\n throw is.invalidParameterError('brightness', 'number above zero', options.brightness);\n }\n }\n if ('saturation' in options) {\n if (is.number(options.saturation) && options.saturation >= 0) {\n this.options.saturation = options.saturation;\n } else {\n throw is.invalidParameterError('saturation', 'number above zero', options.saturation);\n }\n }\n if ('hue' in options) {\n if (is.integer(options.hue)) {\n this.options.hue = options.hue % 360;\n } else {\n throw is.invalidParameterError('hue', 'number', options.hue);\n }\n }\n if ('lightness' in options) {\n if (is.number(options.lightness)) {\n this.options.lightness = options.lightness;\n } else {\n throw is.invalidParameterError('lightness', 'number', options.lightness);\n }\n }\n return this;\n}\n\n/**\n * Decorate the Sharp prototype with operation-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n autoOrient,\n rotate,\n flip,\n flop,\n affine,\n sharpen,\n erode,\n dilate,\n median,\n blur,\n flatten,\n unflatten,\n gamma,\n negate,\n normalise,\n normalize,\n clahe,\n convolve,\n threshold,\n boolean,\n linear,\n recomb,\n modulate\n });\n};\n", "var __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// node_modules/color/index.js\nvar index_exports = {};\n__export(index_exports, {\n default: () => index_default\n});\nmodule.exports = __toCommonJS(index_exports);\n\n// node_modules/color-name/index.js\nvar color_name_default = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 134, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 250, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 221],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [112, 128, 144],\n slategrey: [112, 128, 144],\n snow: [255, 250, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 50]\n};\n\n// node_modules/color-string/index.js\nvar reverseNames = /* @__PURE__ */ Object.create(null);\nfor (const name in color_name_default) {\n if (Object.hasOwn(color_name_default, name)) {\n reverseNames[color_name_default[name]] = name;\n }\n}\nvar cs = {\n to: {},\n get: {}\n};\ncs.get = function(string) {\n const prefix = string.slice(0, 3).toLowerCase();\n let value;\n let model;\n switch (prefix) {\n case \"hsl\": {\n value = cs.get.hsl(string);\n model = \"hsl\";\n break;\n }\n case \"hwb\": {\n value = cs.get.hwb(string);\n model = \"hwb\";\n break;\n }\n default: {\n value = cs.get.rgb(string);\n model = \"rgb\";\n break;\n }\n }\n if (!value) {\n return null;\n }\n return { model, value };\n};\ncs.get.rgb = function(string) {\n if (!string) {\n return null;\n }\n const abbr = /^#([a-f\\d]{3,4})$/i;\n const hex = /^#([a-f\\d]{6})([a-f\\d]{2})?$/i;\n const rgba = /^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[\\s,|/]\\s*([+-]?[\\d.]+)(%?)\\s*)?\\)$/;\n const per = /^rgba?\\(\\s*([+-]?[\\d.]+)%\\s*,?\\s*([+-]?[\\d.]+)%\\s*,?\\s*([+-]?[\\d.]+)%\\s*(?:[\\s,|/]\\s*([+-]?[\\d.]+)(%?)\\s*)?\\)$/;\n const keyword = /^(\\w+)$/;\n let rgb = [0, 0, 0, 1];\n let match;\n let i;\n let hexAlpha;\n if (match = string.match(hex)) {\n hexAlpha = match[2];\n match = match[1];\n for (i = 0; i < 3; i++) {\n const i2 = i * 2;\n rgb[i] = Number.parseInt(match.slice(i2, i2 + 2), 16);\n }\n if (hexAlpha) {\n rgb[3] = Number.parseInt(hexAlpha, 16) / 255;\n }\n } else if (match = string.match(abbr)) {\n match = match[1];\n hexAlpha = match[3];\n for (i = 0; i < 3; i++) {\n rgb[i] = Number.parseInt(match[i] + match[i], 16);\n }\n if (hexAlpha) {\n rgb[3] = Number.parseInt(hexAlpha + hexAlpha, 16) / 255;\n }\n } else if (match = string.match(rgba)) {\n for (i = 0; i < 3; i++) {\n rgb[i] = Number.parseInt(match[i + 1], 10);\n }\n if (match[4]) {\n rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);\n }\n } else if (match = string.match(per)) {\n for (i = 0; i < 3; i++) {\n rgb[i] = Math.round(Number.parseFloat(match[i + 1]) * 2.55);\n }\n if (match[4]) {\n rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);\n }\n } else if (match = string.match(keyword)) {\n if (match[1] === \"transparent\") {\n return [0, 0, 0, 0];\n }\n if (!Object.hasOwn(color_name_default, match[1])) {\n return null;\n }\n rgb = color_name_default[match[1]];\n rgb[3] = 1;\n return rgb;\n } else {\n return null;\n }\n for (i = 0; i < 3; i++) {\n rgb[i] = clamp(rgb[i], 0, 255);\n }\n rgb[3] = clamp(rgb[3], 0, 1);\n return rgb;\n};\ncs.get.hsl = function(string) {\n if (!string) {\n return null;\n }\n const hsl = /^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d.]+)%\\s*,?\\s*([+-]?[\\d.]+)%\\s*(?:[,|/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/;\n const match = string.match(hsl);\n if (match) {\n const alpha = Number.parseFloat(match[4]);\n const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;\n const s = clamp(Number.parseFloat(match[2]), 0, 100);\n const l = clamp(Number.parseFloat(match[3]), 0, 100);\n const a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);\n return [h, s, l, a];\n }\n return null;\n};\ncs.get.hwb = function(string) {\n if (!string) {\n return null;\n }\n const hwb = /^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*[\\s,]\\s*([+-]?[\\d.]+)%\\s*[\\s,]\\s*([+-]?[\\d.]+)%\\s*(?:[\\s,]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/;\n const match = string.match(hwb);\n if (match) {\n const alpha = Number.parseFloat(match[4]);\n const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;\n const w = clamp(Number.parseFloat(match[2]), 0, 100);\n const b = clamp(Number.parseFloat(match[3]), 0, 100);\n const a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);\n return [h, w, b, a];\n }\n return null;\n};\ncs.to.hex = function(...rgba) {\n return \"#\" + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : \"\");\n};\ncs.to.rgb = function(...rgba) {\n return rgba.length < 4 || rgba[3] === 1 ? \"rgb(\" + Math.round(rgba[0]) + \", \" + Math.round(rgba[1]) + \", \" + Math.round(rgba[2]) + \")\" : \"rgba(\" + Math.round(rgba[0]) + \", \" + Math.round(rgba[1]) + \", \" + Math.round(rgba[2]) + \", \" + rgba[3] + \")\";\n};\ncs.to.rgb.percent = function(...rgba) {\n const r = Math.round(rgba[0] / 255 * 100);\n const g = Math.round(rgba[1] / 255 * 100);\n const b = Math.round(rgba[2] / 255 * 100);\n return rgba.length < 4 || rgba[3] === 1 ? \"rgb(\" + r + \"%, \" + g + \"%, \" + b + \"%)\" : \"rgba(\" + r + \"%, \" + g + \"%, \" + b + \"%, \" + rgba[3] + \")\";\n};\ncs.to.hsl = function(...hsla) {\n return hsla.length < 4 || hsla[3] === 1 ? \"hsl(\" + hsla[0] + \", \" + hsla[1] + \"%, \" + hsla[2] + \"%)\" : \"hsla(\" + hsla[0] + \", \" + hsla[1] + \"%, \" + hsla[2] + \"%, \" + hsla[3] + \")\";\n};\ncs.to.hwb = function(...hwba) {\n let a = \"\";\n if (hwba.length >= 4 && hwba[3] !== 1) {\n a = \", \" + hwba[3];\n }\n return \"hwb(\" + hwba[0] + \", \" + hwba[1] + \"%, \" + hwba[2] + \"%\" + a + \")\";\n};\ncs.to.keyword = function(...rgb) {\n return reverseNames[rgb.slice(0, 3)];\n};\nfunction clamp(number_, min, max) {\n return Math.min(Math.max(min, number_), max);\n}\nfunction hexDouble(number_) {\n const string_ = Math.round(number_).toString(16).toUpperCase();\n return string_.length < 2 ? \"0\" + string_ : string_;\n}\nvar color_string_default = cs;\n\n// node_modules/color-convert/conversions.js\nvar reverseKeywords = {};\nfor (const key of Object.keys(color_name_default)) {\n reverseKeywords[color_name_default[key]] = key;\n}\nvar convert = {\n rgb: { channels: 3, labels: \"rgb\" },\n hsl: { channels: 3, labels: \"hsl\" },\n hsv: { channels: 3, labels: \"hsv\" },\n hwb: { channels: 3, labels: \"hwb\" },\n cmyk: { channels: 4, labels: \"cmyk\" },\n xyz: { channels: 3, labels: \"xyz\" },\n lab: { channels: 3, labels: \"lab\" },\n oklab: { channels: 3, labels: [\"okl\", \"oka\", \"okb\"] },\n lch: { channels: 3, labels: \"lch\" },\n oklch: { channels: 3, labels: [\"okl\", \"okc\", \"okh\"] },\n hex: { channels: 1, labels: [\"hex\"] },\n keyword: { channels: 1, labels: [\"keyword\"] },\n ansi16: { channels: 1, labels: [\"ansi16\"] },\n ansi256: { channels: 1, labels: [\"ansi256\"] },\n hcg: { channels: 3, labels: [\"h\", \"c\", \"g\"] },\n apple: { channels: 3, labels: [\"r16\", \"g16\", \"b16\"] },\n gray: { channels: 1, labels: [\"gray\"] }\n};\nvar conversions_default = convert;\nvar LAB_FT = (6 / 29) ** 3;\nfunction srgbNonlinearTransform(c) {\n const cc = c > 31308e-7 ? 1.055 * c ** (1 / 2.4) - 0.055 : c * 12.92;\n return Math.min(Math.max(0, cc), 1);\n}\nfunction srgbNonlinearTransformInv(c) {\n return c > 0.04045 ? ((c + 0.055) / 1.055) ** 2.4 : c / 12.92;\n}\nfor (const model of Object.keys(convert)) {\n if (!(\"channels\" in convert[model])) {\n throw new Error(\"missing channels property: \" + model);\n }\n if (!(\"labels\" in convert[model])) {\n throw new Error(\"missing channel labels property: \" + model);\n }\n if (convert[model].labels.length !== convert[model].channels) {\n throw new Error(\"channel and label counts mismatch: \" + model);\n }\n const { channels, labels } = convert[model];\n delete convert[model].channels;\n delete convert[model].labels;\n Object.defineProperty(convert[model], \"channels\", { value: channels });\n Object.defineProperty(convert[model], \"labels\", { value: labels });\n}\nconvert.rgb.hsl = function(rgb) {\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n const delta = max - min;\n let h;\n let s;\n switch (max) {\n case min: {\n h = 0;\n break;\n }\n case r: {\n h = (g - b) / delta;\n break;\n }\n case g: {\n h = 2 + (b - r) / delta;\n break;\n }\n case b: {\n h = 4 + (r - g) / delta;\n break;\n }\n }\n h = Math.min(h * 60, 360);\n if (h < 0) {\n h += 360;\n }\n const l = (min + max) / 2;\n if (max === min) {\n s = 0;\n } else if (l <= 0.5) {\n s = delta / (max + min);\n } else {\n s = delta / (2 - max - min);\n }\n return [h, s * 100, l * 100];\n};\nconvert.rgb.hsv = function(rgb) {\n let rdif;\n let gdif;\n let bdif;\n let h;\n let s;\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n const v = Math.max(r, g, b);\n const diff = v - Math.min(r, g, b);\n const diffc = function(c) {\n return (v - c) / 6 / diff + 1 / 2;\n };\n if (diff === 0) {\n h = 0;\n s = 0;\n } else {\n s = diff / v;\n rdif = diffc(r);\n gdif = diffc(g);\n bdif = diffc(b);\n switch (v) {\n case r: {\n h = bdif - gdif;\n break;\n }\n case g: {\n h = 1 / 3 + rdif - bdif;\n break;\n }\n case b: {\n h = 2 / 3 + gdif - rdif;\n break;\n }\n }\n if (h < 0) {\n h += 1;\n } else if (h > 1) {\n h -= 1;\n }\n }\n return [\n h * 360,\n s * 100,\n v * 100\n ];\n};\nconvert.rgb.hwb = function(rgb) {\n const r = rgb[0];\n const g = rgb[1];\n let b = rgb[2];\n const h = convert.rgb.hsl(rgb)[0];\n const w = 1 / 255 * Math.min(r, Math.min(g, b));\n b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));\n return [h, w * 100, b * 100];\n};\nconvert.rgb.oklab = function(rgb) {\n const r = srgbNonlinearTransformInv(rgb[0] / 255);\n const g = srgbNonlinearTransformInv(rgb[1] / 255);\n const b = srgbNonlinearTransformInv(rgb[2] / 255);\n const lp = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n const mp = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n const sp = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;\n const aa = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;\n const bb = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;\n return [l * 100, aa * 100, bb * 100];\n};\nconvert.rgb.cmyk = function(rgb) {\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n const k = Math.min(1 - r, 1 - g, 1 - b);\n const c = (1 - r - k) / (1 - k) || 0;\n const m = (1 - g - k) / (1 - k) || 0;\n const y = (1 - b - k) / (1 - k) || 0;\n return [c * 100, m * 100, y * 100, k * 100];\n};\nfunction comparativeDistance(x, y) {\n return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;\n}\nconvert.rgb.keyword = function(rgb) {\n const reversed = reverseKeywords[rgb];\n if (reversed) {\n return reversed;\n }\n let currentClosestDistance = Number.POSITIVE_INFINITY;\n let currentClosestKeyword;\n for (const keyword of Object.keys(color_name_default)) {\n const value = color_name_default[keyword];\n const distance = comparativeDistance(rgb, value);\n if (distance < currentClosestDistance) {\n currentClosestDistance = distance;\n currentClosestKeyword = keyword;\n }\n }\n return currentClosestKeyword;\n};\nconvert.keyword.rgb = function(keyword) {\n return color_name_default[keyword];\n};\nconvert.rgb.xyz = function(rgb) {\n const r = srgbNonlinearTransformInv(rgb[0] / 255);\n const g = srgbNonlinearTransformInv(rgb[1] / 255);\n const b = srgbNonlinearTransformInv(rgb[2] / 255);\n const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;\n const y = r * 0.2126729 + g * 0.7151522 + b * 0.072175;\n const z = r * 0.0193339 + g * 0.119192 + b * 0.9503041;\n return [x * 100, y * 100, z * 100];\n};\nconvert.rgb.lab = function(rgb) {\n const xyz = convert.rgb.xyz(rgb);\n let x = xyz[0];\n let y = xyz[1];\n let z = xyz[2];\n x /= 95.047;\n y /= 100;\n z /= 108.883;\n x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;\n y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;\n z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;\n const l = 116 * y - 16;\n const a = 500 * (x - y);\n const b = 200 * (y - z);\n return [l, a, b];\n};\nconvert.hsl.rgb = function(hsl) {\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n let t3;\n let value;\n if (s === 0) {\n value = l * 255;\n return [value, value, value];\n }\n const t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const t1 = 2 * l - t2;\n const rgb = [0, 0, 0];\n for (let i = 0; i < 3; i++) {\n t3 = h + 1 / 3 * -(i - 1);\n if (t3 < 0) {\n t3++;\n }\n if (t3 > 1) {\n t3--;\n }\n if (6 * t3 < 1) {\n value = t1 + (t2 - t1) * 6 * t3;\n } else if (2 * t3 < 1) {\n value = t2;\n } else if (3 * t3 < 2) {\n value = t1 + (t2 - t1) * (2 / 3 - t3) * 6;\n } else {\n value = t1;\n }\n rgb[i] = value * 255;\n }\n return rgb;\n};\nconvert.hsl.hsv = function(hsl) {\n const h = hsl[0];\n let s = hsl[1] / 100;\n let l = hsl[2] / 100;\n let smin = s;\n const lmin = Math.max(l, 0.01);\n l *= 2;\n s *= l <= 1 ? l : 2 - l;\n smin *= lmin <= 1 ? lmin : 2 - lmin;\n const v = (l + s) / 2;\n const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);\n return [h, sv * 100, v * 100];\n};\nconvert.hsv.rgb = function(hsv) {\n const h = hsv[0] / 60;\n const s = hsv[1] / 100;\n let v = hsv[2] / 100;\n const hi = Math.floor(h) % 6;\n const f = h - Math.floor(h);\n const p = 255 * v * (1 - s);\n const q = 255 * v * (1 - s * f);\n const t = 255 * v * (1 - s * (1 - f));\n v *= 255;\n switch (hi) {\n case 0: {\n return [v, t, p];\n }\n case 1: {\n return [q, v, p];\n }\n case 2: {\n return [p, v, t];\n }\n case 3: {\n return [p, q, v];\n }\n case 4: {\n return [t, p, v];\n }\n case 5: {\n return [v, p, q];\n }\n }\n};\nconvert.hsv.hsl = function(hsv) {\n const h = hsv[0];\n const s = hsv[1] / 100;\n const v = hsv[2] / 100;\n const vmin = Math.max(v, 0.01);\n let sl;\n let l;\n l = (2 - s) * v;\n const lmin = (2 - s) * vmin;\n sl = s * vmin;\n sl /= lmin <= 1 ? lmin : 2 - lmin;\n sl = sl || 0;\n l /= 2;\n return [h, sl * 100, l * 100];\n};\nconvert.hwb.rgb = function(hwb) {\n const h = hwb[0] / 360;\n let wh = hwb[1] / 100;\n let bl = hwb[2] / 100;\n const ratio = wh + bl;\n let f;\n if (ratio > 1) {\n wh /= ratio;\n bl /= ratio;\n }\n const i = Math.floor(6 * h);\n const v = 1 - bl;\n f = 6 * h - i;\n if ((i & 1) !== 0) {\n f = 1 - f;\n }\n const n = wh + f * (v - wh);\n let r;\n let g;\n let b;\n switch (i) {\n default:\n case 6:\n case 0: {\n r = v;\n g = n;\n b = wh;\n break;\n }\n case 1: {\n r = n;\n g = v;\n b = wh;\n break;\n }\n case 2: {\n r = wh;\n g = v;\n b = n;\n break;\n }\n case 3: {\n r = wh;\n g = n;\n b = v;\n break;\n }\n case 4: {\n r = n;\n g = wh;\n b = v;\n break;\n }\n case 5: {\n r = v;\n g = wh;\n b = n;\n break;\n }\n }\n return [r * 255, g * 255, b * 255];\n};\nconvert.cmyk.rgb = function(cmyk) {\n const c = cmyk[0] / 100;\n const m = cmyk[1] / 100;\n const y = cmyk[2] / 100;\n const k = cmyk[3] / 100;\n const r = 1 - Math.min(1, c * (1 - k) + k);\n const g = 1 - Math.min(1, m * (1 - k) + k);\n const b = 1 - Math.min(1, y * (1 - k) + k);\n return [r * 255, g * 255, b * 255];\n};\nconvert.xyz.rgb = function(xyz) {\n const x = xyz[0] / 100;\n const y = xyz[1] / 100;\n const z = xyz[2] / 100;\n let r;\n let g;\n let b;\n r = x * 3.2404542 + y * -1.5371385 + z * -0.4985314;\n g = x * -0.969266 + y * 1.8760108 + z * 0.041556;\n b = x * 0.0556434 + y * -0.2040259 + z * 1.0572252;\n r = srgbNonlinearTransform(r);\n g = srgbNonlinearTransform(g);\n b = srgbNonlinearTransform(b);\n return [r * 255, g * 255, b * 255];\n};\nconvert.xyz.lab = function(xyz) {\n let x = xyz[0];\n let y = xyz[1];\n let z = xyz[2];\n x /= 95.047;\n y /= 100;\n z /= 108.883;\n x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;\n y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;\n z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;\n const l = 116 * y - 16;\n const a = 500 * (x - y);\n const b = 200 * (y - z);\n return [l, a, b];\n};\nconvert.xyz.oklab = function(xyz) {\n const x = xyz[0] / 100;\n const y = xyz[1] / 100;\n const z = xyz[2] / 100;\n const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z);\n const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z);\n const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z);\n const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;\n const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;\n const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;\n return [l * 100, a * 100, b * 100];\n};\nconvert.oklab.oklch = function(oklab) {\n return convert.lab.lch(oklab);\n};\nconvert.oklab.xyz = function(oklab) {\n const ll = oklab[0] / 100;\n const a = oklab[1] / 100;\n const b = oklab[2] / 100;\n const l = (0.999999998 * ll + 0.396337792 * a + 0.215803758 * b) ** 3;\n const m = (1.000000008 * ll - 0.105561342 * a - 0.063854175 * b) ** 3;\n const s = (1.000000055 * ll - 0.089484182 * a - 1.291485538 * b) ** 3;\n const x = 1.227013851 * l - 0.55779998 * m + 0.281256149 * s;\n const y = -0.040580178 * l + 1.11225687 * m - 0.071676679 * s;\n const z = -0.076381285 * l - 0.421481978 * m + 1.58616322 * s;\n return [x * 100, y * 100, z * 100];\n};\nconvert.oklab.rgb = function(oklab) {\n const ll = oklab[0] / 100;\n const aa = oklab[1] / 100;\n const bb = oklab[2] / 100;\n const l = (ll + 0.3963377774 * aa + 0.2158037573 * bb) ** 3;\n const m = (ll - 0.1055613458 * aa - 0.0638541728 * bb) ** 3;\n const s = (ll - 0.0894841775 * aa - 1.291485548 * bb) ** 3;\n const r = srgbNonlinearTransform(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s);\n const g = srgbNonlinearTransform(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s);\n const b = srgbNonlinearTransform(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s);\n return [r * 255, g * 255, b * 255];\n};\nconvert.oklch.oklab = function(oklch) {\n return convert.lch.lab(oklch);\n};\nconvert.lab.xyz = function(lab) {\n const l = lab[0];\n const a = lab[1];\n const b = lab[2];\n let x;\n let y;\n let z;\n y = (l + 16) / 116;\n x = a / 500 + y;\n z = y - b / 200;\n const y2 = y ** 3;\n const x2 = x ** 3;\n const z2 = z ** 3;\n y = y2 > LAB_FT ? y2 : (y - 16 / 116) / 7.787;\n x = x2 > LAB_FT ? x2 : (x - 16 / 116) / 7.787;\n z = z2 > LAB_FT ? z2 : (z - 16 / 116) / 7.787;\n x *= 95.047;\n y *= 100;\n z *= 108.883;\n return [x, y, z];\n};\nconvert.lab.lch = function(lab) {\n const l = lab[0];\n const a = lab[1];\n const b = lab[2];\n let h;\n const hr = Math.atan2(b, a);\n h = hr * 360 / 2 / Math.PI;\n if (h < 0) {\n h += 360;\n }\n const c = Math.sqrt(a * a + b * b);\n return [l, c, h];\n};\nconvert.lch.lab = function(lch) {\n const l = lch[0];\n const c = lch[1];\n const h = lch[2];\n const hr = h / 360 * 2 * Math.PI;\n const a = c * Math.cos(hr);\n const b = c * Math.sin(hr);\n return [l, a, b];\n};\nconvert.rgb.ansi16 = function(args, saturation = null) {\n const [r, g, b] = args;\n let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;\n value = Math.round(value / 50);\n if (value === 0) {\n return 30;\n }\n let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));\n if (value === 2) {\n ansi += 60;\n }\n return ansi;\n};\nconvert.hsv.ansi16 = function(args) {\n return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);\n};\nconvert.rgb.ansi256 = function(args) {\n const r = args[0];\n const g = args[1];\n const b = args[2];\n if (r >> 4 === g >> 4 && g >> 4 === b >> 4) {\n if (r < 8) {\n return 16;\n }\n if (r > 248) {\n return 231;\n }\n return Math.round((r - 8) / 247 * 24) + 232;\n }\n const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);\n return ansi;\n};\nconvert.ansi16.rgb = function(args) {\n args = args[0];\n let color = args % 10;\n if (color === 0 || color === 7) {\n if (args > 50) {\n color += 3.5;\n }\n color = color / 10.5 * 255;\n return [color, color, color];\n }\n const mult = (Math.trunc(args > 50) + 1) * 0.5;\n const r = (color & 1) * mult * 255;\n const g = (color >> 1 & 1) * mult * 255;\n const b = (color >> 2 & 1) * mult * 255;\n return [r, g, b];\n};\nconvert.ansi256.rgb = function(args) {\n args = args[0];\n if (args >= 232) {\n const c = (args - 232) * 10 + 8;\n return [c, c, c];\n }\n args -= 16;\n let rem;\n const r = Math.floor(args / 36) / 5 * 255;\n const g = Math.floor((rem = args % 36) / 6) / 5 * 255;\n const b = rem % 6 / 5 * 255;\n return [r, g, b];\n};\nconvert.rgb.hex = function(args) {\n const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);\n const string = integer.toString(16).toUpperCase();\n return \"000000\".slice(string.length) + string;\n};\nconvert.hex.rgb = function(args) {\n const match = args.toString(16).match(/[a-f\\d]{6}|[a-f\\d]{3}/i);\n if (!match) {\n return [0, 0, 0];\n }\n let colorString = match[0];\n if (match[0].length === 3) {\n colorString = [...colorString].map((char) => char + char).join(\"\");\n }\n const integer = Number.parseInt(colorString, 16);\n const r = integer >> 16 & 255;\n const g = integer >> 8 & 255;\n const b = integer & 255;\n return [r, g, b];\n};\nconvert.rgb.hcg = function(rgb) {\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n const max = Math.max(Math.max(r, g), b);\n const min = Math.min(Math.min(r, g), b);\n const chroma = max - min;\n let hue;\n const grayscale = chroma < 1 ? min / (1 - chroma) : 0;\n if (chroma <= 0) {\n hue = 0;\n } else if (max === r) {\n hue = (g - b) / chroma % 6;\n } else if (max === g) {\n hue = 2 + (b - r) / chroma;\n } else {\n hue = 4 + (r - g) / chroma;\n }\n hue /= 6;\n hue %= 1;\n return [hue * 360, chroma * 100, grayscale * 100];\n};\nconvert.hsl.hcg = function(hsl) {\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);\n let f = 0;\n if (c < 1) {\n f = (l - 0.5 * c) / (1 - c);\n }\n return [hsl[0], c * 100, f * 100];\n};\nconvert.hsv.hcg = function(hsv) {\n const s = hsv[1] / 100;\n const v = hsv[2] / 100;\n const c = s * v;\n let f = 0;\n if (c < 1) {\n f = (v - c) / (1 - c);\n }\n return [hsv[0], c * 100, f * 100];\n};\nconvert.hcg.rgb = function(hcg) {\n const h = hcg[0] / 360;\n const c = hcg[1] / 100;\n const g = hcg[2] / 100;\n if (c === 0) {\n return [g * 255, g * 255, g * 255];\n }\n const pure = [0, 0, 0];\n const hi = h % 1 * 6;\n const v = hi % 1;\n const w = 1 - v;\n let mg = 0;\n switch (Math.floor(hi)) {\n case 0: {\n pure[0] = 1;\n pure[1] = v;\n pure[2] = 0;\n break;\n }\n case 1: {\n pure[0] = w;\n pure[1] = 1;\n pure[2] = 0;\n break;\n }\n case 2: {\n pure[0] = 0;\n pure[1] = 1;\n pure[2] = v;\n break;\n }\n case 3: {\n pure[0] = 0;\n pure[1] = w;\n pure[2] = 1;\n break;\n }\n case 4: {\n pure[0] = v;\n pure[1] = 0;\n pure[2] = 1;\n break;\n }\n default: {\n pure[0] = 1;\n pure[1] = 0;\n pure[2] = w;\n }\n }\n mg = (1 - c) * g;\n return [\n (c * pure[0] + mg) * 255,\n (c * pure[1] + mg) * 255,\n (c * pure[2] + mg) * 255\n ];\n};\nconvert.hcg.hsv = function(hcg) {\n const c = hcg[1] / 100;\n const g = hcg[2] / 100;\n const v = c + g * (1 - c);\n let f = 0;\n if (v > 0) {\n f = c / v;\n }\n return [hcg[0], f * 100, v * 100];\n};\nconvert.hcg.hsl = function(hcg) {\n const c = hcg[1] / 100;\n const g = hcg[2] / 100;\n const l = g * (1 - c) + 0.5 * c;\n let s = 0;\n if (l > 0 && l < 0.5) {\n s = c / (2 * l);\n } else if (l >= 0.5 && l < 1) {\n s = c / (2 * (1 - l));\n }\n return [hcg[0], s * 100, l * 100];\n};\nconvert.hcg.hwb = function(hcg) {\n const c = hcg[1] / 100;\n const g = hcg[2] / 100;\n const v = c + g * (1 - c);\n return [hcg[0], (v - c) * 100, (1 - v) * 100];\n};\nconvert.hwb.hcg = function(hwb) {\n const w = hwb[1] / 100;\n const b = hwb[2] / 100;\n const v = 1 - b;\n const c = v - w;\n let g = 0;\n if (c < 1) {\n g = (v - c) / (1 - c);\n }\n return [hwb[0], c * 100, g * 100];\n};\nconvert.apple.rgb = function(apple) {\n return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];\n};\nconvert.rgb.apple = function(rgb) {\n return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];\n};\nconvert.gray.rgb = function(args) {\n return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];\n};\nconvert.gray.hsl = function(args) {\n return [0, 0, args[0]];\n};\nconvert.gray.hsv = convert.gray.hsl;\nconvert.gray.hwb = function(gray) {\n return [0, 100, gray[0]];\n};\nconvert.gray.cmyk = function(gray) {\n return [0, 0, 0, gray[0]];\n};\nconvert.gray.lab = function(gray) {\n return [gray[0], 0, 0];\n};\nconvert.gray.hex = function(gray) {\n const value = Math.round(gray[0] / 100 * 255) & 255;\n const integer = (value << 16) + (value << 8) + value;\n const string = integer.toString(16).toUpperCase();\n return \"000000\".slice(string.length) + string;\n};\nconvert.rgb.gray = function(rgb) {\n const value = (rgb[0] + rgb[1] + rgb[2]) / 3;\n return [value / 255 * 100];\n};\n\n// node_modules/color-convert/route.js\nfunction buildGraph() {\n const graph = {};\n const models2 = Object.keys(conversions_default);\n for (let { length } = models2, i = 0; i < length; i++) {\n graph[models2[i]] = {\n // http://jsperf.com/1-vs-infinity\n // micro-opt, but this is simple.\n distance: -1,\n parent: null\n };\n }\n return graph;\n}\nfunction deriveBFS(fromModel) {\n const graph = buildGraph();\n const queue = [fromModel];\n graph[fromModel].distance = 0;\n while (queue.length > 0) {\n const current = queue.pop();\n const adjacents = Object.keys(conversions_default[current]);\n for (let { length } = adjacents, i = 0; i < length; i++) {\n const adjacent = adjacents[i];\n const node = graph[adjacent];\n if (node.distance === -1) {\n node.distance = graph[current].distance + 1;\n node.parent = current;\n queue.unshift(adjacent);\n }\n }\n }\n return graph;\n}\nfunction link(from, to) {\n return function(args) {\n return to(from(args));\n };\n}\nfunction wrapConversion(toModel, graph) {\n const path = [graph[toModel].parent, toModel];\n let fn = conversions_default[graph[toModel].parent][toModel];\n let cur = graph[toModel].parent;\n while (graph[cur].parent) {\n path.unshift(graph[cur].parent);\n fn = link(conversions_default[graph[cur].parent][cur], fn);\n cur = graph[cur].parent;\n }\n fn.conversion = path;\n return fn;\n}\nfunction route(fromModel) {\n const graph = deriveBFS(fromModel);\n const conversion = {};\n const models2 = Object.keys(graph);\n for (let { length } = models2, i = 0; i < length; i++) {\n const toModel = models2[i];\n const node = graph[toModel];\n if (node.parent === null) {\n continue;\n }\n conversion[toModel] = wrapConversion(toModel, graph);\n }\n return conversion;\n}\nvar route_default = route;\n\n// node_modules/color-convert/index.js\nvar convert2 = {};\nvar models = Object.keys(conversions_default);\nfunction wrapRaw(fn) {\n const wrappedFn = function(...args) {\n const arg0 = args[0];\n if (arg0 === void 0 || arg0 === null) {\n return arg0;\n }\n if (arg0.length > 1) {\n args = arg0;\n }\n return fn(args);\n };\n if (\"conversion\" in fn) {\n wrappedFn.conversion = fn.conversion;\n }\n return wrappedFn;\n}\nfunction wrapRounded(fn) {\n const wrappedFn = function(...args) {\n const arg0 = args[0];\n if (arg0 === void 0 || arg0 === null) {\n return arg0;\n }\n if (arg0.length > 1) {\n args = arg0;\n }\n const result = fn(args);\n if (typeof result === \"object\") {\n for (let { length } = result, i = 0; i < length; i++) {\n result[i] = Math.round(result[i]);\n }\n }\n return result;\n };\n if (\"conversion\" in fn) {\n wrappedFn.conversion = fn.conversion;\n }\n return wrappedFn;\n}\nfor (const fromModel of models) {\n convert2[fromModel] = {};\n Object.defineProperty(convert2[fromModel], \"channels\", { value: conversions_default[fromModel].channels });\n Object.defineProperty(convert2[fromModel], \"labels\", { value: conversions_default[fromModel].labels });\n const routes = route_default(fromModel);\n const routeModels = Object.keys(routes);\n for (const toModel of routeModels) {\n const fn = routes[toModel];\n convert2[fromModel][toModel] = wrapRounded(fn);\n convert2[fromModel][toModel].raw = wrapRaw(fn);\n }\n}\nvar color_convert_default = convert2;\n\n// node_modules/color/index.js\nvar skippedModels = [\n // To be honest, I don't really feel like keyword belongs in color convert, but eh.\n \"keyword\",\n // Gray conflicts with some method names, and has its own method defined.\n \"gray\",\n // Shouldn't really be in color-convert either...\n \"hex\"\n];\nvar hashedModelKeys = {};\nfor (const model of Object.keys(color_convert_default)) {\n hashedModelKeys[[...color_convert_default[model].labels].sort().join(\"\")] = model;\n}\nvar limiters = {};\nfunction Color(object, model) {\n if (!(this instanceof Color)) {\n return new Color(object, model);\n }\n if (model && model in skippedModels) {\n model = null;\n }\n if (model && !(model in color_convert_default)) {\n throw new Error(\"Unknown model: \" + model);\n }\n let i;\n let channels;\n if (object == null) {\n this.model = \"rgb\";\n this.color = [0, 0, 0];\n this.valpha = 1;\n } else if (object instanceof Color) {\n this.model = object.model;\n this.color = [...object.color];\n this.valpha = object.valpha;\n } else if (typeof object === \"string\") {\n const result = color_string_default.get(object);\n if (result === null) {\n throw new Error(\"Unable to parse color from string: \" + object);\n }\n this.model = result.model;\n channels = color_convert_default[this.model].channels;\n this.color = result.value.slice(0, channels);\n this.valpha = typeof result.value[channels] === \"number\" ? result.value[channels] : 1;\n } else if (object.length > 0) {\n this.model = model || \"rgb\";\n channels = color_convert_default[this.model].channels;\n const newArray = Array.prototype.slice.call(object, 0, channels);\n this.color = zeroArray(newArray, channels);\n this.valpha = typeof object[channels] === \"number\" ? object[channels] : 1;\n } else if (typeof object === \"number\") {\n this.model = \"rgb\";\n this.color = [\n object >> 16 & 255,\n object >> 8 & 255,\n object & 255\n ];\n this.valpha = 1;\n } else {\n this.valpha = 1;\n const keys = Object.keys(object);\n if (\"alpha\" in object) {\n keys.splice(keys.indexOf(\"alpha\"), 1);\n this.valpha = typeof object.alpha === \"number\" ? object.alpha : 0;\n }\n const hashedKeys = keys.sort().join(\"\");\n if (!(hashedKeys in hashedModelKeys)) {\n throw new Error(\"Unable to parse color from object: \" + JSON.stringify(object));\n }\n this.model = hashedModelKeys[hashedKeys];\n const { labels } = color_convert_default[this.model];\n const color = [];\n for (i = 0; i < labels.length; i++) {\n color.push(object[labels[i]]);\n }\n this.color = zeroArray(color);\n }\n if (limiters[this.model]) {\n channels = color_convert_default[this.model].channels;\n for (i = 0; i < channels; i++) {\n const limit = limiters[this.model][i];\n if (limit) {\n this.color[i] = limit(this.color[i]);\n }\n }\n }\n this.valpha = Math.max(0, Math.min(1, this.valpha));\n if (Object.freeze) {\n Object.freeze(this);\n }\n}\nColor.prototype = {\n toString() {\n return this.string();\n },\n toJSON() {\n return this[this.model]();\n },\n string(places) {\n let self = this.model in color_string_default.to ? this : this.rgb();\n self = self.round(typeof places === \"number\" ? places : 1);\n const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];\n return color_string_default.to[self.model](...arguments_);\n },\n percentString(places) {\n const self = this.rgb().round(typeof places === \"number\" ? places : 1);\n const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];\n return color_string_default.to.rgb.percent(...arguments_);\n },\n array() {\n return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];\n },\n object() {\n const result = {};\n const { channels } = color_convert_default[this.model];\n const { labels } = color_convert_default[this.model];\n for (let i = 0; i < channels; i++) {\n result[labels[i]] = this.color[i];\n }\n if (this.valpha !== 1) {\n result.alpha = this.valpha;\n }\n return result;\n },\n unitArray() {\n const rgb = this.rgb().color;\n rgb[0] /= 255;\n rgb[1] /= 255;\n rgb[2] /= 255;\n if (this.valpha !== 1) {\n rgb.push(this.valpha);\n }\n return rgb;\n },\n unitObject() {\n const rgb = this.rgb().object();\n rgb.r /= 255;\n rgb.g /= 255;\n rgb.b /= 255;\n if (this.valpha !== 1) {\n rgb.alpha = this.valpha;\n }\n return rgb;\n },\n round(places) {\n places = Math.max(places || 0, 0);\n return new Color([...this.color.map(roundToPlace(places)), this.valpha], this.model);\n },\n alpha(value) {\n if (value !== void 0) {\n return new Color([...this.color, Math.max(0, Math.min(1, value))], this.model);\n }\n return this.valpha;\n },\n // Rgb\n red: getset(\"rgb\", 0, maxfn(255)),\n green: getset(\"rgb\", 1, maxfn(255)),\n blue: getset(\"rgb\", 2, maxfn(255)),\n hue: getset([\"hsl\", \"hsv\", \"hsl\", \"hwb\", \"hcg\"], 0, (value) => (value % 360 + 360) % 360),\n saturationl: getset(\"hsl\", 1, maxfn(100)),\n lightness: getset(\"hsl\", 2, maxfn(100)),\n saturationv: getset(\"hsv\", 1, maxfn(100)),\n value: getset(\"hsv\", 2, maxfn(100)),\n chroma: getset(\"hcg\", 1, maxfn(100)),\n gray: getset(\"hcg\", 2, maxfn(100)),\n white: getset(\"hwb\", 1, maxfn(100)),\n wblack: getset(\"hwb\", 2, maxfn(100)),\n cyan: getset(\"cmyk\", 0, maxfn(100)),\n magenta: getset(\"cmyk\", 1, maxfn(100)),\n yellow: getset(\"cmyk\", 2, maxfn(100)),\n black: getset(\"cmyk\", 3, maxfn(100)),\n x: getset(\"xyz\", 0, maxfn(95.047)),\n y: getset(\"xyz\", 1, maxfn(100)),\n z: getset(\"xyz\", 2, maxfn(108.833)),\n l: getset(\"lab\", 0, maxfn(100)),\n a: getset(\"lab\", 1),\n b: getset(\"lab\", 2),\n keyword(value) {\n if (value !== void 0) {\n return new Color(value);\n }\n return color_convert_default[this.model].keyword(this.color);\n },\n hex(value) {\n if (value !== void 0) {\n return new Color(value);\n }\n return color_string_default.to.hex(...this.rgb().round().color);\n },\n hexa(value) {\n if (value !== void 0) {\n return new Color(value);\n }\n const rgbArray = this.rgb().round().color;\n let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();\n if (alphaHex.length === 1) {\n alphaHex = \"0\" + alphaHex;\n }\n return color_string_default.to.hex(...rgbArray) + alphaHex;\n },\n rgbNumber() {\n const rgb = this.rgb().color;\n return (rgb[0] & 255) << 16 | (rgb[1] & 255) << 8 | rgb[2] & 255;\n },\n luminosity() {\n const rgb = this.rgb().color;\n const lum = [];\n for (const [i, element] of rgb.entries()) {\n const chan = element / 255;\n lum[i] = chan <= 0.04045 ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;\n }\n return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];\n },\n contrast(color2) {\n const lum1 = this.luminosity();\n const lum2 = color2.luminosity();\n if (lum1 > lum2) {\n return (lum1 + 0.05) / (lum2 + 0.05);\n }\n return (lum2 + 0.05) / (lum1 + 0.05);\n },\n level(color2) {\n const contrastRatio = this.contrast(color2);\n if (contrastRatio >= 7) {\n return \"AAA\";\n }\n return contrastRatio >= 4.5 ? \"AA\" : \"\";\n },\n isDark() {\n const rgb = this.rgb().color;\n const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 1e4;\n return yiq < 128;\n },\n isLight() {\n return !this.isDark();\n },\n negate() {\n const rgb = this.rgb();\n for (let i = 0; i < 3; i++) {\n rgb.color[i] = 255 - rgb.color[i];\n }\n return rgb;\n },\n lighten(ratio) {\n const hsl = this.hsl();\n hsl.color[2] += hsl.color[2] * ratio;\n return hsl;\n },\n darken(ratio) {\n const hsl = this.hsl();\n hsl.color[2] -= hsl.color[2] * ratio;\n return hsl;\n },\n saturate(ratio) {\n const hsl = this.hsl();\n hsl.color[1] += hsl.color[1] * ratio;\n return hsl;\n },\n desaturate(ratio) {\n const hsl = this.hsl();\n hsl.color[1] -= hsl.color[1] * ratio;\n return hsl;\n },\n whiten(ratio) {\n const hwb = this.hwb();\n hwb.color[1] += hwb.color[1] * ratio;\n return hwb;\n },\n blacken(ratio) {\n const hwb = this.hwb();\n hwb.color[2] += hwb.color[2] * ratio;\n return hwb;\n },\n grayscale() {\n const rgb = this.rgb().color;\n const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;\n return Color.rgb(value, value, value);\n },\n fade(ratio) {\n return this.alpha(this.valpha - this.valpha * ratio);\n },\n opaquer(ratio) {\n return this.alpha(this.valpha + this.valpha * ratio);\n },\n rotate(degrees) {\n const hsl = this.hsl();\n let hue = hsl.color[0];\n hue = (hue + degrees) % 360;\n hue = hue < 0 ? 360 + hue : hue;\n hsl.color[0] = hue;\n return hsl;\n },\n mix(mixinColor, weight) {\n if (!mixinColor || !mixinColor.rgb) {\n throw new Error('Argument to \"mix\" was not a Color instance, but rather an instance of ' + typeof mixinColor);\n }\n const color1 = mixinColor.rgb();\n const color2 = this.rgb();\n const p = weight === void 0 ? 0.5 : weight;\n const w = 2 * p - 1;\n const a = color1.alpha() - color2.alpha();\n const w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2;\n const w2 = 1 - w1;\n return Color.rgb(\n w1 * color1.red() + w2 * color2.red(),\n w1 * color1.green() + w2 * color2.green(),\n w1 * color1.blue() + w2 * color2.blue(),\n color1.alpha() * p + color2.alpha() * (1 - p)\n );\n }\n};\nfor (const model of Object.keys(color_convert_default)) {\n if (skippedModels.includes(model)) {\n continue;\n }\n const { channels } = color_convert_default[model];\n Color.prototype[model] = function(...arguments_) {\n if (this.model === model) {\n return new Color(this);\n }\n if (arguments_.length > 0) {\n return new Color(arguments_, model);\n }\n return new Color([...assertArray(color_convert_default[this.model][model].raw(this.color)), this.valpha], model);\n };\n Color[model] = function(...arguments_) {\n let color = arguments_[0];\n if (typeof color === \"number\") {\n color = zeroArray(arguments_, channels);\n }\n return new Color(color, model);\n };\n}\nfunction roundTo(number, places) {\n return Number(number.toFixed(places));\n}\nfunction roundToPlace(places) {\n return function(number) {\n return roundTo(number, places);\n };\n}\nfunction getset(model, channel, modifier) {\n model = Array.isArray(model) ? model : [model];\n for (const m of model) {\n (limiters[m] ||= [])[channel] = modifier;\n }\n model = model[0];\n return function(value) {\n let result;\n if (value !== void 0) {\n if (modifier) {\n value = modifier(value);\n }\n result = this[model]();\n result.color[channel] = value;\n return result;\n }\n result = this[model]().color[channel];\n if (modifier) {\n result = modifier(result);\n }\n return result;\n };\n}\nfunction maxfn(max) {\n return function(v) {\n return Math.max(0, Math.min(max, v));\n };\n}\nfunction assertArray(value) {\n return Array.isArray(value) ? value : [value];\n}\nfunction zeroArray(array, length) {\n for (let i = 0; i < length; i++) {\n if (typeof array[i] !== \"number\") {\n array[i] = 0;\n }\n }\n return array;\n}\nvar index_default = Color;\n", "module.exports = require(\"./color.cjs\").default;\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst color = require('@img/colour');\nconst is = require('./is');\n\n/**\n * Colourspaces.\n * @private\n */\nconst colourspace = {\n multiband: 'multiband',\n 'b-w': 'b-w',\n bw: 'b-w',\n cmyk: 'cmyk',\n srgb: 'srgb'\n};\n\n/**\n * Tint the image using the provided colour.\n * An alpha channel may be present and will be unchanged by the operation.\n *\n * @example\n * const output = await sharp(input)\n * .tint({ r: 255, g: 240, b: 16 })\n * .toBuffer();\n *\n * @param {string|Object} tint - Parsed by the [color](https://www.npmjs.org/package/color) module.\n * @returns {Sharp}\n * @throws {Error} Invalid parameter\n */\nfunction tint (tint) {\n this._setBackgroundColourOption('tint', tint);\n return this;\n}\n\n/**\n * Convert to 8-bit greyscale; 256 shades of grey.\n * This is a linear operation. If the input image is in a non-linear colour space such as sRGB, use `gamma()` with `greyscale()` for the best results.\n * By default the output image will be web-friendly sRGB and contain three (identical) colour channels.\n * This may be overridden by other sharp operations such as `toColourspace('b-w')`,\n * which will produce an output image containing one colour channel.\n * An alpha channel may be present, and will be unchanged by the operation.\n *\n * @example\n * const output = await sharp(input).greyscale().toBuffer();\n *\n * @param {Boolean} [greyscale=true]\n * @returns {Sharp}\n */\nfunction greyscale (greyscale) {\n this.options.greyscale = is.bool(greyscale) ? greyscale : true;\n return this;\n}\n\n/**\n * Alternative spelling of `greyscale`.\n * @param {Boolean} [grayscale=true]\n * @returns {Sharp}\n */\nfunction grayscale (grayscale) {\n return this.greyscale(grayscale);\n}\n\n/**\n * Set the pipeline colourspace.\n *\n * The input image will be converted to the provided colourspace at the start of the pipeline.\n * All operations will use this colourspace before converting to the output colourspace,\n * as defined by {@link #tocolourspace toColourspace}.\n *\n * @since 0.29.0\n *\n * @example\n * // Run pipeline in 16 bits per channel RGB while converting final result to 8 bits per channel sRGB.\n * await sharp(input)\n * .pipelineColourspace('rgb16')\n * .toColourspace('srgb')\n * .toFile('16bpc-pipeline-to-8bpc-output.png')\n *\n * @param {string} [colourspace] - pipeline colourspace e.g. `rgb16`, `scrgb`, `lab`, `grey16` [...](https://www.libvips.org/API/current/enum.Interpretation.html)\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction pipelineColourspace (colourspace) {\n if (!is.string(colourspace)) {\n throw is.invalidParameterError('colourspace', 'string', colourspace);\n }\n this.options.colourspacePipeline = colourspace;\n return this;\n}\n\n/**\n * Alternative spelling of `pipelineColourspace`.\n * @param {string} [colorspace] - pipeline colorspace.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction pipelineColorspace (colorspace) {\n return this.pipelineColourspace(colorspace);\n}\n\n/**\n * Set the output colourspace.\n * By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.\n *\n * @example\n * // Output 16 bits per pixel RGB\n * await sharp(input)\n * .toColourspace('rgb16')\n * .toFile('16-bpp.png')\n *\n * @param {string} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/enum.Interpretation.html)\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction toColourspace (colourspace) {\n if (!is.string(colourspace)) {\n throw is.invalidParameterError('colourspace', 'string', colourspace);\n }\n this.options.colourspace = colourspace;\n return this;\n}\n\n/**\n * Alternative spelling of `toColourspace`.\n * @param {string} [colorspace] - output colorspace.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction toColorspace (colorspace) {\n return this.toColourspace(colorspace);\n}\n\n/**\n * Create a RGBA colour array from a given value.\n * @private\n * @param {string|Object} value\n * @throws {Error} Invalid value\n */\nfunction _getBackgroundColourOption (value) {\n if (\n is.object(value) ||\n (is.string(value) && value.length >= 3 && value.length <= 200)\n ) {\n const colour = color(value);\n return [\n colour.red(),\n colour.green(),\n colour.blue(),\n Math.round(colour.alpha() * 255)\n ];\n } else {\n throw is.invalidParameterError('background', 'object or string', value);\n }\n}\n\n/**\n * Update a colour attribute of the this.options Object.\n * @private\n * @param {string} key\n * @param {string|Object} value\n * @throws {Error} Invalid value\n */\nfunction _setBackgroundColourOption (key, value) {\n if (is.defined(value)) {\n this.options[key] = _getBackgroundColourOption(value);\n }\n}\n\n/**\n * Decorate the Sharp prototype with colour-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n // Public\n tint,\n greyscale,\n grayscale,\n pipelineColourspace,\n pipelineColorspace,\n toColourspace,\n toColorspace,\n // Private\n _getBackgroundColourOption,\n _setBackgroundColourOption\n });\n // Class attributes\n Sharp.colourspace = colourspace;\n Sharp.colorspace = colourspace;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst is = require('./is');\n\n/**\n * Boolean operations for bandbool.\n * @private\n */\nconst bool = {\n and: 'and',\n or: 'or',\n eor: 'eor'\n};\n\n/**\n * Remove alpha channels, if any. This is a no-op if the image does not have an alpha channel.\n *\n * See also {@link /api-operation/#flatten flatten}.\n *\n * @example\n * sharp('rgba.png')\n * .removeAlpha()\n * .toFile('rgb.png', function(err, info) {\n * // rgb.png is a 3 channel image without an alpha channel\n * });\n *\n * @returns {Sharp}\n */\nfunction removeAlpha () {\n this.options.removeAlpha = true;\n return this;\n}\n\n/**\n * Ensure the output image has an alpha transparency channel.\n * If missing, the added alpha channel will have the specified\n * transparency level, defaulting to fully-opaque (1).\n * This is a no-op if the image already has an alpha channel.\n *\n * @since 0.21.2\n *\n * @example\n * // rgba.png will be a 4 channel image with a fully-opaque alpha channel\n * await sharp('rgb.jpg')\n * .ensureAlpha()\n * .toFile('rgba.png')\n *\n * @example\n * // rgba is a 4 channel image with a fully-transparent alpha channel\n * const rgba = await sharp(rgb)\n * .ensureAlpha(0)\n * .toBuffer();\n *\n * @param {number} [alpha=1] - alpha transparency level (0=fully-transparent, 1=fully-opaque)\n * @returns {Sharp}\n * @throws {Error} Invalid alpha transparency level\n */\nfunction ensureAlpha (alpha) {\n if (is.defined(alpha)) {\n if (is.number(alpha) && is.inRange(alpha, 0, 1)) {\n this.options.ensureAlpha = alpha;\n } else {\n throw is.invalidParameterError('alpha', 'number between 0 and 1', alpha);\n }\n } else {\n this.options.ensureAlpha = 1;\n }\n return this;\n}\n\n/**\n * Extract a single channel from a multi-channel image.\n *\n * The output colourspace will be either `b-w` (8-bit) or `grey16` (16-bit).\n *\n * @example\n * // green.jpg is a greyscale image containing the green channel of the input\n * await sharp(input)\n * .extractChannel('green')\n * .toFile('green.jpg');\n *\n * @example\n * // red1 is the red value of the first pixel, red2 the second pixel etc.\n * const [red1, red2, ...] = await sharp(input)\n * .extractChannel(0)\n * .raw()\n * .toBuffer();\n *\n * @param {number|string} channel - zero-indexed channel/band number to extract, or `red`, `green`, `blue` or `alpha`.\n * @returns {Sharp}\n * @throws {Error} Invalid channel\n */\nfunction extractChannel (channel) {\n const channelMap = { red: 0, green: 1, blue: 2, alpha: 3 };\n if (Object.keys(channelMap).includes(channel)) {\n channel = channelMap[channel];\n }\n if (is.integer(channel) && is.inRange(channel, 0, 4)) {\n this.options.extractChannel = channel;\n } else {\n throw is.invalidParameterError('channel', 'integer or one of: red, green, blue, alpha', channel);\n }\n return this;\n}\n\n/**\n * Join one or more channels to the image.\n * The meaning of the added channels depends on the output colourspace, set with `toColourspace()`.\n * By default the output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.\n * Channel ordering follows vips convention:\n * - sRGB: 0: Red, 1: Green, 2: Blue, 3: Alpha.\n * - CMYK: 0: Magenta, 1: Cyan, 2: Yellow, 3: Black, 4: Alpha.\n *\n * Buffers may be any of the image formats supported by sharp.\n * For raw pixel input, the `options` object should contain a `raw` attribute, which follows the format of the attribute of the same name in the `sharp()` constructor.\n *\n * @param {Array<string|Buffer>|string|Buffer} images - one or more images (file paths, Buffers).\n * @param {Object} options - image options, see `sharp()` constructor.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction joinChannel (images, options) {\n if (Array.isArray(images)) {\n images.forEach(function (image) {\n this.options.joinChannelIn.push(this._createInputDescriptor(image, options));\n }, this);\n } else {\n this.options.joinChannelIn.push(this._createInputDescriptor(images, options));\n }\n return this;\n}\n\n/**\n * Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image.\n *\n * @example\n * sharp('3-channel-rgb-input.png')\n * .bandbool(sharp.bool.and)\n * .toFile('1-channel-output.png', function (err, info) {\n * // The output will be a single channel image where each pixel `P = R & G & B`.\n * // If `I(1,1) = [247, 170, 14] = [0b11110111, 0b10101010, 0b00001111]`\n * // then `O(1,1) = 0b11110111 & 0b10101010 & 0b00001111 = 0b00000010 = 2`.\n * });\n *\n * @param {string} boolOp - one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction bandbool (boolOp) {\n if (is.string(boolOp) && is.inArray(boolOp, ['and', 'or', 'eor'])) {\n this.options.bandBoolOp = boolOp;\n } else {\n throw is.invalidParameterError('boolOp', 'one of: and, or, eor', boolOp);\n }\n return this;\n}\n\n/**\n * Decorate the Sharp prototype with channel-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n // Public instance functions\n removeAlpha,\n ensureAlpha,\n extractChannel,\n joinChannel,\n bandbool\n });\n // Class attributes\n Sharp.bool = bool;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst path = require('node:path');\nconst is = require('./is');\nconst sharp = require('./sharp');\n\nconst formats = new Map([\n ['heic', 'heif'],\n ['heif', 'heif'],\n ['avif', 'avif'],\n ['jpeg', 'jpeg'],\n ['jpg', 'jpeg'],\n ['jpe', 'jpeg'],\n ['tile', 'tile'],\n ['dz', 'tile'],\n ['png', 'png'],\n ['raw', 'raw'],\n ['tiff', 'tiff'],\n ['tif', 'tiff'],\n ['webp', 'webp'],\n ['gif', 'gif'],\n ['jp2', 'jp2'],\n ['jpx', 'jp2'],\n ['j2k', 'jp2'],\n ['j2c', 'jp2'],\n ['jxl', 'jxl']\n]);\n\nconst jp2Regex = /\\.(jp[2x]|j2[kc])$/i;\n\nconst errJp2Save = () => new Error('JP2 output requires libvips with support for OpenJPEG');\n\nconst bitdepthFromColourCount = (colours) => 1 << 31 - Math.clz32(Math.ceil(Math.log2(colours)));\n\n/**\n * Write output image data to a file.\n *\n * If an explicit output format is not selected, it will be inferred from the extension,\n * with JPEG, PNG, WebP, AVIF, TIFF, GIF, DZI, and libvips' V format supported.\n * Note that raw pixel data is only supported for buffer output.\n *\n * By default all metadata will be removed, which includes EXIF-based orientation.\n * See {@link #withmetadata withMetadata} for control over this.\n *\n * The caller is responsible for ensuring directory structures and permissions exist.\n *\n * A `Promise` is returned when `callback` is not provided.\n *\n * @example\n * sharp(input)\n * .toFile('output.png', (err, info) => { ... });\n *\n * @example\n * sharp(input)\n * .toFile('output.png')\n * .then(info => { ... })\n * .catch(err => { ... });\n *\n * @param {string} fileOut - the path to write the image data to.\n * @param {Function} [callback] - called on completion with two arguments `(err, info)`.\n * `info` contains the output image `format`, `size` (bytes), `width`, `height`,\n * `channels` and `premultiplied` (indicating if premultiplication was used).\n * When using a crop strategy also contains `cropOffsetLeft` and `cropOffsetTop`.\n * When using the attention crop strategy also contains `attentionX` and `attentionY`, the focal point of the cropped region.\n * Animated output will also contain `pageHeight` and `pages`.\n * May also contain `textAutofitDpi` (dpi the font was rendered at) if image was created from text.\n * @returns {Promise<Object>} - when no callback is provided\n * @throws {Error} Invalid parameters\n */\nfunction toFile (fileOut, callback) {\n let err;\n if (!is.string(fileOut)) {\n err = new Error('Missing output file path');\n } else if (is.string(this.options.input.file) && path.resolve(this.options.input.file) === path.resolve(fileOut)) {\n err = new Error('Cannot use same file for input and output');\n } else if (jp2Regex.test(path.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {\n err = errJp2Save();\n }\n if (err) {\n if (is.fn(callback)) {\n callback(err);\n } else {\n return Promise.reject(err);\n }\n } else {\n this.options.fileOut = fileOut;\n const stack = Error();\n return this._pipeline(callback, stack);\n }\n return this;\n}\n\n/**\n * Write output to a Buffer.\n * JPEG, PNG, WebP, AVIF, TIFF, GIF and raw pixel data output are supported.\n *\n * Use {@link #toformat toFormat} or one of the format-specific functions such as {@link #jpeg jpeg}, {@link #png png} etc. to set the output format.\n *\n * If no explicit format is set, the output format will match the input image, except SVG input which becomes PNG output.\n *\n * By default all metadata will be removed, which includes EXIF-based orientation.\n * See {@link #withmetadata withMetadata} for control over this.\n *\n * `callback`, if present, gets three arguments `(err, data, info)` where:\n * - `err` is an error, if any.\n * - `data` is the output image data.\n * - `info` contains the output image `format`, `size` (bytes), `width`, `height`,\n * `channels` and `premultiplied` (indicating if premultiplication was used).\n * When using a crop strategy also contains `cropOffsetLeft` and `cropOffsetTop`.\n * Animated output will also contain `pageHeight` and `pages`.\n * May also contain `textAutofitDpi` (dpi the font was rendered at) if image was created from text.\n *\n * A `Promise` is returned when `callback` is not provided.\n *\n * @example\n * sharp(input)\n * .toBuffer((err, data, info) => { ... });\n *\n * @example\n * sharp(input)\n * .toBuffer()\n * .then(data => { ... })\n * .catch(err => { ... });\n *\n * @example\n * sharp(input)\n * .png()\n * .toBuffer({ resolveWithObject: true })\n * .then(({ data, info }) => { ... })\n * .catch(err => { ... });\n *\n * @example\n * const { data, info } = await sharp('my-image.jpg')\n * // output the raw pixels\n * .raw()\n * .toBuffer({ resolveWithObject: true });\n *\n * // create a more type safe way to work with the raw pixel data\n * // this will not copy the data, instead it will change `data`s underlying ArrayBuffer\n * // so `data` and `pixelArray` point to the same memory location\n * const pixelArray = new Uint8ClampedArray(data.buffer);\n *\n * // When you are done changing the pixelArray, sharp takes the `pixelArray` as an input\n * const { width, height, channels } = info;\n * await sharp(pixelArray, { raw: { width, height, channels } })\n * .toFile('my-changed-image.jpg');\n *\n * @param {Object} [options]\n * @param {boolean} [options.resolveWithObject] Resolve the Promise with an Object containing `data` and `info` properties instead of resolving only with `data`.\n * @param {Function} [callback]\n * @returns {Promise<Buffer>} - when no callback is provided\n */\nfunction toBuffer (options, callback) {\n if (is.object(options)) {\n this._setBooleanOption('resolveWithObject', options.resolveWithObject);\n } else if (this.options.resolveWithObject) {\n this.options.resolveWithObject = false;\n }\n this.options.fileOut = '';\n const stack = Error();\n return this._pipeline(is.fn(options) ? options : callback, stack);\n}\n\n/**\n * Keep all EXIF metadata from the input image in the output image.\n *\n * EXIF metadata is unsupported for TIFF output.\n *\n * @since 0.33.0\n *\n * @example\n * const outputWithExif = await sharp(inputWithExif)\n * .keepExif()\n * .toBuffer();\n *\n * @returns {Sharp}\n */\nfunction keepExif () {\n this.options.keepMetadata |= 0b00001;\n return this;\n}\n\n/**\n * Set EXIF metadata in the output image, ignoring any EXIF in the input image.\n *\n * @since 0.33.0\n *\n * @example\n * const dataWithExif = await sharp(input)\n * .withExif({\n * IFD0: {\n * Copyright: 'The National Gallery'\n * },\n * IFD3: {\n * GPSLatitudeRef: 'N',\n * GPSLatitude: '51/1 30/1 3230/100',\n * GPSLongitudeRef: 'W',\n * GPSLongitude: '0/1 7/1 4366/100'\n * }\n * })\n * .toBuffer();\n *\n * @param {Object<string, Object<string, string>>} exif Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction withExif (exif) {\n if (is.object(exif)) {\n for (const [ifd, entries] of Object.entries(exif)) {\n if (is.object(entries)) {\n for (const [k, v] of Object.entries(entries)) {\n if (is.string(v)) {\n this.options.withExif[`exif-${ifd.toLowerCase()}-${k}`] = v;\n } else {\n throw is.invalidParameterError(`${ifd}.${k}`, 'string', v);\n }\n }\n } else {\n throw is.invalidParameterError(ifd, 'object', entries);\n }\n }\n } else {\n throw is.invalidParameterError('exif', 'object', exif);\n }\n this.options.withExifMerge = false;\n return this.keepExif();\n}\n\n/**\n * Update EXIF metadata from the input image in the output image.\n *\n * @since 0.33.0\n *\n * @example\n * const dataWithMergedExif = await sharp(inputWithExif)\n * .withExifMerge({\n * IFD0: {\n * Copyright: 'The National Gallery'\n * }\n * })\n * .toBuffer();\n *\n * @param {Object<string, Object<string, string>>} exif Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction withExifMerge (exif) {\n this.withExif(exif);\n this.options.withExifMerge = true;\n return this;\n}\n\n/**\n * Keep ICC profile from the input image in the output image.\n *\n * When input and output colour spaces differ, use with {@link /api-colour/#tocolourspace toColourspace} and optionally {@link /api-colour/#pipelinecolourspace pipelineColourspace}.\n *\n * @since 0.33.0\n *\n * @example\n * const outputWithIccProfile = await sharp(inputWithIccProfile)\n * .keepIccProfile()\n * .toBuffer();\n *\n * @example\n * const cmykOutputWithIccProfile = await sharp(cmykInputWithIccProfile)\n * .pipelineColourspace('cmyk')\n * .toColourspace('cmyk')\n * .keepIccProfile()\n * .toBuffer();\n *\n * @returns {Sharp}\n */\nfunction keepIccProfile () {\n this.options.keepMetadata |= 0b01000;\n return this;\n}\n\n/**\n * Transform using an ICC profile and attach to the output image.\n *\n * This can either be an absolute filesystem path or\n * built-in profile name (`srgb`, `p3`, `cmyk`).\n *\n * @since 0.33.0\n *\n * @example\n * const outputWithP3 = await sharp(input)\n * .withIccProfile('p3')\n * .toBuffer();\n *\n * @param {string} icc - Absolute filesystem path to output ICC profile or built-in profile name (srgb, p3, cmyk).\n * @param {Object} [options]\n * @param {number} [options.attach=true] Should the ICC profile be included in the output image metadata?\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction withIccProfile (icc, options) {\n if (is.string(icc)) {\n this.options.withIccProfile = icc;\n } else {\n throw is.invalidParameterError('icc', 'string', icc);\n }\n this.keepIccProfile();\n if (is.object(options)) {\n if (is.defined(options.attach)) {\n if (is.bool(options.attach)) {\n if (!options.attach) {\n this.options.keepMetadata &= ~0b01000;\n }\n } else {\n throw is.invalidParameterError('attach', 'boolean', options.attach);\n }\n }\n }\n return this;\n}\n\n/**\n * Keep XMP metadata from the input image in the output image.\n *\n * @since 0.34.3\n *\n * @example\n * const outputWithXmp = await sharp(inputWithXmp)\n * .keepXmp()\n * .toBuffer();\n *\n * @returns {Sharp}\n */\nfunction keepXmp () {\n this.options.keepMetadata |= 0b00010;\n return this;\n}\n\n/**\n * Set XMP metadata in the output image.\n *\n * Supported by PNG, JPEG, WebP, and TIFF output.\n *\n * @since 0.34.3\n *\n * @example\n * const xmpString = `\n * <?xml version=\"1.0\"?>\n * <x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n * <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n * <rdf:Description rdf:about=\"\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n * <dc:creator><rdf:Seq><rdf:li>John Doe</rdf:li></rdf:Seq></dc:creator>\n * </rdf:Description>\n * </rdf:RDF>\n * </x:xmpmeta>`;\n *\n * const data = await sharp(input)\n * .withXmp(xmpString)\n * .toBuffer();\n *\n * @param {string} xmp String containing XMP metadata to be embedded in the output image.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction withXmp (xmp) {\n if (is.string(xmp) && xmp.length > 0) {\n this.options.withXmp = xmp;\n this.options.keepMetadata |= 0b00010;\n } else {\n throw is.invalidParameterError('xmp', 'non-empty string', xmp);\n }\n return this;\n}\n\n/**\n * Keep all metadata (EXIF, ICC, XMP, IPTC) from the input image in the output image.\n *\n * The default behaviour, when `keepMetadata` is not used, is to convert to the device-independent\n * sRGB colour space and strip all metadata, including the removal of any ICC profile.\n *\n * @since 0.33.0\n *\n * @example\n * const outputWithMetadata = await sharp(inputWithMetadata)\n * .keepMetadata()\n * .toBuffer();\n *\n * @returns {Sharp}\n */\nfunction keepMetadata () {\n this.options.keepMetadata = 0b11111;\n return this;\n}\n\n/**\n * Keep most metadata (EXIF, XMP, IPTC) from the input image in the output image.\n *\n * This will also convert to and add a web-friendly sRGB ICC profile if appropriate.\n *\n * Allows orientation and density to be set or updated.\n *\n * @example\n * const outputSrgbWithMetadata = await sharp(inputRgbWithMetadata)\n * .withMetadata()\n * .toBuffer();\n *\n * @example\n * // Set output metadata to 96 DPI\n * const data = await sharp(input)\n * .withMetadata({ density: 96 })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {number} [options.orientation] Used to update the EXIF `Orientation` tag, integer between 1 and 8.\n * @param {number} [options.density] Number of pixels per inch (DPI).\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction withMetadata (options) {\n this.keepMetadata();\n this.withIccProfile('srgb');\n if (is.object(options)) {\n if (is.defined(options.orientation)) {\n if (is.integer(options.orientation) && is.inRange(options.orientation, 1, 8)) {\n this.options.withMetadataOrientation = options.orientation;\n } else {\n throw is.invalidParameterError('orientation', 'integer between 1 and 8', options.orientation);\n }\n }\n if (is.defined(options.density)) {\n if (is.number(options.density) && options.density > 0) {\n this.options.withMetadataDensity = options.density;\n } else {\n throw is.invalidParameterError('density', 'positive number', options.density);\n }\n }\n if (is.defined(options.icc)) {\n this.withIccProfile(options.icc);\n }\n if (is.defined(options.exif)) {\n this.withExifMerge(options.exif);\n }\n }\n return this;\n}\n\n/**\n * Force output to a given format.\n *\n * @example\n * // Convert any input to PNG output\n * const data = await sharp(input)\n * .toFormat('png')\n * .toBuffer();\n *\n * @param {(string|Object)} format - as a string or an Object with an 'id' attribute\n * @param {Object} options - output options\n * @returns {Sharp}\n * @throws {Error} unsupported format or options\n */\nfunction toFormat (format, options) {\n const actualFormat = formats.get((is.object(format) && is.string(format.id) ? format.id : format).toLowerCase());\n if (!actualFormat) {\n throw is.invalidParameterError('format', `one of: ${[...formats.keys()].join(', ')}`, format);\n }\n return this[actualFormat](options);\n}\n\n/**\n * Use these JPEG options for output image.\n *\n * @example\n * // Convert any input to very high quality JPEG output\n * const data = await sharp(input)\n * .jpeg({\n * quality: 100,\n * chromaSubsampling: '4:4:4'\n * })\n * .toBuffer();\n *\n * @example\n * // Use mozjpeg to reduce output JPEG file size (slower)\n * const data = await sharp(input)\n * .jpeg({ mozjpeg: true })\n * .toBuffer();\n *\n * @param {Object} [options] - output options\n * @param {number} [options.quality=80] - quality, integer 1-100\n * @param {boolean} [options.progressive=false] - use progressive (interlace) scan\n * @param {string} [options.chromaSubsampling='4:2:0'] - set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling\n * @param {boolean} [options.optimiseCoding=true] - optimise Huffman coding tables\n * @param {boolean} [options.optimizeCoding=true] - alternative spelling of optimiseCoding\n * @param {boolean} [options.mozjpeg=false] - use mozjpeg defaults, equivalent to `{ trellisQuantisation: true, overshootDeringing: true, optimiseScans: true, quantisationTable: 3 }`\n * @param {boolean} [options.trellisQuantisation=false] - apply trellis quantisation\n * @param {boolean} [options.overshootDeringing=false] - apply overshoot deringing\n * @param {boolean} [options.optimiseScans=false] - optimise progressive scans, forces progressive\n * @param {boolean} [options.optimizeScans=false] - alternative spelling of optimiseScans\n * @param {number} [options.quantisationTable=0] - quantization table to use, integer 0-8\n * @param {number} [options.quantizationTable=0] - alternative spelling of quantisationTable\n * @param {boolean} [options.force=true] - force JPEG output, otherwise attempt to use input format\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction jpeg (options) {\n if (is.object(options)) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n this.options.jpegQuality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n }\n if (is.defined(options.progressive)) {\n this._setBooleanOption('jpegProgressive', options.progressive);\n }\n if (is.defined(options.chromaSubsampling)) {\n if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) {\n this.options.jpegChromaSubsampling = options.chromaSubsampling;\n } else {\n throw is.invalidParameterError('chromaSubsampling', 'one of: 4:2:0, 4:4:4', options.chromaSubsampling);\n }\n }\n const optimiseCoding = is.bool(options.optimizeCoding) ? options.optimizeCoding : options.optimiseCoding;\n if (is.defined(optimiseCoding)) {\n this._setBooleanOption('jpegOptimiseCoding', optimiseCoding);\n }\n if (is.defined(options.mozjpeg)) {\n if (is.bool(options.mozjpeg)) {\n if (options.mozjpeg) {\n this.options.jpegTrellisQuantisation = true;\n this.options.jpegOvershootDeringing = true;\n this.options.jpegOptimiseScans = true;\n this.options.jpegProgressive = true;\n this.options.jpegQuantisationTable = 3;\n }\n } else {\n throw is.invalidParameterError('mozjpeg', 'boolean', options.mozjpeg);\n }\n }\n const trellisQuantisation = is.bool(options.trellisQuantization) ? options.trellisQuantization : options.trellisQuantisation;\n if (is.defined(trellisQuantisation)) {\n this._setBooleanOption('jpegTrellisQuantisation', trellisQuantisation);\n }\n if (is.defined(options.overshootDeringing)) {\n this._setBooleanOption('jpegOvershootDeringing', options.overshootDeringing);\n }\n const optimiseScans = is.bool(options.optimizeScans) ? options.optimizeScans : options.optimiseScans;\n if (is.defined(optimiseScans)) {\n this._setBooleanOption('jpegOptimiseScans', optimiseScans);\n if (optimiseScans) {\n this.options.jpegProgressive = true;\n }\n }\n const quantisationTable = is.number(options.quantizationTable) ? options.quantizationTable : options.quantisationTable;\n if (is.defined(quantisationTable)) {\n if (is.integer(quantisationTable) && is.inRange(quantisationTable, 0, 8)) {\n this.options.jpegQuantisationTable = quantisationTable;\n } else {\n throw is.invalidParameterError('quantisationTable', 'integer between 0 and 8', quantisationTable);\n }\n }\n }\n return this._updateFormatOut('jpeg', options);\n}\n\n/**\n * Use these PNG options for output image.\n *\n * By default, PNG output is full colour at 8 bits per pixel.\n *\n * Indexed PNG input at 1, 2 or 4 bits per pixel is converted to 8 bits per pixel.\n * Set `palette` to `true` for slower, indexed PNG output.\n *\n * For 16 bits per pixel output, convert to `rgb16` via\n * {@link /api-colour/#tocolourspace toColourspace}.\n *\n * @example\n * // Convert any input to full colour PNG output\n * const data = await sharp(input)\n * .png()\n * .toBuffer();\n *\n * @example\n * // Convert any input to indexed PNG output (slower)\n * const data = await sharp(input)\n * .png({ palette: true })\n * .toBuffer();\n *\n * @example\n * // Output 16 bits per pixel RGB(A)\n * const data = await sharp(input)\n * .toColourspace('rgb16')\n * .png()\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {boolean} [options.progressive=false] - use progressive (interlace) scan\n * @param {number} [options.compressionLevel=6] - zlib compression level, 0 (fastest, largest) to 9 (slowest, smallest)\n * @param {boolean} [options.adaptiveFiltering=false] - use adaptive row filtering\n * @param {boolean} [options.palette=false] - quantise to a palette-based image with alpha transparency support\n * @param {number} [options.quality=100] - use the lowest number of colours needed to achieve given quality, sets `palette` to `true`\n * @param {number} [options.effort=7] - CPU effort, between 1 (fastest) and 10 (slowest), sets `palette` to `true`\n * @param {number} [options.colours=256] - maximum number of palette entries, sets `palette` to `true`\n * @param {number} [options.colors=256] - alternative spelling of `options.colours`, sets `palette` to `true`\n * @param {number} [options.dither=1.0] - level of Floyd-Steinberg error diffusion, sets `palette` to `true`\n * @param {boolean} [options.force=true] - force PNG output, otherwise attempt to use input format\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction png (options) {\n if (is.object(options)) {\n if (is.defined(options.progressive)) {\n this._setBooleanOption('pngProgressive', options.progressive);\n }\n if (is.defined(options.compressionLevel)) {\n if (is.integer(options.compressionLevel) && is.inRange(options.compressionLevel, 0, 9)) {\n this.options.pngCompressionLevel = options.compressionLevel;\n } else {\n throw is.invalidParameterError('compressionLevel', 'integer between 0 and 9', options.compressionLevel);\n }\n }\n if (is.defined(options.adaptiveFiltering)) {\n this._setBooleanOption('pngAdaptiveFiltering', options.adaptiveFiltering);\n }\n const colours = options.colours || options.colors;\n if (is.defined(colours)) {\n if (is.integer(colours) && is.inRange(colours, 2, 256)) {\n this.options.pngBitdepth = bitdepthFromColourCount(colours);\n } else {\n throw is.invalidParameterError('colours', 'integer between 2 and 256', colours);\n }\n }\n if (is.defined(options.palette)) {\n this._setBooleanOption('pngPalette', options.palette);\n } else if ([options.quality, options.effort, options.colours, options.colors, options.dither].some(is.defined)) {\n this._setBooleanOption('pngPalette', true);\n }\n if (this.options.pngPalette) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 0, 100)) {\n this.options.pngQuality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 0 and 100', options.quality);\n }\n }\n if (is.defined(options.effort)) {\n if (is.integer(options.effort) && is.inRange(options.effort, 1, 10)) {\n this.options.pngEffort = options.effort;\n } else {\n throw is.invalidParameterError('effort', 'integer between 1 and 10', options.effort);\n }\n }\n if (is.defined(options.dither)) {\n if (is.number(options.dither) && is.inRange(options.dither, 0, 1)) {\n this.options.pngDither = options.dither;\n } else {\n throw is.invalidParameterError('dither', 'number between 0.0 and 1.0', options.dither);\n }\n }\n }\n }\n return this._updateFormatOut('png', options);\n}\n\n/**\n * Use these WebP options for output image.\n *\n * @example\n * // Convert any input to lossless WebP output\n * const data = await sharp(input)\n * .webp({ lossless: true })\n * .toBuffer();\n *\n * @example\n * // Optimise the file size of an animated WebP\n * const outputWebp = await sharp(inputWebp, { animated: true })\n * .webp({ effort: 6 })\n * .toBuffer();\n *\n * @param {Object} [options] - output options\n * @param {number} [options.quality=80] - quality, integer 1-100\n * @param {number} [options.alphaQuality=100] - quality of alpha layer, integer 0-100\n * @param {boolean} [options.lossless=false] - use lossless compression mode\n * @param {boolean} [options.nearLossless=false] - use near_lossless compression mode\n * @param {boolean} [options.smartSubsample=false] - use high quality chroma subsampling\n * @param {boolean} [options.smartDeblock=false] - auto-adjust the deblocking filter, can improve low contrast edges (slow)\n * @param {string} [options.preset='default'] - named preset for preprocessing/filtering, one of: default, photo, picture, drawing, icon, text\n * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 6 (slowest)\n * @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation\n * @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)\n * @param {boolean} [options.minSize=false] - prevent use of animation key frames to minimise file size (slow)\n * @param {boolean} [options.mixed=false] - allow mixture of lossy and lossless animation frames (slow)\n * @param {boolean} [options.force=true] - force WebP output, otherwise attempt to use input format\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction webp (options) {\n if (is.object(options)) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n this.options.webpQuality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n }\n if (is.defined(options.alphaQuality)) {\n if (is.integer(options.alphaQuality) && is.inRange(options.alphaQuality, 0, 100)) {\n this.options.webpAlphaQuality = options.alphaQuality;\n } else {\n throw is.invalidParameterError('alphaQuality', 'integer between 0 and 100', options.alphaQuality);\n }\n }\n if (is.defined(options.lossless)) {\n this._setBooleanOption('webpLossless', options.lossless);\n }\n if (is.defined(options.nearLossless)) {\n this._setBooleanOption('webpNearLossless', options.nearLossless);\n }\n if (is.defined(options.smartSubsample)) {\n this._setBooleanOption('webpSmartSubsample', options.smartSubsample);\n }\n if (is.defined(options.smartDeblock)) {\n this._setBooleanOption('webpSmartDeblock', options.smartDeblock);\n }\n if (is.defined(options.preset)) {\n if (is.string(options.preset) && is.inArray(options.preset, ['default', 'photo', 'picture', 'drawing', 'icon', 'text'])) {\n this.options.webpPreset = options.preset;\n } else {\n throw is.invalidParameterError('preset', 'one of: default, photo, picture, drawing, icon, text', options.preset);\n }\n }\n if (is.defined(options.effort)) {\n if (is.integer(options.effort) && is.inRange(options.effort, 0, 6)) {\n this.options.webpEffort = options.effort;\n } else {\n throw is.invalidParameterError('effort', 'integer between 0 and 6', options.effort);\n }\n }\n if (is.defined(options.minSize)) {\n this._setBooleanOption('webpMinSize', options.minSize);\n }\n if (is.defined(options.mixed)) {\n this._setBooleanOption('webpMixed', options.mixed);\n }\n }\n trySetAnimationOptions(options, this.options);\n return this._updateFormatOut('webp', options);\n}\n\n/**\n * Use these GIF options for the output image.\n *\n * The first entry in the palette is reserved for transparency.\n *\n * The palette of the input image will be re-used if possible.\n *\n * @since 0.30.0\n *\n * @example\n * // Convert PNG to GIF\n * await sharp(pngBuffer)\n * .gif()\n * .toBuffer();\n *\n * @example\n * // Convert animated WebP to animated GIF\n * await sharp('animated.webp', { animated: true })\n * .toFile('animated.gif');\n *\n * @example\n * // Create a 128x128, cropped, non-dithered, animated thumbnail of an animated GIF\n * const out = await sharp('in.gif', { animated: true })\n * .resize({ width: 128, height: 128 })\n * .gif({ dither: 0 })\n * .toBuffer();\n *\n * @example\n * // Lossy file size reduction of animated GIF\n * await sharp('in.gif', { animated: true })\n * .gif({ interFrameMaxError: 8 })\n * .toFile('optim.gif');\n *\n * @param {Object} [options] - output options\n * @param {boolean} [options.reuse=true] - re-use existing palette, otherwise generate new (slow)\n * @param {boolean} [options.progressive=false] - use progressive (interlace) scan\n * @param {number} [options.colours=256] - maximum number of palette entries, including transparency, between 2 and 256\n * @param {number} [options.colors=256] - alternative spelling of `options.colours`\n * @param {number} [options.effort=7] - CPU effort, between 1 (fastest) and 10 (slowest)\n * @param {number} [options.dither=1.0] - level of Floyd-Steinberg error diffusion, between 0 (least) and 1 (most)\n * @param {number} [options.interFrameMaxError=0] - maximum inter-frame error for transparency, between 0 (lossless) and 32\n * @param {number} [options.interPaletteMaxError=3] - maximum inter-palette error for palette reuse, between 0 and 256\n * @param {boolean} [options.keepDuplicateFrames=false] - keep duplicate frames in the output instead of combining them\n * @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation\n * @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)\n * @param {boolean} [options.force=true] - force GIF output, otherwise attempt to use input format\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction gif (options) {\n if (is.object(options)) {\n if (is.defined(options.reuse)) {\n this._setBooleanOption('gifReuse', options.reuse);\n }\n if (is.defined(options.progressive)) {\n this._setBooleanOption('gifProgressive', options.progressive);\n }\n const colours = options.colours || options.colors;\n if (is.defined(colours)) {\n if (is.integer(colours) && is.inRange(colours, 2, 256)) {\n this.options.gifBitdepth = bitdepthFromColourCount(colours);\n } else {\n throw is.invalidParameterError('colours', 'integer between 2 and 256', colours);\n }\n }\n if (is.defined(options.effort)) {\n if (is.number(options.effort) && is.inRange(options.effort, 1, 10)) {\n this.options.gifEffort = options.effort;\n } else {\n throw is.invalidParameterError('effort', 'integer between 1 and 10', options.effort);\n }\n }\n if (is.defined(options.dither)) {\n if (is.number(options.dither) && is.inRange(options.dither, 0, 1)) {\n this.options.gifDither = options.dither;\n } else {\n throw is.invalidParameterError('dither', 'number between 0.0 and 1.0', options.dither);\n }\n }\n if (is.defined(options.interFrameMaxError)) {\n if (is.number(options.interFrameMaxError) && is.inRange(options.interFrameMaxError, 0, 32)) {\n this.options.gifInterFrameMaxError = options.interFrameMaxError;\n } else {\n throw is.invalidParameterError('interFrameMaxError', 'number between 0.0 and 32.0', options.interFrameMaxError);\n }\n }\n if (is.defined(options.interPaletteMaxError)) {\n if (is.number(options.interPaletteMaxError) && is.inRange(options.interPaletteMaxError, 0, 256)) {\n this.options.gifInterPaletteMaxError = options.interPaletteMaxError;\n } else {\n throw is.invalidParameterError('interPaletteMaxError', 'number between 0.0 and 256.0', options.interPaletteMaxError);\n }\n }\n if (is.defined(options.keepDuplicateFrames)) {\n if (is.bool(options.keepDuplicateFrames)) {\n this._setBooleanOption('gifKeepDuplicateFrames', options.keepDuplicateFrames);\n } else {\n throw is.invalidParameterError('keepDuplicateFrames', 'boolean', options.keepDuplicateFrames);\n }\n }\n }\n trySetAnimationOptions(options, this.options);\n return this._updateFormatOut('gif', options);\n}\n\n/**\n * Use these JP2 options for output image.\n *\n * Requires libvips compiled with support for OpenJPEG.\n * The prebuilt binaries do not include this - see\n * {@link /install#custom-libvips installing a custom libvips}.\n *\n * @example\n * // Convert any input to lossless JP2 output\n * const data = await sharp(input)\n * .jp2({ lossless: true })\n * .toBuffer();\n *\n * @example\n * // Convert any input to very high quality JP2 output\n * const data = await sharp(input)\n * .jp2({\n * quality: 100,\n * chromaSubsampling: '4:4:4'\n * })\n * .toBuffer();\n *\n * @since 0.29.1\n *\n * @param {Object} [options] - output options\n * @param {number} [options.quality=80] - quality, integer 1-100\n * @param {boolean} [options.lossless=false] - use lossless compression mode\n * @param {number} [options.tileWidth=512] - horizontal tile size\n * @param {number} [options.tileHeight=512] - vertical tile size\n * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction jp2 (options) {\n /* node:coverage ignore next 41 */\n if (!this.constructor.format.jp2k.output.buffer) {\n throw errJp2Save();\n }\n if (is.object(options)) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n this.options.jp2Quality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n }\n if (is.defined(options.lossless)) {\n if (is.bool(options.lossless)) {\n this.options.jp2Lossless = options.lossless;\n } else {\n throw is.invalidParameterError('lossless', 'boolean', options.lossless);\n }\n }\n if (is.defined(options.tileWidth)) {\n if (is.integer(options.tileWidth) && is.inRange(options.tileWidth, 1, 32768)) {\n this.options.jp2TileWidth = options.tileWidth;\n } else {\n throw is.invalidParameterError('tileWidth', 'integer between 1 and 32768', options.tileWidth);\n }\n }\n if (is.defined(options.tileHeight)) {\n if (is.integer(options.tileHeight) && is.inRange(options.tileHeight, 1, 32768)) {\n this.options.jp2TileHeight = options.tileHeight;\n } else {\n throw is.invalidParameterError('tileHeight', 'integer between 1 and 32768', options.tileHeight);\n }\n }\n if (is.defined(options.chromaSubsampling)) {\n if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) {\n this.options.jp2ChromaSubsampling = options.chromaSubsampling;\n } else {\n throw is.invalidParameterError('chromaSubsampling', 'one of: 4:2:0, 4:4:4', options.chromaSubsampling);\n }\n }\n }\n return this._updateFormatOut('jp2', options);\n}\n\n/**\n * Set animation options if available.\n * @private\n *\n * @param {Object} [source] - output options\n * @param {number} [source.loop=0] - number of animation iterations, use 0 for infinite animation\n * @param {number[]} [source.delay] - list of delays between animation frames (in milliseconds)\n * @param {Object} [target] - target object for valid options\n * @throws {Error} Invalid options\n */\nfunction trySetAnimationOptions (source, target) {\n if (is.object(source) && is.defined(source.loop)) {\n if (is.integer(source.loop) && is.inRange(source.loop, 0, 65535)) {\n target.loop = source.loop;\n } else {\n throw is.invalidParameterError('loop', 'integer between 0 and 65535', source.loop);\n }\n }\n if (is.object(source) && is.defined(source.delay)) {\n // We allow singular values as well\n if (is.integer(source.delay) && is.inRange(source.delay, 0, 65535)) {\n target.delay = [source.delay];\n } else if (\n Array.isArray(source.delay) &&\n source.delay.every(is.integer) &&\n source.delay.every(v => is.inRange(v, 0, 65535))) {\n target.delay = source.delay;\n } else {\n throw is.invalidParameterError('delay', 'integer or an array of integers between 0 and 65535', source.delay);\n }\n }\n}\n\n/**\n * Use these TIFF options for output image.\n *\n * The `density` can be set in pixels/inch via {@link #withmetadata withMetadata}\n * instead of providing `xres` and `yres` in pixels/mm.\n *\n * @example\n * // Convert SVG input to LZW-compressed, 1 bit per pixel TIFF output\n * sharp('input.svg')\n * .tiff({\n * compression: 'lzw',\n * bitdepth: 1\n * })\n * .toFile('1-bpp-output.tiff')\n * .then(info => { ... });\n *\n * @param {Object} [options] - output options\n * @param {number} [options.quality=80] - quality, integer 1-100\n * @param {boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format\n * @param {string} [options.compression='jpeg'] - compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k\n * @param {boolean} [options.bigtiff=false] - use BigTIFF variant (has no effect when compression is none)\n * @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float\n * @param {boolean} [options.pyramid=false] - write an image pyramid\n * @param {boolean} [options.tile=false] - write a tiled tiff\n * @param {number} [options.tileWidth=256] - horizontal tile size\n * @param {number} [options.tileHeight=256] - vertical tile size\n * @param {number} [options.xres=1.0] - horizontal resolution in pixels/mm\n * @param {number} [options.yres=1.0] - vertical resolution in pixels/mm\n * @param {string} [options.resolutionUnit='inch'] - resolution unit options: inch, cm\n * @param {number} [options.bitdepth=8] - reduce bitdepth to 1, 2 or 4 bit\n * @param {boolean} [options.miniswhite=false] - write 1-bit images as miniswhite\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction tiff (options) {\n if (is.object(options)) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n this.options.tiffQuality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n }\n if (is.defined(options.bitdepth)) {\n if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4, 8])) {\n this.options.tiffBitdepth = options.bitdepth;\n } else {\n throw is.invalidParameterError('bitdepth', '1, 2, 4 or 8', options.bitdepth);\n }\n }\n // tiling\n if (is.defined(options.tile)) {\n this._setBooleanOption('tiffTile', options.tile);\n }\n if (is.defined(options.tileWidth)) {\n if (is.integer(options.tileWidth) && options.tileWidth > 0) {\n this.options.tiffTileWidth = options.tileWidth;\n } else {\n throw is.invalidParameterError('tileWidth', 'integer greater than zero', options.tileWidth);\n }\n }\n if (is.defined(options.tileHeight)) {\n if (is.integer(options.tileHeight) && options.tileHeight > 0) {\n this.options.tiffTileHeight = options.tileHeight;\n } else {\n throw is.invalidParameterError('tileHeight', 'integer greater than zero', options.tileHeight);\n }\n }\n // miniswhite\n if (is.defined(options.miniswhite)) {\n this._setBooleanOption('tiffMiniswhite', options.miniswhite);\n }\n // pyramid\n if (is.defined(options.pyramid)) {\n this._setBooleanOption('tiffPyramid', options.pyramid);\n }\n // resolution\n if (is.defined(options.xres)) {\n if (is.number(options.xres) && options.xres > 0) {\n this.options.tiffXres = options.xres;\n } else {\n throw is.invalidParameterError('xres', 'number greater than zero', options.xres);\n }\n }\n if (is.defined(options.yres)) {\n if (is.number(options.yres) && options.yres > 0) {\n this.options.tiffYres = options.yres;\n } else {\n throw is.invalidParameterError('yres', 'number greater than zero', options.yres);\n }\n }\n // compression\n if (is.defined(options.compression)) {\n if (is.string(options.compression) && is.inArray(options.compression, ['none', 'jpeg', 'deflate', 'packbits', 'ccittfax4', 'lzw', 'webp', 'zstd', 'jp2k'])) {\n this.options.tiffCompression = options.compression;\n } else {\n throw is.invalidParameterError('compression', 'one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k', options.compression);\n }\n }\n // bigtiff\n if (is.defined(options.bigtiff)) {\n this._setBooleanOption('tiffBigtiff', options.bigtiff);\n }\n // predictor\n if (is.defined(options.predictor)) {\n if (is.string(options.predictor) && is.inArray(options.predictor, ['none', 'horizontal', 'float'])) {\n this.options.tiffPredictor = options.predictor;\n } else {\n throw is.invalidParameterError('predictor', 'one of: none, horizontal, float', options.predictor);\n }\n }\n // resolutionUnit\n if (is.defined(options.resolutionUnit)) {\n if (is.string(options.resolutionUnit) && is.inArray(options.resolutionUnit, ['inch', 'cm'])) {\n this.options.tiffResolutionUnit = options.resolutionUnit;\n } else {\n throw is.invalidParameterError('resolutionUnit', 'one of: inch, cm', options.resolutionUnit);\n }\n }\n }\n return this._updateFormatOut('tiff', options);\n}\n\n/**\n * Use these AVIF options for output image.\n *\n * AVIF image sequences are not supported.\n * Prebuilt binaries support a bitdepth of 8 only.\n *\n * This feature is experimental on the Windows ARM64 platform\n * and requires a CPU with ARM64v8.4 or later.\n *\n * @example\n * const data = await sharp(input)\n * .avif({ effort: 2 })\n * .toBuffer();\n *\n * @example\n * const data = await sharp(input)\n * .avif({ lossless: true })\n * .toBuffer();\n *\n * @since 0.27.0\n *\n * @param {Object} [options] - output options\n * @param {number} [options.quality=50] - quality, integer 1-100\n * @param {boolean} [options.lossless=false] - use lossless compression\n * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)\n * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling\n * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction avif (options) {\n return this.heif({ ...options, compression: 'av1' });\n}\n\n/**\n * Use these HEIF options for output image.\n *\n * Support for patent-encumbered HEIC images using `hevc` compression requires the use of a\n * globally-installed libvips compiled with support for libheif, libde265 and x265.\n *\n * @example\n * const data = await sharp(input)\n * .heif({ compression: 'hevc' })\n * .toBuffer();\n *\n * @since 0.23.0\n *\n * @param {Object} options - output options\n * @param {string} options.compression - compression format: av1, hevc\n * @param {number} [options.quality=50] - quality, integer 1-100\n * @param {boolean} [options.lossless=false] - use lossless compression\n * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)\n * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling\n * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction heif (options) {\n if (is.object(options)) {\n if (is.string(options.compression) && is.inArray(options.compression, ['av1', 'hevc'])) {\n this.options.heifCompression = options.compression;\n } else {\n throw is.invalidParameterError('compression', 'one of: av1, hevc', options.compression);\n }\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n this.options.heifQuality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n }\n if (is.defined(options.lossless)) {\n if (is.bool(options.lossless)) {\n this.options.heifLossless = options.lossless;\n } else {\n throw is.invalidParameterError('lossless', 'boolean', options.lossless);\n }\n }\n if (is.defined(options.effort)) {\n if (is.integer(options.effort) && is.inRange(options.effort, 0, 9)) {\n this.options.heifEffort = options.effort;\n } else {\n throw is.invalidParameterError('effort', 'integer between 0 and 9', options.effort);\n }\n }\n if (is.defined(options.chromaSubsampling)) {\n if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) {\n this.options.heifChromaSubsampling = options.chromaSubsampling;\n } else {\n throw is.invalidParameterError('chromaSubsampling', 'one of: 4:2:0, 4:4:4', options.chromaSubsampling);\n }\n }\n if (is.defined(options.bitdepth)) {\n if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [8, 10, 12])) {\n if (options.bitdepth !== 8 && this.constructor.versions.heif) {\n throw is.invalidParameterError('bitdepth when using prebuilt binaries', 8, options.bitdepth);\n }\n this.options.heifBitdepth = options.bitdepth;\n } else {\n throw is.invalidParameterError('bitdepth', '8, 10 or 12', options.bitdepth);\n }\n }\n } else {\n throw is.invalidParameterError('options', 'Object', options);\n }\n return this._updateFormatOut('heif', options);\n}\n\n/**\n * Use these JPEG-XL (JXL) options for output image.\n *\n * This feature is experimental, please do not use in production systems.\n *\n * Requires libvips compiled with support for libjxl.\n * The prebuilt binaries do not include this - see\n * {@link /install/#custom-libvips installing a custom libvips}.\n *\n * @since 0.31.3\n *\n * @param {Object} [options] - output options\n * @param {number} [options.distance=1.0] - maximum encoding error, between 0 (highest quality) and 15 (lowest quality)\n * @param {number} [options.quality] - calculate `distance` based on JPEG-like quality, between 1 and 100, overrides distance if specified\n * @param {number} [options.decodingTier=0] - target decode speed tier, between 0 (highest quality) and 4 (lowest quality)\n * @param {boolean} [options.lossless=false] - use lossless compression\n * @param {number} [options.effort=7] - CPU effort, between 1 (fastest) and 9 (slowest)\n * @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation\n * @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction jxl (options) {\n if (is.object(options)) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n // https://github.com/libjxl/libjxl/blob/0aeea7f180bafd6893c1db8072dcb67d2aa5b03d/tools/cjxl_main.cc#L640-L644\n this.options.jxlDistance = options.quality >= 30\n ? 0.1 + (100 - options.quality) * 0.09\n : 53 / 3000 * options.quality * options.quality - 23 / 20 * options.quality + 25;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n } else if (is.defined(options.distance)) {\n if (is.number(options.distance) && is.inRange(options.distance, 0, 15)) {\n this.options.jxlDistance = options.distance;\n } else {\n throw is.invalidParameterError('distance', 'number between 0.0 and 15.0', options.distance);\n }\n }\n if (is.defined(options.decodingTier)) {\n if (is.integer(options.decodingTier) && is.inRange(options.decodingTier, 0, 4)) {\n this.options.jxlDecodingTier = options.decodingTier;\n } else {\n throw is.invalidParameterError('decodingTier', 'integer between 0 and 4', options.decodingTier);\n }\n }\n if (is.defined(options.lossless)) {\n if (is.bool(options.lossless)) {\n this.options.jxlLossless = options.lossless;\n } else {\n throw is.invalidParameterError('lossless', 'boolean', options.lossless);\n }\n }\n if (is.defined(options.effort)) {\n if (is.integer(options.effort) && is.inRange(options.effort, 1, 9)) {\n this.options.jxlEffort = options.effort;\n } else {\n throw is.invalidParameterError('effort', 'integer between 1 and 9', options.effort);\n }\n }\n }\n trySetAnimationOptions(options, this.options);\n return this._updateFormatOut('jxl', options);\n}\n\n/**\n * Force output to be raw, uncompressed pixel data.\n * Pixel ordering is left-to-right, top-to-bottom, without padding.\n * Channel ordering will be RGB or RGBA for non-greyscale colourspaces.\n *\n * @example\n * // Extract raw, unsigned 8-bit RGB pixel data from JPEG input\n * const { data, info } = await sharp('input.jpg')\n * .raw()\n * .toBuffer({ resolveWithObject: true });\n *\n * @example\n * // Extract alpha channel as raw, unsigned 16-bit pixel data from PNG input\n * const data = await sharp('input.png')\n * .ensureAlpha()\n * .extractChannel(3)\n * .toColourspace('b-w')\n * .raw({ depth: 'ushort' })\n * .toBuffer();\n *\n * @param {Object} [options] - output options\n * @param {string} [options.depth='uchar'] - bit depth, one of: char, uchar (default), short, ushort, int, uint, float, complex, double, dpcomplex\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction raw (options) {\n if (is.object(options)) {\n if (is.defined(options.depth)) {\n if (is.string(options.depth) && is.inArray(options.depth,\n ['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'float', 'complex', 'double', 'dpcomplex']\n )) {\n this.options.rawDepth = options.depth;\n } else {\n throw is.invalidParameterError('depth', 'one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex', options.depth);\n }\n }\n }\n return this._updateFormatOut('raw');\n}\n\n/**\n * Use tile-based deep zoom (image pyramid) output.\n *\n * Set the format and options for tile images via the `toFormat`, `jpeg`, `png` or `webp` functions.\n * Use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format.\n *\n * The container will be set to `zip` when the output is a Buffer or Stream, otherwise it will default to `fs`.\n *\n * @example\n * sharp('input.tiff')\n * .png()\n * .tile({\n * size: 512\n * })\n * .toFile('output.dz', function(err, info) {\n * // output.dzi is the Deep Zoom XML definition\n * // output_files contains 512x512 tiles grouped by zoom level\n * });\n *\n * @example\n * const zipFileWithTiles = await sharp(input)\n * .tile({ basename: \"tiles\" })\n * .toBuffer();\n *\n * @example\n * const iiififier = sharp().tile({ layout: \"iiif\" });\n * readableStream\n * .pipe(iiififier)\n * .pipe(writeableStream);\n *\n * @param {Object} [options]\n * @param {number} [options.size=256] tile size in pixels, a value between 1 and 8192.\n * @param {number} [options.overlap=0] tile overlap in pixels, a value between 0 and 8192.\n * @param {number} [options.angle=0] tile angle of rotation, must be a multiple of 90.\n * @param {string|Object} [options.background={r: 255, g: 255, b: 255, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to white without transparency.\n * @param {string} [options.depth] how deep to make the pyramid, possible values are `onepixel`, `onetile` or `one`, default based on layout.\n * @param {number} [options.skipBlanks=-1] Threshold to skip tile generation. Range is 0-255 for 8-bit images, 0-65535 for 16-bit images. Default is 5 for `google` layout, -1 (no skip) otherwise.\n * @param {string} [options.container='fs'] tile container, with value `fs` (filesystem) or `zip` (compressed file).\n * @param {string} [options.layout='dz'] filesystem layout, possible values are `dz`, `iiif`, `iiif3`, `zoomify` or `google`.\n * @param {boolean} [options.centre=false] centre image in tile.\n * @param {boolean} [options.center=false] alternative spelling of centre.\n * @param {string} [options.id='https://example.com/iiif'] when `layout` is `iiif`/`iiif3`, sets the `@id`/`id` attribute of `info.json`\n * @param {string} [options.basename] the name of the directory within the zip file when container is `zip`.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction tile (options) {\n if (is.object(options)) {\n // Size of square tiles, in pixels\n if (is.defined(options.size)) {\n if (is.integer(options.size) && is.inRange(options.size, 1, 8192)) {\n this.options.tileSize = options.size;\n } else {\n throw is.invalidParameterError('size', 'integer between 1 and 8192', options.size);\n }\n }\n // Overlap of tiles, in pixels\n if (is.defined(options.overlap)) {\n if (is.integer(options.overlap) && is.inRange(options.overlap, 0, 8192)) {\n if (options.overlap > this.options.tileSize) {\n throw is.invalidParameterError('overlap', `<= size (${this.options.tileSize})`, options.overlap);\n }\n this.options.tileOverlap = options.overlap;\n } else {\n throw is.invalidParameterError('overlap', 'integer between 0 and 8192', options.overlap);\n }\n }\n // Container\n if (is.defined(options.container)) {\n if (is.string(options.container) && is.inArray(options.container, ['fs', 'zip'])) {\n this.options.tileContainer = options.container;\n } else {\n throw is.invalidParameterError('container', 'one of: fs, zip', options.container);\n }\n }\n // Layout\n if (is.defined(options.layout)) {\n if (is.string(options.layout) && is.inArray(options.layout, ['dz', 'google', 'iiif', 'iiif3', 'zoomify'])) {\n this.options.tileLayout = options.layout;\n } else {\n throw is.invalidParameterError('layout', 'one of: dz, google, iiif, iiif3, zoomify', options.layout);\n }\n }\n // Angle of rotation,\n if (is.defined(options.angle)) {\n if (is.integer(options.angle) && !(options.angle % 90)) {\n this.options.tileAngle = options.angle;\n } else {\n throw is.invalidParameterError('angle', 'positive/negative multiple of 90', options.angle);\n }\n }\n // Background colour\n this._setBackgroundColourOption('tileBackground', options.background);\n // Depth of tiles\n if (is.defined(options.depth)) {\n if (is.string(options.depth) && is.inArray(options.depth, ['onepixel', 'onetile', 'one'])) {\n this.options.tileDepth = options.depth;\n } else {\n throw is.invalidParameterError('depth', 'one of: onepixel, onetile, one', options.depth);\n }\n }\n // Threshold to skip blank tiles\n if (is.defined(options.skipBlanks)) {\n if (is.integer(options.skipBlanks) && is.inRange(options.skipBlanks, -1, 65535)) {\n this.options.tileSkipBlanks = options.skipBlanks;\n } else {\n throw is.invalidParameterError('skipBlanks', 'integer between -1 and 255/65535', options.skipBlanks);\n }\n } else if (is.defined(options.layout) && options.layout === 'google') {\n this.options.tileSkipBlanks = 5;\n }\n // Center image in tile\n const centre = is.bool(options.center) ? options.center : options.centre;\n if (is.defined(centre)) {\n this._setBooleanOption('tileCentre', centre);\n }\n // @id attribute for IIIF layout\n if (is.defined(options.id)) {\n if (is.string(options.id)) {\n this.options.tileId = options.id;\n } else {\n throw is.invalidParameterError('id', 'string', options.id);\n }\n }\n // Basename for zip container\n if (is.defined(options.basename)) {\n if (is.string(options.basename)) {\n this.options.tileBasename = options.basename;\n } else {\n throw is.invalidParameterError('basename', 'string', options.basename);\n }\n }\n }\n // Format\n if (is.inArray(this.options.formatOut, ['jpeg', 'png', 'webp'])) {\n this.options.tileFormat = this.options.formatOut;\n } else if (this.options.formatOut !== 'input') {\n throw is.invalidParameterError('format', 'one of: jpeg, png, webp', this.options.formatOut);\n }\n return this._updateFormatOut('dz');\n}\n\n/**\n * Set a timeout for processing, in seconds.\n * Use a value of zero to continue processing indefinitely, the default behaviour.\n *\n * The clock starts when libvips opens an input image for processing.\n * Time spent waiting for a libuv thread to become available is not included.\n *\n * @example\n * // Ensure processing takes no longer than 3 seconds\n * try {\n * const data = await sharp(input)\n * .blur(1000)\n * .timeout({ seconds: 3 })\n * .toBuffer();\n * } catch (err) {\n * if (err.message.includes('timeout')) { ... }\n * }\n *\n * @since 0.29.2\n *\n * @param {Object} options\n * @param {number} options.seconds - Number of seconds after which processing will be stopped\n * @returns {Sharp}\n */\nfunction timeout (options) {\n if (!is.plainObject(options)) {\n throw is.invalidParameterError('options', 'object', options);\n }\n if (is.integer(options.seconds) && is.inRange(options.seconds, 0, 3600)) {\n this.options.timeoutSeconds = options.seconds;\n } else {\n throw is.invalidParameterError('seconds', 'integer between 0 and 3600', options.seconds);\n }\n return this;\n}\n\n/**\n * Update the output format unless options.force is false,\n * in which case revert to input format.\n * @private\n * @param {string} formatOut\n * @param {Object} [options]\n * @param {boolean} [options.force=true] - force output format, otherwise attempt to use input format\n * @returns {Sharp}\n */\nfunction _updateFormatOut (formatOut, options) {\n if (!(is.object(options) && options.force === false)) {\n this.options.formatOut = formatOut;\n }\n return this;\n}\n\n/**\n * Update a boolean attribute of the this.options Object.\n * @private\n * @param {string} key\n * @param {boolean} val\n * @throws {Error} Invalid key\n */\nfunction _setBooleanOption (key, val) {\n if (is.bool(val)) {\n this.options[key] = val;\n } else {\n throw is.invalidParameterError(key, 'boolean', val);\n }\n}\n\n/**\n * Called by a WriteableStream to notify us it is ready for data.\n * @private\n */\nfunction _read () {\n if (!this.options.streamOut) {\n this.options.streamOut = true;\n const stack = Error();\n this._pipeline(undefined, stack);\n }\n}\n\n/**\n * Invoke the C++ image processing pipeline\n * Supports callback, stream and promise variants\n * @private\n */\nfunction _pipeline (callback, stack) {\n if (typeof callback === 'function') {\n // output=file/buffer\n if (this._isStreamInput()) {\n // output=file/buffer, input=stream\n this.on('finish', () => {\n this._flattenBufferIn();\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, data, info);\n }\n });\n });\n } else {\n // output=file/buffer, input=file/buffer\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, data, info);\n }\n });\n }\n return this;\n } else if (this.options.streamOut) {\n // output=stream\n if (this._isStreamInput()) {\n // output=stream, input=stream\n this.once('finish', () => {\n this._flattenBufferIn();\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n this.emit('error', is.nativeError(err, stack));\n } else {\n this.emit('info', info);\n this.push(data);\n }\n this.push(null);\n this.on('end', () => this.emit('close'));\n });\n });\n if (this.streamInFinished) {\n this.emit('finish');\n }\n } else {\n // output=stream, input=file/buffer\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n this.emit('error', is.nativeError(err, stack));\n } else {\n this.emit('info', info);\n this.push(data);\n }\n this.push(null);\n this.on('end', () => this.emit('close'));\n });\n }\n return this;\n } else {\n // output=promise\n if (this._isStreamInput()) {\n // output=promise, input=stream\n return new Promise((resolve, reject) => {\n this.once('finish', () => {\n this._flattenBufferIn();\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n if (this.options.resolveWithObject) {\n resolve({ data, info });\n } else {\n resolve(data);\n }\n }\n });\n });\n });\n } else {\n // output=promise, input=file/buffer\n return new Promise((resolve, reject) => {\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n if (this.options.resolveWithObject) {\n resolve({ data, info });\n } else {\n resolve(data);\n }\n }\n });\n });\n }\n }\n}\n\n/**\n * Decorate the Sharp prototype with output-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n // Public\n toFile,\n toBuffer,\n keepExif,\n withExif,\n withExifMerge,\n keepIccProfile,\n withIccProfile,\n keepXmp,\n withXmp,\n keepMetadata,\n withMetadata,\n toFormat,\n jpeg,\n jp2,\n png,\n webp,\n tiff,\n avif,\n heif,\n jxl,\n gif,\n raw,\n tile,\n timeout,\n // Private\n _updateFormatOut,\n _setBooleanOption,\n _read,\n _pipeline\n });\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst events = require('node:events');\nconst detectLibc = require('detect-libc');\n\nconst is = require('./is');\nconst { runtimePlatformArch } = require('./libvips');\nconst sharp = require('./sharp');\n\nconst runtimePlatform = runtimePlatformArch();\nconst libvipsVersion = sharp.libvipsVersion();\n\n/**\n * An Object containing nested boolean values representing the available input and output formats/methods.\n * @member\n * @example\n * console.log(sharp.format);\n * @returns {Object}\n */\nconst format = sharp.format();\nformat.heif.output.alias = ['avif', 'heic'];\nformat.jpeg.output.alias = ['jpe', 'jpg'];\nformat.tiff.output.alias = ['tif'];\nformat.jp2k.output.alias = ['j2c', 'j2k', 'jp2', 'jpx'];\n\n/**\n * An Object containing the available interpolators and their proper values\n * @readonly\n * @enum {string}\n */\nconst interpolators = {\n /** [Nearest neighbour interpolation](http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation). Suitable for image enlargement only. */\n nearest: 'nearest',\n /** [Bilinear interpolation](http://en.wikipedia.org/wiki/Bilinear_interpolation). Faster than bicubic but with less smooth results. */\n bilinear: 'bilinear',\n /** [Bicubic interpolation](http://en.wikipedia.org/wiki/Bicubic_interpolation) (the default). */\n bicubic: 'bicubic',\n /** [LBB interpolation](https://github.com/libvips/libvips/blob/master/libvips/resample/lbb.cpp#L100). Prevents some \"[acutance](http://en.wikipedia.org/wiki/Acutance)\" but typically reduces performance by a factor of 2. */\n locallyBoundedBicubic: 'lbb',\n /** [Nohalo interpolation](http://eprints.soton.ac.uk/268086/). Prevents acutance but typically reduces performance by a factor of 3. */\n nohalo: 'nohalo',\n /** [VSQBS interpolation](https://github.com/libvips/libvips/blob/master/libvips/resample/vsqbs.cpp#L48). Prevents \"staircasing\" when enlarging. */\n vertexSplitQuadraticBasisSpline: 'vsqbs'\n};\n\n/**\n * An Object containing the version numbers of sharp, libvips\n * and (when using prebuilt binaries) its dependencies.\n *\n * @member\n * @example\n * console.log(sharp.versions);\n */\nlet versions = {\n vips: libvipsVersion.semver\n};\n/* node:coverage ignore next 15 */\nif (!libvipsVersion.isGlobal) {\n if (!libvipsVersion.isWasm) {\n try {\n versions = require(`@img/sharp-${runtimePlatform}/versions`);\n } catch (_) {\n try {\n versions = require(`@img/sharp-libvips-${runtimePlatform}/versions`);\n } catch (_) {}\n }\n } else {\n try {\n versions = require('@img/sharp-wasm32/versions');\n } catch (_) {}\n }\n}\nversions.sharp = require('../package.json').version;\n\n/* node:coverage ignore next 5 */\nif (versions.heif && format.heif) {\n // Prebuilt binaries provide AV1\n format.heif.input.fileSuffix = ['.avif'];\n format.heif.output.alias = ['avif'];\n}\n\n/**\n * Gets or, when options are provided, sets the limits of _libvips'_ operation cache.\n * Existing entries in the cache will be trimmed after any change in limits.\n * This method always returns cache statistics,\n * useful for determining how much working memory is required for a particular task.\n *\n * @example\n * const stats = sharp.cache();\n * @example\n * sharp.cache( { items: 200 } );\n * sharp.cache( { files: 0 } );\n * sharp.cache(false);\n *\n * @param {Object|boolean} [options=true] - Object with the following attributes, or boolean where true uses default cache settings and false removes all caching\n * @param {number} [options.memory=50] - is the maximum memory in MB to use for this cache\n * @param {number} [options.files=20] - is the maximum number of files to hold open\n * @param {number} [options.items=100] - is the maximum number of operations to cache\n * @returns {Object}\n */\nfunction cache (options) {\n if (is.bool(options)) {\n if (options) {\n // Default cache settings of 50MB, 20 files, 100 items\n return sharp.cache(50, 20, 100);\n } else {\n return sharp.cache(0, 0, 0);\n }\n } else if (is.object(options)) {\n return sharp.cache(options.memory, options.files, options.items);\n } else {\n return sharp.cache();\n }\n}\ncache(true);\n\n/**\n * Gets or, when a concurrency is provided, sets\n * the maximum number of threads _libvips_ should use to process _each image_.\n * These are from a thread pool managed by glib,\n * which helps avoid the overhead of creating new threads.\n *\n * This method always returns the current concurrency.\n *\n * The default value is the number of CPU cores,\n * except when using glibc-based Linux without jemalloc,\n * where the default is `1` to help reduce memory fragmentation.\n *\n * A value of `0` will reset this to the number of CPU cores.\n *\n * Some image format libraries spawn additional threads,\n * e.g. libaom manages its own 4 threads when encoding AVIF images,\n * and these are independent of the value set here.\n *\n * :::note\n * Further {@link /performance/ control over performance} is available.\n * :::\n *\n * @example\n * const threads = sharp.concurrency(); // 4\n * sharp.concurrency(2); // 2\n * sharp.concurrency(0); // 4\n *\n * @param {number} [concurrency]\n * @returns {number} concurrency\n */\nfunction concurrency (concurrency) {\n return sharp.concurrency(is.integer(concurrency) ? concurrency : null);\n}\n/* node:coverage ignore next 7 */\nif (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) {\n // Reduce default concurrency to 1 when using glibc memory allocator\n sharp.concurrency(1);\n} else if (detectLibc.familySync() === detectLibc.MUSL && sharp.concurrency() === 1024) {\n // Reduce default concurrency when musl thread over-subscription detected\n sharp.concurrency(require('node:os').availableParallelism());\n}\n\n/**\n * An EventEmitter that emits a `change` event when a task is either:\n * - queued, waiting for _libuv_ to provide a worker thread\n * - complete\n * @member\n * @example\n * sharp.queue.on('change', function(queueLength) {\n * console.log('Queue contains ' + queueLength + ' task(s)');\n * });\n */\nconst queue = new events.EventEmitter();\n\n/**\n * Provides access to internal task counters.\n * - queue is the number of tasks this module has queued waiting for _libuv_ to provide a worker thread from its pool.\n * - process is the number of resize tasks currently being processed.\n *\n * @example\n * const counters = sharp.counters(); // { queue: 2, process: 4 }\n *\n * @returns {Object}\n */\nfunction counters () {\n return sharp.counters();\n}\n\n/**\n * Get and set use of SIMD vector unit instructions.\n * Requires libvips to have been compiled with highway support.\n *\n * Improves the performance of `resize`, `blur` and `sharpen` operations\n * by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.\n *\n * @example\n * const simd = sharp.simd();\n * // simd is `true` if the runtime use of highway is currently enabled\n * @example\n * const simd = sharp.simd(false);\n * // prevent libvips from using highway at runtime\n *\n * @param {boolean} [simd=true]\n * @returns {boolean}\n */\nfunction simd (simd) {\n return sharp.simd(is.bool(simd) ? simd : null);\n}\n\n/**\n * Block libvips operations at runtime.\n *\n * This is in addition to the `VIPS_BLOCK_UNTRUSTED` environment variable,\n * which when set will block all \"untrusted\" operations.\n *\n * @since 0.32.4\n *\n * @example <caption>Block all TIFF input.</caption>\n * sharp.block({\n * operation: ['VipsForeignLoadTiff']\n * });\n *\n * @param {Object} options\n * @param {Array<string>} options.operation - List of libvips low-level operation names to block.\n */\nfunction block (options) {\n if (is.object(options)) {\n if (Array.isArray(options.operation) && options.operation.every(is.string)) {\n sharp.block(options.operation, true);\n } else {\n throw is.invalidParameterError('operation', 'Array<string>', options.operation);\n }\n } else {\n throw is.invalidParameterError('options', 'object', options);\n }\n}\n\n/**\n * Unblock libvips operations at runtime.\n *\n * This is useful for defining a list of allowed operations.\n *\n * @since 0.32.4\n *\n * @example <caption>Block all input except WebP from the filesystem.</caption>\n * sharp.block({\n * operation: ['VipsForeignLoad']\n * });\n * sharp.unblock({\n * operation: ['VipsForeignLoadWebpFile']\n * });\n *\n * @example <caption>Block all input except JPEG and PNG from a Buffer or Stream.</caption>\n * sharp.block({\n * operation: ['VipsForeignLoad']\n * });\n * sharp.unblock({\n * operation: ['VipsForeignLoadJpegBuffer', 'VipsForeignLoadPngBuffer']\n * });\n *\n * @param {Object} options\n * @param {Array<string>} options.operation - List of libvips low-level operation names to unblock.\n */\nfunction unblock (options) {\n if (is.object(options)) {\n if (Array.isArray(options.operation) && options.operation.every(is.string)) {\n sharp.block(options.operation, false);\n } else {\n throw is.invalidParameterError('operation', 'Array<string>', options.operation);\n }\n } else {\n throw is.invalidParameterError('options', 'object', options);\n }\n}\n\n/**\n * Decorate the Sharp class with utility-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Sharp.cache = cache;\n Sharp.concurrency = concurrency;\n Sharp.counters = counters;\n Sharp.simd = simd;\n Sharp.format = format;\n Sharp.interpolators = interpolators;\n Sharp.versions = versions;\n Sharp.queue = queue;\n Sharp.block = block;\n Sharp.unblock = unblock;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst Sharp = require('./constructor');\nrequire('./input')(Sharp);\nrequire('./resize')(Sharp);\nrequire('./composite')(Sharp);\nrequire('./operation')(Sharp);\nrequire('./colour')(Sharp);\nrequire('./channel')(Sharp);\nrequire('./output')(Sharp);\nrequire('./utility')(Sharp);\n\nmodule.exports = Sharp;\n", "export type {\n BuiltInPaletteAlgorithm,\n InputType,\n PaletteAlgorithm,\n PaletteGenerator,\n PaletteGeneratorInput,\n PaletteOptions,\n PaletteResult,\n} from './core';\nexport {\n detectInputType,\n generatePalette,\n generatePaletteFromHex,\n generatePaletteFromDataUri,\n generatePaletteFromUrl,\n generatePaletteFromPath,\n getAlgorithm,\n listAlgorithms,\n registerAlgorithm,\n unregisterAlgorithm,\n} from './core';\nexport { getGameBoyPalette } from './presets';\nexport type { RgbaColor } from './presets';\n", "import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport sharp from 'sharp';\nimport {\n Hct,\n QuantizerCelebi,\n Score,\n TonalPalette,\n argbFromRgb,\n hexFromArgb,\n} from '@material/material-color-utilities';\n\n/**\n * Supported input types for palette generation.\n */\nexport type InputType = 'hex' | 'datauri' | 'url' | 'path';\n\n/**\n * Built-in palette algorithms.\n */\nexport type BuiltInPaletteAlgorithm =\n | 'analogous'\n | 'complementary'\n | 'triadic'\n | 'tetradic'\n | 'split-complementary'\n | 'monochrome'\n | 'monet'\n | 'dominant';\n\n/**\n * Palette algorithm name, including custom algorithms.\n */\nexport type PaletteAlgorithm = BuiltInPaletteAlgorithm | (string & { __paletteAlgorithm?: never });\n\n/**\n * Input for palette generators.\n */\nexport interface PaletteGeneratorInput {\n inputType: InputType;\n baseColor: string;\n baseRgb: RgbColor;\n baseHsl: HslColor;\n count?: number;\n buffer?: Buffer;\n}\n\n/**\n * Palette generator contract.\n */\nexport type PaletteGenerator = (\n input: PaletteGeneratorInput\n) => Promise<string[]> | string[];\n\n/**\n * Options used when generating palettes.\n */\nexport interface PaletteOptions {\n /**\n * Palette algorithm to apply.\n */\n algorithm?: PaletteAlgorithm;\n /**\n * Palette size hint.\n */\n count?: number;\n}\n\n/**\n * Palette generation result.\n */\nexport interface PaletteResult {\n /**\n * Detected input type.\n */\n inputType: InputType;\n /**\n * Algorithm used for palette generation.\n */\n algorithm: PaletteAlgorithm;\n /**\n * Base color extracted from input.\n */\n baseColor: string;\n /**\n * Generated palette colors in HEX.\n */\n colors: string[];\n}\n\ninterface RgbColor {\n r: number;\n g: number;\n b: number;\n}\n\ninterface HslColor {\n h: number;\n s: number;\n l: number;\n}\n\nconst DEFAULT_ALGORITHM: BuiltInPaletteAlgorithm = 'analogous';\n\nconst algorithmRegistry = new Map<string, PaletteGenerator>();\nlet builtInsRegistered = false;\n\n/**\n * Registers a custom palette algorithm.\n */\nexport function registerAlgorithm(name: string, generator: PaletteGenerator): void {\n if (!name.trim()) {\n throw new Error('Algorithm name is required');\n }\n algorithmRegistry.set(name, generator);\n}\n\n/**\n * Unregisters a palette algorithm.\n */\nexport function unregisterAlgorithm(name: string): boolean {\n return algorithmRegistry.delete(name);\n}\n\n/**\n * Returns a registered algorithm by name.\n */\nexport function getAlgorithm(name: string): PaletteGenerator | undefined {\n return algorithmRegistry.get(name);\n}\n\n/**\n * Returns the list of supported palette algorithms.\n */\nexport function listAlgorithms(): PaletteAlgorithm[] {\n return Array.from(algorithmRegistry.keys()).sort();\n}\n\n/**\n * Detects the input type from the raw string.\n * @param input The raw input string.\n */\nexport function detectInputType(input: string): InputType {\n const trimmed = input.trim();\n if (isHex(trimmed)) return 'hex';\n if (isDataUri(trimmed)) return 'datauri';\n if (isUrl(trimmed)) return 'url';\n return 'path';\n}\n\n/**\n * Generates a palette by automatically detecting the input type.\n * @param input The input string.\n * @param options Optional palette options.\n */\nexport async function generatePalette(\n input: string,\n options: PaletteOptions = {}\n): Promise<PaletteResult> {\n const type = detectInputType(input);\n if (type === 'hex') return generatePaletteFromHex(input, options);\n if (type === 'datauri') return generatePaletteFromDataUri(input, options);\n if (type === 'url') return generatePaletteFromUrl(input, options);\n return generatePaletteFromPath(input, options);\n}\n\n/**\n * Generates a palette from a HEX color string.\n * @param hex The HEX string, with or without leading #.\n * @param options Optional palette options.\n */\nexport async function generatePaletteFromHex(\n hex: string,\n options: PaletteOptions = {}\n): Promise<PaletteResult> {\n const normalizedHex = normalizeHex(hex);\n const baseRgb = hexToRgb(normalizedHex);\n return buildPaletteResultFromBase(baseRgb, 'hex', options.algorithm, options.count);\n}\n\n/**\n * Generates a palette from an image data URI.\n * @param dataUri The image data URI.\n * @param options Optional palette options.\n */\nexport async function generatePaletteFromDataUri(\n dataUri: string,\n options: PaletteOptions = {}\n): Promise<PaletteResult> {\n const buffer = decodeDataUri(dataUri);\n return buildPaletteResultFromBuffer(buffer, 'datauri', options.algorithm, options.count);\n}\n\n/**\n * Generates a palette from an image URL.\n * @param url The image URL.\n * @param options Optional palette options.\n */\nexport async function generatePaletteFromUrl(\n url: string,\n options: PaletteOptions = {}\n): Promise<PaletteResult> {\n const buffer = await fetchBuffer(url);\n return buildPaletteResultFromBuffer(buffer, 'url', options.algorithm, options.count);\n}\n\n/**\n * Generates a palette from an image file path.\n * @param filePath The file path to the image.\n * @param options Optional palette options.\n */\nexport async function generatePaletteFromPath(\n filePath: string,\n options: PaletteOptions = {}\n): Promise<PaletteResult> {\n const resolved = path.resolve(filePath);\n const buffer = await fs.readFile(resolved);\n return buildPaletteResultFromBuffer(buffer, 'path', options.algorithm, options.count);\n}\n\n/**\n * Builds a palette result from an image buffer.\n * @param buffer The image buffer.\n * @param inputType The detected input type.\n * @param algorithm Optional algorithm override.\n * @param count Optional palette size.\n */\nasync function buildPaletteResultFromBuffer(\n buffer: Buffer,\n inputType: InputType,\n algorithm?: PaletteAlgorithm,\n count?: number\n): Promise<PaletteResult> {\n const resolvedAlgorithm = resolveAlgorithm(algorithm);\n const baseRgb = await getAverageColor(buffer);\n const baseHex = rgbToHex(baseRgb);\n return buildPaletteResult(\n {\n inputType,\n baseColor: baseHex,\n baseRgb,\n baseHsl: rgbToHsl(baseRgb),\n count,\n buffer,\n },\n resolvedAlgorithm\n );\n}\n\n/**\n * Builds a palette result from a base color.\n * @param baseRgb The base RGB color.\n * @param inputType The detected input type.\n * @param algorithm Optional algorithm override.\n * @param count Optional palette size.\n */\nasync function buildPaletteResultFromBase(\n baseRgb: RgbColor,\n inputType: InputType,\n algorithm?: PaletteAlgorithm,\n count?: number\n): Promise<PaletteResult> {\n const resolvedAlgorithm = resolveAlgorithm(algorithm);\n const baseHex = rgbToHex(baseRgb);\n return buildPaletteResult(\n {\n inputType,\n baseColor: baseHex,\n baseRgb,\n baseHsl: rgbToHsl(baseRgb),\n count,\n },\n resolvedAlgorithm\n );\n}\n\n/**\n * Resolves an algorithm, applying defaults and validation.\n * @param algorithm Optional algorithm override.\n */\nfunction resolveAlgorithm(algorithm: PaletteAlgorithm | undefined): PaletteAlgorithm {\n const resolved = algorithm ?? DEFAULT_ALGORITHM;\n if (!algorithmRegistry.has(resolved)) {\n throw new Error(`Unknown algorithm: ${resolved}`);\n }\n return resolved;\n}\n\n/**\n * Builds a palette in HSL space.\n * @param base The base HSL color.\n * @param algorithm The algorithm to apply.\n * @param count Optional palette size.\n */\nfunction buildPaletteHsl(base: HslColor, algorithm: PaletteAlgorithm, count?: number): HslColor[] {\n const hue = normalizeHue(base.h);\n const sat = clamp(base.s, 20, 90);\n const light = clamp(base.l, 20, 80);\n\n if (algorithm === 'analogous') {\n return buildByOffsets(hue, sat, light, resolveCount(count, 5), 40);\n }\n\n if (algorithm === 'complementary') {\n return buildByCycle(hue, sat, light, resolveCount(count, 3), [0, 180], 14);\n }\n\n if (algorithm === 'triadic') {\n return buildByCycle(hue, sat, light, resolveCount(count, 3), [0, 120, 240], 10);\n }\n\n if (algorithm === 'tetradic') {\n return buildByCycle(hue, sat, light, resolveCount(count, 4), [0, 90, 180, 270], 8);\n }\n\n if (algorithm === 'split-complementary') {\n return buildByCycle(hue, sat, light, resolveCount(count, 3), [0, 150, 210], 10);\n }\n\n if (algorithm === 'monochrome') {\n return buildMonochrome(hue, sat, light, resolveCount(count, 4));\n }\n\n return buildMonochrome(hue, sat, light, resolveCount(count, 6));\n}\n\nfunction buildHslPaletteColors(\n input: PaletteGeneratorInput,\n algorithm: BuiltInPaletteAlgorithm\n): string[] {\n const paletteHsl = buildPaletteHsl(input.baseHsl, algorithm, input.count);\n return paletteHsl.map((color) => rgbToHex(hslToRgb(color)));\n}\n\nfunction registerBuiltInAlgorithms(): void {\n if (builtInsRegistered) return;\n builtInsRegistered = true;\n registerAlgorithm('analogous', (input) => buildHslPaletteColors(input, 'analogous'));\n registerAlgorithm('complementary', (input) => buildHslPaletteColors(input, 'complementary'));\n registerAlgorithm('triadic', (input) => buildHslPaletteColors(input, 'triadic'));\n registerAlgorithm('tetradic', (input) => buildHslPaletteColors(input, 'tetradic'));\n registerAlgorithm('split-complementary', (input) =>\n buildHslPaletteColors(input, 'split-complementary')\n );\n registerAlgorithm('monochrome', (input) => buildHslPaletteColors(input, 'monochrome'));\n registerAlgorithm('monet', async (input) => {\n if (input.buffer) {\n const colors = await extractMonetPalette(input.buffer, resolveMonetCount(input.count, 6));\n if (colors.length > 0) {\n return colors;\n }\n }\n const sourceArgb = argbFromHex(input.baseColor);\n return buildMonetPaletteFromSourceArgb(sourceArgb, resolveMonetCount(input.count, 6));\n });\n registerAlgorithm('dominant', async (input) => {\n if (input.buffer) {\n const colors = await extractDominantPalette(input.buffer, resolveCount(input.count, 8));\n if (colors.length > 0) {\n return colors;\n }\n }\n return buildHslPaletteColors(input, 'monochrome');\n });\n}\n\nregisterBuiltInAlgorithms();\n\nasync function buildPaletteResult(\n input: PaletteGeneratorInput,\n algorithm: PaletteAlgorithm\n): Promise<PaletteResult> {\n const generator = getAlgorithm(algorithm);\n if (!generator) {\n throw new Error(`Unknown algorithm: ${algorithm}`);\n }\n const colors = await generator(input);\n return {\n inputType: input.inputType,\n algorithm,\n baseColor: input.baseColor,\n colors,\n };\n}\n\n/**\n * Checks whether a string is a valid HEX color.\n * @param value The string to validate.\n */\nfunction isHex(value: string): boolean {\n return /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(value);\n}\n\n/**\n * Checks whether a string is an image data URI.\n * @param value The string to validate.\n */\nfunction isDataUri(value: string): boolean {\n return /^data:image\\/[a-z0-9.+-]+;base64,/i.test(value);\n}\n\n/**\n * Checks whether a string is an HTTP(S) URL.\n * @param value The string to validate.\n */\nfunction isUrl(value: string): boolean {\n return /^https?:\\/\\//i.test(value);\n}\n\n/**\n * Normalizes HEX input to #RRGGBB format.\n * @param value The HEX string.\n */\nfunction normalizeHex(value: string): string {\n const raw = value.trim();\n if (!isHex(raw)) throw new Error(`Invalid HEX color: ${value}`);\n const cleaned = raw.startsWith('#') ? raw.slice(1) : raw;\n if (cleaned.length === 3) {\n const expanded = cleaned\n .split('')\n .map((char) => char + char)\n .join('');\n return `#${expanded.toUpperCase()}`;\n }\n return `#${cleaned.toUpperCase()}`;\n}\n\nfunction argbFromHex(hex: string): number {\n const clean = normalizeHex(hex).slice(1);\n const r = parseInt(clean.slice(0, 2), 16);\n const g = parseInt(clean.slice(2, 4), 16);\n const b = parseInt(clean.slice(4, 6), 16);\n return argbFromRgb(r, g, b);\n}\n\n/**\n * Converts HEX to RGB.\n * @param hex The HEX color string.\n */\nfunction hexToRgb(hex: string): RgbColor {\n const clean = normalizeHex(hex).slice(1);\n const r = parseInt(clean.slice(0, 2), 16);\n const g = parseInt(clean.slice(2, 4), 16);\n const b = parseInt(clean.slice(4, 6), 16);\n return { r, g, b };\n}\n\n/**\n * Converts RGB to HEX.\n * @param color The RGB color.\n */\nfunction rgbToHex(color: RgbColor): string {\n const toHex = (value: number) =>\n Math.round(clamp(value, 0, 255))\n .toString(16)\n .padStart(2, '0')\n .toUpperCase();\n return `#${toHex(color.r)}${toHex(color.g)}${toHex(color.b)}`;\n}\n\n/**\n * Converts RGB to HSL.\n * @param color The RGB color.\n */\nfunction rgbToHsl(color: RgbColor): HslColor {\n const r = color.r / 255;\n const g = color.g / 255;\n const b = color.b / 255;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const delta = max - min;\n let h = 0;\n if (delta !== 0) {\n if (max === r) h = ((g - b) / delta) % 6;\n else if (max === g) h = (b - r) / delta + 2;\n else h = (r - g) / delta + 4;\n h *= 60;\n }\n if (h < 0) h += 360;\n const l = (max + min) / 2;\n const s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));\n return { h, s: s * 100, l: l * 100 };\n}\n\n/**\n * Converts HSL to RGB.\n * @param color The HSL color.\n */\nfunction hslToRgb(color: HslColor): RgbColor {\n const h = normalizeHue(color.h);\n const s = clamp(color.s, 0, 100) / 100;\n const l = clamp(color.l, 0, 100) / 100;\n const c = (1 - Math.abs(2 * l - 1)) * s;\n const x = c * (1 - Math.abs(((h / 60) % 2) - 1));\n const m = l - c / 2;\n let r = 0;\n let g = 0;\n let b = 0;\n if (h >= 0 && h < 60) {\n r = c;\n g = x;\n } else if (h < 120) {\n r = x;\n g = c;\n } else if (h < 180) {\n g = c;\n b = x;\n } else if (h < 240) {\n g = x;\n b = c;\n } else if (h < 300) {\n r = x;\n b = c;\n } else {\n r = c;\n b = x;\n }\n return {\n r: (r + m) * 255,\n g: (g + m) * 255,\n b: (b + m) * 255,\n };\n}\n\n/**\n * Computes the average color of an image buffer.\n * @param buffer The image buffer.\n */\nasync function getAverageColor(buffer: Buffer): Promise<RgbColor> {\n const stats = await sharp(buffer).stats();\n const channels = stats.channels;\n return {\n r: channels[0]?.mean ?? 0,\n g: channels[1]?.mean ?? 0,\n b: channels[2]?.mean ?? 0,\n };\n}\n\n/**\n * Extracts a Monet-style palette from an image buffer.\n * @param buffer The image buffer.\n * @param count The number of colors to return.\n */\nasync function extractMonetPalette(buffer: Buffer, count: number): Promise<string[]> {\n const { data, info } = await sharp(buffer)\n .resize({ width: 48, height: 48, fit: 'inside' })\n .removeAlpha()\n .raw()\n .toBuffer({ resolveWithObject: true });\n const pixels: number[] = [];\n const step = info.channels;\n for (let i = 0; i < data.length; i += step) {\n const r = data[i] ?? 0;\n const g = data[i + 1] ?? 0;\n const b = data[i + 2] ?? 0;\n pixels.push(argbFromRgb(r, g, b));\n }\n if (pixels.length === 0) return [];\n const sampled = downsamplePixels(pixels, 1200);\n const quantized = QuantizerCelebi.quantize(sampled, 128);\n const ranked = Score.score(quantized);\n const sourceArgb = ranked[0] ?? sampled[0];\n return buildMonetPaletteFromSourceArgb(sourceArgb, count);\n}\n\nasync function extractDominantPalette(buffer: Buffer, count: number): Promise<string[]> {\n const { data, info } = await sharp(buffer)\n .resize({ width: 96, height: 96, fit: 'inside' })\n .removeAlpha()\n .raw()\n .toBuffer({ resolveWithObject: true });\n const step = info.channels;\n const pixels: number[] = [];\n for (let i = 0; i < data.length; i += step) {\n const r = data[i] ?? 0;\n const g = data[i + 1] ?? 0;\n const b = data[i + 2] ?? 0;\n pixels.push(argbFromRgb(r, g, b));\n }\n if (pixels.length === 0) return [];\n const sampled = downsamplePixels(pixels, 2400);\n const quantized = QuantizerCelebi.quantize(sampled, 128);\n const entries = Array.from(quantized.entries()).map(([argb, population]) => ({\n rgb: argbToRgb(argb),\n count: population,\n }));\n if (entries.length === 0) return [];\n entries.sort((a, b) => b.count - a.count);\n const totalCount = entries.reduce((sum, entry) => sum + entry.count, 0);\n const coverageTarget = 0.95;\n const candidateEntries: typeof entries = [];\n let coverage = 0;\n for (const entry of entries) {\n if (candidateEntries.length >= count) {\n candidateEntries.push(entry);\n continue;\n }\n candidateEntries.push(entry);\n coverage += entry.count / Math.max(1, totalCount);\n if (coverage >= coverageTarget) {\n break;\n }\n }\n if (candidateEntries.length < count) {\n candidateEntries.splice(0, candidateEntries.length, ...entries);\n }\n if (entries.length <= count) {\n return entries.map((entry) => rgbToHex(entry.rgb));\n }\n const maxCount = Math.max(1, entries[0]?.count ?? 1);\n const seeds: RgbColor[] = [candidateEntries[0].rgb];\n while (seeds.length < count) {\n let best: (typeof entries)[number] | null = null;\n let bestScore = -1;\n for (const entry of candidateEntries) {\n if (seeds.some((seed) => rgbDistanceSq(seed, entry.rgb) === 0)) continue;\n let minDist = Number.POSITIVE_INFINITY;\n for (const seed of seeds) {\n minDist = Math.min(minDist, rgbDistanceSq(seed, entry.rgb));\n }\n const weight = entry.count / maxCount;\n const score = minDist * (0.2 + Math.sqrt(weight));\n if (score > bestScore) {\n bestScore = score;\n best = entry;\n }\n }\n if (!best) break;\n seeds.push(best.rgb);\n }\n const refined = refineCentroids(seeds, entries);\n return refined.slice(0, count).map((color) => rgbToHex(color));\n}\n\n/**\n * Resolves the palette size with bounds.\n * @param count Optional requested count.\n * @param fallback Default count.\n */\nfunction resolveCount(count: number | undefined, fallback: number): number {\n if (!count) return fallback;\n return Math.max(2, Math.min(12, Math.floor(count)));\n}\n\nfunction resolveMonetCount(count: number | undefined, fallback: number): number {\n if (!count) return fallback;\n return Math.max(1, Math.floor(count));\n}\n\n/**\n * Builds hue offsets distributed across a range.\n * @param count Number of offsets.\n * @param maxOffset Maximum absolute offset.\n */\nfunction buildOffsets(count: number, maxOffset: number): number[] {\n if (count <= 1) return [0];\n const step = (maxOffset * 2) / (count - 1);\n const offsets: number[] = [];\n for (let i = 0; i < count; i += 1) {\n offsets.push(-maxOffset + i * step);\n }\n return offsets;\n}\n\n/**\n * Builds lightness offsets distributed across a range.\n * @param count Number of offsets.\n * @param maxOffset Maximum absolute offset.\n */\nfunction buildLightOffsets(count: number, maxOffset: number): number[] {\n if (count <= 1) return [0];\n const step = (maxOffset * 2) / (count - 1);\n const offsets: number[] = [];\n for (let i = 0; i < count; i += 1) {\n offsets.push(-maxOffset + i * step);\n }\n return offsets;\n}\n\n/**\n * Builds HSL colors by evenly spaced hue offsets.\n * @param hue Base hue.\n * @param sat Base saturation.\n * @param light Base lightness.\n * @param count Number of colors.\n * @param maxOffset Maximum hue offset.\n */\nfunction buildByOffsets(\n hue: number,\n sat: number,\n light: number,\n count: number,\n maxOffset: number\n): HslColor[] {\n const offsets = buildOffsets(count, maxOffset);\n return offsets.map((offset) => ({\n h: normalizeHue(hue + offset),\n s: clamp(sat, 0, 100),\n l: clamp(light, 0, 100),\n }));\n}\n\n/**\n * Builds HSL colors by cycling hue offsets with lightness variation.\n * @param hue Base hue.\n * @param sat Base saturation.\n * @param light Base lightness.\n * @param count Number of colors.\n * @param offsets Hue offsets to cycle.\n * @param lightStep Lightness step per cycle layer.\n */\nfunction buildByCycle(\n hue: number,\n sat: number,\n light: number,\n count: number,\n offsets: number[],\n lightStep: number\n): HslColor[] {\n const result: HslColor[] = [];\n for (let i = 0; i < count; i += 1) {\n const offset = offsets[i % offsets.length] ?? 0;\n const layer = Math.floor(i / offsets.length);\n const delta = (layer % 2 === 0 ? 1 : -1) * lightStep * (layer + 1) * 0.5;\n result.push({\n h: normalizeHue(hue + offset),\n s: clamp(sat, 0, 100),\n l: clamp(light + delta, 0, 100),\n });\n }\n return result;\n}\n\n/**\n * Builds a monochrome palette by lightness offsets.\n * @param hue Base hue.\n * @param sat Base saturation.\n * @param light Base lightness.\n * @param count Number of colors.\n */\nfunction buildMonochrome(hue: number, sat: number, light: number, count: number): HslColor[] {\n const offsets = buildLightOffsets(count, 20);\n return offsets.map((offset) => ({\n h: normalizeHue(hue),\n s: clamp(sat, 0, 100),\n l: clamp(light + offset, 0, 100),\n }));\n}\n\n/**\n * Downsamples pixels to a maximum size.\n * @param pixels The pixel list.\n * @param max Maximum number of pixels.\n */\nfunction downsamplePixels(pixels: number[], max: number): number[] {\n if (pixels.length <= max) return pixels;\n const stride = Math.ceil(pixels.length / max);\n const result: number[] = [];\n for (let i = 0; i < pixels.length; i += stride) {\n result.push(pixels[i]);\n }\n return result;\n}\nfunction buildMonetPaletteFromSourceArgb(sourceArgb: number, count: number): string[] {\n const hct = Hct.fromInt(sourceArgb);\n const palette = TonalPalette.fromHct(hct);\n const tones = buildToneSteps(count);\n return tones.map((tone) => hexFromArgb(palette.tone(tone)));\n}\n\nfunction buildToneSteps(count: number): number[] {\n const base = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 98, 100];\n if (count <= base.length) {\n return base.slice(0, count);\n }\n const tones: number[] = [];\n for (let i = 0; i < count; i += 1) {\n tones.push(Math.round((100 * i) / (count - 1)));\n }\n return tones;\n}\n\n/**\n * Decodes a data URI into a buffer.\n * @param value The data URI string.\n */\nfunction decodeDataUri(value: string): Buffer {\n if (!isDataUri(value)) {\n throw new Error('Invalid data URI');\n }\n const base64 = value.split(',')[1] ?? '';\n return Buffer.from(base64, 'base64');\n}\n\n/**\n * Fetches a URL and returns the response as a buffer.\n * @param url The resource URL.\n */\nasync function fetchBuffer(url: string): Promise<Buffer> {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Failed to fetch image: ${response.status} ${response.statusText}`);\n }\n const arrayBuffer = await response.arrayBuffer();\n return Buffer.from(arrayBuffer);\n}\n\n/**\n * Clamps a number between min and max.\n * @param value The input value.\n * @param min Minimum value.\n * @param max Maximum value.\n */\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\nfunction rgbDistanceSq(a: RgbColor, b: RgbColor): number {\n const dr = a.r - b.r;\n const dg = a.g - b.g;\n const db = a.b - b.b;\n return dr * dr + dg * dg + db * db;\n}\n\nfunction argbToRgb(argb: number): RgbColor {\n return {\n r: (argb >>> 16) & 255,\n g: (argb >>> 8) & 255,\n b: argb & 255,\n };\n}\n\nfunction refineCentroids(\n seeds: RgbColor[],\n entries: { rgb: RgbColor; count: number }[]\n): RgbColor[] {\n const accum = seeds.map(() => ({ r: 0, g: 0, b: 0, count: 0 }));\n for (const entry of entries) {\n let bestIndex = 0;\n let bestDist = Number.POSITIVE_INFINITY;\n for (let i = 0; i < seeds.length; i += 1) {\n const dist = rgbDistanceSq(seeds[i], entry.rgb);\n if (dist < bestDist) {\n bestDist = dist;\n bestIndex = i;\n }\n }\n const target = accum[bestIndex];\n target.r += entry.rgb.r * entry.count;\n target.g += entry.rgb.g * entry.count;\n target.b += entry.rgb.b * entry.count;\n target.count += entry.count;\n }\n return seeds.map((seed, index) => {\n const bucket = accum[index];\n if (!bucket || bucket.count === 0) return seed;\n return {\n r: clamp(bucket.r / bucket.count, 0, 255),\n g: clamp(bucket.g / bucket.count, 0, 255),\n b: clamp(bucket.b / bucket.count, 0, 255),\n };\n });\n}\n\n/**\n * Normalizes hue to the [0, 360) range.\n * @param hue The input hue.\n */\nfunction normalizeHue(hue: number): number {\n const normalized = hue % 360;\n return normalized < 0 ? normalized + 360 : normalized;\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// This file is automatically generated. Do not modify it.\n\n/**\n * Utility methods for mathematical operations.\n */\n\n/**\n * The signum function.\n *\n * @return 1 if num > 0, -1 if num < 0, and 0 if num = 0\n */\nexport function signum(num: number): number {\n if (num < 0) {\n return -1;\n } else if (num === 0) {\n return 0;\n } else {\n return 1;\n }\n}\n\n/**\n * The linear interpolation function.\n *\n * @return start if amount = 0 and stop if amount = 1\n */\nexport function lerp(start: number, stop: number, amount: number): number {\n return (1.0 - amount) * start + amount * stop;\n}\n\n/**\n * Clamps an integer between two integers.\n *\n * @return input when min <= input <= max, and either min or max\n * otherwise.\n */\nexport function clampInt(min: number, max: number, input: number): number {\n if (input < min) {\n return min;\n } else if (input > max) {\n return max;\n }\n\n return input;\n}\n\n/**\n * Clamps an integer between two floating-point numbers.\n *\n * @return input when min <= input <= max, and either min or max\n * otherwise.\n */\nexport function clampDouble(min: number, max: number, input: number): number {\n if (input < min) {\n return min;\n } else if (input > max) {\n return max;\n }\n\n return input;\n}\n\n/**\n * Sanitizes a degree measure as an integer.\n *\n * @return a degree measure between 0 (inclusive) and 360\n * (exclusive).\n */\nexport function sanitizeDegreesInt(degrees: number): number {\n degrees = degrees % 360;\n if (degrees < 0) {\n degrees = degrees + 360;\n }\n return degrees;\n}\n\n/**\n * Sanitizes a degree measure as a floating-point number.\n *\n * @return a degree measure between 0.0 (inclusive) and 360.0\n * (exclusive).\n */\nexport function sanitizeDegreesDouble(degrees: number): number {\n degrees = degrees % 360.0;\n if (degrees < 0) {\n degrees = degrees + 360.0;\n }\n return degrees;\n}\n\n/**\n * Sign of direction change needed to travel from one angle to\n * another.\n *\n * For angles that are 180 degrees apart from each other, both\n * directions have the same travel distance, so either direction is\n * shortest. The value 1.0 is returned in this case.\n *\n * @param from The angle travel starts from, in degrees.\n * @param to The angle travel ends at, in degrees.\n * @return -1 if decreasing from leads to the shortest travel\n * distance, 1 if increasing from leads to the shortest travel\n * distance.\n */\nexport function rotationDirection(from: number, to: number): number {\n const increasingDifference = sanitizeDegreesDouble(to - from);\n return increasingDifference <= 180.0 ? 1.0 : -1.0;\n}\n\n/**\n * Distance of two points on a circle, represented using degrees.\n */\nexport function differenceDegrees(a: number, b: number): number {\n return 180.0 - Math.abs(Math.abs(a - b) - 180.0);\n}\n\n/**\n * Multiplies a 1x3 row vector with a 3x3 matrix.\n */\nexport function matrixMultiply(row: number[], matrix: number[][]): number[] {\n const a =\n row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2];\n const b =\n row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2];\n const c =\n row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];\n return [a, b, c];\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// This file is automatically generated. Do not modify it.\n\nimport * as mathUtils from './math_utils.js';\n\n/**\n * Color science utilities.\n *\n * Utility methods for color science constants and color space\n * conversions that aren't HCT or CAM16.\n */\n\nconst SRGB_TO_XYZ = [\n [0.41233895, 0.35762064, 0.18051042],\n [0.2126, 0.7152, 0.0722],\n [0.01932141, 0.11916382, 0.95034478],\n];\n\nconst XYZ_TO_SRGB = [\n [\n 3.2413774792388685,\n -1.5376652402851851,\n -0.49885366846268053,\n ],\n [\n -0.9691452513005321,\n 1.8758853451067872,\n 0.04156585616912061,\n ],\n [\n 0.05562093689691305,\n -0.20395524564742123,\n 1.0571799111220335,\n ],\n];\n\nconst WHITE_POINT_D65 = [95.047, 100.0, 108.883];\n\n/**\n * Converts a color from RGB components to ARGB format.\n */\nexport function argbFromRgb(red: number, green: number, blue: number): number {\n return (255 << 24 | (red & 255) << 16 | (green & 255) << 8 | blue & 255) >>>\n 0;\n}\n\n/**\n * Converts a color from linear RGB components to ARGB format.\n */\nexport function argbFromLinrgb(linrgb: number[]): number {\n const r = delinearized(linrgb[0]);\n const g = delinearized(linrgb[1]);\n const b = delinearized(linrgb[2]);\n return argbFromRgb(r, g, b);\n}\n\n/**\n * Returns the alpha component of a color in ARGB format.\n */\nexport function alphaFromArgb(argb: number): number {\n return argb >> 24 & 255;\n}\n\n/**\n * Returns the red component of a color in ARGB format.\n */\nexport function redFromArgb(argb: number): number {\n return argb >> 16 & 255;\n}\n\n/**\n * Returns the green component of a color in ARGB format.\n */\nexport function greenFromArgb(argb: number): number {\n return argb >> 8 & 255;\n}\n\n/**\n * Returns the blue component of a color in ARGB format.\n */\nexport function blueFromArgb(argb: number): number {\n return argb & 255;\n}\n\n/**\n * Returns whether a color in ARGB format is opaque.\n */\nexport function isOpaque(argb: number): boolean {\n return alphaFromArgb(argb) >= 255;\n}\n\n/**\n * Converts a color from ARGB to XYZ.\n */\nexport function argbFromXyz(x: number, y: number, z: number): number {\n const matrix = XYZ_TO_SRGB;\n const linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z;\n const linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z;\n const linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z;\n const r = delinearized(linearR);\n const g = delinearized(linearG);\n const b = delinearized(linearB);\n return argbFromRgb(r, g, b);\n}\n\n/**\n * Converts a color from XYZ to ARGB.\n */\nexport function xyzFromArgb(argb: number): number[] {\n const r = linearized(redFromArgb(argb));\n const g = linearized(greenFromArgb(argb));\n const b = linearized(blueFromArgb(argb));\n return mathUtils.matrixMultiply([r, g, b], SRGB_TO_XYZ);\n}\n\n/**\n * Converts a color represented in Lab color space into an ARGB\n * integer.\n */\nexport function argbFromLab(l: number, a: number, b: number): number {\n const whitePoint = WHITE_POINT_D65;\n const fy = (l + 16.0) / 116.0;\n const fx = a / 500.0 + fy;\n const fz = fy - b / 200.0;\n const xNormalized = labInvf(fx);\n const yNormalized = labInvf(fy);\n const zNormalized = labInvf(fz);\n const x = xNormalized * whitePoint[0];\n const y = yNormalized * whitePoint[1];\n const z = zNormalized * whitePoint[2];\n return argbFromXyz(x, y, z);\n}\n\n/**\n * Converts a color from ARGB representation to L*a*b*\n * representation.\n *\n * @param argb the ARGB representation of a color\n * @return a Lab object representing the color\n */\nexport function labFromArgb(argb: number): number[] {\n const linearR = linearized(redFromArgb(argb));\n const linearG = linearized(greenFromArgb(argb));\n const linearB = linearized(blueFromArgb(argb));\n const matrix = SRGB_TO_XYZ;\n const x =\n matrix[0][0] * linearR + matrix[0][1] * linearG + matrix[0][2] * linearB;\n const y =\n matrix[1][0] * linearR + matrix[1][1] * linearG + matrix[1][2] * linearB;\n const z =\n matrix[2][0] * linearR + matrix[2][1] * linearG + matrix[2][2] * linearB;\n const whitePoint = WHITE_POINT_D65;\n const xNormalized = x / whitePoint[0];\n const yNormalized = y / whitePoint[1];\n const zNormalized = z / whitePoint[2];\n const fx = labF(xNormalized);\n const fy = labF(yNormalized);\n const fz = labF(zNormalized);\n const l = 116.0 * fy - 16;\n const a = 500.0 * (fx - fy);\n const b = 200.0 * (fy - fz);\n return [l, a, b];\n}\n\n/**\n * Converts an L* value to an ARGB representation.\n *\n * @param lstar L* in L*a*b*\n * @return ARGB representation of grayscale color with lightness\n * matching L*\n */\nexport function argbFromLstar(lstar: number): number {\n const y = yFromLstar(lstar);\n const component = delinearized(y);\n return argbFromRgb(component, component, component);\n}\n\n/**\n * Computes the L* value of a color in ARGB representation.\n *\n * @param argb ARGB representation of a color\n * @return L*, from L*a*b*, coordinate of the color\n */\nexport function lstarFromArgb(argb: number): number {\n const y = xyzFromArgb(argb)[1];\n return 116.0 * labF(y / 100.0) - 16.0;\n}\n\n/**\n * Converts an L* value to a Y value.\n *\n * L* in L*a*b* and Y in XYZ measure the same quantity, luminance.\n *\n * L* measures perceptual luminance, a linear scale. Y in XYZ\n * measures relative luminance, a logarithmic scale.\n *\n * @param lstar L* in L*a*b*\n * @return Y in XYZ\n */\nexport function yFromLstar(lstar: number): number {\n return 100.0 * labInvf((lstar + 16.0) / 116.0);\n}\n\n/**\n * Converts a Y value to an L* value.\n *\n * L* in L*a*b* and Y in XYZ measure the same quantity, luminance.\n *\n * L* measures perceptual luminance, a linear scale. Y in XYZ\n * measures relative luminance, a logarithmic scale.\n *\n * @param y Y in XYZ\n * @return L* in L*a*b*\n */\nexport function lstarFromY(y: number): number {\n return labF(y / 100.0) * 116.0 - 16.0;\n}\n\n/**\n * Linearizes an RGB component.\n *\n * @param rgbComponent 0 <= rgb_component <= 255, represents R/G/B\n * channel\n * @return 0.0 <= output <= 100.0, color channel converted to\n * linear RGB space\n */\nexport function linearized(rgbComponent: number): number {\n const normalized = rgbComponent / 255.0;\n if (normalized <= 0.040449936) {\n return normalized / 12.92 * 100.0;\n } else {\n return Math.pow((normalized + 0.055) / 1.055, 2.4) * 100.0;\n }\n}\n\n/**\n * Delinearizes an RGB component.\n *\n * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents\n * linear R/G/B channel\n * @return 0 <= output <= 255, color channel converted to regular\n * RGB space\n */\nexport function delinearized(rgbComponent: number): number {\n const normalized = rgbComponent / 100.0;\n let delinearized = 0.0;\n if (normalized <= 0.0031308) {\n delinearized = normalized * 12.92;\n } else {\n delinearized = 1.055 * Math.pow(normalized, 1.0 / 2.4) - 0.055;\n }\n return mathUtils.clampInt(0, 255, Math.round(delinearized * 255.0));\n}\n\n/**\n * Returns the standard white point; white on a sunny day.\n *\n * @return The white point\n */\nexport function whitePointD65(): number[] {\n return WHITE_POINT_D65;\n}\n\n/**\n * RGBA component\n * \n * @param r Red value should be between 0-255\n * @param g Green value should be between 0-255\n * @param b Blue value should be between 0-255\n * @param a Alpha value should be between 0-255\n */\nexport interface Rgba {\n r: number;\n g: number;\n b: number;\n a: number;\n}\n\n/**\n * Return RGBA from a given int32 color\n *\n * @param argb ARGB representation of a int32 color.\n * @return RGBA representation of a int32 color.\n */\nexport function rgbaFromArgb(argb: number): Rgba {\n const r = redFromArgb(argb);\n const g = greenFromArgb(argb);\n const b = blueFromArgb(argb);\n const a = alphaFromArgb(argb);\n return {r, g, b, a};\n}\n\n/**\n * Return int32 color from a given RGBA component\n * \n * @param rgba RGBA representation of a int32 color.\n * @returns ARGB representation of a int32 color.\n */\nexport function argbFromRgba({r, g, b, a}: Rgba): number {\n const rValue = clampComponent(r);\n const gValue = clampComponent(g);\n const bValue = clampComponent(b);\n const aValue = clampComponent(a);\n return (aValue << 24) | (rValue << 16) | (gValue << 8) | bValue;\n}\n\nfunction clampComponent(value: number) {\n if (value < 0) return 0;\n if (value > 255) return 255;\n return value\n}\n\nfunction labF(t: number): number {\n const e = 216.0 / 24389.0;\n const kappa = 24389.0 / 27.0;\n if (t > e) {\n return Math.pow(t, 1.0 / 3.0);\n } else {\n return (kappa * t + 16) / 116;\n }\n}\n\nfunction labInvf(ft: number): number {\n const e = 216.0 / 24389.0;\n const kappa = 24389.0 / 27.0;\n const ft3 = ft * ft * ft;\n if (ft3 > e) {\n return ft3;\n } else {\n return (116 * ft - 16) / kappa;\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as utils from '../utils/color_utils.js';\nimport * as math from '../utils/math_utils.js';\n\n/**\n * In traditional color spaces, a color can be identified solely by the\n * observer's measurement of the color. Color appearance models such as CAM16\n * also use information about the environment where the color was\n * observed, known as the viewing conditions.\n *\n * For example, white under the traditional assumption of a midday sun white\n * point is accurately measured as a slightly chromatic blue by CAM16. (roughly,\n * hue 203, chroma 3, lightness 100)\n *\n * This class caches intermediate values of the CAM16 conversion process that\n * depend only on viewing conditions, enabling speed ups.\n */\nexport class ViewingConditions {\n /** sRGB-like viewing conditions. */\n static DEFAULT = ViewingConditions.make();\n\n /**\n * Create ViewingConditions from a simple, physically relevant, set of\n * parameters.\n *\n * @param whitePoint White point, measured in the XYZ color space.\n * default = D65, or sunny day afternoon\n * @param adaptingLuminance The luminance of the adapting field. Informally,\n * how bright it is in the room where the color is viewed. Can be\n * calculated from lux by multiplying lux by 0.0586. default = 11.72,\n * or 200 lux.\n * @param backgroundLstar The lightness of the area surrounding the color.\n * measured by L* in L*a*b*. default = 50.0\n * @param surround A general description of the lighting surrounding the\n * color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a\n * dimly light room, like watching TV at home at night. 2.0 means there\n * is no difference between the lighting on the color and around it.\n * default = 2.0\n * @param discountingIlluminant Whether the eye accounts for the tint of the\n * ambient lighting, such as knowing an apple is still red in green light.\n * default = false, the eye does not perform this process on\n * self-luminous objects like displays.\n */\n static make(\n whitePoint = utils.whitePointD65(),\n adaptingLuminance = (200.0 / Math.PI) * utils.yFromLstar(50.0) / 100.0,\n backgroundLstar = 50.0, surround = 2.0,\n discountingIlluminant = false): ViewingConditions {\n const xyz = whitePoint;\n const rW = xyz[0] * 0.401288 + xyz[1] * 0.650173 + xyz[2] * -0.051461;\n const gW = xyz[0] * -0.250268 + xyz[1] * 1.204414 + xyz[2] * 0.045854;\n const bW = xyz[0] * -0.002079 + xyz[1] * 0.048952 + xyz[2] * 0.953127;\n const f = 0.8 + surround / 10.0;\n const c = f >= 0.9 ? math.lerp(0.59, 0.69, (f - 0.9) * 10.0) :\n math.lerp(0.525, 0.59, (f - 0.8) * 10.0);\n let d = discountingIlluminant ?\n 1.0 :\n f * (1.0 - (1.0 / 3.6) * Math.exp((-adaptingLuminance - 42.0) / 92.0));\n d = d > 1.0 ? 1.0 : d < 0.0 ? 0.0 : d;\n const nc = f;\n const rgbD = [\n d * (100.0 / rW) + 1.0 - d,\n d * (100.0 / gW) + 1.0 - d,\n d * (100.0 / bW) + 1.0 - d,\n ];\n const k = 1.0 / (5.0 * adaptingLuminance + 1.0);\n const k4 = k * k * k * k;\n const k4F = 1.0 - k4;\n const fl = k4 * adaptingLuminance +\n 0.1 * k4F * k4F * Math.cbrt(5.0 * adaptingLuminance);\n const n = utils.yFromLstar(backgroundLstar) / whitePoint[1];\n const z = 1.48 + Math.sqrt(n);\n const nbb = 0.725 / Math.pow(n, 0.2);\n const ncb = nbb;\n const rgbAFactors = [\n Math.pow((fl * rgbD[0] * rW) / 100.0, 0.42),\n Math.pow((fl * rgbD[1] * gW) / 100.0, 0.42),\n Math.pow((fl * rgbD[2] * bW) / 100.0, 0.42),\n ];\n const rgbA = [\n (400.0 * rgbAFactors[0]) / (rgbAFactors[0] + 27.13),\n (400.0 * rgbAFactors[1]) / (rgbAFactors[1] + 27.13),\n (400.0 * rgbAFactors[2]) / (rgbAFactors[2] + 27.13),\n ];\n const aw = (2.0 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]) * nbb;\n return new ViewingConditions(\n n, aw, nbb, ncb, c, nc, rgbD, fl, Math.pow(fl, 0.25), z);\n }\n\n /**\n * Parameters are intermediate values of the CAM16 conversion process. Their\n * names are shorthand for technical color science terminology, this class\n * would not benefit from documenting them individually. A brief overview\n * is available in the CAM16 specification, and a complete overview requires\n * a color science textbook, such as Fairchild's Color Appearance Models.\n */\n private constructor(\n public n: number, public aw: number, public nbb: number,\n public ncb: number, public c: number, public nc: number,\n public rgbD: number[], public fl: number, public fLRoot: number,\n public z: number) {}\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as utils from '../utils/color_utils.js';\nimport * as math from '../utils/math_utils.js';\n\nimport {ViewingConditions} from './viewing_conditions.js';\n\n/**\n * CAM16, a color appearance model. Colors are not just defined by their hex\n * code, but rather, a hex code and viewing conditions.\n *\n * CAM16 instances also have coordinates in the CAM16-UCS space, called J*, a*,\n * b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16\n * specification, and should be used when measuring distances between colors.\n *\n * In traditional color spaces, a color can be identified solely by the\n * observer's measurement of the color. Color appearance models such as CAM16\n * also use information about the environment where the color was\n * observed, known as the viewing conditions.\n *\n * For example, white under the traditional assumption of a midday sun white\n * point is accurately measured as a slightly chromatic blue by CAM16. (roughly,\n * hue 203, chroma 3, lightness 100)\n */\nexport class Cam16 {\n /**\n * All of the CAM16 dimensions can be calculated from 3 of the dimensions, in\n * the following combinations:\n * - {j or q} and {c, m, or s} and hue\n * - jstar, astar, bstar\n * Prefer using a static method that constructs from 3 of those dimensions.\n * This constructor is intended for those methods to use to return all\n * possible dimensions.\n *\n * @param hue\n * @param chroma informally, colorfulness / color intensity. like saturation\n * in HSL, except perceptually accurate.\n * @param j lightness\n * @param q brightness; ratio of lightness to white point's lightness\n * @param m colorfulness\n * @param s saturation; ratio of chroma to white point's chroma\n * @param jstar CAM16-UCS J coordinate\n * @param astar CAM16-UCS a coordinate\n * @param bstar CAM16-UCS b coordinate\n */\n constructor(\n readonly hue: number, readonly chroma: number, readonly j: number,\n readonly q: number, readonly m: number, readonly s: number,\n readonly jstar: number, readonly astar: number, readonly bstar: number) {}\n\n /**\n * CAM16 instances also have coordinates in the CAM16-UCS space, called J*,\n * a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16\n * specification, and is used to measure distances between colors.\n */\n distance(other: Cam16): number {\n const dJ = this.jstar - other.jstar;\n const dA = this.astar - other.astar;\n const dB = this.bstar - other.bstar;\n const dEPrime = Math.sqrt(dJ * dJ + dA * dA + dB * dB);\n const dE = 1.41 * Math.pow(dEPrime, 0.63);\n return dE;\n }\n\n /**\n * @param argb ARGB representation of a color.\n * @return CAM16 color, assuming the color was viewed in default viewing\n * conditions.\n */\n static fromInt(argb: number): Cam16 {\n return Cam16.fromIntInViewingConditions(argb, ViewingConditions.DEFAULT);\n }\n\n /**\n * @param argb ARGB representation of a color.\n * @param viewingConditions Information about the environment where the color\n * was observed.\n * @return CAM16 color.\n */\n static fromIntInViewingConditions(\n argb: number, viewingConditions: ViewingConditions): Cam16 {\n const red = (argb & 0x00ff0000) >> 16;\n const green = (argb & 0x0000ff00) >> 8;\n const blue = (argb & 0x000000ff);\n const redL = utils.linearized(red);\n const greenL = utils.linearized(green);\n const blueL = utils.linearized(blue);\n const x = 0.41233895 * redL + 0.35762064 * greenL + 0.18051042 * blueL;\n const y = 0.2126 * redL + 0.7152 * greenL + 0.0722 * blueL;\n const z = 0.01932141 * redL + 0.11916382 * greenL + 0.95034478 * blueL;\n\n const rC = 0.401288 * x + 0.650173 * y - 0.051461 * z;\n const gC = -0.250268 * x + 1.204414 * y + 0.045854 * z;\n const bC = -0.002079 * x + 0.048952 * y + 0.953127 * z;\n\n const rD = viewingConditions.rgbD[0] * rC;\n const gD = viewingConditions.rgbD[1] * gC;\n const bD = viewingConditions.rgbD[2] * bC;\n\n const rAF = Math.pow((viewingConditions.fl * Math.abs(rD)) / 100.0, 0.42);\n const gAF = Math.pow((viewingConditions.fl * Math.abs(gD)) / 100.0, 0.42);\n const bAF = Math.pow((viewingConditions.fl * Math.abs(bD)) / 100.0, 0.42);\n\n const rA = (math.signum(rD) * 400.0 * rAF) / (rAF + 27.13);\n const gA = (math.signum(gD) * 400.0 * gAF) / (gAF + 27.13);\n const bA = (math.signum(bD) * 400.0 * bAF) / (bAF + 27.13);\n\n const a = (11.0 * rA + -12.0 * gA + bA) / 11.0;\n const b = (rA + gA - 2.0 * bA) / 9.0;\n const u = (20.0 * rA + 20.0 * gA + 21.0 * bA) / 20.0;\n const p2 = (40.0 * rA + 20.0 * gA + bA) / 20.0;\n const atan2 = Math.atan2(b, a);\n const atanDegrees = (atan2 * 180.0) / Math.PI;\n const hue = atanDegrees < 0 ? atanDegrees + 360.0 :\n atanDegrees >= 360 ? atanDegrees - 360.0 :\n atanDegrees;\n const hueRadians = (hue * Math.PI) / 180.0;\n\n const ac = p2 * viewingConditions.nbb;\n const j = 100.0 *\n Math.pow(\n ac / viewingConditions.aw,\n viewingConditions.c * viewingConditions.z);\n const q = (4.0 / viewingConditions.c) * Math.sqrt(j / 100.0) *\n (viewingConditions.aw + 4.0) * viewingConditions.fLRoot;\n const huePrime = hue < 20.14 ? hue + 360 : hue;\n const eHue = 0.25 * (Math.cos((huePrime * Math.PI) / 180.0 + 2.0) + 3.8);\n const p1 =\n (50000.0 / 13.0) * eHue * viewingConditions.nc * viewingConditions.ncb;\n const t = (p1 * Math.sqrt(a * a + b * b)) / (u + 0.305);\n const alpha = Math.pow(t, 0.9) *\n Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);\n const c = alpha * Math.sqrt(j / 100.0);\n const m = c * viewingConditions.fLRoot;\n const s = 50.0 *\n Math.sqrt((alpha * viewingConditions.c) / (viewingConditions.aw + 4.0));\n const jstar = ((1.0 + 100.0 * 0.007) * j) / (1.0 + 0.007 * j);\n const mstar = (1.0 / 0.0228) * Math.log(1.0 + 0.0228 * m);\n const astar = mstar * Math.cos(hueRadians);\n const bstar = mstar * Math.sin(hueRadians);\n\n return new Cam16(hue, c, j, q, m, s, jstar, astar, bstar);\n }\n\n /**\n * @param j CAM16 lightness\n * @param c CAM16 chroma\n * @param h CAM16 hue\n */\n static fromJch(j: number, c: number, h: number): Cam16 {\n return Cam16.fromJchInViewingConditions(j, c, h, ViewingConditions.DEFAULT);\n }\n\n /**\n * @param j CAM16 lightness\n * @param c CAM16 chroma\n * @param h CAM16 hue\n * @param viewingConditions Information about the environment where the color\n * was observed.\n */\n static fromJchInViewingConditions(\n j: number, c: number, h: number,\n viewingConditions: ViewingConditions): Cam16 {\n const q = (4.0 / viewingConditions.c) * Math.sqrt(j / 100.0) *\n (viewingConditions.aw + 4.0) * viewingConditions.fLRoot;\n const m = c * viewingConditions.fLRoot;\n const alpha = c / Math.sqrt(j / 100.0);\n const s = 50.0 *\n Math.sqrt((alpha * viewingConditions.c) / (viewingConditions.aw + 4.0));\n const hueRadians = (h * Math.PI) / 180.0;\n const jstar = ((1.0 + 100.0 * 0.007) * j) / (1.0 + 0.007 * j);\n const mstar = (1.0 / 0.0228) * Math.log(1.0 + 0.0228 * m);\n const astar = mstar * Math.cos(hueRadians);\n const bstar = mstar * Math.sin(hueRadians);\n return new Cam16(h, c, j, q, m, s, jstar, astar, bstar);\n }\n\n /**\n * @param jstar CAM16-UCS lightness.\n * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian\n * coordinate on the Y axis.\n * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian\n * coordinate on the X axis.\n */\n static fromUcs(jstar: number, astar: number, bstar: number): Cam16 {\n return Cam16.fromUcsInViewingConditions(\n jstar, astar, bstar, ViewingConditions.DEFAULT);\n }\n\n /**\n * @param jstar CAM16-UCS lightness.\n * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian\n * coordinate on the Y axis.\n * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian\n * coordinate on the X axis.\n * @param viewingConditions Information about the environment where the color\n * was observed.\n */\n static fromUcsInViewingConditions(\n jstar: number, astar: number, bstar: number,\n viewingConditions: ViewingConditions): Cam16 {\n const a = astar;\n const b = bstar;\n const m = Math.sqrt(a * a + b * b);\n const M = (Math.exp(m * 0.0228) - 1.0) / 0.0228;\n const c = M / viewingConditions.fLRoot;\n let h = Math.atan2(b, a) * (180.0 / Math.PI);\n if (h < 0.0) {\n h += 360.0;\n }\n const j = jstar / (1 - (jstar - 100) * 0.007);\n return Cam16.fromJchInViewingConditions(j, c, h, viewingConditions);\n }\n\n /**\n * @return ARGB representation of color, assuming the color was viewed in\n * default viewing conditions, which are near-identical to the default\n * viewing conditions for sRGB.\n */\n toInt(): number {\n return this.viewed(ViewingConditions.DEFAULT);\n }\n\n /**\n * @param viewingConditions Information about the environment where the color\n * will be viewed.\n * @return ARGB representation of color\n */\n viewed(viewingConditions: ViewingConditions): number {\n const alpha = this.chroma === 0.0 || this.j === 0.0 ?\n 0.0 :\n this.chroma / Math.sqrt(this.j / 100.0);\n\n const t = Math.pow(\n alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73),\n 1.0 / 0.9);\n const hRad = (this.hue * Math.PI) / 180.0;\n\n const eHue = 0.25 * (Math.cos(hRad + 2.0) + 3.8);\n const ac = viewingConditions.aw *\n Math.pow(\n this.j / 100.0, 1.0 / viewingConditions.c / viewingConditions.z);\n const p1 =\n eHue * (50000.0 / 13.0) * viewingConditions.nc * viewingConditions.ncb;\n const p2 = ac / viewingConditions.nbb;\n\n const hSin = Math.sin(hRad);\n const hCos = Math.cos(hRad);\n\n const gamma = (23.0 * (p2 + 0.305) * t) /\n (23.0 * p1 + 11.0 * t * hCos + 108.0 * t * hSin);\n const a = gamma * hCos;\n const b = gamma * hSin;\n const rA = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;\n const gA = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;\n const bA = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;\n\n const rCBase = Math.max(0, (27.13 * Math.abs(rA)) / (400.0 - Math.abs(rA)));\n const rC = math.signum(rA) * (100.0 / viewingConditions.fl) *\n Math.pow(rCBase, 1.0 / 0.42);\n const gCBase = Math.max(0, (27.13 * Math.abs(gA)) / (400.0 - Math.abs(gA)));\n const gC = math.signum(gA) * (100.0 / viewingConditions.fl) *\n Math.pow(gCBase, 1.0 / 0.42);\n const bCBase = Math.max(0, (27.13 * Math.abs(bA)) / (400.0 - Math.abs(bA)));\n const bC = math.signum(bA) * (100.0 / viewingConditions.fl) *\n Math.pow(bCBase, 1.0 / 0.42);\n const rF = rC / viewingConditions.rgbD[0];\n const gF = gC / viewingConditions.rgbD[1];\n const bF = bC / viewingConditions.rgbD[2];\n\n const x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF;\n const y = 0.38752654 * rF + 0.62144744 * gF - 0.00897398 * bF;\n const z = -0.01584150 * rF - 0.03412294 * gF + 1.04996444 * bF;\n\n const argb = utils.argbFromXyz(x, y, z);\n return argb;\n }\n\n /// Given color expressed in XYZ and viewed in [viewingConditions], convert to\n /// CAM16.\n static fromXyzInViewingConditions(\n x: number, y: number, z: number,\n viewingConditions: ViewingConditions): Cam16 {\n // Transform XYZ to 'cone'/'rgb' responses\n\n const rC = 0.401288 * x + 0.650173 * y - 0.051461 * z;\n const gC = -0.250268 * x + 1.204414 * y + 0.045854 * z;\n const bC = -0.002079 * x + 0.048952 * y + 0.953127 * z;\n\n // Discount illuminant\n const rD = viewingConditions.rgbD[0] * rC;\n const gD = viewingConditions.rgbD[1] * gC;\n const bD = viewingConditions.rgbD[2] * bC;\n\n // chromatic adaptation\n const rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100.0, 0.42);\n const gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100.0, 0.42);\n const bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100.0, 0.42);\n const rA = math.signum(rD) * 400.0 * rAF / (rAF + 27.13);\n const gA = math.signum(gD) * 400.0 * gAF / (gAF + 27.13);\n const bA = math.signum(bD) * 400.0 * bAF / (bAF + 27.13);\n\n // redness-greenness\n const a = (11.0 * rA + -12.0 * gA + bA) / 11.0;\n // yellowness-blueness\n const b = (rA + gA - 2.0 * bA) / 9.0;\n\n // auxiliary components\n const u = (20.0 * rA + 20.0 * gA + 21.0 * bA) / 20.0;\n const p2 = (40.0 * rA + 20.0 * gA + bA) / 20.0;\n\n // hue\n const atan2 = Math.atan2(b, a);\n const atanDegrees = atan2 * 180.0 / Math.PI;\n const hue = atanDegrees < 0 ? atanDegrees + 360.0 :\n atanDegrees >= 360 ? atanDegrees - 360 :\n atanDegrees;\n const hueRadians = hue * Math.PI / 180.0;\n\n // achromatic response to color\n const ac = p2 * viewingConditions.nbb;\n\n // CAM16 lightness and brightness\n const J = 100.0 *\n Math.pow(\n ac / viewingConditions.aw,\n viewingConditions.c * viewingConditions.z);\n const Q = (4.0 / viewingConditions.c) * Math.sqrt(J / 100.0) *\n (viewingConditions.aw + 4.0) * (viewingConditions.fLRoot);\n\n const huePrime = (hue < 20.14) ? hue + 360 : hue;\n const eHue =\n (1.0 / 4.0) * (Math.cos(huePrime * Math.PI / 180.0 + 2.0) + 3.8);\n const p1 =\n 50000.0 / 13.0 * eHue * viewingConditions.nc * viewingConditions.ncb;\n const t = p1 * Math.sqrt(a * a + b * b) / (u + 0.305);\n const alpha = Math.pow(t, 0.9) *\n Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);\n // CAM16 chroma, colorfulness, chroma\n const C = alpha * Math.sqrt(J / 100.0);\n const M = C * viewingConditions.fLRoot;\n const s = 50.0 *\n Math.sqrt((alpha * viewingConditions.c) / (viewingConditions.aw + 4.0));\n\n // CAM16-UCS components\n const jstar = (1.0 + 100.0 * 0.007) * J / (1.0 + 0.007 * J);\n const mstar = Math.log(1.0 + 0.0228 * M) / 0.0228;\n const astar = mstar * Math.cos(hueRadians);\n const bstar = mstar * Math.sin(hueRadians);\n return new Cam16(hue, C, J, Q, M, s, jstar, astar, bstar);\n }\n\n /// XYZ representation of CAM16 seen in [viewingConditions].\n xyzInViewingConditions(viewingConditions: ViewingConditions): number[] {\n const alpha = (this.chroma === 0.0 || this.j === 0.0) ?\n 0.0 :\n this.chroma / Math.sqrt(this.j / 100.0);\n\n const t = Math.pow(\n alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73),\n 1.0 / 0.9);\n const hRad = this.hue * Math.PI / 180.0;\n\n const eHue = 0.25 * (Math.cos(hRad + 2.0) + 3.8);\n const ac = viewingConditions.aw *\n Math.pow(\n this.j / 100.0, 1.0 / viewingConditions.c / viewingConditions.z);\n const p1 =\n eHue * (50000.0 / 13.0) * viewingConditions.nc * viewingConditions.ncb;\n\n const p2 = (ac / viewingConditions.nbb);\n\n const hSin = Math.sin(hRad);\n const hCos = Math.cos(hRad);\n\n const gamma = 23.0 * (p2 + 0.305) * t /\n (23.0 * p1 + 11 * t * hCos + 108.0 * t * hSin);\n const a = gamma * hCos;\n const b = gamma * hSin;\n const rA = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;\n const gA = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;\n const bA = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;\n\n const rCBase = Math.max(0, (27.13 * Math.abs(rA)) / (400.0 - Math.abs(rA)));\n const rC = math.signum(rA) * (100.0 / viewingConditions.fl) *\n Math.pow(rCBase, 1.0 / 0.42);\n const gCBase = Math.max(0, (27.13 * Math.abs(gA)) / (400.0 - Math.abs(gA)));\n const gC = math.signum(gA) * (100.0 / viewingConditions.fl) *\n Math.pow(gCBase, 1.0 / 0.42);\n const bCBase = Math.max(0, (27.13 * Math.abs(bA)) / (400.0 - Math.abs(bA)));\n const bC = math.signum(bA) * (100.0 / viewingConditions.fl) *\n Math.pow(bCBase, 1.0 / 0.42);\n const rF = rC / viewingConditions.rgbD[0];\n const gF = gC / viewingConditions.rgbD[1];\n const bF = bC / viewingConditions.rgbD[2];\n\n const x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF;\n const y = 0.38752654 * rF + 0.62144744 * gF - 0.00897398 * bF;\n const z = -0.01584150 * rF - 0.03412294 * gF + 1.04996444 * bF;\n\n return [x, y, z];\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// This file is automatically generated. Do not modify it.\n\nimport * as colorUtils from '../utils/color_utils.js';\nimport * as mathUtils from '../utils/math_utils.js';\n\nimport {Cam16} from './cam16.js';\nimport {ViewingConditions} from './viewing_conditions.js';\n\n\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable:class-as-namespace\n/**\n * A class that solves the HCT equation.\n */\nexport class HctSolver {\n static SCALED_DISCOUNT_FROM_LINRGB = [\n [\n 0.001200833568784504,\n 0.002389694492170889,\n 0.0002795742885861124,\n ],\n [\n 0.0005891086651375999,\n 0.0029785502573438758,\n 0.0003270666104008398,\n ],\n [\n 0.00010146692491640572,\n 0.0005364214359186694,\n 0.0032979401770712076,\n ],\n ];\n\n static LINRGB_FROM_SCALED_DISCOUNT = [\n [\n 1373.2198709594231,\n -1100.4251190754821,\n -7.278681089101213,\n ],\n [\n -271.815969077903,\n 559.6580465940733,\n -32.46047482791194,\n ],\n [\n 1.9622899599665666,\n -57.173814538844006,\n 308.7233197812385,\n ],\n ];\n\n static Y_FROM_LINRGB = [0.2126, 0.7152, 0.0722];\n\n static CRITICAL_PLANES = [\n 0.015176349177441876, 0.045529047532325624, 0.07588174588720938,\n 0.10623444424209313, 0.13658714259697685, 0.16693984095186062,\n 0.19729253930674434, 0.2276452376616281, 0.2579979360165119,\n 0.28835063437139563, 0.3188300904430532, 0.350925934958123,\n 0.3848314933096426, 0.42057480301049466, 0.458183274052838,\n 0.4976837250274023, 0.5391024159806381, 0.5824650784040898,\n 0.6277969426914107, 0.6751227633498623, 0.7244668422128921,\n 0.775853049866786, 0.829304845476233, 0.8848452951698498,\n 0.942497089126609, 1.0022825574869039, 1.0642236851973577,\n 1.1283421258858297, 1.1946592148522128, 1.2631959812511864,\n 1.3339731595349034, 1.407011200216447, 1.4823302800086415,\n 1.5599503113873272, 1.6398909516233677, 1.7221716113234105,\n 1.8068114625156377, 1.8938294463134073, 1.9832442801866852,\n 2.075074464868551, 2.1693382909216234, 2.2660538449872063,\n 2.36523901573795, 2.4669114995532007, 2.5710888059345764,\n 2.6777882626779785, 2.7870270208169257, 2.898822059350997,\n 3.0131901897720907, 3.1301480604002863, 3.2497121605402226,\n 3.3718988244681087, 3.4967242352587946, 3.624204428461639,\n 3.754355295633311, 3.887192587735158, 4.022731918402185,\n 4.160988767090289, 4.301978482107941, 4.445716283538092,\n 4.592217266055746, 4.741496401646282, 4.893568542229298,\n 5.048448422192488, 5.20615066083972, 5.3666897647573375,\n 5.5300801301023865, 5.696336044816294, 5.865471690767354,\n 6.037501145825082, 6.212438385869475, 6.390297286737924,\n 6.571091626112461, 6.7548350853498045, 6.941541251256611,\n 7.131223617812143, 7.323895587840543, 7.5195704746346665,\n 7.7182615035334345, 7.919981813454504, 8.124744458384042,\n 8.332562408825165, 8.543448553206703, 8.757415699253682,\n 8.974476575321063, 9.194643831691977, 9.417930041841839,\n 9.644347703669503, 9.873909240696694, 10.106627003236781,\n 10.342513269534024, 10.58158024687427, 10.8238400726681,\n 11.069304815507364, 11.317986476196008, 11.569896988756009,\n 11.825048221409341, 12.083451977536606, 12.345119996613247,\n 12.610063955123938, 12.878295467455942, 13.149826086772048,\n 13.42466730586372, 13.702830557985108, 13.984327217668513,\n 14.269168601521828, 14.55736596900856, 14.848930523210871,\n 15.143873411576273, 15.44220572664832, 15.743938506781891,\n 16.04908273684337, 16.35764934889634, 16.66964922287304,\n 16.985093187232053, 17.30399201960269, 17.62635644741625,\n 17.95219714852476, 18.281524751807332, 18.614349837764564,\n 18.95068293910138, 19.290534541298456, 19.633915083172692,\n 19.98083495742689, 20.331304511189067, 20.685334046541502,\n 21.042933821039977, 21.404114048223256, 21.76888489811322,\n 22.137256497705877, 22.50923893145328, 22.884842241736916,\n 23.264076429332462, 23.6469514538663, 24.033477234264016,\n 24.42366364919083, 24.817520537484558, 25.21505769858089,\n 25.61628489293138, 26.021211842414342, 26.429848230738664,\n 26.842203703840827, 27.258287870275353, 27.678110301598522,\n 28.10168053274597, 28.529008062403893, 28.96010235337422,\n 29.39497283293396, 29.83362889318845, 30.276079891419332,\n 30.722335150426627, 31.172403958865512, 31.62629557157785,\n 32.08401920991837, 32.54558406207592, 33.010999283389665,\n 33.4802739966603, 33.953417292456834, 34.430438229418264,\n 34.911345834551085, 35.39614910352207, 35.88485700094671,\n 36.37747846067349, 36.87402238606382, 37.37449765026789,\n 37.87891309649659, 38.38727753828926, 38.89959975977785,\n 39.41588851594697, 39.93615253289054, 40.460400508064545,\n 40.98864111053629, 41.520882981230194, 42.05713473317016,\n 42.597404951718396, 43.141702194811224, 43.6900349931913,\n 44.24241185063697, 44.798841244188324, 45.35933162437017,\n 45.92389141541209, 46.49252901546552, 47.065252796817916,\n 47.64207110610409, 48.22299226451468, 48.808024568002054,\n 49.3971762874833, 49.9904556690408, 50.587870934119984,\n 51.189430279724725, 51.79514187861014, 52.40501387947288,\n 53.0190544071392, 53.637271562750364, 54.259673423945976,\n 54.88626804504493, 55.517063457223934, 56.15206766869424,\n 56.79128866487574, 57.43473440856916, 58.08241284012621,\n 58.734331877617365, 59.39049941699807, 60.05092333227251,\n 60.715611475655585, 61.38457167773311, 62.057811747619894,\n 62.7353394731159, 63.417162620860914, 64.10328893648692,\n 64.79372614476921, 65.48848194977529, 66.18756403501224,\n 66.89098006357258, 67.59873767827808, 68.31084450182222,\n 69.02730813691093, 69.74813616640164, 70.47333615344107,\n 71.20291564160104, 71.93688215501312, 72.67524319850172,\n 73.41800625771542, 74.16517879925733, 74.9167682708136,\n 75.67278210128072, 76.43322770089146, 77.1981124613393,\n 77.96744375590167, 78.74122893956174, 79.51947534912904,\n 80.30219030335869, 81.08938110306934, 81.88105503125999,\n 82.67721935322541, 83.4778813166706, 84.28304815182372,\n 85.09272707154808, 85.90692527145302, 86.72564993000343,\n 87.54890820862819, 88.3767072518277, 89.2090541872801,\n 90.04595612594655, 90.88742016217518, 91.73345337380438,\n 92.58406282226491, 93.43925555268066, 94.29903859396902,\n 95.16341895893969, 96.03240364439274, 96.9059996312159,\n 97.78421388448044, 98.6670533535366, 99.55452497210776,\n ];\n\n /**\n * Sanitizes a small enough angle in radians.\n *\n * @param angle An angle in radians; must not deviate too much\n * from 0.\n * @return A coterminal angle between 0 and 2pi.\n */\n private static sanitizeRadians(angle: number): number {\n return (angle + Math.PI * 8) % (Math.PI * 2);\n }\n\n /**\n * Delinearizes an RGB component, returning a floating-point\n * number.\n *\n * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents\n * linear R/G/B channel\n * @return 0.0 <= output <= 255.0, color channel converted to\n * regular RGB space\n */\n private static trueDelinearized(rgbComponent: number): number {\n const normalized = rgbComponent / 100.0;\n let delinearized = 0.0;\n if (normalized <= 0.0031308) {\n delinearized = normalized * 12.92;\n } else {\n delinearized = 1.055 * Math.pow(normalized, 1.0 / 2.4) - 0.055;\n }\n return delinearized * 255.0;\n }\n\n private static chromaticAdaptation(component: number): number {\n const af = Math.pow(Math.abs(component), 0.42);\n return mathUtils.signum(component) * 400.0 * af / (af + 27.13);\n }\n\n /**\n * Returns the hue of a linear RGB color in CAM16.\n *\n * @param linrgb The linear RGB coordinates of a color.\n * @return The hue of the color in CAM16, in radians.\n */\n private static hueOf(linrgb: number[]): number {\n const scaledDiscount =\n mathUtils.matrixMultiply(linrgb, HctSolver.SCALED_DISCOUNT_FROM_LINRGB);\n const rA = HctSolver.chromaticAdaptation(scaledDiscount[0]);\n const gA = HctSolver.chromaticAdaptation(scaledDiscount[1]);\n const bA = HctSolver.chromaticAdaptation(scaledDiscount[2]);\n // redness-greenness\n const a = (11.0 * rA + -12.0 * gA + bA) / 11.0;\n // yellowness-blueness\n const b = (rA + gA - 2.0 * bA) / 9.0;\n return Math.atan2(b, a);\n }\n\n private static areInCyclicOrder(a: number, b: number, c: number): boolean {\n const deltaAB = HctSolver.sanitizeRadians(b - a);\n const deltaAC = HctSolver.sanitizeRadians(c - a);\n return deltaAB < deltaAC;\n }\n\n /**\n * Solves the lerp equation.\n *\n * @param source The starting number.\n * @param mid The number in the middle.\n * @param target The ending number.\n * @return A number t such that lerp(source, target, t) = mid.\n */\n private static intercept(source: number, mid: number, target: number):\n number {\n return (mid - source) / (target - source);\n }\n\n private static lerpPoint(source: number[], t: number, target: number[]):\n number[] {\n return [\n source[0] + (target[0] - source[0]) * t,\n source[1] + (target[1] - source[1]) * t,\n source[2] + (target[2] - source[2]) * t,\n ];\n }\n\n /**\n * Intersects a segment with a plane.\n *\n * @param source The coordinates of point A.\n * @param coordinate The R-, G-, or B-coordinate of the plane.\n * @param target The coordinates of point B.\n * @param axis The axis the plane is perpendicular with. (0: R, 1:\n * G, 2: B)\n * @return The intersection point of the segment AB with the plane\n * R=coordinate, G=coordinate, or B=coordinate\n */\n private static setCoordinate(\n source: number[],\n coordinate: number,\n target: number[],\n axis: number,\n ): number[] {\n const t = HctSolver.intercept(source[axis], coordinate, target[axis]);\n return HctSolver.lerpPoint(source, t, target);\n }\n\n private static isBounded(x: number): boolean {\n return 0.0 <= x && x <= 100.0;\n }\n\n /**\n * Returns the nth possible vertex of the polygonal intersection.\n *\n * @param y The Y value of the plane.\n * @param n The zero-based index of the point. 0 <= n <= 11.\n * @return The nth possible vertex of the polygonal intersection\n * of the y plane and the RGB cube, in linear RGB coordinates, if\n * it exists. If this possible vertex lies outside of the cube,\n * [-1.0, -1.0, -1.0] is returned.\n */\n private static nthVertex(y: number, n: number): number[] {\n const kR = HctSolver.Y_FROM_LINRGB[0];\n const kG = HctSolver.Y_FROM_LINRGB[1];\n const kB = HctSolver.Y_FROM_LINRGB[2];\n const coordA = n % 4 <= 1 ? 0.0 : 100.0;\n const coordB = n % 2 === 0 ? 0.0 : 100.0;\n if (n < 4) {\n const g = coordA;\n const b = coordB;\n const r = (y - g * kG - b * kB) / kR;\n if (HctSolver.isBounded(r)) {\n return [r, g, b];\n } else {\n return [-1.0, -1.0, -1.0];\n }\n } else if (n < 8) {\n const b = coordA;\n const r = coordB;\n const g = (y - r * kR - b * kB) / kG;\n if (HctSolver.isBounded(g)) {\n return [r, g, b];\n } else {\n return [-1.0, -1.0, -1.0];\n }\n } else {\n const r = coordA;\n const g = coordB;\n const b = (y - r * kR - g * kG) / kB;\n if (HctSolver.isBounded(b)) {\n return [r, g, b];\n } else {\n return [-1.0, -1.0, -1.0];\n }\n }\n }\n\n /**\n * Finds the segment containing the desired color.\n *\n * @param y The Y value of the color.\n * @param targetHue The hue of the color.\n * @return A list of two sets of linear RGB coordinates, each\n * corresponding to an endpoint of the segment containing the\n * desired color.\n */\n private static bisectToSegment(y: number, targetHue: number): number[][] {\n let left = [-1.0, -1.0, -1.0];\n let right = left;\n let leftHue = 0.0;\n let rightHue = 0.0;\n let initialized = false;\n let uncut = true;\n for (let n = 0; n < 12; n++) {\n const mid = HctSolver.nthVertex(y, n);\n if (mid[0] < 0) {\n continue;\n }\n const midHue = HctSolver.hueOf(mid);\n if (!initialized) {\n left = mid;\n right = mid;\n leftHue = midHue;\n rightHue = midHue;\n initialized = true;\n continue;\n }\n if (uncut || HctSolver.areInCyclicOrder(leftHue, midHue, rightHue)) {\n uncut = false;\n if (HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {\n right = mid;\n rightHue = midHue;\n } else {\n left = mid;\n leftHue = midHue;\n }\n }\n }\n return [left, right];\n }\n\n private static midpoint(a: number[], b: number[]): number[] {\n return [\n (a[0] + b[0]) / 2,\n (a[1] + b[1]) / 2,\n (a[2] + b[2]) / 2,\n ];\n }\n\n private static criticalPlaneBelow(x: number): number {\n return Math.floor(x - 0.5);\n }\n\n private static criticalPlaneAbove(x: number): number {\n return Math.ceil(x - 0.5);\n }\n\n /**\n * Finds a color with the given Y and hue on the boundary of the\n * cube.\n *\n * @param y The Y value of the color.\n * @param targetHue The hue of the color.\n * @return The desired color, in linear RGB coordinates.\n */\n private static bisectToLimit(y: number, targetHue: number): number[] {\n const segment = HctSolver.bisectToSegment(y, targetHue);\n let left = segment[0];\n let leftHue = HctSolver.hueOf(left);\n let right = segment[1];\n for (let axis = 0; axis < 3; axis++) {\n if (left[axis] !== right[axis]) {\n let lPlane = -1;\n let rPlane = 255;\n if (left[axis] < right[axis]) {\n lPlane = HctSolver.criticalPlaneBelow(\n HctSolver.trueDelinearized(left[axis]));\n rPlane = HctSolver.criticalPlaneAbove(\n HctSolver.trueDelinearized(right[axis]));\n } else {\n lPlane = HctSolver.criticalPlaneAbove(\n HctSolver.trueDelinearized(left[axis]));\n rPlane = HctSolver.criticalPlaneBelow(\n HctSolver.trueDelinearized(right[axis]));\n }\n for (let i = 0; i < 8; i++) {\n if (Math.abs(rPlane - lPlane) <= 1) {\n break;\n } else {\n const mPlane = Math.floor((lPlane + rPlane) / 2.0);\n const midPlaneCoordinate = HctSolver.CRITICAL_PLANES[mPlane];\n const mid =\n HctSolver.setCoordinate(left, midPlaneCoordinate, right, axis);\n const midHue = HctSolver.hueOf(mid);\n if (HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {\n right = mid;\n rPlane = mPlane;\n } else {\n left = mid;\n leftHue = midHue;\n lPlane = mPlane;\n }\n }\n }\n }\n }\n return HctSolver.midpoint(left, right);\n }\n\n private static inverseChromaticAdaptation(adapted: number): number {\n const adaptedAbs = Math.abs(adapted);\n const base = Math.max(0, 27.13 * adaptedAbs / (400.0 - adaptedAbs));\n return mathUtils.signum(adapted) * Math.pow(base, 1.0 / 0.42);\n }\n\n /**\n * Finds a color with the given hue, chroma, and Y.\n *\n * @param hueRadians The desired hue in radians.\n * @param chroma The desired chroma.\n * @param y The desired Y.\n * @return The desired color as a hexadecimal integer, if found; 0\n * otherwise.\n */\n private static findResultByJ(hueRadians: number, chroma: number, y: number):\n number {\n // Initial estimate of j.\n let j = Math.sqrt(y) * 11.0;\n // ===========================================================\n // Operations inlined from Cam16 to avoid repeated calculation\n // ===========================================================\n const viewingConditions = ViewingConditions.DEFAULT;\n const tInnerCoeff =\n 1 / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);\n const eHue = 0.25 * (Math.cos(hueRadians + 2.0) + 3.8);\n const p1 =\n eHue * (50000.0 / 13.0) * viewingConditions.nc * viewingConditions.ncb;\n const hSin = Math.sin(hueRadians);\n const hCos = Math.cos(hueRadians);\n for (let iterationRound = 0; iterationRound < 5; iterationRound++) {\n // ===========================================================\n // Operations inlined from Cam16 to avoid repeated calculation\n // ===========================================================\n const jNormalized = j / 100.0;\n const alpha =\n chroma === 0.0 || j === 0.0 ? 0.0 : chroma / Math.sqrt(jNormalized);\n const t = Math.pow(alpha * tInnerCoeff, 1.0 / 0.9);\n const ac = viewingConditions.aw *\n Math.pow(\n jNormalized,\n 1.0 / viewingConditions.c / viewingConditions.z,\n );\n const p2 = ac / viewingConditions.nbb;\n const gamma = 23.0 * (p2 + 0.305) * t /\n (23.0 * p1 + 11 * t * hCos + 108.0 * t * hSin);\n const a = gamma * hCos;\n const b = gamma * hSin;\n const rA = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;\n const gA = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;\n const bA = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;\n const rCScaled = HctSolver.inverseChromaticAdaptation(rA);\n const gCScaled = HctSolver.inverseChromaticAdaptation(gA);\n const bCScaled = HctSolver.inverseChromaticAdaptation(bA);\n const linrgb = mathUtils.matrixMultiply(\n [rCScaled, gCScaled, bCScaled],\n HctSolver.LINRGB_FROM_SCALED_DISCOUNT,\n );\n // ===========================================================\n // Operations inlined from Cam16 to avoid repeated calculation\n // ===========================================================\n if (linrgb[0] < 0 || linrgb[1] < 0 || linrgb[2] < 0) {\n return 0;\n }\n const kR = HctSolver.Y_FROM_LINRGB[0];\n const kG = HctSolver.Y_FROM_LINRGB[1];\n const kB = HctSolver.Y_FROM_LINRGB[2];\n const fnj = kR * linrgb[0] + kG * linrgb[1] + kB * linrgb[2];\n if (fnj <= 0) {\n return 0;\n }\n if (iterationRound === 4 || Math.abs(fnj - y) < 0.002) {\n if (linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01) {\n return 0;\n }\n return colorUtils.argbFromLinrgb(linrgb);\n }\n // Iterates with Newton method,\n // Using 2 * fn(j) / j as the approximation of fn'(j)\n j = j - (fnj - y) * j / (2 * fnj);\n }\n return 0;\n }\n\n /**\n * Finds an sRGB color with the given hue, chroma, and L*, if\n * possible.\n *\n * @param hueDegrees The desired hue, in degrees.\n * @param chroma The desired chroma.\n * @param lstar The desired L*.\n * @return A hexadecimal representing the sRGB color. The color\n * has sufficiently close hue, chroma, and L* to the desired\n * values, if possible; otherwise, the hue and L* will be\n * sufficiently close, and chroma will be maximized.\n */\n static solveToInt(hueDegrees: number, chroma: number, lstar: number): number {\n if (chroma < 0.0001 || lstar < 0.0001 || lstar > 99.9999) {\n return colorUtils.argbFromLstar(lstar);\n }\n hueDegrees = mathUtils.sanitizeDegreesDouble(hueDegrees);\n const hueRadians = hueDegrees / 180 * Math.PI;\n const y = colorUtils.yFromLstar(lstar);\n const exactAnswer = HctSolver.findResultByJ(hueRadians, chroma, y);\n if (exactAnswer !== 0) {\n return exactAnswer;\n }\n const linrgb = HctSolver.bisectToLimit(y, hueRadians);\n return colorUtils.argbFromLinrgb(linrgb);\n }\n\n /**\n * Finds an sRGB color with the given hue, chroma, and L*, if\n * possible.\n *\n * @param hueDegrees The desired hue, in degrees.\n * @param chroma The desired chroma.\n * @param lstar The desired L*.\n * @return An CAM16 object representing the sRGB color. The color\n * has sufficiently close hue, chroma, and L* to the desired\n * values, if possible; otherwise, the hue and L* will be\n * sufficiently close, and chroma will be maximized.\n */\n static solveToCam(hueDegrees: number, chroma: number, lstar: number): Cam16 {\n return Cam16.fromInt(HctSolver.solveToInt(hueDegrees, chroma, lstar));\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A color system built using CAM16 hue and chroma, and L* from\n * L*a*b*.\n *\n * Using L* creates a link between the color system, contrast, and thus\n * accessibility. Contrast ratio depends on relative luminance, or Y in the XYZ\n * color space. L*, or perceptual luminance can be calculated from Y.\n *\n * Unlike Y, L* is linear to human perception, allowing trivial creation of\n * accurate color tones.\n *\n * Unlike contrast ratio, measuring contrast in L* is linear, and simple to\n * calculate. A difference of 40 in HCT tone guarantees a contrast ratio >= 3.0,\n * and a difference of 50 guarantees a contrast ratio >= 4.5.\n */\n\nimport * as utils from '../utils/color_utils.js';\n\nimport {Cam16} from './cam16.js';\nimport {HctSolver} from './hct_solver.js';\nimport {ViewingConditions} from './viewing_conditions.js';\n\n\n/**\n * HCT, hue, chroma, and tone. A color system that provides a perceptually\n * accurate color measurement system that can also accurately render what colors\n * will appear as in different lighting environments.\n */\nexport class Hct {\n /**\n * @param hue 0 <= hue < 360; invalid values are corrected.\n * @param chroma 0 <= chroma < ?; Informally, colorfulness. The color\n * returned may be lower than the requested chroma. Chroma has a different\n * maximum for any given hue and tone.\n * @param tone 0 <= tone <= 100; invalid values are corrected.\n * @return HCT representation of a color in default viewing conditions.\n */\n\n internalHue: number;\n internalChroma: number;\n internalTone: number;\n\n static from(hue: number, chroma: number, tone: number) {\n return new Hct(HctSolver.solveToInt(hue, chroma, tone));\n }\n\n /**\n * @param argb ARGB representation of a color.\n * @return HCT representation of a color in default viewing conditions\n */\n static fromInt(argb: number) {\n return new Hct(argb);\n }\n\n toInt(): number {\n return this.argb;\n }\n\n /**\n * A number, in degrees, representing ex. red, orange, yellow, etc.\n * Ranges from 0 <= hue < 360.\n */\n get hue(): number {\n return this.internalHue;\n }\n\n /**\n * @param newHue 0 <= newHue < 360; invalid values are corrected.\n * Chroma may decrease because chroma has a different maximum for any given\n * hue and tone.\n */\n set hue(newHue: number) {\n this.setInternalState(\n HctSolver.solveToInt(\n newHue,\n this.internalChroma,\n this.internalTone,\n ),\n );\n }\n\n get chroma(): number {\n return this.internalChroma;\n }\n\n /**\n * @param newChroma 0 <= newChroma < ?\n * Chroma may decrease because chroma has a different maximum for any given\n * hue and tone.\n */\n set chroma(newChroma: number) {\n this.setInternalState(\n HctSolver.solveToInt(\n this.internalHue,\n newChroma,\n this.internalTone,\n ),\n );\n }\n\n /** Lightness. Ranges from 0 to 100. */\n get tone(): number {\n return this.internalTone;\n }\n\n /**\n * @param newTone 0 <= newTone <= 100; invalid valids are corrected.\n * Chroma may decrease because chroma has a different maximum for any given\n * hue and tone.\n */\n set tone(newTone: number) {\n this.setInternalState(\n HctSolver.solveToInt(\n this.internalHue,\n this.internalChroma,\n newTone,\n ),\n );\n }\n\n private constructor(private argb: number) {\n const cam = Cam16.fromInt(argb);\n this.internalHue = cam.hue;\n this.internalChroma = cam.chroma;\n this.internalTone = utils.lstarFromArgb(argb);\n this.argb = argb;\n }\n\n private setInternalState(argb: number) {\n const cam = Cam16.fromInt(argb);\n this.internalHue = cam.hue;\n this.internalChroma = cam.chroma;\n this.internalTone = utils.lstarFromArgb(argb);\n this.argb = argb;\n }\n\n /**\n * Translates a color into different [ViewingConditions].\n *\n * Colors change appearance. They look different with lights on versus off,\n * the same color, as in hex code, on white looks different when on black.\n * This is called color relativity, most famously explicated by Josef Albers\n * in Interaction of Color.\n *\n * In color science, color appearance models can account for this and\n * calculate the appearance of a color in different settings. HCT is based on\n * CAM16, a color appearance model, and uses it to make these calculations.\n *\n * See [ViewingConditions.make] for parameters affecting color appearance.\n */\n inViewingConditions(vc: ViewingConditions): Hct {\n // 1. Use CAM16 to find XYZ coordinates of color in specified VC.\n const cam = Cam16.fromInt(this.toInt());\n const viewedInVc = cam.xyzInViewingConditions(vc);\n\n // 2. Create CAM16 of those XYZ coordinates in default VC.\n const recastInVc = Cam16.fromXyzInViewingConditions(\n viewedInVc[0],\n viewedInVc[1],\n viewedInVc[2],\n ViewingConditions.make(),\n );\n\n // 3. Create HCT from:\n // - CAM16 using default VC with XYZ coordinates in specified VC.\n // - L* converted from Y in XYZ coordinates in specified VC.\n const recastHct = Hct.from(\n recastInVc.hue,\n recastInVc.chroma,\n utils.lstarFromY(viewedInVc[1]),\n );\n return recastHct;\n }\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable:class-as-namespace\n\nimport * as utils from '../utils/color_utils.js';\nimport * as math from '../utils/math_utils.js';\n\n/**\n * Utility methods for calculating contrast given two colors, or calculating a\n * color given one color and a contrast ratio.\n *\n * Contrast ratio is calculated using XYZ's Y. When linearized to match human\n * perception, Y becomes HCT's tone and L*a*b*'s' L*. Informally, this is the\n * lightness of a color.\n *\n * Methods refer to tone, T in the the HCT color space.\n * Tone is equivalent to L* in the L*a*b* color space, or L in the LCH color\n * space.\n */\nexport class Contrast {\n /**\n * Returns a contrast ratio, which ranges from 1 to 21.\n *\n * @param toneA Tone between 0 and 100. Values outside will be clamped.\n * @param toneB Tone between 0 and 100. Values outside will be clamped.\n */\n static ratioOfTones(toneA: number, toneB: number): number {\n toneA = math.clampDouble(0.0, 100.0, toneA);\n toneB = math.clampDouble(0.0, 100.0, toneB);\n return Contrast.ratioOfYs(utils.yFromLstar(toneA), utils.yFromLstar(toneB));\n }\n\n static ratioOfYs(y1: number, y2: number): number {\n const lighter = y1 > y2 ? y1 : y2;\n const darker = (lighter === y2) ? y1 : y2;\n return (lighter + 5.0) / (darker + 5.0);\n }\n\n /**\n * Returns a tone >= tone parameter that ensures ratio parameter.\n * Return value is between 0 and 100.\n * Returns -1 if ratio cannot be achieved with tone parameter.\n *\n * @param tone Tone return value must contrast with.\n * Range is 0 to 100. Invalid values will result in -1 being returned.\n * @param ratio Contrast ratio of return value and tone.\n * Range is 1 to 21, invalid values have undefined behavior.\n */\n static lighter(tone: number, ratio: number): number {\n if (tone < 0.0 || tone > 100.0) {\n return -1.0;\n }\n\n const darkY = utils.yFromLstar(tone);\n const lightY = ratio * (darkY + 5.0) - 5.0;\n const realContrast = Contrast.ratioOfYs(lightY, darkY);\n const delta = Math.abs(realContrast - ratio);\n if (realContrast < ratio && delta > 0.04) {\n return -1;\n }\n\n // Ensure gamut mapping, which requires a 'range' on tone, will still result\n // the correct ratio by darkening slightly.\n const returnValue = utils.lstarFromY(lightY) + 0.4;\n if (returnValue < 0 || returnValue > 100) {\n return -1;\n }\n return returnValue;\n }\n\n /**\n * Returns a tone <= tone parameter that ensures ratio parameter.\n * Return value is between 0 and 100.\n * Returns -1 if ratio cannot be achieved with tone parameter.\n *\n * @param tone Tone return value must contrast with.\n * Range is 0 to 100. Invalid values will result in -1 being returned.\n * @param ratio Contrast ratio of return value and tone.\n * Range is 1 to 21, invalid values have undefined behavior.\n */\n static darker(tone: number, ratio: number): number {\n if (tone < 0.0 || tone > 100.0) {\n return -1.0;\n }\n\n const lightY = utils.yFromLstar(tone);\n const darkY = ((lightY + 5.0) / ratio) - 5.0;\n const realContrast = Contrast.ratioOfYs(lightY, darkY);\n\n const delta = Math.abs(realContrast - ratio);\n if (realContrast < ratio && delta > 0.04) {\n return -1;\n }\n\n // Ensure gamut mapping, which requires a 'range' on tone, will still result\n // the correct ratio by darkening slightly.\n const returnValue = utils.lstarFromY(darkY) - 0.4;\n if (returnValue < 0 || returnValue > 100) {\n return -1;\n }\n return returnValue;\n }\n\n /**\n * Returns a tone >= tone parameter that ensures ratio parameter.\n * Return value is between 0 and 100.\n * Returns 100 if ratio cannot be achieved with tone parameter.\n *\n * This method is unsafe because the returned value is guaranteed to be in\n * bounds for tone, i.e. between 0 and 100. However, that value may not reach\n * the ratio with tone. For example, there is no color lighter than T100.\n *\n * @param tone Tone return value must contrast with.\n * Range is 0 to 100. Invalid values will result in 100 being returned.\n * @param ratio Desired contrast ratio of return value and tone parameter.\n * Range is 1 to 21, invalid values have undefined behavior.\n */\n static lighterUnsafe(tone: number, ratio: number): number {\n const lighterSafe = Contrast.lighter(tone, ratio);\n return (lighterSafe < 0.0) ? 100.0 : lighterSafe;\n }\n\n /**\n * Returns a tone >= tone parameter that ensures ratio parameter.\n * Return value is between 0 and 100.\n * Returns 100 if ratio cannot be achieved with tone parameter.\n *\n * This method is unsafe because the returned value is guaranteed to be in\n * bounds for tone, i.e. between 0 and 100. However, that value may not reach\n * the [ratio with [tone]. For example, there is no color darker than T0.\n *\n * @param tone Tone return value must contrast with.\n * Range is 0 to 100. Invalid values will result in 0 being returned.\n * @param ratio Desired contrast ratio of return value and tone parameter.\n * Range is 1 to 21, invalid values have undefined behavior.\n */\n static darkerUnsafe(tone: number, ratio: number): number {\n const darkerSafe = Contrast.darker(tone, ratio);\n return (darkerSafe < 0.0) ? 0.0 : darkerSafe;\n }\n}", "/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Hct} from '../hct/hct.js';\n\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable:class-as-namespace\n\n/**\n * Check and/or fix universally disliked colors.\n * Color science studies of color preference indicate universal distaste for\n * dark yellow-greens, and also show this is correlated to distate for\n * biological waste and rotting food.\n *\n * See Palmer and Schloss, 2010 or Schloss and Palmer's Chapter 21 in Handbook\n * of Color Psychology (2015).\n */\nexport class DislikeAnalyzer {\n /**\n * Returns true if a color is disliked.\n *\n * @param hct A color to be judged.\n * @return Whether the color is disliked.\n *\n * Disliked is defined as a dark yellow-green that is not neutral.\n */\n static isDisliked(hct: Hct): boolean {\n const huePasses =\n Math.round(hct.hue) >= 90.0 && Math.round(hct.hue) <= 111.0;\n const chromaPasses = Math.round(hct.chroma) > 16.0;\n const tonePasses = Math.round(hct.tone) < 65.0;\n\n return huePasses && chromaPasses && tonePasses;\n }\n\n /**\n * If a color is disliked, lighten it to make it likable.\n *\n * @param hct A color to be judged.\n * @return A new color if the original color is disliked, or the original\n * color if it is acceptable.\n */\n static fixIfDisliked(hct: Hct): Hct {\n if (DislikeAnalyzer.isDisliked(hct)) {\n return Hct.from(\n hct.hue,\n hct.chroma,\n 70.0,\n );\n }\n\n return hct;\n }\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Contrast} from '../contrast/contrast.js';\nimport {Hct} from '../hct/hct.js';\nimport {TonalPalette} from '../palettes/tonal_palette.js';\nimport * as math from '../utils/math_utils.js';\n\nimport {ContrastCurve} from './contrast_curve.js';\nimport {DynamicScheme} from './dynamic_scheme.js';\nimport {ToneDeltaPair} from './tone_delta_pair.js';\n\n/**\n * @param name The name of the dynamic color. Defaults to empty.\n * @param palette Function that provides a TonalPalette given\n * DynamicScheme. A TonalPalette is defined by a hue and chroma, so this\n * replaces the need to specify hue/chroma. By providing a tonal palette, when\n * contrast adjustments are made, intended chroma can be preserved.\n * @param tone Function that provides a tone given DynamicScheme.\n * @param isBackground Whether this dynamic color is a background, with\n * some other color as the foreground. Defaults to false.\n * @param background The background of the dynamic color (as a function of a\n * `DynamicScheme`), if it exists.\n * @param secondBackground A second background of the dynamic color (as a\n * function of a `DynamicScheme`), if it\n * exists.\n * @param contrastCurve A `ContrastCurve` object specifying how its contrast\n * against its background should behave in various contrast levels options.\n * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta\n * constraint between two colors. One of them must be the color being\n * constructed.\n */\ninterface FromPaletteOptions {\n name?: string;\n palette: (scheme: DynamicScheme) => TonalPalette;\n tone: (scheme: DynamicScheme) => number;\n isBackground?: boolean;\n background?: (scheme: DynamicScheme) => DynamicColor;\n secondBackground?: (scheme: DynamicScheme) => DynamicColor;\n contrastCurve?: ContrastCurve;\n toneDeltaPair?: (scheme: DynamicScheme) => ToneDeltaPair;\n}\n\n/**\n * A color that adjusts itself based on UI state provided by DynamicScheme.\n *\n * Colors without backgrounds do not change tone when contrast changes. Colors\n * with backgrounds become closer to their background as contrast lowers, and\n * further when contrast increases.\n *\n * Prefer static constructors. They require either a hexcode, a palette and\n * tone, or a hue and chroma. Optionally, they can provide a background\n * DynamicColor.\n */\nexport class DynamicColor {\n private readonly hctCache = new Map<DynamicScheme, Hct>();\n\n /**\n * Create a DynamicColor defined by a TonalPalette and HCT tone.\n *\n * @param args Functions with DynamicScheme as input. Must provide a palette\n * and tone. May provide a background DynamicColor and ToneDeltaConstraint.\n */\n static fromPalette(args: FromPaletteOptions): DynamicColor {\n return new DynamicColor(\n args.name ?? '',\n args.palette,\n args.tone,\n args.isBackground ?? false,\n args.background,\n args.secondBackground,\n args.contrastCurve,\n args.toneDeltaPair,\n );\n }\n\n /**\n * The base constructor for DynamicColor.\n *\n * _Strongly_ prefer using one of the convenience constructors. This class is\n * arguably too flexible to ensure it can support any scenario. Functional\n * arguments allow overriding without risks that come with subclasses.\n *\n * For example, the default behavior of adjust tone at max contrast\n * to be at a 7.0 ratio with its background is principled and\n * matches accessibility guidance. That does not mean it's the desired\n * approach for _every_ design system, and every color pairing,\n * always, in every case.\n *\n * @param name The name of the dynamic color. Defaults to empty.\n * @param palette Function that provides a TonalPalette given\n * DynamicScheme. A TonalPalette is defined by a hue and chroma, so this\n * replaces the need to specify hue/chroma. By providing a tonal palette, when\n * contrast adjustments are made, intended chroma can be preserved.\n * @param tone Function that provides a tone, given a DynamicScheme.\n * @param isBackground Whether this dynamic color is a background, with\n * some other color as the foreground. Defaults to false.\n * @param background The background of the dynamic color (as a function of a\n * `DynamicScheme`), if it exists.\n * @param secondBackground A second background of the dynamic color (as a\n * function of a `DynamicScheme`), if it\n * exists.\n * @param contrastCurve A `ContrastCurve` object specifying how its contrast\n * against its background should behave in various contrast levels options.\n * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta\n * constraint between two colors. One of them must be the color being\n * constructed.\n */\n constructor(\n readonly name: string,\n readonly palette: (scheme: DynamicScheme) => TonalPalette,\n readonly tone: (scheme: DynamicScheme) => number,\n readonly isBackground: boolean,\n readonly background?: (scheme: DynamicScheme) => DynamicColor,\n readonly secondBackground?: (scheme: DynamicScheme) => DynamicColor,\n readonly contrastCurve?: ContrastCurve,\n readonly toneDeltaPair?: (scheme: DynamicScheme) => ToneDeltaPair,\n ) {\n if ((!background) && secondBackground) {\n throw new Error(\n `Color ${name} has secondBackground` +\n `defined, but background is not defined.`);\n }\n if ((!background) && contrastCurve) {\n throw new Error(\n `Color ${name} has contrastCurve` +\n `defined, but background is not defined.`);\n }\n if (background && !contrastCurve) {\n throw new Error(\n `Color ${name} has background` +\n `defined, but contrastCurve is not defined.`);\n }\n }\n\n /**\n * Return a ARGB integer (i.e. a hex code).\n *\n * @param scheme Defines the conditions of the user interface, for example,\n * whether or not it is dark mode or light mode, and what the desired\n * contrast level is.\n */\n getArgb(scheme: DynamicScheme): number {\n return this.getHct(scheme).toInt();\n }\n\n /**\n * Return a color, expressed in the HCT color space, that this\n * DynamicColor is under the conditions in scheme.\n *\n * @param scheme Defines the conditions of the user interface, for example,\n * whether or not it is dark mode or light mode, and what the desired\n * contrast level is.\n */\n getHct(scheme: DynamicScheme): Hct {\n const cachedAnswer = this.hctCache.get(scheme);\n if (cachedAnswer != null) {\n return cachedAnswer;\n }\n const tone = this.getTone(scheme);\n const answer = this.palette(scheme).getHct(tone);\n if (this.hctCache.size > 4) {\n this.hctCache.clear();\n }\n this.hctCache.set(scheme, answer);\n return answer;\n }\n\n /**\n * Return a tone, T in the HCT color space, that this DynamicColor is under\n * the conditions in scheme.\n *\n * @param scheme Defines the conditions of the user interface, for example,\n * whether or not it is dark mode or light mode, and what the desired\n * contrast level is.\n */\n getTone(scheme: DynamicScheme): number {\n const decreasingContrast = scheme.contrastLevel < 0;\n\n // Case 1: dual foreground, pair of colors with delta constraint.\n if (this.toneDeltaPair) {\n const toneDeltaPair = this.toneDeltaPair(scheme);\n const roleA = toneDeltaPair.roleA;\n const roleB = toneDeltaPair.roleB;\n const delta = toneDeltaPair.delta;\n const polarity = toneDeltaPair.polarity;\n const stayTogether = toneDeltaPair.stayTogether;\n\n const bg = this.background!(scheme);\n const bgTone = bg.getTone(scheme);\n\n const aIsNearer =\n (polarity === 'nearer' ||\n (polarity === 'lighter' && !scheme.isDark) ||\n (polarity === 'darker' && scheme.isDark));\n const nearer = aIsNearer ? roleA : roleB;\n const farther = aIsNearer ? roleB : roleA;\n const amNearer = this.name === nearer.name;\n const expansionDir = scheme.isDark ? 1 : -1;\n\n // 1st round: solve to min, each\n const nContrast = nearer.contrastCurve!.get(scheme.contrastLevel);\n const fContrast = farther.contrastCurve!.get(scheme.contrastLevel);\n\n // If a color is good enough, it is not adjusted.\n // Initial and adjusted tones for `nearer`\n const nInitialTone = nearer.tone(scheme);\n let nTone = Contrast.ratioOfTones(bgTone, nInitialTone) >= nContrast ?\n nInitialTone :\n DynamicColor.foregroundTone(bgTone, nContrast);\n // Initial and adjusted tones for `farther`\n const fInitialTone = farther.tone(scheme);\n let fTone = Contrast.ratioOfTones(bgTone, fInitialTone) >= fContrast ?\n fInitialTone :\n DynamicColor.foregroundTone(bgTone, fContrast);\n\n if (decreasingContrast) {\n // If decreasing contrast, adjust color to the \"bare minimum\"\n // that satisfies contrast.\n nTone = DynamicColor.foregroundTone(bgTone, nContrast);\n fTone = DynamicColor.foregroundTone(bgTone, fContrast);\n }\n\n if ((fTone - nTone) * expansionDir >= delta) {\n // Good! Tones satisfy the constraint; no change needed.\n } else {\n // 2nd round: expand farther to match delta.\n fTone = math.clampDouble(0, 100, nTone + delta * expansionDir);\n if ((fTone - nTone) * expansionDir >= delta) {\n // Good! Tones now satisfy the constraint; no change needed.\n } else {\n // 3rd round: contract nearer to match delta.\n nTone = math.clampDouble(0, 100, fTone - delta * expansionDir);\n }\n }\n\n // Avoids the 50-59 awkward zone.\n if (50 <= nTone && nTone < 60) {\n // If `nearer` is in the awkward zone, move it away, together with\n // `farther`.\n if (expansionDir > 0) {\n nTone = 60;\n fTone = Math.max(fTone, nTone + delta * expansionDir);\n } else {\n nTone = 49;\n fTone = Math.min(fTone, nTone + delta * expansionDir);\n }\n } else if (50 <= fTone && fTone < 60) {\n if (stayTogether) {\n // Fixes both, to avoid two colors on opposite sides of the \"awkward\n // zone\".\n if (expansionDir > 0) {\n nTone = 60;\n fTone = Math.max(fTone, nTone + delta * expansionDir);\n } else {\n nTone = 49;\n fTone = Math.min(fTone, nTone + delta * expansionDir);\n }\n } else {\n // Not required to stay together; fixes just one.\n if (expansionDir > 0) {\n fTone = 60;\n } else {\n fTone = 49;\n }\n }\n }\n\n // Returns `nTone` if this color is `nearer`, otherwise `fTone`.\n return amNearer ? nTone : fTone;\n }\n\n else {\n // Case 2: No contrast pair; just solve for itself.\n let answer = this.tone(scheme);\n\n if (this.background == null) {\n return answer; // No adjustment for colors with no background.\n }\n\n const bgTone = this.background(scheme).getTone(scheme);\n\n const desiredRatio = this.contrastCurve!.get(scheme.contrastLevel);\n\n if (Contrast.ratioOfTones(bgTone, answer) >= desiredRatio) {\n // Don't \"improve\" what's good enough.\n } else {\n // Rough improvement.\n answer = DynamicColor.foregroundTone(bgTone, desiredRatio);\n }\n\n if (decreasingContrast) {\n answer = DynamicColor.foregroundTone(bgTone, desiredRatio);\n }\n\n if (this.isBackground && 50 <= answer && answer < 60) {\n // Must adjust\n if (Contrast.ratioOfTones(49, bgTone) >= desiredRatio) {\n answer = 49;\n } else {\n answer = 60;\n }\n }\n\n if (this.secondBackground) {\n // Case 3: Adjust for dual backgrounds.\n\n const [bg1, bg2] = [this.background, this.secondBackground];\n const [bgTone1, bgTone2] =\n [bg1(scheme).getTone(scheme), bg2(scheme).getTone(scheme)];\n const [upper, lower] =\n [Math.max(bgTone1, bgTone2), Math.min(bgTone1, bgTone2)];\n\n if (Contrast.ratioOfTones(upper, answer) >= desiredRatio &&\n Contrast.ratioOfTones(lower, answer) >= desiredRatio) {\n return answer;\n }\n\n // The darkest light tone that satisfies the desired ratio,\n // or -1 if such ratio cannot be reached.\n const lightOption = Contrast.lighter(upper, desiredRatio);\n\n // The lightest dark tone that satisfies the desired ratio,\n // or -1 if such ratio cannot be reached.\n const darkOption = Contrast.darker(lower, desiredRatio);\n\n // Tones suitable for the foreground.\n const availables = [];\n if (lightOption !== -1) availables.push(lightOption);\n if (darkOption !== -1) availables.push(darkOption);\n\n const prefersLight = DynamicColor.tonePrefersLightForeground(bgTone1) ||\n DynamicColor.tonePrefersLightForeground(bgTone2);\n if (prefersLight) {\n return (lightOption < 0) ? 100 : lightOption;\n }\n if (availables.length === 1) {\n return availables[0];\n }\n return (darkOption < 0) ? 0 : darkOption;\n }\n\n return answer;\n }\n }\n\n /**\n * Given a background tone, find a foreground tone, while ensuring they reach\n * a contrast ratio that is as close to [ratio] as possible.\n *\n * @param bgTone Tone in HCT. Range is 0 to 100, undefined behavior when it\n * falls outside that range.\n * @param ratio The contrast ratio desired between bgTone and the return\n * value.\n */\n static foregroundTone(bgTone: number, ratio: number): number {\n const lighterTone = Contrast.lighterUnsafe(bgTone, ratio);\n const darkerTone = Contrast.darkerUnsafe(bgTone, ratio);\n const lighterRatio = Contrast.ratioOfTones(lighterTone, bgTone);\n const darkerRatio = Contrast.ratioOfTones(darkerTone, bgTone);\n const preferLighter = DynamicColor.tonePrefersLightForeground(bgTone);\n\n if (preferLighter) {\n // This handles an edge case where the initial contrast ratio is high\n // (ex. 13.0), and the ratio passed to the function is that high\n // ratio, and both the lighter and darker ratio fails to pass that\n // ratio.\n //\n // This was observed with Tonal Spot's On Primary Container turning\n // black momentarily between high and max contrast in light mode. PC's\n // standard tone was T90, OPC's was T10, it was light mode, and the\n // contrast value was 0.6568521221032331.\n const negligibleDifference = Math.abs(lighterRatio - darkerRatio) < 0.1 &&\n lighterRatio < ratio && darkerRatio < ratio;\n return lighterRatio >= ratio || lighterRatio >= darkerRatio ||\n negligibleDifference ?\n lighterTone :\n darkerTone;\n } else {\n return darkerRatio >= ratio || darkerRatio >= lighterRatio ? darkerTone :\n lighterTone;\n }\n }\n\n /**\n * Returns whether [tone] prefers a light foreground.\n *\n * People prefer white foregrounds on ~T60-70. Observed over time, and also\n * by Andrew Somers during research for APCA.\n *\n * T60 used as to create the smallest discontinuity possible when skipping\n * down to T49 in order to ensure light foregrounds.\n * Since `tertiaryContainer` in dark monochrome scheme requires a tone of\n * 60, it should not be adjusted. Therefore, 60 is excluded here.\n */\n static tonePrefersLightForeground(tone: number): boolean {\n return Math.round(tone) < 60.0;\n }\n\n /**\n * Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter\n * color.\n */\n static toneAllowsLightForeground(tone: number): boolean {\n return Math.round(tone) <= 49.0;\n }\n\n /**\n * Adjust a tone such that white has 4.5 contrast, if the tone is\n * reasonably close to supporting it.\n */\n static enableLightForeground(tone: number): number {\n if (DynamicColor.tonePrefersLightForeground(tone) &&\n !DynamicColor.toneAllowsLightForeground(tone)) {\n return 49.0;\n }\n return tone;\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Hct} from '../hct/hct.js';\n\n/**\n * A convenience class for retrieving colors that are constant in hue and\n * chroma, but vary in tone.\n */\nexport class TonalPalette {\n private readonly cache = new Map<number, number>();\n\n /**\n * @param argb ARGB representation of a color\n * @return Tones matching that color's hue and chroma.\n */\n static fromInt(argb: number): TonalPalette {\n const hct = Hct.fromInt(argb);\n return TonalPalette.fromHct(hct);\n }\n\n /**\n * @param hct Hct\n * @return Tones matching that color's hue and chroma.\n */\n static fromHct(hct: Hct) {\n return new TonalPalette(hct.hue, hct.chroma, hct);\n }\n\n /**\n * @param hue HCT hue\n * @param chroma HCT chroma\n * @return Tones matching hue and chroma.\n */\n static fromHueAndChroma(hue: number, chroma: number): TonalPalette {\n const keyColor = new KeyColor(hue, chroma).create();\n return new TonalPalette(hue, chroma, keyColor);\n }\n\n private constructor(readonly hue: number, readonly chroma: number, readonly keyColor: Hct) {}\n\n /**\n * @param tone HCT tone, measured from 0 to 100.\n * @return ARGB representation of a color with that tone.\n */\n tone(tone: number): number {\n let argb = this.cache.get(tone);\n if (argb === undefined) {\n argb = Hct.from(this.hue, this.chroma, tone).toInt();\n this.cache.set(tone, argb);\n }\n return argb;\n }\n\n /**\n * @param tone HCT tone.\n * @return HCT representation of a color with that tone.\n */\n getHct(tone: number): Hct {\n return Hct.fromInt(this.tone(tone));\n }\n}\n\n/**\n * Key color is a color that represents the hue and chroma of a tonal palette\n */\nclass KeyColor {\n // Cache that maps tone to max chroma to avoid duplicated HCT calculation.\n private readonly chromaCache = new Map<number, number>();\n private readonly maxChromaValue = 200.0;\n\n constructor(readonly hue: number, readonly requestedChroma: number) {}\n\n /**\n * Creates a key color from a [hue] and a [chroma].\n * The key color is the first tone, starting from T50, matching the given hue\n * and chroma.\n *\n * @return Key color [Hct]\n */\n create(): Hct {\n // Pivot around T50 because T50 has the most chroma available, on\n // average. Thus it is most likely to have a direct answer.\n const pivotTone = 50;\n const toneStepSize = 1;\n // Epsilon to accept values slightly higher than the requested chroma.\n const epsilon = 0.01;\n\n // Binary search to find the tone that can provide a chroma that is closest\n // to the requested chroma.\n let lowerTone = 0;\n let upperTone = 100;\n while (lowerTone < upperTone) {\n const midTone = Math.floor((lowerTone + upperTone) / 2);\n const isAscending =\n this.maxChroma(midTone) < this.maxChroma(midTone + toneStepSize);\n const sufficientChroma =\n this.maxChroma(midTone) >= this.requestedChroma - epsilon;\n\n if (sufficientChroma) {\n // Either range [lowerTone, midTone] or [midTone, upperTone] has\n // the answer, so search in the range that is closer the pivot tone.\n if (Math.abs(lowerTone - pivotTone) < Math.abs(upperTone - pivotTone)) {\n upperTone = midTone;\n } else {\n if (lowerTone === midTone) {\n return Hct.from(this.hue, this.requestedChroma, lowerTone);\n }\n lowerTone = midTone;\n }\n } else {\n // As there is no sufficient chroma in the midTone, follow the direction\n // to the chroma peak.\n if (isAscending) {\n lowerTone = midTone + toneStepSize;\n } else {\n // Keep midTone for potential chroma peak.\n upperTone = midTone;\n }\n }\n }\n\n return Hct.from(this.hue, this.requestedChroma, lowerTone);\n }\n\n // Find the maximum chroma for a given tone\n private maxChroma(tone: number): number {\n if (this.chromaCache.has(tone)) {\n return this.chromaCache.get(tone)!;\n }\n const chroma = Hct.from(this.hue, this.maxChromaValue, tone).chroma;\n this.chromaCache.set(tone, chroma);\n return chroma;\n }\n}\n", "/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as math from '../utils/math_utils.js';\n\n/**\n * A class containing a value that changes with the contrast level.\n *\n * Usually represents the contrast requirements for a dynamic color on its\n * background. The four values correspond to values for contrast levels -1.0,\n * 0.0, 0.5, and 1.0, respectively.\n */\nexport class ContrastCurve {\n /**\n * Creates a `ContrastCurve` object.\n *\n * @param low Value for contrast level -1.0\n * @param normal Value for contrast level 0.0\n * @param medium Value for contrast level 0.5\n * @param high Value for contrast level 1.0\n */\n constructor(\n readonly low: number,\n readonly normal: number,\n readonly medium: number,\n readonly high: number,\n ) {}\n\n /**\n * Returns the value at a given contrast level.\n *\n * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0\n * is the lowest; 1.0 is the highest.\n * @return The value. For contrast ratios, a number between 1.0 and 21.0.\n */\n get(contrastLevel: number): number {\n if (contrastLevel <= -1.0) {\n return this.low;\n } else if (contrastLevel < 0.0) {\n return math.lerp(this.low, this.normal, (contrastLevel - (-1)) / 1);\n } else if (contrastLevel < 0.5) {\n return math.lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5);\n } else if (contrastLevel < 1.0) {\n return math.lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5);\n } else {\n return this.high;\n }\n }\n}\n", "/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {DynamicColor} from './dynamic_color.js';\n\n/**\n * Describes the different in tone between colors.\n */\nexport type TonePolarity = 'darker'|'lighter'|'nearer'|'farther';\n\n/**\n * Documents a constraint between two DynamicColors, in which their tones must\n * have a certain distance from each other.\n *\n * Prefer a DynamicColor with a background, this is for special cases when\n * designers want tonal distance, literally contrast, between two colors that\n * don't have a background / foreground relationship or a contrast guarantee.\n */\nexport class ToneDeltaPair {\n /**\n * Documents a constraint in tone distance between two DynamicColors.\n *\n * The polarity is an adjective that describes \"A\", compared to \"B\".\n *\n * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that\n * A's tone should be at least 15 darker than B's.\n *\n * 'nearer' and 'farther' describes closeness to the surface roles. For\n * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A\n * should be 10 lighter than B in light mode, and 10 darker than B in dark\n * mode.\n *\n * @param roleA The first role in a pair.\n * @param roleB The second role in a pair.\n * @param delta Required difference between tones. Absolute value, negative\n * values have undefined behavior.\n * @param polarity The relative relation between tones of roleA and roleB,\n * as described above.\n * @param stayTogether Whether these two roles should stay on the same side of\n * the \"awkward zone\" (T50-59). This is necessary for certain cases where\n * one role has two backgrounds.\n */\n constructor(\n readonly roleA: DynamicColor,\n readonly roleB: DynamicColor,\n readonly delta: number,\n readonly polarity: TonePolarity,\n readonly stayTogether: boolean,\n ) {}\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Set of themes supported by Dynamic Color.\n * Instantiate the corresponding subclass, ex. SchemeTonalSpot, to create\n * colors corresponding to the theme.\n */\nexport enum Variant {\n MONOCHROME,\n NEUTRAL,\n TONAL_SPOT,\n VIBRANT,\n EXPRESSIVE,\n FIDELITY,\n CONTENT,\n RAINBOW,\n FRUIT_SALAD\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {DislikeAnalyzer} from '../dislike/dislike_analyzer.js';\nimport {Hct} from '../hct/hct.js';\n\nimport {ContrastCurve} from './contrast_curve.js';\nimport {DynamicColor} from './dynamic_color.js';\nimport {DynamicScheme} from './dynamic_scheme.js';\nimport {ToneDeltaPair} from './tone_delta_pair.js';\nimport {Variant} from './variant.js';\n\nfunction isFidelity(scheme: DynamicScheme): boolean {\n return scheme.variant === Variant.FIDELITY ||\n scheme.variant === Variant.CONTENT;\n}\n\nfunction isMonochrome(scheme: DynamicScheme): boolean {\n return scheme.variant === Variant.MONOCHROME;\n}\n\nfunction findDesiredChromaByTone(\n hue: number, chroma: number, tone: number,\n byDecreasingTone: boolean): number {\n let answer = tone;\n\n let closestToChroma = Hct.from(hue, chroma, tone);\n if (closestToChroma.chroma < chroma) {\n let chromaPeak = closestToChroma.chroma;\n while (closestToChroma.chroma < chroma) {\n answer += byDecreasingTone ? -1.0 : 1.0;\n const potentialSolution = Hct.from(hue, chroma, answer);\n if (chromaPeak > potentialSolution.chroma) {\n break;\n }\n if (Math.abs(potentialSolution.chroma - chroma) < 0.4) {\n break;\n }\n\n const potentialDelta = Math.abs(potentialSolution.chroma - chroma);\n const currentDelta = Math.abs(closestToChroma.chroma - chroma);\n if (potentialDelta < currentDelta) {\n closestToChroma = potentialSolution;\n }\n chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);\n }\n }\n\n return answer;\n}\n\n/**\n * DynamicColors for the colors in the Material Design system.\n */\n// Material Color Utilities namespaces the various utilities it provides.\n// tslint:disable-next-line:class-as-namespace\nexport class MaterialDynamicColors {\n static contentAccentToneDelta = 15.0;\n static highestSurface(s: DynamicScheme): DynamicColor {\n return s.isDark ? MaterialDynamicColors.surfaceBright :\n MaterialDynamicColors.surfaceDim;\n }\n\n static primaryPaletteKeyColor = DynamicColor.fromPalette({\n name: 'primary_palette_key_color',\n palette: (s) => s.primaryPalette,\n tone: (s) => s.primaryPalette.keyColor.tone,\n });\n\n static secondaryPaletteKeyColor = DynamicColor.fromPalette({\n name: 'secondary_palette_key_color',\n palette: (s) => s.secondaryPalette,\n tone: (s) => s.secondaryPalette.keyColor.tone,\n });\n\n static tertiaryPaletteKeyColor = DynamicColor.fromPalette({\n name: 'tertiary_palette_key_color',\n palette: (s) => s.tertiaryPalette,\n tone: (s) => s.tertiaryPalette.keyColor.tone,\n });\n\n static neutralPaletteKeyColor = DynamicColor.fromPalette({\n name: 'neutral_palette_key_color',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.neutralPalette.keyColor.tone,\n });\n\n static neutralVariantPaletteKeyColor = DynamicColor.fromPalette({\n name: 'neutral_variant_palette_key_color',\n palette: (s) => s.neutralVariantPalette,\n tone: (s) => s.neutralVariantPalette.keyColor.tone,\n });\n\n static background = DynamicColor.fromPalette({\n name: 'background',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 6 : 98,\n isBackground: true,\n });\n\n static onBackground = DynamicColor.fromPalette({\n name: 'on_background',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 90 : 10,\n background: (s) => MaterialDynamicColors.background,\n contrastCurve: new ContrastCurve(3, 3, 4.5, 7),\n });\n\n static surface = DynamicColor.fromPalette({\n name: 'surface',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 6 : 98,\n isBackground: true,\n });\n\n static surfaceDim = DynamicColor.fromPalette({\n name: 'surface_dim',\n palette: (s) => s.neutralPalette,\n tone: (s) =>\n s.isDark ? 6 : new ContrastCurve(87, 87, 80, 75).get(s.contrastLevel),\n isBackground: true,\n });\n\n static surfaceBright = DynamicColor.fromPalette({\n name: 'surface_bright',\n palette: (s) => s.neutralPalette,\n tone: (s) =>\n s.isDark ? new ContrastCurve(24, 24, 29, 34).get(s.contrastLevel) : 98,\n isBackground: true,\n });\n\n static surfaceContainerLowest = DynamicColor.fromPalette({\n name: 'surface_container_lowest',\n palette: (s) => s.neutralPalette,\n tone: (s) =>\n s.isDark ? new ContrastCurve(4, 4, 2, 0).get(s.contrastLevel) : 100,\n isBackground: true,\n });\n\n static surfaceContainerLow = DynamicColor.fromPalette({\n name: 'surface_container_low',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ?\n new ContrastCurve(10, 10, 11, 12).get(s.contrastLevel) :\n new ContrastCurve(96, 96, 96, 95).get(s.contrastLevel),\n isBackground: true,\n });\n\n static surfaceContainer = DynamicColor.fromPalette({\n name: 'surface_container',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ?\n new ContrastCurve(12, 12, 16, 20).get(s.contrastLevel) :\n new ContrastCurve(94, 94, 92, 90).get(s.contrastLevel),\n isBackground: true,\n });\n\n static surfaceContainerHigh = DynamicColor.fromPalette({\n name: 'surface_container_high',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ?\n new ContrastCurve(17, 17, 21, 25).get(s.contrastLevel) :\n new ContrastCurve(92, 92, 88, 85).get(s.contrastLevel),\n isBackground: true,\n });\n\n static surfaceContainerHighest = DynamicColor.fromPalette({\n name: 'surface_container_highest',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ?\n new ContrastCurve(22, 22, 26, 30).get(s.contrastLevel) :\n new ContrastCurve(90, 90, 84, 80).get(s.contrastLevel),\n isBackground: true,\n });\n\n static onSurface = DynamicColor.fromPalette({\n name: 'on_surface',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 90 : 10,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static surfaceVariant = DynamicColor.fromPalette({\n name: 'surface_variant',\n palette: (s) => s.neutralVariantPalette,\n tone: (s) => s.isDark ? 30 : 90,\n isBackground: true,\n });\n\n static onSurfaceVariant = DynamicColor.fromPalette({\n name: 'on_surface_variant',\n palette: (s) => s.neutralVariantPalette,\n tone: (s) => s.isDark ? 80 : 30,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static inverseSurface = DynamicColor.fromPalette({\n name: 'inverse_surface',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 90 : 20,\n });\n\n static inverseOnSurface = DynamicColor.fromPalette({\n name: 'inverse_on_surface',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 20 : 95,\n background: (s) => MaterialDynamicColors.inverseSurface,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static outline = DynamicColor.fromPalette({\n name: 'outline',\n palette: (s) => s.neutralVariantPalette,\n tone: (s) => s.isDark ? 60 : 50,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7),\n });\n\n static outlineVariant = DynamicColor.fromPalette({\n name: 'outline_variant',\n palette: (s) => s.neutralVariantPalette,\n tone: (s) => s.isDark ? 30 : 80,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n });\n\n static shadow = DynamicColor.fromPalette({\n name: 'shadow',\n palette: (s) => s.neutralPalette,\n tone: (s) => 0,\n });\n\n static scrim = DynamicColor.fromPalette({\n name: 'scrim',\n palette: (s) => s.neutralPalette,\n tone: (s) => 0,\n });\n\n static surfaceTint = DynamicColor.fromPalette({\n name: 'surface_tint',\n palette: (s) => s.primaryPalette,\n tone: (s) => s.isDark ? 80 : 40,\n isBackground: true,\n });\n\n static primary = DynamicColor.fromPalette({\n name: 'primary',\n palette: (s) => s.primaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 100 : 0;\n }\n return s.isDark ? 80 : 40;\n },\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(3, 4.5, 7, 7),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary,\n 10, 'nearer', false),\n });\n\n static onPrimary = DynamicColor.fromPalette({\n name: 'on_primary',\n palette: (s) => s.primaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 10 : 90;\n }\n return s.isDark ? 20 : 100;\n },\n background: (s) => MaterialDynamicColors.primary,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static primaryContainer = DynamicColor.fromPalette({\n name: 'primary_container',\n palette: (s) => s.primaryPalette,\n tone:\n (s) => {\n if (isFidelity(s)) {\n return s.sourceColorHct.tone;\n }\n if (isMonochrome(s)) {\n return s.isDark ? 85 : 25;\n }\n return s.isDark ? 30 : 90;\n },\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary,\n 10, 'nearer', false),\n });\n\n static onPrimaryContainer = DynamicColor.fromPalette({\n name: 'on_primary_container',\n palette: (s) => s.primaryPalette,\n tone:\n (s) => {\n if (isFidelity(s)) {\n return DynamicColor.foregroundTone(\n MaterialDynamicColors.primaryContainer.tone(s), 4.5);\n }\n if (isMonochrome(s)) {\n return s.isDark ? 0 : 100;\n }\n return s.isDark ? 90 : 30;\n },\n background: (s) => MaterialDynamicColors.primaryContainer,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static inversePrimary = DynamicColor.fromPalette({\n name: 'inverse_primary',\n palette: (s) => s.primaryPalette,\n tone: (s) => s.isDark ? 40 : 80,\n background: (s) => MaterialDynamicColors.inverseSurface,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 7),\n });\n\n static secondary = DynamicColor.fromPalette({\n name: 'secondary',\n palette: (s) => s.secondaryPalette,\n tone: (s) => s.isDark ? 80 : 40,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(3, 4.5, 7, 7),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.secondaryContainer,\n MaterialDynamicColors.secondary, 10, 'nearer', false),\n });\n\n static onSecondary = DynamicColor.fromPalette({\n name: 'on_secondary',\n palette: (s) => s.secondaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 10 : 100;\n } else {\n return s.isDark ? 20 : 100;\n }\n },\n background: (s) => MaterialDynamicColors.secondary,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static secondaryContainer = DynamicColor.fromPalette({\n name: 'secondary_container',\n palette: (s) => s.secondaryPalette,\n tone:\n (s) => {\n const initialTone = s.isDark ? 30 : 90;\n if (isMonochrome(s)) {\n return s.isDark ? 30 : 85;\n }\n if (!isFidelity(s)) {\n return initialTone;\n }\n return findDesiredChromaByTone(\n s.secondaryPalette.hue, s.secondaryPalette.chroma, initialTone,\n s.isDark ? false : true);\n },\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.secondaryContainer,\n MaterialDynamicColors.secondary, 10, 'nearer', false),\n });\n\n static onSecondaryContainer = DynamicColor.fromPalette({\n name: 'on_secondary_container',\n palette: (s) => s.secondaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 90 : 10;\n }\n if (!isFidelity(s)) {\n return s.isDark ? 90 : 30;\n }\n return DynamicColor.foregroundTone(\n MaterialDynamicColors.secondaryContainer.tone(s), 4.5);\n },\n background: (s) => MaterialDynamicColors.secondaryContainer,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static tertiary = DynamicColor.fromPalette({\n name: 'tertiary',\n palette: (s) => s.tertiaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 90 : 25;\n }\n return s.isDark ? 80 : 40;\n },\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(3, 4.5, 7, 7),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary,\n 10, 'nearer', false),\n });\n\n static onTertiary = DynamicColor.fromPalette({\n name: 'on_tertiary',\n palette: (s) => s.tertiaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 10 : 90;\n }\n return s.isDark ? 20 : 100;\n },\n background: (s) => MaterialDynamicColors.tertiary,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static tertiaryContainer = DynamicColor.fromPalette({\n name: 'tertiary_container',\n palette: (s) => s.tertiaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 60 : 49;\n }\n if (!isFidelity(s)) {\n return s.isDark ? 30 : 90;\n }\n const proposedHct = s.tertiaryPalette.getHct(s.sourceColorHct.tone);\n return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;\n },\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary,\n 10, 'nearer', false),\n });\n\n static onTertiaryContainer = DynamicColor.fromPalette({\n name: 'on_tertiary_container',\n palette: (s) => s.tertiaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 0 : 100;\n }\n if (!isFidelity(s)) {\n return s.isDark ? 90 : 30;\n }\n return DynamicColor.foregroundTone(\n MaterialDynamicColors.tertiaryContainer.tone(s), 4.5);\n },\n background: (s) => MaterialDynamicColors.tertiaryContainer,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static error = DynamicColor.fromPalette({\n name: 'error',\n palette: (s) => s.errorPalette,\n tone: (s) => s.isDark ? 80 : 40,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(3, 4.5, 7, 7),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 10,\n 'nearer', false),\n });\n\n static onError = DynamicColor.fromPalette({\n name: 'on_error',\n palette: (s) => s.errorPalette,\n tone: (s) => s.isDark ? 20 : 100,\n background: (s) => MaterialDynamicColors.error,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static errorContainer = DynamicColor.fromPalette({\n name: 'error_container',\n palette: (s) => s.errorPalette,\n tone: (s) => s.isDark ? 30 : 90,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 10,\n 'nearer', false),\n });\n\n static onErrorContainer = DynamicColor.fromPalette({\n name: 'on_error_container',\n palette: (s) => s.errorPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 90 : 10;\n }\n return s.isDark ? 90 : 30;\n },\n background: (s) => MaterialDynamicColors.errorContainer,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static primaryFixed = DynamicColor.fromPalette({\n name: 'primary_fixed',\n palette: (s) => s.primaryPalette,\n tone: (s) => isMonochrome(s) ? 40.0 : 90.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.primaryFixed,\n MaterialDynamicColors.primaryFixedDim, 10, 'lighter', true),\n });\n\n static primaryFixedDim = DynamicColor.fromPalette({\n name: 'primary_fixed_dim',\n palette: (s) => s.primaryPalette,\n tone: (s) => isMonochrome(s) ? 30.0 : 80.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.primaryFixed,\n MaterialDynamicColors.primaryFixedDim, 10, 'lighter', true),\n });\n\n static onPrimaryFixed = DynamicColor.fromPalette({\n name: 'on_primary_fixed',\n palette: (s) => s.primaryPalette,\n tone: (s) => isMonochrome(s) ? 100.0 : 10.0,\n background: (s) => MaterialDynamicColors.primaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.primaryFixed,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static onPrimaryFixedVariant = DynamicColor.fromPalette({\n name: 'on_primary_fixed_variant',\n palette: (s) => s.primaryPalette,\n tone: (s) => isMonochrome(s) ? 90.0 : 30.0,\n background: (s) => MaterialDynamicColors.primaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.primaryFixed,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static secondaryFixed = DynamicColor.fromPalette({\n name: 'secondary_fixed',\n palette: (s) => s.secondaryPalette,\n tone: (s) => isMonochrome(s) ? 80.0 : 90.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.secondaryFixed,\n MaterialDynamicColors.secondaryFixedDim, 10, 'lighter', true),\n });\n\n static secondaryFixedDim = DynamicColor.fromPalette({\n name: 'secondary_fixed_dim',\n palette: (s) => s.secondaryPalette,\n tone: (s) => isMonochrome(s) ? 70.0 : 80.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.secondaryFixed,\n MaterialDynamicColors.secondaryFixedDim, 10, 'lighter', true),\n });\n\n static onSecondaryFixed = DynamicColor.fromPalette({\n name: 'on_secondary_fixed',\n palette: (s) => s.secondaryPalette,\n tone: (s) => 10.0,\n background: (s) => MaterialDynamicColors.secondaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.secondaryFixed,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static onSecondaryFixedVariant = DynamicColor.fromPalette({\n name: 'on_secondary_fixed_variant',\n palette: (s) => s.secondaryPalette,\n tone: (s) => isMonochrome(s) ? 25.0 : 30.0,\n background: (s) => MaterialDynamicColors.secondaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.secondaryFixed,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static tertiaryFixed = DynamicColor.fromPalette({\n name: 'tertiary_fixed',\n palette: (s) => s.tertiaryPalette,\n tone: (s) => isMonochrome(s) ? 40.0 : 90.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.tertiaryFixed,\n MaterialDynamicColors.tertiaryFixedDim, 10, 'lighter', true),\n });\n\n static tertiaryFixedDim = DynamicColor.fromPalette({\n name: 'tertiary_fixed_dim',\n palette: (s) => s.tertiaryPalette,\n tone: (s) => isMonochrome(s) ? 30.0 : 80.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.tertiaryFixed,\n MaterialDynamicColors.tertiaryFixedDim, 10, 'lighter', true),\n });\n\n static onTertiaryFixed = DynamicColor.fromPalette({\n name: 'on_tertiary_fixed',\n palette: (s) => s.tertiaryPalette,\n tone: (s) => isMonochrome(s) ? 100.0 : 10.0,\n background: (s) => MaterialDynamicColors.tertiaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.tertiaryFixed,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static onTertiaryFixedVariant = DynamicColor.fromPalette({\n name: 'on_tertiary_fixed_variant',\n palette: (s) => s.tertiaryPalette,\n tone: (s) => isMonochrome(s) ? 90.0 : 30.0,\n background: (s) => MaterialDynamicColors.tertiaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.tertiaryFixed,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Hct} from '../hct/hct.js';\nimport {TonalPalette} from '../palettes/tonal_palette.js';\nimport * as math from '../utils/math_utils.js';\n\nimport {DynamicColor} from './dynamic_color.js';\nimport {MaterialDynamicColors} from './material_dynamic_colors.js';\nimport {Variant} from './variant.js';\n\n/**\n * @param sourceColorArgb The source color of the theme as an ARGB 32-bit\n * integer.\n * @param variant The variant, or style, of the theme.\n * @param contrastLevel Value from -1 to 1. -1 represents minimum contrast,\n * 0 represents standard (i.e. the design as spec'd), and 1 represents maximum\n * contrast.\n * @param isDark Whether the scheme is in dark mode or light mode.\n * @param primaryPalette Given a tone, produces a color. Hue and chroma of the\n * color are specified in the design specification of the variant. Usually\n * colorful.\n * @param secondaryPalette Given a tone, produces a color. Hue and chroma of\n * the color are specified in the design specification of the variant. Usually\n * less colorful.\n * @param tertiaryPalette Given a tone, produces a color. Hue and chroma of\n * the color are specified in the design specification of the variant. Usually\n * a different hue from primary and colorful.\n * @param neutralPalette Given a tone, produces a color. Hue and chroma of the\n * color are specified in the design specification of the variant. Usually not\n * colorful at all, intended for background & surface colors.\n * @param neutralVariantPalette Given a tone, produces a color. Hue and chroma\n * of the color are specified in the design specification of the variant.\n * Usually not colorful, but slightly more colorful than Neutral. Intended for\n * backgrounds & surfaces.\n */\ninterface DynamicSchemeOptions {\n sourceColorArgb: number;\n variant: Variant;\n contrastLevel: number;\n isDark: boolean;\n primaryPalette: TonalPalette;\n secondaryPalette: TonalPalette;\n tertiaryPalette: TonalPalette;\n neutralPalette: TonalPalette;\n neutralVariantPalette: TonalPalette;\n}\n\n/**\n * Constructed by a set of values representing the current UI state (such as\n * whether or not its dark theme, what the theme style is, etc.), and\n * provides a set of TonalPalettes that can create colors that fit in\n * with the theme style. Used by DynamicColor to resolve into a color.\n */\nexport class DynamicScheme {\n /**\n * The source color of the theme as an HCT color.\n */\n sourceColorHct: Hct;\n /**\n * Given a tone, produces a reddish, colorful, color.\n */\n errorPalette: TonalPalette;\n\n /** The source color of the theme as an ARGB 32-bit integer. */\n readonly sourceColorArgb: number;\n\n /** The variant, or style, of the theme. */\n readonly variant: Variant;\n\n /**\n * Value from -1 to 1. -1 represents minimum contrast. 0 represents standard\n * (i.e. the design as spec'd), and 1 represents maximum contrast.\n */\n readonly contrastLevel: number;\n\n /** Whether the scheme is in dark mode or light mode. */\n readonly isDark: boolean;\n\n /**\n * Given a tone, produces a color. Hue and chroma of the\n * color are specified in the design specification of the variant. Usually\n * colorful.\n */\n readonly primaryPalette: TonalPalette;\n\n /**\n * Given a tone, produces a color. Hue and chroma of\n * the color are specified in the design specification of the variant. Usually\n * less colorful.\n */\n readonly secondaryPalette: TonalPalette;\n\n /**\n * Given a tone, produces a color. Hue and chroma of\n * the color are specified in the design specification of the variant. Usually\n * a different hue from primary and colorful.\n */\n readonly tertiaryPalette: TonalPalette;\n\n /**\n * Given a tone, produces a color. Hue and chroma of the\n * color are specified in the design specification of the variant. Usually not\n * colorful at all, intended for background & surface colors.\n */\n readonly neutralPalette: TonalPalette;\n\n /**\n * Given a tone, produces a color. Hue and chroma\n * of the color are specified in the design specification of the variant.\n * Usually not colorful, but slightly more colorful than Neutral. Intended for\n * backgrounds & surfaces.\n */\n readonly neutralVariantPalette: TonalPalette;\n\n constructor(args: DynamicSchemeOptions) {\n this.sourceColorArgb = args.sourceColorArgb;\n this.variant = args.variant;\n this.contrastLevel = args.contrastLevel;\n this.isDark = args.isDark;\n this.sourceColorHct = Hct.fromInt(args.sourceColorArgb);\n this.primaryPalette = args.primaryPalette;\n this.secondaryPalette = args.secondaryPalette;\n this.tertiaryPalette = args.tertiaryPalette;\n this.neutralPalette = args.neutralPalette;\n this.neutralVariantPalette = args.neutralVariantPalette;\n this.errorPalette = TonalPalette.fromHueAndChroma(25.0, 84.0);\n }\n\n /**\n * Support design spec'ing Dynamic Color by schemes that specify hue\n * rotations that should be applied at certain breakpoints.\n * @param sourceColor the source color of the theme, in HCT.\n * @param hues The \"breakpoints\", i.e. the hues at which a rotation should\n * be apply.\n * @param rotations The rotation that should be applied when source color's\n * hue is >= the same index in hues array, and <= the hue at the next index\n * in hues array.\n */\n static getRotatedHue(sourceColor: Hct, hues: number[], rotations: number[]):\n number {\n const sourceHue = sourceColor.hue;\n if (hues.length !== rotations.length) {\n throw new Error(`mismatch between hue length ${hues.length} & rotations ${\n rotations.length}`);\n }\n if (rotations.length === 1) {\n return math.sanitizeDegreesDouble(sourceColor.hue + rotations[0]);\n }\n const size = hues.length;\n for (let i = 0; i <= size - 2; i++) {\n const thisHue = hues[i];\n const nextHue = hues[i + 1];\n if (thisHue < sourceHue && sourceHue < nextHue) {\n return math.sanitizeDegreesDouble(sourceHue + rotations[i]);\n }\n }\n // If this statement executes, something is wrong, there should have been a\n // rotation found using the arrays.\n return sourceHue;\n }\n\n\n getArgb(dynamicColor: DynamicColor): number {\n return dynamicColor.getArgb(this);\n }\n\n getHct(dynamicColor: DynamicColor): Hct {\n return dynamicColor.getHct(this);\n }\n\n get primaryPaletteKeyColor(): number {\n return this.getArgb(MaterialDynamicColors.primaryPaletteKeyColor);\n }\n\n get secondaryPaletteKeyColor(): number {\n return this.getArgb(MaterialDynamicColors.secondaryPaletteKeyColor);\n }\n\n get tertiaryPaletteKeyColor(): number {\n return this.getArgb(MaterialDynamicColors.tertiaryPaletteKeyColor);\n }\n\n get neutralPaletteKeyColor(): number {\n return this.getArgb(MaterialDynamicColors.neutralPaletteKeyColor);\n }\n\n get neutralVariantPaletteKeyColor(): number {\n return this.getArgb(MaterialDynamicColors.neutralVariantPaletteKeyColor);\n }\n\n get background(): number {\n return this.getArgb(MaterialDynamicColors.background);\n }\n\n get onBackground(): number {\n return this.getArgb(MaterialDynamicColors.onBackground);\n }\n\n get surface(): number {\n return this.getArgb(MaterialDynamicColors.surface);\n }\n\n get surfaceDim(): number {\n return this.getArgb(MaterialDynamicColors.surfaceDim);\n }\n\n get surfaceBright(): number {\n return this.getArgb(MaterialDynamicColors.surfaceBright);\n }\n\n get surfaceContainerLowest(): number {\n return this.getArgb(MaterialDynamicColors.surfaceContainerLowest);\n }\n\n get surfaceContainerLow(): number {\n return this.getArgb(MaterialDynamicColors.surfaceContainerLow);\n }\n\n get surfaceContainer(): number {\n return this.getArgb(MaterialDynamicColors.surfaceContainer);\n }\n\n get surfaceContainerHigh(): number {\n return this.getArgb(MaterialDynamicColors.surfaceContainerHigh);\n }\n\n get surfaceContainerHighest(): number {\n return this.getArgb(MaterialDynamicColors.surfaceContainerHighest);\n }\n\n get onSurface(): number {\n return this.getArgb(MaterialDynamicColors.onSurface);\n }\n\n get surfaceVariant(): number {\n return this.getArgb(MaterialDynamicColors.surfaceVariant);\n }\n\n get onSurfaceVariant(): number {\n return this.getArgb(MaterialDynamicColors.onSurfaceVariant);\n }\n\n get inverseSurface(): number {\n return this.getArgb(MaterialDynamicColors.inverseSurface);\n }\n\n get inverseOnSurface(): number {\n return this.getArgb(MaterialDynamicColors.inverseOnSurface);\n }\n\n get outline(): number {\n return this.getArgb(MaterialDynamicColors.outline);\n }\n\n get outlineVariant(): number {\n return this.getArgb(MaterialDynamicColors.outlineVariant);\n }\n\n get shadow(): number {\n return this.getArgb(MaterialDynamicColors.shadow);\n }\n\n get scrim(): number {\n return this.getArgb(MaterialDynamicColors.scrim);\n }\n\n get surfaceTint(): number {\n return this.getArgb(MaterialDynamicColors.surfaceTint);\n }\n\n get primary(): number {\n return this.getArgb(MaterialDynamicColors.primary);\n }\n\n get onPrimary(): number {\n return this.getArgb(MaterialDynamicColors.onPrimary);\n }\n\n get primaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.primaryContainer);\n }\n\n get onPrimaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.onPrimaryContainer);\n }\n\n get inversePrimary(): number {\n return this.getArgb(MaterialDynamicColors.inversePrimary);\n }\n\n get secondary(): number {\n return this.getArgb(MaterialDynamicColors.secondary);\n }\n\n get onSecondary(): number {\n return this.getArgb(MaterialDynamicColors.onSecondary);\n }\n\n get secondaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.secondaryContainer);\n }\n\n get onSecondaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.onSecondaryContainer);\n }\n\n get tertiary(): number {\n return this.getArgb(MaterialDynamicColors.tertiary);\n }\n\n get onTertiary(): number {\n return this.getArgb(MaterialDynamicColors.onTertiary);\n }\n\n get tertiaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.tertiaryContainer);\n }\n\n get onTertiaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.onTertiaryContainer);\n }\n\n get error(): number {\n return this.getArgb(MaterialDynamicColors.error);\n }\n\n get onError(): number {\n return this.getArgb(MaterialDynamicColors.onError);\n }\n\n get errorContainer(): number {\n return this.getArgb(MaterialDynamicColors.errorContainer);\n }\n\n get onErrorContainer(): number {\n return this.getArgb(MaterialDynamicColors.onErrorContainer);\n }\n\n get primaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.primaryFixed);\n }\n\n get primaryFixedDim(): number {\n return this.getArgb(MaterialDynamicColors.primaryFixedDim);\n }\n\n get onPrimaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.onPrimaryFixed);\n }\n\n get onPrimaryFixedVariant(): number {\n return this.getArgb(MaterialDynamicColors.onPrimaryFixedVariant);\n }\n\n get secondaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.secondaryFixed);\n }\n\n get secondaryFixedDim(): number {\n return this.getArgb(MaterialDynamicColors.secondaryFixedDim);\n }\n\n get onSecondaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.onSecondaryFixed);\n }\n\n get onSecondaryFixedVariant(): number {\n return this.getArgb(MaterialDynamicColors.onSecondaryFixedVariant);\n }\n\n get tertiaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.tertiaryFixed);\n }\n\n get tertiaryFixedDim(): number {\n return this.getArgb(MaterialDynamicColors.tertiaryFixedDim);\n }\n\n get onTertiaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.onTertiaryFixed);\n }\n\n get onTertiaryFixedVariant(): number {\n return this.getArgb(MaterialDynamicColors.onTertiaryFixedVariant);\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as utils from '../utils/color_utils.js';\n\nimport {PointProvider} from './point_provider.js';\n\n/**\n * Provides conversions needed for K-Means quantization. Converting input to\n * points, and converting the final state of the K-Means algorithm to colors.\n */\nexport class LabPointProvider implements PointProvider {\n /**\n * Convert a color represented in ARGB to a 3-element array of L*a*b*\n * coordinates of the color.\n */\n fromInt(argb: number): number[] {\n return utils.labFromArgb(argb);\n }\n\n /**\n * Convert a 3-element array to a color represented in ARGB.\n */\n toInt(point: number[]): number {\n return utils.argbFromLab(point[0], point[1], point[2]);\n }\n\n /**\n * Standard CIE 1976 delta E formula also takes the square root, unneeded\n * here. This method is used by quantization algorithms to compare distance,\n * and the relative ordering is the same, with or without a square root.\n *\n * This relatively minor optimization is helpful because this method is\n * called at least once for each pixel in an image.\n */\n distance(from: number[], to: number[]): number {\n const dL = from[0] - to[0];\n const dA = from[1] - to[1];\n const dB = from[2] - to[2];\n return dL * dL + dA * dA + dB * dB;\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {LabPointProvider} from './lab_point_provider.js';\n\nconst MAX_ITERATIONS = 10;\nconst MIN_MOVEMENT_DISTANCE = 3.0;\n\n/**\n * An image quantizer that improves on the speed of a standard K-Means algorithm\n * by implementing several optimizations, including deduping identical pixels\n * and a triangle inequality rule that reduces the number of comparisons needed\n * to identify which cluster a point should be moved to.\n *\n * Wsmeans stands for Weighted Square Means.\n *\n * This algorithm was designed by M. Emre Celebi, and was found in their 2011\n * paper, Improving the Performance of K-Means for Color Quantization.\n * https://arxiv.org/abs/1101.0395\n */\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable-next-line:class-as-namespace\nexport class QuantizerWsmeans {\n /**\n * @param inputPixels Colors in ARGB format.\n * @param startingClusters Defines the initial state of the quantizer. Passing\n * an empty array is fine, the implementation will create its own initial\n * state that leads to reproducible results for the same inputs.\n * Passing an array that is the result of Wu quantization leads to higher\n * quality results.\n * @param maxColors The number of colors to divide the image into. A lower\n * number of colors may be returned.\n * @return Colors in ARGB format.\n */\n static quantize(\n inputPixels: number[], startingClusters: number[],\n maxColors: number): Map<number, number> {\n const pixelToCount = new Map<number, number>();\n const points = new Array<number[]>();\n const pixels = new Array<number>();\n const pointProvider = new LabPointProvider();\n let pointCount = 0;\n for (let i = 0; i < inputPixels.length; i++) {\n const inputPixel = inputPixels[i];\n const pixelCount = pixelToCount.get(inputPixel);\n if (pixelCount === undefined) {\n pointCount++;\n points.push(pointProvider.fromInt(inputPixel));\n pixels.push(inputPixel);\n pixelToCount.set(inputPixel, 1);\n } else {\n pixelToCount.set(inputPixel, pixelCount + 1);\n }\n }\n\n const counts = new Array<number>();\n for (let i = 0; i < pointCount; i++) {\n const pixel = pixels[i];\n const count = pixelToCount.get(pixel);\n if (count !== undefined) {\n counts[i] = count;\n }\n }\n\n let clusterCount = Math.min(maxColors, pointCount);\n if (startingClusters.length > 0) {\n clusterCount = Math.min(clusterCount, startingClusters.length);\n }\n\n const clusters = new Array<number[]>();\n for (let i = 0; i < startingClusters.length; i++) {\n clusters.push(pointProvider.fromInt(startingClusters[i]));\n }\n const additionalClustersNeeded = clusterCount - clusters.length;\n if (startingClusters.length === 0 && additionalClustersNeeded > 0) {\n for (let i = 0; i < additionalClustersNeeded; i++) {\n const l = Math.random() * 100.0;\n const a = Math.random() * (100.0 - (-100.0) + 1) + -100;\n const b = Math.random() * (100.0 - (-100.0) + 1) + -100;\n\n clusters.push(new Array(l, a, b));\n }\n }\n\n const clusterIndices = new Array<number>();\n for (let i = 0; i < pointCount; i++) {\n clusterIndices.push(Math.floor(Math.random() * clusterCount));\n }\n\n const indexMatrix = new Array<number[]>();\n for (let i = 0; i < clusterCount; i++) {\n indexMatrix.push(new Array<number>());\n for (let j = 0; j < clusterCount; j++) {\n indexMatrix[i].push(0);\n }\n }\n\n const distanceToIndexMatrix = new Array<DistanceAndIndex[]>();\n for (let i = 0; i < clusterCount; i++) {\n distanceToIndexMatrix.push(new Array<DistanceAndIndex>());\n for (let j = 0; j < clusterCount; j++) {\n distanceToIndexMatrix[i].push(new DistanceAndIndex());\n }\n }\n\n\n const pixelCountSums = new Array<number>();\n for (let i = 0; i < clusterCount; i++) {\n pixelCountSums.push(0);\n }\n for (let iteration = 0; iteration < MAX_ITERATIONS; iteration++) {\n for (let i = 0; i < clusterCount; i++) {\n for (let j = i + 1; j < clusterCount; j++) {\n const distance = pointProvider.distance(clusters[i], clusters[j]);\n distanceToIndexMatrix[j][i].distance = distance;\n distanceToIndexMatrix[j][i].index = i;\n distanceToIndexMatrix[i][j].distance = distance;\n distanceToIndexMatrix[i][j].index = j;\n }\n distanceToIndexMatrix[i].sort();\n for (let j = 0; j < clusterCount; j++) {\n indexMatrix[i][j] = distanceToIndexMatrix[i][j].index;\n }\n }\n\n let pointsMoved = 0;\n for (let i = 0; i < pointCount; i++) {\n const point = points[i];\n const previousClusterIndex = clusterIndices[i];\n const previousCluster = clusters[previousClusterIndex];\n const previousDistance = pointProvider.distance(point, previousCluster);\n let minimumDistance = previousDistance;\n let newClusterIndex = -1;\n for (let j = 0; j < clusterCount; j++) {\n if (distanceToIndexMatrix[previousClusterIndex][j].distance >=\n 4 * previousDistance) {\n continue;\n }\n const distance = pointProvider.distance(point, clusters[j]);\n if (distance < minimumDistance) {\n minimumDistance = distance;\n newClusterIndex = j;\n }\n }\n if (newClusterIndex !== -1) {\n const distanceChange = Math.abs(\n (Math.sqrt(minimumDistance) - Math.sqrt(previousDistance)));\n if (distanceChange > MIN_MOVEMENT_DISTANCE) {\n pointsMoved++;\n clusterIndices[i] = newClusterIndex;\n }\n }\n }\n\n if (pointsMoved === 0 && iteration !== 0) {\n break;\n }\n\n const componentASums = new Array<number>(clusterCount).fill(0);\n const componentBSums = new Array<number>(clusterCount).fill(0);\n const componentCSums = new Array<number>(clusterCount).fill(0);\n\n for (let i = 0; i < clusterCount; i++) {\n pixelCountSums[i] = 0;\n }\n for (let i = 0; i < pointCount; i++) {\n const clusterIndex = clusterIndices[i];\n const point = points[i];\n const count = counts[i];\n pixelCountSums[clusterIndex] += count;\n componentASums[clusterIndex] += (point[0] * count);\n componentBSums[clusterIndex] += (point[1] * count);\n componentCSums[clusterIndex] += (point[2] * count);\n }\n\n for (let i = 0; i < clusterCount; i++) {\n const count = pixelCountSums[i];\n if (count === 0) {\n clusters[i] = [0.0, 0.0, 0.0];\n continue;\n }\n const a = componentASums[i] / count;\n const b = componentBSums[i] / count;\n const c = componentCSums[i] / count;\n clusters[i] = [a, b, c];\n }\n }\n\n const argbToPopulation = new Map<number, number>();\n for (let i = 0; i < clusterCount; i++) {\n const count = pixelCountSums[i];\n if (count === 0) {\n continue;\n }\n\n const possibleNewCluster = pointProvider.toInt(clusters[i]);\n if (argbToPopulation.has(possibleNewCluster)) {\n continue;\n }\n\n argbToPopulation.set(possibleNewCluster, count);\n }\n return argbToPopulation;\n }\n}\n\n/**\n * A wrapper for maintaining a table of distances between K-Means clusters.\n */\nclass DistanceAndIndex {\n distance: number = -1;\n index: number = -1;\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as utils from '../utils/color_utils.js';\n\n/**\n * Quantizes an image into a map, with keys of ARGB colors, and values of the\n * number of times that color appears in the image.\n */\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable-next-line:class-as-namespace\nexport class QuantizerMap {\n /**\n * @param pixels Colors in ARGB format.\n * @return A Map with keys of ARGB colors, and values of the number of times\n * the color appears in the image.\n */\n static quantize(pixels: number[]): Map<number, number> {\n const countByColor = new Map<number, number>();\n for (let i = 0; i < pixels.length; i++) {\n const pixel = pixels[i];\n const alpha = utils.alphaFromArgb(pixel);\n if (alpha < 255) {\n continue;\n }\n countByColor.set(pixel, (countByColor.get(pixel) ?? 0) + 1);\n }\n return countByColor;\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as utils from '../utils/color_utils.js';\n\nimport {QuantizerMap} from './quantizer_map.js';\n\nconst INDEX_BITS = 5;\nconst SIDE_LENGTH = 33; // ((1 << INDEX_INDEX_BITS) + 1)\nconst TOTAL_SIZE = 35937; // SIDE_LENGTH * SIDE_LENGTH * SIDE_LENGTH\n\nconst directions = {\n RED: 'red',\n GREEN: 'green',\n BLUE: 'blue',\n};\n\n/**\n * An image quantizer that divides the image's pixels into clusters by\n * recursively cutting an RGB cube, based on the weight of pixels in each area\n * of the cube.\n *\n * The algorithm was described by Xiaolin Wu in Graphic Gems II, published in\n * 1991.\n */\nexport class QuantizerWu {\n constructor(\n private weights: number[] = [], private momentsR: number[] = [],\n private momentsG: number[] = [], private momentsB: number[] = [],\n private moments: number[] = [], private cubes: Box[] = []) {}\n\n /**\n * @param pixels Colors in ARGB format.\n * @param maxColors The number of colors to divide the image into. A lower\n * number of colors may be returned.\n * @return Colors in ARGB format.\n */\n quantize(pixels: number[], maxColors: number): number[] {\n this.constructHistogram(pixels);\n this.computeMoments();\n const createBoxesResult = this.createBoxes(maxColors);\n const results = this.createResult(createBoxesResult.resultCount);\n return results;\n }\n\n private constructHistogram(pixels: number[]) {\n this.weights = Array.from<number>({length: TOTAL_SIZE}).fill(0);\n this.momentsR = Array.from<number>({length: TOTAL_SIZE}).fill(0);\n this.momentsG = Array.from<number>({length: TOTAL_SIZE}).fill(0);\n this.momentsB = Array.from<number>({length: TOTAL_SIZE}).fill(0);\n this.moments = Array.from<number>({length: TOTAL_SIZE}).fill(0);\n\n const countByColor = QuantizerMap.quantize(pixels);\n\n for (const [pixel, count] of countByColor.entries()) {\n const red = utils.redFromArgb(pixel);\n const green = utils.greenFromArgb(pixel);\n const blue = utils.blueFromArgb(pixel);\n\n const bitsToRemove = 8 - INDEX_BITS;\n const iR = (red >> bitsToRemove) + 1;\n const iG = (green >> bitsToRemove) + 1;\n const iB = (blue >> bitsToRemove) + 1;\n const index = this.getIndex(iR, iG, iB);\n\n this.weights[index] = (this.weights[index] ?? 0) + count;\n this.momentsR[index] += count * red;\n this.momentsG[index] += count * green;\n this.momentsB[index] += count * blue;\n this.moments[index] += count * (red * red + green * green + blue * blue);\n }\n }\n\n private computeMoments() {\n for (let r = 1; r < SIDE_LENGTH; r++) {\n const area = Array.from<number>({length: SIDE_LENGTH}).fill(0);\n const areaR = Array.from<number>({length: SIDE_LENGTH}).fill(0);\n const areaG = Array.from<number>({length: SIDE_LENGTH}).fill(0);\n const areaB = Array.from<number>({length: SIDE_LENGTH}).fill(0);\n const area2 = Array.from<number>({length: SIDE_LENGTH}).fill(0.0);\n for (let g = 1; g < SIDE_LENGTH; g++) {\n let line = 0;\n let lineR = 0;\n let lineG = 0;\n let lineB = 0;\n let line2 = 0.0;\n for (let b = 1; b < SIDE_LENGTH; b++) {\n const index = this.getIndex(r, g, b);\n line += this.weights[index];\n lineR += this.momentsR[index];\n lineG += this.momentsG[index];\n lineB += this.momentsB[index];\n line2 += this.moments[index];\n\n area[b] += line;\n areaR[b] += lineR;\n areaG[b] += lineG;\n areaB[b] += lineB;\n area2[b] += line2;\n\n const previousIndex = this.getIndex(r - 1, g, b);\n this.weights[index] = this.weights[previousIndex] + area[b];\n this.momentsR[index] = this.momentsR[previousIndex] + areaR[b];\n this.momentsG[index] = this.momentsG[previousIndex] + areaG[b];\n this.momentsB[index] = this.momentsB[previousIndex] + areaB[b];\n this.moments[index] = this.moments[previousIndex] + area2[b];\n }\n }\n }\n }\n\n private createBoxes(maxColors: number): CreateBoxesResult {\n this.cubes =\n Array.from<number>({length: maxColors}).fill(0).map(() => new Box());\n const volumeVariance = Array.from<number>({length: maxColors}).fill(0.0);\n this.cubes[0].r0 = 0;\n this.cubes[0].g0 = 0;\n this.cubes[0].b0 = 0;\n\n this.cubes[0].r1 = SIDE_LENGTH - 1;\n this.cubes[0].g1 = SIDE_LENGTH - 1;\n this.cubes[0].b1 = SIDE_LENGTH - 1;\n\n let generatedColorCount = maxColors;\n let next = 0;\n for (let i = 1; i < maxColors; i++) {\n if (this.cut(this.cubes[next], this.cubes[i])) {\n volumeVariance[next] =\n this.cubes[next].vol > 1 ? this.variance(this.cubes[next]) : 0.0;\n volumeVariance[i] =\n this.cubes[i].vol > 1 ? this.variance(this.cubes[i]) : 0.0;\n } else {\n volumeVariance[next] = 0.0;\n i--;\n }\n\n next = 0;\n let temp = volumeVariance[0];\n for (let j = 1; j <= i; j++) {\n if (volumeVariance[j] > temp) {\n temp = volumeVariance[j];\n next = j;\n }\n }\n if (temp <= 0.0) {\n generatedColorCount = i + 1;\n break;\n }\n }\n return new CreateBoxesResult(maxColors, generatedColorCount);\n }\n\n private createResult(colorCount: number): number[] {\n const colors: number[] = [];\n for (let i = 0; i < colorCount; ++i) {\n const cube = this.cubes[i];\n const weight = this.volume(cube, this.weights);\n if (weight > 0) {\n const r = Math.round(this.volume(cube, this.momentsR) / weight);\n const g = Math.round(this.volume(cube, this.momentsG) / weight);\n const b = Math.round(this.volume(cube, this.momentsB) / weight);\n const color = (255 << 24) | ((r & 0x0ff) << 16) | ((g & 0x0ff) << 8) |\n (b & 0x0ff);\n colors.push(color);\n }\n }\n return colors;\n }\n\n private variance(cube: Box) {\n const dr = this.volume(cube, this.momentsR);\n const dg = this.volume(cube, this.momentsG);\n const db = this.volume(cube, this.momentsB);\n const xx = this.moments[this.getIndex(cube.r1, cube.g1, cube.b1)] -\n this.moments[this.getIndex(cube.r1, cube.g1, cube.b0)] -\n this.moments[this.getIndex(cube.r1, cube.g0, cube.b1)] +\n this.moments[this.getIndex(cube.r1, cube.g0, cube.b0)] -\n this.moments[this.getIndex(cube.r0, cube.g1, cube.b1)] +\n this.moments[this.getIndex(cube.r0, cube.g1, cube.b0)] +\n this.moments[this.getIndex(cube.r0, cube.g0, cube.b1)] -\n this.moments[this.getIndex(cube.r0, cube.g0, cube.b0)];\n const hypotenuse = dr * dr + dg * dg + db * db;\n const volume = this.volume(cube, this.weights);\n return xx - hypotenuse / volume;\n }\n\n private cut(one: Box, two: Box) {\n const wholeR = this.volume(one, this.momentsR);\n const wholeG = this.volume(one, this.momentsG);\n const wholeB = this.volume(one, this.momentsB);\n const wholeW = this.volume(one, this.weights);\n\n const maxRResult = this.maximize(\n one, directions.RED, one.r0 + 1, one.r1, wholeR, wholeG, wholeB,\n wholeW);\n const maxGResult = this.maximize(\n one, directions.GREEN, one.g0 + 1, one.g1, wholeR, wholeG, wholeB,\n wholeW);\n const maxBResult = this.maximize(\n one, directions.BLUE, one.b0 + 1, one.b1, wholeR, wholeG, wholeB,\n wholeW);\n\n let direction;\n const maxR = maxRResult.maximum;\n const maxG = maxGResult.maximum;\n const maxB = maxBResult.maximum;\n if (maxR >= maxG && maxR >= maxB) {\n if (maxRResult.cutLocation < 0) {\n return false;\n }\n direction = directions.RED;\n } else if (maxG >= maxR && maxG >= maxB) {\n direction = directions.GREEN;\n } else {\n direction = directions.BLUE;\n }\n\n two.r1 = one.r1;\n two.g1 = one.g1;\n two.b1 = one.b1;\n\n switch (direction) {\n case directions.RED:\n one.r1 = maxRResult.cutLocation;\n two.r0 = one.r1;\n two.g0 = one.g0;\n two.b0 = one.b0;\n break;\n case directions.GREEN:\n one.g1 = maxGResult.cutLocation;\n two.r0 = one.r0;\n two.g0 = one.g1;\n two.b0 = one.b0;\n break;\n case directions.BLUE:\n one.b1 = maxBResult.cutLocation;\n two.r0 = one.r0;\n two.g0 = one.g0;\n two.b0 = one.b1;\n break;\n default:\n throw new Error('unexpected direction ' + direction);\n }\n\n one.vol = (one.r1 - one.r0) * (one.g1 - one.g0) * (one.b1 - one.b0);\n two.vol = (two.r1 - two.r0) * (two.g1 - two.g0) * (two.b1 - two.b0);\n return true;\n }\n\n private maximize(\n cube: Box, direction: string, first: number, last: number, wholeR: number,\n wholeG: number, wholeB: number, wholeW: number) {\n const bottomR = this.bottom(cube, direction, this.momentsR);\n const bottomG = this.bottom(cube, direction, this.momentsG);\n const bottomB = this.bottom(cube, direction, this.momentsB);\n const bottomW = this.bottom(cube, direction, this.weights);\n\n let max = 0.0;\n let cut = -1;\n\n let halfR = 0;\n let halfG = 0;\n let halfB = 0;\n let halfW = 0;\n for (let i = first; i < last; i++) {\n halfR = bottomR + this.top(cube, direction, i, this.momentsR);\n halfG = bottomG + this.top(cube, direction, i, this.momentsG);\n halfB = bottomB + this.top(cube, direction, i, this.momentsB);\n halfW = bottomW + this.top(cube, direction, i, this.weights);\n if (halfW === 0) {\n continue;\n }\n\n let tempNumerator = (halfR * halfR + halfG * halfG + halfB * halfB) * 1.0;\n let tempDenominator = halfW * 1.0;\n let temp = tempNumerator / tempDenominator;\n\n halfR = wholeR - halfR;\n halfG = wholeG - halfG;\n halfB = wholeB - halfB;\n halfW = wholeW - halfW;\n if (halfW === 0) {\n continue;\n }\n\n tempNumerator = (halfR * halfR + halfG * halfG + halfB * halfB) * 1.0;\n tempDenominator = halfW * 1.0;\n temp += tempNumerator / tempDenominator;\n\n if (temp > max) {\n max = temp;\n cut = i;\n }\n }\n return new MaximizeResult(cut, max);\n }\n\n private volume(cube: Box, moment: number[]) {\n return (\n moment[this.getIndex(cube.r1, cube.g1, cube.b1)] -\n moment[this.getIndex(cube.r1, cube.g1, cube.b0)] -\n moment[this.getIndex(cube.r1, cube.g0, cube.b1)] +\n moment[this.getIndex(cube.r1, cube.g0, cube.b0)] -\n moment[this.getIndex(cube.r0, cube.g1, cube.b1)] +\n moment[this.getIndex(cube.r0, cube.g1, cube.b0)] +\n moment[this.getIndex(cube.r0, cube.g0, cube.b1)] -\n moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);\n }\n\n private bottom(cube: Box, direction: string, moment: number[]) {\n switch (direction) {\n case directions.RED:\n return (\n -moment[this.getIndex(cube.r0, cube.g1, cube.b1)] +\n moment[this.getIndex(cube.r0, cube.g1, cube.b0)] +\n moment[this.getIndex(cube.r0, cube.g0, cube.b1)] -\n moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);\n case directions.GREEN:\n return (\n -moment[this.getIndex(cube.r1, cube.g0, cube.b1)] +\n moment[this.getIndex(cube.r1, cube.g0, cube.b0)] +\n moment[this.getIndex(cube.r0, cube.g0, cube.b1)] -\n moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);\n case directions.BLUE:\n return (\n -moment[this.getIndex(cube.r1, cube.g1, cube.b0)] +\n moment[this.getIndex(cube.r1, cube.g0, cube.b0)] +\n moment[this.getIndex(cube.r0, cube.g1, cube.b0)] -\n moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);\n default:\n throw new Error('unexpected direction $direction');\n }\n }\n\n private top(\n cube: Box, direction: string, position: number, moment: number[]) {\n switch (direction) {\n case directions.RED:\n return (\n moment[this.getIndex(position, cube.g1, cube.b1)] -\n moment[this.getIndex(position, cube.g1, cube.b0)] -\n moment[this.getIndex(position, cube.g0, cube.b1)] +\n moment[this.getIndex(position, cube.g0, cube.b0)]);\n case directions.GREEN:\n return (\n moment[this.getIndex(cube.r1, position, cube.b1)] -\n moment[this.getIndex(cube.r1, position, cube.b0)] -\n moment[this.getIndex(cube.r0, position, cube.b1)] +\n moment[this.getIndex(cube.r0, position, cube.b0)]);\n case directions.BLUE:\n return (\n moment[this.getIndex(cube.r1, cube.g1, position)] -\n moment[this.getIndex(cube.r1, cube.g0, position)] -\n moment[this.getIndex(cube.r0, cube.g1, position)] +\n moment[this.getIndex(cube.r0, cube.g0, position)]);\n default:\n throw new Error('unexpected direction $direction');\n }\n }\n\n private getIndex(r: number, g: number, b: number): number {\n return (r << (INDEX_BITS * 2)) + (r << (INDEX_BITS + 1)) + r +\n (g << INDEX_BITS) + g + b;\n }\n}\n\n/**\n * Keeps track of the state of each box created as the Wu quantization\n * algorithm progresses through dividing the image's pixels as plotted in RGB.\n */\nclass Box {\n constructor(\n public r0: number = 0, public r1: number = 0, public g0: number = 0,\n public g1: number = 0, public b0: number = 0, public b1: number = 0,\n public vol: number = 0) {}\n}\n\n/**\n * Represents final result of Wu algorithm.\n */\nclass CreateBoxesResult {\n /**\n * @param requestedCount how many colors the caller asked to be returned from\n * quantization.\n * @param resultCount the actual number of colors achieved from quantization.\n * May be lower than the requested count.\n */\n constructor(public requestedCount: number, public resultCount: number) {}\n}\n\n/**\n * Represents the result of calculating where to cut an existing box in such\n * a way to maximize variance between the two new boxes created by a cut.\n */\nclass MaximizeResult {\n constructor(public cutLocation: number, public maximum: number) {}\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {QuantizerWsmeans} from './quantizer_wsmeans.js';\nimport {QuantizerWu} from './quantizer_wu.js';\n\n/**\n * An image quantizer that improves on the quality of a standard K-Means\n * algorithm by setting the K-Means initial state to the output of a Wu\n * quantizer, instead of random centroids. Improves on speed by several\n * optimizations, as implemented in Wsmeans, or Weighted Square Means, K-Means\n * with those optimizations.\n *\n * This algorithm was designed by M. Emre Celebi, and was found in their 2011\n * paper, Improving the Performance of K-Means for Color Quantization.\n * https://arxiv.org/abs/1101.0395\n */\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable-next-line:class-as-namespace\nexport class QuantizerCelebi {\n /**\n * @param pixels Colors in ARGB format.\n * @param maxColors The number of colors to divide the image into. A lower\n * number of colors may be returned.\n * @return Map with keys of colors in ARGB format, and values of number of\n * pixels in the original image that correspond to the color in the\n * quantized image.\n */\n static quantize(pixels: number[], maxColors: number): Map<number, number> {\n const wu = new QuantizerWu();\n const wuResult = wu.quantize(pixels, maxColors);\n return QuantizerWsmeans.quantize(pixels, wuResult, maxColors);\n }\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {DynamicScheme} from '../dynamiccolor/dynamic_scheme.js';\nimport {Variant} from '../dynamiccolor/variant.js';\nimport {Hct} from '../hct/hct.js';\nimport {TonalPalette} from '../palettes/tonal_palette.js';\nimport * as math from '../utils/math_utils.js';\n\n/**\n * A Dynamic Color theme that is intentionally detached from the source color.\n */\nexport class SchemeExpressive extends DynamicScheme {\n /**\n * Hues (in degrees) used at breakpoints such that designers can specify a\n * hue rotation that occurs at a given break point.\n */\n private static readonly hues: number[] = [\n 0.0,\n 21.0,\n 51.0,\n 121.0,\n 151.0,\n 191.0,\n 271.0,\n 321.0,\n 360.0,\n ];\n\n /**\n * Hue rotations (in degrees) of the Secondary [TonalPalette],\n * corresponding to the breakpoints in [hues].\n */\n private static readonly secondaryRotations: number[] = [\n 45.0,\n 95.0,\n 45.0,\n 20.0,\n 45.0,\n 90.0,\n 45.0,\n 45.0,\n 45.0,\n ];\n\n /**\n * Hue rotations (in degrees) of the Tertiary [TonalPalette],\n * corresponding to the breakpoints in [hues].\n */\n private static readonly tertiaryRotations: number[] = [\n 120.0,\n 120.0,\n 20.0,\n 45.0,\n 20.0,\n 15.0,\n 20.0,\n 120.0,\n 120.0,\n ];\n\n constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number) {\n super({\n sourceColorArgb: sourceColorHct.toInt(),\n variant: Variant.EXPRESSIVE,\n contrastLevel,\n isDark,\n primaryPalette: TonalPalette.fromHueAndChroma(\n math.sanitizeDegreesDouble(sourceColorHct.hue + 240.0), 40.0),\n secondaryPalette: TonalPalette.fromHueAndChroma(\n DynamicScheme.getRotatedHue(\n sourceColorHct, SchemeExpressive.hues,\n SchemeExpressive.secondaryRotations),\n 24.0),\n tertiaryPalette: TonalPalette.fromHueAndChroma(\n DynamicScheme.getRotatedHue(\n sourceColorHct, SchemeExpressive.hues,\n SchemeExpressive.tertiaryRotations),\n 32.0),\n neutralPalette:\n TonalPalette.fromHueAndChroma(sourceColorHct.hue + 15, 8.0),\n neutralVariantPalette:\n TonalPalette.fromHueAndChroma(sourceColorHct.hue + 15, 12.0),\n });\n }\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {DynamicScheme} from '../dynamiccolor/dynamic_scheme.js';\nimport {Variant} from '../dynamiccolor/variant.js';\nimport {Hct} from '../hct/hct.js';\nimport {TonalPalette} from '../palettes/tonal_palette.js';\n\n/**\n * A Dynamic Color theme that maxes out colorfulness at each position in the\n * Primary Tonal Palette.\n */\nexport class SchemeVibrant extends DynamicScheme {\n /**\n * Hues (in degrees) used at breakpoints such that designers can specify a\n * hue rotation that occurs at a given break point.\n */\n private static readonly hues = [\n 0.0,\n 41.0,\n 61.0,\n 101.0,\n 131.0,\n 181.0,\n 251.0,\n 301.0,\n 360.0,\n ];\n\n /**\n * Hue rotations (in degrees) of the Secondary [TonalPalette],\n * corresponding to the breakpoints in [hues].\n */\n private static readonly secondaryRotations = [\n 18.0,\n 15.0,\n 10.0,\n 12.0,\n 15.0,\n 18.0,\n 15.0,\n 12.0,\n 12.0,\n ];\n\n /**\n * Hue rotations (in degrees) of the Tertiary [TonalPalette],\n * corresponding to the breakpoints in [hues].\n */\n private static readonly tertiaryRotations = [\n 35.0,\n 30.0,\n 20.0,\n 25.0,\n 30.0,\n 35.0,\n 30.0,\n 25.0,\n 25.0,\n ];\n\n constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number) {\n super({\n sourceColorArgb: sourceColorHct.toInt(),\n variant: Variant.VIBRANT,\n contrastLevel,\n isDark,\n primaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 200.0),\n secondaryPalette: TonalPalette.fromHueAndChroma(\n DynamicScheme.getRotatedHue(\n sourceColorHct, SchemeVibrant.hues,\n SchemeVibrant.secondaryRotations),\n 24.0),\n tertiaryPalette: TonalPalette.fromHueAndChroma(\n DynamicScheme.getRotatedHue(\n sourceColorHct, SchemeVibrant.hues,\n SchemeVibrant.tertiaryRotations),\n 32.0),\n neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 10.0),\n neutralVariantPalette:\n TonalPalette.fromHueAndChroma(sourceColorHct.hue, 12.0),\n });\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Hct} from '../hct/hct.js';\nimport * as math from '../utils/math_utils.js';\n\n/**\n * Default options for ranking colors based on usage counts.\n * desired: is the max count of the colors returned.\n * fallbackColorARGB: Is the default color that should be used if no\n * other colors are suitable.\n * filter: controls if the resulting colors should be filtered to not include\n * hues that are not used often enough, and colors that are effectively\n * grayscale.\n */\ndeclare interface ScoreOptions {\n desired?: number;\n fallbackColorARGB?: number;\n filter?: boolean;\n}\n\nconst SCORE_OPTION_DEFAULTS = {\n desired: 4, // 4 colors matches what Android wallpaper picker.\n fallbackColorARGB: 0xff4285f4, // Google Blue.\n filter: true, // Avoid unsuitable colors.\n};\n\nfunction compare(a: {hct: Hct, score: number}, b: {hct: Hct, score: number}): number {\n if (a.score > b.score) {\n return -1;\n } else if (a.score < b.score) {\n return 1;\n }\n return 0;\n}\n\n/**\n * Given a large set of colors, remove colors that are unsuitable for a UI\n * theme, and rank the rest based on suitability.\n *\n * Enables use of a high cluster count for image quantization, thus ensuring\n * colors aren't muddied, while curating the high cluster count to a much\n * smaller number of appropriate choices.\n */\nexport class Score {\n private static readonly TARGET_CHROMA = 48.0; // A1 Chroma\n private static readonly WEIGHT_PROPORTION = 0.7;\n private static readonly WEIGHT_CHROMA_ABOVE = 0.3;\n private static readonly WEIGHT_CHROMA_BELOW = 0.1;\n private static readonly CUTOFF_CHROMA = 5.0;\n private static readonly CUTOFF_EXCITED_PROPORTION = 0.01;\n\n private constructor() {}\n\n /**\n * Given a map with keys of colors and values of how often the color appears,\n * rank the colors based on suitability for being used for a UI theme.\n *\n * @param colorsToPopulation map with keys of colors and values of how often\n * the color appears, usually from a source image.\n * @param {ScoreOptions} options optional parameters.\n * @return Colors sorted by suitability for a UI theme. The most suitable\n * color is the first item, the least suitable is the last. There will\n * always be at least one color returned. If all the input colors\n * were not suitable for a theme, a default fallback color will be\n * provided, Google Blue.\n */\n static score(\n colorsToPopulation: Map<number, number>, options?: ScoreOptions):\n number[] {\n const {desired, fallbackColorARGB, filter} = {...SCORE_OPTION_DEFAULTS, ...options};\n // Get the HCT color for each Argb value, while finding the per hue count and\n // total count.\n const colorsHct: Hct[] = [];\n const huePopulation = new Array<number>(360).fill(0);\n let populationSum = 0;\n for (const [argb, population] of colorsToPopulation.entries()) {\n const hct = Hct.fromInt(argb);\n colorsHct.push(hct);\n const hue = Math.floor(hct.hue);\n huePopulation[hue] += population;\n populationSum += population;\n }\n\n // Hues with more usage in neighboring 30 degree slice get a larger number.\n const hueExcitedProportions = new Array<number>(360).fill(0.0);\n for (let hue = 0; hue < 360; hue++) {\n const proportion = huePopulation[hue] / populationSum;\n for (let i = hue - 14; i < hue + 16; i++) {\n const neighborHue = math.sanitizeDegreesInt(i);\n hueExcitedProportions[neighborHue] += proportion;\n }\n }\n\n // Scores each HCT color based on usage and chroma, while optionally\n // filtering out values that do not have enough chroma or usage.\n const scoredHct = new Array<{hct: Hct, score: number}>();\n for (const hct of colorsHct) {\n const hue = math.sanitizeDegreesInt(Math.round(hct.hue));\n const proportion = hueExcitedProportions[hue];\n if (filter && (hct.chroma < Score.CUTOFF_CHROMA || proportion <= Score.CUTOFF_EXCITED_PROPORTION)) {\n continue;\n }\n\n const proportionScore = proportion * 100.0 * Score.WEIGHT_PROPORTION;\n const chromaWeight = hct.chroma < Score.TARGET_CHROMA ? Score.WEIGHT_CHROMA_BELOW : Score.WEIGHT_CHROMA_ABOVE;\n const chromaScore = (hct.chroma - Score.TARGET_CHROMA) * chromaWeight;\n const score = proportionScore + chromaScore;\n scoredHct.push({hct, score});\n }\n // Sorted so that colors with higher scores come first.\n scoredHct.sort(compare);\n\n // Iterates through potential hue differences in degrees in order to select\n // the colors with the largest distribution of hues possible. Starting at\n // 90 degrees(maximum difference for 4 colors) then decreasing down to a\n // 15 degree minimum.\n const chosenColors: Hct[] = [];\n for (let differenceDegrees = 90; differenceDegrees >= 15; differenceDegrees--) {\n chosenColors.length = 0;\n for (const {hct} of scoredHct) {\n const duplicateHue = chosenColors.find(chosenHct => {\n return math.differenceDegrees(hct.hue, chosenHct.hue) < differenceDegrees;\n });\n if (!duplicateHue) {\n chosenColors.push(hct);\n }\n if (chosenColors.length >= desired) break;\n }\n if (chosenColors.length >= desired) break;\n }\n const colors: number[] = [];\n if (chosenColors.length === 0) {\n colors.push(fallbackColorARGB);\n }\n for (const chosenHct of chosenColors) {\n colors.push(chosenHct.toInt());\n }\n return colors;\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as colorUtils from './color_utils.js';\n\n/**\n * Utility methods for hexadecimal representations of colors.\n */\n\n/**\n * @param argb ARGB representation of a color.\n * @return Hex string representing color, ex. #ff0000 for red.\n */\nexport function hexFromArgb(argb: number) {\n const r = colorUtils.redFromArgb(argb);\n const g = colorUtils.greenFromArgb(argb);\n const b = colorUtils.blueFromArgb(argb);\n const outParts = [r.toString(16), g.toString(16), b.toString(16)];\n\n // Pad single-digit output values\n for (const [i, part] of outParts.entries()) {\n if (part.length === 1) {\n outParts[i] = '0' + part;\n }\n }\n\n return '#' + outParts.join('');\n}\n\n/**\n * @param hex String representing color as hex code. Accepts strings with or\n * without leading #, and string representing the color using 3, 6, or 8\n * hex characters.\n * @return ARGB representation of color.\n */\nexport function argbFromHex(hex: string) {\n hex = hex.replace('#', '');\n const isThree = hex.length === 3;\n const isSix = hex.length === 6;\n const isEight = hex.length === 8;\n if (!isThree && !isSix && !isEight) {\n throw new Error('unexpected hex ' + hex);\n }\n let r = 0;\n let g = 0;\n let b = 0;\n if (isThree) {\n r = parseIntHex(hex.slice(0, 1).repeat(2));\n g = parseIntHex(hex.slice(1, 2).repeat(2));\n b = parseIntHex(hex.slice(2, 3).repeat(2));\n } else if (isSix) {\n r = parseIntHex(hex.slice(0, 2));\n g = parseIntHex(hex.slice(2, 4));\n b = parseIntHex(hex.slice(4, 6));\n } else if (isEight) {\n r = parseIntHex(hex.slice(2, 4));\n g = parseIntHex(hex.slice(4, 6));\n b = parseIntHex(hex.slice(6, 8));\n }\n\n return (\n ((255 << 24) | ((r & 0x0ff) << 16) | ((g & 0x0ff) << 8) | (b & 0x0ff)) >>>\n 0);\n}\n\nfunction parseIntHex(value: string) {\n // tslint:disable-next-line:ban\n return parseInt(value, 16);\n}\n", "/**\n * RGBA color in 0-255 integer space.\n */\nexport interface RgbaColor {\n r: number;\n g: number;\n b: number;\n a: number;\n}\n\n/**\n * Returns the classic Game Boy palette.\n * Colors: #9bbc0f, #8bac0f, #306230, #0f380f\n */\nexport function getGameBoyPalette(): RgbaColor[] {\n return [\n { r: 155, g: 188, b: 15, a: 255 },\n { r: 139, g: 172, b: 15, a: 255 },\n { r: 48, g: 98, b: 48, a: 255 },\n { r: 15, g: 56, b: 15, a: 255 },\n ];\n}\n"],
5
- "mappings": "yoBAAA,IAAAA,GAAAC,EAAA,CAAAC,GAAAC,KAAA,CASA,IAAMC,GAAWC,GAAQ,OAAOA,EAAQ,KAAeA,IAAQ,KAMzDC,GAAUD,GAAQ,OAAOA,GAAQ,SAMjCE,GAAeF,GAAQ,OAAO,UAAU,SAAS,KAAKA,CAAG,IAAM,kBAM/DG,GAAMH,GAAQ,OAAOA,GAAQ,WAM7BI,GAAQJ,GAAQ,OAAOA,GAAQ,UAM/BK,GAAUL,GAAQA,aAAe,OAMjCM,GAAcN,GAAQ,CAC1B,GAAID,GAAQC,CAAG,EACb,OAAQA,EAAI,YAAa,CACvB,KAAK,WACL,KAAK,kBACL,KAAK,UACL,KAAK,YACL,KAAK,WACL,KAAK,YACL,KAAK,WACL,KAAK,aACL,KAAK,aACH,MAAO,EACX,CAGF,MAAO,EACT,EAMMO,GAAeP,GAAQA,aAAe,YAMtCQ,GAAUR,GAAQ,OAAOA,GAAQ,UAAYA,EAAI,OAAS,EAM1DS,GAAUT,GAAQ,OAAOA,GAAQ,UAAY,CAAC,OAAO,MAAMA,CAAG,EAM9DU,GAAWV,GAAQ,OAAO,UAAUA,CAAG,EAMvCW,GAAU,CAACX,EAAKY,EAAKC,IAAQb,GAAOY,GAAOZ,GAAOa,EAMlDC,GAAU,CAACd,EAAKe,IAASA,EAAK,SAASf,CAAG,EAW1CgB,GAAwB,CAACC,EAAMC,EAAUC,IAAW,IAAI,MAC1D,YAAYD,CAAQ,QAAQD,CAAI,iBAAiBE,CAAM,YAAY,OAAOA,CAA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ItE,CAAC,EAAE,SAAWN,GAAW,KAI7B4E,EAAItE,CAAC,EAAE,OAAO,WAAW,OAAS,EAAG,CACvC,IAAMuE,EAAUD,EAAItE,CAAC,EAAE,OACvB,GAAIuE,EAAQ,QAAU1C,EAAQ,OAC1B0C,EAAQ,QAAU1C,EAAQ,OAC1B0C,EAAQ,QAAU1C,EAAQ,MAC5B,MAAO,EAEX,CAIF,MAAO,EACT,CAEA,MAAO,EACT,IC5iBA,IAAA2C,GAAAC,EAAA,CAAAC,GAAAC,KAAA,cAEA,IAAMC,GAAQ,KACRC,GAAY,CAACC,EAASC,EAAOC,IAAY,CAC7C,GAAI,CACFD,EAAQ,IAAIH,GAAMG,EAAOC,CAAO,CAClC,MAAa,CACX,MAAO,EACT,CACA,OAAOD,EAAM,KAAKD,CAAO,CAC3B,EACAH,GAAO,QAAUE,KCXjB,IAAAI,GAAAC,EAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAA,SACE,KAAQ,QACR,YAAe,qHACf,QAAW,SACX,OAAU,kCACV,SAAY,kCACZ,aAAgB,CACd,gDACA,8CACA,4CACA,yCACA,yCACA,wCACA,sCACA,yCACA,iCACA,4CACA,0CACA,0CACA,8CACA,8CACA,oCACA,oCACA,2CACA,qCACA,gDACA,4CACA,uCACA,qCACA,4CACA,sCACA,yCACA,yCACA,uCACA,sCACA,sCACA,gDACA,iCACA,oCACA,oCACA,0CACA,wDACA,iDACA,wDACA,2CACA,wCACA,wDACA,0CACA,4BACA,kCACA,iDACA,iCACA,4CACA,8CACA,iDACA,4CACA,mCACA,2BACA,kCACA,gCACA,sCACA,uCACA,wCACA,gCACA,gCACA,oCACA,uCACA,yCACA,2CACA,uCACA,yCACA,wCACA,6DACA,uCACA,qCACA,+BACA,6BACA,gCACA,iCACA,mCACA,4CACA,uCACA,oDACA,uCACA,uCACA,yCACA,uCACA,qCACA,2CACA,sCACA,sCACA,qCACF,EACA,QAAW,CACT,MAAS,wBACT,QAAW,yCACX,MAAS,kEACT,KAAQ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AAO,EAAIA,EAAO,MAAO,EAAG,GAAG,EACxC,EAAGnG,GAAMmG,EAAO,EAAIA,EAAO,MAAO,EAAG,GAAG,EACxC,EAAGnG,GAAMmG,EAAO,EAAIA,EAAO,MAAO,EAAG,GAAG,CAC1C,CACF,CAAC,CACH,CAMA,SAASrG,GAAaD,EAAqB,CACzC,IAAMuG,EAAavG,EAAM,IACzB,OAAOuG,EAAa,EAAIA,EAAa,IAAMA,CAC7C,CyBz1BO,SAASC,IAAiC,CAC/C,MAAO,CACL,CAAE,EAAG,IAAK,EAAG,IAAK,EAAG,GAAI,EAAG,GAAI,EAChC,CAAE,EAAG,IAAK,EAAG,IAAK,EAAG,GAAI,EAAG,GAAI,EAChC,CAAE,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,EAC9B,CAAE,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,CAChC,CACF",
6
- "names": ["require_is", "__commonJSMin", "exports", "module", "defined", "val", "object", "plainObject", "fn", "bool", "buffer", "typedArray", "arrayBuffer", "string", "number", "integer", "inRange", "min", "max", "inArray", "list", "invalidParameterError", "name", "expected", "actual", "nativeError", "native", "context", "require_process", "__commonJSMin", "exports", "module", "isLinux", "report", "getReport", "orig", "require_filesystem", "__commonJSMin", "exports", "module", "fs", "LDD_PATH", "SELF_PATH", "MAX_LENGTH", "readFileSync", "path", "fd", "buffer", "bytesRead", "readFile", "resolve", "reject", "err", "_", "require_elf", "__commonJSMin", "exports", "module", "interpreterPath", "elf", "offset", "size", "count", "headerOffset", "fileOffset", "fileSize", "require_detect_libc", "__commonJSMin", "exports", "module", "childProcess", "isLinux", "getReport", "LDD_PATH", "SELF_PATH", "readFile", "readFileSync", "interpreterPath", "cachedFamilyInterpreter", "cachedFamilyFilesystem", "cachedVersionFilesystem", "command", "commandOut", "safeCommand", "resolve", "err", "out", "safeCommandSync", "GLIBC", "RE_GLIBC_VERSION", "MUSL", "isFileMusl", "f", "familyFromReport", "report", "familyFromCommand", "getconf", "ldd1", "familyFromInterpreterPath", "path", "getFamilyFromLddContent", "content", "familyFromFilesystem", "lddContent", "familyFromFilesystemSync", "familyFromInterpreter", "selfContent", "familyFromInterpreterSync", "family", "familySync", "isNonGlibcLinux", "isNonGlibcLinuxSync", "versionFromFilesystem", "versionMatch", "versionFromFilesystemSync", "versionFromReport", "versionSuffix", "s", "versionFromCommand", "ldd2", "version", "versionSync", "require_debug", "__commonJSMin", "exports", "module", "debug", "args", "require_constants", "__commonJSMin", "exports", "module", "SEMVER_SPEC_VERSION", "MAX_SAFE_INTEGER", "MAX_SAFE_COMPONENT_LENGTH", "MAX_SAFE_BUILD_LENGTH", "RELEASE_TYPES", "require_re", "__commonJSMin", "exports", "module", "MAX_SAFE_COMPONENT_LENGTH", "MAX_SAFE_BUILD_LENGTH", "MAX_LENGTH", "debug", "re", "safeRe", "src", "safeSrc", "t", "R", "LETTERDASHNUMBER", "safeRegexReplacements", "makeSafeRegex", "value", "token", "max", "createToken", "name", "isGlobal", "safe", "index", "require_parse_options", "__commonJSMin", "exports", "module", "looseOption", "emptyOpts", "parseOptions", "options", "require_identifiers", "__commonJSMin", "exports", "module", "numeric", "compareIdentifiers", "a", "b", "anum", "bnum", "rcompareIdentifiers", "require_semver", "__commonJSMin", "exports", "module", "debug", "MAX_LENGTH", "MAX_SAFE_INTEGER", "re", "t", "parseOptions", "compareIdentifiers", "SemVer", "_SemVer", "version", "options", "m", "id", "num", "other", "i", "a", "b", "release", "identifier", "identifierBase", "match", "base", "prerelease", "require_parse", "__commonJSMin", "exports", "module", "SemVer", "parse", "version", "options", "throwErrors", "er", "require_coerce", "__commonJSMin", "exports", "module", "SemVer", "parse", "re", "t", "coerce", "version", "options", "match", "coerceRtlRegex", "next", "major", "minor", "patch", "prerelease", "build", "require_compare", "__commonJSMin", "exports", "module", "SemVer", "compare", "a", "b", "loose", "require_gte", "__commonJSMin", "exports", "module", "compare", "gte", "a", "b", "loose", "require_lrucache", "__commonJSMin", "exports", "module", "LRUCache", "key", "value", "firstKey", "require_eq", "__commonJSMin", "exports", "module", "compare", "eq", "a", "b", "loose", "require_neq", "__commonJSMin", "exports", "module", "compare", "neq", "a", "b", "loose", "require_gt", "__commonJSMin", "exports", "module", "compare", "gt", "a", "b", "loose", "require_lt", "__commonJSMin", "exports", "module", "compare", "lt", "a", "b", "loose", "require_lte", "__commonJSMin", "exports", "module", "compare", "lte", "a", "b", "loose", "require_cmp", "__commonJSMin", "exports", "module", "eq", "neq", "gt", "gte", "lt", "lte", "cmp", "a", "op", "b", "loose", "require_comparator", "__commonJSMin", "exports", "module", "ANY", "Comparator", "_Comparator", "comp", "options", "parseOptions", "debug", "re", "t", "m", "SemVer", "version", "cmp", "Range", "require_range", "__commonJSMin", "exports", "module", "SPACE_CHARACTERS", "Range", "_Range", "range", "options", "parseOptions", "Comparator", "r", "c", "first", "isNullSet", "isAny", "i", "comps", "k", "memoKey", "FLAG_INCLUDE_PRERELEASE", "FLAG_LOOSE", "cached", "cache", "loose", "hr", "re", "t", "hyphenReplace", "debug", "comparatorTrimReplace", "tildeTrimReplace", "caretTrimReplace", "rangeList", "comp", "parseComparator", "replaceGTE0", "rangeMap", "comparators", "result", "thisComparators", "isSatisfiable", "rangeComparators", "thisComparator", "rangeComparator", "version", "SemVer", "testSet", "LRU", "remainingComparators", "testComparator", "otherComparator", "replaceCarets", "replaceTildes", "replaceXRanges", "replaceStars", "isX", "id", "replaceTilde", "_", "M", "m", "p", "pr", "ret", "replaceCaret", "z", "replaceXRange", "gtlt", "xM", "xm", "xp", "anyX", "incPr", "$0", "from", "fM", "fm", "fp", "fpr", "fb", "to", "tM", "tm", "tp", "tpr", "set", "allowed", "require_satisfies", "__commonJSMin", "exports", "module", "Range", "satisfies", "version", "range", "options", "require_package", "__commonJSMin", "exports", "module", "require_libvips", "__commonJSMin", "exports", "module", "spawnSync", "createHash", "semverCoerce", "semverGreaterThanOrEqualTo", "semverSatisfies", "detectLibc", "config", "engines", "optionalDependencies", "minimumLibvipsVersionLabelled", "minimumLibvipsVersion", "prebuiltPlatforms", "spawnSyncOptions", "log", "item", "runtimeLibc", "runtimePlatformArch", "buildPlatformArch", "isEmscripten", "npm_config_arch", "npm_config_platform", "npm_config_libc", "libc", "buildSharpLibvipsIncludeDir", "buildSharpLibvipsCPlusPlusDir", "buildSharpLibvipsLibDir", "isUnsupportedNodeRuntime", "CC", "isRosetta", "sha512", "s", "yarnLocator", "identHash", "npmVersion", "spawnRebuild", "globalLibvipsVersion", "pkgConfigPath", "skipSearch", "status", "reason", "logger", "useGlobalLibvips", "globalVipsVersion", "require_sharp", "__commonJSMin", "exports", "module", "familySync", "versionSync", "runtimePlatformArch", "isUnsupportedNodeRuntime", "prebuiltPlatforms", "minimumLibvipsVersion", "runtimePlatform", "paths", "path", "sharp", "errors", "err", "isLinux", "isMacOs", "isWindows", "os", "help", "messages", "found", "expected", "cpu", "libc", "config", "libcFound", "libcRequires", "require_constructor", "__commonJSMin", "exports", "module", "util", "stream", "is", "debuglog", "queueListener", "queueLength", "Sharp", "input", "options", "warning", "clone", "require_input", "__commonJSMin", "exports", "module", "is", "sharp", "align", "inputStreamParameters", "_inputOptionsFromObject", "obj", "params", "p", "_createInputDescriptor", "input", "inputOptions", "containerOptions", "inputDescriptor", "_write", "chunk", "_encoding", "callback", "_flattenBufferIn", "_isStreamInput", "metadata", "stack", "err", "resolve", "reject", "finished", "stats", "Sharp", "require_resize", "__commonJSMin", "exports", "module", "is", "gravity", "position", "extendWith", "strategy", "kernel", "fit", "mapFitToCanvas", "isRotationExpected", "options", "isResizeExpected", "resize", "widthOrOptions", "height", "canvas", "pos", "extend", "extract", "suffix", "name", "value", "trim", "Sharp", "require_composite", "__commonJSMin", "exports", "module", "is", "blend", "composite", "images", "image", "inputOptions", "Sharp", "require_operation", "__commonJSMin", "exports", "module", "is", "vipsPrecision", "rotate", "angle", "options", "autoOrient", "flip", "flop", "affine", "matrix", "flatMatrix", "sharpen", "flat", "jagged", "median", "size", "blur", "sigma", "dilate", "width", "erode", "flatten", "unflatten", "gamma", "gammaOut", "negate", "normalise", "normalize", "clahe", "convolve", "kernel", "a", "b", "threshold", "boolean", "operand", "operator", "linear", "recomb", "inputMatrix", "recombMatrix", "modulate", "Sharp", "require_color", "__commonJSMin", "exports", "module", "__defProp", "__getOwnPropDesc", "__getOwnPropNames", "__hasOwnProp", "__export", "target", "all", "name", "__copyProps", "to", "from", "except", "desc", "key", "__toCommonJS", "mod", "index_exports", "index_default", "color_name_default", "reverseNames", "cs", "string", "prefix", "value", "model", "abbr", "hex", "rgba", "per", "keyword", "rgb", "match", "i", "hexAlpha", "i2", "clamp", "hsl", "alpha", "h", "s", "l", "a", "hwb", "w", "b", "hexDouble", "r", "g", "hsla", "hwba", "number_", "min", "max", "string_", "color_string_default", "reverseKeywords", "convert", "conversions_default", "LAB_FT", "srgbNonlinearTransform", "c", "cc", "srgbNonlinearTransformInv", "channels", "labels", "delta", "rdif", "gdif", "bdif", "v", "diff", "diffc", "lp", "mp", "sp", "aa", "bb", "k", "m", "y", "comparativeDistance", "x", "reversed", "currentClosestDistance", "currentClosestKeyword", "distance", "z", "xyz", "t3", "t2", "t1", "smin", "lmin", "sv", "hsv", "hi", "f", "p", "q", "t", "vmin", "sl", "wh", "bl", "ratio", "n", "cmyk", "oklab", "ll", "oklch", "lab", "y2", "x2", "z2", "lch", "hr", "args", "saturation", "ansi", "color", "mult", "rem", "colorString", "char", "integer", "chroma", "hue", "grayscale", "hcg", "pure", "mg", "apple", "gray", "buildGraph", "graph", "models2", "length", "deriveBFS", "fromModel", "queue", "current", "adjacents", "adjacent", "node", "link", "wrapConversion", "toModel", "path", "fn", "cur", "route", "conversion", "route_default", "convert2", "models", "wrapRaw", "wrappedFn", "arg0", "wrapRounded", "result", "routes", "routeModels", "color_convert_default", "skippedModels", "hashedModelKeys", "limiters", "Color", "object", "newArray", "zeroArray", "keys", "hashedKeys", "limit", "places", "self", "arguments_", "roundToPlace", "getset", "maxfn", "rgbArray", "alphaHex", "lum", "element", "chan", "color2", "lum1", "lum2", "contrastRatio", "degrees", "mixinColor", "weight", "color1", "w1", "w2", "assertArray", "roundTo", "number", "channel", "modifier", "array", "require_colour", "__commonJSMin", "exports", "module", "require_colour", "__commonJSMin", "exports", "module", "color", "is", "colourspace", "tint", "greyscale", "grayscale", "pipelineColourspace", "pipelineColorspace", "colorspace", "toColourspace", "toColorspace", "_getBackgroundColourOption", "value", "colour", "_setBackgroundColourOption", "key", "Sharp", "require_channel", "__commonJSMin", "exports", "module", "is", "bool", "removeAlpha", "ensureAlpha", "alpha", "extractChannel", "channel", "channelMap", "joinChannel", "images", "options", "image", "bandbool", "boolOp", "Sharp", "require_output", "__commonJSMin", "exports", "module", "path", "is", "sharp", "formats", "jp2Regex", "errJp2Save", "bitdepthFromColourCount", "colours", "toFile", "fileOut", "callback", "err", "stack", "toBuffer", "options", "keepExif", "withExif", "exif", "ifd", "entries", "k", "v", "withExifMerge", "keepIccProfile", "withIccProfile", "icc", "keepXmp", "withXmp", "xmp", "keepMetadata", "withMetadata", "toFormat", "format", "actualFormat", "jpeg", "optimiseCoding", "trellisQuantisation", "optimiseScans", "quantisationTable", "png", "webp", "trySetAnimationOptions", "gif", "jp2", "source", "target", "tiff", "avif", "heif", "jxl", "raw", "tile", "centre", "timeout", "_updateFormatOut", "formatOut", "_setBooleanOption", "key", "val", "_read", "_pipeline", "data", "info", "resolve", "reject", "Sharp", "require_utility", "__commonJSMin", "exports", "module", "events", "detectLibc", "is", "runtimePlatformArch", "sharp", "runtimePlatform", "libvipsVersion", "format", "interpolators", "versions", "cache", "options", "concurrency", "queue", "counters", "simd", "block", "unblock", "Sharp", "require_lib", "__commonJSMin", "exports", "module", "Sharp", "index_exports", "__export", "detectInputType", "generatePalette", "generatePaletteFromDataUri", "generatePaletteFromHex", "generatePaletteFromPath", "generatePaletteFromUrl", "getAlgorithm", "getGameBoyPalette", "listAlgorithms", "registerAlgorithm", "unregisterAlgorithm", "__toCommonJS", "import_promises", "import_node_path", "import_sharp", "signum", "num", "lerp", "start", "stop", "amount", "clampInt", "min", "max", "input", "clampDouble", "sanitizeDegreesInt", "degrees", "sanitizeDegreesDouble", "differenceDegrees", "a", "b", "matrixMultiply", "row", "matrix", "c", "SRGB_TO_XYZ", "XYZ_TO_SRGB", "WHITE_POINT_D65", "argbFromRgb", "red", "green", "blue", "argbFromLinrgb", "linrgb", "r", "delinearized", "g", "b", "alphaFromArgb", "argb", "redFromArgb", "greenFromArgb", "blueFromArgb", "argbFromXyz", "x", "y", "z", "matrix", "XYZ_TO_SRGB", "linearR", "linearG", "linearB", "r", "delinearized", "g", "b", "argbFromRgb", "xyzFromArgb", "argb", "linearized", "redFromArgb", "greenFromArgb", "blueFromArgb", "matrixMultiply", "SRGB_TO_XYZ", "argbFromLab", "l", "a", "whitePoint", "WHITE_POINT_D65", "fy", "fx", "fz", "xNormalized", "labInvf", "yNormalized", "zNormalized", "labFromArgb", "labF", "argbFromLstar", "lstar", "yFromLstar", "component", "lstarFromArgb", "lstarFromY", "rgbComponent", "normalized", "clampInt", "whitePointD65", "labF", "t", "e", "kappa", "labInvf", "ft", "ft3", "ViewingConditions", "_ViewingConditions", "whitePoint", "whitePointD65", "adaptingLuminance", "yFromLstar", "backgroundLstar", "surround", "discountingIlluminant", "xyz", "rW", "gW", "bW", "f", "c", "lerp", "d", "nc", "rgbD", "k", "k4", "k4F", "fl", "n", "z", "nbb", "ncb", "rgbAFactors", "rgbA", "aw", "fLRoot", "Cam16", "_Cam16", "hue", "chroma", "j", "q", "m", "s", "jstar", "astar", "bstar", "other", "dJ", "dA", "dB", "dEPrime", "argb", "ViewingConditions", "viewingConditions", "red", "green", "blue", "redL", "linearized", "greenL", "blueL", "x", "y", "z", "rC", "gC", "bC", "rD", "gD", "bD", "rAF", "gAF", "bAF", "rA", "signum", "gA", "bA", "a", "b", "u", "p2", "atanDegrees", "hueRadians", "ac", "huePrime", "eHue", "t", "alpha", "c", "mstar", "h", "hRad", "p1", "hSin", "hCos", "gamma", "rCBase", "gCBase", "bCBase", "rF", "gF", "bF", "argbFromXyz", "J", "Q", "C", "M", "HctSolver", "_HctSolver", "angle", "rgbComponent", "normalized", "delinearized", "component", "af", "signum", "linrgb", "scaledDiscount", "matrixMultiply", "rA", "gA", "bA", "a", "b", "c", "deltaAB", "deltaAC", "source", "mid", "target", "t", "coordinate", "axis", "x", "y", "n", "kR", "kG", "kB", "coordA", "coordB", "g", "r", "targetHue", "left", "right", "leftHue", "rightHue", "initialized", "uncut", "midHue", "segment", "lPlane", "rPlane", "i", "mPlane", "midPlaneCoordinate", "adapted", "adaptedAbs", "base", "hueRadians", "chroma", "j", "viewingConditions", "ViewingConditions", "tInnerCoeff", "p1", "hSin", "hCos", "iterationRound", "jNormalized", "alpha", "p2", "gamma", "rCScaled", "gCScaled", "bCScaled", "fnj", "argbFromLinrgb", "hueDegrees", "lstar", "argbFromLstar", "sanitizeDegreesDouble", "yFromLstar", "exactAnswer", "Cam16", "Hct", "_Hct", "hue", "chroma", "tone", "HctSolver", "argb", "newHue", "newChroma", "newTone", "cam", "Cam16", "lstarFromArgb", "vc", "viewedInVc", "recastInVc", "ViewingConditions", "lstarFromY", "Contrast", "_Contrast", "toneA", "toneB", "clampDouble", "yFromLstar", "y1", "y2", "lighter", "darker", "tone", "ratio", "darkY", "lightY", "realContrast", "delta", "returnValue", "lstarFromY", "lighterSafe", "darkerSafe", "DislikeAnalyzer", "_DislikeAnalyzer", "hct", "huePasses", "chromaPasses", "tonePasses", "Hct", "DynamicColor", "_DynamicColor", "args", "name", "palette", "tone", "isBackground", "background", "secondBackground", "contrastCurve", "toneDeltaPair", "scheme", "cachedAnswer", "answer", "decreasingContrast", "roleA", "roleB", "delta", "polarity", "stayTogether", "bgTone", "aIsNearer", "nearer", "farther", "amNearer", "expansionDir", "nContrast", "fContrast", "nInitialTone", "nTone", "Contrast", "fInitialTone", "fTone", "clampDouble", "desiredRatio", "bg1", "bg2", "bgTone1", "bgTone2", "upper", "lower", "lightOption", "darkOption", "availables", "ratio", "lighterTone", "darkerTone", "lighterRatio", "darkerRatio", "negligibleDifference", "TonalPalette", "_TonalPalette", "argb", "hct", "Hct", "hue", "chroma", "keyColor", "KeyColor", "tone", "requestedChroma", "lowerTone", "upperTone", "midTone", "isAscending", "ContrastCurve", "low", "normal", "medium", "high", "contrastLevel", "lerp", "ToneDeltaPair", "roleA", "roleB", "delta", "polarity", "stayTogether", "Variant", "isFidelity", "scheme", "Variant", "isMonochrome", "findDesiredChromaByTone", "hue", "chroma", "tone", "byDecreasingTone", "answer", "closestToChroma", "Hct", "chromaPeak", "potentialSolution", "potentialDelta", "currentDelta", "MaterialDynamicColors", "_MaterialDynamicColors", "s", "DynamicColor", "ContrastCurve", "ToneDeltaPair", "initialTone", "proposedHct", "DislikeAnalyzer", "DynamicScheme", "args", "Hct", "TonalPalette", "sourceColor", "hues", "rotations", "sourceHue", "sanitizeDegreesDouble", "size", "i", "thisHue", "nextHue", "dynamicColor", "MaterialDynamicColors", "LabPointProvider", "argb", "labFromArgb", "point", "argbFromLab", "from", "to", "dL", "dA", "dB", "MAX_ITERATIONS", "MIN_MOVEMENT_DISTANCE", "QuantizerWsmeans", "inputPixels", "startingClusters", "maxColors", "pixelToCount", "points", "pixels", "pointProvider", "LabPointProvider", "pointCount", "i", "inputPixel", "pixelCount", "counts", "pixel", "count", "clusterCount", "clusters", "additionalClustersNeeded", "l", "a", "b", "clusterIndices", "indexMatrix", "j", "distanceToIndexMatrix", "DistanceAndIndex", "pixelCountSums", "iteration", "distance", "pointsMoved", "point", "previousClusterIndex", "previousCluster", "previousDistance", "minimumDistance", "newClusterIndex", "componentASums", "componentBSums", "componentCSums", "clusterIndex", "c", "argbToPopulation", "possibleNewCluster", "QuantizerMap", "pixels", "countByColor", "i", "pixel", "alphaFromArgb", "INDEX_BITS", "SIDE_LENGTH", "TOTAL_SIZE", "directions", "QuantizerWu", "weights", "momentsR", "momentsG", "momentsB", "moments", "cubes", "pixels", "maxColors", "createBoxesResult", "countByColor", "QuantizerMap", "pixel", "count", "red", "redFromArgb", "green", "greenFromArgb", "blue", "blueFromArgb", "bitsToRemove", "iR", "iG", "iB", "index", "r", "area", "areaR", "areaG", "areaB", "area2", "g", "line", "lineR", "lineG", "lineB", "line2", "b", "previousIndex", "Box", "volumeVariance", "generatedColorCount", "next", "i", "temp", "j", "CreateBoxesResult", "colorCount", "colors", "cube", "weight", "color", "dr", "dg", "db", "xx", "hypotenuse", "volume", "one", "two", "wholeR", "wholeG", "wholeB", "wholeW", "maxRResult", "maxGResult", "maxBResult", "direction", "maxR", "maxG", "maxB", "first", "last", "bottomR", "bottomG", "bottomB", "bottomW", "max", "cut", "halfR", "halfG", "halfB", "halfW", "tempNumerator", "tempDenominator", "MaximizeResult", "moment", "position", "r0", "r1", "g0", "g1", "b0", "b1", "vol", "requestedCount", "resultCount", "cutLocation", "maximum", "QuantizerCelebi", "pixels", "maxColors", "wuResult", "QuantizerWu", "QuantizerWsmeans", "SchemeExpressive", "_SchemeExpressive", "DynamicScheme", "sourceColorHct", "isDark", "contrastLevel", "Variant", "TonalPalette", "sanitizeDegreesDouble", "SchemeVibrant", "_SchemeVibrant", "DynamicScheme", "sourceColorHct", "isDark", "contrastLevel", "Variant", "TonalPalette", "SCORE_OPTION_DEFAULTS", "compare", "a", "b", "Score", "_Score", "colorsToPopulation", "options", "desired", "fallbackColorARGB", "filter", "colorsHct", "huePopulation", "populationSum", "argb", "population", "hct", "Hct", "hue", "hueExcitedProportions", "proportion", "i", "neighborHue", "sanitizeDegreesInt", "scoredHct", "proportionScore", "chromaWeight", "chromaScore", "score", "chosenColors", "differenceDegrees", "chosenHct", "colors", "hexFromArgb", "argb", "r", "redFromArgb", "g", "greenFromArgb", "b", "blueFromArgb", "outParts", "i", "part", "DEFAULT_ALGORITHM", "algorithmRegistry", "builtInsRegistered", "registerAlgorithm", "name", "generator", "unregisterAlgorithm", "getAlgorithm", "listAlgorithms", "detectInputType", "input", "trimmed", "isHex", "isDataUri", "isUrl", "generatePalette", "options", "type", "generatePaletteFromHex", "generatePaletteFromDataUri", "generatePaletteFromUrl", "generatePaletteFromPath", "hex", "normalizedHex", "normalizeHex", "baseRgb", "hexToRgb", "buildPaletteResultFromBase", "dataUri", "buffer", "decodeDataUri", "buildPaletteResultFromBuffer", "url", "fetchBuffer", "filePath", "resolved", "path", "fs", "inputType", "algorithm", "count", "resolvedAlgorithm", "resolveAlgorithm", "getAverageColor", "baseHex", "rgbToHex", "buildPaletteResult", "rgbToHsl", "buildPaletteHsl", "base", "hue", "normalizeHue", "sat", "clamp", "light", "buildByOffsets", "resolveCount", "buildByCycle", "buildMonochrome", "buildHslPaletteColors", "color", "hslToRgb", "registerBuiltInAlgorithms", "colors", "extractMonetPalette", "resolveMonetCount", "sourceArgb", "argbFromHex", "buildMonetPaletteFromSourceArgb", "extractDominantPalette", "value", "raw", "cleaned", "char", "clean", "g", "b", "argbFromRgb", "toHex", "r", "max", "min", "delta", "h", "l", "s", "c", "x", "m", "channels", "sharp", "data", "info", "pixels", "step", "i", "sampled", "downsamplePixels", "quantized", "QuantizerCelebi", "Score", "entries", "argb", "population", "argbToRgb", "a", "totalCount", "sum", "entry", "coverageTarget", "candidateEntries", "coverage", "maxCount", "seeds", "best", "bestScore", "seed", "rgbDistanceSq", "minDist", "weight", "score", "refineCentroids", "fallback", "buildOffsets", "maxOffset", "offsets", "buildLightOffsets", "offset", "lightStep", "result", "layer", "stride", "hct", "Hct", "palette", "TonalPalette", "buildToneSteps", "tone", "hexFromArgb", "tones", "base64", "response", "arrayBuffer", "dr", "dg", "db", "accum", "bestIndex", "bestDist", "dist", "target", "index", "bucket", "normalized", "getGameBoyPalette"]
4
+ "sourcesContent": ["/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\n/**\n * Is this value defined and not null?\n * @private\n */\nconst defined = (val) => typeof val !== 'undefined' && val !== null;\n\n/**\n * Is this value an object?\n * @private\n */\nconst object = (val) => typeof val === 'object';\n\n/**\n * Is this value a plain object?\n * @private\n */\nconst plainObject = (val) => Object.prototype.toString.call(val) === '[object Object]';\n\n/**\n * Is this value a function?\n * @private\n */\nconst fn = (val) => typeof val === 'function';\n\n/**\n * Is this value a boolean?\n * @private\n */\nconst bool = (val) => typeof val === 'boolean';\n\n/**\n * Is this value a Buffer object?\n * @private\n */\nconst buffer = (val) => val instanceof Buffer;\n\n/**\n * Is this value a typed array object?. E.g. Uint8Array or Uint8ClampedArray?\n * @private\n */\nconst typedArray = (val) => {\n if (defined(val)) {\n switch (val.constructor) {\n case Uint8Array:\n case Uint8ClampedArray:\n case Int8Array:\n case Uint16Array:\n case Int16Array:\n case Uint32Array:\n case Int32Array:\n case Float32Array:\n case Float64Array:\n return true;\n }\n }\n\n return false;\n};\n\n/**\n * Is this value an ArrayBuffer object?\n * @private\n */\nconst arrayBuffer = (val) => val instanceof ArrayBuffer;\n\n/**\n * Is this value a non-empty string?\n * @private\n */\nconst string = (val) => typeof val === 'string' && val.length > 0;\n\n/**\n * Is this value a real number?\n * @private\n */\nconst number = (val) => typeof val === 'number' && !Number.isNaN(val);\n\n/**\n * Is this value an integer?\n * @private\n */\nconst integer = (val) => Number.isInteger(val);\n\n/**\n * Is this value within an inclusive given range?\n * @private\n */\nconst inRange = (val, min, max) => val >= min && val <= max;\n\n/**\n * Is this value within the elements of an array?\n * @private\n */\nconst inArray = (val, list) => list.includes(val);\n\n/**\n * Create an Error with a message relating to an invalid parameter.\n *\n * @param {string} name - parameter name.\n * @param {string} expected - description of the type/value/range expected.\n * @param {*} actual - the value received.\n * @returns {Error} Containing the formatted message.\n * @private\n */\nconst invalidParameterError = (name, expected, actual) => new Error(\n `Expected ${expected} for ${name} but received ${actual} of type ${typeof actual}`\n );\n\n/**\n * Ensures an Error from C++ contains a JS stack.\n *\n * @param {Error} native - Error with message from C++.\n * @param {Error} context - Error with stack from JS.\n * @returns {Error} Error with message and stack.\n * @private\n */\nconst nativeError = (native, context) => {\n context.message = native.message;\n return context;\n};\n\nmodule.exports = {\n defined,\n object,\n plainObject,\n fn,\n bool,\n buffer,\n typedArray,\n arrayBuffer,\n string,\n number,\n integer,\n inRange,\n inArray,\n invalidParameterError,\n nativeError\n};\n", "// Copyright 2017 Lovell Fuller and others.\n// SPDX-License-Identifier: Apache-2.0\n\n'use strict';\n\nconst isLinux = () => process.platform === 'linux';\n\nlet report = null;\nconst getReport = () => {\n if (!report) {\n /* istanbul ignore next */\n if (isLinux() && process.report) {\n const orig = process.report.excludeNetwork;\n process.report.excludeNetwork = true;\n report = process.report.getReport();\n process.report.excludeNetwork = orig;\n } else {\n report = {};\n }\n }\n return report;\n};\n\nmodule.exports = { isLinux, getReport };\n", "// Copyright 2017 Lovell Fuller and others.\n// SPDX-License-Identifier: Apache-2.0\n\n'use strict';\n\nconst fs = require('fs');\n\nconst LDD_PATH = '/usr/bin/ldd';\nconst SELF_PATH = '/proc/self/exe';\nconst MAX_LENGTH = 2048;\n\n/**\n * Read the content of a file synchronous\n *\n * @param {string} path\n * @returns {Buffer}\n */\nconst readFileSync = (path) => {\n const fd = fs.openSync(path, 'r');\n const buffer = Buffer.alloc(MAX_LENGTH);\n const bytesRead = fs.readSync(fd, buffer, 0, MAX_LENGTH, 0);\n fs.close(fd, () => {});\n return buffer.subarray(0, bytesRead);\n};\n\n/**\n * Read the content of a file\n *\n * @param {string} path\n * @returns {Promise<Buffer>}\n */\nconst readFile = (path) => new Promise((resolve, reject) => {\n fs.open(path, 'r', (err, fd) => {\n if (err) {\n reject(err);\n } else {\n const buffer = Buffer.alloc(MAX_LENGTH);\n fs.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {\n resolve(buffer.subarray(0, bytesRead));\n fs.close(fd, () => {});\n });\n }\n });\n});\n\nmodule.exports = {\n LDD_PATH,\n SELF_PATH,\n readFileSync,\n readFile\n};\n", "// Copyright 2017 Lovell Fuller and others.\n// SPDX-License-Identifier: Apache-2.0\n\n'use strict';\n\nconst interpreterPath = (elf) => {\n if (elf.length < 64) {\n return null;\n }\n if (elf.readUInt32BE(0) !== 0x7F454C46) {\n // Unexpected magic bytes\n return null;\n }\n if (elf.readUInt8(4) !== 2) {\n // Not a 64-bit ELF\n return null;\n }\n if (elf.readUInt8(5) !== 1) {\n // Not little-endian\n return null;\n }\n const offset = elf.readUInt32LE(32);\n const size = elf.readUInt16LE(54);\n const count = elf.readUInt16LE(56);\n for (let i = 0; i < count; i++) {\n const headerOffset = offset + (i * size);\n const type = elf.readUInt32LE(headerOffset);\n if (type === 3) {\n const fileOffset = elf.readUInt32LE(headerOffset + 8);\n const fileSize = elf.readUInt32LE(headerOffset + 32);\n return elf.subarray(fileOffset, fileOffset + fileSize).toString().replace(/\\0.*$/g, '');\n }\n }\n return null;\n};\n\nmodule.exports = {\n interpreterPath\n};\n", "// Copyright 2017 Lovell Fuller and others.\n// SPDX-License-Identifier: Apache-2.0\n\n'use strict';\n\nconst childProcess = require('child_process');\nconst { isLinux, getReport } = require('./process');\nconst { LDD_PATH, SELF_PATH, readFile, readFileSync } = require('./filesystem');\nconst { interpreterPath } = require('./elf');\n\nlet cachedFamilyInterpreter;\nlet cachedFamilyFilesystem;\nlet cachedVersionFilesystem;\n\nconst command = 'getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true';\nlet commandOut = '';\n\nconst safeCommand = () => {\n if (!commandOut) {\n return new Promise((resolve) => {\n childProcess.exec(command, (err, out) => {\n commandOut = err ? ' ' : out;\n resolve(commandOut);\n });\n });\n }\n return commandOut;\n};\n\nconst safeCommandSync = () => {\n if (!commandOut) {\n try {\n commandOut = childProcess.execSync(command, { encoding: 'utf8' });\n } catch (_err) {\n commandOut = ' ';\n }\n }\n return commandOut;\n};\n\n/**\n * A String constant containing the value `glibc`.\n * @type {string}\n * @public\n */\nconst GLIBC = 'glibc';\n\n/**\n * A Regexp constant to get the GLIBC Version.\n * @type {string}\n */\nconst RE_GLIBC_VERSION = /LIBC[a-z0-9 \\-).]*?(\\d+\\.\\d+)/i;\n\n/**\n * A String constant containing the value `musl`.\n * @type {string}\n * @public\n */\nconst MUSL = 'musl';\n\nconst isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-');\n\nconst familyFromReport = () => {\n const report = getReport();\n if (report.header && report.header.glibcVersionRuntime) {\n return GLIBC;\n }\n if (Array.isArray(report.sharedObjects)) {\n if (report.sharedObjects.some(isFileMusl)) {\n return MUSL;\n }\n }\n return null;\n};\n\nconst familyFromCommand = (out) => {\n const [getconf, ldd1] = out.split(/[\\r\\n]+/);\n if (getconf && getconf.includes(GLIBC)) {\n return GLIBC;\n }\n if (ldd1 && ldd1.includes(MUSL)) {\n return MUSL;\n }\n return null;\n};\n\nconst familyFromInterpreterPath = (path) => {\n if (path) {\n if (path.includes('/ld-musl-')) {\n return MUSL;\n } else if (path.includes('/ld-linux-')) {\n return GLIBC;\n }\n }\n return null;\n};\n\nconst getFamilyFromLddContent = (content) => {\n content = content.toString();\n if (content.includes('musl')) {\n return MUSL;\n }\n if (content.includes('GNU C Library')) {\n return GLIBC;\n }\n return null;\n};\n\nconst familyFromFilesystem = async () => {\n if (cachedFamilyFilesystem !== undefined) {\n return cachedFamilyFilesystem;\n }\n cachedFamilyFilesystem = null;\n try {\n const lddContent = await readFile(LDD_PATH);\n cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);\n } catch (e) {}\n return cachedFamilyFilesystem;\n};\n\nconst familyFromFilesystemSync = () => {\n if (cachedFamilyFilesystem !== undefined) {\n return cachedFamilyFilesystem;\n }\n cachedFamilyFilesystem = null;\n try {\n const lddContent = readFileSync(LDD_PATH);\n cachedFamilyFilesystem = getFamilyFromLddContent(lddContent);\n } catch (e) {}\n return cachedFamilyFilesystem;\n};\n\nconst familyFromInterpreter = async () => {\n if (cachedFamilyInterpreter !== undefined) {\n return cachedFamilyInterpreter;\n }\n cachedFamilyInterpreter = null;\n try {\n const selfContent = await readFile(SELF_PATH);\n const path = interpreterPath(selfContent);\n cachedFamilyInterpreter = familyFromInterpreterPath(path);\n } catch (e) {}\n return cachedFamilyInterpreter;\n};\n\nconst familyFromInterpreterSync = () => {\n if (cachedFamilyInterpreter !== undefined) {\n return cachedFamilyInterpreter;\n }\n cachedFamilyInterpreter = null;\n try {\n const selfContent = readFileSync(SELF_PATH);\n const path = interpreterPath(selfContent);\n cachedFamilyInterpreter = familyFromInterpreterPath(path);\n } catch (e) {}\n return cachedFamilyInterpreter;\n};\n\n/**\n * Resolves with the libc family when it can be determined, `null` otherwise.\n * @returns {Promise<?string>}\n */\nconst family = async () => {\n let family = null;\n if (isLinux()) {\n family = await familyFromInterpreter();\n if (!family) {\n family = await familyFromFilesystem();\n if (!family) {\n family = familyFromReport();\n }\n if (!family) {\n const out = await safeCommand();\n family = familyFromCommand(out);\n }\n }\n }\n return family;\n};\n\n/**\n * Returns the libc family when it can be determined, `null` otherwise.\n * @returns {?string}\n */\nconst familySync = () => {\n let family = null;\n if (isLinux()) {\n family = familyFromInterpreterSync();\n if (!family) {\n family = familyFromFilesystemSync();\n if (!family) {\n family = familyFromReport();\n }\n if (!family) {\n const out = safeCommandSync();\n family = familyFromCommand(out);\n }\n }\n }\n return family;\n};\n\n/**\n * Resolves `true` only when the platform is Linux and the libc family is not `glibc`.\n * @returns {Promise<boolean>}\n */\nconst isNonGlibcLinux = async () => isLinux() && await family() !== GLIBC;\n\n/**\n * Returns `true` only when the platform is Linux and the libc family is not `glibc`.\n * @returns {boolean}\n */\nconst isNonGlibcLinuxSync = () => isLinux() && familySync() !== GLIBC;\n\nconst versionFromFilesystem = async () => {\n if (cachedVersionFilesystem !== undefined) {\n return cachedVersionFilesystem;\n }\n cachedVersionFilesystem = null;\n try {\n const lddContent = await readFile(LDD_PATH);\n const versionMatch = lddContent.match(RE_GLIBC_VERSION);\n if (versionMatch) {\n cachedVersionFilesystem = versionMatch[1];\n }\n } catch (e) {}\n return cachedVersionFilesystem;\n};\n\nconst versionFromFilesystemSync = () => {\n if (cachedVersionFilesystem !== undefined) {\n return cachedVersionFilesystem;\n }\n cachedVersionFilesystem = null;\n try {\n const lddContent = readFileSync(LDD_PATH);\n const versionMatch = lddContent.match(RE_GLIBC_VERSION);\n if (versionMatch) {\n cachedVersionFilesystem = versionMatch[1];\n }\n } catch (e) {}\n return cachedVersionFilesystem;\n};\n\nconst versionFromReport = () => {\n const report = getReport();\n if (report.header && report.header.glibcVersionRuntime) {\n return report.header.glibcVersionRuntime;\n }\n return null;\n};\n\nconst versionSuffix = (s) => s.trim().split(/\\s+/)[1];\n\nconst versionFromCommand = (out) => {\n const [getconf, ldd1, ldd2] = out.split(/[\\r\\n]+/);\n if (getconf && getconf.includes(GLIBC)) {\n return versionSuffix(getconf);\n }\n if (ldd1 && ldd2 && ldd1.includes(MUSL)) {\n return versionSuffix(ldd2);\n }\n return null;\n};\n\n/**\n * Resolves with the libc version when it can be determined, `null` otherwise.\n * @returns {Promise<?string>}\n */\nconst version = async () => {\n let version = null;\n if (isLinux()) {\n version = await versionFromFilesystem();\n if (!version) {\n version = versionFromReport();\n }\n if (!version) {\n const out = await safeCommand();\n version = versionFromCommand(out);\n }\n }\n return version;\n};\n\n/**\n * Returns the libc version when it can be determined, `null` otherwise.\n * @returns {?string}\n */\nconst versionSync = () => {\n let version = null;\n if (isLinux()) {\n version = versionFromFilesystemSync();\n if (!version) {\n version = versionFromReport();\n }\n if (!version) {\n const out = safeCommandSync();\n version = versionFromCommand(out);\n }\n }\n return version;\n};\n\nmodule.exports = {\n GLIBC,\n MUSL,\n family,\n familySync,\n isNonGlibcLinux,\n isNonGlibcLinuxSync,\n version,\n versionSync\n};\n", "'use strict'\n\nconst debug = (\n typeof process === 'object' &&\n process.env &&\n process.env.NODE_DEBUG &&\n /\\bsemver\\b/i.test(process.env.NODE_DEBUG)\n) ? (...args) => console.error('SEMVER', ...args)\n : () => {}\n\nmodule.exports = debug\n", "'use strict'\n\n// Note: this is the semver.org version of the spec that it implements\n// Not necessarily the package version of this code.\nconst SEMVER_SPEC_VERSION = '2.0.0'\n\nconst MAX_LENGTH = 256\nconst MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||\n/* istanbul ignore next */ 9007199254740991\n\n// Max safe segment length for coercion.\nconst MAX_SAFE_COMPONENT_LENGTH = 16\n\n// Max safe length for a build identifier. The max length minus 6 characters for\n// the shortest version with a build 0.0.0+BUILD.\nconst MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6\n\nconst RELEASE_TYPES = [\n 'major',\n 'premajor',\n 'minor',\n 'preminor',\n 'patch',\n 'prepatch',\n 'prerelease',\n]\n\nmodule.exports = {\n MAX_LENGTH,\n MAX_SAFE_COMPONENT_LENGTH,\n MAX_SAFE_BUILD_LENGTH,\n MAX_SAFE_INTEGER,\n RELEASE_TYPES,\n SEMVER_SPEC_VERSION,\n FLAG_INCLUDE_PRERELEASE: 0b001,\n FLAG_LOOSE: 0b010,\n}\n", "'use strict'\n\nconst {\n MAX_SAFE_COMPONENT_LENGTH,\n MAX_SAFE_BUILD_LENGTH,\n MAX_LENGTH,\n} = require('./constants')\nconst debug = require('./debug')\nexports = module.exports = {}\n\n// The actual regexps go on exports.re\nconst re = exports.re = []\nconst safeRe = exports.safeRe = []\nconst src = exports.src = []\nconst safeSrc = exports.safeSrc = []\nconst t = exports.t = {}\nlet R = 0\n\nconst LETTERDASHNUMBER = '[a-zA-Z0-9-]'\n\n// Replace some greedy regex tokens to prevent regex dos issues. These regex are\n// used internally via the safeRe object since all inputs in this library get\n// normalized first to trim and collapse all extra whitespace. The original\n// regexes are exported for userland consumption and lower level usage. A\n// future breaking change could export the safer regex only with a note that\n// all input should have extra whitespace removed.\nconst safeRegexReplacements = [\n ['\\\\s', 1],\n ['\\\\d', MAX_LENGTH],\n [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],\n]\n\nconst makeSafeRegex = (value) => {\n for (const [token, max] of safeRegexReplacements) {\n value = value\n .split(`${token}*`).join(`${token}{0,${max}}`)\n .split(`${token}+`).join(`${token}{1,${max}}`)\n }\n return value\n}\n\nconst createToken = (name, value, isGlobal) => {\n const safe = makeSafeRegex(value)\n const index = R++\n debug(name, index, value)\n t[name] = index\n src[index] = value\n safeSrc[index] = safe\n re[index] = new RegExp(value, isGlobal ? 'g' : undefined)\n safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)\n}\n\n// The following Regular Expressions can be used for tokenizing,\n// validating, and parsing SemVer version strings.\n\n// ## Numeric Identifier\n// A single `0`, or a non-zero digit followed by zero or more digits.\n\ncreateToken('NUMERICIDENTIFIER', '0|[1-9]\\\\d*')\ncreateToken('NUMERICIDENTIFIERLOOSE', '\\\\d+')\n\n// ## Non-numeric Identifier\n// Zero or more digits, followed by a letter or hyphen, and then zero or\n// more letters, digits, or hyphens.\n\ncreateToken('NONNUMERICIDENTIFIER', `\\\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`)\n\n// ## Main Version\n// Three dot-separated numeric identifiers.\n\ncreateToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIER]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIER]})`)\n\ncreateToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIERLOOSE]})\\\\.` +\n `(${src[t.NUMERICIDENTIFIERLOOSE]})`)\n\n// ## Pre-release Version Identifier\n// A numeric identifier, or a non-numeric identifier.\n// Non-numeric identifiers include numeric identifiers but can be longer.\n// Therefore non-numeric identifiers must go first.\n\ncreateToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]\n}|${src[t.NUMERICIDENTIFIER]})`)\n\ncreateToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]\n}|${src[t.NUMERICIDENTIFIERLOOSE]})`)\n\n// ## Pre-release Version\n// Hyphen, followed by one or more dot-separated pre-release version\n// identifiers.\n\ncreateToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]\n}(?:\\\\.${src[t.PRERELEASEIDENTIFIER]})*))`)\n\ncreateToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]\n}(?:\\\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`)\n\n// ## Build Metadata Identifier\n// Any combination of digits, letters, or hyphens.\n\ncreateToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`)\n\n// ## Build Metadata\n// Plus sign, followed by one or more period-separated build metadata\n// identifiers.\n\ncreateToken('BUILD', `(?:\\\\+(${src[t.BUILDIDENTIFIER]\n}(?:\\\\.${src[t.BUILDIDENTIFIER]})*))`)\n\n// ## Full Version String\n// A main version, followed optionally by a pre-release version and\n// build metadata.\n\n// Note that the only major, minor, patch, and pre-release sections of\n// the version string are capturing groups. The build metadata is not a\n// capturing group, because it should not ever be used in version\n// comparison.\n\ncreateToken('FULLPLAIN', `v?${src[t.MAINVERSION]\n}${src[t.PRERELEASE]}?${\n src[t.BUILD]}?`)\n\ncreateToken('FULL', `^${src[t.FULLPLAIN]}$`)\n\n// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.\n// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty\n// common in the npm registry.\ncreateToken('LOOSEPLAIN', `[v=\\\\s]*${src[t.MAINVERSIONLOOSE]\n}${src[t.PRERELEASELOOSE]}?${\n src[t.BUILD]}?`)\n\ncreateToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)\n\ncreateToken('GTLT', '((?:<|>)?=?)')\n\n// Something like \"2.*\" or \"1.2.x\".\n// Note that \"x.x\" is a valid xRange identifer, meaning \"any version\"\n// Only the first item is strictly required.\ncreateToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\\\*`)\ncreateToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\\\*`)\n\ncreateToken('XRANGEPLAIN', `[v=\\\\s]*(${src[t.XRANGEIDENTIFIER]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIER]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIER]})` +\n `(?:${src[t.PRERELEASE]})?${\n src[t.BUILD]}?` +\n `)?)?`)\n\ncreateToken('XRANGEPLAINLOOSE', `[v=\\\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:\\\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +\n `(?:${src[t.PRERELEASELOOSE]})?${\n src[t.BUILD]}?` +\n `)?)?`)\n\ncreateToken('XRANGE', `^${src[t.GTLT]}\\\\s*${src[t.XRANGEPLAIN]}$`)\ncreateToken('XRANGELOOSE', `^${src[t.GTLT]}\\\\s*${src[t.XRANGEPLAINLOOSE]}$`)\n\n// Coercion.\n// Extract anything that could conceivably be a part of a valid semver\ncreateToken('COERCEPLAIN', `${'(^|[^\\\\d])' +\n '(\\\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +\n `(?:\\\\.(\\\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +\n `(?:\\\\.(\\\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`)\ncreateToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\\\d])`)\ncreateToken('COERCEFULL', src[t.COERCEPLAIN] +\n `(?:${src[t.PRERELEASE]})?` +\n `(?:${src[t.BUILD]})?` +\n `(?:$|[^\\\\d])`)\ncreateToken('COERCERTL', src[t.COERCE], true)\ncreateToken('COERCERTLFULL', src[t.COERCEFULL], true)\n\n// Tilde ranges.\n// Meaning is \"reasonably at or greater than\"\ncreateToken('LONETILDE', '(?:~>?)')\n\ncreateToken('TILDETRIM', `(\\\\s*)${src[t.LONETILDE]}\\\\s+`, true)\nexports.tildeTrimReplace = '$1~'\n\ncreateToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`)\ncreateToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`)\n\n// Caret ranges.\n// Meaning is \"at least and backwards compatible with\"\ncreateToken('LONECARET', '(?:\\\\^)')\n\ncreateToken('CARETTRIM', `(\\\\s*)${src[t.LONECARET]}\\\\s+`, true)\nexports.caretTrimReplace = '$1^'\n\ncreateToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`)\ncreateToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`)\n\n// A simple gt/lt/eq thing, or just \"\" to indicate \"any version\"\ncreateToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\\\s*(${src[t.LOOSEPLAIN]})$|^$`)\ncreateToken('COMPARATOR', `^${src[t.GTLT]}\\\\s*(${src[t.FULLPLAIN]})$|^$`)\n\n// An expression to strip any whitespace between the gtlt and the thing\n// it modifies, so that `> 1.2.3` ==> `>1.2.3`\ncreateToken('COMPARATORTRIM', `(\\\\s*)${src[t.GTLT]\n}\\\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true)\nexports.comparatorTrimReplace = '$1$2$3'\n\n// Something like `1.2.3 - 1.2.4`\n// Note that these all use the loose form, because they'll be\n// checked against either the strict or loose comparator form\n// later.\ncreateToken('HYPHENRANGE', `^\\\\s*(${src[t.XRANGEPLAIN]})` +\n `\\\\s+-\\\\s+` +\n `(${src[t.XRANGEPLAIN]})` +\n `\\\\s*$`)\n\ncreateToken('HYPHENRANGELOOSE', `^\\\\s*(${src[t.XRANGEPLAINLOOSE]})` +\n `\\\\s+-\\\\s+` +\n `(${src[t.XRANGEPLAINLOOSE]})` +\n `\\\\s*$`)\n\n// Star ranges basically just allow anything at all.\ncreateToken('STAR', '(<|>)?=?\\\\s*\\\\*')\n// >=0.0.0 is like a star\ncreateToken('GTE0', '^\\\\s*>=\\\\s*0\\\\.0\\\\.0\\\\s*$')\ncreateToken('GTE0PRE', '^\\\\s*>=\\\\s*0\\\\.0\\\\.0-0\\\\s*$')\n", "'use strict'\n\n// parse out just the options we care about\nconst looseOption = Object.freeze({ loose: true })\nconst emptyOpts = Object.freeze({ })\nconst parseOptions = options => {\n if (!options) {\n return emptyOpts\n }\n\n if (typeof options !== 'object') {\n return looseOption\n }\n\n return options\n}\nmodule.exports = parseOptions\n", "'use strict'\n\nconst numeric = /^[0-9]+$/\nconst compareIdentifiers = (a, b) => {\n if (typeof a === 'number' && typeof b === 'number') {\n return a === b ? 0 : a < b ? -1 : 1\n }\n\n const anum = numeric.test(a)\n const bnum = numeric.test(b)\n\n if (anum && bnum) {\n a = +a\n b = +b\n }\n\n return a === b ? 0\n : (anum && !bnum) ? -1\n : (bnum && !anum) ? 1\n : a < b ? -1\n : 1\n}\n\nconst rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)\n\nmodule.exports = {\n compareIdentifiers,\n rcompareIdentifiers,\n}\n", "'use strict'\n\nconst debug = require('../internal/debug')\nconst { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')\nconst { safeRe: re, t } = require('../internal/re')\n\nconst parseOptions = require('../internal/parse-options')\nconst { compareIdentifiers } = require('../internal/identifiers')\nclass SemVer {\n constructor (version, options) {\n options = parseOptions(options)\n\n if (version instanceof SemVer) {\n if (version.loose === !!options.loose &&\n version.includePrerelease === !!options.includePrerelease) {\n return version\n } else {\n version = version.version\n }\n } else if (typeof version !== 'string') {\n throw new TypeError(`Invalid version. Must be a string. Got type \"${typeof version}\".`)\n }\n\n if (version.length > MAX_LENGTH) {\n throw new TypeError(\n `version is longer than ${MAX_LENGTH} characters`\n )\n }\n\n debug('SemVer', version, options)\n this.options = options\n this.loose = !!options.loose\n // this isn't actually relevant for versions, but keep it so that we\n // don't run into trouble passing this.options around.\n this.includePrerelease = !!options.includePrerelease\n\n const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL])\n\n if (!m) {\n throw new TypeError(`Invalid Version: ${version}`)\n }\n\n this.raw = version\n\n // these are actually numbers\n this.major = +m[1]\n this.minor = +m[2]\n this.patch = +m[3]\n\n if (this.major > MAX_SAFE_INTEGER || this.major < 0) {\n throw new TypeError('Invalid major version')\n }\n\n if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {\n throw new TypeError('Invalid minor version')\n }\n\n if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {\n throw new TypeError('Invalid patch version')\n }\n\n // numberify any prerelease numeric ids\n if (!m[4]) {\n this.prerelease = []\n } else {\n this.prerelease = m[4].split('.').map((id) => {\n if (/^[0-9]+$/.test(id)) {\n const num = +id\n if (num >= 0 && num < MAX_SAFE_INTEGER) {\n return num\n }\n }\n return id\n })\n }\n\n this.build = m[5] ? m[5].split('.') : []\n this.format()\n }\n\n format () {\n this.version = `${this.major}.${this.minor}.${this.patch}`\n if (this.prerelease.length) {\n this.version += `-${this.prerelease.join('.')}`\n }\n return this.version\n }\n\n toString () {\n return this.version\n }\n\n compare (other) {\n debug('SemVer.compare', this.version, this.options, other)\n if (!(other instanceof SemVer)) {\n if (typeof other === 'string' && other === this.version) {\n return 0\n }\n other = new SemVer(other, this.options)\n }\n\n if (other.version === this.version) {\n return 0\n }\n\n return this.compareMain(other) || this.comparePre(other)\n }\n\n compareMain (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n if (this.major < other.major) {\n return -1\n }\n if (this.major > other.major) {\n return 1\n }\n if (this.minor < other.minor) {\n return -1\n }\n if (this.minor > other.minor) {\n return 1\n }\n if (this.patch < other.patch) {\n return -1\n }\n if (this.patch > other.patch) {\n return 1\n }\n return 0\n }\n\n comparePre (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n // NOT having a prerelease is > having one\n if (this.prerelease.length && !other.prerelease.length) {\n return -1\n } else if (!this.prerelease.length && other.prerelease.length) {\n return 1\n } else if (!this.prerelease.length && !other.prerelease.length) {\n return 0\n }\n\n let i = 0\n do {\n const a = this.prerelease[i]\n const b = other.prerelease[i]\n debug('prerelease compare', i, a, b)\n if (a === undefined && b === undefined) {\n return 0\n } else if (b === undefined) {\n return 1\n } else if (a === undefined) {\n return -1\n } else if (a === b) {\n continue\n } else {\n return compareIdentifiers(a, b)\n }\n } while (++i)\n }\n\n compareBuild (other) {\n if (!(other instanceof SemVer)) {\n other = new SemVer(other, this.options)\n }\n\n let i = 0\n do {\n const a = this.build[i]\n const b = other.build[i]\n debug('build compare', i, a, b)\n if (a === undefined && b === undefined) {\n return 0\n } else if (b === undefined) {\n return 1\n } else if (a === undefined) {\n return -1\n } else if (a === b) {\n continue\n } else {\n return compareIdentifiers(a, b)\n }\n } while (++i)\n }\n\n // preminor will bump the version up to the next minor release, and immediately\n // down to pre-release. premajor and prepatch work the same way.\n inc (release, identifier, identifierBase) {\n if (release.startsWith('pre')) {\n if (!identifier && identifierBase === false) {\n throw new Error('invalid increment argument: identifier is empty')\n }\n // Avoid an invalid semver results\n if (identifier) {\n const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE])\n if (!match || match[1] !== identifier) {\n throw new Error(`invalid identifier: ${identifier}`)\n }\n }\n }\n\n switch (release) {\n case 'premajor':\n this.prerelease.length = 0\n this.patch = 0\n this.minor = 0\n this.major++\n this.inc('pre', identifier, identifierBase)\n break\n case 'preminor':\n this.prerelease.length = 0\n this.patch = 0\n this.minor++\n this.inc('pre', identifier, identifierBase)\n break\n case 'prepatch':\n // If this is already a prerelease, it will bump to the next version\n // drop any prereleases that might already exist, since they are not\n // relevant at this point.\n this.prerelease.length = 0\n this.inc('patch', identifier, identifierBase)\n this.inc('pre', identifier, identifierBase)\n break\n // If the input is a non-prerelease version, this acts the same as\n // prepatch.\n case 'prerelease':\n if (this.prerelease.length === 0) {\n this.inc('patch', identifier, identifierBase)\n }\n this.inc('pre', identifier, identifierBase)\n break\n case 'release':\n if (this.prerelease.length === 0) {\n throw new Error(`version ${this.raw} is not a prerelease`)\n }\n this.prerelease.length = 0\n break\n\n case 'major':\n // If this is a pre-major version, bump up to the same major version.\n // Otherwise increment major.\n // 1.0.0-5 bumps to 1.0.0\n // 1.1.0 bumps to 2.0.0\n if (\n this.minor !== 0 ||\n this.patch !== 0 ||\n this.prerelease.length === 0\n ) {\n this.major++\n }\n this.minor = 0\n this.patch = 0\n this.prerelease = []\n break\n case 'minor':\n // If this is a pre-minor version, bump up to the same minor version.\n // Otherwise increment minor.\n // 1.2.0-5 bumps to 1.2.0\n // 1.2.1 bumps to 1.3.0\n if (this.patch !== 0 || this.prerelease.length === 0) {\n this.minor++\n }\n this.patch = 0\n this.prerelease = []\n break\n case 'patch':\n // If this is not a pre-release version, it will increment the patch.\n // If it is a pre-release it will bump up to the same patch version.\n // 1.2.0-5 patches to 1.2.0\n // 1.2.0 patches to 1.2.1\n if (this.prerelease.length === 0) {\n this.patch++\n }\n this.prerelease = []\n break\n // This probably shouldn't be used publicly.\n // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.\n case 'pre': {\n const base = Number(identifierBase) ? 1 : 0\n\n if (this.prerelease.length === 0) {\n this.prerelease = [base]\n } else {\n let i = this.prerelease.length\n while (--i >= 0) {\n if (typeof this.prerelease[i] === 'number') {\n this.prerelease[i]++\n i = -2\n }\n }\n if (i === -1) {\n // didn't increment anything\n if (identifier === this.prerelease.join('.') && identifierBase === false) {\n throw new Error('invalid increment argument: identifier already exists')\n }\n this.prerelease.push(base)\n }\n }\n if (identifier) {\n // 1.2.0-beta.1 bumps to 1.2.0-beta.2,\n // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0\n let prerelease = [identifier, base]\n if (identifierBase === false) {\n prerelease = [identifier]\n }\n if (compareIdentifiers(this.prerelease[0], identifier) === 0) {\n if (isNaN(this.prerelease[1])) {\n this.prerelease = prerelease\n }\n } else {\n this.prerelease = prerelease\n }\n }\n break\n }\n default:\n throw new Error(`invalid increment argument: ${release}`)\n }\n this.raw = this.format()\n if (this.build.length) {\n this.raw += `+${this.build.join('.')}`\n }\n return this\n }\n}\n\nmodule.exports = SemVer\n", "'use strict'\n\nconst SemVer = require('../classes/semver')\nconst parse = (version, options, throwErrors = false) => {\n if (version instanceof SemVer) {\n return version\n }\n try {\n return new SemVer(version, options)\n } catch (er) {\n if (!throwErrors) {\n return null\n }\n throw er\n }\n}\n\nmodule.exports = parse\n", "'use strict'\n\nconst SemVer = require('../classes/semver')\nconst parse = require('./parse')\nconst { safeRe: re, t } = require('../internal/re')\n\nconst coerce = (version, options) => {\n if (version instanceof SemVer) {\n return version\n }\n\n if (typeof version === 'number') {\n version = String(version)\n }\n\n if (typeof version !== 'string') {\n return null\n }\n\n options = options || {}\n\n let match = null\n if (!options.rtl) {\n match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE])\n } else {\n // Find the right-most coercible string that does not share\n // a terminus with a more left-ward coercible string.\n // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'\n // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4'\n //\n // Walk through the string checking with a /g regexp\n // Manually set the index so as to pick up overlapping matches.\n // Stop when we get a match that ends at the string end, since no\n // coercible string can be more right-ward without the same terminus.\n const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL]\n let next\n while ((next = coerceRtlRegex.exec(version)) &&\n (!match || match.index + match[0].length !== version.length)\n ) {\n if (!match ||\n next.index + next[0].length !== match.index + match[0].length) {\n match = next\n }\n coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length\n }\n // leave it in a clean state\n coerceRtlRegex.lastIndex = -1\n }\n\n if (match === null) {\n return null\n }\n\n const major = match[2]\n const minor = match[3] || '0'\n const patch = match[4] || '0'\n const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : ''\n const build = options.includePrerelease && match[6] ? `+${match[6]}` : ''\n\n return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options)\n}\nmodule.exports = coerce\n", "'use strict'\n\nconst SemVer = require('../classes/semver')\nconst compare = (a, b, loose) =>\n new SemVer(a, loose).compare(new SemVer(b, loose))\n\nmodule.exports = compare\n", "'use strict'\n\nconst compare = require('./compare')\nconst gte = (a, b, loose) => compare(a, b, loose) >= 0\nmodule.exports = gte\n", "'use strict'\n\nclass LRUCache {\n constructor () {\n this.max = 1000\n this.map = new Map()\n }\n\n get (key) {\n const value = this.map.get(key)\n if (value === undefined) {\n return undefined\n } else {\n // Remove the key from the map and add it to the end\n this.map.delete(key)\n this.map.set(key, value)\n return value\n }\n }\n\n delete (key) {\n return this.map.delete(key)\n }\n\n set (key, value) {\n const deleted = this.delete(key)\n\n if (!deleted && value !== undefined) {\n // If cache is full, delete the least recently used item\n if (this.map.size >= this.max) {\n const firstKey = this.map.keys().next().value\n this.delete(firstKey)\n }\n\n this.map.set(key, value)\n }\n\n return this\n }\n}\n\nmodule.exports = LRUCache\n", "'use strict'\n\nconst compare = require('./compare')\nconst eq = (a, b, loose) => compare(a, b, loose) === 0\nmodule.exports = eq\n", "'use strict'\n\nconst compare = require('./compare')\nconst neq = (a, b, loose) => compare(a, b, loose) !== 0\nmodule.exports = neq\n", "'use strict'\n\nconst compare = require('./compare')\nconst gt = (a, b, loose) => compare(a, b, loose) > 0\nmodule.exports = gt\n", "'use strict'\n\nconst compare = require('./compare')\nconst lt = (a, b, loose) => compare(a, b, loose) < 0\nmodule.exports = lt\n", "'use strict'\n\nconst compare = require('./compare')\nconst lte = (a, b, loose) => compare(a, b, loose) <= 0\nmodule.exports = lte\n", "'use strict'\n\nconst eq = require('./eq')\nconst neq = require('./neq')\nconst gt = require('./gt')\nconst gte = require('./gte')\nconst lt = require('./lt')\nconst lte = require('./lte')\n\nconst cmp = (a, op, b, loose) => {\n switch (op) {\n case '===':\n if (typeof a === 'object') {\n a = a.version\n }\n if (typeof b === 'object') {\n b = b.version\n }\n return a === b\n\n case '!==':\n if (typeof a === 'object') {\n a = a.version\n }\n if (typeof b === 'object') {\n b = b.version\n }\n return a !== b\n\n case '':\n case '=':\n case '==':\n return eq(a, b, loose)\n\n case '!=':\n return neq(a, b, loose)\n\n case '>':\n return gt(a, b, loose)\n\n case '>=':\n return gte(a, b, loose)\n\n case '<':\n return lt(a, b, loose)\n\n case '<=':\n return lte(a, b, loose)\n\n default:\n throw new TypeError(`Invalid operator: ${op}`)\n }\n}\nmodule.exports = cmp\n", "'use strict'\n\nconst ANY = Symbol('SemVer ANY')\n// hoisted class for cyclic dependency\nclass Comparator {\n static get ANY () {\n return ANY\n }\n\n constructor (comp, options) {\n options = parseOptions(options)\n\n if (comp instanceof Comparator) {\n if (comp.loose === !!options.loose) {\n return comp\n } else {\n comp = comp.value\n }\n }\n\n comp = comp.trim().split(/\\s+/).join(' ')\n debug('comparator', comp, options)\n this.options = options\n this.loose = !!options.loose\n this.parse(comp)\n\n if (this.semver === ANY) {\n this.value = ''\n } else {\n this.value = this.operator + this.semver.version\n }\n\n debug('comp', this)\n }\n\n parse (comp) {\n const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]\n const m = comp.match(r)\n\n if (!m) {\n throw new TypeError(`Invalid comparator: ${comp}`)\n }\n\n this.operator = m[1] !== undefined ? m[1] : ''\n if (this.operator === '=') {\n this.operator = ''\n }\n\n // if it literally is just '>' or '' then allow anything.\n if (!m[2]) {\n this.semver = ANY\n } else {\n this.semver = new SemVer(m[2], this.options.loose)\n }\n }\n\n toString () {\n return this.value\n }\n\n test (version) {\n debug('Comparator.test', version, this.options.loose)\n\n if (this.semver === ANY || version === ANY) {\n return true\n }\n\n if (typeof version === 'string') {\n try {\n version = new SemVer(version, this.options)\n } catch (er) {\n return false\n }\n }\n\n return cmp(version, this.operator, this.semver, this.options)\n }\n\n intersects (comp, options) {\n if (!(comp instanceof Comparator)) {\n throw new TypeError('a Comparator is required')\n }\n\n if (this.operator === '') {\n if (this.value === '') {\n return true\n }\n return new Range(comp.value, options).test(this.value)\n } else if (comp.operator === '') {\n if (comp.value === '') {\n return true\n }\n return new Range(this.value, options).test(comp.semver)\n }\n\n options = parseOptions(options)\n\n // Special cases where nothing can possibly be lower\n if (options.includePrerelease &&\n (this.value === '<0.0.0-0' || comp.value === '<0.0.0-0')) {\n return false\n }\n if (!options.includePrerelease &&\n (this.value.startsWith('<0.0.0') || comp.value.startsWith('<0.0.0'))) {\n return false\n }\n\n // Same direction increasing (> or >=)\n if (this.operator.startsWith('>') && comp.operator.startsWith('>')) {\n return true\n }\n // Same direction decreasing (< or <=)\n if (this.operator.startsWith('<') && comp.operator.startsWith('<')) {\n return true\n }\n // same SemVer and both sides are inclusive (<= or >=)\n if (\n (this.semver.version === comp.semver.version) &&\n this.operator.includes('=') && comp.operator.includes('=')) {\n return true\n }\n // opposite directions less than\n if (cmp(this.semver, '<', comp.semver, options) &&\n this.operator.startsWith('>') && comp.operator.startsWith('<')) {\n return true\n }\n // opposite directions greater than\n if (cmp(this.semver, '>', comp.semver, options) &&\n this.operator.startsWith('<') && comp.operator.startsWith('>')) {\n return true\n }\n return false\n }\n}\n\nmodule.exports = Comparator\n\nconst parseOptions = require('../internal/parse-options')\nconst { safeRe: re, t } = require('../internal/re')\nconst cmp = require('../functions/cmp')\nconst debug = require('../internal/debug')\nconst SemVer = require('./semver')\nconst Range = require('./range')\n", "'use strict'\n\nconst SPACE_CHARACTERS = /\\s+/g\n\n// hoisted class for cyclic dependency\nclass Range {\n constructor (range, options) {\n options = parseOptions(options)\n\n if (range instanceof Range) {\n if (\n range.loose === !!options.loose &&\n range.includePrerelease === !!options.includePrerelease\n ) {\n return range\n } else {\n return new Range(range.raw, options)\n }\n }\n\n if (range instanceof Comparator) {\n // just put it in the set and return\n this.raw = range.value\n this.set = [[range]]\n this.formatted = undefined\n return this\n }\n\n this.options = options\n this.loose = !!options.loose\n this.includePrerelease = !!options.includePrerelease\n\n // First reduce all whitespace as much as possible so we do not have to rely\n // on potentially slow regexes like \\s*. This is then stored and used for\n // future error messages as well.\n this.raw = range.trim().replace(SPACE_CHARACTERS, ' ')\n\n // First, split on ||\n this.set = this.raw\n .split('||')\n // map the range to a 2d array of comparators\n .map(r => this.parseRange(r.trim()))\n // throw out any comparator lists that are empty\n // this generally means that it was not a valid range, which is allowed\n // in loose mode, but will still throw if the WHOLE range is invalid.\n .filter(c => c.length)\n\n if (!this.set.length) {\n throw new TypeError(`Invalid SemVer Range: ${this.raw}`)\n }\n\n // if we have any that are not the null set, throw out null sets.\n if (this.set.length > 1) {\n // keep the first one, in case they're all null sets\n const first = this.set[0]\n this.set = this.set.filter(c => !isNullSet(c[0]))\n if (this.set.length === 0) {\n this.set = [first]\n } else if (this.set.length > 1) {\n // if we have any that are *, then the range is just *\n for (const c of this.set) {\n if (c.length === 1 && isAny(c[0])) {\n this.set = [c]\n break\n }\n }\n }\n }\n\n this.formatted = undefined\n }\n\n get range () {\n if (this.formatted === undefined) {\n this.formatted = ''\n for (let i = 0; i < this.set.length; i++) {\n if (i > 0) {\n this.formatted += '||'\n }\n const comps = this.set[i]\n for (let k = 0; k < comps.length; k++) {\n if (k > 0) {\n this.formatted += ' '\n }\n this.formatted += comps[k].toString().trim()\n }\n }\n }\n return this.formatted\n }\n\n format () {\n return this.range\n }\n\n toString () {\n return this.range\n }\n\n parseRange (range) {\n // memoize range parsing for performance.\n // this is a very hot path, and fully deterministic.\n const memoOpts =\n (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) |\n (this.options.loose && FLAG_LOOSE)\n const memoKey = memoOpts + ':' + range\n const cached = cache.get(memoKey)\n if (cached) {\n return cached\n }\n\n const loose = this.options.loose\n // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`\n const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]\n range = range.replace(hr, hyphenReplace(this.options.includePrerelease))\n debug('hyphen replace', range)\n\n // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`\n range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)\n debug('comparator trim', range)\n\n // `~ 1.2.3` => `~1.2.3`\n range = range.replace(re[t.TILDETRIM], tildeTrimReplace)\n debug('tilde trim', range)\n\n // `^ 1.2.3` => `^1.2.3`\n range = range.replace(re[t.CARETTRIM], caretTrimReplace)\n debug('caret trim', range)\n\n // At this point, the range is completely trimmed and\n // ready to be split into comparators.\n\n let rangeList = range\n .split(' ')\n .map(comp => parseComparator(comp, this.options))\n .join(' ')\n .split(/\\s+/)\n // >=0.0.0 is equivalent to *\n .map(comp => replaceGTE0(comp, this.options))\n\n if (loose) {\n // in loose mode, throw out any that are not valid comparators\n rangeList = rangeList.filter(comp => {\n debug('loose invalid filter', comp, this.options)\n return !!comp.match(re[t.COMPARATORLOOSE])\n })\n }\n debug('range list', rangeList)\n\n // if any comparators are the null set, then replace with JUST null set\n // if more than one comparator, remove any * comparators\n // also, don't include the same comparator more than once\n const rangeMap = new Map()\n const comparators = rangeList.map(comp => new Comparator(comp, this.options))\n for (const comp of comparators) {\n if (isNullSet(comp)) {\n return [comp]\n }\n rangeMap.set(comp.value, comp)\n }\n if (rangeMap.size > 1 && rangeMap.has('')) {\n rangeMap.delete('')\n }\n\n const result = [...rangeMap.values()]\n cache.set(memoKey, result)\n return result\n }\n\n intersects (range, options) {\n if (!(range instanceof Range)) {\n throw new TypeError('a Range is required')\n }\n\n return this.set.some((thisComparators) => {\n return (\n isSatisfiable(thisComparators, options) &&\n range.set.some((rangeComparators) => {\n return (\n isSatisfiable(rangeComparators, options) &&\n thisComparators.every((thisComparator) => {\n return rangeComparators.every((rangeComparator) => {\n return thisComparator.intersects(rangeComparator, options)\n })\n })\n )\n })\n )\n })\n }\n\n // if ANY of the sets match ALL of its comparators, then pass\n test (version) {\n if (!version) {\n return false\n }\n\n if (typeof version === 'string') {\n try {\n version = new SemVer(version, this.options)\n } catch (er) {\n return false\n }\n }\n\n for (let i = 0; i < this.set.length; i++) {\n if (testSet(this.set[i], version, this.options)) {\n return true\n }\n }\n return false\n }\n}\n\nmodule.exports = Range\n\nconst LRU = require('../internal/lrucache')\nconst cache = new LRU()\n\nconst parseOptions = require('../internal/parse-options')\nconst Comparator = require('./comparator')\nconst debug = require('../internal/debug')\nconst SemVer = require('./semver')\nconst {\n safeRe: re,\n t,\n comparatorTrimReplace,\n tildeTrimReplace,\n caretTrimReplace,\n} = require('../internal/re')\nconst { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require('../internal/constants')\n\nconst isNullSet = c => c.value === '<0.0.0-0'\nconst isAny = c => c.value === ''\n\n// take a set of comparators and determine whether there\n// exists a version which can satisfy it\nconst isSatisfiable = (comparators, options) => {\n let result = true\n const remainingComparators = comparators.slice()\n let testComparator = remainingComparators.pop()\n\n while (result && remainingComparators.length) {\n result = remainingComparators.every((otherComparator) => {\n return testComparator.intersects(otherComparator, options)\n })\n\n testComparator = remainingComparators.pop()\n }\n\n return result\n}\n\n// comprised of xranges, tildes, stars, and gtlt's at this point.\n// already replaced the hyphen ranges\n// turn into a set of JUST comparators.\nconst parseComparator = (comp, options) => {\n comp = comp.replace(re[t.BUILD], '')\n debug('comp', comp, options)\n comp = replaceCarets(comp, options)\n debug('caret', comp)\n comp = replaceTildes(comp, options)\n debug('tildes', comp)\n comp = replaceXRanges(comp, options)\n debug('xrange', comp)\n comp = replaceStars(comp, options)\n debug('stars', comp)\n return comp\n}\n\nconst isX = id => !id || id.toLowerCase() === 'x' || id === '*'\n\n// ~, ~> --> * (any, kinda silly)\n// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0\n// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0\n// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0\n// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0\n// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0\n// ~0.0.1 --> >=0.0.1 <0.1.0-0\nconst replaceTildes = (comp, options) => {\n return comp\n .trim()\n .split(/\\s+/)\n .map((c) => replaceTilde(c, options))\n .join(' ')\n}\n\nconst replaceTilde = (comp, options) => {\n const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]\n return comp.replace(r, (_, M, m, p, pr) => {\n debug('tilde', comp, _, M, m, p, pr)\n let ret\n\n if (isX(M)) {\n ret = ''\n } else if (isX(m)) {\n ret = `>=${M}.0.0 <${+M + 1}.0.0-0`\n } else if (isX(p)) {\n // ~1.2 == >=1.2.0 <1.3.0-0\n ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`\n } else if (pr) {\n debug('replaceTilde pr', pr)\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${+m + 1}.0-0`\n } else {\n // ~1.2.3 == >=1.2.3 <1.3.0-0\n ret = `>=${M}.${m}.${p\n } <${M}.${+m + 1}.0-0`\n }\n\n debug('tilde return', ret)\n return ret\n })\n}\n\n// ^ --> * (any, kinda silly)\n// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0\n// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0\n// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0\n// ^1.2.3 --> >=1.2.3 <2.0.0-0\n// ^1.2.0 --> >=1.2.0 <2.0.0-0\n// ^0.0.1 --> >=0.0.1 <0.0.2-0\n// ^0.1.0 --> >=0.1.0 <0.2.0-0\nconst replaceCarets = (comp, options) => {\n return comp\n .trim()\n .split(/\\s+/)\n .map((c) => replaceCaret(c, options))\n .join(' ')\n}\n\nconst replaceCaret = (comp, options) => {\n debug('caret', comp, options)\n const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]\n const z = options.includePrerelease ? '-0' : ''\n return comp.replace(r, (_, M, m, p, pr) => {\n debug('caret', comp, _, M, m, p, pr)\n let ret\n\n if (isX(M)) {\n ret = ''\n } else if (isX(m)) {\n ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`\n } else if (isX(p)) {\n if (M === '0') {\n ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`\n } else {\n ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`\n }\n } else if (pr) {\n debug('replaceCaret pr', pr)\n if (M === '0') {\n if (m === '0') {\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${m}.${+p + 1}-0`\n } else {\n ret = `>=${M}.${m}.${p}-${pr\n } <${M}.${+m + 1}.0-0`\n }\n } else {\n ret = `>=${M}.${m}.${p}-${pr\n } <${+M + 1}.0.0-0`\n }\n } else {\n debug('no pr')\n if (M === '0') {\n if (m === '0') {\n ret = `>=${M}.${m}.${p\n }${z} <${M}.${m}.${+p + 1}-0`\n } else {\n ret = `>=${M}.${m}.${p\n }${z} <${M}.${+m + 1}.0-0`\n }\n } else {\n ret = `>=${M}.${m}.${p\n } <${+M + 1}.0.0-0`\n }\n }\n\n debug('caret return', ret)\n return ret\n })\n}\n\nconst replaceXRanges = (comp, options) => {\n debug('replaceXRanges', comp, options)\n return comp\n .split(/\\s+/)\n .map((c) => replaceXRange(c, options))\n .join(' ')\n}\n\nconst replaceXRange = (comp, options) => {\n comp = comp.trim()\n const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]\n return comp.replace(r, (ret, gtlt, M, m, p, pr) => {\n debug('xRange', comp, ret, gtlt, M, m, p, pr)\n const xM = isX(M)\n const xm = xM || isX(m)\n const xp = xm || isX(p)\n const anyX = xp\n\n if (gtlt === '=' && anyX) {\n gtlt = ''\n }\n\n // if we're including prereleases in the match, then we need\n // to fix this to -0, the lowest possible prerelease value\n pr = options.includePrerelease ? '-0' : ''\n\n if (xM) {\n if (gtlt === '>' || gtlt === '<') {\n // nothing is allowed\n ret = '<0.0.0-0'\n } else {\n // nothing is forbidden\n ret = '*'\n }\n } else if (gtlt && anyX) {\n // we know patch is an x, because we have any x at all.\n // replace X with 0\n if (xm) {\n m = 0\n }\n p = 0\n\n if (gtlt === '>') {\n // >1 => >=2.0.0\n // >1.2 => >=1.3.0\n gtlt = '>='\n if (xm) {\n M = +M + 1\n m = 0\n p = 0\n } else {\n m = +m + 1\n p = 0\n }\n } else if (gtlt === '<=') {\n // <=0.7.x is actually <0.8.0, since any 0.7.x should\n // pass. Similarly, <=7.x is actually <8.0.0, etc.\n gtlt = '<'\n if (xm) {\n M = +M + 1\n } else {\n m = +m + 1\n }\n }\n\n if (gtlt === '<') {\n pr = '-0'\n }\n\n ret = `${gtlt + M}.${m}.${p}${pr}`\n } else if (xm) {\n ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`\n } else if (xp) {\n ret = `>=${M}.${m}.0${pr\n } <${M}.${+m + 1}.0-0`\n }\n\n debug('xRange return', ret)\n\n return ret\n })\n}\n\n// Because * is AND-ed with everything else in the comparator,\n// and '' means \"any version\", just remove the *s entirely.\nconst replaceStars = (comp, options) => {\n debug('replaceStars', comp, options)\n // Looseness is ignored here. star is always as loose as it gets!\n return comp\n .trim()\n .replace(re[t.STAR], '')\n}\n\nconst replaceGTE0 = (comp, options) => {\n debug('replaceGTE0', comp, options)\n return comp\n .trim()\n .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')\n}\n\n// This function is passed to string.replace(re[t.HYPHENRANGE])\n// M, m, patch, prerelease, build\n// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5\n// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do\n// 1.2 - 3.4 => >=1.2.0 <3.5.0-0\n// TODO build?\nconst hyphenReplace = incPr => ($0,\n from, fM, fm, fp, fpr, fb,\n to, tM, tm, tp, tpr) => {\n if (isX(fM)) {\n from = ''\n } else if (isX(fm)) {\n from = `>=${fM}.0.0${incPr ? '-0' : ''}`\n } else if (isX(fp)) {\n from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`\n } else if (fpr) {\n from = `>=${from}`\n } else {\n from = `>=${from}${incPr ? '-0' : ''}`\n }\n\n if (isX(tM)) {\n to = ''\n } else if (isX(tm)) {\n to = `<${+tM + 1}.0.0-0`\n } else if (isX(tp)) {\n to = `<${tM}.${+tm + 1}.0-0`\n } else if (tpr) {\n to = `<=${tM}.${tm}.${tp}-${tpr}`\n } else if (incPr) {\n to = `<${tM}.${tm}.${+tp + 1}-0`\n } else {\n to = `<=${to}`\n }\n\n return `${from} ${to}`.trim()\n}\n\nconst testSet = (set, version, options) => {\n for (let i = 0; i < set.length; i++) {\n if (!set[i].test(version)) {\n return false\n }\n }\n\n if (version.prerelease.length && !options.includePrerelease) {\n // Find the set of versions that are allowed to have prereleases\n // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0\n // That should allow `1.2.3-pr.2` to pass.\n // However, `1.2.4-alpha.notready` should NOT be allowed,\n // even though it's within the range set by the comparators.\n for (let i = 0; i < set.length; i++) {\n debug(set[i].semver)\n if (set[i].semver === Comparator.ANY) {\n continue\n }\n\n if (set[i].semver.prerelease.length > 0) {\n const allowed = set[i].semver\n if (allowed.major === version.major &&\n allowed.minor === version.minor &&\n allowed.patch === version.patch) {\n return true\n }\n }\n }\n\n // Version has a -pre, but it's not one of the ones we like.\n return false\n }\n\n return true\n}\n", "'use strict'\n\nconst Range = require('../classes/range')\nconst satisfies = (version, range, options) => {\n try {\n range = new Range(range, options)\n } catch (er) {\n return false\n }\n return range.test(version)\n}\nmodule.exports = satisfies\n", "{\n \"name\": \"sharp\",\n \"description\": \"High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images\",\n \"version\": \"0.34.5\",\n \"author\": \"Lovell Fuller <npm@lovell.info>\",\n \"homepage\": \"https://sharp.pixelplumbing.com\",\n \"contributors\": [\n \"Pierre Inglebert <pierre.inglebert@gmail.com>\",\n \"Jonathan Ong <jonathanrichardong@gmail.com>\",\n \"Chanon Sajjamanochai <chanon.s@gmail.com>\",\n \"Juliano Julio <julianojulio@gmail.com>\",\n \"Daniel Gasienica <daniel@gasienica.ch>\",\n \"Julian Walker <julian@fiftythree.com>\",\n \"Amit Pitaru <pitaru.amit@gmail.com>\",\n \"Brandon Aaron <hello.brandon@aaron.sh>\",\n \"Andreas Lind <andreas@one.com>\",\n \"Maurus Cuelenaere <mcuelenaere@gmail.com>\",\n \"Linus Unneb\u00E4ck <linus@folkdatorn.se>\",\n \"Victor Mateevitsi <mvictoras@gmail.com>\",\n \"Alaric Holloway <alaric.holloway@gmail.com>\",\n \"Bernhard K. Weisshuhn <bkw@codingforce.com>\",\n \"Chris Riley <criley@primedia.com>\",\n \"David Carley <dacarley@gmail.com>\",\n \"John Tobin <john@limelightmobileinc.com>\",\n \"Kenton Gray <kentongray@gmail.com>\",\n \"Felix B\u00FCnemann <Felix.Buenemann@gmail.com>\",\n \"Samy Al Zahrani <samyalzahrany@gmail.com>\",\n \"Chintan Thakkar <lemnisk8@gmail.com>\",\n \"F. Orlando Galashan <frulo@gmx.de>\",\n \"Kleis Auke Wolthuizen <info@kleisauke.nl>\",\n \"Matt Hirsch <mhirsch@media.mit.edu>\",\n \"Matthias Thoemmes <thoemmes@gmail.com>\",\n \"Patrick Paskaris <patrick@paskaris.gr>\",\n \"J\u00E9r\u00E9my Lal <kapouer@melix.org>\",\n \"Rahul Nanwani <r.nanwani@gmail.com>\",\n \"Alice Monday <alice0meta@gmail.com>\",\n \"Kristo Jorgenson <kristo.jorgenson@gmail.com>\",\n \"YvesBos <yves_bos@outlook.com>\",\n \"Guy Maliar <guy@tailorbrands.com>\",\n \"Nicolas Coden <nicolas@ncoden.fr>\",\n \"Matt Parrish <matt.r.parrish@gmail.com>\",\n \"Marcel Bretschneider <marcel.bretschneider@gmail.com>\",\n \"Matthew McEachen <matthew+github@mceachen.org>\",\n \"Jarda Kot\u011B\u0161ovec <jarda.kotesovec@gmail.com>\",\n \"Kenric D'Souza <kenric.dsouza@gmail.com>\",\n \"Oleh Aleinyk <oleg.aleynik@gmail.com>\",\n \"Marcel Bretschneider <marcel.bretschneider@gmail.com>\",\n \"Andrea Bianco <andrea.bianco@unibas.ch>\",\n \"Rik Heywood <rik@rik.org>\",\n \"Thomas Parisot <hi@oncletom.io>\",\n \"Nathan Graves <nathanrgraves+github@gmail.com>\",\n \"Tom Lokhorst <tom@lokhorst.eu>\",\n \"Espen Hovlandsdal <espen@hovlandsdal.com>\",\n \"Sylvain Dumont <sylvain.dumont35@gmail.com>\",\n \"Alun Davies <alun.owain.davies@googlemail.com>\",\n \"Aidan Hoolachan <ajhoolachan21@gmail.com>\",\n \"Axel Eirola <axel.eirola@iki.fi>\",\n \"Freezy <freezy@xbmc.org>\",\n \"Daiz <taneli.vatanen@gmail.com>\",\n \"Julian Aubourg <j@ubourg.net>\",\n \"Keith Belovay <keith@picthrive.com>\",\n \"Michael B. Klein <mbklein@gmail.com>\",\n \"Jordan Prudhomme <jordan@raboland.fr>\",\n \"Ilya Ovdin <iovdin@gmail.com>\",\n \"Andargor <andargor@yahoo.com>\",\n \"Paul Neave <paul.neave@gmail.com>\",\n \"Brendan Kennedy <brenwken@gmail.com>\",\n \"Brychan Bennett-Odlum <git@brychan.io>\",\n \"Edward Silverton <e.silverton@gmail.com>\",\n \"Roman Malieiev <aromaleev@gmail.com>\",\n \"Tomas Szabo <tomas.szabo@deftomat.com>\",\n \"Robert O'Rourke <robert@o-rourke.org>\",\n \"Guillermo Alfonso Varela Chouci\u00F1o <guillevch@gmail.com>\",\n \"Christian Flintrup <chr@gigahost.dk>\",\n \"Manan Jadhav <manan@motionden.com>\",\n \"Leon Radley <leon@radley.se>\",\n \"alza54 <alza54@thiocod.in>\",\n \"Jacob Smith <jacob@frende.me>\",\n \"Michael Nutt <michael@nutt.im>\",\n \"Brad Parham <baparham@gmail.com>\",\n \"Taneli Vatanen <taneli.vatanen@gmail.com>\",\n \"Joris Dugu\u00E9 <zaruike10@gmail.com>\",\n \"Chris Banks <christopher.bradley.banks@gmail.com>\",\n \"Ompal Singh <ompal.hitm09@gmail.com>\",\n \"Brodan <christopher.hranj@gmail.com>\",\n \"Ankur Parihar <ankur.github@gmail.com>\",\n \"Brahim Ait elhaj <brahima@gmail.com>\",\n \"Mart Jansink <m.jansink@gmail.com>\",\n \"Lachlan Newman <lachnewman007@gmail.com>\",\n \"Dennis Beatty <dennis@dcbeatty.com>\",\n \"Ingvar Stepanyan <me@rreverser.com>\",\n \"Don Denton <don@happycollision.com>\"\n ],\n \"scripts\": {\n \"build\": \"node install/build.js\",\n \"install\": \"node install/check.js || npm run build\",\n \"clean\": \"rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*\",\n \"test\": \"npm run lint && npm run test-unit\",\n \"lint\": \"npm run lint-cpp && npm run lint-js && npm run lint-types\",\n \"lint-cpp\": \"cpplint --quiet src/*.h src/*.cc\",\n \"lint-js\": \"biome lint\",\n \"lint-types\": \"tsd --files ./test/types/sharp.test-d.ts\",\n \"test-leak\": \"./test/leak/leak.sh\",\n \"test-unit\": \"node --experimental-test-coverage test/unit.mjs\",\n \"package-from-local-build\": \"node npm/from-local-build.js\",\n \"package-release-notes\": \"node npm/release-notes.js\",\n \"docs-build\": \"node docs/build.mjs\",\n \"docs-serve\": \"cd docs && npm start\",\n \"docs-publish\": \"cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp\"\n },\n \"type\": \"commonjs\",\n \"main\": \"lib/index.js\",\n \"types\": \"lib/index.d.ts\",\n \"files\": [\n \"install\",\n \"lib\",\n \"src/*.{cc,h,gyp}\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git://github.com/lovell/sharp.git\"\n },\n \"keywords\": [\n \"jpeg\",\n \"png\",\n \"webp\",\n \"avif\",\n \"tiff\",\n \"gif\",\n \"svg\",\n \"jp2\",\n \"dzi\",\n \"image\",\n \"resize\",\n \"thumbnail\",\n \"crop\",\n \"embed\",\n \"libvips\",\n \"vips\"\n ],\n \"dependencies\": {\n \"@img/colour\": \"^1.0.0\",\n \"detect-libc\": \"^2.1.2\",\n \"semver\": \"^7.7.3\"\n },\n \"optionalDependencies\": {\n \"@img/sharp-darwin-arm64\": \"0.34.5\",\n \"@img/sharp-darwin-x64\": \"0.34.5\",\n \"@img/sharp-libvips-darwin-arm64\": \"1.2.4\",\n \"@img/sharp-libvips-darwin-x64\": \"1.2.4\",\n \"@img/sharp-libvips-linux-arm\": \"1.2.4\",\n \"@img/sharp-libvips-linux-arm64\": \"1.2.4\",\n \"@img/sharp-libvips-linux-ppc64\": \"1.2.4\",\n \"@img/sharp-libvips-linux-riscv64\": \"1.2.4\",\n \"@img/sharp-libvips-linux-s390x\": \"1.2.4\",\n \"@img/sharp-libvips-linux-x64\": \"1.2.4\",\n \"@img/sharp-libvips-linuxmusl-arm64\": \"1.2.4\",\n \"@img/sharp-libvips-linuxmusl-x64\": \"1.2.4\",\n \"@img/sharp-linux-arm\": \"0.34.5\",\n \"@img/sharp-linux-arm64\": \"0.34.5\",\n \"@img/sharp-linux-ppc64\": \"0.34.5\",\n \"@img/sharp-linux-riscv64\": \"0.34.5\",\n \"@img/sharp-linux-s390x\": \"0.34.5\",\n \"@img/sharp-linux-x64\": \"0.34.5\",\n \"@img/sharp-linuxmusl-arm64\": \"0.34.5\",\n \"@img/sharp-linuxmusl-x64\": \"0.34.5\",\n \"@img/sharp-wasm32\": \"0.34.5\",\n \"@img/sharp-win32-arm64\": \"0.34.5\",\n \"@img/sharp-win32-ia32\": \"0.34.5\",\n \"@img/sharp-win32-x64\": \"0.34.5\"\n },\n \"devDependencies\": {\n \"@biomejs/biome\": \"^2.3.4\",\n \"@cpplint/cli\": \"^0.1.0\",\n \"@emnapi/runtime\": \"^1.7.0\",\n \"@img/sharp-libvips-dev\": \"1.2.4\",\n \"@img/sharp-libvips-dev-wasm32\": \"1.2.4\",\n \"@img/sharp-libvips-win32-arm64\": \"1.2.4\",\n \"@img/sharp-libvips-win32-ia32\": \"1.2.4\",\n \"@img/sharp-libvips-win32-x64\": \"1.2.4\",\n \"@types/node\": \"*\",\n \"emnapi\": \"^1.7.0\",\n \"exif-reader\": \"^2.0.2\",\n \"extract-zip\": \"^2.0.1\",\n \"icc\": \"^3.0.0\",\n \"jsdoc-to-markdown\": \"^9.1.3\",\n \"node-addon-api\": \"^8.5.0\",\n \"node-gyp\": \"^11.5.0\",\n \"tar-fs\": \"^3.1.1\",\n \"tsd\": \"^0.33.0\"\n },\n \"license\": \"Apache-2.0\",\n \"engines\": {\n \"node\": \"^18.17.0 || ^20.3.0 || >=21.0.0\"\n },\n \"config\": {\n \"libvips\": \">=8.17.3\"\n },\n \"funding\": {\n \"url\": \"https://opencollective.com/libvips\"\n }\n}\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst { spawnSync } = require('node:child_process');\nconst { createHash } = require('node:crypto');\nconst semverCoerce = require('semver/functions/coerce');\nconst semverGreaterThanOrEqualTo = require('semver/functions/gte');\nconst semverSatisfies = require('semver/functions/satisfies');\nconst detectLibc = require('detect-libc');\n\nconst { config, engines, optionalDependencies } = require('../package.json');\n\n/* node:coverage ignore next */\nconst minimumLibvipsVersionLabelled = process.env.npm_package_config_libvips || config.libvips;\nconst minimumLibvipsVersion = semverCoerce(minimumLibvipsVersionLabelled).version;\n\nconst prebuiltPlatforms = [\n 'darwin-arm64', 'darwin-x64',\n 'linux-arm', 'linux-arm64', 'linux-ppc64', 'linux-riscv64', 'linux-s390x', 'linux-x64',\n 'linuxmusl-arm64', 'linuxmusl-x64',\n 'win32-arm64', 'win32-ia32', 'win32-x64'\n];\n\nconst spawnSyncOptions = {\n encoding: 'utf8',\n shell: true\n};\n\nconst log = (item) => {\n if (item instanceof Error) {\n console.error(`sharp: Installation error: ${item.message}`);\n } else {\n console.log(`sharp: ${item}`);\n }\n};\n\n/* node:coverage ignore next */\nconst runtimeLibc = () => detectLibc.isNonGlibcLinuxSync() ? detectLibc.familySync() : '';\n\nconst runtimePlatformArch = () => `${process.platform}${runtimeLibc()}-${process.arch}`;\n\nconst buildPlatformArch = () => {\n /* node:coverage ignore next 3 */\n if (isEmscripten()) {\n return 'wasm32';\n }\n const { npm_config_arch, npm_config_platform, npm_config_libc } = process.env;\n const libc = typeof npm_config_libc === 'string' ? npm_config_libc : runtimeLibc();\n return `${npm_config_platform || process.platform}${libc}-${npm_config_arch || process.arch}`;\n};\n\nconst buildSharpLibvipsIncludeDir = () => {\n try {\n return require(`@img/sharp-libvips-dev-${buildPlatformArch()}/include`);\n } catch {\n /* node:coverage ignore next 5 */\n try {\n return require('@img/sharp-libvips-dev/include');\n } catch {}\n }\n return '';\n};\n\nconst buildSharpLibvipsCPlusPlusDir = () => {\n /* node:coverage ignore next 4 */\n try {\n return require('@img/sharp-libvips-dev/cplusplus');\n } catch {}\n return '';\n};\n\nconst buildSharpLibvipsLibDir = () => {\n try {\n return require(`@img/sharp-libvips-dev-${buildPlatformArch()}/lib`);\n } catch {\n /* node:coverage ignore next 5 */\n try {\n return require(`@img/sharp-libvips-${buildPlatformArch()}/lib`);\n } catch {}\n }\n return '';\n};\n\n/* node:coverage disable */\n\nconst isUnsupportedNodeRuntime = () => {\n if (process.release?.name === 'node' && process.versions) {\n if (!semverSatisfies(process.versions.node, engines.node)) {\n return { found: process.versions.node, expected: engines.node };\n }\n }\n};\n\nconst isEmscripten = () => {\n const { CC } = process.env;\n return Boolean(CC?.endsWith('/emcc'));\n};\n\nconst isRosetta = () => {\n if (process.platform === 'darwin' && process.arch === 'x64') {\n const translated = spawnSync('sysctl sysctl.proc_translated', spawnSyncOptions).stdout;\n return (translated || '').trim() === 'sysctl.proc_translated: 1';\n }\n return false;\n};\n\n/* node:coverage enable */\n\nconst sha512 = (s) => createHash('sha512').update(s).digest('hex');\n\nconst yarnLocator = () => {\n try {\n const identHash = sha512(`imgsharp-libvips-${buildPlatformArch()}`);\n const npmVersion = semverCoerce(optionalDependencies[`@img/sharp-libvips-${buildPlatformArch()}`], {\n includePrerelease: true\n }).version;\n return sha512(`${identHash}npm:${npmVersion}`).slice(0, 10);\n } catch {}\n return '';\n};\n\n/* node:coverage disable */\n\nconst spawnRebuild = () =>\n spawnSync(`node-gyp rebuild --directory=src ${isEmscripten() ? '--nodedir=emscripten' : ''}`, {\n ...spawnSyncOptions,\n stdio: 'inherit'\n }).status;\n\nconst globalLibvipsVersion = () => {\n if (process.platform !== 'win32') {\n const globalLibvipsVersion = spawnSync('pkg-config --modversion vips-cpp', {\n ...spawnSyncOptions,\n env: {\n ...process.env,\n PKG_CONFIG_PATH: pkgConfigPath()\n }\n }).stdout;\n return (globalLibvipsVersion || '').trim();\n } else {\n return '';\n }\n};\n\n/* node:coverage enable */\n\nconst pkgConfigPath = () => {\n if (process.platform !== 'win32') {\n /* node:coverage ignore next 4 */\n const brewPkgConfigPath = spawnSync(\n 'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d\" \" -f2',\n spawnSyncOptions\n ).stdout || '';\n return [\n brewPkgConfigPath.trim(),\n process.env.PKG_CONFIG_PATH,\n '/usr/local/lib/pkgconfig',\n '/usr/lib/pkgconfig',\n '/usr/local/libdata/pkgconfig',\n '/usr/libdata/pkgconfig'\n ].filter(Boolean).join(':');\n } else {\n return '';\n }\n};\n\nconst skipSearch = (status, reason, logger) => {\n if (logger) {\n logger(`Detected ${reason}, skipping search for globally-installed libvips`);\n }\n return status;\n};\n\nconst useGlobalLibvips = (logger) => {\n if (Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS) === true) {\n return skipSearch(false, 'SHARP_IGNORE_GLOBAL_LIBVIPS', logger);\n }\n if (Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS) === true) {\n return skipSearch(true, 'SHARP_FORCE_GLOBAL_LIBVIPS', logger);\n }\n /* node:coverage ignore next 3 */\n if (isRosetta()) {\n return skipSearch(false, 'Rosetta', logger);\n }\n const globalVipsVersion = globalLibvipsVersion();\n /* node:coverage ignore next */\n return !!globalVipsVersion && semverGreaterThanOrEqualTo(globalVipsVersion, minimumLibvipsVersion);\n};\n\nmodule.exports = {\n minimumLibvipsVersion,\n prebuiltPlatforms,\n buildPlatformArch,\n buildSharpLibvipsIncludeDir,\n buildSharpLibvipsCPlusPlusDir,\n buildSharpLibvipsLibDir,\n isUnsupportedNodeRuntime,\n runtimePlatformArch,\n log,\n yarnLocator,\n spawnRebuild,\n globalLibvipsVersion,\n pkgConfigPath,\n useGlobalLibvips\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\n// Inspects the runtime environment and exports the relevant sharp.node binary\n\nconst { familySync, versionSync } = require('detect-libc');\n\nconst { runtimePlatformArch, isUnsupportedNodeRuntime, prebuiltPlatforms, minimumLibvipsVersion } = require('./libvips');\nconst runtimePlatform = runtimePlatformArch();\n\nconst paths = [\n `../src/build/Release/sharp-${runtimePlatform}.node`,\n '../src/build/Release/sharp-wasm32.node',\n `@img/sharp-${runtimePlatform}/sharp.node`,\n '@img/sharp-wasm32/sharp.node'\n];\n\n/* node:coverage disable */\n\nlet path, sharp;\nconst errors = [];\nfor (path of paths) {\n try {\n sharp = require(path);\n break;\n } catch (err) {\n errors.push(err);\n }\n}\n\nif (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2()) {\n const err = new Error('Prebuilt binaries for linux-x64 require v2 microarchitecture');\n err.code = 'Unsupported CPU';\n errors.push(err);\n sharp = null;\n}\n\nif (sharp) {\n module.exports = sharp;\n} else {\n const [isLinux, isMacOs, isWindows] = ['linux', 'darwin', 'win32'].map(os => runtimePlatform.startsWith(os));\n\n const help = [`Could not load the \"sharp\" module using the ${runtimePlatform} runtime`];\n errors.forEach(err => {\n if (err.code !== 'MODULE_NOT_FOUND') {\n help.push(`${err.code}: ${err.message}`);\n }\n });\n const messages = errors.map(err => err.message).join(' ');\n help.push('Possible solutions:');\n // Common error messages\n if (isUnsupportedNodeRuntime()) {\n const { found, expected } = isUnsupportedNodeRuntime();\n help.push(\n '- Please upgrade Node.js:',\n ` Found ${found}`,\n ` Requires ${expected}`\n );\n } else if (prebuiltPlatforms.includes(runtimePlatform)) {\n const [os, cpu] = runtimePlatform.split('-');\n const libc = os.endsWith('musl') ? ' --libc=musl' : '';\n help.push(\n '- Ensure optional dependencies can be installed:',\n ' npm install --include=optional sharp',\n '- Ensure your package manager supports multi-platform installation:',\n ' See https://sharp.pixelplumbing.com/install#cross-platform',\n '- Add platform-specific dependencies:',\n ` npm install --os=${os.replace('musl', '')}${libc} --cpu=${cpu} sharp`\n );\n } else {\n help.push(\n `- Manually install libvips >= ${minimumLibvipsVersion}`,\n '- Add experimental WebAssembly-based dependencies:',\n ' npm install --cpu=wasm32 sharp',\n ' npm install @img/sharp-wasm32'\n );\n }\n if (isLinux && /(symbol not found|CXXABI_)/i.test(messages)) {\n try {\n const { config } = require(`@img/sharp-libvips-${runtimePlatform}/package`);\n const libcFound = `${familySync()} ${versionSync()}`;\n const libcRequires = `${config.musl ? 'musl' : 'glibc'} ${config.musl || config.glibc}`;\n help.push(\n '- Update your OS:',\n ` Found ${libcFound}`,\n ` Requires ${libcRequires}`\n );\n } catch (_errEngines) {}\n }\n if (isLinux && /\\/snap\\/core[0-9]{2}/.test(messages)) {\n help.push(\n '- Remove the Node.js Snap, which does not support native modules',\n ' snap remove node'\n );\n }\n if (isMacOs && /Incompatible library version/.test(messages)) {\n help.push(\n '- Update Homebrew:',\n ' brew update && brew upgrade vips'\n );\n }\n if (errors.some(err => err.code === 'ERR_DLOPEN_DISABLED')) {\n help.push('- Run Node.js without using the --no-addons flag');\n }\n // Link to installation docs\n if (isWindows && /The specified procedure could not be found/.test(messages)) {\n help.push(\n '- Using the canvas package on Windows?',\n ' See https://sharp.pixelplumbing.com/install#canvas-and-windows',\n '- Check for outdated versions of sharp in the dependency tree:',\n ' npm ls sharp'\n );\n }\n help.push(\n '- Consult the installation documentation:',\n ' See https://sharp.pixelplumbing.com/install'\n );\n throw new Error(help.join('\\n'));\n}\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst util = require('node:util');\nconst stream = require('node:stream');\nconst is = require('./is');\n\nrequire('./sharp');\n\n// Use NODE_DEBUG=sharp to enable libvips warnings\nconst debuglog = util.debuglog('sharp');\n\nconst queueListener = (queueLength) => {\n Sharp.queue.emit('change', queueLength);\n};\n\n/**\n * Constructor factory to create an instance of `sharp`, to which further methods are chained.\n *\n * JPEG, PNG, WebP, GIF, AVIF or TIFF format image data can be streamed out from this object.\n * When using Stream based output, derived attributes are available from the `info` event.\n *\n * Non-critical problems encountered during processing are emitted as `warning` events.\n *\n * Implements the [stream.Duplex](http://nodejs.org/api/stream.html#stream_class_stream_duplex) class.\n *\n * When loading more than one page/frame of an animated image,\n * these are combined as a vertically-stacked \"toilet roll\" image\n * where the overall height is the `pageHeight` multiplied by the number of `pages`.\n *\n * @constructs Sharp\n *\n * @emits Sharp#info\n * @emits Sharp#warning\n *\n * @example\n * sharp('input.jpg')\n * .resize(300, 200)\n * .toFile('output.jpg', function(err) {\n * // output.jpg is a 300 pixels wide and 200 pixels high image\n * // containing a scaled and cropped version of input.jpg\n * });\n *\n * @example\n * // Read image data from remote URL,\n * // resize to 300 pixels wide,\n * // emit an 'info' event with calculated dimensions\n * // and finally write image data to writableStream\n * const { body } = fetch('https://...');\n * const readableStream = Readable.fromWeb(body);\n * const transformer = sharp()\n * .resize(300)\n * .on('info', ({ height }) => {\n * console.log(`Image height is ${height}`);\n * });\n * readableStream.pipe(transformer).pipe(writableStream);\n *\n * @example\n * // Create a blank 300x200 PNG image of semi-translucent red pixels\n * sharp({\n * create: {\n * width: 300,\n * height: 200,\n * channels: 4,\n * background: { r: 255, g: 0, b: 0, alpha: 0.5 }\n * }\n * })\n * .png()\n * .toBuffer()\n * .then( ... );\n *\n * @example\n * // Convert an animated GIF to an animated WebP\n * await sharp('in.gif', { animated: true }).toFile('out.webp');\n *\n * @example\n * // Read a raw array of pixels and save it to a png\n * const input = Uint8Array.from([255, 255, 255, 0, 0, 0]); // or Uint8ClampedArray\n * const image = sharp(input, {\n * // because the input does not contain its dimensions or how many channels it has\n * // we need to specify it in the constructor options\n * raw: {\n * width: 2,\n * height: 1,\n * channels: 3\n * }\n * });\n * await image.toFile('my-two-pixels.png');\n *\n * @example\n * // Generate RGB Gaussian noise\n * await sharp({\n * create: {\n * width: 300,\n * height: 200,\n * channels: 3,\n * noise: {\n * type: 'gaussian',\n * mean: 128,\n * sigma: 30\n * }\n * }\n * }).toFile('noise.png');\n *\n * @example\n * // Generate an image from text\n * await sharp({\n * text: {\n * text: 'Hello, world!',\n * width: 400, // max width\n * height: 300 // max height\n * }\n * }).toFile('text_bw.png');\n *\n * @example\n * // Generate an rgba image from text using pango markup and font\n * await sharp({\n * text: {\n * text: '<span foreground=\"red\">Red!</span><span background=\"cyan\">blue</span>',\n * font: 'sans',\n * rgba: true,\n * dpi: 300\n * }\n * }).toFile('text_rgba.png');\n *\n * @example\n * // Join four input images as a 2x2 grid with a 4 pixel gutter\n * const data = await sharp(\n * [image1, image2, image3, image4],\n * { join: { across: 2, shim: 4 } }\n * ).toBuffer();\n *\n * @example\n * // Generate a two-frame animated image from emoji\n * const images = ['\uD83D\uDE00', '\uD83D\uDE1B'].map(text => ({\n * text: { text, width: 64, height: 64, channels: 4, rgba: true }\n * }));\n * await sharp(images, { join: { animated: true } }).toFile('out.gif');\n *\n * @param {(Buffer|ArrayBuffer|Uint8Array|Uint8ClampedArray|Int8Array|Uint16Array|Int16Array|Uint32Array|Int32Array|Float32Array|Float64Array|string|Array)} [input] - if present, can be\n * a Buffer / ArrayBuffer / Uint8Array / Uint8ClampedArray containing JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image data, or\n * a TypedArray containing raw pixel image data, or\n * a String containing the filesystem path to an JPEG, PNG, WebP, AVIF, GIF, SVG or TIFF image file.\n * An array of inputs can be provided, and these will be joined together.\n * JPEG, PNG, WebP, AVIF, GIF, SVG, TIFF or raw pixel image data can be streamed into the object when not present.\n * @param {Object} [options] - if present, is an Object with optional attributes.\n * @param {string} [options.failOn='warning'] - When to abort processing of invalid pixel data, one of (in order of sensitivity, least to most): 'none', 'truncated', 'error', 'warning'. Higher levels imply lower levels. Invalid metadata will always abort.\n * @param {number|boolean} [options.limitInputPixels=268402689] - Do not process input images where the number of pixels\n * (width x height) exceeds this limit. Assumes image dimensions contained in the input metadata can be trusted.\n * An integral Number of pixels, zero or false to remove limit, true to use default limit of 268402689 (0x3FFF x 0x3FFF).\n * @param {boolean} [options.unlimited=false] - Set this to `true` to remove safety features that help prevent memory exhaustion (JPEG, PNG, SVG, HEIF).\n * @param {boolean} [options.autoOrient=false] - Set this to `true` to rotate/flip the image to match EXIF `Orientation`, if any.\n * @param {boolean} [options.sequentialRead=true] - Set this to `false` to use random access rather than sequential read. Some operations will do this automatically.\n * @param {number} [options.density=72] - number representing the DPI for vector images in the range 1 to 100000.\n * @param {number} [options.ignoreIcc=false] - should the embedded ICC profile, if any, be ignored.\n * @param {number} [options.pages=1] - Number of pages to extract for multi-page input (GIF, WebP, TIFF), use -1 for all pages.\n * @param {number} [options.page=0] - Page number to start extracting from for multi-page input (GIF, WebP, TIFF), zero based.\n * @param {boolean} [options.animated=false] - Set to `true` to read all frames/pages of an animated image (GIF, WebP, TIFF), equivalent of setting `pages` to `-1`.\n * @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.\n * @param {number} [options.raw.width] - integral number of pixels wide.\n * @param {number} [options.raw.height] - integral number of pixels high.\n * @param {number} [options.raw.channels] - integral number of channels, between 1 and 4.\n * @param {boolean} [options.raw.premultiplied] - specifies that the raw input has already been premultiplied, set to `true`\n * to avoid sharp premultiplying the image. (optional, default `false`)\n * @param {number} [options.raw.pageHeight] - The pixel height of each page/frame for animated images, must be an integral factor of `raw.height`.\n * @param {Object} [options.create] - describes a new image to be created.\n * @param {number} [options.create.width] - integral number of pixels wide.\n * @param {number} [options.create.height] - integral number of pixels high.\n * @param {number} [options.create.channels] - integral number of channels, either 3 (RGB) or 4 (RGBA).\n * @param {string|Object} [options.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @param {number} [options.create.pageHeight] - The pixel height of each page/frame for animated images, must be an integral factor of `create.height`.\n * @param {Object} [options.create.noise] - describes a noise to be created.\n * @param {string} [options.create.noise.type] - type of generated noise, currently only `gaussian` is supported.\n * @param {number} [options.create.noise.mean=128] - Mean value of pixels in the generated noise.\n * @param {number} [options.create.noise.sigma=30] - Standard deviation of pixel values in the generated noise.\n * @param {Object} [options.text] - describes a new text image to be created.\n * @param {string} [options.text.text] - text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`.\n * @param {string} [options.text.font] - font name to render with.\n * @param {string} [options.text.fontfile] - absolute filesystem path to a font file that can be used by `font`.\n * @param {number} [options.text.width=0] - Integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries.\n * @param {number} [options.text.height=0] - Maximum integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0.\n * @param {string} [options.text.align='left'] - Alignment style for multi-line text (`'left'`, `'centre'`, `'center'`, `'right'`).\n * @param {boolean} [options.text.justify=false] - set this to true to apply justification to the text.\n * @param {number} [options.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.\n * @param {boolean} [options.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for pango markup features like `<span foreground=\"red\">Red!</span>`.\n * @param {number} [options.text.spacing=0] - text line height in points. Will use the font line height if none is specified.\n * @param {string} [options.text.wrap='word'] - word wrapping style when width is provided, one of: 'word', 'char', 'word-char' (prefer word, fallback to char) or 'none'.\n * @param {Object} [options.join] - describes how an array of input images should be joined.\n * @param {number} [options.join.across=1] - number of images to join horizontally.\n * @param {boolean} [options.join.animated=false] - set this to `true` to join the images as an animated image.\n * @param {number} [options.join.shim=0] - number of pixels to insert between joined images.\n * @param {string|Object} [options.join.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @param {string} [options.join.halign='left'] - horizontal alignment style for images joined horizontally (`'left'`, `'centre'`, `'center'`, `'right'`).\n * @param {string} [options.join.valign='top'] - vertical alignment style for images joined vertically (`'top'`, `'centre'`, `'center'`, `'bottom'`).\n * @param {Object} [options.tiff] - Describes TIFF specific options.\n * @param {number} [options.tiff.subifd=-1] - Sub Image File Directory to extract for OME-TIFF, defaults to main image.\n * @param {Object} [options.svg] - Describes SVG specific options.\n * @param {string} [options.svg.stylesheet] - Custom CSS for SVG input, applied with a User Origin during the CSS cascade.\n * @param {boolean} [options.svg.highBitdepth=false] - Set to `true` to render SVG input at 32-bits per channel (128-bit) instead of 8-bits per channel (32-bit) RGBA.\n * @param {Object} [options.pdf] - Describes PDF specific options. Requires the use of a globally-installed libvips compiled with support for PDFium, Poppler, ImageMagick or GraphicsMagick.\n * @param {string|Object} [options.pdf.background] - Background colour to use when PDF is partially transparent. Parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @param {Object} [options.openSlide] - Describes OpenSlide specific options. Requires the use of a globally-installed libvips compiled with support for OpenSlide.\n * @param {number} [options.openSlide.level=0] - Level to extract from a multi-level input, zero based.\n * @param {Object} [options.jp2] - Describes JPEG 2000 specific options. Requires the use of a globally-installed libvips compiled with support for OpenJPEG.\n * @param {boolean} [options.jp2.oneshot=false] - Set to `true` to decode tiled JPEG 2000 images in a single operation, improving compatibility.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nconst Sharp = function (input, options) {\n // biome-ignore lint/complexity/noArguments: constructor factory\n if (arguments.length === 1 && !is.defined(input)) {\n throw new Error('Invalid input');\n }\n if (!(this instanceof Sharp)) {\n return new Sharp(input, options);\n }\n stream.Duplex.call(this);\n this.options = {\n // resize options\n topOffsetPre: -1,\n leftOffsetPre: -1,\n widthPre: -1,\n heightPre: -1,\n topOffsetPost: -1,\n leftOffsetPost: -1,\n widthPost: -1,\n heightPost: -1,\n width: -1,\n height: -1,\n canvas: 'crop',\n position: 0,\n resizeBackground: [0, 0, 0, 255],\n angle: 0,\n rotationAngle: 0,\n rotationBackground: [0, 0, 0, 255],\n rotateBefore: false,\n orientBefore: false,\n flip: false,\n flop: false,\n extendTop: 0,\n extendBottom: 0,\n extendLeft: 0,\n extendRight: 0,\n extendBackground: [0, 0, 0, 255],\n extendWith: 'background',\n withoutEnlargement: false,\n withoutReduction: false,\n affineMatrix: [],\n affineBackground: [0, 0, 0, 255],\n affineIdx: 0,\n affineIdy: 0,\n affineOdx: 0,\n affineOdy: 0,\n affineInterpolator: this.constructor.interpolators.bilinear,\n kernel: 'lanczos3',\n fastShrinkOnLoad: true,\n // operations\n tint: [-1, 0, 0, 0],\n flatten: false,\n flattenBackground: [0, 0, 0],\n unflatten: false,\n negate: false,\n negateAlpha: true,\n medianSize: 0,\n blurSigma: 0,\n precision: 'integer',\n minAmpl: 0.2,\n sharpenSigma: 0,\n sharpenM1: 1,\n sharpenM2: 2,\n sharpenX1: 2,\n sharpenY2: 10,\n sharpenY3: 20,\n threshold: 0,\n thresholdGrayscale: true,\n trimBackground: [],\n trimThreshold: -1,\n trimLineArt: false,\n dilateWidth: 0,\n erodeWidth: 0,\n gamma: 0,\n gammaOut: 0,\n greyscale: false,\n normalise: false,\n normaliseLower: 1,\n normaliseUpper: 99,\n claheWidth: 0,\n claheHeight: 0,\n claheMaxSlope: 3,\n brightness: 1,\n saturation: 1,\n hue: 0,\n lightness: 0,\n booleanBufferIn: null,\n booleanFileIn: '',\n joinChannelIn: [],\n extractChannel: -1,\n removeAlpha: false,\n ensureAlpha: -1,\n colourspace: 'srgb',\n colourspacePipeline: 'last',\n composite: [],\n // output\n fileOut: '',\n formatOut: 'input',\n streamOut: false,\n keepMetadata: 0,\n withMetadataOrientation: -1,\n withMetadataDensity: 0,\n withIccProfile: '',\n withExif: {},\n withExifMerge: true,\n withXmp: '',\n resolveWithObject: false,\n loop: -1,\n delay: [],\n // output format\n jpegQuality: 80,\n jpegProgressive: false,\n jpegChromaSubsampling: '4:2:0',\n jpegTrellisQuantisation: false,\n jpegOvershootDeringing: false,\n jpegOptimiseScans: false,\n jpegOptimiseCoding: true,\n jpegQuantisationTable: 0,\n pngProgressive: false,\n pngCompressionLevel: 6,\n pngAdaptiveFiltering: false,\n pngPalette: false,\n pngQuality: 100,\n pngEffort: 7,\n pngBitdepth: 8,\n pngDither: 1,\n jp2Quality: 80,\n jp2TileHeight: 512,\n jp2TileWidth: 512,\n jp2Lossless: false,\n jp2ChromaSubsampling: '4:4:4',\n webpQuality: 80,\n webpAlphaQuality: 100,\n webpLossless: false,\n webpNearLossless: false,\n webpSmartSubsample: false,\n webpSmartDeblock: false,\n webpPreset: 'default',\n webpEffort: 4,\n webpMinSize: false,\n webpMixed: false,\n gifBitdepth: 8,\n gifEffort: 7,\n gifDither: 1,\n gifInterFrameMaxError: 0,\n gifInterPaletteMaxError: 3,\n gifKeepDuplicateFrames: false,\n gifReuse: true,\n gifProgressive: false,\n tiffQuality: 80,\n tiffCompression: 'jpeg',\n tiffBigtiff: false,\n tiffPredictor: 'horizontal',\n tiffPyramid: false,\n tiffMiniswhite: false,\n tiffBitdepth: 8,\n tiffTile: false,\n tiffTileHeight: 256,\n tiffTileWidth: 256,\n tiffXres: 1.0,\n tiffYres: 1.0,\n tiffResolutionUnit: 'inch',\n heifQuality: 50,\n heifLossless: false,\n heifCompression: 'av1',\n heifEffort: 4,\n heifChromaSubsampling: '4:4:4',\n heifBitdepth: 8,\n jxlDistance: 1,\n jxlDecodingTier: 0,\n jxlEffort: 7,\n jxlLossless: false,\n rawDepth: 'uchar',\n tileSize: 256,\n tileOverlap: 0,\n tileContainer: 'fs',\n tileLayout: 'dz',\n tileFormat: 'last',\n tileDepth: 'last',\n tileAngle: 0,\n tileSkipBlanks: -1,\n tileBackground: [255, 255, 255, 255],\n tileCentre: false,\n tileId: 'https://example.com/iiif',\n tileBasename: '',\n timeoutSeconds: 0,\n linearA: [],\n linearB: [],\n pdfBackground: [255, 255, 255, 255],\n // Function to notify of libvips warnings\n debuglog: warning => {\n this.emit('warning', warning);\n debuglog(warning);\n },\n // Function to notify of queue length changes\n queueListener\n };\n this.options.input = this._createInputDescriptor(input, options, { allowStream: true });\n return this;\n};\nObject.setPrototypeOf(Sharp.prototype, stream.Duplex.prototype);\nObject.setPrototypeOf(Sharp, stream.Duplex);\n\n/**\n * Take a \"snapshot\" of the Sharp instance, returning a new instance.\n * Cloned instances inherit the input of their parent instance.\n * This allows multiple output Streams and therefore multiple processing pipelines to share a single input Stream.\n *\n * @example\n * const pipeline = sharp().rotate();\n * pipeline.clone().resize(800, 600).pipe(firstWritableStream);\n * pipeline.clone().extract({ left: 20, top: 20, width: 100, height: 100 }).pipe(secondWritableStream);\n * readableStream.pipe(pipeline);\n * // firstWritableStream receives auto-rotated, resized readableStream\n * // secondWritableStream receives auto-rotated, extracted region of readableStream\n *\n * @example\n * // Create a pipeline that will download an image, resize it and format it to different files\n * // Using Promises to know when the pipeline is complete\n * const fs = require(\"fs\");\n * const got = require(\"got\");\n * const sharpStream = sharp({ failOn: 'none' });\n *\n * const promises = [];\n *\n * promises.push(\n * sharpStream\n * .clone()\n * .jpeg({ quality: 100 })\n * .toFile(\"originalFile.jpg\")\n * );\n *\n * promises.push(\n * sharpStream\n * .clone()\n * .resize({ width: 500 })\n * .jpeg({ quality: 80 })\n * .toFile(\"optimized-500.jpg\")\n * );\n *\n * promises.push(\n * sharpStream\n * .clone()\n * .resize({ width: 500 })\n * .webp({ quality: 80 })\n * .toFile(\"optimized-500.webp\")\n * );\n *\n * // https://github.com/sindresorhus/got/blob/main/documentation/3-streams.md\n * got.stream(\"https://www.example.com/some-file.jpg\").pipe(sharpStream);\n *\n * Promise.all(promises)\n * .then(res => { console.log(\"Done!\", res); })\n * .catch(err => {\n * console.error(\"Error processing files, let's clean it up\", err);\n * try {\n * fs.unlinkSync(\"originalFile.jpg\");\n * fs.unlinkSync(\"optimized-500.jpg\");\n * fs.unlinkSync(\"optimized-500.webp\");\n * } catch (e) {}\n * });\n *\n * @returns {Sharp}\n */\nfunction clone () {\n // Clone existing options\n const clone = this.constructor.call();\n const { debuglog, queueListener, ...options } = this.options;\n clone.options = structuredClone(options);\n clone.options.debuglog = debuglog;\n clone.options.queueListener = queueListener;\n // Pass 'finish' event to clone for Stream-based input\n if (this._isStreamInput()) {\n this.on('finish', () => {\n // Clone inherits input data\n this._flattenBufferIn();\n clone.options.input.buffer = this.options.input.buffer;\n clone.emit('finish');\n });\n }\n return clone;\n}\nObject.assign(Sharp.prototype, { clone });\n\n/**\n * Export constructor.\n * @module Sharp\n * @private\n */\nmodule.exports = Sharp;\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst is = require('./is');\nconst sharp = require('./sharp');\n\n/**\n * Justification alignment\n * @member\n * @private\n */\nconst align = {\n left: 'low',\n top: 'low',\n low: 'low',\n center: 'centre',\n centre: 'centre',\n right: 'high',\n bottom: 'high',\n high: 'high'\n};\n\nconst inputStreamParameters = [\n // Limits and error handling\n 'failOn', 'limitInputPixels', 'unlimited',\n // Format-generic\n 'animated', 'autoOrient', 'density', 'ignoreIcc', 'page', 'pages', 'sequentialRead',\n // Format-specific\n 'jp2', 'openSlide', 'pdf', 'raw', 'svg', 'tiff',\n // Deprecated\n 'failOnError', 'openSlideLevel', 'pdfBackground', 'tiffSubifd'\n];\n\n/**\n * Extract input options, if any, from an object.\n * @private\n */\nfunction _inputOptionsFromObject (obj) {\n const params = inputStreamParameters\n .filter(p => is.defined(obj[p]))\n .map(p => ([p, obj[p]]));\n return params.length\n ? Object.fromEntries(params)\n : undefined;\n}\n\n/**\n * Create Object containing input and input-related options.\n * @private\n */\nfunction _createInputDescriptor (input, inputOptions, containerOptions) {\n const inputDescriptor = {\n autoOrient: false,\n failOn: 'warning',\n limitInputPixels: 0x3FFF ** 2,\n ignoreIcc: false,\n unlimited: false,\n sequentialRead: true\n };\n if (is.string(input)) {\n // filesystem\n inputDescriptor.file = input;\n } else if (is.buffer(input)) {\n // Buffer\n if (input.length === 0) {\n throw Error('Input Buffer is empty');\n }\n inputDescriptor.buffer = input;\n } else if (is.arrayBuffer(input)) {\n if (input.byteLength === 0) {\n throw Error('Input bit Array is empty');\n }\n inputDescriptor.buffer = Buffer.from(input, 0, input.byteLength);\n } else if (is.typedArray(input)) {\n if (input.length === 0) {\n throw Error('Input Bit Array is empty');\n }\n inputDescriptor.buffer = Buffer.from(input.buffer, input.byteOffset, input.byteLength);\n } else if (is.plainObject(input) && !is.defined(inputOptions)) {\n // Plain Object descriptor, e.g. create\n inputOptions = input;\n if (_inputOptionsFromObject(inputOptions)) {\n // Stream with options\n inputDescriptor.buffer = [];\n }\n } else if (!is.defined(input) && !is.defined(inputOptions) && is.object(containerOptions) && containerOptions.allowStream) {\n // Stream without options\n inputDescriptor.buffer = [];\n } else if (Array.isArray(input)) {\n if (input.length > 1) {\n // Join images together\n if (!this.options.joining) {\n this.options.joining = true;\n this.options.join = input.map(i => this._createInputDescriptor(i));\n } else {\n throw new Error('Recursive join is unsupported');\n }\n } else {\n throw new Error('Expected at least two images to join');\n }\n } else {\n throw new Error(`Unsupported input '${input}' of type ${typeof input}${\n is.defined(inputOptions) ? ` when also providing options of type ${typeof inputOptions}` : ''\n }`);\n }\n if (is.object(inputOptions)) {\n // Deprecated: failOnError\n if (is.defined(inputOptions.failOnError)) {\n if (is.bool(inputOptions.failOnError)) {\n inputDescriptor.failOn = inputOptions.failOnError ? 'warning' : 'none';\n } else {\n throw is.invalidParameterError('failOnError', 'boolean', inputOptions.failOnError);\n }\n }\n // failOn\n if (is.defined(inputOptions.failOn)) {\n if (is.string(inputOptions.failOn) && is.inArray(inputOptions.failOn, ['none', 'truncated', 'error', 'warning'])) {\n inputDescriptor.failOn = inputOptions.failOn;\n } else {\n throw is.invalidParameterError('failOn', 'one of: none, truncated, error, warning', inputOptions.failOn);\n }\n }\n // autoOrient\n if (is.defined(inputOptions.autoOrient)) {\n if (is.bool(inputOptions.autoOrient)) {\n inputDescriptor.autoOrient = inputOptions.autoOrient;\n } else {\n throw is.invalidParameterError('autoOrient', 'boolean', inputOptions.autoOrient);\n }\n }\n // Density\n if (is.defined(inputOptions.density)) {\n if (is.inRange(inputOptions.density, 1, 100000)) {\n inputDescriptor.density = inputOptions.density;\n } else {\n throw is.invalidParameterError('density', 'number between 1 and 100000', inputOptions.density);\n }\n }\n // Ignore embeddded ICC profile\n if (is.defined(inputOptions.ignoreIcc)) {\n if (is.bool(inputOptions.ignoreIcc)) {\n inputDescriptor.ignoreIcc = inputOptions.ignoreIcc;\n } else {\n throw is.invalidParameterError('ignoreIcc', 'boolean', inputOptions.ignoreIcc);\n }\n }\n // limitInputPixels\n if (is.defined(inputOptions.limitInputPixels)) {\n if (is.bool(inputOptions.limitInputPixels)) {\n inputDescriptor.limitInputPixels = inputOptions.limitInputPixels\n ? 0x3FFF ** 2\n : 0;\n } else if (is.integer(inputOptions.limitInputPixels) && is.inRange(inputOptions.limitInputPixels, 0, Number.MAX_SAFE_INTEGER)) {\n inputDescriptor.limitInputPixels = inputOptions.limitInputPixels;\n } else {\n throw is.invalidParameterError('limitInputPixels', 'positive integer', inputOptions.limitInputPixels);\n }\n }\n // unlimited\n if (is.defined(inputOptions.unlimited)) {\n if (is.bool(inputOptions.unlimited)) {\n inputDescriptor.unlimited = inputOptions.unlimited;\n } else {\n throw is.invalidParameterError('unlimited', 'boolean', inputOptions.unlimited);\n }\n }\n // sequentialRead\n if (is.defined(inputOptions.sequentialRead)) {\n if (is.bool(inputOptions.sequentialRead)) {\n inputDescriptor.sequentialRead = inputOptions.sequentialRead;\n } else {\n throw is.invalidParameterError('sequentialRead', 'boolean', inputOptions.sequentialRead);\n }\n }\n // Raw pixel input\n if (is.defined(inputOptions.raw)) {\n if (\n is.object(inputOptions.raw) &&\n is.integer(inputOptions.raw.width) && inputOptions.raw.width > 0 &&\n is.integer(inputOptions.raw.height) && inputOptions.raw.height > 0 &&\n is.integer(inputOptions.raw.channels) && is.inRange(inputOptions.raw.channels, 1, 4)\n ) {\n inputDescriptor.rawWidth = inputOptions.raw.width;\n inputDescriptor.rawHeight = inputOptions.raw.height;\n inputDescriptor.rawChannels = inputOptions.raw.channels;\n switch (input.constructor) {\n case Uint8Array:\n case Uint8ClampedArray:\n inputDescriptor.rawDepth = 'uchar';\n break;\n case Int8Array:\n inputDescriptor.rawDepth = 'char';\n break;\n case Uint16Array:\n inputDescriptor.rawDepth = 'ushort';\n break;\n case Int16Array:\n inputDescriptor.rawDepth = 'short';\n break;\n case Uint32Array:\n inputDescriptor.rawDepth = 'uint';\n break;\n case Int32Array:\n inputDescriptor.rawDepth = 'int';\n break;\n case Float32Array:\n inputDescriptor.rawDepth = 'float';\n break;\n case Float64Array:\n inputDescriptor.rawDepth = 'double';\n break;\n default:\n inputDescriptor.rawDepth = 'uchar';\n break;\n }\n } else {\n throw new Error('Expected width, height and channels for raw pixel input');\n }\n inputDescriptor.rawPremultiplied = false;\n if (is.defined(inputOptions.raw.premultiplied)) {\n if (is.bool(inputOptions.raw.premultiplied)) {\n inputDescriptor.rawPremultiplied = inputOptions.raw.premultiplied;\n } else {\n throw is.invalidParameterError('raw.premultiplied', 'boolean', inputOptions.raw.premultiplied);\n }\n }\n inputDescriptor.rawPageHeight = 0;\n if (is.defined(inputOptions.raw.pageHeight)) {\n if (is.integer(inputOptions.raw.pageHeight) && inputOptions.raw.pageHeight > 0 && inputOptions.raw.pageHeight <= inputOptions.raw.height) {\n if (inputOptions.raw.height % inputOptions.raw.pageHeight !== 0) {\n throw new Error(`Expected raw.height ${inputOptions.raw.height} to be a multiple of raw.pageHeight ${inputOptions.raw.pageHeight}`);\n }\n inputDescriptor.rawPageHeight = inputOptions.raw.pageHeight;\n } else {\n throw is.invalidParameterError('raw.pageHeight', 'positive integer', inputOptions.raw.pageHeight);\n }\n }\n }\n // Multi-page input (GIF, TIFF, PDF)\n if (is.defined(inputOptions.animated)) {\n if (is.bool(inputOptions.animated)) {\n inputDescriptor.pages = inputOptions.animated ? -1 : 1;\n } else {\n throw is.invalidParameterError('animated', 'boolean', inputOptions.animated);\n }\n }\n if (is.defined(inputOptions.pages)) {\n if (is.integer(inputOptions.pages) && is.inRange(inputOptions.pages, -1, 100000)) {\n inputDescriptor.pages = inputOptions.pages;\n } else {\n throw is.invalidParameterError('pages', 'integer between -1 and 100000', inputOptions.pages);\n }\n }\n if (is.defined(inputOptions.page)) {\n if (is.integer(inputOptions.page) && is.inRange(inputOptions.page, 0, 100000)) {\n inputDescriptor.page = inputOptions.page;\n } else {\n throw is.invalidParameterError('page', 'integer between 0 and 100000', inputOptions.page);\n }\n }\n // OpenSlide specific options\n if (is.object(inputOptions.openSlide) && is.defined(inputOptions.openSlide.level)) {\n if (is.integer(inputOptions.openSlide.level) && is.inRange(inputOptions.openSlide.level, 0, 256)) {\n inputDescriptor.openSlideLevel = inputOptions.openSlide.level;\n } else {\n throw is.invalidParameterError('openSlide.level', 'integer between 0 and 256', inputOptions.openSlide.level);\n }\n } else if (is.defined(inputOptions.level)) {\n // Deprecated\n if (is.integer(inputOptions.level) && is.inRange(inputOptions.level, 0, 256)) {\n inputDescriptor.openSlideLevel = inputOptions.level;\n } else {\n throw is.invalidParameterError('level', 'integer between 0 and 256', inputOptions.level);\n }\n }\n // TIFF specific options\n if (is.object(inputOptions.tiff) && is.defined(inputOptions.tiff.subifd)) {\n if (is.integer(inputOptions.tiff.subifd) && is.inRange(inputOptions.tiff.subifd, -1, 100000)) {\n inputDescriptor.tiffSubifd = inputOptions.tiff.subifd;\n } else {\n throw is.invalidParameterError('tiff.subifd', 'integer between -1 and 100000', inputOptions.tiff.subifd);\n }\n } else if (is.defined(inputOptions.subifd)) {\n // Deprecated\n if (is.integer(inputOptions.subifd) && is.inRange(inputOptions.subifd, -1, 100000)) {\n inputDescriptor.tiffSubifd = inputOptions.subifd;\n } else {\n throw is.invalidParameterError('subifd', 'integer between -1 and 100000', inputOptions.subifd);\n }\n }\n // SVG specific options\n if (is.object(inputOptions.svg)) {\n if (is.defined(inputOptions.svg.stylesheet)) {\n if (is.string(inputOptions.svg.stylesheet)) {\n inputDescriptor.svgStylesheet = inputOptions.svg.stylesheet;\n } else {\n throw is.invalidParameterError('svg.stylesheet', 'string', inputOptions.svg.stylesheet);\n }\n }\n if (is.defined(inputOptions.svg.highBitdepth)) {\n if (is.bool(inputOptions.svg.highBitdepth)) {\n inputDescriptor.svgHighBitdepth = inputOptions.svg.highBitdepth;\n } else {\n throw is.invalidParameterError('svg.highBitdepth', 'boolean', inputOptions.svg.highBitdepth);\n }\n }\n }\n // PDF specific options\n if (is.object(inputOptions.pdf) && is.defined(inputOptions.pdf.background)) {\n inputDescriptor.pdfBackground = this._getBackgroundColourOption(inputOptions.pdf.background);\n } else if (is.defined(inputOptions.pdfBackground)) {\n // Deprecated\n inputDescriptor.pdfBackground = this._getBackgroundColourOption(inputOptions.pdfBackground);\n }\n // JPEG 2000 specific options\n if (is.object(inputOptions.jp2) && is.defined(inputOptions.jp2.oneshot)) {\n if (is.bool(inputOptions.jp2.oneshot)) {\n inputDescriptor.jp2Oneshot = inputOptions.jp2.oneshot;\n } else {\n throw is.invalidParameterError('jp2.oneshot', 'boolean', inputOptions.jp2.oneshot);\n }\n }\n // Create new image\n if (is.defined(inputOptions.create)) {\n if (\n is.object(inputOptions.create) &&\n is.integer(inputOptions.create.width) && inputOptions.create.width > 0 &&\n is.integer(inputOptions.create.height) && inputOptions.create.height > 0 &&\n is.integer(inputOptions.create.channels)\n ) {\n inputDescriptor.createWidth = inputOptions.create.width;\n inputDescriptor.createHeight = inputOptions.create.height;\n inputDescriptor.createChannels = inputOptions.create.channels;\n inputDescriptor.createPageHeight = 0;\n if (is.defined(inputOptions.create.pageHeight)) {\n if (is.integer(inputOptions.create.pageHeight) && inputOptions.create.pageHeight > 0 && inputOptions.create.pageHeight <= inputOptions.create.height) {\n if (inputOptions.create.height % inputOptions.create.pageHeight !== 0) {\n throw new Error(`Expected create.height ${inputOptions.create.height} to be a multiple of create.pageHeight ${inputOptions.create.pageHeight}`);\n }\n inputDescriptor.createPageHeight = inputOptions.create.pageHeight;\n } else {\n throw is.invalidParameterError('create.pageHeight', 'positive integer', inputOptions.create.pageHeight);\n }\n }\n // Noise\n if (is.defined(inputOptions.create.noise)) {\n if (!is.object(inputOptions.create.noise)) {\n throw new Error('Expected noise to be an object');\n }\n if (inputOptions.create.noise.type !== 'gaussian') {\n throw new Error('Only gaussian noise is supported at the moment');\n }\n inputDescriptor.createNoiseType = inputOptions.create.noise.type;\n if (!is.inRange(inputOptions.create.channels, 1, 4)) {\n throw is.invalidParameterError('create.channels', 'number between 1 and 4', inputOptions.create.channels);\n }\n inputDescriptor.createNoiseMean = 128;\n if (is.defined(inputOptions.create.noise.mean)) {\n if (is.number(inputOptions.create.noise.mean) && is.inRange(inputOptions.create.noise.mean, 0, 10000)) {\n inputDescriptor.createNoiseMean = inputOptions.create.noise.mean;\n } else {\n throw is.invalidParameterError('create.noise.mean', 'number between 0 and 10000', inputOptions.create.noise.mean);\n }\n }\n inputDescriptor.createNoiseSigma = 30;\n if (is.defined(inputOptions.create.noise.sigma)) {\n if (is.number(inputOptions.create.noise.sigma) && is.inRange(inputOptions.create.noise.sigma, 0, 10000)) {\n inputDescriptor.createNoiseSigma = inputOptions.create.noise.sigma;\n } else {\n throw is.invalidParameterError('create.noise.sigma', 'number between 0 and 10000', inputOptions.create.noise.sigma);\n }\n }\n } else if (is.defined(inputOptions.create.background)) {\n if (!is.inRange(inputOptions.create.channels, 3, 4)) {\n throw is.invalidParameterError('create.channels', 'number between 3 and 4', inputOptions.create.channels);\n }\n inputDescriptor.createBackground = this._getBackgroundColourOption(inputOptions.create.background);\n } else {\n throw new Error('Expected valid noise or background to create a new input image');\n }\n delete inputDescriptor.buffer;\n } else {\n throw new Error('Expected valid width, height and channels to create a new input image');\n }\n }\n // Create a new image with text\n if (is.defined(inputOptions.text)) {\n if (is.object(inputOptions.text) && is.string(inputOptions.text.text)) {\n inputDescriptor.textValue = inputOptions.text.text;\n if (is.defined(inputOptions.text.height) && is.defined(inputOptions.text.dpi)) {\n throw new Error('Expected only one of dpi or height');\n }\n if (is.defined(inputOptions.text.font)) {\n if (is.string(inputOptions.text.font)) {\n inputDescriptor.textFont = inputOptions.text.font;\n } else {\n throw is.invalidParameterError('text.font', 'string', inputOptions.text.font);\n }\n }\n if (is.defined(inputOptions.text.fontfile)) {\n if (is.string(inputOptions.text.fontfile)) {\n inputDescriptor.textFontfile = inputOptions.text.fontfile;\n } else {\n throw is.invalidParameterError('text.fontfile', 'string', inputOptions.text.fontfile);\n }\n }\n if (is.defined(inputOptions.text.width)) {\n if (is.integer(inputOptions.text.width) && inputOptions.text.width > 0) {\n inputDescriptor.textWidth = inputOptions.text.width;\n } else {\n throw is.invalidParameterError('text.width', 'positive integer', inputOptions.text.width);\n }\n }\n if (is.defined(inputOptions.text.height)) {\n if (is.integer(inputOptions.text.height) && inputOptions.text.height > 0) {\n inputDescriptor.textHeight = inputOptions.text.height;\n } else {\n throw is.invalidParameterError('text.height', 'positive integer', inputOptions.text.height);\n }\n }\n if (is.defined(inputOptions.text.align)) {\n if (is.string(inputOptions.text.align) && is.string(this.constructor.align[inputOptions.text.align])) {\n inputDescriptor.textAlign = this.constructor.align[inputOptions.text.align];\n } else {\n throw is.invalidParameterError('text.align', 'valid alignment', inputOptions.text.align);\n }\n }\n if (is.defined(inputOptions.text.justify)) {\n if (is.bool(inputOptions.text.justify)) {\n inputDescriptor.textJustify = inputOptions.text.justify;\n } else {\n throw is.invalidParameterError('text.justify', 'boolean', inputOptions.text.justify);\n }\n }\n if (is.defined(inputOptions.text.dpi)) {\n if (is.integer(inputOptions.text.dpi) && is.inRange(inputOptions.text.dpi, 1, 1000000)) {\n inputDescriptor.textDpi = inputOptions.text.dpi;\n } else {\n throw is.invalidParameterError('text.dpi', 'integer between 1 and 1000000', inputOptions.text.dpi);\n }\n }\n if (is.defined(inputOptions.text.rgba)) {\n if (is.bool(inputOptions.text.rgba)) {\n inputDescriptor.textRgba = inputOptions.text.rgba;\n } else {\n throw is.invalidParameterError('text.rgba', 'bool', inputOptions.text.rgba);\n }\n }\n if (is.defined(inputOptions.text.spacing)) {\n if (is.integer(inputOptions.text.spacing) && is.inRange(inputOptions.text.spacing, -1000000, 1000000)) {\n inputDescriptor.textSpacing = inputOptions.text.spacing;\n } else {\n throw is.invalidParameterError('text.spacing', 'integer between -1000000 and 1000000', inputOptions.text.spacing);\n }\n }\n if (is.defined(inputOptions.text.wrap)) {\n if (is.string(inputOptions.text.wrap) && is.inArray(inputOptions.text.wrap, ['word', 'char', 'word-char', 'none'])) {\n inputDescriptor.textWrap = inputOptions.text.wrap;\n } else {\n throw is.invalidParameterError('text.wrap', 'one of: word, char, word-char, none', inputOptions.text.wrap);\n }\n }\n delete inputDescriptor.buffer;\n } else {\n throw new Error('Expected a valid string to create an image with text.');\n }\n }\n // Join images together\n if (is.defined(inputOptions.join)) {\n if (is.defined(this.options.join)) {\n if (is.defined(inputOptions.join.animated)) {\n if (is.bool(inputOptions.join.animated)) {\n inputDescriptor.joinAnimated = inputOptions.join.animated;\n } else {\n throw is.invalidParameterError('join.animated', 'boolean', inputOptions.join.animated);\n }\n }\n if (is.defined(inputOptions.join.across)) {\n if (is.integer(inputOptions.join.across) && is.inRange(inputOptions.join.across, 1, 1000000)) {\n inputDescriptor.joinAcross = inputOptions.join.across;\n } else {\n throw is.invalidParameterError('join.across', 'integer between 1 and 100000', inputOptions.join.across);\n }\n }\n if (is.defined(inputOptions.join.shim)) {\n if (is.integer(inputOptions.join.shim) && is.inRange(inputOptions.join.shim, 0, 1000000)) {\n inputDescriptor.joinShim = inputOptions.join.shim;\n } else {\n throw is.invalidParameterError('join.shim', 'integer between 0 and 100000', inputOptions.join.shim);\n }\n }\n if (is.defined(inputOptions.join.background)) {\n inputDescriptor.joinBackground = this._getBackgroundColourOption(inputOptions.join.background);\n }\n if (is.defined(inputOptions.join.halign)) {\n if (is.string(inputOptions.join.halign) && is.string(this.constructor.align[inputOptions.join.halign])) {\n inputDescriptor.joinHalign = this.constructor.align[inputOptions.join.halign];\n } else {\n throw is.invalidParameterError('join.halign', 'valid alignment', inputOptions.join.halign);\n }\n }\n if (is.defined(inputOptions.join.valign)) {\n if (is.string(inputOptions.join.valign) && is.string(this.constructor.align[inputOptions.join.valign])) {\n inputDescriptor.joinValign = this.constructor.align[inputOptions.join.valign];\n } else {\n throw is.invalidParameterError('join.valign', 'valid alignment', inputOptions.join.valign);\n }\n }\n } else {\n throw new Error('Expected input to be an array of images to join');\n }\n }\n } else if (is.defined(inputOptions)) {\n throw new Error(`Invalid input options ${inputOptions}`);\n }\n return inputDescriptor;\n}\n\n/**\n * Handle incoming Buffer chunk on Writable Stream.\n * @private\n * @param {Buffer} chunk\n * @param {string} encoding - unused\n * @param {Function} callback\n */\nfunction _write (chunk, _encoding, callback) {\n if (Array.isArray(this.options.input.buffer)) {\n if (is.buffer(chunk)) {\n if (this.options.input.buffer.length === 0) {\n this.on('finish', () => {\n this.streamInFinished = true;\n });\n }\n this.options.input.buffer.push(chunk);\n callback();\n } else {\n callback(new Error('Non-Buffer data on Writable Stream'));\n }\n } else {\n callback(new Error('Unexpected data on Writable Stream'));\n }\n}\n\n/**\n * Flattens the array of chunks accumulated in input.buffer.\n * @private\n */\nfunction _flattenBufferIn () {\n if (this._isStreamInput()) {\n this.options.input.buffer = Buffer.concat(this.options.input.buffer);\n }\n}\n\n/**\n * Are we expecting Stream-based input?\n * @private\n * @returns {boolean}\n */\nfunction _isStreamInput () {\n return Array.isArray(this.options.input.buffer);\n}\n\n/**\n * Fast access to (uncached) image metadata without decoding any compressed pixel data.\n *\n * This is read from the header of the input image.\n * It does not take into consideration any operations to be applied to the output image,\n * such as resize or rotate.\n *\n * Dimensions in the response will respect the `page` and `pages` properties of the\n * {@link /api-constructor/ constructor parameters}.\n *\n * A `Promise` is returned when `callback` is not provided.\n *\n * - `format`: Name of decoder used to decompress image data e.g. `jpeg`, `png`, `webp`, `gif`, `svg`\n * - `size`: Total size of image in bytes, for Stream and Buffer input only\n * - `width`: Number of pixels wide (EXIF orientation is not taken into consideration, see example below)\n * - `height`: Number of pixels high (EXIF orientation is not taken into consideration, see example below)\n * - `space`: Name of colour space interpretation e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/enum.Interpretation.html)\n * - `channels`: Number of bands e.g. `3` for sRGB, `4` for CMYK\n * - `depth`: Name of pixel depth format e.g. `uchar`, `char`, `ushort`, `float` [...](https://www.libvips.org/API/current/enum.BandFormat.html)\n * - `density`: Number of pixels per inch (DPI), if present\n * - `chromaSubsampling`: String containing JPEG chroma subsampling, `4:2:0` or `4:4:4` for RGB, `4:2:0:4` or `4:4:4:4` for CMYK\n * - `isProgressive`: Boolean indicating whether the image is interlaced using a progressive scan\n * - `isPalette`: Boolean indicating whether the image is palette-based (GIF, PNG).\n * - `bitsPerSample`: Number of bits per sample for each channel (GIF, PNG, HEIF).\n * - `pages`: Number of pages/frames contained within the image, with support for TIFF, HEIF, PDF, animated GIF and animated WebP\n * - `pageHeight`: Number of pixels high each page in a multi-page image will be.\n * - `loop`: Number of times to loop an animated image, zero refers to a continuous loop.\n * - `delay`: Delay in ms between each page in an animated image, provided as an array of integers.\n * - `pagePrimary`: Number of the primary page in a HEIF image\n * - `levels`: Details of each level in a multi-level image provided as an array of objects, requires libvips compiled with support for OpenSlide\n * - `subifds`: Number of Sub Image File Directories in an OME-TIFF image\n * - `background`: Default background colour, if present, for PNG (bKGD) and GIF images\n * - `compression`: The encoder used to compress an HEIF file, `av1` (AVIF) or `hevc` (HEIC)\n * - `resolutionUnit`: The unit of resolution (density), either `inch` or `cm`, if present\n * - `hasProfile`: Boolean indicating the presence of an embedded ICC profile\n * - `hasAlpha`: Boolean indicating the presence of an alpha transparency channel\n * - `orientation`: Number value of the EXIF Orientation header, if present\n * - `exif`: Buffer containing raw EXIF data, if present\n * - `icc`: Buffer containing raw [ICC](https://www.npmjs.com/package/icc) profile data, if present\n * - `iptc`: Buffer containing raw IPTC data, if present\n * - `xmp`: Buffer containing raw XMP data, if present\n * - `xmpAsString`: String containing XMP data, if valid UTF-8.\n * - `tifftagPhotoshop`: Buffer containing raw TIFFTAG_PHOTOSHOP data, if present\n * - `formatMagick`: String containing format for images loaded via *magick\n * - `comments`: Array of keyword/text pairs representing PNG text blocks, if present.\n *\n * @example\n * const metadata = await sharp(input).metadata();\n *\n * @example\n * const image = sharp(inputJpg);\n * image\n * .metadata()\n * .then(function(metadata) {\n * return image\n * .resize(Math.round(metadata.width / 2))\n * .webp()\n * .toBuffer();\n * })\n * .then(function(data) {\n * // data contains a WebP image half the width and height of the original JPEG\n * });\n *\n * @example\n * // Get dimensions taking EXIF Orientation into account.\n * const { autoOrient } = await sharp(input).metadata();\n * const { width, height } = autoOrient;\n *\n * @param {Function} [callback] - called with the arguments `(err, metadata)`\n * @returns {Promise<Object>|Sharp}\n */\nfunction metadata (callback) {\n const stack = Error();\n if (is.fn(callback)) {\n if (this._isStreamInput()) {\n this.on('finish', () => {\n this._flattenBufferIn();\n sharp.metadata(this.options, (err, metadata) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, metadata);\n }\n });\n });\n } else {\n sharp.metadata(this.options, (err, metadata) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, metadata);\n }\n });\n }\n return this;\n } else {\n if (this._isStreamInput()) {\n return new Promise((resolve, reject) => {\n const finished = () => {\n this._flattenBufferIn();\n sharp.metadata(this.options, (err, metadata) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n resolve(metadata);\n }\n });\n };\n if (this.writableFinished) {\n finished();\n } else {\n this.once('finish', finished);\n }\n });\n } else {\n return new Promise((resolve, reject) => {\n sharp.metadata(this.options, (err, metadata) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n resolve(metadata);\n }\n });\n });\n }\n }\n}\n\n/**\n * Access to pixel-derived image statistics for every channel in the image.\n * A `Promise` is returned when `callback` is not provided.\n *\n * - `channels`: Array of channel statistics for each channel in the image. Each channel statistic contains\n * - `min` (minimum value in the channel)\n * - `max` (maximum value in the channel)\n * - `sum` (sum of all values in a channel)\n * - `squaresSum` (sum of squared values in a channel)\n * - `mean` (mean of the values in a channel)\n * - `stdev` (standard deviation for the values in a channel)\n * - `minX` (x-coordinate of one of the pixel where the minimum lies)\n * - `minY` (y-coordinate of one of the pixel where the minimum lies)\n * - `maxX` (x-coordinate of one of the pixel where the maximum lies)\n * - `maxY` (y-coordinate of one of the pixel where the maximum lies)\n * - `isOpaque`: Is the image fully opaque? Will be `true` if the image has no alpha channel or if every pixel is fully opaque.\n * - `entropy`: Histogram-based estimation of greyscale entropy, discarding alpha channel if any.\n * - `sharpness`: Estimation of greyscale sharpness based on the standard deviation of a Laplacian convolution, discarding alpha channel if any.\n * - `dominant`: Object containing most dominant sRGB colour based on a 4096-bin 3D histogram.\n *\n * **Note**: Statistics are derived from the original input image. Any operations performed on the image must first be\n * written to a buffer in order to run `stats` on the result (see third example).\n *\n * @example\n * const image = sharp(inputJpg);\n * image\n * .stats()\n * .then(function(stats) {\n * // stats contains the channel-wise statistics array and the isOpaque value\n * });\n *\n * @example\n * const { entropy, sharpness, dominant } = await sharp(input).stats();\n * const { r, g, b } = dominant;\n *\n * @example\n * const image = sharp(input);\n * // store intermediate result\n * const part = await image.extract(region).toBuffer();\n * // create new instance to obtain statistics of extracted region\n * const stats = await sharp(part).stats();\n *\n * @param {Function} [callback] - called with the arguments `(err, stats)`\n * @returns {Promise<Object>}\n */\nfunction stats (callback) {\n const stack = Error();\n if (is.fn(callback)) {\n if (this._isStreamInput()) {\n this.on('finish', () => {\n this._flattenBufferIn();\n sharp.stats(this.options, (err, stats) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, stats);\n }\n });\n });\n } else {\n sharp.stats(this.options, (err, stats) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, stats);\n }\n });\n }\n return this;\n } else {\n if (this._isStreamInput()) {\n return new Promise((resolve, reject) => {\n this.on('finish', function () {\n this._flattenBufferIn();\n sharp.stats(this.options, (err, stats) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n resolve(stats);\n }\n });\n });\n });\n } else {\n return new Promise((resolve, reject) => {\n sharp.stats(this.options, (err, stats) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n resolve(stats);\n }\n });\n });\n }\n }\n}\n\n/**\n * Decorate the Sharp prototype with input-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n // Private\n _inputOptionsFromObject,\n _createInputDescriptor,\n _write,\n _flattenBufferIn,\n _isStreamInput,\n // Public\n metadata,\n stats\n });\n // Class attributes\n Sharp.align = align;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst is = require('./is');\n\n/**\n * Weighting to apply when using contain/cover fit.\n * @member\n * @private\n */\nconst gravity = {\n center: 0,\n centre: 0,\n north: 1,\n east: 2,\n south: 3,\n west: 4,\n northeast: 5,\n southeast: 6,\n southwest: 7,\n northwest: 8\n};\n\n/**\n * Position to apply when using contain/cover fit.\n * @member\n * @private\n */\nconst position = {\n top: 1,\n right: 2,\n bottom: 3,\n left: 4,\n 'right top': 5,\n 'right bottom': 6,\n 'left bottom': 7,\n 'left top': 8\n};\n\n/**\n * How to extend the image.\n * @member\n * @private\n */\nconst extendWith = {\n background: 'background',\n copy: 'copy',\n repeat: 'repeat',\n mirror: 'mirror'\n};\n\n/**\n * Strategies for automagic cover behaviour.\n * @member\n * @private\n */\nconst strategy = {\n entropy: 16,\n attention: 17\n};\n\n/**\n * Reduction kernels.\n * @member\n * @private\n */\nconst kernel = {\n nearest: 'nearest',\n linear: 'linear',\n cubic: 'cubic',\n mitchell: 'mitchell',\n lanczos2: 'lanczos2',\n lanczos3: 'lanczos3',\n mks2013: 'mks2013',\n mks2021: 'mks2021'\n};\n\n/**\n * Methods by which an image can be resized to fit the provided dimensions.\n * @member\n * @private\n */\nconst fit = {\n contain: 'contain',\n cover: 'cover',\n fill: 'fill',\n inside: 'inside',\n outside: 'outside'\n};\n\n/**\n * Map external fit property to internal canvas property.\n * @member\n * @private\n */\nconst mapFitToCanvas = {\n contain: 'embed',\n cover: 'crop',\n fill: 'ignore_aspect',\n inside: 'max',\n outside: 'min'\n};\n\n/**\n * @private\n */\nfunction isRotationExpected (options) {\n return (options.angle % 360) !== 0 || options.rotationAngle !== 0;\n}\n\n/**\n * @private\n */\nfunction isResizeExpected (options) {\n return options.width !== -1 || options.height !== -1;\n}\n\n/**\n * Resize image to `width`, `height` or `width x height`.\n *\n * When both a `width` and `height` are provided, the possible methods by which the image should **fit** these are:\n * - `cover`: (default) Preserving aspect ratio, attempt to ensure the image covers both provided dimensions by cropping/clipping to fit.\n * - `contain`: Preserving aspect ratio, contain within both provided dimensions using \"letterboxing\" where necessary.\n * - `fill`: Ignore the aspect ratio of the input and stretch to both provided dimensions.\n * - `inside`: Preserving aspect ratio, resize the image to be as large as possible while ensuring its dimensions are less than or equal to both those specified.\n * - `outside`: Preserving aspect ratio, resize the image to be as small as possible while ensuring its dimensions are greater than or equal to both those specified.\n *\n * Some of these values are based on the [object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) CSS property.\n *\n * <img alt=\"Examples of various values for the fit property when resizing\" width=\"100%\" style=\"aspect-ratio: 998/243\" src=\"/api-resize-fit.svg\">\n *\n * When using a **fit** of `cover` or `contain`, the default **position** is `centre`. Other options are:\n * - `sharp.position`: `top`, `right top`, `right`, `right bottom`, `bottom`, `left bottom`, `left`, `left top`.\n * - `sharp.gravity`: `north`, `northeast`, `east`, `southeast`, `south`, `southwest`, `west`, `northwest`, `center` or `centre`.\n * - `sharp.strategy`: `cover` only, dynamically crop using either the `entropy` or `attention` strategy.\n *\n * Some of these values are based on the [object-position](https://developer.mozilla.org/en-US/docs/Web/CSS/object-position) CSS property.\n *\n * The strategy-based approach initially resizes so one dimension is at its target length\n * then repeatedly ranks edge regions, discarding the edge with the lowest score based on the selected strategy.\n * - `entropy`: focus on the region with the highest [Shannon entropy](https://en.wikipedia.org/wiki/Entropy_%28information_theory%29).\n * - `attention`: focus on the region with the highest luminance frequency, colour saturation and presence of skin tones.\n *\n * Possible downsizing kernels are:\n * - `nearest`: Use [nearest neighbour interpolation](http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation).\n * - `linear`: Use a [triangle filter](https://en.wikipedia.org/wiki/Triangular_function).\n * - `cubic`: Use a [Catmull-Rom spline](https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline).\n * - `mitchell`: Use a [Mitchell-Netravali spline](https://www.cs.utexas.edu/~fussell/courses/cs384g-fall2013/lectures/mitchell/Mitchell.pdf).\n * - `lanczos2`: Use a [Lanczos kernel](https://en.wikipedia.org/wiki/Lanczos_resampling#Lanczos_kernel) with `a=2`.\n * - `lanczos3`: Use a Lanczos kernel with `a=3` (the default).\n * - `mks2013`: Use a [Magic Kernel Sharp](https://johncostella.com/magic/mks.pdf) 2013 kernel, as adopted by Facebook.\n * - `mks2021`: Use a Magic Kernel Sharp 2021 kernel, with more accurate (reduced) sharpening than the 2013 version.\n *\n * When upsampling, these kernels map to `nearest`, `linear` and `cubic` interpolators.\n * Downsampling kernels without a matching upsampling interpolator map to `cubic`.\n *\n * Only one resize can occur per pipeline.\n * Previous calls to `resize` in the same pipeline will be ignored.\n *\n * @example\n * sharp(input)\n * .resize({ width: 100 })\n * .toBuffer()\n * .then(data => {\n * // 100 pixels wide, auto-scaled height\n * });\n *\n * @example\n * sharp(input)\n * .resize({ height: 100 })\n * .toBuffer()\n * .then(data => {\n * // 100 pixels high, auto-scaled width\n * });\n *\n * @example\n * sharp(input)\n * .resize(200, 300, {\n * kernel: sharp.kernel.nearest,\n * fit: 'contain',\n * position: 'right top',\n * background: { r: 255, g: 255, b: 255, alpha: 0.5 }\n * })\n * .toFile('output.png')\n * .then(() => {\n * // output.png is a 200 pixels wide and 300 pixels high image\n * // containing a nearest-neighbour scaled version\n * // contained within the north-east corner of a semi-transparent white canvas\n * });\n *\n * @example\n * const transformer = sharp()\n * .resize({\n * width: 200,\n * height: 200,\n * fit: sharp.fit.cover,\n * position: sharp.strategy.entropy\n * });\n * // Read image data from readableStream\n * // Write 200px square auto-cropped image data to writableStream\n * readableStream\n * .pipe(transformer)\n * .pipe(writableStream);\n *\n * @example\n * sharp(input)\n * .resize(200, 200, {\n * fit: sharp.fit.inside,\n * withoutEnlargement: true\n * })\n * .toFormat('jpeg')\n * .toBuffer()\n * .then(function(outputBuffer) {\n * // outputBuffer contains JPEG image data\n * // no wider and no higher than 200 pixels\n * // and no larger than the input image\n * });\n *\n * @example\n * sharp(input)\n * .resize(200, 200, {\n * fit: sharp.fit.outside,\n * withoutReduction: true\n * })\n * .toFormat('jpeg')\n * .toBuffer()\n * .then(function(outputBuffer) {\n * // outputBuffer contains JPEG image data\n * // of at least 200 pixels wide and 200 pixels high while maintaining aspect ratio\n * // and no smaller than the input image\n * });\n *\n * @example\n * const scaleByHalf = await sharp(input)\n * .metadata()\n * .then(({ width }) => sharp(input)\n * .resize(Math.round(width * 0.5))\n * .toBuffer()\n * );\n *\n * @param {number} [width] - How many pixels wide the resultant image should be. Use `null` or `undefined` to auto-scale the width to match the height.\n * @param {number} [height] - How many pixels high the resultant image should be. Use `null` or `undefined` to auto-scale the height to match the width.\n * @param {Object} [options]\n * @param {number} [options.width] - An alternative means of specifying `width`. If both are present this takes priority.\n * @param {number} [options.height] - An alternative means of specifying `height`. If both are present this takes priority.\n * @param {String} [options.fit='cover'] - How the image should be resized/cropped to fit the target dimension(s), one of `cover`, `contain`, `fill`, `inside` or `outside`.\n * @param {String} [options.position='centre'] - A position, gravity or strategy to use when `fit` is `cover` or `contain`.\n * @param {String|Object} [options.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour when `fit` is `contain`, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency.\n * @param {String} [options.kernel='lanczos3'] - The kernel to use for image reduction and the inferred interpolator to use for upsampling. Use the `fastShrinkOnLoad` option to control kernel vs shrink-on-load.\n * @param {Boolean} [options.withoutEnlargement=false] - Do not scale up if the width *or* height are already less than the target dimensions, equivalent to GraphicsMagick's `>` geometry option. This may result in output dimensions smaller than the target dimensions.\n * @param {Boolean} [options.withoutReduction=false] - Do not scale down if the width *or* height are already greater than the target dimensions, equivalent to GraphicsMagick's `<` geometry option. This may still result in a crop to reach the target dimensions.\n * @param {Boolean} [options.fastShrinkOnLoad=true] - Take greater advantage of the JPEG and WebP shrink-on-load feature, which can lead to a slight moir\u00E9 pattern or round-down of an auto-scaled dimension.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction resize (widthOrOptions, height, options) {\n if (isResizeExpected(this.options)) {\n this.options.debuglog('ignoring previous resize options');\n }\n if (this.options.widthPost !== -1) {\n this.options.debuglog('operation order will be: extract, resize, extract');\n }\n if (is.defined(widthOrOptions)) {\n if (is.object(widthOrOptions) && !is.defined(options)) {\n options = widthOrOptions;\n } else if (is.integer(widthOrOptions) && widthOrOptions > 0) {\n this.options.width = widthOrOptions;\n } else {\n throw is.invalidParameterError('width', 'positive integer', widthOrOptions);\n }\n } else {\n this.options.width = -1;\n }\n if (is.defined(height)) {\n if (is.integer(height) && height > 0) {\n this.options.height = height;\n } else {\n throw is.invalidParameterError('height', 'positive integer', height);\n }\n } else {\n this.options.height = -1;\n }\n if (is.object(options)) {\n // Width\n if (is.defined(options.width)) {\n if (is.integer(options.width) && options.width > 0) {\n this.options.width = options.width;\n } else {\n throw is.invalidParameterError('width', 'positive integer', options.width);\n }\n }\n // Height\n if (is.defined(options.height)) {\n if (is.integer(options.height) && options.height > 0) {\n this.options.height = options.height;\n } else {\n throw is.invalidParameterError('height', 'positive integer', options.height);\n }\n }\n // Fit\n if (is.defined(options.fit)) {\n const canvas = mapFitToCanvas[options.fit];\n if (is.string(canvas)) {\n this.options.canvas = canvas;\n } else {\n throw is.invalidParameterError('fit', 'valid fit', options.fit);\n }\n }\n // Position\n if (is.defined(options.position)) {\n const pos = is.integer(options.position)\n ? options.position\n : strategy[options.position] || position[options.position] || gravity[options.position];\n if (is.integer(pos) && (is.inRange(pos, 0, 8) || is.inRange(pos, 16, 17))) {\n this.options.position = pos;\n } else {\n throw is.invalidParameterError('position', 'valid position/gravity/strategy', options.position);\n }\n }\n // Background\n this._setBackgroundColourOption('resizeBackground', options.background);\n // Kernel\n if (is.defined(options.kernel)) {\n if (is.string(kernel[options.kernel])) {\n this.options.kernel = kernel[options.kernel];\n } else {\n throw is.invalidParameterError('kernel', 'valid kernel name', options.kernel);\n }\n }\n // Without enlargement\n if (is.defined(options.withoutEnlargement)) {\n this._setBooleanOption('withoutEnlargement', options.withoutEnlargement);\n }\n // Without reduction\n if (is.defined(options.withoutReduction)) {\n this._setBooleanOption('withoutReduction', options.withoutReduction);\n }\n // Shrink on load\n if (is.defined(options.fastShrinkOnLoad)) {\n this._setBooleanOption('fastShrinkOnLoad', options.fastShrinkOnLoad);\n }\n }\n if (isRotationExpected(this.options) && isResizeExpected(this.options)) {\n this.options.rotateBefore = true;\n }\n return this;\n}\n\n/**\n * Extend / pad / extrude one or more edges of the image with either\n * the provided background colour or pixels derived from the image.\n * This operation will always occur after resizing and extraction, if any.\n *\n * @example\n * // Resize to 140 pixels wide, then add 10 transparent pixels\n * // to the top, left and right edges and 20 to the bottom edge\n * sharp(input)\n * .resize(140)\n * .extend({\n * top: 10,\n * bottom: 20,\n * left: 10,\n * right: 10,\n * background: { r: 0, g: 0, b: 0, alpha: 0 }\n * })\n * ...\n *\n* @example\n * // Add a row of 10 red pixels to the bottom\n * sharp(input)\n * .extend({\n * bottom: 10,\n * background: 'red'\n * })\n * ...\n *\n * @example\n * // Extrude image by 8 pixels to the right, mirroring existing right hand edge\n * sharp(input)\n * .extend({\n * right: 8,\n * background: 'mirror'\n * })\n * ...\n *\n * @param {(number|Object)} extend - single pixel count to add to all edges or an Object with per-edge counts\n * @param {number} [extend.top=0]\n * @param {number} [extend.left=0]\n * @param {number} [extend.bottom=0]\n * @param {number} [extend.right=0]\n * @param {String} [extend.extendWith='background'] - populate new pixels using this method, one of: background, copy, repeat, mirror.\n * @param {String|Object} [extend.background={r: 0, g: 0, b: 0, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black without transparency.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n*/\nfunction extend (extend) {\n if (is.integer(extend) && extend > 0) {\n this.options.extendTop = extend;\n this.options.extendBottom = extend;\n this.options.extendLeft = extend;\n this.options.extendRight = extend;\n } else if (is.object(extend)) {\n if (is.defined(extend.top)) {\n if (is.integer(extend.top) && extend.top >= 0) {\n this.options.extendTop = extend.top;\n } else {\n throw is.invalidParameterError('top', 'positive integer', extend.top);\n }\n }\n if (is.defined(extend.bottom)) {\n if (is.integer(extend.bottom) && extend.bottom >= 0) {\n this.options.extendBottom = extend.bottom;\n } else {\n throw is.invalidParameterError('bottom', 'positive integer', extend.bottom);\n }\n }\n if (is.defined(extend.left)) {\n if (is.integer(extend.left) && extend.left >= 0) {\n this.options.extendLeft = extend.left;\n } else {\n throw is.invalidParameterError('left', 'positive integer', extend.left);\n }\n }\n if (is.defined(extend.right)) {\n if (is.integer(extend.right) && extend.right >= 0) {\n this.options.extendRight = extend.right;\n } else {\n throw is.invalidParameterError('right', 'positive integer', extend.right);\n }\n }\n this._setBackgroundColourOption('extendBackground', extend.background);\n if (is.defined(extend.extendWith)) {\n if (is.string(extendWith[extend.extendWith])) {\n this.options.extendWith = extendWith[extend.extendWith];\n } else {\n throw is.invalidParameterError('extendWith', 'one of: background, copy, repeat, mirror', extend.extendWith);\n }\n }\n } else {\n throw is.invalidParameterError('extend', 'integer or object', extend);\n }\n return this;\n}\n\n/**\n * Extract/crop a region of the image.\n *\n * - Use `extract` before `resize` for pre-resize extraction.\n * - Use `extract` after `resize` for post-resize extraction.\n * - Use `extract` twice and `resize` once for extract-then-resize-then-extract in a fixed operation order.\n *\n * @example\n * sharp(input)\n * .extract({ left: left, top: top, width: width, height: height })\n * .toFile(output, function(err) {\n * // Extract a region of the input image, saving in the same format.\n * });\n * @example\n * sharp(input)\n * .extract({ left: leftOffsetPre, top: topOffsetPre, width: widthPre, height: heightPre })\n * .resize(width, height)\n * .extract({ left: leftOffsetPost, top: topOffsetPost, width: widthPost, height: heightPost })\n * .toFile(output, function(err) {\n * // Extract a region, resize, then extract from the resized image\n * });\n *\n * @param {Object} options - describes the region to extract using integral pixel values\n * @param {number} options.left - zero-indexed offset from left edge\n * @param {number} options.top - zero-indexed offset from top edge\n * @param {number} options.width - width of region to extract\n * @param {number} options.height - height of region to extract\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction extract (options) {\n const suffix = isResizeExpected(this.options) || this.options.widthPre !== -1 ? 'Post' : 'Pre';\n if (this.options[`width${suffix}`] !== -1) {\n this.options.debuglog('ignoring previous extract options');\n }\n ['left', 'top', 'width', 'height'].forEach(function (name) {\n const value = options[name];\n if (is.integer(value) && value >= 0) {\n this.options[name + (name === 'left' || name === 'top' ? 'Offset' : '') + suffix] = value;\n } else {\n throw is.invalidParameterError(name, 'integer', value);\n }\n }, this);\n // Ensure existing rotation occurs before pre-resize extraction\n if (isRotationExpected(this.options) && !isResizeExpected(this.options)) {\n if (this.options.widthPre === -1 || this.options.widthPost === -1) {\n this.options.rotateBefore = true;\n }\n }\n if (this.options.input.autoOrient) {\n this.options.orientBefore = true;\n }\n return this;\n}\n\n/**\n * Trim pixels from all edges that contain values similar to the given background colour, which defaults to that of the top-left pixel.\n *\n * Images with an alpha channel will use the combined bounding box of alpha and non-alpha channels.\n *\n * If the result of this operation would trim an image to nothing then no change is made.\n *\n * The `info` response Object will contain `trimOffsetLeft` and `trimOffsetTop` properties.\n *\n * @example\n * // Trim pixels with a colour similar to that of the top-left pixel.\n * await sharp(input)\n * .trim()\n * .toFile(output);\n *\n * @example\n * // Trim pixels with the exact same colour as that of the top-left pixel.\n * await sharp(input)\n * .trim({\n * threshold: 0\n * })\n * .toFile(output);\n *\n * @example\n * // Assume input is line art and trim only pixels with a similar colour to red.\n * const output = await sharp(input)\n * .trim({\n * background: \"#FF0000\",\n * lineArt: true\n * })\n * .toBuffer();\n *\n * @example\n * // Trim all \"yellow-ish\" pixels, being more lenient with the higher threshold.\n * const output = await sharp(input)\n * .trim({\n * background: \"yellow\",\n * threshold: 42,\n * })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {string|Object} [options.background='top-left pixel'] - Background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to that of the top-left pixel.\n * @param {number} [options.threshold=10] - Allowed difference from the above colour, a positive number.\n * @param {boolean} [options.lineArt=false] - Does the input more closely resemble line art (e.g. vector) rather than being photographic?\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction trim (options) {\n this.options.trimThreshold = 10;\n if (is.defined(options)) {\n if (is.object(options)) {\n if (is.defined(options.background)) {\n this._setBackgroundColourOption('trimBackground', options.background);\n }\n if (is.defined(options.threshold)) {\n if (is.number(options.threshold) && options.threshold >= 0) {\n this.options.trimThreshold = options.threshold;\n } else {\n throw is.invalidParameterError('threshold', 'positive number', options.threshold);\n }\n }\n if (is.defined(options.lineArt)) {\n this._setBooleanOption('trimLineArt', options.lineArt);\n }\n } else {\n throw is.invalidParameterError('trim', 'object', options);\n }\n }\n if (isRotationExpected(this.options)) {\n this.options.rotateBefore = true;\n }\n return this;\n}\n\n/**\n * Decorate the Sharp prototype with resize-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n resize,\n extend,\n extract,\n trim\n });\n // Class attributes\n Sharp.gravity = gravity;\n Sharp.strategy = strategy;\n Sharp.kernel = kernel;\n Sharp.fit = fit;\n Sharp.position = position;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst is = require('./is');\n\n/**\n * Blend modes.\n * @member\n * @private\n */\nconst blend = {\n clear: 'clear',\n source: 'source',\n over: 'over',\n in: 'in',\n out: 'out',\n atop: 'atop',\n dest: 'dest',\n 'dest-over': 'dest-over',\n 'dest-in': 'dest-in',\n 'dest-out': 'dest-out',\n 'dest-atop': 'dest-atop',\n xor: 'xor',\n add: 'add',\n saturate: 'saturate',\n multiply: 'multiply',\n screen: 'screen',\n overlay: 'overlay',\n darken: 'darken',\n lighten: 'lighten',\n 'colour-dodge': 'colour-dodge',\n 'color-dodge': 'colour-dodge',\n 'colour-burn': 'colour-burn',\n 'color-burn': 'colour-burn',\n 'hard-light': 'hard-light',\n 'soft-light': 'soft-light',\n difference: 'difference',\n exclusion: 'exclusion'\n};\n\n/**\n * Composite image(s) over the processed (resized, extracted etc.) image.\n *\n * The images to composite must be the same size or smaller than the processed image.\n * If both `top` and `left` options are provided, they take precedence over `gravity`.\n *\n * Other operations in the same processing pipeline (e.g. resize, rotate, flip,\n * flop, extract) will always be applied to the input image before composition.\n *\n * The `blend` option can be one of `clear`, `source`, `over`, `in`, `out`, `atop`,\n * `dest`, `dest-over`, `dest-in`, `dest-out`, `dest-atop`,\n * `xor`, `add`, `saturate`, `multiply`, `screen`, `overlay`, `darken`, `lighten`,\n * `colour-dodge`, `color-dodge`, `colour-burn`,`color-burn`,\n * `hard-light`, `soft-light`, `difference`, `exclusion`.\n *\n * More information about blend modes can be found at\n * https://www.libvips.org/API/current/enum.BlendMode.html\n * and https://www.cairographics.org/operators/\n *\n * @since 0.22.0\n *\n * @example\n * await sharp(background)\n * .composite([\n * { input: layer1, gravity: 'northwest' },\n * { input: layer2, gravity: 'southeast' },\n * ])\n * .toFile('combined.png');\n *\n * @example\n * const output = await sharp('input.gif', { animated: true })\n * .composite([\n * { input: 'overlay.png', tile: true, blend: 'saturate' }\n * ])\n * .toBuffer();\n *\n * @example\n * sharp('input.png')\n * .rotate(180)\n * .resize(300)\n * .flatten( { background: '#ff6600' } )\n * .composite([{ input: 'overlay.png', gravity: 'southeast' }])\n * .sharpen()\n * .withMetadata()\n * .webp( { quality: 90 } )\n * .toBuffer()\n * .then(function(outputBuffer) {\n * // outputBuffer contains upside down, 300px wide, alpha channel flattened\n * // onto orange background, composited with overlay.png with SE gravity,\n * // sharpened, with metadata, 90% quality WebP image data. Phew!\n * });\n *\n * @param {Object[]} images - Ordered list of images to composite\n * @param {Buffer|String} [images[].input] - Buffer containing image data, String containing the path to an image file, or Create object (see below)\n * @param {Object} [images[].input.create] - describes a blank overlay to be created.\n * @param {Number} [images[].input.create.width]\n * @param {Number} [images[].input.create.height]\n * @param {Number} [images[].input.create.channels] - 3-4\n * @param {String|Object} [images[].input.create.background] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @param {Object} [images[].input.text] - describes a new text image to be created.\n * @param {string} [images[].input.text.text] - text to render as a UTF-8 string. It can contain Pango markup, for example `<i>Le</i>Monde`.\n * @param {string} [images[].input.text.font] - font name to render with.\n * @param {string} [images[].input.text.fontfile] - absolute filesystem path to a font file that can be used by `font`.\n * @param {number} [images[].input.text.width=0] - integral number of pixels to word-wrap at. Lines of text wider than this will be broken at word boundaries.\n * @param {number} [images[].input.text.height=0] - integral number of pixels high. When defined, `dpi` will be ignored and the text will automatically fit the pixel resolution defined by `width` and `height`. Will be ignored if `width` is not specified or set to 0.\n * @param {string} [images[].input.text.align='left'] - text alignment (`'left'`, `'centre'`, `'center'`, `'right'`).\n * @param {boolean} [images[].input.text.justify=false] - set this to true to apply justification to the text.\n * @param {number} [images[].input.text.dpi=72] - the resolution (size) at which to render the text. Does not take effect if `height` is specified.\n * @param {boolean} [images[].input.text.rgba=false] - set this to true to enable RGBA output. This is useful for colour emoji rendering, or support for Pango markup features like `<span foreground=\"red\">Red!</span>`.\n * @param {number} [images[].input.text.spacing=0] - text line height in points. Will use the font line height if none is specified.\n * @param {Boolean} [images[].autoOrient=false] - set to true to use EXIF orientation data, if present, to orient the image.\n * @param {String} [images[].blend='over'] - how to blend this image with the image below.\n * @param {String} [images[].gravity='centre'] - gravity at which to place the overlay.\n * @param {Number} [images[].top] - the pixel offset from the top edge.\n * @param {Number} [images[].left] - the pixel offset from the left edge.\n * @param {Boolean} [images[].tile=false] - set to true to repeat the overlay image across the entire image with the given `gravity`.\n * @param {Boolean} [images[].premultiplied=false] - set to true to avoid premultiplying the image below. Equivalent to the `--premultiplied` vips option.\n * @param {Number} [images[].density=72] - number representing the DPI for vector overlay image.\n * @param {Object} [images[].raw] - describes overlay when using raw pixel data.\n * @param {Number} [images[].raw.width]\n * @param {Number} [images[].raw.height]\n * @param {Number} [images[].raw.channels]\n * @param {boolean} [images[].animated=false] - Set to `true` to read all frames/pages of an animated image.\n * @param {string} [images[].failOn='warning'] - @see {@link /api-constructor/ constructor parameters}\n * @param {number|boolean} [images[].limitInputPixels=268402689] - @see {@link /api-constructor/ constructor parameters}\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction composite (images) {\n if (!Array.isArray(images)) {\n throw is.invalidParameterError('images to composite', 'array', images);\n }\n this.options.composite = images.map(image => {\n if (!is.object(image)) {\n throw is.invalidParameterError('image to composite', 'object', image);\n }\n const inputOptions = this._inputOptionsFromObject(image);\n const composite = {\n input: this._createInputDescriptor(image.input, inputOptions, { allowStream: false }),\n blend: 'over',\n tile: false,\n left: 0,\n top: 0,\n hasOffset: false,\n gravity: 0,\n premultiplied: false\n };\n if (is.defined(image.blend)) {\n if (is.string(blend[image.blend])) {\n composite.blend = blend[image.blend];\n } else {\n throw is.invalidParameterError('blend', 'valid blend name', image.blend);\n }\n }\n if (is.defined(image.tile)) {\n if (is.bool(image.tile)) {\n composite.tile = image.tile;\n } else {\n throw is.invalidParameterError('tile', 'boolean', image.tile);\n }\n }\n if (is.defined(image.left)) {\n if (is.integer(image.left)) {\n composite.left = image.left;\n } else {\n throw is.invalidParameterError('left', 'integer', image.left);\n }\n }\n if (is.defined(image.top)) {\n if (is.integer(image.top)) {\n composite.top = image.top;\n } else {\n throw is.invalidParameterError('top', 'integer', image.top);\n }\n }\n if (is.defined(image.top) !== is.defined(image.left)) {\n throw new Error('Expected both left and top to be set');\n } else {\n composite.hasOffset = is.integer(image.top) && is.integer(image.left);\n }\n if (is.defined(image.gravity)) {\n if (is.integer(image.gravity) && is.inRange(image.gravity, 0, 8)) {\n composite.gravity = image.gravity;\n } else if (is.string(image.gravity) && is.integer(this.constructor.gravity[image.gravity])) {\n composite.gravity = this.constructor.gravity[image.gravity];\n } else {\n throw is.invalidParameterError('gravity', 'valid gravity', image.gravity);\n }\n }\n if (is.defined(image.premultiplied)) {\n if (is.bool(image.premultiplied)) {\n composite.premultiplied = image.premultiplied;\n } else {\n throw is.invalidParameterError('premultiplied', 'boolean', image.premultiplied);\n }\n }\n return composite;\n });\n return this;\n}\n\n/**\n * Decorate the Sharp prototype with composite-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Sharp.prototype.composite = composite;\n Sharp.blend = blend;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst is = require('./is');\n\n/**\n * How accurate an operation should be.\n * @member\n * @private\n */\nconst vipsPrecision = {\n integer: 'integer',\n float: 'float',\n approximate: 'approximate'\n};\n\n/**\n * Rotate the output image.\n *\n * The provided angle is converted to a valid positive degree rotation.\n * For example, `-450` will produce a 270 degree rotation.\n *\n * When rotating by an angle other than a multiple of 90,\n * the background colour can be provided with the `background` option.\n *\n * For backwards compatibility, if no angle is provided, `.autoOrient()` will be called.\n *\n * Only one rotation can occur per pipeline (aside from an initial call without\n * arguments to orient via EXIF data). Previous calls to `rotate` in the same\n * pipeline will be ignored.\n *\n * Multi-page images can only be rotated by 180 degrees.\n *\n * Method order is important when rotating, resizing and/or extracting regions,\n * for example `.rotate(x).extract(y)` will produce a different result to `.extract(y).rotate(x)`.\n *\n * @example\n * const rotateThenResize = await sharp(input)\n * .rotate(90)\n * .resize({ width: 16, height: 8, fit: 'fill' })\n * .toBuffer();\n * const resizeThenRotate = await sharp(input)\n * .resize({ width: 16, height: 8, fit: 'fill' })\n * .rotate(90)\n * .toBuffer();\n *\n * @param {number} [angle=auto] angle of rotation.\n * @param {Object} [options] - if present, is an Object with optional attributes.\n * @param {string|Object} [options.background=\"#000000\"] parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction rotate (angle, options) {\n if (!is.defined(angle)) {\n return this.autoOrient();\n }\n if (this.options.angle || this.options.rotationAngle) {\n this.options.debuglog('ignoring previous rotate options');\n this.options.angle = 0;\n this.options.rotationAngle = 0;\n }\n if (is.integer(angle) && !(angle % 90)) {\n this.options.angle = angle;\n } else if (is.number(angle)) {\n this.options.rotationAngle = angle;\n if (is.object(options) && options.background) {\n this._setBackgroundColourOption('rotationBackground', options.background);\n }\n } else {\n throw is.invalidParameterError('angle', 'numeric', angle);\n }\n return this;\n}\n\n/**\n * Auto-orient based on the EXIF `Orientation` tag, then remove the tag.\n * Mirroring is supported and may infer the use of a flip operation.\n *\n * Previous or subsequent use of `rotate(angle)` and either `flip()` or `flop()`\n * will logically occur after auto-orientation, regardless of call order.\n *\n * @example\n * const output = await sharp(input).autoOrient().toBuffer();\n *\n * @example\n * const pipeline = sharp()\n * .autoOrient()\n * .resize(null, 200)\n * .toBuffer(function (err, outputBuffer, info) {\n * // outputBuffer contains 200px high JPEG image data,\n * // auto-oriented using EXIF Orientation tag\n * // info.width and info.height contain the dimensions of the resized image\n * });\n * readableStream.pipe(pipeline);\n *\n * @returns {Sharp}\n */\nfunction autoOrient () {\n this.options.input.autoOrient = true;\n return this;\n}\n\n/**\n * Mirror the image vertically (up-down) about the x-axis.\n * This always occurs before rotation, if any.\n *\n * This operation does not work correctly with multi-page images.\n *\n * @example\n * const output = await sharp(input).flip().toBuffer();\n *\n * @param {Boolean} [flip=true]\n * @returns {Sharp}\n */\nfunction flip (flip) {\n this.options.flip = is.bool(flip) ? flip : true;\n return this;\n}\n\n/**\n * Mirror the image horizontally (left-right) about the y-axis.\n * This always occurs before rotation, if any.\n *\n * @example\n * const output = await sharp(input).flop().toBuffer();\n *\n * @param {Boolean} [flop=true]\n * @returns {Sharp}\n */\nfunction flop (flop) {\n this.options.flop = is.bool(flop) ? flop : true;\n return this;\n}\n\n/**\n * Perform an affine transform on an image. This operation will always occur after resizing, extraction and rotation, if any.\n *\n * You must provide an array of length 4 or a 2x2 affine transformation matrix.\n * By default, new pixels are filled with a black background. You can provide a background colour with the `background` option.\n * A particular interpolator may also be specified. Set the `interpolator` option to an attribute of the `sharp.interpolators` Object e.g. `sharp.interpolators.nohalo`.\n *\n * In the case of a 2x2 matrix, the transform is:\n * - X = `matrix[0, 0]` \\* (x + `idx`) + `matrix[0, 1]` \\* (y + `idy`) + `odx`\n * - Y = `matrix[1, 0]` \\* (x + `idx`) + `matrix[1, 1]` \\* (y + `idy`) + `ody`\n *\n * where:\n * - x and y are the coordinates in input image.\n * - X and Y are the coordinates in output image.\n * - (0,0) is the upper left corner.\n *\n * @since 0.27.0\n *\n * @example\n * const pipeline = sharp()\n * .affine([[1, 0.3], [0.1, 0.7]], {\n * background: 'white',\n * interpolator: sharp.interpolators.nohalo\n * })\n * .toBuffer((err, outputBuffer, info) => {\n * // outputBuffer contains the transformed image\n * // info.width and info.height contain the new dimensions\n * });\n *\n * inputStream\n * .pipe(pipeline);\n *\n * @param {Array<Array<number>>|Array<number>} matrix - affine transformation matrix\n * @param {Object} [options] - if present, is an Object with optional attributes.\n * @param {String|Object} [options.background=\"#000000\"] - parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.\n * @param {Number} [options.idx=0] - input horizontal offset\n * @param {Number} [options.idy=0] - input vertical offset\n * @param {Number} [options.odx=0] - output horizontal offset\n * @param {Number} [options.ody=0] - output vertical offset\n * @param {String} [options.interpolator=sharp.interpolators.bicubic] - interpolator\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction affine (matrix, options) {\n const flatMatrix = [].concat(...matrix);\n if (flatMatrix.length === 4 && flatMatrix.every(is.number)) {\n this.options.affineMatrix = flatMatrix;\n } else {\n throw is.invalidParameterError('matrix', '1x4 or 2x2 array', matrix);\n }\n\n if (is.defined(options)) {\n if (is.object(options)) {\n this._setBackgroundColourOption('affineBackground', options.background);\n if (is.defined(options.idx)) {\n if (is.number(options.idx)) {\n this.options.affineIdx = options.idx;\n } else {\n throw is.invalidParameterError('options.idx', 'number', options.idx);\n }\n }\n if (is.defined(options.idy)) {\n if (is.number(options.idy)) {\n this.options.affineIdy = options.idy;\n } else {\n throw is.invalidParameterError('options.idy', 'number', options.idy);\n }\n }\n if (is.defined(options.odx)) {\n if (is.number(options.odx)) {\n this.options.affineOdx = options.odx;\n } else {\n throw is.invalidParameterError('options.odx', 'number', options.odx);\n }\n }\n if (is.defined(options.ody)) {\n if (is.number(options.ody)) {\n this.options.affineOdy = options.ody;\n } else {\n throw is.invalidParameterError('options.ody', 'number', options.ody);\n }\n }\n if (is.defined(options.interpolator)) {\n if (is.inArray(options.interpolator, Object.values(this.constructor.interpolators))) {\n this.options.affineInterpolator = options.interpolator;\n } else {\n throw is.invalidParameterError('options.interpolator', 'valid interpolator name', options.interpolator);\n }\n }\n } else {\n throw is.invalidParameterError('options', 'object', options);\n }\n }\n\n return this;\n}\n\n/**\n * Sharpen the image.\n *\n * When used without parameters, performs a fast, mild sharpen of the output image.\n *\n * When a `sigma` is provided, performs a slower, more accurate sharpen of the L channel in the LAB colour space.\n * Fine-grained control over the level of sharpening in \"flat\" (m1) and \"jagged\" (m2) areas is available.\n *\n * See {@link https://www.libvips.org/API/current/method.Image.sharpen.html libvips sharpen} operation.\n *\n * @example\n * const data = await sharp(input).sharpen().toBuffer();\n *\n * @example\n * const data = await sharp(input).sharpen({ sigma: 2 }).toBuffer();\n *\n * @example\n * const data = await sharp(input)\n * .sharpen({\n * sigma: 2,\n * m1: 0,\n * m2: 3,\n * x1: 3,\n * y2: 15,\n * y3: 15,\n * })\n * .toBuffer();\n *\n * @param {Object|number} [options] - if present, is an Object with attributes\n * @param {number} [options.sigma] - the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`, between 0.000001 and 10\n * @param {number} [options.m1=1.0] - the level of sharpening to apply to \"flat\" areas, between 0 and 1000000\n * @param {number} [options.m2=2.0] - the level of sharpening to apply to \"jagged\" areas, between 0 and 1000000\n * @param {number} [options.x1=2.0] - threshold between \"flat\" and \"jagged\", between 0 and 1000000\n * @param {number} [options.y2=10.0] - maximum amount of brightening, between 0 and 1000000\n * @param {number} [options.y3=20.0] - maximum amount of darkening, between 0 and 1000000\n * @param {number} [flat] - (deprecated) see `options.m1`.\n * @param {number} [jagged] - (deprecated) see `options.m2`.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction sharpen (options, flat, jagged) {\n if (!is.defined(options)) {\n // No arguments: default to mild sharpen\n this.options.sharpenSigma = -1;\n } else if (is.bool(options)) {\n // Deprecated boolean argument: apply mild sharpen?\n this.options.sharpenSigma = options ? -1 : 0;\n } else if (is.number(options) && is.inRange(options, 0.01, 10000)) {\n // Deprecated numeric argument: specific sigma\n this.options.sharpenSigma = options;\n // Deprecated control over flat areas\n if (is.defined(flat)) {\n if (is.number(flat) && is.inRange(flat, 0, 10000)) {\n this.options.sharpenM1 = flat;\n } else {\n throw is.invalidParameterError('flat', 'number between 0 and 10000', flat);\n }\n }\n // Deprecated control over jagged areas\n if (is.defined(jagged)) {\n if (is.number(jagged) && is.inRange(jagged, 0, 10000)) {\n this.options.sharpenM2 = jagged;\n } else {\n throw is.invalidParameterError('jagged', 'number between 0 and 10000', jagged);\n }\n }\n } else if (is.plainObject(options)) {\n if (is.number(options.sigma) && is.inRange(options.sigma, 0.000001, 10)) {\n this.options.sharpenSigma = options.sigma;\n } else {\n throw is.invalidParameterError('options.sigma', 'number between 0.000001 and 10', options.sigma);\n }\n if (is.defined(options.m1)) {\n if (is.number(options.m1) && is.inRange(options.m1, 0, 1000000)) {\n this.options.sharpenM1 = options.m1;\n } else {\n throw is.invalidParameterError('options.m1', 'number between 0 and 1000000', options.m1);\n }\n }\n if (is.defined(options.m2)) {\n if (is.number(options.m2) && is.inRange(options.m2, 0, 1000000)) {\n this.options.sharpenM2 = options.m2;\n } else {\n throw is.invalidParameterError('options.m2', 'number between 0 and 1000000', options.m2);\n }\n }\n if (is.defined(options.x1)) {\n if (is.number(options.x1) && is.inRange(options.x1, 0, 1000000)) {\n this.options.sharpenX1 = options.x1;\n } else {\n throw is.invalidParameterError('options.x1', 'number between 0 and 1000000', options.x1);\n }\n }\n if (is.defined(options.y2)) {\n if (is.number(options.y2) && is.inRange(options.y2, 0, 1000000)) {\n this.options.sharpenY2 = options.y2;\n } else {\n throw is.invalidParameterError('options.y2', 'number between 0 and 1000000', options.y2);\n }\n }\n if (is.defined(options.y3)) {\n if (is.number(options.y3) && is.inRange(options.y3, 0, 1000000)) {\n this.options.sharpenY3 = options.y3;\n } else {\n throw is.invalidParameterError('options.y3', 'number between 0 and 1000000', options.y3);\n }\n }\n } else {\n throw is.invalidParameterError('sigma', 'number between 0.01 and 10000', options);\n }\n return this;\n}\n\n/**\n * Apply median filter.\n * When used without parameters the default window is 3x3.\n *\n * @example\n * const output = await sharp(input).median().toBuffer();\n *\n * @example\n * const output = await sharp(input).median(5).toBuffer();\n *\n * @param {number} [size=3] square mask size: size x size\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction median (size) {\n if (!is.defined(size)) {\n // No arguments: default to 3x3\n this.options.medianSize = 3;\n } else if (is.integer(size) && is.inRange(size, 1, 1000)) {\n // Numeric argument: specific sigma\n this.options.medianSize = size;\n } else {\n throw is.invalidParameterError('size', 'integer between 1 and 1000', size);\n }\n return this;\n}\n\n/**\n * Blur the image.\n *\n * When used without parameters, performs a fast 3x3 box blur (equivalent to a box linear filter).\n *\n * When a `sigma` is provided, performs a slower, more accurate Gaussian blur.\n *\n * @example\n * const boxBlurred = await sharp(input)\n * .blur()\n * .toBuffer();\n *\n * @example\n * const gaussianBlurred = await sharp(input)\n * .blur(5)\n * .toBuffer();\n *\n * @param {Object|number|Boolean} [options]\n * @param {number} [options.sigma] a value between 0.3 and 1000 representing the sigma of the Gaussian mask, where `sigma = 1 + radius / 2`.\n * @param {string} [options.precision='integer'] How accurate the operation should be, one of: integer, float, approximate.\n * @param {number} [options.minAmplitude=0.2] A value between 0.001 and 1. A smaller value will generate a larger, more accurate mask.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction blur (options) {\n let sigma;\n if (is.number(options)) {\n sigma = options;\n } else if (is.plainObject(options)) {\n if (!is.number(options.sigma)) {\n throw is.invalidParameterError('options.sigma', 'number between 0.3 and 1000', sigma);\n }\n sigma = options.sigma;\n if ('precision' in options) {\n if (is.string(vipsPrecision[options.precision])) {\n this.options.precision = vipsPrecision[options.precision];\n } else {\n throw is.invalidParameterError('precision', 'one of: integer, float, approximate', options.precision);\n }\n }\n if ('minAmplitude' in options) {\n if (is.number(options.minAmplitude) && is.inRange(options.minAmplitude, 0.001, 1)) {\n this.options.minAmpl = options.minAmplitude;\n } else {\n throw is.invalidParameterError('minAmplitude', 'number between 0.001 and 1', options.minAmplitude);\n }\n }\n }\n\n if (!is.defined(options)) {\n // No arguments: default to mild blur\n this.options.blurSigma = -1;\n } else if (is.bool(options)) {\n // Boolean argument: apply mild blur?\n this.options.blurSigma = options ? -1 : 0;\n } else if (is.number(sigma) && is.inRange(sigma, 0.3, 1000)) {\n // Numeric argument: specific sigma\n this.options.blurSigma = sigma;\n } else {\n throw is.invalidParameterError('sigma', 'number between 0.3 and 1000', sigma);\n }\n\n return this;\n}\n\n/**\n * Expand foreground objects using the dilate morphological operator.\n *\n * @example\n * const output = await sharp(input)\n * .dilate()\n * .toBuffer();\n *\n * @param {Number} [width=1] dilation width in pixels.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction dilate (width) {\n if (!is.defined(width)) {\n this.options.dilateWidth = 1;\n } else if (is.integer(width) && width > 0) {\n this.options.dilateWidth = width;\n } else {\n throw is.invalidParameterError('dilate', 'positive integer', dilate);\n }\n return this;\n}\n\n/**\n * Shrink foreground objects using the erode morphological operator.\n *\n * @example\n * const output = await sharp(input)\n * .erode()\n * .toBuffer();\n *\n * @param {Number} [width=1] erosion width in pixels.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction erode (width) {\n if (!is.defined(width)) {\n this.options.erodeWidth = 1;\n } else if (is.integer(width) && width > 0) {\n this.options.erodeWidth = width;\n } else {\n throw is.invalidParameterError('erode', 'positive integer', erode);\n }\n return this;\n}\n\n/**\n * Merge alpha transparency channel, if any, with a background, then remove the alpha channel.\n *\n * See also {@link /api-channel#removealpha removeAlpha}.\n *\n * @example\n * await sharp(rgbaInput)\n * .flatten({ background: '#F0A703' })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {string|Object} [options.background={r: 0, g: 0, b: 0}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to black.\n * @returns {Sharp}\n */\nfunction flatten (options) {\n this.options.flatten = is.bool(options) ? options : true;\n if (is.object(options)) {\n this._setBackgroundColourOption('flattenBackground', options.background);\n }\n return this;\n}\n\n/**\n * Ensure the image has an alpha channel\n * with all white pixel values made fully transparent.\n *\n * Existing alpha channel values for non-white pixels remain unchanged.\n *\n * This feature is experimental and the API may change.\n *\n * @since 0.32.1\n *\n * @example\n * await sharp(rgbInput)\n * .unflatten()\n * .toBuffer();\n *\n * @example\n * await sharp(rgbInput)\n * .threshold(128, { grayscale: false }) // converter bright pixels to white\n * .unflatten()\n * .toBuffer();\n */\nfunction unflatten () {\n this.options.unflatten = true;\n return this;\n}\n\n/**\n * Apply a gamma correction by reducing the encoding (darken) pre-resize at a factor of `1/gamma`\n * then increasing the encoding (brighten) post-resize at a factor of `gamma`.\n * This can improve the perceived brightness of a resized image in non-linear colour spaces.\n * JPEG and WebP input images will not take advantage of the shrink-on-load performance optimisation\n * when applying a gamma correction.\n *\n * Supply a second argument to use a different output gamma value, otherwise the first value is used in both cases.\n *\n * @param {number} [gamma=2.2] value between 1.0 and 3.0.\n * @param {number} [gammaOut] value between 1.0 and 3.0. (optional, defaults to same as `gamma`)\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction gamma (gamma, gammaOut) {\n if (!is.defined(gamma)) {\n // Default gamma correction of 2.2 (sRGB)\n this.options.gamma = 2.2;\n } else if (is.number(gamma) && is.inRange(gamma, 1, 3)) {\n this.options.gamma = gamma;\n } else {\n throw is.invalidParameterError('gamma', 'number between 1.0 and 3.0', gamma);\n }\n if (!is.defined(gammaOut)) {\n // Default gamma correction for output is same as input\n this.options.gammaOut = this.options.gamma;\n } else if (is.number(gammaOut) && is.inRange(gammaOut, 1, 3)) {\n this.options.gammaOut = gammaOut;\n } else {\n throw is.invalidParameterError('gammaOut', 'number between 1.0 and 3.0', gammaOut);\n }\n return this;\n}\n\n/**\n * Produce the \"negative\" of the image.\n *\n * @example\n * const output = await sharp(input)\n * .negate()\n * .toBuffer();\n *\n * @example\n * const output = await sharp(input)\n * .negate({ alpha: false })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {Boolean} [options.alpha=true] Whether or not to negate any alpha channel\n * @returns {Sharp}\n */\nfunction negate (options) {\n this.options.negate = is.bool(options) ? options : true;\n if (is.plainObject(options) && 'alpha' in options) {\n if (!is.bool(options.alpha)) {\n throw is.invalidParameterError('alpha', 'should be boolean value', options.alpha);\n } else {\n this.options.negateAlpha = options.alpha;\n }\n }\n return this;\n}\n\n/**\n * Enhance output image contrast by stretching its luminance to cover a full dynamic range.\n *\n * Uses a histogram-based approach, taking a default range of 1% to 99% to reduce sensitivity to noise at the extremes.\n *\n * Luminance values below the `lower` percentile will be underexposed by clipping to zero.\n * Luminance values above the `upper` percentile will be overexposed by clipping to the max pixel value.\n *\n * @example\n * const output = await sharp(input)\n * .normalise()\n * .toBuffer();\n *\n * @example\n * const output = await sharp(input)\n * .normalise({ lower: 0, upper: 100 })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {number} [options.lower=1] - Percentile below which luminance values will be underexposed.\n * @param {number} [options.upper=99] - Percentile above which luminance values will be overexposed.\n * @returns {Sharp}\n */\nfunction normalise (options) {\n if (is.plainObject(options)) {\n if (is.defined(options.lower)) {\n if (is.number(options.lower) && is.inRange(options.lower, 0, 99)) {\n this.options.normaliseLower = options.lower;\n } else {\n throw is.invalidParameterError('lower', 'number between 0 and 99', options.lower);\n }\n }\n if (is.defined(options.upper)) {\n if (is.number(options.upper) && is.inRange(options.upper, 1, 100)) {\n this.options.normaliseUpper = options.upper;\n } else {\n throw is.invalidParameterError('upper', 'number between 1 and 100', options.upper);\n }\n }\n }\n if (this.options.normaliseLower >= this.options.normaliseUpper) {\n throw is.invalidParameterError('range', 'lower to be less than upper',\n `${this.options.normaliseLower} >= ${this.options.normaliseUpper}`);\n }\n this.options.normalise = true;\n return this;\n}\n\n/**\n * Alternative spelling of normalise.\n *\n * @example\n * const output = await sharp(input)\n * .normalize()\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {number} [options.lower=1] - Percentile below which luminance values will be underexposed.\n * @param {number} [options.upper=99] - Percentile above which luminance values will be overexposed.\n * @returns {Sharp}\n */\nfunction normalize (options) {\n return this.normalise(options);\n}\n\n/**\n * Perform contrast limiting adaptive histogram equalization\n * {@link https://en.wikipedia.org/wiki/Adaptive_histogram_equalization#Contrast_Limited_AHE CLAHE}.\n *\n * This will, in general, enhance the clarity of the image by bringing out darker details.\n *\n * @since 0.28.3\n *\n * @example\n * const output = await sharp(input)\n * .clahe({\n * width: 3,\n * height: 3,\n * })\n * .toBuffer();\n *\n * @param {Object} options\n * @param {number} options.width - Integral width of the search window, in pixels.\n * @param {number} options.height - Integral height of the search window, in pixels.\n * @param {number} [options.maxSlope=3] - Integral level of brightening, between 0 and 100, where 0 disables contrast limiting.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction clahe (options) {\n if (is.plainObject(options)) {\n if (is.integer(options.width) && options.width > 0) {\n this.options.claheWidth = options.width;\n } else {\n throw is.invalidParameterError('width', 'integer greater than zero', options.width);\n }\n if (is.integer(options.height) && options.height > 0) {\n this.options.claheHeight = options.height;\n } else {\n throw is.invalidParameterError('height', 'integer greater than zero', options.height);\n }\n if (is.defined(options.maxSlope)) {\n if (is.integer(options.maxSlope) && is.inRange(options.maxSlope, 0, 100)) {\n this.options.claheMaxSlope = options.maxSlope;\n } else {\n throw is.invalidParameterError('maxSlope', 'integer between 0 and 100', options.maxSlope);\n }\n }\n } else {\n throw is.invalidParameterError('options', 'plain object', options);\n }\n return this;\n}\n\n/**\n * Convolve the image with the specified kernel.\n *\n * @example\n * sharp(input)\n * .convolve({\n * width: 3,\n * height: 3,\n * kernel: [-1, 0, 1, -2, 0, 2, -1, 0, 1]\n * })\n * .raw()\n * .toBuffer(function(err, data, info) {\n * // data contains the raw pixel data representing the convolution\n * // of the input image with the horizontal Sobel operator\n * });\n *\n * @param {Object} kernel\n * @param {number} kernel.width - width of the kernel in pixels.\n * @param {number} kernel.height - height of the kernel in pixels.\n * @param {Array<number>} kernel.kernel - Array of length `width*height` containing the kernel values.\n * @param {number} [kernel.scale=sum] - the scale of the kernel in pixels.\n * @param {number} [kernel.offset=0] - the offset of the kernel in pixels.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction convolve (kernel) {\n if (!is.object(kernel) || !Array.isArray(kernel.kernel) ||\n !is.integer(kernel.width) || !is.integer(kernel.height) ||\n !is.inRange(kernel.width, 3, 1001) || !is.inRange(kernel.height, 3, 1001) ||\n kernel.height * kernel.width !== kernel.kernel.length\n ) {\n // must pass in a kernel\n throw new Error('Invalid convolution kernel');\n }\n // Default scale is sum of kernel values\n if (!is.integer(kernel.scale)) {\n kernel.scale = kernel.kernel.reduce((a, b) => a + b, 0);\n }\n // Clip scale to a minimum value of 1\n if (kernel.scale < 1) {\n kernel.scale = 1;\n }\n if (!is.integer(kernel.offset)) {\n kernel.offset = 0;\n }\n this.options.convKernel = kernel;\n return this;\n}\n\n/**\n * Any pixel value greater than or equal to the threshold value will be set to 255, otherwise it will be set to 0.\n * @param {number} [threshold=128] - a value in the range 0-255 representing the level at which the threshold will be applied.\n * @param {Object} [options]\n * @param {Boolean} [options.greyscale=true] - convert to single channel greyscale.\n * @param {Boolean} [options.grayscale=true] - alternative spelling for greyscale.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction threshold (threshold, options) {\n if (!is.defined(threshold)) {\n this.options.threshold = 128;\n } else if (is.bool(threshold)) {\n this.options.threshold = threshold ? 128 : 0;\n } else if (is.integer(threshold) && is.inRange(threshold, 0, 255)) {\n this.options.threshold = threshold;\n } else {\n throw is.invalidParameterError('threshold', 'integer between 0 and 255', threshold);\n }\n if (!is.object(options) || options.greyscale === true || options.grayscale === true) {\n this.options.thresholdGrayscale = true;\n } else {\n this.options.thresholdGrayscale = false;\n }\n return this;\n}\n\n/**\n * Perform a bitwise boolean operation with operand image.\n *\n * This operation creates an output image where each pixel is the result of\n * the selected bitwise boolean `operation` between the corresponding pixels of the input images.\n *\n * @param {Buffer|string} operand - Buffer containing image data or string containing the path to an image file.\n * @param {string} operator - one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.\n * @param {Object} [options]\n * @param {Object} [options.raw] - describes operand when using raw pixel data.\n * @param {number} [options.raw.width]\n * @param {number} [options.raw.height]\n * @param {number} [options.raw.channels]\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction boolean (operand, operator, options) {\n this.options.boolean = this._createInputDescriptor(operand, options);\n if (is.string(operator) && is.inArray(operator, ['and', 'or', 'eor'])) {\n this.options.booleanOp = operator;\n } else {\n throw is.invalidParameterError('operator', 'one of: and, or, eor', operator);\n }\n return this;\n}\n\n/**\n * Apply the linear formula `a` * input + `b` to the image to adjust image levels.\n *\n * When a single number is provided, it will be used for all image channels.\n * When an array of numbers is provided, the array length must match the number of channels.\n *\n * @example\n * await sharp(input)\n * .linear(0.5, 2)\n * .toBuffer();\n *\n * @example\n * await sharp(rgbInput)\n * .linear(\n * [0.25, 0.5, 0.75],\n * [150, 100, 50]\n * )\n * .toBuffer();\n *\n * @param {(number|number[])} [a=[]] multiplier\n * @param {(number|number[])} [b=[]] offset\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction linear (a, b) {\n if (!is.defined(a) && is.number(b)) {\n a = 1.0;\n } else if (is.number(a) && !is.defined(b)) {\n b = 0.0;\n }\n if (!is.defined(a)) {\n this.options.linearA = [];\n } else if (is.number(a)) {\n this.options.linearA = [a];\n } else if (Array.isArray(a) && a.length && a.every(is.number)) {\n this.options.linearA = a;\n } else {\n throw is.invalidParameterError('a', 'number or array of numbers', a);\n }\n if (!is.defined(b)) {\n this.options.linearB = [];\n } else if (is.number(b)) {\n this.options.linearB = [b];\n } else if (Array.isArray(b) && b.length && b.every(is.number)) {\n this.options.linearB = b;\n } else {\n throw is.invalidParameterError('b', 'number or array of numbers', b);\n }\n if (this.options.linearA.length !== this.options.linearB.length) {\n throw new Error('Expected a and b to be arrays of the same length');\n }\n return this;\n}\n\n/**\n * Recombine the image with the specified matrix.\n *\n * @since 0.21.1\n *\n * @example\n * sharp(input)\n * .recomb([\n * [0.3588, 0.7044, 0.1368],\n * [0.2990, 0.5870, 0.1140],\n * [0.2392, 0.4696, 0.0912],\n * ])\n * .raw()\n * .toBuffer(function(err, data, info) {\n * // data contains the raw pixel data after applying the matrix\n * // With this example input, a sepia filter has been applied\n * });\n *\n * @param {Array<Array<number>>} inputMatrix - 3x3 or 4x4 Recombination matrix\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction recomb (inputMatrix) {\n if (!Array.isArray(inputMatrix)) {\n throw is.invalidParameterError('inputMatrix', 'array', inputMatrix);\n }\n if (inputMatrix.length !== 3 && inputMatrix.length !== 4) {\n throw is.invalidParameterError('inputMatrix', '3x3 or 4x4 array', inputMatrix.length);\n }\n const recombMatrix = inputMatrix.flat().map(Number);\n if (recombMatrix.length !== 9 && recombMatrix.length !== 16) {\n throw is.invalidParameterError('inputMatrix', 'cardinality of 9 or 16', recombMatrix.length);\n }\n this.options.recombMatrix = recombMatrix;\n return this;\n}\n\n/**\n * Transforms the image using brightness, saturation, hue rotation, and lightness.\n * Brightness and lightness both operate on luminance, with the difference being that\n * brightness is multiplicative whereas lightness is additive.\n *\n * @since 0.22.1\n *\n * @example\n * // increase brightness by a factor of 2\n * const output = await sharp(input)\n * .modulate({\n * brightness: 2\n * })\n * .toBuffer();\n *\n * @example\n * // hue-rotate by 180 degrees\n * const output = await sharp(input)\n * .modulate({\n * hue: 180\n * })\n * .toBuffer();\n *\n * @example\n * // increase lightness by +50\n * const output = await sharp(input)\n * .modulate({\n * lightness: 50\n * })\n * .toBuffer();\n *\n * @example\n * // decrease brightness and saturation while also hue-rotating by 90 degrees\n * const output = await sharp(input)\n * .modulate({\n * brightness: 0.5,\n * saturation: 0.5,\n * hue: 90,\n * })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {number} [options.brightness] Brightness multiplier\n * @param {number} [options.saturation] Saturation multiplier\n * @param {number} [options.hue] Degrees for hue rotation\n * @param {number} [options.lightness] Lightness addend\n * @returns {Sharp}\n */\nfunction modulate (options) {\n if (!is.plainObject(options)) {\n throw is.invalidParameterError('options', 'plain object', options);\n }\n if ('brightness' in options) {\n if (is.number(options.brightness) && options.brightness >= 0) {\n this.options.brightness = options.brightness;\n } else {\n throw is.invalidParameterError('brightness', 'number above zero', options.brightness);\n }\n }\n if ('saturation' in options) {\n if (is.number(options.saturation) && options.saturation >= 0) {\n this.options.saturation = options.saturation;\n } else {\n throw is.invalidParameterError('saturation', 'number above zero', options.saturation);\n }\n }\n if ('hue' in options) {\n if (is.integer(options.hue)) {\n this.options.hue = options.hue % 360;\n } else {\n throw is.invalidParameterError('hue', 'number', options.hue);\n }\n }\n if ('lightness' in options) {\n if (is.number(options.lightness)) {\n this.options.lightness = options.lightness;\n } else {\n throw is.invalidParameterError('lightness', 'number', options.lightness);\n }\n }\n return this;\n}\n\n/**\n * Decorate the Sharp prototype with operation-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n autoOrient,\n rotate,\n flip,\n flop,\n affine,\n sharpen,\n erode,\n dilate,\n median,\n blur,\n flatten,\n unflatten,\n gamma,\n negate,\n normalise,\n normalize,\n clahe,\n convolve,\n threshold,\n boolean,\n linear,\n recomb,\n modulate\n });\n};\n", "var __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// node_modules/color/index.js\nvar index_exports = {};\n__export(index_exports, {\n default: () => index_default\n});\nmodule.exports = __toCommonJS(index_exports);\n\n// node_modules/color-name/index.js\nvar color_name_default = {\n aliceblue: [240, 248, 255],\n antiquewhite: [250, 235, 215],\n aqua: [0, 255, 255],\n aquamarine: [127, 255, 212],\n azure: [240, 255, 255],\n beige: [245, 245, 220],\n bisque: [255, 228, 196],\n black: [0, 0, 0],\n blanchedalmond: [255, 235, 205],\n blue: [0, 0, 255],\n blueviolet: [138, 43, 226],\n brown: [165, 42, 42],\n burlywood: [222, 184, 135],\n cadetblue: [95, 158, 160],\n chartreuse: [127, 255, 0],\n chocolate: [210, 105, 30],\n coral: [255, 127, 80],\n cornflowerblue: [100, 149, 237],\n cornsilk: [255, 248, 220],\n crimson: [220, 20, 60],\n cyan: [0, 255, 255],\n darkblue: [0, 0, 139],\n darkcyan: [0, 139, 139],\n darkgoldenrod: [184, 134, 11],\n darkgray: [169, 169, 169],\n darkgreen: [0, 100, 0],\n darkgrey: [169, 169, 169],\n darkkhaki: [189, 183, 107],\n darkmagenta: [139, 0, 139],\n darkolivegreen: [85, 107, 47],\n darkorange: [255, 140, 0],\n darkorchid: [153, 50, 204],\n darkred: [139, 0, 0],\n darksalmon: [233, 150, 122],\n darkseagreen: [143, 188, 143],\n darkslateblue: [72, 61, 139],\n darkslategray: [47, 79, 79],\n darkslategrey: [47, 79, 79],\n darkturquoise: [0, 206, 209],\n darkviolet: [148, 0, 211],\n deeppink: [255, 20, 147],\n deepskyblue: [0, 191, 255],\n dimgray: [105, 105, 105],\n dimgrey: [105, 105, 105],\n dodgerblue: [30, 144, 255],\n firebrick: [178, 34, 34],\n floralwhite: [255, 250, 240],\n forestgreen: [34, 139, 34],\n fuchsia: [255, 0, 255],\n gainsboro: [220, 220, 220],\n ghostwhite: [248, 248, 255],\n gold: [255, 215, 0],\n goldenrod: [218, 165, 32],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenyellow: [173, 255, 47],\n grey: [128, 128, 128],\n honeydew: [240, 255, 240],\n hotpink: [255, 105, 180],\n indianred: [205, 92, 92],\n indigo: [75, 0, 130],\n ivory: [255, 255, 240],\n khaki: [240, 230, 140],\n lavender: [230, 230, 250],\n lavenderblush: [255, 240, 245],\n lawngreen: [124, 252, 0],\n lemonchiffon: [255, 250, 205],\n lightblue: [173, 216, 230],\n lightcoral: [240, 128, 128],\n lightcyan: [224, 255, 255],\n lightgoldenrodyellow: [250, 250, 210],\n lightgray: [211, 211, 211],\n lightgreen: [144, 238, 144],\n lightgrey: [211, 211, 211],\n lightpink: [255, 182, 193],\n lightsalmon: [255, 160, 122],\n lightseagreen: [32, 178, 170],\n lightskyblue: [135, 206, 250],\n lightslategray: [119, 136, 153],\n lightslategrey: [119, 136, 153],\n lightsteelblue: [176, 196, 222],\n lightyellow: [255, 255, 224],\n lime: [0, 255, 0],\n limegreen: [50, 205, 50],\n linen: [250, 240, 230],\n magenta: [255, 0, 255],\n maroon: [128, 0, 0],\n mediumaquamarine: [102, 205, 170],\n mediumblue: [0, 0, 205],\n mediumorchid: [186, 85, 211],\n mediumpurple: [147, 112, 219],\n mediumseagreen: [60, 179, 113],\n mediumslateblue: [123, 104, 238],\n mediumspringgreen: [0, 250, 154],\n mediumturquoise: [72, 209, 204],\n mediumvioletred: [199, 21, 133],\n midnightblue: [25, 25, 112],\n mintcream: [245, 255, 250],\n mistyrose: [255, 228, 225],\n moccasin: [255, 228, 181],\n navajowhite: [255, 222, 173],\n navy: [0, 0, 128],\n oldlace: [253, 245, 230],\n olive: [128, 128, 0],\n olivedrab: [107, 142, 35],\n orange: [255, 165, 0],\n orangered: [255, 69, 0],\n orchid: [218, 112, 214],\n palegoldenrod: [238, 232, 170],\n palegreen: [152, 251, 152],\n paleturquoise: [175, 238, 238],\n palevioletred: [219, 112, 147],\n papayawhip: [255, 239, 213],\n peachpuff: [255, 218, 185],\n peru: [205, 133, 63],\n pink: [255, 192, 203],\n plum: [221, 160, 221],\n powderblue: [176, 224, 230],\n purple: [128, 0, 128],\n rebeccapurple: [102, 51, 153],\n red: [255, 0, 0],\n rosybrown: [188, 143, 143],\n royalblue: [65, 105, 225],\n saddlebrown: [139, 69, 19],\n salmon: [250, 128, 114],\n sandybrown: [244, 164, 96],\n seagreen: [46, 139, 87],\n seashell: [255, 245, 238],\n sienna: [160, 82, 45],\n silver: [192, 192, 192],\n skyblue: [135, 206, 235],\n slateblue: [106, 90, 205],\n slategray: [112, 128, 144],\n slategrey: [112, 128, 144],\n snow: [255, 250, 250],\n springgreen: [0, 255, 127],\n steelblue: [70, 130, 180],\n tan: [210, 180, 140],\n teal: [0, 128, 128],\n thistle: [216, 191, 216],\n tomato: [255, 99, 71],\n turquoise: [64, 224, 208],\n violet: [238, 130, 238],\n wheat: [245, 222, 179],\n white: [255, 255, 255],\n whitesmoke: [245, 245, 245],\n yellow: [255, 255, 0],\n yellowgreen: [154, 205, 50]\n};\n\n// node_modules/color-string/index.js\nvar reverseNames = /* @__PURE__ */ Object.create(null);\nfor (const name in color_name_default) {\n if (Object.hasOwn(color_name_default, name)) {\n reverseNames[color_name_default[name]] = name;\n }\n}\nvar cs = {\n to: {},\n get: {}\n};\ncs.get = function(string) {\n const prefix = string.slice(0, 3).toLowerCase();\n let value;\n let model;\n switch (prefix) {\n case \"hsl\": {\n value = cs.get.hsl(string);\n model = \"hsl\";\n break;\n }\n case \"hwb\": {\n value = cs.get.hwb(string);\n model = \"hwb\";\n break;\n }\n default: {\n value = cs.get.rgb(string);\n model = \"rgb\";\n break;\n }\n }\n if (!value) {\n return null;\n }\n return { model, value };\n};\ncs.get.rgb = function(string) {\n if (!string) {\n return null;\n }\n const abbr = /^#([a-f\\d]{3,4})$/i;\n const hex = /^#([a-f\\d]{6})([a-f\\d]{2})?$/i;\n const rgba = /^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[\\s,|/]\\s*([+-]?[\\d.]+)(%?)\\s*)?\\)$/;\n const per = /^rgba?\\(\\s*([+-]?[\\d.]+)%\\s*,?\\s*([+-]?[\\d.]+)%\\s*,?\\s*([+-]?[\\d.]+)%\\s*(?:[\\s,|/]\\s*([+-]?[\\d.]+)(%?)\\s*)?\\)$/;\n const keyword = /^(\\w+)$/;\n let rgb = [0, 0, 0, 1];\n let match;\n let i;\n let hexAlpha;\n if (match = string.match(hex)) {\n hexAlpha = match[2];\n match = match[1];\n for (i = 0; i < 3; i++) {\n const i2 = i * 2;\n rgb[i] = Number.parseInt(match.slice(i2, i2 + 2), 16);\n }\n if (hexAlpha) {\n rgb[3] = Number.parseInt(hexAlpha, 16) / 255;\n }\n } else if (match = string.match(abbr)) {\n match = match[1];\n hexAlpha = match[3];\n for (i = 0; i < 3; i++) {\n rgb[i] = Number.parseInt(match[i] + match[i], 16);\n }\n if (hexAlpha) {\n rgb[3] = Number.parseInt(hexAlpha + hexAlpha, 16) / 255;\n }\n } else if (match = string.match(rgba)) {\n for (i = 0; i < 3; i++) {\n rgb[i] = Number.parseInt(match[i + 1], 10);\n }\n if (match[4]) {\n rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);\n }\n } else if (match = string.match(per)) {\n for (i = 0; i < 3; i++) {\n rgb[i] = Math.round(Number.parseFloat(match[i + 1]) * 2.55);\n }\n if (match[4]) {\n rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);\n }\n } else if (match = string.match(keyword)) {\n if (match[1] === \"transparent\") {\n return [0, 0, 0, 0];\n }\n if (!Object.hasOwn(color_name_default, match[1])) {\n return null;\n }\n rgb = color_name_default[match[1]];\n rgb[3] = 1;\n return rgb;\n } else {\n return null;\n }\n for (i = 0; i < 3; i++) {\n rgb[i] = clamp(rgb[i], 0, 255);\n }\n rgb[3] = clamp(rgb[3], 0, 1);\n return rgb;\n};\ncs.get.hsl = function(string) {\n if (!string) {\n return null;\n }\n const hsl = /^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d.]+)%\\s*,?\\s*([+-]?[\\d.]+)%\\s*(?:[,|/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/;\n const match = string.match(hsl);\n if (match) {\n const alpha = Number.parseFloat(match[4]);\n const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;\n const s = clamp(Number.parseFloat(match[2]), 0, 100);\n const l = clamp(Number.parseFloat(match[3]), 0, 100);\n const a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);\n return [h, s, l, a];\n }\n return null;\n};\ncs.get.hwb = function(string) {\n if (!string) {\n return null;\n }\n const hwb = /^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*[\\s,]\\s*([+-]?[\\d.]+)%\\s*[\\s,]\\s*([+-]?[\\d.]+)%\\s*(?:[\\s,]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/;\n const match = string.match(hwb);\n if (match) {\n const alpha = Number.parseFloat(match[4]);\n const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;\n const w = clamp(Number.parseFloat(match[2]), 0, 100);\n const b = clamp(Number.parseFloat(match[3]), 0, 100);\n const a = clamp(Number.isNaN(alpha) ? 1 : alpha, 0, 1);\n return [h, w, b, a];\n }\n return null;\n};\ncs.to.hex = function(...rgba) {\n return \"#\" + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : \"\");\n};\ncs.to.rgb = function(...rgba) {\n return rgba.length < 4 || rgba[3] === 1 ? \"rgb(\" + Math.round(rgba[0]) + \", \" + Math.round(rgba[1]) + \", \" + Math.round(rgba[2]) + \")\" : \"rgba(\" + Math.round(rgba[0]) + \", \" + Math.round(rgba[1]) + \", \" + Math.round(rgba[2]) + \", \" + rgba[3] + \")\";\n};\ncs.to.rgb.percent = function(...rgba) {\n const r = Math.round(rgba[0] / 255 * 100);\n const g = Math.round(rgba[1] / 255 * 100);\n const b = Math.round(rgba[2] / 255 * 100);\n return rgba.length < 4 || rgba[3] === 1 ? \"rgb(\" + r + \"%, \" + g + \"%, \" + b + \"%)\" : \"rgba(\" + r + \"%, \" + g + \"%, \" + b + \"%, \" + rgba[3] + \")\";\n};\ncs.to.hsl = function(...hsla) {\n return hsla.length < 4 || hsla[3] === 1 ? \"hsl(\" + hsla[0] + \", \" + hsla[1] + \"%, \" + hsla[2] + \"%)\" : \"hsla(\" + hsla[0] + \", \" + hsla[1] + \"%, \" + hsla[2] + \"%, \" + hsla[3] + \")\";\n};\ncs.to.hwb = function(...hwba) {\n let a = \"\";\n if (hwba.length >= 4 && hwba[3] !== 1) {\n a = \", \" + hwba[3];\n }\n return \"hwb(\" + hwba[0] + \", \" + hwba[1] + \"%, \" + hwba[2] + \"%\" + a + \")\";\n};\ncs.to.keyword = function(...rgb) {\n return reverseNames[rgb.slice(0, 3)];\n};\nfunction clamp(number_, min, max) {\n return Math.min(Math.max(min, number_), max);\n}\nfunction hexDouble(number_) {\n const string_ = Math.round(number_).toString(16).toUpperCase();\n return string_.length < 2 ? \"0\" + string_ : string_;\n}\nvar color_string_default = cs;\n\n// node_modules/color-convert/conversions.js\nvar reverseKeywords = {};\nfor (const key of Object.keys(color_name_default)) {\n reverseKeywords[color_name_default[key]] = key;\n}\nvar convert = {\n rgb: { channels: 3, labels: \"rgb\" },\n hsl: { channels: 3, labels: \"hsl\" },\n hsv: { channels: 3, labels: \"hsv\" },\n hwb: { channels: 3, labels: \"hwb\" },\n cmyk: { channels: 4, labels: \"cmyk\" },\n xyz: { channels: 3, labels: \"xyz\" },\n lab: { channels: 3, labels: \"lab\" },\n oklab: { channels: 3, labels: [\"okl\", \"oka\", \"okb\"] },\n lch: { channels: 3, labels: \"lch\" },\n oklch: { channels: 3, labels: [\"okl\", \"okc\", \"okh\"] },\n hex: { channels: 1, labels: [\"hex\"] },\n keyword: { channels: 1, labels: [\"keyword\"] },\n ansi16: { channels: 1, labels: [\"ansi16\"] },\n ansi256: { channels: 1, labels: [\"ansi256\"] },\n hcg: { channels: 3, labels: [\"h\", \"c\", \"g\"] },\n apple: { channels: 3, labels: [\"r16\", \"g16\", \"b16\"] },\n gray: { channels: 1, labels: [\"gray\"] }\n};\nvar conversions_default = convert;\nvar LAB_FT = (6 / 29) ** 3;\nfunction srgbNonlinearTransform(c) {\n const cc = c > 31308e-7 ? 1.055 * c ** (1 / 2.4) - 0.055 : c * 12.92;\n return Math.min(Math.max(0, cc), 1);\n}\nfunction srgbNonlinearTransformInv(c) {\n return c > 0.04045 ? ((c + 0.055) / 1.055) ** 2.4 : c / 12.92;\n}\nfor (const model of Object.keys(convert)) {\n if (!(\"channels\" in convert[model])) {\n throw new Error(\"missing channels property: \" + model);\n }\n if (!(\"labels\" in convert[model])) {\n throw new Error(\"missing channel labels property: \" + model);\n }\n if (convert[model].labels.length !== convert[model].channels) {\n throw new Error(\"channel and label counts mismatch: \" + model);\n }\n const { channels, labels } = convert[model];\n delete convert[model].channels;\n delete convert[model].labels;\n Object.defineProperty(convert[model], \"channels\", { value: channels });\n Object.defineProperty(convert[model], \"labels\", { value: labels });\n}\nconvert.rgb.hsl = function(rgb) {\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n const min = Math.min(r, g, b);\n const max = Math.max(r, g, b);\n const delta = max - min;\n let h;\n let s;\n switch (max) {\n case min: {\n h = 0;\n break;\n }\n case r: {\n h = (g - b) / delta;\n break;\n }\n case g: {\n h = 2 + (b - r) / delta;\n break;\n }\n case b: {\n h = 4 + (r - g) / delta;\n break;\n }\n }\n h = Math.min(h * 60, 360);\n if (h < 0) {\n h += 360;\n }\n const l = (min + max) / 2;\n if (max === min) {\n s = 0;\n } else if (l <= 0.5) {\n s = delta / (max + min);\n } else {\n s = delta / (2 - max - min);\n }\n return [h, s * 100, l * 100];\n};\nconvert.rgb.hsv = function(rgb) {\n let rdif;\n let gdif;\n let bdif;\n let h;\n let s;\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n const v = Math.max(r, g, b);\n const diff = v - Math.min(r, g, b);\n const diffc = function(c) {\n return (v - c) / 6 / diff + 1 / 2;\n };\n if (diff === 0) {\n h = 0;\n s = 0;\n } else {\n s = diff / v;\n rdif = diffc(r);\n gdif = diffc(g);\n bdif = diffc(b);\n switch (v) {\n case r: {\n h = bdif - gdif;\n break;\n }\n case g: {\n h = 1 / 3 + rdif - bdif;\n break;\n }\n case b: {\n h = 2 / 3 + gdif - rdif;\n break;\n }\n }\n if (h < 0) {\n h += 1;\n } else if (h > 1) {\n h -= 1;\n }\n }\n return [\n h * 360,\n s * 100,\n v * 100\n ];\n};\nconvert.rgb.hwb = function(rgb) {\n const r = rgb[0];\n const g = rgb[1];\n let b = rgb[2];\n const h = convert.rgb.hsl(rgb)[0];\n const w = 1 / 255 * Math.min(r, Math.min(g, b));\n b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));\n return [h, w * 100, b * 100];\n};\nconvert.rgb.oklab = function(rgb) {\n const r = srgbNonlinearTransformInv(rgb[0] / 255);\n const g = srgbNonlinearTransformInv(rgb[1] / 255);\n const b = srgbNonlinearTransformInv(rgb[2] / 255);\n const lp = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);\n const mp = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);\n const sp = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);\n const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;\n const aa = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;\n const bb = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;\n return [l * 100, aa * 100, bb * 100];\n};\nconvert.rgb.cmyk = function(rgb) {\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n const k = Math.min(1 - r, 1 - g, 1 - b);\n const c = (1 - r - k) / (1 - k) || 0;\n const m = (1 - g - k) / (1 - k) || 0;\n const y = (1 - b - k) / (1 - k) || 0;\n return [c * 100, m * 100, y * 100, k * 100];\n};\nfunction comparativeDistance(x, y) {\n return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;\n}\nconvert.rgb.keyword = function(rgb) {\n const reversed = reverseKeywords[rgb];\n if (reversed) {\n return reversed;\n }\n let currentClosestDistance = Number.POSITIVE_INFINITY;\n let currentClosestKeyword;\n for (const keyword of Object.keys(color_name_default)) {\n const value = color_name_default[keyword];\n const distance = comparativeDistance(rgb, value);\n if (distance < currentClosestDistance) {\n currentClosestDistance = distance;\n currentClosestKeyword = keyword;\n }\n }\n return currentClosestKeyword;\n};\nconvert.keyword.rgb = function(keyword) {\n return color_name_default[keyword];\n};\nconvert.rgb.xyz = function(rgb) {\n const r = srgbNonlinearTransformInv(rgb[0] / 255);\n const g = srgbNonlinearTransformInv(rgb[1] / 255);\n const b = srgbNonlinearTransformInv(rgb[2] / 255);\n const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;\n const y = r * 0.2126729 + g * 0.7151522 + b * 0.072175;\n const z = r * 0.0193339 + g * 0.119192 + b * 0.9503041;\n return [x * 100, y * 100, z * 100];\n};\nconvert.rgb.lab = function(rgb) {\n const xyz = convert.rgb.xyz(rgb);\n let x = xyz[0];\n let y = xyz[1];\n let z = xyz[2];\n x /= 95.047;\n y /= 100;\n z /= 108.883;\n x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;\n y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;\n z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;\n const l = 116 * y - 16;\n const a = 500 * (x - y);\n const b = 200 * (y - z);\n return [l, a, b];\n};\nconvert.hsl.rgb = function(hsl) {\n const h = hsl[0] / 360;\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n let t3;\n let value;\n if (s === 0) {\n value = l * 255;\n return [value, value, value];\n }\n const t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const t1 = 2 * l - t2;\n const rgb = [0, 0, 0];\n for (let i = 0; i < 3; i++) {\n t3 = h + 1 / 3 * -(i - 1);\n if (t3 < 0) {\n t3++;\n }\n if (t3 > 1) {\n t3--;\n }\n if (6 * t3 < 1) {\n value = t1 + (t2 - t1) * 6 * t3;\n } else if (2 * t3 < 1) {\n value = t2;\n } else if (3 * t3 < 2) {\n value = t1 + (t2 - t1) * (2 / 3 - t3) * 6;\n } else {\n value = t1;\n }\n rgb[i] = value * 255;\n }\n return rgb;\n};\nconvert.hsl.hsv = function(hsl) {\n const h = hsl[0];\n let s = hsl[1] / 100;\n let l = hsl[2] / 100;\n let smin = s;\n const lmin = Math.max(l, 0.01);\n l *= 2;\n s *= l <= 1 ? l : 2 - l;\n smin *= lmin <= 1 ? lmin : 2 - lmin;\n const v = (l + s) / 2;\n const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);\n return [h, sv * 100, v * 100];\n};\nconvert.hsv.rgb = function(hsv) {\n const h = hsv[0] / 60;\n const s = hsv[1] / 100;\n let v = hsv[2] / 100;\n const hi = Math.floor(h) % 6;\n const f = h - Math.floor(h);\n const p = 255 * v * (1 - s);\n const q = 255 * v * (1 - s * f);\n const t = 255 * v * (1 - s * (1 - f));\n v *= 255;\n switch (hi) {\n case 0: {\n return [v, t, p];\n }\n case 1: {\n return [q, v, p];\n }\n case 2: {\n return [p, v, t];\n }\n case 3: {\n return [p, q, v];\n }\n case 4: {\n return [t, p, v];\n }\n case 5: {\n return [v, p, q];\n }\n }\n};\nconvert.hsv.hsl = function(hsv) {\n const h = hsv[0];\n const s = hsv[1] / 100;\n const v = hsv[2] / 100;\n const vmin = Math.max(v, 0.01);\n let sl;\n let l;\n l = (2 - s) * v;\n const lmin = (2 - s) * vmin;\n sl = s * vmin;\n sl /= lmin <= 1 ? lmin : 2 - lmin;\n sl = sl || 0;\n l /= 2;\n return [h, sl * 100, l * 100];\n};\nconvert.hwb.rgb = function(hwb) {\n const h = hwb[0] / 360;\n let wh = hwb[1] / 100;\n let bl = hwb[2] / 100;\n const ratio = wh + bl;\n let f;\n if (ratio > 1) {\n wh /= ratio;\n bl /= ratio;\n }\n const i = Math.floor(6 * h);\n const v = 1 - bl;\n f = 6 * h - i;\n if ((i & 1) !== 0) {\n f = 1 - f;\n }\n const n = wh + f * (v - wh);\n let r;\n let g;\n let b;\n switch (i) {\n default:\n case 6:\n case 0: {\n r = v;\n g = n;\n b = wh;\n break;\n }\n case 1: {\n r = n;\n g = v;\n b = wh;\n break;\n }\n case 2: {\n r = wh;\n g = v;\n b = n;\n break;\n }\n case 3: {\n r = wh;\n g = n;\n b = v;\n break;\n }\n case 4: {\n r = n;\n g = wh;\n b = v;\n break;\n }\n case 5: {\n r = v;\n g = wh;\n b = n;\n break;\n }\n }\n return [r * 255, g * 255, b * 255];\n};\nconvert.cmyk.rgb = function(cmyk) {\n const c = cmyk[0] / 100;\n const m = cmyk[1] / 100;\n const y = cmyk[2] / 100;\n const k = cmyk[3] / 100;\n const r = 1 - Math.min(1, c * (1 - k) + k);\n const g = 1 - Math.min(1, m * (1 - k) + k);\n const b = 1 - Math.min(1, y * (1 - k) + k);\n return [r * 255, g * 255, b * 255];\n};\nconvert.xyz.rgb = function(xyz) {\n const x = xyz[0] / 100;\n const y = xyz[1] / 100;\n const z = xyz[2] / 100;\n let r;\n let g;\n let b;\n r = x * 3.2404542 + y * -1.5371385 + z * -0.4985314;\n g = x * -0.969266 + y * 1.8760108 + z * 0.041556;\n b = x * 0.0556434 + y * -0.2040259 + z * 1.0572252;\n r = srgbNonlinearTransform(r);\n g = srgbNonlinearTransform(g);\n b = srgbNonlinearTransform(b);\n return [r * 255, g * 255, b * 255];\n};\nconvert.xyz.lab = function(xyz) {\n let x = xyz[0];\n let y = xyz[1];\n let z = xyz[2];\n x /= 95.047;\n y /= 100;\n z /= 108.883;\n x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;\n y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;\n z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;\n const l = 116 * y - 16;\n const a = 500 * (x - y);\n const b = 200 * (y - z);\n return [l, a, b];\n};\nconvert.xyz.oklab = function(xyz) {\n const x = xyz[0] / 100;\n const y = xyz[1] / 100;\n const z = xyz[2] / 100;\n const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z);\n const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z);\n const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z);\n const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;\n const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;\n const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;\n return [l * 100, a * 100, b * 100];\n};\nconvert.oklab.oklch = function(oklab) {\n return convert.lab.lch(oklab);\n};\nconvert.oklab.xyz = function(oklab) {\n const ll = oklab[0] / 100;\n const a = oklab[1] / 100;\n const b = oklab[2] / 100;\n const l = (0.999999998 * ll + 0.396337792 * a + 0.215803758 * b) ** 3;\n const m = (1.000000008 * ll - 0.105561342 * a - 0.063854175 * b) ** 3;\n const s = (1.000000055 * ll - 0.089484182 * a - 1.291485538 * b) ** 3;\n const x = 1.227013851 * l - 0.55779998 * m + 0.281256149 * s;\n const y = -0.040580178 * l + 1.11225687 * m - 0.071676679 * s;\n const z = -0.076381285 * l - 0.421481978 * m + 1.58616322 * s;\n return [x * 100, y * 100, z * 100];\n};\nconvert.oklab.rgb = function(oklab) {\n const ll = oklab[0] / 100;\n const aa = oklab[1] / 100;\n const bb = oklab[2] / 100;\n const l = (ll + 0.3963377774 * aa + 0.2158037573 * bb) ** 3;\n const m = (ll - 0.1055613458 * aa - 0.0638541728 * bb) ** 3;\n const s = (ll - 0.0894841775 * aa - 1.291485548 * bb) ** 3;\n const r = srgbNonlinearTransform(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s);\n const g = srgbNonlinearTransform(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s);\n const b = srgbNonlinearTransform(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s);\n return [r * 255, g * 255, b * 255];\n};\nconvert.oklch.oklab = function(oklch) {\n return convert.lch.lab(oklch);\n};\nconvert.lab.xyz = function(lab) {\n const l = lab[0];\n const a = lab[1];\n const b = lab[2];\n let x;\n let y;\n let z;\n y = (l + 16) / 116;\n x = a / 500 + y;\n z = y - b / 200;\n const y2 = y ** 3;\n const x2 = x ** 3;\n const z2 = z ** 3;\n y = y2 > LAB_FT ? y2 : (y - 16 / 116) / 7.787;\n x = x2 > LAB_FT ? x2 : (x - 16 / 116) / 7.787;\n z = z2 > LAB_FT ? z2 : (z - 16 / 116) / 7.787;\n x *= 95.047;\n y *= 100;\n z *= 108.883;\n return [x, y, z];\n};\nconvert.lab.lch = function(lab) {\n const l = lab[0];\n const a = lab[1];\n const b = lab[2];\n let h;\n const hr = Math.atan2(b, a);\n h = hr * 360 / 2 / Math.PI;\n if (h < 0) {\n h += 360;\n }\n const c = Math.sqrt(a * a + b * b);\n return [l, c, h];\n};\nconvert.lch.lab = function(lch) {\n const l = lch[0];\n const c = lch[1];\n const h = lch[2];\n const hr = h / 360 * 2 * Math.PI;\n const a = c * Math.cos(hr);\n const b = c * Math.sin(hr);\n return [l, a, b];\n};\nconvert.rgb.ansi16 = function(args, saturation = null) {\n const [r, g, b] = args;\n let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;\n value = Math.round(value / 50);\n if (value === 0) {\n return 30;\n }\n let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));\n if (value === 2) {\n ansi += 60;\n }\n return ansi;\n};\nconvert.hsv.ansi16 = function(args) {\n return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);\n};\nconvert.rgb.ansi256 = function(args) {\n const r = args[0];\n const g = args[1];\n const b = args[2];\n if (r >> 4 === g >> 4 && g >> 4 === b >> 4) {\n if (r < 8) {\n return 16;\n }\n if (r > 248) {\n return 231;\n }\n return Math.round((r - 8) / 247 * 24) + 232;\n }\n const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);\n return ansi;\n};\nconvert.ansi16.rgb = function(args) {\n args = args[0];\n let color = args % 10;\n if (color === 0 || color === 7) {\n if (args > 50) {\n color += 3.5;\n }\n color = color / 10.5 * 255;\n return [color, color, color];\n }\n const mult = (Math.trunc(args > 50) + 1) * 0.5;\n const r = (color & 1) * mult * 255;\n const g = (color >> 1 & 1) * mult * 255;\n const b = (color >> 2 & 1) * mult * 255;\n return [r, g, b];\n};\nconvert.ansi256.rgb = function(args) {\n args = args[0];\n if (args >= 232) {\n const c = (args - 232) * 10 + 8;\n return [c, c, c];\n }\n args -= 16;\n let rem;\n const r = Math.floor(args / 36) / 5 * 255;\n const g = Math.floor((rem = args % 36) / 6) / 5 * 255;\n const b = rem % 6 / 5 * 255;\n return [r, g, b];\n};\nconvert.rgb.hex = function(args) {\n const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);\n const string = integer.toString(16).toUpperCase();\n return \"000000\".slice(string.length) + string;\n};\nconvert.hex.rgb = function(args) {\n const match = args.toString(16).match(/[a-f\\d]{6}|[a-f\\d]{3}/i);\n if (!match) {\n return [0, 0, 0];\n }\n let colorString = match[0];\n if (match[0].length === 3) {\n colorString = [...colorString].map((char) => char + char).join(\"\");\n }\n const integer = Number.parseInt(colorString, 16);\n const r = integer >> 16 & 255;\n const g = integer >> 8 & 255;\n const b = integer & 255;\n return [r, g, b];\n};\nconvert.rgb.hcg = function(rgb) {\n const r = rgb[0] / 255;\n const g = rgb[1] / 255;\n const b = rgb[2] / 255;\n const max = Math.max(Math.max(r, g), b);\n const min = Math.min(Math.min(r, g), b);\n const chroma = max - min;\n let hue;\n const grayscale = chroma < 1 ? min / (1 - chroma) : 0;\n if (chroma <= 0) {\n hue = 0;\n } else if (max === r) {\n hue = (g - b) / chroma % 6;\n } else if (max === g) {\n hue = 2 + (b - r) / chroma;\n } else {\n hue = 4 + (r - g) / chroma;\n }\n hue /= 6;\n hue %= 1;\n return [hue * 360, chroma * 100, grayscale * 100];\n};\nconvert.hsl.hcg = function(hsl) {\n const s = hsl[1] / 100;\n const l = hsl[2] / 100;\n const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);\n let f = 0;\n if (c < 1) {\n f = (l - 0.5 * c) / (1 - c);\n }\n return [hsl[0], c * 100, f * 100];\n};\nconvert.hsv.hcg = function(hsv) {\n const s = hsv[1] / 100;\n const v = hsv[2] / 100;\n const c = s * v;\n let f = 0;\n if (c < 1) {\n f = (v - c) / (1 - c);\n }\n return [hsv[0], c * 100, f * 100];\n};\nconvert.hcg.rgb = function(hcg) {\n const h = hcg[0] / 360;\n const c = hcg[1] / 100;\n const g = hcg[2] / 100;\n if (c === 0) {\n return [g * 255, g * 255, g * 255];\n }\n const pure = [0, 0, 0];\n const hi = h % 1 * 6;\n const v = hi % 1;\n const w = 1 - v;\n let mg = 0;\n switch (Math.floor(hi)) {\n case 0: {\n pure[0] = 1;\n pure[1] = v;\n pure[2] = 0;\n break;\n }\n case 1: {\n pure[0] = w;\n pure[1] = 1;\n pure[2] = 0;\n break;\n }\n case 2: {\n pure[0] = 0;\n pure[1] = 1;\n pure[2] = v;\n break;\n }\n case 3: {\n pure[0] = 0;\n pure[1] = w;\n pure[2] = 1;\n break;\n }\n case 4: {\n pure[0] = v;\n pure[1] = 0;\n pure[2] = 1;\n break;\n }\n default: {\n pure[0] = 1;\n pure[1] = 0;\n pure[2] = w;\n }\n }\n mg = (1 - c) * g;\n return [\n (c * pure[0] + mg) * 255,\n (c * pure[1] + mg) * 255,\n (c * pure[2] + mg) * 255\n ];\n};\nconvert.hcg.hsv = function(hcg) {\n const c = hcg[1] / 100;\n const g = hcg[2] / 100;\n const v = c + g * (1 - c);\n let f = 0;\n if (v > 0) {\n f = c / v;\n }\n return [hcg[0], f * 100, v * 100];\n};\nconvert.hcg.hsl = function(hcg) {\n const c = hcg[1] / 100;\n const g = hcg[2] / 100;\n const l = g * (1 - c) + 0.5 * c;\n let s = 0;\n if (l > 0 && l < 0.5) {\n s = c / (2 * l);\n } else if (l >= 0.5 && l < 1) {\n s = c / (2 * (1 - l));\n }\n return [hcg[0], s * 100, l * 100];\n};\nconvert.hcg.hwb = function(hcg) {\n const c = hcg[1] / 100;\n const g = hcg[2] / 100;\n const v = c + g * (1 - c);\n return [hcg[0], (v - c) * 100, (1 - v) * 100];\n};\nconvert.hwb.hcg = function(hwb) {\n const w = hwb[1] / 100;\n const b = hwb[2] / 100;\n const v = 1 - b;\n const c = v - w;\n let g = 0;\n if (c < 1) {\n g = (v - c) / (1 - c);\n }\n return [hwb[0], c * 100, g * 100];\n};\nconvert.apple.rgb = function(apple) {\n return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];\n};\nconvert.rgb.apple = function(rgb) {\n return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];\n};\nconvert.gray.rgb = function(args) {\n return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];\n};\nconvert.gray.hsl = function(args) {\n return [0, 0, args[0]];\n};\nconvert.gray.hsv = convert.gray.hsl;\nconvert.gray.hwb = function(gray) {\n return [0, 100, gray[0]];\n};\nconvert.gray.cmyk = function(gray) {\n return [0, 0, 0, gray[0]];\n};\nconvert.gray.lab = function(gray) {\n return [gray[0], 0, 0];\n};\nconvert.gray.hex = function(gray) {\n const value = Math.round(gray[0] / 100 * 255) & 255;\n const integer = (value << 16) + (value << 8) + value;\n const string = integer.toString(16).toUpperCase();\n return \"000000\".slice(string.length) + string;\n};\nconvert.rgb.gray = function(rgb) {\n const value = (rgb[0] + rgb[1] + rgb[2]) / 3;\n return [value / 255 * 100];\n};\n\n// node_modules/color-convert/route.js\nfunction buildGraph() {\n const graph = {};\n const models2 = Object.keys(conversions_default);\n for (let { length } = models2, i = 0; i < length; i++) {\n graph[models2[i]] = {\n // http://jsperf.com/1-vs-infinity\n // micro-opt, but this is simple.\n distance: -1,\n parent: null\n };\n }\n return graph;\n}\nfunction deriveBFS(fromModel) {\n const graph = buildGraph();\n const queue = [fromModel];\n graph[fromModel].distance = 0;\n while (queue.length > 0) {\n const current = queue.pop();\n const adjacents = Object.keys(conversions_default[current]);\n for (let { length } = adjacents, i = 0; i < length; i++) {\n const adjacent = adjacents[i];\n const node = graph[adjacent];\n if (node.distance === -1) {\n node.distance = graph[current].distance + 1;\n node.parent = current;\n queue.unshift(adjacent);\n }\n }\n }\n return graph;\n}\nfunction link(from, to) {\n return function(args) {\n return to(from(args));\n };\n}\nfunction wrapConversion(toModel, graph) {\n const path = [graph[toModel].parent, toModel];\n let fn = conversions_default[graph[toModel].parent][toModel];\n let cur = graph[toModel].parent;\n while (graph[cur].parent) {\n path.unshift(graph[cur].parent);\n fn = link(conversions_default[graph[cur].parent][cur], fn);\n cur = graph[cur].parent;\n }\n fn.conversion = path;\n return fn;\n}\nfunction route(fromModel) {\n const graph = deriveBFS(fromModel);\n const conversion = {};\n const models2 = Object.keys(graph);\n for (let { length } = models2, i = 0; i < length; i++) {\n const toModel = models2[i];\n const node = graph[toModel];\n if (node.parent === null) {\n continue;\n }\n conversion[toModel] = wrapConversion(toModel, graph);\n }\n return conversion;\n}\nvar route_default = route;\n\n// node_modules/color-convert/index.js\nvar convert2 = {};\nvar models = Object.keys(conversions_default);\nfunction wrapRaw(fn) {\n const wrappedFn = function(...args) {\n const arg0 = args[0];\n if (arg0 === void 0 || arg0 === null) {\n return arg0;\n }\n if (arg0.length > 1) {\n args = arg0;\n }\n return fn(args);\n };\n if (\"conversion\" in fn) {\n wrappedFn.conversion = fn.conversion;\n }\n return wrappedFn;\n}\nfunction wrapRounded(fn) {\n const wrappedFn = function(...args) {\n const arg0 = args[0];\n if (arg0 === void 0 || arg0 === null) {\n return arg0;\n }\n if (arg0.length > 1) {\n args = arg0;\n }\n const result = fn(args);\n if (typeof result === \"object\") {\n for (let { length } = result, i = 0; i < length; i++) {\n result[i] = Math.round(result[i]);\n }\n }\n return result;\n };\n if (\"conversion\" in fn) {\n wrappedFn.conversion = fn.conversion;\n }\n return wrappedFn;\n}\nfor (const fromModel of models) {\n convert2[fromModel] = {};\n Object.defineProperty(convert2[fromModel], \"channels\", { value: conversions_default[fromModel].channels });\n Object.defineProperty(convert2[fromModel], \"labels\", { value: conversions_default[fromModel].labels });\n const routes = route_default(fromModel);\n const routeModels = Object.keys(routes);\n for (const toModel of routeModels) {\n const fn = routes[toModel];\n convert2[fromModel][toModel] = wrapRounded(fn);\n convert2[fromModel][toModel].raw = wrapRaw(fn);\n }\n}\nvar color_convert_default = convert2;\n\n// node_modules/color/index.js\nvar skippedModels = [\n // To be honest, I don't really feel like keyword belongs in color convert, but eh.\n \"keyword\",\n // Gray conflicts with some method names, and has its own method defined.\n \"gray\",\n // Shouldn't really be in color-convert either...\n \"hex\"\n];\nvar hashedModelKeys = {};\nfor (const model of Object.keys(color_convert_default)) {\n hashedModelKeys[[...color_convert_default[model].labels].sort().join(\"\")] = model;\n}\nvar limiters = {};\nfunction Color(object, model) {\n if (!(this instanceof Color)) {\n return new Color(object, model);\n }\n if (model && model in skippedModels) {\n model = null;\n }\n if (model && !(model in color_convert_default)) {\n throw new Error(\"Unknown model: \" + model);\n }\n let i;\n let channels;\n if (object == null) {\n this.model = \"rgb\";\n this.color = [0, 0, 0];\n this.valpha = 1;\n } else if (object instanceof Color) {\n this.model = object.model;\n this.color = [...object.color];\n this.valpha = object.valpha;\n } else if (typeof object === \"string\") {\n const result = color_string_default.get(object);\n if (result === null) {\n throw new Error(\"Unable to parse color from string: \" + object);\n }\n this.model = result.model;\n channels = color_convert_default[this.model].channels;\n this.color = result.value.slice(0, channels);\n this.valpha = typeof result.value[channels] === \"number\" ? result.value[channels] : 1;\n } else if (object.length > 0) {\n this.model = model || \"rgb\";\n channels = color_convert_default[this.model].channels;\n const newArray = Array.prototype.slice.call(object, 0, channels);\n this.color = zeroArray(newArray, channels);\n this.valpha = typeof object[channels] === \"number\" ? object[channels] : 1;\n } else if (typeof object === \"number\") {\n this.model = \"rgb\";\n this.color = [\n object >> 16 & 255,\n object >> 8 & 255,\n object & 255\n ];\n this.valpha = 1;\n } else {\n this.valpha = 1;\n const keys = Object.keys(object);\n if (\"alpha\" in object) {\n keys.splice(keys.indexOf(\"alpha\"), 1);\n this.valpha = typeof object.alpha === \"number\" ? object.alpha : 0;\n }\n const hashedKeys = keys.sort().join(\"\");\n if (!(hashedKeys in hashedModelKeys)) {\n throw new Error(\"Unable to parse color from object: \" + JSON.stringify(object));\n }\n this.model = hashedModelKeys[hashedKeys];\n const { labels } = color_convert_default[this.model];\n const color = [];\n for (i = 0; i < labels.length; i++) {\n color.push(object[labels[i]]);\n }\n this.color = zeroArray(color);\n }\n if (limiters[this.model]) {\n channels = color_convert_default[this.model].channels;\n for (i = 0; i < channels; i++) {\n const limit = limiters[this.model][i];\n if (limit) {\n this.color[i] = limit(this.color[i]);\n }\n }\n }\n this.valpha = Math.max(0, Math.min(1, this.valpha));\n if (Object.freeze) {\n Object.freeze(this);\n }\n}\nColor.prototype = {\n toString() {\n return this.string();\n },\n toJSON() {\n return this[this.model]();\n },\n string(places) {\n let self = this.model in color_string_default.to ? this : this.rgb();\n self = self.round(typeof places === \"number\" ? places : 1);\n const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];\n return color_string_default.to[self.model](...arguments_);\n },\n percentString(places) {\n const self = this.rgb().round(typeof places === \"number\" ? places : 1);\n const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];\n return color_string_default.to.rgb.percent(...arguments_);\n },\n array() {\n return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];\n },\n object() {\n const result = {};\n const { channels } = color_convert_default[this.model];\n const { labels } = color_convert_default[this.model];\n for (let i = 0; i < channels; i++) {\n result[labels[i]] = this.color[i];\n }\n if (this.valpha !== 1) {\n result.alpha = this.valpha;\n }\n return result;\n },\n unitArray() {\n const rgb = this.rgb().color;\n rgb[0] /= 255;\n rgb[1] /= 255;\n rgb[2] /= 255;\n if (this.valpha !== 1) {\n rgb.push(this.valpha);\n }\n return rgb;\n },\n unitObject() {\n const rgb = this.rgb().object();\n rgb.r /= 255;\n rgb.g /= 255;\n rgb.b /= 255;\n if (this.valpha !== 1) {\n rgb.alpha = this.valpha;\n }\n return rgb;\n },\n round(places) {\n places = Math.max(places || 0, 0);\n return new Color([...this.color.map(roundToPlace(places)), this.valpha], this.model);\n },\n alpha(value) {\n if (value !== void 0) {\n return new Color([...this.color, Math.max(0, Math.min(1, value))], this.model);\n }\n return this.valpha;\n },\n // Rgb\n red: getset(\"rgb\", 0, maxfn(255)),\n green: getset(\"rgb\", 1, maxfn(255)),\n blue: getset(\"rgb\", 2, maxfn(255)),\n hue: getset([\"hsl\", \"hsv\", \"hsl\", \"hwb\", \"hcg\"], 0, (value) => (value % 360 + 360) % 360),\n saturationl: getset(\"hsl\", 1, maxfn(100)),\n lightness: getset(\"hsl\", 2, maxfn(100)),\n saturationv: getset(\"hsv\", 1, maxfn(100)),\n value: getset(\"hsv\", 2, maxfn(100)),\n chroma: getset(\"hcg\", 1, maxfn(100)),\n gray: getset(\"hcg\", 2, maxfn(100)),\n white: getset(\"hwb\", 1, maxfn(100)),\n wblack: getset(\"hwb\", 2, maxfn(100)),\n cyan: getset(\"cmyk\", 0, maxfn(100)),\n magenta: getset(\"cmyk\", 1, maxfn(100)),\n yellow: getset(\"cmyk\", 2, maxfn(100)),\n black: getset(\"cmyk\", 3, maxfn(100)),\n x: getset(\"xyz\", 0, maxfn(95.047)),\n y: getset(\"xyz\", 1, maxfn(100)),\n z: getset(\"xyz\", 2, maxfn(108.833)),\n l: getset(\"lab\", 0, maxfn(100)),\n a: getset(\"lab\", 1),\n b: getset(\"lab\", 2),\n keyword(value) {\n if (value !== void 0) {\n return new Color(value);\n }\n return color_convert_default[this.model].keyword(this.color);\n },\n hex(value) {\n if (value !== void 0) {\n return new Color(value);\n }\n return color_string_default.to.hex(...this.rgb().round().color);\n },\n hexa(value) {\n if (value !== void 0) {\n return new Color(value);\n }\n const rgbArray = this.rgb().round().color;\n let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();\n if (alphaHex.length === 1) {\n alphaHex = \"0\" + alphaHex;\n }\n return color_string_default.to.hex(...rgbArray) + alphaHex;\n },\n rgbNumber() {\n const rgb = this.rgb().color;\n return (rgb[0] & 255) << 16 | (rgb[1] & 255) << 8 | rgb[2] & 255;\n },\n luminosity() {\n const rgb = this.rgb().color;\n const lum = [];\n for (const [i, element] of rgb.entries()) {\n const chan = element / 255;\n lum[i] = chan <= 0.04045 ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;\n }\n return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];\n },\n contrast(color2) {\n const lum1 = this.luminosity();\n const lum2 = color2.luminosity();\n if (lum1 > lum2) {\n return (lum1 + 0.05) / (lum2 + 0.05);\n }\n return (lum2 + 0.05) / (lum1 + 0.05);\n },\n level(color2) {\n const contrastRatio = this.contrast(color2);\n if (contrastRatio >= 7) {\n return \"AAA\";\n }\n return contrastRatio >= 4.5 ? \"AA\" : \"\";\n },\n isDark() {\n const rgb = this.rgb().color;\n const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 1e4;\n return yiq < 128;\n },\n isLight() {\n return !this.isDark();\n },\n negate() {\n const rgb = this.rgb();\n for (let i = 0; i < 3; i++) {\n rgb.color[i] = 255 - rgb.color[i];\n }\n return rgb;\n },\n lighten(ratio) {\n const hsl = this.hsl();\n hsl.color[2] += hsl.color[2] * ratio;\n return hsl;\n },\n darken(ratio) {\n const hsl = this.hsl();\n hsl.color[2] -= hsl.color[2] * ratio;\n return hsl;\n },\n saturate(ratio) {\n const hsl = this.hsl();\n hsl.color[1] += hsl.color[1] * ratio;\n return hsl;\n },\n desaturate(ratio) {\n const hsl = this.hsl();\n hsl.color[1] -= hsl.color[1] * ratio;\n return hsl;\n },\n whiten(ratio) {\n const hwb = this.hwb();\n hwb.color[1] += hwb.color[1] * ratio;\n return hwb;\n },\n blacken(ratio) {\n const hwb = this.hwb();\n hwb.color[2] += hwb.color[2] * ratio;\n return hwb;\n },\n grayscale() {\n const rgb = this.rgb().color;\n const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;\n return Color.rgb(value, value, value);\n },\n fade(ratio) {\n return this.alpha(this.valpha - this.valpha * ratio);\n },\n opaquer(ratio) {\n return this.alpha(this.valpha + this.valpha * ratio);\n },\n rotate(degrees) {\n const hsl = this.hsl();\n let hue = hsl.color[0];\n hue = (hue + degrees) % 360;\n hue = hue < 0 ? 360 + hue : hue;\n hsl.color[0] = hue;\n return hsl;\n },\n mix(mixinColor, weight) {\n if (!mixinColor || !mixinColor.rgb) {\n throw new Error('Argument to \"mix\" was not a Color instance, but rather an instance of ' + typeof mixinColor);\n }\n const color1 = mixinColor.rgb();\n const color2 = this.rgb();\n const p = weight === void 0 ? 0.5 : weight;\n const w = 2 * p - 1;\n const a = color1.alpha() - color2.alpha();\n const w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2;\n const w2 = 1 - w1;\n return Color.rgb(\n w1 * color1.red() + w2 * color2.red(),\n w1 * color1.green() + w2 * color2.green(),\n w1 * color1.blue() + w2 * color2.blue(),\n color1.alpha() * p + color2.alpha() * (1 - p)\n );\n }\n};\nfor (const model of Object.keys(color_convert_default)) {\n if (skippedModels.includes(model)) {\n continue;\n }\n const { channels } = color_convert_default[model];\n Color.prototype[model] = function(...arguments_) {\n if (this.model === model) {\n return new Color(this);\n }\n if (arguments_.length > 0) {\n return new Color(arguments_, model);\n }\n return new Color([...assertArray(color_convert_default[this.model][model].raw(this.color)), this.valpha], model);\n };\n Color[model] = function(...arguments_) {\n let color = arguments_[0];\n if (typeof color === \"number\") {\n color = zeroArray(arguments_, channels);\n }\n return new Color(color, model);\n };\n}\nfunction roundTo(number, places) {\n return Number(number.toFixed(places));\n}\nfunction roundToPlace(places) {\n return function(number) {\n return roundTo(number, places);\n };\n}\nfunction getset(model, channel, modifier) {\n model = Array.isArray(model) ? model : [model];\n for (const m of model) {\n (limiters[m] ||= [])[channel] = modifier;\n }\n model = model[0];\n return function(value) {\n let result;\n if (value !== void 0) {\n if (modifier) {\n value = modifier(value);\n }\n result = this[model]();\n result.color[channel] = value;\n return result;\n }\n result = this[model]().color[channel];\n if (modifier) {\n result = modifier(result);\n }\n return result;\n };\n}\nfunction maxfn(max) {\n return function(v) {\n return Math.max(0, Math.min(max, v));\n };\n}\nfunction assertArray(value) {\n return Array.isArray(value) ? value : [value];\n}\nfunction zeroArray(array, length) {\n for (let i = 0; i < length; i++) {\n if (typeof array[i] !== \"number\") {\n array[i] = 0;\n }\n }\n return array;\n}\nvar index_default = Color;\n", "module.exports = require(\"./color.cjs\").default;\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst color = require('@img/colour');\nconst is = require('./is');\n\n/**\n * Colourspaces.\n * @private\n */\nconst colourspace = {\n multiband: 'multiband',\n 'b-w': 'b-w',\n bw: 'b-w',\n cmyk: 'cmyk',\n srgb: 'srgb'\n};\n\n/**\n * Tint the image using the provided colour.\n * An alpha channel may be present and will be unchanged by the operation.\n *\n * @example\n * const output = await sharp(input)\n * .tint({ r: 255, g: 240, b: 16 })\n * .toBuffer();\n *\n * @param {string|Object} tint - Parsed by the [color](https://www.npmjs.org/package/color) module.\n * @returns {Sharp}\n * @throws {Error} Invalid parameter\n */\nfunction tint (tint) {\n this._setBackgroundColourOption('tint', tint);\n return this;\n}\n\n/**\n * Convert to 8-bit greyscale; 256 shades of grey.\n * This is a linear operation. If the input image is in a non-linear colour space such as sRGB, use `gamma()` with `greyscale()` for the best results.\n * By default the output image will be web-friendly sRGB and contain three (identical) colour channels.\n * This may be overridden by other sharp operations such as `toColourspace('b-w')`,\n * which will produce an output image containing one colour channel.\n * An alpha channel may be present, and will be unchanged by the operation.\n *\n * @example\n * const output = await sharp(input).greyscale().toBuffer();\n *\n * @param {Boolean} [greyscale=true]\n * @returns {Sharp}\n */\nfunction greyscale (greyscale) {\n this.options.greyscale = is.bool(greyscale) ? greyscale : true;\n return this;\n}\n\n/**\n * Alternative spelling of `greyscale`.\n * @param {Boolean} [grayscale=true]\n * @returns {Sharp}\n */\nfunction grayscale (grayscale) {\n return this.greyscale(grayscale);\n}\n\n/**\n * Set the pipeline colourspace.\n *\n * The input image will be converted to the provided colourspace at the start of the pipeline.\n * All operations will use this colourspace before converting to the output colourspace,\n * as defined by {@link #tocolourspace toColourspace}.\n *\n * @since 0.29.0\n *\n * @example\n * // Run pipeline in 16 bits per channel RGB while converting final result to 8 bits per channel sRGB.\n * await sharp(input)\n * .pipelineColourspace('rgb16')\n * .toColourspace('srgb')\n * .toFile('16bpc-pipeline-to-8bpc-output.png')\n *\n * @param {string} [colourspace] - pipeline colourspace e.g. `rgb16`, `scrgb`, `lab`, `grey16` [...](https://www.libvips.org/API/current/enum.Interpretation.html)\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction pipelineColourspace (colourspace) {\n if (!is.string(colourspace)) {\n throw is.invalidParameterError('colourspace', 'string', colourspace);\n }\n this.options.colourspacePipeline = colourspace;\n return this;\n}\n\n/**\n * Alternative spelling of `pipelineColourspace`.\n * @param {string} [colorspace] - pipeline colorspace.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction pipelineColorspace (colorspace) {\n return this.pipelineColourspace(colorspace);\n}\n\n/**\n * Set the output colourspace.\n * By default output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.\n *\n * @example\n * // Output 16 bits per pixel RGB\n * await sharp(input)\n * .toColourspace('rgb16')\n * .toFile('16-bpp.png')\n *\n * @param {string} [colourspace] - output colourspace e.g. `srgb`, `rgb`, `cmyk`, `lab`, `b-w` [...](https://www.libvips.org/API/current/enum.Interpretation.html)\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction toColourspace (colourspace) {\n if (!is.string(colourspace)) {\n throw is.invalidParameterError('colourspace', 'string', colourspace);\n }\n this.options.colourspace = colourspace;\n return this;\n}\n\n/**\n * Alternative spelling of `toColourspace`.\n * @param {string} [colorspace] - output colorspace.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction toColorspace (colorspace) {\n return this.toColourspace(colorspace);\n}\n\n/**\n * Create a RGBA colour array from a given value.\n * @private\n * @param {string|Object} value\n * @throws {Error} Invalid value\n */\nfunction _getBackgroundColourOption (value) {\n if (\n is.object(value) ||\n (is.string(value) && value.length >= 3 && value.length <= 200)\n ) {\n const colour = color(value);\n return [\n colour.red(),\n colour.green(),\n colour.blue(),\n Math.round(colour.alpha() * 255)\n ];\n } else {\n throw is.invalidParameterError('background', 'object or string', value);\n }\n}\n\n/**\n * Update a colour attribute of the this.options Object.\n * @private\n * @param {string} key\n * @param {string|Object} value\n * @throws {Error} Invalid value\n */\nfunction _setBackgroundColourOption (key, value) {\n if (is.defined(value)) {\n this.options[key] = _getBackgroundColourOption(value);\n }\n}\n\n/**\n * Decorate the Sharp prototype with colour-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n // Public\n tint,\n greyscale,\n grayscale,\n pipelineColourspace,\n pipelineColorspace,\n toColourspace,\n toColorspace,\n // Private\n _getBackgroundColourOption,\n _setBackgroundColourOption\n });\n // Class attributes\n Sharp.colourspace = colourspace;\n Sharp.colorspace = colourspace;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst is = require('./is');\n\n/**\n * Boolean operations for bandbool.\n * @private\n */\nconst bool = {\n and: 'and',\n or: 'or',\n eor: 'eor'\n};\n\n/**\n * Remove alpha channels, if any. This is a no-op if the image does not have an alpha channel.\n *\n * See also {@link /api-operation/#flatten flatten}.\n *\n * @example\n * sharp('rgba.png')\n * .removeAlpha()\n * .toFile('rgb.png', function(err, info) {\n * // rgb.png is a 3 channel image without an alpha channel\n * });\n *\n * @returns {Sharp}\n */\nfunction removeAlpha () {\n this.options.removeAlpha = true;\n return this;\n}\n\n/**\n * Ensure the output image has an alpha transparency channel.\n * If missing, the added alpha channel will have the specified\n * transparency level, defaulting to fully-opaque (1).\n * This is a no-op if the image already has an alpha channel.\n *\n * @since 0.21.2\n *\n * @example\n * // rgba.png will be a 4 channel image with a fully-opaque alpha channel\n * await sharp('rgb.jpg')\n * .ensureAlpha()\n * .toFile('rgba.png')\n *\n * @example\n * // rgba is a 4 channel image with a fully-transparent alpha channel\n * const rgba = await sharp(rgb)\n * .ensureAlpha(0)\n * .toBuffer();\n *\n * @param {number} [alpha=1] - alpha transparency level (0=fully-transparent, 1=fully-opaque)\n * @returns {Sharp}\n * @throws {Error} Invalid alpha transparency level\n */\nfunction ensureAlpha (alpha) {\n if (is.defined(alpha)) {\n if (is.number(alpha) && is.inRange(alpha, 0, 1)) {\n this.options.ensureAlpha = alpha;\n } else {\n throw is.invalidParameterError('alpha', 'number between 0 and 1', alpha);\n }\n } else {\n this.options.ensureAlpha = 1;\n }\n return this;\n}\n\n/**\n * Extract a single channel from a multi-channel image.\n *\n * The output colourspace will be either `b-w` (8-bit) or `grey16` (16-bit).\n *\n * @example\n * // green.jpg is a greyscale image containing the green channel of the input\n * await sharp(input)\n * .extractChannel('green')\n * .toFile('green.jpg');\n *\n * @example\n * // red1 is the red value of the first pixel, red2 the second pixel etc.\n * const [red1, red2, ...] = await sharp(input)\n * .extractChannel(0)\n * .raw()\n * .toBuffer();\n *\n * @param {number|string} channel - zero-indexed channel/band number to extract, or `red`, `green`, `blue` or `alpha`.\n * @returns {Sharp}\n * @throws {Error} Invalid channel\n */\nfunction extractChannel (channel) {\n const channelMap = { red: 0, green: 1, blue: 2, alpha: 3 };\n if (Object.keys(channelMap).includes(channel)) {\n channel = channelMap[channel];\n }\n if (is.integer(channel) && is.inRange(channel, 0, 4)) {\n this.options.extractChannel = channel;\n } else {\n throw is.invalidParameterError('channel', 'integer or one of: red, green, blue, alpha', channel);\n }\n return this;\n}\n\n/**\n * Join one or more channels to the image.\n * The meaning of the added channels depends on the output colourspace, set with `toColourspace()`.\n * By default the output image will be web-friendly sRGB, with additional channels interpreted as alpha channels.\n * Channel ordering follows vips convention:\n * - sRGB: 0: Red, 1: Green, 2: Blue, 3: Alpha.\n * - CMYK: 0: Magenta, 1: Cyan, 2: Yellow, 3: Black, 4: Alpha.\n *\n * Buffers may be any of the image formats supported by sharp.\n * For raw pixel input, the `options` object should contain a `raw` attribute, which follows the format of the attribute of the same name in the `sharp()` constructor.\n *\n * @param {Array<string|Buffer>|string|Buffer} images - one or more images (file paths, Buffers).\n * @param {Object} options - image options, see `sharp()` constructor.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction joinChannel (images, options) {\n if (Array.isArray(images)) {\n images.forEach(function (image) {\n this.options.joinChannelIn.push(this._createInputDescriptor(image, options));\n }, this);\n } else {\n this.options.joinChannelIn.push(this._createInputDescriptor(images, options));\n }\n return this;\n}\n\n/**\n * Perform a bitwise boolean operation on all input image channels (bands) to produce a single channel output image.\n *\n * @example\n * sharp('3-channel-rgb-input.png')\n * .bandbool(sharp.bool.and)\n * .toFile('1-channel-output.png', function (err, info) {\n * // The output will be a single channel image where each pixel `P = R & G & B`.\n * // If `I(1,1) = [247, 170, 14] = [0b11110111, 0b10101010, 0b00001111]`\n * // then `O(1,1) = 0b11110111 & 0b10101010 & 0b00001111 = 0b00000010 = 2`.\n * });\n *\n * @param {string} boolOp - one of `and`, `or` or `eor` to perform that bitwise operation, like the C logic operators `&`, `|` and `^` respectively.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction bandbool (boolOp) {\n if (is.string(boolOp) && is.inArray(boolOp, ['and', 'or', 'eor'])) {\n this.options.bandBoolOp = boolOp;\n } else {\n throw is.invalidParameterError('boolOp', 'one of: and, or, eor', boolOp);\n }\n return this;\n}\n\n/**\n * Decorate the Sharp prototype with channel-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n // Public instance functions\n removeAlpha,\n ensureAlpha,\n extractChannel,\n joinChannel,\n bandbool\n });\n // Class attributes\n Sharp.bool = bool;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst path = require('node:path');\nconst is = require('./is');\nconst sharp = require('./sharp');\n\nconst formats = new Map([\n ['heic', 'heif'],\n ['heif', 'heif'],\n ['avif', 'avif'],\n ['jpeg', 'jpeg'],\n ['jpg', 'jpeg'],\n ['jpe', 'jpeg'],\n ['tile', 'tile'],\n ['dz', 'tile'],\n ['png', 'png'],\n ['raw', 'raw'],\n ['tiff', 'tiff'],\n ['tif', 'tiff'],\n ['webp', 'webp'],\n ['gif', 'gif'],\n ['jp2', 'jp2'],\n ['jpx', 'jp2'],\n ['j2k', 'jp2'],\n ['j2c', 'jp2'],\n ['jxl', 'jxl']\n]);\n\nconst jp2Regex = /\\.(jp[2x]|j2[kc])$/i;\n\nconst errJp2Save = () => new Error('JP2 output requires libvips with support for OpenJPEG');\n\nconst bitdepthFromColourCount = (colours) => 1 << 31 - Math.clz32(Math.ceil(Math.log2(colours)));\n\n/**\n * Write output image data to a file.\n *\n * If an explicit output format is not selected, it will be inferred from the extension,\n * with JPEG, PNG, WebP, AVIF, TIFF, GIF, DZI, and libvips' V format supported.\n * Note that raw pixel data is only supported for buffer output.\n *\n * By default all metadata will be removed, which includes EXIF-based orientation.\n * See {@link #withmetadata withMetadata} for control over this.\n *\n * The caller is responsible for ensuring directory structures and permissions exist.\n *\n * A `Promise` is returned when `callback` is not provided.\n *\n * @example\n * sharp(input)\n * .toFile('output.png', (err, info) => { ... });\n *\n * @example\n * sharp(input)\n * .toFile('output.png')\n * .then(info => { ... })\n * .catch(err => { ... });\n *\n * @param {string} fileOut - the path to write the image data to.\n * @param {Function} [callback] - called on completion with two arguments `(err, info)`.\n * `info` contains the output image `format`, `size` (bytes), `width`, `height`,\n * `channels` and `premultiplied` (indicating if premultiplication was used).\n * When using a crop strategy also contains `cropOffsetLeft` and `cropOffsetTop`.\n * When using the attention crop strategy also contains `attentionX` and `attentionY`, the focal point of the cropped region.\n * Animated output will also contain `pageHeight` and `pages`.\n * May also contain `textAutofitDpi` (dpi the font was rendered at) if image was created from text.\n * @returns {Promise<Object>} - when no callback is provided\n * @throws {Error} Invalid parameters\n */\nfunction toFile (fileOut, callback) {\n let err;\n if (!is.string(fileOut)) {\n err = new Error('Missing output file path');\n } else if (is.string(this.options.input.file) && path.resolve(this.options.input.file) === path.resolve(fileOut)) {\n err = new Error('Cannot use same file for input and output');\n } else if (jp2Regex.test(path.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {\n err = errJp2Save();\n }\n if (err) {\n if (is.fn(callback)) {\n callback(err);\n } else {\n return Promise.reject(err);\n }\n } else {\n this.options.fileOut = fileOut;\n const stack = Error();\n return this._pipeline(callback, stack);\n }\n return this;\n}\n\n/**\n * Write output to a Buffer.\n * JPEG, PNG, WebP, AVIF, TIFF, GIF and raw pixel data output are supported.\n *\n * Use {@link #toformat toFormat} or one of the format-specific functions such as {@link #jpeg jpeg}, {@link #png png} etc. to set the output format.\n *\n * If no explicit format is set, the output format will match the input image, except SVG input which becomes PNG output.\n *\n * By default all metadata will be removed, which includes EXIF-based orientation.\n * See {@link #withmetadata withMetadata} for control over this.\n *\n * `callback`, if present, gets three arguments `(err, data, info)` where:\n * - `err` is an error, if any.\n * - `data` is the output image data.\n * - `info` contains the output image `format`, `size` (bytes), `width`, `height`,\n * `channels` and `premultiplied` (indicating if premultiplication was used).\n * When using a crop strategy also contains `cropOffsetLeft` and `cropOffsetTop`.\n * Animated output will also contain `pageHeight` and `pages`.\n * May also contain `textAutofitDpi` (dpi the font was rendered at) if image was created from text.\n *\n * A `Promise` is returned when `callback` is not provided.\n *\n * @example\n * sharp(input)\n * .toBuffer((err, data, info) => { ... });\n *\n * @example\n * sharp(input)\n * .toBuffer()\n * .then(data => { ... })\n * .catch(err => { ... });\n *\n * @example\n * sharp(input)\n * .png()\n * .toBuffer({ resolveWithObject: true })\n * .then(({ data, info }) => { ... })\n * .catch(err => { ... });\n *\n * @example\n * const { data, info } = await sharp('my-image.jpg')\n * // output the raw pixels\n * .raw()\n * .toBuffer({ resolveWithObject: true });\n *\n * // create a more type safe way to work with the raw pixel data\n * // this will not copy the data, instead it will change `data`s underlying ArrayBuffer\n * // so `data` and `pixelArray` point to the same memory location\n * const pixelArray = new Uint8ClampedArray(data.buffer);\n *\n * // When you are done changing the pixelArray, sharp takes the `pixelArray` as an input\n * const { width, height, channels } = info;\n * await sharp(pixelArray, { raw: { width, height, channels } })\n * .toFile('my-changed-image.jpg');\n *\n * @param {Object} [options]\n * @param {boolean} [options.resolveWithObject] Resolve the Promise with an Object containing `data` and `info` properties instead of resolving only with `data`.\n * @param {Function} [callback]\n * @returns {Promise<Buffer>} - when no callback is provided\n */\nfunction toBuffer (options, callback) {\n if (is.object(options)) {\n this._setBooleanOption('resolveWithObject', options.resolveWithObject);\n } else if (this.options.resolveWithObject) {\n this.options.resolveWithObject = false;\n }\n this.options.fileOut = '';\n const stack = Error();\n return this._pipeline(is.fn(options) ? options : callback, stack);\n}\n\n/**\n * Keep all EXIF metadata from the input image in the output image.\n *\n * EXIF metadata is unsupported for TIFF output.\n *\n * @since 0.33.0\n *\n * @example\n * const outputWithExif = await sharp(inputWithExif)\n * .keepExif()\n * .toBuffer();\n *\n * @returns {Sharp}\n */\nfunction keepExif () {\n this.options.keepMetadata |= 0b00001;\n return this;\n}\n\n/**\n * Set EXIF metadata in the output image, ignoring any EXIF in the input image.\n *\n * @since 0.33.0\n *\n * @example\n * const dataWithExif = await sharp(input)\n * .withExif({\n * IFD0: {\n * Copyright: 'The National Gallery'\n * },\n * IFD3: {\n * GPSLatitudeRef: 'N',\n * GPSLatitude: '51/1 30/1 3230/100',\n * GPSLongitudeRef: 'W',\n * GPSLongitude: '0/1 7/1 4366/100'\n * }\n * })\n * .toBuffer();\n *\n * @param {Object<string, Object<string, string>>} exif Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction withExif (exif) {\n if (is.object(exif)) {\n for (const [ifd, entries] of Object.entries(exif)) {\n if (is.object(entries)) {\n for (const [k, v] of Object.entries(entries)) {\n if (is.string(v)) {\n this.options.withExif[`exif-${ifd.toLowerCase()}-${k}`] = v;\n } else {\n throw is.invalidParameterError(`${ifd}.${k}`, 'string', v);\n }\n }\n } else {\n throw is.invalidParameterError(ifd, 'object', entries);\n }\n }\n } else {\n throw is.invalidParameterError('exif', 'object', exif);\n }\n this.options.withExifMerge = false;\n return this.keepExif();\n}\n\n/**\n * Update EXIF metadata from the input image in the output image.\n *\n * @since 0.33.0\n *\n * @example\n * const dataWithMergedExif = await sharp(inputWithExif)\n * .withExifMerge({\n * IFD0: {\n * Copyright: 'The National Gallery'\n * }\n * })\n * .toBuffer();\n *\n * @param {Object<string, Object<string, string>>} exif Object keyed by IFD0, IFD1 etc. of key/value string pairs to write as EXIF data.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction withExifMerge (exif) {\n this.withExif(exif);\n this.options.withExifMerge = true;\n return this;\n}\n\n/**\n * Keep ICC profile from the input image in the output image.\n *\n * When input and output colour spaces differ, use with {@link /api-colour/#tocolourspace toColourspace} and optionally {@link /api-colour/#pipelinecolourspace pipelineColourspace}.\n *\n * @since 0.33.0\n *\n * @example\n * const outputWithIccProfile = await sharp(inputWithIccProfile)\n * .keepIccProfile()\n * .toBuffer();\n *\n * @example\n * const cmykOutputWithIccProfile = await sharp(cmykInputWithIccProfile)\n * .pipelineColourspace('cmyk')\n * .toColourspace('cmyk')\n * .keepIccProfile()\n * .toBuffer();\n *\n * @returns {Sharp}\n */\nfunction keepIccProfile () {\n this.options.keepMetadata |= 0b01000;\n return this;\n}\n\n/**\n * Transform using an ICC profile and attach to the output image.\n *\n * This can either be an absolute filesystem path or\n * built-in profile name (`srgb`, `p3`, `cmyk`).\n *\n * @since 0.33.0\n *\n * @example\n * const outputWithP3 = await sharp(input)\n * .withIccProfile('p3')\n * .toBuffer();\n *\n * @param {string} icc - Absolute filesystem path to output ICC profile or built-in profile name (srgb, p3, cmyk).\n * @param {Object} [options]\n * @param {number} [options.attach=true] Should the ICC profile be included in the output image metadata?\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction withIccProfile (icc, options) {\n if (is.string(icc)) {\n this.options.withIccProfile = icc;\n } else {\n throw is.invalidParameterError('icc', 'string', icc);\n }\n this.keepIccProfile();\n if (is.object(options)) {\n if (is.defined(options.attach)) {\n if (is.bool(options.attach)) {\n if (!options.attach) {\n this.options.keepMetadata &= ~0b01000;\n }\n } else {\n throw is.invalidParameterError('attach', 'boolean', options.attach);\n }\n }\n }\n return this;\n}\n\n/**\n * Keep XMP metadata from the input image in the output image.\n *\n * @since 0.34.3\n *\n * @example\n * const outputWithXmp = await sharp(inputWithXmp)\n * .keepXmp()\n * .toBuffer();\n *\n * @returns {Sharp}\n */\nfunction keepXmp () {\n this.options.keepMetadata |= 0b00010;\n return this;\n}\n\n/**\n * Set XMP metadata in the output image.\n *\n * Supported by PNG, JPEG, WebP, and TIFF output.\n *\n * @since 0.34.3\n *\n * @example\n * const xmpString = `\n * <?xml version=\"1.0\"?>\n * <x:xmpmeta xmlns:x=\"adobe:ns:meta/\">\n * <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n * <rdf:Description rdf:about=\"\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n * <dc:creator><rdf:Seq><rdf:li>John Doe</rdf:li></rdf:Seq></dc:creator>\n * </rdf:Description>\n * </rdf:RDF>\n * </x:xmpmeta>`;\n *\n * const data = await sharp(input)\n * .withXmp(xmpString)\n * .toBuffer();\n *\n * @param {string} xmp String containing XMP metadata to be embedded in the output image.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction withXmp (xmp) {\n if (is.string(xmp) && xmp.length > 0) {\n this.options.withXmp = xmp;\n this.options.keepMetadata |= 0b00010;\n } else {\n throw is.invalidParameterError('xmp', 'non-empty string', xmp);\n }\n return this;\n}\n\n/**\n * Keep all metadata (EXIF, ICC, XMP, IPTC) from the input image in the output image.\n *\n * The default behaviour, when `keepMetadata` is not used, is to convert to the device-independent\n * sRGB colour space and strip all metadata, including the removal of any ICC profile.\n *\n * @since 0.33.0\n *\n * @example\n * const outputWithMetadata = await sharp(inputWithMetadata)\n * .keepMetadata()\n * .toBuffer();\n *\n * @returns {Sharp}\n */\nfunction keepMetadata () {\n this.options.keepMetadata = 0b11111;\n return this;\n}\n\n/**\n * Keep most metadata (EXIF, XMP, IPTC) from the input image in the output image.\n *\n * This will also convert to and add a web-friendly sRGB ICC profile if appropriate.\n *\n * Allows orientation and density to be set or updated.\n *\n * @example\n * const outputSrgbWithMetadata = await sharp(inputRgbWithMetadata)\n * .withMetadata()\n * .toBuffer();\n *\n * @example\n * // Set output metadata to 96 DPI\n * const data = await sharp(input)\n * .withMetadata({ density: 96 })\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {number} [options.orientation] Used to update the EXIF `Orientation` tag, integer between 1 and 8.\n * @param {number} [options.density] Number of pixels per inch (DPI).\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction withMetadata (options) {\n this.keepMetadata();\n this.withIccProfile('srgb');\n if (is.object(options)) {\n if (is.defined(options.orientation)) {\n if (is.integer(options.orientation) && is.inRange(options.orientation, 1, 8)) {\n this.options.withMetadataOrientation = options.orientation;\n } else {\n throw is.invalidParameterError('orientation', 'integer between 1 and 8', options.orientation);\n }\n }\n if (is.defined(options.density)) {\n if (is.number(options.density) && options.density > 0) {\n this.options.withMetadataDensity = options.density;\n } else {\n throw is.invalidParameterError('density', 'positive number', options.density);\n }\n }\n if (is.defined(options.icc)) {\n this.withIccProfile(options.icc);\n }\n if (is.defined(options.exif)) {\n this.withExifMerge(options.exif);\n }\n }\n return this;\n}\n\n/**\n * Force output to a given format.\n *\n * @example\n * // Convert any input to PNG output\n * const data = await sharp(input)\n * .toFormat('png')\n * .toBuffer();\n *\n * @param {(string|Object)} format - as a string or an Object with an 'id' attribute\n * @param {Object} options - output options\n * @returns {Sharp}\n * @throws {Error} unsupported format or options\n */\nfunction toFormat (format, options) {\n const actualFormat = formats.get((is.object(format) && is.string(format.id) ? format.id : format).toLowerCase());\n if (!actualFormat) {\n throw is.invalidParameterError('format', `one of: ${[...formats.keys()].join(', ')}`, format);\n }\n return this[actualFormat](options);\n}\n\n/**\n * Use these JPEG options for output image.\n *\n * @example\n * // Convert any input to very high quality JPEG output\n * const data = await sharp(input)\n * .jpeg({\n * quality: 100,\n * chromaSubsampling: '4:4:4'\n * })\n * .toBuffer();\n *\n * @example\n * // Use mozjpeg to reduce output JPEG file size (slower)\n * const data = await sharp(input)\n * .jpeg({ mozjpeg: true })\n * .toBuffer();\n *\n * @param {Object} [options] - output options\n * @param {number} [options.quality=80] - quality, integer 1-100\n * @param {boolean} [options.progressive=false] - use progressive (interlace) scan\n * @param {string} [options.chromaSubsampling='4:2:0'] - set to '4:4:4' to prevent chroma subsampling otherwise defaults to '4:2:0' chroma subsampling\n * @param {boolean} [options.optimiseCoding=true] - optimise Huffman coding tables\n * @param {boolean} [options.optimizeCoding=true] - alternative spelling of optimiseCoding\n * @param {boolean} [options.mozjpeg=false] - use mozjpeg defaults, equivalent to `{ trellisQuantisation: true, overshootDeringing: true, optimiseScans: true, quantisationTable: 3 }`\n * @param {boolean} [options.trellisQuantisation=false] - apply trellis quantisation\n * @param {boolean} [options.overshootDeringing=false] - apply overshoot deringing\n * @param {boolean} [options.optimiseScans=false] - optimise progressive scans, forces progressive\n * @param {boolean} [options.optimizeScans=false] - alternative spelling of optimiseScans\n * @param {number} [options.quantisationTable=0] - quantization table to use, integer 0-8\n * @param {number} [options.quantizationTable=0] - alternative spelling of quantisationTable\n * @param {boolean} [options.force=true] - force JPEG output, otherwise attempt to use input format\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction jpeg (options) {\n if (is.object(options)) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n this.options.jpegQuality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n }\n if (is.defined(options.progressive)) {\n this._setBooleanOption('jpegProgressive', options.progressive);\n }\n if (is.defined(options.chromaSubsampling)) {\n if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) {\n this.options.jpegChromaSubsampling = options.chromaSubsampling;\n } else {\n throw is.invalidParameterError('chromaSubsampling', 'one of: 4:2:0, 4:4:4', options.chromaSubsampling);\n }\n }\n const optimiseCoding = is.bool(options.optimizeCoding) ? options.optimizeCoding : options.optimiseCoding;\n if (is.defined(optimiseCoding)) {\n this._setBooleanOption('jpegOptimiseCoding', optimiseCoding);\n }\n if (is.defined(options.mozjpeg)) {\n if (is.bool(options.mozjpeg)) {\n if (options.mozjpeg) {\n this.options.jpegTrellisQuantisation = true;\n this.options.jpegOvershootDeringing = true;\n this.options.jpegOptimiseScans = true;\n this.options.jpegProgressive = true;\n this.options.jpegQuantisationTable = 3;\n }\n } else {\n throw is.invalidParameterError('mozjpeg', 'boolean', options.mozjpeg);\n }\n }\n const trellisQuantisation = is.bool(options.trellisQuantization) ? options.trellisQuantization : options.trellisQuantisation;\n if (is.defined(trellisQuantisation)) {\n this._setBooleanOption('jpegTrellisQuantisation', trellisQuantisation);\n }\n if (is.defined(options.overshootDeringing)) {\n this._setBooleanOption('jpegOvershootDeringing', options.overshootDeringing);\n }\n const optimiseScans = is.bool(options.optimizeScans) ? options.optimizeScans : options.optimiseScans;\n if (is.defined(optimiseScans)) {\n this._setBooleanOption('jpegOptimiseScans', optimiseScans);\n if (optimiseScans) {\n this.options.jpegProgressive = true;\n }\n }\n const quantisationTable = is.number(options.quantizationTable) ? options.quantizationTable : options.quantisationTable;\n if (is.defined(quantisationTable)) {\n if (is.integer(quantisationTable) && is.inRange(quantisationTable, 0, 8)) {\n this.options.jpegQuantisationTable = quantisationTable;\n } else {\n throw is.invalidParameterError('quantisationTable', 'integer between 0 and 8', quantisationTable);\n }\n }\n }\n return this._updateFormatOut('jpeg', options);\n}\n\n/**\n * Use these PNG options for output image.\n *\n * By default, PNG output is full colour at 8 bits per pixel.\n *\n * Indexed PNG input at 1, 2 or 4 bits per pixel is converted to 8 bits per pixel.\n * Set `palette` to `true` for slower, indexed PNG output.\n *\n * For 16 bits per pixel output, convert to `rgb16` via\n * {@link /api-colour/#tocolourspace toColourspace}.\n *\n * @example\n * // Convert any input to full colour PNG output\n * const data = await sharp(input)\n * .png()\n * .toBuffer();\n *\n * @example\n * // Convert any input to indexed PNG output (slower)\n * const data = await sharp(input)\n * .png({ palette: true })\n * .toBuffer();\n *\n * @example\n * // Output 16 bits per pixel RGB(A)\n * const data = await sharp(input)\n * .toColourspace('rgb16')\n * .png()\n * .toBuffer();\n *\n * @param {Object} [options]\n * @param {boolean} [options.progressive=false] - use progressive (interlace) scan\n * @param {number} [options.compressionLevel=6] - zlib compression level, 0 (fastest, largest) to 9 (slowest, smallest)\n * @param {boolean} [options.adaptiveFiltering=false] - use adaptive row filtering\n * @param {boolean} [options.palette=false] - quantise to a palette-based image with alpha transparency support\n * @param {number} [options.quality=100] - use the lowest number of colours needed to achieve given quality, sets `palette` to `true`\n * @param {number} [options.effort=7] - CPU effort, between 1 (fastest) and 10 (slowest), sets `palette` to `true`\n * @param {number} [options.colours=256] - maximum number of palette entries, sets `palette` to `true`\n * @param {number} [options.colors=256] - alternative spelling of `options.colours`, sets `palette` to `true`\n * @param {number} [options.dither=1.0] - level of Floyd-Steinberg error diffusion, sets `palette` to `true`\n * @param {boolean} [options.force=true] - force PNG output, otherwise attempt to use input format\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction png (options) {\n if (is.object(options)) {\n if (is.defined(options.progressive)) {\n this._setBooleanOption('pngProgressive', options.progressive);\n }\n if (is.defined(options.compressionLevel)) {\n if (is.integer(options.compressionLevel) && is.inRange(options.compressionLevel, 0, 9)) {\n this.options.pngCompressionLevel = options.compressionLevel;\n } else {\n throw is.invalidParameterError('compressionLevel', 'integer between 0 and 9', options.compressionLevel);\n }\n }\n if (is.defined(options.adaptiveFiltering)) {\n this._setBooleanOption('pngAdaptiveFiltering', options.adaptiveFiltering);\n }\n const colours = options.colours || options.colors;\n if (is.defined(colours)) {\n if (is.integer(colours) && is.inRange(colours, 2, 256)) {\n this.options.pngBitdepth = bitdepthFromColourCount(colours);\n } else {\n throw is.invalidParameterError('colours', 'integer between 2 and 256', colours);\n }\n }\n if (is.defined(options.palette)) {\n this._setBooleanOption('pngPalette', options.palette);\n } else if ([options.quality, options.effort, options.colours, options.colors, options.dither].some(is.defined)) {\n this._setBooleanOption('pngPalette', true);\n }\n if (this.options.pngPalette) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 0, 100)) {\n this.options.pngQuality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 0 and 100', options.quality);\n }\n }\n if (is.defined(options.effort)) {\n if (is.integer(options.effort) && is.inRange(options.effort, 1, 10)) {\n this.options.pngEffort = options.effort;\n } else {\n throw is.invalidParameterError('effort', 'integer between 1 and 10', options.effort);\n }\n }\n if (is.defined(options.dither)) {\n if (is.number(options.dither) && is.inRange(options.dither, 0, 1)) {\n this.options.pngDither = options.dither;\n } else {\n throw is.invalidParameterError('dither', 'number between 0.0 and 1.0', options.dither);\n }\n }\n }\n }\n return this._updateFormatOut('png', options);\n}\n\n/**\n * Use these WebP options for output image.\n *\n * @example\n * // Convert any input to lossless WebP output\n * const data = await sharp(input)\n * .webp({ lossless: true })\n * .toBuffer();\n *\n * @example\n * // Optimise the file size of an animated WebP\n * const outputWebp = await sharp(inputWebp, { animated: true })\n * .webp({ effort: 6 })\n * .toBuffer();\n *\n * @param {Object} [options] - output options\n * @param {number} [options.quality=80] - quality, integer 1-100\n * @param {number} [options.alphaQuality=100] - quality of alpha layer, integer 0-100\n * @param {boolean} [options.lossless=false] - use lossless compression mode\n * @param {boolean} [options.nearLossless=false] - use near_lossless compression mode\n * @param {boolean} [options.smartSubsample=false] - use high quality chroma subsampling\n * @param {boolean} [options.smartDeblock=false] - auto-adjust the deblocking filter, can improve low contrast edges (slow)\n * @param {string} [options.preset='default'] - named preset for preprocessing/filtering, one of: default, photo, picture, drawing, icon, text\n * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 6 (slowest)\n * @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation\n * @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)\n * @param {boolean} [options.minSize=false] - prevent use of animation key frames to minimise file size (slow)\n * @param {boolean} [options.mixed=false] - allow mixture of lossy and lossless animation frames (slow)\n * @param {boolean} [options.force=true] - force WebP output, otherwise attempt to use input format\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction webp (options) {\n if (is.object(options)) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n this.options.webpQuality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n }\n if (is.defined(options.alphaQuality)) {\n if (is.integer(options.alphaQuality) && is.inRange(options.alphaQuality, 0, 100)) {\n this.options.webpAlphaQuality = options.alphaQuality;\n } else {\n throw is.invalidParameterError('alphaQuality', 'integer between 0 and 100', options.alphaQuality);\n }\n }\n if (is.defined(options.lossless)) {\n this._setBooleanOption('webpLossless', options.lossless);\n }\n if (is.defined(options.nearLossless)) {\n this._setBooleanOption('webpNearLossless', options.nearLossless);\n }\n if (is.defined(options.smartSubsample)) {\n this._setBooleanOption('webpSmartSubsample', options.smartSubsample);\n }\n if (is.defined(options.smartDeblock)) {\n this._setBooleanOption('webpSmartDeblock', options.smartDeblock);\n }\n if (is.defined(options.preset)) {\n if (is.string(options.preset) && is.inArray(options.preset, ['default', 'photo', 'picture', 'drawing', 'icon', 'text'])) {\n this.options.webpPreset = options.preset;\n } else {\n throw is.invalidParameterError('preset', 'one of: default, photo, picture, drawing, icon, text', options.preset);\n }\n }\n if (is.defined(options.effort)) {\n if (is.integer(options.effort) && is.inRange(options.effort, 0, 6)) {\n this.options.webpEffort = options.effort;\n } else {\n throw is.invalidParameterError('effort', 'integer between 0 and 6', options.effort);\n }\n }\n if (is.defined(options.minSize)) {\n this._setBooleanOption('webpMinSize', options.minSize);\n }\n if (is.defined(options.mixed)) {\n this._setBooleanOption('webpMixed', options.mixed);\n }\n }\n trySetAnimationOptions(options, this.options);\n return this._updateFormatOut('webp', options);\n}\n\n/**\n * Use these GIF options for the output image.\n *\n * The first entry in the palette is reserved for transparency.\n *\n * The palette of the input image will be re-used if possible.\n *\n * @since 0.30.0\n *\n * @example\n * // Convert PNG to GIF\n * await sharp(pngBuffer)\n * .gif()\n * .toBuffer();\n *\n * @example\n * // Convert animated WebP to animated GIF\n * await sharp('animated.webp', { animated: true })\n * .toFile('animated.gif');\n *\n * @example\n * // Create a 128x128, cropped, non-dithered, animated thumbnail of an animated GIF\n * const out = await sharp('in.gif', { animated: true })\n * .resize({ width: 128, height: 128 })\n * .gif({ dither: 0 })\n * .toBuffer();\n *\n * @example\n * // Lossy file size reduction of animated GIF\n * await sharp('in.gif', { animated: true })\n * .gif({ interFrameMaxError: 8 })\n * .toFile('optim.gif');\n *\n * @param {Object} [options] - output options\n * @param {boolean} [options.reuse=true] - re-use existing palette, otherwise generate new (slow)\n * @param {boolean} [options.progressive=false] - use progressive (interlace) scan\n * @param {number} [options.colours=256] - maximum number of palette entries, including transparency, between 2 and 256\n * @param {number} [options.colors=256] - alternative spelling of `options.colours`\n * @param {number} [options.effort=7] - CPU effort, between 1 (fastest) and 10 (slowest)\n * @param {number} [options.dither=1.0] - level of Floyd-Steinberg error diffusion, between 0 (least) and 1 (most)\n * @param {number} [options.interFrameMaxError=0] - maximum inter-frame error for transparency, between 0 (lossless) and 32\n * @param {number} [options.interPaletteMaxError=3] - maximum inter-palette error for palette reuse, between 0 and 256\n * @param {boolean} [options.keepDuplicateFrames=false] - keep duplicate frames in the output instead of combining them\n * @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation\n * @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)\n * @param {boolean} [options.force=true] - force GIF output, otherwise attempt to use input format\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction gif (options) {\n if (is.object(options)) {\n if (is.defined(options.reuse)) {\n this._setBooleanOption('gifReuse', options.reuse);\n }\n if (is.defined(options.progressive)) {\n this._setBooleanOption('gifProgressive', options.progressive);\n }\n const colours = options.colours || options.colors;\n if (is.defined(colours)) {\n if (is.integer(colours) && is.inRange(colours, 2, 256)) {\n this.options.gifBitdepth = bitdepthFromColourCount(colours);\n } else {\n throw is.invalidParameterError('colours', 'integer between 2 and 256', colours);\n }\n }\n if (is.defined(options.effort)) {\n if (is.number(options.effort) && is.inRange(options.effort, 1, 10)) {\n this.options.gifEffort = options.effort;\n } else {\n throw is.invalidParameterError('effort', 'integer between 1 and 10', options.effort);\n }\n }\n if (is.defined(options.dither)) {\n if (is.number(options.dither) && is.inRange(options.dither, 0, 1)) {\n this.options.gifDither = options.dither;\n } else {\n throw is.invalidParameterError('dither', 'number between 0.0 and 1.0', options.dither);\n }\n }\n if (is.defined(options.interFrameMaxError)) {\n if (is.number(options.interFrameMaxError) && is.inRange(options.interFrameMaxError, 0, 32)) {\n this.options.gifInterFrameMaxError = options.interFrameMaxError;\n } else {\n throw is.invalidParameterError('interFrameMaxError', 'number between 0.0 and 32.0', options.interFrameMaxError);\n }\n }\n if (is.defined(options.interPaletteMaxError)) {\n if (is.number(options.interPaletteMaxError) && is.inRange(options.interPaletteMaxError, 0, 256)) {\n this.options.gifInterPaletteMaxError = options.interPaletteMaxError;\n } else {\n throw is.invalidParameterError('interPaletteMaxError', 'number between 0.0 and 256.0', options.interPaletteMaxError);\n }\n }\n if (is.defined(options.keepDuplicateFrames)) {\n if (is.bool(options.keepDuplicateFrames)) {\n this._setBooleanOption('gifKeepDuplicateFrames', options.keepDuplicateFrames);\n } else {\n throw is.invalidParameterError('keepDuplicateFrames', 'boolean', options.keepDuplicateFrames);\n }\n }\n }\n trySetAnimationOptions(options, this.options);\n return this._updateFormatOut('gif', options);\n}\n\n/**\n * Use these JP2 options for output image.\n *\n * Requires libvips compiled with support for OpenJPEG.\n * The prebuilt binaries do not include this - see\n * {@link /install#custom-libvips installing a custom libvips}.\n *\n * @example\n * // Convert any input to lossless JP2 output\n * const data = await sharp(input)\n * .jp2({ lossless: true })\n * .toBuffer();\n *\n * @example\n * // Convert any input to very high quality JP2 output\n * const data = await sharp(input)\n * .jp2({\n * quality: 100,\n * chromaSubsampling: '4:4:4'\n * })\n * .toBuffer();\n *\n * @since 0.29.1\n *\n * @param {Object} [options] - output options\n * @param {number} [options.quality=80] - quality, integer 1-100\n * @param {boolean} [options.lossless=false] - use lossless compression mode\n * @param {number} [options.tileWidth=512] - horizontal tile size\n * @param {number} [options.tileHeight=512] - vertical tile size\n * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction jp2 (options) {\n /* node:coverage ignore next 41 */\n if (!this.constructor.format.jp2k.output.buffer) {\n throw errJp2Save();\n }\n if (is.object(options)) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n this.options.jp2Quality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n }\n if (is.defined(options.lossless)) {\n if (is.bool(options.lossless)) {\n this.options.jp2Lossless = options.lossless;\n } else {\n throw is.invalidParameterError('lossless', 'boolean', options.lossless);\n }\n }\n if (is.defined(options.tileWidth)) {\n if (is.integer(options.tileWidth) && is.inRange(options.tileWidth, 1, 32768)) {\n this.options.jp2TileWidth = options.tileWidth;\n } else {\n throw is.invalidParameterError('tileWidth', 'integer between 1 and 32768', options.tileWidth);\n }\n }\n if (is.defined(options.tileHeight)) {\n if (is.integer(options.tileHeight) && is.inRange(options.tileHeight, 1, 32768)) {\n this.options.jp2TileHeight = options.tileHeight;\n } else {\n throw is.invalidParameterError('tileHeight', 'integer between 1 and 32768', options.tileHeight);\n }\n }\n if (is.defined(options.chromaSubsampling)) {\n if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) {\n this.options.jp2ChromaSubsampling = options.chromaSubsampling;\n } else {\n throw is.invalidParameterError('chromaSubsampling', 'one of: 4:2:0, 4:4:4', options.chromaSubsampling);\n }\n }\n }\n return this._updateFormatOut('jp2', options);\n}\n\n/**\n * Set animation options if available.\n * @private\n *\n * @param {Object} [source] - output options\n * @param {number} [source.loop=0] - number of animation iterations, use 0 for infinite animation\n * @param {number[]} [source.delay] - list of delays between animation frames (in milliseconds)\n * @param {Object} [target] - target object for valid options\n * @throws {Error} Invalid options\n */\nfunction trySetAnimationOptions (source, target) {\n if (is.object(source) && is.defined(source.loop)) {\n if (is.integer(source.loop) && is.inRange(source.loop, 0, 65535)) {\n target.loop = source.loop;\n } else {\n throw is.invalidParameterError('loop', 'integer between 0 and 65535', source.loop);\n }\n }\n if (is.object(source) && is.defined(source.delay)) {\n // We allow singular values as well\n if (is.integer(source.delay) && is.inRange(source.delay, 0, 65535)) {\n target.delay = [source.delay];\n } else if (\n Array.isArray(source.delay) &&\n source.delay.every(is.integer) &&\n source.delay.every(v => is.inRange(v, 0, 65535))) {\n target.delay = source.delay;\n } else {\n throw is.invalidParameterError('delay', 'integer or an array of integers between 0 and 65535', source.delay);\n }\n }\n}\n\n/**\n * Use these TIFF options for output image.\n *\n * The `density` can be set in pixels/inch via {@link #withmetadata withMetadata}\n * instead of providing `xres` and `yres` in pixels/mm.\n *\n * @example\n * // Convert SVG input to LZW-compressed, 1 bit per pixel TIFF output\n * sharp('input.svg')\n * .tiff({\n * compression: 'lzw',\n * bitdepth: 1\n * })\n * .toFile('1-bpp-output.tiff')\n * .then(info => { ... });\n *\n * @param {Object} [options] - output options\n * @param {number} [options.quality=80] - quality, integer 1-100\n * @param {boolean} [options.force=true] - force TIFF output, otherwise attempt to use input format\n * @param {string} [options.compression='jpeg'] - compression options: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k\n * @param {boolean} [options.bigtiff=false] - use BigTIFF variant (has no effect when compression is none)\n * @param {string} [options.predictor='horizontal'] - compression predictor options: none, horizontal, float\n * @param {boolean} [options.pyramid=false] - write an image pyramid\n * @param {boolean} [options.tile=false] - write a tiled tiff\n * @param {number} [options.tileWidth=256] - horizontal tile size\n * @param {number} [options.tileHeight=256] - vertical tile size\n * @param {number} [options.xres=1.0] - horizontal resolution in pixels/mm\n * @param {number} [options.yres=1.0] - vertical resolution in pixels/mm\n * @param {string} [options.resolutionUnit='inch'] - resolution unit options: inch, cm\n * @param {number} [options.bitdepth=8] - reduce bitdepth to 1, 2 or 4 bit\n * @param {boolean} [options.miniswhite=false] - write 1-bit images as miniswhite\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction tiff (options) {\n if (is.object(options)) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n this.options.tiffQuality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n }\n if (is.defined(options.bitdepth)) {\n if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [1, 2, 4, 8])) {\n this.options.tiffBitdepth = options.bitdepth;\n } else {\n throw is.invalidParameterError('bitdepth', '1, 2, 4 or 8', options.bitdepth);\n }\n }\n // tiling\n if (is.defined(options.tile)) {\n this._setBooleanOption('tiffTile', options.tile);\n }\n if (is.defined(options.tileWidth)) {\n if (is.integer(options.tileWidth) && options.tileWidth > 0) {\n this.options.tiffTileWidth = options.tileWidth;\n } else {\n throw is.invalidParameterError('tileWidth', 'integer greater than zero', options.tileWidth);\n }\n }\n if (is.defined(options.tileHeight)) {\n if (is.integer(options.tileHeight) && options.tileHeight > 0) {\n this.options.tiffTileHeight = options.tileHeight;\n } else {\n throw is.invalidParameterError('tileHeight', 'integer greater than zero', options.tileHeight);\n }\n }\n // miniswhite\n if (is.defined(options.miniswhite)) {\n this._setBooleanOption('tiffMiniswhite', options.miniswhite);\n }\n // pyramid\n if (is.defined(options.pyramid)) {\n this._setBooleanOption('tiffPyramid', options.pyramid);\n }\n // resolution\n if (is.defined(options.xres)) {\n if (is.number(options.xres) && options.xres > 0) {\n this.options.tiffXres = options.xres;\n } else {\n throw is.invalidParameterError('xres', 'number greater than zero', options.xres);\n }\n }\n if (is.defined(options.yres)) {\n if (is.number(options.yres) && options.yres > 0) {\n this.options.tiffYres = options.yres;\n } else {\n throw is.invalidParameterError('yres', 'number greater than zero', options.yres);\n }\n }\n // compression\n if (is.defined(options.compression)) {\n if (is.string(options.compression) && is.inArray(options.compression, ['none', 'jpeg', 'deflate', 'packbits', 'ccittfax4', 'lzw', 'webp', 'zstd', 'jp2k'])) {\n this.options.tiffCompression = options.compression;\n } else {\n throw is.invalidParameterError('compression', 'one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k', options.compression);\n }\n }\n // bigtiff\n if (is.defined(options.bigtiff)) {\n this._setBooleanOption('tiffBigtiff', options.bigtiff);\n }\n // predictor\n if (is.defined(options.predictor)) {\n if (is.string(options.predictor) && is.inArray(options.predictor, ['none', 'horizontal', 'float'])) {\n this.options.tiffPredictor = options.predictor;\n } else {\n throw is.invalidParameterError('predictor', 'one of: none, horizontal, float', options.predictor);\n }\n }\n // resolutionUnit\n if (is.defined(options.resolutionUnit)) {\n if (is.string(options.resolutionUnit) && is.inArray(options.resolutionUnit, ['inch', 'cm'])) {\n this.options.tiffResolutionUnit = options.resolutionUnit;\n } else {\n throw is.invalidParameterError('resolutionUnit', 'one of: inch, cm', options.resolutionUnit);\n }\n }\n }\n return this._updateFormatOut('tiff', options);\n}\n\n/**\n * Use these AVIF options for output image.\n *\n * AVIF image sequences are not supported.\n * Prebuilt binaries support a bitdepth of 8 only.\n *\n * This feature is experimental on the Windows ARM64 platform\n * and requires a CPU with ARM64v8.4 or later.\n *\n * @example\n * const data = await sharp(input)\n * .avif({ effort: 2 })\n * .toBuffer();\n *\n * @example\n * const data = await sharp(input)\n * .avif({ lossless: true })\n * .toBuffer();\n *\n * @since 0.27.0\n *\n * @param {Object} [options] - output options\n * @param {number} [options.quality=50] - quality, integer 1-100\n * @param {boolean} [options.lossless=false] - use lossless compression\n * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)\n * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling\n * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction avif (options) {\n return this.heif({ ...options, compression: 'av1' });\n}\n\n/**\n * Use these HEIF options for output image.\n *\n * Support for patent-encumbered HEIC images using `hevc` compression requires the use of a\n * globally-installed libvips compiled with support for libheif, libde265 and x265.\n *\n * @example\n * const data = await sharp(input)\n * .heif({ compression: 'hevc' })\n * .toBuffer();\n *\n * @since 0.23.0\n *\n * @param {Object} options - output options\n * @param {string} options.compression - compression format: av1, hevc\n * @param {number} [options.quality=50] - quality, integer 1-100\n * @param {boolean} [options.lossless=false] - use lossless compression\n * @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 9 (slowest)\n * @param {string} [options.chromaSubsampling='4:4:4'] - set to '4:2:0' to use chroma subsampling\n * @param {number} [options.bitdepth=8] - set bitdepth to 8, 10 or 12 bit\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction heif (options) {\n if (is.object(options)) {\n if (is.string(options.compression) && is.inArray(options.compression, ['av1', 'hevc'])) {\n this.options.heifCompression = options.compression;\n } else {\n throw is.invalidParameterError('compression', 'one of: av1, hevc', options.compression);\n }\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n this.options.heifQuality = options.quality;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n }\n if (is.defined(options.lossless)) {\n if (is.bool(options.lossless)) {\n this.options.heifLossless = options.lossless;\n } else {\n throw is.invalidParameterError('lossless', 'boolean', options.lossless);\n }\n }\n if (is.defined(options.effort)) {\n if (is.integer(options.effort) && is.inRange(options.effort, 0, 9)) {\n this.options.heifEffort = options.effort;\n } else {\n throw is.invalidParameterError('effort', 'integer between 0 and 9', options.effort);\n }\n }\n if (is.defined(options.chromaSubsampling)) {\n if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) {\n this.options.heifChromaSubsampling = options.chromaSubsampling;\n } else {\n throw is.invalidParameterError('chromaSubsampling', 'one of: 4:2:0, 4:4:4', options.chromaSubsampling);\n }\n }\n if (is.defined(options.bitdepth)) {\n if (is.integer(options.bitdepth) && is.inArray(options.bitdepth, [8, 10, 12])) {\n if (options.bitdepth !== 8 && this.constructor.versions.heif) {\n throw is.invalidParameterError('bitdepth when using prebuilt binaries', 8, options.bitdepth);\n }\n this.options.heifBitdepth = options.bitdepth;\n } else {\n throw is.invalidParameterError('bitdepth', '8, 10 or 12', options.bitdepth);\n }\n }\n } else {\n throw is.invalidParameterError('options', 'Object', options);\n }\n return this._updateFormatOut('heif', options);\n}\n\n/**\n * Use these JPEG-XL (JXL) options for output image.\n *\n * This feature is experimental, please do not use in production systems.\n *\n * Requires libvips compiled with support for libjxl.\n * The prebuilt binaries do not include this - see\n * {@link /install/#custom-libvips installing a custom libvips}.\n *\n * @since 0.31.3\n *\n * @param {Object} [options] - output options\n * @param {number} [options.distance=1.0] - maximum encoding error, between 0 (highest quality) and 15 (lowest quality)\n * @param {number} [options.quality] - calculate `distance` based on JPEG-like quality, between 1 and 100, overrides distance if specified\n * @param {number} [options.decodingTier=0] - target decode speed tier, between 0 (highest quality) and 4 (lowest quality)\n * @param {boolean} [options.lossless=false] - use lossless compression\n * @param {number} [options.effort=7] - CPU effort, between 1 (fastest) and 9 (slowest)\n * @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation\n * @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction jxl (options) {\n if (is.object(options)) {\n if (is.defined(options.quality)) {\n if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {\n // https://github.com/libjxl/libjxl/blob/0aeea7f180bafd6893c1db8072dcb67d2aa5b03d/tools/cjxl_main.cc#L640-L644\n this.options.jxlDistance = options.quality >= 30\n ? 0.1 + (100 - options.quality) * 0.09\n : 53 / 3000 * options.quality * options.quality - 23 / 20 * options.quality + 25;\n } else {\n throw is.invalidParameterError('quality', 'integer between 1 and 100', options.quality);\n }\n } else if (is.defined(options.distance)) {\n if (is.number(options.distance) && is.inRange(options.distance, 0, 15)) {\n this.options.jxlDistance = options.distance;\n } else {\n throw is.invalidParameterError('distance', 'number between 0.0 and 15.0', options.distance);\n }\n }\n if (is.defined(options.decodingTier)) {\n if (is.integer(options.decodingTier) && is.inRange(options.decodingTier, 0, 4)) {\n this.options.jxlDecodingTier = options.decodingTier;\n } else {\n throw is.invalidParameterError('decodingTier', 'integer between 0 and 4', options.decodingTier);\n }\n }\n if (is.defined(options.lossless)) {\n if (is.bool(options.lossless)) {\n this.options.jxlLossless = options.lossless;\n } else {\n throw is.invalidParameterError('lossless', 'boolean', options.lossless);\n }\n }\n if (is.defined(options.effort)) {\n if (is.integer(options.effort) && is.inRange(options.effort, 1, 9)) {\n this.options.jxlEffort = options.effort;\n } else {\n throw is.invalidParameterError('effort', 'integer between 1 and 9', options.effort);\n }\n }\n }\n trySetAnimationOptions(options, this.options);\n return this._updateFormatOut('jxl', options);\n}\n\n/**\n * Force output to be raw, uncompressed pixel data.\n * Pixel ordering is left-to-right, top-to-bottom, without padding.\n * Channel ordering will be RGB or RGBA for non-greyscale colourspaces.\n *\n * @example\n * // Extract raw, unsigned 8-bit RGB pixel data from JPEG input\n * const { data, info } = await sharp('input.jpg')\n * .raw()\n * .toBuffer({ resolveWithObject: true });\n *\n * @example\n * // Extract alpha channel as raw, unsigned 16-bit pixel data from PNG input\n * const data = await sharp('input.png')\n * .ensureAlpha()\n * .extractChannel(3)\n * .toColourspace('b-w')\n * .raw({ depth: 'ushort' })\n * .toBuffer();\n *\n * @param {Object} [options] - output options\n * @param {string} [options.depth='uchar'] - bit depth, one of: char, uchar (default), short, ushort, int, uint, float, complex, double, dpcomplex\n * @returns {Sharp}\n * @throws {Error} Invalid options\n */\nfunction raw (options) {\n if (is.object(options)) {\n if (is.defined(options.depth)) {\n if (is.string(options.depth) && is.inArray(options.depth,\n ['char', 'uchar', 'short', 'ushort', 'int', 'uint', 'float', 'complex', 'double', 'dpcomplex']\n )) {\n this.options.rawDepth = options.depth;\n } else {\n throw is.invalidParameterError('depth', 'one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex', options.depth);\n }\n }\n }\n return this._updateFormatOut('raw');\n}\n\n/**\n * Use tile-based deep zoom (image pyramid) output.\n *\n * Set the format and options for tile images via the `toFormat`, `jpeg`, `png` or `webp` functions.\n * Use a `.zip` or `.szi` file extension with `toFile` to write to a compressed archive file format.\n *\n * The container will be set to `zip` when the output is a Buffer or Stream, otherwise it will default to `fs`.\n *\n * @example\n * sharp('input.tiff')\n * .png()\n * .tile({\n * size: 512\n * })\n * .toFile('output.dz', function(err, info) {\n * // output.dzi is the Deep Zoom XML definition\n * // output_files contains 512x512 tiles grouped by zoom level\n * });\n *\n * @example\n * const zipFileWithTiles = await sharp(input)\n * .tile({ basename: \"tiles\" })\n * .toBuffer();\n *\n * @example\n * const iiififier = sharp().tile({ layout: \"iiif\" });\n * readableStream\n * .pipe(iiififier)\n * .pipe(writeableStream);\n *\n * @param {Object} [options]\n * @param {number} [options.size=256] tile size in pixels, a value between 1 and 8192.\n * @param {number} [options.overlap=0] tile overlap in pixels, a value between 0 and 8192.\n * @param {number} [options.angle=0] tile angle of rotation, must be a multiple of 90.\n * @param {string|Object} [options.background={r: 255, g: 255, b: 255, alpha: 1}] - background colour, parsed by the [color](https://www.npmjs.org/package/color) module, defaults to white without transparency.\n * @param {string} [options.depth] how deep to make the pyramid, possible values are `onepixel`, `onetile` or `one`, default based on layout.\n * @param {number} [options.skipBlanks=-1] Threshold to skip tile generation. Range is 0-255 for 8-bit images, 0-65535 for 16-bit images. Default is 5 for `google` layout, -1 (no skip) otherwise.\n * @param {string} [options.container='fs'] tile container, with value `fs` (filesystem) or `zip` (compressed file).\n * @param {string} [options.layout='dz'] filesystem layout, possible values are `dz`, `iiif`, `iiif3`, `zoomify` or `google`.\n * @param {boolean} [options.centre=false] centre image in tile.\n * @param {boolean} [options.center=false] alternative spelling of centre.\n * @param {string} [options.id='https://example.com/iiif'] when `layout` is `iiif`/`iiif3`, sets the `@id`/`id` attribute of `info.json`\n * @param {string} [options.basename] the name of the directory within the zip file when container is `zip`.\n * @returns {Sharp}\n * @throws {Error} Invalid parameters\n */\nfunction tile (options) {\n if (is.object(options)) {\n // Size of square tiles, in pixels\n if (is.defined(options.size)) {\n if (is.integer(options.size) && is.inRange(options.size, 1, 8192)) {\n this.options.tileSize = options.size;\n } else {\n throw is.invalidParameterError('size', 'integer between 1 and 8192', options.size);\n }\n }\n // Overlap of tiles, in pixels\n if (is.defined(options.overlap)) {\n if (is.integer(options.overlap) && is.inRange(options.overlap, 0, 8192)) {\n if (options.overlap > this.options.tileSize) {\n throw is.invalidParameterError('overlap', `<= size (${this.options.tileSize})`, options.overlap);\n }\n this.options.tileOverlap = options.overlap;\n } else {\n throw is.invalidParameterError('overlap', 'integer between 0 and 8192', options.overlap);\n }\n }\n // Container\n if (is.defined(options.container)) {\n if (is.string(options.container) && is.inArray(options.container, ['fs', 'zip'])) {\n this.options.tileContainer = options.container;\n } else {\n throw is.invalidParameterError('container', 'one of: fs, zip', options.container);\n }\n }\n // Layout\n if (is.defined(options.layout)) {\n if (is.string(options.layout) && is.inArray(options.layout, ['dz', 'google', 'iiif', 'iiif3', 'zoomify'])) {\n this.options.tileLayout = options.layout;\n } else {\n throw is.invalidParameterError('layout', 'one of: dz, google, iiif, iiif3, zoomify', options.layout);\n }\n }\n // Angle of rotation,\n if (is.defined(options.angle)) {\n if (is.integer(options.angle) && !(options.angle % 90)) {\n this.options.tileAngle = options.angle;\n } else {\n throw is.invalidParameterError('angle', 'positive/negative multiple of 90', options.angle);\n }\n }\n // Background colour\n this._setBackgroundColourOption('tileBackground', options.background);\n // Depth of tiles\n if (is.defined(options.depth)) {\n if (is.string(options.depth) && is.inArray(options.depth, ['onepixel', 'onetile', 'one'])) {\n this.options.tileDepth = options.depth;\n } else {\n throw is.invalidParameterError('depth', 'one of: onepixel, onetile, one', options.depth);\n }\n }\n // Threshold to skip blank tiles\n if (is.defined(options.skipBlanks)) {\n if (is.integer(options.skipBlanks) && is.inRange(options.skipBlanks, -1, 65535)) {\n this.options.tileSkipBlanks = options.skipBlanks;\n } else {\n throw is.invalidParameterError('skipBlanks', 'integer between -1 and 255/65535', options.skipBlanks);\n }\n } else if (is.defined(options.layout) && options.layout === 'google') {\n this.options.tileSkipBlanks = 5;\n }\n // Center image in tile\n const centre = is.bool(options.center) ? options.center : options.centre;\n if (is.defined(centre)) {\n this._setBooleanOption('tileCentre', centre);\n }\n // @id attribute for IIIF layout\n if (is.defined(options.id)) {\n if (is.string(options.id)) {\n this.options.tileId = options.id;\n } else {\n throw is.invalidParameterError('id', 'string', options.id);\n }\n }\n // Basename for zip container\n if (is.defined(options.basename)) {\n if (is.string(options.basename)) {\n this.options.tileBasename = options.basename;\n } else {\n throw is.invalidParameterError('basename', 'string', options.basename);\n }\n }\n }\n // Format\n if (is.inArray(this.options.formatOut, ['jpeg', 'png', 'webp'])) {\n this.options.tileFormat = this.options.formatOut;\n } else if (this.options.formatOut !== 'input') {\n throw is.invalidParameterError('format', 'one of: jpeg, png, webp', this.options.formatOut);\n }\n return this._updateFormatOut('dz');\n}\n\n/**\n * Set a timeout for processing, in seconds.\n * Use a value of zero to continue processing indefinitely, the default behaviour.\n *\n * The clock starts when libvips opens an input image for processing.\n * Time spent waiting for a libuv thread to become available is not included.\n *\n * @example\n * // Ensure processing takes no longer than 3 seconds\n * try {\n * const data = await sharp(input)\n * .blur(1000)\n * .timeout({ seconds: 3 })\n * .toBuffer();\n * } catch (err) {\n * if (err.message.includes('timeout')) { ... }\n * }\n *\n * @since 0.29.2\n *\n * @param {Object} options\n * @param {number} options.seconds - Number of seconds after which processing will be stopped\n * @returns {Sharp}\n */\nfunction timeout (options) {\n if (!is.plainObject(options)) {\n throw is.invalidParameterError('options', 'object', options);\n }\n if (is.integer(options.seconds) && is.inRange(options.seconds, 0, 3600)) {\n this.options.timeoutSeconds = options.seconds;\n } else {\n throw is.invalidParameterError('seconds', 'integer between 0 and 3600', options.seconds);\n }\n return this;\n}\n\n/**\n * Update the output format unless options.force is false,\n * in which case revert to input format.\n * @private\n * @param {string} formatOut\n * @param {Object} [options]\n * @param {boolean} [options.force=true] - force output format, otherwise attempt to use input format\n * @returns {Sharp}\n */\nfunction _updateFormatOut (formatOut, options) {\n if (!(is.object(options) && options.force === false)) {\n this.options.formatOut = formatOut;\n }\n return this;\n}\n\n/**\n * Update a boolean attribute of the this.options Object.\n * @private\n * @param {string} key\n * @param {boolean} val\n * @throws {Error} Invalid key\n */\nfunction _setBooleanOption (key, val) {\n if (is.bool(val)) {\n this.options[key] = val;\n } else {\n throw is.invalidParameterError(key, 'boolean', val);\n }\n}\n\n/**\n * Called by a WriteableStream to notify us it is ready for data.\n * @private\n */\nfunction _read () {\n if (!this.options.streamOut) {\n this.options.streamOut = true;\n const stack = Error();\n this._pipeline(undefined, stack);\n }\n}\n\n/**\n * Invoke the C++ image processing pipeline\n * Supports callback, stream and promise variants\n * @private\n */\nfunction _pipeline (callback, stack) {\n if (typeof callback === 'function') {\n // output=file/buffer\n if (this._isStreamInput()) {\n // output=file/buffer, input=stream\n this.on('finish', () => {\n this._flattenBufferIn();\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, data, info);\n }\n });\n });\n } else {\n // output=file/buffer, input=file/buffer\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n callback(is.nativeError(err, stack));\n } else {\n callback(null, data, info);\n }\n });\n }\n return this;\n } else if (this.options.streamOut) {\n // output=stream\n if (this._isStreamInput()) {\n // output=stream, input=stream\n this.once('finish', () => {\n this._flattenBufferIn();\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n this.emit('error', is.nativeError(err, stack));\n } else {\n this.emit('info', info);\n this.push(data);\n }\n this.push(null);\n this.on('end', () => this.emit('close'));\n });\n });\n if (this.streamInFinished) {\n this.emit('finish');\n }\n } else {\n // output=stream, input=file/buffer\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n this.emit('error', is.nativeError(err, stack));\n } else {\n this.emit('info', info);\n this.push(data);\n }\n this.push(null);\n this.on('end', () => this.emit('close'));\n });\n }\n return this;\n } else {\n // output=promise\n if (this._isStreamInput()) {\n // output=promise, input=stream\n return new Promise((resolve, reject) => {\n this.once('finish', () => {\n this._flattenBufferIn();\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n if (this.options.resolveWithObject) {\n resolve({ data, info });\n } else {\n resolve(data);\n }\n }\n });\n });\n });\n } else {\n // output=promise, input=file/buffer\n return new Promise((resolve, reject) => {\n sharp.pipeline(this.options, (err, data, info) => {\n if (err) {\n reject(is.nativeError(err, stack));\n } else {\n if (this.options.resolveWithObject) {\n resolve({ data, info });\n } else {\n resolve(data);\n }\n }\n });\n });\n }\n }\n}\n\n/**\n * Decorate the Sharp prototype with output-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Object.assign(Sharp.prototype, {\n // Public\n toFile,\n toBuffer,\n keepExif,\n withExif,\n withExifMerge,\n keepIccProfile,\n withIccProfile,\n keepXmp,\n withXmp,\n keepMetadata,\n withMetadata,\n toFormat,\n jpeg,\n jp2,\n png,\n webp,\n tiff,\n avif,\n heif,\n jxl,\n gif,\n raw,\n tile,\n timeout,\n // Private\n _updateFormatOut,\n _setBooleanOption,\n _read,\n _pipeline\n });\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst events = require('node:events');\nconst detectLibc = require('detect-libc');\n\nconst is = require('./is');\nconst { runtimePlatformArch } = require('./libvips');\nconst sharp = require('./sharp');\n\nconst runtimePlatform = runtimePlatformArch();\nconst libvipsVersion = sharp.libvipsVersion();\n\n/**\n * An Object containing nested boolean values representing the available input and output formats/methods.\n * @member\n * @example\n * console.log(sharp.format);\n * @returns {Object}\n */\nconst format = sharp.format();\nformat.heif.output.alias = ['avif', 'heic'];\nformat.jpeg.output.alias = ['jpe', 'jpg'];\nformat.tiff.output.alias = ['tif'];\nformat.jp2k.output.alias = ['j2c', 'j2k', 'jp2', 'jpx'];\n\n/**\n * An Object containing the available interpolators and their proper values\n * @readonly\n * @enum {string}\n */\nconst interpolators = {\n /** [Nearest neighbour interpolation](http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation). Suitable for image enlargement only. */\n nearest: 'nearest',\n /** [Bilinear interpolation](http://en.wikipedia.org/wiki/Bilinear_interpolation). Faster than bicubic but with less smooth results. */\n bilinear: 'bilinear',\n /** [Bicubic interpolation](http://en.wikipedia.org/wiki/Bicubic_interpolation) (the default). */\n bicubic: 'bicubic',\n /** [LBB interpolation](https://github.com/libvips/libvips/blob/master/libvips/resample/lbb.cpp#L100). Prevents some \"[acutance](http://en.wikipedia.org/wiki/Acutance)\" but typically reduces performance by a factor of 2. */\n locallyBoundedBicubic: 'lbb',\n /** [Nohalo interpolation](http://eprints.soton.ac.uk/268086/). Prevents acutance but typically reduces performance by a factor of 3. */\n nohalo: 'nohalo',\n /** [VSQBS interpolation](https://github.com/libvips/libvips/blob/master/libvips/resample/vsqbs.cpp#L48). Prevents \"staircasing\" when enlarging. */\n vertexSplitQuadraticBasisSpline: 'vsqbs'\n};\n\n/**\n * An Object containing the version numbers of sharp, libvips\n * and (when using prebuilt binaries) its dependencies.\n *\n * @member\n * @example\n * console.log(sharp.versions);\n */\nlet versions = {\n vips: libvipsVersion.semver\n};\n/* node:coverage ignore next 15 */\nif (!libvipsVersion.isGlobal) {\n if (!libvipsVersion.isWasm) {\n try {\n versions = require(`@img/sharp-${runtimePlatform}/versions`);\n } catch (_) {\n try {\n versions = require(`@img/sharp-libvips-${runtimePlatform}/versions`);\n } catch (_) {}\n }\n } else {\n try {\n versions = require('@img/sharp-wasm32/versions');\n } catch (_) {}\n }\n}\nversions.sharp = require('../package.json').version;\n\n/* node:coverage ignore next 5 */\nif (versions.heif && format.heif) {\n // Prebuilt binaries provide AV1\n format.heif.input.fileSuffix = ['.avif'];\n format.heif.output.alias = ['avif'];\n}\n\n/**\n * Gets or, when options are provided, sets the limits of _libvips'_ operation cache.\n * Existing entries in the cache will be trimmed after any change in limits.\n * This method always returns cache statistics,\n * useful for determining how much working memory is required for a particular task.\n *\n * @example\n * const stats = sharp.cache();\n * @example\n * sharp.cache( { items: 200 } );\n * sharp.cache( { files: 0 } );\n * sharp.cache(false);\n *\n * @param {Object|boolean} [options=true] - Object with the following attributes, or boolean where true uses default cache settings and false removes all caching\n * @param {number} [options.memory=50] - is the maximum memory in MB to use for this cache\n * @param {number} [options.files=20] - is the maximum number of files to hold open\n * @param {number} [options.items=100] - is the maximum number of operations to cache\n * @returns {Object}\n */\nfunction cache (options) {\n if (is.bool(options)) {\n if (options) {\n // Default cache settings of 50MB, 20 files, 100 items\n return sharp.cache(50, 20, 100);\n } else {\n return sharp.cache(0, 0, 0);\n }\n } else if (is.object(options)) {\n return sharp.cache(options.memory, options.files, options.items);\n } else {\n return sharp.cache();\n }\n}\ncache(true);\n\n/**\n * Gets or, when a concurrency is provided, sets\n * the maximum number of threads _libvips_ should use to process _each image_.\n * These are from a thread pool managed by glib,\n * which helps avoid the overhead of creating new threads.\n *\n * This method always returns the current concurrency.\n *\n * The default value is the number of CPU cores,\n * except when using glibc-based Linux without jemalloc,\n * where the default is `1` to help reduce memory fragmentation.\n *\n * A value of `0` will reset this to the number of CPU cores.\n *\n * Some image format libraries spawn additional threads,\n * e.g. libaom manages its own 4 threads when encoding AVIF images,\n * and these are independent of the value set here.\n *\n * :::note\n * Further {@link /performance/ control over performance} is available.\n * :::\n *\n * @example\n * const threads = sharp.concurrency(); // 4\n * sharp.concurrency(2); // 2\n * sharp.concurrency(0); // 4\n *\n * @param {number} [concurrency]\n * @returns {number} concurrency\n */\nfunction concurrency (concurrency) {\n return sharp.concurrency(is.integer(concurrency) ? concurrency : null);\n}\n/* node:coverage ignore next 7 */\nif (detectLibc.familySync() === detectLibc.GLIBC && !sharp._isUsingJemalloc()) {\n // Reduce default concurrency to 1 when using glibc memory allocator\n sharp.concurrency(1);\n} else if (detectLibc.familySync() === detectLibc.MUSL && sharp.concurrency() === 1024) {\n // Reduce default concurrency when musl thread over-subscription detected\n sharp.concurrency(require('node:os').availableParallelism());\n}\n\n/**\n * An EventEmitter that emits a `change` event when a task is either:\n * - queued, waiting for _libuv_ to provide a worker thread\n * - complete\n * @member\n * @example\n * sharp.queue.on('change', function(queueLength) {\n * console.log('Queue contains ' + queueLength + ' task(s)');\n * });\n */\nconst queue = new events.EventEmitter();\n\n/**\n * Provides access to internal task counters.\n * - queue is the number of tasks this module has queued waiting for _libuv_ to provide a worker thread from its pool.\n * - process is the number of resize tasks currently being processed.\n *\n * @example\n * const counters = sharp.counters(); // { queue: 2, process: 4 }\n *\n * @returns {Object}\n */\nfunction counters () {\n return sharp.counters();\n}\n\n/**\n * Get and set use of SIMD vector unit instructions.\n * Requires libvips to have been compiled with highway support.\n *\n * Improves the performance of `resize`, `blur` and `sharpen` operations\n * by taking advantage of the SIMD vector unit of the CPU, e.g. Intel SSE and ARM NEON.\n *\n * @example\n * const simd = sharp.simd();\n * // simd is `true` if the runtime use of highway is currently enabled\n * @example\n * const simd = sharp.simd(false);\n * // prevent libvips from using highway at runtime\n *\n * @param {boolean} [simd=true]\n * @returns {boolean}\n */\nfunction simd (simd) {\n return sharp.simd(is.bool(simd) ? simd : null);\n}\n\n/**\n * Block libvips operations at runtime.\n *\n * This is in addition to the `VIPS_BLOCK_UNTRUSTED` environment variable,\n * which when set will block all \"untrusted\" operations.\n *\n * @since 0.32.4\n *\n * @example <caption>Block all TIFF input.</caption>\n * sharp.block({\n * operation: ['VipsForeignLoadTiff']\n * });\n *\n * @param {Object} options\n * @param {Array<string>} options.operation - List of libvips low-level operation names to block.\n */\nfunction block (options) {\n if (is.object(options)) {\n if (Array.isArray(options.operation) && options.operation.every(is.string)) {\n sharp.block(options.operation, true);\n } else {\n throw is.invalidParameterError('operation', 'Array<string>', options.operation);\n }\n } else {\n throw is.invalidParameterError('options', 'object', options);\n }\n}\n\n/**\n * Unblock libvips operations at runtime.\n *\n * This is useful for defining a list of allowed operations.\n *\n * @since 0.32.4\n *\n * @example <caption>Block all input except WebP from the filesystem.</caption>\n * sharp.block({\n * operation: ['VipsForeignLoad']\n * });\n * sharp.unblock({\n * operation: ['VipsForeignLoadWebpFile']\n * });\n *\n * @example <caption>Block all input except JPEG and PNG from a Buffer or Stream.</caption>\n * sharp.block({\n * operation: ['VipsForeignLoad']\n * });\n * sharp.unblock({\n * operation: ['VipsForeignLoadJpegBuffer', 'VipsForeignLoadPngBuffer']\n * });\n *\n * @param {Object} options\n * @param {Array<string>} options.operation - List of libvips low-level operation names to unblock.\n */\nfunction unblock (options) {\n if (is.object(options)) {\n if (Array.isArray(options.operation) && options.operation.every(is.string)) {\n sharp.block(options.operation, false);\n } else {\n throw is.invalidParameterError('operation', 'Array<string>', options.operation);\n }\n } else {\n throw is.invalidParameterError('options', 'object', options);\n }\n}\n\n/**\n * Decorate the Sharp class with utility-related functions.\n * @module Sharp\n * @private\n */\nmodule.exports = (Sharp) => {\n Sharp.cache = cache;\n Sharp.concurrency = concurrency;\n Sharp.counters = counters;\n Sharp.simd = simd;\n Sharp.format = format;\n Sharp.interpolators = interpolators;\n Sharp.versions = versions;\n Sharp.queue = queue;\n Sharp.block = block;\n Sharp.unblock = unblock;\n};\n", "/*!\n Copyright 2013 Lovell Fuller and others.\n SPDX-License-Identifier: Apache-2.0\n*/\n\nconst Sharp = require('./constructor');\nrequire('./input')(Sharp);\nrequire('./resize')(Sharp);\nrequire('./composite')(Sharp);\nrequire('./operation')(Sharp);\nrequire('./colour')(Sharp);\nrequire('./channel')(Sharp);\nrequire('./output')(Sharp);\nrequire('./utility')(Sharp);\n\nmodule.exports = Sharp;\n", "export type {\n BuiltInPaletteAlgorithm,\n InputType,\n PaletteAlgorithm,\n PaletteGenerator,\n PaletteGeneratorInput,\n PaletteOptions,\n PaletteResult,\n} from './core';\nexport {\n detectInputType,\n generatePalette,\n generatePaletteFromHex,\n generatePaletteFromDataUri,\n generatePaletteFromUrl,\n generatePaletteFromPath,\n getAlgorithm,\n listAlgorithms,\n registerAlgorithm,\n unregisterAlgorithm,\n} from './core';\nexport { getGameBoyPalette } from './presets';\nexport type { RgbaColor } from './presets';\n", "import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport sharp from 'sharp';\nimport {\n Hct,\n QuantizerCelebi,\n Score,\n TonalPalette,\n argbFromRgb,\n hexFromArgb,\n} from '@material/material-color-utilities';\n\n/**\n * Supported input types for palette generation.\n */\nexport type InputType = 'hex' | 'datauri' | 'url' | 'path';\n\n/**\n * Built-in palette algorithms.\n */\nexport type BuiltInPaletteAlgorithm =\n | 'analogous'\n | 'complementary'\n | 'triadic'\n | 'tetradic'\n | 'split-complementary'\n | 'monochrome'\n | 'monet'\n | 'dominant';\n\n/**\n * Palette algorithm name, including custom algorithms.\n */\nexport type PaletteAlgorithm = BuiltInPaletteAlgorithm | (string & { __paletteAlgorithm?: never });\n\n/**\n * Input for palette generators.\n */\nexport interface PaletteGeneratorInput {\n inputType: InputType;\n baseColor: string;\n baseRgb: RgbColor;\n baseHsl: HslColor;\n count?: number;\n buffer?: Buffer;\n}\n\n/**\n * Palette generator contract.\n */\nexport type PaletteGenerator = (\n input: PaletteGeneratorInput\n) => Promise<string[]> | string[];\n\n/**\n * Options used when generating palettes.\n */\nexport interface PaletteOptions {\n /**\n * Palette algorithm to apply.\n */\n algorithm?: PaletteAlgorithm;\n /**\n * Palette size hint.\n */\n count?: number;\n}\n\n/**\n * Palette generation result.\n */\nexport interface PaletteResult {\n /**\n * Detected input type.\n */\n inputType: InputType;\n /**\n * Algorithm used for palette generation.\n */\n algorithm: PaletteAlgorithm;\n /**\n * Base color extracted from input.\n */\n baseColor: string;\n /**\n * Generated palette colors in HEX.\n */\n colors: string[];\n}\n\ninterface RgbColor {\n r: number;\n g: number;\n b: number;\n}\n\ninterface HslColor {\n h: number;\n s: number;\n l: number;\n}\n\nconst DEFAULT_ALGORITHM: BuiltInPaletteAlgorithm = 'analogous';\n\nconst algorithmRegistry = new Map<string, PaletteGenerator>();\nlet builtInsRegistered = false;\n\n/**\n * Registers a custom palette algorithm.\n */\nexport function registerAlgorithm(name: string, generator: PaletteGenerator): void {\n if (!name.trim()) {\n throw new Error('Algorithm name is required');\n }\n algorithmRegistry.set(name, generator);\n}\n\n/**\n * Unregisters a palette algorithm.\n */\nexport function unregisterAlgorithm(name: string): boolean {\n return algorithmRegistry.delete(name);\n}\n\n/**\n * Returns a registered algorithm by name.\n */\nexport function getAlgorithm(name: string): PaletteGenerator | undefined {\n return algorithmRegistry.get(name);\n}\n\n/**\n * Returns the list of supported palette algorithms.\n */\nexport function listAlgorithms(): PaletteAlgorithm[] {\n return Array.from(algorithmRegistry.keys()).sort();\n}\n\n/**\n * Detects the input type from the raw string.\n * @param input The raw input string.\n */\nexport function detectInputType(input: string): InputType {\n const trimmed = input.trim();\n if (isHex(trimmed)) return 'hex';\n if (isDataUri(trimmed)) return 'datauri';\n if (isUrl(trimmed)) return 'url';\n return 'path';\n}\n\n/**\n * Generates a palette by automatically detecting the input type.\n * @param input The input string.\n * @param options Optional palette options.\n */\nexport async function generatePalette(\n input: string,\n options: PaletteOptions = {}\n): Promise<PaletteResult> {\n const type = detectInputType(input);\n if (type === 'hex') return generatePaletteFromHex(input, options);\n if (type === 'datauri') return generatePaletteFromDataUri(input, options);\n if (type === 'url') return generatePaletteFromUrl(input, options);\n return generatePaletteFromPath(input, options);\n}\n\n/**\n * Generates a palette from a HEX color string.\n * @param hex The HEX string, with or without leading #.\n * @param options Optional palette options.\n */\nexport async function generatePaletteFromHex(\n hex: string,\n options: PaletteOptions = {}\n): Promise<PaletteResult> {\n const normalizedHex = normalizeHex(hex);\n const baseRgb = hexToRgb(normalizedHex);\n return buildPaletteResultFromBase(baseRgb, 'hex', options.algorithm, options.count);\n}\n\n/**\n * Generates a palette from an image data URI.\n * @param dataUri The image data URI.\n * @param options Optional palette options.\n */\nexport async function generatePaletteFromDataUri(\n dataUri: string,\n options: PaletteOptions = {}\n): Promise<PaletteResult> {\n const buffer = decodeDataUri(dataUri);\n return buildPaletteResultFromBuffer(buffer, 'datauri', options.algorithm, options.count);\n}\n\n/**\n * Generates a palette from an image URL.\n * @param url The image URL.\n * @param options Optional palette options.\n */\nexport async function generatePaletteFromUrl(\n url: string,\n options: PaletteOptions = {}\n): Promise<PaletteResult> {\n const buffer = await fetchBuffer(url);\n return buildPaletteResultFromBuffer(buffer, 'url', options.algorithm, options.count);\n}\n\n/**\n * Generates a palette from an image file path.\n * @param filePath The file path to the image.\n * @param options Optional palette options.\n */\nexport async function generatePaletteFromPath(\n filePath: string,\n options: PaletteOptions = {}\n): Promise<PaletteResult> {\n const resolved = path.resolve(filePath);\n const buffer = await fs.readFile(resolved);\n return buildPaletteResultFromBuffer(buffer, 'path', options.algorithm, options.count);\n}\n\n/**\n * Builds a palette result from an image buffer.\n * @param buffer The image buffer.\n * @param inputType The detected input type.\n * @param algorithm Optional algorithm override.\n * @param count Optional palette size.\n */\nasync function buildPaletteResultFromBuffer(\n buffer: Buffer,\n inputType: InputType,\n algorithm?: PaletteAlgorithm,\n count?: number\n): Promise<PaletteResult> {\n const resolvedAlgorithm = resolveAlgorithm(algorithm);\n const baseRgb = await getAverageColor(buffer);\n const baseHex = rgbToHex(baseRgb);\n return buildPaletteResult(\n {\n inputType,\n baseColor: baseHex,\n baseRgb,\n baseHsl: rgbToHsl(baseRgb),\n count,\n buffer,\n },\n resolvedAlgorithm\n );\n}\n\n/**\n * Builds a palette result from a base color.\n * @param baseRgb The base RGB color.\n * @param inputType The detected input type.\n * @param algorithm Optional algorithm override.\n * @param count Optional palette size.\n */\nasync function buildPaletteResultFromBase(\n baseRgb: RgbColor,\n inputType: InputType,\n algorithm?: PaletteAlgorithm,\n count?: number\n): Promise<PaletteResult> {\n const resolvedAlgorithm = resolveAlgorithm(algorithm);\n const baseHex = rgbToHex(baseRgb);\n return buildPaletteResult(\n {\n inputType,\n baseColor: baseHex,\n baseRgb,\n baseHsl: rgbToHsl(baseRgb),\n count,\n },\n resolvedAlgorithm\n );\n}\n\n/**\n * Resolves an algorithm, applying defaults and validation.\n * @param algorithm Optional algorithm override.\n */\nfunction resolveAlgorithm(algorithm: PaletteAlgorithm | undefined): PaletteAlgorithm {\n const resolved = algorithm ?? DEFAULT_ALGORITHM;\n if (!algorithmRegistry.has(resolved)) {\n throw new Error(`Unknown algorithm: ${resolved}`);\n }\n return resolved;\n}\n\n/**\n * Builds a palette in HSL space.\n * @param base The base HSL color.\n * @param algorithm The algorithm to apply.\n * @param count Optional palette size.\n */\nfunction buildPaletteHsl(base: HslColor, algorithm: PaletteAlgorithm, count?: number): HslColor[] {\n const hue = normalizeHue(base.h);\n const sat = clamp(base.s, 20, 90);\n const light = clamp(base.l, 20, 80);\n\n if (algorithm === 'analogous') {\n return buildByOffsets(hue, sat, light, resolveCount(count, 5), 40);\n }\n\n if (algorithm === 'complementary') {\n return buildByCycle(hue, sat, light, resolveCount(count, 3), [0, 180], 14);\n }\n\n if (algorithm === 'triadic') {\n return buildByCycle(hue, sat, light, resolveCount(count, 3), [0, 120, 240], 10);\n }\n\n if (algorithm === 'tetradic') {\n return buildByCycle(hue, sat, light, resolveCount(count, 4), [0, 90, 180, 270], 8);\n }\n\n if (algorithm === 'split-complementary') {\n return buildByCycle(hue, sat, light, resolveCount(count, 3), [0, 150, 210], 10);\n }\n\n if (algorithm === 'monochrome') {\n return buildMonochrome(hue, sat, light, resolveCount(count, 4));\n }\n\n return buildMonochrome(hue, sat, light, resolveCount(count, 6));\n}\n\nfunction buildHslPaletteColors(\n input: PaletteGeneratorInput,\n algorithm: BuiltInPaletteAlgorithm\n): string[] {\n const paletteHsl = buildPaletteHsl(input.baseHsl, algorithm, input.count);\n return paletteHsl.map((color) => rgbToHex(hslToRgb(color)));\n}\n\nfunction registerBuiltInAlgorithms(): void {\n if (builtInsRegistered) return;\n builtInsRegistered = true;\n registerAlgorithm('analogous', (input) => buildHslPaletteColors(input, 'analogous'));\n registerAlgorithm('complementary', (input) => buildHslPaletteColors(input, 'complementary'));\n registerAlgorithm('triadic', (input) => buildHslPaletteColors(input, 'triadic'));\n registerAlgorithm('tetradic', (input) => buildHslPaletteColors(input, 'tetradic'));\n registerAlgorithm('split-complementary', (input) =>\n buildHslPaletteColors(input, 'split-complementary')\n );\n registerAlgorithm('monochrome', (input) => buildHslPaletteColors(input, 'monochrome'));\n registerAlgorithm('monet', async (input) => {\n if (input.buffer) {\n const colors = await extractMonetPalette(input.buffer, resolveMonetCount(input.count, 6));\n if (colors.length > 0) {\n return colors;\n }\n }\n const sourceArgb = argbFromHex(input.baseColor);\n return buildMonetPaletteFromSourceArgb(sourceArgb, resolveMonetCount(input.count, 6));\n });\n registerAlgorithm('dominant', async (input) => {\n if (input.buffer) {\n const colors = await extractDominantPalette(input.buffer, resolveCount(input.count, 8));\n if (colors.length > 0) {\n return colors;\n }\n }\n return buildHslPaletteColors(input, 'monochrome');\n });\n}\n\nregisterBuiltInAlgorithms();\n\nasync function buildPaletteResult(\n input: PaletteGeneratorInput,\n algorithm: PaletteAlgorithm\n): Promise<PaletteResult> {\n const generator = getAlgorithm(algorithm);\n if (!generator) {\n throw new Error(`Unknown algorithm: ${algorithm}`);\n }\n const colors = await generator(input);\n return {\n inputType: input.inputType,\n algorithm,\n baseColor: input.baseColor,\n colors,\n };\n}\n\n/**\n * Checks whether a string is a valid HEX color.\n * @param value The string to validate.\n */\nfunction isHex(value: string): boolean {\n return /^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(value);\n}\n\n/**\n * Checks whether a string is an image data URI.\n * @param value The string to validate.\n */\nfunction isDataUri(value: string): boolean {\n return /^data:image\\/[a-z0-9.+-]+;base64,/i.test(value);\n}\n\n/**\n * Checks whether a string is an HTTP(S) URL.\n * @param value The string to validate.\n */\nfunction isUrl(value: string): boolean {\n return /^https?:\\/\\//i.test(value);\n}\n\n/**\n * Normalizes HEX input to #RRGGBB format.\n * @param value The HEX string.\n */\nfunction normalizeHex(value: string): string {\n const raw = value.trim();\n if (!isHex(raw)) throw new Error(`Invalid HEX color: ${value}`);\n const cleaned = raw.startsWith('#') ? raw.slice(1) : raw;\n if (cleaned.length === 3) {\n const expanded = cleaned\n .split('')\n .map((char) => char + char)\n .join('');\n return `#${expanded.toUpperCase()}`;\n }\n return `#${cleaned.toUpperCase()}`;\n}\n\nfunction argbFromHex(hex: string): number {\n const clean = normalizeHex(hex).slice(1);\n const r = parseInt(clean.slice(0, 2), 16);\n const g = parseInt(clean.slice(2, 4), 16);\n const b = parseInt(clean.slice(4, 6), 16);\n return argbFromRgb(r, g, b);\n}\n\n/**\n * Converts HEX to RGB.\n * @param hex The HEX color string.\n */\nfunction hexToRgb(hex: string): RgbColor {\n const clean = normalizeHex(hex).slice(1);\n const r = parseInt(clean.slice(0, 2), 16);\n const g = parseInt(clean.slice(2, 4), 16);\n const b = parseInt(clean.slice(4, 6), 16);\n return { r, g, b };\n}\n\n/**\n * Converts RGB to HEX.\n * @param color The RGB color.\n */\nfunction rgbToHex(color: RgbColor): string {\n const toHex = (value: number) =>\n Math.round(clamp(value, 0, 255))\n .toString(16)\n .padStart(2, '0')\n .toUpperCase();\n return `#${toHex(color.r)}${toHex(color.g)}${toHex(color.b)}`;\n}\n\n/**\n * Converts RGB to HSL.\n * @param color The RGB color.\n */\nfunction rgbToHsl(color: RgbColor): HslColor {\n const r = color.r / 255;\n const g = color.g / 255;\n const b = color.b / 255;\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const delta = max - min;\n let h = 0;\n if (delta !== 0) {\n if (max === r) h = ((g - b) / delta) % 6;\n else if (max === g) h = (b - r) / delta + 2;\n else h = (r - g) / delta + 4;\n h *= 60;\n }\n if (h < 0) h += 360;\n const l = (max + min) / 2;\n const s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));\n return { h, s: s * 100, l: l * 100 };\n}\n\n/**\n * Converts HSL to RGB.\n * @param color The HSL color.\n */\nfunction hslToRgb(color: HslColor): RgbColor {\n const h = normalizeHue(color.h);\n const s = clamp(color.s, 0, 100) / 100;\n const l = clamp(color.l, 0, 100) / 100;\n const c = (1 - Math.abs(2 * l - 1)) * s;\n const x = c * (1 - Math.abs(((h / 60) % 2) - 1));\n const m = l - c / 2;\n let r = 0;\n let g = 0;\n let b = 0;\n if (h >= 0 && h < 60) {\n r = c;\n g = x;\n } else if (h < 120) {\n r = x;\n g = c;\n } else if (h < 180) {\n g = c;\n b = x;\n } else if (h < 240) {\n g = x;\n b = c;\n } else if (h < 300) {\n r = x;\n b = c;\n } else {\n r = c;\n b = x;\n }\n return {\n r: (r + m) * 255,\n g: (g + m) * 255,\n b: (b + m) * 255,\n };\n}\n\n/**\n * Computes the average color of an image buffer.\n * @param buffer The image buffer.\n */\nasync function getAverageColor(buffer: Buffer): Promise<RgbColor> {\n const stats = await sharp(buffer).stats();\n const channels = stats.channels;\n return {\n r: channels[0]?.mean ?? 0,\n g: channels[1]?.mean ?? 0,\n b: channels[2]?.mean ?? 0,\n };\n}\n\n/**\n * Extracts a Monet-style palette from an image buffer.\n * @param buffer The image buffer.\n * @param count The number of colors to return.\n */\nasync function extractMonetPalette(buffer: Buffer, count: number): Promise<string[]> {\n const { data, info } = await sharp(buffer)\n .resize({ width: 48, height: 48, fit: 'inside' })\n .removeAlpha()\n .raw()\n .toBuffer({ resolveWithObject: true });\n const pixels: number[] = [];\n const step = info.channels;\n for (let i = 0; i < data.length; i += step) {\n const r = data[i] ?? 0;\n const g = data[i + 1] ?? 0;\n const b = data[i + 2] ?? 0;\n pixels.push(argbFromRgb(r, g, b));\n }\n if (pixels.length === 0) return [];\n const sampled = downsamplePixels(pixels, 1200);\n const quantized = QuantizerCelebi.quantize(sampled, 128);\n const ranked = Score.score(quantized);\n const sourceArgb = ranked[0] ?? sampled[0];\n return buildMonetPaletteFromSourceArgb(sourceArgb, count);\n}\n\nasync function extractDominantPalette(buffer: Buffer, count: number): Promise<string[]> {\n const { data, info } = await sharp(buffer)\n .resize({ width: 96, height: 96, fit: 'inside' })\n .removeAlpha()\n .raw()\n .toBuffer({ resolveWithObject: true });\n const step = info.channels;\n const pixels: number[] = [];\n for (let i = 0; i < data.length; i += step) {\n const r = data[i] ?? 0;\n const g = data[i + 1] ?? 0;\n const b = data[i + 2] ?? 0;\n pixels.push(argbFromRgb(r, g, b));\n }\n if (pixels.length === 0) return [];\n const sampled = downsamplePixels(pixels, 2400);\n const quantized = QuantizerCelebi.quantize(sampled, 128);\n const entries = Array.from(quantized.entries()).map(([argb, population]) => ({\n rgb: argbToRgb(argb),\n count: population,\n }));\n if (entries.length === 0) return [];\n entries.sort((a, b) => {\n const countDelta = b.count - a.count;\n if (countDelta !== 0) return countDelta;\n return rgbKey(a.rgb) - rgbKey(b.rgb);\n });\n const totalCount = entries.reduce((sum, entry) => sum + entry.count, 0);\n const coverageTarget = 0.95;\n const candidateEntries: typeof entries = [];\n let coverage = 0;\n for (const entry of entries) {\n if (candidateEntries.length >= count) {\n candidateEntries.push(entry);\n continue;\n }\n candidateEntries.push(entry);\n coverage += entry.count / Math.max(1, totalCount);\n if (coverage >= coverageTarget) {\n break;\n }\n }\n if (candidateEntries.length < count) {\n candidateEntries.splice(0, candidateEntries.length, ...entries);\n }\n if (entries.length <= count) {\n return entries.map((entry) => rgbToHex(entry.rgb));\n }\n const maxCount = Math.max(1, entries[0]?.count ?? 1);\n const seeds: RgbColor[] = [candidateEntries[0].rgb];\n while (seeds.length < count) {\n let best: (typeof entries)[number] | null = null;\n let bestScore = -1;\n for (const entry of candidateEntries) {\n if (seeds.some((seed) => rgbDistanceSq(seed, entry.rgb) === 0)) continue;\n let minDist = Number.POSITIVE_INFINITY;\n for (const seed of seeds) {\n minDist = Math.min(minDist, rgbDistanceSq(seed, entry.rgb));\n }\n const weight = entry.count / maxCount;\n const score = minDist * (0.2 + Math.sqrt(weight));\n if (\n score > bestScore + 1e-9 ||\n (Math.abs(score - bestScore) <= 1e-9 &&\n best !== null &&\n rgbKey(entry.rgb) < rgbKey(best.rgb))\n ) {\n bestScore = score;\n best = entry;\n }\n }\n if (!best) break;\n seeds.push(best.rgb);\n }\n const refined = refineCentroids(seeds, entries);\n return refined.slice(0, count).map((color) => rgbToHex(color));\n}\n\n/**\n * Resolves the palette size with bounds.\n * @param count Optional requested count.\n * @param fallback Default count.\n */\nfunction resolveCount(count: number | undefined, fallback: number): number {\n if (!count) return fallback;\n return Math.max(2, Math.min(12, Math.floor(count)));\n}\n\nfunction resolveMonetCount(count: number | undefined, fallback: number): number {\n if (!count) return fallback;\n return Math.max(1, Math.floor(count));\n}\n\n/**\n * Builds hue offsets distributed across a range.\n * @param count Number of offsets.\n * @param maxOffset Maximum absolute offset.\n */\nfunction buildOffsets(count: number, maxOffset: number): number[] {\n if (count <= 1) return [0];\n const step = (maxOffset * 2) / (count - 1);\n const offsets: number[] = [];\n for (let i = 0; i < count; i += 1) {\n offsets.push(-maxOffset + i * step);\n }\n return offsets;\n}\n\n/**\n * Builds lightness offsets distributed across a range.\n * @param count Number of offsets.\n * @param maxOffset Maximum absolute offset.\n */\nfunction buildLightOffsets(count: number, maxOffset: number): number[] {\n if (count <= 1) return [0];\n const step = (maxOffset * 2) / (count - 1);\n const offsets: number[] = [];\n for (let i = 0; i < count; i += 1) {\n offsets.push(-maxOffset + i * step);\n }\n return offsets;\n}\n\n/**\n * Builds HSL colors by evenly spaced hue offsets.\n * @param hue Base hue.\n * @param sat Base saturation.\n * @param light Base lightness.\n * @param count Number of colors.\n * @param maxOffset Maximum hue offset.\n */\nfunction buildByOffsets(\n hue: number,\n sat: number,\n light: number,\n count: number,\n maxOffset: number\n): HslColor[] {\n const offsets = buildOffsets(count, maxOffset);\n return offsets.map((offset) => ({\n h: normalizeHue(hue + offset),\n s: clamp(sat, 0, 100),\n l: clamp(light, 0, 100),\n }));\n}\n\n/**\n * Builds HSL colors by cycling hue offsets with lightness variation.\n * @param hue Base hue.\n * @param sat Base saturation.\n * @param light Base lightness.\n * @param count Number of colors.\n * @param offsets Hue offsets to cycle.\n * @param lightStep Lightness step per cycle layer.\n */\nfunction buildByCycle(\n hue: number,\n sat: number,\n light: number,\n count: number,\n offsets: number[],\n lightStep: number\n): HslColor[] {\n const result: HslColor[] = [];\n for (let i = 0; i < count; i += 1) {\n const offset = offsets[i % offsets.length] ?? 0;\n const layer = Math.floor(i / offsets.length);\n const delta = (layer % 2 === 0 ? 1 : -1) * lightStep * (layer + 1) * 0.5;\n result.push({\n h: normalizeHue(hue + offset),\n s: clamp(sat, 0, 100),\n l: clamp(light + delta, 0, 100),\n });\n }\n return result;\n}\n\n/**\n * Builds a monochrome palette by lightness offsets.\n * @param hue Base hue.\n * @param sat Base saturation.\n * @param light Base lightness.\n * @param count Number of colors.\n */\nfunction buildMonochrome(hue: number, sat: number, light: number, count: number): HslColor[] {\n const offsets = buildLightOffsets(count, 20);\n return offsets.map((offset) => ({\n h: normalizeHue(hue),\n s: clamp(sat, 0, 100),\n l: clamp(light + offset, 0, 100),\n }));\n}\n\n/**\n * Downsamples pixels to a maximum size.\n * @param pixels The pixel list.\n * @param max Maximum number of pixels.\n */\nfunction downsamplePixels(pixels: number[], max: number): number[] {\n if (pixels.length <= max) return pixels;\n const stride = Math.ceil(pixels.length / max);\n const result: number[] = [];\n for (let i = 0; i < pixels.length; i += stride) {\n result.push(pixels[i]);\n }\n return result;\n}\nfunction buildMonetPaletteFromSourceArgb(sourceArgb: number, count: number): string[] {\n const hct = Hct.fromInt(sourceArgb);\n const palette = TonalPalette.fromHct(hct);\n const tones = buildToneSteps(count);\n return tones.map((tone) => hexFromArgb(palette.tone(tone)));\n}\n\nfunction buildToneSteps(count: number): number[] {\n const base = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 98, 100];\n if (count <= base.length) {\n return base.slice(0, count);\n }\n const tones: number[] = [];\n for (let i = 0; i < count; i += 1) {\n tones.push(Math.round((100 * i) / (count - 1)));\n }\n return tones;\n}\n\n/**\n * Decodes a data URI into a buffer.\n * @param value The data URI string.\n */\nfunction decodeDataUri(value: string): Buffer {\n if (!isDataUri(value)) {\n throw new Error('Invalid data URI');\n }\n const base64 = value.split(',')[1] ?? '';\n return Buffer.from(base64, 'base64');\n}\n\n/**\n * Fetches a URL and returns the response as a buffer.\n * @param url The resource URL.\n */\nasync function fetchBuffer(url: string): Promise<Buffer> {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`Failed to fetch image: ${response.status} ${response.statusText}`);\n }\n const arrayBuffer = await response.arrayBuffer();\n return Buffer.from(arrayBuffer);\n}\n\n/**\n * Clamps a number between min and max.\n * @param value The input value.\n * @param min Minimum value.\n * @param max Maximum value.\n */\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(max, Math.max(min, value));\n}\n\nfunction rgbDistanceSq(a: RgbColor, b: RgbColor): number {\n const dr = a.r - b.r;\n const dg = a.g - b.g;\n const db = a.b - b.b;\n return dr * dr + dg * dg + db * db;\n}\n\nfunction rgbKey(color: RgbColor): number {\n return (color.r << 16) + (color.g << 8) + color.b;\n}\n\nfunction argbToRgb(argb: number): RgbColor {\n return {\n r: (argb >>> 16) & 255,\n g: (argb >>> 8) & 255,\n b: argb & 255,\n };\n}\n\nfunction refineCentroids(\n seeds: RgbColor[],\n entries: { rgb: RgbColor; count: number }[]\n): RgbColor[] {\n const accum = seeds.map(() => ({ r: 0, g: 0, b: 0, count: 0 }));\n for (const entry of entries) {\n let bestIndex = 0;\n let bestDist = Number.POSITIVE_INFINITY;\n for (let i = 0; i < seeds.length; i += 1) {\n const dist = rgbDistanceSq(seeds[i], entry.rgb);\n if (dist < bestDist) {\n bestDist = dist;\n bestIndex = i;\n }\n }\n const target = accum[bestIndex];\n target.r += entry.rgb.r * entry.count;\n target.g += entry.rgb.g * entry.count;\n target.b += entry.rgb.b * entry.count;\n target.count += entry.count;\n }\n return seeds.map((seed, index) => {\n const bucket = accum[index];\n if (!bucket || bucket.count === 0) return seed;\n return {\n r: clamp(bucket.r / bucket.count, 0, 255),\n g: clamp(bucket.g / bucket.count, 0, 255),\n b: clamp(bucket.b / bucket.count, 0, 255),\n };\n });\n}\n\n/**\n * Normalizes hue to the [0, 360) range.\n * @param hue The input hue.\n */\nfunction normalizeHue(hue: number): number {\n const normalized = hue % 360;\n return normalized < 0 ? normalized + 360 : normalized;\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// This file is automatically generated. Do not modify it.\n\n/**\n * Utility methods for mathematical operations.\n */\n\n/**\n * The signum function.\n *\n * @return 1 if num > 0, -1 if num < 0, and 0 if num = 0\n */\nexport function signum(num: number): number {\n if (num < 0) {\n return -1;\n } else if (num === 0) {\n return 0;\n } else {\n return 1;\n }\n}\n\n/**\n * The linear interpolation function.\n *\n * @return start if amount = 0 and stop if amount = 1\n */\nexport function lerp(start: number, stop: number, amount: number): number {\n return (1.0 - amount) * start + amount * stop;\n}\n\n/**\n * Clamps an integer between two integers.\n *\n * @return input when min <= input <= max, and either min or max\n * otherwise.\n */\nexport function clampInt(min: number, max: number, input: number): number {\n if (input < min) {\n return min;\n } else if (input > max) {\n return max;\n }\n\n return input;\n}\n\n/**\n * Clamps an integer between two floating-point numbers.\n *\n * @return input when min <= input <= max, and either min or max\n * otherwise.\n */\nexport function clampDouble(min: number, max: number, input: number): number {\n if (input < min) {\n return min;\n } else if (input > max) {\n return max;\n }\n\n return input;\n}\n\n/**\n * Sanitizes a degree measure as an integer.\n *\n * @return a degree measure between 0 (inclusive) and 360\n * (exclusive).\n */\nexport function sanitizeDegreesInt(degrees: number): number {\n degrees = degrees % 360;\n if (degrees < 0) {\n degrees = degrees + 360;\n }\n return degrees;\n}\n\n/**\n * Sanitizes a degree measure as a floating-point number.\n *\n * @return a degree measure between 0.0 (inclusive) and 360.0\n * (exclusive).\n */\nexport function sanitizeDegreesDouble(degrees: number): number {\n degrees = degrees % 360.0;\n if (degrees < 0) {\n degrees = degrees + 360.0;\n }\n return degrees;\n}\n\n/**\n * Sign of direction change needed to travel from one angle to\n * another.\n *\n * For angles that are 180 degrees apart from each other, both\n * directions have the same travel distance, so either direction is\n * shortest. The value 1.0 is returned in this case.\n *\n * @param from The angle travel starts from, in degrees.\n * @param to The angle travel ends at, in degrees.\n * @return -1 if decreasing from leads to the shortest travel\n * distance, 1 if increasing from leads to the shortest travel\n * distance.\n */\nexport function rotationDirection(from: number, to: number): number {\n const increasingDifference = sanitizeDegreesDouble(to - from);\n return increasingDifference <= 180.0 ? 1.0 : -1.0;\n}\n\n/**\n * Distance of two points on a circle, represented using degrees.\n */\nexport function differenceDegrees(a: number, b: number): number {\n return 180.0 - Math.abs(Math.abs(a - b) - 180.0);\n}\n\n/**\n * Multiplies a 1x3 row vector with a 3x3 matrix.\n */\nexport function matrixMultiply(row: number[], matrix: number[][]): number[] {\n const a =\n row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2];\n const b =\n row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2];\n const c =\n row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];\n return [a, b, c];\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// This file is automatically generated. Do not modify it.\n\nimport * as mathUtils from './math_utils.js';\n\n/**\n * Color science utilities.\n *\n * Utility methods for color science constants and color space\n * conversions that aren't HCT or CAM16.\n */\n\nconst SRGB_TO_XYZ = [\n [0.41233895, 0.35762064, 0.18051042],\n [0.2126, 0.7152, 0.0722],\n [0.01932141, 0.11916382, 0.95034478],\n];\n\nconst XYZ_TO_SRGB = [\n [\n 3.2413774792388685,\n -1.5376652402851851,\n -0.49885366846268053,\n ],\n [\n -0.9691452513005321,\n 1.8758853451067872,\n 0.04156585616912061,\n ],\n [\n 0.05562093689691305,\n -0.20395524564742123,\n 1.0571799111220335,\n ],\n];\n\nconst WHITE_POINT_D65 = [95.047, 100.0, 108.883];\n\n/**\n * Converts a color from RGB components to ARGB format.\n */\nexport function argbFromRgb(red: number, green: number, blue: number): number {\n return (255 << 24 | (red & 255) << 16 | (green & 255) << 8 | blue & 255) >>>\n 0;\n}\n\n/**\n * Converts a color from linear RGB components to ARGB format.\n */\nexport function argbFromLinrgb(linrgb: number[]): number {\n const r = delinearized(linrgb[0]);\n const g = delinearized(linrgb[1]);\n const b = delinearized(linrgb[2]);\n return argbFromRgb(r, g, b);\n}\n\n/**\n * Returns the alpha component of a color in ARGB format.\n */\nexport function alphaFromArgb(argb: number): number {\n return argb >> 24 & 255;\n}\n\n/**\n * Returns the red component of a color in ARGB format.\n */\nexport function redFromArgb(argb: number): number {\n return argb >> 16 & 255;\n}\n\n/**\n * Returns the green component of a color in ARGB format.\n */\nexport function greenFromArgb(argb: number): number {\n return argb >> 8 & 255;\n}\n\n/**\n * Returns the blue component of a color in ARGB format.\n */\nexport function blueFromArgb(argb: number): number {\n return argb & 255;\n}\n\n/**\n * Returns whether a color in ARGB format is opaque.\n */\nexport function isOpaque(argb: number): boolean {\n return alphaFromArgb(argb) >= 255;\n}\n\n/**\n * Converts a color from ARGB to XYZ.\n */\nexport function argbFromXyz(x: number, y: number, z: number): number {\n const matrix = XYZ_TO_SRGB;\n const linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z;\n const linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z;\n const linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z;\n const r = delinearized(linearR);\n const g = delinearized(linearG);\n const b = delinearized(linearB);\n return argbFromRgb(r, g, b);\n}\n\n/**\n * Converts a color from XYZ to ARGB.\n */\nexport function xyzFromArgb(argb: number): number[] {\n const r = linearized(redFromArgb(argb));\n const g = linearized(greenFromArgb(argb));\n const b = linearized(blueFromArgb(argb));\n return mathUtils.matrixMultiply([r, g, b], SRGB_TO_XYZ);\n}\n\n/**\n * Converts a color represented in Lab color space into an ARGB\n * integer.\n */\nexport function argbFromLab(l: number, a: number, b: number): number {\n const whitePoint = WHITE_POINT_D65;\n const fy = (l + 16.0) / 116.0;\n const fx = a / 500.0 + fy;\n const fz = fy - b / 200.0;\n const xNormalized = labInvf(fx);\n const yNormalized = labInvf(fy);\n const zNormalized = labInvf(fz);\n const x = xNormalized * whitePoint[0];\n const y = yNormalized * whitePoint[1];\n const z = zNormalized * whitePoint[2];\n return argbFromXyz(x, y, z);\n}\n\n/**\n * Converts a color from ARGB representation to L*a*b*\n * representation.\n *\n * @param argb the ARGB representation of a color\n * @return a Lab object representing the color\n */\nexport function labFromArgb(argb: number): number[] {\n const linearR = linearized(redFromArgb(argb));\n const linearG = linearized(greenFromArgb(argb));\n const linearB = linearized(blueFromArgb(argb));\n const matrix = SRGB_TO_XYZ;\n const x =\n matrix[0][0] * linearR + matrix[0][1] * linearG + matrix[0][2] * linearB;\n const y =\n matrix[1][0] * linearR + matrix[1][1] * linearG + matrix[1][2] * linearB;\n const z =\n matrix[2][0] * linearR + matrix[2][1] * linearG + matrix[2][2] * linearB;\n const whitePoint = WHITE_POINT_D65;\n const xNormalized = x / whitePoint[0];\n const yNormalized = y / whitePoint[1];\n const zNormalized = z / whitePoint[2];\n const fx = labF(xNormalized);\n const fy = labF(yNormalized);\n const fz = labF(zNormalized);\n const l = 116.0 * fy - 16;\n const a = 500.0 * (fx - fy);\n const b = 200.0 * (fy - fz);\n return [l, a, b];\n}\n\n/**\n * Converts an L* value to an ARGB representation.\n *\n * @param lstar L* in L*a*b*\n * @return ARGB representation of grayscale color with lightness\n * matching L*\n */\nexport function argbFromLstar(lstar: number): number {\n const y = yFromLstar(lstar);\n const component = delinearized(y);\n return argbFromRgb(component, component, component);\n}\n\n/**\n * Computes the L* value of a color in ARGB representation.\n *\n * @param argb ARGB representation of a color\n * @return L*, from L*a*b*, coordinate of the color\n */\nexport function lstarFromArgb(argb: number): number {\n const y = xyzFromArgb(argb)[1];\n return 116.0 * labF(y / 100.0) - 16.0;\n}\n\n/**\n * Converts an L* value to a Y value.\n *\n * L* in L*a*b* and Y in XYZ measure the same quantity, luminance.\n *\n * L* measures perceptual luminance, a linear scale. Y in XYZ\n * measures relative luminance, a logarithmic scale.\n *\n * @param lstar L* in L*a*b*\n * @return Y in XYZ\n */\nexport function yFromLstar(lstar: number): number {\n return 100.0 * labInvf((lstar + 16.0) / 116.0);\n}\n\n/**\n * Converts a Y value to an L* value.\n *\n * L* in L*a*b* and Y in XYZ measure the same quantity, luminance.\n *\n * L* measures perceptual luminance, a linear scale. Y in XYZ\n * measures relative luminance, a logarithmic scale.\n *\n * @param y Y in XYZ\n * @return L* in L*a*b*\n */\nexport function lstarFromY(y: number): number {\n return labF(y / 100.0) * 116.0 - 16.0;\n}\n\n/**\n * Linearizes an RGB component.\n *\n * @param rgbComponent 0 <= rgb_component <= 255, represents R/G/B\n * channel\n * @return 0.0 <= output <= 100.0, color channel converted to\n * linear RGB space\n */\nexport function linearized(rgbComponent: number): number {\n const normalized = rgbComponent / 255.0;\n if (normalized <= 0.040449936) {\n return normalized / 12.92 * 100.0;\n } else {\n return Math.pow((normalized + 0.055) / 1.055, 2.4) * 100.0;\n }\n}\n\n/**\n * Delinearizes an RGB component.\n *\n * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents\n * linear R/G/B channel\n * @return 0 <= output <= 255, color channel converted to regular\n * RGB space\n */\nexport function delinearized(rgbComponent: number): number {\n const normalized = rgbComponent / 100.0;\n let delinearized = 0.0;\n if (normalized <= 0.0031308) {\n delinearized = normalized * 12.92;\n } else {\n delinearized = 1.055 * Math.pow(normalized, 1.0 / 2.4) - 0.055;\n }\n return mathUtils.clampInt(0, 255, Math.round(delinearized * 255.0));\n}\n\n/**\n * Returns the standard white point; white on a sunny day.\n *\n * @return The white point\n */\nexport function whitePointD65(): number[] {\n return WHITE_POINT_D65;\n}\n\n/**\n * RGBA component\n * \n * @param r Red value should be between 0-255\n * @param g Green value should be between 0-255\n * @param b Blue value should be between 0-255\n * @param a Alpha value should be between 0-255\n */\nexport interface Rgba {\n r: number;\n g: number;\n b: number;\n a: number;\n}\n\n/**\n * Return RGBA from a given int32 color\n *\n * @param argb ARGB representation of a int32 color.\n * @return RGBA representation of a int32 color.\n */\nexport function rgbaFromArgb(argb: number): Rgba {\n const r = redFromArgb(argb);\n const g = greenFromArgb(argb);\n const b = blueFromArgb(argb);\n const a = alphaFromArgb(argb);\n return {r, g, b, a};\n}\n\n/**\n * Return int32 color from a given RGBA component\n * \n * @param rgba RGBA representation of a int32 color.\n * @returns ARGB representation of a int32 color.\n */\nexport function argbFromRgba({r, g, b, a}: Rgba): number {\n const rValue = clampComponent(r);\n const gValue = clampComponent(g);\n const bValue = clampComponent(b);\n const aValue = clampComponent(a);\n return (aValue << 24) | (rValue << 16) | (gValue << 8) | bValue;\n}\n\nfunction clampComponent(value: number) {\n if (value < 0) return 0;\n if (value > 255) return 255;\n return value\n}\n\nfunction labF(t: number): number {\n const e = 216.0 / 24389.0;\n const kappa = 24389.0 / 27.0;\n if (t > e) {\n return Math.pow(t, 1.0 / 3.0);\n } else {\n return (kappa * t + 16) / 116;\n }\n}\n\nfunction labInvf(ft: number): number {\n const e = 216.0 / 24389.0;\n const kappa = 24389.0 / 27.0;\n const ft3 = ft * ft * ft;\n if (ft3 > e) {\n return ft3;\n } else {\n return (116 * ft - 16) / kappa;\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as utils from '../utils/color_utils.js';\nimport * as math from '../utils/math_utils.js';\n\n/**\n * In traditional color spaces, a color can be identified solely by the\n * observer's measurement of the color. Color appearance models such as CAM16\n * also use information about the environment where the color was\n * observed, known as the viewing conditions.\n *\n * For example, white under the traditional assumption of a midday sun white\n * point is accurately measured as a slightly chromatic blue by CAM16. (roughly,\n * hue 203, chroma 3, lightness 100)\n *\n * This class caches intermediate values of the CAM16 conversion process that\n * depend only on viewing conditions, enabling speed ups.\n */\nexport class ViewingConditions {\n /** sRGB-like viewing conditions. */\n static DEFAULT = ViewingConditions.make();\n\n /**\n * Create ViewingConditions from a simple, physically relevant, set of\n * parameters.\n *\n * @param whitePoint White point, measured in the XYZ color space.\n * default = D65, or sunny day afternoon\n * @param adaptingLuminance The luminance of the adapting field. Informally,\n * how bright it is in the room where the color is viewed. Can be\n * calculated from lux by multiplying lux by 0.0586. default = 11.72,\n * or 200 lux.\n * @param backgroundLstar The lightness of the area surrounding the color.\n * measured by L* in L*a*b*. default = 50.0\n * @param surround A general description of the lighting surrounding the\n * color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a\n * dimly light room, like watching TV at home at night. 2.0 means there\n * is no difference between the lighting on the color and around it.\n * default = 2.0\n * @param discountingIlluminant Whether the eye accounts for the tint of the\n * ambient lighting, such as knowing an apple is still red in green light.\n * default = false, the eye does not perform this process on\n * self-luminous objects like displays.\n */\n static make(\n whitePoint = utils.whitePointD65(),\n adaptingLuminance = (200.0 / Math.PI) * utils.yFromLstar(50.0) / 100.0,\n backgroundLstar = 50.0, surround = 2.0,\n discountingIlluminant = false): ViewingConditions {\n const xyz = whitePoint;\n const rW = xyz[0] * 0.401288 + xyz[1] * 0.650173 + xyz[2] * -0.051461;\n const gW = xyz[0] * -0.250268 + xyz[1] * 1.204414 + xyz[2] * 0.045854;\n const bW = xyz[0] * -0.002079 + xyz[1] * 0.048952 + xyz[2] * 0.953127;\n const f = 0.8 + surround / 10.0;\n const c = f >= 0.9 ? math.lerp(0.59, 0.69, (f - 0.9) * 10.0) :\n math.lerp(0.525, 0.59, (f - 0.8) * 10.0);\n let d = discountingIlluminant ?\n 1.0 :\n f * (1.0 - (1.0 / 3.6) * Math.exp((-adaptingLuminance - 42.0) / 92.0));\n d = d > 1.0 ? 1.0 : d < 0.0 ? 0.0 : d;\n const nc = f;\n const rgbD = [\n d * (100.0 / rW) + 1.0 - d,\n d * (100.0 / gW) + 1.0 - d,\n d * (100.0 / bW) + 1.0 - d,\n ];\n const k = 1.0 / (5.0 * adaptingLuminance + 1.0);\n const k4 = k * k * k * k;\n const k4F = 1.0 - k4;\n const fl = k4 * adaptingLuminance +\n 0.1 * k4F * k4F * Math.cbrt(5.0 * adaptingLuminance);\n const n = utils.yFromLstar(backgroundLstar) / whitePoint[1];\n const z = 1.48 + Math.sqrt(n);\n const nbb = 0.725 / Math.pow(n, 0.2);\n const ncb = nbb;\n const rgbAFactors = [\n Math.pow((fl * rgbD[0] * rW) / 100.0, 0.42),\n Math.pow((fl * rgbD[1] * gW) / 100.0, 0.42),\n Math.pow((fl * rgbD[2] * bW) / 100.0, 0.42),\n ];\n const rgbA = [\n (400.0 * rgbAFactors[0]) / (rgbAFactors[0] + 27.13),\n (400.0 * rgbAFactors[1]) / (rgbAFactors[1] + 27.13),\n (400.0 * rgbAFactors[2]) / (rgbAFactors[2] + 27.13),\n ];\n const aw = (2.0 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]) * nbb;\n return new ViewingConditions(\n n, aw, nbb, ncb, c, nc, rgbD, fl, Math.pow(fl, 0.25), z);\n }\n\n /**\n * Parameters are intermediate values of the CAM16 conversion process. Their\n * names are shorthand for technical color science terminology, this class\n * would not benefit from documenting them individually. A brief overview\n * is available in the CAM16 specification, and a complete overview requires\n * a color science textbook, such as Fairchild's Color Appearance Models.\n */\n private constructor(\n public n: number, public aw: number, public nbb: number,\n public ncb: number, public c: number, public nc: number,\n public rgbD: number[], public fl: number, public fLRoot: number,\n public z: number) {}\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as utils from '../utils/color_utils.js';\nimport * as math from '../utils/math_utils.js';\n\nimport {ViewingConditions} from './viewing_conditions.js';\n\n/**\n * CAM16, a color appearance model. Colors are not just defined by their hex\n * code, but rather, a hex code and viewing conditions.\n *\n * CAM16 instances also have coordinates in the CAM16-UCS space, called J*, a*,\n * b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16\n * specification, and should be used when measuring distances between colors.\n *\n * In traditional color spaces, a color can be identified solely by the\n * observer's measurement of the color. Color appearance models such as CAM16\n * also use information about the environment where the color was\n * observed, known as the viewing conditions.\n *\n * For example, white under the traditional assumption of a midday sun white\n * point is accurately measured as a slightly chromatic blue by CAM16. (roughly,\n * hue 203, chroma 3, lightness 100)\n */\nexport class Cam16 {\n /**\n * All of the CAM16 dimensions can be calculated from 3 of the dimensions, in\n * the following combinations:\n * - {j or q} and {c, m, or s} and hue\n * - jstar, astar, bstar\n * Prefer using a static method that constructs from 3 of those dimensions.\n * This constructor is intended for those methods to use to return all\n * possible dimensions.\n *\n * @param hue\n * @param chroma informally, colorfulness / color intensity. like saturation\n * in HSL, except perceptually accurate.\n * @param j lightness\n * @param q brightness; ratio of lightness to white point's lightness\n * @param m colorfulness\n * @param s saturation; ratio of chroma to white point's chroma\n * @param jstar CAM16-UCS J coordinate\n * @param astar CAM16-UCS a coordinate\n * @param bstar CAM16-UCS b coordinate\n */\n constructor(\n readonly hue: number, readonly chroma: number, readonly j: number,\n readonly q: number, readonly m: number, readonly s: number,\n readonly jstar: number, readonly astar: number, readonly bstar: number) {}\n\n /**\n * CAM16 instances also have coordinates in the CAM16-UCS space, called J*,\n * a*, b*, or jstar, astar, bstar in code. CAM16-UCS is included in the CAM16\n * specification, and is used to measure distances between colors.\n */\n distance(other: Cam16): number {\n const dJ = this.jstar - other.jstar;\n const dA = this.astar - other.astar;\n const dB = this.bstar - other.bstar;\n const dEPrime = Math.sqrt(dJ * dJ + dA * dA + dB * dB);\n const dE = 1.41 * Math.pow(dEPrime, 0.63);\n return dE;\n }\n\n /**\n * @param argb ARGB representation of a color.\n * @return CAM16 color, assuming the color was viewed in default viewing\n * conditions.\n */\n static fromInt(argb: number): Cam16 {\n return Cam16.fromIntInViewingConditions(argb, ViewingConditions.DEFAULT);\n }\n\n /**\n * @param argb ARGB representation of a color.\n * @param viewingConditions Information about the environment where the color\n * was observed.\n * @return CAM16 color.\n */\n static fromIntInViewingConditions(\n argb: number, viewingConditions: ViewingConditions): Cam16 {\n const red = (argb & 0x00ff0000) >> 16;\n const green = (argb & 0x0000ff00) >> 8;\n const blue = (argb & 0x000000ff);\n const redL = utils.linearized(red);\n const greenL = utils.linearized(green);\n const blueL = utils.linearized(blue);\n const x = 0.41233895 * redL + 0.35762064 * greenL + 0.18051042 * blueL;\n const y = 0.2126 * redL + 0.7152 * greenL + 0.0722 * blueL;\n const z = 0.01932141 * redL + 0.11916382 * greenL + 0.95034478 * blueL;\n\n const rC = 0.401288 * x + 0.650173 * y - 0.051461 * z;\n const gC = -0.250268 * x + 1.204414 * y + 0.045854 * z;\n const bC = -0.002079 * x + 0.048952 * y + 0.953127 * z;\n\n const rD = viewingConditions.rgbD[0] * rC;\n const gD = viewingConditions.rgbD[1] * gC;\n const bD = viewingConditions.rgbD[2] * bC;\n\n const rAF = Math.pow((viewingConditions.fl * Math.abs(rD)) / 100.0, 0.42);\n const gAF = Math.pow((viewingConditions.fl * Math.abs(gD)) / 100.0, 0.42);\n const bAF = Math.pow((viewingConditions.fl * Math.abs(bD)) / 100.0, 0.42);\n\n const rA = (math.signum(rD) * 400.0 * rAF) / (rAF + 27.13);\n const gA = (math.signum(gD) * 400.0 * gAF) / (gAF + 27.13);\n const bA = (math.signum(bD) * 400.0 * bAF) / (bAF + 27.13);\n\n const a = (11.0 * rA + -12.0 * gA + bA) / 11.0;\n const b = (rA + gA - 2.0 * bA) / 9.0;\n const u = (20.0 * rA + 20.0 * gA + 21.0 * bA) / 20.0;\n const p2 = (40.0 * rA + 20.0 * gA + bA) / 20.0;\n const atan2 = Math.atan2(b, a);\n const atanDegrees = (atan2 * 180.0) / Math.PI;\n const hue = atanDegrees < 0 ? atanDegrees + 360.0 :\n atanDegrees >= 360 ? atanDegrees - 360.0 :\n atanDegrees;\n const hueRadians = (hue * Math.PI) / 180.0;\n\n const ac = p2 * viewingConditions.nbb;\n const j = 100.0 *\n Math.pow(\n ac / viewingConditions.aw,\n viewingConditions.c * viewingConditions.z);\n const q = (4.0 / viewingConditions.c) * Math.sqrt(j / 100.0) *\n (viewingConditions.aw + 4.0) * viewingConditions.fLRoot;\n const huePrime = hue < 20.14 ? hue + 360 : hue;\n const eHue = 0.25 * (Math.cos((huePrime * Math.PI) / 180.0 + 2.0) + 3.8);\n const p1 =\n (50000.0 / 13.0) * eHue * viewingConditions.nc * viewingConditions.ncb;\n const t = (p1 * Math.sqrt(a * a + b * b)) / (u + 0.305);\n const alpha = Math.pow(t, 0.9) *\n Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);\n const c = alpha * Math.sqrt(j / 100.0);\n const m = c * viewingConditions.fLRoot;\n const s = 50.0 *\n Math.sqrt((alpha * viewingConditions.c) / (viewingConditions.aw + 4.0));\n const jstar = ((1.0 + 100.0 * 0.007) * j) / (1.0 + 0.007 * j);\n const mstar = (1.0 / 0.0228) * Math.log(1.0 + 0.0228 * m);\n const astar = mstar * Math.cos(hueRadians);\n const bstar = mstar * Math.sin(hueRadians);\n\n return new Cam16(hue, c, j, q, m, s, jstar, astar, bstar);\n }\n\n /**\n * @param j CAM16 lightness\n * @param c CAM16 chroma\n * @param h CAM16 hue\n */\n static fromJch(j: number, c: number, h: number): Cam16 {\n return Cam16.fromJchInViewingConditions(j, c, h, ViewingConditions.DEFAULT);\n }\n\n /**\n * @param j CAM16 lightness\n * @param c CAM16 chroma\n * @param h CAM16 hue\n * @param viewingConditions Information about the environment where the color\n * was observed.\n */\n static fromJchInViewingConditions(\n j: number, c: number, h: number,\n viewingConditions: ViewingConditions): Cam16 {\n const q = (4.0 / viewingConditions.c) * Math.sqrt(j / 100.0) *\n (viewingConditions.aw + 4.0) * viewingConditions.fLRoot;\n const m = c * viewingConditions.fLRoot;\n const alpha = c / Math.sqrt(j / 100.0);\n const s = 50.0 *\n Math.sqrt((alpha * viewingConditions.c) / (viewingConditions.aw + 4.0));\n const hueRadians = (h * Math.PI) / 180.0;\n const jstar = ((1.0 + 100.0 * 0.007) * j) / (1.0 + 0.007 * j);\n const mstar = (1.0 / 0.0228) * Math.log(1.0 + 0.0228 * m);\n const astar = mstar * Math.cos(hueRadians);\n const bstar = mstar * Math.sin(hueRadians);\n return new Cam16(h, c, j, q, m, s, jstar, astar, bstar);\n }\n\n /**\n * @param jstar CAM16-UCS lightness.\n * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian\n * coordinate on the Y axis.\n * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian\n * coordinate on the X axis.\n */\n static fromUcs(jstar: number, astar: number, bstar: number): Cam16 {\n return Cam16.fromUcsInViewingConditions(\n jstar, astar, bstar, ViewingConditions.DEFAULT);\n }\n\n /**\n * @param jstar CAM16-UCS lightness.\n * @param astar CAM16-UCS a dimension. Like a* in L*a*b*, it is a Cartesian\n * coordinate on the Y axis.\n * @param bstar CAM16-UCS b dimension. Like a* in L*a*b*, it is a Cartesian\n * coordinate on the X axis.\n * @param viewingConditions Information about the environment where the color\n * was observed.\n */\n static fromUcsInViewingConditions(\n jstar: number, astar: number, bstar: number,\n viewingConditions: ViewingConditions): Cam16 {\n const a = astar;\n const b = bstar;\n const m = Math.sqrt(a * a + b * b);\n const M = (Math.exp(m * 0.0228) - 1.0) / 0.0228;\n const c = M / viewingConditions.fLRoot;\n let h = Math.atan2(b, a) * (180.0 / Math.PI);\n if (h < 0.0) {\n h += 360.0;\n }\n const j = jstar / (1 - (jstar - 100) * 0.007);\n return Cam16.fromJchInViewingConditions(j, c, h, viewingConditions);\n }\n\n /**\n * @return ARGB representation of color, assuming the color was viewed in\n * default viewing conditions, which are near-identical to the default\n * viewing conditions for sRGB.\n */\n toInt(): number {\n return this.viewed(ViewingConditions.DEFAULT);\n }\n\n /**\n * @param viewingConditions Information about the environment where the color\n * will be viewed.\n * @return ARGB representation of color\n */\n viewed(viewingConditions: ViewingConditions): number {\n const alpha = this.chroma === 0.0 || this.j === 0.0 ?\n 0.0 :\n this.chroma / Math.sqrt(this.j / 100.0);\n\n const t = Math.pow(\n alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73),\n 1.0 / 0.9);\n const hRad = (this.hue * Math.PI) / 180.0;\n\n const eHue = 0.25 * (Math.cos(hRad + 2.0) + 3.8);\n const ac = viewingConditions.aw *\n Math.pow(\n this.j / 100.0, 1.0 / viewingConditions.c / viewingConditions.z);\n const p1 =\n eHue * (50000.0 / 13.0) * viewingConditions.nc * viewingConditions.ncb;\n const p2 = ac / viewingConditions.nbb;\n\n const hSin = Math.sin(hRad);\n const hCos = Math.cos(hRad);\n\n const gamma = (23.0 * (p2 + 0.305) * t) /\n (23.0 * p1 + 11.0 * t * hCos + 108.0 * t * hSin);\n const a = gamma * hCos;\n const b = gamma * hSin;\n const rA = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;\n const gA = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;\n const bA = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;\n\n const rCBase = Math.max(0, (27.13 * Math.abs(rA)) / (400.0 - Math.abs(rA)));\n const rC = math.signum(rA) * (100.0 / viewingConditions.fl) *\n Math.pow(rCBase, 1.0 / 0.42);\n const gCBase = Math.max(0, (27.13 * Math.abs(gA)) / (400.0 - Math.abs(gA)));\n const gC = math.signum(gA) * (100.0 / viewingConditions.fl) *\n Math.pow(gCBase, 1.0 / 0.42);\n const bCBase = Math.max(0, (27.13 * Math.abs(bA)) / (400.0 - Math.abs(bA)));\n const bC = math.signum(bA) * (100.0 / viewingConditions.fl) *\n Math.pow(bCBase, 1.0 / 0.42);\n const rF = rC / viewingConditions.rgbD[0];\n const gF = gC / viewingConditions.rgbD[1];\n const bF = bC / viewingConditions.rgbD[2];\n\n const x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF;\n const y = 0.38752654 * rF + 0.62144744 * gF - 0.00897398 * bF;\n const z = -0.01584150 * rF - 0.03412294 * gF + 1.04996444 * bF;\n\n const argb = utils.argbFromXyz(x, y, z);\n return argb;\n }\n\n /// Given color expressed in XYZ and viewed in [viewingConditions], convert to\n /// CAM16.\n static fromXyzInViewingConditions(\n x: number, y: number, z: number,\n viewingConditions: ViewingConditions): Cam16 {\n // Transform XYZ to 'cone'/'rgb' responses\n\n const rC = 0.401288 * x + 0.650173 * y - 0.051461 * z;\n const gC = -0.250268 * x + 1.204414 * y + 0.045854 * z;\n const bC = -0.002079 * x + 0.048952 * y + 0.953127 * z;\n\n // Discount illuminant\n const rD = viewingConditions.rgbD[0] * rC;\n const gD = viewingConditions.rgbD[1] * gC;\n const bD = viewingConditions.rgbD[2] * bC;\n\n // chromatic adaptation\n const rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100.0, 0.42);\n const gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100.0, 0.42);\n const bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100.0, 0.42);\n const rA = math.signum(rD) * 400.0 * rAF / (rAF + 27.13);\n const gA = math.signum(gD) * 400.0 * gAF / (gAF + 27.13);\n const bA = math.signum(bD) * 400.0 * bAF / (bAF + 27.13);\n\n // redness-greenness\n const a = (11.0 * rA + -12.0 * gA + bA) / 11.0;\n // yellowness-blueness\n const b = (rA + gA - 2.0 * bA) / 9.0;\n\n // auxiliary components\n const u = (20.0 * rA + 20.0 * gA + 21.0 * bA) / 20.0;\n const p2 = (40.0 * rA + 20.0 * gA + bA) / 20.0;\n\n // hue\n const atan2 = Math.atan2(b, a);\n const atanDegrees = atan2 * 180.0 / Math.PI;\n const hue = atanDegrees < 0 ? atanDegrees + 360.0 :\n atanDegrees >= 360 ? atanDegrees - 360 :\n atanDegrees;\n const hueRadians = hue * Math.PI / 180.0;\n\n // achromatic response to color\n const ac = p2 * viewingConditions.nbb;\n\n // CAM16 lightness and brightness\n const J = 100.0 *\n Math.pow(\n ac / viewingConditions.aw,\n viewingConditions.c * viewingConditions.z);\n const Q = (4.0 / viewingConditions.c) * Math.sqrt(J / 100.0) *\n (viewingConditions.aw + 4.0) * (viewingConditions.fLRoot);\n\n const huePrime = (hue < 20.14) ? hue + 360 : hue;\n const eHue =\n (1.0 / 4.0) * (Math.cos(huePrime * Math.PI / 180.0 + 2.0) + 3.8);\n const p1 =\n 50000.0 / 13.0 * eHue * viewingConditions.nc * viewingConditions.ncb;\n const t = p1 * Math.sqrt(a * a + b * b) / (u + 0.305);\n const alpha = Math.pow(t, 0.9) *\n Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);\n // CAM16 chroma, colorfulness, chroma\n const C = alpha * Math.sqrt(J / 100.0);\n const M = C * viewingConditions.fLRoot;\n const s = 50.0 *\n Math.sqrt((alpha * viewingConditions.c) / (viewingConditions.aw + 4.0));\n\n // CAM16-UCS components\n const jstar = (1.0 + 100.0 * 0.007) * J / (1.0 + 0.007 * J);\n const mstar = Math.log(1.0 + 0.0228 * M) / 0.0228;\n const astar = mstar * Math.cos(hueRadians);\n const bstar = mstar * Math.sin(hueRadians);\n return new Cam16(hue, C, J, Q, M, s, jstar, astar, bstar);\n }\n\n /// XYZ representation of CAM16 seen in [viewingConditions].\n xyzInViewingConditions(viewingConditions: ViewingConditions): number[] {\n const alpha = (this.chroma === 0.0 || this.j === 0.0) ?\n 0.0 :\n this.chroma / Math.sqrt(this.j / 100.0);\n\n const t = Math.pow(\n alpha / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73),\n 1.0 / 0.9);\n const hRad = this.hue * Math.PI / 180.0;\n\n const eHue = 0.25 * (Math.cos(hRad + 2.0) + 3.8);\n const ac = viewingConditions.aw *\n Math.pow(\n this.j / 100.0, 1.0 / viewingConditions.c / viewingConditions.z);\n const p1 =\n eHue * (50000.0 / 13.0) * viewingConditions.nc * viewingConditions.ncb;\n\n const p2 = (ac / viewingConditions.nbb);\n\n const hSin = Math.sin(hRad);\n const hCos = Math.cos(hRad);\n\n const gamma = 23.0 * (p2 + 0.305) * t /\n (23.0 * p1 + 11 * t * hCos + 108.0 * t * hSin);\n const a = gamma * hCos;\n const b = gamma * hSin;\n const rA = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;\n const gA = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;\n const bA = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;\n\n const rCBase = Math.max(0, (27.13 * Math.abs(rA)) / (400.0 - Math.abs(rA)));\n const rC = math.signum(rA) * (100.0 / viewingConditions.fl) *\n Math.pow(rCBase, 1.0 / 0.42);\n const gCBase = Math.max(0, (27.13 * Math.abs(gA)) / (400.0 - Math.abs(gA)));\n const gC = math.signum(gA) * (100.0 / viewingConditions.fl) *\n Math.pow(gCBase, 1.0 / 0.42);\n const bCBase = Math.max(0, (27.13 * Math.abs(bA)) / (400.0 - Math.abs(bA)));\n const bC = math.signum(bA) * (100.0 / viewingConditions.fl) *\n Math.pow(bCBase, 1.0 / 0.42);\n const rF = rC / viewingConditions.rgbD[0];\n const gF = gC / viewingConditions.rgbD[1];\n const bF = bC / viewingConditions.rgbD[2];\n\n const x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF;\n const y = 0.38752654 * rF + 0.62144744 * gF - 0.00897398 * bF;\n const z = -0.01584150 * rF - 0.03412294 * gF + 1.04996444 * bF;\n\n return [x, y, z];\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// This file is automatically generated. Do not modify it.\n\nimport * as colorUtils from '../utils/color_utils.js';\nimport * as mathUtils from '../utils/math_utils.js';\n\nimport {Cam16} from './cam16.js';\nimport {ViewingConditions} from './viewing_conditions.js';\n\n\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable:class-as-namespace\n/**\n * A class that solves the HCT equation.\n */\nexport class HctSolver {\n static SCALED_DISCOUNT_FROM_LINRGB = [\n [\n 0.001200833568784504,\n 0.002389694492170889,\n 0.0002795742885861124,\n ],\n [\n 0.0005891086651375999,\n 0.0029785502573438758,\n 0.0003270666104008398,\n ],\n [\n 0.00010146692491640572,\n 0.0005364214359186694,\n 0.0032979401770712076,\n ],\n ];\n\n static LINRGB_FROM_SCALED_DISCOUNT = [\n [\n 1373.2198709594231,\n -1100.4251190754821,\n -7.278681089101213,\n ],\n [\n -271.815969077903,\n 559.6580465940733,\n -32.46047482791194,\n ],\n [\n 1.9622899599665666,\n -57.173814538844006,\n 308.7233197812385,\n ],\n ];\n\n static Y_FROM_LINRGB = [0.2126, 0.7152, 0.0722];\n\n static CRITICAL_PLANES = [\n 0.015176349177441876, 0.045529047532325624, 0.07588174588720938,\n 0.10623444424209313, 0.13658714259697685, 0.16693984095186062,\n 0.19729253930674434, 0.2276452376616281, 0.2579979360165119,\n 0.28835063437139563, 0.3188300904430532, 0.350925934958123,\n 0.3848314933096426, 0.42057480301049466, 0.458183274052838,\n 0.4976837250274023, 0.5391024159806381, 0.5824650784040898,\n 0.6277969426914107, 0.6751227633498623, 0.7244668422128921,\n 0.775853049866786, 0.829304845476233, 0.8848452951698498,\n 0.942497089126609, 1.0022825574869039, 1.0642236851973577,\n 1.1283421258858297, 1.1946592148522128, 1.2631959812511864,\n 1.3339731595349034, 1.407011200216447, 1.4823302800086415,\n 1.5599503113873272, 1.6398909516233677, 1.7221716113234105,\n 1.8068114625156377, 1.8938294463134073, 1.9832442801866852,\n 2.075074464868551, 2.1693382909216234, 2.2660538449872063,\n 2.36523901573795, 2.4669114995532007, 2.5710888059345764,\n 2.6777882626779785, 2.7870270208169257, 2.898822059350997,\n 3.0131901897720907, 3.1301480604002863, 3.2497121605402226,\n 3.3718988244681087, 3.4967242352587946, 3.624204428461639,\n 3.754355295633311, 3.887192587735158, 4.022731918402185,\n 4.160988767090289, 4.301978482107941, 4.445716283538092,\n 4.592217266055746, 4.741496401646282, 4.893568542229298,\n 5.048448422192488, 5.20615066083972, 5.3666897647573375,\n 5.5300801301023865, 5.696336044816294, 5.865471690767354,\n 6.037501145825082, 6.212438385869475, 6.390297286737924,\n 6.571091626112461, 6.7548350853498045, 6.941541251256611,\n 7.131223617812143, 7.323895587840543, 7.5195704746346665,\n 7.7182615035334345, 7.919981813454504, 8.124744458384042,\n 8.332562408825165, 8.543448553206703, 8.757415699253682,\n 8.974476575321063, 9.194643831691977, 9.417930041841839,\n 9.644347703669503, 9.873909240696694, 10.106627003236781,\n 10.342513269534024, 10.58158024687427, 10.8238400726681,\n 11.069304815507364, 11.317986476196008, 11.569896988756009,\n 11.825048221409341, 12.083451977536606, 12.345119996613247,\n 12.610063955123938, 12.878295467455942, 13.149826086772048,\n 13.42466730586372, 13.702830557985108, 13.984327217668513,\n 14.269168601521828, 14.55736596900856, 14.848930523210871,\n 15.143873411576273, 15.44220572664832, 15.743938506781891,\n 16.04908273684337, 16.35764934889634, 16.66964922287304,\n 16.985093187232053, 17.30399201960269, 17.62635644741625,\n 17.95219714852476, 18.281524751807332, 18.614349837764564,\n 18.95068293910138, 19.290534541298456, 19.633915083172692,\n 19.98083495742689, 20.331304511189067, 20.685334046541502,\n 21.042933821039977, 21.404114048223256, 21.76888489811322,\n 22.137256497705877, 22.50923893145328, 22.884842241736916,\n 23.264076429332462, 23.6469514538663, 24.033477234264016,\n 24.42366364919083, 24.817520537484558, 25.21505769858089,\n 25.61628489293138, 26.021211842414342, 26.429848230738664,\n 26.842203703840827, 27.258287870275353, 27.678110301598522,\n 28.10168053274597, 28.529008062403893, 28.96010235337422,\n 29.39497283293396, 29.83362889318845, 30.276079891419332,\n 30.722335150426627, 31.172403958865512, 31.62629557157785,\n 32.08401920991837, 32.54558406207592, 33.010999283389665,\n 33.4802739966603, 33.953417292456834, 34.430438229418264,\n 34.911345834551085, 35.39614910352207, 35.88485700094671,\n 36.37747846067349, 36.87402238606382, 37.37449765026789,\n 37.87891309649659, 38.38727753828926, 38.89959975977785,\n 39.41588851594697, 39.93615253289054, 40.460400508064545,\n 40.98864111053629, 41.520882981230194, 42.05713473317016,\n 42.597404951718396, 43.141702194811224, 43.6900349931913,\n 44.24241185063697, 44.798841244188324, 45.35933162437017,\n 45.92389141541209, 46.49252901546552, 47.065252796817916,\n 47.64207110610409, 48.22299226451468, 48.808024568002054,\n 49.3971762874833, 49.9904556690408, 50.587870934119984,\n 51.189430279724725, 51.79514187861014, 52.40501387947288,\n 53.0190544071392, 53.637271562750364, 54.259673423945976,\n 54.88626804504493, 55.517063457223934, 56.15206766869424,\n 56.79128866487574, 57.43473440856916, 58.08241284012621,\n 58.734331877617365, 59.39049941699807, 60.05092333227251,\n 60.715611475655585, 61.38457167773311, 62.057811747619894,\n 62.7353394731159, 63.417162620860914, 64.10328893648692,\n 64.79372614476921, 65.48848194977529, 66.18756403501224,\n 66.89098006357258, 67.59873767827808, 68.31084450182222,\n 69.02730813691093, 69.74813616640164, 70.47333615344107,\n 71.20291564160104, 71.93688215501312, 72.67524319850172,\n 73.41800625771542, 74.16517879925733, 74.9167682708136,\n 75.67278210128072, 76.43322770089146, 77.1981124613393,\n 77.96744375590167, 78.74122893956174, 79.51947534912904,\n 80.30219030335869, 81.08938110306934, 81.88105503125999,\n 82.67721935322541, 83.4778813166706, 84.28304815182372,\n 85.09272707154808, 85.90692527145302, 86.72564993000343,\n 87.54890820862819, 88.3767072518277, 89.2090541872801,\n 90.04595612594655, 90.88742016217518, 91.73345337380438,\n 92.58406282226491, 93.43925555268066, 94.29903859396902,\n 95.16341895893969, 96.03240364439274, 96.9059996312159,\n 97.78421388448044, 98.6670533535366, 99.55452497210776,\n ];\n\n /**\n * Sanitizes a small enough angle in radians.\n *\n * @param angle An angle in radians; must not deviate too much\n * from 0.\n * @return A coterminal angle between 0 and 2pi.\n */\n private static sanitizeRadians(angle: number): number {\n return (angle + Math.PI * 8) % (Math.PI * 2);\n }\n\n /**\n * Delinearizes an RGB component, returning a floating-point\n * number.\n *\n * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents\n * linear R/G/B channel\n * @return 0.0 <= output <= 255.0, color channel converted to\n * regular RGB space\n */\n private static trueDelinearized(rgbComponent: number): number {\n const normalized = rgbComponent / 100.0;\n let delinearized = 0.0;\n if (normalized <= 0.0031308) {\n delinearized = normalized * 12.92;\n } else {\n delinearized = 1.055 * Math.pow(normalized, 1.0 / 2.4) - 0.055;\n }\n return delinearized * 255.0;\n }\n\n private static chromaticAdaptation(component: number): number {\n const af = Math.pow(Math.abs(component), 0.42);\n return mathUtils.signum(component) * 400.0 * af / (af + 27.13);\n }\n\n /**\n * Returns the hue of a linear RGB color in CAM16.\n *\n * @param linrgb The linear RGB coordinates of a color.\n * @return The hue of the color in CAM16, in radians.\n */\n private static hueOf(linrgb: number[]): number {\n const scaledDiscount =\n mathUtils.matrixMultiply(linrgb, HctSolver.SCALED_DISCOUNT_FROM_LINRGB);\n const rA = HctSolver.chromaticAdaptation(scaledDiscount[0]);\n const gA = HctSolver.chromaticAdaptation(scaledDiscount[1]);\n const bA = HctSolver.chromaticAdaptation(scaledDiscount[2]);\n // redness-greenness\n const a = (11.0 * rA + -12.0 * gA + bA) / 11.0;\n // yellowness-blueness\n const b = (rA + gA - 2.0 * bA) / 9.0;\n return Math.atan2(b, a);\n }\n\n private static areInCyclicOrder(a: number, b: number, c: number): boolean {\n const deltaAB = HctSolver.sanitizeRadians(b - a);\n const deltaAC = HctSolver.sanitizeRadians(c - a);\n return deltaAB < deltaAC;\n }\n\n /**\n * Solves the lerp equation.\n *\n * @param source The starting number.\n * @param mid The number in the middle.\n * @param target The ending number.\n * @return A number t such that lerp(source, target, t) = mid.\n */\n private static intercept(source: number, mid: number, target: number):\n number {\n return (mid - source) / (target - source);\n }\n\n private static lerpPoint(source: number[], t: number, target: number[]):\n number[] {\n return [\n source[0] + (target[0] - source[0]) * t,\n source[1] + (target[1] - source[1]) * t,\n source[2] + (target[2] - source[2]) * t,\n ];\n }\n\n /**\n * Intersects a segment with a plane.\n *\n * @param source The coordinates of point A.\n * @param coordinate The R-, G-, or B-coordinate of the plane.\n * @param target The coordinates of point B.\n * @param axis The axis the plane is perpendicular with. (0: R, 1:\n * G, 2: B)\n * @return The intersection point of the segment AB with the plane\n * R=coordinate, G=coordinate, or B=coordinate\n */\n private static setCoordinate(\n source: number[],\n coordinate: number,\n target: number[],\n axis: number,\n ): number[] {\n const t = HctSolver.intercept(source[axis], coordinate, target[axis]);\n return HctSolver.lerpPoint(source, t, target);\n }\n\n private static isBounded(x: number): boolean {\n return 0.0 <= x && x <= 100.0;\n }\n\n /**\n * Returns the nth possible vertex of the polygonal intersection.\n *\n * @param y The Y value of the plane.\n * @param n The zero-based index of the point. 0 <= n <= 11.\n * @return The nth possible vertex of the polygonal intersection\n * of the y plane and the RGB cube, in linear RGB coordinates, if\n * it exists. If this possible vertex lies outside of the cube,\n * [-1.0, -1.0, -1.0] is returned.\n */\n private static nthVertex(y: number, n: number): number[] {\n const kR = HctSolver.Y_FROM_LINRGB[0];\n const kG = HctSolver.Y_FROM_LINRGB[1];\n const kB = HctSolver.Y_FROM_LINRGB[2];\n const coordA = n % 4 <= 1 ? 0.0 : 100.0;\n const coordB = n % 2 === 0 ? 0.0 : 100.0;\n if (n < 4) {\n const g = coordA;\n const b = coordB;\n const r = (y - g * kG - b * kB) / kR;\n if (HctSolver.isBounded(r)) {\n return [r, g, b];\n } else {\n return [-1.0, -1.0, -1.0];\n }\n } else if (n < 8) {\n const b = coordA;\n const r = coordB;\n const g = (y - r * kR - b * kB) / kG;\n if (HctSolver.isBounded(g)) {\n return [r, g, b];\n } else {\n return [-1.0, -1.0, -1.0];\n }\n } else {\n const r = coordA;\n const g = coordB;\n const b = (y - r * kR - g * kG) / kB;\n if (HctSolver.isBounded(b)) {\n return [r, g, b];\n } else {\n return [-1.0, -1.0, -1.0];\n }\n }\n }\n\n /**\n * Finds the segment containing the desired color.\n *\n * @param y The Y value of the color.\n * @param targetHue The hue of the color.\n * @return A list of two sets of linear RGB coordinates, each\n * corresponding to an endpoint of the segment containing the\n * desired color.\n */\n private static bisectToSegment(y: number, targetHue: number): number[][] {\n let left = [-1.0, -1.0, -1.0];\n let right = left;\n let leftHue = 0.0;\n let rightHue = 0.0;\n let initialized = false;\n let uncut = true;\n for (let n = 0; n < 12; n++) {\n const mid = HctSolver.nthVertex(y, n);\n if (mid[0] < 0) {\n continue;\n }\n const midHue = HctSolver.hueOf(mid);\n if (!initialized) {\n left = mid;\n right = mid;\n leftHue = midHue;\n rightHue = midHue;\n initialized = true;\n continue;\n }\n if (uncut || HctSolver.areInCyclicOrder(leftHue, midHue, rightHue)) {\n uncut = false;\n if (HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {\n right = mid;\n rightHue = midHue;\n } else {\n left = mid;\n leftHue = midHue;\n }\n }\n }\n return [left, right];\n }\n\n private static midpoint(a: number[], b: number[]): number[] {\n return [\n (a[0] + b[0]) / 2,\n (a[1] + b[1]) / 2,\n (a[2] + b[2]) / 2,\n ];\n }\n\n private static criticalPlaneBelow(x: number): number {\n return Math.floor(x - 0.5);\n }\n\n private static criticalPlaneAbove(x: number): number {\n return Math.ceil(x - 0.5);\n }\n\n /**\n * Finds a color with the given Y and hue on the boundary of the\n * cube.\n *\n * @param y The Y value of the color.\n * @param targetHue The hue of the color.\n * @return The desired color, in linear RGB coordinates.\n */\n private static bisectToLimit(y: number, targetHue: number): number[] {\n const segment = HctSolver.bisectToSegment(y, targetHue);\n let left = segment[0];\n let leftHue = HctSolver.hueOf(left);\n let right = segment[1];\n for (let axis = 0; axis < 3; axis++) {\n if (left[axis] !== right[axis]) {\n let lPlane = -1;\n let rPlane = 255;\n if (left[axis] < right[axis]) {\n lPlane = HctSolver.criticalPlaneBelow(\n HctSolver.trueDelinearized(left[axis]));\n rPlane = HctSolver.criticalPlaneAbove(\n HctSolver.trueDelinearized(right[axis]));\n } else {\n lPlane = HctSolver.criticalPlaneAbove(\n HctSolver.trueDelinearized(left[axis]));\n rPlane = HctSolver.criticalPlaneBelow(\n HctSolver.trueDelinearized(right[axis]));\n }\n for (let i = 0; i < 8; i++) {\n if (Math.abs(rPlane - lPlane) <= 1) {\n break;\n } else {\n const mPlane = Math.floor((lPlane + rPlane) / 2.0);\n const midPlaneCoordinate = HctSolver.CRITICAL_PLANES[mPlane];\n const mid =\n HctSolver.setCoordinate(left, midPlaneCoordinate, right, axis);\n const midHue = HctSolver.hueOf(mid);\n if (HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {\n right = mid;\n rPlane = mPlane;\n } else {\n left = mid;\n leftHue = midHue;\n lPlane = mPlane;\n }\n }\n }\n }\n }\n return HctSolver.midpoint(left, right);\n }\n\n private static inverseChromaticAdaptation(adapted: number): number {\n const adaptedAbs = Math.abs(adapted);\n const base = Math.max(0, 27.13 * adaptedAbs / (400.0 - adaptedAbs));\n return mathUtils.signum(adapted) * Math.pow(base, 1.0 / 0.42);\n }\n\n /**\n * Finds a color with the given hue, chroma, and Y.\n *\n * @param hueRadians The desired hue in radians.\n * @param chroma The desired chroma.\n * @param y The desired Y.\n * @return The desired color as a hexadecimal integer, if found; 0\n * otherwise.\n */\n private static findResultByJ(hueRadians: number, chroma: number, y: number):\n number {\n // Initial estimate of j.\n let j = Math.sqrt(y) * 11.0;\n // ===========================================================\n // Operations inlined from Cam16 to avoid repeated calculation\n // ===========================================================\n const viewingConditions = ViewingConditions.DEFAULT;\n const tInnerCoeff =\n 1 / Math.pow(1.64 - Math.pow(0.29, viewingConditions.n), 0.73);\n const eHue = 0.25 * (Math.cos(hueRadians + 2.0) + 3.8);\n const p1 =\n eHue * (50000.0 / 13.0) * viewingConditions.nc * viewingConditions.ncb;\n const hSin = Math.sin(hueRadians);\n const hCos = Math.cos(hueRadians);\n for (let iterationRound = 0; iterationRound < 5; iterationRound++) {\n // ===========================================================\n // Operations inlined from Cam16 to avoid repeated calculation\n // ===========================================================\n const jNormalized = j / 100.0;\n const alpha =\n chroma === 0.0 || j === 0.0 ? 0.0 : chroma / Math.sqrt(jNormalized);\n const t = Math.pow(alpha * tInnerCoeff, 1.0 / 0.9);\n const ac = viewingConditions.aw *\n Math.pow(\n jNormalized,\n 1.0 / viewingConditions.c / viewingConditions.z,\n );\n const p2 = ac / viewingConditions.nbb;\n const gamma = 23.0 * (p2 + 0.305) * t /\n (23.0 * p1 + 11 * t * hCos + 108.0 * t * hSin);\n const a = gamma * hCos;\n const b = gamma * hSin;\n const rA = (460.0 * p2 + 451.0 * a + 288.0 * b) / 1403.0;\n const gA = (460.0 * p2 - 891.0 * a - 261.0 * b) / 1403.0;\n const bA = (460.0 * p2 - 220.0 * a - 6300.0 * b) / 1403.0;\n const rCScaled = HctSolver.inverseChromaticAdaptation(rA);\n const gCScaled = HctSolver.inverseChromaticAdaptation(gA);\n const bCScaled = HctSolver.inverseChromaticAdaptation(bA);\n const linrgb = mathUtils.matrixMultiply(\n [rCScaled, gCScaled, bCScaled],\n HctSolver.LINRGB_FROM_SCALED_DISCOUNT,\n );\n // ===========================================================\n // Operations inlined from Cam16 to avoid repeated calculation\n // ===========================================================\n if (linrgb[0] < 0 || linrgb[1] < 0 || linrgb[2] < 0) {\n return 0;\n }\n const kR = HctSolver.Y_FROM_LINRGB[0];\n const kG = HctSolver.Y_FROM_LINRGB[1];\n const kB = HctSolver.Y_FROM_LINRGB[2];\n const fnj = kR * linrgb[0] + kG * linrgb[1] + kB * linrgb[2];\n if (fnj <= 0) {\n return 0;\n }\n if (iterationRound === 4 || Math.abs(fnj - y) < 0.002) {\n if (linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01) {\n return 0;\n }\n return colorUtils.argbFromLinrgb(linrgb);\n }\n // Iterates with Newton method,\n // Using 2 * fn(j) / j as the approximation of fn'(j)\n j = j - (fnj - y) * j / (2 * fnj);\n }\n return 0;\n }\n\n /**\n * Finds an sRGB color with the given hue, chroma, and L*, if\n * possible.\n *\n * @param hueDegrees The desired hue, in degrees.\n * @param chroma The desired chroma.\n * @param lstar The desired L*.\n * @return A hexadecimal representing the sRGB color. The color\n * has sufficiently close hue, chroma, and L* to the desired\n * values, if possible; otherwise, the hue and L* will be\n * sufficiently close, and chroma will be maximized.\n */\n static solveToInt(hueDegrees: number, chroma: number, lstar: number): number {\n if (chroma < 0.0001 || lstar < 0.0001 || lstar > 99.9999) {\n return colorUtils.argbFromLstar(lstar);\n }\n hueDegrees = mathUtils.sanitizeDegreesDouble(hueDegrees);\n const hueRadians = hueDegrees / 180 * Math.PI;\n const y = colorUtils.yFromLstar(lstar);\n const exactAnswer = HctSolver.findResultByJ(hueRadians, chroma, y);\n if (exactAnswer !== 0) {\n return exactAnswer;\n }\n const linrgb = HctSolver.bisectToLimit(y, hueRadians);\n return colorUtils.argbFromLinrgb(linrgb);\n }\n\n /**\n * Finds an sRGB color with the given hue, chroma, and L*, if\n * possible.\n *\n * @param hueDegrees The desired hue, in degrees.\n * @param chroma The desired chroma.\n * @param lstar The desired L*.\n * @return An CAM16 object representing the sRGB color. The color\n * has sufficiently close hue, chroma, and L* to the desired\n * values, if possible; otherwise, the hue and L* will be\n * sufficiently close, and chroma will be maximized.\n */\n static solveToCam(hueDegrees: number, chroma: number, lstar: number): Cam16 {\n return Cam16.fromInt(HctSolver.solveToInt(hueDegrees, chroma, lstar));\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A color system built using CAM16 hue and chroma, and L* from\n * L*a*b*.\n *\n * Using L* creates a link between the color system, contrast, and thus\n * accessibility. Contrast ratio depends on relative luminance, or Y in the XYZ\n * color space. L*, or perceptual luminance can be calculated from Y.\n *\n * Unlike Y, L* is linear to human perception, allowing trivial creation of\n * accurate color tones.\n *\n * Unlike contrast ratio, measuring contrast in L* is linear, and simple to\n * calculate. A difference of 40 in HCT tone guarantees a contrast ratio >= 3.0,\n * and a difference of 50 guarantees a contrast ratio >= 4.5.\n */\n\nimport * as utils from '../utils/color_utils.js';\n\nimport {Cam16} from './cam16.js';\nimport {HctSolver} from './hct_solver.js';\nimport {ViewingConditions} from './viewing_conditions.js';\n\n\n/**\n * HCT, hue, chroma, and tone. A color system that provides a perceptually\n * accurate color measurement system that can also accurately render what colors\n * will appear as in different lighting environments.\n */\nexport class Hct {\n /**\n * @param hue 0 <= hue < 360; invalid values are corrected.\n * @param chroma 0 <= chroma < ?; Informally, colorfulness. The color\n * returned may be lower than the requested chroma. Chroma has a different\n * maximum for any given hue and tone.\n * @param tone 0 <= tone <= 100; invalid values are corrected.\n * @return HCT representation of a color in default viewing conditions.\n */\n\n internalHue: number;\n internalChroma: number;\n internalTone: number;\n\n static from(hue: number, chroma: number, tone: number) {\n return new Hct(HctSolver.solveToInt(hue, chroma, tone));\n }\n\n /**\n * @param argb ARGB representation of a color.\n * @return HCT representation of a color in default viewing conditions\n */\n static fromInt(argb: number) {\n return new Hct(argb);\n }\n\n toInt(): number {\n return this.argb;\n }\n\n /**\n * A number, in degrees, representing ex. red, orange, yellow, etc.\n * Ranges from 0 <= hue < 360.\n */\n get hue(): number {\n return this.internalHue;\n }\n\n /**\n * @param newHue 0 <= newHue < 360; invalid values are corrected.\n * Chroma may decrease because chroma has a different maximum for any given\n * hue and tone.\n */\n set hue(newHue: number) {\n this.setInternalState(\n HctSolver.solveToInt(\n newHue,\n this.internalChroma,\n this.internalTone,\n ),\n );\n }\n\n get chroma(): number {\n return this.internalChroma;\n }\n\n /**\n * @param newChroma 0 <= newChroma < ?\n * Chroma may decrease because chroma has a different maximum for any given\n * hue and tone.\n */\n set chroma(newChroma: number) {\n this.setInternalState(\n HctSolver.solveToInt(\n this.internalHue,\n newChroma,\n this.internalTone,\n ),\n );\n }\n\n /** Lightness. Ranges from 0 to 100. */\n get tone(): number {\n return this.internalTone;\n }\n\n /**\n * @param newTone 0 <= newTone <= 100; invalid valids are corrected.\n * Chroma may decrease because chroma has a different maximum for any given\n * hue and tone.\n */\n set tone(newTone: number) {\n this.setInternalState(\n HctSolver.solveToInt(\n this.internalHue,\n this.internalChroma,\n newTone,\n ),\n );\n }\n\n private constructor(private argb: number) {\n const cam = Cam16.fromInt(argb);\n this.internalHue = cam.hue;\n this.internalChroma = cam.chroma;\n this.internalTone = utils.lstarFromArgb(argb);\n this.argb = argb;\n }\n\n private setInternalState(argb: number) {\n const cam = Cam16.fromInt(argb);\n this.internalHue = cam.hue;\n this.internalChroma = cam.chroma;\n this.internalTone = utils.lstarFromArgb(argb);\n this.argb = argb;\n }\n\n /**\n * Translates a color into different [ViewingConditions].\n *\n * Colors change appearance. They look different with lights on versus off,\n * the same color, as in hex code, on white looks different when on black.\n * This is called color relativity, most famously explicated by Josef Albers\n * in Interaction of Color.\n *\n * In color science, color appearance models can account for this and\n * calculate the appearance of a color in different settings. HCT is based on\n * CAM16, a color appearance model, and uses it to make these calculations.\n *\n * See [ViewingConditions.make] for parameters affecting color appearance.\n */\n inViewingConditions(vc: ViewingConditions): Hct {\n // 1. Use CAM16 to find XYZ coordinates of color in specified VC.\n const cam = Cam16.fromInt(this.toInt());\n const viewedInVc = cam.xyzInViewingConditions(vc);\n\n // 2. Create CAM16 of those XYZ coordinates in default VC.\n const recastInVc = Cam16.fromXyzInViewingConditions(\n viewedInVc[0],\n viewedInVc[1],\n viewedInVc[2],\n ViewingConditions.make(),\n );\n\n // 3. Create HCT from:\n // - CAM16 using default VC with XYZ coordinates in specified VC.\n // - L* converted from Y in XYZ coordinates in specified VC.\n const recastHct = Hct.from(\n recastInVc.hue,\n recastInVc.chroma,\n utils.lstarFromY(viewedInVc[1]),\n );\n return recastHct;\n }\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable:class-as-namespace\n\nimport * as utils from '../utils/color_utils.js';\nimport * as math from '../utils/math_utils.js';\n\n/**\n * Utility methods for calculating contrast given two colors, or calculating a\n * color given one color and a contrast ratio.\n *\n * Contrast ratio is calculated using XYZ's Y. When linearized to match human\n * perception, Y becomes HCT's tone and L*a*b*'s' L*. Informally, this is the\n * lightness of a color.\n *\n * Methods refer to tone, T in the the HCT color space.\n * Tone is equivalent to L* in the L*a*b* color space, or L in the LCH color\n * space.\n */\nexport class Contrast {\n /**\n * Returns a contrast ratio, which ranges from 1 to 21.\n *\n * @param toneA Tone between 0 and 100. Values outside will be clamped.\n * @param toneB Tone between 0 and 100. Values outside will be clamped.\n */\n static ratioOfTones(toneA: number, toneB: number): number {\n toneA = math.clampDouble(0.0, 100.0, toneA);\n toneB = math.clampDouble(0.0, 100.0, toneB);\n return Contrast.ratioOfYs(utils.yFromLstar(toneA), utils.yFromLstar(toneB));\n }\n\n static ratioOfYs(y1: number, y2: number): number {\n const lighter = y1 > y2 ? y1 : y2;\n const darker = (lighter === y2) ? y1 : y2;\n return (lighter + 5.0) / (darker + 5.0);\n }\n\n /**\n * Returns a tone >= tone parameter that ensures ratio parameter.\n * Return value is between 0 and 100.\n * Returns -1 if ratio cannot be achieved with tone parameter.\n *\n * @param tone Tone return value must contrast with.\n * Range is 0 to 100. Invalid values will result in -1 being returned.\n * @param ratio Contrast ratio of return value and tone.\n * Range is 1 to 21, invalid values have undefined behavior.\n */\n static lighter(tone: number, ratio: number): number {\n if (tone < 0.0 || tone > 100.0) {\n return -1.0;\n }\n\n const darkY = utils.yFromLstar(tone);\n const lightY = ratio * (darkY + 5.0) - 5.0;\n const realContrast = Contrast.ratioOfYs(lightY, darkY);\n const delta = Math.abs(realContrast - ratio);\n if (realContrast < ratio && delta > 0.04) {\n return -1;\n }\n\n // Ensure gamut mapping, which requires a 'range' on tone, will still result\n // the correct ratio by darkening slightly.\n const returnValue = utils.lstarFromY(lightY) + 0.4;\n if (returnValue < 0 || returnValue > 100) {\n return -1;\n }\n return returnValue;\n }\n\n /**\n * Returns a tone <= tone parameter that ensures ratio parameter.\n * Return value is between 0 and 100.\n * Returns -1 if ratio cannot be achieved with tone parameter.\n *\n * @param tone Tone return value must contrast with.\n * Range is 0 to 100. Invalid values will result in -1 being returned.\n * @param ratio Contrast ratio of return value and tone.\n * Range is 1 to 21, invalid values have undefined behavior.\n */\n static darker(tone: number, ratio: number): number {\n if (tone < 0.0 || tone > 100.0) {\n return -1.0;\n }\n\n const lightY = utils.yFromLstar(tone);\n const darkY = ((lightY + 5.0) / ratio) - 5.0;\n const realContrast = Contrast.ratioOfYs(lightY, darkY);\n\n const delta = Math.abs(realContrast - ratio);\n if (realContrast < ratio && delta > 0.04) {\n return -1;\n }\n\n // Ensure gamut mapping, which requires a 'range' on tone, will still result\n // the correct ratio by darkening slightly.\n const returnValue = utils.lstarFromY(darkY) - 0.4;\n if (returnValue < 0 || returnValue > 100) {\n return -1;\n }\n return returnValue;\n }\n\n /**\n * Returns a tone >= tone parameter that ensures ratio parameter.\n * Return value is between 0 and 100.\n * Returns 100 if ratio cannot be achieved with tone parameter.\n *\n * This method is unsafe because the returned value is guaranteed to be in\n * bounds for tone, i.e. between 0 and 100. However, that value may not reach\n * the ratio with tone. For example, there is no color lighter than T100.\n *\n * @param tone Tone return value must contrast with.\n * Range is 0 to 100. Invalid values will result in 100 being returned.\n * @param ratio Desired contrast ratio of return value and tone parameter.\n * Range is 1 to 21, invalid values have undefined behavior.\n */\n static lighterUnsafe(tone: number, ratio: number): number {\n const lighterSafe = Contrast.lighter(tone, ratio);\n return (lighterSafe < 0.0) ? 100.0 : lighterSafe;\n }\n\n /**\n * Returns a tone >= tone parameter that ensures ratio parameter.\n * Return value is between 0 and 100.\n * Returns 100 if ratio cannot be achieved with tone parameter.\n *\n * This method is unsafe because the returned value is guaranteed to be in\n * bounds for tone, i.e. between 0 and 100. However, that value may not reach\n * the [ratio with [tone]. For example, there is no color darker than T0.\n *\n * @param tone Tone return value must contrast with.\n * Range is 0 to 100. Invalid values will result in 0 being returned.\n * @param ratio Desired contrast ratio of return value and tone parameter.\n * Range is 1 to 21, invalid values have undefined behavior.\n */\n static darkerUnsafe(tone: number, ratio: number): number {\n const darkerSafe = Contrast.darker(tone, ratio);\n return (darkerSafe < 0.0) ? 0.0 : darkerSafe;\n }\n}", "/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Hct} from '../hct/hct.js';\n\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable:class-as-namespace\n\n/**\n * Check and/or fix universally disliked colors.\n * Color science studies of color preference indicate universal distaste for\n * dark yellow-greens, and also show this is correlated to distate for\n * biological waste and rotting food.\n *\n * See Palmer and Schloss, 2010 or Schloss and Palmer's Chapter 21 in Handbook\n * of Color Psychology (2015).\n */\nexport class DislikeAnalyzer {\n /**\n * Returns true if a color is disliked.\n *\n * @param hct A color to be judged.\n * @return Whether the color is disliked.\n *\n * Disliked is defined as a dark yellow-green that is not neutral.\n */\n static isDisliked(hct: Hct): boolean {\n const huePasses =\n Math.round(hct.hue) >= 90.0 && Math.round(hct.hue) <= 111.0;\n const chromaPasses = Math.round(hct.chroma) > 16.0;\n const tonePasses = Math.round(hct.tone) < 65.0;\n\n return huePasses && chromaPasses && tonePasses;\n }\n\n /**\n * If a color is disliked, lighten it to make it likable.\n *\n * @param hct A color to be judged.\n * @return A new color if the original color is disliked, or the original\n * color if it is acceptable.\n */\n static fixIfDisliked(hct: Hct): Hct {\n if (DislikeAnalyzer.isDisliked(hct)) {\n return Hct.from(\n hct.hue,\n hct.chroma,\n 70.0,\n );\n }\n\n return hct;\n }\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Contrast} from '../contrast/contrast.js';\nimport {Hct} from '../hct/hct.js';\nimport {TonalPalette} from '../palettes/tonal_palette.js';\nimport * as math from '../utils/math_utils.js';\n\nimport {ContrastCurve} from './contrast_curve.js';\nimport {DynamicScheme} from './dynamic_scheme.js';\nimport {ToneDeltaPair} from './tone_delta_pair.js';\n\n/**\n * @param name The name of the dynamic color. Defaults to empty.\n * @param palette Function that provides a TonalPalette given\n * DynamicScheme. A TonalPalette is defined by a hue and chroma, so this\n * replaces the need to specify hue/chroma. By providing a tonal palette, when\n * contrast adjustments are made, intended chroma can be preserved.\n * @param tone Function that provides a tone given DynamicScheme.\n * @param isBackground Whether this dynamic color is a background, with\n * some other color as the foreground. Defaults to false.\n * @param background The background of the dynamic color (as a function of a\n * `DynamicScheme`), if it exists.\n * @param secondBackground A second background of the dynamic color (as a\n * function of a `DynamicScheme`), if it\n * exists.\n * @param contrastCurve A `ContrastCurve` object specifying how its contrast\n * against its background should behave in various contrast levels options.\n * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta\n * constraint between two colors. One of them must be the color being\n * constructed.\n */\ninterface FromPaletteOptions {\n name?: string;\n palette: (scheme: DynamicScheme) => TonalPalette;\n tone: (scheme: DynamicScheme) => number;\n isBackground?: boolean;\n background?: (scheme: DynamicScheme) => DynamicColor;\n secondBackground?: (scheme: DynamicScheme) => DynamicColor;\n contrastCurve?: ContrastCurve;\n toneDeltaPair?: (scheme: DynamicScheme) => ToneDeltaPair;\n}\n\n/**\n * A color that adjusts itself based on UI state provided by DynamicScheme.\n *\n * Colors without backgrounds do not change tone when contrast changes. Colors\n * with backgrounds become closer to their background as contrast lowers, and\n * further when contrast increases.\n *\n * Prefer static constructors. They require either a hexcode, a palette and\n * tone, or a hue and chroma. Optionally, they can provide a background\n * DynamicColor.\n */\nexport class DynamicColor {\n private readonly hctCache = new Map<DynamicScheme, Hct>();\n\n /**\n * Create a DynamicColor defined by a TonalPalette and HCT tone.\n *\n * @param args Functions with DynamicScheme as input. Must provide a palette\n * and tone. May provide a background DynamicColor and ToneDeltaConstraint.\n */\n static fromPalette(args: FromPaletteOptions): DynamicColor {\n return new DynamicColor(\n args.name ?? '',\n args.palette,\n args.tone,\n args.isBackground ?? false,\n args.background,\n args.secondBackground,\n args.contrastCurve,\n args.toneDeltaPair,\n );\n }\n\n /**\n * The base constructor for DynamicColor.\n *\n * _Strongly_ prefer using one of the convenience constructors. This class is\n * arguably too flexible to ensure it can support any scenario. Functional\n * arguments allow overriding without risks that come with subclasses.\n *\n * For example, the default behavior of adjust tone at max contrast\n * to be at a 7.0 ratio with its background is principled and\n * matches accessibility guidance. That does not mean it's the desired\n * approach for _every_ design system, and every color pairing,\n * always, in every case.\n *\n * @param name The name of the dynamic color. Defaults to empty.\n * @param palette Function that provides a TonalPalette given\n * DynamicScheme. A TonalPalette is defined by a hue and chroma, so this\n * replaces the need to specify hue/chroma. By providing a tonal palette, when\n * contrast adjustments are made, intended chroma can be preserved.\n * @param tone Function that provides a tone, given a DynamicScheme.\n * @param isBackground Whether this dynamic color is a background, with\n * some other color as the foreground. Defaults to false.\n * @param background The background of the dynamic color (as a function of a\n * `DynamicScheme`), if it exists.\n * @param secondBackground A second background of the dynamic color (as a\n * function of a `DynamicScheme`), if it\n * exists.\n * @param contrastCurve A `ContrastCurve` object specifying how its contrast\n * against its background should behave in various contrast levels options.\n * @param toneDeltaPair A `ToneDeltaPair` object specifying a tone delta\n * constraint between two colors. One of them must be the color being\n * constructed.\n */\n constructor(\n readonly name: string,\n readonly palette: (scheme: DynamicScheme) => TonalPalette,\n readonly tone: (scheme: DynamicScheme) => number,\n readonly isBackground: boolean,\n readonly background?: (scheme: DynamicScheme) => DynamicColor,\n readonly secondBackground?: (scheme: DynamicScheme) => DynamicColor,\n readonly contrastCurve?: ContrastCurve,\n readonly toneDeltaPair?: (scheme: DynamicScheme) => ToneDeltaPair,\n ) {\n if ((!background) && secondBackground) {\n throw new Error(\n `Color ${name} has secondBackground` +\n `defined, but background is not defined.`);\n }\n if ((!background) && contrastCurve) {\n throw new Error(\n `Color ${name} has contrastCurve` +\n `defined, but background is not defined.`);\n }\n if (background && !contrastCurve) {\n throw new Error(\n `Color ${name} has background` +\n `defined, but contrastCurve is not defined.`);\n }\n }\n\n /**\n * Return a ARGB integer (i.e. a hex code).\n *\n * @param scheme Defines the conditions of the user interface, for example,\n * whether or not it is dark mode or light mode, and what the desired\n * contrast level is.\n */\n getArgb(scheme: DynamicScheme): number {\n return this.getHct(scheme).toInt();\n }\n\n /**\n * Return a color, expressed in the HCT color space, that this\n * DynamicColor is under the conditions in scheme.\n *\n * @param scheme Defines the conditions of the user interface, for example,\n * whether or not it is dark mode or light mode, and what the desired\n * contrast level is.\n */\n getHct(scheme: DynamicScheme): Hct {\n const cachedAnswer = this.hctCache.get(scheme);\n if (cachedAnswer != null) {\n return cachedAnswer;\n }\n const tone = this.getTone(scheme);\n const answer = this.palette(scheme).getHct(tone);\n if (this.hctCache.size > 4) {\n this.hctCache.clear();\n }\n this.hctCache.set(scheme, answer);\n return answer;\n }\n\n /**\n * Return a tone, T in the HCT color space, that this DynamicColor is under\n * the conditions in scheme.\n *\n * @param scheme Defines the conditions of the user interface, for example,\n * whether or not it is dark mode or light mode, and what the desired\n * contrast level is.\n */\n getTone(scheme: DynamicScheme): number {\n const decreasingContrast = scheme.contrastLevel < 0;\n\n // Case 1: dual foreground, pair of colors with delta constraint.\n if (this.toneDeltaPair) {\n const toneDeltaPair = this.toneDeltaPair(scheme);\n const roleA = toneDeltaPair.roleA;\n const roleB = toneDeltaPair.roleB;\n const delta = toneDeltaPair.delta;\n const polarity = toneDeltaPair.polarity;\n const stayTogether = toneDeltaPair.stayTogether;\n\n const bg = this.background!(scheme);\n const bgTone = bg.getTone(scheme);\n\n const aIsNearer =\n (polarity === 'nearer' ||\n (polarity === 'lighter' && !scheme.isDark) ||\n (polarity === 'darker' && scheme.isDark));\n const nearer = aIsNearer ? roleA : roleB;\n const farther = aIsNearer ? roleB : roleA;\n const amNearer = this.name === nearer.name;\n const expansionDir = scheme.isDark ? 1 : -1;\n\n // 1st round: solve to min, each\n const nContrast = nearer.contrastCurve!.get(scheme.contrastLevel);\n const fContrast = farther.contrastCurve!.get(scheme.contrastLevel);\n\n // If a color is good enough, it is not adjusted.\n // Initial and adjusted tones for `nearer`\n const nInitialTone = nearer.tone(scheme);\n let nTone = Contrast.ratioOfTones(bgTone, nInitialTone) >= nContrast ?\n nInitialTone :\n DynamicColor.foregroundTone(bgTone, nContrast);\n // Initial and adjusted tones for `farther`\n const fInitialTone = farther.tone(scheme);\n let fTone = Contrast.ratioOfTones(bgTone, fInitialTone) >= fContrast ?\n fInitialTone :\n DynamicColor.foregroundTone(bgTone, fContrast);\n\n if (decreasingContrast) {\n // If decreasing contrast, adjust color to the \"bare minimum\"\n // that satisfies contrast.\n nTone = DynamicColor.foregroundTone(bgTone, nContrast);\n fTone = DynamicColor.foregroundTone(bgTone, fContrast);\n }\n\n if ((fTone - nTone) * expansionDir >= delta) {\n // Good! Tones satisfy the constraint; no change needed.\n } else {\n // 2nd round: expand farther to match delta.\n fTone = math.clampDouble(0, 100, nTone + delta * expansionDir);\n if ((fTone - nTone) * expansionDir >= delta) {\n // Good! Tones now satisfy the constraint; no change needed.\n } else {\n // 3rd round: contract nearer to match delta.\n nTone = math.clampDouble(0, 100, fTone - delta * expansionDir);\n }\n }\n\n // Avoids the 50-59 awkward zone.\n if (50 <= nTone && nTone < 60) {\n // If `nearer` is in the awkward zone, move it away, together with\n // `farther`.\n if (expansionDir > 0) {\n nTone = 60;\n fTone = Math.max(fTone, nTone + delta * expansionDir);\n } else {\n nTone = 49;\n fTone = Math.min(fTone, nTone + delta * expansionDir);\n }\n } else if (50 <= fTone && fTone < 60) {\n if (stayTogether) {\n // Fixes both, to avoid two colors on opposite sides of the \"awkward\n // zone\".\n if (expansionDir > 0) {\n nTone = 60;\n fTone = Math.max(fTone, nTone + delta * expansionDir);\n } else {\n nTone = 49;\n fTone = Math.min(fTone, nTone + delta * expansionDir);\n }\n } else {\n // Not required to stay together; fixes just one.\n if (expansionDir > 0) {\n fTone = 60;\n } else {\n fTone = 49;\n }\n }\n }\n\n // Returns `nTone` if this color is `nearer`, otherwise `fTone`.\n return amNearer ? nTone : fTone;\n }\n\n else {\n // Case 2: No contrast pair; just solve for itself.\n let answer = this.tone(scheme);\n\n if (this.background == null) {\n return answer; // No adjustment for colors with no background.\n }\n\n const bgTone = this.background(scheme).getTone(scheme);\n\n const desiredRatio = this.contrastCurve!.get(scheme.contrastLevel);\n\n if (Contrast.ratioOfTones(bgTone, answer) >= desiredRatio) {\n // Don't \"improve\" what's good enough.\n } else {\n // Rough improvement.\n answer = DynamicColor.foregroundTone(bgTone, desiredRatio);\n }\n\n if (decreasingContrast) {\n answer = DynamicColor.foregroundTone(bgTone, desiredRatio);\n }\n\n if (this.isBackground && 50 <= answer && answer < 60) {\n // Must adjust\n if (Contrast.ratioOfTones(49, bgTone) >= desiredRatio) {\n answer = 49;\n } else {\n answer = 60;\n }\n }\n\n if (this.secondBackground) {\n // Case 3: Adjust for dual backgrounds.\n\n const [bg1, bg2] = [this.background, this.secondBackground];\n const [bgTone1, bgTone2] =\n [bg1(scheme).getTone(scheme), bg2(scheme).getTone(scheme)];\n const [upper, lower] =\n [Math.max(bgTone1, bgTone2), Math.min(bgTone1, bgTone2)];\n\n if (Contrast.ratioOfTones(upper, answer) >= desiredRatio &&\n Contrast.ratioOfTones(lower, answer) >= desiredRatio) {\n return answer;\n }\n\n // The darkest light tone that satisfies the desired ratio,\n // or -1 if such ratio cannot be reached.\n const lightOption = Contrast.lighter(upper, desiredRatio);\n\n // The lightest dark tone that satisfies the desired ratio,\n // or -1 if such ratio cannot be reached.\n const darkOption = Contrast.darker(lower, desiredRatio);\n\n // Tones suitable for the foreground.\n const availables = [];\n if (lightOption !== -1) availables.push(lightOption);\n if (darkOption !== -1) availables.push(darkOption);\n\n const prefersLight = DynamicColor.tonePrefersLightForeground(bgTone1) ||\n DynamicColor.tonePrefersLightForeground(bgTone2);\n if (prefersLight) {\n return (lightOption < 0) ? 100 : lightOption;\n }\n if (availables.length === 1) {\n return availables[0];\n }\n return (darkOption < 0) ? 0 : darkOption;\n }\n\n return answer;\n }\n }\n\n /**\n * Given a background tone, find a foreground tone, while ensuring they reach\n * a contrast ratio that is as close to [ratio] as possible.\n *\n * @param bgTone Tone in HCT. Range is 0 to 100, undefined behavior when it\n * falls outside that range.\n * @param ratio The contrast ratio desired between bgTone and the return\n * value.\n */\n static foregroundTone(bgTone: number, ratio: number): number {\n const lighterTone = Contrast.lighterUnsafe(bgTone, ratio);\n const darkerTone = Contrast.darkerUnsafe(bgTone, ratio);\n const lighterRatio = Contrast.ratioOfTones(lighterTone, bgTone);\n const darkerRatio = Contrast.ratioOfTones(darkerTone, bgTone);\n const preferLighter = DynamicColor.tonePrefersLightForeground(bgTone);\n\n if (preferLighter) {\n // This handles an edge case where the initial contrast ratio is high\n // (ex. 13.0), and the ratio passed to the function is that high\n // ratio, and both the lighter and darker ratio fails to pass that\n // ratio.\n //\n // This was observed with Tonal Spot's On Primary Container turning\n // black momentarily between high and max contrast in light mode. PC's\n // standard tone was T90, OPC's was T10, it was light mode, and the\n // contrast value was 0.6568521221032331.\n const negligibleDifference = Math.abs(lighterRatio - darkerRatio) < 0.1 &&\n lighterRatio < ratio && darkerRatio < ratio;\n return lighterRatio >= ratio || lighterRatio >= darkerRatio ||\n negligibleDifference ?\n lighterTone :\n darkerTone;\n } else {\n return darkerRatio >= ratio || darkerRatio >= lighterRatio ? darkerTone :\n lighterTone;\n }\n }\n\n /**\n * Returns whether [tone] prefers a light foreground.\n *\n * People prefer white foregrounds on ~T60-70. Observed over time, and also\n * by Andrew Somers during research for APCA.\n *\n * T60 used as to create the smallest discontinuity possible when skipping\n * down to T49 in order to ensure light foregrounds.\n * Since `tertiaryContainer` in dark monochrome scheme requires a tone of\n * 60, it should not be adjusted. Therefore, 60 is excluded here.\n */\n static tonePrefersLightForeground(tone: number): boolean {\n return Math.round(tone) < 60.0;\n }\n\n /**\n * Returns whether [tone] can reach a contrast ratio of 4.5 with a lighter\n * color.\n */\n static toneAllowsLightForeground(tone: number): boolean {\n return Math.round(tone) <= 49.0;\n }\n\n /**\n * Adjust a tone such that white has 4.5 contrast, if the tone is\n * reasonably close to supporting it.\n */\n static enableLightForeground(tone: number): number {\n if (DynamicColor.tonePrefersLightForeground(tone) &&\n !DynamicColor.toneAllowsLightForeground(tone)) {\n return 49.0;\n }\n return tone;\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Hct} from '../hct/hct.js';\n\n/**\n * A convenience class for retrieving colors that are constant in hue and\n * chroma, but vary in tone.\n */\nexport class TonalPalette {\n private readonly cache = new Map<number, number>();\n\n /**\n * @param argb ARGB representation of a color\n * @return Tones matching that color's hue and chroma.\n */\n static fromInt(argb: number): TonalPalette {\n const hct = Hct.fromInt(argb);\n return TonalPalette.fromHct(hct);\n }\n\n /**\n * @param hct Hct\n * @return Tones matching that color's hue and chroma.\n */\n static fromHct(hct: Hct) {\n return new TonalPalette(hct.hue, hct.chroma, hct);\n }\n\n /**\n * @param hue HCT hue\n * @param chroma HCT chroma\n * @return Tones matching hue and chroma.\n */\n static fromHueAndChroma(hue: number, chroma: number): TonalPalette {\n const keyColor = new KeyColor(hue, chroma).create();\n return new TonalPalette(hue, chroma, keyColor);\n }\n\n private constructor(readonly hue: number, readonly chroma: number, readonly keyColor: Hct) {}\n\n /**\n * @param tone HCT tone, measured from 0 to 100.\n * @return ARGB representation of a color with that tone.\n */\n tone(tone: number): number {\n let argb = this.cache.get(tone);\n if (argb === undefined) {\n argb = Hct.from(this.hue, this.chroma, tone).toInt();\n this.cache.set(tone, argb);\n }\n return argb;\n }\n\n /**\n * @param tone HCT tone.\n * @return HCT representation of a color with that tone.\n */\n getHct(tone: number): Hct {\n return Hct.fromInt(this.tone(tone));\n }\n}\n\n/**\n * Key color is a color that represents the hue and chroma of a tonal palette\n */\nclass KeyColor {\n // Cache that maps tone to max chroma to avoid duplicated HCT calculation.\n private readonly chromaCache = new Map<number, number>();\n private readonly maxChromaValue = 200.0;\n\n constructor(readonly hue: number, readonly requestedChroma: number) {}\n\n /**\n * Creates a key color from a [hue] and a [chroma].\n * The key color is the first tone, starting from T50, matching the given hue\n * and chroma.\n *\n * @return Key color [Hct]\n */\n create(): Hct {\n // Pivot around T50 because T50 has the most chroma available, on\n // average. Thus it is most likely to have a direct answer.\n const pivotTone = 50;\n const toneStepSize = 1;\n // Epsilon to accept values slightly higher than the requested chroma.\n const epsilon = 0.01;\n\n // Binary search to find the tone that can provide a chroma that is closest\n // to the requested chroma.\n let lowerTone = 0;\n let upperTone = 100;\n while (lowerTone < upperTone) {\n const midTone = Math.floor((lowerTone + upperTone) / 2);\n const isAscending =\n this.maxChroma(midTone) < this.maxChroma(midTone + toneStepSize);\n const sufficientChroma =\n this.maxChroma(midTone) >= this.requestedChroma - epsilon;\n\n if (sufficientChroma) {\n // Either range [lowerTone, midTone] or [midTone, upperTone] has\n // the answer, so search in the range that is closer the pivot tone.\n if (Math.abs(lowerTone - pivotTone) < Math.abs(upperTone - pivotTone)) {\n upperTone = midTone;\n } else {\n if (lowerTone === midTone) {\n return Hct.from(this.hue, this.requestedChroma, lowerTone);\n }\n lowerTone = midTone;\n }\n } else {\n // As there is no sufficient chroma in the midTone, follow the direction\n // to the chroma peak.\n if (isAscending) {\n lowerTone = midTone + toneStepSize;\n } else {\n // Keep midTone for potential chroma peak.\n upperTone = midTone;\n }\n }\n }\n\n return Hct.from(this.hue, this.requestedChroma, lowerTone);\n }\n\n // Find the maximum chroma for a given tone\n private maxChroma(tone: number): number {\n if (this.chromaCache.has(tone)) {\n return this.chromaCache.get(tone)!;\n }\n const chroma = Hct.from(this.hue, this.maxChromaValue, tone).chroma;\n this.chromaCache.set(tone, chroma);\n return chroma;\n }\n}\n", "/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as math from '../utils/math_utils.js';\n\n/**\n * A class containing a value that changes with the contrast level.\n *\n * Usually represents the contrast requirements for a dynamic color on its\n * background. The four values correspond to values for contrast levels -1.0,\n * 0.0, 0.5, and 1.0, respectively.\n */\nexport class ContrastCurve {\n /**\n * Creates a `ContrastCurve` object.\n *\n * @param low Value for contrast level -1.0\n * @param normal Value for contrast level 0.0\n * @param medium Value for contrast level 0.5\n * @param high Value for contrast level 1.0\n */\n constructor(\n readonly low: number,\n readonly normal: number,\n readonly medium: number,\n readonly high: number,\n ) {}\n\n /**\n * Returns the value at a given contrast level.\n *\n * @param contrastLevel The contrast level. 0.0 is the default (normal); -1.0\n * is the lowest; 1.0 is the highest.\n * @return The value. For contrast ratios, a number between 1.0 and 21.0.\n */\n get(contrastLevel: number): number {\n if (contrastLevel <= -1.0) {\n return this.low;\n } else if (contrastLevel < 0.0) {\n return math.lerp(this.low, this.normal, (contrastLevel - (-1)) / 1);\n } else if (contrastLevel < 0.5) {\n return math.lerp(this.normal, this.medium, (contrastLevel - 0) / 0.5);\n } else if (contrastLevel < 1.0) {\n return math.lerp(this.medium, this.high, (contrastLevel - 0.5) / 0.5);\n } else {\n return this.high;\n }\n }\n}\n", "/**\n * @license\n * Copyright 2023 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {DynamicColor} from './dynamic_color.js';\n\n/**\n * Describes the different in tone between colors.\n */\nexport type TonePolarity = 'darker'|'lighter'|'nearer'|'farther';\n\n/**\n * Documents a constraint between two DynamicColors, in which their tones must\n * have a certain distance from each other.\n *\n * Prefer a DynamicColor with a background, this is for special cases when\n * designers want tonal distance, literally contrast, between two colors that\n * don't have a background / foreground relationship or a contrast guarantee.\n */\nexport class ToneDeltaPair {\n /**\n * Documents a constraint in tone distance between two DynamicColors.\n *\n * The polarity is an adjective that describes \"A\", compared to \"B\".\n *\n * For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that\n * A's tone should be at least 15 darker than B's.\n *\n * 'nearer' and 'farther' describes closeness to the surface roles. For\n * instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A\n * should be 10 lighter than B in light mode, and 10 darker than B in dark\n * mode.\n *\n * @param roleA The first role in a pair.\n * @param roleB The second role in a pair.\n * @param delta Required difference between tones. Absolute value, negative\n * values have undefined behavior.\n * @param polarity The relative relation between tones of roleA and roleB,\n * as described above.\n * @param stayTogether Whether these two roles should stay on the same side of\n * the \"awkward zone\" (T50-59). This is necessary for certain cases where\n * one role has two backgrounds.\n */\n constructor(\n readonly roleA: DynamicColor,\n readonly roleB: DynamicColor,\n readonly delta: number,\n readonly polarity: TonePolarity,\n readonly stayTogether: boolean,\n ) {}\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Set of themes supported by Dynamic Color.\n * Instantiate the corresponding subclass, ex. SchemeTonalSpot, to create\n * colors corresponding to the theme.\n */\nexport enum Variant {\n MONOCHROME,\n NEUTRAL,\n TONAL_SPOT,\n VIBRANT,\n EXPRESSIVE,\n FIDELITY,\n CONTENT,\n RAINBOW,\n FRUIT_SALAD\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {DislikeAnalyzer} from '../dislike/dislike_analyzer.js';\nimport {Hct} from '../hct/hct.js';\n\nimport {ContrastCurve} from './contrast_curve.js';\nimport {DynamicColor} from './dynamic_color.js';\nimport {DynamicScheme} from './dynamic_scheme.js';\nimport {ToneDeltaPair} from './tone_delta_pair.js';\nimport {Variant} from './variant.js';\n\nfunction isFidelity(scheme: DynamicScheme): boolean {\n return scheme.variant === Variant.FIDELITY ||\n scheme.variant === Variant.CONTENT;\n}\n\nfunction isMonochrome(scheme: DynamicScheme): boolean {\n return scheme.variant === Variant.MONOCHROME;\n}\n\nfunction findDesiredChromaByTone(\n hue: number, chroma: number, tone: number,\n byDecreasingTone: boolean): number {\n let answer = tone;\n\n let closestToChroma = Hct.from(hue, chroma, tone);\n if (closestToChroma.chroma < chroma) {\n let chromaPeak = closestToChroma.chroma;\n while (closestToChroma.chroma < chroma) {\n answer += byDecreasingTone ? -1.0 : 1.0;\n const potentialSolution = Hct.from(hue, chroma, answer);\n if (chromaPeak > potentialSolution.chroma) {\n break;\n }\n if (Math.abs(potentialSolution.chroma - chroma) < 0.4) {\n break;\n }\n\n const potentialDelta = Math.abs(potentialSolution.chroma - chroma);\n const currentDelta = Math.abs(closestToChroma.chroma - chroma);\n if (potentialDelta < currentDelta) {\n closestToChroma = potentialSolution;\n }\n chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);\n }\n }\n\n return answer;\n}\n\n/**\n * DynamicColors for the colors in the Material Design system.\n */\n// Material Color Utilities namespaces the various utilities it provides.\n// tslint:disable-next-line:class-as-namespace\nexport class MaterialDynamicColors {\n static contentAccentToneDelta = 15.0;\n static highestSurface(s: DynamicScheme): DynamicColor {\n return s.isDark ? MaterialDynamicColors.surfaceBright :\n MaterialDynamicColors.surfaceDim;\n }\n\n static primaryPaletteKeyColor = DynamicColor.fromPalette({\n name: 'primary_palette_key_color',\n palette: (s) => s.primaryPalette,\n tone: (s) => s.primaryPalette.keyColor.tone,\n });\n\n static secondaryPaletteKeyColor = DynamicColor.fromPalette({\n name: 'secondary_palette_key_color',\n palette: (s) => s.secondaryPalette,\n tone: (s) => s.secondaryPalette.keyColor.tone,\n });\n\n static tertiaryPaletteKeyColor = DynamicColor.fromPalette({\n name: 'tertiary_palette_key_color',\n palette: (s) => s.tertiaryPalette,\n tone: (s) => s.tertiaryPalette.keyColor.tone,\n });\n\n static neutralPaletteKeyColor = DynamicColor.fromPalette({\n name: 'neutral_palette_key_color',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.neutralPalette.keyColor.tone,\n });\n\n static neutralVariantPaletteKeyColor = DynamicColor.fromPalette({\n name: 'neutral_variant_palette_key_color',\n palette: (s) => s.neutralVariantPalette,\n tone: (s) => s.neutralVariantPalette.keyColor.tone,\n });\n\n static background = DynamicColor.fromPalette({\n name: 'background',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 6 : 98,\n isBackground: true,\n });\n\n static onBackground = DynamicColor.fromPalette({\n name: 'on_background',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 90 : 10,\n background: (s) => MaterialDynamicColors.background,\n contrastCurve: new ContrastCurve(3, 3, 4.5, 7),\n });\n\n static surface = DynamicColor.fromPalette({\n name: 'surface',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 6 : 98,\n isBackground: true,\n });\n\n static surfaceDim = DynamicColor.fromPalette({\n name: 'surface_dim',\n palette: (s) => s.neutralPalette,\n tone: (s) =>\n s.isDark ? 6 : new ContrastCurve(87, 87, 80, 75).get(s.contrastLevel),\n isBackground: true,\n });\n\n static surfaceBright = DynamicColor.fromPalette({\n name: 'surface_bright',\n palette: (s) => s.neutralPalette,\n tone: (s) =>\n s.isDark ? new ContrastCurve(24, 24, 29, 34).get(s.contrastLevel) : 98,\n isBackground: true,\n });\n\n static surfaceContainerLowest = DynamicColor.fromPalette({\n name: 'surface_container_lowest',\n palette: (s) => s.neutralPalette,\n tone: (s) =>\n s.isDark ? new ContrastCurve(4, 4, 2, 0).get(s.contrastLevel) : 100,\n isBackground: true,\n });\n\n static surfaceContainerLow = DynamicColor.fromPalette({\n name: 'surface_container_low',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ?\n new ContrastCurve(10, 10, 11, 12).get(s.contrastLevel) :\n new ContrastCurve(96, 96, 96, 95).get(s.contrastLevel),\n isBackground: true,\n });\n\n static surfaceContainer = DynamicColor.fromPalette({\n name: 'surface_container',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ?\n new ContrastCurve(12, 12, 16, 20).get(s.contrastLevel) :\n new ContrastCurve(94, 94, 92, 90).get(s.contrastLevel),\n isBackground: true,\n });\n\n static surfaceContainerHigh = DynamicColor.fromPalette({\n name: 'surface_container_high',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ?\n new ContrastCurve(17, 17, 21, 25).get(s.contrastLevel) :\n new ContrastCurve(92, 92, 88, 85).get(s.contrastLevel),\n isBackground: true,\n });\n\n static surfaceContainerHighest = DynamicColor.fromPalette({\n name: 'surface_container_highest',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ?\n new ContrastCurve(22, 22, 26, 30).get(s.contrastLevel) :\n new ContrastCurve(90, 90, 84, 80).get(s.contrastLevel),\n isBackground: true,\n });\n\n static onSurface = DynamicColor.fromPalette({\n name: 'on_surface',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 90 : 10,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static surfaceVariant = DynamicColor.fromPalette({\n name: 'surface_variant',\n palette: (s) => s.neutralVariantPalette,\n tone: (s) => s.isDark ? 30 : 90,\n isBackground: true,\n });\n\n static onSurfaceVariant = DynamicColor.fromPalette({\n name: 'on_surface_variant',\n palette: (s) => s.neutralVariantPalette,\n tone: (s) => s.isDark ? 80 : 30,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static inverseSurface = DynamicColor.fromPalette({\n name: 'inverse_surface',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 90 : 20,\n });\n\n static inverseOnSurface = DynamicColor.fromPalette({\n name: 'inverse_on_surface',\n palette: (s) => s.neutralPalette,\n tone: (s) => s.isDark ? 20 : 95,\n background: (s) => MaterialDynamicColors.inverseSurface,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static outline = DynamicColor.fromPalette({\n name: 'outline',\n palette: (s) => s.neutralVariantPalette,\n tone: (s) => s.isDark ? 60 : 50,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7),\n });\n\n static outlineVariant = DynamicColor.fromPalette({\n name: 'outline_variant',\n palette: (s) => s.neutralVariantPalette,\n tone: (s) => s.isDark ? 30 : 80,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n });\n\n static shadow = DynamicColor.fromPalette({\n name: 'shadow',\n palette: (s) => s.neutralPalette,\n tone: (s) => 0,\n });\n\n static scrim = DynamicColor.fromPalette({\n name: 'scrim',\n palette: (s) => s.neutralPalette,\n tone: (s) => 0,\n });\n\n static surfaceTint = DynamicColor.fromPalette({\n name: 'surface_tint',\n palette: (s) => s.primaryPalette,\n tone: (s) => s.isDark ? 80 : 40,\n isBackground: true,\n });\n\n static primary = DynamicColor.fromPalette({\n name: 'primary',\n palette: (s) => s.primaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 100 : 0;\n }\n return s.isDark ? 80 : 40;\n },\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(3, 4.5, 7, 7),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary,\n 10, 'nearer', false),\n });\n\n static onPrimary = DynamicColor.fromPalette({\n name: 'on_primary',\n palette: (s) => s.primaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 10 : 90;\n }\n return s.isDark ? 20 : 100;\n },\n background: (s) => MaterialDynamicColors.primary,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static primaryContainer = DynamicColor.fromPalette({\n name: 'primary_container',\n palette: (s) => s.primaryPalette,\n tone:\n (s) => {\n if (isFidelity(s)) {\n return s.sourceColorHct.tone;\n }\n if (isMonochrome(s)) {\n return s.isDark ? 85 : 25;\n }\n return s.isDark ? 30 : 90;\n },\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary,\n 10, 'nearer', false),\n });\n\n static onPrimaryContainer = DynamicColor.fromPalette({\n name: 'on_primary_container',\n palette: (s) => s.primaryPalette,\n tone:\n (s) => {\n if (isFidelity(s)) {\n return DynamicColor.foregroundTone(\n MaterialDynamicColors.primaryContainer.tone(s), 4.5);\n }\n if (isMonochrome(s)) {\n return s.isDark ? 0 : 100;\n }\n return s.isDark ? 90 : 30;\n },\n background: (s) => MaterialDynamicColors.primaryContainer,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static inversePrimary = DynamicColor.fromPalette({\n name: 'inverse_primary',\n palette: (s) => s.primaryPalette,\n tone: (s) => s.isDark ? 40 : 80,\n background: (s) => MaterialDynamicColors.inverseSurface,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 7),\n });\n\n static secondary = DynamicColor.fromPalette({\n name: 'secondary',\n palette: (s) => s.secondaryPalette,\n tone: (s) => s.isDark ? 80 : 40,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(3, 4.5, 7, 7),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.secondaryContainer,\n MaterialDynamicColors.secondary, 10, 'nearer', false),\n });\n\n static onSecondary = DynamicColor.fromPalette({\n name: 'on_secondary',\n palette: (s) => s.secondaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 10 : 100;\n } else {\n return s.isDark ? 20 : 100;\n }\n },\n background: (s) => MaterialDynamicColors.secondary,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static secondaryContainer = DynamicColor.fromPalette({\n name: 'secondary_container',\n palette: (s) => s.secondaryPalette,\n tone:\n (s) => {\n const initialTone = s.isDark ? 30 : 90;\n if (isMonochrome(s)) {\n return s.isDark ? 30 : 85;\n }\n if (!isFidelity(s)) {\n return initialTone;\n }\n return findDesiredChromaByTone(\n s.secondaryPalette.hue, s.secondaryPalette.chroma, initialTone,\n s.isDark ? false : true);\n },\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.secondaryContainer,\n MaterialDynamicColors.secondary, 10, 'nearer', false),\n });\n\n static onSecondaryContainer = DynamicColor.fromPalette({\n name: 'on_secondary_container',\n palette: (s) => s.secondaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 90 : 10;\n }\n if (!isFidelity(s)) {\n return s.isDark ? 90 : 30;\n }\n return DynamicColor.foregroundTone(\n MaterialDynamicColors.secondaryContainer.tone(s), 4.5);\n },\n background: (s) => MaterialDynamicColors.secondaryContainer,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static tertiary = DynamicColor.fromPalette({\n name: 'tertiary',\n palette: (s) => s.tertiaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 90 : 25;\n }\n return s.isDark ? 80 : 40;\n },\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(3, 4.5, 7, 7),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary,\n 10, 'nearer', false),\n });\n\n static onTertiary = DynamicColor.fromPalette({\n name: 'on_tertiary',\n palette: (s) => s.tertiaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 10 : 90;\n }\n return s.isDark ? 20 : 100;\n },\n background: (s) => MaterialDynamicColors.tertiary,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static tertiaryContainer = DynamicColor.fromPalette({\n name: 'tertiary_container',\n palette: (s) => s.tertiaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 60 : 49;\n }\n if (!isFidelity(s)) {\n return s.isDark ? 30 : 90;\n }\n const proposedHct = s.tertiaryPalette.getHct(s.sourceColorHct.tone);\n return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;\n },\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary,\n 10, 'nearer', false),\n });\n\n static onTertiaryContainer = DynamicColor.fromPalette({\n name: 'on_tertiary_container',\n palette: (s) => s.tertiaryPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 0 : 100;\n }\n if (!isFidelity(s)) {\n return s.isDark ? 90 : 30;\n }\n return DynamicColor.foregroundTone(\n MaterialDynamicColors.tertiaryContainer.tone(s), 4.5);\n },\n background: (s) => MaterialDynamicColors.tertiaryContainer,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static error = DynamicColor.fromPalette({\n name: 'error',\n palette: (s) => s.errorPalette,\n tone: (s) => s.isDark ? 80 : 40,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(3, 4.5, 7, 7),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 10,\n 'nearer', false),\n });\n\n static onError = DynamicColor.fromPalette({\n name: 'on_error',\n palette: (s) => s.errorPalette,\n tone: (s) => s.isDark ? 20 : 100,\n background: (s) => MaterialDynamicColors.error,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static errorContainer = DynamicColor.fromPalette({\n name: 'error_container',\n palette: (s) => s.errorPalette,\n tone: (s) => s.isDark ? 30 : 90,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 10,\n 'nearer', false),\n });\n\n static onErrorContainer = DynamicColor.fromPalette({\n name: 'on_error_container',\n palette: (s) => s.errorPalette,\n tone:\n (s) => {\n if (isMonochrome(s)) {\n return s.isDark ? 90 : 10;\n }\n return s.isDark ? 90 : 30;\n },\n background: (s) => MaterialDynamicColors.errorContainer,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static primaryFixed = DynamicColor.fromPalette({\n name: 'primary_fixed',\n palette: (s) => s.primaryPalette,\n tone: (s) => isMonochrome(s) ? 40.0 : 90.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.primaryFixed,\n MaterialDynamicColors.primaryFixedDim, 10, 'lighter', true),\n });\n\n static primaryFixedDim = DynamicColor.fromPalette({\n name: 'primary_fixed_dim',\n palette: (s) => s.primaryPalette,\n tone: (s) => isMonochrome(s) ? 30.0 : 80.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.primaryFixed,\n MaterialDynamicColors.primaryFixedDim, 10, 'lighter', true),\n });\n\n static onPrimaryFixed = DynamicColor.fromPalette({\n name: 'on_primary_fixed',\n palette: (s) => s.primaryPalette,\n tone: (s) => isMonochrome(s) ? 100.0 : 10.0,\n background: (s) => MaterialDynamicColors.primaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.primaryFixed,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static onPrimaryFixedVariant = DynamicColor.fromPalette({\n name: 'on_primary_fixed_variant',\n palette: (s) => s.primaryPalette,\n tone: (s) => isMonochrome(s) ? 90.0 : 30.0,\n background: (s) => MaterialDynamicColors.primaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.primaryFixed,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static secondaryFixed = DynamicColor.fromPalette({\n name: 'secondary_fixed',\n palette: (s) => s.secondaryPalette,\n tone: (s) => isMonochrome(s) ? 80.0 : 90.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.secondaryFixed,\n MaterialDynamicColors.secondaryFixedDim, 10, 'lighter', true),\n });\n\n static secondaryFixedDim = DynamicColor.fromPalette({\n name: 'secondary_fixed_dim',\n palette: (s) => s.secondaryPalette,\n tone: (s) => isMonochrome(s) ? 70.0 : 80.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.secondaryFixed,\n MaterialDynamicColors.secondaryFixedDim, 10, 'lighter', true),\n });\n\n static onSecondaryFixed = DynamicColor.fromPalette({\n name: 'on_secondary_fixed',\n palette: (s) => s.secondaryPalette,\n tone: (s) => 10.0,\n background: (s) => MaterialDynamicColors.secondaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.secondaryFixed,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static onSecondaryFixedVariant = DynamicColor.fromPalette({\n name: 'on_secondary_fixed_variant',\n palette: (s) => s.secondaryPalette,\n tone: (s) => isMonochrome(s) ? 25.0 : 30.0,\n background: (s) => MaterialDynamicColors.secondaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.secondaryFixed,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n\n static tertiaryFixed = DynamicColor.fromPalette({\n name: 'tertiary_fixed',\n palette: (s) => s.tertiaryPalette,\n tone: (s) => isMonochrome(s) ? 40.0 : 90.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.tertiaryFixed,\n MaterialDynamicColors.tertiaryFixedDim, 10, 'lighter', true),\n });\n\n static tertiaryFixedDim = DynamicColor.fromPalette({\n name: 'tertiary_fixed_dim',\n palette: (s) => s.tertiaryPalette,\n tone: (s) => isMonochrome(s) ? 30.0 : 80.0,\n isBackground: true,\n background: (s) => MaterialDynamicColors.highestSurface(s),\n contrastCurve: new ContrastCurve(1, 1, 3, 4.5),\n toneDeltaPair: (s) => new ToneDeltaPair(\n MaterialDynamicColors.tertiaryFixed,\n MaterialDynamicColors.tertiaryFixedDim, 10, 'lighter', true),\n });\n\n static onTertiaryFixed = DynamicColor.fromPalette({\n name: 'on_tertiary_fixed',\n palette: (s) => s.tertiaryPalette,\n tone: (s) => isMonochrome(s) ? 100.0 : 10.0,\n background: (s) => MaterialDynamicColors.tertiaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.tertiaryFixed,\n contrastCurve: new ContrastCurve(4.5, 7, 11, 21),\n });\n\n static onTertiaryFixedVariant = DynamicColor.fromPalette({\n name: 'on_tertiary_fixed_variant',\n palette: (s) => s.tertiaryPalette,\n tone: (s) => isMonochrome(s) ? 90.0 : 30.0,\n background: (s) => MaterialDynamicColors.tertiaryFixedDim,\n secondBackground: (s) => MaterialDynamicColors.tertiaryFixed,\n contrastCurve: new ContrastCurve(3, 4.5, 7, 11),\n });\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Hct} from '../hct/hct.js';\nimport {TonalPalette} from '../palettes/tonal_palette.js';\nimport * as math from '../utils/math_utils.js';\n\nimport {DynamicColor} from './dynamic_color.js';\nimport {MaterialDynamicColors} from './material_dynamic_colors.js';\nimport {Variant} from './variant.js';\n\n/**\n * @param sourceColorArgb The source color of the theme as an ARGB 32-bit\n * integer.\n * @param variant The variant, or style, of the theme.\n * @param contrastLevel Value from -1 to 1. -1 represents minimum contrast,\n * 0 represents standard (i.e. the design as spec'd), and 1 represents maximum\n * contrast.\n * @param isDark Whether the scheme is in dark mode or light mode.\n * @param primaryPalette Given a tone, produces a color. Hue and chroma of the\n * color are specified in the design specification of the variant. Usually\n * colorful.\n * @param secondaryPalette Given a tone, produces a color. Hue and chroma of\n * the color are specified in the design specification of the variant. Usually\n * less colorful.\n * @param tertiaryPalette Given a tone, produces a color. Hue and chroma of\n * the color are specified in the design specification of the variant. Usually\n * a different hue from primary and colorful.\n * @param neutralPalette Given a tone, produces a color. Hue and chroma of the\n * color are specified in the design specification of the variant. Usually not\n * colorful at all, intended for background & surface colors.\n * @param neutralVariantPalette Given a tone, produces a color. Hue and chroma\n * of the color are specified in the design specification of the variant.\n * Usually not colorful, but slightly more colorful than Neutral. Intended for\n * backgrounds & surfaces.\n */\ninterface DynamicSchemeOptions {\n sourceColorArgb: number;\n variant: Variant;\n contrastLevel: number;\n isDark: boolean;\n primaryPalette: TonalPalette;\n secondaryPalette: TonalPalette;\n tertiaryPalette: TonalPalette;\n neutralPalette: TonalPalette;\n neutralVariantPalette: TonalPalette;\n}\n\n/**\n * Constructed by a set of values representing the current UI state (such as\n * whether or not its dark theme, what the theme style is, etc.), and\n * provides a set of TonalPalettes that can create colors that fit in\n * with the theme style. Used by DynamicColor to resolve into a color.\n */\nexport class DynamicScheme {\n /**\n * The source color of the theme as an HCT color.\n */\n sourceColorHct: Hct;\n /**\n * Given a tone, produces a reddish, colorful, color.\n */\n errorPalette: TonalPalette;\n\n /** The source color of the theme as an ARGB 32-bit integer. */\n readonly sourceColorArgb: number;\n\n /** The variant, or style, of the theme. */\n readonly variant: Variant;\n\n /**\n * Value from -1 to 1. -1 represents minimum contrast. 0 represents standard\n * (i.e. the design as spec'd), and 1 represents maximum contrast.\n */\n readonly contrastLevel: number;\n\n /** Whether the scheme is in dark mode or light mode. */\n readonly isDark: boolean;\n\n /**\n * Given a tone, produces a color. Hue and chroma of the\n * color are specified in the design specification of the variant. Usually\n * colorful.\n */\n readonly primaryPalette: TonalPalette;\n\n /**\n * Given a tone, produces a color. Hue and chroma of\n * the color are specified in the design specification of the variant. Usually\n * less colorful.\n */\n readonly secondaryPalette: TonalPalette;\n\n /**\n * Given a tone, produces a color. Hue and chroma of\n * the color are specified in the design specification of the variant. Usually\n * a different hue from primary and colorful.\n */\n readonly tertiaryPalette: TonalPalette;\n\n /**\n * Given a tone, produces a color. Hue and chroma of the\n * color are specified in the design specification of the variant. Usually not\n * colorful at all, intended for background & surface colors.\n */\n readonly neutralPalette: TonalPalette;\n\n /**\n * Given a tone, produces a color. Hue and chroma\n * of the color are specified in the design specification of the variant.\n * Usually not colorful, but slightly more colorful than Neutral. Intended for\n * backgrounds & surfaces.\n */\n readonly neutralVariantPalette: TonalPalette;\n\n constructor(args: DynamicSchemeOptions) {\n this.sourceColorArgb = args.sourceColorArgb;\n this.variant = args.variant;\n this.contrastLevel = args.contrastLevel;\n this.isDark = args.isDark;\n this.sourceColorHct = Hct.fromInt(args.sourceColorArgb);\n this.primaryPalette = args.primaryPalette;\n this.secondaryPalette = args.secondaryPalette;\n this.tertiaryPalette = args.tertiaryPalette;\n this.neutralPalette = args.neutralPalette;\n this.neutralVariantPalette = args.neutralVariantPalette;\n this.errorPalette = TonalPalette.fromHueAndChroma(25.0, 84.0);\n }\n\n /**\n * Support design spec'ing Dynamic Color by schemes that specify hue\n * rotations that should be applied at certain breakpoints.\n * @param sourceColor the source color of the theme, in HCT.\n * @param hues The \"breakpoints\", i.e. the hues at which a rotation should\n * be apply.\n * @param rotations The rotation that should be applied when source color's\n * hue is >= the same index in hues array, and <= the hue at the next index\n * in hues array.\n */\n static getRotatedHue(sourceColor: Hct, hues: number[], rotations: number[]):\n number {\n const sourceHue = sourceColor.hue;\n if (hues.length !== rotations.length) {\n throw new Error(`mismatch between hue length ${hues.length} & rotations ${\n rotations.length}`);\n }\n if (rotations.length === 1) {\n return math.sanitizeDegreesDouble(sourceColor.hue + rotations[0]);\n }\n const size = hues.length;\n for (let i = 0; i <= size - 2; i++) {\n const thisHue = hues[i];\n const nextHue = hues[i + 1];\n if (thisHue < sourceHue && sourceHue < nextHue) {\n return math.sanitizeDegreesDouble(sourceHue + rotations[i]);\n }\n }\n // If this statement executes, something is wrong, there should have been a\n // rotation found using the arrays.\n return sourceHue;\n }\n\n\n getArgb(dynamicColor: DynamicColor): number {\n return dynamicColor.getArgb(this);\n }\n\n getHct(dynamicColor: DynamicColor): Hct {\n return dynamicColor.getHct(this);\n }\n\n get primaryPaletteKeyColor(): number {\n return this.getArgb(MaterialDynamicColors.primaryPaletteKeyColor);\n }\n\n get secondaryPaletteKeyColor(): number {\n return this.getArgb(MaterialDynamicColors.secondaryPaletteKeyColor);\n }\n\n get tertiaryPaletteKeyColor(): number {\n return this.getArgb(MaterialDynamicColors.tertiaryPaletteKeyColor);\n }\n\n get neutralPaletteKeyColor(): number {\n return this.getArgb(MaterialDynamicColors.neutralPaletteKeyColor);\n }\n\n get neutralVariantPaletteKeyColor(): number {\n return this.getArgb(MaterialDynamicColors.neutralVariantPaletteKeyColor);\n }\n\n get background(): number {\n return this.getArgb(MaterialDynamicColors.background);\n }\n\n get onBackground(): number {\n return this.getArgb(MaterialDynamicColors.onBackground);\n }\n\n get surface(): number {\n return this.getArgb(MaterialDynamicColors.surface);\n }\n\n get surfaceDim(): number {\n return this.getArgb(MaterialDynamicColors.surfaceDim);\n }\n\n get surfaceBright(): number {\n return this.getArgb(MaterialDynamicColors.surfaceBright);\n }\n\n get surfaceContainerLowest(): number {\n return this.getArgb(MaterialDynamicColors.surfaceContainerLowest);\n }\n\n get surfaceContainerLow(): number {\n return this.getArgb(MaterialDynamicColors.surfaceContainerLow);\n }\n\n get surfaceContainer(): number {\n return this.getArgb(MaterialDynamicColors.surfaceContainer);\n }\n\n get surfaceContainerHigh(): number {\n return this.getArgb(MaterialDynamicColors.surfaceContainerHigh);\n }\n\n get surfaceContainerHighest(): number {\n return this.getArgb(MaterialDynamicColors.surfaceContainerHighest);\n }\n\n get onSurface(): number {\n return this.getArgb(MaterialDynamicColors.onSurface);\n }\n\n get surfaceVariant(): number {\n return this.getArgb(MaterialDynamicColors.surfaceVariant);\n }\n\n get onSurfaceVariant(): number {\n return this.getArgb(MaterialDynamicColors.onSurfaceVariant);\n }\n\n get inverseSurface(): number {\n return this.getArgb(MaterialDynamicColors.inverseSurface);\n }\n\n get inverseOnSurface(): number {\n return this.getArgb(MaterialDynamicColors.inverseOnSurface);\n }\n\n get outline(): number {\n return this.getArgb(MaterialDynamicColors.outline);\n }\n\n get outlineVariant(): number {\n return this.getArgb(MaterialDynamicColors.outlineVariant);\n }\n\n get shadow(): number {\n return this.getArgb(MaterialDynamicColors.shadow);\n }\n\n get scrim(): number {\n return this.getArgb(MaterialDynamicColors.scrim);\n }\n\n get surfaceTint(): number {\n return this.getArgb(MaterialDynamicColors.surfaceTint);\n }\n\n get primary(): number {\n return this.getArgb(MaterialDynamicColors.primary);\n }\n\n get onPrimary(): number {\n return this.getArgb(MaterialDynamicColors.onPrimary);\n }\n\n get primaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.primaryContainer);\n }\n\n get onPrimaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.onPrimaryContainer);\n }\n\n get inversePrimary(): number {\n return this.getArgb(MaterialDynamicColors.inversePrimary);\n }\n\n get secondary(): number {\n return this.getArgb(MaterialDynamicColors.secondary);\n }\n\n get onSecondary(): number {\n return this.getArgb(MaterialDynamicColors.onSecondary);\n }\n\n get secondaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.secondaryContainer);\n }\n\n get onSecondaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.onSecondaryContainer);\n }\n\n get tertiary(): number {\n return this.getArgb(MaterialDynamicColors.tertiary);\n }\n\n get onTertiary(): number {\n return this.getArgb(MaterialDynamicColors.onTertiary);\n }\n\n get tertiaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.tertiaryContainer);\n }\n\n get onTertiaryContainer(): number {\n return this.getArgb(MaterialDynamicColors.onTertiaryContainer);\n }\n\n get error(): number {\n return this.getArgb(MaterialDynamicColors.error);\n }\n\n get onError(): number {\n return this.getArgb(MaterialDynamicColors.onError);\n }\n\n get errorContainer(): number {\n return this.getArgb(MaterialDynamicColors.errorContainer);\n }\n\n get onErrorContainer(): number {\n return this.getArgb(MaterialDynamicColors.onErrorContainer);\n }\n\n get primaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.primaryFixed);\n }\n\n get primaryFixedDim(): number {\n return this.getArgb(MaterialDynamicColors.primaryFixedDim);\n }\n\n get onPrimaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.onPrimaryFixed);\n }\n\n get onPrimaryFixedVariant(): number {\n return this.getArgb(MaterialDynamicColors.onPrimaryFixedVariant);\n }\n\n get secondaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.secondaryFixed);\n }\n\n get secondaryFixedDim(): number {\n return this.getArgb(MaterialDynamicColors.secondaryFixedDim);\n }\n\n get onSecondaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.onSecondaryFixed);\n }\n\n get onSecondaryFixedVariant(): number {\n return this.getArgb(MaterialDynamicColors.onSecondaryFixedVariant);\n }\n\n get tertiaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.tertiaryFixed);\n }\n\n get tertiaryFixedDim(): number {\n return this.getArgb(MaterialDynamicColors.tertiaryFixedDim);\n }\n\n get onTertiaryFixed(): number {\n return this.getArgb(MaterialDynamicColors.onTertiaryFixed);\n }\n\n get onTertiaryFixedVariant(): number {\n return this.getArgb(MaterialDynamicColors.onTertiaryFixedVariant);\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as utils from '../utils/color_utils.js';\n\nimport {PointProvider} from './point_provider.js';\n\n/**\n * Provides conversions needed for K-Means quantization. Converting input to\n * points, and converting the final state of the K-Means algorithm to colors.\n */\nexport class LabPointProvider implements PointProvider {\n /**\n * Convert a color represented in ARGB to a 3-element array of L*a*b*\n * coordinates of the color.\n */\n fromInt(argb: number): number[] {\n return utils.labFromArgb(argb);\n }\n\n /**\n * Convert a 3-element array to a color represented in ARGB.\n */\n toInt(point: number[]): number {\n return utils.argbFromLab(point[0], point[1], point[2]);\n }\n\n /**\n * Standard CIE 1976 delta E formula also takes the square root, unneeded\n * here. This method is used by quantization algorithms to compare distance,\n * and the relative ordering is the same, with or without a square root.\n *\n * This relatively minor optimization is helpful because this method is\n * called at least once for each pixel in an image.\n */\n distance(from: number[], to: number[]): number {\n const dL = from[0] - to[0];\n const dA = from[1] - to[1];\n const dB = from[2] - to[2];\n return dL * dL + dA * dA + dB * dB;\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {LabPointProvider} from './lab_point_provider.js';\n\nconst MAX_ITERATIONS = 10;\nconst MIN_MOVEMENT_DISTANCE = 3.0;\n\n/**\n * An image quantizer that improves on the speed of a standard K-Means algorithm\n * by implementing several optimizations, including deduping identical pixels\n * and a triangle inequality rule that reduces the number of comparisons needed\n * to identify which cluster a point should be moved to.\n *\n * Wsmeans stands for Weighted Square Means.\n *\n * This algorithm was designed by M. Emre Celebi, and was found in their 2011\n * paper, Improving the Performance of K-Means for Color Quantization.\n * https://arxiv.org/abs/1101.0395\n */\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable-next-line:class-as-namespace\nexport class QuantizerWsmeans {\n /**\n * @param inputPixels Colors in ARGB format.\n * @param startingClusters Defines the initial state of the quantizer. Passing\n * an empty array is fine, the implementation will create its own initial\n * state that leads to reproducible results for the same inputs.\n * Passing an array that is the result of Wu quantization leads to higher\n * quality results.\n * @param maxColors The number of colors to divide the image into. A lower\n * number of colors may be returned.\n * @return Colors in ARGB format.\n */\n static quantize(\n inputPixels: number[], startingClusters: number[],\n maxColors: number): Map<number, number> {\n const pixelToCount = new Map<number, number>();\n const points = new Array<number[]>();\n const pixels = new Array<number>();\n const pointProvider = new LabPointProvider();\n let pointCount = 0;\n for (let i = 0; i < inputPixels.length; i++) {\n const inputPixel = inputPixels[i];\n const pixelCount = pixelToCount.get(inputPixel);\n if (pixelCount === undefined) {\n pointCount++;\n points.push(pointProvider.fromInt(inputPixel));\n pixels.push(inputPixel);\n pixelToCount.set(inputPixel, 1);\n } else {\n pixelToCount.set(inputPixel, pixelCount + 1);\n }\n }\n\n const counts = new Array<number>();\n for (let i = 0; i < pointCount; i++) {\n const pixel = pixels[i];\n const count = pixelToCount.get(pixel);\n if (count !== undefined) {\n counts[i] = count;\n }\n }\n\n let clusterCount = Math.min(maxColors, pointCount);\n if (startingClusters.length > 0) {\n clusterCount = Math.min(clusterCount, startingClusters.length);\n }\n\n const clusters = new Array<number[]>();\n for (let i = 0; i < startingClusters.length; i++) {\n clusters.push(pointProvider.fromInt(startingClusters[i]));\n }\n const additionalClustersNeeded = clusterCount - clusters.length;\n if (startingClusters.length === 0 && additionalClustersNeeded > 0) {\n for (let i = 0; i < additionalClustersNeeded; i++) {\n const l = Math.random() * 100.0;\n const a = Math.random() * (100.0 - (-100.0) + 1) + -100;\n const b = Math.random() * (100.0 - (-100.0) + 1) + -100;\n\n clusters.push(new Array(l, a, b));\n }\n }\n\n const clusterIndices = new Array<number>();\n for (let i = 0; i < pointCount; i++) {\n clusterIndices.push(Math.floor(Math.random() * clusterCount));\n }\n\n const indexMatrix = new Array<number[]>();\n for (let i = 0; i < clusterCount; i++) {\n indexMatrix.push(new Array<number>());\n for (let j = 0; j < clusterCount; j++) {\n indexMatrix[i].push(0);\n }\n }\n\n const distanceToIndexMatrix = new Array<DistanceAndIndex[]>();\n for (let i = 0; i < clusterCount; i++) {\n distanceToIndexMatrix.push(new Array<DistanceAndIndex>());\n for (let j = 0; j < clusterCount; j++) {\n distanceToIndexMatrix[i].push(new DistanceAndIndex());\n }\n }\n\n\n const pixelCountSums = new Array<number>();\n for (let i = 0; i < clusterCount; i++) {\n pixelCountSums.push(0);\n }\n for (let iteration = 0; iteration < MAX_ITERATIONS; iteration++) {\n for (let i = 0; i < clusterCount; i++) {\n for (let j = i + 1; j < clusterCount; j++) {\n const distance = pointProvider.distance(clusters[i], clusters[j]);\n distanceToIndexMatrix[j][i].distance = distance;\n distanceToIndexMatrix[j][i].index = i;\n distanceToIndexMatrix[i][j].distance = distance;\n distanceToIndexMatrix[i][j].index = j;\n }\n distanceToIndexMatrix[i].sort();\n for (let j = 0; j < clusterCount; j++) {\n indexMatrix[i][j] = distanceToIndexMatrix[i][j].index;\n }\n }\n\n let pointsMoved = 0;\n for (let i = 0; i < pointCount; i++) {\n const point = points[i];\n const previousClusterIndex = clusterIndices[i];\n const previousCluster = clusters[previousClusterIndex];\n const previousDistance = pointProvider.distance(point, previousCluster);\n let minimumDistance = previousDistance;\n let newClusterIndex = -1;\n for (let j = 0; j < clusterCount; j++) {\n if (distanceToIndexMatrix[previousClusterIndex][j].distance >=\n 4 * previousDistance) {\n continue;\n }\n const distance = pointProvider.distance(point, clusters[j]);\n if (distance < minimumDistance) {\n minimumDistance = distance;\n newClusterIndex = j;\n }\n }\n if (newClusterIndex !== -1) {\n const distanceChange = Math.abs(\n (Math.sqrt(minimumDistance) - Math.sqrt(previousDistance)));\n if (distanceChange > MIN_MOVEMENT_DISTANCE) {\n pointsMoved++;\n clusterIndices[i] = newClusterIndex;\n }\n }\n }\n\n if (pointsMoved === 0 && iteration !== 0) {\n break;\n }\n\n const componentASums = new Array<number>(clusterCount).fill(0);\n const componentBSums = new Array<number>(clusterCount).fill(0);\n const componentCSums = new Array<number>(clusterCount).fill(0);\n\n for (let i = 0; i < clusterCount; i++) {\n pixelCountSums[i] = 0;\n }\n for (let i = 0; i < pointCount; i++) {\n const clusterIndex = clusterIndices[i];\n const point = points[i];\n const count = counts[i];\n pixelCountSums[clusterIndex] += count;\n componentASums[clusterIndex] += (point[0] * count);\n componentBSums[clusterIndex] += (point[1] * count);\n componentCSums[clusterIndex] += (point[2] * count);\n }\n\n for (let i = 0; i < clusterCount; i++) {\n const count = pixelCountSums[i];\n if (count === 0) {\n clusters[i] = [0.0, 0.0, 0.0];\n continue;\n }\n const a = componentASums[i] / count;\n const b = componentBSums[i] / count;\n const c = componentCSums[i] / count;\n clusters[i] = [a, b, c];\n }\n }\n\n const argbToPopulation = new Map<number, number>();\n for (let i = 0; i < clusterCount; i++) {\n const count = pixelCountSums[i];\n if (count === 0) {\n continue;\n }\n\n const possibleNewCluster = pointProvider.toInt(clusters[i]);\n if (argbToPopulation.has(possibleNewCluster)) {\n continue;\n }\n\n argbToPopulation.set(possibleNewCluster, count);\n }\n return argbToPopulation;\n }\n}\n\n/**\n * A wrapper for maintaining a table of distances between K-Means clusters.\n */\nclass DistanceAndIndex {\n distance: number = -1;\n index: number = -1;\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as utils from '../utils/color_utils.js';\n\n/**\n * Quantizes an image into a map, with keys of ARGB colors, and values of the\n * number of times that color appears in the image.\n */\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable-next-line:class-as-namespace\nexport class QuantizerMap {\n /**\n * @param pixels Colors in ARGB format.\n * @return A Map with keys of ARGB colors, and values of the number of times\n * the color appears in the image.\n */\n static quantize(pixels: number[]): Map<number, number> {\n const countByColor = new Map<number, number>();\n for (let i = 0; i < pixels.length; i++) {\n const pixel = pixels[i];\n const alpha = utils.alphaFromArgb(pixel);\n if (alpha < 255) {\n continue;\n }\n countByColor.set(pixel, (countByColor.get(pixel) ?? 0) + 1);\n }\n return countByColor;\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as utils from '../utils/color_utils.js';\n\nimport {QuantizerMap} from './quantizer_map.js';\n\nconst INDEX_BITS = 5;\nconst SIDE_LENGTH = 33; // ((1 << INDEX_INDEX_BITS) + 1)\nconst TOTAL_SIZE = 35937; // SIDE_LENGTH * SIDE_LENGTH * SIDE_LENGTH\n\nconst directions = {\n RED: 'red',\n GREEN: 'green',\n BLUE: 'blue',\n};\n\n/**\n * An image quantizer that divides the image's pixels into clusters by\n * recursively cutting an RGB cube, based on the weight of pixels in each area\n * of the cube.\n *\n * The algorithm was described by Xiaolin Wu in Graphic Gems II, published in\n * 1991.\n */\nexport class QuantizerWu {\n constructor(\n private weights: number[] = [], private momentsR: number[] = [],\n private momentsG: number[] = [], private momentsB: number[] = [],\n private moments: number[] = [], private cubes: Box[] = []) {}\n\n /**\n * @param pixels Colors in ARGB format.\n * @param maxColors The number of colors to divide the image into. A lower\n * number of colors may be returned.\n * @return Colors in ARGB format.\n */\n quantize(pixels: number[], maxColors: number): number[] {\n this.constructHistogram(pixels);\n this.computeMoments();\n const createBoxesResult = this.createBoxes(maxColors);\n const results = this.createResult(createBoxesResult.resultCount);\n return results;\n }\n\n private constructHistogram(pixels: number[]) {\n this.weights = Array.from<number>({length: TOTAL_SIZE}).fill(0);\n this.momentsR = Array.from<number>({length: TOTAL_SIZE}).fill(0);\n this.momentsG = Array.from<number>({length: TOTAL_SIZE}).fill(0);\n this.momentsB = Array.from<number>({length: TOTAL_SIZE}).fill(0);\n this.moments = Array.from<number>({length: TOTAL_SIZE}).fill(0);\n\n const countByColor = QuantizerMap.quantize(pixels);\n\n for (const [pixel, count] of countByColor.entries()) {\n const red = utils.redFromArgb(pixel);\n const green = utils.greenFromArgb(pixel);\n const blue = utils.blueFromArgb(pixel);\n\n const bitsToRemove = 8 - INDEX_BITS;\n const iR = (red >> bitsToRemove) + 1;\n const iG = (green >> bitsToRemove) + 1;\n const iB = (blue >> bitsToRemove) + 1;\n const index = this.getIndex(iR, iG, iB);\n\n this.weights[index] = (this.weights[index] ?? 0) + count;\n this.momentsR[index] += count * red;\n this.momentsG[index] += count * green;\n this.momentsB[index] += count * blue;\n this.moments[index] += count * (red * red + green * green + blue * blue);\n }\n }\n\n private computeMoments() {\n for (let r = 1; r < SIDE_LENGTH; r++) {\n const area = Array.from<number>({length: SIDE_LENGTH}).fill(0);\n const areaR = Array.from<number>({length: SIDE_LENGTH}).fill(0);\n const areaG = Array.from<number>({length: SIDE_LENGTH}).fill(0);\n const areaB = Array.from<number>({length: SIDE_LENGTH}).fill(0);\n const area2 = Array.from<number>({length: SIDE_LENGTH}).fill(0.0);\n for (let g = 1; g < SIDE_LENGTH; g++) {\n let line = 0;\n let lineR = 0;\n let lineG = 0;\n let lineB = 0;\n let line2 = 0.0;\n for (let b = 1; b < SIDE_LENGTH; b++) {\n const index = this.getIndex(r, g, b);\n line += this.weights[index];\n lineR += this.momentsR[index];\n lineG += this.momentsG[index];\n lineB += this.momentsB[index];\n line2 += this.moments[index];\n\n area[b] += line;\n areaR[b] += lineR;\n areaG[b] += lineG;\n areaB[b] += lineB;\n area2[b] += line2;\n\n const previousIndex = this.getIndex(r - 1, g, b);\n this.weights[index] = this.weights[previousIndex] + area[b];\n this.momentsR[index] = this.momentsR[previousIndex] + areaR[b];\n this.momentsG[index] = this.momentsG[previousIndex] + areaG[b];\n this.momentsB[index] = this.momentsB[previousIndex] + areaB[b];\n this.moments[index] = this.moments[previousIndex] + area2[b];\n }\n }\n }\n }\n\n private createBoxes(maxColors: number): CreateBoxesResult {\n this.cubes =\n Array.from<number>({length: maxColors}).fill(0).map(() => new Box());\n const volumeVariance = Array.from<number>({length: maxColors}).fill(0.0);\n this.cubes[0].r0 = 0;\n this.cubes[0].g0 = 0;\n this.cubes[0].b0 = 0;\n\n this.cubes[0].r1 = SIDE_LENGTH - 1;\n this.cubes[0].g1 = SIDE_LENGTH - 1;\n this.cubes[0].b1 = SIDE_LENGTH - 1;\n\n let generatedColorCount = maxColors;\n let next = 0;\n for (let i = 1; i < maxColors; i++) {\n if (this.cut(this.cubes[next], this.cubes[i])) {\n volumeVariance[next] =\n this.cubes[next].vol > 1 ? this.variance(this.cubes[next]) : 0.0;\n volumeVariance[i] =\n this.cubes[i].vol > 1 ? this.variance(this.cubes[i]) : 0.0;\n } else {\n volumeVariance[next] = 0.0;\n i--;\n }\n\n next = 0;\n let temp = volumeVariance[0];\n for (let j = 1; j <= i; j++) {\n if (volumeVariance[j] > temp) {\n temp = volumeVariance[j];\n next = j;\n }\n }\n if (temp <= 0.0) {\n generatedColorCount = i + 1;\n break;\n }\n }\n return new CreateBoxesResult(maxColors, generatedColorCount);\n }\n\n private createResult(colorCount: number): number[] {\n const colors: number[] = [];\n for (let i = 0; i < colorCount; ++i) {\n const cube = this.cubes[i];\n const weight = this.volume(cube, this.weights);\n if (weight > 0) {\n const r = Math.round(this.volume(cube, this.momentsR) / weight);\n const g = Math.round(this.volume(cube, this.momentsG) / weight);\n const b = Math.round(this.volume(cube, this.momentsB) / weight);\n const color = (255 << 24) | ((r & 0x0ff) << 16) | ((g & 0x0ff) << 8) |\n (b & 0x0ff);\n colors.push(color);\n }\n }\n return colors;\n }\n\n private variance(cube: Box) {\n const dr = this.volume(cube, this.momentsR);\n const dg = this.volume(cube, this.momentsG);\n const db = this.volume(cube, this.momentsB);\n const xx = this.moments[this.getIndex(cube.r1, cube.g1, cube.b1)] -\n this.moments[this.getIndex(cube.r1, cube.g1, cube.b0)] -\n this.moments[this.getIndex(cube.r1, cube.g0, cube.b1)] +\n this.moments[this.getIndex(cube.r1, cube.g0, cube.b0)] -\n this.moments[this.getIndex(cube.r0, cube.g1, cube.b1)] +\n this.moments[this.getIndex(cube.r0, cube.g1, cube.b0)] +\n this.moments[this.getIndex(cube.r0, cube.g0, cube.b1)] -\n this.moments[this.getIndex(cube.r0, cube.g0, cube.b0)];\n const hypotenuse = dr * dr + dg * dg + db * db;\n const volume = this.volume(cube, this.weights);\n return xx - hypotenuse / volume;\n }\n\n private cut(one: Box, two: Box) {\n const wholeR = this.volume(one, this.momentsR);\n const wholeG = this.volume(one, this.momentsG);\n const wholeB = this.volume(one, this.momentsB);\n const wholeW = this.volume(one, this.weights);\n\n const maxRResult = this.maximize(\n one, directions.RED, one.r0 + 1, one.r1, wholeR, wholeG, wholeB,\n wholeW);\n const maxGResult = this.maximize(\n one, directions.GREEN, one.g0 + 1, one.g1, wholeR, wholeG, wholeB,\n wholeW);\n const maxBResult = this.maximize(\n one, directions.BLUE, one.b0 + 1, one.b1, wholeR, wholeG, wholeB,\n wholeW);\n\n let direction;\n const maxR = maxRResult.maximum;\n const maxG = maxGResult.maximum;\n const maxB = maxBResult.maximum;\n if (maxR >= maxG && maxR >= maxB) {\n if (maxRResult.cutLocation < 0) {\n return false;\n }\n direction = directions.RED;\n } else if (maxG >= maxR && maxG >= maxB) {\n direction = directions.GREEN;\n } else {\n direction = directions.BLUE;\n }\n\n two.r1 = one.r1;\n two.g1 = one.g1;\n two.b1 = one.b1;\n\n switch (direction) {\n case directions.RED:\n one.r1 = maxRResult.cutLocation;\n two.r0 = one.r1;\n two.g0 = one.g0;\n two.b0 = one.b0;\n break;\n case directions.GREEN:\n one.g1 = maxGResult.cutLocation;\n two.r0 = one.r0;\n two.g0 = one.g1;\n two.b0 = one.b0;\n break;\n case directions.BLUE:\n one.b1 = maxBResult.cutLocation;\n two.r0 = one.r0;\n two.g0 = one.g0;\n two.b0 = one.b1;\n break;\n default:\n throw new Error('unexpected direction ' + direction);\n }\n\n one.vol = (one.r1 - one.r0) * (one.g1 - one.g0) * (one.b1 - one.b0);\n two.vol = (two.r1 - two.r0) * (two.g1 - two.g0) * (two.b1 - two.b0);\n return true;\n }\n\n private maximize(\n cube: Box, direction: string, first: number, last: number, wholeR: number,\n wholeG: number, wholeB: number, wholeW: number) {\n const bottomR = this.bottom(cube, direction, this.momentsR);\n const bottomG = this.bottom(cube, direction, this.momentsG);\n const bottomB = this.bottom(cube, direction, this.momentsB);\n const bottomW = this.bottom(cube, direction, this.weights);\n\n let max = 0.0;\n let cut = -1;\n\n let halfR = 0;\n let halfG = 0;\n let halfB = 0;\n let halfW = 0;\n for (let i = first; i < last; i++) {\n halfR = bottomR + this.top(cube, direction, i, this.momentsR);\n halfG = bottomG + this.top(cube, direction, i, this.momentsG);\n halfB = bottomB + this.top(cube, direction, i, this.momentsB);\n halfW = bottomW + this.top(cube, direction, i, this.weights);\n if (halfW === 0) {\n continue;\n }\n\n let tempNumerator = (halfR * halfR + halfG * halfG + halfB * halfB) * 1.0;\n let tempDenominator = halfW * 1.0;\n let temp = tempNumerator / tempDenominator;\n\n halfR = wholeR - halfR;\n halfG = wholeG - halfG;\n halfB = wholeB - halfB;\n halfW = wholeW - halfW;\n if (halfW === 0) {\n continue;\n }\n\n tempNumerator = (halfR * halfR + halfG * halfG + halfB * halfB) * 1.0;\n tempDenominator = halfW * 1.0;\n temp += tempNumerator / tempDenominator;\n\n if (temp > max) {\n max = temp;\n cut = i;\n }\n }\n return new MaximizeResult(cut, max);\n }\n\n private volume(cube: Box, moment: number[]) {\n return (\n moment[this.getIndex(cube.r1, cube.g1, cube.b1)] -\n moment[this.getIndex(cube.r1, cube.g1, cube.b0)] -\n moment[this.getIndex(cube.r1, cube.g0, cube.b1)] +\n moment[this.getIndex(cube.r1, cube.g0, cube.b0)] -\n moment[this.getIndex(cube.r0, cube.g1, cube.b1)] +\n moment[this.getIndex(cube.r0, cube.g1, cube.b0)] +\n moment[this.getIndex(cube.r0, cube.g0, cube.b1)] -\n moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);\n }\n\n private bottom(cube: Box, direction: string, moment: number[]) {\n switch (direction) {\n case directions.RED:\n return (\n -moment[this.getIndex(cube.r0, cube.g1, cube.b1)] +\n moment[this.getIndex(cube.r0, cube.g1, cube.b0)] +\n moment[this.getIndex(cube.r0, cube.g0, cube.b1)] -\n moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);\n case directions.GREEN:\n return (\n -moment[this.getIndex(cube.r1, cube.g0, cube.b1)] +\n moment[this.getIndex(cube.r1, cube.g0, cube.b0)] +\n moment[this.getIndex(cube.r0, cube.g0, cube.b1)] -\n moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);\n case directions.BLUE:\n return (\n -moment[this.getIndex(cube.r1, cube.g1, cube.b0)] +\n moment[this.getIndex(cube.r1, cube.g0, cube.b0)] +\n moment[this.getIndex(cube.r0, cube.g1, cube.b0)] -\n moment[this.getIndex(cube.r0, cube.g0, cube.b0)]);\n default:\n throw new Error('unexpected direction $direction');\n }\n }\n\n private top(\n cube: Box, direction: string, position: number, moment: number[]) {\n switch (direction) {\n case directions.RED:\n return (\n moment[this.getIndex(position, cube.g1, cube.b1)] -\n moment[this.getIndex(position, cube.g1, cube.b0)] -\n moment[this.getIndex(position, cube.g0, cube.b1)] +\n moment[this.getIndex(position, cube.g0, cube.b0)]);\n case directions.GREEN:\n return (\n moment[this.getIndex(cube.r1, position, cube.b1)] -\n moment[this.getIndex(cube.r1, position, cube.b0)] -\n moment[this.getIndex(cube.r0, position, cube.b1)] +\n moment[this.getIndex(cube.r0, position, cube.b0)]);\n case directions.BLUE:\n return (\n moment[this.getIndex(cube.r1, cube.g1, position)] -\n moment[this.getIndex(cube.r1, cube.g0, position)] -\n moment[this.getIndex(cube.r0, cube.g1, position)] +\n moment[this.getIndex(cube.r0, cube.g0, position)]);\n default:\n throw new Error('unexpected direction $direction');\n }\n }\n\n private getIndex(r: number, g: number, b: number): number {\n return (r << (INDEX_BITS * 2)) + (r << (INDEX_BITS + 1)) + r +\n (g << INDEX_BITS) + g + b;\n }\n}\n\n/**\n * Keeps track of the state of each box created as the Wu quantization\n * algorithm progresses through dividing the image's pixels as plotted in RGB.\n */\nclass Box {\n constructor(\n public r0: number = 0, public r1: number = 0, public g0: number = 0,\n public g1: number = 0, public b0: number = 0, public b1: number = 0,\n public vol: number = 0) {}\n}\n\n/**\n * Represents final result of Wu algorithm.\n */\nclass CreateBoxesResult {\n /**\n * @param requestedCount how many colors the caller asked to be returned from\n * quantization.\n * @param resultCount the actual number of colors achieved from quantization.\n * May be lower than the requested count.\n */\n constructor(public requestedCount: number, public resultCount: number) {}\n}\n\n/**\n * Represents the result of calculating where to cut an existing box in such\n * a way to maximize variance between the two new boxes created by a cut.\n */\nclass MaximizeResult {\n constructor(public cutLocation: number, public maximum: number) {}\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {QuantizerWsmeans} from './quantizer_wsmeans.js';\nimport {QuantizerWu} from './quantizer_wu.js';\n\n/**\n * An image quantizer that improves on the quality of a standard K-Means\n * algorithm by setting the K-Means initial state to the output of a Wu\n * quantizer, instead of random centroids. Improves on speed by several\n * optimizations, as implemented in Wsmeans, or Weighted Square Means, K-Means\n * with those optimizations.\n *\n * This algorithm was designed by M. Emre Celebi, and was found in their 2011\n * paper, Improving the Performance of K-Means for Color Quantization.\n * https://arxiv.org/abs/1101.0395\n */\n// material_color_utilities is designed to have a consistent API across\n// platforms and modular components that can be moved around easily. Using a\n// class as a namespace facilitates this.\n//\n// tslint:disable-next-line:class-as-namespace\nexport class QuantizerCelebi {\n /**\n * @param pixels Colors in ARGB format.\n * @param maxColors The number of colors to divide the image into. A lower\n * number of colors may be returned.\n * @return Map with keys of colors in ARGB format, and values of number of\n * pixels in the original image that correspond to the color in the\n * quantized image.\n */\n static quantize(pixels: number[], maxColors: number): Map<number, number> {\n const wu = new QuantizerWu();\n const wuResult = wu.quantize(pixels, maxColors);\n return QuantizerWsmeans.quantize(pixels, wuResult, maxColors);\n }\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {DynamicScheme} from '../dynamiccolor/dynamic_scheme.js';\nimport {Variant} from '../dynamiccolor/variant.js';\nimport {Hct} from '../hct/hct.js';\nimport {TonalPalette} from '../palettes/tonal_palette.js';\nimport * as math from '../utils/math_utils.js';\n\n/**\n * A Dynamic Color theme that is intentionally detached from the source color.\n */\nexport class SchemeExpressive extends DynamicScheme {\n /**\n * Hues (in degrees) used at breakpoints such that designers can specify a\n * hue rotation that occurs at a given break point.\n */\n private static readonly hues: number[] = [\n 0.0,\n 21.0,\n 51.0,\n 121.0,\n 151.0,\n 191.0,\n 271.0,\n 321.0,\n 360.0,\n ];\n\n /**\n * Hue rotations (in degrees) of the Secondary [TonalPalette],\n * corresponding to the breakpoints in [hues].\n */\n private static readonly secondaryRotations: number[] = [\n 45.0,\n 95.0,\n 45.0,\n 20.0,\n 45.0,\n 90.0,\n 45.0,\n 45.0,\n 45.0,\n ];\n\n /**\n * Hue rotations (in degrees) of the Tertiary [TonalPalette],\n * corresponding to the breakpoints in [hues].\n */\n private static readonly tertiaryRotations: number[] = [\n 120.0,\n 120.0,\n 20.0,\n 45.0,\n 20.0,\n 15.0,\n 20.0,\n 120.0,\n 120.0,\n ];\n\n constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number) {\n super({\n sourceColorArgb: sourceColorHct.toInt(),\n variant: Variant.EXPRESSIVE,\n contrastLevel,\n isDark,\n primaryPalette: TonalPalette.fromHueAndChroma(\n math.sanitizeDegreesDouble(sourceColorHct.hue + 240.0), 40.0),\n secondaryPalette: TonalPalette.fromHueAndChroma(\n DynamicScheme.getRotatedHue(\n sourceColorHct, SchemeExpressive.hues,\n SchemeExpressive.secondaryRotations),\n 24.0),\n tertiaryPalette: TonalPalette.fromHueAndChroma(\n DynamicScheme.getRotatedHue(\n sourceColorHct, SchemeExpressive.hues,\n SchemeExpressive.tertiaryRotations),\n 32.0),\n neutralPalette:\n TonalPalette.fromHueAndChroma(sourceColorHct.hue + 15, 8.0),\n neutralVariantPalette:\n TonalPalette.fromHueAndChroma(sourceColorHct.hue + 15, 12.0),\n });\n }\n}\n", "/**\n * @license\n * Copyright 2022 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {DynamicScheme} from '../dynamiccolor/dynamic_scheme.js';\nimport {Variant} from '../dynamiccolor/variant.js';\nimport {Hct} from '../hct/hct.js';\nimport {TonalPalette} from '../palettes/tonal_palette.js';\n\n/**\n * A Dynamic Color theme that maxes out colorfulness at each position in the\n * Primary Tonal Palette.\n */\nexport class SchemeVibrant extends DynamicScheme {\n /**\n * Hues (in degrees) used at breakpoints such that designers can specify a\n * hue rotation that occurs at a given break point.\n */\n private static readonly hues = [\n 0.0,\n 41.0,\n 61.0,\n 101.0,\n 131.0,\n 181.0,\n 251.0,\n 301.0,\n 360.0,\n ];\n\n /**\n * Hue rotations (in degrees) of the Secondary [TonalPalette],\n * corresponding to the breakpoints in [hues].\n */\n private static readonly secondaryRotations = [\n 18.0,\n 15.0,\n 10.0,\n 12.0,\n 15.0,\n 18.0,\n 15.0,\n 12.0,\n 12.0,\n ];\n\n /**\n * Hue rotations (in degrees) of the Tertiary [TonalPalette],\n * corresponding to the breakpoints in [hues].\n */\n private static readonly tertiaryRotations = [\n 35.0,\n 30.0,\n 20.0,\n 25.0,\n 30.0,\n 35.0,\n 30.0,\n 25.0,\n 25.0,\n ];\n\n constructor(sourceColorHct: Hct, isDark: boolean, contrastLevel: number) {\n super({\n sourceColorArgb: sourceColorHct.toInt(),\n variant: Variant.VIBRANT,\n contrastLevel,\n isDark,\n primaryPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 200.0),\n secondaryPalette: TonalPalette.fromHueAndChroma(\n DynamicScheme.getRotatedHue(\n sourceColorHct, SchemeVibrant.hues,\n SchemeVibrant.secondaryRotations),\n 24.0),\n tertiaryPalette: TonalPalette.fromHueAndChroma(\n DynamicScheme.getRotatedHue(\n sourceColorHct, SchemeVibrant.hues,\n SchemeVibrant.tertiaryRotations),\n 32.0),\n neutralPalette: TonalPalette.fromHueAndChroma(sourceColorHct.hue, 10.0),\n neutralVariantPalette:\n TonalPalette.fromHueAndChroma(sourceColorHct.hue, 12.0),\n });\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {Hct} from '../hct/hct.js';\nimport * as math from '../utils/math_utils.js';\n\n/**\n * Default options for ranking colors based on usage counts.\n * desired: is the max count of the colors returned.\n * fallbackColorARGB: Is the default color that should be used if no\n * other colors are suitable.\n * filter: controls if the resulting colors should be filtered to not include\n * hues that are not used often enough, and colors that are effectively\n * grayscale.\n */\ndeclare interface ScoreOptions {\n desired?: number;\n fallbackColorARGB?: number;\n filter?: boolean;\n}\n\nconst SCORE_OPTION_DEFAULTS = {\n desired: 4, // 4 colors matches what Android wallpaper picker.\n fallbackColorARGB: 0xff4285f4, // Google Blue.\n filter: true, // Avoid unsuitable colors.\n};\n\nfunction compare(a: {hct: Hct, score: number}, b: {hct: Hct, score: number}): number {\n if (a.score > b.score) {\n return -1;\n } else if (a.score < b.score) {\n return 1;\n }\n return 0;\n}\n\n/**\n * Given a large set of colors, remove colors that are unsuitable for a UI\n * theme, and rank the rest based on suitability.\n *\n * Enables use of a high cluster count for image quantization, thus ensuring\n * colors aren't muddied, while curating the high cluster count to a much\n * smaller number of appropriate choices.\n */\nexport class Score {\n private static readonly TARGET_CHROMA = 48.0; // A1 Chroma\n private static readonly WEIGHT_PROPORTION = 0.7;\n private static readonly WEIGHT_CHROMA_ABOVE = 0.3;\n private static readonly WEIGHT_CHROMA_BELOW = 0.1;\n private static readonly CUTOFF_CHROMA = 5.0;\n private static readonly CUTOFF_EXCITED_PROPORTION = 0.01;\n\n private constructor() {}\n\n /**\n * Given a map with keys of colors and values of how often the color appears,\n * rank the colors based on suitability for being used for a UI theme.\n *\n * @param colorsToPopulation map with keys of colors and values of how often\n * the color appears, usually from a source image.\n * @param {ScoreOptions} options optional parameters.\n * @return Colors sorted by suitability for a UI theme. The most suitable\n * color is the first item, the least suitable is the last. There will\n * always be at least one color returned. If all the input colors\n * were not suitable for a theme, a default fallback color will be\n * provided, Google Blue.\n */\n static score(\n colorsToPopulation: Map<number, number>, options?: ScoreOptions):\n number[] {\n const {desired, fallbackColorARGB, filter} = {...SCORE_OPTION_DEFAULTS, ...options};\n // Get the HCT color for each Argb value, while finding the per hue count and\n // total count.\n const colorsHct: Hct[] = [];\n const huePopulation = new Array<number>(360).fill(0);\n let populationSum = 0;\n for (const [argb, population] of colorsToPopulation.entries()) {\n const hct = Hct.fromInt(argb);\n colorsHct.push(hct);\n const hue = Math.floor(hct.hue);\n huePopulation[hue] += population;\n populationSum += population;\n }\n\n // Hues with more usage in neighboring 30 degree slice get a larger number.\n const hueExcitedProportions = new Array<number>(360).fill(0.0);\n for (let hue = 0; hue < 360; hue++) {\n const proportion = huePopulation[hue] / populationSum;\n for (let i = hue - 14; i < hue + 16; i++) {\n const neighborHue = math.sanitizeDegreesInt(i);\n hueExcitedProportions[neighborHue] += proportion;\n }\n }\n\n // Scores each HCT color based on usage and chroma, while optionally\n // filtering out values that do not have enough chroma or usage.\n const scoredHct = new Array<{hct: Hct, score: number}>();\n for (const hct of colorsHct) {\n const hue = math.sanitizeDegreesInt(Math.round(hct.hue));\n const proportion = hueExcitedProportions[hue];\n if (filter && (hct.chroma < Score.CUTOFF_CHROMA || proportion <= Score.CUTOFF_EXCITED_PROPORTION)) {\n continue;\n }\n\n const proportionScore = proportion * 100.0 * Score.WEIGHT_PROPORTION;\n const chromaWeight = hct.chroma < Score.TARGET_CHROMA ? Score.WEIGHT_CHROMA_BELOW : Score.WEIGHT_CHROMA_ABOVE;\n const chromaScore = (hct.chroma - Score.TARGET_CHROMA) * chromaWeight;\n const score = proportionScore + chromaScore;\n scoredHct.push({hct, score});\n }\n // Sorted so that colors with higher scores come first.\n scoredHct.sort(compare);\n\n // Iterates through potential hue differences in degrees in order to select\n // the colors with the largest distribution of hues possible. Starting at\n // 90 degrees(maximum difference for 4 colors) then decreasing down to a\n // 15 degree minimum.\n const chosenColors: Hct[] = [];\n for (let differenceDegrees = 90; differenceDegrees >= 15; differenceDegrees--) {\n chosenColors.length = 0;\n for (const {hct} of scoredHct) {\n const duplicateHue = chosenColors.find(chosenHct => {\n return math.differenceDegrees(hct.hue, chosenHct.hue) < differenceDegrees;\n });\n if (!duplicateHue) {\n chosenColors.push(hct);\n }\n if (chosenColors.length >= desired) break;\n }\n if (chosenColors.length >= desired) break;\n }\n const colors: number[] = [];\n if (chosenColors.length === 0) {\n colors.push(fallbackColorARGB);\n }\n for (const chosenHct of chosenColors) {\n colors.push(chosenHct.toInt());\n }\n return colors;\n }\n}\n", "/**\n * @license\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as colorUtils from './color_utils.js';\n\n/**\n * Utility methods for hexadecimal representations of colors.\n */\n\n/**\n * @param argb ARGB representation of a color.\n * @return Hex string representing color, ex. #ff0000 for red.\n */\nexport function hexFromArgb(argb: number) {\n const r = colorUtils.redFromArgb(argb);\n const g = colorUtils.greenFromArgb(argb);\n const b = colorUtils.blueFromArgb(argb);\n const outParts = [r.toString(16), g.toString(16), b.toString(16)];\n\n // Pad single-digit output values\n for (const [i, part] of outParts.entries()) {\n if (part.length === 1) {\n outParts[i] = '0' + part;\n }\n }\n\n return '#' + outParts.join('');\n}\n\n/**\n * @param hex String representing color as hex code. Accepts strings with or\n * without leading #, and string representing the color using 3, 6, or 8\n * hex characters.\n * @return ARGB representation of color.\n */\nexport function argbFromHex(hex: string) {\n hex = hex.replace('#', '');\n const isThree = hex.length === 3;\n const isSix = hex.length === 6;\n const isEight = hex.length === 8;\n if (!isThree && !isSix && !isEight) {\n throw new Error('unexpected hex ' + hex);\n }\n let r = 0;\n let g = 0;\n let b = 0;\n if (isThree) {\n r = parseIntHex(hex.slice(0, 1).repeat(2));\n g = parseIntHex(hex.slice(1, 2).repeat(2));\n b = parseIntHex(hex.slice(2, 3).repeat(2));\n } else if (isSix) {\n r = parseIntHex(hex.slice(0, 2));\n g = parseIntHex(hex.slice(2, 4));\n b = parseIntHex(hex.slice(4, 6));\n } else if (isEight) {\n r = parseIntHex(hex.slice(2, 4));\n g = parseIntHex(hex.slice(4, 6));\n b = parseIntHex(hex.slice(6, 8));\n }\n\n return (\n ((255 << 24) | ((r & 0x0ff) << 16) | ((g & 0x0ff) << 8) | (b & 0x0ff)) >>>\n 0);\n}\n\nfunction parseIntHex(value: string) {\n // tslint:disable-next-line:ban\n return parseInt(value, 16);\n}\n", "/**\n * RGBA color in 0-255 integer space.\n */\nexport interface RgbaColor {\n r: number;\n g: number;\n b: number;\n a: number;\n}\n\n/**\n * Returns the classic Game Boy palette.\n * Colors: #9bbc0f, #8bac0f, #306230, #0f380f\n */\nexport function getGameBoyPalette(): RgbaColor[] {\n return [\n { r: 155, g: 188, b: 15, a: 255 },\n { r: 139, g: 172, b: 15, a: 255 },\n { r: 48, g: 98, b: 48, a: 255 },\n { r: 15, g: 56, b: 15, a: 255 },\n ];\n}\n"],
5
+ "mappings": "yoBAAA,IAAAA,GAAAC,EAAA,CAAAC,GAAAC,KAAA,CASA,IAAMC,GAAWC,GAAQ,OAAOA,EAAQ,KAAeA,IAAQ,KAMzDC,GAAUD,GAAQ,OAAOA,GAAQ,SAMjCE,GAAeF,GAAQ,OAAO,UAAU,SAAS,KAAKA,CAAG,IAAM,kBAM/DG,GAAMH,GAAQ,OAAOA,GAAQ,WAM7BI,GAAQJ,GAAQ,OAAOA,GAAQ,UAM/BK,GAAUL,GAAQA,aAAe,OAMjCM,GAAcN,GAAQ,CAC1B,GAAID,GAAQC,CAAG,EACb,OAAQA,EAAI,YAAa,CACvB,KAAK,WACL,KAAK,kBACL,KAAK,UACL,KAAK,YACL,KAAK,WACL,KAAK,YACL,KAAK,WACL,KAAK,aACL,KAAK,aACH,MAAO,EACX,CAGF,MAAO,EACT,EAMMO,GAAe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yCACA,uCACA,sCACA,sCACA,gDACA,iCACA,oCACA,oCACA,0CACA,wDACA,iDACA,wDACA,2CACA,wCACA,wDACA,0CACA,4BACA,kCACA,iDACA,iCACA,4CACA,8CACA,iDACA,4CACA,mCACA,2BACA,kCACA,gCACA,sCACA,uCACA,wCACA,gCACA,gCACA,oCACA,uCACA,yCACA,2CACA,uCACA,yCACA,wCACA,6DACA,uCACA,qCACA,+BACA,6BACA,gCACA,iCACA,mCACA,4CACA,uCACA,oDACA,uCACA,uCACA,yCACA,uCACA,qCACA,2CACA,sCACA,sCACA,qCACF,EACA,QAAW,CACT,MAAS,wBACT,QAAW,yCACX,MAAS,kEACT,KAAQ,oCACR,KAAQ,4DACR,WAAY,mCACZ,UAAW,aACX,aAAc,2CACd,YAAa,sBACb,YAAa,kDACb,2BAA4B,+BAC5B,wBAAyB,4BACzB,aAAc,sBACd,aAAc,uBACd,eAAgB,kHAClB,EACA,KAAQ,WACR,KAAQ,eACR,MAAS,iBACT,MAAS,CACP,UACA,MACA,kBACF,EACA,WAAc,CACZ,KAAQ,MACR,IAAO,mCACT,EACA,SAAY,CACV,OACA,MACA,OACA,OACA,OACA,MACA,MACA,MACA,MACA,QACA,SACA,YACA,OACA,QACA,UACA,MACF,EACA,aAAgB,CACd,cAAe,SACf,cAAe,SACf,OAAU,QACZ,EACA,qBAAwB,CACtB,0BAA2B,SAC3B,wBAAyB,SACzB,kCAAmC,QACnC,gCAAiC,QACjC,+BAAgC,QAChC,iCAAkC,QAClC,iCAAkC,QAClC,mCAAoC,QACpC,iCAAkC,QAClC,+BAAgC,QAChC,qCAAsC,QACtC,mCAAoC,QACpC,uBAAwB,SACxB,yBAA0B,SAC1B,yBAA0B,SAC1B,2BAA4B,SAC5B,yBAA0B,SAC1B,uBAAwB,SACxB,6BAA8B,SAC9B,2BAA4B,SAC5B,oBAAqB,SACrB,yBAA0B,SAC1B,wBAAyB,SACzB,uBAAwB,QAC1B,EACA,gBAAmB,CACjB,iBAAkB,SAClB,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EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,EAAG,GAAI,CAChC,CACF",
6
+ "names": ["require_is", "__commonJSMin", "exports", "module", "defined", "val", "object", "plainObject", "fn", "bool", "buffer", "typedArray", "arrayBuffer", "string", "number", "integer", "inRange", "min", "max", "inArray", "list", "invalidParameterError", "name", "expected", "actual", "nativeError", "native", "context", "require_process", "__commonJSMin", "exports", "module", "isLinux", "report", "getReport", "orig", "require_filesystem", "__commonJSMin", "exports", "module", "fs", "LDD_PATH", "SELF_PATH", "MAX_LENGTH", "readFileSync", "path", "fd", "buffer", "bytesRead", "readFile", "resolve", "reject", "err", "_", "require_elf", "__commonJSMin", "exports", "module", "interpreterPath", "elf", "offset", "size", "count", "headerOffset", "fileOffset", "fileSize", "require_detect_libc", "__commonJSMin", "exports", "module", "childProcess", "isLinux", "getReport", "LDD_PATH", "SELF_PATH", "readFile", "readFileSync", "interpreterPath", "cachedFamilyInterpreter", "cachedFamilyFilesystem", "cachedVersionFilesystem", "command", "commandOut", "safeCommand", "resolve", "err", "out", "safeCommandSync", "GLIBC", "RE_GLIBC_VERSION", "MUSL", "isFileMusl", "f", "familyFromReport", "report", "familyFromCommand", "getconf", "ldd1", "familyFromInterpreterPath", "path", "getFamilyFromLddContent", "content", "familyFromFilesystem", "lddContent", "familyFromFilesystemSync", "familyFromInterpreter", "selfContent", "familyFromInterpreterSync", "family", "familySync", "isNonGlibcLinux", "isNonGlibcLinuxSync", "versionFromFilesystem", "versionMatch", "versionFromFilesystemSync", "versionFromReport", "versionSuffix", "s", "versionFromCommand", "ldd2", "version", "versionSync", "require_debug", "__commonJSMin", "exports", "module", "debug", "args", "require_constants", "__commonJSMin", "exports", "module", "SEMVER_SPEC_VERSION", "MAX_SAFE_INTEGER", "MAX_SAFE_COMPONENT_LENGTH", "MAX_SAFE_BUILD_LENGTH", "RELEASE_TYPES", "require_re", "__commonJSMin", "exports", "module", "MAX_SAFE_COMPONENT_LENGTH", "MAX_SAFE_BUILD_LENGTH", "MAX_LENGTH", "debug", "re", "safeRe", "src", "safeSrc", "t", "R", "LETTERDASHNUMBER", "safeRegexReplacements", "makeSafeRegex", "value", "token", "max", "createToken", "name", "isGlobal", "safe", "index", "require_parse_options", "__commonJSMin", "exports", "module", "looseOption", "emptyOpts", "parseOptions", "options", "require_identifiers", "__commonJSMin", "exports", "module", "numeric", "compareIdentifiers", "a", "b", "anum", "bnum", "rcompareIdentifiers", "require_semver", "__commonJSMin", "exports", "module", "debug", "MAX_LENGTH", "MAX_SAFE_INTEGER", "re", "t", "parseOptions", "compareIdentifiers", "SemVer", "_SemVer", "version", "options", "m", "id", "num", "other", "i", "a", "b", "release", "identifier", "identifierBase", "match", "base", "prerelease", "require_parse", "__commonJSMin", "exports", "module", "SemVer", "parse", "version", "options", "throwErrors", "er", "require_coerce", "__commonJSMin", "exports", "module", "SemVer", "parse", "re", "t", "coerce", "version", "options", "match", "coerceRtlRegex", "next", "major", "minor", "patch", "prerelease", "build", "require_compare", "__commonJSMin", "exports", "module", "SemVer", "compare", "a", "b", "loose", "require_gte", "__commonJSMin", "exports", "module", "compare", "gte", "a", "b", "loose", "require_lrucache", "__commonJSMin", "exports", "module", "LRUCache", "key", "value", "firstKey", "require_eq", "__commonJSMin", "exports", "module", "compare", "eq", "a", "b", "loose", "require_neq", "__commonJSMin", "exports", "module", "compare", "neq", "a", "b", "loose", "require_gt", "__commonJSMin", "exports", "module", "compare", "gt", "a", "b", "loose", "require_lt", "__commonJSMin", "exports", "module", "compare", "lt", "a", "b", "loose", "require_lte", "__commonJSMin", "exports", "module", "compare", "lte", "a", "b", "loose", "require_cmp", "__commonJSMin", "exports", "module", "eq", "neq", "gt", "gte", "lt", "lte", "cmp", "a", "op", "b", "loose", "require_comparator", "__commonJSMin", "exports", "module", "ANY", "Comparator", "_Comparator", "comp", "options", "parseOptions", "debug", "re", "t", "m", "SemVer", "version", "cmp", "Range", "require_range", "__commonJSMin", "exports", "module", "SPACE_CHARACTERS", "Range", "_Range", "range", "options", "parseOptions", "Comparator", "r", "c", "first", "isNullSet", "isAny", "i", "comps", "k", "memoKey", "FLAG_INCLUDE_PRERELEASE", "FLAG_LOOSE", "cached", "cache", "loose", "hr", "re", "t", "hyphenReplace", "debug", "comparatorTrimReplace", "tildeTrimReplace", "caretTrimReplace", "rangeList", "comp", "parseComparator", "replaceGTE0", "rangeMap", "comparators", "result", "thisComparators", "isSatisfiable", "rangeComparators", "thisComparator", "rangeComparator", "version", "SemVer", "testSet", "LRU", "remainingComparators", "testComparator", "otherComparator", "replaceCarets", "replaceTildes", "replaceXRanges", "replaceStars", "isX", "id", "replaceTilde", "_", "M", "m", "p", "pr", "ret", "replaceCaret", "z", "replaceXRange", "gtlt", "xM", "xm", "xp", "anyX", "incPr", "$0", "from", "fM", "fm", "fp", "fpr", "fb", "to", "tM", "tm", "tp", "tpr", "set", "allowed", "require_satisfies", "__commonJSMin", "exports", "module", "Range", "satisfies", "version", "range", "options", "require_package", "__commonJSMin", "exports", "module", "require_libvips", "__commonJSMin", "exports", "module", "spawnSync", "createHash", "semverCoerce", "semverGreaterThanOrEqualTo", "semverSatisfies", "detectLibc", "config", "engines", "optionalDependencies", "minimumLibvipsVersionLabelled", "minimumLibvipsVersion", "prebuiltPlatforms", "spawnSyncOptions", "log", "item", "runtimeLibc", "runtimePlatformArch", "buildPlatformArch", "isEmscripten", "npm_config_arch", "npm_config_platform", "npm_config_libc", "libc", "buildSharpLibvipsIncludeDir", "buildSharpLibvipsCPlusPlusDir", "buildSharpLibvipsLibDir", "isUnsupportedNodeRuntime", "CC", "isRosetta", "sha512", "s", "yarnLocator", "identHash", "npmVersion", "spawnRebuild", "globalLibvipsVersion", "pkgConfigPath", "skipSearch", "status", "reason", "logger", "useGlobalLibvips", "globalVipsVersion", "require_sharp", "__commonJSMin", "exports", "module", "familySync", "versionSync", "runtimePlatformArch", "isUnsupportedNodeRuntime", "prebuiltPlatforms", "minimumLibvipsVersion", "runtimePlatform", "paths", "path", "sharp", "errors", "err", "isLinux", "isMacOs", "isWindows", "os", "help", "messages", "found", "expected", "cpu", "libc", "config", "libcFound", "libcRequires", "require_constructor", "__commonJSMin", "exports", "module", "util", "stream", "is", "debuglog", "queueListener", "queueLength", "Sharp", "input", "options", "warning", "clone", "require_input", "__commonJSMin", "exports", "module", "is", "sharp", "align", "inputStreamParameters", "_inputOptionsFromObject", "obj", "params", "p", "_createInputDescriptor", "input", "inputOptions", "containerOptions", "inputDescriptor", "_write", "chunk", "_encoding", "callback", "_flattenBufferIn", "_isStreamInput", "metadata", "stack", "err", "resolve", "reject", "finished", "stats", "Sharp", "require_resize", "__commonJSMin", "exports", "module", "is", "gravity", "position", "extendWith", "strategy", "kernel", "fit", "mapFitToCanvas", "isRotationExpected", "options", "isResizeExpected", "resize", "widthOrOptions", "height", "canvas", "pos", "extend", "extract", "suffix", "name", "value", "trim", "Sharp", "require_composite", "__commonJSMin", "exports", "module", "is", "blend", "composite", "images", "image", "inputOptions", "Sharp", "require_operation", "__commonJSMin", "exports", "module", "is", "vipsPrecision", "rotate", "angle", "options", "autoOrient", "flip", "flop", "affine", "matrix", "flatMatrix", "sharpen", "flat", "jagged", "median", "size", "blur", "sigma", "dilate", "width", "erode", "flatten", "unflatten", "gamma", "gammaOut", "negate", "normalise", "normalize", "clahe", "convolve", "kernel", "a", "b", "threshold", "boolean", "operand", "operator", "linear", "recomb", "inputMatrix", "recombMatrix", "modulate", "Sharp", "require_color", "__commonJSMin", "exports", "module", "__defProp", "__getOwnPropDesc", "__getOwnPropNames", "__hasOwnProp", "__export", "target", "all", "name", "__copyProps", "to", "from", "except", "desc", "key", "__toCommonJS", "mod", "index_exports", "index_default", "color_name_default", "reverseNames", "cs", "string", "prefix", "value", "model", "abbr", "hex", "rgba", "per", "keyword", "rgb", "match", "i", "hexAlpha", "i2", "clamp", "hsl", "alpha", "h", "s", "l", "a", "hwb", "w", "b", "hexDouble", "r", "g", "hsla", "hwba", "number_", "min", "max", "string_", "color_string_default", "reverseKeywords", "convert", "conversions_default", "LAB_FT", "srgbNonlinearTransform", "c", "cc", "srgbNonlinearTransformInv", "channels", "labels", "delta", "rdif", "gdif", "bdif", "v", "diff", "diffc", "lp", "mp", "sp", "aa", "bb", "k", "m", "y", "comparativeDistance", "x", "reversed", "currentClosestDistance", "currentClosestKeyword", "distance", "z", "xyz", "t3", "t2", "t1", "smin", "lmin", "sv", "hsv", "hi", "f", "p", "q", "t", "vmin", "sl", "wh", "bl", "ratio", "n", "cmyk", "oklab", "ll", "oklch", "lab", "y2", "x2", "z2", "lch", "hr", "args", "saturation", "ansi", "color", "mult", "rem", "colorString", "char", "integer", "chroma", "hue", "grayscale", "hcg", "pure", "mg", "apple", "gray", "buildGraph", "graph", "models2", "length", "deriveBFS", "fromModel", "queue", "current", "adjacents", "adjacent", "node", "link", "wrapConversion", "toModel", "path", "fn", "cur", "route", "conversion", "route_default", "convert2", "models", "wrapRaw", "wrappedFn", "arg0", "wrapRounded", "result", "routes", "routeModels", "color_convert_default", "skippedModels", "hashedModelKeys", "limiters", "Color", "object", "newArray", "zeroArray", "keys", "hashedKeys", "limit", "places", "self", "arguments_", "roundToPlace", "getset", "maxfn", "rgbArray", "alphaHex", "lum", "element", "chan", "color2", "lum1", "lum2", "contrastRatio", "degrees", "mixinColor", "weight", "color1", "w1", "w2", "assertArray", "roundTo", "number", "channel", "modifier", "array", "require_colour", "__commonJSMin", "exports", "module", "require_colour", "__commonJSMin", "exports", "module", "color", "is", "colourspace", "tint", "greyscale", "grayscale", "pipelineColourspace", "pipelineColorspace", "colorspace", "toColourspace", "toColorspace", "_getBackgroundColourOption", "value", "colour", "_setBackgroundColourOption", "key", "Sharp", "require_channel", "__commonJSMin", "exports", "module", "is", "bool", "removeAlpha", "ensureAlpha", "alpha", "extractChannel", "channel", "channelMap", "joinChannel", "images", "options", "image", "bandbool", "boolOp", "Sharp", "require_output", "__commonJSMin", "exports", "module", "path", "is", "sharp", "formats", "jp2Regex", "errJp2Save", "bitdepthFromColourCount", "colours", "toFile", "fileOut", "callback", "err", "stack", "toBuffer", "options", "keepExif", "withExif", "exif", "ifd", "entries", "k", "v", "withExifMerge", "keepIccProfile", "withIccProfile", "icc", "keepXmp", "withXmp", "xmp", "keepMetadata", "withMetadata", "toFormat", "format", "actualFormat", "jpeg", "optimiseCoding", "trellisQuantisation", "optimiseScans", "quantisationTable", "png", "webp", "trySetAnimationOptions", "gif", "jp2", "source", "target", "tiff", "avif", "heif", "jxl", "raw", "tile", "centre", "timeout", "_updateFormatOut", "formatOut", "_setBooleanOption", "key", "val", "_read", "_pipeline", "data", "info", "resolve", "reject", "Sharp", "require_utility", "__commonJSMin", "exports", "module", "events", "detectLibc", "is", "runtimePlatformArch", "sharp", "runtimePlatform", "libvipsVersion", "format", "interpolators", "versions", "cache", "options", "concurrency", "queue", "counters", "simd", "block", "unblock", "Sharp", "require_lib", "__commonJSMin", "exports", "module", "Sharp", "index_exports", "__export", "detectInputType", "generatePalette", "generatePaletteFromDataUri", "generatePaletteFromHex", "generatePaletteFromPath", "generatePaletteFromUrl", "getAlgorithm", "getGameBoyPalette", "listAlgorithms", "registerAlgorithm", "unregisterAlgorithm", "__toCommonJS", "import_promises", "import_node_path", "import_sharp", "signum", "num", "lerp", "start", "stop", "amount", "clampInt", "min", "max", "input", "clampDouble", "sanitizeDegreesInt", "degrees", "sanitizeDegreesDouble", "differenceDegrees", "a", "b", "matrixMultiply", "row", "matrix", "c", "SRGB_TO_XYZ", "XYZ_TO_SRGB", "WHITE_POINT_D65", "argbFromRgb", "red", "green", "blue", "argbFromLinrgb", "linrgb", "r", "delinearized", "g", "b", "alphaFromArgb", "argb", "redFromArgb", "greenFromArgb", "blueFromArgb", "argbFromXyz", "x", "y", "z", "matrix", "XYZ_TO_SRGB", "linearR", "linearG", "linearB", "r", "delinearized", "g", "b", "argbFromRgb", "xyzFromArgb", "argb", "linearized", "redFromArgb", "greenFromArgb", "blueFromArgb", "matrixMultiply", "SRGB_TO_XYZ", "argbFromLab", "l", "a", "whitePoint", "WHITE_POINT_D65", "fy", "fx", "fz", "xNormalized", "labInvf", "yNormalized", "zNormalized", "labFromArgb", "labF", "argbFromLstar", "lstar", "yFromLstar", "component", "lstarFromArgb", "lstarFromY", "rgbComponent", "normalized", "clampInt", "whitePointD65", "labF", "t", "e", "kappa", "labInvf", "ft", "ft3", "ViewingConditions", "_ViewingConditions", "whitePoint", "whitePointD65", "adaptingLuminance", "yFromLstar", "backgroundLstar", "surround", "discountingIlluminant", "xyz", "rW", "gW", "bW", "f", "c", "lerp", "d", "nc", "rgbD", "k", "k4", "k4F", "fl", "n", "z", "nbb", "ncb", "rgbAFactors", "rgbA", "aw", "fLRoot", "Cam16", "_Cam16", "hue", "chroma", "j", "q", "m", "s", "jstar", "astar", "bstar", "other", "dJ", "dA", "dB", "dEPrime", "argb", "ViewingConditions", "viewingConditions", "red", "green", "blue", "redL", "linearized", "greenL", "blueL", "x", "y", "z", "rC", "gC", "bC", "rD", "gD", "bD", "rAF", "gAF", "bAF", "rA", "signum", "gA", "bA", "a", "b", "u", "p2", "atanDegrees", "hueRadians", "ac", "huePrime", "eHue", "t", "alpha", "c", "mstar", "h", "hRad", "p1", "hSin", "hCos", "gamma", "rCBase", "gCBase", "bCBase", "rF", "gF", "bF", "argbFromXyz", "J", "Q", "C", "M", "HctSolver", "_HctSolver", "angle", "rgbComponent", "normalized", "delinearized", "component", "af", "signum", "linrgb", "scaledDiscount", "matrixMultiply", "rA", "gA", "bA", "a", "b", "c", "deltaAB", "deltaAC", "source", "mid", "target", "t", "coordinate", "axis", "x", "y", "n", "kR", "kG", "kB", "coordA", "coordB", "g", "r", "targetHue", "left", "right", "leftHue", "rightHue", "initialized", "uncut", "midHue", "segment", "lPlane", "rPlane", "i", "mPlane", "midPlaneCoordinate", "adapted", "adaptedAbs", "base", "hueRadians", "chroma", "j", "viewingConditions", "ViewingConditions", "tInnerCoeff", "p1", "hSin", "hCos", "iterationRound", "jNormalized", "alpha", "p2", "gamma", "rCScaled", "gCScaled", "bCScaled", "fnj", "argbFromLinrgb", "hueDegrees", "lstar", "argbFromLstar", "sanitizeDegreesDouble", "yFromLstar", "exactAnswer", "Cam16", "Hct", "_Hct", "hue", "chroma", "tone", "HctSolver", "argb", "newHue", "newChroma", "newTone", "cam", "Cam16", "lstarFromArgb", "vc", "viewedInVc", "recastInVc", "ViewingConditions", "lstarFromY", "Contrast", "_Contrast", "toneA", "toneB", "clampDouble", "yFromLstar", "y1", "y2", "lighter", "darker", "tone", "ratio", "darkY", "lightY", "realContrast", "delta", "returnValue", "lstarFromY", "lighterSafe", "darkerSafe", "DislikeAnalyzer", "_DislikeAnalyzer", "hct", "huePasses", "chromaPasses", "tonePasses", "Hct", "DynamicColor", "_DynamicColor", "args", "name", "palette", "tone", "isBackground", "background", "secondBackground", "contrastCurve", "toneDeltaPair", "scheme", "cachedAnswer", "answer", "decreasingContrast", "roleA", "roleB", "delta", "polarity", "stayTogether", "bgTone", "aIsNearer", "nearer", "farther", "amNearer", "expansionDir", "nContrast", "fContrast", "nInitialTone", "nTone", "Contrast", "fInitialTone", "fTone", "clampDouble", "desiredRatio", "bg1", "bg2", "bgTone1", "bgTone2", "upper", "lower", "lightOption", "darkOption", "availables", "ratio", "lighterTone", "darkerTone", "lighterRatio", "darkerRatio", "negligibleDifference", "TonalPalette", "_TonalPalette", "argb", "hct", "Hct", "hue", "chroma", "keyColor", "KeyColor", "tone", "requestedChroma", "lowerTone", "upperTone", "midTone", "isAscending", "ContrastCurve", "low", "normal", "medium", "high", "contrastLevel", "lerp", "ToneDeltaPair", "roleA", "roleB", "delta", "polarity", "stayTogether", "Variant", "isFidelity", "scheme", "Variant", "isMonochrome", "findDesiredChromaByTone", "hue", "chroma", "tone", "byDecreasingTone", "answer", "closestToChroma", "Hct", "chromaPeak", "potentialSolution", "potentialDelta", "currentDelta", "MaterialDynamicColors", "_MaterialDynamicColors", "s", "DynamicColor", "ContrastCurve", "ToneDeltaPair", "initialTone", "proposedHct", "DislikeAnalyzer", "DynamicScheme", "args", "Hct", "TonalPalette", "sourceColor", "hues", "rotations", "sourceHue", "sanitizeDegreesDouble", "size", "i", "thisHue", "nextHue", "dynamicColor", "MaterialDynamicColors", "LabPointProvider", "argb", "labFromArgb", "point", "argbFromLab", "from", "to", "dL", "dA", "dB", "MAX_ITERATIONS", "MIN_MOVEMENT_DISTANCE", "QuantizerWsmeans", "inputPixels", "startingClusters", "maxColors", "pixelToCount", "points", "pixels", "pointProvider", "LabPointProvider", "pointCount", "i", "inputPixel", "pixelCount", "counts", "pixel", "count", "clusterCount", "clusters", "additionalClustersNeeded", "l", "a", "b", "clusterIndices", "indexMatrix", "j", "distanceToIndexMatrix", "DistanceAndIndex", "pixelCountSums", "iteration", "distance", "pointsMoved", "point", "previousClusterIndex", "previousCluster", "previousDistance", "minimumDistance", "newClusterIndex", "componentASums", "componentBSums", "componentCSums", "clusterIndex", "c", "argbToPopulation", "possibleNewCluster", "QuantizerMap", "pixels", "countByColor", "i", "pixel", "alphaFromArgb", "INDEX_BITS", "SIDE_LENGTH", "TOTAL_SIZE", "directions", "QuantizerWu", "weights", "momentsR", "momentsG", "momentsB", "moments", "cubes", "pixels", "maxColors", "createBoxesResult", "countByColor", "QuantizerMap", "pixel", "count", "red", "redFromArgb", "green", "greenFromArgb", "blue", "blueFromArgb", "bitsToRemove", "iR", "iG", "iB", "index", "r", "area", "areaR", "areaG", "areaB", "area2", "g", "line", "lineR", "lineG", "lineB", "line2", "b", "previousIndex", "Box", "volumeVariance", "generatedColorCount", "next", "i", "temp", "j", "CreateBoxesResult", "colorCount", "colors", "cube", "weight", "color", "dr", "dg", "db", "xx", "hypotenuse", "volume", "one", "two", "wholeR", "wholeG", "wholeB", "wholeW", "maxRResult", "maxGResult", "maxBResult", "direction", "maxR", "maxG", "maxB", "first", "last", "bottomR", "bottomG", "bottomB", "bottomW", "max", "cut", "halfR", "halfG", "halfB", "halfW", "tempNumerator", "tempDenominator", "MaximizeResult", "moment", "position", "r0", "r1", "g0", "g1", "b0", "b1", "vol", "requestedCount", "resultCount", "cutLocation", "maximum", "QuantizerCelebi", "pixels", "maxColors", "wuResult", "QuantizerWu", "QuantizerWsmeans", "SchemeExpressive", "_SchemeExpressive", "DynamicScheme", "sourceColorHct", "isDark", "contrastLevel", "Variant", "TonalPalette", "sanitizeDegreesDouble", "SchemeVibrant", "_SchemeVibrant", "DynamicScheme", "sourceColorHct", "isDark", "contrastLevel", "Variant", "TonalPalette", "SCORE_OPTION_DEFAULTS", "compare", "a", "b", "Score", "_Score", "colorsToPopulation", "options", "desired", "fallbackColorARGB", "filter", "colorsHct", "huePopulation", "populationSum", "argb", "population", "hct", "Hct", "hue", "hueExcitedProportions", "proportion", "i", "neighborHue", "sanitizeDegreesInt", "scoredHct", "proportionScore", "chromaWeight", "chromaScore", "score", "chosenColors", "differenceDegrees", "chosenHct", "colors", "hexFromArgb", "argb", "r", "redFromArgb", "g", "greenFromArgb", "b", "blueFromArgb", "outParts", "i", "part", "DEFAULT_ALGORITHM", "algorithmRegistry", "builtInsRegistered", "registerAlgorithm", "name", "generator", "unregisterAlgorithm", "getAlgorithm", "listAlgorithms", "detectInputType", "input", "trimmed", "isHex", "isDataUri", "isUrl", "generatePalette", "options", "type", "generatePaletteFromHex", "generatePaletteFromDataUri", "generatePaletteFromUrl", "generatePaletteFromPath", "hex", "normalizedHex", "normalizeHex", "baseRgb", "hexToRgb", "buildPaletteResultFromBase", "dataUri", "buffer", "decodeDataUri", "buildPaletteResultFromBuffer", "url", "fetchBuffer", "filePath", "resolved", "path", "fs", "inputType", "algorithm", "count", "resolvedAlgorithm", "resolveAlgorithm", "getAverageColor", "baseHex", "rgbToHex", "buildPaletteResult", "rgbToHsl", "buildPaletteHsl", "base", "hue", "normalizeHue", "sat", "clamp", "light", "buildByOffsets", "resolveCount", "buildByCycle", "buildMonochrome", "buildHslPaletteColors", "color", "hslToRgb", "registerBuiltInAlgorithms", "colors", "extractMonetPalette", "resolveMonetCount", "sourceArgb", "argbFromHex", "buildMonetPaletteFromSourceArgb", "extractDominantPalette", "value", "raw", "cleaned", "char", "clean", "g", "b", "argbFromRgb", "toHex", "r", "max", "min", "delta", "h", "l", "s", "c", "x", "m", "channels", "sharp", "data", "info", "pixels", "step", "i", "sampled", "downsamplePixels", "quantized", "QuantizerCelebi", "Score", "entries", "argb", "population", "argbToRgb", "a", "countDelta", "rgbKey", "totalCount", "sum", "entry", "coverageTarget", "candidateEntries", "coverage", "maxCount", "seeds", "best", "bestScore", "seed", "rgbDistanceSq", "minDist", "weight", "score", "refineCentroids", "fallback", "buildOffsets", "maxOffset", "offsets", "buildLightOffsets", "offset", "lightStep", "result", "layer", "stride", "hct", "Hct", "palette", "TonalPalette", "buildToneSteps", "tone", "hexFromArgb", "tones", "base64", "response", "arrayBuffer", "dr", "dg", "db", "accum", "bestIndex", "bestDist", "dist", "target", "index", "bucket", "normalized", "getGameBoyPalette"]
7
7
  }