Walk through all rules, and replace each themify occurrence with the corresponding CSS variable.
@example background-color: themify(primary-300, 0.5) => background-color: rgba(var(--primary-300),0.6)
@param root
4044
function processRules(root) {
  root.walkRules(rule => {
    if (!hasThemify(rule.toString())) {
      return;
    }

    let aggragatedSelectorsMap = {};
    let aggragatedSelectors = [];

    let createdRules = [];
    const variationRules = {
      [defaultVariation]: rule,
    };

    rule.walkDecls(decl => {
      const propertyValue = decl.value;
      if (!hasThemify(propertyValue)) return;

      const property = decl.prop;

      const variationValueMap = getThemifyValue(
        propertyValue,
        ExecutionMode.CSS_VAR,
      );
      const defaultVariationValue = variationValueMap[defaultVariation];
      decl.value = defaultVariationValue;

      // indicate if we have a global rule, that cannot be nested
      const createNonDefaultVariationRules = isAtRule(rule);

      // don't create extra CSS for global rules
      if (createNonDefaultVariationRules) {
        return;
      }

      // create a new declaration and append it to each rule
      nonDefaultVariations.forEach(variationName => {
        const currentValue = variationValueMap[variationName];

        // variable for non-default variation is optional
        if (!currentValue || currentValue === 'null') {
          return;
        }

        // when the declaration is the same as the default variation,
        // we just need to concatenate our selector to the default rule
        if (currentValue === defaultVariationValue) {
          const selector = getSelectorName(rule, variationName);

          // append the selector once
          if (!aggragatedSelectorsMap[variationName]) {
            aggragatedSelectorsMap[variationName] = true;
            aggragatedSelectors.push(selector);
          }
        } else {
          // creating the rule for the first time
          if (!variationRules[variationName]) {
            const clonedRule = createRuleWithVariation(rule, variationName);
            variationRules[variationName] = clonedRule;
            // append the new rule to the array, so we can append it later
            createdRules.push(clonedRule);
          }

          const variationDecl = createDecl(
            property,
            variationValueMap[variationName],
          );
          variationRules[variationName].append(variationDecl);
        }
      });
    });

    if (aggragatedSelectors.length) {
      rule.selectors = [...rule.selectors];

      // Don't add extra redundant CSS selectors to every component using CSS vars
      // rule.selectors = [...rule.selectors, ...aggragatedSelectors];
    }

    // append each created rule
    if (createdRules.length) {
      createdRules.forEach(r => root.append(r));
    }
  });
}
936746
private void transform(JSONArray root) {
        for (int i = 0, size = root.size(); i < size; i++)
        {
            Object target = root.get(i);
            if (target instanceof JSONObject)
                this.transform((JSONObject)target);
        }
    }
104791
public static void saveColorPository (ColorPository posit, File root)
    {
        File path = new File(root, CONFIG_PATH);
        try {
            CompiledConfig.saveConfig(path, posit);
        } catch (IOException ioe) {
            log.warning("Failure saving color pository", "path", path, "error", ioe);
        }
    }
310896
function setColor(color) {
         var alpha = this.currentColor.glArray[3];
         this.currentColor.copy(color);
         this.currentColor.glArray[3] *= alpha;
       }
363877
public void setNeedleBorderColor(final Color COLOR) {
        if (null == needleBorderColor) {
            _needleBorderColor = null == COLOR ? Color.TRANSPARENT : COLOR;
            fireUpdateEvent(REDRAW_EVENT);
        } else {
            needleBorderColor.set(COLOR);
        }
    }
1358408
public void setForegroundBaseColor(final Color COLOR) {
        if (null == titleColor) { _titleColor = COLOR; } else { titleColor.set(COLOR); }
        if (null == descriptionColor) { _descriptionColor = COLOR; } else { descriptionColor.set(COLOR); }
        if (null == unitColor) { _unitColor = COLOR; } else { unitColor.set(COLOR); }
        if (null == valueColor) { _valueColor = COLOR; } else { valueColor.set(COLOR); }
        if (null == textColor) { _textColor = COLOR; } else { textColor.set(COLOR); }
        if (null == foregroundColor) { _foregroundColor = COLOR; } else { foregroundColor.set(COLOR); }
        fireTileEvent(REDRAW_EVENT);
    }
