import { E as compilerRuntimeExports, j as jsxRuntimeExports } from "./vendor-react-DYNCg6N5.js";
import { n as Bq, b as gq, a3 as ZCe } from "./vendor-icons-xWhXK_Ui.js";
import { c as createStyles, U as UnstyledButton, G as Group, T as Text, m as Center, Z as alpha, ap as Spoiler } from "./vendor-mantine-h0WlM2Mj.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
const useStyles$1 = createStyles((theme, {
  hideSort
}) => ({
  th: {
    padding: "0 !important",
    height: "44px",
    borderBottom: "none !important"
  },
  control: {
    width: "100%",
    padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
    cursor: hideSort ? "default" : "pointer"
  },
  icon: {
    width: 21,
    height: 21,
    borderRadius: 21
  },
  hideColumn: {
    display: "none"
  }
}));
const Th = (t0) => {
  const $ = compilerRuntimeExports.c(20);
  const {
    children,
    reversed,
    sorted,
    onSort,
    width: t1,
    hideSort: t2,
    hideColumn: t3
  } = t0;
  const width = t1 === void 0 ? "auto" : t1;
  const hideSort = t2 === void 0 ? true : t2;
  const hideColumn = t3 === void 0 ? false : t3;
  let t4;
  if ($[0] !== hideSort) {
    t4 = {
      hideSort
    };
    $[0] = hideSort;
    $[1] = t4;
  } else {
    t4 = $[1];
  }
  const {
    classes,
    cx
  } = useStyles$1(t4);
  const Icon = sorted ? reversed ? Bq : gq : ZCe;
  let t5;
  if ($[2] !== classes.hideColumn || $[3] !== classes.th || $[4] !== cx || $[5] !== hideColumn) {
    t5 = cx(classes.th, {
      [classes.hideColumn]: hideColumn
    });
    $[2] = classes.hideColumn;
    $[3] = classes.th;
    $[4] = cx;
    $[5] = hideColumn;
    $[6] = t5;
  } else {
    t5 = $[6];
  }
  let t6;
  if ($[7] !== width) {
    t6 = {
      width,
      minWidth: width
    };
    $[7] = width;
    $[8] = t6;
  } else {
    t6 = $[8];
  }
  let t7;
  if ($[9] !== Icon || $[10] !== children || $[11] !== classes.control || $[12] !== classes.icon || $[13] !== hideSort || $[14] !== onSort) {
    t7 = (children || !hideSort) && /* @__PURE__ */ jsxRuntimeExports.jsx(UnstyledButton, { onClick: onSort, className: classes.control, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Group, { justify: "space-between", wrap: "nowrap", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { size: "sm", c: "gray.6", fw: 400, children }),
      hideSort || /* @__PURE__ */ jsxRuntimeExports.jsx(Center, { className: classes.icon, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { size: 14, stroke: 1.5 }) })
    ] }) });
    $[9] = Icon;
    $[10] = children;
    $[11] = classes.control;
    $[12] = classes.icon;
    $[13] = hideSort;
    $[14] = onSort;
    $[15] = t7;
  } else {
    t7 = $[15];
  }
  let t8;
  if ($[16] !== t5 || $[17] !== t6 || $[18] !== t7) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: t5, style: t6, children: t7 });
    $[16] = t5;
    $[17] = t6;
    $[18] = t7;
    $[19] = t8;
  } else {
    t8 = $[19];
  }
  return t8;
};
const useStyles = createStyles((theme, _, utils) => ({
  tr: {
    padding: "0 !important",
    height: "72px",
    position: "relative",
    backgroundColor: "white",
    cursor: "pointer",
    "&:first-of-type td": {
      borderTop: "none !important"
    },
    "&:hover": {
      [utils.dark]: {
        backgroundColor: theme.colors.dark[6]
      },
      [utils.light]: {
        backgroundColor: theme.colors.backgroundGray[6]
      },
      "& .action-icon": {
        opacity: 1
      }
    },
    "& .action-icon": {
      opacity: 0
    }
  },
  td: {
    padding: "17px 24px !important",
    borderTop: `1px solid ${theme.colors.backgroundGray[6]} !important`,
    "& p": {
      fontSize: "14px"
    }
  },
  rowSelected: {
    [utils.dark]: {
      backgroundColor: alpha(theme.colors[theme.primaryColor][7], 0.2)
    },
    [utils.light]: {
      backgroundColor: theme.colors.mainBlue[0]
    }
  },
  pinnedRow: {
    backgroundColor: theme.colors.backgroundGray[6],
    fontWeight: 600
  },
  withCheckbox: {
    padding: "17px 16px !important"
  },
  hideColumn: {
    display: "none"
  },
  pinnedCOlumn: {
    fontWeight: 600
  }
}));
const Tr = (t0) => {
  const $ = compilerRuntimeExports.c(44);
  const {
    columns,
    row,
    selection,
    pinnedRows,
    handleRowClick
  } = t0;
  const {
    classes,
    cx
  } = useStyles();
  const {
    t
  } = useTranslation();
  let t1;
  if ($[0] !== row || $[1] !== selection) {
    t1 = selection == null ? void 0 : selection.includes(row.Id);
    $[0] = row;
    $[1] = selection;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  const isSelected = !!t1;
  let t2;
  if ($[3] !== pinnedRows || $[4] !== row) {
    t2 = pinnedRows == null ? void 0 : pinnedRows.includes(row.Id);
    $[3] = pinnedRows;
    $[4] = row;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  const isPinned = !!t2;
  let t3;
  if ($[6] !== handleRowClick || $[7] !== (row == null ? void 0 : row.Id)) {
    t3 = (e) => {
      const currentTarget = e.currentTarget;
      const target = e.target;
      if (currentTarget.contains(target) && handleRowClick) {
        handleRowClick(Number(row == null ? void 0 : row.Id));
      }
    };
    $[6] = handleRowClick;
    $[7] = row == null ? void 0 : row.Id;
    $[8] = t3;
  } else {
    t3 = $[8];
  }
  const clickRow = t3;
  let t4;
  if ($[9] !== t) {
    t4 = t("showMore");
    $[9] = t;
    $[10] = t4;
  } else {
    t4 = $[10];
  }
  const showMoreText = t4;
  let t5;
  if ($[11] !== t) {
    t5 = t("hide");
    $[11] = t;
    $[12] = t5;
  } else {
    t5 = $[12];
  }
  const hideMoreText = t5;
  const t6 = row == null ? void 0 : row.Id;
  let t7;
  if ($[13] !== classes.pinnedRow || $[14] !== classes.rowSelected || $[15] !== classes.tr || $[16] !== cx || $[17] !== isPinned || $[18] !== isSelected) {
    t7 = cx(classes.tr, {
      [classes.rowSelected]: isSelected,
      [classes.pinnedRow]: isPinned
    });
    $[13] = classes.pinnedRow;
    $[14] = classes.rowSelected;
    $[15] = classes.tr;
    $[16] = cx;
    $[17] = isPinned;
    $[18] = isSelected;
    $[19] = t7;
  } else {
    t7 = $[19];
  }
  let t8;
  if ($[20] !== classes.hideColumn || $[21] !== classes.td || $[22] !== classes.withCheckbox || $[23] !== columns || $[24] !== cx || $[25] !== hideMoreText || $[26] !== row || $[27] !== selection || $[28] !== showMoreText) {
    let t92;
    if ($[30] !== classes.hideColumn || $[31] !== classes.td || $[32] !== classes.withCheckbox || $[33] !== cx || $[34] !== hideMoreText || $[35] !== row || $[36] !== selection || $[37] !== showMoreText) {
      t92 = (col, colIndex) => {
        const currentValue = col.render && col.render(row, selection);
        return /* @__PURE__ */ jsxRuntimeExports.jsxs("td", { className: cx(classes.td, {
          [classes.withCheckbox]: Boolean(selection),
          [classes.hideColumn]: col.hideColumn
        }), children: [
          col.dataIndex === "Description" && /* @__PURE__ */ jsxRuntimeExports.jsx(Spoiler, { maxHeight: 70, showLabel: showMoreText, hideLabel: hideMoreText, children: currentValue }),
          col.dataIndex !== "Description" && currentValue
        ] }, colIndex);
      };
      $[30] = classes.hideColumn;
      $[31] = classes.td;
      $[32] = classes.withCheckbox;
      $[33] = cx;
      $[34] = hideMoreText;
      $[35] = row;
      $[36] = selection;
      $[37] = showMoreText;
      $[38] = t92;
    } else {
      t92 = $[38];
    }
    t8 = columns.map(t92);
    $[20] = classes.hideColumn;
    $[21] = classes.td;
    $[22] = classes.withCheckbox;
    $[23] = columns;
    $[24] = cx;
    $[25] = hideMoreText;
    $[26] = row;
    $[27] = selection;
    $[28] = showMoreText;
    $[29] = t8;
  } else {
    t8 = $[29];
  }
  let t9;
  if ($[39] !== clickRow || $[40] !== t6 || $[41] !== t7 || $[42] !== t8) {
    t9 = /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { "data-id": t6, onClick: clickRow, className: t7, children: t8 });
    $[39] = clickRow;
    $[40] = t6;
    $[41] = t7;
    $[42] = t8;
    $[43] = t9;
  } else {
    t9 = $[43];
  }
  return t9;
};
export {
  Tr as T,
  Th as a
};
//# sourceMappingURL=index-Zaude47i.js.map
