import "zone.js";
import * as singleSpa from "single-spa";
import { GlobalEventDistributor } from "./globalEventDistributor";
import { loadApp } from "./helper";

async function init() {
  const globalEventDistributor = new GlobalEventDistributor();
  const loadingPromises = [];
  loadingPromises.push(loadApp("grainreservesArea", "/grainreservesArea", "../grainreservesArea/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("earlyWarning", "/earlyWarning", "../earlyWarning/singleSpaEntry.js", null, null)); //预警
  loadingPromises.push(loadApp("accountability", "/accountability", "../accountability/singleSpaEntry.js", null, null)); // does not have a store, so we pass null
  loadingPromises.push(loadApp("publicfunction", "/publicfunction", "../publicfunction/singleSpaEntry.js", null, null)); //通用功能子系統
  loadingPromises.push(loadApp("grainReserves", "/grainReserves", "../grainReserves/singleSpaEntry.js", null, null)); // does not have a store, so we pass null

  loadingPromises.push(
    loadApp("grainReservesFirm", "/grainReservesFirm", "../grainReservesFirm/singleSpaEntry.js", null, null)
  ); // does not have a store, so we pass null
  loadingPromises.push(
    loadApp("grainCoManage", '/grainCoManage', "../grainCoManage/singleSpaEntry.js", null, null)
  ); // does not have a store, so we pass null

  loadingPromises.push(loadApp("emergency", "/emergency", "../emergency/singleSpaEntry.js", null, null));

  loadingPromises.push(loadApp("monitor", "/monitor", "../monitor/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("quality", "/quality", "../quality/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("circulate", "/circulate", "../circulate/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("transaction", "/transaction", "../transaction/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("decision", "/decision", "../decision/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("inspection", "/inspection", "../inspection/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("financial", "/financial", "../financial/singleSpaEntry.js", null, null));
  loadingPromises.push(
    loadApp("headResponsibility", "/headResponsibility", "../headResponsibility/singleSpaEntry.js", null, null)
  );
  loadingPromises.push(loadApp("industry", "/industry", "../industry/singleSpaEntry.js", null, null));
  loadingPromises.push(
    loadApp("safetyProduction", "/safetyProduction", "../safetyProduction/singleSpaEntry.js", null, null)
  );
  loadingPromises.push(loadApp("systemSetting", "/systemSetting", "../systemSetting/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("webDecision", "/webDecision", "../webDecision/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("projectmanage", "/projectmanage", "../projectmanage/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("ywbb", "/ywbb", "../ywbb/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("log", "/log", "../log/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("safeProduction", "/safeProduction", "../safeProduction/singleSpaEntry.js", null, null));
  loadingPromises.push(loadApp("operationservices", "/operationservices", "../operationservices/singleSpaEntry.js", null, null)); //运维服务功能子系統

  await Promise.all(loadingPromises);

  singleSpa.start();
}

init();
