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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        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);
};
import { Component, Input, Output } from "@angular/core";
import { Radio } from "./radio";
import { ValueField } from "../value-field";
var RadioGroupComponent = /** @class */ (function () {
    function RadioGroupComponent() {
    }
    __decorate([
        Input("field"),
        Output("field"),
        __metadata("design:type", RadioGroupField)
    ], RadioGroupComponent.prototype, "field", void 0);
    RadioGroupComponent = __decorate([
        Component({
            selector: "path-radio-group",
            templateUrl: "radio-group.component.html"
        })
    ], RadioGroupComponent);
    return RadioGroupComponent;
}());
export { RadioGroupComponent };
var RadioGroupField = /** @class */ (function (_super) {
    __extends(RadioGroupField, _super);
    function RadioGroupField() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._radios = [];
        return _this;
    }
    Object.defineProperty(RadioGroupField.prototype, "radios", {
        get: function () {
            return this._radios;
        },
        set: function (value) {
            this._radios = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RadioGroupField.prototype, "horizontal", {
        get: function () {
            return this._horizontal;
        },
        set: function (value) {
            this._horizontal = value;
        },
        enumerable: false,
        configurable: true
    });
    RadioGroupField.prototype.setValue = function (value) {
        if (value != null) {
            value = value.toString();
        }
        _super.prototype.setValue.call(this, value);
    };
    RadioGroupField.prototype.updateValueFromGui = function (value) {
        this.setValue(value.toString());
    };
    RadioGroupField.prototype.isReadonly = function () {
        return _super.prototype.isReadonly.call(this) && this.isInitialValueSet;
    };
    RadioGroupField.prototype.fromJson = function (modelFormField) {
        _super.prototype.fromJson.call(this, modelFormField);
        this._horizontal = true;
        if (modelFormField["alignment"] != null) {
            if (modelFormField["alignment"] === "vertical") {
                this._horizontal = false;
            }
        }
        if (modelFormField["radios"] != null) {
            for (var _i = 0, _a = modelFormField["radios"]; _i < _a.length; _i++) {
                var radioModel = _a[_i];
                var radio = new Radio(this.getForm(), this.translationService);
                radio.name = radioModel.name;
                radio.key = radioModel.key;
                if (radio.key === modelFormField["defaultKey"]) {
                    this.setValue(radio.key);
                }
                this.radios.push(radio);
            }
        }
    };
    return RadioGroupField;
}(ValueField));
export { RadioGroupField };
//# sourceMappingURL=radio-group.component.js.map