/* eslint-disable curly
433412
function ArgRW(sizerw) {
    Base.call(this);
    this.sizerw = sizerw;
    this.strrw = bufrw.String(this.sizerw, 'utf8');
    this.bufrw = bufrw.VariableBuffer(this.sizerw, true);
}
994896
function compileValidator( attributes ) {
	if ( !attributes || typeof attributes !== "object" || Array.isArray( attributes ) ) {
		throw new TypeError( "definition of attributes must be object" );
	}

	const attributeNames = Object.keys( attributes );
	const numAttributes = attributeNames.length;
	const validation = [];

	for ( let ai = 0; ai < numAttributes; ai++ ) {
		const attributeName = attributeNames[ai];
		const attribute = attributes[attributeName];

		const handler = Types.selectByName( attribute.type );

		const { args, body } = extractBody( handler.isValid );
		if ( args.length < 4 ) {
			throw new TypeError( `isValid() of ModelType for handling ${attribute.type} values must accept four arguments` );
		}

		validation[ai] = `
{
	const ${args[0]} = "${attributeName}";
	let ${args[1]} = __props["${attributeName}"];
	const ${args[2]} = __attrs["${attributeName}"];
	const ${args[3]} = __errors;

	{
		${body}
	}
}
		`;
	}

	// eslint-disable-next-line no-new-func
	return new Function( `
const __attrs = this.constructor.schema.attributes;
const __props = this.properties;
const __errors = [];

${validation.join( "" )}

return __errors;
` );
}
137353
function unescapeHtml(s) {
            if (_toString.call(s) != "[object String]") return s;
            if (!s) return "";
            return s.replace(/(&lt;)|(&gt;)|(&amp;)|(&quot;)/gm, function (match) {
                switch (match) {
                    case "&lt;":
                        return "<";
                    case "&gt;":
                        return ">";
                    case "&amp;":
                        return "&";
                    case "&quot;":
                        return "\"";
                    default:
                        return match;
                }
            });
        }
1044542
function prune(code) {
  var ast = esprima.parse(code);

  estraverse.replace(ast, {
    leave: function leave(node, parent) {
      var ret;

      if ('IfStatement' === node.type) {
        if ('BinaryExpression' !== node.test.type) return;

        if ('self' === node.test.left.argument.name) {
          node.alternate = null;
        } else if ('global' === node.test.left.argument.name) {
          ret = node.alternate;
        }

        return ret;
      }

      if (
          'BlockStatement' === node.type
        && 'FunctionExpression' === parent.type
      ) {
        return node.body[0].alternate.alternate;
      }
    }
  });

  return escodegen.generate(ast, {
    format: {
      indent: { style: '  ' },
      semicolons: false,
      compact: true
    }
  });
}
136056
function replace() {

    if (!isOriginal) return;
    else isOriginal = false;

    function replaceWith(fn) {
        return function() {
            /* eslint prefer-rest-params:0 */
            // todo: once node v4 support dropped, use rest parameter instead
            fn.apply(logger, Array.from(arguments));
        };
    }

    ['log', 'debug', 'info', 'warn', 'error'].forEach((lvl) => {
        console[lvl] = function() {
            Array.prototype.slice.call(arguments).forEach((arg) => {
                write(lvl == "error" ? process.stderr : process.stdout, lvl, arg);
            });
        };
    });

}
1135692
function objToLK(obj) {
        var p, objLow;
        objLow = {};
        for (p in obj) {
            if (obj.hasOwnProperty(p)) {
                objLow[p.toLowerCase()] = obj[p];
            }
        }
        return objLow;
    }
