Creates a rule string for background and text colors.
@param {String} className - class name
@param {Objecr} options - options
@returns {String}
@ignore
501241
function bgTextRuleString(className, options) {
    return classRule(className)
        .bg(options.background)
        .text(options.text)
        .build();
}
895816
def get_style_defs(self, arg=None):
        
        if arg is None:
            arg = ('cssclass' in self.options and '.'+self.cssclass or '')
        if isinstance(arg, string_types):
            args = [arg]
        else:
            args = list(arg)

        def prefix(cls):
            if cls:
                cls = '.' + cls
            tmp = []
            for arg in args:
                tmp.append((arg and arg + ' ' or '') + cls)
            return ', '.join(tmp)

        styles = [(level, ttype, cls, style)
                  for cls, (style, ttype, level) in iteritems(self.class2style)
                  if cls and style]
        styles.sort()
        lines = ['%s { %s } /* %s */' % (prefix(cls), style, repr(ttype)[6:])
                 for (level, ttype, cls, style) in styles]
        if arg and not self.nobackground and \
           self.style.background_color is not None:
            text_style = ''
            if Text in self.ttype2class:
                text_style = ' ' + self.class2style[self.ttype2class[Text]][0]
            lines.insert(0, '%s { background: %s;%s }' %
                         (prefix(''), self.style.background_color, text_style))
        if self.style.highlight_color is not None:
            lines.insert(0, '%s.hll { background-color: %s }' %
                         (prefix(''), self.style.highlight_color))
        return '\n'.join(lines)
249107
def color(string, name, style='normal', when='auto'):
    
    if name not in colors:
        from .text import oxford_comma
        raise ValueError("unknown color '{}'.\nknown colors are: {}".format(
            name, oxford_comma(["'{}'".format(x) for x in sorted(colors)])))

    if style not in styles:
        from .text import oxford_comma
        raise ValueError("unknown style '{}'.\nknown styles are: {}".format(
            style, oxford_comma(["'{}'".format(x) for x in sorted(styles)])))

    prefix = '\033[%d;%dm' % (styles[style], colors[name])
    suffix = '\033[%d;%dm' % (styles['normal'], colors['normal'])
    color_string = prefix + string + suffix

    if when == 'always':
        return color_string
    elif when == 'auto':
        return color_string if sys.stdout.isatty() else string
    elif when == 'never':
        return string
    else:
        raise ValueError("when must be one of: 'always', 'auto', 'never'")
1037412
function createCssRule(selector, ...rules) {
    let styles = document.getElementById(styleId);

    if (!styles) {
        styles = document.createElement('style');
        styles.type = 'text/css';
        styles.id = styleId;
        document.getElementsByTagName('head')[0].appendChild(styles);
    }

    const sheet = styles.sheet;

    // add each rule via 'insertRule' if that rule doesn't already exist
    // (needed due to storybook / webpack hot reloading)
    for (let i = 0; i < rules.length; i++) {
        const rule = rules[i];
        const cssText = `${selector} { ${rule}; }`;
        let found = false;

        for (let j = 0; j < sheet.cssRules.length; j++) {
            const existingRule = sheet.cssRules[j];
            if (cssText === existingRule.cssText) {
                found = true;
                break;
            }
        }

        if (!found) {
            // insertRule won't allow semicolons
            sheet.insertRule(cssText.replace(';', ''), 0);
        }
    }
}
1138061
function(options) {
        var borderTopRule = classRule(classNameConst.BORDER_TOP).bg(options.border);
        var borderBottomRule = classComposeRule(' .', [
            classNameConst.NO_SCROLL_X,
            classNameConst.BORDER_BOTTOM
        ]).bg(options.border);
        var rules = [
            borderTopRule,
            borderBottomRule
        ];
        var borderLeftRule, borderRightRule;

        if (options.showVerticalBorder) {
            borderLeftRule = classRule(classNameConst.BORDER_LEFT).bg(options.border);
            borderRightRule = classComposeRule(' .', [
                classNameConst.NO_SCROLL_Y,
                classNameConst.BORDER_RIGHT
            ]).bg(options.border);

            rules = rules.concat([borderLeftRule, borderRightRule]);
        }

        return builder.buildAll(rules);
    }
521836
function findBackgroundColor(element) {
  if (element == null || typeof element.style === 'undefined') {
    // This element has no background, assume white.
    return 'rgb(255,255,255)';
  }
  const backgroundColor = getComputedStyle(element).backgroundColor;
  if (backgroundColor === 'transparent' || backgroundColor === 'rgba(0, 0, 0, 0)') {
    return findBackgroundColor(element.parentNode);
  } else {
    return backgroundColor;
  }
}
485732
function getShade(varName) {
  let [, className, number] = varName.match(/(.*)-(\d)/);
  if (/theme-\d/.test(varName)) className = '@theme-color';
  return 'color(~`colorPalette("@{' + className.replace('@', '') + '}", ' + number + ")`)";
}
708469
function generateFileName(className) {
    return className
        .replace(/component/gi, '')
        .replace(/system/gi, '')
        .replace('2D', '2d')
        .replace('3D', '3d')
        .replace(/^[A-Z]/, function(c) {
            return c.toLowerCase();
        })
        .replace(/[A-Z]/g, function(c) {
            return '-' + c.toLowerCase();
        }) + '.js';
}
708863
function (classPrefix) {
            var text = this._getOutput();

            // Format the prefix for the CSS text
            var prefix = "." + classPrefix + " ";

            var prefixed = this.__prefixingAlgorithm(text, prefix);
            this.__prefixedText = prefixed.text;
            this.__numSelectors = prefixed.selectors;
        }
