"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getUrlStateFilter = getUrlStateFilter;
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function getUrlStateFilter(urlState, actionRef) {
  var _actionRef$current$ge, _actionRef$current, _actionRef$current$ge2, _actionRef$current$ge3, _actionRef$current2, _actionRef$current2$s;
  var filters = Object.keys(urlState).filter(function (item) {
    return /^filter.+$/.test(item);
  });
  var urlStateParams = Object.fromEntries(filters.map(function (item) {
    var _item$split, _urlState$item, _urlState$item$join, _urlState$item$split, _urlState$item2, _urlState$item2$split;
    return [(_item$split = item.split('filter')) === null || _item$split === void 0 ? void 0 : _item$split[1], {
      params: Array.isArray(urlState === null || urlState === void 0 ? void 0 : urlState[item]) ? urlState === null || urlState === void 0 ? void 0 : (_urlState$item = urlState[item]) === null || _urlState$item === void 0 ? void 0 : (_urlState$item$join = _urlState$item.join) === null || _urlState$item$join === void 0 ? void 0 : _urlState$item$join.call(_urlState$item, ',') : urlState === null || urlState === void 0 ? void 0 : urlState[item],
      rules: Array.isArray(urlState === null || urlState === void 0 ? void 0 : urlState[item]) ? urlState === null || urlState === void 0 ? void 0 : urlState[item] : (_urlState$item$split = urlState === null || urlState === void 0 ? void 0 : (_urlState$item2 = urlState[item]) === null || _urlState$item2 === void 0 ? void 0 : (_urlState$item2$split = _urlState$item2.split) === null || _urlState$item2$split === void 0 ? void 0 : _urlState$item2$split.call(_urlState$item2, ',')) !== null && _urlState$item$split !== void 0 ? _urlState$item$split : []
    }];
  }));
  var rules = (_actionRef$current$ge = (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$ge2 = _actionRef$current.getState) === null || _actionRef$current$ge2 === void 0 ? void 0 : (_actionRef$current$ge3 = _actionRef$current$ge2.call(_actionRef$current)) === null || _actionRef$current$ge3 === void 0 ? void 0 : _actionRef$current$ge3.filterRules) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {};
  // 再设置所有的列筛选状态
  (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$s = _actionRef$current2.setFilterRules) === null || _actionRef$current2$s === void 0 ? void 0 : _actionRef$current2$s.call(_actionRef$current2, _objectSpread(_objectSpread({}, rules), urlStateParams));
}