/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { Base, INotifyPropertyChanged_$type, PropertyChangedEventArgs, enumGetBox, markType, String_$type, typeCast } from "igniteui-webcomponents-core";
import { PropertyEditorValueType_$type } from "./PropertyEditorValueType";
import { ObservableCollection$1 } from "igniteui-webcomponents-core";
import { List$1 } from "igniteui-webcomponents-core";
import { stringEndsWith, stringContains, stringReplace } from "igniteui-webcomponents-core";
import { stringSplit } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
var PropertyEditorPropertyDescription = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(PropertyEditorPropertyDescription, _super);
    function PropertyEditorPropertyDescription() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.u = null;
        _this.s = null;
        _this.j = 0;
        _this.t = null;
        _this.l = false;
        _this.r = null;
        _this.a = null;
        _this.b = null;
        _this.o = null;
        _this.f = null;
        _this.h = null;
        _this.e = null;
        _this.propertyChanged = null;
        return _this;
    }
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "y", {
        get: function () {
            return this.u;
        },
        set: function (a) {
            var b = this.u;
            this.u = a;
            if (this.u != b) {
                this.z("PropertyPath", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "w", {
        get: function () {
            return this.s;
        },
        set: function (a) {
            var b = this.s;
            this.s = a;
            if (this.s != b) {
                this.z("Label", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "k", {
        get: function () {
            return this.j;
        },
        set: function (a) {
            var b = this.j;
            this.j = a;
            if (this.j != b) {
                this.z("ValueType", enumGetBox(PropertyEditorValueType_$type, b), enumGetBox(PropertyEditorValueType_$type, a));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "x", {
        get: function () {
            return this.t;
        },
        set: function (a) {
            var b = this.t;
            this.t = a;
            if (this.t != b) {
                this.z("PropertyDescriptionType", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "n", {
        get: function () {
            return this.l;
        },
        set: function (a) {
            var b = this.l;
            this.l = a;
            if (this.l != b) {
                this.z("ShouldOverrideDefaultEditor", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "v", {
        get: function () {
            return this.r;
        },
        set: function (a) {
            var b = this.r;
            this.r = a;
            if (this.r != b) {
                this.z("ElementDescriptionType", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "c", {
        get: function () {
            return this.a;
        },
        set: function (a) {
            var b = this.a;
            this.a = a;
            if (this.a != b) {
                this.z("DropDownNames", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "d", {
        get: function () {
            return this.b;
        },
        set: function (a) {
            var b = this.b;
            this.b = a;
            if (this.b != b) {
                this.z("DropDownValues", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "q", {
        get: function () {
            return this.o;
        },
        set: function (a) {
            var b = this.o;
            this.o = a;
            if (this.o != b) {
                this.z("PrimitiveValue", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "g", {
        get: function () {
            return this.f;
        },
        set: function (a) {
            var b = this.f;
            this.f = a;
            if (this.f != b) {
                this.z("ComplexValue", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorPropertyDescription.prototype, "i", {
        get: function () {
            return this.h;
        },
        set: function (a) {
            var b = this.h;
            this.h = a;
            if (this.h != b) {
                this.z("ComplexValues", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    PropertyEditorPropertyDescription.prototype.z = function (a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
    };
    PropertyEditorPropertyDescription.prototype.m = function (a) {
        var b = false;
        if (a == null) {
            return false;
        }
        if (a.c != null && (this.c == null || !this.n)) {
            this.c = a.c;
        }
        if (a.d != null && (this.d == null || !this.n)) {
            this.d = a.d;
        }
        if (a.v != null && (this.v == null || !this.n)) {
            this.v = a.v;
        }
        if (a.x != null && (this.x == null || !this.n)) {
            this.x = a.x;
        }
        if (a.k != 0 && (this.k == 0 || !this.n)) {
            this.k = a.k;
            b = true;
        }
        return true;
    };
    PropertyEditorPropertyDescription.prototype.p = function (a, b) {
        if (b) {
            return this.e;
        }
        if (this.e != null) {
            return this.e.d(a, false);
        }
        return null;
    };
    PropertyEditorPropertyDescription.$t = markType(PropertyEditorPropertyDescription, 'PropertyEditorPropertyDescription', Base.$, [INotifyPropertyChanged_$type]);
    return PropertyEditorPropertyDescription;
}(Base));
export { PropertyEditorPropertyDescription };
/**
 * @hidden
 */
var PropertyEditorDescriptionObject = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(PropertyEditorDescriptionObject, _super);
    function PropertyEditorDescriptionObject() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.b = null;
        _this.a = null;
        return _this;
    }
    PropertyEditorDescriptionObject.$t = markType(PropertyEditorDescriptionObject, 'PropertyEditorDescriptionObject');
    return PropertyEditorDescriptionObject;
}(Base));
export { PropertyEditorDescriptionObject };
/**
 * @hidden
 */
var PropertyEditorDescriptionObjectCollection = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(PropertyEditorDescriptionObjectCollection, _super);
    function PropertyEditorDescriptionObjectCollection() {
        return _super.call(this, PropertyEditorDescriptionObject.$, 0) || this;
    }
    PropertyEditorDescriptionObjectCollection.$t = markType(PropertyEditorDescriptionObjectCollection, 'PropertyEditorDescriptionObjectCollection', ObservableCollection$1.$.specialize(PropertyEditorDescriptionObject.$));
    return PropertyEditorDescriptionObjectCollection;
}(ObservableCollection$1));
export { PropertyEditorDescriptionObjectCollection };
/**
 * @hidden
 */
var PropertyEditorPropertyDescriptionCollection = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(PropertyEditorPropertyDescriptionCollection, _super);
    function PropertyEditorPropertyDescriptionCollection() {
        return _super.call(this, PropertyEditorPropertyDescription.$, 0) || this;
    }
    PropertyEditorPropertyDescriptionCollection.$t = markType(PropertyEditorPropertyDescriptionCollection, 'PropertyEditorPropertyDescriptionCollection', ObservableCollection$1.$.specialize(PropertyEditorPropertyDescription.$));
    return PropertyEditorPropertyDescriptionCollection;
}(ObservableCollection$1));
export { PropertyEditorPropertyDescriptionCollection };
/**
 * @hidden
 */
var PropertyEditorDataSource = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(PropertyEditorDataSource, _super);
    function PropertyEditorDataSource() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.i = null;
        _this.a = null;
        _this.f = null;
        _this.propertyChanged = null;
        return _this;
    }
    Object.defineProperty(PropertyEditorDataSource.prototype, "l", {
        get: function () {
            return this.i;
        },
        set: function (a) {
            var b = this.i;
            this.i = a;
            this.n("DescriptionType", b, this.i);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorDataSource.prototype, "b", {
        get: function () {
            return this.a;
        },
        set: function (a) {
            var b = this.a;
            this.a = a;
            this.n("Context", b, this.a);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(PropertyEditorDataSource.prototype, "g", {
        get: function () {
            return this.f;
        },
        set: function (a) {
            var b = this.f;
            this.f = a;
            this.n("Data", b, this.f);
        },
        enumerable: true,
        configurable: true
    });
    PropertyEditorDataSource.prototype.n = function (a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        this.o(a, b, c);
    };
    PropertyEditorDataSource.prototype.o = function (a, b, c) {
        switch (a) {
            case "DescriptionType":
                this.p();
                break;
            case "Context":
                this.p();
                break;
        }
    };
    PropertyEditorDataSource.prototype.e = function (a) {
        var _this = this;
        var b = new PropertyEditorPropertyDescription();
        b.y = a.propertyName;
        b.k = this.h(a);
        b.x = a.specificExternalType != null ? a.specificExternalType : a.specificType;
        if (a.knownType == 9) {
            b.v = a.collectionElementType;
            b.e = ((function () {
                var $ret = new PropertyEditorDataSource();
                $ret.b = _this.a;
                $ret.l = b.v;
                return $ret;
            })());
        }
        if (b.k == 8) {
            b.e = ((function () {
                var $ret = new PropertyEditorDataSource();
                $ret.b = _this.a;
                $ret.l = b.x;
                return $ret;
            })());
        }
        if (b.k == 15) {
            b.c = this.a.b(this.l, b.y);
            b.d = b.d;
        }
        return b;
    };
    PropertyEditorDataSource.prototype.h = function (a) {
        switch (a.knownType) {
            case 10: return 10;
            case 7: return 7;
            case 4: return 4;
            case 6: return 6;
            case 9: return 9;
            case 5: return 5;
            case 16: return 14;
            case 20: return 18;
            case 15: return 0;
            case 3: return 3;
            case 19: return 17;
            case 8:
                if (a.specificExternalType == "string") {
                    return 15;
                }
                return 8;
            case 13: return 0;
            case 18: return 0;
            case 1: return 1;
            case 11: return 11;
            case 14: return 13;
            case 12: return 12;
            case 2: return 2;
            case 21: return 19;
            case 17: return 0;
            case 0: return 0;
        }
        return 0;
    };
    PropertyEditorDataSource.prototype.p = function () {
        var a = new PropertyEditorPropertyDescriptionCollection();
        if (this.l != null && this.b != null) {
            var b = this.b.a(this.l);
            if (b == null) {
                return;
            }
            for (var c = 0; c < b.length; c++) {
                if (stringEndsWith(b[c], "@names")) {
                    continue;
                }
                var d = this.b.d(this.l, b[c]);
                var e = this.e(d);
                if (e.k == 0) {
                    continue;
                }
                a.add(e);
            }
        }
        this.g = a;
    };
    PropertyEditorDataSource.prototype.d = function (a, b) {
        if (a == null) {
            return null;
        }
        var c = stringSplit(a, ['.', '['], 0);
        var d = new List$1(String_$type, 1, c);
        var e = null;
        var f = null;
        var g = null;
        while (d.count > 0) {
            var h = d._inner[0];
            d.removeAt(0);
            var i = false;
            if (stringContains(h, "]")) {
                h = stringReplace(h, "]", "");
                i = true;
                if (stringContains(h, "as")) {
                    var j = h.indexOf("as");
                    g = h.substr(0, j).trim();
                    f = h.substr(j + 2).trim();
                }
                if (f != null && f != this.l) {
                    var k = this.c();
                    k.l = f;
                    e = k;
                    continue;
                }
            }
            if (b) {
                i = true;
            }
            if (e != null && typeCast(PropertyEditorPropertyDescription.$, e) !== null) {
                var l = e.p(h, i);
                if (l == null) {
                    return null;
                }
                e = l;
            }
            else {
                if (e != null) {
                    var m = e;
                    var n = m.d(h, i);
                    if (n == null) {
                        return null;
                    }
                    e = n;
                }
                else {
                    if (this.g == null) {
                        return null;
                    }
                    for (var o = 0; o < this.g.count; o++) {
                        if (Base.equalsStatic(this.g._inner[o].y, h)) {
                            e = this.g._inner[o];
                            break;
                        }
                    }
                    if (e == null) {
                        return null;
                    }
                }
            }
        }
        return typeCast(PropertyEditorPropertyDescription.$, e);
    };
    PropertyEditorDataSource.prototype.c = function () {
        var _this = this;
        return ((function () {
            var $ret = new PropertyEditorDataSource();
            $ret.b = _this.b;
            $ret.l = _this.l;
            return $ret;
        })());
    };
    PropertyEditorDataSource.$t = markType(PropertyEditorDataSource, 'PropertyEditorDataSource', Base.$, [INotifyPropertyChanged_$type]);
    return PropertyEditorDataSource;
}(Base));
export { PropertyEditorDataSource };
//# sourceMappingURL=PropertyEditorPropertyDescription_combined.js.map
