"use strict";

function calcRoutes() {
  var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], t = arguments.length > 1 ? arguments[1] : void 0, l = [];
  if (e && e.length > 0) {
    var n = function e(l, n, h) {
      l.map((function(l) {
        if (l.path) {
          var i = l.path.split("/"), c = i[h + 1];
          if (i.length > 2) {
            var o = {
              path: c,
              component: t(c),
              childRoutes: []
            };
            if (i.length > h + 2) for (var r = o.childRoutes, u = h + 2; u < i.length; u++) {
              var d = {
                path: i[u],
                component: t(i[u]),
                childRoutes: []
              };
              r.push(d), r = d.childRoutes;
            }
            l.children && l.children.length > 0 && e(l.children, o.childRoutes, h + 1), n.push(o);
          } else l.children && l.children.length > 0 && e(l.children, n, h);
        }
      }));
    };
    n(e, l, 1);
  }
  return l;
}

Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = calcRoutes;