/*
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 } from "tslib";
import { Base, markType } from "igniteui-angular-core";
import { IDomainChartToolbarProvider_$type } from "./IDomainChartToolbarProvider";
import { ToolCommandStateChanged } from "igniteui-angular-core";
import { ValueModeCollection } from "./ValueModeCollection";
import { BrushCollection } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-core";
/**
 * @hidden
 */
var DomainChartToolbarProvider = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(DomainChartToolbarProvider, _super);
    function DomainChartToolbarProvider() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.a = false;
        _this._container = null;
        _this._commandChanged = null;
        return _this;
    }
    Object.defineProperty(DomainChartToolbarProvider.prototype, "container", {
        get: function () {
            return this._container;
        },
        set: function (a) {
            this._container = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DomainChartToolbarProvider.prototype, "commandChanged", {
        get: function () {
            return this._commandChanged;
        },
        set: function (a) {
            this._commandChanged = a;
        },
        enumerable: false,
        configurable: true
    });
    DomainChartToolbarProvider.prototype.getDesiredToolbarActions = function (a, b) {
        for (var c = 0; c < b.length; c++) {
            this.c(a, b[c]);
        }
        return b;
    };
    DomainChartToolbarProvider.prototype.c = function (a, b) {
        if (b.actions != null && b.actions.length > 0) {
            for (var c = 0; c < b.actions.length; c++) {
                this.c(a, b.actions[c]);
            }
        }
        switch (b.name) {
            case "ShowCrosshairs":
                {
                    var d = b;
                    d.isChecked = a.a9 != 1;
                }
                break;
            case "ShowGridlines":
                {
                    var e = b;
                    e.isChecked = a.fj;
                }
                break;
            case "ShowValueLabels":
                {
                    var f = b;
                    f.isChecked = a.fj;
                }
                break;
            case "ShowLastValueLabel":
                {
                    var g = b;
                    g.isChecked = a.ft;
                }
                break;
            case "MinValue":
                {
                    if (a.du != null) {
                        var h = b;
                        for (var i = 0; i < a.du.count; i++) {
                            if (a.du._inner[i] == 4) {
                                h.isChecked = true;
                                break;
                            }
                        }
                    }
                }
                break;
            case "MaxValue":
                {
                    if (a.du != null) {
                        var j = b;
                        for (var k = 0; k < a.du.count; k++) {
                            if (a.du._inner[k] == 5) {
                                j.isChecked = true;
                                break;
                            }
                        }
                    }
                }
                break;
            case "Average":
                {
                    if (a.du != null) {
                        var l = b;
                        for (var m = 0; m < a.du.count; m++) {
                            if (a.du._inner[m] == 6) {
                                l.isChecked = true;
                                break;
                            }
                        }
                    }
                }
                break;
            case "SeriesAvg":
                {
                    if (a.du != null) {
                        var n = b;
                        for (var o = 0; o < a.du.count; o++) {
                            if (a.du._inner[o] == 3) {
                                n.isChecked = true;
                                break;
                            }
                        }
                    }
                }
                break;
        }
        this.d(a, b);
    };
    DomainChartToolbarProvider.prototype.d = function (a, b) {
    };
    DomainChartToolbarProvider.prototype.onToolCommandExecuting = function (a, b) {
        if (b.commandId == null) {
            return;
        }
        this.a = true;
        switch (b.commandId) {
            case "ZoomReset":
                this.u(a, b);
                break;
            case "ZoomIn":
                this.s(a, b);
                break;
            case "ZoomOut":
                this.t(a, b);
                break;
            case "ShowCrosshairs":
                this.g(a, b);
                break;
            case "ShowGridlines":
                this.i(a, b);
                break;
            case "MaxValue":
                this.l(a, b);
                break;
            case "MinValue":
                this.m(a, b);
                break;
            case "Average":
                this.f(a, b);
                break;
            case "Exponential":
                this.h(a, b);
                break;
            case "Linear":
                this.j(a, b);
                break;
            case "Logarithmic":
                this.k(a, b);
                break;
            case "NoTrends":
                this.n(a, b);
                break;
            case "SeriesAvg":
                this.o(a, b);
                break;
            case "ShowValueLabels":
                this.q(a, b);
                break;
            case "ShowLastValueLabel":
                this.p(a, b);
                break;
        }
        this.a = false;
    };
    DomainChartToolbarProvider.prototype.onTargetPropertyChanged = function (a, b, c, d) {
        if (this.a) {
            return;
        }
        switch (b) {
            case "CrosshairsDisplayMode":
                if (a.a9 == 1) {
                    this.e("ShowCrosshairs", 2, false);
                }
                else {
                    this.e("ShowCrosshairs", 2, true);
                }
                break;
            case "AutoCalloutsVisible":
                this.e("ShowValueLabels", 2, a.fj);
                break;
            case "FinalValueAnnotationsVisible":
                this.e("ShowLastValueLabel", 2, a.ft);
                break;
        }
        this.r(a, b, c, d);
    };
    DomainChartToolbarProvider.prototype.r = function (a, b, c, d) {
    };
    DomainChartToolbarProvider.prototype.e = function (a, b, c) {
        if (this.commandChanged != null) {
            this.commandChanged(((function () {
                var $ret = new ToolCommandStateChanged();
                $ret.c = a;
                $ret.a = b;
                $ret.b = c;
                return $ret;
            })()));
        }
    };
    DomainChartToolbarProvider.prototype.b = function (a, b) {
        var e = a.argumentsList;
        for (var d = 0; d < e.length; d++) {
            var c = e[d];
            if (c.argumentName == b) {
                return c.value;
            }
        }
        return false;
    };
    DomainChartToolbarProvider.prototype.g = function (a, b) {
        if (this.b(b, "ShowCrosshairs")) {
            a.a9 = 0;
            a.fm = true;
        }
        else {
            a.a9 = 1;
        }
    };
    DomainChartToolbarProvider.prototype.i = function (a, b) {
    };
    DomainChartToolbarProvider.prototype.h = function (a, b) {
        if (this.b(b, "Exponential")) {
            a.dq = 7;
        }
        else {
            a.dq = 0;
        }
    };
    DomainChartToolbarProvider.prototype.j = function (a, b) {
        if (this.b(b, "Linear")) {
            a.dq = 1;
        }
        else {
            a.dq = 0;
        }
    };
    DomainChartToolbarProvider.prototype.k = function (a, b) {
        if (this.b(b, "Logarithmic")) {
            a.dq = 6;
        }
        else {
            a.dq = 0;
        }
    };
    DomainChartToolbarProvider.prototype.n = function (a, b) {
        if (this.b(b, "NoTrends")) {
            a.dq = 0;
        }
    };
    DomainChartToolbarProvider.prototype.l = function (a, b) {
        if (this.b(b, "MaxValue")) {
            if (a.du == null) {
                a.du = new ValueModeCollection();
            }
            if (a.ai == null) {
                a.ai = new BrushCollection();
            }
            a.du.add(5);
            a.ai.add(BrushUtil.g(255, 99, 208, 0));
        }
        else {
            for (var c = 0; c < a.du.count; c++) {
                if (a.du._inner[c] == 5) {
                    a.du.removeAt(c);
                    a.ai.removeAt(c);
                    c--;
                }
            }
        }
    };
    DomainChartToolbarProvider.prototype.m = function (a, b) {
        if (this.b(b, "MinValue")) {
            if (a.du == null) {
                a.du = new ValueModeCollection();
            }
            if (a.ai == null) {
                a.ai = new BrushCollection();
            }
            a.du.add(4);
            a.ai.add(BrushUtil.g(255, 246, 93, 80));
        }
        else {
            for (var c = 0; c < a.du.count; c++) {
                if (a.du._inner[c] == 4) {
                    a.du.removeAt(c);
                    a.ai.removeAt(c);
                    c--;
                }
            }
        }
    };
    DomainChartToolbarProvider.prototype.f = function (a, b) {
        if (this.b(b, "Average")) {
            if (a.du == null) {
                a.du = new ValueModeCollection();
            }
            if (a.ai == null) {
                a.ai = new BrushCollection();
            }
            a.du.add(6);
            a.ai.add(BrushUtil.g(255, 248, 173, 118));
        }
        else {
            for (var c = 0; c < a.du.count; c++) {
                if (a.du._inner[c] == 6) {
                    a.du.removeAt(c);
                    a.ai.removeAt(c);
                    c--;
                }
            }
        }
    };
    DomainChartToolbarProvider.prototype.o = function (a, b) {
        if (this.b(b, "SeriesAvg")) {
            if (a.du == null) {
                a.du = new ValueModeCollection();
            }
            a.du.add(3);
        }
        else {
            for (var c = 0; c < a.du.count; c++) {
                if (a.du._inner[c] == 3) {
                    a.du.removeAt(c);
                    c--;
                }
            }
        }
    };
    DomainChartToolbarProvider.prototype.q = function (a, b) {
        if (this.b(b, "ShowValueLabels")) {
            a.fj = true;
        }
        else {
            a.fj = false;
        }
    };
    DomainChartToolbarProvider.prototype.p = function (a, b) {
        if (this.b(b, "ShowLastValueLabel")) {
            a.ft = true;
            a.gb = true;
        }
        else {
            a.ft = false;
        }
    };
    DomainChartToolbarProvider.prototype.s = function (a, b) {
        a.tq(0.05);
    };
    DomainChartToolbarProvider.prototype.t = function (a, b) {
        a.tr(0.05);
    };
    DomainChartToolbarProvider.prototype.u = function (a, b) {
        a.tm();
    };
    DomainChartToolbarProvider.$t = markType(DomainChartToolbarProvider, 'DomainChartToolbarProvider', Base.$, [IDomainChartToolbarProvider_$type]);
    return DomainChartToolbarProvider;
}(Base));
export { DomainChartToolbarProvider };
