"use strict";
/**
 * Liza Field Styler Factory
 *
 *  Copyright (C) 2010-2019 R-T Specialty, LLC.
 *
 *  This file is part of the Liza Data Collection Framework
 *
 *  Liza is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldStylerFactory = void 0;
var CheckboxFieldStyler_1 = require("./CheckboxFieldStyler");
var DefaultFieldStyler_1 = require("./DefaultFieldStyler");
var DisplayFieldStyler_1 = require("./DisplayFieldStyler");
var FieldStylerFactory = /** @class */ (function () {
    /**
     * Initialize FieldStylerFactory
     *
     * TODO: Remove need for ElementStyler
     *
     * @param _qtypes - question types
     * @param _answer_refs - answer refs
     * @param _element_styler - element styler
     */
    function FieldStylerFactory(_qtypes, _answer_refs, _element_styler) {
        this._qtypes = _qtypes;
        this._answer_refs = _answer_refs;
        this._element_styler = _element_styler;
    }
    /**
     * Create field styler based on the question type
     *
     * @param name - field name
     * @param index - field index
     */
    FieldStylerFactory.prototype.create = function (name, index) {
        var _a;
        if (this._answer_refs[name] !== undefined) {
            return new DisplayFieldStyler_1.DisplayFieldStyler(this._element_styler, name, index);
        }
        var qtype = ((_a = this._qtypes[name]) === null || _a === void 0 ? void 0 : _a.type) || this._qtypes[name];
        switch (qtype) {
            case 'radio':
            case 'legacyradio':
            case 'noyes':
            case 'checkbox':
                return new CheckboxFieldStyler_1.CheckboxFieldStyler(name, index);
            default:
                return new DefaultFieldStyler_1.DefaultFieldStyler(name, index);
        }
    };
    return FieldStylerFactory;
}());
exports.FieldStylerFactory = FieldStylerFactory;
//# sourceMappingURL=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