/*
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 { __extends, __values } from "tslib";
import { DependencyObject } from "igniteui-angular-core";
import { INotifyPropertyChanged_$type, PropertyChangedEventArgs, runOn, delegateCombine, fromEnum, typeCast, delegateRemove, markType } from "igniteui-angular-core";
import { BrushCollection } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { Series } from "./Series";
import { PropertyUpdatedEventArgs } from "igniteui-angular-core";
import { ISupportsFillScale_$type } from "./ISupportsFillScale";
import { BrushCollectionUtil } from "igniteui-angular-core";
import { isNaN_, isInfinity } from "igniteui-angular-core";
/**
 * @hidden
 */
var BrushScale = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(BrushScale, _super);
    function BrushScale() {
        var _this = _super.call(this) || this;
        _this.j = null;
        _this.o = null;
        _this.propertyChanged = null;
        _this.propertyUpdated = null;
        _this.q = 0;
        _this.p = 0;
        _this.o = new List$1(Series.$, 0);
        _this.brushes = new BrushCollection();
        var a = _this.brushes;
        a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.r));
        _this.propertyUpdated = delegateCombine(_this.propertyUpdated, function (b, c) { return _this.u(b, c.propertyName, c.oldValue, c.newValue); });
        return _this;
    }
    BrushScale.prototype.r = function (a, b) {
        var e_1, _a;
        try {
            for (var _b = __values(fromEnum(this.o)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                c.mh(false);
                c.lh();
                c.lo();
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
    };
    BrushScale.prototype.s = function () {
        var e_2, _a;
        if (isNaN_(this.q) || isNaN_(this.p)) {
            try {
                for (var _b = __values(fromEnum(this.o)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var a = _c.value;
                    if (typeCast(ISupportsFillScale_$type, a) !== null) {
                        a.updateFillScaleGlobals();
                    }
                }
            }
            catch (e_2_1) {
                e_2 = { error: e_2_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_2)
                        throw e_2.error;
                }
            }
        }
    };
    Object.defineProperty(BrushScale.prototype, "brushes", {
        get: function () {
            return this.j;
        },
        set: function (a) {
            var b = this.j;
            if (this.j != null) {
                var c = this.j;
                c.collectionChanged = delegateRemove(c.collectionChanged, runOn(this, this.r));
            }
            this.j = a;
            if (this.j != null) {
                var d = this.j;
                d.collectionChanged = delegateCombine(d.collectionChanged, runOn(this, this.r));
            }
            this.notifySeries();
        },
        enumerable: false,
        configurable: true
    });
    BrushScale.prototype.registerSeries = function (a) {
        var b = this.o.contains(a);
        if (!b) {
            this.o.add(a);
        }
    };
    BrushScale.prototype.unregisterSeries = function (a) {
        var b = this.o.contains(a);
        if (b) {
            this.o.remove(a);
        }
    };
    BrushScale.prototype.getBrush = function (a) {
        if (this.brushes == null || a < 0 || a >= this.brushes.count) {
            return null;
        }
        return this.brushes.item(a);
    };
    BrushScale.prototype.get_isReady = function () {
        return true;
    };
    Object.defineProperty(BrushScale.prototype, "isReady", {
        get: function () {
            return this.get_isReady();
        },
        enumerable: false,
        configurable: true
    });
    BrushScale.prototype.ab = function (a) {
        if (this.brushes == null || this.brushes.count == 0 || a < 0) {
            return null;
        }
        return BrushCollectionUtil.b(this.brushes, a);
    };
    BrushScale.prototype.v = function (a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        if (this.propertyUpdated != null) {
            this.propertyUpdated(this, new PropertyUpdatedEventArgs(a, b, c));
        }
    };
    BrushScale.prototype.u = function (a, b, c, d) {
        this.notifySeries();
    };
    BrushScale.prototype.notifySeries = function () {
        var e_3, _a;
        try {
            for (var _b = __values(fromEnum(this.o)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var a = _c.value;
                a.lj();
                a.mh(false);
                a.lh();
                a.lo();
            }
        }
        catch (e_3_1) {
            e_3 = { error: e_3_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_3)
                    throw e_3.error;
            }
        }
    };
    BrushScale.prototype.z = function (a, b) {
        if (!isNaN_(a) && !isInfinity(a)) {
            if (isNaN_(this.q)) {
                this.q = a;
            }
            else {
                this.q = Math.min(a, this.q);
            }
        }
        if (!isNaN_(b) && !isInfinity(b)) {
            if (isNaN_(this.p)) {
                this.p = b;
            }
            else {
                this.p = Math.max(b, this.p);
            }
        }
    };
    BrushScale.prototype.x = function () {
        this.q = NaN;
        this.p = NaN;
    };
    BrushScale.prototype.get_isBrushScale = function () {
        return true;
    };
    Object.defineProperty(BrushScale.prototype, "isBrushScale", {
        get: function () {
            return this.get_isBrushScale();
        },
        enumerable: false,
        configurable: true
    });
    BrushScale.$t = markType(BrushScale, 'BrushScale', DependencyObject.$, [INotifyPropertyChanged_$type]);
    return BrushScale;
}(DependencyObject));
export { BrushScale };
