import "core-js/modules/es.array.reduce.js";
import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import { transformRoute } from '@umijs/route-utils';
function fromEntries(iterable) {
  const iterableArray = Array.from(iterable);
  return iterableArray.reduce((obj, [key, val]) => {
    obj[key] = val;
    return obj;
  }, {});
}
export default ((routes, menu, formatMessage, menuDataRender) => {
  const {
    menuData,
    breadcrumb
  } = 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 = 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
  };
});