"use strict";

exports.__esModule = true;
exports.default = void 0;
var _isEmpty2 = _interopRequireDefault(require("lodash/fp/isEmpty"));
var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _provider = _interopRequireDefault(require("../../../atom/provider"));
var _button = _interopRequireDefault(require("../../../atom/button"));
var _filters = _interopRequireDefault(require("../../../molecule/filters"));
var _cardsGrid = _interopRequireDefault(require("../../../organism/cards-grid"));
var _cardsList = _interopRequireDefault(require("../../../molecule/dashboard/cards-list"));
var _cmPopin = _interopRequireDefault(require("../../../molecule/cm-popin"));
var _style = _interopRequireDefault(require("./style.css"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const SearchPage = (props, context) => {
  const {
    title,
    searchFilters,
    cards,
    noresultsfound,
    clearFilters,
    recommendations,
    moreSortAriaLabel,
    moreFilterAriaLabel,
    filterGroupAriaLabel,
    sortAriaLabel,
    popinWithCards
  } = props;
  const {
    skin
  } = context;
  const defaultColor = (0, _getOr2.default)('#00B0FF', 'common.primary', skin);
  const nodeRef = (0, _react.useRef)(null);
  const recommendationsView = (0, _isEmpty2.default)(recommendations) ? null : /*#__PURE__*/_react.default.createElement(_cardsList.default, recommendations);
  const cardsView = (0, _isEmpty2.default)(cards.list) ? /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.noresults
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.noresultstxt
  }, noresultsfound), /*#__PURE__*/_react.default.createElement(_button.default, _extends({}, clearFilters, {
    "data-name": "searchPageClear",
    className: _style.default.clear,
    style: {
      background: defaultColor
    },
    type: "link"
  }))), recommendationsView) : /*#__PURE__*/_react.default.createElement(_cardsGrid.default, cards);
  return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_filters.default, _extends({}, searchFilters, {
    moreSortAriaLabel: moreSortAriaLabel,
    moreFilterAriaLabel: moreFilterAriaLabel,
    filterGroupAriaLabel: filterGroupAriaLabel,
    sortAriaLabel: sortAriaLabel
  })), /*#__PURE__*/_react.default.createElement("div", {
    "data-name": "searchResult",
    className: _style.default.cardsWrapper
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.title,
    role: "status"
  }, title), cardsView), popinWithCards ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.popinWithCards,
    ref: nodeRef
  }, /*#__PURE__*/_react.default.createElement(_cmPopin.default, popinWithCards)) : null);
};
SearchPage.contextTypes = {
  skin: _provider.default.childContextTypes.skin
};
SearchPage.propTypes = process.env.NODE_ENV !== "production" ? {
  noresultsfound: _propTypes.default.string,
  title: _propTypes.default.string,
  searchFilters: _propTypes.default.shape(_filters.default.propTypes),
  cards: _propTypes.default.shape(_cardsGrid.default.propTypes),
  clearFilters: _propTypes.default.shape(_button.default.propTypes),
  recommendations: _propTypes.default.shape(_cardsList.default.propTypes),
  moreSortAriaLabel: _propTypes.default.string,
  moreFilterAriaLabel: _propTypes.default.string,
  filterGroupAriaLabel: _propTypes.default.string,
  sortAriaLabel: _propTypes.default.string,
  popinWithCards: _propTypes.default.shape(_cmPopin.default.propTypes)
} : {};
var _default = exports.default = SearchPage;
//# sourceMappingURL=index.js.map