define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var SparepartsController = /** @class */ (function () {
        function SparepartsController(SparepartsService) {
            this.SparepartsService = SparepartsService;
            this.attribute = 'kopfhoerermodell';
            this.itemsPerPage = 12;
            this.headline = 'SPAREPARTS';
        }
        SparepartsController.prototype.getData = function () {
            var _this = this;
            this.SparepartsService.get('1466').then(function (data) {
                data.attributeValues.unshift('all');
                _this.attributeValues = data.attributeValues;
                _this.selectedAttributeValue = _this.attributeValues[0];
                _this.productsRaw = data.products;
            });
        };
        Object.defineProperty(SparepartsController.prototype, "products", {
            get: function () {
                var _this = this;
                var list;
                if (!this.selectedAttributeValue || this.selectedAttributeValue === 'all') {
                    list = this.productsRaw;
                }
                else {
                    list = this.productsRaw.filter(function (product) {
                        var result = product.custom_attributes.filter(function (attribute) {
                            if (attribute.attribute_code === _this.attribute) {
                                if (attribute.value instanceof Array) {
                                    return attribute.value.indexOf(_this.selectedAttributeValue) !== -1;
                                }
                                else {
                                    return attribute.value === _this.selectedAttributeValue;
                                }
                            }
                        });
                        return result.length;
                    });
                }
                return list;
            },
            enumerable: true,
            configurable: true
        });
        SparepartsController.prototype.$onInit = function () {
            this.getData();
        };
        return SparepartsController;
    }());
    exports.SparepartsController = SparepartsController;
});
//# sourceMappingURL=spareparts.controller.js.map