import { b9 as T, fF as re, cp as le, fG as ee, bg as de, fH as se, fI as te, bu as ce, c1 as oe, cr as he, a0 as q, V as c, fJ as ge, d5 as be, P as J, co as ue, fK as $e, fL as me, fM as we, fN as fe } from "./684d2f28.js";
import { TableRowContext as ne, TableCellContext as pe } from "./b1144c16.js";
import { TableToolbar as ye } from "./6cb1f6af.js";
import { i as xe, j as Se, C as ve, o as Ce, k as X, O as Q } from "./bdf03194.js";
import { useContext as M, useState as C, useMemo as h, useCallback as ke, useRef as ze, useEffect as Re } from "react";
import { SlotConfigContext as He } from "./36711569.js";
import "react-dom";
import "./0667825e.js";
import "./49a8125c.js";
import "./7281819e.js";
import "./9869e60a.js";
import "./d404aae1.js";
import "./926d8ea1.js";
import "./d6402597.js";
import "./7a630f06.js";
import "./d883a28b.js";
import "./6be5dc74.js";
import "./1312a48b.js";
import "./00dac55d.js";
import "./622ce240.js";
import "./0c4ef413.js";
import "./b8f8370b.js";
import "./ca17ca0f.js";
import "./d9d1e856.js";
import "./6538ec2e.js";
import "./226f78bd.js";
import "./8e06f4ed.js";
import "./a014bc57.js";
import "./6cf5f7c0.js";
import "./7f2964c3.js";
import "./602ac28f.js";
import "./f9c25fbe.js";
import "./2d5fc5ff.js";
import "./0f3d7a1a.js";
import "./698a4355.js";
import "./cf2c1864.js";
import "./fcd1d96f.js";
function x(e) {
  return `linear-gradient(${e}, ${e})`;
}
const Te = (e, o, l, a) => {
  const i = x(e.background), d = x(o.selectedRowBackground), $ = x(o.hoverRowBackground), g = x(o.alternateBackground);
  return ue`
    .ant-table-body {
      background: ${x(e.background)};
    }
    .ant-table-tbody {
      > tr:nth-of-type(2n + 1) {
        &,
        > td {
          background: ${x(o.background)};
        }
      }

      > tr:nth-of-type(2n) {
        &,
        > td {
          background: ${g};
        }
      }

      // selected row
      > tr:nth-of-type(2n + 1).ant-table-row-selected {
        > td {
          background: ${d}, ${o.background} !important;
        }

        > td.ant-table-cell-row-hover,
        &:hover > td {
          background: ${$}, ${d}, ${o.background} !important;
        }
      }

      > tr:nth-of-type(2n).ant-table-row-selected {
        > td {
          background: ${d}, ${g} !important;
        }

        > td.ant-table-cell-row-hover,
        &:hover > td {
          background: ${$}, ${d}, ${g} !important;
        }
      }

      // hover row
      > tr:nth-of-type(2n + 1) > td.ant-table-cell-row-hover {
        &,
        > div:nth-of-type(2) {
          background: ${$}, ${o.background} !important;
        }
      }

      > tr:nth-of-type(2n) > td.ant-table-cell-row-hover {
        &,
        > div:nth-of-type(2) {
          background: ${$}, ${g} !important;
        }
      }

      > tr.ant-table-expanded-row > td {
        background: ${i};
      }
    }
  `;
}, Ve = T.span`
  position: absolute;
  top: 0;
  right: -5px;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  z-index: 1;
`, Ee = T.div`  
  ${(e) => !e.$tableAutoHeight && `height: calc(100% - ${e.$style.margin} - ${e.$style.margin});`}
  background: ${(e) => e.$style.background} !important;
  border: ${(e) => `${e.$style.borderWidth} solid ${e.$style.border} !important`};
  border-radius: ${(e) => e.$style.radius} !important;
  // padding: unset !important;
  padding: ${(e) => e.$style.padding} !important
  margin: ${(e) => e.$style.margin} !important;
  overflow: scroll !important;
  ${(e) => e.$style}
`, De = T.div`
  overflow: unset !important;

  .ant-table-wrapper {
    border-top: unset;
    border-color: inherit;
  }

  .ant-table-row-expand-icon {
    color: ${re};
  }

  .ant-table .ant-table-cell-with-append .ant-table-row-expand-icon {
    margin: 0;
    top: 18px;
    left: 4px;
  }

  .ant-table.ant-table-small .ant-table-cell-with-append .ant-table-row-expand-icon {
    top: 10px;
  }

  .ant-table.ant-table-middle .ant-table-cell-with-append .ant-table-row-expand-icon {
    top: 14px;
  }

  .ant-table {
    background: ${(e) => e.$style.background};
    .ant-table-container {
      border-left: unset;
      border-top: none !important;
      border-inline-start: none !important;

      &::after {
        box-shadow: none !important;
      }

      .ant-table-content {
        overflow: unset !important;
      }

      // A table expand row contains table
      .ant-table-tbody .ant-table-wrapper:only-child .ant-table {
        margin: 0;
      }

      table {
        border-top: unset;

        > .ant-table-thead {
          > tr > th {
            background-color: ${(e) => e.$headerStyle.headerBackground};
           
            border-color: ${(e) => e.$headerStyle.border};
            border-width: ${(e) => e.$headerStyle.borderWidth};
            color: ${(e) => e.$headerStyle.headerText};
            border-inline-end: ${(e) => `${e.$headerStyle.borderWidth} solid ${e.$headerStyle.border}`} !important;
            ${(e) => e.$fixedHeader && `
                position: sticky;
                position: -webkit-sticky;
                top: ${e.$fixedToolbar ? "47px" : "0"};
                z-index: 99;
              `}

            > div {
              margin: ${(e) => e.$headerStyle.margin};

              &, .ant-table-column-title > div {
                font-size: ${(e) => e.$headerStyle.textSize};
                font-weight: ${(e) => e.$headerStyle.textWeight};
                font-family: ${(e) => e.$headerStyle.fontFamily};
                font-style: ${(e) => e.$headerStyle.fontStyle};
                color:${(e) => e.$headerStyle.text}
              }
            }

            &:last-child {
              border-inline-end: none !important;
            }
            &.ant-table-column-has-sorters:hover {
              background-color: ${(e) => le(e.$headerStyle.headerBackground, 0.05)};
            }
  
            > .ant-table-column-sorters > .ant-table-column-sorter {
              color: ${(e) => e.$headerStyle.headerText === ee.textDark ? "#bfbfbf" : e.$headerStyle.headerText};
            }

            &::before {
              background-color: ${(e) => e.$headerStyle.border};
              width: ${(e) => e.$visibleResizables ? "1px" : "0px"} !important;
            }
          }
        }

        > thead > tr > th,
        > tbody > tr > td {
          border-color: ${(e) => e.$headerStyle.border};
          ${(e) => !e.$showHRowGridBorder && "border-bottom: 0px;"}
        }

        td {
          padding: 0px 0px;
        }

        thead > tr:first-child {
          th:last-child {
            border-right: unset;
          }
        }

        tbody > tr > td:last-child {
          border-right: unset;
        }

        .ant-empty-img-simple-g {
          fill: #fff;
        }

        > thead > tr:first-child {
          th:first-child {
            border-top-left-radius: 0px;
          }

          th:last-child {
            border-top-right-radius: 0px;
          }
        }

        // hide the bottom border of the last row
        ${(e) => e.$toolbarPosition !== "below" && `
            tbody > tr:last-child > td {
              border-bottom: unset;
            }
        `}
      }

      .ant-table-expanded-row-fixed:after {
        border-right: unset !important;
      }
    }
  }
  
  ${(e) => e.$style && Te(e.$style, e.$rowStyle, e.$headerStyle, e.$toolbarStyle)}
`, Z = T.th`
  overflow: hidden;

  > div {
    overflow: hidden;
    white-space: pre;
    text-overflow: ellipsis;
  }

  ${(e) => e.width && `width: ${e.width}px`};
`, We = T.td`
  .ant-table-row-expand-icon,
  .ant-table-row-indent {
    display: ${(e) => e.$isEditing ? "none" : "initial"};
  }
  &.ant-table-row-expand-icon-cell {
    background: ${(e) => e.$background};
    border-color: ${(e) => e.$style.border};
  }
  background: ${(e) => e.$background} !important;
  border-color: ${(e) => e.$style.border} !important;
  border-width: ${(e) => e.$style.borderWidth} !important;
  border-radius: ${(e) => e.$style.radius};

  padding: 0 !important;

  > div {
    margin: ${(e) => e.$style.margin};
    color: ${(e) => e.$style.text};
    font-weight: ${(e) => e.$style.textWeight};
    font-family: ${(e) => e.$style.fontFamily};
    
    ${(e) => e.$tableSize === "small" && `
      padding: 1px 8px;
      font-size: ${e.$defaultThemeDetail.textSize == e.$style.textSize ? "14px !important" : e.$style.textSize + " !important"};
    font-style:${e.$style.fontStyle} !important;
      min-height: ${e.$style.rowHeight || "14px"};
      line-height: 20px;
      ${!e.$autoHeight && `
        overflow-y: auto;
        max-height: ${e.$style.rowHeight || "28px"};
      `};
    `};
    ${(e) => e.$tableSize === "middle" && `
      padding: 8px 8px;
      font-size: ${e.$defaultThemeDetail.textSize == e.$style.textSize ? "16px !important" : e.$style.textSize + " !important"};
      font-style:${e.$style.fontStyle} !important;
      min-height: ${e.$style.rowHeight || "24px"};
      line-height: 24px;
      ${!e.$autoHeight && `
        overflow-y: auto;
        max-height: ${e.$style.rowHeight || "48px"};
      `};
    `};
    ${(e) => e.$tableSize === "large" && `
      padding: 16px 16px;
      font-size: ${e.$defaultThemeDetail.textSize == e.$style.textSize ? "18px !important" : e.$style.textSize + " !important"};
      font-style:${e.$style.fontStyle} !important;
      min-height: ${e.$style.rowHeight || "48px"};
      ${!e.$autoHeight && `
        overflow-y: auto;
        max-height: ${e.$style.rowHeight || "96px"};
      `};
    `};
    
    > div > .ant-badge > .ant-badge-status-text,
    > div > div > .markdown-body {
      color: ${(e) => e.$style.text};
    }

    > div > svg g {
      stroke: ${(e) => e.$style.text};
    }

    // dark link|links color
    > a,
    > div  a {
      color: ${(e) => {
  var o;
  return (o = e.$linkStyle) == null ? void 0 : o.text;
}};

      &:hover {
        color: ${(e) => {
  var o;
  return (o = e.$linkStyle) == null ? void 0 : o.hoverText;
}};
      }

      &:active {
        color: ${(e) => {
  var o;
  return (o = e.$linkStyle) == null ? void 0 : o.activeText;
}}};
      }
    }
  }
`, Be = (e) => {
  const {
    onResize: o,
    onResizeStop: l,
    width: a,
    viewModeResizable: i,
    ...d
  } = e, [$, g] = C(0), n = ze(null), r = te(), f = () => {
    a && a > 0 || g(n.current.getBoundingClientRect().width);
  };
  Re(() => {
    n.current && f();
  }, []);
  const t = oe.isNil(d.title);
  return r && !i || t ? /* @__PURE__ */ c(Z, {
    ref: n,
    ...d,
    width: a
  }) : /* @__PURE__ */ c(me, {
    width: a > 0 ? a : $,
    height: 0,
    onResize: (b, {
      size: m
    }) => o(m.width),
    onResizeStart: (b) => {
      f(), b.stopPropagation(), b.preventDefault();
    },
    onResizeStop: l,
    draggableOpts: {
      enableUserSelectHack: !1
    },
    handle: (b, m) => /* @__PURE__ */ c(Ve, {
      ref: m,
      onClick: (u) => {
        u.preventDefault(), u.stopPropagation();
      }
    }),
    children: /* @__PURE__ */ c(Z, {
      ref: n,
      ...d
    })
  });
};
function Fe(e) {
  const {
    record: o,
    title: l,
    rowIndex: a,
    rowColorFn: i,
    rowHeightFn: d,
    cellColorFn: $,
    children: g,
    columnsStyle: n,
    columnStyle: r,
    linkStyle: f,
    tableSize: t,
    autoHeight: b,
    ...m
  } = e, [u, p] = C(!1), V = M(ne);
  let k;
  if (!o)
    k = /* @__PURE__ */ c("td", {
      ...m,
      children: g
    });
  else {
    const B = i({
      currentRow: o,
      currentIndex: a,
      currentOriginalIndex: o[Q],
      columnTitle: l
    }), F = d({
      currentRow: o,
      currentIndex: a,
      currentOriginalIndex: o[Q],
      columnTitle: l
    }), z = {
      background: $({
        currentCell: o[l]
      }) || B || r.background || n.background,
      margin: r.margin || n.margin,
      text: r.text || n.text,
      border: r.border || n.border,
      radius: r.radius || n.radius,
      borderWidth: r.borderWidth || n.borderWidth,
      textSize: r.textSize || n.textSize,
      textWeight: n.textWeight || r.textWeight,
      fontFamily: n.fontFamily || r.fontFamily,
      fontStyle: n.fontStyle || r.fontStyle,
      rowHeight: F
    };
    let {
      background: w
    } = z;
    V.selected && (w = x(we(w)) + "," + w), V.hover && (w = x(fe(w)) + "," + w), k = /* @__PURE__ */ c(We, {
      ...m,
      $background: w,
      $style: z,
      $defaultThemeDetail: ee,
      $linkStyle: f,
      $isEditing: u,
      $tableSize: t,
      $autoHeight: b,
      children: g
    });
  }
  return /* @__PURE__ */ c(pe.Provider, {
    value: {
      isEditing: u,
      setIsEditing: p
    },
    children: k
  });
}
function Ie(e) {
  const [o, l] = C(!1), [a, i] = C(!1);
  return /* @__PURE__ */ c(ne.Provider, {
    value: {
      hover: o,
      selected: a
    },
    children: /* @__PURE__ */ c("tr", {
      ...e,
      tabIndex: -1,
      onMouseEnter: () => l(!0),
      onMouseLeave: () => l(!1),
      onFocus: () => i(!0),
      onBlur: () => i(!1)
    })
  });
}
function ie(e) {
  const [o, l] = C({
    index: -1,
    width: -1
  }), a = e.columns.map((i, d) => {
    const {
      width: $,
      style: g,
      linkStyle: n,
      cellColorFn: r,
      ...f
    } = i, t = (o.index === d ? o.width : i.width) ?? 0;
    let b = "auto", m = X;
    return typeof t == "number" && t > 0 && (m = "unset", b = t), {
      ...f,
      RC_TABLE_INTERNAL_COL_DEFINE: {
        style: {
          minWidth: m,
          width: b
        }
      },
      onCell: (u, p) => ({
        record: u,
        title: i.titleText,
        rowColorFn: e.rowColorFn,
        rowHeightFn: e.rowHeightFn,
        cellColorFn: r,
        rowIndex: p,
        columnsStyle: e.columnsStyle,
        columnStyle: g,
        linkStyle: n,
        tableSize: e.size,
        autoHeight: e.rowAutoHeight
      }),
      onHeaderCell: () => ({
        width: t,
        title: i.titleText,
        viewModeResizable: e.viewModeResizable,
        onResize: (u) => {
          u && l({
            index: d,
            width: u
          });
        },
        onResizeStop: (u, {
          size: p
        }) => {
          l({
            index: -1,
            width: -1
          }), i.onWidthResize && i.onWidthResize(p.width);
        }
      })
    };
  });
  return /* @__PURE__ */ c($e, {
    components: {
      header: {
        cell: Be
      },
      body: {
        cell: Fe,
        row: Ie
      }
    },
    ...e,
    pagination: !1,
    columns: a,
    scroll: {
      x: X * a.length,
      y: void 0
    }
  });
}
ie.whyDidYouRender = !0;
function yt(e) {
  const o = M(de), {
    width: l,
    ref: a
  } = se({
    refreshMode: "debounce",
    refreshRate: 600,
    handleHeight: !1
  }), i = te(), d = M(ce), [$, g] = C(!1), {
    comp: n,
    onDownload: r,
    onRefresh: f
  } = e, t = n.children, b = t.style.getView(), m = t.rowStyle.getView(), u = t.headerStyle.getView(), p = t.toolbarStyle.getView(), V = t.rowAutoHeight.getView(), k = n.getTableAutoHeight(), B = t.visibleResizables.getView(), F = t.showHRowGridBorder.getView(), _ = t.columnsStyle.getView(), z = h(() => t.columns.getChangeSet(), [t.columns]), w = h(() => !oe.isEmpty(z), [z]), I = h(() => t.columns.getView(), [t.columns]), A = h(() => I.map((s) => s.getView()), [I]), E = n.filterData, N = h(() => t.sort.getView(), [t.sort]), y = h(() => t.toolbar.getView(), [t.toolbar]), S = h(() => t.pagination.getView(), [t.pagination]), P = h(() => t.size.getView(), [t.size]), D = h(() => t.onEvent.getView(), [t.onEvent]), O = t.dynamicColumn.getView(), G = h(() => t.dynamicColumnConfig.getView(), [t.dynamicColumnConfig]), U = n.columnAggrData, j = h(() => t.expansion.getView(), [t.expansion]), K = h(() => xe(A, N, y.columnSetting, P, O, G, U, D), [A, N, y.columnSetting, P, O, G, U]), ae = h(() => Se(t.data.getView()), [t.data]), L = h(() => {
    let s = E, H = S.current;
    const W = S.total || E.length;
    if (E.length > S.pageSize) {
      let v = (H - 1) * S.pageSize;
      v >= W && (H = 1, v = 0), s = s.slice(v, v + S.pageSize);
    }
    return {
      total: W,
      current: H,
      data: s
    };
  }, [S, E]), R = ke((s) => {
    if (s === "saveChanges" && !t.onEvent.isBind(s)) {
      !i && he.warning(q("table.saveChangesNotBind"));
      return;
    }
    t.onEvent.getView()(s), setTimeout(() => t.columns.dispatchClearChangeSet());
  }, [i, t.onEvent, t.columns]), Y = /* @__PURE__ */ c(ye, {
    toolbar: y,
    $style: p,
    pagination: {
      ...S,
      total: L.total,
      current: L.current
    },
    columns: I,
    onRefresh: () => f(o.queryCompInfoList().map((s) => s.name), g),
    onDownload: () => {
      R("download"), r(`${d}-data`);
    },
    hasChange: w,
    onSaveChanges: () => R("saveChanges"),
    onCancelChanges: () => R("cancelChanges"),
    onEvent: D
  });
  return K.length === 0 ? /* @__PURE__ */ c(ge, {
    text: q("table.emptyColumns")
  }) : /* @__PURE__ */ c(be.Provider, {
    value: b.background,
    children: /* @__PURE__ */ J(Ee, {
      ref: a,
      $style: b,
      $tableAutoHeight: k,
      children: [y.position === "above" && Y, /* @__PURE__ */ J(De, {
        $style: b,
        $rowStyle: m,
        $headerStyle: u,
        $toolbarStyle: p,
        $toolbarPosition: y.position,
        $fixedHeader: t.fixedHeader.getView(),
        $fixedToolbar: y.fixedToolbar && y.position === "above",
        $visibleResizables: B,
        $showHRowGridBorder: F,
        children: [/* @__PURE__ */ c(ie, {
          expandable: {
            ...j.expandableConfig,
            childrenColumnName: ae ? ve : "OB_CHILDREN_KEY_PLACEHOLDER",
            fixed: "left",
            onExpand: (s) => {
              R(s ? "rowExpand" : "rowShrink");
            }
          },
          rowColorFn: t.rowColor.getView(),
          rowHeightFn: t.rowHeight.getView(),
          ...t.selection.getView()(D),
          bordered: t.showRowGridBorder.getView(),
          onChange: (s, H, W, v) => {
            Ce(s, H, W, v, n.dispatch, D);
          },
          showHeader: !t.hideHeader.getView(),
          columns: K,
          columnsStyle: _,
          viewModeResizable: t.viewModeResizable.getView(),
          visibleResizables: t.visibleResizables.getView(),
          dataSource: L.data,
          size: t.size.getView(),
          rowAutoHeight: V,
          tableLayout: "fixed",
          loading: $ || // fixme isLoading type
          t.showDataLoadSpinner.getView() && t.data.isLoading() || t.loading.getView()
        }), /* @__PURE__ */ c(He.Provider, {
          value: {
            modalWidth: l && Math.max(l, 300)
          },
          children: j.expandModalView
        })]
      }), y.position === "below" && Y]
    })
  });
}
export {
  yt as TableCompView
};
