import { jsx as c } from "react/jsx-runtime";
import { useId as j, useRef as E } from "react";
import V from "../../utils/classNames.js";
import { isProd as q } from "../../utils/init/initConfig.js";
import B from "./render/header/TableDraggableHeaderCell.js";
import F from "./render/header/TableStaticHeaderCell.js";
import { useOptionalTableInteractionContext as G } from "./context/TableInteractionContext.js";
import { useOptionalTableLayoutContext as J } from "./context/TableLayoutContext.js";
import { useOptionalTableRenderConfigContext as Q } from "./context/TableRenderConfigContext.js";
import { useOptionalTableSection as U, useTableHeaderRowContext as X } from "./context/TableStructureContext.js";
import { useOptionalTableRenderContext as Y } from "./context/TableRenderContext.js";
const ie = (d) => {
  const {
    children: C,
    className: h,
    colSpan: a = 1,
    columnKey: r,
    draggable: b,
    filter: f,
    headerClassName: p,
    hideLabel: g,
    hideOnMobile: R,
    horizontalAlign: y,
    icon: S,
    label: x,
    maxResizeWidth: w,
    mobileLabel: z,
    minResizeWidth: K,
    resizeable: T,
    rowSpan: H = 1,
    sortable: O,
    verticalAlign: k,
    width: L,
    ...W
  } = d, t = Y(), s = Q(), n = G(), o = J(), v = U(), D = X(), i = j(), u = E(!1);
  if (!t || !s || !n || !o || v !== "header")
    return null;
  !q && a === 1 && !r && !u.current && (console.warn(
    "TableHeaderColumn: Header cells for a single data column with colSpan=1 should provide a columnKey. Without it, the table cannot derive a stable data-column layout."
  ), u.current = !0);
  const N = D?.row ?? 1;
  if (t.renderDraft.headerColumns.push({
    id: i,
    columnKey: r,
    label: x ?? C ?? "",
    icon: S,
    filter: f,
    hideLabel: g,
    width: L,
    mobileLabel: z,
    horizontalAlign: y,
    verticalAlign: k,
    headerClassName: V(h, p),
    hideOnMobile: R,
    sortable: O,
    draggable: b,
    resizeable: T,
    minResizeWidth: K,
    maxResizeWidth: w,
    row: N,
    colSpan: a,
    rowSpan: H
  }), !s.isTableView)
    return null;
  const l = t.header, e = l?.columns.find((M) => String(M.key) === i);
  if (!l || !e)
    return null;
  const A = !!e.columnKey && e.colSpan === 1 && e.columnKey !== o.lastResizableColumnKey && e.resizeable === !0 && !!o.onColumnResizeStart, I = !!e.columnKey && e.colSpan === 1 && (o.draggableColumnKeys?.length ?? 0) > 1 && e.draggable === !0 && !!o.onColumnDragEnd, P = !!e.columnKey && o.resettableColumnKeys?.has(e.columnKey), m = {
    column: e,
    header: l,
    htmlAttributes: W,
    hasResettableWidth: P,
    isResizable: A,
    onColumnResizeReset: o.onColumnResizeReset,
    onColumnResizeStart: o.onColumnResizeStart,
    onSortChange: n.onSortChange,
    showSelectionColumn: n.showSelectionColumn,
    stickyLeftColumnCount: o.stickyLeftColumnCount,
    stickyRightColumnCount: o.stickyRightColumnCount
  };
  return I ? /* @__PURE__ */ c(B, { ...m }) : /* @__PURE__ */ c(F, { ...m });
};
export {
  ie as default
};
//# sourceMappingURL=TableHeaderColumn.js.map