386654
public void setRoot(int root)
  {
    // %OPT% Get this directly from the lpi.
    XPathContext xctxt = wi().getXPathContext();
    m_dtm = xctxt.getDTM(root);
    m_traverser = m_dtm.getAxisTraverser(m_axis);
    m_isFresh = true;
    m_foundLast = false;
    m_root = root;
    m_currentNode = root;

    if (DTM.NULL == root)
    {
      throw new RuntimeException(
        XSLMessages.createXPATHMessage(XPATHErrorResources.ER_SETTING_WALKER_ROOT_TO_NULL, null)); //"\n !!!! Error! Setting the root of a walker to null!!!");
    }

    resetProximityPositions();
  }
1273041
function cssnext (tagName, css) {
  // A small hack: it passes :scope as :root to PostCSS.
  // This make it easy to use css variables inside tags.
  css = css.replace(/:scope/g, ':root')
  css = postcss([postcssCssnext]).process(css).css
  css = css.replace(/:root/g, ':scope')
  return css
}
666352
private void colorChooserRootBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorChooserRootBackgroundActionPerformed
    if (this.colorChooserRootBackground.isLastOkPressed() && changeNotificationAllowed) {
      this.controller.changed();
    }
  }
109450
public void setLeafStyle(boolean isLeaf) {

        if (isLeaf) {
            m_leafStyleVar.setValue(CSS.listTreeItemLeaf());
        } else {
            m_leafStyleVar.setValue(CSS.listTreeItemInternal());
        }
    }
542034
public void setTheme(final Theme theme) {
        if (this.themeReference != null || this.themeUrl != null) {
            throw new IllegalStateException(
                    "A theme can only be defined once. Calling different setTheme methods is not allowed!");
        }
        this.theme = theme;
    }
1313334
private void updateForeground(Color color) {
        StyledDocument doc = (StyledDocument)getComponent().getDocument();
        Style style = doc.getStyle(StyleContext.DEFAULT_STYLE);

        if (style == null) {
            return;
        }

        if (color == null) {
            style.removeAttribute(StyleConstants.Foreground);
        } else {
            StyleConstants.setForeground(style, color);
        }
    }
946182
function(color) { 
        if (color != undefined) {
            this.backgroundColor = color; 
        }
        
        if (this.div != null) {
            this.div.style.backgroundColor = this.backgroundColor;
        }
    }
1162668
public static void setColor(String strProperty, ColorUIResource color, PropertyOwner propertyOwner, Map<String,Object> properties)
    {
        if (color != null)
            ScreenUtil.setProperty(strProperty, "#" + Integer.toHexString(color.getRGB() & 0xFFFFFF), propertyOwner, properties);
        else
            ScreenUtil.setProperty(strProperty, null, propertyOwner, properties);
    }
1184927
public void setUseChartDataTextColor(final boolean USE) {
        if (null == useChartDataTextColor) {
            _useChartDataTextColor = USE;
            redraw();
        } else {
            useChartDataTextColor.set(USE);
        }
    }
900880
protected void initVisibilities(Element root, CmsXmlContentDefinition contentDefinition) {

        m_visibilityConfigurations = new HashMap<String, VisibilityConfiguration>();
        String mainHandlerClassName = root.attributeValue(APPINFO_ATTR_CLASS);
        // using self as the default visibility handler implementation
        I_CmsXmlContentVisibilityHandler mainHandler = this;
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(mainHandlerClassName)) {
            try {
                // in case there is a main handler configured, try to instanciate it
                Class<?> handlerClass = Class.forName(mainHandlerClassName);
                mainHandler = (I_CmsXmlContentVisibilityHandler)handlerClass.newInstance();
            } catch (Exception e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
        List<Element> elements = new ArrayList<Element>(CmsXmlGenericWrapper.elements(root, APPINFO_VISIBILITY));
        for (Element element : elements) {
            try {
                String elementName = element.attributeValue(APPINFO_ATTR_ELEMENT);
                String handlerClassName = element.attributeValue(APPINFO_ATTR_CLASS);
                String params = element.attributeValue(APPINFO_ATTR_PARAMS);
                I_CmsXmlContentVisibilityHandler handler = null;
                if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(handlerClassName)) {

                    Class<?> handlerClass = Class.forName(handlerClassName);
                    handler = (I_CmsXmlContentVisibilityHandler)handlerClass.newInstance();
                } else {
                    handler = mainHandler;
                }
                m_visibilityConfigurations.put(elementName, new VisibilityConfiguration(handler, params));

            } catch (Exception e) {
                LOG.error(e.getLocalizedMessage(), e);
            }
        }
    }
