<commit_before>(function() {

"use strict";

if (!window.Echo) window.Echo = {};

if (Echo.Utils) return;

if (!Echo.Global) Echo.Global = {};

if (!Echo.Vars) Echo.Vars = {
	"regexps": {
		"templateSubstitution": /{([a-z]+):(([a-z_]+\.)*[a-z_]+)}/ig,
		"mobileUA": /mobile|midp-|opera mini|iphone|ipad|blackberry|nokia|samsung|docomo|symbian|windows ce|windows phone|android|up\.browser|ipod|netfront|skyfire|palm|webos|audiovox/i,
		"parseURL": /^((([^:\/\?#]+):)?\/\/)?([^\/\?#]*)?([^\?#]*)(\?([^#]*))?(#(.*))?/,
		"w3cdtf": /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/
	}
};


/**
 * Static class implements common methods of data processing.
 * The Echo.Utils class is used in various places of Echo JS SDK components.
 */

Echo.Utils = {};

/**
 * Method to add CSS styles on the page.
 *
 * This function adds CSS styles to the style tag which is placed in the head of the document.
 * The first argument is a string that contains CSS styles, the second one is the unique identity string of CSS styles to be added. 
 * If CSS styles with corresponding id were added before then this function returns false.
 *
 *     // style tag in the head of HTML document
 *     // <style>
 *     //     .example-class { font-size: 12px; }
 *     // </style>
 *
 *     Echo.Utils.addCSS(
 *         '.echo-class { font-size: 14px; } '
 *     , 'echo-class-id'); // will return true
 *     // and new CSS style will be added to style tag
 *     // <style>
 *     //     .example-class { font-size: 12px; }
 *     //     .echo-class { font-size: 14px; }
 *     // </style>
 *
 *     Echo.Utils.addCSS(
 *         '.echo-new-class { font-size: 16px; } '
 *     , 'echo-class-id'); // will return false because styles with id = 'echo-class-id' were added before
 *
 * @static
 * @param {String} cssCode Contains CSS styles to be added.
 * @param {String} id Unique identity string of CSS styles.
 * @return {Boolean} Returns true if CSS styles was successfully added, false - if CSS styles is already in the document.
 */
Echo.Utils.addCSS = function(cssCode, id) {
	Echo.Vars.css = Echo.Vars.css || {
		"index": 1,
		"processed": {}
	};
	if (id) {
		if (Echo.Vars.css.processed[id]) return false;
		Echo.Vars.css.processed[id] = true;
	}
	var currentCssCode = "";
	var oldStyle = Echo.Vars.css.anchor;
	if (oldStyle && oldStyle.length) {
		currentCssCode = oldStyle.html();
	}
	// IE limit is 4095 rules per style tag
	// so we limit it to 100000 characters
	// (2000 rules x 50 characters per rule)
	if (currentCssCode.length + cssCode.length > 100000) {
		Echo.Vars.css.index++;
		oldStyle = null;
		currentCssCode = "";
	}
	var newStyle = $('<style id="echo-css-' + Echo.Vars.css.index + '" type="text/css">' + currentCssCode + cssCode + '</style>');
	if (oldStyle && oldStyle.length) {
		// use replacing instead of adding css to existing element
		// because IE doesn't allow it
		oldStyle.replaceWith(newStyle);
	} else {
		if (Echo.Vars.css.anchor) {
			Echo.Vars.css.anchor.after(newStyle);
		} else {
			$(document.getElementsByTagName("head")[0] || document.documentElement).prepend(newStyle);
		}
	}
	Echo.Vars.css.anchor = newStyle;
	return true;
};

/**
 * Method implementing folding mechanism.
 *
 * This function iterates over each value of the object passing them to callback function.
 * The first argument is the object that is available in callback function to accumulate items.
 *
 *     var array = Echo.Utils.foldl([], [1, 2, 3], function(item, acc) {
 *         acc.push(item);
 *     }); // array will be [1, 2, 3];
 *     <commit_msg>Moving global CSS hash to private variable<commit_after>(function() {

"use strict";

if (!window.Echo) window.Echo = {};

if (Echo.Utils) return;

if (!Echo.Global) Echo.Global = {};

if (!Echo.Vars) Echo.Vars = {
	"regexps": {
		"templateSubstitution": /{([a-z]+):(([a-z_]+\.)*[a-z_]+)}/ig,
		"mobileUA": /mobile|midp-|opera mini|iphone|ipad|blackberry|nokia|samsung|docomo|symbian|windows ce|windows phone|android|up\.browser|ipod|netfront|skyfire|palm|webos|audiovox/i,
		"parseURL": /^((([^:\/\?#]+):)?\/\/)?([^\/\?#]*)?([^\?#]*)(\?([^#]*))?(#(.*))?/,
		"w3cdtf": /^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/
	}
};


/**
 * Static class implements common methods of data processing.
 * The Echo.Utils class is used in various places of Echo JS SDK components.
 */

Echo.Utils = {};

var _cssStyles = {
	"anchor": undefined,
	"index": 1,
	"processed": {}
};

/**
 * Method to add CSS styles on the page.
 *
 * This function adds CSS styles to the style tag which is placed in the head of the document.
 * The first argument is a string that contains CSS styles, the second one is the unique identity string of CSS styles to be added. 
 * If CSS styles with corresponding id were added before then this function returns false.
 *
 *     // style tag in the head of HTML document
 *     // <style>
 *     //     .example-class { font-size: 12px; }
 *     // </style>
 *
 *     Echo.Utils.addCSS(
 *         '.echo-class { font-size: 14px; } '
 *     , 'echo-class-id'); // will return true
 *     // and new CSS style will be added to style tag
 *     // <style>
 *     //     .example-class { font-size: 12px; }
 *     //     .echo-class { font-size: 14px; }
 *     // </style>
 *
 *     Echo.Utils.addCSS(
 *         '.echo-new-class { font-size: 16px; } '
 *     , 'echo-class-id'); // will return false because styles with id = 'echo-class-id' were added before
 *
 * @static
 * @param {String} cssCode Contains CSS styles to be added.
 * @param {String} id Unique identity string of CSS styles.
 * @return {Boolean} Returns true if CSS styles was successfully added, false - if CSS styles is already in the document.
 */
Echo.Utils.addCSS = function(cssCode, id) {
	if (id) {
		if (_cssStyles.processed[id]) return false;
		_cssStyles.processed[id] = true;
	}
	var currentCssCode = "";
	var oldStyle = _cssStyles.anchor;
	if (oldStyle && oldStyle.length) {
		currentCssCode = oldStyle.html();
	}
	// IE limit is 4095 rules per style tag
	// so we limit it to 100000 characters
	// (2000 rules x 50 characters per rule)
	if (currentCssCode.length + cssCode.length > 100000) {
		_cssStyles.index++;
		oldStyle = null;
		currentCssCode = "";
	}
	var newStyle = $('<style id="echo-css-' + _cssStyles.index + '" type="text/css">' + currentCssCode + cssCode + '</style>');
	if (oldStyle && oldStyle.length) {
		// use replacing instead of adding css to existing element
		// because IE doesn't allow it
		oldStyle.replaceWith(newStyle);
	} else {
		if (_cssStyles.anchor) {
			_cssStyles.anchor.after(newStyle);
		} else {
			$(document.getElementsByTagName("head")[0] || document.documentElement).prepend(newStyle);
		}
	}
	_cssStyles.anchor = newStyle;
	return true;
};

/**
 * Method implementing folding mechanism.
 *
 * This function iterates over each value of the object passing them to callback function.
 * The first argument is the object that is available in callback function to accumulate items.
 *
 *     var array = Echo.Utils.foldl([], [1, 2, 3], function(item, acc) {
 *         acc.push(item);
 *     }); // array will be [1, 2, 3];
 *     
{'fraction_non_alphanumeric': 0.16807195053400786, 'fraction_numerical': 0.011804384485666104, 'mean_word_length': 3.0949367088607596, 'pattern_counts': {'":': 15, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '51059', 'n_tokens_mistral': 2555, 'n_tokens_neox': 2413, 'n_words': 702}