<commit_before>import invariant from 'invariant';
import warning from 'warning';

import generateNestedRenderer from './NestedRenderer';

function getRouteName(branch) {
  const path = branch
    .map(leaf => leaf.path)
    .filter(path => path)
    .join('/');

  invariant(
    path && path.length > 0,
    'relay-nested-routes: Leaf route with components `%s` is missing ' +
    '`path` props required by relay-nested-routes.',
    branch.map(leaf => leaf.component).map(component => {
      if (!component) {
        return '[none]';
      }

      return component.displayName || component.name;
    }).join(' -> ')
  );

  return path;
}

export default function generateContainer(React, Relay, newProps){
  const {branch, components} = newProps;
  const name = getRouteName(branch);

  const params = {...newProps.location.query, ...newProps.params};
  const rootQueries = {};
  const fragmentSpecs = {};
  let queryIdx = 0;

  const [, ...elements] = components.map((Component, index) => {
    if (!Relay.isContainer(Component)) {
      return (props) => <Component {...props}/>;
    }

    const componentName = Component.displayName || Component.name;
    const {queries} = branch[index];

    invariant(
      queries,
      'relay-nested-routes: Route with component `%s` is missing a ' +
      '`queries` prop: <Route component={%s} queries={...} /> or ',
      componentName,
      componentName
    );

    const fragmentResolvers = [];
    Object.keys(queries).forEach(queryName => {
      warning(
        !params[queryName],
        'relay-nested-routes: Route with component `%s` has a fragment and a ' +
        'parameter named `%s`. If you meant to override an initialVariable ' +
        'then rename one of them.',
        componentName,
        queryName
      );
      const generatedName = `$$_${name}_${queryName}_${++queryIdx}`;
      const resolve = function() {<commit_msg>Fix a space in generateContainer.js<commit_after>import invariant from 'invariant';
import warning from 'warning';

import generateNestedRenderer from './NestedRenderer';

function getRouteName(branch) {
  const path = branch
    .map(leaf => leaf.path)
    .filter(path => path)
    .join('/');

  invariant(
    path && path.length > 0,
    'relay-nested-routes: Leaf route with components `%s` is missing ' +
    '`path` props required by relay-nested-routes.',
    branch.map(leaf => leaf.component).map(component => {
      if (!component) {
        return '[none]';
      }

      return component.displayName || component.name;
    }).join(' -> ')
  );

  return path;
}

export default function generateContainer(React, Relay, newProps){
  const {branch, components} = newProps;
  const name = getRouteName(branch);

  const params = {...newProps.location.query, ...newProps.params};
  const rootQueries = {};
  const fragmentSpecs = {};
  let queryIdx = 0;

  const [, ...elements] = components.map((Component, index) => {
    if (!Relay.isContainer(Component)) {
      return (props) => <Component {...props} />;
    }

    const componentName = Component.displayName || Component.name;
    const {queries} = branch[index];

    invariant(
      queries,
      'relay-nested-routes: Route with component `%s` is missing a ' +
      '`queries` prop: <Route component={%s} queries={...} /> or ',
      componentName,
      componentName
    );

    const fragmentResolvers = [];
    Object.keys(queries).forEach(queryName => {
      warning(
        !params[queryName],
        'relay-nested-routes: Route with component `%s` has a fragment and a ' +
        'parameter named `%s`. If you meant to override an initialVariable ' +
        'then rename one of them.',
        componentName,
        queryName
      );
      const generatedName = `$$_${name}_${queryName}_${++queryIdx}`;
      const resolve = function() {
{'fraction_non_alphanumeric': 0.14539284782041242, 'fraction_numerical': 0.0010441138084051162, 'mean_word_length': 2.9383350462487154, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, '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': '7286681', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1105, 'n_words': 300}