/*
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 { IFastItemColumnInternal_$type } from "./IFastItemColumnInternal";
import { IFastItemColumn$1_$type } from "./IFastItemColumn$1";
import { Base, fromEnum, Date_$type, markType, TypeRegistrar } from "./type";
import { List$1 } from "./List$1";
import { NotImplementedException } from "./NotImplementedException";
import { FastItemColumn } from "./FastItemColumn";
import { dateMinValue } from "./date";
var FastItemDateTimeColumn = /** @class */ (function (_super) {
    tslib_1.__extends(FastItemDateTimeColumn, _super);
    function FastItemDateTimeColumn(a, b, c, d) {
        var _this = _super.call(this) || this;
        _this.k = null;
        _this.c = false;
        _this.a = null;
        _this._propertyName = null;
        _this.e = false;
        _this.d = false;
        _this.i = new Date();
        _this.h = new Date();
        _this.g = null;
        _this.k = c;
        _this.c = d;
        _this.propertyName = b;
        _this.b = a;
        return _this;
    }
    Object.defineProperty(FastItemDateTimeColumn.prototype, "b", {
        get: function () {
            return this.a;
        },
        set: function (a) {
            this.a = a;
            this.reset();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FastItemDateTimeColumn.prototype, "propertyName", {
        get: function () {
            return this._propertyName;
        },
        set: function (a) {
            this._propertyName = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FastItemDateTimeColumn.prototype, "minimum", {
        get: function () {
            if (!this.e && this.g != null) {
                try {
                    for (var _a = tslib_1.__values(fromEnum(this.g)), _b = _a.next(); !_b.done; _b = _a.next()) {
                        var a = _b.value;
                        if (a < this.i) {
                            this.i = a;
                        }
                    }
                }
                catch (e_1_1) { e_1 = { error: e_1_1 }; }
                finally {
                    try {
                        if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
                    }
                    finally { if (e_1) throw e_1.error; }
                }
                if (this.g.count > 0) {
                    this.e = true;
                }
            }
            return this.i;
            var e_1, _c;
        },
        set: function (a) {
            this.i = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FastItemDateTimeColumn.prototype, "maximum", {
        get: function () {
            if (!this.d && this.g != null) {
                try {
                    for (var _a = tslib_1.__values(fromEnum(this.g)), _b = _a.next(); !_b.done; _b = _a.next()) {
                        var a = _b.value;
                        if (a > this.h) {
                            this.h = a;
                        }
                    }
                }
                catch (e_2_1) { e_2 = { error: e_2_1 }; }
                finally {
                    try {
                        if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
                    }
                    finally { if (e_2) throw e_2.error; }
                }
                if (this.g.count > 0) {
                    this.d = true;
                }
            }
            return this.h;
            var e_2, _c;
        },
        set: function (a) {
            this.h = a;
        },
        enumerable: true,
        configurable: true
    });
    FastItemDateTimeColumn.prototype.item = function (a, b) {
        if (arguments.length === 2) {
            return b;
        }
        else {
            return this.g._inner[a];
        }
    };
    FastItemDateTimeColumn.prototype.getEnumerator = function () {
        return this.g.getEnumerator();
    };
    FastItemDateTimeColumn.prototype.getEnumeratorObject = function () {
        return this.g.getEnumerator();
    };
    FastItemDateTimeColumn.prototype.contains = function (a) {
        return this.g.contains(a);
    };
    FastItemDateTimeColumn.prototype.copyTo = function (a, b) {
        this.g.copyTo(a, b);
    };
    Object.defineProperty(FastItemDateTimeColumn.prototype, "count", {
        get: function () {
            return this.g.count;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(FastItemDateTimeColumn.prototype, "isReadOnly", {
        get: function () {
            return true;
        },
        enumerable: true,
        configurable: true
    });
    FastItemDateTimeColumn.prototype.indexOf = function (a) {
        return this.g.indexOf(a);
    };
    FastItemDateTimeColumn.prototype.add = function (a) {
        throw new NotImplementedException(0);
    };
    FastItemDateTimeColumn.prototype.clear = function () {
        throw new NotImplementedException(0);
    };
    FastItemDateTimeColumn.prototype.remove = function (a) {
        throw new NotImplementedException(0);
    };
    FastItemDateTimeColumn.prototype.insert = function (a, b) {
        throw new NotImplementedException(0);
    };
    FastItemDateTimeColumn.prototype.removeAt = function (a) {
        throw new NotImplementedException(0);
    };
    FastItemDateTimeColumn.prototype.reset = function () {
        this.g = null;
        this.e = false;
        this.d = false;
        return this.b != null ? this.insertRange(0, this.b.count) : true;
    };
    FastItemDateTimeColumn.prototype.insertRange = function (a, b) {
        var c = new Array(b);
        var source_ = this.a.asArray();
        var item_;
        var d = this.minimum;
        var e = this.maximum;
        var f;
        var g = 0;
        var h = this.k;
        var propertyName_ = this._propertyName;
        var sourceItem_ = null;
        if (this.k != null || this.c) {
            for (var i_ = a; i_ < a + b; ++i_) {
                sourceItem_ = source_[i_];
                item_ = (source_[i_][propertyName_]);
                if (this.c) {
                    if ((typeof (item_) == 'function')) {
                        item_ = item_.apply(sourceItem_);
                    }
                }
                if (h != null) {
                    item_ = h(item_);
                }
                f = item_ == null ? (new Date()) : item_;
                if (!this.e) {
                    d = f;
                    this.e = true;
                }
                else if (f < d) {
                    d = f;
                }
                if (!this.d) {
                    e = f;
                    this.d = true;
                }
                else if (f > e) {
                    e = f;
                }
                c[g] = f;
                g++;
            }
        }
        else {
            for (var i_ = a; i_ < a + b; ++i_) {
                item_ = (source_[i_][propertyName_]);
                f = item_ == null ? (new Date()) : item_;
                if (!this.e) {
                    d = f;
                    this.e = true;
                }
                else if (f < d) {
                    d = f;
                }
                if (!this.d) {
                    e = f;
                    this.d = true;
                }
                else if (f > e) {
                    e = f;
                }
                c[g] = f;
                g++;
            }
        }
        this.minimum = d;
        this.maximum = e;
        if (this.g == null) {
            this.g = new List$1(Date_$type, 1, c);
        }
        else {
            this.g.t(a, c);
        }
        return true;
    };
    FastItemDateTimeColumn.prototype.removeRange = function (a, b) {
        for (var c = a; c < a + b; ++c) {
            if (+(this.item(c)) == +(this.minimum)) {
                this.e = false;
            }
            if (+(this.item(c)) == +(this.maximum)) {
                this.d = false;
            }
        }
        this.g.v(a, b);
        return true;
    };
    FastItemDateTimeColumn.prototype.n = function (a, b) {
        if (+a != +(dateMinValue())) {
            if (+b != +(dateMinValue())) {
                this.minimum = b < this.minimum ? b : this.minimum;
                this.maximum = b > this.maximum ? b : this.maximum;
            }
            return;
        }
        this.minimum = b < this.minimum ? b : this.minimum;
        this.maximum = b > this.maximum ? b : this.maximum;
    };
    FastItemDateTimeColumn.prototype.replaceRange = function (a, b) {
        var c = false;
        for (var d = 0; d < b; ++d) {
            var e = this.g._inner[a + d];
            var f = this.j(this.b.item(a + d));
            if (+e != +f) {
                this.g._inner[a + d] = f;
                c = true;
                this.n(e, f);
            }
        }
        return c;
    };
    FastItemDateTimeColumn.prototype.j = function (a) {
        if (a == null) {
            return dateMinValue();
        }
        var sourceItem_ = a;
        var from_ = a;
        var propertyName_ = this._propertyName;
        a = from_[propertyName_];
        if (this.c) {
            from_ = a;
            if ((typeof (from_) == 'function')) {
                a = from_.apply(sourceItem_);
            }
        }
        if (this.k != null) {
            a = this.k(a);
        }
        if (a == null) {
            return dateMinValue();
        }
        return a;
    };
    Object.defineProperty(FastItemDateTimeColumn.prototype, "mayContainUnknowns", {
        get: function () {
            return true;
        },
        enumerable: true,
        configurable: true
    });
    FastItemDateTimeColumn.prototype.f = function () {
        return FastItemColumn.e(this.g, function (a, b) {
            var c = a;
            var d = b;
            if (c < d) {
                return -1;
            }
            if (c > d) {
                return 1;
            }
            return 0;
        });
    };
    FastItemDateTimeColumn.prototype.asArray = function () {
        return this.g.asArray();
    };
    FastItemDateTimeColumn.prototype.getItem = function (a) {
        return this.item(a);
    };
    FastItemDateTimeColumn.m = function () {
        TypeRegistrar.register("FastItemDateTimeColumn", FastItemDateTimeColumn.$);
    };
    FastItemDateTimeColumn.$t = markType(FastItemDateTimeColumn, 'FastItemDateTimeColumn', Base.$, [IFastItemColumnInternal_$type, IFastItemColumn$1_$type.specialize(Date_$type)]);
    return FastItemDateTimeColumn;
}(Base));
export { FastItemDateTimeColumn };
//# sourceMappingURL=FastItemDateTimeColumn.js.map