"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
var core_1 = require("@angular/core");
var typescript_angular_utilities_1 = require("typescript-angular-utilities");
var __notification = typescript_angular_utilities_1.services.notification;
var simpleCardList_1 = require("./simpleCardList");
var form_1 = require("../form/form");
var async_service_1 = require("../../services/async/async.service");
var form_service_1 = require("../../services/form/form.service");
var index_1 = require("../cards/index");
var SimpleCardComponent = SimpleCardComponent_1 = (function (_super) {
    __extends(SimpleCardComponent, _super);
    function SimpleCardComponent(notification, asyncHelper, formService, guidService, parentForm, nullInjectionConflictsWithCardParameter, list) {
        var _this = _super.call(this, notification, asyncHelper, formService, guidService, parentForm) || this;
        _this.onOpen = new core_1.EventEmitter();
        _this.showContent = false;
        _this.alternatingClass = '';
        _this.list = list || _this.emptyList();
        return _this;
    }
    SimpleCardComponent.prototype.ngOnInit = function () {
        this.canOpen = this.canOpen != null ? this.canOpen : true;
    };
    SimpleCardComponent.prototype.toggle = function () {
        if (this.showContent) {
            this.close();
        }
        else {
            this.open();
        }
    };
    SimpleCardComponent.prototype.open = function () {
        if (this.canOpen && this.list.openCard()) {
            this.showContent = true;
            this.onOpen.emit(null);
        }
    };
    SimpleCardComponent.prototype.close = function () {
        if (!this.showContent || this.alwaysOpen) {
            return true;
        }
        var canClose = this.submit();
        if (canClose) {
            this.showContent = false;
        }
        return canClose;
    };
    SimpleCardComponent.prototype.emptyList = function () {
        var list = new simpleCardList_1.SimpleCardListComponent(null);
        list.openCard = function () { return true; };
        return list;
    };
    return SimpleCardComponent;
}(form_1.FormComponent));
__decorate([
    core_1.Input(),
    __metadata("design:type", Boolean)
], SimpleCardComponent.prototype, "canOpen", void 0);
__decorate([
    core_1.Input(),
    __metadata("design:type", Boolean)
], SimpleCardComponent.prototype, "alwaysOpen", void 0);
__decorate([
    core_1.Input(),
    __metadata("design:type", Boolean)
], SimpleCardComponent.prototype, "saveWhenInvalid", void 0);
__decorate([
    core_1.Input(),
    __metadata("design:type", String)
], SimpleCardComponent.prototype, "cardType", void 0);
__decorate([
    core_1.Output(),
    __metadata("design:type", core_1.EventEmitter)
], SimpleCardComponent.prototype, "onOpen", void 0);
__decorate([
    core_1.ContentChild(index_1.CardHeaderTemplate),
    __metadata("design:type", index_1.CardHeaderTemplate)
], SimpleCardComponent.prototype, "header", void 0);
__decorate([
    core_1.ContentChild(index_1.CardContentTemplate),
    __metadata("design:type", index_1.CardContentTemplate)
], SimpleCardComponent.prototype, "content", void 0);
__decorate([
    core_1.ContentChild(index_1.CardFooterTemplate),
    __metadata("design:type", index_1.CardFooterTemplate)
], SimpleCardComponent.prototype, "footer", void 0);
SimpleCardComponent = SimpleCardComponent_1 = __decorate([
    core_1.Component({
        selector: 'rlSimpleCard',
        template: require('./simpleCard.html'),
        inputs: [form_1.baseInputs.save],
        providers: [
            {
                provide: form_1.FormComponent,
                useExisting: core_1.forwardRef(function () { return SimpleCardComponent_1; }),
            },
        ],
    }),
    __param(4, core_1.Optional()), __param(4, core_1.SkipSelf()),
    __param(5, core_1.Optional()),
    __param(6, core_1.Optional()), __param(6, core_1.Inject(core_1.forwardRef(function () { return simpleCardList_1.SimpleCardListComponent; }))),
    __metadata("design:paramtypes", [__notification.NotificationService, async_service_1.AsyncHelper,
        form_service_1.FormService, typescript_angular_utilities_1.services.guid.GuidService, form_1.FormComponent,
        async_service_1.AsyncHelper,
        simpleCardList_1.SimpleCardListComponent])
], SimpleCardComponent);
exports.SimpleCardComponent = SimpleCardComponent;
var SimpleCardComponent_1;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2ltcGxlQ2FyZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInNpbXBsZUNhcmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsc0NBQXFJO0FBRXJJLDZFQUF3RDtBQUN4RCxJQUFPLGNBQWMsR0FBRyx1Q0FBUSxDQUFDLFlBQVksQ0FBQztBQUU5QyxtREFBMkQ7QUFDM0QscUNBQXlEO0FBQ3pELG9FQUFpRTtBQUNqRSxpRUFBK0Q7QUFDL0Qsd0NBQTZGO0FBYTdGLElBQWEsbUJBQW1CO0lBQVksdUNBQWE7SUFleEQsNkJBQVksWUFBZ0QsRUFDekQsV0FBd0IsRUFDeEIsV0FBd0IsRUFDeEIsV0FBc0MsRUFDZCxVQUF5QixFQUNyQyx1Q0FBb0QsRUFDRCxJQUFnQztRQU5sRyxZQVFDLGtCQUFNLFlBQVksRUFBRSxXQUFXLEVBQUUsV0FBVyxFQUFFLFdBQVcsRUFBRSxVQUFVLENBQUMsU0FFdEU7UUFwQlMsWUFBTSxHQUF1QixJQUFJLG1CQUFZLEVBQVEsQ0FBQztRQU1oRSxpQkFBVyxHQUFZLEtBQUssQ0FBQztRQUU3QixzQkFBZ0IsR0FBVyxFQUFFLENBQUM7UUFXN0IsS0FBSSxDQUFDLElBQUksR0FBRyxJQUFJLElBQUksS0FBSSxDQUFDLFNBQVMsRUFBRSxDQUFDOztJQUN0QyxDQUFDO0lBRUQ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