892120
function getColorObj(text) {
  const hashedText = hash(text);
  const colorIndex = hashedText % materialColors.length;

  return materialColors[colorIndex];
}
1079036
function formatBufferColored(err, options) {
    // istanbul ignore else
    if (!hex) {
        return err.buffer.toString('hex');
    }

    options = options || {};
    var opts = options.hexerOptions ? Object.create(options.hexerOptions) : {};
    if (opts.colored === undefined) {
        opts.colored = true;
    }
    var highlight = errorHighlighter(err, options);
    opts.decorateHexen = highlight;
    opts.decorateHuman = highlight;
    return hex(err.buffer, opts);
}
401106
def color(
            self, text=None, fore=None, back=None, style=None,
            no_closing=False):
        
        has_args = (
            (fore is not None) or
            (back is not None) or
            (style is not None)
        )
        if hasattr(text, '__colr__') and not has_args:
            # Use custom __colr__ method in the absence of arguments.
            return str(self._call_dunder_colr(text))

        # Stringify everything before operating on it.
        text = str(text) if text is not None else ''
        if _disabled:
            return text

        # Considered to have unclosed codes if embedded codes exist and
        # the last code was not a color code.
        embedded_codes = get_codes(text)
        has_end_code = embedded_codes and embedded_codes[-1] == closing_code
        # Add closing code if not already added, there is text, and
        # some kind of color/style was used (whether from args, or
        # color codes were included in the text already).
        # If the last code embedded in the text was a closing code,
        # then it is not added.
        # This can be overriden with `no_closing`.
        needs_closing = (
            text and
            (not no_closing) and
            (not has_end_code) and
            (has_args or embedded_codes)
        )
        if needs_closing:
            end = closing_code
        else:
            end = ''
        return ''.join((
            self.color_code(fore=fore, back=back, style=style),
            text,
            end,
        ))
1254218
function( options ) {
			var out = {},
				items,
				classItems,
				x,
				i;

			this.init();
			options = (options)? options : {};
			this.getDOMContext( options );

			// if we do not have any context create error
			if(!this.rootNode || !this.document){
				return {'errors': [this.noContentErr]};
			}else{

				items = this.findRootNodes( this.rootNode, true );
				i = items.length;
				while(i--) {
					classItems = modules.domUtils.getAttributeList(items[i], 'class');
					x = classItems.length;
					while(x--) {
						// find v2 names
						if(modules.utils.startWith( classItems[x], 'h-' )){
							this.appendCount(classItems[x], 1, out);
						}
						// find v1 names
						for(var key in modules.maps) {
							// dont double count if v1 and v2 roots are present
							if(modules.maps[key].root === classItems[x] && classItems.indexOf(key) === -1) {
								this.appendCount(key, 1, out);
							}
						}
					}
				}
				var relCount = this.countRels( this.rootNode );
				if(relCount > 0){
					out.rels = relCount;
				}

				return out;
			}
		}
152097
function createOptions( options ) {
	var object = optionsCache[ options ] = {};
	jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
		object[ flag ] = true;
	});
	return object;
}
768777
function Text(options) {

	this.__proto__ = new Control();

	this.init = function(options) {
		this.type = options.type = 'Text';
		this.parent = options.parent;
		this.defaults = {
			x:48, y:48,
			text: '',
			fill:this.parent.fill,
			fill_highlight: this.parent.lighter(this.parent.stroke),
			stroke: this.parent.stroke,
			'stroke-width': this.parent.control_stroke,
			fontsize: this.parent.fontsize,
			script: undefined,
			onload: undefined
		};
		this.setoptions(options);
		this.render();
		return this;
	};

	this.render = function() {
		this.label = this.parent.paper.text(this.x, this.y, this.text)
			.attr({fill:this.stroke, stroke:this.stroke, 'font-size': this.fontsize,
				'text-anchor': 'start'});	// http://stackoverflow.com/questions/2124763/raphael-js-and-text-positioning
		this.textelts.push(this.label);
		this.sethandlers();
	};

	this.move = function(newx, newy) {
		this.label.attr({x:this.x, y:this.y});
	};

	this.setValue = function(value) {
		this.value = value;
		this.label.attr({text: this.value});
		var update = {id: this.id, value: this.value};
		this.fire('update', update);
	};

	return this.init(options || {});
}
1027672
function expandClassNames(node, options) {
	const classNames = node.classList.reduce((out, cl) => {
		// remove all modifiers and element prefixes from class name to get a base element name
		const ix = cl.indexOf('_');
		if (ix > 0 && !cl.startsWith('-')) {
			out.add(cl.slice(0, ix));
		    out.add(cl.slice(ix));
			return out;
		}

		return out.add(cl);
	}, new Set());

	if (classNames.size) {
		node.setAttribute('class', Array.from(classNames).join(' '));
	}
}
460669
function(className, options)
{
    options = $.extend({
        el: 'div',
        attributes: {},
        css: {},
        parent: null,
        children: [],
        data: {}
    }, options);

     /* Unfortunately, jquery doesn't seem to like to set some attributes as DOM properties. (Notably href for off-DOM objects!!)
        Converting the attributes to a string and making that part of the $el constructor forces jquery to use innerHTML for atts. Yes, slower.
        If there's any problem constructing elements, use the following line:*/
    //  var $el = $( '<'+ options.el + obj_to_attr(options.attributes) +' />' ).css( options.css );
    var $el = $( '<'+ options.el +' />', options.attributes ).css( options.css );

    $el.addClass(className);

    if (options.parent!=null)
        options.parent.append($el);
    for (var i=0; i<options.children.length; i++)
        $el.append(options.children[i]);
    for (var p in options.data)
        $el.attr('data-'+p, options.data[p]);
    return $el;
}