{"version":3,"file":"index.esm.mjs","sources":["src/lib/is-ignored.js","src/lib/get-custom-properties-from-root.js","src/lib/get-custom-properties-from-imports.js","src/lib/transform-value-ast.js","src/lib/transform-properties.js","src/lib/write-custom-properties-to-exports.js","src/index.js"],"sourcesContent":["function isBlockIgnored(ruleOrDeclaration) {\n\tvar rule = ruleOrDeclaration.selector ?\n\t\truleOrDeclaration : ruleOrDeclaration.parent;\n\n\treturn /(!\\s*)?postcss-custom-properties:\\s*off\\b/i.test(rule.toString())\n}\n\nfunction isRuleIgnored(rule) {\n\tvar previous = rule.prev();\n\n\treturn Boolean(isBlockIgnored(rule) ||\n\t\tprevious &&\n\t\tprevious.type === 'comment' &&\n\t\t/(!\\s*)?postcss-custom-properties:\\s*ignore\\s+next\\b/i.test(previous.text));\n}\n\nexport {\n\tisBlockIgnored,\n\tisRuleIgnored\n}\n","import { parse } from 'postcss-values-parser';\nimport { isBlockIgnored } from './is-ignored';\n\n// return custom selectors from the css root, conditionally removing them\nexport default function getCustomPropertiesFromRoot(root, opts) {\n\t// initialize custom selectors\n\tconst customPropertiesFromHtmlElement = {};\n\tconst customPropertiesFromRootPseudo = {};\n\n\t// for each html or :root rule\n\troot.nodes.slice().forEach(rule => {\n\t\tconst customPropertiesObject = isHtmlRule(rule)\n\t\t\t? customPropertiesFromHtmlElement\n\t\t: isRootRule(rule)\n\t\t\t? customPropertiesFromRootPseudo\n\t\t: null;\n\n\t\t// for each custom property\n\t\tif (customPropertiesObject) {\n\t\t\trule.nodes.slice().forEach(decl => {\n\t\t\t\tif (isCustomDecl(decl) && !isBlockIgnored(decl)) {\n\t\t\t\t\tconst { prop } = decl;\n\n\t\t\t\t\t// write the parsed value to the custom property\n\t\t\t\t\tcustomPropertiesObject[prop] = parse(decl.value).nodes;\n\n\t\t\t\t\t// conditionally remove the custom property declaration\n\t\t\t\t\tif (!opts.preserve) {\n\t\t\t\t\t\tdecl.remove();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// conditionally remove the empty html or :root rule\n\t\t\tif (!opts.preserve && isEmptyParent(rule) && !isBlockIgnored(rule)) {\n\t\t\t\trule.remove();\n\t\t\t}\n\t\t}\n\t});\n\n\t// return all custom properties, preferring :root properties over html properties\n\treturn { ...customPropertiesFromHtmlElement, ...customPropertiesFromRootPseudo };\n}\n\n// match html and :root rules\nconst htmlSelectorRegExp = /^html$/i;\nconst rootSelectorRegExp = /^:root$/i;\nconst customPropertyRegExp = /^--[A-z][\\w-]*$/;\n\n// whether the node is an html or :root rule\nconst isHtmlRule = node => node.type === 'rule' && node.selector.split(',').some(item => htmlSelectorRegExp.test(item)) && Object(node.nodes).length;\nconst isRootRule = node => node.type === 'rule' && node.selector.split(',').some(item => rootSelectorRegExp.test(item)) && Object(node.nodes).length;\n\n// whether the node is an custom property\nconst isCustomDecl = node => node.type === 'decl' && customPropertyRegExp.test(node.prop);\n\n// whether the node is a parent without children\nconst isEmptyParent = node => Object(node.nodes).length === 0;\n","import fs from 'fs';\nimport path from 'path';\nimport postcss from 'postcss';\nimport { parse } from 'postcss-values-parser';\nimport getCustomPropertiesFromRoot from './get-custom-properties-from-root';\n\n/* Get Custom Properties from CSS File\n/* ========================================================================== */\n\nasync function getCustomPropertiesFromCSSFile(from) {\n\tconst css = await readFile(from);\n\tconst root = postcss.parse(css, { from });\n\n\treturn getCustomPropertiesFromRoot(root, { preserve: true });\n}\n\n/* Get Custom Properties from Object\n/* ========================================================================== */\n\nfunction getCustomPropertiesFromObject(object) {\n\tconst customProperties = Object.assign(\n\t\t{},\n\t\tObject(object).customProperties,\n\t\tObject(object)['custom-properties']\n\t);\n\n\tfor (const key in customProperties) {\n\t\tcustomProperties[key] = parse(String(customProperties[key])).nodes;\n\t}\n\n\treturn customProperties;\n}\n\n/* Get Custom Properties from JSON file\n/* ========================================================================== */\n\nasync function getCustomPropertiesFromJSONFile(from) {\n\tconst object = await readJSON(from);\n\n\treturn getCustomPropertiesFromObject(object);\n}\n\n/* Get Custom Properties from JS file\n/* ========================================================================== */\n\nasync function getCustomPropertiesFromJSFile(from) {\n\tconst object = await import(from);\n\n\treturn getCustomPropertiesFromObject(object);\n}\n\n/* Get Custom Properties from Imports\n/* ========================================================================== */\n\nexport default function getCustomPropertiesFromImports(sources) {\n\treturn sources.map(source => {\n\t\tif (source instanceof Promise) {\n\t\t\treturn source;\n\t\t} else if (source instanceof Function) {\n\t\t\treturn source();\n\t\t}\n\n\t\t// read the source as an object\n\t\tconst opts = source === Object(source) ? source : { from: String(source) };\n\n\t\t// skip objects with Custom Properties\n\t\tif (opts.customProperties || opts['custom-properties']) {\n\t\t\treturn opts\n\t\t}\n\n\t\t// source pathname\n\t\tconst from = path.resolve(String(opts.from || ''));\n\n\t\t// type of file being read from\n\t\tconst type = (opts.type || path.extname(from).slice(1)).toLowerCase();\n\n\t\treturn { type, from };\n\t}).reduce(async (customProperties, source) => {\n\t\tconst { type, from } = await source;\n\n\t\tif (type === 'css' || type === 'pcss') {\n\t\t\treturn Object.assign(await customProperties, await getCustomPropertiesFromCSSFile(from));\n\t\t}\n\n\t\tif (type === 'js') {\n\t\t\treturn Object.assign(await customProperties, await getCustomPropertiesFromJSFile(from));\n\t\t}\n\n\t\tif (type === 'json') {\n\t\t\treturn Object.assign(await customProperties, await getCustomPropertiesFromJSONFile(from));\n\t\t}\n\n\t\treturn Object.assign(await customProperties, await getCustomPropertiesFromObject(await source));\n\t}, {});\n}\n\n/* Helper utilities\n/* ========================================================================== */\n\nconst readFile = from => new Promise((resolve, reject) => {\n\tfs.readFile(from, 'utf8', (error, result) => {\n\t\tif (error) {\n\t\t\treject(error);\n\t\t} else {\n\t\t\tresolve(result);\n\t\t}\n\t});\n});\n\nconst readJSON = async from => JSON.parse(await readFile(from));\n","export default function transformValueAST(root, customProperties) {\n\tif (root.nodes && root.nodes.length) {\n\t\troot.nodes.slice().forEach(child => {\n\t\t\tif (isVarFunction(child)) {\n\t\t\t\t// eslint-disable-next-line no-unused-vars\n\t\t\t\tconst [propertyNode, comma, ...fallbacks] = child.nodes;\n\t\t\t\tconst { value: name } = propertyNode;\n\n\t\t\t\tif (name in Object(customProperties)) {\n\t\t\t\t\t// conditionally replace a known custom property\n\t\t\t\t\tconst nodes = asClonedArrayWithBeforeSpacing(customProperties[name], child.raws.before);\n\n\t\t\t\t\t/**\n\t\t\t\t\t * https://github.com/postcss/postcss-custom-properties/issues/221\n\t\t\t\t\t * https://github.com/postcss/postcss-custom-properties/issues/218\n\t\t\t\t\t *\n\t\t\t\t\t * replaceWith loses node.raws values, so we need to save it and restore\n\t\t\t\t\t */\n\t\t\t\t\tconst raws = nodes.map(node => ({...node.raws}));\n\n\t\t\t\t\tchild.replaceWith(...nodes);\n\n\t\t\t\t\tnodes.forEach((node, index) => {\n\t\t\t\t\t\tnode.raws = raws[index];\n\t\t\t\t\t});\n\n\t\t\t\t\tretransformValueAST({ nodes }, customProperties, name);\n\t\t\t\t} else if (fallbacks.length) {\n\t\t\t\t\t// conditionally replace a custom property with a fallback\n\t\t\t\t\tconst index = root.nodes.indexOf(child);\n\n\t\t\t\t\tif (index !== -1) {\n\t\t\t\t\t\troot.nodes.splice(index, 1, ...asClonedArrayWithBeforeSpacing(fallbacks, child.raws.before));\n\t\t\t\t\t}\n\n\t\t\t\t\ttransformValueAST(root, customProperties);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttransformValueAST(child, customProperties);\n\t\t\t}\n\t\t});\n\t}\n\n\treturn root;\n}\n\n// retransform the current ast without a custom property (to prevent recursion)\nfunction retransformValueAST(root, customProperties, withoutProperty) {\n\tconst nextCustomProperties = Object.assign({}, customProperties);\n\n\tdelete nextCustomProperties[withoutProperty];\n\n\treturn transformValueAST(root, nextCustomProperties);\n}\n\n// match var() functions\nconst varRegExp = /^var$/i;\n\n// whether the node is a var() function\nconst isVarFunction = node => node.type === 'func' && varRegExp.test(node.name) && Object(node.nodes).length > 0;\n\n// return an array with its nodes cloned, preserving the raw\nconst asClonedArrayWithBeforeSpacing = (array, beforeSpacing) => {\n\tconst clonedArray = asClonedArray(array, null);\n\n\tif (clonedArray[0]) {\n\t\tclonedArray[0].raws.before = beforeSpacing;\n\t}\n\n\treturn clonedArray;\n};\n\n// return an array with its nodes cloned\nconst asClonedArray = (array, parent) => array.map(node => asClonedNode(node, parent));\n\n// return a cloned node\nconst asClonedNode = (node, parent) => {\n\tconst cloneNode = new node.constructor(node);\n\n\tfor (const key in node) {\n\t\tif (key === 'parent') {\n\t\t\tcloneNode.parent = parent;\n\t\t} else if (Object(node[key]).constructor === Array) {\n\t\t\tcloneNode[key] = asClonedArray(node.nodes, cloneNode);\n\t\t} else if (Object(node[key]).constructor === Object) {\n\t\t\tcloneNode[key] = Object.assign({}, node[key]);\n\t\t}\n\t}\n\n\treturn cloneNode;\n};\n","import { parse } from 'postcss-values-parser';\nimport transformValueAST from './transform-value-ast';\nimport { isRuleIgnored } from './is-ignored';\n\n// transform custom pseudo selectors with custom selectors\nexport default (root, customProperties, opts) => {\n\t// walk decls that can be transformed\n\troot.walkDecls(decl => {\n\t\tif (isTransformableDecl(decl) && !isRuleIgnored(decl)) {\n\t\t\tconst originalValue = decl.value;\n\t\t\tconst valueAST = parse(originalValue);\n\t\t\tconst value = String(transformValueAST(valueAST, customProperties));\n\n\t\t\t// conditionally transform values that have changed\n\t\t\tif (value !== originalValue) {\n\t\t\t\tif (opts.preserve) {\n\t\t\t\t\tconst beforeDecl = decl.cloneBefore({ value });\n\n\t\t\t\t\tif (hasTrailingComment(beforeDecl)) {\n\t\t\t\t\t\tbeforeDecl.raws.value.value = beforeDecl.value.replace(trailingCommentRegExp, '$1');\n\t\t\t\t\t\tbeforeDecl.raws.value.raw = beforeDecl.raws.value.value + beforeDecl.raws.value.raw.replace(trailingCommentRegExp, '$2');\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tdecl.value = value;\n\n\t\t\t\t\tif (hasTrailingComment(decl)) {\n\t\t\t\t\t\tdecl.raws.value.value = decl.value.replace(trailingCommentRegExp, '$1');\n\t\t\t\t\t\tdecl.raws.value.raw = decl.raws.value.value + decl.raws.value.raw.replace(trailingCommentRegExp, '$2');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n};\n\n// match custom properties\nconst customPropertyRegExp = /^--[A-z][\\w-]*$/;\n\n// match custom property inclusions\nconst customPropertiesRegExp = /(^|[^\\w-])var\\([\\W\\w]+\\)/;\n\n// whether the declaration should be potentially transformed\nconst isTransformableDecl = decl => !customPropertyRegExp.test(decl.prop) && customPropertiesRegExp.test(decl.value);\n\n// whether the declaration has a trailing comment\nconst hasTrailingComment = decl => 'value' in Object(Object(decl.raws).value) && 'raw' in decl.raws.value && trailingCommentRegExp.test(decl.raws.value.raw);\nconst trailingCommentRegExp = /^([\\W\\w]+)(\\s*\\/\\*[\\W\\w]+?\\*\\/)$/;\n","import fs from 'fs';\nimport path from 'path';\n\n/* Write Custom Properties to CSS File\n/* ========================================================================== */\n\nasync function writeCustomPropertiesToCssFile(to, customProperties) {\n\tconst cssContent = Object.keys(customProperties).reduce((cssLines, name) => {\n\t\tcssLines.push(`\\t${name}: ${customProperties[name]};`);\n\n\t\treturn cssLines;\n\t}, []).join('\\n');\n\tconst css = `:root {\\n${cssContent}\\n}\\n`;\n\n\tawait writeFile(to, css);\n}\n\n/* Write Custom Properties to SCSS File\n/* ========================================================================== */\n\nasync function writeCustomPropertiesToScssFile(to, customProperties) {\n\tconst scssContent = Object.keys(customProperties).reduce((scssLines, name) => {\n\t\tconst scssName = name.replace('--', '$');\n\t\tscssLines.push(`${scssName}: ${customProperties[name]};`);\n\n\t\treturn scssLines;\n\t}, []).join('\\n');\n\tconst scss = `${scssContent}\\n`;\n\n\tawait writeFile(to, scss);\n}\n\n/* Write Custom Properties to JSON file\n/* ========================================================================== */\n\nasync function writeCustomPropertiesToJsonFile(to, customProperties) {\n\tconst jsonContent = JSON.stringify({\n\t\t'custom-properties': customProperties\n\t}, null, '  ');\n\tconst json = `${jsonContent}\\n`;\n\n\tawait writeFile(to, json);\n}\n\n/* Write Custom Properties to Common JS file\n/* ========================================================================== */\n\nasync function writeCustomPropertiesToCjsFile(to, customProperties) {\n\tconst jsContents = Object.keys(customProperties).reduce((jsLines, name) => {\n\t\tjsLines.push(`\\t\\t'${escapeForJS(name)}': '${escapeForJS(customProperties[name])}'`);\n\n\t\treturn jsLines;\n\t}, []).join(',\\n');\n\tconst js = `module.exports = {\\n\\tcustomProperties: {\\n${jsContents}\\n\\t}\\n};\\n`;\n\n\tawait writeFile(to, js);\n}\n\n/* Write Custom Properties to Module JS file\n/* ========================================================================== */\n\nasync function writeCustomPropertiesToMjsFile(to, customProperties) {\n\tconst mjsContents = Object.keys(customProperties).reduce((mjsLines, name) => {\n\t\tmjsLines.push(`\\t'${escapeForJS(name)}': '${escapeForJS(customProperties[name])}'`);\n\n\t\treturn mjsLines;\n\t}, []).join(',\\n');\n\tconst mjs = `export const customProperties = {\\n${mjsContents}\\n};\\n`;\n\n\tawait writeFile(to, mjs);\n}\n\n/* Write Custom Properties to Exports\n/* ========================================================================== */\n\nexport default function writeCustomPropertiesToExports(customProperties, destinations) {\n\treturn Promise.all(destinations.map(async destination => {\n\t\tif (destination instanceof Function) {\n\t\t\tawait destination(defaultCustomPropertiesToJSON(customProperties));\n\t\t} else {\n\t\t\t// read the destination as an object\n\t\t\tconst opts = destination === Object(destination) ? destination : { to: String(destination) };\n\n\t\t\t// transformer for Custom Properties into a JSON-compatible object\n\t\t\tconst toJSON = opts.toJSON || defaultCustomPropertiesToJSON;\n\n\t\t\tif ('customProperties' in opts) {\n\t\t\t\t// write directly to an object as customProperties\n\t\t\t\topts.customProperties = toJSON(customProperties);\n\t\t\t} else if ('custom-properties' in opts) {\n\t\t\t\t// write directly to an object as custom-properties\n\t\t\t\topts['custom-properties'] = toJSON(customProperties);\n\t\t\t} else {\n\t\t\t\t// destination pathname\n\t\t\t\tconst to = String(opts.to || '');\n\n\t\t\t\t// type of file being written to\n\t\t\t\tconst type = (opts.type || path.extname(opts.to).slice(1)).toLowerCase();\n\n\t\t\t\t// transformed Custom Properties\n\t\t\t\tconst customPropertiesJSON = toJSON(customProperties);\n\n\t\t\t\tif (type === 'css') {\n\t\t\t\t\tawait writeCustomPropertiesToCssFile(to, customPropertiesJSON);\n\t\t\t\t}\n\n\t\t\t\tif (type === 'scss') {\n\t\t\t\t\tawait writeCustomPropertiesToScssFile(to, customPropertiesJSON);\n\t\t\t\t}\n\n\t\t\t\tif (type === 'js') {\n\t\t\t\t\tawait writeCustomPropertiesToCjsFile(to, customPropertiesJSON);\n\t\t\t\t}\n\n\t\t\t\tif (type === 'json') {\n\t\t\t\t\tawait writeCustomPropertiesToJsonFile(to, customPropertiesJSON);\n\t\t\t\t}\n\n\t\t\t\tif (type === 'mjs') {\n\t\t\t\t\tawait writeCustomPropertiesToMjsFile(to, customPropertiesJSON);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}));\n}\n\n/* Helper utilities\n/* ========================================================================== */\n\nconst defaultCustomPropertiesToJSON = customProperties => {\n\treturn Object.keys(customProperties).reduce((customPropertiesJSON, key) => {\n\t\tconst valueNodes = customProperties[key];\n\t\tcustomPropertiesJSON[key] = valueNodes.map((propertyObject) => {\n\t\t\treturn propertyObject.toString();\n\t\t}).join(' ');\n\n\t\treturn customPropertiesJSON;\n\t}, {});\n};\n\nconst writeFile = (to, text) => new Promise((resolve, reject) => {\n\tfs.writeFile(to, text, error => {\n\t\tif (error) {\n\t\t\treject(error);\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t});\n});\n\nconst escapeForJS = string => string.replace(/\\\\([\\s\\S])|(')/g, '\\\\$1$2').replace(/\\n/g, '\\\\n').replace(/\\r/g, '\\\\r');\n","import postcss from 'postcss';\nimport getCustomPropertiesFromRoot from './lib/get-custom-properties-from-root';\nimport getCustomPropertiesFromImports from './lib/get-custom-properties-from-imports';\nimport transformProperties from './lib/transform-properties';\nimport writeCustomPropertiesToExports from './lib/write-custom-properties-to-exports';\n\nexport default postcss.plugin('postcss-custom-properties', opts => {\n\t// whether to preserve custom selectors and rules using them\n\tconst preserve = 'preserve' in Object(opts) ? Boolean(opts.preserve) : true;\n\n\t// sources to import custom selectors from\n\tconst importFrom = [].concat(Object(opts).importFrom || []);\n\n\t// destinations to export custom selectors to\n\tconst exportTo = [].concat(Object(opts).exportTo || []);\n\n\t// promise any custom selectors are imported\n\tconst customPropertiesPromise = getCustomPropertiesFromImports(importFrom);\n\n\t// synchronous transform\n\tconst syncTransform = root => {\n\t\tconst customProperties = getCustomPropertiesFromRoot(root, { preserve });\n\n\t\ttransformProperties(root, customProperties, { preserve });\n\t};\n\n\t// asynchronous transform\n\tconst asyncTransform = async root => {\n\t\tconst customProperties = Object.assign(\n\t\t\t{},\n\t\t\tgetCustomPropertiesFromRoot(root, { preserve }),\n\t\t\tawait customPropertiesPromise,\n\t\t);\n\n\t\tawait writeCustomPropertiesToExports(customProperties, exportTo);\n\n\t\ttransformProperties(root, customProperties, { preserve });\n\t};\n\n\t// whether to return synchronous function if no asynchronous operations are requested\n\tconst canReturnSyncFunction = importFrom.length === 0 && exportTo.length === 0;\n\n\treturn canReturnSyncFunction ? syncTransform : asyncTransform;\n});\n"],"names":["isBlockIgnored","ruleOrDeclaration","rule","selector","parent","test","toString","isRuleIgnored","previous","prev","Boolean","type","text","getCustomPropertiesFromRoot","root","opts","customPropertiesFromHtmlElement","customPropertiesFromRootPseudo","nodes","slice","forEach","customPropertiesObject","isHtmlRule","isRootRule","decl","isCustomDecl","prop","parse","value","preserve","remove","isEmptyParent","htmlSelectorRegExp","rootSelectorRegExp","customPropertyRegExp","node","split","some","item","Object","length","getCustomPropertiesFromCSSFile","from","css","readFile","postcss","getCustomPropertiesFromObject","object","customProperties","assign","key","String","getCustomPropertiesFromJSONFile","readJSON","getCustomPropertiesFromJSFile","getCustomPropertiesFromImports","sources","map","source","Promise","Function","path","resolve","extname","toLowerCase","reduce","reject","fs","error","result","JSON","transformValueAST","child","isVarFunction","propertyNode","comma","fallbacks","name","asClonedArrayWithBeforeSpacing","raws","before","replaceWith","index","retransformValueAST","indexOf","splice","withoutProperty","nextCustomProperties","varRegExp","array","beforeSpacing","clonedArray","asClonedArray","asClonedNode","cloneNode","constructor","Array","walkDecls","isTransformableDecl","originalValue","valueAST","beforeDecl","cloneBefore","hasTrailingComment","replace","trailingCommentRegExp","raw","customPropertiesRegExp","writeCustomPropertiesToCssFile","to","cssContent","keys","cssLines","push","join","writeFile","writeCustomPropertiesToScssFile","scssContent","scssLines","scssName","scss","writeCustomPropertiesToJsonFile","jsonContent","stringify","json","writeCustomPropertiesToCjsFile","jsContents","jsLines","escapeForJS","js","writeCustomPropertiesToMjsFile","mjsContents","mjsLines","mjs","writeCustomPropertiesToExports","destinations","all","destination","defaultCustomPropertiesToJSON","toJSON","customPropertiesJSON","valueNodes","propertyObject","string","plugin","importFrom","concat","exportTo","customPropertiesPromise","syncTransform","transformProperties","asyncTransform","canReturnSyncFunction"],"mappings":";;;;;AAAA,SAASA,cAAT,CAAwBC,iBAAxB,EAA2C;AAC1C,MAAIC,IAAI,GAAGD,iBAAiB,CAACE,QAAlB,GACVF,iBADU,GACUA,iBAAiB,CAACG,MADvC;AAGA,SAAO,6CAA6CC,IAA7C,CAAkDH,IAAI,CAACI,QAAL,EAAlD,CAAP;AACA;;AAED,SAASC,aAAT,CAAuBL,IAAvB,EAA6B;AAC5B,MAAIM,QAAQ,GAAGN,IAAI,CAACO,IAAL,EAAf;AAEA,SAAOC,OAAO,CAACV,cAAc,CAACE,IAAD,CAAd,IACdM,QAAQ,IACRA,QAAQ,CAACG,IAAT,KAAkB,SADlB,IAEA,uDAAuDN,IAAvD,CAA4DG,QAAQ,CAACI,IAArE,CAHa,CAAd;AAIA;;ACVc,SAASC,2BAAT,CAAqCC,IAArC,EAA2CC,IAA3C,EAAiD;AAC/D;AACA,QAAMC,+BAA+B,GAAG,EAAxC;AACA,QAAMC,8BAA8B,GAAG,EAAvC,CAH+D;;AAM/DH,EAAAA,IAAI,C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