'use strict';

require('core-js/modules/es.symbol.js');
require('core-js/modules/es.array.filter.js');
require('core-js/modules/es.object.get-own-property-descriptor.js');
require('core-js/modules/es.object.get-own-property-descriptors.js');
require('core-js/modules/es.object.keys.js');
require('core-js/modules/es.object.to-string.js');
require('core-js/modules/web.dom-collections.for-each.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
require('core-js/modules/es.array.concat.js');
require('core-js/modules/es.object.values.js');
var PropTypes = require('prop-types');
var SharedPropTypes = require('../../constants/SharedPropTypes.js');
var deprecate = require('../../internal/deprecate.js');
var bundledIcons = require('../../utils/bundledIcons.js');
var tableUtilities = require('./tableUtilities.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var RowActionPropTypes = PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
  /** Unique id of the action */
  id: PropTypes__default.default.string.isRequired,
  /** icon ultimately gets passed through all the way to <Button>, or is rendered in the OverflowMenu, this definition handles both cases, including custom svg as a function */
  renderIcon: PropTypes__default.default.oneOfType([PropTypes__default.default.shape({
    width: PropTypes__default.default.string,
    height: PropTypes__default.default.string,
    viewBox: PropTypes__default.default.string.isRequired,
    svgData: SharedPropTypes.SvgPropType.isRequired
  }), PropTypes__default.default.oneOf(bundledIcons.bundledIconNames), PropTypes__default.default.node, PropTypes__default.default.object, PropTypes__default.default.func]),
  disabled: PropTypes__default.default.bool,
  hidden: PropTypes__default.default.bool,
  labelText: PropTypes__default.default.string,
  /** Action should go into the overflow menu, not be rendered inline in the row */
  isOverflow: PropTypes__default.default.bool,
  hasDivider: PropTypes__default.default.bool,
  isDelete: PropTypes__default.default.bool,
  isEdit: PropTypes__default.default.bool
}));
var RowActionErrorPropTypes = PropTypes__default.default.shape({
  title: PropTypes__default.default.node,
  message: PropTypes__default.default.node,
  learnMoreURL: PropTypes__default.default.string
});
var RowActionsStatePropTypes = PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
  rowId: PropTypes__default.default.string,
  isRunning: PropTypes__default.default.bool,
  isEditMode: PropTypes__default.default.bool,
  error: RowActionErrorPropTypes
}));
var EmptyStatePropTypes = PropTypes__default.default.oneOfType([PropTypes__default.default.shape({
  message: PropTypes__default.default.oneOfType([PropTypes__default.default.node, PropTypes__default.default.string]).isRequired,
  messageBody: PropTypes__default.default.oneOfType([PropTypes__default.default.node, PropTypes__default.default.string]),
  /* Show a different message if no content is in the table matching the filters */
  messageWithFilters: PropTypes__default.default.oneOfType([PropTypes__default.default.node, PropTypes__default.default.string]),
  messageWithFiltersBody: PropTypes__default.default.oneOfType([PropTypes__default.default.node, PropTypes__default.default.string]),
  /* If a label is not provided, no action button will be rendered */
  buttonLabel: PropTypes__default.default.oneOfType([PropTypes__default.default.node, PropTypes__default.default.string]),
  /* Show a different button label if no content is in the table matching the filters */
  buttonLabelWithFilters: PropTypes__default.default.oneOfType([PropTypes__default.default.node, PropTypes__default.default.string])
}), /* If a React element is provided, it will be rendered in place of the default */
PropTypes__default.default.element]);

