"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.ListingPage = void 0;

var _react = _interopRequireDefault(require("react"));

var _lib = require("@sentecacommerce-theme/lib");

var _Components = require("./Components");

var _router = require("next/router");

var listingContentUnderTitleKey = 'afterTitle';

var ListingPage = function ListingPage(_ref) {
  var seoAggregates = _ref.seoAggregates,
      aggregates = _ref.aggregates,
      sortOptions = _ref.sortOptions,
      defaultSortKey = _ref.defaultSortKey,
      categoryTreeConfig = _ref.categoryTreeConfig,
      labels = _ref.labels,
      productsPerPage = _ref.productsPerPage;
  var router = (0, _router.useRouter)();
  var content = (0, _lib.useListingInjectedContent)({
    path: router.asPath,
    currentPage: router.query.page || '1'
  });
  return /*#__PURE__*/_react["default"].createElement(_lib.ListingPageProvider, {
    config: {
      seoAggregates: seoAggregates,
      aggregates: aggregates,
      categoryTreeConfig: categoryTreeConfig,
      sortOptions: sortOptions,
      defaultSortKey: defaultSortKey,
      productsPerPage: productsPerPage
    }
  }, /*#__PURE__*/_react["default"].createElement(_lib.LocalLabelsProvider, {
    labels: labels
  }, /*#__PURE__*/_react["default"].createElement(_lib.RenderInjectedContent, {
    componentList: content.before.filter(function (c) {
      var _c$positionMetadata;

      return !((_c$positionMetadata = c.positionMetadata) != null && _c$positionMetadata.includes(listingContentUnderTitleKey));
    })
  }), /*#__PURE__*/_react["default"].createElement(_lib.BasicListingSEO, null), /*#__PURE__*/_react["default"].createElement(_Components.ListingPageComponent, {
    contentInside: content.inside,
    contentUnderTitle: content.before.filter(function (c) {
      var _c$positionMetadata2;

      return (_c$positionMetadata2 = c.positionMetadata) == null ? void 0 : _c$positionMetadata2.includes(listingContentUnderTitleKey);
    })
  }), /*#__PURE__*/_react["default"].createElement(_lib.RenderInjectedContent, {
    componentList: content.after
  })));
};

exports.ListingPage = ListingPage;
//# sourceMappingURL=listingPage.component.js.map