import { __extends } from "tslib";
import { BasicBuilder } from './basic';
import { FieldArrayModel } from '../models';
import { or } from '../maybe';
var FieldArrayBuilder = (function (_super) {
    __extends(FieldArrayBuilder, _super);
    function FieldArrayBuilder(childBuilder) {
        var _this = _super.call(this) || this;
        _this.childBuilder = childBuilder;
        _this._defaultValue = [];
        return _this;
    }
    FieldArrayBuilder.prototype.defaultValue = function (defaultValue) {
        this._defaultValue = defaultValue;
        return this;
    };
    FieldArrayBuilder.prototype.build = function (defaultValue) {
        var _this = this;
        var model = new FieldArrayModel(this.childBuilder, or(defaultValue, function () { return _this._defaultValue; }));
        model.validators = this._validators;
        model.normalizeBeforeSubmit = this._normalizeBeforeSubmit;
        model.builder = this;
        return model;
    };
    FieldArrayBuilder.prototype.unwrap = function () {
        return this.childBuilder;
    };
    return FieldArrayBuilder;
}(BasicBuilder));
export { FieldArrayBuilder };
