import { __awaiter, __decorate, __generator, __values } from "tslib";
import { Pipe } from '@angular/core';
var ColumnCommandFilterPipe = /** @class */ (function () {
    function ColumnCommandFilterPipe() {
    }
    ColumnCommandFilterPipe.prototype.transform = function (commands, item) {
        return __awaiter(this, void 0, void 0, function () {
            var results, commands_1, commands_1_1, command, hiddenByItem, hidden, e_1_1;
            var e_1, _a;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        results = [];
                        if (!commands) {
                            return [2 /*return*/, results];
                        }
                        _b.label = 1;
                    case 1:
                        _b.trys.push([1, 8, 9, 10]);
                        commands_1 = __values(commands), commands_1_1 = commands_1.next();
                        _b.label = 2;
                    case 2:
                        if (!!commands_1_1.done) return [3 /*break*/, 7];
                        command = commands_1_1.value;
                        hiddenByItem = command.hiddenByItem;
                        if (!!hiddenByItem) return [3 /*break*/, 3];
                        results.push(command);
                        return [3 /*break*/, 6];
                    case 3:
                        hidden = hiddenByItem(item);
                        if (!(hidden instanceof Promise)) return [3 /*break*/, 5];
                        return [4 /*yield*/, hidden];
                    case 4:
                        if (!(_b.sent())) {
                            results.push(command);
                        }
                        return [3 /*break*/, 6];
                    case 5:
                        if (!hidden) {
                            results.push(command);
                        }
                        _b.label = 6;
                    case 6:
                        commands_1_1 = commands_1.next();
                        return [3 /*break*/, 2];
                    case 7: return [3 /*break*/, 10];
                    case 8:
                        e_1_1 = _b.sent();
                        e_1 = { error: e_1_1 };
                        return [3 /*break*/, 10];
                    case 9:
                        try {
                            if (commands_1_1 && !commands_1_1.done && (_a = commands_1.return)) _a.call(commands_1);
                        }
                        finally { if (e_1) throw e_1.error; }
                        return [7 /*endfinally*/];
                    case 10: return [2 /*return*/, results];
                }
            });
        });
    };
    ColumnCommandFilterPipe = __decorate([
        Pipe({
            name: 'columnCommandFilter'
        })
    ], ColumnCommandFilterPipe);
    return ColumnCommandFilterPipe;
}());
export { ColumnCommandFilterPipe };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWx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