/** Construct ahead of time with correct content */
var ExpandedRowsPropTypes = PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
  rowId: PropTypes__default.default.string,
  content: PropTypes__default.default.node
}));
var TableRowPropTypes = PropTypes__default.default.shape({
  /** id is sent back on each event callback as users interact with the row */
  id: PropTypes__default.default.string.isRequired,
  /** {key: value} object where each key is a column identifier so that it can be dynamically ordered and value is the underlying data value of the each field.
   * If the item is a boolean, string, or number, it can be searched, filtered, and sorted. Else, it will not be able to. */
  values: PropTypes__default.default.objectOf(PropTypes__default.default.any).isRequired,
  /** Optional array of rows (TableDataPropTypes) nested beneath this one */
  children: PropTypes__default.default.oneOfType([PropTypes__default.default.array // an array of TableRowPropTypes or elements
  ]),
  /** Optional list of actions visible on row hover or expansion */
  rowActions: RowActionPropTypes,
  /** is this particular row selectable */
  isSelectable: PropTypes__default.default.bool,
  /** boolean to define load more row */
  hasLoadMore: PropTypes__default.default.bool,
  /** If this row can be dragged. The table must be set to use `hasDragAndDrop`. */
  isDraggable: PropTypes__default.default.bool
});
var TableRowsPropTypes = PropTypes__default.default.arrayOf(TableRowPropTypes);
var TableColumnsPropTypes = PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
  id: PropTypes__default.default.string.isRequired,
  name: PropTypes__default.default.string.isRequired,
  isSortable: PropTypes__default.default.bool,
  /** optional sort function for this column, called back with the column to sort on and the in-memory data as parameters
   * { columnId: PropTypes.string, direction: PropTypes.oneOf(['ASC','DESC']), data: PropTypes.array }
   * You should return the updated data
   */
  sortFunction: PropTypes__default.default.func,
  width: PropTypes__default.default.string,
  // ex: 150px, or 2rem
  align: PropTypes__default.default.oneOf(['start', 'center', 'end']),
  // ex: start, center, end
  /** for each column you can register a render callback function that is called with this object payload
   * {
   *    value: PropTypes.any (current cell value),
   *    columnId: PropTypes.string,
   *    rowId: PropTypes.string,
   *    row: PropTypes.object like this {col: value, col2: value}
   * }, you should return the node that should render within that cell */
  renderDataFunction: PropTypes__default.default.func,
  /** tooltip to show with the column, for instance to provide more information */
  tooltip: PropTypes__default.default.string,
  /**
   * If omitted, no filter input will be shown for this column
   */
  filter: PropTypes__default.default.shape({
    /** I18N text for the filter */
    placeholderText: PropTypes__default.default.string,
    /** if isMultiselect is true, the table is filtered based on a multiselect */
    isMultiselect: PropTypes__default.default.bool,
    /**
     * customInput should be a React component that will accept the following props. value, onChange, id, column, columns etc.
     * The expectation is that the input component will use value as the default value and onChange will be called when the value changes.  The FilterTableRow will debounce the values so the component does not need to do this
     */
    customInput: PropTypes__default.default.elementType,
    options: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      id: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number, PropTypes__default.default.bool]).isRequired,
      text: PropTypes__default.default.string.isRequired
    })),
    /** if isDate and isFilterable are true, the table is filtered base on a date picker */
    isDate: PropTypes__default.default.bool,
    /** if dateOptions is empty array, assume a default format and locale */
    dateOptions: PropTypes__default.default.shape({
      dateFormat: PropTypes__default.default.string,
      locale: PropTypes__default.default.string
    }),
    /** custom filtration function, called back with (columnValue, filterValue) */
    filterFunction: PropTypes__default.default.func
  }),
  /**
   * If omitted, column overflow menu will not render
   */
  overflowMenuItems: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
    id: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number, PropTypes__default.default.bool]).isRequired,
    text: PropTypes__default.default.string.isRequired
  }))
}));
var I18NPropTypes = PropTypes__default.default.shape({
  /** pagination */
  pageBackwardAria: PropTypes__default.default.string,
  pageForwardAria: PropTypes__default.default.string,
  pageNumberAria: PropTypes__default.default.string,
  itemsPerPage: PropTypes__default.default.string,
  /** (min, max, total) => `${min}-${max} of ${total} items` */
  itemsRangeWithTotal: PropTypes__default.default.func,
  /** (current, total) => `${current} of ${total} pages` */
  /** table body */
  pageRange: PropTypes__default.default.func,
  overflowMenuAria: PropTypes__default.default.string,
  clickToExpandAria: PropTypes__default.default.string,
  clickToCollapseAria: PropTypes__default.default.string,
  selectAllAria: PropTypes__default.default.string,
  selectRowAria: PropTypes__default.default.string,
  /** toolbar */
  searchLabel: PropTypes__default.default.string,
  searchPlaceholder: PropTypes__default.default.string,
  clearAllFilters: PropTypes__default.default.string,
  columnSelectionButtonAria: PropTypes__default.default.string,
  columnSelectionConfig: PropTypes__default.default.string,
  filterButtonAria: PropTypes__default.default.string,
  editButtonAria: PropTypes__default.default.string,
  clearFilterAria: PropTypes__default.default.string,
  filterAria: PropTypes__default.default.string,
  downloadIconDescription: PropTypes__default.default.string,
  openMenuAria: PropTypes__default.default.string,
  closeMenuAria: PropTypes__default.default.string,
  clearSelectionAria: PropTypes__default.default.string,
  batchCancel: PropTypes__default.default.string,
  toolbarLabelAria: PropTypes__default.default.string,
  /** String 'items selected' or function receiving the selectedCount as param:
   * (selectedCount) => `${selectedCount} items selected` */
  itemsSelected: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.func]),
  /** String 'item selected' or function receiving the selectedCount as param:
   * (selectedCount) => `${selectedCount} item selected` */
  itemSelected: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.func]),
  /** Row actions in table body */
  /** I18N label for in progress */
  inProgressText: PropTypes__default.default.string,
  /** I18N label for action failed */
  actionFailedText: PropTypes__default.default.string,
  /** I18N label for learn more */
  learnMoreText: PropTypes__default.default.string,
  /** I18N label for dismiss */
  dismissText: PropTypes__default.default.string,
  filterNone: PropTypes__default.default.string,
  filterAscending: PropTypes__default.default.string,
  filterDescending: PropTypes__default.default.string,
  rowCountInHeader: PropTypes__default.default.func,
  toggleAggregations: PropTypes__default.default.string,
  multiSortModalTitle: PropTypes__default.default.string,
  multiSortModalPrimaryLabel: PropTypes__default.default.string,
  multiSortModalSecondaryLabel: PropTypes__default.default.string,
  multiSortModalClearLabel: PropTypes__default.default.string,
  multiSortSelectColumnLabel: PropTypes__default.default.string,
  multiSortSelectColumnSortByTitle: PropTypes__default.default.string,
  multiSortSelectColumnThenByTitle: PropTypes__default.default.string,
  multiSortDirectionLabel: PropTypes__default.default.string,
  multiSortDirectionTitle: PropTypes__default.default.string,
  multiSortAddColumn: PropTypes__default.default.string,
  multiSortRemoveColumn: PropTypes__default.default.string,
  multiSortAscending: PropTypes__default.default.string,
  multiSortDescending: PropTypes__default.default.string,
  multiSortCloseModal: PropTypes__default.default.string,
  multiSortOpenMenu: PropTypes__default.default.string,
  multiSortCloseMenu: PropTypes__default.default.string,
  multiSortDragHandle: PropTypes__default.default.string,
  /** I18N label for load more row */
  loadMoreText: PropTypes__default.default.string,
  /** aria-label applied to the tooltip in the toolbar (if given) */
  toolbarTooltipLabel: PropTypes__default.default.string,
  /** tooltip text for filter row icon button */
  filterRowIconDescription: PropTypes__default.default.string,
  /** button label for batch action overflow menu */
  batchActionsOverflowMenuText: PropTypes__default.default.string,
  /** overflow menu text callback for truncated filter tags */
  filterTagsOverflowMenuText: PropTypes__default.default.oneOfType([PropTypes__default.default.func, PropTypes__default.default.string]),
  /** I18N label for search icon in toolbar */
  toolbarSearchIconDescription: PropTypes__default.default.string
});
var defaultI18NPropTypes = {
  /** pagination */
  pageBackwardAria: 'Previous page',
  pageForwardAria: 'Next page',
  pageNumberAria: 'Page Number',
  itemsPerPage: 'Items per page:',
  itemsRangeWithTotal: function itemsRangeWithTotal(min, max, total) {
    return "".concat(min, "\u2013").concat(max, " of ").concat(total, " items");
  },
  pageRange: function pageRange(current, total) {
    return "of ".concat(total, " pages");
  },
  /** table body */
  overflowMenuAria: 'More actions',
  clickToExpandAria: 'Click to expand content',
  clickToCollapseAria: 'Click to collapse content',
  selectAllAria: 'Select all items',
  selectRowAria: 'Select row',
  /** toolbar */
  clearAllFilters: 'Clear all filters',
  columnSelectionButtonAria: 'Column Selection',
  columnSelectionConfig: 'Manage columns',
  filterButtonAria: 'Filters',
  editButtonAria: 'Edit rows',
  searchLabel: 'Search',
  searchPlaceholder: 'Search',
  clearFilterAria: 'Clear filter',
  filterAria: 'Filter',
  openMenuAria: 'Open menu',
  closeMenuAria: 'Close menu',
  clearSelectionAria: 'Clear selection',
  batchCancel: 'Cancel',
  itemsSelected: function itemsSelected(selectedCount) {
    return "".concat(selectedCount, " items selected");
  },
  itemSelected: function itemSelected(selectedCount) {
    return "".concat(selectedCount, " item selected");
  },
  applyButtonText: 'Apply filters',
  cancelButtonText: 'Cancel',
  advancedFilterLabelText: 'Select an existing filter or',
  createNewAdvancedFilterText: 'create a new advanced filter',
  advancedFilterPlaceholderText: 'Select a filter',
  simpleFiltersTabLabel: 'Simple filters',
  advancedFiltersTabLabel: 'Advanced filters',
  /** empty state */
  emptyMessage: 'There is no data',
  emptyMessageWithFilters: 'No results match the current filters',
  emptyButtonLabel: 'Create some data',
  emptyButtonLabelWithFilters: 'Clear all filters',
  filterNone: 'Unsort rows by this header',
  filterAscending: 'Sort rows by this header in ascending order',
  filterDescending: 'Sort rows by this header in descending order',
  rowCountInHeader: function rowCountInHeader(totalRowCount) {
    return "Results: ".concat(totalRowCount);
  },
  toggleAggregations: 'Toggle aggregations',
  multiSortModalTitle: 'Select columns to sort',
  multiSortModalPrimaryLabel: 'Sort',
  multiSortModalSecondaryLabel: 'Cancel',
  multiSortSelectColumnLabel: 'Select a column',
  multiSortSelectColumnSortByTitle: 'Sort by',
  multiSortSelectColumnThenByTitle: 'Then by',
  multiSortDirectionLabel: 'Select a direction',
  multiSortDirectionTitle: 'Sort order',
  multiSortAddColumn: 'Add column',
  multiSortRemoveColumn: 'Remove column',
  multiSortAscending: 'Ascending',
  multiSortDescending: 'Descending',
  multiSortCloseModal: 'Close',
  multiSortOpenMenu: 'Open menu',
  multiSortCloseMenu: 'Close menu',
  multiSortDragHandle: 'Drag handle',
  toolbarTooltipLabel: 'Toolbar tooltip'
};
var TableSearchPropTypes = PropTypes__default.default.shape({
  value: deprecate(PropTypes__default.default.string, '\n The prop `value` has been deprecated in favor of `defaultValue`'),
  defaultValue: PropTypes__default.default.string,
  defaultExpanded: PropTypes__default.default.bool,
  onChange: deprecate(PropTypes__default.default.func, '\n The prop `onChange` has been deprecated in favor of `onApplySearch` in table actions object'),
  onExpand: deprecate(PropTypes__default.default.func, '\n The prop `onExpand` has been deprecated in favor of `onSearchExpand` in table actions object'),
  isExpanded: PropTypes__default.default.bool
});

