import { E as compilerRuntimeExports, j as jsxRuntimeExports, r as reactExports } from "./vendor-react-DYNCg6N5.js";
import { u as useStyles } from "./styles-rKP3r-bS.js";
import { cv as useImageUrl, cw as Modules, _ as TailType, a0 as UserAvatar, c as useAppSelector, I as IFiltersEnumType, aU as axiosInstance, O as themeColors, cx as AccessType } from "./index-DfebxkL9.js";
import { O as OverflowTip } from "./index-C-CFogWu.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
import { $ as Table, G as Group, b as Box, g as Loader, O as Badge, T as Text, h as ActionIcon, B as Button, av as Combobox, d as Checkbox, aE as Pill, a4 as Select, E as TextInput, aG as FileButton, F as Flex, s as showNotification, m as Center } from "./vendor-mantine-h0WlM2Mj.js";
import { P as PopUpUI, u as useGetDeviceType } from "./index-DGrXxZ89.js";
import { F as IconX, H as IconPencil, y as IconTrash, a9 as IconGripVertical, J as IconChevronDown } from "./vendor-icons-xWhXK_Ui.js";
import { A as AddButton } from "./index-72JBTuLT.js";
import { M as Modal } from "./index-DqcA8P_y.js";
import { m as mailIcon, c as calendarIcon, a as contactsIcon, p as projectsIcon, b as pagesIcon, f as formsIcon } from "./icon-forms-C3RNUl8Z.js";
import { d as drawIcon } from "./icon-draw-BHY0kAVH.js";
import { P as PillsInputAutoCompleteWithQuery } from "./index-BBtw-2vv.js";
import { U as UserAvatarWithCard } from "./index-3c9En-DB.js";
import "./styles-3NoIlzov.js";
import "./useDebounce-DTubzIUC.js";
const container$1 = "_container_s8kg3_1";
const title$1 = "_title_s8kg3_15";
const classes$4 = {
  container: container$1,
  title: title$1
};
const NameCell = (t0) => {
  const $ = compilerRuntimeExports.c(19);
  const {
    item
  } = t0;
  const {
    i18n,
    t
  } = useTranslation();
  const displayName = i18n.language === "ru" ? item.titleRu : item.titleEn;
  const imageUrl = useImageUrl(item.icon);
  let t1;
  if ($[0] !== t) {
    t1 = (module) => {
      switch (module) {
        case Modules.Mail: {
          return t("filials.mail");
        }
        case Modules.Calendar: {
          return t("filials.calendar");
        }
        case Modules.Disk: {
          return t("filials.disk");
        }
        case Modules.Admin: {
          return t("filials.admin");
        }
        case Modules.Draw: {
          return t("filials.draw");
        }
        case Modules.Payments: {
          return t("filials.payments");
        }
        case Modules.Contacts: {
          return t("filials.contacts");
        }
        case Modules.Team: {
          return t("filials.teams");
        }
        case Modules.Projects: {
          return t("filials.projects");
        }
        case Modules.Pages: {
          return t("filials.pages");
        }
        case Modules.Forms: {
          return t("filials.forms");
        }
        default: {
          return null;
        }
      }
    };
    $[0] = t;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  const getModuleLabel = t1;
  let t2;
  if ($[2] !== getModuleLabel || $[3] !== item.module) {
    t2 = getModuleLabel(item.module);
    $[2] = getModuleLabel;
    $[3] = item.module;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  const moduleLabel = t2;
  let t3;
  if ($[5] !== displayName || $[6] !== imageUrl) {
    t3 = imageUrl ? /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { component: "img", src: imageUrl, alt: displayName, style: {
      width: 40,
      height: 40,
      objectFit: "contain",
      borderRadius: 4
    } }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { style: {
      width: 40,
      height: 40,
      display: "flex",
      alignItems: "center",
      justifyContent: "center"
    }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { size: "xs" }) });
    $[5] = displayName;
    $[6] = imageUrl;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  let t4;
  if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
    t4 = {
      display: "flex",
      flexDirection: "column",
      gap: "4px",
      minWidth: 0
    };
    $[8] = t4;
  } else {
    t4 = $[8];
  }
  let t5;
  if ($[9] !== displayName) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(OverflowTip, { size: "sm", fw: 500, children: displayName });
    $[9] = displayName;
    $[10] = t5;
  } else {
    t5 = $[10];
  }
  let t6;
  if ($[11] !== moduleLabel) {
    t6 = moduleLabel && /* @__PURE__ */ jsxRuntimeExports.jsx(Badge, { size: "sm", variant: "light", color: "blue", children: moduleLabel });
    $[11] = moduleLabel;
    $[12] = t6;
  } else {
    t6 = $[12];
  }
  let t7;
  if ($[13] !== t5 || $[14] !== t6) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: t4, children: [
      t5,
      t6
    ] });
    $[13] = t5;
    $[14] = t6;
    $[15] = t7;
  } else {
    t7 = $[15];
  }
  let t8;
  if ($[16] !== t3 || $[17] !== t7) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(Table.Td, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { gap: "sm", wrap: "nowrap", children: [
      t3,
      t7
    ] }) });
    $[16] = t3;
    $[17] = t7;
    $[18] = t8;
  } else {
    t8 = $[18];
  }
  return t8;
};
const TypeCell = (t0) => {
  const $ = compilerRuntimeExports.c(7);
  const {
    item
  } = t0;
  const {
    t
  } = useTranslation();
  let t1;
  if ($[0] !== t) {
    t1 = (type) => {
      switch (type) {
        case TailType.Module: {
          return t("CustomLinks.types.module");
        }
        case TailType.Integration: {
          return t("CustomLinks.types.integration");
        }
        case TailType.Link: {
          return t("CustomLinks.types.link");
        }
        default: {
          return type;
        }
      }
    };
    $[0] = t;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  const getTypeLabel = t1;
  let t2;
  if ($[2] !== getTypeLabel || $[3] !== item.tailType) {
    t2 = getTypeLabel(item.tailType);
    $[2] = getTypeLabel;
    $[3] = item.tailType;
    $[4] = t2;
  } else {
    t2 = $[4];
  }
  let t3;
  if ($[5] !== t2) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(Table.Td, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "sm", children: t2 }) });
    $[5] = t2;
    $[6] = t3;
  } else {
    t3 = $[6];
  }
  return t3;
};
const container = "_container_xabwg_1";
const header = "_header_xabwg_16";
const title = "_title_xabwg_24";
const body$1 = "_body_xabwg_30";
const footer$1 = "_footer_xabwg_35";
const classes$3 = {
  container,
  header,
  title,
  body: body$1,
  footer: footer$1
};
const DeleteCustomLinkModal = (t0) => {
  const $ = compilerRuntimeExports.c(38);
  const {
    setIsOpen,
    link,
    onConfirm
  } = t0;
  const {
    t,
    i18n
  } = useTranslation();
  let t1;
  if ($[0] !== setIsOpen) {
    t1 = () => setIsOpen(false);
    $[0] = setIsOpen;
    $[1] = t1;
  } else {
    t1 = $[1];
  }
  const onClose = t1;
  let t2;
  if ($[2] !== link.id || $[3] !== onClose || $[4] !== onConfirm) {
    t2 = () => {
      onConfirm(link.id);
      onClose();
    };
    $[2] = link.id;
    $[3] = onClose;
    $[4] = onConfirm;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  const handleConfirm = t2;
  const displayName = i18n.language === "ru" ? link.titleRu : link.titleEn;
  let t3;
  if ($[6] !== t) {
    t3 = t("CustomLinks.deleteModal.title");
    $[6] = t;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  let t4;
  if ($[8] !== t3) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classes$3.title, children: t3 });
    $[8] = t3;
    $[9] = t4;
  } else {
    t4 = $[9];
  }
  let t5;
  if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(IconX, { size: 16 });
    $[10] = t5;
  } else {
    t5 = $[10];
  }
  let t6;
  if ($[11] !== onClose) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { onClick: onClose, children: t5 });
    $[11] = onClose;
    $[12] = t6;
  } else {
    t6 = $[12];
  }
  let t7;
  if ($[13] !== t4 || $[14] !== t6) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes$3.header, children: [
      t4,
      t6
    ] });
    $[13] = t4;
    $[14] = t6;
    $[15] = t7;
  } else {
    t7 = $[15];
  }
  let t8;
  if ($[16] !== displayName || $[17] !== t) {
    t8 = t("CustomLinks.deleteModal.message", {
      name: displayName
    });
    $[16] = displayName;
    $[17] = t;
    $[18] = t8;
  } else {
    t8 = $[18];
  }
  let t9;
  if ($[19] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classes$3.body, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "sm", c: "dimmed", children: t8 }) });
    $[19] = t8;
    $[20] = t9;
  } else {
    t9 = $[20];
  }
  let t10;
  if ($[21] !== t) {
    t10 = t("CustomLinks.deleteModal.confirmButton");
    $[21] = t;
    $[22] = t10;
  } else {
    t10 = $[22];
  }
  let t11;
  if ($[23] !== handleConfirm || $[24] !== t10) {
    t11 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { fullWidth: true, size: "sm", radius: 8, color: "red", onClick: handleConfirm, children: t10 });
    $[23] = handleConfirm;
    $[24] = t10;
    $[25] = t11;
  } else {
    t11 = $[25];
  }
  let t12;
  if ($[26] !== t) {
    t12 = t("CustomLinks.deleteModal.cancelButton");
    $[26] = t;
    $[27] = t12;
  } else {
    t12 = $[27];
  }
  let t13;
  if ($[28] !== onClose || $[29] !== t12) {
    t13 = /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { fullWidth: true, size: "sm", color: "grey", radius: 8, variant: "light", onClick: onClose, children: t12 });
    $[28] = onClose;
    $[29] = t12;
    $[30] = t13;
  } else {
    t13 = $[30];
  }
  let t14;
  if ($[31] !== t11 || $[32] !== t13) {
    t14 = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes$3.footer, children: [
      t11,
      t13
    ] });
    $[31] = t11;
    $[32] = t13;
    $[33] = t14;
  } else {
    t14 = $[33];
  }
  let t15;
  if ($[34] !== t14 || $[35] !== t7 || $[36] !== t9) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes$3.container, children: [
      t7,
      t9,
      t14
    ] });
    $[34] = t14;
    $[35] = t7;
    $[36] = t9;
    $[37] = t15;
  } else {
    t15 = $[37];
  }
  return t15;
};
const ActionsCell = (t0) => {
  const $ = compilerRuntimeExports.c(13);
  const {
    item,
    onEdit,
    onDelete
  } = t0;
  const canDelete = item.tailType === TailType.Link;
  let t1;
  if ($[0] !== item || $[1] !== onEdit) {
    t1 = () => onEdit(item);
    $[0] = item;
    $[1] = onEdit;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  let t2;
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx(IconPencil, { size: 18 });
    $[3] = t2;
  } else {
    t2 = $[3];
  }
  let t3;
  if ($[4] !== t1) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { variant: "subtle", color: "gray", onClick: t1, "aria-label": "Edit", children: t2 });
    $[4] = t1;
    $[5] = t3;
  } else {
    t3 = $[5];
  }
  let t4;
  if ($[6] !== canDelete || $[7] !== item || $[8] !== onDelete) {
    t4 = canDelete && /* @__PURE__ */ jsxRuntimeExports.jsx(PopUpUI, { mobileSize: "100%", desktopPosition: "top-end", trigger: _temp$2, children: (t52) => {
      const {
        isOpen,
        setIsOpen: setIsOpen_0
      } = t52;
      return /* @__PURE__ */ jsxRuntimeExports.jsx(DeleteCustomLinkModal, { isOpen, setIsOpen: setIsOpen_0, link: item, onConfirm: onDelete });
    } });
    $[6] = canDelete;
    $[7] = item;
    $[8] = onDelete;
    $[9] = t4;
  } else {
    t4 = $[9];
  }
  let t5;
  if ($[10] !== t3 || $[11] !== t4) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(Table.Td, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { gap: "xs", justify: "flex-end", wrap: "nowrap", children: [
      t3,
      t4
    ] }) });
    $[10] = t3;
    $[11] = t4;
    $[12] = t5;
  } else {
    t5 = $[12];
  }
  return t5;
};
function _temp$2(t0) {
  const {
    setIsOpen
  } = t0;
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { variant: "subtle", color: "red", onClick: () => setIsOpen(true), "aria-label": "Delete", children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconTrash, { size: 18 }) });
}
const dragCell = "_dragCell_18s96_1";
const classes$2 = {
  dragCell
};
const DragCell = () => {
  const $ = compilerRuntimeExports.c(1);
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classes$2.dragCell, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconGripVertical, { size: 20, color: "#667085", style: {
      cursor: "grab"
    } }) });
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  return t0;
};
const scrollWrapper = "_scrollWrapper_1gigi_1";
const cell = "_cell_1gigi_5";
const row = "_row_1gigi_16";
const dragging = "_dragging_1gigi_23";
const dragOver = "_dragOver_1gigi_32";
const classes$1 = {
  scrollWrapper,
  cell,
  row,
  dragging,
  dragOver
};
const RulesTable = (props) => {
  const $ = compilerRuntimeExports.c(28);
  const {
    t
  } = useTranslation();
  const {
    items,
    onEdit,
    onDelete,
    onReorder
  } = props;
  const [draggedIndex, setDraggedIndex] = reactExports.useState(null);
  const dragOverIndexRef = reactExports.useRef(null);
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = (index) => (e) => {
      setDraggedIndex(index);
      e.dataTransfer.effectAllowed = "move";
      e.dataTransfer.setData("text/plain", String(index));
      const target = e.currentTarget;
      requestAnimationFrame(() => {
        target.classList.add(classes$1.dragging);
      });
    };
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  const handleDragStart = t0;
  const handleDragOver = (index_0) => (e_0) => {
    e_0.preventDefault();
    e_0.stopPropagation();
    if (draggedIndex === null || draggedIndex === index_0) {
      return;
    }
    dragOverIndexRef.current = index_0;
    e_0.currentTarget.classList.add(classes$1.dragOver);
  };
  const handleDragLeave = _temp$1;
  const handleDrop = (dropIndex) => (e_2) => {
    e_2.preventDefault();
    e_2.stopPropagation();
    e_2.currentTarget.classList.remove(classes$1.dragOver);
    if (draggedIndex === null || draggedIndex === dropIndex) {
      setDraggedIndex(null);
      dragOverIndexRef.current = null;
      return;
    }
    const reorderedItems = Array.from(items);
    const [removed] = reorderedItems.splice(draggedIndex, 1);
    reorderedItems.splice(dropIndex, 0, removed);
    const updatedItems = reorderedItems.map(_temp2);
    onReorder(updatedItems);
    setDraggedIndex(null);
    dragOverIndexRef.current = null;
  };
  const handleDragEnd = (e_3) => {
    e_3.currentTarget.classList.remove(classes$1.dragging);
    document.querySelectorAll(`.${classes$1.dragOver}`).forEach(_temp3);
    setDraggedIndex(null);
    dragOverIndexRef.current = null;
  };
  const t1 = classes$1;
  const T0 = Table;
  let t2;
  let t3;
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
    t2 = {
      tableLayout: "fixed",
      width: "100%"
    };
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsxs("colgroup", { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx("col", { style: {
        width: "40px"
      } }),
      /* @__PURE__ */ jsxRuntimeExports.jsx("col", { style: {
        width: "auto"
      } }),
      /* @__PURE__ */ jsxRuntimeExports.jsx("col", { style: {
        width: "160px"
      } }),
      /* @__PURE__ */ jsxRuntimeExports.jsx("col", { style: {
        width: "100px"
      } })
    ] });
    $[1] = t2;
    $[2] = t3;
  } else {
    t2 = $[1];
    t3 = $[2];
  }
  let t4;
  if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsx(Table.Th, { className: classes$1.cell });
    $[3] = t4;
  } else {
    t4 = $[3];
  }
  let t5;
  if ($[4] !== t) {
    t5 = t("CustomLinks.table.name");
    $[4] = t;
    $[5] = t5;
  } else {
    t5 = $[5];
  }
  let t6;
  if ($[6] !== t5) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(Table.Th, { className: classes$1.cell, children: t5 });
    $[6] = t5;
    $[7] = t6;
  } else {
    t6 = $[7];
  }
  let t7;
  if ($[8] !== t) {
    t7 = t("CustomLinks.table.type");
    $[8] = t;
    $[9] = t7;
  } else {
    t7 = $[9];
  }
  let t8;
  if ($[10] !== t7) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(Table.Th, { className: classes$1.cell, children: t7 });
    $[10] = t7;
    $[11] = t8;
  } else {
    t8 = $[11];
  }
  let t9;
  if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx(Table.Th, { className: classes$1.cell });
    $[12] = t9;
  } else {
    t9 = $[12];
  }
  let t10;
  if ($[13] !== t6 || $[14] !== t8) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsx(Table.Thead, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Table.Tr, { children: [
      t4,
      t6,
      t8,
      t9
    ] }) });
    $[13] = t6;
    $[14] = t8;
    $[15] = t10;
  } else {
    t10 = $[15];
  }
  const t11 = Table;
  const t12 = items.map((item_0, index_2) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Table.Tr, { draggable: true, onDragStart: handleDragStart(index_2), onDragOver: handleDragOver(index_2), onDragLeave: handleDragLeave, onDrop: handleDrop(index_2), onDragEnd: handleDragEnd, className: classes$1.row, children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(Table.Td, { className: classes$1.cell, children: /* @__PURE__ */ jsxRuntimeExports.jsx(DragCell, {}) }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(NameCell, { item: item_0 }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(TypeCell, { item: item_0 }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(ActionsCell, { item: item_0, onEdit, onDelete })
  ] }, item_0.id));
  let t13;
  if ($[16] !== t11.Tbody || $[17] !== t12) {
    t13 = /* @__PURE__ */ jsxRuntimeExports.jsx(t11.Tbody, { children: t12 });
    $[16] = t11.Tbody;
    $[17] = t12;
    $[18] = t13;
  } else {
    t13 = $[18];
  }
  let t14;
  if ($[19] !== T0 || $[20] !== t10 || $[21] !== t13 || $[22] !== t2 || $[23] !== t3) {
    t14 = /* @__PURE__ */ jsxRuntimeExports.jsxs(T0, { style: t2, children: [
      t3,
      t10,
      t13
    ] });
    $[19] = T0;
    $[20] = t10;
    $[21] = t13;
    $[22] = t2;
    $[23] = t3;
    $[24] = t14;
  } else {
    t14 = $[24];
  }
  let t15;
  if ($[25] !== t1.scrollWrapper || $[26] !== t14) {
    t15 = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: t1.scrollWrapper, children: t14 });
    $[25] = t1.scrollWrapper;
    $[26] = t14;
    $[27] = t15;
  } else {
    t15 = $[27];
  }
  return t15;
};
function _temp$1(e_1) {
  e_1.currentTarget.classList.remove(classes$1.dragOver);
}
function _temp2(item, index_1) {
  return {
    ...item,
    order: index_1 + 1
  };
}
function _temp3(el) {
  el.classList.remove(classes$1.dragOver);
}
const modalRoot = "_modalRoot_104x5_1";
const body = "_body_104x5_8";
const form = "_form_104x5_17";
const imagePreviewContainer = "_imagePreviewContainer_104x5_34";
const accessSection = "_accessSection_104x5_39";
const accessBlock = "_accessBlock_104x5_43";
const footer = "_footer_104x5_48";
const fullWidth = "_fullWidth_104x5_53";
const imagePreview = "_imagePreview_104x5_34";
const imagePreviewText = "_imagePreviewText_104x5_91";
const classes = {
  modalRoot,
  body,
  form,
  imagePreviewContainer,
  accessSection,
  accessBlock,
  footer,
  fullWidth,
  imagePreview,
  imagePreviewText
};
const teamIcon = "data:image/svg+xml,%3csvg%20width='60'%20height='60'%20viewBox='0%200%2060%2060'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1342_586)'%3e%3cpath%20d='M51.8747%200H8.12531C3.63782%200%200%203.63782%200%208.12531V51.8747C0%2056.3622%203.63782%2060%208.12531%2060H51.8747C56.3622%2060%2060%2056.3622%2060%2051.8747V8.12531C60%203.63782%2056.3622%200%2051.8747%200Z'%20fill='%23603997'/%3e%3cpath%20d='M38.9558%2024.7877V31.3692C38.9554%2031.4838%2038.9236%2031.5961%2038.8639%2031.694C38.8042%2031.7918%2038.7189%2031.8715%2038.6172%2031.9244C38.5155%2031.9772%2038.4013%2032.0013%2038.2869%2031.9939C38.1725%2031.9865%2038.0623%2031.948%2037.9682%2031.8825L35.2006%2029.9307V32.3216C35.2006%2032.6602%2035.0661%2032.9849%2034.8267%2033.2242C34.5873%2033.4636%2034.2627%2033.5981%2033.9241%2033.5981H24.4853C24.1467%2033.5981%2023.822%2033.4636%2023.5827%2033.2242C23.3433%2032.9849%2023.2088%2032.6602%2023.2088%2032.3216V23.8392C23.2088%2023.5006%2023.3433%2023.1759%2023.5827%2022.9366C23.822%2022.6972%2024.1467%2022.5627%2024.4853%2022.5627H33.9241C34.2627%2022.5627%2034.5873%2022.6972%2034.8267%2022.9366C35.0661%2023.1759%2035.2006%2023.5006%2035.2006%2023.8392V26.1813L37.9741%2024.2725C38.0681%2024.2078%2038.178%2024.17%2038.2919%2024.1631C38.4058%2024.1563%2038.5194%2024.1808%2038.6205%2024.2338C38.7215%2024.2868%2038.8062%2024.3665%2038.8653%2024.4641C38.9244%2024.5617%2038.9557%2024.6736%2038.9558%2024.7877ZM46.7357%2019.8458V36.3033C46.7357%2038.8152%2044.5887%2040.849%2041.9401%2040.849H22.6759L13.2722%2047.5319V19.8399C13.2722%2017.328%2015.4192%2015.2942%2018.0678%2015.2942H41.9401C44.5887%2015.2942%2046.7357%2017.328%2046.7357%2019.8399V19.8458ZM44.2354%2019.8458C44.2354%2018.7177%2043.2068%2017.8003%2041.9401%2017.8003H18.06C16.7952%2017.8003%2015.7647%2018.7177%2015.7647%2019.8458V42.6896L21.2297%2038.8094L21.8796%2038.3468H41.9401C43.2068%2038.3468%2044.2354%2037.4295%2044.2354%2036.3013V19.8458Z'%20fill='white'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1342_586'%3e%3crect%20width='60'%20height='60'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";
const linkIcon = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='icon%20icon-tabler%20icons-tabler-outline%20icon-tabler-link'%3e%3cpath%20stroke='none'%20d='M0%200h24v24H0z'%20fill='none'/%3e%3cpath%20d='M9%2015l6%20-6'%20/%3e%3cpath%20d='M11%206l.463%20-.536a5%205%200%200%201%207.071%207.072l-.534%20.464'%20/%3e%3cpath%20d='M13%2018l-.397%20.534a5.068%205.068%200%200%201%20-7.127%200a4.972%204.972%200%200%201%200%20-7.071l.524%20-.463'%20/%3e%3c/svg%3e";
const UserOptionWithAvatar = (props) => {
  const $ = compilerRuntimeExports.c(34);
  const {
    item,
    values
  } = props;
  let T0;
  let T1;
  let T2;
  let t0;
  let t1;
  let t2;
  let t3;
  let t4;
  let t5;
  let user;
  if ($[0] !== item || $[1] !== values) {
    const valuesIds = values.map(_temp);
    user = item.entity;
    T2 = Combobox.Option;
    if ($[12] !== item.value) {
      t3 = item.value.toString();
      $[12] = item.value;
      $[13] = t3;
    } else {
      t3 = $[13];
    }
    t4 = item.value;
    t5 = values.includes(item);
    T1 = Group;
    t2 = "sm";
    T0 = Checkbox;
    t0 = true;
    t1 = valuesIds.includes(item.value);
    $[0] = item;
    $[1] = values;
    $[2] = T0;
    $[3] = T1;
    $[4] = T2;
    $[5] = t0;
    $[6] = t1;
    $[7] = t2;
    $[8] = t3;
    $[9] = t4;
    $[10] = t5;
    $[11] = user;
  } else {
    T0 = $[2];
    T1 = $[3];
    T2 = $[4];
    t0 = $[5];
    t1 = $[6];
    t2 = $[7];
    t3 = $[8];
    t4 = $[9];
    t5 = $[10];
    user = $[11];
  }
  let t6;
  if ($[14] !== T0 || $[15] !== t0 || $[16] !== t1) {
    t6 = /* @__PURE__ */ jsxRuntimeExports.jsx(T0, { readOnly: t0, checked: t1, size: "xs" });
    $[14] = T0;
    $[15] = t0;
    $[16] = t1;
    $[17] = t6;
  } else {
    t6 = $[17];
  }
  let t7;
  if ($[18] !== user) {
    t7 = user && /* @__PURE__ */ jsxRuntimeExports.jsx(UserAvatarWithCard, { hoverCardProps: {
      zIndex: 2e3
    }, size: 32, src: user.Avatar, user, notClickable: true });
    $[18] = user;
    $[19] = t7;
  } else {
    t7 = $[19];
  }
  let t8;
  if ($[20] !== item.label) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.label });
    $[20] = item.label;
    $[21] = t8;
  } else {
    t8 = $[21];
  }
  let t9;
  if ($[22] !== T1 || $[23] !== t2 || $[24] !== t6 || $[25] !== t7 || $[26] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsxs(T1, { gap: t2, children: [
      t6,
      t7,
      t8
    ] });
    $[22] = T1;
    $[23] = t2;
    $[24] = t6;
    $[25] = t7;
    $[26] = t8;
    $[27] = t9;
  } else {
    t9 = $[27];
  }
  let t10;
  if ($[28] !== T2 || $[29] !== t3 || $[30] !== t4 || $[31] !== t5 || $[32] !== t9) {
    t10 = /* @__PURE__ */ jsxRuntimeExports.jsx(T2, { value: t3, active: t5, children: t9 }, t4);
    $[28] = T2;
    $[29] = t3;
    $[30] = t4;
    $[31] = t5;
    $[32] = t9;
    $[33] = t10;
  } else {
    t10 = $[33];
  }
  return t10;
};
function _temp(value) {
  return value.value;
}
const UserPillWithAvatar = (props) => {
  const $ = compilerRuntimeExports.c(17);
  const {
    item,
    renderLabel,
    handleValueRemove
  } = props;
  const user = item.entity;
  let t0;
  if ($[0] !== handleValueRemove || $[1] !== item) {
    t0 = () => handleValueRemove(item);
    $[0] = handleValueRemove;
    $[1] = item;
    $[2] = t0;
  } else {
    t0 = $[2];
  }
  let t1;
  if ($[3] !== user) {
    t1 = user && /* @__PURE__ */ jsxRuntimeExports.jsx(UserAvatar, { size: 20, src: user.Avatar, user, notClickable: true });
    $[3] = user;
    $[4] = t1;
  } else {
    t1 = $[4];
  }
  let t2;
  if ($[5] !== item || $[6] !== renderLabel) {
    t2 = renderLabel ? renderLabel(item) : item.label;
    $[5] = item;
    $[6] = renderLabel;
    $[7] = t2;
  } else {
    t2 = $[7];
  }
  let t3;
  if ($[8] !== t2) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: t2 });
    $[8] = t2;
    $[9] = t3;
  } else {
    t3 = $[9];
  }
  let t4;
  if ($[10] !== t1 || $[11] !== t3) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { gap: 6, wrap: "nowrap", children: [
      t1,
      t3
    ] });
    $[10] = t1;
    $[11] = t3;
    $[12] = t4;
  } else {
    t4 = $[12];
  }
  let t5;
  if ($[13] !== item.value || $[14] !== t0 || $[15] !== t4) {
    t5 = /* @__PURE__ */ jsxRuntimeExports.jsx(Pill, { withRemoveButton: true, onRemove: t0, children: t4 }, item.value);
    $[13] = item.value;
    $[14] = t0;
    $[15] = t4;
    $[16] = t5;
  } else {
    t5 = $[16];
  }
  return t5;
};
const TITLE_MAX_LENGTH = 70;
const TITLE_WARN_LENGTH = 50;
const AVAILABLE_MODULES = [{
  value: "link",
  label: "filials.link",
  icon: linkIcon
}, {
  value: "team",
  label: "filials.teams",
  icon: teamIcon
}, {
  value: Modules.Mail,
  label: "filials.mail",
  icon: mailIcon
}, {
  value: Modules.Calendar,
  label: "filials.calendar",
  icon: calendarIcon
}, {
  value: Modules.Draw,
  label: "filials.draw",
  icon: drawIcon
}, {
  value: Modules.Contacts,
  label: "filials.contacts",
  icon: contactsIcon
}, {
  value: Modules.Projects,
  label: "filials.projects",
  icon: projectsIcon
}, {
  value: Modules.Pages,
  label: "filials.pages",
  icon: pagesIcon
}, {
  value: Modules.Forms,
  label: "filials.forms",
  icon: formsIcon
}];
const CustomLinkModal = ({
  link,
  initialGroups,
  initialUsers,
  onSuccess,
  onClose
}) => {
  const {
    t
  } = useTranslation();
  const renderSelectOption = ({
    option
  }) => {
    const module = AVAILABLE_MODULES.find((m) => String(m.value) === option.value);
    return /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { gap: "sm", align: "center", children: [
      (module == null ? void 0 : module.icon) && /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: module.icon, alt: "", style: {
        width: 20,
        height: 20
      } }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { children: option.label })
    ] });
  };
  const {
    filial
  } = useAppSelector((state) => state.filials);
  const modules = useAppSelector((state_0) => {
    var _a;
    return (_a = state_0.userInfo.Settings) == null ? void 0 : _a.ModuleSettings;
  });
  const getModuleUrl = reactExports.useCallback((moduleName) => {
    if (!(modules == null ? void 0 : modules.ModuleUrls)) {
      return null;
    }
    const moduleMapping = {
      [Modules.Mail.toString()]: "Mail",
      [Modules.Calendar.toString()]: "Calendar",
      [Modules.Disk.toString()]: "Disk",
      [Modules.Draw.toString()]: "Draw",
      [Modules.Contacts.toString()]: "Contacts",
      [Modules.Projects.toString()]: "Projects",
      [Modules.Pages.toString()]: "Pages",
      [Modules.Forms.toString()]: "Forms",
      [Modules.Team.toString()]: "Team"
    };
    const systemModuleName = moduleMapping[moduleName];
    if (!systemModuleName) {
      return null;
    }
    const moduleUrl = modules.ModuleUrls.find((m_0) => m_0.Name === systemModuleName);
    return (moduleUrl == null ? void 0 : moduleUrl.Url) || null;
  }, [modules]);
  const [groups, setGroups] = reactExports.useState(initialGroups || []);
  const [users, setUsers] = reactExports.useState(initialUsers || []);
  const [uploadedImage, setUploadedImage] = reactExports.useState(null);
  const [imagePreview2, setImagePreview] = reactExports.useState((link == null ? void 0 : link.icon) || null);
  const [isSystemIcon, setIsSystemIcon] = reactExports.useState(false);
  const displayImageUrl = useImageUrl(imagePreview2);
  const [selectedModuleType, setSelectedModuleType] = reactExports.useState(() => {
    if (!link) return "link";
    if (link.tailType === TailType.Link) return "link";
    if (link.tailType === TailType.Integration) return "team";
    return link.module;
  });
  const [formData, setFormData] = reactExports.useState({
    url: (link == null ? void 0 : link.url) || "",
    titleRu: (link == null ? void 0 : link.titleRu) || "",
    titleEn: (link == null ? void 0 : link.titleEn) || ""
  });
  const [errors, setErrors] = reactExports.useState({
    module: "",
    titleRu: "",
    titleEn: "",
    icon: "",
    url: ""
  });
  const submitLabel = reactExports.useMemo(() => link ? t("CustomLinks.modal.updateButton") : t("CustomLinks.modal.saveButton"), [link, t]);
  const tailType = reactExports.useMemo(() => {
    if (selectedModuleType === "team") return TailType.Integration;
    if (selectedModuleType === "link") return TailType.Link;
    return TailType.Module;
  }, [selectedModuleType]);
  const moduleValue_0 = reactExports.useMemo(() => {
    if (typeof selectedModuleType === "number") return selectedModuleType;
    return Modules.None;
  }, [selectedModuleType]);
  const isEditingLocked = link && (link.tailType === TailType.Integration || link.tailType === TailType.Module);
  const availableModulesForSelect = reactExports.useMemo(() => {
    if (link) {
      let filterValue;
      if (link.tailType === TailType.Link) {
        filterValue = "link";
      } else if (link.tailType === TailType.Integration) {
        filterValue = "team";
      } else {
        filterValue = link.module;
      }
      return AVAILABLE_MODULES.filter((m_1) => m_1.value === filterValue);
    } else {
      return AVAILABLE_MODULES.filter((m_2) => m_2.value === "link");
    }
  }, [link]);
  const isUrlDisabled = typeof selectedModuleType === "number" || isEditingLocked;
  reactExports.useEffect(() => {
    const loadDefaultLinkIcon = async () => {
      if (!link && selectedModuleType === "link" && !imagePreview2) {
        const linkModule = AVAILABLE_MODULES.find((m_3) => m_3.value === "link");
        if (linkModule == null ? void 0 : linkModule.icon) {
          try {
            const response = await fetch(linkModule.icon);
            const blob = await response.blob();
            const reader = new FileReader();
            reader.onload = (e) => {
              var _a;
              const base64 = (_a = e.target) == null ? void 0 : _a.result;
              setImagePreview(base64);
              setIsSystemIcon(false);
            };
            reader.readAsDataURL(blob);
          } catch {
          }
        }
      }
    };
    void loadDefaultLinkIcon();
  }, [link, selectedModuleType, imagePreview2]);
  const renderCharCounter = (value) => {
    if (value.length <= TITLE_WARN_LENGTH) return null;
    const remaining = TITLE_MAX_LENGTH - value.length;
    return /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "xs", c: remaining <= 10 ? "red" : "orange", mt: 4, children: t("CustomLinks.modal.charsLeft", {
      count: remaining
    }) });
  };
  const validateForm = () => {
    const newErrors = {
      module: "",
      titleRu: "",
      titleEn: "",
      icon: "",
      url: ""
    };
    let isValid = true;
    if (!selectedModuleType) {
      newErrors.module = t("CustomLinks.modal.validation.moduleRequired");
      isValid = false;
    }
    if (!formData.titleRu.trim()) {
      newErrors.titleRu = t("CustomLinks.modal.validation.titleRuRequired");
      isValid = false;
    }
    if (!formData.titleEn.trim()) {
      newErrors.titleEn = t("CustomLinks.modal.validation.titleEnRequired");
      isValid = false;
    }
    if (formData.url && !isUrlDisabled && !/^https?:\/\/.+/.test(formData.url)) {
      newErrors.url = t("CustomLinks.modal.validation.invalidUrl");
      isValid = false;
    }
    if (!imagePreview2) {
      newErrors.icon = t("CustomLinks.modal.validation.iconRequired");
      isValid = false;
    } else if (tailType === TailType.Link && !link) {
      if (!imagePreview2.startsWith("data:")) {
        newErrors.icon = t("CustomLinks.modal.validation.iconRequired");
        isValid = false;
      }
    }
    setErrors(newErrors);
    return isValid;
  };
  const handleSubmit = () => {
    if (!validateForm()) {
      showNotification({
        title: t("CustomLinks.modal.errorTitle"),
        message: t("CustomLinks.modal.requiredFields"),
        color: "red"
      });
      return;
    }
    let iconValue = "";
    if (!isSystemIcon && (imagePreview2 == null ? void 0 : imagePreview2.startsWith("data:"))) {
      iconValue = imagePreview2;
    } else if ((link == null ? void 0 : link.icon) && link.icon.startsWith("/api/")) {
      iconValue = link.icon;
    } else if (!link) {
      iconValue = "";
    } else {
      iconValue = link.icon || "";
    }
    const linkData = {
      id: (link == null ? void 0 : link.id) || Date.now(),
      titleRu: formData.titleRu,
      titleEn: formData.titleEn,
      module: moduleValue_0,
      tailType,
      icon: iconValue,
      url: formData.url,
      order: (link == null ? void 0 : link.order) || 0
    };
    onSuccess(linkData, groups, users);
    onClose();
  };
  const handleRemoveImage = () => {
    setUploadedImage(null);
    setImagePreview(null);
  };
  const handleFieldChange = (field, value_0) => {
    setFormData((prev) => ({
      ...prev,
      [field]: value_0
    }));
    if (field === "titleRu") {
      setErrors((prev_0) => ({
        ...prev_0,
        titleRu: ""
      }));
    }
    if (field === "titleEn") {
      setErrors((prev_1) => ({
        ...prev_1,
        titleEn: ""
      }));
    }
    if (field === "url") {
      setErrors((prev_2) => ({
        ...prev_2,
        url: ""
      }));
    }
  };
  const handleModuleChange = async (value_1) => {
    if (!value_1) return;
    const parsedValue = isNaN(Number(value_1)) ? value_1 : parseInt(value_1);
    setSelectedModuleType(parsedValue);
    setErrors((prev_3) => ({
      ...prev_3,
      module: ""
    }));
    const module_0 = AVAILABLE_MODULES.find((m_4) => {
      if (typeof m_4.value === "string") return m_4.value === parsedValue;
      return m_4.value === parsedValue;
    });
    if (module_0) {
      if (parsedValue === "link") {
        setImagePreview(null);
        setIsSystemIcon(false);
        setFormData((prev_4) => ({
          ...prev_4,
          url: ""
        }));
        return;
      }
      if (parsedValue === "team") {
        setFormData((prev_5) => ({
          ...prev_5,
          url: ""
        }));
      } else if (typeof parsedValue === "number") {
        const moduleUrl_0 = getModuleUrl(String(parsedValue));
        if (moduleUrl_0) {
          setFormData((prev_6) => ({
            ...prev_6,
            url: moduleUrl_0
          }));
        }
      }
      try {
        const response_0 = await fetch(module_0.icon);
        const blob_0 = await response_0.blob();
        const reader_0 = new FileReader();
        reader_0.onload = (e_0) => {
          var _a;
          const base64_0 = (_a = e_0.target) == null ? void 0 : _a.result;
          setImagePreview(base64_0);
          setIsSystemIcon(true);
          setErrors((prev_8) => ({
            ...prev_8,
            icon: ""
          }));
        };
        reader_0.readAsDataURL(blob_0);
      } catch (error) {
        setImagePreview(module_0.icon);
        setIsSystemIcon(true);
        setErrors((prev_7) => ({
          ...prev_7,
          icon: ""
        }));
      }
    }
  };
  const handleFileChange = async (file) => {
    if (!file) {
      setUploadedImage(null);
      setImagePreview(null);
      return;
    }
    const validTypes = ["image/png", "image/jpeg", "image/svg+xml"];
    if (!validTypes.includes(file.type)) {
      showNotification({
        title: t("CustomLinks.modal.errorTitle"),
        message: t("CustomLinks.modal.invalidImageFormat"),
        color: "red"
      });
      return;
    }
    if (file.type === "image/svg+xml") {
      const reader_1 = new FileReader();
      reader_1.onload = (e_1) => {
        var _a;
        const result = (_a = e_1.target) == null ? void 0 : _a.result;
        setUploadedImage(file);
        setImagePreview(result);
        setIsSystemIcon(false);
        setErrors((prev_9) => ({
          ...prev_9,
          icon: ""
        }));
      };
      reader_1.onerror = () => {
      };
      reader_1.readAsDataURL(file);
      return;
    }
    const img = new Image();
    const objectUrl = URL.createObjectURL(file);
    img.onload = () => {
      const {
        width,
        height
      } = img;
      URL.revokeObjectURL(objectUrl);
      if (width < 24 || height < 24 || width > 512 || height > 512) {
        showNotification({
          title: t("CustomLinks.modal.errorTitle"),
          message: t("CustomLinks.modal.invalidImageSize"),
          color: "red"
        });
        return;
      }
      setUploadedImage(file);
      const reader_2 = new FileReader();
      reader_2.onload = (e_2) => {
        var _a;
        const result_0 = (_a = e_2.target) == null ? void 0 : _a.result;
        setImagePreview(result_0);
        setIsSystemIcon(false);
        setErrors((prev_10) => ({
          ...prev_10,
          icon: ""
        }));
      };
      reader_2.onerror = () => {
      };
      reader_2.readAsDataURL(file);
    };
    img.onerror = () => {
      URL.revokeObjectURL(objectUrl);
      showNotification({
        title: t("CustomLinks.modal.errorTitle"),
        message: t("CustomLinks.modal.invalidImage"),
        color: "red"
      });
    };
    img.src = objectUrl;
  };
  const groupsLoader = reactExports.useCallback(async (query) => {
    const paramsToRequest = {
      Query: query,
      Count: 15,
      Size: 15,
      SortOrder: 0,
      Offset: 0,
      FilterConditions: filial ? [{
        Type: IFiltersEnumType.FilialFilter,
        NumValues: [filial.Id]
      }] : [],
      Filters: {},
      SkipIds: [],
      SortField: 0
    };
    try {
      const {
        data
      } = await axiosInstance.post("v2/roles/list", paramsToRequest);
      const groups_0 = data.Response.Data.Items;
      return groups_0;
    } catch (e_3) {
      return [];
    }
  }, [filial == null ? void 0 : filial.Id]);
  const usersLoader = reactExports.useCallback(async (query_0) => {
    const paramsToRequest_0 = {
      Query: query_0,
      SortOrder: 0,
      SortOrderField: "Email",
      Size: 15,
      Offset: 0
    };
    try {
      const res = await axiosInstance.post("v1/User/search", paramsToRequest_0);
      const users_0 = res.data;
      return users_0;
    } catch (e_4) {
      return [];
    }
  }, []);
  const handleGroupsChange = reactExports.useCallback((items) => {
    const mappedGroups = items.map((item) => item.entity).filter((entity) => entity !== void 0);
    setGroups(mappedGroups);
  }, []);
  const handleUsersChange = reactExports.useCallback((items_0) => {
    const mappedUsers = items_0.map((item_0) => item_0.entity).filter((entity_0) => entity_0 !== void 0);
    setUsers(mappedUsers);
  }, []);
  const handleMapGroupsToOptions = reactExports.useCallback((item_1) => {
    const option_0 = {
      label: item_1.Name,
      value: item_1.Id,
      entity: item_1
    };
    return option_0;
  }, []);
  const handleMapUsersToOptions = reactExports.useCallback((item_2) => {
    const option_1 = {
      label: item_2.Email || `${item_2.FirstName || ""} ${item_2.Surname || ""}`.trim(),
      value: item_2.Id,
      entity: item_2
    };
    return option_1;
  }, []);
  const initialGroupOptions = reactExports.useMemo(() => (initialGroups || []).map(handleMapGroupsToOptions), []);
  const initialUserOptions = reactExports.useMemo(() => (initialUsers || []).map(handleMapUsersToOptions), []);
  const [isAccessible] = reactExports.useState((link == null ? void 0 : link.module) === Modules.Admin || (link == null ? void 0 : link.module) === Modules.Disk || (link == null ? void 0 : link.module) === Modules.Team);
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.modalRoot, children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes.body, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes.form, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { comboboxProps: {
          withinPortal: true,
          zIndex: 1400
        }, label: t("CustomLinks.modal.module"), placeholder: t("CustomLinks.modal.modulePlaceholder"), rightSection: /* @__PURE__ */ jsxRuntimeExports.jsx(IconChevronDown, { size: "1rem", color: "#98A2B3" }), data: availableModulesForSelect.map((module_1) => ({
          value: String(module_1.value),
          label: t(module_1.label)
        })), value: selectedModuleType !== null ? String(selectedModuleType) : null, onChange: handleModuleChange, error: errors.module, withAsterisk: true, disabled: !!link, renderOption: renderSelectOption }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(TextInput, { label: t("CustomLinks.modal.ruName"), placeholder: t("CustomLinks.modal.namePlaceholder"), value: formData.titleRu, onChange: (e_5) => handleFieldChange("titleRu", e_5.currentTarget.value), error: errors.titleRu, maxLength: TITLE_MAX_LENGTH, withAsterisk: true, disabled: isEditingLocked }),
          renderCharCounter(formData.titleRu)
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(TextInput, { label: t("CustomLinks.modal.enName"), placeholder: t("CustomLinks.modal.namePlaceholder"), value: formData.titleEn, onChange: (e_6) => handleFieldChange("titleEn", e_6.currentTarget.value), error: errors.titleEn, maxLength: TITLE_MAX_LENGTH, withAsterisk: true, disabled: isEditingLocked }),
          renderCharCounter(formData.titleEn)
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(TextInput, { label: t("CustomLinks.modal.url"), placeholder: t("CustomLinks.modal.urlPlaceholder"), value: formData.url, onChange: (e_7) => handleFieldChange("url", e_7.currentTarget.value), error: errors.url, disabled: isUrlDisabled }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { size: "sm", fw: 500, mb: 4, children: [
            t("CustomLinks.modal.icon"),
            /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { component: "span", c: "red", ml: 4, children: "*" })
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(FileButton, { onChange: handleFileChange, accept: "image/png,image/jpeg,image/svg+xml", disabled: isEditingLocked, children: (props) => /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { ...props, variant: "outline", color: imagePreview2 ? "green" : "gray", size: "sm", fullWidth: true, disabled: isEditingLocked, children: t("CustomLinks.modal.uploadImage") }) }),
          errors.icon && /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "xs", c: "red", mt: 4, children: errors.icon })
        ] }),
        imagePreview2 && /* @__PURE__ */ jsxRuntimeExports.jsxs(Box, { className: classes.imagePreviewContainer, children: [
          displayImageUrl ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: displayImageUrl, alt: "Preview", className: classes.imagePreview }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Box, { className: classes.imagePreview, style: {
            display: "flex",
            alignItems: "center",
            justifyContent: "center"
          }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { size: "sm" }) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "sm", c: "dimmed", className: classes.imagePreviewText, children: (uploadedImage == null ? void 0 : uploadedImage.name) || (isSystemIcon ? t("CustomLinks.modal.systemIcon") : "") }),
          !isEditingLocked && /* @__PURE__ */ jsxRuntimeExports.jsx(ActionIcon, { size: "sm", variant: "subtle", color: "gray", onClick: handleRemoveImage, title: t("delete"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconX, { size: 16 }) })
        ] })
      ] }),
      !isAccessible && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classes.fullWidth, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes.accessSection, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "md", fw: 600, mb: 8, children: t("CustomLinks.modal.accessTitle") }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "sm", c: "dimmed", mb: 16, children: t("CustomLinks.modal.accessDescription") }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes.accessBlock, children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "sm", fw: 500, mb: 8, children: t("CustomLinks.modal.addGroup") }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(PillsInputAutoCompleteWithQuery, { loaderData: groupsLoader, onValueChange: handleGroupsChange, defaultValues: initialGroupOptions, mapDataToOptions: handleMapGroupsToOptions, props: {
            PillsInputFieldProps: {
              placeholder: t("CustomLinks.modal.groupPlaceholder")
            },
            ComboboxDropdownProps: {
              style: {
                maxHeight: "250px",
                overflowY: "auto"
              }
            }
          } })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes.accessBlock, children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "sm", fw: 500, mb: 8, children: t("CustomLinks.modal.addUser") }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(PillsInputAutoCompleteWithQuery, { loaderData: usersLoader, onValueChange: handleUsersChange, defaultValues: initialUserOptions, mapDataToOptions: handleMapUsersToOptions, RenderOption: UserOptionWithAvatar, RenderPill: UserPillWithAvatar, props: {
            PillsInputFieldProps: {
              placeholder: t("CustomLinks.modal.userPlaceholder")
            },
            ComboboxDropdownProps: {
              style: {
                maxHeight: "250px",
                overflowY: "auto"
              }
            }
          } })
        ] })
      ] }) })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { justify: "space-between", gap: 12, p: "16px 34px", w: "100%", className: classes.footer, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { fullWidth: true, size: "sm", radius: 8, onClick: handleSubmit, children: submitLabel }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { fullWidth: true, size: "sm", color: "grey", radius: 8, variant: "light", onClick: onClose, children: t("CustomLinks.modal.cancelButton") })
    ] })
  ] });
};
class MenuTailsService {
  async GetMenuTails(customerId) {
    var _a;
    try {
      const {
        data
      } = await axiosInstance.get("v2/MenuTails", {
        params: {
          customerId
        }
      });
      const menuTails = ((_a = data.Response) == null ? void 0 : _a.map((item) => item.Data)) || [];
      return {
        data: menuTails
      };
    } catch (e) {
      throw new Error("Unable to fetch menu tails. Please try again later.");
    }
  }
  async GetMenuTail(id) {
    var _a;
    try {
      const {
        data
      } = await axiosInstance.get(`v2/MenuTails/${id}`);
      return {
        data: (_a = data.Response) == null ? void 0 : _a.Data
      };
    } catch (e) {
      throw new Error("Unable to fetch menu tail. Please try again later.");
    }
  }
  async CreateMenuTail(params) {
    var _a;
    try {
      const {
        data
      } = await axiosInstance.post("v2/MenuTails", params);
      return {
        data: (_a = data.Response) == null ? void 0 : _a.Data
      };
    } catch (e) {
      throw new Error("Unable to create menu tail. Please try again later.");
    }
  }
  async UpdateMenuTail(id, params) {
    var _a;
    try {
      const {
        data
      } = await axiosInstance.patch(`v2/MenuTails/${id}`, params);
      return {
        data: (_a = data.Response) == null ? void 0 : _a.Data
      };
    } catch (e) {
      throw new Error("Unable to update menu tail. Please try again later.");
    }
  }
  async UpdateOrders(orders) {
    try {
      const {
        status
      } = await axiosInstance.post("v2/MenuTails/orders", orders);
      return {
        success: status === 204 || status === 200
      };
    } catch (e) {
      throw new Error("Unable to update menu tail orders. Please try again later.");
    }
  }
  async GetAccess(id) {
    var _a;
    try {
      const {
        data
      } = await axiosInstance.get(`v2/MenuTails/${id}/access`);
      return {
        data: (_a = data.Response) == null ? void 0 : _a.Data
      };
    } catch (e) {
      throw new Error("Unable to fetch menu tail access rights. Please try again later.");
    }
  }
  async GrantAccess(id, params) {
    try {
      const {
        status
      } = await axiosInstance.post(`v2/MenuTails/${id}/access`, params);
      return {
        success: status === 204 || status === 200
      };
    } catch (e) {
      throw new Error("Unable to grant menu tail access. Please try again later.");
    }
  }
  async RevokeAccess(id, params) {
    try {
      const {
        status
      } = await axiosInstance.delete(`v2/MenuTails/${id}/access`, {
        data: params
      });
      return {
        success: status === 204 || status === 200
      };
    } catch (e) {
      throw new Error("Unable to revoke menu tail access. Please try again later.");
    }
  }
  async DeleteMenuTail(id) {
    try {
      const {
        status
      } = await axiosInstance.delete(`v2/MenuTails/${id}`);
      return {
        success: status === 204 || status === 200
      };
    } catch (e) {
      throw new Error("Unable to delete menu tail. Please try again later.");
    }
  }
}
const menuTailsApiArea = () => new MenuTailsService();
const normalizeIconUrl = (iconUrl) => {
  if (!iconUrl) return "";
  if (iconUrl.startsWith("http://") || iconUrl.startsWith("https://") || iconUrl.startsWith("data:")) {
    return iconUrl;
  }
  return iconUrl.startsWith("/") ? iconUrl : `/${iconUrl}`;
};
const CustomLinks = () => {
  const {
    t
  } = useTranslation();
  const {
    filial
  } = useAppSelector((state) => state.filials);
  const currentUser = useAppSelector((state_0) => state_0.userInfo.User);
  const isSaas = (currentUser == null ? void 0 : currentUser.isSaas) || false;
  const {
    isMobile,
    isTablet
  } = useGetDeviceType();
  const [allItems, setAllItems] = reactExports.useState([]);
  const [items, setItems] = reactExports.useState([]);
  const [editingLink, setEditingLink] = reactExports.useState(null);
  const [editingAccess, setEditingAccess] = reactExports.useState(null);
  const [modalOpened, setModalOpened] = reactExports.useState(false);
  const [loading, setLoading] = reactExports.useState(true);
  const getModalSize = () => {
    if (isMobile) return "95%";
    if (isTablet) return "90%";
    return "700px";
  };
  reactExports.useEffect(() => {
    const loadMenuTails = async () => {
      if (!(filial == null ? void 0 : filial.Id)) return;
      try {
        setLoading(true);
        const response = await menuTailsApiArea().GetMenuTails(filial.Id);
        const allLinks = response.data.map((item, index) => {
          const iconFileId = item.IconUrl ? parseInt(item.IconUrl.split("id=")[1]) : void 0;
          return {
            id: item.Id,
            titleRu: item.TitleRu,
            titleEn: item.TitleEn,
            tailType: item.TailType,
            module: item.Modules,
            icon: normalizeIconUrl(item.IconUrl),
            iconFileId,
            url: "",
            // URL is not provided in MenuTailShortModel, will be loaded on edit
            order: index + 1
            // Order starts from 1 to match backend expectation
          };
        });
        setAllItems(allLinks);
        const visibleLinks = isSaas ? allLinks : allLinks.filter((link) => link.module !== Modules.Payments);
        setItems(visibleLinks);
      } catch (error) {
        showNotification({
          title: t("CustomLinks.modal.errorTitle"),
          message: t("CustomLinks.errors.loadFailed"),
          color: "red"
        });
      } finally {
        setLoading(false);
      }
    };
    loadMenuTails();
  }, [filial == null ? void 0 : filial.Id, isSaas, t]);
  const handleEdit = async (item_0) => {
    var _a, _b;
    try {
      const [menuTailResponse, accessResponse] = await Promise.all([menuTailsApiArea().GetMenuTail(item_0.id), menuTailsApiArea().GetAccess(item_0.id).catch(() => ({
        data: {
          Roles: [],
          Users: []
        }
      }))]);
      const fullData = menuTailResponse.data;
      const accessData = accessResponse.data;
      const iconFileId_0 = fullData.IconUrl ? parseInt(fullData.IconUrl.split("id=")[1]) : void 0;
      const editingData = {
        id: fullData.Id,
        titleRu: fullData.TitleRu,
        titleEn: fullData.TitleEn,
        tailType: fullData.TailType,
        module: fullData.Module,
        icon: normalizeIconUrl(fullData.IconUrl),
        iconFileId: iconFileId_0,
        url: fullData.RedirectUrl || "",
        order: fullData.Order
      };
      const groupIds = (accessData.Roles ?? []).map((r) => r.Id);
      const userIds = (accessData.Users ?? []).map((u) => u.Id);
      const [groupsData, usersData] = await Promise.all([groupIds.length > 0 ? axiosInstance.post("v2/roles/list", {
        Query: "",
        Count: 100,
        Size: 100,
        SortOrder: 0,
        Offset: 0,
        FilterConditions: filial ? [{
          Type: IFiltersEnumType.FilialFilter,
          NumValues: [filial.Id]
        }] : [],
        Filters: {},
        SkipIds: [],
        SortField: 0
      }).catch(() => {
        return {
          data: {
            Response: {
              Data: {
                Items: []
              }
            }
          }
        };
      }) : Promise.resolve({
        data: {
          Response: {
            Data: {
              Items: []
            }
          }
        }
      }), userIds.length > 0 ? axiosInstance.post("v1/User/get", {
        Ids: userIds
      }).catch(() => {
        return {
          data: []
        };
      }) : Promise.resolve({
        data: []
      })]);
      const groups = ((_b = (_a = groupsData.data.Response) == null ? void 0 : _a.Data) == null ? void 0 : _b.Items) || [];
      const filteredGroups = groups.filter((g) => groupIds.includes(g.Id));
      const filteredUsers = usersData.data || [];
      setEditingLink(editingData);
      setEditingAccess({
        groups: filteredGroups,
        users: filteredUsers
      });
      setModalOpened(true);
    } catch (error_0) {
      showNotification({
        title: t("CustomLinks.modal.errorTitle"),
        message: t("CustomLinks.errors.loadFailed"),
        color: "red"
      });
    }
  };
  const handleAddLink = () => {
    setEditingLink(null);
    setModalOpened(true);
  };
  const handleModalClose = () => {
    setModalOpened(false);
    setEditingLink(null);
    setEditingAccess(null);
  };
  const handleDelete = async (id) => {
    try {
      await menuTailsApiArea().DeleteMenuTail(Number(id));
      const newAllItems = allItems.filter((item_1) => item_1.id !== id);
      const newVisibleItems = items.filter((item_2) => item_2.id !== id);
      setAllItems(newAllItems);
      setItems(newVisibleItems);
      showNotification({
        title: t("success"),
        message: t("CustomLinks.notifications.deleteSuccess"),
        color: "green"
      });
    } catch (error_1) {
      showNotification({
        title: t("CustomLinks.modal.errorTitle"),
        message: t("CustomLinks.errors.deleteFailed"),
        color: "red"
      });
    }
  };
  const handleReorder = reactExports.useCallback((reorderedItems) => {
    setItems(reorderedItems);
    const visibleIds = new Set(reorderedItems.map((ri) => ri.id));
    const visiblePositions = [];
    allItems.forEach((item_3, index_0) => {
      if (visibleIds.has(item_3.id)) visiblePositions.push(index_0);
    });
    const newAllItems_0 = [...allItems];
    visiblePositions.forEach((pos, i) => {
      newAllItems_0[pos] = reorderedItems[i];
    });
    const finalAllItems = newAllItems_0.map((item_4, index_1) => ({
      ...item_4,
      order: index_1 + 1
    }));
    setAllItems(finalAllItems);
    const orders = finalAllItems.map((item_5) => ({
      TailId: item_5.id,
      Order: item_5.order
    }));
    menuTailsApiArea().UpdateOrders(orders).then(() => {
      showNotification({
        title: t("success"),
        message: t("CustomLinks.notifications.orderSuccess"),
        color: "green"
      });
    }).catch(() => {
      showNotification({
        title: t("CustomLinks.modal.errorTitle"),
        message: t("CustomLinks.errors.orderFailed"),
        color: "red"
      });
      if (filial == null ? void 0 : filial.Id) {
        menuTailsApiArea().GetMenuTails(filial.Id).then((response_0) => {
          const allLinks_0 = response_0.data.map((item_6, index_2) => {
            const iconFileId_1 = item_6.IconUrl ? parseInt(item_6.IconUrl.split("id=")[1]) : void 0;
            return {
              id: item_6.Id,
              titleRu: item_6.TitleRu,
              titleEn: item_6.TitleEn,
              tailType: item_6.TailType,
              module: item_6.Modules,
              icon: normalizeIconUrl(item_6.IconUrl),
              iconFileId: iconFileId_1,
              url: "",
              order: index_2 + 1
            };
          });
          setAllItems(allLinks_0);
          const visibleLinks_0 = isSaas ? allLinks_0 : allLinks_0.filter((link_0) => link_0.module !== Modules.Payments);
          setItems(visibleLinks_0);
        });
      }
    });
  }, [t, filial == null ? void 0 : filial.Id, isSaas, allItems]);
  const handleLinkSuccess = async (link_1, groups_0, users) => {
    try {
      let menuTailId;
      if (editingLink !== null) {
        menuTailId = editingLink.id;
        const isSystemIcon = link_1.icon === "";
        const iconChanged = link_1.icon && link_1.icon.startsWith("data:");
        const iconActuallyChanged = iconChanged || isSystemIcon && editingLink.icon !== "";
        const mainDataChanged = link_1.titleRu !== editingLink.titleRu || link_1.titleEn !== editingLink.titleEn || link_1.url !== editingLink.url || link_1.module !== editingLink.module || iconActuallyChanged;
        if (mainDataChanged) {
          const updateResponse = await menuTailsApiArea().UpdateMenuTail(editingLink.id, {
            TitleRu: link_1.titleRu,
            TitleEn: link_1.titleEn,
            CustomerId: filial == null ? void 0 : filial.Id,
            Url: link_1.url,
            Module: link_1.module,
            IconFileId: !iconChanged && !isSystemIcon ? editingLink.iconFileId : void 0,
            IconBase64: iconChanged ? link_1.icon : void 0
          });
          const updatedIconFileId = updateResponse.data.IconUrl ? parseInt(updateResponse.data.IconUrl.split("id=")[1]) : editingLink.iconFileId;
          const updatedLink = {
            ...link_1,
            id: editingLink.id,
            icon: normalizeIconUrl(updateResponse.data.IconUrl),
            iconFileId: updatedIconFileId
          };
          setAllItems(allItems.map((item_7) => item_7.id === editingLink.id ? updatedLink : item_7));
          setItems(items.map((item_8) => item_8.id === editingLink.id ? updatedLink : item_8));
        }
        const oldGroupIds = new Set(((editingAccess == null ? void 0 : editingAccess.groups) ?? []).map((g_0) => g_0.Id));
        const oldUserIds = new Set(((editingAccess == null ? void 0 : editingAccess.users) ?? []).map((u_0) => u_0.Id));
        const newGroupIds = new Set(groups_0.map((g_1) => g_1.Id));
        const newUserIds = new Set(users.map((u_1) => u_1.Id));
        const accessChanged = oldGroupIds.size !== newGroupIds.size || oldUserIds.size !== newUserIds.size || [...newGroupIds].some((id_1) => !oldGroupIds.has(id_1)) || [...newUserIds].some((id_0) => !oldUserIds.has(id_0));
        if (accessChanged) {
          const currentRoleIds = [...oldGroupIds];
          const currentUserIds = [...oldUserIds];
          try {
            if (currentRoleIds.length > 0 || currentUserIds.length > 0) {
              await menuTailsApiArea().RevokeAccess(menuTailId, {
                RoleIds: currentRoleIds,
                UserIds: currentUserIds
              });
            }
          } catch (error_3) {
          }
          const roleIds = groups_0.map((g_2) => g_2.Id);
          const userIds_0 = users.map((u_2) => u_2.Id);
          if (roleIds.length > 0 || userIds_0.length > 0) {
            await menuTailsApiArea().GrantAccess(menuTailId, {
              RoleIds: roleIds,
              UserIds: userIds_0,
              AccessType: AccessType.Read
            });
          }
        }
      } else {
        if (!(filial == null ? void 0 : filial.Id)) {
          throw new Error("Filial ID is required");
        }
        const isBase64Icon = link_1.icon && link_1.icon.trim() !== "" && link_1.icon.startsWith("data:");
        const response_1 = await menuTailsApiArea().CreateMenuTail({
          TitleRu: link_1.titleRu,
          TitleEn: link_1.titleEn,
          CustomerId: filial.Id,
          Url: link_1.url || "",
          Module: link_1.module,
          TailType: link_1.tailType,
          IconBase64: isBase64Icon ? link_1.icon : void 0
        });
        menuTailId = response_1.data.Id;
        const iconFileId_2 = response_1.data.IconUrl ? parseInt(response_1.data.IconUrl.split("id=")[1]) : void 0;
        const newLink = {
          id: response_1.data.Id,
          titleRu: link_1.titleRu,
          titleEn: link_1.titleEn,
          tailType: response_1.data.TailType,
          module: response_1.data.Module,
          icon: normalizeIconUrl(response_1.data.IconUrl),
          iconFileId: iconFileId_2,
          url: response_1.data.RedirectUrl,
          order: response_1.data.Order
        };
        setAllItems([...allItems, newLink]);
        setItems([...items, newLink]);
        const roleIds_0 = groups_0.map((g_3) => g_3.Id);
        const userIds_1 = users.map((u_3) => u_3.Id);
        if (roleIds_0.length > 0 || userIds_1.length > 0) {
          await menuTailsApiArea().GrantAccess(menuTailId, {
            RoleIds: roleIds_0,
            UserIds: userIds_1,
            AccessType: AccessType.Read
          });
        }
      }
      showNotification({
        title: t("success"),
        message: editingLink ? t("CustomLinks.notifications.updateSuccess") : t("CustomLinks.notifications.createSuccess"),
        color: "green"
      });
      handleModalClose();
    } catch (error_2) {
      showNotification({
        title: t("CustomLinks.modal.errorTitle"),
        message: t("CustomLinks.errors.saveFailed"),
        color: "red"
      });
    }
  };
  if (loading) {
    return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classes$4.container, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Center, { h: 200, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { size: "lg" }) }) });
  }
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes$4.container, children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: classes$4.title, children: t("CustomLinks.title") }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(RulesTable, { items, onEdit: handleEdit, onDelete: handleDelete, onReorder: handleReorder }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(AddButton, { onClick: handleAddLink, mt: "md", children: t("CustomLinks.addLink") }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { color: themeColors.brandGray[0], fz: "sm", mt: 24, children: t("CustomLinks.description") }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { size: getModalSize(), opened: modalOpened, onClose: handleModalClose, title: editingLink ? t("CustomLinks.modal.edit") : t("CustomLinks.modal.add"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(CustomLinkModal, { link: editingLink || void 0, initialGroups: editingAccess == null ? void 0 : editingAccess.groups, initialUsers: editingAccess == null ? void 0 : editingAccess.users, onSuccess: handleLinkSuccess, onClose: handleModalClose }) })
  ] });
};
const CustomPage = () => {
  const $ = compilerRuntimeExports.c(3);
  const {
    classes: classes2
  } = useStyles();
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = /* @__PURE__ */ jsxRuntimeExports.jsx(CustomLinks, {});
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  let t1;
  if ($[1] !== classes2.container) {
    t1 = /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { className: classes2.container, direction: "column", children: t0 });
    $[1] = classes2.container;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  return t1;
};
export {
  CustomPage as default
};
//# sourceMappingURL=index-BQFpm4P_.js.map