126818
function showHelp(){
  var jshint_proc = fork(require.resolve('jshint/bin/jshint'), ['-h'], {silent: true});
  var ts = through(function write(chunk){
    this.queue(chunk.toString().replace(/(jshint)\b/g, 'jsxhint'));
  }, function end() {
    // This feels like a hack. There might be a better way to do this.
    this.queue('\nThe above options are native to JSHint, which JSXHint extends.\n');
    this.queue('\x1b[1m'); // bold
    this.queue('\nJSXHint Options:\n');
    this.queue('\x1b[0m');
    this.queue('      --jsx-only         Only transform files with the .jsx extension.\n' +
               '                         Will run somewhat faster.\n');
    this.queue('      --babel            Use babel (6to5) instead of react esprima.\n' +
               '                         Useful if you are using es6-module, etc. You must \n' +
               '                         install the module `babel` manually with npm.\n');
    this.queue('      --babel-experimental  Use babel with experimental support for ES7.\n' +
               '                            Useful if you are using es7-async, etc.\n');
    this.queue('      --harmony          Use react esprima with ES6 transformation support.\n' +
               '                         Useful if you are using both es6-class and react.\n');
    this.queue('      --es6module             Pass the --es6module flag to react tools.\n');
    this.queue('      --non-strict-es6module  Pass this flag to react tools.\n');
    this.queue('      --transform-errors STRING   Whether to fail on transform errors.\n' +
               '                                  Valid: always, jsx, never (default: jsx)');
  });
  jshint_proc.stderr.pipe(ts).pipe(process.stderr);
}
1045255
function curlyColors(str) {
  var res = '';
  var esc;
  var match;
  var history = [];
  var lastIndex = 0;

  if (arguments.length >= 2) str = format.apply(null, slice.apply(arguments));

  while ((match = rx.exec(str)) !== null) {
    res += str.slice(lastIndex, match.index);
    if (match[1]) {
      // Opening tag found.
      // Append the starting escape string sequence.
      esc = colors[match[1]];
      history.push(esc);
      res += esc[0];
    } else if (history.length) {
      // Closing tag found.
      // Append the closing escape string sequence of the current color.
      res += history.pop()[1];
      if (history.length) {
        // Continue with previous starting escape string sequence.
        res += history[history.length - 1][0];
      }
    }
    lastIndex = match.index + match[0].length;
  }

  // Append the remaining string to the result string.
  res += str.slice(lastIndex);

  // Close all remaining tags.
  while (history.length) res += history.pop()[1];

  // Delete double occurrences of color sequences.
  res = res.replace(/(\x1b\[\d+m)\1{1,}/g, '$1');

  return res;
}
299260
function func_expr_eval(arg_scope={}, arg_expr_tree={ type:undefined}, arg_errors=[], arg_name_str )
{
	const context = 'func_expr_eval:'

	// console.log('func_expr_eval:scope=', arg_scope)
	// console.log('func_expr_eval:arg_expr_tree=', arg_expr_tree)
	// console.log('func_expr_eval:arg_errors=', arg_errors)

	switch(arg_expr_tree.type) {
		case 'Literal':             return arg_expr_tree.value
		case 'Identifier': {
			if (arg_expr_tree.name.length > 0 && arg_expr_tree.name[0] != '_') {
				return arg_expr_tree.name
			}
			arg_errors.push('Identifier:bad value [' + arg_expr_tree.name + ']')
			return undefined
		}
		case 'BinaryExpression':{
			try{
				const op = arg_expr_tree.operator
				const left_tree   = arg_expr_tree.left
				const right_tree  = arg_expr_tree.right
				const left_value  = func_expr_eval(arg_scope, left_tree, arg_errors, arg_name_str)
				const right_value = func_expr_eval(arg_scope, right_tree, arg_errors, arg_name_str)
				switch(op){
					case '+': return left_value + right_value
					case '-': return left_value - right_value
					case '*': return left_value * right_value
					case '/': return left_value / right_value
				}
			} catch(e){
				arg_errors.push('BinaryExpression:failure [' + e + '] for op=' + op + ' left=[' + left_value + '] right=[' + right_value + ']')
				return undefined
			}
		}
		case 'UnaryExpression':{
			try{
				const op = arg_expr_tree.operator
				const left_tree   = arg_expr_tree.argument
				const left_value  = func_expr_eval(arg_scope, left_tree, arg_errors, arg_name_str)
				switch(op){
					case '+': return left_value
					case '-': return - left_value
					case '!': return ! left_value
				}
			} catch(e){
				arg_errors.push('UnaryExpression:failure [' + e + '] for op=' + op + ' left=[' + left_value + ']')
				return undefined
			}
		}
		case 'MemberExpression': {
			const obj_name = func_expr_eval(arg_scope, arg_expr_tree.object,   arg_errors, arg_name_str)
			const att_name = func_expr_eval(arg_scope, arg_expr_tree.property, arg_errors, arg_name_str)
			if (! obj_name || ! att_name)
			{
				arg_errors.push('MemberExpression:bad object/attribute name')
				return undefined
			}
			const obj = arg_scope[obj_name]
			if (! obj)
			{
				arg_errors.push('MemberExpression:object not found in scope or bad object:[' + obj_name + ']')
				return undefined
			}
			if (att_name.length > 0 && att_name[0] == '_')
			{
				arg_errors.push('MemberExpression:object method is private:[' + obj_name + '].[' + att_name + ']')
				return undefined
			}
			if (! (att_name in obj) )
			{
				arg_errors.push('MemberExpression:attribute not found')
				return undefined
			}
			return obj[att_name]
		}
		case 'CallExpression':{
			const callee = arg_expr_tree.callee
			const opds = arg_expr_tree.arguments
			// console.log('func_expr_eval:CallExpression:opds=', opds)

			// EVAL OPERANDS
			const opds_results = []
			if (arg_name_str)
			{
				opds_results.push('##NAME##' + arg_name_str)
			}
			if (opds && opds.length > 0)
			{
				opds.forEach(
					(opd, index)=>{
						// console.log('func_expr_eval:CallExpression:opd=', opd)
						const opd_result = func_expr_eval(arg_scope, opd, arg_errors, arg_name_str)
						// console.log('func_expr_eval:CallExpression:opd_result=', opd_result)
						opds_results.push(opd_result)
					}
				)
			}
			// console.log(context + 'CallExpression:opds_results=', opds_results)

			// EVAL FUNCTION
			if (callee.type == 'Identifier')
			{
				const func_name = callee.name
				const func_call = arg_scope[func_name]
				if (! func_call)
				{
					arg_errors.push('CallExpression:function not found in scope or bad function:[' + func_name + ']')
					return undefined
				}

				if (opds_results.length == 0)
				{
					// console.log(context + 'CallExpression:func_call=', func_call)
					return func_call(null)
				}
				
				// console.log(context + 'CallExpression:func_call=', func_call, opds_results)
				return func_call.call(null, ...opds_results)
			}

			// EVAL METHOD
			if (callee.type == 'MemberExpression')
			{
				const object_name = callee.object.name
				const method_name = callee.property.name

				if (method_name.length > 0 && method_name[0] == '_')
				{
					arg_errors.push('CallExpression:object method is private:[' + object_name + '].[' + method_name + ']')
					return undefined
				}
				const object_instance = arg_scope[object_name]
				if (! object_instance || ! object_instance.get_method)
				{
					arg_errors.push('CallExpression:method object not found in scope or bad object:[' + object_name + ']')
					return undefined
				}

				const object_method = object_instance.get_method(method_name)
				if (! object_method)
				{
					arg_errors.push('CallExpression:method not found in object or bad method:[' + object_name + '].[' + method_name + ']')
					return undefined
				}

				if (opds_results.length == 0)
				{
					return object_method.apply(object_instance)
				}
				
				const call_result = object_method.apply(object_instance, opds_results)
				if (call_result.error)
				{
					return call_result.errors
				}
				return call_result.value
			}
		}
		case 'ArrayExpression':{
			const items_expressions = arg_expr_tree.elements
			const items = []
			items_expressions.forEach(
				(item_expr)=>{
					items.push( func_expr_eval(arg_scope, item_expr, arg_errors, arg_name_str) )
				}
			)
			return items
		}
		default:{
			console.log('func_expr_eval:scope=', arg_scope)
			console.log('func_expr_eval:arg_expr_tree=', arg_expr_tree)
			console.log('func_expr_eval:arg_errors=', arg_errors)
			console.log('func_expr_eval:arg_name_str=', arg_name_str)
		}
	}

	return undefined
}
245822
function tryCatchStringify(obj) {
  try {
    return JSON.stringify(obj);
  } catch (err) {
    /* eslint-disable no-console */
    if (process.env.NODE_ENV !== 'production')
      console.log('Failed to stringify', err);
     no-console */
    return jsan.stringify(obj, null, null, { circular: '[CIRCULAR]' });
  }
}
788338
function (type) {
  var args = [], len = arguments.length - 1;
  while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];

  args.unshift('[riotx]');
  try {
    console.log.apply(console, args); // eslint-disable-line
  } catch (e) {
    console.log(args); // eslint-disable-line
  }
}
734752
function(str, index) {
    // replace {{ xxx }}
    var obj = this
    str = str.replace(interpolateReg, function(match, interpolate) {
      try {
        /*jslint evil: true */
        var funcNames = ['','index'].concat(fakerFuncNames).concat(['return ' + interpolate + ';']),
        func = new (Function.prototype.bind.apply(Function, funcNames)),
        funcs = [function(){return index}].concat(fakerFuncs);

        return func.apply(obj, funcs);
        
      } catch(e)  {
        return e.message;
      }
    });

    // if result is true or false, parse it to boolean
    if(/^(true|false)$/.test(str)) {
      str = str === 'true';
    }

    // if result is digit, parse it to float
    if(/^[-+]?\d*\.?\d+$/.test(str)) {
      str = parseFloat(str);
    }

    return str;
  }