/** Which toolbar is currently active */
var ActiveTableToolbarPropType = PropTypes__default.default.oneOf(['column', 'filter', 'rowEdit']);
var TableSortPropType = PropTypes__default.default.shape({
  columnId: PropTypes__default.default.string,
  direction: PropTypes__default.default.oneOf(['NONE', 'ASC', 'DESC'])
});

/** Specify the properties of each column group in the table */
var TableColumnGroupPropType = PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
  id: PropTypes__default.default.string,
  name: PropTypes__default.default.string
}));

/** Specify the order, visibility and group belonging of the table columns */
var TableOrderingPropType = PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
  columnId: PropTypes__default.default.string.isRequired,
  /* Visibility of column in table, defaults to false */
  isHidden: PropTypes__default.default.bool,
  /* The id of the column group this column belongs to if any */
  columnGroupId: PropTypes__default.default.string
}));
var TableFiltersPropType = PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
  columnId: PropTypes__default.default.string.isRequired,
  value: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number, PropTypes__default.default.bool, PropTypes__default.default.arrayOf(PropTypes__default.default.string)]).isRequired
}));
var TableSharedActionPropTypes = {
  id: PropTypes__default.default.string.isRequired,
  /** the item is displayed, but disabled */
  disabled: PropTypes__default.default.bool,
  /** the text for the option */
  labelText: PropTypes__default.default.string.isRequired,
  /** filters out the option so it isn't displayed */
  hidden: PropTypes__default.default.bool,
  /** the icon to render for this action */
  renderIcon: PropTypes__default.default.oneOfType([PropTypes__default.default.shape({
    width: PropTypes__default.default.string,
    height: PropTypes__default.default.string,
    viewBox: PropTypes__default.default.string.isRequired,
    svgData: SharedPropTypes.SvgPropType.isRequired
  }), PropTypes__default.default.oneOf(bundledIcons.bundledIconNames), PropTypes__default.default.node, PropTypes__default.default.object, PropTypes__default.default.func])
};
var TableSharedOverflowMenuPropTypes = _objectSpread(_objectSpread({}, TableSharedActionPropTypes), {}, {
  /** displays the option in red */
  isDelete: PropTypes__default.default.bool,
  /** show a divider above this item */
  hasDivider: PropTypes__default.default.bool,
  /** should this action be shown in the overflow menu */
  isOverflow: PropTypes__default.default.bool
});
var TableToolbarActionsPropType = PropTypes__default.default.oneOfType([/** allow the actions to be generated dynamically by a callback */
PropTypes__default.default.func, PropTypes__default.default.arrayOf(PropTypes__default.default.shape(_objectSpread(_objectSpread({}, TableSharedOverflowMenuPropTypes), {}, {
  /** only used for actions in the toolbar (not overflow menu) to show when they are active */
  isActive: PropTypes__default.default.bool
})))]);
var PinColumnPropTypes = PropTypes__default.default.oneOf(Object.values(tableUtilities.PIN_COLUMN));

