"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        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 __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var has_1 = __importDefault(require("lodash/has"));
var store_1 = require("@angular-redux/store");
var core_1 = require("@angular/core");
var angular_1 = require("@jsonforms/angular");
var core_2 = require("@jsonforms/core");
var LabelRenderer = /** @class */ (function (_super) {
    __extends(LabelRenderer, _super);
    function LabelRenderer(ngRedux) {
        var _this = _super.call(this) || this;
        _this.ngRedux = ngRedux;
        return _this;
    }
    LabelRenderer.prototype.ngOnInit = function () {
        var _this = this;
        var labelElement = this.uischema;
        this.label =
            labelElement.text !== undefined &&
                labelElement.text !== null &&
                labelElement.text;
        this.subscription = this.ngRedux
            .select()
            .map(function (s) { return mapStateToProps(s, _this.getOwnProps()); })
            .subscribe(function (props) {
            _this.visible = props.visible;
        });
    };
    LabelRenderer.prototype.ngOnDestroy = function () {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    };
    LabelRenderer.prototype.mapAdditionalProps = function () {
        this.label = this.uischema.text;
    };
    LabelRenderer = __decorate([
        core_1.Component({
            selector: 'LabelRenderer',
            template: "\n    <label class=\"mat-title\" fxFlex> {{ label }} </label>\n  "
        }),
        __metadata("design:paramtypes", [store_1.NgRedux])
    ], LabelRenderer);
    return LabelRenderer;
}(angular_1.JsonFormsBaseRenderer));
exports.LabelRenderer = LabelRenderer;
var mapStateToProps = function (state, ownProps) {
    var visible = has_1.default(ownProps, 'visible')
        ? ownProps.visible
        : core_2.isVisible(ownProps, state);
    return {
        visible: visible
    };
};
exports.LabelRendererTester = core_2.rankWith(4, core_2.uiTypeIs('Label'));
//# sourceMappingURL=label.renderer.js.map