'use strict';

var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var isEqual = require('../../../node_modules/lodash-es/isEqual.js');
var memoize = require('../../../node_modules/lodash-es/memoize.js');
require('core-js/modules/es.symbol.js');
require('core-js/modules/es.array.concat.js');
require('core-js/modules/es.array.filter.js');
require('core-js/modules/es.array.find.js');
require('core-js/modules/es.array.includes.js');
require('core-js/modules/es.array.map.js');
require('core-js/modules/es.array.sort.js');
require('core-js/modules/es.function.name.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/es.string.includes.js');
require('core-js/modules/web.dom-collections.for-each.js');
var react = require('@carbon/react');
var React = require('react');
var classnames = require('classnames');
var PropTypes = require('prop-types');
var Settings = require('../../../constants/Settings.js');
var FlyoutMenu = require('../../FlyoutMenu/FlyoutMenu.js');
var componentUtilityFunctions = require('../../../utils/componentUtilityFunctions.js');
var iconsReact = require('@carbon/icons-react');

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

var _toConsumableArray__default = /*#__PURE__*/_interopDefault(_toConsumableArray);
var _slicedToArray__default = /*#__PURE__*/_interopDefault(_slicedToArray);
var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
var React__default = /*#__PURE__*/_interopDefault(React);
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
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 iotPrefix = Settings.settings.iotPrefix,
  prefix = Settings.settings.prefix;