468357
private void addCSS(UIViewRoot root, FacesContext context) {
		// The following code is needed to diagnose the warning "Unable to save dynamic
		// action with clientId 'j_id...'"
		// List<UIComponent> r = root.getComponentResources(context, "head");
		// System.out.println("**************");
		// for (UIComponent ava : r) {
		// String name = (String) ava.getAttributes().get("name");
		// System.out.println(ava.getClientId(context) +":" + name + " " +
		// ava.getClass().getSimpleName());
		// }
		// System.out.println("**************");
		// end of the diagnostic code

		// 1) First load Theme files (core.css + theme.css)
		String theme = loadTheme(root, context);

		// deactivate FontAwesome support if the no-fa facet is found in the h:head tag
		UIComponent header = findHeader(root);
		boolean useCDNImportForFontAwesome = (null == header) || (null == header.getFacet("no-fa"));
		if (useCDNImportForFontAwesome) {
			String useCDN = BsfUtils.getInitParam(P_GET_FONTAWESOME_FROM_CDN);
			if (null != useCDN) {
				useCDN = ELTools.evalAsString(useCDN);
			}
			if (null != useCDN) {
				useCDNImportForFontAwesome = !isFalseOrNo(useCDN);
			}
		}

		// Do we have to add font-awesome, or are the resources already there?
		List<UIComponent> availableResources = root.getComponentResources(context, "head");
		for (UIComponent ava : availableResources) {
			String name = (String) ava.getAttributes().get("name");
			if (null != name) {
				name = name.toLowerCase();
				if ((name.contains("font-awesome") || name.contains("fontawesome")) && name.endsWith("css"))
					useCDNImportForFontAwesome = false;
			}
		}

		// 2) Font Awesome
		if (useCDNImportForFontAwesome) {
			InternalFALink output = new InternalFALink();
			Map<String, Object> viewMap = root.getViewMap();
			if (viewMap.containsKey(FONTAWESOME_USED)) {
				String version = (String) viewMap.get(FONTAWESOME_VERSION);
				if (version != null) {
					output.setVersion(version);
					output.setNeedsVersion4(needsFontAwesome4());
				} else {
					output.setVersion("4");
					output.setNeedsVersion4(needsFontAwesome4());
				}
				addResourceIfNecessary(root, context, output);
			}
		}

		@SuppressWarnings("unchecked")
		List<String> extCSSMap = (List<String>) root.getViewMap().get(EXT_RESOURCE_KEY);
		if (extCSSMap != null) {
			for (String file : extCSSMap) {
				String name = "css/" + file;

				createAndAddComponent(root, context, CSS_RENDERER, name, C.BSF_LIBRARY);
			}
		}

		@SuppressWarnings("unchecked")
		List<String> themedCSSMap = (List<String>) root.getViewMap().get(THEME_RESOURCE_KEY);
		if (themedCSSMap != null) {
			for (String file : themedCSSMap) {
				String name = "css/" + theme + "/" + file;
				// Glyphicons icons now are in core.css if(file.equals("icons.css")) //the
				// icons.css file isn't found in a theme folder
				// Glyphicons icons now are in core.css name = "css/icons.css"; //look for it
				// under the css root instead

				createAndAddComponent(root, context, CSS_RENDERER, name, C.BSF_LIBRARY);
			}
		}

		if (theme.equals("patternfly")) {
			createAndAddComponent(root, context, CSS_RENDERER, "css/patternfly/bootstrap-switch.css", C.BSF_LIBRARY);
		}

		// Add mandatory CSS bsf.css
		createAndAddComponent(root, context, CSS_RENDERER, "css/bsf.css", C.BSF_LIBRARY);

		// 3) Bootstrap from CDN (TODO: check removeBootstrapResources)
		boolean loadBootstrap = shouldLibraryBeLoaded(P_GET_BOOTSTRAP_FROM_CDN, true);
		if (!loadBootstrap) {
			removeBootstrapResources(root, context);
		}
	}