{"version":3,"file":"index.cjs","sources":["../src/onCSSIdentifier.js","../src/options.js","../src/onCSSDeclaration.js","../src/index.js"],"sourcesContent":["/** @type {(decl: CSSIdentifier) => void} Transform the rebeccapurple keyword. */\nconst onCSSIdentifier = node => {\n\tif (isRebeccaPurple(node.value)) node.value = '#639';\n};\n\nexport default onCSSIdentifier;\n\n/** @type {(value: RegExp) => (value: string) => boolean} Return a function that checks whether the expression exists in a value. */\nconst createRegExpTest = Function.bind.bind(RegExp.prototype.test);\n\n/** Return whether the value is rebeccapurple. */\nconst isRebeccaPurple = createRegExpTest(/^rebeccapurple$/i);\n","export default {\n\t/** Whether to preserve the original keyword. */\n\tpreserve: false,\n};\n","import valuesParser from 'postcss-value-parser';\nimport onCSSIdentifier from './onCSSIdentifier';\nimport options from './options';\n\n/** @type {(decl: CSSDeclaration) => void} Transform the rebeccapurple keyword in CSS Declarations. */\nconst onCSSDeclaration = decl => {\n\tconst { value: originalValue } = decl;\n\n\tif (hasAnyRebeccapurple(originalValue)) {\n\t\tconst valueAST = valuesParser(originalValue);\n\n\t\tvalueAST.walk(node => {\n\t\t\tif (node.type === 'word') {\n\t\t\t\tonCSSIdentifier(node);\n\t\t\t}\n\t\t});\n\n\t\tconst modifiedValue = String(valueAST);\n\n\t\tif (modifiedValue !== originalValue) {\n\t\t\tif (options.preserve) decl.cloneBefore({ value: modifiedValue });\n\t\t\telse decl.value = modifiedValue;\n\t\t}\n\t}\n};\n\nexport default onCSSDeclaration;\n\n/** @type {(value: RegExp) => (value: string) => boolean} Return a function that checks whether the expression exists in a value. */\nconst createRegExpTest = Function.bind.bind(RegExp.prototype.test);\n\n/** Return whether the value has a rebeccapurple keyword. */\nconst hasAnyRebeccapurple = createRegExpTest(/(^|[^\\w-])rebeccapurple([^\\w-]|$)/i);\n\n/** @typedef {import('postcss').Declaration} CSSDeclaration */\n","import onCSSDeclaration from './onCSSDeclaration';\nimport options from './options';\n\n/** Transform the rebeccapurple keyword in CSS. */\nfunction postcssColorRebeccaPurple(opts) {\n\toptions.preserve = 'preserve' in Object(opts) ? Boolean(opts.preserve) : false;\n\n\treturn {\n\t\tpostcssPlugin: 'postcss-color-rebeccapurple',\n\t\tDeclaration: onCSSDeclaration,\n\t};\n}\n\npostcssColorRebeccaPurple.postcss = true;\n\nexport default postcssColorRebeccaPurple;\n"],"names":["isRebeccaPurple","Function","bind","RegExp","prototype","test","createRegExpTest","preserve","onCSSDeclaration","decl","value","originalValue","hasAnyRebeccapurple","valueAST","valuesParser","walk","node","type","onCSSIdentifier","modifiedValue","String","options","cloneBefore","postcssColorRebeccaPurple","opts","Object","Boolean","postcssPlugin","Declaration","postcss"],"mappings":"8HACA,MAUMA,EAHmBC,SAASC,KAAKA,KAAKC,OAAOC,UAAUC,KAGrCC,CAAiB,oBCXzC,MAAe,CAEdC,UAAU,GCGX,MAAMC,EAAmBC,UAChBC,MAAOC,GAAkBF,KAE7BG,EAAoBD,GAAgB,OACjCE,EAAWC,UAAaH,GAE9BE,EAASE,MAAKC,IACK,SAAdA,EAAKC,MFXYD,CAAAA,IACnBhB,EAAgBgB,EAAKN,SAAQM,EAAKN,MAAQ,SEW3CQ,CAAgBF,YAIZG,EAAgBC,OAAOP,GAEzBM,IAAkBR,IACjBU,EAAQd,SAAUE,EAAKa,YAAY,CAAEZ,MAAOS,IAC3CV,EAAKC,MAAQS,KAWfP,EAHmBX,SAASC,KAAKA,KAAKC,OAAOC,UAAUC,KAGjCC,CAAiB,sCC5B7C,SAASiB,EAA0BC,UAClCH,EAAQd,SAAW,aAAckB,OAAOD,IAAQE,QAAQF,EAAKjB,UAEtD,CACNoB,cAAe,8BACfC,YAAapB,GAIfe,EAA0BM,SAAU"}