Liferay.Loader.define("portal-workflow-metrics-web@2.0.46/js/shared/components/list/ListHeadItem.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/icon', 'portal-workflow-metrics-web$path-to-regexp', 'frontend-js-react-web$react', 'portal-workflow-metrics-web$react-router-dom'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = void 0;

    var _icon = _interopRequireDefault(require("@frontend-taglib-clay$clayui/icon"));

    var _pathToRegexp = _interopRequireDefault(require("portal-workflow-metrics-web$path-to-regexp"));

    var _react = _interopRequireDefault(require("frontend-js-react-web$react"));

    var _reactRouterDom = require("portal-workflow-metrics-web$react-router-dom");

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function ownKeys(object, enumerableOnly) {
      var keys = Object.keys(object);if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);if (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 = arguments[i] != null ? arguments[i] : {};if (i % 2) {
          ownKeys(Object(source), true).forEach(function (key) {
            _defineProperty(target, key, source[key]);
          });
        } else if (Object.getOwnPropertyDescriptors) {
          Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
        } else {
          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 _slicedToArray(arr, i) {
      return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
    }

    function _nonIterableRest() {
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
    }

    function _iterableToArrayLimit(arr, i) {
      if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
        return;
      }var _arr = [];var _n = true;var _d = false;var _e = undefined;try {
        for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
          _arr.push(_s.value);if (i && _arr.length === i) break;
        }
      } catch (err) {
        _d = true;_e = err;
      } finally {
        try {
          if (!_n && _i["return"] != null) _i["return"]();
        } finally {
          if (_d) throw _e;
        }
      }return _arr;
    }

    function _arrayWithHoles(arr) {
      if (Array.isArray(arr)) return arr;
    }

    var ListHeadItem = function ListHeadItem(_ref) {
      var iconColor = _ref.iconColor,
          iconName = _ref.iconName,
          search = _ref.location.search,
          _ref$match = _ref.match,
          params = _ref$match.params,
          path = _ref$match.path,
          name = _ref.name,
          title = _ref.title;
      var sort = params && params.sort ? params.sort : "".concat(name, ":asc");

      var _decodeURIComponent$s = decodeURIComponent(sort).split(':'),
          _decodeURIComponent$s2 = _slicedToArray(_decodeURIComponent$s, 2),
          field = _decodeURIComponent$s2[0],
          order = _decodeURIComponent$s2[1];

      var sorted = field === name;
      var nextSort = "".concat(name, ":").concat(sorted && order === 'desc' ? 'asc' : 'desc');
      var sortIcon = order === 'asc' ? 'order-arrow-up' : 'order-arrow-down';

      var pathname = _pathToRegexp.default.compile(path)(_objectSpread(_objectSpread({}, params), {}, {
        sort: nextSort
      }));

      return (/*#__PURE__*/_react.default.createElement(_reactRouterDom.Link, {
          className: "inline-item text-truncate-inline",
          to: {
            pathname: pathname,
            search: search
          }
        }, iconName && /*#__PURE__*/_react.default.createElement("span", {
          className: "inline-item inline-item-before mr-2"
        }, /*#__PURE__*/_react.default.createElement("span", {
          className: "sticker sticker-sm"
        }, /*#__PURE__*/_react.default.createElement("span", {
          className: "inline-item"
        }, /*#__PURE__*/_react.default.createElement(_icon.default, {
          className: "text-".concat(iconColor),
          symbol: iconName
        })))), /*#__PURE__*/_react.default.createElement("span", {
          className: "text-truncate title",
          "data-title": title,
          title: title
        }, title), sorted && /*#__PURE__*/_react.default.createElement("span", {
          className: "inline-item inline-item-after"
        }, /*#__PURE__*/_react.default.createElement(_icon.default, {
          symbol: sortIcon
        })))
      );
    };

    var _default = (0, _reactRouterDom.withRouter)(ListHeadItem);

    exports.default = _default;
    //# sourceMappingURL=ListHeadItem.es.js.map
  }
});
//# sourceMappingURL=ListHeadItem.es.js.map