794227
function compile(config) {
  let compiler;
  try {
    compiler = webpack(config);
  } catch (e) {
    console.log('Failed to compile: ', [e]); // eslint-disable-line
    process.exit(1);
  }
  return compiler;
}
582060
function(val, ctx, partials, inverted) {
      if (isArray(val) && val.length === 0) {
        return false;
      }

      var func;
      if (typeof val == 'function') {
        val = this.ms(val, ctx, partials);
        if (typeof val == 'function') {
          func = val;
        }
      }

      var pass = !!val;

      if (!inverted && pass && ctx) {
        if (func) {
          ctx.push(func);
        } else {
          ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
        }
      }

      return pass;
    }
718934
function(msg) {
      // eslint-disable-next-line no-console
      if (console.debug) {
        // eslint-disable-next-line no-console
        console.debug.apply(console, arguments);
      } else {
        // eslint-disable-next-line no-console
        console.log.apply(console, arguments);
      }
    }
1358273
function(req, res, next) {
                if (req.headers.accept && req.headers.accept.startsWith('text/html')) {
                  req.url = '/index.html'; // eslint-disable-line no-param-reassign
                }
                next();
              }
19398
async function nResolve(id: string, options?: Options): Promise<string> { // eslint-disable-line no-use-before-define
	assert(typeof id === 'string' && id.length > 0, '<id> has to be a non-empty string');
	assert(typeof options === 'object' && !Array.isArray(options), '[options] has to be an object');

	const s = getSettings(options);
	assert(nonEmpty(s.base), 'options.base has to be a non-empty string');
	assert(nonEmpty(s.index), 'options.index has to be a non-empty string');
	assert(nonEmpty(s.resolveKey), 'options.resolveKey has to be a non-empty string');
	assert(plain(s.package), 'options.package has to be an object');
	assert(plain(s.modules), 'options.modules has to be an object');

	if (s.modules[id]) {
		return s.modules[id];
	}

	if (isBuiltin(id)) {
		return id;
	}

	const [name, ...rest] = id.split('/').filter(Boolean);
	const isRelative = name === '.' || name === '..';

	const modulePath = isRelative ?
		path.resolve(s.base, name) :
		await getModulePath(name, s);

	const relativeBase = s.filename ?
		path.dirname(s.filename) :
		s.base;

	const relativePath = rest.length ?
		path.resolve(relativeBase, ...rest) :
		await getMainPath(modulePath, s);

	const moduleRelativePath = path.extname(relativePath) === '' ?
		`${relativePath}.js` : relativePath;

	const moduleFilePath = path.resolve(modulePath, moduleRelativePath);

	if (!(await exists(moduleFilePath))) {
		const nameDesc = isRelative ? '' : ` in ${name}`;
		throw new Error(`Could not find ${moduleFilePath}${nameDesc} at ${modulePath}`);
	}

	const parsed = path.parse(moduleFilePath);
	const ext = parsed.ext === '.js' ? '' : parsed.ext;

	return path.format({
		dir: parsed.dir,
		base: `${parsed.name}${ext}`
	});
}