/*::
type Package = string
type Lockfile = {|
version: number,
packages: {
flowgen: {[key: string]: Package},
custom: {[key: string]: Package},
flowTyped: {[key: string]: Package},
stub: {[key: string]: Package},
builtin: {[key: string]: Package}
}
|}
766131
function normalizePattern(
  pattern /*: string*/,
) /*: {
  hasVersion: boolean,
  name: string,
  range: string,
}*/ {
  let hasVersion = false
  let range = 'latest'
  let name = pattern

  // if we're a scope then remove the @ and add it back later
  let isScoped = false
  if (name[0] === '@') {
    isScoped = true
    name = name.slice(1)
  }

  // take first part as the name
  const parts = name.split('@')
  if (parts.length > 1) {
    name = parts.shift()
    range = parts.join('@')

    if (range) {
      hasVersion = true
    } else {
      range = '*'
    }
  }

  // add back @ scope suffix
  if (isScoped) {
    name = `@${name}`
  }

  return {name, range, hasVersion}
}
296135
function buildDep(file, pkg){
  var files = [];

  if (file.processed || file.package != pkg)
    return files;

  file.processed = true;

  for (var i = 0, depFile; depFile = file.deps[i++];)
    files.push.apply(files, buildDep(depFile, file.package));

  files.push(file);

  return files;
}
626177
function TypeParser(defaultBuilder) {

	/* TODO
	 * - function(this:) // type of this
	 * - function(new:) // constructor
	 */
	var rLexer = /\s*(Array\.?<|Object\.?<|Set\.?<|Promise\.?<|function\(|\{|:|\(|\||\}|>|\)|,|\[\]|\*|\?|!|\.\.\.)|\s*((?:module:)?\w+(?:[\/.#~]\w+)*)|./g;

	var input,
		builder,
		token,
		tokenStr;

	function next(expected) {
		if ( expected !== undefined && token !== expected ) {
			throw new SyntaxError("TypeParser: expected '" + expected + "', but found '" + tokenStr + "' (pos: " + rLexer.lastIndex + ", input='" + input + "')");
		}
		var match = rLexer.exec(input);
		if ( match ) {
			tokenStr = match[1] || match[2];
			token = match[1] || (match[2] && 'symbol');
			if ( !token ) {
				throw new SyntaxError("TypeParser: unexpected '" + tokenStr + "' (pos: " + match.index + ", input='" + input + "')");
			}
		} else {
			tokenStr = token = null;
		}
	}

	function parseType() {
		var nullable = false;
		var mandatory = false;
		if ( token === '?' ) {
			next();
			nullable = true;
		} else if ( token === '!' ) {
			next();
			mandatory = true;
		}

		var type;

		if ( token === 'Array.<' || token === 'Array<' ) {
			next();
			var componentType = parseType();
			next('>');
			type = builder.array(componentType);
		} else if ( token === 'Object.<' || token === 'Object<' ) {
			next();
			var keyType;
			var valueType = parseType();
			if ( token === ',' ) {
				next();
				keyType = valueType;
				valueType = parseType();
			} else {
				keyType = builder.synthetic(builder.simpleType('string'));
			}
			next('>');
			type = builder.object(keyType, valueType);
		} else if ( token === 'Set.<' || token === 'Set<' ) {
			next();
			var elementType = parseType();
			next('>');
			type = builder.set(elementType);
		} else if ( token === 'Promise.<' || token === 'Promise<' ) {
			next();
			var resultType = parseType();
			next('>');
			type = builder.promise(resultType);
		} else if ( token === 'function(' ) {
			next();
			var thisType, constructorType, paramTypes = [], returnType;
			if ( tokenStr === 'this' ) {
				next();
				next(':');
				thisType = parseType();
				if ( token === ',' ) {
					next();
				}
			} else if ( tokenStr === 'new' ) {
				next();
				next(':');
				constructorType = parseType();
				if ( token === ',' ) {
					next();
				}
			}
			while ( token === 'symbol' || token === '...' ) {
				var repeatable = token === '...';
				if ( repeatable) {
					next();
				}
				var paramType = parseType();
				if ( repeatable ) {
					paramType = builder.repeatable(paramType);
				}
				paramTypes.push(paramType);
				if ( token === ',' ) {
					if ( repeatable ) {
						throw new SyntaxError("TypeParser: only the last parameter of a function can be repeatable (pos: " + rLexer.lastIndex + ", input='" + input + "')");
					}
					next();
				}
			}
			next(')');
			if ( token === ':' ) {
				next(':');
				returnType = parseType();
			}
			type = builder.function(paramTypes, returnType, thisType, constructorType);
		} else if ( token === '{' ) {
			var structure = Object.create(null);
			var propName,propType;
			next();
			do {
				propName = tokenStr;
				if ( !/^\w+$/.test(propName) ) {
					throw new SyntaxError("TypeParser: structure field must have a simple name (pos: " + rLexer.lastIndex + ", input='" + input + "', field:'" + propName + "')");
				}
				next('symbol');
				if ( token === ':' ) {
					next();
					propType = parseType();
				} else {
					propType = builder.synthetic(builder.simpleType('any'));
				}
				structure[propName] = propType;
				if ( token === '}' ) {
					break;
				}
				next(',');
			} while (token);
			next('}');
			type = builder.structure(structure);
		} else if ( token === '(' ) {
			next();
			type = parseTypes();
			next(')');
		} else if ( token === '*' ) {
			next();
			type = builder.simpleType('*');
		} else {
			type = builder.simpleType(tokenStr);
			next('symbol');
			while ( token === '[]' ) {
				next();
				type = builder.array(type);
			}
		}
		if ( nullable ) {
			type = builder.nullable(type);
		}
		if ( mandatory ) {
			type = builder.mandatory(type);
		}
		return type;
	}

	function parseTypes() {
		var types = [];
		do {
			types.push(parseType());
			if ( token !== '|' ) {
				break;
			}
			next();
		} while (token);
		return types.length === 1 ? types[0] : builder.union(types);
	}

	this.parse = function(typeStr, tempBuilder) {
		builder = tempBuilder || defaultBuilder || TypeParser.ASTBuilder;
		input = String(typeStr);
		rLexer.lastIndex = 0;
		next();
		var type = parseTypes();
		next(null);
		return type;
	};

}
803572
function replaceRequireAndDefine(code, amdPackages, amdModules) {
  // Parse the code as an AST
  const ast = esprima.parseScript(code, {
    range: true
  });

  // Split the code into an array for easier substitutions
  const buffer = code.split('');

  // Walk thru the tree, find and replace our targets
  eswalk(ast, function(node) {
    if (!node) {
      return;
    }

    switch (node.type) {
      case 'CallExpression':

        if (!amdPackages || !amdModules) {
          // If not provided then we don't need to track them
          break;
        }

        // Collect the AMD modules
        // Looking for something like define(<name>, [<module1>, <module2>, ...], <function>)
        // This is the way ember defines a module
        if (node.callee.name === 'define') {

          if (node.arguments.length < 2 || node.arguments[1].type !== 'ArrayExpression' || !node.arguments[1].elements) {
            return;
          }

          node.arguments[1].elements.forEach(function(element) {
            if (element.type !== 'Literal') {
              return;
            }

            const isAMD = amdPackages.some(function(amdPackage) {
              if (typeof element.value !== 'string') {
                return false;
              }
              return element.value.indexOf(amdPackage + '/') === 0 || element.value === amdPackage;
            });

            if (!isAMD) {
              return;
            }

            amdModules.add(element.value);

          });

          return;
        }

        // Dealing with ember-auto-import eval
        if (node.callee.name === 'eval' && node.arguments[0].type === 'Literal' && typeof node.arguments[0].value === 'string') {
          const evalCode = node.arguments[0].value;
          const evalCodeAfter = replaceRequireAndDefine(evalCode, amdPackages, amdModules);
          if (evalCode !== evalCodeAfter) {
            write(buffer, "eval(" + JSON.stringify(evalCodeAfter) + ");", node.range);
          }
        }

        return;

      case 'Identifier':
        {
          // We are dealing with code, make sure the node.name is not inherited from object 
          if (!identifiers.hasOwnProperty(node.name)) {
            return;
          }

          const identifier = identifiers[node.name];
          if (!identifier) {
            return;
          }

          write(buffer, identifier, node.range);
        }
        return;

      case 'Literal':
        {
          // We are dealing with code, make sure the node.name is not inherited from object 
          if (!literals.hasOwnProperty(node.value)) {
            return;
          }

          const literal = literals[node.value];
          if (!literal) {
            return;
          }

          write(buffer, literal, node.range);
        }
        return;
    }
  });

  // Return the new code
  return buffer.join('');
}
568650
def _GetCallingPrototypeAsString(self, flow_cls):
    """"""
    output = []
    output.append("flow.StartAFF4Flow(client_id=client_id, ")
    output.append("flow_name=\"%s\", " % flow_cls.__name__)
    prototypes = []
    if flow_cls.args_type:
      for type_descriptor in flow_cls.args_type.type_infos:
        if not type_descriptor.hidden:
          prototypes.append("%s=%s" %
                            (type_descriptor.name, type_descriptor.name))
    output.append(", ".join(prototypes))
    output.append(")")
    return "".join(output)
1116799
function handlerReducersForType(type:String) {
  let apiActionTypes = getApiTypes(type);
  let reducers = {};
  let namesToState = {};
  apiActionTypes.forEach((key, idx) => {
    reducers[apiActionTypes[idx]] = apiReducers[apiStates[idx]];
    namesToState[upcase(apiStates[idx])] = toApiKey(apiActionTypes[idx]);
  });
  return {reducers, namesToState};
}
752875
function objectHasType (node) {
      const typeProperty = node.properties
        .find(p =>
          utils.getStaticPropertyName(p.key) === 'type' &&
          (
            p.value.type !== 'ArrayExpression' ||
            p.value.elements.length > 0
          )
        )
      return Boolean(typeProperty)
    }
85565
private void type(String type) throws IOException {
    if (this.packagePrefix == null) {
      throw new IllegalStateException();
    }

    Matcher m = TYPE_PATTERN.matcher(type);
    int pos = 0;
    while (true) {
      boolean found = m.find(pos);

      // copy non-matching characters like "<"
      int typeStart = found ? m.start() : type.length();
      out.write(type, pos, typeStart - pos);

      if (!found) {
        break;
      }

      // copy a single class name, shortening it if possible
      String name = m.group(0);
      String imported;
      if ((imported = importedTypes.get(name)) != null) {
        out.write(imported);
      } else if (name.startsWith(packagePrefix)
          && name.indexOf('.', packagePrefix.length()) == -1) {
        out.write(name.substring(packagePrefix.length()));
      } else if (name.startsWith("java.lang.")) {
        out.write(name.substring("java.lang.".length()));
      } else {
        out.write(name);
      }
      pos = m.end();
    }
  }
437958
function _Type(
    type,       // :: String
    name,       // :: String
    url,        // :: String
    arity,      // :: NonNegativeInteger
    format,
    // :: Nullable ((String -> String, String -> String -> String) -> String)
    supertypes, // :: Array Type
    test,       // :: Any -> Boolean
    tuples      // :: Array (Array3 String (a -> Array b) Type)
  ) {
    var t = Object.create (Type$prototype);
    t._test = test;
    t._extractors = tuples.reduce (function(_extractors, tuple) {
      _extractors[tuple[0]] = tuple[1];
      return _extractors;
    }, {});
    t.arity = arity;  // number of type parameters
    t.extractors = Z.map (B (toArray), t._extractors);
    t.format = format || function(outer, inner) {
      return Z.reduce (function(s, tuple) {
        return s +
               outer (' ') +
               when (tuple[2].arity > 0)
                    (parenthesize (outer))
                    (inner (tuple[0]) (show (tuple[2])));
      }, outer (name), tuples);
    };
    t.keys = tuples.map (function(tuple) { return tuple[0]; });
    t.name = name;
    t.supertypes = supertypes;
    t.type = type;
    t.types = tuples.reduce (function(types, tuple) {
      types[tuple[0]] = tuple[2];
      return types;
    }, {});
    t.url = url;
    return t;
  }
268677
function stringify (parsedPackageName) {
  const { scope, version } = parsedPackageName
  let name = parsedPackageName.name

  if (scope) {
    name = `@${scope}/${name}`
  }

  if (version) {
    name = `${name}@${version}`
  }

  return name
}
361031
function makeReflectTypes(uniforms, useIndex) {
  var obj = {}
  for(var i=0; i<uniforms.length; ++i) {
    var n = uniforms[i].name
    var parts = n.split(".")
    var o = obj
    for(var j=0; j<parts.length; ++j) {
      var x = parts[j].split("[")
      if(x.length > 1) {
        if(!(x[0] in o)) {
          o[x[0]] = []
        }
        o = o[x[0]]
        for(var k=1; k<x.length; ++k) {
          var y = parseInt(x[k])
          if(k<x.length-1 || j<parts.length-1) {
            if(!(y in o)) {
              if(k < x.length-1) {
                o[y] = []
              } else {
                o[y] = {}
              }
            }
            o = o[y]
          } else {
            if(useIndex) {
              o[y] = i
            } else {
              o[y] = uniforms[i].type
            }
          }
        }
      } else if(j < parts.length-1) {
        if(!(x[0] in o)) {
          o[x[0]] = {}
        }
        o = o[x[0]]
      } else {
        if(useIndex) {
          o[x[0]] = i
        } else {
          o[x[0]] = uniforms[i].type
        }
      }
    }
  }
  return obj
}
1275183
function mixin(compiler) {
  compiler._comment = compiler.comment;
  compiler.map = new SourceMap();
  compiler.position = { line: 1, column: 1 };
  compiler.files = {};
  for (var k in exports) compiler[k] = exports[k];
}
1149722
function diffProperties(pixiElement, type, lastProps, nextProps, rootContainerElement) {
  let updatePayload = null

  for (let propKey in lastProps) {
    if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
      continue
    }
    if (propKey === CHILDREN) {
      // Noop. Text children not supported
    } else {
      // For all other deleted properties we add it to the queue. We use
      // the whitelist in the commit phase instead.
      if (!updatePayload) {
        updatePayload = []
      }
      updatePayload.push(propKey, null)
    }
  }

  for (let propKey in nextProps) {
    const nextProp = nextProps[propKey]
    const lastProp = lastProps != null ? lastProps[propKey] : undefined

    if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || (nextProp == null && lastProp == null)) {
      continue
    }

    if (propKey === CHILDREN) {
      // Noop. Text children not supported
    } else {
      // For any other property we always add it to the queue and then we
      // filter it out using the whitelist during the commit.
      if (!updatePayload) {
        updatePayload = []
      }
      updatePayload.push(propKey, nextProp)
    }
  }
  return updatePayload
}
1248605
static String typeVarToString(DocEnv env, TypeVar v, boolean full) {
        StringBuilder s = new StringBuilder(v.toString());
        List<Type> bounds = getBounds(v, env);
        if (bounds.nonEmpty()) {
            boolean first = true;
            for (Type b : bounds) {
                s.append(first ? " extends " : " & ");
                s.append(TypeMaker.getTypeString(env, b, full));
                first = false;
            }
        }
        return s.toString();
    }
313243
function Pa () {

  var paFile = path.resolve('package.json');

  var writePackageJson = function (json) {
    fs.writeFileSync(paFile, JSON.stringify(json, null, 2));
  };

  this.init = function () {
    this.pkg = require(paFile);
    return this;
  };

  this.get = function (key) {
    var val = this.pkg[key] || this.pkg[require('./alias').init().aliases[key]];
    if (typeof val === 'undefined') {
      return ('can not read property ' + key + ' from package.json').red;
    }
    return (typeof val === 'object' ? JSON.stringify(val, null, 2) : val).green;
  };

  this.set = function (key, value) {
    key = this.pkg[key] ? key : require('./alias').init().aliases[key];
    this.pkg[key] = value;
    writePackageJson(this.pkg);
    return ("set key '" + key + "' to value '" + value + "'").green;
  };

  this.trigger = function (argv) {
    switch (argv._.length) {
      case 0:
        return JSON.stringify(this.pkg, null, 2).green;
      case 1:
        return this.get(argv._[0]);
      case 2:
        return this.set(argv._[0], argv._[1]);
      default:
        return "something bad happened, just run 'pa [key] [value]' to set the new value in your package.json";
    }

  };

}
541507
function getTransformCacheKey(opts: {|
  +cacheVersion: string,
  +projectRoot: string,
  +transformerConfig: TransformerConfig,
|}): string {
  const {transformerPath, transformerConfig} = opts.transformerConfig;

  // eslint-disable-next-line lint/flow-no-fixme
  /* $FlowFixMe: dynamic requires prevent static typing :'(  */
  const Transformer = require(transformerPath);
  const transformerInstance = new Transformer(
    opts.projectRoot,
    transformerConfig,
  );

  const transformerKey =
    typeof transformerInstance.getCacheKey !== 'undefined'
      ? transformerInstance.getCacheKey()
      : '';

  const cacheKeyParts = [
    'metro-cache',
    VERSION,
    opts.cacheVersion,
    path.relative(path.join(__dirname, '../../../..'), opts.projectRoot),
    getKeyFromFiles([require.resolve(transformerPath)]),
    transformerKey,
  ];

  return crypto
    .createHash('sha1')
    .update(cacheKeyParts.join('$'))
    .digest('hex');
}
549326
function isBuildInType(type) {
        return type === Function
            || type === String
            || type === Boolean
            || type === Number
            || type === RegExp
            || type === Object
            || type === Array
            || type === Date
    }