import { jsx as m } from "react/jsx-runtime";
import { memo as L, useCallback as u, useMemo as D } from "react";
import { TableRow as R } from "../../../table/components/TablePrimitive.js";
import { DEFAULT_ROW_HEIGHT as k } from "../../constants/tableDefaults.js";
import { SortableContext as K, horizontalListSortingStrategy as N } from "@dnd-kit/sortable";
import O from "../../../table/utils/areRowPropsEqual.js";
import _ from "../../hooks/useDataTableStaticContext.js";
import $ from "../data-table-cell/DataTableCell.js";
import { c as j } from "../../../../index-BtlgVD4m.js";
const q = ({
  dataIndex: n,
  measureElement: y,
  rowStartPosition: f,
  row: T,
  columnSizingId: o,
  columnSizingDeltaOffset: i,
  columnSize: a,
  isSelected: c,
  cellEdit: b
}) => {
  const { rowHeight: p = k, hasColumnSeparator: g, onRowClick: r, onRowDoubleClick: s, columnOrder: w, columns: h } = _(), { original: e, getVisibleCells: x } = T, l = x(), d = u(() => {
    r == null || r(e);
  }, [r, e]), C = u(() => {
    s == null || s(e);
  }, [s, e]), v = u(
    (t) => {
      if (t.key === "Enter" || t.key === " ") {
        if (t.target !== t.currentTarget) return;
        t.preventDefault(), r == null || r(e);
      }
    },
    [r, e]
  ), E = D(() => l.map((t) => ({
    hasColumnSeparator: g,
    cell: t,
    cellsLength: l.length,
    isSelected: c,
    columnSizingId: o === t.column.id ? o : !1,
    columnSizingDeltaOffset: o === t.column.id ? i : null,
    handleClickRow: d,
    columnSizeNumber: a == null ? void 0 : a[t.column.id],
    record: e,
    rowIndex: n,
    cellEdit: b,
    columns: h
  })), [
    l,
    g,
    c,
    o,
    i,
    d,
    a,
    b,
    n,
    e,
    h
  ]), H = D(
    () => ({
      height: p,
      top: f
    }),
    [p, f]
  );
  return /* @__PURE__ */ m(
    R,
    {
      "data-index": n,
      ref: y,
      tabIndex: 0,
      onKeyDown: v,
      onDoubleClick: C,
      className: j(
        "hover:bg-[var(--base-muted)] w-full flex absolute",
        "focus:outline-none focus:ring-2 focus:ring-[var(--base-ring)] focus:ring-inset focus:z-10"
      ),
      style: H,
      children: /* @__PURE__ */ m(K, { items: w, strategy: N, children: E.map((t) => /* @__PURE__ */ m($, { ...t }, `data-table-cell-${t.cell.id}`)) })
    }
  );
}, P = L(q, O);
export {
  P as default
};
//# sourceMappingURL=DataTableRow.js.map
