import { P as Pathname, a as PathnameAccounting, c as PathnameInventory, e as PathnamePurchase, d as PathnameManufacturing, b as PathnameCrm, f as PathnameRental } from "./pathname.rental-VYOFVGX6.esm.js";
import { i as images } from "./images-DvZ6-RV8.esm.js";
import { a as PathnameUsers, P as PathnameHrms } from "./pathname.hrms-C5ojsho0.esm.js";
import { g as getApiConfig } from "./api-config-GOys-syK.esm.js";
import { a as getModuleRoutes } from "./module-routes-config-CCkZEtfg.esm.js";
let PathnameDocument = {
  LANDING_PAGE: "/",
  PRIVATE: "/private",
  SHARED: "/shared",
  PUBLIC: "/public",
  SETTING: "/setting",
  FORMS: "/setting/forms",
  ADD_CUSTOM_FIELDS: "/setting/forms/add-custom-fields"
};
const PathnameOnBoarding = {
  LANDING_PAGE: "/",
  LIST: "/list",
  FORMS: "/settings/forms"
};
const getOnboardingMenuItem = (t, env) => {
  if (!["ksa"].includes(env)) {
    return [];
  }
  return [
    {
      label: t("onboarding.name"),
      link: Pathname.DASHBOARD_ONBOARDING,
      sidebar: images.sidebar.user,
      bacModuleName: "user",
      icon: images.user,
      permission: "",
      beModuleName: "rbac",
      bg: "#F3E8FF",
      connectedRoutes: Object.values(PathnameOnBoarding).map(
        (path) => Pathname.DASHBOARD_ONBOARDING + path
      ),
      translationModule: ["onboarding"]
    }
  ];
};
const modules = (t) => {
  const u_data = localStorage.getItem("_u_data") || void 0;
  const userData = u_data ? JSON.parse(u_data) : "";
  const config = getApiConfig();
  const access_modules = (userData == null ? void 0 : userData.module_access) || [];
  const VITE_APP_ENV = (config == null ? void 0 : config.zatcaEnvironment) || "simulation";
  const accessibleModules = access_modules.map((module) => module.module_name);
  const accessibleModulesSet = new Set(accessibleModules);
  const MenuBar = [
    {
      label: t("user.name"),
      link: Pathname.DASHBOARD_USER,
      sidebar: images.sidebar.user,
      bacModuleName: "user",
      icon: images.user,
      permission: "",
      beModuleName: "rbac",
      bg: "#F3E8FF",
      connectedRoutes: Object.values(PathnameUsers).map(
        (path) => Pathname.DASHBOARD_USER + path
      ),
      translationModule: ["user"]
    },
    {
      label: t("document.name"),
      link: Pathname.DASHBOARD_DOCUMENT,
      sidebar: images.sidebar.document,
      bacModuleName: "document",
      icon: images.document,
      permission: "",
      beModuleName: "document",
      bg: "#E0F2FE",
      connectedRoutes: Object.values(PathnameDocument).map(
        (path) => Pathname.DASHBOARD_DOCUMENT + path
      ),
      translationModule: ["document"]
    },
    {
      label: t("accounting.name"),
      link: Pathname.DASHBOARD_ACCOUNTING,
      sidebar: images.sidebar.accountingIcon,
      bacModuleName: "accounts-and-finance",
      icon: images.accounting,
      permission: "",
      beModuleName: "accounts-and-finance",
      bg: "#E8EAF6",
      connectedRoutes: Object.values(PathnameAccounting).map(
        (path) => Pathname.DASHBOARD_ACCOUNTING + path
      ),
      translationModule: ["accounting"]
    },
    {
      label: t("inventory.name"),
      link: Pathname.DASHBOARD_INVENTORY,
      sidebar: images.sidebar.inventoryIcon,
      bacModuleName: "inventory",
      icon: images.inventory,
      permission: "",
      beModuleName: "inventory",
      bg: "#FFF3E6",
      connectedRoutes: Object.values(PathnameInventory).map(
        (path) => Pathname.DASHBOARD_INVENTORY + path
      ),
      translationModule: ["inventory"]
    },
    {
      label: t("project.name"),
      link: Pathname.DASHBOARD_PROJECT,
      sidebar: images.sidebar.projectIcon,
      bacModuleName: "project",
      icon: images.project,
      permission: "",
      beModuleName: "project",
      bg: "#DCFCE7",
      connectedRoutes: [],
      translationModule: ["project"]
    },
    {
      label: t("procurement.name"),
      link: Pathname.DASHBOARD_PROCUREMENT,
      sidebar: images.sidebar.procurementIcon,
      bacModuleName: "purchase",
      icon: images.procurement,
      permission: "",
      beModuleName: "purchase",
      bg: "#FFEBE6",
      connectedRoutes: Object.values(PathnamePurchase).map(
        (path) => Pathname.DASHBOARD_PROCUREMENT + path
      ),
      // connectedRoutes: [],
      translationModule: ["procurement"]
    },
    {
      label: t("manufacturing.name"),
      link: Pathname.DASHBOARD_MANUFACTURING,
      sidebar: images.sidebar.manufacturingIcon,
      bacModuleName: "manufacturing",
      icon: images.manufacturing,
      permission: "",
      beModuleName: "manufacturing",
      bg: "#F0FDF4",
      connectedRoutes: Object.values(PathnameManufacturing).map(
        (path) => Pathname.DASHBOARD_MANUFACTURING + path
      ),
      translationModule: ["manufacturing"]
    },
    {
      label: t("crm.name"),
      link: Pathname.DASHBOARD_CRM,
      sidebar: images.sidebar.crmIcon,
      bacModuleName: "sales",
      icon: images.crm,
      permission: "",
      beModuleName: "sales",
      bg: "#FCEBEC",
      connectedRoutes: Object.values(PathnameCrm).map(
        (path) => Pathname.DASHBOARD_CRM + path
      ),
      translationModule: ["crm"]
    },
    // {
    //   label: t("purchase.name"),
    //   link: Pathname.DASHBOARD_PURCHASE,
    //   sidebar: image.sidebar.purchaseIcon,
    //   icon: image.sidebar.purchaseIcon,
    //   permission: "",
    //   bg: "rgba(111, 102, 215, 0.10)",
    //   connectedRoutes: [],
    // },
    {
      label: t("hrms.name"),
      link: Pathname.DASHBOARD_HRMS,
      sidebar: images.sidebar.hrmsIcon,
      bacModuleName: "hrms",
      icon: images.hrms,
      permission: "",
      beModuleName: "hrms",
      bg: "#EBF9F2",
      connectedRoutes: (() => {
        const mfeRoutes = getModuleRoutes("hrms");
        if (mfeRoutes.length > 0) return mfeRoutes;
        return Object.values(PathnameHrms).map(
          (path) => Pathname.DASHBOARD_HRMS + path
        );
      })(),
      translationModule: ["hrms"]
    },
    {
      label: t("office.name"),
      link: Pathname.DASHBOARD_OFFICE,
      sidebar: images.sidebar.officeIcon,
      bacModuleName: "office",
      icon: images.office,
      permission: "",
      beModuleName: "office",
      bg: "#DCFCE7",
      connectedRoutes: [],
      translationModule: ["office"]
    },
    {
      label: t("rental.name"),
      link: Pathname.DASHBOARD_RENTAL,
      sidebar: images.sidebar.rentalIcon,
      bacModuleName: "rental",
      icon: images.rental,
      permission: "",
      beModuleName: "rental",
      bg: "#FEF3C7",
      connectedRoutes: Object.values(PathnameRental).map(
        (path) => Pathname.DASHBOARD_RENTAL + path
      ),
      translationModule: ["rental", "inventory"]
    },
    {
      label: "Settings",
      link: Pathname.DASHBOARD_QUOTES,
      sidebar: images.sidebar.setting,
      bacModuleName: "setting",
      icon: images.settings,
      permission: "",
      beModuleName: "setting",
      bg: "#EEF2FF",
      connectedRoutes: [],
      translationModule: ["settings"]
    },
    ...getOnboardingMenuItem(t, VITE_APP_ENV)
  ];
  function filterMenu(menu) {
    return menu.filter((item) => {
      const isModuleAccessible = accessibleModulesSet.has(item.bacModuleName);
      let hasValidSubmenu = false;
      if (item.submenu && item.submenu.length > 0) {
        item.submenu = filterMenu(item.submenu);
        hasValidSubmenu = item.submenu.length > 0;
      }
      return isModuleAccessible || hasValidSubmenu;
    });
  }
  const filteredMenu = filterMenu(MenuBar);
  return filteredMenu;
};
export {
  PathnameDocument as P,
  modules as m
};
//# sourceMappingURL=modules-Bpg0vTA2.esm.js.map
