import { E as compilerRuntimeExports, j as jsxRuntimeExports, r as reactExports, a0 as useParams, V as Outlet } from "./vendor-react-DYNCg6N5.js";
import { R as ROUTES, aC as GearIcon, aD as UsersIcon, aE as ShieldIcon, aF as MailIcon, aG as SendIcon, aH as TimezonesIcon, aI as inviteUserIcon, a2 as DriveIcon, aJ as CalendarExtraIcon, aK as DrawIcon, aL as ContactsIcon, aM as ProjectsIcon, aN as PagesIcon, aO as FormsIcon, c as useAppSelector, aP as getFilialEditRoutes, i as isSaaS, b as useActions, aQ as useGetFilialsInfoCommonQuery, L as Layout, E as ErrorBoundary, F as CompanyPlaceholder, aR as NotFound } from "./index-DfebxkL9.js";
import { S as SidebarMenu, a as SimpleNavbar } from "./index-B7nmdYVM.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
import { u as IconBox } from "./vendor-icons-xWhXK_Ui.js";
import { u as useStyles } from "./styles-Dnu4P1Zm.js";
import { F as Flex, g as Loader, b as Box, V as LoadingOverlay, o as Burger, T as Text } from "./vendor-mantine-h0WlM2Mj.js";
import "./styles-3NoIlzov.js";
const useGetNavMenuItems = () => {
  const $ = compilerRuntimeExports.c(85);
  const {
    t
  } = useTranslation();
  let t0;
  if ($[0] !== t) {
    t0 = t("filials.settings.general");
    $[0] = t;
    $[1] = t0;
  } else {
    t0 = $[1];
  }
  let t1;
  if ($[2] !== t0) {
    t1 = {
      label: t0,
      icon: GearIcon,
      value: ROUTES.filials.edit.pages.common.settings
    };
    $[2] = t0;
    $[3] = t1;
  } else {
    t1 = $[3];
  }
  let t2;
  if ($[4] !== t) {
    t2 = t("filials.settings.auth");
    $[4] = t;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  let t3;
  if ($[6] !== t2) {
    t3 = {
      label: t2,
      icon: UsersIcon,
      value: ROUTES.filials.edit.pages.auth.ldap
    };
    $[6] = t2;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  let t4;
  if ($[8] !== t) {
    t4 = t("CustomLinks.title");
    $[8] = t;
    $[9] = t4;
  } else {
    t4 = $[9];
  }
  let t5;
  if ($[10] !== t4) {
    t5 = {
      label: t4,
      icon: IconBox,
      value: ROUTES.filials.edit.pages.common.modules
    };
    $[10] = t4;
    $[11] = t5;
  } else {
    t5 = $[11];
  }
  let t6;
  if ($[12] !== t) {
    t6 = t("profile.safety");
    $[12] = t;
    $[13] = t6;
  } else {
    t6 = $[13];
  }
  let t7;
  if ($[14] !== t6) {
    t7 = {
      label: t6,
      icon: ShieldIcon,
      value: ROUTES.filials.edit.pages.common.security
    };
    $[14] = t6;
    $[15] = t7;
  } else {
    t7 = $[15];
  }
  let t8;
  if ($[16] !== t) {
    t8 = t("servers.title");
    $[16] = t;
    $[17] = t8;
  } else {
    t8 = $[17];
  }
  let t9;
  if ($[18] !== t8) {
    t9 = {
      label: t8,
      icon: MailIcon,
      value: ROUTES.filials.edit.pages.common.mailServers
    };
    $[18] = t8;
    $[19] = t9;
  } else {
    t9 = $[19];
  }
  let t10;
  if ($[20] !== t) {
    t10 = t("filials.settings.linkSettings");
    $[20] = t;
    $[21] = t10;
  } else {
    t10 = $[21];
  }
  let t11;
  if ($[22] !== t10) {
    t11 = {
      label: t10,
      icon: SendIcon,
      value: ROUTES.filials.edit.pages.common.mailingSetup
    };
    $[22] = t10;
    $[23] = t11;
  } else {
    t11 = $[23];
  }
  let t12;
  if ($[24] !== t) {
    t12 = t("filials.settings.locale");
    $[24] = t;
    $[25] = t12;
  } else {
    t12 = $[25];
  }
  let t13;
  if ($[26] !== t12) {
    t13 = {
      label: t12,
      icon: TimezonesIcon,
      value: ROUTES.filials.edit.pages.common.locale
    };
    $[26] = t12;
    $[27] = t13;
  } else {
    t13 = $[27];
  }
  let t14;
  if ($[28] !== t) {
    t14 = t("register.title");
    $[28] = t;
    $[29] = t14;
  } else {
    t14 = $[29];
  }
  let t15;
  if ($[30] !== t14) {
    t15 = {
      label: t14,
      icon: inviteUserIcon,
      value: ROUTES.filials.edit.pages.auth.invite
    };
    $[30] = t14;
    $[31] = t15;
  } else {
    t15 = $[31];
  }
  let t16;
  if ($[32] !== t) {
    t16 = t("profile.retentionPolicy");
    $[32] = t;
    $[33] = t16;
  } else {
    t16 = $[33];
  }
  let t17;
  if ($[34] !== t16) {
    t17 = {
      label: t16,
      icon: DriveIcon,
      value: ROUTES.filials.edit.pages.common.diskSpace
    };
    $[34] = t16;
    $[35] = t17;
  } else {
    t17 = $[35];
  }
  let t18;
  if ($[36] !== t1 || $[37] !== t11 || $[38] !== t13 || $[39] !== t15 || $[40] !== t17 || $[41] !== t3 || $[42] !== t5 || $[43] !== t7 || $[44] !== t9) {
    t18 = [t1, t3, t5, t7, t9, t11, t13, t15, t17];
    $[36] = t1;
    $[37] = t11;
    $[38] = t13;
    $[39] = t15;
    $[40] = t17;
    $[41] = t3;
    $[42] = t5;
    $[43] = t7;
    $[44] = t9;
    $[45] = t18;
  } else {
    t18 = $[45];
  }
  const filialCommonNavItems = t18;
  let t19;
  if ($[46] !== t) {
    t19 = t("filials.mail");
    $[46] = t;
    $[47] = t19;
  } else {
    t19 = $[47];
  }
  let t20;
  if ($[48] !== t19) {
    t20 = {
      label: t19,
      icon: MailIcon,
      value: ROUTES.filials.edit.pages.modules.email
    };
    $[48] = t19;
    $[49] = t20;
  } else {
    t20 = $[49];
  }
  let t21;
  if ($[50] !== t) {
    t21 = t("filials.calendar");
    $[50] = t;
    $[51] = t21;
  } else {
    t21 = $[51];
  }
  let t22;
  if ($[52] !== t21) {
    t22 = {
      label: t21,
      icon: CalendarExtraIcon,
      value: ROUTES.filials.edit.pages.modules.calendar
    };
    $[52] = t21;
    $[53] = t22;
  } else {
    t22 = $[53];
  }
  let t23;
  if ($[54] !== t) {
    t23 = t("filials.draw");
    $[54] = t;
    $[55] = t23;
  } else {
    t23 = $[55];
  }
  let t24;
  if ($[56] !== t23) {
    t24 = {
      label: t23,
      icon: DrawIcon,
      value: ROUTES.filials.edit.pages.modules.draw
    };
    $[56] = t23;
    $[57] = t24;
  } else {
    t24 = $[57];
  }
  let t25;
  if ($[58] !== t) {
    t25 = t("filials.contacts");
    $[58] = t;
    $[59] = t25;
  } else {
    t25 = $[59];
  }
  let t26;
  if ($[60] !== t25) {
    t26 = {
      label: t25,
      icon: ContactsIcon,
      value: ROUTES.filials.edit.pages.modules.contacts
    };
    $[60] = t25;
    $[61] = t26;
  } else {
    t26 = $[61];
  }
  let t27;
  if ($[62] !== t) {
    t27 = t("filials.projects");
    $[62] = t;
    $[63] = t27;
  } else {
    t27 = $[63];
  }
  let t28;
  if ($[64] !== t27) {
    t28 = {
      label: t27,
      icon: ProjectsIcon,
      value: ROUTES.filials.edit.pages.modules.projects
    };
    $[64] = t27;
    $[65] = t28;
  } else {
    t28 = $[65];
  }
  let t29;
  if ($[66] !== t) {
    t29 = t("filials.pages");
    $[66] = t;
    $[67] = t29;
  } else {
    t29 = $[67];
  }
  let t30;
  if ($[68] !== t29) {
    t30 = {
      label: t29,
      icon: PagesIcon,
      value: ROUTES.filials.edit.pages.modules.pages
    };
    $[68] = t29;
    $[69] = t30;
  } else {
    t30 = $[69];
  }
  let t31;
  if ($[70] !== t) {
    t31 = t("filials.forms");
    $[70] = t;
    $[71] = t31;
  } else {
    t31 = $[71];
  }
  let t32;
  if ($[72] !== t31) {
    t32 = {
      label: t31,
      icon: FormsIcon,
      value: ROUTES.filials.edit.pages.modules.forms
    };
    $[72] = t31;
    $[73] = t32;
  } else {
    t32 = $[73];
  }
  let t33;
  if ($[74] !== t20 || $[75] !== t22 || $[76] !== t24 || $[77] !== t26 || $[78] !== t28 || $[79] !== t30 || $[80] !== t32) {
    t33 = [t20, t22, t24, t26, t28, t30, t32];
    $[74] = t20;
    $[75] = t22;
    $[76] = t24;
    $[77] = t26;
    $[78] = t28;
    $[79] = t30;
    $[80] = t32;
    $[81] = t33;
  } else {
    t33 = $[81];
  }
  const filialModulesNavItems = t33;
  let t34;
  if ($[82] !== filialCommonNavItems || $[83] !== filialModulesNavItems) {
    t34 = {
      filialCommonNavItems,
      filialModulesNavItems
    };
    $[82] = filialCommonNavItems;
    $[83] = filialModulesNavItems;
    $[84] = t34;
  } else {
    t34 = $[84];
  }
  return t34;
};
const NavMenu = (t0) => {
  const $ = compilerRuntimeExports.c(14);
  const {
    setIsOpen
  } = t0;
  const {
    t
  } = useTranslation();
  const {
    Settings
  } = useAppSelector(_temp);
  const {
    filialCommonNavItems
  } = useGetNavMenuItems();
  let t1;
  if ($[0] !== t) {
    t1 = t("common");
    $[0] = t;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  let t2;
  if ($[2] !== Settings || $[3] !== filialCommonNavItems) {
    let t32;
    if ($[5] !== Settings) {
      t32 = (item) => !isSaaS(Settings) || !["mailing-setup"].includes(item.value);
      $[5] = Settings;
      $[6] = t32;
    } else {
      t32 = $[6];
    }
    t2 = filialCommonNavItems.filter(t32);
    $[2] = Settings;
    $[3] = filialCommonNavItems;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  let t3;
  if ($[7] !== t1 || $[8] !== t2) {
    t3 = [{
      label: t1,
      pages: t2
    }];
    $[7] = t1;
    $[8] = t2;
    $[9] = t3;
  } else {
    t3 = $[9];
  }
  const linksBlocks = t3;
  let t4;
  if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
    t4 = getFilialEditRoutes();
    $[10] = t4;
  } else {
    t4 = $[10];
  }
  let t5;
  if ($[11] !== linksBlocks || $[12] !== setIsOpen) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenu, { setIsOpen, linksBlocks, routes: t4 });
    $[11] = linksBlocks;
    $[12] = setIsOpen;
    $[13] = t5;
  } else {
    t5 = $[13];
  }
  return t5;
};
function _temp(state) {
  return state.userInfo;
}
const FilialEdit = (t0) => {
  const $ = compilerRuntimeExports.c(17);
  const {
    children
  } = t0;
  const containerRef = reactExports.useRef(null);
  const {
    setFilial
  } = useActions();
  const {
    classes
  } = useStyles();
  const [isOpen, setIsOpen] = reactExports.useState(false);
  const {
    id: t1
  } = useParams();
  const id = t1 === void 0 ? "" : t1;
  const t2 = +id;
  let t3;
  if ($[0] !== t2) {
    t3 = {
      id: t2,
      extended: true
    };
    $[0] = t2;
    $[1] = t3;
  } else {
    t3 = $[1];
  }
  const {
    isLoading,
    data: filialData,
    error
  } = useGetFilialsInfoCommonQuery(t3);
  let t4;
  if ($[2] !== filialData || $[3] !== setFilial) {
    t4 = () => {
      if (filialData) {
        setFilial(filialData);
      }
    };
    $[2] = filialData;
    $[3] = setFilial;
    $[4] = t4;
  } else {
    t4 = $[4];
  }
  let t5;
  if ($[5] !== filialData) {
    t5 = [filialData];
    $[5] = filialData;
    $[6] = t5;
  } else {
    t5 = $[6];
  }
  reactExports.useEffect(t4, t5);
  let t6;
  if ($[7] !== setFilial) {
    t6 = () => () => {
      setFilial(null);
    };
    $[7] = setFilial;
    $[8] = t6;
  } else {
    t6 = $[8];
  }
  let t7;
  if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
    t7 = [];
    $[9] = t7;
  } else {
    t7 = $[9];
  }
  reactExports.useEffect(t6, t7);
  if (id !== void 0 && isNaN(Number(id)) || error) {
    let t82;
    if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
      t82 = /* @__PURE__ */ jsxRuntimeExports.jsx(NotFound, {});
      $[10] = t82;
    } else {
      t82 = $[10];
    }
    return t82;
  }
  let t8;
  if ($[11] !== children || $[12] !== classes || $[13] !== (filialData == null ? void 0 : filialData.Title) || $[14] !== isLoading || $[15] !== isOpen) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { justify: "center", align: "center", w: "100vw", h: "100vh", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, {}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Layout, { leftNavbarContent: /* @__PURE__ */ jsxRuntimeExports.jsx(SimpleNavbar, { widthNav: 290, className: classes.simpleNavbar, isOpen, setIsOpen, children: /* @__PURE__ */ jsxRuntimeExports.jsx(NavMenu, { setIsOpen }) }), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(ErrorBoundary, { componentTitle: "Filial edit page", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.wrapper, ref: containerRef, style: {
        flexGrow: 1,
        overflow: "auto"
      }, mt: "md", children: isLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { visible: isLoading, overlayProps: {
        blur: 2
      } }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { mb: "md", align: "center", className: classes.headerMenu, children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Burger, { opened: isOpen, onClick: () => setIsOpen(true), className: classes.burgerMenu, size: "sm" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(CompanyPlaceholder, { size: 24, stroke: "#101828" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { className: classes.titleContainer, px: "xs", color: "#101828", fw: 600, children: filialData == null ? void 0 : filialData.Title })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Outlet, {})
      ] }) }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.section, children })
    ] }) }) });
    $[11] = children;
    $[12] = classes;
    $[13] = filialData == null ? void 0 : filialData.Title;
    $[14] = isLoading;
    $[15] = isOpen;
    $[16] = t8;
  } else {
    t8 = $[16];
  }
  return t8;
};
export {
  FilialEdit as default
};
//# sourceMappingURL=index-DpSc2s9t.js.map
