Resolve Babel plugins for all 'browsers'
@param {Array} browsers
@returns {Array}
511923
function resolvePluginsForBrowsers(browsers) {
  const plugins = [];

  if (!Array.isArray(browsers)) browsers = [browsers];

  browsers.forEach(browser => {
    const name = Object.keys(browser)[0];
    const version = browser[name];

    for (const pluginName in babelPluginsByEnvironmentVersion) {
      if (
        !babelPluginsByEnvironmentVersion[pluginName][name] ||
        babelPluginsByEnvironmentVersion[pluginName][name] > version
      ) {
        plugins.push(`babel-plugin-${pluginName}`);
      }
    }
  });

  return plugins;
}
832005
function(resolvers) {
        return function(path, name, importerPath) {
            var num_resolvers = resolvers.length;
            return new Promise(function(resolve, reject) {
                if (resolvers.length === 0 ) {
                    reject('At least 1 resolver must be provided');
                }

                function try_resolver(index) {
                    resolvers[index](path, name, importerPath)
                        .then(function(m) {
                            resolve(m);
                        })
                        .catch(function() {
                            if (index + 1 === num_resolvers) {
                                reject(new Error('Could not find module: ' + path));
                            } else {
                                try_resolver(index + 1);
                            }
                        });
                }

                try_resolver(0);
            });
        };
    }
1347360
function resolve(url, localUrl, chunks, skyPagesConfig) {
  let host = skyPagesConfig.skyux.host.url;
  let config = {
    scripts: getScripts(chunks),
    localUrl: localUrl
  };

  if (skyPagesConfig.skyux.app && skyPagesConfig.skyux.app.externals) {
    config.externals = skyPagesConfig.skyux.app.externals;
  }

  // Trim leading slash since getAppBase adds it
  if (url && url.charAt(0) === '/') {
    url = url.substring(1);
  }

  // Trim trailing slash since geAppBase adds it
  if (host && host.charAt(host.length - 1) === '/') {
    host = host.slice(0, -1);
  }

  const delimeter = url.indexOf('?') === -1 ? '?' : '&';
  const encoded = new Buffer(JSON.stringify(config)).toString('base64');
  const base = skyPagesConfigUtil.getAppBase(skyPagesConfig);
  const resolved = `${host}${base}${url}${delimeter}local=true&_cfg=${encoded}`;

  return resolved;
}
506109
function resolve (options) {
  return {
    apiBuilders: resolveOption(options, 'apiBuilders'),
    languages: resolveOption(options, 'languages'),
    targetVersions: resolveOption(options, 'targetVersions'),
    issueUrl: resolveOption(options, 'issueUrl'),
    processChangelogs: resolveOption(options, 'processChangelogs'),
    changelogReverseVisibleList: resolveOption(options, 'changelogReverseVisibleList'),
    changelogGroupByApi: resolveOption(options, 'changelogGroupByApi')
  }
}
867150
function resolveSources() {
  const sources = [
    ...resolveEnvSources('NODE_PATH'),
    ...resolveEnvSources('BROWSER_PATH'),
    // Get global path from npm config
    path.join(
      process.env.npm_config_prefix || exec('npm config get prefix', { encoding: 'utf8' }).replace('\n', ''),
      'lib/node_modules'
    )
  ];

  return unique(sources.map(source => path.resolve(source)));
}
196489
function fixAllLinks(htmlFiles) {
  const writePromises = [];
  htmlFiles.forEach(file => {
    // Update links in each html file to match flattened file structure.
    writePromises.push(fixLinks(`${docPath}/${file}.html`));
  });
  return Promise.all(writePromises);
}
1019272
function resolveScripts(file, pathes) {
    var filePath = file.path,
        scriptsStr = '';

    for(var i = 0, len = pathes.length; i < len; i ++) {
        scriptsStr += '<script defer src="' + path.relative(path.dirname(filePath), pathes[i]) + '"></script>\r\n';
    }

    return scriptsStr;
}
147111
function browserBuild(config) {
  const compiler = webpack(config);
  return new Promise((resolve, reject) => {
    compiler.run((err, stats) => {
      if (err) {
        return reject(err);
      }
      const messages = formatWebpackMessages(stats.toJson({}, true));
      if (messages.errors.length) {
        return reject(new Error(messages.errors.join('\n\n')));
      }
      return resolve({ stats, warnings: messages.warnings });
    });
  });
}
921165
function resolveNodeSlots (
  children,
  context
) {
  const slots = {}

  const defaultSlot = []
  for (let i = 0, l = children.length; i < l; i++) {
    const child = children[i]
    const name = child.getAttribute && child.getAttribute('slot')

    if (name) {
      const slot = (slots[name] || (slots[name] = []))
      if (child.tagName === 'TEMPLATE') {
        slot.push.apply(slot, child.content.childNodes)
      } else {
        slot.push(child)
      }
      child.removeAttribute('slot')
    } else {
      defaultSlot.push(child)
    }
  }

  slots.default = defaultSlot

  return slots
}
642130
function _resolveElements(elements) {
                // No input is just an empty array
                if (!elements) {
                    return [];
                }

                // Make sure it's in array form.
                if (typeof elements === "string" || !elements || !elements.length) {
                    elements = [elements];
                }

                // Make sure we have a DOM element for each one, (could be string id name or toolkit object)
                var i,
                    realElements = [];
                for (i = 0; i < elements.length; i++) {
                    if (elements[i]) {
                        if (typeof elements[i] === "string") {
                            var element = _Global.document.getElementById(elements[i]);
                            if (element) {
                                realElements.push(element);
                            }
                        } else if (elements[i].element) {
                            realElements.push(elements[i].element);
                        } else {
                            realElements.push(elements[i]);
                        }
                    }
                }

                return realElements;
            }
