'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var index = require('./index.js');
var schedule = require('./schedule.js');
var selectorAll = require('../../../../../d3-selection@3.0.0/node_modules/d3-selection/src/selectorAll.js');

function transition_selectAll(select) {
  var name = this._name,
      id = this._id;

  if (typeof select !== "function") select = selectorAll.default(select);

  for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
    for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
      if (node = group[i]) {
        for (var children = select.call(node, node.__data__, i, group), child, inherit = schedule.get(node, id), k = 0, l = children.length; k < l; ++k) {
          if (child = children[k]) {
            schedule.default(child, name, id, k, children, inherit);
          }
        }
        subgroups.push(children);
        parents.push(node);
      }
    }
  }

  return new index.Transition(subgroups, parents, name, id);
}

exports.default = transition_selectAll;
