"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var igd_core_1 = require("@intelligentgraphics/igd.core");
var Types_1 = require("./Types");
var filterFunctions = (_a = {},
    _a[Types_1.CatalogViewContentFilter.onlyFolderLike] = function (items) {
        return items.filter(function (item) {
            return item.Type === igd_core_1.IGXA.EItemType.MultiArticle ||
                item.Type === igd_core_1.IGXA.EItemType.Folder;
        });
    },
    _a[Types_1.CatalogViewContentFilter.onlyArticleLike] = function (items) {
        return items.filter(function (item) {
            return item.Type === igd_core_1.IGXA.EItemType.ArticleCom ||
                item.Type === igd_core_1.IGXA.EItemType.ArticleGfx ||
                item.Type === igd_core_1.IGXA.EItemType.Impression ||
                item.Type === igd_core_1.IGXA.EItemType.Set;
        });
    },
    _a[Types_1.CatalogViewContentFilter.onlyArticle] = function (items) {
        return items.filter(function (item) {
            return item.Type === igd_core_1.IGXA.EItemType.ArticleGfx ||
                item.Type === igd_core_1.IGXA.EItemType.ArticleCom;
        });
    },
    _a);
exports.defaultFetchContent = function (params, catalogFetcher) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
    var content, filter;
    return tslib_1.__generator(this, function (_a) {
        switch (_a.label) {
            case 0:
                if (params.addableTargetId !== undefined) {
                    return [2 /*return*/, catalogFetcher.getAddables(params.path, params.addableTargetId)];
                }
                return [4 /*yield*/, catalogFetcher.getPathContent(params.path, {
                        flat: params.flat,
                    })];
            case 1:
                content = _a.sent();
                if (params.filterContent !== undefined) {
                    filter = typeof params.filterContent === "function"
                        ? params.filterContent
                        : filterFunctions[params.filterContent];
                    return [2 /*return*/, filter(content)];
                }
                return [2 /*return*/, content];
        }
    });
}); };
