import { GridRowModel, GridRowId, GridRowModelUpdate, GridValidRowModel, GridTreeNode } from "../gridRows.js";
export type RowReorderDropPosition = 'above' | 'below' | 'inside';
export type RowReorderDragDirection = 'up' | 'down';
export interface GridRowGroupChildrenGetterParams {
  /**
   * The row id of the group
   */
  groupId: GridRowId;
  /**
   * If `true`, the method will not return the generated rows generated by the grid (aggregation footers, groups, ...)
   * @default true
   */
  skipAutoGeneratedRows?: boolean;
  /**
   * If `true`, the method will only return the rows that are matching the current filters
   * @default false
   */
  applyFiltering?: boolean;
  /**
   * If `true`, the method will order the returned rows according to the current sorting rules
   * @default false
   */
  applySorting?: boolean;
  /**
   * If `true`, the method will only return the direct leaf children of the group
   * @default false
   */
  directChildrenOnly?: boolean;
}
/**
 * The Row API interface that is available in the grid `apiRef`.
 */
export interface GridRowApi {
  /**
   * Gets the full set of rows as [[Map<GridRowId, GridRowModel>]].
   * @returns {Map<GridRowId, GridRowModel>} The full set of rows.
   */
  getRowModels: () => Map<GridRowId, GridRowModel>;
  /**
   * Gets the total number of rows in the grid.
   * @returns {number} The number of rows.
   */
  getRowsCount: () => number;
  /**
   * Gets the list of row ids.
   * TODO rows v6: Rename or remove ?
   * @returns {GridRowId[]} A list of ids.
   */
  getAllRowIds: () => GridRowId[];
  /**
   * Sets the internal loading state.
   * @param {boolean} loading If `true` the loading indicator will be shown over the Data Grid.
   */
  setLoading: (loading: boolean) => void;
  /**
   * Sets a new set of rows.
   * @param {GridRowModel[]} rows The new rows.
   */
  setRows: (rows: GridRowModel[]) => void;
  /**
   * Allows to update, insert and delete rows.
   * @param {GridRowModelUpdate[]} updates An array of rows with an `action` specifying what to do.
   */
  updateRows: (updates: GridRowModelUpdate[]) => void;
  /**
   * Gets the row data with a given id.
   * @param {GridRowId} id The id of the row.
   * @returns {GridRowModel} The row data.
   */
  getRow: <R extends GridValidRowModel = any>(id: GridRowId) => R | null;
  /**
   * Gets the ID of a row given its data.
   * @param {GridRowModel} row The row data.
   * @returns {GridRowId} The id of the row.
   * @deprecated Use `gridRowIdSelector` instead.
   */
  getRowId: <R extends GridValidRowModel = any>(row: R) => GridRowId;
  /**
   * Gets the row node from the internal tree structure.
   * @param {GridRowId} id The id of the row.
   * @returns {GridTreeNode} The tree node.
   * @deprecated Use `gridRowNodeSelector` instead.
   */
  getRowNode: <N extends GridTreeNode>(id: GridRowId) => N | null;
  /**
   * Gets the index of a row relative to the rows that are reachable by scroll.
   * @param {GridRowId} id The row id.
   * @returns {number} The index of the row.
   */
  getRowIndexRelativeToVisibleRows: (id: GridRowId) => number;
  /**
   * Replace a set of rows with new rows.
   * @param {number} firstRowToReplace The index of the first row to be replaced.
   * @param {GridRowModel[]} newRows The new rows.
   */
  unstable_replaceRows: (firstRowToReplace: number, newRows: GridRowModel[]) => void;
}
export interface GridRowProApi {
  /**
   * Moves a row from its original position to the position given by `targetIndex`.
   * Doesn't support tree data ordering. Use `setRowPosition()` instead.
   * @param {GridRowId} rowId The row id
   * @param {number} targetIndex The new position (0-based).
   * @returns {void | Promise<void>} Returns a Promise when async operations are involved (e.g., processRowUpdate)
   * @deprecated Use `setRowPosition()` instead. This method will be removed in the next major version.
   */
  setRowIndex: (rowId: GridRowId, targetIndex: number) => void | Promise<void>;
  /**
   * Moves a row to a new position relative to another row.
   * @param {GridRowId} sourceRowId The ID of the row to move
   * @param {GridRowId} targetRowId The ID of the row to position relative to
   * @param {DropPosition} position Where to place the source row: 'above', 'below', or 'over' (for tree data)
   * @returns {void | Promise<void>} Returns a Promise when async operations are involved (e.g., processRowUpdate)
   */
  setRowPosition: (sourceRowId: GridRowId, targetRowId: GridRowId, position: RowReorderDropPosition) => void | Promise<void>;
  /**
   * Gets the rows of a grouping criteria.
   * Only contains the rows provided to the grid, not the rows automatically generated by it.
   * @param {GridRowGroupChildrenGetterParams} params Object containing parameters for the getter.
   * @returns {GridRowId[]} The id of each row in the grouping criteria.
   */
  getRowGroupChildren: (params: GridRowGroupChildrenGetterParams) => GridRowId[];
  /**
   * Expand or collapse a row children.
   * Only works for the client side data or to collapse already fetched server side rows.
   * For server-side data, use `dataSource.fetchRows(childId)` to fetch and expand the children.
   * @param {GridRowId} id the ID of the row to expand or collapse.
   * @param {boolean} isExpanded A boolean indicating if the row must be expanded or collapsed.
   */
  setRowChildrenExpansion: (id: GridRowId, isExpanded: boolean) => void;
  /**
   * Expand all rows. Works for the client side data only.
   */
  expandAllRows: () => void;
  /**
   * Collapse all rows. Works for the client side data only.
   */
  collapseAllRows: () => void;
}
export interface GridRowProPrivateApi {
  /**
   * Allows to update, insert and delete rows at a specific nested level.
   * @param {GridRowModelUpdate[]} updates An array of rows with an `action` specifying what to do.
   * @param {string[]} nestedLevel The nested level of the rows to update, it represents the path to the row in the tree based on `node.groupingKey`.
   */
  updateNestedRows: (updates: GridRowModelUpdate[], nestedLevel?: string[]) => void;
}