var itemToString = function itemToString(key) {
  return function (item) {
    var _item$key;
    return (_item$key = item === null || item === void 0 ? void 0 : item[key]) !== null && _item$key !== void 0 ? _item$key : '';
  };
};
var propTypes = {
  columns: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
    id: PropTypes__default.default.string,
    /** When false, no filter shows */
    isFilterable: PropTypes__default.default.bool,
    /** i18N text for translation */
    placeholderText: PropTypes__default.default.string,
    /** if options is empty array, assume text input for filter */
    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 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
    }),
    /** if isMultiselect and isFilterable are true, the table is filtered based on a multiselect */
    isMultiselect: PropTypes__default.default.bool,
    /** if isDate and isFilterable are true, the table is filtered base on a date picker */
    isDate: PropTypes__default.default.bool
  })).isRequired,
  tableState: PropTypes__default.default.shape({
    ordering: 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
    })).isRequired,
    filters: 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.object, PropTypes__default.default.arrayOf(PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.object]))]).isRequired
    })),
    advancedFilters: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
      /** Unique id for particular filter */
      filterId: PropTypes__default.default.string.isRequired,
      /** Text for main tilte of page */
      filterTitleText: PropTypes__default.default.string.isRequired
    })),
    advancedFilterFlyoutOpen: PropTypes__default.default.bool,
    selectedAdvancedFilterIds: PropTypes__default.default.arrayOf(PropTypes__default.default.string),
    isDisabled: PropTypes__default.default.bool
  }),
  actions: PropTypes__default.default.shape({
    onApplyAdvancedFilter: PropTypes__default.default.func,
    onCancelAdvancedFilter: PropTypes__default.default.func,
    onCreateAdvancedFilter: PropTypes__default.default.func,
    onChangeAdvancedFilter: PropTypes__default.default.func,
    onToggleAdvancedFilter: PropTypes__default.default.func
  }),
  i18n: PropTypes__default.default.shape({
    applyButtonText: PropTypes__default.default.string,
    cancelButtonText: PropTypes__default.default.string,
    advancedFilterLabelText: PropTypes__default.default.string,
    createNewAdvancedFilterText: PropTypes__default.default.string,
    advancedFilterPlaceholderText: PropTypes__default.default.string,
    simpleFiltersTabLabel: PropTypes__default.default.string,
    advancedFiltersTabLabel: PropTypes__default.default.string,
    clearAllFilters: PropTypes__default.default.string,
    filterAria: PropTypes__default.default.string,
    openMenuAria: PropTypes__default.default.string,
    closeMenuAria: PropTypes__default.default.string,
    clearSelectionAria: PropTypes__default.default.string,
    toolbarIconLabelText: PropTypes__default.default.string
  })
};
var reduceFilterState = function reduceFilterState(filters, selectedAdvancedFilterIds) {
  var simple = {};
  var advanced = {
    filterIds: []
  };
  if (Array.isArray(filters) && filters.length) {
    simple = filters.reduce(function (state, _ref) {
      var columnId = _ref.columnId,
        value = _ref.value;
      return _objectSpread(_objectSpread({}, state), {}, _defineProperty__default.default({}, columnId, value));
    }, {});
  }
  if (Array.isArray(selectedAdvancedFilterIds) && selectedAdvancedFilterIds.length) {
    advanced = {
      filterIds: selectedAdvancedFilterIds
    };
  }
  return {
    simple: simple,
    advanced: advanced
  };
};
var defaultProps = {
  tableState: {
    filters: [],
    advancedFilters: [],
    advancedFilterFlyoutOpen: false,
    selectedAdvancedFilterIds: [],
    isDisabled: false
  },
  actions: {
    onApplyAdvancedFilter: componentUtilityFunctions.defaultFunction('on AdvancedFilter'),
    onCancelAdvancedFilter: componentUtilityFunctions.defaultFunction('onCancelAdvancedFilter'),
    onCreateAdvancedFilter: componentUtilityFunctions.defaultFunction('onCreateAdvancedFilter'),
    onChangeAdvancedFilter: componentUtilityFunctions.defaultFunction('onChangeAdvancedFilter'),
    onToggleAdvancedFilter: componentUtilityFunctions.defaultFunction('onToggleAdvancedFilter')
  },
  i18n: {
    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',
    filterAria: 'Filter',
    openMenuAria: 'Open menu',
    closeMenuAria: 'Close menu',
    clearSelectionAria: 'Clear selection',
    clearFilterAria: 'Clear filter',
    toolbarIconLabelText: 'Toggle advanced filters'
  }
};
var TableToolbarAdvancedFilterFlyout = function TableToolbarAdvancedFilterFlyout(_ref2) {
  var columns = _ref2.columns,
    _ref2$tableState = _ref2.tableState,
    ordering = _ref2$tableState.ordering,
    filters = _ref2$tableState.filters,
    advancedFilters = _ref2$tableState.advancedFilters,
    advancedFilterFlyoutOpen = _ref2$tableState.advancedFilterFlyoutOpen,
    selectedAdvancedFilterIds = _ref2$tableState.selectedAdvancedFilterIds,
    isDisabled = _ref2$tableState.isDisabled,
    i18n = _ref2.i18n,
    _ref2$actions = _ref2.actions,
    onApplyAdvancedFilter = _ref2$actions.onApplyAdvancedFilter,
    onCancelAdvancedFilter = _ref2$actions.onCancelAdvancedFilter,
    onCreateAdvancedFilter = _ref2$actions.onCreateAdvancedFilter,
    onChangeAdvancedFilter = _ref2$actions.onChangeAdvancedFilter,
    onToggleAdvancedFilter = _ref2$actions.onToggleAdvancedFilter;
  var _defaultProps$i18n = _objectSpread(_objectSpread({}, defaultProps.i18n), i18n !== null && i18n !== void 0 ? i18n : {}),
    applyButtonText = _defaultProps$i18n.applyButtonText,
    cancelButtonText = _defaultProps$i18n.cancelButtonText,
    advancedFilterLabelText = _defaultProps$i18n.advancedFilterLabelText,
    createNewAdvancedFilterText = _defaultProps$i18n.createNewAdvancedFilterText,
    advancedFilterPlaceholderText = _defaultProps$i18n.advancedFilterPlaceholderText,
    simpleFiltersTabLabel = _defaultProps$i18n.simpleFiltersTabLabel,
    advancedFiltersTabLabel = _defaultProps$i18n.advancedFiltersTabLabel,
    filterAria = _defaultProps$i18n.filterAria,
    openMenuAria = _defaultProps$i18n.openMenuAria,
    closeMenuAria = _defaultProps$i18n.closeMenuAria,
    clearSelectionAria = _defaultProps$i18n.clearSelectionAria,
    clearFilterAria = _defaultProps$i18n.clearFilterAria,
    toolbarIconLabelText = _defaultProps$i18n.toolbarIconLabelText;
  var _useState = React.useState(reduceFilterState(filters, selectedAdvancedFilterIds)),
    _useState2 = _slicedToArray__default.default(_useState, 2),
    filterState = _useState2[0],
    setFilterState = _useState2[1];
  var previousFilters = React.useRef(null);
  React.useEffect(function () {
    if (!isEqual(previousFilters.current, {
      filters: filters,
      selectedAdvancedFilterIds: selectedAdvancedFilterIds
    })) {
      var newState = reduceFilterState(filters, selectedAdvancedFilterIds);
      if (!isEqual(newState, filterState)) {
        setFilterState(newState);
        onApplyAdvancedFilter(newState);
      }
    }
  }, [filterState, filters, onApplyAdvancedFilter, selectedAdvancedFilterIds]);
  React.useEffect(function () {
    previousFilters.current = {
      filters: filters,
      selectedAdvancedFilterIds: selectedAdvancedFilterIds
    };
  });
  var handleClearFilter = React.useCallback(function (event, _ref3) {
    var id = _ref3.id;
    setFilterState(function (prev) {
      return _objectSpread(_objectSpread({}, prev), {}, {
        simple: _objectSpread(_objectSpread({}, prev.simple), {}, _defineProperty__default.default({}, id, ''))
      });
    });
  }, []);
  var handleTranslation = React.useCallback(function (idToTranslate) {
    switch (idToTranslate) {
      default:
        return '';
      case 'clear.selection':
        return clearSelectionAria;
      case 'clear.all':
        return clearSelectionAria;
      case 'open.menu':
        return openMenuAria;
      case 'close.menu':
        return closeMenuAria;
    }
  }, [clearSelectionAria, closeMenuAria, openMenuAria]);
  return /*#__PURE__*/React__default.default.createElement(FlyoutMenu.default, {
    testId: "advanced-filter-flyout",
    iconDescription: toolbarIconLabelText,
    className: "".concat(iotPrefix, "--table-toolbar__advanced-filters-button-wrapper"),
    direction: FlyoutMenu.FlyoutMenuDirection.BottomEnd,
    disabled: isDisabled,
    renderIcon: iconsReact.Filter,
    hideTooltip: false,
    light: true,
    isOpen: advancedFilterFlyoutOpen,
    onApply: function onApply() {
      onApplyAdvancedFilter(filterState);
    },
    onCancel: function onCancel() {
      setFilterState(reduceFilterState(filters, selectedAdvancedFilterIds));
      onCancelAdvancedFilter();
    },
    buttonProps: {
      size: 'lg',
      className: classnames__default.default("".concat(prefix, "--btn--icon-only"), "".concat(iotPrefix, "--tooltip-svg-wrapper"), "".concat(iotPrefix, "--table-toolbar__advanced-filters-button"), _defineProperty__default.default({}, "".concat(iotPrefix, "--table-toolbar-button-active"), advancedFilterFlyoutOpen)),
      onClick: onToggleAdvancedFilter,
      tooltipPosition: 'bottom'
    },
    i18n: {
      applyButtonText: applyButtonText,
      cancelButtonText: cancelButtonText
    }
  }, /*#__PURE__*/React__default.default.createElement(react.Tabs, {
    className: "".concat(iotPrefix, "--advanced-filter__tab-container")
  }, /*#__PURE__*/React__default.default.createElement(react.TabList, {
    "aria-label": "advanced-filter-flyout-tab"
  }, /*#__PURE__*/React__default.default.createElement(react.Tab, {
    title: simpleFiltersTabLabel
  }, simpleFiltersTabLabel), /*#__PURE__*/React__default.default.createElement(react.Tab, {
    title: advancedFiltersTabLabel
  }, advancedFiltersTabLabel)), /*#__PURE__*/React__default.default.createElement(react.TabPanels, null, /*#__PURE__*/React__default.default.createElement(react.TabPanel, null, ordering.filter(function (column) {
    var fullColumn = columns.find(function (item) {
      return column.columnId === item.id;
    });
    return !column.isHidden && (fullColumn === null || fullColumn === void 0 ? void 0 : fullColumn.isFilterable) === true;
  }).reduce(function (chunks, item, index) {
    var newChunks = _toConsumableArray__default.default(chunks);
    var chunkIndex = Math.floor(index / 2);
    if (!chunks[chunkIndex]) {
      newChunks[chunkIndex] = [];
    }
    newChunks[chunkIndex] = [].concat(_toConsumableArray__default.default(newChunks[chunkIndex]), [item]);
    return newChunks;
  }, []).map(function (aRow, rowIndex) {
    return /*#__PURE__*/React__default.default.createElement("div", {
      key: "simple-filter-row-".concat(rowIndex),
      className: "".concat(iotPrefix, "--filter-flyout__simple-row")
    }, aRow.map(function (aColumn, columnIndex) {
      var _filterState$simple2, _filterState$simple3;
      var column = columns.find(function (item) {
        return aColumn.columnId === item.id;
      });
      var columnFilterValue = filterState === null || filterState === void 0 ? void 0 : filterState.simple[column.id];
      var filterColumnOptions = function filterColumnOptions(options) {
        options.sort(function (a, b) {
          return a.text.localeCompare(b.text, {
            sensitivity: 'base'
          });
        });
        return options;
      };
      var memoizeColumnOptions = memoize(filterColumnOptions); // TODO: this memoize isn't really working, should refactor to a higher column level
      if (column.isDate) {
        var _column$dateOptions, _column$dateOptions2, _filterState$simple;
        return /*#__PURE__*/React__default.default.createElement(react.FormItem, {
          key: "simple-filter-item-".concat(rowIndex, "-").concat(columnIndex),
          className: "".concat(iotPrefix, "--filter-flyout__simple-field")
        }, /*#__PURE__*/React__default.default.createElement(react.DatePicker, {
          key: "datepicker-".concat(rowIndex, "-").concat(columnIndex, "-").concat(columnFilterValue),
          datePickerType: "single",
          locale: (column === null || column === void 0 || (_column$dateOptions = column.dateOptions) === null || _column$dateOptions === void 0 ? void 0 : _column$dateOptions.locale) || 'en',
          dateFormat: (column === null || column === void 0 || (_column$dateOptions2 = column.dateOptions) === null || _column$dateOptions2 === void 0 ? void 0 : _column$dateOptions2.dateFormat) || 'Y-m-d',
          id: "column-".concat(rowIndex, "-").concat(columnIndex),
          value: filterState === null || filterState === void 0 || (_filterState$simple = filterState.simple) === null || _filterState$simple === void 0 ? void 0 : _filterState$simple[column.id],
          onChange: function onChange(evt) {
            setFilterState(function (prev) {
              return _objectSpread(_objectSpread({}, prev), {}, {
                simple: _objectSpread(_objectSpread({}, prev.simple), {}, _defineProperty__default.default({}, column.id, evt[0]))
              });
            });
          }
        }, /*#__PURE__*/React__default.default.createElement(react.DatePickerInput, {
          className: "".concat(iotPrefix, "--lelele"),
          placeholder: column.placeholderText || 'enter a date',
          labelText: column.name,
          id: "column-".concat(rowIndex, "-").concat(columnIndex)
        })));
      }
      if (column.options) {
        if (column.isMultiselect) {
          return /*#__PURE__*/React__default.default.createElement(react.FilterableMultiSelect, {
            className: "".concat(iotPrefix, "--filter-flyout__simple-field"),
            key: "multiselect-".concat(rowIndex, "-").concat(columnIndex, "-").concat(columnFilterValue),
            id: "column-".concat(rowIndex, "-").concat(columnIndex),
            "aria-label": filterAria,
            placeholder: column.placeholderText || 'Choose an option',
            translateWithId: handleTranslation,
            items: memoizeColumnOptions(column.options),
            label: column.placeholderText || 'Choose an option',
            itemToString: itemToString('text'),
            titleText: column.name,
            initialSelectedItems: componentUtilityFunctions.getMultiSelectItems(column, columnFilterValue),
            onChange: function onChange(evt) {
              var selectedItems = evt.selectedItems;
              setFilterState(function (prev) {
                return _objectSpread(_objectSpread({}, prev), {}, {
                  simple: _objectSpread(_objectSpread({}, prev.simple), {}, _defineProperty__default.default({}, column.id, selectedItems.map(componentUtilityFunctions.getMultiselectFilterValue)))
                });
              });
            }
          });
        }
        return /*#__PURE__*/React__default.default.createElement(react.ComboBox, {
          className: "".concat(iotPrefix, "--filter-flyout__simple-field"),
          key: "combobox-".concat(rowIndex, "-").concat(columnIndex, "-").concat(columnFilterValue),
          id: "column-".concat(columnIndex),
          "aria-label": filterAria,
          translateWithId: handleTranslation,
          items: memoizeColumnOptions(column.options),
          itemToString: itemToString('text'),
          initialSelectedItem: {
            id: columnFilterValue,
            text: componentUtilityFunctions.getAppliedFilterText(column, columnFilterValue)
          },
          placeholder: column.placeholderText || 'Choose an option',
          titleText: column.name,
          onChange: function onChange(evt) {
            var selectedItem = evt.selectedItem;
            setFilterState(function (prev) {
              return _objectSpread(_objectSpread({}, prev), {}, {
                simple: _objectSpread(_objectSpread({}, prev.simple), {}, _defineProperty__default.default({}, column.id, componentUtilityFunctions.getFilterValue(selectedItem)))
              });
            });
          }
        });
      }
      return /*#__PURE__*/React__default.default.createElement(react.FormItem, {
        key: "simple-filter-item-".concat(rowIndex, "-").concat(columnIndex),
        className: "".concat(iotPrefix, "--filter-flyout__simple-field")
      }, /*#__PURE__*/React__default.default.createElement(react.TextInput, {
        id: column.id,
        labelText: column.name,
        placeholder: column.placeholderText || 'Type and hit enter to apply',
        title: (filterState === null || filterState === void 0 ? void 0 : filterState[column.id]) || column.placeholderText,
        onChange: function onChange(event) {
          var value = event.target.value;
          setFilterState(function (prev) {
            return _objectSpread(_objectSpread({}, prev), {}, {
              simple: _objectSpread(_objectSpread({}, prev.simple), {}, _defineProperty__default.default({}, column.id, value))
            });
          });
        },
        defaultValue: filterState === null || filterState === void 0 || (_filterState$simple2 = filterState.simple) === null || _filterState$simple2 === void 0 ? void 0 : _filterState$simple2[column.id]
      }), filterState !== null && filterState !== void 0 && (_filterState$simple3 = filterState.simple) !== null && _filterState$simple3 !== void 0 && _filterState$simple3[column.id] ? /*#__PURE__*/React__default.default.createElement("div", {
        role: "button",
        className: classnames__default.default("".concat(prefix, "--list-box__selection"), _defineProperty__default.default({}, "".concat(iotPrefix, "--clear-filters-button--disabled"), isDisabled)),
        tabIndex: isDisabled ? '-1' : '0',
        onClick: function onClick(event) {
          if (!isDisabled) {
            handleClearFilter(event, column);
          }
        },
        onKeyDown: function onKeyDown(event) {
          return componentUtilityFunctions.handleEnterKeyDown(event, function () {
            if (!isDisabled) {
              handleClearFilter(event, column);
            }
          });
        },
        title: clearFilterAria
      }, /*#__PURE__*/React__default.default.createElement(iconsReact.Close, {
        description: clearFilterAria
      })) : null);
    }));
  })), /*#__PURE__*/React__default.default.createElement(react.TabPanel, null, /*#__PURE__*/React__default.default.createElement(react.MultiSelect, {
    id: "advanced-filter-multiselect",
    titleText: /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, advancedFilterLabelText, ' ', /*#__PURE__*/React__default.default.createElement(react.Button, {
      className: "".concat(iotPrefix, "--advanced-filter__inline-button"),
      kind: "ghost",
      onClick: onCreateAdvancedFilter
    }, createNewAdvancedFilterText)),
    onChange: function onChange(e) {
      onChangeAdvancedFilter(e);
      setFilterState(function (prev) {
        var _e$selectedItems$map, _e$selectedItems;
        return _objectSpread(_objectSpread({}, prev), {}, {
          advanced: {
            filterIds: (_e$selectedItems$map = (_e$selectedItems = e.selectedItems) === null || _e$selectedItems === void 0 ? void 0 : _e$selectedItems.map(function (advFilter) {
              return advFilter.filterId;
            })) !== null && _e$selectedItems$map !== void 0 ? _e$selectedItems$map : []
          }
        });
      });
    },
    itemToString: itemToString('filterTitleText'),
    items: advancedFilters !== null && advancedFilters !== void 0 ? advancedFilters : [],
    initialSelectedItems: advancedFilters === null || advancedFilters === void 0 ? void 0 : advancedFilters.filter(function (advFilter) {
      return selectedAdvancedFilterIds.includes(advFilter.filterId);
    }),
    label: advancedFilterPlaceholderText
  })))));
};
TableToolbarAdvancedFilterFlyout.propTypes = propTypes;
TableToolbarAdvancedFilterFlyout.defaultProps = defaultProps;
TableToolbarAdvancedFilterFlyout.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "TableToolbarAdvancedFilterFlyout",
  "props": {
    "tableState": {
      "defaultValue": {
        "value": "{\n  filters: [],\n  advancedFilters: [],\n  advancedFilterFlyoutOpen: false,\n  selectedAdvancedFilterIds: [],\n  isDisabled: false,\n}",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "shape",
        "value": {
          "ordering": {
            "name": "arrayOf",
            "value": {
              "name": "shape",
              "value": {
                "columnId": {
                  "name": "string",
                  "required": true
                },
                "isHidden": {
                  "name": "bool",
                  "required": false
                }
              }
            },
            "required": true
          },
          "filters": {
            "name": "arrayOf",
            "value": {
              "name": "shape",
              "value": {
                "columnId": {
                  "name": "string",
                  "required": true
                },
                "value": {
                  "name": "union",
                  "value": [{
                    "name": "string"
                  }, {
                    "name": "number"
                  }, {
                    "name": "bool"
                  }, {
                    "name": "object"
                  }, {
                    "name": "arrayOf",
                    "value": {
                      "name": "union",
                      "value": [{
                        "name": "string"
                      }, {
                        "name": "object"
                      }]
                    }
                  }],
                  "required": true
                }
              }
            },
            "required": false
          },
          "advancedFilters": {
            "name": "arrayOf",
            "value": {
              "name": "shape",
              "value": {
                "filterId": {
                  "name": "string",
                  "description": "Unique id for particular filter",
                  "required": true
                },
                "filterTitleText": {
                  "name": "string",
                  "description": "Text for main tilte of page",
                  "required": true
                }
              }
            },
            "required": false
          },
          "advancedFilterFlyoutOpen": {
            "name": "bool",
            "required": false
          },
          "selectedAdvancedFilterIds": {
            "name": "arrayOf",
            "value": {
              "name": "string"
            },
            "required": false
          },
          "isDisabled": {
            "name": "bool",
            "required": false
          }
        }
      },
      "required": false
    },
    "actions": {
      "defaultValue": {
        "value": "{\n  onApplyAdvancedFilter: defaultFunction('on AdvancedFilter'),\n  onCancelAdvancedFilter: defaultFunction('onCancelAdvancedFilter'),\n  onCreateAdvancedFilter: defaultFunction('onCreateAdvancedFilter'),\n  onChangeAdvancedFilter: defaultFunction('onChangeAdvancedFilter'),\n  onToggleAdvancedFilter: defaultFunction('onToggleAdvancedFilter'),\n}",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "shape",
        "value": {
          "onApplyAdvancedFilter": {
            "name": "func",
            "required": false
          },
          "onCancelAdvancedFilter": {
            "name": "func",
            "required": false
          },
          "onCreateAdvancedFilter": {
            "name": "func",
            "required": false
          },
          "onChangeAdvancedFilter": {
            "name": "func",
            "required": false
          },
          "onToggleAdvancedFilter": {
            "name": "func",
            "required": false
          }
        }
      },
      "required": false
    },
    "i18n": {
      "defaultValue": {
        "value": "{\n  applyButtonText: 'Apply filters',\n  cancelButtonText: 'Cancel',\n  advancedFilterLabelText: 'Select an existing filter or',\n  createNewAdvancedFilterText: 'create a new advanced filter',\n  advancedFilterPlaceholderText: 'Select a filter',\n  simpleFiltersTabLabel: 'Simple filters',\n  advancedFiltersTabLabel: 'Advanced filters',\n  filterAria: 'Filter',\n  openMenuAria: 'Open menu',\n  closeMenuAria: 'Close menu',\n  clearSelectionAria: 'Clear selection',\n  clearFilterAria: 'Clear filter',\n  toolbarIconLabelText: 'Toggle advanced filters',\n}",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "shape",
        "value": {
          "applyButtonText": {
            "name": "string",
            "required": false
          },
          "cancelButtonText": {
            "name": "string",
            "required": false
          },
          "advancedFilterLabelText": {
            "name": "string",
            "required": false
          },
          "createNewAdvancedFilterText": {
            "name": "string",
            "required": false
          },
          "advancedFilterPlaceholderText": {
            "name": "string",
            "required": false
          },
          "simpleFiltersTabLabel": {
            "name": "string",
            "required": false
          },
          "advancedFiltersTabLabel": {
            "name": "string",
            "required": false
          },
          "clearAllFilters": {
            "name": "string",
            "required": false
          },
          "filterAria": {
            "name": "string",
            "required": false
          },
          "openMenuAria": {
            "name": "string",
            "required": false
          },
          "closeMenuAria": {
            "name": "string",
            "required": false
          },
          "clearSelectionAria": {
            "name": "string",
            "required": false
          },
          "toolbarIconLabelText": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": false
    },
    "columns": {
      "description": "",
      "type": {
        "name": "arrayOf",
        "value": {
          "name": "shape",
          "value": {
            "id": {
              "name": "string",
              "required": false
            },
            "isFilterable": {
              "name": "bool",
              "description": "When false, no filter shows",
              "required": false
            },
            "placeholderText": {
              "name": "string",
              "description": "i18N text for translation",
              "required": false
            },
            "options": {
              "name": "arrayOf",
              "value": {
                "name": "shape",
                "value": {
                  "id": {
                    "name": "union",
                    "value": [{
                      "name": "string"
                    }, {
                      "name": "number"
                    }, {
                      "name": "bool"
                    }],
                    "required": true
                  },
                  "text": {
                    "name": "string",
                    "required": true
                  }
                }
              },
              "description": "if options is empty array, assume text input for filter",
              "required": false
            },
            "dateOptions": {
              "name": "shape",
              "value": {
                "dateFormat": {
                  "name": "string",
                  "required": false
                },
                "locale": {
                  "name": "string",
                  "required": false
                }
              },
              "description": "if dateOptions is empty array, assume a default format and locale",
              "required": false
            },
            "isMultiselect": {
              "name": "bool",
              "description": "if isMultiselect and isFilterable are true, the table is filtered based on a multiselect",
              "required": false
            },
            "isDate": {
              "name": "bool",
              "description": "if isDate and isFilterable are true, the table is filtered base on a date picker",
              "required": false
            }
          }
        }
      },
      "required": true
    }
  }
};
var TableToolbarAdvancedFilterFlyout$1 = TableToolbarAdvancedFilterFlyout;

module.exports = TableToolbarAdvancedFilterFlyout$1;
