import type { App } from 'vue'

import { EXPAND_COLUMN, Summary, SummaryCell, SummaryRow } from '../vc-table'
import Column from './Column'
import ColumnGroup from './ColumnGroup'
import Table, { tableProps } from './Table'
import type { TablePaginationConfig, TableProps } from './Table'
import {
  SELECTION_ALL,
  SELECTION_COLUMN,
  SELECTION_INVERT,
  SELECTION_NONE,
} from './hooks/useSelection'

export type { ColumnProps } from './Column'
export type { ColumnGroupType, ColumnsType, ColumnType } from './interface'
export type { TablePaginationConfig, TableProps }

const TableSummaryRow = SummaryRow
const TableSummaryCell = SummaryCell

const TableSummary = Object.assign(Summary, {
  Cell: TableSummaryCell,
  Row: TableSummaryRow,
  name: 'ATableSummary',
})

/* istanbul ignore next */
export {
  Column as TableColumn,
  ColumnGroup as TableColumnGroup,
  tableProps,
  TableSummary,
  TableSummaryCell,
  TableSummaryRow,
}

export default Object.assign(Table, {
  SELECTION_ALL,
  SELECTION_INVERT,
  SELECTION_NONE,
  SELECTION_COLUMN,
  EXPAND_COLUMN,
  Column,
  ColumnGroup,
  Summary: TableSummary,
  install: (app: App) => {
    app.component(TableSummary.name, TableSummary)
    app.component(TableSummaryCell.name, TableSummaryCell)
    app.component(TableSummaryRow.name, TableSummaryRow)
    app.component(Table.name, Table)
    app.component(Column.name, Column)
    app.component(ColumnGroup.name, ColumnGroup)
    return app
  },
})
