"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = _default;

function _react() {
  const data = _interopRequireDefault(require("react"));

  _react = function _react() {
    return data;
  };

  return data;
}

var _getRouteConfig = _interopRequireDefault(require("../../routes/getRouteConfig"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const debug = require('debug')('umi-build-dev:getRouteManager');

function _default(service) {
  const paths = service.paths;
  return {
    routes: null,

    fetchRoutes() {
      debug('fetch routes');
      const config = service.userConfig.getConfig({
        force: true
      });
      const routes = service.applyPlugins('modifyRoutes', {
        initialValue: (0, _getRouteConfig.default)(paths, config, route => {
          service.applyPlugins('onPatchRoute', {
            args: {
              route
            }
          });
        })
      });
      debug('fetch routes done');
      debug(routes);
      this.routes = routes;
      service.routes = routes;
    }

  };
}