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 __values = (this && this.__values) || function(o) {
    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
    if (m) return m.call(o);
    if (o && typeof o.length === "number") return {
        next: function () {
            if (o && i >= o.length) o = void 0;
            return { value: o && o[i++], done: !o };
        }
    };
    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
import BaseRenderer from "./base-renderer";
var ManyToManyTagRenderer = (function (_super) {
    __extends(ManyToManyTagRenderer, _super);
    function ManyToManyTagRenderer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ManyToManyTagRenderer.prototype.init = function (params) {
        this.params = params;
        this.setupGui();
    };
    ManyToManyTagRenderer.prototype.setupContentGui = function () {
        var _a;
        if (this.params.data == null) {
            return '';
        }
        else {
            var allFieldPath = this.params.colDef.field.split('.');
            var arrayField_1 = (_a = this.params.colDef.floatingFilterComponentParams.arrayField) !== null && _a !== void 0 ? _a : this.params.colDef.field.split('.')[0];
            var arrayIndex = allFieldPath.findIndex(function (x) { return x == arrayField_1; });
            var fieldPath_1 = allFieldPath.slice(arrayIndex + 1);
            var arrayName = allFieldPath.slice(0, arrayIndex + 1);
            var array_1 = this.params.data;
            arrayName.forEach(function (x) {
                if (array_1 != null) {
                    array_1 = array_1[x];
                }
            });
            if (array_1 == null) {
                return "";
            }
            return array_1.map(function (element) {
                var e_1, _a;
                var fieldValue = element;
                var enumerationType;
                try {
                    for (var fieldPath_2 = __values(fieldPath_1), fieldPath_2_1 = fieldPath_2.next(); !fieldPath_2_1.done; fieldPath_2_1 = fieldPath_2.next()) {
                        var fieldName = fieldPath_2_1.value;
                        if (fieldName == "denomination") {
                            enumerationType = fieldValue;
                        }
                        if (fieldValue == null)
                            return '';
                        fieldValue = fieldValue[fieldName];
                    }
                }
                catch (e_1_1) { e_1 = { error: e_1_1 }; }
                finally {
                    try {
                        if (fieldPath_2_1 && !fieldPath_2_1.done && (_a = fieldPath_2.return)) _a.call(fieldPath_2);
                    }
                    finally { if (e_1) throw e_1.error; }
                }
                return "<ui-tag label=\"".concat(fieldValue, "\" text-color=\"").concat(enumerationType === null || enumerationType === void 0 ? void 0 : enumerationType.textColor, "\" background-color=\"").concat(enumerationType === null || enumerationType === void 0 ? void 0 : enumerationType.backgroundColor, "\" size=\"md\" type=\"solid\"></ui-tag>");
            }).join('');
        }
    };
    return ManyToManyTagRenderer;
}(BaseRenderer));
export { ManyToManyTagRenderer };

//# sourceMappingURL=many-to-many-tag-renderer.js.map