1278154
function _withPlugins(fn) {
  return function() {
    const args = Array.from(arguments);
    const opts = args[1] || {};
    args[1] = Object.assign({}, opts, {
      plugins: loadPlugins(opts.plugins, opts.pluginSearchDirs)
    });
    return fn.apply(null, args);
  };
}
1053246
function Resolver(domains, arbiters, exts, npmTree, builtIns, serverModules) {
  this.finder = makeFinder(exts);
  this.npmResolve = makeNpmResolver(domains.npm);
  this.domains = domains;
  this.arbiters = arbiters;
  this.exts = exts;
  this.npmTree = npmTree;
  this.builtIns = builtIns;
  this.serverModules = serverModules;
}
208456
function isSupportedInAllBrowsers(bcdProperty) {
	if (bcdProperty.__compat) {
		return Object.keys(browserNames).every((abbrev) => {
			const browserName = browserNames[abbrev].toLowerCase()
			if (bcdProperty.__compat && bcdProperty.__compat.support[browserName]) {
				const browserSupport = bcdProperty.__compat.support[browserName]
				if (browserSupport) {
					return isSupported(browserSupport)
				}
			}

			return false
		})
	} else {
		return Object.keys(browserNames).every((abbrev) => {
			const browserName = browserNames[abbrev].toLowerCase()

			return Object.keys(bcdProperty).some(contextName => {
				const context = bcdProperty[contextName]
				if (context.__compat && context.__compat.support[browserName]) {
					const browserSupport = context.__compat.support[browserName]
					if (browserSupport) {
						return isSupported(browserSupport)
					}
				}

				return false
			})
		})
	}
}
202484
function loadPluginsForType(type, options, version, compress) {
  // Start with default if available
  let plugins = type in allPlugins && allPlugins[type].default ? allPlugins[type].default.slice() : [];

  // Add plugins based on version presets
  plugins = version.reduce((plugins, preset) => {
    let presetPlugins;

    if ('string' == typeof preset) {
      preset = preset.toLowerCase();
      // Ignore generic
      if (RE_GENERIC_VERSION.test(preset)) return plugins;
      // Skip if babel version and type is postcss
      if (type == 'postcss' && preset in allPlugins.babel) return plugins;

      presetPlugins = allPlugins[type][preset];
      // Try and parse with browserslist if no match
      if (!presetPlugins) preset = { browsers: [preset] };
    }

    // Handle object ({ chrome: 5 }, { browsers: ['last 3'] })
    if (!presetPlugins && 'string' != typeof preset) {
      const key = Object.keys(preset)[0];
      const value = preset[key];

      if (key == 'browsers' && Array.isArray(value)) {
        if (type == 'postcss') {
          // Add Autoprefixer and pass-through
          presetPlugins = [['autoprefixer', preset]];
        } else if (type == 'babel') {
          try {
            // Add Babel plugins based on Autoprefixer-style config
            presetPlugins = resolvePluginsForBrowsers(
              browserslist(value).map(browser => {
                const [name, version] = browser.split(' ');

                return { [name]: version };
              })
            );
          } catch (err) {
            /* invalid browserslist value */
          }
        }
      } else {
        // See if concated key+value exists already
        presetPlugins =
          allPlugins[type][(key + value).toLowerCase()] || (type == 'babel' && resolvePluginsForBrowsers(preset));
      }
    }

    if (!presetPlugins) warn(`unable to resolve plugins for ${strong(preset)} version`, 1);

    return unique(plugins.concat(presetPlugins || []));
  }, plugins);

  // Add compression plugins
  if (compress && type in allPlugins && allPlugins[type].compress) {
    plugins.push(...allPlugins[type].compress);
  }

  // Add plugins defined in build (add before current plugins, but preserve order)
  for (let i = options.plugins.length - 1; i >= 0; i--) {
    const plugin = options.plugins[i];
    const pluginName = Array.isArray(plugin) ? plugin[0] : plugin;
    let exists = false;

    plugins.some((existingPlugin, idx) => {
      const existingPluginName = Array.isArray(existingPlugin) ? existingPlugin[0] : existingPlugin;

      // Overwrite if exists
      if (pluginName == existingPluginName) {
        plugins[idx] = plugin;
        exists = true;
      }

      return exists;
    });

    if (!exists) plugins.unshift(plugin);
  }
  options.plugins = plugins;
  // Store hash of plugin names
  options.fingerprint = md5(JSON.stringify(options));
  // Install missing dependencies
  dependencies.install(extractDependencyIds(options));
  resolveDependencyPaths(options);
}
894594
function resolverMiddleware (resolver) {
  return function (req, res, next) {
    try {
      const { source, args, context, info } = req
      const ctx = { req, res, next }
      const value = resolver.call(ctx, source, args, context, info)

      return Promise.resolve(value)
        .then(result => {
          req.result = result
          return next()
        })
        .catch(next)
    } catch (err) {
      return next(err)
    }
  }
}
1189256
function filterBrowsers (browsers, re) {
    return Object.keys(browsers).filter(function (key) {
        return re.test(key);
    });
}
876854
function resolveByPlugin(plugin, from, id) {
	if (plugin.exports && plugin.exports.normalize) {
		return plugin.exports.normalize(id, resolveId.bind(null, from));
	}
	return resolveId(from, id);
}