exports.ActiveTableToolbarPropType = ActiveTableToolbarPropType;
exports.EmptyStatePropTypes = EmptyStatePropTypes;
exports.ExpandedRowsPropTypes = ExpandedRowsPropTypes;
exports.I18NPropTypes = I18NPropTypes;
exports.PinColumnPropTypes = PinColumnPropTypes;
exports.RowActionErrorPropTypes = RowActionErrorPropTypes;
exports.RowActionPropTypes = RowActionPropTypes;
exports.RowActionsStatePropTypes = RowActionsStatePropTypes;
exports.TableColumnGroupPropType = TableColumnGroupPropType;
exports.TableColumnsPropTypes = TableColumnsPropTypes;
exports.TableFiltersPropType = TableFiltersPropType;
exports.TableOrderingPropType = TableOrderingPropType;
exports.TableRowPropTypes = TableRowPropTypes;
exports.TableRowsPropTypes = TableRowsPropTypes;
exports.TableSearchPropTypes = TableSearchPropTypes;
exports.TableSharedActionPropTypes = TableSharedActionPropTypes;
exports.TableSharedOverflowMenuPropTypes = TableSharedOverflowMenuPropTypes;
exports.TableSortPropType = TableSortPropType;
exports.TableToolbarActionsPropType = TableToolbarActionsPropType;
exports.defaultI18NPropTypes = defaultI18NPropTypes;
