"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
require("core-js/modules/es.array.reduce.js");
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/web.dom-collections.iterator.js");
var _routeUtils = require("@umijs/route-utils");
function fromEntries(iterable) {
  const iterableArray = Array.from(iterable);
  return iterableArray.reduce((obj, [key, val]) => {
    obj[key] = val;
    return obj;
  }, {});
}
var _default = (routes, menu, formatMessage, menuDataRender) => {
  const {
    menuData,
    breadcrumb
  } = (0, _routeUtils.transformRoute)(routes, (menu === null || menu === void 0 ? void 0 : menu.locale) || false, formatMessage, true);
  if (!menuDataRender) {
    return {
      breadcrumb: fromEntries(breadcrumb),
      breadcrumbMap: breadcrumb,
      menuData
    };
  }
  const renderData = (0, _routeUtils.transformRoute)(menuDataRender(menuData), (menu === null || menu === void 0 ? void 0 : menu.locale) || false, formatMessage, true);
  return {
    breadcrumb: fromEntries(renderData.breadcrumb),
    breadcrumbMap: renderData.breadcrumb,
    menuData: renderData.menuData
  };
};
exports.default = _default;