"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CardListingContainer = void 0;
var react_1 = __importStar(require("react"));
var isEqual_1 = __importDefault(require("lodash/isEqual"));
var PageError_1 = require("../../PageError");
var PageListingNotFound_1 = require("../../PageListingNotFound");
var PageListingContext_1 = require("../PageListingContext");
var CardListingContainer = function FiltersComponent(props) {
    var _a = (0, react_1.useContext)(PageListingContext_1.PageListingContext), resources = _a.resources, skeletonResources = _a.skeletonResources, resourcesTotal = _a.resourcesTotal, currentPage = _a.currentPage, setPage = _a.setPage, showCardsSkeleton = _a.showCardsSkeleton, showCards = _a.showCards, errorLoadData = _a.errorLoadData, reloadPage = _a.reloadPage;
    return (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement(CardListingContainerComponent, { resources: resources, renderResource: props.renderResource, resourcesTotal: resourcesTotal, currentPage: currentPage, skeletonResources: skeletonResources, renderResourceSkeleton: props.renderResourceSkeleton, changePage: setPage, showCardsSkeleton: showCardsSkeleton, showCards: showCards, errorLoadData: errorLoadData, reloadPage: reloadPage })));
};
exports.CardListingContainer = CardListingContainer;
var CardListingContainerComponent = react_1.default.memo(function FiltersDesktop(props) {
    var showCards = props.showCards, showCardsSkeleton = props.showCardsSkeleton, errorLoadData = props.errorLoadData, resources = props.resources, renderResource = props.renderResource, resourcesTotal = props.resourcesTotal, skeletonResources = props.skeletonResources, renderResourceSkeleton = props.renderResourceSkeleton, currentPage = props.currentPage, changePage = props.changePage, reloadPage = props.reloadPage;
    return (react_1.default.createElement("div", { className: "cards-listing" },
        errorLoadData && react_1.default.createElement(PageError_1.PageError, { retry: reloadPage, fullscreen: true }),
        showCards &&
            !!resourcesTotal &&
            resources.map(function (resource, i) { return (react_1.default.createElement(EmptyComponent, { key: "card-".concat(resource.id) }, renderResource(resource, i))); }),
        showCards && !resourcesTotal && react_1.default.createElement(PageListingNotFound_1.PageListingNotFound, null),
        react_1.default.createElement("div", { className: "cards-listing-skeleton" }, showCardsSkeleton &&
            skeletonResources.map(function (resource, i) { return (react_1.default.createElement(EmptyComponent, { key: "card-skeleton-".concat(i) }, renderResourceSkeleton(resource, i))); }))));
}, isEqual_1.default);
function EmptyComponent(props) {
    return props.children;
}
//# sourceMappingURL=CardListingContainer.js.map