"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;
}

function _path() {
  const data = require("path");

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

  return data;
}

function _lodash() {
  const data = require("lodash");

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

  return data;
}

function _umiUtils() {
  const data = require("umi-utils");

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

  return data;
}

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

function _default(api) {
  const _api$service = api.service,
        paths = _api$service.paths,
        config = _api$service.config;

  if (process.env.NODE_ENV === 'development') {
    api.modifyRoutes(memo => {
      const notFoundRoute = {
        component: `
() => React.createElement(require('${(0, _umiUtils().winPath)((0, _path().join)(__dirname, 'NotFound.js'))}').default, { pagesPath: '${paths.pagesPath}', hasRoutesInConfig: ${!!config.routes} })
        `.trim()
      };
      const routes = (0, _lodash().cloneDeep)(memo);

      function addNotFound(_route) {
        if (!_route.routes) {
          return;
        }

        _route.routes.forEach(_r => addNotFound(_r));

        _route.routes.push(notFoundRoute);
      }

      routes.forEach(r => addNotFound(r));
      routes.push(notFoundRoute);
      return routes;
    });
  }
}