import { jsx as e, jsxs as B } from "@emotion/react/jsx-runtime";
import { useRef as J } from "react";
import { useModuleSkeleton as X } from "@m4l/core";
import { DataGridProvider as q } from "../../contexts/DataGridContext/DataGridContext.js";
import { TEST_PROP_COLUMNS as Q } from "../../types.js";
import { TEST_PROP_ID as W } from "../../../../test/constants_no_mock.js";
import { getNameDataTestId as Y } from "../../../../test/getNameDataTestId.js";
import { TEST_SKELETON as Z, DATAGRID_PREFIX_NAME as l } from "../../constants.js";
import { DataGridRootStyled as $, CustomHeaderStyled as ee } from "../../slots/DataGridSlot.js";
import { getComponentSlotRoot as te } from "../../../../utils/getComponentSlotRoot.js";
import { useComponentSize as oe } from "../../../../hooks/useComponentSize/index.js";
import { FilterProvider as re } from "../../contexts/FilterContext/FilterContext.js";
import { HeaderActions as ie } from "../../subcomponents/HeaderActions/HeaderActions.js";
import { ControlNavigate as se } from "../../subcomponents/ControlNavigate/ControlNavigate.js";
function Re(m) {
  const {
    id: c,
    withActions: d = !0,
    rows: i,
    columns: t,
    actionsProps: s,
    rowKeyGetter: f,
    rowActionsGetter: u,
    rowHeaderHeights: p,
    rowHeights: g,
    initialRowHeightVariant: h,
    checkedRows: w,
    onCheckedRowsChange: C,
    checkedRowsMultiple: S,
    dataTestId: R = "",
    customHeader: n,
    visibleCustomHeader: P = !0,
    defaultConfig: T,
    onChangeConfig: A,
    defaultUserColumns: D,
    onChangeUserColumns: E,
    size: H,
    externalSortSettings: N,
    externalFilterSettings: _,
    defaultViewMode: G,
    cardsViewConfig: O,
    listViewConfig: v,
    reorderable: x = !0,
    children: z
  } = m, {
    withSettings: k,
    settingsProps: F,
    withRowsCount: I,
    withLocalFilters: M,
    leftActions: V,
    rightActions: y,
    withPager: o,
    pagerOptions: L,
    exportConfig: U
  } = s, { currentSize: r } = oe(H), b = J(null), j = te(l), a = {
    visibleCustomHeader: P
  }, K = X();
  return /* @__PURE__ */ e(
    $,
    {
      ownerState: a,
      ref: b,
      className: j,
      ...process.env.NODE_ENV !== "production" ? {
        [Q]: JSON.stringify(t),
        [W]: Y(
          l,
          "root",
          R
        ),
        [Z]: !!K
      } : {},
      children: /* @__PURE__ */ e(
        q,
        {
          id: c,
          columns: t,
          rowHeights: g,
          rowHeaderHeights: p,
          initialRowHeightVariant: h,
          rowsCount: i.length,
          checkedRows: w,
          rowActionsGetter: u,
          onCheckedRowsChange: C,
          checkedRowsMultiple: S,
          rowKeyGetter: f,
          rows: i,
          defaultConfig: T,
          onChangeConfig: A,
          defaultUserColumns: D,
          onChangeUserColumns: E,
          size: r,
          externalSortSettings: N,
          externalFilterSettings: _,
          defaultViewMode: G,
          cardsViewConfig: O,
          listViewConfig: v,
          reorderable: x,
          children: /* @__PURE__ */ B(re, { initialActiveFilters: !1, children: [
            d && s && /* @__PURE__ */ e(
              ie,
              {
                withSettings: k,
                settingsProps: F,
                withRowsCount: I,
                withLocalFilters: M,
                leftActions: V,
                rightActions: y,
                withPager: o,
                exportConfig: U,
                columns: t,
                size: r
              }
            ),
            n ? /* @__PURE__ */ e(ee, { ownerState: a, children: n }) : null,
            z,
            o && /* @__PURE__ */ e(
              se,
              {
                size: r,
                withPager: o,
                pagerOptions: L
              }
            )
          ] })
        }
      )
    }
  );
}
export {
  Re as BaseDataGrid
};
